@active-reach/web-sdk 1.51.0 → 1.53.0

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.
Files changed (53) hide show
  1. package/README.md +14 -0
  2. package/dist/aegis-boot.min.js +2 -0
  3. package/dist/aegis-boot.min.js.map +1 -0
  4. package/dist/aegis.min.js +1 -1
  5. package/dist/aegis.min.js.map +1 -1
  6. package/dist/{analytics-DMY0Q0rI.mjs → analytics-CM31xECy.mjs} +3 -211
  7. package/dist/analytics-CM31xECy.mjs.map +1 -0
  8. package/dist/boot.d.ts +46 -0
  9. package/dist/boot.d.ts.map +1 -0
  10. package/dist/boot.js +63 -0
  11. package/dist/boot.js.map +1 -0
  12. package/dist/core/bootstrap.d.ts.map +1 -1
  13. package/dist/core/prefetch-bundle-client.d.ts.map +1 -1
  14. package/dist/fetch-abort-Bs-Stg-I.mjs +216 -0
  15. package/dist/fetch-abort-Bs-Stg-I.mjs.map +1 -0
  16. package/dist/inapp/AegisInAppManager.d.ts +15 -0
  17. package/dist/inapp/AegisInAppManager.d.ts.map +1 -1
  18. package/dist/inapp/active-request.d.ts +63 -0
  19. package/dist/inapp/active-request.d.ts.map +1 -0
  20. package/dist/inapp/anon-claim.d.ts.map +1 -1
  21. package/dist/inapp/brand-accent.d.ts +34 -0
  22. package/dist/inapp/brand-accent.d.ts.map +1 -0
  23. package/dist/inapp/index.d.ts +3 -0
  24. package/dist/inapp/index.d.ts.map +1 -1
  25. package/dist/inapp/renderers/card-template.d.ts.map +1 -1
  26. package/dist/inapp/renderers/carousel-cards.d.ts.map +1 -1
  27. package/dist/inapp/renderers/hero.d.ts +48 -0
  28. package/dist/inapp/renderers/hero.d.ts.map +1 -1
  29. package/dist/inapp/renderers/overlay-layout.d.ts +41 -0
  30. package/dist/inapp/renderers/overlay-layout.d.ts.map +1 -0
  31. package/dist/inapp/renderers/product-rail-section.d.ts +37 -7
  32. package/dist/inapp/renderers/product-rail-section.d.ts.map +1 -1
  33. package/dist/inapp/renderers/product-recommendation.d.ts.map +1 -1
  34. package/dist/inapp/renderers/progress-bar.d.ts.map +1 -1
  35. package/dist/inapp/renderers/reviews.d.ts.map +1 -1
  36. package/dist/inapp/renderers/sticky-bar.d.ts.map +1 -1
  37. package/dist/inapp/slot-kind.d.ts +28 -0
  38. package/dist/inapp/slot-kind.d.ts.map +1 -0
  39. package/dist/index.d.ts +2 -1
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +666 -565
  42. package/dist/index.js.map +1 -1
  43. package/dist/integrations/react.d.ts.map +1 -1
  44. package/dist/react.js +1 -1
  45. package/dist/storage-D5jp9bO-.mjs +212 -0
  46. package/dist/storage-D5jp9bO-.mjs.map +1 -0
  47. package/dist/triggers/IntentRuleEvaluator.d.ts.map +1 -1
  48. package/dist/utils/fetch-abort.d.ts +17 -0
  49. package/dist/utils/fetch-abort.d.ts.map +1 -1
  50. package/dist/widgets/AegisWidgetManager.d.ts +2 -0
  51. package/dist/widgets/AegisWidgetManager.d.ts.map +1 -1
  52. package/package.json +9 -3
  53. package/dist/analytics-DMY0Q0rI.mjs.map +0 -1
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
- import { g as generateUUID, S as Storage, r as redactUrl, i as isPreviewPage, p as previewAsOfToken, a as recordInAppItemTouch, e as ensureFbc, l as logger, A as Aegis } from "./analytics-DMY0Q0rI.mjs";
2
- import { B, E, N, R, U, m } from "./analytics-DMY0Q0rI.mjs";
1
+ import { g as generateUUID, r as recordInAppItemTouch, e as ensureFbc, l as logger, A as Aegis } from "./analytics-CM31xECy.mjs";
2
+ import { B, E, N, R, U, m } from "./analytics-CM31xECy.mjs";
3
+ import { S as Storage, r as redactUrl, i as isPreviewPage } from "./storage-D5jp9bO-.mjs";
4
+ import { r as readAnonIdFromStorage$1, m as markReturningVisitor, a as activeRequestKey, c as cartKeyPartOf, K as KNOWN_SURFACES, b as buildActiveRequest, t as takeActiveBoot, d as fetchWithAbort, f as fetchWithAbortRetry, e as detectDeviceType, g as readABAssignments, h as currentPageUrl, i as isNewVisitor, j as isAbortError, S as SDK_FETCH_ABORT_MS } from "./fetch-abort-Bs-Stg-I.mjs";
3
5
  import { a as assetIdOf } from "./AegisWebPush-BE9wJcx0.mjs";
4
6
  import { A } from "./AegisWebPush-BE9wJcx0.mjs";
5
7
  function debounce(func, wait) {
@@ -148,6 +150,254 @@ function prizeStateOf(resp, retryMessage) {
148
150
  if (outcome === "credited_win") return { state: "credited_win" };
149
151
  return prize.win === false ? { state: "loss" } : { state: "credited_win" };
150
152
  }
153
+ const BOTTOM_RESERVE_VAR = "--aegis-bottom-reserve";
154
+ const DESKTOP_MIN_WIDTH_PX = 768;
155
+ function bottomOffset(px) {
156
+ return `calc(var(${BOTTOM_RESERVE_VAR}, 0px) + ${px}px)`;
157
+ }
158
+ const SHEET_STYLE_ID = "aegis-overlay-layout-style";
159
+ function injectOverlayLayoutCss() {
160
+ if (typeof document === "undefined" || !document.head) return;
161
+ if (document.getElementById(SHEET_STYLE_ID)) return;
162
+ const style = document.createElement("style");
163
+ style.id = SHEET_STYLE_ID;
164
+ style.textContent = `@media (min-width:${DESKTOP_MIN_WIDTH_PX}px){.aegis-sheet-overlay{align-items:center !important;padding:24px !important;}.aegis-sheet{border-radius:20px !important;max-height:80vh !important;}.aegis-sheet-grabber{display:none !important;}.aegis-bottom-panel{top:0 !important;bottom:0 !important;display:flex !important;align-items:center !important;justify-content:center !important;padding:24px !important;background:rgba(17,24,39,0.45) !important;}.aegis-bottom-panel > *{width:100%;}}`;
165
+ document.head.appendChild(style);
166
+ }
167
+ function overlayAnchor(c) {
168
+ const ic = c.interactive_config || {};
169
+ switch (c.type) {
170
+ case "sticky_bar":
171
+ return ic.sticky_position === "top" ? "top" : "bottom";
172
+ case "progress_bar":
173
+ case "carousel_cards":
174
+ return "bottom";
175
+ case "banner":
176
+ return ic.banner_position === "bottom" ? "bottom" : "top";
177
+ case "pip": {
178
+ const pos = typeof ic.pip_position === "string" ? ic.pip_position : "bottom-right";
179
+ return pos.startsWith("top") ? "top" : "bottom";
180
+ }
181
+ default:
182
+ return "center";
183
+ }
184
+ }
185
+ const keywords = ["inherit", "system", "serif", "mono"];
186
+ const system_stacks = { "system": "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif", "serif": "Georgia, 'Times New Roman', serif", "mono": "ui-monospace, 'SF Mono', Menlo, monospace" };
187
+ const aliases = { "system-ui": "system", "-apple-system": "system", "georgia": "serif", "times new roman": "serif", "sf mono": "mono", "ui-monospace": "mono", "menlo": "mono", "monospace": "mono" };
188
+ const role_weights = { "body": [400, 500], "display": [600, 700] };
189
+ const google = [{ "name": "Urbanist", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "99.04%", "ascent_override": "95.93%", "descent_override": "25.24%", "line_gap_override": "0.00%" } }, { "name": "Inter", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "107.12%", "ascent_override": "90.44%", "descent_override": "22.52%", "line_gap_override": "0.00%" } }, { "name": "Poppins", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "112.16%", "ascent_override": "93.62%", "descent_override": "31.21%", "line_gap_override": "8.92%" } }, { "name": "DM Sans", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "104.53%", "ascent_override": "94.90%", "descent_override": "29.66%", "line_gap_override": "0.00%" } }, { "name": "Nunito", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "101.39%", "ascent_override": "99.71%", "descent_override": "34.82%", "line_gap_override": "0.00%" } }, { "name": "Montserrat", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "112.83%", "ascent_override": "85.79%", "descent_override": "22.25%", "line_gap_override": "0.00%" } }, { "name": "Roboto", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "99.78%", "ascent_override": "92.98%", "descent_override": "24.47%", "line_gap_override": "0.00%" } }, { "name": "Outfit", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "99.82%", "ascent_override": "100.18%", "descent_override": "26.05%", "line_gap_override": "0.00%" } }, { "name": "Playfair Display", "category": "serif", "fallback": { "local": "Times New Roman", "size_adjust": "111.26%", "ascent_override": "97.25%", "descent_override": "22.56%", "line_gap_override": "0.00%" } }, { "name": "Lora", "category": "serif", "fallback": { "local": "Times New Roman", "size_adjust": "115.20%", "ascent_override": "87.33%", "descent_override": "23.78%", "line_gap_override": "0.00%" } }];
190
+ const FONT_ALLOWLIST = {
191
+ keywords,
192
+ system_stacks,
193
+ aliases,
194
+ role_weights,
195
+ google
196
+ };
197
+ const BODY_FONT_STACK = "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif";
198
+ const SERIF_STACK = "Georgia, 'Times New Roman', serif";
199
+ const AEGIS_BODY_FONT_VAR = "--aegis-font-body";
200
+ const AEGIS_DISPLAY_FONT_VAR = "--aegis-font-display";
201
+ const ACS_DISPLAY_FONT_VAR = "--acs-font-display";
202
+ const ACS_BODY_FONT_VAR = "--acs-font-body";
203
+ const GOOGLE_FONTS = FONT_ALLOWLIST.google;
204
+ const KEYWORDS = FONT_ALLOWLIST.keywords;
205
+ const SYSTEM_STACKS = FONT_ALLOWLIST.system_stacks;
206
+ const ALIASES = FONT_ALLOWLIST.aliases;
207
+ const ROLE_WEIGHTS = FONT_ALLOWLIST.role_weights;
208
+ function fontFamilyCss(role) {
209
+ return `font-family:var(${role === "display" ? AEGIS_DISPLAY_FONT_VAR : AEGIS_BODY_FONT_VAR});`;
210
+ }
211
+ function findGoogleFont(value) {
212
+ const v = value.trim().toLowerCase();
213
+ return GOOGLE_FONTS.find((f) => f.name.toLowerCase() === v);
214
+ }
215
+ function normalizeFontValue(value) {
216
+ var _a;
217
+ if (typeof value !== "string") return null;
218
+ const first = value.split(",")[0].trim().replace(/^['"]|['"]$/g, "").trim();
219
+ if (!first) return null;
220
+ const v = first.toLowerCase();
221
+ if (KEYWORDS.includes(v)) return v;
222
+ if (ALIASES[v]) return ALIASES[v];
223
+ return ((_a = findGoogleFont(first)) == null ? void 0 : _a.name) ?? null;
224
+ }
225
+ function fallbackFamily(f) {
226
+ return `${f.name} Aegis Fallback`;
227
+ }
228
+ function fontValueToCss(value, host = "third_party") {
229
+ const canonical = normalizeFontValue(value);
230
+ if (!canonical) return null;
231
+ if (canonical === "inherit") return { css: "initial" };
232
+ if (SYSTEM_STACKS[canonical]) return { css: SYSTEM_STACKS[canonical] };
233
+ const f = findGoogleFont(canonical);
234
+ if (!f) return null;
235
+ const stack = f.category === "serif" ? SERIF_STACK : BODY_FONT_STACK;
236
+ if (host === "acs") return { css: `var(${acsFaceVar(f)}), ${stack}` };
237
+ return { css: `'${f.name}', '${fallbackFamily(f)}', ${stack}`, font: f };
238
+ }
239
+ function acsFaceVar(f) {
240
+ return `--acs-face-${f.name.toLowerCase().replace(/ /g, "-")}`;
241
+ }
242
+ function readRootVar(name) {
243
+ if (typeof document === "undefined" || typeof getComputedStyle !== "function") return "";
244
+ try {
245
+ return getComputedStyle(document.documentElement).getPropertyValue(name).trim();
246
+ } catch {
247
+ return "";
248
+ }
249
+ }
250
+ function detectFontHost(read2 = readRootVar) {
251
+ return read2(ACS_BODY_FONT_VAR) ? "acs" : "third_party";
252
+ }
253
+ function resolveRootFonts(brand, read2 = readRootVar) {
254
+ const host = detectFontHost(read2);
255
+ if (host === "acs") {
256
+ return {
257
+ host,
258
+ body: `var(${ACS_BODY_FONT_VAR})`,
259
+ display: read2(ACS_DISPLAY_FONT_VAR) ? `var(${ACS_DISPLAY_FONT_VAR})` : `var(${ACS_BODY_FONT_VAR})`,
260
+ load: []
261
+ };
262
+ }
263
+ const load = [];
264
+ const pick = (role) => {
265
+ const served = fontValueToCss(role === "display" ? brand == null ? void 0 : brand.display : brand == null ? void 0 : brand.body);
266
+ if (!served) return null;
267
+ if (served.font) load.push({ font: served.font, role });
268
+ return served.css;
269
+ };
270
+ const body = pick("body");
271
+ const display = pick("display");
272
+ return { host, body, display, load };
273
+ }
274
+ const LINK_ID = "aegis-inapp-fonts";
275
+ const FALLBACK_STYLE_ID = "aegis-inapp-font-fallbacks";
276
+ const PRECONNECT_ORIGINS = ["https://fonts.googleapis.com", "https://fonts.gstatic.com"];
277
+ const requested = /* @__PURE__ */ new Map();
278
+ function googleFontsHref(families) {
279
+ const parts = [...families.keys()].sort((a, b) => a.localeCompare(b)).map((name) => {
280
+ const weights = [...families.get(name) ?? []].sort((a, b) => a - b);
281
+ return `family=${name.replace(/ /g, "+")}:wght@${weights.join(";")}`;
282
+ });
283
+ return `https://fonts.googleapis.com/css2?${parts.join("&")}&display=swap`;
284
+ }
285
+ function fallbackFaceCss(fonts) {
286
+ return fonts.map(
287
+ (f) => `@font-face{font-family:'${fallbackFamily(f)}';src:local('${f.fallback.local}');size-adjust:${f.fallback.size_adjust};ascent-override:${f.fallback.ascent_override};descent-override:${f.fallback.descent_override};line-gap-override:${f.fallback.line_gap_override};}`
288
+ ).join("\n");
289
+ }
290
+ function ensurePreconnect() {
291
+ for (const origin of PRECONNECT_ORIGINS) {
292
+ if (document.head.querySelector(`link[rel="preconnect"][href="${origin}"]`)) continue;
293
+ const l = document.createElement("link");
294
+ l.rel = "preconnect";
295
+ l.href = origin;
296
+ if (origin.includes("gstatic")) l.crossOrigin = "anonymous";
297
+ document.head.appendChild(l);
298
+ }
299
+ }
300
+ function loadFonts(loads, read2 = readRootVar) {
301
+ if (typeof document === "undefined" || loads.length === 0) return;
302
+ if (detectFontHost(read2) === "acs") return;
303
+ let grew = false;
304
+ for (const { font, role } of loads) {
305
+ const known = findGoogleFont(font.name);
306
+ if (!known) continue;
307
+ const set = requested.get(known.name) ?? /* @__PURE__ */ new Set();
308
+ for (const w of ROLE_WEIGHTS[role]) {
309
+ if (!set.has(w)) {
310
+ set.add(w);
311
+ grew = true;
312
+ }
313
+ }
314
+ requested.set(known.name, set);
315
+ }
316
+ if (!grew) return;
317
+ ensurePreconnect();
318
+ let style = document.getElementById(FALLBACK_STYLE_ID);
319
+ if (!style) {
320
+ style = document.createElement("style");
321
+ style.id = FALLBACK_STYLE_ID;
322
+ document.head.appendChild(style);
323
+ }
324
+ style.textContent = fallbackFaceCss(
325
+ [...requested.keys()].map((n) => findGoogleFont(n)).filter((f) => !!f)
326
+ );
327
+ let link = document.getElementById(LINK_ID);
328
+ if (!link) {
329
+ link = document.createElement("link");
330
+ link.id = LINK_ID;
331
+ link.rel = "stylesheet";
332
+ document.head.appendChild(link);
333
+ }
334
+ link.href = googleFontsHref(requested);
335
+ }
336
+ function applyRootFonts(brand, read2 = readRootVar) {
337
+ const r = resolveRootFonts(brand, read2);
338
+ if (typeof document === "undefined") return r;
339
+ const root = document.documentElement.style;
340
+ if (r.body) root.setProperty(AEGIS_BODY_FONT_VAR, r.body);
341
+ else root.removeProperty(AEGIS_BODY_FONT_VAR);
342
+ if (r.display) root.setProperty(AEGIS_DISPLAY_FONT_VAR, r.display);
343
+ else root.removeProperty(AEGIS_DISPLAY_FONT_VAR);
344
+ loadFonts(r.load, read2);
345
+ return r;
346
+ }
347
+ function campaignFontFamily(campaign) {
348
+ var _a;
349
+ const style = (_a = campaign == null ? void 0 : campaign.interactive_config) == null ? void 0 : _a.style;
350
+ if (style && typeof style === "object") {
351
+ const ff = style.fontFamily;
352
+ if (typeof ff === "string" && ff.trim()) return ff;
353
+ }
354
+ return void 0;
355
+ }
356
+ function campaignFontVarsCss(value, read2 = readRootVar) {
357
+ const served = fontValueToCss(value, detectFontHost(read2));
358
+ if (!served) return "";
359
+ if (served.font) {
360
+ loadFonts(
361
+ [
362
+ { font: served.font, role: "body" },
363
+ { font: served.font, role: "display" }
364
+ ],
365
+ read2
366
+ );
367
+ }
368
+ return `${AEGIS_BODY_FONT_VAR}:${served.css};${AEGIS_DISPLAY_FONT_VAR}:${served.css};`;
369
+ }
370
+ const CAMPAIGN_SHEET_ID = "aegis-campaign-fonts";
371
+ const SAFE_ID = /^[A-Za-z0-9_-]{1,128}$/;
372
+ function registerCampaignFonts(campaigns, read2 = readRootVar) {
373
+ const rules = [];
374
+ for (const c of campaigns) {
375
+ const id = typeof c.id === "string" ? c.id : "";
376
+ if (!SAFE_ID.test(id)) continue;
377
+ const decl = campaignFontVarsCss(campaignFontFamily(c), read2);
378
+ if (decl) rules.push(`[data-campaign-id="${id}"]{${decl}}`);
379
+ }
380
+ const css = rules.join("\n");
381
+ if (typeof document === "undefined") return css;
382
+ let sheet = document.getElementById(CAMPAIGN_SHEET_ID);
383
+ if (!css) {
384
+ sheet == null ? void 0 : sheet.remove();
385
+ return css;
386
+ }
387
+ if (!sheet) {
388
+ sheet = document.createElement("style");
389
+ sheet.id = CAMPAIGN_SHEET_ID;
390
+ document.head.appendChild(sheet);
391
+ }
392
+ sheet.textContent = css;
393
+ return css;
394
+ }
395
+ function applyCampaignFonts(campaigns, read2 = readRootVar) {
396
+ var _a;
397
+ const brand = ((_a = campaigns.find((c) => c.brand_typography)) == null ? void 0 : _a.brand_typography) ?? null;
398
+ applyRootFonts(brand, read2);
399
+ registerCampaignFonts(campaigns, read2);
400
+ }
151
401
  const CLAIM_BUTTON_LABEL = "Log in or sign up to claim";
152
402
  const SIGN_IN_BUTTON_LABEL = "Sign in to play";
153
403
  const ANON_CLAIMS_TTL_MS = 24 * 60 * 60 * 1e3;
@@ -214,7 +464,7 @@ function showClaimNotice(answer, onRetry) {
214
464
  const box = document.createElement("div");
215
465
  box.setAttribute("data-aegis-anon-claim-notice", "");
216
466
  box.setAttribute("role", "status");
217
- box.style.cssText = "position:fixed;left:16px;right:16px;bottom:16px;max-width:420px;margin:0 auto;z-index:2147483646;background:#fff;color:#111827;border-radius:12px;padding:14px 16px;box-shadow:0 8px 30px rgba(0,0,0,0.18);font:14px/1.4 system-ui,sans-serif;";
467
+ box.style.cssText = `position:fixed;left:16px;right:16px;bottom:${bottomOffset(16)};max-width:420px;margin:0 auto;z-index:2147483646;background:#fff;color:#111827;border-radius:12px;padding:14px 16px;box-shadow:0 8px 30px rgba(0,0,0,0.18);font-size:14px;line-height:1.4;${fontFamilyCss("body")}`;
218
468
  const text = document.createElement("div");
219
469
  text.style.cssText = "font-weight:600;";
220
470
  text.textContent = answer.text;
@@ -385,321 +635,105 @@ const ICONS = {
385
635
  wallet: [
386
636
  ["path", { d: "M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1" }],
387
637
  ["path", { d: "M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4" }]
388
- ],
389
- coins: [
390
- ["circle", { cx: "8", cy: "8", r: "6" }],
391
- ["path", { d: "M18.09 10.37A6 6 0 1 1 10.34 18" }],
392
- ["path", { d: "M7 6h1v4" }],
393
- ["path", { d: "m16.71 13.88.7.71-2.82 2.82" }]
394
- ],
395
- trophy: [
396
- ["path", { d: "M6 9H4.5a2.5 2.5 0 0 1 0-5H6" }],
397
- ["path", { d: "M18 9h1.5a2.5 2.5 0 0 0 0-5H18" }],
398
- ["path", { d: "M4 22h16" }],
399
- ["path", { d: "M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22" }],
400
- ["path", { d: "M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22" }],
401
- ["path", { d: "M18 2H6v7a6 6 0 0 0 12 0V2Z" }]
402
- ],
403
- timer: [
404
- ["line", { x1: "10", x2: "14", y1: "2", y2: "2" }],
405
- ["line", { x1: "12", x2: "15", y1: "14", y2: "11" }],
406
- ["circle", { cx: "12", cy: "14", r: "8" }]
407
- ],
408
- "map-pin": [
409
- ["path", { d: "M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0" }],
410
- ["circle", { cx: "12", cy: "10", r: "3" }]
411
- ],
412
- user: [
413
- ["path", { d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" }],
414
- ["circle", { cx: "12", cy: "7", r: "4" }]
415
- ],
416
- "thumbs-up": [
417
- ["path", { d: "M7 10v12" }],
418
- ["path", { d: "M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z" }]
419
- ],
420
- "arrow-right": [
421
- ["path", { d: "M5 12h14" }],
422
- ["path", { d: "m12 5 7 7-7 7" }]
423
- ],
424
- "chevron-right": [["path", { d: "m9 18 6-6-6-6" }]],
425
- plus: [
426
- ["path", { d: "M5 12h14" }],
427
- ["path", { d: "M12 5v14" }]
428
- ],
429
- store: [
430
- ["path", { d: "m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7" }],
431
- ["path", { d: "M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8" }],
432
- ["path", { d: "M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4" }],
433
- ["path", { d: "M2 7h20" }],
434
- ["path", { d: "M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7" }]
435
- ],
436
- rocket: [
437
- ["path", { d: "M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z" }],
438
- ["path", { d: "m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z" }],
439
- ["path", { d: "M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0" }],
440
- ["path", { d: "M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5" }]
441
- ]
442
- };
443
- function escapeAttr(value) {
444
- return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
445
- }
446
- const SVG_NS$1 = "http://www.w3.org/2000/svg";
447
- function lucideSvgEl(name, opts = {}) {
448
- const node = ICONS[name];
449
- if (!node || typeof document === "undefined") return null;
450
- const size = opts.size ?? 24;
451
- const svg = document.createElementNS(SVG_NS$1, "svg");
452
- svg.setAttribute("width", String(size));
453
- svg.setAttribute("height", String(size));
454
- svg.setAttribute("viewBox", "0 0 24 24");
455
- svg.setAttribute("fill", "none");
456
- svg.setAttribute("stroke", opts.color ?? "currentColor");
457
- svg.setAttribute("stroke-width", String(opts.strokeWidth ?? 2));
458
- svg.setAttribute("stroke-linecap", "round");
459
- svg.setAttribute("stroke-linejoin", "round");
460
- if (opts.className) svg.setAttribute("class", opts.className);
461
- if (opts.ariaLabel) {
462
- svg.setAttribute("role", "img");
463
- svg.setAttribute("aria-label", opts.ariaLabel);
464
- } else {
465
- svg.setAttribute("aria-hidden", "true");
466
- }
467
- for (const [tag, attrs] of node) {
468
- const child = document.createElementNS(SVG_NS$1, tag);
469
- for (const [k, v] of Object.entries(attrs)) child.setAttribute(k, String(v));
470
- svg.appendChild(child);
471
- }
472
- return svg;
473
- }
474
- function lucideSvg(name, opts = {}) {
475
- const node = ICONS[name];
476
- if (!node) return "";
477
- const size = opts.size ?? 24;
478
- const color = opts.color ?? "currentColor";
479
- const strokeWidth = opts.strokeWidth ?? 2;
480
- const a11y = opts.ariaLabel ? `role="img" aria-label="${escapeAttr(opts.ariaLabel)}"` : 'aria-hidden="true"';
481
- const cls = opts.className ? ` class="${escapeAttr(opts.className)}"` : "";
482
- const children = node.map(([tag, attrs]) => {
483
- const attrStr = Object.entries(attrs).map(([k, v]) => `${k}="${escapeAttr(String(v))}"`).join(" ");
484
- return `<${tag} ${attrStr}/>`;
485
- }).join("");
486
- return `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 24 24" fill="none" stroke="${escapeAttr(color)}" stroke-width="${strokeWidth}" stroke-linecap="round" stroke-linejoin="round"${cls} ${a11y}>${children}</svg>`;
487
- }
488
- const keywords = ["inherit", "system", "serif", "mono"];
489
- const system_stacks = { "system": "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif", "serif": "Georgia, 'Times New Roman', serif", "mono": "ui-monospace, 'SF Mono', Menlo, monospace" };
490
- const aliases = { "system-ui": "system", "-apple-system": "system", "georgia": "serif", "times new roman": "serif", "sf mono": "mono", "ui-monospace": "mono", "menlo": "mono", "monospace": "mono" };
491
- const role_weights = { "body": [400, 500], "display": [600, 700] };
492
- const google = [{ "name": "Urbanist", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "99.04%", "ascent_override": "95.93%", "descent_override": "25.24%", "line_gap_override": "0.00%" } }, { "name": "Inter", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "107.12%", "ascent_override": "90.44%", "descent_override": "22.52%", "line_gap_override": "0.00%" } }, { "name": "Poppins", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "112.16%", "ascent_override": "93.62%", "descent_override": "31.21%", "line_gap_override": "8.92%" } }, { "name": "DM Sans", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "104.53%", "ascent_override": "94.90%", "descent_override": "29.66%", "line_gap_override": "0.00%" } }, { "name": "Nunito", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "101.39%", "ascent_override": "99.71%", "descent_override": "34.82%", "line_gap_override": "0.00%" } }, { "name": "Montserrat", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "112.83%", "ascent_override": "85.79%", "descent_override": "22.25%", "line_gap_override": "0.00%" } }, { "name": "Roboto", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "99.78%", "ascent_override": "92.98%", "descent_override": "24.47%", "line_gap_override": "0.00%" } }, { "name": "Outfit", "category": "sans-serif", "fallback": { "local": "Arial", "size_adjust": "99.82%", "ascent_override": "100.18%", "descent_override": "26.05%", "line_gap_override": "0.00%" } }, { "name": "Playfair Display", "category": "serif", "fallback": { "local": "Times New Roman", "size_adjust": "111.26%", "ascent_override": "97.25%", "descent_override": "22.56%", "line_gap_override": "0.00%" } }, { "name": "Lora", "category": "serif", "fallback": { "local": "Times New Roman", "size_adjust": "115.20%", "ascent_override": "87.33%", "descent_override": "23.78%", "line_gap_override": "0.00%" } }];
493
- const FONT_ALLOWLIST = {
494
- keywords,
495
- system_stacks,
496
- aliases,
497
- role_weights,
498
- google
499
- };
500
- const BODY_FONT_STACK = "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif";
501
- const SERIF_STACK = "Georgia, 'Times New Roman', serif";
502
- const AEGIS_BODY_FONT_VAR = "--aegis-font-body";
503
- const AEGIS_DISPLAY_FONT_VAR = "--aegis-font-display";
504
- const ACS_DISPLAY_FONT_VAR = "--acs-font-display";
505
- const ACS_BODY_FONT_VAR = "--acs-font-body";
506
- const GOOGLE_FONTS = FONT_ALLOWLIST.google;
507
- const KEYWORDS = FONT_ALLOWLIST.keywords;
508
- const SYSTEM_STACKS = FONT_ALLOWLIST.system_stacks;
509
- const ALIASES = FONT_ALLOWLIST.aliases;
510
- const ROLE_WEIGHTS = FONT_ALLOWLIST.role_weights;
511
- function fontFamilyCss(role) {
512
- return `font-family:var(${role === "display" ? AEGIS_DISPLAY_FONT_VAR : AEGIS_BODY_FONT_VAR});`;
513
- }
514
- function findGoogleFont(value) {
515
- const v = value.trim().toLowerCase();
516
- return GOOGLE_FONTS.find((f) => f.name.toLowerCase() === v);
517
- }
518
- function normalizeFontValue(value) {
519
- var _a;
520
- if (typeof value !== "string") return null;
521
- const first = value.split(",")[0].trim().replace(/^['"]|['"]$/g, "").trim();
522
- if (!first) return null;
523
- const v = first.toLowerCase();
524
- if (KEYWORDS.includes(v)) return v;
525
- if (ALIASES[v]) return ALIASES[v];
526
- return ((_a = findGoogleFont(first)) == null ? void 0 : _a.name) ?? null;
527
- }
528
- function fallbackFamily(f) {
529
- return `${f.name} Aegis Fallback`;
530
- }
531
- function fontValueToCss(value, host = "third_party") {
532
- const canonical = normalizeFontValue(value);
533
- if (!canonical) return null;
534
- if (canonical === "inherit") return { css: "initial" };
535
- if (SYSTEM_STACKS[canonical]) return { css: SYSTEM_STACKS[canonical] };
536
- const f = findGoogleFont(canonical);
537
- if (!f) return null;
538
- const stack = f.category === "serif" ? SERIF_STACK : BODY_FONT_STACK;
539
- if (host === "acs") return { css: `var(${acsFaceVar(f)}), ${stack}` };
540
- return { css: `'${f.name}', '${fallbackFamily(f)}', ${stack}`, font: f };
541
- }
542
- function acsFaceVar(f) {
543
- return `--acs-face-${f.name.toLowerCase().replace(/ /g, "-")}`;
544
- }
545
- function readRootVar(name) {
546
- if (typeof document === "undefined" || typeof getComputedStyle !== "function") return "";
547
- try {
548
- return getComputedStyle(document.documentElement).getPropertyValue(name).trim();
549
- } catch {
550
- return "";
551
- }
552
- }
553
- function detectFontHost(read2 = readRootVar) {
554
- return read2(ACS_BODY_FONT_VAR) ? "acs" : "third_party";
555
- }
556
- function resolveRootFonts(brand, read2 = readRootVar) {
557
- const host = detectFontHost(read2);
558
- if (host === "acs") {
559
- return {
560
- host,
561
- body: `var(${ACS_BODY_FONT_VAR})`,
562
- display: read2(ACS_DISPLAY_FONT_VAR) ? `var(${ACS_DISPLAY_FONT_VAR})` : `var(${ACS_BODY_FONT_VAR})`,
563
- load: []
564
- };
565
- }
566
- const load = [];
567
- const pick = (role) => {
568
- const served = fontValueToCss(role === "display" ? brand == null ? void 0 : brand.display : brand == null ? void 0 : brand.body);
569
- if (!served) return null;
570
- if (served.font) load.push({ font: served.font, role });
571
- return served.css;
572
- };
573
- const body = pick("body");
574
- const display = pick("display");
575
- return { host, body, display, load };
576
- }
577
- const LINK_ID = "aegis-inapp-fonts";
578
- const FALLBACK_STYLE_ID = "aegis-inapp-font-fallbacks";
579
- const PRECONNECT_ORIGINS = ["https://fonts.googleapis.com", "https://fonts.gstatic.com"];
580
- const requested = /* @__PURE__ */ new Map();
581
- function googleFontsHref(families) {
582
- const parts = [...families.keys()].sort((a, b) => a.localeCompare(b)).map((name) => {
583
- const weights = [...families.get(name) ?? []].sort((a, b) => a - b);
584
- return `family=${name.replace(/ /g, "+")}:wght@${weights.join(";")}`;
585
- });
586
- return `https://fonts.googleapis.com/css2?${parts.join("&")}&display=swap`;
587
- }
588
- function fallbackFaceCss(fonts) {
589
- return fonts.map(
590
- (f) => `@font-face{font-family:'${fallbackFamily(f)}';src:local('${f.fallback.local}');size-adjust:${f.fallback.size_adjust};ascent-override:${f.fallback.ascent_override};descent-override:${f.fallback.descent_override};line-gap-override:${f.fallback.line_gap_override};}`
591
- ).join("\n");
592
- }
593
- function ensurePreconnect() {
594
- for (const origin of PRECONNECT_ORIGINS) {
595
- if (document.head.querySelector(`link[rel="preconnect"][href="${origin}"]`)) continue;
596
- const l = document.createElement("link");
597
- l.rel = "preconnect";
598
- l.href = origin;
599
- if (origin.includes("gstatic")) l.crossOrigin = "anonymous";
600
- document.head.appendChild(l);
601
- }
602
- }
603
- function loadFonts(loads, read2 = readRootVar) {
604
- if (typeof document === "undefined" || loads.length === 0) return;
605
- if (detectFontHost(read2) === "acs") return;
606
- let grew = false;
607
- for (const { font, role } of loads) {
608
- const known = findGoogleFont(font.name);
609
- if (!known) continue;
610
- const set = requested.get(known.name) ?? /* @__PURE__ */ new Set();
611
- for (const w of ROLE_WEIGHTS[role]) {
612
- if (!set.has(w)) {
613
- set.add(w);
614
- grew = true;
615
- }
616
- }
617
- requested.set(known.name, set);
618
- }
619
- if (!grew) return;
620
- ensurePreconnect();
621
- let style = document.getElementById(FALLBACK_STYLE_ID);
622
- if (!style) {
623
- style = document.createElement("style");
624
- style.id = FALLBACK_STYLE_ID;
625
- document.head.appendChild(style);
626
- }
627
- style.textContent = fallbackFaceCss(
628
- [...requested.keys()].map((n) => findGoogleFont(n)).filter((f) => !!f)
629
- );
630
- let link = document.getElementById(LINK_ID);
631
- if (!link) {
632
- link = document.createElement("link");
633
- link.id = LINK_ID;
634
- link.rel = "stylesheet";
635
- document.head.appendChild(link);
636
- }
637
- link.href = googleFontsHref(requested);
638
- }
639
- function applyRootFonts(brand, read2 = readRootVar) {
640
- const r = resolveRootFonts(brand, read2);
641
- if (typeof document === "undefined") return r;
642
- const root = document.documentElement.style;
643
- if (r.body) root.setProperty(AEGIS_BODY_FONT_VAR, r.body);
644
- else root.removeProperty(AEGIS_BODY_FONT_VAR);
645
- if (r.display) root.setProperty(AEGIS_DISPLAY_FONT_VAR, r.display);
646
- else root.removeProperty(AEGIS_DISPLAY_FONT_VAR);
647
- loadFonts(r.load, read2);
648
- return r;
649
- }
650
- function campaignFontFamily(campaign) {
651
- var _a;
652
- const style = (_a = campaign == null ? void 0 : campaign.interactive_config) == null ? void 0 : _a.style;
653
- if (style && typeof style === "object") {
654
- const ff = style.fontFamily;
655
- if (typeof ff === "string" && ff.trim()) return ff;
656
- }
657
- return void 0;
658
- }
659
- function campaignFontVarsCss(value, read2 = readRootVar) {
660
- const served = fontValueToCss(value, detectFontHost(read2));
661
- if (!served) return "";
662
- if (served.font) {
663
- loadFonts(
664
- [
665
- { font: served.font, role: "body" },
666
- { font: served.font, role: "display" }
667
- ],
668
- read2
669
- );
670
- }
671
- return `${AEGIS_BODY_FONT_VAR}:${served.css};${AEGIS_DISPLAY_FONT_VAR}:${served.css};`;
638
+ ],
639
+ coins: [
640
+ ["circle", { cx: "8", cy: "8", r: "6" }],
641
+ ["path", { d: "M18.09 10.37A6 6 0 1 1 10.34 18" }],
642
+ ["path", { d: "M7 6h1v4" }],
643
+ ["path", { d: "m16.71 13.88.7.71-2.82 2.82" }]
644
+ ],
645
+ trophy: [
646
+ ["path", { d: "M6 9H4.5a2.5 2.5 0 0 1 0-5H6" }],
647
+ ["path", { d: "M18 9h1.5a2.5 2.5 0 0 0 0-5H18" }],
648
+ ["path", { d: "M4 22h16" }],
649
+ ["path", { d: "M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22" }],
650
+ ["path", { d: "M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22" }],
651
+ ["path", { d: "M18 2H6v7a6 6 0 0 0 12 0V2Z" }]
652
+ ],
653
+ timer: [
654
+ ["line", { x1: "10", x2: "14", y1: "2", y2: "2" }],
655
+ ["line", { x1: "12", x2: "15", y1: "14", y2: "11" }],
656
+ ["circle", { cx: "12", cy: "14", r: "8" }]
657
+ ],
658
+ "map-pin": [
659
+ ["path", { d: "M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0" }],
660
+ ["circle", { cx: "12", cy: "10", r: "3" }]
661
+ ],
662
+ user: [
663
+ ["path", { d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" }],
664
+ ["circle", { cx: "12", cy: "7", r: "4" }]
665
+ ],
666
+ "thumbs-up": [
667
+ ["path", { d: "M7 10v12" }],
668
+ ["path", { d: "M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z" }]
669
+ ],
670
+ "arrow-right": [
671
+ ["path", { d: "M5 12h14" }],
672
+ ["path", { d: "m12 5 7 7-7 7" }]
673
+ ],
674
+ "chevron-right": [["path", { d: "m9 18 6-6-6-6" }]],
675
+ plus: [
676
+ ["path", { d: "M5 12h14" }],
677
+ ["path", { d: "M12 5v14" }]
678
+ ],
679
+ store: [
680
+ ["path", { d: "m2 7 4.41-4.41A2 2 0 0 1 7.83 2h8.34a2 2 0 0 1 1.42.59L22 7" }],
681
+ ["path", { d: "M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8" }],
682
+ ["path", { d: "M15 22v-4a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2v4" }],
683
+ ["path", { d: "M2 7h20" }],
684
+ ["path", { d: "M22 7v3a2 2 0 0 1-2 2a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 16 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 12 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 8 12a2.7 2.7 0 0 1-1.59-.63.7.7 0 0 0-.82 0A2.7 2.7 0 0 1 4 12a2 2 0 0 1-2-2V7" }]
685
+ ],
686
+ rocket: [
687
+ ["path", { d: "M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z" }],
688
+ ["path", { d: "m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z" }],
689
+ ["path", { d: "M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0" }],
690
+ ["path", { d: "M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5" }]
691
+ ]
692
+ };
693
+ function escapeAttr(value) {
694
+ return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
672
695
  }
673
- const CAMPAIGN_SHEET_ID = "aegis-campaign-fonts";
674
- const SAFE_ID = /^[A-Za-z0-9_-]{1,128}$/;
675
- function registerCampaignFonts(campaigns, read2 = readRootVar) {
676
- const rules = [];
677
- for (const c of campaigns) {
678
- const id = typeof c.id === "string" ? c.id : "";
679
- if (!SAFE_ID.test(id)) continue;
680
- const decl = campaignFontVarsCss(campaignFontFamily(c), read2);
681
- if (decl) rules.push(`[data-campaign-id="${id}"]{${decl}}`);
682
- }
683
- const css = rules.join("\n");
684
- if (typeof document === "undefined") return css;
685
- let sheet = document.getElementById(CAMPAIGN_SHEET_ID);
686
- if (!css) {
687
- sheet == null ? void 0 : sheet.remove();
688
- return css;
696
+ const SVG_NS$1 = "http://www.w3.org/2000/svg";
697
+ function lucideSvgEl(name, opts = {}) {
698
+ const node = ICONS[name];
699
+ if (!node || typeof document === "undefined") return null;
700
+ const size = opts.size ?? 24;
701
+ const svg = document.createElementNS(SVG_NS$1, "svg");
702
+ svg.setAttribute("width", String(size));
703
+ svg.setAttribute("height", String(size));
704
+ svg.setAttribute("viewBox", "0 0 24 24");
705
+ svg.setAttribute("fill", "none");
706
+ svg.setAttribute("stroke", opts.color ?? "currentColor");
707
+ svg.setAttribute("stroke-width", String(opts.strokeWidth ?? 2));
708
+ svg.setAttribute("stroke-linecap", "round");
709
+ svg.setAttribute("stroke-linejoin", "round");
710
+ if (opts.className) svg.setAttribute("class", opts.className);
711
+ if (opts.ariaLabel) {
712
+ svg.setAttribute("role", "img");
713
+ svg.setAttribute("aria-label", opts.ariaLabel);
714
+ } else {
715
+ svg.setAttribute("aria-hidden", "true");
689
716
  }
690
- if (!sheet) {
691
- sheet = document.createElement("style");
692
- sheet.id = CAMPAIGN_SHEET_ID;
693
- document.head.appendChild(sheet);
717
+ for (const [tag, attrs] of node) {
718
+ const child = document.createElementNS(SVG_NS$1, tag);
719
+ for (const [k, v] of Object.entries(attrs)) child.setAttribute(k, String(v));
720
+ svg.appendChild(child);
694
721
  }
695
- sheet.textContent = css;
696
- return css;
722
+ return svg;
697
723
  }
698
- function applyCampaignFonts(campaigns, read2 = readRootVar) {
699
- var _a;
700
- const brand = ((_a = campaigns.find((c) => c.brand_typography)) == null ? void 0 : _a.brand_typography) ?? null;
701
- applyRootFonts(brand, read2);
702
- registerCampaignFonts(campaigns, read2);
724
+ function lucideSvg(name, opts = {}) {
725
+ const node = ICONS[name];
726
+ if (!node) return "";
727
+ const size = opts.size ?? 24;
728
+ const color = opts.color ?? "currentColor";
729
+ const strokeWidth = opts.strokeWidth ?? 2;
730
+ const a11y = opts.ariaLabel ? `role="img" aria-label="${escapeAttr(opts.ariaLabel)}"` : 'aria-hidden="true"';
731
+ const cls = opts.className ? ` class="${escapeAttr(opts.className)}"` : "";
732
+ const children = node.map(([tag, attrs]) => {
733
+ const attrStr = Object.entries(attrs).map(([k, v]) => `${k}="${escapeAttr(String(v))}"`).join(" ");
734
+ return `<${tag} ${attrStr}/>`;
735
+ }).join("");
736
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 24 24" fill="none" stroke="${escapeAttr(color)}" stroke-width="${strokeWidth}" stroke-linecap="round" stroke-linejoin="round"${cls} ${a11y}>${children}</svg>`;
703
737
  }
704
738
  const HERO_IMAGE_SIZES = "100vw";
705
739
  function cardImageSizes(kind, widthPx) {
@@ -1805,8 +1839,9 @@ function buildNpsElement(el2, ctx, fg, accent, muted) {
1805
1839
  wrap.appendChild(scale);
1806
1840
  return wrap;
1807
1841
  }
1808
- function buildProgressElement(el2, ctx, accent, muted, compact) {
1842
+ function buildProgressElement(el2, ctx, accent, muted, compact, onMeasuredDefault) {
1809
1843
  const { trackEvent, campaign, sanitizeColor } = ctx;
1844
+ const reportMeasured = compact ? compact.onMeasured : onMeasuredDefault;
1810
1845
  const goal = el2.goal_type || "cart_total";
1811
1846
  const moneyGoal = goal === "cart_total";
1812
1847
  const fill = el2.fill ? sanitizeColor(el2.fill) : accent;
@@ -1878,17 +1913,17 @@ function buildProgressElement(el2, ctx, accent, muted, compact) {
1878
1913
  let firedUnlock = false;
1879
1914
  let seenIncomplete = false;
1880
1915
  const update = () => {
1881
- var _a, _b, _c;
1916
+ var _a;
1882
1917
  const th = threshold();
1883
1918
  const cur = readCur();
1884
1919
  if (th <= 0 && el2.threshold_source === "free_delivery_setting") {
1885
1920
  wrap.style.display = "none";
1886
1921
  markProgress(shell, null, false);
1887
- (_a = compact == null ? void 0 : compact.onMeasured) == null ? void 0 : _a.call(compact, false);
1922
+ reportMeasured == null ? void 0 : reportMeasured(false);
1888
1923
  return;
1889
1924
  }
1890
1925
  wrap.style.display = "flex";
1891
- (_b = compact == null ? void 0 : compact.onMeasured) == null ? void 0 : _b.call(compact, true);
1926
+ reportMeasured == null ? void 0 : reportMeasured(true);
1892
1927
  const { pct, complete } = computeProgress({ threshold: th, current: cur });
1893
1928
  bar.style.width = `${pct}%`;
1894
1929
  markProgress(shell, pct, complete);
@@ -1910,7 +1945,7 @@ function buildProgressElement(el2, ctx, accent, muted, compact) {
1910
1945
  firedUnlock = true;
1911
1946
  if (seenIncomplete) {
1912
1947
  trackEvent(campaign.id, "clicked", { stepId: el2.id || "unlocked" });
1913
- if (el2.celebrate_on_complete !== false) (_c = ctx.playReaction) == null ? void 0 : _c.call(ctx, wrap, "celebrate");
1948
+ if (el2.celebrate_on_complete !== false) (_a = ctx.playReaction) == null ? void 0 : _a.call(ctx, wrap, "celebrate");
1914
1949
  }
1915
1950
  }
1916
1951
  } else {
@@ -2176,7 +2211,12 @@ function renderCardFromTemplate(card, opts) {
2176
2211
  break;
2177
2212
  }
2178
2213
  case "progress": {
2179
- container.appendChild(buildProgressElement(el2, ctx, brand, muted));
2214
+ const tileDisplay = tile.style.display;
2215
+ const onMeasured = (measured) => {
2216
+ tile.hidden = !measured;
2217
+ tile.style.display = measured ? tileDisplay : "none";
2218
+ };
2219
+ container.appendChild(buildProgressElement(el2, ctx, brand, muted, void 0, onMeasured));
2180
2220
  break;
2181
2221
  }
2182
2222
  case "countdown": {
@@ -2286,6 +2326,28 @@ function renderCardFromTemplate(card, opts) {
2286
2326
  }
2287
2327
  return tile;
2288
2328
  }
2329
+ const BRAND_ACCENT_VAR = "--aegis-brand-accent";
2330
+ const DEFAULT_BRAND_ACCENT = "#4169e1";
2331
+ const CONCRETE = /^(#[0-9a-fA-F]{3,6}|rgb\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*\)|rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*[\d.]+\s*\))$/;
2332
+ function brandAccentCss(fallback = DEFAULT_BRAND_ACCENT) {
2333
+ return `var(${BRAND_ACCENT_VAR}, ${fallback})`;
2334
+ }
2335
+ function readBrandAccent() {
2336
+ if (typeof document === "undefined" || typeof getComputedStyle !== "function") return null;
2337
+ const els = [document.documentElement, document.body].filter(Boolean);
2338
+ for (const el2 of els) {
2339
+ try {
2340
+ const v = getComputedStyle(el2).getPropertyValue(BRAND_ACCENT_VAR).trim();
2341
+ if (v && CONCRETE.test(v)) return v;
2342
+ } catch {
2343
+ }
2344
+ }
2345
+ return null;
2346
+ }
2347
+ function resolveAccent(explicit, sanitizeColor, fallback = DEFAULT_BRAND_ACCENT) {
2348
+ if (typeof explicit === "string" && explicit.trim()) return sanitizeColor(explicit.trim());
2349
+ return brandAccentCss(fallback);
2350
+ }
2289
2351
  const MAX_CARDS_RENDERED = 10;
2290
2352
  function renderCarouselCards(ctx) {
2291
2353
  const { campaign, trackEvent, sanitizeColor, log, addAnimationStyles } = ctx;
@@ -2302,12 +2364,13 @@ function renderCarouselCards(ctx) {
2302
2364
  addAnimationStyles();
2303
2365
  const bg = "#ffffff";
2304
2366
  const fg = "#0f172a";
2305
- const accent = sanitizeColor(campaign.background_color || "#4169e1");
2367
+ const accent = resolveAccent(campaign.background_color, sanitizeColor);
2306
2368
  const overlay = document.createElement("div");
2307
- overlay.className = "aegis-in-app-carousel-overlay";
2369
+ injectOverlayLayoutCss();
2370
+ overlay.className = "aegis-in-app-carousel-overlay aegis-bottom-panel";
2308
2371
  overlay.setAttribute("data-campaign-id", campaign.id);
2309
2372
  overlay.style.cssText = `
2310
- position: fixed; left: 0; right: 0; bottom: 0;
2373
+ position: fixed; left: 0; right: 0; bottom: ${bottomOffset(0)};
2311
2374
  z-index: 99999; padding: 12px 12px 20px;
2312
2375
  background: rgba(0,0,0,0.12); backdrop-filter: blur(8px);
2313
2376
  ${fontFamilyCss("body")}
@@ -2482,14 +2545,12 @@ function renderStickyBar(ctx) {
2482
2545
  } catch {
2483
2546
  }
2484
2547
  addAnimationStyles();
2485
- const bg = sanitizeColor(
2486
- ic.sticky_bg_color || campaign.background_color || "#4169e1"
2487
- );
2548
+ const bg = resolveAccent(ic.sticky_bg_color || campaign.background_color, sanitizeColor);
2488
2549
  const fg = sanitizeColor(campaign.text_color || "#ffffff");
2489
2550
  const bar = document.createElement("div");
2490
2551
  bar.className = "aegis-in-app-sticky-bar";
2491
2552
  bar.setAttribute("data-campaign-id", campaign.id);
2492
- const positionCss = position === "top" ? "top: 0; left: 0; right: 0; animation: aegisSlideDown 0.3s ease-out;" : "bottom: 0; left: 0; right: 0; animation: aegisSlideInFromBottom 0.3s ease-out;";
2553
+ const positionCss = position === "top" ? "top: 0; left: 0; right: 0; animation: aegisSlideDown 0.3s ease-out;" : `bottom: ${bottomOffset(0)}; left: 0; right: 0; animation: aegisSlideInFromBottom 0.3s ease-out;`;
2493
2554
  bar.style.cssText = `
2494
2555
  position: fixed; ${positionCss}
2495
2556
  background: ${bg}; color: ${fg};
@@ -2586,7 +2647,7 @@ function buildProgressBar(ctx, inline, compact = false) {
2586
2647
  padding: 10px 14px;
2587
2648
  ${fontFamilyCss("body")}
2588
2649
  ` : `
2589
- position: fixed; left: 12px; right: 12px; bottom: 12px;
2650
+ position: fixed; left: 12px; right: 12px; bottom: ${bottomOffset(12)};
2590
2651
  max-width: 540px; margin: 0 auto;
2591
2652
  background: ${bg}; color: ${fg}; border-radius: 12px;
2592
2653
  padding: 10px 14px; z-index: 999997;
@@ -3069,14 +3130,37 @@ function isProductCard(card) {
3069
3130
  return Boolean(m2.product_id || m2.sku);
3070
3131
  }
3071
3132
  function isProductRailCards(cards) {
3072
- return cards.length > 0 && cards.every(isProductCard);
3133
+ return cards.some(isProductCard);
3134
+ }
3135
+ function productRailOrder(cards) {
3136
+ const all = cards.map((card, index) => ({ card, index }));
3137
+ return [...all.filter((e) => isProductCard(e.card)), ...all.filter((e) => !isProductCard(e.card))];
3073
3138
  }
3074
3139
  function productRailAccent(ctx) {
3075
- return ctx.sanitizeColor(ctx.campaign.background_color || "#4169e1");
3140
+ return resolveAccent(ctx.campaign.background_color, ctx.sanitizeColor);
3141
+ }
3142
+ function clampOpt(v, lo, hi) {
3143
+ if (v === void 0 || v === null || v === "") return void 0;
3144
+ const n = Number(v);
3145
+ if (!Number.isFinite(n)) return void 0;
3146
+ return Math.max(lo, Math.min(hi, n));
3147
+ }
3148
+ function productRailStyle(ctx) {
3149
+ const ic = ctx.campaign.interactive_config || {};
3150
+ const tc = ctx.campaign.text_color;
3151
+ const wRaw = ic.heading_font_weight != null ? String(ic.heading_font_weight) : "";
3152
+ return {
3153
+ fg: typeof tc === "string" && tc.trim() ? ctx.sanitizeColor(tc.trim()) : "#0f172a",
3154
+ weight: ["400", "500", "600", "700", "800"].includes(wRaw) ? wRaw : "700",
3155
+ padX: clampOpt(ic.padding_x, 0, 32) ?? 0,
3156
+ padY: clampOpt(ic.padding_y, 0, 24) ?? 0,
3157
+ radius: clampOpt(ic.border_radius, 0, 24) ?? 0
3158
+ };
3076
3159
  }
3077
3160
  function renderProductRailSection(ctx, target, opts) {
3078
3161
  const { campaign } = ctx;
3079
- const fg = "#0f172a";
3162
+ const style = productRailStyle(ctx);
3163
+ const fg = style.fg;
3080
3164
  const accent = productRailAccent(ctx);
3081
3165
  const layout = opts.layout || "row";
3082
3166
  const section = document.createElement("section");
@@ -3086,12 +3170,14 @@ function renderProductRailSection(ctx, target, opts) {
3086
3170
  section.style.cssText = `
3087
3171
  ${fontFamilyCss("body")}
3088
3172
  color: ${fg};
3173
+ ${style.padX || style.padY ? `padding: ${style.padY}px ${style.padX}px;` : ""}
3174
+ ${style.radius ? `border-radius: ${style.radius}px;` : ""}
3089
3175
  `;
3090
3176
  if (opts.heading) {
3091
3177
  const title = document.createElement("h2");
3092
3178
  title.textContent = opts.heading;
3093
3179
  title.setAttribute("data-aegis-rail-heading", "");
3094
- title.style.cssText = "font-weight: 700; font-size: 16px; margin: 0 0 2px;";
3180
+ title.style.cssText = `font-weight: ${style.weight}; font-size: 16px; margin: 0 0 2px; color: ${fg};`;
3095
3181
  section.appendChild(title);
3096
3182
  }
3097
3183
  if (opts.subtitle) {
@@ -3110,12 +3196,13 @@ function renderProductRailSection(ctx, target, opts) {
3110
3196
  } else {
3111
3197
  strip.style.cssText = `
3112
3198
  display: flex; gap: 10px; overflow-x: auto;
3113
- scroll-snap-type: x proximity; padding: 10px 8px 18px; margin: -8px -8px -6px;
3199
+ scroll-snap-type: x proximity; padding: 2px 2px 12px; scroll-padding: 0 2px;
3114
3200
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
3115
3201
  `;
3116
3202
  strip.style.msOverflowStyle = "none";
3117
3203
  }
3118
- opts.cards.forEach((c, i) => {
3204
+ const order = opts.productsFirst ? productRailOrder(opts.cards) : opts.cards.map((card, index) => ({ card, index }));
3205
+ order.forEach(({ card: c, index: i }) => {
3119
3206
  const tile = renderCardFromTemplate(c, {
3120
3207
  template: opts.template,
3121
3208
  ctx,
@@ -3136,7 +3223,7 @@ function renderProductRailSection(ctx, target, opts) {
3136
3223
  arrow.innerHTML = "›";
3137
3224
  arrow.style.cssText = `
3138
3225
  position: absolute; top: 50%; right: 0; transform: translateY(-50%);
3139
- width: 30px; height: 30px; border-radius: 999px; border: 1px solid ${fg}1a;
3226
+ width: 30px; height: 30px; border-radius: 999px; border: 1px solid color-mix(in srgb, ${fg} 10%, transparent);
3140
3227
  background: #fff; color: ${fg}; font-size: 18px; line-height: 1; cursor: pointer;
3141
3228
  box-shadow: 0 2px 8px rgba(0,0,0,0.12); display: flex; align-items: center;
3142
3229
  justify-content: center; z-index: 2;
@@ -3175,7 +3262,7 @@ function renderProductRecommendation(ctx) {
3175
3262
  addAnimationStyles();
3176
3263
  const bg = "#ffffff";
3177
3264
  const fg = "#0f172a";
3178
- const accent = sanitizeColor(campaign.background_color || "#4169e1");
3265
+ const accent = resolveAccent(campaign.background_color, sanitizeColor);
3179
3266
  const overlay = document.createElement("div");
3180
3267
  overlay.className = "aegis-in-app-product-rec";
3181
3268
  overlay.setAttribute("data-campaign-id", campaign.id);
@@ -4737,8 +4824,9 @@ function renderVideoInline(ctx, target) {
4737
4824
  return true;
4738
4825
  }
4739
4826
  const HEX = /^#[0-9a-fA-F]{3,8}$/;
4740
- function safeColor(c, fallback) {
4741
- return c && HEX.test(c) ? c : fallback;
4827
+ const RADIUS_PX = { none: 0, lg: 8, xl: 12, "2xl": 16 };
4828
+ function heroRadiusPx(radius) {
4829
+ return radius !== void 0 && Object.prototype.hasOwnProperty.call(RADIUS_PX, radius) ? RADIUS_PX[radius] : void 0;
4742
4830
  }
4743
4831
  const ASPECT = { "16:9": "16 / 9", "4:3": "4 / 3", "21:9": "21 / 9" };
4744
4832
  const HERO_DESKTOP_RATIO = "8 / 3";
@@ -4756,7 +4844,7 @@ function _injectHeroResponsiveCss() {
4756
4844
  if (document.getElementById("aegis-hero-style")) return;
4757
4845
  const style = document.createElement("style");
4758
4846
  style.id = "aegis-hero-style";
4759
- style.textContent = `.aegis-hero-root{border-radius:16px;}.aegis-hero-auto{min-height:300px;}@media (max-width:${HERO_PHONE_MAX_WIDTH_PX}px){.aegis-hero-auto.aegis-hero-phone-square{min-height:0;aspect-ratio:${HERO_PHONE_RATIO};}}@media (min-width:${HERO_PHONE_MAX_WIDTH_PX + 1}px){.aegis-hero-root{border-radius:0;min-height:0;max-height:70vh;aspect-ratio:${HERO_DESKTOP_RATIO} !important;}}`;
4847
+ style.textContent = `.aegis-hero-root{border-radius:var(--aegis-hero-radius,16px);}.aegis-hero-auto{min-height:300px;}@media (max-width:${HERO_PHONE_MAX_WIDTH_PX}px){.aegis-hero-auto.aegis-hero-phone-square{min-height:0;aspect-ratio:${HERO_PHONE_RATIO};}}@media (min-width:${HERO_PHONE_MAX_WIDTH_PX + 1}px){.aegis-hero-root{border-radius:0;min-height:0;max-height:70vh;aspect-ratio:${HERO_DESKTOP_RATIO} !important;}}`;
4760
4848
  document.head.appendChild(style);
4761
4849
  }
4762
4850
  function srcsetUrl$1(url) {
@@ -4787,38 +4875,103 @@ function cardUrl(c) {
4787
4875
  if (t && t.value) return t.type === "category" ? `?category=${encodeURIComponent(t.value)}` : t.value;
4788
4876
  return "";
4789
4877
  }
4878
+ function announcementContent(campaign, card) {
4879
+ const ic = campaign.interactive_config || {};
4880
+ const head = card ? cardHeadline(card) : campaign.title || "";
4881
+ const sub = card ? cardSub(card) : campaign.body || "";
4882
+ const text = [head, sub].filter(Boolean).join(" · ");
4883
+ const coupon = typeof ic.coupon_code === "string" ? ic.coupon_code.trim() : "";
4884
+ const ctaUrl = (card ? cardUrl(card) : "") || campaign.action_url || "";
4885
+ const ctaText = (card ? cardCta(card) : "") || campaign.button_text || (ctaUrl ? "Order now" : "");
4886
+ if (!text && !coupon && !ctaText) return null;
4887
+ return { text, coupon, ctaText, ctaUrl };
4888
+ }
4889
+ function _injectAnnouncementCss() {
4890
+ if (typeof document === "undefined" || !document.head) return;
4891
+ if (document.getElementById("aegis-announcement-style")) return;
4892
+ const style = document.createElement("style");
4893
+ style.id = "aegis-announcement-style";
4894
+ style.textContent = `@media (min-width:${HERO_PHONE_MAX_WIDTH_PX + 1}px){.aegis-announcement-bar{flex-wrap:nowrap !important;}.aegis-announcement-text{flex:1 1 auto;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}.aegis-announcement-coupon,.aegis-announcement-cta{flex:none;}}`;
4895
+ document.head.appendChild(style);
4896
+ }
4897
+ function renderAnnouncementBar(ctx, card, accent) {
4898
+ const { campaign, sanitizeUrl: sanitizeUrl2, trackEvent } = ctx;
4899
+ const content = announcementContent(campaign, card);
4900
+ if (!content) return null;
4901
+ _injectAnnouncementCss();
4902
+ const bar = document.createElement("div");
4903
+ bar.className = "aegis-announcement-bar";
4904
+ bar.setAttribute("data-campaign-id", campaign.id);
4905
+ bar.style.cssText = `display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-start;column-gap:10px;row-gap:4px;min-height:34px;box-sizing:border-box;background:${accent};color:#fff;padding:7px 16px;font-weight:600;font-size:13px;line-height:1.35;${fontFamilyCss("body")}text-align:left;`;
4906
+ if (content.text) {
4907
+ const t = document.createElement("span");
4908
+ t.className = "aegis-announcement-text";
4909
+ t.setAttribute("data-aegis-announcement-text", "");
4910
+ t.style.cssText = "min-width:0;overflow-wrap:anywhere;";
4911
+ t.textContent = content.text;
4912
+ bar.appendChild(t);
4913
+ }
4914
+ if (content.coupon) {
4915
+ const chip = document.createElement("button");
4916
+ chip.type = "button";
4917
+ chip.className = "aegis-announcement-coupon";
4918
+ chip.setAttribute("data-aegis-announcement-coupon", "");
4919
+ chip.setAttribute("aria-label", `Copy code ${content.coupon}`);
4920
+ chip.style.cssText = "border:1px dashed rgba(255,255,255,0.75);background:rgba(255,255,255,0.14);color:inherit;border-radius:6px;padding:1px 8px;font:inherit;font-family:ui-monospace,monospace;font-size:12px;letter-spacing:0.04em;cursor:pointer;white-space:nowrap;";
4921
+ chip.textContent = content.coupon;
4922
+ chip.addEventListener("click", (e) => {
4923
+ var _a;
4924
+ e.stopPropagation();
4925
+ try {
4926
+ void ((_a = navigator.clipboard) == null ? void 0 : _a.writeText(content.coupon));
4927
+ chip.textContent = "Copied";
4928
+ } catch {
4929
+ }
4930
+ setTimeout(() => {
4931
+ chip.textContent = content.coupon;
4932
+ }, 1500);
4933
+ });
4934
+ bar.appendChild(chip);
4935
+ }
4936
+ const url = content.ctaUrl ? sanitizeUrl2(content.ctaUrl) : "";
4937
+ if (url && content.ctaText) {
4938
+ const a = document.createElement("a");
4939
+ a.className = "aegis-announcement-cta";
4940
+ a.setAttribute("data-aegis-announcement-cta", "");
4941
+ a.href = url;
4942
+ a.style.cssText = "color:inherit;text-decoration:underline;text-underline-offset:2px;cursor:pointer;white-space:nowrap;font-weight:700;";
4943
+ a.textContent = `${content.ctaText} ›`;
4944
+ a.addEventListener("click", (e) => {
4945
+ e.preventDefault();
4946
+ trackEvent(campaign.id, "clicked");
4947
+ if (ctx.navigate) ctx.navigate(url);
4948
+ else if (typeof window !== "undefined") window.location.assign(url);
4949
+ });
4950
+ bar.appendChild(a);
4951
+ }
4952
+ return bar;
4953
+ }
4954
+ function heroAccent(chrome, backgroundColor) {
4955
+ if (chrome.accent && chrome.accent !== "brand" && HEX.test(chrome.accent)) return chrome.accent;
4956
+ if (backgroundColor && HEX.test(backgroundColor)) return backgroundColor;
4957
+ return brandAccentCss();
4958
+ }
4790
4959
  function renderHeroInline(ctx, target) {
4791
4960
  const { campaign, sanitizeUrl: sanitizeUrl2, trackEvent } = ctx;
4792
4961
  const ic = campaign.interactive_config || {};
4793
4962
  const cards = Array.isArray(ic.cards) ? ic.cards : [];
4794
- if (cards.length === 0) return false;
4795
4963
  const chrome = ic.chrome || {};
4796
- const accent = safeColor(
4797
- chrome.accent && chrome.accent !== "brand" ? chrome.accent : campaign.background_color,
4798
- "#4169e1"
4799
- );
4800
- const variant = chrome.variant ?? "hero_fullbleed";
4964
+ const accent = heroAccent(chrome, campaign.background_color);
4965
+ const isAnnouncement = campaign.widget_category === "announcement";
4966
+ const variant = chrome.variant ?? (isAnnouncement ? "announcement_bar" : "hero_fullbleed");
4801
4967
  if (variant === "announcement_bar") {
4802
- const c = cards[0];
4803
- const bar = document.createElement("div");
4804
- bar.style.cssText = `display:flex;align-items:center;justify-content:center;gap:10px;background:${accent};color:#fff;padding:8px 14px;font-weight:600;font-size:13px;line-height:1.3;${fontFamilyCss("body")}text-align:center;`;
4805
- bar.textContent = [cardHeadline(c), cardSub(c)].filter(Boolean).join(" · ");
4806
- const url = sanitizeUrl2(cardUrl(c));
4807
- if (url && cardCta(c)) {
4808
- const a = document.createElement("span");
4809
- a.style.cssText = "text-decoration:underline;cursor:pointer;white-space:nowrap;";
4810
- a.textContent = cardCta(c);
4811
- a.addEventListener("click", () => {
4812
- var _a;
4813
- trackEvent(campaign.id, "clicked");
4814
- (_a = ctx.navigate) == null ? void 0 : _a.call(ctx, url);
4815
- });
4816
- bar.appendChild(a);
4817
- }
4968
+ const bar = renderAnnouncementBar(ctx, cards[0] ?? null, accent);
4969
+ if (!bar) return false;
4818
4970
  target.appendChild(bar);
4819
4971
  trackEvent(campaign.id, "impression");
4820
4972
  return true;
4821
4973
  }
4974
+ if (cards.length === 0) return false;
4822
4975
  _injectHeroResponsiveCss();
4823
4976
  const explicitRatio = chrome.aspect_ratio ? ASPECT[chrome.aspect_ratio] : void 0;
4824
4977
  const hasPhoneImage = cards.some(
@@ -4826,7 +4979,8 @@ function renderHeroInline(ctx, target) {
4826
4979
  );
4827
4980
  const root = document.createElement("div");
4828
4981
  root.className = explicitRatio ? "aegis-hero-root" : `aegis-hero-root aegis-hero-auto${hasPhoneImage ? " aegis-hero-phone-square" : ""}`;
4829
- root.style.cssText = `position:relative;width:100%;overflow:hidden;box-shadow:0 1px 2px rgba(16,24,40,0.06);${explicitRatio ? `aspect-ratio:${explicitRatio};` : ""}`;
4982
+ const radiusPx = heroRadiusPx(chrome.radius);
4983
+ root.style.cssText = `position:relative;width:100%;overflow:hidden;box-shadow:0 1px 2px rgba(16,24,40,0.06);${explicitRatio ? `aspect-ratio:${explicitRatio};` : ""}${radiusPx !== void 0 ? `--aegis-hero-radius:${radiusPx}px;` : ""}`;
4830
4984
  root.setAttribute("data-campaign-id", campaign.id);
4831
4985
  const track = document.createElement("div");
4832
4986
  track.style.cssText = "display:flex;height:100%;width:100%;transition:transform 0.5s ease;";
@@ -7772,12 +7926,17 @@ function renderReviewsInline(ctx, target, creds) {
7772
7926
  }
7773
7927
  function renderReviewsOverlay(ctx, creds) {
7774
7928
  if (typeof document === "undefined" || !(creds == null ? void 0 : creds.apiHost) || !(creds == null ? void 0 : creds.writeKey)) return;
7929
+ injectOverlayLayoutCss();
7775
7930
  const overlay = document.createElement("div");
7931
+ overlay.className = "aegis-sheet-overlay";
7776
7932
  overlay.setAttribute("data-campaign-id", ctx.campaign.id);
7777
7933
  overlay.style.cssText = "position:fixed;inset:0;background:rgba(17,24,39,0.5);display:flex;align-items:flex-end;justify-content:center;z-index:99999;";
7778
7934
  const sheet = document.createElement("div");
7935
+ sheet.className = "aegis-sheet";
7779
7936
  sheet.style.cssText = `background:#fff;color:#111827;max-width:680px;width:100%;max-height:84vh;overflow-y:auto;border-radius:24px 24px 0 0;padding:18px 18px 28px;${fontFamilyCss("body")}box-shadow:0 -16px 40px rgba(0,0,0,0.14);`;
7780
- sheet.appendChild(el("div", "width:38px;height:4px;border-radius:999px;background:#e5e7eb;margin:0 auto 14px;"));
7937
+ const grabber = el("div", "width:38px;height:4px;border-radius:999px;background:#e5e7eb;margin:0 auto 14px;");
7938
+ grabber.className = "aegis-sheet-grabber";
7939
+ sheet.appendChild(grabber);
7781
7940
  const bar = el("div", "display:flex;justify-content:space-between;align-items:center;margin-bottom:10px;");
7782
7941
  bar.appendChild(el("div", "font-weight:800;font-size:17px;", ctx.campaign.title || "Customer reviews"));
7783
7942
  const close = el("button", "background:none;border:none;cursor:pointer;padding:4px 8px;color:#6b7280;");
@@ -8165,6 +8324,21 @@ function pickSlotWinners(campaigns, opts = {}) {
8165
8324
  });
8166
8325
  return out;
8167
8326
  }
8327
+ function slotKind(c) {
8328
+ const sub = typeof c.sub_type === "string" ? c.sub_type.trim() : "";
8329
+ if (sub && sub !== "standard") return sub;
8330
+ return typeof c.type === "string" ? c.type : "";
8331
+ }
8332
+ function stepsAsFormFields(ic, title) {
8333
+ const raw = Array.isArray(ic.steps) ? ic.steps : [];
8334
+ const steps = raw.length > 0 ? raw : [{ question: title || "Tell us more", options: [] }];
8335
+ return steps.map((step, i) => {
8336
+ const key = typeof step.key === "string" && step.key ? step.key : `step_${i + 1}`;
8337
+ const label = typeof step.question === "string" && step.question || typeof step.label === "string" && step.label || `Step ${i + 1}`;
8338
+ const options = Array.isArray(step.options) ? step.options.filter((o) => typeof o === "string" && o !== "") : [];
8339
+ return options.length > 0 ? { key, label, type: "select", options, required: step.required === true } : { key, label, type: "text", required: step.required === true };
8340
+ });
8341
+ }
8168
8342
  const SECTION_SPOT_SELECTOR_PREFIX = "[data-aegis-section-spot=";
8169
8343
  function isSectionSpotSelector(selector) {
8170
8344
  return typeof selector === "string" && selector.trim().startsWith(SECTION_SPOT_SELECTOR_PREFIX);
@@ -8495,54 +8669,6 @@ function drawSlotShells(ctx, doc = document) {
8495
8669
  });
8496
8670
  return drawn;
8497
8671
  }
8498
- const RETURNING_MARKER_KEY = "aegis_returning_user";
8499
- const SESSION_VERDICT_KEY = "aegis_new_visitor_session";
8500
- let cachedVerdict = null;
8501
- function readSessionVerdict() {
8502
- try {
8503
- if (typeof sessionStorage === "undefined") return null;
8504
- const stored = sessionStorage.getItem(SESSION_VERDICT_KEY);
8505
- if (stored === "1") return true;
8506
- if (stored === "0") return false;
8507
- return null;
8508
- } catch {
8509
- return null;
8510
- }
8511
- }
8512
- function writeSessionVerdict(verdict) {
8513
- try {
8514
- if (typeof sessionStorage === "undefined") return;
8515
- sessionStorage.setItem(SESSION_VERDICT_KEY, verdict ? "1" : "0");
8516
- } catch {
8517
- }
8518
- }
8519
- function readMarkerVerdict() {
8520
- try {
8521
- if (typeof localStorage === "undefined") return false;
8522
- return localStorage.getItem(RETURNING_MARKER_KEY) === null;
8523
- } catch {
8524
- return false;
8525
- }
8526
- }
8527
- function isNewVisitor() {
8528
- if (cachedVerdict !== null) return cachedVerdict;
8529
- const sessionVerdict = readSessionVerdict();
8530
- if (sessionVerdict !== null) {
8531
- cachedVerdict = sessionVerdict;
8532
- return cachedVerdict;
8533
- }
8534
- cachedVerdict = readMarkerVerdict();
8535
- writeSessionVerdict(cachedVerdict);
8536
- return cachedVerdict;
8537
- }
8538
- function markReturningVisitor() {
8539
- isNewVisitor();
8540
- try {
8541
- if (typeof localStorage === "undefined") return;
8542
- localStorage.setItem(RETURNING_MARKER_KEY, "1");
8543
- } catch {
8544
- }
8545
- }
8546
8672
  const DEFAULT_SCROLL_DEPTH_PERCENT = 50;
8547
8673
  const DEFAULT_TIME_ON_PAGE_SECONDS = 30;
8548
8674
  const DEFAULT_IDLE_SECONDS = 30;
@@ -8607,27 +8733,6 @@ function armBehaviouralTriggers(engine, triggers, armed, fire, isMobile) {
8607
8733
  }
8608
8734
  return newlyArmed;
8609
8735
  }
8610
- const SDK_FETCH_ABORT_MS = 800;
8611
- function fetchWithAbort(input, init = {}, timeoutMs = SDK_FETCH_ABORT_MS) {
8612
- const budget = Math.min(timeoutMs, SDK_FETCH_ABORT_MS);
8613
- if (typeof AbortController === "undefined") {
8614
- return fetch(input, init);
8615
- }
8616
- const controller = new AbortController();
8617
- const outer = init.signal;
8618
- if (outer) {
8619
- if (outer.aborted) controller.abort();
8620
- else outer.addEventListener("abort", () => controller.abort(), { once: true });
8621
- }
8622
- const timer = setTimeout(() => controller.abort(), budget);
8623
- return fetch(input, { ...init, signal: controller.signal }).catch((err) => {
8624
- clearTimeout(timer);
8625
- throw err;
8626
- });
8627
- }
8628
- function isAbortError(err) {
8629
- return !!err && typeof err === "object" && (err.name === "AbortError" || err.name === "TimeoutError");
8630
- }
8631
8736
  const LAST_GOOD_PREFIX = "aegis_rail_lastgood:v1:";
8632
8737
  const LAST_GOOD_SPECIFIC_PREFIX = "aegis_rail_lastgood_specific:v1:";
8633
8738
  const POPULAR_PREFIX = "aegis_rail_popular:v1:";
@@ -8766,15 +8871,6 @@ function readRailFallback(ctx, now = Date.now(), audience = {}) {
8766
8871
  if (popular.length > 0) return { tier: "popular", campaigns: popular };
8767
8872
  return { tier: "hidden", campaigns: [] };
8768
8873
  }
8769
- function readAnonIdFromStorage$1() {
8770
- if (typeof document === "undefined") return void 0;
8771
- try {
8772
- const storage = new Storage();
8773
- return storage.get("anon_id") ?? void 0;
8774
- } catch {
8775
- return void 0;
8776
- }
8777
- }
8778
8874
  function readAdClickIdsFromStorage() {
8779
8875
  const out = {};
8780
8876
  if (typeof document === "undefined") return out;
@@ -8889,6 +8985,8 @@ const _AegisInAppManager = class _AegisInAppManager {
8889
8985
  this.pendingAnchorRender = false;
8890
8986
  this.slotsTornDown = false;
8891
8987
  this.campaignsLoaded = false;
8988
+ this.activeETag = null;
8989
+ this.activeETagKey = void 0;
8892
8990
  this.shellTimeout = null;
8893
8991
  this.lifecycleGen = 0;
8894
8992
  this.slotUnfilledBeaconed = /* @__PURE__ */ new Set();
@@ -9149,8 +9247,25 @@ const _AegisInAppManager = class _AegisInAppManager {
9149
9247
  }
9150
9248
  /** The page context a `/v1/in-app/active` request is built from now. */
9151
9249
  activeRequestKey() {
9152
- const url = this.currentPageUrl() ?? "/";
9153
- return [url, this.currentSurface ?? "", this.currentScreen ?? "", this.currentLocationId ?? "", this.cartKeyPart()].join("|");
9250
+ return activeRequestKey(this.requestContext());
9251
+ }
9252
+ /** Everything the shared /active builder needs (inapp/active-request.ts):
9253
+ * the ONE place this manager's request is described. */
9254
+ requestContext() {
9255
+ return {
9256
+ apiHost: this.apiHost,
9257
+ writeKey: this.writeKey,
9258
+ userId: this.userId,
9259
+ contactId: this.contactId,
9260
+ contactToken: this.contactToken,
9261
+ organizationId: this.organizationId,
9262
+ propertyId: this.propertyId,
9263
+ surface: this.currentSurface,
9264
+ screen: this.currentScreen,
9265
+ locationId: this.currentLocationId,
9266
+ cartProductIds: this.currentCartProductIds,
9267
+ previewOnly: this.previewOnly
9268
+ };
9154
9269
  }
9155
9270
  /** The cart ids as a request-key part: sorted + deduped so a reorder is not a
9156
9271
  * change; `-` = no cart known, distinct from `` = an empty cart. */
@@ -9173,7 +9288,7 @@ const _AegisInAppManager = class _AegisInAppManager {
9173
9288
  return out;
9174
9289
  }
9175
9290
  cartKeyPartOf(ids) {
9176
- return ids === null ? "-" : [...ids].sort().join(",");
9291
+ return cartKeyPartOf(ids);
9177
9292
  }
9178
9293
  /**
9179
9294
  * Qualifying-event refresh — schedule a debounced `refreshCampaigns()`
@@ -9496,75 +9611,57 @@ const _AegisInAppManager = class _AegisInAppManager {
9496
9611
  }
9497
9612
  }, delay);
9498
9613
  }
9499
- async refreshCampaigns() {
9614
+ refreshCampaigns() {
9615
+ const key = this.activeRequestKey();
9616
+ if (this.inflightActive && this.inflightActive.key === key) {
9617
+ this.log("refreshCampaigns() — joining the in-flight /active for this page context");
9618
+ return this.inflightActive.promise;
9619
+ }
9620
+ const entry = { key, promise: Promise.resolve() };
9621
+ entry.promise = this.refreshCampaignsNow().finally(() => {
9622
+ if (this.inflightActive === entry) this.inflightActive = void 0;
9623
+ });
9624
+ this.inflightActive = entry;
9625
+ return entry.promise;
9626
+ }
9627
+ async refreshCampaignsNow() {
9500
9628
  const gen = this.lifecycleGen;
9501
9629
  let requestKey;
9502
9630
  try {
9503
- const context = new URLSearchParams({
9504
- device_type: this.detectDeviceType(),
9505
- // Credential params keep their key and lose their value, so a
9506
- // `*placed=1*` / `*?step=cart*` rule still matches.
9507
- page_url: typeof window !== "undefined" ? redactUrl(window.location.pathname + window.location.search) : "/"
9508
- });
9509
- context.set("is_new_user", isNewVisitor() ? "true" : "false");
9510
- if (this.currentSurface) {
9511
- context.set("current_surface", this.currentSurface);
9512
- }
9513
- if (this.currentScreen) {
9514
- context.set("current_screen", this.currentScreen);
9515
- }
9516
- if (this.currentLocationId) {
9517
- context.set("location_id", this.currentLocationId);
9518
- }
9519
- if (this.currentCartProductIds !== null) {
9520
- context.set("cart_product_ids", this.currentCartProductIds.join(","));
9521
- }
9522
- const previewAsOf = previewAsOfToken();
9523
- if (previewAsOf) {
9524
- context.set("preview_as_of", previewAsOf);
9525
- }
9526
- if (this.previewOnly) {
9527
- context.set("preview", "1");
9528
- }
9529
- const url = `${this.apiHost}/v1/in-app/active?${context.toString()}`;
9530
- requestKey = this.activeRequestKey();
9631
+ const req = buildActiveRequest(this.requestContext());
9632
+ const url = req.url;
9633
+ requestKey = req.key;
9531
9634
  this.lastActiveRequestKey = requestKey;
9532
9635
  const shellCtx = this.shellContext();
9533
9636
  const railAudience = this.railAudience();
9534
- const headers = {
9535
- "X-Aegis-Write-Key": this.writeKey,
9536
- "Content-Type": "application/json"
9537
- };
9538
- if (this.userId) {
9539
- headers["X-User-ID"] = this.userId;
9540
- }
9541
- if (this.contactId) {
9542
- headers["X-Contact-ID"] = this.contactId;
9543
- }
9544
- if (this.contactId && this.contactToken) {
9545
- headers["X-Contact-Token"] = this.contactToken;
9546
- }
9547
- if (this.organizationId) {
9548
- headers["X-Organization-ID"] = this.organizationId;
9549
- }
9550
- if (this.propertyId) {
9551
- headers["X-Property-Id"] = this.propertyId;
9552
- }
9553
- const abAssignments = this.getABAssignments();
9554
- if (Object.keys(abAssignments).length > 0) {
9555
- headers["X-AB-Assignments"] = btoa(JSON.stringify(abAssignments));
9556
- }
9557
- const response = await fetchWithAbort(url, {
9637
+ const conditional = this.campaignsLoaded && this.activeETag !== null && this.activeETagKey === requestKey;
9638
+ if (conditional && this.activeETag) {
9639
+ req.headers["If-None-Match"] = this.activeETag;
9640
+ }
9641
+ const boot = takeActiveBoot(req);
9642
+ const adopted = this.campaignsLoaded ? null : boot;
9643
+ if (adopted) this.log("Adopting the early-boot /active read for this page");
9644
+ const fetchActive = this.campaignsLoaded ? fetchWithAbort : fetchWithAbortRetry;
9645
+ const response = adopted ? await adopted : await fetchActive(url, {
9558
9646
  method: "GET",
9559
- headers,
9647
+ headers: req.headers,
9560
9648
  credentials: "include"
9561
9649
  });
9562
9650
  if (gen !== this.lifecycleGen) return;
9563
- if (!response.ok) {
9564
- throw new Error(`Failed to fetch campaigns: ${response.status}`);
9651
+ let payload;
9652
+ if (response.status === 304 && conditional) {
9653
+ this.log("Active campaigns unchanged (304)");
9654
+ payload = this.campaigns;
9655
+ } else {
9656
+ if (!response.ok) {
9657
+ throw new Error(`Failed to fetch campaigns: ${response.status}`);
9658
+ }
9659
+ payload = await response.json();
9660
+ if (gen !== this.lifecycleGen) return;
9661
+ const tag = response.headers && typeof response.headers.get === "function" ? response.headers.get("ETag") : null;
9662
+ this.activeETag = tag;
9663
+ this.activeETagKey = tag ? requestKey : void 0;
9565
9664
  }
9566
- const payload = await response.json();
9567
- if (gen !== this.lifecycleGen) return;
9568
9665
  this.campaigns = Array.isArray(payload) ? payload : [];
9569
9666
  this.campaignsLoaded = true;
9570
9667
  this.railFallbackTier = null;
@@ -9617,22 +9714,13 @@ const _AegisInAppManager = class _AegisInAppManager {
9617
9714
  }
9618
9715
  // --- Client Context Helpers (Critical Fix B) ---
9619
9716
  detectDeviceType() {
9620
- if (typeof navigator === "undefined") return "desktop";
9621
- const ua = navigator.userAgent;
9622
- if (/Mobi|Android/i.test(ua)) return "mobile";
9623
- if (/iPad|Tablet/i.test(ua)) return "tablet";
9624
- return "desktop";
9717
+ return detectDeviceType();
9625
9718
  }
9626
9719
  // --- A/B Assignment Persistence (Critical Fix C) ---
9627
9720
  // Both A/B helpers sit on the campaign-fetch path, so blocked storage
9628
9721
  // (where even `typeof localStorage` throws) must not abort the fetch.
9629
9722
  getABAssignments() {
9630
- try {
9631
- if (typeof localStorage === "undefined") return {};
9632
- return JSON.parse(localStorage.getItem("aegis_ab_assignments") || "{}");
9633
- } catch {
9634
- return {};
9635
- }
9723
+ return readABAssignments();
9636
9724
  }
9637
9725
  processABAssignments(campaigns) {
9638
9726
  const stored = this.getABAssignments();
@@ -9762,8 +9850,7 @@ const _AegisInAppManager = class _AegisInAppManager {
9762
9850
  * as `page_url` (pathname + search, credential values redacted). Null off
9763
9851
  * the browser — no page, no filter (the server's rule too). */
9764
9852
  currentPageUrl() {
9765
- if (typeof window === "undefined" || !window.location) return null;
9766
- return redactUrl((window.location.pathname || "") + (window.location.search || ""));
9853
+ return currentPageUrl();
9767
9854
  }
9768
9855
  /** The full client placement gate: screen/surface tier AND page rules, both
9769
9856
  * mirroring `/v1/in-app/active`, applied to CACHED campaigns (the page may
@@ -10400,16 +10487,17 @@ const _AegisInAppManager = class _AegisInAppManager {
10400
10487
  return;
10401
10488
  }
10402
10489
  this._ensureSurveyTemplate(campaign);
10403
- const _isMultiCard = campaign.sub_type === "product_recommendation" || campaign.sub_type === "carousel_cards";
10404
- if (this._hasComposedTemplate(ic) && !_isMultiCard) {
10405
- rendered = this.renderComposedCardSlot(campaign, ic, target);
10406
- } else if (campaign.widget_category === "hero") {
10490
+ const kind = slotKind(campaign);
10491
+ const _isMultiCard = kind === "product_recommendation" || kind === "carousel_cards";
10492
+ if (campaign.widget_category === "hero" || campaign.widget_category === "announcement") {
10407
10493
  const heroCtx = this.buildRenderContext(campaign);
10408
10494
  const heroSlot = target.closest("[data-aegis-slot]");
10409
10495
  heroCtx.shellImage = heroSlot ? this.shellHeroImages.get(heroSlot) ?? null : null;
10410
10496
  rendered = renderHeroInline(heroCtx, target);
10497
+ } else if (this._hasComposedTemplate(ic) && !_isMultiCard) {
10498
+ rendered = this.renderComposedCardSlot(campaign, ic, target);
10411
10499
  } else
10412
- switch (campaign.sub_type) {
10500
+ switch (kind) {
10413
10501
  // P6.full — star_rating / nps_survey / quick_poll slots route through the
10414
10502
  // unified composed-card slot engine via `_ensureSurveyTemplate` (the gate
10415
10503
  // above), so the bespoke *Slot survey renderers are RETIRED.
@@ -10448,16 +10536,20 @@ const _AegisInAppManager = class _AegisInAppManager {
10448
10536
  writeKey: this.writeKey
10449
10537
  });
10450
10538
  break;
10539
+ case "multi_step_form": {
10540
+ const stepFields = stepsAsFormFields(ic, campaign.title);
10541
+ rendered = this.renderFormSlot(campaign, stepFields, bg, text, target);
10542
+ break;
10543
+ }
10451
10544
  case "quiz":
10452
10545
  rendered = this.renderQuizSlot(campaign, ic, bg, text, target);
10453
10546
  if (!rendered) {
10454
10547
  rendered = this.renderGenericCardSlot(campaign, ic, bg, text, target);
10455
10548
  }
10456
10549
  break;
10457
- // Remaining sub_types (sticky_bar, progress_bar,
10458
- // product_recommendation) render as a generic card on the bill slot
10459
- // (overlay path handles their full UX); dedicated slot variants get added
10460
- // here as merchants need them.
10550
+ // Remaining kinds (sticky_bar, pip, banner, modal, ...) render as a
10551
+ // generic card in a slot (the overlay path handles their full UX);
10552
+ // dedicated slot variants get added here as merchants need them.
10461
10553
  default:
10462
10554
  rendered = this.renderGenericCardSlot(campaign, ic, bg, text, target);
10463
10555
  break;
@@ -10576,7 +10668,9 @@ const _AegisInAppManager = class _AegisInAppManager {
10576
10668
  template,
10577
10669
  ctx,
10578
10670
  action: "navigate",
10579
- layoutAccent: this.sanitizeColor(campaign.background_color || accent)
10671
+ // The palette accent may be the brand var expression: never pass it
10672
+ // through sanitizeColor (which turns var() into #000000).
10673
+ layoutAccent: campaign.background_color ? this.sanitizeColor(campaign.background_color) : accent
10580
10674
  });
10581
10675
  target.appendChild(tile);
10582
10676
  return true;
@@ -10616,7 +10710,9 @@ const _AegisInAppManager = class _AegisInAppManager {
10616
10710
  template,
10617
10711
  ctx: this.buildRenderContext(campaign),
10618
10712
  action: "navigate",
10619
- layoutAccent: this.sanitizeColor(campaign.background_color || accent)
10713
+ // The palette accent may be the brand var expression: never pass it
10714
+ // through sanitizeColor (which turns var() into #000000).
10715
+ layoutAccent: campaign.background_color ? this.sanitizeColor(campaign.background_color) : accent
10620
10716
  });
10621
10717
  modal.appendChild(tile);
10622
10718
  this._addCornerClose(modal, overlay, campaign.id, text);
@@ -10709,7 +10805,8 @@ const _AegisInAppManager = class _AegisInAppManager {
10709
10805
  if (buttonText) {
10710
10806
  const btn = document.createElement("button");
10711
10807
  btn.textContent = buttonText;
10712
- btn.style.cssText = `margin-top: 2px; align-self: flex-start; padding: 8px 14px; border-radius: ${st.btnRadius ?? 9}px; border: none; background: ${text}; color: ${bg}; font-size: 13px; font-weight: 600; cursor: pointer;`;
10808
+ const pal = this._surfacePalette(campaign);
10809
+ btn.style.cssText = `margin-top: 2px; align-self: flex-start; padding: 8px 14px; border-radius: ${st.btnRadius ?? 9}px; border: none; background: ${pal.btnBg}; color: ${pal.btnText}; font-size: 13px; font-weight: 600; cursor: pointer;`;
10713
10810
  btn.addEventListener("click", () => {
10714
10811
  void this.trackEvent(campaign.id, "clicked");
10715
10812
  if (actionUrl) window.open(actionUrl, "_blank", "noopener");
@@ -11694,7 +11791,8 @@ const _AegisInAppManager = class _AegisInAppManager {
11694
11791
  layout,
11695
11792
  template: resolveGlobalTemplate(ic),
11696
11793
  className: "aegis-in-app-carousel-rail",
11697
- actionFor: () => "cart"
11794
+ actionFor: (c) => isProductCard(c) ? "cart" : "navigate",
11795
+ productsFirst: true
11698
11796
  });
11699
11797
  this._carouselAutoplay(ic, layout, cards.length, strip2);
11700
11798
  return true;
@@ -12232,7 +12330,7 @@ const _AegisInAppManager = class _AegisInAppManager {
12232
12330
  */
12233
12331
  _slotStyle(campaign) {
12234
12332
  const ic = campaign.interactive_config || {};
12235
- const clampOpt = (v, lo, hi) => {
12333
+ const clampOpt2 = (v, lo, hi) => {
12236
12334
  if (v === void 0 || v === null || v === "") return void 0;
12237
12335
  const n = Number(v);
12238
12336
  if (!Number.isFinite(n)) return void 0;
@@ -12243,10 +12341,10 @@ const _AegisInAppManager = class _AegisInAppManager {
12243
12341
  return {
12244
12342
  bg: pal.bg,
12245
12343
  text: pal.text,
12246
- radius: clampOpt(ic.border_radius, 0, 24) ?? 12,
12247
- padX: clampOpt(ic.padding_x, 0, 32),
12248
- padY: clampOpt(ic.padding_y, 0, 24),
12249
- btnRadius: clampOpt(ic.button_radius, 0, 999),
12344
+ radius: clampOpt2(ic.border_radius, 0, 24) ?? 12,
12345
+ padX: clampOpt2(ic.padding_x, 0, 32),
12346
+ padY: clampOpt2(ic.padding_y, 0, 24),
12347
+ btnRadius: clampOpt2(ic.button_radius, 0, 999),
12250
12348
  weight: ["400", "500", "600", "700"].includes(wRaw) ? wRaw : void 0
12251
12349
  };
12252
12350
  }
@@ -12335,7 +12433,7 @@ const _AegisInAppManager = class _AegisInAppManager {
12335
12433
  this.log(`campaign ${campaign.id} not drawn: overlays held by the host`);
12336
12434
  return;
12337
12435
  }
12338
- const willShow = { target: "overlay" };
12436
+ const willShow = { target: "overlay", anchor: overlayAnchor(campaign) };
12339
12437
  const proceed = this.emit("campaign-will-show", campaign, willShow);
12340
12438
  if (!proceed) {
12341
12439
  this.log(`campaign ${campaign.id} suppressed by campaign-will-show handler`);
@@ -13594,7 +13692,10 @@ const _AegisInAppManager = class _AegisInAppManager {
13594
13692
  * fill when branded, CTA accent when clean. */
13595
13693
  _surfacePalette(campaign) {
13596
13694
  const ic = campaign.interactive_config || {};
13597
- const brand = this.sanitizeColor(campaign.background_color || "#4169e1");
13695
+ const explicit = campaign.background_color ? this.sanitizeColor(campaign.background_color) : "";
13696
+ const hostBrand = explicit ? "" : readBrandAccent() || "";
13697
+ const brand = explicit || hostBrand || brandAccentCss();
13698
+ const brandInk = explicit || hostBrand ? this._contrastText(explicit || hostBrand) : "#ffffff";
13598
13699
  const surface = ic.surface_style;
13599
13700
  if (surface === "branded") {
13600
13701
  const bg = brand;
@@ -13606,7 +13707,7 @@ const _AegisInAppManager = class _AegisInAppManager {
13606
13707
  const text = campaign.text_color ? this.sanitizeColor(campaign.text_color) : "#ffffff";
13607
13708
  return { bg, text, btnBg: "#ffffff", btnText: bg, accent: text, branded: false };
13608
13709
  }
13609
- return { bg: "#ffffff", text: "#0f172a", btnBg: brand, btnText: this._contrastText(brand), accent: brand, branded: false };
13710
+ return { bg: "#ffffff", text: "#0f172a", btnBg: brand, btnText: brandInk, accent: brand, branded: false };
13610
13711
  }
13611
13712
  inAppStyle(campaign) {
13612
13713
  const ic = campaign.interactive_config || {};
@@ -13642,7 +13743,7 @@ const _AegisInAppManager = class _AegisInAppManager {
13642
13743
  const atBottom = ic.banner_position === "bottom";
13643
13744
  banner.style.cssText = `
13644
13745
  position: fixed;
13645
- ${atBottom ? "bottom: 0;" : "top: 0;"}
13746
+ ${atBottom ? `bottom: ${bottomOffset(0)};` : "top: 0;"}
13646
13747
  left: 0;
13647
13748
  right: 0;
13648
13749
  background: ${st.bg};
@@ -14314,15 +14415,17 @@ const _AegisInAppManager = class _AegisInAppManager {
14314
14415
  // Corner → fixed-position CSS for the floating PiP card.
14315
14416
  _pipCornerCss(position, gap) {
14316
14417
  switch (position) {
14418
+ // Bottom corners sit above the host's dock / launcher / cart pill
14419
+ // (`--aegis-bottom-reserve`, overlay-layout.ts, 1.52.0).
14317
14420
  case "bottom-left":
14318
- return `bottom: ${gap}px; left: ${gap}px;`;
14421
+ return `bottom: ${bottomOffset(gap)}; left: ${gap}px;`;
14319
14422
  case "top-right":
14320
14423
  return `top: ${gap}px; right: ${gap}px;`;
14321
14424
  case "top-left":
14322
14425
  return `top: ${gap}px; left: ${gap}px;`;
14323
14426
  case "bottom-right":
14324
14427
  default:
14325
- return `bottom: ${gap}px; right: ${gap}px;`;
14428
+ return `bottom: ${bottomOffset(gap)}; right: ${gap}px;`;
14326
14429
  }
14327
14430
  }
14328
14431
  renderPIP(campaign) {
@@ -15396,6 +15499,9 @@ const _AegisInAppManager = class _AegisInAppManager {
15396
15499
  this.removeShells({ sdkOnly: true });
15397
15500
  this.campaignsLoaded = false;
15398
15501
  this.campaignsRequestKey = void 0;
15502
+ this.inflightActive = void 0;
15503
+ this.activeETag = null;
15504
+ this.activeETagKey = void 0;
15399
15505
  if (typeof document !== "undefined") {
15400
15506
  document.querySelectorAll(
15401
15507
  ".aegis-in-app-banner, .aegis-in-app-modal-overlay, .aegis-in-app-fullscreen-overlay, .aegis-in-app-half-interstitial-overlay, .aegis-in-app-alert-overlay, .aegis-in-app-pip, .aegis-in-app-nps-overlay, .aegis-in-app-countdown-overlay, .aegis-in-app-rating-overlay, .aegis-in-app-poll-overlay, .aegis-in-app-quiz-overlay, .aegis-in-app-rating-card, .aegis-in-app-nps-card"
@@ -15418,19 +15524,7 @@ const _AegisInAppManager = class _AegisInAppManager {
15418
15524
  };
15419
15525
  _AegisInAppManager.CONVERSION_STORAGE_PREFIX = "aegis_conv_";
15420
15526
  _AegisInAppManager.REFRESH_DEBOUNCE_MS = 300;
15421
- _AegisInAppManager.KNOWN_SURFACES = /* @__PURE__ */ new Set([
15422
- "bill",
15423
- "storefront_catalog",
15424
- "storefront_rewards",
15425
- "storefront_feedback",
15426
- "storefront_reviews",
15427
- "storefront_members",
15428
- "storefront_orders",
15429
- "storefront_account",
15430
- "storefront_referrals",
15431
- "external_website",
15432
- "external_mobile_screen"
15433
- ]);
15527
+ _AegisInAppManager.KNOWN_SURFACES = KNOWN_SURFACES;
15434
15528
  _AegisInAppManager.SERVED_DEDUP_PREFIX = "aegis_served_fired:";
15435
15529
  _AegisInAppManager.SHELL_TIMEOUT_MS = 1e4;
15436
15530
  _AegisInAppManager.JOURNEY_ACK_RETRY_MS = 2e3;
@@ -16196,7 +16290,8 @@ class PrefetchBundleClient {
16196
16290
  }
16197
16291
  let response;
16198
16292
  try {
16199
- response = await fetchWithAbort(url, { method: "GET", headers, cache: "no-cache" });
16293
+ const fetchBundle = this.currentBundle ? fetchWithAbort : fetchWithAbortRetry;
16294
+ response = await fetchBundle(url, { method: "GET", headers, cache: "no-cache" });
16200
16295
  } catch (err) {
16201
16296
  logger.warn("prefetch-bundle fetch network error:", err);
16202
16297
  return this.currentBundle;
@@ -16578,6 +16673,8 @@ class AegisWidgetManager {
16578
16673
  this.isInitialized = false;
16579
16674
  this.isDestroyed = false;
16580
16675
  this.prefetchWidgetConfigs = {};
16676
+ this.widgetsLoaded = false;
16677
+ this.prefetchConfigsLoaded = false;
16581
16678
  this.writeKey = config.writeKey;
16582
16679
  this.apiHost = config.apiHost || "https://api.aegis.ai";
16583
16680
  this.userId = config.userId ?? readAnonIdFromStorage();
@@ -16804,11 +16901,13 @@ class AegisWidgetManager {
16804
16901
  if (this.contactId) headers["X-Contact-ID"] = this.contactId;
16805
16902
  if (this.contactId && this.contactToken) headers["X-Contact-Token"] = this.contactToken;
16806
16903
  if (this.organizationId) headers["X-Organization-ID"] = this.organizationId;
16807
- const response = await fetch(url, { headers, credentials: "include" });
16904
+ const fetchConfigs = this.prefetchConfigsLoaded ? fetchWithAbort : fetchWithAbortRetry;
16905
+ const response = await fetchConfigs(url, { headers, credentials: "include" });
16808
16906
  if (!response.ok) {
16809
16907
  throw new Error(`Failed to fetch prefetch configs: ${response.status}`);
16810
16908
  }
16811
16909
  this.prefetchWidgetConfigs = await response.json();
16910
+ this.prefetchConfigsLoaded = true;
16812
16911
  const elapsed = performance.now() - startTime;
16813
16912
  this.log(`Fetched prefetch widget configs in ${elapsed.toFixed(2)}ms`);
16814
16913
  } catch (error) {
@@ -16828,11 +16927,13 @@ class AegisWidgetManager {
16828
16927
  if (this.contactId && this.contactToken) headers["X-Contact-Token"] = this.contactToken;
16829
16928
  if (this.organizationId) headers["X-Organization-ID"] = this.organizationId;
16830
16929
  if (this.sourcePlatform) headers["X-Source-Platform"] = this.sourcePlatform;
16831
- const response = await fetch(url, { headers, credentials: "include" });
16930
+ const fetchConfig = this.widgetsLoaded ? fetchWithAbort : fetchWithAbortRetry;
16931
+ const response = await fetchConfig(url, { headers, credentials: "include" });
16832
16932
  if (!response.ok) {
16833
16933
  throw new Error(`Failed to fetch widgets: ${response.status}`);
16834
16934
  }
16835
16935
  this.widgets = await response.json();
16936
+ this.widgetsLoaded = true;
16836
16937
  this.log(`Fetched ${this.widgets.length} widgets`);
16837
16938
  } catch (error) {
16838
16939
  this.log(`Error fetching widgets: ${error}`, true);
@@ -16958,7 +17059,10 @@ class AegisWidgetManager {
16958
17059
  return;
16959
17060
  }
16960
17061
  const beaconData = {
16961
- organization_id: this.organizationId || "default",
17062
+ // PL-9 (2026-11-20): never a 'default' tenant. The cell takes the WRITE
17063
+ // KEY's org and refuses (403) a body org that differs, so the field is
17064
+ // sent only when the SDK was configured with its org.
17065
+ ...this.organizationId ? { organization_id: this.organizationId } : {},
16962
17066
  contact_id: this.contactId,
16963
17067
  cart_id: this.cartData.cart_id,
16964
17068
  cart_total: this.cartData.cart_total,
@@ -18054,7 +18158,7 @@ const _AegisMessageRuntime = class _AegisMessageRuntime {
18054
18158
  this.initialized = false;
18055
18159
  this.armedInAppTriggers = /* @__PURE__ */ new Set();
18056
18160
  {
18057
- const v = "1.51.0";
18161
+ const v = "1.53.0";
18058
18162
  try {
18059
18163
  globalThis.__AEGIS_SDK_VERSION__ = v;
18060
18164
  } catch {
@@ -18486,7 +18590,7 @@ async function bootstrap(apiHost, req) {
18486
18590
  const url = `${apiHost.replace(/\/$/, "")}/v1/sdk/bootstrap`;
18487
18591
  const doFetch = async () => {
18488
18592
  try {
18489
- return await fetchWithAbort(url, {
18593
+ return await fetchWithAbortRetry(url, {
18490
18594
  method: "POST",
18491
18595
  headers: { "Content-Type": "application/json" },
18492
18596
  body: JSON.stringify(body),
@@ -18499,13 +18603,7 @@ async function bootstrap(apiHost, req) {
18499
18603
  throw err;
18500
18604
  }
18501
18605
  };
18502
- let resp;
18503
- try {
18504
- resp = await doFetch();
18505
- } catch (err) {
18506
- if (!(err instanceof BootstrapError) || err.status !== 0) throw err;
18507
- resp = await doFetch();
18508
- }
18606
+ let resp = await doFetch();
18509
18607
  if (resp.status >= 500) {
18510
18608
  await new Promise((r) => setTimeout(r, 750));
18511
18609
  resp = await doFetch();
@@ -18549,6 +18647,8 @@ export {
18549
18647
  AegisLoyaltyManager,
18550
18648
  AegisMessageRuntime,
18551
18649
  A as AegisWebPush,
18650
+ BOTTOM_RESERVE_VAR,
18651
+ BRAND_ACCENT_VAR,
18552
18652
  B as BloomFilter,
18553
18653
  BootstrapError,
18554
18654
  DEFAULT_RAIL_TITLES,
@@ -18576,6 +18676,7 @@ export {
18576
18676
  m as murmurhash3_x86_32,
18577
18677
  onLauncherChange,
18578
18678
  openChat,
18679
+ overlayAnchor,
18579
18680
  parseAction,
18580
18681
  readFirstPartyCookie,
18581
18682
  renderPreview,