@gengage/assistant-fe 0.6.28 → 0.6.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agent-ui-steps-Dc4ByfZo.js → agent-ui-steps-WKbTVOS4.js} +806 -770
- package/dist/agentic/index.js +1 -1
- package/dist/agentic/worker/rpc.d.ts +4 -1
- package/dist/agentic/worker.js +1 -1
- package/dist/agentic.iife.js +9 -9
- package/dist/{api-paths-PFiXYIey.js → api-paths-DdJr0XJ-.js} +1 -1
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +1 -1
- package/dist/chat.js +1 -1
- package/dist/{common-DyAcz33-.js → common-DlxPSm8-.js} +1 -1
- package/dist/common.js +5 -5
- package/dist/{connection-warning-nWEUv5bp.js → connection-warning-B5i-GYl3.js} +1 -1
- package/dist/{fastIntent-BiHAWBIa.js → fastIntent-BXTc79jM.js} +1 -1
- package/dist/index.js +10 -10
- package/dist/native.iife.js +1 -1
- package/dist/qna-runtime.js +1 -1
- package/dist/qna.iife.js +1 -1
- package/dist/qna.js +1 -1
- package/dist/{runtime-BIA5sGno.js → runtime-2RYLgot8.js} +3 -3
- package/dist/{runtime-BuzZUB0i.js → runtime-BMBmZgp7.js} +3 -3
- package/dist/{runtime-PHarcyNZ.js → runtime-DzSiJPPm.js} +3 -3
- package/dist/{simbut-CiPq-niE.js → simbut-Bwpt8E03.js} +1 -1
- package/dist/simbut.iife.js +1 -1
- package/dist/simbut.js +1 -1
- package/dist/{simrel-XWtKe-OG.js → simrel-D0G7CUSn.js} +1 -1
- package/dist/simrel-runtime.js +1 -1
- package/dist/simrel.iife.js +1 -1
- package/dist/simrel.js +2 -2
- package/dist/{widget-base-DSl6thOx.js → widget-base-XYJ0Ou6y.js} +1 -1
- package/package.json +1 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
var
|
|
3
|
-
function
|
|
1
|
+
import { t as ve } from "./request-response-cache-BxRsKGJ0.js";
|
|
2
|
+
var Ce = 120 * 1e3, Te = "gengage-agentic-ref";
|
|
3
|
+
function Ee({ namespace: t = Te, ttlMs: e = Ce, maxEntries: r = 100 } = {}) {
|
|
4
4
|
const n = /* @__PURE__ */ new Map();
|
|
5
5
|
async function o(u, l = {}) {
|
|
6
6
|
c();
|
|
7
|
-
const f =
|
|
7
|
+
const f = Ie(), d = l.kind || "pageRef", p = {
|
|
8
8
|
kind: d,
|
|
9
9
|
value: u,
|
|
10
10
|
expiresAt: Date.now() + (l.ttlMs || e)
|
|
11
11
|
};
|
|
12
12
|
for (n.set(f, p); n.size > r; ) n.delete(n.keys().next().value);
|
|
13
|
-
return await
|
|
13
|
+
return await Oe(t, f, p), {
|
|
14
14
|
kind: d,
|
|
15
15
|
id: f
|
|
16
16
|
};
|
|
@@ -21,7 +21,7 @@ function Te({ namespace: t = Ce, ttlMs: e = ve, maxEntries: r = 100 } = {}) {
|
|
|
21
21
|
const f = n.get(l) || await je(t, l);
|
|
22
22
|
if (f) {
|
|
23
23
|
if (f.expiresAt <= Date.now()) {
|
|
24
|
-
n.delete(l), await
|
|
24
|
+
n.delete(l), await Ft(t, l);
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
27
|
return n.set(l, f), f.value;
|
|
@@ -29,10 +29,10 @@ function Te({ namespace: t = Ce, ttlMs: e = ve, maxEntries: r = 100 } = {}) {
|
|
|
29
29
|
}
|
|
30
30
|
async function a(u) {
|
|
31
31
|
const l = typeof u == "string" ? u : u?.id;
|
|
32
|
-
l && (n.delete(l), await
|
|
32
|
+
l && (n.delete(l), await Ft(t, l));
|
|
33
33
|
}
|
|
34
34
|
async function s(u) {
|
|
35
|
-
if (
|
|
35
|
+
if (Pe(u)) return i(u);
|
|
36
36
|
if (Array.isArray(u)) return Promise.all(u.map((f) => s(f)));
|
|
37
37
|
if (!u || typeof u != "object") return u;
|
|
38
38
|
const l = await Promise.all(Object.entries(u).map(async ([f, d]) => [f, await s(d)]));
|
|
@@ -50,82 +50,90 @@ function Te({ namespace: t = Ce, ttlMs: e = ve, maxEntries: r = 100 } = {}) {
|
|
|
50
50
|
cleanup: c
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function Pe(t) {
|
|
54
54
|
return !!(t && typeof t == "object" && typeof t.kind == "string" && typeof t.id == "string");
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function Ie() {
|
|
57
57
|
return globalThis.crypto?.randomUUID ? globalThis.crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
58
58
|
}
|
|
59
|
-
async function
|
|
60
|
-
const n = await
|
|
61
|
-
n && (await
|
|
59
|
+
async function Oe(t, e, r) {
|
|
60
|
+
const n = await St(t);
|
|
61
|
+
n && (await ot(n.transaction("refs", "readwrite").objectStore("refs").put(r, e)), n.close());
|
|
62
62
|
}
|
|
63
63
|
async function je(t, e) {
|
|
64
|
-
const r = await
|
|
64
|
+
const r = await St(t);
|
|
65
65
|
if (!r) return;
|
|
66
|
-
const n = await
|
|
66
|
+
const n = await ot(r.transaction("refs", "readonly").objectStore("refs").get(e));
|
|
67
67
|
return r.close(), n;
|
|
68
68
|
}
|
|
69
|
-
async function
|
|
70
|
-
const r = await
|
|
71
|
-
r && (await
|
|
69
|
+
async function Ft(t, e) {
|
|
70
|
+
const r = await St(t);
|
|
71
|
+
r && (await ot(r.transaction("refs", "readwrite").objectStore("refs").delete(e)), r.close());
|
|
72
72
|
}
|
|
73
|
-
async function
|
|
73
|
+
async function St(t) {
|
|
74
74
|
if (!globalThis.indexedDB) return null;
|
|
75
75
|
try {
|
|
76
76
|
const e = globalThis.indexedDB.open(t, 1);
|
|
77
77
|
return e.onupgradeneeded = () => {
|
|
78
78
|
e.result.createObjectStore("refs");
|
|
79
|
-
}, await
|
|
79
|
+
}, await ot(e);
|
|
80
80
|
} catch {
|
|
81
81
|
return null;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
function
|
|
84
|
+
function ot(t) {
|
|
85
85
|
return new Promise((e, r) => {
|
|
86
86
|
t.onsuccess = () => e(t.result), t.onerror = () => r(t.error);
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
var Me = 12e4;
|
|
90
|
+
function Re(t) {
|
|
90
91
|
return !!t && typeof t == "object" && t.type === "rpc.result";
|
|
91
92
|
}
|
|
92
|
-
function
|
|
93
|
+
function Be(t) {
|
|
93
94
|
return !!t && typeof t == "object" && t.type === "rpc.req";
|
|
94
95
|
}
|
|
95
|
-
function
|
|
96
|
-
let
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
96
|
+
function wo(t = self, e = {}) {
|
|
97
|
+
let r = 1;
|
|
98
|
+
const n = /* @__PURE__ */ new Map(), o = e.timeoutMs === void 0 ? Me : Number.isFinite(e.timeoutMs) && e.timeoutMs > 0 ? e.timeoutMs : 0, i = (a) => {
|
|
99
|
+
const s = n.get(a);
|
|
100
|
+
if (s)
|
|
101
|
+
return n.delete(a), s.timer && clearTimeout(s.timer), s;
|
|
102
|
+
};
|
|
103
|
+
return t.addEventListener("message", (a) => {
|
|
104
|
+
const s = a.data;
|
|
105
|
+
if (!Re(s)) return;
|
|
106
|
+
const c = i(s.rpcId);
|
|
107
|
+
if (c) {
|
|
108
|
+
if (s.ok === !1) {
|
|
109
|
+
const u = typeof s.error == "object" ? s.error?.message : s.error;
|
|
110
|
+
c.reject(new Error(u || "RPC failed"));
|
|
106
111
|
return;
|
|
107
112
|
}
|
|
108
|
-
|
|
113
|
+
c.resolve(s.value);
|
|
109
114
|
}
|
|
110
|
-
}), function(
|
|
111
|
-
const
|
|
115
|
+
}), function(s, c, u) {
|
|
116
|
+
const l = r++;
|
|
112
117
|
return t.postMessage({
|
|
113
118
|
type: "rpc.req",
|
|
114
|
-
rpcId:
|
|
115
|
-
method:
|
|
116
|
-
payload:
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
resolve: (
|
|
120
|
-
reject:
|
|
121
|
-
}
|
|
119
|
+
rpcId: l,
|
|
120
|
+
method: s,
|
|
121
|
+
payload: c
|
|
122
|
+
}, u || []), new Promise((f, d) => {
|
|
123
|
+
const p = {
|
|
124
|
+
resolve: (m) => f(m),
|
|
125
|
+
reject: d
|
|
126
|
+
};
|
|
127
|
+
o && (p.timer = setTimeout(() => {
|
|
128
|
+
n.has(l) && (n.delete(l), d(/* @__PURE__ */ new Error(`RPC '${s}' timed out after ${o}ms`)));
|
|
129
|
+
}, o)), n.set(l, p);
|
|
122
130
|
});
|
|
123
131
|
};
|
|
124
132
|
}
|
|
125
|
-
function
|
|
133
|
+
function bo({ worker: t, tools: e = {}, beacon: r, confirmation: n, memory: o = Ne(), refStore: i }) {
|
|
126
134
|
t.addEventListener("message", (a) => {
|
|
127
135
|
const s = a.data;
|
|
128
|
-
|
|
136
|
+
Be(s) && $e(t, s, {
|
|
129
137
|
tools: e,
|
|
130
138
|
beacon: r,
|
|
131
139
|
confirmation: n,
|
|
@@ -134,9 +142,9 @@ function go({ worker: t, tools: e = {}, beacon: r, confirmation: n, memory: o =
|
|
|
134
142
|
});
|
|
135
143
|
});
|
|
136
144
|
}
|
|
137
|
-
async function
|
|
145
|
+
async function $e(t, e, r) {
|
|
138
146
|
try {
|
|
139
|
-
const n = await
|
|
147
|
+
const n = await We(e.method, e.payload, r);
|
|
140
148
|
t.postMessage({
|
|
141
149
|
type: "rpc.result",
|
|
142
150
|
rpcId: e.rpcId,
|
|
@@ -152,52 +160,52 @@ async function Me(t, e, r) {
|
|
|
152
160
|
});
|
|
153
161
|
}
|
|
154
162
|
}
|
|
155
|
-
var
|
|
156
|
-
function
|
|
163
|
+
var lt = /* @__PURE__ */ new Map(), qt = null;
|
|
164
|
+
function Ne() {
|
|
157
165
|
try {
|
|
158
166
|
if (typeof sessionStorage < "u") return sessionStorage;
|
|
159
167
|
} catch {
|
|
160
168
|
}
|
|
161
169
|
return {
|
|
162
|
-
getItem: (t) =>
|
|
170
|
+
getItem: (t) => lt.get(t) ?? null,
|
|
163
171
|
setItem: (t, e) => {
|
|
164
|
-
|
|
172
|
+
lt.set(t, e);
|
|
165
173
|
},
|
|
166
174
|
removeItem: (t) => {
|
|
167
|
-
|
|
175
|
+
lt.delete(t);
|
|
168
176
|
}
|
|
169
177
|
};
|
|
170
178
|
}
|
|
171
|
-
function
|
|
172
|
-
return
|
|
179
|
+
function Le() {
|
|
180
|
+
return qt ||= Ee(), qt;
|
|
173
181
|
}
|
|
174
|
-
function
|
|
182
|
+
function Fe(t) {
|
|
175
183
|
if (t && typeof t == "object" && typeof t.name == "string") return t;
|
|
176
184
|
throw new Error("tool.invoke requires { name, input }");
|
|
177
185
|
}
|
|
178
|
-
function
|
|
186
|
+
function qe(t) {
|
|
179
187
|
if (t && typeof t == "object" && t.key !== void 0) return t;
|
|
180
188
|
throw new Error("memory.get requires { key }");
|
|
181
189
|
}
|
|
182
|
-
function
|
|
190
|
+
function De(t) {
|
|
183
191
|
if (t && typeof t == "object" && t.key !== void 0) return t;
|
|
184
192
|
throw new Error("memory.set requires { key }");
|
|
185
193
|
}
|
|
186
|
-
function
|
|
194
|
+
function Ue(t) {
|
|
187
195
|
if (t && typeof t == "object" && t.key !== void 0) return t;
|
|
188
196
|
throw new Error("memory.remove requires { key }");
|
|
189
197
|
}
|
|
190
|
-
function
|
|
198
|
+
function ze(t) {
|
|
191
199
|
return !t || typeof t != "object" ? { value: t } : t;
|
|
192
200
|
}
|
|
193
|
-
function
|
|
201
|
+
function Ve(t) {
|
|
194
202
|
const e = typeof t.kind == "string" && t.kind.trim() ? t.kind.trim() : void 0, r = typeof t.ttlMs == "number" && Number.isFinite(t.ttlMs) && t.ttlMs > 0 ? t.ttlMs : void 0;
|
|
195
203
|
return e || r ? {
|
|
196
204
|
...e ? { kind: e } : {},
|
|
197
205
|
...r ? { ttlMs: r } : {}
|
|
198
206
|
} : void 0;
|
|
199
207
|
}
|
|
200
|
-
function
|
|
208
|
+
function ft(t) {
|
|
201
209
|
if (t == null) return "session";
|
|
202
210
|
if (t === "volatile" || t === "session" || t === "local" || t === "indexedDb") return t;
|
|
203
211
|
if (typeof t == "string") {
|
|
@@ -206,21 +214,21 @@ function ut(t) {
|
|
|
206
214
|
}
|
|
207
215
|
throw new Error(`Unsupported memory tier: ${String(t)}`);
|
|
208
216
|
}
|
|
209
|
-
function
|
|
217
|
+
function xt(t) {
|
|
210
218
|
return typeof t.getItem == "function" && typeof t.setItem == "function";
|
|
211
219
|
}
|
|
212
|
-
function
|
|
220
|
+
function vt(t) {
|
|
213
221
|
return typeof t.get == "function" && typeof t.set == "function";
|
|
214
222
|
}
|
|
215
|
-
function
|
|
223
|
+
function Ct(t) {
|
|
216
224
|
return typeof t.accountId == "string" && !!t.session && !!t.indexedDb;
|
|
217
225
|
}
|
|
218
|
-
function
|
|
226
|
+
function Ke(t) {
|
|
219
227
|
const e = t.options?.ttlMs ?? t.ttlMs;
|
|
220
228
|
return typeof e == "number" && Number.isFinite(e) && e > 0 ? { ttlMs: e } : void 0;
|
|
221
229
|
}
|
|
222
|
-
async function
|
|
223
|
-
if (
|
|
230
|
+
async function He(t, e, r) {
|
|
231
|
+
if (xt(t)) {
|
|
224
232
|
const n = t.getItem(r);
|
|
225
233
|
if (!n) return null;
|
|
226
234
|
try {
|
|
@@ -229,17 +237,17 @@ async function Ve(t, e, r) {
|
|
|
229
237
|
return t.removeItem?.(r), null;
|
|
230
238
|
}
|
|
231
239
|
}
|
|
232
|
-
return
|
|
240
|
+
return vt(t) && !Ct(t) ? await t.get(e, r) ?? null : await t[e].get(r) ?? null;
|
|
233
241
|
}
|
|
234
|
-
async function
|
|
235
|
-
return
|
|
242
|
+
async function Je(t, e, r, n, o) {
|
|
243
|
+
return xt(t) ? (t.setItem(r, JSON.stringify(n ?? null)), !0) : vt(t) && !Ct(t) ? await t.set(e, r, n ?? null, o) !== !1 : await t[e].set(r, n ?? null, o) !== !1;
|
|
236
244
|
}
|
|
237
|
-
async function
|
|
238
|
-
return
|
|
245
|
+
async function Ze(t, e, r) {
|
|
246
|
+
return xt(t) ? (t.removeItem?.(r), !0) : vt(t) && !Ct(t) ? t.remove ? (await t.remove(e, r), !0) : !1 : (await t[e].remove(r), !0);
|
|
239
247
|
}
|
|
240
|
-
async function
|
|
248
|
+
async function We(t, e, { tools: r, beacon: n, confirmation: o, memory: i, refStore: a }) {
|
|
241
249
|
if (t === "tool.invoke") {
|
|
242
|
-
const { name: s, input: c } =
|
|
250
|
+
const { name: s, input: c } = Fe(e), u = r[s];
|
|
243
251
|
if (typeof u != "function") throw new Error(`Unknown tool: ${s}`);
|
|
244
252
|
return u(c);
|
|
245
253
|
}
|
|
@@ -251,35 +259,35 @@ async function Je(t, e, { tools: r, beacon: n, confirmation: o, memory: i, refSt
|
|
|
251
259
|
return typeof s == "boolean" ? { confirmed: s } : s;
|
|
252
260
|
}
|
|
253
261
|
if (t === "memory.get") {
|
|
254
|
-
const { key: s, tier: c } =
|
|
255
|
-
return
|
|
262
|
+
const { key: s, tier: c } = qe(e);
|
|
263
|
+
return He(i, ft(c), String(s));
|
|
256
264
|
}
|
|
257
265
|
if (t === "memory.set") {
|
|
258
|
-
const s =
|
|
259
|
-
return { ok: await
|
|
266
|
+
const s = De(e);
|
|
267
|
+
return { ok: await Je(i, ft(s.tier), String(s.key), s.value, Ke(s)) };
|
|
260
268
|
}
|
|
261
269
|
if (t === "memory.remove") {
|
|
262
|
-
const { key: s, tier: c } =
|
|
263
|
-
return { ok: await
|
|
270
|
+
const { key: s, tier: c } = Ue(e);
|
|
271
|
+
return { ok: await Ze(i, ft(c), String(s)) };
|
|
264
272
|
}
|
|
265
273
|
if (t === "ref.put") {
|
|
266
|
-
const s =
|
|
274
|
+
const s = tt({
|
|
267
275
|
tools: r,
|
|
268
276
|
beacon: n,
|
|
269
277
|
confirmation: o,
|
|
270
278
|
memory: i,
|
|
271
279
|
refStore: a
|
|
272
|
-
}), c =
|
|
273
|
-
return s.put(c.value,
|
|
280
|
+
}), c = ze(e);
|
|
281
|
+
return s.put(c.value, Ve(c));
|
|
274
282
|
}
|
|
275
|
-
if (t === "ref.get") return
|
|
283
|
+
if (t === "ref.get") return tt({
|
|
276
284
|
tools: r,
|
|
277
285
|
beacon: n,
|
|
278
286
|
confirmation: o,
|
|
279
287
|
memory: i,
|
|
280
288
|
refStore: a
|
|
281
289
|
}).get(e);
|
|
282
|
-
if (t === "ref.materialize") return
|
|
290
|
+
if (t === "ref.materialize") return tt({
|
|
283
291
|
tools: r,
|
|
284
292
|
beacon: n,
|
|
285
293
|
confirmation: o,
|
|
@@ -287,7 +295,7 @@ async function Je(t, e, { tools: r, beacon: n, confirmation: o, memory: i, refSt
|
|
|
287
295
|
refStore: a
|
|
288
296
|
}).materialize(e);
|
|
289
297
|
if (t === "ref.remove")
|
|
290
|
-
return await
|
|
298
|
+
return await tt({
|
|
291
299
|
tools: r,
|
|
292
300
|
beacon: n,
|
|
293
301
|
confirmation: o,
|
|
@@ -296,25 +304,25 @@ async function Je(t, e, { tools: r, beacon: n, confirmation: o, memory: i, refSt
|
|
|
296
304
|
}).delete(e), { ok: !0 };
|
|
297
305
|
throw new Error(`Unknown RPC method: ${t}`);
|
|
298
306
|
}
|
|
299
|
-
function
|
|
300
|
-
const e = t.refStore ||
|
|
307
|
+
function tt(t) {
|
|
308
|
+
const e = t.refStore || Le();
|
|
301
309
|
if (!e || typeof e.put != "function" || typeof e.get != "function") throw new Error("No ref store is configured.");
|
|
302
310
|
return e;
|
|
303
311
|
}
|
|
304
|
-
function
|
|
312
|
+
function Ge() {
|
|
305
313
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
306
314
|
}
|
|
307
|
-
function
|
|
315
|
+
function I(t) {
|
|
308
316
|
return Math.max(0, Math.round(performance.now() - t));
|
|
309
317
|
}
|
|
310
|
-
function
|
|
318
|
+
function V(t) {
|
|
311
319
|
return typeof t == "object" && t !== null && !Array.isArray(t);
|
|
312
320
|
}
|
|
313
|
-
function
|
|
314
|
-
const { accountId: e, locale: r = "en-GB", parentUrl: n = "", threadId: o, incomingContext: i, messageLimit: a } = t, s =
|
|
321
|
+
function Ye(t) {
|
|
322
|
+
const { accountId: e, locale: r = "en-GB", parentUrl: n = "", threadId: o, incomingContext: i, messageLimit: a } = t, s = V(i) ? i : {}, c = V(s.thread) ? s.thread : {}, u = V(s.panel) ? s.panel : {}, l = V(s.meta) ? s.meta : {}, f = Qt(s.messages, a), d = {
|
|
315
323
|
id: String(o || c.id || self.crypto.randomUUID()),
|
|
316
|
-
started_at: String(c.started_at ||
|
|
317
|
-
extensions:
|
|
324
|
+
started_at: String(c.started_at || Ge()),
|
|
325
|
+
extensions: V(c.extensions) ? { ...c.extensions } : {}
|
|
318
326
|
}, p = String(l.locale || r), m = String(l.parentUrl || n || typeof self < "u" && self.location?.href || "");
|
|
319
327
|
return {
|
|
320
328
|
panel: { ...u },
|
|
@@ -327,19 +335,19 @@ function We(t) {
|
|
|
327
335
|
}
|
|
328
336
|
};
|
|
329
337
|
}
|
|
330
|
-
function
|
|
331
|
-
const n =
|
|
338
|
+
function Dt(t, e, r) {
|
|
339
|
+
const n = Qt([e], r)[0];
|
|
332
340
|
return n ? {
|
|
333
341
|
...t,
|
|
334
|
-
messages:
|
|
342
|
+
messages: it([...t.messages, n], r)
|
|
335
343
|
} : t;
|
|
336
344
|
}
|
|
337
|
-
function
|
|
338
|
-
const r =
|
|
345
|
+
function it(t, e) {
|
|
346
|
+
const r = Qe(e);
|
|
339
347
|
return r === 1 / 0 ? [...t] : t.slice(-r);
|
|
340
348
|
}
|
|
341
|
-
function
|
|
342
|
-
return Array.isArray(t) ?
|
|
349
|
+
function Qt(t, e) {
|
|
350
|
+
return Array.isArray(t) ? it(t.map((r) => {
|
|
343
351
|
const n = r?.role;
|
|
344
352
|
return {
|
|
345
353
|
role: n === "model" ? "assistant" : typeof n == "string" ? n : "",
|
|
@@ -347,37 +355,37 @@ function Yt(t, e) {
|
|
|
347
355
|
};
|
|
348
356
|
}).filter((r) => (r.role === "user" || r.role === "assistant" || r.role === "tool_result") && (r.role === "tool_result" || !!r.content)), e) : [];
|
|
349
357
|
}
|
|
350
|
-
function
|
|
358
|
+
function Qe(t) {
|
|
351
359
|
if (t === void 0) return 50;
|
|
352
360
|
if (!Number.isFinite(t)) return 1 / 0;
|
|
353
361
|
const e = Math.floor(t);
|
|
354
362
|
return e > 0 ? e : 50;
|
|
355
363
|
}
|
|
356
|
-
var
|
|
357
|
-
async function
|
|
364
|
+
var Xe = "gengage:agent:context:";
|
|
365
|
+
async function tr({ accountId: t, threadId: e, rpc: r }) {
|
|
358
366
|
const n = await r("memory.get", {
|
|
359
367
|
tier: "session",
|
|
360
|
-
key:
|
|
368
|
+
key: Xt(t, e)
|
|
361
369
|
});
|
|
362
370
|
return n && typeof n == "object" && !Array.isArray(n) ? n : {};
|
|
363
371
|
}
|
|
364
|
-
async function
|
|
372
|
+
async function er({ accountId: t, threadId: e, extensions: r, panel: n, rpc: o }) {
|
|
365
373
|
await o("memory.set", {
|
|
366
374
|
tier: "session",
|
|
367
|
-
key:
|
|
375
|
+
key: Xt(t, e),
|
|
368
376
|
value: {
|
|
369
377
|
thread: { extensions: r },
|
|
370
378
|
...n && Object.keys(n).length > 0 ? { panel: n } : {}
|
|
371
379
|
}
|
|
372
380
|
});
|
|
373
381
|
}
|
|
374
|
-
function
|
|
375
|
-
return `${
|
|
382
|
+
function Xt(t, e) {
|
|
383
|
+
return `${Xe}${t}:${e}`;
|
|
376
384
|
}
|
|
377
385
|
function w(t) {
|
|
378
386
|
return typeof t == "object" && t !== null && !Array.isArray(t);
|
|
379
387
|
}
|
|
380
|
-
var
|
|
388
|
+
var rr = "gengage_agentic_savepoints", et = "savepoints", Ut = 3600 * 1e3, nr = 1, ko = class {
|
|
381
389
|
#t = /* @__PURE__ */ new Map();
|
|
382
390
|
#i = /* @__PURE__ */ new Map();
|
|
383
391
|
#e;
|
|
@@ -391,7 +399,7 @@ var tr = "gengage_agentic_savepoints", Y = "savepoints", Dt = 3600 * 1e3, er = 1
|
|
|
391
399
|
#c;
|
|
392
400
|
#r = /* @__PURE__ */ new Map();
|
|
393
401
|
constructor({ accountId: t, locale: e, parentUrl: r, rpc: n, persistentPanelKeys: o = [], panelKeyLimits: i = {}, messageLimit: a, maxThreads: s, threadTtlMs: c }) {
|
|
394
|
-
this.#e = t, this.#u = e, this.#l = r, this.#a = n, this.#f = [...new Set(o.filter(Boolean))], this.#d =
|
|
402
|
+
this.#e = t, this.#u = e, this.#l = r, this.#a = n, this.#f = [...new Set(o.filter(Boolean))], this.#d = ar(i), this.#o = mt(a), this.#s = mt(s), this.#c = mt(c);
|
|
395
403
|
}
|
|
396
404
|
get size() {
|
|
397
405
|
return this.pruneExpired(), this.#t.size;
|
|
@@ -412,19 +420,19 @@ var tr = "gengage_agentic_savepoints", Y = "savepoints", Dt = 3600 * 1e3, er = 1
|
|
|
412
420
|
this.pruneExpired();
|
|
413
421
|
const e = t?.session_id || t?.meta?.threadId || t?.sessionId, r = String(e || "default"), n = this.#t.get(r);
|
|
414
422
|
if (n) {
|
|
415
|
-
const a =
|
|
423
|
+
const a = ur(n, t?.context, this.#o);
|
|
416
424
|
return this.#n(r, a), a;
|
|
417
425
|
}
|
|
418
|
-
const o = await
|
|
426
|
+
const o = await tr({
|
|
419
427
|
accountId: this.#e,
|
|
420
428
|
threadId: r,
|
|
421
429
|
rpc: this.#a
|
|
422
|
-
}), i =
|
|
430
|
+
}), i = Ye({
|
|
423
431
|
accountId: this.#e,
|
|
424
432
|
locale: t?.locale || this.#u,
|
|
425
433
|
parentUrl: this.#l,
|
|
426
434
|
threadId: r,
|
|
427
|
-
incomingContext:
|
|
435
|
+
incomingContext: cr(o, t?.context),
|
|
428
436
|
messageLimit: this.#o
|
|
429
437
|
});
|
|
430
438
|
return this.#n(r, i), this.#m(), i;
|
|
@@ -433,7 +441,7 @@ var tr = "gengage_agentic_savepoints", Y = "savepoints", Dt = 3600 * 1e3, er = 1
|
|
|
433
441
|
this.pruneExpired();
|
|
434
442
|
const r = String(t || "default"), n = this.#t.get(r);
|
|
435
443
|
if (!n) return null;
|
|
436
|
-
const o =
|
|
444
|
+
const o = Tt(n, typeof e == "function" ? e(n) : e, this.#o);
|
|
437
445
|
return this.#n(r, o), o;
|
|
438
446
|
}
|
|
439
447
|
appendUserMessage(t, e) {
|
|
@@ -442,7 +450,7 @@ var tr = "gengage_agentic_savepoints", Y = "savepoints", Dt = 3600 * 1e3, er = 1
|
|
|
442
450
|
if (!e) return this.#t.get(r) ?? null;
|
|
443
451
|
const n = this.#t.get(r);
|
|
444
452
|
if (!n) return null;
|
|
445
|
-
const o =
|
|
453
|
+
const o = Dt(n, {
|
|
446
454
|
role: "user",
|
|
447
455
|
content: e
|
|
448
456
|
}, this.#o);
|
|
@@ -452,7 +460,7 @@ var tr = "gengage_agentic_savepoints", Y = "savepoints", Dt = 3600 * 1e3, er = 1
|
|
|
452
460
|
this.pruneExpired();
|
|
453
461
|
const r = String(t || "default"), n = this.#t.get(r);
|
|
454
462
|
if (!n) return null;
|
|
455
|
-
const o =
|
|
463
|
+
const o = Dt(n, {
|
|
456
464
|
role: "tool_result",
|
|
457
465
|
content: String(e?.content || ""),
|
|
458
466
|
...e?.name ? { name: String(e.name) } : {},
|
|
@@ -463,11 +471,11 @@ var tr = "gengage_agentic_savepoints", Y = "savepoints", Dt = 3600 * 1e3, er = 1
|
|
|
463
471
|
async commit(t) {
|
|
464
472
|
this.pruneExpired();
|
|
465
473
|
const e = String(t || "default"), r = this.#t.get(e);
|
|
466
|
-
return r ? (this.#n(e, r), await
|
|
474
|
+
return r ? (this.#n(e, r), await er({
|
|
467
475
|
accountId: this.#e,
|
|
468
476
|
threadId: e,
|
|
469
477
|
extensions: r.thread.extensions,
|
|
470
|
-
panel:
|
|
478
|
+
panel: ir(r.panel, this.#f, this.#d),
|
|
471
479
|
rpc: this.#a
|
|
472
480
|
}), r) : null;
|
|
473
481
|
}
|
|
@@ -517,8 +525,8 @@ var tr = "gengage_agentic_savepoints", Y = "savepoints", Dt = 3600 * 1e3, er = 1
|
|
|
517
525
|
createdAt: Date.now()
|
|
518
526
|
};
|
|
519
527
|
try {
|
|
520
|
-
await
|
|
521
|
-
o.put(n,
|
|
528
|
+
await pt(this.#e, "readwrite", (o) => {
|
|
529
|
+
o.put(n, dt(t, e));
|
|
522
530
|
});
|
|
523
531
|
} catch {
|
|
524
532
|
}
|
|
@@ -527,13 +535,13 @@ var tr = "gengage_agentic_savepoints", Y = "savepoints", Dt = 3600 * 1e3, er = 1
|
|
|
527
535
|
if (!t) return null;
|
|
528
536
|
try {
|
|
529
537
|
let r = null;
|
|
530
|
-
return await
|
|
531
|
-
const o = typeof e == "number" ?
|
|
538
|
+
return await pt(this.#e, "readonly", (n) => {
|
|
539
|
+
const o = typeof e == "number" ? dt(t, e) : null;
|
|
532
540
|
if (o !== null) {
|
|
533
541
|
const i = n.get(o);
|
|
534
542
|
i.onsuccess = () => {
|
|
535
543
|
const a = i.result;
|
|
536
|
-
a && Date.now() - a.createdAt <
|
|
544
|
+
a && Date.now() - a.createdAt < Ut && (r = a);
|
|
537
545
|
};
|
|
538
546
|
} else {
|
|
539
547
|
const i = n.openCursor(null, "prev");
|
|
@@ -545,7 +553,7 @@ var tr = "gengage_agentic_savepoints", Y = "savepoints", Dt = 3600 * 1e3, er = 1
|
|
|
545
553
|
a.continue();
|
|
546
554
|
return;
|
|
547
555
|
}
|
|
548
|
-
Date.now() - s.createdAt <
|
|
556
|
+
Date.now() - s.createdAt < Ut && (r = s);
|
|
549
557
|
};
|
|
550
558
|
}
|
|
551
559
|
}), r;
|
|
@@ -556,9 +564,9 @@ var tr = "gengage_agentic_savepoints", Y = "savepoints", Dt = 3600 * 1e3, er = 1
|
|
|
556
564
|
async clearSavepoint(t, e) {
|
|
557
565
|
if (t)
|
|
558
566
|
try {
|
|
559
|
-
await
|
|
567
|
+
await pt(this.#e, "readwrite", (r) => {
|
|
560
568
|
if (typeof e == "number") {
|
|
561
|
-
r.delete(
|
|
569
|
+
r.delete(dt(t, e));
|
|
562
570
|
return;
|
|
563
571
|
}
|
|
564
572
|
const n = r.openCursor();
|
|
@@ -589,26 +597,26 @@ var tr = "gengage_agentic_savepoints", Y = "savepoints", Dt = 3600 * 1e3, er = 1
|
|
|
589
597
|
}
|
|
590
598
|
}
|
|
591
599
|
};
|
|
592
|
-
function
|
|
600
|
+
function dt(t, e) {
|
|
593
601
|
return `${t}|${e}`;
|
|
594
602
|
}
|
|
595
|
-
function
|
|
603
|
+
function or() {
|
|
596
604
|
return (typeof self < "u" ? self : globalThis)?.indexedDB || null;
|
|
597
605
|
}
|
|
598
|
-
async function
|
|
599
|
-
const n =
|
|
606
|
+
async function pt(t, e, r) {
|
|
607
|
+
const n = or();
|
|
600
608
|
if (!n) return;
|
|
601
|
-
const o = `${
|
|
609
|
+
const o = `${rr}_${t}`;
|
|
602
610
|
await new Promise((i, a) => {
|
|
603
|
-
const s = n.open(o,
|
|
611
|
+
const s = n.open(o, nr);
|
|
604
612
|
s.onupgradeneeded = () => {
|
|
605
613
|
const c = s.result;
|
|
606
|
-
c.objectStoreNames.contains(
|
|
614
|
+
c.objectStoreNames.contains(et) || c.createObjectStore(et);
|
|
607
615
|
}, s.onerror = () => a(s.error || /* @__PURE__ */ new Error("savepoint:open_failed")), s.onsuccess = () => {
|
|
608
616
|
const c = s.result;
|
|
609
617
|
try {
|
|
610
|
-
const u = c.transaction(
|
|
611
|
-
r(u.objectStore(
|
|
618
|
+
const u = c.transaction(et, e);
|
|
619
|
+
r(u.objectStore(et)), u.oncomplete = () => {
|
|
612
620
|
c.close(), i();
|
|
613
621
|
}, u.onerror = () => {
|
|
614
622
|
c.close(), a(u.error || /* @__PURE__ */ new Error("savepoint:tx_failed"));
|
|
@@ -621,13 +629,13 @@ async function ft(t, e, r) {
|
|
|
621
629
|
};
|
|
622
630
|
});
|
|
623
631
|
}
|
|
624
|
-
function
|
|
632
|
+
function ir(t, e, r) {
|
|
625
633
|
if (!e.length || !w(t)) return;
|
|
626
634
|
const n = {};
|
|
627
|
-
for (const o of e) Object.prototype.hasOwnProperty.call(t, o) && (n[o] =
|
|
635
|
+
for (const o of e) Object.prototype.hasOwnProperty.call(t, o) && (n[o] = sr(t[o], r[o]));
|
|
628
636
|
return n;
|
|
629
637
|
}
|
|
630
|
-
function
|
|
638
|
+
function ar(t) {
|
|
631
639
|
const e = {};
|
|
632
640
|
for (const [r, n] of Object.entries(t || {})) {
|
|
633
641
|
const o = Math.floor(Number(n));
|
|
@@ -635,22 +643,22 @@ function or(t) {
|
|
|
635
643
|
}
|
|
636
644
|
return e;
|
|
637
645
|
}
|
|
638
|
-
function
|
|
646
|
+
function mt(t) {
|
|
639
647
|
if (t === void 0) return;
|
|
640
648
|
const e = Math.floor(Number(t));
|
|
641
649
|
return Number.isFinite(e) && e > 0 ? e : void 0;
|
|
642
650
|
}
|
|
643
|
-
function
|
|
651
|
+
function sr(t, e) {
|
|
644
652
|
return !e || !Array.isArray(t) ? t : t.slice(-e);
|
|
645
653
|
}
|
|
646
|
-
function
|
|
654
|
+
function cr(t, e) {
|
|
647
655
|
if (!w(t) && !w(e)) return {};
|
|
648
|
-
const r = w(t) ? t : {}, n =
|
|
656
|
+
const r = w(t) ? t : {}, n = Tt(r, w(e) ? e : {});
|
|
649
657
|
return w(r.panel) && (n.panel = r.panel), n;
|
|
650
658
|
}
|
|
651
|
-
function
|
|
659
|
+
function ur(t, e, r) {
|
|
652
660
|
if (!w(e)) return t;
|
|
653
|
-
const n =
|
|
661
|
+
const n = Tt(t, e, r);
|
|
654
662
|
return {
|
|
655
663
|
...n,
|
|
656
664
|
panel: t.panel,
|
|
@@ -665,7 +673,7 @@ function sr(t, e, r) {
|
|
|
665
673
|
}
|
|
666
674
|
};
|
|
667
675
|
}
|
|
668
|
-
function
|
|
676
|
+
function Tt(t, e, r) {
|
|
669
677
|
if (!w(e)) return t;
|
|
670
678
|
const n = t, o = e, i = w(n.panel) ? n.panel : {}, a = w(o.panel) ? o.panel : {}, s = w(n.thread) ? n.thread : {}, c = w(o.thread) ? o.thread : {}, u = w(s.extensions) ? s.extensions : {}, l = w(c.extensions) ? c.extensions : {}, f = w(n.meta) ? n.meta : {}, d = w(o.meta) ? o.meta : {};
|
|
671
679
|
return {
|
|
@@ -687,22 +695,22 @@ function vt(t, e, r) {
|
|
|
687
695
|
...f,
|
|
688
696
|
...d
|
|
689
697
|
},
|
|
690
|
-
messages: Array.isArray(o.messages) ?
|
|
698
|
+
messages: Array.isArray(o.messages) ? it(o.messages, r) : t.messages ?? []
|
|
691
699
|
};
|
|
692
700
|
}
|
|
693
|
-
function
|
|
701
|
+
function te(t) {
|
|
694
702
|
const e = String.fromCharCode(...t);
|
|
695
703
|
return btoa(e).replace(/\+/gu, "-").replace(/\//gu, "_").replace(/=+$/u, "");
|
|
696
704
|
}
|
|
697
|
-
function
|
|
698
|
-
return
|
|
705
|
+
function zt(t) {
|
|
706
|
+
return te(new TextEncoder().encode(JSON.stringify(t)));
|
|
699
707
|
}
|
|
700
|
-
async function
|
|
708
|
+
async function lr({ accountId: t, devJwtSecret: e, ttlS: r = 300 }) {
|
|
701
709
|
if (!e) throw new Error("devJwtSecret is required for local agent mode.");
|
|
702
|
-
const n = Math.floor(Date.now() / 1e3), o = `${
|
|
710
|
+
const n = Math.floor(Date.now() / 1e3), o = `${zt({
|
|
703
711
|
alg: "HS256",
|
|
704
712
|
typ: "JWT"
|
|
705
|
-
})}.${
|
|
713
|
+
})}.${zt({
|
|
706
714
|
sub: t,
|
|
707
715
|
iat: n,
|
|
708
716
|
exp: n + r,
|
|
@@ -712,18 +720,18 @@ async function cr({ accountId: t, devJwtSecret: e, ttlS: r = 300 }) {
|
|
|
712
720
|
name: "HMAC",
|
|
713
721
|
hash: "SHA-256"
|
|
714
722
|
}, !1, ["sign"]), a = await crypto.subtle.sign("HMAC", i, new TextEncoder().encode(o));
|
|
715
|
-
return `${o}.${
|
|
723
|
+
return `${o}.${te(new Uint8Array(a))}`;
|
|
716
724
|
}
|
|
717
|
-
function
|
|
725
|
+
function fr({ accountId: t, devJwtSecret: e, tokenBrokerUrl: r, tokenBrokerAudience: n, refreshSkewS: o = 30, fetchImpl: i = fetch }) {
|
|
718
726
|
let a = null;
|
|
719
727
|
return async ({ signal: s, parentUrl: c } = {}) => {
|
|
720
|
-
if (e) return
|
|
728
|
+
if (e) return lr({
|
|
721
729
|
accountId: t,
|
|
722
730
|
devJwtSecret: e
|
|
723
731
|
});
|
|
724
732
|
if (!r) throw new Error("tokenBrokerUrl is required for production agent mode.");
|
|
725
733
|
const u = Math.floor(Date.now() / 1e3);
|
|
726
|
-
return a?.token && a.expiresAtS - o > u || (a = await
|
|
734
|
+
return a?.token && a.expiresAtS - o > u || (a = await dr({
|
|
727
735
|
accountId: t,
|
|
728
736
|
tokenBrokerUrl: r,
|
|
729
737
|
tokenBrokerAudience: n,
|
|
@@ -733,7 +741,7 @@ function ur({ accountId: t, devJwtSecret: e, tokenBrokerUrl: r, tokenBrokerAudie
|
|
|
733
741
|
})), a.token;
|
|
734
742
|
};
|
|
735
743
|
}
|
|
736
|
-
async function
|
|
744
|
+
async function dr({ accountId: t, tokenBrokerUrl: e, tokenBrokerAudience: r, parentUrl: n, signal: o, fetchImpl: i }) {
|
|
737
745
|
const a = await i(e, {
|
|
738
746
|
method: "POST",
|
|
739
747
|
credentials: "include",
|
|
@@ -754,10 +762,10 @@ async function lr({ accountId: t, tokenBrokerUrl: e, tokenBrokerAudience: r, par
|
|
|
754
762
|
if (!c || typeof c != "string") throw new Error("Token broker response did not include a JWT.");
|
|
755
763
|
return {
|
|
756
764
|
token: c,
|
|
757
|
-
expiresAtS:
|
|
765
|
+
expiresAtS: pr(s) || mr(c) || Math.floor(Date.now() / 1e3) + 300
|
|
758
766
|
};
|
|
759
767
|
}
|
|
760
|
-
function
|
|
768
|
+
function pr(t) {
|
|
761
769
|
const e = t?.expiresAtS ?? t?.expires_at_s ?? t?.expiresInS ?? t?.expires_in_s;
|
|
762
770
|
if (Number.isFinite(e)) return Number(e);
|
|
763
771
|
const r = t?.expiresIn ?? t?.expires_in;
|
|
@@ -769,7 +777,7 @@ function fr(t) {
|
|
|
769
777
|
}
|
|
770
778
|
return null;
|
|
771
779
|
}
|
|
772
|
-
function
|
|
780
|
+
function mr(t) {
|
|
773
781
|
try {
|
|
774
782
|
const [, e] = t.split(".");
|
|
775
783
|
if (!e) return null;
|
|
@@ -779,7 +787,7 @@ function dr(t) {
|
|
|
779
787
|
return null;
|
|
780
788
|
}
|
|
781
789
|
}
|
|
782
|
-
var
|
|
790
|
+
var Vt = {
|
|
783
791
|
unauthorized: {
|
|
784
792
|
code: "auth",
|
|
785
793
|
message: "Assistant authentication failed. Please retry."
|
|
@@ -829,22 +837,22 @@ var zt = {
|
|
|
829
837
|
super(e), this.name = "AgentError", this.code = t, this.source = r.source || "agent", r.sourceCode && (this.sourceCode = r.sourceCode), r.detail !== void 0 && (this.detail = r.detail);
|
|
830
838
|
}
|
|
831
839
|
};
|
|
832
|
-
function
|
|
833
|
-
const e = String(t?.code || "upstream_llm"), r =
|
|
840
|
+
function ee(t) {
|
|
841
|
+
const e = String(t?.code || "upstream_llm"), r = Vt[e] || Vt.upstream_llm;
|
|
834
842
|
return new x(r.code, r.message, {
|
|
835
843
|
source: "be",
|
|
836
844
|
sourceCode: e,
|
|
837
845
|
detail: t?.detail
|
|
838
846
|
});
|
|
839
847
|
}
|
|
840
|
-
function
|
|
848
|
+
function yr(t, e) {
|
|
841
849
|
const r = e?.error && typeof e.error == "object" ? e.error : {};
|
|
842
|
-
return
|
|
843
|
-
code: String(r.code ||
|
|
850
|
+
return ee({
|
|
851
|
+
code: String(r.code || gr(t)),
|
|
844
852
|
detail: r.detail
|
|
845
853
|
});
|
|
846
854
|
}
|
|
847
|
-
function
|
|
855
|
+
function _o(t) {
|
|
848
856
|
return t instanceof x ? {
|
|
849
857
|
type: "error",
|
|
850
858
|
code: t.code,
|
|
@@ -855,11 +863,11 @@ function wo(t) {
|
|
|
855
863
|
message: "The assistant could not complete that request."
|
|
856
864
|
};
|
|
857
865
|
}
|
|
858
|
-
function
|
|
866
|
+
function gr(t) {
|
|
859
867
|
return t === 401 ? "unauthorized" : t === 403 ? "forbidden" : t === 413 ? "payload_too_large" : t === 429 ? "rate_limited" : "internal";
|
|
860
868
|
}
|
|
861
|
-
async function
|
|
862
|
-
const { beUrl: e, accountId: r, devJwtSecret: n, tokenBrokerUrl: o, tokenBrokerAudience: i, jwtProvider: a, parentUrl: s, op: c, input: u, cacheTtlS: l, cacheKey: f, browserCache: d, signal: p, interceptors: m } = t, h = await (a ||
|
|
869
|
+
async function Ao(t) {
|
|
870
|
+
const { beUrl: e, accountId: r, devJwtSecret: n, tokenBrokerUrl: o, tokenBrokerAudience: i, jwtProvider: a, parentUrl: s, op: c, input: u, cacheTtlS: l, cacheKey: f, browserCache: d, signal: p, interceptors: m } = t, h = await (a || fr({
|
|
863
871
|
accountId: r,
|
|
864
872
|
devJwtSecret: n,
|
|
865
873
|
tokenBrokerUrl: o,
|
|
@@ -867,8 +875,8 @@ async function bo(t) {
|
|
|
867
875
|
}))({
|
|
868
876
|
...p ? { signal: p } : {},
|
|
869
877
|
...s ? { parentUrl: s } : {}
|
|
870
|
-
}), { opDomain:
|
|
871
|
-
let
|
|
878
|
+
}), { opDomain: T, opName: $ } = hr(c, r);
|
|
879
|
+
let M = {
|
|
872
880
|
method: "POST",
|
|
873
881
|
headers: {
|
|
874
882
|
authorization: `Bearer ${h}`,
|
|
@@ -876,7 +884,7 @@ async function bo(t) {
|
|
|
876
884
|
accept: "application/x-ndjson"
|
|
877
885
|
},
|
|
878
886
|
body: JSON.stringify({
|
|
879
|
-
op_domain:
|
|
887
|
+
op_domain: T,
|
|
880
888
|
op_name: $,
|
|
881
889
|
op_payload: u,
|
|
882
890
|
...l !== void 0 ? { cache_ttl_s: l } : {},
|
|
@@ -884,42 +892,42 @@ async function bo(t) {
|
|
|
884
892
|
}),
|
|
885
893
|
...p ? { signal: p } : {}
|
|
886
894
|
};
|
|
887
|
-
const
|
|
895
|
+
const N = `${String(e).replace(/\/+$/u, "")}/v1/execute`;
|
|
888
896
|
if (m?.beforeRequest) {
|
|
889
897
|
const k = await m.beforeRequest(t, {
|
|
890
|
-
url:
|
|
891
|
-
init:
|
|
898
|
+
url: N,
|
|
899
|
+
init: M
|
|
892
900
|
});
|
|
893
901
|
if (k && "cached" in k && k.cached !== void 0) return k.cached;
|
|
894
|
-
k?.init && (
|
|
902
|
+
k?.init && (M = k.init);
|
|
895
903
|
}
|
|
896
|
-
const
|
|
897
|
-
if (!
|
|
898
|
-
let
|
|
904
|
+
const R = d === !1 ? await fetch(N, M) : await ve(N, M, typeof d == "object" ? d : {});
|
|
905
|
+
if (!R.ok) throw yr(R.status, await br(R));
|
|
906
|
+
let L = await kr(R);
|
|
899
907
|
if (m?.afterResponse) {
|
|
900
|
-
const k = await m.afterResponse(t,
|
|
901
|
-
k && "result" in k && k.result !== void 0 && (
|
|
908
|
+
const k = await m.afterResponse(t, L);
|
|
909
|
+
k && "result" in k && k.result !== void 0 && (L = k.result);
|
|
902
910
|
}
|
|
903
|
-
return
|
|
911
|
+
return L;
|
|
904
912
|
}
|
|
905
|
-
function
|
|
913
|
+
function hr(t, e) {
|
|
906
914
|
if (!t || t.startsWith("-") || t.endsWith("-")) throw new Error(`Invalid BE op name: ${t}`);
|
|
907
915
|
return {
|
|
908
|
-
opDomain:
|
|
916
|
+
opDomain: wr(e),
|
|
909
917
|
opName: t
|
|
910
918
|
};
|
|
911
919
|
}
|
|
912
|
-
function
|
|
920
|
+
function wr(t) {
|
|
913
921
|
return t.replace(/-agentic$/u, "");
|
|
914
922
|
}
|
|
915
|
-
async function
|
|
923
|
+
async function br(t) {
|
|
916
924
|
try {
|
|
917
925
|
return await t.json();
|
|
918
926
|
} catch {
|
|
919
927
|
return { error: { code: t.statusText || "internal" } };
|
|
920
928
|
}
|
|
921
929
|
}
|
|
922
|
-
async function
|
|
930
|
+
async function kr(t) {
|
|
923
931
|
const e = t.body?.getReader();
|
|
924
932
|
if (!e) throw new Error("BE response body is not readable.");
|
|
925
933
|
const r = new TextDecoder();
|
|
@@ -933,15 +941,15 @@ async function wr(t) {
|
|
|
933
941
|
`);
|
|
934
942
|
for (; c >= 0; ) {
|
|
935
943
|
const u = n.slice(0, c).trim();
|
|
936
|
-
n = n.slice(c + 1), u &&
|
|
944
|
+
n = n.slice(c + 1), u && Kt(JSON.parse(u), o), c = n.indexOf(`
|
|
937
945
|
`);
|
|
938
946
|
}
|
|
939
947
|
}
|
|
940
948
|
const i = n.trim();
|
|
941
|
-
return i &&
|
|
949
|
+
return i && Kt(JSON.parse(i), o), o;
|
|
942
950
|
}
|
|
943
|
-
function
|
|
944
|
-
if (t._error) throw
|
|
951
|
+
function Kt(t, e) {
|
|
952
|
+
if (t._error) throw ee(t._error);
|
|
945
953
|
if (!t._end)
|
|
946
954
|
for (const [r, n] of Object.entries(t)) {
|
|
947
955
|
if (Object.prototype.hasOwnProperty.call(e, r)) throw new x("op_failed", `BE streamed duplicate field "${r}".`, {
|
|
@@ -951,13 +959,13 @@ function Vt(t, e) {
|
|
|
951
959
|
e[r] = n;
|
|
952
960
|
}
|
|
953
961
|
}
|
|
954
|
-
function
|
|
962
|
+
function So(t = {}) {
|
|
955
963
|
return {
|
|
956
964
|
type: "metadata",
|
|
957
965
|
...t
|
|
958
966
|
};
|
|
959
967
|
}
|
|
960
|
-
function
|
|
968
|
+
function _r(t, e = !1, r = {}) {
|
|
961
969
|
return {
|
|
962
970
|
type: "text_chunk",
|
|
963
971
|
content: t,
|
|
@@ -965,36 +973,36 @@ function br(t, e = !1, r = {}) {
|
|
|
965
973
|
...r
|
|
966
974
|
};
|
|
967
975
|
}
|
|
968
|
-
function
|
|
976
|
+
function xo(t) {
|
|
969
977
|
return {
|
|
970
978
|
type: "ui_spec",
|
|
971
979
|
...t
|
|
972
980
|
};
|
|
973
981
|
}
|
|
974
|
-
function
|
|
982
|
+
function vo(t) {
|
|
975
983
|
return {
|
|
976
984
|
type: "action",
|
|
977
985
|
action: t
|
|
978
986
|
};
|
|
979
987
|
}
|
|
980
|
-
function
|
|
988
|
+
function Ar(t, e) {
|
|
981
989
|
return {
|
|
982
990
|
type: "error",
|
|
983
991
|
code: t,
|
|
984
992
|
message: e
|
|
985
993
|
};
|
|
986
994
|
}
|
|
987
|
-
function
|
|
995
|
+
function re() {
|
|
988
996
|
return { type: "done" };
|
|
989
997
|
}
|
|
990
|
-
function
|
|
998
|
+
function Sr(t, e) {
|
|
991
999
|
return t[e?.type || e?.action?.type || "inputText"] || t.inputText;
|
|
992
1000
|
}
|
|
993
|
-
function
|
|
1001
|
+
function ne(t) {
|
|
994
1002
|
return t && typeof t == "object" && !Array.isArray(t) ? t : null;
|
|
995
1003
|
}
|
|
996
|
-
function
|
|
997
|
-
const r =
|
|
1004
|
+
function Et(t, e = {}) {
|
|
1005
|
+
const r = ne(t);
|
|
998
1006
|
if (!r) return null;
|
|
999
1007
|
const n = e.catalogMapper?.(r);
|
|
1000
1008
|
if (n) return n;
|
|
@@ -1006,23 +1014,23 @@ function Ct(t, e = {}) {
|
|
|
1006
1014
|
url: F(r.url) || ""
|
|
1007
1015
|
}, a = Array.isArray(r.images) ? r.images : void 0, s = F(r.imageUrl, r.image_url, r.image, a?.[0]);
|
|
1008
1016
|
s && (i.imageUrl = s), a && a.length > 1 && (i.images = a.filter(($) => !!$).map(String));
|
|
1009
|
-
const c =
|
|
1017
|
+
const c = K(r.price_discounted), u = K(r.price), l = c || u;
|
|
1010
1018
|
l > 0 && (i.price = String(l));
|
|
1011
1019
|
const f = c > 0 ? u : 0;
|
|
1012
1020
|
f > 0 && (i.originalPrice = String(f));
|
|
1013
1021
|
const d = F(r.brand);
|
|
1014
1022
|
d && (i.brand = d);
|
|
1015
|
-
const p =
|
|
1023
|
+
const p = K(r.rating);
|
|
1016
1024
|
p > 0 && (i.rating = p);
|
|
1017
|
-
const m =
|
|
1025
|
+
const m = K(r.review_count) || K(r.reviewCount);
|
|
1018
1026
|
m > 0 && (i.reviewCount = m);
|
|
1019
1027
|
const h = F(r.cart_code, r.cartCode);
|
|
1020
1028
|
h && (i.cartCode = h), typeof r.in_stock == "boolean" && (i.inStock = r.in_stock), typeof r.inStock == "boolean" && (i.inStock = r.inStock);
|
|
1021
|
-
const
|
|
1022
|
-
return Array.isArray(
|
|
1029
|
+
const T = r.category_names;
|
|
1030
|
+
return Array.isArray(T) && (i.categoryNames = T.map(String)), i;
|
|
1023
1031
|
}
|
|
1024
|
-
function
|
|
1025
|
-
const e =
|
|
1032
|
+
function Pt(t) {
|
|
1033
|
+
const e = ne(t);
|
|
1026
1034
|
if (!e) return t;
|
|
1027
1035
|
const r = e.category_names, n = Array.isArray(r) ? r : void 0, o = e.images, i = Array.isArray(o) ? o : void 0, a = {
|
|
1028
1036
|
sku: e.sku,
|
|
@@ -1040,91 +1048,91 @@ function Tt(t) {
|
|
|
1040
1048
|
for (const s of Object.keys(a)) a[s] === void 0 && delete a[s];
|
|
1041
1049
|
return a;
|
|
1042
1050
|
}
|
|
1043
|
-
function
|
|
1044
|
-
return Array.isArray(t) ? t.map(
|
|
1051
|
+
function Co(t) {
|
|
1052
|
+
return Array.isArray(t) ? t.map(Pt).filter((e) => !!e) : [];
|
|
1045
1053
|
}
|
|
1046
1054
|
function F(...t) {
|
|
1047
1055
|
for (const e of t) if (typeof e == "string" && e.trim()) return e.trim();
|
|
1048
1056
|
return "";
|
|
1049
1057
|
}
|
|
1050
|
-
function
|
|
1058
|
+
function K(t) {
|
|
1051
1059
|
const e = Number(t);
|
|
1052
1060
|
return Number.isFinite(e) ? e : 0;
|
|
1053
1061
|
}
|
|
1054
|
-
function
|
|
1062
|
+
function Ht(t) {
|
|
1055
1063
|
return Array.isArray(t) ? t.map(String).filter(Boolean) : typeof t == "string" && t ? [t] : [];
|
|
1056
1064
|
}
|
|
1057
|
-
function
|
|
1058
|
-
return `${t}:${r.version || "v2"}:${
|
|
1065
|
+
function oe(t, e, r = {}) {
|
|
1066
|
+
return `${t}:${r.version || "v2"}:${ie(e)}`;
|
|
1059
1067
|
}
|
|
1060
|
-
function
|
|
1061
|
-
return
|
|
1068
|
+
function To(t, e = {}) {
|
|
1069
|
+
return ae(t).map((r) => se(typeof r == "string" ? r : r.sku, e.locale)).filter(Boolean).filter((r, n, o) => o.indexOf(r) === n).sort((r, n) => It(r, n, e.locale)).slice(0, e.limit || 16).join(",");
|
|
1062
1070
|
}
|
|
1063
|
-
function
|
|
1064
|
-
return
|
|
1071
|
+
function Eo(t, e = {}) {
|
|
1072
|
+
return ie(ae(t).map((r) => xr(r, e)).filter((r) => !!r).sort((r, n) => It(String(r.sku || r.name || ""), String(n.sku || n.name || ""), e.locale)).slice(0, e.limit || 16));
|
|
1065
1073
|
}
|
|
1066
|
-
function
|
|
1067
|
-
return
|
|
1074
|
+
function Po(t, e) {
|
|
1075
|
+
return O(t, e);
|
|
1068
1076
|
}
|
|
1069
|
-
function
|
|
1077
|
+
function ie(t) {
|
|
1070
1078
|
let e = 2166136261;
|
|
1071
|
-
const r =
|
|
1079
|
+
const r = vr(t);
|
|
1072
1080
|
for (let n = 0; n < r.length; n += 1)
|
|
1073
1081
|
e ^= r.charCodeAt(n), e = Math.imul(e, 16777619);
|
|
1074
1082
|
return (e >>> 0).toString(36);
|
|
1075
1083
|
}
|
|
1076
|
-
function
|
|
1084
|
+
function xr(t, e) {
|
|
1077
1085
|
if (!t || typeof t != "object" || Array.isArray(t)) return null;
|
|
1078
1086
|
const r = t, n = e.mapProduct?.(r);
|
|
1079
1087
|
if (n) return J(n);
|
|
1080
|
-
const o =
|
|
1081
|
-
return o && typeof o == "object" && !Array.isArray(o) ? J(
|
|
1088
|
+
const o = Pt(r);
|
|
1089
|
+
return o && typeof o == "object" && !Array.isArray(o) ? J(Cr(o, e)) : null;
|
|
1082
1090
|
}
|
|
1083
|
-
function
|
|
1091
|
+
function ae(t) {
|
|
1084
1092
|
return Array.isArray(t) ? t.filter((e) => typeof e == "string" || !!(e && typeof e == "object" && !Array.isArray(e))) : [];
|
|
1085
1093
|
}
|
|
1086
|
-
function
|
|
1094
|
+
function vr(t) {
|
|
1087
1095
|
return JSON.stringify(J(t));
|
|
1088
1096
|
}
|
|
1089
1097
|
function J(t) {
|
|
1090
1098
|
return Array.isArray(t) ? t.map(J) : !t || typeof t != "object" ? t : Object.fromEntries(Object.entries(t).filter(([, e]) => e !== void 0).sort(([e], [r]) => e.localeCompare(r)).map(([e, r]) => [e, J(r)]));
|
|
1091
1099
|
}
|
|
1092
|
-
function
|
|
1100
|
+
function Cr(t, e) {
|
|
1093
1101
|
return {
|
|
1094
|
-
sku:
|
|
1095
|
-
name:
|
|
1096
|
-
url:
|
|
1102
|
+
sku: se(t.sku, e.locale),
|
|
1103
|
+
name: O(t.name, e.locale),
|
|
1104
|
+
url: O(t.url, e.locale),
|
|
1097
1105
|
price: t.price,
|
|
1098
|
-
currency:
|
|
1099
|
-
category:
|
|
1100
|
-
category_names:
|
|
1101
|
-
image:
|
|
1106
|
+
currency: O(t.currency, e.locale),
|
|
1107
|
+
category: O(t.category, e.locale),
|
|
1108
|
+
category_names: Tr(t.category_names, e.locale, 16),
|
|
1109
|
+
image: O(t.image, e.locale),
|
|
1102
1110
|
in_stock: t.in_stock,
|
|
1103
1111
|
rating: t.rating,
|
|
1104
1112
|
review_count: t.review_count
|
|
1105
1113
|
};
|
|
1106
1114
|
}
|
|
1107
|
-
function
|
|
1108
|
-
return
|
|
1115
|
+
function se(t, e) {
|
|
1116
|
+
return O(t, e).toUpperCase();
|
|
1109
1117
|
}
|
|
1110
|
-
function
|
|
1118
|
+
function O(t, e) {
|
|
1111
1119
|
return typeof t == "string" ? t.trim().replace(/\s+/gu, " ").toLocaleLowerCase(e || void 0) : "";
|
|
1112
1120
|
}
|
|
1113
|
-
function
|
|
1121
|
+
function It(t, e, r) {
|
|
1114
1122
|
return t.localeCompare(e, r, { numeric: !0 });
|
|
1115
1123
|
}
|
|
1116
|
-
function
|
|
1117
|
-
return Array.isArray(t) ? t.map((n) =>
|
|
1124
|
+
function Tr(t, e, r) {
|
|
1125
|
+
return Array.isArray(t) ? t.map((n) => O(n, e)).filter(Boolean).sort((n, o) => It(n, o, e)).slice(0, r) : void 0;
|
|
1118
1126
|
}
|
|
1119
|
-
function
|
|
1127
|
+
function Er(t, e) {
|
|
1120
1128
|
if (!t) return { ok: !0 };
|
|
1121
1129
|
const r = [];
|
|
1122
|
-
return
|
|
1130
|
+
return bt(t, e, "", r), r.length ? {
|
|
1123
1131
|
ok: !1,
|
|
1124
1132
|
error: r[0] || "invalid"
|
|
1125
1133
|
} : { ok: !0 };
|
|
1126
1134
|
}
|
|
1127
|
-
function
|
|
1135
|
+
function bt(t, e, r, n) {
|
|
1128
1136
|
if (t) {
|
|
1129
1137
|
if (Array.isArray(t.enum) && !t.enum.includes(e)) {
|
|
1130
1138
|
n.push(`${r || "value"} must be one of [${t.enum.join(", ")}]`);
|
|
@@ -1155,7 +1163,7 @@ function ht(t, e, r, n) {
|
|
|
1155
1163
|
}
|
|
1156
1164
|
if (t.minItems != null && e.length < t.minItems && n.push(`${r || "value"} must have >= ${t.minItems} items`), t.maxItems != null && e.length > t.maxItems && n.push(`${r || "value"} must have <= ${t.maxItems} items`), t.items) {
|
|
1157
1165
|
for (let o = 0; o < e.length; o += 1)
|
|
1158
|
-
if (
|
|
1166
|
+
if (bt(t.items, e[o], `${r}[${o}]`, n), n.length) return;
|
|
1159
1167
|
}
|
|
1160
1168
|
return;
|
|
1161
1169
|
case "object":
|
|
@@ -1172,7 +1180,7 @@ function ht(t, e, r, n) {
|
|
|
1172
1180
|
}
|
|
1173
1181
|
if (t.properties) for (const [o, i] of Object.entries(t.properties)) {
|
|
1174
1182
|
const a = e[o];
|
|
1175
|
-
if (a !== void 0 && (
|
|
1183
|
+
if (a !== void 0 && (bt(i, a, r ? `${r}.${o}` : o, n), n.length))
|
|
1176
1184
|
return;
|
|
1177
1185
|
}
|
|
1178
1186
|
return;
|
|
@@ -1181,12 +1189,13 @@ function ht(t, e, r, n) {
|
|
|
1181
1189
|
}
|
|
1182
1190
|
}
|
|
1183
1191
|
}
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1192
|
+
var Pr = 12e4;
|
|
1193
|
+
async function Io({ request: t, accountModule: e, contextStore: r, beClient: n, toolBridge: o, emit: i, rpc: a, signal: s }) {
|
|
1194
|
+
const c = performance.now(), u = await r.load(t), l = u.thread.id, f = Qr(t);
|
|
1195
|
+
zr(u, f) && r.appendUserMessage(l, f);
|
|
1196
|
+
const d = Sr(e.flows, t);
|
|
1188
1197
|
if (!d)
|
|
1189
|
-
return i(
|
|
1198
|
+
return i(Ar("unknown_action", `No agent flow for request type ${t?.type || "inputText"}`)), i(re()), {
|
|
1190
1199
|
steps: 0,
|
|
1191
1200
|
productSkusEmitted: []
|
|
1192
1201
|
};
|
|
@@ -1199,7 +1208,7 @@ async function To({ request: t, accountModule: e, contextStore: r, beClient: n,
|
|
|
1199
1208
|
steps: 0,
|
|
1200
1209
|
productSkusEmitted: /* @__PURE__ */ new Set(),
|
|
1201
1210
|
committed: !1,
|
|
1202
|
-
messageLimit:
|
|
1211
|
+
messageLimit: Yr(e.contextPersistence?.messageLimit),
|
|
1203
1212
|
catalogMapper: e.catalogMapper,
|
|
1204
1213
|
similarityMapper: e.similarityMapper
|
|
1205
1214
|
}, m = {
|
|
@@ -1213,14 +1222,14 @@ async function To({ request: t, accountModule: e, contextStore: r, beClient: n,
|
|
|
1213
1222
|
...e.trace ? { trace: e.trace } : {},
|
|
1214
1223
|
...e.hooks ? { hooks: e.hooks } : {}
|
|
1215
1224
|
};
|
|
1216
|
-
await
|
|
1225
|
+
await v(m, q("turn:start", p));
|
|
1217
1226
|
try {
|
|
1218
|
-
await
|
|
1227
|
+
await U(d, p, m), p.committed || await Ot(p, m);
|
|
1219
1228
|
} catch (h) {
|
|
1220
|
-
throw await
|
|
1221
|
-
...
|
|
1222
|
-
latencyMs:
|
|
1223
|
-
errorCode:
|
|
1229
|
+
throw await v(m, {
|
|
1230
|
+
...q("turn:error", p),
|
|
1231
|
+
latencyMs: I(c),
|
|
1232
|
+
errorCode: G(h)
|
|
1224
1233
|
}), h;
|
|
1225
1234
|
}
|
|
1226
1235
|
return await a("beacon.send", {
|
|
@@ -1229,95 +1238,95 @@ async function To({ request: t, accountModule: e, contextStore: r, beClient: n,
|
|
|
1229
1238
|
sessionId: t?.session_id || t?.sessionId || l,
|
|
1230
1239
|
accountId: e.accountId || p.context.meta.accountId,
|
|
1231
1240
|
steps: p.steps,
|
|
1232
|
-
totalLatencyMs:
|
|
1241
|
+
totalLatencyMs: I(c),
|
|
1233
1242
|
productSkusEmitted: [...p.productSkusEmitted]
|
|
1234
|
-
}), await
|
|
1235
|
-
...
|
|
1236
|
-
latencyMs:
|
|
1243
|
+
}), await v(m, {
|
|
1244
|
+
...q("turn:end", p),
|
|
1245
|
+
latencyMs: I(c)
|
|
1237
1246
|
}), {
|
|
1238
1247
|
steps: p.steps,
|
|
1239
1248
|
productSkusEmitted: [...p.productSkusEmitted]
|
|
1240
1249
|
};
|
|
1241
1250
|
}
|
|
1242
|
-
async function
|
|
1251
|
+
async function U(t, e, r) {
|
|
1243
1252
|
for (const n of t) {
|
|
1244
1253
|
if (r.signal?.aborted || e.committed) return;
|
|
1245
1254
|
e.steps += 1;
|
|
1246
1255
|
const o = e.steps, i = performance.now();
|
|
1247
|
-
await
|
|
1256
|
+
await v(r, yt("step:start", e, n, o));
|
|
1248
1257
|
try {
|
|
1249
|
-
await
|
|
1250
|
-
...
|
|
1251
|
-
latencyMs:
|
|
1258
|
+
await Ir(n, e, r), await v(r, {
|
|
1259
|
+
...yt("step:end", e, n, o),
|
|
1260
|
+
latencyMs: I(i)
|
|
1252
1261
|
});
|
|
1253
1262
|
} catch (a) {
|
|
1254
|
-
throw await
|
|
1255
|
-
...
|
|
1256
|
-
latencyMs:
|
|
1257
|
-
errorCode:
|
|
1263
|
+
throw await v(r, {
|
|
1264
|
+
...yt("step:error", e, n, o),
|
|
1265
|
+
latencyMs: I(i),
|
|
1266
|
+
errorCode: G(a)
|
|
1258
1267
|
}), a;
|
|
1259
1268
|
}
|
|
1260
1269
|
e.context = r.contextStore.patch(e.threadId, {}) || e.context;
|
|
1261
1270
|
}
|
|
1262
1271
|
}
|
|
1263
|
-
async function
|
|
1272
|
+
async function Ir(t, e, r) {
|
|
1264
1273
|
if (r.hooks?.transformContext) {
|
|
1265
|
-
const o = await r.hooks.transformContext(e.context);
|
|
1274
|
+
const o = await W(r, e, "transformContext", () => r.hooks.transformContext(e.context));
|
|
1266
1275
|
o && (e.context = o);
|
|
1267
1276
|
}
|
|
1268
|
-
const n =
|
|
1277
|
+
const n = D(e, r);
|
|
1269
1278
|
if (t.kind === "be_op") {
|
|
1270
|
-
await
|
|
1279
|
+
await Or(t, e, r, n);
|
|
1271
1280
|
return;
|
|
1272
1281
|
}
|
|
1273
1282
|
if (t.kind === "tool") {
|
|
1274
|
-
await
|
|
1283
|
+
await Rr(t, e, r, n);
|
|
1275
1284
|
return;
|
|
1276
1285
|
}
|
|
1277
1286
|
if (t.kind === "adapter") {
|
|
1278
|
-
await
|
|
1287
|
+
await Br(t, e, r, n);
|
|
1279
1288
|
return;
|
|
1280
1289
|
}
|
|
1281
1290
|
if (t.kind === "emit") {
|
|
1282
|
-
await
|
|
1291
|
+
await $r(t, e, r);
|
|
1283
1292
|
return;
|
|
1284
1293
|
}
|
|
1285
1294
|
if (t.kind === "patch") {
|
|
1286
|
-
await
|
|
1295
|
+
await Nr(t, e, r);
|
|
1287
1296
|
return;
|
|
1288
1297
|
}
|
|
1289
1298
|
if (t.kind === "branch") {
|
|
1290
|
-
await
|
|
1299
|
+
await Lr(t, e, r, n);
|
|
1291
1300
|
return;
|
|
1292
1301
|
}
|
|
1293
1302
|
if (t.kind === "agent_loop") {
|
|
1294
|
-
await
|
|
1303
|
+
await Fr(t, e, r, n);
|
|
1295
1304
|
return;
|
|
1296
1305
|
}
|
|
1297
1306
|
if (t.kind === "parallel") {
|
|
1298
|
-
await
|
|
1307
|
+
await qr(t, e, r);
|
|
1299
1308
|
return;
|
|
1300
1309
|
}
|
|
1301
1310
|
if (t.kind === "refusal") {
|
|
1302
|
-
await
|
|
1311
|
+
await Dr(t, e, r, n);
|
|
1303
1312
|
return;
|
|
1304
1313
|
}
|
|
1305
|
-
t.kind === "commit" && await
|
|
1314
|
+
t.kind === "commit" && await Ur(t, e, r);
|
|
1306
1315
|
}
|
|
1307
|
-
async function
|
|
1316
|
+
async function Or(t, e, r, n) {
|
|
1308
1317
|
const o = performance.now();
|
|
1309
1318
|
let i;
|
|
1310
1319
|
try {
|
|
1311
1320
|
let s = await _(t.input, n);
|
|
1312
1321
|
if (r.hooks?.beforeBeOp) {
|
|
1313
|
-
const c = await r.hooks.beforeBeOp(t.op, s, n);
|
|
1322
|
+
const c = await W(r, e, "beforeBeOp", () => r.hooks.beforeBeOp(t.op, s, n));
|
|
1314
1323
|
c && "cached" in c && c.cached !== void 0 ? i = c.cached : c && "input" in c && c.input !== void 0 && (s = c.input);
|
|
1315
1324
|
}
|
|
1316
1325
|
if (i === void 0) {
|
|
1317
|
-
const c = await _(t.cache, n), u =
|
|
1318
|
-
await
|
|
1319
|
-
const m = p ? new AbortController() : null, h =
|
|
1320
|
-
i = await
|
|
1326
|
+
const c = await _(t.cache, n), u = jr(t, e, s, c), l = await _(t.cacheTtlS, n) ?? u.cacheTtlS, f = await _(t.cacheKey, n) ?? u.cacheKey, d = await _(t.browserCache, n), p = Y(await _(t.timeoutMs, n));
|
|
1327
|
+
await jt(t, e, r, n);
|
|
1328
|
+
const m = p ? new AbortController() : null, h = ce(r.signal, m?.signal);
|
|
1329
|
+
i = await Q(r.beClient.invoke({
|
|
1321
1330
|
op: t.op,
|
|
1322
1331
|
input: s,
|
|
1323
1332
|
...l !== void 0 ? { cacheTtlS: l } : {},
|
|
@@ -1330,7 +1339,7 @@ async function Er(t, e, r, n) {
|
|
|
1330
1339
|
}), () => m?.abort());
|
|
1331
1340
|
}
|
|
1332
1341
|
if (r.hooks?.afterBeOp) {
|
|
1333
|
-
const c = await r.hooks.afterBeOp(t.op, i, n);
|
|
1342
|
+
const c = await W(r, e, "afterBeOp", () => r.hooks.afterBeOp(t.op, i, n));
|
|
1334
1343
|
c && "result" in c && c.result !== void 0 && (i = c.result);
|
|
1335
1344
|
}
|
|
1336
1345
|
} catch (s) {
|
|
@@ -1341,16 +1350,16 @@ async function Er(t, e, r, n) {
|
|
|
1341
1350
|
accountId: e.context.meta.accountId,
|
|
1342
1351
|
op: t.op,
|
|
1343
1352
|
status: "error",
|
|
1344
|
-
latencyMs:
|
|
1353
|
+
latencyMs: I(o),
|
|
1345
1354
|
errorCode: u
|
|
1346
1355
|
};
|
|
1347
1356
|
if (await r.rpc("beacon.send", l), t.onError) {
|
|
1348
|
-
t.errorOut && (e.bag[t.errorOut] = s), await
|
|
1357
|
+
t.errorOut && (e.bag[t.errorOut] = s), await U(t.onError, e, r);
|
|
1349
1358
|
return;
|
|
1350
1359
|
}
|
|
1351
1360
|
throw s;
|
|
1352
1361
|
}
|
|
1353
|
-
t.out && (e.bag[t.out] = i), await
|
|
1362
|
+
t.out && (e.bag[t.out] = i), await at(t, i, e, r.contextStore);
|
|
1354
1363
|
const a = {
|
|
1355
1364
|
type: "agentOp",
|
|
1356
1365
|
threadId: e.threadId,
|
|
@@ -1358,18 +1367,18 @@ async function Er(t, e, r, n) {
|
|
|
1358
1367
|
accountId: e.context.meta.accountId,
|
|
1359
1368
|
op: t.op,
|
|
1360
1369
|
status: "ok",
|
|
1361
|
-
latencyMs:
|
|
1370
|
+
latencyMs: I(o)
|
|
1362
1371
|
};
|
|
1363
1372
|
await r.rpc("beacon.send", a);
|
|
1364
1373
|
}
|
|
1365
|
-
function
|
|
1374
|
+
function jr(t, e, r, n) {
|
|
1366
1375
|
if (!n || n.strategy !== "input-hash") return {};
|
|
1367
|
-
const o =
|
|
1376
|
+
const o = Y(n.ttlS);
|
|
1368
1377
|
if (!o) return {};
|
|
1369
|
-
const i = e.context.meta.locale, a = n.promptVersion ||
|
|
1378
|
+
const i = e.context.meta.locale, a = n.promptVersion || Mr(r) || "current";
|
|
1370
1379
|
return {
|
|
1371
1380
|
cacheTtlS: o,
|
|
1372
|
-
cacheKey:
|
|
1381
|
+
cacheKey: oe(t.op, {
|
|
1373
1382
|
account: e.context.meta.accountId,
|
|
1374
1383
|
locale: i,
|
|
1375
1384
|
promptVersion: a,
|
|
@@ -1377,19 +1386,19 @@ function Pr(t, e, r, n) {
|
|
|
1377
1386
|
}, { version: "input-hash" })
|
|
1378
1387
|
};
|
|
1379
1388
|
}
|
|
1380
|
-
function
|
|
1389
|
+
function Mr(t) {
|
|
1381
1390
|
if (!t || typeof t != "object" || Array.isArray(t)) return;
|
|
1382
1391
|
const e = t, r = e.prompt_version || e.promptVersion;
|
|
1383
1392
|
return typeof r == "string" && r.trim() ? r.trim() : void 0;
|
|
1384
1393
|
}
|
|
1385
|
-
async function
|
|
1394
|
+
async function Rr(t, e, r, n) {
|
|
1386
1395
|
const o = performance.now();
|
|
1387
1396
|
try {
|
|
1388
|
-
await
|
|
1389
|
-
const i =
|
|
1397
|
+
await jt(t, e, r, n);
|
|
1398
|
+
const i = Y(await _(t.timeoutMs, n));
|
|
1390
1399
|
let a = await _(t.input, n);
|
|
1391
1400
|
if (r.hooks?.beforeToolCall) {
|
|
1392
|
-
const c = await r.hooks.beforeToolCall(t.name, a, n);
|
|
1401
|
+
const c = await W(r, e, "beforeToolCall", () => r.hooks.beforeToolCall(t.name, a, n));
|
|
1393
1402
|
if (c?.block) throw new x("tool_blocked", c.reason || `Tool '${t.name}' blocked by hook.`, {
|
|
1394
1403
|
source: "tool",
|
|
1395
1404
|
sourceCode: "blocked"
|
|
@@ -1397,99 +1406,99 @@ async function jr(t, e, r, n) {
|
|
|
1397
1406
|
c && "args" in c && c.args !== void 0 && (a = c.args);
|
|
1398
1407
|
}
|
|
1399
1408
|
if (t.parameters) {
|
|
1400
|
-
const c =
|
|
1409
|
+
const c = Er(t.parameters, a);
|
|
1401
1410
|
if (!c.ok) throw new x("tool_invalid_args", `Invalid args for tool '${t.name}': ${c.error}`, {
|
|
1402
1411
|
source: "tool",
|
|
1403
1412
|
sourceCode: "invalid_args"
|
|
1404
1413
|
});
|
|
1405
1414
|
}
|
|
1406
|
-
let s = await
|
|
1415
|
+
let s = await Q(r.toolBridge.invoke(t.name, a), i, () => new x("tool_timeout", "The assistant tool took too long to respond.", {
|
|
1407
1416
|
source: "tool",
|
|
1408
1417
|
sourceCode: "timeout"
|
|
1409
1418
|
}));
|
|
1410
1419
|
if (r.hooks?.afterToolCall) {
|
|
1411
|
-
const c = await r.hooks.afterToolCall(t.name, s, n);
|
|
1420
|
+
const c = await W(r, e, "afterToolCall", () => r.hooks.afterToolCall(t.name, s, n));
|
|
1412
1421
|
c && "result" in c && c.result !== void 0 && (s = c.result), c?.terminate && (e.committed = !0);
|
|
1413
1422
|
}
|
|
1414
|
-
t.out && (e.bag[t.out] = s), await
|
|
1423
|
+
t.out && (e.bag[t.out] = s), await at(t, s, e, r.contextStore), await r.rpc("beacon.send", {
|
|
1415
1424
|
type: "agentTool",
|
|
1416
1425
|
threadId: e.threadId,
|
|
1417
|
-
sessionId:
|
|
1426
|
+
sessionId: Z(e),
|
|
1418
1427
|
accountId: e.context.meta.accountId,
|
|
1419
1428
|
tool: t.name,
|
|
1420
1429
|
status: "ok",
|
|
1421
|
-
latencyMs:
|
|
1430
|
+
latencyMs: I(o)
|
|
1422
1431
|
});
|
|
1423
1432
|
} catch (i) {
|
|
1424
1433
|
const a = i;
|
|
1425
1434
|
if (await r.rpc("beacon.send", {
|
|
1426
1435
|
type: "agentTool",
|
|
1427
1436
|
threadId: e.threadId,
|
|
1428
|
-
sessionId:
|
|
1437
|
+
sessionId: Z(e),
|
|
1429
1438
|
accountId: e.context.meta.accountId,
|
|
1430
1439
|
tool: t.name,
|
|
1431
1440
|
status: "error",
|
|
1432
|
-
latencyMs:
|
|
1441
|
+
latencyMs: I(o),
|
|
1433
1442
|
errorCode: String(a?.code || a?.name || "unknown")
|
|
1434
1443
|
}), t.onError) {
|
|
1435
|
-
t.errorOut && (e.bag[t.errorOut] = i), await
|
|
1444
|
+
t.errorOut && (e.bag[t.errorOut] = i), await U(t.onError, e, r);
|
|
1436
1445
|
return;
|
|
1437
1446
|
}
|
|
1438
1447
|
throw i;
|
|
1439
1448
|
}
|
|
1440
1449
|
}
|
|
1441
|
-
async function
|
|
1450
|
+
async function Br(t, e, r, n) {
|
|
1442
1451
|
const o = r.adapters?.[t.name];
|
|
1443
1452
|
if (typeof o != "function") throw new Error(`Unknown flow adapter: ${t.name}`);
|
|
1444
|
-
await
|
|
1445
|
-
const i =
|
|
1453
|
+
await jt(t, e, r, n);
|
|
1454
|
+
const i = Y(await _(t.timeoutMs, n)), a = await Q(o(await _(t.input, n), n), i, () => new x("adapter_timeout", "The assistant adapter took too long to respond.", {
|
|
1446
1455
|
source: "adapter",
|
|
1447
1456
|
sourceCode: "timeout"
|
|
1448
1457
|
}));
|
|
1449
|
-
t.out && (e.bag[t.out] = a), await
|
|
1458
|
+
t.out && (e.bag[t.out] = a), await at(t, a, e, r.contextStore);
|
|
1450
1459
|
}
|
|
1451
|
-
async function
|
|
1452
|
-
const n = await t.build(
|
|
1453
|
-
|
|
1460
|
+
async function $r(t, e, r) {
|
|
1461
|
+
const n = await t.build(D(e, r));
|
|
1462
|
+
Xr(n, e.productSkusEmitted), r.emit(n);
|
|
1454
1463
|
}
|
|
1455
|
-
async function
|
|
1456
|
-
await
|
|
1464
|
+
async function Nr(t, e, r) {
|
|
1465
|
+
await at(t, void 0, e, r.contextStore);
|
|
1457
1466
|
}
|
|
1458
|
-
async function
|
|
1467
|
+
async function Lr(t, e, r, n) {
|
|
1459
1468
|
const o = String(await _(t.on, n) || "default");
|
|
1460
|
-
await
|
|
1469
|
+
await U(t.cases[o] || t.cases.default || [], e, r);
|
|
1461
1470
|
}
|
|
1462
|
-
async function
|
|
1471
|
+
async function Fr(t, e, r, n) {
|
|
1463
1472
|
if (!await t.shouldContinue(e.bag, n)) return;
|
|
1464
1473
|
const o = Math.max(0, Math.floor(Number(t.maxIterations) || 0));
|
|
1465
1474
|
let i = 0;
|
|
1466
1475
|
for (; !r.signal?.aborted && !e.committed; ) {
|
|
1467
|
-
if (await
|
|
1468
|
-
const a = await t.onIterate?.(e.bag,
|
|
1476
|
+
if (await U(t.body, e, r), r.signal?.aborted || e.committed || !await t.shouldContinue(e.bag, D(e, r)) || i >= o) return;
|
|
1477
|
+
const a = await t.onIterate?.(e.bag, D(e, r));
|
|
1469
1478
|
a && typeof a == "object" && Object.assign(e.bag, a), i += 1;
|
|
1470
1479
|
}
|
|
1471
1480
|
}
|
|
1472
|
-
async function
|
|
1473
|
-
const n =
|
|
1481
|
+
async function qr(t, e, r) {
|
|
1482
|
+
const n = Y(await _(t.timeoutMs, D(e, r))), o = n ? new AbortController() : null, i = ce(r.signal, o?.signal), a = t.steps.map((u) => {
|
|
1474
1483
|
const l = {
|
|
1475
1484
|
...e,
|
|
1476
|
-
context:
|
|
1477
|
-
bag:
|
|
1485
|
+
context: Vr(e.context),
|
|
1486
|
+
bag: kt(e.bag),
|
|
1478
1487
|
productSkusEmitted: new Set(e.productSkusEmitted),
|
|
1479
1488
|
committed: !1
|
|
1480
1489
|
}, f = [];
|
|
1481
|
-
return
|
|
1490
|
+
return U(u, l, {
|
|
1482
1491
|
...r,
|
|
1483
1492
|
emit: (d) => {
|
|
1484
1493
|
!i?.aborted && d.type !== "done" && f.push(d);
|
|
1485
1494
|
},
|
|
1486
|
-
contextStore:
|
|
1495
|
+
contextStore: Kr(l),
|
|
1487
1496
|
...i ? { signal: i } : {}
|
|
1488
1497
|
}).then(() => ({
|
|
1489
1498
|
state: l,
|
|
1490
1499
|
events: f
|
|
1491
1500
|
}));
|
|
1492
|
-
}), s = await
|
|
1501
|
+
}), s = await Q(Promise.all(a), n, () => new x("parallel_timeout", "The assistant parallel step took too long to respond.", {
|
|
1493
1502
|
source: "agent",
|
|
1494
1503
|
sourceCode: "timeout"
|
|
1495
1504
|
}), () => o?.abort()), c = t.merge || {};
|
|
@@ -1498,11 +1507,11 @@ async function Lr(t, e, r) {
|
|
|
1498
1507
|
for (const f of u.productSkusEmitted) e.productSkusEmitted.add(f);
|
|
1499
1508
|
for (const f of c.bag || []) Object.prototype.hasOwnProperty.call(u.bag, f) && (e.bag[f] = u.bag[f]);
|
|
1500
1509
|
if (c.panel?.length) {
|
|
1501
|
-
const f =
|
|
1510
|
+
const f = Jt(u.context.panel, c.panel);
|
|
1502
1511
|
Object.keys(f).length && (e.context = r.contextStore.patch(e.threadId, { panel: f }) || e.context);
|
|
1503
1512
|
}
|
|
1504
1513
|
if (c.threadExtensions?.length) {
|
|
1505
|
-
const f =
|
|
1514
|
+
const f = Jt(u.context.thread.extensions, c.threadExtensions);
|
|
1506
1515
|
Object.keys(f).length && (e.context = r.contextStore.patch(e.threadId, { thread: {
|
|
1507
1516
|
...e.context.thread,
|
|
1508
1517
|
extensions: f
|
|
@@ -1510,21 +1519,21 @@ async function Lr(t, e, r) {
|
|
|
1510
1519
|
}
|
|
1511
1520
|
}
|
|
1512
1521
|
}
|
|
1513
|
-
async function
|
|
1514
|
-
r.emit(
|
|
1522
|
+
async function Dr(t, e, r, n) {
|
|
1523
|
+
r.emit(_r(await _(t.message, n), !0)), await Ot(e, r);
|
|
1515
1524
|
}
|
|
1516
|
-
async function
|
|
1517
|
-
await
|
|
1525
|
+
async function Ur(t, e, r) {
|
|
1526
|
+
await Ot(e, r);
|
|
1518
1527
|
}
|
|
1519
|
-
async function
|
|
1520
|
-
t.committed || (t.context = await e.commit(t.threadId) || t.context, t.committed = !0, r(
|
|
1528
|
+
async function Ot(t, { contextStore: e, emit: r }) {
|
|
1529
|
+
t.committed || (t.context = await e.commit(t.threadId) || t.context, t.committed = !0, r(re()));
|
|
1521
1530
|
}
|
|
1522
|
-
async function
|
|
1531
|
+
async function at(t, e, r, n) {
|
|
1523
1532
|
if (typeof t.patch != "function") return;
|
|
1524
|
-
const o = await t.patch(r.context, e,
|
|
1533
|
+
const o = await t.patch(r.context, e, D(r));
|
|
1525
1534
|
o && (r.context = n.patch(r.threadId, o) || r.context);
|
|
1526
1535
|
}
|
|
1527
|
-
function
|
|
1536
|
+
function D(t, e) {
|
|
1528
1537
|
return {
|
|
1529
1538
|
request: t.request,
|
|
1530
1539
|
context: t.context,
|
|
@@ -1539,38 +1548,38 @@ function q(t, e) {
|
|
|
1539
1548
|
...e?.signal ? { signal: e.signal } : {}
|
|
1540
1549
|
};
|
|
1541
1550
|
}
|
|
1542
|
-
function
|
|
1551
|
+
function Z(t) {
|
|
1543
1552
|
return t.request?.session_id || t.request?.sessionId || t.threadId;
|
|
1544
1553
|
}
|
|
1545
|
-
function
|
|
1554
|
+
function zr(t, e) {
|
|
1546
1555
|
if (!e) return !1;
|
|
1547
1556
|
const r = t.messages[t.messages.length - 1];
|
|
1548
1557
|
return r?.role !== "user" || r.content !== e;
|
|
1549
1558
|
}
|
|
1550
|
-
function
|
|
1559
|
+
function Jt(t, e) {
|
|
1551
1560
|
const r = {};
|
|
1552
1561
|
for (const n of e) Object.prototype.hasOwnProperty.call(t, n) && (r[n] = t[n]);
|
|
1553
1562
|
return r;
|
|
1554
1563
|
}
|
|
1555
|
-
function
|
|
1564
|
+
function Vr(t) {
|
|
1556
1565
|
return {
|
|
1557
1566
|
...t,
|
|
1558
|
-
panel:
|
|
1567
|
+
panel: kt(t.panel || {}),
|
|
1559
1568
|
thread: {
|
|
1560
1569
|
...t.thread,
|
|
1561
|
-
extensions:
|
|
1570
|
+
extensions: kt(t.thread?.extensions || {})
|
|
1562
1571
|
},
|
|
1563
1572
|
meta: t.meta,
|
|
1564
1573
|
messages: t.messages
|
|
1565
1574
|
};
|
|
1566
1575
|
}
|
|
1567
|
-
function
|
|
1576
|
+
function Kr(t) {
|
|
1568
1577
|
return {
|
|
1569
1578
|
async load() {
|
|
1570
1579
|
return t.context;
|
|
1571
1580
|
},
|
|
1572
1581
|
patch(e, r) {
|
|
1573
|
-
return t.context =
|
|
1582
|
+
return t.context = Hr(t.context, r, t.messageLimit), t.context;
|
|
1574
1583
|
},
|
|
1575
1584
|
appendUserMessage() {
|
|
1576
1585
|
return t.context;
|
|
@@ -1580,9 +1589,9 @@ function Ur(t) {
|
|
|
1580
1589
|
}
|
|
1581
1590
|
};
|
|
1582
1591
|
}
|
|
1583
|
-
function
|
|
1592
|
+
function Hr(t, e, r) {
|
|
1584
1593
|
if (!e || typeof e != "object") return t;
|
|
1585
|
-
const n =
|
|
1594
|
+
const n = Zt(t.panel, e.panel), o = Zt(t.thread?.extensions || {}, e.thread?.extensions);
|
|
1586
1595
|
return {
|
|
1587
1596
|
...t,
|
|
1588
1597
|
...e,
|
|
@@ -1596,24 +1605,24 @@ function zr(t, e, r) {
|
|
|
1596
1605
|
...t.meta || {},
|
|
1597
1606
|
...e.meta || {}
|
|
1598
1607
|
},
|
|
1599
|
-
messages: Array.isArray(e.messages) ?
|
|
1608
|
+
messages: Array.isArray(e.messages) ? it(e.messages, r) : t.messages
|
|
1600
1609
|
};
|
|
1601
1610
|
}
|
|
1602
|
-
function
|
|
1611
|
+
function Zt(t, e) {
|
|
1603
1612
|
if (!e || typeof e != "object" || Array.isArray(e)) return t;
|
|
1604
1613
|
const r = {};
|
|
1605
1614
|
for (const n of Object.keys(t)) r[n] = t[n];
|
|
1606
1615
|
for (const [n, o] of Object.entries(e)) r[n] = o;
|
|
1607
1616
|
return r;
|
|
1608
1617
|
}
|
|
1609
|
-
function
|
|
1618
|
+
function kt(t) {
|
|
1610
1619
|
return new Proxy({}, {
|
|
1611
1620
|
get(e, r, n) {
|
|
1612
1621
|
if (typeof r != "string") return Reflect.get(e, r, n);
|
|
1613
1622
|
if (Object.prototype.hasOwnProperty.call(e, r)) return e[r];
|
|
1614
1623
|
const o = t[r];
|
|
1615
|
-
if (
|
|
1616
|
-
const i =
|
|
1624
|
+
if (Jr(o)) {
|
|
1625
|
+
const i = Zr(o);
|
|
1617
1626
|
return e[r] = i, i;
|
|
1618
1627
|
}
|
|
1619
1628
|
return o;
|
|
@@ -1629,10 +1638,10 @@ function wt(t) {
|
|
|
1629
1638
|
}
|
|
1630
1639
|
});
|
|
1631
1640
|
}
|
|
1632
|
-
function
|
|
1641
|
+
function Jr(t) {
|
|
1633
1642
|
return !!(t && typeof t == "object");
|
|
1634
1643
|
}
|
|
1635
|
-
function
|
|
1644
|
+
function Zr(t) {
|
|
1636
1645
|
if (typeof structuredClone == "function") try {
|
|
1637
1646
|
return structuredClone(t);
|
|
1638
1647
|
} catch {
|
|
@@ -1646,12 +1655,12 @@ function Kr(t) {
|
|
|
1646
1655
|
async function _(t, e) {
|
|
1647
1656
|
return typeof t == "function" ? await t(e) : t;
|
|
1648
1657
|
}
|
|
1649
|
-
function
|
|
1658
|
+
function Y(t) {
|
|
1650
1659
|
if (t === void 0) return;
|
|
1651
1660
|
const e = Math.floor(Number(t));
|
|
1652
1661
|
return Number.isFinite(e) && e > 0 ? e : void 0;
|
|
1653
1662
|
}
|
|
1654
|
-
async function
|
|
1663
|
+
async function Q(t, e, r, n) {
|
|
1655
1664
|
if (!e) return t;
|
|
1656
1665
|
let o, i = !1;
|
|
1657
1666
|
return new Promise((a, s) => {
|
|
@@ -1664,45 +1673,48 @@ async function ot(t, e, r, n) {
|
|
|
1664
1673
|
});
|
|
1665
1674
|
});
|
|
1666
1675
|
}
|
|
1667
|
-
function
|
|
1676
|
+
function ce(t, e) {
|
|
1668
1677
|
if (!t) return e;
|
|
1669
1678
|
if (!e || t.aborted) return t;
|
|
1670
1679
|
if (e.aborted) return e;
|
|
1671
1680
|
const r = new AbortController(), n = () => r.abort();
|
|
1672
1681
|
return t.addEventListener("abort", n, { once: !0 }), e.addEventListener("abort", n, { once: !0 }), r.signal;
|
|
1673
1682
|
}
|
|
1674
|
-
async function
|
|
1683
|
+
async function jt(t, e, r, n) {
|
|
1675
1684
|
if (!t.confirm) return;
|
|
1676
1685
|
const o = await _(t.confirm, n);
|
|
1677
1686
|
if (!o) return;
|
|
1678
|
-
const i =
|
|
1679
|
-
await
|
|
1687
|
+
const i = Wr(o, t, e);
|
|
1688
|
+
await v(r, gt("confirmation:start", e, t));
|
|
1680
1689
|
try {
|
|
1681
|
-
const a = await r.rpc("confirmation.request", i),
|
|
1682
|
-
|
|
1690
|
+
const a = await Q(r.rpc("confirmation.request", i), Pr, () => new x("confirmation_timeout", "The confirmation prompt timed out without a response.", {
|
|
1691
|
+
source: t.kind === "be_op" ? "be" : t.kind,
|
|
1692
|
+
sourceCode: "confirmation_timeout"
|
|
1693
|
+
})), s = typeof a == "boolean" ? a : a?.confirmed === !0;
|
|
1694
|
+
if (await v(r, gt("confirmation:end", e, t)), s) return;
|
|
1683
1695
|
throw new x("confirmation_declined", "The requested action was not confirmed.", {
|
|
1684
1696
|
source: t.kind === "be_op" ? "be" : t.kind,
|
|
1685
1697
|
sourceCode: "confirmation_declined",
|
|
1686
1698
|
detail: a
|
|
1687
1699
|
});
|
|
1688
1700
|
} catch (a) {
|
|
1689
|
-
throw await
|
|
1690
|
-
...
|
|
1691
|
-
errorCode:
|
|
1701
|
+
throw await v(r, {
|
|
1702
|
+
...gt("confirmation:error", e, t),
|
|
1703
|
+
errorCode: G(a)
|
|
1692
1704
|
}), a;
|
|
1693
1705
|
}
|
|
1694
1706
|
}
|
|
1695
|
-
function
|
|
1707
|
+
function Wr(t, e, r) {
|
|
1696
1708
|
return {
|
|
1697
|
-
...
|
|
1709
|
+
...Gr(t),
|
|
1698
1710
|
accountId: r.context.meta.accountId,
|
|
1699
1711
|
threadId: r.threadId,
|
|
1700
|
-
sessionId:
|
|
1712
|
+
sessionId: Z(r),
|
|
1701
1713
|
stepKind: e.kind,
|
|
1702
1714
|
...e.kind === "be_op" ? { stepName: e.op } : { stepName: e.name }
|
|
1703
1715
|
};
|
|
1704
1716
|
}
|
|
1705
|
-
function
|
|
1717
|
+
function Gr(t) {
|
|
1706
1718
|
return typeof t == "string" ? { message: t } : t === !0 ? {} : t && typeof t == "object" ? {
|
|
1707
1719
|
...typeof t.title == "string" ? { title: t.title } : {},
|
|
1708
1720
|
...typeof t.message == "string" ? { message: t.message } : {},
|
|
@@ -1710,54 +1722,78 @@ function Jr(t) {
|
|
|
1710
1722
|
...Object.prototype.hasOwnProperty.call(t, "payload") ? { payload: t.payload } : {}
|
|
1711
1723
|
} : {};
|
|
1712
1724
|
}
|
|
1713
|
-
async function
|
|
1725
|
+
async function v(t, e) {
|
|
1714
1726
|
try {
|
|
1715
1727
|
await t.trace?.(e);
|
|
1716
1728
|
} catch {
|
|
1717
1729
|
}
|
|
1718
1730
|
}
|
|
1719
|
-
function
|
|
1731
|
+
async function W(t, e, r, n) {
|
|
1732
|
+
try {
|
|
1733
|
+
return await n();
|
|
1734
|
+
} catch (o) {
|
|
1735
|
+
await v(t, {
|
|
1736
|
+
...q("step:error", e),
|
|
1737
|
+
stepName: `hook:${r}`,
|
|
1738
|
+
errorCode: G(o)
|
|
1739
|
+
});
|
|
1740
|
+
try {
|
|
1741
|
+
await t.rpc("beacon.send", {
|
|
1742
|
+
type: "agentHookError",
|
|
1743
|
+
threadId: e.threadId,
|
|
1744
|
+
sessionId: Z(e),
|
|
1745
|
+
accountId: e.context.meta.accountId,
|
|
1746
|
+
hook: r,
|
|
1747
|
+
errorCode: G(o),
|
|
1748
|
+
message: o instanceof Error ? o.message : String(o)
|
|
1749
|
+
});
|
|
1750
|
+
} catch {
|
|
1751
|
+
}
|
|
1752
|
+
return;
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
function q(t, e) {
|
|
1720
1756
|
return {
|
|
1721
1757
|
type: t,
|
|
1722
1758
|
accountId: e.context.meta.accountId,
|
|
1723
1759
|
threadId: e.threadId,
|
|
1724
|
-
sessionId:
|
|
1760
|
+
sessionId: Z(e)
|
|
1725
1761
|
};
|
|
1726
1762
|
}
|
|
1727
|
-
function
|
|
1728
|
-
const o =
|
|
1763
|
+
function yt(t, e, r, n) {
|
|
1764
|
+
const o = ue(r);
|
|
1729
1765
|
return {
|
|
1730
|
-
...
|
|
1766
|
+
...q(t, e),
|
|
1731
1767
|
stepIndex: n,
|
|
1732
1768
|
stepKind: r.kind,
|
|
1733
1769
|
...o ? { stepName: o } : {}
|
|
1734
1770
|
};
|
|
1735
1771
|
}
|
|
1736
|
-
function
|
|
1737
|
-
const n =
|
|
1772
|
+
function gt(t, e, r) {
|
|
1773
|
+
const n = ue(r);
|
|
1738
1774
|
return {
|
|
1739
|
-
...
|
|
1775
|
+
...q(t, e),
|
|
1740
1776
|
stepKind: r.kind,
|
|
1741
1777
|
...n ? { stepName: n } : {}
|
|
1742
1778
|
};
|
|
1743
1779
|
}
|
|
1744
|
-
function
|
|
1780
|
+
function ue(t) {
|
|
1745
1781
|
if (t.kind === "be_op") return t.op;
|
|
1746
1782
|
if (t.kind === "tool" || t.kind === "adapter") return t.name;
|
|
1747
1783
|
}
|
|
1748
|
-
function
|
|
1784
|
+
function G(t) {
|
|
1749
1785
|
if (t && typeof t == "object") {
|
|
1750
1786
|
const e = t;
|
|
1751
1787
|
return String(e.sourceCode || e.code || e.name || "unknown");
|
|
1752
1788
|
}
|
|
1753
1789
|
return "unknown";
|
|
1754
1790
|
}
|
|
1755
|
-
function
|
|
1791
|
+
function Yr(t) {
|
|
1756
1792
|
if (t === void 0) return;
|
|
1757
1793
|
const e = Math.floor(Number(t));
|
|
1758
1794
|
return Number.isFinite(e) && e > 0 ? e : void 0;
|
|
1759
1795
|
}
|
|
1760
|
-
function
|
|
1796
|
+
function Qr(t) {
|
|
1761
1797
|
const e = t?.payload;
|
|
1762
1798
|
if (typeof e == "string") return e;
|
|
1763
1799
|
if (e && typeof e == "object" && "text" in e) {
|
|
@@ -1766,7 +1802,7 @@ function Wr(t) {
|
|
|
1766
1802
|
}
|
|
1767
1803
|
return typeof t?.action?.payload == "string" ? t.action.payload : typeof t?.action?.title == "string" ? t.action.title : "";
|
|
1768
1804
|
}
|
|
1769
|
-
function
|
|
1805
|
+
function Xr(t, e) {
|
|
1770
1806
|
const r = t, n = r.spec, o = Array.isArray(n?.items) ? n.items : void 0, i = Array.isArray(r.items) ? r.items : void 0, a = o || i;
|
|
1771
1807
|
if (Array.isArray(a)) {
|
|
1772
1808
|
for (const s of a) if (s && typeof s == "object") {
|
|
@@ -1775,7 +1811,7 @@ function Gr(t, e) {
|
|
|
1775
1811
|
}
|
|
1776
1812
|
}
|
|
1777
1813
|
}
|
|
1778
|
-
function
|
|
1814
|
+
function Oo(t) {
|
|
1779
1815
|
return { invoke(e, r) {
|
|
1780
1816
|
return t("tool.invoke", {
|
|
1781
1817
|
name: e,
|
|
@@ -1783,15 +1819,15 @@ function Eo(t) {
|
|
|
1783
1819
|
});
|
|
1784
1820
|
} };
|
|
1785
1821
|
}
|
|
1786
|
-
function
|
|
1822
|
+
function jo(t, e = {}) {
|
|
1787
1823
|
if (!Array.isArray(t)) return [];
|
|
1788
1824
|
const r = e.maxItems ?? 8, n = e.maxFeatures ?? 8;
|
|
1789
|
-
return t.map((o) =>
|
|
1825
|
+
return t.map((o) => tn(o, e.defaultBrand, n)).filter((o) => !!o).slice(0, r);
|
|
1790
1826
|
}
|
|
1791
|
-
function
|
|
1827
|
+
function tn(t, e, r) {
|
|
1792
1828
|
if (!t || typeof t != "object" || Array.isArray(t)) return null;
|
|
1793
|
-
const n = t, o =
|
|
1794
|
-
return o ?
|
|
1829
|
+
const n = t, o = Pt(n);
|
|
1830
|
+
return o ? nn({
|
|
1795
1831
|
sku: o.sku,
|
|
1796
1832
|
name: o.name,
|
|
1797
1833
|
url: o.url,
|
|
@@ -1801,37 +1837,37 @@ function Yr(t, e, r) {
|
|
|
1801
1837
|
category: o.category,
|
|
1802
1838
|
category_names: o.category_names,
|
|
1803
1839
|
brand: n.brand || e,
|
|
1804
|
-
features:
|
|
1805
|
-
specs:
|
|
1840
|
+
features: en(n.features, r),
|
|
1841
|
+
specs: rn(n.specs, r),
|
|
1806
1842
|
in_stock: o.in_stock
|
|
1807
1843
|
}) : null;
|
|
1808
1844
|
}
|
|
1809
|
-
function
|
|
1845
|
+
function en(t, e) {
|
|
1810
1846
|
return Array.isArray(t) ? t.filter(Boolean).slice(0, e) : void 0;
|
|
1811
1847
|
}
|
|
1812
|
-
function
|
|
1848
|
+
function rn(t, e) {
|
|
1813
1849
|
if (!(!t || typeof t != "object" || Array.isArray(t)))
|
|
1814
1850
|
return Object.fromEntries(Object.entries(t).filter(([, r]) => r != null).slice(0, e));
|
|
1815
1851
|
}
|
|
1816
|
-
function
|
|
1852
|
+
function nn(t) {
|
|
1817
1853
|
return Object.fromEntries(Object.entries(t).filter(([, e]) => e != null));
|
|
1818
1854
|
}
|
|
1819
|
-
function
|
|
1855
|
+
function le(t) {
|
|
1820
1856
|
if (!t || typeof t != "object" || Array.isArray(t)) return {};
|
|
1821
1857
|
const e = t, r = Array.isArray(e.rows) ? e.rows : [];
|
|
1822
1858
|
return {
|
|
1823
1859
|
...e,
|
|
1824
|
-
rows: r.map(
|
|
1860
|
+
rows: r.map(an).filter(Boolean)
|
|
1825
1861
|
};
|
|
1826
1862
|
}
|
|
1827
|
-
function
|
|
1828
|
-
const r = Array.isArray(t) ? t.filter((s) => !!(s && typeof s == "object" && !Array.isArray(s))) : [], n =
|
|
1863
|
+
function on(t, e) {
|
|
1864
|
+
const r = Array.isArray(t) ? t.filter((s) => !!(s && typeof s == "object" && !Array.isArray(s))) : [], n = le(e), o = Array.isArray(n.columns) ? n.columns.map(String) : [];
|
|
1829
1865
|
if (!o.length) return r;
|
|
1830
1866
|
const i = new Map(r.map((s) => [String(s.sku || s.id || ""), s])), a = o.map((s) => i.get(s)).filter((s) => !!s);
|
|
1831
1867
|
return a.length ? a : r;
|
|
1832
1868
|
}
|
|
1833
|
-
function
|
|
1834
|
-
const r =
|
|
1869
|
+
function Mo(t, e) {
|
|
1870
|
+
const r = le(t?.table), n = on(e, r);
|
|
1835
1871
|
return {
|
|
1836
1872
|
...t || {},
|
|
1837
1873
|
table: r,
|
|
@@ -1839,12 +1875,12 @@ function Io(t, e) {
|
|
|
1839
1875
|
multiple_product_details: n
|
|
1840
1876
|
};
|
|
1841
1877
|
}
|
|
1842
|
-
function
|
|
1878
|
+
function an(t) {
|
|
1843
1879
|
return !t || typeof t != "object" || Array.isArray(t) ? null : Object.fromEntries(Object.entries(t).filter(([, e]) => e !== void 0));
|
|
1844
1880
|
}
|
|
1845
|
-
function
|
|
1881
|
+
function Ro(t = [], e = {}) {
|
|
1846
1882
|
const r = {}, n = [];
|
|
1847
|
-
return (Array.isArray(t) ? t.map((o) =>
|
|
1883
|
+
return (Array.isArray(t) ? t.map((o) => Et(o, e)).filter((o) => !!o) : []).forEach((o, i) => {
|
|
1848
1884
|
const a = `product-${i.toString()}`;
|
|
1849
1885
|
n.push(a);
|
|
1850
1886
|
const s = {
|
|
@@ -1876,7 +1912,7 @@ function jo(t = [], e = {}) {
|
|
|
1876
1912
|
}
|
|
1877
1913
|
};
|
|
1878
1914
|
}
|
|
1879
|
-
function
|
|
1915
|
+
function Bo(t, e = {}) {
|
|
1880
1916
|
return {
|
|
1881
1917
|
widget: "chat",
|
|
1882
1918
|
panelHint: "panel",
|
|
@@ -1884,13 +1920,13 @@ function Oo(t, e = {}) {
|
|
|
1884
1920
|
root: "root",
|
|
1885
1921
|
elements: { root: {
|
|
1886
1922
|
type: "ProductDetailsPanel",
|
|
1887
|
-
props: { product:
|
|
1923
|
+
props: { product: Et(t, e) || t || {} }
|
|
1888
1924
|
} }
|
|
1889
1925
|
}
|
|
1890
1926
|
};
|
|
1891
1927
|
}
|
|
1892
|
-
function
|
|
1893
|
-
const r = (t.multiple_product_details || t.products || []).map((o) =>
|
|
1928
|
+
function $o(t = {}, e = {}) {
|
|
1929
|
+
const r = (t.multiple_product_details || t.products || []).map((o) => Et(o, e)).filter((o) => !!o), n = t.table || sn(t.comparison_table);
|
|
1894
1930
|
return {
|
|
1895
1931
|
widget: "chat",
|
|
1896
1932
|
panelHint: "panel",
|
|
@@ -1905,8 +1941,8 @@ function Ro(t = {}, e = {}) {
|
|
|
1905
1941
|
label: o,
|
|
1906
1942
|
values: Array.isArray(i) ? i.map(String) : [String(i ?? "")]
|
|
1907
1943
|
})),
|
|
1908
|
-
highlights:
|
|
1909
|
-
specialCases:
|
|
1944
|
+
highlights: Ht(t.key_differences),
|
|
1945
|
+
specialCases: Ht(t.special_considerations),
|
|
1910
1946
|
recommendedText: t.recommended_choice,
|
|
1911
1947
|
productActions: Object.fromEntries(r.map((o) => [o.sku, {
|
|
1912
1948
|
title: o.name,
|
|
@@ -1921,13 +1957,13 @@ function Ro(t = {}, e = {}) {
|
|
|
1921
1957
|
}
|
|
1922
1958
|
};
|
|
1923
1959
|
}
|
|
1924
|
-
function
|
|
1960
|
+
function sn(t) {
|
|
1925
1961
|
return Array.isArray(t) ? Object.fromEntries(t.map((e) => {
|
|
1926
1962
|
const r = typeof e?.label == "string" ? e.label.trim() : "";
|
|
1927
1963
|
return r ? [r, e.values] : null;
|
|
1928
1964
|
}).filter((e) => !!e)) : {};
|
|
1929
1965
|
}
|
|
1930
|
-
function
|
|
1966
|
+
function No(t = []) {
|
|
1931
1967
|
return {
|
|
1932
1968
|
widget: "chat",
|
|
1933
1969
|
panelHint: "inline",
|
|
@@ -1950,10 +1986,10 @@ function Mo(t = []) {
|
|
|
1950
1986
|
}
|
|
1951
1987
|
};
|
|
1952
1988
|
}
|
|
1953
|
-
function
|
|
1989
|
+
function Lo(t) {
|
|
1954
1990
|
return Object.freeze([...t]);
|
|
1955
1991
|
}
|
|
1956
|
-
function
|
|
1992
|
+
function cn(t) {
|
|
1957
1993
|
const e = t?.payload;
|
|
1958
1994
|
if (typeof e == "string") return e;
|
|
1959
1995
|
if (e && typeof e == "object" && "text" in e) {
|
|
@@ -1963,10 +1999,10 @@ function on(t) {
|
|
|
1963
1999
|
const r = t?.action;
|
|
1964
2000
|
return r && typeof r.payload == "string" ? r.payload : r && typeof r.title == "string" ? r.title : "";
|
|
1965
2001
|
}
|
|
1966
|
-
var
|
|
2002
|
+
var fe = [
|
|
1967
2003
|
{
|
|
1968
2004
|
pattern: /\bhttps?:\/\/[^\s?#]+(?:\?[^\s#]*)?/giu,
|
|
1969
|
-
replacement:
|
|
2005
|
+
replacement: ln
|
|
1970
2006
|
},
|
|
1971
2007
|
{
|
|
1972
2008
|
pattern: /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/giu,
|
|
@@ -1984,8 +2020,8 @@ var le = [
|
|
|
1984
2020
|
pattern: /\b(?:order|cart|session)[_-]?(?:id|no|number)?\s*[:#=]?\s*[A-Z0-9-]{6,}\b/giu,
|
|
1985
2021
|
replacement: "[secret]"
|
|
1986
2022
|
}
|
|
1987
|
-
],
|
|
1988
|
-
function
|
|
2023
|
+
], de = { patterns: fe };
|
|
2024
|
+
function pe(t, e = de) {
|
|
1989
2025
|
let r = typeof t == "string" ? t : t == null ? "" : String(t);
|
|
1990
2026
|
for (const n of e.patterns || []) {
|
|
1991
2027
|
const o = n.replacement;
|
|
@@ -1993,10 +2029,10 @@ function de(t, e = fe) {
|
|
|
1993
2029
|
}
|
|
1994
2030
|
return r;
|
|
1995
2031
|
}
|
|
1996
|
-
function
|
|
1997
|
-
return
|
|
2032
|
+
function un(t, e = de) {
|
|
2033
|
+
return pe(cn(t), e);
|
|
1998
2034
|
}
|
|
1999
|
-
function
|
|
2035
|
+
function ln(t) {
|
|
2000
2036
|
try {
|
|
2001
2037
|
const e = new URL(t);
|
|
2002
2038
|
return `${e.origin}${e.pathname}${e.search ? "?[query]" : ""}`;
|
|
@@ -2004,65 +2040,65 @@ function sn(t) {
|
|
|
2004
2040
|
return "[url]";
|
|
2005
2041
|
}
|
|
2006
2042
|
}
|
|
2007
|
-
var
|
|
2043
|
+
var fn = [
|
|
2008
2044
|
"assistantName",
|
|
2009
2045
|
"homeDomain",
|
|
2010
2046
|
"categories",
|
|
2011
2047
|
"policyTopics"
|
|
2012
|
-
],
|
|
2013
|
-
function
|
|
2014
|
-
const o =
|
|
2048
|
+
], dn = { intent: ["searchContract", "competitorBrands"] };
|
|
2049
|
+
function Fo(t, e, r, n = {}) {
|
|
2050
|
+
const o = pn(e, r, n);
|
|
2015
2051
|
return Object.keys(o).length ? {
|
|
2016
2052
|
...t,
|
|
2017
2053
|
account_config: o
|
|
2018
2054
|
} : t;
|
|
2019
2055
|
}
|
|
2020
|
-
function
|
|
2056
|
+
function pn(t, e, r = {}) {
|
|
2021
2057
|
if (!t) return {};
|
|
2022
|
-
const n = {}, o = r.baseKeys ||
|
|
2023
|
-
for (const s of o)
|
|
2058
|
+
const n = {}, o = r.baseKeys || fn;
|
|
2059
|
+
for (const s of o) Wt(n, t, s);
|
|
2024
2060
|
const i = t[e];
|
|
2025
|
-
i && typeof i == "object" && !Array.isArray(i) && Object.assign(n,
|
|
2026
|
-
const a = r.opAllowlist ||
|
|
2027
|
-
for (const s of a[e] || [])
|
|
2061
|
+
i && typeof i == "object" && !Array.isArray(i) && Object.assign(n, mn(i));
|
|
2062
|
+
const a = r.opAllowlist || dn;
|
|
2063
|
+
for (const s of a[e] || []) Wt(n, t, s);
|
|
2028
2064
|
return n;
|
|
2029
2065
|
}
|
|
2030
|
-
function
|
|
2066
|
+
function Wt(t, e, r) {
|
|
2031
2067
|
e[r] !== void 0 && (t[r] = e[r]);
|
|
2032
2068
|
}
|
|
2033
|
-
function
|
|
2069
|
+
function mn(t) {
|
|
2034
2070
|
return Object.fromEntries(Object.entries(t).filter(([, e]) => e !== void 0));
|
|
2035
2071
|
}
|
|
2036
|
-
var
|
|
2037
|
-
function
|
|
2072
|
+
var yn = "input-hash";
|
|
2073
|
+
function gn({ ttlS: t, promptVersion: e = "current" } = {}) {
|
|
2038
2074
|
if (!Number.isFinite(t) || t <= 0) throw new Error("inputHashCachePolicy requires a positive ttlS");
|
|
2039
2075
|
return {
|
|
2040
|
-
strategy:
|
|
2076
|
+
strategy: yn,
|
|
2041
2077
|
ttlS: t,
|
|
2042
2078
|
promptVersion: e
|
|
2043
2079
|
};
|
|
2044
2080
|
}
|
|
2045
|
-
function
|
|
2081
|
+
function hn({ accountId: t = "", op: e, ttlS: r, promptVersion: n = "current", input: o, keyParts: i, locale: a } = {}) {
|
|
2046
2082
|
if (!e) throw new Error("declarativeBeOpCache requires an op");
|
|
2047
2083
|
return {
|
|
2048
|
-
cache:
|
|
2084
|
+
cache: gn({
|
|
2049
2085
|
ttlS: r,
|
|
2050
2086
|
promptVersion: n
|
|
2051
2087
|
}),
|
|
2052
2088
|
cacheTtlS: r,
|
|
2053
|
-
cacheKey: (s = {}) =>
|
|
2089
|
+
cacheKey: (s = {}) => oe(e, {
|
|
2054
2090
|
account: t,
|
|
2055
|
-
locale:
|
|
2091
|
+
locale: ht(a, s) || s.context?.meta?.locale || s.locale || "",
|
|
2056
2092
|
promptVersion: n,
|
|
2057
|
-
payload:
|
|
2058
|
-
...
|
|
2093
|
+
payload: _t(ht(o, s)),
|
|
2094
|
+
...wn(ht(i, s))
|
|
2059
2095
|
})
|
|
2060
2096
|
};
|
|
2061
2097
|
}
|
|
2062
|
-
function
|
|
2098
|
+
function qo(t, e = {}) {
|
|
2063
2099
|
return !t || t.kind !== "be_op" ? t : {
|
|
2064
2100
|
...t,
|
|
2065
|
-
...
|
|
2101
|
+
...hn({
|
|
2066
2102
|
op: t.op,
|
|
2067
2103
|
ttlS: t.cacheTtlS,
|
|
2068
2104
|
input: t.input,
|
|
@@ -2070,31 +2106,31 @@ function Lo(t, e = {}) {
|
|
|
2070
2106
|
})
|
|
2071
2107
|
};
|
|
2072
2108
|
}
|
|
2073
|
-
function
|
|
2109
|
+
function ht(t, e) {
|
|
2074
2110
|
return typeof t == "function" ? t(e) : t;
|
|
2075
2111
|
}
|
|
2076
|
-
function
|
|
2077
|
-
return Array.isArray(t) ? t.map(
|
|
2112
|
+
function _t(t) {
|
|
2113
|
+
return Array.isArray(t) ? t.map(_t) : !t || typeof t != "object" ? t : Object.fromEntries(Object.entries(t).filter(([, e]) => e !== void 0).sort(([e], [r]) => e.localeCompare(r)).map(([e, r]) => [e, _t(r)]));
|
|
2078
2114
|
}
|
|
2079
|
-
function
|
|
2115
|
+
function wn(t) {
|
|
2080
2116
|
return !t || typeof t != "object" || Array.isArray(t) ? {} : Object.fromEntries(Object.entries(t).filter(([, e]) => e != null));
|
|
2081
2117
|
}
|
|
2082
|
-
var
|
|
2118
|
+
var Do = Object.freeze({
|
|
2083
2119
|
FALLBACK_RESULTS: "fallback_results",
|
|
2084
2120
|
FALLBACK_NO_RESULTS: "fallback_no_results",
|
|
2085
2121
|
FALLBACK_PARTIAL: "fallback_partial",
|
|
2086
2122
|
OP_UNAVAILABLE: "op_unavailable"
|
|
2087
2123
|
});
|
|
2088
|
-
function
|
|
2124
|
+
function Uo(t, e = {}) {
|
|
2089
2125
|
return {
|
|
2090
2126
|
status: t,
|
|
2091
2127
|
...e
|
|
2092
2128
|
};
|
|
2093
2129
|
}
|
|
2094
|
-
function
|
|
2130
|
+
function zo(t) {
|
|
2095
2131
|
return !!(t && typeof t == "object" && typeof t.status == "string");
|
|
2096
2132
|
}
|
|
2097
|
-
function
|
|
2133
|
+
function Vo(t) {
|
|
2098
2134
|
return function() {
|
|
2099
2135
|
return [{
|
|
2100
2136
|
kind: "tool",
|
|
@@ -2106,10 +2142,10 @@ function Do(t) {
|
|
|
2106
2142
|
}];
|
|
2107
2143
|
};
|
|
2108
2144
|
}
|
|
2109
|
-
function
|
|
2145
|
+
function Ko(t) {
|
|
2110
2146
|
return !t || typeof t != "object" || Array.isArray(t) ? {} : Object.fromEntries(Object.entries(t).filter(([, e]) => e != null && e !== "" && (!Array.isArray(e) || e.length > 0)));
|
|
2111
2147
|
}
|
|
2112
|
-
function
|
|
2148
|
+
function Ho(t, { screenSummary: e } = {}) {
|
|
2113
2149
|
return { panel: {
|
|
2114
2150
|
...t?.panel || {},
|
|
2115
2151
|
screen_type: "homepage",
|
|
@@ -2128,13 +2164,13 @@ function zo(t, { screenSummary: e } = {}) {
|
|
|
2128
2164
|
ui_hints: null
|
|
2129
2165
|
} };
|
|
2130
2166
|
}
|
|
2131
|
-
function
|
|
2132
|
-
const o = { patterns: [...
|
|
2167
|
+
function bn({ patterns: t, messageFilter: e, messageNormalizer: r = (o) => o, messageLimit: n = 10 } = {}) {
|
|
2168
|
+
const o = { patterns: [...fe, ...Array.isArray(t) ? t : []] };
|
|
2133
2169
|
function i(c) {
|
|
2134
|
-
return
|
|
2170
|
+
return pe(c, o);
|
|
2135
2171
|
}
|
|
2136
2172
|
function a(c) {
|
|
2137
|
-
return
|
|
2173
|
+
return un(c, o);
|
|
2138
2174
|
}
|
|
2139
2175
|
function s(c = []) {
|
|
2140
2176
|
const u = (Array.isArray(c) ? c : []).filter((l) => typeof e == "function" ? e(l) : l && typeof l == "object").filter(Boolean);
|
|
@@ -2149,7 +2185,7 @@ function gn({ patterns: t, messageFilter: e, messageNormalizer: r = (o) => o, me
|
|
|
2149
2185
|
anonymizeMessages: s
|
|
2150
2186
|
};
|
|
2151
2187
|
}
|
|
2152
|
-
function
|
|
2188
|
+
function Jo(t) {
|
|
2153
2189
|
return String(t || "").replace(/<script\b[\s\S]*?<\/script>/giu, " ").replace(/<style\b[\s\S]*?<\/style>/giu, " ").replace(/<[^>]+>/gu, " ").replace(/ /giu, " ").replace(/&/giu, "&").replace(/<|>/giu, " ").replace(/\s+/gu, " ").trim();
|
|
2154
2190
|
}
|
|
2155
2191
|
var A = {
|
|
@@ -2162,7 +2198,7 @@ var A = {
|
|
|
2162
2198
|
textBlocks: 6,
|
|
2163
2199
|
relatedProducts: 8,
|
|
2164
2200
|
textChars: 220
|
|
2165
|
-
},
|
|
2201
|
+
}, Mt = {
|
|
2166
2202
|
description: /\b(?:description|details|product information|urun bilgisi|urun aciklamasi|açıklama|aciklama)\b/iu,
|
|
2167
2203
|
seller: /\b(?:seller|merchant|store|satici|satıcı|magaza|mağaza)\b/iu,
|
|
2168
2204
|
review: /\b(?:review|reviews|rating|ratings|yorum|degerlendirme|değerlendirme|puan)\b/iu,
|
|
@@ -2171,9 +2207,9 @@ var A = {
|
|
|
2171
2207
|
delivery: /\b(?:delivery|shipping|cargo|stock|availability|teslimat|kargo|stok|gonderim|gönderim)\b/iu,
|
|
2172
2208
|
promotion: /\b(?:campaign|promotion|discount|coupon|deal|kampanya|indirim|kupon|firsat|fırsat)\b/iu,
|
|
2173
2209
|
variant: /\b(?:variant|size|colour|color|beden|olcu|ölçü|renk|numara)\b/iu
|
|
2174
|
-
},
|
|
2175
|
-
function
|
|
2176
|
-
return (i = {}) =>
|
|
2210
|
+
}, kn = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\+?\d[\d\s().-]{8,}\d|\b[A-Z]{1,2}\d[A-Z\d]?\s*\d[A-Z]{2}\b|\b(?:token|session|csrf|secret)\s*[:=]\s*[\w.-]+/giu, _n = /(?:token|session|sid|auth|code|csrf|secret|key|password|passwd|phone|email|address|postcode|zip|jwt|bearer)/iu, An = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\+?\d[\d\s().-]{8,}\d|[A-Z]{1,2}\d[A-Z\d]?\s*\d[A-Z]{2}|[A-Za-z0-9_-]{24,}/iu;
|
|
2211
|
+
function Zo({ accountId: t, getPageType: e, getProduct: r, getProducts: n, normalizeProduct: o = (i) => i }) {
|
|
2212
|
+
return (i = {}) => Sn({
|
|
2177
2213
|
accountId: t,
|
|
2178
2214
|
getPageType: e,
|
|
2179
2215
|
getProduct: r,
|
|
@@ -2182,43 +2218,43 @@ function Ko({ accountId: t, getPageType: e, getProduct: r, getProducts: n, norma
|
|
|
2182
2218
|
input: i
|
|
2183
2219
|
});
|
|
2184
2220
|
}
|
|
2185
|
-
function
|
|
2186
|
-
const a =
|
|
2221
|
+
function Sn({ accountId: t, getPageType: e, getProduct: r, getProducts: n, normalizeProduct: o = (a) => a, input: i = {} }) {
|
|
2222
|
+
const a = Wn(i), s = o(i.product || wt(r)), c = (wt(n) || []).map(o).filter(Boolean), u = b(i.sku || s?.sku || i.product?.sku), l = u ? c.find((ut) => b(ut?.sku) === u) || s : s || c[0] || null, f = Cn(u || l?.sku), d = Gt({
|
|
2187
2223
|
...f.product,
|
|
2188
2224
|
...l
|
|
2189
|
-
}), p =
|
|
2225
|
+
}), p = Nt(nt(l?.features), nt(l?.specs), Ln(l?.facet_hits), nt(f.product?.features), En(), Pn(), In()).slice(0, a.features), m = ye(st(l?.reviews), f.reviews, On()).slice(0, a.reviews), h = ge(Rt(l?.qna), jn()).slice(0, a.qna), T = he(Bt(l?.sellers), Mn()).slice(0, a.sellers), $ = B([...l?.payment || [], ...rt("payment", a)]), M = B([...l?.delivery || [], ...rt("delivery", a)]), N = B([...l?.promotions || [], ...rt("promotion", a)]), R = we($t(l?.variants), Rn()).slice(0, a.variants), L = Bn(a.documents), k = ke(l?.description, f.product?.description, $n("description"), rt("description", {
|
|
2190
2226
|
...a,
|
|
2191
2227
|
textBlocks: 2
|
|
2192
|
-
})[0]), Lt = c.filter((
|
|
2193
|
-
return
|
|
2228
|
+
})[0]), Lt = c.filter((ut) => !u || b(ut?.sku) !== u).map(Gt).filter(Boolean).slice(0, a.relatedProducts);
|
|
2229
|
+
return z({
|
|
2194
2230
|
accountId: t,
|
|
2195
|
-
pageType:
|
|
2196
|
-
url:
|
|
2231
|
+
pageType: wt(e) || "other",
|
|
2232
|
+
url: Zn(),
|
|
2197
2233
|
product: d,
|
|
2198
2234
|
description: k,
|
|
2199
2235
|
features: p,
|
|
2200
|
-
sellers:
|
|
2236
|
+
sellers: T,
|
|
2201
2237
|
reviews: m,
|
|
2202
2238
|
qna: h,
|
|
2203
2239
|
rating: S(l?.rating ?? f.rating),
|
|
2204
2240
|
review_count: S(l?.review_count ?? f.review_count),
|
|
2205
2241
|
payment: $,
|
|
2206
|
-
delivery:
|
|
2207
|
-
promotions:
|
|
2208
|
-
variants:
|
|
2209
|
-
documents:
|
|
2242
|
+
delivery: M,
|
|
2243
|
+
promotions: N,
|
|
2244
|
+
variants: R,
|
|
2245
|
+
documents: L,
|
|
2210
2246
|
related_products: Lt,
|
|
2211
|
-
capabilities:
|
|
2247
|
+
capabilities: Vn({
|
|
2212
2248
|
description: k,
|
|
2213
2249
|
features: p,
|
|
2214
|
-
sellers:
|
|
2250
|
+
sellers: T,
|
|
2215
2251
|
reviews: m,
|
|
2216
2252
|
qna: h,
|
|
2217
2253
|
payment: $,
|
|
2218
|
-
delivery:
|
|
2219
|
-
promotions:
|
|
2220
|
-
variants:
|
|
2221
|
-
documents:
|
|
2254
|
+
delivery: M,
|
|
2255
|
+
promotions: N,
|
|
2256
|
+
variants: R,
|
|
2257
|
+
documents: L,
|
|
2222
2258
|
relatedProducts: Lt
|
|
2223
2259
|
}),
|
|
2224
2260
|
privacy: {
|
|
@@ -2231,96 +2267,96 @@ function kn({ accountId: t, getPageType: e, getProduct: r, getProducts: n, norma
|
|
|
2231
2267
|
}
|
|
2232
2268
|
});
|
|
2233
2269
|
}
|
|
2234
|
-
function
|
|
2270
|
+
function Wo(t, e) {
|
|
2235
2271
|
const r = Array.isArray(t) ? t.filter(Boolean) : [];
|
|
2236
2272
|
if (!e || typeof e != "object" || !r.length) return r;
|
|
2237
2273
|
const n = b(e.product?.sku);
|
|
2238
2274
|
return r.map((o, i) => {
|
|
2239
2275
|
const a = b(o?.sku);
|
|
2240
|
-
return r.length === 1 || n && a && n === a || i === 0 ?
|
|
2276
|
+
return r.length === 1 || n && a && n === a || i === 0 ? vn(o, e) : o;
|
|
2241
2277
|
});
|
|
2242
2278
|
}
|
|
2243
|
-
function
|
|
2244
|
-
return !t || typeof t != "object" ? null :
|
|
2279
|
+
function xn(t) {
|
|
2280
|
+
return !t || typeof t != "object" ? null : z({
|
|
2245
2281
|
product: t.product,
|
|
2246
2282
|
description: g(t.description, 500),
|
|
2247
|
-
features:
|
|
2248
|
-
sellers:
|
|
2249
|
-
reviews:
|
|
2250
|
-
qna:
|
|
2283
|
+
features: Fn(t.features, 14),
|
|
2284
|
+
sellers: Un(t.sellers, 4),
|
|
2285
|
+
reviews: qn(t.reviews, 4),
|
|
2286
|
+
qna: Dn(t.qna, 4),
|
|
2251
2287
|
rating: t.rating,
|
|
2252
2288
|
review_count: t.review_count,
|
|
2253
|
-
payment:
|
|
2254
|
-
delivery:
|
|
2255
|
-
promotions:
|
|
2256
|
-
variants:
|
|
2257
|
-
documents:
|
|
2289
|
+
payment: j(t.payment, 5, 160),
|
|
2290
|
+
delivery: j(t.delivery, 5, 160),
|
|
2291
|
+
promotions: j(t.promotions, 5, 160),
|
|
2292
|
+
variants: zn(t.variants, 10),
|
|
2293
|
+
documents: j(t.documents, 5, 220),
|
|
2258
2294
|
capabilities: Array.isArray(t.capabilities) ? t.capabilities.slice(0, 12) : void 0
|
|
2259
2295
|
});
|
|
2260
2296
|
}
|
|
2261
|
-
function
|
|
2262
|
-
const n =
|
|
2297
|
+
function Go(t, e, r = {}) {
|
|
2298
|
+
const n = xn(t);
|
|
2263
2299
|
if (!n) return e;
|
|
2264
2300
|
const o = String(r.locale || "").toLowerCase().startsWith("en"), i = [], a = [n.rating ? `${n.rating}/5` : "", n.review_count ? `${n.review_count} ${o ? "reviews" : "yorum"}` : ""].filter(Boolean).join(", ");
|
|
2265
2301
|
return a && i.push(o ? `Visible rating: ${a}.` : `Görünür puan bilgisi: ${a}.`), n.reviews?.length && i.push(`${o ? "Visible review highlights" : "Görünür yorumlardan öne çıkanlar"}: ${n.reviews.map((s) => [s.star ? `${s.star}/5` : "", s.content].filter(Boolean).join(" ")).filter(Boolean).slice(0, 3).join(" | ")}.`), i.length ? (i.push(o ? "This summary only uses product review and rating fields visible in the browser." : "Bu özet yalnızca tarayıcıda görünen ürün yorumu ve puan alanlarından hazırlandı."), i.join(" ")) : e;
|
|
2266
2302
|
}
|
|
2267
|
-
function
|
|
2268
|
-
return
|
|
2303
|
+
function vn(t, e) {
|
|
2304
|
+
return z({
|
|
2269
2305
|
...t,
|
|
2270
|
-
description:
|
|
2271
|
-
features:
|
|
2272
|
-
specs: t.specs || (e.features?.length ? Object.fromEntries(e.features.map(
|
|
2273
|
-
sellers:
|
|
2274
|
-
reviews:
|
|
2275
|
-
qna:
|
|
2306
|
+
description: ke(t.description, e.description),
|
|
2307
|
+
features: Nt(nt(t.features), e.features).slice(0, 24),
|
|
2308
|
+
specs: t.specs || (e.features?.length ? Object.fromEntries(e.features.map(Kn)) : void 0),
|
|
2309
|
+
sellers: he(Bt(t.sellers), e.sellers),
|
|
2310
|
+
reviews: ye(st(t.reviews), e.reviews),
|
|
2311
|
+
qna: ge(Rt(t.qna), e.qna),
|
|
2276
2312
|
rating: t.rating ?? e.rating,
|
|
2277
2313
|
review_count: t.review_count ?? e.review_count,
|
|
2278
2314
|
payment: B([...t.payment || [], ...e.payment || []]),
|
|
2279
2315
|
delivery: B([...t.delivery || [], ...e.delivery || []]),
|
|
2280
2316
|
promotions: B([...t.promotions || [], ...e.promotions || []]),
|
|
2281
|
-
variants:
|
|
2317
|
+
variants: we($t(t.variants), e.variants),
|
|
2282
2318
|
documents: B([...t.documents || [], ...e.documents || []])
|
|
2283
2319
|
});
|
|
2284
2320
|
}
|
|
2285
|
-
function
|
|
2321
|
+
function Cn(t) {
|
|
2286
2322
|
const e = [];
|
|
2287
|
-
for (const o of
|
|
2288
|
-
const i =
|
|
2289
|
-
for (const a of
|
|
2323
|
+
for (const o of C('script[type="application/ld+json"]')) {
|
|
2324
|
+
const i = Tn(o.textContent);
|
|
2325
|
+
for (const a of At(i))
|
|
2290
2326
|
String(a?.["@type"] || "").toLowerCase() === "product" && e.push(a);
|
|
2291
2327
|
}
|
|
2292
2328
|
const r = e.find((o) => b(o.sku || o.productID || o.mpn) === b(t)) || e[0];
|
|
2293
2329
|
if (!r) return {};
|
|
2294
2330
|
const n = r.aggregateRating || {};
|
|
2295
2331
|
return {
|
|
2296
|
-
product:
|
|
2332
|
+
product: z({
|
|
2297
2333
|
sku: b(r.sku || r.productID || r.mpn),
|
|
2298
2334
|
name: y(r.name),
|
|
2299
2335
|
brand: y(r.brand?.name || r.brand),
|
|
2300
2336
|
description: y(r.description),
|
|
2301
|
-
images:
|
|
2302
|
-
url:
|
|
2337
|
+
images: j(r.image, 8, 280),
|
|
2338
|
+
url: X(r.url),
|
|
2303
2339
|
rating: S(n.ratingValue),
|
|
2304
2340
|
review_count: S(n.reviewCount || n.ratingCount)
|
|
2305
2341
|
}),
|
|
2306
|
-
reviews:
|
|
2342
|
+
reviews: st(r.review),
|
|
2307
2343
|
rating: S(n.ratingValue),
|
|
2308
2344
|
review_count: S(n.reviewCount || n.ratingCount)
|
|
2309
2345
|
};
|
|
2310
2346
|
}
|
|
2311
|
-
function
|
|
2312
|
-
return Array.isArray(t) ? t.flatMap(
|
|
2347
|
+
function At(t) {
|
|
2348
|
+
return Array.isArray(t) ? t.flatMap(At) : !t || typeof t != "object" ? [] : [t, ...At(t["@graph"])];
|
|
2313
2349
|
}
|
|
2314
|
-
function
|
|
2350
|
+
function Tn(t) {
|
|
2315
2351
|
try {
|
|
2316
2352
|
return JSON.parse(String(t || ""));
|
|
2317
2353
|
} catch {
|
|
2318
2354
|
return null;
|
|
2319
2355
|
}
|
|
2320
2356
|
}
|
|
2321
|
-
function
|
|
2357
|
+
function En() {
|
|
2322
2358
|
const t = [];
|
|
2323
|
-
for (const e of
|
|
2359
|
+
for (const e of C("table tr")) {
|
|
2324
2360
|
const r = [...e.querySelectorAll?.("th,td") || []].map((n) => y(n.textContent));
|
|
2325
2361
|
r.length >= 2 && r[0] && r[1] && t.push({
|
|
2326
2362
|
key: r[0],
|
|
@@ -2329,9 +2365,9 @@ function vn() {
|
|
|
2329
2365
|
}
|
|
2330
2366
|
return t;
|
|
2331
2367
|
}
|
|
2332
|
-
function
|
|
2368
|
+
function Pn() {
|
|
2333
2369
|
const t = [];
|
|
2334
|
-
for (const e of
|
|
2370
|
+
for (const e of C("dt")) {
|
|
2335
2371
|
const r = y(e.textContent), n = y(e.nextElementSibling?.matches?.("dd") ? e.nextElementSibling.textContent : "");
|
|
2336
2372
|
r && n && t.push({
|
|
2337
2373
|
key: r,
|
|
@@ -2340,23 +2376,23 @@ function Cn() {
|
|
|
2340
2376
|
}
|
|
2341
2377
|
return t;
|
|
2342
2378
|
}
|
|
2343
|
-
function
|
|
2344
|
-
return
|
|
2379
|
+
function In() {
|
|
2380
|
+
return C('[class*="spec" i], [class*="feature" i], [class*="attribute" i], li').map((t) => me(y(t.textContent))).filter(Boolean).slice(0, A.features);
|
|
2345
2381
|
}
|
|
2346
|
-
function
|
|
2347
|
-
return
|
|
2382
|
+
function On() {
|
|
2383
|
+
return C('[class*="review" i], [data-review], [itemprop="review"]').map((t) => {
|
|
2348
2384
|
const e = y(t.textContent);
|
|
2349
|
-
return !e || e.length < 8 ||
|
|
2385
|
+
return !e || e.length < 8 || Mt.qna.test(e) ? null : {
|
|
2350
2386
|
content: g(e, 260),
|
|
2351
2387
|
star: S(t.getAttribute?.("data-rating"))
|
|
2352
2388
|
};
|
|
2353
2389
|
}).filter(Boolean);
|
|
2354
2390
|
}
|
|
2355
|
-
function
|
|
2356
|
-
const t =
|
|
2391
|
+
function jn() {
|
|
2392
|
+
const t = C('[class*="question" i], [class*="answer" i], [data-question], [data-answer]'), e = [];
|
|
2357
2393
|
for (const r of t) {
|
|
2358
2394
|
const n = y(r.textContent);
|
|
2359
|
-
if (!n || !
|
|
2395
|
+
if (!n || !Mt.qna.test(n)) continue;
|
|
2360
2396
|
const o = y(r.getAttribute?.("data-question") || n), i = y(r.getAttribute?.("data-answer") || r.nextElementSibling?.textContent || "");
|
|
2361
2397
|
e.push({
|
|
2362
2398
|
question: g(o, 220),
|
|
@@ -2365,39 +2401,39 @@ function Pn() {
|
|
|
2365
2401
|
}
|
|
2366
2402
|
return e;
|
|
2367
2403
|
}
|
|
2368
|
-
function
|
|
2369
|
-
return
|
|
2404
|
+
function Mn() {
|
|
2405
|
+
return C('[class*="seller" i], [class*="merchant" i], [data-seller], [data-merchant]').map((t) => y(t.getAttribute?.("data-seller") || t.getAttribute?.("data-merchant") || t.textContent)).filter(Boolean).map((t) => ({ merchant: g(t, 120) }));
|
|
2370
2406
|
}
|
|
2371
|
-
function
|
|
2372
|
-
return
|
|
2373
|
-
name: g(
|
|
2407
|
+
function Rn() {
|
|
2408
|
+
return C('[class*="variant" i] a,[class*="variant" i] button,[class*="size" i] button,[class*="color" i] button,[data-variant],[data-size],[data-color]').map((t) => z({
|
|
2409
|
+
name: g(_e(t), 120),
|
|
2374
2410
|
value: g(t.getAttribute?.("data-value") || t.getAttribute?.("data-size") || t.getAttribute?.("data-color"), 120),
|
|
2375
2411
|
sku: b(t.getAttribute?.("data-sku") || t.getAttribute?.("data-product-id")),
|
|
2376
|
-
url:
|
|
2412
|
+
url: X(t.getAttribute?.("href")),
|
|
2377
2413
|
in_stock: t.getAttribute?.("disabled") == null && t.getAttribute?.("aria-disabled") !== "true"
|
|
2378
2414
|
})).filter((t) => t.name || t.value || t.sku);
|
|
2379
2415
|
}
|
|
2380
|
-
function
|
|
2381
|
-
return
|
|
2382
|
-
const r =
|
|
2416
|
+
function Bn(t) {
|
|
2417
|
+
return C("a[href]").filter((e) => /\.pdf(?:$|[?#])/iu.test(e.getAttribute?.("href") || "")).map((e) => {
|
|
2418
|
+
const r = _e(e) || "PDF", n = X(e.getAttribute?.("href"));
|
|
2383
2419
|
return n ? `${r}: ${n}` : "";
|
|
2384
2420
|
}).filter(Boolean).slice(0, t);
|
|
2385
2421
|
}
|
|
2386
|
-
function
|
|
2387
|
-
const r =
|
|
2388
|
-
return r ?
|
|
2422
|
+
function rt(t, e) {
|
|
2423
|
+
const r = Mt[t];
|
|
2424
|
+
return r ? C("section,article,div,li,p,span,button,a").map((n) => y(n.textContent)).filter((n) => n && r.test(n) && n.length <= 900).map((n) => g(n, e.textChars || A.textChars)).filter(be()).slice(0, e.textBlocks || A.textBlocks) : [];
|
|
2389
2425
|
}
|
|
2390
|
-
function
|
|
2426
|
+
function $n(t) {
|
|
2391
2427
|
return y(document.querySelector?.(`meta[name="${t}"]`)?.getAttribute?.("content") || document.querySelector?.(`meta[property="og:${t}"]`)?.getAttribute?.("content"));
|
|
2392
2428
|
}
|
|
2393
|
-
function
|
|
2429
|
+
function C(t) {
|
|
2394
2430
|
try {
|
|
2395
|
-
return [...document.querySelectorAll?.(t) || []].filter(
|
|
2431
|
+
return [...document.querySelectorAll?.(t) || []].filter(Nn);
|
|
2396
2432
|
} catch {
|
|
2397
2433
|
return [];
|
|
2398
2434
|
}
|
|
2399
2435
|
}
|
|
2400
|
-
function
|
|
2436
|
+
function Nn(t) {
|
|
2401
2437
|
if (!t) return !1;
|
|
2402
2438
|
if (!t.getBoundingClientRect) return !0;
|
|
2403
2439
|
const e = t.getBoundingClientRect();
|
|
@@ -2405,11 +2441,11 @@ function Mn(t) {
|
|
|
2405
2441
|
const r = window.getComputedStyle?.(t);
|
|
2406
2442
|
return !r || r.visibility !== "hidden" && r.display !== "none" && Number(r.opacity || 1) > 0;
|
|
2407
2443
|
}
|
|
2408
|
-
function
|
|
2444
|
+
function nt(t) {
|
|
2409
2445
|
return t ? (Array.isArray(t) ? t : Object.entries(t).map(([e, r]) => ({
|
|
2410
2446
|
key: e,
|
|
2411
2447
|
value: r
|
|
2412
|
-
}))).map((e) => typeof e == "string" ?
|
|
2448
|
+
}))).map((e) => typeof e == "string" ? me(e) || {
|
|
2413
2449
|
key: "",
|
|
2414
2450
|
value: y(e)
|
|
2415
2451
|
} : {
|
|
@@ -2417,20 +2453,20 @@ function X(t) {
|
|
|
2417
2453
|
value: y(e.value || e.text || "")
|
|
2418
2454
|
}).filter((e) => e.key || e.value) : [];
|
|
2419
2455
|
}
|
|
2420
|
-
function
|
|
2456
|
+
function Ln(t) {
|
|
2421
2457
|
return !t || typeof t != "object" ? [] : Object.entries(t).map(([e, r]) => ({
|
|
2422
2458
|
key: y(e),
|
|
2423
2459
|
value: y(r)
|
|
2424
2460
|
}));
|
|
2425
2461
|
}
|
|
2426
|
-
function
|
|
2462
|
+
function me(t) {
|
|
2427
2463
|
const e = /^(.{2,80}?)\s*[::]\s*(.{1,220})$/u.exec(y(t));
|
|
2428
2464
|
return e ? {
|
|
2429
2465
|
key: e[1],
|
|
2430
2466
|
value: e[2]
|
|
2431
2467
|
} : null;
|
|
2432
2468
|
}
|
|
2433
|
-
function
|
|
2469
|
+
function st(t) {
|
|
2434
2470
|
return (Array.isArray(t) ? t : t ? [t] : []).map((e) => typeof e == "string" ? { content: g(e, 260) } : {
|
|
2435
2471
|
content: g(e.content || e.reviewBody || e.description || e.text, 260),
|
|
2436
2472
|
star: S(e.star || e.rating || e.reviewRating?.ratingValue)
|
|
@@ -2442,7 +2478,7 @@ function Rt(t) {
|
|
|
2442
2478
|
answer: g(e.answer || e.acceptedAnswer?.text || e.text || "", 260)
|
|
2443
2479
|
})).filter((e) => e.question || e.answer);
|
|
2444
2480
|
}
|
|
2445
|
-
function
|
|
2481
|
+
function Bt(t) {
|
|
2446
2482
|
return (Array.isArray(t) ? t : t ? [t] : []).map((e) => typeof e == "string" ? { merchant: g(e, 120) } : {
|
|
2447
2483
|
merchant: g(e.merchant || e.name || e.seller || "", 120),
|
|
2448
2484
|
merchant_id: b(e.merchant_id || e.id || ""),
|
|
@@ -2450,16 +2486,16 @@ function Mt(t) {
|
|
|
2450
2486
|
price_offer: S(e.price_offer || e.price)
|
|
2451
2487
|
}).filter((e) => e.merchant || e.merchant_id);
|
|
2452
2488
|
}
|
|
2453
|
-
function
|
|
2489
|
+
function $t(t) {
|
|
2454
2490
|
return (Array.isArray(t) ? t : t ? [t] : []).map((e) => ({
|
|
2455
2491
|
name: g(e.name || e.label || e.title || "", 120),
|
|
2456
2492
|
value: g(e.value || e.size || e.color || "", 120),
|
|
2457
2493
|
sku: b(e.sku || e.code || ""),
|
|
2458
|
-
url:
|
|
2494
|
+
url: X(e.url),
|
|
2459
2495
|
in_stock: e.in_stock
|
|
2460
2496
|
})).filter((e) => e.name || e.value || e.sku || e.url);
|
|
2461
2497
|
}
|
|
2462
|
-
function
|
|
2498
|
+
function Nt(...t) {
|
|
2463
2499
|
const e = /* @__PURE__ */ new Set(), r = [];
|
|
2464
2500
|
for (const n of t.flat().filter(Boolean)) {
|
|
2465
2501
|
const o = {
|
|
@@ -2470,19 +2506,19 @@ function $t(...t) {
|
|
|
2470
2506
|
}
|
|
2471
2507
|
return r;
|
|
2472
2508
|
}
|
|
2473
|
-
function me(...t) {
|
|
2474
|
-
return at(t.flat().filter(Boolean), (e) => `${e.star || ""}:${e.content || ""}`);
|
|
2475
|
-
}
|
|
2476
2509
|
function ye(...t) {
|
|
2477
|
-
return
|
|
2510
|
+
return ct(t.flat().filter(Boolean), (e) => `${e.star || ""}:${e.content || ""}`);
|
|
2478
2511
|
}
|
|
2479
2512
|
function ge(...t) {
|
|
2480
|
-
return
|
|
2513
|
+
return ct(t.flat().filter(Boolean), (e) => `${e.question || ""}:${e.answer || ""}`);
|
|
2481
2514
|
}
|
|
2482
2515
|
function he(...t) {
|
|
2483
|
-
return
|
|
2516
|
+
return ct(t.flat().filter(Boolean), (e) => `${e.merchant || ""}:${e.merchant_id || ""}`);
|
|
2517
|
+
}
|
|
2518
|
+
function we(...t) {
|
|
2519
|
+
return ct(t.flat().filter(Boolean), (e) => `${e.sku || ""}:${e.name || ""}:${e.value || ""}`);
|
|
2484
2520
|
}
|
|
2485
|
-
function
|
|
2521
|
+
function ct(t, e) {
|
|
2486
2522
|
const r = /* @__PURE__ */ new Set();
|
|
2487
2523
|
return t.filter((n) => {
|
|
2488
2524
|
const o = e(n).toLocaleLowerCase("tr-TR");
|
|
@@ -2490,51 +2526,51 @@ function at(t, e) {
|
|
|
2490
2526
|
});
|
|
2491
2527
|
}
|
|
2492
2528
|
function B(t) {
|
|
2493
|
-
return
|
|
2529
|
+
return j(t, 20, A.textChars);
|
|
2494
2530
|
}
|
|
2495
|
-
function
|
|
2496
|
-
return (Array.isArray(t) ? t : t ? [t] : []).map((n) => g(n, r)).filter(Boolean).filter(
|
|
2531
|
+
function j(t, e, r) {
|
|
2532
|
+
return (Array.isArray(t) ? t : t ? [t] : []).map((n) => g(n, r)).filter(Boolean).filter(be()).slice(0, e);
|
|
2497
2533
|
}
|
|
2498
|
-
function
|
|
2534
|
+
function be() {
|
|
2499
2535
|
const t = /* @__PURE__ */ new Set();
|
|
2500
2536
|
return (e) => {
|
|
2501
2537
|
const r = y(e).toLocaleLowerCase("tr-TR");
|
|
2502
2538
|
return !r || t.has(r) ? !1 : (t.add(r), !0);
|
|
2503
2539
|
};
|
|
2504
2540
|
}
|
|
2505
|
-
function
|
|
2506
|
-
return
|
|
2541
|
+
function Fn(t, e) {
|
|
2542
|
+
return Nt(t).slice(0, e);
|
|
2507
2543
|
}
|
|
2508
|
-
function
|
|
2509
|
-
return
|
|
2544
|
+
function qn(t, e) {
|
|
2545
|
+
return st(t).slice(0, e);
|
|
2510
2546
|
}
|
|
2511
|
-
function
|
|
2547
|
+
function Dn(t, e) {
|
|
2512
2548
|
return Rt(t).slice(0, e);
|
|
2513
2549
|
}
|
|
2514
|
-
function
|
|
2515
|
-
return Mt(t).slice(0, e);
|
|
2516
|
-
}
|
|
2517
|
-
function qn(t, e) {
|
|
2550
|
+
function Un(t, e) {
|
|
2518
2551
|
return Bt(t).slice(0, e);
|
|
2519
2552
|
}
|
|
2520
|
-
function
|
|
2521
|
-
return
|
|
2553
|
+
function zn(t, e) {
|
|
2554
|
+
return $t(t).slice(0, e);
|
|
2555
|
+
}
|
|
2556
|
+
function Gt(t) {
|
|
2557
|
+
return !t || typeof t != "object" ? null : z({
|
|
2522
2558
|
sku: b(t.sku || t.id || ""),
|
|
2523
2559
|
group_id: b(t.group_id || t.groupId || ""),
|
|
2524
2560
|
name: y(t.name || t.title || ""),
|
|
2525
2561
|
brand: y(t.brand || ""),
|
|
2526
|
-
url:
|
|
2527
|
-
images:
|
|
2562
|
+
url: X(t.url),
|
|
2563
|
+
images: j(t.images || t.image, 8, 280),
|
|
2528
2564
|
price: S(t.price),
|
|
2529
2565
|
price_discounted: S(t.price_discounted || t.discountedPrice),
|
|
2530
2566
|
price_text: y(t.price_text || t.priceText || ""),
|
|
2531
2567
|
price_currency: y(t.price_currency || t.currency || ""),
|
|
2532
|
-
category_ids:
|
|
2533
|
-
category_names:
|
|
2568
|
+
category_ids: Hn(t.category_ids || t.categoryIds, 8, 90),
|
|
2569
|
+
category_names: j(t.category_names || t.categoryNames || t.category, 8, 140),
|
|
2534
2570
|
in_stock: t.in_stock
|
|
2535
2571
|
});
|
|
2536
2572
|
}
|
|
2537
|
-
function
|
|
2573
|
+
function Vn(t) {
|
|
2538
2574
|
return [
|
|
2539
2575
|
t.description ? "description" : "",
|
|
2540
2576
|
t.features?.length ? "features" : "",
|
|
@@ -2549,29 +2585,29 @@ function Dn(t) {
|
|
|
2549
2585
|
t.relatedProducts?.length ? "related_products" : ""
|
|
2550
2586
|
].filter(Boolean);
|
|
2551
2587
|
}
|
|
2552
|
-
function
|
|
2588
|
+
function Kn(t) {
|
|
2553
2589
|
return [y(t.key || t.name), y(t.value || t.text)];
|
|
2554
2590
|
}
|
|
2555
|
-
function
|
|
2591
|
+
function ke(...t) {
|
|
2556
2592
|
return t.map((e) => g(e, 700)).find(Boolean) || "";
|
|
2557
2593
|
}
|
|
2558
2594
|
function g(t, e) {
|
|
2559
2595
|
return y(t).slice(0, e);
|
|
2560
2596
|
}
|
|
2561
|
-
function
|
|
2597
|
+
function _e(t) {
|
|
2562
2598
|
return y(t.getAttribute?.("aria-label") || t.getAttribute?.("title") || t.getAttribute?.("alt") || t.textContent);
|
|
2563
2599
|
}
|
|
2564
2600
|
function y(t) {
|
|
2565
|
-
return String(t ?? "").replace(/<script\b[\s\S]*?<\/script>/giu, " ").replace(/<style\b[\s\S]*?<\/style>/giu, " ").replace(/<[^>]+>/gu, " ").replace(
|
|
2601
|
+
return String(t ?? "").replace(/<script\b[\s\S]*?<\/script>/giu, " ").replace(/<style\b[\s\S]*?<\/style>/giu, " ").replace(/<[^>]+>/gu, " ").replace(kn, "[redacted]").replace(/\s+/gu, " ").trim();
|
|
2566
2602
|
}
|
|
2567
2603
|
function b(t) {
|
|
2568
2604
|
const e = String(t ?? "").replace(/<script\b[\s\S]*?<\/script>/giu, " ").replace(/<style\b[\s\S]*?<\/style>/giu, " ").replace(/<[^>]+>/gu, " ").replace(/\s+/gu, " ").trim();
|
|
2569
2605
|
return !e || /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/iu.test(e) || /\b(?:token|session|csrf|secret|password|passwd|jwt|bearer)\s*[:=]\s*[\w.-]+/iu.test(e) ? "" : e.slice(0, 120);
|
|
2570
2606
|
}
|
|
2571
|
-
function
|
|
2572
|
-
return (Array.isArray(t) ? t : t ? [t] : []).map((n) => b(n).slice(0, r)).filter(Boolean).filter(
|
|
2607
|
+
function Hn(t, e, r) {
|
|
2608
|
+
return (Array.isArray(t) ? t : t ? [t] : []).map((n) => b(n).slice(0, r)).filter(Boolean).filter(Jn()).slice(0, e);
|
|
2573
2609
|
}
|
|
2574
|
-
function
|
|
2610
|
+
function Jn() {
|
|
2575
2611
|
const t = /* @__PURE__ */ new Set();
|
|
2576
2612
|
return (e) => {
|
|
2577
2613
|
const r = b(e).toLocaleLowerCase("tr-TR");
|
|
@@ -2582,72 +2618,72 @@ function S(t) {
|
|
|
2582
2618
|
const e = Number(String(t ?? "").replace(",", "."));
|
|
2583
2619
|
return Number.isFinite(e) && e > 0 ? e : void 0;
|
|
2584
2620
|
}
|
|
2585
|
-
function
|
|
2621
|
+
function X(t) {
|
|
2586
2622
|
if (!t) return "";
|
|
2587
2623
|
try {
|
|
2588
2624
|
const e = new URL(t, window.location.href);
|
|
2589
|
-
return /^https?:$/u.test(e.protocol) ? (e.hash = "",
|
|
2625
|
+
return /^https?:$/u.test(e.protocol) ? (e.hash = "", Ae(e), e.href) : "";
|
|
2590
2626
|
} catch {
|
|
2591
2627
|
return "";
|
|
2592
2628
|
}
|
|
2593
2629
|
}
|
|
2594
|
-
function
|
|
2630
|
+
function Zn() {
|
|
2595
2631
|
try {
|
|
2596
2632
|
const t = new URL(window.location.href);
|
|
2597
|
-
return t.hash = "",
|
|
2633
|
+
return t.hash = "", Ae(t), `${t.origin}${t.pathname}${t.search}`;
|
|
2598
2634
|
} catch {
|
|
2599
2635
|
return "";
|
|
2600
2636
|
}
|
|
2601
2637
|
}
|
|
2602
|
-
function
|
|
2638
|
+
function Ae(t) {
|
|
2603
2639
|
for (const [e, r] of [...t.searchParams.entries()]) {
|
|
2604
2640
|
const n = String(r || "");
|
|
2605
|
-
(
|
|
2641
|
+
(_n.test(e) || An.test(n)) && t.searchParams.set(e, "redacted");
|
|
2606
2642
|
}
|
|
2607
2643
|
return t;
|
|
2608
2644
|
}
|
|
2609
|
-
function
|
|
2645
|
+
function Wn(t = {}) {
|
|
2610
2646
|
return {
|
|
2611
|
-
features:
|
|
2612
|
-
reviews:
|
|
2613
|
-
qna:
|
|
2614
|
-
sellers:
|
|
2615
|
-
variants:
|
|
2616
|
-
documents:
|
|
2617
|
-
textBlocks:
|
|
2618
|
-
relatedProducts:
|
|
2619
|
-
textChars:
|
|
2647
|
+
features: E(t.maxFeatures, A.features, 40),
|
|
2648
|
+
reviews: E(t.maxReviews, A.reviews, 12),
|
|
2649
|
+
qna: E(t.maxQna, A.qna, 12),
|
|
2650
|
+
sellers: E(t.maxSellers, A.sellers, 12),
|
|
2651
|
+
variants: E(t.maxVariants, A.variants, 30),
|
|
2652
|
+
documents: E(t.maxDocuments, A.documents, 12),
|
|
2653
|
+
textBlocks: E(t.maxTextBlocks, A.textBlocks, 16),
|
|
2654
|
+
relatedProducts: E(t.maxRelatedProducts, A.relatedProducts, 20),
|
|
2655
|
+
textChars: E(t.textChars, A.textChars, 420)
|
|
2620
2656
|
};
|
|
2621
2657
|
}
|
|
2622
|
-
function
|
|
2658
|
+
function E(t, e, r) {
|
|
2623
2659
|
const n = Number(t);
|
|
2624
2660
|
return !Number.isFinite(n) || n <= 0 ? e : Math.min(Math.floor(n), r);
|
|
2625
2661
|
}
|
|
2626
|
-
function
|
|
2662
|
+
function wt(t) {
|
|
2627
2663
|
try {
|
|
2628
2664
|
return typeof t == "function" ? t() : null;
|
|
2629
2665
|
} catch {
|
|
2630
2666
|
return null;
|
|
2631
2667
|
}
|
|
2632
2668
|
}
|
|
2633
|
-
function
|
|
2669
|
+
function z(t) {
|
|
2634
2670
|
return Object.fromEntries(Object.entries(t || {}).filter(([, e]) => e != null && e !== "" && (!Array.isArray(e) || e.length)));
|
|
2635
2671
|
}
|
|
2636
|
-
var { redactPii:
|
|
2672
|
+
var { redactPii: Yo, anonymousRequestText: Qo, anonymizeMessages: Xo } = bn({ patterns: [{
|
|
2637
2673
|
pattern: /\b\d{5}\b/gu,
|
|
2638
2674
|
replacement: "[postcode]"
|
|
2639
2675
|
}, {
|
|
2640
2676
|
pattern: /\b(?:adresim|adres|mahalle|sokak|cadde)\b[^,.!?\n]{8,160}/giu,
|
|
2641
2677
|
replacement: "[address]"
|
|
2642
2678
|
}] });
|
|
2643
|
-
function
|
|
2679
|
+
function Gn(t) {
|
|
2644
2680
|
return (t?.route?.flow_params && typeof t.route.flow_params == "object" ? t.route.flow_params : null) || (t?.route?.flowParams && typeof t.route.flowParams == "object" ? t.route.flowParams : null) || {};
|
|
2645
2681
|
}
|
|
2646
|
-
function
|
|
2682
|
+
function ti(t) {
|
|
2647
2683
|
return Array.isArray(t) ? t.find((e) => String(e || "").trim()) : void 0;
|
|
2648
2684
|
}
|
|
2649
|
-
function
|
|
2650
|
-
const e =
|
|
2685
|
+
function ei(t) {
|
|
2686
|
+
const e = Gn(t);
|
|
2651
2687
|
return [
|
|
2652
2688
|
...e.sku ? [e.sku] : [],
|
|
2653
2689
|
...Array.isArray(e.sku_list) ? e.sku_list : [],
|
|
@@ -2655,18 +2691,18 @@ function Qo(t) {
|
|
|
2655
2691
|
...Array.isArray(e.target_skus) ? e.target_skus : []
|
|
2656
2692
|
].map((r) => String(r || "").trim()).filter(Boolean).filter((r, n, o) => o.indexOf(r) === n);
|
|
2657
2693
|
}
|
|
2658
|
-
var
|
|
2659
|
-
function
|
|
2660
|
-
const n = r.ttlMs ??
|
|
2694
|
+
var Yn = 3e4;
|
|
2695
|
+
function Qn(t, e, r = {}) {
|
|
2696
|
+
const n = r.ttlMs ?? Yn, o = r.clock ?? Date.now, i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
2661
2697
|
return async function(c) {
|
|
2662
2698
|
const u = String(e(c) ?? "");
|
|
2663
2699
|
if (!u) return t(c);
|
|
2664
2700
|
const l = o();
|
|
2665
|
-
|
|
2701
|
+
Xn(a, l, n);
|
|
2666
2702
|
const f = i.get(u);
|
|
2667
2703
|
if (f) return f;
|
|
2668
2704
|
const d = a.get(u);
|
|
2669
|
-
if (d && l - d.at < n) return
|
|
2705
|
+
if (d && l - d.at < n) return to(d.observation, u);
|
|
2670
2706
|
const p = (async () => {
|
|
2671
2707
|
try {
|
|
2672
2708
|
const m = await t(c);
|
|
@@ -2681,79 +2717,79 @@ function Wn(t, e, r = {}) {
|
|
|
2681
2717
|
return i.set(u, p), p;
|
|
2682
2718
|
};
|
|
2683
2719
|
}
|
|
2684
|
-
function
|
|
2720
|
+
function Xn(t, e, r) {
|
|
2685
2721
|
for (const [n, o] of t) e - o.at >= r && t.delete(n);
|
|
2686
2722
|
}
|
|
2687
|
-
function
|
|
2723
|
+
function to(t, e) {
|
|
2688
2724
|
return !t || typeof t != "object" ? t : {
|
|
2689
2725
|
...t,
|
|
2690
2726
|
deduped: !0,
|
|
2691
2727
|
dedupe_key: e
|
|
2692
2728
|
};
|
|
2693
2729
|
}
|
|
2694
|
-
var
|
|
2695
|
-
function
|
|
2696
|
-
const e = () =>
|
|
2697
|
-
const i =
|
|
2730
|
+
var eo = 3e4, Se = /* @__PURE__ */ new Set();
|
|
2731
|
+
function ri(t) {
|
|
2732
|
+
const e = () => Qn(async (o) => t(o || {}), (o) => {
|
|
2733
|
+
const i = ro(o), a = Number(o?.quantity || o?.qty || 1) || 1, s = no(o);
|
|
2698
2734
|
return i ? `${i}|${a}|${s}` : "";
|
|
2699
|
-
}, { ttlMs:
|
|
2735
|
+
}, { ttlMs: eo });
|
|
2700
2736
|
let r = e();
|
|
2701
2737
|
const n = async function(i = {}) {
|
|
2702
2738
|
return r(i);
|
|
2703
2739
|
};
|
|
2704
2740
|
return n.__resetForTesting = () => {
|
|
2705
2741
|
r = e();
|
|
2706
|
-
},
|
|
2742
|
+
}, Se.add(n), n;
|
|
2707
2743
|
}
|
|
2708
|
-
function
|
|
2709
|
-
for (const t of
|
|
2744
|
+
function ni() {
|
|
2745
|
+
for (const t of Se) typeof t.__resetForTesting == "function" && t.__resetForTesting();
|
|
2710
2746
|
}
|
|
2711
|
-
function
|
|
2747
|
+
function ro(t) {
|
|
2712
2748
|
const e = t?.cartCode ?? t?.sku ?? t?.productCode ?? t?.product?.sku ?? t?.product?.cart_code;
|
|
2713
2749
|
return e == null ? "" : String(e).trim();
|
|
2714
2750
|
}
|
|
2715
|
-
function
|
|
2751
|
+
function no(t) {
|
|
2716
2752
|
const e = t?.variantId ?? t?.variantCode ?? t?.product?.variantId ?? "";
|
|
2717
2753
|
return e == null ? "" : String(e).trim();
|
|
2718
2754
|
}
|
|
2719
|
-
var
|
|
2720
|
-
function
|
|
2721
|
-
const { accountId: r, allowedHostnames: n, productFromPage: o, mergeProduct: i =
|
|
2755
|
+
var oo = 32, xe = /* @__PURE__ */ new Set();
|
|
2756
|
+
function oi(t, e) {
|
|
2757
|
+
const { accountId: r, allowedHostnames: n, productFromPage: o, mergeProduct: i = ao, needsHydration: a = io, fetchOptions: s = { credentials: "include" }, maxConcurrency: c = 4 } = e;
|
|
2722
2758
|
if (!r) throw new Error("wrapResolveProductsWithPdpHydration: accountId is required");
|
|
2723
2759
|
if (typeof o != "function") throw new Error("wrapResolveProductsWithPdpHydration: productFromPage(doc, url) is required");
|
|
2724
2760
|
if (!Array.isArray(n) || !n.length) throw new Error("wrapResolveProductsWithPdpHydration: allowedHostnames must be a non-empty array");
|
|
2725
|
-
const u = /* @__PURE__ */ new Map(), l =
|
|
2761
|
+
const u = /* @__PURE__ */ new Map(), l = uo({
|
|
2726
2762
|
productFromPage: o,
|
|
2727
2763
|
fetchOptions: s,
|
|
2728
|
-
isAllowed:
|
|
2764
|
+
isAllowed: so(n)
|
|
2729
2765
|
}), f = async function(p = {}) {
|
|
2730
2766
|
const m = await t(p || {});
|
|
2731
2767
|
if (p?.hydrateFromPdp === !1) return m;
|
|
2732
2768
|
const h = Array.isArray(m?.products) ? m.products : [];
|
|
2733
2769
|
if (!h.length) return m;
|
|
2734
|
-
const
|
|
2770
|
+
const T = await lo(h, l, u, c, i, a);
|
|
2735
2771
|
return {
|
|
2736
2772
|
...m,
|
|
2737
|
-
products:
|
|
2773
|
+
products: T
|
|
2738
2774
|
};
|
|
2739
2775
|
};
|
|
2740
|
-
return f.__resetCacheForTesting = () => u.clear(), f.__cacheSizeForTesting = () => u.size,
|
|
2776
|
+
return f.__resetCacheForTesting = () => u.clear(), f.__cacheSizeForTesting = () => u.size, xe.add(f), f;
|
|
2741
2777
|
}
|
|
2742
|
-
function
|
|
2743
|
-
for (const t of
|
|
2778
|
+
function ii() {
|
|
2779
|
+
for (const t of xe) typeof t.__resetCacheForTesting == "function" && t.__resetCacheForTesting();
|
|
2744
2780
|
}
|
|
2745
|
-
function
|
|
2781
|
+
function io(t) {
|
|
2746
2782
|
if (!t || !t.url) return !1;
|
|
2747
2783
|
const e = t, r = e.features, n = e.specs, o = e.category_names, i = Array.isArray(r) && r.length > 0, a = !!n && typeof n == "object" && Object.keys(n).length > 0, s = Array.isArray(o) && o.length > 0;
|
|
2748
2784
|
return !i && !a && !s;
|
|
2749
2785
|
}
|
|
2750
|
-
function
|
|
2786
|
+
function ao(t, e) {
|
|
2751
2787
|
return t ? e ? {
|
|
2752
2788
|
...t,
|
|
2753
2789
|
...e
|
|
2754
2790
|
} : t : e;
|
|
2755
2791
|
}
|
|
2756
|
-
function
|
|
2792
|
+
function so(t) {
|
|
2757
2793
|
const e = t.map((r) => String(r || "").toLowerCase().trim()).filter(Boolean);
|
|
2758
2794
|
return (r) => {
|
|
2759
2795
|
const n = String(r || "").toLowerCase();
|
|
@@ -2763,7 +2799,7 @@ function oo(t) {
|
|
|
2763
2799
|
return !1;
|
|
2764
2800
|
};
|
|
2765
2801
|
}
|
|
2766
|
-
function
|
|
2802
|
+
function co(t, e) {
|
|
2767
2803
|
if (!t) return null;
|
|
2768
2804
|
try {
|
|
2769
2805
|
const r = new URL(String(t));
|
|
@@ -2772,10 +2808,10 @@ function io(t, e) {
|
|
|
2772
2808
|
return null;
|
|
2773
2809
|
}
|
|
2774
2810
|
}
|
|
2775
|
-
function
|
|
2811
|
+
function uo(t) {
|
|
2776
2812
|
const { productFromPage: e, fetchOptions: r, isAllowed: n } = t;
|
|
2777
2813
|
return async function(i) {
|
|
2778
|
-
const a =
|
|
2814
|
+
const a = co(i?.url, n);
|
|
2779
2815
|
if (!a || typeof fetch != "function") return null;
|
|
2780
2816
|
let s;
|
|
2781
2817
|
try {
|
|
@@ -2800,7 +2836,7 @@ function ao(t) {
|
|
|
2800
2836
|
}
|
|
2801
2837
|
};
|
|
2802
2838
|
}
|
|
2803
|
-
async function
|
|
2839
|
+
async function lo(t, e, r, n, o, i) {
|
|
2804
2840
|
const a = new Array(t.length);
|
|
2805
2841
|
let s = 0;
|
|
2806
2842
|
const c = Math.max(1, Math.min(n, t.length)), u = new Array(c).fill(null).map(() => l());
|
|
@@ -2820,18 +2856,18 @@ async function so(t, e, r, n, o, i) {
|
|
|
2820
2856
|
return h ? o(d, h) : d;
|
|
2821
2857
|
}
|
|
2822
2858
|
const m = await e(d);
|
|
2823
|
-
return p && (r.set(p, m || null),
|
|
2859
|
+
return p && (r.set(p, m || null), fo(r)), m ? o(d, m) : d;
|
|
2824
2860
|
}
|
|
2825
2861
|
}
|
|
2826
|
-
function
|
|
2827
|
-
for (; t.size >
|
|
2862
|
+
function fo(t) {
|
|
2863
|
+
for (; t.size > oo; ) {
|
|
2828
2864
|
const e = t.keys().next().value;
|
|
2829
2865
|
if (e === void 0) break;
|
|
2830
2866
|
t.delete(e);
|
|
2831
2867
|
}
|
|
2832
2868
|
}
|
|
2833
|
-
var
|
|
2834
|
-
function
|
|
2869
|
+
var po = 20;
|
|
2870
|
+
function mo(t, e = {}) {
|
|
2835
2871
|
const { context: r, accountConfig: n } = e, o = Array.isArray(t) ? t.filter(Boolean) : [];
|
|
2836
2872
|
if (!o.length) return [];
|
|
2837
2873
|
const i = String(r?.meta?.locale || n?.locale || n?.defaultLocale || "tr-TR").toLowerCase().startsWith("en"), a = i ? "Compare the first two" : "İlk ikisini karşılaştır", s = i ? "Open product page" : "Ürün sayfasını aç", c = i ? "Tell me the comfort details" : "Konfor özelliklerini anlat", u = i ? "Show similar" : "Benzerlerini göster", l = [];
|
|
@@ -2869,7 +2905,7 @@ function lo(t, e = {}) {
|
|
|
2869
2905
|
}
|
|
2870
2906
|
}), l;
|
|
2871
2907
|
}
|
|
2872
|
-
function
|
|
2908
|
+
function Yt(t, e = po) {
|
|
2873
2909
|
const r = [];
|
|
2874
2910
|
if (!Array.isArray(t)) return [];
|
|
2875
2911
|
for (const a of t) {
|
|
@@ -2896,7 +2932,7 @@ function Gt(t, e = uo) {
|
|
|
2896
2932
|
}
|
|
2897
2933
|
return n;
|
|
2898
2934
|
}
|
|
2899
|
-
function
|
|
2935
|
+
function ai(t) {
|
|
2900
2936
|
if (!t?.spec?.elements) return t;
|
|
2901
2937
|
const e = t.spec.root;
|
|
2902
2938
|
if (!e) return t;
|
|
@@ -2918,11 +2954,11 @@ function ni(t) {
|
|
|
2918
2954
|
}
|
|
2919
2955
|
};
|
|
2920
2956
|
}
|
|
2921
|
-
function
|
|
2957
|
+
function si(t, e = {}) {
|
|
2922
2958
|
const r = e.threshold ?? 0;
|
|
2923
2959
|
return !r || r <= 0 || !Array.isArray(t) ? !1 : t.length > r;
|
|
2924
2960
|
}
|
|
2925
|
-
function
|
|
2961
|
+
function ci(t, e = {}) {
|
|
2926
2962
|
const r = Math.max(0, e.retainTail ?? 4);
|
|
2927
2963
|
if (!Array.isArray(t) || t.length === 0 || t.length <= r) return null;
|
|
2928
2964
|
const n = t.slice(t.length - r), o = t.slice(0, t.length - r);
|
|
@@ -2931,7 +2967,7 @@ function ii(t, e = {}) {
|
|
|
2931
2967
|
retainedTail: n
|
|
2932
2968
|
} : null;
|
|
2933
2969
|
}
|
|
2934
|
-
function
|
|
2970
|
+
function ui(t, e, r = {}) {
|
|
2935
2971
|
const n = String(e || "").trim();
|
|
2936
2972
|
if (!n) return t;
|
|
2937
2973
|
const o = Math.max(0, r.retainTail ?? 4), i = Array.isArray(t.messages) ? t.messages : [], a = i.slice(Math.max(0, i.length - o));
|
|
@@ -2953,18 +2989,18 @@ function ai(t, e, r = {}) {
|
|
|
2953
2989
|
}
|
|
2954
2990
|
};
|
|
2955
2991
|
}
|
|
2956
|
-
function
|
|
2992
|
+
function P(t, e) {
|
|
2957
2993
|
const r = t?.[e];
|
|
2958
2994
|
return Array.isArray(r) ? r : [];
|
|
2959
2995
|
}
|
|
2960
|
-
function
|
|
2996
|
+
function H(t, e, r = !1) {
|
|
2961
2997
|
return [...t].reverse().find((n) => n?.name === e && (!r || n?.observation?.status === "ok"));
|
|
2962
2998
|
}
|
|
2963
|
-
function
|
|
2999
|
+
function yo(t) {
|
|
2964
3000
|
return {
|
|
2965
3001
|
kind: "patch",
|
|
2966
3002
|
patch: (e, r, n) => {
|
|
2967
|
-
const o =
|
|
3003
|
+
const o = H(P(n.bag, t), "search_catalog"), i = Array.isArray(o?.observation?.products) ? o.observation.products : null;
|
|
2968
3004
|
return i?.length ? { panel: {
|
|
2969
3005
|
...e.panel,
|
|
2970
3006
|
screen_type: "product_list",
|
|
@@ -2980,25 +3016,25 @@ function fo(t) {
|
|
|
2980
3016
|
}
|
|
2981
3017
|
};
|
|
2982
3018
|
}
|
|
2983
|
-
function
|
|
3019
|
+
function li(t) {
|
|
2984
3020
|
const e = t.obsKey || "roundObservations", r = t.gridLimit ?? 20, n = t.similarsFollowupSteps ? t.similarsFollowupSteps() : [];
|
|
2985
3021
|
return [
|
|
2986
|
-
|
|
3022
|
+
yo(e),
|
|
2987
3023
|
{
|
|
2988
3024
|
kind: "branch",
|
|
2989
|
-
on: ({ bag: o }) =>
|
|
3025
|
+
on: ({ bag: o }) => P(o, e).some((i) => Array.isArray(i?.observation?.products) && i.observation.products.length) ? "has_products" : "no_products",
|
|
2990
3026
|
cases: {
|
|
2991
3027
|
has_products: [{
|
|
2992
3028
|
kind: "emit",
|
|
2993
3029
|
build: ({ bag: o }) => {
|
|
2994
|
-
const i =
|
|
3030
|
+
const i = Yt(P(o, e), r);
|
|
2995
3031
|
return t.uiSpec(t.productsUiSpec(i));
|
|
2996
3032
|
}
|
|
2997
3033
|
}, {
|
|
2998
3034
|
kind: "emit",
|
|
2999
3035
|
build: ({ bag: o, context: i, accountConfig: a }) => {
|
|
3000
|
-
const s =
|
|
3001
|
-
return t.uiSpec(t.actionButtonsUiSpec(
|
|
3036
|
+
const s = Yt(P(o, e), r);
|
|
3037
|
+
return t.uiSpec(t.actionButtonsUiSpec(mo(s, {
|
|
3002
3038
|
context: i,
|
|
3003
3039
|
accountConfig: a
|
|
3004
3040
|
})));
|
|
@@ -3009,12 +3045,12 @@ function si(t) {
|
|
|
3009
3045
|
},
|
|
3010
3046
|
{
|
|
3011
3047
|
kind: "branch",
|
|
3012
|
-
on: ({ bag: o }) =>
|
|
3048
|
+
on: ({ bag: o }) => H(P(o, e), "compare_products", !0) ? "has_compare" : "no_compare",
|
|
3013
3049
|
cases: {
|
|
3014
3050
|
has_compare: [{
|
|
3015
3051
|
kind: "emit",
|
|
3016
3052
|
build: ({ context: o, bag: i }) => {
|
|
3017
|
-
const a =
|
|
3053
|
+
const a = H(P(i, e), "compare_products"), s = a?.observation || {}, c = a?.arguments || {}, u = Array.isArray(c.target_skus) ? c.target_skus.map(String) : [], l = Array.isArray(o?.panel?.last_search_products) ? o.panel.last_search_products : [], f = u.length ? u.map((d) => l.find((p) => String(p?.sku) === d)).filter(Boolean) : l.slice(0, 4);
|
|
3018
3054
|
return t.uiSpec(t.comparisonUiSpec({
|
|
3019
3055
|
products: f,
|
|
3020
3056
|
comparison_table: s.comparison_table,
|
|
@@ -3029,29 +3065,29 @@ function si(t) {
|
|
|
3029
3065
|
},
|
|
3030
3066
|
{
|
|
3031
3067
|
kind: "branch",
|
|
3032
|
-
on: ({ bag: o }) =>
|
|
3068
|
+
on: ({ bag: o }) => H(P(o, e), "get_product_details", !0) ? "has_details" : "no_details",
|
|
3033
3069
|
cases: {
|
|
3034
3070
|
has_details: [{
|
|
3035
3071
|
kind: "emit",
|
|
3036
3072
|
build: ({ context: o, bag: i }) => {
|
|
3037
|
-
const a =
|
|
3073
|
+
const a = H(P(i, e), "get_product_details"), s = a?.observation?.surface || {}, c = a?.arguments || {}, u = Array.isArray(o?.panel?.last_search_products) ? o.panel.last_search_products : [], l = c.sku ? u.find((d) => String(d?.sku) === String(c.sku)) : null, f = s.product || l || s || {};
|
|
3038
3074
|
return t.uiSpec(t.productDetailsUiSpec(f));
|
|
3039
3075
|
}
|
|
3040
3076
|
}, ...n],
|
|
3041
3077
|
no_details: []
|
|
3042
3078
|
}
|
|
3043
3079
|
},
|
|
3044
|
-
...
|
|
3080
|
+
...go({
|
|
3045
3081
|
...t,
|
|
3046
3082
|
obsKey: e
|
|
3047
3083
|
})
|
|
3048
3084
|
];
|
|
3049
3085
|
}
|
|
3050
|
-
function
|
|
3086
|
+
function go(t) {
|
|
3051
3087
|
const e = t.obsKey || "roundObservations", r = t.pdpFollowupProduct;
|
|
3052
3088
|
return r ? [{
|
|
3053
3089
|
kind: "branch",
|
|
3054
|
-
on: ({ bag: n, context: o }) => n.pdpFollowupRendered ||
|
|
3090
|
+
on: ({ bag: n, context: o }) => n.pdpFollowupRendered || P(n, e).some((i) => {
|
|
3055
3091
|
const a = i?.name;
|
|
3056
3092
|
return a === "search_catalog" || a === "compare_products" || a === "get_product_details" || Array.isArray(i?.observation?.products) && i.observation.products.length;
|
|
3057
3093
|
}) ? "skip" : r(n, o) ? "render" : "skip",
|
|
@@ -3072,90 +3108,90 @@ function po(t) {
|
|
|
3072
3108
|
}] : [];
|
|
3073
3109
|
}
|
|
3074
3110
|
export {
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
+
Io as $,
|
|
3112
|
+
Do as A,
|
|
3113
|
+
We as At,
|
|
3114
|
+
fe as B,
|
|
3115
|
+
Wo as C,
|
|
3116
|
+
ko as Ct,
|
|
3117
|
+
Ho as D,
|
|
3118
|
+
wo as Dt,
|
|
3119
|
+
Jo as E,
|
|
3120
|
+
Ge as Et,
|
|
3121
|
+
qo as F,
|
|
3122
|
+
$o as G,
|
|
3123
|
+
cn as H,
|
|
3124
|
+
pn as I,
|
|
3125
|
+
on as J,
|
|
3126
|
+
Bo as K,
|
|
3127
|
+
Fo as L,
|
|
3128
|
+
zo as M,
|
|
3129
|
+
Pe as Mt,
|
|
3130
|
+
hn as N,
|
|
3131
|
+
Ko as O,
|
|
3132
|
+
Ne as Ot,
|
|
3133
|
+
gn as P,
|
|
3134
|
+
Oo as Q,
|
|
3135
|
+
un as R,
|
|
3136
|
+
Sn as S,
|
|
3137
|
+
lr as St,
|
|
3138
|
+
bn as T,
|
|
3139
|
+
I as Tt,
|
|
3140
|
+
Lo as U,
|
|
3141
|
+
pe as V,
|
|
3142
|
+
No as W,
|
|
3143
|
+
le as X,
|
|
3144
|
+
Mo as Y,
|
|
3145
|
+
jo as Z,
|
|
3146
|
+
Xo as _,
|
|
3111
3147
|
x as _t,
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3148
|
+
si as a,
|
|
3149
|
+
Po as at,
|
|
3150
|
+
xn as b,
|
|
3151
|
+
yr as bt,
|
|
3152
|
+
ai as c,
|
|
3153
|
+
Co as ct,
|
|
3154
|
+
ni as d,
|
|
3155
|
+
re as dt,
|
|
3156
|
+
Er as et,
|
|
3157
|
+
ri as f,
|
|
3158
|
+
Ar as ft,
|
|
3159
|
+
ei as g,
|
|
3160
|
+
Ao as gt,
|
|
3161
|
+
Gn as h,
|
|
3162
|
+
xo as ht,
|
|
3163
|
+
ci as i,
|
|
3164
|
+
ie as it,
|
|
3165
|
+
Uo as j,
|
|
3166
|
+
Ee as jt,
|
|
3167
|
+
Vo as k,
|
|
3168
|
+
bo as kt,
|
|
3169
|
+
ii as l,
|
|
3170
|
+
Sr as lt,
|
|
3171
|
+
ti as m,
|
|
3172
|
+
_r as mt,
|
|
3173
|
+
li as n,
|
|
3174
|
+
Eo as nt,
|
|
3175
|
+
Yt as o,
|
|
3176
|
+
Et as ot,
|
|
3177
|
+
Qn as p,
|
|
3178
|
+
So as pt,
|
|
3179
|
+
Ro as q,
|
|
3180
|
+
ui as r,
|
|
3181
|
+
To as rt,
|
|
3182
|
+
mo as s,
|
|
3183
|
+
Pt as st,
|
|
3184
|
+
go as t,
|
|
3185
|
+
oe as tt,
|
|
3186
|
+
oi as u,
|
|
3187
|
+
vo as ut,
|
|
3188
|
+
Qo as v,
|
|
3189
|
+
ee as vt,
|
|
3190
|
+
Go as w,
|
|
3191
|
+
Xt as wt,
|
|
3192
|
+
Zo as x,
|
|
3193
|
+
fr as xt,
|
|
3194
|
+
Yo as y,
|
|
3195
|
+
_o as yt,
|
|
3196
|
+
de as z
|
|
3161
3197
|
};
|