@gengage/assistant-fe 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/chat.iife.js CHANGED
@@ -1,15 +1,15 @@
1
- (function(ue){"use strict";var bt=typeof document<"u"?document.currentScript:null;const Na=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const a of e.children){const i=t(a);i&&n.appendChild(i)}return n};function Ma(e){const t=document.createElement("div");if(t.className=e.containerClassName,!e.spec.elements[e.spec.root])return t;const a=e.unknownRenderer??Na,i=r=>{const s=e.spec.elements[r];if(!s)return null;const c=e.registry[s.type];return c?c({elementId:r,element:s,spec:e.spec,context:e.context,renderElement:i}):a({elementId:r,element:s,spec:e.spec,context:e.context,renderElement:i})},o=i(e.spec.root);return o&&t.appendChild(o),t}function Ba(e,t){if(!t)return e;const n={...e};for(const[a,i]of Object.entries(t))i&&(n[a]=i);return n}function Ra(e,t){const n={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&&(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 Oa(e,t){const n={request_id:t.request_id,chunk_index:t.chunk_index};t.latency_ms!==void 0&&(n.latency_ms=t.latency_ms);const a={event_name:"stream.chunk",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:n};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 $a(e,t){const n={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&&(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 Da(e,t){const n={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&&(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 Fa(e,t){const n={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&&(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 Ua(e,t){const n={model:t.model,prompt_tokens:t.prompt_tokens,completion_tokens:t.completion_tokens,total_tokens:t.total_tokens};t.provider!==void 0&&(n.provider=t.provider);const a={event_name:"llm.usage",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:n};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 Za(e,t){const n={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&&(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 ja(e,t){const n={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&&(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 qa(e,t){const n={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&&(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 Ha(e,t){const n={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&&(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 Va(e,t){const n={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&&(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 Wa(e,t){const n={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&&(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}const Ga=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"]),Ka=new Set(["script","iframe","object","embed","form","input","textarea","select","button","style","link","meta","template","noscript"]),Wt={"*":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 Ya(e){return/^\s*javascript\s*:/i.test(e)}const Ja=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"]),Xa=/url\s*\(|expression\s*\(|javascript\s*:|\bimport\b|-moz-binding|behavior\s*:/i;function Qa(e){const t=[];for(const n of e.split(";")){const a=n.trim();if(!a)continue;const i=a.indexOf(":");if(i===-1)continue;const o=a.slice(0,i).trim().toLowerCase(),r=a.slice(i+1).trim();Ja.has(o)&&(Xa.test(r)||t.push(a))}return t.join("; ")}function _t(e,t){if(e.nodeType===Node.TEXT_NODE)return;if(e.nodeType!==Node.ELEMENT_NODE){e.parentNode?.removeChild(e);return}const n=e,a=n.tagName.toLowerCase();if(Ka.has(a)){n.parentNode?.removeChild(n);return}if(!Ga.has(a)){const c=Array.from(n.childNodes);for(const l of c)t.insertBefore(l,n);t.removeChild(n);for(const l of c)_t(l,t);return}const i=Wt["*"]??new Set,o=Wt[a]??new Set,r=Array.from(n.attributes);for(const c of r){const l=c.name.toLowerCase();if(!i.has(l)&&!o.has(l)){n.removeAttribute(c.name);continue}if(Ya(c.value)){n.removeAttribute(c.name);continue}if(l==="style"){const d=Qa(c.value);d?n.setAttribute("style",d):n.removeAttribute("style");continue}}if(a==="a"){const c=n.getAttribute("href");if(c!==null){const l=c.trim().toLowerCase();!l.startsWith("http://")&&!l.startsWith("https://")&&!l.startsWith("mailto:")&&n.removeAttribute("href")}n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer")}if(a==="img"){const c=n.getAttribute("src");c!==null&&(c.trim().toLowerCase().startsWith("https://")||n.removeAttribute("src"))}const s=Array.from(n.childNodes);for(const c of s)_t(c,n)}const Gt=["http:","https:"];function Ee(e){try{return Gt.includes(new URL(e).protocol)}catch{return!1}}function ce(e){if(e.startsWith("/")&&!e.startsWith("//"))return!0;try{const t=new URL(e);return Gt.includes(t.protocol)}catch{return!1}}function ae(e,t,n){(t==="href"||t==="src")&&!ce(n)||e.setAttribute(t,n)}function _e(e){if(!e)return"";const n=new DOMParser().parseFromString(e,"text/html").body,a=Array.from(n.childNodes);for(const i of a)_t(i,n);return n.innerHTML}function ve(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!1}))}function Kt(e,t){const n=a=>{t(a.detail)};return window.addEventListener(e,n),()=>window.removeEventListener(e,n)}function ei(){const t=window.__gengageSessionId??sessionStorage.getItem("gengage_session_id")??null??crypto.randomUUID();return window.__gengageSessionId=t,sessionStorage.setItem("gengage_session_id",t),window.gengage||(window.gengage={}),window.gengage.sessionId=t,t}function ti(e){return{sessionId:e?.sessionId??ei(),...e}}const Yt={"--gengage-chat-offset":"20px","--gengage-chat-launcher-size":"56px","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"1rem","--gengage-chat-header-height":"60px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"860px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"0.75rem","--gengage-simrel-card-radius":"0.75rem"};function ni(e){return e?{...Yt,...e}:{...Yt}}const Se="gengage-global-toast-root",Jt="gengage-global-toast-style",vt="gengage-global-toast-root--visible",ai=4200,ii=1500,oi=15e3;let Xt=!1,Me=null;function ri(){Xt||typeof window>"u"||typeof document>"u"||(Xt=!0,Kt("gengage:global:error",e=>{si(e)}))}function si(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;pi();const n=gi();n.innerHTML="";const a=document.createElement("section");a.className="gengage-global-toast gengage-global-toast--error",a.setAttribute("role","status"),a.setAttribute("aria-live","polite");const i=document.createElement("div");i.className="gengage-global-toast-title",i.textContent=li(e.source);const o=document.createElement("div");o.className="gengage-global-toast-message",o.textContent=t,a.appendChild(i),a.appendChild(o),n.appendChild(a),n.classList.add(vt),Me&&(clearTimeout(Me),Me=null),Me=setTimeout(()=>{ci()},di(e.durationMs))}function ci(){if(typeof document>"u")return;const e=document.getElementById(Se);e&&(e.classList.remove(vt),e.innerHTML="",Me&&(clearTimeout(Me),Me=null))}function li(e){switch(e){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function gi(){const e=document.getElementById(Se);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=Se,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function di(e){return typeof e!="number"||!Number.isFinite(e)?ai:Math.min(oi,Math.max(ii,Math.round(e)))}function pi(){if(document.getElementById(Jt))return;const e=document.createElement("style");e.id=Jt,e.textContent=`
2
- #${Se} {
1
+ (function(fe){"use strict";var _t=typeof document<"u"?document.currentScript:null;const Ba=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const a of e.children){const i=t(a);i&&n.appendChild(i)}return n};function Ra(e){const t=document.createElement("div");if(t.className=e.containerClassName,!e.spec.elements[e.spec.root])return t;const a=e.unknownRenderer??Ba,i=r=>{const s=e.spec.elements[r];if(!s)return null;const c=e.registry[s.type];return c?c({elementId:r,element:s,spec:e.spec,context:e.context,renderElement:i}):a({elementId:r,element:s,spec:e.spec,context:e.context,renderElement:i})},o=i(e.spec.root);return o&&t.appendChild(o),t}function Oa(e,t){if(!t)return e;const n={...e};for(const[a,i]of Object.entries(t))i&&(n[a]=i);return n}function $a(e,t){const n={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&&(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 Da(e,t){const n={request_id:t.request_id,chunk_index:t.chunk_index};t.latency_ms!==void 0&&(n.latency_ms=t.latency_ms);const a={event_name:"stream.chunk",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:n};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 Fa(e,t){const n={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&&(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 Ua(e,t){const n={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&&(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 Za(e,t){const n={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&&(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 ja(e,t){const n={model:t.model,prompt_tokens:t.prompt_tokens,completion_tokens:t.completion_tokens,total_tokens:t.total_tokens};t.provider!==void 0&&(n.provider=t.provider);const a={event_name:"llm.usage",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:n};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 qa(e,t){const n={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&&(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 Ha(e,t){const n={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&&(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 Va(e,t){const n={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&&(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 Wa(e,t){const n={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&&(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 Ga(e,t){const n={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&&(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 Ka(e,t){const n={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&&(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}const Ya=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"]),Ja=new Set(["script","iframe","object","embed","form","input","textarea","select","button","style","link","meta","template","noscript"]),Gt={"*":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 Xa(e){return/^\s*javascript\s*:/i.test(e)}const Qa=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"]),ei=/url\s*\(|expression\s*\(|javascript\s*:|\bimport\b|-moz-binding|behavior\s*:/i;function ti(e){const t=[];for(const n of e.split(";")){const a=n.trim();if(!a)continue;const i=a.indexOf(":");if(i===-1)continue;const o=a.slice(0,i).trim().toLowerCase(),r=a.slice(i+1).trim();Qa.has(o)&&(ei.test(r)||t.push(a))}return t.join("; ")}function vt(e,t){if(e.nodeType===Node.TEXT_NODE)return;if(e.nodeType!==Node.ELEMENT_NODE){e.parentNode?.removeChild(e);return}const n=e,a=n.tagName.toLowerCase();if(Ja.has(a)){n.parentNode?.removeChild(n);return}if(!Ya.has(a)){const c=Array.from(n.childNodes);for(const l of c)t.insertBefore(l,n);t.removeChild(n);for(const l of c)vt(l,t);return}const i=Gt["*"]??new Set,o=Gt[a]??new Set,r=Array.from(n.attributes);for(const c of r){const l=c.name.toLowerCase();if(!i.has(l)&&!o.has(l)){n.removeAttribute(c.name);continue}if(Xa(c.value)){n.removeAttribute(c.name);continue}if(l==="style"){const g=ti(c.value);g?n.setAttribute("style",g):n.removeAttribute("style");continue}}if(a==="a"){const c=n.getAttribute("href");if(c!==null){const l=c.trim().toLowerCase();!l.startsWith("http://")&&!l.startsWith("https://")&&!l.startsWith("mailto:")&&n.removeAttribute("href")}n.setAttribute("target","_blank"),n.setAttribute("rel","noopener noreferrer")}if(a==="img"){const c=n.getAttribute("src");c!==null&&(c.trim().toLowerCase().startsWith("https://")||n.removeAttribute("src"))}const s=Array.from(n.childNodes);for(const c of s)vt(c,n)}const Kt=["http:","https:"];function Se(e){try{return Kt.includes(new URL(e).protocol)}catch{return!1}}function le(e){if(e.startsWith("/")&&!e.startsWith("//"))return!0;try{const t=new URL(e);return Kt.includes(t.protocol)}catch{return!1}}function ae(e,t,n){(t==="href"||t==="src")&&!le(n)||e.setAttribute(t,n)}function we(e){if(!e)return"";const n=new DOMParser().parseFromString(e,"text/html").body,a=Array.from(n.childNodes);for(const i of a)vt(i,n);return n.innerHTML}function xe(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!1}))}function Yt(e,t){const n=a=>{t(a.detail)};return window.addEventListener(e,n),()=>window.removeEventListener(e,n)}function ni(){const t=window.__gengageSessionId??sessionStorage.getItem("gengage_session_id")??null??crypto.randomUUID();return window.__gengageSessionId=t,sessionStorage.setItem("gengage_session_id",t),window.gengage||(window.gengage={}),window.gengage.sessionId=t,t}function ai(e){return{sessionId:e?.sessionId??ni(),...e}}const Jt={"--gengage-chat-offset":"20px","--gengage-chat-launcher-size":"56px","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"1rem","--gengage-chat-header-height":"60px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"860px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"0.75rem","--gengage-simrel-card-radius":"0.75rem"};function ii(e){return e?{...Jt,...e}:{...Jt}}const Te="gengage-global-toast-root",Xt="gengage-global-toast-style",yt="gengage-global-toast-root--visible",oi=4200,ri=1500,si=15e3;let Qt=!1,Me=null;function ci(){Qt||typeof window>"u"||typeof document>"u"||(Qt=!0,Yt("gengage:global:error",e=>{li(e)}))}function li(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;ui();const n=pi();n.innerHTML="";const a=document.createElement("section");a.className="gengage-global-toast gengage-global-toast--error",a.setAttribute("role","status"),a.setAttribute("aria-live","polite");const i=document.createElement("div");i.className="gengage-global-toast-title",i.textContent=di(e.source);const o=document.createElement("div");o.className="gengage-global-toast-message",o.textContent=t,a.appendChild(i),a.appendChild(o),n.appendChild(a),n.classList.add(yt),Me&&(clearTimeout(Me),Me=null),Me=setTimeout(()=>{gi()},hi(e.durationMs))}function gi(){if(typeof document>"u")return;const e=document.getElementById(Te);e&&(e.classList.remove(yt),e.innerHTML="",Me&&(clearTimeout(Me),Me=null))}function di(e){switch(e){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function pi(){const e=document.getElementById(Te);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=Te,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function hi(e){return typeof e!="number"||!Number.isFinite(e)?oi:Math.min(si,Math.max(ri,Math.round(e)))}function ui(){if(document.getElementById(Xt))return;const e=document.createElement("style");e.id=Xt,e.textContent=`
2
+ #${Te} {
3
3
  position: fixed;
4
4
  top: 16px;
5
5
  right: 16px;
6
6
  z-index: 2147483646;
7
7
  pointer-events: none;
8
8
  }
9
- #${Se}.${vt} {
9
+ #${Te}.${yt} {
10
10
  pointer-events: auto;
11
11
  }
12
- #${Se} .gengage-global-toast {
12
+ #${Te} .gengage-global-toast {
13
13
  min-width: 260px;
14
14
  max-width: min(92vw, 420px);
15
15
  border-radius: 12px;
@@ -24,12 +24,12 @@
24
24
  line-height: 1.4;
25
25
  animation: gengage-global-toast-in 180ms ease-out forwards;
26
26
  }
27
- #${Se} .gengage-global-toast-title {
27
+ #${Te} .gengage-global-toast-title {
28
28
  margin: 0 0 4px;
29
29
  font-size: 12px;
30
30
  font-weight: 700;
31
31
  }
32
- #${Se} .gengage-global-toast-message {
32
+ #${Te} .gengage-global-toast-message {
33
33
  margin: 0;
34
34
  font-weight: 500;
35
35
  }
@@ -43,8 +43,8 @@
43
43
  transform: translateY(0);
44
44
  }
45
45
  }
46
- `,document.head.appendChild(e)}let We=null;function hi(){if(We!==null)return We;try{We=localStorage.getItem("gengage:debug")==="1"}catch{We=!1}return We}function tt(e,t,n){if(!hi())return;const a=[`[gengage:${e}]`,t];n!==void 0&&a.push(n),console.debug(...a)}class ui{constructor(){this.isVisible=!1,this.isInitialised=!1,this._handlers=new Map,this._cleanups=[],this._ownsRoot=!1,this._destroying=!1}async init(t){if(this.isInitialised){console.warn("[gengage] Widget already initialised. Call update() instead.");return}const n=ni(t.theme);this.config={...t,theme:n,session:ti(t.session)},this.root=this._resolveMount(t.mountTarget),this._applyTheme(n),ri();const a=Kt("gengage:context:update",i=>this.update(i));this._cleanups.push(a),tt("lifecycle",`${this.constructor.name}.init`,{accountId:t.accountId,sku:t.pageContext?.sku});try{await this.onInit(this.config)}catch(i){throw this.destroy(),i}this._destroying||(this.isInitialised=!0,tt("lifecycle",`${this.constructor.name} ready`),this.emit("ready"))}update(t){this.isInitialised&&(this.config.pageContext?this.config={...this.config,pageContext:{...this.config.pageContext,...t}}:t.pageType!==void 0&&(this.config={...this.config,pageContext:t}),this.onUpdate(t),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(t=>t()),this._cleanups.length=0,this._handlers.clear(),this.onDestroy(),this.config.analyticsClient?.destroy(),this._ownsRoot?this.root.remove():this.root.innerHTML="",this.isInitialised=!1)}on(t,n){return this._handlers.has(t)||this._handlers.set(t,new Set),this._handlers.get(t).add(n),()=>this._handlers.get(t)?.delete(n)}trackCheckout(t,n){const a=t==="start"?Va:Wa;this.track(a(this.analyticsContext(),n))}flushMeteringSummary(t){this.track(ja(this.analyticsContext(),t))}emit(t,...n){this._handlers.get(t)?.forEach(a=>a(...n))}addCleanup(t){this._cleanups.push(t)}track(t){this.config.analyticsClient?.track(t)}analyticsContext(){const t={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??""};return this.config.session?.viewId!==void 0&&(t.view_id=this.config.session.viewId),this.config.session?.userId!==void 0&&(t.user_id=this.config.session.userId),this.config.pageContext?.pageType!==void 0&&(t.page_type=this.config.pageContext.pageType),this.config.pageContext?.sku!==void 0&&(t.sku=this.config.pageContext.sku),this.config.session?.abTestVariant!==void 0&&(t.ab_test_variant=this.config.session.abTestVariant),this.config.session?.abTestExperimentId!==void 0&&(t.ab_test_experiment_id=this.config.session.abTestExperimentId),t}_resolveMount(t){if(t instanceof HTMLElement)return t;if(typeof t=="string"){const a=document.querySelector(t);if(!a)throw new Error(`[gengage] Mount target not found: "${t}"`);return a}const n=document.createElement("div");return n.dataset.gengageWidget=this.constructor.name.toLowerCase(),document.body.appendChild(n),this._ownsRoot=!0,n}_applyTheme(t){if(t){for(const[n,a]of Object.entries(t))if(a!==void 0){const i=n.startsWith("--")?n:`--gengage-${fi(n)}`;this.root.style.setProperty(i,a)}}}}function fi(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function yt(){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 n=Array.from(t,a=>a.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}class mi{constructor(t){this._handlers=new Map,this._destroyed=!1,this._namespace=t.namespace,this._allowedOrigins=t.allowedOrigins??[location.origin],this._onMessage=t.onMessage,this._allowedOrigins.includes("*")&&typeof{url:bt&&bt.tagName.toUpperCase()==="SCRIPT"&&bt.src||new URL("chat.iife.js",document.baseURI).href}<"u",this._messageListener=n=>this._handlePostMessage(n),window.addEventListener("message",this._messageListener)}send(t,n){if(this._destroyed)return;const a={namespace:this._namespace,type:t};n!==void 0&&(a.payload=n),window.dispatchEvent(new CustomEvent("gengage:bridge:message",{detail:a,bubbles:!1}))}on(t,n){this._handlers.has(t)||this._handlers.set(t,new Set);const a=this._handlers.get(t);return a.add(n),()=>{a.delete(n),a.size===0&&this._handlers.delete(t)}}destroy(){this._destroyed||(this._destroyed=!0,window.removeEventListener("message",this._messageListener),this._handlers.clear())}_handlePostMessage(t){if(this._destroyed||!this._isOriginAllowed(t.origin))return;const n=t.data;if(!bi(n)||n.gengage!==this._namespace)return;const a={type:n.type};n.payload!==void 0&&(a.payload=n.payload),this._onMessage?.(a);const i=this._handlers.get(a.type);if(i)for(const o of i)o(a.payload)}_isOriginAllowed(t){return this._allowedOrigins.includes("*")?!0:this._allowedOrigins.includes(t)}}function bi(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.gengage=="string"&&typeof t.type=="string"}const _i=console;function vi(e,t,n={}){const a=e.action,i=n.logger??_i;switch(tt("action",`routing action: ${a.kind}`,a),a.kind){case"open_chat":{t.openChat?.(a.payload);return}case"navigate":{if(typeof a.url!="string"){$e(a,t,n,i);return}if(!ce(a.url)){i.warn("[gengage] Blocked navigation to unsafe URL:",a.url);return}const o=typeof a.newTab=="boolean"?a.newTab:void 0;if(t.navigate){t.navigate({url:a.url,...o!==void 0&&{newTab:o}});return}yi(a.url,o);return}case"save_session":{if(typeof a.sessionId!="string"||typeof a.sku!="string"){$e(a,t,n,i);return}t.saveSession?.({sessionId:a.sessionId,sku:a.sku});return}case"add_to_cart":{if(typeof a.sku!="string"||typeof a.quantity!="number"||typeof a.cartCode!="string"){$e(a,t,n,i);return}t.addToCart?.({sku:a.sku,quantity:a.quantity,cartCode:a.cartCode});return}case"script_call":{if(n.allowScriptCall===!1){$e(a,t,n,i);return}if(typeof a.name!="string"){$e(a,t,n,i);return}const o=wi(a.payload)?a.payload:void 0;t.scriptCall?.({name:a.name,...o!==void 0&&{payload:o}});return}default:$e(a,t,n,i)}}function $e(e,t,n,a){const i=n.unknownActionPolicy??"log-and-ignore";if(i==="delegate"){t.unknown?.(e),t.unknown||a.warn("[gengage] Unknown action received without delegate handler",e);return}if(i==="throw")throw new Error(`[gengage] Unknown action kind: ${e.kind}`);a.warn("[gengage] Unknown action ignored",e)}function yi(e,t){if(!(typeof window>"u")){if(!ce(e)){console.warn("[gengage] Blocked navigation to unsafe URL:",e);return}if(t){window.open(e,"_blank","noopener,noreferrer");return}window.location.href=e}}function wi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const xi=["image/jpeg","image/png","image/webp"],ki=5*1024*1024;function Ci(e){return xi.includes(e.type)?e.size>ki?{ok:!1,reason:"too_large"}:{ok:!0}:{ok:!1,reason:"invalid_type"}}function Qt(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function Ei(e){const t=[];let n=0,a=!1,i=!1,o=0;for(let r=0;r<e.length;r++){const s=e[r];if(i){i=!1;continue}if(s==="\\"&&a){i=!0;continue}if(s==='"'){a=!a;continue}a||(s==="{"&&n++,s==="}"&&(n--,n===0&&(t.push(e.slice(o,r+1)),o=r+1)))}return t.length>0?t:[e]}function en(e,t){const n=e.trim();if(!n||n.startsWith(":"))return!1;const a=n.startsWith("data: ")?n.slice(6):n;if(a==="[DONE]")return t.onDone?.(),!0;try{const i=JSON.parse(a);return Qt(i)?(tt("stream",`event: ${i.type}`,i),t.onEvent(i),i.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const i=Ei(a);if(i.length>1){for(const o of i)try{const r=JSON.parse(o);if(!Qt(r))continue;if(t.onEvent(r),r.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function Si(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 n=e.body.getReader(),a=new TextDecoder("utf-8");let i="";const o=t.idleTimeoutMs??6e4,r=Symbol("idle-timeout");let s=!1;try{for(;;){const c=n.read();let l;const d=await(o>0?Promise.race([c.then(b=>(clearTimeout(l),b)),new Promise(b=>{l=setTimeout(()=>b(r),o)})]):c);if(d===r){s=!0,await n.cancel();break}const{done:p,value:g}=d;if(p)break;i+=a.decode(g,{stream:!0});const h=i.split(`
47
- `);i=h.pop()??"";for(const b of h)if(en(b,t))return}if(i.trim()&&en(i,t))return}catch(c){if(c instanceof DOMException&&c.name==="AbortError")return;t.onError?.(c instanceof Error?c:new Error(String(c)))}finally{s||n.releaseLock()}t.onDone?.()}const tn=3,Ti=(e,t)=>{const n=e.replace(/\s+/g," ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g,"");if(!n)return"";const a=t?.stripLeadingStopWords?n.replace(/^(?:daha|için)\s+/i,"").trim():n;return a?a.split(/\s+/).slice(0,3).join(" ").trim():""},wt=(e,t)=>e?e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(n=>Ti(n,t)).filter(Boolean):[];function Ai(e){const t=(e.display_keywords??[]).flatMap(i=>wt(i,{stripLeadingStopWords:!0})),n=t.filter((i,o)=>t.indexOf(i)===o);if(n.length>0)return n.slice(0,tn);const a=[...wt(e.chosen_attribute,{stripLeadingStopWords:!0}),...wt(e.short_name)];return a.filter((i,o)=>a.indexOf(i)===o).slice(0,tn)}function Ii(e){return Ai(e).join(" • ")}function Pi(e){if(typeof e.type!="string")return null;if(Li(e))return e;const n=e;switch(n.type){case"outputText":return zi(n);case"suggestedActions":return Ni(n);case"productList":return Mi(n);case"productDetails":return Bi(n);case"productDetailsSimilars":return Ri(n);case"comparisonTable":return Oi(n);case"context":return Ui(n);case"chatStreamEnd":return Zi();case"loading":return ji(n);case"panelLoading":return qi(n);case"similarLoading":return Hi(n);case"redirect":return Vi(n);case"error":return Wi(n);case"dummy":return Gi();case"launcherAction":return Ki(n);case"text":return xt(n);case"productItem":return Yi(n);case"text_image":return nn(n);case"quick_qna":return an(n);case"reviewHighlights":return Ji(n);case"aiProductSuggestions":return eo(n);case"aiProductGroupings":return to(n);case"aiSuggestedSearches":return no(n);case"prosAndCons":return Xi(n);case"getGroundingReview":return ao(n);case"voice":return oo(n);case"visitorDataResponse":return Qi(n);case"productListPreview":return io();case"groupList":return ro(n);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return so(n);case"launcherContent":return lo(n);case"handoff":return co(n);default:return null}}function Li(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 n=e.widget;if(n!=="chat"&&n!=="qna"&&n!=="simrel")return!1;const a=Ce(e.spec);return a?typeof a.root=="string"&&Ce(a.elements)!==null:!1}case"action":{const n=Ce(e.action);return n!==null&&typeof n.kind=="string"}case"error":return typeof e.code=="string"&&typeof e.message=="string";case"done":return!0;default:return!1}}function zi(e){const t=H(e.payload.text,e.payload.plain_text)??"",n=H(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:n||"Backend returned an error"};const a={type:"text_chunk",content:t,final:!0},i=e.payload.product_mentions;Array.isArray(i)&&i.length>0&&(a.productMentions=i.filter(s=>typeof s=="object"&&s!==null&&typeof s.sku=="string"&&typeof s.short_name=="string"));const o=e.payload.sku_to_product_item;o&&typeof o=="object"&&!Array.isArray(o)&&(a.skuToProductItem=o);const r=e.payload.conversation_mode;return typeof r=="string"&&r&&(a.conversationMode=r),a}function Ni(e){const t=(e.payload.actions??[]).map(n=>{const a=H(n.title)??"",i=ye(n.requestDetails,a),o=i?{label:a,action:i}:null;return o?(typeof n.icon=="string"&&(o.icon=n.icon),typeof n.image=="string"&&(o.image=n.image),o):null});return on(t.filter(sn),"chat")}function Mi(e){const t=rn(e.payload.product_list??[],"chat");t.panelHint="panel";const n=t.spec.elements[t.spec.root];return n&&(typeof e.payload.offset=="number"&&(n.props={...n.props,offset:e.payload.offset}),typeof e.payload.end_of_list=="boolean"&&(n.props={...n.props,endOfList:e.payload.end_of_list}),typeof e.payload.title=="string"&&(n.props={...n.props,panelTitle:e.payload.title})),t}function Bi(e){const t=e.payload.productDetails;return t?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:De(t)}}}},panelHint:"panel"}:po("chat")}function Ri(e){const t=rn(e.payload.similarProducts??[],"chat"),n=t.spec.elements[t.spec.root];return n&&(n.props={...n.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function Oi(e){const t=e.payload.multiple_product_details??[],n=e.payload,a={key_differences:n.key_differences,recommended_choice:n.recommended_choice,recommended_choice_sku:n.recommended_choice_sku,special_considerations:n.special_considerations,criteria_view:n.criteria_view,criteria_view_short:n.criteria_view_short,compared_field_names:n.compared_field_names,winner_product:n.winner_product,winner_hits:n.winner_hits,...e.payload.product_comparison_framework??{}},i=e.payload.table,o=e.payload.features_list,r=[];for(const y of t){const x=De(y);r.push(x)}const s=$i(i,r,a,o);let c;a?.recommended_choice_sku?c=a.recommended_choice_sku:a?.winner_product&&a.winner_product.length>0&&(c=a.winner_product[0]?.product_detail?.sku??a.winner_product[0]?.sku);const l=c?r.find(y=>y.sku===c)??r[0]:r[0],d=[];if(Array.isArray(a?.key_differences))for(const y of a.key_differences)typeof y=="string"&&d.push(y);const p=mo(a?.special_considerations),g=a?.recommended_choice,h=a?.winner_hits,b={};for(const y of r){const x=y.sku;x&&(b[x]={title:y.name??x,type:"launchSingleProduct",payload:{sku:x}})}const _={products:r,attributes:s,highlights:d,productActions:b};return l&&(_.recommended=l),p.length>0&&(_.specialCases=p),g&&(_.recommendedText=g),h&&(_.winnerHits=h),typeof a?.key_differences=="string"&&(_.keyDifferencesHtml=a.key_differences),a?.special_considerations&&(_.specialConsiderations=a.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:_}}},panelHint:"panel"}}function $i(e,t,n,a){if(!e)return[];const i=Object.entries(e);if(i.length===0)return[];const o=i[0]?.[1];if(Array.isArray(o)){const g=n.criteria_view??n.criteria_view_short??{},h=n.compared_field_names??Object.keys(e),b=[];for(const _ of h){const y=e[_];if(!y||!Array.isArray(y))continue;const x=g[_]??_;b.push({label:x,values:y.map(k=>typeof k=="string"?k:String(k??""))})}return b}const r=e,s=t.map(g=>String(g.sku??"")).filter(g=>g.length>0),c=n.criteria_view??n.criteria_view_short??{},d=(a&&a.length>0?a:n.compared_field_names&&n.compared_field_names.length>0?n.compared_field_names:Di(r)).filter(g=>g!=="name"&&g!=="name_short"&&!g.endsWith("_short")),p=[];for(const g of d){const h=s.map(_=>{const y=r[_];if(!y||typeof y!="object")return"";const x=y[`${g}_short`],k=y[g];return Fi(x??k)});if(h.every(_=>_.length===0))continue;const b=c[g]??g;p.push({label:b,values:h})}return p}function Di(e){const t=[],n=new Set;for(const a of Object.values(e))if(!(!a||typeof a!="object"))for(const i of Object.keys(a))n.has(i)||(n.add(i),t.push(i));return t}function Fi(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function Ui(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function Zi(){return{type:"done"}}function ji(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 qi(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Hi(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Vi(e){const t=H(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:H(e.payload.to)}}}function Wi(e){return{type:"error",code:"BACKEND_ERROR",message:H(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function Gi(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function Ki(e){const t=e.payload??{};if(Array.isArray(t.action_list)){const o={action_list:t.action_list},r=typeof t.type=="string"?t.type:void 0,s=typeof t.theme=="string"?t.theme:void 0;return r!==void 0&&(o.type=r),s!==void 0&&(o.theme=s),an({payload:o})}const a=Ce(t.action);if(a){const o={action:a},r=typeof t.text=="string"?t.text:void 0,s=typeof t.image_url=="string"?t.image_url:void 0,c=typeof t.theme=="string"?t.theme:void 0;return r!==void 0&&(o.text=r),s!==void 0&&(o.image_url=s),c!==void 0&&(o.theme=c),nn({payload:o})}const i=typeof t.text=="string"?t.text:"";if(i){const o={text:i},r=typeof t.type=="string"?t.type:void 0,s=typeof t.theme=="string"?t.theme:void 0,c=Ce(t.payload)??void 0;return r!==void 0&&(o.type=r),c!==void 0&&(o.payload=c),s!==void 0&&(o.theme=s),xt({payload:o})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function xt(e){const t={text:H(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 Yi(e){return go(e.payload,"qna")}function nn(e){const t=H(e.payload.text)??"",n=ye(e.payload.action,t);if(n){const i={label:t||n.title,action:n};return typeof e.payload.image_url=="string"&&(i.image=e.payload.image_url),typeof e.payload.theme=="string"&&(i.theme=e.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:i}}}}}const a={text:t};return typeof e.payload.theme=="string"&&(a.theme=e.payload.theme),xt({payload:a})}function an(e){const t=(e.payload.action_list??[]).map(n=>{const a=H(n.title)??"",i=ye(n.requestDetails,a),o=i?{label:a,action:i}:null;return o?(typeof n.icon=="string"&&(o.icon=n.icon),typeof n.image=="string"&&(o.image=n.image),o):null});return on(t.filter(sn),"qna")}function Ji(e){const n={reviews:(e.payload.reviews??[]).map(a=>{const i={};return typeof a.review_class=="string"&&(i.review_class=a.review_class),typeof a.review_text=="string"&&(i.review_text=a.review_text),(typeof a.review_rating=="string"||typeof a.review_rating=="number")&&(i.review_rating=a.review_rating),typeof a.review_tag=="string"&&(i.review_tag=a.review_tag),i})};return typeof e.payload.sku=="string"&&(n.sku=e.payload.sku),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ReviewHighlights",props:n}}}}}function Xi(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 Qi(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function eo(e){const t=e.payload.product_suggestions??[],n=[];for(let a=0;a<t.length;a++){const i=t[a];if(!i)continue;const o=ho(i);if(!o)continue;const r={product:o},s=ye(i.requestDetails,o.name);s&&(r.action=s),typeof i.role=="string"&&(r.role=i.role),typeof i.reason=="string"&&(r.reason=i.reason),typeof i.review_highlight=="string"&&(r.reviewHighlight=i.review_highlight),Array.isArray(i.labels)&&(r.labels=i.labels),typeof i.expert_quality_score=="number"&&(r.expertQualityScore=i.expert_quality_score),n.push(r)}return n.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:n}}}}}}function to(e){const t=e.payload.product_groupings??[],n=[];for(let a=0;a<t.length;a++){const i=t[a];if(!i)continue;const o=H(i.name)??"",r=i.sku&&i.sku.length>0?{type:"findSimilar",payload:{sku:i.sku}}:void 0,s=ye(i.requestDetails??r,o);if(!s)continue;const c={name:o,action:s};if(Array.isArray(i.labels)){const l=i.labels.filter(d=>typeof d=="string");l.length>0&&(c.labels=l)}typeof i.image=="string"&&(c.image=i.image),n.push(c)}return 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 no(e){const t=e.payload.suggested_searches??[],n=[];for(let a=0;a<t.length;a++){const i=t[a];if(!i)continue;const o=H(i.short_name,i.chosen_attribute,i.detailed_user_message)??`Search ${a+1}`,r={},s=H(i.detailed_user_message);s&&(r.text=s);const c=Ce(i.requestDetails),l=Ce(c?.payload),d=l?.group_skus;i.group_skus&&Array.isArray(i.group_skus)?r.group_skus=i.group_skus:Array.isArray(d)&&(r.group_skus=d.filter(k=>typeof k=="string"));const p=H(i.sku,i.representative_product_sku,l?.sku);p&&(r.sku=p),r.is_suggested_text=1;const g={type:"inputText",payload:r},h=ye(i.requestDetails,o),b=h?.type==="findSimilar"&&typeof r.text=="string"?ye(g,o):h??ye(g,o);if(!b)continue;const _={shortName:o,action:b},y=H(i.detailed_user_message);y&&y!==o&&(_.detailedMessage=y);const x=Ii(i);x&&x!==o&&x!==(y??"")&&(_.whyDifferent=x),typeof i.image=="string"&&(_.image=i.image),n.push(_)}return n.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:n}}}}}}function ao(e){const t=ye(e.payload.requestDetails,H(e.payload.review_count,e.payload.text,e.payload.title)??"Show product reviews");if(!t)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:e.payload}};const n={action:t};return e.payload.title&&(n.title=e.payload.title),e.payload.text&&(n.text=e.payload.text),e.payload.review_count&&(n.reviewCount=e.payload.review_count),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:n}}}}}function io(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function oo(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function ro(e){const t=e.payload.group_list??[],n=[];for(const i of t){const o=i.group_name??"",r=(i.product_list??[]).map(De);n.push({groupName:o,products:r})}const a=[];for(const i of e.payload.filter_tags??[]){const o=i.title??"";if(!o)continue;const r=ye(i.requestDetails,o),s={title:o};r&&(s.action=r),a.push(s)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:n,filterTags:a}}}},panelHint:"panel"}}function so(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function co(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 lo(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function on(e,t){const n={},a=[];for(let i=0;i<e.length;i++){const o=e[i];if(!o)continue;const r=`action-${i}`;a.push(r);const s={label:o.label,action:o.action};o.icon!==void 0&&(s.icon=o.icon),o.image!==void 0&&(s.image=o.image),o.description!==void 0&&(s.description=o.description),n[r]={type:"ActionButton",props:s}}return n.root={type:"ActionButtons",props:{buttons:e.map(i=>{const o={label:i.label,action:i.action};return i.image!==void 0&&(o.image=i.image),i.description!==void 0&&(o.description=i.description),i.icon!==void 0&&(o.icon=i.icon),o})},children:a},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function rn(e,t){const n={},a=[];for(let i=0;i<e.length;i++){const o=e[i];if(!o)continue;const r=`product-${i}`;a.push(r),n[r]={type:"ProductCard",props:{product:De(o),index:i}}}return n.root={type:"ProductGrid",props:{layout:"grid"},children:a},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function go(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:De(e),index:0}}}}}}function po(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function ho(e){const t=H(e.sku),n=H(e.short_name),a=Ce(e.product_item)??e;return uo(a,t,n)}function uo(e,t,n){const a=H(e.sku,t),i=H(e.name,n);if(!a||!i)return null;const o={sku:a,name:i},r=H(e.brand);r&&(o.brand=r);const s=H(e.url);s&&(o.url=s);const c=fo(e.images);if(c.length>0)o.images=c;else{const b=H(e.image,e.image_url,e.imageUrl);b&&(o.images=[b])}const l=Ge(e.price_discounted);l!==void 0&&(o.price_discounted=l);const d=Ge(e.price);d!==void 0&&(o.price=d);const p=Ge(e.rating);p!==void 0&&(o.rating=p);const g=Ge(e.review_count)??Ge(e.reviewCount);g!==void 0&&(o.review_count=g);const h=H(e.cart_code,e.cartCode);return h&&(o.cart_code=h),typeof e.in_stock=="boolean"&&(o.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(o.in_stock=e.inStock),De(o)}function ye(e,t){const n=Ce(e);if(!n)return null;const a=n.type;if(typeof a!="string"||a.length===0)return null;const i={title:t||a,type:a};return n.payload!==void 0&&(i.payload=n.payload),i}function Ce(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function H(...e){for(const t of e)if(typeof t=="string"){const n=t.trim();if(n.length>0)return n}}function fo(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function mo(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 Ge(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 n=Number(t);if(Number.isFinite(n))return n}}function sn(e){return e!=null}const bo=new Set(["sku","name","brand","images","price","price_discounted","price_currency","discount_reason","url","rating","review_count","cart_code","in_stock","category_ids","category_names","variants","facet_hits","promotions"]);function De(e){const t=e.price_discounted!=null&&e.price_discounted>0,n=t?e.price_discounted:e.price,a=t&&e.price!=null?e.price:void 0;let i;a!=null&&n!=null&&a>0&&(i=Math.round((a-n)/a*100));const o=H(e.brand),r=H(e.name)??e.sku,s=o&&!r.toLowerCase().startsWith(o.toLowerCase())?`${o} ${r}`:r,c={sku:e.sku,name:s,url:H(e.url)??""},l=e.images?.[0];l&&(c.imageUrl=l),e.images&&e.images.length>1&&(c.images=e.images),n!=null&&(c.price=String(n)),a!=null&&(c.originalPrice=String(a)),i!==void 0&&(c.discountPercent=i),o!==void 0&&(c.brand=o),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);const d=e,p={};let g=!1;for(const h of Object.keys(d))bo.has(h)||(p[h]=d[h],g=!0);return g&&(c.extras=p),c}const _o={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"};function vo(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 yo(e,t){return`${vo(t?.middlewareUrl)}/chat${_o[e]}`}function wo(e,t){const n=e.type,a=e.payload!=null&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:{},i=o=>{const r={...a};for(const[s,c]of Object.entries(o))s in r||(r[s]=c);return r};switch(n){case"inputText":{const o={is_launcher:0};return t.pageContext?.extra&&(o.page_details=t.pageContext.extra),"is_suggested_text"in a||(o.is_suggested_text=0),{...e,payload:i(o)}}case"findSimilar":{const o={is_launcher:0};return e.title&&(o.text=e.title,o.input=e.title),{...e,payload:i(o)}}case"getComparisonTable":return e;case"addToCart":{const o={};return"error_message"in a||(o.error_message=""),{...e,payload:i(o)}}case"reviewSummary":{const o={};return t.pageContext?.sku&&!("sku"in a)&&(o.sku=t.pageContext.sku),Object.keys(o).length===0?e:{...e,payload:i(o)}}default:return e}}const xo={user_message:"inputText"};function ko(e){const{action:t,type:n,payload:a,...i}=e,o=n??t?.type??"inputText",r=a??t?.payload,s=xo[o]??o,c={...i,type:s};return r!==void 0&&(c.payload=typeof r=="string"?{text:r}:r),JSON.stringify(c)}function Co(e,t,n){const a=yo("process_action",n),i=new AbortController;return(async()=>{try{const r=ko(e),s=n.attachment!==void 0;let c;if(s){const g=new FormData;g.append("request",r),n.attachment!==void 0&&g.append("attachment",n.attachment),c={method:"POST",body:g,signal:i.signal}}else c={method:"POST",headers:{"Content-Type":"application/json"},body:r,signal:i.signal};const l=await fetch(a,c);if(!l.ok){let g=l.statusText;try{const h=await l.json(),b=h.detail??h.message??h.error;typeof b=="string"&&(g=b)}catch{}t.onError(new Error(`HTTP ${l.status}: ${g}`));return}let d=!1;const p=()=>{d||(d=!0,t.onDone())};await Si(l,{onEvent:g=>{const h=Pi(g);if(h)switch(h.type){case"text_chunk":t.onTextChunk(h.content,h.final===!0,{productMentions:h.productMentions,skuToProductItem:h.skuToProductItem,conversationMode:h.conversationMode});break;case"ui_spec":t.onUISpec(h.spec,h.widget,h.panelHint);break;case"action":t.onAction(h);break;case"metadata":t.onMetadata(h);break;case"error":t.onError(new Error(h.message));break;case"done":p();break}},onError:t.onError,signal:i.signal}),p()}catch(r){if(r instanceof DOMException&&r.name==="AbortError")return;t.onError(r instanceof Error?r:new Error(String(r)))}})(),i}const Eo=["chat_debug","presentation_debug"],So=["gengage_chat_debug","gengage_presentation_debug"];function To(){if(typeof window>"u")return!1;const e=new URLSearchParams(window.location.search);if(Eo.some(t=>e.get(t)==="1"))return!0;try{return So.some(t=>window.localStorage.getItem(t)==="1")}catch{return!1}}function Ao(e,t,n){if(!To())return;const a=(window.__gengageChatPresentationDebugSeq??0)+1;window.__gengageChatPresentationDebugSeq=a;const i={seq:a,time:new Date().toISOString(),scope:e,message:t,payload:n};window.__gengageChatPresentationDebugLog||(window.__gengageChatPresentationDebugLog=[]),window.__gengageChatPresentationDebugLog.push(i),window.__gengageChatPresentationDebugLog.length>400&&window.__gengageChatPresentationDebugLog.shift();const o=`[gengage-chat-debug #${a}][${e}] ${t}`;n===void 0?console.debug(o):console.debug(o,n)}const nt="gengage-chat-scroll";let Fe=null;function cn(e){Fe=e}function Io(){if(Fe&&Fe.isConnected)return Fe;Fe=null;const e=document.getElementById(nt);return e||(Ao("chat-scroll","failed to resolve scroll container (not registered)",{id:nt}),null)}function ln(){Fe=null}const kt={headerTitle:"Ürün Uzmanı",inputPlaceholder:"Ürün ara, soru sor",sendButton:"Gönder",closeButton:"Kapat",openButton:"Sohbeti aç",newChatButton:"Yeni sohbet",poweredBy:"Powered by Gengage",errorMessage:"Bir hata oluştu. Lütfen tekrar deneyin.",retryButton:"Tekrar Dene",loadingMessage:"Düşünüyorum...",productCtaLabel:"İncele",attachImageButton:"Resim ekle",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:"En Beğendiğim",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 ↑",sortPriceDesc:"Fiyat ↓",compareSelected:"Karşılaştır",compareMinHint:"En az 2 ürün seçin",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",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",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.",stillWorkingMessage:"İsteğiniz üzerinde hâlâ çalışılıyor...",cartAriaLabel:"Sepetim",favoritesAriaLabel:"Favorilerim",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",dismissAriaLabel:"Kapat",cartAddErrorMessage:"Üzgünüm sepete ekleyemedim, bir sorunla karşılaştım.",reviewFilterAll:"Tümü",reviewFilterPositive:"Olumlu",reviewFilterNegative:"Olumsuz",decreaseLabel:"Azalt",increaseLabel:"Artır",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"},Po={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:"Thinking...",productCtaLabel:"View",attachImageButton:"Attach image",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:"Related",sortPriceAsc:"Price ↑",sortPriceDesc:"Price ↓",compareSelected:"Compare",compareMinHint:"Select at least 2 products",panelTitleProductDetails:"Product Details",panelTitleSimilarProducts:"Similar Products",panelTitleComparisonResults:"Comparison Results",panelTitleCategories:"Categories",panelTitleSearchResults:"Search Results",inStockLabel:"In Stock",outOfStockLabel:"Out of Stock",findSimilarLabel:"Find Similar",choicePrompterHeading:"Can't decide?",choicePrompterSuggestion:"Select products to compare them",choicePrompterCta:"Select & Compare",viewMoreLabel:"Show More",similarProductsLabel:"Similar Products",addToCartButton:"Add 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.",stillWorkingMessage:"Still working on your request...",cartAriaLabel:"My cart",favoritesAriaLabel:"My favorites",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",dismissAriaLabel:"Dismiss",cartAddErrorMessage:"Sorry, I couldn't add that to your cart. Something went wrong.",reviewFilterAll:"All",reviewFilterPositive:"Positive",reviewFilterNegative:"Negative",decreaseLabel:"Decrease",increaseLabel:"Increase",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"};function Lo(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function zo(e){return Lo(e)==="en"?Po:kt}function No(){return gn()!==null}function gn(){const e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition??null}class Mo{constructor(t,n){this.recognition=null,this._state="idle",this.silenceTimer=null,this.accumulatedTranscript="",this.intentionalStop=!1,this._lastRestartAt=0,this.callbacks=t,this.lang=n?.lang??"tr-TR",this.silenceTimeoutMs=n?.silenceTimeoutMs??1500,this.autoSubmit=n?.autoSubmit??!0}get state(){return this._state}start(){if(this._state==="listening")return;const t=gn();if(!t){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 n=new t;n.continuous=!0,n.interimResults=!0,n.lang=this.lang,n.maxAlternatives=1,n.onstart=()=>{this.setState("listening")},n.onresult=a=>{this.clearSilenceTimer();let i="",o="";for(let r=a.resultIndex;r<a.results.length;r++){const s=a.results[r];if(!s)continue;const c=s[0];c&&(s.isFinal?o+=c.transcript:i+=c.transcript)}o&&(this.accumulatedTranscript+=o,this.callbacks.onFinal?.(this.accumulatedTranscript)),i&&this.callbacks.onInterim?.(this.accumulatedTranscript+i),this.autoSubmit&&this.accumulatedTranscript&&this.startSilenceTimer()},n.onerror=a=>{const i=Bo(a.error);this.intentionalStop&&(a.error==="no-speech"||a.error==="aborted")||(this.setState("error"),this.callbacks.onError?.(i,a.message||a.error))},n.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{n.start()}catch{this.setState("idle")}return}this.setState("idle")},this.recognition=n;try{n.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(t){this._state!==t&&(this._state=t,this.callbacks.onStateChange?.(t))}startSilenceTimer(){this.clearSilenceTimer(),this.silenceTimer=setTimeout(()=>{const t=this.stop();t.trim()&&this.callbacks.onAutoSubmit?.(t.trim())},this.silenceTimeoutMs)}clearSilenceTimer(){this.silenceTimer!==null&&(clearTimeout(this.silenceTimer),this.silenceTimer=null)}}function Bo(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 Ro(e){const t=document.createElement("div");t.className="gengage-chat-kvkk-banner",t.setAttribute("role","alert");const n=document.createElement("div");n.className="gengage-chat-kvkk-content",n.innerHTML=_e(e.htmlContent),t.appendChild(n);const a=document.createElement("button");return a.className="gengage-chat-kvkk-dismiss",a.type="button",a.setAttribute("aria-label",e.closeAriaLabel??"Close privacy notice"),a.textContent="×",a.addEventListener("click",e.onDismiss),t.appendChild(a),t}class Oo{constructor(t){this._el=document.createElement("div"),this._el.className="gengage-chat-panel-topbar",this._backBtn=document.createElement("button"),this._backBtn.className="gengage-chat-panel-topbar-back",this._backBtn.type="button",this._backBtn.disabled=!0,this._backBtn.setAttribute("aria-label",t.backAriaLabel??"Back"),this._backBtn.title=t.backAriaLabel??"Back",this._backBtn.textContent="←",this._backBtn.addEventListener("click",()=>t.onBack()),this._titleEl=document.createElement("span"),this._titleEl.className="gengage-chat-panel-topbar-title",this._forwardBtn=document.createElement("button"),this._forwardBtn.className="gengage-chat-panel-topbar-forward",this._forwardBtn.type="button",this._forwardBtn.disabled=!0,this._forwardBtn.setAttribute("aria-label",t.forwardAriaLabel??"Forward"),this._forwardBtn.title=t.forwardAriaLabel??"Forward",this._forwardBtn.textContent="→",this._forwardBtn.addEventListener("click",()=>t.onForward()),this._el.appendChild(this._backBtn),this._el.appendChild(this._titleEl),this._el.appendChild(this._forwardBtn)}update(t,n,a){this._backBtn.disabled=!t,this._forwardBtn.disabled=!n,this._titleEl.textContent=a}getElement(){return this._el}getTitle(){return this._titleEl.textContent??""}}class $o{constructor(t){this._onThumbnailClick=t.onThumbnailClick,this._el=document.createElement("div"),this._el.className="gengage-chat-thumbnails-column",this._el.style.display="none"}getElement(){return this._el}setEntries(t){const n=new Set,a=[];for(const i of t)n.has(i.sku)||(n.add(i.sku),a.push(i));this._el.innerHTML="";for(const i of a){const o=document.createElement("button");if(o.type="button",o.className="gengage-chat-thumbnail-btn",o.title=i.sku,Ee(i.imageUrl)){const r=document.createElement("img");r.className="gengage-chat-thumbnail-img",r.src=i.imageUrl,r.alt=i.sku,r.width=40,r.height=40,o.appendChild(r)}o.addEventListener("click",()=>{this._onThumbnailClick(i.threadId)}),this._el.appendChild(o)}}show(){this._el.style.display=""}hide(){this._el.style.display="none"}}const dn='<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>',pn={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>'},Do=kt;class Fo{constructor(t,n){this._panelVisible=!1,this._panelCollapsed=!1,this._onPanelToggle=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._stillWorkingTimer=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._options=n,this.i18n={...Do,...n.i18n},this.onSend=n.onSend,n.onPanelToggle!==void 0&&(this._onPanelToggle=n.onPanelToggle),n.onAttachment!==void 0&&(this._onAttachment=n.onAttachment),n.onRollback!==void 0&&(this._onRollback=n.onRollback),n.onLinkClick!==void 0&&(this._onLinkClick=n.onLinkClick),n.voiceEnabled&&(this._voiceEnabled=!0),n.voiceLang!==void 0&&(this._voiceLang=n.voiceLang),this.root=document.createElement("div"),this.root.className="gengage-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",i=document.createElement("span");i.id=a,i.className="gengage-sr-only",i.textContent=this.i18n.headerTitle??"AI shopping assistant",this.root.appendChild(i),this.root.setAttribute("aria-describedby",a);{const f=document.createElement("div");f.className="gengage-chat-drawer-handle",f.setAttribute("aria-hidden","true"),this.root.appendChild(f);const $=72;let se=0,oe=0,xe=!1;const Ht=ke=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768))return;const de=ke.changedTouches?.[0];de&&(se=de.clientY,oe=0,xe=!0,this.root.style.transition="none")},Vt=ke=>{if(!xe)return;const de=ke.changedTouches?.[0];if(!de)return;oe=de.clientY-se;const fp=(n.getMobileState?.()??"full")==="full"?Math.max(0,oe):oe;ke.preventDefault(),this.root.style.transform=`translateY(${fp}px)`},Oe=()=>{if(!xe)return;xe=!1;const ke=n.getMobileState?.()??"full";let de;oe>$?de=ke==="full"?"half":"close":oe<-$&&ke==="half"?de="full":de=ke,this.root.style.transition="",de==="close"?(this.root.style.transform="translateY(100%)",setTimeout(()=>{this.root.style.transform="",n.onMobileSnap?.("close")},280)):(this.root.style.transform="",n.onMobileSnap?.(de)),oe=0},et=()=>{xe&&(xe=!1,oe=0,this.root.style.transition="",this.root.style.transform="")};f.addEventListener("touchstart",Ht,{passive:!0}),f.addEventListener("touchmove",Vt,{passive:!1}),f.addEventListener("touchend",Oe,{passive:!0}),f.addEventListener("touchcancel",et,{passive:!0}),this._cleanups.push(()=>{f.removeEventListener("touchstart",Ht),f.removeEventListener("touchmove",Vt),f.removeEventListener("touchend",Oe),f.removeEventListener("touchcancel",et)})}const o=document.createElement("div");o.className="gengage-chat-header";const r=document.createElement("div");r.className="gengage-chat-header-left";const s=n.headerAvatarUrl??n.launcherImageUrl;if(s){const f=document.createElement("img");f.className="gengage-chat-header-avatar",f.src=s,f.alt=n.headerTitle??"Assistant",r.appendChild(f)}const c=document.createElement("div");c.className="gengage-chat-header-info";const l=document.createElement("div");l.className="gengage-chat-header-title-row";const d=document.createElement("span");if(d.className="gengage-chat-header-title",d.textContent=n.headerTitle??this.i18n.headerTitle??"Product Expert",l.appendChild(d),n.headerBadge){const f=document.createElement("span");f.className="gengage-chat-header-badge",f.textContent=n.headerBadge,l.appendChild(f)}c.appendChild(l);const p=document.createElement("a");p.className="gengage-chat-header-powered",p.href="https://gengage.ai/",p.target="_blank",p.rel="noopener noreferrer",p.innerHTML='<svg viewBox="0 0 16 16" fill="currentColor"><path d="M8 1a7 7 0 110 14A7 7 0 018 1zm0 1.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM7 4.5h2v4H7v-4zm0 5h2v2H7v-2z"/></svg>Powered by Gengage',c.appendChild(p),r.appendChild(c),o.appendChild(r);const g=document.createElement("div");g.className="gengage-chat-header-right";{const f=document.createElement("button");f.type="button",f.className="gengage-chat-header-btn gengage-chat-header-btn--reopen-panel",f.setAttribute("aria-label",this.i18n.showPanelAriaLabel),f.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>',f.addEventListener("click",()=>this._showMobilePanelFromBtn()),g.appendChild(f),this._reopenPanelBtn=f}{const f=document.createElement("button");f.type="button",f.className="gengage-chat-header-btn",f.setAttribute("aria-label",this.i18n.cartAriaLabel),f.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>',f.addEventListener("click",()=>n.onCartClick?.()),g.appendChild(f)}if(n.onNewChat){const f=document.createElement("button");f.className="gengage-chat-header-btn gengage-chat-new-chat",f.type="button",f.setAttribute("aria-label",this.i18n.newChatButton),f.title=this.i18n.newChatButton,f.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>',f.addEventListener("click",()=>n.onNewChat?.()),g.appendChild(f)}const h=document.createElement("button");h.className="gengage-chat-close",h.type="button",h.setAttribute("aria-label",this.i18n.closeButton),h.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>',h.addEventListener("click",n.onClose);{const f=document.createElement("button");f.className="gengage-chat-header-btn gengage-chat-header-btn--fav",f.type="button",f.setAttribute("aria-label",this.i18n.favoritesAriaLabel),f.setAttribute("aria-pressed","false"),f.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 $=document.createElement("span");$.className="gengage-chat-header-fav-badge",$.setAttribute("aria-hidden","true"),$.style.display="none",f.appendChild($),this._favBadgeEl=$,f.addEventListener("click",()=>{const se=f.getAttribute("aria-pressed")==="true";f.setAttribute("aria-pressed",String(!se)),n.onFavoritesClick?.()}),g.appendChild(f)}g.appendChild(h),o.appendChild(g);const b=document.createElement("div");b.className="gengage-chat-body",this._panelEl=document.createElement("div"),this._panelEl.className="gengage-chat-panel",this._panelTopBar=new Oo({onBack:()=>n.onPanelBack?.(),onForward:()=>n.onPanelForward?.(),backAriaLabel:this.i18n.backAriaLabel,forwardAriaLabel:this.i18n.forwardAriaLabel}),this._panelEl.appendChild(this._panelTopBar.getElement());const _=()=>this._updateScrollAffordance();this._panelEl.addEventListener("scroll",_,{passive:!0}),this._cleanups.push(()=>this._panelEl.removeEventListener("scroll",_)),b.appendChild(this._panelEl),this._dividerEl=document.createElement("div"),this._dividerEl.className="gengage-chat-panel-divider gengage-chat-panel-divider--hidden",this._dividerEl.setAttribute("role","separator"),this._dividerEl.setAttribute("aria-label",this.i18n.togglePanelAriaLabel),this._dividerEl.setAttribute("title",this.i18n.togglePanelAriaLabel);const y=document.createElement("button");y.className="gengage-chat-panel-divider-toggle",y.type="button",y.setAttribute("aria-label",this.i18n.togglePanelAriaLabel),y.setAttribute("title",this.i18n.togglePanelAriaLabel),y.textContent="»",y.addEventListener("click",()=>{if(this._ignoreNextDividerClick){this._ignoreNextDividerClick=!1;return}this.togglePanel(),this._onPanelToggle?.()});let x=null,k=null;const I=24,m=f=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768))return;const $=f.changedTouches?.[0];$&&(x=$.clientX,k=$.clientY)},C=f=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768)||x===null||k===null)return;const $=f.changedTouches?.[0];if(!$)return;const se=$.clientX-x,oe=$.clientY-k;if(x=null,k=null,Math.abs(oe)<I||Math.abs(oe)<Math.abs(se))return;const xe=oe<0;xe!==this._panelCollapsed&&(this._ignoreNextDividerClick=!0,this.setPanelCollapsed(xe),this._onPanelToggle?.())};this._dividerEl.addEventListener("touchstart",m,{passive:!0}),this._dividerEl.addEventListener("touchend",C,{passive:!0}),this._cleanups.push(()=>{this._dividerEl.removeEventListener("touchstart",m),this._dividerEl.removeEventListener("touchend",C)}),this._dividerEl.appendChild(y),b.appendChild(this._dividerEl);const B=document.createElement("div");B.className="gengage-chat-conversation",this._conversationEl=B,B.appendChild(o);const D=document.createElement("div");D.className="gengage-chat-offline-bar",D.setAttribute("role","status"),D.setAttribute("aria-live","polite"),D.textContent=this.i18n.offlineMessage,typeof navigator<"u"&&!navigator.onLine&&D.classList.add("gengage-chat-offline-bar--visible"),B.appendChild(D);const E=()=>D.classList.add("gengage-chat-offline-bar--visible"),A=()=>D.classList.remove("gengage-chat-offline-bar--visible");window.addEventListener("offline",E),window.addEventListener("online",A),this._cleanups.push(()=>{window.removeEventListener("offline",E),window.removeEventListener("online",A)}),this._kvkkSlot=document.createElement("div"),this._kvkkSlot.className="gengage-chat-kvkk-slot",B.appendChild(this._kvkkSlot),this.messagesEl=document.createElement("div"),this.messagesEl.id=nt,this.messagesEl.className="gengage-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),cn(this.messagesEl);const S=document.createElement("button");S.type="button",S.className="gengage-chat-former-messages-btn",S.textContent=this.i18n.showFormerMessagesButton,S.setAttribute("aria-label",this.i18n.showFormerMessagesButton),S.style.display="none",S.addEventListener("click",()=>{this._options.presentation?.onReleasePresentationFocus?.()}),this.messagesEl.appendChild(S),this._formerMessagesBtn=S;const R=()=>{this._userInteractionUntil=Date.now()+2e3};let ne=!1;const U=()=>this._options.presentation,v=()=>{ne||(ne=!0,requestAnimationFrame(()=>{ne=!1;const{scrollTop:f,scrollHeight:$,clientHeight:se}=this.messagesEl,oe=$-f-se;this._userScrolledUp=oe>10;const Oe=this._presentationPinned?oe<96:oe<32,et=Date.now(),ke=et<this._programmaticScrollUntil,de=!Oe&&et<this._userInteractionUntil,mt=ke?!1:de;Oe!==this._presentationPinned&&(this._presentationPinned=Oe,U()?.onPinnedToBottomChange?.(Oe)),mt!==this._presentationUserInteracting&&(this._presentationUserInteracting=mt,U()?.onUserInteractingChange?.(mt))}))};this.messagesEl.addEventListener("scroll",v,{passive:!0}),this._cleanups.push(()=>{this.messagesEl.removeEventListener("scroll",v)});const L=f=>{R(),f.deltaY<-6&&this._presentationFocusThreadId&&this._options.presentation?.onFormerMessagesHint?.()};this.messagesEl.addEventListener("wheel",L,{passive:!0}),this._cleanups.push(()=>this.messagesEl.removeEventListener("wheel",L));const P=f=>{R(),this._touchStartY=f.touches[0]?.clientY??null},T=f=>{R();const $=f.touches[0]?.clientY,se=this._touchStartY;typeof $=="number"&&typeof se=="number"&&$-se>10&&this._presentationFocusThreadId&&this._options.presentation?.onFormerMessagesHint?.()};this.messagesEl.addEventListener("touchstart",P,{passive:!0}),this.messagesEl.addEventListener("touchmove",T,{passive:!0}),this._cleanups.push(()=>{this.messagesEl.removeEventListener("touchstart",P),this.messagesEl.removeEventListener("touchmove",T)}),B.appendChild(this.messagesEl),this._thumbnailsColumn=new $o({onThumbnailClick:f=>n.onThumbnailClick?.(f)}),this._panelEl.appendChild(this._thumbnailsColumn.getElement()),this._panelFloatingEl=document.createElement("div"),this._panelFloatingEl.className="gengage-chat-panel-float",this._panelEl.appendChild(this._panelFloatingEl),this._resetPanelAiZoneElement(),this._pillsEl=document.createElement("div"),this._pillsEl.className="gengage-chat-pills",this._pillsEl.setAttribute("role","toolbar"),this._pillsEl.setAttribute("aria-label",this.i18n.suggestionsAriaLabel),this._pillsEl.style.display="none";const N=document.createElement("div");N.className="gengage-chat-pills-scroll",this._pillsEl.appendChild(N);const M=document.createElement("button");M.className="gengage-chat-pills-arrow",M.type="button",M.setAttribute("aria-label",this.i18n.moreSuggestionsAriaLabel),M.textContent="›",M.addEventListener("click",()=>{N.scrollBy({left:150,behavior:"smooth"})}),this._pillsEl.appendChild(M);let ee=!1;const W=()=>{ee||(ee=!0,requestAnimationFrame(()=>{ee=!1;const f=N.scrollLeft+N.clientWidth>=N.scrollWidth-4;M.style.display=f?"none":""}))};N.addEventListener("scroll",W,{passive:!0}),this._cleanups.push(()=>{N.removeEventListener("scroll",W)}),B.appendChild(this._pillsEl),this._inputChipsEl=document.createElement("div"),this._inputChipsEl.className="gengage-chat-input-chips",this._inputChipsEl.style.display="none",B.appendChild(this._inputChipsEl);const Y=document.createElement("div");Y.className="gengage-chat-input-area",this.inputEl=document.createElement("textarea"),this.inputEl.className="gengage-chat-input",this.inputEl.rows=1,this.inputEl.placeholder=this.i18n.inputPlaceholder,this.inputEl.addEventListener("input",()=>{requestAnimationFrame(()=>{this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,120)}px`}),this._updateSendEnabled()}),this.inputEl.addEventListener("keydown",f=>{f.key==="Enter"&&((this._options.getMobileViewport?.()??window.innerWidth<=768)||!f.shiftKey)&&(f.preventDefault(),this._submit())}),this.inputEl.addEventListener("paste",f=>{const $=f.clipboardData?.files[0];if($&&$.type.startsWith("image/"))if(f.preventDefault(),this._onAttachment)try{this._onAttachment($)}catch(se){console.error("[gengage:chat] Attachment callback error:",se)}else this.stageAttachment($)}),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 f=this._fileInput.files?.[0];if(f)if(this._onAttachment)try{this._onAttachment(f)}catch($){console.error("[gengage:chat] Attachment callback error:",$)}else this.stageAttachment(f);this._fileInput.value=""});const he=document.createElement("button");he.className="gengage-chat-attach-btn",he.type="button",he.setAttribute("aria-label",this.i18n.attachImageButton),he.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>',he.addEventListener("click",()=>this._fileInput.click()),this._previewStrip=document.createElement("div"),this._previewStrip.className="gengage-chat-attachment-preview gengage-chat-attachment-preview--hidden";const Ne=document.createElement("img");Ne.className="gengage-chat-attachment-preview-thumb",Ne.alt="",this._previewName=document.createElement("span"),this._previewName.className="gengage-chat-attachment-name";const Z=document.createElement("button");Z.className="gengage-chat-attachment-remove",Z.type="button",Z.setAttribute("aria-label",this.i18n.removeAttachmentButton),Z.textContent="×",Z.addEventListener("click",()=>this.clearAttachment()),this._previewStrip.appendChild(Ne),this._previewStrip.appendChild(this._previewName),this._previewStrip.appendChild(Z),this.sendBtn=document.createElement("button"),this.sendBtn.className="gengage-chat-send",this.sendBtn.type="button",this.sendBtn.disabled=!0,this.sendBtn.setAttribute("aria-label",this.i18n.sendButton),this.sendBtn.innerHTML='<svg viewBox="0 0 24 24" fill="currentColor"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/></svg>',this.sendBtn.addEventListener("click",()=>this._submit()),Y.addEventListener("dragover",f=>{f.preventDefault(),Y.classList.add("gengage-chat-input-area--dragover")}),Y.addEventListener("dragleave",()=>{Y.classList.remove("gengage-chat-input-area--dragover")}),Y.addEventListener("drop",f=>{f.preventDefault(),Y.classList.remove("gengage-chat-input-area--dragover");const $=f.dataTransfer?.files[0];if($)if(this._onAttachment)try{this._onAttachment($)}catch(se){console.error("[gengage:chat] Attachment callback error:",se)}else this.stageAttachment($)});const j=document.createElement("div");j.className="gengage-chat-input-pill",j.appendChild(he),j.appendChild(this.inputEl),this._voiceEnabled&&No()&&(this._micBtn=document.createElement("button"),this._micBtn.className="gengage-chat-mic-btn",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()),j.appendChild(this._micBtn),this._voiceInput=new Mo({onInterim:f=>{this.inputEl.value=f,this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,120)}px`},onFinal:f=>{this.inputEl.value=f},onAutoSubmit:f=>{this.inputEl.value=f,this._micBtn?.classList.remove("gengage-chat-mic-btn--active"),this._submit()},onStateChange:f=>{f==="listening"?this._micBtn?.classList.add("gengage-chat-mic-btn--active"):this._micBtn?.classList.remove("gengage-chat-mic-btn--active")},onError:(f,$)=>{this._micBtn?.classList.remove("gengage-chat-mic-btn--active")}},{lang:this._voiceLang})),j.appendChild(this.sendBtn),Y.appendChild(this._previewStrip),Y.appendChild(this._fileInput),Y.appendChild(j),B.appendChild(Y),b.appendChild(B),this.root.appendChild(b),this._setupHorizontalSwipe(B),this._setupHorizontalSwipe(this._panelEl);const V=document.createElement("div");V.className="gengage-chat-footer",V.textContent=this.i18n.poweredBy,this.root.appendChild(V);const F=f=>{f.key==="Escape"&&n.onClose()};this.root.addEventListener("keydown",F),this._cleanups.push(()=>this.root.removeEventListener("keydown",F)),t.appendChild(this.root)}addMessage(t){const n=document.createElement("div");if(n.className=`gengage-chat-bubble gengage-chat-bubble--${t.role}`,n.setAttribute("role","listitem"),n.dataset.messageId=t.id,t.threadId&&(n.dataset.threadId=t.threadId),this._firstBotMessageIds.has(t.id)&&n.classList.add("gengage-chat-bubble--first"),t.attachment){const a=document.createElement("img");a.className="gengage-chat-attachment-thumb";const i=URL.createObjectURL(t.attachment);a.src=i,a.alt=t.attachment.name,a.addEventListener("load",()=>URL.revokeObjectURL(i),{once:!0}),a.addEventListener("error",()=>URL.revokeObjectURL(i),{once:!0}),n.insertBefore(a,n.firstChild)}if(t.content){const a=document.createElement("div");if(a.className="gengage-chat-bubble-text",t.role==="assistant"){if(a.innerHTML=_e(t.content),this._onLinkClick){const i=a.querySelectorAll("a[href]");for(const o of i)o.addEventListener("click",r=>{r.preventDefault();const s=o.getAttribute("href");s&&this._onLinkClick?.(s)})}}else a.textContent=t.content;n.appendChild(a)}if(t.role==="user"&&this._onRollback){const a=document.createElement("button");a.className="gengage-chat-rollback-btn",a.type="button",a.setAttribute("aria-label",this.i18n.rollbackAriaLabel),a.title=this.i18n.rollbackAriaLabel,a.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>',a.addEventListener("click",i=>{i.stopPropagation(),this._onRollback?.(t.id)}),n.appendChild(a)}this.messagesEl.appendChild(n),this._presentationFocusThreadId&&this._applyPresentationCollapsed(),this._scrollToBottom(t.role==="user")}showTypingIndicator(t){this.removeTypingIndicator();const n=document.createElement("div");if(n.className="gengage-chat-typing",n.dataset.typing="true",this._thinkingSteps.length>0)this._renderThinkingStepsInto(n);else{const a=document.createElement("div");a.className="gengage-chat-typing-dots";for(let i=0;i<3;i++)a.appendChild(document.createElement("span"));if(n.appendChild(a),t){const i=document.createElement("span");i.className="gengage-chat-typing-sparkle",i.textContent="✨",n.appendChild(i);const o=document.createElement("span");o.className="gengage-chat-typing-text",o.textContent=t,n.appendChild(o)}}this.messagesEl.appendChild(n),this._scrollToBottom(!0),this._clearStillWorkingTimer(),this._stillWorkingTimer=setTimeout(()=>{this._stillWorkingTimer=null;const a=this.messagesEl.querySelector(".gengage-chat-typing");if(!a||a.querySelector(".gengage-chat-still-working"))return;const i=document.createElement("div");i.className="gengage-chat-still-working",i.textContent=this.i18n.stillWorkingMessage,a.appendChild(i),this._scrollToBottom(!0)},1e4)}addThinkingStep(t){this._thinkingSteps.push(t),this._renderThinkingSteps()}removeTypingIndicator(){this._clearStillWorkingTimer(),this.messagesEl.querySelector(".gengage-chat-typing")?.remove(),this._thinkingSteps=[],this.hideStopButton()}_clearStillWorkingTimer(){this._stillWorkingTimer!==null&&(clearTimeout(this._stillWorkingTimer),this._stillWorkingTimer=null)}showStopButton(t){this.hideStopButton();const n=document.createElement("button");n.className="gengage-chat-stop-btn",n.type="button",n.setAttribute("aria-label",this.i18n.stopGenerating);const a=document.createElement("span");a.className="gengage-chat-stop-icon",a.setAttribute("aria-hidden","true"),n.appendChild(a);const i=document.createElement("span");i.textContent=this.i18n.stopGenerating,n.appendChild(i),n.addEventListener("click",()=>{this.hideStopButton(),t()}),this.messagesEl.appendChild(n),this._scrollToBottom(!0)}hideStopButton(){this.messagesEl.querySelector(".gengage-chat-stop-btn")?.remove()}showError(t,n){const a=document.createElement("div");a.className="gengage-chat-error",a.setAttribute("role","alert");const i=document.createElement("span");if(i.textContent=t??this.i18n.errorMessage,a.appendChild(i),n){const o=document.createElement("button");o.className="gengage-chat-error-retry",o.textContent=this.i18n.retryButton??"Retry",o.addEventListener("click",()=>{a.remove(),n()}),a.appendChild(o)}this.messagesEl.appendChild(a),this._scrollToBottom(!0)}showErrorWithRecovery(t,n){this.showError(t),this.setPills([{label:this.i18n.tryAgainButton,onAction:n.onRetry},{label:this.i18n.askSomethingElseButton,onAction:n.onNewQuestion}])}clearMessages(){const t=this._formerMessagesBtn;for(const n of[...this.messagesEl.children])n!==t&&n.remove()}setPills(t){const n=this._pillsEl.querySelector(".gengage-chat-pills-scroll");if(!n)return;for(;n.firstChild;)n.removeChild(n.firstChild);if(t.length===0){this._pillsEl.style.display="none";return}this._pillsEl.style.display="";for(const i of t){const o=document.createElement("button");if(o.className=i.image?"gengage-chat-pill gengage-chat-pill--rich":"gengage-chat-pill",o.type="button",i.icon){const s=pn[i.icon]??dn,c=document.createElement("span");c.className="gengage-chat-pill-icon",c.innerHTML=s,o.appendChild(c)}if(i.image&&Ee(i.image)){const s=document.createElement("img");s.className="gengage-chat-pill-img",s.src=i.image,s.alt="",o.appendChild(s)}const r=document.createElement("span");if(r.className="gengage-chat-pill-text",r.textContent=i.label,o.appendChild(r),i.description){const s=document.createElement("span");s.className="gengage-chat-pill-desc";const c=`pill-desc-${Math.random().toString(36).slice(2,9)}`;s.id=c,s.textContent=i.description,o.appendChild(s),o.setAttribute("aria-describedby",c)}o.addEventListener("click",()=>i.onAction()),n.appendChild(o)}const a=this._pillsEl.querySelector(".gengage-chat-pills-arrow");a&&requestAnimationFrame(()=>{a.style.display=n.scrollWidth>n.clientWidth?"":"none"})}focusInput(){this.inputEl.focus()}showKvkkBanner(t,n){this._kvkkSlot.innerHTML="";const a=Ro({htmlContent:t,onDismiss:n,closeAriaLabel:this.i18n.closeAriaLabel});this._kvkkSlot.appendChild(a)}hideKvkkBanner(){this._kvkkSlot.innerHTML=""}getElement(){return this.root}stageAttachment(t){this._pendingAttachment=t,this._previewName.textContent=t.name;const n=this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");n&&(n.src&&n.src.startsWith("blob:")&&URL.revokeObjectURL(n.src),n.src=URL.createObjectURL(t)),this._previewStrip.classList.remove("gengage-chat-attachment-preview--hidden"),this._updateSendEnabled()}clearAttachment(){const t=this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");t?.src&&(URL.revokeObjectURL(t.src),t.src=""),this._pendingAttachment=null,this._previewStrip.classList.add("gengage-chat-attachment-preview--hidden"),this._updateSendEnabled()}getPendingAttachment(){return this._pendingAttachment}setPanelAiZoneState(t,n){if(this._panelAiZoneEl.isConnected){if(t==="hidden"){this._panelAiZoneEl.innerHTML="",this._panelAiZoneEl.setAttribute("hidden","");return}if(this._panelAiZoneEl.removeAttribute("hidden"),t==="analyzing"){this._panelAiZoneEl.innerHTML="";const a=document.createElement("div");a.className="gengage-chat-panel-ai-zone-inner";const i=document.createElement("div");i.className="gengage-chat-typing-dots";for(let r=0;r<3;r++)i.appendChild(document.createElement("span"));const o=document.createElement("span");o.className="gengage-chat-panel-ai-zone-text",o.textContent=n?.analyzingLabel??this.i18n.aiAnalysisAnalyzingLabel,a.appendChild(i),a.appendChild(o),this._panelAiZoneEl.appendChild(a)}else t==="results"&&n?.resultEl&&(this._panelAiZoneEl.innerHTML="",this._panelAiZoneEl.appendChild(n.resultEl))}}_resetPanelAiZoneElement(){this._panelAiZoneEl=document.createElement("div"),this._panelAiZoneEl.className="gengage-chat-panel-ai-zone",this._panelAiZoneEl.setAttribute("hidden","")}setPanelContent(t){this._panelEl.classList.add("gengage-chat-panel--transitioning"),this._panelEl.innerHTML="",this._resetPanelAiZoneElement(),this._panelEl.appendChild(this._panelTopBar.getElement()),this._panelEl.appendChild(this._panelAiZoneEl),this._panelEl.appendChild(t),this._panelEl.appendChild(this._thumbnailsColumn.getElement()),this._panelEl.appendChild(this._panelFloatingEl),this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel")),this._panelCollapsed&&this._panelEl.classList.add("gengage-chat-panel--collapsed"),requestAnimationFrame(()=>{this._panelEl.classList.remove("gengage-chat-panel--transitioning"),this._updateScrollAffordance()}),this._reopenPanelBtn&&(this._reopenPanelBtn.style.display="none")}appendPanelContent(t){const n=this._thumbnailsColumn.getElement(),a=n.parentElement===this._panelEl?n:this._panelFloatingEl;this._panelEl.insertBefore(t,a),this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel"))}getPanelContentElement(){const t=this._panelEl.children;for(let n=0;n<t.length;n++){const a=t[n];if(!(a.classList.contains("gengage-chat-panel-topbar")||a.classList.contains("gengage-chat-panel-ai-zone")||a.classList.contains("gengage-chat-thumbnails-column")||a.classList.contains("gengage-chat-panel-float")))return a}return null}isPanelVisible(){return this._panelVisible}hasPanelContent(){return this._panelVisible&&this.getPanelContentElement()!==null}isPanelLoading(){return this._panelEl.querySelector(".gengage-chat-panel-skeleton")!==null}showPanelLoading(t){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 n=document.createElement("div");switch(n.className="gengage-chat-panel-skeleton",t){case"productDetails":{const a=document.createElement("div");a.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--image",n.appendChild(a);for(let i=0;i<3;i++){const o=document.createElement("div");o.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--text",n.appendChild(o)}break}case"productList":case"groupList":{const a=document.createElement("div");a.className="gengage-chat-panel-skeleton-grid";for(let i=0;i<6;i++){const o=document.createElement("div");o.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--card",a.appendChild(o)}n.appendChild(a);break}case"comparisonTable":{for(let a=0;a<4;a++){const i=document.createElement("div");i.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--row",n.appendChild(i)}break}default:{for(let a=0;a<3;a++){const i=document.createElement("div");i.className="gengage-chat-panel-skeleton-block",n.appendChild(i)}break}}this._panelEl.appendChild(n),this._panelEl.appendChild(this._thumbnailsColumn.getElement()),this._panelEl.appendChild(this._panelFloatingEl),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel"))}updatePanelTopBar(t,n,a){const i=this._options.getMobileViewport?.()??!1;this._panelTopBar.update(i?!0:t,n,a)}getPanelTopBarTitle(){return this._panelTopBar.getTitle()}updateFavoritesBadge(t){this._favBadgeEl&&(t>0?(this._favBadgeEl.textContent=t>99?"99+":String(t),this._favBadgeEl.style.display=""):this._favBadgeEl.style.display="none")}clearPanel(){this._panelEl.innerHTML="",this._resetPanelAiZoneElement(),this._panelEl.appendChild(this._panelTopBar.getElement()),this._panelEl.appendChild(this._panelAiZoneEl),this._panelEl.appendChild(this._thumbnailsColumn.getElement()),this._panelEl.appendChild(this._panelFloatingEl),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")}hideMobilePanel(){this._panelVisible&&(this._panelVisible=!1,this._panelEl.classList.remove("gengage-chat-panel--visible"),this._reopenPanelBtn&&(this._reopenPanelBtn.style.display="flex"))}_showMobilePanelFromBtn(){this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this._reopenPanelBtn&&(this._reopenPanelBtn.style.display="none"))}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"))}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")}_updateScrollAffordance(){const t=this._panelEl,n=t.scrollTop+t.clientHeight>=t.scrollHeight-10;t.classList.toggle("gengage-chat-panel--has-scroll",!n&&t.scrollHeight>t.clientHeight)}_setupHorizontalSwipe(t){let n=0,a=0;const i=r=>{if(window.innerWidth>768)return;const s=r.touches[0];s&&(n=s.clientX,a=s.clientY)},o=r=>{if(window.innerWidth>768)return;const s=r.changedTouches[0];if(!s)return;const c=s.clientX-n,l=s.clientY-a;Math.abs(c)>50&&Math.abs(c)>Math.abs(l)*2&&(this.togglePanel(),this._onPanelToggle?.())};t.addEventListener("touchstart",i,{passive:!0}),t.addEventListener("touchend",o,{passive:!0}),this._cleanups.push(()=>{t.removeEventListener("touchstart",i),t.removeEventListener("touchend",o)})}togglePanel(){this.setPanelCollapsed(!this._panelCollapsed)}isPanelCollapsed(){return this._panelCollapsed}setPanelCollapsed(t){this._panelCollapsed=t,t?this._panelEl.classList.add("gengage-chat-panel--collapsed"):this._panelEl.classList.remove("gengage-chat-panel--collapsed");const n=this._dividerEl.querySelector(".gengage-chat-panel-divider-toggle");n&&(n.textContent=t?"«":"»")}persistPanelState(t){try{const n=`gengage:panel:${t}`;this._panelCollapsed?sessionStorage.setItem(n,"collapsed"):sessionStorage.removeItem(n)}catch{}}restorePanelState(t){try{const n=`gengage:panel:${t}`;if(sessionStorage.getItem(n)==="collapsed")return this._panelCollapsed=!0,!0}catch{}return!1}_renderThinkingSteps(){const t=this.messagesEl.querySelector('[data-typing="true"]');if(!t){this.showTypingIndicator();return}t.innerHTML="",this._renderThinkingStepsInto(t),this._scrollToBottom(!1)}_renderThinkingStepsInto(t){const n=document.createElement("div");n.className="gengage-chat-thinking-steps";for(let a=0;a<this._thinkingSteps.length;a++){const i=document.createElement("div");i.className="gengage-chat-thinking-step";const o=document.createElement("span");o.className="gengage-chat-thinking-step-marker",a<this._thinkingSteps.length-1?(o.textContent="✓",o.classList.add("gengage-chat-thinking-step-marker--done")):(o.textContent="●",o.classList.add("gengage-chat-thinking-step-marker--active")),i.appendChild(o);const r=document.createElement("span");r.className="gengage-chat-thinking-step-text",r.textContent=this._thinkingSteps[a],i.appendChild(r),n.appendChild(i)}t.appendChild(n)}_updateSendEnabled(){const t=this.inputEl.value.trim().length>0||this._pendingAttachment!==null;this.sendBtn.disabled=!t}_submit(){const t=this.inputEl.value.trim(),n=this._pendingAttachment;!t&&!n||(this.onSend(t,n??void 0),this.inputEl.value="",this.inputEl.style.height="auto",this.clearAttachment(),this._updateSendEnabled())}_toggleVoice(){if(this._voiceInput)if(this._voiceInput.state==="listening"){const t=this._voiceInput.stop();t.trim()&&(this.inputEl.value=t,this._submit())}else this.inputEl.value="",this._voiceInput.start()}lockScrollForRestore(){this._scrollLockedUntil=Date.now()+500}_scrollToBottom(t=!1){!t&&this._userScrolledUp||!t&&this._options.presentation?.shouldBlockSoftAutoScroll?.()||!t&&Date.now()<this._scrollLockedUntil||requestAnimationFrame(()=>{this.messagesEl.scrollTop=this.messagesEl.scrollHeight,this._userScrolledUp=!1})}scrollToBottomIfNeeded(){this._scrollToBottom(!1)}updateBotMessage(t,n){const a=this.messagesEl.querySelector(`[data-message-id="${CSS.escape(t)}"]`);if(!a)return;let i=a.querySelector(".gengage-chat-bubble-text");i||(i=document.createElement("div"),i.className="gengage-chat-bubble-text",a.appendChild(i)),i.innerHTML=_e(n),this._scrollToBottom(!1)}markFirstBotMessage(t){this._firstBotMessageIds.add(t);const n=this.messagesEl.querySelector(`[data-message-id="${CSS.escape(t)}"]`);n&&n.classList.add("gengage-chat-bubble--first")}scrollToLastThread(){const t=this.messagesEl.querySelectorAll("[data-thread-id]");if(t.length===0){this._scrollToBottom(!0);return}const n=t[t.length-1].getAttribute("data-thread-id");if(!n){this._scrollToBottom(!0);return}this._programmaticScrollUntil=Date.now()+700;const a=this.messagesEl.querySelector(`[data-thread-id="${CSS.escape(n)}"]`);a?requestAnimationFrame(()=>{a.scrollIntoView({block:"start",behavior:"auto"}),this._userScrolledUp=!1}):this._scrollToBottom(!0)}scrollThreadIntoView(t,n="smooth"){const a=this.messagesEl.querySelector(`[data-thread-id="${CSS.escape(t)}"]`);if(!a)return!1;const o=Math.max(a.offsetTop-20,0);return this._programmaticScrollUntil=Date.now()+700,this._scrollMessagesTo(o,n),!0}scrollToBottomPresentation(t="smooth"){this._programmaticScrollUntil=Date.now()+700,requestAnimationFrame(()=>{this._scrollMessagesTo(this.messagesEl.scrollHeight,t),this._userScrolledUp=!1})}_scrollMessagesTo(t,n){if(typeof this.messagesEl.scrollTo=="function"){this.messagesEl.scrollTo({top:t,behavior:n});return}this.messagesEl.scrollTop=t}setPresentationFocus(t){this._presentationFocusThreadId=t,this._applyPresentationCollapsed()}setFormerMessagesButtonVisible(t){this._formerMessagesBtn&&(this._formerMessagesBtn.style.display=t?"":"none")}_applyPresentationCollapsed(){const t=this._presentationFocusThreadId;this.messagesEl.querySelectorAll("[data-thread-id]").forEach(n=>{const a=n.dataset.threadId;a&&(t&&a!==t?n.classList.add("gengage-chat-bubble--presentation-collapsed"):n.classList.remove("gengage-chat-bubble--presentation-collapsed"))})}refreshPresentationCollapsed(){this._presentationFocusThreadId&&this._applyPresentationCollapsed()}setInputAreaChips(t){if(this._inputChipsEl.innerHTML="",t.length===0){this._inputChipsEl.style.display="none";return}this._inputChipsEl.style.display="";for(const n of t){const a=document.createElement("button");if(a.className="gengage-chat-input-chip",a.type="button",n.icon){const o=pn[n.icon]??dn,r=document.createElement("span");r.className="gengage-chat-input-chip-icon",r.innerHTML=o,a.appendChild(r)}const i=document.createElement("span");i.textContent=n.label,a.appendChild(i),a.addEventListener("click",()=>n.onAction()),this._inputChipsEl.appendChild(a)}}clearInputAreaChips(){this._inputChipsEl.innerHTML="",this._inputChipsEl.style.display="none"}setThumbnails(t){this._thumbnailsColumn.setEntries(t),t.length>0?this._thumbnailsColumn.show():this._thumbnailsColumn.hide()}hideThumbnails(){this._thumbnailsColumn.hide()}trapFocus(){this._previouslyFocusedElement=document.activeElement,this.releaseFocus();const t=n=>{if(n.key!=="Tab")return;const a=this.root.querySelectorAll('a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])');if(a.length===0)return;const i=a[0],o=a[a.length-1],r=this.root.getRootNode(),s=r instanceof ShadowRoot?r.activeElement:document.activeElement;n.shiftKey?(s===i||!this.root.contains(s))&&(n.preventDefault(),o.focus()):(s===o||!this.root.contains(s))&&(n.preventDefault(),i.focus())};this._focusTrapHandler=t,this.root.addEventListener("keydown",t)}releaseFocus(){if(this._focusTrapHandler&&(this.root.removeEventListener("keydown",this._focusTrapHandler),this._focusTrapHandler=null),this._previouslyFocusedElement){try{this._previouslyFocusedElement.focus()}catch{}this._previouslyFocusedElement=null}}destroy(){cn(null),this.releaseFocus(),this._clearStillWorkingTimer();for(const t of this._cleanups)t();this._cleanups.length=0,this._voiceInput?.destroy(),this._voiceInput=null}}const Uo=`<svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
46
+ `,document.head.appendChild(e)}let Ge=null;function fi(){if(Ge!==null)return Ge;try{Ge=localStorage.getItem("gengage:debug")==="1"}catch{Ge=!1}return Ge}function at(e,t,n){if(!fi())return;const a=[`[gengage:${e}]`,t];n!==void 0&&a.push(n),console.debug(...a)}class mi{constructor(){this.isVisible=!1,this.isInitialised=!1,this._handlers=new Map,this._cleanups=[],this._ownsRoot=!1,this._destroying=!1}async init(t){if(this.isInitialised){console.warn("[gengage] Widget already initialised. Call update() instead.");return}const n=ii(t.theme);this.config={...t,theme:n,session:ai(t.session)},this.root=this._resolveMount(t.mountTarget),this._applyTheme(n),ci();const a=Yt("gengage:context:update",i=>this.update(i));this._cleanups.push(a),at("lifecycle",`${this.constructor.name}.init`,{accountId:t.accountId,sku:t.pageContext?.sku});try{await this.onInit(this.config)}catch(i){throw this.destroy(),i}this._destroying||(this.isInitialised=!0,at("lifecycle",`${this.constructor.name} ready`),this.emit("ready"))}update(t){this.isInitialised&&(this.config.pageContext?this.config={...this.config,pageContext:{...this.config.pageContext,...t}}:t.pageType!==void 0&&(this.config={...this.config,pageContext:t}),this.onUpdate(t),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(t=>t()),this._cleanups.length=0,this._handlers.clear(),this.onDestroy(),this.config.analyticsClient?.destroy(),this._ownsRoot?this.root.remove():this.root.innerHTML="",this.isInitialised=!1)}on(t,n){return this._handlers.has(t)||this._handlers.set(t,new Set),this._handlers.get(t).add(n),()=>this._handlers.get(t)?.delete(n)}trackCheckout(t,n){const a=t==="start"?Ga:Ka;this.track(a(this.analyticsContext(),n))}flushMeteringSummary(t){this.track(Ha(this.analyticsContext(),t))}emit(t,...n){this._handlers.get(t)?.forEach(a=>a(...n))}addCleanup(t){this._cleanups.push(t)}track(t){this.config.analyticsClient?.track(t)}analyticsContext(){const t={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??""};return this.config.session?.viewId!==void 0&&(t.view_id=this.config.session.viewId),this.config.session?.userId!==void 0&&(t.user_id=this.config.session.userId),this.config.pageContext?.pageType!==void 0&&(t.page_type=this.config.pageContext.pageType),this.config.pageContext?.sku!==void 0&&(t.sku=this.config.pageContext.sku),this.config.session?.abTestVariant!==void 0&&(t.ab_test_variant=this.config.session.abTestVariant),this.config.session?.abTestExperimentId!==void 0&&(t.ab_test_experiment_id=this.config.session.abTestExperimentId),t}_resolveMount(t){if(t instanceof HTMLElement)return t;if(typeof t=="string"){const a=document.querySelector(t);if(!a)throw new Error(`[gengage] Mount target not found: "${t}"`);return a}const n=document.createElement("div");return n.dataset.gengageWidget=this.constructor.name.toLowerCase(),document.body.appendChild(n),this._ownsRoot=!0,n}_applyTheme(t){if(t){for(const[n,a]of Object.entries(t))if(a!==void 0){const i=n.startsWith("--")?n:`--gengage-${bi(n)}`;this.root.style.setProperty(i,a)}}}}function bi(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function wt(){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 n=Array.from(t,a=>a.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}class _i{constructor(t){this._handlers=new Map,this._destroyed=!1,this._namespace=t.namespace,this._allowedOrigins=t.allowedOrigins??[location.origin],this._onMessage=t.onMessage,this._allowedOrigins.includes("*")&&typeof{url:_t&&_t.tagName.toUpperCase()==="SCRIPT"&&_t.src||new URL("chat.iife.js",document.baseURI).href}<"u",this._messageListener=n=>this._handlePostMessage(n),window.addEventListener("message",this._messageListener)}send(t,n){if(this._destroyed)return;const a={namespace:this._namespace,type:t};n!==void 0&&(a.payload=n),window.dispatchEvent(new CustomEvent("gengage:bridge:message",{detail:a,bubbles:!1}))}on(t,n){this._handlers.has(t)||this._handlers.set(t,new Set);const a=this._handlers.get(t);return a.add(n),()=>{a.delete(n),a.size===0&&this._handlers.delete(t)}}destroy(){this._destroyed||(this._destroyed=!0,window.removeEventListener("message",this._messageListener),this._handlers.clear())}_handlePostMessage(t){if(this._destroyed||!this._isOriginAllowed(t.origin))return;const n=t.data;if(!vi(n)||n.gengage!==this._namespace)return;const a={type:n.type};n.payload!==void 0&&(a.payload=n.payload),this._onMessage?.(a);const i=this._handlers.get(a.type);if(i)for(const o of i)o(a.payload)}_isOriginAllowed(t){return this._allowedOrigins.includes("*")?!0:this._allowedOrigins.includes(t)}}function vi(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.gengage=="string"&&typeof t.type=="string"}const yi=console;function wi(e,t,n={}){const a=e.action,i=n.logger??yi;switch(at("action",`routing action: ${a.kind}`,a),a.kind){case"open_chat":{t.openChat?.(a.payload);return}case"navigate":{if(typeof a.url!="string"){$e(a,t,n,i);return}if(!le(a.url)){i.warn("[gengage] Blocked navigation to unsafe URL:",a.url);return}const o=typeof a.newTab=="boolean"?a.newTab:void 0;if(t.navigate){t.navigate({url:a.url,...o!==void 0&&{newTab:o}});return}xi(a.url,o);return}case"save_session":{if(typeof a.sessionId!="string"||typeof a.sku!="string"){$e(a,t,n,i);return}t.saveSession?.({sessionId:a.sessionId,sku:a.sku});return}case"add_to_cart":{if(typeof a.sku!="string"||typeof a.quantity!="number"||typeof a.cartCode!="string"){$e(a,t,n,i);return}t.addToCart?.({sku:a.sku,quantity:a.quantity,cartCode:a.cartCode});return}case"script_call":{if(n.allowScriptCall===!1){$e(a,t,n,i);return}if(typeof a.name!="string"){$e(a,t,n,i);return}const o=ki(a.payload)?a.payload:void 0;t.scriptCall?.({name:a.name,...o!==void 0&&{payload:o}});return}default:$e(a,t,n,i)}}function $e(e,t,n,a){const i=n.unknownActionPolicy??"log-and-ignore";if(i==="delegate"){t.unknown?.(e),t.unknown||a.warn("[gengage] Unknown action received without delegate handler",e);return}if(i==="throw")throw new Error(`[gengage] Unknown action kind: ${e.kind}`);a.warn("[gengage] Unknown action ignored",e)}function xi(e,t){if(!(typeof window>"u")){if(!le(e)){console.warn("[gengage] Blocked navigation to unsafe URL:",e);return}if(t){window.open(e,"_blank","noopener,noreferrer");return}window.location.href=e}}function ki(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Ci=["image/jpeg","image/png","image/webp"],Ei=5*1024*1024;function Si(e){return Ci.includes(e.type)?e.size>Ei?{ok:!1,reason:"too_large"}:{ok:!0}:{ok:!1,reason:"invalid_type"}}function en(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function Ti(e){const t=[];let n=0,a=!1,i=!1,o=0;for(let r=0;r<e.length;r++){const s=e[r];if(i){i=!1;continue}if(s==="\\"&&a){i=!0;continue}if(s==='"'){a=!a;continue}a||(s==="{"&&n++,s==="}"&&(n--,n===0&&(t.push(e.slice(o,r+1)),o=r+1)))}return t.length>0?t:[e]}function tn(e,t){const n=e.trim();if(!n||n.startsWith(":"))return!1;const a=n.startsWith("data: ")?n.slice(6):n;if(a==="[DONE]")return t.onDone?.(),!0;try{const i=JSON.parse(a);return en(i)?(at("stream",`event: ${i.type}`,i),t.onEvent(i),i.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const i=Ti(a);if(i.length>1){for(const o of i)try{const r=JSON.parse(o);if(!en(r))continue;if(t.onEvent(r),r.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function Ai(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 n=e.body.getReader(),a=new TextDecoder("utf-8");let i="";const o=t.idleTimeoutMs??6e4,r=Symbol("idle-timeout");let s=!1;try{for(;;){const c=n.read();let l;const g=await(o>0?Promise.race([c.then(u=>(clearTimeout(l),u)),new Promise(u=>{l=setTimeout(()=>u(r),o)})]):c);if(g===r){s=!0,await n.cancel();break}const{done:p,value:d}=g;if(p)break;i+=a.decode(d,{stream:!0});const h=i.split(`
47
+ `);i=h.pop()??"";for(const u of h)if(tn(u,t))return}if(i.trim()&&tn(i,t))return}catch(c){if(c instanceof DOMException&&c.name==="AbortError")return;t.onError?.(c instanceof Error?c:new Error(String(c)))}finally{s||n.releaseLock()}t.onDone?.()}const nn=3,Ii=(e,t)=>{const n=e.replace(/\s+/g," ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g,"");if(!n)return"";const a=t?.stripLeadingStopWords?n.replace(/^(?:daha|için)\s+/i,"").trim():n;return a?a.split(/\s+/).slice(0,3).join(" ").trim():""},xt=(e,t)=>e?e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(n=>Ii(n,t)).filter(Boolean):[];function Pi(e){const t=(e.display_keywords??[]).flatMap(i=>xt(i,{stripLeadingStopWords:!0})),n=t.filter((i,o)=>t.indexOf(i)===o);if(n.length>0)return n.slice(0,nn);const a=[...xt(e.chosen_attribute,{stripLeadingStopWords:!0}),...xt(e.short_name)];return a.filter((i,o)=>a.indexOf(i)===o).slice(0,nn)}function Li(e){return Pi(e).join(" • ")}function zi(e){if(typeof e.type!="string")return null;if(Ni(e))return e;const n=e;switch(n.type){case"outputText":return Mi(n);case"suggestedActions":return Bi(n);case"productList":return Ri(n);case"productDetails":return Oi(n);case"productDetailsSimilars":return $i(n);case"comparisonTable":return Di(n);case"context":return ji(n);case"chatStreamEnd":return qi();case"loading":return Hi(n);case"panelLoading":return Vi(n);case"similarLoading":return Wi(n);case"redirect":return Gi(n);case"error":return Ki(n);case"dummy":return Yi();case"launcherAction":return Ji(n);case"text":return kt(n);case"productItem":return Xi(n);case"text_image":return an(n);case"quick_qna":return on(n);case"reviewHighlights":return Qi(n);case"aiProductSuggestions":return no(n);case"aiProductGroupings":return ao(n);case"aiSuggestedSearches":return io(n);case"prosAndCons":return eo(n);case"getGroundingReview":return oo(n);case"voice":return so(n);case"visitorDataResponse":return to(n);case"productListPreview":return ro();case"groupList":return co(n);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return lo(n);case"launcherContent":return po(n);case"handoff":return go(n);default:return null}}function Ni(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 n=e.widget;if(n!=="chat"&&n!=="qna"&&n!=="simrel")return!1;const a=Ee(e.spec);return a?typeof a.root=="string"&&Ee(a.elements)!==null:!1}case"action":{const n=Ee(e.action);return n!==null&&typeof n.kind=="string"}case"error":return typeof e.code=="string"&&typeof e.message=="string";case"done":return!0;default:return!1}}function Mi(e){const t=V(e.payload.text,e.payload.plain_text)??"",n=V(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:n||"Backend returned an error"};const a={type:"text_chunk",content:t,final:!0},i=e.payload.product_mentions;Array.isArray(i)&&i.length>0&&(a.productMentions=i.filter(s=>typeof s=="object"&&s!==null&&typeof s.sku=="string"&&typeof s.short_name=="string"));const o=e.payload.sku_to_product_item;o&&typeof o=="object"&&!Array.isArray(o)&&(a.skuToProductItem=o);const r=e.payload.conversation_mode;return typeof r=="string"&&r&&(a.conversationMode=r),a}function Bi(e){const t=(e.payload.actions??[]).map(n=>{const a=V(n.title)??"",i=ke(n.requestDetails,a),o=i?{label:a,action:i}:null;return o?(typeof n.icon=="string"&&(o.icon=n.icon),typeof n.image=="string"&&(o.image=n.image),o):null});return rn(t.filter(cn),"chat")}function Ri(e){const t=sn(e.payload.product_list??[],"chat");t.panelHint="panel";const n=t.spec.elements[t.spec.root];return n&&(typeof e.payload.offset=="number"&&(n.props={...n.props,offset:e.payload.offset}),typeof e.payload.end_of_list=="boolean"&&(n.props={...n.props,endOfList:e.payload.end_of_list}),typeof e.payload.title=="string"&&(n.props={...n.props,panelTitle:e.payload.title})),t}function Oi(e){const t=e.payload.productDetails;return t?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:De(t)}}}},panelHint:"panel"}:uo("chat")}function $i(e){const t=sn(e.payload.similarProducts??[],"chat"),n=t.spec.elements[t.spec.root];return n&&(n.props={...n.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function Di(e){const t=e.payload.multiple_product_details??[],n=e.payload,a={key_differences:n.key_differences,recommended_choice:n.recommended_choice,recommended_choice_sku:n.recommended_choice_sku,special_considerations:n.special_considerations,criteria_view:n.criteria_view,criteria_view_short:n.criteria_view_short,compared_field_names:n.compared_field_names,winner_product:n.winner_product,winner_hits:n.winner_hits,...e.payload.product_comparison_framework??{}},i=e.payload.table,o=e.payload.features_list,r=[];for(const y of t){const w=De(y);r.push(w)}const s=Fi(i,r,a,o);let c;a?.recommended_choice_sku?c=a.recommended_choice_sku:a?.winner_product&&a.winner_product.length>0&&(c=a.winner_product[0]?.product_detail?.sku??a.winner_product[0]?.sku);const l=c?r.find(y=>y.sku===c)??r[0]:r[0],g=[];if(Array.isArray(a?.key_differences))for(const y of a.key_differences)typeof y=="string"&&g.push(y);const p=_o(a?.special_considerations),d=a?.recommended_choice,h=a?.winner_hits,u={};for(const y of r){const w=y.sku;w&&(u[w]={title:y.name??w,type:"launchSingleProduct",payload:{sku:w}})}const b={products:r,attributes:s,highlights:g,productActions:u};return l&&(b.recommended=l),p.length>0&&(b.specialCases=p),d&&(b.recommendedText=d),h&&(b.winnerHits=h),typeof a?.key_differences=="string"&&(b.keyDifferencesHtml=a.key_differences),a?.special_considerations&&(b.specialConsiderations=a.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:b}}},panelHint:"panel"}}function Fi(e,t,n,a){if(!e)return[];const i=Object.entries(e);if(i.length===0)return[];const o=i[0]?.[1];if(Array.isArray(o)){const d=n.criteria_view??n.criteria_view_short??{},h=n.compared_field_names??Object.keys(e),u=[];for(const b of h){const y=e[b];if(!y||!Array.isArray(y))continue;const w=d[b]??b;u.push({label:w,values:y.map(E=>typeof E=="string"?E:String(E??""))})}return u}const r=e,s=t.map(d=>String(d.sku??"")).filter(d=>d.length>0),c=n.criteria_view??n.criteria_view_short??{},g=(a&&a.length>0?a:n.compared_field_names&&n.compared_field_names.length>0?n.compared_field_names:Ui(r)).filter(d=>d!=="name"&&d!=="name_short"&&!d.endsWith("_short")),p=[];for(const d of g){const h=s.map(b=>{const y=r[b];if(!y||typeof y!="object")return"";const w=y[`${d}_short`],E=y[d];return Zi(w??E)});if(h.every(b=>b.length===0))continue;const u=c[d]??d;p.push({label:u,values:h})}return p}function Ui(e){const t=[],n=new Set;for(const a of Object.values(e))if(!(!a||typeof a!="object"))for(const i of Object.keys(a))n.has(i)||(n.add(i),t.push(i));return t}function Zi(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function ji(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function qi(){return{type:"done"}}function Hi(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 Vi(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Wi(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function Gi(e){const t=V(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:V(e.payload.to)}}}function Ki(e){return{type:"error",code:"BACKEND_ERROR",message:V(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function Yi(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function Ji(e){const t=e.payload??{};if(Array.isArray(t.action_list)){const o={action_list:t.action_list},r=typeof t.type=="string"?t.type:void 0,s=typeof t.theme=="string"?t.theme:void 0;return r!==void 0&&(o.type=r),s!==void 0&&(o.theme=s),on({payload:o})}const a=Ee(t.action);if(a){const o={action:a},r=typeof t.text=="string"?t.text:void 0,s=typeof t.image_url=="string"?t.image_url:void 0,c=typeof t.theme=="string"?t.theme:void 0;return r!==void 0&&(o.text=r),s!==void 0&&(o.image_url=s),c!==void 0&&(o.theme=c),an({payload:o})}const i=typeof t.text=="string"?t.text:"";if(i){const o={text:i},r=typeof t.type=="string"?t.type:void 0,s=typeof t.theme=="string"?t.theme:void 0,c=Ee(t.payload)??void 0;return r!==void 0&&(o.type=r),c!==void 0&&(o.payload=c),s!==void 0&&(o.theme=s),kt({payload:o})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function kt(e){const t={text:V(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 Xi(e){return ho(e.payload,"qna")}function an(e){const t=V(e.payload.text)??"",n=ke(e.payload.action,t);if(n){const i={label:t||n.title,action:n};return typeof e.payload.image_url=="string"&&(i.image=e.payload.image_url),typeof e.payload.theme=="string"&&(i.theme=e.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:i}}}}}const a={text:t};return typeof e.payload.theme=="string"&&(a.theme=e.payload.theme),kt({payload:a})}function on(e){const t=(e.payload.action_list??[]).map(n=>{const a=V(n.title)??"",i=ke(n.requestDetails,a),o=i?{label:a,action:i}:null;return o?(typeof n.icon=="string"&&(o.icon=n.icon),typeof n.image=="string"&&(o.image=n.image),o):null});return rn(t.filter(cn),"qna")}function Qi(e){const n={reviews:(e.payload.reviews??[]).map(a=>{const i={};return typeof a.review_class=="string"&&(i.review_class=a.review_class),typeof a.review_text=="string"&&(i.review_text=a.review_text),(typeof a.review_rating=="string"||typeof a.review_rating=="number")&&(i.review_rating=a.review_rating),typeof a.review_tag=="string"&&(i.review_tag=a.review_tag),i})};return typeof e.payload.sku=="string"&&(n.sku=e.payload.sku),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ReviewHighlights",props:n}}}}}function eo(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 to(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function no(e){const t=e.payload.product_suggestions??[],n=[];for(let a=0;a<t.length;a++){const i=t[a];if(!i)continue;const o=fo(i);if(!o)continue;const r={product:o},s=ke(i.requestDetails,o.name);s&&(r.action=s),typeof i.role=="string"&&(r.role=i.role),typeof i.reason=="string"&&(r.reason=i.reason),typeof i.review_highlight=="string"&&(r.reviewHighlight=i.review_highlight),Array.isArray(i.labels)&&(r.labels=i.labels),typeof i.expert_quality_score=="number"&&(r.expertQualityScore=i.expert_quality_score),n.push(r)}return n.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:n}}}}}}function ao(e){const t=e.payload.product_groupings??[],n=[];for(let a=0;a<t.length;a++){const i=t[a];if(!i)continue;const o=V(i.name)??"",r=i.sku&&i.sku.length>0?{type:"findSimilar",payload:{sku:i.sku}}:void 0,s=ke(i.requestDetails??r,o);if(!s)continue;const c={name:o,action:s};if(Array.isArray(i.labels)){const l=i.labels.filter(g=>typeof g=="string");l.length>0&&(c.labels=l)}typeof i.image=="string"&&(c.image=i.image),n.push(c)}return 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 io(e){const t=e.payload.suggested_searches??[],n=[];for(let a=0;a<t.length;a++){const i=t[a];if(!i)continue;const o=V(i.short_name,i.chosen_attribute,i.detailed_user_message)??`Search ${a+1}`,r={},s=V(i.detailed_user_message);s&&(r.text=s);const c=Ee(i.requestDetails),l=Ee(c?.payload),g=l?.group_skus;i.group_skus&&Array.isArray(i.group_skus)?r.group_skus=i.group_skus:Array.isArray(g)&&(r.group_skus=g.filter(E=>typeof E=="string"));const p=V(i.sku,i.representative_product_sku,l?.sku);p&&(r.sku=p),r.is_suggested_text=1;const d={type:"inputText",payload:r},h=ke(i.requestDetails,o),u=h?.type==="findSimilar"&&typeof r.text=="string"?ke(d,o):h??ke(d,o);if(!u)continue;const b={shortName:o,action:u},y=V(i.detailed_user_message);y&&y!==o&&(b.detailedMessage=y);const w=Li(i);w&&w!==o&&w!==(y??"")&&(b.whyDifferent=w),typeof i.image=="string"&&(b.image=i.image),n.push(b)}return n.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:n}}}}}}function oo(e){const t=ke(e.payload.requestDetails,V(e.payload.review_count,e.payload.text,e.payload.title)??"Show product reviews");if(!t)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:e.payload}};const n={action:t};return e.payload.title&&(n.title=e.payload.title),e.payload.text&&(n.text=e.payload.text),e.payload.review_count&&(n.reviewCount=e.payload.review_count),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:n}}}}}function ro(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function so(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function co(e){const t=e.payload.group_list??[],n=[];for(const i of t){const o=i.group_name??"",r=(i.product_list??[]).map(De);n.push({groupName:o,products:r})}const a=[];for(const i of e.payload.filter_tags??[]){const o=i.title??"";if(!o)continue;const r=ke(i.requestDetails,o),s={title:o};r&&(s.action=r),a.push(s)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:n,filterTags:a}}}},panelHint:"panel"}}function lo(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 po(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function rn(e,t){const n={},a=[];for(let i=0;i<e.length;i++){const o=e[i];if(!o)continue;const r=`action-${i}`;a.push(r);const s={label:o.label,action:o.action};o.icon!==void 0&&(s.icon=o.icon),o.image!==void 0&&(s.image=o.image),o.description!==void 0&&(s.description=o.description),n[r]={type:"ActionButton",props:s}}return n.root={type:"ActionButtons",props:{buttons:e.map(i=>{const o={label:i.label,action:i.action};return i.image!==void 0&&(o.image=i.image),i.description!==void 0&&(o.description=i.description),i.icon!==void 0&&(o.icon=i.icon),o})},children:a},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function sn(e,t){const n={},a=[];for(let i=0;i<e.length;i++){const o=e[i];if(!o)continue;const r=`product-${i}`;a.push(r),n[r]={type:"ProductCard",props:{product:De(o),index:i}}}return n.root={type:"ProductGrid",props:{layout:"grid"},children:a},{type:"ui_spec",widget:t,spec:{root:"root",elements:n}}}function ho(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:De(e),index:0}}}}}}function uo(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function fo(e){const t=V(e.sku),n=V(e.short_name),a=Ee(e.product_item)??e;return mo(a,t,n)}function mo(e,t,n){const a=V(e.sku,t),i=V(e.name,n);if(!a||!i)return null;const o={sku:a,name:i},r=V(e.brand);r&&(o.brand=r);const s=V(e.url);s&&(o.url=s);const c=bo(e.images);if(c.length>0)o.images=c;else{const u=V(e.image,e.image_url,e.imageUrl);u&&(o.images=[u])}const l=Ke(e.price_discounted);l!==void 0&&(o.price_discounted=l);const g=Ke(e.price);g!==void 0&&(o.price=g);const p=Ke(e.rating);p!==void 0&&(o.rating=p);const d=Ke(e.review_count)??Ke(e.reviewCount);d!==void 0&&(o.review_count=d);const h=V(e.cart_code,e.cartCode);return h&&(o.cart_code=h),typeof e.in_stock=="boolean"&&(o.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(o.in_stock=e.inStock),De(o)}function ke(e,t){const n=Ee(e);if(!n)return null;const a=n.type;if(typeof a!="string"||a.length===0)return null;const i={title:t||a,type:a};return n.payload!==void 0&&(i.payload=n.payload),i}function Ee(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function V(...e){for(const t of e)if(typeof t=="string"){const n=t.trim();if(n.length>0)return n}}function bo(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function _o(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 Ke(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 n=Number(t);if(Number.isFinite(n))return n}}function cn(e){return e!=null}const vo=new Set(["sku","name","brand","images","price","price_discounted","price_currency","discount_reason","url","rating","review_count","cart_code","in_stock","category_ids","category_names","variants","facet_hits","promotions"]);function De(e){const t=e.price_discounted!=null&&e.price_discounted>0,n=t?e.price_discounted:e.price,a=t&&e.price!=null?e.price:void 0;let i;a!=null&&n!=null&&a>0&&(i=Math.round((a-n)/a*100));const o=V(e.brand),r=V(e.name)??e.sku,s=o&&!r.toLowerCase().startsWith(o.toLowerCase())?`${o} ${r}`:r,c={sku:e.sku,name:s,url:V(e.url)??""},l=e.images?.[0];l&&(c.imageUrl=l),e.images&&e.images.length>1&&(c.images=e.images),n!=null&&(c.price=String(n)),a!=null&&(c.originalPrice=String(a)),i!==void 0&&(c.discountPercent=i),o!==void 0&&(c.brand=o),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);const g=e,p={};let d=!1;for(const h of Object.keys(g))vo.has(h)||(p[h]=g[h],d=!0);return d&&(c.extras=p),c}const yo={process_action:"/process_action",launcher_action:"/launcher_action",similar_products:"/similar_products",product_groupings:"/product_groupings"};function wo(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 xo(e,t){return`${wo(t?.middlewareUrl)}/chat${yo[e]}`}function ko(e,t){const n=e.type,a=e.payload!=null&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:{},i=o=>{const r={...a};for(const[s,c]of Object.entries(o))s in r||(r[s]=c);return r};switch(n){case"inputText":{const o={is_launcher:0};return t.pageContext?.extra&&(o.page_details=t.pageContext.extra),"is_suggested_text"in a||(o.is_suggested_text=0),{...e,payload:i(o)}}case"findSimilar":{const o={is_launcher:0};return e.title&&(o.text=e.title,o.input=e.title),{...e,payload:i(o)}}case"getComparisonTable":return e;case"addToCart":{const o={};return"error_message"in a||(o.error_message=""),{...e,payload:i(o)}}case"reviewSummary":{const o={};return t.pageContext?.sku&&!("sku"in a)&&(o.sku=t.pageContext.sku),Object.keys(o).length===0?e:{...e,payload:i(o)}}default:return e}}const Co={user_message:"inputText"};function Eo(e){const{action:t,type:n,payload:a,...i}=e,o=n??t?.type??"inputText",r=a??t?.payload,s=Co[o]??o,c={...i,type:s};return r!==void 0&&(c.payload=typeof r=="string"?{text:r}:r),JSON.stringify(c)}function So(e,t,n){const a=xo("process_action",n),i=new AbortController;return(async()=>{try{const r=Eo(e),s=n.attachment!==void 0;let c;if(s){const d=new FormData;d.append("request",r),n.attachment!==void 0&&d.append("attachment",n.attachment),c={method:"POST",body:d,signal:i.signal}}else c={method:"POST",headers:{"Content-Type":"application/json"},body:r,signal:i.signal};const l=await fetch(a,c);if(!l.ok){let d=l.statusText;try{const h=await l.json(),u=h.detail??h.message??h.error;typeof u=="string"&&(d=u)}catch{}t.onError(new Error(`HTTP ${l.status}: ${d}`));return}let g=!1;const p=()=>{g||(g=!0,t.onDone())};await Ai(l,{onEvent:d=>{const h=zi(d);if(h)switch(h.type){case"text_chunk":t.onTextChunk(h.content,h.final===!0,{productMentions:h.productMentions,skuToProductItem:h.skuToProductItem,conversationMode:h.conversationMode});break;case"ui_spec":t.onUISpec(h.spec,h.widget,h.panelHint);break;case"action":t.onAction(h);break;case"metadata":t.onMetadata(h);break;case"error":t.onError(new Error(h.message));break;case"done":p();break}},onError:t.onError,signal:i.signal}),p()}catch(r){if(r instanceof DOMException&&r.name==="AbortError")return;t.onError(r instanceof Error?r:new Error(String(r)))}})(),i}const To=["chat_debug","presentation_debug"],Ao=["gengage_chat_debug","gengage_presentation_debug"];function Io(){if(typeof window>"u")return!1;const e=new URLSearchParams(window.location.search);if(To.some(t=>e.get(t)==="1"))return!0;try{return Ao.some(t=>window.localStorage.getItem(t)==="1")}catch{return!1}}function Po(e,t,n){if(!Io())return;const a=(window.__gengageChatPresentationDebugSeq??0)+1;window.__gengageChatPresentationDebugSeq=a;const i={seq:a,time:new Date().toISOString(),scope:e,message:t,payload:n};window.__gengageChatPresentationDebugLog||(window.__gengageChatPresentationDebugLog=[]),window.__gengageChatPresentationDebugLog.push(i),window.__gengageChatPresentationDebugLog.length>400&&window.__gengageChatPresentationDebugLog.shift();const o=`[gengage-chat-debug #${a}][${e}] ${t}`;n===void 0?console.debug(o):console.debug(o,n)}const it="gengage-chat-scroll";let Fe=null;function ln(e){Fe=e}function Lo(){if(Fe&&Fe.isConnected)return Fe;Fe=null;const e=document.getElementById(it);return e||(Po("chat-scroll","failed to resolve scroll container (not registered)",{id:it}),null)}function gn(){Fe=null}const Ct={headerTitle:"Ürün Uzmanı",inputPlaceholder:"Ürün ara, soru sor",sendButton:"Gönder",closeButton:"Kapat",openButton:"Sohbeti aç",newChatButton:"Yeni sohbet",poweredBy:"Powered by Gengage",errorMessage:"Bir hata oluştu. Lütfen tekrar deneyin.",retryButton:"Tekrar Dene",loadingMessage:"Düşünüyorum...",productCtaLabel:"İncele",attachImageButton:"Resim ekle",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:"En Beğendiğim",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 ↑",sortPriceDesc:"Fiyat ↓",compareSelected:"Karşılaştır",compareMinHint:"En az 2 ürün seçin",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",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",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.",stillWorkingMessage:"İsteğiniz üzerinde hâlâ çalışılıyor...",cartAriaLabel:"Sepetim",favoritesAriaLabel:"Favorilerim",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",dismissAriaLabel:"Kapat",cartAddErrorMessage:"Üzgünüm sepete ekleyemedim, bir sorunla karşılaştım.",reviewFilterAll:"Tümü",reviewFilterPositive:"Olumlu",reviewFilterNegative:"Olumsuz",decreaseLabel:"Azalt",increaseLabel:"Artır",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"},zo={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:"Thinking...",productCtaLabel:"View",attachImageButton:"Attach image",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:"Related",sortPriceAsc:"Price ↑",sortPriceDesc:"Price ↓",compareSelected:"Compare",compareMinHint:"Select at least 2 products",panelTitleProductDetails:"Product Details",panelTitleSimilarProducts:"Similar Products",panelTitleComparisonResults:"Comparison Results",panelTitleCategories:"Categories",panelTitleSearchResults:"Search Results",inStockLabel:"In Stock",outOfStockLabel:"Out of Stock",findSimilarLabel:"Find Similar",choicePrompterHeading:"Can't decide?",choicePrompterSuggestion:"Select products to compare them",choicePrompterCta:"Select & Compare",viewMoreLabel:"Show More",similarProductsLabel:"Similar Products",addToCartButton:"Add 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.",stillWorkingMessage:"Still working on your request...",cartAriaLabel:"My cart",favoritesAriaLabel:"My favorites",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",dismissAriaLabel:"Dismiss",cartAddErrorMessage:"Sorry, I couldn't add that to your cart. Something went wrong.",reviewFilterAll:"All",reviewFilterPositive:"Positive",reviewFilterNegative:"Negative",decreaseLabel:"Decrease",increaseLabel:"Increase",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"};function No(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function Mo(e){return No(e)==="en"?zo:Ct}function Bo(){return dn()!==null}function dn(){const e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition??null}class Ro{constructor(t,n){this.recognition=null,this._state="idle",this.silenceTimer=null,this.accumulatedTranscript="",this.intentionalStop=!1,this._lastRestartAt=0,this.callbacks=t,this.lang=n?.lang??"tr-TR",this.silenceTimeoutMs=n?.silenceTimeoutMs??1500,this.autoSubmit=n?.autoSubmit??!0}get state(){return this._state}start(){if(this._state==="listening")return;const t=dn();if(!t){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 n=new t;n.continuous=!0,n.interimResults=!0,n.lang=this.lang,n.maxAlternatives=1,n.onstart=()=>{this.setState("listening")},n.onresult=a=>{this.clearSilenceTimer();let i="",o="";for(let r=a.resultIndex;r<a.results.length;r++){const s=a.results[r];if(!s)continue;const c=s[0];c&&(s.isFinal?o+=c.transcript:i+=c.transcript)}o&&(this.accumulatedTranscript+=o,this.callbacks.onFinal?.(this.accumulatedTranscript)),i&&this.callbacks.onInterim?.(this.accumulatedTranscript+i),this.autoSubmit&&this.accumulatedTranscript&&this.startSilenceTimer()},n.onerror=a=>{const i=Oo(a.error);this.intentionalStop&&(a.error==="no-speech"||a.error==="aborted")||(this.setState("error"),this.callbacks.onError?.(i,a.message||a.error))},n.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{n.start()}catch{this.setState("idle")}return}this.setState("idle")},this.recognition=n;try{n.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(t){this._state!==t&&(this._state=t,this.callbacks.onStateChange?.(t))}startSilenceTimer(){this.clearSilenceTimer(),this.silenceTimer=setTimeout(()=>{const t=this.stop();t.trim()&&this.callbacks.onAutoSubmit?.(t.trim())},this.silenceTimeoutMs)}clearSilenceTimer(){this.silenceTimer!==null&&(clearTimeout(this.silenceTimer),this.silenceTimer=null)}}function Oo(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 $o(e){const t=document.createElement("div");t.className="gengage-chat-kvkk-banner",t.setAttribute("role","alert");const n=document.createElement("div");n.className="gengage-chat-kvkk-content",n.innerHTML=we(e.htmlContent),t.appendChild(n);const a=document.createElement("button");return a.className="gengage-chat-kvkk-dismiss",a.type="button",a.setAttribute("aria-label",e.closeAriaLabel??"Close privacy notice"),a.textContent="×",a.addEventListener("click",e.onDismiss),t.appendChild(a),t}class Do{constructor(t){this._el=document.createElement("div"),this._el.className="gengage-chat-panel-topbar",this._backBtn=document.createElement("button"),this._backBtn.className="gengage-chat-panel-topbar-back",this._backBtn.type="button",this._backBtn.disabled=!0,this._backBtn.setAttribute("aria-label",t.backAriaLabel??"Back"),this._backBtn.title=t.backAriaLabel??"Back",this._backBtn.textContent="←",this._backBtn.addEventListener("click",()=>t.onBack()),this._titleEl=document.createElement("span"),this._titleEl.className="gengage-chat-panel-topbar-title",this._forwardBtn=document.createElement("button"),this._forwardBtn.className="gengage-chat-panel-topbar-forward",this._forwardBtn.type="button",this._forwardBtn.disabled=!0,this._forwardBtn.setAttribute("aria-label",t.forwardAriaLabel??"Forward"),this._forwardBtn.title=t.forwardAriaLabel??"Forward",this._forwardBtn.textContent="→",this._forwardBtn.addEventListener("click",()=>t.onForward()),this._el.appendChild(this._backBtn),this._el.appendChild(this._titleEl),this._el.appendChild(this._forwardBtn)}update(t,n,a){this._backBtn.disabled=!t,this._forwardBtn.disabled=!n,this._titleEl.textContent=a}getElement(){return this._el}getTitle(){return this._titleEl.textContent??""}}class Fo{constructor(t){this._onThumbnailClick=t.onThumbnailClick,this._el=document.createElement("div"),this._el.className="gengage-chat-thumbnails-column",this._el.style.display="none"}getElement(){return this._el}setEntries(t){const n=new Set,a=[];for(const i of t)n.has(i.sku)||(n.add(i.sku),a.push(i));this._el.innerHTML="";for(const i of a){const o=document.createElement("button");if(o.type="button",o.className="gengage-chat-thumbnail-btn",o.title=i.sku,Se(i.imageUrl)){const r=document.createElement("img");r.className="gengage-chat-thumbnail-img",r.src=i.imageUrl,r.alt=i.sku,r.width=40,r.height=40,o.appendChild(r)}o.addEventListener("click",()=>{this._onThumbnailClick(i.threadId)}),this._el.appendChild(o)}}show(){this._el.style.display=""}hide(){this._el.style.display="none"}}const pn='<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>',hn={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>'},Uo=Ct;class Zo{constructor(t,n){this._panelVisible=!1,this._panelCollapsed=!1,this._onPanelToggle=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._stillWorkingTimer=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._options=n,this.i18n={...Uo,...n.i18n},this.onSend=n.onSend,n.onPanelToggle!==void 0&&(this._onPanelToggle=n.onPanelToggle),n.onAttachment!==void 0&&(this._onAttachment=n.onAttachment),n.onRollback!==void 0&&(this._onRollback=n.onRollback),n.onLinkClick!==void 0&&(this._onLinkClick=n.onLinkClick),n.voiceEnabled&&(this._voiceEnabled=!0),n.voiceLang!==void 0&&(this._voiceLang=n.voiceLang),this.root=document.createElement("div"),this.root.className="gengage-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",i=document.createElement("span");i.id=a,i.className="gengage-sr-only",i.textContent=this.i18n.headerTitle??"AI shopping assistant",this.root.appendChild(i),this.root.setAttribute("aria-describedby",a);let o=null;{const v=document.createElement("div");v.className="gengage-chat-drawer-handle",v.setAttribute("aria-hidden","true"),v.style.pointerEvents="none",o=v}const r=document.createElement("div");r.className="gengage-chat-header";const s=document.createElement("div");s.className="gengage-chat-header-left";const c=n.headerAvatarUrl??n.launcherImageUrl;if(c){const v=document.createElement("img");v.className="gengage-chat-header-avatar",v.src=c,v.alt=n.headerTitle??"Assistant",s.appendChild(v)}const l=document.createElement("div");l.className="gengage-chat-header-info";const g=document.createElement("div");g.className="gengage-chat-header-title-row";const p=document.createElement("span");if(p.className="gengage-chat-header-title",p.textContent=n.headerTitle??this.i18n.headerTitle??"Product Expert",g.appendChild(p),n.headerBadge){const v=document.createElement("span");v.className="gengage-chat-header-badge",v.textContent=n.headerBadge,g.appendChild(v)}l.appendChild(g);const d=document.createElement("a");d.className="gengage-chat-header-powered",d.href="https://gengage.ai/",d.target="_blank",d.rel="noopener noreferrer",d.innerHTML='<svg viewBox="0 0 16 16" fill="currentColor"><path d="M8 1a7 7 0 110 14A7 7 0 018 1zm0 1.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM7 4.5h2v4H7v-4zm0 5h2v2H7v-2z"/></svg>Powered by Gengage',l.appendChild(d),s.appendChild(l),r.appendChild(s);const h=document.createElement("div");h.className="gengage-chat-header-right";{const v=document.createElement("button");v.type="button",v.className="gengage-chat-header-btn gengage-chat-header-btn--reopen-panel",v.setAttribute("aria-label",this.i18n.showPanelAriaLabel),v.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>',v.addEventListener("click",()=>this._showMobilePanelFromBtn()),h.appendChild(v),this._reopenPanelBtn=v}{const v=document.createElement("button");v.type="button",v.className="gengage-chat-header-btn",v.setAttribute("aria-label",this.i18n.cartAriaLabel),v.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>',v.addEventListener("click",()=>n.onCartClick?.()),h.appendChild(v)}if(n.onNewChat){const v=document.createElement("button");v.className="gengage-chat-header-btn gengage-chat-new-chat",v.type="button",v.setAttribute("aria-label",this.i18n.newChatButton),v.title=this.i18n.newChatButton,v.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>',v.addEventListener("click",()=>n.onNewChat?.()),h.appendChild(v)}const u=document.createElement("button");u.className="gengage-chat-close",u.type="button",u.setAttribute("aria-label",this.i18n.closeButton),u.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>',u.addEventListener("click",n.onClose);{const v=document.createElement("button");v.className="gengage-chat-header-btn gengage-chat-header-btn--fav",v.type="button",v.setAttribute("aria-label",this.i18n.favoritesAriaLabel),v.setAttribute("aria-pressed","false"),v.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 D=document.createElement("span");D.className="gengage-chat-header-fav-badge",D.setAttribute("aria-hidden","true"),D.style.display="none",v.appendChild(D),this._favBadgeEl=D,v.addEventListener("click",()=>{const ee=v.getAttribute("aria-pressed")==="true";v.setAttribute("aria-pressed",String(!ee)),n.onFavoritesClick?.()}),h.appendChild(v)}h.appendChild(u),o&&r.insertBefore(o,r.firstChild),r.appendChild(h);{let D=0,ee=0,pe=!1;const We=ue=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768)||ue.target.closest('button, a, input, [role="button"]'))return;const tt=ue.changedTouches?.[0];tt&&(D=tt.clientY,ee=0,pe=!0,this.root.style.transition="none")},Vt=ue=>{if(!pe)return;const ye=ue.changedTouches?.[0];if(!ye)return;ee=ye.clientY-D;const nt=(n.getMobileState?.()??"full")==="full"?Math.max(0,ee):ee;ue.preventDefault(),this.root.style.transform=`translateY(${nt}px)`},Wt=()=>{if(!pe)return;pe=!1;const ue=n.getMobileState?.()??"full";let ye;ee>72?ye=ue==="full"?"half":"close":ee<-72&&ue==="half"?ye="full":ye=ue,this.root.style.transition="",ye==="close"?(this.root.style.transform="translateY(100%)",setTimeout(()=>{this.root.style.transform="",n.onMobileSnap?.("close")},280)):(this.root.style.transform="",n.onMobileSnap?.(ye)),ee=0},Oe=()=>{pe&&(pe=!1,ee=0,this.root.style.transition="",this.root.style.transform="")};r.addEventListener("touchstart",We,{passive:!0}),r.addEventListener("touchmove",Vt,{passive:!1}),r.addEventListener("touchend",Wt,{passive:!0}),r.addEventListener("touchcancel",Oe,{passive:!0}),this._cleanups.push(()=>{r.removeEventListener("touchstart",We),r.removeEventListener("touchmove",Vt),r.removeEventListener("touchend",Wt),r.removeEventListener("touchcancel",Oe)})}const b=document.createElement("div");b.className="gengage-chat-body",this._panelEl=document.createElement("div"),this._panelEl.className="gengage-chat-panel",this._panelTopBar=new Do({onBack:()=>n.onPanelBack?.(),onForward:()=>n.onPanelForward?.(),backAriaLabel:this.i18n.backAriaLabel,forwardAriaLabel:this.i18n.forwardAriaLabel}),this._panelEl.appendChild(this._panelTopBar.getElement());const y=()=>this._updateScrollAffordance();this._panelEl.addEventListener("scroll",y,{passive:!0}),this._cleanups.push(()=>this._panelEl.removeEventListener("scroll",y)),b.appendChild(this._panelEl),this._dividerEl=document.createElement("div"),this._dividerEl.className="gengage-chat-panel-divider gengage-chat-panel-divider--hidden",this._dividerEl.setAttribute("role","separator"),this._dividerEl.setAttribute("aria-label",this.i18n.togglePanelAriaLabel),this._dividerEl.setAttribute("title",this.i18n.togglePanelAriaLabel);const w=document.createElement("button");w.className="gengage-chat-panel-divider-toggle",w.type="button",w.setAttribute("aria-label",this.i18n.togglePanelAriaLabel),w.setAttribute("title",this.i18n.togglePanelAriaLabel),w.textContent="»",w.addEventListener("click",()=>{if(this._ignoreNextDividerClick){this._ignoreNextDividerClick=!1;return}this.togglePanel(),this._onPanelToggle?.()});let E=null,A=null;const f=24,C=v=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768))return;const D=v.changedTouches?.[0];D&&(E=D.clientX,A=D.clientY)},U=v=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768)||E===null||A===null)return;const D=v.changedTouches?.[0];if(!D)return;const ee=D.clientX-E,pe=D.clientY-A;if(E=null,A=null,Math.abs(pe)<f||Math.abs(pe)<Math.abs(ee))return;const We=pe<0;We!==this._panelCollapsed&&(this._ignoreNextDividerClick=!0,this.setPanelCollapsed(We),this._onPanelToggle?.())};this._dividerEl.addEventListener("touchstart",C,{passive:!0}),this._dividerEl.addEventListener("touchend",U,{passive:!0}),this._cleanups.push(()=>{this._dividerEl.removeEventListener("touchstart",C),this._dividerEl.removeEventListener("touchend",U)}),this._dividerEl.appendChild(w),b.appendChild(this._dividerEl);const R=document.createElement("div");R.className="gengage-chat-conversation",this._conversationEl=R,R.appendChild(r);const k=document.createElement("div");k.className="gengage-chat-offline-bar",k.setAttribute("role","status"),k.setAttribute("aria-live","polite"),k.textContent=this.i18n.offlineMessage,typeof navigator<"u"&&!navigator.onLine&&k.classList.add("gengage-chat-offline-bar--visible"),R.appendChild(k);const I=()=>k.classList.add("gengage-chat-offline-bar--visible"),S=()=>k.classList.remove("gengage-chat-offline-bar--visible");window.addEventListener("offline",I),window.addEventListener("online",S),this._cleanups.push(()=>{window.removeEventListener("offline",I),window.removeEventListener("online",S)}),this._kvkkSlot=document.createElement("div"),this._kvkkSlot.className="gengage-chat-kvkk-slot",R.appendChild(this._kvkkSlot),this.messagesEl=document.createElement("div"),this.messagesEl.id=it,this.messagesEl.className="gengage-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),ln(this.messagesEl);const B=document.createElement("button");B.type="button",B.className="gengage-chat-former-messages-btn",B.textContent=this.i18n.showFormerMessagesButton,B.setAttribute("aria-label",this.i18n.showFormerMessagesButton),B.style.display="none",B.addEventListener("click",()=>{this._options.presentation?.onReleasePresentationFocus?.()}),this.messagesEl.appendChild(B),this._formerMessagesBtn=B;const ne=()=>{this._userInteractionUntil=Date.now()+2e3};let F=!1;const _=()=>this._options.presentation,L=()=>{F||(F=!0,requestAnimationFrame(()=>{F=!1;const{scrollTop:v,scrollHeight:D,clientHeight:ee}=this.messagesEl,pe=D-v-ee;this._userScrolledUp=pe>10;const Oe=this._presentationPinned?pe<96:pe<32,ue=Date.now(),ye=ue<this._programmaticScrollUntil,tt=!Oe&&ue<this._userInteractionUntil,nt=ye?!1:tt;Oe!==this._presentationPinned&&(this._presentationPinned=Oe,_()?.onPinnedToBottomChange?.(Oe)),nt!==this._presentationUserInteracting&&(this._presentationUserInteracting=nt,_()?.onUserInteractingChange?.(nt))}))};this.messagesEl.addEventListener("scroll",L,{passive:!0}),this._cleanups.push(()=>{this.messagesEl.removeEventListener("scroll",L)});const P=v=>{ne(),v.deltaY<-6&&this._presentationFocusThreadId&&this._options.presentation?.onFormerMessagesHint?.()};this.messagesEl.addEventListener("wheel",P,{passive:!0}),this._cleanups.push(()=>this.messagesEl.removeEventListener("wheel",P));const T=v=>{ne(),this._touchStartY=v.touches[0]?.clientY??null},M=v=>{ne();const D=v.touches[0]?.clientY,ee=this._touchStartY;typeof D=="number"&&typeof ee=="number"&&D-ee>10&&this._presentationFocusThreadId&&this._options.presentation?.onFormerMessagesHint?.()};this.messagesEl.addEventListener("touchstart",T,{passive:!0}),this.messagesEl.addEventListener("touchmove",M,{passive:!0}),this._cleanups.push(()=>{this.messagesEl.removeEventListener("touchstart",T),this.messagesEl.removeEventListener("touchmove",M)}),R.appendChild(this.messagesEl),this._thumbnailsColumn=new Fo({onThumbnailClick:v=>n.onThumbnailClick?.(v)}),this._panelEl.appendChild(this._thumbnailsColumn.getElement()),this._panelFloatingEl=document.createElement("div"),this._panelFloatingEl.className="gengage-chat-panel-float",this._panelEl.appendChild(this._panelFloatingEl),this._resetPanelAiZoneElement(),this._pillsEl=document.createElement("div"),this._pillsEl.className="gengage-chat-pills",this._pillsEl.setAttribute("role","toolbar"),this._pillsEl.setAttribute("aria-label",this.i18n.suggestionsAriaLabel),this._pillsEl.style.display="none";const N=document.createElement("div");N.className="gengage-chat-pills-scroll",this._pillsEl.appendChild(N);const G=document.createElement("button");G.className="gengage-chat-pills-arrow",G.type="button",G.setAttribute("aria-label",this.i18n.moreSuggestionsAriaLabel),G.textContent="›",G.addEventListener("click",()=>{N.scrollBy({left:150,behavior:"smooth"})}),this._pillsEl.appendChild(G);let W=!1;const ce=()=>{W||(W=!0,requestAnimationFrame(()=>{W=!1;const v=N.scrollLeft+N.clientWidth>=N.scrollWidth-4;G.style.display=v?"none":""}))};N.addEventListener("scroll",ce,{passive:!0}),this._cleanups.push(()=>{N.removeEventListener("scroll",ce)}),R.appendChild(this._pillsEl),this._inputChipsEl=document.createElement("div"),this._inputChipsEl.className="gengage-chat-input-chips",this._inputChipsEl.style.display="none",R.appendChild(this._inputChipsEl);const oe=document.createElement("div");oe.className="gengage-chat-input-area",this.inputEl=document.createElement("textarea"),this.inputEl.className="gengage-chat-input",this.inputEl.rows=1,this.inputEl.placeholder=this.i18n.inputPlaceholder,this.inputEl.addEventListener("input",()=>{requestAnimationFrame(()=>{this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,120)}px`}),this._updateSendEnabled()}),this.inputEl.addEventListener("keydown",v=>{v.key==="Enter"&&((this._options.getMobileViewport?.()??window.innerWidth<=768)||!v.shiftKey)&&(v.preventDefault(),this._submit())}),this.inputEl.addEventListener("paste",v=>{const D=v.clipboardData?.files[0];if(D&&D.type.startsWith("image/"))if(v.preventDefault(),this._onAttachment)try{this._onAttachment(D)}catch(ee){console.error("[gengage:chat] Attachment callback error:",ee)}else this.stageAttachment(D)}),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 v=this._fileInput.files?.[0];if(v)if(this._onAttachment)try{this._onAttachment(v)}catch(D){console.error("[gengage:chat] Attachment callback error:",D)}else this.stageAttachment(v);this._fileInput.value=""});const ve=document.createElement("button");ve.className="gengage-chat-attach-btn",ve.type="button",ve.setAttribute("aria-label",this.i18n.attachImageButton),ve.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>',ve.addEventListener("click",()=>this._fileInput.click()),this._previewStrip=document.createElement("div"),this._previewStrip.className="gengage-chat-attachment-preview gengage-chat-attachment-preview--hidden";const H=document.createElement("img");H.className="gengage-chat-attachment-preview-thumb",H.alt="",this._previewName=document.createElement("span"),this._previewName.className="gengage-chat-attachment-name";const Z=document.createElement("button");Z.className="gengage-chat-attachment-remove",Z.type="button",Z.setAttribute("aria-label",this.i18n.removeAttachmentButton),Z.textContent="×",Z.addEventListener("click",()=>this.clearAttachment()),this._previewStrip.appendChild(H),this._previewStrip.appendChild(this._previewName),this._previewStrip.appendChild(Z),this.sendBtn=document.createElement("button"),this.sendBtn.className="gengage-chat-send",this.sendBtn.type="button",this.sendBtn.disabled=!0,this.sendBtn.setAttribute("aria-label",this.i18n.sendButton),this.sendBtn.innerHTML='<svg viewBox="0 0 24 24" fill="currentColor"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/></svg>',this.sendBtn.addEventListener("click",()=>this._submit()),oe.addEventListener("dragover",v=>{v.preventDefault(),oe.classList.add("gengage-chat-input-area--dragover")}),oe.addEventListener("dragleave",()=>{oe.classList.remove("gengage-chat-input-area--dragover")}),oe.addEventListener("drop",v=>{v.preventDefault(),oe.classList.remove("gengage-chat-input-area--dragover");const D=v.dataTransfer?.files[0];if(D)if(this._onAttachment)try{this._onAttachment(D)}catch(ee){console.error("[gengage:chat] Attachment callback error:",ee)}else this.stageAttachment(D)});const q=document.createElement("div");q.className="gengage-chat-input-pill",q.appendChild(ve),q.appendChild(this.inputEl),this._voiceEnabled&&Bo()&&(this._micBtn=document.createElement("button"),this._micBtn.className="gengage-chat-mic-btn",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()),q.appendChild(this._micBtn),this._voiceInput=new Ro({onInterim:v=>{this.inputEl.value=v,this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,120)}px`},onFinal:v=>{this.inputEl.value=v},onAutoSubmit:v=>{this.inputEl.value=v,this._micBtn?.classList.remove("gengage-chat-mic-btn--active"),this._submit()},onStateChange:v=>{v==="listening"?this._micBtn?.classList.add("gengage-chat-mic-btn--active"):this._micBtn?.classList.remove("gengage-chat-mic-btn--active")},onError:(v,D)=>{this._micBtn?.classList.remove("gengage-chat-mic-btn--active")}},{lang:this._voiceLang})),q.appendChild(this.sendBtn),oe.appendChild(this._previewStrip),oe.appendChild(this._fileInput),oe.appendChild(q),R.appendChild(oe),b.appendChild(R),this.root.appendChild(b),this._setupHorizontalSwipe(R),this._setupHorizontalSwipe(this._panelEl);const $=document.createElement("div");$.className="gengage-chat-footer",$.textContent=this.i18n.poweredBy,this.root.appendChild($);const re=v=>{v.key==="Escape"&&n.onClose()};this.root.addEventListener("keydown",re),this._cleanups.push(()=>this.root.removeEventListener("keydown",re)),t.appendChild(this.root)}addMessage(t){const n=document.createElement("div");if(n.className=`gengage-chat-bubble gengage-chat-bubble--${t.role}`,n.setAttribute("role","listitem"),n.dataset.messageId=t.id,t.threadId&&(n.dataset.threadId=t.threadId),this._firstBotMessageIds.has(t.id)&&n.classList.add("gengage-chat-bubble--first"),t.attachment){const a=document.createElement("img");a.className="gengage-chat-attachment-thumb";const i=URL.createObjectURL(t.attachment);a.src=i,a.alt=t.attachment.name,a.addEventListener("load",()=>URL.revokeObjectURL(i),{once:!0}),a.addEventListener("error",()=>URL.revokeObjectURL(i),{once:!0}),n.insertBefore(a,n.firstChild)}if(t.content){const a=document.createElement("div");if(a.className="gengage-chat-bubble-text",t.role==="assistant"){if(a.innerHTML=we(t.content),this._onLinkClick){const i=a.querySelectorAll("a[href]");for(const o of i)o.addEventListener("click",r=>{r.preventDefault();const s=o.getAttribute("href");s&&this._onLinkClick?.(s)})}}else a.textContent=t.content;n.appendChild(a)}if(t.role==="user"&&this._onRollback){const a=document.createElement("button");a.className="gengage-chat-rollback-btn",a.type="button",a.setAttribute("aria-label",this.i18n.rollbackAriaLabel),a.title=this.i18n.rollbackAriaLabel,a.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>',a.addEventListener("click",i=>{i.stopPropagation(),this._onRollback?.(t.id)}),n.appendChild(a)}this.messagesEl.appendChild(n),this._presentationFocusThreadId&&this._applyPresentationCollapsed(),this._scrollToBottom(t.role==="user")}showTypingIndicator(t){this.removeTypingIndicator();const n=document.createElement("div");if(n.className="gengage-chat-typing",n.dataset.typing="true",this._thinkingSteps.length>0)this._renderThinkingStepsInto(n);else{const a=document.createElement("div");a.className="gengage-chat-typing-dots";for(let i=0;i<3;i++)a.appendChild(document.createElement("span"));if(n.appendChild(a),t){const i=document.createElement("span");i.className="gengage-chat-typing-sparkle",i.textContent="✨",n.appendChild(i);const o=document.createElement("span");o.className="gengage-chat-typing-text",o.textContent=t,n.appendChild(o)}}this.messagesEl.appendChild(n),this._scrollToBottom(!0),this._clearStillWorkingTimer(),this._stillWorkingTimer=setTimeout(()=>{this._stillWorkingTimer=null;const a=this.messagesEl.querySelector(".gengage-chat-typing");if(!a||a.querySelector(".gengage-chat-still-working"))return;const i=document.createElement("div");i.className="gengage-chat-still-working",i.textContent=this.i18n.stillWorkingMessage,a.appendChild(i),this._scrollToBottom(!0)},1e4)}addThinkingStep(t){this._thinkingSteps.push(t),this._renderThinkingSteps()}removeTypingIndicator(){this._clearStillWorkingTimer(),this.messagesEl.querySelector(".gengage-chat-typing")?.remove(),this._thinkingSteps=[],this.hideStopButton()}_clearStillWorkingTimer(){this._stillWorkingTimer!==null&&(clearTimeout(this._stillWorkingTimer),this._stillWorkingTimer=null)}showStopButton(t){this.hideStopButton();const n=document.createElement("button");n.className="gengage-chat-stop-btn",n.type="button",n.setAttribute("aria-label",this.i18n.stopGenerating);const a=document.createElement("span");a.className="gengage-chat-stop-icon",a.setAttribute("aria-hidden","true"),n.appendChild(a);const i=document.createElement("span");i.textContent=this.i18n.stopGenerating,n.appendChild(i),n.addEventListener("click",()=>{this.hideStopButton(),t()}),this.messagesEl.appendChild(n),this._scrollToBottom(!0)}hideStopButton(){this.messagesEl.querySelector(".gengage-chat-stop-btn")?.remove()}showError(t,n){const a=document.createElement("div");a.className="gengage-chat-error",a.setAttribute("role","alert");const i=document.createElement("span");if(i.textContent=t??this.i18n.errorMessage,a.appendChild(i),n){const o=document.createElement("button");o.className="gengage-chat-error-retry",o.textContent=this.i18n.retryButton??"Retry",o.addEventListener("click",()=>{a.remove(),n()}),a.appendChild(o)}this.messagesEl.appendChild(a),this._scrollToBottom(!0)}showErrorWithRecovery(t,n){this.showError(t),this.setPills([{label:this.i18n.tryAgainButton,onAction:n.onRetry},{label:this.i18n.askSomethingElseButton,onAction:n.onNewQuestion}])}clearMessages(){const t=this._formerMessagesBtn;for(const n of[...this.messagesEl.children])n!==t&&n.remove()}setPills(t){const n=this._pillsEl.querySelector(".gengage-chat-pills-scroll");if(!n)return;for(;n.firstChild;)n.removeChild(n.firstChild);if(t.length===0){this._pillsEl.style.display="none";return}this._pillsEl.style.display="";for(const i of t){const o=document.createElement("button");if(o.className=i.image?"gengage-chat-pill gengage-chat-pill--rich":"gengage-chat-pill",o.type="button",i.icon){const s=hn[i.icon]??pn,c=document.createElement("span");c.className="gengage-chat-pill-icon",c.innerHTML=s,o.appendChild(c)}if(i.image&&Se(i.image)){const s=document.createElement("img");s.className="gengage-chat-pill-img",s.src=i.image,s.alt="",o.appendChild(s)}const r=document.createElement("span");if(r.className="gengage-chat-pill-text",r.textContent=i.label,o.appendChild(r),i.description){const s=document.createElement("span");s.className="gengage-chat-pill-desc";const c=`pill-desc-${Math.random().toString(36).slice(2,9)}`;s.id=c,s.textContent=i.description,o.appendChild(s),o.setAttribute("aria-describedby",c)}o.addEventListener("click",()=>i.onAction()),n.appendChild(o)}const a=this._pillsEl.querySelector(".gengage-chat-pills-arrow");a&&requestAnimationFrame(()=>{a.style.display=n.scrollWidth>n.clientWidth?"":"none"})}focusInput(){this.inputEl.focus()}showKvkkBanner(t,n){this._kvkkSlot.innerHTML="";const a=$o({htmlContent:t,onDismiss:n,closeAriaLabel:this.i18n.closeAriaLabel});this._kvkkSlot.appendChild(a)}hideKvkkBanner(){this._kvkkSlot.innerHTML=""}getElement(){return this.root}stageAttachment(t){this._pendingAttachment=t,this._previewName.textContent=t.name;const n=this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");n&&(n.src&&n.src.startsWith("blob:")&&URL.revokeObjectURL(n.src),n.src=URL.createObjectURL(t)),this._previewStrip.classList.remove("gengage-chat-attachment-preview--hidden"),this._updateSendEnabled()}clearAttachment(){const t=this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");t?.src&&(URL.revokeObjectURL(t.src),t.src=""),this._pendingAttachment=null,this._previewStrip.classList.add("gengage-chat-attachment-preview--hidden"),this._updateSendEnabled()}getPendingAttachment(){return this._pendingAttachment}setPanelAiZoneState(t,n){if(this._panelAiZoneEl.isConnected){if(t==="hidden"){this._panelAiZoneEl.innerHTML="",this._panelAiZoneEl.setAttribute("hidden","");return}if(this._panelAiZoneEl.removeAttribute("hidden"),t==="analyzing"){this._panelAiZoneEl.innerHTML="";const a=document.createElement("div");a.className="gengage-chat-panel-ai-zone-inner";const i=document.createElement("div");i.className="gengage-chat-typing-dots";for(let r=0;r<3;r++)i.appendChild(document.createElement("span"));const o=document.createElement("span");o.className="gengage-chat-panel-ai-zone-text",o.textContent=n?.analyzingLabel??this.i18n.aiAnalysisAnalyzingLabel,a.appendChild(i),a.appendChild(o),this._panelAiZoneEl.appendChild(a)}else t==="results"&&n?.resultEl&&(this._panelAiZoneEl.innerHTML="",this._panelAiZoneEl.appendChild(n.resultEl))}}_resetPanelAiZoneElement(){this._panelAiZoneEl=document.createElement("div"),this._panelAiZoneEl.className="gengage-chat-panel-ai-zone",this._panelAiZoneEl.setAttribute("hidden","")}setPanelContent(t){this._panelVisible&&this._panelEl.classList.add("gengage-chat-panel--transitioning"),this._panelEl.innerHTML="",this._resetPanelAiZoneElement(),this._panelEl.appendChild(this._panelTopBar.getElement()),this._panelEl.appendChild(this._panelAiZoneEl),this._panelEl.appendChild(t),this._panelEl.appendChild(this._thumbnailsColumn.getElement()),this._panelEl.appendChild(this._panelFloatingEl),this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel")),this._panelCollapsed&&this._panelEl.classList.add("gengage-chat-panel--collapsed"),requestAnimationFrame(()=>{this._panelEl.classList.remove("gengage-chat-panel--transitioning"),this._updateScrollAffordance()}),this._reopenPanelBtn&&(this._reopenPanelBtn.style.display="none")}appendPanelContent(t){const n=this._thumbnailsColumn.getElement(),a=n.parentElement===this._panelEl?n:this._panelFloatingEl;this._panelEl.insertBefore(t,a),this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel"))}getPanelContentElement(){const t=this._panelEl.children;for(let n=0;n<t.length;n++){const a=t[n];if(!(a.classList.contains("gengage-chat-panel-topbar")||a.classList.contains("gengage-chat-panel-ai-zone")||a.classList.contains("gengage-chat-thumbnails-column")||a.classList.contains("gengage-chat-panel-float")))return a}return null}isPanelVisible(){return this._panelVisible}hasPanelContent(){return this._panelVisible&&this.getPanelContentElement()!==null}isPanelLoading(){return this._panelEl.querySelector(".gengage-chat-panel-skeleton")!==null}showPanelLoading(t){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 n=document.createElement("div");switch(n.className="gengage-chat-panel-skeleton",t){case"productDetails":{const a=document.createElement("div");a.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--image",n.appendChild(a);for(let i=0;i<3;i++){const o=document.createElement("div");o.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--text",n.appendChild(o)}break}case"productList":case"groupList":{const a=document.createElement("div");a.className="gengage-chat-panel-skeleton-grid";for(let i=0;i<6;i++){const o=document.createElement("div");o.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--card",a.appendChild(o)}n.appendChild(a);break}case"comparisonTable":{for(let a=0;a<4;a++){const i=document.createElement("div");i.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--row",n.appendChild(i)}break}default:{for(let a=0;a<3;a++){const i=document.createElement("div");i.className="gengage-chat-panel-skeleton-block",n.appendChild(i)}break}}this._panelEl.appendChild(n),this._panelEl.appendChild(this._thumbnailsColumn.getElement()),this._panelEl.appendChild(this._panelFloatingEl),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel"))}updatePanelTopBar(t,n,a){const i=this._options.getMobileViewport?.()??!1;this._panelTopBar.update(i?!0:t,n,a)}getPanelTopBarTitle(){return this._panelTopBar.getTitle()}updateFavoritesBadge(t){this._favBadgeEl&&(t>0?(this._favBadgeEl.textContent=t>99?"99+":String(t),this._favBadgeEl.style.display=""):this._favBadgeEl.style.display="none")}clearPanel(){this._panelEl.innerHTML="",this._resetPanelAiZoneElement(),this._panelEl.appendChild(this._panelTopBar.getElement()),this._panelEl.appendChild(this._panelAiZoneEl),this._panelEl.appendChild(this._thumbnailsColumn.getElement()),this._panelEl.appendChild(this._panelFloatingEl),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")}hideMobilePanel(){this._panelVisible&&(this._panelVisible=!1,this._panelEl.classList.remove("gengage-chat-panel--visible"),this._reopenPanelBtn&&(this._reopenPanelBtn.style.display="flex"))}_showMobilePanelFromBtn(){this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this._reopenPanelBtn&&(this._reopenPanelBtn.style.display="none"))}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"))}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")}_updateScrollAffordance(){const t=this._panelEl,n=t.scrollTop+t.clientHeight>=t.scrollHeight-10;t.classList.toggle("gengage-chat-panel--has-scroll",!n&&t.scrollHeight>t.clientHeight)}_setupHorizontalSwipe(t){let n=0,a=0;const i=r=>{if(window.innerWidth>768)return;const s=r.touches[0];s&&(n=s.clientX,a=s.clientY)},o=r=>{if(window.innerWidth>768)return;const s=r.changedTouches[0];if(!s)return;const c=s.clientX-n,l=s.clientY-a;Math.abs(c)>50&&Math.abs(c)>Math.abs(l)*2&&(this.togglePanel(),this._onPanelToggle?.())};t.addEventListener("touchstart",i,{passive:!0}),t.addEventListener("touchend",o,{passive:!0}),this._cleanups.push(()=>{t.removeEventListener("touchstart",i),t.removeEventListener("touchend",o)})}togglePanel(){this.setPanelCollapsed(!this._panelCollapsed)}isPanelCollapsed(){return this._panelCollapsed}setPanelCollapsed(t){this._panelCollapsed=t,t?this._panelEl.classList.add("gengage-chat-panel--collapsed"):this._panelEl.classList.remove("gengage-chat-panel--collapsed");const n=this._dividerEl.querySelector(".gengage-chat-panel-divider-toggle");n&&(n.textContent=t?"«":"»")}persistPanelState(t){try{const n=`gengage:panel:${t}`;this._panelCollapsed?sessionStorage.setItem(n,"collapsed"):sessionStorage.removeItem(n)}catch{}}restorePanelState(t){try{const n=`gengage:panel:${t}`;if(sessionStorage.getItem(n)==="collapsed")return this._panelCollapsed=!0,!0}catch{}return!1}_renderThinkingSteps(){const t=this.messagesEl.querySelector('[data-typing="true"]');if(!t){this.showTypingIndicator();return}t.innerHTML="",this._renderThinkingStepsInto(t),this._scrollToBottom(!1)}_renderThinkingStepsInto(t){const n=document.createElement("div");n.className="gengage-chat-thinking-steps";for(let a=0;a<this._thinkingSteps.length;a++){const i=document.createElement("div");i.className="gengage-chat-thinking-step";const o=document.createElement("span");o.className="gengage-chat-thinking-step-marker",a<this._thinkingSteps.length-1?(o.textContent="✓",o.classList.add("gengage-chat-thinking-step-marker--done")):(o.textContent="●",o.classList.add("gengage-chat-thinking-step-marker--active")),i.appendChild(o);const r=document.createElement("span");r.className="gengage-chat-thinking-step-text",r.textContent=this._thinkingSteps[a],i.appendChild(r),n.appendChild(i)}t.appendChild(n)}_updateSendEnabled(){const t=this.inputEl.value.trim().length>0||this._pendingAttachment!==null;this.sendBtn.disabled=!t}_submit(){const t=this.inputEl.value.trim(),n=this._pendingAttachment;!t&&!n||(this.onSend(t,n??void 0),this.inputEl.value="",this.inputEl.style.height="auto",this.clearAttachment(),this._updateSendEnabled())}_toggleVoice(){if(this._voiceInput)if(this._voiceInput.state==="listening"){const t=this._voiceInput.stop();t.trim()&&(this.inputEl.value=t,this._submit())}else this.inputEl.value="",this._voiceInput.start()}lockScrollForRestore(){this._scrollLockedUntil=Date.now()+500}_scrollToBottom(t=!1){!t&&this._userScrolledUp||!t&&this._options.presentation?.shouldBlockSoftAutoScroll?.()||!t&&Date.now()<this._scrollLockedUntil||requestAnimationFrame(()=>{this.messagesEl.scrollTop=this.messagesEl.scrollHeight,this._userScrolledUp=!1})}scrollToBottomIfNeeded(){this._scrollToBottom(!1)}updateBotMessage(t,n){const a=this.messagesEl.querySelector(`[data-message-id="${CSS.escape(t)}"]`);if(!a)return;let i=a.querySelector(".gengage-chat-bubble-text");i||(i=document.createElement("div"),i.className="gengage-chat-bubble-text",a.appendChild(i)),i.innerHTML=we(n),this._scrollToBottom(!1)}markFirstBotMessage(t){this._firstBotMessageIds.add(t);const n=this.messagesEl.querySelector(`[data-message-id="${CSS.escape(t)}"]`);n&&n.classList.add("gengage-chat-bubble--first")}scrollToLastThread(){const t=this.messagesEl.querySelectorAll("[data-thread-id]");if(t.length===0){this._scrollToBottom(!0);return}const n=t[t.length-1].getAttribute("data-thread-id");if(!n){this._scrollToBottom(!0);return}this._programmaticScrollUntil=Date.now()+700;const a=this.messagesEl.querySelector(`[data-thread-id="${CSS.escape(n)}"]`);a?requestAnimationFrame(()=>{a.scrollIntoView({block:"start",behavior:"auto"}),this._userScrolledUp=!1}):this._scrollToBottom(!0)}scrollThreadIntoView(t,n="smooth"){const a=this.messagesEl.querySelector(`[data-thread-id="${CSS.escape(t)}"]`);if(!a)return!1;const o=Math.max(a.offsetTop-20,0);return this._programmaticScrollUntil=Date.now()+700,this._scrollMessagesTo(o,n),!0}scrollToBottomPresentation(t="smooth"){this._programmaticScrollUntil=Date.now()+700,requestAnimationFrame(()=>{this._scrollMessagesTo(this.messagesEl.scrollHeight,t),this._userScrolledUp=!1})}_scrollMessagesTo(t,n){if(typeof this.messagesEl.scrollTo=="function"){this.messagesEl.scrollTo({top:t,behavior:n});return}this.messagesEl.scrollTop=t}setPresentationFocus(t){this._presentationFocusThreadId=t,this._applyPresentationCollapsed()}setFormerMessagesButtonVisible(t){this._formerMessagesBtn&&(this._formerMessagesBtn.style.display=t?"":"none")}_applyPresentationCollapsed(){const t=this._presentationFocusThreadId;this.messagesEl.querySelectorAll("[data-thread-id]").forEach(n=>{const a=n.dataset.threadId;a&&(t&&a!==t?n.classList.add("gengage-chat-bubble--presentation-collapsed"):n.classList.remove("gengage-chat-bubble--presentation-collapsed"))})}refreshPresentationCollapsed(){this._presentationFocusThreadId&&this._applyPresentationCollapsed()}setInputAreaChips(t){if(this._inputChipsEl.innerHTML="",t.length===0){this._inputChipsEl.style.display="none";return}this._inputChipsEl.style.display="";for(const n of t){const a=document.createElement("button");if(a.className="gengage-chat-input-chip",a.type="button",n.icon){const o=hn[n.icon]??pn,r=document.createElement("span");r.className="gengage-chat-input-chip-icon",r.innerHTML=o,a.appendChild(r)}const i=document.createElement("span");i.textContent=n.label,a.appendChild(i),a.addEventListener("click",()=>n.onAction()),this._inputChipsEl.appendChild(a)}}clearInputAreaChips(){this._inputChipsEl.innerHTML="",this._inputChipsEl.style.display="none"}setThumbnails(t){this._thumbnailsColumn.setEntries(t),t.length>0?this._thumbnailsColumn.show():this._thumbnailsColumn.hide()}hideThumbnails(){this._thumbnailsColumn.hide()}trapFocus(){this._previouslyFocusedElement=document.activeElement,this.releaseFocus();const t=n=>{if(n.key!=="Tab")return;const a=this.root.querySelectorAll('a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])');if(a.length===0)return;const i=a[0],o=a[a.length-1],r=this.root.getRootNode(),s=r instanceof ShadowRoot?r.activeElement:document.activeElement;n.shiftKey?(s===i||!this.root.contains(s))&&(n.preventDefault(),o.focus()):(s===o||!this.root.contains(s))&&(n.preventDefault(),i.focus())};this._focusTrapHandler=t,this.root.addEventListener("keydown",t)}releaseFocus(){if(this._focusTrapHandler&&(this.root.removeEventListener("keydown",this._focusTrapHandler),this._focusTrapHandler=null),this._previouslyFocusedElement){try{this._previouslyFocusedElement.focus()}catch{}this._previouslyFocusedElement=null}}destroy(){ln(null),this.releaseFocus(),this._clearStillWorkingTimer();for(const t of this._cleanups)t();this._cleanups.length=0,this._voiceInput?.destroy(),this._voiceInput=null}}const jo=`<svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
48
48
  <rect x="3" y="7" width="18" height="13" rx="3" fill="currentColor" opacity="0.15"/>
49
49
  <rect x="3" y="7" width="18" height="13" rx="3" stroke="currentColor" stroke-width="1.5"/>
50
50
  <circle cx="9" cy="13" r="1.5" fill="currentColor"/>
@@ -54,44 +54,44 @@
54
54
  <circle cx="12" cy="3" r="1" fill="currentColor"/>
55
55
  <path d="M1 12V14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
56
56
  <path d="M23 12V14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
57
- </svg>`;function Zo(e){const t=document.createElement("div");t.className="gengage-chat-launcher-container";const n=document.createElement("div");n.className="gengage-chat-launcher-content-area",t.appendChild(n);const a=document.createElement("button");if(a.type="button",a.setAttribute("aria-label",e.ariaLabel??"Open chat"),e.imageUrl){a.className="gengage-chat-launcher gengage-chat-launcher--image-mode";const o=document.createElement("img");o.src=e.imageUrl,o.alt="",o.draggable=!1,a.appendChild(o)}else a.className="gengage-chat-launcher",a.innerHTML=e.svgMarkup??Uo;if(e.tooltip!==void 0){const o=document.createElement("span");o.className="gengage-chat-launcher-tooltip",o.textContent=e.tooltip,a.appendChild(o)}e.hideMobile&&(t.dataset.hideMobile="1"),e.mobileBreakpoint!==void 0&&(t.dataset.mobileBreakpoint=String(e.mobileBreakpoint)),a.addEventListener("click",e.onClick),t.appendChild(a);const i=document.createElement("div");return i.className="gengage-chat-launcher-content-area-bottom",t.appendChild(i),{container:t,button:a,contentArea:n,contentAreaBottom:i}}const jo=new Set(["audio/ogg","audio/mpeg","audio/mp3","audio/wav","audio/webm","audio/aac","audio/mp4"]),hn=new Set;function Ct(e){e.pause(),e.removeAttribute("src"),e.load(),hn.delete(e)}function qo(e,t="audio/ogg"){const n=t.split(";")[0].trim();if(!jo.has(n))return null;try{const a=new Audio(`data:${t};base64,${e}`);return hn.add(a),a.addEventListener("ended",()=>Ct(a),{once:!0}),a.play().catch(()=>{Ct(a)}),{stop:()=>Ct(a)}}catch{return null}}const Ho={currencySymbol:"TL",currencyPosition:"suffix",thousandsSeparator:".",decimalSeparator:",",alwaysShowDecimals:!0};function le(e,t){const n=Number(e);if(!Number.isFinite(n)||n<0)return e;const a={...Ho,...t},o=n%1!==0||a.alwaysShowDecimals?n.toFixed(2):n.toFixed(0),r=o.indexOf("."),s=r===-1?o:o.slice(0,r),c=r===-1?void 0:o.slice(r+1),l=s.replace(/\B(?=(\d{3})+(?!\d))/g,a.thousandsSeparator);let d;return c!==void 0?d=`${l}${a.decimalSeparator}${c}`:d=l,a.currencySymbol?a.currencyPosition==="prefix"?`${a.currencySymbol}${d}`:`${d} ${a.currencySymbol}`:d}const Vo={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 Wo(e,t){return t?.[e]??Vo[e]??e.replace(/_/g," ").replace(/^\w/,n=>n.toUpperCase())}function Go(e){const{recommended:t,products:n,attributes:a,highlights:i,specialCases:o,onProductClick:r,i18n:s}=e,c=document.createElement("div");c.className="gengage-chat-comparison",c.setAttribute("role","dialog"),c.setAttribute("aria-label",s?.comparisonHeading??"Comparison Results");const l=document.createElement("h3");if(l.className="gengage-chat-comparison-heading",l.textContent=s?.comparisonHeading??"COMPARISON RESULTS",c.appendChild(l),t){const d=document.createElement("div");d.className="gengage-chat-comparison-recommended";const p=document.createElement("div");p.className="gengage-chat-comparison-recommended-label",p.textContent=s?.recommendedChoiceLabel??"Recommended Choice",d.appendChild(p);const g=document.createElement("div");if(g.className="gengage-chat-comparison-recommended-body",t.imageUrl&&Ee(t.imageUrl)){const y=document.createElement("img");y.src=t.imageUrl,y.alt=t.name,y.loading="lazy",y.addEventListener("error",()=>{y.style.display="none"},{once:!0}),g.appendChild(y)}const h=document.createElement("div");h.className="gengage-chat-comparison-recommended-info";const b=document.createElement("div");b.className="gengage-chat-comparison-recommended-title",b.textContent=t.name,h.appendChild(b);const _=document.createElement("div");if(_.className="gengage-chat-comparison-recommended-price",_.textContent=le(t.price,e.pricing),h.appendChild(_),g.appendChild(h),g.addEventListener("click",()=>{r(t.sku)}),g.style.cursor="pointer",d.appendChild(g),i.length>0){const y=document.createElement("div");y.className="gengage-chat-comparison-highlights";const x=document.createElement("div");x.className="gengage-chat-comparison-highlights-label",x.textContent=s?.highlightsLabel??"Key Highlights",y.appendChild(x);const k=document.createElement("ul");for(const I of i){const m=document.createElement("li");m.textContent=I,k.appendChild(m)}y.appendChild(k),d.appendChild(y)}if(e.recommendedText){const y=document.createElement("div");y.className="gengage-chat-comparison-recommended-text",y.innerHTML=_e(e.recommendedText),d.appendChild(y)}c.appendChild(d)}if(e.keyDifferencesHtml){const d=document.createElement("div");d.className="gengage-chat-comparison-key-differences";const p=document.createElement("h4");p.textContent=s?.keyDifferencesLabel??"Key Differences",d.appendChild(p);const g=document.createElement("div");g.className="gengage-chat-comparison-key-differences-content",g.innerHTML=_e(Ko(e.keyDifferencesHtml)),d.appendChild(g),c.appendChild(d)}if(o&&o.length>0){const d=document.createElement("details");d.className="gengage-chat-comparison-special";const p=document.createElement("summary");p.textContent=s?.specialCasesLabel??"For Special Cases",d.appendChild(p);const g=document.createElement("ul");for(const h of o)Yo(g,h);g.childElementCount>0&&d.appendChild(g),c.appendChild(d)}if(n.length>0&&a.length>0){const d=document.createElement("table");d.className="gengage-chat-comparison-table";const p=document.createElement("thead"),g=document.createElement("tr"),h=document.createElement("th");g.appendChild(h);for(const _ of n){const y=document.createElement("th");if(_.sku===t?.sku&&(y.className="gengage-chat-comparison-selected"),_.imageUrl&&Ee(_.imageUrl)){const I=document.createElement("img");I.src=_.imageUrl,I.alt=_.name,I.loading="lazy",I.addEventListener("error",()=>{I.style.display="none"},{once:!0}),y.appendChild(I)}const x=document.createElement("div");x.textContent=_.name,y.appendChild(x);const k=document.createElement("div");k.className="gengage-chat-comparison-table-price",k.textContent=le(_.price,e.pricing),y.appendChild(k),g.appendChild(y)}p.appendChild(g),d.appendChild(p);const b=document.createElement("tbody");for(const _ of a){const y=document.createElement("tr"),x=document.createElement("td");x.className="gengage-chat-comparison-label",x.textContent=Wo(_.label,s?.criteriaLabels),y.appendChild(x);for(let k=0;k<_.values.length;k++){const I=document.createElement("td");n[k]?.sku===t?.sku&&(I.className="gengage-chat-comparison-selected"),I.textContent=_.values[k]??"",y.appendChild(I)}b.appendChild(y)}d.appendChild(b),c.appendChild(d)}if(e.productActions){const d=document.createElement("div");d.className="gengage-chat-comparison-product-actions";for(const p of n)if(e.productActions[p.sku]){const h=document.createElement("button");h.className="gengage-chat-comparison-view-btn",h.type="button",h.textContent=p.name,h.addEventListener("click",()=>r(p.sku)),d.appendChild(h)}d.childElementCount>0&&c.appendChild(d)}return c.addEventListener("keydown",d=>{if(d.key!=="Tab")return;const p=c.querySelectorAll('button, [href], input, [tabindex]:not([tabindex="-1"])');if(p.length===0)return;const g=p[0],h=p[p.length-1];d.shiftKey&&document.activeElement===g?(d.preventDefault(),h.focus()):!d.shiftKey&&document.activeElement===h&&(d.preventDefault(),g.focus())}),c}function Ko(e){if(/<[uo]l[\s>]/i.test(e)||/<li[\s>]/i.test(e))return e;const t=e.split(`
58
- `).filter(n=>n.trim());return t.length<=1?e:"<ul>"+t.map(n=>`<li>${n.trim()}</li>`).join("")+"</ul>"}function Yo(e,t){const n=_e(t);if(!n)return;const a=document.createElement("template");a.innerHTML=n;const i=Array.from(a.content.querySelectorAll("li"));if(i.length>0){for(const r of i){const s=document.createElement("li");s.innerHTML=_e(r.innerHTML),e.appendChild(s)}return}const o=document.createElement("li");Jo(t)?o.innerHTML=n:o.textContent=t,e.appendChild(o)}function Jo(e){return/<\/?[a-z][\s\S]*>/i.test(e)}function Xo(e,t){const n=document.createElement("div");n.className="gengage-chat-review-highlights";const a=e.props?.reviews;if(!Array.isArray(a)||a.length===0){const x=document.createElement("div");return x.className="gengage-chat-review-empty",x.textContent=t?.emptyReviewsMessage??"No review summary found.",n.appendChild(x),n}const i=a.filter(x=>x!==null&&typeof x=="object"),o={all:i.length,positive:0,negative:0,neutral:0};for(const x of i)x.review_class==="positive"?o.positive++:x.review_class==="negative"?o.negative++:o.neutral++;const r=new Map;for(const x of i)if(typeof x.review_tag=="string"&&x.review_tag.length>0){const k=r.get(x.review_tag);k?k.count++:r.set(x.review_tag,{count:1,sentiment:x.review_class??"neutral"})}const s=r.size>0?r.keys().next().value:null;let c="all",l=s;const d=document.createElement("div");d.className="gengage-chat-review-tabs";const p=t?.reviewFilterAll??"All",g=t?.reviewFilterPositive??"Positive",h=t?.reviewFilterNegative??"Negative",b=[{label:`${p} (${o.all})`,filter:"all"}];o.positive>0&&b.push({label:`${g} (${o.positive})`,filter:"positive"}),o.negative>0&&b.push({label:`${h} (${o.negative})`,filter:"negative"});const _=document.createElement("div");_.className="gengage-chat-review-items";function y(){for(;_.firstChild;)_.removeChild(_.firstChild);const x=i.filter(k=>{const I=c==="all"||k.review_class===c,m=l===null||k.review_tag===l;return I&&m});for(const k of x){const I=document.createElement("article");I.className="gengage-chat-review-item";const m=k.review_class;if((m==="positive"||m==="negative"||m==="neutral")&&(I.dataset.tone=m),typeof k.review_tag=="string"&&k.review_tag.length>0){const C=document.createElement("div");C.className="gengage-chat-review-tag",C.textContent=k.review_tag,I.appendChild(C)}if(typeof k.review_text=="string"&&k.review_text.length>0){const C=document.createElement("div");C.className="gengage-chat-review-text",C.textContent=k.review_text,I.appendChild(C)}if(k.review_rating!==void 0&&String(k.review_rating).length>0){const C=document.createElement("div");C.className="gengage-chat-review-rating",C.textContent=String(k.review_rating),I.appendChild(C)}_.appendChild(I)}}for(const x of b){const k=document.createElement("button");k.className="gengage-chat-review-tab",k.type="button",k.textContent=x.label,x.filter===c&&k.classList.add("gengage-chat-review-tab--active"),k.addEventListener("click",()=>{c=x.filter;for(const I of d.querySelectorAll(".gengage-chat-review-tab"))I.classList.toggle("gengage-chat-review-tab--active",I===k);y()}),d.appendChild(k)}if(n.appendChild(d),r.size>0){const x=document.createElement("div");x.className="gengage-chat-review-pills";for(const[k,I]of r){const m=document.createElement("button");m.type="button",m.className="gengage-chat-review-pill",m.dataset.tone=I.sentiment,m.dataset.tag=k,k===l&&m.classList.add("gengage-chat-review-pill--active");const C=document.createElement("span");C.className="gengage-chat-review-pill-icon",C.textContent=I.sentiment==="positive"?"✓":I.sentiment==="negative"?"✕":"●",m.appendChild(C);const B=document.createElement("span");if(B.textContent=k,m.appendChild(B),I.count>1){const D=document.createElement("span");D.className="gengage-chat-review-pill-count",D.textContent=String(I.count),m.appendChild(D)}m.addEventListener("click",()=>{l=l===k?null:k;for(const D of x.querySelectorAll(".gengage-chat-review-pill")){const E=l!==null&&D.dataset.tag===l;D.classList.toggle("gengage-chat-review-pill--active",E)}y()}),x.appendChild(m)}n.appendChild(x)}return y(),n.appendChild(_),n}function un(e){return Number.isFinite(e)?Math.max(0,Math.min(5,e)):0}function fn(e){return Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function mn(e){const t=un(e),n=Math.floor(t),a=t-n>=.5,i=5-n-(a?1:0),o=document.createElement("span");if(o.className="gengage-star-rating",o.setAttribute("role","img"),o.setAttribute("aria-label",`${t.toFixed(1)} out of 5 stars`),n>0&&o.appendChild(document.createTextNode("★".repeat(n))),a){const r=document.createElement("span");r.className="gengage-star-half",r.textContent="☆";const s=document.createElement("span");s.textContent="★",r.appendChild(s),o.appendChild(r)}return i>0&&o.appendChild(document.createTextNode("☆".repeat(i))),o}function Be(e){e.addEventListener("error",()=>{e.style.display="none"},{once:!0})}function Qo(e){const t=e.product.sku;if(typeof t=="string"&&t.length>0)return t;const n=e.action?.payload;return n&&typeof n=="object"&&"sku"in n&&typeof n.sku=="string"?n.sku:null}const er={winner:"roleWinner",best_value:"roleBestValue",best_alternative:"roleBestAlternative"};function bn(e,t){if(!e||!t)return null;const n=er[e];return n?t[n]??e:e}function tr(e){const t=e.rating,n=typeof t=="number"?t:typeof t=="string"?parseFloat(t):NaN;if(Number.isNaN(n))return null;const a=document.createElement("div");return a.className="gengage-chat-ai-toppick-rating",a.textContent=`★ ${n.toFixed(1)}`,a}function nr(e,t,n){const a=document.createElement("div");a.className="gengage-chat-ai-toppick-media";const i=e.discountPercent;if(typeof i=="number"&&i>0){const r=document.createElement("span");r.className="gengage-chat-ai-toppick-discount-badge",r.textContent=`%${fn(i)}`,a.appendChild(r)}const o=e.imageUrl;if(o&&Ee(o)){const r=document.createElement("img");r.className="gengage-chat-ai-toppick-img",ae(r,"src",o),r.loading="lazy",r.alt=t,Be(r),a.appendChild(r)}n.appendChild(a)}function ar(e,t,n){const a=e.price,i=e.originalPrice;if(!a)return;const o=document.createElement("div");if(o.className="gengage-chat-ai-toppick-price",i&&i!==a){const s=document.createElement("span");s.className="gengage-chat-ai-toppick-original-price",s.textContent=le(i,n.pricing),o.appendChild(s),o.appendChild(document.createTextNode(" "))}const r=document.createElement("span");r.textContent=le(a,n.pricing),o.appendChild(r),t.appendChild(o)}function ir(e,t,n){const a=document.createElement("div");a.className=n?"gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--winner":"gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--compact";const i=e.product,o=i.name||"Product image",r=n?bn(e.role,t.i18n)??t.i18n?.roleWinner??"TOP MATCH":bn(e.role,t.i18n);if(r){const d=document.createElement("span");d.className="gengage-chat-ai-toppick-badge",d.textContent=r,a.appendChild(d)}nr(i,o,a);const s=document.createElement("div");s.className="gengage-chat-ai-toppick-body";const c=i.name;if(c){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-name",d.textContent=c,s.appendChild(d)}const l=tr(i);if(l&&s.appendChild(l),ar(i,s,t),e.reason){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-reason",d.textContent=e.reason,s.appendChild(d)}if(e.labels&&e.labels.length>0&&s.appendChild(rr(e.labels)),n&&typeof e.expertQualityScore=="number"){const d=document.createElement("div");d.className="gengage-chat-ai-toppick-score";let p=e.expertQualityScore,g=10;p>10?p=Math.round(p)/10:p<=5&&(g=5),d.textContent=`${p}/${g}`,s.appendChild(d)}if(n&&e.reviewHighlight){const d=document.createElement("blockquote");d.className="gengage-chat-ai-toppick-review",d.textContent=e.reviewHighlight,s.appendChild(d)}if(a.appendChild(s),e.action){const d=Qo(e),p=i.url??"",g=document.createElement("div");g.className="gengage-chat-ai-toppick-spinner",g.style.display=d&&t.topPicksLoadingSku===d?"":"none",a.appendChild(g);const h=document.createElement("button");h.className="gengage-chat-ai-toppick-cta",h.type="button",h.textContent=t.i18n?.viewDetails??"View Details",h.addEventListener("click",()=>{if(e.action?.type==="findSimilar"&&d&&t.onProductClick){t.onProductClick({sku:d,url:p});return}t.onAction(e.action)}),a.appendChild(h)}return a}function or(e,t){const n=document.createElement("div");n.className="gengage-chat-ai-top-picks";const a=e.props?.suggestions??[];if(a.length===0)return n;const i=document.createElement("h3");i.className="gengage-chat-ai-top-picks-title",i.textContent=t.i18n?.aiTopPicksTitle??"Top Picks",n.appendChild(i);const o=document.createElement("div");o.className="gengage-chat-ai-top-picks-scroll";for(let r=0;r<a.length;r++){const s=a[r],c=s.role==="winner"||r===0;o.appendChild(ir(s,t,c))}return n.appendChild(o),n}function rr(e){const t=document.createElement("div");t.className="gengage-chat-ai-toppick-labels";for(const n of e){const a=document.createElement("span");a.className="gengage-chat-ai-toppick-label",a.dataset.sentiment=n.sentiment??"neutral",a.textContent=n.label,t.appendChild(a)}return t}function sr(e,t){const n=document.createElement("div");n.className="gengage-chat-grounding-review";const a=e.props??{},i=a.title,o=a.reviewCount,r=a.action,s=t.i18n?.groundingReviewCta??"Read Reviews",c=document.createElement("span");c.className="gengage-chat-grounding-review-icon",c.textContent="📋",n.appendChild(c);const l=document.createElement("div");l.className="gengage-chat-grounding-review-body";const d=document.createElement("div");if(d.className="gengage-chat-grounding-review-title",d.textContent=i??t.i18n?.customerReviewsTitle??"Customer Reviews",l.appendChild(d),o){const g=document.createElement("div");g.className="gengage-chat-grounding-review-subtitle";const h=t.i18n?.groundingReviewSubtitle??"{count} yorum mevcut";g.textContent=h.replace("{count}",o),l.appendChild(g)}n.appendChild(l);const p=document.createElement("span");return p.className="gengage-chat-grounding-review-cta",p.textContent=`${s} →`,n.appendChild(p),r&&(n.style.cursor="pointer",n.setAttribute("role","button"),n.setAttribute("tabindex","0"),n.addEventListener("click",()=>t.onAction(r)),n.addEventListener("keydown",g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),t.onAction(r))})),n}function cr(e){if(e.action.type!=="findSimilar")return e.action;const t=e.action.payload&&typeof e.action.payload=="object"?e.action.payload:null,n=typeof t?.input=="string"&&t.input.trim()||typeof t?.text=="string"&&t.text.trim()||e.name.trim();if(!n)return e.action;const a={text:n,is_suggested_text:1};if(typeof t?.sku=="string"&&t.sku.trim()&&(a.sku=t.sku),Array.isArray(t?.group_skus)){const i=t.group_skus.filter(o=>typeof o=="string"&&o.length>0);i.length>0&&(a.group_skus=i)}return{title:e.action.title,type:"inputText",payload:a}}function lr(e,t){const n=document.createElement("div");n.className="gengage-chat-grouping-cards";const a=e.props?.entries??[];if(a.length===0)return n;const i=e.props?.sectionTitle,o=typeof i=="string"&&i.trim().length>0?i.trim():t.i18n?.aiBrowseCategoriesTitle;if(o){const s=document.createElement("h3");s.className="gengage-chat-grouping-section-title",s.textContent=o,n.appendChild(s)}const r=document.createElement("div");r.className="gengage-chat-grouping-cards-scroll";for(const s of a){const c=document.createElement("div");if(c.className="gengage-chat-grouping-card",c.style.cursor="pointer",c.addEventListener("click",()=>t.onAction(cr(s))),s.image&&Ee(s.image)){const g=document.createElement("img");g.className="gengage-chat-grouping-card-img",g.src=s.image,g.alt=s.name,g.width=64,g.height=64,c.appendChild(g)}const l=document.createElement("div");l.className="gengage-chat-grouping-card-body";const d=document.createElement("span");if(d.className="gengage-chat-grouping-card-name",d.textContent=s.name,l.appendChild(d),s.description){const g=document.createElement("span");g.className="gengage-chat-grouping-card-desc",g.textContent=s.description,l.appendChild(g)}if(s.labels&&s.labels.length>0){const g=document.createElement("span");g.className="gengage-chat-grouping-card-labels",g.textContent=s.labels.slice(0,3).join(" · "),l.appendChild(g)}c.appendChild(l);const p=document.createElement("span");p.className="gengage-chat-grouping-card-arrow",p.textContent="↳",c.insertBefore(p,c.firstChild),r.appendChild(c)}return n.appendChild(r),n}function gr(e,t){const n=document.createElement("div");n.className="gengage-chat-suggested-search-cards";const a=e.props?.entries??[];if(a.length===0)return n;for(const i of a){const o=document.createElement("div");if(o.className="gengage-chat-suggested-search-card",o.style.cursor="pointer",o.addEventListener("click",()=>t.onAction(i.action)),i.image&&Ee(i.image)){const c=document.createElement("img");c.className="gengage-chat-suggested-search-card-img",c.src=i.image,c.alt=i.shortName,c.width=40,c.height=40,o.appendChild(c)}const r=document.createElement("div");r.className="gengage-chat-suggested-search-card-body";const s=document.createElement("div");if(s.className="gengage-chat-suggested-search-card-name",s.textContent=i.shortName,r.appendChild(s),i.detailedMessage){const c=document.createElement("div");c.className="gengage-chat-suggested-search-card-desc",c.textContent=i.detailedMessage,r.appendChild(c)}if(i.whyDifferent){const c=document.createElement("div");c.className="gengage-chat-suggested-search-card-diff",c.textContent=i.whyDifferent,r.appendChild(c)}o.appendChild(r),n.appendChild(o)}return n}function dr(e,t){const n=document.createElement("button");n.className="gengage-chat-comparison-floating-btn",n.type="button";const a=t.i18n?.compareSelected??"Compare";return n.textContent=`${a} (${e.length})`,n.addEventListener("click",()=>{t.onAction({title:a,type:"getComparisonTable",payload:{sku_list:[...e]}})}),n}function pr(e){const t=document.createElement("div");t.className="gengage-chat-pros-cons";const n=e.props?.productName;if(n){const o=document.createElement("h4");o.className="gengage-chat-pros-cons-heading",o.textContent=n,t.appendChild(o)}const a=e.props?.pros,i=e.props?.cons;if(a&&a.length>0){const o=document.createElement("ul");o.className="gengage-chat-pros-cons-list";for(const r of a){const s=document.createElement("li");s.className="gengage-chat-pros-cons-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=r,s.appendChild(l),o.appendChild(s)}t.appendChild(o)}if(i&&i.length>0){const o=document.createElement("ul");o.className="gengage-chat-pros-cons-list";for(const r of i){const s=document.createElement("li");s.className="gengage-chat-pros-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=r,s.appendChild(l),o.appendChild(s)}t.appendChild(o)}return t}function hr(e,t){const n=e.props?.groups??[],a=e.props?.filterTags??[],i=document.createElement("div");if(i.className="gengage-chat-categories",n.length===0)return i;const o=document.createElement("div");o.className="gengage-chat-categories-tabs",o.setAttribute("role","tablist");const r=[],s=[],c=l=>{for(let d=0;d<r.length;d++){const p=d===l;r[d].classList.toggle("gengage-chat-categories-tab--active",p),r[d].setAttribute("aria-selected",String(p)),r[d].tabIndex=p?0:-1,s[d].style.display=p?"":"none"}};for(let l=0;l<n.length;l++){const d=n[l],p=`gengage-cat-tab-${l}`,g=`gengage-cat-panel-${l}`,h=document.createElement("button");h.className="gengage-chat-categories-tab",h.type="button",h.id=p,h.setAttribute("role","tab"),h.setAttribute("aria-controls",g),h.setAttribute("aria-selected",String(l===0)),h.tabIndex=l===0?0:-1,l===0&&h.classList.add("gengage-chat-categories-tab--active"),h.textContent=d.groupName,h.addEventListener("click",()=>c(l)),h.addEventListener("keydown",_=>{let y=-1;_.key==="ArrowRight"||_.key==="ArrowDown"?y=(l+1)%n.length:_.key==="ArrowLeft"||_.key==="ArrowUp"?y=(l-1+n.length)%n.length:_.key==="Home"?y=0:_.key==="End"&&(y=n.length-1),y>=0&&(_.preventDefault(),c(y),r[y].focus())}),r.push(h),o.appendChild(h);const b=document.createElement("div");b.className="gengage-chat-categories-grid",b.id=g,b.setAttribute("role","tabpanel"),b.setAttribute("aria-labelledby",p),l!==0&&(b.style.display="none");for(const _ of d.products){const y=ur(_,t);b.appendChild(y)}s.push(b)}i.appendChild(o);for(const l of s)i.appendChild(l);if(a.length>0){const l=document.createElement("div");l.className="gengage-chat-categories-filter-tags";for(const d of a){const p=document.createElement("button");p.className="gengage-chat-categories-filter-tag",p.type="button",p.textContent=d.title,d.action&&p.addEventListener("click",()=>{t.onAction(d.action)}),l.appendChild(p)}i.appendChild(l)}return i}function ur(e,t){const n=document.createElement("div");if(n.className="gengage-chat-product-card",e.imageUrl&&Ee(e.imageUrl)){const o=document.createElement("img");o.className="gengage-chat-product-card-img",o.src=e.imageUrl,o.alt=e.name,o.loading="lazy",Be(o),n.appendChild(o)}const a=document.createElement("div");a.className="gengage-chat-product-card-body";const i=document.createElement("div");if(i.className="gengage-chat-product-card-name",i.textContent=e.name,a.appendChild(i),e.price){const o=document.createElement("div");o.className="gengage-chat-product-card-price",o.textContent=le(e.price,t.pricing),a.appendChild(o)}return n.appendChild(a),t.onProductSelect&&(n.style.cursor="pointer",n.addEventListener("click",()=>{t.onProductSelect?.(e)})),n}function fr(e,t){const n=document.createElement("div");n.className="gengage-chat-handoff-notice",n.setAttribute("role","alert");const a=document.createElement("span");a.className="gengage-chat-handoff-notice-icon",a.textContent="👤",a.setAttribute("aria-hidden","true"),n.appendChild(a);const i=document.createElement("h4");i.className="gengage-chat-handoff-notice-heading",i.textContent=t.i18n?.handoffHeading??"Transferring to a support agent",n.appendChild(i);const o=e.props?.summary;if(o){const r=document.createElement("p");r.className="gengage-chat-handoff-notice-summary",r.textContent=o,n.appendChild(r)}return n}function mr(e,t){const n=e.props?.product??e.props,a=document.createElement("div");if(a.className="gengage-chat-product-summary",!n)return a;a.style.cursor="pointer",a.addEventListener("click",h=>{h.target.closest("a")||t.onProductSelect?.(n)});const i=n.imageUrl;if(i&&ce(i)){const h=document.createElement("div");h.className="gengage-chat-product-summary__image";const b=document.createElement("img");b.loading="lazy",ae(b,"src",i);const _=n.name;b.alt=_||"Product image",Be(b),h.appendChild(b),a.appendChild(h)}const o=document.createElement("div");o.className="gengage-chat-product-summary__content";const r=n.brand,s=n.name;if(s){const h=document.createElement("div");h.className="gengage-chat-product-summary__name";const _=r&&!s.toLowerCase().startsWith(r.toLowerCase())?`${r} ${s}`:s;h.textContent=_,h.title=_,o.appendChild(h)}const c=n.rating,l=n.reviewCount;if(typeof c=="number"&&Number.isFinite(c)&&c>0){const h=document.createElement("div");if(h.className="gengage-chat-product-summary__rating",h.appendChild(mn(c)),typeof l=="number"&&Number.isFinite(l)){const b=document.createElement("span");b.className="gengage-chat-product-summary__review-count",b.textContent=` (${l})`,h.appendChild(b)}o.appendChild(h)}const d=n.price,p=n.originalPrice;if(d){const h=document.createElement("div");if(h.className="gengage-chat-product-summary__price",p&&p!==d){const _=document.createElement("span");_.className="gengage-chat-product-summary__price-original",_.textContent=le(p,t.pricing),h.appendChild(_),h.appendChild(document.createTextNode(" "))}const b=document.createElement("span");b.className="gengage-chat-product-summary__price-current",b.textContent=le(d,t.pricing),h.appendChild(b),o.appendChild(h)}a.appendChild(o);const g=n.url;if(g&&ce(g)){const h=document.createElement("a");h.className="gengage-chat-product-summary__cta",ae(h,"href",g),ae(h,"target","_blank"),ae(h,"rel","noopener noreferrer"),h.textContent=t.i18n?.productCtaLabel??"View",a.appendChild(h)}return a}function _n(e){const t=e.min??1,n=e.max??99,a=Math.min(t,n),i=Math.max(t,n),o=Math.max(a,Math.min(i,e.initial??a)),r=e.compact??!1;let s=o;const c=document.createElement("div");c.className=`gengage-qty-stepper${r?" gengage-qty-stepper--compact":""}`;const l=document.createElement("button");l.className="gengage-qty-btn",l.type="button",l.textContent=e.decreaseSymbol??"−",l.setAttribute("aria-label",e.decreaseLabel??"Decrease");const d=document.createElement("span");d.className="gengage-qty-value",d.textContent=String(s),d.setAttribute("aria-live","polite"),d.setAttribute("aria-atomic","true");const p=document.createElement("button");p.className="gengage-qty-btn",p.type="button",p.textContent=e.increaseSymbol??"+",p.setAttribute("aria-label",e.increaseLabel??"Increase");const g=document.createElement("button");g.className="gengage-qty-submit",g.type="button";const h='<svg width="16" height="16" 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>';r?(g.innerHTML=e.submitIcon??h,g.title=e.label??"Add to Cart"):g.textContent=e.label??"Add to Cart";function b(){l.disabled=s<=a,p.disabled=s>=i}return l.addEventListener("click",_=>{_.stopPropagation(),s>a&&(s--,d.textContent=String(s),b())}),p.addEventListener("click",_=>{_.stopPropagation(),s<i&&(s++,d.textContent=String(s),b())}),g.addEventListener("click",_=>{_.stopPropagation(),e.onSubmit(s);const y=g.innerHTML;g.textContent="✓",g.classList.add("gengage-qty-submit--success"),g.disabled=!0,setTimeout(()=>{g.innerHTML=y,g.classList.remove("gengage-qty-submit--success"),g.disabled=!1},1200)}),c.addEventListener("click",_=>{_.stopPropagation()}),b(),c.appendChild(l),c.appendChild(d),c.appendChild(p),c.appendChild(g),c}function vn(){return window.innerWidth<768}const yn={ActionButtons:({element:e,context:t})=>br(e,t),ActionButton:({element:e,context:t})=>_r(e,t),ProductCard:({element:e,context:t})=>vr(e,t),ProductDetailsPanel:({element:e,context:t})=>yr(e,t),ProductGrid:({element:e,spec:t,renderElement:n,context:a})=>kr(e,t,n,a),ReviewHighlights:({element:e,context:t})=>Xo(e,{emptyReviewsMessage:t.i18n?.emptyReviewsMessage,reviewFilterAll:t.i18n?.reviewFilterAll,reviewFilterPositive:t.i18n?.reviewFilterPositive,reviewFilterNegative:t.i18n?.reviewFilterNegative}),ComparisonTable:({element:e,context:t})=>Cr(e,t),AITopPicks:({element:e,context:t})=>or(e,t),GroundingReviewCard:({element:e,context:t})=>sr(e,t),AIGroupingCards:({element:e,context:t})=>lr(e,t),AISuggestedSearchCards:({element:e,context:t})=>gr(e,t),ProsAndCons:({element:e})=>pr(e),CategoriesContainer:({element:e,context:t})=>hr(e,t),HandoffNotice:({element:e,context:t})=>fr(e,t),ProductSummaryCard:({element:e,context:t})=>mr(e,t),Divider:({element:e})=>Er(e)},Et=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const a of e.children){const i=t(a);i&&n.appendChild(i)}return n};function wn(){return{...yn}}function xn(e,t,n=yn,a=Et){return Ma({spec:e,context:t,registry:n,containerClassName:"gengage-chat-uispec",unknownRenderer:a})}function br(e,t){const n=document.createElement("div");n.className="gengage-chat-action-buttons";const a=e.props?.buttons;if(a)for(const i of a){const o=document.createElement("button");o.className="gengage-chat-action-btn",o.textContent=i.label,o.addEventListener("click",()=>t.onAction(i.action)),n.appendChild(o)}return n}function _r(e,t){const n=document.createElement("button");n.className="gengage-chat-action-btn";const a=e.props?.label;typeof a=="string"&&(n.textContent=a);const i=e.props?.action;return i&&n.addEventListener("click",()=>t.onAction(i)),n}function vr(e,t){const n=document.createElement("div");n.className="gengage-chat-product-card";const a=e.props?.product??e.props;if(!a)return n;const i=a.sku;i&&(n.dataset.sku=i),t.onProductSelect&&(n.style.cursor="pointer",n.addEventListener("click",m=>{n.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")||m.target.closest(".gengage-chat-product-card-atc")||m.target.closest(".gengage-chat-product-card-cta")||t.onProductSelect?.(a)}));const o=a.imageUrl;if(o&&ce(o)){const m=document.createElement("div");m.className="gengage-chat-product-card-img-wrapper";const C=document.createElement("img");C.className="gengage-chat-product-card-img",C.loading="lazy",ae(C,"src",o);const B=a.name;B&&(C.alt=B),Be(C),m.appendChild(C);const D=a.discountPercent;if(typeof D=="number"&&D>0){const S=document.createElement("span");S.className="gengage-chat-product-card-discount-badge",S.textContent=`%${fn(D)}`,m.appendChild(S)}const E=a.sku;if(E){const S=document.createElement("button");S.className="gengage-chat-find-similar-pill",S.type="button",S.textContent=t.i18n?.findSimilarLabel??"Find Similar",S.addEventListener("click",R=>{R.stopPropagation(),t.onAction({title:t.i18n?.findSimilarLabel??"Find Similar",type:"findSimilar",payload:{sku:E,...o?{image_url:o}:{}}})}),m.appendChild(S)}const A=a.sku;if(A&&t.onFavoriteToggle){const S=document.createElement("button");S.className="gengage-chat-favorite-btn",S.type="button",S.setAttribute("aria-label",t.i18n?.addToFavoritesLabel??"Add to favorites");const R=t.favoritedSkus?.has(A)??!1;R&&S.classList.add("gengage-chat-favorite-btn--active");const ne=R?"currentColor":"none";S.innerHTML=`<svg width="16" height="16" viewBox="0 0 24 24" fill="${ne}" 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>`,S.addEventListener("click",U=>{U.stopPropagation(),S.classList.toggle("gengage-chat-favorite-btn--active");const v=S.querySelector("svg");v&&v.setAttribute("fill",S.classList.contains("gengage-chat-favorite-btn--active")?"currentColor":"none"),t.onFavoriteToggle(A,a)}),m.appendChild(S)}n.appendChild(m)}const r=document.createElement("div");r.className="gengage-chat-product-card-body";const s=a.brand;if(s){const m=document.createElement("div");m.className="gengage-chat-product-card-brand",m.textContent=s,r.appendChild(m)}const c=a.name;if(c){const m=document.createElement("div");m.className="gengage-chat-product-card-name",m.textContent=c,m.title=c,r.appendChild(m)}const l=a.rating,d=a.reviewCount;if(typeof l=="number"&&Number.isFinite(l)&&l>0){const m=document.createElement("div");if(m.className="gengage-chat-product-card-rating",m.appendChild(mn(l)),typeof d=="number"&&Number.isFinite(d)){const C=document.createElement("span");C.className="gengage-chat-product-card-review-count",C.textContent=` (${d})`,m.appendChild(C)}r.appendChild(m)}const p=a.price,g=a.originalPrice;if(a.price_async===!0){const m=document.createElement("div");m.className="gengage-chat-product-card-price";const C=document.createElement("span");C.className="gengage-chat-price-skeleton",m.appendChild(C),r.appendChild(m),setTimeout(()=>{C.parentElement&&(p&&parseFloat(p)>0?C.replaceWith(document.createTextNode(le(p,t.pricing))):C.remove())},300)}else if(p&&parseFloat(p)>0){const m=document.createElement("div");if(m.className="gengage-chat-product-card-price",g&&g!==p){const B=document.createElement("span");B.className="gengage-chat-product-card-original-price",B.textContent=le(g,t.pricing),m.appendChild(B),m.appendChild(document.createTextNode(" "))}const C=document.createElement("span");C.textContent=le(p,t.pricing),m.appendChild(C),r.appendChild(m)}const b=a.inStock;if(typeof b=="boolean"){const m=document.createElement("div");m.className=`gengage-chat-product-card-stock ${b?"is-in-stock":"is-out-of-stock"}`,m.textContent=b?t.i18n?.inStockLabel??"In Stock":t.i18n?.outOfStockLabel??"Out of Stock",r.appendChild(m)}const _=a.promotions;if(_&&_.length>0){const m=document.createElement("div");m.className="gengage-chat-product-card-promos";for(const C of _.slice(0,3)){if(!C||/%(0(\.0+)?)\s/.test(C))continue;const B=document.createElement("span");B.className="gengage-chat-product-card-promo-badge",B.textContent=C,B.title=C,m.appendChild(B)}m.childElementCount>0&&r.appendChild(m)}n.appendChild(r);const y=a.url,x=a.sku,k=e.props?.action;if(k){const m=document.createElement("button");m.className="gengage-chat-product-card-cta",m.type="button",m.textContent=k.title||t.i18n?.productCtaLabel||"View",m.addEventListener("click",C=>{if(n.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){C.stopPropagation();return}t.onAction(k)}),n.appendChild(m)}else if(y&&ce(y)){const m=document.createElement("a");m.className="gengage-chat-product-card-cta",ae(m,"href",y),ae(m,"target","_blank"),ae(m,"rel","noopener noreferrer"),m.textContent=t.i18n?.productCtaLabel??"View",m.addEventListener("click",C=>{if(n.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){C.preventDefault(),C.stopPropagation();return}t.onProductClick&&x&&(C.preventDefault(),t.onProductClick({sku:x,url:y}))}),n.appendChild(m)}const I=a.cartCode;if(I&&x&&b!==!1){const m=_n({compact:!0,label:t.i18n?.addToCartButton??"Add to Cart",decreaseLabel:t.i18n?.decreaseLabel,increaseLabel:t.i18n?.increaseLabel,onSubmit:C=>{t.onAction({title:t.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:x,cartCode:I,quantity:C}})}});m.classList.add("gengage-chat-product-card-atc"),n.appendChild(m)}if(t.comparisonSelectMode&&x&&t.onToggleComparisonSku){const m=document.createElement("div");m.className="gengage-chat-comparison-select-wrapper";const C=document.createElement("input");return C.type="checkbox",C.className="gengage-chat-comparison-checkbox",C.checked=t.comparisonSelectedSkus?.includes(x)??!1,C.addEventListener("change",()=>{t.onToggleComparisonSku?.(x)}),m.addEventListener("click",B=>{B.target.closest(".gengage-chat-comparison-checkbox")||(B.stopPropagation(),t.onToggleComparisonSku?.(x))}),m.appendChild(C),m.appendChild(n),m}return n}function yr(e,t){const n=document.createElement("article");n.className="gengage-chat-product-details-panel";const a=e.props?.product??e.props;if(!a)return n;const i=a.images,o=a.imageUrl,r=a.sku;if(i&&i.length>1){const E=document.createElement("div");E.className="gengage-chat-product-details-media gengage-chat-product-details-gallery gengage-chat-product-details-img-wrap";const A=document.createElement("img");A.className="gengage-chat-product-details-img";const S=i.find(M=>ce(M));S&&ae(A,"src",S);const R=a.name;R&&(A.alt=R),Be(A),E.appendChild(A);const ne=document.createElement("div");ne.className="gengage-chat-product-gallery-thumbs";const U=6,v=i.filter(M=>!!M&&ce(M));let L=null,P=0;for(let M=0;M<v.length;M++){const ee=v[M];if(M>=U)break;const W=document.createElement("img");W.className="gengage-chat-product-gallery-thumb",M===0&&(W.classList.add("gengage-chat-product-gallery-thumb--active"),L=W),ae(W,"src",ee),W.alt=`${R??"Product"} ${M+1}`,W.width=48,W.height=48,Be(W),W.addEventListener("click",()=>{ae(A,"src",ee),L&&L.classList.remove("gengage-chat-product-gallery-thumb--active"),W.classList.add("gengage-chat-product-gallery-thumb--active"),L=W,P=M}),ne.appendChild(W)}if(v.length>U){const M=document.createElement("span");M.className="gengage-chat-product-gallery-thumb-more",M.textContent=`+${v.length-U}`,ne.appendChild(M)}let T=0;const N=50;if(A.addEventListener("touchstart",M=>{T=M.changedTouches[0].clientX},{passive:!0}),A.addEventListener("touchend",M=>{const ee=M.changedTouches[0].clientX,W=T-ee;if(Math.abs(W)<N)return;const Y=W>0?Math.min(P+1,v.length-1):Math.max(P-1,0);if(Y!==P){const he=v[Y];if(he){ae(A,"src",he);const Ne=ne.querySelectorAll(".gengage-chat-product-gallery-thumb");L&&L.classList.remove("gengage-chat-product-gallery-thumb--active"),Y<U&&Ne[Y]?(Ne[Y].classList.add("gengage-chat-product-gallery-thumb--active"),L=Ne[Y]):L=null,P=Y}}}),E.appendChild(ne),r){const M=document.createElement("button");M.className="gengage-chat-find-similar-pill",M.type="button",M.textContent=t.i18n?.findSimilarLabel??"Find Similar",M.addEventListener("click",()=>{t.onAction({title:t.i18n?.findSimilarLabel??"Find Similar",type:"findSimilar",payload:{sku:r,...S?{image_url:S}:{}}})}),E.appendChild(M)}n.appendChild(E)}else if(o&&ce(o)){const E=document.createElement("div");E.className="gengage-chat-product-details-media gengage-chat-product-details-img-wrap";const A=document.createElement("img");A.className="gengage-chat-product-details-img",A.loading="lazy",ae(A,"src",o),Be(A);const S=a.name;if(S&&(A.alt=S),E.appendChild(A),r){const R=document.createElement("button");R.className="gengage-chat-find-similar-pill",R.type="button",R.textContent=t.i18n?.findSimilarLabel??"Find Similar",R.addEventListener("click",()=>{t.onAction({title:t.i18n?.findSimilarLabel??"Find Similar",type:"findSimilar",payload:{sku:r,...o?{image_url:o}:{}}})}),E.appendChild(R)}n.appendChild(E)}const s=document.createElement("div");s.className="gengage-chat-product-details-content";const c=a.name;if(c){const E=document.createElement("h3");E.className="gengage-chat-product-details-title",E.textContent=c,E.title=c,s.appendChild(E)}const l=a.rating,d=a.reviewCount;if(typeof l=="number"&&Number.isFinite(l)&&l>0){const E=document.createElement("div");if(E.className="gengage-chat-product-details-rating",E.textContent=`★ ${un(l).toFixed(1)}`,typeof d=="number"&&Number.isFinite(d)){const A=document.createElement("span");A.className="gengage-chat-product-details-review-count",A.textContent=` (${d})`,E.appendChild(A)}s.appendChild(E)}const p=a.price,g=a.originalPrice;if(a.price_async===!0){const E=document.createElement("div");E.className="gengage-chat-product-details-price";const A=document.createElement("span");A.className="gengage-chat-price-skeleton",E.appendChild(A),s.appendChild(E),setTimeout(()=>{if(A.parentElement)if(p&&parseFloat(p)>0){const S=document.createElement("span");S.className="gengage-chat-product-details-current-price",S.textContent=le(p,t.pricing),A.replaceWith(S)}else A.remove()},300)}else if(p&&parseFloat(p)>0){const E=document.createElement("div");if(E.className="gengage-chat-product-details-price",g&&g!==p){const S=document.createElement("span");S.className="gengage-chat-product-details-original-price",S.textContent=le(g,t.pricing),E.appendChild(S),E.appendChild(document.createTextNode(" "))}const A=document.createElement("span");A.className="gengage-chat-product-details-current-price",A.textContent=le(p,t.pricing),E.appendChild(A),s.appendChild(E)}const b=a.inStock;if(typeof b=="boolean"){const E=document.createElement("div");E.className=`gengage-chat-product-details-stock ${b?"is-in-stock":"is-out-of-stock"}`,E.textContent=b?t.i18n?.inStockLabel??"In Stock":t.i18n?.outOfStockLabel??"Out of Stock",s.appendChild(E)}const _=a.promotions;if(_&&_.length>0){const E=document.createElement("div");E.className="gengage-chat-product-details-promos";for(const A of _.slice(0,3)){if(!A||/%(0(\.0+)?)\s/.test(A))continue;const S=document.createElement("span");S.className="gengage-chat-product-details-promo-badge",S.textContent=A,S.title=A,E.appendChild(S)}E.childElementCount>0&&s.appendChild(E)}const y=a.variants;if(y&&y.length>0){const E=document.createElement("div");E.className="gengage-chat-product-variants";const A=document.createElement("div");A.className="gengage-chat-product-variants-label",A.textContent=t.i18n?.variantsLabel??"Variants",E.appendChild(A);const S=document.createElement("div");S.className="gengage-chat-product-variants-list";for(const R of y){const U=R.value??R.name??R.variant_name,v=R.sku;if(!U&&!v)continue;const L=document.createElement("button");L.className="gengage-chat-product-variant-btn",L.type="button";const P=U??v??"",T=R.price;T&&String(T)!==String(p)?L.textContent=`${P} - ${le(String(T),t.pricing)}`:L.textContent=P,v&&L.addEventListener("click",()=>{t.onAction({title:P,type:"launchVariant",payload:{sku:v}})}),S.appendChild(L)}E.appendChild(S),s.appendChild(E)}const x=a.sku,k=a.cartCode,I=document.createElement("div");I.className="gengage-chat-product-details-actions";const m=e.props?.action;if(m){const E=document.createElement("button");E.className="gengage-chat-product-details-cta",E.type="button",E.textContent=m.title||t.i18n?.productCtaLabel||"View",E.addEventListener("click",()=>t.onAction(m)),I.appendChild(E)}else{const E=a.url;if(E&&ce(E)){const A=document.createElement("a");A.className="gengage-chat-product-details-cta",ae(A,"href",E),ae(A,"target","_blank"),ae(A,"rel","noopener noreferrer"),A.textContent=t.i18n?.productCtaLabel??"View",A.addEventListener("click",S=>{t.onProductClick&&x&&(S.preventDefault(),t.onProductClick({sku:x,url:E}))}),I.appendChild(A)}}if(k&&x&&b!==!1){const E=_n({compact:!1,label:t.i18n?.addToCartButton??"Add to Cart",decreaseLabel:t.i18n?.decreaseLabel,increaseLabel:t.i18n?.increaseLabel,onSubmit:A=>{t.onAction({title:t.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:x,cartCode:k,quantity:A}})}});E.classList.add("gengage-chat-product-details-atc-stepper"),I.appendChild(E)}const C=a.url;if(C&&ce(C)){let E=function(v,L){const P=document.createElementNS(ne,"circle");P.setAttribute("cx",v),P.setAttribute("cy",L),P.setAttribute("r","3"),U.appendChild(P)},A=function(v,L,P,T){const N=document.createElementNS(ne,"line");N.setAttribute("x1",v),N.setAttribute("y1",L),N.setAttribute("x2",P),N.setAttribute("y2",T),U.appendChild(N)};const S=document.createElement("button");S.className="gengage-chat-product-details-share",S.type="button";const R=t.i18n?.shareButton??"Share";S.title=R,S.setAttribute("aria-label",R);const ne="http://www.w3.org/2000/svg",U=document.createElementNS(ne,"svg");U.setAttribute("width","18"),U.setAttribute("height","18"),U.setAttribute("viewBox","0 0 24 24"),U.setAttribute("fill","none"),U.setAttribute("stroke","currentColor"),U.setAttribute("stroke-width","2"),U.setAttribute("stroke-linecap","round"),U.setAttribute("stroke-linejoin","round"),E("18","5"),E("6","12"),E("18","19"),A("8.59","13.51","15.42","17.49"),A("15.41","6.51","8.59","10.49"),S.appendChild(U),S.addEventListener("click",async()=>{const v=a.name;try{navigator.share?await navigator.share({title:v??"",url:C}):navigator.clipboard&&(await navigator.clipboard.writeText(C),S.classList.add("gengage-chat-product-details-share--copied"),setTimeout(()=>S.classList.remove("gengage-chat-product-details-share--copied"),1500))}catch{}}),I.appendChild(S)}I.childElementCount>0&&s.appendChild(I),n.appendChild(s);const B=a.description,D=a.specifications;return(B||D)&&n.appendChild(wr(B,D,t)),n}function wr(e,t,n){const a=document.createElement("div");a.className="gengage-chat-product-detail-tabs";const i=document.createElement("div");i.className="gengage-chat-product-detail-tab-bar";const o=[];if(e){const s=document.createElement("button");s.className="gengage-chat-product-detail-tab gengage-chat-product-detail-tab--active",s.type="button",s.textContent=n.i18n?.productInfoTab??"Product Info",i.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-product-detail-tab-panel",c.textContent=e,o.push(c)}if(t){const s=document.createElement("button");s.className=`gengage-chat-product-detail-tab${e?"":" gengage-chat-product-detail-tab--active"}`,s.type="button",s.textContent=n.i18n?.specificationsTab??"Specifications",i.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,g])=>({key:p,value:g}));for(const p of d){const g=document.createElement("tr"),h=document.createElement("td");h.className="gengage-chat-product-specs-key",h.textContent=p.key;const b=document.createElement("td");b.className="gengage-chat-product-specs-value",b.textContent=p.value,g.appendChild(h),g.appendChild(b),l.appendChild(g)}c.appendChild(l),o.push(c)}const r=i.querySelectorAll(".gengage-chat-product-detail-tab");r.forEach((s,c)=>{s.addEventListener("click",()=>{r.forEach(l=>l.classList.remove("gengage-chat-product-detail-tab--active")),s.classList.add("gengage-chat-product-detail-tab--active"),o.forEach((l,d)=>{l.style.display=d===c?"":"none"})})}),a.appendChild(i);for(const s of o)a.appendChild(s);return a}function kn(e,t,n){if(!n||n.type==="related")return e;const a=e.map(i=>{const r=t.elements[i]?.props?.product,s=r?Number(r.price):NaN;return{id:i,price:Number.isFinite(s)?s:1/0}});return a.sort((i,o)=>i.price===1/0&&o.price===1/0?0:i.price===1/0?1:o.price===1/0?-1:n.direction==="desc"?o.price-i.price:i.price-o.price),a.map(i=>i.id)}function xr(e,t,n,a){const i=kn(t,n,a),o=new Map;for(const r of Array.from(e.children)){const s=r.dataset.elementId;s&&o.set(s,r)}for(const r of i){const s=o.get(r);s&&e.appendChild(s)}}function kr(e,t,n,a){const i=document.createElement("div");i.className="gengage-chat-product-grid-wrapper";const o=e.children??[];if(o.length>1&&a?.onSortChange){const l=document.createElement("div");l.className="gengage-chat-product-sort-toolbar";const d=a.productSort??{type:"related"},p=[{label:a.i18n?.sortRelated??"Related",sortState:{type:"related"}},{label:a.i18n?.sortPriceAsc??"Price ↑",sortState:{type:"price",direction:"asc"}},{label:a.i18n?.sortPriceDesc??"Price ↓",sortState:{type:"price",direction:"desc"}}];for(const g of p){const h=document.createElement("button");h.className="gengage-chat-product-sort-btn",h.type="button",d.type===g.sortState.type&&d.direction===g.sortState.direction&&h.classList.add("gengage-chat-product-sort-btn--active"),h.textContent=g.label,h.addEventListener("click",()=>{a.onSortChange?.(g.sortState),xr(r,o,t,g.sortState),l.querySelectorAll(".gengage-chat-product-sort-btn").forEach(_=>_.classList.remove("gengage-chat-product-sort-btn--active")),h.classList.add("gengage-chat-product-sort-btn--active")}),l.appendChild(h)}if(a.onToggleComparisonSku){const g=document.createElement("div");g.className="gengage-chat-product-sort-separator",l.appendChild(g);const h=document.createElement("button");h.className="gengage-chat-comparison-toggle-btn",h.type="button",a.comparisonSelectMode&&h.classList.add("gengage-chat-comparison-toggle-btn--active"),a.isStreaming&&h.classList.add("gengage-chat-comparison-toggle-btn--hidden"),h.textContent=a.i18n?.compareSelected??"Compare",h.addEventListener("click",()=>{a.onToggleComparisonSku?.("")}),l.appendChild(h)}i.appendChild(l)}const r=document.createElement("div");r.className="gengage-chat-product-grid";const s=kn(o,t,a?.productSort);for(const l of s){if(!t.elements[l])continue;const d=n(l);d&&(d.dataset.elementId=l,r.appendChild(d))}if((a?.isMobile??vn())&&r.classList.add("gengage-chat-product-grid--mobile"),i.appendChild(r),e.props?.endOfList!==!0&&o.length>0){const l=document.createElement("button");l.className="gengage-chat-product-grid-view-more",l.type="button",l.textContent=a?.i18n?.viewMoreLabel??"Show More",l.addEventListener("click",()=>{a?.onAction({title:"More",type:"moreProductList",payload:{}})}),i.appendChild(l)}if(a?.comparisonSelectMode&&a.comparisonSelectedSkus&&a.comparisonSelectedSkus.length>=2){const l=dr(a.comparisonSelectedSkus,a);i.appendChild(l)}return i}function Cr(e,t){const n=e.props??{},a=n.keyDifferencesHtml,i=n.recommended,o=n.products??[],r=n.attributes??[],s=n.highlights??[],c=n.specialCases,l=n.recommendedText,d=n.winnerHits,p=n.productActions;if(!i)return document.createElement("div");const g={recommended:i,products:o,attributes:r,highlights:s,specialCases:c,onProductClick:b=>{t.onProductClick?.({sku:b,url:""})},pricing:t.pricing};l!==void 0&&(g.recommendedText=l),d!==void 0&&(g.winnerHits=d),p!==void 0&&(g.productActions=p),a!==void 0&&(g.keyDifferencesHtml=a),t.i18n&&(g.i18n={comparisonHeading:t.i18n.panelTitleComparisonResults,recommendedChoiceLabel:t.i18n.recommendedChoiceLabel,highlightsLabel:t.i18n.highlightsLabel,keyDifferencesLabel:t.i18n.keyDifferencesLabel,specialCasesLabel:t.i18n.specialCasesLabel,addToCartButton:t.i18n.addToCartButton});const h=Go(g);return(t.isMobile??vn())&&h.classList.add("gengage-chat-comparison--mobile"),h}function Er(e){const t=document.createElement("hr");t.className="gengage-chat-divider";const n=e.props?.label;if(n){const a=document.createElement("div");a.className="gengage-chat-divider-wrapper";const i=document.createElement("span");return i.className="gengage-chat-divider-label",i.textContent=n,a.appendChild(t),a.appendChild(i),a}return t}const Sr=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","LI","UL","OL","BLOCKQUOTE","PRE","TABLE","SECTION","HR","FIGURE","FIGCAPTION","DL","DT","DD"]);function Tr(e){const t=[];let n=[];for(const a of e)a.nodeType===Node.ELEMENT_NODE&&Sr.has(a.tagName)?(n.length>0&&(t.push(n),n=[]),t.push([a])):n.push(a);return n.length>0&&t.push(n),t}function Ar(e){for(const t of e)for(const n of t)if(n.nodeType===Node.ELEMENT_NODE&&(n.tagName==="TABLE"||n.querySelector?.("table")))return!0;return!1}function Ir(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Pr(e){const{container:t,html:n,delayMs:a=30,onTick:i,onComplete:o}=e,r=document.createElement("template");r.innerHTML=n;const s=Tr(r.content.childNodes);if(Ir()||s.length<=1||Ar(s))return t.innerHTML=n,o?.(),{complete(){},cancel(){},isRunning:!1};t.innerHTML="";let c=0,l=null,d=!0;function p(){if(!d||c>=s.length){d=!1,o?.();return}const g=s[c],h=document.createElement("span");h.className="gengage-chat-typewriter-block";for(const b of g)h.appendChild(b.cloneNode(!0));t.appendChild(h),c++,i?.(),c<s.length?l=setTimeout(p,a):(d=!1,o?.())}return p(),{complete(){d&&(l!==null&&clearTimeout(l),d=!1,t.innerHTML=n,o?.())},cancel(){l!==null&&clearTimeout(l),d=!1},get isRunning(){return d}}}function Cn(e){return e!==void 0&&/[\p{L}\p{N}_]/u.test(e)}function Lr(e){const{container:t,mentions:n,onProductClick:a}=e;if(n.length===0)return;const i=new Map;for(const o of n)o.short_name.length!==0&&i.set(o.short_name.toLowerCase(),o);if(i.size!==0)for(const[o,r]of i){const s=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);let c=s.nextNode(),l=!1;for(;c&&!l;){const d=c.textContent??"",p=d.toLowerCase().indexOf(o);if(p===-1){c=s.nextNode();continue}const g=p>0?d[p-1]:void 0,h=d[p+r.short_name.length];if(Cn(g)||Cn(h)){c=s.nextNode();continue}const b=d.slice(0,p),_=d.slice(p,p+r.short_name.length),y=d.slice(p+r.short_name.length),x=c.parentNode;if(!x){c=s.nextNode();continue}const k=document.createElement("a");k.className="gengage-product-mention",k.textContent=_,k.href="#",k.addEventListener("click",I=>{I.preventDefault(),a(r.sku)}),b&&x.insertBefore(document.createTextNode(b),c),x.insertBefore(k,c),y&&x.insertBefore(document.createTextNode(y),c),x.removeChild(c),l=!0}}}const zr=new Set(["search","info","review","similar"]),Nr=new Set(["quickAnswer","reviewSummary","searchDiscovery","launchDiscovery","exploreTogetherV2"]);function Mr(e){return!!(e.icon&&zr.has(e.icon)||e.action?.type&&Nr.has(e.action.type))}const St="gengage_choice_prompter_dismissed",Tt="gengage_choice_prompter_dismissed_global";function Br(e){const t=document.createElement("div");t.className="gengage-chat-choice-prompter";const n=document.createElement("div");n.className="gengage-chat-choice-prompter-heading",n.textContent=e.heading,t.appendChild(n);const a=document.createElement("div");a.className="gengage-chat-choice-prompter-suggestion",a.textContent=e.suggestion,t.appendChild(a);const i=document.createElement("button");i.type="button",i.className="gengage-chat-choice-prompter-cta",i.textContent=e.ctaLabel,i.addEventListener("click",()=>{En(e.threadId);try{sessionStorage.setItem(Tt,"1")}catch{}t.remove(),e.onCtaClick()}),t.appendChild(i);const o=document.createElement("button");return o.type="button",o.className="gengage-chat-choice-prompter-dismiss",o.textContent="×",o.setAttribute("aria-label",e.dismissAriaLabel??"Dismiss"),o.addEventListener("click",()=>{En(e.threadId);try{sessionStorage.setItem(Tt,"1")}catch{}t.remove(),e.onDismiss?.()}),t.appendChild(o),t}function Rr(){try{return sessionStorage.getItem(Tt)==="1"}catch{return!1}}function Or(e){try{const t=sessionStorage.getItem(St);return t?JSON.parse(t).includes(e):!1}catch{return!1}}function En(e){try{const t=sessionStorage.getItem(St),n=t?JSON.parse(t):[];n.includes(e)||n.push(e),sessionStorage.setItem(St,JSON.stringify(n))}catch{}}const $r="gengage_assistant",Dr=3,Te="sessions",fe="context",we="payload",me="favorites";function Ke(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}function Ue(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error),e.onabort=()=>n(e.error??new DOMException("Transaction aborted"))})}class Fr{constructor(t=$r,n=Dr){this._db=null,this._dbName=t,this._version=n}async open(){return this._db?this._db:new Promise((t,n)=>{const a=indexedDB.open(this._dbName,this._version);a.onupgradeneeded=i=>{const o=a.result,r=i.oldVersion;r<1&&(o.createObjectStore(Te,{keyPath:["userId","appId","sessionId"]}),o.createObjectStore(fe,{keyPath:["sessionId","threadId"]}),o.createObjectStore(we,{keyPath:["threadId","messageId"]}).createIndex("threadId","threadId",{unique:!1}),o.createObjectStore(me,{keyPath:["userId","appId","sku"]})),r>=1&&r<2&&(o.objectStoreNames.contains(Te)&&o.deleteObjectStore(Te),o.objectStoreNames.contains(we)&&o.deleteObjectStore(we),o.createObjectStore(Te,{keyPath:["userId","appId","sessionId"]}),o.createObjectStore(we,{keyPath:["threadId","messageId"]}).createIndex("threadId","threadId",{unique:!1}),o.objectStoreNames.contains(fe)||o.createObjectStore(fe,{keyPath:["sessionId","threadId"]})),r<3&&(o.objectStoreNames.contains(me)||o.createObjectStore(me,{keyPath:["userId","appId","sku"]}))},a.onsuccess=()=>{this._db=a.result,t(this._db)},a.onerror=()=>n(a.error)})}close(){this._db?.close(),this._db=null}async saveSession(t){const a=this._requireDb().transaction(Te,"readwrite");a.objectStore(Te).put(t),await Ue(a)}async loadSession(t,n,a){const o=this._requireDb().transaction(Te,"readonly");return await Ke(o.objectStore(Te).get([t,n,a]))??null}async saveContext(t){const a=this._requireDb().transaction(fe,"readwrite");a.objectStore(fe).put(t),await Ue(a)}async loadContext(t,n){const i=this._requireDb().transaction(fe,"readonly");return await Ke(i.objectStore(fe).get([t,n]))??null}async deleteContextsAfterThread(t,n){const i=this._requireDb().transaction(fe,"readwrite"),r=i.objectStore(fe).openCursor();await new Promise((s,c)=>{r.onsuccess=()=>{const l=r.result;if(!l){s();return}const d=l.value;if(d.sessionId===t&&d.threadId>n)try{l.delete()}catch{}l.continue()},r.onerror=()=>c(r.error)}),await Ue(i)}async loadLatestContext(t){const i=this._requireDb().transaction(fe,"readonly").objectStore(fe),o=IDBKeyRange.bound([t,""],[t,"￿"]);return new Promise((r,s)=>{const c=i.openCursor(o,"prev");c.onsuccess=()=>{const l=c.result;r(l?l.value:null)},c.onerror=()=>s(c.error)})}async savePayload(t){const a=this._requireDb().transaction(we,"readwrite");a.objectStore(we).put(t),await Ue(a)}async loadPayload(t,n){const i=this._requireDb().transaction(we,"readonly");return await Ke(i.objectStore(we).get([t,n]))??null}async loadPayloadsByThread(t){const i=this._requireDb().transaction(we,"readonly").objectStore(we).index("threadId"),o=[];return new Promise((r,s)=>{const c=i.openCursor(IDBKeyRange.only(t));c.onsuccess=()=>{const l=c.result;if(!l){r(o);return}o.push(l.value),l.continue()},c.onerror=()=>s(c.error)})}async saveFavorite(t){const a=this._requireDb().transaction(me,"readwrite");a.objectStore(me).put(t),await Ue(a)}async removeFavorite(t,n,a){const o=this._requireDb().transaction(me,"readwrite");o.objectStore(me).delete([t,n,a]),await Ue(o)}async loadFavorites(t,n){const i=this._requireDb().transaction(me,"readonly");return(await Ke(i.objectStore(me).getAll())).filter(r=>r.userId===t&&r.appId===n)}async isFavorite(t,n,a){const o=this._requireDb().transaction(me,"readonly");return await Ke(o.objectStore(me).get([t,n,a]))!==void 0}_requireDb(){if(!this._db)throw new Error("GengageIndexedDB: database not open. Call open() first.");return this._db}}const Ur=["comparisonTable","groupList","productDetailsSimilars","productList"];class Zr{constructor(t){this._lockCount=1,this._hiddenByUser=!1,this._lastPanelContentType=null,this._chatShown=!1,this._isFavoritesMode=!1,this._lastExtended=!1,this._onChange=t.onChange;const n=new Set(Ur);t.productDetailsInPanel&&n.add("productDetails"),this._panelContentTypes=n}get isExtended(){return this._lockCount===0&&!this._hiddenByUser&&!this._isFavoritesMode&&this._lastPanelContentType!==null&&this._panelContentTypes.has(this._lastPanelContentType)&&this._chatShown}unlock(){this._lockCount>0&&this._lockCount--,this._checkStateChange()}lock(){this._lockCount++,this._checkStateChange()}setHiddenByUser(t){this._hiddenByUser=t,this._checkStateChange()}setChatShown(t){this._chatShown=t,this._checkStateChange()}setFavoritesMode(t){this._isFavoritesMode=t,this._checkStateChange()}setPanelContentType(t){this._lastPanelContentType=t,this._checkStateChange()}_checkStateChange(){const t=this.isExtended;t!==this._lastExtended&&(this._lastExtended=t,this._onChange(t))}}class jr{constructor(t){this.deps=t,this.snapshots=new Map,this._snapshotRebuilders=new Map,this.snapshotTypes=new Map,this.activePanelMessageId=null,this.currentType=null,this.threads=[],this.lastActionType=null}snapshotForMessage(t,n){const a=this.deps.drawer();if(!a?.hasPanelContent()||a.isPanelLoading())return;const i=a.getPanelContentElement();if(!i)return;const o=i.cloneNode(!0);this.snapshots.set(t,o),n&&this._snapshotRebuilders.set(t,n),this.currentType&&this.snapshotTypes.set(t,this.currentType)}attachClickHandler(t){const a=this.deps.shadow()?.querySelector(`[data-message-id="${CSS.escape(t)}"]`);a&&(a.style.cursor="pointer",a.addEventListener("click",()=>this.restoreForMessage(t)))}restoreForMessage(t){const n=this._snapshotRebuilders.get(t),a=this.snapshots.get(t);if(!n&&!a)return!1;const i=this.deps.shadow(),o=this.deps.drawer();this.activePanelMessageId&&i?.querySelector(`[data-message-id="${CSS.escape(this.activePanelMessageId)}"]`)?.classList.remove("gengage-chat-bubble--active"),i?.querySelector(`[data-message-id="${CSS.escape(t)}"]`)?.classList.add("gengage-chat-bubble--active"),this.activePanelMessageId=t;const s=n?n():a.cloneNode(!0);o?.setPanelContent(s);const c=this.snapshotTypes.get(t);return c&&(this.currentType=c,this.updateTopBar(c)),!0}notifyExtension(t){const n=this.deps.bridge();t?setTimeout(()=>n?.send("maximize-pdp",{}),350):setTimeout(()=>n?.send("minify-pdp",{}),200)}titleForComponent(t,n){if(n)return n;const a=this.deps.i18n();switch(t){case"ProductDetailsPanel":return a.panelTitleProductDetails;case"ProductGrid":return Sn(this.lastActionType)?a.panelTitleSearchResults:a.panelTitleSimilarProducts;case"ComparisonTable":return a.panelTitleComparisonResults;case"AIGroupingCards":return a.panelTitleCategories;default:return""}}updateTopBar(t,n){const a=this.deps.currentThreadId();if(!a)return;const i=this.threads.indexOf(a),o=i>0,r=i>=0&&i<this.threads.length-1,s=this.titleForComponent(t,n);this.deps.drawer()?.updatePanelTopBar(o,r,s)}updateTopBarForLoading(t){const n=this.deps.i18n(),i={productDetails:n.panelTitleProductDetails,productList:Sn(this.lastActionType)?n.panelTitleSearchResults:n.panelTitleSimilarProducts,comparisonTable:n.panelTitleComparisonResults,groupList:n.panelTitleCategories}[t]??"";if(i){const o=this.deps.currentThreadId(),r=o?this.threads.indexOf(o):-1,s=r>0,c=r>=0&&r<this.threads.length-1;this.deps.drawer()?.updatePanelTopBar(s,c,i)}}updateExtendedMode(t){const a={ComparisonTable:"comparisonTable",AIGroupingCards:"groupList",ProductDetailsPanel:"productDetails",ProductGrid:"productList"}[t]??null;this.deps.extendedModeManager()?.setPanelContentType(a)}navigateBack(){const t=this.deps.currentThreadId();if(!t)return;const n=this.threads.indexOf(t);if(n>0){const a=this.threads[n-1];a&&this.deps.rollbackToThread(a)}}navigateForward(){const t=this.deps.currentThreadId();if(!t)return;const n=this.threads.indexOf(t);if(n>=0&&n<this.threads.length-1){const a=this.threads[n+1];a&&this.deps.rollbackToThread(a)}}toPanelSpec(t){const n=t.elements[t.root];if(!n||n.type!=="ProductCard")return t;const a={...n,type:"ProductDetailsPanel"};return{root:t.root,elements:{...t.elements,[t.root]:a}}}destroy(){this.snapshots.clear(),this._snapshotRebuilders.clear(),this.snapshotTypes.clear(),this.activePanelMessageId=null,this.currentType=null,this.threads=[]}}function Sn(e){return e==="user_message"||e==="inputText"}function qr(e){return e.similarsAppend&&e.currentPanelType==="ProductDetailsPanel"&&e.hasPanelContent&&!e.isPanelLoading?"appendSimilars":e.componentType==="ProductGrid"&&!e.isFirstPanelContentInStream&&e.hasPanelContent&&!e.isPanelLoading?"append":"replace"}class Tn{constructor(t){this.favoritedSkus=new Set,this._favoritesCache=new Map,this._persistLock=Promise.resolve(),this._db=t}get db(){return this._db}set db(t){this._db=t}async persist(t){if(!this._db)return;const n=this._persistLock;let a;this._persistLock=new Promise(i=>{a=i}),await n;try{await this._persistImpl(t)}finally{a()}}async _persistImpl(t){if(!this._db)return;const n=t.messages.map(i=>{const o={id:i.id,role:i.role,timestamp:i.timestamp,status:i.status==="streaming"?"done":i.status};return i.threadId!==void 0&&(o.threadId=i.threadId),i.content!==void 0&&(o.content=i.content),i.silent&&(o.silent=!0),o}),a={};for(const[i,o]of t.panelSnapshots)o.querySelector(".gengage-chat-panel-skeleton")||(a[i]=o.innerHTML);await this._db.saveSession({userId:t.userId,appId:t.appId,sessionId:t.sessionId,messages:n,currentThreadId:t.currentThreadId,lastThreadId:t.lastThreadId,createdAt:t.chatCreatedAt,panelThreads:t.panelThreads.length>0?t.panelThreads:void 0,thumbnailEntries:t.thumbnailEntries.length>0?t.thumbnailEntries:void 0,panelSnapshotHtml:Object.keys(a).length>0?a:void 0,sku:t.sku}),t.lastBackendContext&&t.currentThreadId&&await this._db.saveContext({sessionId:t.sessionId,threadId:t.currentThreadId,context:t.lastBackendContext});for(const i of t.messages)i.uiSpec&&i.threadId&&await this._db.savePayload({threadId:i.threadId,messageId:i.id,uiSpec:i.uiSpec})}async saveAndOpenURL(t,n,a){try{await n()}catch{}a?.send("openURLInNewTab",{url:t}),ce(t)&&(window.location.href=t)}async loadPayload(t,n){if(!this._db)return null;for(let a=0;a<3;a++){try{const i=await this._db.loadPayload(t,n);if(i)return i.uiSpec}catch{}a<2&&await new Promise(i=>setTimeout(i,100))}return null}async loadFavorites(t,n){if(this._db)try{const a=await this._db.loadFavorites(t,n);for(const i of a)this.favoritedSkus.add(i.sku),this._favoritesCache.set(i.sku,i)}catch{}}getFavoriteProducts(){return[...this._favoritesCache.values()].sort((t,n)=>(n.savedAt??"").localeCompare(t.savedAt??""))}async toggleFavorite(t,n,a,i){if(this.favoritedSkus.has(a))this.favoritedSkus.delete(a),this._favoritesCache.delete(a),this._db&&await this._db.removeFavorite(t,n,a);else{const o={userId:t,appId:n,sku:a,name:i.name,imageUrl:i.imageUrl,price:i.price,savedAt:new Date().toISOString()};this.favoritedSkus.add(a),this._favoritesCache.set(a,o),this._db&&await this._db.saveFavorite(o)}}close(){this._db?.close(),this._db=null}}const At=e=>`${e}:assistant`;class An{constructor(){this.groups={},this.pinnedToBottom=!0,this.userInteracting=!1,this.focusedThreadId=null,this.shown=!1,this.lastAutoAnchoredGroupId=null,this.scrollRequest=null,this._nextScrollId=1}setShown(t){this.shown=t,t||(this.userInteracting=!1,this.pinnedToBottom=!0,this.focusedThreadId=null,this.scrollRequest=null)}reset(){this.groups={},this.pinnedToBottom=!0,this.userInteracting=!1,this.focusedThreadId=null,this.lastAutoAnchoredGroupId=null,this.scrollRequest=null}registerAssistantActivity(t){const n=At(t),a=this.groups[n],i=this.shown&&this.pinnedToBottom&&!this.userInteracting?"active_unread":"unseen";this.groups[n]={id:n,threadId:t,readState:a?.readState==="seen"?i:a?.readState??i,status:"streaming",updatedAt:Date.now()},a?.readState==="seen"&&this.lastAutoAnchoredGroupId===n&&(this.lastAutoAnchoredGroupId=null)}finalizeAssistantGroup(t){const n=At(t),a=this.groups[n];a&&(a.status="complete",a.updatedAt=Date.now())}setGroupReadStates(t){const n=Date.now();for(const{groupId:a,readState:i}of t){const o=this.groups[a];!o||o.readState===i||(o.readState=i,o.updatedAt=n)}}requestThreadFocus(t,n="smooth"){this.focusedThreadId=t,this.scrollRequest={id:this._nextScrollId++,type:"thread",threadId:t,behavior:n}}requestScrollToBottom(t="smooth"){this.scrollRequest={id:this._nextScrollId++,type:"bottom",behavior:t}}consumeScrollRequest(t){this.scrollRequest?.id===t&&(this.scrollRequest=null)}releaseFocusedThread(){this.focusedThreadId=null}setFocusedThreadId(t){this.focusedThreadId=t}markGroupAutoAnchored(t){this.lastAutoAnchoredGroupId=t}shouldBlockStreamAutoScroll(){return this.shown&&this.userInteracting&&!this.pinnedToBottom}getAssistantReadState(t){return this.groups[At(t)]?.readState}}function Hr(e,t){for(let n=e.length-1;n>=0;n--){const a=e[n],i=t.getAssistantReadState(a);if(i!==void 0&&i!=="seen")return a}return null}const In="gengage_kvkk_shown",Vr=["kvkk","kişisel veri","kisisel veri"],Wr=/\b6698\b/;function It(e){const t=e.toLowerCase();return Vr.some(n=>t.includes(n))||Wr.test(t)}function Pn(e){try{return localStorage.getItem(`${In}_${e}`)==="1"}catch{return!1}}function Ln(e){try{localStorage.setItem(`${In}_${e}`,"1")}catch{}}function Gr(e){const n=new DOMParser().parseFromString(e,"text/html").body,a=Array.from(n.children);for(const i of a)if(It(i.textContent??"")){i.remove();break}return n.innerHTML.trim()}function Kr(e){const t=new DOMParser().parseFromString(e,"text/html");for(const n of Array.from(t.body.children))if(It(n.textContent??""))return n.outerHTML;return null}const Yr={tr:"TURKISH",en:"ENGLISH",de:"GERMAN",fr:"FRENCH"};function Jr(e){return e?Yr[e.toLowerCase().slice(0,2)]??"TURKISH":"TURKISH"}const Xr=':host{all:initial;font-family:var( --gengage-font-family, "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif );font-size:var(--gengage-font-size, 14px)}.gengage-chat-root button,.gengage-chat-root [role=button],.gengage-chat-root a{cursor:pointer}.gengage-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.gengage-chat-root{position:fixed;z-index:var(--gengage-z-index, 2147483647);--_gengage-chat-offset: var(--gengage-chat-offset, 20px);--_gengage-chat-launcher-bottom: var(--gengage-chat-launcher-bottom, 20px);--_gengage-chat-launcher-right: var(--gengage-chat-launcher-right, 20px);--_gengage-chat-launcher-size: var(--gengage-chat-launcher-size, 56px);--_gengage-chat-drawer-width: var(--gengage-chat-width, 400px);--_gengage-chat-radius: var(--gengage-chat-shell-radius, 1rem);--_gengage-chat-header-height: var(--gengage-chat-header-height, 60px);--_gengage-chat-conversation-width: var(--gengage-chat-conversation-width, 396px);--_gengage-chat-panel-min-width: var(--gengage-chat-panel-min-width, 320px);--_gengage-chat-panel-max-width: var(--gengage-chat-panel-max-width, 860px);--_gengage-chat-input-height: var(--gengage-chat-input-height, 48px);--_gengage-chat-shadow: var(--gengage-chat-shadow, 0 12px 40px rgba(25, 28, 29, .04));--_gengage-border-color: var(--gengage-border-color, #edeeef);--_gengage-discount-color: var(--gengage-discount-color, #a03d40);--_gengage-success-color: var(--gengage-success-color, #16a34a);--_gengage-text-primary: var(--gengage-text-primary, #191c1d);--_gengage-text-secondary: var(--gengage-text-secondary, #64748b);--_gengage-surface-secondary: var(--gengage-surface-secondary, #f3f4f5);--_gengage-surface-muted: var(--gengage-surface-muted, #f8f9fa);--_gengage-surface-dark: var(--gengage-surface-dark, #1e293b);--_gengage-rating-color: var(--gengage-rating-color, #d97706);--_gengage-error: var(--gengage-error, #dc2626);--_gengage-ghost-border: var(--gengage-ghost-border, rgba(228, 190, 188, .2));--_gengage-qty-btn-size: var(--gengage-qty-btn-size, 28px);--_gengage-qty-btn-size-compact: var(--gengage-qty-btn-size-compact, 24px)}.gengage-chat-launcher-container{position:fixed;bottom:var(--_gengage-chat-launcher-bottom);right:var(--_gengage-chat-launcher-right);display:flex;flex-direction:column;align-items:flex-end;gap:10px;z-index:var(--gengage-z-index, 2147483647)}.gengage-chat-launcher-content-area,.gengage-chat-launcher-content-area-bottom{display:flex;flex-direction:column;align-items:flex-end;gap:8px}.gengage-chat-launcher-content-area:empty,.gengage-chat-launcher-content-area-bottom:empty{display:none}.gengage-chat-root--open .gengage-chat-launcher-content-area,.gengage-chat-root--open .gengage-chat-launcher-content-area-bottom{display:none}.gengage-chat-root--open .gengage-chat-launcher-container{pointer-events:none;opacity:0;transition:opacity .2s ease}.gengage-chat-launcher{width:var(--_gengage-chat-launcher-size);height:var(--_gengage-chat-launcher-size);border-radius:50%;border:none;background:var(--gengage-primary-color, #b7102a);color:var(--gengage-primary-foreground, #ffffff);cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:0 8px 22px #191c1d2e;transition:transform .18s cubic-bezier(.2,.8,.2,1),box-shadow .18s ease;position:relative;flex-shrink:0}.gengage-chat-launcher:hover{transform:scale(1.05);box-shadow:0 14px 28px #191c1d38}.gengage-chat-launcher svg{width:28px;height:28px}.gengage-chat-launcher--image-mode{background:none;border-radius:0;box-shadow:none;padding:0;overflow:hidden}.gengage-chat-launcher--image-mode:hover{box-shadow:none}.gengage-chat-launcher--image-mode img{width:100%;height:100%;object-fit:contain}.gengage-chat-launcher--hidden-mobile{display:none!important}.gengage-chat-launcher-tooltip{position:absolute;right:calc(100% + 12px);top:50%;transform:translateY(-50%);padding:6px 12px;border-radius:8px;background:var(--_gengage-surface-dark);color:#fff;font-size:13px;font-weight:500;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .2s ease;box-shadow:0 2px 8px #00000026}.gengage-chat-launcher-tooltip:after{content:"";position:absolute;left:100%;top:50%;transform:translateY(-50%);border:5px solid transparent;border-left-color:var(--_gengage-surface-dark)}.gengage-chat-launcher:hover .gengage-chat-launcher-tooltip{opacity:1}.gengage-chat-root--open .gengage-chat-launcher-tooltip{display:none}.gengage-chat-drawer{position:fixed;top:0;bottom:0;right:0;width:var(--_gengage-chat-drawer-width);max-height:-webkit-fill-available;max-height:100dvh;border-radius:0;background:var(--gengage-background-color, #ffffff);box-shadow:var(--_gengage-chat-shadow);display:flex;flex-direction:column;overflow:hidden;z-index:var(--gengage-z-index, 2147483647);transform:translate(0);transition:transform .25s cubic-bezier(.4,0,.2,1),opacity .2s ease;opacity:1}.gengage-chat-root--mobile .gengage-chat-launcher-container{right:var(--gengage-chat-launcher-mobile-right, 16px);bottom:calc(var(--gengage-chat-launcher-mobile-bottom, 16px) + env(safe-area-inset-bottom,0px))}.gengage-chat-root--mobile .gengage-chat-drawer{left:0;right:0;bottom:0;width:100%;max-width:none;max-height:-webkit-fill-available;max-height:100dvh;border-radius:16px 16px 0 0;border-top:none;box-shadow:0 -4px 16px #0000001a,0 12px 40px #0f172a2e;padding-bottom:env(safe-area-inset-bottom,0px);background:var(--gengage-chat-header-bg, #1d2939)}.gengage-chat-drawer-handle{display:none}.gengage-chat-root--mobile .gengage-chat-drawer-handle{display:flex;align-items:center;justify-content:center;height:22px;flex-shrink:0;cursor:grab;touch-action:none;background:var(--gengage-chat-header-bg, #1d2939);border-radius:16px 16px 0 0;user-select:none;-webkit-user-select:none}.gengage-chat-root--mobile .gengage-chat-drawer-handle:before{content:"";width:36px;height:4px;border-radius:999px;background:#ffffff4d;pointer-events:none}.gengage-chat-root--mobile.gengage-chat-root--open:before{content:"";position:fixed;inset:0;background:#0000001f;z-index:-1;pointer-events:none}.gengage-chat-root--mobile.gengage-chat-root--mobile-half .gengage-chat-drawer{top:auto;height:min(72dvh,620px);max-height:min(72dvh,620px)}.gengage-chat-root--mobile.gengage-chat-root--mobile-full .gengage-chat-drawer{top:0;height:100dvh;max-height:100dvh;border-radius:0}.gengage-chat-root--mobile.gengage-chat-root--mobile-full .gengage-chat-drawer-handle{border-radius:0}.gengage-chat-root--mobile .gengage-chat-input-area{padding-bottom:calc(10px + env(safe-area-inset-bottom,0px));border-top:1px solid var(--_gengage-border-color, #e5e7eb);transform:translateY(calc(-1 * var(--gengage-keyboard-offset, 0px)))}.gengage-chat-header{display:flex;align-items:center;justify-content:space-between;box-sizing:border-box;min-height:var(--_gengage-chat-header-height);padding:4px 12px;background:var(--gengage-chat-header-bg, #1d2939);color:var(--gengage-chat-header-foreground, #fff);box-shadow:0 4px 20px #00000014,0 0 2px #0000001f;border:none;position:relative;z-index:2}.gengage-chat-header-left{display:flex;align-items:center;gap:10px;min-width:0}.gengage-chat-header-avatar{width:40px;height:40px;border-radius:0;object-fit:contain;flex-shrink:0}.gengage-chat-header-info{display:flex;flex-direction:column;gap:2px;min-width:0}.gengage-chat-header-title-row{display:flex;align-items:center;gap:6px}.gengage-chat-header-title{font-weight:700;font-size:15px;line-height:1.25;letter-spacing:.01em;color:inherit}.gengage-chat-header-badge{display:inline-flex;align-items:center;padding:1px 6px;border-radius:4px;background:var(--gengage-primary-color, #b7102a);color:#fff;font-size:10px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;line-height:1.5}.gengage-chat-header-powered{display:flex;align-items:center;gap:4px;font-size:11px;color:#ffffffa6;text-decoration:none;transition:color .15s}.gengage-chat-header-powered:hover{color:#fffc}.gengage-chat-header-powered svg{width:12px;height:12px;opacity:.6}.gengage-chat-header-right{display:flex;align-items:center;gap:4px;flex-shrink:0}.gengage-chat-header-btn{width:32px;height:32px;border-radius:8px;background:transparent;border:1px solid rgba(255,255,255,.12);color:#ffffffb3;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;text-decoration:none;line-height:1;transition:background-color .15s ease,color .15s ease,border-color .15s ease}.gengage-chat-header-btn:hover{background:#ffffff1a;color:#fff;border-color:#ffffff40}.gengage-chat-header-btn--fav{position:relative}.gengage-chat-header-btn--reopen-panel{display:none}.gengage-chat-header-fav-badge{position:absolute;top:-4px;right:-4px;min-width:16px;height:16px;border-radius:999px;background:var(--_gengage-danger-color, #ef4444);color:var(--_gengage-on-danger, #fff);font-size:9px;font-weight:700;line-height:16px;text-align:center;padding:0 3px;pointer-events:none}.gengage-chat-close{width:32px;height:32px;min-width:32px;min-height:32px;border-radius:8px;background:transparent;border:1px solid rgba(255,255,255,.12);color:#ffffffb3;font-size:18px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;line-height:1;transition:background-color .15s ease,color .15s ease,border-color .15s ease}.gengage-chat-close:hover{background:#ffffff1a;color:#fff;border-color:#ffffff40}.gengage-chat-body{display:flex;flex:1;overflow:hidden;min-height:0;position:relative}.gengage-chat-panel{display:none;width:0;overflow:hidden;transition:width .22s cubic-bezier(.2,.72,.2,1)}.gengage-chat-panel--visible{display:flex;flex-direction:column;position:relative;box-sizing:border-box;width:440px;min-width:440px;background:var(--gengage-chat-panel-bg, var(--_gengage-surface-muted, #fff));border-right:1px solid var(--_gengage-border-color);overflow-y:auto;padding:16px;scrollbar-width:thin;scrollbar-color:rgba(0,0,0,.15) transparent}.gengage-chat-panel--visible::-webkit-scrollbar{width:6px}.gengage-chat-panel--visible::-webkit-scrollbar-track{background:transparent}.gengage-chat-panel--visible::-webkit-scrollbar-thumb{background:#00000026;border-radius:3px}.gengage-chat-panel--visible::-webkit-scrollbar-thumb:hover{background:#00000040}.gengage-chat-panel-ai-zone{flex-shrink:0;width:100%;box-sizing:border-box;padding:8px 0 12px;margin-bottom:4px;border-bottom:1px solid var(--_gengage-border-color, rgba(0, 0, 0, .08));max-height:min(42vh,320px);overflow:auto}.gengage-chat-panel-ai-zone:has(.gengage-chat-grouping-cards){max-height:min(52vh,520px)}.gengage-chat-panel-ai-zone:has(.gengage-chat-ai-top-picks){max-height:none;overflow:visible}.gengage-chat-panel-ai-zone[hidden]{display:none!important}.gengage-chat-panel-ai-zone-inner{display:flex;align-items:center;gap:10px}.gengage-chat-panel-ai-zone-text{font-size:13px;color:var(--_gengage-muted, #64748b)}.gengage-chat-grouping-section-title{display:none}.gengage-chat-panel-ai-zone .gengage-chat-grouping-section-title{display:block;flex-shrink:0;align-self:stretch;width:100%;margin:0 0 10px;font-size:15px;font-weight:700;color:var(--gengage-text-color, #1e293b);letter-spacing:-.01em}.gengage-chat-panel-ai-zone .gengage-chat-grouping-cards{display:flex;flex-direction:column;align-items:stretch;gap:0;width:100%;min-width:0;max-height:none}.gengage-chat-panel-ai-zone .gengage-chat-grouping-cards-scroll{display:flex;flex-direction:row;flex-wrap:nowrap;align-items:stretch;gap:10px;width:100%;min-width:0;overflow-x:auto;overflow-y:hidden;padding:2px 2px 10px;margin:0 -2px;-webkit-overflow-scrolling:touch;scrollbar-width:thin}.gengage-chat-panel-ai-zone .gengage-chat-grouping-card{flex:0 0 auto;width:136px;min-width:136px;max-width:150px;box-sizing:border-box;flex-direction:column;align-items:stretch;gap:8px;padding:12px 10px 14px;background:#fff;border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:12px;box-shadow:0 1px 2px #0f172a0a}.gengage-chat-panel-ai-zone .gengage-chat-grouping-card:hover{border-color:var(--gengage-primary-color, #ea580c);box-shadow:0 2px 8px #ea580c1f}.gengage-chat-panel-ai-zone .gengage-chat-grouping-card-arrow{display:none}.gengage-chat-panel-ai-zone .gengage-chat-grouping-card-img{width:100%;max-width:88px;height:72px;min-width:0;min-height:72px;margin:0 auto;border-radius:8px;object-fit:cover}.gengage-chat-panel-ai-zone .gengage-chat-grouping-card-body{flex-direction:column;align-items:center;text-align:center;gap:4px;width:100%}.gengage-chat-panel-ai-zone .gengage-chat-grouping-card-name{font-size:13px;font-weight:700;line-height:1.25}.gengage-chat-panel-ai-zone .gengage-chat-grouping-card-desc{font-size:11px;color:var(--gengage-text-muted, #64748b);line-height:1.3}.gengage-chat-panel-ai-zone .gengage-chat-grouping-card-labels{display:block;margin-top:0;font-size:11px;color:var(--gengage-chat-text-secondary, #64748b);white-space:normal;text-overflow:unset;overflow:visible;line-height:1.35}.gengage-chat-panel-divider{display:flex;align-items:center;width:4px;cursor:pointer;background:var(--_gengage-border-color);position:relative;flex-shrink:0;transition:background .15s;z-index:2}.gengage-chat-panel-divider:hover{background:#cbd5e1}.gengage-chat-panel-divider--hidden{display:none}.gengage-chat-panel-divider-toggle{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:28px;height:48px;border:1px solid var(--_gengage-border-color);border-radius:6px;background:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:14px;color:var(--_gengage-text-secondary);box-shadow:0 1px 3px #00000014;transition:background .15s,color .15s;padding:0;line-height:1}.gengage-chat-panel-divider-toggle:hover{background:var(--_gengage-surface-muted);color:#334155}.gengage-chat-panel.gengage-chat-panel--collapsed{flex:0 0 0px;width:0;min-width:0;max-width:0;padding:0;border-right:none;overflow:hidden}.gengage-chat-panel--collapsed~.gengage-chat-panel-divider{width:0;background:transparent}.gengage-chat-panel--collapsed~.gengage-chat-panel-divider .gengage-chat-panel-divider-toggle{left:0;transform:translateY(-50%)}.gengage-chat-conversation{display:flex;flex-direction:column;flex:1;min-width:0;overflow:hidden;background:var(--gengage-background-color, #ffffff);position:relative;z-index:1}.gengage-chat-drawer--with-panel{width:auto;background:transparent;box-shadow:none}.gengage-chat-drawer--with-panel .gengage-chat-header{border-radius:0;flex-shrink:0}.gengage-chat-drawer--with-panel .gengage-chat-body{flex:1 1 0;min-height:0;gap:0;padding:0;align-items:stretch}.gengage-chat-drawer--with-panel .gengage-chat-panel--visible{flex:0 0 auto;width:clamp(var(--_gengage-chat-panel-min-width),50vw,var(--_gengage-chat-panel-max-width));min-width:var(--_gengage-chat-panel-min-width);max-width:var(--_gengage-chat-panel-max-width);border-right:none;background:var(--gengage-chat-panel-bg, var(--_gengage-surface, #fff));padding:0 16px 16px;overflow-y:auto;margin:0;border-radius:0;box-shadow:0 8px 32px #0f172a1f,0 2px 8px #0f172a0f;max-height:100dvh}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider{width:0;background:transparent}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle{width:20px;height:48px;border-radius:10px;background:var(--gengage-primary-color, #b7102a);color:#fff;border:2px solid #fff;box-shadow:0 2px 8px #0f172a2e;font-size:12px;z-index:10}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle:hover{background:var(--gengage-primary-hover, #9a0d23);color:#fff}.gengage-chat-drawer--with-panel .gengage-chat-conversation{flex:0 0 var(--_gengage-chat-conversation-width);width:var(--_gengage-chat-conversation-width);border-left:none;background:var(--gengage-background-color, #ffffff);box-shadow:-4px 0 24px #0f172a1f,-1px 0 4px #0f172a0f}.gengage-chat-drawer--with-panel .gengage-chat-messages{padding-right:6px;scrollbar-width:thin;scrollbar-color:rgba(0,0,0,.12) transparent}.gengage-chat-drawer--with-panel .gengage-chat-messages::-webkit-scrollbar{width:0}.gengage-chat-drawer--with-panel .gengage-chat-panel.gengage-chat-panel--collapsed{flex:0 0 0px;width:0;min-width:0;max-width:0;padding:0;overflow:hidden}.gengage-chat-drawer--with-panel:has(.gengage-chat-panel--collapsed){width:var(--_gengage-chat-conversation-width);background:var(--gengage-background-color, #ffffff);box-shadow:var(--_gengage-chat-shadow)}.gengage-chat-drawer--with-panel .gengage-chat-footer{display:none}.gengage-chat-messages{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:16px;min-height:0;scroll-behavior:smooth;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;touch-action:pan-y}.gengage-chat-messages::-webkit-scrollbar{width:6px}.gengage-chat-messages::-webkit-scrollbar-track{background:transparent}.gengage-chat-messages::-webkit-scrollbar-thumb{background:#0000001f;border-radius:3px}.gengage-chat-messages::-webkit-scrollbar-thumb:hover{background:#0003}.gengage-chat-bubble--presentation-collapsed{display:none!important}.gengage-chat-former-messages-btn{position:sticky;top:0;z-index:2;flex-shrink:0;align-self:center;margin-bottom:4px;padding:8px 14px;border-radius:999px;border:1px solid var(--_gengage-border-color, #e5e7eb);background:var(--gengage-background-color, #ffffff);color:var(--_gengage-text-primary, #1f2937);font-size:13px;font-weight:600;cursor:pointer;box-shadow:0 2px 8px #0f172a14}.gengage-chat-former-messages-btn:hover{background:var(--_gengage-surface-secondary, #f3f4f6)}.gengage-chat-bubble{max-width:85%;padding:12px 16px;border-radius:12px;line-height:1.5;font-size:14px;font-weight:500;word-wrap:break-word;overflow-wrap:break-word;animation:gengage-chat-msg-in .3s cubic-bezier(.2,.7,.2,1)}@keyframes gengage-chat-msg-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-bubble--user{align-self:flex-end;background:var(--gengage-primary-color, #b7102a);color:var(--gengage-primary-foreground, #ffffff);border-bottom-right-radius:4px}.gengage-chat-bubble--assistant{align-self:flex-start;background:var(--_gengage-surface-secondary);color:var(--_gengage-text-primary);border-bottom-left-radius:4px;min-width:120px}.gengage-chat-bubble--active{outline:2px solid var(--gengage-primary-color, #b7102a);outline-offset:-2px}.gengage-chat-bubble--assistant:empty{display:none}.gengage-chat-bubble--assistant .gengage-chat-bubble-text a{color:var(--gengage-primary-color, #b7102a);text-decoration:underline}.gengage-chat-bubble--assistant .gengage-chat-bubble-text a:hover{text-decoration:none}.gengage-chat-bubble--assistant .gengage-chat-bubble-text p{margin:0 0 8px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text p:last-child{margin-bottom:0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text ul,.gengage-chat-bubble--assistant .gengage-chat-bubble-text ol{margin:6px 0;padding-left:20px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text li{margin-bottom:6px;line-height:1.5}.gengage-chat-bubble--assistant .gengage-chat-bubble-text code{background:#0000000f;padding:1px 4px;border-radius:3px;font-size:.9em}.gengage-chat-bubble--assistant .gengage-chat-bubble-text pre{background:#0000000a;padding:8px;border-radius:6px;overflow-x:auto;margin:4px 0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text table{border-collapse:collapse;margin:4px 0;font-size:.9em}.gengage-chat-bubble--assistant .gengage-chat-bubble-text th,.gengage-chat-bubble--assistant .gengage-chat-bubble-text td{border:1px solid var(--_gengage-border-color);padding:4px 8px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text img{max-width:100%;height:auto;border-radius:4px;margin:4px 0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text h1,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h2,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h3,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h4,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h5,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h6{margin:8px 0 4px;line-height:1.3;color:#0f172a}.gengage-chat-bubble--assistant .gengage-chat-bubble-text blockquote{border-left:3px solid var(--_gengage-border-color);padding-left:12px;margin:4px 0;color:var(--_gengage-text-secondary)}.gengage-chat-bubble--assistant .gengage-chat-bubble-text{overflow-wrap:break-word}.gengage-chat-bubble--first{border-left:3px solid var(--gengage-primary-color, #b7102a);padding-left:12px}.gengage-chat-bubble--first .gengage-chat-bubble-text{font-size:15px}@media(max-width:768px){.gengage-chat-bubble--assistant .gengage-chat-bubble-text{line-height:1.5}.gengage-chat-bubble--user{max-width:calc(100% - 16px);word-break:break-word}}.gengage-chat-typing{display:flex;align-items:center;gap:5px;padding:8px 4px;align-self:flex-start;max-width:85%}.gengage-chat-typing:has(.gengage-chat-typing-text),.gengage-chat-typing:has(.gengage-chat-thinking-steps){background:var(--_gengage-surface-secondary);padding:10px 14px;border-radius:12px 12px 12px 4px;gap:8px}.gengage-chat-typing-dots{display:flex;align-items:center;gap:5px}.gengage-chat-typing-dots span{width:6px;height:6px;border-radius:50%;background:#94a3b8;display:inline-block;animation:gengage-chat-typing-fade 1.4s ease-in-out infinite}.gengage-chat-typing-dots span:nth-child(2){animation-delay:.2s}.gengage-chat-typing-dots span:nth-child(3){animation-delay:.4s}@keyframes gengage-chat-typing-fade{0%,to{opacity:.25}50%{opacity:1}}.gengage-chat-typing-sparkle{animation:gengage-sparkle-pulse 1.2s infinite}@keyframes gengage-sparkle-pulse{0%,to{opacity:1}50%{opacity:.4}}.gengage-chat-typing-text{font-size:13px;color:var(--_gengage-text-secondary);font-style:italic;flex:1;min-width:0;word-wrap:break-word;overflow-wrap:break-word}.gengage-chat-stop-btn{display:flex;align-items:center;gap:6px;margin:4px 0 8px;padding:6px 16px;border:1px solid var(--gengage-primary-color, #b7102a);border-radius:16px;background:var(--gengage-background-color, #ffffff);color:var(--gengage-primary-color, #b7102a);font-size:12px;max-width:200px;align-self:center;cursor:pointer;transition:background .15s ease,border-color .15s ease}.gengage-chat-stop-btn:hover{background:var(--_gengage-surface-secondary);border-color:var(--gengage-primary-color, #b7102a)}.gengage-chat-stop-btn:focus-visible{outline:2px solid var(--gengage-primary-color, #b7102a);outline-offset:2px}.gengage-chat-stop-icon{display:inline-block;width:10px;height:10px;background:currentColor;border-radius:2px;flex-shrink:0}.gengage-chat-offline-bar{display:none;align-items:center;gap:6px;padding:6px 12px;font-size:12px;line-height:1.4;color:#92400e;background:#fef3c7;border-bottom:1px solid #fde68a}.gengage-chat-offline-bar--visible{display:flex}.gengage-chat-offline-bar:before{content:"";display:inline-block;width:8px;height:8px;background:var(--_gengage-rating-color);border-radius:50%;flex-shrink:0}.gengage-chat-still-working{font-size:12px;color:var(--gengage-chat-text-secondary, #666);margin-top:6px;animation:gengage-fade-in .3s ease}@keyframes gengage-fade-in{0%{opacity:0}to{opacity:1}}.gengage-chat-thinking-steps{display:flex;flex-direction:column;gap:4px;padding:4px 0}.gengage-chat-thinking-step{display:flex;align-items:center;gap:6px;font-size:13px;color:var(--gengage-chat-text-secondary, #666)}.gengage-chat-thinking-step-marker{font-size:12px;width:16px;text-align:center;flex-shrink:0}.gengage-chat-thinking-step-marker--done{color:var(--_gengage-success-color)}.gengage-chat-thinking-step-marker--active{color:var(--gengage-primary-color, #b7102a);animation:gengage-thinking-pulse 1.5s ease-in-out infinite}@keyframes gengage-thinking-pulse{0%,to{opacity:1}50%{opacity:.4}}.gengage-chat-thinking-step-text{line-height:1.4}.gengage-chat-error{display:flex;align-items:center;justify-content:center;gap:10px;padding:10px 14px;border-radius:10px;background:#fef2f2;color:var(--gengage-error, #991b1b);font-size:13px;text-align:center;border:1px solid #fecaca}.gengage-chat-error-retry{flex-shrink:0;padding:4px 12px;border:1px solid #fca5a5;border-radius:6px;background:#fff;color:#991b1b;font-size:12px;font-weight:500;cursor:pointer;transition:background .15s}.gengage-chat-error-retry:hover{background:#fee2e2}.gengage-chat-input-area{display:flex;flex-wrap:wrap;align-items:center;flex-shrink:0;gap:0;padding:8px 12px;border-top:1px solid var(--_gengage-border-color);background:var(--gengage-background-color, #ffffff)}.gengage-chat-input-pill{display:flex;align-items:center;gap:4px;flex:1;min-width:0;height:44px;background:var(--_gengage-surface-secondary);border:1px solid var(--_gengage-border-color);border-radius:30px;padding:2px 8px;overflow:hidden;transition:border-color .2s ease,box-shadow .2s ease}.gengage-chat-input-pill:focus-within{border-color:var(--gengage-primary-color, #b7102a);box-shadow:0 0 0 2px #b7102a26}.gengage-chat-input{flex:1;min-width:0;min-height:40px;max-height:120px;padding:0 6px 0 14px;border:none;border-radius:0;font-size:14px;font-family:inherit;line-height:1.4;align-content:center;outline:none;background:transparent;color:var(--_gengage-text-primary);resize:none;overflow-y:hidden}.gengage-chat-root--mobile .gengage-chat-input-pill{height:52px;padding:3px 8px}.gengage-chat-root--mobile .gengage-chat-input{min-height:44px;max-height:44px;font-size:16px;white-space:nowrap;overflow:hidden}.gengage-chat-root--mobile .gengage-chat-input::placeholder{font-size:15px}.gengage-chat-input::placeholder{font-size:14px;color:#6b7280;line-height:normal}.gengage-chat-send{width:36px;height:36px;min-width:36px;padding:0;border:none;border-radius:50%;background:var(--gengage-primary-color, #b7102a);color:var(--gengage-primary-foreground, #ffffff);font-weight:700;font-size:0;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:background-color .2s cubic-bezier(.4,0,.2,1),box-shadow .2s ease,transform .15s ease;box-shadow:0 2px 6px #00000026}.gengage-chat-send:hover{filter:brightness(.92);transform:translateY(-1px);box-shadow:0 4px 8px #0000002e}.gengage-chat-send:active{transform:translateY(0);box-shadow:0 1px 2px #0000001f}.gengage-chat-send svg{width:18px;height:18px}.gengage-chat-send:disabled{background:#e5e7eb;opacity:.5;box-shadow:none;cursor:not-allowed}.gengage-chat-footer{padding:4px 10px;text-align:center;font-size:10px;color:#6b7280;border-top:1px solid var(--_gengage-surface-muted);background:var(--gengage-background-color, #ffffff)}.gengage-chat-uispec{width:100%}.gengage-chat-uispec:empty{display:none}.gengage-chat-uispec>*{animation:gengage-chat-widget-enter .16s cubic-bezier(.2,.7,.2,1) both}@keyframes gengage-chat-widget-enter{0%{opacity:0;transform:translateY(5px) scale(.99)}to{opacity:1;transform:translateY(0) scale(1)}}.gengage-chat-action-buttons{display:flex;flex-wrap:wrap;gap:8px;padding:6px 0 4px}.gengage-chat-action-btn{flex:0 0 auto;padding:8px 16px;border:none;border-radius:999px;background:var(--gengage-primary-color, #b7102a);color:var(--gengage-primary-foreground, #ffffff);font-size:13px;font-weight:600;line-height:1.25;font-family:inherit;cursor:pointer;white-space:nowrap;transition:filter .15s ease,transform .1s ease}.gengage-chat-action-btn:hover{filter:brightness(.92)}.gengage-chat-action-btn:active{transform:scale(.97)}.gengage-chat-product-card{position:relative;display:flex;flex-direction:column;border:1px solid #eee;border-radius:16px;overflow:hidden;background:#fff;width:160px;min-width:160px;max-width:160px;box-shadow:0 2px 8px #0000000f;transition:transform .1s ease,box-shadow .2s ease}.gengage-chat-product-card:hover{transform:translateY(-2px);box-shadow:0 4px 12px #0000001a}.gengage-chat-product-card-img{width:100%;height:120px;object-fit:contain;display:block;background:#fff;padding:8px;box-sizing:border-box}.gengage-chat-product-card-body{display:flex;flex-direction:column;flex:1;gap:4px;padding:8px 10px 10px;text-align:center}.gengage-chat-product-card-name{font-size:13px;font-weight:600;color:var(--_gengage-text-primary);line-height:1.35;margin-bottom:0;min-height:2.7em;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis}.gengage-chat-product-card-brand{font-size:10px;color:#666}.gengage-chat-product-card-rating{font-size:11px;color:var(--_gengage-rating-color);line-height:1}.gengage-star-half{display:inline-block;position:relative}.gengage-star-half>span{position:absolute;left:0;top:0;overflow:hidden;width:.5em}.gengage-chat-product-card-review-count{color:#475569;font-size:10px}.gengage-chat-product-card-price{display:flex;flex-wrap:wrap;align-items:baseline;justify-content:center;gap:2px 4px;font-size:16px;font-weight:800;color:#0f172a}.gengage-chat-product-card-original-price{text-decoration:line-through;color:var(--_gengage-text-secondary);font-weight:400;font-size:inherit;margin-right:6px}.gengage-chat-price-skeleton{display:inline-block;width:80px;height:16px;background:linear-gradient(90deg,#e2e8f0 25%,#f1f5f9,#e2e8f0 75%);background-size:200% 100%;animation:gengage-skeleton-price-pulse 1.5s ease-in-out infinite;border-radius:4px;vertical-align:middle}@keyframes gengage-skeleton-price-pulse{0%{background-position:200% 0}to{background-position:-200% 0}}.gengage-chat-product-card-cta{display:block;margin-top:auto;padding:8px 10px;text-align:center;background:transparent;color:var(--gengage-primary-color, #b7102a);text-decoration:none;font-size:12px;font-weight:700;letter-spacing:.01em;border-top:1px solid var(--_gengage-surface-muted);cursor:pointer;transition:color .15s ease,background .15s ease}.gengage-chat-product-card-cta:hover{color:var(--gengage-primary-color, #9a0d23);background:var(--_gengage-surface-muted)}.gengage-chat-product-card-cta:active{background:var(--_gengage-surface-muted)}.gengage-chat-product-summary{display:flex;align-items:center;gap:12px;padding:10px 12px;border:1px solid var(--_gengage-border-color);border-radius:12px;background:#fff;cursor:pointer;transition:background .15s,box-shadow .15s;margin:4px 0}.gengage-chat-product-summary:hover{background:#f9fafb;box-shadow:0 1px 4px #0000000f}.gengage-chat-product-summary__image{flex-shrink:0;width:64px;height:64px;border-radius:8px;overflow:hidden;border:1px solid var(--_gengage-surface-secondary);background:#f9fafb}.gengage-chat-product-summary__image img{width:100%;height:100%;object-fit:cover;display:block}.gengage-chat-product-summary__content{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.gengage-chat-product-summary__name{font-size:13px;font-weight:500;line-height:1.3;color:#111827;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis}.gengage-chat-product-summary__rating{font-size:11px;color:var(--_gengage-rating-color);line-height:1}.gengage-chat-product-summary__review-count{color:#475569;font-size:11px}.gengage-chat-product-summary__price{font-size:13px;font-weight:600;color:#111827;line-height:1;margin-top:2px}.gengage-chat-product-summary__price-original{text-decoration:line-through;color:var(--_gengage-text-secondary);font-weight:400;font-size:11px}.gengage-chat-product-summary__price-current{color:var(--gengage-primary-color, #111827)}.gengage-chat-product-summary__cta{flex-shrink:0;font-size:12px;font-weight:500;color:var(--gengage-primary-color, #b7102a);text-decoration:none;padding:4px 10px;border-radius:8px;transition:background .15s;white-space:nowrap}.gengage-chat-product-summary__cta:hover{background:#0000000a}.gengage-chat-product-summary__cta:focus-visible{outline:2px solid var(--gengage-primary-color, #b7102a);outline-offset:2px}.gengage-chat-product-grid{display:flex;gap:12px;overflow-x:auto;padding:8px 0;-webkit-overflow-scrolling:touch;scrollbar-width:none;scroll-snap-type:x proximity;min-height:180px}.gengage-chat-product-grid>*{scroll-snap-align:start;flex:0 0 auto}.gengage-chat-product-grid::-webkit-scrollbar{display:none}.gengage-chat-review-highlights{padding:2px 0 6px}.gengage-chat-review-item{border:1px solid var(--_gengage-border-color);border-radius:12px;padding:10px 12px;background:#fff}.gengage-chat-review-item[data-tone=positive]{border-color:#bbf7d0;background:#f0fdf4}.gengage-chat-review-item[data-tone=negative]{border-color:#fecaca;background:#fef2f2}.gengage-chat-review-tag{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.03em;color:var(--_gengage-text-secondary);margin-bottom:4px}.gengage-chat-review-text{font-size:13px;line-height:1.45;color:var(--_gengage-text-primary);display:-webkit-box;-webkit-line-clamp:4;line-clamp:4;-webkit-box-orient:vertical;overflow:hidden}.gengage-chat-review-rating{margin-top:6px;font-size:12px;font-weight:700;color:#0f172a}.gengage-chat-review-empty{font-size:12px;color:var(--_gengage-text-secondary)}.gengage-chat-review-tabs{display:flex;gap:6px;margin-bottom:10px}.gengage-chat-review-tab{padding:6px 14px;border:1px solid var(--_gengage-border-color);border-radius:999px;background:#fff;color:var(--_gengage-text-secondary);font-size:12px;font-weight:600;font-family:inherit;cursor:pointer;transition:background .15s,border-color .15s}.gengage-chat-review-tab:hover{background:var(--_gengage-surface-muted)}.gengage-chat-review-tab--active{background:var(--_gengage-surface-muted);border-color:#94a3b8;color:#0f172a}.gengage-chat-review-pills{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:10px}.gengage-chat-review-pill{display:flex;align-items:center;gap:6px;padding:6px 10px;border:1px solid var(--_gengage-border-color);border-radius:8px;background:#fff;font-size:12px;font-family:inherit;color:#334155;box-shadow:0 1px 2px #0000000a;cursor:pointer;transition:background .15s,border-color .15s}.gengage-chat-review-pill:hover{background:var(--_gengage-surface-muted)}.gengage-chat-review-pill--active{background:var(--_gengage-surface-muted);border-color:var(--_gengage-text-secondary, #64748b);color:var(--_gengage-text-primary, #0f172a);font-weight:600}.gengage-chat-review-pill--active .gengage-chat-review-pill-count{background:var(--_gengage-border-color, #e2e8f0);color:var(--_gengage-text-primary, #0f172a)}.gengage-chat-review-pill[data-tone=positive]{border-color:#bbf7d0}.gengage-chat-review-pill[data-tone=negative]{border-color:#fecaca}.gengage-chat-review-pill-icon{font-size:11px;font-weight:700}.gengage-chat-review-pill[data-tone=positive] .gengage-chat-review-pill-icon{color:var(--_gengage-success-color)}.gengage-chat-review-pill[data-tone=negative] .gengage-chat-review-pill-icon{color:#dc2626}.gengage-chat-review-pill-count{font-size:10px;font-weight:700;background:var(--_gengage-surface-muted);color:var(--_gengage-text-secondary);border-radius:4px;padding:1px 5px}.gengage-chat-review-items{display:grid;gap:10px}.gengage-chat-favorites-page{padding:12px}.gengage-chat-favorites-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:48px 24px;text-align:center;color:var(--_gengage-text-secondary)}.gengage-chat-favorites-empty-icon{opacity:.25;color:var(--_gengage-danger-color, #ef4444)}.gengage-chat-favorites-empty p{font-size:13px;margin:0;line-height:1.5}.gengage-chat-favorites-list{display:flex;flex-direction:column;gap:10px}.gengage-chat-favorites-card{display:flex;align-items:center;gap:12px;padding:10px 12px;border:1px solid var(--_gengage-border-color);border-radius:12px;background:var(--_gengage-surface-color, #fff);position:relative;transition:opacity .2s,transform .2s}.gengage-chat-favorites-card--removing{opacity:0;transform:translate(8px)}.gengage-chat-favorites-card__image{width:56px;height:56px;flex-shrink:0;border-radius:8px;overflow:hidden;background:var(--_gengage-surface-muted)}.gengage-chat-favorites-card__image img{width:100%;height:100%;object-fit:contain}.gengage-chat-favorites-card__info{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px}.gengage-chat-favorites-card__name{font-size:13px;font-weight:500;color:var(--_gengage-text-primary, #0f172a);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gengage-chat-favorites-card__price{font-size:13px;font-weight:700;color:var(--_gengage-primary-color, #1d4ed8)}.gengage-chat-favorites-remove{flex-shrink:0;width:28px;height:28px;border-radius:50%;background:transparent;border:none;color:var(--_gengage-danger-color, #ef4444);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;opacity:.7;transition:opacity .15s,background .15s}.gengage-chat-favorites-remove:hover{opacity:1;background:var(--_gengage-danger-light, #fee2e2)}.gengage-chat-divider{border:none;border-top:1px solid var(--_gengage-border-color);margin:8px 0}.gengage-chat-divider-wrapper{display:flex;align-items:center;gap:8px;margin:8px 0}.gengage-chat-divider-wrapper hr{flex:1;border:none;border-top:1px solid var(--_gengage-border-color);margin:0}.gengage-chat-divider-label{font-size:11px;color:#6b7280;white-space:nowrap}.gengage-chat--overlay .gengage-chat-drawer{position:fixed;inset:0;width:100%;max-width:480px;max-height:100%;margin:0 auto;border-radius:0;animation:gengage-chat-overlay-in .24s cubic-bezier(.2,.72,.2,1)}.gengage-chat--overlay:before{content:"";position:fixed;inset:0;background:var(--gengage-chat-overlay-backdrop, rgba(0, 0, 0, .45));z-index:-1}@keyframes gengage-chat-overlay-in{0%{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-panel-skeleton{display:flex;flex-direction:column;gap:14px;padding:6px 0}.gengage-chat-panel-skeleton-block{height:110px;border-radius:10px;background:linear-gradient(90deg,#e5e7eb 25%,#f3f4f6,#e5e7eb 75%);background-size:200% 100%;animation:gengage-panel-shimmer 1.4s infinite}@keyframes gengage-panel-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}.gengage-chat-panel-skeleton-block--image{height:200px;border-radius:8px;margin-bottom:12px}.gengage-chat-panel-skeleton-block--text{height:16px;border-radius:4px;margin-bottom:8px}.gengage-chat-panel-skeleton-block--text:nth-child(3){width:80%}.gengage-chat-panel-skeleton-block--text:nth-child(4){width:60%}.gengage-chat-panel-skeleton-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.gengage-chat-panel-skeleton-block--card{height:120px;border-radius:8px}.gengage-chat-panel-skeleton-block--row{height:32px;border-radius:4px;margin-bottom:4px}.gengage-chat-panel .gengage-chat-product-card{width:100%;max-width:100%;min-width:0;display:flex;flex-direction:column;border-radius:12px;border:1px solid var(--_gengage-border-color);box-shadow:0 1px 4px #0000000f;overflow:hidden;padding:0}.gengage-chat-panel .gengage-chat-product-card:hover{transform:translateY(-2px);box-shadow:0 4px 12px #0000001a;border-color:#d1d5db}.gengage-chat-panel .gengage-chat-product-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));overflow-x:visible;gap:12px;min-height:auto;padding:4px 0}.gengage-chat-panel:has(.gengage-chat-choice-prompter) .gengage-chat-product-grid{padding-bottom:120px}.gengage-chat-panel .gengage-chat-product-card-img{width:100%;height:160px;border-radius:0;object-fit:contain;background:#fafafa;padding:12px;box-sizing:border-box}.gengage-chat-panel .gengage-chat-product-card-body{padding:10px 12px 12px;text-align:left;gap:4px}.gengage-chat-panel .gengage-chat-product-card-name{min-height:0;margin-bottom:2px;font-size:13px;-webkit-line-clamp:2;line-clamp:2}.gengage-chat-panel .gengage-chat-product-card-price{justify-content:flex-start;font-size:15px}.gengage-chat-panel .gengage-chat-product-card-cta{display:block;padding:10px 12px;text-align:center;border-top:1px solid var(--_gengage-surface-muted);border-radius:0;background:transparent;color:var(--gengage-primary-color, #b7102a);font-weight:700;font-size:13px}.gengage-chat-product-card--selected{border-color:var(--gengage-primary-color, #b7102a);background:color-mix(in srgb,var(--gengage-primary-color, #b7102a) 8%,transparent);box-shadow:0 0 0 1px var(--gengage-primary-color, #b7102a)}.gengage-chat-panel--visible{min-height:0}.gengage-chat-panel--visible>*{flex-shrink:0}.gengage-chat-load-more-btn{display:block;margin:12px auto;padding:8px 24px;border:1px solid var(--_gengage-border-color);border-radius:8px;background:transparent;color:var(--gengage-primary-color, #b7102a);cursor:pointer;font-size:14px}.gengage-chat-load-more-btn:hover{background:var(--_gengage-surface-muted, #f8fafc)}.gengage-chat-product-details-panel{display:flex;flex-direction:column;gap:12px;width:100%;background:#fff;border:1px solid var(--_gengage-border-color);border-radius:16px;padding:14px;box-sizing:border-box}.gengage-chat-product-details-media{border:1px solid var(--_gengage-surface-muted);border-radius:12px;background:#fafafa;padding:12px;display:flex;flex-direction:column;align-items:center}.gengage-chat-product-details-img{width:100%;height:auto;max-height:300px;object-fit:contain;border-radius:8px}.gengage-chat-product-details-content{display:flex;flex-direction:column;gap:8px;min-width:0}.gengage-chat-product-details-title{margin:0;font-size:17px;font-weight:700;line-height:1.3;color:#0f172a}.gengage-chat-product-details-rating{display:inline-flex;align-items:center;gap:4px;width:fit-content;padding:3px 8px;border-radius:999px;background:#fff7ed;color:#9a3412;font-size:13px;font-weight:700}.gengage-chat-product-details-review-count{color:#7c2d12;font-weight:600}.gengage-chat-product-details-price{display:flex;align-items:baseline;gap:6px}.gengage-chat-product-details-original-price{font-size:14px;color:#64748b;text-decoration:line-through}.gengage-chat-product-details-current-price{font-size:22px;font-weight:800;line-height:1.1;color:#0f172a}.gengage-chat-product-details-stock{width:fit-content;padding:4px 10px;border-radius:999px;font-size:12px;font-weight:700}.gengage-chat-product-details-stock.is-in-stock{background:#dcfce7;color:#166534}.gengage-chat-product-details-stock.is-out-of-stock{background:#fee2e2;color:#991b1b}.gengage-chat-product-details-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:4px}.gengage-chat-product-details-cta{display:inline-flex;align-items:center;justify-content:center;min-height:40px;padding:0 20px;border-radius:999px;border:none;text-decoration:none;background:var(--gengage-primary-color, #b7102a);color:var(--gengage-primary-foreground, #ffffff);font-size:14px;font-weight:700;cursor:pointer;transition:filter .14s ease,transform .12s ease}.gengage-chat-product-details-cta:hover{filter:brightness(1.05);transform:translateY(-1px)}.gengage-chat-product-details-cta:active{transform:translateY(1px)}.gengage-chat-product-details-atc{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:10px 20px;border:none;border-radius:10px;background:var(--_gengage-success-color);color:#fff;font-size:14px;font-weight:700;font-family:inherit;cursor:pointer;transition:filter .12s ease,transform .12s ease}.gengage-chat-product-details-atc:hover{filter:brightness(1.08);transform:translateY(-1px)}.gengage-chat-product-details-atc:active{transform:translateY(1px)}.gengage-chat-product-detail-tabs{margin-top:4px;border-top:1px solid var(--_gengage-border-color);padding-top:12px}.gengage-chat-product-detail-tab-bar{display:flex;gap:0;border-bottom:2px solid var(--_gengage-border-color);margin-bottom:12px}.gengage-chat-product-detail-tab{flex:1;padding:8px 12px;border:none;background:transparent;color:var(--_gengage-text-secondary);font-size:13px;font-weight:600;font-family:inherit;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-2px;transition:color .15s,border-color .15s}.gengage-chat-product-detail-tab:hover{color:#334155}.gengage-chat-product-detail-tab--active{color:var(--gengage-primary-color, #b7102a);border-bottom-color:var(--gengage-primary-color, #b7102a)}.gengage-chat-product-detail-tab-panel{font-size:13px;line-height:1.6;color:#374151}.gengage-chat-product-specs-table{width:100%;border-collapse:collapse;font-size:13px}.gengage-chat-product-specs-table tr:nth-child(2n){background:var(--_gengage-surface-muted)}.gengage-chat-product-specs-key{padding:6px 10px;font-weight:600;color:#475569;white-space:nowrap;border-bottom:1px solid var(--_gengage-surface-muted);width:40%}.gengage-chat-product-specs-value{padding:6px 10px;color:var(--_gengage-text-primary);border-bottom:1px solid var(--_gengage-surface-muted)}.gengage-chat-product-card-atc{position:absolute;bottom:42px;right:6px;opacity:0;transition:opacity .15s ease;z-index:1}.gengage-chat-product-card:hover .gengage-chat-product-card-atc{opacity:1}@media(hover:none),(pointer:coarse){.gengage-chat-product-card-atc{opacity:1;position:relative;bottom:auto;right:auto;margin-top:4px}}.gengage-chat-drawer.gengage-chat-drawer--hidden{transform:translate(100%);opacity:0;pointer-events:none;box-shadow:none;visibility:hidden}.gengage-chat-root--mobile .gengage-chat-drawer.gengage-chat-drawer--hidden{transform:translateY(100%);opacity:0;pointer-events:none;box-shadow:none;visibility:hidden}@media(max-width:900px){.gengage-chat-drawer--with-panel .gengage-chat-panel--visible{width:clamp(280px,calc(100vw - var(--_gengage-chat-conversation-width)),560px);max-width:560px}}.gengage-chat-attachment-preview{display:flex;align-items:center;gap:8px;padding:6px 10px;background:var(--_gengage-surface-secondary);border:1px solid var(--_gengage-border-color);border-radius:8px;width:100%;box-sizing:border-box}.gengage-chat-attachment-preview--hidden{display:none}.gengage-chat-attachment-preview-thumb{width:40px;height:40px;border-radius:4px;object-fit:cover;flex-shrink:0}.gengage-chat-attachment-name{flex:1;font-size:12px;color:#4b5563;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.gengage-chat-attachment-remove{background:none;border:none;cursor:pointer;font-size:18px;color:#6b7280;padding:0 4px;line-height:1;flex-shrink:0}.gengage-chat-attachment-remove:hover{color:#ef4444}.gengage-chat-attach-btn{background:none;border:none;cursor:pointer;width:32px;height:32px;padding:0;line-height:1;flex-shrink:0;display:flex;align-items:center;justify-content:center;border-radius:50%;color:#6b7280;transition:color .15s,background .15s}.gengage-chat-attach-btn:hover{color:#4b5563;background:#0000000d}.gengage-chat-attach-btn svg{width:20px;height:20px}.gengage-chat-mic-btn{background:none;border:none;cursor:pointer;width:32px;height:32px;padding:0;line-height:1;flex-shrink:0;display:flex;align-items:center;justify-content:center;border-radius:50%;color:#6b7280;transition:color .15s,background .15s}.gengage-chat-mic-btn:hover{color:#4b5563;background:#0000000d}.gengage-chat-mic-btn svg{width:20px;height:20px}.gengage-chat-mic-btn--active{color:#ef4444;animation:gengage-mic-pulse 1.2s ease-in-out infinite}.gengage-chat-mic-btn--active:hover{color:#dc2626}@keyframes gengage-mic-pulse{0%,to{transform:scale(1);opacity:1}50%{transform:scale(1.15);opacity:.8}}.gengage-chat-input-area--dragover{outline:2px dashed var(--gengage-primary-color, #b7102a);outline-offset:-2px;background:#eff6ff}.gengage-chat-attachment-thumb{width:120px;max-width:100%;height:auto;border-radius:8px;margin-bottom:6px;display:block}.gengage-chat-root--mobile{--_gengage-qty-btn-size: 44px;--_gengage-qty-btn-size-compact: 44px}.gengage-chat-root--mobile .gengage-chat-header-btn,.gengage-chat-root--mobile .gengage-chat-close{width:44px;height:44px;border-radius:12px}.gengage-chat-root--mobile .gengage-chat-attach-btn,.gengage-chat-root--mobile .gengage-chat-mic-btn,.gengage-chat-root--mobile .gengage-chat-send{width:44px;height:44px;min-width:44px}.gengage-chat-root--mobile .gengage-chat-attach-btn svg,.gengage-chat-root--mobile .gengage-chat-mic-btn svg{width:22px;height:22px}.gengage-chat-root--mobile .gengage-chat-panel-divider{display:flex;width:100%;height:20px;align-items:center;justify-content:center;cursor:ns-resize;background:transparent;touch-action:pan-y;position:relative;overflow:visible}.gengage-chat-root--mobile .gengage-chat-panel-divider--hidden{display:none}.gengage-chat-root--mobile .gengage-chat-drawer--with-panel{left:0;right:0;width:100%;border-radius:0}.gengage-chat-root--mobile .gengage-chat-panel{display:flex;flex-direction:column;position:absolute;inset:0;z-index:10;width:100%;min-width:0;max-width:none;max-height:none;border:none;box-shadow:none;border-radius:0;background:var(--gengage-chat-panel-bg, #fff);overflow-y:auto;overflow-x:hidden;transform:translate(100%);transition:transform .32s cubic-bezier(.4,0,.2,1);pointer-events:none;padding:0 12px 16px}.gengage-chat-root--mobile .gengage-chat-panel--visible{transform:translate(0);pointer-events:auto}.gengage-chat-root--mobile .gengage-chat-panel-divider,.gengage-chat-root--mobile .gengage-chat-drawer--with-panel .gengage-chat-panel-divider{display:none}.gengage-chat-root--mobile .gengage-chat-drawer--with-panel .gengage-chat-body{flex-direction:row}.gengage-chat-root--mobile .gengage-chat-drawer--with-panel .gengage-chat-conversation{width:100%;flex:1;border-left:none}.gengage-chat-root--mobile .gengage-qty-stepper--compact .gengage-qty-submit{min-height:44px;padding:0 12px;font-size:13px}.gengage-chat-root--mobile .gengage-chat-product-details-atc-stepper .gengage-qty-submit{min-height:44px;padding:0 16px}.gengage-chat-root--mobile .gengage-chat-product-details-share{width:44px;height:44px}.gengage-chat-root--mobile .gengage-chat-panel .gengage-chat-product-card{grid-template-columns:84px 1fr}.gengage-chat-root--mobile .gengage-chat-panel .gengage-chat-product-card-cta{grid-column:1 / -1;width:100%}.gengage-chat-root--mobile .gengage-chat-product-details-panel{padding:12px;gap:12px}.gengage-chat-root--mobile .gengage-chat-product-details-media{min-height:140px}.gengage-chat-root--mobile .gengage-chat-product-details-title{font-size:15px}.gengage-chat-root--mobile .gengage-chat-product-details-current-price{font-size:20px}.gengage-chat-root--mobile .gengage-chat-product-grid{scroll-snap-type:x mandatory}.gengage-chat-root--mobile .gengage-chat-product-card{width:280px;min-width:280px;scroll-snap-align:center}.gengage-chat-root--mobile .gengage-chat-product-card-img{height:180px}.gengage-chat-root--mobile .gengage-chat-drawer{position:fixed;inset:0;width:100%;max-height:100%;border-radius:0}.gengage-chat-root--mobile .gengage-chat-bubble{max-width:100%}.gengage-chat-root--mobile .gengage-chat-panel .gengage-chat-product-card-img{max-height:120px;object-fit:contain}.gengage-chat-root--mobile .gengage-chat-messages{scrollbar-width:none;padding:12px 16px}.gengage-chat-root--mobile .gengage-chat-messages::-webkit-scrollbar{display:none}.gengage-chat-root--mobile .gengage-chat-drawer{border-top:none}.gengage-chat-root--mobile .gengage-chat-header{border-radius:16px 16px 0 0}.gengage-chat-root--mobile .gengage-chat-conversation{overflow-y:auto;-webkit-overflow-scrolling:touch;min-height:0}.gengage-chat-root--mobile .gengage-chat-product-details-img{min-height:120px;object-fit:contain}.gengage-chat-root--mobile .gengage-chat-product-details-actions{flex-wrap:wrap;gap:8px}.gengage-chat-root--mobile .gengage-chat-product-card-promos,.gengage-chat-root--mobile .gengage-chat-product-details-promos{flex-wrap:wrap;gap:4px}.gengage-chat-root--mobile .gengage-chat-input::placeholder{font-size:13px}.gengage-chat-kvkk-banner{display:flex;align-items:flex-start;gap:8px;padding:10px 14px;background:#fffbeb;border-bottom:1px solid #fde68a;font-size:12px;line-height:1.5;color:#92400e}.gengage-chat-kvkk-content{flex:1;min-width:0}.gengage-chat-kvkk-content a{color:#b45309;text-decoration:underline}.gengage-chat-kvkk-dismiss{flex-shrink:0;width:20px;height:20px;border:none;background:transparent;color:#78350f;font-size:18px;cursor:pointer;padding:0;line-height:1}.gengage-chat-comparison{padding:16px}.gengage-chat-comparison-heading{font-size:14px;font-weight:700;letter-spacing:.05em;color:#0f172a;margin:0 0 16px}.gengage-chat-comparison-recommended{border:1px solid var(--_gengage-border-color);border-radius:12px;padding:16px;background:#fff;box-shadow:0 1px 3px #0000000f;margin-bottom:12px}.gengage-chat-comparison-recommended-label{font-size:12px;font-weight:700;color:var(--_gengage-success-color);text-transform:uppercase;letter-spacing:.04em;margin-bottom:12px}.gengage-chat-comparison-recommended-body{display:flex;gap:12px;align-items:flex-start}.gengage-chat-comparison-recommended-body img{width:80px;height:80px;object-fit:contain;border-radius:8px;background:var(--_gengage-surface-muted)}.gengage-chat-comparison-recommended-info{flex:1;min-width:0}.gengage-chat-comparison-recommended-title{font-size:14px;font-weight:600;color:#0f172a;margin-bottom:4px}.gengage-chat-comparison-recommended-price{font-size:16px;font-weight:700;color:#0f172a}.gengage-chat-comparison-highlights{margin-top:12px;padding-top:12px;border-top:1px solid var(--_gengage-surface-muted)}.gengage-chat-comparison-highlights-label{font-size:12px;font-weight:600;color:var(--_gengage-text-secondary);margin-bottom:6px}.gengage-chat-comparison-highlights ul{margin:0;padding-left:18px;font-size:13px;color:#334155;line-height:1.6}.gengage-chat-comparison-special{background:#fffbeb;border:1px solid #fde68a;border-radius:12px;padding:12px 16px;margin-bottom:12px;font-size:13px;color:#92400e}.gengage-chat-comparison-special summary{cursor:pointer;font-weight:600}.gengage-chat-comparison-special ul{margin:8px 0 0;padding-left:18px;line-height:1.6}.gengage-chat-comparison-table{width:100%;border-collapse:collapse;font-size:13px;margin-top:12px}.gengage-chat-comparison-table th,.gengage-chat-comparison-table td{padding:10px 12px;text-align:center;border-bottom:1px solid var(--_gengage-surface-muted);vertical-align:top}.gengage-chat-comparison-table th{font-weight:600;font-size:12px;color:#334155}.gengage-chat-comparison-table th img{width:60px;height:60px;object-fit:contain;border-radius:6px;background:var(--_gengage-surface-muted);margin-bottom:6px}.gengage-chat-comparison-table-price{font-weight:700;color:#0f172a}.gengage-chat-comparison-label{text-align:left;font-weight:600;color:var(--_gengage-text-secondary);white-space:nowrap}.gengage-chat-comparison-selected{background:#f0fdf4}.gengage-chat-comparison-recommended-text{padding:8px 12px;font-size:12px;color:var(--gengage-text-secondary, #475569);font-style:italic;border-top:1px solid var(--gengage-border-color, #e2e8f0);margin-top:8px}.gengage-chat-comparison-product-actions{display:flex;gap:8px;margin-top:12px;flex-wrap:wrap}.gengage-chat-comparison-view-btn{flex:1;min-width:0;padding:8px 12px;border:1px solid var(--gengage-primary-color, #b7102a);border-radius:6px;background:transparent;color:var(--gengage-primary-color, #b7102a);font-size:12px;font-weight:500;font-family:inherit;cursor:pointer;transition:background .15s ease,color .15s ease;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.gengage-chat-comparison-view-btn:hover{background:var(--gengage-primary-color, #b7102a);color:#fff}.gengage-chat-pills{position:relative;padding:8px 12px;border-top:1px solid var(--_gengage-surface-muted);background:var(--gengage-background-color, #ffffff)}.gengage-chat-pills-scroll{display:flex;gap:8px;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch;padding-right:28px}.gengage-chat-pills-scroll::-webkit-scrollbar{display:none}.gengage-chat-root--mobile .gengage-chat-pills-scroll{flex-wrap:wrap;gap:6px}.gengage-chat-root--mobile .gengage-chat-pill{white-space:normal;max-width:100%}.gengage-chat-pill{flex:0 0 auto;padding:8px 16px;border:none;border-radius:999px;background:var(--gengage-primary-color, #b7102a);color:var(--gengage-primary-foreground, #ffffff);font-size:13px;font-weight:600;font-family:inherit;white-space:nowrap;cursor:pointer;transition:filter .15s,transform .1s}.gengage-chat-pill:hover{filter:brightness(.92)}.gengage-chat-pill:active{transform:scale(.97)}.gengage-chat-pill--rich{display:flex;align-items:center;gap:8px;padding:6px 14px 6px 6px;border-radius:20px}.gengage-chat-pill-img{width:32px;height:32px;border-radius:50%;object-fit:cover;flex-shrink:0;background:#ffffff26}.gengage-chat-pill-text{font-size:13px;font-weight:600;line-height:1.2}.gengage-chat-pill-desc{display:none}.gengage-chat-pill--rich .gengage-chat-pill-desc{display:block;font-size:10px;font-weight:400;opacity:.8;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:160px}.gengage-chat-pills-arrow{position:absolute;right:8px;top:50%;transform:translateY(-50%);width:28px;height:28px;border-radius:50%;border:1px solid var(--_gengage-border-color);background:#fff;color:var(--_gengage-text-secondary);font-size:16px;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:-4px 0 8px #ffffffe6;z-index:1}.gengage-chat-pills-arrow:hover{background:var(--_gengage-surface-muted);color:#334155}@media(prefers-reduced-motion:reduce){.gengage-chat-uispec>*,.gengage-chat-action-btn,.gengage-chat-product-card,.gengage-chat-product-card-cta,.gengage-chat-send,.gengage-chat-launcher,.gengage-chat-pill,.gengage-chat-drawer,.gengage-chat-typing-dots span,.gengage-chat-typing-sparkle,.gengage-chat-thinking-step-marker--active,.gengage-chat-bubble,.gengage-chat-panel-skeleton-block,.gengage-chat-ai-toppick-card,.gengage-chat-mic-btn--active,.gengage-chat-ai-toppick-spinner:after,.gengage-chat-panel-shimmer,.gengage-chat-overlay,.gengage-chat-product-details-skeleton-price,.gengage-chat-still-working,.gengage-skeleton-card,.gengage-skeleton-line,.gengage-skeleton-img,.gengage-skeleton-text,.gengage-skeleton-price{animation:none!important;transition:none!important;transform:none!important}}.gengage-chat-bubble--user{position:relative}.gengage-chat-rollback-btn{position:absolute;left:-28px;top:50%;transform:translateY(-50%);width:24px;height:24px;border:none;border-radius:50%;background:var(--gengage-surface-color, #f1f5f9);color:var(--gengage-text-secondary, #64748b);cursor:pointer;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .15s ease;padding:0}.gengage-chat-bubble--user:hover .gengage-chat-rollback-btn{opacity:1}.gengage-chat-rollback-btn:hover{background:var(--gengage-primary-color, #b7102a);color:#fff}.gengage-chat-bubble--hidden{display:none}.gengage-chat-ai-top-picks{display:flex;flex-direction:column;gap:12px;padding:8px 0;scroll-margin-top:60px}.gengage-chat-ai-top-picks-title{font-size:15px;font-weight:600;color:var(--gengage-text-primary, #1e293b);margin:0 0 4px}.gengage-chat-ai-top-picks-scroll{display:flex;flex-direction:column;gap:10px;min-width:0}.gengage-chat-panel-ai-zone .gengage-chat-ai-top-picks{gap:0;padding-top:4px}.gengage-chat-panel-ai-zone .gengage-chat-ai-top-picks-title{flex-shrink:0;width:100%;margin:0 0 10px;font-weight:700}.gengage-chat-panel-ai-zone .gengage-chat-ai-top-picks-scroll{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));align-items:stretch;gap:12px;overflow:visible;padding:12px 0;margin:0;scrollbar-width:none}.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--winner,.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--compact{width:100%;min-width:0;max-width:none;flex:initial;scroll-snap-align:none}.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--compact{flex-direction:column;align-items:stretch}.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-media,.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-media{max-height:140px}.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-img,.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-img{width:100%;height:100%;max-height:140px;object-fit:contain;flex-shrink:0}.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-body,.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-body{padding:0;flex:1;min-height:0}.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-cta{width:calc(100% - 24px);margin:14px 12px 12px;align-self:stretch;border:1px solid var(--gengage-primary-color, #ea580c);background:transparent;color:var(--gengage-primary-color, #ea580c)}.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-cta{width:calc(100% - 24px);margin:14px 12px 12px;border:1px solid var(--gengage-primary-color, #ea580c);background:transparent;color:var(--gengage-primary-color, #ea580c)}.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-cta:hover,.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-cta:hover{background:#ea580c0f;filter:none}.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--winner{border-color:var(--gengage-primary-color, #ea580c)}.gengage-chat-ai-toppick-rating{font-size:12px;font-weight:600;color:#ca8a04;margin-top:4px}.gengage-chat-ai-toppick-media .gengage-chat-ai-toppick-discount-badge{position:absolute;top:4px;left:4px;right:auto;background:var(--gengage-primary-color, #ea580c);color:#fff;font-size:9px;font-weight:800;padding:2px 6px;border-radius:999px;z-index:1;line-height:1.2}.gengage-chat-ai-toppick-card--winner,.gengage-chat-ai-toppick-card--compact{position:relative;display:flex;flex-direction:column;align-items:stretch;box-sizing:border-box;padding:12px;border-radius:12px;background:#fff;overflow:visible;transition:box-shadow .2s ease,background .15s ease,transform .15s ease}.gengage-chat-ai-toppick-card--winner{border:1.5px solid var(--gengage-primary-color, #ea580c)}.gengage-chat-ai-toppick-card--winner:hover{background:#fafafa;box-shadow:0 4px 16px #ea580c1f}.gengage-chat-ai-toppick-card--compact{border:1px solid #e5e7eb}.gengage-chat-ai-toppick-card--compact:hover{background:#fafafa;box-shadow:0 2px 8px #00000014;transform:translateY(-1px)}.gengage-chat-ai-toppick-badge{position:absolute;top:-10px;left:12px;z-index:2;max-width:calc(100% - 24px);box-sizing:border-box;font-size:10px;font-weight:700;line-height:1.25;padding:2px 10px;border-radius:999px;text-transform:uppercase;letter-spacing:.05em;pointer-events:none;white-space:normal}.gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-badge{background:var(--gengage-primary-color, #ea580c);color:#fff}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-badge{background:#f3f4f6;color:#4b5563}.gengage-chat-ai-toppick-media{position:relative;width:100%;flex-shrink:0;display:flex;align-items:center;justify-content:center;margin-top:4px;margin-bottom:8px;aspect-ratio:1 / 1;border-radius:8px;border:1px solid #f3f4f6;overflow:hidden;background:#fff}.gengage-chat-ai-toppick-img{max-width:100%;max-height:100%;width:auto;height:auto;object-fit:contain;padding:4px;box-sizing:border-box}.gengage-chat-ai-toppick-body{display:flex;flex-direction:column;gap:0;padding:0;flex:1;min-width:0}.gengage-chat-ai-toppick-name{font-size:14px;font-weight:600;line-height:1.375;color:#111827;margin-bottom:4px;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical}.gengage-chat-ai-toppick-role{font-size:11px;font-weight:600;color:var(--gengage-primary-color, #b7102a);text-transform:uppercase;letter-spacing:.3px}.gengage-chat-ai-toppick-labels{display:flex;flex-wrap:wrap;gap:4px;margin-top:6px}.gengage-chat-ai-toppick-label{font-size:11px;padding:1px 6px;border-radius:4px;font-weight:500}.gengage-chat-ai-toppick-label[data-sentiment=positive]{background:#dcfce7;color:#166534}.gengage-chat-ai-toppick-label[data-sentiment=negative]{background:#fee2e2;color:#991b1b}.gengage-chat-ai-toppick-label[data-sentiment=neutral]{background:var(--_gengage-surface-muted);color:#475569}.gengage-chat-ai-toppick-score{font-size:12px;font-weight:700;color:var(--gengage-primary-color, #b7102a);margin-top:6px}.gengage-chat-ai-toppick-reason{font-size:11px;color:#6b7280;line-height:1.45;margin-top:8px;margin-bottom:12px;flex:1 1 auto;min-height:0;display:-webkit-box;-webkit-line-clamp:3;line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}.gengage-chat-ai-toppick-review{font-size:12px;font-style:italic;color:var(--gengage-text-secondary, #64748b);margin:6px 0 0;padding-left:8px;border-left:2px solid var(--gengage-border-color, #e2e8f0);display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.gengage-chat-ai-toppick-price{font-size:14px;font-weight:700;color:var(--gengage-text-primary, #1e293b);margin-top:4px}.gengage-chat-ai-toppick-original-price{text-decoration:line-through;color:var(--gengage-text-secondary, #64748b);font-weight:400;font-size:12px}.gengage-chat-ai-toppick-cta{display:block;width:calc(100% - 24px);margin:14px 12px 12px;padding:8px 0;border:none;border-radius:8px;background:var(--gengage-primary-color, #b7102a);color:#fff;font-size:13px;font-weight:600;cursor:pointer;text-align:center;transition:background .15s ease;flex-shrink:0;align-self:stretch;box-sizing:border-box}.gengage-chat-ai-toppick-cta:hover{filter:brightness(.92)}.gengage-chat-ai-toppick-spinner{position:absolute;inset:0;background:#ffffffb3;display:flex;align-items:center;justify-content:center;border-radius:12px;z-index:6}.gengage-chat-ai-toppick-spinner:after{content:"";width:24px;height:24px;border:3px solid var(--gengage-border, #e2e8f0);border-top-color:var(--gengage-accent-primary, #3b82f6);border-radius:50%;animation:gengage-spin .7s linear infinite}@keyframes gengage-spin{to{transform:rotate(360deg)}}.gengage-chat-root--mobile .gengage-chat-ai-top-picks-scroll{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;overflow:visible;padding:10px 0 4px}.gengage-chat-root--mobile .gengage-chat-ai-toppick-card--winner,.gengage-chat-root--mobile .gengage-chat-ai-toppick-card--compact{width:100%;min-width:0;max-width:none;flex-shrink:1;scroll-snap-align:none}.gengage-chat-root--mobile .gengage-chat-ai-toppick-card--compact{flex-direction:column;align-items:stretch}.gengage-chat-root--mobile .gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-media,.gengage-chat-root--mobile .gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-media{max-height:76px;margin-top:4px;margin-bottom:6px}.gengage-chat-root--mobile .gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-img,.gengage-chat-root--mobile .gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-img{max-height:76px}.gengage-chat-root--mobile .gengage-chat-ai-toppick-badge{top:-8px;left:6px;font-size:7px;padding:2px 5px;max-width:calc(100% - 12px)}.gengage-chat-root--mobile .gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-cta,.gengage-chat-root--mobile .gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-cta{width:calc(100% - 20px);margin:12px 10px 10px;align-self:stretch}.gengage-chat-root--mobile .gengage-chat-rollback-btn{left:-24px}.gengage-chat-grounding-review{display:flex;align-items:center;gap:12px;padding:12px 16px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:10px;transition:background .15s ease,border-color .15s ease}.gengage-chat-grounding-review:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #b7102a)}.gengage-chat-grounding-review-icon{font-size:20px;flex-shrink:0}.gengage-chat-grounding-review-body{flex:1;min-width:0}.gengage-chat-grounding-review-title{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-grounding-review-subtitle{font-size:12px;color:var(--gengage-text-muted, #64748b);margin-top:2px}.gengage-chat-grounding-review-cta{font-size:13px;font-weight:500;color:var(--gengage-primary-color, #b7102a);white-space:nowrap;flex-shrink:0}.gengage-chat-grouping-cards{display:flex;flex-direction:column;gap:6px}.gengage-chat-grouping-cards-scroll{display:flex;flex-direction:column;gap:6px;min-width:0}.gengage-chat-grouping-card{display:flex;align-items:center;gap:10px;padding:8px 12px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:8px;transition:background .15s ease,border-color .15s ease}.gengage-chat-grouping-card:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #b7102a)}.gengage-chat-grouping-card-arrow{display:none;font-size:14px;color:var(--gengage-primary-color, #b7102a);flex-shrink:0}.gengage-chat-grouping-card-img{width:48px;height:48px;min-width:48px;min-height:48px;border-radius:4px;object-fit:cover;flex-shrink:0}.gengage-chat-grouping-card-body{flex:1;min-width:0;display:flex;align-items:baseline;gap:6px;flex-wrap:wrap}.gengage-chat-grouping-card-name{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-grouping-card-desc{font-size:12px;color:var(--gengage-text-muted, #64748b)}.gengage-chat-grouping-card-labels{display:block;font-size:11px;color:var(--gengage-chat-text-secondary, #888);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gengage-chat-root--mobile .gengage-chat-grouping-card-img{display:none}.gengage-chat-root--mobile .gengage-chat-grouping-card-arrow{display:inline}.gengage-chat-suggested-search-cards{display:flex;flex-direction:column;gap:8px}.gengage-chat-suggested-search-card{display:flex;align-items:flex-start;gap:12px;padding:10px 14px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:10px;transition:background .15s ease,border-color .15s ease}.gengage-chat-suggested-search-card:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #b7102a)}.gengage-chat-suggested-search-card-img{width:40px;height:40px;border-radius:6px;object-fit:cover;flex-shrink:0}.gengage-chat-suggested-search-card-body{flex:1;min-width:0}.gengage-chat-suggested-search-card-name{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-suggested-search-card-desc{font-size:12px;color:var(--gengage-text-secondary, #475569);margin-top:2px}.gengage-chat-suggested-search-card-diff{font-size:11px;color:var(--gengage-text-muted, #64748b);margin-top:2px;font-style:italic}.gengage-chat-product-details-gallery{position:relative}.gengage-chat-product-details-gallery .gengage-chat-product-details-img{touch-action:pan-y}.gengage-chat-product-gallery-thumbs{display:flex;gap:8px;padding:10px 0 4px;overflow-x:auto;scrollbar-width:thin;justify-content:center;width:100%}.gengage-chat-product-gallery-thumb{width:56px;height:56px;object-fit:cover;border-radius:8px;border:2px solid transparent;cursor:pointer;flex-shrink:0;transition:border-color .15s ease;background:#fff}.gengage-chat-product-gallery-thumb:hover{border-color:var(--gengage-border-color, #cbd5e1)}.gengage-chat-product-gallery-thumb--active{border-color:var(--gengage-primary-color, #b7102a)}.gengage-chat-product-gallery-thumb-more{display:flex;align-items:center;justify-content:center;width:56px;height:56px;border-radius:8px;background:var(--_gengage-surface-muted, #f1f5f9);color:var(--_gengage-text-secondary, #64748b);font-size:13px;font-weight:600;flex-shrink:0}.gengage-chat-product-variants{margin-top:12px}.gengage-chat-product-variants-label{font-size:12px;font-weight:600;color:var(--gengage-text-muted, #64748b);margin-bottom:6px;text-transform:none;letter-spacing:.5px}.gengage-chat-product-variants-list{display:flex;flex-wrap:wrap;gap:6px}.gengage-chat-product-variant-btn{padding:6px 12px;border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:6px;background:var(--gengage-surface-color, #f8fafc);color:var(--gengage-text-color, #1e293b);font-size:12px;cursor:pointer;transition:background .15s ease,border-color .15s ease}.gengage-chat-product-variant-btn:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #b7102a)}.gengage-chat-product-grid-wrapper{display:flex;flex-direction:column;gap:8px}.gengage-chat-product-sort-toolbar{display:flex;gap:4px;padding:4px;background:var(--gengage-surface-color, #f8fafc);border-radius:8px;border:1px solid var(--gengage-border-color, #e2e8f0)}.gengage-chat-product-sort-btn{flex:1;padding:6px 10px;border:1px solid var(--_gengage-border-color);border-radius:6px;background:transparent;color:var(--_gengage-text-secondary);font-size:12px;font-weight:500;cursor:pointer;transition:background .15s ease,color .15s ease}.gengage-chat-product-sort-btn:hover{background:var(--gengage-hover-color, #f1f5f9);color:var(--gengage-text-color, #1e293b)}.gengage-chat-product-sort-btn--active,.gengage-chat-product-sort-btn--active:hover{background:var(--gengage-primary-color, #b7102a);color:#fff}.gengage-chat-product-sort-separator{width:1px;background:var(--gengage-border-color, #e2e8f0);margin:2px}.gengage-chat-comparison-toggle-btn{flex:none;padding:6px 10px;border:none;border-radius:6px;background:transparent;color:var(--gengage-text-muted, #64748b);font-size:12px;font-weight:500;cursor:pointer;transition:background .15s ease,color .15s ease;white-space:nowrap}.gengage-chat-comparison-toggle-btn:hover{background:var(--gengage-hover-color, #f1f5f9);color:var(--gengage-text-color, #1e293b)}.gengage-chat-comparison-toggle-btn--active{background:transparent;border:1px solid var(--gengage-primary-color, #b7102a);color:var(--gengage-primary-color, #b7102a)}.gengage-chat-comparison-toggle-btn--active:hover{background:var(--gengage-primary-color, #b7102a);color:#fff}.gengage-chat-comparison-select-wrapper{position:relative}.gengage-chat-comparison-checkbox{position:absolute;top:8px;right:8px;z-index:4;width:20px;height:20px;cursor:pointer;accent-color:var(--gengage-primary-color, #b7102a);background:#fff;border-radius:4px;box-shadow:0 1px 3px #00000026}.gengage-chat-comparison-toggle-btn--hidden{opacity:0;pointer-events:none}@keyframes gengage-comparison-fade-in{0%{opacity:0}to{opacity:1}}.gengage-chat-comparison-toggle-btn--reveal{animation:gengage-comparison-fade-in .5s ease forwards}@media(prefers-reduced-motion:reduce){.gengage-chat-comparison-toggle-btn--reveal{animation:none;opacity:1}}.gengage-chat-comparison-floating-btn{display:block;width:100%;padding:10px 16px;border:none;border-radius:8px;background:var(--gengage-primary-color, #b7102a);color:#fff;font-size:14px;font-weight:600;cursor:pointer;transition:background .15s ease;text-align:center;position:sticky;bottom:0;z-index:5;box-shadow:0 -2px 8px #0000001a}.gengage-chat-comparison-floating-btn:hover:not(:disabled){background:var(--gengage-primary-hover, #9a0d23)}.gengage-chat-comparison-floating-btn--disabled{background:#94a3b8;cursor:default;opacity:.8}.gengage-chat-panel-topbar{display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid var(--_gengage-border-color);background:var(--_gengage-surface-muted);min-height:44px;flex-shrink:0;position:sticky;top:0;z-index:3}.gengage-chat-panel-topbar-back,.gengage-chat-panel-topbar-forward{width:28px;height:28px;min-width:28px;padding:0;border:1px solid #d1d5db;border-radius:6px;background:transparent;color:#374151;font-size:14px;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .15s ease,border-color .15s ease,opacity .15s ease}.gengage-chat-panel-topbar-back:hover:not(:disabled),.gengage-chat-panel-topbar-forward:hover:not(:disabled){background:var(--_gengage-surface-secondary);border-color:#9ca3af}.gengage-chat-panel-topbar-back:disabled,.gengage-chat-panel-topbar-forward:disabled{opacity:.3;cursor:default}.gengage-chat-panel-topbar-title{flex:1;font-size:14px;font-weight:600;color:var(--_gengage-text-primary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}@keyframes gengage-typewriter-fade-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-typewriter-block{display:block;animation:gengage-typewriter-fade-in .15s ease both}@media(prefers-reduced-motion:reduce){.gengage-chat-typewriter-block{animation:none}}.gengage-product-mention{color:var(--gengage-primary-color, #b7102a);text-decoration:none;cursor:pointer;font-weight:500;border-bottom:1px dashed var(--gengage-primary-color, #b7102a);transition:border-color .15s}.gengage-product-mention:hover{border-bottom-style:solid}@keyframes gengage-skeleton-pulse{0%,to{opacity:.4}50%{opacity:.8}}.gengage-chat-panel-skeleton-block{animation:gengage-skeleton-pulse 1.5s ease-in-out infinite}@media(prefers-reduced-motion:reduce){.gengage-chat-panel-skeleton-block{animation:none}}.gengage-chat-input-chips{display:flex;gap:6px;padding:4px 12px 2px;flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;-ms-overflow-style:none}.gengage-chat-input-chips::-webkit-scrollbar{display:none}.gengage-chat-input-chip{display:inline-flex;align-items:center;padding:4px 10px;border-radius:12px;border:1px solid var(--_gengage-border-color);background:#f9fafb;color:#374151;font-size:12px;font-weight:500;font-family:inherit;cursor:pointer;transition:background .12s,border-color .12s;white-space:nowrap}.gengage-chat-input-chip:hover{background:var(--_gengage-surface-secondary);border-color:#d1d5db}.gengage-chat-icon{width:14px;height:14px;flex-shrink:0}.gengage-chat-input-chip-icon,.gengage-chat-pill-icon{display:inline-flex;align-items:center;margin-right:4px}.gengage-chat-product-card-img-wrapper,.gengage-chat-product-details-img-wrap{position:relative;overflow:hidden}.gengage-chat-product-card-discount-badge{position:absolute;top:8px;left:8px;padding:3px 8px;border-radius:4px;background:var(--_gengage-discount-color);color:#fff;font-size:11px;font-weight:700;line-height:1.3;z-index:1}.gengage-chat-product-card-stock{font-size:11px;font-weight:600;margin-top:2px;padding:2px 6px;border-radius:4px;width:fit-content}.gengage-chat-product-card-stock.is-in-stock{background:#ecfdf5;color:#065f46}.gengage-chat-product-card-stock.is-out-of-stock{background:#fef2f2;color:#dc2626}.gengage-chat-find-similar-pill{position:absolute;top:40px;right:8px;opacity:0;pointer-events:none;transition:opacity .2s ease;padding:4px 10px;font-size:11px;font-weight:500;font-family:inherit;border:none;border-radius:12px;background:var(--gengage-chat-pill-bg, rgba(0, 0, 0, .7));color:var(--gengage-chat-pill-text, #fff);cursor:pointer;white-space:nowrap;z-index:2}.gengage-chat-product-card-img-wrapper:hover .gengage-chat-find-similar-pill,.gengage-chat-product-details-img-wrap:hover .gengage-chat-find-similar-pill{opacity:1;pointer-events:auto}.gengage-chat-favorite-btn{position:absolute;top:8px;right:8px;background:#ffffffe6;border:none;border-radius:50%;width:28px;height:28px;display:flex;align-items:center;justify-content:center;cursor:pointer;color:var(--gengage-text-secondary, #64748b);z-index:3;transition:color .2s;padding:0}.gengage-chat-favorite-btn:hover,.gengage-chat-favorite-btn--active{color:var(--gengage-accent-primary, #ef4444)}.gengage-chat-product-card-promos,.gengage-chat-product-details-promos{display:flex;flex-wrap:wrap;gap:4px;margin-top:4px}.gengage-chat-product-card-promo-badge,.gengage-chat-product-details-promo-badge{display:inline-block;padding:2px 6px;font-size:10px;font-weight:500;border-radius:4px;background:var(--gengage-chat-promo-bg, #e8f5e9);color:var(--gengage-chat-promo-text, #2e7d32);white-space:nowrap;min-height:20px;box-sizing:border-box}.gengage-chat-thumbnails-column{display:none!important;pointer-events:none}.gengage-chat-thumbnail-btn{display:flex;align-items:center;justify-content:center;width:40px;height:40px;padding:0;border:2px solid var(--_gengage-border-color);border-radius:6px;background:#fff;cursor:pointer;overflow:hidden;transition:border-color .15s ease}.gengage-chat-thumbnail-btn:hover{border-color:var(--gengage-primary-color, #b7102a)}.gengage-chat-thumbnail-img{width:100%;height:100%;object-fit:cover}.gengage-chat-panel-float{position:sticky;bottom:0;height:0;overflow:visible;pointer-events:none;z-index:10}.gengage-chat-choice-prompter{position:absolute;bottom:12px;right:12px;pointer-events:auto;width:200px;padding:12px 14px;background:#fff;border:1px solid var(--_gengage-border-color);border-radius:10px;box-shadow:0 4px 12px #0000001a;z-index:5;animation:gengage-choice-prompter-in .2s ease}@keyframes gengage-choice-prompter-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-choice-prompter-heading{font-size:13px;font-weight:600;color:var(--_gengage-text-primary);margin-bottom:4px}.gengage-chat-choice-prompter-suggestion{font-size:12px;color:#6b7280;margin-bottom:10px;line-height:1.4}.gengage-chat-choice-prompter-cta{display:block;width:100%;padding:6px 12px;border:none;border-radius:6px;background:var(--gengage-primary-color, #b7102a);color:#fff;font-size:12px;font-weight:600;font-family:inherit;cursor:pointer;text-align:center;transition:opacity .15s ease}.gengage-chat-choice-prompter-cta:hover{opacity:.9}.gengage-chat-choice-prompter-dismiss{position:absolute;top:8px;right:8px;padding:4px 8px;min-width:28px;min-height:28px;display:flex;align-items:center;justify-content:center;border:none;background:none;color:#6b7280;font-size:16px;cursor:pointer;line-height:1}.gengage-chat-choice-prompter-dismiss:hover{color:#6b7280}@media(prefers-reduced-motion:reduce){.gengage-chat-choice-prompter{animation:none}}.gengage-chat-pros-cons{padding:12px 14px;background:var(--_gengage-surface-muted);border-radius:8px;margin:8px 0}.gengage-chat-pros-cons-heading{margin:0 0 10px;font-size:14px;font-weight:600;color:#0f172a}.gengage-chat-pros-cons-list{list-style:none;margin:0 0 8px;padding:0}.gengage-chat-pros-cons-list:last-child{margin-bottom:0}.gengage-chat-pros-cons-item{display:flex;align-items:flex-start;gap:8px;padding:4px 0;font-size:13px;line-height:1.5;color:#334155}.gengage-chat-pros-cons-icon{flex-shrink:0;width:18px;height:18px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;border-radius:50%}.gengage-chat-pros-cons-icon--pro{color:var(--_gengage-success-color);background:color-mix(in srgb,var(--_gengage-success-color) 15%,#fff)}.gengage-chat-pros-cons-icon--con{color:#dc2626;background:#fee2e2}.gengage-chat-categories{display:flex;flex-direction:column;gap:8px}.gengage-chat-categories-tabs{display:flex;gap:4px;overflow-x:auto;padding:4px 0;-webkit-overflow-scrolling:touch}.gengage-chat-categories-tab{padding:6px 14px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:20px;background:var(--gengage-bg, #fff);color:var(--gengage-text, #374151);cursor:pointer;white-space:nowrap;font-size:13px;transition:background .15s,color .15s}.gengage-chat-categories-tab:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-categories-tab--active{background:var(--gengage-primary, #2563eb);color:#fff;border-color:var(--gengage-primary, #2563eb)}.gengage-chat-categories-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px}.gengage-chat-categories-filter-tags{display:flex;gap:6px;flex-wrap:wrap;margin-top:4px}.gengage-chat-categories-filter-tag{padding:4px 10px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:14px;background:var(--gengage-bg, #fff);color:var(--gengage-text-secondary, #6b7280);font-size:12px;cursor:pointer;transition:background .15s}.gengage-chat-categories-filter-tag:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-product-grid-view-more{display:block;width:100%;padding:10px;margin-top:8px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:8px;background:var(--gengage-bg, #fff);color:var(--gengage-primary, #2563eb);font-size:14px;font-weight:500;cursor:pointer;text-align:center;transition:background .15s;grid-column:1 / -1}.gengage-chat-product-grid-view-more:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-product-grid--mobile{display:flex;overflow-x:auto;gap:8px;padding:8px 0;-webkit-overflow-scrolling:touch}.gengage-chat-product-grid--mobile .gengage-chat-product-card{min-width:160px;max-width:180px;flex-shrink:0}.gengage-chat-comparison--mobile{overflow-x:auto;-webkit-overflow-scrolling:touch;position:relative}.gengage-chat-comparison--mobile{-webkit-mask-image:linear-gradient(to right,#000 85%,transparent);mask-image:linear-gradient(to right,#000 85%,transparent)}.gengage-chat-comparison--mobile .gengage-chat-comparison-table{min-width:480px}.gengage-chat-comparison-key-differences{margin-top:12px;padding:12px;background:var(--gengage-bg-secondary, #f9fafb);border-radius:8px}.gengage-chat-comparison-key-differences h4{margin:0 0 8px;font-size:14px;font-weight:600;color:var(--gengage-text, #374151)}.gengage-chat-comparison-key-differences-content{font-size:13px;color:var(--gengage-text-secondary, #6b7280);line-height:1.5}.gengage-chat-comparison-key-differences-content ul{margin:0;padding-left:18px}.gengage-chat-comparison-key-differences-content li{margin-bottom:4px}.gengage-chat-product-details-similars-heading{margin:16px 0 8px;font-size:15px;font-weight:600;color:var(--gengage-text, #374151)}.gengage-chat-product-details-similars{margin-top:8px}.gengage-chat-handoff-notice{display:flex;flex-direction:column;align-items:center;gap:6px;padding:16px;margin:8px 0;background:#fef3c7;border:1px solid #fcd34d;border-radius:8px;text-align:center}.gengage-chat-handoff-notice-icon{font-size:24px}.gengage-chat-handoff-notice-heading{margin:0;font-size:14px;font-weight:600;color:#92400e}.gengage-chat-handoff-notice-summary{margin:0;font-size:13px;line-height:1.5;color:#78350f}.gengage-qty-stepper{display:inline-flex;align-items:center;gap:0;border:1px solid #d1d5db;border-radius:8px;overflow:hidden;background:#fff}.gengage-qty-btn{width:var(--_gengage-qty-btn-size);height:var(--_gengage-qty-btn-size);border:none;background:transparent;color:#374151;font-size:14px;font-weight:600;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background-color .12s}.gengage-qty-btn:hover:not(:disabled){background:var(--_gengage-surface-secondary)}.gengage-qty-btn:disabled{opacity:.35;cursor:default}.gengage-qty-value{min-width:24px;text-align:center;font-size:13px;font-weight:600;color:var(--_gengage-text-primary);-webkit-user-select:none;user-select:none}.gengage-qty-submit{border:none;border-left:1px solid #d1d5db;background:var(--_gengage-success-color);color:#fff;font-size:13px;font-weight:700;font-family:inherit;cursor:pointer;padding:6px 12px;transition:filter .12s ease,transform .12s ease}.gengage-qty-submit:hover{filter:brightness(1.08)}.gengage-qty-submit:active{transform:translateY(1px)}.gengage-qty-submit--success{background:var(--_gengage-success-color);transition:background .2s ease}.gengage-qty-stepper--compact{border-radius:14px;box-shadow:0 2px 6px #0000001f}.gengage-qty-stepper--compact .gengage-qty-btn{width:var(--_gengage-qty-btn-size-compact);height:var(--_gengage-qty-btn-size-compact);font-size:12px}.gengage-qty-stepper--compact .gengage-qty-value{min-width:18px;font-size:12px}.gengage-qty-stepper--compact .gengage-qty-submit{padding:4px 8px;font-size:13px;border-radius:0 14px 14px 0}.gengage-chat-panel .gengage-qty-stepper{border:1px solid var(--_gengage-border-color);border-radius:8px;overflow:hidden}.gengage-chat-panel .gengage-qty-stepper button,.gengage-chat-panel .gengage-qty-stepper .gengage-qty-value{border:none;border-right:1px solid var(--_gengage-border-color)}.gengage-chat-panel .gengage-qty-stepper .gengage-qty-submit{border-right:none}.gengage-chat-product-details-atc-stepper{border-radius:10px}.gengage-chat-product-details-atc-stepper .gengage-qty-btn{width:32px;height:32px}.gengage-chat-product-details-atc-stepper .gengage-qty-value{min-width:28px;font-size:14px}.gengage-chat-product-details-atc-stepper .gengage-qty-submit{padding:8px 18px;font-size:14px;border-radius:0 10px 10px 0}.gengage-chat-product-details-share{display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;border:1px solid #d1d5db;border-radius:10px;background:transparent;color:#6b7280;cursor:pointer;transition:color .12s,border-color .12s,background-color .12s;position:relative;flex-shrink:0}.gengage-chat-product-details-share:hover{color:var(--gengage-primary-color, #b7102a);border-color:var(--gengage-primary-color, #b7102a);background:#f0f7ff}.gengage-chat-product-details-share:before{content:attr(aria-label);position:absolute;bottom:calc(100% + 6px);left:50%;transform:translate(-50%);padding:4px 8px;border-radius:4px;background:var(--_gengage-surface-dark);color:#fff;font-size:11px;font-weight:500;white-space:nowrap;pointer-events:none;opacity:0;transition:opacity .15s ease;z-index:2}.gengage-chat-product-details-share:hover:before{opacity:1}.gengage-chat-product-details-share--copied:after{content:"✓";position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:var(--_gengage-success-color);color:#fff;border-radius:10px;font-size:16px;font-weight:700}.gengage-chat-product-details-share svg{width:20px;height:20px}.gengage-chat-review-link,.gengage-chat-grounding-link{text-decoration:underline;color:var(--gengage-primary-color, #b7102a)}@media(max-width:768px){.gengage-chat-product-card-promo-badge,.gengage-chat-product-details-promo-badge{-webkit-line-clamp:2;line-clamp:2;display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden;white-space:normal}}.gengage-chat-launcher:focus-visible,.gengage-chat-close:focus-visible,.gengage-chat-header-btn:focus-visible,.gengage-chat-header-powered:focus-visible,.gengage-chat-send:focus-visible,.gengage-chat-action-btn:focus-visible,.gengage-chat-pill:focus-visible,.gengage-chat-input-chip:focus-visible,.gengage-chat-pills-arrow:focus-visible,.gengage-chat-error-retry:focus-visible,.gengage-chat-product-card-cta:focus-visible,.gengage-chat-product-details-cta:focus-visible,.gengage-chat-product-details-atc:focus-visible,.gengage-chat-product-detail-tab:focus-visible,.gengage-chat-panel-divider-toggle:focus-visible,.gengage-chat-panel-topbar-back:focus-visible,.gengage-chat-panel-topbar-forward:focus-visible,.gengage-chat-rollback-btn:focus-visible,.gengage-chat-ai-toppick-cta:focus-visible,.gengage-chat-comparison-view-btn:focus-visible,.gengage-chat-comparison-toggle-btn:focus-visible,.gengage-chat-comparison-floating-btn:focus-visible,.gengage-chat-comparison-checkbox:focus-visible,.gengage-chat-product-sort-btn:focus-visible,.gengage-chat-product-variant-btn:focus-visible,.gengage-chat-product-gallery-thumb:focus-visible,.gengage-chat-thumbnail-btn:focus-visible,.gengage-chat-find-similar-pill:focus-visible,.gengage-chat-favorite-btn:focus-visible,.gengage-chat-attach-btn:focus-visible,.gengage-chat-mic-btn:focus-visible,.gengage-chat-attachment-remove:focus-visible,.gengage-chat-kvkk-dismiss:focus-visible,.gengage-chat-choice-prompter-cta:focus-visible,.gengage-chat-choice-prompter-dismiss:focus-visible,.gengage-chat-categories-tab:focus-visible,.gengage-chat-categories-filter-tag:focus-visible,.gengage-chat-product-grid-view-more:focus-visible,.gengage-chat-product-details-share:focus-visible,.gengage-qty-btn:focus-visible,.gengage-qty-submit:focus-visible{outline:2px solid var(--gengage-primary-color, #b7102a);outline-offset:2px}.gengage-chat-root--mobile .gengage-chat-choice-prompter{left:12px;right:12px;width:auto;max-width:none;bottom:12px;max-height:40vh;overflow-y:auto}.gengage-chat-root--mobile .gengage-chat-product-sort-btn,.gengage-chat-root--mobile .gengage-chat-comparison-toggle-btn{min-height:40px}.gengage-chat-root--mobile .gengage-chat-input-chip{min-height:40px;padding:8px 12px}.gengage-chat-root--mobile .gengage-chat-choice-prompter-dismiss{width:32px;height:32px}.gengage-chat-root--mobile .gengage-chat-panel-divider-toggle{min-height:44px}.gengage-chat-root--mobile .gengage-chat-product-details-atc-stepper .gengage-qty-btn{width:44px;height:44px}.gengage-chat-root--mobile .gengage-chat-product-details-atc-stepper .gengage-qty-submit,.gengage-chat-root--mobile .gengage-qty-stepper--compact .gengage-qty-submit{min-height:44px}.gengage-chat-root--mobile .gengage-qty-stepper--compact .gengage-qty-submit{min-width:44px;padding:0 10px}.gengage-chat-root--mobile .gengage-qty-stepper--compact .gengage-qty-btn{width:44px;height:44px;font-size:14px}.gengage-chat-root--mobile .gengage-qty-stepper--compact .gengage-qty-value{min-width:24px;font-size:13px}.gengage-chat-root--mobile .gengage-chat-product-card-cta,.gengage-chat-root--mobile .gengage-chat-choice-prompter-cta,.gengage-chat-root--mobile .gengage-chat-product-grid-view-more{min-height:44px;display:flex;align-items:center;justify-content:center}.gengage-chat-root--mobile .gengage-chat-panel-topbar-back,.gengage-chat-root--mobile .gengage-chat-panel-topbar-forward,.gengage-chat-root--mobile .gengage-chat-favorite-btn,.gengage-chat-root--mobile .gengage-chat-product-details-share{width:44px;height:44px}.gengage-skeleton{display:flex;gap:12px;padding:12px}.gengage-skeleton--message{flex-direction:column;gap:8px;padding:16px}.gengage-skeleton-card{flex:1;display:flex;flex-direction:column;gap:8px}.gengage-skeleton-img{height:120px;border-radius:8px}.gengage-skeleton-text{height:14px;border-radius:4px}.gengage-skeleton-price{height:14px;width:60%;border-radius:4px}.gengage-skeleton-line{height:12px;border-radius:4px}@media(prefers-reduced-motion:no-preference){.gengage-skeleton-card,.gengage-skeleton-line,.gengage-skeleton-img,.gengage-skeleton-text,.gengage-skeleton-price{background:linear-gradient(90deg,#f0f0f0 25%,#e0e0e0,#f0f0f0 75%);background-size:200% 100%;animation:gengage-shimmer 1.5s infinite}@keyframes gengage-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}}@media(prefers-reduced-motion:reduce){.gengage-skeleton-card,.gengage-skeleton-line,.gengage-skeleton-img,.gengage-skeleton-text,.gengage-skeleton-price{background:#f0f0f0}}.gengage-chat-panel--has-scroll:after{content:"";position:sticky;bottom:0;display:block;height:40px;background:linear-gradient(transparent,var(--gengage-chat-panel-bg, #f5f5f5));pointer-events:none}@media(prefers-reduced-motion:no-preference){.gengage-chat-panel--transitioning{opacity:0;transition:opacity .15s ease}}';function Qr(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function ie(e,t){const n={event:e,...t};Qr()&&window.dataLayer.push(n)}function es(e){ie("gengage-on-init",{gengage_widget:e})}function ts(e){ie("gengage-show",{gengage_widget:e})}function ns(e,t){ie("gengage-suggested-question",{gengage_question_title:e,gengage_action_type:t})}function as(e){ie("gengage-find-similars",{gengage_sku:e})}function is(e){ie("gengage-compare-preselection",{gengage_sku:e})}function zn(e){ie("gengage-compare-selected",{gengage_skus:e,gengage_product_count:e.length})}function os(){ie("gengage-compare-clear")}function rs(e){ie("gengage-compare-received",{gengage_product_count:e})}function ss(e){ie("gengage-like-product",{gengage_sku:e})}function cs(){ie("gengage-like-list")}function ls(e,t){ie("gengage-search",{gengage_search_query:e,gengage_result_count:t})}function gs(e,t){ie("gengage-product-detail",{gengage_sku:e,gengage_product_name:t})}function ds(e,t){ie("gengage-cart-add",{gengage_sku:e,gengage_quantity:t})}function ps(){ie("gengage-message-sent")}function Nn(){ie("gengage-message-received")}function hs(){ie("gengage-conversation-start")}function us(){ie("gengage-voice-input")}function u(e,t,n){function a(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:r,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,c);const l=r.prototype,d=Object.keys(l);for(let p=0;p<d.length;p++){const g=d[p];g in s||(s[g]=l[g].bind(s))}}const i=n?.Parent??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function r(s){var c;const l=n?.Parent?new o:this;a(l,s),(c=l._zod).deferred??(c.deferred=[]);for(const d of l._zod.deferred)d();return l}return Object.defineProperty(r,"init",{value:a}),Object.defineProperty(r,Symbol.hasInstance,{value:s=>n?.Parent&&s instanceof n.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(r,"name",{value:e}),r}class Ze extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Mn extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Bn={};function Ae(e){return Bn}function Rn(e){const t=Object.values(e).filter(a=>typeof a=="number");return Object.entries(e).filter(([a,i])=>t.indexOf(+a)===-1).map(([a,i])=>i)}function Pt(e,t){return typeof t=="bigint"?t.toString():t}function Lt(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function zt(e){return e==null}function Nt(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function fs(e,t){const n=(e.toString().split(".")[1]||"").length,a=t.toString();let i=(a.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(a)){const c=a.match(/\d?e-(\d?)/);c?.[1]&&(i=Number.parseInt(c[1]))}const o=n>i?n:i,r=Number.parseInt(e.toFixed(o).replace(".","")),s=Number.parseInt(t.toFixed(o).replace(".",""));return r%s/10**o}const On=Symbol("evaluating");function q(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==On)return a===void 0&&(a=On,a=n()),a},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Re(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ie(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function $n(e){return JSON.stringify(e)}function ms(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Dn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function at(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const bs=Lt(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function je(e){if(at(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(at(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Fn(e){return je(e)?{...e}:Array.isArray(e)?[...e]:e}const _s=new Set(["string","number","symbol"]);function it(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Pe(e,t,n){const a=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(a._zod.parent=e),a}function z(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function vs(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const ys={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ws(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o=Ie(e._zod.def,{get shape(){const r={};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(r[s]=n.shape[s])}return Re(this,"shape",r),r},checks:[]});return Pe(e,o)}function xs(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=Ie(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete r[s]}return Re(this,"shape",r),r},checks:[]});return Pe(e,o)}function ks(e,t){if(!je(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const o=e._zod.def.shape;for(const r in t)if(Object.getOwnPropertyDescriptor(o,r)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=Ie(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return Re(this,"shape",o),o}});return Pe(e,i)}function Cs(e,t){if(!je(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Ie(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return Re(this,"shape",a),a}});return Pe(e,n)}function Es(e,t){const n=Ie(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return Re(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:[]});return Pe(e,n)}function Ss(e,t,n){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const r=Ie(t._zod.def,{get shape(){const s=t._zod.def.shape,c={...s};if(n)for(const l in n){if(!(l in s))throw new Error(`Unrecognized key: "${l}"`);n[l]&&(c[l]=e?new e({type:"optional",innerType:s[l]}):s[l])}else for(const l in s)c[l]=e?new e({type:"optional",innerType:s[l]}):s[l];return Re(this,"shape",c),c},checks:[]});return Pe(t,r)}function Ts(e,t,n){const a=Ie(t._zod.def,{get shape(){const i=t._zod.def.shape,o={...i};if(n)for(const r in n){if(!(r in o))throw new Error(`Unrecognized key: "${r}"`);n[r]&&(o[r]=new e({type:"nonoptional",innerType:i[r]}))}else for(const r in i)o[r]=new e({type:"nonoptional",innerType:i[r]});return Re(this,"shape",o),o}});return Pe(t,a)}function qe(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function He(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function ot(e){return typeof e=="string"?e:e?.message}function Le(e,t,n){const a={...e,path:e.path??[]};if(!e.message){const i=ot(e.inst?._zod.def?.error?.(e))??ot(t?.error?.(e))??ot(n.customError?.(e))??ot(n.localeError?.(e))??"Invalid input";a.message=i}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function Mt(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ye(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}const Un=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Pt,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Zn=u("$ZodError",Un),jn=u("$ZodError",Un,{Parent:Error});function As(e,t=n=>n.message){const n={},a=[];for(const i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):a.push(t(i));return{formErrors:a,fieldErrors:n}}function Is(e,t=n=>n.message){const n={_errors:[]},a=i=>{for(const o of i.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(r=>a({issues:r}));else if(o.code==="invalid_key")a({issues:o.issues});else if(o.code==="invalid_element")a({issues:o.issues});else if(o.path.length===0)n._errors.push(t(o));else{let r=n,s=0;for(;s<o.path.length;){const c=o.path[s];s===o.path.length-1?(r[c]=r[c]||{_errors:[]},r[c]._errors.push(t(o))):r[c]=r[c]||{_errors:[]},r=r[c],s++}}};return a(e),n}const Bt=e=>(t,n,a,i)=>{const o=a?Object.assign(a,{async:!1}):{async:!1},r=t._zod.run({value:n,issues:[]},o);if(r instanceof Promise)throw new Ze;if(r.issues.length){const s=new(i?.Err??e)(r.issues.map(c=>Le(c,o,Ae())));throw Dn(s,i?.callee),s}return r.value},Rt=e=>async(t,n,a,i)=>{const o=a?Object.assign(a,{async:!0}):{async:!0};let r=t._zod.run({value:n,issues:[]},o);if(r instanceof Promise&&(r=await r),r.issues.length){const s=new(i?.Err??e)(r.issues.map(c=>Le(c,o,Ae())));throw Dn(s,i?.callee),s}return r.value},rt=e=>(t,n,a)=>{const i=a?{...a,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new Ze;return o.issues.length?{success:!1,error:new(e??Zn)(o.issues.map(r=>Le(r,i,Ae())))}:{success:!0,data:o.value}},Ps=rt(jn),st=e=>async(t,n,a)=>{const i=a?Object.assign(a,{async:!0}):{async:!0};let o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(r=>Le(r,i,Ae())))}:{success:!0,data:o.value}},Ls=st(jn),zs=e=>(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Bt(e)(t,n,i)},Ns=e=>(t,n,a)=>Bt(e)(t,n,a),Ms=e=>async(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Rt(e)(t,n,i)},Bs=e=>async(t,n,a)=>Rt(e)(t,n,a),Rs=e=>(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return rt(e)(t,n,i)},Os=e=>(t,n,a)=>rt(e)(t,n,a),$s=e=>async(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return st(e)(t,n,i)},Ds=e=>async(t,n,a)=>st(e)(t,n,a),Fs=/^[cC][^\s-]{8,}$/,Us=/^[0-9a-z]+$/,Zs=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,js=/^[0-9a-vA-V]{20}$/,qs=/^[A-Za-z0-9]{27}$/,Hs=/^[a-zA-Z0-9_-]{21}$/,Vs=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ws=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,qn=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Gs=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Ks="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Ys(){return new RegExp(Ks,"u")}const Js=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Xs=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Qs=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,ec=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,tc=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Hn=/^[A-Za-z0-9_-]*$/,nc=/^\+[1-9]\d{6,14}$/,Vn="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",ac=new RegExp(`^${Vn}$`);function Wn(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function ic(e){return new RegExp(`^${Wn(e)}$`)}function oc(e){const t=Wn({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const a=`${t}(?:${n.join("|")})`;return new RegExp(`^${Vn}T(?:${a})$`)}const rc=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},sc=/^-?\d+$/,Gn=/^-?\d+(?:\.\d+)?$/,cc=/^(?:true|false)$/i,lc=/^[^A-Z]*$/,gc=/^[^a-z]*$/,ge=u("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Kn={number:"number",bigint:"bigint",object:"date"},Yn=u("$ZodCheckLessThan",(e,t)=>{ge.init(e,t);const n=Kn[typeof t.value];e._zod.onattach.push(a=>{const i=a._zod.bag,o=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value<=t.value:a.value<t.value)||a.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Jn=u("$ZodCheckGreaterThan",(e,t)=>{ge.init(e,t);const n=Kn[typeof t.value];e._zod.onattach.push(a=>{const i=a._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value>=t.value:a.value>t.value)||a.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),dc=u("$ZodCheckMultipleOf",(e,t)=>{ge.init(e,t),e._zod.onattach.push(n=>{var a;(a=n._zod.bag).multipleOf??(a.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):fs(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),pc=u("$ZodCheckNumberFormat",(e,t)=>{ge.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),a=n?"int":"number",[i,o]=ys[t.format];e._zod.onattach.push(r=>{const s=r._zod.bag;s.format=t.format,s.minimum=i,s.maximum=o,n&&(s.pattern=sc)}),e._zod.check=r=>{const s=r.value;if(n){if(!Number.isInteger(s)){r.issues.push({expected:a,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?r.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort}):r.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort});return}}s<i&&r.issues.push({origin:"number",input:s,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>o&&r.issues.push({origin:"number",input:s,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),hc=u("$ZodCheckMaxLength",(e,t)=>{var n;ge.init(e,t),(n=e._zod.def).when??(n.when=a=>{const i=a.value;return!zt(i)&&i.length!==void 0}),e._zod.onattach.push(a=>{const i=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(a._zod.bag.maximum=t.maximum)}),e._zod.check=a=>{const i=a.value;if(i.length<=t.maximum)return;const r=Mt(i);a.issues.push({origin:r,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),uc=u("$ZodCheckMinLength",(e,t)=>{var n;ge.init(e,t),(n=e._zod.def).when??(n.when=a=>{const i=a.value;return!zt(i)&&i.length!==void 0}),e._zod.onattach.push(a=>{const i=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(a._zod.bag.minimum=t.minimum)}),e._zod.check=a=>{const i=a.value;if(i.length>=t.minimum)return;const r=Mt(i);a.issues.push({origin:r,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),fc=u("$ZodCheckLengthEquals",(e,t)=>{var n;ge.init(e,t),(n=e._zod.def).when??(n.when=a=>{const i=a.value;return!zt(i)&&i.length!==void 0}),e._zod.onattach.push(a=>{const i=a._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=a=>{const i=a.value,o=i.length;if(o===t.length)return;const r=Mt(i),s=o>t.length;a.issues.push({origin:r,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),ct=u("$ZodCheckStringFormat",(e,t)=>{var n,a;ge.init(e,t),e._zod.onattach.push(i=>{const o=i._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(a=e._zod).check??(a.check=()=>{})}),mc=u("$ZodCheckRegex",(e,t)=>{ct.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),bc=u("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=lc),ct.init(e,t)}),_c=u("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=gc),ct.init(e,t)}),vc=u("$ZodCheckIncludes",(e,t)=>{ge.init(e,t);const n=it(t.includes),a=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=a,e._zod.onattach.push(i=>{const o=i._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(a)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),yc=u("$ZodCheckStartsWith",(e,t)=>{ge.init(e,t);const n=new RegExp(`^${it(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:e,continue:!t.abort})}}),wc=u("$ZodCheckEndsWith",(e,t)=>{ge.init(e,t);const n=new RegExp(`.*${it(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:e,continue:!t.abort})}}),xc=u("$ZodCheckOverwrite",(e,t)=>{ge.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class kc{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const a=t.split(`
57
+ </svg>`;function qo(e){const t=document.createElement("div");t.className="gengage-chat-launcher-container";const n=document.createElement("div");n.className="gengage-chat-launcher-content-area",t.appendChild(n);const a=document.createElement("button");if(a.type="button",a.setAttribute("aria-label",e.ariaLabel??"Open chat"),e.imageUrl){a.className="gengage-chat-launcher gengage-chat-launcher--image-mode";const o=document.createElement("img");o.src=e.imageUrl,o.alt="",o.draggable=!1,a.appendChild(o)}else a.className="gengage-chat-launcher",a.innerHTML=e.svgMarkup??jo;if(e.tooltip!==void 0){const o=document.createElement("span");o.className="gengage-chat-launcher-tooltip",o.textContent=e.tooltip,a.appendChild(o)}e.hideMobile&&(t.dataset.hideMobile="1"),e.mobileBreakpoint!==void 0&&(t.dataset.mobileBreakpoint=String(e.mobileBreakpoint)),a.addEventListener("click",e.onClick),t.appendChild(a);const i=document.createElement("div");return i.className="gengage-chat-launcher-content-area-bottom",t.appendChild(i),{container:t,button:a,contentArea:n,contentAreaBottom:i}}const Ho=new Set(["audio/ogg","audio/mpeg","audio/mp3","audio/wav","audio/webm","audio/aac","audio/mp4"]),un=new Set;function Et(e){e.pause(),e.removeAttribute("src"),e.load(),un.delete(e)}function Vo(e,t="audio/ogg"){const n=t.split(";")[0].trim();if(!Ho.has(n))return null;try{const a=new Audio(`data:${t};base64,${e}`);return un.add(a),a.addEventListener("ended",()=>Et(a),{once:!0}),a.play().catch(()=>{Et(a)}),{stop:()=>Et(a)}}catch{return null}}const Wo={currencySymbol:"TL",currencyPosition:"suffix",thousandsSeparator:".",decimalSeparator:",",alwaysShowDecimals:!0};function ge(e,t){const n=Number(e);if(!Number.isFinite(n)||n<0)return e;const a={...Wo,...t},o=n%1!==0||a.alwaysShowDecimals?n.toFixed(2):n.toFixed(0),r=o.indexOf("."),s=r===-1?o:o.slice(0,r),c=r===-1?void 0:o.slice(r+1),l=s.replace(/\B(?=(\d{3})+(?!\d))/g,a.thousandsSeparator);let g;return c!==void 0?g=`${l}${a.decimalSeparator}${c}`:g=l,a.currencySymbol?a.currencyPosition==="prefix"?`${a.currencySymbol}${g}`:`${g} ${a.currencySymbol}`:g}const Go={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 Ko(e,t){return t?.[e]??Go[e]??e.replace(/_/g," ").replace(/^\w/,n=>n.toUpperCase())}function Yo(e){const{recommended:t,products:n,attributes:a,highlights:i,specialCases:o,onProductClick:r,i18n:s}=e,c=document.createElement("div");c.className="gengage-chat-comparison",c.setAttribute("role","dialog"),c.setAttribute("aria-label",s?.comparisonHeading??"Comparison Results");const l=document.createElement("h3");if(l.className="gengage-chat-comparison-heading",l.textContent=s?.comparisonHeading??"COMPARISON RESULTS",c.appendChild(l),t){const g=document.createElement("div");g.className="gengage-chat-comparison-recommended";const p=document.createElement("div");p.className="gengage-chat-comparison-recommended-label",p.textContent=s?.recommendedChoiceLabel??"Recommended Choice",g.appendChild(p);const d=document.createElement("div");if(d.className="gengage-chat-comparison-recommended-body",t.imageUrl&&Se(t.imageUrl)){const y=document.createElement("img");y.src=t.imageUrl,y.alt=t.name,y.loading="lazy",y.addEventListener("error",()=>{y.style.display="none"},{once:!0}),d.appendChild(y)}const h=document.createElement("div");h.className="gengage-chat-comparison-recommended-info";const u=document.createElement("div");u.className="gengage-chat-comparison-recommended-title",u.textContent=t.name,h.appendChild(u);const b=document.createElement("div");if(b.className="gengage-chat-comparison-recommended-price",b.textContent=ge(t.price,e.pricing),h.appendChild(b),d.appendChild(h),d.addEventListener("click",()=>{r(t.sku)}),d.style.cursor="pointer",g.appendChild(d),i.length>0){const y=document.createElement("div");y.className="gengage-chat-comparison-highlights";const w=document.createElement("div");w.className="gengage-chat-comparison-highlights-label",w.textContent=s?.highlightsLabel??"Key Highlights",y.appendChild(w);const E=document.createElement("ul");for(const A of i){const f=document.createElement("li");f.textContent=A,E.appendChild(f)}y.appendChild(E),g.appendChild(y)}if(e.recommendedText){const y=document.createElement("div");y.className="gengage-chat-comparison-recommended-text",y.innerHTML=we(e.recommendedText),g.appendChild(y)}c.appendChild(g)}if(e.keyDifferencesHtml){const g=document.createElement("div");g.className="gengage-chat-comparison-key-differences";const p=document.createElement("h4");p.textContent=s?.keyDifferencesLabel??"Key Differences",g.appendChild(p);const d=document.createElement("div");d.className="gengage-chat-comparison-key-differences-content",d.innerHTML=we(Jo(e.keyDifferencesHtml)),g.appendChild(d),c.appendChild(g)}if(o&&o.length>0){const g=document.createElement("details");g.className="gengage-chat-comparison-special";const p=document.createElement("summary");p.textContent=s?.specialCasesLabel??"For Special Cases",g.appendChild(p);const d=document.createElement("ul");for(const h of o)Xo(d,h);d.childElementCount>0&&g.appendChild(d),c.appendChild(g)}if(n.length>0&&a.length>0){const g=document.createElement("table");g.className="gengage-chat-comparison-table";const p=document.createElement("thead"),d=document.createElement("tr"),h=document.createElement("th");d.appendChild(h);for(const y of n){const w=document.createElement("th");if(y.sku===t?.sku&&(w.className="gengage-chat-comparison-selected"),y.imageUrl&&Se(y.imageUrl)){const f=document.createElement("img");f.src=y.imageUrl,f.alt=y.name,f.loading="lazy",f.addEventListener("error",()=>{f.style.display="none"},{once:!0}),w.appendChild(f)}const E=document.createElement("div");E.textContent=y.name,w.appendChild(E);const A=document.createElement("div");A.className="gengage-chat-comparison-table-price",A.textContent=ge(y.price,e.pricing),w.appendChild(A),d.appendChild(w)}p.appendChild(d),g.appendChild(p);const u=document.createElement("tbody");for(const y of a){const w=document.createElement("tr"),E=document.createElement("td");E.className="gengage-chat-comparison-label",E.textContent=Ko(y.label,s?.criteriaLabels),w.appendChild(E);for(let A=0;A<y.values.length;A++){const f=document.createElement("td");n[A]?.sku===t?.sku&&(f.className="gengage-chat-comparison-selected"),f.textContent=y.values[A]??"",w.appendChild(f)}u.appendChild(w)}g.appendChild(u);const b=document.createElement("div");b.className="gengage-chat-comparison-table-wrapper",b.appendChild(g),c.appendChild(b)}if(e.productActions){const g=document.createElement("div");g.className="gengage-chat-comparison-product-actions";for(const p of n)if(e.productActions[p.sku]){const h=document.createElement("button");h.className="gengage-chat-comparison-view-btn",h.type="button",h.textContent=p.name,h.addEventListener("click",()=>r(p.sku)),g.appendChild(h)}g.childElementCount>0&&c.appendChild(g)}return c.addEventListener("keydown",g=>{if(g.key!=="Tab")return;const p=c.querySelectorAll('button, [href], input, [tabindex]:not([tabindex="-1"])');if(p.length===0)return;const d=p[0],h=p[p.length-1];g.shiftKey&&document.activeElement===d?(g.preventDefault(),h.focus()):!g.shiftKey&&document.activeElement===h&&(g.preventDefault(),d.focus())}),c}function Jo(e){if(/<[uo]l[\s>]/i.test(e)||/<li[\s>]/i.test(e))return e;const t=e.split(`
58
+ `).filter(n=>n.trim());return t.length<=1?e:"<ul>"+t.map(n=>`<li>${n.trim()}</li>`).join("")+"</ul>"}function Xo(e,t){const n=we(t);if(!n)return;const a=document.createElement("template");a.innerHTML=n;const i=Array.from(a.content.querySelectorAll("li"));if(i.length>0){for(const r of i){const s=document.createElement("li");s.innerHTML=we(r.innerHTML),e.appendChild(s)}return}const o=document.createElement("li");Qo(t)?o.innerHTML=n:o.textContent=t,e.appendChild(o)}function Qo(e){return/<\/?[a-z][\s\S]*>/i.test(e)}function er(e,t){const n=document.createElement("div");n.className="gengage-chat-review-highlights";const a=e.props?.reviews;if(!Array.isArray(a)||a.length===0){const w=document.createElement("div");return w.className="gengage-chat-review-empty",w.textContent=t?.emptyReviewsMessage??"No review summary found.",n.appendChild(w),n}const i=a.filter(w=>w!==null&&typeof w=="object"),o={all:i.length,positive:0,negative:0,neutral:0};for(const w of i)w.review_class==="positive"?o.positive++:w.review_class==="negative"?o.negative++:o.neutral++;const r=new Map;for(const w of i)if(typeof w.review_tag=="string"&&w.review_tag.length>0){const E=r.get(w.review_tag);E?E.count++:r.set(w.review_tag,{count:1,sentiment:w.review_class??"neutral"})}const s=r.size>0?r.keys().next().value:null;let c="all",l=s;const g=document.createElement("div");g.className="gengage-chat-review-tabs";const p=t?.reviewFilterAll??"All",d=t?.reviewFilterPositive??"Positive",h=t?.reviewFilterNegative??"Negative",u=[{label:`${p} (${o.all})`,filter:"all"}];o.positive>0&&u.push({label:`${d} (${o.positive})`,filter:"positive"}),o.negative>0&&u.push({label:`${h} (${o.negative})`,filter:"negative"});const b=document.createElement("div");b.className="gengage-chat-review-items";function y(){for(;b.firstChild;)b.removeChild(b.firstChild);const w=i.filter(E=>{const A=c==="all"||E.review_class===c,f=l===null||E.review_tag===l;return A&&f});for(const E of w){const A=document.createElement("article");A.className="gengage-chat-review-item";const f=E.review_class;if((f==="positive"||f==="negative"||f==="neutral")&&(A.dataset.tone=f),typeof E.review_tag=="string"&&E.review_tag.length>0){const C=document.createElement("div");C.className="gengage-chat-review-tag",C.textContent=E.review_tag,A.appendChild(C)}if(typeof E.review_text=="string"&&E.review_text.length>0){const C=document.createElement("div");C.className="gengage-chat-review-text",C.textContent=E.review_text,A.appendChild(C)}if(E.review_rating!==void 0&&String(E.review_rating).length>0){const C=document.createElement("div");C.className="gengage-chat-review-rating",C.textContent=String(E.review_rating),A.appendChild(C)}b.appendChild(A)}}for(const w of u){const E=document.createElement("button");E.className="gengage-chat-review-tab",E.type="button",E.textContent=w.label,w.filter===c&&E.classList.add("gengage-chat-review-tab--active"),E.addEventListener("click",()=>{c=w.filter;for(const A of g.querySelectorAll(".gengage-chat-review-tab"))A.classList.toggle("gengage-chat-review-tab--active",A===E);y()}),g.appendChild(E)}if(n.appendChild(g),r.size>0){const w=document.createElement("div");w.className="gengage-chat-review-pills";for(const[E,A]of r){const f=document.createElement("button");f.type="button",f.className="gengage-chat-review-pill",f.dataset.tone=A.sentiment,f.dataset.tag=E,E===l&&f.classList.add("gengage-chat-review-pill--active");const C=document.createElement("span");C.className="gengage-chat-review-pill-icon",C.textContent=A.sentiment==="positive"?"✓":A.sentiment==="negative"?"✕":"●",f.appendChild(C);const U=document.createElement("span");if(U.textContent=E,f.appendChild(U),A.count>1){const R=document.createElement("span");R.className="gengage-chat-review-pill-count",R.textContent=String(A.count),f.appendChild(R)}f.addEventListener("click",()=>{l=l===E?null:E;for(const R of w.querySelectorAll(".gengage-chat-review-pill")){const k=l!==null&&R.dataset.tag===l;R.classList.toggle("gengage-chat-review-pill--active",k)}y()}),w.appendChild(f)}n.appendChild(w)}return y(),n.appendChild(b),n}function fn(e){return Number.isFinite(e)?Math.max(0,Math.min(5,e)):0}function mn(e){return Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function bn(e){const t=fn(e),n=Math.floor(t),a=t-n>=.5,i=5-n-(a?1:0),o=document.createElement("span");if(o.className="gengage-star-rating",o.setAttribute("role","img"),o.setAttribute("aria-label",`${t.toFixed(1)} out of 5 stars`),n>0&&o.appendChild(document.createTextNode("★".repeat(n))),a){const r=document.createElement("span");r.className="gengage-star-half",r.textContent="☆";const s=document.createElement("span");s.textContent="★",r.appendChild(s),o.appendChild(r)}return i>0&&o.appendChild(document.createTextNode("☆".repeat(i))),o}function Be(e){e.addEventListener("error",()=>{e.style.display="none"},{once:!0})}function tr(e){const t=e.product.sku;if(typeof t=="string"&&t.length>0)return t;const n=e.action?.payload;return n&&typeof n=="object"&&"sku"in n&&typeof n.sku=="string"?n.sku:null}const nr={winner:"roleWinner",best_value:"roleBestValue",best_alternative:"roleBestAlternative"};function _n(e,t){if(!e||!t)return null;const n=nr[e];return n?t[n]??e:e}function ar(e){const t=e.rating,n=typeof t=="number"?t:typeof t=="string"?parseFloat(t):NaN;if(Number.isNaN(n))return null;const a=document.createElement("div");return a.className="gengage-chat-ai-toppick-rating",a.textContent=`★ ${n.toFixed(1)}`,a}function ir(e,t,n){const a=document.createElement("div");a.className="gengage-chat-ai-toppick-media";const i=e.discountPercent;if(typeof i=="number"&&i>0){const r=document.createElement("span");r.className="gengage-chat-ai-toppick-discount-badge",r.textContent=`%${mn(i)}`,a.appendChild(r)}const o=e.imageUrl;if(o&&Se(o)){const r=document.createElement("img");r.className="gengage-chat-ai-toppick-img",ae(r,"src",o),r.loading="lazy",r.alt=t,Be(r),a.appendChild(r)}n.appendChild(a)}function or(e,t,n){const a=e.price,i=e.originalPrice;if(!a)return;const o=document.createElement("div");if(o.className="gengage-chat-ai-toppick-price",i&&i!==a){const s=document.createElement("span");s.className="gengage-chat-ai-toppick-original-price",s.textContent=ge(i,n.pricing),o.appendChild(s),o.appendChild(document.createTextNode(" "))}const r=document.createElement("span");r.textContent=ge(a,n.pricing),o.appendChild(r),t.appendChild(o)}function rr(e,t,n){const a=document.createElement("div");a.className=n?"gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--winner":"gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--compact";const i=e.product,o=i.name||"Product image",r=n?_n(e.role,t.i18n)??t.i18n?.roleWinner??"TOP MATCH":_n(e.role,t.i18n);if(r){const g=document.createElement("span");g.className="gengage-chat-ai-toppick-badge",g.textContent=r,a.appendChild(g)}ir(i,o,a);const s=document.createElement("div");s.className="gengage-chat-ai-toppick-body";const c=i.name;if(c){const g=document.createElement("div");g.className="gengage-chat-ai-toppick-name",g.textContent=c,s.appendChild(g)}const l=ar(i);if(l&&s.appendChild(l),or(i,s,t),e.reason){const g=document.createElement("div");g.className="gengage-chat-ai-toppick-reason",g.textContent=e.reason,s.appendChild(g)}if(e.labels&&e.labels.length>0&&s.appendChild(cr(e.labels)),n&&typeof e.expertQualityScore=="number"){const g=document.createElement("div");g.className="gengage-chat-ai-toppick-score";let p=e.expertQualityScore,d=10;p>10?p=Math.round(p)/10:p<=5&&(d=5),g.textContent=`${p}/${d}`,s.appendChild(g)}if(n&&e.reviewHighlight){const g=document.createElement("blockquote");g.className="gengage-chat-ai-toppick-review",g.textContent=e.reviewHighlight,s.appendChild(g)}if(a.appendChild(s),e.action){const g=tr(e),p=i.url??"",d=document.createElement("div");d.className="gengage-chat-ai-toppick-spinner",d.style.display=g&&t.topPicksLoadingSku===g?"":"none",a.appendChild(d);const h=document.createElement("button");h.className="gengage-chat-ai-toppick-cta",h.type="button",h.textContent=t.i18n?.viewDetails??"View Details",h.addEventListener("click",()=>{if(e.action?.type==="findSimilar"&&g&&t.onProductClick){t.onProductClick({sku:g,url:p});return}t.onAction(e.action)}),a.appendChild(h)}return a}function sr(e,t){const n=document.createElement("div");n.className="gengage-chat-ai-top-picks";const a=e.props?.suggestions??[];if(a.length===0)return n;const i=document.createElement("h3");i.className="gengage-chat-ai-top-picks-title",i.textContent=t.i18n?.aiTopPicksTitle??"Top Picks",n.appendChild(i);const o=document.createElement("div");o.className="gengage-chat-ai-top-picks-scroll";for(let r=0;r<a.length;r++){const s=a[r],c=s.role==="winner"||r===0;o.appendChild(rr(s,t,c))}return n.appendChild(o),n}function cr(e){const t=document.createElement("div");t.className="gengage-chat-ai-toppick-labels";for(const n of e){const a=document.createElement("span");a.className="gengage-chat-ai-toppick-label",a.dataset.sentiment=n.sentiment??"neutral",a.textContent=n.label,t.appendChild(a)}return t}function lr(e,t){const n=document.createElement("div");n.className="gengage-chat-grounding-review";const a=e.props??{},i=a.title,o=a.reviewCount,r=a.action,s=t.i18n?.groundingReviewCta??"Read Reviews",c=document.createElement("span");c.className="gengage-chat-grounding-review-icon",c.textContent="📋",n.appendChild(c);const l=document.createElement("div");l.className="gengage-chat-grounding-review-body";const g=document.createElement("div");if(g.className="gengage-chat-grounding-review-title",g.textContent=i??t.i18n?.customerReviewsTitle??"Customer Reviews",l.appendChild(g),o){const d=document.createElement("div");d.className="gengage-chat-grounding-review-subtitle";const h=t.i18n?.groundingReviewSubtitle??"{count} yorum mevcut";d.textContent=h.replace("{count}",o),l.appendChild(d)}n.appendChild(l);const p=document.createElement("span");return p.className="gengage-chat-grounding-review-cta",p.textContent=`${s} →`,n.appendChild(p),r&&(n.style.cursor="pointer",n.setAttribute("role","button"),n.setAttribute("tabindex","0"),n.addEventListener("click",()=>t.onAction(r)),n.addEventListener("keydown",d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),t.onAction(r))})),n}function gr(e){if(e.action.type!=="findSimilar")return e.action;const t=e.action.payload&&typeof e.action.payload=="object"?e.action.payload:null,n=typeof t?.input=="string"&&t.input.trim()||typeof t?.text=="string"&&t.text.trim()||e.name.trim();if(!n)return e.action;const a={text:n,is_suggested_text:1};if(typeof t?.sku=="string"&&t.sku.trim()&&(a.sku=t.sku),Array.isArray(t?.group_skus)){const i=t.group_skus.filter(o=>typeof o=="string"&&o.length>0);i.length>0&&(a.group_skus=i)}return{title:e.action.title,type:"inputText",payload:a}}function dr(e,t){const n=document.createElement("div");n.className="gengage-chat-grouping-cards";const a=e.props?.entries??[];if(a.length===0)return n;const i=e.props?.sectionTitle,o=typeof i=="string"&&i.trim().length>0?i.trim():t.i18n?.aiBrowseCategoriesTitle;if(o){const s=document.createElement("h3");s.className="gengage-chat-grouping-section-title",s.textContent=o,n.appendChild(s)}const r=document.createElement("div");r.className="gengage-chat-grouping-cards-scroll";for(const s of a){const c=document.createElement("div");if(c.className="gengage-chat-grouping-card",c.style.cursor="pointer",c.addEventListener("click",()=>t.onAction(gr(s))),s.image&&Se(s.image)){const d=document.createElement("img");d.className="gengage-chat-grouping-card-img",d.src=s.image,d.alt=s.name,d.width=64,d.height=64,c.appendChild(d)}const l=document.createElement("div");l.className="gengage-chat-grouping-card-body";const g=document.createElement("span");if(g.className="gengage-chat-grouping-card-name",g.textContent=s.name,l.appendChild(g),s.description){const d=document.createElement("span");d.className="gengage-chat-grouping-card-desc",d.textContent=s.description,l.appendChild(d)}if(s.labels&&s.labels.length>0){const d=document.createElement("span");d.className="gengage-chat-grouping-card-labels",d.textContent=s.labels.slice(0,3).join(" · "),l.appendChild(d)}c.appendChild(l);const p=document.createElement("span");p.className="gengage-chat-grouping-card-arrow",p.textContent="↳",c.insertBefore(p,c.firstChild),r.appendChild(c)}return n.appendChild(r),n}function pr(e,t){const n=document.createElement("div");n.className="gengage-chat-suggested-search-cards";const a=e.props?.entries??[];if(a.length===0)return n;for(const i of a){const o=document.createElement("div");if(o.className="gengage-chat-suggested-search-card",o.style.cursor="pointer",o.addEventListener("click",()=>t.onAction(i.action)),i.image&&Se(i.image)){const c=document.createElement("img");c.className="gengage-chat-suggested-search-card-img",c.src=i.image,c.alt=i.shortName,c.width=40,c.height=40,o.appendChild(c)}const r=document.createElement("div");r.className="gengage-chat-suggested-search-card-body";const s=document.createElement("div");if(s.className="gengage-chat-suggested-search-card-name",s.textContent=i.shortName,r.appendChild(s),i.detailedMessage){const c=document.createElement("div");c.className="gengage-chat-suggested-search-card-desc",c.textContent=i.detailedMessage,r.appendChild(c)}if(i.whyDifferent){const c=document.createElement("div");c.className="gengage-chat-suggested-search-card-diff",c.textContent=i.whyDifferent,r.appendChild(c)}o.appendChild(r),n.appendChild(o)}return n}function hr(e,t){const n=document.createElement("button");n.className="gengage-chat-comparison-floating-btn",n.type="button";const a=t.i18n?.compareSelected??"Compare";return n.textContent=`${a} (${e.length})`,n.addEventListener("click",()=>{t.onAction({title:a,type:"getComparisonTable",payload:{sku_list:[...e]}})}),n}function ur(e){const t=document.createElement("div");t.className="gengage-chat-pros-cons";const n=e.props?.productName;if(n){const o=document.createElement("h4");o.className="gengage-chat-pros-cons-heading",o.textContent=n,t.appendChild(o)}const a=e.props?.pros,i=e.props?.cons;if(a&&a.length>0){const o=document.createElement("ul");o.className="gengage-chat-pros-cons-list";for(const r of a){const s=document.createElement("li");s.className="gengage-chat-pros-cons-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=r,s.appendChild(l),o.appendChild(s)}t.appendChild(o)}if(i&&i.length>0){const o=document.createElement("ul");o.className="gengage-chat-pros-cons-list";for(const r of i){const s=document.createElement("li");s.className="gengage-chat-pros-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=r,s.appendChild(l),o.appendChild(s)}t.appendChild(o)}return t}function fr(e,t){const n=e.props?.groups??[],a=e.props?.filterTags??[],i=document.createElement("div");if(i.className="gengage-chat-categories",n.length===0)return i;const o=document.createElement("div");o.className="gengage-chat-categories-tabs",o.setAttribute("role","tablist");const r=[],s=[],c=l=>{for(let g=0;g<r.length;g++){const p=g===l;r[g].classList.toggle("gengage-chat-categories-tab--active",p),r[g].setAttribute("aria-selected",String(p)),r[g].tabIndex=p?0:-1,s[g].style.display=p?"":"none"}};for(let l=0;l<n.length;l++){const g=n[l],p=`gengage-cat-tab-${l}`,d=`gengage-cat-panel-${l}`,h=document.createElement("button");h.className="gengage-chat-categories-tab",h.type="button",h.id=p,h.setAttribute("role","tab"),h.setAttribute("aria-controls",d),h.setAttribute("aria-selected",String(l===0)),h.tabIndex=l===0?0:-1,l===0&&h.classList.add("gengage-chat-categories-tab--active"),h.textContent=g.groupName,h.addEventListener("click",()=>c(l)),h.addEventListener("keydown",b=>{let y=-1;b.key==="ArrowRight"||b.key==="ArrowDown"?y=(l+1)%n.length:b.key==="ArrowLeft"||b.key==="ArrowUp"?y=(l-1+n.length)%n.length:b.key==="Home"?y=0:b.key==="End"&&(y=n.length-1),y>=0&&(b.preventDefault(),c(y),r[y].focus())}),r.push(h),o.appendChild(h);const u=document.createElement("div");u.className="gengage-chat-categories-grid",u.id=d,u.setAttribute("role","tabpanel"),u.setAttribute("aria-labelledby",p),l!==0&&(u.style.display="none");for(const b of g.products){const y=mr(b,t);u.appendChild(y)}s.push(u)}i.appendChild(o);for(const l of s)i.appendChild(l);if(a.length>0){const l=document.createElement("div");l.className="gengage-chat-categories-filter-tags";for(const g of a){const p=document.createElement("button");p.className="gengage-chat-categories-filter-tag",p.type="button",p.textContent=g.title,g.action&&p.addEventListener("click",()=>{t.onAction(g.action)}),l.appendChild(p)}i.appendChild(l)}return i}function mr(e,t){const n=document.createElement("div");if(n.className="gengage-chat-product-card",e.imageUrl&&Se(e.imageUrl)){const o=document.createElement("img");o.className="gengage-chat-product-card-img",o.src=e.imageUrl,o.alt=e.name,o.loading="lazy",Be(o),n.appendChild(o)}const a=document.createElement("div");a.className="gengage-chat-product-card-body";const i=document.createElement("div");if(i.className="gengage-chat-product-card-name",i.textContent=e.name,a.appendChild(i),e.price){const o=document.createElement("div");o.className="gengage-chat-product-card-price",o.textContent=ge(e.price,t.pricing),a.appendChild(o)}return n.appendChild(a),t.onProductSelect&&(n.style.cursor="pointer",n.addEventListener("click",()=>{t.onProductSelect?.(e)})),n}function br(e,t){const n=document.createElement("div");n.className="gengage-chat-handoff-notice",n.setAttribute("role","alert");const a=document.createElement("span");a.className="gengage-chat-handoff-notice-icon",a.textContent="👤",a.setAttribute("aria-hidden","true"),n.appendChild(a);const i=document.createElement("h4");i.className="gengage-chat-handoff-notice-heading",i.textContent=t.i18n?.handoffHeading??"Transferring to a support agent",n.appendChild(i);const o=e.props?.summary;if(o){const r=document.createElement("p");r.className="gengage-chat-handoff-notice-summary",r.textContent=o,n.appendChild(r)}return n}function _r(e,t){const n=e.props?.product??e.props,a=document.createElement("div");if(a.className="gengage-chat-product-summary",!n)return a;a.style.cursor="pointer",a.addEventListener("click",h=>{h.target.closest("a")||t.onProductSelect?.(n)});const i=n.imageUrl;if(i&&le(i)){const h=document.createElement("div");h.className="gengage-chat-product-summary__image";const u=document.createElement("img");u.loading="lazy",ae(u,"src",i);const b=n.name;u.alt=b||"Product image",Be(u),h.appendChild(u),a.appendChild(h)}const o=document.createElement("div");o.className="gengage-chat-product-summary__content";const r=n.brand,s=n.name;if(s){const h=document.createElement("div");h.className="gengage-chat-product-summary__name";const b=r&&!s.toLowerCase().startsWith(r.toLowerCase())?`${r} ${s}`:s;h.textContent=b,h.title=b,o.appendChild(h)}const c=n.rating,l=n.reviewCount;if(typeof c=="number"&&Number.isFinite(c)&&c>0){const h=document.createElement("div");if(h.className="gengage-chat-product-summary__rating",h.appendChild(bn(c)),typeof l=="number"&&Number.isFinite(l)){const u=document.createElement("span");u.className="gengage-chat-product-summary__review-count",u.textContent=` (${l})`,h.appendChild(u)}o.appendChild(h)}const g=n.price,p=n.originalPrice;if(g){const h=document.createElement("div");if(h.className="gengage-chat-product-summary__price",p&&p!==g){const b=document.createElement("span");b.className="gengage-chat-product-summary__price-original",b.textContent=ge(p,t.pricing),h.appendChild(b),h.appendChild(document.createTextNode(" "))}const u=document.createElement("span");u.className="gengage-chat-product-summary__price-current",u.textContent=ge(g,t.pricing),h.appendChild(u),o.appendChild(h)}a.appendChild(o);const d=n.url;if(d&&le(d)){const h=document.createElement("a");h.className="gengage-chat-product-summary__cta",ae(h,"href",d),ae(h,"target","_blank"),ae(h,"rel","noopener noreferrer"),h.textContent=t.i18n?.productCtaLabel??"View",a.appendChild(h)}return a}function vn(e){const t=e.min??1,n=e.max??99,a=Math.min(t,n),i=Math.max(t,n),o=Math.max(a,Math.min(i,e.initial??a)),r=e.compact??!1;let s=o;const c=document.createElement("div");c.className=`gengage-qty-stepper${r?" gengage-qty-stepper--compact":""}`;const l=document.createElement("button");l.className="gengage-qty-btn",l.type="button",l.textContent=e.decreaseSymbol??"−",l.setAttribute("aria-label",e.decreaseLabel??"Decrease");const g=document.createElement("span");g.className="gengage-qty-value",g.textContent=String(s),g.setAttribute("aria-live","polite"),g.setAttribute("aria-atomic","true");const p=document.createElement("button");p.className="gengage-qty-btn",p.type="button",p.textContent=e.increaseSymbol??"+",p.setAttribute("aria-label",e.increaseLabel??"Increase");const d=document.createElement("button");d.className="gengage-qty-submit",d.type="button";const h='<svg width="16" height="16" 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>';r?(d.innerHTML=e.submitIcon??h,d.title=e.label??"Add to Cart"):d.textContent=e.label??"Add to Cart";function u(){l.disabled=s<=a,p.disabled=s>=i}return l.addEventListener("click",b=>{b.stopPropagation(),s>a&&(s--,g.textContent=String(s),u())}),p.addEventListener("click",b=>{b.stopPropagation(),s<i&&(s++,g.textContent=String(s),u())}),d.addEventListener("click",b=>{b.stopPropagation(),e.onSubmit(s);const y=d.innerHTML;d.textContent="✓",d.classList.add("gengage-qty-submit--success"),d.disabled=!0,setTimeout(()=>{d.innerHTML=y,d.classList.remove("gengage-qty-submit--success"),d.disabled=!1},1200)}),c.addEventListener("click",b=>{b.stopPropagation()}),u(),c.appendChild(l),c.appendChild(g),c.appendChild(p),c.appendChild(d),c}function yn(){return window.innerWidth<768}const wn={ActionButtons:({element:e,context:t})=>vr(e,t),ActionButton:({element:e,context:t})=>yr(e,t),ProductCard:({element:e,context:t})=>wr(e,t),ProductDetailsPanel:({element:e,context:t})=>xr(e,t),ProductGrid:({element:e,spec:t,renderElement:n,context:a})=>Er(e,t,n,a),ReviewHighlights:({element:e,context:t})=>er(e,{emptyReviewsMessage:t.i18n?.emptyReviewsMessage,reviewFilterAll:t.i18n?.reviewFilterAll,reviewFilterPositive:t.i18n?.reviewFilterPositive,reviewFilterNegative:t.i18n?.reviewFilterNegative}),ComparisonTable:({element:e,context:t})=>Sr(e,t),AITopPicks:({element:e,context:t})=>sr(e,t),GroundingReviewCard:({element:e,context:t})=>lr(e,t),AIGroupingCards:({element:e,context:t})=>dr(e,t),AISuggestedSearchCards:({element:e,context:t})=>pr(e,t),ProsAndCons:({element:e})=>ur(e),CategoriesContainer:({element:e,context:t})=>fr(e,t),HandoffNotice:({element:e,context:t})=>br(e,t),ProductSummaryCard:({element:e,context:t})=>_r(e,t),Divider:({element:e})=>Tr(e)},St=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const a of e.children){const i=t(a);i&&n.appendChild(i)}return n};function xn(){return{...wn}}function kn(e,t,n=wn,a=St){return Ra({spec:e,context:t,registry:n,containerClassName:"gengage-chat-uispec",unknownRenderer:a})}function vr(e,t){const n=document.createElement("div");n.className="gengage-chat-action-buttons";const a=e.props?.buttons;if(a)for(const i of a){const o=document.createElement("button");o.className="gengage-chat-action-btn",o.textContent=i.label,o.addEventListener("click",()=>t.onAction(i.action)),n.appendChild(o)}return n}function yr(e,t){const n=document.createElement("button");n.className="gengage-chat-action-btn";const a=e.props?.label;typeof a=="string"&&(n.textContent=a);const i=e.props?.action;return i&&n.addEventListener("click",()=>t.onAction(i)),n}function wr(e,t){const n=document.createElement("div");n.className="gengage-chat-product-card";const a=e.props?.product??e.props;if(!a)return n;const i=a.sku;i&&(n.dataset.sku=i),t.onProductSelect&&(n.style.cursor="pointer",n.addEventListener("click",f=>{n.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")||f.target.closest(".gengage-chat-product-card-atc")||f.target.closest(".gengage-chat-product-card-cta")||t.onProductSelect?.(a)}));const o=a.imageUrl;if(o&&le(o)){const f=document.createElement("div");f.className="gengage-chat-product-card-img-wrapper";const C=document.createElement("img");C.className="gengage-chat-product-card-img",C.loading="lazy",ae(C,"src",o);const U=a.name;U&&(C.alt=U),Be(C),f.appendChild(C);const R=a.discountPercent;if(typeof R=="number"&&R>0){const S=document.createElement("span");S.className="gengage-chat-product-card-discount-badge",S.textContent=`%${mn(R)}`,f.appendChild(S)}const k=a.sku;if(k){const S=document.createElement("button");S.className="gengage-chat-find-similar-pill",S.type="button",S.textContent=t.i18n?.findSimilarLabel??"Find Similar",S.addEventListener("click",B=>{B.stopPropagation(),t.onAction({title:t.i18n?.findSimilarLabel??"Find Similar",type:"findSimilar",payload:{sku:k,...o?{image_url:o}:{}}})}),f.appendChild(S)}const I=a.sku;if(I&&t.onFavoriteToggle){const S=document.createElement("button");S.className="gengage-chat-favorite-btn",S.type="button",S.setAttribute("aria-label",t.i18n?.addToFavoritesLabel??"Add to favorites");const B=t.favoritedSkus?.has(I)??!1;B&&S.classList.add("gengage-chat-favorite-btn--active");const ne=B?"currentColor":"none";S.innerHTML=`<svg width="16" height="16" viewBox="0 0 24 24" fill="${ne}" 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>`,S.addEventListener("click",F=>{F.stopPropagation(),S.classList.toggle("gengage-chat-favorite-btn--active");const _=S.querySelector("svg");_&&_.setAttribute("fill",S.classList.contains("gengage-chat-favorite-btn--active")?"currentColor":"none"),t.onFavoriteToggle(I,a)}),f.appendChild(S)}n.appendChild(f)}const r=document.createElement("div");r.className="gengage-chat-product-card-body";const s=a.brand;if(s){const f=document.createElement("div");f.className="gengage-chat-product-card-brand",f.textContent=s,r.appendChild(f)}const c=a.name;if(c){const f=document.createElement("div");f.className="gengage-chat-product-card-name",f.textContent=c,f.title=c,r.appendChild(f)}const l=a.rating,g=a.reviewCount;if(typeof l=="number"&&Number.isFinite(l)&&l>0){const f=document.createElement("div");if(f.className="gengage-chat-product-card-rating",f.appendChild(bn(l)),typeof g=="number"&&Number.isFinite(g)){const C=document.createElement("span");C.className="gengage-chat-product-card-review-count",C.textContent=` (${g})`,f.appendChild(C)}r.appendChild(f)}const p=a.price,d=a.originalPrice;if(a.price_async===!0){const f=document.createElement("div");f.className="gengage-chat-product-card-price";const C=document.createElement("span");C.className="gengage-chat-price-skeleton",f.appendChild(C),r.appendChild(f),setTimeout(()=>{C.parentElement&&(p&&parseFloat(p)>0?C.replaceWith(document.createTextNode(ge(p,t.pricing))):C.remove())},300)}else if(p&&parseFloat(p)>0){const f=document.createElement("div");if(f.className="gengage-chat-product-card-price",d&&d!==p){const U=document.createElement("span");U.className="gengage-chat-product-card-original-price",U.textContent=ge(d,t.pricing),f.appendChild(U),f.appendChild(document.createTextNode(" "))}const C=document.createElement("span");C.textContent=ge(p,t.pricing),f.appendChild(C),r.appendChild(f)}const u=a.inStock;if(typeof u=="boolean"){const f=document.createElement("div");f.className=`gengage-chat-product-card-stock ${u?"is-in-stock":"is-out-of-stock"}`,f.textContent=u?t.i18n?.inStockLabel??"In Stock":t.i18n?.outOfStockLabel??"Out of Stock",r.appendChild(f)}const b=a.promotions;if(b&&b.length>0){const f=document.createElement("div");f.className="gengage-chat-product-card-promos";for(const C of b.slice(0,3)){if(!C||/%(0(\.0+)?)\s/.test(C))continue;const U=document.createElement("span");U.className="gengage-chat-product-card-promo-badge",U.textContent=C,U.title=C,f.appendChild(U)}f.childElementCount>0&&r.appendChild(f)}n.appendChild(r);const y=a.url,w=a.sku,E=e.props?.action;if(E){const f=document.createElement("button");f.className="gengage-chat-product-card-cta",f.type="button",f.textContent=E.title||t.i18n?.productCtaLabel||"View",f.addEventListener("click",C=>{if(n.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){C.stopPropagation();return}t.onAction(E)}),n.appendChild(f)}else if(y&&le(y)){const f=document.createElement("a");f.className="gengage-chat-product-card-cta",ae(f,"href",y),ae(f,"target","_blank"),ae(f,"rel","noopener noreferrer"),f.textContent=t.i18n?.productCtaLabel??"View",f.addEventListener("click",C=>{if(n.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){C.preventDefault(),C.stopPropagation();return}t.onProductClick&&w&&(C.preventDefault(),t.onProductClick({sku:w,url:y}))}),n.appendChild(f)}const A=a.cartCode;if(A&&w&&u!==!1){const f=vn({compact:!0,label:t.i18n?.addToCartButton??"Add to Cart",decreaseLabel:t.i18n?.decreaseLabel,increaseLabel:t.i18n?.increaseLabel,onSubmit:C=>{t.onAction({title:t.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:w,cartCode:A,quantity:C}})}});f.classList.add("gengage-chat-product-card-atc"),n.appendChild(f)}if(t.comparisonSelectMode&&w&&t.onToggleComparisonSku){const f=document.createElement("div");f.className="gengage-chat-comparison-select-wrapper";const C=document.createElement("input");return C.type="checkbox",C.className="gengage-chat-comparison-checkbox",C.checked=t.comparisonSelectedSkus?.includes(w)??!1,C.addEventListener("change",()=>{t.onToggleComparisonSku?.(w)}),f.addEventListener("click",U=>{U.target.closest(".gengage-chat-comparison-checkbox")||(U.stopPropagation(),t.onToggleComparisonSku?.(w))}),f.appendChild(C),f.appendChild(n),f}return n}function xr(e,t){const n=document.createElement("article");n.className="gengage-chat-product-details-panel";const a=e.props?.product??e.props;if(!a)return n;const i=a.images,o=a.imageUrl,r=a.sku;if(i&&i.length>1){const k=document.createElement("div");k.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";const S=i.find(N=>le(N));S&&ae(I,"src",S);const B=a.name;B&&(I.alt=B),Be(I),k.appendChild(I);const ne=document.createElement("div");ne.className="gengage-chat-product-gallery-thumbs";const F=6,_=i.filter(N=>!!N&&le(N));let L=null,P=0;for(let N=0;N<_.length;N++){const G=_[N];if(N>=F)break;const W=document.createElement("img");W.className="gengage-chat-product-gallery-thumb",N===0&&(W.classList.add("gengage-chat-product-gallery-thumb--active"),L=W),ae(W,"src",G),W.alt=`${B??"Product"} ${N+1}`,W.width=48,W.height=48,Be(W),W.addEventListener("click",()=>{ae(I,"src",G),L&&L.classList.remove("gengage-chat-product-gallery-thumb--active"),W.classList.add("gengage-chat-product-gallery-thumb--active"),L=W,P=N}),ne.appendChild(W)}if(_.length>F){const N=document.createElement("span");N.className="gengage-chat-product-gallery-thumb-more",N.textContent=`+${_.length-F}`,ne.appendChild(N)}let T=0;const M=50;if(I.addEventListener("touchstart",N=>{T=N.changedTouches[0].clientX},{passive:!0}),I.addEventListener("touchend",N=>{const G=N.changedTouches[0].clientX,W=T-G;if(Math.abs(W)<M)return;const ce=W>0?Math.min(P+1,_.length-1):Math.max(P-1,0);if(ce!==P){const oe=_[ce];if(oe){ae(I,"src",oe);const ve=ne.querySelectorAll(".gengage-chat-product-gallery-thumb");L&&L.classList.remove("gengage-chat-product-gallery-thumb--active"),ce<F&&ve[ce]?(ve[ce].classList.add("gengage-chat-product-gallery-thumb--active"),L=ve[ce]):L=null,P=ce}}}),k.appendChild(ne),r){const N=document.createElement("button");N.className="gengage-chat-find-similar-pill",N.type="button",N.textContent=t.i18n?.findSimilarLabel??"Find Similar",N.addEventListener("click",()=>{t.onAction({title:t.i18n?.findSimilarLabel??"Find Similar",type:"findSimilar",payload:{sku:r,...S?{image_url:S}:{}}})}),k.appendChild(N)}n.appendChild(k)}else if(o&&le(o)){const k=document.createElement("div");k.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",ae(I,"src",o),Be(I);const S=a.name;if(S&&(I.alt=S),k.appendChild(I),r){const B=document.createElement("button");B.className="gengage-chat-find-similar-pill",B.type="button",B.textContent=t.i18n?.findSimilarLabel??"Find Similar",B.addEventListener("click",()=>{t.onAction({title:t.i18n?.findSimilarLabel??"Find Similar",type:"findSimilar",payload:{sku:r,...o?{image_url:o}:{}}})}),k.appendChild(B)}n.appendChild(k)}const s=document.createElement("div");s.className="gengage-chat-product-details-content";const c=a.name;if(c){const k=document.createElement("h3");k.className="gengage-chat-product-details-title",k.textContent=c,k.title=c,s.appendChild(k)}const l=a.rating,g=a.reviewCount;if(typeof l=="number"&&Number.isFinite(l)&&l>0){const k=document.createElement("div");if(k.className="gengage-chat-product-details-rating",k.textContent=`★ ${fn(l).toFixed(1)}`,typeof g=="number"&&Number.isFinite(g)){const I=document.createElement("span");I.className="gengage-chat-product-details-review-count",I.textContent=` (${g})`,k.appendChild(I)}s.appendChild(k)}const p=a.price,d=a.originalPrice;if(a.price_async===!0){const k=document.createElement("div");k.className="gengage-chat-product-details-price";const I=document.createElement("span");I.className="gengage-chat-price-skeleton",k.appendChild(I),s.appendChild(k),setTimeout(()=>{if(I.parentElement)if(p&&parseFloat(p)>0){const S=document.createElement("span");S.className="gengage-chat-product-details-current-price",S.textContent=ge(p,t.pricing),I.replaceWith(S)}else I.remove()},300)}else if(p&&parseFloat(p)>0){const k=document.createElement("div");if(k.className="gengage-chat-product-details-price",d&&d!==p){const S=document.createElement("span");S.className="gengage-chat-product-details-original-price",S.textContent=ge(d,t.pricing),k.appendChild(S),k.appendChild(document.createTextNode(" "))}const I=document.createElement("span");I.className="gengage-chat-product-details-current-price",I.textContent=ge(p,t.pricing),k.appendChild(I),s.appendChild(k)}const u=a.inStock;if(typeof u=="boolean"){const k=document.createElement("div");k.className=`gengage-chat-product-details-stock ${u?"is-in-stock":"is-out-of-stock"}`,k.textContent=u?t.i18n?.inStockLabel??"In Stock":t.i18n?.outOfStockLabel??"Out of Stock",s.appendChild(k)}const b=a.promotions;if(b&&b.length>0){const k=document.createElement("div");k.className="gengage-chat-product-details-promos";for(const I of b.slice(0,3)){if(!I||/%(0(\.0+)?)\s/.test(I))continue;const S=document.createElement("span");S.className="gengage-chat-product-details-promo-badge",S.textContent=I,S.title=I,k.appendChild(S)}k.childElementCount>0&&s.appendChild(k)}const y=a.variants;if(y&&y.length>0){const k=document.createElement("div");k.className="gengage-chat-product-variants";const I=document.createElement("div");I.className="gengage-chat-product-variants-label",I.textContent=t.i18n?.variantsLabel??"Variants",k.appendChild(I);const S=document.createElement("div");S.className="gengage-chat-product-variants-list";for(const B of y){const F=B.value??B.name??B.variant_name,_=B.sku;if(!F&&!_)continue;const L=document.createElement("button");L.className="gengage-chat-product-variant-btn",L.type="button";const P=F??_??"",T=B.price;T&&String(T)!==String(p)?L.textContent=`${P} - ${ge(String(T),t.pricing)}`:L.textContent=P,_&&L.addEventListener("click",()=>{t.onAction({title:P,type:"launchVariant",payload:{sku:_}})}),S.appendChild(L)}k.appendChild(S),s.appendChild(k)}const w=a.sku,E=a.cartCode,A=document.createElement("div");A.className="gengage-chat-product-details-actions";const f=e.props?.action;if(f){const k=document.createElement("button");k.className="gengage-chat-product-details-cta",k.type="button",k.textContent=f.title||t.i18n?.productCtaLabel||"View",k.addEventListener("click",()=>t.onAction(f)),A.appendChild(k)}else{const k=a.url;if(k&&le(k)){const I=document.createElement("a");I.className="gengage-chat-product-details-cta",ae(I,"href",k),ae(I,"target","_blank"),ae(I,"rel","noopener noreferrer"),I.textContent=t.i18n?.productCtaLabel??"View",I.addEventListener("click",S=>{t.onProductClick&&w&&(S.preventDefault(),t.onProductClick({sku:w,url:k}))}),A.appendChild(I)}}if(E&&w&&u!==!1){const k=vn({compact:!1,label:t.i18n?.addToCartButton??"Add to Cart",decreaseLabel:t.i18n?.decreaseLabel,increaseLabel:t.i18n?.increaseLabel,onSubmit:I=>{t.onAction({title:t.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:w,cartCode:E,quantity:I}})}});k.classList.add("gengage-chat-product-details-atc-stepper"),A.appendChild(k)}const C=a.url;if(C&&le(C)){let k=function(_,L){const P=document.createElementNS(ne,"circle");P.setAttribute("cx",_),P.setAttribute("cy",L),P.setAttribute("r","3"),F.appendChild(P)},I=function(_,L,P,T){const M=document.createElementNS(ne,"line");M.setAttribute("x1",_),M.setAttribute("y1",L),M.setAttribute("x2",P),M.setAttribute("y2",T),F.appendChild(M)};const S=document.createElement("button");S.className="gengage-chat-product-details-share",S.type="button";const B=t.i18n?.shareButton??"Share";S.title=B,S.setAttribute("aria-label",B);const ne="http://www.w3.org/2000/svg",F=document.createElementNS(ne,"svg");F.setAttribute("width","18"),F.setAttribute("height","18"),F.setAttribute("viewBox","0 0 24 24"),F.setAttribute("fill","none"),F.setAttribute("stroke","currentColor"),F.setAttribute("stroke-width","2"),F.setAttribute("stroke-linecap","round"),F.setAttribute("stroke-linejoin","round"),k("18","5"),k("6","12"),k("18","19"),I("8.59","13.51","15.42","17.49"),I("15.41","6.51","8.59","10.49"),S.appendChild(F),S.addEventListener("click",async()=>{const _=a.name;try{navigator.share?await navigator.share({title:_??"",url:C}):navigator.clipboard&&(await navigator.clipboard.writeText(C),S.classList.add("gengage-chat-product-details-share--copied"),setTimeout(()=>S.classList.remove("gengage-chat-product-details-share--copied"),1500))}catch{}}),A.appendChild(S)}A.childElementCount>0&&s.appendChild(A),n.appendChild(s);const U=a.description,R=a.specifications;return(U||R)&&n.appendChild(kr(U,R,t)),n}function kr(e,t,n){const a=document.createElement("div");a.className="gengage-chat-product-detail-tabs";const i=document.createElement("div");i.className="gengage-chat-product-detail-tab-bar";const o=[];if(e){const s=document.createElement("button");s.className="gengage-chat-product-detail-tab gengage-chat-product-detail-tab--active",s.type="button",s.textContent=n.i18n?.productInfoTab??"Product Info",i.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-product-detail-tab-panel",c.textContent=e,o.push(c)}if(t){const s=document.createElement("button");s.className=`gengage-chat-product-detail-tab${e?"":" gengage-chat-product-detail-tab--active"}`,s.type="button",s.textContent=n.i18n?.specificationsTab??"Specifications",i.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-product-detail-tab-panel",e&&(c.style.display="none");const l=document.createElement("table");l.className="gengage-chat-product-specs-table";const g=Array.isArray(t)?t:Object.entries(t).map(([p,d])=>({key:p,value:d}));for(const p of g){const d=document.createElement("tr"),h=document.createElement("td");h.className="gengage-chat-product-specs-key",h.textContent=p.key;const u=document.createElement("td");u.className="gengage-chat-product-specs-value",u.textContent=p.value,d.appendChild(h),d.appendChild(u),l.appendChild(d)}c.appendChild(l),o.push(c)}const r=i.querySelectorAll(".gengage-chat-product-detail-tab");r.forEach((s,c)=>{s.addEventListener("click",()=>{r.forEach(l=>l.classList.remove("gengage-chat-product-detail-tab--active")),s.classList.add("gengage-chat-product-detail-tab--active"),o.forEach((l,g)=>{l.style.display=g===c?"":"none"})})}),a.appendChild(i);for(const s of o)a.appendChild(s);return a}function Cn(e,t,n){if(!n||n.type==="related")return e;const a=e.map(i=>{const r=t.elements[i]?.props?.product,s=r?Number(r.price):NaN;return{id:i,price:Number.isFinite(s)?s:1/0}});return a.sort((i,o)=>i.price===1/0&&o.price===1/0?0:i.price===1/0?1:o.price===1/0?-1:n.direction==="desc"?o.price-i.price:i.price-o.price),a.map(i=>i.id)}function Cr(e,t,n,a){const i=Cn(t,n,a),o=new Map;for(const r of Array.from(e.children)){const s=r.dataset.elementId;s&&o.set(s,r)}for(const r of i){const s=o.get(r);s&&e.appendChild(s)}}function Er(e,t,n,a){const i=document.createElement("div");i.className="gengage-chat-product-grid-wrapper";const o=e.children??[];if(o.length>1&&a?.onSortChange){const l=document.createElement("div");l.className="gengage-chat-product-sort-toolbar";const g=a.productSort??{type:"related"},p=[{label:a.i18n?.sortRelated??"Related",sortState:{type:"related"}},{label:a.i18n?.sortPriceAsc??"Price ↑",sortState:{type:"price",direction:"asc"}},{label:a.i18n?.sortPriceDesc??"Price ↓",sortState:{type:"price",direction:"desc"}}];for(const d of p){const h=document.createElement("button");h.className="gengage-chat-product-sort-btn",h.type="button",g.type===d.sortState.type&&g.direction===d.sortState.direction&&h.classList.add("gengage-chat-product-sort-btn--active"),h.textContent=d.label,h.addEventListener("click",()=>{a.onSortChange?.(d.sortState),Cr(r,o,t,d.sortState),l.querySelectorAll(".gengage-chat-product-sort-btn").forEach(b=>b.classList.remove("gengage-chat-product-sort-btn--active")),h.classList.add("gengage-chat-product-sort-btn--active")}),l.appendChild(h)}if(a.onToggleComparisonSku){const d=document.createElement("div");d.className="gengage-chat-product-sort-separator",l.appendChild(d);const h=document.createElement("button");h.className="gengage-chat-comparison-toggle-btn",h.type="button",a.comparisonSelectMode&&h.classList.add("gengage-chat-comparison-toggle-btn--active"),a.isStreaming&&h.classList.add("gengage-chat-comparison-toggle-btn--hidden"),h.textContent=a.i18n?.compareSelected??"Compare",h.addEventListener("click",()=>{a.onToggleComparisonSku?.("")}),l.appendChild(h)}i.appendChild(l)}const r=document.createElement("div");r.className="gengage-chat-product-grid";const s=Cn(o,t,a?.productSort);for(const l of s){if(!t.elements[l])continue;const g=n(l);g&&(g.dataset.elementId=l,r.appendChild(g))}if((a?.isMobile??yn())&&r.classList.add("gengage-chat-product-grid--mobile"),i.appendChild(r),e.props?.endOfList!==!0&&o.length>0){const l=document.createElement("button");l.className="gengage-chat-product-grid-view-more",l.type="button",l.textContent=a?.i18n?.viewMoreLabel??"Show More",l.addEventListener("click",()=>{a?.onAction({title:"More",type:"moreProductList",payload:{}})}),i.appendChild(l)}if(a?.comparisonSelectMode&&a.comparisonSelectedSkus&&a.comparisonSelectedSkus.length>=2){const l=hr(a.comparisonSelectedSkus,a);i.appendChild(l)}return i}function Sr(e,t){const n=e.props??{},a=n.keyDifferencesHtml,i=n.recommended,o=n.products??[],r=n.attributes??[],s=n.highlights??[],c=n.specialCases,l=n.recommendedText,g=n.winnerHits,p=n.productActions;if(!i)return document.createElement("div");const d={recommended:i,products:o,attributes:r,highlights:s,specialCases:c,onProductClick:u=>{t.onProductClick?.({sku:u,url:""})},pricing:t.pricing};l!==void 0&&(d.recommendedText=l),g!==void 0&&(d.winnerHits=g),p!==void 0&&(d.productActions=p),a!==void 0&&(d.keyDifferencesHtml=a),t.i18n&&(d.i18n={comparisonHeading:t.i18n.panelTitleComparisonResults,recommendedChoiceLabel:t.i18n.recommendedChoiceLabel,highlightsLabel:t.i18n.highlightsLabel,keyDifferencesLabel:t.i18n.keyDifferencesLabel,specialCasesLabel:t.i18n.specialCasesLabel,addToCartButton:t.i18n.addToCartButton});const h=Yo(d);return(t.isMobile??yn())&&h.classList.add("gengage-chat-comparison--mobile"),h}function Tr(e){const t=document.createElement("hr");t.className="gengage-chat-divider";const n=e.props?.label;if(n){const a=document.createElement("div");a.className="gengage-chat-divider-wrapper";const i=document.createElement("span");return i.className="gengage-chat-divider-label",i.textContent=n,a.appendChild(t),a.appendChild(i),a}return t}const Ar=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","LI","UL","OL","BLOCKQUOTE","PRE","TABLE","SECTION","HR","FIGURE","FIGCAPTION","DL","DT","DD"]);function Ir(e){const t=[];let n=[];for(const a of e)a.nodeType===Node.ELEMENT_NODE&&Ar.has(a.tagName)?(n.length>0&&(t.push(n),n=[]),t.push([a])):n.push(a);return n.length>0&&t.push(n),t}function Pr(e){for(const t of e)for(const n of t)if(n.nodeType===Node.ELEMENT_NODE&&(n.tagName==="TABLE"||n.querySelector?.("table")))return!0;return!1}function Lr(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function zr(e){const{container:t,html:n,delayMs:a=30,onTick:i,onComplete:o}=e,r=document.createElement("template");r.innerHTML=n;const s=Ir(r.content.childNodes);if(Lr()||s.length<=1||Pr(s))return t.innerHTML=n,o?.(),{complete(){},cancel(){},isRunning:!1};t.innerHTML="";let c=0,l=null,g=!0;function p(){if(!g||c>=s.length){g=!1,o?.();return}const d=s[c],h=document.createElement("span");h.className="gengage-chat-typewriter-block";for(const u of d)h.appendChild(u.cloneNode(!0));t.appendChild(h),c++,i?.(),c<s.length?l=setTimeout(p,a):(g=!1,o?.())}return p(),{complete(){g&&(l!==null&&clearTimeout(l),g=!1,t.innerHTML=n,o?.())},cancel(){l!==null&&clearTimeout(l),g=!1},get isRunning(){return g}}}function En(e){return e!==void 0&&/[\p{L}\p{N}_]/u.test(e)}function Nr(e){const{container:t,mentions:n,onProductClick:a}=e;if(n.length===0)return;const i=new Map;for(const o of n)o.short_name.length!==0&&i.set(o.short_name.toLowerCase(),o);if(i.size!==0)for(const[o,r]of i){const s=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);let c=s.nextNode(),l=!1;for(;c&&!l;){const g=c.textContent??"",p=g.toLowerCase().indexOf(o);if(p===-1){c=s.nextNode();continue}const d=p>0?g[p-1]:void 0,h=g[p+r.short_name.length];if(En(d)||En(h)){c=s.nextNode();continue}const u=g.slice(0,p),b=g.slice(p,p+r.short_name.length),y=g.slice(p+r.short_name.length),w=c.parentNode;if(!w){c=s.nextNode();continue}const E=document.createElement("a");E.className="gengage-product-mention",E.textContent=b,E.href="#",E.addEventListener("click",A=>{A.preventDefault(),a(r.sku)}),u&&w.insertBefore(document.createTextNode(u),c),w.insertBefore(E,c),y&&w.insertBefore(document.createTextNode(y),c),w.removeChild(c),l=!0}}}const Mr=new Set(["search","info","review","similar"]),Br=new Set(["quickAnswer","reviewSummary","searchDiscovery","launchDiscovery","exploreTogetherV2"]);function Rr(e){return!!(e.icon&&Mr.has(e.icon)||e.action?.type&&Br.has(e.action.type))}const Tt="gengage_choice_prompter_dismissed",At="gengage_choice_prompter_dismissed_global";function Or(e){const t=document.createElement("div");t.className="gengage-chat-choice-prompter";const n=document.createElement("div");n.className="gengage-chat-choice-prompter-heading",n.textContent=e.heading,t.appendChild(n);const a=document.createElement("div");a.className="gengage-chat-choice-prompter-suggestion",a.textContent=e.suggestion,t.appendChild(a);const i=document.createElement("button");i.type="button",i.className="gengage-chat-choice-prompter-cta",i.textContent=e.ctaLabel,i.addEventListener("click",()=>{Sn(e.threadId);try{sessionStorage.setItem(At,"1")}catch{}t.remove(),e.onCtaClick()}),t.appendChild(i);const o=document.createElement("button");return o.type="button",o.className="gengage-chat-choice-prompter-dismiss",o.textContent="×",o.setAttribute("aria-label",e.dismissAriaLabel??"Dismiss"),o.addEventListener("click",()=>{Sn(e.threadId);try{sessionStorage.setItem(At,"1")}catch{}t.remove(),e.onDismiss?.()}),t.appendChild(o),t}function $r(){try{return sessionStorage.getItem(At)==="1"}catch{return!1}}function Dr(e){try{const t=sessionStorage.getItem(Tt);return t?JSON.parse(t).includes(e):!1}catch{return!1}}function Sn(e){try{const t=sessionStorage.getItem(Tt),n=t?JSON.parse(t):[];n.includes(e)||n.push(e),sessionStorage.setItem(Tt,JSON.stringify(n))}catch{}}const Fr="gengage_assistant",Ur=3,Ae="sessions",me="context",Ce="payload",be="favorites";function Ye(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error)})}function Ue(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onerror=()=>n(e.error),e.onabort=()=>n(e.error??new DOMException("Transaction aborted"))})}class Zr{constructor(t=Fr,n=Ur){this._db=null,this._dbName=t,this._version=n}async open(){return this._db?this._db:new Promise((t,n)=>{const a=indexedDB.open(this._dbName,this._version);a.onupgradeneeded=i=>{const o=a.result,r=i.oldVersion;r<1&&(o.createObjectStore(Ae,{keyPath:["userId","appId","sessionId"]}),o.createObjectStore(me,{keyPath:["sessionId","threadId"]}),o.createObjectStore(Ce,{keyPath:["threadId","messageId"]}).createIndex("threadId","threadId",{unique:!1}),o.createObjectStore(be,{keyPath:["userId","appId","sku"]})),r>=1&&r<2&&(o.objectStoreNames.contains(Ae)&&o.deleteObjectStore(Ae),o.objectStoreNames.contains(Ce)&&o.deleteObjectStore(Ce),o.createObjectStore(Ae,{keyPath:["userId","appId","sessionId"]}),o.createObjectStore(Ce,{keyPath:["threadId","messageId"]}).createIndex("threadId","threadId",{unique:!1}),o.objectStoreNames.contains(me)||o.createObjectStore(me,{keyPath:["sessionId","threadId"]})),r<3&&(o.objectStoreNames.contains(be)||o.createObjectStore(be,{keyPath:["userId","appId","sku"]}))},a.onsuccess=()=>{this._db=a.result,t(this._db)},a.onerror=()=>n(a.error)})}close(){this._db?.close(),this._db=null}async saveSession(t){const a=this._requireDb().transaction(Ae,"readwrite");a.objectStore(Ae).put(t),await Ue(a)}async loadSession(t,n,a){const o=this._requireDb().transaction(Ae,"readonly");return await Ye(o.objectStore(Ae).get([t,n,a]))??null}async saveContext(t){const a=this._requireDb().transaction(me,"readwrite");a.objectStore(me).put(t),await Ue(a)}async loadContext(t,n){const i=this._requireDb().transaction(me,"readonly");return await Ye(i.objectStore(me).get([t,n]))??null}async deleteContextsAfterThread(t,n){const i=this._requireDb().transaction(me,"readwrite"),r=i.objectStore(me).openCursor();await new Promise((s,c)=>{r.onsuccess=()=>{const l=r.result;if(!l){s();return}const g=l.value;if(g.sessionId===t&&g.threadId>n)try{l.delete()}catch{}l.continue()},r.onerror=()=>c(r.error)}),await Ue(i)}async loadLatestContext(t){const i=this._requireDb().transaction(me,"readonly").objectStore(me),o=IDBKeyRange.bound([t,""],[t,"￿"]);return new Promise((r,s)=>{const c=i.openCursor(o,"prev");c.onsuccess=()=>{const l=c.result;r(l?l.value:null)},c.onerror=()=>s(c.error)})}async savePayload(t){const a=this._requireDb().transaction(Ce,"readwrite");a.objectStore(Ce).put(t),await Ue(a)}async loadPayload(t,n){const i=this._requireDb().transaction(Ce,"readonly");return await Ye(i.objectStore(Ce).get([t,n]))??null}async loadPayloadsByThread(t){const i=this._requireDb().transaction(Ce,"readonly").objectStore(Ce).index("threadId"),o=[];return new Promise((r,s)=>{const c=i.openCursor(IDBKeyRange.only(t));c.onsuccess=()=>{const l=c.result;if(!l){r(o);return}o.push(l.value),l.continue()},c.onerror=()=>s(c.error)})}async saveFavorite(t){const a=this._requireDb().transaction(be,"readwrite");a.objectStore(be).put(t),await Ue(a)}async removeFavorite(t,n,a){const o=this._requireDb().transaction(be,"readwrite");o.objectStore(be).delete([t,n,a]),await Ue(o)}async loadFavorites(t,n){const i=this._requireDb().transaction(be,"readonly");return(await Ye(i.objectStore(be).getAll())).filter(r=>r.userId===t&&r.appId===n)}async isFavorite(t,n,a){const o=this._requireDb().transaction(be,"readonly");return await Ye(o.objectStore(be).get([t,n,a]))!==void 0}_requireDb(){if(!this._db)throw new Error("GengageIndexedDB: database not open. Call open() first.");return this._db}}const jr=["comparisonTable","groupList","productDetailsSimilars","productList"];class qr{constructor(t){this._lockCount=1,this._hiddenByUser=!1,this._lastPanelContentType=null,this._chatShown=!1,this._isFavoritesMode=!1,this._lastExtended=!1,this._onChange=t.onChange;const n=new Set(jr);t.productDetailsInPanel&&n.add("productDetails"),this._panelContentTypes=n}get isExtended(){return this._lockCount===0&&!this._hiddenByUser&&!this._isFavoritesMode&&this._lastPanelContentType!==null&&this._panelContentTypes.has(this._lastPanelContentType)&&this._chatShown}unlock(){this._lockCount>0&&this._lockCount--,this._checkStateChange()}lock(){this._lockCount++,this._checkStateChange()}setHiddenByUser(t){this._hiddenByUser=t,this._checkStateChange()}setChatShown(t){this._chatShown=t,this._checkStateChange()}setFavoritesMode(t){this._isFavoritesMode=t,this._checkStateChange()}setPanelContentType(t){this._lastPanelContentType=t,this._checkStateChange()}_checkStateChange(){const t=this.isExtended;t!==this._lastExtended&&(this._lastExtended=t,this._onChange(t))}}class Hr{constructor(t){this.deps=t,this.snapshots=new Map,this._snapshotRebuilders=new Map,this.snapshotTypes=new Map,this.activePanelMessageId=null,this.currentType=null,this.threads=[],this.lastActionType=null}snapshotForMessage(t,n){const a=this.deps.drawer();if(!a?.hasPanelContent()||a.isPanelLoading())return;const i=a.getPanelContentElement();if(!i)return;const o=i.cloneNode(!0);this.snapshots.set(t,o),n&&this._snapshotRebuilders.set(t,n),this.currentType&&this.snapshotTypes.set(t,this.currentType)}attachClickHandler(t){const a=this.deps.shadow()?.querySelector(`[data-message-id="${CSS.escape(t)}"]`);a&&(a.style.cursor="pointer",a.addEventListener("click",()=>this.restoreForMessage(t)))}restoreForMessage(t){const n=this._snapshotRebuilders.get(t),a=this.snapshots.get(t);if(!n&&!a)return!1;const i=this.deps.shadow(),o=this.deps.drawer();this.activePanelMessageId&&i?.querySelector(`[data-message-id="${CSS.escape(this.activePanelMessageId)}"]`)?.classList.remove("gengage-chat-bubble--active"),i?.querySelector(`[data-message-id="${CSS.escape(t)}"]`)?.classList.add("gengage-chat-bubble--active"),this.activePanelMessageId=t;const s=n?n():a.cloneNode(!0);o?.setPanelContent(s);const c=this.snapshotTypes.get(t);return c&&(this.currentType=c,this.updateTopBar(c)),!0}notifyExtension(t){const n=this.deps.bridge();t?setTimeout(()=>n?.send("maximize-pdp",{}),350):setTimeout(()=>n?.send("minify-pdp",{}),200)}titleForComponent(t,n){if(n)return n;const a=this.deps.i18n();switch(t){case"ProductDetailsPanel":return a.panelTitleProductDetails;case"ProductGrid":return Tn(this.lastActionType)?a.panelTitleSearchResults:a.panelTitleSimilarProducts;case"ComparisonTable":return a.panelTitleComparisonResults;case"AIGroupingCards":return a.panelTitleCategories;default:return""}}updateTopBar(t,n){const a=this.deps.currentThreadId();if(!a)return;const i=this.threads.indexOf(a),o=i>0,r=i>=0&&i<this.threads.length-1,s=this.titleForComponent(t,n);this.deps.drawer()?.updatePanelTopBar(o,r,s)}updateTopBarForLoading(t){const n=this.deps.i18n(),i={productDetails:n.panelTitleProductDetails,productList:Tn(this.lastActionType)?n.panelTitleSearchResults:n.panelTitleSimilarProducts,comparisonTable:n.panelTitleComparisonResults,groupList:n.panelTitleCategories}[t]??"";if(i){const o=this.deps.currentThreadId(),r=o?this.threads.indexOf(o):-1,s=r>0,c=r>=0&&r<this.threads.length-1;this.deps.drawer()?.updatePanelTopBar(s,c,i)}}updateExtendedMode(t){const a={ComparisonTable:"comparisonTable",AIGroupingCards:"groupList",ProductDetailsPanel:"productDetails",ProductGrid:"productList"}[t]??null;this.deps.extendedModeManager()?.setPanelContentType(a)}navigateBack(){const t=this.deps.currentThreadId();if(!t)return;const n=this.threads.indexOf(t);if(n>0){const a=this.threads[n-1];a&&this.deps.rollbackToThread(a)}}navigateForward(){const t=this.deps.currentThreadId();if(!t)return;const n=this.threads.indexOf(t);if(n>=0&&n<this.threads.length-1){const a=this.threads[n+1];a&&this.deps.rollbackToThread(a)}}toPanelSpec(t){const n=t.elements[t.root];if(!n||n.type!=="ProductCard")return t;const a={...n,type:"ProductDetailsPanel"};return{root:t.root,elements:{...t.elements,[t.root]:a}}}destroy(){this.snapshots.clear(),this._snapshotRebuilders.clear(),this.snapshotTypes.clear(),this.activePanelMessageId=null,this.currentType=null,this.threads=[]}}function Tn(e){return e==="user_message"||e==="inputText"}function Vr(e){return e.similarsAppend&&e.currentPanelType==="ProductDetailsPanel"&&e.hasPanelContent&&!e.isPanelLoading?"appendSimilars":e.componentType==="ProductGrid"&&!e.isFirstPanelContentInStream&&e.hasPanelContent&&!e.isPanelLoading?"append":"replace"}class An{constructor(t){this.favoritedSkus=new Set,this._favoritesCache=new Map,this._persistLock=Promise.resolve(),this._db=t}get db(){return this._db}set db(t){this._db=t}async persist(t){if(!this._db)return;const n=this._persistLock;let a;this._persistLock=new Promise(i=>{a=i}),await n;try{await this._persistImpl(t)}finally{a()}}async _persistImpl(t){if(!this._db)return;const n=t.messages.map(i=>{const o={id:i.id,role:i.role,timestamp:i.timestamp,status:i.status==="streaming"?"done":i.status};return i.threadId!==void 0&&(o.threadId=i.threadId),i.content!==void 0&&(o.content=i.content),i.silent&&(o.silent=!0),o}),a={};for(const[i,o]of t.panelSnapshots)o.querySelector(".gengage-chat-panel-skeleton")||(a[i]=o.innerHTML);await this._db.saveSession({userId:t.userId,appId:t.appId,sessionId:t.sessionId,messages:n,currentThreadId:t.currentThreadId,lastThreadId:t.lastThreadId,createdAt:t.chatCreatedAt,panelThreads:t.panelThreads.length>0?t.panelThreads:void 0,thumbnailEntries:t.thumbnailEntries.length>0?t.thumbnailEntries:void 0,panelSnapshotHtml:Object.keys(a).length>0?a:void 0,sku:t.sku}),t.lastBackendContext&&t.currentThreadId&&await this._db.saveContext({sessionId:t.sessionId,threadId:t.currentThreadId,context:t.lastBackendContext});for(const i of t.messages)i.uiSpec&&i.threadId&&await this._db.savePayload({threadId:i.threadId,messageId:i.id,uiSpec:i.uiSpec})}async saveAndOpenURL(t,n,a){try{await n()}catch{}a?.send("openURLInNewTab",{url:t}),le(t)&&(window.location.href=t)}async loadPayload(t,n){if(!this._db)return null;for(let a=0;a<3;a++){try{const i=await this._db.loadPayload(t,n);if(i)return i.uiSpec}catch{}a<2&&await new Promise(i=>setTimeout(i,100))}return null}async loadFavorites(t,n){if(this._db)try{const a=await this._db.loadFavorites(t,n);for(const i of a)this.favoritedSkus.add(i.sku),this._favoritesCache.set(i.sku,i)}catch{}}getFavoriteProducts(){return[...this._favoritesCache.values()].sort((t,n)=>(n.savedAt??"").localeCompare(t.savedAt??""))}async toggleFavorite(t,n,a,i){if(this.favoritedSkus.has(a))this.favoritedSkus.delete(a),this._favoritesCache.delete(a),this._db&&await this._db.removeFavorite(t,n,a);else{const o={userId:t,appId:n,sku:a,name:i.name,imageUrl:i.imageUrl,price:i.price,savedAt:new Date().toISOString()};this.favoritedSkus.add(a),this._favoritesCache.set(a,o),this._db&&await this._db.saveFavorite(o)}}close(){this._db?.close(),this._db=null}}const It=e=>`${e}:assistant`;class In{constructor(){this.groups={},this.pinnedToBottom=!0,this.userInteracting=!1,this.focusedThreadId=null,this.shown=!1,this.lastAutoAnchoredGroupId=null,this.scrollRequest=null,this._nextScrollId=1}setShown(t){this.shown=t,t||(this.userInteracting=!1,this.pinnedToBottom=!0,this.focusedThreadId=null,this.scrollRequest=null)}reset(){this.groups={},this.pinnedToBottom=!0,this.userInteracting=!1,this.focusedThreadId=null,this.lastAutoAnchoredGroupId=null,this.scrollRequest=null}registerAssistantActivity(t){const n=It(t),a=this.groups[n],i=this.shown&&this.pinnedToBottom&&!this.userInteracting?"active_unread":"unseen";this.groups[n]={id:n,threadId:t,readState:a?.readState==="seen"?i:a?.readState??i,status:"streaming",updatedAt:Date.now()},a?.readState==="seen"&&this.lastAutoAnchoredGroupId===n&&(this.lastAutoAnchoredGroupId=null)}finalizeAssistantGroup(t){const n=It(t),a=this.groups[n];a&&(a.status="complete",a.updatedAt=Date.now())}setGroupReadStates(t){const n=Date.now();for(const{groupId:a,readState:i}of t){const o=this.groups[a];!o||o.readState===i||(o.readState=i,o.updatedAt=n)}}requestThreadFocus(t,n="smooth"){this.focusedThreadId=t,this.scrollRequest={id:this._nextScrollId++,type:"thread",threadId:t,behavior:n}}requestScrollToBottom(t="smooth"){this.scrollRequest={id:this._nextScrollId++,type:"bottom",behavior:t}}consumeScrollRequest(t){this.scrollRequest?.id===t&&(this.scrollRequest=null)}releaseFocusedThread(){this.focusedThreadId=null}setFocusedThreadId(t){this.focusedThreadId=t}markGroupAutoAnchored(t){this.lastAutoAnchoredGroupId=t}shouldBlockStreamAutoScroll(){return this.shown&&this.userInteracting&&!this.pinnedToBottom}getAssistantReadState(t){return this.groups[It(t)]?.readState}}function Wr(e,t){for(let n=e.length-1;n>=0;n--){const a=e[n],i=t.getAssistantReadState(a);if(i!==void 0&&i!=="seen")return a}return null}const Pn="gengage_kvkk_shown",Gr=["kvkk","kişisel veri","kisisel veri"],Kr=/\b6698\b/;function Pt(e){const t=e.toLowerCase();return Gr.some(n=>t.includes(n))||Kr.test(t)}function Ln(e){try{return localStorage.getItem(`${Pn}_${e}`)==="1"}catch{return!1}}function zn(e){try{localStorage.setItem(`${Pn}_${e}`,"1")}catch{}}function Yr(e){const n=new DOMParser().parseFromString(e,"text/html").body,a=Array.from(n.children);for(const i of a)if(Pt(i.textContent??"")){i.remove();break}return n.innerHTML.trim()}function Jr(e){const t=new DOMParser().parseFromString(e,"text/html");for(const n of Array.from(t.body.children))if(Pt(n.textContent??""))return n.outerHTML;return null}const Xr={tr:"TURKISH",en:"ENGLISH",de:"GERMAN",fr:"FRENCH"};function Qr(e){return e?Xr[e.toLowerCase().slice(0,2)]??"TURKISH":"TURKISH"}const es=':host{all:initial;font-family:var( --gengage-font-family, "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif );font-size:var(--gengage-font-size, 14px)}.gengage-chat-root button,.gengage-chat-root [role=button],.gengage-chat-root a{cursor:pointer}.gengage-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.gengage-chat-root{position:fixed;z-index:var(--gengage-z-index, 2147483647);--_gengage-chat-offset: var(--gengage-chat-offset, 20px);--_gengage-chat-launcher-bottom: var(--gengage-chat-launcher-bottom, 20px);--_gengage-chat-launcher-right: var(--gengage-chat-launcher-right, 20px);--_gengage-chat-launcher-size: var(--gengage-chat-launcher-size, 56px);--_gengage-chat-drawer-width: var(--gengage-chat-width, 400px);--_gengage-chat-radius: var(--gengage-chat-shell-radius, 1rem);--_gengage-chat-header-height: var(--gengage-chat-header-height, 60px);--_gengage-chat-conversation-width: var(--gengage-chat-conversation-width, 396px);--_gengage-chat-panel-min-width: var(--gengage-chat-panel-min-width, 320px);--_gengage-chat-panel-max-width: var(--gengage-chat-panel-max-width, 860px);--_gengage-chat-input-height: var(--gengage-chat-input-height, 48px);--_gengage-chat-shadow: var(--gengage-chat-shadow, 0 12px 40px rgba(25, 28, 29, .04));--_gengage-border-color: var(--gengage-border-color, #edeeef);--_gengage-discount-color: var(--gengage-discount-color, #a03d40);--_gengage-success-color: var(--gengage-success-color, #16a34a);--_gengage-text-primary: var(--gengage-text-primary, #191c1d);--_gengage-text-secondary: var(--gengage-text-secondary, #64748b);--_gengage-surface-secondary: var(--gengage-surface-secondary, #f3f4f5);--_gengage-surface-muted: var(--gengage-surface-muted, #f8f9fa);--_gengage-surface-dark: var(--gengage-surface-dark, #1e293b);--_gengage-rating-color: var(--gengage-rating-color, #d97706);--_gengage-error: var(--gengage-error, #dc2626);--_gengage-ghost-border: var(--gengage-ghost-border, rgba(228, 190, 188, .2));--_gengage-qty-btn-size: var(--gengage-qty-btn-size, 28px);--_gengage-qty-btn-size-compact: var(--gengage-qty-btn-size-compact, 24px)}.gengage-chat-launcher-container{position:fixed;bottom:var(--_gengage-chat-launcher-bottom);right:var(--_gengage-chat-launcher-right);display:flex;flex-direction:column;align-items:flex-end;gap:10px;z-index:var(--gengage-z-index, 2147483647)}.gengage-chat-launcher-content-area,.gengage-chat-launcher-content-area-bottom{display:flex;flex-direction:column;align-items:flex-end;gap:8px}.gengage-chat-launcher-content-area:empty,.gengage-chat-launcher-content-area-bottom:empty{display:none}.gengage-chat-root--open .gengage-chat-launcher-content-area,.gengage-chat-root--open .gengage-chat-launcher-content-area-bottom{display:none}.gengage-chat-root--open .gengage-chat-launcher-container{pointer-events:none;opacity:0;transition:opacity .2s ease}.gengage-chat-launcher{width:var(--_gengage-chat-launcher-size);height:var(--_gengage-chat-launcher-size);border-radius:50%;border:none;background:var(--gengage-primary-color, #b7102a);color:var(--gengage-primary-foreground, #ffffff);cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:0 8px 22px #191c1d2e;transition:transform .18s cubic-bezier(.2,.8,.2,1),box-shadow .18s ease;position:relative;flex-shrink:0}.gengage-chat-launcher:hover{transform:scale(1.05);box-shadow:0 14px 28px #191c1d38}.gengage-chat-launcher svg{width:28px;height:28px}.gengage-chat-launcher--image-mode{background:none;border-radius:0;box-shadow:none;padding:0;overflow:hidden}.gengage-chat-launcher--image-mode:hover{box-shadow:none}.gengage-chat-launcher--image-mode img{width:100%;height:100%;object-fit:contain}.gengage-chat-launcher--hidden-mobile{display:none!important}.gengage-chat-launcher-tooltip{position:absolute;right:calc(100% + 12px);top:50%;transform:translateY(-50%);padding:6px 12px;border-radius:8px;background:var(--_gengage-surface-dark);color:#fff;font-size:13px;font-weight:500;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .2s ease;box-shadow:0 2px 8px #00000026}.gengage-chat-launcher-tooltip:after{content:"";position:absolute;left:100%;top:50%;transform:translateY(-50%);border:5px solid transparent;border-left-color:var(--_gengage-surface-dark)}.gengage-chat-launcher:hover .gengage-chat-launcher-tooltip{opacity:1}.gengage-chat-root--open .gengage-chat-launcher-tooltip{display:none}.gengage-chat-drawer{position:fixed;top:0;bottom:0;right:0;width:var(--_gengage-chat-drawer-width);max-height:-webkit-fill-available;max-height:100dvh;border-radius:0;background:var(--gengage-background-color, #ffffff);box-shadow:var(--_gengage-chat-shadow);display:flex;flex-direction:column;overflow:hidden;z-index:var(--gengage-z-index, 2147483647);transform:translate(0);transition:transform .25s cubic-bezier(.4,0,.2,1),opacity .2s ease;opacity:1}.gengage-chat-root--mobile .gengage-chat-launcher-container{right:var(--gengage-chat-launcher-mobile-right, 16px);bottom:calc(var(--gengage-chat-launcher-mobile-bottom, 16px) + env(safe-area-inset-bottom,0px))}.gengage-chat-root--mobile .gengage-chat-drawer{left:0;right:0;bottom:0;width:100%;max-width:none;max-height:-webkit-fill-available;max-height:100dvh;border-radius:16px 16px 0 0;border-top:none;box-shadow:0 -4px 16px #0000001a,0 12px 40px #0f172a2e;padding-bottom:env(safe-area-inset-bottom,0px);background:var(--gengage-chat-header-bg, #1d2939)}.gengage-chat-drawer-handle{display:none}.gengage-chat-root--mobile .gengage-chat-drawer-handle{display:flex;align-items:center;justify-content:center;position:absolute;top:6px;left:0;right:0;height:14px;pointer-events:none;z-index:1}.gengage-chat-root--mobile .gengage-chat-header{cursor:grab;touch-action:none;user-select:none;-webkit-user-select:none}.gengage-chat-root--mobile .gengage-chat-header button,.gengage-chat-root--mobile .gengage-chat-header a{cursor:pointer;touch-action:auto;user-select:auto;-webkit-user-select:auto}.gengage-chat-root--mobile .gengage-chat-drawer-handle:before{content:"";width:36px;height:4px;border-radius:999px;background:#ffffff4d;pointer-events:none}.gengage-chat-root--mobile.gengage-chat-root--open:before{content:"";position:fixed;inset:0;background:#0000001f;z-index:-1;pointer-events:none}.gengage-chat-root--mobile.gengage-chat-root--mobile-half .gengage-chat-drawer{top:auto;height:min(72dvh,620px);max-height:min(72dvh,620px)}.gengage-chat-root--mobile.gengage-chat-root--mobile-full .gengage-chat-drawer{top:0;height:100dvh;max-height:100dvh;border-radius:0}.gengage-chat-root--mobile .gengage-chat-input-area{padding-bottom:calc(10px + env(safe-area-inset-bottom,0px));border-top:1px solid var(--_gengage-border-color, #e5e7eb);transform:translateY(calc(-1 * var(--gengage-keyboard-offset, 0px)))}.gengage-chat-header{display:flex;align-items:center;justify-content:space-between;box-sizing:border-box;min-height:var(--_gengage-chat-header-height);padding:4px 12px;background:var(--gengage-chat-header-bg, #1d2939);color:var(--gengage-chat-header-foreground, #fff);box-shadow:0 4px 20px #00000014,0 0 2px #0000001f;border:none;position:relative;z-index:2}.gengage-chat-header-left{display:flex;align-items:center;gap:10px;min-width:0}.gengage-chat-header-avatar{width:40px;height:40px;border-radius:0;object-fit:contain;flex-shrink:0}.gengage-chat-header-info{display:flex;flex-direction:column;gap:2px;min-width:0}.gengage-chat-header-title-row{display:flex;align-items:center;gap:6px}.gengage-chat-header-title{font-weight:700;font-size:15px;line-height:1.25;letter-spacing:.01em;color:inherit}.gengage-chat-header-badge{display:inline-flex;align-items:center;padding:1px 6px;border-radius:4px;background:var(--gengage-primary-color, #b7102a);color:#fff;font-size:10px;font-weight:700;letter-spacing:.04em;text-transform:uppercase;line-height:1.5}.gengage-chat-header-powered{display:flex;align-items:center;gap:4px;font-size:11px;color:#ffffffa6;text-decoration:none;transition:color .15s}.gengage-chat-header-powered:hover{color:#fffc}.gengage-chat-header-powered svg{width:12px;height:12px;opacity:.6}.gengage-chat-header-right{display:flex;align-items:center;gap:4px;flex-shrink:0}.gengage-chat-header-btn{width:32px;height:32px;border-radius:8px;background:transparent;border:1px solid rgba(255,255,255,.12);color:#ffffffb3;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;text-decoration:none;line-height:1;transition:background-color .15s ease,color .15s ease,border-color .15s ease}.gengage-chat-header-btn:hover{background:#ffffff1a;color:#fff;border-color:#ffffff40}.gengage-chat-header-btn--fav{position:relative}.gengage-chat-header-btn--reopen-panel,.gengage-chat-root--mobile .gengage-chat-new-chat{display:none}.gengage-chat-header-fav-badge{position:absolute;top:-4px;right:-4px;min-width:16px;height:16px;border-radius:999px;background:var(--_gengage-danger-color, #ef4444);color:var(--_gengage-on-danger, #fff);font-size:9px;font-weight:700;line-height:16px;text-align:center;padding:0 3px;pointer-events:none}.gengage-chat-close{width:32px;height:32px;min-width:32px;min-height:32px;border-radius:8px;background:transparent;border:1px solid rgba(255,255,255,.12);color:#ffffffb3;font-size:18px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;line-height:1;transition:background-color .15s ease,color .15s ease,border-color .15s ease}.gengage-chat-close:hover{background:#ffffff1a;color:#fff;border-color:#ffffff40}.gengage-chat-body{display:flex;flex:1;overflow:hidden;min-height:0;position:relative}.gengage-chat-panel{display:none;width:0;overflow:hidden;transition:width .22s cubic-bezier(.2,.72,.2,1)}.gengage-chat-panel--visible{display:flex;flex-direction:column;position:relative;box-sizing:border-box;width:440px;min-width:440px;background:var(--gengage-chat-panel-bg, var(--_gengage-surface-muted, #fff));border-right:1px solid var(--_gengage-border-color);overflow-y:auto;padding:16px;scrollbar-width:thin;scrollbar-color:rgba(0,0,0,.15) transparent}.gengage-chat-panel--visible::-webkit-scrollbar{width:6px}.gengage-chat-panel--visible::-webkit-scrollbar-track{background:transparent}.gengage-chat-panel--visible::-webkit-scrollbar-thumb{background:#00000026;border-radius:3px}.gengage-chat-panel--visible::-webkit-scrollbar-thumb:hover{background:#00000040}.gengage-chat-panel-ai-zone{flex-shrink:0;width:100%;box-sizing:border-box;padding:8px 0 12px;margin-bottom:4px;border-bottom:1px solid var(--_gengage-border-color, rgba(0, 0, 0, .08));max-height:min(42vh,320px);overflow:auto}.gengage-chat-panel-ai-zone:has(.gengage-chat-grouping-cards){max-height:min(52vh,520px)}.gengage-chat-panel-ai-zone:has(.gengage-chat-ai-top-picks){max-height:none;overflow:visible}.gengage-chat-panel-ai-zone[hidden]{display:none!important}.gengage-chat-panel-ai-zone-inner{display:flex;align-items:center;gap:10px}.gengage-chat-panel-ai-zone-text{font-size:13px;color:var(--_gengage-muted, #64748b)}.gengage-chat-grouping-section-title{display:none}.gengage-chat-panel-ai-zone .gengage-chat-grouping-section-title{display:block;flex-shrink:0;align-self:stretch;width:100%;margin:0 0 10px;font-size:15px;font-weight:700;color:var(--gengage-text-color, #1e293b);letter-spacing:-.01em}.gengage-chat-panel-ai-zone .gengage-chat-grouping-cards{display:flex;flex-direction:column;align-items:stretch;gap:0;width:100%;min-width:0;max-height:none}.gengage-chat-panel-ai-zone .gengage-chat-grouping-cards-scroll{display:flex;flex-direction:row;flex-wrap:nowrap;align-items:stretch;gap:10px;width:100%;min-width:0;overflow-x:auto;overflow-y:hidden;padding:2px 2px 10px;margin:0 -2px;-webkit-overflow-scrolling:touch;scrollbar-width:thin}.gengage-chat-panel-ai-zone .gengage-chat-grouping-card{flex:0 0 auto;width:136px;min-width:136px;max-width:150px;box-sizing:border-box;flex-direction:column;align-items:stretch;gap:8px;padding:12px 10px 14px;background:#fff;border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:12px;box-shadow:0 1px 2px #0f172a0a}.gengage-chat-panel-ai-zone .gengage-chat-grouping-card:hover{border-color:var(--gengage-primary-color, #ea580c);box-shadow:0 2px 8px #ea580c1f}.gengage-chat-panel-ai-zone .gengage-chat-grouping-card-arrow{display:none}.gengage-chat-panel-ai-zone .gengage-chat-grouping-card-img{width:100%;max-width:88px;height:72px;min-width:0;min-height:72px;margin:0 auto;border-radius:8px;object-fit:cover}.gengage-chat-panel-ai-zone .gengage-chat-grouping-card-body{flex-direction:column;align-items:center;text-align:center;gap:4px;width:100%}.gengage-chat-panel-ai-zone .gengage-chat-grouping-card-name{font-size:13px;font-weight:700;line-height:1.25}.gengage-chat-panel-ai-zone .gengage-chat-grouping-card-desc{font-size:11px;color:var(--gengage-text-muted, #64748b);line-height:1.3}.gengage-chat-panel-ai-zone .gengage-chat-grouping-card-labels{display:block;margin-top:0;font-size:11px;color:var(--gengage-chat-text-secondary, #64748b);white-space:normal;text-overflow:unset;overflow:visible;line-height:1.35}.gengage-chat-panel-divider{display:flex;align-items:center;width:4px;cursor:pointer;background:var(--_gengage-border-color);position:relative;flex-shrink:0;transition:background .15s;z-index:2}.gengage-chat-panel-divider:hover{background:#cbd5e1}.gengage-chat-panel-divider--hidden{display:none}.gengage-chat-panel-divider-toggle{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:28px;height:48px;border:1px solid var(--_gengage-border-color);border-radius:6px;background:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:14px;color:var(--_gengage-text-secondary);box-shadow:0 1px 3px #00000014;transition:background .15s,color .15s;padding:0;line-height:1}.gengage-chat-panel-divider-toggle:hover{background:var(--_gengage-surface-muted);color:#334155}.gengage-chat-panel.gengage-chat-panel--collapsed{flex:0 0 0px;width:0;min-width:0;max-width:0;padding:0;border-right:none;overflow:hidden}.gengage-chat-panel--collapsed~.gengage-chat-panel-divider{width:0;background:transparent}.gengage-chat-panel--collapsed~.gengage-chat-panel-divider .gengage-chat-panel-divider-toggle{left:0;transform:translateY(-50%)}.gengage-chat-conversation{display:flex;flex-direction:column;flex:1;min-width:0;overflow:hidden;background:var(--gengage-background-color, #ffffff);position:relative;z-index:1}.gengage-chat-drawer--with-panel{width:auto;background:transparent;box-shadow:none}.gengage-chat-drawer--with-panel .gengage-chat-header{border-radius:0;flex-shrink:0}.gengage-chat-drawer--with-panel .gengage-chat-body{flex:1 1 0;min-height:0;gap:0;padding:0;align-items:stretch}.gengage-chat-drawer--with-panel .gengage-chat-panel--visible{flex:0 0 auto;width:clamp(var(--_gengage-chat-panel-min-width),50vw,var(--_gengage-chat-panel-max-width));min-width:var(--_gengage-chat-panel-min-width);max-width:var(--_gengage-chat-panel-max-width);border-right:none;background:var(--gengage-chat-panel-bg, var(--_gengage-surface, #fff));padding:0 16px 16px;overflow-y:auto;margin:0;border-radius:0;box-shadow:0 8px 32px #0f172a1f,0 2px 8px #0f172a0f;max-height:100dvh}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider{width:0;background:transparent}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle{width:20px;height:48px;border-radius:10px;background:var(--gengage-primary-color, #b7102a);color:#fff;border:2px solid #fff;box-shadow:0 2px 8px #0f172a2e;font-size:12px;z-index:10}.gengage-chat-drawer--with-panel .gengage-chat-panel-divider-toggle:hover{background:var(--gengage-primary-hover, #9a0d23);color:#fff}.gengage-chat-drawer--with-panel .gengage-chat-conversation{flex:0 0 var(--_gengage-chat-conversation-width);width:var(--_gengage-chat-conversation-width);border-left:none;background:var(--gengage-background-color, #ffffff);box-shadow:-4px 0 24px #0f172a1f,-1px 0 4px #0f172a0f}.gengage-chat-drawer--with-panel .gengage-chat-messages{padding-right:6px;scrollbar-width:thin;scrollbar-color:rgba(0,0,0,.12) transparent}.gengage-chat-drawer--with-panel .gengage-chat-messages::-webkit-scrollbar{width:0}.gengage-chat-drawer--with-panel .gengage-chat-panel.gengage-chat-panel--collapsed{flex:0 0 0px;width:0;min-width:0;max-width:0;padding:0;overflow:hidden}.gengage-chat-drawer--with-panel:has(.gengage-chat-panel--collapsed){width:var(--_gengage-chat-conversation-width);background:var(--gengage-background-color, #ffffff);box-shadow:var(--_gengage-chat-shadow)}.gengage-chat-drawer--with-panel .gengage-chat-footer{display:none}.gengage-chat-messages{flex:1;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:16px;min-height:0;scroll-behavior:smooth;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;touch-action:pan-y}.gengage-chat-messages::-webkit-scrollbar{width:6px}.gengage-chat-messages::-webkit-scrollbar-track{background:transparent}.gengage-chat-messages::-webkit-scrollbar-thumb{background:#0000001f;border-radius:3px}.gengage-chat-messages::-webkit-scrollbar-thumb:hover{background:#0003}.gengage-chat-bubble--presentation-collapsed{display:none!important}.gengage-chat-former-messages-btn{position:sticky;top:0;z-index:2;flex-shrink:0;align-self:center;margin-bottom:4px;padding:8px 14px;border-radius:999px;border:1px solid var(--_gengage-border-color, #e5e7eb);background:var(--gengage-background-color, #ffffff);color:var(--_gengage-text-primary, #1f2937);font-size:13px;font-weight:600;cursor:pointer;box-shadow:0 2px 8px #0f172a14}.gengage-chat-former-messages-btn:hover{background:var(--_gengage-surface-secondary, #f3f4f6)}.gengage-chat-bubble{max-width:85%;padding:12px 16px;border-radius:12px;line-height:1.5;font-size:14px;font-weight:500;word-wrap:break-word;overflow-wrap:break-word;animation:gengage-chat-msg-in .3s cubic-bezier(.2,.7,.2,1)}@keyframes gengage-chat-msg-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-bubble--user{align-self:flex-end;background:var(--gengage-primary-color, #b7102a);color:var(--gengage-primary-foreground, #ffffff);border-bottom-right-radius:4px}.gengage-chat-bubble--assistant{align-self:flex-start;background:var(--_gengage-surface-secondary);color:var(--_gengage-text-primary);border-bottom-left-radius:4px;min-width:120px}.gengage-chat-bubble--active{outline:2px solid var(--gengage-primary-color, #b7102a);outline-offset:-2px}.gengage-chat-bubble--assistant:empty{display:none}.gengage-chat-bubble--assistant .gengage-chat-bubble-text a{color:var(--gengage-primary-color, #b7102a);text-decoration:underline}.gengage-chat-bubble--assistant .gengage-chat-bubble-text a:hover{text-decoration:none}.gengage-chat-bubble--assistant .gengage-chat-bubble-text p{margin:0 0 8px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text p:last-child{margin-bottom:0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text ul,.gengage-chat-bubble--assistant .gengage-chat-bubble-text ol{margin:6px 0;padding-left:20px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text li{margin-bottom:6px;line-height:1.5}.gengage-chat-bubble--assistant .gengage-chat-bubble-text code{background:#0000000f;padding:1px 4px;border-radius:3px;font-size:.9em}.gengage-chat-bubble--assistant .gengage-chat-bubble-text pre{background:#0000000a;padding:8px;border-radius:6px;overflow-x:auto;margin:4px 0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text table{border-collapse:collapse;margin:4px 0;font-size:.9em}.gengage-chat-bubble--assistant .gengage-chat-bubble-text th,.gengage-chat-bubble--assistant .gengage-chat-bubble-text td{border:1px solid var(--_gengage-border-color);padding:4px 8px}.gengage-chat-bubble--assistant .gengage-chat-bubble-text img{max-width:100%;height:auto;border-radius:4px;margin:4px 0}.gengage-chat-bubble--assistant .gengage-chat-bubble-text h1,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h2,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h3,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h4,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h5,.gengage-chat-bubble--assistant .gengage-chat-bubble-text h6{margin:8px 0 4px;line-height:1.3;color:#0f172a}.gengage-chat-bubble--assistant .gengage-chat-bubble-text blockquote{border-left:3px solid var(--_gengage-border-color);padding-left:12px;margin:4px 0;color:var(--_gengage-text-secondary)}.gengage-chat-bubble--assistant .gengage-chat-bubble-text{overflow-wrap:break-word}.gengage-chat-bubble--first{border-left:3px solid var(--gengage-primary-color, #b7102a);padding-left:12px}.gengage-chat-bubble--first .gengage-chat-bubble-text{font-size:15px}@media(max-width:768px){.gengage-chat-bubble--assistant .gengage-chat-bubble-text{line-height:1.5}.gengage-chat-bubble--user{max-width:calc(100% - 16px);word-break:break-word}}.gengage-chat-typing{display:flex;align-items:center;gap:5px;padding:8px 4px;align-self:flex-start;max-width:85%}.gengage-chat-typing:has(.gengage-chat-typing-text),.gengage-chat-typing:has(.gengage-chat-thinking-steps){background:var(--_gengage-surface-secondary);padding:10px 14px;border-radius:12px 12px 12px 4px;gap:8px}.gengage-chat-typing-dots{display:flex;align-items:center;gap:5px}.gengage-chat-typing-dots span{width:6px;height:6px;border-radius:50%;background:#94a3b8;display:inline-block;animation:gengage-chat-typing-fade 1.4s ease-in-out infinite}.gengage-chat-typing-dots span:nth-child(2){animation-delay:.2s}.gengage-chat-typing-dots span:nth-child(3){animation-delay:.4s}@keyframes gengage-chat-typing-fade{0%,to{opacity:.25}50%{opacity:1}}.gengage-chat-typing-sparkle{animation:gengage-sparkle-pulse 1.2s infinite}@keyframes gengage-sparkle-pulse{0%,to{opacity:1}50%{opacity:.4}}.gengage-chat-typing-text{font-size:13px;color:var(--_gengage-text-secondary);font-style:italic;flex:1;min-width:0;word-wrap:break-word;overflow-wrap:break-word}.gengage-chat-stop-btn{display:flex;align-items:center;gap:6px;margin:4px 0 8px;padding:6px 16px;border:1px solid var(--gengage-primary-color, #b7102a);border-radius:16px;background:var(--gengage-background-color, #ffffff);color:var(--gengage-primary-color, #b7102a);font-size:12px;max-width:200px;align-self:center;cursor:pointer;transition:background .15s ease,border-color .15s ease}.gengage-chat-stop-btn:hover{background:var(--_gengage-surface-secondary);border-color:var(--gengage-primary-color, #b7102a)}.gengage-chat-stop-btn:focus-visible{outline:2px solid var(--gengage-primary-color, #b7102a);outline-offset:2px}.gengage-chat-stop-icon{display:inline-block;width:10px;height:10px;background:currentColor;border-radius:2px;flex-shrink:0}.gengage-chat-offline-bar{display:none;align-items:center;gap:6px;padding:6px 12px;font-size:12px;line-height:1.4;color:#92400e;background:#fef3c7;border-bottom:1px solid #fde68a}.gengage-chat-offline-bar--visible{display:flex}.gengage-chat-offline-bar:before{content:"";display:inline-block;width:8px;height:8px;background:var(--_gengage-rating-color);border-radius:50%;flex-shrink:0}.gengage-chat-still-working{font-size:12px;color:var(--gengage-chat-text-secondary, #666);margin-top:6px;animation:gengage-fade-in .3s ease}@keyframes gengage-fade-in{0%{opacity:0}to{opacity:1}}.gengage-chat-thinking-steps{display:flex;flex-direction:column;gap:4px;padding:4px 0}.gengage-chat-thinking-step{display:flex;align-items:center;gap:6px;font-size:13px;color:var(--gengage-chat-text-secondary, #666)}.gengage-chat-thinking-step-marker{font-size:12px;width:16px;text-align:center;flex-shrink:0}.gengage-chat-thinking-step-marker--done{color:var(--_gengage-success-color)}.gengage-chat-thinking-step-marker--active{color:var(--gengage-primary-color, #b7102a);animation:gengage-thinking-pulse 1.5s ease-in-out infinite}@keyframes gengage-thinking-pulse{0%,to{opacity:1}50%{opacity:.4}}.gengage-chat-thinking-step-text{line-height:1.4}.gengage-chat-error{display:flex;align-items:center;justify-content:center;gap:10px;padding:10px 14px;border-radius:10px;background:#fef2f2;color:var(--gengage-error, #991b1b);font-size:13px;text-align:center;border:1px solid #fecaca}.gengage-chat-error-retry{flex-shrink:0;padding:4px 12px;border:1px solid #fca5a5;border-radius:6px;background:#fff;color:#991b1b;font-size:12px;font-weight:500;cursor:pointer;transition:background .15s}.gengage-chat-error-retry:hover{background:#fee2e2}.gengage-chat-input-area{display:flex;flex-wrap:wrap;align-items:center;flex-shrink:0;gap:0;padding:8px 12px;border-top:1px solid var(--_gengage-border-color);background:var(--gengage-background-color, #ffffff)}.gengage-chat-input-pill{display:flex;align-items:center;gap:4px;flex:1;min-width:0;height:44px;background:var(--_gengage-surface-secondary);border:1px solid var(--_gengage-border-color);border-radius:30px;padding:2px 8px;overflow:hidden;transition:border-color .2s ease,box-shadow .2s ease}.gengage-chat-input-pill:focus-within{border-color:var(--gengage-primary-color, #b7102a);box-shadow:0 0 0 2px #b7102a26}.gengage-chat-input{flex:1;min-width:0;min-height:40px;max-height:120px;padding:0 6px 0 14px;border:none;border-radius:0;font-size:14px;font-family:inherit;line-height:1.4;align-content:center;outline:none;background:transparent;color:var(--_gengage-text-primary);resize:none;overflow-y:hidden}.gengage-chat-root--mobile .gengage-chat-input-pill{height:52px;padding:3px 8px}.gengage-chat-root--mobile .gengage-chat-input{min-height:44px;max-height:44px;font-size:16px;white-space:nowrap;overflow:hidden}.gengage-chat-root--mobile .gengage-chat-input::placeholder{font-size:15px}.gengage-chat-input::placeholder{font-size:14px;color:#6b7280;line-height:normal}.gengage-chat-send{width:36px;height:36px;min-width:36px;padding:0;border:none;border-radius:50%;background:var(--gengage-primary-color, #b7102a);color:var(--gengage-primary-foreground, #ffffff);font-weight:700;font-size:0;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:background-color .2s cubic-bezier(.4,0,.2,1),box-shadow .2s ease,transform .15s ease;box-shadow:0 2px 6px #00000026}.gengage-chat-send:hover{filter:brightness(.92);transform:translateY(-1px);box-shadow:0 4px 8px #0000002e}.gengage-chat-send:active{transform:translateY(0);box-shadow:0 1px 2px #0000001f}.gengage-chat-send svg{width:18px;height:18px}.gengage-chat-send:disabled{background:#e5e7eb;opacity:.5;box-shadow:none;cursor:not-allowed}.gengage-chat-footer{padding:4px 10px;text-align:center;font-size:10px;color:#6b7280;border-top:1px solid var(--_gengage-surface-muted);background:var(--gengage-background-color, #ffffff)}.gengage-chat-uispec{width:100%}.gengage-chat-uispec:empty{display:none}.gengage-chat-uispec>*{animation:gengage-chat-widget-enter .16s cubic-bezier(.2,.7,.2,1) both}@keyframes gengage-chat-widget-enter{0%{opacity:0;transform:translateY(5px) scale(.99)}to{opacity:1;transform:translateY(0) scale(1)}}.gengage-chat-action-buttons{display:flex;flex-wrap:wrap;gap:8px;padding:6px 0 4px}.gengage-chat-action-btn{flex:0 0 auto;padding:8px 16px;border:none;border-radius:999px;background:var(--gengage-primary-color, #b7102a);color:var(--gengage-primary-foreground, #ffffff);font-size:13px;font-weight:600;line-height:1.25;font-family:inherit;cursor:pointer;white-space:nowrap;transition:filter .15s ease,transform .1s ease}.gengage-chat-action-btn:hover{filter:brightness(.92)}.gengage-chat-action-btn:active{transform:scale(.97)}.gengage-chat-product-card{position:relative;display:flex;flex-direction:column;border:1px solid #eee;border-radius:16px;overflow:hidden;background:#fff;width:160px;min-width:160px;max-width:160px;box-shadow:0 2px 8px #0000000f;transition:transform .1s ease,box-shadow .2s ease}.gengage-chat-product-card:hover{transform:translateY(-2px);box-shadow:0 4px 12px #0000001a}.gengage-chat-product-card-img{width:100%;height:120px;object-fit:contain;display:block;background:#fff;padding:8px;box-sizing:border-box}.gengage-chat-product-card-body{display:flex;flex-direction:column;flex:1;gap:4px;padding:8px 10px 10px;text-align:center}.gengage-chat-product-card-name{font-size:13px;font-weight:600;color:var(--_gengage-text-primary);line-height:1.35;margin-bottom:0;min-height:2.7em;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis}.gengage-chat-product-card-brand{font-size:10px;color:#666}.gengage-chat-product-card-rating{font-size:11px;color:var(--_gengage-rating-color);line-height:1}.gengage-star-half{display:inline-block;position:relative}.gengage-star-half>span{position:absolute;left:0;top:0;overflow:hidden;width:.5em}.gengage-chat-product-card-review-count{color:#475569;font-size:10px}.gengage-chat-product-card-price{display:flex;flex-wrap:wrap;align-items:baseline;justify-content:center;gap:2px 4px;font-size:16px;font-weight:800;color:#0f172a}.gengage-chat-product-card-original-price{text-decoration:line-through;color:var(--_gengage-text-secondary);font-weight:400;font-size:inherit;margin-right:6px}.gengage-chat-price-skeleton{display:inline-block;width:80px;height:16px;background:linear-gradient(90deg,#e2e8f0 25%,#f1f5f9,#e2e8f0 75%);background-size:200% 100%;animation:gengage-skeleton-price-pulse 1.5s ease-in-out infinite;border-radius:4px;vertical-align:middle}@keyframes gengage-skeleton-price-pulse{0%{background-position:200% 0}to{background-position:-200% 0}}.gengage-chat-product-card-cta{display:block;margin-top:auto;padding:8px 10px;text-align:center;background:transparent;color:var(--gengage-primary-color, #b7102a);text-decoration:none;font-size:12px;font-weight:700;letter-spacing:.01em;border-top:1px solid var(--_gengage-surface-muted);cursor:pointer;transition:color .15s ease,background .15s ease}.gengage-chat-product-card-cta:hover{color:var(--gengage-primary-color, #9a0d23);background:var(--_gengage-surface-muted)}.gengage-chat-product-card-cta:active{background:var(--_gengage-surface-muted)}.gengage-chat-product-summary{display:flex;align-items:center;gap:12px;padding:10px 12px;border:1px solid var(--_gengage-border-color);border-radius:12px;background:#fff;cursor:pointer;transition:background .15s,box-shadow .15s;margin:4px 0}.gengage-chat-product-summary:hover{background:#f9fafb;box-shadow:0 1px 4px #0000000f}.gengage-chat-product-summary__image{flex-shrink:0;width:64px;height:64px;border-radius:8px;overflow:hidden;border:1px solid var(--_gengage-surface-secondary);background:#f9fafb}.gengage-chat-product-summary__image img{width:100%;height:100%;object-fit:cover;display:block}.gengage-chat-product-summary__content{flex:1;min-width:0;display:flex;flex-direction:column;gap:2px}.gengage-chat-product-summary__name{font-size:13px;font-weight:500;line-height:1.3;color:#111827;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis}.gengage-chat-product-summary__rating{font-size:11px;color:var(--_gengage-rating-color);line-height:1}.gengage-chat-product-summary__review-count{color:#475569;font-size:11px}.gengage-chat-product-summary__price{font-size:13px;font-weight:600;color:#111827;line-height:1;margin-top:2px}.gengage-chat-product-summary__price-original{text-decoration:line-through;color:var(--_gengage-text-secondary);font-weight:400;font-size:11px}.gengage-chat-product-summary__price-current{color:var(--gengage-primary-color, #111827)}.gengage-chat-product-summary__cta{flex-shrink:0;font-size:12px;font-weight:500;color:var(--gengage-primary-color, #b7102a);text-decoration:none;padding:4px 10px;border-radius:8px;transition:background .15s;white-space:nowrap}.gengage-chat-product-summary__cta:hover{background:#0000000a}.gengage-chat-product-summary__cta:focus-visible{outline:2px solid var(--gengage-primary-color, #b7102a);outline-offset:2px}.gengage-chat-product-grid{display:flex;gap:12px;overflow-x:auto;padding:8px 0;-webkit-overflow-scrolling:touch;scrollbar-width:none;scroll-snap-type:x proximity;min-height:180px}.gengage-chat-product-grid>*{scroll-snap-align:start;flex:0 0 auto}.gengage-chat-product-grid::-webkit-scrollbar{display:none}.gengage-chat-review-highlights{padding:2px 0 6px}.gengage-chat-review-item{border:1px solid var(--_gengage-border-color);border-radius:12px;padding:10px 12px;background:#fff}.gengage-chat-review-item[data-tone=positive]{border-color:#bbf7d0;background:#f0fdf4}.gengage-chat-review-item[data-tone=negative]{border-color:#fecaca;background:#fef2f2}.gengage-chat-review-tag{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.03em;color:var(--_gengage-text-secondary);margin-bottom:4px}.gengage-chat-review-text{font-size:13px;line-height:1.45;color:var(--_gengage-text-primary);display:-webkit-box;-webkit-line-clamp:4;line-clamp:4;-webkit-box-orient:vertical;overflow:hidden}.gengage-chat-review-rating{margin-top:6px;font-size:12px;font-weight:700;color:#0f172a}.gengage-chat-review-empty{font-size:12px;color:var(--_gengage-text-secondary)}.gengage-chat-review-tabs{display:flex;gap:6px;margin-bottom:10px}.gengage-chat-review-tab{padding:6px 14px;border:1px solid var(--_gengage-border-color);border-radius:999px;background:#fff;color:var(--_gengage-text-secondary);font-size:12px;font-weight:600;font-family:inherit;cursor:pointer;transition:background .15s,border-color .15s}.gengage-chat-review-tab:hover{background:var(--_gengage-surface-muted)}.gengage-chat-review-tab--active{background:var(--_gengage-surface-muted);border-color:#94a3b8;color:#0f172a}.gengage-chat-review-pills{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:10px}.gengage-chat-review-pill{display:flex;align-items:center;gap:6px;padding:6px 10px;border:1px solid var(--_gengage-border-color);border-radius:8px;background:#fff;font-size:12px;font-family:inherit;color:#334155;box-shadow:0 1px 2px #0000000a;cursor:pointer;transition:background .15s,border-color .15s}.gengage-chat-review-pill:hover{background:var(--_gengage-surface-muted)}.gengage-chat-review-pill--active{background:var(--_gengage-surface-muted);border-color:var(--_gengage-text-secondary, #64748b);color:var(--_gengage-text-primary, #0f172a);font-weight:600}.gengage-chat-review-pill--active .gengage-chat-review-pill-count{background:var(--_gengage-border-color, #e2e8f0);color:var(--_gengage-text-primary, #0f172a)}.gengage-chat-review-pill[data-tone=positive]{border-color:#bbf7d0}.gengage-chat-review-pill[data-tone=negative]{border-color:#fecaca}.gengage-chat-review-pill-icon{font-size:11px;font-weight:700}.gengage-chat-review-pill[data-tone=positive] .gengage-chat-review-pill-icon{color:var(--_gengage-success-color)}.gengage-chat-review-pill[data-tone=negative] .gengage-chat-review-pill-icon{color:#dc2626}.gengage-chat-review-pill-count{font-size:10px;font-weight:700;background:var(--_gengage-surface-muted);color:var(--_gengage-text-secondary);border-radius:4px;padding:1px 5px}.gengage-chat-review-items{display:grid;gap:10px}.gengage-chat-favorites-page{padding:12px}.gengage-chat-favorites-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:48px 24px;text-align:center;color:var(--_gengage-text-secondary)}.gengage-chat-favorites-empty-icon{opacity:.25;color:var(--_gengage-danger-color, #ef4444)}.gengage-chat-favorites-empty p{font-size:13px;margin:0;line-height:1.5}.gengage-chat-favorites-list{display:flex;flex-direction:column;gap:10px}.gengage-chat-favorites-card{display:flex;align-items:center;gap:12px;padding:10px 12px;border:1px solid var(--_gengage-border-color);border-radius:12px;background:var(--_gengage-surface-color, #fff);position:relative;transition:opacity .2s,transform .2s}.gengage-chat-favorites-card--removing{opacity:0;transform:translate(8px)}.gengage-chat-favorites-card__image{width:56px;height:56px;flex-shrink:0;border-radius:8px;overflow:hidden;background:var(--_gengage-surface-muted)}.gengage-chat-favorites-card__image img{width:100%;height:100%;object-fit:contain}.gengage-chat-favorites-card__info{flex:1;min-width:0;display:flex;flex-direction:column;gap:4px}.gengage-chat-favorites-card__name{font-size:13px;font-weight:500;color:var(--_gengage-text-primary, #0f172a);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gengage-chat-favorites-card__price{font-size:13px;font-weight:700;color:var(--_gengage-primary-color, #1d4ed8)}.gengage-chat-favorites-remove{flex-shrink:0;width:28px;height:28px;border-radius:50%;background:transparent;border:none;color:var(--_gengage-danger-color, #ef4444);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;opacity:.7;transition:opacity .15s,background .15s}.gengage-chat-favorites-remove:hover{opacity:1;background:var(--_gengage-danger-light, #fee2e2)}.gengage-chat-divider{border:none;border-top:1px solid var(--_gengage-border-color);margin:8px 0}.gengage-chat-divider-wrapper{display:flex;align-items:center;gap:8px;margin:8px 0}.gengage-chat-divider-wrapper hr{flex:1;border:none;border-top:1px solid var(--_gengage-border-color);margin:0}.gengage-chat-divider-label{font-size:11px;color:#6b7280;white-space:nowrap}.gengage-chat--overlay .gengage-chat-drawer{position:fixed;inset:0;width:100%;max-width:480px;max-height:100%;margin:0 auto;border-radius:0;animation:gengage-chat-overlay-in .24s cubic-bezier(.2,.72,.2,1)}.gengage-chat--overlay:before{content:"";position:fixed;inset:0;background:var(--gengage-chat-overlay-backdrop, rgba(0, 0, 0, .45));z-index:-1}@keyframes gengage-chat-overlay-in{0%{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-panel-skeleton{display:flex;flex-direction:column;gap:14px;padding:6px 0}.gengage-chat-panel-skeleton-block{height:110px;border-radius:10px;background:linear-gradient(90deg,#e5e7eb 25%,#f3f4f6,#e5e7eb 75%);background-size:200% 100%;animation:gengage-panel-shimmer 1.4s infinite}@keyframes gengage-panel-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}.gengage-chat-panel-skeleton-block--image{height:200px;border-radius:8px;margin-bottom:12px}.gengage-chat-panel-skeleton-block--text{height:16px;border-radius:4px;margin-bottom:8px}.gengage-chat-panel-skeleton-block--text:nth-child(3){width:80%}.gengage-chat-panel-skeleton-block--text:nth-child(4){width:60%}.gengage-chat-panel-skeleton-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px}.gengage-chat-panel-skeleton-block--card{height:120px;border-radius:8px}.gengage-chat-panel-skeleton-block--row{height:32px;border-radius:4px;margin-bottom:4px}.gengage-chat-panel .gengage-chat-product-card{width:100%;max-width:100%;min-width:0;display:flex;flex-direction:column;border-radius:12px;border:1px solid var(--_gengage-border-color);box-shadow:0 1px 4px #0000000f;overflow:hidden;padding:0}.gengage-chat-panel .gengage-chat-product-card:hover{transform:translateY(-2px);box-shadow:0 4px 12px #0000001a;border-color:#d1d5db}.gengage-chat-panel .gengage-chat-product-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));overflow-x:visible;gap:12px;min-height:auto;padding:4px 0}.gengage-chat-panel:has(.gengage-chat-choice-prompter) .gengage-chat-product-grid{padding-bottom:120px}.gengage-chat-panel .gengage-chat-product-card-img{width:100%;height:160px;border-radius:0;object-fit:contain;background:#fafafa;padding:12px;box-sizing:border-box}.gengage-chat-panel .gengage-chat-product-card-body{padding:10px 12px 12px;text-align:left;gap:4px}.gengage-chat-panel .gengage-chat-product-card-name{min-height:0;margin-bottom:2px;font-size:13px;-webkit-line-clamp:2;line-clamp:2}.gengage-chat-panel .gengage-chat-product-card-price{justify-content:flex-start;font-size:15px}.gengage-chat-panel .gengage-chat-product-card-cta{display:block;padding:10px 12px;text-align:center;border-top:1px solid var(--_gengage-surface-muted);border-radius:0;background:transparent;color:var(--gengage-primary-color, #b7102a);font-weight:700;font-size:13px}.gengage-chat-product-card--selected{border-color:var(--gengage-primary-color, #b7102a);background:color-mix(in srgb,var(--gengage-primary-color, #b7102a) 8%,transparent);box-shadow:0 0 0 1px var(--gengage-primary-color, #b7102a)}.gengage-chat-panel--visible{min-height:0}.gengage-chat-panel--visible>*{flex-shrink:0}.gengage-chat-load-more-btn{display:block;margin:12px auto;padding:8px 24px;border:1px solid var(--_gengage-border-color);border-radius:8px;background:transparent;color:var(--gengage-primary-color, #b7102a);cursor:pointer;font-size:14px}.gengage-chat-load-more-btn:hover{background:var(--_gengage-surface-muted, #f8fafc)}.gengage-chat-product-details-panel{display:flex;flex-direction:column;gap:12px;width:100%;background:#fff;border:1px solid var(--_gengage-border-color);border-radius:16px;padding:14px;box-sizing:border-box}.gengage-chat-product-details-media{border:1px solid var(--_gengage-surface-muted);border-radius:12px;background:#fafafa;padding:12px;display:flex;flex-direction:column;align-items:center}.gengage-chat-product-details-img{width:100%;height:auto;max-height:300px;object-fit:contain;border-radius:8px}.gengage-chat-product-details-content{display:flex;flex-direction:column;gap:8px;min-width:0}.gengage-chat-product-details-title{margin:0;font-size:17px;font-weight:700;line-height:1.3;color:#0f172a}.gengage-chat-product-details-rating{display:inline-flex;align-items:center;gap:4px;width:fit-content;padding:3px 8px;border-radius:999px;background:#fff7ed;color:#9a3412;font-size:13px;font-weight:700}.gengage-chat-product-details-review-count{color:#7c2d12;font-weight:600}.gengage-chat-product-details-price{display:flex;align-items:baseline;gap:6px}.gengage-chat-product-details-original-price{font-size:14px;color:#64748b;text-decoration:line-through}.gengage-chat-product-details-current-price{font-size:22px;font-weight:800;line-height:1.1;color:#0f172a}.gengage-chat-product-details-stock{width:fit-content;padding:4px 10px;border-radius:999px;font-size:12px;font-weight:700}.gengage-chat-product-details-stock.is-in-stock{background:#dcfce7;color:#166534}.gengage-chat-product-details-stock.is-out-of-stock{background:#fee2e2;color:#991b1b}.gengage-chat-product-details-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:4px}.gengage-chat-product-details-cta{display:inline-flex;align-items:center;justify-content:center;min-height:40px;padding:0 20px;border-radius:999px;border:none;text-decoration:none;background:var(--gengage-primary-color, #b7102a);color:var(--gengage-primary-foreground, #ffffff);font-size:14px;font-weight:700;cursor:pointer;transition:filter .14s ease,transform .12s ease}.gengage-chat-product-details-cta:hover{filter:brightness(1.05);transform:translateY(-1px)}.gengage-chat-product-details-cta:active{transform:translateY(1px)}.gengage-chat-product-details-atc{display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:10px 20px;border:none;border-radius:10px;background:var(--_gengage-success-color);color:#fff;font-size:14px;font-weight:700;font-family:inherit;cursor:pointer;transition:filter .12s ease,transform .12s ease}.gengage-chat-product-details-atc:hover{filter:brightness(1.08);transform:translateY(-1px)}.gengage-chat-product-details-atc:active{transform:translateY(1px)}.gengage-chat-product-detail-tabs{margin-top:4px;border-top:1px solid var(--_gengage-border-color);padding-top:12px}.gengage-chat-product-detail-tab-bar{display:flex;gap:0;border-bottom:2px solid var(--_gengage-border-color);margin-bottom:12px}.gengage-chat-product-detail-tab{flex:1;padding:8px 12px;border:none;background:transparent;color:var(--_gengage-text-secondary);font-size:13px;font-weight:600;font-family:inherit;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-2px;transition:color .15s,border-color .15s}.gengage-chat-product-detail-tab:hover{color:#334155}.gengage-chat-product-detail-tab--active{color:var(--gengage-primary-color, #b7102a);border-bottom-color:var(--gengage-primary-color, #b7102a)}.gengage-chat-product-detail-tab-panel{font-size:13px;line-height:1.6;color:#374151}.gengage-chat-product-specs-table{width:100%;border-collapse:collapse;font-size:13px}.gengage-chat-product-specs-table tr:nth-child(2n){background:var(--_gengage-surface-muted)}.gengage-chat-product-specs-key{padding:6px 10px;font-weight:600;color:#475569;white-space:nowrap;border-bottom:1px solid var(--_gengage-surface-muted);width:40%}.gengage-chat-product-specs-value{padding:6px 10px;color:var(--_gengage-text-primary);border-bottom:1px solid var(--_gengage-surface-muted)}.gengage-chat-product-card-atc{position:absolute;bottom:42px;right:6px;opacity:0;transition:opacity .15s ease;z-index:1}.gengage-chat-product-card:hover .gengage-chat-product-card-atc{opacity:1}@media(hover:none),(pointer:coarse){.gengage-chat-product-card-atc{opacity:1;position:relative;bottom:auto;right:auto;margin:0;display:flex;width:100%}}.gengage-chat-drawer.gengage-chat-drawer--hidden{transform:translate(100%);opacity:0;pointer-events:none;box-shadow:none;visibility:hidden}.gengage-chat-root--mobile .gengage-chat-drawer.gengage-chat-drawer--hidden{transform:translateY(100%);opacity:0;pointer-events:none;box-shadow:none;visibility:hidden}@media(max-width:900px){.gengage-chat-drawer--with-panel .gengage-chat-panel--visible{width:clamp(280px,calc(100vw - var(--_gengage-chat-conversation-width)),560px);max-width:560px}}.gengage-chat-attachment-preview{display:flex;align-items:center;gap:8px;padding:6px 10px;background:var(--_gengage-surface-secondary);border:1px solid var(--_gengage-border-color);border-radius:8px;width:100%;box-sizing:border-box}.gengage-chat-attachment-preview--hidden{display:none}.gengage-chat-attachment-preview-thumb{width:40px;height:40px;border-radius:4px;object-fit:cover;flex-shrink:0}.gengage-chat-attachment-name{flex:1;font-size:12px;color:#4b5563;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.gengage-chat-attachment-remove{background:none;border:none;cursor:pointer;font-size:18px;color:#6b7280;padding:0 4px;line-height:1;flex-shrink:0}.gengage-chat-attachment-remove:hover{color:#ef4444}.gengage-chat-attach-btn{background:none;border:none;cursor:pointer;width:32px;height:32px;padding:0;line-height:1;flex-shrink:0;display:flex;align-items:center;justify-content:center;border-radius:50%;color:#6b7280;transition:color .15s,background .15s}.gengage-chat-attach-btn:hover{color:#4b5563;background:#0000000d}.gengage-chat-attach-btn svg{width:20px;height:20px}.gengage-chat-mic-btn{background:none;border:none;cursor:pointer;width:32px;height:32px;padding:0;line-height:1;flex-shrink:0;display:flex;align-items:center;justify-content:center;border-radius:50%;color:#6b7280;transition:color .15s,background .15s}.gengage-chat-mic-btn:hover{color:#4b5563;background:#0000000d}.gengage-chat-mic-btn svg{width:20px;height:20px}.gengage-chat-mic-btn--active{color:#ef4444;animation:gengage-mic-pulse 1.2s ease-in-out infinite}.gengage-chat-mic-btn--active:hover{color:#dc2626}@keyframes gengage-mic-pulse{0%,to{transform:scale(1);opacity:1}50%{transform:scale(1.15);opacity:.8}}.gengage-chat-input-area--dragover{outline:2px dashed var(--gengage-primary-color, #b7102a);outline-offset:-2px;background:#eff6ff}.gengage-chat-attachment-thumb{width:120px;max-width:100%;height:auto;border-radius:8px;margin-bottom:6px;display:block}.gengage-chat-root--mobile{--_gengage-qty-btn-size: 44px;--_gengage-qty-btn-size-compact: 44px}.gengage-chat-root--mobile .gengage-chat-header-btn,.gengage-chat-root--mobile .gengage-chat-close{width:44px;height:44px;border-radius:12px}.gengage-chat-root--mobile .gengage-chat-attach-btn,.gengage-chat-root--mobile .gengage-chat-mic-btn,.gengage-chat-root--mobile .gengage-chat-send{width:44px;height:44px;min-width:44px}.gengage-chat-root--mobile .gengage-chat-attach-btn svg,.gengage-chat-root--mobile .gengage-chat-mic-btn svg{width:22px;height:22px}.gengage-chat-root--mobile .gengage-chat-panel-divider{display:flex;width:100%;height:20px;align-items:center;justify-content:center;cursor:ns-resize;background:transparent;touch-action:pan-y;position:relative;overflow:visible}.gengage-chat-root--mobile .gengage-chat-panel-divider--hidden{display:none}.gengage-chat-root--mobile .gengage-chat-drawer--with-panel{left:0;right:0;width:100%;border-radius:0}.gengage-chat-root--mobile .gengage-chat-panel{display:flex;flex-direction:column;position:absolute;inset:0;z-index:10;width:100%;min-width:0;max-width:none;max-height:none;border:none;box-shadow:none;border-radius:0;background:var(--gengage-chat-panel-bg, #fff);overflow-y:auto;transform:translate(100%);transition:transform .32s cubic-bezier(.4,0,.2,1);pointer-events:none;padding:0 12px 16px}.gengage-chat-root--mobile .gengage-chat-panel--visible{transform:translate(0);pointer-events:auto}.gengage-chat-root--mobile .gengage-chat-panel-divider,.gengage-chat-root--mobile .gengage-chat-drawer--with-panel .gengage-chat-panel-divider{display:none}.gengage-chat-root--mobile .gengage-chat-drawer--with-panel .gengage-chat-body{flex-direction:row}.gengage-chat-root--mobile .gengage-chat-drawer--with-panel .gengage-chat-conversation{width:100%;flex:1;border-left:none}.gengage-chat-root--mobile .gengage-qty-stepper--compact .gengage-qty-submit{min-height:44px;padding:0 12px;font-size:13px}.gengage-chat-root--mobile .gengage-chat-product-details-atc-stepper .gengage-qty-submit{min-height:44px;padding:0 16px}.gengage-chat-root--mobile .gengage-chat-product-details-share{width:44px;height:44px}.gengage-chat-root--mobile .gengage-chat-panel .gengage-chat-product-card{grid-template-columns:84px 1fr}.gengage-chat-root--mobile .gengage-chat-panel .gengage-chat-product-card-cta{grid-column:1 / -1;width:100%}.gengage-chat-root--mobile .gengage-chat-panel .gengage-chat-product-card-atc{grid-column:1 / -1;width:100%;border-radius:0;box-shadow:none;border-width:0;border-top:1px solid var(--_gengage-border-color, #e5e7eb)}.gengage-chat-root--mobile .gengage-chat-panel .gengage-chat-product-card-atc .gengage-qty-submit{flex:1;border-radius:0}.gengage-chat-root--mobile .gengage-chat-product-details-panel{padding:12px;gap:12px}.gengage-chat-root--mobile .gengage-chat-product-details-media{min-height:140px}.gengage-chat-root--mobile .gengage-chat-product-details-title{font-size:15px}.gengage-chat-root--mobile .gengage-chat-product-details-current-price{font-size:20px}.gengage-chat-root--mobile .gengage-chat-product-grid{scroll-snap-type:x mandatory}.gengage-chat-root--mobile .gengage-chat-product-card{width:280px;min-width:280px;scroll-snap-align:center}.gengage-chat-root--mobile .gengage-chat-product-card-img{height:180px}.gengage-chat-root--mobile .gengage-chat-drawer{position:fixed;inset:0;width:100%;max-height:100%;border-radius:0}.gengage-chat-root--mobile .gengage-chat-bubble{max-width:100%}.gengage-chat-root--mobile .gengage-chat-panel .gengage-chat-product-card-img{max-height:120px;object-fit:contain}.gengage-chat-root--mobile .gengage-chat-messages{scrollbar-width:none;padding:12px 16px}.gengage-chat-root--mobile .gengage-chat-messages::-webkit-scrollbar{display:none}.gengage-chat-root--mobile .gengage-chat-drawer{border-top:none}.gengage-chat-root--mobile .gengage-chat-header{border-radius:16px 16px 0 0;padding-top:22px;padding-bottom:8px;min-height:72px}.gengage-chat-root--mobile.gengage-chat-root--mobile-full .gengage-chat-header{border-radius:0}.gengage-chat-root--mobile .gengage-chat-conversation{overflow-y:auto;-webkit-overflow-scrolling:touch;min-height:0}.gengage-chat-root--mobile .gengage-chat-product-details-img{min-height:120px;object-fit:contain}.gengage-chat-root--mobile .gengage-chat-product-details-actions{flex-wrap:wrap;gap:8px}.gengage-chat-root--mobile .gengage-chat-product-card-promos,.gengage-chat-root--mobile .gengage-chat-product-details-promos{flex-wrap:wrap;gap:4px}.gengage-chat-root--mobile .gengage-chat-input::placeholder{font-size:13px}.gengage-chat-kvkk-banner{display:flex;align-items:flex-start;gap:8px;padding:10px 14px;background:#fffbeb;border-bottom:1px solid #fde68a;font-size:12px;line-height:1.5;color:#92400e}.gengage-chat-kvkk-content{flex:1;min-width:0}.gengage-chat-kvkk-content a{color:#b45309;text-decoration:underline}.gengage-chat-kvkk-dismiss{flex-shrink:0;width:20px;height:20px;border:none;background:transparent;color:#78350f;font-size:18px;cursor:pointer;padding:0;line-height:1}.gengage-chat-comparison{padding:16px}.gengage-chat-comparison-heading{font-size:14px;font-weight:700;letter-spacing:.05em;color:#0f172a;margin:0 0 16px}.gengage-chat-comparison-recommended{border:1px solid var(--_gengage-border-color);border-radius:12px;padding:16px;background:#fff;box-shadow:0 1px 3px #0000000f;margin-bottom:12px}.gengage-chat-comparison-recommended-label{font-size:12px;font-weight:700;color:var(--_gengage-success-color);text-transform:uppercase;letter-spacing:.04em;margin-bottom:12px}.gengage-chat-comparison-recommended-body{display:flex;gap:12px;align-items:flex-start}.gengage-chat-comparison-recommended-body img{width:80px;height:80px;object-fit:contain;border-radius:8px;background:var(--_gengage-surface-muted)}.gengage-chat-comparison-recommended-info{flex:1;min-width:0}.gengage-chat-comparison-recommended-title{font-size:14px;font-weight:600;color:#0f172a;margin-bottom:4px}.gengage-chat-comparison-recommended-price{font-size:16px;font-weight:700;color:#0f172a}.gengage-chat-comparison-highlights{margin-top:12px;padding-top:12px;border-top:1px solid var(--_gengage-surface-muted)}.gengage-chat-comparison-highlights-label{font-size:12px;font-weight:600;color:var(--_gengage-text-secondary);margin-bottom:6px}.gengage-chat-comparison-highlights ul{margin:0;padding-left:18px;font-size:13px;color:#334155;line-height:1.6}.gengage-chat-comparison-special{background:#fffbeb;border:1px solid #fde68a;border-radius:12px;padding:12px 16px;margin-bottom:12px;font-size:13px;color:#92400e}.gengage-chat-comparison-special summary{cursor:pointer;font-weight:600}.gengage-chat-comparison-special ul{margin:8px 0 0;padding-left:18px;line-height:1.6}.gengage-chat-comparison-table{width:100%;border-collapse:collapse;font-size:13px;margin-top:12px}.gengage-chat-comparison-table th,.gengage-chat-comparison-table td{padding:10px 12px;text-align:center;border-bottom:1px solid var(--_gengage-surface-muted);vertical-align:top}.gengage-chat-comparison-table th{font-weight:600;font-size:12px;color:#334155}.gengage-chat-comparison-table th img{width:60px;height:60px;object-fit:contain;border-radius:6px;background:var(--_gengage-surface-muted);margin-bottom:6px}.gengage-chat-comparison-table-price{font-weight:700;color:#0f172a}.gengage-chat-comparison-label{text-align:left;font-weight:600;color:var(--_gengage-text-secondary);white-space:nowrap}.gengage-chat-comparison-selected{background:#f0fdf4}.gengage-chat-comparison-recommended-text{padding:8px 12px;font-size:12px;color:var(--gengage-text-secondary, #475569);font-style:italic;border-top:1px solid var(--gengage-border-color, #e2e8f0);margin-top:8px}.gengage-chat-comparison-product-actions{display:flex;gap:8px;margin-top:12px;flex-wrap:wrap}.gengage-chat-comparison-view-btn{flex:1;min-width:0;padding:8px 12px;border:1px solid var(--gengage-primary-color, #b7102a);border-radius:6px;background:transparent;color:var(--gengage-primary-color, #b7102a);font-size:12px;font-weight:500;font-family:inherit;cursor:pointer;transition:background .15s ease,color .15s ease;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.gengage-chat-comparison-view-btn:hover{background:var(--gengage-primary-color, #b7102a);color:#fff}.gengage-chat-pills{position:relative;padding:8px 12px;border-top:1px solid var(--_gengage-surface-muted);background:var(--gengage-background-color, #ffffff)}.gengage-chat-pills-scroll{display:flex;gap:8px;overflow-x:auto;scrollbar-width:none;-webkit-overflow-scrolling:touch;padding-right:28px}.gengage-chat-pills-scroll::-webkit-scrollbar{display:none}.gengage-chat-root--mobile .gengage-chat-pills-scroll{flex-wrap:wrap;gap:6px}.gengage-chat-root--mobile .gengage-chat-pill{white-space:normal;max-width:100%}.gengage-chat-pill{flex:0 0 auto;padding:8px 16px;border:none;border-radius:999px;background:var(--gengage-primary-color, #b7102a);color:var(--gengage-primary-foreground, #ffffff);font-size:13px;font-weight:600;font-family:inherit;white-space:nowrap;cursor:pointer;transition:filter .15s,transform .1s}.gengage-chat-pill:hover{filter:brightness(.92)}.gengage-chat-pill:active{transform:scale(.97)}.gengage-chat-pill--rich{display:flex;align-items:center;gap:8px;padding:6px 14px 6px 6px;border-radius:20px}.gengage-chat-pill-img{width:32px;height:32px;border-radius:50%;object-fit:cover;flex-shrink:0;background:#ffffff26}.gengage-chat-pill-text{font-size:13px;font-weight:600;line-height:1.2}.gengage-chat-pill-desc{display:none}.gengage-chat-pill--rich .gengage-chat-pill-desc{display:block;font-size:10px;font-weight:400;opacity:.8;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:160px}.gengage-chat-pills-arrow{position:absolute;right:8px;top:50%;transform:translateY(-50%);width:28px;height:28px;border-radius:50%;border:1px solid var(--_gengage-border-color);background:#fff;color:var(--_gengage-text-secondary);font-size:16px;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:-4px 0 8px #ffffffe6;z-index:1}.gengage-chat-pills-arrow:hover{background:var(--_gengage-surface-muted);color:#334155}@media(prefers-reduced-motion:reduce){.gengage-chat-uispec>*,.gengage-chat-action-btn,.gengage-chat-product-card,.gengage-chat-product-card-cta,.gengage-chat-send,.gengage-chat-launcher,.gengage-chat-pill,.gengage-chat-drawer,.gengage-chat-typing-dots span,.gengage-chat-typing-sparkle,.gengage-chat-thinking-step-marker--active,.gengage-chat-bubble,.gengage-chat-panel-skeleton-block,.gengage-chat-ai-toppick-card,.gengage-chat-mic-btn--active,.gengage-chat-ai-toppick-spinner:after,.gengage-chat-panel-shimmer,.gengage-chat-overlay,.gengage-chat-product-details-skeleton-price,.gengage-chat-still-working,.gengage-skeleton-card,.gengage-skeleton-line,.gengage-skeleton-img,.gengage-skeleton-text,.gengage-skeleton-price{animation:none!important;transition:none!important;transform:none!important}}.gengage-chat-bubble--user{position:relative}.gengage-chat-rollback-btn{position:absolute;left:-28px;top:50%;transform:translateY(-50%);width:24px;height:24px;border:none;border-radius:50%;background:var(--gengage-surface-color, #f1f5f9);color:var(--gengage-text-secondary, #64748b);cursor:pointer;display:flex;align-items:center;justify-content:center;opacity:0;transition:opacity .15s ease;padding:0}.gengage-chat-bubble--user:hover .gengage-chat-rollback-btn{opacity:1}.gengage-chat-rollback-btn:hover{background:var(--gengage-primary-color, #b7102a);color:#fff}.gengage-chat-bubble--hidden{display:none}.gengage-chat-ai-top-picks{display:flex;flex-direction:column;gap:12px;padding:8px 0;scroll-margin-top:60px}.gengage-chat-ai-top-picks-title{font-size:15px;font-weight:600;color:var(--gengage-text-primary, #1e293b);margin:0 0 4px}.gengage-chat-ai-top-picks-scroll{display:flex;flex-direction:column;gap:10px;min-width:0}.gengage-chat-panel-ai-zone .gengage-chat-ai-top-picks{gap:0;padding-top:4px}.gengage-chat-panel-ai-zone .gengage-chat-ai-top-picks-title{flex-shrink:0;width:100%;margin:0 0 10px;font-weight:700}.gengage-chat-panel-ai-zone .gengage-chat-ai-top-picks-scroll{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));align-items:stretch;gap:12px;overflow:visible;padding:12px 0;margin:0;scrollbar-width:none}.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--winner,.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--compact{width:100%;min-width:0;max-width:none;flex:initial;scroll-snap-align:none}.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--compact{flex-direction:column;align-items:stretch}.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-media,.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-media{max-height:140px}.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-img,.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-img{width:100%;height:100%;max-height:140px;object-fit:contain;flex-shrink:0}.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-body,.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-body{padding:0;flex:1;min-height:0}.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-cta{width:calc(100% - 24px);margin:14px 12px 12px;align-self:stretch;border:1px solid var(--gengage-primary-color, #ea580c);background:transparent;color:var(--gengage-primary-color, #ea580c)}.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-cta{width:calc(100% - 24px);margin:14px 12px 12px;border:1px solid var(--gengage-primary-color, #ea580c);background:transparent;color:var(--gengage-primary-color, #ea580c)}.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-cta:hover,.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-cta:hover{background:#ea580c0f;filter:none}.gengage-chat-panel-ai-zone .gengage-chat-ai-toppick-card--winner{border-color:var(--gengage-primary-color, #ea580c)}.gengage-chat-ai-toppick-rating{font-size:12px;font-weight:600;color:#ca8a04;margin-top:4px}.gengage-chat-ai-toppick-media .gengage-chat-ai-toppick-discount-badge{position:absolute;top:4px;left:4px;right:auto;background:var(--gengage-primary-color, #ea580c);color:#fff;font-size:9px;font-weight:800;padding:2px 6px;border-radius:999px;z-index:1;line-height:1.2}.gengage-chat-ai-toppick-card--winner,.gengage-chat-ai-toppick-card--compact{position:relative;display:flex;flex-direction:column;align-items:stretch;box-sizing:border-box;padding:12px;border-radius:12px;background:#fff;overflow:visible;transition:box-shadow .2s ease,background .15s ease,transform .15s ease}.gengage-chat-ai-toppick-card--winner{border:1.5px solid var(--gengage-primary-color, #ea580c)}.gengage-chat-ai-toppick-card--winner:hover{background:#fafafa;box-shadow:0 4px 16px #ea580c1f}.gengage-chat-ai-toppick-card--compact{border:1px solid #e5e7eb}.gengage-chat-ai-toppick-card--compact:hover{background:#fafafa;box-shadow:0 2px 8px #00000014;transform:translateY(-1px)}.gengage-chat-ai-toppick-badge{position:absolute;top:-10px;left:12px;z-index:2;max-width:calc(100% - 24px);box-sizing:border-box;font-size:10px;font-weight:700;line-height:1.25;padding:2px 10px;border-radius:999px;text-transform:uppercase;letter-spacing:.05em;pointer-events:none;white-space:normal}.gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-badge{background:var(--gengage-primary-color, #ea580c);color:#fff}.gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-badge{background:#f3f4f6;color:#4b5563}.gengage-chat-ai-toppick-media{position:relative;width:100%;flex-shrink:0;display:flex;align-items:center;justify-content:center;margin-top:4px;margin-bottom:8px;aspect-ratio:1 / 1;border-radius:8px;border:1px solid #f3f4f6;overflow:hidden;background:#fff}.gengage-chat-ai-toppick-img{max-width:100%;max-height:100%;width:auto;height:auto;object-fit:contain;padding:4px;box-sizing:border-box}.gengage-chat-ai-toppick-body{display:flex;flex-direction:column;gap:0;padding:0;flex:1;min-width:0}.gengage-chat-ai-toppick-name{font-size:14px;font-weight:600;line-height:1.375;color:#111827;margin-bottom:4px;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical}.gengage-chat-ai-toppick-role{font-size:11px;font-weight:600;color:var(--gengage-primary-color, #b7102a);text-transform:uppercase;letter-spacing:.3px}.gengage-chat-ai-toppick-labels{display:flex;flex-wrap:wrap;gap:4px;margin-top:6px}.gengage-chat-ai-toppick-label{font-size:11px;padding:1px 6px;border-radius:4px;font-weight:500}.gengage-chat-ai-toppick-label[data-sentiment=positive]{background:#dcfce7;color:#166534}.gengage-chat-ai-toppick-label[data-sentiment=negative]{background:#fee2e2;color:#991b1b}.gengage-chat-ai-toppick-label[data-sentiment=neutral]{background:var(--_gengage-surface-muted);color:#475569}.gengage-chat-ai-toppick-score{font-size:12px;font-weight:700;color:var(--gengage-primary-color, #b7102a);margin-top:6px}.gengage-chat-ai-toppick-reason{font-size:11px;color:#6b7280;line-height:1.45;margin-top:8px;margin-bottom:12px;flex:1 1 auto;min-height:0;display:-webkit-box;-webkit-line-clamp:3;line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}.gengage-chat-ai-toppick-review{font-size:12px;font-style:italic;color:var(--gengage-text-secondary, #64748b);margin:6px 0 0;padding-left:8px;border-left:2px solid var(--gengage-border-color, #e2e8f0);display:-webkit-box;-webkit-line-clamp:2;line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.gengage-chat-ai-toppick-price{font-size:14px;font-weight:700;color:var(--gengage-text-primary, #1e293b);margin-top:4px}.gengage-chat-ai-toppick-original-price{text-decoration:line-through;color:var(--gengage-text-secondary, #64748b);font-weight:400;font-size:12px}.gengage-chat-ai-toppick-cta{display:block;width:calc(100% - 24px);margin:14px 12px 12px;padding:8px 0;border:none;border-radius:8px;background:var(--gengage-primary-color, #b7102a);color:#fff;font-size:13px;font-weight:600;cursor:pointer;text-align:center;transition:background .15s ease;flex-shrink:0;align-self:stretch;box-sizing:border-box}.gengage-chat-ai-toppick-cta:hover{filter:brightness(.92)}.gengage-chat-ai-toppick-spinner{position:absolute;inset:0;background:#ffffffb3;display:flex;align-items:center;justify-content:center;border-radius:12px;z-index:6}.gengage-chat-ai-toppick-spinner:after{content:"";width:24px;height:24px;border:3px solid var(--gengage-border, #e2e8f0);border-top-color:var(--gengage-accent-primary, #3b82f6);border-radius:50%;animation:gengage-spin .7s linear infinite}@keyframes gengage-spin{to{transform:rotate(360deg)}}.gengage-chat-root--mobile .gengage-chat-ai-top-picks-scroll{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;overflow:visible;padding:10px 0 4px}.gengage-chat-root--mobile .gengage-chat-ai-toppick-card--winner,.gengage-chat-root--mobile .gengage-chat-ai-toppick-card--compact{width:100%;min-width:0;max-width:none;flex-shrink:1;scroll-snap-align:none}.gengage-chat-root--mobile .gengage-chat-ai-toppick-card--compact{flex-direction:column;align-items:stretch}.gengage-chat-root--mobile .gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-media,.gengage-chat-root--mobile .gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-media{max-height:76px;margin-top:4px;margin-bottom:6px}.gengage-chat-root--mobile .gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-img,.gengage-chat-root--mobile .gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-img{max-height:76px}.gengage-chat-root--mobile .gengage-chat-ai-toppick-badge{top:-8px;left:6px;font-size:7px;padding:2px 5px;max-width:calc(100% - 12px)}.gengage-chat-root--mobile .gengage-chat-ai-toppick-card--compact .gengage-chat-ai-toppick-cta,.gengage-chat-root--mobile .gengage-chat-ai-toppick-card--winner .gengage-chat-ai-toppick-cta{width:calc(100% - 20px);margin:12px 10px 10px;align-self:stretch}.gengage-chat-root--mobile .gengage-chat-rollback-btn{left:-24px}.gengage-chat-grounding-review{display:flex;align-items:center;gap:12px;padding:12px 16px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:10px;transition:background .15s ease,border-color .15s ease}.gengage-chat-grounding-review:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #b7102a)}.gengage-chat-grounding-review-icon{font-size:20px;flex-shrink:0}.gengage-chat-grounding-review-body{flex:1;min-width:0}.gengage-chat-grounding-review-title{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-grounding-review-subtitle{font-size:12px;color:var(--gengage-text-muted, #64748b);margin-top:2px}.gengage-chat-grounding-review-cta{font-size:13px;font-weight:500;color:var(--gengage-primary-color, #b7102a);white-space:nowrap;flex-shrink:0}.gengage-chat-grouping-cards{display:flex;flex-direction:column;gap:6px}.gengage-chat-grouping-cards-scroll{display:flex;flex-direction:column;gap:6px;min-width:0}.gengage-chat-grouping-card{display:flex;align-items:center;gap:10px;padding:8px 12px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:8px;transition:background .15s ease,border-color .15s ease}.gengage-chat-grouping-card:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #b7102a)}.gengage-chat-grouping-card-arrow{display:none;font-size:14px;color:var(--gengage-primary-color, #b7102a);flex-shrink:0}.gengage-chat-grouping-card-img{width:48px;height:48px;min-width:48px;min-height:48px;border-radius:4px;object-fit:cover;flex-shrink:0}.gengage-chat-grouping-card-body{flex:1;min-width:0;display:flex;align-items:baseline;gap:6px;flex-wrap:wrap}.gengage-chat-grouping-card-name{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-grouping-card-desc{font-size:12px;color:var(--gengage-text-muted, #64748b)}.gengage-chat-grouping-card-labels{display:block;font-size:11px;color:var(--gengage-chat-text-secondary, #888);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.gengage-chat-root--mobile .gengage-chat-grouping-card-img{display:none}.gengage-chat-root--mobile .gengage-chat-grouping-card-arrow{display:inline}.gengage-chat-suggested-search-cards{display:flex;flex-direction:column;gap:8px}.gengage-chat-suggested-search-card{display:flex;align-items:flex-start;gap:12px;padding:10px 14px;background:var(--gengage-surface-color, #f8fafc);border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:10px;transition:background .15s ease,border-color .15s ease}.gengage-chat-suggested-search-card:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #b7102a)}.gengage-chat-suggested-search-card-img{width:40px;height:40px;border-radius:6px;object-fit:cover;flex-shrink:0}.gengage-chat-suggested-search-card-body{flex:1;min-width:0}.gengage-chat-suggested-search-card-name{font-weight:600;font-size:13px;color:var(--gengage-text-color, #1e293b)}.gengage-chat-suggested-search-card-desc{font-size:12px;color:var(--gengage-text-secondary, #475569);margin-top:2px}.gengage-chat-suggested-search-card-diff{font-size:11px;color:var(--gengage-text-muted, #64748b);margin-top:2px;font-style:italic}.gengage-chat-product-details-gallery{position:relative}.gengage-chat-product-details-gallery .gengage-chat-product-details-img{touch-action:pan-y}.gengage-chat-product-gallery-thumbs{display:flex;gap:8px;padding:10px 0 4px;overflow-x:auto;scrollbar-width:thin;justify-content:center;width:100%}.gengage-chat-product-gallery-thumb{width:56px;height:56px;object-fit:cover;border-radius:8px;border:2px solid transparent;cursor:pointer;flex-shrink:0;transition:border-color .15s ease;background:#fff}.gengage-chat-product-gallery-thumb:hover{border-color:var(--gengage-border-color, #cbd5e1)}.gengage-chat-product-gallery-thumb--active{border-color:var(--gengage-primary-color, #b7102a)}.gengage-chat-product-gallery-thumb-more{display:flex;align-items:center;justify-content:center;width:56px;height:56px;border-radius:8px;background:var(--_gengage-surface-muted, #f1f5f9);color:var(--_gengage-text-secondary, #64748b);font-size:13px;font-weight:600;flex-shrink:0}.gengage-chat-product-variants{margin-top:12px}.gengage-chat-product-variants-label{font-size:12px;font-weight:600;color:var(--gengage-text-muted, #64748b);margin-bottom:6px;text-transform:none;letter-spacing:.5px}.gengage-chat-product-variants-list{display:flex;flex-wrap:wrap;gap:6px}.gengage-chat-product-variant-btn{padding:6px 12px;border:1px solid var(--gengage-border-color, #e2e8f0);border-radius:6px;background:var(--gengage-surface-color, #f8fafc);color:var(--gengage-text-color, #1e293b);font-size:12px;cursor:pointer;transition:background .15s ease,border-color .15s ease}.gengage-chat-product-variant-btn:hover{background:var(--gengage-hover-color, #f1f5f9);border-color:var(--gengage-primary-color, #b7102a)}.gengage-chat-product-grid-wrapper{display:flex;flex-direction:column;gap:8px}.gengage-chat-product-sort-toolbar{display:flex;gap:4px;padding:4px;background:var(--gengage-surface-color, #f8fafc);border-radius:8px;border:1px solid var(--gengage-border-color, #e2e8f0)}.gengage-chat-product-sort-btn{flex:1;padding:6px 10px;border:1px solid var(--_gengage-border-color);border-radius:6px;background:transparent;color:var(--_gengage-text-secondary);font-size:12px;font-weight:500;cursor:pointer;transition:background .15s ease,color .15s ease}.gengage-chat-product-sort-btn:hover{background:var(--gengage-hover-color, #f1f5f9);color:var(--gengage-text-color, #1e293b)}.gengage-chat-product-sort-btn--active,.gengage-chat-product-sort-btn--active:hover{background:var(--gengage-primary-color, #b7102a);color:#fff}.gengage-chat-product-sort-separator{width:1px;background:var(--gengage-border-color, #e2e8f0);margin:2px}.gengage-chat-comparison-toggle-btn{flex:none;padding:6px 10px;border:none;border-radius:6px;background:transparent;color:var(--gengage-text-muted, #64748b);font-size:12px;font-weight:500;cursor:pointer;transition:background .15s ease,color .15s ease;white-space:nowrap}.gengage-chat-comparison-toggle-btn:hover{background:var(--gengage-hover-color, #f1f5f9);color:var(--gengage-text-color, #1e293b)}.gengage-chat-comparison-toggle-btn--active{background:transparent;border:1px solid var(--gengage-primary-color, #b7102a);color:var(--gengage-primary-color, #b7102a)}.gengage-chat-comparison-toggle-btn--active:hover{background:var(--gengage-primary-color, #b7102a);color:#fff}.gengage-chat-comparison-select-wrapper{position:relative}.gengage-chat-comparison-checkbox{position:absolute;top:8px;left:8px;right:auto;z-index:4;width:20px;height:20px;cursor:pointer;accent-color:var(--gengage-primary-color, #b7102a);background:#fff;border-radius:4px;box-shadow:0 1px 3px #00000026}.gengage-chat-comparison-toggle-btn--hidden{opacity:0;pointer-events:none}@keyframes gengage-comparison-fade-in{0%{opacity:0}to{opacity:1}}.gengage-chat-comparison-toggle-btn--reveal{animation:gengage-comparison-fade-in .5s ease forwards}@media(prefers-reduced-motion:reduce){.gengage-chat-comparison-toggle-btn--reveal{animation:none;opacity:1}}.gengage-chat-comparison-floating-btn{display:block;width:100%;padding:10px 16px;border:none;border-radius:8px;background:var(--gengage-primary-color, #b7102a);color:#fff;font-size:14px;font-weight:600;cursor:pointer;transition:background .15s ease;text-align:center;position:sticky;bottom:0;z-index:5;box-shadow:0 -2px 8px #0000001a}.gengage-chat-comparison-floating-btn:hover:not(:disabled){background:var(--gengage-primary-hover, #9a0d23)}.gengage-chat-comparison-floating-btn--disabled{background:#94a3b8;cursor:default;opacity:.8}.gengage-chat-panel-topbar{display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid var(--_gengage-border-color);background:var(--_gengage-surface-muted);min-height:44px;flex-shrink:0;position:sticky;top:0;z-index:3}.gengage-chat-panel-topbar-back,.gengage-chat-panel-topbar-forward{width:28px;height:28px;min-width:28px;padding:0;border:1px solid #d1d5db;border-radius:6px;background:transparent;color:#374151;font-size:14px;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background .15s ease,border-color .15s ease,opacity .15s ease}.gengage-chat-panel-topbar-back:hover:not(:disabled),.gengage-chat-panel-topbar-forward:hover:not(:disabled){background:var(--_gengage-surface-secondary);border-color:#9ca3af}.gengage-chat-panel-topbar-back:disabled,.gengage-chat-panel-topbar-forward:disabled{opacity:.3;cursor:default}.gengage-chat-panel-topbar-title{flex:1;font-size:14px;font-weight:600;color:var(--_gengage-text-primary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-align:center}@keyframes gengage-typewriter-fade-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-typewriter-block{display:block;animation:gengage-typewriter-fade-in .15s ease both}@media(prefers-reduced-motion:reduce){.gengage-chat-typewriter-block{animation:none}}.gengage-product-mention{color:var(--gengage-primary-color, #b7102a);text-decoration:none;cursor:pointer;font-weight:500;border-bottom:1px dashed var(--gengage-primary-color, #b7102a);transition:border-color .15s}.gengage-product-mention:hover{border-bottom-style:solid}@keyframes gengage-skeleton-pulse{0%,to{opacity:.4}50%{opacity:.8}}.gengage-chat-panel-skeleton-block{animation:gengage-skeleton-pulse 1.5s ease-in-out infinite}@media(prefers-reduced-motion:reduce){.gengage-chat-panel-skeleton-block{animation:none}}.gengage-chat-input-chips{display:flex;gap:6px;padding:4px 12px 2px;flex-wrap:nowrap;overflow-x:auto;scrollbar-width:none;-ms-overflow-style:none}.gengage-chat-input-chips::-webkit-scrollbar{display:none}.gengage-chat-input-chip{display:inline-flex;align-items:center;padding:4px 10px;border-radius:12px;border:1px solid var(--_gengage-border-color);background:#f9fafb;color:#374151;font-size:12px;font-weight:500;font-family:inherit;cursor:pointer;transition:background .12s,border-color .12s;white-space:nowrap}.gengage-chat-input-chip:hover{background:var(--_gengage-surface-secondary);border-color:#d1d5db}.gengage-chat-icon{width:14px;height:14px;flex-shrink:0}.gengage-chat-input-chip-icon,.gengage-chat-pill-icon{display:inline-flex;align-items:center;margin-right:4px}.gengage-chat-product-card-img-wrapper,.gengage-chat-product-details-img-wrap{position:relative;overflow:hidden}.gengage-chat-product-card-discount-badge{position:absolute;top:8px;left:8px;padding:3px 8px;border-radius:4px;background:var(--_gengage-discount-color);color:#fff;font-size:11px;font-weight:700;line-height:1.3;z-index:1}.gengage-chat-product-card-stock{font-size:11px;font-weight:600;margin-top:2px;padding:2px 6px;border-radius:4px;width:fit-content}.gengage-chat-product-card-stock.is-in-stock{background:#ecfdf5;color:#065f46}.gengage-chat-product-card-stock.is-out-of-stock{background:#fef2f2;color:#dc2626}.gengage-chat-find-similar-pill{position:absolute;top:40px;right:8px;opacity:0;pointer-events:none;transition:opacity .2s ease;padding:4px 10px;font-size:11px;font-weight:500;font-family:inherit;border:none;border-radius:12px;background:var(--gengage-chat-pill-bg, rgba(0, 0, 0, .7));color:var(--gengage-chat-pill-text, #fff);cursor:pointer;white-space:nowrap;z-index:2}.gengage-chat-product-card-img-wrapper:hover .gengage-chat-find-similar-pill,.gengage-chat-product-details-img-wrap:hover .gengage-chat-find-similar-pill{opacity:1;pointer-events:auto}.gengage-chat-favorite-btn{position:absolute;top:8px;right:8px;background:#ffffffe6;border:none;border-radius:50%;width:28px;height:28px;display:flex;align-items:center;justify-content:center;cursor:pointer;color:var(--gengage-text-secondary, #64748b);z-index:3;transition:color .2s;padding:0}.gengage-chat-favorite-btn:hover,.gengage-chat-favorite-btn--active{color:var(--gengage-accent-primary, #ef4444)}.gengage-chat-product-card-promos,.gengage-chat-product-details-promos{display:flex;flex-wrap:wrap;gap:4px;margin-top:4px}.gengage-chat-product-card-promo-badge,.gengage-chat-product-details-promo-badge{display:inline-block;padding:2px 6px;font-size:10px;font-weight:500;border-radius:4px;background:var(--gengage-chat-promo-bg, #e8f5e9);color:var(--gengage-chat-promo-text, #2e7d32);white-space:nowrap;min-height:20px;box-sizing:border-box}.gengage-chat-thumbnails-column{display:none!important;pointer-events:none}.gengage-chat-thumbnail-btn{display:flex;align-items:center;justify-content:center;width:40px;height:40px;padding:0;border:2px solid var(--_gengage-border-color);border-radius:6px;background:#fff;cursor:pointer;overflow:hidden;transition:border-color .15s ease}.gengage-chat-thumbnail-btn:hover{border-color:var(--gengage-primary-color, #b7102a)}.gengage-chat-thumbnail-img{width:100%;height:100%;object-fit:cover}.gengage-chat-panel-float{position:sticky;bottom:0;height:0;overflow:visible;pointer-events:none;z-index:10}.gengage-chat-choice-prompter{position:absolute;bottom:12px;right:12px;pointer-events:auto;width:200px;padding:12px 14px;background:#fff;border:1px solid var(--_gengage-border-color);border-radius:10px;box-shadow:0 4px 12px #0000001a;z-index:5;animation:gengage-choice-prompter-in .2s ease}@keyframes gengage-choice-prompter-in{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}.gengage-chat-choice-prompter-heading{font-size:13px;font-weight:600;color:var(--_gengage-text-primary);margin-bottom:4px}.gengage-chat-choice-prompter-suggestion{font-size:12px;color:#6b7280;margin-bottom:10px;line-height:1.4}.gengage-chat-choice-prompter-cta{display:block;width:100%;padding:6px 12px;border:none;border-radius:6px;background:var(--gengage-primary-color, #b7102a);color:#fff;font-size:12px;font-weight:600;font-family:inherit;cursor:pointer;text-align:center;transition:opacity .15s ease}.gengage-chat-choice-prompter-cta:hover{opacity:.9}.gengage-chat-choice-prompter-dismiss{position:absolute;top:8px;right:8px;padding:4px 8px;min-width:28px;min-height:28px;display:flex;align-items:center;justify-content:center;border:none;background:none;color:#6b7280;font-size:16px;cursor:pointer;line-height:1}.gengage-chat-choice-prompter-dismiss:hover{color:#6b7280}@media(prefers-reduced-motion:reduce){.gengage-chat-choice-prompter{animation:none}}.gengage-chat-pros-cons{padding:12px 14px;background:var(--_gengage-surface-muted);border-radius:8px;margin:8px 0}.gengage-chat-pros-cons-heading{margin:0 0 10px;font-size:14px;font-weight:600;color:#0f172a}.gengage-chat-pros-cons-list{list-style:none;margin:0 0 8px;padding:0}.gengage-chat-pros-cons-list:last-child{margin-bottom:0}.gengage-chat-pros-cons-item{display:flex;align-items:flex-start;gap:8px;padding:4px 0;font-size:13px;line-height:1.5;color:#334155}.gengage-chat-pros-cons-icon{flex-shrink:0;width:18px;height:18px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;border-radius:50%}.gengage-chat-pros-cons-icon--pro{color:var(--_gengage-success-color);background:color-mix(in srgb,var(--_gengage-success-color) 15%,#fff)}.gengage-chat-pros-cons-icon--con{color:#dc2626;background:#fee2e2}.gengage-chat-categories{display:flex;flex-direction:column;gap:8px}.gengage-chat-categories-tabs{display:flex;gap:4px;overflow-x:auto;padding:4px 0;-webkit-overflow-scrolling:touch}.gengage-chat-categories-tab{padding:6px 14px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:20px;background:var(--gengage-bg, #fff);color:var(--gengage-text, #374151);cursor:pointer;white-space:nowrap;font-size:13px;transition:background .15s,color .15s}.gengage-chat-categories-tab:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-categories-tab--active{background:var(--gengage-primary, #2563eb);color:#fff;border-color:var(--gengage-primary, #2563eb)}.gengage-chat-categories-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:8px}.gengage-chat-categories-filter-tags{display:flex;gap:6px;flex-wrap:wrap;margin-top:4px}.gengage-chat-categories-filter-tag{padding:4px 10px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:14px;background:var(--gengage-bg, #fff);color:var(--gengage-text-secondary, #6b7280);font-size:12px;cursor:pointer;transition:background .15s}.gengage-chat-categories-filter-tag:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-product-grid-view-more{display:block;width:100%;padding:10px;margin-top:8px;border:1px solid var(--gengage-border-color, #e5e7eb);border-radius:8px;background:var(--gengage-bg, #fff);color:var(--gengage-primary, #2563eb);font-size:14px;font-weight:500;cursor:pointer;text-align:center;transition:background .15s;grid-column:1 / -1}.gengage-chat-product-grid-view-more:hover{background:var(--gengage-bg-hover, #f3f4f6)}.gengage-chat-product-grid--mobile{display:flex;overflow-x:auto;gap:8px;padding:8px 0;-webkit-overflow-scrolling:touch}.gengage-chat-product-grid--mobile .gengage-chat-product-card{min-width:160px;max-width:180px;flex-shrink:0}.gengage-chat-comparison--mobile{overflow-x:clip;position:relative}.gengage-chat-comparison--mobile .gengage-chat-comparison-table-wrapper{overflow-x:auto;-webkit-overflow-scrolling:touch;touch-action:pan-x pan-y;-webkit-mask-image:linear-gradient(to right,#000 88%,transparent);mask-image:linear-gradient(to right,#000 88%,transparent)}.gengage-chat-comparison--mobile .gengage-chat-comparison-table{min-width:480px}.gengage-chat-comparison--mobile .gengage-chat-comparison-table th:first-child,.gengage-chat-comparison--mobile .gengage-chat-comparison-table .gengage-chat-comparison-label{position:sticky;left:0;background:var(--gengage-background-color, #fff);z-index:1;box-shadow:2px 0 4px #0000000f}.gengage-chat-comparison-key-differences{margin-top:12px;padding:12px;background:var(--gengage-bg-secondary, #f9fafb);border-radius:8px}.gengage-chat-comparison-key-differences h4{margin:0 0 8px;font-size:14px;font-weight:600;color:var(--gengage-text, #374151)}.gengage-chat-comparison-key-differences-content{font-size:13px;color:var(--gengage-text-secondary, #6b7280);line-height:1.5}.gengage-chat-comparison-key-differences-content ul{margin:0;padding-left:18px}.gengage-chat-comparison-key-differences-content li{margin-bottom:4px}.gengage-chat-product-details-similars-heading{margin:16px 0 8px;font-size:15px;font-weight:600;color:var(--gengage-text, #374151)}.gengage-chat-product-details-similars{margin-top:8px}.gengage-chat-handoff-notice{display:flex;flex-direction:column;align-items:center;gap:6px;padding:16px;margin:8px 0;background:#fef3c7;border:1px solid #fcd34d;border-radius:8px;text-align:center}.gengage-chat-handoff-notice-icon{font-size:24px}.gengage-chat-handoff-notice-heading{margin:0;font-size:14px;font-weight:600;color:#92400e}.gengage-chat-handoff-notice-summary{margin:0;font-size:13px;line-height:1.5;color:#78350f}.gengage-qty-stepper{display:inline-flex;align-items:center;gap:0;border:1px solid #d1d5db;border-radius:8px;overflow:hidden;background:#fff}.gengage-qty-btn{width:var(--_gengage-qty-btn-size);height:var(--_gengage-qty-btn-size);border:none;background:transparent;color:#374151;font-size:14px;font-weight:600;font-family:inherit;cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background-color .12s}.gengage-qty-btn:hover:not(:disabled){background:var(--_gengage-surface-secondary)}.gengage-qty-btn:disabled{opacity:.35;cursor:default}.gengage-qty-value{min-width:24px;text-align:center;font-size:13px;font-weight:600;color:var(--_gengage-text-primary);-webkit-user-select:none;user-select:none}.gengage-qty-submit{border:none;border-left:1px solid #d1d5db;background:var(--_gengage-success-color);color:#fff;font-size:13px;font-weight:700;font-family:inherit;cursor:pointer;padding:6px 12px;transition:filter .12s ease,transform .12s ease}.gengage-qty-submit:hover{filter:brightness(1.08)}.gengage-qty-submit:active{transform:translateY(1px)}.gengage-qty-submit--success{background:var(--_gengage-success-color);transition:background .2s ease}.gengage-qty-stepper--compact{border-radius:14px;box-shadow:0 2px 6px #0000001f}.gengage-qty-stepper--compact .gengage-qty-btn{width:var(--_gengage-qty-btn-size-compact);height:var(--_gengage-qty-btn-size-compact);font-size:12px}.gengage-qty-stepper--compact .gengage-qty-value{min-width:18px;font-size:12px}.gengage-qty-stepper--compact .gengage-qty-submit{padding:4px 8px;font-size:13px}.gengage-chat-panel .gengage-qty-stepper{border:1px solid var(--_gengage-border-color);border-radius:8px;overflow:hidden}.gengage-chat-panel .gengage-qty-stepper button,.gengage-chat-panel .gengage-qty-stepper .gengage-qty-value{border:none;border-right:1px solid var(--_gengage-border-color)}.gengage-chat-panel .gengage-qty-stepper .gengage-qty-submit{border-right:none}.gengage-chat-product-details-atc-stepper{border-radius:10px}.gengage-chat-product-details-atc-stepper .gengage-qty-btn{width:32px;height:32px}.gengage-chat-product-details-atc-stepper .gengage-qty-value{min-width:28px;font-size:14px}.gengage-chat-product-details-atc-stepper .gengage-qty-submit{padding:8px 18px;font-size:14px}.gengage-chat-product-details-share{display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;border:1px solid #d1d5db;border-radius:10px;background:transparent;color:#6b7280;cursor:pointer;transition:color .12s,border-color .12s,background-color .12s;position:relative;flex-shrink:0}.gengage-chat-product-details-share:hover{color:var(--gengage-primary-color, #b7102a);border-color:var(--gengage-primary-color, #b7102a);background:#f0f7ff}.gengage-chat-product-details-share:before{content:attr(aria-label);position:absolute;bottom:calc(100% + 6px);left:50%;transform:translate(-50%);padding:4px 8px;border-radius:4px;background:var(--_gengage-surface-dark);color:#fff;font-size:11px;font-weight:500;white-space:nowrap;pointer-events:none;opacity:0;transition:opacity .15s ease;z-index:2}.gengage-chat-product-details-share:hover:before{opacity:1}.gengage-chat-product-details-share--copied:after{content:"✓";position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:var(--_gengage-success-color);color:#fff;border-radius:10px;font-size:16px;font-weight:700}.gengage-chat-product-details-share svg{width:20px;height:20px}.gengage-chat-review-link,.gengage-chat-grounding-link{text-decoration:underline;color:var(--gengage-primary-color, #b7102a)}@media(max-width:768px){.gengage-chat-product-card-promo-badge,.gengage-chat-product-details-promo-badge{-webkit-line-clamp:2;line-clamp:2;display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden;white-space:normal}}.gengage-chat-launcher:focus-visible,.gengage-chat-close:focus-visible,.gengage-chat-header-btn:focus-visible,.gengage-chat-header-powered:focus-visible,.gengage-chat-send:focus-visible,.gengage-chat-action-btn:focus-visible,.gengage-chat-pill:focus-visible,.gengage-chat-input-chip:focus-visible,.gengage-chat-pills-arrow:focus-visible,.gengage-chat-error-retry:focus-visible,.gengage-chat-product-card-cta:focus-visible,.gengage-chat-product-details-cta:focus-visible,.gengage-chat-product-details-atc:focus-visible,.gengage-chat-product-detail-tab:focus-visible,.gengage-chat-panel-divider-toggle:focus-visible,.gengage-chat-panel-topbar-back:focus-visible,.gengage-chat-panel-topbar-forward:focus-visible,.gengage-chat-rollback-btn:focus-visible,.gengage-chat-ai-toppick-cta:focus-visible,.gengage-chat-comparison-view-btn:focus-visible,.gengage-chat-comparison-toggle-btn:focus-visible,.gengage-chat-comparison-floating-btn:focus-visible,.gengage-chat-comparison-checkbox:focus-visible,.gengage-chat-product-sort-btn:focus-visible,.gengage-chat-product-variant-btn:focus-visible,.gengage-chat-product-gallery-thumb:focus-visible,.gengage-chat-thumbnail-btn:focus-visible,.gengage-chat-find-similar-pill:focus-visible,.gengage-chat-favorite-btn:focus-visible,.gengage-chat-attach-btn:focus-visible,.gengage-chat-mic-btn:focus-visible,.gengage-chat-attachment-remove:focus-visible,.gengage-chat-kvkk-dismiss:focus-visible,.gengage-chat-choice-prompter-cta:focus-visible,.gengage-chat-choice-prompter-dismiss:focus-visible,.gengage-chat-categories-tab:focus-visible,.gengage-chat-categories-filter-tag:focus-visible,.gengage-chat-product-grid-view-more:focus-visible,.gengage-chat-product-details-share:focus-visible,.gengage-qty-btn:focus-visible,.gengage-qty-submit:focus-visible{outline:2px solid var(--gengage-primary-color, #b7102a);outline-offset:2px}.gengage-chat-root--mobile .gengage-chat-choice-prompter{left:12px;right:12px;width:auto;max-width:none;bottom:12px;max-height:40vh;overflow-y:auto}.gengage-chat-root--mobile .gengage-chat-product-sort-btn,.gengage-chat-root--mobile .gengage-chat-comparison-toggle-btn{min-height:40px}.gengage-chat-root--mobile .gengage-chat-input-chip{min-height:40px;padding:8px 12px}.gengage-chat-root--mobile .gengage-chat-choice-prompter-dismiss{width:32px;height:32px}.gengage-chat-root--mobile .gengage-chat-panel-divider-toggle{min-height:44px}.gengage-chat-root--mobile .gengage-chat-product-details-atc-stepper .gengage-qty-btn{width:44px;height:44px}.gengage-chat-root--mobile .gengage-chat-product-details-atc-stepper .gengage-qty-submit,.gengage-chat-root--mobile .gengage-qty-stepper--compact .gengage-qty-submit{min-height:44px}.gengage-chat-root--mobile .gengage-qty-stepper--compact .gengage-qty-submit{min-width:44px;padding:0 10px}.gengage-chat-root--mobile .gengage-qty-stepper--compact .gengage-qty-btn{width:44px;height:44px;font-size:14px}.gengage-chat-root--mobile .gengage-qty-stepper--compact .gengage-qty-value{min-width:24px;font-size:13px}.gengage-chat-root--mobile .gengage-chat-product-card-cta,.gengage-chat-root--mobile .gengage-chat-choice-prompter-cta,.gengage-chat-root--mobile .gengage-chat-product-grid-view-more{min-height:44px;display:flex;align-items:center;justify-content:center}.gengage-chat-root--mobile .gengage-chat-panel-topbar-back,.gengage-chat-root--mobile .gengage-chat-panel-topbar-forward,.gengage-chat-root--mobile .gengage-chat-favorite-btn,.gengage-chat-root--mobile .gengage-chat-product-details-share{width:44px;height:44px}.gengage-skeleton{display:flex;gap:12px;padding:12px}.gengage-skeleton--message{flex-direction:column;gap:8px;padding:16px}.gengage-skeleton-card{flex:1;display:flex;flex-direction:column;gap:8px}.gengage-skeleton-img{height:120px;border-radius:8px}.gengage-skeleton-text{height:14px;border-radius:4px}.gengage-skeleton-price{height:14px;width:60%;border-radius:4px}.gengage-skeleton-line{height:12px;border-radius:4px}@media(prefers-reduced-motion:no-preference){.gengage-skeleton-card,.gengage-skeleton-line,.gengage-skeleton-img,.gengage-skeleton-text,.gengage-skeleton-price{background:linear-gradient(90deg,#f0f0f0 25%,#e0e0e0,#f0f0f0 75%);background-size:200% 100%;animation:gengage-shimmer 1.5s infinite}@keyframes gengage-shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}}@media(prefers-reduced-motion:reduce){.gengage-skeleton-card,.gengage-skeleton-line,.gengage-skeleton-img,.gengage-skeleton-text,.gengage-skeleton-price{background:#f0f0f0}}.gengage-chat-panel--has-scroll:after{content:"";position:sticky;bottom:0;display:block;height:40px;background:linear-gradient(transparent,var(--gengage-chat-panel-bg, #f5f5f5));pointer-events:none}@media(prefers-reduced-motion:no-preference){.gengage-chat-panel--transitioning{opacity:0;transition:opacity .15s ease}}';function ts(){return typeof window<"u"&&Array.isArray(window.dataLayer)}function ie(e,t){const n={event:e,...t};ts()&&window.dataLayer.push(n)}function ns(e){ie("gengage-on-init",{gengage_widget:e})}function as(e){ie("gengage-show",{gengage_widget:e})}function is(e,t){ie("gengage-suggested-question",{gengage_question_title:e,gengage_action_type:t})}function os(e){ie("gengage-find-similars",{gengage_sku:e})}function rs(e){ie("gengage-compare-preselection",{gengage_sku:e})}function Nn(e){ie("gengage-compare-selected",{gengage_skus:e,gengage_product_count:e.length})}function ss(){ie("gengage-compare-clear")}function cs(e){ie("gengage-compare-received",{gengage_product_count:e})}function ls(e){ie("gengage-like-product",{gengage_sku:e})}function gs(){ie("gengage-like-list")}function ds(e,t){ie("gengage-search",{gengage_search_query:e,gengage_result_count:t})}function ps(e,t){ie("gengage-product-detail",{gengage_sku:e,gengage_product_name:t})}function hs(e,t){ie("gengage-cart-add",{gengage_sku:e,gengage_quantity:t})}function us(){ie("gengage-message-sent")}function Mn(){ie("gengage-message-received")}function fs(){ie("gengage-conversation-start")}function ms(){ie("gengage-voice-input")}function m(e,t,n){function a(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:r,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,c);const l=r.prototype,g=Object.keys(l);for(let p=0;p<g.length;p++){const d=g[p];d in s||(s[d]=l[d].bind(s))}}const i=n?.Parent??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function r(s){var c;const l=n?.Parent?new o:this;a(l,s),(c=l._zod).deferred??(c.deferred=[]);for(const g of l._zod.deferred)g();return l}return Object.defineProperty(r,"init",{value:a}),Object.defineProperty(r,Symbol.hasInstance,{value:s=>n?.Parent&&s instanceof n.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(r,"name",{value:e}),r}class Ze extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Bn extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const Rn={};function Ie(e){return Rn}function On(e){const t=Object.values(e).filter(a=>typeof a=="number");return Object.entries(e).filter(([a,i])=>t.indexOf(+a)===-1).map(([a,i])=>i)}function Lt(e,t){return typeof t=="bigint"?t.toString():t}function zt(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Nt(e){return e==null}function Mt(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function bs(e,t){const n=(e.toString().split(".")[1]||"").length,a=t.toString();let i=(a.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(a)){const c=a.match(/\d?e-(\d?)/);c?.[1]&&(i=Number.parseInt(c[1]))}const o=n>i?n:i,r=Number.parseInt(e.toFixed(o).replace(".","")),s=Number.parseInt(t.toFixed(o).replace(".",""));return r%s/10**o}const $n=Symbol("evaluating");function j(e,t,n){let a;Object.defineProperty(e,t,{get(){if(a!==$n)return a===void 0&&(a=$n,a=n()),a},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Re(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Pe(...e){const t={};for(const n of e){const a=Object.getOwnPropertyDescriptors(n);Object.assign(t,a)}return Object.defineProperties({},t)}function Dn(e){return JSON.stringify(e)}function _s(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Fn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ot(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const vs=zt(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function je(e){if(ot(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ot(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Un(e){return je(e)?{...e}:Array.isArray(e)?[...e]:e}const ys=new Set(["string","number","symbol"]);function rt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Le(e,t,n){const a=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(a._zod.parent=e),a}function z(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function ws(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const xs={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ks(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o=Pe(e._zod.def,{get shape(){const r={};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(r[s]=n.shape[s])}return Re(this,"shape",r),r},checks:[]});return Le(e,o)}function Cs(e,t){const n=e._zod.def,a=n.checks;if(a&&a.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=Pe(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete r[s]}return Re(this,"shape",r),r},checks:[]});return Le(e,o)}function Es(e,t){if(!je(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const o=e._zod.def.shape;for(const r in t)if(Object.getOwnPropertyDescriptor(o,r)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const i=Pe(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return Re(this,"shape",o),o}});return Le(e,i)}function Ss(e,t){if(!je(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Pe(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t};return Re(this,"shape",a),a}});return Le(e,n)}function Ts(e,t){const n=Pe(e._zod.def,{get shape(){const a={...e._zod.def.shape,...t._zod.def.shape};return Re(this,"shape",a),a},get catchall(){return t._zod.def.catchall},checks:[]});return Le(e,n)}function As(e,t,n){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const r=Pe(t._zod.def,{get shape(){const s=t._zod.def.shape,c={...s};if(n)for(const l in n){if(!(l in s))throw new Error(`Unrecognized key: "${l}"`);n[l]&&(c[l]=e?new e({type:"optional",innerType:s[l]}):s[l])}else for(const l in s)c[l]=e?new e({type:"optional",innerType:s[l]}):s[l];return Re(this,"shape",c),c},checks:[]});return Le(t,r)}function Is(e,t,n){const a=Pe(t._zod.def,{get shape(){const i=t._zod.def.shape,o={...i};if(n)for(const r in n){if(!(r in o))throw new Error(`Unrecognized key: "${r}"`);n[r]&&(o[r]=new e({type:"nonoptional",innerType:i[r]}))}else for(const r in i)o[r]=new e({type:"nonoptional",innerType:i[r]});return Re(this,"shape",o),o}});return Le(t,a)}function qe(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function He(e,t){return t.map(n=>{var a;return(a=n).path??(a.path=[]),n.path.unshift(e),n})}function st(e){return typeof e=="string"?e:e?.message}function ze(e,t,n){const a={...e,path:e.path??[]};if(!e.message){const i=st(e.inst?._zod.def?.error?.(e))??st(t?.error?.(e))??st(n.customError?.(e))??st(n.localeError?.(e))??"Invalid input";a.message=i}return delete a.inst,delete a.continue,t?.reportInput||delete a.input,a}function Bt(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Je(...e){const[t,n,a]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:a}:{...t}}const Zn=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Lt,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},jn=m("$ZodError",Zn),qn=m("$ZodError",Zn,{Parent:Error});function Ps(e,t=n=>n.message){const n={},a=[];for(const i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):a.push(t(i));return{formErrors:a,fieldErrors:n}}function Ls(e,t=n=>n.message){const n={_errors:[]},a=i=>{for(const o of i.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(r=>a({issues:r}));else if(o.code==="invalid_key")a({issues:o.issues});else if(o.code==="invalid_element")a({issues:o.issues});else if(o.path.length===0)n._errors.push(t(o));else{let r=n,s=0;for(;s<o.path.length;){const c=o.path[s];s===o.path.length-1?(r[c]=r[c]||{_errors:[]},r[c]._errors.push(t(o))):r[c]=r[c]||{_errors:[]},r=r[c],s++}}};return a(e),n}const Rt=e=>(t,n,a,i)=>{const o=a?Object.assign(a,{async:!1}):{async:!1},r=t._zod.run({value:n,issues:[]},o);if(r instanceof Promise)throw new Ze;if(r.issues.length){const s=new(i?.Err??e)(r.issues.map(c=>ze(c,o,Ie())));throw Fn(s,i?.callee),s}return r.value},Ot=e=>async(t,n,a,i)=>{const o=a?Object.assign(a,{async:!0}):{async:!0};let r=t._zod.run({value:n,issues:[]},o);if(r instanceof Promise&&(r=await r),r.issues.length){const s=new(i?.Err??e)(r.issues.map(c=>ze(c,o,Ie())));throw Fn(s,i?.callee),s}return r.value},ct=e=>(t,n,a)=>{const i=a?{...a,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new Ze;return o.issues.length?{success:!1,error:new(e??jn)(o.issues.map(r=>ze(r,i,Ie())))}:{success:!0,data:o.value}},zs=ct(qn),lt=e=>async(t,n,a)=>{const i=a?Object.assign(a,{async:!0}):{async:!0};let o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(r=>ze(r,i,Ie())))}:{success:!0,data:o.value}},Ns=lt(qn),Ms=e=>(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Rt(e)(t,n,i)},Bs=e=>(t,n,a)=>Rt(e)(t,n,a),Rs=e=>async(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return Ot(e)(t,n,i)},Os=e=>async(t,n,a)=>Ot(e)(t,n,a),$s=e=>(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return ct(e)(t,n,i)},Ds=e=>(t,n,a)=>ct(e)(t,n,a),Fs=e=>async(t,n,a)=>{const i=a?Object.assign(a,{direction:"backward"}):{direction:"backward"};return lt(e)(t,n,i)},Us=e=>async(t,n,a)=>lt(e)(t,n,a),Zs=/^[cC][^\s-]{8,}$/,js=/^[0-9a-z]+$/,qs=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Hs=/^[0-9a-vA-V]{20}$/,Vs=/^[A-Za-z0-9]{27}$/,Ws=/^[a-zA-Z0-9_-]{21}$/,Gs=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ks=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Hn=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Ys=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Js="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Xs(){return new RegExp(Js,"u")}const Qs=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ec=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,tc=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,nc=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ac=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Vn=/^[A-Za-z0-9_-]*$/,ic=/^\+[1-9]\d{6,14}$/,Wn="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",oc=new RegExp(`^${Wn}$`);function Gn(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function rc(e){return new RegExp(`^${Gn(e)}$`)}function sc(e){const t=Gn({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const a=`${t}(?:${n.join("|")})`;return new RegExp(`^${Wn}T(?:${a})$`)}const cc=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},lc=/^-?\d+$/,Kn=/^-?\d+(?:\.\d+)?$/,gc=/^(?:true|false)$/i,dc=/^[^A-Z]*$/,pc=/^[^a-z]*$/,de=m("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Yn={number:"number",bigint:"bigint",object:"date"},Jn=m("$ZodCheckLessThan",(e,t)=>{de.init(e,t);const n=Yn[typeof t.value];e._zod.onattach.push(a=>{const i=a._zod.bag,o=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value<=t.value:a.value<t.value)||a.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Xn=m("$ZodCheckGreaterThan",(e,t)=>{de.init(e,t);const n=Yn[typeof t.value];e._zod.onattach.push(a=>{const i=a._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=a=>{(t.inclusive?a.value>=t.value:a.value>t.value)||a.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:a.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),hc=m("$ZodCheckMultipleOf",(e,t)=>{de.init(e,t),e._zod.onattach.push(n=>{var a;(a=n._zod.bag).multipleOf??(a.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):bs(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),uc=m("$ZodCheckNumberFormat",(e,t)=>{de.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),a=n?"int":"number",[i,o]=xs[t.format];e._zod.onattach.push(r=>{const s=r._zod.bag;s.format=t.format,s.minimum=i,s.maximum=o,n&&(s.pattern=lc)}),e._zod.check=r=>{const s=r.value;if(n){if(!Number.isInteger(s)){r.issues.push({expected:a,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?r.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort}):r.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:a,inclusive:!0,continue:!t.abort});return}}s<i&&r.issues.push({origin:"number",input:s,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>o&&r.issues.push({origin:"number",input:s,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),fc=m("$ZodCheckMaxLength",(e,t)=>{var n;de.init(e,t),(n=e._zod.def).when??(n.when=a=>{const i=a.value;return!Nt(i)&&i.length!==void 0}),e._zod.onattach.push(a=>{const i=a._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(a._zod.bag.maximum=t.maximum)}),e._zod.check=a=>{const i=a.value;if(i.length<=t.maximum)return;const r=Bt(i);a.issues.push({origin:r,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),mc=m("$ZodCheckMinLength",(e,t)=>{var n;de.init(e,t),(n=e._zod.def).when??(n.when=a=>{const i=a.value;return!Nt(i)&&i.length!==void 0}),e._zod.onattach.push(a=>{const i=a._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(a._zod.bag.minimum=t.minimum)}),e._zod.check=a=>{const i=a.value;if(i.length>=t.minimum)return;const r=Bt(i);a.issues.push({origin:r,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),bc=m("$ZodCheckLengthEquals",(e,t)=>{var n;de.init(e,t),(n=e._zod.def).when??(n.when=a=>{const i=a.value;return!Nt(i)&&i.length!==void 0}),e._zod.onattach.push(a=>{const i=a._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=a=>{const i=a.value,o=i.length;if(o===t.length)return;const r=Bt(i),s=o>t.length;a.issues.push({origin:r,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:a.value,inst:e,continue:!t.abort})}}),gt=m("$ZodCheckStringFormat",(e,t)=>{var n,a;de.init(e,t),e._zod.onattach.push(i=>{const o=i._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(a=e._zod).check??(a.check=()=>{})}),_c=m("$ZodCheckRegex",(e,t)=>{gt.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),vc=m("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=dc),gt.init(e,t)}),yc=m("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=pc),gt.init(e,t)}),wc=m("$ZodCheckIncludes",(e,t)=>{de.init(e,t);const n=rt(t.includes),a=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=a,e._zod.onattach.push(i=>{const o=i._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(a)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),xc=m("$ZodCheckStartsWith",(e,t)=>{de.init(e,t);const n=new RegExp(`^${rt(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=a=>{a.value.startsWith(t.prefix)||a.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:a.value,inst:e,continue:!t.abort})}}),kc=m("$ZodCheckEndsWith",(e,t)=>{de.init(e,t);const n=new RegExp(`.*${rt(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(a=>{const i=a._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=a=>{a.value.endsWith(t.suffix)||a.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:a.value,inst:e,continue:!t.abort})}}),Cc=m("$ZodCheckOverwrite",(e,t)=>{de.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Ec{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const a=t.split(`
59
59
  `).filter(r=>r),i=Math.min(...a.map(r=>r.length-r.trimStart().length)),o=a.map(r=>r.slice(i)).map(r=>" ".repeat(this.indent*2)+r);for(const r of o)this.content.push(r)}compile(){const t=Function,n=this?.args,i=[...(this?.content??[""]).map(o=>` ${o}`)];return new t(...n,i.join(`
60
- `))}}const Cc={major:4,minor:3,patch:6},X=u("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Cc;const a=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&a.unshift(e);for(const i of a)for(const o of i._zod.onattach)o(e);if(a.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const i=(r,s,c)=>{let l=qe(r),d;for(const p of s){if(p._zod.def.when){if(!p._zod.def.when(r))continue}else if(l)continue;const g=r.issues.length,h=p._zod.check(r);if(h instanceof Promise&&c?.async===!1)throw new Ze;if(d||h instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await h,r.issues.length!==g&&(l||(l=qe(r,g)))});else{if(r.issues.length===g)continue;l||(l=qe(r,g))}}return d?d.then(()=>r):r},o=(r,s,c)=>{if(qe(r))return r.aborted=!0,r;const l=i(s,a,c);if(l instanceof Promise){if(c.async===!1)throw new Ze;return l.then(d=>e._zod.parse(d,c))}return e._zod.parse(l,c)};e._zod.run=(r,s)=>{if(s.skipChecks)return e._zod.parse(r,s);if(s.direction==="backward"){const l=e._zod.parse({value:r.value,issues:[]},{...s,skipChecks:!0});return l instanceof Promise?l.then(d=>o(d,r,s)):o(l,r,s)}const c=e._zod.parse(r,s);if(c instanceof Promise){if(s.async===!1)throw new Ze;return c.then(l=>i(l,a,s))}return i(c,a,s)}}q(e,"~standard",()=>({validate:i=>{try{const o=Ps(e,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return Ls(e,i).then(r=>r.success?{value:r.data}:{issues:r.error?.issues})}},vendor:"zod",version:1}))}),Ot=u("$ZodString",(e,t)=>{X.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??rc(e._zod.bag),e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),G=u("$ZodStringFormat",(e,t)=>{ct.init(e,t),Ot.init(e,t)}),Ec=u("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Ws),G.init(e,t)}),Sc=u("$ZodUUID",(e,t)=>{if(t.version){const a={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(a===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=qn(a))}else t.pattern??(t.pattern=qn());G.init(e,t)}),Tc=u("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Gs),G.init(e,t)}),Ac=u("$ZodURL",(e,t)=>{G.init(e,t),e._zod.check=n=>{try{const a=n.value.trim(),i=new URL(a);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=a;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Ic=u("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Ys()),G.init(e,t)}),Pc=u("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Hs),G.init(e,t)}),Lc=u("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Fs),G.init(e,t)}),zc=u("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Us),G.init(e,t)}),Nc=u("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Zs),G.init(e,t)}),Mc=u("$ZodXID",(e,t)=>{t.pattern??(t.pattern=js),G.init(e,t)}),Bc=u("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=qs),G.init(e,t)}),Rc=u("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=oc(t)),G.init(e,t)}),Oc=u("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ac),G.init(e,t)}),$c=u("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=ic(t)),G.init(e,t)}),Dc=u("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Vs),G.init(e,t)}),Fc=u("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Js),G.init(e,t),e._zod.bag.format="ipv4"}),Uc=u("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Xs),G.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),Zc=u("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Qs),G.init(e,t)}),jc=u("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ec),G.init(e,t),e._zod.check=n=>{const a=n.value.split("/");try{if(a.length!==2)throw new Error;const[i,o]=a;if(!o)throw new Error;const r=Number(o);if(`${r}`!==o)throw new Error;if(r<0||r>128)throw new Error;new URL(`http://[${i}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Xn(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const qc=u("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=tc),G.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Xn(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Hc(e){if(!Hn.test(e))return!1;const t=e.replace(/[-_]/g,a=>a==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Xn(n)}const Vc=u("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Hn),G.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Hc(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Wc=u("$ZodE164",(e,t)=>{t.pattern??(t.pattern=nc),G.init(e,t)});function Gc(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[a]=n;if(!a)return!1;const i=JSON.parse(atob(a));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const Kc=u("$ZodJWT",(e,t)=>{G.init(e,t),e._zod.check=n=>{Gc(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Qn=u("$ZodNumber",(e,t)=>{X.init(e,t),e._zod.pattern=e._zod.bag.pattern??Gn,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),n}}),Yc=u("$ZodNumberFormat",(e,t)=>{pc.init(e,t),Qn.init(e,t)}),Jc=u("$ZodBoolean",(e,t)=>{X.init(e,t),e._zod.pattern=cc,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),Xc=u("$ZodUnknown",(e,t)=>{X.init(e,t),e._zod.parse=n=>n}),Qc=u("$ZodNever",(e,t)=>{X.init(e,t),e._zod.parse=(n,a)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function ea(e,t,n){e.issues.length&&t.issues.push(...He(n,e.issues)),t.value[n]=e.value}const el=u("$ZodArray",(e,t)=>{X.init(e,t),e._zod.parse=(n,a)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const o=[];for(let r=0;r<i.length;r++){const s=i[r],c=t.element._zod.run({value:s,issues:[]},a);c instanceof Promise?o.push(c.then(l=>ea(l,n,r))):ea(c,n,r)}return o.length?Promise.all(o).then(()=>n):n}});function lt(e,t,n,a,i){if(e.issues.length){if(i&&!(n in a))return;t.issues.push(...He(n,e.issues))}e.value===void 0?n in a&&(t.value[n]=void 0):t.value[n]=e.value}function ta(e){const t=Object.keys(e.shape);for(const a of t)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=vs(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function na(e,t,n,a,i,o){const r=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,d=c.optout==="optional";for(const p in t){if(s.has(p))continue;if(l==="never"){r.push(p);continue}const g=c.run({value:t[p],issues:[]},a);g instanceof Promise?e.push(g.then(h=>lt(h,n,p,t,d))):lt(g,n,p,t,d)}return r.length&&n.issues.push({code:"unrecognized_keys",keys:r,input:t,inst:o}),e.length?Promise.all(e).then(()=>n):n}const tl=u("$ZodObject",(e,t)=>{if(X.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const s=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...s};return Object.defineProperty(t,"shape",{value:c}),c}})}const a=Lt(()=>ta(t));q(e._zod,"propValues",()=>{const s=t.shape,c={};for(const l in s){const d=s[l]._zod;if(d.values){c[l]??(c[l]=new Set);for(const p of d.values)c[l].add(p)}}return c});const i=at,o=t.catchall;let r;e._zod.parse=(s,c)=>{r??(r=a.value);const l=s.value;if(!i(l))return s.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),s;s.value={};const d=[],p=r.shape;for(const g of r.keys){const h=p[g],b=h._zod.optout==="optional",_=h._zod.run({value:l[g],issues:[]},c);_ instanceof Promise?d.push(_.then(y=>lt(y,s,g,l,b))):lt(_,s,g,l,b)}return o?na(d,l,s,c,a.value,e):d.length?Promise.all(d).then(()=>s):s}}),nl=u("$ZodObjectJIT",(e,t)=>{tl.init(e,t);const n=e._zod.parse,a=Lt(()=>ta(t)),i=g=>{const h=new kc(["shape","payload","ctx"]),b=a.value,_=I=>{const m=$n(I);return`shape[${m}]._zod.run({ value: input[${m}], issues: [] }, ctx)`};h.write("const input = payload.value;");const y=Object.create(null);let x=0;for(const I of b.keys)y[I]=`key_${x++}`;h.write("const newResult = {};");for(const I of b.keys){const m=y[I],C=$n(I),D=g[I]?._zod?.optout==="optional";h.write(`const ${m} = ${_(I)};`),D?h.write(`
61
- if (${m}.issues.length) {
60
+ `))}}const Sc={major:4,minor:3,patch:6},X=m("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Sc;const a=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&a.unshift(e);for(const i of a)for(const o of i._zod.onattach)o(e);if(a.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const i=(r,s,c)=>{let l=qe(r),g;for(const p of s){if(p._zod.def.when){if(!p._zod.def.when(r))continue}else if(l)continue;const d=r.issues.length,h=p._zod.check(r);if(h instanceof Promise&&c?.async===!1)throw new Ze;if(g||h instanceof Promise)g=(g??Promise.resolve()).then(async()=>{await h,r.issues.length!==d&&(l||(l=qe(r,d)))});else{if(r.issues.length===d)continue;l||(l=qe(r,d))}}return g?g.then(()=>r):r},o=(r,s,c)=>{if(qe(r))return r.aborted=!0,r;const l=i(s,a,c);if(l instanceof Promise){if(c.async===!1)throw new Ze;return l.then(g=>e._zod.parse(g,c))}return e._zod.parse(l,c)};e._zod.run=(r,s)=>{if(s.skipChecks)return e._zod.parse(r,s);if(s.direction==="backward"){const l=e._zod.parse({value:r.value,issues:[]},{...s,skipChecks:!0});return l instanceof Promise?l.then(g=>o(g,r,s)):o(l,r,s)}const c=e._zod.parse(r,s);if(c instanceof Promise){if(s.async===!1)throw new Ze;return c.then(l=>i(l,a,s))}return i(c,a,s)}}j(e,"~standard",()=>({validate:i=>{try{const o=zs(e,i);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return Ns(e,i).then(r=>r.success?{value:r.data}:{issues:r.error?.issues})}},vendor:"zod",version:1}))}),$t=m("$ZodString",(e,t)=>{X.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??cc(e._zod.bag),e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),K=m("$ZodStringFormat",(e,t)=>{gt.init(e,t),$t.init(e,t)}),Tc=m("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Ks),K.init(e,t)}),Ac=m("$ZodUUID",(e,t)=>{if(t.version){const a={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(a===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Hn(a))}else t.pattern??(t.pattern=Hn());K.init(e,t)}),Ic=m("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ys),K.init(e,t)}),Pc=m("$ZodURL",(e,t)=>{K.init(e,t),e._zod.check=n=>{try{const a=n.value.trim(),i=new URL(a);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=a;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Lc=m("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Xs()),K.init(e,t)}),zc=m("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Ws),K.init(e,t)}),Nc=m("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Zs),K.init(e,t)}),Mc=m("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=js),K.init(e,t)}),Bc=m("$ZodULID",(e,t)=>{t.pattern??(t.pattern=qs),K.init(e,t)}),Rc=m("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Hs),K.init(e,t)}),Oc=m("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Vs),K.init(e,t)}),$c=m("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=sc(t)),K.init(e,t)}),Dc=m("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=oc),K.init(e,t)}),Fc=m("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=rc(t)),K.init(e,t)}),Uc=m("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Gs),K.init(e,t)}),Zc=m("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Qs),K.init(e,t),e._zod.bag.format="ipv4"}),jc=m("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ec),K.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),qc=m("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=tc),K.init(e,t)}),Hc=m("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=nc),K.init(e,t),e._zod.check=n=>{const a=n.value.split("/");try{if(a.length!==2)throw new Error;const[i,o]=a;if(!o)throw new Error;const r=Number(o);if(`${r}`!==o)throw new Error;if(r<0||r>128)throw new Error;new URL(`http://[${i}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Qn(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Vc=m("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ac),K.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Qn(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Wc(e){if(!Vn.test(e))return!1;const t=e.replace(/[-_]/g,a=>a==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Qn(n)}const Gc=m("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Vn),K.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Wc(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Kc=m("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ic),K.init(e,t)});function Yc(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[a]=n;if(!a)return!1;const i=JSON.parse(atob(a));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const Jc=m("$ZodJWT",(e,t)=>{K.init(e,t),e._zod.check=n=>{Yc(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),ea=m("$ZodNumber",(e,t)=>{X.init(e,t),e._zod.pattern=e._zod.bag.pattern??Kn,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),n}}),Xc=m("$ZodNumberFormat",(e,t)=>{uc.init(e,t),ea.init(e,t)}),Qc=m("$ZodBoolean",(e,t)=>{X.init(e,t),e._zod.pattern=gc,e._zod.parse=(n,a)=>{if(t.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),el=m("$ZodUnknown",(e,t)=>{X.init(e,t),e._zod.parse=n=>n}),tl=m("$ZodNever",(e,t)=>{X.init(e,t),e._zod.parse=(n,a)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function ta(e,t,n){e.issues.length&&t.issues.push(...He(n,e.issues)),t.value[n]=e.value}const nl=m("$ZodArray",(e,t)=>{X.init(e,t),e._zod.parse=(n,a)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const o=[];for(let r=0;r<i.length;r++){const s=i[r],c=t.element._zod.run({value:s,issues:[]},a);c instanceof Promise?o.push(c.then(l=>ta(l,n,r))):ta(c,n,r)}return o.length?Promise.all(o).then(()=>n):n}});function dt(e,t,n,a,i){if(e.issues.length){if(i&&!(n in a))return;t.issues.push(...He(n,e.issues))}e.value===void 0?n in a&&(t.value[n]=void 0):t.value[n]=e.value}function na(e){const t=Object.keys(e.shape);for(const a of t)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=ws(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function aa(e,t,n,a,i,o){const r=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,g=c.optout==="optional";for(const p in t){if(s.has(p))continue;if(l==="never"){r.push(p);continue}const d=c.run({value:t[p],issues:[]},a);d instanceof Promise?e.push(d.then(h=>dt(h,n,p,t,g))):dt(d,n,p,t,g)}return r.length&&n.issues.push({code:"unrecognized_keys",keys:r,input:t,inst:o}),e.length?Promise.all(e).then(()=>n):n}const al=m("$ZodObject",(e,t)=>{if(X.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const s=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...s};return Object.defineProperty(t,"shape",{value:c}),c}})}const a=zt(()=>na(t));j(e._zod,"propValues",()=>{const s=t.shape,c={};for(const l in s){const g=s[l]._zod;if(g.values){c[l]??(c[l]=new Set);for(const p of g.values)c[l].add(p)}}return c});const i=ot,o=t.catchall;let r;e._zod.parse=(s,c)=>{r??(r=a.value);const l=s.value;if(!i(l))return s.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),s;s.value={};const g=[],p=r.shape;for(const d of r.keys){const h=p[d],u=h._zod.optout==="optional",b=h._zod.run({value:l[d],issues:[]},c);b instanceof Promise?g.push(b.then(y=>dt(y,s,d,l,u))):dt(b,s,d,l,u)}return o?aa(g,l,s,c,a.value,e):g.length?Promise.all(g).then(()=>s):s}}),il=m("$ZodObjectJIT",(e,t)=>{al.init(e,t);const n=e._zod.parse,a=zt(()=>na(t)),i=d=>{const h=new Ec(["shape","payload","ctx"]),u=a.value,b=A=>{const f=Dn(A);return`shape[${f}]._zod.run({ value: input[${f}], issues: [] }, ctx)`};h.write("const input = payload.value;");const y=Object.create(null);let w=0;for(const A of u.keys)y[A]=`key_${w++}`;h.write("const newResult = {};");for(const A of u.keys){const f=y[A],C=Dn(A),R=d[A]?._zod?.optout==="optional";h.write(`const ${f} = ${b(A)};`),R?h.write(`
61
+ if (${f}.issues.length) {
62
62
  if (${C} in input) {
63
- payload.issues = payload.issues.concat(${m}.issues.map(iss => ({
63
+ payload.issues = payload.issues.concat(${f}.issues.map(iss => ({
64
64
  ...iss,
65
65
  path: iss.path ? [${C}, ...iss.path] : [${C}]
66
66
  })));
67
67
  }
68
68
  }
69
69
 
70
- if (${m}.value === undefined) {
70
+ if (${f}.value === undefined) {
71
71
  if (${C} in input) {
72
72
  newResult[${C}] = undefined;
73
73
  }
74
74
  } else {
75
- newResult[${C}] = ${m}.value;
75
+ newResult[${C}] = ${f}.value;
76
76
  }
77
77
 
78
78
  `):h.write(`
79
- if (${m}.issues.length) {
80
- payload.issues = payload.issues.concat(${m}.issues.map(iss => ({
79
+ if (${f}.issues.length) {
80
+ payload.issues = payload.issues.concat(${f}.issues.map(iss => ({
81
81
  ...iss,
82
82
  path: iss.path ? [${C}, ...iss.path] : [${C}]
83
83
  })));
84
84
  }
85
85
 
86
- if (${m}.value === undefined) {
86
+ if (${f}.value === undefined) {
87
87
  if (${C} in input) {
88
88
  newResult[${C}] = undefined;
89
89
  }
90
90
  } else {
91
- newResult[${C}] = ${m}.value;
91
+ newResult[${C}] = ${f}.value;
92
92
  }
93
93
 
94
- `)}h.write("payload.value = newResult;"),h.write("return payload;");const k=h.compile();return(I,m)=>k(g,I,m)};let o;const r=at,s=!Bn.jitless,l=s&&bs.value,d=t.catchall;let p;e._zod.parse=(g,h)=>{p??(p=a.value);const b=g.value;return r(b)?s&&l&&h?.async===!1&&h.jitless!==!0?(o||(o=i(t.shape)),g=o(g,h),d?na([],b,g,h,p,e):g):n(g,h):(g.issues.push({expected:"object",code:"invalid_type",input:b,inst:e}),g)}});function aa(e,t,n,a){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const i=e.filter(o=>!qe(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(r=>Le(r,a,Ae())))}),t)}const al=u("$ZodUnion",(e,t)=>{X.init(e,t),q(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),q(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),q(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),q(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>Nt(o.source)).join("|")})$`)}});const n=t.options.length===1,a=t.options[0]._zod.run;e._zod.parse=(i,o)=>{if(n)return a(i,o);let r=!1;const s=[];for(const c of t.options){const l=c._zod.run({value:i.value,issues:[]},o);if(l instanceof Promise)s.push(l),r=!0;else{if(l.issues.length===0)return l;s.push(l)}}return r?Promise.all(s).then(c=>aa(c,i,e,o)):aa(s,i,e,o)}}),il=u("$ZodIntersection",(e,t)=>{X.init(e,t),e._zod.parse=(n,a)=>{const i=n.value,o=t.left._zod.run({value:i,issues:[]},a),r=t.right._zod.run({value:i,issues:[]},a);return o instanceof Promise||r instanceof Promise?Promise.all([o,r]).then(([c,l])=>ia(n,c,l)):ia(n,o,r)}});function $t(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(je(e)&&je(t)){const n=Object.keys(t),a=Object.keys(e).filter(o=>n.indexOf(o)!==-1),i={...e,...t};for(const o of a){const r=$t(e[o],t[o]);if(!r.valid)return{valid:!1,mergeErrorPath:[o,...r.mergeErrorPath]};i[o]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let a=0;a<e.length;a++){const i=e[a],o=t[a],r=$t(i,o);if(!r.valid)return{valid:!1,mergeErrorPath:[a,...r.mergeErrorPath]};n.push(r.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function ia(e,t,n){const a=new Map;let i;for(const s of t.issues)if(s.code==="unrecognized_keys"){i??(i=s);for(const c of s.keys)a.has(c)||a.set(c,{}),a.get(c).l=!0}else e.issues.push(s);for(const s of n.issues)if(s.code==="unrecognized_keys")for(const c of s.keys)a.has(c)||a.set(c,{}),a.get(c).r=!0;else e.issues.push(s);const o=[...a].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(o.length&&i&&e.issues.push({...i,keys:o}),qe(e))return e;const r=$t(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const ol=u("$ZodRecord",(e,t)=>{X.init(e,t),e._zod.parse=(n,a)=>{const i=n.value;if(!je(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const o=[],r=t.keyType._zod.values;if(r){n.value={};const s=new Set;for(const l of r)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){s.add(typeof l=="number"?l.toString():l);const d=t.valueType._zod.run({value:i[l],issues:[]},a);d instanceof Promise?o.push(d.then(p=>{p.issues.length&&n.issues.push(...He(l,p.issues)),n.value[l]=p.value})):(d.issues.length&&n.issues.push(...He(l,d.issues)),n.value[l]=d.value)}let c;for(const l in i)s.has(l)||(c=c??[],c.push(l));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c})}else{n.value={};for(const s of Reflect.ownKeys(i)){if(s==="__proto__")continue;let c=t.keyType._zod.run({value:s,issues:[]},a);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof s=="string"&&Gn.test(s)&&c.issues.length){const p=t.keyType._zod.run({value:Number(s),issues:[]},a);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(c=p)}if(c.issues.length){t.mode==="loose"?n.value[s]=i[s]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(p=>Le(p,a,Ae())),input:s,path:[s],inst:e});continue}const d=t.valueType._zod.run({value:i[s],issues:[]},a);d instanceof Promise?o.push(d.then(p=>{p.issues.length&&n.issues.push(...He(s,p.issues)),n.value[c.value]=p.value})):(d.issues.length&&n.issues.push(...He(s,d.issues)),n.value[c.value]=d.value)}}return o.length?Promise.all(o).then(()=>n):n}}),rl=u("$ZodEnum",(e,t)=>{X.init(e,t);const n=Rn(t.entries),a=new Set(n);e._zod.values=a,e._zod.pattern=new RegExp(`^(${n.filter(i=>_s.has(typeof i)).map(i=>typeof i=="string"?it(i):i.toString()).join("|")})$`),e._zod.parse=(i,o)=>{const r=i.value;return a.has(r)||i.issues.push({code:"invalid_value",values:n,input:r,inst:e}),i}}),sl=u("$ZodTransform",(e,t)=>{X.init(e,t),e._zod.parse=(n,a)=>{if(a.direction==="backward")throw new Mn(e.constructor.name);const i=t.transform(n.value,n);if(a.async)return(i instanceof Promise?i:Promise.resolve(i)).then(r=>(n.value=r,n));if(i instanceof Promise)throw new Ze;return n.value=i,n}});function oa(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const ra=u("$ZodOptional",(e,t)=>{X.init(e,t),e._zod.optin="optional",e._zod.optout="optional",q(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),q(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Nt(n.source)})?$`):void 0}),e._zod.parse=(n,a)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(o=>oa(o,n.value)):oa(i,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,a)}}),cl=u("$ZodExactOptional",(e,t)=>{ra.init(e,t),q(e._zod,"values",()=>t.innerType._zod.values),q(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,a)=>t.innerType._zod.run(n,a)}),ll=u("$ZodNullable",(e,t)=>{X.init(e,t),q(e._zod,"optin",()=>t.innerType._zod.optin),q(e._zod,"optout",()=>t.innerType._zod.optout),q(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Nt(n.source)}|null)$`):void 0}),q(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,a)=>n.value===null?n:t.innerType._zod.run(n,a)}),gl=u("$ZodDefault",(e,t)=>{X.init(e,t),e._zod.optin="optional",q(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);if(n.value===void 0)return n.value=t.defaultValue,n;const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(o=>sa(o,t)):sa(i,t)}});function sa(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const dl=u("$ZodPrefault",(e,t)=>{X.init(e,t),e._zod.optin="optional",q(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>(a.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,a))}),pl=u("$ZodNonOptional",(e,t)=>{X.init(e,t),q(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(a=>a!==void 0)):void 0}),e._zod.parse=(n,a)=>{const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(o=>ca(o,e)):ca(i,e)}});function ca(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const hl=u("$ZodCatch",(e,t)=>{X.init(e,t),q(e._zod,"optin",()=>t.innerType._zod.optin),q(e._zod,"optout",()=>t.innerType._zod.optout),q(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(o=>(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(r=>Le(r,a,Ae()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(o=>Le(o,a,Ae()))},input:n.value}),n.issues=[]),n)}}),ul=u("$ZodPipe",(e,t)=>{X.init(e,t),q(e._zod,"values",()=>t.in._zod.values),q(e._zod,"optin",()=>t.in._zod.optin),q(e._zod,"optout",()=>t.out._zod.optout),q(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,a)=>{if(a.direction==="backward"){const o=t.out._zod.run(n,a);return o instanceof Promise?o.then(r=>gt(r,t.in,a)):gt(o,t.in,a)}const i=t.in._zod.run(n,a);return i instanceof Promise?i.then(o=>gt(o,t.out,a)):gt(i,t.out,a)}});function gt(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const fl=u("$ZodReadonly",(e,t)=>{X.init(e,t),q(e._zod,"propValues",()=>t.innerType._zod.propValues),q(e._zod,"values",()=>t.innerType._zod.values),q(e._zod,"optin",()=>t.innerType?._zod?.optin),q(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(la):la(i)}});function la(e){return e.value=Object.freeze(e.value),e}const ml=u("$ZodCustom",(e,t)=>{ge.init(e,t),X.init(e,t),e._zod.parse=(n,a)=>n,e._zod.check=n=>{const a=n.value,i=t.fn(a);if(i instanceof Promise)return i.then(o=>ga(o,n,a,e));ga(i,n,a,e)}});function ga(e,t,n,a){if(!e){const i={code:"custom",input:n,inst:a,path:[...a._zod.def.path??[]],continue:!a._zod.def.abort};a._zod.def.params&&(i.params=a._zod.def.params),t.issues.push(Ye(i))}}var da;class bl{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const a=n[0];return this._map.set(t,a),a&&typeof a=="object"&&"id"in a&&this._idmap.set(a.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const a={...this.get(n)??{}};delete a.id;const i={...a,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function _l(){return new bl}(da=globalThis).__zod_globalRegistry??(da.__zod_globalRegistry=_l());const Je=globalThis.__zod_globalRegistry;function vl(e,t){return new e({type:"string",...z(t)})}function yl(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...z(t)})}function pa(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...z(t)})}function wl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...z(t)})}function xl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(t)})}function kl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(t)})}function Cl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(t)})}function El(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...z(t)})}function Sl(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...z(t)})}function Tl(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(t)})}function Al(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...z(t)})}function Il(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(t)})}function Pl(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...z(t)})}function Ll(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...z(t)})}function zl(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(t)})}function Nl(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(t)})}function Ml(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(t)})}function Bl(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(t)})}function Rl(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(t)})}function Ol(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...z(t)})}function $l(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...z(t)})}function Dl(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...z(t)})}function Fl(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...z(t)})}function Ul(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(t)})}function Zl(e,t){return new e({type:"string",format:"date",check:"string_format",...z(t)})}function jl(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...z(t)})}function ql(e,t){return new e({type:"string",format:"duration",check:"string_format",...z(t)})}function Hl(e,t){return new e({type:"number",checks:[],...z(t)})}function Vl(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...z(t)})}function Wl(e,t){return new e({type:"boolean",...z(t)})}function Gl(e){return new e({type:"unknown"})}function Kl(e,t){return new e({type:"never",...z(t)})}function ha(e,t){return new Yn({check:"less_than",...z(t),value:e,inclusive:!1})}function Dt(e,t){return new Yn({check:"less_than",...z(t),value:e,inclusive:!0})}function ua(e,t){return new Jn({check:"greater_than",...z(t),value:e,inclusive:!1})}function Ft(e,t){return new Jn({check:"greater_than",...z(t),value:e,inclusive:!0})}function fa(e,t){return new dc({check:"multiple_of",...z(t),value:e})}function ma(e,t){return new hc({check:"max_length",...z(t),maximum:e})}function dt(e,t){return new uc({check:"min_length",...z(t),minimum:e})}function ba(e,t){return new fc({check:"length_equals",...z(t),length:e})}function Yl(e,t){return new mc({check:"string_format",format:"regex",...z(t),pattern:e})}function Jl(e){return new bc({check:"string_format",format:"lowercase",...z(e)})}function Xl(e){return new _c({check:"string_format",format:"uppercase",...z(e)})}function Ql(e,t){return new vc({check:"string_format",format:"includes",...z(t),includes:e})}function eg(e,t){return new yc({check:"string_format",format:"starts_with",...z(t),prefix:e})}function tg(e,t){return new wc({check:"string_format",format:"ends_with",...z(t),suffix:e})}function Ve(e){return new xc({check:"overwrite",tx:e})}function ng(e){return Ve(t=>t.normalize(e))}function ag(){return Ve(e=>e.trim())}function ig(){return Ve(e=>e.toLowerCase())}function og(){return Ve(e=>e.toUpperCase())}function rg(){return Ve(e=>ms(e))}function sg(e,t,n){return new e({type:"array",element:t,...z(n)})}function cg(e,t,n){return new e({type:"custom",check:"custom",fn:t,...z(n)})}function lg(e){const t=gg(n=>(n.addIssue=a=>{if(typeof a=="string")n.issues.push(Ye(a,n.value,t._zod.def));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),n.issues.push(Ye(i))}},e(n.value,n)));return t}function gg(e,t){const n=new ge({check:"custom",...z(t)});return n._zod.check=e,n}function _a(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Je,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function te(e,t,n={path:[],schemaPath:[]}){var a;const i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;const r={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,r);const s=e._zod.toJSONSchema?.();if(s)r.schema=s;else{const d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,r.schema,d);else{const g=r.schema,h=t.processors[i.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);h(e,t,g,d)}const p=e._zod.parent;p&&(r.ref||(r.ref=p),te(p,t,d),t.seen.get(p).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(r.schema,c),t.io==="input"&&re(e)&&(delete r.schema.examples,delete r.schema.default),t.io==="input"&&r.schema._prefault&&((a=r.schema).default??(a.default=r.schema._prefault)),delete r.schema._prefault,t.seen.get(e).schema}function va(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=new Map;for(const r of e.seen.entries()){const s=e.metadataRegistry.get(r[0])?.id;if(s){const c=a.get(s);if(c&&c!==r[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);a.set(s,r[0])}}const i=r=>{const s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const p=e.external.registry.get(r[0])?.id,g=e.external.uri??(b=>b);if(p)return{ref:g(p)};const h=r[1].defId??r[1].schema.id??`schema${e.counter++}`;return r[1].defId=h,{defId:h,ref:`${g("__shared")}#/${s}/${h}`}}if(r[1]===n)return{ref:"#"};const l=`#/${s}/`,d=r[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:l+d}},o=r=>{if(r[1].schema.$ref)return;const s=r[1],{ref:c,defId:l}=i(r);s.def={...s.schema},l&&(s.defId=l);const d=s.schema;for(const p in d)delete d[p];d.$ref=c};if(e.cycles==="throw")for(const r of e.seen.entries()){const s=r[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
94
+ `)}h.write("payload.value = newResult;"),h.write("return payload;");const E=h.compile();return(A,f)=>E(d,A,f)};let o;const r=ot,s=!Rn.jitless,l=s&&vs.value,g=t.catchall;let p;e._zod.parse=(d,h)=>{p??(p=a.value);const u=d.value;return r(u)?s&&l&&h?.async===!1&&h.jitless!==!0?(o||(o=i(t.shape)),d=o(d,h),g?aa([],u,d,h,p,e):d):n(d,h):(d.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),d)}});function ia(e,t,n,a){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const i=e.filter(o=>!qe(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(r=>ze(r,a,Ie())))}),t)}const ol=m("$ZodUnion",(e,t)=>{X.init(e,t),j(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),j(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),j(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),j(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>Mt(o.source)).join("|")})$`)}});const n=t.options.length===1,a=t.options[0]._zod.run;e._zod.parse=(i,o)=>{if(n)return a(i,o);let r=!1;const s=[];for(const c of t.options){const l=c._zod.run({value:i.value,issues:[]},o);if(l instanceof Promise)s.push(l),r=!0;else{if(l.issues.length===0)return l;s.push(l)}}return r?Promise.all(s).then(c=>ia(c,i,e,o)):ia(s,i,e,o)}}),rl=m("$ZodIntersection",(e,t)=>{X.init(e,t),e._zod.parse=(n,a)=>{const i=n.value,o=t.left._zod.run({value:i,issues:[]},a),r=t.right._zod.run({value:i,issues:[]},a);return o instanceof Promise||r instanceof Promise?Promise.all([o,r]).then(([c,l])=>oa(n,c,l)):oa(n,o,r)}});function Dt(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(je(e)&&je(t)){const n=Object.keys(t),a=Object.keys(e).filter(o=>n.indexOf(o)!==-1),i={...e,...t};for(const o of a){const r=Dt(e[o],t[o]);if(!r.valid)return{valid:!1,mergeErrorPath:[o,...r.mergeErrorPath]};i[o]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let a=0;a<e.length;a++){const i=e[a],o=t[a],r=Dt(i,o);if(!r.valid)return{valid:!1,mergeErrorPath:[a,...r.mergeErrorPath]};n.push(r.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function oa(e,t,n){const a=new Map;let i;for(const s of t.issues)if(s.code==="unrecognized_keys"){i??(i=s);for(const c of s.keys)a.has(c)||a.set(c,{}),a.get(c).l=!0}else e.issues.push(s);for(const s of n.issues)if(s.code==="unrecognized_keys")for(const c of s.keys)a.has(c)||a.set(c,{}),a.get(c).r=!0;else e.issues.push(s);const o=[...a].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(o.length&&i&&e.issues.push({...i,keys:o}),qe(e))return e;const r=Dt(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const sl=m("$ZodRecord",(e,t)=>{X.init(e,t),e._zod.parse=(n,a)=>{const i=n.value;if(!je(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;const o=[],r=t.keyType._zod.values;if(r){n.value={};const s=new Set;for(const l of r)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){s.add(typeof l=="number"?l.toString():l);const g=t.valueType._zod.run({value:i[l],issues:[]},a);g instanceof Promise?o.push(g.then(p=>{p.issues.length&&n.issues.push(...He(l,p.issues)),n.value[l]=p.value})):(g.issues.length&&n.issues.push(...He(l,g.issues)),n.value[l]=g.value)}let c;for(const l in i)s.has(l)||(c=c??[],c.push(l));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c})}else{n.value={};for(const s of Reflect.ownKeys(i)){if(s==="__proto__")continue;let c=t.keyType._zod.run({value:s,issues:[]},a);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof s=="string"&&Kn.test(s)&&c.issues.length){const p=t.keyType._zod.run({value:Number(s),issues:[]},a);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(c=p)}if(c.issues.length){t.mode==="loose"?n.value[s]=i[s]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(p=>ze(p,a,Ie())),input:s,path:[s],inst:e});continue}const g=t.valueType._zod.run({value:i[s],issues:[]},a);g instanceof Promise?o.push(g.then(p=>{p.issues.length&&n.issues.push(...He(s,p.issues)),n.value[c.value]=p.value})):(g.issues.length&&n.issues.push(...He(s,g.issues)),n.value[c.value]=g.value)}}return o.length?Promise.all(o).then(()=>n):n}}),cl=m("$ZodEnum",(e,t)=>{X.init(e,t);const n=On(t.entries),a=new Set(n);e._zod.values=a,e._zod.pattern=new RegExp(`^(${n.filter(i=>ys.has(typeof i)).map(i=>typeof i=="string"?rt(i):i.toString()).join("|")})$`),e._zod.parse=(i,o)=>{const r=i.value;return a.has(r)||i.issues.push({code:"invalid_value",values:n,input:r,inst:e}),i}}),ll=m("$ZodTransform",(e,t)=>{X.init(e,t),e._zod.parse=(n,a)=>{if(a.direction==="backward")throw new Bn(e.constructor.name);const i=t.transform(n.value,n);if(a.async)return(i instanceof Promise?i:Promise.resolve(i)).then(r=>(n.value=r,n));if(i instanceof Promise)throw new Ze;return n.value=i,n}});function ra(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const sa=m("$ZodOptional",(e,t)=>{X.init(e,t),e._zod.optin="optional",e._zod.optout="optional",j(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),j(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Mt(n.source)})?$`):void 0}),e._zod.parse=(n,a)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(o=>ra(o,n.value)):ra(i,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,a)}}),gl=m("$ZodExactOptional",(e,t)=>{sa.init(e,t),j(e._zod,"values",()=>t.innerType._zod.values),j(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,a)=>t.innerType._zod.run(n,a)}),dl=m("$ZodNullable",(e,t)=>{X.init(e,t),j(e._zod,"optin",()=>t.innerType._zod.optin),j(e._zod,"optout",()=>t.innerType._zod.optout),j(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Mt(n.source)}|null)$`):void 0}),j(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,a)=>n.value===null?n:t.innerType._zod.run(n,a)}),pl=m("$ZodDefault",(e,t)=>{X.init(e,t),e._zod.optin="optional",j(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);if(n.value===void 0)return n.value=t.defaultValue,n;const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(o=>ca(o,t)):ca(i,t)}});function ca(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const hl=m("$ZodPrefault",(e,t)=>{X.init(e,t),e._zod.optin="optional",j(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>(a.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,a))}),ul=m("$ZodNonOptional",(e,t)=>{X.init(e,t),j(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(a=>a!==void 0)):void 0}),e._zod.parse=(n,a)=>{const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(o=>la(o,e)):la(i,e)}});function la(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const fl=m("$ZodCatch",(e,t)=>{X.init(e,t),j(e._zod,"optin",()=>t.innerType._zod.optin),j(e._zod,"optout",()=>t.innerType._zod.optout),j(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(o=>(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(r=>ze(r,a,Ie()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(o=>ze(o,a,Ie()))},input:n.value}),n.issues=[]),n)}}),ml=m("$ZodPipe",(e,t)=>{X.init(e,t),j(e._zod,"values",()=>t.in._zod.values),j(e._zod,"optin",()=>t.in._zod.optin),j(e._zod,"optout",()=>t.out._zod.optout),j(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,a)=>{if(a.direction==="backward"){const o=t.out._zod.run(n,a);return o instanceof Promise?o.then(r=>pt(r,t.in,a)):pt(o,t.in,a)}const i=t.in._zod.run(n,a);return i instanceof Promise?i.then(o=>pt(o,t.out,a)):pt(i,t.out,a)}});function pt(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const bl=m("$ZodReadonly",(e,t)=>{X.init(e,t),j(e._zod,"propValues",()=>t.innerType._zod.propValues),j(e._zod,"values",()=>t.innerType._zod.values),j(e._zod,"optin",()=>t.innerType?._zod?.optin),j(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,a)=>{if(a.direction==="backward")return t.innerType._zod.run(n,a);const i=t.innerType._zod.run(n,a);return i instanceof Promise?i.then(ga):ga(i)}});function ga(e){return e.value=Object.freeze(e.value),e}const _l=m("$ZodCustom",(e,t)=>{de.init(e,t),X.init(e,t),e._zod.parse=(n,a)=>n,e._zod.check=n=>{const a=n.value,i=t.fn(a);if(i instanceof Promise)return i.then(o=>da(o,n,a,e));da(i,n,a,e)}});function da(e,t,n,a){if(!e){const i={code:"custom",input:n,inst:a,path:[...a._zod.def.path??[]],continue:!a._zod.def.abort};a._zod.def.params&&(i.params=a._zod.def.params),t.issues.push(Je(i))}}var pa;class vl{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const a=n[0];return this._map.set(t,a),a&&typeof a=="object"&&"id"in a&&this._idmap.set(a.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const a={...this.get(n)??{}};delete a.id;const i={...a,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function yl(){return new vl}(pa=globalThis).__zod_globalRegistry??(pa.__zod_globalRegistry=yl());const Xe=globalThis.__zod_globalRegistry;function wl(e,t){return new e({type:"string",...z(t)})}function xl(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...z(t)})}function ha(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...z(t)})}function kl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...z(t)})}function Cl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(t)})}function El(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(t)})}function Sl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(t)})}function Tl(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...z(t)})}function Al(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...z(t)})}function Il(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(t)})}function Pl(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...z(t)})}function Ll(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(t)})}function zl(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...z(t)})}function Nl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...z(t)})}function Ml(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(t)})}function Bl(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(t)})}function Rl(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(t)})}function Ol(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(t)})}function $l(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(t)})}function Dl(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...z(t)})}function Fl(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...z(t)})}function Ul(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...z(t)})}function Zl(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...z(t)})}function jl(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(t)})}function ql(e,t){return new e({type:"string",format:"date",check:"string_format",...z(t)})}function Hl(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...z(t)})}function Vl(e,t){return new e({type:"string",format:"duration",check:"string_format",...z(t)})}function Wl(e,t){return new e({type:"number",checks:[],...z(t)})}function Gl(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...z(t)})}function Kl(e,t){return new e({type:"boolean",...z(t)})}function Yl(e){return new e({type:"unknown"})}function Jl(e,t){return new e({type:"never",...z(t)})}function ua(e,t){return new Jn({check:"less_than",...z(t),value:e,inclusive:!1})}function Ft(e,t){return new Jn({check:"less_than",...z(t),value:e,inclusive:!0})}function fa(e,t){return new Xn({check:"greater_than",...z(t),value:e,inclusive:!1})}function Ut(e,t){return new Xn({check:"greater_than",...z(t),value:e,inclusive:!0})}function ma(e,t){return new hc({check:"multiple_of",...z(t),value:e})}function ba(e,t){return new fc({check:"max_length",...z(t),maximum:e})}function ht(e,t){return new mc({check:"min_length",...z(t),minimum:e})}function _a(e,t){return new bc({check:"length_equals",...z(t),length:e})}function Xl(e,t){return new _c({check:"string_format",format:"regex",...z(t),pattern:e})}function Ql(e){return new vc({check:"string_format",format:"lowercase",...z(e)})}function eg(e){return new yc({check:"string_format",format:"uppercase",...z(e)})}function tg(e,t){return new wc({check:"string_format",format:"includes",...z(t),includes:e})}function ng(e,t){return new xc({check:"string_format",format:"starts_with",...z(t),prefix:e})}function ag(e,t){return new kc({check:"string_format",format:"ends_with",...z(t),suffix:e})}function Ve(e){return new Cc({check:"overwrite",tx:e})}function ig(e){return Ve(t=>t.normalize(e))}function og(){return Ve(e=>e.trim())}function rg(){return Ve(e=>e.toLowerCase())}function sg(){return Ve(e=>e.toUpperCase())}function cg(){return Ve(e=>_s(e))}function lg(e,t,n){return new e({type:"array",element:t,...z(n)})}function gg(e,t,n){return new e({type:"custom",check:"custom",fn:t,...z(n)})}function dg(e){const t=pg(n=>(n.addIssue=a=>{if(typeof a=="string")n.issues.push(Je(a,n.value,t._zod.def));else{const i=a;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),n.issues.push(Je(i))}},e(n.value,n)));return t}function pg(e,t){const n=new de({check:"custom",...z(t)});return n._zod.check=e,n}function va(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Xe,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function te(e,t,n={path:[],schemaPath:[]}){var a;const i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;const r={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,r);const s=e._zod.toJSONSchema?.();if(s)r.schema=s;else{const g={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,r.schema,g);else{const d=r.schema,h=t.processors[i.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);h(e,t,d,g)}const p=e._zod.parent;p&&(r.ref||(r.ref=p),te(p,t,g),t.seen.get(p).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(r.schema,c),t.io==="input"&&se(e)&&(delete r.schema.examples,delete r.schema.default),t.io==="input"&&r.schema._prefault&&((a=r.schema).default??(a.default=r.schema._prefault)),delete r.schema._prefault,t.seen.get(e).schema}function ya(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=new Map;for(const r of e.seen.entries()){const s=e.metadataRegistry.get(r[0])?.id;if(s){const c=a.get(s);if(c&&c!==r[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);a.set(s,r[0])}}const i=r=>{const s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const p=e.external.registry.get(r[0])?.id,d=e.external.uri??(u=>u);if(p)return{ref:d(p)};const h=r[1].defId??r[1].schema.id??`schema${e.counter++}`;return r[1].defId=h,{defId:h,ref:`${d("__shared")}#/${s}/${h}`}}if(r[1]===n)return{ref:"#"};const l=`#/${s}/`,g=r[1].schema.id??`__schema${e.counter++}`;return{defId:g,ref:l+g}},o=r=>{if(r[1].schema.$ref)return;const s=r[1],{ref:c,defId:l}=i(r);s.def={...s.schema},l&&(s.defId=l);const g=s.schema;for(const p in g)delete g[p];g.$ref=c};if(e.cycles==="throw")for(const r of e.seen.entries()){const s=r[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
95
95
 
96
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const r of e.seen.entries()){const s=r[1];if(t===r[0]){o(r);continue}if(e.external){const l=e.external.registry.get(r[0])?.id;if(t!==r[0]&&l){o(r);continue}}if(e.metadataRegistry.get(r[0])?.id){o(r);continue}if(s.cycle){o(r);continue}if(s.count>1&&e.reused==="ref"){o(r);continue}}}function ya(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=r=>{const s=e.seen.get(r);if(s.ref===null)return;const c=s.def??s.schema,l={...c},d=s.ref;if(s.ref=null,d){a(d);const g=e.seen.get(d),h=g.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(h)):Object.assign(c,h),Object.assign(c,l),r._zod.parent===d)for(const _ in c)_==="$ref"||_==="allOf"||_ in l||delete c[_];if(h.$ref&&g.def)for(const _ in c)_==="$ref"||_==="allOf"||_ in g.def&&JSON.stringify(c[_])===JSON.stringify(g.def[_])&&delete c[_]}const p=r._zod.parent;if(p&&p!==d){a(p);const g=e.seen.get(p);if(g?.schema.$ref&&(c.$ref=g.schema.$ref,g.def))for(const h in c)h==="$ref"||h==="allOf"||h in g.def&&JSON.stringify(c[h])===JSON.stringify(g.def[h])&&delete c[h]}e.override({zodSchema:r,jsonSchema:c,path:s.path??[]})};for(const r of[...e.seen.entries()].reverse())a(r[0]);const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const r=e.external.registry.get(t)?.id;if(!r)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(r)}Object.assign(i,n.def??n.schema);const o=e.external?.defs??{};for(const r of e.seen.entries()){const s=r[1];s.def&&s.defId&&(o[s.defId]=s.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?i.$defs=o:i.definitions=o);try{const r=JSON.parse(JSON.stringify(i));return Object.defineProperty(r,"~standard",{value:{...t["~standard"],jsonSchema:{input:pt(t,"input",e.processors),output:pt(t,"output",e.processors)}},enumerable:!1,writable:!1}),r}catch{throw new Error("Error converting schema to JSON.")}}function re(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const a=e._zod.def;if(a.type==="transform")return!0;if(a.type==="array")return re(a.element,n);if(a.type==="set")return re(a.valueType,n);if(a.type==="lazy")return re(a.getter(),n);if(a.type==="promise"||a.type==="optional"||a.type==="nonoptional"||a.type==="nullable"||a.type==="readonly"||a.type==="default"||a.type==="prefault")return re(a.innerType,n);if(a.type==="intersection")return re(a.left,n)||re(a.right,n);if(a.type==="record"||a.type==="map")return re(a.keyType,n)||re(a.valueType,n);if(a.type==="pipe")return re(a.in,n)||re(a.out,n);if(a.type==="object"){for(const i in a.shape)if(re(a.shape[i],n))return!0;return!1}if(a.type==="union"){for(const i of a.options)if(re(i,n))return!0;return!1}if(a.type==="tuple"){for(const i of a.items)if(re(i,n))return!0;return!!(a.rest&&re(a.rest,n))}return!1}const dg=(e,t={})=>n=>{const a=_a({...n,processors:t});return te(e,a),va(a,e),ya(a,e)},pt=(e,t,n={})=>a=>{const{libraryOptions:i,target:o}=a??{},r=_a({...i??{},target:o,io:t,processors:n});return te(e,r),va(r,e),ya(r,e)},pg={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},hg=(e,t,n,a)=>{const i=n;i.type="string";const{minimum:o,maximum:r,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof o=="number"&&(i.minLength=o),typeof r=="number"&&(i.maxLength=r),s&&(i.format=pg[s]??s,i.format===""&&delete i.format,s==="time"&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){const d=[...c];d.length===1?i.pattern=d[0].source:d.length>1&&(i.allOf=[...d.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},ug=(e,t,n,a)=>{const i=n,{minimum:o,maximum:r,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:d}=e._zod.bag;typeof s=="string"&&s.includes("int")?i.type="integer":i.type="number",typeof d=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=d,i.exclusiveMinimum=!0):i.exclusiveMinimum=d),typeof o=="number"&&(i.minimum=o,typeof d=="number"&&t.target!=="draft-04"&&(d>=o?delete i.minimum:delete i.exclusiveMinimum)),typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof r=="number"&&(i.maximum=r,typeof l=="number"&&t.target!=="draft-04"&&(l<=r?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},fg=(e,t,n,a)=>{n.type="boolean"},mg=(e,t,n,a)=>{n.not={}},bg=(e,t,n,a)=>{},_g=(e,t,n,a)=>{const i=e._zod.def,o=Rn(i.entries);o.every(r=>typeof r=="number")&&(n.type="number"),o.every(r=>typeof r=="string")&&(n.type="string"),n.enum=o},vg=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},yg=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},wg=(e,t,n,a)=>{const i=n,o=e._zod.def,{minimum:r,maximum:s}=e._zod.bag;typeof r=="number"&&(i.minItems=r),typeof s=="number"&&(i.maxItems=s),i.type="array",i.items=te(o.element,t,{...a,path:[...a.path,"items"]})},xg=(e,t,n,a)=>{const i=n,o=e._zod.def;i.type="object",i.properties={};const r=o.shape;for(const l in r)i.properties[l]=te(r[l],t,{...a,path:[...a.path,"properties",l]});const s=new Set(Object.keys(r)),c=new Set([...s].filter(l=>{const d=o.shape[l]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));c.size>0&&(i.required=Array.from(c)),o.catchall?._zod.def.type==="never"?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=te(o.catchall,t,{...a,path:[...a.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},kg=(e,t,n,a)=>{const i=e._zod.def,o=i.inclusive===!1,r=i.options.map((s,c)=>te(s,t,{...a,path:[...a.path,o?"oneOf":"anyOf",c]}));o?n.oneOf=r:n.anyOf=r},Cg=(e,t,n,a)=>{const i=e._zod.def,o=te(i.left,t,{...a,path:[...a.path,"allOf",0]}),r=te(i.right,t,{...a,path:[...a.path,"allOf",1]}),s=l=>"allOf"in l&&Object.keys(l).length===1,c=[...s(o)?o.allOf:[o],...s(r)?r.allOf:[r]];n.allOf=c},Eg=(e,t,n,a)=>{const i=n,o=e._zod.def;i.type="object";const r=o.keyType,c=r._zod.bag?.patterns;if(o.mode==="loose"&&c&&c.size>0){const d=te(o.valueType,t,{...a,path:[...a.path,"patternProperties","*"]});i.patternProperties={};for(const p of c)i.patternProperties[p.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=te(o.keyType,t,{...a,path:[...a.path,"propertyNames"]})),i.additionalProperties=te(o.valueType,t,{...a,path:[...a.path,"additionalProperties"]});const l=r._zod.values;if(l){const d=[...l].filter(p=>typeof p=="string"||typeof p=="number");d.length>0&&(i.required=d)}},Sg=(e,t,n,a)=>{const i=e._zod.def,o=te(i.innerType,t,a),r=t.seen.get(e);t.target==="openapi-3.0"?(r.ref=i.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},Tg=(e,t,n,a)=>{const i=e._zod.def;te(i.innerType,t,a);const o=t.seen.get(e);o.ref=i.innerType},Ag=(e,t,n,a)=>{const i=e._zod.def;te(i.innerType,t,a);const o=t.seen.get(e);o.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Ig=(e,t,n,a)=>{const i=e._zod.def;te(i.innerType,t,a);const o=t.seen.get(e);o.ref=i.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Pg=(e,t,n,a)=>{const i=e._zod.def;te(i.innerType,t,a);const o=t.seen.get(e);o.ref=i.innerType;let r;try{r=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=r},Lg=(e,t,n,a)=>{const i=e._zod.def,o=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;te(o,t,a);const r=t.seen.get(e);r.ref=o},zg=(e,t,n,a)=>{const i=e._zod.def;te(i.innerType,t,a);const o=t.seen.get(e);o.ref=i.innerType,n.readOnly=!0},wa=(e,t,n,a)=>{const i=e._zod.def;te(i.innerType,t,a);const o=t.seen.get(e);o.ref=i.innerType},Ng=u("ZodISODateTime",(e,t)=>{Rc.init(e,t),J.init(e,t)});function Mg(e){return Ul(Ng,e)}const Bg=u("ZodISODate",(e,t)=>{Oc.init(e,t),J.init(e,t)});function Rg(e){return Zl(Bg,e)}const Og=u("ZodISOTime",(e,t)=>{$c.init(e,t),J.init(e,t)});function $g(e){return jl(Og,e)}const Dg=u("ZodISODuration",(e,t)=>{Dc.init(e,t),J.init(e,t)});function Fg(e){return ql(Dg,e)}const pe=u("ZodError",(e,t)=>{Zn.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Is(e,n)},flatten:{value:n=>As(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Pt,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Pt,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Ug=Bt(pe),Zg=Rt(pe),jg=rt(pe),qg=st(pe),Hg=zs(pe),Vg=Ns(pe),Wg=Ms(pe),Gg=Bs(pe),Kg=Rs(pe),Yg=Os(pe),Jg=$s(pe),Xg=Ds(pe),Q=u("ZodType",(e,t)=>(X.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:pt(e,"input"),output:pt(e,"output")}}),e.toJSONSchema=dg(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(Ie(t,{checks:[...t.checks??[],...n.map(a=>typeof a=="function"?{_zod:{check:a,def:{check:"custom"},onattach:[]}}:a)]}),{parent:!0}),e.with=e.check,e.clone=(n,a)=>Pe(e,n,a),e.brand=()=>e,e.register=((n,a)=>(n.add(e,a),e)),e.parse=(n,a)=>Ug(e,n,a,{callee:e.parse}),e.safeParse=(n,a)=>jg(e,n,a),e.parseAsync=async(n,a)=>Zg(e,n,a,{callee:e.parseAsync}),e.safeParseAsync=async(n,a)=>qg(e,n,a),e.spa=e.safeParseAsync,e.encode=(n,a)=>Hg(e,n,a),e.decode=(n,a)=>Vg(e,n,a),e.encodeAsync=async(n,a)=>Wg(e,n,a),e.decodeAsync=async(n,a)=>Gg(e,n,a),e.safeEncode=(n,a)=>Kg(e,n,a),e.safeDecode=(n,a)=>Yg(e,n,a),e.safeEncodeAsync=async(n,a)=>Jg(e,n,a),e.safeDecodeAsync=async(n,a)=>Xg(e,n,a),e.refine=(n,a)=>e.check(qd(n,a)),e.superRefine=n=>e.check(Hd(n)),e.overwrite=n=>e.check(Ve(n)),e.optional=()=>Ta(e),e.exactOptional=()=>Ld(e),e.nullable=()=>Aa(e),e.nullish=()=>Ta(Aa(e)),e.nonoptional=n=>Od(e,n),e.array=()=>K(e),e.or=n=>ut([e,n]),e.and=n=>Sd(e,n),e.transform=n=>Pa(e,Id(n)),e.default=n=>Md(e,n),e.prefault=n=>Rd(e,n),e.catch=n=>Dd(e,n),e.pipe=n=>Pa(e,n),e.readonly=()=>Zd(e),e.describe=n=>{const a=e.clone();return Je.add(a,{description:n}),a},Object.defineProperty(e,"description",{get(){return Je.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Je.get(e);const a=e.clone();return Je.add(a,n[0]),a},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),xa=u("_ZodString",(e,t)=>{Ot.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(a,i,o)=>hg(e,a,i);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...a)=>e.check(Yl(...a)),e.includes=(...a)=>e.check(Ql(...a)),e.startsWith=(...a)=>e.check(eg(...a)),e.endsWith=(...a)=>e.check(tg(...a)),e.min=(...a)=>e.check(dt(...a)),e.max=(...a)=>e.check(ma(...a)),e.length=(...a)=>e.check(ba(...a)),e.nonempty=(...a)=>e.check(dt(1,...a)),e.lowercase=a=>e.check(Jl(a)),e.uppercase=a=>e.check(Xl(a)),e.trim=()=>e.check(ag()),e.normalize=(...a)=>e.check(ng(...a)),e.toLowerCase=()=>e.check(ig()),e.toUpperCase=()=>e.check(og()),e.slugify=()=>e.check(rg())}),Qg=u("ZodString",(e,t)=>{Ot.init(e,t),xa.init(e,t),e.email=n=>e.check(yl(ed,n)),e.url=n=>e.check(El(td,n)),e.jwt=n=>e.check(Fl(md,n)),e.emoji=n=>e.check(Sl(nd,n)),e.guid=n=>e.check(pa(ka,n)),e.uuid=n=>e.check(wl(ht,n)),e.uuidv4=n=>e.check(xl(ht,n)),e.uuidv6=n=>e.check(kl(ht,n)),e.uuidv7=n=>e.check(Cl(ht,n)),e.nanoid=n=>e.check(Tl(ad,n)),e.guid=n=>e.check(pa(ka,n)),e.cuid=n=>e.check(Al(id,n)),e.cuid2=n=>e.check(Il(od,n)),e.ulid=n=>e.check(Pl(rd,n)),e.base64=n=>e.check(Ol(hd,n)),e.base64url=n=>e.check($l(ud,n)),e.xid=n=>e.check(Ll(sd,n)),e.ksuid=n=>e.check(zl(cd,n)),e.ipv4=n=>e.check(Nl(ld,n)),e.ipv6=n=>e.check(Ml(gd,n)),e.cidrv4=n=>e.check(Bl(dd,n)),e.cidrv6=n=>e.check(Rl(pd,n)),e.e164=n=>e.check(Dl(fd,n)),e.datetime=n=>e.check(Mg(n)),e.date=n=>e.check(Rg(n)),e.time=n=>e.check($g(n)),e.duration=n=>e.check(Fg(n))});function w(e){return vl(Qg,e)}const J=u("ZodStringFormat",(e,t)=>{G.init(e,t),xa.init(e,t)}),ed=u("ZodEmail",(e,t)=>{Tc.init(e,t),J.init(e,t)}),ka=u("ZodGUID",(e,t)=>{Ec.init(e,t),J.init(e,t)}),ht=u("ZodUUID",(e,t)=>{Sc.init(e,t),J.init(e,t)}),td=u("ZodURL",(e,t)=>{Ac.init(e,t),J.init(e,t)}),nd=u("ZodEmoji",(e,t)=>{Ic.init(e,t),J.init(e,t)}),ad=u("ZodNanoID",(e,t)=>{Pc.init(e,t),J.init(e,t)}),id=u("ZodCUID",(e,t)=>{Lc.init(e,t),J.init(e,t)}),od=u("ZodCUID2",(e,t)=>{zc.init(e,t),J.init(e,t)}),rd=u("ZodULID",(e,t)=>{Nc.init(e,t),J.init(e,t)}),sd=u("ZodXID",(e,t)=>{Mc.init(e,t),J.init(e,t)}),cd=u("ZodKSUID",(e,t)=>{Bc.init(e,t),J.init(e,t)}),ld=u("ZodIPv4",(e,t)=>{Fc.init(e,t),J.init(e,t)}),gd=u("ZodIPv6",(e,t)=>{Uc.init(e,t),J.init(e,t)}),dd=u("ZodCIDRv4",(e,t)=>{Zc.init(e,t),J.init(e,t)}),pd=u("ZodCIDRv6",(e,t)=>{jc.init(e,t),J.init(e,t)}),hd=u("ZodBase64",(e,t)=>{qc.init(e,t),J.init(e,t)}),ud=u("ZodBase64URL",(e,t)=>{Vc.init(e,t),J.init(e,t)}),fd=u("ZodE164",(e,t)=>{Wc.init(e,t),J.init(e,t)}),md=u("ZodJWT",(e,t)=>{Kc.init(e,t),J.init(e,t)}),Ca=u("ZodNumber",(e,t)=>{Qn.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(a,i,o)=>ug(e,a,i),e.gt=(a,i)=>e.check(ua(a,i)),e.gte=(a,i)=>e.check(Ft(a,i)),e.min=(a,i)=>e.check(Ft(a,i)),e.lt=(a,i)=>e.check(ha(a,i)),e.lte=(a,i)=>e.check(Dt(a,i)),e.max=(a,i)=>e.check(Dt(a,i)),e.int=a=>e.check(Ea(a)),e.safe=a=>e.check(Ea(a)),e.positive=a=>e.check(ua(0,a)),e.nonnegative=a=>e.check(Ft(0,a)),e.negative=a=>e.check(ha(0,a)),e.nonpositive=a=>e.check(Dt(0,a)),e.multipleOf=(a,i)=>e.check(fa(a,i)),e.step=(a,i)=>e.check(fa(a,i)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function ze(e){return Hl(Ca,e)}const bd=u("ZodNumberFormat",(e,t)=>{Yc.init(e,t),Ca.init(e,t)});function Ea(e){return Vl(bd,e)}const _d=u("ZodBoolean",(e,t)=>{Jc.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>fg(e,n,a)});function Ut(e){return Wl(_d,e)}const vd=u("ZodUnknown",(e,t)=>{Xc.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>bg()});function be(){return Gl(vd)}const yd=u("ZodNever",(e,t)=>{Qc.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>mg(e,n,a)});function wd(e){return Kl(yd,e)}const xd=u("ZodArray",(e,t)=>{el.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>wg(e,n,a,i),e.element=t.element,e.min=(n,a)=>e.check(dt(n,a)),e.nonempty=n=>e.check(dt(1,n)),e.max=(n,a)=>e.check(ma(n,a)),e.length=(n,a)=>e.check(ba(n,a)),e.unwrap=()=>e.element});function K(e,t){return sg(xd,e,t)}const kd=u("ZodObject",(e,t)=>{nl.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>xg(e,n,a,i),q(e,"shape",()=>t.shape),e.keyof=()=>jt(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:be()}),e.loose=()=>e.clone({...e._zod.def,catchall:be()}),e.strict=()=>e.clone({...e._zod.def,catchall:wd()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>ks(e,n),e.safeExtend=n=>Cs(e,n),e.merge=n=>Es(e,n),e.pick=n=>ws(e,n),e.omit=n=>xs(e,n),e.partial=(...n)=>Ss(Sa,e,n[0]),e.required=(...n)=>Ts(Ia,e,n[0])});function O(e,t){const n={type:"object",shape:e??{},...z(t)};return new kd(n)}const Cd=u("ZodUnion",(e,t)=>{al.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>kg(e,n,a,i),e.options=t.options});function ut(e,t){return new Cd({type:"union",options:e,...z(t)})}const Ed=u("ZodIntersection",(e,t)=>{il.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Cg(e,n,a,i)});function Sd(e,t){return new Ed({type:"intersection",left:e,right:t})}const Td=u("ZodRecord",(e,t)=>{ol.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Eg(e,n,a,i),e.keyType=t.keyType,e.valueType=t.valueType});function Xe(e,t,n){return new Td({type:"record",keyType:e,valueType:t,...z(n)})}const Zt=u("ZodEnum",(e,t)=>{rl.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(a,i,o)=>_g(e,a,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(a,i)=>{const o={};for(const r of a)if(n.has(r))o[r]=t.entries[r];else throw new Error(`Key ${r} not found in enum`);return new Zt({...t,checks:[],...z(i),entries:o})},e.exclude=(a,i)=>{const o={...t.entries};for(const r of a)if(n.has(r))delete o[r];else throw new Error(`Key ${r} not found in enum`);return new Zt({...t,checks:[],...z(i),entries:o})}});function jt(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(a=>[a,a])):e;return new Zt({type:"enum",entries:n,...z(t)})}const Ad=u("ZodTransform",(e,t)=>{sl.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>yg(e,n),e._zod.parse=(n,a)=>{if(a.direction==="backward")throw new Mn(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(Ye(o,n.value,t));else{const r=o;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=e),n.issues.push(Ye(r))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(o=>(n.value=o,n)):(n.value=i,n)}});function Id(e){return new Ad({type:"transform",transform:e})}const Sa=u("ZodOptional",(e,t)=>{ra.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>wa(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function Ta(e){return new Sa({type:"optional",innerType:e})}const Pd=u("ZodExactOptional",(e,t)=>{cl.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>wa(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function Ld(e){return new Pd({type:"optional",innerType:e})}const zd=u("ZodNullable",(e,t)=>{ll.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Sg(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function Aa(e){return new zd({type:"nullable",innerType:e})}const Nd=u("ZodDefault",(e,t)=>{gl.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Ag(e,n,a,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Md(e,t){return new Nd({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Fn(t)}})}const Bd=u("ZodPrefault",(e,t)=>{dl.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Ig(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function Rd(e,t){return new Bd({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Fn(t)}})}const Ia=u("ZodNonOptional",(e,t)=>{pl.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Tg(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function Od(e,t){return new Ia({type:"nonoptional",innerType:e,...z(t)})}const $d=u("ZodCatch",(e,t)=>{hl.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Pg(e,n,a,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Dd(e,t){return new $d({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Fd=u("ZodPipe",(e,t)=>{ul.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Lg(e,n,a,i),e.in=t.in,e.out=t.out});function Pa(e,t){return new Fd({type:"pipe",in:e,out:t})}const Ud=u("ZodReadonly",(e,t)=>{fl.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>zg(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function Zd(e){return new Ud({type:"readonly",innerType:e})}const jd=u("ZodCustom",(e,t)=>{ml.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>vg(e,n)});function qd(e,t={}){return cg(jd,e,t)}function Hd(e){return lg(e)}const Vd=O({role:jt(["user","assistant"]),content:w(),timestamp:ze().optional()}),Wd=O({sku:w(),name:w(),imageUrl:w().url().optional(),price:w().optional(),originalPrice:w().optional(),url:w().url(),ctaLabel:w().optional()}),Gd=O({buttons:K(O({label:w(),action:O({title:w(),type:w(),payload:be().optional()})}))}),Kd=O({}),Yd=O({label:w().optional()}),La=O({sku:w(),name:w(),price:w(),imageUrl:w().optional(),rating:ze().optional(),reviewCount:ze().optional()}),Jd=O({recommended:La,products:K(La),attributes:K(O({label:w(),values:K(w())})),highlights:K(w()),specialCases:K(w()).optional(),recommendedText:w().optional(),winnerHits:Xe(w(),O({positive:K(w()).optional(),negative:K(w()).optional()})).optional(),productActions:Xe(w(),O({title:w(),type:w(),payload:be().optional()})).optional()}),Xd=O({label:w(),sentiment:jt(["positive","negative","neutral"]).optional()}),Qd=O({product:Xe(w(),be()),role:w().optional(),reason:w().optional(),labels:K(Xd).optional(),expertQualityScore:ze().optional(),reviewHighlight:w().optional(),action:O({title:w(),type:w(),payload:be().optional()}).optional()}),ep=O({suggestions:K(Qd)}),tp=O({title:w().optional(),text:w().optional(),reviewCount:w().optional(),action:O({title:w(),type:w(),payload:be().optional()})}),np=O({entries:K(O({name:w(),image:w().optional(),description:w().optional(),action:O({title:w(),type:w(),payload:be().optional()})}))}),ap=O({entries:K(O({shortName:w(),detailedMessage:w().optional(),whyDifferent:w().optional(),image:w().optional(),action:O({title:w(),type:w(),payload:be().optional()})}))}),za=O({title:w(),type:w(),payload:be().optional()}),ip=O({name:w().optional(),value:w().optional(),variant_name:w().optional(),sku:w().optional(),price:ut([ze(),w()]).optional()}),op=O({product:O({sku:w().optional(),name:w().optional(),images:K(w()).optional(),imageUrl:w().optional(),rating:ze().optional(),reviewCount:ze().optional(),price:w().optional(),originalPrice:w().optional(),price_async:Ut().optional(),inStock:Ut().optional(),promotions:K(w()).optional(),variants:K(ip).optional(),url:w().optional(),cartCode:w().optional(),description:w().optional(),specifications:ut([Xe(w(),w()),K(O({key:w(),value:w()}))]).optional()}).optional(),action:za.optional()}),rp=O({endOfList:Ut().optional()}),sp=O({review_class:w().optional(),review_text:w().optional(),review_rating:ut([w(),ze()]).optional(),review_tag:w().optional()}),cp=O({reviews:K(sp).optional()}),lp=O({productName:w().optional(),pros:K(w()).optional(),cons:K(w()).optional()}),gp=O({groups:K(O({groupName:w(),products:K(Xe(w(),be())).optional()})).optional(),filterTags:K(O({title:w(),action:za.optional()})).optional()}),dp=O({summary:w().optional(),products_discussed:K(w()).optional(),user_sentiment:w().optional()}),pp={components:{MessageBubble:{schema:Vd,description:"A single chat message bubble for user or assistant turns."},ProductCard:{schema:Wd,description:"A product card rendered inline in the chat stream."},ActionButtons:{schema:Gd,description:"A horizontal row of quick-reply action buttons."},TypingIndicator:{schema:Kd,description:"An animated indicator shown while the assistant is typing."},Divider:{schema:Yd,description:"A horizontal rule with an optional label."},ComparisonTable:{schema:Jd,description:"A product comparison table with recommended pick, attribute rows, and highlights."},AITopPicks:{schema:ep,description:"Rich AI-curated product suggestion cards with roles, sentiment labels, scores, and review quotes."},GroundingReviewCard:{schema:tp,description:"A card showing review grounding data with review count and CTA."},AIGroupingCards:{schema:np,description:"Category grouping cards with images and labels for product discovery."},AISuggestedSearchCards:{schema:ap,description:"Suggested search cards with images, descriptions, and differentiation."},ProductDetailsPanel:{schema:op,description:"Full product detail view with images, specs, variants, and purchase actions."},ProductGrid:{schema:rp,description:'A scrollable grid of ProductCard children with optional "more" pagination.'},ReviewHighlights:{schema:cp,description:"A list of highlighted customer reviews with sentiment and ratings."},ProsAndCons:{schema:lp,description:"A pros and cons list for a product."},CategoriesContainer:{schema:gp,description:"Tabbed product groups with optional filter tag buttons."},HandoffNotice:{schema:dp,description:"A notice shown when the conversation is escalated to a human agent."}}};function hp(e){return e.length>120?!1:/^[a-zA-Z0-9#(),.\s%/\-]+$/.test(e)}function qt(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}const Qe=class Qe extends ui{constructor(){super(...arguments),this._shadow=null,this._rootEl=null,this._launcher=null,this._drawer=null,this._bridge=null,this._drawerVisible=!1,this._messages=[],this._currentMessageId=0,this._abortControllers=new Set,this._currentThreadId=null,this._lastThreadId=null,this._chatCreatedAt="",this._lastBackendContext=null,this._productSort={type:"related"},this._comparisonSelectMode=!1,this._comparisonSelectedSkus=[],this._viewedProductSkus=new Set,this._thumbnailEntries=[],this._choicePrompterEl=null,this._openState="full",this._mobileBreakpoint=768,this._isMobileViewport=!1,this._pdpLaunched=!1,this._pdpPrimingInFlight=!1,this._queuedUserMessages=[],this._productContextUnavailableSku=null,this._i18n=kt,this._extendedModeManager=null,this._activeTypewriter=null,this._activeTtsHandle=null,this._activeRequestThreadId=null,this._skuToProductItem={},this._conversationMode=null,this._initComplete=!1,this._pendingActions=[],this._bridgeContext=null,this._cartQuantity=null,this._threadsWithFirstBot=new Set,this._panel=null,this._localPanelHistory=[],this._currentPanelSource=null,this._session=null,this._presentation=new An,this._eventCallbacks=new Map,this._lastSentAction=null,this._consecutiveErrorCount=0,this._lastErrorMessage=""}async onInit(t){this._i18n=this._resolveI18n(t),this._chatCreatedAt=new Date().toISOString(),this._shadow=this.root.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=Xr,this._shadow.appendChild(n);const a=document.createElement("div");a.className="gengage-chat-root",this._rootEl=a,this._shadow.appendChild(a);const i=t.variant??"floating";if(i==="floating"){const g={onClick:()=>this.open(),ariaLabel:this._i18n.openButton};t.launcherImageUrl!==void 0?g.imageUrl=t.launcherImageUrl:t.launcherSvg!==void 0&&(g.svgMarkup=t.launcherSvg),t.hideMobileLauncher!==void 0&&(g.hideMobile=t.hideMobileLauncher),t.mobileBreakpoint!==void 0&&(g.mobileBreakpoint=t.mobileBreakpoint),t.launcherTooltip!==void 0&&(g.tooltip=t.launcherTooltip),this._launcher=Zo(g),a.appendChild(this._launcher.container)}i==="overlay"&&a.classList.add("gengage-chat--overlay");const o=document.createElement("div");a.appendChild(o),this._drawer=new Fo(o,{i18n:this._i18n,onSend:(g,h)=>this._sendMessage(g,h),onClose:()=>this.close(),onAttachment:g=>this._handleAttachment(g),onPanelToggle:()=>{this._drawer?.persistPanelState(t.accountId)},onRollback:g=>this._handleRollback(g),onPanelBack:()=>this._navigatePanelBack(),onPanelForward:()=>this._panel?.navigateForward(),headerTitle:t.headerTitle,headerAvatarUrl:t.headerAvatarUrl,launcherImageUrl:t.launcherImageUrl,headerBadge:t.headerBadge,headerCartUrl:t.headerCartUrl,headerFavoritesToggle:t.headerFavoritesToggle,onCartClick:()=>{t.headerCartUrl?this._saveSessionAndOpenURL(t.headerCartUrl):t.onCartClick?.()},onFavoritesClick:()=>{cs(),t.onFavoritesClick?.(),this._openFavoritesPanel()},getMobileState:()=>this._openState??"full",getMobileViewport:()=>this._isMobileViewport,onMobileSnap:g=>{g==="close"?this.close():(this._openState=g,this._applyOpenStateClasses())},onThumbnailClick:g=>this._rollbackToThread(g),onLinkClick:g=>{this._saveSessionAndOpenURL(g)},voiceEnabled:t.voiceEnabled,voiceLang:t.locale?`${t.locale.split("-")[0]??"tr"}-${(t.locale.split("-")[1]??t.locale.split("-")[0]??"TR").toUpperCase()}`:void 0,onNewChat:()=>{this._abortControllers.forEach(g=>g.abort()),this._abortControllers.clear(),this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,this._messages=[],this._drawer?.clearMessages(),this._currentThreadId=yt(),this._lastThreadId=this._currentThreadId,this._choicePrompterEl?.remove(),this._choicePrompterEl=null,this._viewedProductSkus.clear(),this._drawer?.clearPanel(),this._consecutiveErrorCount=0,this._lastErrorMessage="",this._thumbnailEntries=[],this._drawer?.setThumbnails([]),this._panel.snapshots.clear(),this._panel.threads=[],this._presentation.reset(),this._drawer?.setPresentationFocus(null),this._drawer?.setFormerMessagesButtonVisible(!1),this._showWelcomeIfNeeded()},presentation:{onPinnedToBottomChange:g=>{this._presentation.pinnedToBottom=g},onUserInteractingChange:g=>{this._presentation.userInteracting=g},onFormerMessagesHint:()=>{this._presentation.focusedThreadId&&this._hasMultipleThreadIds()&&this._drawer?.setFormerMessagesButtonVisible(!0)},shouldBlockSoftAutoScroll:()=>this._presentation.shouldBlockStreamAutoScroll(),onReleasePresentationFocus:()=>this._releasePresentationFocus()}}),this._extendedModeManager=new Zr({onChange:g=>this._panel?.notifyExtension(g),productDetailsInPanel:t.isDemoWebsite??!1}),this._panel=new jr({drawer:()=>this._drawer,shadow:()=>this._shadow,currentThreadId:()=>this._currentThreadId,bridge:()=>this._bridge,extendedModeManager:()=>this._extendedModeManager,i18n:()=>this._i18n,rollbackToThread:g=>this._rollbackToThread(g)}),i!=="inline"&&this._drawer.getElement().classList.add("gengage-chat-drawer--hidden"),this._drawer.restorePanelState(t.accountId);const r=t.panelMode??"auto";r==="collapsed"?this._drawer.setPanelCollapsed(!0):r==="expanded"&&this._drawer.setForceExpanded();const s=sessionStorage.getItem("gengage_restore_session_id"),c=sessionStorage.getItem("gengage_restore_sku"),l=!!(s&&c);l&&(sessionStorage.removeItem("gengage_restore_session_id"),sessionStorage.removeItem("gengage_restore_sku"));try{const g=new Fr;await g.open(),this._session=new Tn(g),await this._restoreFromIndexedDB(l)}catch{this._session=new Tn(null)}this._registerPublicAPI(),t.mobileInitialState!==void 0&&(this._openState=t.mobileInitialState),this._mobileBreakpoint=t.mobileBreakpoint??768,this._syncViewportState();const d=()=>this._syncViewportState();if(window.addEventListener("resize",d,{passive:!0}),this.addCleanup(()=>window.removeEventListener("resize",d)),window.visualViewport){const g=()=>{if(!this._drawerVisible||!this._isMobileViewport)return;const h=this._drawer?.getElement();if(!h)return;const b=window.innerHeight-(window.visualViewport?.height??window.innerHeight);h.style.setProperty("--gengage-keyboard-offset",`${Math.max(0,b)}px`)};window.visualViewport.addEventListener("resize",g),this.addCleanup(()=>window.visualViewport?.removeEventListener("resize",g))}i==="inline"&&(this._drawerVisible=!0,this.isVisible=!0,this._applyOpenStateClasses(),this._presentation.setShown(!0),setTimeout(()=>this._maybeAutoAnchorUnreadAssistant(),60));const p={namespace:"chat",onMessage:g=>this._handleBridgeMessage(g)};t.allowedOrigins!==void 0&&(p.allowedOrigins=t.allowedOrigins),this._bridge=new mi(p),this._lastSku=this.config.pageContext?.sku,this._initComplete=!0;for(const g of this._pendingActions)this._sendAction(g.action,g.options);this._pendingActions=[],ve("gengage:chat:ready",{}),es("chat"),t.onReady?.()}onUpdate(t){t.sku!==void 0&&t.sku!==this._lastSku&&(this._lastSku=t.sku,this._resetForNewPage())}onShow(){this._showDrawer(),this.emit("open"),ve("gengage:chat:open",{state:this._openState}),ts("chat"),this.config.onOpen?.(),this._showWelcomeIfNeeded(),!this._pdpLaunched&&this.config.pageContext?.sku&&(this._pdpLaunched=!0,this._pdpPrimingInFlight=!0,this._sendAction({title:"",type:"launchSingleProduct",payload:{sku:this.config.pageContext.sku}},{silent:!0,isPdpPrime:!0}))}onHide(){(this.config.variant??"floating")==="floating"&&(this.root.style.display=""),this._hideDrawer(),this.emit("close"),ve("gengage:chat:close",{}),this.config.onClose?.()}onDestroy(){this._abortControllers.forEach(t=>t.abort()),this._abortControllers.clear(),this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,this._drawer?.destroy(),ln(),this._drawer=null,this._bridge?.destroy(),this._bridge=null,this._extendedModeManager=null,this._panel?.destroy(),this._panel=null,this._session?.close(),this._session=null,this._localPanelHistory=[],this._currentPanelSource=null,window.gengage&&delete window.gengage.chat,this._shadow&&(this._shadow.innerHTML="",this._shadow=null),this._rootEl=null}open(t){t?.state!==void 0&&(this._openState=t.state,this._drawerVisible&&this._applyOpenStateClasses()),this.show(),t?.initialMessage!==void 0&&this._sendMessage(t.initialMessage)}openWithAction(t,n){n?.sku!==void 0&&this.update({sku:n.sku}),this._pdpLaunched=!0,n?.state!==void 0?this._openState=n.state:this._isMobileViewport&&(this._openState="half"),this.show(),this._drawerVisible&&this._applyOpenStateClasses(),this._sendAction(t)}sendMessage(t){this._sendMessage(t)}sendAction(t,n){this._sendAction(t,n)}close(){this.hide()}saveSession(t,n){sessionStorage.setItem("gengage_restore_session_id",t),sessionStorage.setItem("gengage_restore_sku",n)}get isOpen(){return this._drawerVisible}addCallback(t,n){let a=this._eventCallbacks.get(t);return a||(a=new Set,this._eventCallbacks.set(t,a)),a.add(n),()=>{a.delete(n),a.size===0&&this._eventCallbacks.delete(t)}}_resetForNewPage(){this._activeRequestThreadId=null,this._abortControllers.forEach(t=>t.abort()),this._abortControllers.clear(),this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,this._messages.length=0,this._drawer?.clearMessages(),this._drawer?.clearPanel(),this._currentPanelSource=null,this._panel.snapshots.clear(),this._panel.threads=[],this._thumbnailEntries=[],this._drawer?.setThumbnails([]),this._comparisonSelectMode=!1,this._comparisonSelectedSkus=[],this._viewedProductSkus.clear(),this._currentThreadId=null,this._lastThreadId=null,this._lastBackendContext=null,this._chatCreatedAt=new Date().toISOString(),this._pdpLaunched=!1,this._pdpPrimingInFlight=!1,this._queuedUserMessages=[],this._productContextUnavailableSku=null,this._presentation.reset(),this._drawer?.setPresentationFocus(null),this._drawer?.setFormerMessagesButtonVisible(!1)}_flushPresentationScroll(){const t=this._presentation.scrollRequest;if(!t||!this._drawer)return;let n=!1;t.type==="thread"&&t.threadId?(n=this._drawer.scrollThreadIntoView(t.threadId,t.behavior),n||(this._drawer.scrollToBottomPresentation(t.behavior),n=!0)):t.type==="bottom"&&(this._drawer.scrollToBottomPresentation(t.behavior),n=!0),n&&this._presentation.consumeScrollRequest(t.id)}_releasePresentationFocus(){this._presentation.releaseFocusedThread(),this._drawer?.setPresentationFocus(null),this._drawer?.setFormerMessagesButtonVisible(!1)}_hasMultipleThreadIds(){const t=new Set;for(const n of this._messages)n.threadId&&t.add(n.threadId);return t.size>1}_orderedThreadIds(){const t=[],n=new Set;for(const a of this._messages)a.threadId&&!n.has(a.threadId)&&(n.add(a.threadId),t.push(a.threadId));return t}_maybeAutoAnchorUnreadAssistant(){if(!this._drawer||!this._presentation.shown)return;const t=this._orderedThreadIds();if(t.length===0)return;const n=Hr(t,this._presentation);if(!n)return;const a=`${n}:assistant`;this._presentation.lastAutoAnchoredGroupId!==a&&(this._presentation.userInteracting&&!this._presentation.pinnedToBottom||this._drawer.scrollThreadIntoView(n,"smooth")&&this._presentation.markGroupAutoAnchored(a))}_handleBridgeMessage(t){switch(t.type){case"openChat":this.open();break;case"closeChat":this.close();break;case"startNewChatWithLauncherAction":{const n=t.payload,a=n?.action,i=qt(a)?a:qt(n)?n:null;i&&this._sendAction(i,{silent:!0}),this.open();break}case"startNewChatWithDetailContext":{const n=t.payload;if(n&&typeof n=="object"){this._bridgeContext=n;const a=n.sku;if(a&&this.update({sku:a}),qt(n.action)){this._pdpLaunched=!0,this.open(),this._sendAction(n.action);break}}this.open();break}case"launcherAction":{const a=t.payload?.action;a&&typeof a=="object"&&"type"in a&&this._sendAction(a);break}case"scrollToBottom":this._presentation.requestScrollToBottom("smooth"),setTimeout(()=>this._flushPresentationScroll(),40);break;case"addToCardHandler":{this._bridge?.send("addToCardResult",t.payload);break}case"cartQuantityHandler":{const n=t.payload;n&&"quantity"in n&&typeof n.quantity=="number"&&(this._cartQuantity=n.quantity);break}case"minimizeRequestedByUser":this._extendedModeManager?.setHiddenByUser(!0);break;case"bgColorChange":{const a=t.payload?.color;typeof a=="string"&&hp(a)&&this._shadow&&this._shadow.host.style.setProperty("--gengage-chat-bg",a);break}}}_registerPublicAPI(){window.gengage||(window.gengage={}),window.gengage.chat={open:t=>this.open(t),openWithAction:(t,n)=>this.openWithAction(t,n),sendMessage:t=>this.sendMessage(t),sendAction:(t,n)=>this.sendAction(t,n),close:()=>this.close(),saveSession:(t,n)=>this.saveSession(t,n),get isOpen(){return!1},on:(t,n)=>this.on(t,n),trackCheckout:(t,n)=>this.trackCheckout(t,n),flushMeteringSummary:t=>this.flushMeteringSummary(t),addCallback:(t,n)=>this.addCallback(t,n)},Object.defineProperty(window.gengage.chat,"isOpen",{get:()=>this._drawerVisible})}_showDrawer(){if(this._drawerVisible)return;this._drawerVisible=!0;const t=this._drawer?.getElement();t&&t.classList.remove("gengage-chat-drawer--hidden"),this._applyOpenStateClasses(),this._drawer?.trapFocus(),this._isMobileViewport&&this._openState==="half"||this._drawer?.focusInput(),this._extendedModeManager?.setChatShown(!0),this._presentation.setShown(!0),setTimeout(()=>this._maybeAutoAnchorUnreadAssistant(),60)}_showWelcomeIfNeeded(){if(this._messages.length!==0||!this.config.welcomeMessage)return;const t={id:yt(),role:"assistant",content:this.config.welcomeMessage,timestamp:Date.now(),status:"done"};this._messages.push(t),this._drawer?.addMessage(t),this.config.welcomeActions?.length&&this._drawer?.setPills(this.config.welcomeActions.map(n=>({label:n,onAction:()=>this._sendMessage(n)})))}_hideDrawer(){if(!this._drawerVisible)return;this._drawer?.releaseFocus(),this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,this._drawerVisible=!1,this._openState="full";const t=this._drawer?.getElement();t&&t.classList.add("gengage-chat-drawer--hidden"),this._applyOpenStateClasses(),this._extendedModeManager?.setChatShown(!1),this._presentation.setShown(!1),this._drawer?.setPresentationFocus(null),this._drawer?.setFormerMessagesButtonVisible(!1)}_syncViewportState(){if(this._rootEl){if(this._isMobileViewport=window.innerWidth<=this._mobileBreakpoint,this._rootEl.classList.toggle("gengage-chat-root--mobile",this._isMobileViewport),this._launcher){const t=this._isMobileViewport&&this.config.hideMobileLauncher===!0;this._launcher.container.classList.toggle("gengage-chat-launcher--hidden-mobile",t)}this._applyOpenStateClasses()}}_applyOpenStateClasses(){if(!this._rootEl)return;const t=this._drawerVisible&&this._isMobileViewport&&this._openState==="half",n=this._drawerVisible&&this._isMobileViewport&&this._openState==="full";this._rootEl.classList.toggle("gengage-chat-root--open",this._drawerVisible),this._rootEl.classList.toggle("gengage-chat-root--mobile-half",t),this._rootEl.classList.toggle("gengage-chat-root--mobile-full",n)}_handleAttachment(t){const n=Ci(t);if(!n.ok){const a=n.reason==="invalid_type"?this._i18n.invalidFileType:this._i18n.fileTooLarge;ve("gengage:global:error",{message:a,source:"chat"});return}this._drawer?.stageAttachment(t)}_sendMessage(t,n){if(this._pdpPrimingInFlight){this._queuedUserMessages.push(n!==void 0?{text:t,attachment:n}:{text:t});return}ps(),this._messages.some(o=>o.role==="user")||hs();const i=n!==void 0?{title:t,type:"findSimilar",payload:t?{text:t}:{}}:{title:t,type:"user_message",payload:t};n!==void 0?this._sendAction(i,{attachment:n}):this._sendAction(i)}_flushQueuedUserMessages(){if(this._pdpPrimingInFlight||this._queuedUserMessages.length===0)return;const t=[...this._queuedUserMessages];this._queuedUserMessages=[];for(const n of t)this._sendMessage(n.text,n.attachment)}_sendAction(t,n){if(this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,this._lastSentAction={action:t,options:n},!this._initComplete){this._pendingActions.length<10&&this._pendingActions.push({action:t,options:n});return}if(this._choicePrompterEl?.remove(),this._choicePrompterEl=null,!n?.preservePanel&&this._comparisonSelectMode&&(this._comparisonSelectMode=!1,this._comparisonSelectedSkus=[]),n?.preservePanel||(this._localPanelHistory=[]),this._currentThreadId&&this._lastThreadId&&this._lastThreadId>this._currentThreadId){const v=this._currentThreadId,L=this._messages.filter(T=>T.threadId!==void 0&&T.threadId>v);this._messages=this._messages.filter(T=>!T.threadId||T.threadId<=v);for(const T of L)this._shadow?.querySelector(`[data-message-id="${CSS.escape(T.id)}"]`)?.remove(),this._panel.snapshots.delete(T.id),this._panel.snapshotTypes.delete(T.id);this._shadow?.querySelectorAll("[data-thread-id]")?.forEach(T=>{T instanceof HTMLElement&&T.dataset.threadId&&T.dataset.threadId>v&&T.remove()})}this._drawer?.setPills([]),this._drawer?.clearInputAreaChips(),this._bridge?.send("isResponding",!0);const a=yt();this._currentThreadId=a,this._lastThreadId=a,this._panel&&t.type!=="launchSingleProduct"&&(this._panel.lastActionType=t.type);const i=n?.preservePanel===!0,o=t.type==="launchSingleProduct"&&n?.silent===!0&&n?.isPdpPrime===!0;if(i||(this._activeRequestThreadId=a),!n?.silent){const v=typeof t.payload=="string"?t.payload:t.title,L=this._messages.length>0?this._messages[this._messages.length-1]:void 0;if(!(L!==void 0&&L.role==="user"&&L.content===v)){const T=this._createMessage("user",v);T.threadId=a,n?.attachment!==void 0&&(T.attachment=n.attachment),this._drawer?.addMessage(T),this._messages.push(T)}}if(!n?.silent&&this._hasUnavailableProductContext()&&(t.type==="user_message"||t.type==="inputText")){const v=this._i18n.productNotFoundMessage,L=this._createMessage("assistant",v);L.threadId=a,L.status="done",this._messages.push(L),this._ensureAssistantMessageRendered(L),this._drawer?.updateBotMessage(L.id,v),this._bridge?.send("isResponding",!1),this.emit("message",L),this._persistToIndexedDB().catch(()=>{});return}let s=this._currentPanelSource,c=!1;const l=()=>{c||n?.preservePanel||(s=this._currentPanelSource,c=!0)},d=()=>{if(this._drawer?.isPanelLoading()){if(s){const v=this._buildRenderContext(),L=s.kind==="favorites"?this._buildFavoritesPageEl():this._renderUISpec(s.spec,v);this._drawer.setPanelContent(L),this._currentPanelSource=s}else this._drawer.clearPanel(),this._currentPanelSource=null;s=null}};this._drawer?.showTypingIndicator();let p="";const g=this._createMessage("assistant","");g.threadId=a,g.status="streaming",n?.silent&&(g.silent=!0),this._messages.push(g),this._presentation.registerAssistantActivity(a),this._presentation.requestThreadFocus(a,"smooth"),this._drawer?.setPresentationFocus(a),this._drawer?.setFormerMessagesButtonVisible(!1),setTimeout(()=>this._flushPresentationScroll(),40),n?.preservePanel||(this._abortControllers.forEach(v=>v.abort()),this._abortControllers.clear());const h={middlewareUrl:this.config.middlewareUrl,...this.config.accountId?{accountId:this.config.accountId}:{}};n?.attachment!==void 0&&(h.attachment=n.attachment);const _=this._getVisibleMessages().filter(v=>v!==g&&(v.content||v.role==="assistant")).slice(-50).map(v=>({role:v.role==="user"?"user":"model",content:v.content??""})),y={outputLanguage:Jr(this.config.locale),parentUrl:window.location.href,windowWidth:String(window.innerWidth),windowHeight:String(window.innerHeight),selfUrl:"",id:this.config.session?.sessionId??"",userId:this.config.session?.userId??"",appId:this.config.accountId,threads:[],createdAt:this._chatCreatedAt,kvkkApproved:Pn(this.config.accountId),voiceEnabled:this.config.voiceEnabled??!1,threadId:a,isControlGroup:this.config.session?.abTestVariant==="control",isMobile:this._isMobileViewport};this.config.session?.viewId!==void 0&&(y.viewId=this.config.session.viewId);const x=wo(t,{pageContext:this.config.pageContext,backendContext:this._lastBackendContext,isMobile:this._isMobileViewport}),k={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",type:x.type,locale:this.config.locale??"tr",meta:y,context:{...this._lastBackendContext??{},messages:_,session_id:this.config.session?.sessionId??""}};this.config.session?.userId!==void 0&&(k.user_id=this.config.session.userId),this.config.session?.viewId!==void 0&&(k.view_id=this.config.session.viewId),x.payload!==void 0&&(k.payload=x.payload),this.config.pageContext?.sku!==void 0&&(k.sku=this.config.pageContext.sku),this.config.pageContext?.pageType!==void 0&&(k.page_type=this.config.pageContext.pageType);const I=crypto.randomUUID(),m=Date.now();let C=0,B=!1,D=!1,E=!1,A=!1,S=!1,R=null;const ne=()=>{if(this._drawer){if(this._isMobileViewport||!E){this._drawer.setPanelAiZoneState("hidden");return}A||(S?this._drawer.setPanelAiZoneState("hidden"):this._drawer.setPanelAiZoneState("analyzing",{analyzingLabel:this._i18n.aiAnalysisAnalyzingLabel}))}};this.track(Ra(this.analyticsContext(),{endpoint:"process_action",request_id:I,widget:"chat"}));let U=null;if(U=Co(k,{onTextChunk:(v,L,P)=>{if(!i&&a!==this._activeRequestThreadId||(p+=v,this._drawer?.removeTypingIndicator(),P?.skuToProductItem&&(this._skuToProductItem={...this._skuToProductItem,...P.skuToProductItem}),P?.conversationMode&&(this._conversationMode=P.conversationMode),this.track(Oa(this.analyticsContext(),{request_id:I,chunk_index:C++,widget:"chat"})),!this._drawer))return;let T=p;if(L&&It(T)){const M=this.config.accountId;if(!Pn(M)){const ee=Kr(T);ee?this._drawer?.showKvkkBanner(ee,()=>{this._drawer?.hideKvkkBanner(),Ln(M)}):Ln(M)}T=Gr(T)}const N=this._shadow?.querySelector(`[data-message-id="${g.id}"] .gengage-chat-bubble-text`);if(N?N.innerHTML=_e(T):(g.content=T,g.role==="assistant"&&g.threadId&&!this._threadsWithFirstBot.has(g.threadId)&&(this._threadsWithFirstBot.add(g.threadId),this._drawer.markFirstBotMessage(g.id)),this._drawer.addMessage(g)),L){g.content=T,g.status="done",Nn();const M=this._shadow?.querySelector(`[data-message-id="${g.id}"] .gengage-chat-bubble-text`);if(M){this._activeTypewriter?.cancel();const ee=P?.productMentions;this._activeTypewriter=Pr({container:M,html:_e(T),onTick:()=>this._drawer?.scrollToBottomIfNeeded(),onComplete:()=>{this._activeTypewriter=null,ee&&ee.length>0&&M&&Lr({container:M,mentions:ee,onProductClick:W=>{this._sendAction({title:ee.find(Y=>Y.sku===W)?.short_name??W,type:"launchSingleProduct",payload:{sku:W}})}})}})}}},onUISpec:(v,L,P)=>{if(!i&&a!==this._activeRequestThreadId||L!=="chat")return;const T=v.elements[v.root],N=T?.type??"unknown";this.track($a(this.analyticsContext(),{request_id:I,chunk_index:C,component_type:N,widget:"chat"}));const M=this._buildRenderContext();if(M.isStreaming=!0,N==="ComparisonTable"){const Z=T?.props?.products;rs(Array.isArray(Z)?Z.length:0)}if(N==="ProductGrid"){const Z=T?.children?.length??0;ls(void 0,Z)}const ee=P==="panel"&&this._panel?this._panel.toPanelSpec(v):v;if(P==="panel"&&this._panel){const Z=!D;D=!0;const j=qr({componentType:N,similarsAppend:T?.props?.similarsAppend===!0,currentPanelType:this._panel.currentType,hasPanelContent:this._drawer?.hasPanelContent()??!1,isPanelLoading:this._drawer?.isPanelLoading()??!1,isFirstPanelContentInStream:Z});j==="appendSimilars"?this._appendSimilarsToPanel(ee,M):j==="append"?(this._drawer?.appendPanelContent(this._renderUISpec(ee,M)),this._comparisonSelectMode&&this._refreshComparisonUI()):(this._comparisonSelectMode=!1,this._comparisonSelectedSkus=[],this._drawer?.setPanelContent(this._renderUISpec(ee,M)),this._currentPanelSource={kind:"spec",spec:ee},this._panel.currentType=N),N==="ProductDetailsPanel"&&t.type==="launchSingleProduct"&&this._clearUnavailableProductContext(),g.threadId&&!this._panel.threads.includes(g.threadId)&&this._panel.threads.push(g.threadId);const V=this._panel.currentType??N,F=T?.props?.panelTitle;if(this._panel.updateTopBar(V,F),this._panel.updateExtendedMode(N),N==="ProductGrid"||N==="CategoriesContainer"){if(E=!this._isMobileViewport,R){const f=this._buildRenderContext();f.isStreaming=!0;const $=this._renderUISpec(R,f);A=!0,this._drawer?.setPanelAiZoneState("results",{resultEl:$}),R=null}}else j!=="appendSimilars"&&j!=="append"&&(E=!1,R=null,this._drawer?.setPanelAiZoneState("hidden"))}if(N==="ProductDetailsPanel"&&!g.silent&&P==="panel"){const Z=T?.props?.product;if(Z){const j={root:"root",elements:{root:{type:"ProductSummaryCard",props:{product:Z}}}},V=this._shadow?.querySelector(".gengage-chat-messages");if(V){const F=this._renderUISpec(j,M);g.threadId&&(F.dataset.threadId=g.threadId),V.appendChild(F),F.scrollIntoView({behavior:"auto",block:"end"}),this._drawer?.refreshPresentationCollapsed()}}}const W=N==="AITopPicks"||N==="AIGroupingCards";let Y=!1,he=!1;if(W&&!this._isMobileViewport&&!g.silent)if(E){const Z=this._renderUISpec(v,M);A=!0,this._drawer?.setPanelAiZoneState("results",{resultEl:Z}),Y=!0,R=null}else R=v,he=!0;if(!g.silent&&(P!=="panel"||N==="ProductCard")&&N!=="ActionButtons"&&!Y&&!(he&&W)){const Z=this._shadow?.querySelector(".gengage-chat-messages");if(Z){const j=this._renderUISpec(v,M);g.threadId&&(j.dataset.threadId=g.threadId),Z.appendChild(j),j.scrollIntoView({behavior:"auto",block:"end"}),this._drawer?.refreshPresentationCollapsed()}}if((N==="ProductGrid"||N==="ProductCard")&&g.threadId){const Z=T?.children??[],j=N==="ProductGrid"?Z.map(V=>v.elements[V]?.props?.product).filter(Boolean):[T?.props?.product].filter(Boolean);for(const V of j){const F=V.sku,f=V.imageUrl;F&&f&&this._thumbnailEntries.push({sku:F,imageUrl:f,threadId:g.threadId}),F&&this._viewedProductSkus.add(F)}this._drawer?.setThumbnails(this._thumbnailEntries)}if(N==="ProductGrid"||N==="ProductDetailsPanel"){const j=(N==="ProductGrid"?(T?.children??[]).map(V=>v.elements[V]?.props?.product).filter(Boolean):[T?.props?.product??T?.props].filter(Boolean)).map(V=>V.imageUrl).filter(V=>typeof V=="string").slice(0,5);j.length>0&&this._bridge?.send("previewImages",{images:j})}if(N==="ProductGrid"&&P==="panel"&&this._viewedProductSkus.size>=2&&!this._comparisonSelectMode&&!Rr()&&!Or(this._currentThreadId??"")){this._choicePrompterEl?.remove(),this._shadow?.querySelectorAll(".gengage-chat-choice-prompter").forEach(j=>j.remove()),this._choicePrompterEl=Br({heading:this._i18n.choicePrompterHeading,suggestion:this._i18n.choicePrompterSuggestion,ctaLabel:this._i18n.choicePrompterCta,threadId:this._currentThreadId??"",dismissAriaLabel:this._i18n.dismissAriaLabel,onCtaClick:()=>{this._comparisonSelectMode=!0,this._choicePrompterEl=null,this._refreshComparisonUI()},onDismiss:()=>{this._choicePrompterEl=null}});const Z=this._shadow?.querySelector(".gengage-chat-panel-float");if(Z){if(Z.appendChild(this._choicePrompterEl),this._isMobileViewport&&window.visualViewport){const j=this._choicePrompterEl,V=()=>{window.visualViewport.height/window.innerHeight<.75&&(j.remove(),this._choicePrompterEl===j&&(this._choicePrompterEl=null),window.visualViewport.removeEventListener("resize",V))};window.visualViewport.addEventListener("resize",V)}}else this._choicePrompterEl=null}if(N==="ActionButtons"){const Z=T?.props?.buttons;if(Z&&Z.length>0){const j=[],V=[];for(const F of Z)if(Mr(F)){const f={label:F.label,action:F.action};F.icon&&(f.icon=F.icon),j.push(f)}else V.push(F);j.length>0&&this._drawer?.setInputAreaChips(j.map(F=>({label:F.label,onAction:()=>this._sendAction(F.action),...F.icon?{icon:F.icon}:{}}))),V.length>0&&this._drawer?.setPills(V.map(F=>{const f={label:F.label,onAction:()=>this._sendAction(F.action)};return F.icon&&(f.icon=F.icon),F.image&&(f.image=F.image),F.description&&(f.description=F.description),f}))}}ne(),g.uiSpec=v},onAction:v=>{if(!(!i&&a!==this._activeRequestThreadId)&&v.type==="action"){const L={};this.config.actionHandling?.unknownActionPolicy!==void 0&&(L.unknownActionPolicy=this.config.actionHandling.unknownActionPolicy),this.config.actionHandling?.allowScriptCall!==void 0&&(L.allowScriptCall=this.config.actionHandling.allowScriptCall),vi(v,{openChat:()=>this.open(),navigate:P=>{ce(P.url)&&(this._bridge?.send("navigate",P),P.newTab?window.open(P.url,"_blank","noopener,noreferrer"):window.location.href=P.url)},saveSession:P=>this.saveSession(P.sessionId,P.sku),addToCart:P=>{ve("gengage:similar:add-to-cart",P)},scriptCall:P=>{ve("gengage:chat:script-call",P),this.config.onScriptCall?.(P)}},L)}},onMetadata:v=>{if(!(!i&&a!==this._activeRequestThreadId)&&v.type==="metadata"&&v.meta){if((v.meta.panel!==void 0||v.meta.messages!==void 0||v.meta.message_id!==void 0)&&(this._lastBackendContext=v.meta),v.meta.panelLoading){B=!0,D=!1,l();const P=typeof v.meta.panelPendingType=="string"?v.meta.panelPendingType:void 0;this._panel&&(this._panel.currentType=null),this._drawer?.showPanelLoading(P),P&&this._panel?.updateTopBarForLoading(P)}if(v.meta.voice){const P=new CustomEvent("gengage:chat:voice",{detail:{payload:v.meta.voice},bubbles:!1,cancelable:!0}),T=window.dispatchEvent(P);if(us(),T){const N=v.meta.voice;N.audio_base64&&(this._activeTtsHandle?.stop(),this._activeTtsHandle=qo(N.audio_base64,N.content_type??"audio/ogg"))}}(v.meta.redirectTarget||v.meta.redirect)&&ve("gengage:chat:redirect",{target:v.meta.redirectTarget??null,payload:v.meta.redirect??null}),v.meta.analyzeAnimation&&(B=!0,D=!1,l(),this._panel&&(this._panel.currentType=null),this._drawer?.showPanelLoading(),this._panel?.updateTopBarForLoading("productDetails")),v.meta.loading&&typeof v.meta.loadingText=="string"&&(this._drawer?.addThinkingStep(v.meta.loadingText),this._bridge?.send("loadingMessage",{text:v.meta.loadingText})),v.meta.visitorDataResponse&&this._bridge?.send("engagingMessage",v.meta.visitorDataResponse),v.meta.formType&&this._bridge?.send("glovOtokoc",{type:v.meta.formType,data:v.meta.formPayload}),v.meta.launcherContent&&this._bridge?.send("launcherContent",v.meta.launcherContent),ve("gengage:chat:metadata",{payload:v.meta});const L=v.meta;typeof L.prompt_tokens=="number"&&typeof L.completion_tokens=="number"&&this.track(Ua(this.analyticsContext(),{model:v.model??"unknown",prompt_tokens:L.prompt_tokens,completion_tokens:L.completion_tokens,total_tokens:L.total_tokens??L.prompt_tokens+L.completion_tokens}))}},onError:v=>{if(U&&this._abortControllers.delete(U),!i&&a!==this._activeRequestThreadId)return;S=!0,ne(),R=null,this._bridge?.send("isResponding",!1),this._bridge?.send("loadingMessage",{text:null}),this._drawer?.removeTypingIndicator();const L=D;if(B&&!D&&d(),B=!1,D=!1,!(g.silent||g.content!=null&&g.content.length>0||p.length>0||L))if(o||this._hasUnavailableProductContext()){const T=this._i18n.productNotFoundMessage;g.content=T,g.status="done",this._ensureAssistantMessageRendered(g),this._drawer?.updateBotMessage(g.id,T),this._markUnavailableProductContext()}else{this.emit("error",v);const T=v.message;T===this._lastErrorMessage?this._consecutiveErrorCount++:(this._consecutiveErrorCount=1,this._lastErrorMessage=T),this._consecutiveErrorCount>=2?this._drawer?.showErrorWithRecovery(this._i18n.accountInactiveMessage,{onRetry:()=>{this._lastSentAction&&this._sendAction(this._lastSentAction.action,this._lastSentAction.options)},onNewQuestion:()=>{this._drawer?.focusInput()}}):this._drawer?.showErrorWithRecovery(this._i18n.errorMessage,{onRetry:()=>{this._lastSentAction&&this._sendAction(this._lastSentAction.action,this._lastSentAction.options)},onNewQuestion:()=>{this._drawer?.focusInput()}})}o&&(this._pdpPrimingInFlight=!1,this._flushQueuedUserMessages()),g.status==="streaming"&&(g.status="error"),this.track(Fa(this.analyticsContext(),{request_id:I,error_code:"STREAM_ERROR",error_message:v.message,widget:"chat"}))},onDone:()=>{if(U&&this._abortControllers.delete(U),!i&&a!==this._activeRequestThreadId)return;if(S=!0,ne(),R){const P=this._buildRenderContext();P.isStreaming=!1;const T=this._shadow?.querySelector(".gengage-chat-messages");if(T){const N=this._renderUISpec(R,P);g.threadId&&(N.dataset.threadId=g.threadId),T.appendChild(N),N.scrollIntoView({behavior:"auto",block:"end"}),this._drawer?.refreshPresentationCollapsed()}R=null}if(this._activeRequestThreadId=null,this._consecutiveErrorCount=0,this._lastErrorMessage="",this._bridge?.send("isResponding",!1),this._bridge?.send("loadingMessage",{text:null}),this._drawer?.removeTypingIndicator(),B&&!D&&d(),B=!1,D=!1,o&&!p&&!D){const P=this._i18n.productNotFoundMessage;g.content=P,this._ensureAssistantMessageRendered(g),this._drawer?.updateBotMessage(g.id,P),this._markUnavailableProductContext()}o&&(this._pdpPrimingInFlight=!1,this._flushQueuedUserMessages()),g.status==="streaming"&&(g.status="done",Nn()),this._presentation.finalizeAssistantGroup(a);const v=this._shadow?.querySelector(".gengage-chat-comparison-toggle-btn--hidden");v&&(v.classList.remove("gengage-chat-comparison-toggle-btn--hidden"),v.classList.add("gengage-chat-comparison-toggle-btn--reveal")),this.emit("message",g);const L=this._currentPanelSource;this._panel?.snapshotForMessage(g.id,L?()=>{const P=this._buildRenderContext();return L.kind==="favorites"?this._buildFavoritesPageEl():this._renderUISpec(L.spec,P)}:void 0),this._panel?.attachClickHandler(g.id),this.track(Da(this.analyticsContext(),{request_id:I,latency_ms:Date.now()-m,chunk_count:C,widget:"chat"})),this.track(Za(this.analyticsContext(),{meter_key:"chat_request",quantity:1,unit:"request"})),this.track(qa(this.analyticsContext(),{message_count:this._messages.length,history_ref:this.config.session?.sessionId??"",redaction_level:"none"})),this._persistToIndexedDB().catch(()=>{})}},h),this._abortControllers.add(U),!n?.silent&&!i){const v=U;this._drawer?.showStopButton(()=>{v.abort(),this._abortControllers.delete(v),this._drawer?.removeTypingIndicator(),this._bridge?.send("isResponding",!1),this._bridge?.send("loadingMessage",{text:null}),g.status==="streaming"&&(g.status="done")})}}_getVisibleMessages(){const t=this._messages.filter(a=>!a.silent);if(!this._currentThreadId)return t;const n=this._currentThreadId;return t.filter(a=>!a.threadId||a.threadId<=n)}_appendSimilarsToPanel(t,n){if(!this._drawer)return;const a=this._drawer.getPanelContentElement();if(!a)return;const i=document.createElement("h3");i.className="gengage-chat-product-details-similars-heading",i.textContent=this._i18n.similarProductsLabel??"Similar Products",a.appendChild(i);const o=this._renderUISpec(t,n);o.classList.add("gengage-chat-product-details-similars"),a.appendChild(o)}_handleRollback(t){const n=this._messages.find(a=>a.id===t);n?.threadId&&this._rollbackToThread(n.threadId)}_rollbackToThread(t){if(this._panel&&this._panel.threads.length>0&&!this._panel.threads.includes(t)&&!this._messages.some(o=>o.threadId===t))return;this._currentThreadId=t,this._extendedModeManager?.setHiddenByUser(!1),this._presentation.setFocusedThreadId(t),this._drawer?.setPresentationFocus(t),this._drawer?.setFormerMessagesButtonVisible(!1);for(const o of this._messages){const r=this._shadow?.querySelector(`[data-message-id="${CSS.escape(o.id)}"]`);r&&(o.threadId&&o.threadId>t?r.classList.add("gengage-chat-bubble--hidden"):r.classList.remove("gengage-chat-bubble--hidden"))}this._shadow?.querySelectorAll("[data-thread-id]").forEach(o=>{o instanceof HTMLElement&&o.dataset.threadId&&o.dataset.threadId>t?o.classList.add("gengage-chat-bubble--hidden"):o instanceof HTMLElement&&o.classList.remove("gengage-chat-bubble--hidden")});const n=this._messages.find(o=>o.role==="assistant"&&o.threadId===t),a=n?this._panel?.restoreForMessage(n.id):!1;a||(this._drawer?.clearPanel(),this._currentPanelSource=null),a&&n&&(this._currentPanelSource=null);const i=this._panel.currentType??"";if(this._panel?.updateTopBar(i),this._drawer?.setPills([]),this._session?.db&&this.config.session?.sessionId){const o=this.config.session.sessionId;(async()=>{try{const r=await this._session?.db?.loadContext(o,t);r&&(this._lastBackendContext=r.context),await this._session?.db?.deleteContextsAfterThread(o,t)}catch{}})()}}async _persistToIndexedDB(){!this._session||!this.config.session?.sessionId||await this._session.persist({userId:this.config.session.userId??"",appId:this.config.accountId,sessionId:this.config.session.sessionId,messages:this._messages,currentThreadId:this._currentThreadId,lastThreadId:this._lastThreadId,chatCreatedAt:this._chatCreatedAt,panelSnapshots:this._panel?.snapshots??new Map,panelThreads:this._panel?.threads??[],thumbnailEntries:this._thumbnailEntries,lastBackendContext:this._lastBackendContext,sku:this.config.pageContext?.sku})}_isSameOriginUrl(t){try{return t.trim()?new URL(t,window.location.href).origin===window.location.origin:!1}catch{return!1}}_markUnavailableProductContext(){this._productContextUnavailableSku=this.config.pageContext?.sku??null}_clearUnavailableProductContext(){this._productContextUnavailableSku=null}_hasUnavailableProductContext(){const t=this.config.pageContext?.sku;return t!==void 0&&t.length>0&&this._productContextUnavailableSku===t}_ensureAssistantMessageRendered(t){if(!(this._shadow?.querySelector(`[data-message-id="${CSS.escape(t.id)}"]`)||!this._drawer)){if(t.role==="assistant"&&t.threadId&&!this._threadsWithFirstBot.has(t.threadId)){this._threadsWithFirstBot.add(t.threadId),this._drawer.addMessage(t),this._drawer.markFirstBotMessage(t.id);return}this._drawer.addMessage(t)}}async _saveSessionAndOpenURL(t){this._session&&await this._session.saveAndOpenURL(t,()=>this._persistToIndexedDB(),this._bridge)}async _loadPayload(t,n){return this._session?this._session.loadPayload(t,n):null}async _restoreFromIndexedDB(t){if(!this._session?.db)return;const n=this.config.session?.sessionId;if(!n)return;const a=this.config.session?.userId??"",i=this.config.accountId;if(await this._session.loadFavorites(a,i),this._drawer?.updateFavoritesBadge(this._session.favoritedSkus.size),!t)return;const o=await this._session.db?.loadSession(a,i,n);if(!o||o.messages.length===0)return;const r=this.config.pageContext?.sku;if(r&&o.sku&&o.sku!==r)return;if(this._pdpLaunched=!0,this._drawer?.lockScrollForRestore(),this._currentThreadId=o.currentThreadId,this._lastThreadId=o.lastThreadId,this._currentThreadId&&this._lastThreadId&&this._currentThreadId>this._lastThreadId&&(this._currentThreadId=this._lastThreadId),this._chatCreatedAt=o.createdAt,o.panelThreads&&(this._panel.threads=o.panelThreads),o.thumbnailEntries&&(this._thumbnailEntries=o.thumbnailEntries,this._drawer?.setThumbnails(this._thumbnailEntries)),o.panelSnapshotHtml)for(const[c,l]of Object.entries(o.panelSnapshotHtml)){const d=document.createElement("div");d.innerHTML=_e(l),this._panel.snapshots.set(c,d)}let s=0;for(const c of o.messages){const l={id:c.id,role:c.role,timestamp:c.timestamp,status:c.status};if(c.threadId!==void 0&&(l.threadId=c.threadId),c.content!==void 0&&(l.content=c.content),c.silent&&(l.silent=!0),this._messages.push(l),l.silent)continue;l.role==="assistant"&&l.threadId&&!this._threadsWithFirstBot.has(l.threadId)&&(this._threadsWithFirstBot.add(l.threadId),this._drawer?.markFirstBotMessage(l.id)),this._drawer?.addMessage(l);const d=parseInt(c.id.replace("msg-",""),10);if(!isNaN(d)&&d>s&&(s=d),l.role==="assistant"&&l.threadId){const p=await this._loadPayload(l.threadId,l.id);p&&(l.uiSpec=p,this._restoreInlineUISpec(l),this._panel?.attachClickHandler(l.id),delete l.uiSpec)}}if(s>this._currentMessageId&&(this._currentMessageId=s),this._currentThreadId){let c=await this._session.db?.loadContext(n,this._currentThreadId);c||(c=await this._session.db?.loadLatestContext(n)),c&&(this._lastBackendContext=c.context)}if(this._currentThreadId){const c=[...this._messages].reverse().find(l=>l.role==="assistant"&&l.threadId===this._currentThreadId&&!l.silent);c&&this._panel.snapshots.has(c.id)&&this._panel?.restoreForMessage(c.id)}if(this._currentThreadId){const c=this._currentThreadId;for(const l of this._messages)l.threadId&&l.threadId>c&&this._shadow?.querySelector(`[data-message-id="${CSS.escape(l.id)}"]`)?.classList.add("gengage-chat-bubble--hidden");this._shadow?.querySelectorAll("[data-thread-id]").forEach(l=>{l instanceof HTMLElement&&l.dataset.threadId&&l.dataset.threadId>c&&l.classList.add("gengage-chat-bubble--hidden")})}if(this._panel.threads.length>0&&this._currentThreadId){const c=this._panel.threads[this._panel.threads.length-1];if(c){const l=[...this._messages].reverse().find(d=>d.role==="assistant"&&d.threadId===c);if(l?.threadId){const d=await this._loadPayload(l.threadId,l.id);if(d){const p=d.elements[d.root];p&&this._panel?.updateTopBar(p.type)}}}}this._presentation.releaseFocusedThread(),this._drawer?.setPresentationFocus(null),setTimeout(()=>{this._drawer?.scrollToLastThread()},550)}_navigatePanelBack(){const t=this._localPanelHistory.pop();if(t){const n=this._buildRenderContext(),a=t.source.kind==="favorites"?this._buildFavoritesPageEl():this._renderUISpec(t.source.spec,n);this._drawer?.setPanelContent(a),this._currentPanelSource=t.source;const i=this._localPanelHistory.length>0||(this._panel?.threads.length??0)>1;this._drawer?.updatePanelTopBar(i,!1,t.title);return}if(this._isMobileViewport){this._drawer?.hideMobilePanel();return}this._panel?.navigateBack()}_toggleComparisonSku(t){t===""?(this._comparisonSelectMode=!this._comparisonSelectMode,this._comparisonSelectMode||(this._comparisonSelectedSkus=[],os())):this._comparisonSelectedSkus.indexOf(t)>=0?this._comparisonSelectedSkus=this._comparisonSelectedSkus.filter(a=>a!==t):(this._comparisonSelectedSkus=[...this._comparisonSelectedSkus,t],is(t)),this._refreshComparisonUI()}_refreshComparisonUI(){const t=this._shadow?.querySelector(".gengage-chat-panel");if(!t)return;const n=t.querySelector(".gengage-chat-product-grid-wrapper");if(!n)return;const a=n.querySelector(".gengage-chat-product-grid");if(!a)return;const i=n.querySelector(".gengage-chat-comparison-toggle-btn");if(i&&i.classList.toggle("gengage-chat-comparison-toggle-btn--active",this._comparisonSelectMode),this._comparisonSelectMode){const r=a.querySelectorAll(".gengage-chat-product-card[data-sku]");for(const s of r){if(s.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){const p=s.parentElement.querySelector(".gengage-chat-comparison-checkbox");p&&(p.checked=this._comparisonSelectedSkus.includes(s.dataset.sku));continue}const c=s.dataset.sku,l=document.createElement("div");l.className="gengage-chat-comparison-select-wrapper";const d=document.createElement("input");d.type="checkbox",d.className="gengage-chat-comparison-checkbox",d.checked=this._comparisonSelectedSkus.includes(c),d.addEventListener("change",()=>{this._toggleComparisonSku(c)}),s.parentNode.insertBefore(l,s),l.appendChild(d),l.appendChild(s),l.style.cursor="pointer",l.addEventListener("click",p=>{p.target!==d&&(d.checked=!d.checked,this._toggleComparisonSku(c))})}}else{const r=a.querySelectorAll(".gengage-chat-comparison-select-wrapper");for(const s of r){const c=s.querySelector(".gengage-chat-product-card");c&&s.parentNode&&(s.parentNode.insertBefore(c,s),s.remove())}}const o=n.querySelector(".gengage-chat-comparison-floating-btn");if(this._comparisonSelectMode){const r=this._comparisonSelectedSkus.length,s=r>=2,c=this._i18n.compareSelected??"Compare",l=s?`${c} (${r})`:this._i18n.compareMinHint??"Select at least 2 products";if(o)o.textContent=l,o.disabled=!s,o.classList.toggle("gengage-chat-comparison-floating-btn--disabled",!s);else{const d=document.createElement("button");d.className="gengage-chat-comparison-floating-btn",d.type="button",d.textContent=l,d.disabled=!s,s||d.classList.add("gengage-chat-comparison-floating-btn--disabled"),d.addEventListener("click",()=>{this._comparisonSelectedSkus.length<2||(zn(this._comparisonSelectedSkus),this._sendAction({title:c,type:"getComparisonTable",payload:{sku_list:[...this._comparisonSelectedSkus]}}))}),n.appendChild(d)}}else o?.remove()}_buildRenderContext(){const t={onAction:n=>{if(ns(n.title,n.type),n.type==="findSimilar"){const i=typeof n.payload=="object"&&n.payload!==null&&"sku"in n.payload?String(n.payload.sku):"";as(i)}n.type==="getComparisonTable"&&zn(this._comparisonSelectedSkus);const a=n.type==="addToCart"||n.type==="like";this._sendAction(n,a?{preservePanel:!0}:void 0)},onProductClick:n=>{gs(n.sku),this.config.isDemoWebsite!==!0&&this._isSameOriginUrl(n.url)?(ve("gengage:similar:product-click",{sku:n.sku,url:n.url,sessionId:this.config.session?.sessionId??null}),this._saveSessionAndOpenURL(n.url)):this._sendAction({title:n.sku,type:"launchSingleProduct",payload:{sku:n.sku}})},onAddToCart:n=>{ds(n.sku,n.quantity);const a={...n,sessionId:this.config.session?.sessionId??null};ve("gengage:chat:add-to-cart",a),this._bridge?.send("addToCart",n),this._runEventCallbacks("gengage-cart-add",a),this.track(Ha(this.analyticsContext(),{attribution_source:"chat",attribution_action_id:crypto.randomUUID(),cart_value:0,currency:"TRY",line_items:n.quantity,sku:n.sku})),this._sendAction({title:this._i18n.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:n.sku,cart_code:n.cartCode,quantity:n.quantity}},{preservePanel:!0})},onProductSelect:n=>{if(this._currentPanelSource){const i=this._drawer?.getPanelTopBarTitle()??"";this._localPanelHistory.push({source:this._currentPanelSource,title:i}),this._localPanelHistory.length>Qe._MAX_PANEL_HISTORY&&this._localPanelHistory.shift()}const a={root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:n}}}};this._drawer?.setPanelContent(this._renderUISpec(a,t)),this._currentPanelSource={kind:"spec",spec:a},this._drawer?.updatePanelTopBar(!0,!1,this._i18n.panelTitleProductDetails)},i18n:this._i18n,pricing:this.config.pricing,productSort:this._productSort,onSortChange:n=>{this._productSort=n},comparisonSelectMode:this._comparisonSelectMode,comparisonSelectedSkus:this._comparisonSelectedSkus,onToggleComparisonSku:n=>{this._toggleComparisonSku(n)},favoritedSkus:this._session?.favoritedSkus??new Set,onFavoriteToggle:(n,a)=>{const i=this._session?.favoritedSkus.has(n)??!1;if(this._toggleFavorite(n,a),!i){ss(n);const o=a.name??n;this._sendAction({title:o,type:"like",payload:{sku:n}},{preservePanel:!0})}},isMobile:this._isMobileViewport};return t}async _toggleFavorite(t,n){if(!this._session)return;const a=this.config.session?.userId??"",i=this.config.accountId;await this._session.toggleFavorite(a,i,t,n),this._drawer?.updateFavoritesBadge(this._session.favoritedSkus.size)}_openFavoritesPanel(){if(this._drawer){if(this._currentPanelSource){const t=this._drawer.getPanelTopBarTitle()??"";this._localPanelHistory.push({source:this._currentPanelSource,title:t}),this._localPanelHistory.length>Qe._MAX_PANEL_HISTORY&&this._localPanelHistory.shift()}this._drawer.setPanelContent(this._buildFavoritesPageEl()),this._currentPanelSource={kind:"favorites"},this._drawer.updatePanelTopBar(!0,!1,this._i18n.favoritesPageTitle)}}_buildFavoritesPageEl(){const t=this._session?.getFavoriteProducts()??[];if(t.length===0){const o=document.createElement("div");o.className="gengage-chat-favorites-empty";const r=document.createElement("div");r.className="gengage-chat-favorites-empty-icon",r.innerHTML='<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" 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>',o.appendChild(r);const s=document.createElement("p");return s.textContent=this._i18n.emptyFavoritesMessage,o.appendChild(s),o}const n={},a=[];for(const[o,r]of t.entries()){const s=`card_${o}`;a.push(s),n[s]={type:"ProductCard",props:{product:{sku:r.sku,name:r.name,imageUrl:r.imageUrl,price:r.price}}}}n.grid={type:"ProductGrid",children:a};const i={root:"grid",elements:n};return this._renderUISpec(i,this._buildRenderContext())}async _runEventCallbacks(t,n){const a=this._eventCallbacks.get(t);if(!(!a||a.size===0))for(const i of a)try{const o=i(n);if((o instanceof Promise?await o:o)===!1){this._handleCallbackFailure(t,n);return}}catch{this._handleCallbackFailure(t,n);return}}_handleCallbackFailure(t,n){if(t==="gengage-cart-add"){const a=this._i18n.cartAddErrorMessage,i=this._createMessage("assistant",a);this._currentThreadId&&(i.threadId=this._currentThreadId),this._messages.push(i),this._drawer?.addMessage(i)}}_restoreInlineUISpec(t){if(!t.uiSpec||!this._drawer)return;const n=t.uiSpec,a=n.elements[n.root];if(!a)return;const i=a.type;if(i==="ActionButtons"||i==="ComparisonTable"||i==="ProductGrid"&&a.props?.similarsAppend===!0)return;const o=this._buildRenderContext(),r=this._shadow?.querySelector(".gengage-chat-messages");if(!r)return;if(i==="ProductDetailsPanel"){const c=a.props?.product;if(!c)return;const l={root:"root",elements:{root:{type:"ProductSummaryCard",props:{product:c}}}},d=this._renderUISpec(l,o);t.threadId&&(d.dataset.threadId=t.threadId),r.appendChild(d),this._drawer?.refreshPresentationCollapsed();return}const s=this._renderUISpec(n,o);t.threadId&&(s.dataset.threadId=t.threadId),r.appendChild(s),this._drawer?.refreshPresentationCollapsed()}_createMessage(t,n){return this._currentMessageId++,{id:`msg-${this._currentMessageId}`,role:t,content:n,timestamp:Date.now(),status:"done"}}_resolveI18n(t){return{...zo(t.locale),...t.i18n}}_resolveUISpecRegistry(){const t=wn();return Ba(t,this.config.renderer?.registry)}_renderUISpec(t,n){const a=this._resolveUISpecRegistry(),i=this.config.renderer?.unknownRenderer??Et,o=(c,l)=>xn(c,l,a,i),r=this.config.renderer?.renderUISpec;return r?r(t,n,{registry:a,unknownRenderer:i,defaultRender:o}):o(t,n)}};Qe._MAX_PANEL_HISTORY=10;let ft=Qe;function up(){return new ft}ue.CHAT_SCROLL_ELEMENT_ID=nt,ue.ChatPresentationState=An,ue.GengageChat=ft,ue.chatCatalog=pp,ue.createChatWidget=up,ue.createDefaultChatUISpecRegistry=wn,ue.defaultChatUnknownUISpecRenderer=Et,ue.getChatScrollElement=Io,ue.invalidateChatScrollCache=ln,ue.renderUISpec=xn,Object.defineProperty(ue,Symbol.toStringTag,{value:"Module"})})(this.Gengage=this.Gengage||{});
96
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const r of e.seen.entries()){const s=r[1];if(t===r[0]){o(r);continue}if(e.external){const l=e.external.registry.get(r[0])?.id;if(t!==r[0]&&l){o(r);continue}}if(e.metadataRegistry.get(r[0])?.id){o(r);continue}if(s.cycle){o(r);continue}if(s.count>1&&e.reused==="ref"){o(r);continue}}}function wa(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const a=r=>{const s=e.seen.get(r);if(s.ref===null)return;const c=s.def??s.schema,l={...c},g=s.ref;if(s.ref=null,g){a(g);const d=e.seen.get(g),h=d.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(h)):Object.assign(c,h),Object.assign(c,l),r._zod.parent===g)for(const b in c)b==="$ref"||b==="allOf"||b in l||delete c[b];if(h.$ref&&d.def)for(const b in c)b==="$ref"||b==="allOf"||b in d.def&&JSON.stringify(c[b])===JSON.stringify(d.def[b])&&delete c[b]}const p=r._zod.parent;if(p&&p!==g){a(p);const d=e.seen.get(p);if(d?.schema.$ref&&(c.$ref=d.schema.$ref,d.def))for(const h in c)h==="$ref"||h==="allOf"||h in d.def&&JSON.stringify(c[h])===JSON.stringify(d.def[h])&&delete c[h]}e.override({zodSchema:r,jsonSchema:c,path:s.path??[]})};for(const r of[...e.seen.entries()].reverse())a(r[0]);const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const r=e.external.registry.get(t)?.id;if(!r)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(r)}Object.assign(i,n.def??n.schema);const o=e.external?.defs??{};for(const r of e.seen.entries()){const s=r[1];s.def&&s.defId&&(o[s.defId]=s.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?i.$defs=o:i.definitions=o);try{const r=JSON.parse(JSON.stringify(i));return Object.defineProperty(r,"~standard",{value:{...t["~standard"],jsonSchema:{input:ut(t,"input",e.processors),output:ut(t,"output",e.processors)}},enumerable:!1,writable:!1}),r}catch{throw new Error("Error converting schema to JSON.")}}function se(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const a=e._zod.def;if(a.type==="transform")return!0;if(a.type==="array")return se(a.element,n);if(a.type==="set")return se(a.valueType,n);if(a.type==="lazy")return se(a.getter(),n);if(a.type==="promise"||a.type==="optional"||a.type==="nonoptional"||a.type==="nullable"||a.type==="readonly"||a.type==="default"||a.type==="prefault")return se(a.innerType,n);if(a.type==="intersection")return se(a.left,n)||se(a.right,n);if(a.type==="record"||a.type==="map")return se(a.keyType,n)||se(a.valueType,n);if(a.type==="pipe")return se(a.in,n)||se(a.out,n);if(a.type==="object"){for(const i in a.shape)if(se(a.shape[i],n))return!0;return!1}if(a.type==="union"){for(const i of a.options)if(se(i,n))return!0;return!1}if(a.type==="tuple"){for(const i of a.items)if(se(i,n))return!0;return!!(a.rest&&se(a.rest,n))}return!1}const hg=(e,t={})=>n=>{const a=va({...n,processors:t});return te(e,a),ya(a,e),wa(a,e)},ut=(e,t,n={})=>a=>{const{libraryOptions:i,target:o}=a??{},r=va({...i??{},target:o,io:t,processors:n});return te(e,r),ya(r,e),wa(r,e)},ug={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},fg=(e,t,n,a)=>{const i=n;i.type="string";const{minimum:o,maximum:r,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof o=="number"&&(i.minLength=o),typeof r=="number"&&(i.maxLength=r),s&&(i.format=ug[s]??s,i.format===""&&delete i.format,s==="time"&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){const g=[...c];g.length===1?i.pattern=g[0].source:g.length>1&&(i.allOf=[...g.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},mg=(e,t,n,a)=>{const i=n,{minimum:o,maximum:r,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:g}=e._zod.bag;typeof s=="string"&&s.includes("int")?i.type="integer":i.type="number",typeof g=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=g,i.exclusiveMinimum=!0):i.exclusiveMinimum=g),typeof o=="number"&&(i.minimum=o,typeof g=="number"&&t.target!=="draft-04"&&(g>=o?delete i.minimum:delete i.exclusiveMinimum)),typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof r=="number"&&(i.maximum=r,typeof l=="number"&&t.target!=="draft-04"&&(l<=r?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},bg=(e,t,n,a)=>{n.type="boolean"},_g=(e,t,n,a)=>{n.not={}},vg=(e,t,n,a)=>{},yg=(e,t,n,a)=>{const i=e._zod.def,o=On(i.entries);o.every(r=>typeof r=="number")&&(n.type="number"),o.every(r=>typeof r=="string")&&(n.type="string"),n.enum=o},wg=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},xg=(e,t,n,a)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},kg=(e,t,n,a)=>{const i=n,o=e._zod.def,{minimum:r,maximum:s}=e._zod.bag;typeof r=="number"&&(i.minItems=r),typeof s=="number"&&(i.maxItems=s),i.type="array",i.items=te(o.element,t,{...a,path:[...a.path,"items"]})},Cg=(e,t,n,a)=>{const i=n,o=e._zod.def;i.type="object",i.properties={};const r=o.shape;for(const l in r)i.properties[l]=te(r[l],t,{...a,path:[...a.path,"properties",l]});const s=new Set(Object.keys(r)),c=new Set([...s].filter(l=>{const g=o.shape[l]._zod;return t.io==="input"?g.optin===void 0:g.optout===void 0}));c.size>0&&(i.required=Array.from(c)),o.catchall?._zod.def.type==="never"?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=te(o.catchall,t,{...a,path:[...a.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},Eg=(e,t,n,a)=>{const i=e._zod.def,o=i.inclusive===!1,r=i.options.map((s,c)=>te(s,t,{...a,path:[...a.path,o?"oneOf":"anyOf",c]}));o?n.oneOf=r:n.anyOf=r},Sg=(e,t,n,a)=>{const i=e._zod.def,o=te(i.left,t,{...a,path:[...a.path,"allOf",0]}),r=te(i.right,t,{...a,path:[...a.path,"allOf",1]}),s=l=>"allOf"in l&&Object.keys(l).length===1,c=[...s(o)?o.allOf:[o],...s(r)?r.allOf:[r]];n.allOf=c},Tg=(e,t,n,a)=>{const i=n,o=e._zod.def;i.type="object";const r=o.keyType,c=r._zod.bag?.patterns;if(o.mode==="loose"&&c&&c.size>0){const g=te(o.valueType,t,{...a,path:[...a.path,"patternProperties","*"]});i.patternProperties={};for(const p of c)i.patternProperties[p.source]=g}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=te(o.keyType,t,{...a,path:[...a.path,"propertyNames"]})),i.additionalProperties=te(o.valueType,t,{...a,path:[...a.path,"additionalProperties"]});const l=r._zod.values;if(l){const g=[...l].filter(p=>typeof p=="string"||typeof p=="number");g.length>0&&(i.required=g)}},Ag=(e,t,n,a)=>{const i=e._zod.def,o=te(i.innerType,t,a),r=t.seen.get(e);t.target==="openapi-3.0"?(r.ref=i.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},Ig=(e,t,n,a)=>{const i=e._zod.def;te(i.innerType,t,a);const o=t.seen.get(e);o.ref=i.innerType},Pg=(e,t,n,a)=>{const i=e._zod.def;te(i.innerType,t,a);const o=t.seen.get(e);o.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Lg=(e,t,n,a)=>{const i=e._zod.def;te(i.innerType,t,a);const o=t.seen.get(e);o.ref=i.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},zg=(e,t,n,a)=>{const i=e._zod.def;te(i.innerType,t,a);const o=t.seen.get(e);o.ref=i.innerType;let r;try{r=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=r},Ng=(e,t,n,a)=>{const i=e._zod.def,o=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;te(o,t,a);const r=t.seen.get(e);r.ref=o},Mg=(e,t,n,a)=>{const i=e._zod.def;te(i.innerType,t,a);const o=t.seen.get(e);o.ref=i.innerType,n.readOnly=!0},xa=(e,t,n,a)=>{const i=e._zod.def;te(i.innerType,t,a);const o=t.seen.get(e);o.ref=i.innerType},Bg=m("ZodISODateTime",(e,t)=>{$c.init(e,t),J.init(e,t)});function Rg(e){return jl(Bg,e)}const Og=m("ZodISODate",(e,t)=>{Dc.init(e,t),J.init(e,t)});function $g(e){return ql(Og,e)}const Dg=m("ZodISOTime",(e,t)=>{Fc.init(e,t),J.init(e,t)});function Fg(e){return Hl(Dg,e)}const Ug=m("ZodISODuration",(e,t)=>{Uc.init(e,t),J.init(e,t)});function Zg(e){return Vl(Ug,e)}const he=m("ZodError",(e,t)=>{jn.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Ls(e,n)},flatten:{value:n=>Ps(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Lt,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Lt,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),jg=Rt(he),qg=Ot(he),Hg=ct(he),Vg=lt(he),Wg=Ms(he),Gg=Bs(he),Kg=Rs(he),Yg=Os(he),Jg=$s(he),Xg=Ds(he),Qg=Fs(he),ed=Us(he),Q=m("ZodType",(e,t)=>(X.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:ut(e,"input"),output:ut(e,"output")}}),e.toJSONSchema=hg(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(Pe(t,{checks:[...t.checks??[],...n.map(a=>typeof a=="function"?{_zod:{check:a,def:{check:"custom"},onattach:[]}}:a)]}),{parent:!0}),e.with=e.check,e.clone=(n,a)=>Le(e,n,a),e.brand=()=>e,e.register=((n,a)=>(n.add(e,a),e)),e.parse=(n,a)=>jg(e,n,a,{callee:e.parse}),e.safeParse=(n,a)=>Hg(e,n,a),e.parseAsync=async(n,a)=>qg(e,n,a,{callee:e.parseAsync}),e.safeParseAsync=async(n,a)=>Vg(e,n,a),e.spa=e.safeParseAsync,e.encode=(n,a)=>Wg(e,n,a),e.decode=(n,a)=>Gg(e,n,a),e.encodeAsync=async(n,a)=>Kg(e,n,a),e.decodeAsync=async(n,a)=>Yg(e,n,a),e.safeEncode=(n,a)=>Jg(e,n,a),e.safeDecode=(n,a)=>Xg(e,n,a),e.safeEncodeAsync=async(n,a)=>Qg(e,n,a),e.safeDecodeAsync=async(n,a)=>ed(e,n,a),e.refine=(n,a)=>e.check(Vd(n,a)),e.superRefine=n=>e.check(Wd(n)),e.overwrite=n=>e.check(Ve(n)),e.optional=()=>Aa(e),e.exactOptional=()=>Nd(e),e.nullable=()=>Ia(e),e.nullish=()=>Aa(Ia(e)),e.nonoptional=n=>Dd(e,n),e.array=()=>Y(e),e.or=n=>mt([e,n]),e.and=n=>Ad(e,n),e.transform=n=>La(e,Ld(n)),e.default=n=>Rd(e,n),e.prefault=n=>$d(e,n),e.catch=n=>Ud(e,n),e.pipe=n=>La(e,n),e.readonly=()=>qd(e),e.describe=n=>{const a=e.clone();return Xe.add(a,{description:n}),a},Object.defineProperty(e,"description",{get(){return Xe.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Xe.get(e);const a=e.clone();return Xe.add(a,n[0]),a},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),ka=m("_ZodString",(e,t)=>{$t.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(a,i,o)=>fg(e,a,i);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...a)=>e.check(Xl(...a)),e.includes=(...a)=>e.check(tg(...a)),e.startsWith=(...a)=>e.check(ng(...a)),e.endsWith=(...a)=>e.check(ag(...a)),e.min=(...a)=>e.check(ht(...a)),e.max=(...a)=>e.check(ba(...a)),e.length=(...a)=>e.check(_a(...a)),e.nonempty=(...a)=>e.check(ht(1,...a)),e.lowercase=a=>e.check(Ql(a)),e.uppercase=a=>e.check(eg(a)),e.trim=()=>e.check(og()),e.normalize=(...a)=>e.check(ig(...a)),e.toLowerCase=()=>e.check(rg()),e.toUpperCase=()=>e.check(sg()),e.slugify=()=>e.check(cg())}),td=m("ZodString",(e,t)=>{$t.init(e,t),ka.init(e,t),e.email=n=>e.check(xl(nd,n)),e.url=n=>e.check(Tl(ad,n)),e.jwt=n=>e.check(Zl(_d,n)),e.emoji=n=>e.check(Al(id,n)),e.guid=n=>e.check(ha(Ca,n)),e.uuid=n=>e.check(kl(ft,n)),e.uuidv4=n=>e.check(Cl(ft,n)),e.uuidv6=n=>e.check(El(ft,n)),e.uuidv7=n=>e.check(Sl(ft,n)),e.nanoid=n=>e.check(Il(od,n)),e.guid=n=>e.check(ha(Ca,n)),e.cuid=n=>e.check(Pl(rd,n)),e.cuid2=n=>e.check(Ll(sd,n)),e.ulid=n=>e.check(zl(cd,n)),e.base64=n=>e.check(Dl(fd,n)),e.base64url=n=>e.check(Fl(md,n)),e.xid=n=>e.check(Nl(ld,n)),e.ksuid=n=>e.check(Ml(gd,n)),e.ipv4=n=>e.check(Bl(dd,n)),e.ipv6=n=>e.check(Rl(pd,n)),e.cidrv4=n=>e.check(Ol(hd,n)),e.cidrv6=n=>e.check($l(ud,n)),e.e164=n=>e.check(Ul(bd,n)),e.datetime=n=>e.check(Rg(n)),e.date=n=>e.check($g(n)),e.time=n=>e.check(Fg(n)),e.duration=n=>e.check(Zg(n))});function x(e){return wl(td,e)}const J=m("ZodStringFormat",(e,t)=>{K.init(e,t),ka.init(e,t)}),nd=m("ZodEmail",(e,t)=>{Ic.init(e,t),J.init(e,t)}),Ca=m("ZodGUID",(e,t)=>{Tc.init(e,t),J.init(e,t)}),ft=m("ZodUUID",(e,t)=>{Ac.init(e,t),J.init(e,t)}),ad=m("ZodURL",(e,t)=>{Pc.init(e,t),J.init(e,t)}),id=m("ZodEmoji",(e,t)=>{Lc.init(e,t),J.init(e,t)}),od=m("ZodNanoID",(e,t)=>{zc.init(e,t),J.init(e,t)}),rd=m("ZodCUID",(e,t)=>{Nc.init(e,t),J.init(e,t)}),sd=m("ZodCUID2",(e,t)=>{Mc.init(e,t),J.init(e,t)}),cd=m("ZodULID",(e,t)=>{Bc.init(e,t),J.init(e,t)}),ld=m("ZodXID",(e,t)=>{Rc.init(e,t),J.init(e,t)}),gd=m("ZodKSUID",(e,t)=>{Oc.init(e,t),J.init(e,t)}),dd=m("ZodIPv4",(e,t)=>{Zc.init(e,t),J.init(e,t)}),pd=m("ZodIPv6",(e,t)=>{jc.init(e,t),J.init(e,t)}),hd=m("ZodCIDRv4",(e,t)=>{qc.init(e,t),J.init(e,t)}),ud=m("ZodCIDRv6",(e,t)=>{Hc.init(e,t),J.init(e,t)}),fd=m("ZodBase64",(e,t)=>{Vc.init(e,t),J.init(e,t)}),md=m("ZodBase64URL",(e,t)=>{Gc.init(e,t),J.init(e,t)}),bd=m("ZodE164",(e,t)=>{Kc.init(e,t),J.init(e,t)}),_d=m("ZodJWT",(e,t)=>{Jc.init(e,t),J.init(e,t)}),Ea=m("ZodNumber",(e,t)=>{ea.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(a,i,o)=>mg(e,a,i),e.gt=(a,i)=>e.check(fa(a,i)),e.gte=(a,i)=>e.check(Ut(a,i)),e.min=(a,i)=>e.check(Ut(a,i)),e.lt=(a,i)=>e.check(ua(a,i)),e.lte=(a,i)=>e.check(Ft(a,i)),e.max=(a,i)=>e.check(Ft(a,i)),e.int=a=>e.check(Sa(a)),e.safe=a=>e.check(Sa(a)),e.positive=a=>e.check(fa(0,a)),e.nonnegative=a=>e.check(Ut(0,a)),e.negative=a=>e.check(ua(0,a)),e.nonpositive=a=>e.check(Ft(0,a)),e.multipleOf=(a,i)=>e.check(ma(a,i)),e.step=(a,i)=>e.check(ma(a,i)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Ne(e){return Wl(Ea,e)}const vd=m("ZodNumberFormat",(e,t)=>{Xc.init(e,t),Ea.init(e,t)});function Sa(e){return Gl(vd,e)}const yd=m("ZodBoolean",(e,t)=>{Qc.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>bg(e,n,a)});function Zt(e){return Kl(yd,e)}const wd=m("ZodUnknown",(e,t)=>{el.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>vg()});function _e(){return Yl(wd)}const xd=m("ZodNever",(e,t)=>{tl.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>_g(e,n,a)});function kd(e){return Jl(xd,e)}const Cd=m("ZodArray",(e,t)=>{nl.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>kg(e,n,a,i),e.element=t.element,e.min=(n,a)=>e.check(ht(n,a)),e.nonempty=n=>e.check(ht(1,n)),e.max=(n,a)=>e.check(ba(n,a)),e.length=(n,a)=>e.check(_a(n,a)),e.unwrap=()=>e.element});function Y(e,t){return lg(Cd,e,t)}const Ed=m("ZodObject",(e,t)=>{il.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Cg(e,n,a,i),j(e,"shape",()=>t.shape),e.keyof=()=>qt(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:_e()}),e.loose=()=>e.clone({...e._zod.def,catchall:_e()}),e.strict=()=>e.clone({...e._zod.def,catchall:kd()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>Es(e,n),e.safeExtend=n=>Ss(e,n),e.merge=n=>Ts(e,n),e.pick=n=>ks(e,n),e.omit=n=>Cs(e,n),e.partial=(...n)=>As(Ta,e,n[0]),e.required=(...n)=>Is(Pa,e,n[0])});function O(e,t){const n={type:"object",shape:e??{},...z(t)};return new Ed(n)}const Sd=m("ZodUnion",(e,t)=>{ol.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Eg(e,n,a,i),e.options=t.options});function mt(e,t){return new Sd({type:"union",options:e,...z(t)})}const Td=m("ZodIntersection",(e,t)=>{rl.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Sg(e,n,a,i)});function Ad(e,t){return new Td({type:"intersection",left:e,right:t})}const Id=m("ZodRecord",(e,t)=>{sl.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Tg(e,n,a,i),e.keyType=t.keyType,e.valueType=t.valueType});function Qe(e,t,n){return new Id({type:"record",keyType:e,valueType:t,...z(n)})}const jt=m("ZodEnum",(e,t)=>{cl.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(a,i,o)=>yg(e,a,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(a,i)=>{const o={};for(const r of a)if(n.has(r))o[r]=t.entries[r];else throw new Error(`Key ${r} not found in enum`);return new jt({...t,checks:[],...z(i),entries:o})},e.exclude=(a,i)=>{const o={...t.entries};for(const r of a)if(n.has(r))delete o[r];else throw new Error(`Key ${r} not found in enum`);return new jt({...t,checks:[],...z(i),entries:o})}});function qt(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(a=>[a,a])):e;return new jt({type:"enum",entries:n,...z(t)})}const Pd=m("ZodTransform",(e,t)=>{ll.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>xg(e,n),e._zod.parse=(n,a)=>{if(a.direction==="backward")throw new Bn(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(Je(o,n.value,t));else{const r=o;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=e),n.issues.push(Je(r))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(o=>(n.value=o,n)):(n.value=i,n)}});function Ld(e){return new Pd({type:"transform",transform:e})}const Ta=m("ZodOptional",(e,t)=>{sa.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>xa(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function Aa(e){return new Ta({type:"optional",innerType:e})}const zd=m("ZodExactOptional",(e,t)=>{gl.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>xa(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function Nd(e){return new zd({type:"optional",innerType:e})}const Md=m("ZodNullable",(e,t)=>{dl.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Ag(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function Ia(e){return new Md({type:"nullable",innerType:e})}const Bd=m("ZodDefault",(e,t)=>{pl.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Pg(e,n,a,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Rd(e,t){return new Bd({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Un(t)}})}const Od=m("ZodPrefault",(e,t)=>{hl.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Lg(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function $d(e,t){return new Od({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Un(t)}})}const Pa=m("ZodNonOptional",(e,t)=>{ul.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Ig(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function Dd(e,t){return new Pa({type:"nonoptional",innerType:e,...z(t)})}const Fd=m("ZodCatch",(e,t)=>{fl.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>zg(e,n,a,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ud(e,t){return new Fd({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Zd=m("ZodPipe",(e,t)=>{ml.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Ng(e,n,a,i),e.in=t.in,e.out=t.out});function La(e,t){return new Zd({type:"pipe",in:e,out:t})}const jd=m("ZodReadonly",(e,t)=>{bl.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>Mg(e,n,a,i),e.unwrap=()=>e._zod.def.innerType});function qd(e){return new jd({type:"readonly",innerType:e})}const Hd=m("ZodCustom",(e,t)=>{_l.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(n,a,i)=>wg(e,n)});function Vd(e,t={}){return gg(Hd,e,t)}function Wd(e){return dg(e)}const Gd=O({role:qt(["user","assistant"]),content:x(),timestamp:Ne().optional()}),Kd=O({sku:x(),name:x(),imageUrl:x().url().optional(),price:x().optional(),originalPrice:x().optional(),url:x().url(),ctaLabel:x().optional()}),Yd=O({buttons:Y(O({label:x(),action:O({title:x(),type:x(),payload:_e().optional()})}))}),Jd=O({}),Xd=O({label:x().optional()}),za=O({sku:x(),name:x(),price:x(),imageUrl:x().optional(),rating:Ne().optional(),reviewCount:Ne().optional()}),Qd=O({recommended:za,products:Y(za),attributes:Y(O({label:x(),values:Y(x())})),highlights:Y(x()),specialCases:Y(x()).optional(),recommendedText:x().optional(),winnerHits:Qe(x(),O({positive:Y(x()).optional(),negative:Y(x()).optional()})).optional(),productActions:Qe(x(),O({title:x(),type:x(),payload:_e().optional()})).optional()}),ep=O({label:x(),sentiment:qt(["positive","negative","neutral"]).optional()}),tp=O({product:Qe(x(),_e()),role:x().optional(),reason:x().optional(),labels:Y(ep).optional(),expertQualityScore:Ne().optional(),reviewHighlight:x().optional(),action:O({title:x(),type:x(),payload:_e().optional()}).optional()}),np=O({suggestions:Y(tp)}),ap=O({title:x().optional(),text:x().optional(),reviewCount:x().optional(),action:O({title:x(),type:x(),payload:_e().optional()})}),ip=O({entries:Y(O({name:x(),image:x().optional(),description:x().optional(),action:O({title:x(),type:x(),payload:_e().optional()})}))}),op=O({entries:Y(O({shortName:x(),detailedMessage:x().optional(),whyDifferent:x().optional(),image:x().optional(),action:O({title:x(),type:x(),payload:_e().optional()})}))}),Na=O({title:x(),type:x(),payload:_e().optional()}),rp=O({name:x().optional(),value:x().optional(),variant_name:x().optional(),sku:x().optional(),price:mt([Ne(),x()]).optional()}),sp=O({product:O({sku:x().optional(),name:x().optional(),images:Y(x()).optional(),imageUrl:x().optional(),rating:Ne().optional(),reviewCount:Ne().optional(),price:x().optional(),originalPrice:x().optional(),price_async:Zt().optional(),inStock:Zt().optional(),promotions:Y(x()).optional(),variants:Y(rp).optional(),url:x().optional(),cartCode:x().optional(),description:x().optional(),specifications:mt([Qe(x(),x()),Y(O({key:x(),value:x()}))]).optional()}).optional(),action:Na.optional()}),cp=O({endOfList:Zt().optional()}),lp=O({review_class:x().optional(),review_text:x().optional(),review_rating:mt([x(),Ne()]).optional(),review_tag:x().optional()}),gp=O({reviews:Y(lp).optional()}),dp=O({productName:x().optional(),pros:Y(x()).optional(),cons:Y(x()).optional()}),pp=O({groups:Y(O({groupName:x(),products:Y(Qe(x(),_e())).optional()})).optional(),filterTags:Y(O({title:x(),action:Na.optional()})).optional()}),hp=O({summary:x().optional(),products_discussed:Y(x()).optional(),user_sentiment:x().optional()}),up={components:{MessageBubble:{schema:Gd,description:"A single chat message bubble for user or assistant turns."},ProductCard:{schema:Kd,description:"A product card rendered inline in the chat stream."},ActionButtons:{schema:Yd,description:"A horizontal row of quick-reply action buttons."},TypingIndicator:{schema:Jd,description:"An animated indicator shown while the assistant is typing."},Divider:{schema:Xd,description:"A horizontal rule with an optional label."},ComparisonTable:{schema:Qd,description:"A product comparison table with recommended pick, attribute rows, and highlights."},AITopPicks:{schema:np,description:"Rich AI-curated product suggestion cards with roles, sentiment labels, scores, and review quotes."},GroundingReviewCard:{schema:ap,description:"A card showing review grounding data with review count and CTA."},AIGroupingCards:{schema:ip,description:"Category grouping cards with images and labels for product discovery."},AISuggestedSearchCards:{schema:op,description:"Suggested search cards with images, descriptions, and differentiation."},ProductDetailsPanel:{schema:sp,description:"Full product detail view with images, specs, variants, and purchase actions."},ProductGrid:{schema:cp,description:'A scrollable grid of ProductCard children with optional "more" pagination.'},ReviewHighlights:{schema:gp,description:"A list of highlighted customer reviews with sentiment and ratings."},ProsAndCons:{schema:dp,description:"A pros and cons list for a product."},CategoriesContainer:{schema:pp,description:"Tabbed product groups with optional filter tag buttons."},HandoffNotice:{schema:hp,description:"A notice shown when the conversation is escalated to a human agent."}}};function Ma(e){return e.length>120?!1:/^[a-zA-Z0-9#(),.\s%/\-]+$/.test(e)}function Ht(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}const et=class et extends mi{constructor(){super(...arguments),this._shadow=null,this._rootEl=null,this._launcher=null,this._drawer=null,this._bridge=null,this._drawerVisible=!1,this._messages=[],this._currentMessageId=0,this._abortControllers=new Set,this._currentThreadId=null,this._lastThreadId=null,this._chatCreatedAt="",this._lastBackendContext=null,this._productSort={type:"related"},this._comparisonSelectMode=!1,this._comparisonSelectedSkus=[],this._viewedProductSkus=new Set,this._thumbnailEntries=[],this._choicePrompterEl=null,this._openState="full",this._mobileBreakpoint=768,this._isMobileViewport=!1,this._pdpLaunched=!1,this._pdpPrimingInFlight=!1,this._queuedUserMessages=[],this._productContextUnavailableSku=null,this._i18n=Ct,this._extendedModeManager=null,this._activeTypewriter=null,this._activeTtsHandle=null,this._activeRequestThreadId=null,this._skuToProductItem={},this._conversationMode=null,this._initComplete=!1,this._pendingActions=[],this._bridgeContext=null,this._cartQuantity=null,this._threadsWithFirstBot=new Set,this._panel=null,this._localPanelHistory=[],this._currentPanelSource=null,this._session=null,this._presentation=new In,this._eventCallbacks=new Map,this._lastSentAction=null,this._consecutiveErrorCount=0,this._lastErrorMessage=""}async onInit(t){this._i18n=this._resolveI18n(t),this._chatCreatedAt=new Date().toISOString(),this._shadow=this.root.attachShadow({mode:"open"});const n=document.createElement("style");n.textContent=es,this._shadow.appendChild(n);const a=this.root,i=(u,b)=>{b&&Ma(b)&&a.style.setProperty(u,b)};if(i("--gengage-chat-header-bg",t.headerBg),i("--gengage-chat-header-foreground",t.headerForeground),t.theme)for(const[u,b]of Object.entries(t.theme))u.startsWith("--")&&typeof b=="string"&&i(u,b);const o=document.createElement("div");o.className="gengage-chat-root",this._rootEl=o,this._shadow.appendChild(o);const r=t.variant??"floating";if(r==="floating"){const u={onClick:()=>this.open(),ariaLabel:this._i18n.openButton};t.launcherImageUrl!==void 0?u.imageUrl=t.launcherImageUrl:t.launcherSvg!==void 0&&(u.svgMarkup=t.launcherSvg),t.hideMobileLauncher!==void 0&&(u.hideMobile=t.hideMobileLauncher),t.mobileBreakpoint!==void 0&&(u.mobileBreakpoint=t.mobileBreakpoint),t.launcherTooltip!==void 0&&(u.tooltip=t.launcherTooltip),this._launcher=qo(u),o.appendChild(this._launcher.container)}r==="overlay"&&o.classList.add("gengage-chat--overlay");const s=document.createElement("div");o.appendChild(s),this._drawer=new Zo(s,{i18n:this._i18n,onSend:(u,b)=>this._sendMessage(u,b),onClose:()=>this.close(),onAttachment:u=>this._handleAttachment(u),onPanelToggle:()=>{this._drawer?.persistPanelState(t.accountId)},onRollback:u=>this._handleRollback(u),onPanelBack:()=>this._navigatePanelBack(),onPanelForward:()=>this._panel?.navigateForward(),headerTitle:t.headerTitle,headerAvatarUrl:t.headerAvatarUrl,launcherImageUrl:t.launcherImageUrl,headerBadge:t.headerBadge,headerCartUrl:t.headerCartUrl,headerFavoritesToggle:t.headerFavoritesToggle,onCartClick:()=>{t.headerCartUrl?this._saveSessionAndOpenURL(t.headerCartUrl):t.onCartClick?.()},onFavoritesClick:()=>{gs(),t.onFavoritesClick?.(),this._openFavoritesPanel()},getMobileState:()=>this._openState??"full",getMobileViewport:()=>this._isMobileViewport,onMobileSnap:u=>{u==="close"?this.close():(this._openState=u,this._applyOpenStateClasses())},onThumbnailClick:u=>this._rollbackToThread(u),onLinkClick:u=>{this._saveSessionAndOpenURL(u)},voiceEnabled:t.voiceEnabled,voiceLang:t.locale?`${t.locale.split("-")[0]??"tr"}-${(t.locale.split("-")[1]??t.locale.split("-")[0]??"TR").toUpperCase()}`:void 0,onNewChat:()=>{this._abortControllers.forEach(u=>u.abort()),this._abortControllers.clear(),this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,this._messages=[],this._drawer?.clearMessages(),this._currentThreadId=wt(),this._lastThreadId=this._currentThreadId,this._choicePrompterEl?.remove(),this._choicePrompterEl=null,this._viewedProductSkus.clear(),this._drawer?.clearPanel(),this._consecutiveErrorCount=0,this._lastErrorMessage="",this._thumbnailEntries=[],this._drawer?.setThumbnails([]),this._panel.snapshots.clear(),this._panel.threads=[],this._presentation.reset(),this._drawer?.setPresentationFocus(null),this._drawer?.setFormerMessagesButtonVisible(!1),this._showWelcomeIfNeeded()},presentation:{onPinnedToBottomChange:u=>{this._presentation.pinnedToBottom=u},onUserInteractingChange:u=>{this._presentation.userInteracting=u},onFormerMessagesHint:()=>{this._presentation.focusedThreadId&&this._hasMultipleThreadIds()&&this._drawer?.setFormerMessagesButtonVisible(!0)},shouldBlockSoftAutoScroll:()=>this._presentation.shouldBlockStreamAutoScroll(),onReleasePresentationFocus:()=>this._releasePresentationFocus()}}),this._extendedModeManager=new qr({onChange:u=>this._panel?.notifyExtension(u),productDetailsInPanel:t.isDemoWebsite??!1}),this._panel=new Hr({drawer:()=>this._drawer,shadow:()=>this._shadow,currentThreadId:()=>this._currentThreadId,bridge:()=>this._bridge,extendedModeManager:()=>this._extendedModeManager,i18n:()=>this._i18n,rollbackToThread:u=>this._rollbackToThread(u)}),r!=="inline"&&this._drawer.getElement().classList.add("gengage-chat-drawer--hidden"),this._drawer.restorePanelState(t.accountId);const c=t.panelMode??"auto";c==="collapsed"?this._drawer.setPanelCollapsed(!0):c==="expanded"&&this._drawer.setForceExpanded();const l=sessionStorage.getItem("gengage_restore_session_id"),g=sessionStorage.getItem("gengage_restore_sku"),p=!!(l&&g);p&&(sessionStorage.removeItem("gengage_restore_session_id"),sessionStorage.removeItem("gengage_restore_sku"));try{const u=new Zr;await u.open(),this._session=new An(u),await this._restoreFromIndexedDB(p)}catch{this._session=new An(null)}this._registerPublicAPI(),t.mobileInitialState!==void 0&&(this._openState=t.mobileInitialState),this._mobileBreakpoint=t.mobileBreakpoint??768,this._syncViewportState();const d=()=>this._syncViewportState();if(window.addEventListener("resize",d,{passive:!0}),this.addCleanup(()=>window.removeEventListener("resize",d)),window.visualViewport){const u=()=>{if(!this._drawerVisible||!this._isMobileViewport)return;const b=this._drawer?.getElement();if(!b)return;const y=window.innerHeight-(window.visualViewport?.height??window.innerHeight);b.style.setProperty("--gengage-keyboard-offset",`${Math.max(0,y)}px`)};window.visualViewport.addEventListener("resize",u),this.addCleanup(()=>window.visualViewport?.removeEventListener("resize",u))}r==="inline"&&(this._drawerVisible=!0,this.isVisible=!0,this._applyOpenStateClasses(),this._presentation.setShown(!0),setTimeout(()=>this._maybeAutoAnchorUnreadAssistant(),60));const h={namespace:"chat",onMessage:u=>this._handleBridgeMessage(u)};t.allowedOrigins!==void 0&&(h.allowedOrigins=t.allowedOrigins),this._bridge=new _i(h),this._lastSku=this.config.pageContext?.sku,this._initComplete=!0;for(const u of this._pendingActions)this._sendAction(u.action,u.options);this._pendingActions=[],xe("gengage:chat:ready",{}),ns("chat"),t.onReady?.()}onUpdate(t){t.sku!==void 0&&t.sku!==this._lastSku&&(this._lastSku=t.sku,this._resetForNewPage())}onShow(){this._showDrawer(),this.emit("open"),xe("gengage:chat:open",{state:this._openState}),as("chat"),this.config.onOpen?.(),this._showWelcomeIfNeeded(),!this._pdpLaunched&&this.config.pageContext?.sku&&(this._pdpLaunched=!0,this._pdpPrimingInFlight=!0,this._sendAction({title:"",type:"launchSingleProduct",payload:{sku:this.config.pageContext.sku}},{silent:!0,isPdpPrime:!0}))}onHide(){(this.config.variant??"floating")==="floating"&&(this.root.style.display=""),this._hideDrawer(),this.emit("close"),xe("gengage:chat:close",{}),this.config.onClose?.()}onDestroy(){this._abortControllers.forEach(t=>t.abort()),this._abortControllers.clear(),this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,this._drawer?.destroy(),gn(),this._drawer=null,this._bridge?.destroy(),this._bridge=null,this._extendedModeManager=null,this._panel?.destroy(),this._panel=null,this._session?.close(),this._session=null,this._localPanelHistory=[],this._currentPanelSource=null,window.gengage&&delete window.gengage.chat,this._shadow&&(this._shadow.innerHTML="",this._shadow=null),this._rootEl=null}open(t){t?.state!==void 0&&(this._openState=t.state,this._drawerVisible&&this._applyOpenStateClasses()),this.show(),t?.initialMessage!==void 0&&this._sendMessage(t.initialMessage)}openWithAction(t,n){n?.sku!==void 0&&this.update({sku:n.sku}),this._pdpLaunched=!0,n?.state!==void 0?this._openState=n.state:this._isMobileViewport&&(this._openState="half"),this.show(),this._drawerVisible&&this._applyOpenStateClasses(),this._sendAction(t)}sendMessage(t){this._sendMessage(t)}sendAction(t,n){this._sendAction(t,n)}close(){this.hide()}saveSession(t,n){sessionStorage.setItem("gengage_restore_session_id",t),sessionStorage.setItem("gengage_restore_sku",n)}get isOpen(){return this._drawerVisible}addCallback(t,n){let a=this._eventCallbacks.get(t);return a||(a=new Set,this._eventCallbacks.set(t,a)),a.add(n),()=>{a.delete(n),a.size===0&&this._eventCallbacks.delete(t)}}_resetForNewPage(){this._activeRequestThreadId=null,this._abortControllers.forEach(t=>t.abort()),this._abortControllers.clear(),this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,this._messages.length=0,this._drawer?.clearMessages(),this._drawer?.clearPanel(),this._currentPanelSource=null,this._panel.snapshots.clear(),this._panel.threads=[],this._thumbnailEntries=[],this._drawer?.setThumbnails([]),this._comparisonSelectMode=!1,this._comparisonSelectedSkus=[],this._viewedProductSkus.clear(),this._currentThreadId=null,this._lastThreadId=null,this._lastBackendContext=null,this._chatCreatedAt=new Date().toISOString(),this._pdpLaunched=!1,this._pdpPrimingInFlight=!1,this._queuedUserMessages=[],this._productContextUnavailableSku=null,this._presentation.reset(),this._drawer?.setPresentationFocus(null),this._drawer?.setFormerMessagesButtonVisible(!1)}_flushPresentationScroll(){const t=this._presentation.scrollRequest;if(!t||!this._drawer)return;let n=!1;t.type==="thread"&&t.threadId?(n=this._drawer.scrollThreadIntoView(t.threadId,t.behavior),n||(this._drawer.scrollToBottomPresentation(t.behavior),n=!0)):t.type==="bottom"&&(this._drawer.scrollToBottomPresentation(t.behavior),n=!0),n&&this._presentation.consumeScrollRequest(t.id)}_releasePresentationFocus(){this._presentation.releaseFocusedThread(),this._drawer?.setPresentationFocus(null),this._drawer?.setFormerMessagesButtonVisible(!1)}_hasMultipleThreadIds(){const t=new Set;for(const n of this._messages)n.threadId&&t.add(n.threadId);return t.size>1}_orderedThreadIds(){const t=[],n=new Set;for(const a of this._messages)a.threadId&&!n.has(a.threadId)&&(n.add(a.threadId),t.push(a.threadId));return t}_maybeAutoAnchorUnreadAssistant(){if(!this._drawer||!this._presentation.shown)return;const t=this._orderedThreadIds();if(t.length===0)return;const n=Wr(t,this._presentation);if(!n)return;const a=`${n}:assistant`;this._presentation.lastAutoAnchoredGroupId!==a&&(this._presentation.userInteracting&&!this._presentation.pinnedToBottom||this._drawer.scrollThreadIntoView(n,"smooth")&&this._presentation.markGroupAutoAnchored(a))}_handleBridgeMessage(t){switch(t.type){case"openChat":this.open();break;case"closeChat":this.close();break;case"startNewChatWithLauncherAction":{const n=t.payload,a=n?.action,i=Ht(a)?a:Ht(n)?n:null;i&&this._sendAction(i,{silent:!0}),this.open();break}case"startNewChatWithDetailContext":{const n=t.payload;if(n&&typeof n=="object"){this._bridgeContext=n;const a=n.sku;if(a&&this.update({sku:a}),Ht(n.action)){this._pdpLaunched=!0,this.open(),this._sendAction(n.action);break}}this.open();break}case"launcherAction":{const a=t.payload?.action;a&&typeof a=="object"&&"type"in a&&this._sendAction(a);break}case"scrollToBottom":this._presentation.requestScrollToBottom("smooth"),setTimeout(()=>this._flushPresentationScroll(),40);break;case"addToCardHandler":{this._bridge?.send("addToCardResult",t.payload);break}case"cartQuantityHandler":{const n=t.payload;n&&"quantity"in n&&typeof n.quantity=="number"&&(this._cartQuantity=n.quantity);break}case"minimizeRequestedByUser":this._extendedModeManager?.setHiddenByUser(!0);break;case"bgColorChange":{const a=t.payload?.color;typeof a=="string"&&Ma(a)&&this._shadow&&this._shadow.host.style.setProperty("--gengage-chat-bg",a);break}}}_registerPublicAPI(){window.gengage||(window.gengage={}),window.gengage.chat={open:t=>this.open(t),openWithAction:(t,n)=>this.openWithAction(t,n),sendMessage:t=>this.sendMessage(t),sendAction:(t,n)=>this.sendAction(t,n),close:()=>this.close(),saveSession:(t,n)=>this.saveSession(t,n),get isOpen(){return!1},on:(t,n)=>this.on(t,n),trackCheckout:(t,n)=>this.trackCheckout(t,n),flushMeteringSummary:t=>this.flushMeteringSummary(t),addCallback:(t,n)=>this.addCallback(t,n)},Object.defineProperty(window.gengage.chat,"isOpen",{get:()=>this._drawerVisible})}_showDrawer(){if(this._drawerVisible)return;this._drawerVisible=!0;const t=this._drawer?.getElement();t&&t.classList.remove("gengage-chat-drawer--hidden"),this._applyOpenStateClasses(),this._drawer?.trapFocus(),this._isMobileViewport&&this._openState==="half"||this._drawer?.focusInput(),this._extendedModeManager?.setChatShown(!0),this._presentation.setShown(!0),setTimeout(()=>this._maybeAutoAnchorUnreadAssistant(),60)}_showWelcomeIfNeeded(){if(this._messages.length!==0||!this.config.welcomeMessage)return;const t={id:wt(),role:"assistant",content:this.config.welcomeMessage,timestamp:Date.now(),status:"done"};this._messages.push(t),this._drawer?.addMessage(t),this.config.welcomeActions?.length&&this._drawer?.setPills(this.config.welcomeActions.map(n=>({label:n,onAction:()=>this._sendMessage(n)})))}_hideDrawer(){if(!this._drawerVisible)return;this._drawer?.releaseFocus(),this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,this._drawerVisible=!1,this._openState="full";const t=this._drawer?.getElement();t&&t.classList.add("gengage-chat-drawer--hidden"),this._applyOpenStateClasses(),this._extendedModeManager?.setChatShown(!1),this._presentation.setShown(!1),this._drawer?.setPresentationFocus(null),this._drawer?.setFormerMessagesButtonVisible(!1)}_syncViewportState(){if(this._rootEl){if(this._isMobileViewport=window.innerWidth<=this._mobileBreakpoint,this._rootEl.classList.toggle("gengage-chat-root--mobile",this._isMobileViewport),this._launcher){const t=this._isMobileViewport&&this.config.hideMobileLauncher===!0;this._launcher.container.classList.toggle("gengage-chat-launcher--hidden-mobile",t)}this._applyOpenStateClasses()}}_applyOpenStateClasses(){if(!this._rootEl)return;const t=this._drawerVisible&&this._isMobileViewport&&this._openState==="half",n=this._drawerVisible&&this._isMobileViewport&&this._openState==="full";this._rootEl.classList.toggle("gengage-chat-root--open",this._drawerVisible),this._rootEl.classList.toggle("gengage-chat-root--mobile-half",t),this._rootEl.classList.toggle("gengage-chat-root--mobile-full",n)}_handleAttachment(t){const n=Si(t);if(!n.ok){const a=n.reason==="invalid_type"?this._i18n.invalidFileType:this._i18n.fileTooLarge;xe("gengage:global:error",{message:a,source:"chat"});return}this._drawer?.stageAttachment(t)}_sendMessage(t,n){if(this._pdpPrimingInFlight){this._queuedUserMessages.push(n!==void 0?{text:t,attachment:n}:{text:t});return}us(),this._messages.some(o=>o.role==="user")||fs();const i=n!==void 0?{title:t,type:"findSimilar",payload:t?{text:t}:{}}:{title:t,type:"user_message",payload:t};n!==void 0?this._sendAction(i,{attachment:n}):this._sendAction(i)}_flushQueuedUserMessages(){if(this._pdpPrimingInFlight||this._queuedUserMessages.length===0)return;const t=[...this._queuedUserMessages];this._queuedUserMessages=[];for(const n of t)this._sendMessage(n.text,n.attachment)}_sendAction(t,n){if(this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,this._lastSentAction={action:t,options:n},!this._initComplete){this._pendingActions.length<10&&this._pendingActions.push({action:t,options:n});return}if(this._choicePrompterEl?.remove(),this._choicePrompterEl=null,!n?.preservePanel&&this._comparisonSelectMode&&(this._comparisonSelectMode=!1,this._comparisonSelectedSkus=[]),n?.preservePanel||(this._localPanelHistory=[]),this._currentThreadId&&this._lastThreadId&&this._lastThreadId>this._currentThreadId){const _=this._currentThreadId,L=this._messages.filter(T=>T.threadId!==void 0&&T.threadId>_);this._messages=this._messages.filter(T=>!T.threadId||T.threadId<=_);for(const T of L)this._shadow?.querySelector(`[data-message-id="${CSS.escape(T.id)}"]`)?.remove(),this._panel.snapshots.delete(T.id),this._panel.snapshotTypes.delete(T.id);this._shadow?.querySelectorAll("[data-thread-id]")?.forEach(T=>{T instanceof HTMLElement&&T.dataset.threadId&&T.dataset.threadId>_&&T.remove()})}this._drawer?.setPills([]),this._drawer?.clearInputAreaChips(),this._bridge?.send("isResponding",!0);const a=wt();this._currentThreadId=a,this._lastThreadId=a,this._panel&&t.type!=="launchSingleProduct"&&(this._panel.lastActionType=t.type);const i=n?.preservePanel===!0,o=t.type==="launchSingleProduct"&&n?.silent===!0&&n?.isPdpPrime===!0;if(i||(this._activeRequestThreadId=a),!n?.silent){const _=typeof t.payload=="string"?t.payload:t.title,L=this._messages.length>0?this._messages[this._messages.length-1]:void 0;if(!(L!==void 0&&L.role==="user"&&L.content===_)){const T=this._createMessage("user",_);T.threadId=a,n?.attachment!==void 0&&(T.attachment=n.attachment),this._drawer?.addMessage(T),this._messages.push(T)}}if(!n?.silent&&this._hasUnavailableProductContext()&&(t.type==="user_message"||t.type==="inputText")){const _=this._i18n.productNotFoundMessage,L=this._createMessage("assistant",_);L.threadId=a,L.status="done",this._messages.push(L),this._ensureAssistantMessageRendered(L),this._drawer?.updateBotMessage(L.id,_),this._bridge?.send("isResponding",!1),this.emit("message",L),this._persistToIndexedDB().catch(()=>{});return}let s=this._currentPanelSource,c=!1;const l=()=>{c||n?.preservePanel||(s=this._currentPanelSource,c=!0)},g=()=>{if(this._drawer?.isPanelLoading()){if(s){const _=this._buildRenderContext(),L=s.kind==="favorites"?this._buildFavoritesPageEl():this._renderUISpec(s.spec,_);this._drawer.setPanelContent(L),this._currentPanelSource=s}else this._drawer.clearPanel(),this._currentPanelSource=null;s=null}};this._drawer?.showTypingIndicator();let p="";const d=this._createMessage("assistant","");d.threadId=a,d.status="streaming",n?.silent&&(d.silent=!0),this._messages.push(d),this._presentation.registerAssistantActivity(a),this._presentation.requestThreadFocus(a,"smooth"),this._drawer?.setPresentationFocus(a),this._drawer?.setFormerMessagesButtonVisible(!1),setTimeout(()=>this._flushPresentationScroll(),40),n?.preservePanel||(this._abortControllers.forEach(_=>_.abort()),this._abortControllers.clear());const h={middlewareUrl:this.config.middlewareUrl,...this.config.accountId?{accountId:this.config.accountId}:{}};n?.attachment!==void 0&&(h.attachment=n.attachment);const b=this._getVisibleMessages().filter(_=>_!==d&&(_.content||_.role==="assistant")).slice(-50).map(_=>({role:_.role==="user"?"user":"model",content:_.content??""})),y={outputLanguage:Qr(this.config.locale),parentUrl:window.location.href,windowWidth:String(window.innerWidth),windowHeight:String(window.innerHeight),selfUrl:"",id:this.config.session?.sessionId??"",userId:this.config.session?.userId??"",appId:this.config.accountId,threads:[],createdAt:this._chatCreatedAt,kvkkApproved:Ln(this.config.accountId),voiceEnabled:this.config.voiceEnabled??!1,threadId:a,isControlGroup:this.config.session?.abTestVariant==="control",isMobile:this._isMobileViewport};this.config.session?.viewId!==void 0&&(y.viewId=this.config.session.viewId);const w=ko(t,{pageContext:this.config.pageContext,backendContext:this._lastBackendContext,isMobile:this._isMobileViewport}),E={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",type:w.type,locale:this.config.locale??"tr",meta:y,context:{...this._lastBackendContext??{},messages:b,session_id:this.config.session?.sessionId??""}};this.config.session?.userId!==void 0&&(E.user_id=this.config.session.userId),this.config.session?.viewId!==void 0&&(E.view_id=this.config.session.viewId),w.payload!==void 0&&(E.payload=w.payload),this.config.pageContext?.sku!==void 0&&(E.sku=this.config.pageContext.sku),this.config.pageContext?.pageType!==void 0&&(E.page_type=this.config.pageContext.pageType);const A=crypto.randomUUID(),f=Date.now();let C=0,U=!1,R=!1,k=!1,I=!1,S=!1,B=null;const ne=()=>{if(this._drawer){if(this._isMobileViewport||!k){this._drawer.setPanelAiZoneState("hidden");return}I||(S?this._drawer.setPanelAiZoneState("hidden"):this._drawer.setPanelAiZoneState("analyzing",{analyzingLabel:this._i18n.aiAnalysisAnalyzingLabel}))}};this.track($a(this.analyticsContext(),{endpoint:"process_action",request_id:A,widget:"chat"}));let F=null;if(F=So(E,{onTextChunk:(_,L,P)=>{if(!i&&a!==this._activeRequestThreadId||(p+=_,this._drawer?.removeTypingIndicator(),P?.skuToProductItem&&(this._skuToProductItem={...this._skuToProductItem,...P.skuToProductItem}),P?.conversationMode&&(this._conversationMode=P.conversationMode),this.track(Da(this.analyticsContext(),{request_id:A,chunk_index:C++,widget:"chat"})),!this._drawer))return;let T=p;if(L&&Pt(T)){const N=this.config.accountId;if(!Ln(N)){const G=Jr(T);G?this._drawer?.showKvkkBanner(G,()=>{this._drawer?.hideKvkkBanner(),zn(N)}):zn(N)}T=Yr(T)}const M=this._shadow?.querySelector(`[data-message-id="${d.id}"] .gengage-chat-bubble-text`);if(M?M.innerHTML=we(T):(d.content=T,d.role==="assistant"&&d.threadId&&!this._threadsWithFirstBot.has(d.threadId)&&(this._threadsWithFirstBot.add(d.threadId),this._drawer.markFirstBotMessage(d.id)),this._drawer.addMessage(d)),L){d.content=T,d.status="done",Mn();const N=this._shadow?.querySelector(`[data-message-id="${d.id}"] .gengage-chat-bubble-text`);if(N){this._activeTypewriter?.cancel();const G=P?.productMentions;this._activeTypewriter=zr({container:N,html:we(T),onTick:()=>this._drawer?.scrollToBottomIfNeeded(),onComplete:()=>{this._activeTypewriter=null,G&&G.length>0&&N&&Nr({container:N,mentions:G,onProductClick:W=>{this._sendAction({title:G.find(ce=>ce.sku===W)?.short_name??W,type:"launchSingleProduct",payload:{sku:W}})}})}})}}},onUISpec:(_,L,P)=>{if(!i&&a!==this._activeRequestThreadId||L!=="chat")return;const T=_.elements[_.root],M=T?.type??"unknown";this.track(Fa(this.analyticsContext(),{request_id:A,chunk_index:C,component_type:M,widget:"chat"}));const N=this._buildRenderContext();if(N.isStreaming=!0,M==="ComparisonTable"){const H=T?.props?.products;cs(Array.isArray(H)?H.length:0)}if(M==="ProductGrid"){const H=T?.children?.length??0;ds(void 0,H)}const G=P==="panel"&&this._panel?this._panel.toPanelSpec(_):_;if(P==="panel"&&this._panel){const H=!R;R=!0;const Z=Vr({componentType:M,similarsAppend:T?.props?.similarsAppend===!0,currentPanelType:this._panel.currentType,hasPanelContent:this._drawer?.hasPanelContent()??!1,isPanelLoading:this._drawer?.isPanelLoading()??!1,isFirstPanelContentInStream:H});Z==="appendSimilars"?this._appendSimilarsToPanel(G,N):Z==="append"?(this._drawer?.appendPanelContent(this._renderUISpec(G,N)),this._comparisonSelectMode&&this._refreshComparisonUI()):(this._comparisonSelectMode=!1,this._comparisonSelectedSkus=[],this._drawer?.setPanelContent(this._renderUISpec(G,N)),this._currentPanelSource={kind:"spec",spec:G},this._panel.currentType=M),M==="ProductDetailsPanel"&&t.type==="launchSingleProduct"&&this._clearUnavailableProductContext(),d.threadId&&!this._panel.threads.includes(d.threadId)&&this._panel.threads.push(d.threadId);const q=this._panel.currentType??M,$=T?.props?.panelTitle;if(this._panel.updateTopBar(q,$),this._panel.updateExtendedMode(M),M==="ProductGrid"||M==="CategoriesContainer"){if(k=!this._isMobileViewport,B){const re=this._buildRenderContext();re.isStreaming=!0;const v=this._renderUISpec(B,re);I=!0,this._drawer?.setPanelAiZoneState("results",{resultEl:v}),B=null}}else Z!=="appendSimilars"&&Z!=="append"&&(k=!1,B=null,this._drawer?.setPanelAiZoneState("hidden"))}if(M==="ProductDetailsPanel"&&!d.silent&&P==="panel"){const H=T?.props?.product;if(H){const Z={root:"root",elements:{root:{type:"ProductSummaryCard",props:{product:H}}}},q=this._shadow?.querySelector(".gengage-chat-messages");if(q){const $=this._renderUISpec(Z,N);d.threadId&&($.dataset.threadId=d.threadId),q.appendChild($),$.scrollIntoView({behavior:"auto",block:"end"}),this._drawer?.refreshPresentationCollapsed()}}}const W=M==="AITopPicks"||M==="AIGroupingCards";let ce=!1,oe=!1;if(W&&!this._isMobileViewport&&!d.silent)if(k){const H=this._renderUISpec(_,N);I=!0,this._drawer?.setPanelAiZoneState("results",{resultEl:H}),ce=!0,B=null}else B=_,oe=!0;if(!d.silent&&(P!=="panel"||M==="ProductCard")&&M!=="ActionButtons"&&!ce&&!(oe&&W)){const H=this._shadow?.querySelector(".gengage-chat-messages");if(H){const Z=this._renderUISpec(_,N);d.threadId&&(Z.dataset.threadId=d.threadId),H.appendChild(Z),Z.scrollIntoView({behavior:"auto",block:"end"}),this._drawer?.refreshPresentationCollapsed()}}if((M==="ProductGrid"||M==="ProductCard")&&d.threadId){const H=T?.children??[],Z=M==="ProductGrid"?H.map(q=>_.elements[q]?.props?.product).filter(Boolean):[T?.props?.product].filter(Boolean);for(const q of Z){const $=q.sku,re=q.imageUrl;$&&re&&this._thumbnailEntries.push({sku:$,imageUrl:re,threadId:d.threadId}),$&&this._viewedProductSkus.add($)}this._drawer?.setThumbnails(this._thumbnailEntries)}if(M==="ProductGrid"||M==="ProductDetailsPanel"){const Z=(M==="ProductGrid"?(T?.children??[]).map(q=>_.elements[q]?.props?.product).filter(Boolean):[T?.props?.product??T?.props].filter(Boolean)).map(q=>q.imageUrl).filter(q=>typeof q=="string").slice(0,5);Z.length>0&&this._bridge?.send("previewImages",{images:Z})}if(M==="ProductGrid"&&P==="panel"&&this._viewedProductSkus.size>=2&&!this._comparisonSelectMode&&!$r()&&!Dr(this._currentThreadId??"")){this._choicePrompterEl?.remove(),this._shadow?.querySelectorAll(".gengage-chat-choice-prompter").forEach(Z=>Z.remove()),this._choicePrompterEl=Or({heading:this._i18n.choicePrompterHeading,suggestion:this._i18n.choicePrompterSuggestion,ctaLabel:this._i18n.choicePrompterCta,threadId:this._currentThreadId??"",dismissAriaLabel:this._i18n.dismissAriaLabel,onCtaClick:()=>{this._comparisonSelectMode=!0,this._choicePrompterEl=null,this._refreshComparisonUI()},onDismiss:()=>{this._choicePrompterEl=null}});const H=this._shadow?.querySelector(".gengage-chat-panel-float");if(H){if(H.appendChild(this._choicePrompterEl),this._isMobileViewport&&window.visualViewport){const Z=this._choicePrompterEl,q=()=>{window.visualViewport.height/window.innerHeight<.75&&(Z.remove(),this._choicePrompterEl===Z&&(this._choicePrompterEl=null),window.visualViewport.removeEventListener("resize",q))};window.visualViewport.addEventListener("resize",q)}}else this._choicePrompterEl=null}if(M==="ActionButtons"){const H=T?.props?.buttons;if(H&&H.length>0){const Z=[],q=[];for(const $ of H)if(Rr($)){const re={label:$.label,action:$.action};$.icon&&(re.icon=$.icon),Z.push(re)}else q.push($);Z.length>0&&this._drawer?.setInputAreaChips(Z.map($=>({label:$.label,onAction:()=>this._sendAction($.action),...$.icon?{icon:$.icon}:{}}))),q.length>0&&this._drawer?.setPills(q.map($=>{const re={label:$.label,onAction:()=>this._sendAction($.action)};return $.icon&&(re.icon=$.icon),$.image&&(re.image=$.image),$.description&&(re.description=$.description),re}))}}ne(),d.uiSpec=_},onAction:_=>{if(!(!i&&a!==this._activeRequestThreadId)&&_.type==="action"){const L={};this.config.actionHandling?.unknownActionPolicy!==void 0&&(L.unknownActionPolicy=this.config.actionHandling.unknownActionPolicy),this.config.actionHandling?.allowScriptCall!==void 0&&(L.allowScriptCall=this.config.actionHandling.allowScriptCall),wi(_,{openChat:()=>this.open(),navigate:P=>{le(P.url)&&(this._bridge?.send("navigate",P),P.newTab?window.open(P.url,"_blank","noopener,noreferrer"):window.location.href=P.url)},saveSession:P=>this.saveSession(P.sessionId,P.sku),addToCart:P=>{xe("gengage:similar:add-to-cart",P)},scriptCall:P=>{xe("gengage:chat:script-call",P),this.config.onScriptCall?.(P)}},L)}},onMetadata:_=>{if(!(!i&&a!==this._activeRequestThreadId)&&_.type==="metadata"&&_.meta){if((_.meta.panel!==void 0||_.meta.messages!==void 0||_.meta.message_id!==void 0)&&(this._lastBackendContext=_.meta),_.meta.panelLoading){U=!0,R=!1,l();const P=typeof _.meta.panelPendingType=="string"?_.meta.panelPendingType:void 0;this._panel&&(this._panel.currentType=null),this._drawer?.showPanelLoading(P),P&&this._panel?.updateTopBarForLoading(P)}if(_.meta.voice){const P=new CustomEvent("gengage:chat:voice",{detail:{payload:_.meta.voice},bubbles:!1,cancelable:!0}),T=window.dispatchEvent(P);if(ms(),T){const M=_.meta.voice;M.audio_base64&&(this._activeTtsHandle?.stop(),this._activeTtsHandle=Vo(M.audio_base64,M.content_type??"audio/ogg"))}}(_.meta.redirectTarget||_.meta.redirect)&&xe("gengage:chat:redirect",{target:_.meta.redirectTarget??null,payload:_.meta.redirect??null}),_.meta.analyzeAnimation&&(U=!0,R=!1,l(),this._panel&&(this._panel.currentType=null),this._drawer?.showPanelLoading(),this._panel?.updateTopBarForLoading("productDetails")),_.meta.loading&&typeof _.meta.loadingText=="string"&&(this._drawer?.addThinkingStep(_.meta.loadingText),this._bridge?.send("loadingMessage",{text:_.meta.loadingText})),_.meta.visitorDataResponse&&this._bridge?.send("engagingMessage",_.meta.visitorDataResponse),_.meta.formType&&this._bridge?.send("glovOtokoc",{type:_.meta.formType,data:_.meta.formPayload}),_.meta.launcherContent&&this._bridge?.send("launcherContent",_.meta.launcherContent),xe("gengage:chat:metadata",{payload:_.meta});const L=_.meta;typeof L.prompt_tokens=="number"&&typeof L.completion_tokens=="number"&&this.track(ja(this.analyticsContext(),{model:_.model??"unknown",prompt_tokens:L.prompt_tokens,completion_tokens:L.completion_tokens,total_tokens:L.total_tokens??L.prompt_tokens+L.completion_tokens}))}},onError:_=>{if(F&&this._abortControllers.delete(F),!i&&a!==this._activeRequestThreadId)return;S=!0,ne(),B=null,this._bridge?.send("isResponding",!1),this._bridge?.send("loadingMessage",{text:null}),this._drawer?.removeTypingIndicator();const L=R;if(U&&!R&&g(),U=!1,R=!1,!(d.silent||d.content!=null&&d.content.length>0||p.length>0||L))if(o||this._hasUnavailableProductContext()){const T=this._i18n.productNotFoundMessage;d.content=T,d.status="done",this._ensureAssistantMessageRendered(d),this._drawer?.updateBotMessage(d.id,T),this._markUnavailableProductContext()}else{this.emit("error",_);const T=_.message;T===this._lastErrorMessage?this._consecutiveErrorCount++:(this._consecutiveErrorCount=1,this._lastErrorMessage=T),this._consecutiveErrorCount>=2?this._drawer?.showErrorWithRecovery(this._i18n.accountInactiveMessage,{onRetry:()=>{this._lastSentAction&&this._sendAction(this._lastSentAction.action,this._lastSentAction.options)},onNewQuestion:()=>{this._drawer?.focusInput()}}):this._drawer?.showErrorWithRecovery(this._i18n.errorMessage,{onRetry:()=>{this._lastSentAction&&this._sendAction(this._lastSentAction.action,this._lastSentAction.options)},onNewQuestion:()=>{this._drawer?.focusInput()}})}o&&(this._pdpPrimingInFlight=!1,this._flushQueuedUserMessages()),d.status==="streaming"&&(d.status="error"),this.track(Za(this.analyticsContext(),{request_id:A,error_code:"STREAM_ERROR",error_message:_.message,widget:"chat"}))},onDone:()=>{if(F&&this._abortControllers.delete(F),!i&&a!==this._activeRequestThreadId)return;if(S=!0,ne(),B){const P=this._buildRenderContext();P.isStreaming=!1;const T=this._shadow?.querySelector(".gengage-chat-messages");if(T){const M=this._renderUISpec(B,P);d.threadId&&(M.dataset.threadId=d.threadId),T.appendChild(M),M.scrollIntoView({behavior:"auto",block:"end"}),this._drawer?.refreshPresentationCollapsed()}B=null}if(this._activeRequestThreadId=null,this._consecutiveErrorCount=0,this._lastErrorMessage="",this._bridge?.send("isResponding",!1),this._bridge?.send("loadingMessage",{text:null}),this._drawer?.removeTypingIndicator(),U&&!R&&g(),U=!1,R=!1,o&&!p&&!R){const P=this._i18n.productNotFoundMessage;d.content=P,this._ensureAssistantMessageRendered(d),this._drawer?.updateBotMessage(d.id,P),this._markUnavailableProductContext()}o&&(this._pdpPrimingInFlight=!1,this._flushQueuedUserMessages()),d.status==="streaming"&&(d.status="done",Mn()),this._presentation.finalizeAssistantGroup(a);const _=this._shadow?.querySelector(".gengage-chat-comparison-toggle-btn--hidden");_&&(_.classList.remove("gengage-chat-comparison-toggle-btn--hidden"),_.classList.add("gengage-chat-comparison-toggle-btn--reveal")),this.emit("message",d);const L=this._currentPanelSource;this._panel?.snapshotForMessage(d.id,L?()=>{const P=this._buildRenderContext();return L.kind==="favorites"?this._buildFavoritesPageEl():this._renderUISpec(L.spec,P)}:void 0),this._panel?.attachClickHandler(d.id),this.track(Ua(this.analyticsContext(),{request_id:A,latency_ms:Date.now()-f,chunk_count:C,widget:"chat"})),this.track(qa(this.analyticsContext(),{meter_key:"chat_request",quantity:1,unit:"request"})),this.track(Va(this.analyticsContext(),{message_count:this._messages.length,history_ref:this.config.session?.sessionId??"",redaction_level:"none"})),this._persistToIndexedDB().catch(()=>{})}},h),this._abortControllers.add(F),!n?.silent&&!i){const _=F;this._drawer?.showStopButton(()=>{_.abort(),this._abortControllers.delete(_),this._drawer?.removeTypingIndicator(),this._bridge?.send("isResponding",!1),this._bridge?.send("loadingMessage",{text:null}),d.status==="streaming"&&(d.status="done")})}}_getVisibleMessages(){const t=this._messages.filter(a=>!a.silent);if(!this._currentThreadId)return t;const n=this._currentThreadId;return t.filter(a=>!a.threadId||a.threadId<=n)}_appendSimilarsToPanel(t,n){if(!this._drawer)return;const a=this._drawer.getPanelContentElement();if(!a)return;const i=document.createElement("h3");i.className="gengage-chat-product-details-similars-heading",i.textContent=this._i18n.similarProductsLabel??"Similar Products",a.appendChild(i);const o=this._renderUISpec(t,n);o.classList.add("gengage-chat-product-details-similars"),a.appendChild(o)}_handleRollback(t){const n=this._messages.find(a=>a.id===t);n?.threadId&&this._rollbackToThread(n.threadId)}_rollbackToThread(t){if(this._panel&&this._panel.threads.length>0&&!this._panel.threads.includes(t)&&!this._messages.some(o=>o.threadId===t))return;this._currentThreadId=t,this._extendedModeManager?.setHiddenByUser(!1),this._presentation.setFocusedThreadId(t),this._drawer?.setPresentationFocus(t),this._drawer?.setFormerMessagesButtonVisible(!1);for(const o of this._messages){const r=this._shadow?.querySelector(`[data-message-id="${CSS.escape(o.id)}"]`);r&&(o.threadId&&o.threadId>t?r.classList.add("gengage-chat-bubble--hidden"):r.classList.remove("gengage-chat-bubble--hidden"))}this._shadow?.querySelectorAll("[data-thread-id]").forEach(o=>{o instanceof HTMLElement&&o.dataset.threadId&&o.dataset.threadId>t?o.classList.add("gengage-chat-bubble--hidden"):o instanceof HTMLElement&&o.classList.remove("gengage-chat-bubble--hidden")});const n=this._messages.find(o=>o.role==="assistant"&&o.threadId===t),a=n?this._panel?.restoreForMessage(n.id):!1;a||(this._drawer?.clearPanel(),this._currentPanelSource=null),a&&n&&(this._currentPanelSource=null);const i=this._panel.currentType??"";if(this._panel?.updateTopBar(i),this._drawer?.setPills([]),this._session?.db&&this.config.session?.sessionId){const o=this.config.session.sessionId;(async()=>{try{const r=await this._session?.db?.loadContext(o,t);r&&(this._lastBackendContext=r.context),await this._session?.db?.deleteContextsAfterThread(o,t)}catch{}})()}}async _persistToIndexedDB(){!this._session||!this.config.session?.sessionId||await this._session.persist({userId:this.config.session.userId??"",appId:this.config.accountId,sessionId:this.config.session.sessionId,messages:this._messages,currentThreadId:this._currentThreadId,lastThreadId:this._lastThreadId,chatCreatedAt:this._chatCreatedAt,panelSnapshots:this._panel?.snapshots??new Map,panelThreads:this._panel?.threads??[],thumbnailEntries:this._thumbnailEntries,lastBackendContext:this._lastBackendContext,sku:this.config.pageContext?.sku})}_isSameOriginUrl(t){try{return t.trim()?new URL(t,window.location.href).origin===window.location.origin:!1}catch{return!1}}_markUnavailableProductContext(){this._productContextUnavailableSku=this.config.pageContext?.sku??null}_clearUnavailableProductContext(){this._productContextUnavailableSku=null}_hasUnavailableProductContext(){const t=this.config.pageContext?.sku;return t!==void 0&&t.length>0&&this._productContextUnavailableSku===t}_ensureAssistantMessageRendered(t){if(!(this._shadow?.querySelector(`[data-message-id="${CSS.escape(t.id)}"]`)||!this._drawer)){if(t.role==="assistant"&&t.threadId&&!this._threadsWithFirstBot.has(t.threadId)){this._threadsWithFirstBot.add(t.threadId),this._drawer.addMessage(t),this._drawer.markFirstBotMessage(t.id);return}this._drawer.addMessage(t)}}async _saveSessionAndOpenURL(t){this._session&&await this._session.saveAndOpenURL(t,()=>this._persistToIndexedDB(),this._bridge)}async _loadPayload(t,n){return this._session?this._session.loadPayload(t,n):null}async _restoreFromIndexedDB(t){if(!this._session?.db)return;const n=this.config.session?.sessionId;if(!n)return;const a=this.config.session?.userId??"",i=this.config.accountId;if(await this._session.loadFavorites(a,i),this._drawer?.updateFavoritesBadge(this._session.favoritedSkus.size),!t)return;const o=await this._session.db?.loadSession(a,i,n);if(!o||o.messages.length===0)return;const r=this.config.pageContext?.sku;if(r&&o.sku&&o.sku!==r)return;if(this._pdpLaunched=!0,this._drawer?.lockScrollForRestore(),this._currentThreadId=o.currentThreadId,this._lastThreadId=o.lastThreadId,this._currentThreadId&&this._lastThreadId&&this._currentThreadId>this._lastThreadId&&(this._currentThreadId=this._lastThreadId),this._chatCreatedAt=o.createdAt,o.panelThreads&&(this._panel.threads=o.panelThreads),o.thumbnailEntries&&(this._thumbnailEntries=o.thumbnailEntries,this._drawer?.setThumbnails(this._thumbnailEntries)),o.panelSnapshotHtml)for(const[c,l]of Object.entries(o.panelSnapshotHtml)){const g=document.createElement("div");g.innerHTML=we(l),this._panel.snapshots.set(c,g)}let s=0;for(const c of o.messages){const l={id:c.id,role:c.role,timestamp:c.timestamp,status:c.status};if(c.threadId!==void 0&&(l.threadId=c.threadId),c.content!==void 0&&(l.content=c.content),c.silent&&(l.silent=!0),this._messages.push(l),l.silent)continue;l.role==="assistant"&&l.threadId&&!this._threadsWithFirstBot.has(l.threadId)&&(this._threadsWithFirstBot.add(l.threadId),this._drawer?.markFirstBotMessage(l.id)),this._drawer?.addMessage(l);const g=parseInt(c.id.replace("msg-",""),10);if(!isNaN(g)&&g>s&&(s=g),l.role==="assistant"&&l.threadId){const p=await this._loadPayload(l.threadId,l.id);p&&(l.uiSpec=p,this._restoreInlineUISpec(l),this._panel?.attachClickHandler(l.id),delete l.uiSpec)}}if(s>this._currentMessageId&&(this._currentMessageId=s),this._currentThreadId){let c=await this._session.db?.loadContext(n,this._currentThreadId);c||(c=await this._session.db?.loadLatestContext(n)),c&&(this._lastBackendContext=c.context)}if(this._currentThreadId){const c=[...this._messages].reverse().find(l=>l.role==="assistant"&&l.threadId===this._currentThreadId&&!l.silent);c&&this._panel.snapshots.has(c.id)&&this._panel?.restoreForMessage(c.id)}if(this._currentThreadId){const c=this._currentThreadId;for(const l of this._messages)l.threadId&&l.threadId>c&&this._shadow?.querySelector(`[data-message-id="${CSS.escape(l.id)}"]`)?.classList.add("gengage-chat-bubble--hidden");this._shadow?.querySelectorAll("[data-thread-id]").forEach(l=>{l instanceof HTMLElement&&l.dataset.threadId&&l.dataset.threadId>c&&l.classList.add("gengage-chat-bubble--hidden")})}if(this._panel.threads.length>0&&this._currentThreadId){const c=this._panel.threads[this._panel.threads.length-1];if(c){const l=[...this._messages].reverse().find(g=>g.role==="assistant"&&g.threadId===c);if(l?.threadId){const g=await this._loadPayload(l.threadId,l.id);if(g){const p=g.elements[g.root];p&&this._panel?.updateTopBar(p.type)}}}}this._presentation.releaseFocusedThread(),this._drawer?.setPresentationFocus(null),setTimeout(()=>{this._drawer?.scrollToLastThread()},550)}_navigatePanelBack(){const t=this._localPanelHistory.pop();if(t){const n=this._buildRenderContext(),a=t.source.kind==="favorites"?this._buildFavoritesPageEl():this._renderUISpec(t.source.spec,n);this._drawer?.setPanelContent(a),this._currentPanelSource=t.source;const i=this._localPanelHistory.length>0||(this._panel?.threads.length??0)>1;this._drawer?.updatePanelTopBar(i,!1,t.title);return}if(this._isMobileViewport){this._drawer?.hideMobilePanel();return}this._panel?.navigateBack()}_toggleComparisonSku(t){t===""?(this._comparisonSelectMode=!this._comparisonSelectMode,this._comparisonSelectMode||(this._comparisonSelectedSkus=[],ss())):this._comparisonSelectedSkus.indexOf(t)>=0?this._comparisonSelectedSkus=this._comparisonSelectedSkus.filter(a=>a!==t):(this._comparisonSelectedSkus=[...this._comparisonSelectedSkus,t],rs(t)),this._refreshComparisonUI()}_refreshComparisonUI(){const t=this._shadow?.querySelector(".gengage-chat-panel");if(!t)return;const n=t.querySelector(".gengage-chat-product-grid-wrapper");if(!n)return;const a=n.querySelector(".gengage-chat-product-grid");if(!a)return;const i=n.querySelector(".gengage-chat-comparison-toggle-btn");if(i&&i.classList.toggle("gengage-chat-comparison-toggle-btn--active",this._comparisonSelectMode),this._comparisonSelectMode){const r=a.querySelectorAll(".gengage-chat-product-card[data-sku]");for(const s of r){if(s.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){const p=s.parentElement.querySelector(".gengage-chat-comparison-checkbox");p&&(p.checked=this._comparisonSelectedSkus.includes(s.dataset.sku));continue}const c=s.dataset.sku,l=document.createElement("div");l.className="gengage-chat-comparison-select-wrapper";const g=document.createElement("input");g.type="checkbox",g.className="gengage-chat-comparison-checkbox",g.checked=this._comparisonSelectedSkus.includes(c),g.addEventListener("change",()=>{this._toggleComparisonSku(c)}),s.parentNode.insertBefore(l,s),l.appendChild(g),l.appendChild(s),l.style.cursor="pointer",l.addEventListener("click",p=>{p.target!==g&&(g.checked=!g.checked,this._toggleComparisonSku(c))})}}else{const r=a.querySelectorAll(".gengage-chat-comparison-select-wrapper");for(const s of r){const c=s.querySelector(".gengage-chat-product-card");c&&s.parentNode&&(s.parentNode.insertBefore(c,s),s.remove())}}const o=n.querySelector(".gengage-chat-comparison-floating-btn");if(this._comparisonSelectMode){const r=this._comparisonSelectedSkus.length,s=r>=2,c=this._i18n.compareSelected??"Compare",l=s?`${c} (${r})`:this._i18n.compareMinHint??"Select at least 2 products";if(o)o.textContent=l,o.disabled=!s,o.classList.toggle("gengage-chat-comparison-floating-btn--disabled",!s);else{const g=document.createElement("button");g.className="gengage-chat-comparison-floating-btn",g.type="button",g.textContent=l,g.disabled=!s,s||g.classList.add("gengage-chat-comparison-floating-btn--disabled"),g.addEventListener("click",()=>{this._comparisonSelectedSkus.length<2||(Nn(this._comparisonSelectedSkus),this._isMobileViewport&&this._drawer?.hideMobilePanel(),this._sendAction({title:c,type:"getComparisonTable",payload:{sku_list:[...this._comparisonSelectedSkus]}}))}),n.appendChild(g)}}else o?.remove()}_buildRenderContext(){const t={onAction:n=>{if(is(n.title,n.type),n.type==="findSimilar"){const i=typeof n.payload=="object"&&n.payload!==null&&"sku"in n.payload?String(n.payload.sku):"";os(i)}n.type==="getComparisonTable"&&Nn(this._comparisonSelectedSkus);const a=n.type==="addToCart"||n.type==="like";this._sendAction(n,a?{preservePanel:!0}:void 0)},onProductClick:n=>{ps(n.sku),this.config.isDemoWebsite!==!0&&this._isSameOriginUrl(n.url)?(xe("gengage:similar:product-click",{sku:n.sku,url:n.url,sessionId:this.config.session?.sessionId??null}),this._saveSessionAndOpenURL(n.url)):this._sendAction({title:n.sku,type:"launchSingleProduct",payload:{sku:n.sku}})},onAddToCart:n=>{hs(n.sku,n.quantity);const a={...n,sessionId:this.config.session?.sessionId??null};xe("gengage:chat:add-to-cart",a),this._bridge?.send("addToCart",n),this._runEventCallbacks("gengage-cart-add",a),this.track(Wa(this.analyticsContext(),{attribution_source:"chat",attribution_action_id:crypto.randomUUID(),cart_value:0,currency:"TRY",line_items:n.quantity,sku:n.sku})),this._sendAction({title:this._i18n.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:n.sku,cart_code:n.cartCode,quantity:n.quantity}},{preservePanel:!0})},onProductSelect:n=>{if(this._currentPanelSource){const i=this._drawer?.getPanelTopBarTitle()??"";this._localPanelHistory.push({source:this._currentPanelSource,title:i}),this._localPanelHistory.length>et._MAX_PANEL_HISTORY&&this._localPanelHistory.shift()}const a={root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:n}}}};this._drawer?.setPanelContent(this._renderUISpec(a,t)),this._currentPanelSource={kind:"spec",spec:a},this._drawer?.updatePanelTopBar(!0,!1,this._i18n.panelTitleProductDetails)},i18n:this._i18n,pricing:this.config.pricing,productSort:this._productSort,onSortChange:n=>{this._productSort=n},comparisonSelectMode:this._comparisonSelectMode,comparisonSelectedSkus:this._comparisonSelectedSkus,onToggleComparisonSku:n=>{this._toggleComparisonSku(n)},favoritedSkus:this._session?.favoritedSkus??new Set,onFavoriteToggle:(n,a)=>{const i=this._session?.favoritedSkus.has(n)??!1;if(this._toggleFavorite(n,a),!i){ls(n);const o=a.name??n;this._sendAction({title:o,type:"like",payload:{sku:n}},{preservePanel:!0})}},isMobile:this._isMobileViewport};return t}async _toggleFavorite(t,n){if(!this._session)return;const a=this.config.session?.userId??"",i=this.config.accountId;await this._session.toggleFavorite(a,i,t,n),this._drawer?.updateFavoritesBadge(this._session.favoritedSkus.size)}_openFavoritesPanel(){if(this._drawer){if(this._currentPanelSource){const t=this._drawer.getPanelTopBarTitle()??"";this._localPanelHistory.push({source:this._currentPanelSource,title:t}),this._localPanelHistory.length>et._MAX_PANEL_HISTORY&&this._localPanelHistory.shift()}this._drawer.setPanelContent(this._buildFavoritesPageEl()),this._currentPanelSource={kind:"favorites"},this._drawer.updatePanelTopBar(!0,!1,this._i18n.favoritesPageTitle)}}_buildFavoritesPageEl(){const t=this._session?.getFavoriteProducts()??[];if(t.length===0){const o=document.createElement("div");o.className="gengage-chat-favorites-empty";const r=document.createElement("div");r.className="gengage-chat-favorites-empty-icon",r.innerHTML='<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" 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>',o.appendChild(r);const s=document.createElement("p");return s.textContent=this._i18n.emptyFavoritesMessage,o.appendChild(s),o}const n={},a=[];for(const[o,r]of t.entries()){const s=`card_${o}`;a.push(s),n[s]={type:"ProductCard",props:{product:{sku:r.sku,name:r.name,imageUrl:r.imageUrl,price:r.price}}}}n.grid={type:"ProductGrid",children:a};const i={root:"grid",elements:n};return this._renderUISpec(i,this._buildRenderContext())}async _runEventCallbacks(t,n){const a=this._eventCallbacks.get(t);if(!(!a||a.size===0))for(const i of a)try{const o=i(n);if((o instanceof Promise?await o:o)===!1){this._handleCallbackFailure(t,n);return}}catch{this._handleCallbackFailure(t,n);return}}_handleCallbackFailure(t,n){if(t==="gengage-cart-add"){const a=this._i18n.cartAddErrorMessage,i=this._createMessage("assistant",a);this._currentThreadId&&(i.threadId=this._currentThreadId),this._messages.push(i),this._drawer?.addMessage(i)}}_restoreInlineUISpec(t){if(!t.uiSpec||!this._drawer)return;const n=t.uiSpec,a=n.elements[n.root];if(!a)return;const i=a.type;if(i==="ActionButtons"||i==="ComparisonTable"||i==="ProductGrid"&&a.props?.similarsAppend===!0)return;const o=this._buildRenderContext(),r=this._shadow?.querySelector(".gengage-chat-messages");if(!r)return;if(i==="ProductDetailsPanel"){const c=a.props?.product;if(!c)return;const l={root:"root",elements:{root:{type:"ProductSummaryCard",props:{product:c}}}},g=this._renderUISpec(l,o);t.threadId&&(g.dataset.threadId=t.threadId),r.appendChild(g),this._drawer?.refreshPresentationCollapsed();return}const s=this._renderUISpec(n,o);t.threadId&&(s.dataset.threadId=t.threadId),r.appendChild(s),this._drawer?.refreshPresentationCollapsed()}_createMessage(t,n){return this._currentMessageId++,{id:`msg-${this._currentMessageId}`,role:t,content:n,timestamp:Date.now(),status:"done"}}_resolveI18n(t){return{...Mo(t.locale),...t.i18n}}_resolveUISpecRegistry(){const t=xn();return Oa(t,this.config.renderer?.registry)}_renderUISpec(t,n){const a=this._resolveUISpecRegistry(),i=this.config.renderer?.unknownRenderer??St,o=(c,l)=>kn(c,l,a,i),r=this.config.renderer?.renderUISpec;return r?r(t,n,{registry:a,unknownRenderer:i,defaultRender:o}):o(t,n)}};et._MAX_PANEL_HISTORY=10;let bt=et;function fp(){return new bt}fe.CHAT_SCROLL_ELEMENT_ID=it,fe.ChatPresentationState=In,fe.GengageChat=bt,fe.chatCatalog=up,fe.createChatWidget=fp,fe.createDefaultChatUISpecRegistry=xn,fe.defaultChatUnknownUISpecRenderer=St,fe.getChatScrollElement=Lo,fe.invalidateChatScrollCache=gn,fe.renderUISpec=kn,Object.defineProperty(fe,Symbol.toStringTag,{value:"Module"})})(this.Gengage=this.Gengage||{});
97
97
  //# sourceMappingURL=chat.iife.js.map