@gengage/assistant-fe 0.6.18 → 0.6.19

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 (41) hide show
  1. package/dist/account-config-D_EMuR0g.js +1479 -0
  2. package/dist/agentic/context/context-store.d.ts +2 -1
  3. package/dist/agentic/index.d.ts +0 -1
  4. package/dist/agentic/index.js +155 -181
  5. package/dist/agentic/types.d.ts +6 -1
  6. package/dist/agentic/worker.d.ts +0 -2
  7. package/dist/agentic/worker.js +117 -415
  8. package/dist/agentic.iife.js +6 -6
  9. package/dist/{api-paths-CEDR4rld.js → api-paths-lIioK7-S.js} +1 -1
  10. package/dist/chat/components/InlineLauncher.d.ts +1 -1
  11. package/dist/chat-runtime.js +1 -1
  12. package/dist/chat.iife.js +1 -1
  13. package/dist/chat.js +1 -1
  14. package/dist/{common-BBgWfT-W.js → common-8WOyaL9-.js} +1 -1
  15. package/dist/common.js +5 -5
  16. package/dist/{connection-warning-B-doodzu.js → connection-warning-CBR0CWsY.js} +1 -1
  17. package/dist/{fastIntent-CloHPZQh.js → fastIntent-Dw79pmRK.js} +1 -1
  18. package/dist/index.js +10 -10
  19. package/dist/native.iife.js +1 -1
  20. package/dist/qna-runtime.js +1 -1
  21. package/dist/qna.iife.js +1 -1
  22. package/dist/qna.js +1 -1
  23. package/dist/{runtime-Ctqq0V6G.js → runtime-BsnZ6gt2.js} +3 -3
  24. package/dist/{runtime-BGCNkU1H.js → runtime-D5Sj-_tA.js} +3 -3
  25. package/dist/{runtime-CbWCU424.js → runtime-w0f2VkzL.js} +3 -3
  26. package/dist/{simbut-Dh4cJysK.js → simbut-BvdJtzCu.js} +1 -1
  27. package/dist/simbut.iife.js +1 -1
  28. package/dist/simbut.js +1 -1
  29. package/dist/{simrel-B-sjHbL5.js → simrel-DU6a27g9.js} +1 -1
  30. package/dist/simrel-runtime.js +1 -1
  31. package/dist/simrel.iife.js +1 -1
  32. package/dist/simrel.js +2 -2
  33. package/dist/{widget-base-CIJT5AiP.js → widget-base-BeWuIxD6.js} +1 -1
  34. package/package.json +4 -2
  35. package/dist/account-config-gj7_mF6Q.js +0 -1731
  36. package/dist/agentic/recipes/catalog-assistant-flow.d.ts +0 -50
  37. package/dist/agentic/recipes/input-text/actions.d.ts +0 -15
  38. package/dist/agentic/recipes/input-text/index.d.ts +0 -4
  39. package/dist/agentic/recipes/input-text/products.d.ts +0 -4
  40. package/dist/agentic/recipes/input-text/ranking.d.ts +0 -14
  41. package/dist/agentic/recipes/input-text/steps.d.ts +0 -31
package/dist/chat.iife.js CHANGED
@@ -44,7 +44,7 @@
44
44
  transform: translateY(0);
45
45
  }
46
46
  }
47
- `,document.head.appendChild(e)}var Pt=null;function vo(){if(Pt!==null)return Pt;try{Pt=localStorage.getItem("gengage:debug")==="1"}catch{Pt=!1}return Pt}function Ve(e,t,a){if(!vo())return;const n=[`[gengage:${e}]`,t];a!==void 0&&n.push(a),console.debug(...n)}var yo=("0.6.18".trim(),"0.6.18".trim()),xo=("iife-build".trim(),"iife-build".trim());function _o(){if(typeof window>"u")return;const e=window;e.__gengageSdkRuntimeInfoLogged||(e.__gengageSdkRuntimeInfoLogged=!0,console.info(`[gengage] @gengage/assistant-fe v${yo} (${xo})`))}var wo=class{constructor(){this.isVisible=!1,this.isInitialised=!1,this._handlers=new Map,this._cleanups=[],this._ownsRoot=!1,this._destroying=!1}async init(e){if(this.isInitialised){console.warn("[gengage] Widget already initialised. Call update() instead.");return}const t=no(e.theme);_o(),this.config={...e,theme:t,session:ao(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),lo();const a=tn("gengage:context:update",n=>this.update(n));this._cleanups.push(a),Ve("lifecycle",`${this.constructor.name}.init`,{accountId:e.accountId,sku:e.pageContext?.sku});try{await this.onInit(this.config)}catch(n){throw this.destroy(),n}this._destroying||(this.isInitialised=!0,Ve("lifecycle",`${this.constructor.name} ready`),this.emit("ready"))}update(e){this.isInitialised&&(this.config.pageContext?this.config={...this.config,pageContext:{...this.config.pageContext,...e}}:e.pageType!==void 0&&(this.config={...this.config,pageContext:e}),this.onUpdate(e),this.emit("context-update",this.config.pageContext))}show(){this.isVisible||(this.isVisible=!0,this.root.style.display="",this.onShow(),this.emit("show"))}hide(){this.isVisible&&(this.isVisible=!1,this.root.style.display="none",this.onHide(),this.emit("hide"))}destroy(){this._destroying||(this._destroying=!0,this.emit("destroy"),this._cleanups.forEach(e=>e()),this._cleanups.length=0,this._handlers.clear(),this.onDestroy(),this._cleanupRoot(),this.isInitialised=!1)}_cleanupRoot(){this._ownsRoot?this.root.remove():this.root.innerHTML=""}on(e,t){return this._handlers.has(e)||this._handlers.set(e,new Set),this._handlers.get(e).add(t),()=>this._handlers.get(e)?.delete(t)}emit(e,...t){this._handlers.get(e)?.forEach(a=>a(...t))}addCleanup(e){this._cleanups.push(e)}_resolveMount(e){if(e instanceof HTMLElement)return e;if(typeof e=="string"){const a=document.querySelector(e);if(!a)throw new Error(`[gengage] Mount target not found: "${e}"`);return a}const t=document.createElement("div");return t.dataset.gengageWidget=this.constructor.name.toLowerCase(),document.body.insertBefore(t,document.body.firstChild),this._ownsRoot=!0,t}_applyTheme(e){if(e){for(const[t,a]of Object.entries(e))if(a!==void 0){const n=t.startsWith("--")?t:`--gengage-${ko(t)}`;this.root.style.setProperty(n,a)}}}};function ko(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function sn(){const e=Date.now(),t=new Uint8Array(16);crypto.getRandomValues(t),t[0]=e/2**40&255,t[1]=e/2**32&255,t[2]=e/2**24&255,t[3]=e/2**16&255,t[4]=e/2**8&255,t[5]=e&255,t[6]=t[6]&15|112,t[8]=t[8]&63|128;const a=Array.from(t,n=>n.toString(16).padStart(2,"0")).join("");return`${a.slice(0,8)}-${a.slice(8,12)}-${a.slice(12,16)}-${a.slice(16,20)}-${a.slice(20)}`}var Co=class{constructor(e){this._handlers=new Map,this._destroyed=!1,this._namespace=e.namespace,this._allowedOrigins=e.allowedOrigins??[location.origin],this._onMessage=e.onMessage,this._allowedOrigins.includes("*")&&Eo()&&console.warn("[gengage] postMessage bridge using wildcard origin. Set allowedOrigins for production security."),this._messageListener=t=>this._handlePostMessage(t),window.addEventListener("message",this._messageListener)}send(e,t){if(this._destroyed)return;const a={namespace:this._namespace,type:e};t!==void 0&&(a.payload=t),window.dispatchEvent(new CustomEvent("gengage:bridge:message",{detail:a,bubbles:!1}))}on(e,t){this._handlers.has(e)||this._handlers.set(e,new Set);const a=this._handlers.get(e);return a.add(t),()=>{a.delete(t),a.size===0&&this._handlers.delete(e)}}destroy(){this._destroyed||(this._destroyed=!0,window.removeEventListener("message",this._messageListener),this._handlers.clear())}_handlePostMessage(e){if(this._destroyed||!this._isOriginAllowed(e.origin))return;const t=e.data;if(!So(t)||t.gengage!==this._namespace)return;const a={type:t.type};t.payload!==void 0&&(a.payload=t.payload),this._onMessage?.(a);const n=this._handlers.get(a.type);if(n)for(const r of n)r(a.payload)}_isOriginAllowed(e){return this._allowedOrigins.includes("*")?!0:this._allowedOrigins.includes(e)}};function So(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.gengage=="string"&&typeof t.type=="string"}function Eo(){try{return typeof process<"u"&&process.env.NODE_ENV!=="production"}catch{return!1}}function cn(e,t){if(typeof window>"u"||!Ce(e))return!1;const a=new CustomEvent("gengage:navigate",{detail:t===void 0?{url:e}:{url:e,newTab:t},cancelable:!0});return window.dispatchEvent(a)?(t?window.open(e,"_blank","noopener,noreferrer"):window.location.href=e,!0):!1}var Po=console;function To(e,t,a={}){const n=e.action,r=a.logger??Po;switch(Ve("action",`routing action: ${n.kind}`,n),n.kind){case"open_chat":t.openChat?.(n.payload);return;case"navigate":{if(typeof n.url!="string"){ut(n,t,a,r);return}if(!Ce(n.url)){r.warn("[gengage] Blocked navigation to unsafe URL:",n.url);return}const i=typeof n.newTab=="boolean"?n.newTab:void 0;if(t.navigate){t.navigate({url:n.url,...i!==void 0&&{newTab:i}});return}(a.defaultNavigate??Ao)(n.url,i);return}case"save_session":if(typeof n.sessionId!="string"||typeof n.sku!="string"){ut(n,t,a,r);return}t.saveSession?.({sessionId:n.sessionId,sku:n.sku});return;case"add_to_cart":if(typeof n.sku!="string"||typeof n.quantity!="number"||typeof n.cartCode!="string"){ut(n,t,a,r);return}t.addToCart?.({sku:n.sku,quantity:n.quantity,cartCode:n.cartCode});return;case"script_call":{if(a.allowScriptCall===!1){ut(n,t,a,r);return}if(typeof n.name!="string"){ut(n,t,a,r);return}const i=Lo(n.payload)?n.payload:void 0;t.scriptCall?.({name:n.name,...i!==void 0&&{payload:i}});return}default:ut(n,t,a,r)}}function ut(e,t,a,n){const r=a.unknownActionPolicy??"log-and-ignore";if(r==="delegate"){t.unknown?.(e),t.unknown||n.warn("[gengage] Unknown action received without delegate handler",e);return}if(r==="throw")throw new Error(`[gengage] Unknown action kind: ${e.kind}`);n.warn("[gengage] Unknown action ignored",e)}function Ao(e,t){if(!(typeof window>"u")){if(!Ce(e)){console.warn("[gengage] Blocked navigation to unsafe URL:",e);return}cn(e,t)}}function Lo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Tt(e){const t=e?.trim();return t||"tr"}function Ee(e){const t=globalThis.CSS?.escape;if(typeof t=="function")return t(e);const a=Array.from(e);return a.map((n,r)=>{const i=n.codePointAt(0);return i===void 0?"":i===0?"�":i>=1&&i<=31||i===127||r===0&&i>=48&&i<=57||r===1&&a[0]==="-"&&i>=48&&i<=57?`\\${i.toString(16)} `:r===0&&n==="-"&&a.length===1?"\\-":i>=128||/[A-Za-z0-9_-]/.test(n)?n:`\\${n}`}).join("")}var Io=["image/jpeg","image/png","image/webp"],Of=5*1024*1024;function No(e){return Io.includes(e.type)?e.size>5242880?{ok:!1,reason:"too_large"}:{ok:!0}:{ok:!1,reason:"invalid_type"}}function ln(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function zo(e){const t=[];let a=0,n=!1,r=!1,i=0;for(let o=0;o<e.length;o++){const s=e[o];if(r){r=!1;continue}if(s==="\\"&&n){r=!0;continue}if(s==='"'){n=!n;continue}n||(s==="{"&&a++,s==="}"&&(a--,a===0&&(t.push(e.slice(i,o+1)),i=o+1)))}return t.length>0?t:[e]}function gn(e,t){const a=e.trim();if(!a||a.startsWith(":"))return!1;const n=a.startsWith("data: ")?a.slice(6):a;if(n==="[DONE]")return t.onDone?.(),!0;try{const r=JSON.parse(n);return ln(r)?(Ve("stream",`event: ${r.type}`,r),t.onEvent(r),r.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const r=zo(n);if(r.length>1){for(const i of r)try{const o=JSON.parse(i);if(!ln(o))continue;if(t.onEvent(o),o.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function Mo(e,t){if(!e.ok){t.onError?.(new Error(`HTTP ${e.status}: ${e.statusText}`));return}if(!e.body){t.onError?.(new Error("Response body is null — streaming not supported"));return}const a=e.body.getReader(),n=new TextDecoder("utf-8");let r="";const i=t.idleTimeoutMs??6e4,o=Symbol("idle-timeout");let s=!1;try{for(;;){const c=a.read();let l;const g=await(i>0?Promise.race([c.then(b=>(clearTimeout(l),b)),new Promise(b=>{l=setTimeout(()=>b(o),i)})]):c);if(g===o){s=!0,await a.cancel();break}const{done:d,value:p}=g;if(d)break;r+=n.decode(p,{stream:!0});const u=r.split(`
47
+ `,document.head.appendChild(e)}var Pt=null;function vo(){if(Pt!==null)return Pt;try{Pt=localStorage.getItem("gengage:debug")==="1"}catch{Pt=!1}return Pt}function Ve(e,t,a){if(!vo())return;const n=[`[gengage:${e}]`,t];a!==void 0&&n.push(a),console.debug(...n)}var yo=("0.6.19".trim(),"0.6.19".trim()),xo=("iife-build".trim(),"iife-build".trim());function _o(){if(typeof window>"u")return;const e=window;e.__gengageSdkRuntimeInfoLogged||(e.__gengageSdkRuntimeInfoLogged=!0,console.info(`[gengage] @gengage/assistant-fe v${yo} (${xo})`))}var wo=class{constructor(){this.isVisible=!1,this.isInitialised=!1,this._handlers=new Map,this._cleanups=[],this._ownsRoot=!1,this._destroying=!1}async init(e){if(this.isInitialised){console.warn("[gengage] Widget already initialised. Call update() instead.");return}const t=no(e.theme);_o(),this.config={...e,theme:t,session:ao(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),lo();const a=tn("gengage:context:update",n=>this.update(n));this._cleanups.push(a),Ve("lifecycle",`${this.constructor.name}.init`,{accountId:e.accountId,sku:e.pageContext?.sku});try{await this.onInit(this.config)}catch(n){throw this.destroy(),n}this._destroying||(this.isInitialised=!0,Ve("lifecycle",`${this.constructor.name} ready`),this.emit("ready"))}update(e){this.isInitialised&&(this.config.pageContext?this.config={...this.config,pageContext:{...this.config.pageContext,...e}}:e.pageType!==void 0&&(this.config={...this.config,pageContext:e}),this.onUpdate(e),this.emit("context-update",this.config.pageContext))}show(){this.isVisible||(this.isVisible=!0,this.root.style.display="",this.onShow(),this.emit("show"))}hide(){this.isVisible&&(this.isVisible=!1,this.root.style.display="none",this.onHide(),this.emit("hide"))}destroy(){this._destroying||(this._destroying=!0,this.emit("destroy"),this._cleanups.forEach(e=>e()),this._cleanups.length=0,this._handlers.clear(),this.onDestroy(),this._cleanupRoot(),this.isInitialised=!1)}_cleanupRoot(){this._ownsRoot?this.root.remove():this.root.innerHTML=""}on(e,t){return this._handlers.has(e)||this._handlers.set(e,new Set),this._handlers.get(e).add(t),()=>this._handlers.get(e)?.delete(t)}emit(e,...t){this._handlers.get(e)?.forEach(a=>a(...t))}addCleanup(e){this._cleanups.push(e)}_resolveMount(e){if(e instanceof HTMLElement)return e;if(typeof e=="string"){const a=document.querySelector(e);if(!a)throw new Error(`[gengage] Mount target not found: "${e}"`);return a}const t=document.createElement("div");return t.dataset.gengageWidget=this.constructor.name.toLowerCase(),document.body.insertBefore(t,document.body.firstChild),this._ownsRoot=!0,t}_applyTheme(e){if(e){for(const[t,a]of Object.entries(e))if(a!==void 0){const n=t.startsWith("--")?t:`--gengage-${ko(t)}`;this.root.style.setProperty(n,a)}}}};function ko(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function sn(){const e=Date.now(),t=new Uint8Array(16);crypto.getRandomValues(t),t[0]=e/2**40&255,t[1]=e/2**32&255,t[2]=e/2**24&255,t[3]=e/2**16&255,t[4]=e/2**8&255,t[5]=e&255,t[6]=t[6]&15|112,t[8]=t[8]&63|128;const a=Array.from(t,n=>n.toString(16).padStart(2,"0")).join("");return`${a.slice(0,8)}-${a.slice(8,12)}-${a.slice(12,16)}-${a.slice(16,20)}-${a.slice(20)}`}var Co=class{constructor(e){this._handlers=new Map,this._destroyed=!1,this._namespace=e.namespace,this._allowedOrigins=e.allowedOrigins??[location.origin],this._onMessage=e.onMessage,this._allowedOrigins.includes("*")&&Eo()&&console.warn("[gengage] postMessage bridge using wildcard origin. Set allowedOrigins for production security."),this._messageListener=t=>this._handlePostMessage(t),window.addEventListener("message",this._messageListener)}send(e,t){if(this._destroyed)return;const a={namespace:this._namespace,type:e};t!==void 0&&(a.payload=t),window.dispatchEvent(new CustomEvent("gengage:bridge:message",{detail:a,bubbles:!1}))}on(e,t){this._handlers.has(e)||this._handlers.set(e,new Set);const a=this._handlers.get(e);return a.add(t),()=>{a.delete(t),a.size===0&&this._handlers.delete(e)}}destroy(){this._destroyed||(this._destroyed=!0,window.removeEventListener("message",this._messageListener),this._handlers.clear())}_handlePostMessage(e){if(this._destroyed||!this._isOriginAllowed(e.origin))return;const t=e.data;if(!So(t)||t.gengage!==this._namespace)return;const a={type:t.type};t.payload!==void 0&&(a.payload=t.payload),this._onMessage?.(a);const n=this._handlers.get(a.type);if(n)for(const r of n)r(a.payload)}_isOriginAllowed(e){return this._allowedOrigins.includes("*")?!0:this._allowedOrigins.includes(e)}};function So(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.gengage=="string"&&typeof t.type=="string"}function Eo(){try{return typeof process<"u"&&process.env.NODE_ENV!=="production"}catch{return!1}}function cn(e,t){if(typeof window>"u"||!Ce(e))return!1;const a=new CustomEvent("gengage:navigate",{detail:t===void 0?{url:e}:{url:e,newTab:t},cancelable:!0});return window.dispatchEvent(a)?(t?window.open(e,"_blank","noopener,noreferrer"):window.location.href=e,!0):!1}var Po=console;function To(e,t,a={}){const n=e.action,r=a.logger??Po;switch(Ve("action",`routing action: ${n.kind}`,n),n.kind){case"open_chat":t.openChat?.(n.payload);return;case"navigate":{if(typeof n.url!="string"){ut(n,t,a,r);return}if(!Ce(n.url)){r.warn("[gengage] Blocked navigation to unsafe URL:",n.url);return}const i=typeof n.newTab=="boolean"?n.newTab:void 0;if(t.navigate){t.navigate({url:n.url,...i!==void 0&&{newTab:i}});return}(a.defaultNavigate??Ao)(n.url,i);return}case"save_session":if(typeof n.sessionId!="string"||typeof n.sku!="string"){ut(n,t,a,r);return}t.saveSession?.({sessionId:n.sessionId,sku:n.sku});return;case"add_to_cart":if(typeof n.sku!="string"||typeof n.quantity!="number"||typeof n.cartCode!="string"){ut(n,t,a,r);return}t.addToCart?.({sku:n.sku,quantity:n.quantity,cartCode:n.cartCode});return;case"script_call":{if(a.allowScriptCall===!1){ut(n,t,a,r);return}if(typeof n.name!="string"){ut(n,t,a,r);return}const i=Lo(n.payload)?n.payload:void 0;t.scriptCall?.({name:n.name,...i!==void 0&&{payload:i}});return}default:ut(n,t,a,r)}}function ut(e,t,a,n){const r=a.unknownActionPolicy??"log-and-ignore";if(r==="delegate"){t.unknown?.(e),t.unknown||n.warn("[gengage] Unknown action received without delegate handler",e);return}if(r==="throw")throw new Error(`[gengage] Unknown action kind: ${e.kind}`);n.warn("[gengage] Unknown action ignored",e)}function Ao(e,t){if(!(typeof window>"u")){if(!Ce(e)){console.warn("[gengage] Blocked navigation to unsafe URL:",e);return}cn(e,t)}}function Lo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Tt(e){const t=e?.trim();return t||"tr"}function Ee(e){const t=globalThis.CSS?.escape;if(typeof t=="function")return t(e);const a=Array.from(e);return a.map((n,r)=>{const i=n.codePointAt(0);return i===void 0?"":i===0?"�":i>=1&&i<=31||i===127||r===0&&i>=48&&i<=57||r===1&&a[0]==="-"&&i>=48&&i<=57?`\\${i.toString(16)} `:r===0&&n==="-"&&a.length===1?"\\-":i>=128||/[A-Za-z0-9_-]/.test(n)?n:`\\${n}`}).join("")}var Io=["image/jpeg","image/png","image/webp"],Of=5*1024*1024;function No(e){return Io.includes(e.type)?e.size>5242880?{ok:!1,reason:"too_large"}:{ok:!0}:{ok:!1,reason:"invalid_type"}}function ln(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function zo(e){const t=[];let a=0,n=!1,r=!1,i=0;for(let o=0;o<e.length;o++){const s=e[o];if(r){r=!1;continue}if(s==="\\"&&n){r=!0;continue}if(s==='"'){n=!n;continue}n||(s==="{"&&a++,s==="}"&&(a--,a===0&&(t.push(e.slice(i,o+1)),i=o+1)))}return t.length>0?t:[e]}function gn(e,t){const a=e.trim();if(!a||a.startsWith(":"))return!1;const n=a.startsWith("data: ")?a.slice(6):a;if(n==="[DONE]")return t.onDone?.(),!0;try{const r=JSON.parse(n);return ln(r)?(Ve("stream",`event: ${r.type}`,r),t.onEvent(r),r.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const r=zo(n);if(r.length>1){for(const i of r)try{const o=JSON.parse(i);if(!ln(o))continue;if(t.onEvent(o),o.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function Mo(e,t){if(!e.ok){t.onError?.(new Error(`HTTP ${e.status}: ${e.statusText}`));return}if(!e.body){t.onError?.(new Error("Response body is null — streaming not supported"));return}const a=e.body.getReader(),n=new TextDecoder("utf-8");let r="";const i=t.idleTimeoutMs??6e4,o=Symbol("idle-timeout");let s=!1;try{for(;;){const c=a.read();let l;const g=await(i>0?Promise.race([c.then(b=>(clearTimeout(l),b)),new Promise(b=>{l=setTimeout(()=>b(o),i)})]):c);if(g===o){s=!0,await a.cancel();break}const{done:d,value:p}=g;if(d)break;r+=n.decode(p,{stream:!0});const u=r.split(`
48
48
  `);r=u.pop()??"";for(const b of u)if(gn(b,t))return}if(r.trim()&&gn(r,t))return}catch(c){if(c instanceof DOMException&&c.name==="AbortError")return;t.onError?.(c instanceof Error?c:new Error(String(c)))}finally{s||a.releaseLock()}t.onDone?.()}var dn=3,Bo=(e,t)=>{const a=e.replace(/\s+/g," ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g,"");if(!a)return"";const n=t?.stripLeadingStopWords?a.replace(/^(?:daha|için)\s+/i,"").trim():a;return n?n.split(/\s+/).slice(0,3).join(" ").trim():""},ma=(e,t)=>e?e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(a=>Bo(a,t)).filter(Boolean):[];function Ro(e){const t=(e.display_keywords??[]).flatMap(r=>ma(r,{stripLeadingStopWords:!0})),a=t.filter((r,i)=>t.indexOf(r)===i);if(a.length>0)return a.slice(0,dn);const n=[...ma(e.chosen_attribute,{stripLeadingStopWords:!0}),...ma(e.short_name)];return n.filter((r,i)=>n.indexOf(r)===i).slice(0,dn)}function $o(e){return Ro(e).join(" • ")}function pn(e){return e==="beauty_consulting"||e==="account_expert"}function fa(...e){for(const t of e){if(typeof t!="string")continue;const a=t.trim();if(a.length>0)return a}}function ba(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0).map(t=>t.trim()):[]}function Ft(e){const t={...e},a=fa(t.sku),n=ba(t.group_skus);if(a?t.sku=a:delete t.sku,n.length>0?t.group_skus=n:delete t.group_skus,a||n.length>0)delete t.image_url;else{const r=fa(t.image_url);r?t.image_url=r:delete t.image_url}return t}function Oo(e){if(typeof e.type!="string")return null;if(Do(e))return e;const t=e;switch(t.type){case"outputText":return Fo(t);case"suggestedActions":return Ho(t);case"productList":return Uo(t);case"productDetails":return jo(t);case"productDetailsSimilars":return Zo(t);case"comparisonTable":return qo(t);case"context":return Ko(t);case"chatStreamEnd":return Yo();case"loading":return Jo(t);case"panelLoading":return Xo(t);case"similarLoading":return Qo(t);case"redirect":return es(t);case"error":return ts(t);case"dummy":return as(t);case"launcherAction":return ns(t);case"text":return va(t);case"productItem":return rs(t);case"text_image":return hn(t);case"quick_qna":return un(t);case"reviewHighlights":return is(t);case"aiProductSuggestions":return cs(t);case"aiProductGroupings":return ls(t);case"aiSuggestedSearches":return ds(t);case"prosAndCons":return os(t);case"getGroundingReview":return ps(t);case"voice":return us(t);case"visitorDataResponse":return ss(t);case"productListPreview":return hs();case"groupList":return ms(t);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return fs(t);case"launcherContent":return vs(t);case"handoff":return bs(t);case"uiSpec":return Ss(t);default:return null}}function Do(e){const t=e.type;if(typeof t!="string")return!1;switch(t){case"metadata":return typeof e.sessionId=="string"&&typeof e.model=="string";case"text_chunk":return typeof e.content=="string";case"ui_spec":{const a=e.widget;if(a!=="chat"&&a!=="qna"&&a!=="simrel")return!1;const n=Pe(e.spec);return n?typeof n.root=="string"&&Pe(n.elements)!==null:!1}case"action":{const a=Pe(e.action);return a!==null&&typeof a.kind=="string"}case"error":return typeof e.code=="string"&&typeof e.message=="string";case"done":return!0;default:return!1}}function Fo(e){const t=re(e.payload.text,e.payload.plain_text)??"",a=re(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:a||"Backend returned an error"};const n={type:"text_chunk",content:t,final:!0},r=e.payload.product_mentions;Array.isArray(r)&&r.length>0&&(n.productMentions=r.filter(c=>typeof c=="object"&&c!==null&&typeof c.sku=="string"&&typeof c.short_name=="string"));const i=e.payload.sku_to_product_item;i&&typeof i=="object"&&!Array.isArray(i)&&(n.skuToProductItem=i);const o=e.payload.conversation_mode;typeof o=="string"&&o&&(n.conversationMode=o);const s=e.payload.render_hint;return typeof s=="string"&&s&&(n.renderHint=s),e.payload.kvkk===!0&&(n.kvkk=!0),n}function Ho(e){return mn((e.payload.actions??[]).map(t=>{const a=re(t.title)??"",n=$e(t.requestDetails,a),r=n?{label:a,action:n}:null;return r?(typeof t.icon=="string"&&(r.icon=t.icon),typeof t.image=="string"&&(r.image=t.image),r):null}).filter(Lt),"chat")}function Uo(e){const t=(Array.isArray(e.payload.style_variations)?e.payload.style_variations:[]).map(o=>{const s=re(o.style_label);if(!s)return null;const c=re(o.style_mood),l=re(o.image_url??void 0),g=(Array.isArray(o.product_list)?o.product_list:[]).map(p=>{const u=Pe(p);return u?ya(Pe(u.product_detail)??Pe(u.product)??u):null}).filter(Lt),d=Array.isArray(o.recommendation_groups)?o.recommendation_groups.map(p=>({label:re(p.label)??"",reason:re(p.reason)??"",skus:Array.isArray(p.skus)?p.skus.filter(u=>typeof u=="string"&&u.trim().length>0):[]})):[];return{style_label:s,style_mood:c??"",...l?{image_url:l}:{},...typeof o.status=="string"?{status:o.status}:{},product_list:g,recommendation_groups:d}}).filter(Lt),a=e.payload.product_list??[],n=pn(e.payload.source)&&t.length>0?t[0].product_list:null,r=n?ys(n,"chat"):fn(a,"chat");r.panelHint="panel";const i=r.spec.elements[r.spec.root];if(i){const o={};typeof e.payload.offset=="number"&&(o.offset=e.payload.offset),typeof e.payload.end_of_list=="boolean"&&(o.endOfList=e.payload.end_of_list),typeof e.payload.title=="string"&&(o.panelTitle=e.payload.title),typeof e.payload.source=="string"&&(o.source=e.payload.source),t.length>0&&(o.styleVariations=t),e.payload.replace_panel===!0&&(o.replacePanel=!0),(e.payload.ranking_state==="pending"||e.payload.ranking_state==="final")&&(o.rankingState=e.payload.ranking_state);const s=e.payload.sequence_id??e.payload.search_id;typeof s=="string"&&s.length>0&&(o.sequenceId=s),Object.keys(o).length>0&&(i.props={...i.props,...o})}return r}function jo(e){const t=e.payload.productDetails;if(!t)return _s("chat");const a=mt(t);return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:{...t,...a}}}}},panelHint:"panel"}}function Zo(e){const t=fn(e.payload.similarProducts??[],"chat"),a=t.spec.elements[t.spec.root];return a&&(a.props={...a.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function qo(e){const t=e.payload.multiple_product_details??[],a=e.payload,n={key_differences:a.key_differences,recommended_choice:a.recommended_choice,recommended_choice_sku:a.recommended_choice_sku,special_considerations:a.special_considerations,criteria_view:a.criteria_view,criteria_view_short:a.criteria_view_short,compared_field_names:a.compared_field_names,winner_product:a.winner_product,winner_hits:a.winner_hits,...e.payload.product_comparison_framework??{}},r=e.payload.table,i=e.payload.features_list,o=[];for(const m of t){const h=mt(m);o.push(h)}const s=Vo(r,o,n,i);let c;n?.recommended_choice_sku?c=n.recommended_choice_sku:n?.winner_product&&n.winner_product.length>0&&(c=n.winner_product[0]?.product_detail?.sku??n.winner_product[0]?.sku);const l=c?o.find(m=>m.sku===c)??o[0]:o[0],g=[];if(Array.isArray(n?.key_differences))for(const m of n.key_differences)typeof m=="string"&&g.push(m);const d=bn(n?.special_considerations),p=n?.recommended_choice,u=n?.winner_hits,b={};for(const m of o){const h=m.sku;h&&(b[h]={title:m.name??h,type:"launchSingleProduct",payload:{sku:h}})}const f={products:o,attributes:s,highlights:g,productActions:b};return l&&(f.recommended=l),d.length>0&&(f.specialCases=d),p&&(f.recommendedText=p),u&&(f.winnerHits=u),typeof n?.key_differences=="string"&&(f.keyDifferencesHtml=n.key_differences),n?.special_considerations&&(f.specialConsiderations=n.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:f}}},panelHint:"panel"}}function Vo(e,t,a,n){if(!e)return[];const r=Object.entries(e);if(r.length===0)return[];const i=r[0]?.[1];if(Array.isArray(i)){const d=a.criteria_view??a.criteria_view_short??{},p=a.compared_field_names??Object.keys(e),u=[];for(const b of p){const f=e[b];if(!f||!Array.isArray(f))continue;const m=d[b]??b;u.push({label:m,values:f.map(h=>typeof h=="string"?h:String(h??""))})}return u}const o=e,s=t.map(d=>String(d.sku??"")).filter(d=>d.length>0),c=a.criteria_view??a.criteria_view_short??{},l=(n&&n.length>0?n:a.compared_field_names&&a.compared_field_names.length>0?a.compared_field_names:Go(o)).filter(d=>d!=="name"&&d!=="name_short"&&!d.endsWith("_short")),g=[];for(const d of l){const p=s.map(b=>{const f=o[b];if(!f||typeof f!="object")return"";const m=f[`${d}_short`],h=f[d];return Wo(m??h)});if(p.every(b=>b.length===0))continue;const u=c[d]??d;g.push({label:u,values:p})}return g}function Go(e){const t=[],a=new Set;for(const n of Object.values(e))if(!(!n||typeof n!="object"))for(const r of Object.keys(n))a.has(r)||(a.add(r),t.push(r));return t}function Wo(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function Ko(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function Yo(){return{type:"done"}}function Jo(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,loadingText:e.payload.text,thinkingMessages:e.payload.thinking_messages,dynamicLoading:e.payload.is_dynamic===!0}}}function Xo(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Qo(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function es(e){const t=re(e.payload.url);return t?{type:"action",action:{kind:"navigate",url:t,newTab:e.payload.new_tab===!0}}:{type:"metadata",sessionId:"",model:"",meta:{redirect:e.payload,redirectTarget:re(e.payload.to)}}}function ts(e){return{type:"error",code:"BACKEND_ERROR",message:re(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function as(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function ns(e){const t=e.payload??{};if(Array.isArray(t.action_list)){const r={action_list:t.action_list},i=typeof t.type=="string"?t.type:void 0,o=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(r.type=i),o!==void 0&&(r.theme=o),un({type:"quick_qna",payload:r})}const a=Pe(t.action);if(a){const r={action:a},i=typeof t.text=="string"?t.text:void 0,o=typeof t.image_url=="string"?t.image_url:void 0,s=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(r.text=i),o!==void 0&&(r.image_url=o),s!==void 0&&(r.theme=s),hn({type:"text_image",payload:r})}const n=typeof t.text=="string"?t.text:"";if(n){const r={text:n},i=typeof t.type=="string"?t.type:void 0,o=typeof t.theme=="string"?t.theme:void 0,s=Pe(t.payload)??void 0;return i!==void 0&&(r.type=i),s!==void 0&&(r.payload=s),o!==void 0&&(r.theme=o),va({type:"text",payload:r})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function va(e){const t={text:re(e.payload.text)??""};return typeof e.payload.theme=="string"&&(t.theme=e.payload.theme),e.payload.payload!==void 0&&(t.payload=e.payload.payload),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"QuestionHeading",props:t}}}}}function rs(e){return xs(e.payload,"qna")}function hn(e){const t=re(e.payload.text)??"",a=$e(e.payload.action,t);if(a){const r={label:t||a.title,action:a};return typeof e.payload.image_url=="string"&&(r.image=e.payload.image_url),typeof e.payload.theme=="string"&&(r.theme=e.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:r}}}}}const n={text:t};return typeof e.payload.theme=="string"&&(n.theme=e.payload.theme),va({type:"text",payload:n})}function un(e){return mn((e.payload.action_list??[]).map(t=>{const a=re(t.title)??"",n=$e(t.requestDetails,a),r=n?{label:a,action:n}:null;return r?(typeof t.icon=="string"&&(r.icon=t.icon),typeof t.image=="string"&&(r.image=t.image),r):null}).filter(Lt),"qna")}function is(e){const t={reviews:(e.payload.reviews??[]).map(a=>{const n={};return typeof a.review_class=="string"&&(n.review_class=a.review_class),typeof a.review_text=="string"&&(n.review_text=a.review_text),(typeof a.review_rating=="string"||typeof a.review_rating=="number")&&(n.review_rating=a.review_rating),typeof a.review_tag=="string"&&(n.review_tag=a.review_tag),n})};return typeof e.payload.sku=="string"&&(t.sku=e.payload.sku),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ReviewHighlights",props:t}}}}}function os(e){const t={};return Array.isArray(e.payload.pros)&&(t.pros=e.payload.pros),Array.isArray(e.payload.cons)&&(t.cons=e.payload.cons),typeof e.payload.product_name=="string"&&(t.productName=e.payload.product_name),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProsAndCons",props:t}}}}}function ss(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function cs(e){const t=e.payload.product_suggestions??[],a=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r)continue;const i=ws(r);if(!i)continue;const o={product:i},s=$e(r.requestDetails,i.name);s&&(o.action=s),typeof r.role=="string"&&(o.role=r.role),typeof r.reason=="string"&&(o.reason=r.reason),typeof r.review_highlight=="string"&&(o.reviewHighlight=r.review_highlight),Array.isArray(r.labels)&&(o.labels=r.labels),typeof r.expert_quality_score=="number"&&(o.expertQualityScore=r.expert_quality_score),a.push(o)}return a.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductSuggestions:e.payload.product_suggestions??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AITopPicks",props:{suggestions:a}}}}}}function ls(e){const t=e.payload.product_groupings??[],a=[],n=[];for(let r=0;r<t.length;r++){const i=t[r];if(!i)continue;const o=re(i.name)??"",s=re(i.description),c=re(i.highlight),l=Array.isArray(i.labels)?bn(i.labels):[],g=re(i.sku,i.repr_sku),d=re(i.image,i.repr_image),p=gs(i,o,g),u=(Array.isArray(i.group_products)?i.group_products:[]).map(m=>{const h=Pe(m);return h?ya(h):null}).filter(Lt),b=d??re(...u.map(m=>m.imageUrl));if(o&&u.length>0){const m={groupName:o,products:u};b&&(m.image=b),s&&(m.description=s),c&&(m.highlight=c),l.length>0&&(m.labels=l),a.push(m)}if(!p)continue;const f={name:o,action:p};l.length>0&&(f.labels=l),d!==void 0&&(f.image=d),n.push(f)}return a.length>0?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:a}}}},panelHint:"panel"}:n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductGroupings:e.payload.product_groupings??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AIGroupingCards",props:{entries:n}}}}}}function gs(e,t,a){const n=Pe(e.requestDetails);if(n){if(n.type!=="findSimilar")return $e(n,t);const o={...Pe(n.payload)??{}};a&&!fa(o.sku)&&(o.sku=a);const s=ba(e.group_skus);return s.length>0&&(o.group_skus=s),$e({...n,payload:Ft(o)},t)}const r={};a&&(r.sku=a);const i=ba(e.group_skus);return i.length>0&&(r.group_skus=i),Object.keys(r).length===0?null:$e({type:"findSimilar",payload:Ft(r)},t)}function ds(e){const t=e.payload.suggested_searches??[],a=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r)continue;const i=re(r.short_name,r.chosen_attribute,r.detailed_user_message)??`Search ${n+1}`,o={},s=re(r.detailed_user_message);s&&(o.text=s);const c=Pe(Pe(r.requestDetails)?.payload),l=c?.group_skus;r.group_skus&&Array.isArray(r.group_skus)?o.group_skus=r.group_skus:Array.isArray(l)&&(o.group_skus=l.filter(h=>typeof h=="string"));const g=re(r.sku,r.representative_product_sku,c?.sku);g&&(o.sku=g),o.is_suggested_text=1;const d={type:"inputText",payload:o},p=$e(r.requestDetails,i),u=p?.type==="findSimilar"&&typeof o.text=="string"?$e(d,i):p??$e(d,i);if(!u)continue;const b={shortName:i,action:u},f=re(r.detailed_user_message);f&&f!==i&&(b.detailedMessage=f);const m=$o(r);m&&m!==i&&m!==(f??"")&&(b.whyDifferent=m),typeof r.image=="string"&&(b.image=r.image),a.push(b)}return a.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiSuggestedSearches:e.payload.suggested_searches??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AISuggestedSearchCards",props:{entries:a}}}}}}function ps(e){const t=e.payload,a=$e(t.requestDetails??t.request_details,re(t.review_count,t.reviewCount,t.text,t.title)??"Show product reviews");if(!a)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:t}};const n={action:a};return t.title&&(n.title=t.title),t.text&&(n.text=t.text),t.review_count?n.reviewCount=t.review_count:typeof t.reviewCount=="string"&&t.reviewCount.trim()&&(n.reviewCount=t.reviewCount),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:n}}}}}function hs(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function us(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function ms(e){const t=e.payload.group_list??[],a=[];for(const r of t){const i=r.group_name??"",o=(r.product_list??[]).map(mt);a.push({groupName:i,products:o})}const n=[];for(const r of e.payload.filter_tags??[]){const i=r.title??"";if(!i)continue;const o=$e(r.requestDetails,i),s={title:i};o&&(s.action=o),n.push(s)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:a,filterTags:n}}}},panelHint:"panel"}}function fs(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function bs(e){const t={};return typeof e.payload?.summary=="string"&&(t.summary=e.payload.summary),Array.isArray(e.payload?.products_discussed)&&(t.products_discussed=e.payload.products_discussed),typeof e.payload?.user_sentiment=="string"&&(t.user_sentiment=e.payload.user_sentiment),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"HandoffNotice",props:t}}}}}function vs(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function mn(e,t){const a={},n=[];for(let r=0;r<e.length;r++){const i=e[r];if(!i)continue;const o=`action-${r}`;n.push(o);const s={label:i.label,action:i.action};i.icon!==void 0&&(s.icon=i.icon),i.image!==void 0&&(s.image=i.image),i.description!==void 0&&(s.description=i.description),a[o]={type:"ActionButton",props:s}}return a.root={type:"ActionButtons",props:{buttons:e.map(r=>{const i={label:r.label,action:r.action};return r.image!==void 0&&(i.image=r.image),r.description!==void 0&&(i.description=r.description),r.icon!==void 0&&(i.icon=r.icon),i})},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:a}}}function fn(e,t){const a={},n=[];for(let r=0;r<e.length;r++){const i=e[r];if(!i)continue;const o=mt(i),s=`product-${r}`;n.push(s);const c={product:o,index:r};o.sku&&(c.action={title:o.name,type:"launchSingleProduct",payload:{sku:o.sku}}),a[s]={type:"ProductCard",props:c}}return a.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:a}}}function ys(e,t){const a={},n=[];for(let r=0;r<e.length;r++){const i=e[r];if(!i)continue;const o=`product-${r}`;n.push(o);const s={product:i,index:r},c=i.sku;c&&(s.action={title:i.name??"",type:"launchSingleProduct",payload:{sku:c}}),a[o]={type:"ProductCard",props:s}}return a.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:a}}}function xs(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:mt(e),index:0}}}}}}function _s(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function ws(e){const t=re(e.sku),a=re(e.short_name),n={...Pe(e.product_item)??e},r=re(e.discount_reason,e.discountReason);return r&&!re(n.discount_reason,n.discountReason)&&(n.discount_reason=r),ya(n,t,a)}function ya(e,t,a){const n=re(e.sku,t),r=re(e.name,a);if(!n||!r)return null;const i={sku:n,name:r},o=re(e.brand);o&&(i.brand=o);const s=re(e.url);s&&(i.url=s);const c=ks(e.images);if(c.length>0)i.images=c;else{const f=re(e.image,e.image_url,e.imageUrl);f&&(i.images=[f])}const l=At(e.price_discounted);l!==void 0&&(i.price_discounted=l);const g=At(e.price);g!==void 0&&(i.price=g);const d=At(e.rating);d!==void 0&&(i.rating=d);const p=At(e.review_count)??At(e.reviewCount);p!==void 0&&(i.review_count=p);const u=re(e.cart_code,e.cartCode);u&&(i.cart_code=u),typeof e.in_stock=="boolean"&&(i.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(i.in_stock=e.inStock);const b=re(e.discount_reason,e.discountReason);return b&&(i.discount_reason=b),mt(i)}function $e(e,t){const a=Pe(e);if(!a)return null;const n=a.type;if(typeof n!="string"||n.length===0)return null;const r={title:t||n,type:n};return a.payload!==void 0&&(r.payload=a.payload),r}function Pe(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function re(...e){for(const t of e)if(typeof t=="string"){const a=t.trim();if(a.length>0)return a}}function ks(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function bn(e){if(typeof e=="string"){const t=e.trim();return t?[t]:[]}return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim()).filter(t=>t.length>0):[]}function At(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){let t;e.includes(".")&&e.includes(",")?t=e.replace(/\./g,"").replace(",","."):t=e.replace(",",".");const a=Number(t);if(Number.isFinite(a))return a}}function Lt(e){return e!=null}var Cs=new Set(["sku","name","brand","images","price","price_discounted","price_discount_rate","price_currency","discount_reason","url","rating","review_count","cart_code","in_stock","description","description_html","features","specifications","short_name","category_ids","category_names","variants","facet_hits","promotions"]);function mt(e){const t=e.price_discounted!=null&&e.price_discounted>0,a=t?e.price_discounted:e.price,n=t&&e.price!=null?e.price:void 0;let r;n!=null&&a!=null&&n>0?r=Math.round((n-a)/n*100):e.price_discount_rate!=null&&e.price_discount_rate>0&&(r=e.price_discount_rate);const i=re(e.brand),o=re(e.name)??e.sku,s=i&&!o.toLowerCase().startsWith(i.toLowerCase())?`${i} ${o}`:o,c={sku:e.sku,name:s,url:re(e.url)??""},l=e.images?.[0];l&&(c.imageUrl=l),e.images&&e.images.length>1&&(c.images=e.images),a!=null&&a>0&&(c.price=String(a)),n!=null&&n>0&&(c.originalPrice=String(n)),r!==void 0&&(c.discountPercent=r),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),e.description!==void 0&&(c.description=e.description),e.description_html!==void 0&&(c.descriptionHtml=e.description_html),e.features&&e.features.length>0&&(c.features=e.features),e.specifications!==void 0&&(c.specifications=e.specifications),e.facet_hits&&(c.facetHits=e.facet_hits),e.category_names&&e.category_names.length>0&&(c.categoryNames=e.category_names),e.short_name!==void 0&&(c.shortName=e.short_name);const g=e,d={};let p=!1;for(const u of Object.keys(g))Cs.has(u)||(d[u]=g[u],p=!0);return p&&(c.extras=d),c}function Ss(e){const t=e.payload.type,{type:a,...n}=e.payload;return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:t,props:n}}}}}var Es={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"};function Ps(e){if(e===void 0)throw new Error("[gengage] middlewareUrl is required. Pass your Gengage backend URL in widget config.");const t=e.trim();return t===""?"":t.replace(/\/+$/,"")}function Ts(e,t){return`${Ps(t?.middlewareUrl)}/chat${Es[e]}`}function As(e){if(!(typeof window>"u"||!e))try{const t=window.GengageAssistantInjector?.[e]?.streamTransport;return typeof t=="function"?t:void 0}catch{return}}var Ls=7200*1e3,vn=200,Is=5*1024*1024,Ns="gengage_request_response_cache",zs=1,Ge="responses",Ms=new Set(["addToCart","like"]),We=new Map,yn=null;async function Bs(e,t={},a={}){const n=Rs(e,t);if(!n)return fetch(e,t);const r=Date.now(),i=await Os(n,r);if(i)return Hs(i);const o=await fetch(e,t);return o.ok&&Ds(n,o.clone(),r,{ttlMs:a.ttlMs??Ls,maxEntries:a.maxEntries??vn,maxBodyBytes:a.maxBodyBytes??Is}),o}function Rs(e,t={}){if(typeof Request<"u"&&e instanceof Request)return null;const a=String(t.method||"GET").toUpperCase();return a!=="POST"||typeof t.body!="string"||$s(t.body)?null:`rr:${Ws(Gs({url:String(e),method:a,headers:Us(t.headers),body:t.body}))}`}function $s(e){try{const t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return!1;const a=t.type;return typeof a=="string"&&Ms.has(a)}catch{return!1}}async function Os(e,t){const a=We.get(e);if(a)if(a.expiresAt<=t)We.delete(e);else return a.lastAccessedAt=t,We.delete(e),We.set(e,a),xa(a),a;const n=await Zs(e);return n?n.expiresAt<=t?(We.delete(e),qs(e),null):(n.lastAccessedAt=t,We.set(e,n),xa(n),xn(vn),n):null}async function Ds(e,t,a,n){try{const r=await t.text();if(Ks(r)>n.maxBodyBytes||Fs(r))return;const i={key:e,status:t.status,statusText:t.statusText,headers:js(t.headers),body:r,createdAt:a,expiresAt:a+n.ttlMs,lastAccessedAt:a};We.set(e,i),xn(n.maxEntries),await xa(i),await Vs(n.maxEntries,a)}catch{}}function Fs(e){return/"_error"\s*:/u.test(e)||/"type"\s*:\s*"error"/u.test(e)}function Hs(e){return new Response(e.body,{status:e.status,statusText:e.statusText,headers:new Headers(e.headers)})}function Us(e){const t=new Headers(e),a=[];return t.forEach((n,r)=>{const i=r.toLowerCase();i!=="authorization"&&i!=="cookie"&&a.push([i,n])}),a.sort(([n],[r])=>n.localeCompare(r))}function js(e){const t=[];return e.forEach((a,n)=>{const r=n.toLowerCase();r!=="set-cookie"&&t.push([r,a])}),t.sort(([a],[n])=>a.localeCompare(n))}function xn(e){for(;We.size>e;){const t=[...We.values()].sort((a,n)=>a.lastAccessedAt-n.lastAccessedAt)[0];if(!t)break;We.delete(t.key)}}async function Ht(){return typeof indexedDB>"u"?null:(yn??=new Promise(e=>{const t=indexedDB.open(Ns,zs);t.onupgradeneeded=()=>{const a=t.result;a.objectStoreNames.contains(Ge)||a.createObjectStore(Ge,{keyPath:"key"}).createIndex("lastAccessedAt","lastAccessedAt",{unique:!1})},t.onsuccess=()=>e(t.result),t.onerror=()=>e(null),t.onblocked=()=>e(null)}),yn)}async function Zs(e){const t=await Ht();return t?new Promise(a=>{const n=t.transaction(Ge,"readonly"),r=n.objectStore(Ge).get(e);r.onsuccess=()=>a(r.result??null),r.onerror=()=>a(null),n.onerror=()=>a(null)}):null}async function xa(e){const t=await Ht();t&&await new Promise(a=>{const n=t.transaction(Ge,"readwrite");n.objectStore(Ge).put(e),n.oncomplete=()=>a(),n.onerror=()=>a(),n.onabort=()=>a()})}async function qs(e){const t=await Ht();t&&await new Promise(a=>{const n=t.transaction(Ge,"readwrite");n.objectStore(Ge).delete(e),n.oncomplete=()=>a(),n.onerror=()=>a(),n.onabort=()=>a()})}async function Vs(e,t){const a=await Ht();a&&await new Promise(n=>{const r=a.transaction(Ge,"readwrite"),i=r.objectStore(Ge),o=[],s=i.openCursor();s.onsuccess=()=>{const c=s.result;if(!c){const l=o.filter(d=>d.expiresAt<=t),g=o.filter(d=>d.expiresAt>t).sort((d,p)=>d.lastAccessedAt-p.lastAccessedAt).slice(0,Math.max(0,o.length-l.length-e));for(const d of[...l,...g])i.delete(d.key);return}o.push(c.value),c.continue()},s.onerror=()=>n(),r.oncomplete=()=>n(),r.onerror=()=>n(),r.onabort=()=>n()})}function Gs(e){return JSON.stringify(_a(e))}function _a(e){return Array.isArray(e)?e.map(_a):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).sort(([t],[a])=>t.localeCompare(a)).map(([t,a])=>[t,_a(a)]))}function Ws(e){let t=14695981039346656037n;const a=1099511628211n;for(let n=0;n<e.length;n+=1)t^=BigInt(e.charCodeAt(n)),t=BigInt.asUintN(64,t*a);return t.toString(16).padStart(16,"0")}function Ks(e){return typeof TextEncoder<"u"?new TextEncoder().encode(e).byteLength:e.length}function Ys(e,t){const a=e.type,n=e.payload!=null&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:{},r=i=>{const o={...n};for(const[s,c]of Object.entries(i))s in o||(o[s]=c);return o};switch(a){case"user_message":case"inputText":{const i=typeof e.payload=="string",o=i?{text:e.payload}:e.payload!=null&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:n,s={is_launcher:0};if(t.pageContext?.extra&&(s.page_details=t.pageContext.extra),!i&&!("sku_list"in o)){const l=t.pageContext?.skuList&&t.pageContext.skuList.length>0?t.pageContext.skuList:t.pageContext?.sku?[t.pageContext.sku]:void 0;l&&l.length>0&&(s.sku_list=l)}"is_suggested_text"in o||(s.is_suggested_text=0);const c={...o};for(const[l,g]of Object.entries(s))l in c||(c[l]=g);return{...e,payload:c}}case"findSimilar":{const i={is_launcher:0};return e.title&&(i.text=e.title,i.input=e.title),{...e,payload:Ft(r(i))}}case"getComparisonTable":{const i=e.payload;if(i&&typeof i=="object"&&!Array.isArray(i)&&"gengage_analytics_source"in i){const o={...i};return delete o.gengage_analytics_source,{...e,payload:o}}return e}case"launchProductList":return e;case"launchHomepage":return e;case"addToCart":{const i={};return"error_message"in n||(i.error_message=""),{...e,payload:r(i)}}case"reviewSummary":{const i={};return t.pageContext?.sku&&!("sku"in n)&&(i.sku=t.pageContext.sku),Object.keys(i).length===0?e:{...e,payload:r(i)}}default:return e}}var Js={user_message:"inputText"};function _n(e){const{action:t,type:a,payload:n,...r}=e,i=a??t?.type??"inputText",o=n??t?.payload,s=Js[i]??i,c={...r,type:s};return o!==void 0&&(c.payload=typeof o=="string"?{text:o}:o),JSON.stringify(c)}function Xs(e){return JSON.parse(_n(e))}function Qs(e){return e!==null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function wn(e,t){let a=!1;const n=()=>t?.aborted===!0,r=()=>a||n(),i=()=>{r()||(a=!0,e.onDone())};return{fireDone:i,callbacks:{onTextChunk:(...o)=>{r()||e.onTextChunk(...o)},onUISpec:(...o)=>{r()||e.onUISpec(...o)},onAction:o=>{r()||e.onAction(o)},onMetadata:o=>{r()||e.onMetadata(o)},onError:o=>{n()||e.onError(o)},onDone:i}}}function ec(e,t,a){const n=new AbortController,r=a.injectorAdapter??As(a.accountId);return r?((async()=>{const o=wn(t,n.signal);try{if(await Promise.resolve(),n.signal.aborted)return;const s=r(Xs(e),o.callbacks,n.signal,a.attachment);Qs(s)&&(await s,o.fireDone())}catch(s){if(n.signal.aborted||s instanceof DOMException&&s.name==="AbortError")return;o.callbacks.onError(s instanceof Error?s:new Error(String(s)))}})(),n):((async()=>{try{const o=Ts("process_action",a),s=_n(e),c=a.attachment!==void 0;let l;if(c){const p=new FormData;p.append("request",s),a.attachment!==void 0&&p.append("attachment",a.attachment),l={method:"POST",body:p,signal:n.signal}}else l={method:"POST",headers:{"Content-Type":"application/json"},body:s,signal:n.signal};const g=c?await fetch(o,l):await Bs(o,l);if(!g.ok){let p=g.statusText;try{const u=await g.json(),b=u.detail??u.message??u.error;typeof b=="string"&&(p=b)}catch{}t.onError(new Error(`HTTP ${g.status}: ${p}`));return}const d=wn(t);await Mo(g,{onEvent:p=>{const u=Oo(p);if(u)switch(u.type){case"text_chunk":d.callbacks.onTextChunk(u.content,u.final===!0,{productMentions:u.productMentions,skuToProductItem:u.skuToProductItem,conversationMode:u.conversationMode,renderHint:u.renderHint,kvkk:u.kvkk});break;case"ui_spec":d.callbacks.onUISpec(u.spec,u.widget,u.panelHint,u.clearPanel===!0);break;case"action":d.callbacks.onAction(u);break;case"metadata":d.callbacks.onMetadata(u);break;case"error":d.callbacks.onError(new Error(u.message));break;case"done":d.fireDone();break}},onError:t.onError,signal:n.signal}),d.fireDone()}catch(o){if(o instanceof DOMException&&o.name==="AbortError")return;t.onError(o instanceof Error?o:new Error(String(o)))}})(),n)}var tc=["chat_debug","presentation_debug"],ac=["gengage_chat_debug","gengage_presentation_debug"];function nc(){if(typeof window>"u")return!1;const e=new URLSearchParams(window.location.search);if(tc.some(t=>e.get(t)==="1"))return!0;try{return ac.some(t=>window.localStorage.getItem(t)==="1")}catch{return!1}}function rc(e,t,a){if(!nc())return;const n=(window.__gengageChatPresentationDebugSeq??0)+1;window.__gengageChatPresentationDebugSeq=n;const r={seq:n,time:new Date().toISOString(),scope:e,message:t,payload:a};window.__gengageChatPresentationDebugLog||(window.__gengageChatPresentationDebugLog=[]),window.__gengageChatPresentationDebugLog.push(r),window.__gengageChatPresentationDebugLog.length>400&&window.__gengageChatPresentationDebugLog.shift();const i=`[gengage-chat-debug #${n}][${e}] ${t}`;a===void 0?console.debug(i):console.debug(i,a)}var Ut="gengage-chat-scroll",ft=null;function kn(e){ft=e}function ic(){if(ft&&ft.isConnected)return ft;ft=null;const e=document.getElementById(Ut);return e||(rc("chat-scroll","failed to resolve scroll container (not registered)",{id:Ut}),null)}function Cn(){ft=null}var bt={headerTitle:"Ürün Uzmanı",inputPlaceholder:"Ürün ara, soru sor",sendButton:"Gönder",closeButton:"Kapat",openButton:"Sohbeti aç",newChatButton:"Yeni sohbet",poweredBy:"Gengage ile",errorMessage:"Bir hata oluştu. Lütfen tekrar deneyin.",retryButton:"Tekrar Dene",loadingMessage:"İsteğinizi inceliyorum...",loadingSequenceGeneric:["İsteğinizi inceliyorum...","Ürün ve yorumlara bakıyorum...","Detayları inceliyorum..."],loadingSequencePanel:["En ilgili detayları inceliyorum","En güçlü sinyalleri kontrol ediyorum","Bu görünümü sizin için hazırlıyorum"],loadingSequenceComparison:["Ürün farklarını inceliyorum","En güçlü farkları ve ödünleşimleri kontrol ediyorum","Karşılaştırmayı sizin için hazırlıyorum"],productCtaLabel:"Satın Al",viewOnSiteLabel:"Sitede Gör",attachImageButton:"Resim ekle",attachMenuSelectPhoto:"Fotoğraf Seç",attachMenuPaste:"Yapıştır",clipboardNoImageMessage:"Panoda görsel bulunamadı. Önce bir görsel kopyalayın veya dosya seçin.",removeAttachmentButton:"Resmi kaldır",invalidFileType:"Sadece JPEG, PNG ve WebP dosyaları destekleniyor.",fileTooLarge:"Dosya boyutu 5 MB'dan küçük olmalıdır.",aiTopPicksTitle:"Sizin İçin En İyiler",roleWinner:"Size Özel Seçimim",roleBestValue:"En Uygun Fiyatlı",roleBestAlternative:"En İyi Alternatif",viewDetails:"Detayları Gör",groundingReviewCta:"Yorumları Oku",groundingReviewSubtitle:"{count} yorum mevcut",variantsLabel:"Varyantlar",sortRelated:"Önerilen",sortPriceAsc:"Fiyat düşükten yükseğe",sortPriceDesc:"Fiyat yüksekten düşüğe",sortToolbarAriaLabel:"Ürünleri sırala",compareSelected:"Karşılaştır",compareMinHint:"En az 2 ürün seçin",compareMaxHint:"En fazla 5 ürün seçebilirsiniz",comparisonSelectLabel:"Karşılaştırmak için seç",comparisonSelectedLabel:"Seçildi",comparisonSelectCardHint:"Karşılaştırmaya eklemek veya çıkarmak için kartın herhangi bir yerine dokunun.",comparisonPreparingLabel:"Karşılaştırma tablosu hazırlanıyor…",panelTitleProductDetails:"Ürün Detayı",panelTitleSimilarProducts:"Benzer Ürünler",panelTitleComparisonResults:"Karşılaştırma Sonuçları",panelTitleCategories:"Kategoriler",panelTitleSearchResults:"Arama Sonuçları",inStockLabel:"Stokta",outOfStockLabel:"Tükendi",findSimilarLabel:"Benzerlerini Bul",galleryPrevAriaLabel:"Önceki görsel",galleryNextAriaLabel:"Sonraki görsel",beautyStylesPreparedTitle:"Sizin için {count} farklı öneri yönü hazırladım",consultingOtherCompatibleProductsLabel:"Diğer Uyumlu Ürünler",consultingFallbackGroupLabel:"Öneri",consultingFallbackStyleLabel:"Stil {index}",consultingStyleLoadingDescription:"Bu stil için ürünleri toplamaya devam ediyorum. Panel kısa süre içinde yenilenir.",consultingStyleUnavailableDescription:"Bu stil için şu anda yeterli ürün eşleşmesi çıkaramadım. Diğer stilleri inceleyebilirsiniz.",consultingStyleLoadingBadge:"Yükleniyor",consultingStyleUnavailableBadge:"Hazır değil",choicePrompterHeading:"Kararsız mı kaldın?",choicePrompterSuggestion:"Ürünleri seçip karşılaştırabilirsin",choicePrompterCta:"Seç ve Karşılaştır",viewMoreLabel:"Daha Fazla Göster",similarProductsLabel:"Benzer Ürünler",addToCartButton:"Sepete Ekle",addedToCartToast:"Sepete eklendi",shareButton:"Paylaş",productInfoTab:"Ürün Bilgileri",specificationsTab:"Teknik Özellikler",recommendedChoiceLabel:"Önerilen Seçim",highlightsLabel:"Öne Çıkan Özellikler",keyDifferencesLabel:"Temel Farklar",specialCasesLabel:"Özel Durumlar İçin",emptyReviewsMessage:"Yorum özeti bulunamadı.",closeAriaLabel:"Kapat",startChatLabel:"Sohbete Başla",voiceButton:"Sesli giriş",voiceListening:"Dinleniyor...",voiceNotSupported:"Sesli giriş bu tarayıcıda desteklenmiyor.",voicePermissionDenied:"Mikrofon erişimi reddedildi.",voiceError:"Sesli giriş hatası.",handoffHeading:"Destek temsilcisine aktarılıyor",productNotFoundMessage:"Bu ürün bilgisi şu an kullanılamıyor. Başka bir konuda yardımcı olabilirim.",stopGenerating:"Yanıtı Durdur",offlineMessage:"Çevrimdışısınız — bağlantı kurulduğunda mesajlar gönderilecek.",cartAriaLabel:"Sepetim",favoritesAriaLabel:"Favorilerim",historyAriaLabel:"Sohbet geçmişi",historyPageTitle:"Sohbet Geçmişi",emptyHistoryMessage:"Henüz kaydedilmiş sohbet yok.",historyDeleteLabel:"Sohbeti sil",historyDeleteConfirmMessage:"Bu sohbet geçmişten silinsin mi? Bu işlem geri alınamaz.",showPanelAriaLabel:"Sonuçları Göster",addToFavoritesLabel:"Favorilere ekle",customerReviewsTitle:"Müşteri Yorumları",togglePanelAriaLabel:"Paneli aç/kapat",chatMessagesAriaLabel:"Sohbet mesajları",suggestionsAriaLabel:"Öneriler",moreSuggestionsAriaLabel:"Daha fazla öneri",rollbackAriaLabel:"Bu mesaja geri dön",backAriaLabel:"Geri",forwardAriaLabel:"İleri",closePanelAriaLabel:"Paneli kapat",dismissAriaLabel:"Kapat",cartAddErrorMessage:"Üzgünüm sepete ekleyemedim, bir sorunla karşılaştım.",favoriteToggleErrorMessage:"Favoriler güncellenemedi. Lütfen tekrar deneyin.",reviewFilterPositive:"Olumlu",reviewFilterNegative:"Olumsuz",decreaseLabel:"Azalt",increaseLabel:"Artır",reviewCustomersMentionSingular:"1 müşteri bahsediyor",reviewCustomersMentionPlural:"müşteri bahsediyor",reviewSubjectsHeading:"İncelemek için seçin",tryAgainButton:"Tekrar dene",askSomethingElseButton:"Başka bir şey sor",accountInactiveMessage:"Bu hesap şu an aktif değil. Lütfen daha sonra tekrar deneyin.",favoritesPageTitle:"Favorilerim",emptyFavoritesMessage:"Henüz favori ürün yok. Bir ürünü kalp ikonuna tıklayarak favorilere ekleyebilirsin.",showFormerMessagesButton:"↑ Önceki mesajları göster",aiAnalysisAnalyzingLabel:"Ürünler analiz ediliyor...",aiBrowseCategoriesTitle:"Kategorilere Göz At",photoAnalysisBadge:"Cilt Analizi",photoAnalysisStrengthsLabel:"Öne Çıkanlar",photoAnalysisFocusLabel:"Odak Noktaları",photoAnalysisCelebStyleLabel:"Celeb Vibe Eşleşmesi",beautyPhotoStepTitle:"Selfie ile kişiselleştir",beautyPhotoStepDescription:"İstersen net bir profil fotoğrafı yükle, sana özel önerilerde bulunayım.",beautyPhotoStepUpload:"Fotoğraf Yükle",beautyPhotoStepProcessing:"Fotoğraf işleniyor...",beautyPhotoStepSkip:"Geç",beautyPhotoStepSkipMessage:"Fotoğraf adımını geçiyorum"},oc={headerTitle:"Product Expert",inputPlaceholder:"Search products, ask questions",sendButton:"Send",closeButton:"Close",openButton:"Open chat",newChatButton:"New chat",poweredBy:"Powered by Gengage",errorMessage:"Something went wrong. Please try again.",retryButton:"Retry",loadingMessage:"Reviewing your request...",loadingSequenceGeneric:["Reviewing your request...","Looking through products and reviews...","Reviewing the details..."],loadingSequencePanel:["Reviewing the most relevant details","Checking the strongest signals","Preparing this view for you"],loadingSequenceComparison:["Reviewing the product differences","Checking the strongest tradeoffs","Preparing your comparison"],productCtaLabel:"Buy",viewOnSiteLabel:"View on Site",attachImageButton:"Attach image",attachMenuSelectPhoto:"Choose photo",attachMenuPaste:"Paste",clipboardNoImageMessage:"No image found in clipboard. Copy an image first or choose a file.",removeAttachmentButton:"Remove image",invalidFileType:"Only JPEG, PNG and WebP files are supported.",fileTooLarge:"File must be smaller than 5 MB.",aiTopPicksTitle:"Top Picks for You",roleWinner:"Top Pick",roleBestValue:"Best Value",roleBestAlternative:"Best Alternative",viewDetails:"View Details",groundingReviewCta:"Read Reviews",groundingReviewSubtitle:"{count} reviews available",variantsLabel:"Variants",sortRelated:"Recommended",sortPriceAsc:"Price low to high",sortPriceDesc:"Price high to low",sortToolbarAriaLabel:"Sort products",compareSelected:"Compare",compareMinHint:"Select at least 2 products",compareMaxHint:"You can select up to 5 products",comparisonSelectLabel:"Select to compare",comparisonSelectedLabel:"Selected",comparisonSelectCardHint:"Tap anywhere on the card to add or remove it from comparison.",comparisonPreparingLabel:"Preparing your comparison…",panelTitleProductDetails:"Product Details",panelTitleSimilarProducts:"Similar Products",panelTitleComparisonResults:"Comparison Results",panelTitleCategories:"Categories",panelTitleSearchResults:"Search Results",inStockLabel:"In Stock",outOfStockLabel:"Out of Stock",findSimilarLabel:"Find Similar",galleryPrevAriaLabel:"Previous image",galleryNextAriaLabel:"Next image",beautyStylesPreparedTitle:"Prepared {count} recommendation directions for you",consultingOtherCompatibleProductsLabel:"Other compatible products",consultingFallbackGroupLabel:"Recommendation",consultingFallbackStyleLabel:"Style {index}",consultingStyleLoadingDescription:"I am still collecting products for this style. The panel will refresh shortly.",consultingStyleUnavailableDescription:"I could not find enough product matches for this style yet. You can review the other styles.",consultingStyleLoadingBadge:"Loading",consultingStyleUnavailableBadge:"Not ready",choicePrompterHeading:"Can't decide?",choicePrompterSuggestion:"Select products to compare them",choicePrompterCta:"Select & Compare",viewMoreLabel:"Show More",similarProductsLabel:"Similar Products",addToCartButton:"Add to Cart",addedToCartToast:"Added to cart",shareButton:"Share",productInfoTab:"Product Info",specificationsTab:"Specifications",recommendedChoiceLabel:"Recommended Choice",highlightsLabel:"Key Highlights",keyDifferencesLabel:"Key Differences",specialCasesLabel:"For Special Cases",emptyReviewsMessage:"No review summary found.",closeAriaLabel:"Close",startChatLabel:"Start Chat",voiceButton:"Voice input",voiceListening:"Listening...",voiceNotSupported:"Voice input is not supported in this browser.",voicePermissionDenied:"Microphone access denied.",voiceError:"Voice input error.",handoffHeading:"Transferring to a support agent",productNotFoundMessage:"Product information is currently unavailable. I can help with something else.",stopGenerating:"Stop generating",offlineMessage:"You're offline — messages will send when you reconnect.",cartAriaLabel:"My cart",favoritesAriaLabel:"My favorites",historyAriaLabel:"Chat history",historyPageTitle:"Chat History",emptyHistoryMessage:"You don't have any saved chats yet.",historyDeleteLabel:"Delete chat",historyDeleteConfirmMessage:"Delete this chat from history? This cannot be undone.",showPanelAriaLabel:"Show Results",addToFavoritesLabel:"Add to favorites",customerReviewsTitle:"Customer Reviews",togglePanelAriaLabel:"Toggle panel",chatMessagesAriaLabel:"Chat messages",suggestionsAriaLabel:"Suggestions",moreSuggestionsAriaLabel:"More suggestions",rollbackAriaLabel:"Rollback to this message",backAriaLabel:"Back",forwardAriaLabel:"Forward",closePanelAriaLabel:"Close panel",dismissAriaLabel:"Dismiss",cartAddErrorMessage:"Sorry, I couldn't add that to your cart. Something went wrong.",favoriteToggleErrorMessage:"We couldn't update favorites. Please try again.",reviewFilterPositive:"Positive",reviewFilterNegative:"Negative",decreaseLabel:"Decrease",increaseLabel:"Increase",reviewCustomersMentionSingular:"1 customer mentions",reviewCustomersMentionPlural:"customers mention",reviewSubjectsHeading:"Select to learn more",tryAgainButton:"Try again",askSomethingElseButton:"Ask something else",accountInactiveMessage:"This account is currently inactive. Please try again later.",favoritesPageTitle:"My Favorites",emptyFavoritesMessage:"No favorites yet. Heart a product to save it here.",showFormerMessagesButton:"↑ Show earlier messages",aiAnalysisAnalyzingLabel:"Analyzing products...",aiBrowseCategoriesTitle:"Browse categories",photoAnalysisBadge:"Skin Analysis",photoAnalysisStrengthsLabel:"Your strengths",photoAnalysisFocusLabel:"Focus points",photoAnalysisCelebStyleLabel:"Celeb style match",beautyPhotoStepTitle:"Personalize with a selfie",beautyPhotoStepDescription:"Upload a clear profile photo so I can give you personalized recommendations.",beautyPhotoStepUpload:"Upload Photo",beautyPhotoStepProcessing:"Processing photo...",beautyPhotoStepSkip:"Skip",beautyPhotoStepSkipMessage:"Skip the photo step"};function sc(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function cc(e){return sc(e)==="en"?oc:bt}function lc(){return Sn()!==null}function Sn(){const e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition??null}var gc=class{constructor(e,t){this.recognition=null,this._state="idle",this.silenceTimer=null,this.accumulatedTranscript="",this.intentionalStop=!1,this._lastRestartAt=0,this.callbacks=e,this.lang=t?.lang??"tr-TR",this.silenceTimeoutMs=t?.silenceTimeoutMs??1500,this.autoSubmit=t?.autoSubmit??!0}get state(){return this._state}start(){if(this._state==="listening")return;const e=Sn();if(!e){this.setState("error"),this.callbacks.onError?.("not-supported","Web Speech API is not supported in this browser.");return}if(typeof globalThis.isSecureContext<"u"&&!globalThis.isSecureContext){this.setState("error"),this.callbacks.onError?.("not-allowed","Voice input requires HTTPS.");return}this.accumulatedTranscript="",this.intentionalStop=!1;const t=new e;t.continuous=!0,t.interimResults=!0,t.lang=this.lang,t.maxAlternatives=1,t.onstart=()=>{this.setState("listening")},t.onresult=a=>{this.clearSilenceTimer();let n="",r="";for(let i=a.resultIndex;i<a.results.length;i++){const o=a.results[i];if(!o)continue;const s=o[0];s&&(o.isFinal?r+=s.transcript:n+=s.transcript)}r&&(this.accumulatedTranscript+=r,this.callbacks.onFinal?.(this.accumulatedTranscript)),n&&this.callbacks.onInterim?.(this.accumulatedTranscript+n),this.autoSubmit&&this.accumulatedTranscript&&this.startSilenceTimer()},t.onerror=a=>{const n=dc(a.error);this.intentionalStop&&(a.error==="no-speech"||a.error==="aborted")||(this.setState("error"),this.callbacks.onError?.(n,a.message||a.error))},t.onend=()=>{if(this.clearSilenceTimer(),this._state==="listening"&&!this.intentionalStop){const a=Date.now();if(a-this._lastRestartAt<500){this.setState("idle");return}this._lastRestartAt=a;try{t.start()}catch{this.setState("idle")}return}this.setState("idle")},this.recognition=t;try{t.start()}catch{this.setState("error"),this.callbacks.onError?.("unknown","Failed to start speech recognition.")}}stop(){if(this.intentionalStop=!0,this.clearSilenceTimer(),this.recognition){try{this.recognition.stop()}catch{}this.recognition=null}return this.setState("idle"),this.accumulatedTranscript}abort(){if(this.intentionalStop=!0,this.clearSilenceTimer(),this.accumulatedTranscript="",this.recognition){try{this.recognition.abort()}catch{}this.recognition=null}this.setState("idle")}destroy(){this.abort()}setState(e){this._state!==e&&(this._state=e,this.callbacks.onStateChange?.(e))}startSilenceTimer(){this.clearSilenceTimer(),this.silenceTimer=setTimeout(()=>{const e=this.stop();e.trim()&&this.callbacks.onAutoSubmit?.(e.trim())},this.silenceTimeoutMs)}clearSilenceTimer(){this.silenceTimer!==null&&(clearTimeout(this.silenceTimer),this.silenceTimer=null)}};function dc(e){switch(e){case"not-allowed":return"not-allowed";case"no-speech":return"no-speech";case"audio-capture":return"no-microphone";case"network":return"network";case"aborted":return"aborted";default:return"unknown"}}function pc(e){const t=document.createElement("div");t.className="gengage-chat-kvkk-banner gds-evidence-card gds-evidence-card-warning",t.dataset.gengagePart="kvkk-banner",t.setAttribute("role","alert");const a=document.createElement("div");a.className="gengage-chat-kvkk-content",a.dataset.gengagePart="kvkk-content",a.innerHTML=Le(e.htmlContent),t.appendChild(a);const n=document.createElement("button");return n.className="gengage-chat-kvkk-dismiss",n.dataset.gengagePart="kvkk-dismiss",n.type="button",n.setAttribute("aria-label",e.closeAriaLabel??"Close privacy notice"),n.textContent="×",n.addEventListener("click",e.onDismiss),t.appendChild(n),t}var hc=class{constructor(e){this._el=document.createElement("div"),this._el.className="gengage-chat-panel-topbar gds-toolbar",this._el.dataset.gengagePart="panel-topbar",this._backBtn=document.createElement("button"),this._backBtn.className="gengage-chat-panel-topbar-back gds-btn gds-btn-ghost gds-icon-btn",this._backBtn.dataset.gengagePart="panel-topbar-back",this._backBtn.type="button",this._backBtn.disabled=!0,this._backBtn.setAttribute("aria-label",e.backAriaLabel??"Back"),this._backBtn.title=e.backAriaLabel??"Back",this._backBtn.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m15 18-6-6 6-6"/><path d="M21 12H9"/></svg>',this._backBtn.addEventListener("click",()=>e.onBack());const t=document.createElement("div");t.className="gengage-chat-panel-topbar-title-wrap",this._titleEl=document.createElement("span"),this._titleEl.className="gengage-chat-panel-topbar-title",this._titleEl.dataset.gengagePart="panel-topbar-title",t.appendChild(this._titleEl),this._forwardBtn=document.createElement("button"),this._forwardBtn.className="gengage-chat-panel-topbar-forward gds-btn gds-btn-ghost gds-icon-btn",this._forwardBtn.dataset.gengagePart="panel-topbar-forward",this._forwardBtn.type="button",this._forwardBtn.disabled=!0,this._forwardBtn.setAttribute("aria-label",e.forwardAriaLabel??"Forward"),this._forwardBtn.title=e.forwardAriaLabel??"Forward",this._forwardBtn.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 18 6-6-6-6"/><path d="M3 12h12"/></svg>',this._forwardBtn.addEventListener("click",()=>e.onForward()),this._actionsEl=document.createElement("div"),this._actionsEl.className="gengage-chat-panel-topbar-actions",this._actionsEl.dataset.gengagePart="panel-topbar-actions",this._closeBtn=document.createElement("button"),this._closeBtn.className="gengage-chat-panel-topbar-close gds-btn gds-btn-ghost gds-icon-btn",this._closeBtn.dataset.gengagePart="panel-topbar-close",this._closeBtn.type="button",this._closeBtn.setAttribute("aria-label",e.closePanelAriaLabel??"Close panel"),this._closeBtn.title=e.closePanelAriaLabel??"Close panel",this._closeBtn.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',this._closeBtn.addEventListener("click",()=>e.onClose?.()),this._el.appendChild(this._backBtn),this._el.appendChild(t),this._el.appendChild(this._actionsEl),this._el.appendChild(this._forwardBtn),this._el.appendChild(this._closeBtn)}update(e,t,a){this._backBtn.disabled=!e,this._forwardBtn.disabled=!t,this._backBtn.hidden=!e,this._forwardBtn.hidden=!t,this._titleEl.textContent=a,this._titleEl.title=a}getElement(){return this._el}setTitle(e){this._titleEl.textContent=e}setActions(e){this._actionsEl.replaceChildren(),e&&this._actionsEl.appendChild(e)}getTitle(){return this._titleEl.textContent??""}};function uc(e){return{processing:e.processing===!0,title:typeof e.title=="string"?e.title:void 0,description:typeof e.description=="string"?e.description:void 0,uploadLabel:typeof e.upload_label=="string"?e.upload_label:void 0,skipLabel:typeof e.skip_label=="string"?e.skip_label:void 0}}function En(e,t,a){const n=e.props??{},r=n.processing===!0,i={...bt,...t.i18n??{}},o=document.createElement("div");o.className="gengage-chat-beauty-photo-step-card";const s=document.createElement("span");s.className="gengage-chat-beauty-photo-step-icon",s.setAttribute("aria-hidden","true"),s.textContent="✦";const c=document.createElement("div");c.className="gengage-chat-beauty-photo-step-content";const l=document.createElement("div");l.className="gengage-chat-beauty-photo-step-title",l.textContent=(typeof n.title=="string"?n.title:void 0)??i.beautyPhotoStepTitle;const g=document.createElement("p");g.className="gengage-chat-beauty-photo-step-desc",g.textContent=(typeof n.description=="string"?n.description:void 0)??i.beautyPhotoStepDescription;const d=document.createElement("div");d.className="gengage-chat-beauty-photo-step-actions";const p=document.createElement("button");p.type="button",p.className="gengage-chat-beauty-photo-step-upload gds-btn gds-btn-primary",p.textContent=r?i.beautyPhotoStepProcessing:(typeof n.upload_label=="string"?n.upload_label:void 0)??i.beautyPhotoStepUpload,p.disabled=r,a?.onUpload&&p.addEventListener("click",()=>a.onUpload());const u=document.createElement("button");return u.type="button",u.className="gengage-chat-beauty-photo-step-skip gds-btn gds-btn-ghost",u.textContent=(typeof n.skip_label=="string"?n.skip_label:void 0)??i.beautyPhotoStepSkip,a?.onSkip&&u.addEventListener("click",()=>a.onSkip()),d.appendChild(p),d.appendChild(u),c.appendChild(l),c.appendChild(g),c.appendChild(d),o.appendChild(s),o.appendChild(c),o}function mc(e,t){if(e)return e;const a=document.createElement("section");a.className="gengage-chat-beauty-photo-step",a.dataset.gengagePart="chat-beauty-photo-step",a.hidden=!0;const n=t?.querySelector(".gengage-chat-input-area");return n?n.parentElement?.insertBefore(a,n):t?.appendChild(a),a}function fc(e,t,a,n,r){if(!a.visible)return e&&(e.hidden=!0,e.innerHTML=""),e;const i=mc(e,t);i.hidden=!1,i.innerHTML="";const o=En({type:"BeautyPhotoStep",props:{processing:a.processing??!1,title:a.title,description:a.description,upload_label:a.uploadLabel,skip_label:a.skipLabel}},{i18n:n,onAction:()=>{}},{onUpload:r,onSkip:a.onSkip});return i.appendChild(o),i}function Pn(e){const t=typeof e.summary=="string"?e.summary:"",a=Array.isArray(e.strengths)?e.strengths.filter(c=>typeof c=="string"):[],n=Array.isArray(e.focus_points)?e.focus_points.filter(c=>typeof c=="string"):[];if(!t&&a.length===0&&n.length===0)return null;const r={summary:t},i=typeof e.celeb_style=="string"?e.celeb_style:void 0,o=typeof e.celeb_style_reason=="string"?e.celeb_style_reason:void 0,s=typeof e.next_question=="string"?e.next_question:void 0;return a.length>0&&(r.strengths=a),n.length>0&&(r.focusPoints=n),i&&(r.celebStyle=i),o&&(r.celebStyleReason=o),s&&(r.nextQuestion=s),r}function Tn(e,t,a){if(t.length===0)return null;const n=document.createElement("section");n.className=`gengage-chat-photo-analysis-section ${a}`;const r=document.createElement("h4");r.className="gengage-chat-photo-analysis-section-title",r.textContent=e;const i=document.createElement("ul");i.className="gengage-chat-photo-analysis-section-list";for(const o of t){const s=document.createElement("li");s.className="gengage-chat-photo-analysis-section-item",s.textContent=o,i.appendChild(s)}return n.appendChild(r),n.appendChild(i),n}function An(e,t){const a=document.createElement("div");a.className="gengage-chat-photo-analysis-card";const n=document.createElement("div");n.className="gengage-chat-photo-analysis-badge",n.textContent=e.badge;const r=document.createElement("div");if(r.className="gengage-chat-photo-analysis-body",t.summary){const c=document.createElement("p");c.className="gengage-chat-photo-analysis-summary",c.textContent=t.summary,r.appendChild(c)}const i=document.createElement("div");i.className="gengage-chat-photo-analysis-highlights";const o=Tn(e.strengths,t.strengths??[],"gengage-chat-photo-analysis-section--strengths"),s=Tn(e.focus,t.focusPoints??[],"gengage-chat-photo-analysis-section--focus");if(o&&i.appendChild(o),s&&i.appendChild(s),i.childElementCount>0&&r.appendChild(i),t.celebStyle){const c=document.createElement("section");c.className="gengage-chat-photo-analysis-section gengage-chat-photo-analysis-section--celeb";const l=document.createElement("h4");l.className="gengage-chat-photo-analysis-section-title",l.textContent=e.celebStyle;const g=document.createElement("p");if(g.className="gengage-chat-photo-analysis-celeb-name",g.textContent=t.celebStyle,c.appendChild(l),c.appendChild(g),t.celebStyleReason){const d=document.createElement("p");d.className="gengage-chat-photo-analysis-celeb-reason",d.textContent=t.celebStyleReason,c.appendChild(d)}r.appendChild(c)}if(t.nextQuestion){const c=document.createElement("p");c.className="gengage-chat-photo-analysis-next",c.textContent=t.nextQuestion,r.appendChild(c)}return a.appendChild(n),a.appendChild(r),a}function bc(e){const t={...bt,...e?.i18n??{}};return{badge:t.photoAnalysisBadge,strengths:t.photoAnalysisStrengthsLabel,focus:t.photoAnalysisFocusLabel,celebStyle:t.photoAnalysisCelebStyleLabel}}function vc(e,t){const a=Pn(e.props??{})??{summary:""};return An(bc(t),a)}function yc(e,t,a){e.innerHTML="",a&&e.appendChild(An(t,a))}var Ln='<svg viewBox="0 0 16 16" class="gengage-chat-icon"><path d="M3 8h10M9 4l4 4-4 4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',In={search:'<svg viewBox="0 0 16 16" class="gengage-chat-icon"><circle cx="6.5" cy="6.5" r="5" fill="none" stroke="currentColor" stroke-width="1.5"/><line x1="10" y1="10" x2="15" y2="15" stroke="currentColor" stroke-width="1.5"/></svg>',review:'<svg viewBox="0 0 16 16" class="gengage-chat-icon"><polygon points="8,1 10,6 15,6 11,9 12.5,14 8,11 3.5,14 5,9 1,6 6,6" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>',info:'<svg viewBox="0 0 16 16" class="gengage-chat-icon"><circle cx="8" cy="8" r="7" fill="none" stroke="currentColor" stroke-width="1.5"/><line x1="8" y1="7" x2="8" y2="12" stroke="currentColor" stroke-width="1.5"/><circle cx="8" cy="4.5" r="0.8" fill="currentColor"/></svg>',similar:'<svg viewBox="0 0 16 16" class="gengage-chat-icon"><rect x="1" y="3" width="6" height="6" rx="1" fill="none" stroke="currentColor" stroke-width="1.5"/><rect x="9" y="3" width="6" height="6" rx="1" fill="none" stroke="currentColor" stroke-width="1.5"/></svg>'},xc=bt,_c=1400,Nn=1500,wc=/data:image\/(png|jpeg|jpg|webp);base64,[A-Za-z0-9+/=]+/gi;async function kc(e){for(const t of e)for(const a of t.types)if(a.startsWith("image/"))try{const n=await t.getType(a);if(!n||n.size===0)continue;const r=a||n.type||"image/png",i=r==="image/png"?"png":r==="image/webp"?"webp":"jpg",o=`paste-${Date.now()}.${i}`;return new File([n],o,{type:r})}catch{continue}for(const t of e)if(t.types.includes("text/html"))try{const a=(await(await t.getType("text/html")).text()).match(wc)?.[0];if(!a||a.length>5e6)continue;const n=await(await fetch(a)).blob();if(!n||n.size===0)continue;const r=n.type||"image/png";if(!["image/jpeg","image/png","image/webp"].includes(r))continue;const i=r==="image/png"?"png":r==="image/webp"?"webp":"jpg";return new File([n],`paste-${Date.now()}.${i}`,{type:r})}catch{continue}return null}async function Cc(e){try{const t=e??(typeof navigator.clipboard?.read=="function"?navigator.clipboard.read():null);return t?kc(await t):null}catch{}return null}var Sc=class{_renderPhotoAnalysisCard(e,t){yc(e,{badge:this.i18n.photoAnalysisBadge,strengths:this.i18n.photoAnalysisStrengthsLabel,focus:this.i18n.photoAnalysisFocusLabel,celebStyle:this.i18n.photoAnalysisCelebStyleLabel},t)}constructor(e,t){this._sendStopHandler=null,this._panelVisible=!1,this._panelCollapsed=!1,this._onPanelToggle=void 0,this._onHostShellSync=void 0,this._pendingAttachment=null,this._onAttachment=void 0,this._onRollback=void 0,this._onLinkClick=void 0,this._userScrolledUp=!1,this._scrollLockedUntil=0,this._favBadgeEl=null,this._thinkingSteps=[],this._firstBotMessageIds=new Set,this._voiceInput=null,this._micBtn=null,this._voiceEnabled=!1,this._voiceLang="tr-TR",this._ignoreNextDividerClick=!1,this._cleanups=[],this._focusTrapHandler=null,this._previouslyFocusedElement=null,this._conversationEl=null,this._reopenPanelBtn=null,this._presentationFocusThreadId=null,this._formerMessagesBtn=null,this._programmaticScrollUntil=0,this._userInteractionUntil=0,this._touchStartY=null,this._presentationPinned=!0,this._presentationUserInteracting=!1,this._resizeRafId=null,this._cartBtn=null,this._attachWrapEl=null,this._attachMenuEl=null,this._attachBtn=null,this._attachMenuCleanup=null,this._attachMenuClickTimerId=null,this._typingLoadingBinding=null,this._panelLoadingBinding=null,this._panelAiZoneLoadingBinding=null,this._beautyPhotoStepEl=null,this._options=t,this.i18n={...xc,...t.i18n},this.onSend=t.onSend,t.onPanelToggle!==void 0&&(this._onPanelToggle=t.onPanelToggle),t.onHostShellSync!==void 0&&(this._onHostShellSync=t.onHostShellSync),t.onAttachment!==void 0&&(this._onAttachment=t.onAttachment),t.onRollback!==void 0&&(this._onRollback=t.onRollback),t.onLinkClick!==void 0&&(this._onLinkClick=t.onLinkClick),t.voiceEnabled&&(this._voiceEnabled=!0),t.voiceLang!==void 0&&(this._voiceLang=t.voiceLang),this.root=document.createElement("div"),this.root.className="gengage-chat-drawer gds-panel",this.root.dataset.gengagePart="chat-drawer",this.root.setAttribute("role","dialog"),this.root.setAttribute("aria-label",this.i18n.headerTitle??"Chat"),this.root.setAttribute("aria-modal","true");const a="gengage-chat-dialog-desc",n=document.createElement("span");n.id=a,n.className="gengage-sr-only",n.textContent=this.i18n.headerTitle??"AI shopping assistant",this.root.appendChild(n),this.root.setAttribute("aria-describedby",a);let r=null;{const C=document.createElement("div");C.className="gengage-chat-drawer-handle",C.dataset.gengagePart="chat-drawer-handle",C.setAttribute("aria-hidden","true"),C.style.pointerEvents="none",r=C}const i=document.createElement("div");i.className="gengage-chat-header gds-shell-header",i.dataset.gengagePart="chat-header";const o=document.createElement("div");o.className="gengage-chat-header-left",o.dataset.gengagePart="chat-header-left";const s=t.headerAvatarUrl??t.launcherImageUrl,c=typeof t.headerAvatarUrl=="string"&&t.headerAvatarUrl.length>0&&t.headerAvatarUrl!==t.launcherImageUrl;if(s){const C=document.createElement("img");C.className="gengage-chat-header-avatar",c&&C.classList.add("gengage-chat-header-avatar--logo"),C.dataset.gengagePart="chat-header-avatar",C.src=s,C.alt=t.headerTitle??"Assistant",o.appendChild(C)}const l=document.createElement("div");l.className="gengage-chat-header-info",l.dataset.gengagePart="chat-header-info";const g=document.createElement("div");g.className="gengage-chat-header-title-row",g.dataset.gengagePart="chat-header-title-row";const d=document.createElement("span");if(d.className="gengage-chat-header-title",d.dataset.gengagePart="chat-header-title",d.textContent=t.headerTitle??this.i18n.headerTitle??"Product Expert",g.appendChild(d),t.headerBadge){const C=document.createElement("span");C.className="gengage-chat-header-badge gds-badge gds-badge-brand",C.dataset.gengagePart="chat-header-badge",C.textContent=t.headerBadge,g.appendChild(C)}l.appendChild(g);const p=document.createElement("a");p.className="gengage-chat-header-powered",p.dataset.gengagePart="chat-header-powered-by",p.href="https://gengage.ai/",p.target="_blank",p.rel="noopener noreferrer",p.innerHTML=`<svg viewBox="0 0 15 15" fill="none" aria-hidden="true"><path d="M15 5.88941C12.2201 5.88941 9.72762 7.14107 8.05571 9.11059H0C2.77991 9.11059 5.27238 7.85893 6.94429 5.88941H15Z" fill="currentColor"/><path d="M9.10964 0C9.10964 2.24394 8.29524 4.30038 6.94429 5.88941C5.27238 7.85962 2.77922 9.11059 0 9.11059V5.88941C3.24802 5.88941 5.89036 3.2465 5.89036 0H9.10964Z" fill="currentColor" fill-opacity="0.68"/><path d="M15 5.88941V9.11059C11.752 9.11059 9.10964 11.7535 9.10964 15H5.89036C5.89036 12.7561 6.70476 10.6996 8.05571 9.11059C9.72762 7.14038 12.2208 5.88941 15 5.88941Z" fill="currentColor" fill-opacity="0.68"/></svg>${this.i18n.poweredBy}`,l.appendChild(p),o.appendChild(l),i.appendChild(o);const u=document.createElement("div");u.className="gengage-chat-header-right",u.dataset.gengagePart="chat-header-actions";{const C=document.createElement("button");C.type="button",C.className="gengage-chat-header-btn gengage-chat-header-btn--reopen-panel gds-btn gds-btn-ghost gds-icon-btn",C.dataset.gengagePart="chat-header-reopen-panel",C.setAttribute("aria-label",this.i18n.showPanelAriaLabel),C.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="9" y1="3" x2="9" y2="21"/></svg>',C.addEventListener("click",()=>this._showMobilePanelFromBtn()),u.appendChild(C),this._reopenPanelBtn=C}if(t.headerCartUrl||t.onCartClick){const C=document.createElement("button");C.type="button",C.className="gengage-chat-header-btn gengage-chat-header-btn--cart gds-btn gds-btn-ghost gds-icon-btn",C.dataset.gengagePart="chat-header-cart",C.setAttribute("aria-label",this.i18n.cartAriaLabel),C.title=this.i18n.cartAriaLabel,C.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="9" cy="21" r="1"/><circle cx="20" cy="21" r="1"/><path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"/></svg>',C.addEventListener("click",()=>t.onCartClick?.()),u.appendChild(C),this._cartBtn=C}if(t.onHistoryClick){const C=document.createElement("button");C.type="button",C.className="gengage-chat-header-btn gengage-chat-header-btn--history gds-btn gds-btn-ghost gds-icon-btn",C.dataset.gengagePart="chat-header-history",C.setAttribute("aria-label",this.i18n.historyAriaLabel),C.title=this.i18n.historyAriaLabel,C.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 8v5l3 2"/><path d="M3.05 11A9 9 0 1 1 5 17.5"/><path d="M3 8v4h4"/></svg>',C.addEventListener("click",()=>t.onHistoryClick?.()),u.appendChild(C)}if(t.onNewChat){const C=document.createElement("button");C.className="gengage-chat-header-btn gengage-chat-new-chat gds-btn gds-btn-ghost gds-icon-btn",C.dataset.gengagePart="chat-header-new-chat",C.type="button",C.setAttribute("aria-label",this.i18n.newChatButton),C.title=this.i18n.newChatButton,C.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>',C.addEventListener("click",()=>t.onNewChat?.()),u.appendChild(C)}const b=document.createElement("button");if(b.className="gengage-chat-close gds-btn gds-btn-ghost gds-icon-btn",b.dataset.gengagePart="chat-header-close",b.type="button",b.setAttribute("aria-label",this.i18n.closeButton),b.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',b.addEventListener("click",t.onClose),t.showHeaderFavorites){const C=document.createElement("button");C.className="gengage-chat-header-btn gengage-chat-header-btn--fav gds-btn gds-btn-ghost gds-icon-btn",C.dataset.gengagePart="chat-header-favorites",C.type="button",C.setAttribute("aria-label",this.i18n.favoritesAriaLabel),C.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>';const T=document.createElement("span");T.className="gengage-chat-header-fav-badge",T.dataset.gengagePart="chat-header-favorites-badge",T.setAttribute("aria-hidden","true"),T.style.display="none",C.appendChild(T),this._favBadgeEl=T,C.addEventListener("click",()=>{t.onFavoritesClick?.()}),u.appendChild(C)}u.appendChild(b),r&&i.insertBefore(r,i.firstChild),i.appendChild(u);{let T=0,$=0,Q=!1;const le=W=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768)||W.target.closest('button, a, input, [role="button"]'))return;const J=W.changedTouches?.[0];J&&(T=J.clientY,$=0,Q=!0,this.root.style.transition="none")},ue=W=>{if(!Q)return;const J=W.changedTouches?.[0];if(!J)return;$=J.clientY-T;const te=(t.getMobileState?.()??"full")==="full"?Math.max(0,$):$;W.preventDefault(),this.root.style.transform=`translateY(${te}px)`},ke=()=>{if(!Q)return;Q=!1;const W=t.getMobileState?.()??"full";let J;$>72?J=W==="full"?"half":"close":$<-72&&W==="half"?J="full":J=W,this.root.style.transition="",J==="close"?(this.root.style.transform="translateY(100%)",setTimeout(()=>{this.root.style.transform="",t.onMobileSnap?.("close")},280)):(this.root.style.transform="",t.onMobileSnap?.(J)),$=0},O=()=>{Q&&(Q=!1,$=0,this.root.style.transition="",this.root.style.transform="")};i.addEventListener("touchstart",le,{passive:!0}),i.addEventListener("touchmove",ue,{passive:!1}),i.addEventListener("touchend",ke,{passive:!0}),i.addEventListener("touchcancel",O,{passive:!0}),this._cleanups.push(()=>{i.removeEventListener("touchstart",le),i.removeEventListener("touchmove",ue),i.removeEventListener("touchend",ke),i.removeEventListener("touchcancel",O)})}const f=document.createElement("div");f.className="gengage-chat-body",f.dataset.gengagePart="chat-body",this._panelEl=document.createElement("div"),this._panelEl.className="gengage-chat-panel gds-panel",this._panelEl.dataset.gengagePart="chat-panel",this._panelTopBar=new hc({onBack:()=>t.onPanelBack?.(),onForward:()=>t.onPanelForward?.(),onClose:()=>{t.getMobileViewport?.()??!1?this.hideMobilePanel():this.clearPanel(),t.onPanelClose?.()},backAriaLabel:this.i18n.backAriaLabel,forwardAriaLabel:this.i18n.forwardAriaLabel,closePanelAriaLabel:this.i18n.closePanelAriaLabel}),this._panelEl.appendChild(this._panelTopBar.getElement());const m=()=>this._updateScrollAffordance();this._panelEl.addEventListener("scroll",m,{passive:!0}),this._cleanups.push(()=>this._panelEl.removeEventListener("scroll",m)),f.appendChild(this._panelEl),this._dividerEl=document.createElement("div"),this._dividerEl.className="gengage-chat-panel-divider gengage-chat-panel-divider--hidden",this._dividerEl.dataset.gengagePart="chat-panel-divider",this._dividerEl.setAttribute("role","separator"),this._dividerEl.setAttribute("aria-label",this.i18n.togglePanelAriaLabel),this._dividerEl.setAttribute("title",this.i18n.togglePanelAriaLabel);const h=document.createElement("button");h.className="gengage-chat-panel-divider-toggle gds-btn gds-btn-ghost",h.dataset.gengagePart="chat-panel-divider-toggle",h.type="button",h.setAttribute("aria-label",this.i18n.togglePanelAriaLabel),h.setAttribute("title",this.i18n.togglePanelAriaLabel),h.textContent="»",h.addEventListener("click",()=>{if(this._ignoreNextDividerClick){this._ignoreNextDividerClick=!1;return}this.togglePanel(),this._onPanelToggle?.()});let I=null,_=null;const y=24,L=C=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768))return;const T=C.changedTouches?.[0];T&&(I=T.clientX,_=T.clientY)},A=C=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768)||I===null||_===null)return;const T=C.changedTouches?.[0];if(!T)return;const $=T.clientX-I,Q=T.clientY-_;if(I=null,_=null,Math.abs(Q)<y||Math.abs(Q)<Math.abs($))return;const le=Q<0;le!==this._panelCollapsed&&(this._ignoreNextDividerClick=!0,this.setPanelCollapsed(le),this._onPanelToggle?.())};this._dividerEl.addEventListener("touchstart",L,{passive:!0}),this._dividerEl.addEventListener("touchend",A,{passive:!0}),this._cleanups.push(()=>{this._dividerEl.removeEventListener("touchstart",L),this._dividerEl.removeEventListener("touchend",A)}),this._dividerEl.appendChild(h),f.appendChild(this._dividerEl);const k=document.createElement("div");k.className="gengage-chat-conversation",k.dataset.gengagePart="chat-conversation",this._conversationEl=k,k.appendChild(i);const E=document.createElement("div");E.className="gengage-chat-offline-bar gds-evidence-card gds-evidence-card-warning",E.dataset.gengagePart="chat-offline-bar",E.setAttribute("role","status"),E.setAttribute("aria-live","polite"),E.textContent=this.i18n.offlineMessage,typeof navigator<"u"&&!navigator.onLine&&E.classList.add("gengage-chat-offline-bar--visible"),k.appendChild(E);const D=()=>E.classList.add("gengage-chat-offline-bar--visible"),X=()=>E.classList.remove("gengage-chat-offline-bar--visible");window.addEventListener("offline",D),window.addEventListener("online",X),this._cleanups.push(()=>{window.removeEventListener("offline",D),window.removeEventListener("online",X)}),this._kvkkSlot=document.createElement("div"),this._kvkkSlot.className="gengage-chat-kvkk-slot",this._kvkkSlot.dataset.gengagePart="chat-kvkk-slot",k.appendChild(this._kvkkSlot),this.messagesEl=document.createElement("div"),this.messagesEl.id=Ut,this.messagesEl.className="gengage-chat-messages",this.messagesEl.dataset.gengagePart="chat-messages",this.messagesEl.setAttribute("role","log"),this.messagesEl.setAttribute("aria-live","polite"),this.messagesEl.setAttribute("aria-atomic","false"),this.messagesEl.setAttribute("aria-label",this.i18n.chatMessagesAriaLabel),kn(this.messagesEl);const ae=document.createElement("button");ae.type="button",ae.className="gengage-chat-former-messages-btn gds-chip",ae.dataset.gengagePart="chat-former-messages-button",ae.textContent=this.i18n.showFormerMessagesButton,ae.setAttribute("aria-label",this.i18n.showFormerMessagesButton),ae.style.display="none",ae.addEventListener("click",()=>{this._options.presentation?.onReleasePresentationFocus?.()}),this.messagesEl.appendChild(ae),this._formerMessagesBtn=ae;const de=()=>{this._userInteractionUntil=Date.now()+2e3};let H=!1;const S=()=>this._options.presentation,B=()=>{H||(H=!0,requestAnimationFrame(()=>{H=!1;const{scrollTop:C,scrollHeight:T,clientHeight:$}=this.messagesEl,Q=T-C-$;this._userScrolledUp=Q>10;const le=this._presentationPinned?Q<96:Q<32,ue=Date.now(),ke=ue<this._programmaticScrollUntil,O=!le&&ue<this._userInteractionUntil,W=ke?!1:O;le!==this._presentationPinned&&(this._presentationPinned=le,S()?.onPinnedToBottomChange?.(le)),W!==this._presentationUserInteracting&&(this._presentationUserInteracting=W,S()?.onUserInteractingChange?.(W))}))};this.messagesEl.addEventListener("scroll",B,{passive:!0}),this._cleanups.push(()=>{this.messagesEl.removeEventListener("scroll",B)});const w=C=>{de(),C.deltaY<-6&&this._presentationFocusThreadId&&this._options.presentation?.onFormerMessagesHint?.()};this.messagesEl.addEventListener("wheel",w,{passive:!0}),this._cleanups.push(()=>this.messagesEl.removeEventListener("wheel",w));const M=C=>{de(),this._touchStartY=C.touches[0]?.clientY??null},K=C=>{de();const T=C.touches[0]?.clientY,$=this._touchStartY;typeof T=="number"&&typeof $=="number"&&T-$>10&&this._presentationFocusThreadId&&this._options.presentation?.onFormerMessagesHint?.()};this.messagesEl.addEventListener("touchstart",M,{passive:!0}),this.messagesEl.addEventListener("touchmove",K,{passive:!0}),this._cleanups.push(()=>{this.messagesEl.removeEventListener("touchstart",M),this.messagesEl.removeEventListener("touchmove",K)}),k.appendChild(this.messagesEl),this._panelFloatingEl=document.createElement("div"),this._panelFloatingEl.className="gengage-chat-panel-float",this._panelFloatingEl.dataset.gengagePart="chat-panel-floating-layer",this._panelEl.appendChild(this._panelFloatingEl),this._resetPanelAiZoneElement(),this._pillsEl=document.createElement("div"),this._pillsEl.className="gengage-chat-pills",this._pillsEl.dataset.gengagePart="chat-suggestion-pills",this._pillsEl.setAttribute("role","toolbar"),this._pillsEl.setAttribute("aria-label",this.i18n.suggestionsAriaLabel),this._pillsEl.style.display="none";const q=document.createElement("div");q.className="gengage-chat-pills-scroll",q.dataset.gengagePart="chat-suggestion-pills-scroll",this._pillsEl.appendChild(q);const F=document.createElement("button");F.className="gengage-chat-pills-arrow gds-btn gds-btn-ghost",F.dataset.gengagePart="chat-suggestion-pills-more",F.type="button",F.setAttribute("aria-label",this.i18n.moreSuggestionsAriaLabel),F.textContent="›",F.addEventListener("click",()=>{q.scrollBy({left:150,behavior:"smooth"})}),this._pillsEl.appendChild(F);let ie=!1;const oe=()=>{ie||(ie=!0,requestAnimationFrame(()=>{ie=!1;const C=q.scrollLeft+q.clientWidth>=q.scrollWidth-4;F.style.display=C?"none":""}))};q.addEventListener("scroll",oe,{passive:!0}),this._cleanups.push(()=>{q.removeEventListener("scroll",oe)}),k.appendChild(this._pillsEl),this._inputChipsEl=document.createElement("div"),this._inputChipsEl.className="gengage-chat-input-chips",this._inputChipsEl.dataset.gengagePart="chat-input-chips",this._inputChipsEl.style.display="none",k.appendChild(this._inputChipsEl);const G=document.createElement("div");G.className="gengage-chat-input-area",G.dataset.gengagePart="chat-input-area",this.inputEl=document.createElement("textarea"),this.inputEl.className="gengage-chat-input",this.inputEl.dataset.gengagePart="chat-input",this.inputEl.rows=1,this.inputEl.placeholder=this.i18n.inputPlaceholder,this.inputEl.addEventListener("input",()=>{this._resizeRafId!==null&&cancelAnimationFrame(this._resizeRafId),this._resizeRafId=requestAnimationFrame(()=>{this._resizeRafId=null,this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,120)}px`}),this._updateSendEnabled()}),this.inputEl.addEventListener("keydown",C=>{C.key==="Enter"&&!C.isComposing&&((this._options.getMobileViewport?.()??window.innerWidth<=768)||!C.shiftKey)&&(C.preventDefault(),this._submit())}),this.inputEl.addEventListener("paste",C=>{const T=C.clipboardData;if(!T)return;let $=null;const Q=T.files?.[0];if(Q&&Q.type.startsWith("image/"))$=Q;else if(T.items?.length)for(let le=0;le<T.items.length;le++){const ue=T.items[le];if(ue?.kind==="file"&&ue.type.startsWith("image/")){const ke=ue.getAsFile();if(ke){$=ke;break}}}$&&(C.preventDefault(),this._routeAttachmentFile($))}),this._fileInput=document.createElement("input"),this._fileInput.type="file",this._fileInput.accept="image/jpeg,image/png,image/webp",this._fileInput.style.display="none",this._fileInput.addEventListener("change",()=>{const C=this._fileInput.files?.[0];C&&this._routeAttachmentFile(C),this._fileInput.value=""});const v=document.createElement("div");v.className="gengage-chat-attach-wrap",v.dataset.gengagePart="chat-attach-wrap",this._attachWrapEl=v;const z=document.createElement("button");this._attachBtn=z,z.className="gengage-chat-attach-btn gds-btn gds-btn-ghost",z.dataset.gengagePart="chat-attach-button",z.type="button",z.setAttribute("aria-label",this.i18n.attachImageButton),z.setAttribute("aria-haspopup","menu"),z.setAttribute("aria-expanded","false"),z.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg>',z.addEventListener("click",C=>{C.stopPropagation(),this._toggleAttachMenu()});const N=document.createElement("div");this._attachMenuEl=N,N.className="gengage-chat-attach-menu gds-menu",N.dataset.gengagePart="chat-attach-menu",N.setAttribute("role","menu"),N.setAttribute("hidden","");const R=document.createElement("button");R.type="button",R.className="gengage-chat-attach-menu-item gds-btn gds-btn-ghost",R.dataset.gengagePart="chat-attach-menu-select-photo",R.setAttribute("role","menuitem"),R.innerHTML=`<span class="gengage-chat-attach-menu-icon" aria-hidden="true"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg></span><span class="gengage-chat-attach-menu-label">${this.i18n.attachMenuSelectPhoto}</span>`,R.addEventListener("click",C=>{C.stopPropagation(),this._closeAttachMenu(),this._fileInput.click()});const U=document.createElement("div");U.className="gengage-chat-attach-menu-sep",U.dataset.gengagePart="chat-attach-menu-separator",U.setAttribute("aria-hidden","true");const j=document.createElement("button");j.type="button",j.className="gengage-chat-attach-menu-item gds-btn gds-btn-ghost",j.dataset.gengagePart="chat-attach-menu-paste",j.setAttribute("role","menuitem"),j.innerHTML=`<span class="gengage-chat-attach-menu-icon" aria-hidden="true"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 2H9a1 1 0 0 0-1 1v1a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V3a1 1 0 0 0-1-1Z"/><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"/><path d="M16 4h2a2 2 0 0 1 2 2v4"/><path d="M21 14H11"/><path d="m15 10-4 4 4 4"/></svg></span><span class="gengage-chat-attach-menu-label">${this.i18n.attachMenuPaste}</span>`,j.addEventListener("click",C=>{C.stopPropagation();const T=typeof navigator.clipboard?.read=="function"?navigator.clipboard.read():void 0;this._pasteImageFromClipboardMenu(T)}),N.appendChild(R),N.appendChild(U),N.appendChild(j),v.appendChild(z),v.appendChild(N),this._previewStrip=document.createElement("div"),this._previewStrip.className="gengage-chat-attachment-preview gengage-chat-attachment-preview--hidden gds-card-soft",this._previewStrip.dataset.gengagePart="chat-attachment-preview";const Z=document.createElement("img");Z.className="gengage-chat-attachment-preview-thumb",Z.dataset.gengagePart="chat-attachment-preview-thumb",Z.alt="",this._previewName=document.createElement("span"),this._previewName.className="gengage-chat-attachment-name",this._previewName.dataset.gengagePart="chat-attachment-preview-name";const ne=document.createElement("button");ne.className="gengage-chat-attachment-remove gds-btn gds-btn-ghost",ne.dataset.gengagePart="chat-attachment-preview-remove",ne.type="button",ne.setAttribute("aria-label",this.i18n.removeAttachmentButton),ne.textContent="×",ne.addEventListener("click",()=>this.clearAttachment()),this._previewStrip.appendChild(Z),this._previewStrip.appendChild(this._previewName),this._previewStrip.appendChild(ne),this.sendBtn=document.createElement("button"),this.sendBtn.className="gengage-chat-send gds-btn gds-btn-primary",this.sendBtn.dataset.gengagePart="chat-send",this.sendBtn.type="button",this.sendBtn.disabled=!0,this.sendBtn.setAttribute("aria-label",this.i18n.sendButton),this.sendBtn.dataset.tooltip=this.i18n.sendButton,this._renderSendButtonIcon("send"),this.sendBtn.addEventListener("click",()=>{if(this._sendStopHandler){const C=this._sendStopHandler;this.hideStopButton(),C();return}this._submit()}),G.addEventListener("dragover",C=>{C.preventDefault(),G.classList.add("gengage-chat-input-area--dragover")}),G.addEventListener("dragleave",()=>{G.classList.remove("gengage-chat-input-area--dragover")}),G.addEventListener("drop",C=>{C.preventDefault(),G.classList.remove("gengage-chat-input-area--dragover");const T=C.dataTransfer?.files[0];T&&this._routeAttachmentFile(T)});const Y=document.createElement("div");Y.className="gengage-chat-input-pill gds-input-shell",Y.dataset.gengagePart="chat-input-shell",Y.appendChild(v),Y.appendChild(this.inputEl),this._voiceEnabled&&lc()&&(this._micBtn=document.createElement("button"),this._micBtn.className="gengage-chat-mic-btn gds-btn gds-btn-ghost",this._micBtn.dataset.gengagePart="chat-mic-button",this._micBtn.type="button",this._micBtn.setAttribute("aria-label",this.i18n.voiceButton),this._micBtn.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" y1="19" x2="12" y2="23"/><line x1="8" y1="23" x2="16" y2="23"/></svg>',this._micBtn.addEventListener("click",()=>this._toggleVoice()),Y.appendChild(this._micBtn),this._voiceInput=new gc({onInterim:C=>{this._resizeRafId!==null&&(cancelAnimationFrame(this._resizeRafId),this._resizeRafId=null),this.inputEl.value=C,this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,120)}px`},onFinal:C=>{this.inputEl.value=C},onAutoSubmit:C=>{this.inputEl.value=C,this._micBtn?.classList.remove("gengage-chat-mic-btn--active"),this._submit()},onStateChange:C=>{C==="listening"?this._micBtn?.classList.add("gengage-chat-mic-btn--active"):this._micBtn?.classList.remove("gengage-chat-mic-btn--active")},onError:(C,T)=>{this._micBtn?.classList.remove("gengage-chat-mic-btn--active")}},{lang:this._voiceLang})),Y.appendChild(this.sendBtn),G.appendChild(this._previewStrip),G.appendChild(this._fileInput),G.appendChild(Y),k.appendChild(G),f.appendChild(k),this._comparisonDockSlotEl=document.createElement("div"),this._comparisonDockSlotEl.className="gengage-chat-comparison-dock-slot",this._comparisonDockSlotEl.dataset.gengagePart="comparison-dock-slot",f.appendChild(this._comparisonDockSlotEl),this.root.appendChild(f),this._setupHorizontalSwipe(k);const he=document.createElement("div");he.className="gengage-chat-footer",he.dataset.gengagePart="chat-footer",he.textContent=this.i18n.poweredBy,this.root.appendChild(he);const we=C=>{C.key==="Escape"&&t.onClose()};this.root.addEventListener("keydown",we),this._cleanups.push(()=>this.root.removeEventListener("keydown",we)),e.appendChild(this.root)}addMessage(e){const t=this._options.renderMessageUISpec?.(e)??null;if(!(e.content||e.attachment||t||e.role==="user"&&this._onRollback))return;const a=document.createElement("div");if(a.className=`gengage-chat-bubble gds-message ${e.role==="assistant"?"gds-message-assistant":"gds-message-user"} gengage-chat-bubble--${e.role}`,a.dataset.gengagePart=e.role==="assistant"?"chat-message-assistant":"chat-message-user",a.setAttribute("role","listitem"),a.dataset.messageId=e.id,e.threadId&&(a.dataset.threadId=e.threadId),this._firstBotMessageIds.has(e.id)&&a.classList.add("gengage-chat-bubble--first"),e.attachment){const n=document.createElement("img");n.className="gengage-chat-attachment-thumb";const r=URL.createObjectURL(e.attachment);n.src=r,n.alt=e.attachment.name,n.addEventListener("load",()=>URL.revokeObjectURL(r),{once:!0}),n.addEventListener("error",()=>URL.revokeObjectURL(r),{once:!0}),a.insertBefore(n,a.firstChild)}if(e.content){const n=document.createElement("div");if(n.className="gengage-chat-bubble-text",n.dataset.gengagePart="chat-message-text",e.role==="assistant"){if(e.renderHint==="photo_analysis"?(a.classList.add("gengage-chat-bubble--photo-analysis"),this._renderPhotoAnalysisCard(n,e.photoAnalysis)):n.innerHTML=Le(e.content),this._onLinkClick){const r=n.querySelectorAll("a[href]");for(const i of r)i.addEventListener("click",o=>{o.preventDefault();const s=i.getAttribute("href");s&&this._onLinkClick?.(s)})}}else n.textContent=e.content;a.appendChild(n)}if(t&&(a.classList.add("gengage-chat-bubble--ui-spec"),e.content||a.classList.add("gengage-chat-bubble--ui-spec-only"),t.classList.add("gengage-chat-bubble-ui-spec"),(t.classList.contains("gengage-chat-panel-restore-card")||t.querySelector(".gengage-chat-panel-restore-card")!==null)&&a.classList.add("gengage-chat-bubble--panel-restore"),a.appendChild(t)),e.role==="user"&&this._onRollback){const n=document.createElement("button");n.className="gengage-chat-rollback-btn gds-btn gds-btn-ghost",n.dataset.gengagePart="chat-message-rollback",n.type="button",n.setAttribute("aria-label",this.i18n.rollbackAriaLabel),n.title=this.i18n.rollbackAriaLabel,n.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="1 4 1 10 7 10"/><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"/></svg>',n.addEventListener("click",r=>{r.stopPropagation(),this._onRollback?.(e.id)}),a.appendChild(n)}this.messagesEl.appendChild(a),this._presentationFocusThreadId&&this._applyPresentationCollapsed(),this._scrollToBottom(e.role==="user")}removeMessageBubble(e){this._firstBotMessageIds.delete(e),this.messagesEl.querySelector(`[data-message-id="${Ee(e)}"]`)?.remove(),this._presentationFocusThreadId&&this._applyPresentationCollapsed()}showTypingIndicator(e,t="auto"){this.removeTypingIndicator();const a=this._thinkingSteps.length>0?this._thinkingSteps.slice(-3):e?[e]:this.i18n.loadingSequenceGeneric,{root:n,binding:r}=this._createLoadingSequence("chat",a,"chat-typing-indicator","gengage-chat-typing");n.dataset.typing="true",this._typingLoadingBinding=r,this.messagesEl.appendChild(n),this.setTypingIndicatorMode(t),this._scrollToBottom(!0)}addThinkingStep(e){const t=e.trim();t&&this._thinkingSteps[this._thinkingSteps.length-1]!==t&&(this._thinkingSteps.push(t),this._thinkingSteps=this._thinkingSteps.slice(-3),this._typingLoadingBinding&&this._applyLoadingSteps(this._typingLoadingBinding,this._thinkingSteps,!0),this._panelLoadingBinding&&this._applyLoadingSteps(this._panelLoadingBinding,this._thinkingSteps,!0),this._panelAiZoneLoadingBinding&&this._applyLoadingSteps(this._panelAiZoneLoadingBinding,this._thinkingSteps,!0))}setThinkingSteps(e){const t=e.map(a=>a.trim()).filter(Boolean).slice(-3);t.length!==0&&(this._thinkingSteps=t,this._typingLoadingBinding&&this._applyLoadingSteps(this._typingLoadingBinding,this._thinkingSteps,!0),this._panelLoadingBinding&&this._applyLoadingSteps(this._panelLoadingBinding,this._thinkingSteps,!0),this._panelAiZoneLoadingBinding&&this._applyLoadingSteps(this._panelAiZoneLoadingBinding,this._thinkingSteps,!0))}removeTypingIndicator(){this._destroyLoadingBinding(this._typingLoadingBinding),this._typingLoadingBinding=null,this.messagesEl.querySelector(".gengage-chat-typing")?.remove(),this._thinkingSteps=[],this.hideStopButton()}setTypingIndicatorMode(e){const t=this.messagesEl.querySelector(".gengage-chat-typing"),a=this._typingLoadingBinding;if(!t||!a)return;const n=e==="auto"?this._panelOwnsProgressSurface()?"presence":"full":e;t.dataset.progressMode!==n&&(t.classList.toggle("gengage-chat-typing--presence",n==="presence"),t.dataset.progressMode=n,n==="presence"?(a.labelEl.setAttribute("aria-hidden","true"),a.labelEl.classList.add("gengage-sr-only"),t.setAttribute("aria-label",this.i18n.loadingMessage)):(a.labelEl.removeAttribute("aria-hidden"),a.labelEl.classList.remove("gengage-sr-only"),t.removeAttribute("aria-label")))}_panelOwnsProgressSurface(){return(this._options.getMobileViewport?.()??window.innerWidth<=768)||!this._panelVisible||this._panelCollapsed?!1:this._panelLoadingBinding!==null||this._panelAiZoneLoadingBinding!==null}showStopButton(e){this._sendStopHandler=e,this.sendBtn.disabled=!1,this.sendBtn.classList.add("gengage-chat-send--stop","gds-btn-secondary"),this.sendBtn.classList.remove("gds-btn-primary"),this.sendBtn.setAttribute("aria-label",this.i18n.stopGenerating),this.sendBtn.dataset.tooltip=this.i18n.stopGenerating,this._renderSendButtonIcon("stop")}hideStopButton(){this._sendStopHandler=null,this.sendBtn.classList.remove("gengage-chat-send--stop","gds-btn-secondary"),this.sendBtn.classList.add("gds-btn-primary"),this.sendBtn.setAttribute("aria-label",this.i18n.sendButton),this.sendBtn.dataset.tooltip=this.i18n.sendButton,this._renderSendButtonIcon("send"),this._updateSendEnabled()}showError(e,t){const a=document.createElement("div");a.className="gengage-chat-error",a.setAttribute("role","alert");const n=document.createElement("span");if(n.textContent=e??this.i18n.errorMessage,a.appendChild(n),t){const r=document.createElement("button");r.className="gengage-chat-error-retry",r.textContent=this.i18n.retryButton??"Retry",r.addEventListener("click",()=>{a.remove(),t()}),a.appendChild(r)}this.messagesEl.appendChild(a),this._scrollToBottom(!0)}showErrorWithRecovery(e,t){this.showError(e),this.setRecoveryPills(t)}showRecoveryPillsOnly(e){this.setRecoveryPills(e)}setRecoveryPills(e){this.setPills([{label:this.i18n.tryAgainButton,onAction:e.onRetry},{label:this.i18n.askSomethingElseButton,onAction:e.onNewQuestion}])}clearMessages(){const e=this._formerMessagesBtn;for(const t of[...this.messagesEl.children])t!==e&&t.remove()}setPills(e){const t=this._pillsEl.querySelector(".gengage-chat-pills-scroll");if(!t)return;for(;t.firstChild;)t.removeChild(t.firstChild);if(e.length===0){this._pillsEl.style.display="none";return}this._pillsEl.style.display="";for(const n of e){const r=document.createElement("button");if(r.className=n.image?"gengage-chat-pill gds-chip gds-chip-active gengage-chat-pill--rich":"gengage-chat-pill gds-chip gds-chip-active",r.type="button",n.icon){const o=In[n.icon]??Ln,s=document.createElement("span");s.className="gengage-chat-pill-icon",s.innerHTML=o,r.appendChild(s)}if(n.image&&De(n.image)){const o=document.createElement("img");o.className="gengage-chat-pill-img",o.src=n.image,o.alt="",r.appendChild(o)}const i=document.createElement("span");if(i.className="gengage-chat-pill-text",i.textContent=n.label,r.appendChild(i),n.description){const o=document.createElement("span");o.className="gengage-chat-pill-desc";const s=`pill-desc-${Math.random().toString(36).slice(2,9)}`;o.id=s,o.textContent=n.description,r.appendChild(o),r.setAttribute("aria-describedby",s)}r.addEventListener("click",()=>n.onAction()),t.appendChild(r)}const a=this._pillsEl.querySelector(".gengage-chat-pills-arrow");a&&requestAnimationFrame(()=>{a.style.display=t.scrollWidth>t.clientWidth?"":"none"})}focusInput(){this.inputEl.focus()}showKvkkBanner(e,t){this._kvkkSlot.innerHTML="";const a=pc({htmlContent:e,onDismiss:t,closeAriaLabel:this.i18n.closeAriaLabel});this._kvkkSlot.appendChild(a)}hideKvkkBanner(){this._kvkkSlot.innerHTML=""}isKvkkBannerVisible(){return this._kvkkSlot.childNodes.length>0}getElement(){return this.root}openAttachmentPicker(){this._fileInput.click()}setAttachmentControlsVisible(e){this._attachWrapEl&&(this._attachWrapEl.style.display=e?"":"none",e||this._closeAttachMenu())}setBeautyPhotoStepCard(e){this._beautyPhotoStepEl=fc(this._beautyPhotoStepEl,this._conversationEl??null,e,this.i18n,()=>this.openAttachmentPicker())}stageAttachment(e){this._pendingAttachment=e,this._previewName.textContent=e.name;const t=this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");t&&(t.src&&t.src.startsWith("blob:")&&URL.revokeObjectURL(t.src),t.src=URL.createObjectURL(e)),this._previewStrip.classList.remove("gengage-chat-attachment-preview--hidden"),this._updateSendEnabled()}clearAttachment(){const e=this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");e?.src&&(URL.revokeObjectURL(e.src),e.src=""),this._pendingAttachment=null,this._previewStrip.classList.add("gengage-chat-attachment-preview--hidden"),this._updateSendEnabled()}_routeAttachmentFile(e){if(this._onAttachment)try{this._onAttachment(e)}catch(t){console.error("[gengage:chat] Attachment callback error:",t)}else this.stageAttachment(e)}_closeAttachMenu(){this._attachMenuEl&&(this._attachMenuEl.setAttribute("hidden",""),this._attachBtn?.setAttribute("aria-expanded","false"),this._attachMenuClickTimerId!==null&&(clearTimeout(this._attachMenuClickTimerId),this._attachMenuClickTimerId=null),this._attachMenuCleanup&&(this._attachMenuCleanup(),this._attachMenuCleanup=null))}_openAttachMenu(){if(!this._attachMenuEl)return;this._attachMenuEl.removeAttribute("hidden"),this._attachBtn?.setAttribute("aria-expanded","true");const e=a=>{this._attachWrapEl?.contains(a.target)||this._closeAttachMenu()},t=a=>{a.key==="Escape"&&(a.stopPropagation(),this._closeAttachMenu())};this._attachMenuClickTimerId=window.setTimeout(()=>{this._attachMenuClickTimerId=null,document.addEventListener("click",e,!0)},0),document.addEventListener("keydown",t,!0),this._attachMenuCleanup=()=>{document.removeEventListener("click",e,!0),document.removeEventListener("keydown",t,!0)}}_toggleAttachMenu(){this._attachMenuEl&&(this._attachMenuEl.hasAttribute("hidden")?this._openAttachMenu():this._closeAttachMenu())}async _pasteImageFromClipboardMenu(e){const t=await Cc(e);if(t){this._routeAttachmentFile(t),this._closeAttachMenu();return}Fe("gengage:global:error",{message:this.i18n.clipboardNoImageMessage,source:"chat"}),this._closeAttachMenu()}getPendingAttachment(){return this._pendingAttachment}setPanelAiZoneState(e,t){if(this._panelAiZoneEl.isConnected&&(this._clearPanelAiZoneState(),e!=="hidden")){if(this._panelAiZoneEl.removeAttribute("hidden"),e==="analyzing"){this._panelAiZoneEl.innerHTML="";const a=[t?.analyzingLabel??this.i18n.aiAnalysisAnalyzingLabel,...this.i18n.loadingSequencePanel],{root:n,binding:r}=this._createLoadingSequence("panel",this._thinkingSteps.length>0?this._thinkingSteps.slice(-3):a,"panel-ai-zone-loading","gengage-chat-panel-ai-zone-inner");this._panelAiZoneLoadingBinding=r,this._panelAiZoneEl.appendChild(n)}else e==="results"&&t?.resultEl&&(this._panelAiZoneEl.innerHTML="",this._panelAiZoneEl.appendChild(t.resultEl));this.setTypingIndicatorMode("auto")}}_clearPanelAiZoneState(){this._destroyLoadingBinding(this._panelAiZoneLoadingBinding),this._panelAiZoneLoadingBinding=null,this._panelAiZoneEl.innerHTML="",this._panelAiZoneEl.setAttribute("hidden",""),this.setTypingIndicatorMode("auto")}_resetPanelAiZoneElement(){this._panelAiZoneEl=document.createElement("div"),this._panelAiZoneEl.className="gengage-chat-panel-ai-zone",this._panelAiZoneEl.setAttribute("hidden","")}_emitHostShellSync(){this.setTypingIndicatorMode("auto"),this._onHostShellSync?.()}_applyPanelCollapsedState(){this._panelEl.classList.toggle("gengage-chat-panel--collapsed",this._panelCollapsed);const e=this._dividerEl.querySelector(".gengage-chat-panel-divider-toggle");e&&(e.textContent=this._panelCollapsed?"«":"»")}_syncPanelTopBarFromContent(e){const t=e.querySelector(".gengage-chat-product-grid-head");if(t){const a=t.querySelector(".gengage-chat-product-grid-head-title"),n=t.querySelector(".gengage-chat-product-grid-head-actions");if(a?.textContent?.trim()){const r=a.textContent.trim();e.dataset.gengagePanelDerivedTitle=r,this._panelTopBar.setTitle(r)}n?(n.classList.add("gengage-chat-panel-topbar-toolbar-host"),this._panelTopBar.setActions(n)):this._panelTopBar.setActions(null),t.remove();return}this._syncPanelTopBarTitleFromContent(e)}_syncPanelTopBarTitleFromContent(e){const t=e.dataset.gengagePanelDerivedTitle;if(t?.trim()){this._panelTopBar.setTitle(t.trim());return}const a=e.querySelector(".gengage-chat-product-details-title, .gengage-chat-product-details-similars-heading, .gengage-chat-ai-top-picks-title")?.textContent?.trim();a&&this._panelTopBar.setTitle(a)}setPanelContent(e,t){this._destroyLoadingBinding(this._panelLoadingBinding),this._panelLoadingBinding=null,t?.preserveAiZone!==!0&&this._clearPanelAiZoneState(),this._panelVisible?this._swapPanelContent(e):(this._panelEl.innerHTML="",this._resetPanelAiZoneElement(),this._panelEl.appendChild(this._panelTopBar.getElement()),this._panelEl.appendChild(this._panelAiZoneEl),this._panelTopBar.setActions(null),this._panelEl.appendChild(e),this._panelEl.appendChild(this._panelFloatingEl)),this._syncPanelTopBarFromContent(e),this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel"),this._panelCollapsed&&this.setPanelCollapsed(!1),this._syncComparisonDockVisibility(),requestAnimationFrame(()=>{this._updateScrollAffordance(),this._smoothScrollPanelListToTop()}),this._reopenPanelBtn&&(this._reopenPanelBtn.style.display="none"),this._emitHostShellSync()}_swapPanelContent(e){this._panelTopBar.setActions(null);const t=this._panelEl.querySelector(".gengage-chat-panel-skeleton");if(t){t.replaceWith(e);return}const a=this.getPanelContentElement();if(a){a.replaceWith(e);return}this._panelEl.insertBefore(e,this._panelFloatingEl)}appendPanelContent(e){this._panelEl.insertBefore(e,this._panelFloatingEl),this._syncPanelTopBarFromContent(this.getPanelContentElement()??e),this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel"),this.setPanelCollapsed(this._panelCollapsed),this._syncComparisonDockVisibility(),this._emitHostShellSync()}getPanelContentElement(){const e=this._panelEl.children;for(let t=0;t<e.length;t++){const a=e[t];if(!(a.classList.contains("gengage-chat-panel-topbar")||a.classList.contains("gengage-chat-panel-ai-zone")||a.classList.contains("gengage-chat-panel-float")))return a}return null}resyncPanelTopBarFromCurrentContent(){const e=this.getPanelContentElement();e&&this._syncPanelTopBarFromContent(e)}isPanelVisible(){return this._panelVisible}hasPanelContent(){return this._panelVisible&&this.getPanelContentElement()!==null}isPanelLoading(){return this._panelEl.querySelector(".gengage-chat-panel-skeleton")!==null}showPanelLoading(e){this._destroyLoadingBinding(this._panelLoadingBinding),this._panelLoadingBinding=null,this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelEl.innerHTML="",this._resetPanelAiZoneElement(),this._panelEl.appendChild(this._panelTopBar.getElement()),this._panelEl.appendChild(this._panelAiZoneEl);const t=document.createElement("div");t.className="gengage-chat-panel-skeleton";const a=e==="comparisonTable"?this.i18n.loadingSequenceComparison:this.i18n.loadingSequencePanel,{root:n,binding:r}=this._createLoadingSequence("panel",this._thinkingSteps.length>0?this._thinkingSteps.slice(-3):a,"panel-loading-status","gengage-chat-panel-loading-status");switch(this._panelLoadingBinding=r,e){case"productDetails":{t.appendChild(n);const i=document.createElement("div");i.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--image",t.appendChild(i);for(let o=0;o<3;o++){const s=document.createElement("div");s.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--text",t.appendChild(s)}break}case"productList":case"groupList":{t.appendChild(n);const i=document.createElement("div");i.className="gengage-chat-panel-skeleton-grid";for(let o=0;o<6;o++){const s=document.createElement("div");s.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--card",i.appendChild(s)}t.appendChild(i);break}case"comparisonTable":{t.classList.add("gengage-chat-panel-skeleton--comparison"),t.appendChild(n);const i=document.createElement("div");i.className="gengage-chat-comparison gengage-chat-comparison--skeleton",i.setAttribute("aria-busy","true");const o=document.createElement("div");o.className="gengage-chat-comparison-recommended";const s=document.createElement("div");s.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-rec-label",o.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-comparison-recommended-body";const l=document.createElement("div");l.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-rec-img",l.setAttribute("aria-hidden","true");const g=document.createElement("div");g.className="gengage-chat-comparison-recommended-info";for(let k=0;k<2;k++){const E=document.createElement("div");E.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-rec-title",k===1&&E.classList.add("gengage-chat-comparison-skeleton-rec-title--short"),g.appendChild(E)}const d=document.createElement("div");d.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-rec-price",g.appendChild(d),c.appendChild(l),c.appendChild(g),o.appendChild(c);const p=document.createElement("div");p.className="gengage-chat-comparison-highlights";const u=document.createElement("div");u.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-hl-label",p.appendChild(u);const b=document.createElement("ul");b.className="gengage-chat-comparison-skeleton-hl-list";for(let k=0;k<3;k++){const E=document.createElement("li"),D=document.createElement("div");D.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-hl-line",k===1&&D.classList.add("gengage-chat-comparison-skeleton-hl-line--medium"),k===2&&D.classList.add("gengage-chat-comparison-skeleton-hl-line--short"),E.appendChild(D),b.appendChild(E)}p.appendChild(b),o.appendChild(p),i.appendChild(o);const f=document.createElement("div");f.className="gengage-chat-comparison-key-differences";const m=document.createElement("div");m.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-kd-heading",f.appendChild(m);const h=document.createElement("div");h.className="gengage-chat-comparison-key-differences-content";for(let k=0;k<4;k++){const E=document.createElement("div");E.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-kd-line",h.appendChild(E)}f.appendChild(h),i.appendChild(f);const I=document.createElement("div");I.className="gengage-chat-comparison-special gengage-chat-comparison-special--skeleton";const _=document.createElement("div");_.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-special-line",I.appendChild(_),i.appendChild(I);const y=document.createElement("div");y.className="gengage-chat-comparison-skeleton-table-wrap";const L=document.createElement("div");L.className="gengage-chat-comparison-skeleton-table-head";const A=document.createElement("div");A.className="gengage-chat-comparison-skeleton-table-corner",L.appendChild(A);for(let k=0;k<3;k++){const E=document.createElement("div");E.className="gengage-chat-comparison-skeleton-table-col";const D=document.createElement("div");D.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-img";const X=document.createElement("div");X.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-name";const ae=document.createElement("div");ae.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-price",E.appendChild(D),E.appendChild(X),E.appendChild(ae),L.appendChild(E)}y.appendChild(L);for(let k=0;k<3;k++){const E=document.createElement("div");E.className="gengage-chat-comparison-skeleton-table-row";const D=document.createElement("div");D.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-label",E.appendChild(D);for(let X=0;X<3;X++){const ae=document.createElement("div");ae.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-cell",E.appendChild(ae)}y.appendChild(E)}i.appendChild(y),t.appendChild(i);break}default:t.appendChild(n);for(let i=0;i<3;i++){const o=document.createElement("div");o.className="gengage-chat-panel-skeleton-block",t.appendChild(o)}break}this._panelEl.appendChild(t),this._panelEl.appendChild(this._panelFloatingEl),this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel"),this._applyPanelCollapsedState(),this._syncComparisonDockVisibility(),this._emitHostShellSync()}updatePanelTopBar(e,t,a){const n=this._options.getMobileViewport?.()??!1;this._panelTopBar.update(n?!0:e,t,a);const r=this.getPanelContentElement();r&&this._syncPanelTopBarTitleFromContent(r)}getPanelTopBarTitle(){return this._panelTopBar.getTitle()}updateFavoritesBadge(e){this._favBadgeEl&&(e>0?(this._favBadgeEl.textContent=e>99?"99+":String(e),this._favBadgeEl.style.display=""):this._favBadgeEl.style.display="none")}clearPanel(){this._destroyLoadingBinding(this._panelLoadingBinding),this._panelLoadingBinding=null,this._destroyLoadingBinding(this._panelAiZoneLoadingBinding),this._panelAiZoneLoadingBinding=null,this._panelEl.innerHTML="",this._resetPanelAiZoneElement(),this._panelEl.appendChild(this._panelTopBar.getElement()),this._panelEl.appendChild(this._panelAiZoneEl),this._panelEl.appendChild(this._panelFloatingEl),this._panelTopBar.setActions(null),this._panelVisible=!1,this._panelEl.classList.remove("gengage-chat-panel--visible","gengage-chat-panel--collapsed"),this.root.classList.remove("gengage-chat-drawer--with-panel"),this._dividerEl.classList.add("gengage-chat-panel-divider--hidden"),this._reopenPanelBtn&&(this._reopenPanelBtn.style.display="none"),this.setComparisonDockContent(null),this._emitHostShellSync()}_syncComparisonDockVisibility(){const e=this._panelVisible&&this._comparisonDockSlotEl.children.length>0;this._comparisonDockSlotEl.classList.toggle("gengage-chat-comparison-dock-slot--panel-visible",e),this._comparisonDockSlotEl.style.display=e?"":"none",this._comparisonDockSlotEl.setAttribute("aria-hidden",e?"false":"true")}setComparisonDockContent(e){this._comparisonDockSlotEl.replaceChildren(),e&&this._comparisonDockSlotEl.appendChild(e),this._syncComparisonDockVisibility()}hideMobilePanel(){this._panelVisible&&(this._panelVisible=!1,this._panelEl.classList.remove("gengage-chat-panel--visible"),this._reopenPanelBtn&&(this._reopenPanelBtn.style.display="flex"),this._syncComparisonDockVisibility(),this._emitHostShellSync())}_showMobilePanelFromBtn(){this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this._reopenPanelBtn&&(this._reopenPanelBtn.style.display="none"),this._syncComparisonDockVisibility(),this._emitHostShellSync())}showMobilePanel(){this._showMobilePanelFromBtn()}expandPanel(){this._panelCollapsed=!1,this._panelEl.classList.remove("gengage-chat-panel--collapsed"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel")),this._syncComparisonDockVisibility(),this._emitHostShellSync()}setForceExpanded(){this._panelCollapsed=!1,this._panelEl.classList.remove("gengage-chat-panel--collapsed"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel")),this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._syncComparisonDockVisibility(),this._emitHostShellSync()}_smoothScrollPanelListToTop(){this._panelEl.scrollTop=0}_getChoicePrompterRevealScrollThreshold(){if(!(this._options.getMobileViewport?.()??window.innerWidth<=768))return 88;const e=this._panelEl.querySelector(".gengage-chat-product-grid--mobile .gengage-chat-product-card, .gengage-chat-product-grid .gengage-chat-product-card"),t=this._panelEl.querySelector(".gengage-chat-product-card"),a=e??t;if(!a)return 88;const n=Math.round(a.getBoundingClientRect().height);return!Number.isFinite(n)||n<=0?88:n}_updateScrollAffordance(){const e=this._panelEl,t=e.scrollTop+e.clientHeight>=e.scrollHeight-10,a=this._getChoicePrompterRevealScrollThreshold();e.classList.toggle("gengage-chat-panel--has-scroll",!t&&e.scrollHeight>e.clientHeight),e.classList.toggle("gengage-chat-panel--scrolled",e.scrollTop>a)}_setupHorizontalSwipe(e){let t=0,a=0;const n=i=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768))return;const o=i.touches[0];o&&(t=o.clientX,a=o.clientY)},r=i=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768))return;const o=i.changedTouches[0];if(!o)return;const s=o.clientX-t,c=o.clientY-a;Math.abs(s)>50&&Math.abs(s)>Math.abs(c)*2&&(this.togglePanel(),this._onPanelToggle?.())};e.addEventListener("touchstart",n,{passive:!0}),e.addEventListener("touchend",r,{passive:!0}),this._cleanups.push(()=>{e.removeEventListener("touchstart",n),e.removeEventListener("touchend",r)})}togglePanel(){this.setPanelCollapsed(!this._panelCollapsed)}isPanelCollapsed(){return this._panelCollapsed}setPanelCollapsed(e){this._panelCollapsed=e,this._applyPanelCollapsedState(),this._emitHostShellSync()}persistPanelState(e){try{const t=`gengage:panel:${e}`;this._panelCollapsed?sessionStorage.setItem(t,"collapsed"):sessionStorage.removeItem(t)}catch{}}restorePanelState(e){try{const t=`gengage:panel:${e}`;if(sessionStorage.getItem(t)==="collapsed")return this._panelCollapsed=!0,!0}catch{}return!1}_createLoadingSequence(e,t,a,n){const r=document.createElement("div");r.className=`${n} gds-progress-loader ${e==="chat"?"gds-progress-loader-chat":"gds-progress-loader-panel"}`,r.dataset.gengagePart=a,r.setAttribute("role","status"),r.setAttribute("aria-live","polite");const i=document.createElement("span");i.className=e==="chat"?"gengage-chat-typing-text gds-progress-label":"gengage-chat-panel-loading-label gds-progress-label",r.appendChild(i);const o=document.createElement("span");o.className=e==="chat"?"gengage-chat-typing-dots gds-progress-dots":"gds-progress-dots",o.setAttribute("aria-hidden","true");for(let c=0;c<3;c++){const l=document.createElement("span");l.className="gds-progress-dot",o.appendChild(l)}r.appendChild(o);const s={labelEl:i,steps:[],index:0,intervalId:null};return this._applyLoadingSteps(s,t),{root:r,binding:s}}_applyLoadingSteps(e,t,a=!1){const n=t.map(i=>i.trim()).filter(Boolean).slice(-3),r=[this.i18n.loadingMessage];e.steps=n.length>0?n:r,this._clearLoadingBindingInterval(e),e.index=a?e.steps.length-1:0,e.labelEl.textContent=e.steps[e.index],!a&&e.steps.length>1&&(e.intervalId=setInterval(()=>{if(e.index>=e.steps.length-1){this._clearLoadingBindingInterval(e);return}e.index+=1,e.labelEl.textContent=e.steps[e.index],e.index>=e.steps.length-1&&this._clearLoadingBindingInterval(e)},_c))}_clearLoadingBindingInterval(e){e?.intervalId&&(clearInterval(e.intervalId),e.intervalId=null)}_destroyLoadingBinding(e){this._clearLoadingBindingInterval(e)}_updateSendEnabled(){if(this._sendStopHandler){this.sendBtn.disabled=!1;return}const e=this.inputEl.value.trim().length>0||this._pendingAttachment!==null;this.sendBtn.disabled=!e}_renderSendButtonIcon(e){this.sendBtn.innerHTML=e==="stop"?'<span class="gengage-chat-send-stop-icon" aria-hidden="true"></span>':'<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/></svg>'}_submit(){const e=this.inputEl.value.trim(),t=this._pendingAttachment;if(this._sendStopHandler){const a=this._sendStopHandler;if(this.hideStopButton(),a(),!e&&!t)return}else if(!e&&!t)return;this.onSend(e,t??void 0),this.inputEl.value="",this.inputEl.style.height="auto",this.clearAttachment(),this._updateSendEnabled()}_toggleVoice(){if(this._voiceInput)if(this._voiceInput.state==="listening"){const e=this._voiceInput.stop();e.trim()&&(this.inputEl.value=e,this._submit())}else this.inputEl.value="",this._voiceInput.start()}lockScrollForRestore(){this._scrollLockedUntil=Date.now()+500}_scrollToBottom(e=!1){!e&&this._userScrolledUp||!e&&this._options.presentation?.shouldBlockSoftAutoScroll?.()||!e&&Date.now()<this._scrollLockedUntil||requestAnimationFrame(()=>{this.messagesEl.scrollTop=this.messagesEl.scrollHeight,this._userScrolledUp=!1})}scrollToBottomIfNeeded(){this._scrollToBottom(!1)}updateBotMessage(e,t,a,n){const r=this.messagesEl.querySelector(`[data-message-id="${Ee(e)}"]`);if(!r)return;let i=r.querySelector(".gengage-chat-bubble-text");i||(i=document.createElement("div"),i.className="gengage-chat-bubble-text",r.appendChild(i)),a==="photo_analysis"?(r.classList.add("gengage-chat-bubble--photo-analysis"),this._renderPhotoAnalysisCard(i,n)):(r.classList.remove("gengage-chat-bubble--photo-analysis"),i.innerHTML=Le(t)),this._scrollToBottom(!1)}markFirstBotMessage(e){this._firstBotMessageIds.add(e);const t=this.messagesEl.querySelector(`[data-message-id="${Ee(e)}"]`);t&&t.classList.add("gengage-chat-bubble--first")}scrollToLastThread(){const e=this.messagesEl.querySelectorAll("[data-thread-id]");if(e.length===0){this._scrollToBottom(!0);return}const t=e[e.length-1].getAttribute("data-thread-id");if(!t){this._scrollToBottom(!0);return}this._programmaticScrollUntil=Date.now()+700;const a=this.messagesEl.querySelector(`[data-thread-id="${Ee(t)}"]`);a?requestAnimationFrame(()=>{a.scrollIntoView({block:"start",behavior:"auto"}),this._userScrolledUp=!1}):this._scrollToBottom(!0)}scrollThreadIntoView(e,t="smooth"){const a=this.messagesEl.querySelectorAll(`[data-thread-id="${Ee(e)}"]`),n=this.messagesEl.ownerDocument.defaultView?.HTMLElement;if(!n)return!1;let r=null,i=null;for(let c=0;c<a.length;c++){const l=a[c];if(l instanceof n&&(i||(i=l),!l.classList.contains("gengage-chat-bubble--presentation-collapsed")&&!l.classList.contains("gengage-chat-bubble--hidden")&&l.offsetHeight!==0&&!(l.classList.contains("gengage-chat-bubble--assistant")&&(l.textContent?.trim().length??0)===0))){r=l;break}}if(r||(r=i),!r)return!1;const o=Date.now();this._programmaticScrollUntil=o+Nn,this._scrollLockedUntil=Math.max(this._scrollLockedUntil,o+Nn),this._userScrolledUp=!0;const s=()=>{this._scrollMessagesTo(Math.max(r.offsetTop-20,0),t)};return s(),requestAnimationFrame(s),!0}scrollToBottomPresentation(e="smooth"){this._programmaticScrollUntil=Date.now()+700,requestAnimationFrame(()=>{this._scrollMessagesTo(this.messagesEl.scrollHeight,e),this._userScrolledUp=!1})}_scrollMessagesTo(e,t){if(typeof this.messagesEl.scrollTo=="function"){this.messagesEl.scrollTo({top:e,behavior:t});return}this.messagesEl.scrollTop=e}setPresentationFocus(e){this._presentationFocusThreadId=e,this._applyPresentationCollapsed()}setFormerMessagesButtonVisible(e){this._formerMessagesBtn&&(this._formerMessagesBtn.style.display=e?"":"none")}setInputPlaceholder(e){this.inputEl.placeholder=e}_applyPresentationCollapsed(){const e=this._presentationFocusThreadId;this.messagesEl.querySelectorAll("[data-thread-id]").forEach(t=>{const a=t.dataset.threadId;a&&(e&&a!==e?t.classList.add("gengage-chat-bubble--presentation-collapsed"):t.classList.remove("gengage-chat-bubble--presentation-collapsed"))})}refreshPresentationCollapsed(){this._presentationFocusThreadId&&this._applyPresentationCollapsed()}setInputAreaChips(e){if(this._inputChipsEl.innerHTML="",e.length===0){this._inputChipsEl.style.display="none";return}this._inputChipsEl.style.display="";for(const t of e){const a=document.createElement("button");if(a.className="gengage-chat-input-chip gds-chip",a.type="button",t.icon){const r=In[t.icon]??Ln,i=document.createElement("span");i.className="gengage-chat-input-chip-icon",i.innerHTML=r,a.appendChild(i)}const n=document.createElement("span");n.textContent=t.label,a.appendChild(n),a.addEventListener("click",()=>t.onAction()),this._inputChipsEl.appendChild(a)}}clearInputAreaChips(){this._inputChipsEl.innerHTML="",this._inputChipsEl.style.display="none"}trapFocus(){this._previouslyFocusedElement=document.activeElement,this.releaseFocus();const e=t=>{if(t.key!=="Tab")return;const a=Array.from(this.root.querySelectorAll('a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(l=>{const g=getComputedStyle(l);return l.hidden||l.getAttribute("aria-hidden")==="true"||g.display==="none"||g.visibility==="hidden"?!1:l.getClientRects().length>0});if(a.length===0)return;const n=a[0],r=a[a.length-1],i=t.composedPath().find(l=>l instanceof HTMLElement&&this.root.contains(l))??null,o=this.root.getRootNode(),s=i??(o instanceof ShadowRoot&&o.activeElement instanceof HTMLElement?o.activeElement:document.activeElement instanceof HTMLElement?document.activeElement:null),c=s&&this.root.contains(s)?s:null;t.shiftKey?(c===n||!this.root.contains(c))&&(t.preventDefault(),r.focus()):(c===r||!this.root.contains(c))&&(t.preventDefault(),n.focus())};this._focusTrapHandler=e,this.root.addEventListener("keydown",e)}releaseFocus(){if(this._focusTrapHandler&&(this.root.removeEventListener("keydown",this._focusTrapHandler),this._focusTrapHandler=null),this._previouslyFocusedElement){try{this._previouslyFocusedElement.focus()}catch{}this._previouslyFocusedElement=null}}flashCartBadge(){this._cartBtn&&(this._cartBtn.classList.remove("gengage-chat-header-btn--cart-flash"),this._cartBtn.offsetWidth,this._cartBtn.classList.add("gengage-chat-header-btn--cart-flash"),this._cartBtn.addEventListener("animationend",()=>{this._cartBtn?.classList.remove("gengage-chat-header-btn--cart-flash")},{once:!0}))}showCartToast(e){this.root.querySelector(".gengage-chat-cart-toast")?.remove();const t=document.createElement("div");t.className="gengage-chat-cart-toast",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.textContent=e,this.root.appendChild(t),t.offsetWidth,t.classList.add("gengage-chat-cart-toast--visible"),setTimeout(()=>{t.classList.remove("gengage-chat-cart-toast--visible"),setTimeout(()=>t.remove(),300)},2500)}destroy(){kn(null),this.releaseFocus(),this._resizeRafId!==null&&(cancelAnimationFrame(this._resizeRafId),this._resizeRafId=null),this._destroyLoadingBinding(this._typingLoadingBinding),this._typingLoadingBinding=null,this._destroyLoadingBinding(this._panelLoadingBinding),this._panelLoadingBinding=null,this._destroyLoadingBinding(this._panelAiZoneLoadingBinding),this._panelAiZoneLoadingBinding=null,this._closeAttachMenu();for(const e of this._cleanups)e();this._cleanups.length=0,this._voiceInput?.destroy(),this._voiceInput=null}},Ec=["shopping","beauty_consulting","account_expert"];function zn(e){return e==="watch_expert"?"account_expert":Ec.includes(e)?e:null}function Pc(e){return typeof e=="string"?zn(e):null}function Ie(e){return e==null||typeof e!="object"||Array.isArray(e)?null:e}function Tc(...e){for(const t of e)if(typeof t=="string"){const a=t.trim();if(a.length>0)return a}}function Ac(e){const t=Ie(e);if(!t)return null;const a=Tc(t.assistant_mode,t.assistantMode);if(!a)return null;const n=zn(a);return!n||n==="shopping"?null:n}function Lc(e){return e==="beauty_consulting"?"user_message":"findSimilar"}var Ic=class{constructor(){this._mode="shopping",this._uiHints=null}get mode(){return this._mode}set mode(e){this._mode=e}get uiHints(){return this._uiHints}set uiHints(e){this._uiHints=e}get isShopping(){return this._mode==="shopping"}get isBeautyConsulting(){return this._mode==="beauty_consulting"}get isChoicePrompterHidden(){return this._uiHints?.hide_choice_prompter===!0}applyUiHints(e,t,a){const n=i=>this._uiHints?.[i]===!0;e?.setAttachmentControlsVisible(!n("hide_attachment_controls")),n("hide_choice_prompter")&&a?.();const r=typeof this._uiHints?.input_placeholder=="string"?this._uiHints.input_placeholder:void 0;r?e?.setInputPlaceholder(r):e?.setInputPlaceholder(t)}handleRedirect(e){Ve("mode","redirect metadata received",e);const t=Ac(e);return t?(this.switchMode(t),!0):!1}switchMode(e){const t=this._mode;this._mode=e,Ve("mode","assistant mode switched",{from:t,to:e})}updateFromContext(e){const t=e.assistant_mode;if(typeof t=="string"&&t){const a=Pc(t);a?this._mode=a:Ve("mode","ignoring unrecognised assistant_mode from context",t)}else t===null&&(this._mode="shopping");this._uiHints=Ie(e.ui_hints)??null}reset(){const e=this._mode!=="shopping";return this._mode="shopping",this._uiHints=null,e}resolveAttachmentActionType(){return Lc(this._mode)}shouldCondenseThinking(){return this._mode!=="shopping"}};function Nc(){return{streamIncludedBeautyPhotoStep:!1,pendingPhotoStepSkip:!1}}function zc(e,t,a,n,r){if(e==="PhotoAnalysisCard"){const i=Pn(t);return i?(r.photoAnalysis=i,r.renderHint="photo_analysis",n.ensureRendered(),n.cancelTypewriter(),n.drawer?.updateBotMessage(r.id,r.content??"","photo_analysis",r.photoAnalysis),!0):(Ve("beauty","PhotoAnalysisCard parse failed, falling through to generic renderer",t),!1)}if(e==="BeautyPhotoStep"){a.streamIncludedBeautyPhotoStep=!0;const i=uc(t);return n.drawer?.setBeautyPhotoStepCard({visible:!0,...i,onSkip:()=>{n.drawer?.setBeautyPhotoStepCard({visible:!1}),n.streamDone?n.sendSkipMessage():a.pendingPhotoStepSkip=!0}}),!0}return!1}function Mc(e){return e.renderHint==="photo_analysis"}function Bc(e,t){e.streamIncludedBeautyPhotoStep||t.drawer?.setBeautyPhotoStepCard({visible:!1}),e.pendingPhotoStepSkip&&(e.pendingPhotoStepSkip=!1,t.sendSkipMessage())}function Rc(e,t){e.pendingPhotoStepSkip&&(e.pendingPhotoStepSkip=!1,t.sendSkipMessage())}function wa(e){return Number.isFinite(e)?Math.max(0,Math.min(5,e)):0}function Mn(e){return Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function Bn(e){const t=wa(e),a=Math.floor(t),n=t-a>=.5,r=5-a-(n?1:0),i=document.createElement("span");if(i.className="gengage-star-rating",i.setAttribute("role","img"),i.setAttribute("aria-label",`${t.toFixed(1)} out of 5 stars`),a>0&&i.appendChild(document.createTextNode("★".repeat(a))),n){const o=document.createElement("span");o.className="gengage-star-half",o.textContent="☆";const s=document.createElement("span");s.textContent="★",o.appendChild(s),i.appendChild(o)}return r>0&&i.appendChild(document.createTextNode("☆".repeat(r))),i}function Be(e){e.addEventListener("error",()=>{e.style.display="none"},{once:!0})}var $c={currencyCode:"TRY",currencySymbol:"TL",currencyPosition:"suffix",thousandsSeparator:".",decimalSeparator:",",alwaysShowDecimals:!1};function se(e,t){const a=Number(e);if(!Number.isFinite(a)||a<0)return e;const n={...$c,...t},r=Math.abs(a%1)<Number.EPSILON,i=n.alwaysShowDecimals||!r?a.toFixed(2):a.toFixed(0),o=i.indexOf("."),s=o===-1?i:i.slice(0,o),c=o===-1?void 0:i.slice(o+1),l=s.replace(/\B(?=(\d{3})+(?!\d))/g,n.thousandsSeparator);let g;return c!==void 0?g=`${l}${n.decimalSeparator}${c}`:g=l,n.currencySymbol?n.currencyPosition==="prefix"?`${n.currencySymbol}${g}`:`${g} ${n.currencySymbol}`:g}var Oc={screen_size:"Screen Size",weight:"Weight",battery_capacity:"Battery Capacity",battery_life:"Battery Life",storage:"Storage",memory:"Memory",ram:"RAM",processor:"Processor",camera:"Camera",resolution:"Resolution",display_type:"Display Type",refresh_rate:"Refresh Rate",color:"Color",material:"Material",dimensions:"Dimensions",warranty:"Warranty",connectivity:"Connectivity",water_resistance:"Water Resistance",operating_system:"Operating System",brand:"Brand",model:"Model",price:"Price",energy_class:"Energy Class",noise_level:"Noise Level",capacity:"Capacity",power:"Power",voltage:"Voltage",width:"Width",height:"Height",depth:"Depth"};function Dc(e,t,a){return t?.[e]??Oc[e]??e.replace(/_/g," ").replace(/^./u,n=>Fc(n,a))}function Fc(e,t){try{return e.toLocaleUpperCase(Tt(t))}catch{return e.toLocaleUpperCase("tr")}}function Rn(e){if(typeof e!="string")return!1;const t=Number(e);return Number.isFinite(t)&&t>0}function Hc(e){const t=typeof e=="number"?e:typeof e=="string"?Number(e):NaN;return Number.isFinite(t)&&t>0}function Uc(e){const t=typeof e=="number"?e:Number(e),a=document.createElement("div");a.className="gengage-chat-comparison-recommended-rating",a.innerHTML='<span class="gengage-chat-comparison-recommended-rating-icon" aria-hidden="true"><svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M12 3.6l2.58 5.23 5.77.84-4.17 4.07.98 5.75L12 16.78l-5.16 2.71.99-5.75L3.66 9.67l5.76-.84L12 3.6z"/></svg></span>';const n=document.createElement("span");return n.className="gengage-chat-comparison-recommended-rating-value",n.textContent=t.toFixed(1),a.appendChild(n),a}function jc(e){const{recommended:t,products:a,attributes:n,highlights:r,specialCases:i,onProductClick:o,i18n:s}=e,c=document.createElement("div");if(c.className="gengage-chat-comparison",c.dataset.gengagePart="comparison-dialog",c.setAttribute("role","dialog"),c.setAttribute("aria-label",s?.comparisonHeading??"Comparison Results"),t){const l=document.createElement("article");l.className="gengage-chat-comparison-recommended gds-card",l.dataset.gengagePart="comparison-recommended-card";const g=document.createElement("div");g.className="gengage-chat-comparison-recommended-label",g.textContent=s?.recommendedChoiceLabel??"Recommended Choice",l.appendChild(g);const d=document.createElement("div");d.className="gengage-chat-comparison-recommended-body",d.classList.add("gds-clickable"),d.tabIndex=0,d.setAttribute("role","button"),d.setAttribute("aria-label",t.name);const p=document.createElement("div");if(p.className="gengage-chat-comparison-recommended-media",t.imageUrl&&De(t.imageUrl)){const h=document.createElement("img");h.src=t.imageUrl,h.alt=t.name,h.loading="lazy",h.addEventListener("error",()=>{h.style.display="none"},{once:!0}),p.appendChild(h)}else{const h=document.createElement("div");h.className="gengage-chat-comparison-recommended-placeholder",h.setAttribute("aria-hidden","true"),p.appendChild(h)}d.appendChild(p);const u=document.createElement("div");u.className="gengage-chat-comparison-recommended-info";const b=document.createElement("div");b.className="gengage-chat-comparison-recommended-title",b.textContent=t.name,u.appendChild(b);const f=document.createElement("div");if(f.className="gengage-chat-comparison-recommended-meta",Hc(t.rating)&&f.appendChild(Uc(t.rating)),Rn(t.price)){const h=document.createElement("div");h.className="gengage-chat-comparison-recommended-price",h.textContent=se(t.price,e.pricing),f.appendChild(h)}if(f.childElementCount>0&&u.appendChild(f),e.recommendedText){const h=document.createElement("p");h.className="gengage-chat-comparison-recommended-text",h.innerHTML=Le(e.recommendedText),u.appendChild(h)}d.appendChild(u);const m=()=>{o({sku:t.sku,name:t.name})};if(d.addEventListener("click",m),d.addEventListener("keydown",h=>{h.key!=="Enter"&&h.key!==" "||(h.preventDefault(),m())}),l.appendChild(d),r.length>0){const h=document.createElement("div");h.className="gengage-chat-comparison-highlights",h.dataset.gengagePart="comparison-highlights";const I=document.createElement("div");I.className="gengage-chat-comparison-highlights-label",I.textContent=s?.highlightsLabel??"Key Highlights",h.appendChild(I);const _=document.createElement("ul");for(const y of r){const L=document.createElement("li");L.textContent=y,_.appendChild(L)}h.appendChild(_),l.appendChild(h)}c.appendChild(l)}if(e.keyDifferencesHtml){const l=document.createElement("details");l.className="gengage-chat-comparison-key-differences",l.dataset.gengagePart="comparison-key-differences";const g=document.createElement("summary");g.className="gengage-chat-comparison-key-differences-summary";const d=document.createElement("span");d.className="gengage-chat-comparison-key-differences-summary-label",d.textContent=s?.keyDifferencesLabel??"Key Differences";const p=document.createElement("span");p.className="gengage-chat-comparison-key-differences-summary-meta",p.textContent=s?.viewMoreLabel??"Show More",g.appendChild(d),g.appendChild(p),l.appendChild(g);const u=document.createElement("div");u.className="gengage-chat-comparison-key-differences-content",u.innerHTML=Le(Zc(e.keyDifferencesHtml)),l.appendChild(u),c.appendChild(l)}if(i&&i.length>0){const l=document.createElement("details");l.className="gengage-chat-comparison-special gds-evidence-card gds-evidence-card-warning",l.dataset.gengagePart="comparison-special-cases";const g=document.createElement("summary");g.textContent=s?.specialCasesLabel??"For Special Cases",l.appendChild(g);const d=document.createElement("ul");for(const p of i)qc(d,p);d.childElementCount>0&&l.appendChild(d),c.appendChild(l)}if(a.length>0&&n.length>0){const l=document.createElement("table");l.className="gengage-chat-comparison-table gds-comparison-table";const g=document.createElement("thead"),d=document.createElement("tr"),p=document.createElement("th");d.appendChild(p);for(const f of a){const m=document.createElement("th");f.sku===t?.sku&&(m.className="gengage-chat-comparison-selected gds-comparison-table-winner-cell");const h=document.createElement("div");h.className="gengage-chat-comparison-table-header-cell gengage-chat-comparison-table-header-cell--clickable gds-clickable",h.tabIndex=0,h.setAttribute("role","button"),h.setAttribute("aria-label",f.name),h.title=f.name;const I=()=>{o({sku:f.sku,name:f.name})};if(h.addEventListener("click",I),h.addEventListener("keydown",y=>{y.key!=="Enter"&&y.key!==" "||(y.preventDefault(),I())}),f.imageUrl&&De(f.imageUrl)){const y=document.createElement("img");y.src=f.imageUrl,y.alt=f.name,y.loading="lazy",y.addEventListener("error",()=>{y.style.display="none"},{once:!0}),h.appendChild(y)}else{const y=document.createElement("div");y.className="gengage-chat-comparison-table-header-img-placeholder",y.setAttribute("aria-hidden","true"),h.appendChild(y)}const _=document.createElement("div");if(_.className="gengage-chat-comparison-table-product-name",_.textContent=f.name,h.appendChild(_),Rn(f.price)){const y=document.createElement("div");y.className="gengage-chat-comparison-table-price",y.textContent=se(f.price,e.pricing),h.appendChild(y)}m.appendChild(h),d.appendChild(m)}g.appendChild(d),l.appendChild(g);const u=document.createElement("tbody");for(const f of n){const m=document.createElement("tr"),h=document.createElement("td");h.className="gengage-chat-comparison-label",h.textContent=Dc(f.label,s?.criteriaLabels,e.locale),m.appendChild(h);for(let I=0;I<f.values.length;I++){const _=document.createElement("td");a[I]?.sku===t?.sku&&(_.className="gengage-chat-comparison-selected gds-comparison-table-winner-cell");const y=f.values[I]??"";$n(y)?_.innerHTML=Le(y):_.textContent=y,m.appendChild(_)}u.appendChild(m)}l.appendChild(u);const b=document.createElement("div");b.className="gengage-chat-comparison-table-wrapper",b.dataset.gengagePart="comparison-table-wrapper",b.appendChild(l),c.appendChild(b)}return c.addEventListener("keydown",l=>{if(l.key!=="Tab")return;const g=c.querySelectorAll('button, [href], input, [tabindex]:not([tabindex="-1"])');if(g.length===0)return;const d=g[0],p=g[g.length-1];l.shiftKey&&document.activeElement===d?(l.preventDefault(),p.focus()):!l.shiftKey&&document.activeElement===p&&(l.preventDefault(),d.focus())}),c}function Zc(e){if(/<[uo]l[\s>]/i.test(e)||/<li[\s>]/i.test(e))return e;const t=e.split(`
49
49
  `).filter(a=>a.trim());return t.length<=1?e:"<ul>"+t.map(a=>`<li>${a.trim()}</li>`).join("")+"</ul>"}function qc(e,t){const a=Le(t);if(!a)return;const n=document.createElement("template");n.innerHTML=a;const r=Array.from(n.content.querySelectorAll("li"));if(r.length>0){for(const o of r){const s=document.createElement("li");s.innerHTML=Le(o.innerHTML),e.appendChild(s)}return}const i=document.createElement("li");$n(t)?i.innerHTML=a:i.textContent=t,e.appendChild(i)}function $n(e){return/<\/?[a-z][\s\S]*>/i.test(e)}function It(e,t=18){const a="http://www.w3.org/2000/svg",n=document.createElementNS(a,"svg");n.setAttribute("width",String(t)),n.setAttribute("height",String(t)),n.setAttribute("viewBox","0 0 24 24"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","2"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.setAttribute("aria-hidden","true");for(const r of e){const i=document.createElementNS(a,"path");i.setAttribute("d",r),n.appendChild(i)}return n}var ka="General",On=220,Vc=6;function Gc(e){if(typeof e!="string")return[ka];const t=e.split(/[,;|/]+/).map(a=>a.trim().replace(/\s+/g," ")).filter(a=>a.length>0);return t.length===0?[ka]:Array.from(new Set(t.map(a=>a.toLocaleLowerCase()))).map(a=>t.find(n=>n.toLocaleLowerCase()===a)??ka)}function Wc(e){return e==="positive"||e==="negative"||e==="neutral"?e:"neutral"}function Kc(e){if(typeof e!="string")return"";const t=e.trim().replace(/\s+/g," ");return t.length<=On?t:`${t.slice(0,On-3).trimEnd()}...`}function Yc(e){return e.positive>e.negative?"positive":e.negative>e.positive?"negative":"neutral"}function Jc(e){return It(e==="positive"?["M7 17 17 7","M7 7h10v10"]:e==="negative"?["M7 7 17 17","M17 7v10H7"]:["M5 12h14"],14)}function Xc(e,t="1 customer mentions",a="customers mention"){return e===1?t:`${e} ${a}`}function Qc(e,t){const a=document.createElement("div");a.className="gengage-chat-review-highlights";const n=e.props?.reviews;if(!Array.isArray(n)||n.length===0){const f=document.createElement("div");return f.className="gengage-chat-review-empty",f.textContent=t?.emptyReviewsMessage??"No review summary found.",a.appendChild(f),a}const r=n.filter(f=>f!==null&&typeof f=="object"),i=new Map;for(const f of r){const m=Wc(f.review_class),h=Kc(f.review_text),I=Gc(f.review_tag);for(const _ of I){const y=_.toLocaleLowerCase();let L=i.get(y);if(L||(L={key:y,label:_,mentions:0,positive:0,negative:0,neutral:0,snippets:[]},i.set(y,L)),L.mentions+=1,m==="positive"?L.positive+=1:m==="negative"?L.negative+=1:L.neutral+=1,h.length>0&&L.snippets.length<Vc&&!L.snippets.some(A=>A.text===h)){const A={text:h,tone:m};f.review_rating!==void 0&&String(f.review_rating).length>0&&(A.rating=f.review_rating),L.snippets.push(A)}}}const o=Array.from(i.values()).sort((f,m)=>m.mentions!==f.mentions?m.mentions-f.mentions:f.label.localeCompare(m.label));if(o.length===0){const f=document.createElement("div");return f.className="gengage-chat-review-empty",f.textContent=t?.emptyReviewsMessage??"No review summary found.",a.appendChild(f),a}const s=(t?.reviewFilterPositive??"positive").toLowerCase(),c=(t?.reviewFilterNegative??"negative").toLowerCase(),l=document.createElement("div");l.className="gengage-chat-review-subjects-heading",l.textContent=t?.reviewSubjectsHeading??"Select to learn more",a.appendChild(l);let g=o[0]?.key??null;const d=document.createElement("div");d.className="gengage-chat-review-subjects gds-toolbar gds-toolbar-compact";const p=document.createElement("section");p.className="gengage-chat-review-detail gds-evidence-card";const u=()=>{for(;p.firstChild;)p.removeChild(p.firstChild);if(!g)return;const f=o.find(_=>_.key===g);if(!f)return;const m=document.createElement("div");m.className="gengage-chat-review-detail-meta";const h=document.createElement("span");if(h.className="gengage-chat-review-detail-mentions",h.textContent=`${Xc(f.mentions,t?.reviewCustomersMentionSingular,t?.reviewCustomersMentionPlural)} "${f.label}"`,m.appendChild(h),f.positive>0){const _=document.createElement("span");_.className="gengage-chat-review-detail-positive",_.textContent=`${f.positive} ${s}`,m.appendChild(_)}if(f.negative>0){const _=document.createElement("span");_.className="gengage-chat-review-detail-negative",_.textContent=`${f.negative} ${c}`,m.appendChild(_)}p.appendChild(m);const I=document.createElement("div");I.className="gengage-chat-review-snippets";for(const _ of f.snippets){const y=document.createElement("article");y.className="gengage-chat-review-snippet",y.dataset.tone=_.tone;const L=document.createElement("div");if(L.className="gengage-chat-review-snippet-text",L.textContent=`"${_.text}"`,y.appendChild(L),_.rating!==void 0&&String(_.rating).length>0){const A=document.createElement("div");A.className="gengage-chat-review-snippet-rating",A.textContent=`★ ${String(_.rating)}`,y.appendChild(A)}I.appendChild(y)}p.appendChild(I)},b=()=>{for(const f of d.querySelectorAll(".gengage-chat-review-subject")){const m=f.dataset.subjectKey===g;f.classList.toggle("gengage-chat-review-subject--active",m),f.classList.toggle("gds-chip-active",m),f.setAttribute("aria-pressed",String(m))}};for(const f of o){const m=Yc(f),h=document.createElement("button");h.type="button",h.className="gengage-chat-review-subject gds-chip",h.dataset.subjectKey=f.key,h.dataset.tone=m;const I=document.createElement("span");I.className="gengage-chat-review-subject-icon",I.appendChild(Jc(m)),h.appendChild(I);const _=document.createElement("span");_.className="gengage-chat-review-subject-label",_.textContent=f.label,h.appendChild(_);const y=document.createElement("span");y.className="gengage-chat-review-subject-count",y.textContent=`(${f.mentions})`,h.appendChild(y),h.addEventListener("click",()=>{g=f.key,b(),u()}),d.appendChild(h)}return a.appendChild(d),b(),u(),a.appendChild(p),a}function el(e){if(!e)return;const t=e.discountReason??e.discount_reason??e.campaignReason??e.campaign_reason;if(typeof t!="string")return;const a=t.trim();return a.length>0?a:void 0}function vt(e,t){if(e.productPriceUi?.showCampaignReason===!0)return el(t)}function Nt(e,t){const a=t?.originalPriceStyle??t?.price_original_style;if(a==="inline"||a==="strikethrough")return a;const n=e.productPriceUi?.originalPriceStyle;return n==="inline"||n==="strikethrough"?n:"strikethrough"}function jt(e){const t=document.createElement("div");return t.className="gengage-chat-campaign-reason",t.textContent=e,t}function Zt(e,t){for(const n of["campaignReasonLogoUrl","campaign_reason_logo_url","discountBadgeLogoUrl","discount_badge_logo_url"]){const r=t?.[n];if(typeof r=="string"&&r.trim()){const i=r.trim();if(De(i))return i}}const a=e.productPriceUi?.campaignBadgeLogoUrl;if(typeof a=="string"&&a.trim()){const n=a.trim();if(De(n))return n}}function qt(e){const t=document.createElement("div");if(t.className="gengage-chat-campaign-price-badge",t.dataset.gengagePart="campaign-price-badge",e.logoUrl){const i=document.createElement("div");i.className="gengage-chat-campaign-price-badge__logo";const o=document.createElement("img");o.alt="",o.loading="lazy",o.src=e.logoUrl,Be(o),i.appendChild(o),t.appendChild(i)}const a=document.createElement("div");a.className="gengage-chat-campaign-price-badge__body";const n=document.createElement("div");n.className="gengage-chat-campaign-price-badge__reason",n.textContent=e.reasonText;const r=document.createElement("span");return r.className="gengage-chat-campaign-price-badge__sale",r.textContent=e.salePriceFormatted,a.appendChild(n),a.appendChild(r),t.appendChild(a),t}function tl(){try{return globalThis.GENGAGE_TOPPICKS_MOBILE_LAYOUT==="uniform"}catch{return!1}}function Dn(e){const t=e.product.sku;if(typeof t=="string"&&t.length>0)return t;const a=e.action?.payload;return a&&typeof a=="object"&&"sku"in a&&typeof a.sku=="string"?a.sku:null}var al={winner:"roleWinner",best_value:"roleBestValue",best_alternative:"roleBestAlternative"};function Fn(e,t){if(!e||!t)return null;const a=al[e];return a?t[a]??e:e}function nl(e){const t=e.rating,a=typeof t=="number"?t:typeof t=="string"?parseFloat(t):NaN;if(Number.isNaN(a)||a<=0)return null;const n=document.createElement("div");n.className="gengage-chat-ai-toppick-rating",n.dataset.gengagePart="ai-top-pick-rating";const r=document.createElement("span");r.className="gengage-chat-ai-toppick-rating-icon",r.setAttribute("aria-hidden","true"),r.innerHTML='<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M12 3.6l2.58 5.23 5.77.84-4.17 4.07.98 5.75L12 16.78l-5.16 2.71.99-5.75L3.66 9.67l5.76-.84L12 3.6z"/></svg>';const i=document.createElement("span");return i.className="gengage-chat-ai-toppick-rating-value",i.textContent=a.toFixed(1),n.appendChild(r),n.appendChild(i),n}function rl(e,t,a,n,r){const i=document.createElement("div");i.className="gengage-chat-ai-toppick-media",i.dataset.gengagePart="ai-top-pick-media";const o=e.product,s=o.imageUrl;if(s&&De(s)){const l=document.createElement("img");l.className="gengage-chat-ai-toppick-img",l.dataset.gengagePart="ai-top-pick-image",xe(l,"src",s),l.loading="lazy",l.alt=t,Be(l),i.appendChild(l)}const c=Dn(e);if(c&&!r?.skipOverlayActions){const l=document.createElement("div");if(l.className="gengage-chat-product-card-img-actions",n.onFavoriteToggle){const u=document.createElement("button");u.className="gengage-chat-favorite-btn",u.type="button",u.dataset.gengageFavoriteSku=c,u.setAttribute("aria-label",n.i18n?.addToFavoritesLabel??"Add to favorites");const b=n.favoritedSkus?.has(c)??!1;b&&u.classList.add("gengage-chat-favorite-btn--active"),u.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="${b?"currentColor":"none"}" stroke="currentColor" stroke-width="2"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>`,u.addEventListener("click",f=>{f.stopPropagation(),u.classList.toggle("gengage-chat-favorite-btn--active"),u.querySelector("svg")?.setAttribute("fill",u.classList.contains("gengage-chat-favorite-btn--active")?"currentColor":"none"),n.onFavoriteToggle?.(c,o)}),l.appendChild(u)}const g=n.i18n?.findSimilarLabel??"Find Similar",d=document.createElement("button");d.className="gengage-chat-find-similar-pill",d.type="button",d.setAttribute("aria-label",g),d.dataset.tooltip=g,d.innerHTML='<span class="gengage-chat-find-similar-pill-icon" aria-hidden="true"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"><circle cx="10.5" cy="10.5" r="6.5"/><path d="M16 16l5.5 5.5"/></svg></span>';const p=document.createElement("span");p.className="gengage-chat-find-similar-pill-text",p.textContent=g,d.appendChild(p),d.addEventListener("click",u=>{u.stopPropagation(),n.onAction({title:g,type:"findSimilar",payload:{sku:c}})}),l.appendChild(d),i.appendChild(l)}a.appendChild(i)}function il(e,t,a){const n=e.price,r=e.originalPrice;if(!n)return;const i=vt(a,e),o=Nt(a,e),s=!!(r&&r!==n),c=!!(i&&s),l=Zt(a,e),g=document.createElement("div");if(g.className="gengage-chat-ai-toppick-price",g.dataset.gengagePart="ai-top-pick-price",c){const d=qt({reasonText:i,salePriceFormatted:se(n,a.pricing),...l!==void 0?{logoUrl:l}:{}});if(s&&o==="inline"){g.classList.add("gengage-chat-ai-toppick-price--inline"),g.appendChild(d);const p=document.createElement("span");p.className="gengage-chat-ai-toppick-price-sep",p.setAttribute("aria-hidden","true");const u=document.createElement("span");u.className="gengage-chat-ai-toppick-original-price",u.textContent=se(r,a.pricing),g.appendChild(p),g.appendChild(u)}else{const p=document.createElement("span");p.className="gengage-chat-ai-toppick-original-price",p.textContent=se(r,a.pricing),g.appendChild(p),g.appendChild(document.createTextNode(" ")),g.appendChild(d)}t.appendChild(g);return}if(s&&o==="inline"){g.classList.add("gengage-chat-ai-toppick-price--inline");const d=document.createElement("span");d.className="gengage-chat-ai-toppick-price-current",d.textContent=se(n,a.pricing);const p=document.createElement("span");p.className="gengage-chat-ai-toppick-price-sep",p.setAttribute("aria-hidden","true");const u=document.createElement("span");u.className="gengage-chat-ai-toppick-original-price",u.textContent=se(r,a.pricing),g.appendChild(d),g.appendChild(p),g.appendChild(u)}else if(s){const d=document.createElement("span");d.className="gengage-chat-ai-toppick-original-price",d.textContent=se(r,a.pricing),g.appendChild(d),g.appendChild(document.createTextNode(" "));const p=document.createElement("span");p.className="gengage-chat-ai-toppick-price-current",p.textContent=se(n,a.pricing),g.appendChild(p)}else{const d=document.createElement("span");d.className="gengage-chat-ai-toppick-price-current",d.textContent=se(n,a.pricing),g.appendChild(d)}if(i){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-price-stack",d.appendChild(jt(i)),d.appendChild(g),t.appendChild(d)}else t.appendChild(g)}function ol(e,t,a){const n=typeof e.reason=="string"?e.reason.trim():"",r=a.hideUserReviews!==!0&&typeof e.reviewHighlight=="string"?e.reviewHighlight.trim():"";if(!(!n&&!r)){if(n){const i=document.createElement("p");i.className="gengage-chat-ai-toppick-reason",i.dataset.gengagePart="ai-top-pick-reason",i.textContent=n,t.appendChild(i)}if(r){const i=document.createElement("div");i.className="gengage-chat-ai-toppick-review",i.dataset.gengagePart="ai-top-pick-review",i.textContent=r,t.appendChild(i)}}}function Hn(e,t,a,n){const r=document.createElement("div");r.className=a?"gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--winner gds-card":"gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--compact gds-card";const i=n?.uniformMobileLayout===!0;!a&&i&&r.classList.add("gengage-chat-ai-toppick-card--mobile-uniform"),r.dataset.gengagePart=a?"ai-top-pick-card-winner":"ai-top-pick-card";const o=e.product,s=Dn(e),c=o.url??"",l=o.cartCode,g=o.inStock,d=!!(s&&l&&g!==!1),p=e.action;s&&t.onProductClick?(r.classList.add("gds-clickable"),r.addEventListener("click",k=>{if(k.target.closest(".gengage-chat-ai-toppick-cta")||k.target.closest(".gengage-chat-favorite-btn")||k.target.closest(".gengage-chat-find-similar-pill"))return;const E=o.name;t.onProductClick?.({sku:s,url:c,...E?{name:E}:{}})})):p&&(r.classList.add("gds-clickable"),r.addEventListener("click",k=>{k.target.closest(".gengage-chat-ai-toppick-cta")||k.target.closest(".gengage-chat-favorite-btn")||k.target.closest(".gengage-chat-find-similar-pill")||t.onAction(p)}));const u=o.name||"Product image",b=!a&&t.isMobile===!0&&!i,f=a?Fn(e.role,t.i18n)??t.i18n?.roleWinner??"TOP MATCH":Fn(e.role,t.i18n);if(f&&!b){const k=document.createElement("span");k.className="gengage-chat-ai-toppick-badge gds-badge",k.dataset.gengagePart="ai-top-pick-role-badge",k.textContent=f,r.appendChild(k)}const m=document.createElement("div");m.className="gengage-chat-ai-toppick-top-row",m.dataset.gengagePart="ai-top-pick-top-row",rl(e,u,m,t,{skipOverlayActions:b});const h=document.createElement("div");if(h.className="gengage-chat-ai-toppick-body",h.dataset.gengagePart="ai-top-pick-body",f&&b){const k=document.createElement("div");k.className="gengage-chat-ai-toppick-role-line",k.dataset.gengagePart="ai-top-pick-role-line",k.textContent=f,h.appendChild(k)}const I=o.name;if(I){const k=document.createElement("div");k.className="gengage-chat-ai-toppick-name",k.dataset.gengagePart="ai-top-pick-name",k.textContent=I,h.appendChild(k)}const _=nl(o);_&&h.appendChild(_),il(o,h,t),e.labels&&e.labels.length>0&&h.appendChild(cl(e.labels)),m.appendChild(h),r.appendChild(m);const y=document.createElement("div");if(y.className="gengage-chat-ai-toppick-detail",y.dataset.gengagePart="ai-top-pick-detail",a)ol(e,y,t);else{const k=typeof e.reason=="string"?e.reason.trim():"";if(k){const E=document.createElement("p");E.className="gengage-chat-ai-toppick-snippet",E.dataset.gengagePart="ai-top-pick-snippet",E.textContent=k,y.appendChild(E)}}y.childNodes.length>0&&r.appendChild(y);const L=!!(s&&t.topPicksLoadingSku===s),A=(d||p)&&!b;if(L||d||p){const k=document.createElement("div");if(k.className="gengage-chat-ai-toppick-spinner",k.dataset.gengagePart="ai-top-pick-spinner",k.style.display=L?"":"none",r.appendChild(k),A){const E=document.createElement("button");E.className="gengage-chat-ai-toppick-cta gds-btn gds-btn-primary",E.dataset.gengagePart="ai-top-pick-cta",E.type="button",E.textContent=d?t.i18n?.addToCartButton??"Add to Cart":t.i18n?.viewDetails??"View Details",E.addEventListener("click",D=>{if(D.stopPropagation(),d){t.onAction({title:t.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:s,cartCode:l,quantity:1}});return}if(p){if(p.type==="findSimilar"&&s&&t.onProductClick){const X=o.name;t.onProductClick({sku:s,url:c,...X?{name:X}:{}});return}t.onAction(p)}}),r.appendChild(E)}}return r}function sl(e,t){const a=document.createElement("div");a.className="gengage-chat-ai-top-picks",a.dataset.gengagePart="ai-top-picks";const n=e.props?.suggestions??[];if(n.length===0)return a;const r=document.createElement("div");r.className="gengage-chat-ai-top-picks-scroll",r.dataset.gengagePart="ai-top-picks-scroll";const i=t.isMobile===!0&&tl(),o=n[0];if(r.appendChild(Hn(o,t,!0,{uniformMobileLayout:i})),n.length>1){const s=document.createElement("div");s.className="gengage-chat-ai-top-picks-rest",i&&s.classList.add("gengage-chat-ai-top-picks-rest--uniform-mobile"),s.dataset.gengagePart="ai-top-picks-rest";for(let c=1;c<n.length;c++){const l=n[c],g=l.role==="winner";s.appendChild(Hn(l,t,g,{uniformMobileLayout:i}))}r.appendChild(s)}return a.appendChild(r),a}function cl(e){const t=document.createElement("div");t.className="gengage-chat-ai-toppick-labels",t.dataset.gengagePart="ai-top-pick-labels";for(const a of e){const n=document.createElement("span");n.className="gengage-chat-ai-toppick-label gds-chip",n.dataset.gengagePart="ai-top-pick-label",n.dataset.sentiment=a.sentiment??"neutral",n.textContent=a.label,t.appendChild(n)}return t}function ll(e,t){const a=document.createElement("div");a.className="gengage-chat-grounding-review gds-evidence-card",a.dataset.gengagePart="grounding-review-card";const n=e.props??{},r=n.title,i=n.reviewCount,o=n.action,s=t.i18n?.groundingReviewCta??"Read Reviews",c=document.createElement("span");c.className="gengage-chat-grounding-review-icon",c.appendChild(It(["M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z","M8 9h8","M8 13h6"])),a.appendChild(c);const l=document.createElement("div");l.className="gengage-chat-grounding-review-body",l.dataset.gengagePart="grounding-review-body";const g=document.createElement("div");if(g.className="gengage-chat-grounding-review-title",g.dataset.gengagePart="grounding-review-title",g.textContent=r??t.i18n?.customerReviewsTitle??"Customer Reviews",l.appendChild(g),i){const b=document.createElement("div");b.className="gengage-chat-grounding-review-subtitle",b.dataset.gengagePart="grounding-review-subtitle",b.textContent=(t.i18n?.groundingReviewSubtitle??"{count} yorum mevcut").replace("{count}",i),l.appendChild(b)}a.appendChild(l);const d=document.createElement("span");d.className="gengage-chat-grounding-review-cta",d.dataset.gengagePart="grounding-review-cta";const p=document.createElement("span");p.textContent=s,d.appendChild(p);const u=document.createElement("span");return u.className="gengage-chat-grounding-review-cta-icon",u.appendChild(It(["M5 12h14","M15 8l4 4-4 4"],14)),d.appendChild(u),a.appendChild(d),o&&(a.classList.add("gds-clickable"),a.setAttribute("role","button"),a.setAttribute("tabindex","0"),a.addEventListener("click",()=>t.onAction(o)),a.addEventListener("keydown",b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),t.onAction(o))})),a}function gl(e){const t=e.action.type;if(t!=="findSimilar")return e.action;const a=e.action.payload&&typeof e.action.payload=="object"?e.action.payload:null,n=typeof a?.input=="string"&&a.input.trim()||typeof a?.text=="string"&&a.text.trim()||e.name.trim();if(!n)return e.action;const r={...a??{},text:n,is_suggested_text:1};return typeof a?.input=="string"&&a.input.trim()?r.input=a.input:delete r.input,{title:e.action.title,type:t,payload:Ft(r)}}function dl(e,t){const a=document.createElement("div");a.className="gengage-chat-grouping-cards",a.dataset.gengagePart="ai-grouping-cards";const n=e.props?.entries??[];if(n.length===0)return a;const r=e.props?.sectionTitle,i=typeof r=="string"&&r.trim().length>0?r.trim():t.i18n?.aiBrowseCategoriesTitle;if(i){const s=document.createElement("h3");s.className="gengage-chat-grouping-section-title",s.textContent=i,a.appendChild(s)}const o=document.createElement("div");o.className="gengage-chat-grouping-cards-scroll",o.dataset.gengagePart="ai-grouping-cards-scroll";for(const s of n){const c=document.createElement("div");if(c.className="gengage-chat-grouping-card gds-card",c.dataset.gengagePart="ai-grouping-card",c.classList.add("gds-clickable"),c.addEventListener("click",()=>t.onAction(gl(s))),s.image&&De(s.image)){const p=document.createElement("img");p.className="gengage-chat-grouping-card-img",p.dataset.gengagePart="ai-grouping-card-image",p.draggable=!1,p.src=s.image,p.alt=s.name,p.width=64,p.height=64,c.appendChild(p)}const l=document.createElement("div");l.className="gengage-chat-grouping-card-body",l.dataset.gengagePart="ai-grouping-card-body";const g=document.createElement("span");if(g.className="gengage-chat-grouping-card-name",g.dataset.gengagePart="ai-grouping-card-name",g.textContent=s.name,l.appendChild(g),s.labels&&s.labels.length>0){const p=document.createElement("div");p.className="gengage-chat-grouping-card-labels",p.dataset.gengagePart="ai-grouping-card-labels";for(const u of s.labels.slice(0,2)){const b=document.createElement("span");b.className="gengage-chat-grouping-card-label gds-chip",b.textContent=u,p.appendChild(b)}l.appendChild(p)}c.appendChild(l);const d=document.createElement("span");d.className="gengage-chat-grouping-card-arrow",d.textContent="↳",c.insertBefore(d,c.firstChild),o.appendChild(c)}return a.appendChild(o),a}function pl(e,t){const a=document.createElement("div");a.className="gengage-chat-suggested-search-cards",a.dataset.gengagePart="ai-suggested-search-cards";const n=e.props?.entries??[];if(n.length===0)return a;for(const r of n){const i=document.createElement("div");if(i.className="gengage-chat-suggested-search-card gds-card",i.dataset.gengagePart="ai-suggested-search-card",i.classList.add("gds-clickable"),i.addEventListener("click",()=>t.onAction(r.action)),r.image&&De(r.image)){const c=document.createElement("img");c.className="gengage-chat-suggested-search-card-img",c.dataset.gengagePart="ai-suggested-search-card-image",c.src=r.image,c.alt=r.shortName,c.width=64,c.height=64,i.appendChild(c)}const o=document.createElement("div");o.className="gengage-chat-suggested-search-card-body",o.dataset.gengagePart="ai-suggested-search-card-body";const s=document.createElement("div");s.className="gengage-chat-suggested-search-card-name",s.dataset.gengagePart="ai-suggested-search-card-name",s.textContent=r.shortName,o.appendChild(s),i.appendChild(o),a.appendChild(i)}return a}function Un(e,t){const a=e.length>=2,n=t.i18n?.compareSelected??"Compare",r=t.comparisonSelectionWarning,i=document.createElement("div");i.className="gengage-chat-comparison-floating-btn",i.dataset.gengagePart="comparison-dock";const o=document.createElement("div");o.className="gengage-chat-comparison-floating-summary";const s=document.createElement("span");s.className="gengage-chat-comparison-floating-count",s.textContent=String(e.length),o.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-comparison-floating-copy";const l=document.createElement("div");if(l.className="gengage-chat-comparison-floating-title",l.textContent=a?`${n} (${e.length})`:t.i18n?.compareMinHint??"Select at least 2 products",c.appendChild(l),r){const d=document.createElement("div");d.className="gengage-chat-comparison-floating-warning",d.setAttribute("role","status"),d.setAttribute("aria-live","polite"),d.textContent=r,c.appendChild(d)}o.appendChild(c),i.appendChild(o);const g=document.createElement("button");if(g.className="gengage-chat-comparison-floating-action gds-btn gds-btn-primary",g.type="button",g.textContent=n,g.disabled=!a,a||g.classList.add("gengage-chat-comparison-floating-action--disabled"),g.addEventListener("click",()=>{a&&t.onAction({title:n,type:"getComparisonTable",payload:{sku_list:[...e],gengage_analytics_source:"floating_compare_dock"}})}),i.appendChild(g),t.onToggleComparisonSku){const d=document.createElement("button");d.className="gengage-chat-comparison-floating-close gds-btn gds-btn-ghost gds-icon-btn",d.dataset.gengagePart="comparison-dock-close",d.type="button",d.setAttribute("aria-label",t.i18n?.closeAriaLabel??"Close"),d.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" aria-hidden="true"><path d="M18 6L6 18"/><path d="M6 6l12 12"/></svg>',d.addEventListener("click",p=>{p.preventDefault(),p.stopPropagation(),t.onToggleComparisonSku?.("")}),i.appendChild(d)}return i}function hl(e){const t=document.createElement("div");t.className="gengage-chat-pros-cons gds-card-soft",t.dataset.gengagePart="pros-cons";const a=e.props?.productName;if(a){const i=document.createElement("h4");i.className="gengage-chat-pros-cons-heading",i.textContent=a,t.appendChild(i)}const n=e.props?.pros,r=e.props?.cons;if(n&&n.length>0){const i=document.createElement("ul");i.className="gengage-chat-pros-cons-list",i.dataset.gengagePart="pros-list";for(const o of n){const s=document.createElement("li");s.className="gengage-chat-pros-cons-item",s.dataset.gengagePart="pros-item";const c=document.createElement("span");c.className="gengage-chat-pros-cons-icon gengage-chat-pros-cons-icon--pro",c.textContent="✓",s.appendChild(c);const l=document.createElement("span");l.textContent=o,s.appendChild(l),i.appendChild(s)}t.appendChild(i)}if(r&&r.length>0){const i=document.createElement("ul");i.className="gengage-chat-pros-cons-list",i.dataset.gengagePart="cons-list";for(const o of r){const s=document.createElement("li");s.className="gengage-chat-pros-cons-item",s.dataset.gengagePart="cons-item";const c=document.createElement("span");c.className="gengage-chat-pros-cons-icon gengage-chat-pros-cons-icon--con",c.textContent="✗",s.appendChild(c);const l=document.createElement("span");l.textContent=o,s.appendChild(l),i.appendChild(s)}t.appendChild(i)}return t}var ul=4,ml=0;function fl(e){const t=[],a=new Set,n=(r,i)=>{if(typeof r!="string")return;const o=r.trim();if(!o)return;const s=o.toLowerCase();a.has(s)||(a.add(s),t.push({text:o,accent:i}))};n(e.highlight,!0);for(const r of e.labels??[])n(r,!1);return t.slice(0,ul)}function bl(e){const t=fl(e),a=typeof e.description=="string"?e.description.trim():"";if(!a&&t.length===0)return null;const n=document.createElement("div");if(n.className="gengage-chat-categories-group-summary",n.dataset.gengagePart="categories-group-summary",n.appendChild(vl(e)),t.length>0&&n.appendChild(yl(t)),a){const r=document.createElement("p");r.className="gengage-chat-categories-group-reason",r.dataset.gengagePart="categories-group-reason",r.textContent=a,n.appendChild(r)}return n}function vl(e){const t=document.createElement("div");if(t.className="gengage-chat-categories-group-selection",t.dataset.gengagePart="categories-group-selection",e.image&&De(e.image)){const n=document.createElement("img");n.className="gengage-chat-categories-group-selection-image",n.draggable=!1,n.src=e.image,n.alt=e.groupName,n.loading="lazy",Be(n),t.appendChild(n)}const a=document.createElement("div");return a.className="gengage-chat-categories-group-selection-title",a.textContent=e.groupName,t.appendChild(a),t}function yl(e){const t=document.createElement("div");t.className="gengage-chat-categories-group-chips",t.dataset.gengagePart="categories-group-chips";for(const a of e){const n=document.createElement("span");n.className=a.accent?"gengage-chat-categories-group-chip gengage-chat-categories-group-chip--accent gds-chip gds-chip-active":"gengage-chat-categories-group-chip gds-chip",n.textContent=a.text,t.appendChild(n)}return t}function xl(e,t){const a=e.props?.groups??[],n=e.props?.filterTags??[],r=`gengage-cat-${ml++}`,i=document.createElement("div");if(i.className="gengage-chat-categories",i.dataset.gengagePart="categories-container",a.length===0)return i;const o=document.createElement("div");o.className="gengage-chat-categories-tabs gds-toolbar",o.dataset.gengagePart="categories-tab-bar",o.setAttribute("role","tablist");const s=[],c=[],l=g=>{for(let d=0;d<s.length;d++){const p=d===g;s[d].classList.toggle("gengage-chat-categories-tab--active",p),s[d].classList.toggle("is-active",p),s[d].setAttribute("aria-selected",String(p)),s[d].tabIndex=p?0:-1,c[d].style.display=p?"":"none"}};for(let g=0;g<a.length;g++){const d=a[g],p=`${r}-tab-${g}`,u=`${r}-panel-${g}`,b=document.createElement("button");if(b.className="gengage-chat-categories-tab gds-tab",b.type="button",b.dataset.gengagePart="categories-tab",b.id=p,b.setAttribute("role","tab"),b.setAttribute("aria-controls",u),b.setAttribute("aria-selected",String(g===0)),b.tabIndex=g===0?0:-1,g===0&&b.classList.add("gengage-chat-categories-tab--active","is-active"),d.image&&De(d.image)){const _=document.createElement("img");_.className="gengage-chat-categories-tab-image",_.draggable=!1,_.src=d.image,_.alt=d.groupName,_.loading="lazy",Be(_),b.appendChild(_)}const f=document.createElement("span");f.className="gengage-chat-categories-tab-text",f.textContent=d.groupName,b.appendChild(f),b.addEventListener("click",()=>l(g)),b.addEventListener("keydown",_=>{let y=-1;_.key==="ArrowRight"||_.key==="ArrowDown"?y=(g+1)%a.length:_.key==="ArrowLeft"||_.key==="ArrowUp"?y=(g-1+a.length)%a.length:_.key==="Home"?y=0:_.key==="End"&&(y=a.length-1),y>=0&&(_.preventDefault(),l(y),s[y].focus())}),s.push(b),o.appendChild(b);const m=document.createElement("div");m.className="gengage-chat-categories-panel",m.dataset.gengagePart="categories-panel",m.id=u,m.setAttribute("role","tabpanel"),m.setAttribute("aria-labelledby",p),g!==0&&(m.style.display="none");const h=bl(d);h&&m.appendChild(h);const I=document.createElement("div");I.className="gengage-chat-categories-grid",I.dataset.gengagePart="categories-grid";for(const _ of d.products){const y=_l(_,t);I.appendChild(y)}m.appendChild(I),c.push(m)}i.appendChild(o);for(const g of c)i.appendChild(g);if(n.length>0){const g=document.createElement("div");g.className="gengage-chat-categories-filter-tags gds-toolbar",g.dataset.gengagePart="categories-filter-tags";for(const d of n){const p=document.createElement("button");p.className="gengage-chat-categories-filter-tag gds-chip",p.type="button",p.dataset.gengagePart="categories-filter-tag",p.textContent=d.title,d.action&&p.addEventListener("click",()=>{t.onAction(d.action)}),g.appendChild(p)}i.appendChild(g)}return i}function _l(e,t){const a=document.createElement("div");if(a.className="gengage-chat-product-card gds-card gds-product-card gds-card-interactive",a.dataset.gengagePart="categories-product-card",e.imageUrl&&De(e.imageUrl)){const i=document.createElement("img");i.className="gengage-chat-product-card-img",i.draggable=!1,i.src=e.imageUrl,i.alt=e.name,i.loading="lazy",Be(i),a.appendChild(i)}const n=document.createElement("div");n.className="gengage-chat-product-card-body";const r=document.createElement("div");if(r.className="gengage-chat-product-card-name",r.textContent=e.name,n.appendChild(r),e.price){const i=document.createElement("div");i.className="gengage-chat-product-card-price",i.textContent=se(e.price,t.pricing),n.appendChild(i)}return a.appendChild(n),(t.onProductSelect||t.onAction)&&(a.classList.add("gds-clickable"),a.addEventListener("click",()=>{if(e.sku){t.onAction({title:e.name,type:"launchSingleProduct",payload:{sku:e.sku}});return}t.onProductSelect?.(e)})),a}function wl(e,t){const a=document.createElement("div");a.className="gengage-chat-handoff-notice gds-evidence-card gds-evidence-card-warning",a.dataset.gengagePart="handoff-notice",a.setAttribute("role","alert");const n=document.createElement("span");n.className="gengage-chat-handoff-notice-icon",n.textContent="👤",n.setAttribute("aria-hidden","true"),a.appendChild(n);const r=document.createElement("h4");r.className="gengage-chat-handoff-notice-heading",r.textContent=t.i18n?.handoffHeading??"Transferring to a support agent",a.appendChild(r);const i=e.props?.summary;if(i){const o=document.createElement("p");o.className="gengage-chat-handoff-notice-summary",o.textContent=i,a.appendChild(o)}return a}var kl="frontend_restore_panel_message";function tt(e){return typeof e=="string"?e:""}function Cl(e){return Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object")return null;const a=t;return{imageUrl:tt(a.imageUrl)||void 0,name:tt(a.name)||void 0}}).filter(t=>t!==null):[]}function Sl(e,t){const a=e.props??{},n=tt(a.eyebrow),r=tt(a.title),i=a.showTitle!==!1,o=tt(a.ctaLabel)||t.i18n?.showPanelAriaLabel||"Show Results",s=tt(a.panelMessageId),c=tt(a.highlightMessageId),l=tt(a.threadId),g=Cl(a.products).slice(0,3),d=document.createElement("button");d.type="button",d.className="gengage-chat-panel-restore-card gds-card",!n&&!i&&d.classList.add("gengage-chat-panel-restore-card--minimal"),d.dataset.gengagePart="panel-restore-card";const p=r||n||o;d.setAttribute("aria-label",r?`${p} - ${o}`:p);const u={title:r,type:kl,payload:{panelMessageId:s,highlightMessageId:c,threadId:l}};if(d.addEventListener("click",()=>t.onAction(u)),n){const f=document.createElement("div");f.className="gengage-chat-panel-restore-card__eyebrow",f.textContent=n,d.appendChild(f)}if(g.length>0){const f=document.createElement("div");f.className="gengage-chat-panel-restore-card__previews";for(const m of g){const h=document.createElement("div");h.className="gengage-chat-panel-restore-card__thumb";const I=m.imageUrl;if(I&&Ce(I)){const _=document.createElement("img");_.loading="lazy",_.alt=m.name||r,xe(_,"src",I),Be(_),h.appendChild(_)}f.appendChild(h)}d.appendChild(f)}if(i&&r){const f=document.createElement("div");f.className="gengage-chat-panel-restore-card__title",f.textContent=r,f.title=r,d.appendChild(f)}const b=document.createElement("div");return b.className="gengage-chat-panel-restore-card__cta",b.textContent=o,d.appendChild(b),d}function El(e,t){const a=e.props?.product??e.props,n=document.createElement("div");if(n.className="gengage-chat-product-summary gds-card",n.dataset.gengagePart="product-summary-card",!a)return n;n.classList.add("gds-clickable"),n.addEventListener("click",h=>{h.target.closest("a")||t.onProductSelect?.(a)});const r=a.imageUrl;if(r&&Ce(r)){const h=document.createElement("div");h.className="gengage-chat-product-summary__image",h.dataset.gengagePart="product-summary-image";const I=document.createElement("img");I.loading="lazy",xe(I,"src",r),I.alt=a.name||"Product image",Be(I),h.appendChild(I),n.appendChild(h)}const i=document.createElement("div");i.className="gengage-chat-product-summary__content",i.dataset.gengagePart="product-summary-content";const o=a.brand,s=a.name;if(s){const h=document.createElement("div");h.className="gengage-chat-product-summary__name",h.dataset.gengagePart="product-summary-name";const I=o&&!s.toLowerCase().startsWith(o.toLowerCase())?`${o} ${s}`:s;h.textContent=I,h.title=I,i.appendChild(h)}const c=a.rating,l=a.reviewCount;if(t.hideUserReviews!==!0&&typeof c=="number"&&Number.isFinite(c)&&c>0){const h=document.createElement("div");if(h.className="gengage-chat-product-summary__rating",h.dataset.gengagePart="product-summary-rating",h.appendChild(Bn(c)),typeof l=="number"&&Number.isFinite(l)){const I=document.createElement("span");I.className="gengage-chat-product-summary__review-count",I.textContent=` (${l})`,h.appendChild(I)}i.appendChild(h)}const g=a.price,d=a.originalPrice;if(g){const h=vt(t,a),I=Nt(t,a),_=!!(d&&d!==g),y=document.createElement("div");y.className="gengage-chat-product-summary__price",y.dataset.gengagePart="product-summary-price";const L=!!(h&&_),A=Zt(t,a);if(L){const k=qt({reasonText:h,salePriceFormatted:se(g,t.pricing),...A!==void 0?{logoUrl:A}:{}});if(_&&I==="inline"){y.classList.add("gengage-chat-product-summary__price--inline"),y.appendChild(k);const E=document.createElement("span");E.className="gengage-chat-product-summary__price-sep",E.setAttribute("aria-hidden","true");const D=document.createElement("span");D.className="gengage-chat-product-summary__price-original",D.textContent=se(d,t.pricing),y.appendChild(E),y.appendChild(D)}else{const E=document.createElement("span");E.className="gengage-chat-product-summary__price-original",E.textContent=se(d,t.pricing),y.appendChild(E),y.appendChild(document.createTextNode(" ")),y.appendChild(k)}i.appendChild(y)}else{if(_&&I==="inline"){y.classList.add("gengage-chat-product-summary__price--inline");const k=document.createElement("span");k.className="gengage-chat-product-summary__price-current",k.textContent=se(g,t.pricing);const E=document.createElement("span");E.className="gengage-chat-product-summary__price-sep",E.setAttribute("aria-hidden","true");const D=document.createElement("span");D.className="gengage-chat-product-summary__price-original",D.textContent=se(d,t.pricing),y.appendChild(k),y.appendChild(E),y.appendChild(D)}else if(_){const k=document.createElement("span");k.className="gengage-chat-product-summary__price-original",k.textContent=se(d,t.pricing),y.appendChild(k),y.appendChild(document.createTextNode(" "));const E=document.createElement("span");E.className="gengage-chat-product-summary__price-current",E.textContent=se(g,t.pricing),y.appendChild(E)}else{const k=document.createElement("span");k.className="gengage-chat-product-summary__price-current",k.textContent=se(g,t.pricing),y.appendChild(k)}if(h){const k=document.createElement("div");k.className="gengage-chat-product-summary__price-stack",k.appendChild(jt(h)),k.appendChild(y),i.appendChild(k)}else i.appendChild(y)}}n.appendChild(i);const p=a.url,u=a.sku,b=a.cartCode??a.cart_code,f=typeof b=="string"&&b.trim()?b.trim():void 0,m=a.inStock;if(u&&f&&m!==!1){const h=document.createElement("button");h.type="button",h.className="gengage-chat-product-summary__cta gds-chip gds-chip-active",h.dataset.gengagePart="product-summary-cta",h.textContent=t.i18n?.addToCartButton??"Add to Cart",h.addEventListener("click",I=>{I.stopPropagation(),t.onAction({title:t.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:u,cartCode:f,quantity:1}})}),n.appendChild(h)}else if(p&&Ce(p)){const h=document.createElement("a");h.className="gengage-chat-product-summary__cta gds-chip gds-chip-active",h.dataset.gengagePart="product-summary-cta",xe(h,"href",p),xe(h,"target","_blank"),xe(h,"rel","noopener noreferrer"),h.textContent=t.i18n?.productCtaLabel??"View",n.appendChild(h)}return n}var Pl={PhotoAnalysisCard:({element:e,context:t})=>vc(e,t),BeautyPhotoStep:({element:e,context:t})=>En(e,t)};function Ca(){return window.innerWidth<768}var jn={ActionButtons:({element:e,context:t})=>Tl(e,t),ActionButton:({element:e,context:t})=>Al(e,t),ProductCard:({element:e,context:t})=>Ea(e,t),ProductDetailsPanel:({element:e,context:t})=>Yl(e,t),ProductGrid:({element:e,spec:t,renderElement:a,context:n})=>rg(e,t,a,n),ReviewHighlights:({element:e,context:t})=>t.hideUserReviews===!0?null:Qc(e,{emptyReviewsMessage:t.i18n?.emptyReviewsMessage,reviewFilterPositive:t.i18n?.reviewFilterPositive,reviewFilterNegative:t.i18n?.reviewFilterNegative,reviewCustomersMentionSingular:t.i18n?.reviewCustomersMentionSingular,reviewCustomersMentionPlural:t.i18n?.reviewCustomersMentionPlural,reviewSubjectsHeading:t.i18n?.reviewSubjectsHeading}),ComparisonTable:({element:e,context:t})=>og(e,t),AITopPicks:({element:e,context:t})=>sl(e,t),GroundingReviewCard:({element:e,context:t})=>t.hideUserReviews===!0?null:ll(e,t),AIGroupingCards:({element:e,context:t})=>dl(e,t),AISuggestedSearchCards:({element:e,context:t})=>pl(e,t),ProsAndCons:({element:e})=>hl(e),CategoriesContainer:({element:e,context:t})=>xl(e,t),HandoffNotice:({element:e,context:t})=>wl(e,t),PanelRestoreCard:({element:e,context:t})=>Sl(e,t),ProductSummaryCard:({element:e,context:t})=>El(e,t),Divider:({element:e})=>sg(e),...Pl},Sa=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const a=document.createElement("div");for(const n of e.children){const r=t(n);r&&a.appendChild(r)}return a};function Zn(){return{...jn}}function qn(e,t,a=jn,n=Sa){return Ai({spec:e,context:t,registry:a,containerClassName:"gengage-chat-uispec",unknownRenderer:n})}function Tl(e,t){const a=document.createElement("div");a.className="gengage-chat-action-buttons";const n=e.props?.buttons;if(n)for(const r of n){const i=document.createElement("button");i.className="gengage-chat-action-btn",i.textContent=r.label,i.addEventListener("click",()=>t.onAction(r.action)),a.appendChild(i)}return a}function Al(e,t){const a=document.createElement("button");a.className="gengage-chat-action-btn";const n=e.props?.label;typeof n=="string"&&(a.textContent=n);const r=e.props?.action;return r&&a.addEventListener("click",()=>t.onAction(r)),a}function Vn(e,t,a,n,r){e.replaceChildren();const i=Nt(t,a),o=!!(r&&n&&r!==n),s=vt(t,a),c=!!(s&&o),l=Zt(t,a);if(!n||parseFloat(n)<=0)return;if(c){const d=qt({reasonText:s,salePriceFormatted:se(n,t.pricing),...l!==void 0?{logoUrl:l}:{}});if(o&&i==="inline"){e.classList.add("gengage-chat-product-card-price-block--inline");const p=document.createElement("div");p.className="gengage-chat-product-card-price-row",p.appendChild(d);const u=document.createElement("span");u.className="gengage-chat-product-card-price-sep",u.setAttribute("aria-hidden","true");const b=document.createElement("span");b.className="gengage-chat-product-card-original-price",b.textContent=se(r,t.pricing),p.appendChild(u),p.appendChild(b),e.appendChild(p);return}if(e.classList.remove("gengage-chat-product-card-price-block--inline"),e.appendChild(d),o){e.appendChild(document.createTextNode(" "));const p=document.createElement("span");p.className="gengage-chat-product-card-original-price",p.textContent=se(r,t.pricing),e.appendChild(p)}return}if(o&&i==="inline"){e.classList.add("gengage-chat-product-card-price-block--inline");const d=document.createElement("div");d.className="gengage-chat-product-card-price-row";const p=document.createElement("span");p.className="gengage-chat-product-card-current-price",p.textContent=se(n,t.pricing);const u=document.createElement("span");u.className="gengage-chat-product-card-price-sep",u.setAttribute("aria-hidden","true");const b=document.createElement("span");b.className="gengage-chat-product-card-original-price",b.textContent=se(r,t.pricing),d.appendChild(p),d.appendChild(u),d.appendChild(b),e.appendChild(d);return}e.classList.remove("gengage-chat-product-card-price-block--inline");const g=document.createElement("span");if(g.className="gengage-chat-product-card-current-price",g.textContent=se(n,t.pricing),e.appendChild(g),o){e.appendChild(document.createTextNode(" "));const d=document.createElement("span");d.className="gengage-chat-product-card-original-price",d.textContent=se(r,t.pricing),e.appendChild(d)}}function Gn(e,t,a,n,r,i,o){e.classList.remove("gengage-chat-product-details-price--inline"),e.replaceChildren(),e.className="gengage-chat-product-details-price";const s=vt(t,a),c=!!(s&&o),l=Zt(t,a);if(c){const d=qt({reasonText:s,salePriceFormatted:se(n,t.pricing),...l!==void 0?{logoUrl:l}:{}});if(o&&i==="inline"){e.classList.add("gengage-chat-product-details-price--inline"),e.appendChild(d);const p=document.createElement("span");p.className="gengage-chat-product-details-price-sep",p.setAttribute("aria-hidden","true");const u=document.createElement("span");u.className="gengage-chat-product-details-original-price",u.textContent=se(r,t.pricing),e.appendChild(p),e.appendChild(u)}else{if(o){const p=document.createElement("span");p.className="gengage-chat-product-details-original-price",p.textContent=se(r,t.pricing),e.appendChild(p),e.appendChild(document.createTextNode(" "))}e.appendChild(d)}}else if(o&&i==="inline"){e.classList.add("gengage-chat-product-details-price--inline");const d=document.createElement("span");d.className="gengage-chat-product-details-current-price",d.textContent=se(n,t.pricing);const p=document.createElement("span");p.className="gengage-chat-product-details-price-sep",p.setAttribute("aria-hidden","true");const u=document.createElement("span");u.className="gengage-chat-product-details-original-price",u.textContent=se(r,t.pricing),e.appendChild(d),e.appendChild(p),e.appendChild(u)}else{if(o){const p=document.createElement("span");p.className="gengage-chat-product-details-original-price",p.textContent=se(r,t.pricing),e.appendChild(p),e.appendChild(document.createTextNode(" "))}const d=document.createElement("span");d.className="gengage-chat-product-details-current-price",d.textContent=se(n,t.pricing),e.appendChild(d)}const g=Vt(a,"discountPercent","price_discount_rate");if(!t.hideProductDiscountBadge&&typeof g=="number"&&g>0){const d=document.createElement("span");d.className="gengage-chat-product-details-discount-badge",d.textContent=`%${Mn(g)}`,e.appendChild(d)}}function Ea(e,t){const a=document.createElement("div");a.className="gengage-chat-product-card gds-card gds-product-card gds-card-interactive";const n=e.props?.product??e.props;if(!n)return a;const r=n.sku;r&&(a.dataset.sku=r);const i=e.props?.action,o=n.name,s=n.url,c=n.sku,l=s&&Ce(s)?s:void 0,g=()=>i?.type!=="launchSingleProduct"||l===void 0||c===void 0||t.onProductClick===void 0?!1:(t.onProductClick({sku:c,url:l,...typeof o=="string"?{name:o}:{}}),!0);(t.onProductSelect||i)&&(a.classList.add("gds-clickable"),a.addEventListener("click",w=>{if(!a.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")&&!w.target.closest(".gengage-chat-product-card-atc")&&!w.target.closest(".gengage-chat-product-card-cta")){if(i){g()||t.onAction(i);return}t.onProductSelect?.(n)}}));const d=n.imageUrl;if(d&&Ce(d)){const w=document.createElement("div");w.className="gengage-chat-product-card-img-wrapper";const M=document.createElement("img");M.className="gengage-chat-product-card-img",M.loading="lazy",xe(M,"src",d);const K=n.name;K&&(M.alt=K),Be(M),w.appendChild(M);const q=n.discountPercent;if(!t.hideProductDiscountBadge&&typeof q=="number"&&q>0){const v=document.createElement("span");v.className="gengage-chat-product-card-discount-badge",v.textContent=`%${Mn(q)}`,w.appendChild(v)}const F=document.createElement("div");F.className="gengage-chat-product-card-img-actions";const ie=n.sku;if(ie&&t.onFavoriteToggle){const v=document.createElement("button");v.className="gengage-chat-favorite-btn",v.type="button",v.dataset.gengageFavoriteSku=ie,v.setAttribute("aria-label",t.i18n?.addToFavoritesLabel??"Add to favorites");const z=t.favoritedSkus?.has(ie)??!1;z&&v.classList.add("gengage-chat-favorite-btn--active"),v.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="${z?"currentColor":"none"}" stroke="currentColor" stroke-width="2"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>`,v.addEventListener("click",N=>{N.stopPropagation(),v.classList.toggle("gengage-chat-favorite-btn--active");const R=v.querySelector("svg");R&&R.setAttribute("fill",v.classList.contains("gengage-chat-favorite-btn--active")?"currentColor":"none"),t.onFavoriteToggle(ie,n)}),F.appendChild(v)}const oe=n.sku,G=t.i18n?.findSimilarLabel??"Find Similar";if(oe){const v=document.createElement("button");v.className="gengage-chat-find-similar-pill",v.type="button",v.setAttribute("aria-label",G),v.dataset.tooltip=G,v.innerHTML='<span class="gengage-chat-find-similar-pill-icon" aria-hidden="true"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"><circle cx="10.5" cy="10.5" r="6.5"/><path d="M16 16l5.5 5.5"/></svg></span>';const z=document.createElement("span");z.className="gengage-chat-find-similar-pill-text",z.textContent=G,v.appendChild(z),v.addEventListener("click",N=>{N.stopPropagation(),t.onAction({title:G,type:"findSimilar",payload:{sku:oe}})}),F.appendChild(v)}F.childElementCount>0&&w.appendChild(F),a.appendChild(w)}const p=document.createElement("div");p.className="gengage-chat-product-card-body";const u=n.brand;if(u){const w=document.createElement("div");w.className="gengage-chat-product-card-brand",w.textContent=u,p.appendChild(w)}const b=n.rating,f=n.reviewCount,m=n.price,h=n.originalPrice,I=n.price_async,_=vt(t,n),y=Nt(t,n),L=!!(h&&m&&h!==m&&parseFloat(m)>0),A=!!(_&&L),k=!!(_&&!A||L&&y==="inline"),E=typeof b=="number"&&Number.isFinite(b)&&b>0,D=document.createElement("div");D.className="gengage-chat-product-card-meta-row";const X=document.createElement("div");X.className="gengage-chat-product-card-price gengage-chat-product-card-price-block";const ae=k?(()=>{const w=document.createElement("div");return w.className="gengage-chat-product-card-price-stack",_&&!A&&w.appendChild(jt(_)),w.appendChild(X),w})():X;if(I===!0){const w=document.createElement("span");w.className="gengage-chat-price-skeleton",X.appendChild(w),setTimeout(()=>{w.parentElement&&(m&&parseFloat(m)>0?Vn(X,t,n,m,n.originalPrice):w.remove())},300)}else m&&parseFloat(m)>0&&Vn(X,t,n,m,h);if((X.childElementCount>0||I===!0)&&D.appendChild(ae),E){const w=document.createElement("div");w.className="gengage-chat-product-card-rating gengage-chat-product-card-rating-compact";const M=wa(b),K=[`${M.toFixed(1)}`,"out of 5 stars"];typeof f=="number"&&Number.isFinite(f)&&K.push(`(${f} reviews)`),w.setAttribute("aria-label",K.join(" "));const q=document.createElement("span");q.className="gengage-chat-product-card-rating-compact-star",q.setAttribute("aria-hidden","true"),q.innerHTML='<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M12 3.6l2.58 5.23 5.77.84-4.17 4.07.98 5.75L12 16.78l-5.16 2.71.99-5.75L3.66 9.67l5.76-.84L12 3.6z"/></svg>';const F=document.createElement("span");F.className="gengage-chat-product-card-rating-compact-value",F.textContent=M.toFixed(1),w.appendChild(q),w.appendChild(F),D.appendChild(w)}if(D.childElementCount===0&&(D.classList.add("gengage-chat-product-card-meta-row--empty"),D.setAttribute("aria-hidden","true")),p.appendChild(D),o){const w=document.createElement("div");w.className="gengage-chat-product-card-name",w.textContent=o,w.title=o,p.appendChild(w)}const de=n.inStock;if(t.hideStockStatus!==!0&&typeof de=="boolean"){const w=document.createElement("div");w.className=`gengage-chat-product-card-stock ${de?"is-in-stock":"is-out-of-stock"}`,w.textContent=de?t.i18n?.inStockLabel??"In Stock":t.i18n?.outOfStockLabel??"Out of Stock",p.appendChild(w)}a.appendChild(p);const H=n.cartCode,S=!!(H&&c&&de!==!1),B=t.i18n?.productCtaLabel??"View";if(S){const w=document.createElement("div");w.className="gengage-chat-product-card-buy-footer";const M=document.createElement("button");M.type="button",M.className="gengage-chat-product-card-buy-trigger",M.textContent=B,M.addEventListener("click",K=>{K.stopPropagation(),t.onAction({title:t.i18n?.addToCartButton??B,type:"addToCart",payload:{sku:c,cartCode:H,quantity:1}})}),w.appendChild(M),a.appendChild(w)}else if(i){const w=document.createElement("button");w.className="gengage-chat-product-card-cta",w.type="button",w.textContent=i.type==="launchSingleProduct"?B:i.title||B,w.addEventListener("click",M=>{if(a.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){M.stopPropagation();return}g()||t.onAction(i)}),a.appendChild(w)}else if(l){const w=document.createElement("a");w.className="gengage-chat-product-card-cta",xe(w,"href",l),xe(w,"target","_blank"),xe(w,"rel","noopener noreferrer"),w.textContent=B,w.addEventListener("click",M=>{if(a.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){M.preventDefault(),M.stopPropagation();return}t.onProductClick&&c&&(M.preventDefault(),t.onProductClick({sku:c,url:l,...o?{name:o}:{}}))}),a.appendChild(w)}if(t.comparisonSelectMode&&c&&t.onToggleComparisonSku){const w=document.createElement("div");w.className="gengage-chat-comparison-select-wrapper";const M=t.comparisonSelectedSkus?.includes(c)??!1;M&&w.classList.add("gengage-chat-comparison-select-wrapper--selected");const K=n.name??c,q=t.i18n?.comparisonSelectCardHint??"Tap anywhere on the card to add or remove it from comparison.";w.setAttribute("role","group"),w.setAttribute("aria-label",`${String(K)}. ${q}`);const F=document.createElement("button");F.type="button",F.className="gengage-chat-comparison-checkbox",F.dataset.selected=M?"true":"false",F.setAttribute("aria-pressed",M?"true":"false");const ie=document.createElement("span");ie.className="gengage-chat-comparison-checkbox-icon",ie.innerHTML=M?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6L9 17l-5-5"/></svg>':'<span class="gengage-chat-comparison-checkbox-dot"></span>';const oe=document.createElement("span");oe.className="gengage-chat-comparison-checkbox-label",oe.textContent=M?t.i18n?.comparisonSelectedLabel??"Selected":t.i18n?.comparisonSelectLabel??"Select to compare",F.appendChild(ie),F.appendChild(oe),F.addEventListener("click",v=>{v.stopPropagation(),t.onToggleComparisonSku?.(c)});const G=document.createElement("div");return G.className="gengage-chat-comparison-card-hint",G.setAttribute("aria-hidden","true"),G.textContent=q,w.addEventListener("click",v=>{v.target.closest(".gengage-chat-comparison-checkbox")||(v.stopPropagation(),t.onToggleComparisonSku?.(c))}),w.appendChild(F),w.appendChild(G),w.appendChild(a),w}return a}var Wn=new Set(["color","colour","renk","renk kodu","color code"]),Ll=new Set(["size","beden","boyut"]),Il=new Set(["finish","bitiş","bitişi"]),Nl=["variants","variantOptions","variant_options","productVariants","product_variants","options"],zl=new Set(["H2","H3","H4","P","BR","UL","OL","LI","STRONG","B","EM","I"]),Ml=new Set(["SCRIPT","STYLE","NOSCRIPT","IFRAME","OBJECT","EMBED"]);function Ne(e,...t){for(const a of t){const n=e[a];if(typeof n=="string"){const r=n.trim();if(r.length>0)return r}}}function Vt(e,...t){for(const a of t){const n=e[a];if(typeof n=="number"&&Number.isFinite(n))return n;if(typeof n=="string"){const r=Number(n.replace(",","."));if(Number.isFinite(r))return r}}}function Gt(e,...t){for(const a of t){const n=e[a];if(typeof n=="boolean")return n}}function Bl(e,...t){for(const a of t){const n=e[a];if(n&&typeof n=="object"&&!Array.isArray(n))return n}}function Rl(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0):[]}function $l(e){const t=[...Rl(e.images),Ne(e,"imageUrl","image_url","image")].filter(a=>!!a&&Ce(a));return Array.from(new Set(t))}function Ol(e){return typeof DOMParser<"u"?(new DOMParser().parseFromString(e,"text/html").body.textContent??"").replace(/\s+/g," ").trim():e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim()}function Dl(e){const t=Ne(e,"description_html","descriptionHtml");if(t){const n=Ol(t);if(n)return{text:n,html:t}}const a=Ne(e,"description");return a?{text:a}:void 0}function Wt(e){return Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object")return null;const a=t,n=Ne(a,"key","name","label","title"),r=a.value,i=typeof r=="string"||typeof r=="number"||typeof r=="boolean"?String(r).trim():void 0;return!n||!i?null:{key:n,value:i}}).filter(t=>t!==null):e&&typeof e=="object"?Object.entries(e).map(([t,a])=>{const n=typeof a=="string"||typeof a=="number"||typeof a=="boolean"?String(a).trim():void 0;return!t||!n?null:{key:t,value:n}}).filter(t=>t!==null):[]}function Kn(e){const t=Wt(e.features);return t.length>0?t:Wt(e.specifications)}function Fl(e){const t=e.specifications,a=Wt(t);if(a.length>0)return Array.isArray(t)?a:Object.fromEntries(a.map(r=>[r.key,r.value]));const n=Wt(e.features);return n.length>0?n:void 0}function Ye(e,...t){return Ne(e,...t)}function Yn(e,...t){return Vt(e,...t)}function Jn(e){return Ye(e,"value","option_value","attribute_value","label","title","name","variant_name","sku")}function Xn(e){const t=Ye(e,"type","attribute","option_name","attribute_name");return t||(Ye(e,"value")?Ye(e,"name","variant_name"):void 0)}function Hl(e){const t=Xn(e)?.toLowerCase();return!!(Ne(e,"color","colour","color_hex","hex","swatch","swatchColor")||t&&Wn.has(t))}function Qn(e){if(!e)return;const t=e.trim();if(!(!t||t.includes(";"))&&(typeof CSS<"u"&&CSS.supports?.("color",t)||/^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)))return t}function Ul(e){const t=Qn(Ye(e,"swatchColor","swatch","color_hex","hex","color","colour"));if(t)return t;if(Hl(e))return Qn(Jn(e))}function jl(e){return Ye(e,"image","imageUrl","image_url","swatchImage","swatch_image")}function Zl(e){return Yn(e,"price_discounted","priceDiscounted")??Ye(e,"price_discounted","priceDiscounted")??Yn(e,"price")??Ye(e,"price")}function ql(e){const t=e.trim().toLowerCase();return Wn.has(t)||Ll.has(t)||Il.has(t)}function Vl(e){const t=e.trim().toLowerCase();return t==="renk kodu"?"Renk":t==="color code"?"Color":e.trim()}function Gl(e){for(const t of Nl){const a=e[t];if(!Array.isArray(a))continue;const n=a.filter(r=>!!r&&typeof r=="object"&&!Array.isArray(r));if(n.length>0)return n}}function Wl(e){const t=Gl(e);if(t)return t;const a=Ne(e,"sku"),n=Gt(e,"inStock","in_stock"),r=[],i=new Set,o=(c,l)=>{if(!ql(c)||typeof l!="string"&&typeof l!="number"&&typeof l!="boolean")return;const g=String(l).trim();if(!g)return;const d=Vl(c),p=`${d.toLowerCase()}:${g.toLowerCase()}`;i.has(p)||(i.add(p),r.push({name:d,value:g,sku:a,inStock:n}))},s=Bl(e,"facetHits","facet_hits");if(s)for(const[c,l]of Object.entries(s))o(c,l);for(const c of Kn(e))o(c.key,c.value);return r}function Kl(e,t){const a=Array.from(new Set(e.map(Xn).filter(n=>!!n)));return a.length===1?`${e.length} ${a[0]}`:t.i18n?.variantsLabel??"Variants"}function Yl(e,t){const a=document.createElement("article");a.className="gengage-chat-product-details-panel";const n=e.props?.product??e.props;if(!n)return a;const r=Ne(n,"name"),i=Ne(n,"brand"),o=Ne(n,"sku"),s=Ne(n,"cartCode","cart_code"),c=Ne(n,"price"),l=Ne(n,"originalPrice","price_original"),g=Gt(n,"price_async"),d=vt(t,n),p=Nt(t,n),u=!!(l&&c&&l!==c),b=Gt(n,"inStock","in_stock"),f=Vt(n,"reviewCount","review_count"),m=Vt(n,"rating"),h=$l(n),I=Kn(n).slice(0,4);if(h.length>1){const S=document.createElement("div");S.className="gengage-chat-product-details-media gengage-chat-product-details-gallery gengage-chat-product-details-img-wrap";const B=document.createElement("img");B.className="gengage-chat-product-details-img",xe(B,"src",h[0]),B.alt=r??"Product image",Be(B),S.appendChild(B);const w=document.createElement("div");w.className="gengage-chat-product-gallery-thumbs";const M=6;let K=null,q=0;const F=t.i18n,ie=F?.galleryPrevAriaLabel??"Previous image",oe=F?.galleryNextAriaLabel??"Next image",G=Z=>Z==="prev"?'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="15 18 9 12 15 6"/></svg>':'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="9 18 15 12 9 6"/></svg>',v=document.createElement("button");v.type="button",v.className="gengage-chat-product-gallery-nav gengage-chat-product-gallery-nav--prev gds-btn gds-btn-ghost gds-icon-btn",v.setAttribute("aria-label",ie),v.innerHTML=G("prev");const z=document.createElement("button");z.type="button",z.className="gengage-chat-product-gallery-nav gengage-chat-product-gallery-nav--next gds-btn gds-btn-ghost gds-icon-btn",z.setAttribute("aria-label",oe),z.innerHTML=G("next");const N=()=>{v.disabled=q<=0,z.disabled=q>=h.length-1},R=Z=>{if(Z<0||Z>=h.length||Z===q)return;const ne=h[Z];if(!ne)return;xe(B,"src",ne);const Y=w.querySelectorAll(".gengage-chat-product-gallery-thumb");K&&K.classList.remove("gengage-chat-product-gallery-thumb--active"),Z<M&&Y[Z]?(Y[Z].classList.add("gengage-chat-product-gallery-thumb--active"),K=Y[Z]):K=null,q=Z,N()};for(let Z=0;Z<h.length;Z++){const ne=h[Z];if(Z>=M)break;const Y=document.createElement("img");Y.className="gengage-chat-product-gallery-thumb",Z===0&&(Y.classList.add("gengage-chat-product-gallery-thumb--active"),K=Y),xe(Y,"src",ne),Y.alt=`${r??"Product"} ${Z+1}`,Y.width=48,Y.height=48,Be(Y),Y.addEventListener("click",()=>{R(Z)}),w.appendChild(Y)}if(h.length>M){const Z=document.createElement("span");Z.className="gengage-chat-product-gallery-thumb-more",Z.textContent=`+${h.length-M}`,w.appendChild(Z)}v.addEventListener("click",Z=>{Z.stopPropagation(),R(q-1)}),z.addEventListener("click",Z=>{Z.stopPropagation(),R(q+1)}),N();let U=0;const j=50;B.addEventListener("touchstart",Z=>{U=Z.changedTouches[0].clientX},{passive:!0}),B.addEventListener("touchend",Z=>{const ne=Z.changedTouches[0].clientX,Y=U-ne;Math.abs(Y)<j||R(Y>0?Math.min(q+1,h.length-1):Math.max(q-1,0))}),S.appendChild(v),S.appendChild(z),S.appendChild(w),a.appendChild(S)}else if(h.length===1){const S=document.createElement("div");S.className="gengage-chat-product-details-media gengage-chat-product-details-img-wrap";const B=document.createElement("img");B.className="gengage-chat-product-details-img",B.loading="lazy",xe(B,"src",h[0]),Be(B),B.alt=r??"Product image",S.appendChild(B),a.appendChild(S)}const _=document.createElement("div");if(_.className="gengage-chat-product-details-content",i&&(!r||!r.toLowerCase().startsWith(i.toLowerCase()))){const S=document.createElement("div");S.className="gengage-chat-product-details-brand",S.textContent=i,_.appendChild(S)}if(r){const S=document.createElement("h3");S.className="gengage-chat-product-details-title",S.textContent=r,S.title=r,_.appendChild(S)}if(t.hideUserReviews!==!0&&typeof m=="number"&&Number.isFinite(m)&&m>0){const S=document.createElement(o?"button":"div");S.className="gengage-chat-product-details-rating",o&&(S.type="button",S.classList.add("gengage-chat-product-details-rating--clickable"),S.setAttribute("aria-label",t.i18n?.groundingReviewCta??"Read Reviews"),S.addEventListener("click",()=>{t.onAction({title:t.i18n?.customerReviewsTitle??"Customer Reviews",type:"reviewSummary",payload:{sku:o}})})),S.appendChild(Bn(m));const B=document.createElement("span");if(B.className="gengage-chat-product-details-rating-value",B.textContent=wa(m).toFixed(1),S.appendChild(B),typeof f=="number"&&Number.isFinite(f)){const w=document.createElement("span");w.className="gengage-chat-product-details-review-count",w.textContent=` (${f})`,S.appendChild(w)}_.appendChild(S)}{const S=!!(d&&u);let B=_;if(d&&!S){const M=document.createElement("div");M.className="gengage-chat-product-details-price-stack",M.appendChild(jt(d)),_.appendChild(M),B=M}const w=document.createElement("div");if(w.className="gengage-chat-product-details-price",g===!0){const M=document.createElement("span");M.className="gengage-chat-price-skeleton",w.appendChild(M),B.appendChild(w),setTimeout(()=>{if(M.parentElement)if(c&&parseFloat(c)>0)Gn(w,t,n,c,l,p,u);else{const K=w.parentElement;w.remove(),K?.classList.contains("gengage-chat-product-details-price-stack")&&K.remove()}},300)}else if(c&&parseFloat(c)>0)Gn(w,t,n,c,l,p,u),B.appendChild(w);else if(d){const M=B;M.classList.contains("gengage-chat-product-details-price-stack")&&M.remove()}}if(t.hideStockStatus!==!0&&typeof b=="boolean"){const S=document.createElement("div");S.className=`gengage-chat-product-details-stock ${b?"is-in-stock":"is-out-of-stock"}`,S.textContent=b?t.i18n?.inStockLabel??"In Stock":t.i18n?.outOfStockLabel??"Out of Stock",_.appendChild(S)}const y=n.promotions;if(y&&y.length>0){const S=document.createElement("div");S.className="gengage-chat-product-details-promos";for(const B of y.slice(0,3)){if(!B||/%(0(\.0+)?)\s/.test(B))continue;const w=document.createElement("span");w.className="gengage-chat-product-details-promo-badge",w.textContent=B,w.title=B,S.appendChild(w)}S.childElementCount>0&&_.appendChild(S)}if(I.length>0){const S=document.createElement("dl");S.className="gengage-chat-product-details-facts";for(const B of I){const w=document.createElement("div");w.className="gengage-chat-product-details-fact";const M=document.createElement("dt");M.textContent=B.key;const K=document.createElement("dd");K.textContent=B.value,w.appendChild(M),w.appendChild(K),S.appendChild(w)}_.appendChild(S)}const L=Wl(n);if(L.length>0){const S=document.createElement("div");S.className="gengage-chat-product-variants";const B=document.createElement("div");B.className="gengage-chat-product-variants-label",B.textContent=Kl(L,t),S.appendChild(B);const w=document.createElement("div");w.className="gengage-chat-product-variants-list";for(const M of L){const K=Jn(M),q=Ye(M,"sku");if(!K&&!q)continue;const F=document.createElement("button");F.className="gengage-chat-product-variant-btn gds-chip",F.type="button";const ie=K??q??"";F.title=ie;const oe=Gt(M,"in_stock","inStock");q&&o&&q===o?(F.classList.add("gengage-chat-product-variant-btn--active"),F.setAttribute("aria-pressed","true")):F.setAttribute("aria-pressed","false"),oe===!1&&(F.classList.add("gengage-chat-product-variant-btn--out"),F.disabled=!0);const G=jl(M),v=Ul(M);if(G&&Ce(G)){const R=document.createElement("img");R.className="gengage-chat-product-variant-swatch gengage-chat-product-variant-swatch--image",xe(R,"src",G),R.alt="",R.setAttribute("aria-hidden","true"),Be(R),F.appendChild(R)}else if(v){const R=document.createElement("span");R.className="gengage-chat-product-variant-swatch",R.setAttribute("aria-hidden","true"),R.style.backgroundColor=v,F.appendChild(R)}const z=document.createElement("span");z.className="gengage-chat-product-variant-label",z.textContent=ie,F.appendChild(z);const N=Zl(M);if(N&&String(N)!==String(c)){const R=document.createElement("span");R.className="gengage-chat-product-variant-price",R.textContent=se(String(N),t.pricing),F.appendChild(R)}if(q&&q!==o){const R=r??"",U=(typeof M.value=="string"?M.value.trim():"")||(typeof M.name=="string"?M.name.trim():"")||(typeof M.variant_name=="string"?M.variant_name.trim():"")||"",j=R.length>0?U.length>0&&U!==R?`${R} (${U})`:R:ie;F.addEventListener("click",()=>{t.onAction({title:j,type:"launchVariant",payload:{sku:q}})})}w.appendChild(F)}w.childElementCount>0&&(S.appendChild(w),_.appendChild(S))}const A=document.createElement("div");A.className="gengage-chat-product-details-actions";const k=e.props?.action;if(k){const S=document.createElement("button");S.className="gengage-chat-product-details-cta gds-btn gds-btn-primary",S.type="button",S.textContent=k.title||t.i18n?.productCtaLabel||"View",S.addEventListener("click",()=>t.onAction(k)),A.appendChild(S)}if(s&&o&&b!==!1){const S=document.createElement("button");S.className="gengage-chat-product-details-atc gds-btn gds-btn-primary",S.type="button",S.textContent=t.i18n?.addToCartButton??"Add to Cart",S.addEventListener("click",()=>{t.onAction({title:t.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:o,cartCode:s,quantity:1}})}),A.appendChild(S)}const E=Ne(n,"url");if(!k&&E&&Ce(E)){const S=document.createElement("a");S.className="gengage-chat-product-details-cta gds-btn gds-btn-secondary",xe(S,"href",E),xe(S,"target","_blank"),xe(S,"rel","noopener noreferrer"),S.textContent=t.i18n?.viewOnSiteLabel??t.i18n?.productCtaLabel??"View on Site",S.addEventListener("click",B=>{t.onProductClick&&o&&(B.preventDefault(),t.onProductClick({sku:o,url:E,...r?{name:r}:{}}))}),A.appendChild(S)}const D=E;if(D&&Ce(D)){let K=function(F,ie){const oe=document.createElementNS(w,"circle");oe.setAttribute("cx",F),oe.setAttribute("cy",ie),oe.setAttribute("r","3"),M.appendChild(oe)},q=function(F,ie,oe,G){const v=document.createElementNS(w,"line");v.setAttribute("x1",F),v.setAttribute("y1",ie),v.setAttribute("x2",oe),v.setAttribute("y2",G),M.appendChild(v)};var de=K,H=q;const S=document.createElement("button");S.className="gengage-chat-product-details-share gds-btn gds-btn-ghost gds-icon-btn",S.type="button";const B=t.i18n?.shareButton??"Share";S.title=B,S.setAttribute("aria-label",B);const w="http://www.w3.org/2000/svg",M=document.createElementNS(w,"svg");M.setAttribute("width","18"),M.setAttribute("height","18"),M.setAttribute("viewBox","0 0 24 24"),M.setAttribute("fill","none"),M.setAttribute("stroke","currentColor"),M.setAttribute("stroke-width","2"),M.setAttribute("stroke-linecap","round"),M.setAttribute("stroke-linejoin","round"),K("18","5"),K("6","12"),K("18","19"),q("8.59","13.51","15.42","17.49"),q("15.41","6.51","8.59","10.49"),S.appendChild(M),S.addEventListener("click",async()=>{try{navigator.share?await navigator.share({title:r??"",url:D}):navigator.clipboard&&(await navigator.clipboard.writeText(D),S.classList.add("gengage-chat-product-details-share--copied"),setTimeout(()=>S.classList.remove("gengage-chat-product-details-share--copied"),1500))}catch{}}),A.appendChild(S)}A.childElementCount>0&&_.appendChild(A),a.appendChild(_);const X=Dl(n),ae=Fl(n);return(X||ae)&&a.appendChild(Ql(X,ae,t)),a}function Pa(e){if(e.nodeType===Node.TEXT_NODE)return document.createTextNode(e.textContent??"");if(e.nodeType!==Node.ELEMENT_NODE)return null;const t=e,a=t.tagName.toUpperCase();if(Ml.has(a))return null;if(!zl.has(a)){const r=document.createDocumentFragment();for(const i of Array.from(t.childNodes)){const o=Pa(i);o&&r.appendChild(o)}return r}const n=document.createElement(a.toLowerCase());for(const r of Array.from(t.childNodes)){const i=Pa(r);i&&n.appendChild(i)}return n}function Jl(e,t){const a=t.split(/\n{2,}/).map(n=>n.replace(/\s+/g," ").trim()).filter(Boolean);if(a.length!==0)for(const n of a){const r=document.createElement("p");r.textContent=n,e.appendChild(r)}}function Xl(e,t){if(e.classList.add("gengage-chat-product-description"),t.html&&typeof DOMParser<"u"){const a=new DOMParser().parseFromString(t.html,"text/html"),n=Array.from(a.body.childNodes).map(r=>Pa(r)).filter(r=>!!r&&(r.nodeType===Node.ELEMENT_NODE||!!r.textContent?.trim()));if(n.length>0){for(const r of n)e.appendChild(r);return}}Jl(e,t.text)}function Ql(e,t,a){const n=document.createElement("div");n.className="gengage-chat-product-detail-tabs";const r=document.createElement("div");r.className="gengage-chat-product-detail-tab-bar gds-toolbar";const i=[];if(e){const s=document.createElement("button");s.className="gengage-chat-product-detail-tab gds-tab gengage-chat-product-detail-tab--active is-active",s.type="button",s.setAttribute("aria-selected","true"),s.textContent=a.i18n?.productInfoTab??"Product Info",r.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-product-detail-tab-panel",Xl(c,e),i.push(c)}if(t){const s=document.createElement("button");s.className=`gengage-chat-product-detail-tab gds-tab${e?"":" gengage-chat-product-detail-tab--active is-active"}`,s.type="button",s.setAttribute("aria-selected",e?"false":"true"),s.textContent=a.i18n?.specificationsTab??"Specifications",r.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-product-detail-tab-panel",e&&(c.style.display="none");const l=document.createElement("table");l.className="gengage-chat-product-specs-table";const g=Array.isArray(t)?t:Object.entries(t).map(([d,p])=>({key:d,value:p}));for(const d of g){const p=document.createElement("tr"),u=document.createElement("td");u.className="gengage-chat-product-specs-key",u.textContent=d.key;const b=document.createElement("td");b.className="gengage-chat-product-specs-value",b.textContent=d.value,p.appendChild(u),p.appendChild(b),l.appendChild(p)}c.appendChild(l),i.push(c)}const o=r.querySelectorAll(".gengage-chat-product-detail-tab");o.forEach((s,c)=>{s.addEventListener("click",()=>{o.forEach(l=>{l.classList.remove("gengage-chat-product-detail-tab--active","is-active"),l.setAttribute("aria-selected","false")}),s.classList.add("gengage-chat-product-detail-tab--active","is-active"),s.setAttribute("aria-selected","true"),i.forEach((l,g)=>{l.style.display=g===c?"":"none"})})}),n.appendChild(r);for(const s of i)n.appendChild(s);return n}function er(e){const t='width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"';switch(e){case"related":return`<svg ${t} aria-hidden="true"><path d="M13 2 3 14h9l-1 8 10-12h-9l1-8z"/></svg>`;case"priceAsc":return`<svg ${t} aria-hidden="true"><polyline points="22 7 13.5 15.5 8.5 10.5 2 17"/><polyline points="16 7 22 7 22 13"/></svg>`;case"priceDesc":return`<svg ${t} aria-hidden="true"><polyline points="22 17 13.5 8.5 8.5 13.5 2 7"/><polyline points="16 17 22 17 22 11"/></svg>`;default:return""}}function eg(){return'<svg class="gengage-chat-product-sort-chevron" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg>'}function tg(){return'<svg class="gengage-chat-product-sort-check" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="20 6 9 17 4 12"/></svg>'}function ag(){return'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 3 4 7l4 4"/><path d="M16 21l4-4-4-4"/><path d="M4 7h16"/><path d="M20 17H4"/></svg>'}function tr(e,t){return e.type===t.type&&e.direction===t.direction}function ar(e,t,a){if(!a||a.type==="related")return e;const n=e.map(r=>{const i=t.elements[r]?.props?.product,o=i?Number(i.price):NaN;return{id:r,price:Number.isFinite(o)?o:1/0}});return n.sort((r,i)=>r.price===1/0&&i.price===1/0?0:r.price===1/0?1:i.price===1/0?-1:a.direction==="desc"?i.price-r.price:r.price-i.price),n.map(r=>r.id)}function ng(e,t,a,n){const r=ar(t,a,n),i=new Map;for(const o of Array.from(e.children)){const s=o.dataset.elementId;s&&i.set(s,o)}for(const o of r){const s=i.get(o);s&&e.appendChild(s)}}function rg(e,t,a,n){const r=document.createElement("div");r.className="gengage-chat-product-grid-wrapper";const i=Ia(e),o=i.isConsulting,s=e.children??[],c=document.createElement("div");c.className="gengage-chat-product-grid";const l=n?.panelProductListHeading;if(!o&&s.length>1&&n?.onSortChange){const p=document.createElement("div");p.className="gengage-chat-product-sort-toolbar",p.setAttribute("role","toolbar"),p.setAttribute("aria-label",n.i18n?.sortToolbarAriaLabel??"Sort products");let u=n.productSort??{type:"related"};const b=[{label:n.i18n?.sortRelated??"Related",sortState:{type:"related"},icon:"related"},{label:n.i18n?.sortPriceAsc??"Price ↑",sortState:{type:"price",direction:"asc"},icon:"priceAsc"},{label:n.i18n?.sortPriceDesc??"Price ↓",sortState:{type:"price",direction:"desc"},icon:"priceDesc"}],f=document.createElement("div");f.className="gengage-chat-product-sort-dropdown";const m=document.createElement("button");m.type="button",m.className="gengage-chat-product-sort-trigger gds-btn gds-btn-ghost",m.setAttribute("aria-haspopup","listbox"),m.setAttribute("aria-expanded","false");const h=n.i18n?.sortToolbarAriaLabel??"Sort products",I=document.createElement("span");I.className="gengage-chat-product-sort-trigger-icon";const _=document.createElement("span");_.className="gengage-chat-product-sort-trigger-label";const y=H=>{const S=b.find(B=>tr(B.sortState,H))??b[0];_.textContent=S.label,I.innerHTML=er(S.icon),f.dataset.sortIcon=S.icon,m.setAttribute("aria-label",`${h}: ${S.label}`),m.title=S.label};y(u);const L=document.createElement("span");L.className="gengage-chat-product-sort-trigger-chevron",L.innerHTML=eg(),m.appendChild(I),m.appendChild(_),m.appendChild(L);const A=document.createElement("div");A.className="gengage-chat-product-sort-menu gds-menu",A.hidden=!0,A.setAttribute("role","listbox"),A.setAttribute("aria-label",h);const k=p.ownerDocument;let E=null;const D=()=>{A.hidden=!0,f.classList.remove("gengage-chat-product-sort-dropdown--open"),m.setAttribute("aria-expanded","false"),E?.abort(),E=null},X=H=>{f.classList.contains("gengage-chat-product-sort-dropdown--open")&&(f.contains(H.target)||D())},ae=H=>{H.key==="Escape"&&(H.preventDefault(),D())},de=()=>{A.hidden=!1,f.classList.add("gengage-chat-product-sort-dropdown--open"),m.setAttribute("aria-expanded","true"),E=new AbortController;const{signal:H}=E;k.addEventListener("click",X,{signal:H}),k.addEventListener("keydown",ae,{capture:!0,signal:H})};m.addEventListener("click",H=>{H.stopPropagation(),f.classList.contains("gengage-chat-product-sort-dropdown--open")?D():de()});for(const H of b){const S=document.createElement("button");S.type="button",S.className="gengage-chat-product-sort-option gds-menu-option",S.setAttribute("role","option");const B=tr(u,H.sortState);S.setAttribute("aria-selected",B?"true":"false"),B&&S.classList.add("gengage-chat-product-sort-option--active","gds-menu-option-active");const w=H.sortState.type==="related"?"related":`price-${H.sortState.direction??""}`;S.dataset.sortKey=w;const M=document.createElement("span");M.className="gengage-chat-product-sort-option-icon",M.innerHTML=er(H.icon);const K=document.createElement("span");K.className="gengage-chat-product-sort-option-label",K.textContent=H.label;const q=document.createElement("span");q.className="gengage-chat-product-sort-option-check",q.innerHTML=tg(),q.setAttribute("aria-hidden","true"),B||q.classList.add("gengage-chat-product-sort-option-check--hidden"),S.appendChild(M),S.appendChild(K),S.appendChild(q),S.addEventListener("click",()=>{u=H.sortState,n.onSortChange?.(H.sortState),ng(c,s,t,H.sortState),A.querySelectorAll(".gengage-chat-product-sort-option").forEach(F=>{const ie=F,oe=ie.dataset.sortKey===w;ie.classList.toggle("gengage-chat-product-sort-option--active",oe),ie.classList.toggle("gds-menu-option-active",oe),ie.setAttribute("aria-selected",oe?"true":"false"),ie.querySelector(".gengage-chat-product-sort-option-check")?.classList.toggle("gengage-chat-product-sort-option-check--hidden",!oe)}),y(H.sortState),D()}),A.appendChild(S)}if(f.appendChild(m),f.appendChild(A),p.appendChild(f),n.onToggleComparisonSku){const H=document.createElement("button");H.className="gengage-chat-comparison-toggle-btn gds-btn gds-btn-ghost",H.type="button",n.comparisonSelectMode&&H.classList.add("gengage-chat-comparison-toggle-btn--active"),n.isStreaming&&H.classList.add("gengage-chat-comparison-toggle-btn--hidden");const S=document.createElement("span");S.className="gengage-chat-comparison-toggle-icon",S.innerHTML=ag();const B=document.createElement("span");B.className="gengage-chat-comparison-toggle-label";const w=n.i18n?.compareSelected??"Compare";B.textContent=w,H.setAttribute("aria-label",w),H.title=w,H.appendChild(S),H.appendChild(B),H.addEventListener("click",()=>{n.onToggleComparisonSku?.("")}),p.appendChild(H)}if(l){p.classList.add("gengage-chat-product-sort-toolbar--inline");const H=document.createElement("div");H.className="gengage-chat-product-grid-head";const S=document.createElement("span");S.className="gengage-chat-product-grid-head-title",S.textContent=l,H.appendChild(S);const B=document.createElement("div");B.className="gengage-chat-product-grid-head-actions",B.appendChild(p),H.appendChild(B),r.appendChild(H)}else r.appendChild(p)}else if(l){const p=document.createElement("div");p.className="gengage-chat-product-grid-head";const u=document.createElement("span");u.className="gengage-chat-product-grid-head-title",u.textContent=l,p.appendChild(u),r.appendChild(p)}if(o)pg(r,c,i,n);else{const p=ar(s,t,n?.productSort);for(const u of p){if(!t.elements[u])continue;const b=a(u);b&&(b.dataset.elementId=u,c.appendChild(b))}}(n?.isMobile??Ca())&&c.classList.add("gengage-chat-product-grid--mobile"),e.props?.rankingState==="pending"&&(c.classList.add("gengage-chat-product-grid--pending"),c.inert=!0,c.setAttribute("aria-busy","true")),r.appendChild(c);const g=e.props?.endOfList;if(!o&&g!==!0&&s.length>0){const p=n?.i18n?.viewMoreLabel??"Show More",u=document.createElement("button");u.className="gengage-chat-product-grid-view-more",u.type="button",u.textContent=p,u.addEventListener("click",()=>{n?.onAction({title:p,type:"moreProductList",payload:{}})}),r.appendChild(u)}const d=n?.isMobile??Ca();if(n?.comparisonSelectMode&&n.comparisonSelectedSkus&&!d){const p=Un(n.comparisonSelectedSkus,n);r.appendChild(p)}return r}function ig(e,t,a){const n=r=>{const i=r?.url;return typeof i=="string"?i.trim():""};if(t.sku===e){const r=n(t);if(r.length>0)return r}return n(a.find(r=>r.sku===e))}function og(e,t){const a=e.props??{},n=a.keyDifferencesHtml,r=a.recommended,i=a.products??[],o=a.attributes??[],s=a.highlights??[],c=a.specialCases,l=a.recommendedText,g=a.winnerHits,d=a.productActions;if(!r)return document.createElement("div");const p={recommended:r,products:i,attributes:o,highlights:s,specialCases:c,locale:t.locale,onProductClick:({sku:b,name:f})=>{const m=ig(b,r,i);t.onProductClick?.({sku:b,url:m,...f!==void 0&&f!==""?{name:f}:{}})},pricing:t.pricing};l!==void 0&&(p.recommendedText=l),g!==void 0&&(p.winnerHits=g),d!==void 0&&(p.productActions=d),n!==void 0&&(p.keyDifferencesHtml=n),t.i18n&&(p.i18n={comparisonHeading:t.i18n.panelTitleComparisonResults,recommendedChoiceLabel:t.i18n.recommendedChoiceLabel,highlightsLabel:t.i18n.highlightsLabel,keyDifferencesLabel:t.i18n.keyDifferencesLabel,viewMoreLabel:t.i18n.viewMoreLabel,specialCasesLabel:t.i18n.specialCasesLabel,addToCartButton:t.i18n.addToCartButton});const u=jc(p);return(t.isMobile??Ca())&&u.classList.add("gengage-chat-comparison--mobile"),u}function sg(e){const t=document.createElement("hr");t.className="gengage-chat-divider";const a=e.props?.label;if(a){const n=document.createElement("div");n.className="gengage-chat-divider-wrapper";const r=document.createElement("span");r.className="gengage-chat-divider-label",r.textContent=a,n.appendChild(t),n.appendChild(r);const i=document.createElement("hr");return i.className="gengage-chat-divider",n.appendChild(i),n}return t}var Kt=new WeakMap;function nr(e){return{...bt,...e?.i18n??{}}}function rr(e){return e.watchStylesPreparedTitle??e.beautyStylesPreparedTitle}function Yt(e){return typeof e.status=="string"?e.status:"ready"}function Ta(e){const t=e.findIndex(a=>Yt(a)!=="loading");return t<0?0:t}function cg(e){if(typeof e!="string")return;const t=e.trim();if(!t)return;if(/^https?:\/\//i.test(t))return t;let a=t.split(/[?#]/)[0];if(a&&(a=a.replace(/^\/+/,""),a.startsWith("remoteConfig/")&&(a=a.slice(13)),!!a))return`https://configs.gengage.ai/assets/${a}`}function ir(e,t,a,n){const{grid:r,i18n:i}=e;r.innerHTML="",r.classList.remove("gengage-chat-product-grid--consulting-groups");const o=document.createElement("section");o.className="gengage-chat-consulting-loading-panel";const s=document.createElement("h4");s.className="gengage-chat-consulting-loading-panel-title",s.textContent=Jt(t,n,i),o.appendChild(s);const c=document.createElement("p");if(c.className="gengage-chat-consulting-loading-panel-copy",c.textContent=a==="loading"?i.consultingStyleLoadingDescription:i.consultingStyleUnavailableDescription,o.appendChild(c),a==="loading"){const l=document.createElement("div");l.className="gengage-chat-consulting-loading-grid";for(let g=0;g<3;g+=1){const d=document.createElement("div");d.className="gengage-chat-consulting-loading-card",l.appendChild(d)}o.appendChild(l)}r.appendChild(o)}function Jt(e,t,a){const n=r=>a.consultingFallbackStyleLabel.replace("{index}",String(r));return e.style_label??n(t)}function Aa(e,t){const a=e.variations[t];if(!a)return;const{grid:n,ctx:r,i18n:i}=e;n.innerHTML="",n.classList.remove("gengage-chat-product-grid--consulting-groups");const o=Yt(a),s=t+1;if(o==="loading"){ir(e,a,"loading",s);return}if(o!=="ready"&&(!Array.isArray(a.product_list)||a.product_list.length===0)){ir(e,a,"unavailable",s);return}const c=Array.isArray(a.product_list)?a.product_list:[],l=Array.isArray(a.recommendation_groups)?a.recommendation_groups:[];if(l.length>0){n.classList.add("gengage-chat-product-grid--consulting-groups");const g=new Map;for(const m of c){const h=typeof m?.sku=="string"?m.sku:void 0;h&&g.set(h,m)}const d=(m,h,I,_)=>{if(h.length===0)return;const y=document.createElement("section");y.className="gengage-chat-consulting-group";const L=document.createElement("div");L.className="gengage-chat-consulting-group-header";const A=document.createElement("h4");if(A.className="gengage-chat-consulting-group-label",A.textContent=`${m} (${h.length})`,L.appendChild(A),typeof _=="string"&&_.trim().length>0){const E=document.createElement("p");E.className="gengage-chat-consulting-group-reason",E.textContent=_,L.appendChild(E)}y.appendChild(L);const k=document.createElement("div");k.className="gengage-chat-product-grid gengage-chat-consulting-group-grid",I&&k.classList.add("gengage-chat-consulting-group-grid--single-group"),k.style.setProperty("--consulting-group-columns",String(Math.max(1,Math.min(4,h.length))));for(const E of h){const D=Ea({type:"ProductCard",props:{product:E}},r??{onAction:()=>{}});k.appendChild(D)}y.appendChild(k),n.appendChild(y)},p=new Set,u=[];for(const m of l){const h=(Array.isArray(m.skus)?m.skus.filter(y=>typeof y=="string"&&y.trim().length>0):[]).map(y=>(p.add(y),g.get(y))).filter(y=>!!y);if(h.length===0)continue;const I=typeof m.label=="string"&&m.label.trim().length>0?m.label:i.consultingFallbackGroupLabel,_=typeof m.reason=="string"?m.reason:void 0;u.push({labelText:I,products:h,..._!==void 0?{reasonText:_}:{}})}const b=c.filter(m=>{const h=typeof m?.sku=="string"?m.sku:"";return h.length>0&&!p.has(h)});b.length>0&&u.push({labelText:i.consultingOtherCompatibleProductsLabel,products:b});const f=u.length===1;for(const m of u)d(m.labelText,m.products,f,m.reasonText);return}for(const g of c){const d=Ea({type:"ProductCard",props:{product:g}},r??{onAction:()=>{}});n.appendChild(d)}}function La(e,t,a,n){const r=Yt(t),i=n.consultingStyleLoadingBadge,o=n.consultingStyleUnavailableBadge;e.classList.remove("gengage-chat-consulting-style-btn--loading","gengage-chat-consulting-style-btn--muted"),r==="loading"?e.classList.add("gengage-chat-consulting-style-btn--loading"):r!=="ready"&&e.classList.add("gengage-chat-consulting-style-btn--muted"),e.setAttribute("aria-label",Jt(t,a+1,n));let s=e.querySelector(".gengage-chat-consulting-style-media");s?s.innerHTML="":(s=document.createElement("div"),s.className="gengage-chat-consulting-style-media",e.appendChild(s));const c=cg(t.image_url);if(c&&Ce(c)){const g=document.createElement("img");g.className="gengage-chat-consulting-style-image",g.draggable=!1,xe(g,"src",c),g.alt=Jt(t,a+1,n),g.loading="lazy",Be(g),s.appendChild(g)}const l=document.createElement("span");if(l.className="gengage-chat-consulting-style-caption",l.textContent=Jt(t,a+1,n),s.appendChild(l),r==="loading"||r!=="ready"){const g=document.createElement("span");g.className="gengage-chat-consulting-style-status",g.textContent=r==="loading"?i:o,s.appendChild(g)}}function or(e,t,a,n){e.addEventListener("click",()=>{const r=Kt.get(t);r&&r.selectedIndex!==n&&(r.selectedIndex=n,a.querySelectorAll(".gengage-chat-consulting-style-btn").forEach((i,o)=>{i.classList.toggle("gengage-chat-consulting-style-btn--active",o===n)}),Aa(r,n))})}function lg(e,t,a,n){const r=nr(n),i=Ta(a),o=document.createElement("div");o.className="gengage-chat-consulting-style-picker";const s={grid:t,ctx:n,variations:a,i18n:r,selectedIndex:i};Kt.set(o,s);const c=document.createElement("div");c.className="gengage-chat-consulting-style-picker-title",c.textContent=rr(r).replace("{count}",String(a.length)),o.appendChild(c);const l=document.createElement("div");l.className="gengage-chat-consulting-style-grid",o.appendChild(l),a.forEach((g,d)=>{const p=document.createElement("button");p.type="button",p.className="gengage-chat-consulting-style-btn gds-card",d===i&&p.classList.add("gengage-chat-consulting-style-btn--active"),La(p,g,d,r),or(p,o,l,d),l.appendChild(p)}),e.appendChild(o),Aa(s,i)}function gg(e,t,a){const n=e.querySelector(".gengage-chat-consulting-style-picker"),r=dg(e);if(!n||!r)return!1;const i=n.querySelector(".gengage-chat-consulting-style-grid");if(!i)return!1;const o=nr(a);let s=Kt.get(n);if(s)s.grid=r,s.ctx=a,s.variations=t,s.i18n=o;else{const p={grid:r,ctx:a,variations:t,i18n:o,selectedIndex:Ta(t)};Kt.set(n,p),s=p}const c=n.querySelector(".gengage-chat-consulting-style-picker-title");c&&(c.textContent=rr(o).replace("{count}",String(t.length)));const l=s;let g=l.selectedIndex;g>=t.length&&(g=Math.max(0,t.length-1)),g<0&&(g=0),t.length>0&&Yt(t[g]??{})==="loading"&&(g=Ta(t)),l.selectedIndex=g;const d=[...i.querySelectorAll(".gengage-chat-consulting-style-btn")];if(d.length===0)return!1;for(let p=0;p<t.length;p+=1){const u=t[p];let b=d[p];b?La(b,u,p,o):(b=document.createElement("button"),b.type="button",b.className="gengage-chat-consulting-style-btn gds-card",La(b,u,p,o),or(b,n,i,p),i.appendChild(b),d[p]=b)}for(;i.querySelectorAll(".gengage-chat-consulting-style-btn").length>t.length;)i.lastElementChild?.remove();return i.querySelectorAll(".gengage-chat-consulting-style-btn").forEach((p,u)=>{p.classList.toggle("gengage-chat-consulting-style-btn--active",u===l.selectedIndex)}),Aa(l,l.selectedIndex),!0}function dg(e){const t=[...e.children];for(let a=t.length-1;a>=0;a-=1){const n=t[a];if(n.classList.contains("gengage-chat-product-grid"))return n}return e.querySelector(":scope > .gengage-chat-product-grid")}function Ia(e){const t=typeof e.props?.source=="string"?e.props.source:void 0,a=(Array.isArray(e.props?.styleVariations)?e.props.styleVariations:[]).filter(n=>typeof n.style_label=="string"&&n.style_label.trim().length>0);return{isConsulting:pn(t)&&a.length>0,source:t,styleVariations:a}}function pg(e,t,a,n){lg(e,t,a.styleVariations,n)}function hg(e){return!e.isConsulting||e.styleVariations.length===0?!0:e.styleVariations.some(t=>(typeof t.status=="string"?t.status:"ready")!=="loading")}function ug(e,t,a){return!t.isConsulting||!t.source?!1:gg(e,t.styleVariations,a)}var mg=`<svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
50
50
  <rect x="3" y="7" width="18" height="13" rx="3" fill="currentColor" opacity="0.15"/>