@gengage/assistant-fe 0.4.1 → 0.4.2
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/types.d.ts +6 -0
- package/dist/{chat-C9l4oBJA.js → chat-Ci4ZA37X.js} +20 -18
- package/dist/chat.iife.js +2 -2
- package/dist/chat.js +1 -1
- package/dist/common/overlay.d.ts +4 -0
- package/dist/{common-CiTC1BDg.js → common-DUMmqYxM.js} +1 -1
- package/dist/common.js +3 -3
- package/dist/index.js +3 -3
- package/dist/{native-webview-FnIiDil0.js → native-webview-v2HYw_9X.js} +35 -35
- package/dist/native.iife.js +2 -2
- package/dist/native.js +1 -1
- package/package.json +1 -1
package/dist/chat.iife.js
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
}
|
|
47
47
|
`,document.head.appendChild(e)}var pt=null;function Oi(){if(pt!==null)return pt;try{pt=localStorage.getItem("gengage:debug")==="1"}catch{pt=!1}return pt}function De(e,t,a){if(!Oi())return;const n=[`[gengage:${e}]`,t];a!==void 0&&n.push(a),console.debug(...n)}var Fi=class{constructor(){this.isVisible=!1,this.isInitialised=!1,this._handlers=new Map,this._cleanups=[],this._ownsRoot=!1,this._destroying=!1}async init(e){if(this.isInitialised){console.warn("[gengage] Widget already initialised. Call update() instead.");return}const t=Ci(e.theme);this.config={...e,theme:t,session:ki(e.session)},this.root=this._resolveMount(e.mountTarget),this._applyTheme(t),Li();const a=Ia("gengage:context:update",n=>this.update(n));this._cleanups.push(a),De("lifecycle",`${this.constructor.name}.init`,{accountId:e.accountId,sku:e.pageContext?.sku});try{await this.onInit(this.config)}catch(n){throw this.destroy(),n}this._destroying||(this.isInitialised=!0,De("lifecycle",`${this.constructor.name} ready`),this.emit("ready"))}update(e){this.isInitialised&&(this.config.pageContext?this.config={...this.config,pageContext:{...this.config.pageContext,...e}}:e.pageType!==void 0&&(this.config={...this.config,pageContext:e}),this.onUpdate(e),this.emit("context-update",this.config.pageContext))}show(){this.isVisible||(this.isVisible=!0,this.root.style.display="",this.onShow(),this.emit("show"))}hide(){this.isVisible&&(this.isVisible=!1,this.root.style.display="none",this.onHide(),this.emit("hide"))}destroy(){this._destroying||(this._destroying=!0,this.emit("destroy"),this._cleanups.forEach(e=>e()),this._cleanups.length=0,this._handlers.clear(),this.onDestroy(),this.config.analyticsClient?.destroy(),this._cleanupRoot(),this.isInitialised=!1)}_cleanupRoot(){this._ownsRoot?this.root.remove():this.root.innerHTML=""}on(e,t){return this._handlers.has(e)||this._handlers.set(e,new Set),this._handlers.get(e).add(t),()=>this._handlers.get(e)?.delete(t)}trackCheckout(e,t){const a=e==="start"?Yr:Jr;this.track(a(this.analyticsContext(),t))}flushMeteringSummary(e){this.track(Gr(this.analyticsContext(),e))}emit(e,...t){this._handlers.get(e)?.forEach(a=>a(...t))}addCleanup(e){this._cleanups.push(e)}track(e){this.config.analyticsClient?.track(e)}analyticsContext(){const e={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??""};return this.config.session?.viewId!==void 0&&(e.view_id=this.config.session.viewId),this.config.session?.userId!==void 0&&(e.user_id=this.config.session.userId),this.config.pageContext?.pageType!==void 0&&(e.page_type=this.config.pageContext.pageType),this.config.pageContext?.sku!==void 0&&(e.sku=this.config.pageContext.sku),this.config.session?.abTestVariant!==void 0&&(e.ab_test_variant=this.config.session.abTestVariant),this.config.session?.abTestExperimentId!==void 0&&(e.ab_test_experiment_id=this.config.session.abTestExperimentId),e}_resolveMount(e){if(e instanceof HTMLElement)return e;if(typeof e=="string"){const a=document.querySelector(e);if(!a)throw new Error(`[gengage] Mount target not found: "${e}"`);return a}const t=document.createElement("div");return t.dataset.gengageWidget=this.constructor.name.toLowerCase(),document.body.insertBefore(t,document.body.firstChild),this._ownsRoot=!0,t}_applyTheme(e){if(e){for(const[t,a]of Object.entries(e))if(a!==void 0){const n=t.startsWith("--")?t:`--gengage-${$i(t)}`;this.root.style.setProperty(n,a)}}}};function $i(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()}function Ra(){const e=Date.now(),t=new Uint8Array(16);crypto.getRandomValues(t),t[0]=e/2**40&255,t[1]=e/2**32&255,t[2]=e/2**24&255,t[3]=e/2**16&255,t[4]=e/2**8&255,t[5]=e&255,t[6]=t[6]&15|112,t[8]=t[8]&63|128;const a=Array.from(t,n=>n.toString(16).padStart(2,"0")).join("");return`${a.slice(0,8)}-${a.slice(8,12)}-${a.slice(12,16)}-${a.slice(16,20)}-${a.slice(20)}`}var Hi=class{constructor(e){this._handlers=new Map,this._destroyed=!1,this._namespace=e.namespace,this._allowedOrigins=e.allowedOrigins??[location.origin],this._onMessage=e.onMessage,this._allowedOrigins.includes("*")&&ji()&&console.warn("[gengage] postMessage bridge using wildcard origin. Set allowedOrigins for production security."),this._messageListener=t=>this._handlePostMessage(t),window.addEventListener("message",this._messageListener)}send(e,t){if(this._destroyed)return;const a={namespace:this._namespace,type:e};t!==void 0&&(a.payload=t),window.dispatchEvent(new CustomEvent("gengage:bridge:message",{detail:a,bubbles:!1}))}on(e,t){this._handlers.has(e)||this._handlers.set(e,new Set);const a=this._handlers.get(e);return a.add(t),()=>{a.delete(t),a.size===0&&this._handlers.delete(e)}}destroy(){this._destroyed||(this._destroyed=!0,window.removeEventListener("message",this._messageListener),this._handlers.clear())}_handlePostMessage(e){if(this._destroyed||!this._isOriginAllowed(e.origin))return;const t=e.data;if(!Ui(t)||t.gengage!==this._namespace)return;const a={type:t.type};t.payload!==void 0&&(a.payload=t.payload),this._onMessage?.(a);const n=this._handlers.get(a.type);if(n)for(const r of n)r(a.payload)}_isOriginAllowed(e){return this._allowedOrigins.includes("*")?!0:this._allowedOrigins.includes(e)}};function Ui(e){if(typeof e!="object"||e===null)return!1;const t=e;return typeof t.gengage=="string"&&typeof t.type=="string"}function ji(){try{return typeof process<"u"&&process.env.NODE_ENV!=="production"}catch{return!1}}function Da(e,t){if(typeof window>"u"||!ye(e))return!1;const a=new CustomEvent("gengage:navigate",{detail:t===void 0?{url:e}:{url:e,newTab:t},cancelable:!0});return window.dispatchEvent(a)?(t?window.open(e,"_blank","noopener,noreferrer"):window.location.href=e,!0):!1}var Zi=console;function qi(e,t,a={}){const n=e.action,r=a.logger??Zi;switch(De("action",`routing action: ${n.kind}`,n),n.kind){case"open_chat":t.openChat?.(n.payload);return;case"navigate":{if(typeof n.url!="string"){Xe(n,t,a,r);return}if(!ye(n.url)){r.warn("[gengage] Blocked navigation to unsafe URL:",n.url);return}const i=typeof n.newTab=="boolean"?n.newTab:void 0;if(t.navigate){t.navigate({url:n.url,...i!==void 0&&{newTab:i}});return}(a.defaultNavigate??Vi)(n.url,i);return}case"save_session":if(typeof n.sessionId!="string"||typeof n.sku!="string"){Xe(n,t,a,r);return}t.saveSession?.({sessionId:n.sessionId,sku:n.sku});return;case"add_to_cart":if(typeof n.sku!="string"||typeof n.quantity!="number"||typeof n.cartCode!="string"){Xe(n,t,a,r);return}t.addToCart?.({sku:n.sku,quantity:n.quantity,cartCode:n.cartCode});return;case"script_call":{if(a.allowScriptCall===!1){Xe(n,t,a,r);return}if(typeof n.name!="string"){Xe(n,t,a,r);return}const i=Gi(n.payload)?n.payload:void 0;t.scriptCall?.({name:n.name,...i!==void 0&&{payload:i}});return}default:Xe(n,t,a,r)}}function Xe(e,t,a,n){const r=a.unknownActionPolicy??"log-and-ignore";if(r==="delegate"){t.unknown?.(e),t.unknown||n.warn("[gengage] Unknown action received without delegate handler",e);return}if(r==="throw")throw new Error(`[gengage] Unknown action kind: ${e.kind}`);n.warn("[gengage] Unknown action ignored",e)}function Vi(e,t){if(!(typeof window>"u")){if(!ye(e)){console.warn("[gengage] Blocked navigation to unsafe URL:",e);return}Da(e,t)}}function Gi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function wt(e){const t=e?.trim();return t||"tr"}function _e(e){const t=globalThis.CSS?.escape;if(typeof t=="function")return t(e);const a=Array.from(e);return a.map((n,r)=>{const i=n.codePointAt(0);return i===void 0?"":i===0?"�":i>=1&&i<=31||i===127||r===0&&i>=48&&i<=57||r===1&&a[0]==="-"&&i>=48&&i<=57?`\\${i.toString(16)} `:r===0&&n==="-"&&a.length===1?"\\-":i>=128||/[A-Za-z0-9_-]/.test(n)?n:`\\${n}`}).join("")}var Wi=["image/jpeg","image/png","image/webp"],Uu=5*1024*1024;function Ki(e){return Wi.includes(e.type)?e.size>5242880?{ok:!1,reason:"too_large"}:{ok:!0}:{ok:!1,reason:"invalid_type"}}function Oa(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function Yi(e){const t=[];let a=0,n=!1,r=!1,i=0;for(let o=0;o<e.length;o++){const s=e[o];if(r){r=!1;continue}if(s==="\\"&&n){r=!0;continue}if(s==='"'){n=!n;continue}n||(s==="{"&&a++,s==="}"&&(a--,a===0&&(t.push(e.slice(i,o+1)),i=o+1)))}return t.length>0?t:[e]}function Fa(e,t){const a=e.trim();if(!a||a.startsWith(":"))return!1;const n=a.startsWith("data: ")?a.slice(6):a;if(n==="[DONE]")return t.onDone?.(),!0;try{const r=JSON.parse(n);return Oa(r)?(De("stream",`event: ${r.type}`,r),t.onEvent(r),r.type==="done"?(t.onDone?.(),!0):!1):!1}catch{const r=Yi(n);if(r.length>1){for(const i of r)try{const o=JSON.parse(i);if(!Oa(o))continue;if(t.onEvent(o),o.type==="done")return t.onDone?.(),!0}catch{}return!1}return!1}}async function Ji(e,t){if(!e.ok){t.onError?.(new Error(`HTTP ${e.status}: ${e.statusText}`));return}if(!e.body){t.onError?.(new Error("Response body is null — streaming not supported"));return}const a=e.body.getReader(),n=new TextDecoder("utf-8");let r="";const i=t.idleTimeoutMs??6e4,o=Symbol("idle-timeout");let s=!1;try{for(;;){const c=a.read();let l;const g=await(i>0?Promise.race([c.then(b=>(clearTimeout(l),b)),new Promise(b=>{l=setTimeout(()=>b(o),i)})]):c);if(g===o){s=!0,await a.cancel();break}const{done:p,value:h}=g;if(p)break;r+=n.decode(h,{stream:!0});const d=r.split(`
|
|
48
48
|
`);r=d.pop()??"";for(const b of d)if(Fa(b,t))return}if(r.trim()&&Fa(r,t))return}catch(c){if(c instanceof DOMException&&c.name==="AbortError")return;t.onError?.(c instanceof Error?c:new Error(String(c)))}finally{s||a.releaseLock()}t.onDone?.()}var $a=3,Xi=(e,t)=>{const a=e.replace(/\s+/g," ").trim().replace(/^[,.;:!?•-]+|[,.;:!?•-]+$/g,"");if(!a)return"";const n=t?.stripLeadingStopWords?a.replace(/^(?:daha|için)\s+/i,"").trim():a;return n?n.split(/\s+/).slice(0,3).join(" ").trim():""},Gt=(e,t)=>e?e.split(/[•,;:/()]|(?:\sve\s)|(?:\sand\s)|(?:\sile\s)|(?:\sfor\s)|(?:\swith\s)/i).map(a=>Xi(a,t)).filter(Boolean):[];function Qi(e){const t=(e.display_keywords??[]).flatMap(r=>Gt(r,{stripLeadingStopWords:!0})),a=t.filter((r,i)=>t.indexOf(r)===i);if(a.length>0)return a.slice(0,$a);const n=[...Gt(e.chosen_attribute,{stripLeadingStopWords:!0}),...Gt(e.short_name)];return n.filter((r,i)=>n.indexOf(r)===i).slice(0,$a)}function eo(e){return Qi(e).join(" • ")}var to=["beauty_consulting","watch_expert"];function Ha(e){return typeof e=="string"&&to.includes(e)}function ao(e){if(typeof e.type!="string")return null;if(no(e))return e;const t=e;switch(t.type){case"outputText":return ro(t);case"suggestedActions":return io(t);case"productList":return oo(t);case"productDetails":return so(t);case"productDetailsSimilars":return co(t);case"comparisonTable":return lo(t);case"context":return uo(t);case"chatStreamEnd":return mo();case"loading":return fo(t);case"panelLoading":return bo(t);case"similarLoading":return vo(t);case"redirect":return yo(t);case"error":return _o(t);case"dummy":return xo(t);case"launcherAction":return wo(t);case"text":return Wt(t);case"productItem":return ko(t);case"text_image":return Ua(t);case"quick_qna":return ja(t);case"reviewHighlights":return Co(t);case"aiProductSuggestions":return Po(t);case"aiProductGroupings":return Ao(t);case"aiSuggestedSearches":return To(t);case"prosAndCons":return So(t);case"getGroundingReview":return Lo(t);case"voice":return No(t);case"visitorDataResponse":return Eo(t);case"productListPreview":return Io();case"groupList":return zo(t);case"formGetInfo":case"formTestDrive":case"formServiceRequest":case"launchFormPage":return Mo(t);case"launcherContent":return Ro(t);case"handoff":return Bo(t);case"uiSpec":return Zo(t);default:return null}}function no(e){const t=e.type;if(typeof t!="string")return!1;switch(t){case"metadata":return typeof e.sessionId=="string"&&typeof e.model=="string";case"text_chunk":return typeof e.content=="string";case"ui_spec":{const a=e.widget;if(a!=="chat"&&a!=="qna"&&a!=="simrel")return!1;const n=Ce(e.spec);return n?typeof n.root=="string"&&Ce(n.elements)!==null:!1}case"action":{const a=Ce(e.action);return a!==null&&typeof a.kind=="string"}case"error":return typeof e.code=="string"&&typeof e.message=="string";case"done":return!0;default:return!1}}function ro(e){const t=K(e.payload.text,e.payload.plain_text)??"",a=K(e.payload.plain_text,e.payload.text)??t;if(e.payload.is_error)return{type:"error",code:"BACKEND_ERROR",message:a||"Backend returned an error"};const n={type:"text_chunk",content:t,final:!0},r=e.payload.product_mentions;Array.isArray(r)&&r.length>0&&(n.productMentions=r.filter(c=>typeof c=="object"&&c!==null&&typeof c.sku=="string"&&typeof c.short_name=="string"));const i=e.payload.sku_to_product_item;i&&typeof i=="object"&&!Array.isArray(i)&&(n.skuToProductItem=i);const o=e.payload.conversation_mode;typeof o=="string"&&o&&(n.conversationMode=o);const s=e.payload.render_hint;return typeof s=="string"&&s&&(n.renderHint=s),e.payload.kvkk===!0&&(n.kvkk=!0),n}function io(e){return Za((e.payload.actions??[]).map(t=>{const a=K(t.title)??"",n=Oe(t.requestDetails,a),r=n?{label:a,action:n}:null;return r?(typeof t.icon=="string"&&(r.icon=t.icon),typeof t.image=="string"&&(r.image=t.image),r):null}).filter(ut),"chat")}function oo(e){const t=(Array.isArray(e.payload.style_variations)?e.payload.style_variations:[]).map(o=>{const s=K(o.style_label);if(!s)return null;const c=K(o.style_mood),l=K(o.image_url??void 0),g=(Array.isArray(o.product_list)?o.product_list:[]).map(h=>{const d=Ce(h);return d?Kt(Ce(d.product_detail)??Ce(d.product)??d):null}).filter(ut),p=Array.isArray(o.recommendation_groups)?o.recommendation_groups.map(h=>({label:K(h.label)??"",reason:K(h.reason)??"",skus:Array.isArray(h.skus)?h.skus.filter(d=>typeof d=="string"&&d.trim().length>0):[]})):[];return{style_label:s,style_mood:c??"",...l?{image_url:l}:{},...typeof o.status=="string"?{status:o.status}:{},product_list:g,recommendation_groups:p}}).filter(ut),a=e.payload.product_list??[],n=Ha(e.payload.source)&&t.length>0?t[0].product_list:null,r=n?Do(n,"chat"):qa(a,"chat");r.panelHint="panel";const i=r.spec.elements[r.spec.root];if(i){const o={};typeof e.payload.offset=="number"&&(o.offset=e.payload.offset),typeof e.payload.end_of_list=="boolean"&&(o.endOfList=e.payload.end_of_list),typeof e.payload.title=="string"&&(o.panelTitle=e.payload.title),typeof e.payload.source=="string"&&(o.source=e.payload.source),t.length>0&&(o.styleVariations=t),e.payload.replace_panel===!0&&(o.replacePanel=!0),(e.payload.ranking_state==="pending"||e.payload.ranking_state==="final")&&(o.rankingState=e.payload.ranking_state);const s=e.payload.sequence_id??e.payload.search_id;typeof s=="string"&&s.length>0&&(o.sequenceId=s),Object.keys(o).length>0&&(i.props={...i.props,...o})}return r}function so(e){const t=e.payload.productDetails;if(!t)return Fo("chat");const a=Qe(t);return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:{...t,...a}}}}},panelHint:"panel"}}function co(e){const t=qa(e.payload.similarProducts??[],"chat"),a=t.spec.elements[t.spec.root];return a&&(a.props={...a.props,similarsAppend:!0}),{...t,panelHint:"panel"}}function lo(e){const t=e.payload.multiple_product_details??[],a=e.payload,n={key_differences:a.key_differences,recommended_choice:a.recommended_choice,recommended_choice_sku:a.recommended_choice_sku,special_considerations:a.special_considerations,criteria_view:a.criteria_view,criteria_view_short:a.criteria_view_short,compared_field_names:a.compared_field_names,winner_product:a.winner_product,winner_hits:a.winner_hits,...e.payload.product_comparison_framework??{}},r=e.payload.table,i=e.payload.features_list,o=[];for(const v of t){const m=Qe(v);o.push(m)}const s=go(r,o,n,i);let c;n?.recommended_choice_sku?c=n.recommended_choice_sku:n?.winner_product&&n.winner_product.length>0&&(c=n.winner_product[0]?.product_detail?.sku??n.winner_product[0]?.sku);const l=c?o.find(v=>v.sku===c)??o[0]:o[0],g=[];if(Array.isArray(n?.key_differences))for(const v of n.key_differences)typeof v=="string"&&g.push(v);const p=Uo(n?.special_considerations),h=n?.recommended_choice,d=n?.winner_hits,b={};for(const v of o){const m=v.sku;m&&(b[m]={title:v.name??m,type:"launchSingleProduct",payload:{sku:m}})}const u={products:o,attributes:s,highlights:g,productActions:b};return l&&(u.recommended=l),p.length>0&&(u.specialCases=p),h&&(u.recommendedText=h),d&&(u.winnerHits=d),typeof n?.key_differences=="string"&&(u.keyDifferencesHtml=n.key_differences),n?.special_considerations&&(u.specialConsiderations=n.special_considerations),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ComparisonTable",props:u}}},panelHint:"panel"}}function go(e,t,a,n){if(!e)return[];const r=Object.entries(e);if(r.length===0)return[];const i=r[0]?.[1];if(Array.isArray(i)){const p=a.criteria_view??a.criteria_view_short??{},h=a.compared_field_names??Object.keys(e),d=[];for(const b of h){const u=e[b];if(!u||!Array.isArray(u))continue;const v=p[b]??b;d.push({label:v,values:u.map(m=>typeof m=="string"?m:String(m??""))})}return d}const o=e,s=t.map(p=>String(p.sku??"")).filter(p=>p.length>0),c=a.criteria_view??a.criteria_view_short??{},l=(n&&n.length>0?n:a.compared_field_names&&a.compared_field_names.length>0?a.compared_field_names:po(o)).filter(p=>p!=="name"&&p!=="name_short"&&!p.endsWith("_short")),g=[];for(const p of l){const h=s.map(b=>{const u=o[b];if(!u||typeof u!="object")return"";const v=u[`${p}_short`],m=u[p];return ho(v??m)});if(h.every(b=>b.length===0))continue;const d=c[p]??p;g.push({label:d,values:h})}return g}function po(e){const t=[],a=new Set;for(const n of Object.values(e))if(!(!n||typeof n!="object"))for(const r of Object.keys(n))a.has(r)||(a.add(r),t.push(r));return t}function ho(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function uo(e){return{type:"metadata",sessionId:"",model:"",meta:{panel:e.payload.panel,messages:e.payload.messages,message_id:e.payload.message_id}}}function mo(){return{type:"done"}}function fo(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 bo(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,panelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function vo(e){return{type:"metadata",sessionId:"",model:"",meta:{loading:!0,similarPanelLoading:!0,panelPendingType:e.payload?.pending_type,loadingText:e.payload?.text}}}function yo(e){const t=K(e.payload.url);return t?{type:"action",action:{kind:"navigate",url:t,newTab:e.payload.new_tab===!0}}:{type:"metadata",sessionId:"",model:"",meta:{redirect:e.payload,redirectTarget:K(e.payload.to)}}}function _o(e){return{type:"error",code:"BACKEND_ERROR",message:K(e.payload?.text,e.payload?.message,e.payload?.error)??"Backend returned an error"}}function xo(e){return{type:"metadata",sessionId:"",model:"",meta:{noop:!0}}}function wo(e){const t=e.payload??{};if(Array.isArray(t.action_list)){const r={action_list:t.action_list},i=typeof t.type=="string"?t.type:void 0,o=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(r.type=i),o!==void 0&&(r.theme=o),ja({type:"quick_qna",payload:r})}const a=Ce(t.action);if(a){const r={action:a},i=typeof t.text=="string"?t.text:void 0,o=typeof t.image_url=="string"?t.image_url:void 0,s=typeof t.theme=="string"?t.theme:void 0;return i!==void 0&&(r.text=i),o!==void 0&&(r.image_url=o),s!==void 0&&(r.theme=s),Ua({type:"text_image",payload:r})}const n=typeof t.text=="string"?t.text:"";if(n){const r={text:n},i=typeof t.type=="string"?t.type:void 0,o=typeof t.theme=="string"?t.theme:void 0,s=Ce(t.payload)??void 0;return i!==void 0&&(r.type=i),s!==void 0&&(r.payload=s),o!==void 0&&(r.theme=o),Wt({type:"text",payload:r})}return{type:"metadata",sessionId:"",model:"",meta:{launcherAction:t}}}function Wt(e){const t={text:K(e.payload.text)??""};return typeof e.payload.theme=="string"&&(t.theme=e.payload.theme),e.payload.payload!==void 0&&(t.payload=e.payload.payload),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"QuestionHeading",props:t}}}}}function ko(e){return Oo(e.payload,"qna")}function Ua(e){const t=K(e.payload.text)??"",a=Oe(e.payload.action,t);if(a){const r={label:t||a.title,action:a};return typeof e.payload.image_url=="string"&&(r.image=e.payload.image_url),typeof e.payload.theme=="string"&&(r.theme=e.payload.theme),{type:"ui_spec",widget:"qna",spec:{root:"root",elements:{root:{type:"ActionButton",props:r}}}}}const n={text:t};return typeof e.payload.theme=="string"&&(n.theme=e.payload.theme),Wt({type:"text",payload:n})}function ja(e){return Za((e.payload.action_list??[]).map(t=>{const a=K(t.title)??"",n=Oe(t.requestDetails,a),r=n?{label:a,action:n}:null;return r?(typeof t.icon=="string"&&(r.icon=t.icon),typeof t.image=="string"&&(r.image=t.image),r):null}).filter(ut),"qna")}function Co(e){const t={reviews:(e.payload.reviews??[]).map(a=>{const n={};return typeof a.review_class=="string"&&(n.review_class=a.review_class),typeof a.review_text=="string"&&(n.review_text=a.review_text),(typeof a.review_rating=="string"||typeof a.review_rating=="number")&&(n.review_rating=a.review_rating),typeof a.review_tag=="string"&&(n.review_tag=a.review_tag),n})};return typeof e.payload.sku=="string"&&(t.sku=e.payload.sku),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"ReviewHighlights",props:t}}}}}function So(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 Eo(e){return{type:"metadata",sessionId:"",model:"",meta:{visitorDataResponse:e.payload}}}function Po(e){const t=e.payload.product_suggestions??[],a=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r)continue;const i=$o(r);if(!i)continue;const o={product:i},s=Oe(r.requestDetails,i.name);s&&(o.action=s),typeof r.role=="string"&&(o.role=r.role),typeof r.reason=="string"&&(o.reason=r.reason),typeof r.review_highlight=="string"&&(o.reviewHighlight=r.review_highlight),Array.isArray(r.labels)&&(o.labels=r.labels),typeof r.expert_quality_score=="number"&&(o.expertQualityScore=r.expert_quality_score),a.push(o)}return a.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductSuggestions:e.payload.product_suggestions??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AITopPicks",props:{suggestions:a}}}}}}function Ao(e){const t=e.payload.product_groupings??[],a=[],n=[];for(let r=0;r<t.length;r++){const i=t[r];if(!i)continue;const o=K(i.name)??"",s=K(i.sku,i.repr_sku),c=K(i.image,i.repr_image),l=s!==void 0?{type:"findSimilar",payload:{sku:s}}:void 0,g=Oe(i.requestDetails??l,o),p=(Array.isArray(i.group_products)?i.group_products:[]).map(b=>{const u=Ce(b);return u?Kt(u):null}).filter(ut),h=c??K(...p.map(b=>b.imageUrl));if(o&&p.length>0){const b={groupName:o,products:p};h&&(b.image=h),a.push(b)}if(!g)continue;const d={name:o,action:g};if(Array.isArray(i.labels)){const b=i.labels.filter(u=>typeof u=="string");b.length>0&&(d.labels=b)}c!==void 0&&(d.image=c),n.push(d)}return a.length>0?{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:a}}}},panelHint:"panel"}:n.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiProductGroupings:e.payload.product_groupings??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AIGroupingCards",props:{entries:n}}}}}}function To(e){const t=e.payload.suggested_searches??[],a=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r)continue;const i=K(r.short_name,r.chosen_attribute,r.detailed_user_message)??`Search ${n+1}`,o={},s=K(r.detailed_user_message);s&&(o.text=s);const c=Ce(Ce(r.requestDetails)?.payload),l=c?.group_skus;r.group_skus&&Array.isArray(r.group_skus)?o.group_skus=r.group_skus:Array.isArray(l)&&(o.group_skus=l.filter(m=>typeof m=="string"));const g=K(r.sku,r.representative_product_sku,c?.sku);g&&(o.sku=g),o.is_suggested_text=1;const p={type:"inputText",payload:o},h=Oe(r.requestDetails,i),d=h?.type==="findSimilar"&&typeof o.text=="string"?Oe(p,i):h??Oe(p,i);if(!d)continue;const b={shortName:i,action:d},u=K(r.detailed_user_message);u&&u!==i&&(b.detailedMessage=u);const v=eo(r);v&&v!==i&&v!==(u??"")&&(b.whyDifferent=v),typeof r.image=="string"&&(b.image=r.image),a.push(b)}return a.length===0?{type:"metadata",sessionId:"",model:"",meta:{aiSuggestedSearches:e.payload.suggested_searches??[]}}:{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"AISuggestedSearchCards",props:{entries:a}}}}}}function Lo(e){const t=e.payload,a=Oe(t.requestDetails??t.request_details,K(t.review_count,t.reviewCount,t.text,t.title)??"Show product reviews");if(!a)return{type:"metadata",sessionId:"",model:"",meta:{groundingReview:t}};const n={action:a};return t.title&&(n.title=t.title),t.text&&(n.text=t.text),t.review_count?n.reviewCount=t.review_count:typeof t.reviewCount=="string"&&t.reviewCount.trim()&&(n.reviewCount=t.reviewCount),{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"GroundingReviewCard",props:n}}}}}function Io(){return{type:"metadata",sessionId:"",model:"",meta:{analyzeAnimation:!0}}}function No(e){return{type:"metadata",sessionId:"",model:"",meta:{voice:e.payload}}}function zo(e){const t=e.payload.group_list??[],a=[];for(const r of t){const i=r.group_name??"",o=(r.product_list??[]).map(Qe);a.push({groupName:i,products:o})}const n=[];for(const r of e.payload.filter_tags??[]){const i=r.title??"";if(!i)continue;const o=Oe(r.requestDetails,i),s={title:i};o&&(s.action=o),n.push(s)}return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:"CategoriesContainer",props:{groups:a,filterTags:n}}}},panelHint:"panel"}}function Mo(e){return{type:"metadata",sessionId:"",model:"",meta:{formType:e.type,formPayload:e.payload??{}}}}function Bo(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 Ro(e){return{type:"metadata",sessionId:"",model:"",meta:{launcherContent:e.payload??{}}}}function Za(e,t){const a={},n=[];for(let r=0;r<e.length;r++){const i=e[r];if(!i)continue;const o=`action-${r}`;n.push(o);const s={label:i.label,action:i.action};i.icon!==void 0&&(s.icon=i.icon),i.image!==void 0&&(s.image=i.image),i.description!==void 0&&(s.description=i.description),a[o]={type:"ActionButton",props:s}}return a.root={type:"ActionButtons",props:{buttons:e.map(r=>{const i={label:r.label,action:r.action};return r.image!==void 0&&(i.image=r.image),r.description!==void 0&&(i.description=r.description),r.icon!==void 0&&(i.icon=r.icon),i})},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:a}}}function qa(e,t){const a={},n=[];for(let r=0;r<e.length;r++){const i=e[r];if(!i)continue;const o=Qe(i),s=`product-${r}`;n.push(s);const c={product:o,index:r};o.sku&&(c.action={title:o.name,type:"launchSingleProduct",payload:{sku:o.sku}}),a[s]={type:"ProductCard",props:c}}return a.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:a}}}function Do(e,t){const a={},n=[];for(let r=0;r<e.length;r++){const i=e[r];if(!i)continue;const o=`product-${r}`;n.push(o);const s={product:i,index:r},c=i.sku;c&&(s.action={title:i.name??"",type:"launchSingleProduct",payload:{sku:c}}),a[o]={type:"ProductCard",props:s}}return a.root={type:"ProductGrid",props:{layout:"grid"},children:n},{type:"ui_spec",widget:t,spec:{root:"root",elements:a}}}function Oo(e,t){return{type:"ui_spec",widget:t,spec:{root:"root",elements:{root:{type:"ProductCard",props:{product:Qe(e),index:0}}}}}}function Fo(e){return{type:"ui_spec",widget:e,spec:{root:"root",elements:{root:{type:"ActionButtons",props:{buttons:[]},children:[]}}}}}function $o(e){const t=K(e.sku),a=K(e.short_name),n={...Ce(e.product_item)??e},r=K(e.discount_reason,e.discountReason);return r&&!K(n.discount_reason,n.discountReason)&&(n.discount_reason=r),Kt(n,t,a)}function Kt(e,t,a){const n=K(e.sku,t),r=K(e.name,a);if(!n||!r)return null;const i={sku:n,name:r},o=K(e.brand);o&&(i.brand=o);const s=K(e.url);s&&(i.url=s);const c=Ho(e.images);if(c.length>0)i.images=c;else{const u=K(e.image,e.image_url,e.imageUrl);u&&(i.images=[u])}const l=ht(e.price_discounted);l!==void 0&&(i.price_discounted=l);const g=ht(e.price);g!==void 0&&(i.price=g);const p=ht(e.rating);p!==void 0&&(i.rating=p);const h=ht(e.review_count)??ht(e.reviewCount);h!==void 0&&(i.review_count=h);const d=K(e.cart_code,e.cartCode);d&&(i.cart_code=d),typeof e.in_stock=="boolean"&&(i.in_stock=e.in_stock),typeof e.inStock=="boolean"&&(i.in_stock=e.inStock);const b=K(e.discount_reason,e.discountReason);return b&&(i.discount_reason=b),Qe(i)}function Oe(e,t){const a=Ce(e);if(!a)return null;const n=a.type;if(typeof n!="string"||n.length===0)return null;const r={title:t||n,type:n};return a.payload!==void 0&&(r.payload=a.payload),r}function Ce(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function K(...e){for(const t of e)if(typeof t=="string"){const a=t.trim();if(a.length>0)return a}}function Ho(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function Uo(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 ht(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"){let t;e.includes(".")&&e.includes(",")?t=e.replace(/\./g,"").replace(",","."):t=e.replace(",",".");const a=Number(t);if(Number.isFinite(a))return a}}function ut(e){return e!=null}var jo=new Set(["sku","name","brand","images","price","price_discounted","price_discount_rate","price_currency","discount_reason","url","rating","review_count","cart_code","in_stock","description","description_html","features","specifications","facet_tags","short_name","category_ids","category_names","variants","facet_hits","promotions"]);function Qe(e){const t=e.price_discounted!=null&&e.price_discounted>0,a=t?e.price_discounted:e.price,n=t&&e.price!=null?e.price:void 0;let r;n!=null&&a!=null&&n>0?r=Math.round((n-a)/n*100):e.price_discount_rate!=null&&e.price_discount_rate>0&&(r=e.price_discount_rate);const i=K(e.brand),o=K(e.name)??e.sku,s=i&&!o.toLowerCase().startsWith(i.toLowerCase())?`${i} ${o}`:o,c={sku:e.sku,name:s,url:K(e.url)??""},l=e.images?.[0];l&&(c.imageUrl=l),e.images&&e.images.length>1&&(c.images=e.images),a!=null&&a>0&&(c.price=String(a)),n!=null&&n>0&&(c.originalPrice=String(n)),r!==void 0&&(c.discountPercent=r),i!==void 0&&(c.brand=i),e.rating!==void 0&&(c.rating=e.rating),e.review_count!==void 0&&(c.reviewCount=e.review_count),e.cart_code!==void 0&&(c.cartCode=e.cart_code),e.in_stock!==void 0&&(c.inStock=e.in_stock),e.variants&&e.variants.length>0&&(c.variants=e.variants),e.discount_reason!==void 0&&(c.discountReason=e.discount_reason),e.promotions&&e.promotions.length>0&&(c.promotions=e.promotions),e.description!==void 0&&(c.description=e.description),e.description_html!==void 0&&(c.descriptionHtml=e.description_html),e.features&&e.features.length>0&&(c.features=e.features),e.specifications!==void 0&&(c.specifications=e.specifications),e.facet_hits&&(c.facetHits=e.facet_hits),e.short_name!==void 0&&(c.shortName=e.short_name);const g=e,p={};let h=!1;for(const d of Object.keys(g))jo.has(d)||(p[d]=g[d],h=!0);return h&&(c.extras=p),c}function Zo(e){const t=e.payload.type,{type:a,...n}=e.payload;return{type:"ui_spec",widget:"chat",spec:{root:"root",elements:{root:{type:t,props:n}}}}}var qo={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 Go(e,t){return`${Vo(t?.middlewareUrl)}/chat${qo[e]}`}function Wo(e,t){const a=e.type,n=e.payload!=null&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:{},r=i=>{const o={...n};for(const[s,c]of Object.entries(i))s in o||(o[s]=c);return o};switch(a){case"inputText":{const i={is_launcher:0};return t.pageContext?.extra&&(i.page_details=t.pageContext.extra),"is_suggested_text"in n||(i.is_suggested_text=0),{...e,payload:r(i)}}case"findSimilar":{const i={is_launcher:0};return e.title&&(i.text=e.title,i.input=e.title),{...e,payload:r(i)}}case"getComparisonTable":{const i=e.payload;if(i&&typeof i=="object"&&!Array.isArray(i)&&"gengage_analytics_source"in i){const o={...i};return delete o.gengage_analytics_source,{...e,payload:o}}return e}case"launchProductList":return e;case"launchHomepage":return e;case"addToCart":{const i={};return"error_message"in n||(i.error_message=""),{...e,payload:r(i)}}case"reviewSummary":{const i={};return t.pageContext?.sku&&!("sku"in n)&&(i.sku=t.pageContext.sku),Object.keys(i).length===0?e:{...e,payload:r(i)}}default:return e}}var Ko={user_message:"inputText"};function Yo(e){const{action:t,type:a,payload:n,...r}=e,i=a??t?.type??"inputText",o=n??t?.payload,s=Ko[i]??i,c={...r,type:s};return o!==void 0&&(c.payload=typeof o=="string"?{text:o}:o),JSON.stringify(c)}function Jo(e,t,a){const n=Go("process_action",a),r=new AbortController;return(async()=>{try{const o=Yo(e),s=a.attachment!==void 0;let c;if(s){const h=new FormData;h.append("request",o),a.attachment!==void 0&&h.append("attachment",a.attachment),c={method:"POST",body:h,signal:r.signal}}else c={method:"POST",headers:{"Content-Type":"application/json"},body:o,signal:r.signal};const l=await fetch(n,c);if(!l.ok){let h=l.statusText;try{const d=await l.json(),b=d.detail??d.message??d.error;typeof b=="string"&&(h=b)}catch{}t.onError(new Error(`HTTP ${l.status}: ${h}`));return}let g=!1;const p=()=>{g||(g=!0,t.onDone())};await Ji(l,{onEvent:h=>{const d=ao(h);if(d&&!(g&&d.type!=="error"))switch(d.type){case"text_chunk":t.onTextChunk(d.content,d.final===!0,{productMentions:d.productMentions,skuToProductItem:d.skuToProductItem,conversationMode:d.conversationMode,renderHint:d.renderHint,kvkk:d.kvkk});break;case"ui_spec":t.onUISpec(d.spec,d.widget,d.panelHint,d.clearPanel===!0);break;case"action":t.onAction(d);break;case"metadata":t.onMetadata(d);break;case"error":t.onError(new Error(d.message));break;case"done":p();break}},onError:t.onError,signal:r.signal}),p()}catch(o){if(o instanceof DOMException&&o.name==="AbortError")return;t.onError(o instanceof Error?o:new Error(String(o)))}})(),r}var Xo=["chat_debug","presentation_debug"],Qo=["gengage_chat_debug","gengage_presentation_debug"];function es(){if(typeof window>"u")return!1;const e=new URLSearchParams(window.location.search);if(Xo.some(t=>e.get(t)==="1"))return!0;try{return Qo.some(t=>window.localStorage.getItem(t)==="1")}catch{return!1}}function ts(e,t,a){if(!es())return;const n=(window.__gengageChatPresentationDebugSeq??0)+1;window.__gengageChatPresentationDebugSeq=n;const r={seq:n,time:new Date().toISOString(),scope:e,message:t,payload:a};window.__gengageChatPresentationDebugLog||(window.__gengageChatPresentationDebugLog=[]),window.__gengageChatPresentationDebugLog.push(r),window.__gengageChatPresentationDebugLog.length>400&&window.__gengageChatPresentationDebugLog.shift();const i=`[gengage-chat-debug #${n}][${e}] ${t}`;a===void 0?console.debug(i):console.debug(i,a)}var kt="gengage-chat-scroll",et=null;function Va(e){et=e}function as(){if(et&&et.isConnected)return et;et=null;const e=document.getElementById(kt);return e||(ts("chat-scroll","failed to resolve scroll container (not registered)",{id:kt}),null)}function Ga(){et=null}var tt={headerTitle:"Ürün Uzmanı",inputPlaceholder:"Ürün ara, soru sor",sendButton:"Gönder",closeButton:"Kapat",openButton:"Sohbeti aç",newChatButton:"Yeni sohbet",poweredBy:"Gengage ile",errorMessage:"Bir hata oluştu. Lütfen tekrar deneyin.",retryButton:"Tekrar Dene",loadingMessage:"İsteğinizi inceliyorum...",loadingSequenceGeneric:["İsteğinizi inceliyorum...","Ürün ve yorumlara bakıyorum...","Detayları inceliyorum..."],loadingSequencePanel:["En ilgili detayları inceliyorum","En güçlü sinyalleri kontrol ediyorum","Bu görünümü sizin için hazırlıyorum"],loadingSequenceComparison:["Ürün farklarını inceliyorum","En güçlü farkları ve ödünleşimleri kontrol ediyorum","Karşılaştırmayı sizin için hazırlıyorum"],productCtaLabel:"Satın Al",viewOnSiteLabel:"Sitede Gör",attachImageButton:"Resim ekle",attachMenuSelectPhoto:"Fotoğraf Seç",attachMenuPaste:"Yapıştır",clipboardNoImageMessage:"Panoda görsel bulunamadı. Önce bir görsel kopyalayın veya dosya seçin.",removeAttachmentButton:"Resmi kaldır",invalidFileType:"Sadece JPEG, PNG ve WebP dosyaları destekleniyor.",fileTooLarge:"Dosya boyutu 5 MB'dan küçük olmalıdır.",aiTopPicksTitle:"Sizin İçin En İyiler",roleWinner:"Size Özel Seçimim",roleBestValue:"En Uygun Fiyatlı",roleBestAlternative:"En İyi Alternatif",viewDetails:"Detayları Gör",groundingReviewCta:"Yorumları Oku",groundingReviewSubtitle:"{count} yorum mevcut",variantsLabel:"Varyantlar",sortRelated:"Önerilen",sortPriceAsc:"Fiyat düşükten yükseğe",sortPriceDesc:"Fiyat yüksekten düşüğe",sortToolbarAriaLabel:"Ürünleri sırala",compareSelected:"Karşılaştır",compareMinHint:"En az 2 ürün seçin",compareMaxHint:"En fazla 5 ürün seçebilirsiniz",comparisonSelectLabel:"Karşılaştırmak için seç",comparisonSelectedLabel:"Seçildi",comparisonSelectCardHint:"Karşılaştırmaya eklemek veya çıkarmak için kartın herhangi bir yerine dokunun.",comparisonPreparingLabel:"Karşılaştırma tablosu hazırlanıyor…",panelTitleProductDetails:"Ürün Detayı",panelTitleSimilarProducts:"Benzer Ürünler",panelTitleComparisonResults:"Karşılaştırma Sonuçları",panelTitleCategories:"Kategoriler",panelTitleSearchResults:"Arama Sonuçları",inStockLabel:"Stokta",outOfStockLabel:"Tükendi",findSimilarLabel:"Benzerlerini Bul",galleryPrevAriaLabel:"Önceki görsel",galleryNextAriaLabel:"Sonraki görsel",beautyStylesPreparedTitle:"Sizin için {count} farklı stil hazırladım",watchStylesPreparedTitle:"Sizin için {count} farklı stil yönü hazırladım",consultingOtherCompatibleProductsLabel:"Diğer Uyumlu Ürünler",consultingFallbackGroupLabel:"Öneri",consultingFallbackStyleLabel:"Stil {index}",consultingStyleLoadingDescription:"Bu stil için ürünleri toplamaya devam ediyorum. Panel kısa süre içinde yenilenir.",consultingStyleUnavailableDescription:"Bu stil için şu anda yeterli ürün eşleşmesi çıkaramadım. Diğer stilleri inceleyebilirsiniz.",consultingStyleLoadingBadge:"Yükleniyor",consultingStyleUnavailableBadge:"Hazır değil",choicePrompterHeading:"Kararsız mı kaldın?",choicePrompterSuggestion:"Ürünleri seçip karşılaştırabilirsin",choicePrompterCta:"Seç ve Karşılaştır",viewMoreLabel:"Daha Fazla Göster",similarProductsLabel:"Benzer Ürünler",addToCartButton:"Sepete Ekle",addedToCartToast:"Sepete eklendi",shareButton:"Paylaş",productInfoTab:"Ürün Bilgileri",specificationsTab:"Teknik Özellikler",recommendedChoiceLabel:"Önerilen Seçim",highlightsLabel:"Öne Çıkan Özellikler",keyDifferencesLabel:"Temel Farklar",specialCasesLabel:"Özel Durumlar İçin",emptyReviewsMessage:"Yorum özeti bulunamadı.",closeAriaLabel:"Kapat",startChatLabel:"Sohbete Başla",voiceButton:"Sesli giriş",voiceListening:"Dinleniyor...",voiceNotSupported:"Sesli giriş bu tarayıcıda desteklenmiyor.",voicePermissionDenied:"Mikrofon erişimi reddedildi.",voiceError:"Sesli giriş hatası.",handoffHeading:"Destek temsilcisine aktarılıyor",productNotFoundMessage:"Bu ürün bilgisi şu an kullanılamıyor. Başka bir konuda yardımcı olabilirim.",stopGenerating:"Yanıtı Durdur",offlineMessage:"Çevrimdışısınız — bağlantı kurulduğunda mesajlar gönderilecek.",cartAriaLabel:"Sepetim",favoritesAriaLabel:"Favorilerim",showPanelAriaLabel:"Sonuçları Göster",addToFavoritesLabel:"Favorilere ekle",customerReviewsTitle:"Müşteri Yorumları",togglePanelAriaLabel:"Paneli aç/kapat",chatMessagesAriaLabel:"Sohbet mesajları",suggestionsAriaLabel:"Öneriler",moreSuggestionsAriaLabel:"Daha fazla öneri",rollbackAriaLabel:"Bu mesaja geri dön",backAriaLabel:"Geri",forwardAriaLabel:"İleri",closePanelAriaLabel:"Paneli kapat",dismissAriaLabel:"Kapat",cartAddErrorMessage:"Üzgünüm sepete ekleyemedim, bir sorunla karşılaştım.",favoriteToggleErrorMessage:"Favoriler güncellenemedi. Lütfen tekrar deneyin.",reviewFilterPositive:"Olumlu",reviewFilterNegative:"Olumsuz",decreaseLabel:"Azalt",increaseLabel:"Artır",reviewCustomersMentionSingular:"1 müşteri bahsediyor",reviewCustomersMentionPlural:"müşteri bahsediyor",reviewSubjectsHeading:"İncelemek için seçin",tryAgainButton:"Tekrar dene",askSomethingElseButton:"Başka bir şey sor",accountInactiveMessage:"Bu hesap şu an aktif değil. Lütfen daha sonra tekrar deneyin.",favoritesPageTitle:"Favorilerim",emptyFavoritesMessage:"Henüz favori ürün yok. Bir ürünü kalp ikonuna tıklayarak favorilere ekleyebilirsin.",showFormerMessagesButton:"↑ Önceki mesajları göster",aiAnalysisAnalyzingLabel:"Ürünler analiz ediliyor...",aiBrowseCategoriesTitle:"Kategorilere Göz At",photoAnalysisBadge:"Cilt Analizi",photoAnalysisStrengthsLabel:"Öne Çıkanlar",photoAnalysisFocusLabel:"Odak Noktaları",photoAnalysisCelebStyleLabel:"Celeb Vibe Eşleşmesi",beautyPhotoStepTitle:"Selfie ile kişiselleştir",beautyPhotoStepDescription:"İstersen net bir profil fotoğrafı yükle, sana özel önerilerde bulunayım.",beautyPhotoStepUpload:"Fotoğraf Yükle",beautyPhotoStepProcessing:"Fotoğraf işleniyor...",beautyPhotoStepSkip:"Geç",beautyPhotoStepSkipMessage:"Fotoğraf adımını geçiyorum"},ns={headerTitle:"Product Expert",inputPlaceholder:"Search products, ask questions",sendButton:"Send",closeButton:"Close",openButton:"Open chat",newChatButton:"New chat",poweredBy:"Powered by Gengage",errorMessage:"Something went wrong. Please try again.",retryButton:"Retry",loadingMessage:"Reviewing your request...",loadingSequenceGeneric:["Reviewing your request...","Looking through products and reviews...","Reviewing the details..."],loadingSequencePanel:["Reviewing the most relevant details","Checking the strongest signals","Preparing this view for you"],loadingSequenceComparison:["Reviewing the product differences","Checking the strongest tradeoffs","Preparing your comparison"],productCtaLabel:"Buy",viewOnSiteLabel:"View on Site",attachImageButton:"Attach image",attachMenuSelectPhoto:"Choose photo",attachMenuPaste:"Paste",clipboardNoImageMessage:"No image found in clipboard. Copy an image first or choose a file.",removeAttachmentButton:"Remove image",invalidFileType:"Only JPEG, PNG and WebP files are supported.",fileTooLarge:"File must be smaller than 5 MB.",aiTopPicksTitle:"Top Picks for You",roleWinner:"Top Pick",roleBestValue:"Best Value",roleBestAlternative:"Best Alternative",viewDetails:"View Details",groundingReviewCta:"Read Reviews",groundingReviewSubtitle:"{count} reviews available",variantsLabel:"Variants",sortRelated:"Recommended",sortPriceAsc:"Price low to high",sortPriceDesc:"Price high to low",sortToolbarAriaLabel:"Sort products",compareSelected:"Compare",compareMinHint:"Select at least 2 products",compareMaxHint:"You can select up to 5 products",comparisonSelectLabel:"Select to compare",comparisonSelectedLabel:"Selected",comparisonSelectCardHint:"Tap anywhere on the card to add or remove it from comparison.",comparisonPreparingLabel:"Preparing your comparison…",panelTitleProductDetails:"Product Details",panelTitleSimilarProducts:"Similar Products",panelTitleComparisonResults:"Comparison Results",panelTitleCategories:"Categories",panelTitleSearchResults:"Search Results",inStockLabel:"In Stock",outOfStockLabel:"Out of Stock",findSimilarLabel:"Find Similar",galleryPrevAriaLabel:"Previous image",galleryNextAriaLabel:"Next image",beautyStylesPreparedTitle:"Prepared {count} beauty styles for you",watchStylesPreparedTitle:"Prepared {count} style directions for you",consultingOtherCompatibleProductsLabel:"Other compatible products",consultingFallbackGroupLabel:"Recommendation",consultingFallbackStyleLabel:"Style {index}",consultingStyleLoadingDescription:"I am still collecting products for this style. The panel will refresh shortly.",consultingStyleUnavailableDescription:"I could not find enough product matches for this style yet. You can review the other styles.",consultingStyleLoadingBadge:"Loading",consultingStyleUnavailableBadge:"Not ready",choicePrompterHeading:"Can't decide?",choicePrompterSuggestion:"Select products to compare them",choicePrompterCta:"Select & Compare",viewMoreLabel:"Show More",similarProductsLabel:"Similar Products",addToCartButton:"Add to Cart",addedToCartToast:"Added to cart",shareButton:"Share",productInfoTab:"Product Info",specificationsTab:"Specifications",recommendedChoiceLabel:"Recommended Choice",highlightsLabel:"Key Highlights",keyDifferencesLabel:"Key Differences",specialCasesLabel:"For Special Cases",emptyReviewsMessage:"No review summary found.",closeAriaLabel:"Close",startChatLabel:"Start Chat",voiceButton:"Voice input",voiceListening:"Listening...",voiceNotSupported:"Voice input is not supported in this browser.",voicePermissionDenied:"Microphone access denied.",voiceError:"Voice input error.",handoffHeading:"Transferring to a support agent",productNotFoundMessage:"Product information is currently unavailable. I can help with something else.",stopGenerating:"Stop generating",offlineMessage:"You're offline — messages will send when you reconnect.",cartAriaLabel:"My cart",favoritesAriaLabel:"My favorites",showPanelAriaLabel:"Show Results",addToFavoritesLabel:"Add to favorites",customerReviewsTitle:"Customer Reviews",togglePanelAriaLabel:"Toggle panel",chatMessagesAriaLabel:"Chat messages",suggestionsAriaLabel:"Suggestions",moreSuggestionsAriaLabel:"More suggestions",rollbackAriaLabel:"Rollback to this message",backAriaLabel:"Back",forwardAriaLabel:"Forward",closePanelAriaLabel:"Close panel",dismissAriaLabel:"Dismiss",cartAddErrorMessage:"Sorry, I couldn't add that to your cart. Something went wrong.",favoriteToggleErrorMessage:"We couldn't update favorites. Please try again.",reviewFilterPositive:"Positive",reviewFilterNegative:"Negative",decreaseLabel:"Decrease",increaseLabel:"Increase",reviewCustomersMentionSingular:"1 customer mentions",reviewCustomersMentionPlural:"customers mention",reviewSubjectsHeading:"Select to learn more",tryAgainButton:"Try again",askSomethingElseButton:"Ask something else",accountInactiveMessage:"This account is currently inactive. Please try again later.",favoritesPageTitle:"My Favorites",emptyFavoritesMessage:"No favorites yet. Heart a product to save it here.",showFormerMessagesButton:"↑ Show earlier messages",aiAnalysisAnalyzingLabel:"Analyzing products...",aiBrowseCategoriesTitle:"Browse categories",photoAnalysisBadge:"Skin Analysis",photoAnalysisStrengthsLabel:"Your strengths",photoAnalysisFocusLabel:"Focus points",photoAnalysisCelebStyleLabel:"Celeb style match",beautyPhotoStepTitle:"Personalize with a selfie",beautyPhotoStepDescription:"Upload a clear profile photo so I can give you personalized recommendations.",beautyPhotoStepUpload:"Upload Photo",beautyPhotoStepProcessing:"Processing photo...",beautyPhotoStepSkip:"Skip",beautyPhotoStepSkipMessage:"Skip the photo step"};function rs(e){return e?e.toLowerCase().split("-")[0]??"tr":"tr"}function is(e){return rs(e)==="en"?ns:tt}function os(){return Wa()!==null}function Wa(){const e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition??null}var ss=class{constructor(e,t){this.recognition=null,this._state="idle",this.silenceTimer=null,this.accumulatedTranscript="",this.intentionalStop=!1,this._lastRestartAt=0,this.callbacks=e,this.lang=t?.lang??"tr-TR",this.silenceTimeoutMs=t?.silenceTimeoutMs??1500,this.autoSubmit=t?.autoSubmit??!0}get state(){return this._state}start(){if(this._state==="listening")return;const e=Wa();if(!e){this.setState("error"),this.callbacks.onError?.("not-supported","Web Speech API is not supported in this browser.");return}if(typeof globalThis.isSecureContext<"u"&&!globalThis.isSecureContext){this.setState("error"),this.callbacks.onError?.("not-allowed","Voice input requires HTTPS.");return}this.accumulatedTranscript="",this.intentionalStop=!1;const t=new e;t.continuous=!0,t.interimResults=!0,t.lang=this.lang,t.maxAlternatives=1,t.onstart=()=>{this.setState("listening")},t.onresult=a=>{this.clearSilenceTimer();let n="",r="";for(let i=a.resultIndex;i<a.results.length;i++){const o=a.results[i];if(!o)continue;const s=o[0];s&&(o.isFinal?r+=s.transcript:n+=s.transcript)}r&&(this.accumulatedTranscript+=r,this.callbacks.onFinal?.(this.accumulatedTranscript)),n&&this.callbacks.onInterim?.(this.accumulatedTranscript+n),this.autoSubmit&&this.accumulatedTranscript&&this.startSilenceTimer()},t.onerror=a=>{const n=cs(a.error);this.intentionalStop&&(a.error==="no-speech"||a.error==="aborted")||(this.setState("error"),this.callbacks.onError?.(n,a.message||a.error))},t.onend=()=>{if(this.clearSilenceTimer(),this._state==="listening"&&!this.intentionalStop){const a=Date.now();if(a-this._lastRestartAt<500){this.setState("idle");return}this._lastRestartAt=a;try{t.start()}catch{this.setState("idle")}return}this.setState("idle")},this.recognition=t;try{t.start()}catch{this.setState("error"),this.callbacks.onError?.("unknown","Failed to start speech recognition.")}}stop(){if(this.intentionalStop=!0,this.clearSilenceTimer(),this.recognition){try{this.recognition.stop()}catch{}this.recognition=null}return this.setState("idle"),this.accumulatedTranscript}abort(){if(this.intentionalStop=!0,this.clearSilenceTimer(),this.accumulatedTranscript="",this.recognition){try{this.recognition.abort()}catch{}this.recognition=null}this.setState("idle")}destroy(){this.abort()}setState(e){this._state!==e&&(this._state=e,this.callbacks.onStateChange?.(e))}startSilenceTimer(){this.clearSilenceTimer(),this.silenceTimer=setTimeout(()=>{const e=this.stop();e.trim()&&this.callbacks.onAutoSubmit?.(e.trim())},this.silenceTimeoutMs)}clearSilenceTimer(){this.silenceTimer!==null&&(clearTimeout(this.silenceTimer),this.silenceTimer=null)}};function cs(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 ls(e){const t=document.createElement("div");t.className="gengage-chat-kvkk-banner gds-evidence-card gds-evidence-card-warning",t.dataset.gengagePart="kvkk-banner",t.setAttribute("role","alert");const a=document.createElement("div");a.className="gengage-chat-kvkk-content",a.dataset.gengagePart="kvkk-content",a.innerHTML=Ae(e.htmlContent),t.appendChild(a);const n=document.createElement("button");return n.className="gengage-chat-kvkk-dismiss",n.dataset.gengagePart="kvkk-dismiss",n.type="button",n.setAttribute("aria-label",e.closeAriaLabel??"Close privacy notice"),n.textContent="×",n.addEventListener("click",e.onDismiss),t.appendChild(n),t}var gs=class{constructor(e){this._el=document.createElement("div"),this._el.className="gengage-chat-panel-topbar gds-toolbar",this._el.dataset.gengagePart="panel-topbar",this._backBtn=document.createElement("button"),this._backBtn.className="gengage-chat-panel-topbar-back gds-btn gds-btn-ghost gds-icon-btn",this._backBtn.dataset.gengagePart="panel-topbar-back",this._backBtn.type="button",this._backBtn.disabled=!0,this._backBtn.setAttribute("aria-label",e.backAriaLabel??"Back"),this._backBtn.title=e.backAriaLabel??"Back",this._backBtn.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m15 18-6-6 6-6"/><path d="M21 12H9"/></svg>',this._backBtn.addEventListener("click",()=>e.onBack());const t=document.createElement("div");t.className="gengage-chat-panel-topbar-title-wrap",this._titleEl=document.createElement("span"),this._titleEl.className="gengage-chat-panel-topbar-title",this._titleEl.dataset.gengagePart="panel-topbar-title",t.appendChild(this._titleEl),this._forwardBtn=document.createElement("button"),this._forwardBtn.className="gengage-chat-panel-topbar-forward gds-btn gds-btn-ghost gds-icon-btn",this._forwardBtn.dataset.gengagePart="panel-topbar-forward",this._forwardBtn.type="button",this._forwardBtn.disabled=!0,this._forwardBtn.setAttribute("aria-label",e.forwardAriaLabel??"Forward"),this._forwardBtn.title=e.forwardAriaLabel??"Forward",this._forwardBtn.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 18 6-6-6-6"/><path d="M3 12h12"/></svg>',this._forwardBtn.addEventListener("click",()=>e.onForward()),this._actionsEl=document.createElement("div"),this._actionsEl.className="gengage-chat-panel-topbar-actions",this._actionsEl.dataset.gengagePart="panel-topbar-actions",this._closeBtn=document.createElement("button"),this._closeBtn.className="gengage-chat-panel-topbar-close gds-btn gds-btn-ghost gds-icon-btn",this._closeBtn.dataset.gengagePart="panel-topbar-close",this._closeBtn.type="button",this._closeBtn.setAttribute("aria-label",e.closePanelAriaLabel??"Close panel"),this._closeBtn.title=e.closePanelAriaLabel??"Close panel",this._closeBtn.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',this._closeBtn.addEventListener("click",()=>e.onClose?.()),this._el.appendChild(this._backBtn),this._el.appendChild(t),this._el.appendChild(this._actionsEl),this._el.appendChild(this._forwardBtn),this._el.appendChild(this._closeBtn)}update(e,t,a){this._backBtn.disabled=!e,this._forwardBtn.disabled=!t,this._backBtn.hidden=!e,this._forwardBtn.hidden=!t,this._titleEl.textContent=a,this._titleEl.title=a}getElement(){return this._el}setTitle(e){this._titleEl.textContent=e}setActions(e){this._actionsEl.replaceChildren(),e&&this._actionsEl.appendChild(e)}getTitle(){return this._titleEl.textContent??""}},ds=class{constructor(e){this._onThumbnailClick=e.onThumbnailClick,this._el=document.createElement("div"),this._el.className="gengage-chat-thumbnails-column",this._el.style.display="none"}getElement(){return this._el}setEntries(e){const t=new Set,a=[];for(const n of e)t.has(n.sku)||(t.add(n.sku),a.push(n));this._el.innerHTML="";for(const n of a){const r=document.createElement("button");if(r.type="button",r.className="gengage-chat-thumbnail-btn",r.title=n.sku,Pe(n.imageUrl)){const i=document.createElement("img");i.className="gengage-chat-thumbnail-img",i.src=n.imageUrl,i.alt=n.sku,i.width=40,i.height=40,r.appendChild(i)}r.addEventListener("click",()=>{this._onThumbnailClick(n.threadId)}),this._el.appendChild(r)}}show(){this._el.style.display=""}hide(){this._el.style.display="none"}};function ps(e){return{processing:e.processing===!0,title:typeof e.title=="string"?e.title:void 0,description:typeof e.description=="string"?e.description:void 0,uploadLabel:typeof e.upload_label=="string"?e.upload_label:void 0,skipLabel:typeof e.skip_label=="string"?e.skip_label:void 0}}function Ka(e,t,a){const n=e.props??{},r=n.processing===!0,i={...tt,...t.i18n??{}},o=document.createElement("div");o.className="gengage-chat-beauty-photo-step-card";const s=document.createElement("span");s.className="gengage-chat-beauty-photo-step-icon",s.setAttribute("aria-hidden","true"),s.textContent="✦";const c=document.createElement("div");c.className="gengage-chat-beauty-photo-step-content";const l=document.createElement("div");l.className="gengage-chat-beauty-photo-step-title",l.textContent=(typeof n.title=="string"?n.title:void 0)??i.beautyPhotoStepTitle;const g=document.createElement("p");g.className="gengage-chat-beauty-photo-step-desc",g.textContent=(typeof n.description=="string"?n.description:void 0)??i.beautyPhotoStepDescription;const p=document.createElement("div");p.className="gengage-chat-beauty-photo-step-actions";const h=document.createElement("button");h.type="button",h.className="gengage-chat-beauty-photo-step-upload gds-btn gds-btn-primary",h.textContent=r?i.beautyPhotoStepProcessing:(typeof n.upload_label=="string"?n.upload_label:void 0)??i.beautyPhotoStepUpload,h.disabled=r,a?.onUpload&&h.addEventListener("click",()=>a.onUpload());const d=document.createElement("button");return d.type="button",d.className="gengage-chat-beauty-photo-step-skip gds-btn gds-btn-ghost",d.textContent=(typeof n.skip_label=="string"?n.skip_label:void 0)??i.beautyPhotoStepSkip,a?.onSkip&&d.addEventListener("click",()=>a.onSkip()),p.appendChild(h),p.appendChild(d),c.appendChild(l),c.appendChild(g),c.appendChild(p),o.appendChild(s),o.appendChild(c),o}function hs(e,t){if(e)return e;const a=document.createElement("section");a.className="gengage-chat-beauty-photo-step",a.dataset.gengagePart="chat-beauty-photo-step",a.hidden=!0;const n=t?.querySelector(".gengage-chat-input-area");return n?n.parentElement?.insertBefore(a,n):t?.appendChild(a),a}function us(e,t,a,n,r){if(!a.visible)return e&&(e.hidden=!0,e.innerHTML=""),e;const i=hs(e,t);i.hidden=!1,i.innerHTML="";const o=Ka({type:"BeautyPhotoStep",props:{processing:a.processing??!1,title:a.title,description:a.description,upload_label:a.uploadLabel,skip_label:a.skipLabel}},{i18n:n,onAction:()=>{}},{onUpload:r,onSkip:a.onSkip});return i.appendChild(o),i}function Ya(e){const t=typeof e.summary=="string"?e.summary:"",a=Array.isArray(e.strengths)?e.strengths.filter(c=>typeof c=="string"):[],n=Array.isArray(e.focus_points)?e.focus_points.filter(c=>typeof c=="string"):[];if(!t&&a.length===0&&n.length===0)return null;const r={summary:t},i=typeof e.celeb_style=="string"?e.celeb_style:void 0,o=typeof e.celeb_style_reason=="string"?e.celeb_style_reason:void 0,s=typeof e.next_question=="string"?e.next_question:void 0;return a.length>0&&(r.strengths=a),n.length>0&&(r.focusPoints=n),i&&(r.celebStyle=i),o&&(r.celebStyleReason=o),s&&(r.nextQuestion=s),r}function Ja(e,t,a){if(t.length===0)return null;const n=document.createElement("section");n.className=`gengage-chat-photo-analysis-section ${a}`;const r=document.createElement("h4");r.className="gengage-chat-photo-analysis-section-title",r.textContent=e;const i=document.createElement("ul");i.className="gengage-chat-photo-analysis-section-list";for(const o of t){const s=document.createElement("li");s.className="gengage-chat-photo-analysis-section-item",s.textContent=o,i.appendChild(s)}return n.appendChild(r),n.appendChild(i),n}function Xa(e,t){const a=document.createElement("div");a.className="gengage-chat-photo-analysis-card";const n=document.createElement("div");n.className="gengage-chat-photo-analysis-badge",n.textContent=e.badge;const r=document.createElement("div");if(r.className="gengage-chat-photo-analysis-body",t.summary){const c=document.createElement("p");c.className="gengage-chat-photo-analysis-summary",c.textContent=t.summary,r.appendChild(c)}const i=document.createElement("div");i.className="gengage-chat-photo-analysis-highlights";const o=Ja(e.strengths,t.strengths??[],"gengage-chat-photo-analysis-section--strengths"),s=Ja(e.focus,t.focusPoints??[],"gengage-chat-photo-analysis-section--focus");if(o&&i.appendChild(o),s&&i.appendChild(s),i.childElementCount>0&&r.appendChild(i),t.celebStyle){const c=document.createElement("section");c.className="gengage-chat-photo-analysis-section gengage-chat-photo-analysis-section--celeb";const l=document.createElement("h4");l.className="gengage-chat-photo-analysis-section-title",l.textContent=e.celebStyle;const g=document.createElement("p");if(g.className="gengage-chat-photo-analysis-celeb-name",g.textContent=t.celebStyle,c.appendChild(l),c.appendChild(g),t.celebStyleReason){const p=document.createElement("p");p.className="gengage-chat-photo-analysis-celeb-reason",p.textContent=t.celebStyleReason,c.appendChild(p)}r.appendChild(c)}if(t.nextQuestion){const c=document.createElement("p");c.className="gengage-chat-photo-analysis-next",c.textContent=t.nextQuestion,r.appendChild(c)}return a.appendChild(n),a.appendChild(r),a}function ms(e){const t={...tt,...e?.i18n??{}};return{badge:t.photoAnalysisBadge,strengths:t.photoAnalysisStrengthsLabel,focus:t.photoAnalysisFocusLabel,celebStyle:t.photoAnalysisCelebStyleLabel}}function fs(e,t){const a=Ya(e.props??{})??{summary:""};return Xa(ms(t),a)}function bs(e,t,a){e.innerHTML="",a&&e.appendChild(Xa(t,a))}var ju='<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>',Qa={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>'},vs=tt,ys=1400,en=1500,_s=/data:image\/(png|jpeg|jpg|webp);base64,[A-Za-z0-9+/=]+/gi;async function xs(e){for(const t of e)for(const a of t.types)if(a.startsWith("image/"))try{const n=await t.getType(a);if(!n||n.size===0)continue;const r=a||n.type||"image/png",i=r==="image/png"?"png":r==="image/webp"?"webp":"jpg",o=`paste-${Date.now()}.${i}`;return new File([n],o,{type:r})}catch{continue}for(const t of e)if(t.types.includes("text/html"))try{const a=(await(await t.getType("text/html")).text()).match(_s)?.[0];if(!a||a.length>5e6)continue;const n=await(await fetch(a)).blob();if(!n||n.size===0)continue;const r=n.type||"image/png";if(!["image/jpeg","image/png","image/webp"].includes(r))continue;const i=r==="image/png"?"png":r==="image/webp"?"webp":"jpg";return new File([n],`paste-${Date.now()}.${i}`,{type:r})}catch{continue}return null}async function ws(e){try{const t=e??(typeof navigator.clipboard?.read=="function"?navigator.clipboard.read():null);return t?xs(await t):null}catch{}return null}var ks=class{_renderPhotoAnalysisCard(e,t){bs(e,{badge:this.i18n.photoAnalysisBadge,strengths:this.i18n.photoAnalysisStrengthsLabel,focus:this.i18n.photoAnalysisFocusLabel,celebStyle:this.i18n.photoAnalysisCelebStyleLabel},t)}constructor(e,t){this._sendStopHandler=null,this._panelVisible=!1,this._panelCollapsed=!1,this._dividerPreviewEnabled=!1,this._onPanelToggle=void 0,this._onHostShellSync=void 0,this._pendingAttachment=null,this._onAttachment=void 0,this._onRollback=void 0,this._onLinkClick=void 0,this._userScrolledUp=!1,this._scrollLockedUntil=0,this._favBadgeEl=null,this._thinkingSteps=[],this._firstBotMessageIds=new Set,this._voiceInput=null,this._micBtn=null,this._voiceEnabled=!1,this._voiceLang="tr-TR",this._ignoreNextDividerClick=!1,this._cleanups=[],this._focusTrapHandler=null,this._previouslyFocusedElement=null,this._conversationEl=null,this._reopenPanelBtn=null,this._presentationFocusThreadId=null,this._formerMessagesBtn=null,this._programmaticScrollUntil=0,this._userInteractionUntil=0,this._touchStartY=null,this._presentationPinned=!0,this._presentationUserInteracting=!1,this._resizeRafId=null,this._cartBtn=null,this._attachWrapEl=null,this._attachMenuEl=null,this._attachBtn=null,this._attachMenuCleanup=null,this._attachMenuClickTimerId=null,this._typingLoadingBinding=null,this._panelLoadingBinding=null,this._panelAiZoneLoadingBinding=null,this._beautyPhotoStepEl=null,this._options=t,this.i18n={...vs,...t.i18n},this.onSend=t.onSend,t.onPanelToggle!==void 0&&(this._onPanelToggle=t.onPanelToggle),t.onHostShellSync!==void 0&&(this._onHostShellSync=t.onHostShellSync),t.onAttachment!==void 0&&(this._onAttachment=t.onAttachment),t.onRollback!==void 0&&(this._onRollback=t.onRollback),t.onLinkClick!==void 0&&(this._onLinkClick=t.onLinkClick),t.voiceEnabled&&(this._voiceEnabled=!0),t.voiceLang!==void 0&&(this._voiceLang=t.voiceLang),this.root=document.createElement("div"),this.root.className="gengage-chat-drawer gds-panel",this.root.dataset.gengagePart="chat-drawer",this.root.setAttribute("role","dialog"),this.root.setAttribute("aria-label",this.i18n.headerTitle??"Chat"),this.root.setAttribute("aria-modal","true");const a="gengage-chat-dialog-desc",n=document.createElement("span");n.id=a,n.className="gengage-sr-only",n.textContent=this.i18n.headerTitle??"AI shopping assistant",this.root.appendChild(n),this.root.setAttribute("aria-describedby",a);let r=null;{const C=document.createElement("div");C.className="gengage-chat-drawer-handle",C.dataset.gengagePart="chat-drawer-handle",C.setAttribute("aria-hidden","true"),C.style.pointerEvents="none",r=C}const i=document.createElement("div");i.className="gengage-chat-header gds-shell-header",i.dataset.gengagePart="chat-header";const o=document.createElement("div");o.className="gengage-chat-header-left",o.dataset.gengagePart="chat-header-left";const s=t.headerAvatarUrl??t.launcherImageUrl,c=typeof t.headerAvatarUrl=="string"&&t.headerAvatarUrl.length>0&&t.headerAvatarUrl!==t.launcherImageUrl;if(s){const C=document.createElement("img");C.className="gengage-chat-header-avatar",c&&C.classList.add("gengage-chat-header-avatar--logo"),C.dataset.gengagePart="chat-header-avatar",C.src=s,C.alt=t.headerTitle??"Assistant",o.appendChild(C)}const l=document.createElement("div");l.className="gengage-chat-header-info",l.dataset.gengagePart="chat-header-info";const g=document.createElement("div");g.className="gengage-chat-header-title-row",g.dataset.gengagePart="chat-header-title-row";const p=document.createElement("span");if(p.className="gengage-chat-header-title",p.dataset.gengagePart="chat-header-title",p.textContent=t.headerTitle??this.i18n.headerTitle??"Product Expert",g.appendChild(p),t.headerBadge){const C=document.createElement("span");C.className="gengage-chat-header-badge gds-badge gds-badge-brand",C.dataset.gengagePart="chat-header-badge",C.textContent=t.headerBadge,g.appendChild(C)}l.appendChild(g);const h=document.createElement("a");h.className="gengage-chat-header-powered",h.dataset.gengagePart="chat-header-powered-by",h.href="https://gengage.ai/",h.target="_blank",h.rel="noopener noreferrer",h.innerHTML=`<svg viewBox="0 0 15 15" fill="none" aria-hidden="true"><path d="M15 5.88941C12.2201 5.88941 9.72762 7.14107 8.05571 9.11059H0C2.77991 9.11059 5.27238 7.85893 6.94429 5.88941H15Z" fill="currentColor"/><path d="M9.10964 0C9.10964 2.24394 8.29524 4.30038 6.94429 5.88941C5.27238 7.85962 2.77922 9.11059 0 9.11059V5.88941C3.24802 5.88941 5.89036 3.2465 5.89036 0H9.10964Z" fill="currentColor" fill-opacity="0.68"/><path d="M15 5.88941V9.11059C11.752 9.11059 9.10964 11.7535 9.10964 15H5.89036C5.89036 12.7561 6.70476 10.6996 8.05571 9.11059C9.72762 7.14038 12.2208 5.88941 15 5.88941Z" fill="currentColor" fill-opacity="0.68"/></svg>${this.i18n.poweredBy}`,l.appendChild(h),o.appendChild(l),i.appendChild(o);const d=document.createElement("div");d.className="gengage-chat-header-right",d.dataset.gengagePart="chat-header-actions";{const C=document.createElement("button");C.type="button",C.className="gengage-chat-header-btn gengage-chat-header-btn--reopen-panel gds-btn gds-btn-ghost gds-icon-btn",C.dataset.gengagePart="chat-header-reopen-panel",C.setAttribute("aria-label",this.i18n.showPanelAriaLabel),C.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="9" y1="3" x2="9" y2="21"/></svg>',C.addEventListener("click",()=>this._showMobilePanelFromBtn()),d.appendChild(C),this._reopenPanelBtn=C}{const C=document.createElement("button");C.type="button",C.className="gengage-chat-header-btn gds-btn gds-btn-ghost gds-icon-btn",C.dataset.gengagePart="chat-header-cart",C.setAttribute("aria-label",this.i18n.cartAriaLabel),C.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="9" cy="21" r="1"/><circle cx="20" cy="21" r="1"/><path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"/></svg>',C.addEventListener("click",()=>t.onCartClick?.()),d.appendChild(C),this._cartBtn=C}if(t.onNewChat){const C=document.createElement("button");C.className="gengage-chat-header-btn gengage-chat-new-chat gds-btn gds-btn-ghost gds-icon-btn",C.dataset.gengagePart="chat-header-new-chat",C.type="button",C.setAttribute("aria-label",this.i18n.newChatButton),C.title=this.i18n.newChatButton,C.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>',C.addEventListener("click",()=>t.onNewChat?.()),d.appendChild(C)}const b=document.createElement("button");if(b.className="gengage-chat-close gds-btn gds-btn-ghost gds-icon-btn",b.dataset.gengagePart="chat-header-close",b.type="button",b.setAttribute("aria-label",this.i18n.closeButton),b.innerHTML='<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',b.addEventListener("click",t.onClose),t.showHeaderFavorites){const C=document.createElement("button");C.className="gengage-chat-header-btn gengage-chat-header-btn--fav gds-btn gds-btn-ghost gds-icon-btn",C.dataset.gengagePart="chat-header-favorites",C.type="button",C.setAttribute("aria-label",this.i18n.favoritesAriaLabel),C.innerHTML='<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>';const Y=document.createElement("span");Y.className="gengage-chat-header-fav-badge",Y.dataset.gengagePart="chat-header-favorites-badge",Y.setAttribute("aria-hidden","true"),Y.style.display="none",C.appendChild(Y),this._favBadgeEl=Y,C.addEventListener("click",()=>{t.onFavoritesClick?.()}),d.appendChild(C)}d.appendChild(b),r&&i.insertBefore(r,i.firstChild),i.appendChild(d);{let Y=0,he=0,me=!1;const V=ie=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768)||ie.target.closest('button, a, input, [role="button"]'))return;const Be=ie.changedTouches?.[0];Be&&(Y=Be.clientY,he=0,me=!0,this.root.style.transition="none")},ee=ie=>{if(!me)return;const Be=ie.changedTouches?.[0];if(!Be)return;he=Be.clientY-Y;const Hu=(t.getMobileState?.()??"full")==="full"?Math.max(0,he):he;ie.preventDefault(),this.root.style.transform=`translateY(${Hu}px)`},ge=()=>{if(!me)return;me=!1;const ie=t.getMobileState?.()??"full";let Be;he>72?Be=ie==="full"?"half":"close":he<-72&&ie==="half"?Be="full":Be=ie,this.root.style.transition="",Be==="close"?(this.root.style.transform="translateY(100%)",setTimeout(()=>{this.root.style.transform="",t.onMobileSnap?.("close")},280)):(this.root.style.transform="",t.onMobileSnap?.(Be)),he=0},W=()=>{me&&(me=!1,he=0,this.root.style.transition="",this.root.style.transform="")};i.addEventListener("touchstart",V,{passive:!0}),i.addEventListener("touchmove",ee,{passive:!1}),i.addEventListener("touchend",ge,{passive:!0}),i.addEventListener("touchcancel",W,{passive:!0}),this._cleanups.push(()=>{i.removeEventListener("touchstart",V),i.removeEventListener("touchmove",ee),i.removeEventListener("touchend",ge),i.removeEventListener("touchcancel",W)})}const u=document.createElement("div");u.className="gengage-chat-body",u.dataset.gengagePart="chat-body",this._panelEl=document.createElement("div"),this._panelEl.className="gengage-chat-panel gds-panel",this._panelEl.dataset.gengagePart="chat-panel",this._panelTopBar=new gs({onBack:()=>t.onPanelBack?.(),onForward:()=>t.onPanelForward?.(),onClose:()=>{t.getMobileViewport?.()??!1?this.hideMobilePanel():this.clearPanel(),t.onPanelClose?.()},backAriaLabel:this.i18n.backAriaLabel,forwardAriaLabel:this.i18n.forwardAriaLabel,closePanelAriaLabel:this.i18n.closePanelAriaLabel}),this._panelEl.appendChild(this._panelTopBar.getElement());const v=()=>this._updateScrollAffordance();this._panelEl.addEventListener("scroll",v,{passive:!0}),this._cleanups.push(()=>this._panelEl.removeEventListener("scroll",v)),u.appendChild(this._panelEl),this._dividerEl=document.createElement("div"),this._dividerEl.className="gengage-chat-panel-divider gengage-chat-panel-divider--hidden",this._dividerEl.dataset.gengagePart="chat-panel-divider",this._dividerEl.setAttribute("role","separator"),this._dividerEl.setAttribute("aria-label",this.i18n.togglePanelAriaLabel),this._dividerEl.setAttribute("title",this.i18n.togglePanelAriaLabel),this._dividerPreviewEl=document.createElement("div"),this._dividerPreviewEl.className="gengage-chat-panel-divider-preview",this._dividerPreviewEl.dataset.gengagePart="chat-panel-divider-preview",this._dividerPreviewEl.setAttribute("aria-hidden","true"),this._dividerEl.appendChild(this._dividerPreviewEl);const m=document.createElement("button");m.className="gengage-chat-panel-divider-toggle gds-btn gds-btn-ghost",m.dataset.gengagePart="chat-panel-divider-toggle",m.type="button",m.setAttribute("aria-label",this.i18n.togglePanelAriaLabel),m.setAttribute("title",this.i18n.togglePanelAriaLabel),m.textContent="»",m.addEventListener("click",()=>{if(this._ignoreNextDividerClick){this._ignoreNextDividerClick=!1;return}this.togglePanel(),this._onPanelToggle?.()});let P=null,A=null;const k=24,x=C=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768))return;const Y=C.changedTouches?.[0];Y&&(P=Y.clientX,A=Y.clientY)},N=C=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768)||P===null||A===null)return;const Y=C.changedTouches?.[0];if(!Y)return;const he=Y.clientX-P,me=Y.clientY-A;if(P=null,A=null,Math.abs(me)<k||Math.abs(me)<Math.abs(he))return;const V=me<0;V!==this._panelCollapsed&&(this._ignoreNextDividerClick=!0,this.setPanelCollapsed(V),this._onPanelToggle?.())};this._dividerEl.addEventListener("touchstart",x,{passive:!0}),this._dividerEl.addEventListener("touchend",N,{passive:!0}),this._cleanups.push(()=>{this._dividerEl.removeEventListener("touchstart",x),this._dividerEl.removeEventListener("touchend",N)}),this._dividerEl.appendChild(m),u.appendChild(this._dividerEl);const T=document.createElement("div");T.className="gengage-chat-conversation",T.dataset.gengagePart="chat-conversation",this._conversationEl=T,T.appendChild(i);const I=document.createElement("div");I.className="gengage-chat-offline-bar gds-evidence-card gds-evidence-card-warning",I.dataset.gengagePart="chat-offline-bar",I.setAttribute("role","status"),I.setAttribute("aria-live","polite"),I.textContent=this.i18n.offlineMessage,typeof navigator<"u"&&!navigator.onLine&&I.classList.add("gengage-chat-offline-bar--visible"),T.appendChild(I);const $=()=>I.classList.add("gengage-chat-offline-bar--visible"),ae=()=>I.classList.remove("gengage-chat-offline-bar--visible");window.addEventListener("offline",$),window.addEventListener("online",ae),this._cleanups.push(()=>{window.removeEventListener("offline",$),window.removeEventListener("online",ae)}),this._kvkkSlot=document.createElement("div"),this._kvkkSlot.className="gengage-chat-kvkk-slot",this._kvkkSlot.dataset.gengagePart="chat-kvkk-slot",T.appendChild(this._kvkkSlot),this.messagesEl=document.createElement("div"),this.messagesEl.id=kt,this.messagesEl.className="gengage-chat-messages",this.messagesEl.dataset.gengagePart="chat-messages",this.messagesEl.setAttribute("role","log"),this.messagesEl.setAttribute("aria-live","polite"),this.messagesEl.setAttribute("aria-atomic","false"),this.messagesEl.setAttribute("aria-label",this.i18n.chatMessagesAriaLabel),Va(this.messagesEl);const oe=document.createElement("button");oe.type="button",oe.className="gengage-chat-former-messages-btn gds-chip",oe.dataset.gengagePart="chat-former-messages-button",oe.textContent=this.i18n.showFormerMessagesButton,oe.setAttribute("aria-label",this.i18n.showFormerMessagesButton),oe.style.display="none",oe.addEventListener("click",()=>{this._options.presentation?.onReleasePresentationFocus?.()}),this.messagesEl.appendChild(oe),this._formerMessagesBtn=oe;const ve=()=>{this._userInteractionUntil=Date.now()+2e3};let O=!1;const f=()=>this._options.presentation,L=()=>{O||(O=!0,requestAnimationFrame(()=>{O=!1;const{scrollTop:C,scrollHeight:Y,clientHeight:he}=this.messagesEl,me=Y-C-he;this._userScrolledUp=me>10;const V=this._presentationPinned?me<96:me<32,ee=Date.now(),ge=ee<this._programmaticScrollUntil,W=!V&&ee<this._userInteractionUntil,ie=ge?!1:W;V!==this._presentationPinned&&(this._presentationPinned=V,f()?.onPinnedToBottomChange?.(V)),ie!==this._presentationUserInteracting&&(this._presentationUserInteracting=ie,f()?.onUserInteractingChange?.(ie))}))};this.messagesEl.addEventListener("scroll",L,{passive:!0}),this._cleanups.push(()=>{this.messagesEl.removeEventListener("scroll",L)});const D=C=>{ve(),C.deltaY<-6&&this._presentationFocusThreadId&&this._options.presentation?.onFormerMessagesHint?.()};this.messagesEl.addEventListener("wheel",D,{passive:!0}),this._cleanups.push(()=>this.messagesEl.removeEventListener("wheel",D));const B=C=>{ve(),this._touchStartY=C.touches[0]?.clientY??null},j=C=>{ve();const Y=C.touches[0]?.clientY,he=this._touchStartY;typeof Y=="number"&&typeof he=="number"&&Y-he>10&&this._presentationFocusThreadId&&this._options.presentation?.onFormerMessagesHint?.()};this.messagesEl.addEventListener("touchstart",B,{passive:!0}),this.messagesEl.addEventListener("touchmove",j,{passive:!0}),this._cleanups.push(()=>{this.messagesEl.removeEventListener("touchstart",B),this.messagesEl.removeEventListener("touchmove",j)}),T.appendChild(this.messagesEl),this._thumbnailsColumn=new ds({onThumbnailClick:C=>t.onThumbnailClick?.(C)}),this._panelEl.appendChild(this._thumbnailsColumn.getElement()),this._panelFloatingEl=document.createElement("div"),this._panelFloatingEl.className="gengage-chat-panel-float",this._panelFloatingEl.dataset.gengagePart="chat-panel-floating-layer",this._panelEl.appendChild(this._panelFloatingEl),this._resetPanelAiZoneElement(),this._pillsEl=document.createElement("div"),this._pillsEl.className="gengage-chat-pills",this._pillsEl.dataset.gengagePart="chat-suggestion-pills",this._pillsEl.setAttribute("role","toolbar"),this._pillsEl.setAttribute("aria-label",this.i18n.suggestionsAriaLabel),this._pillsEl.style.display="none";const Z=document.createElement("div");Z.className="gengage-chat-pills-scroll",Z.dataset.gengagePart="chat-suggestion-pills-scroll",this._pillsEl.appendChild(Z);const q=document.createElement("button");q.className="gengage-chat-pills-arrow gds-btn gds-btn-ghost",q.dataset.gengagePart="chat-suggestion-pills-more",q.type="button",q.setAttribute("aria-label",this.i18n.moreSuggestionsAriaLabel),q.textContent="›",q.addEventListener("click",()=>{Z.scrollBy({left:150,behavior:"smooth"})}),this._pillsEl.appendChild(q);let y=!1;const E=()=>{y||(y=!0,requestAnimationFrame(()=>{y=!1;const C=Z.scrollLeft+Z.clientWidth>=Z.scrollWidth-4;q.style.display=C?"none":""}))};Z.addEventListener("scroll",E,{passive:!0}),this._cleanups.push(()=>{Z.removeEventListener("scroll",E)}),T.appendChild(this._pillsEl),this._inputChipsEl=document.createElement("div"),this._inputChipsEl.className="gengage-chat-input-chips",this._inputChipsEl.dataset.gengagePart="chat-input-chips",this._inputChipsEl.style.display="none",T.appendChild(this._inputChipsEl);const S=document.createElement("div");S.className="gengage-chat-input-area",S.dataset.gengagePart="chat-input-area",this.inputEl=document.createElement("textarea"),this.inputEl.className="gengage-chat-input",this.inputEl.dataset.gengagePart="chat-input",this.inputEl.rows=1,this.inputEl.placeholder=this.i18n.inputPlaceholder,this.inputEl.addEventListener("input",()=>{this._resizeRafId!==null&&cancelAnimationFrame(this._resizeRafId),this._resizeRafId=requestAnimationFrame(()=>{this._resizeRafId=null,this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,120)}px`}),this._updateSendEnabled()}),this.inputEl.addEventListener("keydown",C=>{C.key==="Enter"&&!C.isComposing&&((this._options.getMobileViewport?.()??window.innerWidth<=768)||!C.shiftKey)&&(C.preventDefault(),this._submit())}),this.inputEl.addEventListener("paste",C=>{const Y=C.clipboardData;if(!Y)return;let he=null;const me=Y.files?.[0];if(me&&me.type.startsWith("image/"))he=me;else if(Y.items?.length)for(let V=0;V<Y.items.length;V++){const ee=Y.items[V];if(ee?.kind==="file"&&ee.type.startsWith("image/")){const ge=ee.getAsFile();if(ge){he=ge;break}}}he&&(C.preventDefault(),this._routeAttachmentFile(he))}),this._fileInput=document.createElement("input"),this._fileInput.type="file",this._fileInput.accept="image/jpeg,image/png,image/webp",this._fileInput.style.display="none",this._fileInput.addEventListener("change",()=>{const C=this._fileInput.files?.[0];C&&this._routeAttachmentFile(C),this._fileInput.value=""});const z=document.createElement("div");z.className="gengage-chat-attach-wrap",z.dataset.gengagePart="chat-attach-wrap",this._attachWrapEl=z;const M=document.createElement("button");this._attachBtn=M,M.className="gengage-chat-attach-btn gds-btn gds-btn-ghost",M.dataset.gengagePart="chat-attach-button",M.type="button",M.setAttribute("aria-label",this.i18n.attachImageButton),M.setAttribute("aria-haspopup","menu"),M.setAttribute("aria-expanded","false"),M.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg>',M.addEventListener("click",C=>{C.stopPropagation(),this._toggleAttachMenu()});const R=document.createElement("div");this._attachMenuEl=R,R.className="gengage-chat-attach-menu gds-menu",R.dataset.gengagePart="chat-attach-menu",R.setAttribute("role","menu"),R.setAttribute("hidden","");const H=document.createElement("button");H.type="button",H.className="gengage-chat-attach-menu-item gds-btn gds-btn-ghost",H.dataset.gengagePart="chat-attach-menu-select-photo",H.setAttribute("role","menuitem"),H.innerHTML=`<span class="gengage-chat-attach-menu-icon" aria-hidden="true"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg></span><span class="gengage-chat-attach-menu-label">${this.i18n.attachMenuSelectPhoto}</span>`,H.addEventListener("click",C=>{C.stopPropagation(),this._closeAttachMenu(),this._fileInput.click()});const ne=document.createElement("div");ne.className="gengage-chat-attach-menu-sep",ne.dataset.gengagePart="chat-attach-menu-separator",ne.setAttribute("aria-hidden","true");const te=document.createElement("button");te.type="button",te.className="gengage-chat-attach-menu-item gds-btn gds-btn-ghost",te.dataset.gengagePart="chat-attach-menu-paste",te.setAttribute("role","menuitem"),te.innerHTML=`<span class="gengage-chat-attach-menu-icon" aria-hidden="true"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 2H9a1 1 0 0 0-1 1v1a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V3a1 1 0 0 0-1-1Z"/><path d="M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2"/><path d="M16 4h2a2 2 0 0 1 2 2v4"/><path d="M21 14H11"/><path d="m15 10-4 4 4 4"/></svg></span><span class="gengage-chat-attach-menu-label">${this.i18n.attachMenuPaste}</span>`,te.addEventListener("click",C=>{C.stopPropagation();const Y=typeof navigator.clipboard?.read=="function"?navigator.clipboard.read():void 0;this._pasteImageFromClipboardMenu(Y)}),R.appendChild(H),R.appendChild(ne),R.appendChild(te),z.appendChild(M),z.appendChild(R),this._previewStrip=document.createElement("div"),this._previewStrip.className="gengage-chat-attachment-preview gengage-chat-attachment-preview--hidden gds-card-soft",this._previewStrip.dataset.gengagePart="chat-attachment-preview";const U=document.createElement("img");U.className="gengage-chat-attachment-preview-thumb",U.dataset.gengagePart="chat-attachment-preview-thumb",U.alt="",this._previewName=document.createElement("span"),this._previewName.className="gengage-chat-attachment-name",this._previewName.dataset.gengagePart="chat-attachment-preview-name";const ce=document.createElement("button");ce.className="gengage-chat-attachment-remove gds-btn gds-btn-ghost",ce.dataset.gengagePart="chat-attachment-preview-remove",ce.type="button",ce.setAttribute("aria-label",this.i18n.removeAttachmentButton),ce.textContent="×",ce.addEventListener("click",()=>this.clearAttachment()),this._previewStrip.appendChild(U),this._previewStrip.appendChild(this._previewName),this._previewStrip.appendChild(ce),this.sendBtn=document.createElement("button"),this.sendBtn.className="gengage-chat-send gds-btn gds-btn-primary",this.sendBtn.dataset.gengagePart="chat-send",this.sendBtn.type="button",this.sendBtn.disabled=!0,this.sendBtn.setAttribute("aria-label",this.i18n.sendButton),this.sendBtn.dataset.tooltip=this.i18n.sendButton,this._renderSendButtonIcon("send"),this.sendBtn.addEventListener("click",()=>{if(this._sendStopHandler){const C=this._sendStopHandler;this.hideStopButton(),C();return}this._submit()}),S.addEventListener("dragover",C=>{C.preventDefault(),S.classList.add("gengage-chat-input-area--dragover")}),S.addEventListener("dragleave",()=>{S.classList.remove("gengage-chat-input-area--dragover")}),S.addEventListener("drop",C=>{C.preventDefault(),S.classList.remove("gengage-chat-input-area--dragover");const Y=C.dataTransfer?.files[0];Y&&this._routeAttachmentFile(Y)});const X=document.createElement("div");X.className="gengage-chat-input-pill gds-input-shell",X.dataset.gengagePart="chat-input-shell",X.appendChild(z),X.appendChild(this.inputEl),this._voiceEnabled&&os()&&(this._micBtn=document.createElement("button"),this._micBtn.className="gengage-chat-mic-btn gds-btn gds-btn-ghost",this._micBtn.dataset.gengagePart="chat-mic-button",this._micBtn.type="button",this._micBtn.setAttribute("aria-label",this.i18n.voiceButton),this._micBtn.innerHTML='<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" y1="19" x2="12" y2="23"/><line x1="8" y1="23" x2="16" y2="23"/></svg>',this._micBtn.addEventListener("click",()=>this._toggleVoice()),X.appendChild(this._micBtn),this._voiceInput=new ss({onInterim:C=>{this._resizeRafId!==null&&(cancelAnimationFrame(this._resizeRafId),this._resizeRafId=null),this.inputEl.value=C,this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,120)}px`},onFinal:C=>{this.inputEl.value=C},onAutoSubmit:C=>{this.inputEl.value=C,this._micBtn?.classList.remove("gengage-chat-mic-btn--active"),this._submit()},onStateChange:C=>{C==="listening"?this._micBtn?.classList.add("gengage-chat-mic-btn--active"):this._micBtn?.classList.remove("gengage-chat-mic-btn--active")},onError:(C,Y)=>{this._micBtn?.classList.remove("gengage-chat-mic-btn--active")}},{lang:this._voiceLang})),X.appendChild(this.sendBtn),S.appendChild(this._previewStrip),S.appendChild(this._fileInput),S.appendChild(X),T.appendChild(S),u.appendChild(T),this._comparisonDockSlotEl=document.createElement("div"),this._comparisonDockSlotEl.className="gengage-chat-comparison-dock-slot",this._comparisonDockSlotEl.dataset.gengagePart="comparison-dock-slot",u.appendChild(this._comparisonDockSlotEl),this.root.appendChild(u),this._setupHorizontalSwipe(T),this._setupHorizontalSwipe(this._panelEl);const $e=document.createElement("div");$e.className="gengage-chat-footer",$e.dataset.gengagePart="chat-footer",$e.textContent=this.i18n.poweredBy,this.root.appendChild($e);const xt=C=>{C.key==="Escape"&&t.onClose()};this.root.addEventListener("keydown",xt),this._cleanups.push(()=>this.root.removeEventListener("keydown",xt)),e.appendChild(this.root)}addMessage(e){const t=document.createElement("div");if(t.className=`gengage-chat-bubble gds-message ${e.role==="assistant"?"gds-message-assistant":"gds-message-user"} gengage-chat-bubble--${e.role}`,t.dataset.gengagePart=e.role==="assistant"?"chat-message-assistant":"chat-message-user",t.setAttribute("role","listitem"),t.dataset.messageId=e.id,e.threadId&&(t.dataset.threadId=e.threadId),this._firstBotMessageIds.has(e.id)&&t.classList.add("gengage-chat-bubble--first"),e.attachment){const a=document.createElement("img");a.className="gengage-chat-attachment-thumb";const n=URL.createObjectURL(e.attachment);a.src=n,a.alt=e.attachment.name,a.addEventListener("load",()=>URL.revokeObjectURL(n),{once:!0}),a.addEventListener("error",()=>URL.revokeObjectURL(n),{once:!0}),t.insertBefore(a,t.firstChild)}if(e.content){const a=document.createElement("div");if(a.className="gengage-chat-bubble-text",a.dataset.gengagePart="chat-message-text",e.role==="assistant"){if(e.renderHint==="photo_analysis"?(t.classList.add("gengage-chat-bubble--photo-analysis"),this._renderPhotoAnalysisCard(a,e.photoAnalysis)):a.innerHTML=Ae(e.content),this._onLinkClick){const n=a.querySelectorAll("a[href]");for(const r of n)r.addEventListener("click",i=>{i.preventDefault();const o=r.getAttribute("href");o&&this._onLinkClick?.(o)})}}else a.textContent=e.content;t.appendChild(a)}if(e.role==="user"&&this._onRollback){const a=document.createElement("button");a.className="gengage-chat-rollback-btn gds-btn gds-btn-ghost",a.dataset.gengagePart="chat-message-rollback",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",n=>{n.stopPropagation(),this._onRollback?.(e.id)}),t.appendChild(a)}this.messagesEl.appendChild(t),this._presentationFocusThreadId&&this._applyPresentationCollapsed(),this._scrollToBottom(e.role==="user")}removeMessageBubble(e){this._firstBotMessageIds.delete(e),this.messagesEl.querySelector(`[data-message-id="${_e(e)}"]`)?.remove(),this._presentationFocusThreadId&&this._applyPresentationCollapsed()}showTypingIndicator(e){this.removeTypingIndicator();const t=this._thinkingSteps.length>0?this._thinkingSteps.slice(-3):e?[e]:this.i18n.loadingSequenceGeneric,{root:a,binding:n}=this._createLoadingSequence("chat",t,"chat-typing-indicator","gengage-chat-typing");a.dataset.typing="true",this._typingLoadingBinding=n,this.messagesEl.appendChild(a),this._scrollToBottom(!0)}addThinkingStep(e){const t=e.trim();t&&this._thinkingSteps[this._thinkingSteps.length-1]!==t&&(this._thinkingSteps.push(t),this._thinkingSteps=this._thinkingSteps.slice(-3),this._typingLoadingBinding&&this._applyLoadingSteps(this._typingLoadingBinding,this._thinkingSteps,!0),this._panelLoadingBinding&&this._applyLoadingSteps(this._panelLoadingBinding,this._thinkingSteps,!0),this._panelAiZoneLoadingBinding&&this._applyLoadingSteps(this._panelAiZoneLoadingBinding,this._thinkingSteps,!0))}setThinkingSteps(e){const t=e.map(a=>a.trim()).filter(Boolean).slice(-3);t.length!==0&&(this._thinkingSteps=t,this._typingLoadingBinding&&this._applyLoadingSteps(this._typingLoadingBinding,this._thinkingSteps,!0),this._panelLoadingBinding&&this._applyLoadingSteps(this._panelLoadingBinding,this._thinkingSteps,!0),this._panelAiZoneLoadingBinding&&this._applyLoadingSteps(this._panelAiZoneLoadingBinding,this._thinkingSteps,!0))}removeTypingIndicator(){this._destroyLoadingBinding(this._typingLoadingBinding),this._typingLoadingBinding=null,this.messagesEl.querySelector(".gengage-chat-typing")?.remove(),this._thinkingSteps=[],this.hideStopButton()}showStopButton(e){this._sendStopHandler=e,this.sendBtn.disabled=!1,this.sendBtn.classList.add("gengage-chat-send--stop","gds-btn-secondary"),this.sendBtn.classList.remove("gds-btn-primary"),this.sendBtn.setAttribute("aria-label",this.i18n.stopGenerating),this.sendBtn.dataset.tooltip=this.i18n.stopGenerating,this._renderSendButtonIcon("stop")}hideStopButton(){this._sendStopHandler=null,this.sendBtn.classList.remove("gengage-chat-send--stop","gds-btn-secondary"),this.sendBtn.classList.add("gds-btn-primary"),this.sendBtn.setAttribute("aria-label",this.i18n.sendButton),this.sendBtn.dataset.tooltip=this.i18n.sendButton,this._renderSendButtonIcon("send"),this._updateSendEnabled()}showError(e,t){const a=document.createElement("div");a.className="gengage-chat-error",a.setAttribute("role","alert");const n=document.createElement("span");if(n.textContent=e??this.i18n.errorMessage,a.appendChild(n),t){const r=document.createElement("button");r.className="gengage-chat-error-retry",r.textContent=this.i18n.retryButton??"Retry",r.addEventListener("click",()=>{a.remove(),t()}),a.appendChild(r)}this.messagesEl.appendChild(a),this._scrollToBottom(!0)}showErrorWithRecovery(e,t){this.showError(e),this.setRecoveryPills(t)}showRecoveryPillsOnly(e){this.setRecoveryPills(e)}setRecoveryPills(e){this.setPills([{label:this.i18n.tryAgainButton,onAction:e.onRetry},{label:this.i18n.askSomethingElseButton,onAction:e.onNewQuestion}])}clearMessages(){const e=this._formerMessagesBtn;for(const t of[...this.messagesEl.children])t!==e&&t.remove()}setPills(e){const t=this._pillsEl.querySelector(".gengage-chat-pills-scroll");if(!t)return;for(;t.firstChild;)t.removeChild(t.firstChild);if(e.length===0){this._pillsEl.style.display="none";return}this._pillsEl.style.display="";for(const n of e){const r=document.createElement("button");if(r.className=n.image?"gengage-chat-pill gds-chip gds-chip-active gengage-chat-pill--rich":"gengage-chat-pill gds-chip gds-chip-active",r.type="button",n.icon){const o=Qa[n.icon]??'<svg viewBox="0 0 16 16" class="gengage-chat-icon"><path d="M3 8h10M9 4l4 4-4 4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',s=document.createElement("span");s.className="gengage-chat-pill-icon",s.innerHTML=o,r.appendChild(s)}if(n.image&&Pe(n.image)){const o=document.createElement("img");o.className="gengage-chat-pill-img",o.src=n.image,o.alt="",r.appendChild(o)}const i=document.createElement("span");if(i.className="gengage-chat-pill-text",i.textContent=n.label,r.appendChild(i),n.description){const o=document.createElement("span");o.className="gengage-chat-pill-desc";const s=`pill-desc-${Math.random().toString(36).slice(2,9)}`;o.id=s,o.textContent=n.description,r.appendChild(o),r.setAttribute("aria-describedby",s)}r.addEventListener("click",()=>n.onAction()),t.appendChild(r)}const a=this._pillsEl.querySelector(".gengage-chat-pills-arrow");a&&requestAnimationFrame(()=>{a.style.display=t.scrollWidth>t.clientWidth?"":"none"})}focusInput(){this.inputEl.focus()}showKvkkBanner(e,t){this._kvkkSlot.innerHTML="";const a=ls({htmlContent:e,onDismiss:t,closeAriaLabel:this.i18n.closeAriaLabel});this._kvkkSlot.appendChild(a)}hideKvkkBanner(){this._kvkkSlot.innerHTML=""}isKvkkBannerVisible(){return this._kvkkSlot.childNodes.length>0}getElement(){return this.root}openAttachmentPicker(){this._fileInput.click()}setAttachmentControlsVisible(e){this._attachWrapEl&&(this._attachWrapEl.style.display=e?"":"none",e||this._closeAttachMenu())}setBeautyPhotoStepCard(e){this._beautyPhotoStepEl=us(this._beautyPhotoStepEl,this._conversationEl??null,e,this.i18n,()=>this.openAttachmentPicker())}stageAttachment(e){this._pendingAttachment=e,this._previewName.textContent=e.name;const t=this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");t&&(t.src&&t.src.startsWith("blob:")&&URL.revokeObjectURL(t.src),t.src=URL.createObjectURL(e)),this._previewStrip.classList.remove("gengage-chat-attachment-preview--hidden"),this._updateSendEnabled()}clearAttachment(){const e=this._previewStrip.querySelector(".gengage-chat-attachment-preview-thumb");e?.src&&(URL.revokeObjectURL(e.src),e.src=""),this._pendingAttachment=null,this._previewStrip.classList.add("gengage-chat-attachment-preview--hidden"),this._updateSendEnabled()}_routeAttachmentFile(e){if(this._onAttachment)try{this._onAttachment(e)}catch(t){console.error("[gengage:chat] Attachment callback error:",t)}else this.stageAttachment(e)}_closeAttachMenu(){this._attachMenuEl&&(this._attachMenuEl.setAttribute("hidden",""),this._attachBtn?.setAttribute("aria-expanded","false"),this._attachMenuClickTimerId!==null&&(clearTimeout(this._attachMenuClickTimerId),this._attachMenuClickTimerId=null),this._attachMenuCleanup&&(this._attachMenuCleanup(),this._attachMenuCleanup=null))}_openAttachMenu(){if(!this._attachMenuEl)return;this._attachMenuEl.removeAttribute("hidden"),this._attachBtn?.setAttribute("aria-expanded","true");const e=a=>{this._attachWrapEl?.contains(a.target)||this._closeAttachMenu()},t=a=>{a.key==="Escape"&&(a.stopPropagation(),this._closeAttachMenu())};this._attachMenuClickTimerId=window.setTimeout(()=>{this._attachMenuClickTimerId=null,document.addEventListener("click",e,!0)},0),document.addEventListener("keydown",t,!0),this._attachMenuCleanup=()=>{document.removeEventListener("click",e,!0),document.removeEventListener("keydown",t,!0)}}_toggleAttachMenu(){this._attachMenuEl&&(this._attachMenuEl.hasAttribute("hidden")?this._openAttachMenu():this._closeAttachMenu())}async _pasteImageFromClipboardMenu(e){const t=await ws(e);if(t){this._routeAttachmentFile(t),this._closeAttachMenu();return}Te("gengage:global:error",{message:this.i18n.clipboardNoImageMessage,source:"chat"}),this._closeAttachMenu()}getPendingAttachment(){return this._pendingAttachment}setPanelAiZoneState(e,t){if(this._panelAiZoneEl.isConnected&&(this._clearPanelAiZoneState(),e!=="hidden"))if(this._panelAiZoneEl.removeAttribute("hidden"),e==="analyzing"){this._panelAiZoneEl.innerHTML="";const a=[t?.analyzingLabel??this.i18n.aiAnalysisAnalyzingLabel,...this.i18n.loadingSequencePanel],{root:n,binding:r}=this._createLoadingSequence("panel",this._thinkingSteps.length>0?this._thinkingSteps.slice(-3):a,"panel-ai-zone-loading","gengage-chat-panel-ai-zone-inner");this._panelAiZoneLoadingBinding=r,this._panelAiZoneEl.appendChild(n)}else e==="results"&&t?.resultEl&&(this._panelAiZoneEl.innerHTML="",this._panelAiZoneEl.appendChild(t.resultEl))}_clearPanelAiZoneState(){this._destroyLoadingBinding(this._panelAiZoneLoadingBinding),this._panelAiZoneLoadingBinding=null,this._panelAiZoneEl.innerHTML="",this._panelAiZoneEl.setAttribute("hidden","")}_resetPanelAiZoneElement(){this._panelAiZoneEl=document.createElement("div"),this._panelAiZoneEl.className="gengage-chat-panel-ai-zone",this._panelAiZoneEl.setAttribute("hidden","")}_emitHostShellSync(){this._onHostShellSync?.()}_syncPanelTopBarFromContent(e){const t=e.querySelector(".gengage-chat-product-grid-head");if(t){const a=t.querySelector(".gengage-chat-product-grid-head-title"),n=t.querySelector(".gengage-chat-product-grid-head-actions");if(a?.textContent?.trim()){const r=a.textContent.trim();e.dataset.gengagePanelDerivedTitle=r,this._panelTopBar.setTitle(r)}n?(n.classList.add("gengage-chat-panel-topbar-toolbar-host"),this._panelTopBar.setActions(n)):this._panelTopBar.setActions(null),t.remove();return}this._syncPanelTopBarTitleFromContent(e)}_syncPanelTopBarTitleFromContent(e){const t=e.dataset.gengagePanelDerivedTitle;if(t?.trim()){this._panelTopBar.setTitle(t.trim());return}const a=e.querySelector(".gengage-chat-product-details-title, .gengage-chat-product-details-similars-heading, .gengage-chat-ai-top-picks-title")?.textContent?.trim();a&&this._panelTopBar.setTitle(a)}setPanelContent(e,t){this._destroyLoadingBinding(this._panelLoadingBinding),this._panelLoadingBinding=null,t?.preserveAiZone!==!0&&this._clearPanelAiZoneState(),this._panelVisible?this._swapPanelContent(e):(this._panelEl.innerHTML="",this._resetPanelAiZoneElement(),this._panelEl.appendChild(this._panelTopBar.getElement()),this._panelEl.appendChild(this._panelAiZoneEl),this._panelTopBar.setActions(null),this._panelEl.appendChild(e),this._panelEl.appendChild(this._thumbnailsColumn.getElement()),this._panelEl.appendChild(this._panelFloatingEl)),this._syncPanelTopBarFromContent(e),this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel"),this._panelCollapsed&&this._panelEl.classList.add("gengage-chat-panel--collapsed"),this._syncDividerPreview(),requestAnimationFrame(()=>{this._updateScrollAffordance(),this._smoothScrollPanelListToTop()}),this._reopenPanelBtn&&(this._reopenPanelBtn.style.display="none"),this._emitHostShellSync()}_swapPanelContent(e){this._panelTopBar.setActions(null);const t=this._panelEl.querySelector(".gengage-chat-panel-skeleton");if(t){t.replaceWith(e);return}const a=this.getPanelContentElement();if(a){a.replaceWith(e);return}const n=this._thumbnailsColumn.getElement();n.parentElement===this._panelEl?this._panelEl.insertBefore(e,n):this._panelEl.appendChild(e)}appendPanelContent(e){const t=this._thumbnailsColumn.getElement(),a=t.parentElement===this._panelEl?t:this._panelFloatingEl;this._panelEl.insertBefore(e,a),this._syncPanelTopBarFromContent(this.getPanelContentElement()??e),this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel"),this._syncDividerPreview(),this._emitHostShellSync()}getPanelContentElement(){const e=this._panelEl.children;for(let t=0;t<e.length;t++){const a=e[t];if(!(a.classList.contains("gengage-chat-panel-topbar")||a.classList.contains("gengage-chat-panel-ai-zone")||a.classList.contains("gengage-chat-thumbnails-column")||a.classList.contains("gengage-chat-panel-float")))return a}return null}resyncPanelTopBarFromCurrentContent(){const e=this.getPanelContentElement();e&&this._syncPanelTopBarFromContent(e)}isPanelVisible(){return this._panelVisible}hasPanelContent(){return this._panelVisible&&this.getPanelContentElement()!==null}isPanelLoading(){return this._panelEl.querySelector(".gengage-chat-panel-skeleton")!==null}showPanelLoading(e){this._destroyLoadingBinding(this._panelLoadingBinding),this._panelLoadingBinding=null,this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._panelEl.innerHTML="",this._resetPanelAiZoneElement(),this._panelEl.appendChild(this._panelTopBar.getElement()),this._panelEl.appendChild(this._panelAiZoneEl);const t=document.createElement("div");t.className="gengage-chat-panel-skeleton";const a=e==="comparisonTable"?this.i18n.loadingSequenceComparison:this.i18n.loadingSequencePanel,{root:n,binding:r}=this._createLoadingSequence("panel",this._thinkingSteps.length>0?this._thinkingSteps.slice(-3):a,"panel-loading-status","gengage-chat-panel-loading-status");switch(this._panelLoadingBinding=r,e){case"productDetails":{t.appendChild(n);const i=document.createElement("div");i.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--image",t.appendChild(i);for(let o=0;o<3;o++){const s=document.createElement("div");s.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--text",t.appendChild(s)}break}case"productList":case"groupList":{t.appendChild(n);const i=document.createElement("div");i.className="gengage-chat-panel-skeleton-grid";for(let o=0;o<6;o++){const s=document.createElement("div");s.className="gengage-chat-panel-skeleton-block gengage-chat-panel-skeleton-block--card",i.appendChild(s)}t.appendChild(i);break}case"comparisonTable":{t.classList.add("gengage-chat-panel-skeleton--comparison"),t.appendChild(n);const i=document.createElement("div");i.className="gengage-chat-comparison gengage-chat-comparison--skeleton",i.setAttribute("aria-busy","true");const o=document.createElement("div");o.className="gengage-chat-comparison-recommended";const s=document.createElement("div");s.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-rec-label",o.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-comparison-recommended-body";const l=document.createElement("div");l.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-rec-img",l.setAttribute("aria-hidden","true");const g=document.createElement("div");g.className="gengage-chat-comparison-recommended-info";for(let T=0;T<2;T++){const I=document.createElement("div");I.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-rec-title",T===1&&I.classList.add("gengage-chat-comparison-skeleton-rec-title--short"),g.appendChild(I)}const p=document.createElement("div");p.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-rec-price",g.appendChild(p),c.appendChild(l),c.appendChild(g),o.appendChild(c);const h=document.createElement("div");h.className="gengage-chat-comparison-highlights";const d=document.createElement("div");d.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-hl-label",h.appendChild(d);const b=document.createElement("ul");b.className="gengage-chat-comparison-skeleton-hl-list";for(let T=0;T<3;T++){const I=document.createElement("li"),$=document.createElement("div");$.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-hl-line",T===1&&$.classList.add("gengage-chat-comparison-skeleton-hl-line--medium"),T===2&&$.classList.add("gengage-chat-comparison-skeleton-hl-line--short"),I.appendChild($),b.appendChild(I)}h.appendChild(b),o.appendChild(h),i.appendChild(o);const u=document.createElement("div");u.className="gengage-chat-comparison-key-differences";const v=document.createElement("div");v.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-kd-heading",u.appendChild(v);const m=document.createElement("div");m.className="gengage-chat-comparison-key-differences-content";for(let T=0;T<4;T++){const I=document.createElement("div");I.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-kd-line",m.appendChild(I)}u.appendChild(m),i.appendChild(u);const P=document.createElement("div");P.className="gengage-chat-comparison-special gengage-chat-comparison-special--skeleton";const A=document.createElement("div");A.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-special-line",P.appendChild(A),i.appendChild(P);const k=document.createElement("div");k.className="gengage-chat-comparison-skeleton-table-wrap";const x=document.createElement("div");x.className="gengage-chat-comparison-skeleton-table-head";const N=document.createElement("div");N.className="gengage-chat-comparison-skeleton-table-corner",x.appendChild(N);for(let T=0;T<3;T++){const I=document.createElement("div");I.className="gengage-chat-comparison-skeleton-table-col";const $=document.createElement("div");$.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-img";const ae=document.createElement("div");ae.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-name";const oe=document.createElement("div");oe.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-th-price",I.appendChild($),I.appendChild(ae),I.appendChild(oe),x.appendChild(I)}k.appendChild(x);for(let T=0;T<3;T++){const I=document.createElement("div");I.className="gengage-chat-comparison-skeleton-table-row";const $=document.createElement("div");$.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-label",I.appendChild($);for(let ae=0;ae<3;ae++){const oe=document.createElement("div");oe.className="gengage-chat-comparison-skeleton-shimmer gengage-chat-comparison-skeleton-table-cell",I.appendChild(oe)}k.appendChild(I)}i.appendChild(k),t.appendChild(i);break}default:t.appendChild(n);for(let i=0;i<3;i++){const o=document.createElement("div");o.className="gengage-chat-panel-skeleton-block",t.appendChild(o)}break}this._panelEl.appendChild(t),this._panelEl.appendChild(this._thumbnailsColumn.getElement()),this._panelEl.appendChild(this._panelFloatingEl),this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel"),this._syncDividerPreview(),this._emitHostShellSync()}updatePanelTopBar(e,t,a){const n=this._options.getMobileViewport?.()??!1;this._panelTopBar.update(n?!0:e,t,a);const r=this.getPanelContentElement();r&&this._syncPanelTopBarTitleFromContent(r)}getPanelTopBarTitle(){return this._panelTopBar.getTitle()}updateFavoritesBadge(e){this._favBadgeEl&&(e>0?(this._favBadgeEl.textContent=e>99?"99+":String(e),this._favBadgeEl.style.display=""):this._favBadgeEl.style.display="none")}clearPanel(){this._destroyLoadingBinding(this._panelLoadingBinding),this._panelLoadingBinding=null,this._destroyLoadingBinding(this._panelAiZoneLoadingBinding),this._panelAiZoneLoadingBinding=null,this._panelEl.innerHTML="",this._resetPanelAiZoneElement(),this._panelEl.appendChild(this._panelTopBar.getElement()),this._panelEl.appendChild(this._panelAiZoneEl),this._panelEl.appendChild(this._thumbnailsColumn.getElement()),this._panelEl.appendChild(this._panelFloatingEl),this._panelTopBar.setActions(null),this._panelVisible=!1,this._panelEl.classList.remove("gengage-chat-panel--visible","gengage-chat-panel--collapsed"),this.root.classList.remove("gengage-chat-drawer--with-panel"),this._dividerEl.classList.add("gengage-chat-panel-divider--hidden"),this._dividerPreviewEnabled=!1,this._syncDividerPreview(),this._reopenPanelBtn&&(this._reopenPanelBtn.style.display="none"),this.setComparisonDockContent(null),this._emitHostShellSync()}setComparisonDockContent(e){this._comparisonDockSlotEl.replaceChildren(),e&&this._comparisonDockSlotEl.appendChild(e)}hideMobilePanel(){this._panelVisible&&(this._panelVisible=!1,this._panelEl.classList.remove("gengage-chat-panel--visible"),this._reopenPanelBtn&&(this._reopenPanelBtn.style.display="flex"),this._emitHostShellSync())}_showMobilePanelFromBtn(){this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this._reopenPanelBtn&&(this._reopenPanelBtn.style.display="none"),this._emitHostShellSync())}expandPanel(){this._panelCollapsed=!1,this._panelEl.classList.remove("gengage-chat-panel--collapsed"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel")),this._syncDividerPreview(),this._emitHostShellSync()}setForceExpanded(){this._panelCollapsed=!1,this._panelEl.classList.remove("gengage-chat-panel--collapsed"),this._panelVisible||(this._panelVisible=!0,this._panelEl.classList.add("gengage-chat-panel--visible"),this.root.classList.add("gengage-chat-drawer--with-panel")),this._dividerEl.classList.remove("gengage-chat-panel-divider--hidden"),this._syncDividerPreview(),this._emitHostShellSync()}_smoothScrollPanelListToTop(){this._panelEl.scrollTop=0}_updateScrollAffordance(){const e=this._panelEl,t=e.scrollTop+e.clientHeight>=e.scrollHeight-10;e.classList.toggle("gengage-chat-panel--has-scroll",!t&&e.scrollHeight>e.clientHeight),e.classList.toggle("gengage-chat-panel--scrolled",e.scrollTop>88)}_setupHorizontalSwipe(e){let t=0,a=0;const n=i=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768))return;const o=i.touches[0];o&&(t=o.clientX,a=o.clientY)},r=i=>{if(!(this._options.getMobileViewport?.()??window.innerWidth<=768))return;const o=i.changedTouches[0];if(!o)return;const s=o.clientX-t,c=o.clientY-a;Math.abs(s)>50&&Math.abs(s)>Math.abs(c)*2&&(this.togglePanel(),this._onPanelToggle?.())};e.addEventListener("touchstart",n,{passive:!0}),e.addEventListener("touchend",r,{passive:!0}),this._cleanups.push(()=>{e.removeEventListener("touchstart",n),e.removeEventListener("touchend",r)})}togglePanel(){this.setPanelCollapsed(!this._panelCollapsed)}isPanelCollapsed(){return this._panelCollapsed}setPanelCollapsed(e){this._panelCollapsed=e,e?this._panelEl.classList.add("gengage-chat-panel--collapsed"):this._panelEl.classList.remove("gengage-chat-panel--collapsed");const t=this._dividerEl.querySelector(".gengage-chat-panel-divider-toggle");t&&(t.textContent=e?"«":"»"),this._syncDividerPreview(),this._emitHostShellSync()}setDividerPreviewEnabled(e){this._dividerPreviewEnabled=e,this._syncDividerPreview()}persistPanelState(e){try{const t=`gengage:panel:${e}`;this._panelCollapsed?sessionStorage.setItem(t,"collapsed"):sessionStorage.removeItem(t)}catch{}}restorePanelState(e){try{const t=`gengage:panel:${e}`;if(sessionStorage.getItem(t)==="collapsed")return this._panelCollapsed=!0,!0}catch{}return!1}_createLoadingSequence(e,t,a,n){const r=document.createElement("div");r.className=`${n} gds-progress-loader ${e==="chat"?"gds-progress-loader-chat":"gds-progress-loader-panel"}`,r.dataset.gengagePart=a,r.setAttribute("role","status"),r.setAttribute("aria-live","polite");const i=document.createElement("span");i.className=e==="chat"?"gengage-chat-typing-text gds-progress-label":"gengage-chat-panel-loading-label gds-progress-label",r.appendChild(i);const o=document.createElement("span");o.className=e==="chat"?"gengage-chat-typing-dots gds-progress-dots":"gds-progress-dots",o.setAttribute("aria-hidden","true");for(let c=0;c<3;c++){const l=document.createElement("span");l.className="gds-progress-dot",o.appendChild(l)}r.appendChild(o);const s={labelEl:i,steps:[],index:0,intervalId:null};return this._applyLoadingSteps(s,t),{root:r,binding:s}}_applyLoadingSteps(e,t,a=!1){const n=t.map(i=>i.trim()).filter(Boolean).slice(-3),r=[this.i18n.loadingMessage];e.steps=n.length>0?n:r,this._clearLoadingBindingInterval(e),e.index=a?e.steps.length-1:0,e.labelEl.textContent=e.steps[e.index],!a&&e.steps.length>1&&(e.intervalId=setInterval(()=>{if(e.index>=e.steps.length-1){this._clearLoadingBindingInterval(e);return}e.index+=1,e.labelEl.textContent=e.steps[e.index],e.index>=e.steps.length-1&&this._clearLoadingBindingInterval(e)},ys))}_clearLoadingBindingInterval(e){e?.intervalId&&(clearInterval(e.intervalId),e.intervalId=null)}_destroyLoadingBinding(e){this._clearLoadingBindingInterval(e)}_updateSendEnabled(){if(this._sendStopHandler){this.sendBtn.disabled=!1;return}const e=this.inputEl.value.trim().length>0||this._pendingAttachment!==null;this.sendBtn.disabled=!e}_renderSendButtonIcon(e){this.sendBtn.innerHTML=e==="stop"?'<span class="gengage-chat-send-stop-icon" aria-hidden="true"></span>':'<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"/></svg>'}_submit(){const e=this.inputEl.value.trim(),t=this._pendingAttachment;if(this._sendStopHandler){const a=this._sendStopHandler;if(this.hideStopButton(),a(),!e&&!t)return}else if(!e&&!t)return;this.onSend(e,t??void 0),this.inputEl.value="",this.inputEl.style.height="auto",this.clearAttachment(),this._updateSendEnabled()}_toggleVoice(){if(this._voiceInput)if(this._voiceInput.state==="listening"){const e=this._voiceInput.stop();e.trim()&&(this.inputEl.value=e,this._submit())}else this.inputEl.value="",this._voiceInput.start()}lockScrollForRestore(){this._scrollLockedUntil=Date.now()+500}_scrollToBottom(e=!1){!e&&this._userScrolledUp||!e&&this._options.presentation?.shouldBlockSoftAutoScroll?.()||!e&&Date.now()<this._scrollLockedUntil||requestAnimationFrame(()=>{this.messagesEl.scrollTop=this.messagesEl.scrollHeight,this._userScrolledUp=!1})}scrollToBottomIfNeeded(){this._scrollToBottom(!1)}updateBotMessage(e,t,a,n){const r=this.messagesEl.querySelector(`[data-message-id="${_e(e)}"]`);if(!r)return;let i=r.querySelector(".gengage-chat-bubble-text");i||(i=document.createElement("div"),i.className="gengage-chat-bubble-text",r.appendChild(i)),a==="photo_analysis"?(r.classList.add("gengage-chat-bubble--photo-analysis"),this._renderPhotoAnalysisCard(i,n)):(r.classList.remove("gengage-chat-bubble--photo-analysis"),i.innerHTML=Ae(t)),this._scrollToBottom(!1)}markFirstBotMessage(e){this._firstBotMessageIds.add(e);const t=this.messagesEl.querySelector(`[data-message-id="${_e(e)}"]`);t&&t.classList.add("gengage-chat-bubble--first")}scrollToLastThread(){const e=this.messagesEl.querySelectorAll("[data-thread-id]");if(e.length===0){this._scrollToBottom(!0);return}const t=e[e.length-1].getAttribute("data-thread-id");if(!t){this._scrollToBottom(!0);return}this._programmaticScrollUntil=Date.now()+700;const a=this.messagesEl.querySelector(`[data-thread-id="${_e(t)}"]`);a?requestAnimationFrame(()=>{a.scrollIntoView({block:"start",behavior:"auto"}),this._userScrolledUp=!1}):this._scrollToBottom(!0)}scrollThreadIntoView(e,t="smooth"){const a=this.messagesEl.querySelectorAll(`[data-thread-id="${_e(e)}"]`);let n=null,r=null;for(let s=0;s<a.length;s++){const c=a[s];if(c instanceof HTMLElement&&(r||(r=c),!c.classList.contains("gengage-chat-bubble--presentation-collapsed")&&!c.classList.contains("gengage-chat-bubble--hidden")&&c.offsetHeight!==0&&!(c.classList.contains("gengage-chat-bubble--assistant")&&(c.textContent?.trim().length??0)===0))){n=c;break}}if(n||(n=r),!n)return!1;const i=Date.now();this._programmaticScrollUntil=i+en,this._scrollLockedUntil=Math.max(this._scrollLockedUntil,i+en),this._userScrolledUp=!0;const o=()=>{this._scrollMessagesTo(Math.max(n.offsetTop-20,0),t)};return o(),requestAnimationFrame(o),!0}scrollToBottomPresentation(e="smooth"){this._programmaticScrollUntil=Date.now()+700,requestAnimationFrame(()=>{this._scrollMessagesTo(this.messagesEl.scrollHeight,e),this._userScrolledUp=!1})}_scrollMessagesTo(e,t){if(typeof this.messagesEl.scrollTo=="function"){this.messagesEl.scrollTo({top:e,behavior:t});return}this.messagesEl.scrollTop=e}setPresentationFocus(e){this._presentationFocusThreadId=e,this._applyPresentationCollapsed()}setFormerMessagesButtonVisible(e){this._formerMessagesBtn&&(this._formerMessagesBtn.style.display=e?"":"none")}setInputPlaceholder(e){this.inputEl.placeholder=e}_applyPresentationCollapsed(){const e=this._presentationFocusThreadId;this.messagesEl.querySelectorAll("[data-thread-id]").forEach(t=>{const a=t.dataset.threadId;a&&(e&&a!==e?t.classList.add("gengage-chat-bubble--presentation-collapsed"):t.classList.remove("gengage-chat-bubble--presentation-collapsed"))})}refreshPresentationCollapsed(){this._presentationFocusThreadId&&this._applyPresentationCollapsed()}setInputAreaChips(e){if(this._inputChipsEl.innerHTML="",e.length===0){this._inputChipsEl.style.display="none";return}this._inputChipsEl.style.display="";for(const t of e){const a=document.createElement("button");if(a.className="gengage-chat-input-chip gds-chip",a.type="button",t.icon){const r=Qa[t.icon]??'<svg viewBox="0 0 16 16" class="gengage-chat-icon"><path d="M3 8h10M9 4l4 4-4 4" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>',i=document.createElement("span");i.className="gengage-chat-input-chip-icon",i.innerHTML=r,a.appendChild(i)}const n=document.createElement("span");n.textContent=t.label,a.appendChild(n),a.addEventListener("click",()=>t.onAction()),this._inputChipsEl.appendChild(a)}}clearInputAreaChips(){this._inputChipsEl.innerHTML="",this._inputChipsEl.style.display="none"}setThumbnails(e){this._thumbnailsColumn.setEntries(e),e.length>0?this._thumbnailsColumn.show():this._thumbnailsColumn.hide(),this._renderDividerPreview(e),this._syncDividerPreview()}hideThumbnails(){this._thumbnailsColumn.hide(),this._renderDividerPreview([]),this._syncDividerPreview()}_renderDividerPreview(e){this._dividerPreviewEl.innerHTML="";const t=new Set,a=[];for(let n=e.length-1;n>=0;n--){const r=e[n];if(!(!r||t.has(r.sku)||!Pe(r.imageUrl))&&(t.add(r.sku),a.push(r),a.length>=3))break}a.reverse();for(const n of a){const r=document.createElement("span");r.className="gengage-chat-panel-divider-preview-thumb";const i=document.createElement("img");i.className="gengage-chat-panel-divider-preview-img",i.src=n.imageUrl,i.alt="",i.width=48,i.height=48,r.appendChild(i),this._dividerPreviewEl.appendChild(r)}}_syncDividerPreview(){const e=this._dividerPreviewEl.childElementCount>0,t=this._dividerPreviewEnabled&&e&&this._panelCollapsed&&!this._dividerEl.classList.contains("gengage-chat-panel-divider--hidden");this._dividerEl.classList.toggle("gengage-chat-panel-divider--preview-active",t)}trapFocus(){this._previouslyFocusedElement=document.activeElement,this.releaseFocus();const e=t=>{if(t.key!=="Tab")return;const a=Array.from(this.root.querySelectorAll('a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter(l=>{const g=getComputedStyle(l);return l.hidden||l.getAttribute("aria-hidden")==="true"||g.display==="none"||g.visibility==="hidden"?!1:l.getClientRects().length>0});if(a.length===0)return;const n=a[0],r=a[a.length-1],i=t.composedPath().find(l=>l instanceof HTMLElement&&this.root.contains(l))??null,o=this.root.getRootNode(),s=i??(o instanceof ShadowRoot&&o.activeElement instanceof HTMLElement?o.activeElement:document.activeElement instanceof HTMLElement?document.activeElement:null),c=s&&this.root.contains(s)?s:null;t.shiftKey?(c===n||!this.root.contains(c))&&(t.preventDefault(),r.focus()):(c===r||!this.root.contains(c))&&(t.preventDefault(),n.focus())};this._focusTrapHandler=e,this.root.addEventListener("keydown",e)}releaseFocus(){if(this._focusTrapHandler&&(this.root.removeEventListener("keydown",this._focusTrapHandler),this._focusTrapHandler=null),this._previouslyFocusedElement){try{this._previouslyFocusedElement.focus()}catch{}this._previouslyFocusedElement=null}}flashCartBadge(){this._cartBtn&&(this._cartBtn.classList.remove("gengage-chat-header-btn--cart-flash"),this._cartBtn.offsetWidth,this._cartBtn.classList.add("gengage-chat-header-btn--cart-flash"),this._cartBtn.addEventListener("animationend",()=>{this._cartBtn?.classList.remove("gengage-chat-header-btn--cart-flash")},{once:!0}))}showCartToast(e){this.root.querySelector(".gengage-chat-cart-toast")?.remove();const t=document.createElement("div");t.className="gengage-chat-cart-toast",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.textContent=e,this.root.appendChild(t),t.offsetWidth,t.classList.add("gengage-chat-cart-toast--visible"),setTimeout(()=>{t.classList.remove("gengage-chat-cart-toast--visible"),setTimeout(()=>t.remove(),300)},2500)}destroy(){Va(null),this.releaseFocus(),this._resizeRafId!==null&&(cancelAnimationFrame(this._resizeRafId),this._resizeRafId=null),this._destroyLoadingBinding(this._typingLoadingBinding),this._typingLoadingBinding=null,this._destroyLoadingBinding(this._panelLoadingBinding),this._panelLoadingBinding=null,this._destroyLoadingBinding(this._panelAiZoneLoadingBinding),this._panelAiZoneLoadingBinding=null,this._closeAttachMenu();for(const e of this._cleanups)e();this._cleanups.length=0,this._voiceInput?.destroy(),this._voiceInput=null}},tn=["beauty_consulting","watch_expert","booking"],Cs=["shopping",...tn];function Ss(e){return typeof e=="string"&&Cs.includes(e)?e:null}function Yt(e){return e==null||typeof e!="object"||Array.isArray(e)?null:e}function Es(...e){for(const t of e)if(typeof t=="string"){const a=t.trim();if(a.length>0)return a}}function Ps(e){const t=Yt(e);if(!t)return null;const a=Es(t.assistant_mode,t.assistantMode);return!a||!tn.includes(a)?null:a}var As=class{constructor(){this._mode="shopping",this._uiHints=null}get mode(){return this._mode}set mode(e){this._mode=e}get uiHints(){return this._uiHints}set uiHints(e){this._uiHints=e}get isShopping(){return this._mode==="shopping"}get isBeautyConsulting(){return this._mode==="beauty_consulting"}get isChoicePrompterHidden(){return this._uiHints?.hide_choice_prompter===!0}applyUiHints(e,t,a){const n=i=>this._uiHints?.[i]===!0;e?.setAttachmentControlsVisible(!n("hide_attachment_controls")),n("hide_choice_prompter")&&a?.();const r=typeof this._uiHints?.input_placeholder=="string"?this._uiHints.input_placeholder:void 0;r?e?.setInputPlaceholder(r):e?.setInputPlaceholder(t)}handleRedirect(e){De("mode","redirect metadata received",e);const t=Ps(e);return t?(this.switchMode(t),!0):!1}switchMode(e){const t=this._mode;this._mode=e,De("mode","assistant mode switched",{from:t,to:e})}updateFromContext(e){const t=e.assistant_mode;if(typeof t=="string"&&t){const a=Ss(t);a?this._mode=a:De("mode","ignoring unrecognised assistant_mode from context",t)}else t===null&&(this._mode="shopping");this._uiHints=Yt(e.ui_hints)??null}reset(){const e=this._mode!=="shopping";return this._mode="shopping",this._uiHints=null,e}resolveAttachmentActionType(){return this._mode==="beauty_consulting"?"user_message":"findSimilar"}shouldCondenseThinking(){return this._mode!=="shopping"}};function Ts(){return{streamIncludedBeautyPhotoStep:!1,pendingPhotoStepSkip:!1}}function Ls(e,t,a,n,r){if(e==="PhotoAnalysisCard"){const i=Ya(t);return i?(r.photoAnalysis=i,r.renderHint="photo_analysis",n.ensureRendered(),n.cancelTypewriter(),n.drawer?.updateBotMessage(r.id,r.content??"","photo_analysis",r.photoAnalysis),!0):(De("beauty","PhotoAnalysisCard parse failed, falling through to generic renderer",t),!1)}if(e==="BeautyPhotoStep"){a.streamIncludedBeautyPhotoStep=!0;const i=ps(t);return n.drawer?.setBeautyPhotoStepCard({visible:!0,...i,onSkip:()=>{n.drawer?.setBeautyPhotoStepCard({visible:!1}),n.streamDone?n.sendSkipMessage():a.pendingPhotoStepSkip=!0}}),!0}return!1}function Is(e){return e.renderHint==="photo_analysis"}function Ns(e,t){e.streamIncludedBeautyPhotoStep||t.drawer?.setBeautyPhotoStepCard({visible:!1}),e.pendingPhotoStepSkip&&(e.pendingPhotoStepSkip=!1,t.sendSkipMessage())}function zs(e,t){e.pendingPhotoStepSkip&&(e.pendingPhotoStepSkip=!1,t.sendSkipMessage())}function Jt(e){return Number.isFinite(e)?Math.max(0,Math.min(5,e)):0}function an(e){return Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function nn(e){const t=Jt(e),a=Math.floor(t),n=t-a>=.5,r=5-a-(n?1:0),i=document.createElement("span");if(i.className="gengage-star-rating",i.setAttribute("role","img"),i.setAttribute("aria-label",`${t.toFixed(1)} out of 5 stars`),a>0&&i.appendChild(document.createTextNode("★".repeat(a))),n){const o=document.createElement("span");o.className="gengage-star-half",o.textContent="☆";const s=document.createElement("span");s.textContent="★",o.appendChild(s),i.appendChild(o)}return r>0&&i.appendChild(document.createTextNode("☆".repeat(r))),i}function Ie(e){e.addEventListener("error",()=>{e.style.display="none"},{once:!0})}var Ms={currencyCode:"TRY",currencySymbol:"TL",currencyPosition:"suffix",thousandsSeparator:".",decimalSeparator:",",alwaysShowDecimals:!1};function J(e,t){const a=Number(e);if(!Number.isFinite(a)||a<0)return e;const n={...Ms,...t},r=Math.abs(a%1)<Number.EPSILON,i=n.alwaysShowDecimals||!r?a.toFixed(2):a.toFixed(0),o=i.indexOf("."),s=o===-1?i:i.slice(0,o),c=o===-1?void 0:i.slice(o+1),l=s.replace(/\B(?=(\d{3})+(?!\d))/g,n.thousandsSeparator);let g;return c!==void 0?g=`${l}${n.decimalSeparator}${c}`:g=l,n.currencySymbol?n.currencyPosition==="prefix"?`${n.currencySymbol}${g}`:`${g} ${n.currencySymbol}`:g}var Bs={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 Rs(e,t,a){return t?.[e]??Bs[e]??e.replace(/_/g," ").replace(/^./u,n=>Ds(n,a))}function Ds(e,t){try{return e.toLocaleUpperCase(wt(t))}catch{return e.toLocaleUpperCase("tr")}}function rn(e){if(typeof e!="string")return!1;const t=Number(e);return Number.isFinite(t)&&t>0}function Os(e){const t=typeof e=="number"?e:typeof e=="string"?Number(e):NaN;return Number.isFinite(t)&&t>0}function Fs(e){const t=typeof e=="number"?e:Number(e),a=document.createElement("div");a.className="gengage-chat-comparison-recommended-rating",a.innerHTML='<span class="gengage-chat-comparison-recommended-rating-icon" aria-hidden="true"><svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M12 3.6l2.58 5.23 5.77.84-4.17 4.07.98 5.75L12 16.78l-5.16 2.71.99-5.75L3.66 9.67l5.76-.84L12 3.6z"/></svg></span>';const n=document.createElement("span");return n.className="gengage-chat-comparison-recommended-rating-value",n.textContent=t.toFixed(1),a.appendChild(n),a}function $s(e){const{recommended:t,products:a,attributes:n,highlights:r,specialCases:i,onProductClick:o,i18n:s}=e,c=document.createElement("div");if(c.className="gengage-chat-comparison",c.dataset.gengagePart="comparison-dialog",c.setAttribute("role","dialog"),c.setAttribute("aria-label",s?.comparisonHeading??"Comparison Results"),t){const l=document.createElement("article");l.className="gengage-chat-comparison-recommended gds-card",l.dataset.gengagePart="comparison-recommended-card";const g=document.createElement("div");g.className="gengage-chat-comparison-recommended-label",g.textContent=s?.recommendedChoiceLabel??"Recommended Choice",l.appendChild(g);const p=document.createElement("div");p.className="gengage-chat-comparison-recommended-body",p.classList.add("gds-clickable"),p.tabIndex=0,p.setAttribute("role","button"),p.setAttribute("aria-label",t.name);const h=document.createElement("div");if(h.className="gengage-chat-comparison-recommended-media",t.imageUrl&&Pe(t.imageUrl)){const m=document.createElement("img");m.src=t.imageUrl,m.alt=t.name,m.loading="lazy",m.addEventListener("error",()=>{m.style.display="none"},{once:!0}),h.appendChild(m)}else{const m=document.createElement("div");m.className="gengage-chat-comparison-recommended-placeholder",m.setAttribute("aria-hidden","true"),h.appendChild(m)}p.appendChild(h);const d=document.createElement("div");d.className="gengage-chat-comparison-recommended-info";const b=document.createElement("div");b.className="gengage-chat-comparison-recommended-title",b.textContent=t.name,d.appendChild(b);const u=document.createElement("div");if(u.className="gengage-chat-comparison-recommended-meta",Os(t.rating)&&u.appendChild(Fs(t.rating)),rn(t.price)){const m=document.createElement("div");m.className="gengage-chat-comparison-recommended-price",m.textContent=J(t.price,e.pricing),u.appendChild(m)}if(u.childElementCount>0&&d.appendChild(u),e.recommendedText){const m=document.createElement("p");m.className="gengage-chat-comparison-recommended-text",m.innerHTML=Ae(e.recommendedText),d.appendChild(m)}p.appendChild(d);const v=()=>{o({sku:t.sku,name:t.name})};if(p.addEventListener("click",v),p.addEventListener("keydown",m=>{m.key!=="Enter"&&m.key!==" "||(m.preventDefault(),v())}),l.appendChild(p),r.length>0){const m=document.createElement("div");m.className="gengage-chat-comparison-highlights",m.dataset.gengagePart="comparison-highlights";const P=document.createElement("div");P.className="gengage-chat-comparison-highlights-label",P.textContent=s?.highlightsLabel??"Key Highlights",m.appendChild(P);const A=document.createElement("ul");for(const k of r){const x=document.createElement("li");x.textContent=k,A.appendChild(x)}m.appendChild(A),l.appendChild(m)}c.appendChild(l)}if(e.keyDifferencesHtml){const l=document.createElement("details");l.className="gengage-chat-comparison-key-differences",l.dataset.gengagePart="comparison-key-differences";const g=document.createElement("summary");g.className="gengage-chat-comparison-key-differences-summary";const p=document.createElement("span");p.className="gengage-chat-comparison-key-differences-summary-label",p.textContent=s?.keyDifferencesLabel??"Key Differences";const h=document.createElement("span");h.className="gengage-chat-comparison-key-differences-summary-meta",h.textContent=s?.viewMoreLabel??"Show More",g.appendChild(p),g.appendChild(h),l.appendChild(g);const d=document.createElement("div");d.className="gengage-chat-comparison-key-differences-content",d.innerHTML=Ae(Hs(e.keyDifferencesHtml)),l.appendChild(d),c.appendChild(l)}if(i&&i.length>0){const l=document.createElement("details");l.className="gengage-chat-comparison-special gds-evidence-card gds-evidence-card-warning",l.dataset.gengagePart="comparison-special-cases";const g=document.createElement("summary");g.textContent=s?.specialCasesLabel??"For Special Cases",l.appendChild(g);const p=document.createElement("ul");for(const h of i)Us(p,h);p.childElementCount>0&&l.appendChild(p),c.appendChild(l)}if(a.length>0&&n.length>0){const l=document.createElement("table");l.className="gengage-chat-comparison-table gds-comparison-table";const g=document.createElement("thead"),p=document.createElement("tr"),h=document.createElement("th");p.appendChild(h);for(const u of a){const v=document.createElement("th");u.sku===t?.sku&&(v.className="gengage-chat-comparison-selected gds-comparison-table-winner-cell");const m=document.createElement("div");m.className="gengage-chat-comparison-table-header-cell gengage-chat-comparison-table-header-cell--clickable gds-clickable",m.tabIndex=0,m.setAttribute("role","button"),m.setAttribute("aria-label",u.name),m.title=u.name;const P=()=>{o({sku:u.sku,name:u.name})};if(m.addEventListener("click",P),m.addEventListener("keydown",k=>{k.key!=="Enter"&&k.key!==" "||(k.preventDefault(),P())}),u.imageUrl&&Pe(u.imageUrl)){const k=document.createElement("img");k.src=u.imageUrl,k.alt=u.name,k.loading="lazy",k.addEventListener("error",()=>{k.style.display="none"},{once:!0}),m.appendChild(k)}else{const k=document.createElement("div");k.className="gengage-chat-comparison-table-header-img-placeholder",k.setAttribute("aria-hidden","true"),m.appendChild(k)}const A=document.createElement("div");if(A.className="gengage-chat-comparison-table-product-name",A.textContent=u.name,m.appendChild(A),rn(u.price)){const k=document.createElement("div");k.className="gengage-chat-comparison-table-price",k.textContent=J(u.price,e.pricing),m.appendChild(k)}v.appendChild(m),p.appendChild(v)}g.appendChild(p),l.appendChild(g);const d=document.createElement("tbody");for(const u of n){const v=document.createElement("tr"),m=document.createElement("td");m.className="gengage-chat-comparison-label",m.textContent=Rs(u.label,s?.criteriaLabels,e.locale),v.appendChild(m);for(let P=0;P<u.values.length;P++){const A=document.createElement("td");a[P]?.sku===t?.sku&&(A.className="gengage-chat-comparison-selected gds-comparison-table-winner-cell");const k=u.values[P]??"";on(k)?A.innerHTML=Ae(k):A.textContent=k,v.appendChild(A)}d.appendChild(v)}l.appendChild(d);const b=document.createElement("div");b.className="gengage-chat-comparison-table-wrapper",b.dataset.gengagePart="comparison-table-wrapper",b.appendChild(l),c.appendChild(b)}return c.addEventListener("keydown",l=>{if(l.key!=="Tab")return;const g=c.querySelectorAll('button, [href], input, [tabindex]:not([tabindex="-1"])');if(g.length===0)return;const p=g[0],h=g[g.length-1];l.shiftKey&&document.activeElement===p?(l.preventDefault(),h.focus()):!l.shiftKey&&document.activeElement===h&&(l.preventDefault(),p.focus())}),c}function Hs(e){if(/<[uo]l[\s>]/i.test(e)||/<li[\s>]/i.test(e))return e;const t=e.split(`
|
|
49
|
-
`).filter(a=>a.trim());return t.length<=1?e:"<ul>"+t.map(a=>`<li>${a.trim()}</li>`).join("")+"</ul>"}function Us(e,t){const a=Ae(t);if(!a)return;const n=document.createElement("template");n.innerHTML=a;const r=Array.from(n.content.querySelectorAll("li"));if(r.length>0){for(const o of r){const s=document.createElement("li");s.innerHTML=Ae(o.innerHTML),e.appendChild(s)}return}const i=document.createElement("li");on(t)?i.innerHTML=a:i.textContent=t,e.appendChild(i)}function on(e){return/<\/?[a-z][\s\S]*>/i.test(e)}function mt(e,t=18){const a="http://www.w3.org/2000/svg",n=document.createElementNS(a,"svg");n.setAttribute("width",String(t)),n.setAttribute("height",String(t)),n.setAttribute("viewBox","0 0 24 24"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","2"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.setAttribute("aria-hidden","true");for(const r of e){const i=document.createElementNS(a,"path");i.setAttribute("d",r),n.appendChild(i)}return n}var Xt="General",sn=220,js=6;function Zs(e){if(typeof e!="string")return[Xt];const t=e.split(/[,;|/]+/).map(a=>a.trim().replace(/\s+/g," ")).filter(a=>a.length>0);return t.length===0?[Xt]:Array.from(new Set(t.map(a=>a.toLocaleLowerCase()))).map(a=>t.find(n=>n.toLocaleLowerCase()===a)??Xt)}function qs(e){return e==="positive"||e==="negative"||e==="neutral"?e:"neutral"}function Vs(e){if(typeof e!="string")return"";const t=e.trim().replace(/\s+/g," ");return t.length<=sn?t:`${t.slice(0,sn-3).trimEnd()}...`}function Gs(e){return e.positive>e.negative?"positive":e.negative>e.positive?"negative":"neutral"}function Ws(e){return mt(e==="positive"?["M7 17 17 7","M7 7h10v10"]:e==="negative"?["M7 7 17 17","M17 7v10H7"]:["M5 12h14"],14)}function Ks(e,t="1 customer mentions",a="customers mention"){return e===1?t:`${e} ${a}`}function Ys(e,t){const a=document.createElement("div");a.className="gengage-chat-review-highlights";const n=e.props?.reviews;if(!Array.isArray(n)||n.length===0){const u=document.createElement("div");return u.className="gengage-chat-review-empty",u.textContent=t?.emptyReviewsMessage??"No review summary found.",a.appendChild(u),a}const r=n.filter(u=>u!==null&&typeof u=="object"),i=new Map;for(const u of r){const v=qs(u.review_class),m=Vs(u.review_text),P=Zs(u.review_tag);for(const A of P){const k=A.toLocaleLowerCase();let x=i.get(k);if(x||(x={key:k,label:A,mentions:0,positive:0,negative:0,neutral:0,snippets:[]},i.set(k,x)),x.mentions+=1,v==="positive"?x.positive+=1:v==="negative"?x.negative+=1:x.neutral+=1,m.length>0&&x.snippets.length<js&&!x.snippets.some(N=>N.text===m)){const N={text:m,tone:v};u.review_rating!==void 0&&String(u.review_rating).length>0&&(N.rating=u.review_rating),x.snippets.push(N)}}}const o=Array.from(i.values()).sort((u,v)=>v.mentions!==u.mentions?v.mentions-u.mentions:u.label.localeCompare(v.label));if(o.length===0){const u=document.createElement("div");return u.className="gengage-chat-review-empty",u.textContent=t?.emptyReviewsMessage??"No review summary found.",a.appendChild(u),a}const s=(t?.reviewFilterPositive??"positive").toLowerCase(),c=(t?.reviewFilterNegative??"negative").toLowerCase(),l=document.createElement("div");l.className="gengage-chat-review-subjects-heading",l.textContent=t?.reviewSubjectsHeading??"Select to learn more",a.appendChild(l);let g=o[0]?.key??null;const p=document.createElement("div");p.className="gengage-chat-review-subjects gds-toolbar gds-toolbar-compact";const h=document.createElement("section");h.className="gengage-chat-review-detail gds-evidence-card";const d=()=>{for(;h.firstChild;)h.removeChild(h.firstChild);if(!g)return;const u=o.find(A=>A.key===g);if(!u)return;const v=document.createElement("div");v.className="gengage-chat-review-detail-meta";const m=document.createElement("span");if(m.className="gengage-chat-review-detail-mentions",m.textContent=`${Ks(u.mentions,t?.reviewCustomersMentionSingular,t?.reviewCustomersMentionPlural)} "${u.label}"`,v.appendChild(m),u.positive>0){const A=document.createElement("span");A.className="gengage-chat-review-detail-positive",A.textContent=`${u.positive} ${s}`,v.appendChild(A)}if(u.negative>0){const A=document.createElement("span");A.className="gengage-chat-review-detail-negative",A.textContent=`${u.negative} ${c}`,v.appendChild(A)}h.appendChild(v);const P=document.createElement("div");P.className="gengage-chat-review-snippets";for(const A of u.snippets){const k=document.createElement("article");k.className="gengage-chat-review-snippet",k.dataset.tone=A.tone;const x=document.createElement("div");if(x.className="gengage-chat-review-snippet-text",x.textContent=`"${A.text}"`,k.appendChild(x),A.rating!==void 0&&String(A.rating).length>0){const N=document.createElement("div");N.className="gengage-chat-review-snippet-rating",N.textContent=`★ ${String(A.rating)}`,k.appendChild(N)}P.appendChild(k)}h.appendChild(P)},b=()=>{for(const u of p.querySelectorAll(".gengage-chat-review-subject")){const v=u.dataset.subjectKey===g;u.classList.toggle("gengage-chat-review-subject--active",v),u.classList.toggle("gds-chip-active",v),u.setAttribute("aria-pressed",String(v))}};for(const u of o){const v=Gs(u),m=document.createElement("button");m.type="button",m.className="gengage-chat-review-subject gds-chip",m.dataset.subjectKey=u.key,m.dataset.tone=v;const P=document.createElement("span");P.className="gengage-chat-review-subject-icon",P.appendChild(Ws(v)),m.appendChild(P);const A=document.createElement("span");A.className="gengage-chat-review-subject-label",A.textContent=u.label,m.appendChild(A);const k=document.createElement("span");k.className="gengage-chat-review-subject-count",k.textContent=`(${u.mentions})`,m.appendChild(k),m.addEventListener("click",()=>{g=u.key,b(),d()}),p.appendChild(m)}return a.appendChild(p),b(),d(),a.appendChild(h),a}function Js(e){if(!e)return;const t=e.discountReason??e.discount_reason??e.campaignReason??e.campaign_reason;if(typeof t!="string")return;const a=t.trim();return a.length>0?a:void 0}function at(e,t){if(e.productPriceUi?.showCampaignReason===!0)return Js(t)}function ft(e,t){const a=t?.originalPriceStyle??t?.price_original_style;if(a==="inline"||a==="strikethrough")return a;const n=e.productPriceUi?.originalPriceStyle;return n==="inline"||n==="strikethrough"?n:"strikethrough"}function Ct(e){const t=document.createElement("div");return t.className="gengage-chat-campaign-reason",t.textContent=e,t}function St(e,t){for(const n of["campaignReasonLogoUrl","campaign_reason_logo_url","discountBadgeLogoUrl","discount_badge_logo_url"]){const r=t?.[n];if(typeof r=="string"&&r.trim()){const i=r.trim();if(Pe(i))return i}}const a=e.productPriceUi?.campaignBadgeLogoUrl;if(typeof a=="string"&&a.trim()){const n=a.trim();if(Pe(n))return n}}function Et(e){const t=document.createElement("div");if(t.className="gengage-chat-campaign-price-badge",t.dataset.gengagePart="campaign-price-badge",e.logoUrl){const i=document.createElement("div");i.className="gengage-chat-campaign-price-badge__logo";const o=document.createElement("img");o.alt="",o.loading="lazy",o.src=e.logoUrl,Ie(o),i.appendChild(o),t.appendChild(i)}const a=document.createElement("div");a.className="gengage-chat-campaign-price-badge__body";const n=document.createElement("div");n.className="gengage-chat-campaign-price-badge__reason",n.textContent=e.reasonText;const r=document.createElement("span");return r.className="gengage-chat-campaign-price-badge__sale",r.textContent=e.salePriceFormatted,a.appendChild(n),a.appendChild(r),t.appendChild(a),t}function cn(e){const t=e.product.sku;if(typeof t=="string"&&t.length>0)return t;const a=e.action?.payload;return a&&typeof a=="object"&&"sku"in a&&typeof a.sku=="string"?a.sku:null}var Xs={winner:"roleWinner",best_value:"roleBestValue",best_alternative:"roleBestAlternative"};function ln(e,t){if(!e||!t)return null;const a=Xs[e];return a?t[a]??e:e}function Qs(e){const t=e.rating,a=typeof t=="number"?t:typeof t=="string"?parseFloat(t):NaN;if(Number.isNaN(a)||a<=0)return null;const n=document.createElement("div");n.className="gengage-chat-ai-toppick-rating",n.dataset.gengagePart="ai-top-pick-rating";const r=document.createElement("span");r.className="gengage-chat-ai-toppick-rating-icon",r.setAttribute("aria-hidden","true"),r.innerHTML='<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M12 3.6l2.58 5.23 5.77.84-4.17 4.07.98 5.75L12 16.78l-5.16 2.71.99-5.75L3.66 9.67l5.76-.84L12 3.6z"/></svg>';const i=document.createElement("span");return i.className="gengage-chat-ai-toppick-rating-value",i.textContent=a.toFixed(1),n.appendChild(r),n.appendChild(i),n}function ec(e,t,a,n,r){const i=document.createElement("div");i.className="gengage-chat-ai-toppick-media",i.dataset.gengagePart="ai-top-pick-media";const o=e.product,s=o.imageUrl;if(s&&Pe(s)){const l=document.createElement("img");l.className="gengage-chat-ai-toppick-img",l.dataset.gengagePart="ai-top-pick-image",be(l,"src",s),l.loading="lazy",l.alt=t,Ie(l),i.appendChild(l)}const c=cn(e);if(c&&!r?.skipOverlayActions){const l=document.createElement("div");if(l.className="gengage-chat-product-card-img-actions",n.onFavoriteToggle){const d=document.createElement("button");d.className="gengage-chat-favorite-btn",d.type="button",d.dataset.gengageFavoriteSku=c,d.setAttribute("aria-label",n.i18n?.addToFavoritesLabel??"Add to favorites");const b=n.favoritedSkus?.has(c)??!1;b&&d.classList.add("gengage-chat-favorite-btn--active"),d.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="${b?"currentColor":"none"}" stroke="currentColor" stroke-width="2"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>`,d.addEventListener("click",u=>{u.stopPropagation(),d.classList.toggle("gengage-chat-favorite-btn--active"),d.querySelector("svg")?.setAttribute("fill",d.classList.contains("gengage-chat-favorite-btn--active")?"currentColor":"none"),n.onFavoriteToggle?.(c,o)}),l.appendChild(d)}const g=n.i18n?.findSimilarLabel??"Find Similar",p=document.createElement("button");p.className="gengage-chat-find-similar-pill",p.type="button",p.setAttribute("aria-label",g),p.dataset.tooltip=g,p.innerHTML='<span class="gengage-chat-find-similar-pill-icon" aria-hidden="true"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"><circle cx="10.5" cy="10.5" r="6.5"/><path d="M16 16l5.5 5.5"/></svg></span>';const h=document.createElement("span");h.className="gengage-chat-find-similar-pill-text",h.textContent=g,p.appendChild(h),p.addEventListener("click",d=>{d.stopPropagation(),n.onAction({title:g,type:"findSimilar",payload:{sku:c,...s?{image_url:s}:{}}})}),l.appendChild(p),i.appendChild(l)}a.appendChild(i)}function tc(e,t,a){const n=e.price,r=e.originalPrice;if(!n)return;const i=at(a,e),o=ft(a,e),s=!!(r&&r!==n),c=!!(i&&s),l=St(a,e),g=document.createElement("div");if(g.className="gengage-chat-ai-toppick-price",g.dataset.gengagePart="ai-top-pick-price",c){const p=Et({reasonText:i,salePriceFormatted:J(n,a.pricing),...l!==void 0?{logoUrl:l}:{}});if(s&&o==="inline"){g.classList.add("gengage-chat-ai-toppick-price--inline"),g.appendChild(p);const h=document.createElement("span");h.className="gengage-chat-ai-toppick-price-sep",h.setAttribute("aria-hidden","true");const d=document.createElement("span");d.className="gengage-chat-ai-toppick-original-price",d.textContent=J(r,a.pricing),g.appendChild(h),g.appendChild(d)}else{const h=document.createElement("span");h.className="gengage-chat-ai-toppick-original-price",h.textContent=J(r,a.pricing),g.appendChild(h),g.appendChild(document.createTextNode(" ")),g.appendChild(p)}t.appendChild(g);return}if(s&&o==="inline"){g.classList.add("gengage-chat-ai-toppick-price--inline");const p=document.createElement("span");p.className="gengage-chat-ai-toppick-price-current",p.textContent=J(n,a.pricing);const h=document.createElement("span");h.className="gengage-chat-ai-toppick-price-sep",h.setAttribute("aria-hidden","true");const d=document.createElement("span");d.className="gengage-chat-ai-toppick-original-price",d.textContent=J(r,a.pricing),g.appendChild(p),g.appendChild(h),g.appendChild(d)}else if(s){const p=document.createElement("span");p.className="gengage-chat-ai-toppick-original-price",p.textContent=J(r,a.pricing),g.appendChild(p),g.appendChild(document.createTextNode(" "));const h=document.createElement("span");h.className="gengage-chat-ai-toppick-price-current",h.textContent=J(n,a.pricing),g.appendChild(h)}else{const p=document.createElement("span");p.className="gengage-chat-ai-toppick-price-current",p.textContent=J(n,a.pricing),g.appendChild(p)}if(i){const p=document.createElement("div");p.className="gengage-chat-ai-toppick-price-stack",p.appendChild(Ct(i)),p.appendChild(g),t.appendChild(p)}else t.appendChild(g)}function ac(e,t){const a=typeof e.reason=="string"?e.reason.trim():"",n=typeof e.reviewHighlight=="string"?e.reviewHighlight.trim():"";if(!(!a&&!n)){if(a){const r=document.createElement("p");r.className="gengage-chat-ai-toppick-reason",r.dataset.gengagePart="ai-top-pick-reason",r.textContent=a,t.appendChild(r)}if(n){const r=document.createElement("div");r.className="gengage-chat-ai-toppick-review",r.dataset.gengagePart="ai-top-pick-review",r.textContent=n,t.appendChild(r)}}}function gn(e,t,a){const n=document.createElement("div");n.className=a?"gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--winner gds-card":"gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--compact gds-card",n.dataset.gengagePart=a?"ai-top-pick-card-winner":"ai-top-pick-card";const r=e.product,i=cn(e),o=r.url??"",s=r.cartCode,c=r.inStock,l=!!(i&&s&&c!==!1),g=e.action;i&&t.onProductClick?(n.classList.add("gds-clickable"),n.addEventListener("click",x=>{if(x.target.closest(".gengage-chat-ai-toppick-cta")||x.target.closest(".gengage-chat-favorite-btn")||x.target.closest(".gengage-chat-find-similar-pill"))return;const N=r.name;t.onProductClick?.({sku:i,url:o,...N?{name:N}:{}})})):g&&(n.classList.add("gds-clickable"),n.addEventListener("click",x=>{x.target.closest(".gengage-chat-ai-toppick-cta")||x.target.closest(".gengage-chat-favorite-btn")||x.target.closest(".gengage-chat-find-similar-pill")||t.onAction(g)}));const p=r.name||"Product image",h=!a&&t.isMobile===!0,d=a?ln(e.role,t.i18n)??t.i18n?.roleWinner??"TOP MATCH":ln(e.role,t.i18n);if(d&&!h){const x=document.createElement("span");x.className="gengage-chat-ai-toppick-badge gds-badge",x.dataset.gengagePart="ai-top-pick-role-badge",x.textContent=d,n.appendChild(x)}const b=document.createElement("div");b.className="gengage-chat-ai-toppick-top-row",b.dataset.gengagePart="ai-top-pick-top-row",ec(e,p,b,t,{skipOverlayActions:h});const u=document.createElement("div");if(u.className="gengage-chat-ai-toppick-body",u.dataset.gengagePart="ai-top-pick-body",d&&h){const x=document.createElement("div");x.className="gengage-chat-ai-toppick-role-line",x.dataset.gengagePart="ai-top-pick-role-line",x.textContent=d,u.appendChild(x)}const v=r.name;if(v){const x=document.createElement("div");x.className="gengage-chat-ai-toppick-name",x.dataset.gengagePart="ai-top-pick-name",x.textContent=v,u.appendChild(x)}const m=Qs(r);m&&u.appendChild(m),tc(r,u,t),e.labels&&e.labels.length>0&&u.appendChild(rc(e.labels)),b.appendChild(u),n.appendChild(b);const P=document.createElement("div");if(P.className="gengage-chat-ai-toppick-detail",P.dataset.gengagePart="ai-top-pick-detail",a)ac(e,P);else{const x=typeof e.reason=="string"?e.reason.trim():"";if(x){const N=document.createElement("p");N.className="gengage-chat-ai-toppick-snippet",N.dataset.gengagePart="ai-top-pick-snippet",N.textContent=x,P.appendChild(N)}}P.childNodes.length>0&&n.appendChild(P);const A=!!(i&&t.topPicksLoadingSku===i),k=(l||g)&&!h;if(A||l||g){const x=document.createElement("div");if(x.className="gengage-chat-ai-toppick-spinner",x.dataset.gengagePart="ai-top-pick-spinner",x.style.display=A?"":"none",n.appendChild(x),k){const N=document.createElement("button");N.className="gengage-chat-ai-toppick-cta gds-btn gds-btn-primary",N.dataset.gengagePart="ai-top-pick-cta",N.type="button",N.textContent=l?t.i18n?.addToCartButton??"Add to Cart":t.i18n?.viewDetails??"View Details",N.addEventListener("click",T=>{if(T.stopPropagation(),l){t.onAction({title:t.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:i,cartCode:s,quantity:1}});return}if(g){if(g.type==="findSimilar"&&i&&t.onProductClick){const I=r.name;t.onProductClick({sku:i,url:o,...I?{name:I}:{}});return}t.onAction(g)}}),n.appendChild(N)}}return n}function nc(e,t){const a=document.createElement("div");a.className="gengage-chat-ai-top-picks",a.dataset.gengagePart="ai-top-picks";const n=e.props?.suggestions??[];if(n.length===0)return a;const r=document.createElement("div");r.className="gengage-chat-ai-top-picks-scroll",r.dataset.gengagePart="ai-top-picks-scroll";const i=n[0];if(r.appendChild(gn(i,t,!0)),n.length>1){const o=document.createElement("div");o.className="gengage-chat-ai-top-picks-rest",o.dataset.gengagePart="ai-top-picks-rest";for(let s=1;s<n.length;s++){const c=n[s],l=c.role==="winner";o.appendChild(gn(c,t,l))}r.appendChild(o)}return a.appendChild(r),a}function rc(e){const t=document.createElement("div");t.className="gengage-chat-ai-toppick-labels",t.dataset.gengagePart="ai-top-pick-labels";for(const a of e){const n=document.createElement("span");n.className="gengage-chat-ai-toppick-label gds-chip",n.dataset.gengagePart="ai-top-pick-label",n.dataset.sentiment=a.sentiment??"neutral",n.textContent=a.label,t.appendChild(n)}return t}function ic(e,t){const a=document.createElement("div");a.className="gengage-chat-grounding-review gds-evidence-card",a.dataset.gengagePart="grounding-review-card";const n=e.props??{},r=n.title,i=n.reviewCount,o=n.action,s=t.i18n?.groundingReviewCta??"Read Reviews",c=document.createElement("span");c.className="gengage-chat-grounding-review-icon",c.appendChild(mt(["M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z","M8 9h8","M8 13h6"])),a.appendChild(c);const l=document.createElement("div");l.className="gengage-chat-grounding-review-body",l.dataset.gengagePart="grounding-review-body";const g=document.createElement("div");if(g.className="gengage-chat-grounding-review-title",g.dataset.gengagePart="grounding-review-title",g.textContent=r??t.i18n?.customerReviewsTitle??"Customer Reviews",l.appendChild(g),i){const b=document.createElement("div");b.className="gengage-chat-grounding-review-subtitle",b.dataset.gengagePart="grounding-review-subtitle",b.textContent=(t.i18n?.groundingReviewSubtitle??"{count} yorum mevcut").replace("{count}",i),l.appendChild(b)}a.appendChild(l);const p=document.createElement("span");p.className="gengage-chat-grounding-review-cta",p.dataset.gengagePart="grounding-review-cta";const h=document.createElement("span");h.textContent=s,p.appendChild(h);const d=document.createElement("span");return d.className="gengage-chat-grounding-review-cta-icon",d.appendChild(mt(["M5 12h14","M15 8l4 4-4 4"],14)),p.appendChild(d),a.appendChild(p),o&&(a.classList.add("gds-clickable"),a.setAttribute("role","button"),a.setAttribute("tabindex","0"),a.addEventListener("click",()=>t.onAction(o)),a.addEventListener("keydown",b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),t.onAction(o))})),a}function oc(e){if(e.action.type!=="findSimilar")return e.action;const t=e.action.payload&&typeof e.action.payload=="object"?e.action.payload:null,a=typeof t?.input=="string"&&t.input.trim()||typeof t?.text=="string"&&t.text.trim()||e.name.trim();if(!a)return e.action;const n={text:a,is_suggested_text:1};if(typeof t?.sku=="string"&&t.sku.trim()&&(n.sku=t.sku),Array.isArray(t?.group_skus)){const r=t.group_skus.filter(i=>typeof i=="string"&&i.length>0);r.length>0&&(n.group_skus=r)}return{title:e.action.title,type:"inputText",payload:n}}function sc(e,t){const a=document.createElement("div");a.className="gengage-chat-grouping-cards",a.dataset.gengagePart="ai-grouping-cards";const n=e.props?.entries??[];if(n.length===0)return a;const r=e.props?.sectionTitle,i=typeof r=="string"&&r.trim().length>0?r.trim():t.i18n?.aiBrowseCategoriesTitle;if(i){const s=document.createElement("h3");s.className="gengage-chat-grouping-section-title",s.textContent=i,a.appendChild(s)}const o=document.createElement("div");o.className="gengage-chat-grouping-cards-scroll",o.dataset.gengagePart="ai-grouping-cards-scroll";for(const s of n){const c=document.createElement("div");if(c.className="gengage-chat-grouping-card gds-card",c.dataset.gengagePart="ai-grouping-card",c.classList.add("gds-clickable"),c.addEventListener("click",()=>t.onAction(oc(s))),s.image&&Pe(s.image)){const h=document.createElement("img");h.className="gengage-chat-grouping-card-img",h.dataset.gengagePart="ai-grouping-card-image",h.draggable=!1,h.src=s.image,h.alt=s.name,h.width=64,h.height=64,c.appendChild(h)}const l=document.createElement("div");l.className="gengage-chat-grouping-card-body",l.dataset.gengagePart="ai-grouping-card-body";const g=document.createElement("span");if(g.className="gengage-chat-grouping-card-name",g.dataset.gengagePart="ai-grouping-card-name",g.textContent=s.name,l.appendChild(g),s.labels&&s.labels.length>0){const h=document.createElement("div");h.className="gengage-chat-grouping-card-labels",h.dataset.gengagePart="ai-grouping-card-labels";for(const d of s.labels.slice(0,2)){const b=document.createElement("span");b.className="gengage-chat-grouping-card-label gds-chip",b.textContent=d,h.appendChild(b)}l.appendChild(h)}c.appendChild(l);const p=document.createElement("span");p.className="gengage-chat-grouping-card-arrow",p.textContent="↳",c.insertBefore(p,c.firstChild),o.appendChild(c)}return a.appendChild(o),a}function cc(e,t){const a=document.createElement("div");a.className="gengage-chat-suggested-search-cards",a.dataset.gengagePart="ai-suggested-search-cards";const n=e.props?.entries??[];if(n.length===0)return a;for(const r of n){const i=document.createElement("div");if(i.className="gengage-chat-suggested-search-card gds-card",i.dataset.gengagePart="ai-suggested-search-card",i.classList.add("gds-clickable"),i.addEventListener("click",()=>t.onAction(r.action)),r.image&&Pe(r.image)){const c=document.createElement("img");c.className="gengage-chat-suggested-search-card-img",c.dataset.gengagePart="ai-suggested-search-card-image",c.src=r.image,c.alt=r.shortName,c.width=64,c.height=64,i.appendChild(c)}const o=document.createElement("div");o.className="gengage-chat-suggested-search-card-body",o.dataset.gengagePart="ai-suggested-search-card-body";const s=document.createElement("div");s.className="gengage-chat-suggested-search-card-name",s.dataset.gengagePart="ai-suggested-search-card-name",s.textContent=r.shortName,o.appendChild(s),i.appendChild(o),a.appendChild(i)}return a}function dn(e,t){const a=e.length>=2,n=t.i18n?.compareSelected??"Compare",r=t.comparisonSelectionWarning,i=document.createElement("div");i.className="gengage-chat-comparison-floating-btn",i.dataset.gengagePart="comparison-dock";const o=document.createElement("div");o.className="gengage-chat-comparison-floating-summary";const s=document.createElement("span");s.className="gengage-chat-comparison-floating-count",s.textContent=String(e.length),o.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-comparison-floating-copy";const l=document.createElement("div");if(l.className="gengage-chat-comparison-floating-title",l.textContent=a?`${n} (${e.length})`:t.i18n?.compareMinHint??"Select at least 2 products",c.appendChild(l),r){const p=document.createElement("div");p.className="gengage-chat-comparison-floating-warning",p.setAttribute("role","status"),p.setAttribute("aria-live","polite"),p.textContent=r,c.appendChild(p)}o.appendChild(c),i.appendChild(o);const g=document.createElement("button");if(g.className="gengage-chat-comparison-floating-action gds-btn gds-btn-primary",g.type="button",g.textContent=n,g.disabled=!a,a||g.classList.add("gengage-chat-comparison-floating-action--disabled"),g.addEventListener("click",()=>{a&&t.onAction({title:n,type:"getComparisonTable",payload:{sku_list:[...e],gengage_analytics_source:"floating_compare_dock"}})}),i.appendChild(g),t.onToggleComparisonSku){const p=document.createElement("button");p.className="gengage-chat-comparison-floating-close gds-btn gds-btn-ghost gds-icon-btn",p.dataset.gengagePart="comparison-dock-close",p.type="button",p.setAttribute("aria-label",t.i18n?.closeAriaLabel??"Close"),p.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" aria-hidden="true"><path d="M18 6L6 18"/><path d="M6 6l12 12"/></svg>',p.addEventListener("click",h=>{h.preventDefault(),h.stopPropagation(),t.onToggleComparisonSku?.("")}),i.appendChild(p)}return i}function lc(e){const t=document.createElement("div");t.className="gengage-chat-pros-cons gds-card-soft",t.dataset.gengagePart="pros-cons";const a=e.props?.productName;if(a){const i=document.createElement("h4");i.className="gengage-chat-pros-cons-heading",i.textContent=a,t.appendChild(i)}const n=e.props?.pros,r=e.props?.cons;if(n&&n.length>0){const i=document.createElement("ul");i.className="gengage-chat-pros-cons-list",i.dataset.gengagePart="pros-list";for(const o of n){const s=document.createElement("li");s.className="gengage-chat-pros-cons-item",s.dataset.gengagePart="pros-item";const c=document.createElement("span");c.className="gengage-chat-pros-cons-icon gengage-chat-pros-cons-icon--pro",c.textContent="✓",s.appendChild(c);const l=document.createElement("span");l.textContent=o,s.appendChild(l),i.appendChild(s)}t.appendChild(i)}if(r&&r.length>0){const i=document.createElement("ul");i.className="gengage-chat-pros-cons-list",i.dataset.gengagePart="cons-list";for(const o of r){const s=document.createElement("li");s.className="gengage-chat-pros-cons-item",s.dataset.gengagePart="cons-item";const c=document.createElement("span");c.className="gengage-chat-pros-cons-icon gengage-chat-pros-cons-icon--con",c.textContent="✗",s.appendChild(c);const l=document.createElement("span");l.textContent=o,s.appendChild(l),i.appendChild(s)}t.appendChild(i)}return t}function gc(e,t){const a=e.props?.groups??[],n=e.props?.filterTags??[],r=document.createElement("div");if(r.className="gengage-chat-categories",r.dataset.gengagePart="categories-container",a.length===0)return r;const i=document.createElement("div");i.className="gengage-chat-categories-tabs gds-toolbar",i.dataset.gengagePart="categories-tab-bar",i.setAttribute("role","tablist");const o=[],s=[],c=l=>{for(let g=0;g<o.length;g++){const p=g===l;o[g].classList.toggle("gengage-chat-categories-tab--active",p),o[g].classList.toggle("is-active",p),o[g].setAttribute("aria-selected",String(p)),o[g].tabIndex=p?0:-1,s[g].style.display=p?"":"none"}};for(let l=0;l<a.length;l++){const g=a[l],p=`gengage-cat-tab-${l}`,h=`gengage-cat-panel-${l}`,d=document.createElement("button");if(d.className="gengage-chat-categories-tab gds-tab",d.type="button",d.dataset.gengagePart="categories-tab",d.id=p,d.setAttribute("role","tab"),d.setAttribute("aria-controls",h),d.setAttribute("aria-selected",String(l===0)),d.tabIndex=l===0?0:-1,l===0&&d.classList.add("gengage-chat-categories-tab--active","is-active"),g.image&&Pe(g.image)){const v=document.createElement("img");v.className="gengage-chat-categories-tab-image",v.draggable=!1,v.src=g.image,v.alt=g.groupName,v.loading="lazy",Ie(v),d.appendChild(v)}const b=document.createElement("span");b.className="gengage-chat-categories-tab-text",b.textContent=g.groupName,d.appendChild(b),d.addEventListener("click",()=>c(l)),d.addEventListener("keydown",v=>{let m=-1;v.key==="ArrowRight"||v.key==="ArrowDown"?m=(l+1)%a.length:v.key==="ArrowLeft"||v.key==="ArrowUp"?m=(l-1+a.length)%a.length:v.key==="Home"?m=0:v.key==="End"&&(m=a.length-1),m>=0&&(v.preventDefault(),c(m),o[m].focus())}),o.push(d),i.appendChild(d);const u=document.createElement("div");u.className="gengage-chat-categories-grid",u.dataset.gengagePart="categories-panel",u.id=h,u.setAttribute("role","tabpanel"),u.setAttribute("aria-labelledby",p),l!==0&&(u.style.display="none");for(const v of g.products){const m=dc(v,t);u.appendChild(m)}s.push(u)}r.appendChild(i);for(const l of s)r.appendChild(l);if(n.length>0){const l=document.createElement("div");l.className="gengage-chat-categories-filter-tags gds-toolbar",l.dataset.gengagePart="categories-filter-tags";for(const g of n){const p=document.createElement("button");p.className="gengage-chat-categories-filter-tag gds-chip",p.type="button",p.dataset.gengagePart="categories-filter-tag",p.textContent=g.title,g.action&&p.addEventListener("click",()=>{t.onAction(g.action)}),l.appendChild(p)}r.appendChild(l)}return r}function dc(e,t){const a=document.createElement("div");if(a.className="gengage-chat-product-card gds-card gds-product-card gds-card-interactive",a.dataset.gengagePart="categories-product-card",e.imageUrl&&Pe(e.imageUrl)){const i=document.createElement("img");i.className="gengage-chat-product-card-img",i.draggable=!1,i.src=e.imageUrl,i.alt=e.name,i.loading="lazy",Ie(i),a.appendChild(i)}const n=document.createElement("div");n.className="gengage-chat-product-card-body";const r=document.createElement("div");if(r.className="gengage-chat-product-card-name",r.textContent=e.name,n.appendChild(r),e.price){const i=document.createElement("div");i.className="gengage-chat-product-card-price",i.textContent=J(e.price,t.pricing),n.appendChild(i)}return a.appendChild(n),(t.onProductSelect||t.onAction)&&(a.classList.add("gds-clickable"),a.addEventListener("click",()=>{if(e.sku){t.onAction({title:e.name,type:"launchSingleProduct",payload:{sku:e.sku}});return}t.onProductSelect?.(e)})),a}function pc(e,t){const a=document.createElement("div");a.className="gengage-chat-handoff-notice gds-evidence-card gds-evidence-card-warning",a.dataset.gengagePart="handoff-notice",a.setAttribute("role","alert");const n=document.createElement("span");n.className="gengage-chat-handoff-notice-icon",n.textContent="👤",n.setAttribute("aria-hidden","true"),a.appendChild(n);const r=document.createElement("h4");r.className="gengage-chat-handoff-notice-heading",r.textContent=t.i18n?.handoffHeading??"Transferring to a support agent",a.appendChild(r);const i=e.props?.summary;if(i){const o=document.createElement("p");o.className="gengage-chat-handoff-notice-summary",o.textContent=i,a.appendChild(o)}return a}function hc(e,t){const a=e.props?.product??e.props,n=document.createElement("div");if(n.className="gengage-chat-product-summary gds-card",n.dataset.gengagePart="product-summary-card",!a)return n;n.classList.add("gds-clickable"),n.addEventListener("click",m=>{m.target.closest("a")||t.onProductSelect?.(a)});const r=a.imageUrl;if(r&&ye(r)){const m=document.createElement("div");m.className="gengage-chat-product-summary__image",m.dataset.gengagePart="product-summary-image";const P=document.createElement("img");P.loading="lazy",be(P,"src",r),P.alt=a.name||"Product image",Ie(P),m.appendChild(P),n.appendChild(m)}const i=document.createElement("div");i.className="gengage-chat-product-summary__content",i.dataset.gengagePart="product-summary-content";const o=a.brand,s=a.name;if(s){const m=document.createElement("div");m.className="gengage-chat-product-summary__name",m.dataset.gengagePart="product-summary-name";const P=o&&!s.toLowerCase().startsWith(o.toLowerCase())?`${o} ${s}`:s;m.textContent=P,m.title=P,i.appendChild(m)}const c=a.rating,l=a.reviewCount;if(typeof c=="number"&&Number.isFinite(c)&&c>0){const m=document.createElement("div");if(m.className="gengage-chat-product-summary__rating",m.dataset.gengagePart="product-summary-rating",m.appendChild(nn(c)),typeof l=="number"&&Number.isFinite(l)){const P=document.createElement("span");P.className="gengage-chat-product-summary__review-count",P.textContent=` (${l})`,m.appendChild(P)}i.appendChild(m)}const g=a.price,p=a.originalPrice;if(g){const m=at(t,a),P=ft(t,a),A=!!(p&&p!==g),k=document.createElement("div");k.className="gengage-chat-product-summary__price",k.dataset.gengagePart="product-summary-price";const x=!!(m&&A),N=St(t,a);if(x){const T=Et({reasonText:m,salePriceFormatted:J(g,t.pricing),...N!==void 0?{logoUrl:N}:{}});if(A&&P==="inline"){k.classList.add("gengage-chat-product-summary__price--inline"),k.appendChild(T);const I=document.createElement("span");I.className="gengage-chat-product-summary__price-sep",I.setAttribute("aria-hidden","true");const $=document.createElement("span");$.className="gengage-chat-product-summary__price-original",$.textContent=J(p,t.pricing),k.appendChild(I),k.appendChild($)}else{const I=document.createElement("span");I.className="gengage-chat-product-summary__price-original",I.textContent=J(p,t.pricing),k.appendChild(I),k.appendChild(document.createTextNode(" ")),k.appendChild(T)}i.appendChild(k)}else{if(A&&P==="inline"){k.classList.add("gengage-chat-product-summary__price--inline");const T=document.createElement("span");T.className="gengage-chat-product-summary__price-current",T.textContent=J(g,t.pricing);const I=document.createElement("span");I.className="gengage-chat-product-summary__price-sep",I.setAttribute("aria-hidden","true");const $=document.createElement("span");$.className="gengage-chat-product-summary__price-original",$.textContent=J(p,t.pricing),k.appendChild(T),k.appendChild(I),k.appendChild($)}else if(A){const T=document.createElement("span");T.className="gengage-chat-product-summary__price-original",T.textContent=J(p,t.pricing),k.appendChild(T),k.appendChild(document.createTextNode(" "));const I=document.createElement("span");I.className="gengage-chat-product-summary__price-current",I.textContent=J(g,t.pricing),k.appendChild(I)}else{const T=document.createElement("span");T.className="gengage-chat-product-summary__price-current",T.textContent=J(g,t.pricing),k.appendChild(T)}if(m){const T=document.createElement("div");T.className="gengage-chat-product-summary__price-stack",T.appendChild(Ct(m)),T.appendChild(k),i.appendChild(T)}else i.appendChild(k)}}n.appendChild(i);const h=a.url,d=a.sku,b=a.cartCode??a.cart_code,u=typeof b=="string"&&b.trim()?b.trim():void 0,v=a.inStock;if(d&&u&&v!==!1){const m=document.createElement("button");m.type="button",m.className="gengage-chat-product-summary__cta gds-chip gds-chip-active",m.dataset.gengagePart="product-summary-cta",m.textContent=t.i18n?.addToCartButton??"Add to Cart",m.addEventListener("click",P=>{P.stopPropagation(),t.onAction({title:t.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:d,cartCode:u,quantity:1}})}),n.appendChild(m)}else if(h&&ye(h)){const m=document.createElement("a");m.className="gengage-chat-product-summary__cta gds-chip gds-chip-active",m.dataset.gengagePart="product-summary-cta",be(m,"href",h),be(m,"target","_blank"),be(m,"rel","noopener noreferrer"),m.textContent=t.i18n?.productCtaLabel??"View",n.appendChild(m)}return n}var uc={PhotoAnalysisCard:({element:e,context:t})=>fs(e,t),BeautyPhotoStep:({element:e,context:t})=>Ka(e,t)};function Qt(){return window.innerWidth<768}var pn={ActionButtons:({element:e,context:t})=>mc(e,t),ActionButton:({element:e,context:t})=>fc(e,t),ProductCard:({element:e,context:t})=>ta(e,t),ProductDetailsPanel:({element:e,context:t})=>Dc(e,t),ProductGrid:({element:e,spec:t,renderElement:a,context:n})=>qc(e,t,a,n),ReviewHighlights:({element:e,context:t})=>Ys(e,{emptyReviewsMessage:t.i18n?.emptyReviewsMessage,reviewFilterPositive:t.i18n?.reviewFilterPositive,reviewFilterNegative:t.i18n?.reviewFilterNegative,reviewCustomersMentionSingular:t.i18n?.reviewCustomersMentionSingular,reviewCustomersMentionPlural:t.i18n?.reviewCustomersMentionPlural,reviewSubjectsHeading:t.i18n?.reviewSubjectsHeading}),ComparisonTable:({element:e,context:t})=>Vc(e,t),AITopPicks:({element:e,context:t})=>nc(e,t),GroundingReviewCard:({element:e,context:t})=>ic(e,t),AIGroupingCards:({element:e,context:t})=>sc(e,t),AISuggestedSearchCards:({element:e,context:t})=>cc(e,t),ProsAndCons:({element:e})=>lc(e),CategoriesContainer:({element:e,context:t})=>gc(e,t),HandoffNotice:({element:e,context:t})=>pc(e,t),ProductSummaryCard:({element:e,context:t})=>hc(e,t),Divider:({element:e})=>Gc(e),...uc},ea=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const a=document.createElement("div");for(const n of e.children){const r=t(n);r&&a.appendChild(r)}return a};function hn(){return{...pn}}function un(e,t,a=pn,n=ea){return Or({spec:e,context:t,registry:a,containerClassName:"gengage-chat-uispec",unknownRenderer:n})}function mc(e,t){const a=document.createElement("div");a.className="gengage-chat-action-buttons";const n=e.props?.buttons;if(n)for(const r of n){const i=document.createElement("button");i.className="gengage-chat-action-btn",i.textContent=r.label,i.addEventListener("click",()=>t.onAction(r.action)),a.appendChild(i)}return a}function fc(e,t){const a=document.createElement("button");a.className="gengage-chat-action-btn";const n=e.props?.label;typeof n=="string"&&(a.textContent=n);const r=e.props?.action;return r&&a.addEventListener("click",()=>t.onAction(r)),a}function mn(e,t,a,n,r){e.replaceChildren();const i=ft(t,a),o=!!(r&&n&&r!==n),s=at(t,a),c=!!(s&&o),l=St(t,a);if(!n||parseFloat(n)<=0)return;if(c){const p=Et({reasonText:s,salePriceFormatted:J(n,t.pricing),...l!==void 0?{logoUrl:l}:{}});if(o&&i==="inline"){e.classList.add("gengage-chat-product-card-price-block--inline");const h=document.createElement("div");h.className="gengage-chat-product-card-price-row",h.appendChild(p);const d=document.createElement("span");d.className="gengage-chat-product-card-price-sep",d.setAttribute("aria-hidden","true");const b=document.createElement("span");b.className="gengage-chat-product-card-original-price",b.textContent=J(r,t.pricing),h.appendChild(d),h.appendChild(b),e.appendChild(h);return}if(e.classList.remove("gengage-chat-product-card-price-block--inline"),e.appendChild(p),o){e.appendChild(document.createTextNode(" "));const h=document.createElement("span");h.className="gengage-chat-product-card-original-price",h.textContent=J(r,t.pricing),e.appendChild(h)}return}if(o&&i==="inline"){e.classList.add("gengage-chat-product-card-price-block--inline");const p=document.createElement("div");p.className="gengage-chat-product-card-price-row";const h=document.createElement("span");h.className="gengage-chat-product-card-current-price",h.textContent=J(n,t.pricing);const d=document.createElement("span");d.className="gengage-chat-product-card-price-sep",d.setAttribute("aria-hidden","true");const b=document.createElement("span");b.className="gengage-chat-product-card-original-price",b.textContent=J(r,t.pricing),p.appendChild(h),p.appendChild(d),p.appendChild(b),e.appendChild(p);return}e.classList.remove("gengage-chat-product-card-price-block--inline");const g=document.createElement("span");if(g.className="gengage-chat-product-card-current-price",g.textContent=J(n,t.pricing),e.appendChild(g),o){e.appendChild(document.createTextNode(" "));const p=document.createElement("span");p.className="gengage-chat-product-card-original-price",p.textContent=J(r,t.pricing),e.appendChild(p)}}function fn(e,t,a,n,r,i,o){e.classList.remove("gengage-chat-product-details-price--inline"),e.replaceChildren(),e.className="gengage-chat-product-details-price";const s=at(t,a),c=!!(s&&o),l=St(t,a);if(c){const p=Et({reasonText:s,salePriceFormatted:J(n,t.pricing),...l!==void 0?{logoUrl:l}:{}});if(o&&i==="inline"){e.classList.add("gengage-chat-product-details-price--inline"),e.appendChild(p);const h=document.createElement("span");h.className="gengage-chat-product-details-price-sep",h.setAttribute("aria-hidden","true");const d=document.createElement("span");d.className="gengage-chat-product-details-original-price",d.textContent=J(r,t.pricing),e.appendChild(h),e.appendChild(d)}else{if(o){const h=document.createElement("span");h.className="gengage-chat-product-details-original-price",h.textContent=J(r,t.pricing),e.appendChild(h),e.appendChild(document.createTextNode(" "))}e.appendChild(p)}}else if(o&&i==="inline"){e.classList.add("gengage-chat-product-details-price--inline");const p=document.createElement("span");p.className="gengage-chat-product-details-current-price",p.textContent=J(n,t.pricing);const h=document.createElement("span");h.className="gengage-chat-product-details-price-sep",h.setAttribute("aria-hidden","true");const d=document.createElement("span");d.className="gengage-chat-product-details-original-price",d.textContent=J(r,t.pricing),e.appendChild(p),e.appendChild(h),e.appendChild(d)}else{if(o){const h=document.createElement("span");h.className="gengage-chat-product-details-original-price",h.textContent=J(r,t.pricing),e.appendChild(h),e.appendChild(document.createTextNode(" "))}const p=document.createElement("span");p.className="gengage-chat-product-details-current-price",p.textContent=J(n,t.pricing),e.appendChild(p)}const g=Pt(a,"discountPercent","price_discount_rate");if(!t.hideProductDiscountBadge&&typeof g=="number"&&g>0){const p=document.createElement("span");p.className="gengage-chat-product-details-discount-badge",p.textContent=`%${an(g)}`,e.appendChild(p)}}function ta(e,t){const a=document.createElement("div");a.className="gengage-chat-product-card gds-card gds-product-card gds-card-interactive";const n=e.props?.product??e.props;if(!n)return a;const r=n.sku;r&&(a.dataset.sku=r);const i=e.props?.action;(t.onProductSelect||i)&&(a.classList.add("gds-clickable"),a.addEventListener("click",f=>{if(!a.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")&&!f.target.closest(".gengage-chat-product-card-atc")&&!f.target.closest(".gengage-chat-product-card-cta")){if(i){t.onAction(i);return}t.onProductSelect?.(n)}}));const o=n.imageUrl;if(o&&ye(o)){const f=document.createElement("div");f.className="gengage-chat-product-card-img-wrapper";const L=document.createElement("img");L.className="gengage-chat-product-card-img",L.loading="lazy",be(L,"src",o);const D=n.name;D&&(L.alt=D),Ie(L),f.appendChild(L);const B=n.discountPercent;if(!t.hideProductDiscountBadge&&typeof B=="number"&&B>0){const E=document.createElement("span");E.className="gengage-chat-product-card-discount-badge",E.textContent=`%${an(B)}`,f.appendChild(E)}const j=document.createElement("div");j.className="gengage-chat-product-card-img-actions";const Z=n.sku;if(Z&&t.onFavoriteToggle){const E=document.createElement("button");E.className="gengage-chat-favorite-btn",E.type="button",E.dataset.gengageFavoriteSku=Z,E.setAttribute("aria-label",t.i18n?.addToFavoritesLabel??"Add to favorites");const S=t.favoritedSkus?.has(Z)??!1;S&&E.classList.add("gengage-chat-favorite-btn--active"),E.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="${S?"currentColor":"none"}" stroke="currentColor" stroke-width="2"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>`,E.addEventListener("click",z=>{z.stopPropagation(),E.classList.toggle("gengage-chat-favorite-btn--active");const M=E.querySelector("svg");M&&M.setAttribute("fill",E.classList.contains("gengage-chat-favorite-btn--active")?"currentColor":"none"),t.onFavoriteToggle(Z,n)}),j.appendChild(E)}const q=n.sku,y=t.i18n?.findSimilarLabel??"Find Similar";if(q){const E=document.createElement("button");E.className="gengage-chat-find-similar-pill",E.type="button",E.setAttribute("aria-label",y),E.dataset.tooltip=y,E.innerHTML='<span class="gengage-chat-find-similar-pill-icon" aria-hidden="true"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"><circle cx="10.5" cy="10.5" r="6.5"/><path d="M16 16l5.5 5.5"/></svg></span>';const S=document.createElement("span");S.className="gengage-chat-find-similar-pill-text",S.textContent=y,E.appendChild(S),E.addEventListener("click",z=>{z.stopPropagation(),t.onAction({title:y,type:"findSimilar",payload:{sku:q,...o?{image_url:o}:{}}})}),j.appendChild(E)}j.childElementCount>0&&f.appendChild(j),a.appendChild(f)}const s=document.createElement("div");s.className="gengage-chat-product-card-body";const c=n.brand;if(c){const f=document.createElement("div");f.className="gengage-chat-product-card-brand",f.textContent=c,s.appendChild(f)}const l=n.rating,g=n.reviewCount,p=n.price,h=n.originalPrice,d=n.price_async,b=at(t,n),u=ft(t,n),v=!!(h&&p&&h!==p&&parseFloat(p)>0),m=!!(b&&v),P=!!(b&&!m||v&&u==="inline"),A=typeof l=="number"&&Number.isFinite(l)&&l>0,k=document.createElement("div");k.className="gengage-chat-product-card-meta-row";const x=document.createElement("div");x.className="gengage-chat-product-card-price gengage-chat-product-card-price-block";const N=P?(()=>{const f=document.createElement("div");return f.className="gengage-chat-product-card-price-stack",b&&!m&&f.appendChild(Ct(b)),f.appendChild(x),f})():x;if(d===!0){const f=document.createElement("span");f.className="gengage-chat-price-skeleton",x.appendChild(f),setTimeout(()=>{f.parentElement&&(p&&parseFloat(p)>0?mn(x,t,n,p,n.originalPrice):f.remove())},300)}else p&&parseFloat(p)>0&&mn(x,t,n,p,h);if((x.childElementCount>0||d===!0)&&k.appendChild(N),A){const f=document.createElement("div");f.className="gengage-chat-product-card-rating gengage-chat-product-card-rating-compact";const L=Jt(l),D=[`${L.toFixed(1)}`,"out of 5 stars"];typeof g=="number"&&Number.isFinite(g)&&D.push(`(${g} reviews)`),f.setAttribute("aria-label",D.join(" "));const B=document.createElement("span");B.className="gengage-chat-product-card-rating-compact-star",B.setAttribute("aria-hidden","true"),B.innerHTML='<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M12 3.6l2.58 5.23 5.77.84-4.17 4.07.98 5.75L12 16.78l-5.16 2.71.99-5.75L3.66 9.67l5.76-.84L12 3.6z"/></svg>';const j=document.createElement("span");j.className="gengage-chat-product-card-rating-compact-value",j.textContent=L.toFixed(1),f.appendChild(B),f.appendChild(j),k.appendChild(f)}k.childElementCount===0&&(k.classList.add("gengage-chat-product-card-meta-row--empty"),k.setAttribute("aria-hidden","true")),s.appendChild(k);const T=n.name;if(T){const f=document.createElement("div");f.className="gengage-chat-product-card-name",f.textContent=T,f.title=T,s.appendChild(f)}const I=n.inStock;if(typeof I=="boolean"){const f=document.createElement("div");f.className=`gengage-chat-product-card-stock ${I?"is-in-stock":"is-out-of-stock"}`,f.textContent=I?t.i18n?.inStockLabel??"In Stock":t.i18n?.outOfStockLabel??"Out of Stock",s.appendChild(f)}a.appendChild(s);const $=n.url,ae=n.sku,oe=n.cartCode,ve=!!(oe&&ae&&I!==!1),O=t.i18n?.productCtaLabel??"View";if(ve){const f=document.createElement("div");f.className="gengage-chat-product-card-buy-footer";const L=document.createElement("button");L.type="button",L.className="gengage-chat-product-card-buy-trigger",L.textContent=O,L.addEventListener("click",D=>{D.stopPropagation(),t.onAction({title:t.i18n?.addToCartButton??O,type:"addToCart",payload:{sku:ae,cartCode:oe,quantity:1}})}),f.appendChild(L),a.appendChild(f)}else if(i){const f=document.createElement("button");f.className="gengage-chat-product-card-cta",f.type="button",f.textContent=i.type==="launchSingleProduct"?O:i.title||O,f.addEventListener("click",L=>{if(a.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){L.stopPropagation();return}t.onAction(i)}),a.appendChild(f)}else if($&&ye($)){const f=document.createElement("a");f.className="gengage-chat-product-card-cta",be(f,"href",$),be(f,"target","_blank"),be(f,"rel","noopener noreferrer"),f.textContent=O,f.addEventListener("click",L=>{if(a.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){L.preventDefault(),L.stopPropagation();return}t.onProductClick&&ae&&(L.preventDefault(),t.onProductClick({sku:ae,url:$,...T?{name:T}:{}}))}),a.appendChild(f)}if(t.comparisonSelectMode&&ae&&t.onToggleComparisonSku){const f=document.createElement("div");f.className="gengage-chat-comparison-select-wrapper";const L=t.comparisonSelectedSkus?.includes(ae)??!1;L&&f.classList.add("gengage-chat-comparison-select-wrapper--selected");const D=n.name??ae,B=t.i18n?.comparisonSelectCardHint??"Tap anywhere on the card to add or remove it from comparison.";f.setAttribute("role","group"),f.setAttribute("aria-label",`${String(D)}. ${B}`);const j=document.createElement("button");j.type="button",j.className="gengage-chat-comparison-checkbox",j.dataset.selected=L?"true":"false",j.setAttribute("aria-pressed",L?"true":"false");const Z=document.createElement("span");Z.className="gengage-chat-comparison-checkbox-icon",Z.innerHTML=L?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6L9 17l-5-5"/></svg>':'<span class="gengage-chat-comparison-checkbox-dot"></span>';const q=document.createElement("span");q.className="gengage-chat-comparison-checkbox-label",q.textContent=L?t.i18n?.comparisonSelectedLabel??"Selected":t.i18n?.comparisonSelectLabel??"Select to compare",j.appendChild(Z),j.appendChild(q),j.addEventListener("click",E=>{E.stopPropagation(),t.onToggleComparisonSku?.(ae)});const y=document.createElement("div");return y.className="gengage-chat-comparison-card-hint",y.setAttribute("aria-hidden","true"),y.textContent=B,f.addEventListener("click",E=>{E.target.closest(".gengage-chat-comparison-checkbox")||(E.stopPropagation(),t.onToggleComparisonSku?.(ae))}),f.appendChild(j),f.appendChild(y),f.appendChild(a),f}return a}var bn=new Set(["color","colour","renk","renk kodu","color code"]),bc=new Set(["size","beden","boyut"]),vc=new Set(["finish","bitiş","bitişi"]),yc=["variants","variantOptions","variant_options","productVariants","product_variants","options"],_c=new Set(["H2","H3","H4","P","BR","UL","OL","LI","STRONG","B","EM","I"]),xc=new Set(["SCRIPT","STYLE","NOSCRIPT","IFRAME","OBJECT","EMBED"]);function we(e,...t){for(const a of t){const n=e[a];if(typeof n=="string"){const r=n.trim();if(r.length>0)return r}}}function Pt(e,...t){for(const a of t){const n=e[a];if(typeof n=="number"&&Number.isFinite(n))return n;if(typeof n=="string"){const r=Number(n.replace(",","."));if(Number.isFinite(r))return r}}}function At(e,...t){for(const a of t){const n=e[a];if(typeof n=="boolean")return n}}function wc(e,...t){for(const a of t){const n=e[a];if(n&&typeof n=="object"&&!Array.isArray(n))return n}}function kc(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0):[]}function Cc(e){const t=[...kc(e.images),we(e,"imageUrl","image_url","image")].filter(a=>!!a&&ye(a));return Array.from(new Set(t))}function Sc(e){return typeof DOMParser<"u"?(new DOMParser().parseFromString(e,"text/html").body.textContent??"").replace(/\s+/g," ").trim():e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim()}function Ec(e){const t=we(e,"description_html","descriptionHtml");if(t){const n=Sc(t);if(n)return{text:n,html:t}}const a=we(e,"description");return a?{text:a}:void 0}function Tt(e){return Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object")return null;const a=t,n=we(a,"key","name","label","title"),r=a.value,i=typeof r=="string"||typeof r=="number"||typeof r=="boolean"?String(r).trim():void 0;return!n||!i?null:{key:n,value:i}}).filter(t=>t!==null):e&&typeof e=="object"?Object.entries(e).map(([t,a])=>{const n=typeof a=="string"||typeof a=="number"||typeof a=="boolean"?String(a).trim():void 0;return!t||!n?null:{key:t,value:n}}).filter(t=>t!==null):[]}function vn(e){const t=Tt(e.features);return t.length>0?t:Tt(e.specifications)}function Pc(e){const t=e.specifications,a=Tt(t);if(a.length>0)return Array.isArray(t)?a:Object.fromEntries(a.map(r=>[r.key,r.value]));const n=Tt(e.features);return n.length>0?n:void 0}function He(e,...t){return we(e,...t)}function yn(e,...t){return Pt(e,...t)}function _n(e){return He(e,"value","option_value","attribute_value","label","title","name","variant_name","sku")}function xn(e){const t=He(e,"type","attribute","option_name","attribute_name");return t||(He(e,"value")?He(e,"name","variant_name"):void 0)}function Ac(e){const t=xn(e)?.toLowerCase();return!!(we(e,"color","colour","color_hex","hex","swatch","swatchColor")||t&&bn.has(t))}function wn(e){if(!e)return;const t=e.trim();if(!(!t||t.includes(";"))&&(typeof CSS<"u"&&CSS.supports?.("color",t)||/^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)))return t}function Tc(e){const t=wn(He(e,"swatchColor","swatch","color_hex","hex","color","colour"));if(t)return t;if(Ac(e))return wn(_n(e))}function Lc(e){return He(e,"image","imageUrl","image_url","swatchImage","swatch_image")}function Ic(e){return yn(e,"price_discounted","priceDiscounted")??He(e,"price_discounted","priceDiscounted")??yn(e,"price")??He(e,"price")}function Nc(e){const t=e.trim().toLowerCase();return bn.has(t)||bc.has(t)||vc.has(t)}function zc(e){const t=e.trim().toLowerCase();return t==="renk kodu"?"Renk":t==="color code"?"Color":e.trim()}function Mc(e){for(const t of yc){const a=e[t];if(!Array.isArray(a))continue;const n=a.filter(r=>!!r&&typeof r=="object"&&!Array.isArray(r));if(n.length>0)return n}}function Bc(e){const t=Mc(e);if(t)return t;const a=we(e,"sku"),n=At(e,"inStock","in_stock"),r=[],i=new Set,o=(c,l)=>{if(!Nc(c)||typeof l!="string"&&typeof l!="number"&&typeof l!="boolean")return;const g=String(l).trim();if(!g)return;const p=zc(c),h=`${p.toLowerCase()}:${g.toLowerCase()}`;i.has(h)||(i.add(h),r.push({name:p,value:g,sku:a,inStock:n}))},s=wc(e,"facetHits","facet_hits");if(s)for(const[c,l]of Object.entries(s))o(c,l);for(const c of vn(e))o(c.key,c.value);return r}function Rc(e,t){const a=Array.from(new Set(e.map(xn).filter(n=>!!n)));return a.length===1?`${e.length} ${a[0]}`:t.i18n?.variantsLabel??"Variants"}function Dc(e,t){const a=document.createElement("article");a.className="gengage-chat-product-details-panel";const n=e.props?.product??e.props;if(!n)return a;const r=we(n,"name"),i=we(n,"brand"),o=we(n,"sku"),s=we(n,"cartCode","cart_code"),c=we(n,"price"),l=we(n,"originalPrice","price_original"),g=At(n,"price_async"),p=at(t,n),h=ft(t,n),d=!!(l&&c&&l!==c),b=At(n,"inStock","in_stock"),u=Pt(n,"reviewCount","review_count"),v=Pt(n,"rating"),m=Cc(n),P=vn(n).slice(0,4);if(m.length>1){const f=document.createElement("div");f.className="gengage-chat-product-details-media gengage-chat-product-details-gallery gengage-chat-product-details-img-wrap";const L=document.createElement("img");L.className="gengage-chat-product-details-img",be(L,"src",m[0]),L.alt=r??"Product image",Ie(L),f.appendChild(L);const D=document.createElement("div");D.className="gengage-chat-product-gallery-thumbs";const B=6;let j=null,Z=0;const q=t.i18n,y=q?.galleryPrevAriaLabel??"Previous image",E=q?.galleryNextAriaLabel??"Next image",S=U=>U==="prev"?'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="15 18 9 12 15 6"/></svg>':'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="9 18 15 12 9 6"/></svg>',z=document.createElement("button");z.type="button",z.className="gengage-chat-product-gallery-nav gengage-chat-product-gallery-nav--prev gds-btn gds-btn-ghost gds-icon-btn",z.setAttribute("aria-label",y),z.innerHTML=S("prev");const M=document.createElement("button");M.type="button",M.className="gengage-chat-product-gallery-nav gengage-chat-product-gallery-nav--next gds-btn gds-btn-ghost gds-icon-btn",M.setAttribute("aria-label",E),M.innerHTML=S("next");const R=()=>{z.disabled=Z<=0,M.disabled=Z>=m.length-1},H=U=>{if(U<0||U>=m.length||U===Z)return;const ce=m[U];if(!ce)return;be(L,"src",ce);const X=D.querySelectorAll(".gengage-chat-product-gallery-thumb");j&&j.classList.remove("gengage-chat-product-gallery-thumb--active"),U<B&&X[U]?(X[U].classList.add("gengage-chat-product-gallery-thumb--active"),j=X[U]):j=null,Z=U,R()};for(let U=0;U<m.length;U++){const ce=m[U];if(U>=B)break;const X=document.createElement("img");X.className="gengage-chat-product-gallery-thumb",U===0&&(X.classList.add("gengage-chat-product-gallery-thumb--active"),j=X),be(X,"src",ce),X.alt=`${r??"Product"} ${U+1}`,X.width=48,X.height=48,Ie(X),X.addEventListener("click",()=>{H(U)}),D.appendChild(X)}if(m.length>B){const U=document.createElement("span");U.className="gengage-chat-product-gallery-thumb-more",U.textContent=`+${m.length-B}`,D.appendChild(U)}z.addEventListener("click",U=>{U.stopPropagation(),H(Z-1)}),M.addEventListener("click",U=>{U.stopPropagation(),H(Z+1)}),R();let ne=0;const te=50;L.addEventListener("touchstart",U=>{ne=U.changedTouches[0].clientX},{passive:!0}),L.addEventListener("touchend",U=>{const ce=U.changedTouches[0].clientX,X=ne-ce;Math.abs(X)<te||H(X>0?Math.min(Z+1,m.length-1):Math.max(Z-1,0))}),f.appendChild(z),f.appendChild(M),f.appendChild(D),a.appendChild(f)}else if(m.length===1){const f=document.createElement("div");f.className="gengage-chat-product-details-media gengage-chat-product-details-img-wrap";const L=document.createElement("img");L.className="gengage-chat-product-details-img",L.loading="lazy",be(L,"src",m[0]),Ie(L),L.alt=r??"Product image",f.appendChild(L),a.appendChild(f)}const A=document.createElement("div");if(A.className="gengage-chat-product-details-content",i&&(!r||!r.toLowerCase().startsWith(i.toLowerCase()))){const f=document.createElement("div");f.className="gengage-chat-product-details-brand",f.textContent=i,A.appendChild(f)}if(r){const f=document.createElement("h3");f.className="gengage-chat-product-details-title",f.textContent=r,f.title=r,A.appendChild(f)}if(typeof v=="number"&&Number.isFinite(v)&&v>0){const f=document.createElement(o?"button":"div");f.className="gengage-chat-product-details-rating",o&&(f.type="button",f.classList.add("gengage-chat-product-details-rating--clickable"),f.setAttribute("aria-label",t.i18n?.groundingReviewCta??"Read Reviews"),f.addEventListener("click",()=>{t.onAction({title:t.i18n?.customerReviewsTitle??"Customer Reviews",type:"reviewSummary",payload:{sku:o}})})),f.appendChild(nn(v));const L=document.createElement("span");if(L.className="gengage-chat-product-details-rating-value",L.textContent=Jt(v).toFixed(1),f.appendChild(L),typeof u=="number"&&Number.isFinite(u)){const D=document.createElement("span");D.className="gengage-chat-product-details-review-count",D.textContent=` (${u})`,f.appendChild(D)}A.appendChild(f)}{const f=!!(p&&d);let L=A;if(p&&!f){const B=document.createElement("div");B.className="gengage-chat-product-details-price-stack",B.appendChild(Ct(p)),A.appendChild(B),L=B}const D=document.createElement("div");if(D.className="gengage-chat-product-details-price",g===!0){const B=document.createElement("span");B.className="gengage-chat-price-skeleton",D.appendChild(B),L.appendChild(D),setTimeout(()=>{if(B.parentElement)if(c&&parseFloat(c)>0)fn(D,t,n,c,l,h,d);else{const j=D.parentElement;D.remove(),j?.classList.contains("gengage-chat-product-details-price-stack")&&j.remove()}},300)}else if(c&&parseFloat(c)>0)fn(D,t,n,c,l,h,d),L.appendChild(D);else if(p){const B=L;B.classList.contains("gengage-chat-product-details-price-stack")&&B.remove()}}if(typeof b=="boolean"){const f=document.createElement("div");f.className=`gengage-chat-product-details-stock ${b?"is-in-stock":"is-out-of-stock"}`,f.textContent=b?t.i18n?.inStockLabel??"In Stock":t.i18n?.outOfStockLabel??"Out of Stock",A.appendChild(f)}const k=n.promotions;if(k&&k.length>0){const f=document.createElement("div");f.className="gengage-chat-product-details-promos";for(const L of k.slice(0,3)){if(!L||/%(0(\.0+)?)\s/.test(L))continue;const D=document.createElement("span");D.className="gengage-chat-product-details-promo-badge",D.textContent=L,D.title=L,f.appendChild(D)}f.childElementCount>0&&A.appendChild(f)}if(P.length>0){const f=document.createElement("dl");f.className="gengage-chat-product-details-facts";for(const L of P){const D=document.createElement("div");D.className="gengage-chat-product-details-fact";const B=document.createElement("dt");B.textContent=L.key;const j=document.createElement("dd");j.textContent=L.value,D.appendChild(B),D.appendChild(j),f.appendChild(D)}A.appendChild(f)}const x=Bc(n);if(x.length>0){const f=document.createElement("div");f.className="gengage-chat-product-variants";const L=document.createElement("div");L.className="gengage-chat-product-variants-label",L.textContent=Rc(x,t),f.appendChild(L);const D=document.createElement("div");D.className="gengage-chat-product-variants-list";for(const B of x){const j=_n(B),Z=He(B,"sku");if(!j&&!Z)continue;const q=document.createElement("button");q.className="gengage-chat-product-variant-btn gds-chip",q.type="button";const y=j??Z??"";q.title=y;const E=At(B,"in_stock","inStock");Z&&o&&Z===o?(q.classList.add("gengage-chat-product-variant-btn--active"),q.setAttribute("aria-pressed","true")):q.setAttribute("aria-pressed","false"),E===!1&&(q.classList.add("gengage-chat-product-variant-btn--out"),q.disabled=!0);const S=Lc(B),z=Tc(B);if(S&&ye(S)){const H=document.createElement("img");H.className="gengage-chat-product-variant-swatch gengage-chat-product-variant-swatch--image",be(H,"src",S),H.alt="",H.setAttribute("aria-hidden","true"),Ie(H),q.appendChild(H)}else if(z){const H=document.createElement("span");H.className="gengage-chat-product-variant-swatch",H.setAttribute("aria-hidden","true"),H.style.backgroundColor=z,q.appendChild(H)}const M=document.createElement("span");M.className="gengage-chat-product-variant-label",M.textContent=y,q.appendChild(M);const R=Ic(B);if(R&&String(R)!==String(c)){const H=document.createElement("span");H.className="gengage-chat-product-variant-price",H.textContent=J(String(R),t.pricing),q.appendChild(H)}if(Z&&Z!==o){const H=r??"",ne=(typeof B.value=="string"?B.value.trim():"")||(typeof B.name=="string"?B.name.trim():"")||(typeof B.variant_name=="string"?B.variant_name.trim():"")||"",te=H.length>0?ne.length>0&&ne!==H?`${H} (${ne})`:H:y;q.addEventListener("click",()=>{t.onAction({title:te,type:"launchVariant",payload:{sku:Z}})})}D.appendChild(q)}D.childElementCount>0&&(f.appendChild(D),A.appendChild(f))}const N=document.createElement("div");N.className="gengage-chat-product-details-actions";const T=e.props?.action;if(T){const f=document.createElement("button");f.className="gengage-chat-product-details-cta gds-btn gds-btn-primary",f.type="button",f.textContent=T.title||t.i18n?.productCtaLabel||"View",f.addEventListener("click",()=>t.onAction(T)),N.appendChild(f)}if(s&&o&&b!==!1){const f=document.createElement("button");f.className="gengage-chat-product-details-atc gds-btn gds-btn-primary",f.type="button",f.textContent=t.i18n?.addToCartButton??"Add to Cart",f.addEventListener("click",()=>{t.onAction({title:t.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:o,cartCode:s,quantity:1}})}),N.appendChild(f)}const I=we(n,"url");if(!T&&I&&ye(I)){const f=document.createElement("a");f.className="gengage-chat-product-details-cta gds-btn gds-btn-secondary",be(f,"href",I),be(f,"target","_blank"),be(f,"rel","noopener noreferrer"),f.textContent=t.i18n?.viewOnSiteLabel??t.i18n?.productCtaLabel??"View on Site",f.addEventListener("click",L=>{t.onProductClick&&o&&(L.preventDefault(),t.onProductClick({sku:o,url:I,...r?{name:r}:{}}))}),N.appendChild(f)}const $=I;if($&&ye($)){let j=function(q,y){const E=document.createElementNS(D,"circle");E.setAttribute("cx",q),E.setAttribute("cy",y),E.setAttribute("r","3"),B.appendChild(E)},Z=function(q,y,E,S){const z=document.createElementNS(D,"line");z.setAttribute("x1",q),z.setAttribute("y1",y),z.setAttribute("x2",E),z.setAttribute("y2",S),B.appendChild(z)};var ve=j,O=Z;const f=document.createElement("button");f.className="gengage-chat-product-details-share gds-btn gds-btn-ghost gds-icon-btn",f.type="button";const L=t.i18n?.shareButton??"Share";f.title=L,f.setAttribute("aria-label",L);const D="http://www.w3.org/2000/svg",B=document.createElementNS(D,"svg");B.setAttribute("width","18"),B.setAttribute("height","18"),B.setAttribute("viewBox","0 0 24 24"),B.setAttribute("fill","none"),B.setAttribute("stroke","currentColor"),B.setAttribute("stroke-width","2"),B.setAttribute("stroke-linecap","round"),B.setAttribute("stroke-linejoin","round"),j("18","5"),j("6","12"),j("18","19"),Z("8.59","13.51","15.42","17.49"),Z("15.41","6.51","8.59","10.49"),f.appendChild(B),f.addEventListener("click",async()=>{try{navigator.share?await navigator.share({title:r??"",url:$}):navigator.clipboard&&(await navigator.clipboard.writeText($),f.classList.add("gengage-chat-product-details-share--copied"),setTimeout(()=>f.classList.remove("gengage-chat-product-details-share--copied"),1500))}catch{}}),N.appendChild(f)}N.childElementCount>0&&A.appendChild(N),a.appendChild(A);const ae=Ec(n),oe=Pc(n);return(ae||oe)&&a.appendChild($c(ae,oe,t)),a}function aa(e){if(e.nodeType===Node.TEXT_NODE)return document.createTextNode(e.textContent??"");if(e.nodeType!==Node.ELEMENT_NODE)return null;const t=e,a=t.tagName.toUpperCase();if(xc.has(a))return null;if(!_c.has(a)){const r=document.createDocumentFragment();for(const i of Array.from(t.childNodes)){const o=aa(i);o&&r.appendChild(o)}return r}const n=document.createElement(a.toLowerCase());for(const r of Array.from(t.childNodes)){const i=aa(r);i&&n.appendChild(i)}return n}function Oc(e,t){const a=t.split(/\n{2,}/).map(n=>n.replace(/\s+/g," ").trim()).filter(Boolean);if(a.length!==0)for(const n of a){const r=document.createElement("p");r.textContent=n,e.appendChild(r)}}function Fc(e,t){if(e.classList.add("gengage-chat-product-description"),t.html&&typeof DOMParser<"u"){const a=new DOMParser().parseFromString(t.html,"text/html"),n=Array.from(a.body.childNodes).map(r=>aa(r)).filter(r=>!!r&&(r.nodeType===Node.ELEMENT_NODE||!!r.textContent?.trim()));if(n.length>0){for(const r of n)e.appendChild(r);return}}Oc(e,t.text)}function $c(e,t,a){const n=document.createElement("div");n.className="gengage-chat-product-detail-tabs";const r=document.createElement("div");r.className="gengage-chat-product-detail-tab-bar gds-toolbar";const i=[];if(e){const s=document.createElement("button");s.className="gengage-chat-product-detail-tab gds-tab gengage-chat-product-detail-tab--active is-active",s.type="button",s.setAttribute("aria-selected","true"),s.textContent=a.i18n?.productInfoTab??"Product Info",r.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-product-detail-tab-panel",Fc(c,e),i.push(c)}if(t){const s=document.createElement("button");s.className=`gengage-chat-product-detail-tab gds-tab${e?"":" gengage-chat-product-detail-tab--active is-active"}`,s.type="button",s.setAttribute("aria-selected",e?"false":"true"),s.textContent=a.i18n?.specificationsTab??"Specifications",r.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-product-detail-tab-panel",e&&(c.style.display="none");const l=document.createElement("table");l.className="gengage-chat-product-specs-table";const g=Array.isArray(t)?t:Object.entries(t).map(([p,h])=>({key:p,value:h}));for(const p of g){const h=document.createElement("tr"),d=document.createElement("td");d.className="gengage-chat-product-specs-key",d.textContent=p.key;const b=document.createElement("td");b.className="gengage-chat-product-specs-value",b.textContent=p.value,h.appendChild(d),h.appendChild(b),l.appendChild(h)}c.appendChild(l),i.push(c)}const o=r.querySelectorAll(".gengage-chat-product-detail-tab");o.forEach((s,c)=>{s.addEventListener("click",()=>{o.forEach(l=>{l.classList.remove("gengage-chat-product-detail-tab--active","is-active"),l.setAttribute("aria-selected","false")}),s.classList.add("gengage-chat-product-detail-tab--active","is-active"),s.setAttribute("aria-selected","true"),i.forEach((l,g)=>{l.style.display=g===c?"":"none"})})}),n.appendChild(r);for(const s of i)n.appendChild(s);return n}function kn(e){const t='width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"';switch(e){case"related":return`<svg ${t} aria-hidden="true"><path d="M13 2 3 14h9l-1 8 10-12h-9l1-8z"/></svg>`;case"priceAsc":return`<svg ${t} aria-hidden="true"><polyline points="22 7 13.5 15.5 8.5 10.5 2 17"/><polyline points="16 7 22 7 22 13"/></svg>`;case"priceDesc":return`<svg ${t} aria-hidden="true"><polyline points="22 17 13.5 8.5 8.5 13.5 2 7"/><polyline points="16 17 22 17 22 11"/></svg>`;default:return""}}function Hc(){return'<svg class="gengage-chat-product-sort-chevron" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg>'}function Uc(){return'<svg class="gengage-chat-product-sort-check" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="20 6 9 17 4 12"/></svg>'}function jc(){return'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 3 4 7l4 4"/><path d="M16 21l4-4-4-4"/><path d="M4 7h16"/><path d="M20 17H4"/></svg>'}function Cn(e,t){return e.type===t.type&&e.direction===t.direction}function Sn(e,t,a){if(!a||a.type==="related")return e;const n=e.map(r=>{const i=t.elements[r]?.props?.product,o=i?Number(i.price):NaN;return{id:r,price:Number.isFinite(o)?o:1/0}});return n.sort((r,i)=>r.price===1/0&&i.price===1/0?0:r.price===1/0?1:i.price===1/0?-1:a.direction==="desc"?i.price-r.price:r.price-i.price),n.map(r=>r.id)}function Zc(e,t,a,n){const r=Sn(t,a,n),i=new Map;for(const o of Array.from(e.children)){const s=o.dataset.elementId;s&&i.set(s,o)}for(const o of r){const s=i.get(o);s&&e.appendChild(s)}}function qc(e,t,a,n){const r=document.createElement("div");r.className="gengage-chat-product-grid-wrapper";const i=oa(e),o=i.isConsulting,s=e.children??[],c=document.createElement("div");c.className="gengage-chat-product-grid";const l=n?.panelProductListHeading;if(!o&&s.length>1&&n?.onSortChange){const h=document.createElement("div");h.className="gengage-chat-product-sort-toolbar",h.setAttribute("role","toolbar"),h.setAttribute("aria-label",n.i18n?.sortToolbarAriaLabel??"Sort products");let d=n.productSort??{type:"related"};const b=[{label:n.i18n?.sortRelated??"Related",sortState:{type:"related"},icon:"related"},{label:n.i18n?.sortPriceAsc??"Price ↑",sortState:{type:"price",direction:"asc"},icon:"priceAsc"},{label:n.i18n?.sortPriceDesc??"Price ↓",sortState:{type:"price",direction:"desc"},icon:"priceDesc"}],u=document.createElement("div");u.className="gengage-chat-product-sort-dropdown";const v=document.createElement("button");v.type="button",v.className="gengage-chat-product-sort-trigger gds-btn gds-btn-ghost",v.setAttribute("aria-haspopup","listbox"),v.setAttribute("aria-expanded","false");const m=n.i18n?.sortToolbarAriaLabel??"Sort products",P=document.createElement("span");P.className="gengage-chat-product-sort-trigger-icon";const A=document.createElement("span");A.className="gengage-chat-product-sort-trigger-label";const k=O=>{const f=b.find(L=>Cn(L.sortState,O))??b[0];A.textContent=f.label,P.innerHTML=kn(f.icon),u.dataset.sortIcon=f.icon,v.setAttribute("aria-label",`${m}: ${f.label}`),v.title=f.label};k(d);const x=document.createElement("span");x.className="gengage-chat-product-sort-trigger-chevron",x.innerHTML=Hc(),v.appendChild(P),v.appendChild(A),v.appendChild(x);const N=document.createElement("div");N.className="gengage-chat-product-sort-menu gds-menu",N.hidden=!0,N.setAttribute("role","listbox"),N.setAttribute("aria-label",m);const T=h.ownerDocument;let I=null;const $=()=>{N.hidden=!0,u.classList.remove("gengage-chat-product-sort-dropdown--open"),v.setAttribute("aria-expanded","false"),I?.abort(),I=null},ae=O=>{u.classList.contains("gengage-chat-product-sort-dropdown--open")&&(u.contains(O.target)||$())},oe=O=>{O.key==="Escape"&&(O.preventDefault(),$())},ve=()=>{N.hidden=!1,u.classList.add("gengage-chat-product-sort-dropdown--open"),v.setAttribute("aria-expanded","true"),I=new AbortController;const{signal:O}=I;T.addEventListener("click",ae,{signal:O}),T.addEventListener("keydown",oe,{capture:!0,signal:O})};v.addEventListener("click",O=>{O.stopPropagation(),u.classList.contains("gengage-chat-product-sort-dropdown--open")?$():ve()});for(const O of b){const f=document.createElement("button");f.type="button",f.className="gengage-chat-product-sort-option gds-menu-option",f.setAttribute("role","option");const L=Cn(d,O.sortState);f.setAttribute("aria-selected",L?"true":"false"),L&&f.classList.add("gengage-chat-product-sort-option--active","gds-menu-option-active");const D=O.sortState.type==="related"?"related":`price-${O.sortState.direction??""}`;f.dataset.sortKey=D;const B=document.createElement("span");B.className="gengage-chat-product-sort-option-icon",B.innerHTML=kn(O.icon);const j=document.createElement("span");j.className="gengage-chat-product-sort-option-label",j.textContent=O.label;const Z=document.createElement("span");Z.className="gengage-chat-product-sort-option-check",Z.innerHTML=Uc(),Z.setAttribute("aria-hidden","true"),L||Z.classList.add("gengage-chat-product-sort-option-check--hidden"),f.appendChild(B),f.appendChild(j),f.appendChild(Z),f.addEventListener("click",()=>{d=O.sortState,n.onSortChange?.(O.sortState),Zc(c,s,t,O.sortState),N.querySelectorAll(".gengage-chat-product-sort-option").forEach(q=>{const y=q,E=y.dataset.sortKey===D;y.classList.toggle("gengage-chat-product-sort-option--active",E),y.classList.toggle("gds-menu-option-active",E),y.setAttribute("aria-selected",E?"true":"false"),y.querySelector(".gengage-chat-product-sort-option-check")?.classList.toggle("gengage-chat-product-sort-option-check--hidden",!E)}),k(O.sortState),$()}),N.appendChild(f)}if(u.appendChild(v),u.appendChild(N),h.appendChild(u),n.onToggleComparisonSku){const O=document.createElement("button");O.className="gengage-chat-comparison-toggle-btn gds-btn gds-btn-ghost",O.type="button",n.comparisonSelectMode&&O.classList.add("gengage-chat-comparison-toggle-btn--active"),n.isStreaming&&O.classList.add("gengage-chat-comparison-toggle-btn--hidden");const f=document.createElement("span");f.className="gengage-chat-comparison-toggle-icon",f.innerHTML=jc();const L=document.createElement("span");L.className="gengage-chat-comparison-toggle-label";const D=n.i18n?.compareSelected??"Compare";L.textContent=D,O.setAttribute("aria-label",D),O.title=D,O.appendChild(f),O.appendChild(L),O.addEventListener("click",()=>{n.onToggleComparisonSku?.("")}),h.appendChild(O)}if(l){h.classList.add("gengage-chat-product-sort-toolbar--inline");const O=document.createElement("div");O.className="gengage-chat-product-grid-head";const f=document.createElement("span");f.className="gengage-chat-product-grid-head-title",f.textContent=l,O.appendChild(f);const L=document.createElement("div");L.className="gengage-chat-product-grid-head-actions",L.appendChild(h),O.appendChild(L),r.appendChild(O)}else r.appendChild(h)}else if(l){const h=document.createElement("div");h.className="gengage-chat-product-grid-head";const d=document.createElement("span");d.className="gengage-chat-product-grid-head-title",d.textContent=l,h.appendChild(d),r.appendChild(h)}if(o)Xc(r,c,i,n);else{const h=Sn(s,t,n?.productSort);for(const d of h){if(!t.elements[d])continue;const b=a(d);b&&(b.dataset.elementId=d,c.appendChild(b))}}(n?.isMobile??Qt())&&c.classList.add("gengage-chat-product-grid--mobile"),e.props?.rankingState==="pending"&&(c.classList.add("gengage-chat-product-grid--pending"),c.inert=!0,c.setAttribute("aria-busy","true")),r.appendChild(c);const g=e.props?.endOfList;if(!o&&g!==!0&&s.length>0){const h=n?.i18n?.viewMoreLabel??"Show More",d=document.createElement("button");d.className="gengage-chat-product-grid-view-more",d.type="button",d.textContent=h,d.addEventListener("click",()=>{n?.onAction({title:h,type:"moreProductList",payload:{}})}),r.appendChild(d)}const p=n?.isMobile??Qt();if(n?.comparisonSelectMode&&n.comparisonSelectedSkus&&!p){const h=dn(n.comparisonSelectedSkus,n);r.appendChild(h)}return r}function Vc(e,t){const a=e.props??{},n=a.keyDifferencesHtml,r=a.recommended,i=a.products??[],o=a.attributes??[],s=a.highlights??[],c=a.specialCases,l=a.recommendedText,g=a.winnerHits,p=a.productActions;if(!r)return document.createElement("div");const h={recommended:r,products:i,attributes:o,highlights:s,specialCases:c,locale:t.locale,onProductClick:({sku:b,name:u})=>{t.onProductClick?.({sku:b,url:"",name:u})},pricing:t.pricing};l!==void 0&&(h.recommendedText=l),g!==void 0&&(h.winnerHits=g),p!==void 0&&(h.productActions=p),n!==void 0&&(h.keyDifferencesHtml=n),t.i18n&&(h.i18n={comparisonHeading:t.i18n.panelTitleComparisonResults,recommendedChoiceLabel:t.i18n.recommendedChoiceLabel,highlightsLabel:t.i18n.highlightsLabel,keyDifferencesLabel:t.i18n.keyDifferencesLabel,viewMoreLabel:t.i18n.viewMoreLabel,specialCasesLabel:t.i18n.specialCasesLabel,addToCartButton:t.i18n.addToCartButton});const d=$s(h);return(t.isMobile??Qt())&&d.classList.add("gengage-chat-comparison--mobile"),d}function Gc(e){const t=document.createElement("hr");t.className="gengage-chat-divider";const a=e.props?.label;if(a){const n=document.createElement("div");n.className="gengage-chat-divider-wrapper";const r=document.createElement("span");r.className="gengage-chat-divider-label",r.textContent=a,n.appendChild(t),n.appendChild(r);const i=document.createElement("hr");return i.className="gengage-chat-divider",n.appendChild(i),n}return t}var Lt=new WeakMap;function En(e){return{...tt,...e?.i18n??{}}}function It(e){return typeof e.status=="string"?e.status:"ready"}function na(e){const t=e.findIndex(a=>It(a)!=="loading");return t<0?0:t}function Wc(e){if(typeof e!="string")return;const t=e.trim();if(!t)return;if(/^https?:\/\//i.test(t))return t;let a=t.split(/[?#]/)[0];if(a&&(a=a.replace(/^\/+/,""),a.startsWith("remoteConfig/")&&(a=a.slice(13)),!!a))return`https://configs.gengage.ai/assets/${a}`}function Pn(e,t,a,n){const{grid:r,i18n:i}=e;r.innerHTML="",r.classList.remove("gengage-chat-product-grid--consulting-groups");const o=document.createElement("section");o.className="gengage-chat-consulting-loading-panel";const s=document.createElement("h4");s.className="gengage-chat-consulting-loading-panel-title",s.textContent=Nt(t,n,i),o.appendChild(s);const c=document.createElement("p");if(c.className="gengage-chat-consulting-loading-panel-copy",c.textContent=a==="loading"?i.consultingStyleLoadingDescription:i.consultingStyleUnavailableDescription,o.appendChild(c),a==="loading"){const l=document.createElement("div");l.className="gengage-chat-consulting-loading-grid";for(let g=0;g<3;g+=1){const p=document.createElement("div");p.className="gengage-chat-consulting-loading-card",l.appendChild(p)}o.appendChild(l)}r.appendChild(o)}function Nt(e,t,a){const n=r=>a.consultingFallbackStyleLabel.replace("{index}",String(r));return e.style_label??n(t)}function ra(e,t){const a=e.variations[t];if(!a)return;const{grid:n,source:r,ctx:i,i18n:o}=e;n.innerHTML="",n.classList.remove("gengage-chat-product-grid--consulting-groups");const s=It(a),c=t+1;if(s==="loading"){Pn(e,a,"loading",c);return}if(s!=="ready"&&(!Array.isArray(a.product_list)||a.product_list.length===0)){Pn(e,a,"unavailable",c);return}const l=Array.isArray(a.product_list)?a.product_list:[],g=r==="watch_expert"?[]:Array.isArray(a.recommendation_groups)?a.recommendation_groups:[];if(g.length>0){n.classList.add("gengage-chat-product-grid--consulting-groups");const p=new Map;for(const m of l){const P=typeof m?.sku=="string"?m.sku:void 0;P&&p.set(P,m)}const h=(m,P,A,k)=>{if(P.length===0)return;const x=document.createElement("section");x.className="gengage-chat-consulting-group";const N=document.createElement("div");N.className="gengage-chat-consulting-group-header";const T=document.createElement("h4");if(T.className="gengage-chat-consulting-group-label",T.textContent=`${m} (${P.length})`,N.appendChild(T),typeof k=="string"&&k.trim().length>0){const $=document.createElement("p");$.className="gengage-chat-consulting-group-reason",$.textContent=k,N.appendChild($)}x.appendChild(N);const I=document.createElement("div");I.className="gengage-chat-product-grid gengage-chat-consulting-group-grid",A&&I.classList.add("gengage-chat-consulting-group-grid--single-group"),I.style.setProperty("--consulting-group-columns",String(Math.max(1,Math.min(4,P.length))));for(const $ of P){const ae=ta({type:"ProductCard",props:{product:$}},i??{onAction:()=>{}});I.appendChild(ae)}x.appendChild(I),n.appendChild(x)},d=new Set,b=[];for(const m of g){const P=(Array.isArray(m.skus)?m.skus.filter(x=>typeof x=="string"&&x.trim().length>0):[]).map(x=>(d.add(x),p.get(x))).filter(x=>!!x);if(P.length===0)continue;const A=typeof m.label=="string"&&m.label.trim().length>0?m.label:o.consultingFallbackGroupLabel,k=typeof m.reason=="string"?m.reason:void 0;b.push({labelText:A,products:P,...k!==void 0?{reasonText:k}:{}})}const u=l.filter(m=>{const P=typeof m?.sku=="string"?m.sku:"";return P.length>0&&!d.has(P)});u.length>0&&b.push({labelText:o.consultingOtherCompatibleProductsLabel,products:u});const v=b.length===1;for(const m of b)h(m.labelText,m.products,v,m.reasonText);return}for(const p of l){const h=ta({type:"ProductCard",props:{product:p}},i??{onAction:()=>{}});n.appendChild(h)}}function ia(e,t,a,n){const r=It(t),i=n.consultingStyleLoadingBadge,o=n.consultingStyleUnavailableBadge;e.classList.remove("gengage-chat-consulting-style-btn--loading","gengage-chat-consulting-style-btn--muted"),r==="loading"?e.classList.add("gengage-chat-consulting-style-btn--loading"):r!=="ready"&&e.classList.add("gengage-chat-consulting-style-btn--muted"),e.setAttribute("aria-label",Nt(t,a+1,n));let s=e.querySelector(".gengage-chat-consulting-style-media");s?s.innerHTML="":(s=document.createElement("div"),s.className="gengage-chat-consulting-style-media",e.appendChild(s));const c=Wc(t.image_url);if(c&&ye(c)){const g=document.createElement("img");g.className="gengage-chat-consulting-style-image",g.draggable=!1,be(g,"src",c),g.alt=Nt(t,a+1,n),g.loading="lazy",Ie(g),s.appendChild(g)}const l=document.createElement("span");if(l.className="gengage-chat-consulting-style-caption",l.textContent=Nt(t,a+1,n),s.appendChild(l),r==="loading"||r!=="ready"){const g=document.createElement("span");g.className="gengage-chat-consulting-style-status",g.textContent=r==="loading"?i:o,s.appendChild(g)}}function An(e,t,a,n){e.addEventListener("click",()=>{const r=Lt.get(t);r&&r.selectedIndex!==n&&(r.selectedIndex=n,a.querySelectorAll(".gengage-chat-consulting-style-btn").forEach((i,o)=>{i.classList.toggle("gengage-chat-consulting-style-btn--active",o===n)}),ra(r,n))})}function Kc(e,t,a,n,r){const i=En(r),o=na(n),s=document.createElement("div");s.className="gengage-chat-consulting-style-picker";const c={grid:t,source:a,ctx:r,variations:n,i18n:i,selectedIndex:o};Lt.set(s,c);const l=document.createElement("div");l.className="gengage-chat-consulting-style-picker-title",l.textContent=(a==="watch_expert"?i.watchStylesPreparedTitle:i.beautyStylesPreparedTitle).replace("{count}",String(n.length)),s.appendChild(l);const g=document.createElement("div");g.className="gengage-chat-consulting-style-grid",s.appendChild(g),n.forEach((p,h)=>{const d=document.createElement("button");d.type="button",d.className="gengage-chat-consulting-style-btn gds-card",h===o&&d.classList.add("gengage-chat-consulting-style-btn--active"),ia(d,p,h,i),An(d,s,g,h),g.appendChild(d)}),e.appendChild(s),ra(c,o)}function Yc(e,t,a,n){const r=e.querySelector(".gengage-chat-consulting-style-picker"),i=Jc(e);if(!r||!i)return!1;const o=r.querySelector(".gengage-chat-consulting-style-grid");if(!o)return!1;const s=En(n);let c=Lt.get(r);if(c)c.grid=i,c.source=t,c.ctx=n,c.variations=a,c.i18n=s;else{const d={grid:i,source:t,ctx:n,variations:a,i18n:s,selectedIndex:na(a)};Lt.set(r,d),c=d}const l=r.querySelector(".gengage-chat-consulting-style-picker-title");l&&(l.textContent=(t==="watch_expert"?s.watchStylesPreparedTitle:s.beautyStylesPreparedTitle).replace("{count}",String(a.length)));const g=c;let p=g.selectedIndex;p>=a.length&&(p=Math.max(0,a.length-1)),p<0&&(p=0),a.length>0&&It(a[p]??{})==="loading"&&(p=na(a)),g.selectedIndex=p;const h=[...o.querySelectorAll(".gengage-chat-consulting-style-btn")];if(h.length===0)return!1;for(let d=0;d<a.length;d+=1){const b=a[d];let u=h[d];u?ia(u,b,d,s):(u=document.createElement("button"),u.type="button",u.className="gengage-chat-consulting-style-btn gds-card",ia(u,b,d,s),An(u,r,o,d),o.appendChild(u),h[d]=u)}for(;o.querySelectorAll(".gengage-chat-consulting-style-btn").length>a.length;)o.lastElementChild?.remove();return o.querySelectorAll(".gengage-chat-consulting-style-btn").forEach((d,b)=>{d.classList.toggle("gengage-chat-consulting-style-btn--active",b===g.selectedIndex)}),ra(g,g.selectedIndex),!0}function Jc(e){const t=[...e.children];for(let a=t.length-1;a>=0;a-=1){const n=t[a];if(n.classList.contains("gengage-chat-product-grid"))return n}return e.querySelector(":scope > .gengage-chat-product-grid")}function oa(e){const t=typeof e.props?.source=="string"?e.props.source:void 0,a=(Array.isArray(e.props?.styleVariations)?e.props.styleVariations:[]).filter(n=>typeof n.style_label=="string"&&n.style_label.trim().length>0);return{isConsulting:Ha(t)&&a.length>0,source:t,styleVariations:a}}function Xc(e,t,a,n){Kc(e,t,a.source,a.styleVariations,n)}function Qc(e){return!e.isConsulting||e.styleVariations.length===0?!0:e.styleVariations.some(t=>(typeof t.status=="string"?t.status:"ready")!=="loading")}function el(e,t,a){return!t.isConsulting||!t.source?!1:Yc(e,t.source,t.styleVariations,a)}var tl=`<svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
49
|
+
`).filter(a=>a.trim());return t.length<=1?e:"<ul>"+t.map(a=>`<li>${a.trim()}</li>`).join("")+"</ul>"}function Us(e,t){const a=Ae(t);if(!a)return;const n=document.createElement("template");n.innerHTML=a;const r=Array.from(n.content.querySelectorAll("li"));if(r.length>0){for(const o of r){const s=document.createElement("li");s.innerHTML=Ae(o.innerHTML),e.appendChild(s)}return}const i=document.createElement("li");on(t)?i.innerHTML=a:i.textContent=t,e.appendChild(i)}function on(e){return/<\/?[a-z][\s\S]*>/i.test(e)}function mt(e,t=18){const a="http://www.w3.org/2000/svg",n=document.createElementNS(a,"svg");n.setAttribute("width",String(t)),n.setAttribute("height",String(t)),n.setAttribute("viewBox","0 0 24 24"),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","2"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),n.setAttribute("aria-hidden","true");for(const r of e){const i=document.createElementNS(a,"path");i.setAttribute("d",r),n.appendChild(i)}return n}var Xt="General",sn=220,js=6;function Zs(e){if(typeof e!="string")return[Xt];const t=e.split(/[,;|/]+/).map(a=>a.trim().replace(/\s+/g," ")).filter(a=>a.length>0);return t.length===0?[Xt]:Array.from(new Set(t.map(a=>a.toLocaleLowerCase()))).map(a=>t.find(n=>n.toLocaleLowerCase()===a)??Xt)}function qs(e){return e==="positive"||e==="negative"||e==="neutral"?e:"neutral"}function Vs(e){if(typeof e!="string")return"";const t=e.trim().replace(/\s+/g," ");return t.length<=sn?t:`${t.slice(0,sn-3).trimEnd()}...`}function Gs(e){return e.positive>e.negative?"positive":e.negative>e.positive?"negative":"neutral"}function Ws(e){return mt(e==="positive"?["M7 17 17 7","M7 7h10v10"]:e==="negative"?["M7 7 17 17","M17 7v10H7"]:["M5 12h14"],14)}function Ks(e,t="1 customer mentions",a="customers mention"){return e===1?t:`${e} ${a}`}function Ys(e,t){const a=document.createElement("div");a.className="gengage-chat-review-highlights";const n=e.props?.reviews;if(!Array.isArray(n)||n.length===0){const u=document.createElement("div");return u.className="gengage-chat-review-empty",u.textContent=t?.emptyReviewsMessage??"No review summary found.",a.appendChild(u),a}const r=n.filter(u=>u!==null&&typeof u=="object"),i=new Map;for(const u of r){const v=qs(u.review_class),m=Vs(u.review_text),P=Zs(u.review_tag);for(const A of P){const k=A.toLocaleLowerCase();let x=i.get(k);if(x||(x={key:k,label:A,mentions:0,positive:0,negative:0,neutral:0,snippets:[]},i.set(k,x)),x.mentions+=1,v==="positive"?x.positive+=1:v==="negative"?x.negative+=1:x.neutral+=1,m.length>0&&x.snippets.length<js&&!x.snippets.some(N=>N.text===m)){const N={text:m,tone:v};u.review_rating!==void 0&&String(u.review_rating).length>0&&(N.rating=u.review_rating),x.snippets.push(N)}}}const o=Array.from(i.values()).sort((u,v)=>v.mentions!==u.mentions?v.mentions-u.mentions:u.label.localeCompare(v.label));if(o.length===0){const u=document.createElement("div");return u.className="gengage-chat-review-empty",u.textContent=t?.emptyReviewsMessage??"No review summary found.",a.appendChild(u),a}const s=(t?.reviewFilterPositive??"positive").toLowerCase(),c=(t?.reviewFilterNegative??"negative").toLowerCase(),l=document.createElement("div");l.className="gengage-chat-review-subjects-heading",l.textContent=t?.reviewSubjectsHeading??"Select to learn more",a.appendChild(l);let g=o[0]?.key??null;const p=document.createElement("div");p.className="gengage-chat-review-subjects gds-toolbar gds-toolbar-compact";const h=document.createElement("section");h.className="gengage-chat-review-detail gds-evidence-card";const d=()=>{for(;h.firstChild;)h.removeChild(h.firstChild);if(!g)return;const u=o.find(A=>A.key===g);if(!u)return;const v=document.createElement("div");v.className="gengage-chat-review-detail-meta";const m=document.createElement("span");if(m.className="gengage-chat-review-detail-mentions",m.textContent=`${Ks(u.mentions,t?.reviewCustomersMentionSingular,t?.reviewCustomersMentionPlural)} "${u.label}"`,v.appendChild(m),u.positive>0){const A=document.createElement("span");A.className="gengage-chat-review-detail-positive",A.textContent=`${u.positive} ${s}`,v.appendChild(A)}if(u.negative>0){const A=document.createElement("span");A.className="gengage-chat-review-detail-negative",A.textContent=`${u.negative} ${c}`,v.appendChild(A)}h.appendChild(v);const P=document.createElement("div");P.className="gengage-chat-review-snippets";for(const A of u.snippets){const k=document.createElement("article");k.className="gengage-chat-review-snippet",k.dataset.tone=A.tone;const x=document.createElement("div");if(x.className="gengage-chat-review-snippet-text",x.textContent=`"${A.text}"`,k.appendChild(x),A.rating!==void 0&&String(A.rating).length>0){const N=document.createElement("div");N.className="gengage-chat-review-snippet-rating",N.textContent=`★ ${String(A.rating)}`,k.appendChild(N)}P.appendChild(k)}h.appendChild(P)},b=()=>{for(const u of p.querySelectorAll(".gengage-chat-review-subject")){const v=u.dataset.subjectKey===g;u.classList.toggle("gengage-chat-review-subject--active",v),u.classList.toggle("gds-chip-active",v),u.setAttribute("aria-pressed",String(v))}};for(const u of o){const v=Gs(u),m=document.createElement("button");m.type="button",m.className="gengage-chat-review-subject gds-chip",m.dataset.subjectKey=u.key,m.dataset.tone=v;const P=document.createElement("span");P.className="gengage-chat-review-subject-icon",P.appendChild(Ws(v)),m.appendChild(P);const A=document.createElement("span");A.className="gengage-chat-review-subject-label",A.textContent=u.label,m.appendChild(A);const k=document.createElement("span");k.className="gengage-chat-review-subject-count",k.textContent=`(${u.mentions})`,m.appendChild(k),m.addEventListener("click",()=>{g=u.key,b(),d()}),p.appendChild(m)}return a.appendChild(p),b(),d(),a.appendChild(h),a}function Js(e){if(!e)return;const t=e.discountReason??e.discount_reason??e.campaignReason??e.campaign_reason;if(typeof t!="string")return;const a=t.trim();return a.length>0?a:void 0}function at(e,t){if(e.productPriceUi?.showCampaignReason===!0)return Js(t)}function ft(e,t){const a=t?.originalPriceStyle??t?.price_original_style;if(a==="inline"||a==="strikethrough")return a;const n=e.productPriceUi?.originalPriceStyle;return n==="inline"||n==="strikethrough"?n:"strikethrough"}function Ct(e){const t=document.createElement("div");return t.className="gengage-chat-campaign-reason",t.textContent=e,t}function St(e,t){for(const n of["campaignReasonLogoUrl","campaign_reason_logo_url","discountBadgeLogoUrl","discount_badge_logo_url"]){const r=t?.[n];if(typeof r=="string"&&r.trim()){const i=r.trim();if(Pe(i))return i}}const a=e.productPriceUi?.campaignBadgeLogoUrl;if(typeof a=="string"&&a.trim()){const n=a.trim();if(Pe(n))return n}}function Et(e){const t=document.createElement("div");if(t.className="gengage-chat-campaign-price-badge",t.dataset.gengagePart="campaign-price-badge",e.logoUrl){const i=document.createElement("div");i.className="gengage-chat-campaign-price-badge__logo";const o=document.createElement("img");o.alt="",o.loading="lazy",o.src=e.logoUrl,Ie(o),i.appendChild(o),t.appendChild(i)}const a=document.createElement("div");a.className="gengage-chat-campaign-price-badge__body";const n=document.createElement("div");n.className="gengage-chat-campaign-price-badge__reason",n.textContent=e.reasonText;const r=document.createElement("span");return r.className="gengage-chat-campaign-price-badge__sale",r.textContent=e.salePriceFormatted,a.appendChild(n),a.appendChild(r),t.appendChild(a),t}function cn(e){const t=e.product.sku;if(typeof t=="string"&&t.length>0)return t;const a=e.action?.payload;return a&&typeof a=="object"&&"sku"in a&&typeof a.sku=="string"?a.sku:null}var Xs={winner:"roleWinner",best_value:"roleBestValue",best_alternative:"roleBestAlternative"};function ln(e,t){if(!e||!t)return null;const a=Xs[e];return a?t[a]??e:e}function Qs(e){const t=e.rating,a=typeof t=="number"?t:typeof t=="string"?parseFloat(t):NaN;if(Number.isNaN(a)||a<=0)return null;const n=document.createElement("div");n.className="gengage-chat-ai-toppick-rating",n.dataset.gengagePart="ai-top-pick-rating";const r=document.createElement("span");r.className="gengage-chat-ai-toppick-rating-icon",r.setAttribute("aria-hidden","true"),r.innerHTML='<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M12 3.6l2.58 5.23 5.77.84-4.17 4.07.98 5.75L12 16.78l-5.16 2.71.99-5.75L3.66 9.67l5.76-.84L12 3.6z"/></svg>';const i=document.createElement("span");return i.className="gengage-chat-ai-toppick-rating-value",i.textContent=a.toFixed(1),n.appendChild(r),n.appendChild(i),n}function ec(e,t,a,n,r){const i=document.createElement("div");i.className="gengage-chat-ai-toppick-media",i.dataset.gengagePart="ai-top-pick-media";const o=e.product,s=o.imageUrl;if(s&&Pe(s)){const l=document.createElement("img");l.className="gengage-chat-ai-toppick-img",l.dataset.gengagePart="ai-top-pick-image",be(l,"src",s),l.loading="lazy",l.alt=t,Ie(l),i.appendChild(l)}const c=cn(e);if(c&&!r?.skipOverlayActions){const l=document.createElement("div");if(l.className="gengage-chat-product-card-img-actions",n.onFavoriteToggle){const d=document.createElement("button");d.className="gengage-chat-favorite-btn",d.type="button",d.dataset.gengageFavoriteSku=c,d.setAttribute("aria-label",n.i18n?.addToFavoritesLabel??"Add to favorites");const b=n.favoritedSkus?.has(c)??!1;b&&d.classList.add("gengage-chat-favorite-btn--active"),d.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="${b?"currentColor":"none"}" stroke="currentColor" stroke-width="2"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>`,d.addEventListener("click",u=>{u.stopPropagation(),d.classList.toggle("gengage-chat-favorite-btn--active"),d.querySelector("svg")?.setAttribute("fill",d.classList.contains("gengage-chat-favorite-btn--active")?"currentColor":"none"),n.onFavoriteToggle?.(c,o)}),l.appendChild(d)}const g=n.i18n?.findSimilarLabel??"Find Similar",p=document.createElement("button");p.className="gengage-chat-find-similar-pill",p.type="button",p.setAttribute("aria-label",g),p.dataset.tooltip=g,p.innerHTML='<span class="gengage-chat-find-similar-pill-icon" aria-hidden="true"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"><circle cx="10.5" cy="10.5" r="6.5"/><path d="M16 16l5.5 5.5"/></svg></span>';const h=document.createElement("span");h.className="gengage-chat-find-similar-pill-text",h.textContent=g,p.appendChild(h),p.addEventListener("click",d=>{d.stopPropagation(),n.onAction({title:g,type:"findSimilar",payload:{sku:c,...s?{image_url:s}:{}}})}),l.appendChild(p),i.appendChild(l)}a.appendChild(i)}function tc(e,t,a){const n=e.price,r=e.originalPrice;if(!n)return;const i=at(a,e),o=ft(a,e),s=!!(r&&r!==n),c=!!(i&&s),l=St(a,e),g=document.createElement("div");if(g.className="gengage-chat-ai-toppick-price",g.dataset.gengagePart="ai-top-pick-price",c){const p=Et({reasonText:i,salePriceFormatted:J(n,a.pricing),...l!==void 0?{logoUrl:l}:{}});if(s&&o==="inline"){g.classList.add("gengage-chat-ai-toppick-price--inline"),g.appendChild(p);const h=document.createElement("span");h.className="gengage-chat-ai-toppick-price-sep",h.setAttribute("aria-hidden","true");const d=document.createElement("span");d.className="gengage-chat-ai-toppick-original-price",d.textContent=J(r,a.pricing),g.appendChild(h),g.appendChild(d)}else{const h=document.createElement("span");h.className="gengage-chat-ai-toppick-original-price",h.textContent=J(r,a.pricing),g.appendChild(h),g.appendChild(document.createTextNode(" ")),g.appendChild(p)}t.appendChild(g);return}if(s&&o==="inline"){g.classList.add("gengage-chat-ai-toppick-price--inline");const p=document.createElement("span");p.className="gengage-chat-ai-toppick-price-current",p.textContent=J(n,a.pricing);const h=document.createElement("span");h.className="gengage-chat-ai-toppick-price-sep",h.setAttribute("aria-hidden","true");const d=document.createElement("span");d.className="gengage-chat-ai-toppick-original-price",d.textContent=J(r,a.pricing),g.appendChild(p),g.appendChild(h),g.appendChild(d)}else if(s){const p=document.createElement("span");p.className="gengage-chat-ai-toppick-original-price",p.textContent=J(r,a.pricing),g.appendChild(p),g.appendChild(document.createTextNode(" "));const h=document.createElement("span");h.className="gengage-chat-ai-toppick-price-current",h.textContent=J(n,a.pricing),g.appendChild(h)}else{const p=document.createElement("span");p.className="gengage-chat-ai-toppick-price-current",p.textContent=J(n,a.pricing),g.appendChild(p)}if(i){const p=document.createElement("div");p.className="gengage-chat-ai-toppick-price-stack",p.appendChild(Ct(i)),p.appendChild(g),t.appendChild(p)}else t.appendChild(g)}function ac(e,t,a){const n=typeof e.reason=="string"?e.reason.trim():"",r=a.hideUserReviews!==!0&&typeof e.reviewHighlight=="string"?e.reviewHighlight.trim():"";if(!(!n&&!r)){if(n){const i=document.createElement("p");i.className="gengage-chat-ai-toppick-reason",i.dataset.gengagePart="ai-top-pick-reason",i.textContent=n,t.appendChild(i)}if(r){const i=document.createElement("div");i.className="gengage-chat-ai-toppick-review",i.dataset.gengagePart="ai-top-pick-review",i.textContent=r,t.appendChild(i)}}}function gn(e,t,a){const n=document.createElement("div");n.className=a?"gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--winner gds-card":"gengage-chat-ai-toppick-card gengage-chat-ai-toppick-card--compact gds-card",n.dataset.gengagePart=a?"ai-top-pick-card-winner":"ai-top-pick-card";const r=e.product,i=cn(e),o=r.url??"",s=r.cartCode,c=r.inStock,l=!!(i&&s&&c!==!1),g=e.action;i&&t.onProductClick?(n.classList.add("gds-clickable"),n.addEventListener("click",x=>{if(x.target.closest(".gengage-chat-ai-toppick-cta")||x.target.closest(".gengage-chat-favorite-btn")||x.target.closest(".gengage-chat-find-similar-pill"))return;const N=r.name;t.onProductClick?.({sku:i,url:o,...N?{name:N}:{}})})):g&&(n.classList.add("gds-clickable"),n.addEventListener("click",x=>{x.target.closest(".gengage-chat-ai-toppick-cta")||x.target.closest(".gengage-chat-favorite-btn")||x.target.closest(".gengage-chat-find-similar-pill")||t.onAction(g)}));const p=r.name||"Product image",h=!a&&t.isMobile===!0,d=a?ln(e.role,t.i18n)??t.i18n?.roleWinner??"TOP MATCH":ln(e.role,t.i18n);if(d&&!h){const x=document.createElement("span");x.className="gengage-chat-ai-toppick-badge gds-badge",x.dataset.gengagePart="ai-top-pick-role-badge",x.textContent=d,n.appendChild(x)}const b=document.createElement("div");b.className="gengage-chat-ai-toppick-top-row",b.dataset.gengagePart="ai-top-pick-top-row",ec(e,p,b,t,{skipOverlayActions:h});const u=document.createElement("div");if(u.className="gengage-chat-ai-toppick-body",u.dataset.gengagePart="ai-top-pick-body",d&&h){const x=document.createElement("div");x.className="gengage-chat-ai-toppick-role-line",x.dataset.gengagePart="ai-top-pick-role-line",x.textContent=d,u.appendChild(x)}const v=r.name;if(v){const x=document.createElement("div");x.className="gengage-chat-ai-toppick-name",x.dataset.gengagePart="ai-top-pick-name",x.textContent=v,u.appendChild(x)}const m=Qs(r);m&&u.appendChild(m),tc(r,u,t),e.labels&&e.labels.length>0&&u.appendChild(rc(e.labels)),b.appendChild(u),n.appendChild(b);const P=document.createElement("div");if(P.className="gengage-chat-ai-toppick-detail",P.dataset.gengagePart="ai-top-pick-detail",a)ac(e,P,t);else{const x=typeof e.reason=="string"?e.reason.trim():"";if(x){const N=document.createElement("p");N.className="gengage-chat-ai-toppick-snippet",N.dataset.gengagePart="ai-top-pick-snippet",N.textContent=x,P.appendChild(N)}}P.childNodes.length>0&&n.appendChild(P);const A=!!(i&&t.topPicksLoadingSku===i),k=(l||g)&&!h;if(A||l||g){const x=document.createElement("div");if(x.className="gengage-chat-ai-toppick-spinner",x.dataset.gengagePart="ai-top-pick-spinner",x.style.display=A?"":"none",n.appendChild(x),k){const N=document.createElement("button");N.className="gengage-chat-ai-toppick-cta gds-btn gds-btn-primary",N.dataset.gengagePart="ai-top-pick-cta",N.type="button",N.textContent=l?t.i18n?.addToCartButton??"Add to Cart":t.i18n?.viewDetails??"View Details",N.addEventListener("click",T=>{if(T.stopPropagation(),l){t.onAction({title:t.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:i,cartCode:s,quantity:1}});return}if(g){if(g.type==="findSimilar"&&i&&t.onProductClick){const I=r.name;t.onProductClick({sku:i,url:o,...I?{name:I}:{}});return}t.onAction(g)}}),n.appendChild(N)}}return n}function nc(e,t){const a=document.createElement("div");a.className="gengage-chat-ai-top-picks",a.dataset.gengagePart="ai-top-picks";const n=e.props?.suggestions??[];if(n.length===0)return a;const r=document.createElement("div");r.className="gengage-chat-ai-top-picks-scroll",r.dataset.gengagePart="ai-top-picks-scroll";const i=n[0];if(r.appendChild(gn(i,t,!0)),n.length>1){const o=document.createElement("div");o.className="gengage-chat-ai-top-picks-rest",o.dataset.gengagePart="ai-top-picks-rest";for(let s=1;s<n.length;s++){const c=n[s],l=c.role==="winner";o.appendChild(gn(c,t,l))}r.appendChild(o)}return a.appendChild(r),a}function rc(e){const t=document.createElement("div");t.className="gengage-chat-ai-toppick-labels",t.dataset.gengagePart="ai-top-pick-labels";for(const a of e){const n=document.createElement("span");n.className="gengage-chat-ai-toppick-label gds-chip",n.dataset.gengagePart="ai-top-pick-label",n.dataset.sentiment=a.sentiment??"neutral",n.textContent=a.label,t.appendChild(n)}return t}function ic(e,t){const a=document.createElement("div");a.className="gengage-chat-grounding-review gds-evidence-card",a.dataset.gengagePart="grounding-review-card";const n=e.props??{},r=n.title,i=n.reviewCount,o=n.action,s=t.i18n?.groundingReviewCta??"Read Reviews",c=document.createElement("span");c.className="gengage-chat-grounding-review-icon",c.appendChild(mt(["M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z","M8 9h8","M8 13h6"])),a.appendChild(c);const l=document.createElement("div");l.className="gengage-chat-grounding-review-body",l.dataset.gengagePart="grounding-review-body";const g=document.createElement("div");if(g.className="gengage-chat-grounding-review-title",g.dataset.gengagePart="grounding-review-title",g.textContent=r??t.i18n?.customerReviewsTitle??"Customer Reviews",l.appendChild(g),i){const b=document.createElement("div");b.className="gengage-chat-grounding-review-subtitle",b.dataset.gengagePart="grounding-review-subtitle",b.textContent=(t.i18n?.groundingReviewSubtitle??"{count} yorum mevcut").replace("{count}",i),l.appendChild(b)}a.appendChild(l);const p=document.createElement("span");p.className="gengage-chat-grounding-review-cta",p.dataset.gengagePart="grounding-review-cta";const h=document.createElement("span");h.textContent=s,p.appendChild(h);const d=document.createElement("span");return d.className="gengage-chat-grounding-review-cta-icon",d.appendChild(mt(["M5 12h14","M15 8l4 4-4 4"],14)),p.appendChild(d),a.appendChild(p),o&&(a.classList.add("gds-clickable"),a.setAttribute("role","button"),a.setAttribute("tabindex","0"),a.addEventListener("click",()=>t.onAction(o)),a.addEventListener("keydown",b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),t.onAction(o))})),a}function oc(e){if(e.action.type!=="findSimilar")return e.action;const t=e.action.payload&&typeof e.action.payload=="object"?e.action.payload:null,a=typeof t?.input=="string"&&t.input.trim()||typeof t?.text=="string"&&t.text.trim()||e.name.trim();if(!a)return e.action;const n={text:a,is_suggested_text:1};if(typeof t?.sku=="string"&&t.sku.trim()&&(n.sku=t.sku),Array.isArray(t?.group_skus)){const r=t.group_skus.filter(i=>typeof i=="string"&&i.length>0);r.length>0&&(n.group_skus=r)}return{title:e.action.title,type:"inputText",payload:n}}function sc(e,t){const a=document.createElement("div");a.className="gengage-chat-grouping-cards",a.dataset.gengagePart="ai-grouping-cards";const n=e.props?.entries??[];if(n.length===0)return a;const r=e.props?.sectionTitle,i=typeof r=="string"&&r.trim().length>0?r.trim():t.i18n?.aiBrowseCategoriesTitle;if(i){const s=document.createElement("h3");s.className="gengage-chat-grouping-section-title",s.textContent=i,a.appendChild(s)}const o=document.createElement("div");o.className="gengage-chat-grouping-cards-scroll",o.dataset.gengagePart="ai-grouping-cards-scroll";for(const s of n){const c=document.createElement("div");if(c.className="gengage-chat-grouping-card gds-card",c.dataset.gengagePart="ai-grouping-card",c.classList.add("gds-clickable"),c.addEventListener("click",()=>t.onAction(oc(s))),s.image&&Pe(s.image)){const h=document.createElement("img");h.className="gengage-chat-grouping-card-img",h.dataset.gengagePart="ai-grouping-card-image",h.draggable=!1,h.src=s.image,h.alt=s.name,h.width=64,h.height=64,c.appendChild(h)}const l=document.createElement("div");l.className="gengage-chat-grouping-card-body",l.dataset.gengagePart="ai-grouping-card-body";const g=document.createElement("span");if(g.className="gengage-chat-grouping-card-name",g.dataset.gengagePart="ai-grouping-card-name",g.textContent=s.name,l.appendChild(g),s.labels&&s.labels.length>0){const h=document.createElement("div");h.className="gengage-chat-grouping-card-labels",h.dataset.gengagePart="ai-grouping-card-labels";for(const d of s.labels.slice(0,2)){const b=document.createElement("span");b.className="gengage-chat-grouping-card-label gds-chip",b.textContent=d,h.appendChild(b)}l.appendChild(h)}c.appendChild(l);const p=document.createElement("span");p.className="gengage-chat-grouping-card-arrow",p.textContent="↳",c.insertBefore(p,c.firstChild),o.appendChild(c)}return a.appendChild(o),a}function cc(e,t){const a=document.createElement("div");a.className="gengage-chat-suggested-search-cards",a.dataset.gengagePart="ai-suggested-search-cards";const n=e.props?.entries??[];if(n.length===0)return a;for(const r of n){const i=document.createElement("div");if(i.className="gengage-chat-suggested-search-card gds-card",i.dataset.gengagePart="ai-suggested-search-card",i.classList.add("gds-clickable"),i.addEventListener("click",()=>t.onAction(r.action)),r.image&&Pe(r.image)){const c=document.createElement("img");c.className="gengage-chat-suggested-search-card-img",c.dataset.gengagePart="ai-suggested-search-card-image",c.src=r.image,c.alt=r.shortName,c.width=64,c.height=64,i.appendChild(c)}const o=document.createElement("div");o.className="gengage-chat-suggested-search-card-body",o.dataset.gengagePart="ai-suggested-search-card-body";const s=document.createElement("div");s.className="gengage-chat-suggested-search-card-name",s.dataset.gengagePart="ai-suggested-search-card-name",s.textContent=r.shortName,o.appendChild(s),i.appendChild(o),a.appendChild(i)}return a}function dn(e,t){const a=e.length>=2,n=t.i18n?.compareSelected??"Compare",r=t.comparisonSelectionWarning,i=document.createElement("div");i.className="gengage-chat-comparison-floating-btn",i.dataset.gengagePart="comparison-dock";const o=document.createElement("div");o.className="gengage-chat-comparison-floating-summary";const s=document.createElement("span");s.className="gengage-chat-comparison-floating-count",s.textContent=String(e.length),o.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-comparison-floating-copy";const l=document.createElement("div");if(l.className="gengage-chat-comparison-floating-title",l.textContent=a?`${n} (${e.length})`:t.i18n?.compareMinHint??"Select at least 2 products",c.appendChild(l),r){const p=document.createElement("div");p.className="gengage-chat-comparison-floating-warning",p.setAttribute("role","status"),p.setAttribute("aria-live","polite"),p.textContent=r,c.appendChild(p)}o.appendChild(c),i.appendChild(o);const g=document.createElement("button");if(g.className="gengage-chat-comparison-floating-action gds-btn gds-btn-primary",g.type="button",g.textContent=n,g.disabled=!a,a||g.classList.add("gengage-chat-comparison-floating-action--disabled"),g.addEventListener("click",()=>{a&&t.onAction({title:n,type:"getComparisonTable",payload:{sku_list:[...e],gengage_analytics_source:"floating_compare_dock"}})}),i.appendChild(g),t.onToggleComparisonSku){const p=document.createElement("button");p.className="gengage-chat-comparison-floating-close gds-btn gds-btn-ghost gds-icon-btn",p.dataset.gengagePart="comparison-dock-close",p.type="button",p.setAttribute("aria-label",t.i18n?.closeAriaLabel??"Close"),p.innerHTML='<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" aria-hidden="true"><path d="M18 6L6 18"/><path d="M6 6l12 12"/></svg>',p.addEventListener("click",h=>{h.preventDefault(),h.stopPropagation(),t.onToggleComparisonSku?.("")}),i.appendChild(p)}return i}function lc(e){const t=document.createElement("div");t.className="gengage-chat-pros-cons gds-card-soft",t.dataset.gengagePart="pros-cons";const a=e.props?.productName;if(a){const i=document.createElement("h4");i.className="gengage-chat-pros-cons-heading",i.textContent=a,t.appendChild(i)}const n=e.props?.pros,r=e.props?.cons;if(n&&n.length>0){const i=document.createElement("ul");i.className="gengage-chat-pros-cons-list",i.dataset.gengagePart="pros-list";for(const o of n){const s=document.createElement("li");s.className="gengage-chat-pros-cons-item",s.dataset.gengagePart="pros-item";const c=document.createElement("span");c.className="gengage-chat-pros-cons-icon gengage-chat-pros-cons-icon--pro",c.textContent="✓",s.appendChild(c);const l=document.createElement("span");l.textContent=o,s.appendChild(l),i.appendChild(s)}t.appendChild(i)}if(r&&r.length>0){const i=document.createElement("ul");i.className="gengage-chat-pros-cons-list",i.dataset.gengagePart="cons-list";for(const o of r){const s=document.createElement("li");s.className="gengage-chat-pros-cons-item",s.dataset.gengagePart="cons-item";const c=document.createElement("span");c.className="gengage-chat-pros-cons-icon gengage-chat-pros-cons-icon--con",c.textContent="✗",s.appendChild(c);const l=document.createElement("span");l.textContent=o,s.appendChild(l),i.appendChild(s)}t.appendChild(i)}return t}function gc(e,t){const a=e.props?.groups??[],n=e.props?.filterTags??[],r=document.createElement("div");if(r.className="gengage-chat-categories",r.dataset.gengagePart="categories-container",a.length===0)return r;const i=document.createElement("div");i.className="gengage-chat-categories-tabs gds-toolbar",i.dataset.gengagePart="categories-tab-bar",i.setAttribute("role","tablist");const o=[],s=[],c=l=>{for(let g=0;g<o.length;g++){const p=g===l;o[g].classList.toggle("gengage-chat-categories-tab--active",p),o[g].classList.toggle("is-active",p),o[g].setAttribute("aria-selected",String(p)),o[g].tabIndex=p?0:-1,s[g].style.display=p?"":"none"}};for(let l=0;l<a.length;l++){const g=a[l],p=`gengage-cat-tab-${l}`,h=`gengage-cat-panel-${l}`,d=document.createElement("button");if(d.className="gengage-chat-categories-tab gds-tab",d.type="button",d.dataset.gengagePart="categories-tab",d.id=p,d.setAttribute("role","tab"),d.setAttribute("aria-controls",h),d.setAttribute("aria-selected",String(l===0)),d.tabIndex=l===0?0:-1,l===0&&d.classList.add("gengage-chat-categories-tab--active","is-active"),g.image&&Pe(g.image)){const v=document.createElement("img");v.className="gengage-chat-categories-tab-image",v.draggable=!1,v.src=g.image,v.alt=g.groupName,v.loading="lazy",Ie(v),d.appendChild(v)}const b=document.createElement("span");b.className="gengage-chat-categories-tab-text",b.textContent=g.groupName,d.appendChild(b),d.addEventListener("click",()=>c(l)),d.addEventListener("keydown",v=>{let m=-1;v.key==="ArrowRight"||v.key==="ArrowDown"?m=(l+1)%a.length:v.key==="ArrowLeft"||v.key==="ArrowUp"?m=(l-1+a.length)%a.length:v.key==="Home"?m=0:v.key==="End"&&(m=a.length-1),m>=0&&(v.preventDefault(),c(m),o[m].focus())}),o.push(d),i.appendChild(d);const u=document.createElement("div");u.className="gengage-chat-categories-grid",u.dataset.gengagePart="categories-panel",u.id=h,u.setAttribute("role","tabpanel"),u.setAttribute("aria-labelledby",p),l!==0&&(u.style.display="none");for(const v of g.products){const m=dc(v,t);u.appendChild(m)}s.push(u)}r.appendChild(i);for(const l of s)r.appendChild(l);if(n.length>0){const l=document.createElement("div");l.className="gengage-chat-categories-filter-tags gds-toolbar",l.dataset.gengagePart="categories-filter-tags";for(const g of n){const p=document.createElement("button");p.className="gengage-chat-categories-filter-tag gds-chip",p.type="button",p.dataset.gengagePart="categories-filter-tag",p.textContent=g.title,g.action&&p.addEventListener("click",()=>{t.onAction(g.action)}),l.appendChild(p)}r.appendChild(l)}return r}function dc(e,t){const a=document.createElement("div");if(a.className="gengage-chat-product-card gds-card gds-product-card gds-card-interactive",a.dataset.gengagePart="categories-product-card",e.imageUrl&&Pe(e.imageUrl)){const i=document.createElement("img");i.className="gengage-chat-product-card-img",i.draggable=!1,i.src=e.imageUrl,i.alt=e.name,i.loading="lazy",Ie(i),a.appendChild(i)}const n=document.createElement("div");n.className="gengage-chat-product-card-body";const r=document.createElement("div");if(r.className="gengage-chat-product-card-name",r.textContent=e.name,n.appendChild(r),e.price){const i=document.createElement("div");i.className="gengage-chat-product-card-price",i.textContent=J(e.price,t.pricing),n.appendChild(i)}return a.appendChild(n),(t.onProductSelect||t.onAction)&&(a.classList.add("gds-clickable"),a.addEventListener("click",()=>{if(e.sku){t.onAction({title:e.name,type:"launchSingleProduct",payload:{sku:e.sku}});return}t.onProductSelect?.(e)})),a}function pc(e,t){const a=document.createElement("div");a.className="gengage-chat-handoff-notice gds-evidence-card gds-evidence-card-warning",a.dataset.gengagePart="handoff-notice",a.setAttribute("role","alert");const n=document.createElement("span");n.className="gengage-chat-handoff-notice-icon",n.textContent="👤",n.setAttribute("aria-hidden","true"),a.appendChild(n);const r=document.createElement("h4");r.className="gengage-chat-handoff-notice-heading",r.textContent=t.i18n?.handoffHeading??"Transferring to a support agent",a.appendChild(r);const i=e.props?.summary;if(i){const o=document.createElement("p");o.className="gengage-chat-handoff-notice-summary",o.textContent=i,a.appendChild(o)}return a}function hc(e,t){const a=e.props?.product??e.props,n=document.createElement("div");if(n.className="gengage-chat-product-summary gds-card",n.dataset.gengagePart="product-summary-card",!a)return n;n.classList.add("gds-clickable"),n.addEventListener("click",m=>{m.target.closest("a")||t.onProductSelect?.(a)});const r=a.imageUrl;if(r&&ye(r)){const m=document.createElement("div");m.className="gengage-chat-product-summary__image",m.dataset.gengagePart="product-summary-image";const P=document.createElement("img");P.loading="lazy",be(P,"src",r),P.alt=a.name||"Product image",Ie(P),m.appendChild(P),n.appendChild(m)}const i=document.createElement("div");i.className="gengage-chat-product-summary__content",i.dataset.gengagePart="product-summary-content";const o=a.brand,s=a.name;if(s){const m=document.createElement("div");m.className="gengage-chat-product-summary__name",m.dataset.gengagePart="product-summary-name";const P=o&&!s.toLowerCase().startsWith(o.toLowerCase())?`${o} ${s}`:s;m.textContent=P,m.title=P,i.appendChild(m)}const c=a.rating,l=a.reviewCount;if(t.hideUserReviews!==!0&&typeof c=="number"&&Number.isFinite(c)&&c>0){const m=document.createElement("div");if(m.className="gengage-chat-product-summary__rating",m.dataset.gengagePart="product-summary-rating",m.appendChild(nn(c)),typeof l=="number"&&Number.isFinite(l)){const P=document.createElement("span");P.className="gengage-chat-product-summary__review-count",P.textContent=` (${l})`,m.appendChild(P)}i.appendChild(m)}const g=a.price,p=a.originalPrice;if(g){const m=at(t,a),P=ft(t,a),A=!!(p&&p!==g),k=document.createElement("div");k.className="gengage-chat-product-summary__price",k.dataset.gengagePart="product-summary-price";const x=!!(m&&A),N=St(t,a);if(x){const T=Et({reasonText:m,salePriceFormatted:J(g,t.pricing),...N!==void 0?{logoUrl:N}:{}});if(A&&P==="inline"){k.classList.add("gengage-chat-product-summary__price--inline"),k.appendChild(T);const I=document.createElement("span");I.className="gengage-chat-product-summary__price-sep",I.setAttribute("aria-hidden","true");const $=document.createElement("span");$.className="gengage-chat-product-summary__price-original",$.textContent=J(p,t.pricing),k.appendChild(I),k.appendChild($)}else{const I=document.createElement("span");I.className="gengage-chat-product-summary__price-original",I.textContent=J(p,t.pricing),k.appendChild(I),k.appendChild(document.createTextNode(" ")),k.appendChild(T)}i.appendChild(k)}else{if(A&&P==="inline"){k.classList.add("gengage-chat-product-summary__price--inline");const T=document.createElement("span");T.className="gengage-chat-product-summary__price-current",T.textContent=J(g,t.pricing);const I=document.createElement("span");I.className="gengage-chat-product-summary__price-sep",I.setAttribute("aria-hidden","true");const $=document.createElement("span");$.className="gengage-chat-product-summary__price-original",$.textContent=J(p,t.pricing),k.appendChild(T),k.appendChild(I),k.appendChild($)}else if(A){const T=document.createElement("span");T.className="gengage-chat-product-summary__price-original",T.textContent=J(p,t.pricing),k.appendChild(T),k.appendChild(document.createTextNode(" "));const I=document.createElement("span");I.className="gengage-chat-product-summary__price-current",I.textContent=J(g,t.pricing),k.appendChild(I)}else{const T=document.createElement("span");T.className="gengage-chat-product-summary__price-current",T.textContent=J(g,t.pricing),k.appendChild(T)}if(m){const T=document.createElement("div");T.className="gengage-chat-product-summary__price-stack",T.appendChild(Ct(m)),T.appendChild(k),i.appendChild(T)}else i.appendChild(k)}}n.appendChild(i);const h=a.url,d=a.sku,b=a.cartCode??a.cart_code,u=typeof b=="string"&&b.trim()?b.trim():void 0,v=a.inStock;if(d&&u&&v!==!1){const m=document.createElement("button");m.type="button",m.className="gengage-chat-product-summary__cta gds-chip gds-chip-active",m.dataset.gengagePart="product-summary-cta",m.textContent=t.i18n?.addToCartButton??"Add to Cart",m.addEventListener("click",P=>{P.stopPropagation(),t.onAction({title:t.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:d,cartCode:u,quantity:1}})}),n.appendChild(m)}else if(h&&ye(h)){const m=document.createElement("a");m.className="gengage-chat-product-summary__cta gds-chip gds-chip-active",m.dataset.gengagePart="product-summary-cta",be(m,"href",h),be(m,"target","_blank"),be(m,"rel","noopener noreferrer"),m.textContent=t.i18n?.productCtaLabel??"View",n.appendChild(m)}return n}var uc={PhotoAnalysisCard:({element:e,context:t})=>fs(e,t),BeautyPhotoStep:({element:e,context:t})=>Ka(e,t)};function Qt(){return window.innerWidth<768}var pn={ActionButtons:({element:e,context:t})=>mc(e,t),ActionButton:({element:e,context:t})=>fc(e,t),ProductCard:({element:e,context:t})=>ta(e,t),ProductDetailsPanel:({element:e,context:t})=>Dc(e,t),ProductGrid:({element:e,spec:t,renderElement:a,context:n})=>qc(e,t,a,n),ReviewHighlights:({element:e,context:t})=>t.hideUserReviews===!0?null:Ys(e,{emptyReviewsMessage:t.i18n?.emptyReviewsMessage,reviewFilterPositive:t.i18n?.reviewFilterPositive,reviewFilterNegative:t.i18n?.reviewFilterNegative,reviewCustomersMentionSingular:t.i18n?.reviewCustomersMentionSingular,reviewCustomersMentionPlural:t.i18n?.reviewCustomersMentionPlural,reviewSubjectsHeading:t.i18n?.reviewSubjectsHeading}),ComparisonTable:({element:e,context:t})=>Vc(e,t),AITopPicks:({element:e,context:t})=>nc(e,t),GroundingReviewCard:({element:e,context:t})=>t.hideUserReviews===!0?null:ic(e,t),AIGroupingCards:({element:e,context:t})=>sc(e,t),AISuggestedSearchCards:({element:e,context:t})=>cc(e,t),ProsAndCons:({element:e})=>lc(e),CategoriesContainer:({element:e,context:t})=>gc(e,t),HandoffNotice:({element:e,context:t})=>pc(e,t),ProductSummaryCard:({element:e,context:t})=>hc(e,t),Divider:({element:e})=>Gc(e),...uc},ea=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const a=document.createElement("div");for(const n of e.children){const r=t(n);r&&a.appendChild(r)}return a};function hn(){return{...pn}}function un(e,t,a=pn,n=ea){return Or({spec:e,context:t,registry:a,containerClassName:"gengage-chat-uispec",unknownRenderer:n})}function mc(e,t){const a=document.createElement("div");a.className="gengage-chat-action-buttons";const n=e.props?.buttons;if(n)for(const r of n){const i=document.createElement("button");i.className="gengage-chat-action-btn",i.textContent=r.label,i.addEventListener("click",()=>t.onAction(r.action)),a.appendChild(i)}return a}function fc(e,t){const a=document.createElement("button");a.className="gengage-chat-action-btn";const n=e.props?.label;typeof n=="string"&&(a.textContent=n);const r=e.props?.action;return r&&a.addEventListener("click",()=>t.onAction(r)),a}function mn(e,t,a,n,r){e.replaceChildren();const i=ft(t,a),o=!!(r&&n&&r!==n),s=at(t,a),c=!!(s&&o),l=St(t,a);if(!n||parseFloat(n)<=0)return;if(c){const p=Et({reasonText:s,salePriceFormatted:J(n,t.pricing),...l!==void 0?{logoUrl:l}:{}});if(o&&i==="inline"){e.classList.add("gengage-chat-product-card-price-block--inline");const h=document.createElement("div");h.className="gengage-chat-product-card-price-row",h.appendChild(p);const d=document.createElement("span");d.className="gengage-chat-product-card-price-sep",d.setAttribute("aria-hidden","true");const b=document.createElement("span");b.className="gengage-chat-product-card-original-price",b.textContent=J(r,t.pricing),h.appendChild(d),h.appendChild(b),e.appendChild(h);return}if(e.classList.remove("gengage-chat-product-card-price-block--inline"),e.appendChild(p),o){e.appendChild(document.createTextNode(" "));const h=document.createElement("span");h.className="gengage-chat-product-card-original-price",h.textContent=J(r,t.pricing),e.appendChild(h)}return}if(o&&i==="inline"){e.classList.add("gengage-chat-product-card-price-block--inline");const p=document.createElement("div");p.className="gengage-chat-product-card-price-row";const h=document.createElement("span");h.className="gengage-chat-product-card-current-price",h.textContent=J(n,t.pricing);const d=document.createElement("span");d.className="gengage-chat-product-card-price-sep",d.setAttribute("aria-hidden","true");const b=document.createElement("span");b.className="gengage-chat-product-card-original-price",b.textContent=J(r,t.pricing),p.appendChild(h),p.appendChild(d),p.appendChild(b),e.appendChild(p);return}e.classList.remove("gengage-chat-product-card-price-block--inline");const g=document.createElement("span");if(g.className="gengage-chat-product-card-current-price",g.textContent=J(n,t.pricing),e.appendChild(g),o){e.appendChild(document.createTextNode(" "));const p=document.createElement("span");p.className="gengage-chat-product-card-original-price",p.textContent=J(r,t.pricing),e.appendChild(p)}}function fn(e,t,a,n,r,i,o){e.classList.remove("gengage-chat-product-details-price--inline"),e.replaceChildren(),e.className="gengage-chat-product-details-price";const s=at(t,a),c=!!(s&&o),l=St(t,a);if(c){const p=Et({reasonText:s,salePriceFormatted:J(n,t.pricing),...l!==void 0?{logoUrl:l}:{}});if(o&&i==="inline"){e.classList.add("gengage-chat-product-details-price--inline"),e.appendChild(p);const h=document.createElement("span");h.className="gengage-chat-product-details-price-sep",h.setAttribute("aria-hidden","true");const d=document.createElement("span");d.className="gengage-chat-product-details-original-price",d.textContent=J(r,t.pricing),e.appendChild(h),e.appendChild(d)}else{if(o){const h=document.createElement("span");h.className="gengage-chat-product-details-original-price",h.textContent=J(r,t.pricing),e.appendChild(h),e.appendChild(document.createTextNode(" "))}e.appendChild(p)}}else if(o&&i==="inline"){e.classList.add("gengage-chat-product-details-price--inline");const p=document.createElement("span");p.className="gengage-chat-product-details-current-price",p.textContent=J(n,t.pricing);const h=document.createElement("span");h.className="gengage-chat-product-details-price-sep",h.setAttribute("aria-hidden","true");const d=document.createElement("span");d.className="gengage-chat-product-details-original-price",d.textContent=J(r,t.pricing),e.appendChild(p),e.appendChild(h),e.appendChild(d)}else{if(o){const h=document.createElement("span");h.className="gengage-chat-product-details-original-price",h.textContent=J(r,t.pricing),e.appendChild(h),e.appendChild(document.createTextNode(" "))}const p=document.createElement("span");p.className="gengage-chat-product-details-current-price",p.textContent=J(n,t.pricing),e.appendChild(p)}const g=Pt(a,"discountPercent","price_discount_rate");if(!t.hideProductDiscountBadge&&typeof g=="number"&&g>0){const p=document.createElement("span");p.className="gengage-chat-product-details-discount-badge",p.textContent=`%${an(g)}`,e.appendChild(p)}}function ta(e,t){const a=document.createElement("div");a.className="gengage-chat-product-card gds-card gds-product-card gds-card-interactive";const n=e.props?.product??e.props;if(!n)return a;const r=n.sku;r&&(a.dataset.sku=r);const i=e.props?.action;(t.onProductSelect||i)&&(a.classList.add("gds-clickable"),a.addEventListener("click",f=>{if(!a.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")&&!f.target.closest(".gengage-chat-product-card-atc")&&!f.target.closest(".gengage-chat-product-card-cta")){if(i){t.onAction(i);return}t.onProductSelect?.(n)}}));const o=n.imageUrl;if(o&&ye(o)){const f=document.createElement("div");f.className="gengage-chat-product-card-img-wrapper";const L=document.createElement("img");L.className="gengage-chat-product-card-img",L.loading="lazy",be(L,"src",o);const D=n.name;D&&(L.alt=D),Ie(L),f.appendChild(L);const B=n.discountPercent;if(!t.hideProductDiscountBadge&&typeof B=="number"&&B>0){const E=document.createElement("span");E.className="gengage-chat-product-card-discount-badge",E.textContent=`%${an(B)}`,f.appendChild(E)}const j=document.createElement("div");j.className="gengage-chat-product-card-img-actions";const Z=n.sku;if(Z&&t.onFavoriteToggle){const E=document.createElement("button");E.className="gengage-chat-favorite-btn",E.type="button",E.dataset.gengageFavoriteSku=Z,E.setAttribute("aria-label",t.i18n?.addToFavoritesLabel??"Add to favorites");const S=t.favoritedSkus?.has(Z)??!1;S&&E.classList.add("gengage-chat-favorite-btn--active"),E.innerHTML=`<svg width="14" height="14" viewBox="0 0 24 24" fill="${S?"currentColor":"none"}" stroke="currentColor" stroke-width="2"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>`,E.addEventListener("click",z=>{z.stopPropagation(),E.classList.toggle("gengage-chat-favorite-btn--active");const M=E.querySelector("svg");M&&M.setAttribute("fill",E.classList.contains("gengage-chat-favorite-btn--active")?"currentColor":"none"),t.onFavoriteToggle(Z,n)}),j.appendChild(E)}const q=n.sku,y=t.i18n?.findSimilarLabel??"Find Similar";if(q){const E=document.createElement("button");E.className="gengage-chat-find-similar-pill",E.type="button",E.setAttribute("aria-label",y),E.dataset.tooltip=y,E.innerHTML='<span class="gengage-chat-find-similar-pill-icon" aria-hidden="true"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round"><circle cx="10.5" cy="10.5" r="6.5"/><path d="M16 16l5.5 5.5"/></svg></span>';const S=document.createElement("span");S.className="gengage-chat-find-similar-pill-text",S.textContent=y,E.appendChild(S),E.addEventListener("click",z=>{z.stopPropagation(),t.onAction({title:y,type:"findSimilar",payload:{sku:q,...o?{image_url:o}:{}}})}),j.appendChild(E)}j.childElementCount>0&&f.appendChild(j),a.appendChild(f)}const s=document.createElement("div");s.className="gengage-chat-product-card-body";const c=n.brand;if(c){const f=document.createElement("div");f.className="gengage-chat-product-card-brand",f.textContent=c,s.appendChild(f)}const l=n.rating,g=n.reviewCount,p=n.price,h=n.originalPrice,d=n.price_async,b=at(t,n),u=ft(t,n),v=!!(h&&p&&h!==p&&parseFloat(p)>0),m=!!(b&&v),P=!!(b&&!m||v&&u==="inline"),A=typeof l=="number"&&Number.isFinite(l)&&l>0,k=document.createElement("div");k.className="gengage-chat-product-card-meta-row";const x=document.createElement("div");x.className="gengage-chat-product-card-price gengage-chat-product-card-price-block";const N=P?(()=>{const f=document.createElement("div");return f.className="gengage-chat-product-card-price-stack",b&&!m&&f.appendChild(Ct(b)),f.appendChild(x),f})():x;if(d===!0){const f=document.createElement("span");f.className="gengage-chat-price-skeleton",x.appendChild(f),setTimeout(()=>{f.parentElement&&(p&&parseFloat(p)>0?mn(x,t,n,p,n.originalPrice):f.remove())},300)}else p&&parseFloat(p)>0&&mn(x,t,n,p,h);if((x.childElementCount>0||d===!0)&&k.appendChild(N),A){const f=document.createElement("div");f.className="gengage-chat-product-card-rating gengage-chat-product-card-rating-compact";const L=Jt(l),D=[`${L.toFixed(1)}`,"out of 5 stars"];typeof g=="number"&&Number.isFinite(g)&&D.push(`(${g} reviews)`),f.setAttribute("aria-label",D.join(" "));const B=document.createElement("span");B.className="gengage-chat-product-card-rating-compact-star",B.setAttribute("aria-hidden","true"),B.innerHTML='<svg width="12" height="12" viewBox="0 0 24 24" fill="currentColor"><path d="M12 3.6l2.58 5.23 5.77.84-4.17 4.07.98 5.75L12 16.78l-5.16 2.71.99-5.75L3.66 9.67l5.76-.84L12 3.6z"/></svg>';const j=document.createElement("span");j.className="gengage-chat-product-card-rating-compact-value",j.textContent=L.toFixed(1),f.appendChild(B),f.appendChild(j),k.appendChild(f)}k.childElementCount===0&&(k.classList.add("gengage-chat-product-card-meta-row--empty"),k.setAttribute("aria-hidden","true")),s.appendChild(k);const T=n.name;if(T){const f=document.createElement("div");f.className="gengage-chat-product-card-name",f.textContent=T,f.title=T,s.appendChild(f)}const I=n.inStock;if(t.hideStockStatus!==!0&&typeof I=="boolean"){const f=document.createElement("div");f.className=`gengage-chat-product-card-stock ${I?"is-in-stock":"is-out-of-stock"}`,f.textContent=I?t.i18n?.inStockLabel??"In Stock":t.i18n?.outOfStockLabel??"Out of Stock",s.appendChild(f)}a.appendChild(s);const $=n.url,ae=n.sku,oe=n.cartCode,ve=!!(oe&&ae&&I!==!1),O=t.i18n?.productCtaLabel??"View";if(ve){const f=document.createElement("div");f.className="gengage-chat-product-card-buy-footer";const L=document.createElement("button");L.type="button",L.className="gengage-chat-product-card-buy-trigger",L.textContent=O,L.addEventListener("click",D=>{D.stopPropagation(),t.onAction({title:t.i18n?.addToCartButton??O,type:"addToCart",payload:{sku:ae,cartCode:oe,quantity:1}})}),f.appendChild(L),a.appendChild(f)}else if(i){const f=document.createElement("button");f.className="gengage-chat-product-card-cta",f.type="button",f.textContent=i.type==="launchSingleProduct"?O:i.title||O,f.addEventListener("click",L=>{if(a.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){L.stopPropagation();return}t.onAction(i)}),a.appendChild(f)}else if($&&ye($)){const f=document.createElement("a");f.className="gengage-chat-product-card-cta",be(f,"href",$),be(f,"target","_blank"),be(f,"rel","noopener noreferrer"),f.textContent=O,f.addEventListener("click",L=>{if(a.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){L.preventDefault(),L.stopPropagation();return}t.onProductClick&&ae&&(L.preventDefault(),t.onProductClick({sku:ae,url:$,...T?{name:T}:{}}))}),a.appendChild(f)}if(t.comparisonSelectMode&&ae&&t.onToggleComparisonSku){const f=document.createElement("div");f.className="gengage-chat-comparison-select-wrapper";const L=t.comparisonSelectedSkus?.includes(ae)??!1;L&&f.classList.add("gengage-chat-comparison-select-wrapper--selected");const D=n.name??ae,B=t.i18n?.comparisonSelectCardHint??"Tap anywhere on the card to add or remove it from comparison.";f.setAttribute("role","group"),f.setAttribute("aria-label",`${String(D)}. ${B}`);const j=document.createElement("button");j.type="button",j.className="gengage-chat-comparison-checkbox",j.dataset.selected=L?"true":"false",j.setAttribute("aria-pressed",L?"true":"false");const Z=document.createElement("span");Z.className="gengage-chat-comparison-checkbox-icon",Z.innerHTML=L?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6L9 17l-5-5"/></svg>':'<span class="gengage-chat-comparison-checkbox-dot"></span>';const q=document.createElement("span");q.className="gengage-chat-comparison-checkbox-label",q.textContent=L?t.i18n?.comparisonSelectedLabel??"Selected":t.i18n?.comparisonSelectLabel??"Select to compare",j.appendChild(Z),j.appendChild(q),j.addEventListener("click",E=>{E.stopPropagation(),t.onToggleComparisonSku?.(ae)});const y=document.createElement("div");return y.className="gengage-chat-comparison-card-hint",y.setAttribute("aria-hidden","true"),y.textContent=B,f.addEventListener("click",E=>{E.target.closest(".gengage-chat-comparison-checkbox")||(E.stopPropagation(),t.onToggleComparisonSku?.(ae))}),f.appendChild(j),f.appendChild(y),f.appendChild(a),f}return a}var bn=new Set(["color","colour","renk","renk kodu","color code"]),bc=new Set(["size","beden","boyut"]),vc=new Set(["finish","bitiş","bitişi"]),yc=["variants","variantOptions","variant_options","productVariants","product_variants","options"],_c=new Set(["H2","H3","H4","P","BR","UL","OL","LI","STRONG","B","EM","I"]),xc=new Set(["SCRIPT","STYLE","NOSCRIPT","IFRAME","OBJECT","EMBED"]);function we(e,...t){for(const a of t){const n=e[a];if(typeof n=="string"){const r=n.trim();if(r.length>0)return r}}}function Pt(e,...t){for(const a of t){const n=e[a];if(typeof n=="number"&&Number.isFinite(n))return n;if(typeof n=="string"){const r=Number(n.replace(",","."));if(Number.isFinite(r))return r}}}function At(e,...t){for(const a of t){const n=e[a];if(typeof n=="boolean")return n}}function wc(e,...t){for(const a of t){const n=e[a];if(n&&typeof n=="object"&&!Array.isArray(n))return n}}function kc(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim().length>0):[]}function Cc(e){const t=[...kc(e.images),we(e,"imageUrl","image_url","image")].filter(a=>!!a&&ye(a));return Array.from(new Set(t))}function Sc(e){return typeof DOMParser<"u"?(new DOMParser().parseFromString(e,"text/html").body.textContent??"").replace(/\s+/g," ").trim():e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim()}function Ec(e){const t=we(e,"description_html","descriptionHtml");if(t){const n=Sc(t);if(n)return{text:n,html:t}}const a=we(e,"description");return a?{text:a}:void 0}function Tt(e){return Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object")return null;const a=t,n=we(a,"key","name","label","title"),r=a.value,i=typeof r=="string"||typeof r=="number"||typeof r=="boolean"?String(r).trim():void 0;return!n||!i?null:{key:n,value:i}}).filter(t=>t!==null):e&&typeof e=="object"?Object.entries(e).map(([t,a])=>{const n=typeof a=="string"||typeof a=="number"||typeof a=="boolean"?String(a).trim():void 0;return!t||!n?null:{key:t,value:n}}).filter(t=>t!==null):[]}function vn(e){const t=Tt(e.features);return t.length>0?t:Tt(e.specifications)}function Pc(e){const t=e.specifications,a=Tt(t);if(a.length>0)return Array.isArray(t)?a:Object.fromEntries(a.map(r=>[r.key,r.value]));const n=Tt(e.features);return n.length>0?n:void 0}function He(e,...t){return we(e,...t)}function yn(e,...t){return Pt(e,...t)}function _n(e){return He(e,"value","option_value","attribute_value","label","title","name","variant_name","sku")}function xn(e){const t=He(e,"type","attribute","option_name","attribute_name");return t||(He(e,"value")?He(e,"name","variant_name"):void 0)}function Ac(e){const t=xn(e)?.toLowerCase();return!!(we(e,"color","colour","color_hex","hex","swatch","swatchColor")||t&&bn.has(t))}function wn(e){if(!e)return;const t=e.trim();if(!(!t||t.includes(";"))&&(typeof CSS<"u"&&CSS.supports?.("color",t)||/^#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)))return t}function Tc(e){const t=wn(He(e,"swatchColor","swatch","color_hex","hex","color","colour"));if(t)return t;if(Ac(e))return wn(_n(e))}function Lc(e){return He(e,"image","imageUrl","image_url","swatchImage","swatch_image")}function Ic(e){return yn(e,"price_discounted","priceDiscounted")??He(e,"price_discounted","priceDiscounted")??yn(e,"price")??He(e,"price")}function Nc(e){const t=e.trim().toLowerCase();return bn.has(t)||bc.has(t)||vc.has(t)}function zc(e){const t=e.trim().toLowerCase();return t==="renk kodu"?"Renk":t==="color code"?"Color":e.trim()}function Mc(e){for(const t of yc){const a=e[t];if(!Array.isArray(a))continue;const n=a.filter(r=>!!r&&typeof r=="object"&&!Array.isArray(r));if(n.length>0)return n}}function Bc(e){const t=Mc(e);if(t)return t;const a=we(e,"sku"),n=At(e,"inStock","in_stock"),r=[],i=new Set,o=(c,l)=>{if(!Nc(c)||typeof l!="string"&&typeof l!="number"&&typeof l!="boolean")return;const g=String(l).trim();if(!g)return;const p=zc(c),h=`${p.toLowerCase()}:${g.toLowerCase()}`;i.has(h)||(i.add(h),r.push({name:p,value:g,sku:a,inStock:n}))},s=wc(e,"facetHits","facet_hits");if(s)for(const[c,l]of Object.entries(s))o(c,l);for(const c of vn(e))o(c.key,c.value);return r}function Rc(e,t){const a=Array.from(new Set(e.map(xn).filter(n=>!!n)));return a.length===1?`${e.length} ${a[0]}`:t.i18n?.variantsLabel??"Variants"}function Dc(e,t){const a=document.createElement("article");a.className="gengage-chat-product-details-panel";const n=e.props?.product??e.props;if(!n)return a;const r=we(n,"name"),i=we(n,"brand"),o=we(n,"sku"),s=we(n,"cartCode","cart_code"),c=we(n,"price"),l=we(n,"originalPrice","price_original"),g=At(n,"price_async"),p=at(t,n),h=ft(t,n),d=!!(l&&c&&l!==c),b=At(n,"inStock","in_stock"),u=Pt(n,"reviewCount","review_count"),v=Pt(n,"rating"),m=Cc(n),P=vn(n).slice(0,4);if(m.length>1){const f=document.createElement("div");f.className="gengage-chat-product-details-media gengage-chat-product-details-gallery gengage-chat-product-details-img-wrap";const L=document.createElement("img");L.className="gengage-chat-product-details-img",be(L,"src",m[0]),L.alt=r??"Product image",Ie(L),f.appendChild(L);const D=document.createElement("div");D.className="gengage-chat-product-gallery-thumbs";const B=6;let j=null,Z=0;const q=t.i18n,y=q?.galleryPrevAriaLabel??"Previous image",E=q?.galleryNextAriaLabel??"Next image",S=U=>U==="prev"?'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="15 18 9 12 15 6"/></svg>':'<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="9 18 15 12 9 6"/></svg>',z=document.createElement("button");z.type="button",z.className="gengage-chat-product-gallery-nav gengage-chat-product-gallery-nav--prev gds-btn gds-btn-ghost gds-icon-btn",z.setAttribute("aria-label",y),z.innerHTML=S("prev");const M=document.createElement("button");M.type="button",M.className="gengage-chat-product-gallery-nav gengage-chat-product-gallery-nav--next gds-btn gds-btn-ghost gds-icon-btn",M.setAttribute("aria-label",E),M.innerHTML=S("next");const R=()=>{z.disabled=Z<=0,M.disabled=Z>=m.length-1},H=U=>{if(U<0||U>=m.length||U===Z)return;const ce=m[U];if(!ce)return;be(L,"src",ce);const X=D.querySelectorAll(".gengage-chat-product-gallery-thumb");j&&j.classList.remove("gengage-chat-product-gallery-thumb--active"),U<B&&X[U]?(X[U].classList.add("gengage-chat-product-gallery-thumb--active"),j=X[U]):j=null,Z=U,R()};for(let U=0;U<m.length;U++){const ce=m[U];if(U>=B)break;const X=document.createElement("img");X.className="gengage-chat-product-gallery-thumb",U===0&&(X.classList.add("gengage-chat-product-gallery-thumb--active"),j=X),be(X,"src",ce),X.alt=`${r??"Product"} ${U+1}`,X.width=48,X.height=48,Ie(X),X.addEventListener("click",()=>{H(U)}),D.appendChild(X)}if(m.length>B){const U=document.createElement("span");U.className="gengage-chat-product-gallery-thumb-more",U.textContent=`+${m.length-B}`,D.appendChild(U)}z.addEventListener("click",U=>{U.stopPropagation(),H(Z-1)}),M.addEventListener("click",U=>{U.stopPropagation(),H(Z+1)}),R();let ne=0;const te=50;L.addEventListener("touchstart",U=>{ne=U.changedTouches[0].clientX},{passive:!0}),L.addEventListener("touchend",U=>{const ce=U.changedTouches[0].clientX,X=ne-ce;Math.abs(X)<te||H(X>0?Math.min(Z+1,m.length-1):Math.max(Z-1,0))}),f.appendChild(z),f.appendChild(M),f.appendChild(D),a.appendChild(f)}else if(m.length===1){const f=document.createElement("div");f.className="gengage-chat-product-details-media gengage-chat-product-details-img-wrap";const L=document.createElement("img");L.className="gengage-chat-product-details-img",L.loading="lazy",be(L,"src",m[0]),Ie(L),L.alt=r??"Product image",f.appendChild(L),a.appendChild(f)}const A=document.createElement("div");if(A.className="gengage-chat-product-details-content",i&&(!r||!r.toLowerCase().startsWith(i.toLowerCase()))){const f=document.createElement("div");f.className="gengage-chat-product-details-brand",f.textContent=i,A.appendChild(f)}if(r){const f=document.createElement("h3");f.className="gengage-chat-product-details-title",f.textContent=r,f.title=r,A.appendChild(f)}if(t.hideUserReviews!==!0&&typeof v=="number"&&Number.isFinite(v)&&v>0){const f=document.createElement(o?"button":"div");f.className="gengage-chat-product-details-rating",o&&(f.type="button",f.classList.add("gengage-chat-product-details-rating--clickable"),f.setAttribute("aria-label",t.i18n?.groundingReviewCta??"Read Reviews"),f.addEventListener("click",()=>{t.onAction({title:t.i18n?.customerReviewsTitle??"Customer Reviews",type:"reviewSummary",payload:{sku:o}})})),f.appendChild(nn(v));const L=document.createElement("span");if(L.className="gengage-chat-product-details-rating-value",L.textContent=Jt(v).toFixed(1),f.appendChild(L),typeof u=="number"&&Number.isFinite(u)){const D=document.createElement("span");D.className="gengage-chat-product-details-review-count",D.textContent=` (${u})`,f.appendChild(D)}A.appendChild(f)}{const f=!!(p&&d);let L=A;if(p&&!f){const B=document.createElement("div");B.className="gengage-chat-product-details-price-stack",B.appendChild(Ct(p)),A.appendChild(B),L=B}const D=document.createElement("div");if(D.className="gengage-chat-product-details-price",g===!0){const B=document.createElement("span");B.className="gengage-chat-price-skeleton",D.appendChild(B),L.appendChild(D),setTimeout(()=>{if(B.parentElement)if(c&&parseFloat(c)>0)fn(D,t,n,c,l,h,d);else{const j=D.parentElement;D.remove(),j?.classList.contains("gengage-chat-product-details-price-stack")&&j.remove()}},300)}else if(c&&parseFloat(c)>0)fn(D,t,n,c,l,h,d),L.appendChild(D);else if(p){const B=L;B.classList.contains("gengage-chat-product-details-price-stack")&&B.remove()}}if(t.hideStockStatus!==!0&&typeof b=="boolean"){const f=document.createElement("div");f.className=`gengage-chat-product-details-stock ${b?"is-in-stock":"is-out-of-stock"}`,f.textContent=b?t.i18n?.inStockLabel??"In Stock":t.i18n?.outOfStockLabel??"Out of Stock",A.appendChild(f)}const k=n.promotions;if(k&&k.length>0){const f=document.createElement("div");f.className="gengage-chat-product-details-promos";for(const L of k.slice(0,3)){if(!L||/%(0(\.0+)?)\s/.test(L))continue;const D=document.createElement("span");D.className="gengage-chat-product-details-promo-badge",D.textContent=L,D.title=L,f.appendChild(D)}f.childElementCount>0&&A.appendChild(f)}if(P.length>0){const f=document.createElement("dl");f.className="gengage-chat-product-details-facts";for(const L of P){const D=document.createElement("div");D.className="gengage-chat-product-details-fact";const B=document.createElement("dt");B.textContent=L.key;const j=document.createElement("dd");j.textContent=L.value,D.appendChild(B),D.appendChild(j),f.appendChild(D)}A.appendChild(f)}const x=Bc(n);if(x.length>0){const f=document.createElement("div");f.className="gengage-chat-product-variants";const L=document.createElement("div");L.className="gengage-chat-product-variants-label",L.textContent=Rc(x,t),f.appendChild(L);const D=document.createElement("div");D.className="gengage-chat-product-variants-list";for(const B of x){const j=_n(B),Z=He(B,"sku");if(!j&&!Z)continue;const q=document.createElement("button");q.className="gengage-chat-product-variant-btn gds-chip",q.type="button";const y=j??Z??"";q.title=y;const E=At(B,"in_stock","inStock");Z&&o&&Z===o?(q.classList.add("gengage-chat-product-variant-btn--active"),q.setAttribute("aria-pressed","true")):q.setAttribute("aria-pressed","false"),E===!1&&(q.classList.add("gengage-chat-product-variant-btn--out"),q.disabled=!0);const S=Lc(B),z=Tc(B);if(S&&ye(S)){const H=document.createElement("img");H.className="gengage-chat-product-variant-swatch gengage-chat-product-variant-swatch--image",be(H,"src",S),H.alt="",H.setAttribute("aria-hidden","true"),Ie(H),q.appendChild(H)}else if(z){const H=document.createElement("span");H.className="gengage-chat-product-variant-swatch",H.setAttribute("aria-hidden","true"),H.style.backgroundColor=z,q.appendChild(H)}const M=document.createElement("span");M.className="gengage-chat-product-variant-label",M.textContent=y,q.appendChild(M);const R=Ic(B);if(R&&String(R)!==String(c)){const H=document.createElement("span");H.className="gengage-chat-product-variant-price",H.textContent=J(String(R),t.pricing),q.appendChild(H)}if(Z&&Z!==o){const H=r??"",ne=(typeof B.value=="string"?B.value.trim():"")||(typeof B.name=="string"?B.name.trim():"")||(typeof B.variant_name=="string"?B.variant_name.trim():"")||"",te=H.length>0?ne.length>0&&ne!==H?`${H} (${ne})`:H:y;q.addEventListener("click",()=>{t.onAction({title:te,type:"launchVariant",payload:{sku:Z}})})}D.appendChild(q)}D.childElementCount>0&&(f.appendChild(D),A.appendChild(f))}const N=document.createElement("div");N.className="gengage-chat-product-details-actions";const T=e.props?.action;if(T){const f=document.createElement("button");f.className="gengage-chat-product-details-cta gds-btn gds-btn-primary",f.type="button",f.textContent=T.title||t.i18n?.productCtaLabel||"View",f.addEventListener("click",()=>t.onAction(T)),N.appendChild(f)}if(s&&o&&b!==!1){const f=document.createElement("button");f.className="gengage-chat-product-details-atc gds-btn gds-btn-primary",f.type="button",f.textContent=t.i18n?.addToCartButton??"Add to Cart",f.addEventListener("click",()=>{t.onAction({title:t.i18n?.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:o,cartCode:s,quantity:1}})}),N.appendChild(f)}const I=we(n,"url");if(!T&&I&&ye(I)){const f=document.createElement("a");f.className="gengage-chat-product-details-cta gds-btn gds-btn-secondary",be(f,"href",I),be(f,"target","_blank"),be(f,"rel","noopener noreferrer"),f.textContent=t.i18n?.viewOnSiteLabel??t.i18n?.productCtaLabel??"View on Site",f.addEventListener("click",L=>{t.onProductClick&&o&&(L.preventDefault(),t.onProductClick({sku:o,url:I,...r?{name:r}:{}}))}),N.appendChild(f)}const $=I;if($&&ye($)){let j=function(q,y){const E=document.createElementNS(D,"circle");E.setAttribute("cx",q),E.setAttribute("cy",y),E.setAttribute("r","3"),B.appendChild(E)},Z=function(q,y,E,S){const z=document.createElementNS(D,"line");z.setAttribute("x1",q),z.setAttribute("y1",y),z.setAttribute("x2",E),z.setAttribute("y2",S),B.appendChild(z)};var ve=j,O=Z;const f=document.createElement("button");f.className="gengage-chat-product-details-share gds-btn gds-btn-ghost gds-icon-btn",f.type="button";const L=t.i18n?.shareButton??"Share";f.title=L,f.setAttribute("aria-label",L);const D="http://www.w3.org/2000/svg",B=document.createElementNS(D,"svg");B.setAttribute("width","18"),B.setAttribute("height","18"),B.setAttribute("viewBox","0 0 24 24"),B.setAttribute("fill","none"),B.setAttribute("stroke","currentColor"),B.setAttribute("stroke-width","2"),B.setAttribute("stroke-linecap","round"),B.setAttribute("stroke-linejoin","round"),j("18","5"),j("6","12"),j("18","19"),Z("8.59","13.51","15.42","17.49"),Z("15.41","6.51","8.59","10.49"),f.appendChild(B),f.addEventListener("click",async()=>{try{navigator.share?await navigator.share({title:r??"",url:$}):navigator.clipboard&&(await navigator.clipboard.writeText($),f.classList.add("gengage-chat-product-details-share--copied"),setTimeout(()=>f.classList.remove("gengage-chat-product-details-share--copied"),1500))}catch{}}),N.appendChild(f)}N.childElementCount>0&&A.appendChild(N),a.appendChild(A);const ae=Ec(n),oe=Pc(n);return(ae||oe)&&a.appendChild($c(ae,oe,t)),a}function aa(e){if(e.nodeType===Node.TEXT_NODE)return document.createTextNode(e.textContent??"");if(e.nodeType!==Node.ELEMENT_NODE)return null;const t=e,a=t.tagName.toUpperCase();if(xc.has(a))return null;if(!_c.has(a)){const r=document.createDocumentFragment();for(const i of Array.from(t.childNodes)){const o=aa(i);o&&r.appendChild(o)}return r}const n=document.createElement(a.toLowerCase());for(const r of Array.from(t.childNodes)){const i=aa(r);i&&n.appendChild(i)}return n}function Oc(e,t){const a=t.split(/\n{2,}/).map(n=>n.replace(/\s+/g," ").trim()).filter(Boolean);if(a.length!==0)for(const n of a){const r=document.createElement("p");r.textContent=n,e.appendChild(r)}}function Fc(e,t){if(e.classList.add("gengage-chat-product-description"),t.html&&typeof DOMParser<"u"){const a=new DOMParser().parseFromString(t.html,"text/html"),n=Array.from(a.body.childNodes).map(r=>aa(r)).filter(r=>!!r&&(r.nodeType===Node.ELEMENT_NODE||!!r.textContent?.trim()));if(n.length>0){for(const r of n)e.appendChild(r);return}}Oc(e,t.text)}function $c(e,t,a){const n=document.createElement("div");n.className="gengage-chat-product-detail-tabs";const r=document.createElement("div");r.className="gengage-chat-product-detail-tab-bar gds-toolbar";const i=[];if(e){const s=document.createElement("button");s.className="gengage-chat-product-detail-tab gds-tab gengage-chat-product-detail-tab--active is-active",s.type="button",s.setAttribute("aria-selected","true"),s.textContent=a.i18n?.productInfoTab??"Product Info",r.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-product-detail-tab-panel",Fc(c,e),i.push(c)}if(t){const s=document.createElement("button");s.className=`gengage-chat-product-detail-tab gds-tab${e?"":" gengage-chat-product-detail-tab--active is-active"}`,s.type="button",s.setAttribute("aria-selected",e?"false":"true"),s.textContent=a.i18n?.specificationsTab??"Specifications",r.appendChild(s);const c=document.createElement("div");c.className="gengage-chat-product-detail-tab-panel",e&&(c.style.display="none");const l=document.createElement("table");l.className="gengage-chat-product-specs-table";const g=Array.isArray(t)?t:Object.entries(t).map(([p,h])=>({key:p,value:h}));for(const p of g){const h=document.createElement("tr"),d=document.createElement("td");d.className="gengage-chat-product-specs-key",d.textContent=p.key;const b=document.createElement("td");b.className="gengage-chat-product-specs-value",b.textContent=p.value,h.appendChild(d),h.appendChild(b),l.appendChild(h)}c.appendChild(l),i.push(c)}const o=r.querySelectorAll(".gengage-chat-product-detail-tab");o.forEach((s,c)=>{s.addEventListener("click",()=>{o.forEach(l=>{l.classList.remove("gengage-chat-product-detail-tab--active","is-active"),l.setAttribute("aria-selected","false")}),s.classList.add("gengage-chat-product-detail-tab--active","is-active"),s.setAttribute("aria-selected","true"),i.forEach((l,g)=>{l.style.display=g===c?"":"none"})})}),n.appendChild(r);for(const s of i)n.appendChild(s);return n}function kn(e){const t='width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"';switch(e){case"related":return`<svg ${t} aria-hidden="true"><path d="M13 2 3 14h9l-1 8 10-12h-9l1-8z"/></svg>`;case"priceAsc":return`<svg ${t} aria-hidden="true"><polyline points="22 7 13.5 15.5 8.5 10.5 2 17"/><polyline points="16 7 22 7 22 13"/></svg>`;case"priceDesc":return`<svg ${t} aria-hidden="true"><polyline points="22 17 13.5 8.5 8.5 13.5 2 7"/><polyline points="16 17 22 17 22 11"/></svg>`;default:return""}}function Hc(){return'<svg class="gengage-chat-product-sort-chevron" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="6 9 12 15 18 9"/></svg>'}function Uc(){return'<svg class="gengage-chat-product-sort-check" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="20 6 9 17 4 12"/></svg>'}function jc(){return'<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 3 4 7l4 4"/><path d="M16 21l4-4-4-4"/><path d="M4 7h16"/><path d="M20 17H4"/></svg>'}function Cn(e,t){return e.type===t.type&&e.direction===t.direction}function Sn(e,t,a){if(!a||a.type==="related")return e;const n=e.map(r=>{const i=t.elements[r]?.props?.product,o=i?Number(i.price):NaN;return{id:r,price:Number.isFinite(o)?o:1/0}});return n.sort((r,i)=>r.price===1/0&&i.price===1/0?0:r.price===1/0?1:i.price===1/0?-1:a.direction==="desc"?i.price-r.price:r.price-i.price),n.map(r=>r.id)}function Zc(e,t,a,n){const r=Sn(t,a,n),i=new Map;for(const o of Array.from(e.children)){const s=o.dataset.elementId;s&&i.set(s,o)}for(const o of r){const s=i.get(o);s&&e.appendChild(s)}}function qc(e,t,a,n){const r=document.createElement("div");r.className="gengage-chat-product-grid-wrapper";const i=oa(e),o=i.isConsulting,s=e.children??[],c=document.createElement("div");c.className="gengage-chat-product-grid";const l=n?.panelProductListHeading;if(!o&&s.length>1&&n?.onSortChange){const h=document.createElement("div");h.className="gengage-chat-product-sort-toolbar",h.setAttribute("role","toolbar"),h.setAttribute("aria-label",n.i18n?.sortToolbarAriaLabel??"Sort products");let d=n.productSort??{type:"related"};const b=[{label:n.i18n?.sortRelated??"Related",sortState:{type:"related"},icon:"related"},{label:n.i18n?.sortPriceAsc??"Price ↑",sortState:{type:"price",direction:"asc"},icon:"priceAsc"},{label:n.i18n?.sortPriceDesc??"Price ↓",sortState:{type:"price",direction:"desc"},icon:"priceDesc"}],u=document.createElement("div");u.className="gengage-chat-product-sort-dropdown";const v=document.createElement("button");v.type="button",v.className="gengage-chat-product-sort-trigger gds-btn gds-btn-ghost",v.setAttribute("aria-haspopup","listbox"),v.setAttribute("aria-expanded","false");const m=n.i18n?.sortToolbarAriaLabel??"Sort products",P=document.createElement("span");P.className="gengage-chat-product-sort-trigger-icon";const A=document.createElement("span");A.className="gengage-chat-product-sort-trigger-label";const k=O=>{const f=b.find(L=>Cn(L.sortState,O))??b[0];A.textContent=f.label,P.innerHTML=kn(f.icon),u.dataset.sortIcon=f.icon,v.setAttribute("aria-label",`${m}: ${f.label}`),v.title=f.label};k(d);const x=document.createElement("span");x.className="gengage-chat-product-sort-trigger-chevron",x.innerHTML=Hc(),v.appendChild(P),v.appendChild(A),v.appendChild(x);const N=document.createElement("div");N.className="gengage-chat-product-sort-menu gds-menu",N.hidden=!0,N.setAttribute("role","listbox"),N.setAttribute("aria-label",m);const T=h.ownerDocument;let I=null;const $=()=>{N.hidden=!0,u.classList.remove("gengage-chat-product-sort-dropdown--open"),v.setAttribute("aria-expanded","false"),I?.abort(),I=null},ae=O=>{u.classList.contains("gengage-chat-product-sort-dropdown--open")&&(u.contains(O.target)||$())},oe=O=>{O.key==="Escape"&&(O.preventDefault(),$())},ve=()=>{N.hidden=!1,u.classList.add("gengage-chat-product-sort-dropdown--open"),v.setAttribute("aria-expanded","true"),I=new AbortController;const{signal:O}=I;T.addEventListener("click",ae,{signal:O}),T.addEventListener("keydown",oe,{capture:!0,signal:O})};v.addEventListener("click",O=>{O.stopPropagation(),u.classList.contains("gengage-chat-product-sort-dropdown--open")?$():ve()});for(const O of b){const f=document.createElement("button");f.type="button",f.className="gengage-chat-product-sort-option gds-menu-option",f.setAttribute("role","option");const L=Cn(d,O.sortState);f.setAttribute("aria-selected",L?"true":"false"),L&&f.classList.add("gengage-chat-product-sort-option--active","gds-menu-option-active");const D=O.sortState.type==="related"?"related":`price-${O.sortState.direction??""}`;f.dataset.sortKey=D;const B=document.createElement("span");B.className="gengage-chat-product-sort-option-icon",B.innerHTML=kn(O.icon);const j=document.createElement("span");j.className="gengage-chat-product-sort-option-label",j.textContent=O.label;const Z=document.createElement("span");Z.className="gengage-chat-product-sort-option-check",Z.innerHTML=Uc(),Z.setAttribute("aria-hidden","true"),L||Z.classList.add("gengage-chat-product-sort-option-check--hidden"),f.appendChild(B),f.appendChild(j),f.appendChild(Z),f.addEventListener("click",()=>{d=O.sortState,n.onSortChange?.(O.sortState),Zc(c,s,t,O.sortState),N.querySelectorAll(".gengage-chat-product-sort-option").forEach(q=>{const y=q,E=y.dataset.sortKey===D;y.classList.toggle("gengage-chat-product-sort-option--active",E),y.classList.toggle("gds-menu-option-active",E),y.setAttribute("aria-selected",E?"true":"false"),y.querySelector(".gengage-chat-product-sort-option-check")?.classList.toggle("gengage-chat-product-sort-option-check--hidden",!E)}),k(O.sortState),$()}),N.appendChild(f)}if(u.appendChild(v),u.appendChild(N),h.appendChild(u),n.onToggleComparisonSku){const O=document.createElement("button");O.className="gengage-chat-comparison-toggle-btn gds-btn gds-btn-ghost",O.type="button",n.comparisonSelectMode&&O.classList.add("gengage-chat-comparison-toggle-btn--active"),n.isStreaming&&O.classList.add("gengage-chat-comparison-toggle-btn--hidden");const f=document.createElement("span");f.className="gengage-chat-comparison-toggle-icon",f.innerHTML=jc();const L=document.createElement("span");L.className="gengage-chat-comparison-toggle-label";const D=n.i18n?.compareSelected??"Compare";L.textContent=D,O.setAttribute("aria-label",D),O.title=D,O.appendChild(f),O.appendChild(L),O.addEventListener("click",()=>{n.onToggleComparisonSku?.("")}),h.appendChild(O)}if(l){h.classList.add("gengage-chat-product-sort-toolbar--inline");const O=document.createElement("div");O.className="gengage-chat-product-grid-head";const f=document.createElement("span");f.className="gengage-chat-product-grid-head-title",f.textContent=l,O.appendChild(f);const L=document.createElement("div");L.className="gengage-chat-product-grid-head-actions",L.appendChild(h),O.appendChild(L),r.appendChild(O)}else r.appendChild(h)}else if(l){const h=document.createElement("div");h.className="gengage-chat-product-grid-head";const d=document.createElement("span");d.className="gengage-chat-product-grid-head-title",d.textContent=l,h.appendChild(d),r.appendChild(h)}if(o)Xc(r,c,i,n);else{const h=Sn(s,t,n?.productSort);for(const d of h){if(!t.elements[d])continue;const b=a(d);b&&(b.dataset.elementId=d,c.appendChild(b))}}(n?.isMobile??Qt())&&c.classList.add("gengage-chat-product-grid--mobile"),e.props?.rankingState==="pending"&&(c.classList.add("gengage-chat-product-grid--pending"),c.inert=!0,c.setAttribute("aria-busy","true")),r.appendChild(c);const g=e.props?.endOfList;if(!o&&g!==!0&&s.length>0){const h=n?.i18n?.viewMoreLabel??"Show More",d=document.createElement("button");d.className="gengage-chat-product-grid-view-more",d.type="button",d.textContent=h,d.addEventListener("click",()=>{n?.onAction({title:h,type:"moreProductList",payload:{}})}),r.appendChild(d)}const p=n?.isMobile??Qt();if(n?.comparisonSelectMode&&n.comparisonSelectedSkus&&!p){const h=dn(n.comparisonSelectedSkus,n);r.appendChild(h)}return r}function Vc(e,t){const a=e.props??{},n=a.keyDifferencesHtml,r=a.recommended,i=a.products??[],o=a.attributes??[],s=a.highlights??[],c=a.specialCases,l=a.recommendedText,g=a.winnerHits,p=a.productActions;if(!r)return document.createElement("div");const h={recommended:r,products:i,attributes:o,highlights:s,specialCases:c,locale:t.locale,onProductClick:({sku:b,name:u})=>{t.onProductClick?.({sku:b,url:"",name:u})},pricing:t.pricing};l!==void 0&&(h.recommendedText=l),g!==void 0&&(h.winnerHits=g),p!==void 0&&(h.productActions=p),n!==void 0&&(h.keyDifferencesHtml=n),t.i18n&&(h.i18n={comparisonHeading:t.i18n.panelTitleComparisonResults,recommendedChoiceLabel:t.i18n.recommendedChoiceLabel,highlightsLabel:t.i18n.highlightsLabel,keyDifferencesLabel:t.i18n.keyDifferencesLabel,viewMoreLabel:t.i18n.viewMoreLabel,specialCasesLabel:t.i18n.specialCasesLabel,addToCartButton:t.i18n.addToCartButton});const d=$s(h);return(t.isMobile??Qt())&&d.classList.add("gengage-chat-comparison--mobile"),d}function Gc(e){const t=document.createElement("hr");t.className="gengage-chat-divider";const a=e.props?.label;if(a){const n=document.createElement("div");n.className="gengage-chat-divider-wrapper";const r=document.createElement("span");r.className="gengage-chat-divider-label",r.textContent=a,n.appendChild(t),n.appendChild(r);const i=document.createElement("hr");return i.className="gengage-chat-divider",n.appendChild(i),n}return t}var Lt=new WeakMap;function En(e){return{...tt,...e?.i18n??{}}}function It(e){return typeof e.status=="string"?e.status:"ready"}function na(e){const t=e.findIndex(a=>It(a)!=="loading");return t<0?0:t}function Wc(e){if(typeof e!="string")return;const t=e.trim();if(!t)return;if(/^https?:\/\//i.test(t))return t;let a=t.split(/[?#]/)[0];if(a&&(a=a.replace(/^\/+/,""),a.startsWith("remoteConfig/")&&(a=a.slice(13)),!!a))return`https://configs.gengage.ai/assets/${a}`}function Pn(e,t,a,n){const{grid:r,i18n:i}=e;r.innerHTML="",r.classList.remove("gengage-chat-product-grid--consulting-groups");const o=document.createElement("section");o.className="gengage-chat-consulting-loading-panel";const s=document.createElement("h4");s.className="gengage-chat-consulting-loading-panel-title",s.textContent=Nt(t,n,i),o.appendChild(s);const c=document.createElement("p");if(c.className="gengage-chat-consulting-loading-panel-copy",c.textContent=a==="loading"?i.consultingStyleLoadingDescription:i.consultingStyleUnavailableDescription,o.appendChild(c),a==="loading"){const l=document.createElement("div");l.className="gengage-chat-consulting-loading-grid";for(let g=0;g<3;g+=1){const p=document.createElement("div");p.className="gengage-chat-consulting-loading-card",l.appendChild(p)}o.appendChild(l)}r.appendChild(o)}function Nt(e,t,a){const n=r=>a.consultingFallbackStyleLabel.replace("{index}",String(r));return e.style_label??n(t)}function ra(e,t){const a=e.variations[t];if(!a)return;const{grid:n,source:r,ctx:i,i18n:o}=e;n.innerHTML="",n.classList.remove("gengage-chat-product-grid--consulting-groups");const s=It(a),c=t+1;if(s==="loading"){Pn(e,a,"loading",c);return}if(s!=="ready"&&(!Array.isArray(a.product_list)||a.product_list.length===0)){Pn(e,a,"unavailable",c);return}const l=Array.isArray(a.product_list)?a.product_list:[],g=r==="watch_expert"?[]:Array.isArray(a.recommendation_groups)?a.recommendation_groups:[];if(g.length>0){n.classList.add("gengage-chat-product-grid--consulting-groups");const p=new Map;for(const m of l){const P=typeof m?.sku=="string"?m.sku:void 0;P&&p.set(P,m)}const h=(m,P,A,k)=>{if(P.length===0)return;const x=document.createElement("section");x.className="gengage-chat-consulting-group";const N=document.createElement("div");N.className="gengage-chat-consulting-group-header";const T=document.createElement("h4");if(T.className="gengage-chat-consulting-group-label",T.textContent=`${m} (${P.length})`,N.appendChild(T),typeof k=="string"&&k.trim().length>0){const $=document.createElement("p");$.className="gengage-chat-consulting-group-reason",$.textContent=k,N.appendChild($)}x.appendChild(N);const I=document.createElement("div");I.className="gengage-chat-product-grid gengage-chat-consulting-group-grid",A&&I.classList.add("gengage-chat-consulting-group-grid--single-group"),I.style.setProperty("--consulting-group-columns",String(Math.max(1,Math.min(4,P.length))));for(const $ of P){const ae=ta({type:"ProductCard",props:{product:$}},i??{onAction:()=>{}});I.appendChild(ae)}x.appendChild(I),n.appendChild(x)},d=new Set,b=[];for(const m of g){const P=(Array.isArray(m.skus)?m.skus.filter(x=>typeof x=="string"&&x.trim().length>0):[]).map(x=>(d.add(x),p.get(x))).filter(x=>!!x);if(P.length===0)continue;const A=typeof m.label=="string"&&m.label.trim().length>0?m.label:o.consultingFallbackGroupLabel,k=typeof m.reason=="string"?m.reason:void 0;b.push({labelText:A,products:P,...k!==void 0?{reasonText:k}:{}})}const u=l.filter(m=>{const P=typeof m?.sku=="string"?m.sku:"";return P.length>0&&!d.has(P)});u.length>0&&b.push({labelText:o.consultingOtherCompatibleProductsLabel,products:u});const v=b.length===1;for(const m of b)h(m.labelText,m.products,v,m.reasonText);return}for(const p of l){const h=ta({type:"ProductCard",props:{product:p}},i??{onAction:()=>{}});n.appendChild(h)}}function ia(e,t,a,n){const r=It(t),i=n.consultingStyleLoadingBadge,o=n.consultingStyleUnavailableBadge;e.classList.remove("gengage-chat-consulting-style-btn--loading","gengage-chat-consulting-style-btn--muted"),r==="loading"?e.classList.add("gengage-chat-consulting-style-btn--loading"):r!=="ready"&&e.classList.add("gengage-chat-consulting-style-btn--muted"),e.setAttribute("aria-label",Nt(t,a+1,n));let s=e.querySelector(".gengage-chat-consulting-style-media");s?s.innerHTML="":(s=document.createElement("div"),s.className="gengage-chat-consulting-style-media",e.appendChild(s));const c=Wc(t.image_url);if(c&&ye(c)){const g=document.createElement("img");g.className="gengage-chat-consulting-style-image",g.draggable=!1,be(g,"src",c),g.alt=Nt(t,a+1,n),g.loading="lazy",Ie(g),s.appendChild(g)}const l=document.createElement("span");if(l.className="gengage-chat-consulting-style-caption",l.textContent=Nt(t,a+1,n),s.appendChild(l),r==="loading"||r!=="ready"){const g=document.createElement("span");g.className="gengage-chat-consulting-style-status",g.textContent=r==="loading"?i:o,s.appendChild(g)}}function An(e,t,a,n){e.addEventListener("click",()=>{const r=Lt.get(t);r&&r.selectedIndex!==n&&(r.selectedIndex=n,a.querySelectorAll(".gengage-chat-consulting-style-btn").forEach((i,o)=>{i.classList.toggle("gengage-chat-consulting-style-btn--active",o===n)}),ra(r,n))})}function Kc(e,t,a,n,r){const i=En(r),o=na(n),s=document.createElement("div");s.className="gengage-chat-consulting-style-picker";const c={grid:t,source:a,ctx:r,variations:n,i18n:i,selectedIndex:o};Lt.set(s,c);const l=document.createElement("div");l.className="gengage-chat-consulting-style-picker-title",l.textContent=(a==="watch_expert"?i.watchStylesPreparedTitle:i.beautyStylesPreparedTitle).replace("{count}",String(n.length)),s.appendChild(l);const g=document.createElement("div");g.className="gengage-chat-consulting-style-grid",s.appendChild(g),n.forEach((p,h)=>{const d=document.createElement("button");d.type="button",d.className="gengage-chat-consulting-style-btn gds-card",h===o&&d.classList.add("gengage-chat-consulting-style-btn--active"),ia(d,p,h,i),An(d,s,g,h),g.appendChild(d)}),e.appendChild(s),ra(c,o)}function Yc(e,t,a,n){const r=e.querySelector(".gengage-chat-consulting-style-picker"),i=Jc(e);if(!r||!i)return!1;const o=r.querySelector(".gengage-chat-consulting-style-grid");if(!o)return!1;const s=En(n);let c=Lt.get(r);if(c)c.grid=i,c.source=t,c.ctx=n,c.variations=a,c.i18n=s;else{const d={grid:i,source:t,ctx:n,variations:a,i18n:s,selectedIndex:na(a)};Lt.set(r,d),c=d}const l=r.querySelector(".gengage-chat-consulting-style-picker-title");l&&(l.textContent=(t==="watch_expert"?s.watchStylesPreparedTitle:s.beautyStylesPreparedTitle).replace("{count}",String(a.length)));const g=c;let p=g.selectedIndex;p>=a.length&&(p=Math.max(0,a.length-1)),p<0&&(p=0),a.length>0&&It(a[p]??{})==="loading"&&(p=na(a)),g.selectedIndex=p;const h=[...o.querySelectorAll(".gengage-chat-consulting-style-btn")];if(h.length===0)return!1;for(let d=0;d<a.length;d+=1){const b=a[d];let u=h[d];u?ia(u,b,d,s):(u=document.createElement("button"),u.type="button",u.className="gengage-chat-consulting-style-btn gds-card",ia(u,b,d,s),An(u,r,o,d),o.appendChild(u),h[d]=u)}for(;o.querySelectorAll(".gengage-chat-consulting-style-btn").length>a.length;)o.lastElementChild?.remove();return o.querySelectorAll(".gengage-chat-consulting-style-btn").forEach((d,b)=>{d.classList.toggle("gengage-chat-consulting-style-btn--active",b===g.selectedIndex)}),ra(g,g.selectedIndex),!0}function Jc(e){const t=[...e.children];for(let a=t.length-1;a>=0;a-=1){const n=t[a];if(n.classList.contains("gengage-chat-product-grid"))return n}return e.querySelector(":scope > .gengage-chat-product-grid")}function oa(e){const t=typeof e.props?.source=="string"?e.props.source:void 0,a=(Array.isArray(e.props?.styleVariations)?e.props.styleVariations:[]).filter(n=>typeof n.style_label=="string"&&n.style_label.trim().length>0);return{isConsulting:Ha(t)&&a.length>0,source:t,styleVariations:a}}function Xc(e,t,a,n){Kc(e,t,a.source,a.styleVariations,n)}function Qc(e){return!e.isConsulting||e.styleVariations.length===0?!0:e.styleVariations.some(t=>(typeof t.status=="string"?t.status:"ready")!=="loading")}function el(e,t,a){return!t.isConsulting||!t.source?!1:Yc(e,t.source,t.styleVariations,a)}var tl=`<svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
50
50
|
<rect x="3" y="7" width="18" height="13" rx="3" fill="currentColor" opacity="0.15"/>
|
|
51
51
|
<rect x="3" y="7" width="18" height="13" rx="3" stroke="currentColor" stroke-width="1.5"/>
|
|
52
52
|
<circle cx="9" cy="13" r="1.5" fill="currentColor"/>
|
|
@@ -175,4 +175,4 @@ button[data-gengage-part="chat-launcher-button"] img {
|
|
|
175
175
|
|
|
176
176
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const o of e.seen.entries()){const s=o[1];if(t===o[0]){i(o);continue}if(e.external){const c=e.external.registry.get(o[0])?.id;if(t!==o[0]&&c){i(o);continue}}if(e.metadataRegistry.get(o[0])?.id){i(o);continue}if(s.cycle){i(o);continue}if(s.count>1&&e.reused==="ref"){i(o);continue}}}function xr(e,t){const a=e.seen.get(t);if(!a)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=o=>{const s=e.seen.get(o);if(s.ref===null)return;const c=s.def??s.schema,l={...c},g=s.ref;if(s.ref=null,g){n(g);const h=e.seen.get(g),d=h.schema;if(d.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(d)):Object.assign(c,d),Object.assign(c,l),o._zod.parent===g)for(const b in c)b==="$ref"||b==="allOf"||b in l||delete c[b];if(d.$ref&&h.def)for(const b in c)b==="$ref"||b==="allOf"||b in h.def&&JSON.stringify(c[b])===JSON.stringify(h.def[b])&&delete c[b]}const p=o._zod.parent;if(p&&p!==g){n(p);const h=e.seen.get(p);if(h?.schema.$ref&&(c.$ref=h.schema.$ref,h.def))for(const d in c)d==="$ref"||d==="allOf"||d in h.def&&JSON.stringify(c[d])===JSON.stringify(h.def[d])&&delete c[d]}e.override({zodSchema:o,jsonSchema:c,path:s.path??[]})};for(const o of[...e.seen.entries()].reverse())n(o[0]);const r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const o=e.external.registry.get(t)?.id;if(!o)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(o)}Object.assign(r,a.def??a.schema);const i=e.external?.defs??{};for(const o of e.seen.entries()){const s=o[1];s.def&&s.defId&&(i[s.defId]=s.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?r.$defs=i:r.definitions=i);try{const o=JSON.parse(JSON.stringify(r));return Object.defineProperty(o,"~standard",{value:{...t["~standard"],jsonSchema:{input:jt(t,"input",e.processors),output:jt(t,"output",e.processors)}},enumerable:!1,writable:!1}),o}catch{throw new Error("Error converting schema to JSON.")}}function xe(e,t){const a=t??{seen:new Set};if(a.seen.has(e))return!1;a.seen.add(e);const n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return xe(n.element,a);if(n.type==="set")return xe(n.valueType,a);if(n.type==="lazy")return xe(n.getter(),a);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return xe(n.innerType,a);if(n.type==="intersection")return xe(n.left,a)||xe(n.right,a);if(n.type==="record"||n.type==="map")return xe(n.keyType,a)||xe(n.valueType,a);if(n.type==="pipe")return xe(n.in,a)||xe(n.out,a);if(n.type==="object"){for(const r in n.shape)if(xe(n.shape[r],a))return!0;return!1}if(n.type==="union"){for(const r of n.options)if(xe(r,a))return!0;return!1}if(n.type==="tuple"){for(const r of n.items)if(xe(r,a))return!0;return!!(n.rest&&xe(n.rest,a))}return!1}var Rp=(e,t={})=>a=>{const n=yr({...a,processors:t});return ue(e,n),_r(n,e),xr(n,e)},jt=(e,t,a={})=>n=>{const{libraryOptions:r,target:i}=n??{},o=yr({...r??{},target:i,io:t,processors:a});return ue(e,o),_r(o,e),xr(o,e)},Dp={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Op=(e,t,a,n)=>{const r=a;r.type="string";const{minimum:i,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof i=="number"&&(r.minLength=i),typeof o=="number"&&(r.maxLength=o),s&&(r.format=Dp[s]??s,r.format===""&&delete r.format,s==="time"&&delete r.format),l&&(r.contentEncoding=l),c&&c.size>0){const g=[...c];g.length===1?r.pattern=g[0].source:g.length>1&&(r.allOf=[...g.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},Fp=(e,t,a,n)=>{const r=a,{minimum:i,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:g}=e._zod.bag;typeof s=="string"&&s.includes("int")?r.type="integer":r.type="number",typeof g=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.minimum=g,r.exclusiveMinimum=!0):r.exclusiveMinimum=g),typeof i=="number"&&(r.minimum=i,typeof g=="number"&&t.target!=="draft-04"&&(g>=i?delete r.minimum:delete r.exclusiveMinimum)),typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(r.maximum=l,r.exclusiveMaximum=!0):r.exclusiveMaximum=l),typeof o=="number"&&(r.maximum=o,typeof l=="number"&&t.target!=="draft-04"&&(l<=o?delete r.maximum:delete r.exclusiveMaximum)),typeof c=="number"&&(r.multipleOf=c)},$p=(e,t,a,n)=>{a.type="boolean"},Hp=(e,t,a,n)=>{a.not={}},Up=(e,t,a,n)=>{},jp=(e,t,a,n)=>{const r=e._zod.def,i=Dn(r.entries);i.every(o=>typeof o=="number")&&(a.type="number"),i.every(o=>typeof o=="string")&&(a.type="string"),a.enum=i},Zp=(e,t,a,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},qp=(e,t,a,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Vp=(e,t,a,n)=>{const r=a,i=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o=="number"&&(r.minItems=o),typeof s=="number"&&(r.maxItems=s),r.type="array",r.items=ue(i.element,t,{...n,path:[...n.path,"items"]})},Gp=(e,t,a,n)=>{const r=a,i=e._zod.def;r.type="object",r.properties={};const o=i.shape;for(const l in o)r.properties[l]=ue(o[l],t,{...n,path:[...n.path,"properties",l]});const s=new Set(Object.keys(o)),c=new Set([...s].filter(l=>{const g=i.shape[l]._zod;return t.io==="input"?g.optin===void 0:g.optout===void 0}));c.size>0&&(r.required=Array.from(c)),i.catchall?._zod.def.type==="never"?r.additionalProperties=!1:i.catchall?i.catchall&&(r.additionalProperties=ue(i.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},Wp=(e,t,a,n)=>{const r=e._zod.def,i=r.inclusive===!1,o=r.options.map((s,c)=>ue(s,t,{...n,path:[...n.path,i?"oneOf":"anyOf",c]}));i?a.oneOf=o:a.anyOf=o},Kp=(e,t,a,n)=>{const r=e._zod.def,i=ue(r.left,t,{...n,path:[...n.path,"allOf",0]}),o=ue(r.right,t,{...n,path:[...n.path,"allOf",1]}),s=c=>"allOf"in c&&Object.keys(c).length===1;a.allOf=[...s(i)?i.allOf:[i],...s(o)?o.allOf:[o]]},Yp=(e,t,a,n)=>{const r=a,i=e._zod.def;r.type="object";const o=i.keyType,s=o._zod.bag?.patterns;if(i.mode==="loose"&&s&&s.size>0){const l=ue(i.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});r.patternProperties={};for(const g of s)r.patternProperties[g.source]=l}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(r.propertyNames=ue(i.keyType,t,{...n,path:[...n.path,"propertyNames"]})),r.additionalProperties=ue(i.valueType,t,{...n,path:[...n.path,"additionalProperties"]});const c=o._zod.values;if(c){const l=[...c].filter(g=>typeof g=="string"||typeof g=="number");l.length>0&&(r.required=l)}},Jp=(e,t,a,n)=>{const r=e._zod.def,i=ue(r.innerType,t,n),o=t.seen.get(e);t.target==="openapi-3.0"?(o.ref=r.innerType,a.nullable=!0):a.anyOf=[i,{type:"null"}]},Xp=(e,t,a,n)=>{const r=e._zod.def;ue(r.innerType,t,n);const i=t.seen.get(e);i.ref=r.innerType},Qp=(e,t,a,n)=>{const r=e._zod.def;ue(r.innerType,t,n);const i=t.seen.get(e);i.ref=r.innerType,a.default=JSON.parse(JSON.stringify(r.defaultValue))},eh=(e,t,a,n)=>{const r=e._zod.def;ue(r.innerType,t,n);const i=t.seen.get(e);i.ref=r.innerType,t.io==="input"&&(a._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},th=(e,t,a,n)=>{const r=e._zod.def;ue(r.innerType,t,n);const i=t.seen.get(e);i.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}a.default=o},ah=(e,t,a,n)=>{const r=e._zod.def,i=t.io==="input"?r.in._zod.def.type==="transform"?r.out:r.in:r.out;ue(i,t,n);const o=t.seen.get(e);o.ref=i},nh=(e,t,a,n)=>{const r=e._zod.def;ue(r.innerType,t,n);const i=t.seen.get(e);i.ref=r.innerType,a.readOnly=!0},wr=(e,t,a,n)=>{const r=e._zod.def;ue(r.innerType,t,n);const i=t.seen.get(e);i.ref=r.innerType},rh=w("ZodISODateTime",(e,t)=>{sd.init(e,t),le.init(e,t)});function ih(e){return pp(rh,e)}var oh=w("ZodISODate",(e,t)=>{cd.init(e,t),le.init(e,t)});function sh(e){return hp(oh,e)}var ch=w("ZodISOTime",(e,t)=>{ld.init(e,t),le.init(e,t)});function lh(e){return up(ch,e)}var gh=w("ZodISODuration",(e,t)=>{gd.init(e,t),le.init(e,t)});function dh(e){return mp(gh,e)}var kr=(e,t)=>{jn.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:a=>eg(e,a)},flatten:{value:a=>Ql(e,a)},addIssue:{value:a=>{e.issues.push(a),e.message=JSON.stringify(e.issues,ha,2)}},addIssues:{value:a=>{e.issues.push(...a),e.message=JSON.stringify(e.issues,ha,2)}},isEmpty:{get(){return e.issues.length===0}}})},qu=w("ZodError",kr),Le=w("ZodError",kr,{Parent:Error}),ph=va(Le),hh=ya(Le),uh=Dt(Le),mh=Ot(Le),fh=ng(Le),bh=rg(Le),vh=ig(Le),yh=og(Le),_h=sg(Le),xh=cg(Le),wh=lg(Le),kh=gg(Le),pe=w("ZodType",(e,t)=>(de.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:jt(e,"input"),output:jt(e,"output")}}),e.toJSONSchema=Rp(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...a)=>e.clone(qe(t,{checks:[...t.checks??[],...a.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0}),e.with=e.check,e.clone=(a,n)=>Ve(e,a,n),e.brand=()=>e,e.register=((a,n)=>(a.add(e,n),e)),e.parse=(a,n)=>ph(e,a,n,{callee:e.parse}),e.safeParse=(a,n)=>uh(e,a,n),e.parseAsync=async(a,n)=>hh(e,a,n,{callee:e.parseAsync}),e.safeParseAsync=async(a,n)=>mh(e,a,n),e.spa=e.safeParseAsync,e.encode=(a,n)=>fh(e,a,n),e.decode=(a,n)=>bh(e,a,n),e.encodeAsync=async(a,n)=>vh(e,a,n),e.decodeAsync=async(a,n)=>yh(e,a,n),e.safeEncode=(a,n)=>_h(e,a,n),e.safeDecode=(a,n)=>xh(e,a,n),e.safeEncodeAsync=async(a,n)=>wh(e,a,n),e.safeDecodeAsync=async(a,n)=>kh(e,a,n),e.refine=(a,n)=>e.check(mu(a,n)),e.superRefine=a=>e.check(fu(a)),e.overwrite=a=>e.check(ct(a)),e.optional=()=>Tr(e),e.exactOptional=()=>au(e),e.nullable=()=>Lr(e),e.nullish=()=>Tr(Lr(e)),e.nonoptional=a=>cu(e,a),e.array=()=>Q(e),e.or=a=>lt([e,a]),e.and=a=>Jh(e,a),e.transform=a=>Nr(e,eu(a)),e.default=a=>iu(e,a),e.prefault=a=>su(e,a),e.catch=a=>gu(e,a),e.pipe=a=>Nr(e,a),e.readonly=()=>hu(e),e.describe=a=>{const n=e.clone();return yt.add(n,{description:a}),n},Object.defineProperty(e,"description",{get(){return yt.get(e)?.description},configurable:!0}),e.meta=(...a)=>{if(a.length===0)return yt.get(e);const n=e.clone();return yt.add(n,a[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=a=>a(e),e)),Cr=w("_ZodString",(e,t)=>{_a.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Op(e,n,r,i);const a=e._zod.bag;e.format=a.format??null,e.minLength=a.minimum??null,e.maxLength=a.maximum??null,e.regex=(...n)=>e.check(xp(...n)),e.includes=(...n)=>e.check(Cp(...n)),e.startsWith=(...n)=>e.check(Sp(...n)),e.endsWith=(...n)=>e.check(Ep(...n)),e.min=(...n)=>e.check(Ut(...n)),e.max=(...n)=>e.check(br(...n)),e.length=(...n)=>e.check(vr(...n)),e.nonempty=(...n)=>e.check(Ut(1,...n)),e.lowercase=n=>e.check(wp(n)),e.uppercase=n=>e.check(kp(n)),e.trim=()=>e.check(Ap()),e.normalize=(...n)=>e.check(Pp(...n)),e.toLowerCase=()=>e.check(Tp()),e.toUpperCase=()=>e.check(Lp()),e.slugify=()=>e.check(Ip())}),Ch=w("ZodString",(e,t)=>{_a.init(e,t),Cr.init(e,t),e.email=a=>e.check(qd(Sh,a)),e.url=a=>e.check(Yd(Eh,a)),e.jwt=a=>e.check(dp(Hh,a)),e.emoji=a=>e.check(Jd(Ph,a)),e.guid=a=>e.check(hr(Sr,a)),e.uuid=a=>e.check(Vd(Zt,a)),e.uuidv4=a=>e.check(Gd(Zt,a)),e.uuidv6=a=>e.check(Wd(Zt,a)),e.uuidv7=a=>e.check(Kd(Zt,a)),e.nanoid=a=>e.check(Xd(Ah,a)),e.guid=a=>e.check(hr(Sr,a)),e.cuid=a=>e.check(Qd(Th,a)),e.cuid2=a=>e.check(ep(Lh,a)),e.ulid=a=>e.check(tp(Ih,a)),e.base64=a=>e.check(cp(Oh,a)),e.base64url=a=>e.check(lp(Fh,a)),e.xid=a=>e.check(ap(Nh,a)),e.ksuid=a=>e.check(np(zh,a)),e.ipv4=a=>e.check(rp(Mh,a)),e.ipv6=a=>e.check(ip(Bh,a)),e.cidrv4=a=>e.check(op(Rh,a)),e.cidrv6=a=>e.check(sp(Dh,a)),e.e164=a=>e.check(gp($h,a)),e.datetime=a=>e.check(ih(a)),e.date=a=>e.check(sh(a)),e.time=a=>e.check(lh(a)),e.duration=a=>e.check(dh(a))});function _(e){return Zd(Ch,e)}var le=w("ZodStringFormat",(e,t)=>{se.init(e,t),Cr.init(e,t)}),Sh=w("ZodEmail",(e,t)=>{Xg.init(e,t),le.init(e,t)}),Sr=w("ZodGUID",(e,t)=>{Yg.init(e,t),le.init(e,t)}),Zt=w("ZodUUID",(e,t)=>{Jg.init(e,t),le.init(e,t)}),Eh=w("ZodURL",(e,t)=>{Qg.init(e,t),le.init(e,t)}),Ph=w("ZodEmoji",(e,t)=>{ed.init(e,t),le.init(e,t)}),Ah=w("ZodNanoID",(e,t)=>{td.init(e,t),le.init(e,t)}),Th=w("ZodCUID",(e,t)=>{ad.init(e,t),le.init(e,t)}),Lh=w("ZodCUID2",(e,t)=>{nd.init(e,t),le.init(e,t)}),Ih=w("ZodULID",(e,t)=>{rd.init(e,t),le.init(e,t)}),Nh=w("ZodXID",(e,t)=>{id.init(e,t),le.init(e,t)}),zh=w("ZodKSUID",(e,t)=>{od.init(e,t),le.init(e,t)}),Mh=w("ZodIPv4",(e,t)=>{dd.init(e,t),le.init(e,t)}),Bh=w("ZodIPv6",(e,t)=>{pd.init(e,t),le.init(e,t)}),Rh=w("ZodCIDRv4",(e,t)=>{hd.init(e,t),le.init(e,t)}),Dh=w("ZodCIDRv6",(e,t)=>{ud.init(e,t),le.init(e,t)}),Oh=w("ZodBase64",(e,t)=>{md.init(e,t),le.init(e,t)}),Fh=w("ZodBase64URL",(e,t)=>{bd.init(e,t),le.init(e,t)}),$h=w("ZodE164",(e,t)=>{vd.init(e,t),le.init(e,t)}),Hh=w("ZodJWT",(e,t)=>{_d.init(e,t),le.init(e,t)}),Er=w("ZodNumber",(e,t)=>{er.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Fp(e,n,r,i),e.gt=(n,r)=>e.check(mr(n,r)),e.gte=(n,r)=>e.check(ka(n,r)),e.min=(n,r)=>e.check(ka(n,r)),e.lt=(n,r)=>e.check(ur(n,r)),e.lte=(n,r)=>e.check(wa(n,r)),e.max=(n,r)=>e.check(wa(n,r)),e.int=n=>e.check(Pr(n)),e.safe=n=>e.check(Pr(n)),e.positive=n=>e.check(mr(0,n)),e.nonnegative=n=>e.check(ka(0,n)),e.negative=n=>e.check(ur(0,n)),e.nonpositive=n=>e.check(wa(0,n)),e.multipleOf=(n,r)=>e.check(fr(n,r)),e.step=(n,r)=>e.check(fr(n,r)),e.finite=()=>e;const a=e._zod.bag;e.minValue=Math.max(a.minimum??Number.NEGATIVE_INFINITY,a.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(a.maximum??Number.POSITIVE_INFINITY,a.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(a.format??"").includes("int")||Number.isSafeInteger(a.multipleOf??.5),e.isFinite=!0,e.format=a.format??null});function Me(e){return fp(Er,e)}var Uh=w("ZodNumberFormat",(e,t)=>{xd.init(e,t),Er.init(e,t)});function Pr(e){return bp(Uh,e)}var jh=w("ZodBoolean",(e,t)=>{wd.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(a,n,r)=>$p(e,a,n,r)});function Ye(e){return vp(jh,e)}var Zh=w("ZodUnknown",(e,t)=>{kd.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(a,n,r)=>Up(e,a,n,r)});function Se(){return yp(Zh)}var qh=w("ZodNever",(e,t)=>{Cd.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(a,n,r)=>Hp(e,a,n,r)});function Vh(e){return _p(qh,e)}var Gh=w("ZodArray",(e,t)=>{Sd.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(a,n,r)=>Vp(e,a,n,r),e.element=t.element,e.min=(a,n)=>e.check(Ut(a,n)),e.nonempty=a=>e.check(Ut(1,a)),e.max=(a,n)=>e.check(br(a,n)),e.length=(a,n)=>e.check(vr(a,n)),e.unwrap=()=>e.element});function Q(e,t){return Np(Gh,e,t)}var Wh=w("ZodObject",(e,t)=>{Pd.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(a,n,r)=>Gp(e,a,n,r),re(e,"shape",()=>t.shape),e.keyof=()=>gt(Object.keys(e._zod.def.shape)),e.catchall=a=>e.clone({...e._zod.def,catchall:a}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Se()}),e.loose=()=>e.clone({...e._zod.def,catchall:Se()}),e.strict=()=>e.clone({...e._zod.def,catchall:Vh()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=a=>Wl(e,a),e.safeExtend=a=>Kl(e,a),e.merge=a=>Yl(e,a),e.pick=a=>Vl(e,a),e.omit=a=>Gl(e,a),e.partial=(...a)=>Jl(Ar,e,a[0]),e.required=(...a)=>Xl(Ir,e,a[0])});function G(e,t){return new Wh({type:"object",shape:e??{},...F(t)})}var Kh=w("ZodUnion",(e,t)=>{Ad.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(a,n,r)=>Wp(e,a,n,r),e.options=t.options});function lt(e,t){return new Kh({type:"union",options:e,...F(t)})}var Yh=w("ZodIntersection",(e,t)=>{Td.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(a,n,r)=>Kp(e,a,n,r)});function Jh(e,t){return new Yh({type:"intersection",left:e,right:t})}var Xh=w("ZodRecord",(e,t)=>{Ld.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(a,n,r)=>Yp(e,a,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Je(e,t,a){return new Xh({type:"record",keyType:e,valueType:t,...F(a)})}var Ca=w("ZodEnum",(e,t)=>{Id.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(n,r,i)=>jp(e,n,r,i),e.enum=t.entries,e.options=Object.values(t.entries);const a=new Set(Object.keys(t.entries));e.extract=(n,r)=>{const i={};for(const o of n)if(a.has(o))i[o]=t.entries[o];else throw new Error(`Key ${o} not found in enum`);return new Ca({...t,checks:[],...F(r),entries:i})},e.exclude=(n,r)=>{const i={...t.entries};for(const o of n)if(a.has(o))delete i[o];else throw new Error(`Key ${o} not found in enum`);return new Ca({...t,checks:[],...F(r),entries:i})}});function gt(e,t){return new Ca({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(a=>[a,a])):e,...F(t)})}var Qh=w("ZodTransform",(e,t)=>{Nd.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(a,n,r)=>qp(e,a,n,r),e._zod.parse=(a,n)=>{if(n.direction==="backward")throw new Rn(e.constructor.name);a.addIssue=i=>{if(typeof i=="string")a.issues.push(vt(i,a.value,t));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=a.value),o.inst??(o.inst=e),a.issues.push(vt(o))}};const r=t.transform(a.value,a);return r instanceof Promise?r.then(i=>(a.value=i,a)):(a.value=r,a)}});function eu(e){return new Qh({type:"transform",transform:e})}var Ar=w("ZodOptional",(e,t)=>{sr.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(a,n,r)=>wr(e,a,n,r),e.unwrap=()=>e._zod.def.innerType});function Tr(e){return new Ar({type:"optional",innerType:e})}var tu=w("ZodExactOptional",(e,t)=>{zd.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(a,n,r)=>wr(e,a,n,r),e.unwrap=()=>e._zod.def.innerType});function au(e){return new tu({type:"optional",innerType:e})}var nu=w("ZodNullable",(e,t)=>{Md.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(a,n,r)=>Jp(e,a,n,r),e.unwrap=()=>e._zod.def.innerType});function Lr(e){return new nu({type:"nullable",innerType:e})}var ru=w("ZodDefault",(e,t)=>{Bd.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(a,n,r)=>Qp(e,a,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function iu(e,t){return new ru({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Hn(t)}})}var ou=w("ZodPrefault",(e,t)=>{Rd.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(a,n,r)=>eh(e,a,n,r),e.unwrap=()=>e._zod.def.innerType});function su(e,t){return new ou({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Hn(t)}})}var Ir=w("ZodNonOptional",(e,t)=>{Dd.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(a,n,r)=>Xp(e,a,n,r),e.unwrap=()=>e._zod.def.innerType});function cu(e,t){return new Ir({type:"nonoptional",innerType:e,...F(t)})}var lu=w("ZodCatch",(e,t)=>{Od.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(a,n,r)=>th(e,a,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function gu(e,t){return new lu({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var du=w("ZodPipe",(e,t)=>{Fd.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(a,n,r)=>ah(e,a,n,r),e.in=t.in,e.out=t.out});function Nr(e,t){return new du({type:"pipe",in:e,out:t})}var pu=w("ZodReadonly",(e,t)=>{$d.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(a,n,r)=>nh(e,a,n,r),e.unwrap=()=>e._zod.def.innerType});function hu(e){return new pu({type:"readonly",innerType:e})}var uu=w("ZodCustom",(e,t)=>{Hd.init(e,t),pe.init(e,t),e._zod.processJSONSchema=(a,n,r)=>Zp(e,a,n,r)});function mu(e,t={}){return zp(uu,e,t)}function fu(e){return Mp(e)}var bu=G({role:gt(["user","assistant"]),content:_(),timestamp:Me().optional()}),vu=G({sku:_(),name:_(),imageUrl:_().url().optional(),price:_().optional(),originalPrice:_().optional(),url:_().url(),ctaLabel:_().optional()}),yu=G({buttons:Q(G({label:_(),action:G({title:_(),type:_(),payload:Se().optional()})}))}),_u=G({}),xu=G({label:_().optional()}),zr=G({sku:_(),name:_(),price:_(),imageUrl:_().optional(),rating:Me().optional(),reviewCount:Me().optional()}),wu=G({recommended:zr,products:Q(zr),attributes:Q(G({label:_(),values:Q(_())})),highlights:Q(_()),specialCases:Q(_()).optional(),recommendedText:_().optional(),winnerHits:Je(_(),G({positive:Q(_()).optional(),negative:Q(_()).optional()})).optional(),productActions:Je(_(),G({title:_(),type:_(),payload:Se().optional()})).optional()}),ku=G({label:_(),sentiment:gt(["positive","negative","neutral"]).optional()}),Cu=G({product:Je(_(),Se()),role:_().optional(),reason:_().optional(),labels:Q(ku).optional(),expertQualityScore:Me().optional(),reviewHighlight:_().optional(),action:G({title:_(),type:_(),payload:Se().optional()}).optional()}),Su=G({suggestions:Q(Cu)}),Eu=G({title:_().optional(),text:_().optional(),reviewCount:_().optional(),action:G({title:_(),type:_(),payload:Se().optional()})}),Pu=G({entries:Q(G({name:_(),image:_().optional(),description:_().optional(),action:G({title:_(),type:_(),payload:Se().optional()})}))}),Au=G({entries:Q(G({shortName:_(),detailedMessage:_().optional(),whyDifferent:_().optional(),image:_().optional(),action:G({title:_(),type:_(),payload:Se().optional()})}))}),Mr=G({title:_(),type:_(),payload:Se().optional()}),_t=G({name:_().optional(),value:_().optional(),option_value:_().optional(),attribute_value:_().optional(),type:_().optional(),attribute:_().optional(),option_name:_().optional(),attribute_name:_().optional(),variant_name:_().optional(),sku:_().optional(),price:lt([Me(),_()]).optional(),price_discounted:lt([Me(),_()]).optional(),image:_().optional(),imageUrl:_().optional(),image_url:_().optional(),color:_().optional(),colour:_().optional(),color_hex:_().optional(),hex:_().optional(),swatch:_().optional(),swatchColor:_().optional(),in_stock:Ye().optional(),inStock:Ye().optional()}),Tu=G({product:G({sku:_().optional(),name:_().optional(),images:Q(_()).optional(),imageUrl:_().optional(),rating:Me().optional(),reviewCount:Me().optional(),price:_().optional(),originalPrice:_().optional(),discountReason:_().optional(),discount_reason:_().optional(),campaignReason:_().optional(),campaign_reason:_().optional(),originalPriceStyle:gt(["strikethrough","inline"]).optional(),price_original_style:gt(["strikethrough","inline"]).optional(),price_discount_rate:Me().optional(),price_async:Ye().optional(),inStock:Ye().optional(),promotions:Q(_()).optional(),variants:Q(_t).optional(),variantOptions:Q(_t).optional(),variant_options:Q(_t).optional(),productVariants:Q(_t).optional(),product_variants:Q(_t).optional(),url:_().optional(),cartCode:_().optional(),description:_().optional(),description_html:_().optional(),descriptionHtml:_().optional(),facet_hits:Je(_(),Se()).optional(),facetHits:Je(_(),Se()).optional(),features:Q(G({name:_().optional(),key:_().optional(),label:_().optional(),value:lt([_(),Me(),Ye()]).optional()})).optional(),specifications:lt([Je(_(),_()),Q(G({key:_(),value:_()}))]).optional()}).optional(),action:Mr.optional()}),Lu=G({endOfList:Ye().optional(),rankingState:gt(["pending","final"]).optional(),sequenceId:_().optional()}),Iu=G({review_class:_().optional(),review_text:_().optional(),review_rating:lt([_(),Me()]).optional(),review_tag:_().optional()}),Nu=G({reviews:Q(Iu).optional()}),zu=G({productName:_().optional(),pros:Q(_()).optional(),cons:Q(_()).optional()}),Mu=G({groups:Q(G({groupName:_(),image:_().optional(),products:Q(Je(_(),Se())).optional()})).optional(),filterTags:Q(G({title:_(),action:Mr.optional()})).optional()}),Bu=G({summary:_().optional(),products_discussed:Q(_()).optional(),user_sentiment:_().optional()}),Ru=G({summary:_(),strengths:Q(_()).optional(),focus_points:Q(_()).optional(),celeb_style:_().optional(),celeb_style_reason:_().optional(),next_question:_().optional(),style_images:Q(_()).optional()}),Du=G({processing:Ye().optional(),title:_().optional(),description:_().optional(),upload_label:_().optional(),skip_label:_().optional()}),Ou={components:{MessageBubble:{schema:bu,description:"A single chat message bubble for user or assistant turns."},ProductCard:{schema:vu,description:"A product card rendered inline in the chat stream."},ActionButtons:{schema:yu,description:"A horizontal row of quick-reply action buttons."},TypingIndicator:{schema:_u,description:"An animated indicator shown while the assistant is typing."},Divider:{schema:xu,description:"A horizontal rule with an optional label."},ComparisonTable:{schema:wu,description:"A product comparison table with recommended pick, attribute rows, and highlights."},AITopPicks:{schema:Su,description:"Rich AI-curated product suggestion cards with roles, sentiment labels, scores, and review quotes."},GroundingReviewCard:{schema:Eu,description:"A card showing review grounding data with review count and CTA."},AIGroupingCards:{schema:Pu,description:"Category grouping cards with images and labels for product discovery."},AISuggestedSearchCards:{schema:Au,description:"Suggested search cards with images, descriptions, and differentiation."},ProductDetailsPanel:{schema:Tu,description:"Full product detail view with images, specs, variants, and purchase actions."},ProductGrid:{schema:Lu,description:'A scrollable grid of ProductCard children with optional "more" pagination.'},ReviewHighlights:{schema:Nu,description:"A list of highlighted customer reviews with sentiment and ratings."},ProsAndCons:{schema:zu,description:"A pros and cons list for a product."},CategoriesContainer:{schema:Mu,description:"Tabbed product groups with optional filter tag buttons."},HandoffNotice:{schema:Bu,description:"A notice shown when the conversation is escalated to a human agent."},PhotoAnalysisCard:{schema:Ru,description:"Structured photo analysis card with strengths, focus points, celeb vibe, and follow-up question."},BeautyPhotoStep:{schema:Du,description:"Transient selfie upload prompt for beauty consulting init flow."}}},Fu=new Set(["launchSingleProduct","launchProductList","launchHomepage"]);function Br(e){return e.length>120?!1:/^[a-zA-Z0-9#(),.\s%/\-]+$/.test(e)}function Sa(e){return typeof e=="object"&&e!==null&&typeof e.type=="string"}function Ea(e){return e?.type==="ProductGrid"&&e.props?.similarsAppend===!0}var Rr=class dt extends Fi{constructor(...t){super(...t),this._shadow=null,this._rootEl=null,this._backdropEl=null,this._launcher=null,this._drawer=null,this._bridge=null,this._drawerVisible=!1,this._pillLauncherApply=null,this._hostScrollLockActive=!1,this._hostOverflowRestore=null,this._hostScrollLockViewport=null,this._hostScrollPinning=!1,this._preventHostDocumentTouchMove=a=>{this._hostScrollLockActive&&(this._hostScrollEventShouldReachChatScroller(a)||a.preventDefault())},this._preventHostDocumentWheel=a=>{this._hostScrollLockActive&&(this._hostScrollEventShouldReachChatScroller(a)||a.preventDefault())},this._pinHostViewportScroll=()=>{if(!this._hostScrollLockActive||!this._hostScrollLockViewport||this._hostScrollPinning)return;const a=this._hostScrollLockViewport;window.scrollX===a.x&&window.scrollY===a.y||(this._hostScrollPinning=!0,window.scrollTo(a.x,a.y),this._hostScrollPinning=!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._comparisonSelectionWarning=null,this._comparisonRefreshRafId=null,this._viewedProductSkus=new Set,this._thumbnailEntries=[],this._choicePrompterEl=null,this._openState="full",this._mobileBreakpoint=768,this._isMobileViewport=!1,this._gaPrevMainPaneExpanded=!1,this._pdpLaunched=!1,this._plpLaunched=!1,this._homepageLaunched=!1,this._entryContextPrimed=!1,this._contextPrimingInFlight=!1,this._queuedUserMessages=[],this._productContextUnavailableSku=null,this._i18n=tt,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 zn,this._eventCallbacks=new Map,this._lastSentAction=null,this._consecutiveErrorCount=0,this._lastErrorMessage="",this._modeController=new As}static{this._MAX_COMPARISON_SELECTION=5}static{this._MAX_PANEL_HISTORY=10}get _assistantMode(){return this._modeController.mode}set _assistantMode(t){this._modeController.mode=t}get _uiHints(){return this._modeController.uiHints}set _uiHints(t){this._modeController.uiHints=t}async onInit(t){if(this._i18n=this._resolveI18n(t),this._chatCreatedAt=new Date().toISOString(),t.pillLauncher){const u=Pl(t.pillLauncher);t.launcherImageUrl=u.launcherImageUrl,t.headerAvatarUrl===void 0&&(t.headerAvatarUrl=t.pillLauncher.avatarUrl),this._pillLauncherApply=()=>u.apply(this._shadow??void 0)}this._shadow=this.root.attachShadow({mode:"open"});const a=document.createElement("style");a.textContent=Fl,this._shadow.appendChild(a);const n=this.root,r=(u,v)=>{v&&Br(v)&&n.style.setProperty(u,v)};if(r("--gengage-chat-header-bg",t.headerBg),r("--gengage-chat-header-foreground",t.headerForeground),t.theme)for(const[u,v]of Object.entries(t.theme))u.startsWith("--")&&typeof v=="string"&&r(u,v);this._applyDiscountedPriceColorVar(t.productPriceUi?.discountedPriceColor);const i=document.createElement("div");i.className="gengage-chat-root",i.lang=wt(t.locale),this._rootEl=i,this._shadow.appendChild(i);const o=t.variant??"floating";if(o==="inline"&&i.classList.add("gengage-chat--inline"),o!=="inline"){const u=document.createElement("div");u.className="gengage-chat-backdrop",u.setAttribute("aria-hidden","true"),u.setAttribute("role","button"),u.setAttribute("tabindex","-1"),u.setAttribute("aria-label",this._i18n.closeAriaLabel),u.addEventListener("click",v=>{v.preventDefault(),v.stopPropagation(),this.close()}),this._backdropEl=u,i.prepend(u)}if(o==="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=al(u),i.appendChild(this._launcher.container)}o==="overlay"&&i.classList.add("gengage-chat--overlay");const s=document.createElement("div");i.appendChild(s),this._drawer=new ks(s,{i18n:this._i18n,onSend:(u,v)=>this._sendMessage(u,v),onClose:()=>this.close(),onAttachment:u=>this._handleAttachment(u),onPanelToggle:()=>{this._drawer?.persistPanelState(t.accountId)},onHostShellSync:()=>{this._applyOpenStateClasses()},onRollback:u=>this._handleRollback(u),onPanelBack:()=>this._navigatePanelBack(),onPanelForward:()=>this._panel?.navigateForward(),onPanelClose:()=>{if(this._isMobileViewport){this._comparisonSelectMode=!1,this._comparisonSelectedSkus=[];return}this._localPanelHistory=[],this._comparisonSelectMode=!1,this._comparisonSelectedSkus=[],this._currentPanelSource=null},headerTitle:t.headerTitle,headerAvatarUrl:t.headerAvatarUrl,launcherImageUrl:t.launcherImageUrl,headerBadge:t.headerBadge,headerCartUrl:t.headerCartUrl,showHeaderFavorites:typeof t.onFavoritesClick=="function"||t.headerFavoritesToggle===!0,onCartClick:()=>{t.headerCartUrl?this._saveSessionAndOpenURL(t.headerCartUrl):t.onCartClick?.()},onFavoritesClick:()=>{if(ui(),typeof t.onFavoritesClick=="function"){t.onFavoritesClick();return}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,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._applyUiHints(),this._extendedModeManager=new kl({onChange:u=>this._panel?.notifyExtension(u),productDetailsInPanel:(t.isDemoWebsite??!1)&&(t.productDetailsExtended??!1)}),this._panel=new Cl({drawer:()=>this._drawer,shadow:()=>this._shadow,currentThreadId:()=>this._currentThreadId,bridge:()=>this._bridge,extendedModeManager:()=>this._extendedModeManager,i18n:()=>this._i18n,rollbackToThread:u=>this._rollbackToThread(u)}),o!=="inline"&&this._drawer.getElement().classList.add("gengage-chat-drawer--hidden");const c=this._drawer.restorePanelState(t.accountId),l=t.panelMode??"auto";l==="collapsed"?this._drawer.setPanelCollapsed(!0):l==="expanded"&&this._drawer.setForceExpanded();const g=sessionStorage.getItem("gengage_restore_session_id"),p=sessionStorage.getItem("gengage_restore_sku"),h=!!(g&&p);h&&(sessionStorage.removeItem("gengage_restore_session_id"),sessionStorage.removeItem("gengage_restore_sku"));try{const u=new xl;await u.open(),this._session=new Nn(u),await this._restoreFromIndexedDB(h)}catch{this._session=new Nn(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 v=this._drawer?.getElement();if(!v)return;const m=window.innerHeight-(window.visualViewport?.height??window.innerHeight);v.style.setProperty("--gengage-keyboard-offset",`${Math.max(0,m)}px`)};window.visualViewport.addEventListener("resize",u),this.addCleanup(()=>window.visualViewport?.removeEventListener("resize",u))}o==="inline"&&(this._drawerVisible=!0,this.isVisible=!0,this._applyOpenStateClasses(),this._presentation.setShown(!0),setTimeout(()=>this._maybeAutoAnchorUnreadAssistant(),60));const b={namespace:"chat",onMessage:u=>this._handleBridgeMessage(u)};t.allowedOrigins!==void 0&&(b.allowedOrigins=t.allowedOrigins),this._bridge=new Hi(b),this._lastSku=this.config.pageContext?.sku,this._lastPageType=this.config.pageContext?.pageType,this._lastSkuListKey=this.config.pageContext?.skuList?.slice(0,48).join(","),this._initComplete=!0;for(const u of this._pendingActions)this._sendAction(u.action,u.options);this._pendingActions=[],this._pillLauncherApply&&o==="floating"&&(await this._pillLauncherApply(),this._pillLauncherApply=null),Te("gengage:chat:ready",{}),ii("chat"),t.onReady?.()}onUpdate(t){if(this.config.pageContext&&t.pageType!==void 0){const{sku:n,skuList:r,...i}=this.config.pageContext,o={...i};o.pageType==="pdp"&&n!==void 0&&(o.sku=n),o.pageType==="plp"&&r!==void 0&&(o.skuList=r),this.config={...this.config,pageContext:o}}let a=!1;if(t.sku!==void 0&&t.sku!==this._lastSku&&(this._lastSku=t.sku,a=!0),t.pageType!==void 0&&t.pageType!==this._lastPageType&&(this._lastPageType=t.pageType,a=!0),t.skuList!==void 0){const n=t.skuList.slice(0,48).join(",");n!==this._lastSkuListKey&&(this._lastSkuListKey=n,a=!0)}a&&this._resetForNewPage()}onShow(){this._showDrawer(),this.emit("open"),Te("gengage:chat:open",{state:this._openState}),oi("chat"),this.config.onOpen?.(),this._showWelcomeIfNeeded(),this._maybePrimeEntryContextOpening(),!this._pdpLaunched&&this.config.pageContext?.pageType==="pdp"&&this.config.pageContext?.sku&&(this._pdpLaunched=!0,this._contextPrimingInFlight=!0,this._sendAction({title:"",type:"launchSingleProduct",payload:{sku:this.config.pageContext.sku,...this._resolveContextualOpeningMessage("product")?{opening_message:this._resolveContextualOpeningMessage("product")}:{},...this._resolveContextualOpeningGuidance("product")?{opening_guidance:this._resolveContextualOpeningGuidance("product")}:{}}},{silent:!0,isContextPrime:!0,preservePills:!0})),!this._plpLaunched&&this.config.pageContext?.pageType==="plp"&&this.config.pageContext.skuList?.length&&(this._plpLaunched=!0,this._contextPrimingInFlight=!0,this._sendAction({title:"",type:"launchProductList",payload:{sku_list:this.config.pageContext.skuList.slice(0,48)}},{silent:!0,isContextPrime:!0,preservePills:!0})),!this._homepageLaunched&&this.config.pageContext?.pageType==="home"&&(this._homepageLaunched=!0,this._contextPrimingInFlight=!0,this._sendAction({title:"",type:"launchHomepage",payload:{}},{silent:!0,isContextPrime:!0,preservePills:!0}))}onHide(){(this.config.variant??"floating")==="floating"&&(this.root.style.display=""),this._hideDrawer(),this.emit("close"),Te("gengage:chat:close",{}),this.config.onClose?.()}onDestroy(){this._releaseHostDocumentScrollLock(),this._abortAllActiveRequests(),this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,this._comparisonRefreshRafId!==null&&(cancelAnimationFrame(this._comparisonRefreshRafId),this._comparisonRefreshRafId=null),this._drawer?.destroy(),Ga(),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,a){a?.sku!==void 0&&this.update({sku:a.sku}),this._pdpLaunched=!0,a?.state!==void 0?this._openState=a.state:this._isMobileViewport&&(this._openState="half"),this.show(),this._drawerVisible&&this._applyOpenStateClasses(),this._sendAction(t)}sendMessage(t){this._sendMessage(t)}sendAction(t,a){this._sendAction(t,a)}close(){this.hide()}saveSession(t,a){sessionStorage.setItem("gengage_restore_session_id",t),sessionStorage.setItem("gengage_restore_sku",a)}get isOpen(){return this._drawerVisible}addCallback(t,a){let n=this._eventCallbacks.get(t);return n||(n=new Set,this._eventCallbacks.set(t,n)),n.add(a),()=>{n.delete(a),n.size===0&&this._eventCallbacks.delete(t)}}_applyDiscountedPriceColorVar(t){const a=this.root;t==="client"?a.style.setProperty("--gengage-discounted-price-color","var(--client-primary)"):a.style.removeProperty("--gengage-discounted-price-color")}_abortAllActiveRequests(){for(const t of this._abortControllers)t.abort();this._abortControllers.clear()}_pruneEmptyStreamingAssistantPlaceholders(){const t=[];let a=!1;for(const n of this._messages){if(n.role==="assistant"&&(n.status==="streaming"||n.status==="done")&&(n.content==null||n.content.length===0)){if(n.threadId){this._threadsWithFirstBot.delete(n.threadId),this._presentation.finalizeAssistantGroup(n.threadId),this._shadow?.querySelectorAll(`[data-thread-id="${_e(n.threadId)}"]:not([data-message-id])`).forEach(i=>i.remove()),this._panel&&(this._panel.threads=this._panel.threads.filter(i=>i!==n.threadId));const r=this._thumbnailEntries.length;this._thumbnailEntries=this._thumbnailEntries.filter(i=>i.threadId!==n.threadId),this._thumbnailEntries.length!==r&&(a=!0)}this._drawer?.removeMessageBubble(n.id),this._panel?.snapshots.delete(n.id),this._panel?.snapshotTypes.delete(n.id);continue}t.push(n)}this._messages.length=0,this._messages.push(...t),a&&this._drawer?.setThumbnails(this._thumbnailEntries)}_resetForNewPage(){this._activeRequestThreadId=null,this._abortAllActiveRequests(),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._plpLaunched=!1,this._homepageLaunched=!1,this._entryContextPrimed=!1,this._contextPrimingInFlight=!1,this._queuedUserMessages=[],this._productContextUnavailableSku=null,this._presentation.reset(),this._drawer?.setPresentationFocus(null),this._drawer?.setFormerMessagesButtonVisible(!1),this._modeController.reset()&&(this._drawer?.setInputPlaceholder(this._i18n.inputPlaceholder),this._drawer?.setAttachmentControlsVisible(!0),this._drawer?.setBeautyPhotoStepCard({visible:!1}))}_clearAssistantPanelLikeStreamClearPanel(){this._clearChoicePrompter(),this._drawer?.clearPanel(),this._currentPanelSource=null,this._thumbnailEntries=[],this._drawer?.setThumbnails([]),this._comparisonSelectMode=!1,this._comparisonSelectedSkus=[],this._comparisonSelectionWarning=null,this._panel&&(this._panel.currentType=null,this._panel.updateExtendedMode(""),this._panel.updateTopBar(""))}_flushPresentationScroll(){const t=this._presentation.scrollRequest;if(!t||!this._drawer)return;let a=!1;t.type==="thread"&&t.threadId?(a=this._drawer.scrollThreadIntoView(t.threadId,t.behavior),a||(this._drawer.scrollToBottomPresentation(t.behavior),a=!0)):t.type==="bottom"&&(this._drawer.scrollToBottomPresentation(t.behavior),a=!0),a&&this._presentation.consumeScrollRequest(t.id)}_focusPresentationThread(t,a="smooth",n=!1){this._presentation.requestThreadFocus(t,a),n&&this._drawer?.setPresentationFocus(t),this._drawer?.setFormerMessagesButtonVisible(!1),setTimeout(()=>this._flushPresentationScroll(),40)}_scrollInlineIntoView(t,a){if(a){this._focusPresentationThread(a,"auto");return}t.scrollIntoView({behavior:"auto",block:"start"})}_releasePresentationFocus(){this._presentation.releaseFocusedThread(),this._drawer?.setPresentationFocus(null),this._drawer?.setFormerMessagesButtonVisible(!1)}_hasMultipleThreadIds(){const t=new Set;for(const a of this._messages)a.threadId&&t.add(a.threadId);return t.size>1}_orderedThreadIds(){const t=[],a=new Set;for(const n of this._messages)n.threadId&&!a.has(n.threadId)&&(a.add(n.threadId),t.push(n.threadId));return t}_maybeAutoAnchorUnreadAssistant(){if(!this._drawer||!this._presentation.shown)return;const t=this._orderedThreadIds();if(t.length===0)return;const a=El(t,this._presentation);if(!a)return;const n=`${a}:assistant`;this._presentation.lastAutoAnchoredGroupId!==n&&(this._presentation.userInteracting&&!this._presentation.pinnedToBottom||this._drawer.scrollThreadIntoView(a,"smooth")&&this._presentation.markGroupAutoAnchored(n))}_handleBridgeMessage(t){switch(t.type){case"openChat":this.open();break;case"closeChat":this.close();break;case"startNewChatWithLauncherAction":{const a=t.payload,n=a?.action,r=Sa(n)?n:Sa(a)?a:null;r&&this._sendAction(r,{silent:!0}),this.open();break}case"startNewChatWithDetailContext":{const a=t.payload;if(a&&typeof a=="object"){this._bridgeContext=a;const n=a.sku;if(n&&this.update({sku:n}),Sa(a.action)){this._pdpLaunched=!0,this.open(),this._sendAction(a.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 a=t.payload;a&&"quantity"in a&&typeof a.quantity=="number"&&(this._cartQuantity=a.quantity);break}case"favoritesCountHandler":{const a=t.payload?.count;typeof a=="number"&&a>=0&&this._drawer?.updateFavoritesBadge(a);break}case"minimizeRequestedByUser":this._extendedModeManager?.setHiddenByUser(!0);break;case"bgColorChange":{const a=t.payload?.color;typeof a=="string"&&Br(a)&&this._shadow&&this._shadow.host.style.setProperty("--gengage-chat-bg",a);break}default:break}}_registerPublicAPI(){window.gengage||(window.gengage={}),window.gengage.chat={open:t=>this.open(t),openWithAction:(t,a)=>this.openWithAction(t,a),sendMessage:t=>this.sendMessage(t),sendAction:(t,a)=>this.sendAction(t,a),close:()=>this.close(),saveSession:(t,a)=>this.saveSession(t,a),get isOpen(){return!1},on:(t,a)=>this.on(t,a),trackCheckout:(t,a)=>this.trackCheckout(t,a),flushMeteringSummary:t=>this.flushMeteringSummary(t),addCallback:(t,a)=>this.addCallback(t,a)},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)return;const t=this._resolveOpeningContextKey(),a=this._resolveContextualOpeningActions(t);if(a.length>0&&this._drawer?.setPills(a.map(i=>({label:i.title,onAction:()=>this._sendAction(this._resolveContextualOpeningAction(i,t))}))),this._hasDedicatedContextLaunch()||this._shouldPrimeContextualOpening())return;const n=this._resolveContextualOpeningMessage(t);if(!n)return;const r={id:Ra(),role:"assistant",content:n,timestamp:Date.now(),status:"done"};this._messages.push(r),this._drawer?.addMessage(r)}_resolveOpeningContextKey(){switch(this.config.pageContext?.pageType){case"home":return"home";case"search":case"plp":return"listing";case"pdp":return"product";default:return"default"}}_resolveContextualOpeningMessage(t=this._resolveOpeningContextKey()){return this.config.openingMessagesByContext?.[t]??(t!=="default"?this.config.openingMessagesByContext?.default:void 0)??this.config.welcomeMessage}_resolveContextualOpeningGuidance(t=this._resolveOpeningContextKey()){return this.config.openingGuidanceByContext?.[t]??(t!=="default"?this.config.openingGuidanceByContext?.default:void 0)}_resolveContextualOpeningActions(t=this._resolveOpeningContextKey()){const a=this.config.welcomeActionsByContext?.[t]??(t!=="default"?this.config.welcomeActionsByContext?.default:void 0);return a?.length?a.filter(n=>typeof n?.title=="string"&&n.title.trim().length>0):(this.config.welcomeActions??[]).filter(n=>typeof n=="string"&&n.trim().length>0).map(n=>({title:n}))}_resolveContextualOpeningAction(t,a=this._resolveOpeningContextKey()){const n=t.title.trim(),r=this.config.pageContext?.sku??this._readContextStringField("sku"),i=this._readContextStringListField("visible_skus")??[];return t.icon==="review"&&r?{title:n,type:"reviewSummary",payload:{sku:r}}:t.icon==="similar"&&r?{title:n,type:"findSimilar",payload:{sku:r}}:t.icon==="compare"&&a==="listing"&&i.length>=2?{title:n,type:"getComparisonTable",payload:{sku_list:i.slice(0,2)}}:{title:n,type:"user_message",payload:n}}_readContextStringField(t){const a=this.config.pageContext,n=a?.extra&&typeof a.extra=="object"&&!Array.isArray(a.extra)?a.extra:void 0,r=t.replace(/_([a-z])/g,(o,s)=>s.toUpperCase()),i=a?.[t]??n?.[t]??a?.[r]??n?.[r];return typeof i=="string"&&i.trim().length>0?i.trim():void 0}_readContextStringListField(t){const a=this.config.pageContext,n=a?.extra&&typeof a.extra=="object"&&!Array.isArray(a.extra)?a.extra:void 0,r=t.replace(/_([a-z])/g,(s,c)=>c.toUpperCase()),i=a?.[t]??n?.[t]??a?.[r]??n?.[r];if(!Array.isArray(i))return;const o=i.filter(s=>typeof s=="string"&&s.trim().length>0);return o.length>0?o:void 0}_buildEntryOpeningPageDetails(){const t={};t.url=this.config.pageContext?.url??window.location.href;const a=this._readContextStringField("page_title");a&&(t.page_title=a);const n=this._readContextStringField("page_description");n&&(t.page_description=n);const r=this._readContextStringField("search_query");r&&(t.search_query=r);const i=this._readContextStringListField("visible_skus");i?.length&&(t.visible_skus=i);const o=this._readContextStringListField("popular_searches");o?.length&&(t.popular_searches=o);const s=this.config.pageContext?.categoryTree??this._readContextStringListField("category_path");return s?.length&&(t.category_path=s),Object.keys(t).length>0?t:void 0}_hasDedicatedContextLaunch(){const t=this.config.pageContext;return t?!!(t.pageType==="pdp"&&t.sku||t.pageType==="plp"&&t.skuList?.length||t.pageType==="home"):!1}_shouldPrimeContextualOpening(){return this._messages.length!==0||this._entryContextPrimed||this._contextPrimingInFlight||this._hasDedicatedContextLaunch()?!1:!!(this.config.openingMessagesByContext||this.config.openingGuidanceByContext||this.config.welcomeActionsByContext)}_maybePrimeEntryContextOpening(){const t=this._resolveOpeningContextKey();if(!this._shouldPrimeContextualOpening())return;this._entryContextPrimed=!0;const a={text:"",is_entry_context_opening:1,opening_context_key:t},n=this._buildEntryOpeningPageDetails();n&&(a.page_details=n);const r=this._resolveContextualOpeningMessage(t);r&&(a.opening_message=r);const i=this._resolveContextualOpeningGuidance(t);i&&(a.opening_guidance=i),this._sendAction({title:"",type:"user_message",payload:a},{silent:!0,preservePills:!0})}_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()}}_isMaximizedForHostChrome(){if(!this._drawerVisible)return!1;const t=this.config.variant??"floating";return t==="inline"?!1:t==="overlay"?!0:!(!(this._drawer?.isPanelVisible()??!1)||!this._isMobileViewport&&(this._drawer?.isPanelCollapsed()??!1))}_shouldLockHostDocumentScroll(){if(!this._drawerVisible)return!1;const t=this.config.variant??"floating";return t==="inline"?!1:t==="overlay"||this._isMobileViewport?!0:this._drawer?.isPanelVisible()??!1}_applyOpenStateClasses(){if(!this._rootEl)return;const t=this._drawerVisible&&this._isMobileViewport&&this._openState==="half",a=this._drawerVisible&&this._isMobileViewport&&this._openState==="full",n=this._isMaximizedForHostChrome();if(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",a),this._rootEl.classList.toggle("gengage-chat-root--maximized-host-chrome",n),this._backdropEl){const r=n&&(this.config.variant??"floating")!=="inline";this._backdropEl.setAttribute("aria-hidden",r?"false":"true")}this._syncHostDocumentScrollLock(),this._maybeTrackChatbotMainPaneGa()}_mainPaneExpandedForAnalytics(){const t=this._drawer;return t?.isPanelVisible()?this._isMobileViewport?!0:!t.isPanelCollapsed():!1}_maybeTrackChatbotMainPaneGa(){const t=this._mainPaneExpandedForAnalytics();t&&!this._gaPrevMainPaneExpanded&&bi(),this._gaPrevMainPaneExpanded=t}_syncHostDocumentScrollLock(){if(!(typeof document>"u")){if((this.config.variant??"floating")==="inline"){this._releaseHostDocumentScrollLock();return}this._shouldLockHostDocumentScroll()?this._applyHostDocumentScrollLock():this._releaseHostDocumentScrollLock()}}_hostScrollEventShouldReachChatScroller(t){try{const a=t.composedPath();if(a.length===0)return!0;if(!a.includes(this.root))return!1;for(const n of a){if(n===this.root)break;if(!(n instanceof HTMLElement))continue;if(this._backdropEl&&(n===this._backdropEl||this._backdropEl.contains(n)))return!1;const r=window.getComputedStyle(n),i=(r.overflowY==="auto"||r.overflowY==="scroll")&&n.scrollHeight>n.clientHeight+1,o=(r.overflowX==="auto"||r.overflowX==="scroll")&&n.scrollWidth>n.clientWidth+1;if(i||o)return!0}return!1}catch{return!1}}_applyHostDocumentScrollLock(){if(!(typeof document>"u"||typeof window>"u")){if(!this._hostOverflowRestore){const t=document.documentElement,a=document.body;this._hostOverflowRestore={htmlOverflow:t.style.overflow,bodyOverflow:a?.style.overflow??"",htmlOverscroll:t.style.overscrollBehavior,bodyOverscroll:a?.style.overscrollBehavior??""},t.style.overflow="hidden",t.style.overscrollBehavior="none",a&&(a.style.overflow="hidden",a.style.overscrollBehavior="none"),this._hostScrollLockViewport={x:window.scrollX,y:window.scrollY}}this._hostScrollLockActive||(window.addEventListener("touchmove",this._preventHostDocumentTouchMove,{capture:!0,passive:!1}),window.addEventListener("wheel",this._preventHostDocumentWheel,{capture:!0,passive:!1}),document.addEventListener("touchmove",this._preventHostDocumentTouchMove,{capture:!0,passive:!1}),document.addEventListener("wheel",this._preventHostDocumentWheel,{capture:!0,passive:!1}),window.addEventListener("scroll",this._pinHostViewportScroll,{capture:!0,passive:!0}),this._hostScrollLockActive=!0)}}_releaseHostDocumentScrollLock(){if(!(typeof document>"u")&&(typeof window<"u"&&(window.removeEventListener("scroll",this._pinHostViewportScroll,{capture:!0}),window.removeEventListener("touchmove",this._preventHostDocumentTouchMove,{capture:!0}),window.removeEventListener("wheel",this._preventHostDocumentWheel,{capture:!0})),this._hostScrollLockActive&&(document.removeEventListener("touchmove",this._preventHostDocumentTouchMove,{capture:!0}),document.removeEventListener("wheel",this._preventHostDocumentWheel,{capture:!0}),this._hostScrollLockActive=!1),this._hostScrollLockViewport=null,this._hostScrollPinning=!1,this._hostOverflowRestore)){const t=document.documentElement,a=document.body;t.style.overflow=this._hostOverflowRestore.htmlOverflow,t.style.overscrollBehavior=this._hostOverflowRestore.htmlOverscroll,a&&(a.style.overflow=this._hostOverflowRestore.bodyOverflow,a.style.overscrollBehavior=this._hostOverflowRestore.bodyOverscroll),this._hostOverflowRestore=null}}_handleAttachment(t){const a=Ki(t);if(!a.ok){Te("gengage:global:error",{message:a.reason==="invalid_type"?this._i18n.invalidFileType:this._i18n.fileTooLarge,source:"chat"});return}this._drawer?.stageAttachment(t)}_sendMessage(t,a){this._contextPrimingInFlight&&(this._abortAllActiveRequests(),this._contextPrimingInFlight=!1,this._queuedUserMessages=[]),yi(),this._messages.some(r=>r.role==="user")||_i(),De("chat","sendMessage",{mode:this._assistantMode,hasAttachment:a!==void 0,textLength:t.length});const n=a!==void 0?{title:t,type:this._modeController.resolveAttachmentActionType(),payload:t?{text:t}:{}}:{title:t,type:"user_message",payload:t};a!==void 0?this._sendAction(n,{attachment:a}):this._sendAction(n)}_flushQueuedUserMessages(){if(this._contextPrimingInFlight||this._queuedUserMessages.length===0)return;const t=[...this._queuedUserMessages];this._queuedUserMessages=[];for(const a of t)this._sendMessage(a.text,a.attachment)}_applyUiHints(){this._modeController.applyUiHints(this._drawer,this._i18n.inputPlaceholder,()=>{this._clearChoicePrompter()})}_handleRedirectMetadata(t){this._modeController.handleRedirect(t)}_sendAction(t,a){if(this._activeTypewriter?.cancel(),this._activeTypewriter=null,this._activeTtsHandle?.stop(),this._activeTtsHandle=null,this._lastSentAction={action:t,options:a},!this._initComplete){this._pendingActions.length<10&&this._pendingActions.push({action:t,options:a});return}if(this._clearChoicePrompter(),a?.preservePanel||fl(),!a?.preservePanel&&this._comparisonSelectMode&&t.type!=="getComparisonTable"&&(this._comparisonSelectMode=!1,this._comparisonSelectedSkus=[]),a?.preservePanel||(this._localPanelHistory=[]),this._currentThreadId&&this._lastThreadId&&this._lastThreadId>this._currentThreadId){const y=this._currentThreadId,E=this._messages.filter(S=>S.threadId!==void 0&&S.threadId>y);this._messages=this._messages.filter(S=>!S.threadId||S.threadId<=y);for(const S of E)this._shadow?.querySelector(`[data-message-id="${_e(S.id)}"]`)?.remove(),this._panel.snapshots.delete(S.id),this._panel.snapshotTypes.delete(S.id);this._shadow?.querySelectorAll("[data-thread-id]")?.forEach(S=>{S instanceof HTMLElement&&S.dataset.threadId&&S.dataset.threadId>y&&S.remove()})}a?.preservePills||this._drawer?.setPills([]),this._drawer?.clearInputAreaChips(),this._bridge?.send("isResponding",!0);const n=Ra();this._currentThreadId=n,this._lastThreadId=n,this._panel&&!Fu.has(t.type)&&(this._panel.lastActionType=t.type);const r=a?.preservePanel===!0,i=a?.silent===!0&&a?.isContextPrime===!0,o=i&&t.type==="launchSingleProduct";if(r||(this._activeRequestThreadId=n),!a?.silent&&!r&&this._drawer?.setPresentationFocus(n),!a?.silent){const y=typeof t.payload=="string"?t.payload:typeof t.payload?.text=="string"?t.payload.text:t.title,E=this._messages.length>0?this._messages[this._messages.length-1]:void 0;if(!(E!==void 0&&E.role==="user"&&E.content===y)){(!this._messages.some(z=>z.role==="user")||this._drawer?.isKvkkBannerVisible())&&(da(this.config.accountId),this._drawer?.hideKvkkBanner());const S=this._createMessage("user",y);S.threadId=n,a?.attachment!==void 0&&(S.attachment=a.attachment),this._drawer?.addMessage(S),a?.attachment!==void 0&&this._modeController.isBeautyConsulting&&this._drawer?.setBeautyPhotoStepCard({visible:!1}),this._messages.push(S)}}if(!a?.silent&&this._assistantMode==="shopping"&&this._hasUnavailableProductContext()&&(t.type==="user_message"||t.type==="inputText")){const y=this._i18n.productNotFoundMessage,E=this._createMessage("assistant",y);E.threadId=n,E.status="done",this._messages.push(E),this._ensureAssistantMessageRendered(E),this._drawer?.updateBotMessage(E.id,y),this._drawer?.setPresentationFocus(n),this._bridge?.send("isResponding",!1),this.emit("message",E),this._persistToIndexedDB().catch(()=>{});return}let s=this._currentPanelSource,c=!1;const l=t.type==="user_message"||t.type==="inputText",g=()=>{c||a?.preservePanel||(s=this._currentPanelSource,c=!0)},p=()=>{if(this._drawer?.isPanelLoading()){if(!l&&s){const y=this._buildRenderContext(),E=this._renderPanelFromSource(s,y);this._drawer.setPanelContent(E),this._drawer.setDividerPreviewEnabled(this._shouldUseDividerPreviewForSource(s)),this._currentPanelSource=s}else this._drawer.clearPanel(),this._currentPanelSource=null;s=null}};t.type==="getComparisonTable"&&(this._drawer?.showPanelLoading("comparisonTable"),this._panel?.updateTopBarForLoading("comparisonTable")),!a?.silent&&!r&&this._pruneEmptyStreamingAssistantPlaceholders(),this._drawer?.showTypingIndicator();let h="";const d=this._createMessage("assistant","");d.threadId=n,d.status="streaming",a?.silent&&(d.silent=!0),this._messages.push(d),this._presentation.registerAssistantActivity(n),this._focusPresentationThread(n,"smooth",a?.silent||r),a?.preservePanel||(this._contextPrimingInFlight&&!i&&(this._contextPrimingInFlight=!1,this._queuedUserMessages=[]),this._abortAllActiveRequests());const b={middlewareUrl:this.config.middlewareUrl,...this.config.accountId?{accountId:this.config.accountId}:{}};a?.attachment!==void 0&&(b.attachment=a.attachment);const u=this._getVisibleMessages().filter(y=>y!==d&&(y.content||y.role==="assistant")).slice(-50).map(y=>({role:y.role==="user"?"user":"model",content:y.content??""})),v={outputLanguage:Ol(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:Bn(this.config.accountId),voiceEnabled:this.config.voiceEnabled??!1,threadId:n,isControlGroup:this.config.session?.abTestVariant==="control",isMobile:this._isMobileViewport};this._modeController.isShopping||(v.assistantMode=this._modeController.mode),this.config.session?.viewId!==void 0&&(v.viewId=this.config.session.viewId);const m=Wo(t,{pageContext:this.config.pageContext,backendContext:this._lastBackendContext,isMobile:this._isMobileViewport}),P={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",type:m.type,locale:wt(this.config.locale),meta:v,context:{...this._lastBackendContext??{},messages:u,session_id:this.config.session?.sessionId??""}};this.config.session?.userId!==void 0&&(P.user_id=this.config.session.userId),this.config.session?.viewId!==void 0&&(P.view_id=this.config.session.viewId),m.payload!==void 0&&(P.payload=m.payload),this.config.pageContext?.sku!==void 0&&(P.sku=this.config.pageContext.sku),this.config.pageContext?.pageType!==void 0&&(P.page_type=this.config.pageContext.pageType);const A=crypto.randomUUID(),k=Date.now();let x=0,N=!1,T=!1,I=!1,$=!1,ae=!1;const oe=Ts();let ve=null,O=null;const f=()=>{if(this._drawer&&!$){if(!I){this._drawer.setPanelAiZoneState("hidden");return}ae?this._drawer.setPanelAiZoneState("hidden"):this._drawer.setPanelAiZoneState("analyzing",{analyzingLabel:this._i18n.aiAnalysisAnalyzingLabel})}},L=y=>{if(!ve||!this._drawer)return;const E=this._buildRenderContext();E.isStreaming=y;const S=this._renderUISpec(ve,E);$=!0,this._drawer.setPanelAiZoneState("results",{resultEl:S}),ve=null},D=(y,E,S)=>{if(y==="ProductGrid"||y==="CategoriesContainer"){I=!0,L(S),f();return}E!=="appendSimilars"&&E!=="append"&&(I=!1,$=!1,ve=null,this._drawer?.setPanelAiZoneState("hidden"))},B=y=>(y==="ProductGrid"||y==="CategoriesContainer")&&(I||$||ve!==null),j=(y,E,S)=>{if(!this._drawer||!this._panel)return;const z=y.elements[y.root];if(S==="ProductGrid"&&z){const M=oa(z);if(M.isConsulting){const R=this._drawer.getPanelContentElement();if(R&&el(R,M,E)){this._comparisonSelectMode=!1,this._comparisonSelectedSkus=[],this._comparisonSelectionWarning=null,this._drawer.setComparisonDockContent(null),this._currentPanelSource={kind:"spec",spec:y},this._panel.currentType=S,this._drawer.resyncPanelTopBarFromCurrentContent();return}}}this._comparisonSelectMode=!1,this._comparisonSelectedSkus=[],this._comparisonSelectionWarning=null,this._drawer.setComparisonDockContent(null),this._drawer.setPanelContent(this._renderUISpec(y,E),{preserveAiZone:B(S)}),this._currentPanelSource={kind:"spec",spec:y},this._panel.currentType=S},Z=(y,E,S,z)=>{if(!this._panel)return;this._drawer?.setDividerPreviewEnabled((this._panel.currentType??y)==="ProductGrid"),y==="ProductDetailsPanel"&&t.type==="launchSingleProduct"&&this._clearUnavailableProductContext(),d.threadId&&!this._panel.threads.includes(d.threadId)&&this._panel.threads.push(d.threadId);const M=this._panel.currentType??y,R=E?.props?.panelTitle;this._panel.updateTopBar(M,R),this._panel.updateExtendedMode(y),this._isMobileViewport&&o&&this._drawer?.hideMobilePanel(),D(y,S,z)};this.track($r(this.analyticsContext(),{endpoint:"process_action",request_id:A,widget:"chat"}));let q=null;if(q=Jo(P,{onTextChunk:(y,E,S)=>{if(!r&&n!==this._activeRequestThreadId||(h+=y,this._drawer?.removeTypingIndicator(),S?.skuToProductItem&&(this._skuToProductItem={...this._skuToProductItem,...S.skuToProductItem}),S?.conversationMode&&(this._conversationMode=S.conversationMode),S?.renderHint&&(d.renderHint=S.renderHint),this.track(Hr(this.analyticsContext(),{request_id:A,chunk_index:x++,widget:"chat"})),!this._drawer))return;let z=h;const M=S?.kvkk===!0||o&&ga(z);if(E&&M){const H=this.config.accountId;if(!Bn(H)){const ne=Rl(z);ne?this._drawer?.showKvkkBanner(ne,()=>{this._drawer?.hideKvkkBanner(),da(H)}):da(H)}z=Bl(z)}const R=this._shadow?.querySelector(`[data-message-id="${d.id}"] .gengage-chat-bubble-text`);if(R?R.innerHTML=Ae(z):(d.content=z,d.role==="assistant"&&d.threadId&&!this._threadsWithFirstBot.has(d.threadId)&&(this._threadsWithFirstBot.add(d.threadId),this._drawer.markFirstBotMessage(d.id)),this._drawer.addMessage(d)),E)if(d.content=z,d.status="done",La(),Is(d))this._drawer?.updateBotMessage(d.id,z,"photo_analysis",d.photoAnalysis),d.threadId&&this._focusPresentationThread(d.threadId,"auto");else{const H=this._shadow?.querySelector(`[data-message-id="${d.id}"] .gengage-chat-bubble-text`);if(H){this._activeTypewriter?.cancel();const ne=S?.productMentions;this._activeTypewriter=ll({container:H,html:Ae(z),onTick:()=>this._drawer?.scrollToBottomIfNeeded(),onComplete:()=>{this._activeTypewriter=null,ne&&ne.length>0&&H&&gl({container:H,mentions:ne,onProductClick:te=>{this._sendAction({title:ne.find(U=>U.sku===te)?.short_name??te,type:"launchSingleProduct",payload:{sku:te}})}})}})}}},onUISpec:(y,E,S,z)=>{if(!r&&n!==this._activeRequestThreadId||E!=="chat")return;z&&(this._clearAssistantPanelLikeStreamClearPanel(),N=!1,O=null);const M=y.elements[y.root],R=M?.type??"unknown";if(Ls(R,M?.props??{},oe,{drawer:this._drawer,ensureRendered:()=>this._ensureAssistantMessageRendered(d),cancelTypewriter:()=>{this._activeTypewriter?.cancel(),this._activeTypewriter=null},sendSkipMessage:()=>this._sendMessage(this._i18n.beautyPhotoStepSkipMessage),streamDone:ae},d)){R==="PhotoAnalysisCard"&&d.threadId&&this._focusPresentationThread(d.threadId,"auto");return}const H=Ea(M),ne=this.config.productDetailsExtended!==!0&&(R==="ProductDetailsPanel"||H);ne&&!z&&(this._clearAssistantPanelLikeStreamClearPanel(),N=!1);const te=R==="ProductDetailsPanel"&&S!=="panel"?"panel":S;this.track(Ur(this.analyticsContext(),{request_id:A,chunk_index:x,component_type:R,widget:"chat"}));const U=this._buildRenderContext();if(U.isStreaming=!0,R==="ComparisonTable"){const V=M?.props?.products;pi(Array.isArray(V)?V.length:0)}if(R==="ProductGrid"){const V=M?.children?.length??0;mi(void 0,V)}const ce=te==="panel"&&this._panel?this._panel.toPanelSpec(y):y;if(te==="panel"&&this._panel&&!ne&&R==="ProductGrid"&&M){const V=oa(M);if(V.isConsulting&&!Qc(V)){O=y;return}V.isConsulting&&(O=null)}if(te==="panel"&&this._panel&&!ne){const V=!T;T=!0;const ee=M?.props?.replacePanel===!0,ge=M?.props?.rankingState,W=ee||ge==="pending"||ge==="final"?"replace":Sl({componentType:R,similarsAppend:M?.props?.similarsAppend===!0,currentPanelType:this._panel.currentType,hasPanelContent:this._drawer?.hasPanelContent()??!1,isPanelLoading:this._drawer?.isPanelLoading()??!1,isFirstPanelContentInStream:V});U.panelProductListHeading=void 0,R==="ProductGrid"&&(W==="appendSimilars"?U.panelProductListHeading=this._i18n.similarProductsLabel??"Similar Products":this._applyPanelListHeadingToContext(U,{kind:"spec",spec:ce})),W==="appendSimilars"?this._appendSimilarsToPanel(ce,U):W==="append"?(this._drawer?.appendPanelContent(this._renderUISpec(ce,U)),this._comparisonSelectMode&&this._refreshComparisonUI()):j(ce,U,R),Z(R,M,W,!0)}if(R==="ProductDetailsPanel"&&te==="panel"&&(!d.silent||o)){const V=M?.props?.product;if(V){const ee={root:"root",elements:{root:{type:"ProductSummaryCard",props:{product:V}}}},ge=this._shadow?.querySelector(".gengage-chat-messages");if(ge){const W=this._renderUISpec(ee,U);d.threadId&&(W.dataset.threadId=d.threadId);const ie=this._shadow?.querySelector(`[data-message-id="${d.id}"]`);ie&&ie.parentNode===ge?ie.after(W):ge.appendChild(W),this._scrollInlineIntoView(W,d.threadId),this._drawer?.refreshPresentationCollapsed(),T=!0}}}const X=R==="AITopPicks"||R==="AIGroupingCards",$e=R==="ActionButtons"?M?.props?.buttons:void 0,xt=R==="ActionButtons"&&this._modeController.mode!=="shopping"&&Array.isArray($e)&&$e.length>0&&$e.every(V=>V.action?.type==="inputText");let C=!1,Y=!1;if(ne&&H&&(U.panelProductListHeading=this._i18n.similarProductsLabel??"Similar Products"),X&&(!d.silent||i))if(I){const V=this._renderUISpec(y,U);$=!0,this._drawer?.setPanelAiZoneState("results",{resultEl:V}),C=!0,ve=null}else ve=y,Y=!0;const he=i&&(R==="GroundingReviewCard"||X);if(!X&&(!d.silent||he)&&(te!=="panel"||R==="ProductCard"||ne&&R==="ProductGrid"&&!H)&&(R!=="ActionButtons"||xt)&&!C&&!(Y&&X)){const V=this._shadow?.querySelector(".gengage-chat-messages");if(V){const ee=this._renderUISpec(y,U);d.threadId&&(ee.dataset.threadId=d.threadId),V.appendChild(ee),this._scrollInlineIntoView(ee,d.threadId),this._drawer?.refreshPresentationCollapsed(),ne&&R==="ProductGrid"&&(T=!0)}}if((R==="ProductGrid"||R==="ProductCard")&&d.threadId){const V=M?.children??[],ee=R==="ProductGrid"?V.map(ge=>y.elements[ge]?.props?.product).filter(Boolean):[M?.props?.product].filter(Boolean);for(const ge of ee){const W=ge.sku,ie=ge.imageUrl;W&&ie&&this._thumbnailEntries.push({sku:W,imageUrl:ie,threadId:d.threadId}),W&&this._viewedProductSkus.add(W)}this._drawer?.setThumbnails(this._thumbnailEntries)}if(R==="ProductGrid"||R==="ProductDetailsPanel"){const V=(R==="ProductGrid"?(M?.children??[]).map(ee=>y.elements[ee]?.props?.product).filter(Boolean):[M?.props?.product??M?.props].filter(Boolean)).map(ee=>ee.imageUrl).filter(ee=>typeof ee=="string").slice(0,5);V.length>0&&this._bridge?.send("previewImages",{images:V})}const me=M?.children?.length??0;if(R==="ProductGrid"&&te==="panel"&&!ne&&me>1&&!this._modeController.isChoicePrompterHidden&&!this._comparisonSelectMode&&!bl(this._currentThreadId??"")&&(this._clearChoicePrompter(),this._choicePrompterEl=ml({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}}),this._mountChoicePrompter()&&this._isMobileViewport&&window.visualViewport)){const V=this._choicePrompterEl,ee=()=>{window.visualViewport.height/window.innerHeight<.75&&(V.remove(),this._choicePrompterEl===V&&(this._choicePrompterEl=null),window.visualViewport.removeEventListener("resize",ee))};window.visualViewport.addEventListener("resize",ee)}if(R==="ActionButtons"){const V=M?.props?.buttons;if(V&&V.length>0&&!xt){const ee=[],ge=[];for(const W of V)if(hl(W)){const ie={label:W.label,action:W.action};W.icon&&(ie.icon=W.icon),ee.push(ie)}else ge.push(W);ee.length>0&&this._drawer?.setInputAreaChips(ee.map(W=>({label:W.label,onAction:()=>this._sendAction(W.action),...W.icon?{icon:W.icon}:{}}))),ge.length>0&&this._drawer?.setPills(ge.map(W=>{const ie={label:W.label,onAction:()=>this._sendAction(W.action)};return W.icon&&(ie.icon=W.icon),W.image&&(ie.image=W.image),W.description&&(ie.description=W.description),ie}))}}f(),d.uiSpec=y},onAction:y=>{if(!(!r&&n!==this._activeRequestThreadId)&&y.type==="action"){const E={};this.config.actionHandling?.unknownActionPolicy!==void 0&&(E.unknownActionPolicy=this.config.actionHandling.unknownActionPolicy),this.config.actionHandling?.allowScriptCall!==void 0&&(E.allowScriptCall=this.config.actionHandling.allowScriptCall),qi(y,{openChat:()=>this.open(),navigate:S=>{ye(S.url)&&(this._bridge?.send("navigate",S),S.newTab?window.open(S.url,"_blank","noopener,noreferrer"):window.location.href=S.url)},saveSession:S=>this.saveSession(S.sessionId,S.sku),addToCart:S=>{Te("gengage:similar:add-to-cart",S)},scriptCall:S=>{Te("gengage:chat:script-call",S),this.config.onScriptCall?.(S)}},E)}},onMetadata:y=>{if(!(!r&&n!==this._activeRequestThreadId)&&y.type==="metadata"&&y.meta){if(y.meta.panel!==void 0||y.meta.messages!==void 0||y.meta.message_id!==void 0){this._lastBackendContext=y.meta;const S=Yt(y.meta.panel);S&&(this._modeController.updateFromContext(S),this._applyUiHints())}if(y.meta.panelLoading){const S=typeof y.meta.panelPendingType=="string"?y.meta.panelPendingType:void 0;this.config.productDetailsExtended!==!0&&(S==="productDetails"||S==="productDetailsSimilars")||(N=!0,T=!1,g(),this._panel&&(this._panel.currentType=null),this._drawer?.showPanelLoading(S),S&&this._panel?.updateTopBarForLoading(S))}if(y.meta.voice){const S=new CustomEvent("gengage:chat:voice",{detail:{payload:y.meta.voice},bubbles:!1,cancelable:!0}),z=window.dispatchEvent(S);if(xi(),z){const M=y.meta.voice;M.audio_base64&&(this._activeTtsHandle?.stop(),this._activeTtsHandle=rl(M.audio_base64,M.content_type??"audio/ogg"))}}if((y.meta.redirectTarget||y.meta.redirect)&&(Te("gengage:chat:redirect",{target:y.meta.redirectTarget??null,payload:y.meta.redirect??null}),De("redirect","redirect dispatched",{target:y.meta.redirectTarget??null}),this._handleRedirectMetadata(y.meta.redirect)),y.meta.analyzeAnimation&&this.config.productDetailsExtended===!0&&(N=!0,T=!1,g(),this._panel&&(this._panel.currentType=null),this._drawer?.showPanelLoading(),this._panel?.updateTopBarForLoading("productDetails")),y.meta.loading){const S=Array.isArray(y.meta.thinkingMessages)?y.meta.thinkingMessages.filter(M=>typeof M=="string"):[],z=typeof y.meta.loadingText=="string"?y.meta.loadingText:void 0;if(S.length>0){const M=z&&this._modeController.shouldCondenseThinking()?[...S.slice(0,2),z]:S;this._drawer?.setThinkingSteps(M)}typeof z=="string"&&z.length>0&&(this._drawer?.addThinkingStep(z),this._bridge?.send("loadingMessage",{text:z}))}y.meta.visitorDataResponse&&this._bridge?.send("engagingMessage",y.meta.visitorDataResponse),y.meta.formType&&this._bridge?.send("glovForm",{type:y.meta.formType,data:y.meta.formPayload}),y.meta.launcherContent&&this._bridge?.send("launcherContent",y.meta.launcherContent),Te("gengage:chat:metadata",{payload:y.meta});const E=y.meta;typeof E.prompt_tokens=="number"&&typeof E.completion_tokens=="number"&&this.track(qr(this.analyticsContext(),{model:y.model??"unknown",prompt_tokens:E.prompt_tokens,completion_tokens:E.completion_tokens,total_tokens:E.total_tokens??E.prompt_tokens+E.completion_tokens}))}},onError:y=>{if(q&&this._abortControllers.delete(q),!r&&n!==this._activeRequestThreadId)return;ae=!0,this._activeTypewriter?.cancel(),this._activeTypewriter=null,f(),ve=null,O=null,this._bridge?.send("isResponding",!1),this._bridge?.send("loadingMessage",{text:null}),this._drawer?.removeTypingIndicator(),this._drawer?.clearInputAreaChips(),zs(oe,{drawer:this._drawer,ensureRendered:()=>{},cancelTypewriter:()=>{},sendSkipMessage:()=>this._sendMessage(this._i18n.beautyPhotoStepSkipMessage),streamDone:!0});const E=T;N&&!T&&p(),N=!1,T=!1;const S=d.content!=null&&d.content.length>0||h.length>0||E,z=d.silent||S,M=typeof navigator<"u"&&navigator.onLine===!1&&Ba(y),R=()=>{this._shadow?.querySelector(`[data-message-id="${_e(d.id)}"]`)?.remove();const te=this._messages.indexOf(d);te>=0&&this._messages.splice(te,1)};let H=!1;const ne=()=>{if(M)return;this.emit("error",y);const te=y.message;te===this._lastErrorMessage?this._consecutiveErrorCount++:(this._consecutiveErrorCount=1,this._lastErrorMessage=te);const U=y.message.trim(),ce=U.length>0?U:this._i18n.errorMessage,X={onRetry:()=>{this._lastSentAction&&this._sendAction(this._lastSentAction.action,this._lastSentAction.options)},onNewQuestion:()=>{this._drawer?.focusInput()}};if(this._consecutiveErrorCount>=2){R(),H=!0,this._drawer?.showErrorWithRecovery(this._i18n.accountInactiveMessage,X);return}if(Nl(y,ce)){R(),H=!0,this._drawer?.showErrorWithRecovery(ce,X);return}d.content=ce,d.status="done";const $e=Ae(ce.replace(/\r\n/g,`
|
|
177
177
|
`).split(`
|
|
178
|
-
`).join("<br />"));this._ensureAssistantMessageRendered(d),this._drawer?.updateBotMessage(d.id,$e),this._drawer?.showRecoveryPillsOnly(X)};if(i&&!S)if(o||this._hasUnavailableProductContext()){this._drawer?.setPills([]);const te=this._i18n.productNotFoundMessage;d.content=te,d.status="done",this._ensureAssistantMessageRendered(d),this._drawer?.updateBotMessage(d.id,te),this._markUnavailableProductContext()}else d.status="done";else if(z)this._drawer?.setPills([]),d.silent||ne();else if(ne(),M)return;i&&(this._contextPrimingInFlight=!1,this._flushQueuedUserMessages()),!H&&d.status==="streaming"&&(d.status="error"),M||this.track(Zr(this.analyticsContext(),{request_id:A,error_code:"STREAM_ERROR",error_message:y.message,widget:"chat"}))},onDone:()=>{if(q&&this._abortControllers.delete(q),!r&&n!==this._activeRequestThreadId)return;if(ae=!0,O&&this._panel&&this._drawer){const z=this._buildRenderContext();z.isStreaming=!1;const M=O.elements[O.root],R=this._panel.toPanelSpec(O);this._applyPanelListHeadingToContext(z,{kind:"spec",spec:R});const H=M?.type??"ProductGrid";j(R,z,H),Z(H,M,"replace",!1),T=!0}O=null,ve&&L(!1),f(),this._activeRequestThreadId=null,this._consecutiveErrorCount=0,this._lastErrorMessage="",this._bridge?.send("isResponding",!1),this._bridge?.send("loadingMessage",{text:null}),this._drawer?.removeTypingIndicator(),Ns(oe,{drawer:this._drawer,ensureRendered:()=>{},cancelTypewriter:()=>{},sendSkipMessage:()=>this._sendMessage(this._i18n.beautyPhotoStepSkipMessage),streamDone:!0});const y=T;if(N&&!T&&p(),N=!1,o&&!h&&!y){const z=this._i18n.productNotFoundMessage;d.content=z,this._ensureAssistantMessageRendered(d),this._drawer?.updateBotMessage(d.id,z),this._markUnavailableProductContext()}if(T=!1,i){this._contextPrimingInFlight=!1;const z=this._queuedUserMessages.length>0;this._flushQueuedUserMessages(),!z&&o&&this._ensurePdpPrimeSuggestedUiIfNeeded()}d.status==="streaming"&&(d.status="done",La()),this._presentation.finalizeAssistantGroup(n);const E=this._shadow?.querySelector(".gengage-chat-comparison-toggle-btn--hidden");E&&(E.classList.remove("gengage-chat-comparison-toggle-btn--hidden"),E.classList.add("gengage-chat-comparison-toggle-btn--reveal")),this.emit("message",d);const S=this._currentPanelSource;this._panel?.snapshotForMessage(d.id,S?()=>{const z=this._buildRenderContext();return this._renderPanelFromSource(S,z)}:void 0),this.track(jr(this.analyticsContext(),{request_id:A,latency_ms:Date.now()-k,chunk_count:x,widget:"chat"})),this.track(Vr(this.analyticsContext(),{meter_key:"chat_request",quantity:1,unit:"request"})),this.track(Wr(this.analyticsContext(),{message_count:this._messages.length,history_ref:this.config.session?.sessionId??"",redaction_level:"none"})),this._persistToIndexedDB().catch(()=>{})}},b),this._abortControllers.add(q),!a?.silent&&!r){const y=q;this._drawer?.showStopButton(()=>{y.abort(),this._abortControllers.delete(y),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(n=>!n.silent);if(!this._currentThreadId)return t;const a=this._currentThreadId;return t.filter(n=>!n.threadId||n.threadId<=a)}_appendSimilarsToPanel(t,a){if(!this._drawer)return;const n=this._drawer.getPanelContentElement();if(!n)return;a.panelProductListHeading=this._i18n.similarProductsLabel??"Similar Products";const r=this._renderUISpec(t,a);r.classList.add("gengage-chat-product-details-similars"),n.appendChild(r),this._mergePanelSourceWithSimilars(t)}_coerceSkuKey(t){return typeof t=="string"?t.trim():typeof t=="number"&&Number.isFinite(t)?String(t).trim():""}_productSkuKey(t){return t?this._coerceSkuKey(t.sku):""}_pdpPageContextSkuKey(){const t=this.config.pageContext?.pageType;return typeof t!="string"||t.toLowerCase()!=="pdp"?null:this._coerceSkuKey(this.config.pageContext?.sku)||null}_getCurrentPanelProductSku(){const t=this._currentPanelSource;if(!t)return null;let a=null;if(t.kind==="spec"?a=t.spec:t.kind==="productDetailsWithSimilars"&&(a=t.pdpSpec),!a)return null;const n=a.elements[a.root];if(!n||n.type!=="ProductDetailsPanel")return null;const r=n.props,i=r?.product??r;return i&&this._coerceSkuKey(i.sku)||null}_activeSkuForProductSummaryClick(){const t=this._getCurrentPanelProductSku();return t||this._pdpPageContextSkuKey()}_mergePanelSourceWithSimilars(t){const a=this._currentPanelSource;a?.kind==="spec"&&this._panel?.currentType==="ProductDetailsPanel"&&(this._currentPanelSource={kind:"productDetailsWithSimilars",pdpSpec:a.spec,similarsSpec:t})}_renderProductDetailsWithSimilars(t,a,n){this._applyPanelListHeadingToContext(n,{kind:"productDetailsWithSimilars",pdpSpec:t,similarsSpec:a});const r=this._renderUISpec(t,n),i=this._renderUISpec(a,n);return i.classList.add("gengage-chat-product-details-similars"),r.appendChild(i),r}_applyPanelListHeadingToContext(t,a){if(t.panelProductListHeading=void 0,!!this._panel){if(a.kind==="spec"){const n=a.spec.elements[a.spec.root];n?.type==="ProductGrid"&&(n.children?.length??0)>0&&(t.panelProductListHeading=this._panel.titleForComponent("ProductGrid",n.props?.panelTitle??void 0))}else if(a.kind==="productDetailsWithSimilars"){const n=a.similarsSpec.elements[a.similarsSpec.root];n?.type==="ProductGrid"&&(n.children?.length??0)>0&&(t.panelProductListHeading=this._i18n.similarProductsLabel??"Similar Products")}}}_renderPanelFromSource(t,a){return this._applyPanelListHeadingToContext(a,t),t.kind==="favorites"?this._buildFavoritesPageEl():t.kind==="productDetailsWithSimilars"?this._renderProductDetailsWithSimilars(t.pdpSpec,t.similarsSpec,a):this._renderUISpec(t.spec,a)}_handleRollback(t){const a=this._messages.find(n=>n.id===t);a?.threadId&&this._rollbackToThread(a.threadId)}_ensurePdpPrimeSuggestedUiIfNeeded(){const t=this.config.pageContext?.sku;if(!t||!this._drawer||this._hasUnavailableProductContext())return;const a="product",n=this._resolveContextualOpeningActions(a);if(n.length>0){this._drawer.setInputAreaChips(n.map(r=>({label:r.title,onAction:()=>this._sendAction(this._resolveContextualOpeningAction(r,a)),...r.icon?{icon:r.icon}:{}})));return}this._drawer.setInputAreaChips([{label:this._i18n.groundingReviewCta,icon:"review",onAction:()=>this._sendAction({title:this._i18n.customerReviewsTitle,type:"reviewSummary",payload:{sku:t}})},{label:this._i18n.findSimilarLabel,icon:"similar",onAction:()=>this._sendAction({title:this._i18n.findSimilarLabel,type:"findSimilar",payload:{sku:t}})}])}_rollbackToThread(t){if(this._panel&&this._panel.threads.length>0&&!this._panel.threads.includes(t)&&!this._messages.some(i=>i.threadId===t))return;this._currentThreadId=t,this._extendedModeManager?.setHiddenByUser(!1),this._lastThreadId!=null&&t===this._lastThreadId?(this._presentation.setFocusedThreadId(t),this._drawer?.setPresentationFocus(t)):(this._presentation.releaseFocusedThread(),this._drawer?.setPresentationFocus(null)),this._drawer?.setFormerMessagesButtonVisible(!1);for(const i of this._messages){const o=this._shadow?.querySelector(`[data-message-id="${_e(i.id)}"]`);o&&(i.threadId&&i.threadId>t?o.classList.add("gengage-chat-bubble--hidden"):o.classList.remove("gengage-chat-bubble--hidden"))}this._shadow?.querySelectorAll("[data-thread-id]").forEach(i=>{i instanceof HTMLElement&&i.dataset.threadId&&i.dataset.threadId>t?i.classList.add("gengage-chat-bubble--hidden"):i instanceof HTMLElement&&i.classList.remove("gengage-chat-bubble--hidden")});const a=this._messages.find(i=>i.role==="assistant"&&i.threadId===t),n=a?this._panel?.restoreForMessage(a.id):!1;n||(this._drawer?.clearPanel(),this._currentPanelSource=null),n&&a&&(this._currentPanelSource=null);const r=this._panel.currentType??"";if(this._panel?.updateTopBar(r),this._drawer?.setPills([]),requestAnimationFrame(()=>{this._drawer?.scrollThreadIntoView(t,"auto")}),this._session?.db&&this.config.session?.sessionId){const i=this.config.session.sessionId;(async()=>{try{const o=await this._session?.db?.loadContext(i,t);o&&(this._lastBackendContext=o.context),await this._session?.db?.deleteContextsAfterThread(i,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="${_e(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,a){return this._session?this._session.loadPayload(t,a):null}async _restoreFromIndexedDB(t){if(!this._session?.db)return;const a=this.config.session?.sessionId;if(!a)return;const n=this.config.session?.userId??"",r=this.config.accountId;if(await this._session.loadFavorites(n,r),this._drawer?.updateFavoritesBadge(this._session.favoritedSkus.size),!t)return;const i=await this._session.db?.loadSession(n,r,a);if(!i||i.messages.length===0)return;const o=this.config.pageContext?.sku;if(o&&i.sku&&i.sku!==o)return;if(this._pdpLaunched=!0,this._drawer?.lockScrollForRestore(),this._currentThreadId=i.currentThreadId,this._lastThreadId=i.lastThreadId,this._currentThreadId&&this._lastThreadId&&this._currentThreadId>this._lastThreadId&&(this._currentThreadId=this._lastThreadId),this._chatCreatedAt=i.createdAt,i.panelThreads&&(this._panel.threads=i.panelThreads),i.thumbnailEntries&&(this._thumbnailEntries=i.thumbnailEntries,this._drawer?.setThumbnails(this._thumbnailEntries)),i.panelSnapshotHtml)for(const[c,l]of Object.entries(i.panelSnapshotHtml)){const g=document.createElement("div");g.innerHTML=Ae(l),this._panel.snapshots.set(c,g)}let s=0;for(const c of i.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),delete l.uiSpec)}}if(s>this._currentMessageId&&(this._currentMessageId=s),this._currentThreadId){let c=await this._session.db?.loadContext(a,this._currentThreadId);c||(c=await this._session.db?.loadLatestContext(a)),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="${_e(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 a=this._buildRenderContext(),n=this._renderPanelFromSource(t.source,a);this._drawer?.setPanelContent(n),this._drawer?.setDividerPreviewEnabled(this._shouldUseDividerPreviewForSource(t.source)),this._currentPanelSource=t.source;const r=this._localPanelHistory.length>0||(this._panel?.threads.length??0)>1;this._drawer?.updatePanelTopBar(r,!1,t.title);return}if(this._isMobileViewport){this._drawer?.hideMobilePanel();return}this._panel?.navigateBack()}_shouldUseDividerPreviewForSpec(t){return t.elements[t.root]?.type==="ProductGrid"}_shouldUseDividerPreviewForSource(t){return t?.kind==="spec"?this._shouldUseDividerPreviewForSpec(t.spec):!1}_toggleComparisonSku(t){if(t==="")this._comparisonSelectMode=!this._comparisonSelectMode,this._comparisonSelectionWarning=null,this._comparisonSelectMode&&(vl(this._currentThreadId??""),this._clearChoicePrompter()),this._comparisonSelectMode||(this._comparisonSelectedSkus=[],this._comparisonSelectionWarning=null,di());else if(this._comparisonSelectedSkus.indexOf(t)>=0)this._comparisonSelectedSkus=this._comparisonSelectedSkus.filter(a=>a!==t),this._comparisonSelectionWarning=null;else{if(this._comparisonSelectedSkus.length>=dt._MAX_COMPARISON_SELECTION){this._comparisonSelectionWarning=this._i18n.compareMaxHint??`You can select up to ${dt._MAX_COMPARISON_SELECTION} products`,this._comparisonRefreshRafId!==null&&cancelAnimationFrame(this._comparisonRefreshRafId),this._comparisonRefreshRafId=requestAnimationFrame(()=>{this._comparisonRefreshRafId=null,this._refreshComparisonUI()});return}this._comparisonSelectedSkus=[...this._comparisonSelectedSkus,t],this._comparisonSelectionWarning=null,li(t)}this._comparisonRefreshRafId!==null&&cancelAnimationFrame(this._comparisonRefreshRafId),this._comparisonRefreshRafId=requestAnimationFrame(()=>{this._comparisonRefreshRafId=null,this._refreshComparisonUI()})}_refreshComparisonUI(){const t=this._shadow?.querySelector(".gengage-chat-panel");if(!t){this._drawer?.setComparisonDockContent(null);return}const a=t.querySelector(".gengage-chat-product-grid-wrapper"),n=a?.querySelector(".gengage-chat-product-grid");if(!a||!n){this._drawer?.setComparisonDockContent(null);return}const r=a.querySelector(".gengage-chat-comparison-toggle-btn");if(r&&r.classList.toggle("gengage-chat-comparison-toggle-btn--active",this._comparisonSelectMode),this._comparisonSelectMode){const i=n.querySelectorAll(".gengage-chat-product-card[data-sku]");for(const o of i){if(o.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){const d=o.parentElement,b=this._comparisonSelectedSkus.includes(o.dataset.sku);d.classList.toggle("gengage-chat-comparison-select-wrapper--selected",b);const u=d.querySelector(".gengage-chat-comparison-checkbox");if(u){u.dataset.selected=b?"true":"false",u.setAttribute("aria-pressed",b?"true":"false");const v=u.querySelector(".gengage-chat-comparison-checkbox-icon"),m=u.querySelector(".gengage-chat-comparison-checkbox-label");v&&(v.innerHTML=b?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6L9 17l-5-5"/></svg>':'<span class="gengage-chat-comparison-checkbox-dot"></span>'),m&&(m.textContent=b?this._i18n.comparisonSelectedLabel??"Selected":this._i18n.comparisonSelectLabel??"Select to compare")}continue}const s=o.dataset.sku,c=document.createElement("div");c.className="gengage-chat-comparison-select-wrapper";const l=this._comparisonSelectedSkus.includes(s);l&&c.classList.add("gengage-chat-comparison-select-wrapper--selected");const g=document.createElement("button");g.type="button",g.className="gengage-chat-comparison-checkbox",g.dataset.selected=l?"true":"false",g.setAttribute("aria-pressed",l?"true":"false");const p=document.createElement("span");p.className="gengage-chat-comparison-checkbox-icon",p.innerHTML=l?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6L9 17l-5-5"/></svg>':'<span class="gengage-chat-comparison-checkbox-dot"></span>';const h=document.createElement("span");h.className="gengage-chat-comparison-checkbox-label",h.textContent=l?this._i18n.comparisonSelectedLabel??"Selected":this._i18n.comparisonSelectLabel??"Select to compare",g.appendChild(p),g.appendChild(h),g.addEventListener("click",d=>{d.stopPropagation(),this._toggleComparisonSku(s)}),o.parentNode.insertBefore(c,o),c.appendChild(g),c.appendChild(o),c.classList.add("gds-clickable"),c.addEventListener("click",d=>{d.target.closest(".gengage-chat-comparison-checkbox")||(d.stopPropagation(),this._toggleComparisonSku(s))})}}else{const i=n.querySelectorAll(".gengage-chat-comparison-select-wrapper");for(const o of i){const s=o.querySelector(".gengage-chat-product-card");s&&o.parentNode&&(o.parentNode.insertBefore(s,o),o.remove())}}if(a.querySelector(".gengage-chat-comparison-floating-btn")?.remove(),this._comparisonSelectMode){const i=dn(this._comparisonSelectedSkus,this._buildRenderContext());this._isMobileViewport?this._drawer?.setComparisonDockContent(i):(this._drawer?.setComparisonDockContent(null),a.appendChild(i))}else this._drawer?.setComparisonDockContent(null)}_clearChoicePrompter(){this._choicePrompterEl?.remove(),this._choicePrompterEl=null,this._shadow?.querySelectorAll(".gengage-chat-choice-prompter").forEach(t=>t.remove())}_mountChoicePrompter(){if(!this._choicePrompterEl)return!1;if(this._isMobileViewport)return this._drawer?.setComparisonDockContent(this._choicePrompterEl),!0;const t=this._shadow?.querySelector(".gengage-chat-panel-float");return t?(t.appendChild(this._choicePrompterEl),!0):(this._choicePrompterEl=null,!1)}_parseAddToCartActionPayload(t){if(typeof t!="object"||t===null)return null;const a=t,n=this._coerceAddToCartString(a.sku),r=this._coerceAddToCartString(a.cartCode??a.cart_code);let i=1;return typeof a.quantity=="number"&&Number.isFinite(a.quantity)&&a.quantity>0&&(i=Math.max(1,Math.floor(a.quantity))),!n||!r?null:{sku:n,cartCode:r,quantity:i}}_coerceAddToCartString(t){return typeof t=="string"&&t.length>0?t:typeof t=="number"&&Number.isFinite(t)?String(t):""}_runChatAddToCartFlow(t){if(this.config.onAddToCart!==void 0)try{const r=this.config.onAddToCart(t);r instanceof Promise&&r.catch(i=>console.error("[gengage] onAddToCart",i))}catch(r){console.error("[gengage] onAddToCart",r)}vi(t.sku,t.quantity);const a={...t,sessionId:this.config.session?.sessionId??null};Te("gengage:chat:add-to-cart",a),this._bridge?.send("addToCart",t),this._runEventCallbacks("gengage-cart-add",a),this.track(Kr(this.analyticsContext(),{attribution_source:"chat",attribution_action_id:crypto.randomUUID(),cart_value:0,currency:this.config.pricing?.currencyCode??"TRY",line_items:t.quantity,sku:t.sku})),this._sendAction({title:this._i18n.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:t.sku,cart_code:t.cartCode,quantity:t.quantity}},{preservePanel:!0});const n=this._i18n.addedToCartToast??"Added to cart";this._drawer?.showCartToast(n),this._drawer?.flashCartBadge()}_buildRenderContext(){const t={locale:wt(this.config.locale),onAction:a=>{if(si(a.title,a.type),a.type==="addToCart"){const r=this._parseAddToCartActionPayload(a.payload);if(r){this._runChatAddToCartFlow(r);return}}if(a.type==="launchSingleProduct"){this._drawer?.setDividerPreviewEnabled(!1);const r=typeof a.payload=="object"&&a.payload!==null&&"sku"in a.payload?a.payload.sku:void 0,i=this._coerceSkuKey(r),o=this._activeSkuForProductSummaryClick();if(i&&o&&i===o)return;i&&Ta(i,a.title)}if(a.type==="findSimilar"){const r=typeof a.payload=="object"&&a.payload!==null&&"sku"in a.payload?String(a.payload.sku):"";ci(r)}if(a.type==="getComparisonTable"){const r=a.payload,i=r&&typeof r=="object"?r:null,o=i&&typeof i.gengage_analytics_source=="string"?i.gengage_analytics_source:"";let s=[];i&&Array.isArray(i.sku_list)&&(s=i.sku_list.filter(c=>typeof c=="string")),o==="floating_compare_dock"?fi(s):gi(s.length>0?s:this._comparisonSelectedSkus)}const n=a.type==="addToCart"||a.type==="like";this._sendAction(a,n?{preservePanel:!0}:void 0)},onProductClick:a=>{const n=this.config.isDemoWebsite!==!0&&this._isSameOriginUrl(a.url);if(!n){const r=this._coerceSkuKey(a.sku),i=this._activeSkuForProductSummaryClick();if(r&&i&&r===i)return}if(n)Te("gengage:similar:product-click",{sku:a.sku,url:a.url,sessionId:this.config.session?.sessionId??null,...a.name!==void 0&&a.name!==""?{productName:a.name}:{}}),this._saveSessionAndOpenURL(a.url);else{Ta(a.sku);const r=a.name?.trim()?a.name.trim():a.sku;this._sendAction({title:r,type:"launchSingleProduct",payload:{sku:a.sku}})}},onAddToCart:a=>{this._runChatAddToCartFlow(a)},onProductSelect:a=>{const n=this._productSkuKey(a),r=this._activeSkuForProductSummaryClick();if(n&&r&&n===r)return;if(this._currentPanelSource){const l=this._drawer?.getPanelTopBarTitle()??"";this._localPanelHistory.push({source:this._currentPanelSource,title:l}),this._localPanelHistory.length>dt._MAX_PANEL_HISTORY&&this._localPanelHistory.shift()}const i=this._buildRenderContext(),o={root:"root",elements:{root:{type:"ProductSummaryCard",props:{product:a}}}},s=this._shadow?.querySelector(".gengage-chat-messages");if(s){const l=this._renderUISpec(o,i);this._currentThreadId&&(l.dataset.threadId=this._currentThreadId),s.appendChild(l),this._scrollInlineIntoView(l,this._currentThreadId),this._drawer?.refreshPresentationCollapsed()}if(this.config.productDetailsExtended!==!0){this._clearAssistantPanelLikeStreamClearPanel();return}const c={root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:a}}}};this._drawer?.setPanelContent(this._renderUISpec(c,t)),this._drawer?.setDividerPreviewEnabled(!1),this._currentPanelSource={kind:"spec",spec:c},this._panel&&(this._panel.currentType="ProductDetailsPanel"),this._drawer?.updatePanelTopBar(!0,!1,this._i18n.panelTitleProductDetails)},i18n:this._i18n,pricing:this.config.pricing,productPriceUi:this.config.productPriceUi,hideProductDiscountBadge:this.config.hideProductDiscountBadge,productSort:this._productSort,onSortChange:a=>{this._productSort=a},comparisonSelectMode:this._comparisonSelectMode,comparisonSelectedSkus:this._comparisonSelectedSkus,comparisonMaxSelection:dt._MAX_COMPARISON_SELECTION,comparisonSelectionWarning:this._comparisonSelectionWarning,onToggleComparisonSku:a=>{this._toggleComparisonSku(a)},favoritedSkus:this._session?.favoritedSkus??new Set,onFavoriteToggle:(a,n)=>{this._toggleProductFavorite(a,n)},isMobile:this._isMobileViewport};return t}async _toggleFavorite(t,a){if(!this._session)return;const n=this.config.session?.userId??"",r=this.config.accountId;await this._session.toggleFavorite(n,r,t,a),this._drawer?.updateFavoritesBadge(this._session.favoritedSkus.size)}_revertFavoriteHeartUi(t){const a=this._shadow?.querySelectorAll(`[data-gengage-favorite-sku="${_e(t)}"]`);if(a?.length)for(const n of a){if(!(n instanceof HTMLButtonElement))continue;n.classList.toggle("gengage-chat-favorite-btn--active");const r=n.querySelector("svg");r&&r.setAttribute("fill",n.classList.contains("gengage-chat-favorite-btn--active")?"currentColor":"none")}}async _toggleProductFavorite(t,a){const n=!(this._session?.favoritedSkus.has(t)??!1),r={sku:t,product:a,favorited:n,sessionId:this.config.session?.sessionId??null};Te("gengage:chat:product-favorite",r),this._bridge?.send("productFavorite",r);const i=this._eventCallbacks.get("gengage-product-favorite");if(i&&i.size>0){for(const o of i)try{const s=o(r);if((s instanceof Promise?await s:s)===!1){this._revertFavoriteHeartUi(t),this._handleCallbackFailure("gengage-product-favorite",r);return}}catch{this._revertFavoriteHeartUi(t),this._handleCallbackFailure("gengage-product-favorite",r);return}this._session&&(n?this._session.favoritedSkus.add(t):this._session.favoritedSkus.delete(t),this._drawer?.updateFavoritesBadge(this._session.favoritedSkus.size));return}if(await this._toggleFavorite(t,a),n){hi(t);const o=a.name??t;this._sendAction({title:o,type:"like",payload:{sku:t}},{preservePanel:!0})}}_openFavoritesPanel(){if(this._drawer){if(this._currentPanelSource){const t=this._drawer.getPanelTopBarTitle()??"";this._localPanelHistory.push({source:this._currentPanelSource,title:t}),this._localPanelHistory.length>dt._MAX_PANEL_HISTORY&&this._localPanelHistory.shift()}this._drawer.setPanelContent(this._buildFavoritesPageEl()),this._drawer.setDividerPreviewEnabled(!1),this._currentPanelSource={kind:"favorites"},this._drawer.updatePanelTopBar(!0,!1,this._i18n.favoritesPageTitle)}}_buildFavoritesPageEl(){const t=this._session?.getFavoriteProducts()??[];if(t.length===0){const i=document.createElement("div");i.className="gengage-chat-favorites-empty";const o=document.createElement("div");o.className="gengage-chat-favorites-empty-icon",o.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>',i.appendChild(o);const s=document.createElement("p");return s.textContent=this._i18n.emptyFavoritesMessage,i.appendChild(s),i}const a={},n=[];for(const[i,o]of t.entries()){const s=`card_${i}`;n.push(s),a[s]={type:"ProductCard",props:{product:{sku:o.sku,name:o.name,imageUrl:o.imageUrl,price:o.price}}}}a.grid={type:"ProductGrid",children:n};const r={root:"grid",elements:a};return this._renderUISpec(r,this._buildRenderContext())}async _runEventCallbacks(t,a){const n=this._eventCallbacks.get(t);if(!(!n||n.size===0))for(const r of n)try{const i=r(a);if((i instanceof Promise?await i:i)===!1){this._handleCallbackFailure(t,a);return}}catch{this._handleCallbackFailure(t,a);return}}_handleCallbackFailure(t,a){if(t==="gengage-cart-add"){const n=this._i18n.cartAddErrorMessage,r=this._createMessage("assistant",n);this._currentThreadId&&(r.threadId=this._currentThreadId),this._messages.push(r),this._drawer?.addMessage(r)}if(t==="gengage-product-favorite"){const n=this._i18n.favoriteToggleErrorMessage,r=this._createMessage("assistant",n);this._currentThreadId&&(r.threadId=this._currentThreadId),this._messages.push(r),this._drawer?.addMessage(r)}}_restoreInlineUISpec(t){if(!t.uiSpec||!this._drawer)return;const a=t.uiSpec,n=a.elements[a.root];if(!n)return;const r=n.type;if(r==="ActionButtons"||r==="ComparisonTable"||Ea(n))return;const i=this._buildRenderContext(),o=this._shadow?.querySelector(".gengage-chat-messages");if(!o)return;if(r==="ProductDetailsPanel"){const c=n.props?.product;if(!c)return;const l={root:"root",elements:{root:{type:"ProductSummaryCard",props:{product:c}}}},g=this._renderUISpec(l,i);t.threadId&&(g.dataset.threadId=t.threadId),o.appendChild(g),this._drawer?.refreshPresentationCollapsed();return}const s=this._renderUISpec(a,i);t.threadId&&(s.dataset.threadId=t.threadId),o.appendChild(s),this._drawer?.refreshPresentationCollapsed()}_createMessage(t,a){return this._currentMessageId++,{id:`msg-${this._currentMessageId}`,role:t,content:a,timestamp:Date.now(),status:"done"}}_resolveI18n(t){return{...is(t.locale),...t.i18n}}_resolveUISpecRegistry(){return Fr(hn(),this.config.renderer?.registry)}_renderUISpec(t,a){const n=this._resolveUISpecRegistry(),r=this.config.renderer?.unknownRenderer??ea,i=(s,c)=>un(s,c,n,r),o=this.config.renderer?.renderUISpec;return o?o(t,a,{registry:n,unknownRenderer:r,defaultRender:i}):i(t,a)}};function $u(){return new Rr}Ee.CHAT_SCROLL_ELEMENT_ID=kt,Ee.ChatPresentationState=zn,Ee.GengageChat=Rr,Ee.chatCatalog=Ou,Ee.createChatWidget=$u,Ee.createDefaultChatUISpecRegistry=hn,Ee.defaultChatUnknownUISpecRenderer=ea,Ee.getChatScrollElement=as,Ee.invalidateChatScrollCache=Ga,Ee.isSimilarsAppendGrid=Ea,Ee.renderUISpec=un})(this.Gengage=this.Gengage||{});
|
|
178
|
+
`).join("<br />"));this._ensureAssistantMessageRendered(d),this._drawer?.updateBotMessage(d.id,$e),this._drawer?.showRecoveryPillsOnly(X)};if(i&&!S)if(o||this._hasUnavailableProductContext()){this._drawer?.setPills([]);const te=this._i18n.productNotFoundMessage;d.content=te,d.status="done",this._ensureAssistantMessageRendered(d),this._drawer?.updateBotMessage(d.id,te),this._markUnavailableProductContext()}else d.status="done";else if(z)this._drawer?.setPills([]),d.silent||ne();else if(ne(),M)return;i&&(this._contextPrimingInFlight=!1,this._flushQueuedUserMessages()),!H&&d.status==="streaming"&&(d.status="error"),M||this.track(Zr(this.analyticsContext(),{request_id:A,error_code:"STREAM_ERROR",error_message:y.message,widget:"chat"}))},onDone:()=>{if(q&&this._abortControllers.delete(q),!r&&n!==this._activeRequestThreadId)return;if(ae=!0,O&&this._panel&&this._drawer){const z=this._buildRenderContext();z.isStreaming=!1;const M=O.elements[O.root],R=this._panel.toPanelSpec(O);this._applyPanelListHeadingToContext(z,{kind:"spec",spec:R});const H=M?.type??"ProductGrid";j(R,z,H),Z(H,M,"replace",!1),T=!0}O=null,ve&&L(!1),f(),this._activeRequestThreadId=null,this._consecutiveErrorCount=0,this._lastErrorMessage="",this._bridge?.send("isResponding",!1),this._bridge?.send("loadingMessage",{text:null}),this._drawer?.removeTypingIndicator(),Ns(oe,{drawer:this._drawer,ensureRendered:()=>{},cancelTypewriter:()=>{},sendSkipMessage:()=>this._sendMessage(this._i18n.beautyPhotoStepSkipMessage),streamDone:!0});const y=T;if(N&&!T&&p(),N=!1,o&&!h&&!y){const z=this._i18n.productNotFoundMessage;d.content=z,this._ensureAssistantMessageRendered(d),this._drawer?.updateBotMessage(d.id,z),this._markUnavailableProductContext()}if(T=!1,i){this._contextPrimingInFlight=!1;const z=this._queuedUserMessages.length>0;this._flushQueuedUserMessages(),!z&&o&&this._ensurePdpPrimeSuggestedUiIfNeeded()}d.status==="streaming"&&(d.status="done",La()),this._presentation.finalizeAssistantGroup(n);const E=this._shadow?.querySelector(".gengage-chat-comparison-toggle-btn--hidden");E&&(E.classList.remove("gengage-chat-comparison-toggle-btn--hidden"),E.classList.add("gengage-chat-comparison-toggle-btn--reveal")),this.emit("message",d);const S=this._currentPanelSource;this._panel?.snapshotForMessage(d.id,S?()=>{const z=this._buildRenderContext();return this._renderPanelFromSource(S,z)}:void 0),this.track(jr(this.analyticsContext(),{request_id:A,latency_ms:Date.now()-k,chunk_count:x,widget:"chat"})),this.track(Vr(this.analyticsContext(),{meter_key:"chat_request",quantity:1,unit:"request"})),this.track(Wr(this.analyticsContext(),{message_count:this._messages.length,history_ref:this.config.session?.sessionId??"",redaction_level:"none"})),this._persistToIndexedDB().catch(()=>{})}},b),this._abortControllers.add(q),!a?.silent&&!r){const y=q;this._drawer?.showStopButton(()=>{y.abort(),this._abortControllers.delete(y),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(n=>!n.silent);if(!this._currentThreadId)return t;const a=this._currentThreadId;return t.filter(n=>!n.threadId||n.threadId<=a)}_appendSimilarsToPanel(t,a){if(!this._drawer)return;const n=this._drawer.getPanelContentElement();if(!n)return;a.panelProductListHeading=this._i18n.similarProductsLabel??"Similar Products";const r=this._renderUISpec(t,a);r.classList.add("gengage-chat-product-details-similars"),n.appendChild(r),this._mergePanelSourceWithSimilars(t)}_coerceSkuKey(t){return typeof t=="string"?t.trim():typeof t=="number"&&Number.isFinite(t)?String(t).trim():""}_productSkuKey(t){return t?this._coerceSkuKey(t.sku):""}_pdpPageContextSkuKey(){const t=this.config.pageContext?.pageType;return typeof t!="string"||t.toLowerCase()!=="pdp"?null:this._coerceSkuKey(this.config.pageContext?.sku)||null}_getCurrentPanelProductSku(){const t=this._currentPanelSource;if(!t)return null;let a=null;if(t.kind==="spec"?a=t.spec:t.kind==="productDetailsWithSimilars"&&(a=t.pdpSpec),!a)return null;const n=a.elements[a.root];if(!n||n.type!=="ProductDetailsPanel")return null;const r=n.props,i=r?.product??r;return i&&this._coerceSkuKey(i.sku)||null}_activeSkuForProductSummaryClick(){const t=this._getCurrentPanelProductSku();return t||this._pdpPageContextSkuKey()}_mergePanelSourceWithSimilars(t){const a=this._currentPanelSource;a?.kind==="spec"&&this._panel?.currentType==="ProductDetailsPanel"&&(this._currentPanelSource={kind:"productDetailsWithSimilars",pdpSpec:a.spec,similarsSpec:t})}_renderProductDetailsWithSimilars(t,a,n){this._applyPanelListHeadingToContext(n,{kind:"productDetailsWithSimilars",pdpSpec:t,similarsSpec:a});const r=this._renderUISpec(t,n),i=this._renderUISpec(a,n);return i.classList.add("gengage-chat-product-details-similars"),r.appendChild(i),r}_applyPanelListHeadingToContext(t,a){if(t.panelProductListHeading=void 0,!!this._panel){if(a.kind==="spec"){const n=a.spec.elements[a.spec.root];n?.type==="ProductGrid"&&(n.children?.length??0)>0&&(t.panelProductListHeading=this._panel.titleForComponent("ProductGrid",n.props?.panelTitle??void 0))}else if(a.kind==="productDetailsWithSimilars"){const n=a.similarsSpec.elements[a.similarsSpec.root];n?.type==="ProductGrid"&&(n.children?.length??0)>0&&(t.panelProductListHeading=this._i18n.similarProductsLabel??"Similar Products")}}}_renderPanelFromSource(t,a){return this._applyPanelListHeadingToContext(a,t),t.kind==="favorites"?this._buildFavoritesPageEl():t.kind==="productDetailsWithSimilars"?this._renderProductDetailsWithSimilars(t.pdpSpec,t.similarsSpec,a):this._renderUISpec(t.spec,a)}_handleRollback(t){const a=this._messages.find(n=>n.id===t);a?.threadId&&this._rollbackToThread(a.threadId)}_ensurePdpPrimeSuggestedUiIfNeeded(){const t=this.config.pageContext?.sku;if(!t||!this._drawer||this._hasUnavailableProductContext())return;const a="product",n=this._resolveContextualOpeningActions(a);if(n.length>0){this._drawer.setInputAreaChips(n.map(r=>({label:r.title,onAction:()=>this._sendAction(this._resolveContextualOpeningAction(r,a)),...r.icon?{icon:r.icon}:{}})));return}this._drawer.setInputAreaChips([...this.config.hideUserReviews!==!0?[{label:this._i18n.groundingReviewCta,icon:"review",onAction:()=>this._sendAction({title:this._i18n.customerReviewsTitle,type:"reviewSummary",payload:{sku:t}})}]:[],{label:this._i18n.findSimilarLabel,icon:"similar",onAction:()=>this._sendAction({title:this._i18n.findSimilarLabel,type:"findSimilar",payload:{sku:t}})}])}_rollbackToThread(t){if(this._panel&&this._panel.threads.length>0&&!this._panel.threads.includes(t)&&!this._messages.some(i=>i.threadId===t))return;this._currentThreadId=t,this._extendedModeManager?.setHiddenByUser(!1),this._lastThreadId!=null&&t===this._lastThreadId?(this._presentation.setFocusedThreadId(t),this._drawer?.setPresentationFocus(t)):(this._presentation.releaseFocusedThread(),this._drawer?.setPresentationFocus(null)),this._drawer?.setFormerMessagesButtonVisible(!1);for(const i of this._messages){const o=this._shadow?.querySelector(`[data-message-id="${_e(i.id)}"]`);o&&(i.threadId&&i.threadId>t?o.classList.add("gengage-chat-bubble--hidden"):o.classList.remove("gengage-chat-bubble--hidden"))}this._shadow?.querySelectorAll("[data-thread-id]").forEach(i=>{i instanceof HTMLElement&&i.dataset.threadId&&i.dataset.threadId>t?i.classList.add("gengage-chat-bubble--hidden"):i instanceof HTMLElement&&i.classList.remove("gengage-chat-bubble--hidden")});const a=this._messages.find(i=>i.role==="assistant"&&i.threadId===t),n=a?this._panel?.restoreForMessage(a.id):!1;n||(this._drawer?.clearPanel(),this._currentPanelSource=null),n&&a&&(this._currentPanelSource=null);const r=this._panel.currentType??"";if(this._panel?.updateTopBar(r),this._drawer?.setPills([]),requestAnimationFrame(()=>{this._drawer?.scrollThreadIntoView(t,"auto")}),this._session?.db&&this.config.session?.sessionId){const i=this.config.session.sessionId;(async()=>{try{const o=await this._session?.db?.loadContext(i,t);o&&(this._lastBackendContext=o.context),await this._session?.db?.deleteContextsAfterThread(i,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="${_e(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,a){return this._session?this._session.loadPayload(t,a):null}async _restoreFromIndexedDB(t){if(!this._session?.db)return;const a=this.config.session?.sessionId;if(!a)return;const n=this.config.session?.userId??"",r=this.config.accountId;if(await this._session.loadFavorites(n,r),this._drawer?.updateFavoritesBadge(this._session.favoritedSkus.size),!t)return;const i=await this._session.db?.loadSession(n,r,a);if(!i||i.messages.length===0)return;const o=this.config.pageContext?.sku;if(o&&i.sku&&i.sku!==o)return;if(this._pdpLaunched=!0,this._drawer?.lockScrollForRestore(),this._currentThreadId=i.currentThreadId,this._lastThreadId=i.lastThreadId,this._currentThreadId&&this._lastThreadId&&this._currentThreadId>this._lastThreadId&&(this._currentThreadId=this._lastThreadId),this._chatCreatedAt=i.createdAt,i.panelThreads&&(this._panel.threads=i.panelThreads),i.thumbnailEntries&&(this._thumbnailEntries=i.thumbnailEntries,this._drawer?.setThumbnails(this._thumbnailEntries)),i.panelSnapshotHtml)for(const[c,l]of Object.entries(i.panelSnapshotHtml)){const g=document.createElement("div");g.innerHTML=Ae(l),this._panel.snapshots.set(c,g)}let s=0;for(const c of i.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),delete l.uiSpec)}}if(s>this._currentMessageId&&(this._currentMessageId=s),this._currentThreadId){let c=await this._session.db?.loadContext(a,this._currentThreadId);c||(c=await this._session.db?.loadLatestContext(a)),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="${_e(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 a=this._buildRenderContext(),n=this._renderPanelFromSource(t.source,a);this._drawer?.setPanelContent(n),this._drawer?.setDividerPreviewEnabled(this._shouldUseDividerPreviewForSource(t.source)),this._currentPanelSource=t.source;const r=this._localPanelHistory.length>0||(this._panel?.threads.length??0)>1;this._drawer?.updatePanelTopBar(r,!1,t.title);return}if(this._isMobileViewport){this._drawer?.hideMobilePanel();return}this._panel?.navigateBack()}_shouldUseDividerPreviewForSpec(t){return t.elements[t.root]?.type==="ProductGrid"}_shouldUseDividerPreviewForSource(t){return t?.kind==="spec"?this._shouldUseDividerPreviewForSpec(t.spec):!1}_toggleComparisonSku(t){if(t==="")this._comparisonSelectMode=!this._comparisonSelectMode,this._comparisonSelectionWarning=null,this._comparisonSelectMode&&(vl(this._currentThreadId??""),this._clearChoicePrompter()),this._comparisonSelectMode||(this._comparisonSelectedSkus=[],this._comparisonSelectionWarning=null,di());else if(this._comparisonSelectedSkus.indexOf(t)>=0)this._comparisonSelectedSkus=this._comparisonSelectedSkus.filter(a=>a!==t),this._comparisonSelectionWarning=null;else{if(this._comparisonSelectedSkus.length>=dt._MAX_COMPARISON_SELECTION){this._comparisonSelectionWarning=this._i18n.compareMaxHint??`You can select up to ${dt._MAX_COMPARISON_SELECTION} products`,this._comparisonRefreshRafId!==null&&cancelAnimationFrame(this._comparisonRefreshRafId),this._comparisonRefreshRafId=requestAnimationFrame(()=>{this._comparisonRefreshRafId=null,this._refreshComparisonUI()});return}this._comparisonSelectedSkus=[...this._comparisonSelectedSkus,t],this._comparisonSelectionWarning=null,li(t)}this._comparisonRefreshRafId!==null&&cancelAnimationFrame(this._comparisonRefreshRafId),this._comparisonRefreshRafId=requestAnimationFrame(()=>{this._comparisonRefreshRafId=null,this._refreshComparisonUI()})}_refreshComparisonUI(){const t=this._shadow?.querySelector(".gengage-chat-panel");if(!t){this._drawer?.setComparisonDockContent(null);return}const a=t.querySelector(".gengage-chat-product-grid-wrapper"),n=a?.querySelector(".gengage-chat-product-grid");if(!a||!n){this._drawer?.setComparisonDockContent(null);return}const r=a.querySelector(".gengage-chat-comparison-toggle-btn");if(r&&r.classList.toggle("gengage-chat-comparison-toggle-btn--active",this._comparisonSelectMode),this._comparisonSelectMode){const i=n.querySelectorAll(".gengage-chat-product-card[data-sku]");for(const o of i){if(o.parentElement?.classList.contains("gengage-chat-comparison-select-wrapper")){const d=o.parentElement,b=this._comparisonSelectedSkus.includes(o.dataset.sku);d.classList.toggle("gengage-chat-comparison-select-wrapper--selected",b);const u=d.querySelector(".gengage-chat-comparison-checkbox");if(u){u.dataset.selected=b?"true":"false",u.setAttribute("aria-pressed",b?"true":"false");const v=u.querySelector(".gengage-chat-comparison-checkbox-icon"),m=u.querySelector(".gengage-chat-comparison-checkbox-label");v&&(v.innerHTML=b?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6L9 17l-5-5"/></svg>':'<span class="gengage-chat-comparison-checkbox-dot"></span>'),m&&(m.textContent=b?this._i18n.comparisonSelectedLabel??"Selected":this._i18n.comparisonSelectLabel??"Select to compare")}continue}const s=o.dataset.sku,c=document.createElement("div");c.className="gengage-chat-comparison-select-wrapper";const l=this._comparisonSelectedSkus.includes(s);l&&c.classList.add("gengage-chat-comparison-select-wrapper--selected");const g=document.createElement("button");g.type="button",g.className="gengage-chat-comparison-checkbox",g.dataset.selected=l?"true":"false",g.setAttribute("aria-pressed",l?"true":"false");const p=document.createElement("span");p.className="gengage-chat-comparison-checkbox-icon",p.innerHTML=l?'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6L9 17l-5-5"/></svg>':'<span class="gengage-chat-comparison-checkbox-dot"></span>';const h=document.createElement("span");h.className="gengage-chat-comparison-checkbox-label",h.textContent=l?this._i18n.comparisonSelectedLabel??"Selected":this._i18n.comparisonSelectLabel??"Select to compare",g.appendChild(p),g.appendChild(h),g.addEventListener("click",d=>{d.stopPropagation(),this._toggleComparisonSku(s)}),o.parentNode.insertBefore(c,o),c.appendChild(g),c.appendChild(o),c.classList.add("gds-clickable"),c.addEventListener("click",d=>{d.target.closest(".gengage-chat-comparison-checkbox")||(d.stopPropagation(),this._toggleComparisonSku(s))})}}else{const i=n.querySelectorAll(".gengage-chat-comparison-select-wrapper");for(const o of i){const s=o.querySelector(".gengage-chat-product-card");s&&o.parentNode&&(o.parentNode.insertBefore(s,o),o.remove())}}if(a.querySelector(".gengage-chat-comparison-floating-btn")?.remove(),this._comparisonSelectMode){const i=dn(this._comparisonSelectedSkus,this._buildRenderContext());this._isMobileViewport?this._drawer?.setComparisonDockContent(i):(this._drawer?.setComparisonDockContent(null),a.appendChild(i))}else this._drawer?.setComparisonDockContent(null)}_clearChoicePrompter(){this._choicePrompterEl?.remove(),this._choicePrompterEl=null,this._shadow?.querySelectorAll(".gengage-chat-choice-prompter").forEach(t=>t.remove())}_mountChoicePrompter(){if(!this._choicePrompterEl)return!1;if(this._isMobileViewport)return this._drawer?.setComparisonDockContent(this._choicePrompterEl),!0;const t=this._shadow?.querySelector(".gengage-chat-panel-float");return t?(t.appendChild(this._choicePrompterEl),!0):(this._choicePrompterEl=null,!1)}_parseAddToCartActionPayload(t){if(typeof t!="object"||t===null)return null;const a=t,n=this._coerceAddToCartString(a.sku),r=this._coerceAddToCartString(a.cartCode??a.cart_code);let i=1;return typeof a.quantity=="number"&&Number.isFinite(a.quantity)&&a.quantity>0&&(i=Math.max(1,Math.floor(a.quantity))),!n||!r?null:{sku:n,cartCode:r,quantity:i}}_coerceAddToCartString(t){return typeof t=="string"&&t.length>0?t:typeof t=="number"&&Number.isFinite(t)?String(t):""}_runChatAddToCartFlow(t){if(this.config.onAddToCart!==void 0)try{const r=this.config.onAddToCart(t);r instanceof Promise&&r.catch(i=>console.error("[gengage] onAddToCart",i))}catch(r){console.error("[gengage] onAddToCart",r)}vi(t.sku,t.quantity);const a={...t,sessionId:this.config.session?.sessionId??null};Te("gengage:chat:add-to-cart",a),this._bridge?.send("addToCart",t),this._runEventCallbacks("gengage-cart-add",a),this.track(Kr(this.analyticsContext(),{attribution_source:"chat",attribution_action_id:crypto.randomUUID(),cart_value:0,currency:this.config.pricing?.currencyCode??"TRY",line_items:t.quantity,sku:t.sku})),this._sendAction({title:this._i18n.addToCartButton??"Add to Cart",type:"addToCart",payload:{sku:t.sku,cart_code:t.cartCode,quantity:t.quantity}},{preservePanel:!0});const n=this._i18n.addedToCartToast??"Added to cart";this._drawer?.showCartToast(n),this._drawer?.flashCartBadge()}_buildRenderContext(){const t={locale:wt(this.config.locale),onAction:a=>{if(si(a.title,a.type),a.type==="addToCart"){const r=this._parseAddToCartActionPayload(a.payload);if(r){this._runChatAddToCartFlow(r);return}}if(a.type==="launchSingleProduct"){this._drawer?.setDividerPreviewEnabled(!1);const r=typeof a.payload=="object"&&a.payload!==null&&"sku"in a.payload?a.payload.sku:void 0,i=this._coerceSkuKey(r),o=this._activeSkuForProductSummaryClick();if(i&&o&&i===o)return;i&&Ta(i,a.title)}if(a.type==="findSimilar"){const r=typeof a.payload=="object"&&a.payload!==null&&"sku"in a.payload?String(a.payload.sku):"";ci(r)}if(a.type==="getComparisonTable"){const r=a.payload,i=r&&typeof r=="object"?r:null,o=i&&typeof i.gengage_analytics_source=="string"?i.gengage_analytics_source:"";let s=[];i&&Array.isArray(i.sku_list)&&(s=i.sku_list.filter(c=>typeof c=="string")),o==="floating_compare_dock"?fi(s):gi(s.length>0?s:this._comparisonSelectedSkus)}const n=a.type==="addToCart"||a.type==="like";this._sendAction(a,n?{preservePanel:!0}:void 0)},onProductClick:a=>{const n=this.config.isDemoWebsite!==!0&&this._isSameOriginUrl(a.url);if(!n){const r=this._coerceSkuKey(a.sku),i=this._activeSkuForProductSummaryClick();if(r&&i&&r===i)return}if(n)Te("gengage:similar:product-click",{sku:a.sku,url:a.url,sessionId:this.config.session?.sessionId??null,...a.name!==void 0&&a.name!==""?{productName:a.name}:{}}),this._saveSessionAndOpenURL(a.url);else{Ta(a.sku);const r=a.name?.trim()?a.name.trim():a.sku;this._sendAction({title:r,type:"launchSingleProduct",payload:{sku:a.sku}})}},onAddToCart:a=>{this._runChatAddToCartFlow(a)},onProductSelect:a=>{const n=this._productSkuKey(a),r=this._activeSkuForProductSummaryClick();if(n&&r&&n===r)return;if(this._currentPanelSource){const l=this._drawer?.getPanelTopBarTitle()??"";this._localPanelHistory.push({source:this._currentPanelSource,title:l}),this._localPanelHistory.length>dt._MAX_PANEL_HISTORY&&this._localPanelHistory.shift()}const i=this._buildRenderContext(),o={root:"root",elements:{root:{type:"ProductSummaryCard",props:{product:a}}}},s=this._shadow?.querySelector(".gengage-chat-messages");if(s){const l=this._renderUISpec(o,i);this._currentThreadId&&(l.dataset.threadId=this._currentThreadId),s.appendChild(l),this._scrollInlineIntoView(l,this._currentThreadId),this._drawer?.refreshPresentationCollapsed()}if(this.config.productDetailsExtended!==!0){this._clearAssistantPanelLikeStreamClearPanel();return}const c={root:"root",elements:{root:{type:"ProductDetailsPanel",props:{product:a}}}};this._drawer?.setPanelContent(this._renderUISpec(c,t)),this._drawer?.setDividerPreviewEnabled(!1),this._currentPanelSource={kind:"spec",spec:c},this._panel&&(this._panel.currentType="ProductDetailsPanel"),this._drawer?.updatePanelTopBar(!0,!1,this._i18n.panelTitleProductDetails)},i18n:this._i18n,pricing:this.config.pricing,productPriceUi:this.config.productPriceUi,hideProductDiscountBadge:this.config.hideProductDiscountBadge,hideUserReviews:this.config.hideUserReviews,hideStockStatus:this.config.hideStockStatus,productSort:this._productSort,onSortChange:a=>{this._productSort=a},comparisonSelectMode:this._comparisonSelectMode,comparisonSelectedSkus:this._comparisonSelectedSkus,comparisonMaxSelection:dt._MAX_COMPARISON_SELECTION,comparisonSelectionWarning:this._comparisonSelectionWarning,onToggleComparisonSku:a=>{this._toggleComparisonSku(a)},favoritedSkus:this._session?.favoritedSkus??new Set,onFavoriteToggle:(a,n)=>{this._toggleProductFavorite(a,n)},isMobile:this._isMobileViewport};return t}async _toggleFavorite(t,a){if(!this._session)return;const n=this.config.session?.userId??"",r=this.config.accountId;await this._session.toggleFavorite(n,r,t,a),this._drawer?.updateFavoritesBadge(this._session.favoritedSkus.size)}_revertFavoriteHeartUi(t){const a=this._shadow?.querySelectorAll(`[data-gengage-favorite-sku="${_e(t)}"]`);if(a?.length)for(const n of a){if(!(n instanceof HTMLButtonElement))continue;n.classList.toggle("gengage-chat-favorite-btn--active");const r=n.querySelector("svg");r&&r.setAttribute("fill",n.classList.contains("gengage-chat-favorite-btn--active")?"currentColor":"none")}}async _toggleProductFavorite(t,a){const n=!(this._session?.favoritedSkus.has(t)??!1),r={sku:t,product:a,favorited:n,sessionId:this.config.session?.sessionId??null};Te("gengage:chat:product-favorite",r),this._bridge?.send("productFavorite",r);const i=this._eventCallbacks.get("gengage-product-favorite");if(i&&i.size>0){for(const o of i)try{const s=o(r);if((s instanceof Promise?await s:s)===!1){this._revertFavoriteHeartUi(t),this._handleCallbackFailure("gengage-product-favorite",r);return}}catch{this._revertFavoriteHeartUi(t),this._handleCallbackFailure("gengage-product-favorite",r);return}this._session&&(n?this._session.favoritedSkus.add(t):this._session.favoritedSkus.delete(t),this._drawer?.updateFavoritesBadge(this._session.favoritedSkus.size));return}if(await this._toggleFavorite(t,a),n){hi(t);const o=a.name??t;this._sendAction({title:o,type:"like",payload:{sku:t}},{preservePanel:!0})}}_openFavoritesPanel(){if(this._drawer){if(this._currentPanelSource){const t=this._drawer.getPanelTopBarTitle()??"";this._localPanelHistory.push({source:this._currentPanelSource,title:t}),this._localPanelHistory.length>dt._MAX_PANEL_HISTORY&&this._localPanelHistory.shift()}this._drawer.setPanelContent(this._buildFavoritesPageEl()),this._drawer.setDividerPreviewEnabled(!1),this._currentPanelSource={kind:"favorites"},this._drawer.updatePanelTopBar(!0,!1,this._i18n.favoritesPageTitle)}}_buildFavoritesPageEl(){const t=this._session?.getFavoriteProducts()??[];if(t.length===0){const i=document.createElement("div");i.className="gengage-chat-favorites-empty";const o=document.createElement("div");o.className="gengage-chat-favorites-empty-icon",o.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>',i.appendChild(o);const s=document.createElement("p");return s.textContent=this._i18n.emptyFavoritesMessage,i.appendChild(s),i}const a={},n=[];for(const[i,o]of t.entries()){const s=`card_${i}`;n.push(s),a[s]={type:"ProductCard",props:{product:{sku:o.sku,name:o.name,imageUrl:o.imageUrl,price:o.price}}}}a.grid={type:"ProductGrid",children:n};const r={root:"grid",elements:a};return this._renderUISpec(r,this._buildRenderContext())}async _runEventCallbacks(t,a){const n=this._eventCallbacks.get(t);if(!(!n||n.size===0))for(const r of n)try{const i=r(a);if((i instanceof Promise?await i:i)===!1){this._handleCallbackFailure(t,a);return}}catch{this._handleCallbackFailure(t,a);return}}_handleCallbackFailure(t,a){if(t==="gengage-cart-add"){const n=this._i18n.cartAddErrorMessage,r=this._createMessage("assistant",n);this._currentThreadId&&(r.threadId=this._currentThreadId),this._messages.push(r),this._drawer?.addMessage(r)}if(t==="gengage-product-favorite"){const n=this._i18n.favoriteToggleErrorMessage,r=this._createMessage("assistant",n);this._currentThreadId&&(r.threadId=this._currentThreadId),this._messages.push(r),this._drawer?.addMessage(r)}}_restoreInlineUISpec(t){if(!t.uiSpec||!this._drawer)return;const a=t.uiSpec,n=a.elements[a.root];if(!n)return;const r=n.type;if(r==="ActionButtons"||r==="ComparisonTable"||Ea(n))return;const i=this._buildRenderContext(),o=this._shadow?.querySelector(".gengage-chat-messages");if(!o)return;if(r==="ProductDetailsPanel"){const c=n.props?.product;if(!c)return;const l={root:"root",elements:{root:{type:"ProductSummaryCard",props:{product:c}}}},g=this._renderUISpec(l,i);t.threadId&&(g.dataset.threadId=t.threadId),o.appendChild(g),this._drawer?.refreshPresentationCollapsed();return}const s=this._renderUISpec(a,i);t.threadId&&(s.dataset.threadId=t.threadId),o.appendChild(s),this._drawer?.refreshPresentationCollapsed()}_createMessage(t,a){return this._currentMessageId++,{id:`msg-${this._currentMessageId}`,role:t,content:a,timestamp:Date.now(),status:"done"}}_resolveI18n(t){return{...is(t.locale),...t.i18n}}_resolveUISpecRegistry(){return Fr(hn(),this.config.renderer?.registry)}_renderUISpec(t,a){const n=this._resolveUISpecRegistry(),r=this.config.renderer?.unknownRenderer??ea,i=(s,c)=>un(s,c,n,r),o=this.config.renderer?.renderUISpec;return o?o(t,a,{registry:n,unknownRenderer:r,defaultRender:i}):i(t,a)}};function $u(){return new Rr}Ee.CHAT_SCROLL_ELEMENT_ID=kt,Ee.ChatPresentationState=zn,Ee.GengageChat=Rr,Ee.chatCatalog=Ou,Ee.createChatWidget=$u,Ee.createDefaultChatUISpecRegistry=hn,Ee.defaultChatUnknownUISpecRenderer=ea,Ee.getChatScrollElement=as,Ee.invalidateChatScrollCache=Ga,Ee.isSimilarsAppendGrid=Ea,Ee.renderUISpec=un})(this.Gengage=this.Gengage||{});
|