@gengage/assistant-fe 0.1.9 → 0.2.1

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 (71) hide show
  1. package/dist/assistant-fe.css +1 -1
  2. package/dist/chat/components/CategoriesContainer.d.ts.map +1 -1
  3. package/dist/chat/components/ChatDrawer.d.ts.map +1 -1
  4. package/dist/chat/components/renderUISpec.d.ts.map +1 -1
  5. package/dist/chat/index.d.ts.map +1 -1
  6. package/dist/chat/panel-manager.d.ts +16 -0
  7. package/dist/chat/panel-manager.d.ts.map +1 -1
  8. package/dist/chat.cjs +1 -1
  9. package/dist/chat.iife.js +28 -28
  10. package/dist/chat.iife.js.map +1 -1
  11. package/dist/chat.js +2 -2
  12. package/dist/common/action-router.d.ts.map +1 -1
  13. package/dist/common/debug.d.ts.map +1 -1
  14. package/dist/common/events.d.ts.map +1 -1
  15. package/dist/common/native-webview.d.ts.map +1 -1
  16. package/dist/common/product-utils.d.ts +10 -0
  17. package/dist/common/product-utils.d.ts.map +1 -1
  18. package/dist/common/protocol-adapter.d.ts.map +1 -1
  19. package/dist/common.cjs +1 -1
  20. package/dist/common.js +5 -5
  21. package/dist/index-BUtw0Jlm.cjs +2 -0
  22. package/dist/index-BUtw0Jlm.cjs.map +1 -0
  23. package/dist/index-D-tVifN8.cjs +13 -0
  24. package/dist/index-D-tVifN8.cjs.map +1 -0
  25. package/dist/{index-DR2uepzb.js → index-DjPldwe7.js} +181 -187
  26. package/dist/index-DjPldwe7.js.map +1 -0
  27. package/dist/{index-CEt87kCd.js → index-TY0qKDI-.js} +1291 -1292
  28. package/dist/index-TY0qKDI-.js.map +1 -0
  29. package/dist/index.cjs +1 -1
  30. package/dist/index.js +3 -3
  31. package/dist/native.cjs +1 -1
  32. package/dist/native.iife.js +30 -30
  33. package/dist/native.iife.js.map +1 -1
  34. package/dist/native.js +1 -1
  35. package/dist/qna.cjs +1 -1
  36. package/dist/qna.iife.js +2 -2
  37. package/dist/qna.iife.js.map +1 -1
  38. package/dist/qna.js +1 -1
  39. package/dist/quantity-stepper-BKtPQUR1.js +78 -0
  40. package/dist/quantity-stepper-BKtPQUR1.js.map +1 -0
  41. package/dist/quantity-stepper-DU6va4sS.cjs +2 -0
  42. package/dist/quantity-stepper-DU6va4sS.cjs.map +1 -0
  43. package/dist/{schemas-DIhL3DkL.js → schemas-BAEbjFPE.js} +17 -12
  44. package/dist/schemas-BAEbjFPE.js.map +1 -0
  45. package/dist/{schemas-Dsr0bbO_.cjs → schemas-DIyHm5pa.cjs} +4 -4
  46. package/dist/{schemas-DIhL3DkL.js.map → schemas-DIyHm5pa.cjs.map} +1 -1
  47. package/dist/simrel/api.d.ts.map +1 -1
  48. package/dist/simrel/components/ProductCard.d.ts.map +1 -1
  49. package/dist/simrel/locales/en.d.ts.map +1 -1
  50. package/dist/simrel/locales/tr.d.ts.map +1 -1
  51. package/dist/simrel/types.d.ts +1 -0
  52. package/dist/simrel/types.d.ts.map +1 -1
  53. package/dist/simrel.cjs +1 -1
  54. package/dist/simrel.cjs.map +1 -1
  55. package/dist/simrel.css +1 -1
  56. package/dist/simrel.iife.js +6 -6
  57. package/dist/simrel.iife.js.map +1 -1
  58. package/dist/simrel.js +236 -234
  59. package/dist/simrel.js.map +1 -1
  60. package/package.json +1 -1
  61. package/dist/index-BWPx4pM7.cjs +0 -13
  62. package/dist/index-BWPx4pM7.cjs.map +0 -1
  63. package/dist/index-CEt87kCd.js.map +0 -1
  64. package/dist/index-DL4CAkyL.cjs +0 -2
  65. package/dist/index-DL4CAkyL.cjs.map +0 -1
  66. package/dist/index-DR2uepzb.js.map +0 -1
  67. package/dist/quantity-stepper-C-nV4lwi.js +0 -77
  68. package/dist/quantity-stepper-C-nV4lwi.js.map +0 -1
  69. package/dist/quantity-stepper-CURMkwRF.cjs +0 -2
  70. package/dist/quantity-stepper-CURMkwRF.cjs.map +0 -1
  71. package/dist/schemas-Dsr0bbO_.cjs.map +0 -1
package/dist/qna.js CHANGED
@@ -1,4 +1,4 @@
1
- import { b as q, c as w, a as x, r as Q, o as f, s as p, u as L, d as R, _ as C, e as B, f as N, B as P, t as O, g as H, h as U, w as j, i as D, j as m, k as F, l as z, m as M, n as G } from "./schemas-DIhL3DkL.js";
1
+ import { b as q, c as w, a as x, r as Q, o as f, s as p, u as L, d as R, _ as C, e as B, f as N, B as P, t as O, g as H, h as U, w as j, i as D, j as m, k as F, l as z, m as M, n as G } from "./schemas-BAEbjFPE.js";
2
2
  async function W(n, e, t) {
3
3
  const i = q("launcher_action", e), o = { uiSpecs: [], actions: [] }, s = {
4
4
  method: "POST",
@@ -0,0 +1,78 @@
1
+ const f = {
2
+ currencySymbol: "TL",
3
+ currencyPosition: "suffix",
4
+ thousandsSeparator: ".",
5
+ decimalSeparator: ",",
6
+ alwaysShowDecimals: !1
7
+ };
8
+ function x(t, d) {
9
+ const c = Number(t);
10
+ if (!Number.isFinite(c) || c < 0) return t;
11
+ const e = { ...f, ...d }, s = c % 1 !== 0 || e.alwaysShowDecimals ? c.toFixed(2) : c.toFixed(0), i = s.indexOf("."), n = i === -1 ? s : s.slice(0, i), o = i === -1 ? void 0 : s.slice(i + 1), l = n.replace(/\B(?=(\d{3})+(?!\d))/g, e.thousandsSeparator);
12
+ let r;
13
+ return o !== void 0 ? r = `${l}${e.decimalSeparator}${o}` : r = l, e.currencySymbol ? e.currencyPosition === "prefix" ? `${e.currencySymbol}${r}` : `${r} ${e.currencySymbol}` : r;
14
+ }
15
+ function y(t) {
16
+ return Number.isFinite(t) ? Math.max(0, Math.min(5, t)) : 0;
17
+ }
18
+ function h(t) {
19
+ return Number.isFinite(t) ? Math.max(0, Math.min(100, Math.round(t))) : 0;
20
+ }
21
+ function C(t) {
22
+ const d = y(t), c = Math.floor(d), e = d - c >= 0.5, m = 5 - c - (e ? 1 : 0), s = document.createElement("span");
23
+ if (s.className = "gengage-star-rating", c > 0 && s.appendChild(document.createTextNode("★".repeat(c))), e) {
24
+ const i = document.createElement("span");
25
+ i.className = "gengage-star-half", i.textContent = "☆";
26
+ const n = document.createElement("span");
27
+ n.textContent = "★", i.appendChild(n), s.appendChild(i);
28
+ }
29
+ return m > 0 && s.appendChild(document.createTextNode("☆".repeat(m))), s;
30
+ }
31
+ function S(t) {
32
+ t.addEventListener(
33
+ "error",
34
+ () => {
35
+ t.style.display = "none";
36
+ },
37
+ { once: !0 }
38
+ );
39
+ }
40
+ function E(t) {
41
+ const d = t.min ?? 1, c = t.max ?? 99, e = Math.min(d, c), m = Math.max(d, c), s = Math.max(e, Math.min(m, t.initial ?? e)), i = t.compact ?? !1;
42
+ let n = s;
43
+ const o = document.createElement("div");
44
+ o.className = `gengage-qty-stepper${i ? " gengage-qty-stepper--compact" : ""}`;
45
+ const l = document.createElement("button");
46
+ l.className = "gengage-qty-btn", l.type = "button", l.textContent = t.decreaseSymbol ?? "−", l.setAttribute("aria-label", t.decreaseLabel ?? "Decrease");
47
+ const r = document.createElement("span");
48
+ r.className = "gengage-qty-value", r.textContent = String(n), r.setAttribute("aria-live", "polite"), r.setAttribute("aria-atomic", "true");
49
+ const u = document.createElement("button");
50
+ u.className = "gengage-qty-btn", u.type = "button", u.textContent = t.increaseSymbol ?? "+", u.setAttribute("aria-label", t.increaseLabel ?? "Increase");
51
+ const a = document.createElement("button");
52
+ a.className = "gengage-qty-submit", a.type = "button", i ? (a.textContent = t.submitIcon ?? "🛒", a.title = t.label ?? "Add to Cart") : a.textContent = t.label ?? "Add to Cart";
53
+ function g() {
54
+ l.disabled = n <= e, u.disabled = n >= m;
55
+ }
56
+ return l.addEventListener("click", (p) => {
57
+ p.stopPropagation(), n > e && (n--, r.textContent = String(n), g());
58
+ }), u.addEventListener("click", (p) => {
59
+ p.stopPropagation(), n < m && (n++, r.textContent = String(n), g());
60
+ }), a.addEventListener("click", (p) => {
61
+ p.stopPropagation(), t.onSubmit(n);
62
+ const b = a.textContent;
63
+ a.textContent = "✓", a.classList.add("gengage-qty-submit--success"), a.disabled = !0, setTimeout(() => {
64
+ a.textContent = b, a.classList.remove("gengage-qty-submit--success"), a.disabled = !1;
65
+ }, 1200);
66
+ }), o.addEventListener("click", (p) => {
67
+ p.stopPropagation();
68
+ }), g(), o.appendChild(l), o.appendChild(r), o.appendChild(u), o.appendChild(a), o;
69
+ }
70
+ export {
71
+ S as a,
72
+ C as b,
73
+ h as c,
74
+ E as d,
75
+ y as e,
76
+ x as f
77
+ };
78
+ //# sourceMappingURL=quantity-stepper-BKtPQUR1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quantity-stepper-BKtPQUR1.js","sources":["../src/common/price-formatter.ts","../src/common/product-utils.ts","../src/common/quantity-stepper.ts"],"sourcesContent":["/**\n * Configurable price formatting.\n *\n * Defaults to Turkish locale (dot thousands, comma decimal, TL suffix).\n * Configure via widget config `pricing` field for any locale/currency.\n */\n\nexport interface PriceFormatConfig {\n /** Currency symbol. Default: 'TL' */\n currencySymbol?: string;\n /** Where to place the symbol. Default: 'suffix' */\n currencyPosition?: 'prefix' | 'suffix';\n /** Separator between thousands. Default: '.' (Turkish) */\n thousandsSeparator?: string;\n /** Decimal point character. Default: ',' (Turkish) */\n decimalSeparator?: string;\n /** Whether to show decimal part for whole numbers. Default: false */\n alwaysShowDecimals?: boolean;\n}\n\nconst TURKISH_DEFAULTS: Required<PriceFormatConfig> = {\n currencySymbol: 'TL',\n currencyPosition: 'suffix',\n thousandsSeparator: '.',\n decimalSeparator: ',',\n alwaysShowDecimals: false,\n};\n\n/**\n * Formats a raw numeric price string into the configured locale format.\n *\n * Examples (default Turkish):\n * \"17990\" → \"17.990 TL\"\n * \"17990.5\" → \"17.990,50 TL\"\n *\n * Examples (GBP prefix):\n * \"17990\" with { currencySymbol: '£', currencyPosition: 'prefix', thousandsSeparator: ',', decimalSeparator: '.' }\n * → \"£17,990\"\n *\n * Returns the input as-is if it's not a valid number.\n */\nexport function formatPrice(raw: string, config?: PriceFormatConfig): string {\n const num = Number(raw);\n if (!Number.isFinite(num) || num < 0) return raw;\n\n const resolved = { ...TURKISH_DEFAULTS, ...config };\n\n const hasDecimals = num % 1 !== 0;\n const fixed = hasDecimals || resolved.alwaysShowDecimals ? num.toFixed(2) : num.toFixed(0);\n const dotIdx = fixed.indexOf('.');\n const intPart = dotIdx === -1 ? fixed : fixed.slice(0, dotIdx);\n const decPart = dotIdx === -1 ? undefined : fixed.slice(dotIdx + 1);\n\n // Add thousands separators to integer part\n const withSeparators = intPart.replace(/\\B(?=(\\d{3})+(?!\\d))/g, resolved.thousandsSeparator);\n\n let formatted: string;\n if (decPart !== undefined) {\n formatted = `${withSeparators}${resolved.decimalSeparator}${decPart}`;\n } else {\n formatted = withSeparators;\n }\n\n if (resolved.currencySymbol) {\n if (resolved.currencyPosition === 'prefix') {\n return `${resolved.currencySymbol}${formatted}`;\n }\n return `${formatted} ${resolved.currencySymbol}`;\n }\n\n return formatted;\n}\n","/**\n * Shared product rendering utilities.\n *\n * Extracted from chat/renderUISpec and simrel/ProductCard to eliminate\n * duplication and provide consistent behavior across all widgets.\n */\n\n/** Clamp a rating value to the 0–5 range. Returns 0 for NaN/non-finite. */\nexport function clampRating(value: number): number {\n if (!Number.isFinite(value)) return 0;\n return Math.max(0, Math.min(5, value));\n}\n\n/** Clamp a discount percentage to the 0–100 range, rounded to integer. Returns 0 for NaN/non-finite. */\nexport function clampDiscount(value: number): number {\n if (!Number.isFinite(value)) return 0;\n return Math.max(0, Math.min(100, Math.round(value)));\n}\n\n/**\n * Render a star rating string with full, half, and empty stars.\n *\n * @param rating - A numeric rating (will be clamped to 0–5).\n * @param halfStars - Whether to render half-star characters. Defaults to true.\n * @returns A string like \"★★★½☆\" or \"★★★☆☆\" (without half-stars).\n */\nexport function renderStarRating(rating: number, halfStars: boolean = true): string {\n const clamped = clampRating(rating);\n if (halfStars) {\n const full = Math.floor(clamped);\n const half = clamped - full >= 0.5 ? 1 : 0;\n const empty = 5 - full - half;\n return '\\u2605'.repeat(full) + (half ? '\\u00BD' : '') + '\\u2606'.repeat(empty);\n }\n const rounded = Math.round(clamped);\n return '\\u2605'.repeat(rounded) + '\\u2606'.repeat(5 - rounded);\n}\n\n/**\n * Create a star rating DOM element with proper half-filled star rendering.\n *\n * Uses a CSS-clipped full star overlaid on an empty star for the half-star,\n * giving a visually accurate half-filled appearance instead of the \"½\" character.\n *\n * @param rating - A numeric rating (will be clamped to 0–5).\n * @returns An HTMLSpanElement containing the star icons.\n */\nexport function createStarRatingElement(rating: number): HTMLSpanElement {\n const clamped = clampRating(rating);\n const full = Math.floor(clamped);\n const hasHalf = clamped - full >= 0.5;\n const empty = 5 - full - (hasHalf ? 1 : 0);\n\n const container = document.createElement('span');\n container.className = 'gengage-star-rating';\n\n if (full > 0) {\n container.appendChild(document.createTextNode('\\u2605'.repeat(full)));\n }\n\n if (hasHalf) {\n const halfStar = document.createElement('span');\n halfStar.className = 'gengage-star-half';\n halfStar.textContent = '\\u2606';\n const filled = document.createElement('span');\n filled.textContent = '\\u2605';\n halfStar.appendChild(filled);\n container.appendChild(halfStar);\n }\n\n if (empty > 0) {\n container.appendChild(document.createTextNode('\\u2606'.repeat(empty)));\n }\n\n return container;\n}\n\n/**\n * Attach a one-time error handler that hides the image on load failure.\n *\n * Works with any HTMLImageElement. Hides the element by setting\n * `display: none` so layout doesn't break from broken images.\n */\nexport function addImageErrorHandler(img: HTMLImageElement): void {\n img.addEventListener(\n 'error',\n () => {\n img.style.display = 'none';\n },\n { once: true },\n );\n}\n","export interface QuantityStepperOptions {\n min?: number | undefined;\n max?: number | undefined;\n initial?: number | undefined;\n label?: string | undefined;\n compact?: boolean | undefined;\n decreaseLabel?: string | undefined;\n increaseLabel?: string | undefined;\n /** Symbol for decrease button (default: '\\u2212' minus sign). */\n decreaseSymbol?: string | undefined;\n /** Symbol for increase button (default: '+'). */\n increaseSymbol?: string | undefined;\n /** Icon/text for compact mode submit button (default: shopping cart emoji). */\n submitIcon?: string | undefined;\n onSubmit: (quantity: number) => void;\n}\n\n/**\n * Creates a quantity stepper with [−] [value] [+] and a submit button.\n * Compact mode renders a cart icon button; full mode renders a labeled button.\n */\nexport function createQuantityStepper(options: QuantityStepperOptions): HTMLElement {\n const rawMin = options.min ?? 1;\n const rawMax = options.max ?? 99;\n // Ensure min <= max; swap if caller provided inverted range\n const min = Math.min(rawMin, rawMax);\n const max = Math.max(rawMin, rawMax);\n const initial = Math.max(min, Math.min(max, options.initial ?? min));\n const compact = options.compact ?? false;\n\n let quantity = initial;\n\n const container = document.createElement('div');\n container.className = `gengage-qty-stepper${compact ? ' gengage-qty-stepper--compact' : ''}`;\n\n const decBtn = document.createElement('button');\n decBtn.className = 'gengage-qty-btn';\n decBtn.type = 'button';\n decBtn.textContent = options.decreaseSymbol ?? '\\u2212'; // minus sign\n decBtn.setAttribute('aria-label', options.decreaseLabel ?? 'Decrease');\n\n const valueEl = document.createElement('span');\n valueEl.className = 'gengage-qty-value';\n valueEl.textContent = String(quantity);\n valueEl.setAttribute('aria-live', 'polite');\n valueEl.setAttribute('aria-atomic', 'true');\n\n const incBtn = document.createElement('button');\n incBtn.className = 'gengage-qty-btn';\n incBtn.type = 'button';\n incBtn.textContent = options.increaseSymbol ?? '+';\n incBtn.setAttribute('aria-label', options.increaseLabel ?? 'Increase');\n\n const submitBtn = document.createElement('button');\n submitBtn.className = 'gengage-qty-submit';\n submitBtn.type = 'button';\n\n if (compact) {\n submitBtn.textContent = options.submitIcon ?? '\\uD83D\\uDED2'; // shopping cart emoji\n submitBtn.title = options.label ?? 'Add to Cart';\n } else {\n submitBtn.textContent = options.label ?? 'Add to Cart';\n }\n\n function updateButtons(): void {\n decBtn.disabled = quantity <= min;\n incBtn.disabled = quantity >= max;\n }\n\n decBtn.addEventListener('click', (e) => {\n e.stopPropagation();\n if (quantity > min) {\n quantity--;\n valueEl.textContent = String(quantity);\n updateButtons();\n }\n });\n\n incBtn.addEventListener('click', (e) => {\n e.stopPropagation();\n if (quantity < max) {\n quantity++;\n valueEl.textContent = String(quantity);\n updateButtons();\n }\n });\n\n submitBtn.addEventListener('click', (e) => {\n e.stopPropagation();\n options.onSubmit(quantity);\n // Brief visual feedback: show checkmark then revert\n const original = submitBtn.textContent;\n submitBtn.textContent = '\\u2713'; // checkmark\n submitBtn.classList.add('gengage-qty-submit--success');\n submitBtn.disabled = true;\n setTimeout(() => {\n submitBtn.textContent = original;\n submitBtn.classList.remove('gengage-qty-submit--success');\n submitBtn.disabled = false;\n }, 1200);\n });\n\n // Prevent card click when interacting with stepper\n container.addEventListener('click', (e) => {\n e.stopPropagation();\n });\n\n updateButtons();\n\n container.appendChild(decBtn);\n container.appendChild(valueEl);\n container.appendChild(incBtn);\n container.appendChild(submitBtn);\n\n return container;\n}\n"],"names":["TURKISH_DEFAULTS","formatPrice","raw","config","num","resolved","fixed","dotIdx","intPart","decPart","withSeparators","formatted","clampRating","value","clampDiscount","createStarRatingElement","rating","clamped","full","hasHalf","empty","container","halfStar","filled","addImageErrorHandler","img","createQuantityStepper","options","rawMin","rawMax","min","max","initial","compact","quantity","decBtn","valueEl","incBtn","submitBtn","updateButtons","e","original"],"mappings":"AAoBA,MAAMA,IAAgD;AAAA,EACpD,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,oBAAoB;AACtB;AAeO,SAASC,EAAYC,GAAaC,GAAoC;AAC3E,QAAMC,IAAM,OAAOF,CAAG;AACtB,MAAI,CAAC,OAAO,SAASE,CAAG,KAAKA,IAAM,EAAG,QAAOF;AAE7C,QAAMG,IAAW,EAAE,GAAGL,GAAkB,GAAGG,EAAA,GAGrCG,IADcF,IAAM,MAAM,KACHC,EAAS,qBAAqBD,EAAI,QAAQ,CAAC,IAAIA,EAAI,QAAQ,CAAC,GACnFG,IAASD,EAAM,QAAQ,GAAG,GAC1BE,IAAUD,MAAW,KAAKD,IAAQA,EAAM,MAAM,GAAGC,CAAM,GACvDE,IAAUF,MAAW,KAAK,SAAYD,EAAM,MAAMC,IAAS,CAAC,GAG5DG,IAAiBF,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,EAAO,WAAWD,KAAYJ,GAC9BO,EAAO,WAAWH,KAAYH;AAAA,EAChC;AAEA,SAAAI,EAAO,iBAAiB,SAAS,CAACK,MAAM;AACtC,IAAAA,EAAE,gBAAA,GACEN,IAAWJ,MACbI,KACAE,EAAQ,cAAc,OAAOF,CAAQ,GACrCK,EAAA;AAAA,EAEJ,CAAC,GAEDF,EAAO,iBAAiB,SAAS,CAACG,MAAM;AACtC,IAAAA,EAAE,gBAAA,GACEN,IAAWH,MACbG,KACAE,EAAQ,cAAc,OAAOF,CAAQ,GACrCK,EAAA;AAAA,EAEJ,CAAC,GAEDD,EAAU,iBAAiB,SAAS,CAACE,MAAM;AACzC,IAAAA,EAAE,gBAAA,GACFb,EAAQ,SAASO,CAAQ;AAEzB,UAAMO,IAAWH,EAAU;AAC3B,IAAAA,EAAU,cAAc,KACxBA,EAAU,UAAU,IAAI,6BAA6B,GACrDA,EAAU,WAAW,IACrB,WAAW,MAAM;AACf,MAAAA,EAAU,cAAcG,GACxBH,EAAU,UAAU,OAAO,6BAA6B,GACxDA,EAAU,WAAW;AAAA,IACvB,GAAG,IAAI;AAAA,EACT,CAAC,GAGDjB,EAAU,iBAAiB,SAAS,CAACmB,MAAM;AACzC,IAAAA,EAAE,gBAAA;AAAA,EACJ,CAAC,GAEDD,EAAA,GAEAlB,EAAU,YAAYc,CAAM,GAC5Bd,EAAU,YAAYe,CAAO,GAC7Bf,EAAU,YAAYgB,CAAM,GAC5BhB,EAAU,YAAYiB,CAAS,GAExBjB;AACT;"}
@@ -0,0 +1,2 @@
1
+ "use strict";const y={currencySymbol:"TL",currencyPosition:"suffix",thousandsSeparator:".",decimalSeparator:",",alwaysShowDecimals:!1};function h(t,d){const r=Number(t);if(!Number.isFinite(r)||r<0)return t;const e={...y,...d},i=r%1!==0||e.alwaysShowDecimals?r.toFixed(2):r.toFixed(0),s=i.indexOf("."),n=s===-1?i:i.slice(0,s),o=s===-1?void 0:i.slice(s+1),l=n.replace(/\B(?=(\d{3})+(?!\d))/g,e.thousandsSeparator);let c;return o!==void 0?c=`${l}${e.decimalSeparator}${o}`:c=l,e.currencySymbol?e.currencyPosition==="prefix"?`${e.currencySymbol}${c}`:`${c} ${e.currencySymbol}`:c}function b(t){return Number.isFinite(t)?Math.max(0,Math.min(5,t)):0}function x(t){return Number.isFinite(t)?Math.max(0,Math.min(100,Math.round(t))):0}function S(t){const d=b(t),r=Math.floor(d),e=d-r>=.5,m=5-r-(e?1:0),i=document.createElement("span");if(i.className="gengage-star-rating",r>0&&i.appendChild(document.createTextNode("★".repeat(r))),e){const s=document.createElement("span");s.className="gengage-star-half",s.textContent="☆";const n=document.createElement("span");n.textContent="★",s.appendChild(n),i.appendChild(s)}return m>0&&i.appendChild(document.createTextNode("☆".repeat(m))),i}function C(t){t.addEventListener("error",()=>{t.style.display="none"},{once:!0})}function E(t){const d=t.min??1,r=t.max??99,e=Math.min(d,r),m=Math.max(d,r),i=Math.max(e,Math.min(m,t.initial??e)),s=t.compact??!1;let n=i;const o=document.createElement("div");o.className=`gengage-qty-stepper${s?" gengage-qty-stepper--compact":""}`;const l=document.createElement("button");l.className="gengage-qty-btn",l.type="button",l.textContent=t.decreaseSymbol??"−",l.setAttribute("aria-label",t.decreaseLabel??"Decrease");const c=document.createElement("span");c.className="gengage-qty-value",c.textContent=String(n),c.setAttribute("aria-live","polite"),c.setAttribute("aria-atomic","true");const u=document.createElement("button");u.className="gengage-qty-btn",u.type="button",u.textContent=t.increaseSymbol??"+",u.setAttribute("aria-label",t.increaseLabel??"Increase");const a=document.createElement("button");a.className="gengage-qty-submit",a.type="button",s?(a.textContent=t.submitIcon??"🛒",a.title=t.label??"Add to Cart"):a.textContent=t.label??"Add to Cart";function g(){l.disabled=n<=e,u.disabled=n>=m}return l.addEventListener("click",p=>{p.stopPropagation(),n>e&&(n--,c.textContent=String(n),g())}),u.addEventListener("click",p=>{p.stopPropagation(),n<m&&(n++,c.textContent=String(n),g())}),a.addEventListener("click",p=>{p.stopPropagation(),t.onSubmit(n);const f=a.textContent;a.textContent="✓",a.classList.add("gengage-qty-submit--success"),a.disabled=!0,setTimeout(()=>{a.textContent=f,a.classList.remove("gengage-qty-submit--success"),a.disabled=!1},1200)}),o.addEventListener("click",p=>{p.stopPropagation()}),g(),o.appendChild(l),o.appendChild(c),o.appendChild(u),o.appendChild(a),o}exports.addImageErrorHandler=C;exports.clampDiscount=x;exports.clampRating=b;exports.createQuantityStepper=E;exports.createStarRatingElement=S;exports.formatPrice=h;
2
+ //# sourceMappingURL=quantity-stepper-DU6va4sS.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quantity-stepper-DU6va4sS.cjs","sources":["../src/common/price-formatter.ts","../src/common/product-utils.ts","../src/common/quantity-stepper.ts"],"sourcesContent":["/**\n * Configurable price formatting.\n *\n * Defaults to Turkish locale (dot thousands, comma decimal, TL suffix).\n * Configure via widget config `pricing` field for any locale/currency.\n */\n\nexport interface PriceFormatConfig {\n /** Currency symbol. Default: 'TL' */\n currencySymbol?: string;\n /** Where to place the symbol. Default: 'suffix' */\n currencyPosition?: 'prefix' | 'suffix';\n /** Separator between thousands. Default: '.' (Turkish) */\n thousandsSeparator?: string;\n /** Decimal point character. Default: ',' (Turkish) */\n decimalSeparator?: string;\n /** Whether to show decimal part for whole numbers. Default: false */\n alwaysShowDecimals?: boolean;\n}\n\nconst TURKISH_DEFAULTS: Required<PriceFormatConfig> = {\n currencySymbol: 'TL',\n currencyPosition: 'suffix',\n thousandsSeparator: '.',\n decimalSeparator: ',',\n alwaysShowDecimals: false,\n};\n\n/**\n * Formats a raw numeric price string into the configured locale format.\n *\n * Examples (default Turkish):\n * \"17990\" → \"17.990 TL\"\n * \"17990.5\" → \"17.990,50 TL\"\n *\n * Examples (GBP prefix):\n * \"17990\" with { currencySymbol: '£', currencyPosition: 'prefix', thousandsSeparator: ',', decimalSeparator: '.' }\n * → \"£17,990\"\n *\n * Returns the input as-is if it's not a valid number.\n */\nexport function formatPrice(raw: string, config?: PriceFormatConfig): string {\n const num = Number(raw);\n if (!Number.isFinite(num) || num < 0) return raw;\n\n const resolved = { ...TURKISH_DEFAULTS, ...config };\n\n const hasDecimals = num % 1 !== 0;\n const fixed = hasDecimals || resolved.alwaysShowDecimals ? num.toFixed(2) : num.toFixed(0);\n const dotIdx = fixed.indexOf('.');\n const intPart = dotIdx === -1 ? fixed : fixed.slice(0, dotIdx);\n const decPart = dotIdx === -1 ? undefined : fixed.slice(dotIdx + 1);\n\n // Add thousands separators to integer part\n const withSeparators = intPart.replace(/\\B(?=(\\d{3})+(?!\\d))/g, resolved.thousandsSeparator);\n\n let formatted: string;\n if (decPart !== undefined) {\n formatted = `${withSeparators}${resolved.decimalSeparator}${decPart}`;\n } else {\n formatted = withSeparators;\n }\n\n if (resolved.currencySymbol) {\n if (resolved.currencyPosition === 'prefix') {\n return `${resolved.currencySymbol}${formatted}`;\n }\n return `${formatted} ${resolved.currencySymbol}`;\n }\n\n return formatted;\n}\n","/**\n * Shared product rendering utilities.\n *\n * Extracted from chat/renderUISpec and simrel/ProductCard to eliminate\n * duplication and provide consistent behavior across all widgets.\n */\n\n/** Clamp a rating value to the 0–5 range. Returns 0 for NaN/non-finite. */\nexport function clampRating(value: number): number {\n if (!Number.isFinite(value)) return 0;\n return Math.max(0, Math.min(5, value));\n}\n\n/** Clamp a discount percentage to the 0–100 range, rounded to integer. Returns 0 for NaN/non-finite. */\nexport function clampDiscount(value: number): number {\n if (!Number.isFinite(value)) return 0;\n return Math.max(0, Math.min(100, Math.round(value)));\n}\n\n/**\n * Render a star rating string with full, half, and empty stars.\n *\n * @param rating - A numeric rating (will be clamped to 0–5).\n * @param halfStars - Whether to render half-star characters. Defaults to true.\n * @returns A string like \"★★★½☆\" or \"★★★☆☆\" (without half-stars).\n */\nexport function renderStarRating(rating: number, halfStars: boolean = true): string {\n const clamped = clampRating(rating);\n if (halfStars) {\n const full = Math.floor(clamped);\n const half = clamped - full >= 0.5 ? 1 : 0;\n const empty = 5 - full - half;\n return '\\u2605'.repeat(full) + (half ? '\\u00BD' : '') + '\\u2606'.repeat(empty);\n }\n const rounded = Math.round(clamped);\n return '\\u2605'.repeat(rounded) + '\\u2606'.repeat(5 - rounded);\n}\n\n/**\n * Create a star rating DOM element with proper half-filled star rendering.\n *\n * Uses a CSS-clipped full star overlaid on an empty star for the half-star,\n * giving a visually accurate half-filled appearance instead of the \"½\" character.\n *\n * @param rating - A numeric rating (will be clamped to 0–5).\n * @returns An HTMLSpanElement containing the star icons.\n */\nexport function createStarRatingElement(rating: number): HTMLSpanElement {\n const clamped = clampRating(rating);\n const full = Math.floor(clamped);\n const hasHalf = clamped - full >= 0.5;\n const empty = 5 - full - (hasHalf ? 1 : 0);\n\n const container = document.createElement('span');\n container.className = 'gengage-star-rating';\n\n if (full > 0) {\n container.appendChild(document.createTextNode('\\u2605'.repeat(full)));\n }\n\n if (hasHalf) {\n const halfStar = document.createElement('span');\n halfStar.className = 'gengage-star-half';\n halfStar.textContent = '\\u2606';\n const filled = document.createElement('span');\n filled.textContent = '\\u2605';\n halfStar.appendChild(filled);\n container.appendChild(halfStar);\n }\n\n if (empty > 0) {\n container.appendChild(document.createTextNode('\\u2606'.repeat(empty)));\n }\n\n return container;\n}\n\n/**\n * Attach a one-time error handler that hides the image on load failure.\n *\n * Works with any HTMLImageElement. Hides the element by setting\n * `display: none` so layout doesn't break from broken images.\n */\nexport function addImageErrorHandler(img: HTMLImageElement): void {\n img.addEventListener(\n 'error',\n () => {\n img.style.display = 'none';\n },\n { once: true },\n );\n}\n","export interface QuantityStepperOptions {\n min?: number | undefined;\n max?: number | undefined;\n initial?: number | undefined;\n label?: string | undefined;\n compact?: boolean | undefined;\n decreaseLabel?: string | undefined;\n increaseLabel?: string | undefined;\n /** Symbol for decrease button (default: '\\u2212' minus sign). */\n decreaseSymbol?: string | undefined;\n /** Symbol for increase button (default: '+'). */\n increaseSymbol?: string | undefined;\n /** Icon/text for compact mode submit button (default: shopping cart emoji). */\n submitIcon?: string | undefined;\n onSubmit: (quantity: number) => void;\n}\n\n/**\n * Creates a quantity stepper with [−] [value] [+] and a submit button.\n * Compact mode renders a cart icon button; full mode renders a labeled button.\n */\nexport function createQuantityStepper(options: QuantityStepperOptions): HTMLElement {\n const rawMin = options.min ?? 1;\n const rawMax = options.max ?? 99;\n // Ensure min <= max; swap if caller provided inverted range\n const min = Math.min(rawMin, rawMax);\n const max = Math.max(rawMin, rawMax);\n const initial = Math.max(min, Math.min(max, options.initial ?? min));\n const compact = options.compact ?? false;\n\n let quantity = initial;\n\n const container = document.createElement('div');\n container.className = `gengage-qty-stepper${compact ? ' gengage-qty-stepper--compact' : ''}`;\n\n const decBtn = document.createElement('button');\n decBtn.className = 'gengage-qty-btn';\n decBtn.type = 'button';\n decBtn.textContent = options.decreaseSymbol ?? '\\u2212'; // minus sign\n decBtn.setAttribute('aria-label', options.decreaseLabel ?? 'Decrease');\n\n const valueEl = document.createElement('span');\n valueEl.className = 'gengage-qty-value';\n valueEl.textContent = String(quantity);\n valueEl.setAttribute('aria-live', 'polite');\n valueEl.setAttribute('aria-atomic', 'true');\n\n const incBtn = document.createElement('button');\n incBtn.className = 'gengage-qty-btn';\n incBtn.type = 'button';\n incBtn.textContent = options.increaseSymbol ?? '+';\n incBtn.setAttribute('aria-label', options.increaseLabel ?? 'Increase');\n\n const submitBtn = document.createElement('button');\n submitBtn.className = 'gengage-qty-submit';\n submitBtn.type = 'button';\n\n if (compact) {\n submitBtn.textContent = options.submitIcon ?? '\\uD83D\\uDED2'; // shopping cart emoji\n submitBtn.title = options.label ?? 'Add to Cart';\n } else {\n submitBtn.textContent = options.label ?? 'Add to Cart';\n }\n\n function updateButtons(): void {\n decBtn.disabled = quantity <= min;\n incBtn.disabled = quantity >= max;\n }\n\n decBtn.addEventListener('click', (e) => {\n e.stopPropagation();\n if (quantity > min) {\n quantity--;\n valueEl.textContent = String(quantity);\n updateButtons();\n }\n });\n\n incBtn.addEventListener('click', (e) => {\n e.stopPropagation();\n if (quantity < max) {\n quantity++;\n valueEl.textContent = String(quantity);\n updateButtons();\n }\n });\n\n submitBtn.addEventListener('click', (e) => {\n e.stopPropagation();\n options.onSubmit(quantity);\n // Brief visual feedback: show checkmark then revert\n const original = submitBtn.textContent;\n submitBtn.textContent = '\\u2713'; // checkmark\n submitBtn.classList.add('gengage-qty-submit--success');\n submitBtn.disabled = true;\n setTimeout(() => {\n submitBtn.textContent = original;\n submitBtn.classList.remove('gengage-qty-submit--success');\n submitBtn.disabled = false;\n }, 1200);\n });\n\n // Prevent card click when interacting with stepper\n container.addEventListener('click', (e) => {\n e.stopPropagation();\n });\n\n updateButtons();\n\n container.appendChild(decBtn);\n container.appendChild(valueEl);\n container.appendChild(incBtn);\n container.appendChild(submitBtn);\n\n return container;\n}\n"],"names":["TURKISH_DEFAULTS","formatPrice","raw","config","num","resolved","fixed","dotIdx","intPart","decPart","withSeparators","formatted","clampRating","value","clampDiscount","createStarRatingElement","rating","clamped","full","hasHalf","empty","container","halfStar","filled","addImageErrorHandler","img","createQuantityStepper","options","rawMin","rawMax","min","max","initial","compact","quantity","decBtn","valueEl","incBtn","submitBtn","updateButtons","e","original"],"mappings":"aAoBA,MAAMA,EAAgD,CACpD,eAAgB,KAChB,iBAAkB,SAClB,mBAAoB,IACpB,iBAAkB,IAClB,mBAAoB,EACtB,EAeO,SAASC,EAAYC,EAAaC,EAAoC,CAC3E,MAAMC,EAAM,OAAOF,CAAG,EACtB,GAAI,CAAC,OAAO,SAASE,CAAG,GAAKA,EAAM,EAAG,OAAOF,EAE7C,MAAMG,EAAW,CAAE,GAAGL,EAAkB,GAAGG,CAAA,EAGrCG,EADcF,EAAM,IAAM,GACHC,EAAS,mBAAqBD,EAAI,QAAQ,CAAC,EAAIA,EAAI,QAAQ,CAAC,EACnFG,EAASD,EAAM,QAAQ,GAAG,EAC1BE,EAAUD,IAAW,GAAKD,EAAQA,EAAM,MAAM,EAAGC,CAAM,EACvDE,EAAUF,IAAW,GAAK,OAAYD,EAAM,MAAMC,EAAS,CA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AiB,QAAUK,GAAM,CACtCA,EAAE,gBAAA,EACEN,EAAWJ,IACbI,IACAE,EAAQ,YAAc,OAAOF,CAAQ,EACrCK,EAAA,EAEJ,CAAC,EAEDF,EAAO,iBAAiB,QAAUG,GAAM,CACtCA,EAAE,gBAAA,EACEN,EAAWH,IACbG,IACAE,EAAQ,YAAc,OAAOF,CAAQ,EACrCK,EAAA,EAEJ,CAAC,EAEDD,EAAU,iBAAiB,QAAUE,GAAM,CACzCA,EAAE,gBAAA,EACFb,EAAQ,SAASO,CAAQ,EAEzB,MAAMO,EAAWH,EAAU,YAC3BA,EAAU,YAAc,IACxBA,EAAU,UAAU,IAAI,6BAA6B,EACrDA,EAAU,SAAW,GACrB,WAAW,IAAM,CACfA,EAAU,YAAcG,EACxBH,EAAU,UAAU,OAAO,6BAA6B,EACxDA,EAAU,SAAW,EACvB,EAAG,IAAI,CACT,CAAC,EAGDjB,EAAU,iBAAiB,QAAUmB,GAAM,CACzCA,EAAE,gBAAA,CACJ,CAAC,EAEDD,EAAA,EAEAlB,EAAU,YAAYc,CAAM,EAC5Bd,EAAU,YAAYe,CAAO,EAC7Bf,EAAU,YAAYgB,CAAM,EAC5BhB,EAAU,YAAYiB,CAAS,EAExBjB,CACT"}
@@ -454,9 +454,12 @@ function Xt(e) {
454
454
  if (e.type !== "user_message" && e.type !== "inputText") return null;
455
455
  if (typeof e.payload == "string" && e.payload.trim().length > 0)
456
456
  return e.payload.trim();
457
- if (typeof e.payload == "object" && e.payload !== null && typeof e.payload.text == "string") {
458
- const t = String(e.payload.text).trim();
459
- if (t.length > 0) return t;
457
+ if (typeof e.payload == "object" && e.payload !== null) {
458
+ const t = e.payload;
459
+ if (typeof t.text == "string") {
460
+ const n = t.text.trim();
461
+ if (n.length > 0) return n;
462
+ }
460
463
  }
461
464
  return typeof e.title == "string" && e.title.trim().length > 0 ? e.title.trim() : null;
462
465
  }
@@ -673,7 +676,9 @@ function gn() {
673
676
  return Y;
674
677
  }
675
678
  function me(e, t, n) {
676
- gn() && (n !== void 0 ? console.debug(`[gengage:${e}]`, t, n) : console.debug(`[gengage:${e}]`, t));
679
+ if (!gn()) return;
680
+ const r = [`[gengage:${e}]`, t];
681
+ n !== void 0 && r.push(n), console.debug(...r);
677
682
  }
678
683
  class wc {
679
684
  constructor() {
@@ -1774,15 +1779,15 @@ function lt(e) {
1774
1779
  return e != null;
1775
1780
  }
1776
1781
  function M(e) {
1777
- const t = e.price_discounted != null && e.price_discounted > 0 ? e.price_discounted : e.price, n = e.price_discounted != null && e.price_discounted > 0 && e.price != null ? e.price : void 0;
1778
- let r;
1779
- n != null && t != null && n > 0 && (r = Math.round((n - t) / n * 100));
1780
- const o = w(e.brand), i = w(e.name) ?? e.sku, s = o && !i.toLowerCase().startsWith(o.toLowerCase()) ? `${o} ${i}` : i, a = {
1782
+ const t = e.price_discounted != null && e.price_discounted > 0, n = t ? e.price_discounted : e.price, r = t && e.price != null ? e.price : void 0;
1783
+ let o;
1784
+ r != null && n != null && r > 0 && (o = Math.round((r - n) / r * 100));
1785
+ const i = w(e.brand), s = w(e.name) ?? e.sku, a = i && !s.toLowerCase().startsWith(i.toLowerCase()) ? `${i} ${s}` : s, c = {
1781
1786
  sku: e.sku,
1782
- name: s,
1787
+ name: a,
1783
1788
  url: w(e.url) ?? ""
1784
- }, c = e.images?.[0];
1785
- return c && (a.imageUrl = c), e.images && e.images.length > 1 && (a.images = e.images), t != null && (a.price = String(t)), n != null && (a.originalPrice = String(n)), r !== void 0 && (a.discountPercent = r), o !== void 0 && (a.brand = o), e.rating !== void 0 && (a.rating = e.rating), e.review_count !== void 0 && (a.reviewCount = e.review_count), e.cart_code !== void 0 && (a.cartCode = e.cart_code), e.in_stock !== void 0 && (a.inStock = e.in_stock), e.variants && e.variants.length > 0 && (a.variants = e.variants), e.discount_reason !== void 0 && (a.discountReason = e.discount_reason), e.promotions && e.promotions.length > 0 && (a.promotions = e.promotions), a;
1789
+ }, u = e.images?.[0];
1790
+ return u && (c.imageUrl = u), e.images && e.images.length > 1 && (c.images = e.images), n != null && (c.price = String(n)), r != null && (c.originalPrice = String(r)), o !== void 0 && (c.discountPercent = o), i !== void 0 && (c.brand = i), e.rating !== void 0 && (c.rating = e.rating), e.review_count !== void 0 && (c.reviewCount = e.review_count), e.cart_code !== void 0 && (c.cartCode = e.cart_code), e.in_stock !== void 0 && (c.inStock = e.in_stock), e.variants && e.variants.length > 0 && (c.variants = e.variants), e.discount_reason !== void 0 && (c.discountReason = e.discount_reason), e.promotions && e.promotions.length > 0 && (c.promotions = e.promotions), c;
1786
1791
  }
1787
1792
  function zc(e) {
1788
1793
  return e.results.map(M);
@@ -4889,4 +4894,4 @@ export {
4889
4894
  Uc as y,
4890
4895
  dr as z
4891
4896
  };
4892
- //# sourceMappingURL=schemas-DIhL3DkL.js.map
4897
+ //# sourceMappingURL=schemas-BAEbjFPE.js.map