@gengage/assistant-fe 0.4.6 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -1
- package/dist/{api-paths-C4GDpeTf.js → api-paths-DR5bPNhi.js} +2 -3
- package/dist/assistant-fe.css +1 -1
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +2 -2
- package/dist/chat.js +1 -1
- package/dist/common/overlay.d.ts +4 -0
- package/dist/common/protocol-adapter.d.ts +1 -1
- package/dist/common/safe-html.d.ts +1 -1
- package/dist/{common-CEN5OW7E.js → common-c-awF96O.js} +3 -3
- package/dist/common.js +8 -8
- package/dist/{connection-warning-B6oIU-9s.js → connection-warning-ecZqpczd.js} +1 -1
- package/dist/{context-VIG4SVcS.js → context-DGz5F81j.js} +82 -79
- package/dist/index.d.ts +4 -4
- package/dist/index.js +44 -42
- package/dist/{native-webview-DudQ7nHe.js → native-webview-C_PmKnzm.js} +1 -1
- package/dist/native.iife.js +7 -7
- package/dist/native.js +1 -1
- package/dist/{overlay-1EO41ZC7.js → overlay-DJ1ZRMfI.js} +75 -75
- package/dist/overlay.js +2 -2
- package/dist/{pill-launcher-57nrdLRr.js → pill-launcher-DSEeJT9h.js} +2 -2
- package/dist/qna/runtime.d.ts +2 -1
- package/dist/qna/types.d.ts +14 -0
- package/dist/qna-runtime.js +1 -1
- package/dist/qna.css +1 -1
- package/dist/qna.iife.js +21 -21
- package/dist/qna.js +1 -1
- package/dist/{runtime-BdwZZIrO.js → runtime-BsZZ8zTg.js} +5 -4
- package/dist/{runtime-C0qZk0y7.js → runtime-DNbjpTCh.js} +4 -4
- package/dist/runtime-SKDvc0Xc.js +660 -0
- package/dist/simbut/index.d.ts +3 -1
- package/dist/simbut/types.d.ts +11 -0
- package/dist/simbut-Bw3vBFtW.js +109 -0
- package/dist/simbut.css +1 -1
- package/dist/simbut.iife.js +10 -10
- package/dist/simbut.js +1 -1
- package/dist/simrel/index.d.ts +2 -0
- package/dist/simrel/renderers/default.d.ts +40 -0
- package/dist/simrel-DJZ983BF.js +513 -0
- package/dist/simrel-runtime.js +1 -1
- package/dist/simrel.css +3 -0
- package/dist/simrel.iife.js +38 -38
- package/dist/simrel.js +4 -3
- package/dist/{widget-base-TgwiA8cD.js → widget-base-2-B1Ch5I.js} +1 -1
- package/package.json +6 -1
- package/dist/runtime-DDu8Wk0z.js +0 -629
- package/dist/simbut-BMWC6x_t.js +0 -81
- package/dist/simrel-ohfkluhp.js +0 -55
package/dist/chat.iife.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(Pe){Object.defineProperty(Pe,Symbol.toStringTag,{value:"Module"});var Kr=({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 Yr(e){const t=document.createElement("div");if(t.className=e.containerClassName,!e.spec.elements[e.spec.root])return t;const a=e.unknownRenderer??Kr,n=i=>{const o=e.spec.elements[i];if(!o)return null;const s=e.registry[o.type];return s?s({elementId:i,element:o,spec:e.spec,context:e.context,renderElement:n}):a({elementId:i,element:o,spec:e.spec,context:e.context,renderElement:n})},r=n(e.spec.root);return r&&t.appendChild(r),t}function Jr(e,t){if(!t)return e;const a={...e};for(const[n,r]of Object.entries(t))r&&(a[n]=r);return a}function Xr(e,t){const a={event_name:"stream.start",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{endpoint:t.endpoint,request_id:t.request_id}};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),t.widget!==void 0&&(a.widget=t.widget),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function Qr(e,t){const a={request_id:t.request_id,chunk_index:t.chunk_index};t.latency_ms!==void 0&&(a.latency_ms=t.latency_ms);const n={event_name:"stream.chunk",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:a};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function ei(e,t){const a={event_name:"stream.ui_spec",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,chunk_index:t.chunk_index,component_type:t.component_type}};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),t.widget!==void 0&&(a.widget=t.widget),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function ti(e,t){const a={event_name:"stream.done",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,latency_ms:t.latency_ms,chunk_count:t.chunk_count}};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),t.widget!==void 0&&(a.widget=t.widget),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function ai(e,t){const a={event_name:"stream.error",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,error_code:t.error_code,error_message:t.error_message}};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),t.widget!==void 0&&(a.widget=t.widget),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function ni(e,t){const a={model:t.model,prompt_tokens:t.prompt_tokens,completion_tokens:t.completion_tokens,total_tokens:t.total_tokens};t.provider!==void 0&&(a.provider=t.provider);const n={event_name:"llm.usage",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:a};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function ri(e,t){const a={event_name:"metering.increment",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{meter_key:t.meter_key,quantity:t.quantity,unit:t.unit}};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function ii(e,t){const a={event_name:"metering.summary",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{meter_key:t.meter_key,quantity:t.quantity,unit:t.unit}};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function oi(e,t){const a={event_name:"chat.history.snapshot",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{message_count:t.message_count,history_ref:t.history_ref,redaction_level:t.redaction_level}};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function si(e,t){const a={event_name:"basket.add",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items,sku:t.sku}};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function ci(e,t){const a={event_name:"checkout.start",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function li(e,t){const a={event_name:"checkout.complete",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}var di=new Set(["p","br","a","strong","b","em","i","u","ul","ol","li","h1","h2","h3","h4","h5","h6","span","div","table","thead","tbody","tr","th","td","hr","code","pre","blockquote","img","sup","sub"]),gi=new Set(["script","iframe","object","embed","form","input","textarea","select","button","style","link","meta","template","noscript"]),za={"*":new Set(["class"]),a:new Set(["href","target","rel"]),img:new Set(["src","alt","width","height"]),div:new Set(["style"]),span:new Set(["style"]),p:new Set(["style"])};function pi(e){return/^\s*javascript\s*:/i.test(e)}var hi=new Set(["color","background-color","font-size","font-weight","font-style","font-family","text-align","text-decoration","line-height","letter-spacing","margin","margin-top","margin-right","margin-bottom","margin-left","padding","padding-top","padding-right","padding-bottom","padding-left","border","border-top","border-right","border-bottom","border-left","border-radius","border-color","border-width","border-style","width","max-width","min-width","height","max-height","min-height","display","vertical-align","white-space","word-break","overflow","opacity","visibility","list-style","list-style-type","text-transform","text-indent","text-overflow","box-sizing","flex","flex-direction","flex-wrap","justify-content","align-items","gap"]),ui=/url\s*\(|expression\s*\(|javascript\s*:|\bimport\b|-moz-binding|behavior\s*:/i;function mi(e){const t=[];for(const a of e.split(";")){const n=a.trim();if(!n)continue;const r=n.indexOf(":");if(r===-1)continue;const i=n.slice(0,r).trim().toLowerCase(),o=n.slice(r+1).trim();hi.has(i)&&(ui.test(o)||t.push(n))}return t.join("; ")}function Xt(e,t){if(e.nodeType===Node.TEXT_NODE)return;if(e.nodeType!==Node.ELEMENT_NODE){e.parentNode?.removeChild(e);return}const a=e,n=a.tagName.toLowerCase();if(gi.has(n)){a.parentNode?.removeChild(a);return}if(!di.has(n)){const c=Array.from(a.childNodes);for(const l of c)t.insertBefore(l,a);t.removeChild(a);for(const l of c)Xt(l,t);return}const r=za["*"]??new Set,i=za[n]??new Set,o=Array.from(a.attributes);for(const c of o){const l=c.name.toLowerCase();if(!r.has(l)&&!i.has(l)){a.removeAttribute(c.name);continue}if(pi(c.value)){a.removeAttribute(c.name);continue}if(l==="style"){const d=mi(c.value);d?a.setAttribute("style",d):a.removeAttribute("style");continue}}if(n==="a"){const c=a.getAttribute("href");if(c!==null){const l=c.trim().toLowerCase();!l.startsWith("http://")&&!l.startsWith("https://")&&!l.startsWith("mailto:")&&a.removeAttribute("href")}a.setAttribute("target","_blank"),a.setAttribute("rel","noopener noreferrer")}if(n==="img"){const c=a.getAttribute("src");c!==null&&(c.trim().toLowerCase().startsWith("https://")||a.removeAttribute("src"))}const s=Array.from(a.childNodes);for(const c of s)Xt(c,a)}var Ma=["http:","https:"];function Re(e){try{return Ma.includes(new URL(e).protocol)}catch{return!1}}function ye(e){if(e.startsWith("/")&&!e.startsWith("//"))return!0;try{const t=new URL(e);return Ma.includes(t.protocol)}catch{return!1}}function fe(e,t,a){(t==="href"||t==="src")&&!ye(a)||e.setAttribute(t,a)}function Ce(e){if(!e)return"";const t=new DOMParser().parseFromString(e,"text/html").body,a=Array.from(t.childNodes);for(const n of a)Xt(n,t);return t.innerHTML}function fi(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function be(e,t){const a={event:e,...t};fi()&&window.dataLayer.push(a)}function bi(e){be("gengage-on-init",{gengage_widget:e})}function vi(e){be("gengage-show",{gengage_widget:e})}function yi(e,t){be("gengage-suggested-question",{gengage_question_title:e,gengage_action_type:t})}function _i(e){be("gengage-find-similars",{gengage_sku:e})}function xi(e){be("gengage-compare-preselection",{gengage_sku:e})}function wi(e){be("gengage-compare-selected",{gengage_skus:e,gengage_product_count:e.length})}function ki(){be("gengage-compare-clear")}function Ci(e){be("gengage-compare-received",{gengage_product_count:e})}function Si(e){be("gengage-like-product",{gengage_sku:e})}function Ei(){be("gengage-like-list")}function Pi(e,t){be("gengage-search",{gengage_search_query:e,gengage_result_count:t})}function Ba(e,t){be("gengage-product-detail",{gengage_sku:e,gengage_product_name:t})}function Ti(e){be("gengage-compare-product",{gengage_skus:e,gengage_product_count:e.length})}function Ai(){be("gengage-chatbot-maximized")}function Li(e,t){be("gengage-cart-add",{gengage_sku:e,gengage_quantity:t})}function Ii(){be("gengage-message-sent")}function Ra(){be("gengage-message-received")}function Ni(){be("gengage-conversation-start")}function zi(){be("gengage-voice-input")}function Te(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!1}))}function Oa(e,t){const a=n=>{t(n.detail)};return window.addEventListener(e,a),()=>window.removeEventListener(e,a)}function Mi(){const e=window.__gengageSessionId??sessionStorage.getItem("gengage_session_id")??null??crypto.randomUUID();return window.__gengageSessionId=e,sessionStorage.setItem("gengage_session_id",e),window.gengage||(window.gengage={}),window.gengage.sessionId=e,e}function Bi(e){return{sessionId:e?.sessionId??Mi(),...e}}var Da={"--gengage-chat-offset":"20px","--gengage-chat-launcher-size":"56px","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"1rem","--gengage-chat-header-height":"72px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"1200px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"12px","--gengage-simrel-card-radius":"0.75rem","--radius-control":"12px","--radius-card":"16px","--radius-panel":"24px","--radius-pill":"999px","--surface-card-muted":"#f8fafc","--text-secondary":"#4b5563","--text-muted":"#6b7280","--border-default":"rgba(17, 24, 39, 0.10)"};function Ri(e){return e?{...Da,...e}:{...Da}}var Oe={primaryColor:"#b7102a",primaryForeground:"#ffffff",backgroundColor:"#ffffff",foregroundColor:"#111827",borderRadius:"0.75rem",fontFamily:'"Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontSize:"14px",zIndex:"1000","--glov-chatbot-width":"420px","--glov-left-spacing":"260px","--chatbot-padding":"16px","--root-wrapper-background-color":"#f8f9fa","--root-wrapper-border-color":"#edeeef","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"1rem","--gengage-chat-header-height":"72px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"1200px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"0.75rem","--gengage-simrel-card-radius":"0.75rem","--client-primary":"#b7102a","--client-primary-hover":"color-mix(in srgb, #b7102a 88%, black 12%)","--client-primary-active":"color-mix(in srgb, #b7102a 78%, black 22%)","--client-primary-subtle":"color-mix(in srgb, #b7102a 12%, white)","--client-primary-soft":"color-mix(in srgb, #b7102a 20%, white)","--client-on-primary":"#ffffff","--client-focus-ring":"color-mix(in srgb, #b7102a 32%, transparent)","--surface-page":"#f6f7fb","--surface-shell":"#10131a","--surface-card":"#ffffff","--surface-card-muted":"#f8fafc","--surface-card-soft":"#f8fafc","--surface-elevated":"#ffffff","--surface-input":"#ffffff","--surface-overlay":"rgba(16, 19, 26, 0.52)","--text-primary":"#111827","--text-secondary":"#4b5563","--text-muted":"#6b7280","--text-inverse":"#f9fafb","--border-subtle":"rgba(17, 24, 39, 0.06)","--border-default":"rgba(17, 24, 39, 0.10)","--border-strong":"rgba(17, 24, 39, 0.18)","--shadow-1":"0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06)","--shadow-2":"0 4px 12px rgba(16, 24, 40, 0.08)","--shadow-3":"0 10px 24px rgba(16, 24, 40, 0.12)","--radius-control":"12px","--radius-card":"16px","--radius-panel":"24px","--radius-pill":"999px","--success":"#16a34a","--warning":"#d97706","--error":"#dc2626","--info":"#2563eb","--rating":"#f5b301","--ai-accent-start":"#0b24d6","--ai-accent-end":"#f768f2","--ai-accent-soft":"linear-gradient(135deg, rgba(11, 36, 214, 0.08), rgba(247, 104, 242, 0.08))"},qe="gengage-global-toast-root",Ha="gengage-global-toast-style",Qt="gengage-global-toast-root--visible",Oi=4200,Di=1500,Hi=15e3,Fi=["--gengage-font-family","--surface-card","--text-primary","--text-muted","--border-default","--radius-card","--shadow-3","--error","--ds-toast-error-bg","--ds-toast-error-border","--ds-toast-error-accent","--ds-toast-error-fg","--ds-toast-error-shadow"],Fa=!1,Xe=null,$i=[/failed to fetch/i,/networkerror/i,/network request failed/i,/load failed/i,/err_network/i,/fetch failed/i,/network error/i];function $a(e){if(typeof navigator<"u"&&navigator.onLine===!1)return!0;const t=e instanceof Error?e.message.trim():"";return t?$i.some(a=>a.test(t)):!1}function Ui(){Fa||typeof window>"u"||typeof document>"u"||(Fa=!0,Oa("gengage:global:error",e=>{ji(e)}))}function ji(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;Ki();const a=Vi();Gi(a),a.innerHTML="";const n=document.createElement("section");n.className="gengage-global-toast gengage-global-toast--error",n.setAttribute("role","status"),n.setAttribute("aria-live","polite");const r=document.createElement("div");r.className="gengage-global-toast-title",r.textContent=qi(e.source);const i=document.createElement("div");i.className="gengage-global-toast-message",i.textContent=t,n.appendChild(r),n.appendChild(i),a.appendChild(n),a.classList.add(Qt),Xe&&(clearTimeout(Xe),Xe=null),e.sticky!==!0&&(Xe=setTimeout(()=>{Zi()},Wi(e.durationMs)))}function Zi(){if(typeof document>"u")return;const e=document.getElementById(qe);e&&(e.classList.remove(Qt),e.innerHTML="",Xe&&(clearTimeout(Xe),Xe=null))}function qi(e){switch(e){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function Vi(){const e=document.getElementById(qe);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=qe,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function Gi(e){if(typeof document>"u"||typeof window>"u")return;const t=document.querySelector(".gengage-chat-root, .gengage-qna-container, .gengage-simrel-container, .gengage-simbut-root");if(!t)return;const a=window.getComputedStyle(t);for(const n of Fi){const r=a.getPropertyValue(n).trim();r?e.style.setProperty(n,r):e.style.removeProperty(n)}}function Wi(e){return typeof e!="number"||!Number.isFinite(e)?Oi:Math.min(Hi,Math.max(Di,Math.round(e)))}function Ki(){if(document.getElementById(Ha))return;const e=document.createElement("style");e.id=Ha;const t=Oe["--surface-card"]??Oe.backgroundColor??"#ffffff",a=Oe["--text-primary"]??Oe.foregroundColor??"#111827",n=Oe["--border-default"]??"rgba(17, 24, 39, 0.10)",r=Oe["--error"]??"#dc2626",i=Oe["--shadow-3"]??"0 10px 24px rgba(16, 24, 40, 0.12)",o=Oe["--radius-card"]??"16px",s=Oe["--text-muted"]??"#6b7280";e.textContent=`
|
|
1
|
+
(function(Pe){Object.defineProperty(Pe,Symbol.toStringTag,{value:"Module"});var Kr=({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 Yr(e){const t=document.createElement("div");if(t.className=e.containerClassName,!e.spec.elements[e.spec.root])return t;const a=e.unknownRenderer??Kr,n=i=>{const o=e.spec.elements[i];if(!o)return null;const s=e.registry[o.type];return s?s({elementId:i,element:o,spec:e.spec,context:e.context,renderElement:n}):a({elementId:i,element:o,spec:e.spec,context:e.context,renderElement:n})},r=n(e.spec.root);return r&&t.appendChild(r),t}function Jr(e,t){if(!t)return e;const a={...e};for(const[n,r]of Object.entries(t))r&&(a[n]=r);return a}function Xr(e,t){const a={event_name:"stream.start",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{endpoint:t.endpoint,request_id:t.request_id}};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),t.widget!==void 0&&(a.widget=t.widget),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function Qr(e,t){const a={request_id:t.request_id,chunk_index:t.chunk_index};t.latency_ms!==void 0&&(a.latency_ms=t.latency_ms);const n={event_name:"stream.chunk",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:a};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function ei(e,t){const a={event_name:"stream.ui_spec",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,chunk_index:t.chunk_index,component_type:t.component_type}};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),t.widget!==void 0&&(a.widget=t.widget),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function ti(e,t){const a={event_name:"stream.done",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,latency_ms:t.latency_ms,chunk_count:t.chunk_count}};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),t.widget!==void 0&&(a.widget=t.widget),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function ai(e,t){const a={event_name:"stream.error",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,error_code:t.error_code,error_message:t.error_message}};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),t.widget!==void 0&&(a.widget=t.widget),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function ni(e,t){const a={model:t.model,prompt_tokens:t.prompt_tokens,completion_tokens:t.completion_tokens,total_tokens:t.total_tokens};t.provider!==void 0&&(a.provider=t.provider);const n={event_name:"llm.usage",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:a};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function ri(e,t){const a={event_name:"metering.increment",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{meter_key:t.meter_key,quantity:t.quantity,unit:t.unit}};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function ii(e,t){const a={event_name:"metering.summary",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{meter_key:t.meter_key,quantity:t.quantity,unit:t.unit}};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function oi(e,t){const a={event_name:"chat.history.snapshot",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{message_count:t.message_count,history_ref:t.history_ref,redaction_level:t.redaction_level}};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function si(e,t){const a={event_name:"basket.add",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items,sku:t.sku}};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function ci(e,t){const a={event_name:"checkout.start",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}function li(e,t){const a={event_name:"checkout.complete",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(a.view_id=e.view_id),e.user_id!==void 0&&(a.user_id=e.user_id),e.page_type!==void 0&&(a.page_type=e.page_type),e.sku!==void 0&&(a.sku=e.sku),a}var di=new Set(["p","br","a","strong","b","em","i","u","ul","ol","li","h1","h2","h3","h4","h5","h6","span","div","table","thead","tbody","tr","th","td","hr","code","pre","blockquote","img","sup","sub"]),gi=new Set(["script","iframe","object","embed","form","input","textarea","select","button","style","link","meta","template","noscript"]),za={"*":new Set(["class"]),a:new Set(["href","target","rel"]),img:new Set(["src","alt","width","height"]),div:new Set(["style"]),span:new Set(["style"]),p:new Set(["style"])};function pi(e){return/^\s*javascript\s*:/i.test(e)}var hi=new Set(["color","background-color","font-size","font-weight","font-style","font-family","text-align","text-decoration","line-height","letter-spacing","margin","margin-top","margin-right","margin-bottom","margin-left","padding","padding-top","padding-right","padding-bottom","padding-left","border","border-top","border-right","border-bottom","border-left","border-radius","border-color","border-width","border-style","width","max-width","min-width","height","max-height","min-height","display","vertical-align","white-space","word-break","overflow","opacity","visibility","list-style","list-style-type","text-transform","text-indent","text-overflow","box-sizing","flex","flex-direction","flex-wrap","justify-content","align-items","gap"]),ui=/url\s*\(|expression\s*\(|javascript\s*:|\bimport\b|-moz-binding|behavior\s*:/i;function mi(e){const t=[];for(const a of e.split(";")){const n=a.trim();if(!n)continue;const r=n.indexOf(":");if(r===-1)continue;const i=n.slice(0,r).trim().toLowerCase(),o=n.slice(r+1).trim();hi.has(i)&&(ui.test(o)||t.push(n))}return t.join("; ")}function Xt(e,t){if(e.nodeType===Node.TEXT_NODE)return;if(e.nodeType!==Node.ELEMENT_NODE){e.parentNode?.removeChild(e);return}const a=e,n=a.tagName.toLowerCase();if(gi.has(n)){a.parentNode?.removeChild(a);return}if(!di.has(n)){const c=Array.from(a.childNodes);for(const l of c)t.insertBefore(l,a);t.removeChild(a);for(const l of c)Xt(l,t);return}const r=za["*"]??new Set,i=za[n]??new Set,o=Array.from(a.attributes);for(const c of o){const l=c.name.toLowerCase();if(!r.has(l)&&!i.has(l)){a.removeAttribute(c.name);continue}if(pi(c.value)){a.removeAttribute(c.name);continue}if(l==="style"){const d=mi(c.value);d?a.setAttribute("style",d):a.removeAttribute("style");continue}}if(n==="a"){const c=a.getAttribute("href");if(c!==null){const l=c.trim().toLowerCase();!l.startsWith("http://")&&!l.startsWith("https://")&&!l.startsWith("mailto:")&&a.removeAttribute("href")}a.setAttribute("target","_blank"),a.setAttribute("rel","noopener noreferrer")}if(n==="img"){const c=a.getAttribute("src");c!==null&&(c.trim().toLowerCase().startsWith("https://")||a.removeAttribute("src"))}const s=Array.from(a.childNodes);for(const c of s)Xt(c,a)}var Ma=["http:","https:"];function Re(e){const t=e.trim();if(!t)return!1;if(t.startsWith("/")&&!t.startsWith("//"))return!0;try{return Ma.includes(new URL(t).protocol)}catch{return!1}}function ye(e){if(e.startsWith("/")&&!e.startsWith("//"))return!0;try{const t=new URL(e);return Ma.includes(t.protocol)}catch{return!1}}function fe(e,t,a){(t==="href"||t==="src")&&!ye(a)||e.setAttribute(t,a)}function Ce(e){if(!e)return"";const t=new DOMParser().parseFromString(e,"text/html").body,a=Array.from(t.childNodes);for(const n of a)Xt(n,t);return t.innerHTML}function fi(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function be(e,t){const a={event:e,...t};fi()&&window.dataLayer.push(a)}function bi(e){be("gengage-on-init",{gengage_widget:e})}function vi(e){be("gengage-show",{gengage_widget:e})}function yi(e,t){be("gengage-suggested-question",{gengage_question_title:e,gengage_action_type:t})}function _i(e){be("gengage-find-similars",{gengage_sku:e})}function xi(e){be("gengage-compare-preselection",{gengage_sku:e})}function wi(e){be("gengage-compare-selected",{gengage_skus:e,gengage_product_count:e.length})}function ki(){be("gengage-compare-clear")}function Ci(e){be("gengage-compare-received",{gengage_product_count:e})}function Si(e){be("gengage-like-product",{gengage_sku:e})}function Ei(){be("gengage-like-list")}function Pi(e,t){be("gengage-search",{gengage_search_query:e,gengage_result_count:t})}function Ba(e,t){be("gengage-product-detail",{gengage_sku:e,gengage_product_name:t})}function Ti(e){be("gengage-compare-product",{gengage_skus:e,gengage_product_count:e.length})}function Ai(){be("gengage-chatbot-maximized")}function Li(e,t){be("gengage-cart-add",{gengage_sku:e,gengage_quantity:t})}function Ii(){be("gengage-message-sent")}function Ra(){be("gengage-message-received")}function Ni(){be("gengage-conversation-start")}function zi(){be("gengage-voice-input")}function Te(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!1}))}function Oa(e,t){const a=n=>{t(n.detail)};return window.addEventListener(e,a),()=>window.removeEventListener(e,a)}function Mi(){const e=window.__gengageSessionId??sessionStorage.getItem("gengage_session_id")??null??crypto.randomUUID();return window.__gengageSessionId=e,sessionStorage.setItem("gengage_session_id",e),window.gengage||(window.gengage={}),window.gengage.sessionId=e,e}function Bi(e){return{sessionId:e?.sessionId??Mi(),...e}}var Da={"--gengage-chat-offset":"20px","--gengage-chat-launcher-size":"56px","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"1rem","--gengage-chat-header-height":"72px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"1200px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"12px","--gengage-simrel-card-radius":"0.75rem","--radius-control":"12px","--radius-card":"16px","--radius-panel":"24px","--radius-pill":"999px","--surface-card-muted":"#f8fafc","--text-secondary":"#4b5563","--text-muted":"#6b7280","--border-default":"rgba(17, 24, 39, 0.10)"};function Ri(e){return e?{...Da,...e}:{...Da}}var Oe={primaryColor:"#b7102a",primaryForeground:"#ffffff",backgroundColor:"#ffffff",foregroundColor:"#111827",borderRadius:"0.75rem",fontFamily:'"Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontSize:"14px",zIndex:"1000","--glov-chatbot-width":"420px","--glov-left-spacing":"260px","--chatbot-padding":"16px","--root-wrapper-background-color":"#f8f9fa","--root-wrapper-border-color":"#edeeef","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"1rem","--gengage-chat-header-height":"72px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"1200px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"0.75rem","--gengage-simrel-card-radius":"0.75rem","--client-primary":"#b7102a","--client-primary-hover":"color-mix(in srgb, #b7102a 88%, black 12%)","--client-primary-active":"color-mix(in srgb, #b7102a 78%, black 22%)","--client-primary-subtle":"color-mix(in srgb, #b7102a 12%, white)","--client-primary-soft":"color-mix(in srgb, #b7102a 20%, white)","--client-on-primary":"#ffffff","--client-focus-ring":"color-mix(in srgb, #b7102a 32%, transparent)","--surface-page":"#f6f7fb","--surface-shell":"#10131a","--surface-card":"#ffffff","--surface-card-muted":"#f8fafc","--surface-card-soft":"#f8fafc","--surface-elevated":"#ffffff","--surface-input":"#ffffff","--surface-overlay":"rgba(16, 19, 26, 0.52)","--text-primary":"#111827","--text-secondary":"#4b5563","--text-muted":"#6b7280","--text-inverse":"#f9fafb","--border-subtle":"rgba(17, 24, 39, 0.06)","--border-default":"rgba(17, 24, 39, 0.10)","--border-strong":"rgba(17, 24, 39, 0.18)","--shadow-1":"0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06)","--shadow-2":"0 4px 12px rgba(16, 24, 40, 0.08)","--shadow-3":"0 10px 24px rgba(16, 24, 40, 0.12)","--radius-control":"12px","--radius-card":"16px","--radius-panel":"24px","--radius-pill":"999px","--success":"#16a34a","--warning":"#d97706","--error":"#dc2626","--info":"#2563eb","--rating":"#f5b301","--ai-accent-start":"#0b24d6","--ai-accent-end":"#f768f2","--ai-accent-soft":"linear-gradient(135deg, rgba(11, 36, 214, 0.08), rgba(247, 104, 242, 0.08))"},qe="gengage-global-toast-root",Ha="gengage-global-toast-style",Qt="gengage-global-toast-root--visible",Oi=4200,Di=1500,Hi=15e3,Fi=["--gengage-font-family","--surface-card","--text-primary","--text-muted","--border-default","--radius-card","--shadow-3","--error","--ds-toast-error-bg","--ds-toast-error-border","--ds-toast-error-accent","--ds-toast-error-fg","--ds-toast-error-shadow"],Fa=!1,Xe=null,$i=[/failed to fetch/i,/networkerror/i,/network request failed/i,/load failed/i,/err_network/i,/fetch failed/i,/network error/i];function $a(e){if(typeof navigator<"u"&&navigator.onLine===!1)return!0;const t=e instanceof Error?e.message.trim():"";return t?$i.some(a=>a.test(t)):!1}function Ui(){Fa||typeof window>"u"||typeof document>"u"||(Fa=!0,Oa("gengage:global:error",e=>{ji(e)}))}function ji(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;Ki();const a=Vi();Gi(a),a.innerHTML="";const n=document.createElement("section");n.className="gengage-global-toast gengage-global-toast--error",n.setAttribute("role","status"),n.setAttribute("aria-live","polite");const r=document.createElement("div");r.className="gengage-global-toast-title",r.textContent=qi(e.source);const i=document.createElement("div");i.className="gengage-global-toast-message",i.textContent=t,n.appendChild(r),n.appendChild(i),a.appendChild(n),a.classList.add(Qt),Xe&&(clearTimeout(Xe),Xe=null),e.sticky!==!0&&(Xe=setTimeout(()=>{Zi()},Wi(e.durationMs)))}function Zi(){if(typeof document>"u")return;const e=document.getElementById(qe);e&&(e.classList.remove(Qt),e.innerHTML="",Xe&&(clearTimeout(Xe),Xe=null))}function qi(e){switch(e){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function Vi(){const e=document.getElementById(qe);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=qe,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function Gi(e){if(typeof document>"u"||typeof window>"u")return;const t=document.querySelector(".gengage-chat-root, .gengage-qna-container, .gengage-simrel-container, .gengage-simbut-root");if(!t)return;const a=window.getComputedStyle(t);for(const n of Fi){const r=a.getPropertyValue(n).trim();r?e.style.setProperty(n,r):e.style.removeProperty(n)}}function Wi(e){return typeof e!="number"||!Number.isFinite(e)?Oi:Math.min(Hi,Math.max(Di,Math.round(e)))}function Ki(){if(document.getElementById(Ha))return;const e=document.createElement("style");e.id=Ha;const t=Oe["--surface-card"]??Oe.backgroundColor??"#ffffff",a=Oe["--text-primary"]??Oe.foregroundColor??"#111827",n=Oe["--border-default"]??"rgba(17, 24, 39, 0.10)",r=Oe["--error"]??"#dc2626",i=Oe["--shadow-3"]??"0 10px 24px rgba(16, 24, 40, 0.12)",o=Oe["--radius-card"]??"16px",s=Oe["--text-muted"]??"#6b7280";e.textContent=`
|
|
2
2
|
#${qe} {
|
|
3
3
|
position: fixed;
|
|
4
4
|
top: 16px;
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
`,document.head.appendChild(e)}var mt=null;function Yi(){if(mt!==null)return mt;try{mt=localStorage.getItem("gengage:debug")==="1"}catch{mt=!1}return mt}function De(e,t,a){if(!Yi())return;const n=[`[gengage:${e}]`,t];a!==void 0&&n.push(a),console.debug(...n)}var Ji=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=Ri(e.theme);this.config={...e,theme:t,session:Bi(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),Ui();const a=Oa("gengage:context:update",n=>this.update(n));this._cleanups.push(a),De("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,De("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.config.analyticsClient?.destroy(),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)}trackCheckout(e,t){const a=e==="start"?ci:li;this.track(a(this.analyticsContext(),t))}flushMeteringSummary(e){this.track(ii(this.analyticsContext(),e))}emit(e,...t){this._handlers.get(e)?.forEach(a=>a(...t))}addCleanup(e){this._cleanups.push(e)}track(e){this.config.analyticsClient?.track(e)}analyticsContext(){const e={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??""};return this.config.session?.viewId!==void 0&&(e.view_id=this.config.session.viewId),this.config.session?.userId!==void 0&&(e.user_id=this.config.session.userId),this.config.pageContext?.pageType!==void 0&&(e.page_type=this.config.pageContext.pageType),this.config.pageContext?.sku!==void 0&&(e.sku=this.config.pageContext.sku),this.config.session?.abTestVariant!==void 0&&(e.ab_test_variant=this.config.session.abTestVariant),this.config.session?.abTestExperimentId!==void 0&&(e.ab_test_experiment_id=this.config.session.abTestExperimentId),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-${Xi(t)}`;this.root.style.setProperty(n,a)}}}};function Xi(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function Ua(){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 Qi=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("*")&&to()&&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(!eo(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 eo(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.gengage=="string"&&typeof t.type=="string"}function to(){try{return typeof process<"u"&&process.env.NODE_ENV!=="production"}catch{return!1}}function ja(e,t){if(typeof window>"u"||!ye(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 ao=console;function no(e,t,a={}){const n=e.action,r=a.logger??ao;switch(De("action",`routing action: ${n.kind}`,n),n.kind){case"open_chat":t.openChat?.(n.payload);return;case"navigate":{if(typeof n.url!="string"){at(n,t,a,r);return}if(!ye(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??ro)(n.url,i);return}case"save_session":if(typeof n.sessionId!="string"||typeof n.sku!="string"){at(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"){at(n,t,a,r);return}t.addToCart?.({sku:n.sku,quantity:n.quantity,cartCode:n.cartCode});return;case"script_call":{if(a.allowScriptCall===!1){at(n,t,a,r);return}if(typeof n.name!="string"){at(n,t,a,r);return}const i=io(n.payload)?n.payload:void 0;t.scriptCall?.({name:n.name,...i!==void 0&&{payload:i}});return}default:at(n,t,a,r)}}function at(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 ro(e,t){if(!(typeof window>"u")){if(!ye(e)){console.warn("[gengage] Blocked navigation to unsafe URL:",e);return}ja(e,t)}}function io(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ft(e){const t=e?.trim();return t||"tr"}function _e(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 oo=["image/jpeg","image/png","image/webp"],vm=5*1024*1024;function so(e){return oo.includes(e.type)?e.size>5242880?{ok:!1,reason:"too_large"}:{ok:!0}:{ok:!1,reason:"invalid_type"}}function Za(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function co(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 qa(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 Za(r)?(De("stream",`event: ${r.type}`,r),t.onEvent(r),r.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const r=co(n);if(r.length>1){for(const i of r)try{const o=JSON.parse(i);if(!Za(o))continue;if(t.onEvent(o),o.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function lo(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 d=await(i>0?Promise.race([c.then(b=>(clearTimeout(l),b)),new Promise(b=>{l=setTimeout(()=>b(o),i)})]):c);if(d===o){s=!0,await a.cancel();break}const{done:p,value:h}=d;if(p)break;r+=n.decode(h,{stream:!0});const g=r.split(`
|
|
48
|
-
`);r=g.pop()??"";for(const b of g)if(qa(b,t))return}if(r.trim()&&qa(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 Va=3,go=(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():""},ea=(e,t)=>e?e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(a=>go(a,t)).filter(Boolean):[];function po(e){const t=(e.display_keywords??[]).flatMap(r=>ea(r,{stripLeadingStopWords:!0})),a=t.filter((r,i)=>t.indexOf(r)===i);if(a.length>0)return a.slice(0,Va);const n=[...ea(e.chosen_attribute,{stripLeadingStopWords:!0}),...ea(e.short_name)];return n.filter((r,i)=>n.indexOf(r)===i).slice(0,Va)}function ho(e){return po(e).join(" • ")}var uo=["beauty_consulting","watch_expert"];function Ga(e){return typeof e=="string"&&uo.includes(e)}function mo(e){if(typeof e.type!="string")return null;if(fo(e))return e;const t=e;switch(t.type){case"outputText":return bo(t);case"suggestedActions":return vo(t);case"productList":return yo(t);case"productDetails":return _o(t);case"productDetailsSimilars":return xo(t);case"comparisonTable":return wo(t);case"context":return Eo(t);case"chatStreamEnd":return Po();case"loading":return To(t);case"panelLoading":return Ao(t);case"similarLoading":return Lo(t);case"redirect":return Io(t);case"error":return No(t);case"dummy":return zo(t);case"launcherAction":return Mo(t);case"text":return ta(t);case"productItem":return Bo(t);case"text_image":return Wa(t);case"quick_qna":return Ka(t);case"reviewHighlights":return Ro(t);case"aiProductSuggestions":return Ho(t);case"aiProductGroupings":return Fo(t);case"aiSuggestedSearches":return $o(t);case"prosAndCons":return Oo(t);case"getGroundingReview":return Uo(t);case"voice":return Zo(t);case"visitorDataResponse":return Do(t);case"productListPreview":return jo();case"groupList":return qo(t);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return Vo(t);case"launcherContent":return Wo(t);case"handoff":return Go(t);case"uiSpec":return as(t);default:return null}}function fo(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=Se(e.spec);return n?typeof n.root=="string"&&Se(n.elements)!==null:!1}case"action":{const a=Se(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 bo(e){const t=K(e.payload.text,e.payload.plain_text)??"",a=K(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 vo(e){return Ya((e.payload.actions??[]).map(t=>{const a=K(t.title)??"",n=He(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(vt),"chat")}function yo(e){const t=(Array.isArray(e.payload.style_variations)?e.payload.style_variations:[]).map(o=>{const s=K(o.style_label);if(!s)return null;const c=K(o.style_mood),l=K(o.image_url??void 0),d=(Array.isArray(o.product_list)?o.product_list:[]).map(h=>{const g=Se(h);return g?aa(Se(g.product_detail)??Se(g.product)??g):null}).filter(vt),p=Array.isArray(o.recommendation_groups)?o.recommendation_groups.map(h=>({label:K(h.label)??"",reason:K(h.reason)??"",skus:Array.isArray(h.skus)?h.skus.filter(g=>typeof g=="string"&&g.trim().length>0):[]})):[];return{style_label:s,style_mood:c??"",...l?{image_url:l}:{},...typeof o.status=="string"?{status:o.status}:{},product_list:d,recommendation_groups:p}}).filter(vt),a=e.payload.product_list??[],n=Ga(e.payload.source)&&t.length>0?t[0].product_list:null,r=n?Ko(n,"chat"):Ja(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 _o(e){const t=e.payload.productDetails;if(!t)return Jo("chat");const a=nt(t);return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:{...t,...a}}}}},panelHint:"panel"}}function xo(e){const t=Ja(e.payload.similarProducts??[],"chat"),a=t.spec.elements[t.spec.root];return a&&(a.props={...a.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function wo(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 f of t){const u=nt(f);o.push(u)}const s=ko(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(f=>f.sku===c)??o[0]:o[0],d=[];if(Array.isArray(n?.key_differences))for(const f of n.key_differences)typeof f=="string"&&d.push(f);const p=es(n?.special_considerations),h=n?.recommended_choice,g=n?.winner_hits,b={};for(const f of o){const u=f.sku;u&&(b[u]={title:f.name??u,type:"launchSingleProduct",payload:{sku:u}})}const m={products:o,attributes:s,highlights:d,productActions:b};return l&&(m.recommended=l),p.length>0&&(m.specialCases=p),h&&(m.recommendedText=h),g&&(m.winnerHits=g),typeof n?.key_differences=="string"&&(m.keyDifferencesHtml=n.key_differences),n?.special_considerations&&(m.specialConsiderations=n.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:m}}},panelHint:"panel"}}function ko(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 p=a.criteria_view??a.criteria_view_short??{},h=a.compared_field_names??Object.keys(e),g=[];for(const b of h){const m=e[b];if(!m||!Array.isArray(m))continue;const f=p[b]??b;g.push({label:f,values:m.map(u=>typeof u=="string"?u:String(u??""))})}return g}const o=e,s=t.map(p=>String(p.sku??"")).filter(p=>p.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:Co(o)).filter(p=>p!=="name"&&p!=="name_short"&&!p.endsWith("_short")),d=[];for(const p of l){const h=s.map(b=>{const m=o[b];if(!m||typeof m!="object")return"";const f=m[`${p}_short`],u=m[p];return So(f??u)});if(h.every(b=>b.length===0))continue;const g=c[p]??p;d.push({label:g,values:h})}return d}function Co(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 So(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function Eo(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function Po(){return{type:"done"}}function To(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 Ao(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Lo(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Io(e){const t=K(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:K(e.payload.to)}}}function No(e){return{type:"error",code:"BACKEND_ERROR",message:K(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function zo(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function Mo(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),Ka({type:"quick_qna",payload:r})}const a=Se(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),Wa({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=Se(t.payload)??void 0;return i!==void 0&&(r.type=i),s!==void 0&&(r.payload=s),o!==void 0&&(r.theme=o),ta({type:"text",payload:r})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function ta(e){const t={text:K(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 Bo(e){return Yo(e.payload,"qna")}function Wa(e){const t=K(e.payload.text)??"",a=He(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),ta({type:"text",payload:n})}function Ka(e){return Ya((e.payload.action_list??[]).map(t=>{const a=K(t.title)??"",n=He(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(vt),"qna")}function Ro(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 Oo(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 Do(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function Ho(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=Xo(r);if(!i)continue;const o={product:i},s=He(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 Fo(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=K(i.name)??"",s=K(i.sku,i.repr_sku),c=K(i.image,i.repr_image),l=s!==void 0?{type:"findSimilar",payload:{sku:s}}:void 0,d=He(i.requestDetails??l,o),p=(Array.isArray(i.group_products)?i.group_products:[]).map(b=>{const m=Se(b);return m?aa(m):null}).filter(vt),h=c??K(...p.map(b=>b.imageUrl));if(o&&p.length>0){const b={groupName:o,products:p};h&&(b.image=h),a.push(b)}if(!d)continue;const g={name:o,action:d};if(Array.isArray(i.labels)){const b=i.labels.filter(m=>typeof m=="string");b.length>0&&(g.labels=b)}c!==void 0&&(g.image=c),n.push(g)}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 $o(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=K(r.short_name,r.chosen_attribute,r.detailed_user_message)??`Search ${n+1}`,o={},s=K(r.detailed_user_message);s&&(o.text=s);const c=Se(Se(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(u=>typeof u=="string"));const d=K(r.sku,r.representative_product_sku,c?.sku);d&&(o.sku=d),o.is_suggested_text=1;const p={type:"inputText",payload:o},h=He(r.requestDetails,i),g=h?.type==="findSimilar"&&typeof o.text=="string"?He(p,i):h??He(p,i);if(!g)continue;const b={shortName:i,action:g},m=K(r.detailed_user_message);m&&m!==i&&(b.detailedMessage=m);const f=ho(r);f&&f!==i&&f!==(m??"")&&(b.whyDifferent=f),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 Uo(e){const t=e.payload,a=He(t.requestDetails??t.request_details,K(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 jo(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function Zo(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function qo(e){const t=e.payload.group_list??[],a=[];for(const r of t){const i=r.group_name??"",o=(r.product_list??[]).map(nt);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=He(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 Vo(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function Go(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 Wo(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function Ya(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 Ja(e,t){const a={},n=[];for(let r=0;r<e.length;r++){const i=e[r];if(!i)continue;const o=nt(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 Ko(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 Yo(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:nt(e),index:0}}}}}}function Jo(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function Xo(e){const t=K(e.sku),a=K(e.short_name),n={...Se(e.product_item)??e},r=K(e.discount_reason,e.discountReason);return r&&!K(n.discount_reason,n.discountReason)&&(n.discount_reason=r),aa(n,t,a)}function aa(e,t,a){const n=K(e.sku,t),r=K(e.name,a);if(!n||!r)return null;const i={sku:n,name:r},o=K(e.brand);o&&(i.brand=o);const s=K(e.url);s&&(i.url=s);const c=Qo(e.images);if(c.length>0)i.images=c;else{const m=K(e.image,e.image_url,e.imageUrl);m&&(i.images=[m])}const l=bt(e.price_discounted);l!==void 0&&(i.price_discounted=l);const d=bt(e.price);d!==void 0&&(i.price=d);const p=bt(e.rating);p!==void 0&&(i.rating=p);const h=bt(e.review_count)??bt(e.reviewCount);h!==void 0&&(i.review_count=h);const g=K(e.cart_code,e.cartCode);g&&(i.cart_code=g),typeof e.in_stock=="boolean"&&(i.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(i.in_stock=e.inStock);const b=K(e.discount_reason,e.discountReason);return b&&(i.discount_reason=b),nt(i)}function He(e,t){const a=Se(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 Se(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function K(...e){for(const t of e)if(typeof t=="string"){const a=t.trim();if(a.length>0)return a}}function Qo(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function es(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 bt(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 vt(e){return e!=null}var ts=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","facet_tags","short_name","category_ids","category_names","variants","facet_hits","promotions"]);function nt(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=K(e.brand),o=K(e.name)??e.sku,s=i&&!o.toLowerCase().startsWith(i.toLowerCase())?`${i} ${o}`:o,c={sku:e.sku,name:s,url:K(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.short_name!==void 0&&(c.shortName=e.short_name);const d=e,p={};let h=!1;for(const g of Object.keys(d))ts.has(g)||(p[g]=d[g],h=!0);return h&&(c.extras=p),c}function as(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 ns={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"};function rs(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 is(e,t){return`${rs(t?.middlewareUrl)}/chat${ns[e]}`}function os(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"inputText":{const i={is_launcher:0};return t.pageContext?.extra&&(i.page_details=t.pageContext.extra),"is_suggested_text"in n||(i.is_suggested_text=0),{...e,payload:r(i)}}case"findSimilar":{const i={is_launcher:0};return e.title&&(i.text=e.title,i.input=e.title),{...e,payload: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 ss={user_message:"inputText"};function cs(e){const{action:t,type:a,payload:n,...r}=e,i=a??t?.type??"inputText",o=n??t?.payload,s=ss[i]??i,c={...r,type:s};return o!==void 0&&(c.payload=typeof o=="string"?{text:o}:o),JSON.stringify(c)}function ls(e,t,a){const n=is("process_action",a),r=new AbortController;return(async()=>{try{const o=cs(e),s=a.attachment!==void 0;let c;if(s){const h=new FormData;h.append("request",o),a.attachment!==void 0&&h.append("attachment",a.attachment),c={method:"POST",body:h,signal:r.signal}}else c={method:"POST",headers:{"Content-Type":"application/json"},body:o,signal:r.signal};const l=await fetch(n,c);if(!l.ok){let h=l.statusText;try{const g=await l.json(),b=g.detail??g.message??g.error;typeof b=="string"&&(h=b)}catch{}t.onError(new Error(`HTTP ${l.status}: ${h}`));return}let d=!1;const p=()=>{d||(d=!0,t.onDone())};await lo(l,{onEvent:h=>{const g=mo(h);if(g&&!(d&&g.type!=="error"))switch(g.type){case"text_chunk":t.onTextChunk(g.content,g.final===!0,{productMentions:g.productMentions,skuToProductItem:g.skuToProductItem,conversationMode:g.conversationMode,renderHint:g.renderHint,kvkk:g.kvkk});break;case"ui_spec":t.onUISpec(g.spec,g.widget,g.panelHint,g.clearPanel===!0);break;case"action":t.onAction(g);break;case"metadata":t.onMetadata(g);break;case"error":t.onError(new Error(g.message));break;case"done":p();break}},onError:t.onError,signal:r.signal}),p()}catch(o){if(o instanceof DOMException&&o.name==="AbortError")return;t.onError(o instanceof Error?o:new Error(String(o)))}})(),r}var ds=["chat_debug","presentation_debug"],gs=["gengage_chat_debug","gengage_presentation_debug"];function ps(){if(typeof window>"u")return!1;const e=new URLSearchParams(window.location.search);if(ds.some(t=>e.get(t)==="1"))return!0;try{return gs.some(t=>window.localStorage.getItem(t)==="1")}catch{return!1}}function hs(e,t,a){if(!ps())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 Tt="gengage-chat-scroll",rt=null;function Xa(e){rt=e}function us(){if(rt&&rt.isConnected)return rt;rt=null;const e=document.getElementById(Tt);return e||(hs("chat-scroll","failed to resolve scroll container (not registered)",{id:Tt}),null)}function Qa(){rt=null}var it={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ı stil hazırladım",watchStylesPreparedTitle:"Sizin için {count} farklı stil 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"},ms={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} beauty styles for you",watchStylesPreparedTitle:"Prepared {count} style 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 fs(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function bs(e){return fs(e)==="en"?ms:it}function vs(){return en()!==null}function en(){const e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition??null}var ys=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=en();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=_s(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 _s(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 xs(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=Ce(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 ws=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 ks(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 tn(e,t,a){const n=e.props??{},r=n.processing===!0,i={...it,...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 d=document.createElement("p");d.className="gengage-chat-beauty-photo-step-desc",d.textContent=(typeof n.description=="string"?n.description:void 0)??i.beautyPhotoStepDescription;const p=document.createElement("div");p.className="gengage-chat-beauty-photo-step-actions";const h=document.createElement("button");h.type="button",h.className="gengage-chat-beauty-photo-step-upload gds-btn gds-btn-primary",h.textContent=r?i.beautyPhotoStepProcessing:(typeof n.upload_label=="string"?n.upload_label:void 0)??i.beautyPhotoStepUpload,h.disabled=r,a?.onUpload&&h.addEventListener("click",()=>a.onUpload());const g=document.createElement("button");return g.type="button",g.className="gengage-chat-beauty-photo-step-skip gds-btn gds-btn-ghost",g.textContent=(typeof n.skip_label=="string"?n.skip_label:void 0)??i.beautyPhotoStepSkip,a?.onSkip&&g.addEventListener("click",()=>a.onSkip()),p.appendChild(h),p.appendChild(g),c.appendChild(l),c.appendChild(d),c.appendChild(p),o.appendChild(s),o.appendChild(c),o}function Cs(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 Ss(e,t,a,n,r){if(!a.visible)return e&&(e.hidden=!0,e.innerHTML=""),e;const i=Cs(e,t);i.hidden=!1,i.innerHTML="";const o=tn({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 an(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 nn(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 rn(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=nn(e.strengths,t.strengths??[],"gengage-chat-photo-analysis-section--strengths"),s=nn(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 d=document.createElement("p");if(d.className="gengage-chat-photo-analysis-celeb-name",d.textContent=t.celebStyle,c.appendChild(l),c.appendChild(d),t.celebStyleReason){const p=document.createElement("p");p.className="gengage-chat-photo-analysis-celeb-reason",p.textContent=t.celebStyleReason,c.appendChild(p)}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 Es(e){const t={...it,...e?.i18n??{}};return{badge:t.photoAnalysisBadge,strengths:t.photoAnalysisStrengthsLabel,focus:t.photoAnalysisFocusLabel,celebStyle:t.photoAnalysisCelebStyleLabel}}function Ps(e,t){const a=an(e.props??{})??{summary:""};return rn(Es(t),a)}function Ts(e,t,a){e.innerHTML="",a&&e.appendChild(rn(t,a))}var ym='<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>',on={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>'},As=it,Ls=1400,sn=1500,Is=/data:image\/(png|jpeg|jpg|webp);base64,[A-Za-z0-9+/=]+/gi;async function Ns(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(Is)?.[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 zs(e){try{const t=e??(typeof navigator.clipboard?.read=="function"?navigator.clipboard.read():null);return t?Ns(await t):null}catch{}return null}var Ms=class{_renderPhotoAnalysisCard(e,t){Ts(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={...As,...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 d=document.createElement("div");d.className="gengage-chat-header-title-row",d.dataset.gengagePart="chat-header-title-row";const p=document.createElement("span");if(p.className="gengage-chat-header-title",p.dataset.gengagePart="chat-header-title",p.textContent=t.headerTitle??this.i18n.headerTitle??"Product Expert",d.appendChild(p),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,d.appendChild(C)}l.appendChild(d);const h=document.createElement("a");h.className="gengage-chat-header-powered",h.dataset.gengagePart="chat-header-powered-by",h.href="https://gengage.ai/",h.target="_blank",h.rel="noopener noreferrer",h.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(h),o.appendChild(l),i.appendChild(o);const g=document.createElement("div");g.className="gengage-chat-header-right",g.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()),g.appendChild(C),this._reopenPanelBtn=C}{const C=document.createElement("button");C.type="button",C.className="gengage-chat-header-btn gds-btn gds-btn-ghost gds-icon-btn",C.dataset.gengagePart="chat-header-cart",C.setAttribute("aria-label",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"><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?.()),g.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?.()),g.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?.()),g.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 Y=document.createElement("span");Y.className="gengage-chat-header-fav-badge",Y.dataset.gengagePart="chat-header-favorites-badge",Y.setAttribute("aria-hidden","true"),Y.style.display="none",C.appendChild(Y),this._favBadgeEl=Y,C.addEventListener("click",()=>{t.onFavoritesClick?.()}),g.appendChild(C)}g.appendChild(b),r&&i.insertBefore(r,i.firstChild),i.appendChild(g);{let Y=0,pe=0,me=!1;const V=oe=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768)||oe.target.closest('button, a, input, [role="button"]'))return;const Be=oe.changedTouches?.[0];Be&&(Y=Be.clientY,pe=0,me=!0,this.root.style.transition="none")},ne=oe=>{if(!me)return;const Be=oe.changedTouches?.[0];if(!Be)return;pe=Be.clientY-Y;const bm=(t.getMobileState?.()??"full")==="full"?Math.max(0,pe):pe;oe.preventDefault(),this.root.style.transform=`translateY(${bm}px)`},he=()=>{if(!me)return;me=!1;const oe=t.getMobileState?.()??"full";let Be;pe>72?Be=oe==="full"?"half":"close":pe<-72&&oe==="half"?Be="full":Be=oe,this.root.style.transition="",Be==="close"?(this.root.style.transform="translateY(100%)",setTimeout(()=>{this.root.style.transform="",t.onMobileSnap?.("close")},280)):(this.root.style.transform="",t.onMobileSnap?.(Be)),pe=0},W=()=>{me&&(me=!1,pe=0,this.root.style.transition="",this.root.style.transform="")};i.addEventListener("touchstart",V,{passive:!0}),i.addEventListener("touchmove",ne,{passive:!1}),i.addEventListener("touchend",he,{passive:!0}),i.addEventListener("touchcancel",W,{passive:!0}),this._cleanups.push(()=>{i.removeEventListener("touchstart",V),i.removeEventListener("touchmove",ne),i.removeEventListener("touchend",he),i.removeEventListener("touchcancel",W)})}const m=document.createElement("div");m.className="gengage-chat-body",m.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 ws({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 f=()=>this._updateScrollAffordance();this._panelEl.addEventListener("scroll",f,{passive:!0}),this._cleanups.push(()=>this._panelEl.removeEventListener("scroll",f)),m.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 u=document.createElement("button");u.className="gengage-chat-panel-divider-toggle gds-btn gds-btn-ghost",u.dataset.gengagePart="chat-panel-divider-toggle",u.type="button",u.setAttribute("aria-label",this.i18n.togglePanelAriaLabel),u.setAttribute("title",this.i18n.togglePanelAriaLabel),u.textContent="»",u.addEventListener("click",()=>{if(this._ignoreNextDividerClick){this._ignoreNextDividerClick=!1;return}this.togglePanel(),this._onPanelToggle?.()});let A=null,E=null;const w=24,T=C=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768))return;const Y=C.changedTouches?.[0];Y&&(A=Y.clientX,E=Y.clientY)},N=C=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768)||A===null||E===null)return;const Y=C.changedTouches?.[0];if(!Y)return;const pe=Y.clientX-A,me=Y.clientY-E;if(A=null,E=null,Math.abs(me)<w||Math.abs(me)<Math.abs(pe))return;const V=me<0;V!==this._panelCollapsed&&(this._ignoreNextDividerClick=!0,this.setPanelCollapsed(V),this._onPanelToggle?.())};this._dividerEl.addEventListener("touchstart",T,{passive:!0}),this._dividerEl.addEventListener("touchend",N,{passive:!0}),this._cleanups.push(()=>{this._dividerEl.removeEventListener("touchstart",T),this._dividerEl.removeEventListener("touchend",N)}),this._dividerEl.appendChild(u),m.appendChild(this._dividerEl);const x=document.createElement("div");x.className="gengage-chat-conversation",x.dataset.gengagePart="chat-conversation",this._conversationEl=x,x.appendChild(i);const P=document.createElement("div");P.className="gengage-chat-offline-bar gds-evidence-card gds-evidence-card-warning",P.dataset.gengagePart="chat-offline-bar",P.setAttribute("role","status"),P.setAttribute("aria-live","polite"),P.textContent=this.i18n.offlineMessage,typeof navigator<"u"&&!navigator.onLine&&P.classList.add("gengage-chat-offline-bar--visible"),x.appendChild(P);const F=()=>P.classList.add("gengage-chat-offline-bar--visible"),ee=()=>P.classList.remove("gengage-chat-offline-bar--visible");window.addEventListener("offline",F),window.addEventListener("online",ee),this._cleanups.push(()=>{window.removeEventListener("offline",F),window.removeEventListener("online",ee)}),this._kvkkSlot=document.createElement("div"),this._kvkkSlot.className="gengage-chat-kvkk-slot",this._kvkkSlot.dataset.gengagePart="chat-kvkk-slot",x.appendChild(this._kvkkSlot),this.messagesEl=document.createElement("div"),this.messagesEl.id=Tt,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),Xa(this.messagesEl);const ie=document.createElement("button");ie.type="button",ie.className="gengage-chat-former-messages-btn gds-chip",ie.dataset.gengagePart="chat-former-messages-button",ie.textContent=this.i18n.showFormerMessagesButton,ie.setAttribute("aria-label",this.i18n.showFormerMessagesButton),ie.style.display="none",ie.addEventListener("click",()=>{this._options.presentation?.onReleasePresentationFocus?.()}),this.messagesEl.appendChild(ie),this._formerMessagesBtn=ie;const ve=()=>{this._userInteractionUntil=Date.now()+2e3};let D=!1;const v=()=>this._options.presentation,I=()=>{D||(D=!0,requestAnimationFrame(()=>{D=!1;const{scrollTop:C,scrollHeight:Y,clientHeight:pe}=this.messagesEl,me=Y-C-pe;this._userScrolledUp=me>10;const V=this._presentationPinned?me<96:me<32,ne=Date.now(),he=ne<this._programmaticScrollUntil,W=!V&&ne<this._userInteractionUntil,oe=he?!1:W;V!==this._presentationPinned&&(this._presentationPinned=V,v()?.onPinnedToBottomChange?.(V)),oe!==this._presentationUserInteracting&&(this._presentationUserInteracting=oe,v()?.onUserInteractingChange?.(oe))}))};this.messagesEl.addEventListener("scroll",I,{passive:!0}),this._cleanups.push(()=>{this.messagesEl.removeEventListener("scroll",I)});const O=C=>{ve(),C.deltaY<-6&&this._presentationFocusThreadId&&this._options.presentation?.onFormerMessagesHint?.()};this.messagesEl.addEventListener("wheel",O,{passive:!0}),this._cleanups.push(()=>this.messagesEl.removeEventListener("wheel",O));const B=C=>{ve(),this._touchStartY=C.touches[0]?.clientY??null},j=C=>{ve();const Y=C.touches[0]?.clientY,pe=this._touchStartY;typeof Y=="number"&&typeof pe=="number"&&Y-pe>10&&this._presentationFocusThreadId&&this._options.presentation?.onFormerMessagesHint?.()};this.messagesEl.addEventListener("touchstart",B,{passive:!0}),this.messagesEl.addEventListener("touchmove",j,{passive:!0}),this._cleanups.push(()=>{this.messagesEl.removeEventListener("touchstart",B),this.messagesEl.removeEventListener("touchmove",j)}),x.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 Z=document.createElement("div");Z.className="gengage-chat-pills-scroll",Z.dataset.gengagePart="chat-suggestion-pills-scroll",this._pillsEl.appendChild(Z);const q=document.createElement("button");q.className="gengage-chat-pills-arrow gds-btn gds-btn-ghost",q.dataset.gengagePart="chat-suggestion-pills-more",q.type="button",q.setAttribute("aria-label",this.i18n.moreSuggestionsAriaLabel),q.textContent="›",q.addEventListener("click",()=>{Z.scrollBy({left:150,behavior:"smooth"})}),this._pillsEl.appendChild(q);let y=!1;const L=()=>{y||(y=!0,requestAnimationFrame(()=>{y=!1;const C=Z.scrollLeft+Z.clientWidth>=Z.scrollWidth-4;q.style.display=C?"none":""}))};Z.addEventListener("scroll",L,{passive:!0}),this._cleanups.push(()=>{Z.removeEventListener("scroll",L)}),x.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",x.appendChild(this._inputChipsEl);const S=document.createElement("div");S.className="gengage-chat-input-area",S.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 Y=C.clipboardData;if(!Y)return;let pe=null;const me=Y.files?.[0];if(me&&me.type.startsWith("image/"))pe=me;else if(Y.items?.length)for(let V=0;V<Y.items.length;V++){const ne=Y.items[V];if(ne?.kind==="file"&&ne.type.startsWith("image/")){const he=ne.getAsFile();if(he){pe=he;break}}}pe&&(C.preventDefault(),this._routeAttachmentFile(pe))}),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 z=document.createElement("div");z.className="gengage-chat-attach-wrap",z.dataset.gengagePart="chat-attach-wrap",this._attachWrapEl=z;const M=document.createElement("button");this._attachBtn=M,M.className="gengage-chat-attach-btn gds-btn gds-btn-ghost",M.dataset.gengagePart="chat-attach-button",M.type="button",M.setAttribute("aria-label",this.i18n.attachImageButton),M.setAttribute("aria-haspopup","menu"),M.setAttribute("aria-expanded","false"),M.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>',M.addEventListener("click",C=>{C.stopPropagation(),this._toggleAttachMenu()});const R=document.createElement("div");this._attachMenuEl=R,R.className="gengage-chat-attach-menu gds-menu",R.dataset.gengagePart="chat-attach-menu",R.setAttribute("role","menu"),R.setAttribute("hidden","");const $=document.createElement("button");$.type="button",$.className="gengage-chat-attach-menu-item gds-btn gds-btn-ghost",$.dataset.gengagePart="chat-attach-menu-select-photo",$.setAttribute("role","menuitem"),$.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>`,$.addEventListener("click",C=>{C.stopPropagation(),this._closeAttachMenu(),this._fileInput.click()});const ae=document.createElement("div");ae.className="gengage-chat-attach-menu-sep",ae.dataset.gengagePart="chat-attach-menu-separator",ae.setAttribute("aria-hidden","true");const te=document.createElement("button");te.type="button",te.className="gengage-chat-attach-menu-item gds-btn gds-btn-ghost",te.dataset.gengagePart="chat-attach-menu-paste",te.setAttribute("role","menuitem"),te.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>`,te.addEventListener("click",C=>{C.stopPropagation();const Y=typeof navigator.clipboard?.read=="function"?navigator.clipboard.read():void 0;this._pasteImageFromClipboardMenu(Y)}),R.appendChild($),R.appendChild(ae),R.appendChild(te),z.appendChild(M),z.appendChild(R),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 U=document.createElement("img");U.className="gengage-chat-attachment-preview-thumb",U.dataset.gengagePart="chat-attachment-preview-thumb",U.alt="",this._previewName=document.createElement("span"),this._previewName.className="gengage-chat-attachment-name",this._previewName.dataset.gengagePart="chat-attachment-preview-name";const ce=document.createElement("button");ce.className="gengage-chat-attachment-remove gds-btn gds-btn-ghost",ce.dataset.gengagePart="chat-attachment-preview-remove",ce.type="button",ce.setAttribute("aria-label",this.i18n.removeAttachmentButton),ce.textContent="×",ce.addEventListener("click",()=>this.clearAttachment()),this._previewStrip.appendChild(U),this._previewStrip.appendChild(this._previewName),this._previewStrip.appendChild(ce),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()}),S.addEventListener("dragover",C=>{C.preventDefault(),S.classList.add("gengage-chat-input-area--dragover")}),S.addEventListener("dragleave",()=>{S.classList.remove("gengage-chat-input-area--dragover")}),S.addEventListener("drop",C=>{C.preventDefault(),S.classList.remove("gengage-chat-input-area--dragover");const Y=C.dataTransfer?.files[0];Y&&this._routeAttachmentFile(Y)});const X=document.createElement("div");X.className="gengage-chat-input-pill gds-input-shell",X.dataset.gengagePart="chat-input-shell",X.appendChild(z),X.appendChild(this.inputEl),this._voiceEnabled&&vs()&&(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()),X.appendChild(this._micBtn),this._voiceInput=new ys({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,Y)=>{this._micBtn?.classList.remove("gengage-chat-mic-btn--active")}},{lang:this._voiceLang})),X.appendChild(this.sendBtn),S.appendChild(this._previewStrip),S.appendChild(this._fileInput),S.appendChild(X),x.appendChild(S),m.appendChild(x),this._comparisonDockSlotEl=document.createElement("div"),this._comparisonDockSlotEl.className="gengage-chat-comparison-dock-slot",this._comparisonDockSlotEl.dataset.gengagePart="comparison-dock-slot",m.appendChild(this._comparisonDockSlotEl),this.root.appendChild(m),this._setupHorizontalSwipe(x);const $e=document.createElement("div");$e.className="gengage-chat-footer",$e.dataset.gengagePart="chat-footer",$e.textContent=this.i18n.poweredBy,this.root.appendChild($e);const Pt=C=>{C.key==="Escape"&&t.onClose()};this.root.addEventListener("keydown",Pt),this._cleanups.push(()=>this.root.removeEventListener("keydown",Pt)),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=Ce(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"),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="${_e(e)}"]`)?.remove(),this._presentationFocusThreadId&&this._applyPresentationCollapsed()}showTypingIndicator(e){this.removeTypingIndicator();const t=this._thinkingSteps.length>0?this._thinkingSteps.slice(-3):e?[e]:this.i18n.loadingSequenceGeneric,{root:a,binding:n}=this._createLoadingSequence("chat",t,"chat-typing-indicator","gengage-chat-typing");a.dataset.typing="true",this._typingLoadingBinding=n,this.messagesEl.appendChild(a),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()}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=on[n.icon]??'<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>',s=document.createElement("span");s.className="gengage-chat-pill-icon",s.innerHTML=o,r.appendChild(s)}if(n.image&&Re(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=xs({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=Ss(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 zs(e);if(t){this._routeAttachmentFile(t),this._closeAttachMenu();return}Te("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))}_clearPanelAiZoneState(){this._destroyLoadingBinding(this._panelAiZoneLoadingBinding),this._panelAiZoneLoadingBinding=null,this._panelAiZoneEl.innerHTML="",this._panelAiZoneEl.setAttribute("hidden","")}_resetPanelAiZoneElement(){this._panelAiZoneEl=document.createElement("div"),this._panelAiZoneEl.className="gengage-chat-panel-ai-zone",this._panelAiZoneEl.setAttribute("hidden","")}_emitHostShellSync(){this._onHostShellSync?.()}_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 d=document.createElement("div");d.className="gengage-chat-comparison-recommended-info";for(let x=0;x<2;x++){const P=document.createElement("div");P.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-rec-title",x===1&&P.classList.add("gengage-chat-comparison-skeleton-rec-title--short"),d.appendChild(P)}const p=document.createElement("div");p.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-rec-price",d.appendChild(p),c.appendChild(l),c.appendChild(d),o.appendChild(c);const h=document.createElement("div");h.className="gengage-chat-comparison-highlights";const g=document.createElement("div");g.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-hl-label",h.appendChild(g);const b=document.createElement("ul");b.className="gengage-chat-comparison-skeleton-hl-list";for(let x=0;x<3;x++){const P=document.createElement("li"),F=document.createElement("div");F.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-hl-line",x===1&&F.classList.add("gengage-chat-comparison-skeleton-hl-line--medium"),x===2&&F.classList.add("gengage-chat-comparison-skeleton-hl-line--short"),P.appendChild(F),b.appendChild(P)}h.appendChild(b),o.appendChild(h),i.appendChild(o);const m=document.createElement("div");m.className="gengage-chat-comparison-key-differences";const f=document.createElement("div");f.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-kd-heading",m.appendChild(f);const u=document.createElement("div");u.className="gengage-chat-comparison-key-differences-content";for(let x=0;x<4;x++){const P=document.createElement("div");P.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-kd-line",u.appendChild(P)}m.appendChild(u),i.appendChild(m);const A=document.createElement("div");A.className="gengage-chat-comparison-special gengage-chat-comparison-special--skeleton";const E=document.createElement("div");E.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-special-line",A.appendChild(E),i.appendChild(A);const w=document.createElement("div");w.className="gengage-chat-comparison-skeleton-table-wrap";const T=document.createElement("div");T.className="gengage-chat-comparison-skeleton-table-head";const N=document.createElement("div");N.className="gengage-chat-comparison-skeleton-table-corner",T.appendChild(N);for(let x=0;x<3;x++){const P=document.createElement("div");P.className="gengage-chat-comparison-skeleton-table-col";const F=document.createElement("div");F.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-img";const ee=document.createElement("div");ee.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-name";const ie=document.createElement("div");ie.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-price",P.appendChild(F),P.appendChild(ee),P.appendChild(ie),T.appendChild(P)}w.appendChild(T);for(let x=0;x<3;x++){const P=document.createElement("div");P.className="gengage-chat-comparison-skeleton-table-row";const F=document.createElement("div");F.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-label",P.appendChild(F);for(let ee=0;ee<3;ee++){const ie=document.createElement("div");ie.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-cell",P.appendChild(ie)}w.appendChild(P)}i.appendChild(w),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._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,e?this._panelEl.classList.add("gengage-chat-panel--collapsed"):this._panelEl.classList.remove("gengage-chat-panel--collapsed");const t=this._dividerEl.querySelector(".gengage-chat-panel-divider-toggle");t&&(t.textContent=e?"«":"»"),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)},Ls))}_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="${_e(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=Ce(t)),this._scrollToBottom(!1)}markFirstBotMessage(e){this._firstBotMessageIds.add(e);const t=this.messagesEl.querySelector(`[data-message-id="${_e(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="${_e(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="${_e(e)}"]`);let n=null,r=null;for(let s=0;s<a.length;s++){const c=a[s];if(c instanceof HTMLElement&&(r||(r=c),!c.classList.contains("gengage-chat-bubble--presentation-collapsed")&&!c.classList.contains("gengage-chat-bubble--hidden")&&c.offsetHeight!==0&&!(c.classList.contains("gengage-chat-bubble--assistant")&&(c.textContent?.trim().length??0)===0))){n=c;break}}if(n||(n=r),!n)return!1;const i=Date.now();this._programmaticScrollUntil=i+sn,this._scrollLockedUntil=Math.max(this._scrollLockedUntil,i+sn),this._userScrolledUp=!0;const o=()=>{this._scrollMessagesTo(Math.max(n.offsetTop-20,0),t)};return o(),requestAnimationFrame(o),!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=on[t.icon]??'<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>',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 d=getComputedStyle(l);return l.hidden||l.getAttribute("aria-hidden")==="true"||d.display==="none"||d.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(){Xa(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}},cn=["beauty_consulting","watch_expert","booking"],Bs=["shopping",...cn];function Rs(e){return typeof e=="string"&&Bs.includes(e)?e:null}function na(e){return e==null||typeof e!="object"||Array.isArray(e)?null:e}function Os(...e){for(const t of e)if(typeof t=="string"){const a=t.trim();if(a.length>0)return a}}function Ds(e){const t=na(e);if(!t)return null;const a=Os(t.assistant_mode,t.assistantMode);return!a||!cn.includes(a)?null:a}var Hs=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){De("mode","redirect metadata received",e);const t=Ds(e);return t?(this.switchMode(t),!0):!1}switchMode(e){const t=this._mode;this._mode=e,De("mode","assistant mode switched",{from:t,to:e})}updateFromContext(e){const t=e.assistant_mode;if(typeof t=="string"&&t){const a=Rs(t);a?this._mode=a:De("mode","ignoring unrecognised assistant_mode from context",t)}else t===null&&(this._mode="shopping");this._uiHints=na(e.ui_hints)??null}reset(){const e=this._mode!=="shopping";return this._mode="shopping",this._uiHints=null,e}resolveAttachmentActionType(){return this._mode==="beauty_consulting"?"user_message":"findSimilar"}shouldCondenseThinking(){return this._mode!=="shopping"}};function Fs(){return{streamIncludedBeautyPhotoStep:!1,pendingPhotoStepSkip:!1}}function $s(e,t,a,n,r){if(e==="PhotoAnalysisCard"){const i=an(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):(De("beauty","PhotoAnalysisCard parse failed, falling through to generic renderer",t),!1)}if(e==="BeautyPhotoStep"){a.streamIncludedBeautyPhotoStep=!0;const i=ks(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 Us(e){return e.renderHint==="photo_analysis"}function js(e,t){e.streamIncludedBeautyPhotoStep||t.drawer?.setBeautyPhotoStepCard({visible:!1}),e.pendingPhotoStepSkip&&(e.pendingPhotoStepSkip=!1,t.sendSkipMessage())}function Zs(e,t){e.pendingPhotoStepSkip&&(e.pendingPhotoStepSkip=!1,t.sendSkipMessage())}function ra(e){return Number.isFinite(e)?Math.max(0,Math.min(5,e)):0}function ln(e){return Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function dn(e){const t=ra(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 Ae(e){e.addEventListener("error",()=>{e.style.display="none"},{once:!0})}var qs={currencyCode:"TRY",currencySymbol:"TL",currencyPosition:"suffix",thousandsSeparator:".",decimalSeparator:",",alwaysShowDecimals:!1};function J(e,t){const a=Number(e);if(!Number.isFinite(a)||a<0)return e;const n={...qs,...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 d;return c!==void 0?d=`${l}${n.decimalSeparator}${c}`:d=l,n.currencySymbol?n.currencyPosition==="prefix"?`${n.currencySymbol}${d}`:`${d} ${n.currencySymbol}`:d}var Vs={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 Gs(e,t,a){return t?.[e]??Vs[e]??e.replace(/_/g," ").replace(/^./u,n=>Ws(n,a))}function Ws(e,t){try{return e.toLocaleUpperCase(ft(t))}catch{return e.toLocaleUpperCase("tr")}}function gn(e){if(typeof e!="string")return!1;const t=Number(e);return Number.isFinite(t)&&t>0}function Ks(e){const t=typeof e=="number"?e:typeof e=="string"?Number(e):NaN;return Number.isFinite(t)&&t>0}function Ys(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 Js(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 d=document.createElement("div");d.className="gengage-chat-comparison-recommended-label",d.textContent=s?.recommendedChoiceLabel??"Recommended Choice",l.appendChild(d);const p=document.createElement("div");p.className="gengage-chat-comparison-recommended-body",p.classList.add("gds-clickable"),p.tabIndex=0,p.setAttribute("role","button"),p.setAttribute("aria-label",t.name);const h=document.createElement("div");if(h.className="gengage-chat-comparison-recommended-media",t.imageUrl&&Re(t.imageUrl)){const u=document.createElement("img");u.src=t.imageUrl,u.alt=t.name,u.loading="lazy",u.addEventListener("error",()=>{u.style.display="none"},{once:!0}),h.appendChild(u)}else{const u=document.createElement("div");u.className="gengage-chat-comparison-recommended-placeholder",u.setAttribute("aria-hidden","true"),h.appendChild(u)}p.appendChild(h);const g=document.createElement("div");g.className="gengage-chat-comparison-recommended-info";const b=document.createElement("div");b.className="gengage-chat-comparison-recommended-title",b.textContent=t.name,g.appendChild(b);const m=document.createElement("div");if(m.className="gengage-chat-comparison-recommended-meta",Ks(t.rating)&&m.appendChild(Ys(t.rating)),gn(t.price)){const u=document.createElement("div");u.className="gengage-chat-comparison-recommended-price",u.textContent=J(t.price,e.pricing),m.appendChild(u)}if(m.childElementCount>0&&g.appendChild(m),e.recommendedText){const u=document.createElement("p");u.className="gengage-chat-comparison-recommended-text",u.innerHTML=Ce(e.recommendedText),g.appendChild(u)}p.appendChild(g);const f=()=>{o({sku:t.sku,name:t.name})};if(p.addEventListener("click",f),p.addEventListener("keydown",u=>{u.key!=="Enter"&&u.key!==" "||(u.preventDefault(),f())}),l.appendChild(p),r.length>0){const u=document.createElement("div");u.className="gengage-chat-comparison-highlights",u.dataset.gengagePart="comparison-highlights";const A=document.createElement("div");A.className="gengage-chat-comparison-highlights-label",A.textContent=s?.highlightsLabel??"Key Highlights",u.appendChild(A);const E=document.createElement("ul");for(const w of r){const T=document.createElement("li");T.textContent=w,E.appendChild(T)}u.appendChild(E),l.appendChild(u)}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 d=document.createElement("summary");d.className="gengage-chat-comparison-key-differences-summary";const p=document.createElement("span");p.className="gengage-chat-comparison-key-differences-summary-label",p.textContent=s?.keyDifferencesLabel??"Key Differences";const h=document.createElement("span");h.className="gengage-chat-comparison-key-differences-summary-meta",h.textContent=s?.viewMoreLabel??"Show More",d.appendChild(p),d.appendChild(h),l.appendChild(d);const g=document.createElement("div");g.className="gengage-chat-comparison-key-differences-content",g.innerHTML=Ce(Xs(e.keyDifferencesHtml)),l.appendChild(g),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 d=document.createElement("summary");d.textContent=s?.specialCasesLabel??"For Special Cases",l.appendChild(d);const p=document.createElement("ul");for(const h of i)Qs(p,h);p.childElementCount>0&&l.appendChild(p),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 d=document.createElement("thead"),p=document.createElement("tr"),h=document.createElement("th");p.appendChild(h);for(const m of a){const f=document.createElement("th");m.sku===t?.sku&&(f.className="gengage-chat-comparison-selected gds-comparison-table-winner-cell");const u=document.createElement("div");u.className="gengage-chat-comparison-table-header-cell gengage-chat-comparison-table-header-cell--clickable gds-clickable",u.tabIndex=0,u.setAttribute("role","button"),u.setAttribute("aria-label",m.name),u.title=m.name;const A=()=>{o({sku:m.sku,name:m.name})};if(u.addEventListener("click",A),u.addEventListener("keydown",w=>{w.key!=="Enter"&&w.key!==" "||(w.preventDefault(),A())}),m.imageUrl&&Re(m.imageUrl)){const w=document.createElement("img");w.src=m.imageUrl,w.alt=m.name,w.loading="lazy",w.addEventListener("error",()=>{w.style.display="none"},{once:!0}),u.appendChild(w)}else{const w=document.createElement("div");w.className="gengage-chat-comparison-table-header-img-placeholder",w.setAttribute("aria-hidden","true"),u.appendChild(w)}const E=document.createElement("div");if(E.className="gengage-chat-comparison-table-product-name",E.textContent=m.name,u.appendChild(E),gn(m.price)){const w=document.createElement("div");w.className="gengage-chat-comparison-table-price",w.textContent=J(m.price,e.pricing),u.appendChild(w)}f.appendChild(u),p.appendChild(f)}d.appendChild(p),l.appendChild(d);const g=document.createElement("tbody");for(const m of n){const f=document.createElement("tr"),u=document.createElement("td");u.className="gengage-chat-comparison-label",u.textContent=Gs(m.label,s?.criteriaLabels,e.locale),f.appendChild(u);for(let A=0;A<m.values.length;A++){const E=document.createElement("td");a[A]?.sku===t?.sku&&(E.className="gengage-chat-comparison-selected gds-comparison-table-winner-cell");const w=m.values[A]??"";pn(w)?E.innerHTML=Ce(w):E.textContent=w,f.appendChild(E)}g.appendChild(f)}l.appendChild(g);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 d=c.querySelectorAll('button, [href], input, [tabindex]:not([tabindex="-1"])');if(d.length===0)return;const p=d[0],h=d[d.length-1];l.shiftKey&&document.activeElement===p?(l.preventDefault(),h.focus()):!l.shiftKey&&document.activeElement===h&&(l.preventDefault(),p.focus())}),c}function Xs(e){if(/<[uo]l[\s>]/i.test(e)||/<li[\s>]/i.test(e))return e;const t=e.split(`
|
|
48
|
+
`);r=g.pop()??"";for(const b of g)if(qa(b,t))return}if(r.trim()&&qa(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 Va=3,go=(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():""},ea=(e,t)=>e?e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(a=>go(a,t)).filter(Boolean):[];function po(e){const t=(e.display_keywords??[]).flatMap(r=>ea(r,{stripLeadingStopWords:!0})),a=t.filter((r,i)=>t.indexOf(r)===i);if(a.length>0)return a.slice(0,Va);const n=[...ea(e.chosen_attribute,{stripLeadingStopWords:!0}),...ea(e.short_name)];return n.filter((r,i)=>n.indexOf(r)===i).slice(0,Va)}function ho(e){return po(e).join(" • ")}var uo=["beauty_consulting","watch_expert"];function Ga(e){return typeof e=="string"&&uo.includes(e)}function mo(e){if(typeof e.type!="string")return null;if(fo(e))return e;const t=e;switch(t.type){case"outputText":return bo(t);case"suggestedActions":return vo(t);case"productList":return yo(t);case"productDetails":return _o(t);case"productDetailsSimilars":return xo(t);case"comparisonTable":return wo(t);case"context":return Eo(t);case"chatStreamEnd":return Po();case"loading":return To(t);case"panelLoading":return Ao(t);case"similarLoading":return Lo(t);case"redirect":return Io(t);case"error":return No(t);case"dummy":return zo(t);case"launcherAction":return Mo(t);case"text":return ta(t);case"productItem":return Bo(t);case"text_image":return Wa(t);case"quick_qna":return Ka(t);case"reviewHighlights":return Ro(t);case"aiProductSuggestions":return Ho(t);case"aiProductGroupings":return Fo(t);case"aiSuggestedSearches":return $o(t);case"prosAndCons":return Oo(t);case"getGroundingReview":return Uo(t);case"voice":return Zo(t);case"visitorDataResponse":return Do(t);case"productListPreview":return jo();case"groupList":return qo(t);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return Vo(t);case"launcherContent":return Wo(t);case"handoff":return Go(t);case"uiSpec":return as(t);default:return null}}function fo(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=Se(e.spec);return n?typeof n.root=="string"&&Se(n.elements)!==null:!1}case"action":{const a=Se(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 bo(e){const t=K(e.payload.text,e.payload.plain_text)??"",a=K(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 vo(e){return Ya((e.payload.actions??[]).map(t=>{const a=K(t.title)??"",n=He(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(vt),"chat")}function yo(e){const t=(Array.isArray(e.payload.style_variations)?e.payload.style_variations:[]).map(o=>{const s=K(o.style_label);if(!s)return null;const c=K(o.style_mood),l=K(o.image_url??void 0),d=(Array.isArray(o.product_list)?o.product_list:[]).map(h=>{const g=Se(h);return g?aa(Se(g.product_detail)??Se(g.product)??g):null}).filter(vt),p=Array.isArray(o.recommendation_groups)?o.recommendation_groups.map(h=>({label:K(h.label)??"",reason:K(h.reason)??"",skus:Array.isArray(h.skus)?h.skus.filter(g=>typeof g=="string"&&g.trim().length>0):[]})):[];return{style_label:s,style_mood:c??"",...l?{image_url:l}:{},...typeof o.status=="string"?{status:o.status}:{},product_list:d,recommendation_groups:p}}).filter(vt),a=e.payload.product_list??[],n=Ga(e.payload.source)&&t.length>0?t[0].product_list:null,r=n?Ko(n,"chat"):Ja(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 _o(e){const t=e.payload.productDetails;if(!t)return Jo("chat");const a=nt(t);return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:{...t,...a}}}}},panelHint:"panel"}}function xo(e){const t=Ja(e.payload.similarProducts??[],"chat"),a=t.spec.elements[t.spec.root];return a&&(a.props={...a.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function wo(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 f of t){const u=nt(f);o.push(u)}const s=ko(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(f=>f.sku===c)??o[0]:o[0],d=[];if(Array.isArray(n?.key_differences))for(const f of n.key_differences)typeof f=="string"&&d.push(f);const p=es(n?.special_considerations),h=n?.recommended_choice,g=n?.winner_hits,b={};for(const f of o){const u=f.sku;u&&(b[u]={title:f.name??u,type:"launchSingleProduct",payload:{sku:u}})}const m={products:o,attributes:s,highlights:d,productActions:b};return l&&(m.recommended=l),p.length>0&&(m.specialCases=p),h&&(m.recommendedText=h),g&&(m.winnerHits=g),typeof n?.key_differences=="string"&&(m.keyDifferencesHtml=n.key_differences),n?.special_considerations&&(m.specialConsiderations=n.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:m}}},panelHint:"panel"}}function ko(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 p=a.criteria_view??a.criteria_view_short??{},h=a.compared_field_names??Object.keys(e),g=[];for(const b of h){const m=e[b];if(!m||!Array.isArray(m))continue;const f=p[b]??b;g.push({label:f,values:m.map(u=>typeof u=="string"?u:String(u??""))})}return g}const o=e,s=t.map(p=>String(p.sku??"")).filter(p=>p.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:Co(o)).filter(p=>p!=="name"&&p!=="name_short"&&!p.endsWith("_short")),d=[];for(const p of l){const h=s.map(b=>{const m=o[b];if(!m||typeof m!="object")return"";const f=m[`${p}_short`],u=m[p];return So(f??u)});if(h.every(b=>b.length===0))continue;const g=c[p]??p;d.push({label:g,values:h})}return d}function Co(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 So(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function Eo(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function Po(){return{type:"done"}}function To(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 Ao(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Lo(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Io(e){const t=K(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:K(e.payload.to)}}}function No(e){return{type:"error",code:"BACKEND_ERROR",message:K(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function zo(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function Mo(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),Ka({type:"quick_qna",payload:r})}const a=Se(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),Wa({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=Se(t.payload)??void 0;return i!==void 0&&(r.type=i),s!==void 0&&(r.payload=s),o!==void 0&&(r.theme=o),ta({type:"text",payload:r})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function ta(e){const t={text:K(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 Bo(e){return Yo(e.payload,"qna")}function Wa(e){const t=K(e.payload.text)??"",a=He(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),ta({type:"text",payload:n})}function Ka(e){return Ya((e.payload.action_list??[]).map(t=>{const a=K(t.title)??"",n=He(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(vt),"qna")}function Ro(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 Oo(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 Do(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function Ho(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=Xo(r);if(!i)continue;const o={product:i},s=He(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 Fo(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=K(i.name)??"",s=K(i.sku,i.repr_sku),c=K(i.image,i.repr_image),l=s!==void 0?{type:"findSimilar",payload:{sku:s}}:void 0,d=He(i.requestDetails??l,o),p=(Array.isArray(i.group_products)?i.group_products:[]).map(b=>{const m=Se(b);return m?aa(m):null}).filter(vt),h=c??K(...p.map(b=>b.imageUrl));if(o&&p.length>0){const b={groupName:o,products:p};h&&(b.image=h),a.push(b)}if(!d)continue;const g={name:o,action:d};if(Array.isArray(i.labels)){const b=i.labels.filter(m=>typeof m=="string");b.length>0&&(g.labels=b)}c!==void 0&&(g.image=c),n.push(g)}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 $o(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=K(r.short_name,r.chosen_attribute,r.detailed_user_message)??`Search ${n+1}`,o={},s=K(r.detailed_user_message);s&&(o.text=s);const c=Se(Se(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(u=>typeof u=="string"));const d=K(r.sku,r.representative_product_sku,c?.sku);d&&(o.sku=d),o.is_suggested_text=1;const p={type:"inputText",payload:o},h=He(r.requestDetails,i),g=h?.type==="findSimilar"&&typeof o.text=="string"?He(p,i):h??He(p,i);if(!g)continue;const b={shortName:i,action:g},m=K(r.detailed_user_message);m&&m!==i&&(b.detailedMessage=m);const f=ho(r);f&&f!==i&&f!==(m??"")&&(b.whyDifferent=f),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 Uo(e){const t=e.payload,a=He(t.requestDetails??t.request_details,K(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 jo(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function Zo(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function qo(e){const t=e.payload.group_list??[],a=[];for(const r of t){const i=r.group_name??"",o=(r.product_list??[]).map(nt);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=He(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 Vo(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function Go(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 Wo(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function Ya(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 Ja(e,t){const a={},n=[];for(let r=0;r<e.length;r++){const i=e[r];if(!i)continue;const o=nt(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 Ko(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 Yo(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:nt(e),index:0}}}}}}function Jo(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function Xo(e){const t=K(e.sku),a=K(e.short_name),n={...Se(e.product_item)??e},r=K(e.discount_reason,e.discountReason);return r&&!K(n.discount_reason,n.discountReason)&&(n.discount_reason=r),aa(n,t,a)}function aa(e,t,a){const n=K(e.sku,t),r=K(e.name,a);if(!n||!r)return null;const i={sku:n,name:r},o=K(e.brand);o&&(i.brand=o);const s=K(e.url);s&&(i.url=s);const c=Qo(e.images);if(c.length>0)i.images=c;else{const m=K(e.image,e.image_url,e.imageUrl);m&&(i.images=[m])}const l=bt(e.price_discounted);l!==void 0&&(i.price_discounted=l);const d=bt(e.price);d!==void 0&&(i.price=d);const p=bt(e.rating);p!==void 0&&(i.rating=p);const h=bt(e.review_count)??bt(e.reviewCount);h!==void 0&&(i.review_count=h);const g=K(e.cart_code,e.cartCode);g&&(i.cart_code=g),typeof e.in_stock=="boolean"&&(i.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(i.in_stock=e.inStock);const b=K(e.discount_reason,e.discountReason);return b&&(i.discount_reason=b),nt(i)}function He(e,t){const a=Se(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 Se(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function K(...e){for(const t of e)if(typeof t=="string"){const a=t.trim();if(a.length>0)return a}}function Qo(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function es(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 bt(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 vt(e){return e!=null}var ts=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 nt(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=K(e.brand),o=K(e.name)??e.sku,s=i&&!o.toLowerCase().startsWith(i.toLowerCase())?`${i} ${o}`:o,c={sku:e.sku,name:s,url:K(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 d=e,p={};let h=!1;for(const g of Object.keys(d))ts.has(g)||(p[g]=d[g],h=!0);return h&&(c.extras=p),c}function as(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 ns={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"};function rs(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 is(e,t){return`${rs(t?.middlewareUrl)}/chat${ns[e]}`}function os(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"inputText":{const i={is_launcher:0};return t.pageContext?.extra&&(i.page_details=t.pageContext.extra),"is_suggested_text"in n||(i.is_suggested_text=0),{...e,payload:r(i)}}case"findSimilar":{const i={is_launcher:0};return e.title&&(i.text=e.title,i.input=e.title),{...e,payload: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 ss={user_message:"inputText"};function cs(e){const{action:t,type:a,payload:n,...r}=e,i=a??t?.type??"inputText",o=n??t?.payload,s=ss[i]??i,c={...r,type:s};return o!==void 0&&(c.payload=typeof o=="string"?{text:o}:o),JSON.stringify(c)}function ls(e,t,a){const n=is("process_action",a),r=new AbortController;return(async()=>{try{const o=cs(e),s=a.attachment!==void 0;let c;if(s){const h=new FormData;h.append("request",o),a.attachment!==void 0&&h.append("attachment",a.attachment),c={method:"POST",body:h,signal:r.signal}}else c={method:"POST",headers:{"Content-Type":"application/json"},body:o,signal:r.signal};const l=await fetch(n,c);if(!l.ok){let h=l.statusText;try{const g=await l.json(),b=g.detail??g.message??g.error;typeof b=="string"&&(h=b)}catch{}t.onError(new Error(`HTTP ${l.status}: ${h}`));return}let d=!1;const p=()=>{d||(d=!0,t.onDone())};await lo(l,{onEvent:h=>{const g=mo(h);if(g&&!(d&&g.type!=="error"))switch(g.type){case"text_chunk":t.onTextChunk(g.content,g.final===!0,{productMentions:g.productMentions,skuToProductItem:g.skuToProductItem,conversationMode:g.conversationMode,renderHint:g.renderHint,kvkk:g.kvkk});break;case"ui_spec":t.onUISpec(g.spec,g.widget,g.panelHint,g.clearPanel===!0);break;case"action":t.onAction(g);break;case"metadata":t.onMetadata(g);break;case"error":t.onError(new Error(g.message));break;case"done":p();break}},onError:t.onError,signal:r.signal}),p()}catch(o){if(o instanceof DOMException&&o.name==="AbortError")return;t.onError(o instanceof Error?o:new Error(String(o)))}})(),r}var ds=["chat_debug","presentation_debug"],gs=["gengage_chat_debug","gengage_presentation_debug"];function ps(){if(typeof window>"u")return!1;const e=new URLSearchParams(window.location.search);if(ds.some(t=>e.get(t)==="1"))return!0;try{return gs.some(t=>window.localStorage.getItem(t)==="1")}catch{return!1}}function hs(e,t,a){if(!ps())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 Tt="gengage-chat-scroll",rt=null;function Xa(e){rt=e}function us(){if(rt&&rt.isConnected)return rt;rt=null;const e=document.getElementById(Tt);return e||(hs("chat-scroll","failed to resolve scroll container (not registered)",{id:Tt}),null)}function Qa(){rt=null}var it={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ı stil hazırladım",watchStylesPreparedTitle:"Sizin için {count} farklı stil 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"},ms={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} beauty styles for you",watchStylesPreparedTitle:"Prepared {count} style 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 fs(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function bs(e){return fs(e)==="en"?ms:it}function vs(){return en()!==null}function en(){const e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition??null}var ys=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=en();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=_s(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 _s(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 xs(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=Ce(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 ws=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 ks(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 tn(e,t,a){const n=e.props??{},r=n.processing===!0,i={...it,...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 d=document.createElement("p");d.className="gengage-chat-beauty-photo-step-desc",d.textContent=(typeof n.description=="string"?n.description:void 0)??i.beautyPhotoStepDescription;const p=document.createElement("div");p.className="gengage-chat-beauty-photo-step-actions";const h=document.createElement("button");h.type="button",h.className="gengage-chat-beauty-photo-step-upload gds-btn gds-btn-primary",h.textContent=r?i.beautyPhotoStepProcessing:(typeof n.upload_label=="string"?n.upload_label:void 0)??i.beautyPhotoStepUpload,h.disabled=r,a?.onUpload&&h.addEventListener("click",()=>a.onUpload());const g=document.createElement("button");return g.type="button",g.className="gengage-chat-beauty-photo-step-skip gds-btn gds-btn-ghost",g.textContent=(typeof n.skip_label=="string"?n.skip_label:void 0)??i.beautyPhotoStepSkip,a?.onSkip&&g.addEventListener("click",()=>a.onSkip()),p.appendChild(h),p.appendChild(g),c.appendChild(l),c.appendChild(d),c.appendChild(p),o.appendChild(s),o.appendChild(c),o}function Cs(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 Ss(e,t,a,n,r){if(!a.visible)return e&&(e.hidden=!0,e.innerHTML=""),e;const i=Cs(e,t);i.hidden=!1,i.innerHTML="";const o=tn({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 an(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 nn(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 rn(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=nn(e.strengths,t.strengths??[],"gengage-chat-photo-analysis-section--strengths"),s=nn(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 d=document.createElement("p");if(d.className="gengage-chat-photo-analysis-celeb-name",d.textContent=t.celebStyle,c.appendChild(l),c.appendChild(d),t.celebStyleReason){const p=document.createElement("p");p.className="gengage-chat-photo-analysis-celeb-reason",p.textContent=t.celebStyleReason,c.appendChild(p)}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 Es(e){const t={...it,...e?.i18n??{}};return{badge:t.photoAnalysisBadge,strengths:t.photoAnalysisStrengthsLabel,focus:t.photoAnalysisFocusLabel,celebStyle:t.photoAnalysisCelebStyleLabel}}function Ps(e,t){const a=an(e.props??{})??{summary:""};return rn(Es(t),a)}function Ts(e,t,a){e.innerHTML="",a&&e.appendChild(rn(t,a))}var ym='<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>',on={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>'},As=it,Ls=1400,sn=1500,Is=/data:image\/(png|jpeg|jpg|webp);base64,[A-Za-z0-9+/=]+/gi;async function Ns(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(Is)?.[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 zs(e){try{const t=e??(typeof navigator.clipboard?.read=="function"?navigator.clipboard.read():null);return t?Ns(await t):null}catch{}return null}var Ms=class{_renderPhotoAnalysisCard(e,t){Ts(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={...As,...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 d=document.createElement("div");d.className="gengage-chat-header-title-row",d.dataset.gengagePart="chat-header-title-row";const p=document.createElement("span");if(p.className="gengage-chat-header-title",p.dataset.gengagePart="chat-header-title",p.textContent=t.headerTitle??this.i18n.headerTitle??"Product Expert",d.appendChild(p),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,d.appendChild(C)}l.appendChild(d);const h=document.createElement("a");h.className="gengage-chat-header-powered",h.dataset.gengagePart="chat-header-powered-by",h.href="https://gengage.ai/",h.target="_blank",h.rel="noopener noreferrer",h.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(h),o.appendChild(l),i.appendChild(o);const g=document.createElement("div");g.className="gengage-chat-header-right",g.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()),g.appendChild(C),this._reopenPanelBtn=C}{const C=document.createElement("button");C.type="button",C.className="gengage-chat-header-btn gds-btn gds-btn-ghost gds-icon-btn",C.dataset.gengagePart="chat-header-cart",C.setAttribute("aria-label",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"><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?.()),g.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?.()),g.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?.()),g.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 Y=document.createElement("span");Y.className="gengage-chat-header-fav-badge",Y.dataset.gengagePart="chat-header-favorites-badge",Y.setAttribute("aria-hidden","true"),Y.style.display="none",C.appendChild(Y),this._favBadgeEl=Y,C.addEventListener("click",()=>{t.onFavoritesClick?.()}),g.appendChild(C)}g.appendChild(b),r&&i.insertBefore(r,i.firstChild),i.appendChild(g);{let Y=0,pe=0,me=!1;const V=oe=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768)||oe.target.closest('button, a, input, [role="button"]'))return;const Be=oe.changedTouches?.[0];Be&&(Y=Be.clientY,pe=0,me=!0,this.root.style.transition="none")},ne=oe=>{if(!me)return;const Be=oe.changedTouches?.[0];if(!Be)return;pe=Be.clientY-Y;const bm=(t.getMobileState?.()??"full")==="full"?Math.max(0,pe):pe;oe.preventDefault(),this.root.style.transform=`translateY(${bm}px)`},he=()=>{if(!me)return;me=!1;const oe=t.getMobileState?.()??"full";let Be;pe>72?Be=oe==="full"?"half":"close":pe<-72&&oe==="half"?Be="full":Be=oe,this.root.style.transition="",Be==="close"?(this.root.style.transform="translateY(100%)",setTimeout(()=>{this.root.style.transform="",t.onMobileSnap?.("close")},280)):(this.root.style.transform="",t.onMobileSnap?.(Be)),pe=0},W=()=>{me&&(me=!1,pe=0,this.root.style.transition="",this.root.style.transform="")};i.addEventListener("touchstart",V,{passive:!0}),i.addEventListener("touchmove",ne,{passive:!1}),i.addEventListener("touchend",he,{passive:!0}),i.addEventListener("touchcancel",W,{passive:!0}),this._cleanups.push(()=>{i.removeEventListener("touchstart",V),i.removeEventListener("touchmove",ne),i.removeEventListener("touchend",he),i.removeEventListener("touchcancel",W)})}const m=document.createElement("div");m.className="gengage-chat-body",m.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 ws({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 f=()=>this._updateScrollAffordance();this._panelEl.addEventListener("scroll",f,{passive:!0}),this._cleanups.push(()=>this._panelEl.removeEventListener("scroll",f)),m.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 u=document.createElement("button");u.className="gengage-chat-panel-divider-toggle gds-btn gds-btn-ghost",u.dataset.gengagePart="chat-panel-divider-toggle",u.type="button",u.setAttribute("aria-label",this.i18n.togglePanelAriaLabel),u.setAttribute("title",this.i18n.togglePanelAriaLabel),u.textContent="»",u.addEventListener("click",()=>{if(this._ignoreNextDividerClick){this._ignoreNextDividerClick=!1;return}this.togglePanel(),this._onPanelToggle?.()});let A=null,E=null;const w=24,T=C=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768))return;const Y=C.changedTouches?.[0];Y&&(A=Y.clientX,E=Y.clientY)},N=C=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768)||A===null||E===null)return;const Y=C.changedTouches?.[0];if(!Y)return;const pe=Y.clientX-A,me=Y.clientY-E;if(A=null,E=null,Math.abs(me)<w||Math.abs(me)<Math.abs(pe))return;const V=me<0;V!==this._panelCollapsed&&(this._ignoreNextDividerClick=!0,this.setPanelCollapsed(V),this._onPanelToggle?.())};this._dividerEl.addEventListener("touchstart",T,{passive:!0}),this._dividerEl.addEventListener("touchend",N,{passive:!0}),this._cleanups.push(()=>{this._dividerEl.removeEventListener("touchstart",T),this._dividerEl.removeEventListener("touchend",N)}),this._dividerEl.appendChild(u),m.appendChild(this._dividerEl);const x=document.createElement("div");x.className="gengage-chat-conversation",x.dataset.gengagePart="chat-conversation",this._conversationEl=x,x.appendChild(i);const P=document.createElement("div");P.className="gengage-chat-offline-bar gds-evidence-card gds-evidence-card-warning",P.dataset.gengagePart="chat-offline-bar",P.setAttribute("role","status"),P.setAttribute("aria-live","polite"),P.textContent=this.i18n.offlineMessage,typeof navigator<"u"&&!navigator.onLine&&P.classList.add("gengage-chat-offline-bar--visible"),x.appendChild(P);const F=()=>P.classList.add("gengage-chat-offline-bar--visible"),ee=()=>P.classList.remove("gengage-chat-offline-bar--visible");window.addEventListener("offline",F),window.addEventListener("online",ee),this._cleanups.push(()=>{window.removeEventListener("offline",F),window.removeEventListener("online",ee)}),this._kvkkSlot=document.createElement("div"),this._kvkkSlot.className="gengage-chat-kvkk-slot",this._kvkkSlot.dataset.gengagePart="chat-kvkk-slot",x.appendChild(this._kvkkSlot),this.messagesEl=document.createElement("div"),this.messagesEl.id=Tt,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),Xa(this.messagesEl);const ie=document.createElement("button");ie.type="button",ie.className="gengage-chat-former-messages-btn gds-chip",ie.dataset.gengagePart="chat-former-messages-button",ie.textContent=this.i18n.showFormerMessagesButton,ie.setAttribute("aria-label",this.i18n.showFormerMessagesButton),ie.style.display="none",ie.addEventListener("click",()=>{this._options.presentation?.onReleasePresentationFocus?.()}),this.messagesEl.appendChild(ie),this._formerMessagesBtn=ie;const ve=()=>{this._userInteractionUntil=Date.now()+2e3};let D=!1;const v=()=>this._options.presentation,I=()=>{D||(D=!0,requestAnimationFrame(()=>{D=!1;const{scrollTop:C,scrollHeight:Y,clientHeight:pe}=this.messagesEl,me=Y-C-pe;this._userScrolledUp=me>10;const V=this._presentationPinned?me<96:me<32,ne=Date.now(),he=ne<this._programmaticScrollUntil,W=!V&&ne<this._userInteractionUntil,oe=he?!1:W;V!==this._presentationPinned&&(this._presentationPinned=V,v()?.onPinnedToBottomChange?.(V)),oe!==this._presentationUserInteracting&&(this._presentationUserInteracting=oe,v()?.onUserInteractingChange?.(oe))}))};this.messagesEl.addEventListener("scroll",I,{passive:!0}),this._cleanups.push(()=>{this.messagesEl.removeEventListener("scroll",I)});const O=C=>{ve(),C.deltaY<-6&&this._presentationFocusThreadId&&this._options.presentation?.onFormerMessagesHint?.()};this.messagesEl.addEventListener("wheel",O,{passive:!0}),this._cleanups.push(()=>this.messagesEl.removeEventListener("wheel",O));const B=C=>{ve(),this._touchStartY=C.touches[0]?.clientY??null},j=C=>{ve();const Y=C.touches[0]?.clientY,pe=this._touchStartY;typeof Y=="number"&&typeof pe=="number"&&Y-pe>10&&this._presentationFocusThreadId&&this._options.presentation?.onFormerMessagesHint?.()};this.messagesEl.addEventListener("touchstart",B,{passive:!0}),this.messagesEl.addEventListener("touchmove",j,{passive:!0}),this._cleanups.push(()=>{this.messagesEl.removeEventListener("touchstart",B),this.messagesEl.removeEventListener("touchmove",j)}),x.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 Z=document.createElement("div");Z.className="gengage-chat-pills-scroll",Z.dataset.gengagePart="chat-suggestion-pills-scroll",this._pillsEl.appendChild(Z);const q=document.createElement("button");q.className="gengage-chat-pills-arrow gds-btn gds-btn-ghost",q.dataset.gengagePart="chat-suggestion-pills-more",q.type="button",q.setAttribute("aria-label",this.i18n.moreSuggestionsAriaLabel),q.textContent="›",q.addEventListener("click",()=>{Z.scrollBy({left:150,behavior:"smooth"})}),this._pillsEl.appendChild(q);let y=!1;const L=()=>{y||(y=!0,requestAnimationFrame(()=>{y=!1;const C=Z.scrollLeft+Z.clientWidth>=Z.scrollWidth-4;q.style.display=C?"none":""}))};Z.addEventListener("scroll",L,{passive:!0}),this._cleanups.push(()=>{Z.removeEventListener("scroll",L)}),x.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",x.appendChild(this._inputChipsEl);const S=document.createElement("div");S.className="gengage-chat-input-area",S.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 Y=C.clipboardData;if(!Y)return;let pe=null;const me=Y.files?.[0];if(me&&me.type.startsWith("image/"))pe=me;else if(Y.items?.length)for(let V=0;V<Y.items.length;V++){const ne=Y.items[V];if(ne?.kind==="file"&&ne.type.startsWith("image/")){const he=ne.getAsFile();if(he){pe=he;break}}}pe&&(C.preventDefault(),this._routeAttachmentFile(pe))}),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 z=document.createElement("div");z.className="gengage-chat-attach-wrap",z.dataset.gengagePart="chat-attach-wrap",this._attachWrapEl=z;const M=document.createElement("button");this._attachBtn=M,M.className="gengage-chat-attach-btn gds-btn gds-btn-ghost",M.dataset.gengagePart="chat-attach-button",M.type="button",M.setAttribute("aria-label",this.i18n.attachImageButton),M.setAttribute("aria-haspopup","menu"),M.setAttribute("aria-expanded","false"),M.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>',M.addEventListener("click",C=>{C.stopPropagation(),this._toggleAttachMenu()});const R=document.createElement("div");this._attachMenuEl=R,R.className="gengage-chat-attach-menu gds-menu",R.dataset.gengagePart="chat-attach-menu",R.setAttribute("role","menu"),R.setAttribute("hidden","");const $=document.createElement("button");$.type="button",$.className="gengage-chat-attach-menu-item gds-btn gds-btn-ghost",$.dataset.gengagePart="chat-attach-menu-select-photo",$.setAttribute("role","menuitem"),$.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>`,$.addEventListener("click",C=>{C.stopPropagation(),this._closeAttachMenu(),this._fileInput.click()});const ae=document.createElement("div");ae.className="gengage-chat-attach-menu-sep",ae.dataset.gengagePart="chat-attach-menu-separator",ae.setAttribute("aria-hidden","true");const te=document.createElement("button");te.type="button",te.className="gengage-chat-attach-menu-item gds-btn gds-btn-ghost",te.dataset.gengagePart="chat-attach-menu-paste",te.setAttribute("role","menuitem"),te.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>`,te.addEventListener("click",C=>{C.stopPropagation();const Y=typeof navigator.clipboard?.read=="function"?navigator.clipboard.read():void 0;this._pasteImageFromClipboardMenu(Y)}),R.appendChild($),R.appendChild(ae),R.appendChild(te),z.appendChild(M),z.appendChild(R),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 U=document.createElement("img");U.className="gengage-chat-attachment-preview-thumb",U.dataset.gengagePart="chat-attachment-preview-thumb",U.alt="",this._previewName=document.createElement("span"),this._previewName.className="gengage-chat-attachment-name",this._previewName.dataset.gengagePart="chat-attachment-preview-name";const ce=document.createElement("button");ce.className="gengage-chat-attachment-remove gds-btn gds-btn-ghost",ce.dataset.gengagePart="chat-attachment-preview-remove",ce.type="button",ce.setAttribute("aria-label",this.i18n.removeAttachmentButton),ce.textContent="×",ce.addEventListener("click",()=>this.clearAttachment()),this._previewStrip.appendChild(U),this._previewStrip.appendChild(this._previewName),this._previewStrip.appendChild(ce),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()}),S.addEventListener("dragover",C=>{C.preventDefault(),S.classList.add("gengage-chat-input-area--dragover")}),S.addEventListener("dragleave",()=>{S.classList.remove("gengage-chat-input-area--dragover")}),S.addEventListener("drop",C=>{C.preventDefault(),S.classList.remove("gengage-chat-input-area--dragover");const Y=C.dataTransfer?.files[0];Y&&this._routeAttachmentFile(Y)});const X=document.createElement("div");X.className="gengage-chat-input-pill gds-input-shell",X.dataset.gengagePart="chat-input-shell",X.appendChild(z),X.appendChild(this.inputEl),this._voiceEnabled&&vs()&&(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()),X.appendChild(this._micBtn),this._voiceInput=new ys({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,Y)=>{this._micBtn?.classList.remove("gengage-chat-mic-btn--active")}},{lang:this._voiceLang})),X.appendChild(this.sendBtn),S.appendChild(this._previewStrip),S.appendChild(this._fileInput),S.appendChild(X),x.appendChild(S),m.appendChild(x),this._comparisonDockSlotEl=document.createElement("div"),this._comparisonDockSlotEl.className="gengage-chat-comparison-dock-slot",this._comparisonDockSlotEl.dataset.gengagePart="comparison-dock-slot",m.appendChild(this._comparisonDockSlotEl),this.root.appendChild(m),this._setupHorizontalSwipe(x);const $e=document.createElement("div");$e.className="gengage-chat-footer",$e.dataset.gengagePart="chat-footer",$e.textContent=this.i18n.poweredBy,this.root.appendChild($e);const Pt=C=>{C.key==="Escape"&&t.onClose()};this.root.addEventListener("keydown",Pt),this._cleanups.push(()=>this.root.removeEventListener("keydown",Pt)),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=Ce(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"),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="${_e(e)}"]`)?.remove(),this._presentationFocusThreadId&&this._applyPresentationCollapsed()}showTypingIndicator(e){this.removeTypingIndicator();const t=this._thinkingSteps.length>0?this._thinkingSteps.slice(-3):e?[e]:this.i18n.loadingSequenceGeneric,{root:a,binding:n}=this._createLoadingSequence("chat",t,"chat-typing-indicator","gengage-chat-typing");a.dataset.typing="true",this._typingLoadingBinding=n,this.messagesEl.appendChild(a),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()}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=on[n.icon]??'<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>',s=document.createElement("span");s.className="gengage-chat-pill-icon",s.innerHTML=o,r.appendChild(s)}if(n.image&&Re(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=xs({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=Ss(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 zs(e);if(t){this._routeAttachmentFile(t),this._closeAttachMenu();return}Te("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))}_clearPanelAiZoneState(){this._destroyLoadingBinding(this._panelAiZoneLoadingBinding),this._panelAiZoneLoadingBinding=null,this._panelAiZoneEl.innerHTML="",this._panelAiZoneEl.setAttribute("hidden","")}_resetPanelAiZoneElement(){this._panelAiZoneEl=document.createElement("div"),this._panelAiZoneEl.className="gengage-chat-panel-ai-zone",this._panelAiZoneEl.setAttribute("hidden","")}_emitHostShellSync(){this._onHostShellSync?.()}_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 d=document.createElement("div");d.className="gengage-chat-comparison-recommended-info";for(let x=0;x<2;x++){const P=document.createElement("div");P.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-rec-title",x===1&&P.classList.add("gengage-chat-comparison-skeleton-rec-title--short"),d.appendChild(P)}const p=document.createElement("div");p.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-rec-price",d.appendChild(p),c.appendChild(l),c.appendChild(d),o.appendChild(c);const h=document.createElement("div");h.className="gengage-chat-comparison-highlights";const g=document.createElement("div");g.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-hl-label",h.appendChild(g);const b=document.createElement("ul");b.className="gengage-chat-comparison-skeleton-hl-list";for(let x=0;x<3;x++){const P=document.createElement("li"),F=document.createElement("div");F.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-hl-line",x===1&&F.classList.add("gengage-chat-comparison-skeleton-hl-line--medium"),x===2&&F.classList.add("gengage-chat-comparison-skeleton-hl-line--short"),P.appendChild(F),b.appendChild(P)}h.appendChild(b),o.appendChild(h),i.appendChild(o);const m=document.createElement("div");m.className="gengage-chat-comparison-key-differences";const f=document.createElement("div");f.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-kd-heading",m.appendChild(f);const u=document.createElement("div");u.className="gengage-chat-comparison-key-differences-content";for(let x=0;x<4;x++){const P=document.createElement("div");P.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-kd-line",u.appendChild(P)}m.appendChild(u),i.appendChild(m);const A=document.createElement("div");A.className="gengage-chat-comparison-special gengage-chat-comparison-special--skeleton";const E=document.createElement("div");E.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-special-line",A.appendChild(E),i.appendChild(A);const w=document.createElement("div");w.className="gengage-chat-comparison-skeleton-table-wrap";const T=document.createElement("div");T.className="gengage-chat-comparison-skeleton-table-head";const N=document.createElement("div");N.className="gengage-chat-comparison-skeleton-table-corner",T.appendChild(N);for(let x=0;x<3;x++){const P=document.createElement("div");P.className="gengage-chat-comparison-skeleton-table-col";const F=document.createElement("div");F.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-img";const ee=document.createElement("div");ee.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-name";const ie=document.createElement("div");ie.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-price",P.appendChild(F),P.appendChild(ee),P.appendChild(ie),T.appendChild(P)}w.appendChild(T);for(let x=0;x<3;x++){const P=document.createElement("div");P.className="gengage-chat-comparison-skeleton-table-row";const F=document.createElement("div");F.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-label",P.appendChild(F);for(let ee=0;ee<3;ee++){const ie=document.createElement("div");ie.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-cell",P.appendChild(ie)}w.appendChild(P)}i.appendChild(w),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._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,e?this._panelEl.classList.add("gengage-chat-panel--collapsed"):this._panelEl.classList.remove("gengage-chat-panel--collapsed");const t=this._dividerEl.querySelector(".gengage-chat-panel-divider-toggle");t&&(t.textContent=e?"«":"»"),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)},Ls))}_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="${_e(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=Ce(t)),this._scrollToBottom(!1)}markFirstBotMessage(e){this._firstBotMessageIds.add(e);const t=this.messagesEl.querySelector(`[data-message-id="${_e(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="${_e(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="${_e(e)}"]`);let n=null,r=null;for(let s=0;s<a.length;s++){const c=a[s];if(c instanceof HTMLElement&&(r||(r=c),!c.classList.contains("gengage-chat-bubble--presentation-collapsed")&&!c.classList.contains("gengage-chat-bubble--hidden")&&c.offsetHeight!==0&&!(c.classList.contains("gengage-chat-bubble--assistant")&&(c.textContent?.trim().length??0)===0))){n=c;break}}if(n||(n=r),!n)return!1;const i=Date.now();this._programmaticScrollUntil=i+sn,this._scrollLockedUntil=Math.max(this._scrollLockedUntil,i+sn),this._userScrolledUp=!0;const o=()=>{this._scrollMessagesTo(Math.max(n.offsetTop-20,0),t)};return o(),requestAnimationFrame(o),!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=on[t.icon]??'<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>',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 d=getComputedStyle(l);return l.hidden||l.getAttribute("aria-hidden")==="true"||d.display==="none"||d.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(){Xa(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}},cn=["beauty_consulting","watch_expert","booking"],Bs=["shopping",...cn];function Rs(e){return typeof e=="string"&&Bs.includes(e)?e:null}function na(e){return e==null||typeof e!="object"||Array.isArray(e)?null:e}function Os(...e){for(const t of e)if(typeof t=="string"){const a=t.trim();if(a.length>0)return a}}function Ds(e){const t=na(e);if(!t)return null;const a=Os(t.assistant_mode,t.assistantMode);return!a||!cn.includes(a)?null:a}var Hs=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){De("mode","redirect metadata received",e);const t=Ds(e);return t?(this.switchMode(t),!0):!1}switchMode(e){const t=this._mode;this._mode=e,De("mode","assistant mode switched",{from:t,to:e})}updateFromContext(e){const t=e.assistant_mode;if(typeof t=="string"&&t){const a=Rs(t);a?this._mode=a:De("mode","ignoring unrecognised assistant_mode from context",t)}else t===null&&(this._mode="shopping");this._uiHints=na(e.ui_hints)??null}reset(){const e=this._mode!=="shopping";return this._mode="shopping",this._uiHints=null,e}resolveAttachmentActionType(){return this._mode==="beauty_consulting"?"user_message":"findSimilar"}shouldCondenseThinking(){return this._mode!=="shopping"}};function Fs(){return{streamIncludedBeautyPhotoStep:!1,pendingPhotoStepSkip:!1}}function $s(e,t,a,n,r){if(e==="PhotoAnalysisCard"){const i=an(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):(De("beauty","PhotoAnalysisCard parse failed, falling through to generic renderer",t),!1)}if(e==="BeautyPhotoStep"){a.streamIncludedBeautyPhotoStep=!0;const i=ks(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 Us(e){return e.renderHint==="photo_analysis"}function js(e,t){e.streamIncludedBeautyPhotoStep||t.drawer?.setBeautyPhotoStepCard({visible:!1}),e.pendingPhotoStepSkip&&(e.pendingPhotoStepSkip=!1,t.sendSkipMessage())}function Zs(e,t){e.pendingPhotoStepSkip&&(e.pendingPhotoStepSkip=!1,t.sendSkipMessage())}function ra(e){return Number.isFinite(e)?Math.max(0,Math.min(5,e)):0}function ln(e){return Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function dn(e){const t=ra(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 Ae(e){e.addEventListener("error",()=>{e.style.display="none"},{once:!0})}var qs={currencyCode:"TRY",currencySymbol:"TL",currencyPosition:"suffix",thousandsSeparator:".",decimalSeparator:",",alwaysShowDecimals:!1};function J(e,t){const a=Number(e);if(!Number.isFinite(a)||a<0)return e;const n={...qs,...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 d;return c!==void 0?d=`${l}${n.decimalSeparator}${c}`:d=l,n.currencySymbol?n.currencyPosition==="prefix"?`${n.currencySymbol}${d}`:`${d} ${n.currencySymbol}`:d}var Vs={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 Gs(e,t,a){return t?.[e]??Vs[e]??e.replace(/_/g," ").replace(/^./u,n=>Ws(n,a))}function Ws(e,t){try{return e.toLocaleUpperCase(ft(t))}catch{return e.toLocaleUpperCase("tr")}}function gn(e){if(typeof e!="string")return!1;const t=Number(e);return Number.isFinite(t)&&t>0}function Ks(e){const t=typeof e=="number"?e:typeof e=="string"?Number(e):NaN;return Number.isFinite(t)&&t>0}function Ys(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 Js(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 d=document.createElement("div");d.className="gengage-chat-comparison-recommended-label",d.textContent=s?.recommendedChoiceLabel??"Recommended Choice",l.appendChild(d);const p=document.createElement("div");p.className="gengage-chat-comparison-recommended-body",p.classList.add("gds-clickable"),p.tabIndex=0,p.setAttribute("role","button"),p.setAttribute("aria-label",t.name);const h=document.createElement("div");if(h.className="gengage-chat-comparison-recommended-media",t.imageUrl&&Re(t.imageUrl)){const u=document.createElement("img");u.src=t.imageUrl,u.alt=t.name,u.loading="lazy",u.addEventListener("error",()=>{u.style.display="none"},{once:!0}),h.appendChild(u)}else{const u=document.createElement("div");u.className="gengage-chat-comparison-recommended-placeholder",u.setAttribute("aria-hidden","true"),h.appendChild(u)}p.appendChild(h);const g=document.createElement("div");g.className="gengage-chat-comparison-recommended-info";const b=document.createElement("div");b.className="gengage-chat-comparison-recommended-title",b.textContent=t.name,g.appendChild(b);const m=document.createElement("div");if(m.className="gengage-chat-comparison-recommended-meta",Ks(t.rating)&&m.appendChild(Ys(t.rating)),gn(t.price)){const u=document.createElement("div");u.className="gengage-chat-comparison-recommended-price",u.textContent=J(t.price,e.pricing),m.appendChild(u)}if(m.childElementCount>0&&g.appendChild(m),e.recommendedText){const u=document.createElement("p");u.className="gengage-chat-comparison-recommended-text",u.innerHTML=Ce(e.recommendedText),g.appendChild(u)}p.appendChild(g);const f=()=>{o({sku:t.sku,name:t.name})};if(p.addEventListener("click",f),p.addEventListener("keydown",u=>{u.key!=="Enter"&&u.key!==" "||(u.preventDefault(),f())}),l.appendChild(p),r.length>0){const u=document.createElement("div");u.className="gengage-chat-comparison-highlights",u.dataset.gengagePart="comparison-highlights";const A=document.createElement("div");A.className="gengage-chat-comparison-highlights-label",A.textContent=s?.highlightsLabel??"Key Highlights",u.appendChild(A);const E=document.createElement("ul");for(const w of r){const T=document.createElement("li");T.textContent=w,E.appendChild(T)}u.appendChild(E),l.appendChild(u)}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 d=document.createElement("summary");d.className="gengage-chat-comparison-key-differences-summary";const p=document.createElement("span");p.className="gengage-chat-comparison-key-differences-summary-label",p.textContent=s?.keyDifferencesLabel??"Key Differences";const h=document.createElement("span");h.className="gengage-chat-comparison-key-differences-summary-meta",h.textContent=s?.viewMoreLabel??"Show More",d.appendChild(p),d.appendChild(h),l.appendChild(d);const g=document.createElement("div");g.className="gengage-chat-comparison-key-differences-content",g.innerHTML=Ce(Xs(e.keyDifferencesHtml)),l.appendChild(g),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 d=document.createElement("summary");d.textContent=s?.specialCasesLabel??"For Special Cases",l.appendChild(d);const p=document.createElement("ul");for(const h of i)Qs(p,h);p.childElementCount>0&&l.appendChild(p),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 d=document.createElement("thead"),p=document.createElement("tr"),h=document.createElement("th");p.appendChild(h);for(const m of a){const f=document.createElement("th");m.sku===t?.sku&&(f.className="gengage-chat-comparison-selected gds-comparison-table-winner-cell");const u=document.createElement("div");u.className="gengage-chat-comparison-table-header-cell gengage-chat-comparison-table-header-cell--clickable gds-clickable",u.tabIndex=0,u.setAttribute("role","button"),u.setAttribute("aria-label",m.name),u.title=m.name;const A=()=>{o({sku:m.sku,name:m.name})};if(u.addEventListener("click",A),u.addEventListener("keydown",w=>{w.key!=="Enter"&&w.key!==" "||(w.preventDefault(),A())}),m.imageUrl&&Re(m.imageUrl)){const w=document.createElement("img");w.src=m.imageUrl,w.alt=m.name,w.loading="lazy",w.addEventListener("error",()=>{w.style.display="none"},{once:!0}),u.appendChild(w)}else{const w=document.createElement("div");w.className="gengage-chat-comparison-table-header-img-placeholder",w.setAttribute("aria-hidden","true"),u.appendChild(w)}const E=document.createElement("div");if(E.className="gengage-chat-comparison-table-product-name",E.textContent=m.name,u.appendChild(E),gn(m.price)){const w=document.createElement("div");w.className="gengage-chat-comparison-table-price",w.textContent=J(m.price,e.pricing),u.appendChild(w)}f.appendChild(u),p.appendChild(f)}d.appendChild(p),l.appendChild(d);const g=document.createElement("tbody");for(const m of n){const f=document.createElement("tr"),u=document.createElement("td");u.className="gengage-chat-comparison-label",u.textContent=Gs(m.label,s?.criteriaLabels,e.locale),f.appendChild(u);for(let A=0;A<m.values.length;A++){const E=document.createElement("td");a[A]?.sku===t?.sku&&(E.className="gengage-chat-comparison-selected gds-comparison-table-winner-cell");const w=m.values[A]??"";pn(w)?E.innerHTML=Ce(w):E.textContent=w,f.appendChild(E)}g.appendChild(f)}l.appendChild(g);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 d=c.querySelectorAll('button, [href], input, [tabindex]:not([tabindex="-1"])');if(d.length===0)return;const p=d[0],h=d[d.length-1];l.shiftKey&&document.activeElement===p?(l.preventDefault(),h.focus()):!l.shiftKey&&document.activeElement===h&&(l.preventDefault(),p.focus())}),c}function Xs(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 Qs(e,t){const a=Ce(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=Ce(o.innerHTML),e.appendChild(s)}return}const i=document.createElement("li");pn(t)?i.innerHTML=a:i.textContent=t,e.appendChild(i)}function pn(e){return/<\/?[a-z][\s\S]*>/i.test(e)}function yt(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 ia="General",hn=220,ec=6;function tc(e){if(typeof e!="string")return[ia];const t=e.split(/[,;|/]+/).map(a=>a.trim().replace(/\s+/g," ")).filter(a=>a.length>0);return t.length===0?[ia]:Array.from(new Set(t.map(a=>a.toLocaleLowerCase()))).map(a=>t.find(n=>n.toLocaleLowerCase()===a)??ia)}function ac(e){return e==="positive"||e==="negative"||e==="neutral"?e:"neutral"}function nc(e){if(typeof e!="string")return"";const t=e.trim().replace(/\s+/g," ");return t.length<=hn?t:`${t.slice(0,hn-3).trimEnd()}...`}function rc(e){return e.positive>e.negative?"positive":e.negative>e.positive?"negative":"neutral"}function ic(e){return yt(e==="positive"?["M7 17 17 7","M7 7h10v10"]:e==="negative"?["M7 7 17 17","M17 7v10H7"]:["M5 12h14"],14)}function oc(e,t="1 customer mentions",a="customers mention"){return e===1?t:`${e} ${a}`}function sc(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 m=document.createElement("div");return m.className="gengage-chat-review-empty",m.textContent=t?.emptyReviewsMessage??"No review summary found.",a.appendChild(m),a}const r=n.filter(m=>m!==null&&typeof m=="object"),i=new Map;for(const m of r){const f=ac(m.review_class),u=nc(m.review_text),A=tc(m.review_tag);for(const E of A){const w=E.toLocaleLowerCase();let T=i.get(w);if(T||(T={key:w,label:E,mentions:0,positive:0,negative:0,neutral:0,snippets:[]},i.set(w,T)),T.mentions+=1,f==="positive"?T.positive+=1:f==="negative"?T.negative+=1:T.neutral+=1,u.length>0&&T.snippets.length<ec&&!T.snippets.some(N=>N.text===u)){const N={text:u,tone:f};m.review_rating!==void 0&&String(m.review_rating).length>0&&(N.rating=m.review_rating),T.snippets.push(N)}}}const o=Array.from(i.values()).sort((m,f)=>f.mentions!==m.mentions?f.mentions-m.mentions:m.label.localeCompare(f.label));if(o.length===0){const m=document.createElement("div");return m.className="gengage-chat-review-empty",m.textContent=t?.emptyReviewsMessage??"No review summary found.",a.appendChild(m),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 d=o[0]?.key??null;const p=document.createElement("div");p.className="gengage-chat-review-subjects gds-toolbar gds-toolbar-compact";const h=document.createElement("section");h.className="gengage-chat-review-detail gds-evidence-card";const g=()=>{for(;h.firstChild;)h.removeChild(h.firstChild);if(!d)return;const m=o.find(E=>E.key===d);if(!m)return;const f=document.createElement("div");f.className="gengage-chat-review-detail-meta";const u=document.createElement("span");if(u.className="gengage-chat-review-detail-mentions",u.textContent=`${oc(m.mentions,t?.reviewCustomersMentionSingular,t?.reviewCustomersMentionPlural)} "${m.label}"`,f.appendChild(u),m.positive>0){const E=document.createElement("span");E.className="gengage-chat-review-detail-positive",E.textContent=`${m.positive} ${s}`,f.appendChild(E)}if(m.negative>0){const E=document.createElement("span");E.className="gengage-chat-review-detail-negative",E.textContent=`${m.negative} ${c}`,f.appendChild(E)}h.appendChild(f);const A=document.createElement("div");A.className="gengage-chat-review-snippets";for(const E of m.snippets){const w=document.createElement("article");w.className="gengage-chat-review-snippet",w.dataset.tone=E.tone;const T=document.createElement("div");if(T.className="gengage-chat-review-snippet-text",T.textContent=`"${E.text}"`,w.appendChild(T),E.rating!==void 0&&String(E.rating).length>0){const N=document.createElement("div");N.className="gengage-chat-review-snippet-rating",N.textContent=`★ ${String(E.rating)}`,w.appendChild(N)}A.appendChild(w)}h.appendChild(A)},b=()=>{for(const m of p.querySelectorAll(".gengage-chat-review-subject")){const f=m.dataset.subjectKey===d;m.classList.toggle("gengage-chat-review-subject--active",f),m.classList.toggle("gds-chip-active",f),m.setAttribute("aria-pressed",String(f))}};for(const m of o){const f=rc(m),u=document.createElement("button");u.type="button",u.className="gengage-chat-review-subject gds-chip",u.dataset.subjectKey=m.key,u.dataset.tone=f;const A=document.createElement("span");A.className="gengage-chat-review-subject-icon",A.appendChild(ic(f)),u.appendChild(A);const E=document.createElement("span");E.className="gengage-chat-review-subject-label",E.textContent=m.label,u.appendChild(E);const w=document.createElement("span");w.className="gengage-chat-review-subject-count",w.textContent=`(${m.mentions})`,u.appendChild(w),u.addEventListener("click",()=>{d=m.key,b(),g()}),p.appendChild(u)}return a.appendChild(p),b(),g(),a.appendChild(h),a}function cc(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 ot(e,t){if(e.productPriceUi?.showCampaignReason===!0)return cc(t)}function _t(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 At(e){const t=document.createElement("div");return t.className="gengage-chat-campaign-reason",t.textContent=e,t}function Lt(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(Re(i))return i}}const a=e.productPriceUi?.campaignBadgeLogoUrl;if(typeof a=="string"&&a.trim()){const n=a.trim();if(Re(n))return n}}function It(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,Ae(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 lc(){try{return globalThis.GENGAGE_TOPPICKS_MOBILE_LAYOUT==="uniform"}catch{return!1}}function un(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 dc={winner:"roleWinner",best_value:"roleBestValue",best_alternative:"roleBestAlternative"};function mn(e,t){if(!e||!t)return null;const a=dc[e];return a?t[a]??e:e}function gc(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 pc(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&&Re(s)){const l=document.createElement("img");l.className="gengage-chat-ai-toppick-img",l.dataset.gengagePart="ai-top-pick-image",fe(l,"src",s),l.loading="lazy",l.alt=t,Ae(l),i.appendChild(l)}const c=un(e);if(c&&!r?.skipOverlayActions){const l=document.createElement("div");if(l.className="gengage-chat-product-card-img-actions",n.onFavoriteToggle){const g=document.createElement("button");g.className="gengage-chat-favorite-btn",g.type="button",g.dataset.gengageFavoriteSku=c,g.setAttribute("aria-label",n.i18n?.addToFavoritesLabel??"Add to favorites");const b=n.favoritedSkus?.has(c)??!1;b&&g.classList.add("gengage-chat-favorite-btn--active"),g.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>`,g.addEventListener("click",m=>{m.stopPropagation(),g.classList.toggle("gengage-chat-favorite-btn--active"),g.querySelector("svg")?.setAttribute("fill",g.classList.contains("gengage-chat-favorite-btn--active")?"currentColor":"none"),n.onFavoriteToggle?.(c,o)}),l.appendChild(g)}const d=n.i18n?.findSimilarLabel??"Find Similar",p=document.createElement("button");p.className="gengage-chat-find-similar-pill",p.type="button",p.setAttribute("aria-label",d),p.dataset.tooltip=d,p.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 h=document.createElement("span");h.className="gengage-chat-find-similar-pill-text",h.textContent=d,p.appendChild(h),p.addEventListener("click",g=>{g.stopPropagation(),n.onAction({title:d,type:"findSimilar",payload:{sku:c,...s?{image_url:s}:{}}})}),l.appendChild(p),i.appendChild(l)}a.appendChild(i)}function hc(e,t,a){const n=e.price,r=e.originalPrice;if(!n)return;const i=ot(a,e),o=_t(a,e),s=!!(r&&r!==n),c=!!(i&&s),l=Lt(a,e),d=document.createElement("div");if(d.className="gengage-chat-ai-toppick-price",d.dataset.gengagePart="ai-top-pick-price",c){const p=It({reasonText:i,salePriceFormatted:J(n,a.pricing),...l!==void 0?{logoUrl:l}:{}});if(s&&o==="inline"){d.classList.add("gengage-chat-ai-toppick-price--inline"),d.appendChild(p);const h=document.createElement("span");h.className="gengage-chat-ai-toppick-price-sep",h.setAttribute("aria-hidden","true");const g=document.createElement("span");g.className="gengage-chat-ai-toppick-original-price",g.textContent=J(r,a.pricing),d.appendChild(h),d.appendChild(g)}else{const h=document.createElement("span");h.className="gengage-chat-ai-toppick-original-price",h.textContent=J(r,a.pricing),d.appendChild(h),d.appendChild(document.createTextNode(" ")),d.appendChild(p)}t.appendChild(d);return}if(s&&o==="inline"){d.classList.add("gengage-chat-ai-toppick-price--inline");const p=document.createElement("span");p.className="gengage-chat-ai-toppick-price-current",p.textContent=J(n,a.pricing);const h=document.createElement("span");h.className="gengage-chat-ai-toppick-price-sep",h.setAttribute("aria-hidden","true");const g=document.createElement("span");g.className="gengage-chat-ai-toppick-original-price",g.textContent=J(r,a.pricing),d.appendChild(p),d.appendChild(h),d.appendChild(g)}else if(s){const p=document.createElement("span");p.className="gengage-chat-ai-toppick-original-price",p.textContent=J(r,a.pricing),d.appendChild(p),d.appendChild(document.createTextNode(" "));const h=document.createElement("span");h.className="gengage-chat-ai-toppick-price-current",h.textContent=J(n,a.pricing),d.appendChild(h)}else{const p=document.createElement("span");p.className="gengage-chat-ai-toppick-price-current",p.textContent=J(n,a.pricing),d.appendChild(p)}if(i){const p=document.createElement("div");p.className="gengage-chat-ai-toppick-price-stack",p.appendChild(At(i)),p.appendChild(d),t.appendChild(p)}else t.appendChild(d)}function uc(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 fn(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=un(e),c=o.url??"",l=o.cartCode,d=o.inStock,p=!!(s&&l&&d!==!1),h=e.action;s&&t.onProductClick?(r.classList.add("gds-clickable"),r.addEventListener("click",x=>{if(x.target.closest(".gengage-chat-ai-toppick-cta")||x.target.closest(".gengage-chat-favorite-btn")||x.target.closest(".gengage-chat-find-similar-pill"))return;const P=o.name;t.onProductClick?.({sku:s,url:c,...P?{name:P}:{}})})):h&&(r.classList.add("gds-clickable"),r.addEventListener("click",x=>{x.target.closest(".gengage-chat-ai-toppick-cta")||x.target.closest(".gengage-chat-favorite-btn")||x.target.closest(".gengage-chat-find-similar-pill")||t.onAction(h)}));const g=o.name||"Product image",b=!a&&t.isMobile===!0&&!i,m=a?mn(e.role,t.i18n)??t.i18n?.roleWinner??"TOP MATCH":mn(e.role,t.i18n);if(m&&!b){const x=document.createElement("span");x.className="gengage-chat-ai-toppick-badge gds-badge",x.dataset.gengagePart="ai-top-pick-role-badge",x.textContent=m,r.appendChild(x)}const f=document.createElement("div");f.className="gengage-chat-ai-toppick-top-row",f.dataset.gengagePart="ai-top-pick-top-row",pc(e,g,f,t,{skipOverlayActions:b});const u=document.createElement("div");if(u.className="gengage-chat-ai-toppick-body",u.dataset.gengagePart="ai-top-pick-body",m&&b){const x=document.createElement("div");x.className="gengage-chat-ai-toppick-role-line",x.dataset.gengagePart="ai-top-pick-role-line",x.textContent=m,u.appendChild(x)}const A=o.name;if(A){const x=document.createElement("div");x.className="gengage-chat-ai-toppick-name",x.dataset.gengagePart="ai-top-pick-name",x.textContent=A,u.appendChild(x)}const E=gc(o);E&&u.appendChild(E),hc(o,u,t),e.labels&&e.labels.length>0&&u.appendChild(fc(e.labels)),f.appendChild(u),r.appendChild(f);const w=document.createElement("div");if(w.className="gengage-chat-ai-toppick-detail",w.dataset.gengagePart="ai-top-pick-detail",a)uc(e,w,t);else{const x=typeof e.reason=="string"?e.reason.trim():"";if(x){const P=document.createElement("p");P.className="gengage-chat-ai-toppick-snippet",P.dataset.gengagePart="ai-top-pick-snippet",P.textContent=x,w.appendChild(P)}}w.childNodes.length>0&&r.appendChild(w);const T=!!(s&&t.topPicksLoadingSku===s),N=(p||h)&&!b;if(T||p||h){const x=document.createElement("div");if(x.className="gengage-chat-ai-toppick-spinner",x.dataset.gengagePart="ai-top-pick-spinner",x.style.display=T?"":"none",r.appendChild(x),N){const P=document.createElement("button");P.className="gengage-chat-ai-toppick-cta gds-btn gds-btn-primary",P.dataset.gengagePart="ai-top-pick-cta",P.type="button",P.textContent=p?t.i18n?.addToCartButton??"Add to Cart":t.i18n?.viewDetails??"View Details",P.addEventListener("click",F=>{if(F.stopPropagation(),p){t.onAction({title:t.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:s,cartCode:l,quantity:1}});return}if(h){if(h.type==="findSimilar"&&s&&t.onProductClick){const ee=o.name;t.onProductClick({sku:s,url:c,...ee?{name:ee}:{}});return}t.onAction(h)}}),r.appendChild(P)}}return r}function mc(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&&lc(),o=n[0];if(r.appendChild(fn(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],d=l.role==="winner";s.appendChild(fn(l,t,d,{uniformMobileLayout:i}))}r.appendChild(s)}return a.appendChild(r),a}function fc(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 bc(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(yt(["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 d=document.createElement("div");if(d.className="gengage-chat-grounding-review-title",d.dataset.gengagePart="grounding-review-title",d.textContent=r??t.i18n?.customerReviewsTitle??"Customer Reviews",l.appendChild(d),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 p=document.createElement("span");p.className="gengage-chat-grounding-review-cta",p.dataset.gengagePart="grounding-review-cta";const h=document.createElement("span");h.textContent=s,p.appendChild(h);const g=document.createElement("span");return g.className="gengage-chat-grounding-review-cta-icon",g.appendChild(yt(["M5 12h14","M15 8l4 4-4 4"],14)),p.appendChild(g),a.appendChild(p),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 vc(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};if(typeof a?.sku=="string"&&a.sku.trim()?r.sku=a.sku:delete r.sku,typeof a?.image_url=="string"&&a.image_url.trim()?r.image_url=a.image_url:delete r.image_url,typeof a?.input=="string"&&a.input.trim()?r.input=a.input:delete r.input,Array.isArray(a?.group_skus)){const i=a.group_skus.filter(o=>typeof o=="string"&&o.length>0);i.length>0?r.group_skus=i:delete r.group_skus}else delete r.group_skus;return{title:e.action.title,type:t,payload:r}}function yc(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(vc(s))),s.image&&Re(s.image)){const h=document.createElement("img");h.className="gengage-chat-grouping-card-img",h.dataset.gengagePart="ai-grouping-card-image",h.draggable=!1,h.src=s.image,h.alt=s.name,h.width=64,h.height=64,c.appendChild(h)}const l=document.createElement("div");l.className="gengage-chat-grouping-card-body",l.dataset.gengagePart="ai-grouping-card-body";const d=document.createElement("span");if(d.className="gengage-chat-grouping-card-name",d.dataset.gengagePart="ai-grouping-card-name",d.textContent=s.name,l.appendChild(d),s.labels&&s.labels.length>0){const h=document.createElement("div");h.className="gengage-chat-grouping-card-labels",h.dataset.gengagePart="ai-grouping-card-labels";for(const g of s.labels.slice(0,2)){const b=document.createElement("span");b.className="gengage-chat-grouping-card-label gds-chip",b.textContent=g,h.appendChild(b)}l.appendChild(h)}c.appendChild(l);const p=document.createElement("span");p.className="gengage-chat-grouping-card-arrow",p.textContent="↳",c.insertBefore(p,c.firstChild),o.appendChild(c)}return a.appendChild(o),a}function _c(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&&Re(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 bn(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 p=document.createElement("div");p.className="gengage-chat-comparison-floating-warning",p.setAttribute("role","status"),p.setAttribute("aria-live","polite"),p.textContent=r,c.appendChild(p)}o.appendChild(c),i.appendChild(o);const d=document.createElement("button");if(d.className="gengage-chat-comparison-floating-action gds-btn gds-btn-primary",d.type="button",d.textContent=n,d.disabled=!a,a||d.classList.add("gengage-chat-comparison-floating-action--disabled"),d.addEventListener("click",()=>{a&&t.onAction({title:n,type:"getComparisonTable",payload:{sku_list:[...e],gengage_analytics_source:"floating_compare_dock"}})}),i.appendChild(d),t.onToggleComparisonSku){const p=document.createElement("button");p.className="gengage-chat-comparison-floating-close gds-btn gds-btn-ghost gds-icon-btn",p.dataset.gengagePart="comparison-dock-close",p.type="button",p.setAttribute("aria-label",t.i18n?.closeAriaLabel??"Close"),p.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>',p.addEventListener("click",h=>{h.preventDefault(),h.stopPropagation(),t.onToggleComparisonSku?.("")}),i.appendChild(p)}return i}function xc(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}function wc(e,t){const a=e.props?.groups??[],n=e.props?.filterTags??[],r=document.createElement("div");if(r.className="gengage-chat-categories",r.dataset.gengagePart="categories-container",a.length===0)return r;const i=document.createElement("div");i.className="gengage-chat-categories-tabs gds-toolbar",i.dataset.gengagePart="categories-tab-bar",i.setAttribute("role","tablist");const o=[],s=[],c=l=>{for(let d=0;d<o.length;d++){const p=d===l;o[d].classList.toggle("gengage-chat-categories-tab--active",p),o[d].classList.toggle("is-active",p),o[d].setAttribute("aria-selected",String(p)),o[d].tabIndex=p?0:-1,s[d].style.display=p?"":"none"}};for(let l=0;l<a.length;l++){const d=a[l],p=`gengage-cat-tab-${l}`,h=`gengage-cat-panel-${l}`,g=document.createElement("button");if(g.className="gengage-chat-categories-tab gds-tab",g.type="button",g.dataset.gengagePart="categories-tab",g.id=p,g.setAttribute("role","tab"),g.setAttribute("aria-controls",h),g.setAttribute("aria-selected",String(l===0)),g.tabIndex=l===0?0:-1,l===0&&g.classList.add("gengage-chat-categories-tab--active","is-active"),d.image&&Re(d.image)){const f=document.createElement("img");f.className="gengage-chat-categories-tab-image",f.draggable=!1,f.src=d.image,f.alt=d.groupName,f.loading="lazy",Ae(f),g.appendChild(f)}const b=document.createElement("span");b.className="gengage-chat-categories-tab-text",b.textContent=d.groupName,g.appendChild(b),g.addEventListener("click",()=>c(l)),g.addEventListener("keydown",f=>{let u=-1;f.key==="ArrowRight"||f.key==="ArrowDown"?u=(l+1)%a.length:f.key==="ArrowLeft"||f.key==="ArrowUp"?u=(l-1+a.length)%a.length:f.key==="Home"?u=0:f.key==="End"&&(u=a.length-1),u>=0&&(f.preventDefault(),c(u),o[u].focus())}),o.push(g),i.appendChild(g);const m=document.createElement("div");m.className="gengage-chat-categories-grid",m.dataset.gengagePart="categories-panel",m.id=h,m.setAttribute("role","tabpanel"),m.setAttribute("aria-labelledby",p),l!==0&&(m.style.display="none");for(const f of d.products){const u=kc(f,t);m.appendChild(u)}s.push(m)}r.appendChild(i);for(const l of s)r.appendChild(l);if(n.length>0){const l=document.createElement("div");l.className="gengage-chat-categories-filter-tags gds-toolbar",l.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)}),l.appendChild(p)}r.appendChild(l)}return r}function kc(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&&Re(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",Ae(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=J(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 Cc(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 Sc="frontend_restore_panel_message";function Ve(e){return typeof e=="string"?e:""}function Ec(e){return Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object")return null;const a=t;return{imageUrl:Ve(a.imageUrl)||void 0,name:Ve(a.name)||void 0}}).filter(t=>t!==null):[]}function Pc(e,t){const a=e.props??{},n=Ve(a.eyebrow),r=Ve(a.title),i=a.showTitle!==!1,o=Ve(a.ctaLabel)||t.i18n?.showPanelAriaLabel||"Show Results",s=Ve(a.panelMessageId),c=Ve(a.highlightMessageId),l=Ve(a.threadId),d=Ec(a.products).slice(0,3),p=document.createElement("button");p.type="button",p.className="gengage-chat-panel-restore-card gds-card",!n&&!i&&p.classList.add("gengage-chat-panel-restore-card--minimal"),p.dataset.gengagePart="panel-restore-card";const h=r||n||o;p.setAttribute("aria-label",r?`${h} - ${o}`:h);const g={title:r,type:Sc,payload:{panelMessageId:s,highlightMessageId:c,threadId:l}};if(p.addEventListener("click",()=>t.onAction(g)),n){const m=document.createElement("div");m.className="gengage-chat-panel-restore-card__eyebrow",m.textContent=n,p.appendChild(m)}if(d.length>0){const m=document.createElement("div");m.className="gengage-chat-panel-restore-card__previews";for(const f of d){const u=document.createElement("div");u.className="gengage-chat-panel-restore-card__thumb";const A=f.imageUrl;if(A&&ye(A)){const E=document.createElement("img");E.loading="lazy",E.alt=f.name||r,fe(E,"src",A),Ae(E),u.appendChild(E)}m.appendChild(u)}p.appendChild(m)}if(i&&r){const m=document.createElement("div");m.className="gengage-chat-panel-restore-card__title",m.textContent=r,m.title=r,p.appendChild(m)}const b=document.createElement("div");return b.className="gengage-chat-panel-restore-card__cta",b.textContent=o,p.appendChild(b),p}function Tc(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",u=>{u.target.closest("a")||t.onProductSelect?.(a)});const r=a.imageUrl;if(r&&ye(r)){const u=document.createElement("div");u.className="gengage-chat-product-summary__image",u.dataset.gengagePart="product-summary-image";const A=document.createElement("img");A.loading="lazy",fe(A,"src",r),A.alt=a.name||"Product image",Ae(A),u.appendChild(A),n.appendChild(u)}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 u=document.createElement("div");u.className="gengage-chat-product-summary__name",u.dataset.gengagePart="product-summary-name";const A=o&&!s.toLowerCase().startsWith(o.toLowerCase())?`${o} ${s}`:s;u.textContent=A,u.title=A,i.appendChild(u)}const c=a.rating,l=a.reviewCount;if(t.hideUserReviews!==!0&&typeof c=="number"&&Number.isFinite(c)&&c>0){const u=document.createElement("div");if(u.className="gengage-chat-product-summary__rating",u.dataset.gengagePart="product-summary-rating",u.appendChild(dn(c)),typeof l=="number"&&Number.isFinite(l)){const A=document.createElement("span");A.className="gengage-chat-product-summary__review-count",A.textContent=` (${l})`,u.appendChild(A)}i.appendChild(u)}const d=a.price,p=a.originalPrice;if(d){const u=ot(t,a),A=_t(t,a),E=!!(p&&p!==d),w=document.createElement("div");w.className="gengage-chat-product-summary__price",w.dataset.gengagePart="product-summary-price";const T=!!(u&&E),N=Lt(t,a);if(T){const x=It({reasonText:u,salePriceFormatted:J(d,t.pricing),...N!==void 0?{logoUrl:N}:{}});if(E&&A==="inline"){w.classList.add("gengage-chat-product-summary__price--inline"),w.appendChild(x);const P=document.createElement("span");P.className="gengage-chat-product-summary__price-sep",P.setAttribute("aria-hidden","true");const F=document.createElement("span");F.className="gengage-chat-product-summary__price-original",F.textContent=J(p,t.pricing),w.appendChild(P),w.appendChild(F)}else{const P=document.createElement("span");P.className="gengage-chat-product-summary__price-original",P.textContent=J(p,t.pricing),w.appendChild(P),w.appendChild(document.createTextNode(" ")),w.appendChild(x)}i.appendChild(w)}else{if(E&&A==="inline"){w.classList.add("gengage-chat-product-summary__price--inline");const x=document.createElement("span");x.className="gengage-chat-product-summary__price-current",x.textContent=J(d,t.pricing);const P=document.createElement("span");P.className="gengage-chat-product-summary__price-sep",P.setAttribute("aria-hidden","true");const F=document.createElement("span");F.className="gengage-chat-product-summary__price-original",F.textContent=J(p,t.pricing),w.appendChild(x),w.appendChild(P),w.appendChild(F)}else if(E){const x=document.createElement("span");x.className="gengage-chat-product-summary__price-original",x.textContent=J(p,t.pricing),w.appendChild(x),w.appendChild(document.createTextNode(" "));const P=document.createElement("span");P.className="gengage-chat-product-summary__price-current",P.textContent=J(d,t.pricing),w.appendChild(P)}else{const x=document.createElement("span");x.className="gengage-chat-product-summary__price-current",x.textContent=J(d,t.pricing),w.appendChild(x)}if(u){const x=document.createElement("div");x.className="gengage-chat-product-summary__price-stack",x.appendChild(At(u)),x.appendChild(w),i.appendChild(x)}else i.appendChild(w)}}n.appendChild(i);const h=a.url,g=a.sku,b=a.cartCode??a.cart_code,m=typeof b=="string"&&b.trim()?b.trim():void 0,f=a.inStock;if(g&&m&&f!==!1){const u=document.createElement("button");u.type="button",u.className="gengage-chat-product-summary__cta gds-chip gds-chip-active",u.dataset.gengagePart="product-summary-cta",u.textContent=t.i18n?.addToCartButton??"Add to Cart",u.addEventListener("click",A=>{A.stopPropagation(),t.onAction({title:t.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:g,cartCode:m,quantity:1}})}),n.appendChild(u)}else if(h&&ye(h)){const u=document.createElement("a");u.className="gengage-chat-product-summary__cta gds-chip gds-chip-active",u.dataset.gengagePart="product-summary-cta",fe(u,"href",h),fe(u,"target","_blank"),fe(u,"rel","noopener noreferrer"),u.textContent=t.i18n?.productCtaLabel??"View",n.appendChild(u)}return n}var Ac={PhotoAnalysisCard:({element:e,context:t})=>Ps(e,t),BeautyPhotoStep:({element:e,context:t})=>tn(e,t)};function oa(){return window.innerWidth<768}var vn={ActionButtons:({element:e,context:t})=>Lc(e,t),ActionButton:({element:e,context:t})=>Ic(e,t),ProductCard:({element:e,context:t})=>ca(e,t),ProductDetailsPanel:({element:e,context:t})=>Xc(e,t),ProductGrid:({element:e,spec:t,renderElement:a,context:n})=>ol(e,t,a,n),ReviewHighlights:({element:e,context:t})=>t.hideUserReviews===!0?null:sc(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})=>sl(e,t),AITopPicks:({element:e,context:t})=>mc(e,t),GroundingReviewCard:({element:e,context:t})=>t.hideUserReviews===!0?null:bc(e,t),AIGroupingCards:({element:e,context:t})=>yc(e,t),AISuggestedSearchCards:({element:e,context:t})=>_c(e,t),ProsAndCons:({element:e})=>xc(e),CategoriesContainer:({element:e,context:t})=>wc(e,t),HandoffNotice:({element:e,context:t})=>Cc(e,t),PanelRestoreCard:({element:e,context:t})=>Pc(e,t),ProductSummaryCard:({element:e,context:t})=>Tc(e,t),Divider:({element:e})=>cl(e),...Ac},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 yn(){return{...vn}}function _n(e,t,a=vn,n=sa){return Yr({spec:e,context:t,registry:a,containerClassName:"gengage-chat-uispec",unknownRenderer:n})}function Lc(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 Ic(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 xn(e,t,a,n,r){e.replaceChildren();const i=_t(t,a),o=!!(r&&n&&r!==n),s=ot(t,a),c=!!(s&&o),l=Lt(t,a);if(!n||parseFloat(n)<=0)return;if(c){const p=It({reasonText:s,salePriceFormatted:J(n,t.pricing),...l!==void 0?{logoUrl:l}:{}});if(o&&i==="inline"){e.classList.add("gengage-chat-product-card-price-block--inline");const h=document.createElement("div");h.className="gengage-chat-product-card-price-row",h.appendChild(p);const g=document.createElement("span");g.className="gengage-chat-product-card-price-sep",g.setAttribute("aria-hidden","true");const b=document.createElement("span");b.className="gengage-chat-product-card-original-price",b.textContent=J(r,t.pricing),h.appendChild(g),h.appendChild(b),e.appendChild(h);return}if(e.classList.remove("gengage-chat-product-card-price-block--inline"),e.appendChild(p),o){e.appendChild(document.createTextNode(" "));const h=document.createElement("span");h.className="gengage-chat-product-card-original-price",h.textContent=J(r,t.pricing),e.appendChild(h)}return}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";const h=document.createElement("span");h.className="gengage-chat-product-card-current-price",h.textContent=J(n,t.pricing);const g=document.createElement("span");g.className="gengage-chat-product-card-price-sep",g.setAttribute("aria-hidden","true");const b=document.createElement("span");b.className="gengage-chat-product-card-original-price",b.textContent=J(r,t.pricing),p.appendChild(h),p.appendChild(g),p.appendChild(b),e.appendChild(p);return}e.classList.remove("gengage-chat-product-card-price-block--inline");const d=document.createElement("span");if(d.className="gengage-chat-product-card-current-price",d.textContent=J(n,t.pricing),e.appendChild(d),o){e.appendChild(document.createTextNode(" "));const p=document.createElement("span");p.className="gengage-chat-product-card-original-price",p.textContent=J(r,t.pricing),e.appendChild(p)}}function wn(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=ot(t,a),c=!!(s&&o),l=Lt(t,a);if(c){const p=It({reasonText:s,salePriceFormatted:J(n,t.pricing),...l!==void 0?{logoUrl:l}:{}});if(o&&i==="inline"){e.classList.add("gengage-chat-product-details-price--inline"),e.appendChild(p);const h=document.createElement("span");h.className="gengage-chat-product-details-price-sep",h.setAttribute("aria-hidden","true");const g=document.createElement("span");g.className="gengage-chat-product-details-original-price",g.textContent=J(r,t.pricing),e.appendChild(h),e.appendChild(g)}else{if(o){const h=document.createElement("span");h.className="gengage-chat-product-details-original-price",h.textContent=J(r,t.pricing),e.appendChild(h),e.appendChild(document.createTextNode(" "))}e.appendChild(p)}}else if(o&&i==="inline"){e.classList.add("gengage-chat-product-details-price--inline");const p=document.createElement("span");p.className="gengage-chat-product-details-current-price",p.textContent=J(n,t.pricing);const h=document.createElement("span");h.className="gengage-chat-product-details-price-sep",h.setAttribute("aria-hidden","true");const g=document.createElement("span");g.className="gengage-chat-product-details-original-price",g.textContent=J(r,t.pricing),e.appendChild(p),e.appendChild(h),e.appendChild(g)}else{if(o){const h=document.createElement("span");h.className="gengage-chat-product-details-original-price",h.textContent=J(r,t.pricing),e.appendChild(h),e.appendChild(document.createTextNode(" "))}const p=document.createElement("span");p.className="gengage-chat-product-details-current-price",p.textContent=J(n,t.pricing),e.appendChild(p)}const d=Nt(a,"discountPercent","price_discount_rate");if(!t.hideProductDiscountBadge&&typeof d=="number"&&d>0){const p=document.createElement("span");p.className="gengage-chat-product-details-discount-badge",p.textContent=`%${ln(d)}`,e.appendChild(p)}}function ca(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;(t.onProductSelect||i)&&(a.classList.add("gds-clickable"),a.addEventListener("click",v=>{if(!a.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")&&!v.target.closest(".gengage-chat-product-card-atc")&&!v.target.closest(".gengage-chat-product-card-cta")){if(i){t.onAction(i);return}t.onProductSelect?.(n)}}));const o=n.imageUrl;if(o&&ye(o)){const v=document.createElement("div");v.className="gengage-chat-product-card-img-wrapper";const I=document.createElement("img");I.className="gengage-chat-product-card-img",I.loading="lazy",fe(I,"src",o);const O=n.name;O&&(I.alt=O),Ae(I),v.appendChild(I);const B=n.discountPercent;if(!t.hideProductDiscountBadge&&typeof B=="number"&&B>0){const L=document.createElement("span");L.className="gengage-chat-product-card-discount-badge",L.textContent=`%${ln(B)}`,v.appendChild(L)}const j=document.createElement("div");j.className="gengage-chat-product-card-img-actions";const Z=n.sku;if(Z&&t.onFavoriteToggle){const L=document.createElement("button");L.className="gengage-chat-favorite-btn",L.type="button",L.dataset.gengageFavoriteSku=Z,L.setAttribute("aria-label",t.i18n?.addToFavoritesLabel??"Add to favorites");const S=t.favoritedSkus?.has(Z)??!1;S&&L.classList.add("gengage-chat-favorite-btn--active"),L.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="${S?"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>`,L.addEventListener("click",z=>{z.stopPropagation(),L.classList.toggle("gengage-chat-favorite-btn--active");const M=L.querySelector("svg");M&&M.setAttribute("fill",L.classList.contains("gengage-chat-favorite-btn--active")?"currentColor":"none"),t.onFavoriteToggle(Z,n)}),j.appendChild(L)}const q=n.sku,y=t.i18n?.findSimilarLabel??"Find Similar";if(q){const L=document.createElement("button");L.className="gengage-chat-find-similar-pill",L.type="button",L.setAttribute("aria-label",y),L.dataset.tooltip=y,L.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 S=document.createElement("span");S.className="gengage-chat-find-similar-pill-text",S.textContent=y,L.appendChild(S),L.addEventListener("click",z=>{z.stopPropagation(),t.onAction({title:y,type:"findSimilar",payload:{sku:q,...o?{image_url:o}:{}}})}),j.appendChild(L)}j.childElementCount>0&&v.appendChild(j),a.appendChild(v)}const s=document.createElement("div");s.className="gengage-chat-product-card-body";const c=n.brand;if(c){const v=document.createElement("div");v.className="gengage-chat-product-card-brand",v.textContent=c,s.appendChild(v)}const l=n.rating,d=n.reviewCount,p=n.price,h=n.originalPrice,g=n.price_async,b=ot(t,n),m=_t(t,n),f=!!(h&&p&&h!==p&&parseFloat(p)>0),u=!!(b&&f),A=!!(b&&!u||f&&m==="inline"),E=typeof l=="number"&&Number.isFinite(l)&&l>0,w=document.createElement("div");w.className="gengage-chat-product-card-meta-row";const T=document.createElement("div");T.className="gengage-chat-product-card-price gengage-chat-product-card-price-block";const N=A?(()=>{const v=document.createElement("div");return v.className="gengage-chat-product-card-price-stack",b&&!u&&v.appendChild(At(b)),v.appendChild(T),v})():T;if(g===!0){const v=document.createElement("span");v.className="gengage-chat-price-skeleton",T.appendChild(v),setTimeout(()=>{v.parentElement&&(p&&parseFloat(p)>0?xn(T,t,n,p,n.originalPrice):v.remove())},300)}else p&&parseFloat(p)>0&&xn(T,t,n,p,h);if((T.childElementCount>0||g===!0)&&w.appendChild(N),E){const v=document.createElement("div");v.className="gengage-chat-product-card-rating gengage-chat-product-card-rating-compact";const I=ra(l),O=[`${I.toFixed(1)}`,"out of 5 stars"];typeof d=="number"&&Number.isFinite(d)&&O.push(`(${d} reviews)`),v.setAttribute("aria-label",O.join(" "));const B=document.createElement("span");B.className="gengage-chat-product-card-rating-compact-star",B.setAttribute("aria-hidden","true"),B.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 j=document.createElement("span");j.className="gengage-chat-product-card-rating-compact-value",j.textContent=I.toFixed(1),v.appendChild(B),v.appendChild(j),w.appendChild(v)}w.childElementCount===0&&(w.classList.add("gengage-chat-product-card-meta-row--empty"),w.setAttribute("aria-hidden","true")),s.appendChild(w);const x=n.name;if(x){const v=document.createElement("div");v.className="gengage-chat-product-card-name",v.textContent=x,v.title=x,s.appendChild(v)}const P=n.inStock;if(t.hideStockStatus!==!0&&typeof P=="boolean"){const v=document.createElement("div");v.className=`gengage-chat-product-card-stock ${P?"is-in-stock":"is-out-of-stock"}`,v.textContent=P?t.i18n?.inStockLabel??"In Stock":t.i18n?.outOfStockLabel??"Out of Stock",s.appendChild(v)}a.appendChild(s);const F=n.url,ee=n.sku,ie=n.cartCode,ve=!!(ie&&ee&&P!==!1),D=t.i18n?.productCtaLabel??"View";if(ve){const v=document.createElement("div");v.className="gengage-chat-product-card-buy-footer";const I=document.createElement("button");I.type="button",I.className="gengage-chat-product-card-buy-trigger",I.textContent=D,I.addEventListener("click",O=>{O.stopPropagation(),t.onAction({title:t.i18n?.addToCartButton??D,type:"addToCart",payload:{sku:ee,cartCode:ie,quantity:1}})}),v.appendChild(I),a.appendChild(v)}else if(i){const v=document.createElement("button");v.className="gengage-chat-product-card-cta",v.type="button",v.textContent=i.type==="launchSingleProduct"?D:i.title||D,v.addEventListener("click",I=>{if(a.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){I.stopPropagation();return}t.onAction(i)}),a.appendChild(v)}else if(F&&ye(F)){const v=document.createElement("a");v.className="gengage-chat-product-card-cta",fe(v,"href",F),fe(v,"target","_blank"),fe(v,"rel","noopener noreferrer"),v.textContent=D,v.addEventListener("click",I=>{if(a.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){I.preventDefault(),I.stopPropagation();return}t.onProductClick&&ee&&(I.preventDefault(),t.onProductClick({sku:ee,url:F,...x?{name:x}:{}}))}),a.appendChild(v)}if(t.comparisonSelectMode&&ee&&t.onToggleComparisonSku){const v=document.createElement("div");v.className="gengage-chat-comparison-select-wrapper";const I=t.comparisonSelectedSkus?.includes(ee)??!1;I&&v.classList.add("gengage-chat-comparison-select-wrapper--selected");const O=n.name??ee,B=t.i18n?.comparisonSelectCardHint??"Tap anywhere on the card to add or remove it from comparison.";v.setAttribute("role","group"),v.setAttribute("aria-label",`${String(O)}. ${B}`);const j=document.createElement("button");j.type="button",j.className="gengage-chat-comparison-checkbox",j.dataset.selected=I?"true":"false",j.setAttribute("aria-pressed",I?"true":"false");const Z=document.createElement("span");Z.className="gengage-chat-comparison-checkbox-icon",Z.innerHTML=I?'<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 q=document.createElement("span");q.className="gengage-chat-comparison-checkbox-label",q.textContent=I?t.i18n?.comparisonSelectedLabel??"Selected":t.i18n?.comparisonSelectLabel??"Select to compare",j.appendChild(Z),j.appendChild(q),j.addEventListener("click",L=>{L.stopPropagation(),t.onToggleComparisonSku?.(ee)});const y=document.createElement("div");return y.className="gengage-chat-comparison-card-hint",y.setAttribute("aria-hidden","true"),y.textContent=B,v.addEventListener("click",L=>{L.target.closest(".gengage-chat-comparison-checkbox")||(L.stopPropagation(),t.onToggleComparisonSku?.(ee))}),v.appendChild(j),v.appendChild(y),v.appendChild(a),v}return a}var kn=new Set(["color","colour","renk","renk kodu","color code"]),Nc=new Set(["size","beden","boyut"]),zc=new Set(["finish","bitiş","bitişi"]),Mc=["variants","variantOptions","variant_options","productVariants","product_variants","options"],Bc=new Set(["H2","H3","H4","P","BR","UL","OL","LI","STRONG","B","EM","I"]),Rc=new Set(["SCRIPT","STYLE","NOSCRIPT","IFRAME","OBJECT","EMBED"]);function we(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 Nt(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 zt(e,...t){for(const a of t){const n=e[a];if(typeof n=="boolean")return n}}function Oc(e,...t){for(const a of t){const n=e[a];if(n&&typeof n=="object"&&!Array.isArray(n))return n}}function Dc(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0):[]}function Hc(e){const t=[...Dc(e.images),we(e,"imageUrl","image_url","image")].filter(a=>!!a&&ye(a));return Array.from(new Set(t))}function Fc(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 $c(e){const t=we(e,"description_html","descriptionHtml");if(t){const n=Fc(t);if(n)return{text:n,html:t}}const a=we(e,"description");return a?{text:a}:void 0}function Mt(e){return Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object")return null;const a=t,n=we(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 Cn(e){const t=Mt(e.features);return t.length>0?t:Mt(e.specifications)}function Uc(e){const t=e.specifications,a=Mt(t);if(a.length>0)return Array.isArray(t)?a:Object.fromEntries(a.map(r=>[r.key,r.value]));const n=Mt(e.features);return n.length>0?n:void 0}function Ue(e,...t){return we(e,...t)}function Sn(e,...t){return Nt(e,...t)}function En(e){return Ue(e,"value","option_value","attribute_value","label","title","name","variant_name","sku")}function Pn(e){const t=Ue(e,"type","attribute","option_name","attribute_name");return t||(Ue(e,"value")?Ue(e,"name","variant_name"):void 0)}function jc(e){const t=Pn(e)?.toLowerCase();return!!(we(e,"color","colour","color_hex","hex","swatch","swatchColor")||t&&kn.has(t))}function Tn(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 Zc(e){const t=Tn(Ue(e,"swatchColor","swatch","color_hex","hex","color","colour"));if(t)return t;if(jc(e))return Tn(En(e))}function qc(e){return Ue(e,"image","imageUrl","image_url","swatchImage","swatch_image")}function Vc(e){return Sn(e,"price_discounted","priceDiscounted")??Ue(e,"price_discounted","priceDiscounted")??Sn(e,"price")??Ue(e,"price")}function Gc(e){const t=e.trim().toLowerCase();return kn.has(t)||Nc.has(t)||zc.has(t)}function Wc(e){const t=e.trim().toLowerCase();return t==="renk kodu"?"Renk":t==="color code"?"Color":e.trim()}function Kc(e){for(const t of Mc){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 Yc(e){const t=Kc(e);if(t)return t;const a=we(e,"sku"),n=zt(e,"inStock","in_stock"),r=[],i=new Set,o=(c,l)=>{if(!Gc(c)||typeof l!="string"&&typeof l!="number"&&typeof l!="boolean")return;const d=String(l).trim();if(!d)return;const p=Wc(c),h=`${p.toLowerCase()}:${d.toLowerCase()}`;i.has(h)||(i.add(h),r.push({name:p,value:d,sku:a,inStock:n}))},s=Oc(e,"facetHits","facet_hits");if(s)for(const[c,l]of Object.entries(s))o(c,l);for(const c of Cn(e))o(c.key,c.value);return r}function Jc(e,t){const a=Array.from(new Set(e.map(Pn).filter(n=>!!n)));return a.length===1?`${e.length} ${a[0]}`:t.i18n?.variantsLabel??"Variants"}function Xc(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=we(n,"name"),i=we(n,"brand"),o=we(n,"sku"),s=we(n,"cartCode","cart_code"),c=we(n,"price"),l=we(n,"originalPrice","price_original"),d=zt(n,"price_async"),p=ot(t,n),h=_t(t,n),g=!!(l&&c&&l!==c),b=zt(n,"inStock","in_stock"),m=Nt(n,"reviewCount","review_count"),f=Nt(n,"rating"),u=Hc(n),A=Cn(n).slice(0,4);if(u.length>1){const v=document.createElement("div");v.className="gengage-chat-product-details-media gengage-chat-product-details-gallery gengage-chat-product-details-img-wrap";const I=document.createElement("img");I.className="gengage-chat-product-details-img",fe(I,"src",u[0]),I.alt=r??"Product image",Ae(I),v.appendChild(I);const O=document.createElement("div");O.className="gengage-chat-product-gallery-thumbs";const B=6;let j=null,Z=0;const q=t.i18n,y=q?.galleryPrevAriaLabel??"Previous image",L=q?.galleryNextAriaLabel??"Next image",S=U=>U==="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>',z=document.createElement("button");z.type="button",z.className="gengage-chat-product-gallery-nav gengage-chat-product-gallery-nav--prev gds-btn gds-btn-ghost gds-icon-btn",z.setAttribute("aria-label",y),z.innerHTML=S("prev");const M=document.createElement("button");M.type="button",M.className="gengage-chat-product-gallery-nav gengage-chat-product-gallery-nav--next gds-btn gds-btn-ghost gds-icon-btn",M.setAttribute("aria-label",L),M.innerHTML=S("next");const R=()=>{z.disabled=Z<=0,M.disabled=Z>=u.length-1},$=U=>{if(U<0||U>=u.length||U===Z)return;const ce=u[U];if(!ce)return;fe(I,"src",ce);const X=O.querySelectorAll(".gengage-chat-product-gallery-thumb");j&&j.classList.remove("gengage-chat-product-gallery-thumb--active"),U<B&&X[U]?(X[U].classList.add("gengage-chat-product-gallery-thumb--active"),j=X[U]):j=null,Z=U,R()};for(let U=0;U<u.length;U++){const ce=u[U];if(U>=B)break;const X=document.createElement("img");X.className="gengage-chat-product-gallery-thumb",U===0&&(X.classList.add("gengage-chat-product-gallery-thumb--active"),j=X),fe(X,"src",ce),X.alt=`${r??"Product"} ${U+1}`,X.width=48,X.height=48,Ae(X),X.addEventListener("click",()=>{$(U)}),O.appendChild(X)}if(u.length>B){const U=document.createElement("span");U.className="gengage-chat-product-gallery-thumb-more",U.textContent=`+${u.length-B}`,O.appendChild(U)}z.addEventListener("click",U=>{U.stopPropagation(),$(Z-1)}),M.addEventListener("click",U=>{U.stopPropagation(),$(Z+1)}),R();let ae=0;const te=50;I.addEventListener("touchstart",U=>{ae=U.changedTouches[0].clientX},{passive:!0}),I.addEventListener("touchend",U=>{const ce=U.changedTouches[0].clientX,X=ae-ce;Math.abs(X)<te||$(X>0?Math.min(Z+1,u.length-1):Math.max(Z-1,0))}),v.appendChild(z),v.appendChild(M),v.appendChild(O),a.appendChild(v)}else if(u.length===1){const v=document.createElement("div");v.className="gengage-chat-product-details-media gengage-chat-product-details-img-wrap";const I=document.createElement("img");I.className="gengage-chat-product-details-img",I.loading="lazy",fe(I,"src",u[0]),Ae(I),I.alt=r??"Product image",v.appendChild(I),a.appendChild(v)}const E=document.createElement("div");if(E.className="gengage-chat-product-details-content",i&&(!r||!r.toLowerCase().startsWith(i.toLowerCase()))){const v=document.createElement("div");v.className="gengage-chat-product-details-brand",v.textContent=i,E.appendChild(v)}if(r){const v=document.createElement("h3");v.className="gengage-chat-product-details-title",v.textContent=r,v.title=r,E.appendChild(v)}if(t.hideUserReviews!==!0&&typeof f=="number"&&Number.isFinite(f)&&f>0){const v=document.createElement(o?"button":"div");v.className="gengage-chat-product-details-rating",o&&(v.type="button",v.classList.add("gengage-chat-product-details-rating--clickable"),v.setAttribute("aria-label",t.i18n?.groundingReviewCta??"Read Reviews"),v.addEventListener("click",()=>{t.onAction({title:t.i18n?.customerReviewsTitle??"Customer Reviews",type:"reviewSummary",payload:{sku:o}})})),v.appendChild(dn(f));const I=document.createElement("span");if(I.className="gengage-chat-product-details-rating-value",I.textContent=ra(f).toFixed(1),v.appendChild(I),typeof m=="number"&&Number.isFinite(m)){const O=document.createElement("span");O.className="gengage-chat-product-details-review-count",O.textContent=` (${m})`,v.appendChild(O)}E.appendChild(v)}{const v=!!(p&&g);let I=E;if(p&&!v){const B=document.createElement("div");B.className="gengage-chat-product-details-price-stack",B.appendChild(At(p)),E.appendChild(B),I=B}const O=document.createElement("div");if(O.className="gengage-chat-product-details-price",d===!0){const B=document.createElement("span");B.className="gengage-chat-price-skeleton",O.appendChild(B),I.appendChild(O),setTimeout(()=>{if(B.parentElement)if(c&&parseFloat(c)>0)wn(O,t,n,c,l,h,g);else{const j=O.parentElement;O.remove(),j?.classList.contains("gengage-chat-product-details-price-stack")&&j.remove()}},300)}else if(c&&parseFloat(c)>0)wn(O,t,n,c,l,h,g),I.appendChild(O);else if(p){const B=I;B.classList.contains("gengage-chat-product-details-price-stack")&&B.remove()}}if(t.hideStockStatus!==!0&&typeof b=="boolean"){const v=document.createElement("div");v.className=`gengage-chat-product-details-stock ${b?"is-in-stock":"is-out-of-stock"}`,v.textContent=b?t.i18n?.inStockLabel??"In Stock":t.i18n?.outOfStockLabel??"Out of Stock",E.appendChild(v)}const w=n.promotions;if(w&&w.length>0){const v=document.createElement("div");v.className="gengage-chat-product-details-promos";for(const I of w.slice(0,3)){if(!I||/%(0(\.0+)?)\s/.test(I))continue;const O=document.createElement("span");O.className="gengage-chat-product-details-promo-badge",O.textContent=I,O.title=I,v.appendChild(O)}v.childElementCount>0&&E.appendChild(v)}if(A.length>0){const v=document.createElement("dl");v.className="gengage-chat-product-details-facts";for(const I of A){const O=document.createElement("div");O.className="gengage-chat-product-details-fact";const B=document.createElement("dt");B.textContent=I.key;const j=document.createElement("dd");j.textContent=I.value,O.appendChild(B),O.appendChild(j),v.appendChild(O)}E.appendChild(v)}const T=Yc(n);if(T.length>0){const v=document.createElement("div");v.className="gengage-chat-product-variants";const I=document.createElement("div");I.className="gengage-chat-product-variants-label",I.textContent=Jc(T,t),v.appendChild(I);const O=document.createElement("div");O.className="gengage-chat-product-variants-list";for(const B of T){const j=En(B),Z=Ue(B,"sku");if(!j&&!Z)continue;const q=document.createElement("button");q.className="gengage-chat-product-variant-btn gds-chip",q.type="button";const y=j??Z??"";q.title=y;const L=zt(B,"in_stock","inStock");Z&&o&&Z===o?(q.classList.add("gengage-chat-product-variant-btn--active"),q.setAttribute("aria-pressed","true")):q.setAttribute("aria-pressed","false"),L===!1&&(q.classList.add("gengage-chat-product-variant-btn--out"),q.disabled=!0);const S=qc(B),z=Zc(B);if(S&&ye(S)){const $=document.createElement("img");$.className="gengage-chat-product-variant-swatch gengage-chat-product-variant-swatch--image",fe($,"src",S),$.alt="",$.setAttribute("aria-hidden","true"),Ae($),q.appendChild($)}else if(z){const $=document.createElement("span");$.className="gengage-chat-product-variant-swatch",$.setAttribute("aria-hidden","true"),$.style.backgroundColor=z,q.appendChild($)}const M=document.createElement("span");M.className="gengage-chat-product-variant-label",M.textContent=y,q.appendChild(M);const R=Vc(B);if(R&&String(R)!==String(c)){const $=document.createElement("span");$.className="gengage-chat-product-variant-price",$.textContent=J(String(R),t.pricing),q.appendChild($)}if(Z&&Z!==o){const $=r??"",ae=(typeof B.value=="string"?B.value.trim():"")||(typeof B.name=="string"?B.name.trim():"")||(typeof B.variant_name=="string"?B.variant_name.trim():"")||"",te=$.length>0?ae.length>0&&ae!==$?`${$} (${ae})`:$:y;q.addEventListener("click",()=>{t.onAction({title:te,type:"launchVariant",payload:{sku:Z}})})}O.appendChild(q)}O.childElementCount>0&&(v.appendChild(O),E.appendChild(v))}const N=document.createElement("div");N.className="gengage-chat-product-details-actions";const x=e.props?.action;if(x){const v=document.createElement("button");v.className="gengage-chat-product-details-cta gds-btn gds-btn-primary",v.type="button",v.textContent=x.title||t.i18n?.productCtaLabel||"View",v.addEventListener("click",()=>t.onAction(x)),N.appendChild(v)}if(s&&o&&b!==!1){const v=document.createElement("button");v.className="gengage-chat-product-details-atc gds-btn gds-btn-primary",v.type="button",v.textContent=t.i18n?.addToCartButton??"Add to Cart",v.addEventListener("click",()=>{t.onAction({title:t.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:o,cartCode:s,quantity:1}})}),N.appendChild(v)}const P=we(n,"url");if(!x&&P&&ye(P)){const v=document.createElement("a");v.className="gengage-chat-product-details-cta gds-btn gds-btn-secondary",fe(v,"href",P),fe(v,"target","_blank"),fe(v,"rel","noopener noreferrer"),v.textContent=t.i18n?.viewOnSiteLabel??t.i18n?.productCtaLabel??"View on Site",v.addEventListener("click",I=>{t.onProductClick&&o&&(I.preventDefault(),t.onProductClick({sku:o,url:P,...r?{name:r}:{}}))}),N.appendChild(v)}const F=P;if(F&&ye(F)){let j=function(q,y){const L=document.createElementNS(O,"circle");L.setAttribute("cx",q),L.setAttribute("cy",y),L.setAttribute("r","3"),B.appendChild(L)},Z=function(q,y,L,S){const z=document.createElementNS(O,"line");z.setAttribute("x1",q),z.setAttribute("y1",y),z.setAttribute("x2",L),z.setAttribute("y2",S),B.appendChild(z)};var ve=j,D=Z;const v=document.createElement("button");v.className="gengage-chat-product-details-share gds-btn gds-btn-ghost gds-icon-btn",v.type="button";const I=t.i18n?.shareButton??"Share";v.title=I,v.setAttribute("aria-label",I);const O="http://www.w3.org/2000/svg",B=document.createElementNS(O,"svg");B.setAttribute("width","18"),B.setAttribute("height","18"),B.setAttribute("viewBox","0 0 24 24"),B.setAttribute("fill","none"),B.setAttribute("stroke","currentColor"),B.setAttribute("stroke-width","2"),B.setAttribute("stroke-linecap","round"),B.setAttribute("stroke-linejoin","round"),j("18","5"),j("6","12"),j("18","19"),Z("8.59","13.51","15.42","17.49"),Z("15.41","6.51","8.59","10.49"),v.appendChild(B),v.addEventListener("click",async()=>{try{navigator.share?await navigator.share({title:r??"",url:F}):navigator.clipboard&&(await navigator.clipboard.writeText(F),v.classList.add("gengage-chat-product-details-share--copied"),setTimeout(()=>v.classList.remove("gengage-chat-product-details-share--copied"),1500))}catch{}}),N.appendChild(v)}N.childElementCount>0&&E.appendChild(N),a.appendChild(E);const ee=$c(n),ie=Uc(n);return(ee||ie)&&a.appendChild(tl(ee,ie,t)),a}function la(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(Rc.has(a))return null;if(!Bc.has(a)){const r=document.createDocumentFragment();for(const i of Array.from(t.childNodes)){const o=la(i);o&&r.appendChild(o)}return r}const n=document.createElement(a.toLowerCase());for(const r of Array.from(t.childNodes)){const i=la(r);i&&n.appendChild(i)}return n}function Qc(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 el(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=>la(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}}Qc(e,t.text)}function tl(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",el(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 d=Array.isArray(t)?t:Object.entries(t).map(([p,h])=>({key:p,value:h}));for(const p of d){const h=document.createElement("tr"),g=document.createElement("td");g.className="gengage-chat-product-specs-key",g.textContent=p.key;const b=document.createElement("td");b.className="gengage-chat-product-specs-value",b.textContent=p.value,h.appendChild(g),h.appendChild(b),l.appendChild(h)}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,d)=>{l.style.display=d===c?"":"none"})})}),n.appendChild(r);for(const s of i)n.appendChild(s);return n}function An(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 al(){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 nl(){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 rl(){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 Ln(e,t){return e.type===t.type&&e.direction===t.direction}function In(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 il(e,t,a,n){const r=In(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 ol(e,t,a,n){const r=document.createElement("div");r.className="gengage-chat-product-grid-wrapper";const i=ha(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 h=document.createElement("div");h.className="gengage-chat-product-sort-toolbar",h.setAttribute("role","toolbar"),h.setAttribute("aria-label",n.i18n?.sortToolbarAriaLabel??"Sort products");let g=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"}],m=document.createElement("div");m.className="gengage-chat-product-sort-dropdown";const f=document.createElement("button");f.type="button",f.className="gengage-chat-product-sort-trigger gds-btn gds-btn-ghost",f.setAttribute("aria-haspopup","listbox"),f.setAttribute("aria-expanded","false");const u=n.i18n?.sortToolbarAriaLabel??"Sort products",A=document.createElement("span");A.className="gengage-chat-product-sort-trigger-icon";const E=document.createElement("span");E.className="gengage-chat-product-sort-trigger-label";const w=D=>{const v=b.find(I=>Ln(I.sortState,D))??b[0];E.textContent=v.label,A.innerHTML=An(v.icon),m.dataset.sortIcon=v.icon,f.setAttribute("aria-label",`${u}: ${v.label}`),f.title=v.label};w(g);const T=document.createElement("span");T.className="gengage-chat-product-sort-trigger-chevron",T.innerHTML=al(),f.appendChild(A),f.appendChild(E),f.appendChild(T);const N=document.createElement("div");N.className="gengage-chat-product-sort-menu gds-menu",N.hidden=!0,N.setAttribute("role","listbox"),N.setAttribute("aria-label",u);const x=h.ownerDocument;let P=null;const F=()=>{N.hidden=!0,m.classList.remove("gengage-chat-product-sort-dropdown--open"),f.setAttribute("aria-expanded","false"),P?.abort(),P=null},ee=D=>{m.classList.contains("gengage-chat-product-sort-dropdown--open")&&(m.contains(D.target)||F())},ie=D=>{D.key==="Escape"&&(D.preventDefault(),F())},ve=()=>{N.hidden=!1,m.classList.add("gengage-chat-product-sort-dropdown--open"),f.setAttribute("aria-expanded","true"),P=new AbortController;const{signal:D}=P;x.addEventListener("click",ee,{signal:D}),x.addEventListener("keydown",ie,{capture:!0,signal:D})};f.addEventListener("click",D=>{D.stopPropagation(),m.classList.contains("gengage-chat-product-sort-dropdown--open")?F():ve()});for(const D of b){const v=document.createElement("button");v.type="button",v.className="gengage-chat-product-sort-option gds-menu-option",v.setAttribute("role","option");const I=Ln(g,D.sortState);v.setAttribute("aria-selected",I?"true":"false"),I&&v.classList.add("gengage-chat-product-sort-option--active","gds-menu-option-active");const O=D.sortState.type==="related"?"related":`price-${D.sortState.direction??""}`;v.dataset.sortKey=O;const B=document.createElement("span");B.className="gengage-chat-product-sort-option-icon",B.innerHTML=An(D.icon);const j=document.createElement("span");j.className="gengage-chat-product-sort-option-label",j.textContent=D.label;const Z=document.createElement("span");Z.className="gengage-chat-product-sort-option-check",Z.innerHTML=nl(),Z.setAttribute("aria-hidden","true"),I||Z.classList.add("gengage-chat-product-sort-option-check--hidden"),v.appendChild(B),v.appendChild(j),v.appendChild(Z),v.addEventListener("click",()=>{g=D.sortState,n.onSortChange?.(D.sortState),il(c,s,t,D.sortState),N.querySelectorAll(".gengage-chat-product-sort-option").forEach(q=>{const y=q,L=y.dataset.sortKey===O;y.classList.toggle("gengage-chat-product-sort-option--active",L),y.classList.toggle("gds-menu-option-active",L),y.setAttribute("aria-selected",L?"true":"false"),y.querySelector(".gengage-chat-product-sort-option-check")?.classList.toggle("gengage-chat-product-sort-option-check--hidden",!L)}),w(D.sortState),F()}),N.appendChild(v)}if(m.appendChild(f),m.appendChild(N),h.appendChild(m),n.onToggleComparisonSku){const D=document.createElement("button");D.className="gengage-chat-comparison-toggle-btn gds-btn gds-btn-ghost",D.type="button",n.comparisonSelectMode&&D.classList.add("gengage-chat-comparison-toggle-btn--active"),n.isStreaming&&D.classList.add("gengage-chat-comparison-toggle-btn--hidden");const v=document.createElement("span");v.className="gengage-chat-comparison-toggle-icon",v.innerHTML=rl();const I=document.createElement("span");I.className="gengage-chat-comparison-toggle-label";const O=n.i18n?.compareSelected??"Compare";I.textContent=O,D.setAttribute("aria-label",O),D.title=O,D.appendChild(v),D.appendChild(I),D.addEventListener("click",()=>{n.onToggleComparisonSku?.("")}),h.appendChild(D)}if(l){h.classList.add("gengage-chat-product-sort-toolbar--inline");const D=document.createElement("div");D.className="gengage-chat-product-grid-head";const v=document.createElement("span");v.className="gengage-chat-product-grid-head-title",v.textContent=l,D.appendChild(v);const I=document.createElement("div");I.className="gengage-chat-product-grid-head-actions",I.appendChild(h),D.appendChild(I),r.appendChild(D)}else r.appendChild(h)}else if(l){const h=document.createElement("div");h.className="gengage-chat-product-grid-head";const g=document.createElement("span");g.className="gengage-chat-product-grid-head-title",g.textContent=l,h.appendChild(g),r.appendChild(h)}if(o)hl(r,c,i,n);else{const h=In(s,t,n?.productSort);for(const g of h){if(!t.elements[g])continue;const b=a(g);b&&(b.dataset.elementId=g,c.appendChild(b))}}(n?.isMobile??oa())&&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 d=e.props?.endOfList;if(!o&&d!==!0&&s.length>0){const h=n?.i18n?.viewMoreLabel??"Show More",g=document.createElement("button");g.className="gengage-chat-product-grid-view-more",g.type="button",g.textContent=h,g.addEventListener("click",()=>{n?.onAction({title:h,type:"moreProductList",payload:{}})}),r.appendChild(g)}const p=n?.isMobile??oa();if(n?.comparisonSelectMode&&n.comparisonSelectedSkus&&!p){const h=bn(n.comparisonSelectedSkus,n);r.appendChild(h)}return r}function sl(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,d=a.winnerHits,p=a.productActions;if(!r)return document.createElement("div");const h={recommended:r,products:i,attributes:o,highlights:s,specialCases:c,locale:t.locale,onProductClick:({sku:b,name:m})=>{t.onProductClick?.({sku:b,url:"",name:m})},pricing:t.pricing};l!==void 0&&(h.recommendedText=l),d!==void 0&&(h.winnerHits=d),p!==void 0&&(h.productActions=p),n!==void 0&&(h.keyDifferencesHtml=n),t.i18n&&(h.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 g=Js(h);return(t.isMobile??oa())&&g.classList.add("gengage-chat-comparison--mobile"),g}function cl(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 Bt=new WeakMap;function Nn(e){return{...it,...e?.i18n??{}}}function Rt(e){return typeof e.status=="string"?e.status:"ready"}function da(e){const t=e.findIndex(a=>Rt(a)!=="loading");return t<0?0:t}function ll(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 zn(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=Ot(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 d=0;d<3;d+=1){const p=document.createElement("div");p.className="gengage-chat-consulting-loading-card",l.appendChild(p)}o.appendChild(l)}r.appendChild(o)}function Ot(e,t,a){const n=r=>a.consultingFallbackStyleLabel.replace("{index}",String(r));return e.style_label??n(t)}function ga(e,t){const a=e.variations[t];if(!a)return;const{grid:n,source:r,ctx:i,i18n:o}=e;n.innerHTML="",n.classList.remove("gengage-chat-product-grid--consulting-groups");const s=Rt(a),c=t+1;if(s==="loading"){zn(e,a,"loading",c);return}if(s!=="ready"&&(!Array.isArray(a.product_list)||a.product_list.length===0)){zn(e,a,"unavailable",c);return}const l=Array.isArray(a.product_list)?a.product_list:[],d=r==="watch_expert"?[]:Array.isArray(a.recommendation_groups)?a.recommendation_groups:[];if(d.length>0){n.classList.add("gengage-chat-product-grid--consulting-groups");const p=new Map;for(const u of l){const A=typeof u?.sku=="string"?u.sku:void 0;A&&p.set(A,u)}const h=(u,A,E,w)=>{if(A.length===0)return;const T=document.createElement("section");T.className="gengage-chat-consulting-group";const N=document.createElement("div");N.className="gengage-chat-consulting-group-header";const x=document.createElement("h4");if(x.className="gengage-chat-consulting-group-label",x.textContent=`${u} (${A.length})`,N.appendChild(x),typeof w=="string"&&w.trim().length>0){const F=document.createElement("p");F.className="gengage-chat-consulting-group-reason",F.textContent=w,N.appendChild(F)}T.appendChild(N);const P=document.createElement("div");P.className="gengage-chat-product-grid gengage-chat-consulting-group-grid",E&&P.classList.add("gengage-chat-consulting-group-grid--single-group"),P.style.setProperty("--consulting-group-columns",String(Math.max(1,Math.min(4,A.length))));for(const F of A){const ee=ca({type:"ProductCard",props:{product:F}},i??{onAction:()=>{}});P.appendChild(ee)}T.appendChild(P),n.appendChild(T)},g=new Set,b=[];for(const u of d){const A=(Array.isArray(u.skus)?u.skus.filter(T=>typeof T=="string"&&T.trim().length>0):[]).map(T=>(g.add(T),p.get(T))).filter(T=>!!T);if(A.length===0)continue;const E=typeof u.label=="string"&&u.label.trim().length>0?u.label:o.consultingFallbackGroupLabel,w=typeof u.reason=="string"?u.reason:void 0;b.push({labelText:E,products:A,...w!==void 0?{reasonText:w}:{}})}const m=l.filter(u=>{const A=typeof u?.sku=="string"?u.sku:"";return A.length>0&&!g.has(A)});m.length>0&&b.push({labelText:o.consultingOtherCompatibleProductsLabel,products:m});const f=b.length===1;for(const u of b)h(u.labelText,u.products,f,u.reasonText);return}for(const p of l){const h=ca({type:"ProductCard",props:{product:p}},i??{onAction:()=>{}});n.appendChild(h)}}function pa(e,t,a,n){const r=Rt(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",Ot(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=ll(t.image_url);if(c&&ye(c)){const d=document.createElement("img");d.className="gengage-chat-consulting-style-image",d.draggable=!1,fe(d,"src",c),d.alt=Ot(t,a+1,n),d.loading="lazy",Ae(d),s.appendChild(d)}const l=document.createElement("span");if(l.className="gengage-chat-consulting-style-caption",l.textContent=Ot(t,a+1,n),s.appendChild(l),r==="loading"||r!=="ready"){const d=document.createElement("span");d.className="gengage-chat-consulting-style-status",d.textContent=r==="loading"?i:o,s.appendChild(d)}}function Mn(e,t,a,n){e.addEventListener("click",()=>{const r=Bt.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)}),ga(r,n))})}function dl(e,t,a,n,r){const i=Nn(r),o=da(n),s=document.createElement("div");s.className="gengage-chat-consulting-style-picker";const c={grid:t,source:a,ctx:r,variations:n,i18n:i,selectedIndex:o};Bt.set(s,c);const l=document.createElement("div");l.className="gengage-chat-consulting-style-picker-title",l.textContent=(a==="watch_expert"?i.watchStylesPreparedTitle:i.beautyStylesPreparedTitle).replace("{count}",String(n.length)),s.appendChild(l);const d=document.createElement("div");d.className="gengage-chat-consulting-style-grid",s.appendChild(d),n.forEach((p,h)=>{const g=document.createElement("button");g.type="button",g.className="gengage-chat-consulting-style-btn gds-card",h===o&&g.classList.add("gengage-chat-consulting-style-btn--active"),pa(g,p,h,i),Mn(g,s,d,h),d.appendChild(g)}),e.appendChild(s),ga(c,o)}function gl(e,t,a,n){const r=e.querySelector(".gengage-chat-consulting-style-picker"),i=pl(e);if(!r||!i)return!1;const o=r.querySelector(".gengage-chat-consulting-style-grid");if(!o)return!1;const s=Nn(n);let c=Bt.get(r);if(c)c.grid=i,c.source=t,c.ctx=n,c.variations=a,c.i18n=s;else{const g={grid:i,source:t,ctx:n,variations:a,i18n:s,selectedIndex:da(a)};Bt.set(r,g),c=g}const l=r.querySelector(".gengage-chat-consulting-style-picker-title");l&&(l.textContent=(t==="watch_expert"?s.watchStylesPreparedTitle:s.beautyStylesPreparedTitle).replace("{count}",String(a.length)));const d=c;let p=d.selectedIndex;p>=a.length&&(p=Math.max(0,a.length-1)),p<0&&(p=0),a.length>0&&Rt(a[p]??{})==="loading"&&(p=da(a)),d.selectedIndex=p;const h=[...o.querySelectorAll(".gengage-chat-consulting-style-btn")];if(h.length===0)return!1;for(let g=0;g<a.length;g+=1){const b=a[g];let m=h[g];m?pa(m,b,g,s):(m=document.createElement("button"),m.type="button",m.className="gengage-chat-consulting-style-btn gds-card",pa(m,b,g,s),Mn(m,r,o,g),o.appendChild(m),h[g]=m)}for(;o.querySelectorAll(".gengage-chat-consulting-style-btn").length>a.length;)o.lastElementChild?.remove();return o.querySelectorAll(".gengage-chat-consulting-style-btn").forEach((g,b)=>{g.classList.toggle("gengage-chat-consulting-style-btn--active",b===d.selectedIndex)}),ga(d,d.selectedIndex),!0}function pl(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 ha(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:Ga(t)&&a.length>0,source:t,styleVariations:a}}function hl(e,t,a,n){dl(e,t,a.source,a.styleVariations,n)}function ul(e){return!e.isConsulting||e.styleVariations.length===0?!0:e.styleVariations.some(t=>(typeof t.status=="string"?t.status:"ready")!=="loading")}function ml(e,t,a){return!t.isConsulting||!t.source?!1:gl(e,t.source,t.styleVariations,a)}var fl=`<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"/>
|
|
51
51
|
<rect x="3" y="7" width="18" height="13" rx="3" stroke="currentColor" stroke-width="1.5"/>
|