@gengage/assistant-fe 0.2.6 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/assistant-fe.css +1 -1
  2. package/dist/chat/components/ChatDrawer.d.ts.map +1 -1
  3. package/dist/chat/components/ComparisonTable.d.ts.map +1 -1
  4. package/dist/chat/index.d.ts.map +1 -1
  5. package/dist/chat/types.d.ts +12 -0
  6. package/dist/chat/types.d.ts.map +1 -1
  7. package/dist/chat.cjs +1 -1
  8. package/dist/chat.iife.js +21 -21
  9. package/dist/chat.iife.js.map +1 -1
  10. package/dist/chat.js +2 -2
  11. package/dist/common/theme-utils.d.ts.map +1 -1
  12. package/dist/common.cjs +1 -1
  13. package/dist/common.cjs.map +1 -1
  14. package/dist/common.js +30 -28
  15. package/dist/common.js.map +1 -1
  16. package/dist/{index-BeP3ETm1.cjs → index-BAQXPosE.cjs} +2 -2
  17. package/dist/{index-BeP3ETm1.cjs.map → index-BAQXPosE.cjs.map} +1 -1
  18. package/dist/index-CUBMZpGs.js +5111 -0
  19. package/dist/index-CUBMZpGs.js.map +1 -0
  20. package/dist/index-Dco2Aw73.cjs +13 -0
  21. package/dist/index-Dco2Aw73.cjs.map +1 -0
  22. package/dist/{index-ZO_kMfUR.js → index-DvSU2I9u.js} +3 -3
  23. package/dist/{index-ZO_kMfUR.js.map → index-DvSU2I9u.js.map} +1 -1
  24. package/dist/index.cjs +1 -1
  25. package/dist/index.js +3 -3
  26. package/dist/native.cjs +1 -1
  27. package/dist/native.iife.js +21 -21
  28. package/dist/native.iife.js.map +1 -1
  29. package/dist/native.js +1 -1
  30. package/dist/qna.cjs +1 -1
  31. package/dist/qna.css +1 -1
  32. package/dist/qna.iife.js +1 -1
  33. package/dist/qna.iife.js.map +1 -1
  34. package/dist/qna.js +1 -1
  35. package/dist/{schemas-DR_GaPQj.js → schemas-5lXjLjwW.js} +4 -4
  36. package/dist/schemas-5lXjLjwW.js.map +1 -0
  37. package/dist/{schemas-CaaT5BuE.cjs → schemas-DqUVzVDf.cjs} +2 -2
  38. package/dist/schemas-DqUVzVDf.cjs.map +1 -0
  39. package/dist/simrel.cjs +1 -1
  40. package/dist/simrel.css +1 -1
  41. package/dist/simrel.iife.js +1 -1
  42. package/dist/simrel.iife.js.map +1 -1
  43. package/dist/simrel.js +1 -1
  44. package/package.json +2 -2
  45. package/dist/index-BLq9Phmq.js +0 -5101
  46. package/dist/index-BLq9Phmq.js.map +0 -1
  47. package/dist/index-BwBJkYGY.cjs +0 -13
  48. package/dist/index-BwBJkYGY.cjs.map +0 -1
  49. package/dist/schemas-CaaT5BuE.cjs.map +0 -1
  50. package/dist/schemas-DR_GaPQj.js.map +0 -1
package/dist/native.js CHANGED
@@ -1,4 +1,4 @@
1
- import { D as i, b as t, e as s, g as r, j as v } from "./index-ZO_kMfUR.js";
1
+ import { D as i, b as t, e as s, g as r, j as v } from "./index-DvSU2I9u.js";
2
2
  export {
3
3
  i as DEFAULT_NATIVE_TRACKED_EVENTS,
4
4
  t as applyNativeSession,
package/dist/qna.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./schemas-CaaT5BuE.cjs");async function q(n,e,t){const i=s.buildChatEndpointUrl("launcher_action",e),o={uiSpecs:[],actions:[]},r={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)};t!==void 0&&(r.signal=t);const a=await fetch(i,r);if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);const c={onEvent:l=>{const u=s.adaptBackendEvent(l);if(u&&(u.type==="ui_spec"&&o.uiSpecs.push(u.spec),u.type==="ui_spec"&&u.spec.elements)){for(const h of Object.values(u.spec.elements))if(h.type==="ActionButton"&&h.props?.action){const p=h.props.action;o.actions.push(p)}}}};return t!==void 0&&(c.signal=t),await s.consumeStream(a,c),o}function m(n){const e=document.createElement("div");e.className="gengage-qna-buttons",e.setAttribute("role","group"),e.setAttribute("aria-label",n.quickQuestionsAriaLabel??"Quick questions"),n.orientation==="vertical"&&(e.style.flexDirection="column");for(const t of n.actions){const i=document.createElement("button");i.className="gengage-qna-button",i.textContent=t.title,i.type="button",i.addEventListener("click",()=>{const o={title:t.title,type:t.type};t.payload!==void 0&&(o.payload=t.payload),n.onAction(o)}),e.appendChild(i)}if(n.ctaText||n.onOpenChat){const t=document.createElement("button");t.className="gengage-qna-cta",t.textContent=n.ctaText??n.defaultCtaText??"Ask something else",t.type="button",t.addEventListener("click",()=>{n.onOpenChat?.()}),e.appendChild(t)}return e}function w(n){const e=document.createElement("div");e.className="gengage-qna-input-wrapper";const t=document.createElement("input");t.type="text",t.className="gengage-qna-input",t.setAttribute("aria-label",n.askQuestionAriaLabel??"Ask a question");const i=Array.isArray(n.placeholders)?n.placeholders:n.placeholders?[n.placeholders]:[n.defaultInputPlaceholder??"Ask a question..."];let o=0;t.placeholder=i[0]??"";let r=null,a=null;i.length>1&&(r=setInterval(()=>{t.classList.add("gengage-qna-input--fade"),a=setTimeout(()=>{o=(o+1)%i.length,t.placeholder=i[o]??"",t.classList.remove("gengage-qna-input--fade")},180)},3e3));const c=document.createElement("button");c.className="gengage-qna-send",c.type="button",c.textContent=n.ctaLabel??n.sendButtonText??"Ask",c.setAttribute("aria-label",n.sendQuestionAriaLabel??"Send question");const l=()=>{const u=t.value.trim();u&&(n.onSubmit({title:u,type:"user_message",payload:u}),t.value="")};return c.addEventListener("click",l),t.addEventListener("keydown",u=>{u.key==="Enter"&&(u.preventDefault(),l())}),e.appendChild(t),e.appendChild(c),e._cleanup=()=>{r&&clearInterval(r),a&&clearTimeout(a)},e}function _(n,e){if(!n||typeof n!="object")return null;const t=n,i=t.type;if(typeof i!="string"||i.length===0)return null;const o=t.title,r=t.payload,a=typeof o=="string"&&o.length>0?o:e;if(!a)return null;const c={title:a,type:i};return r!==void 0&&(c.payload=r),c}function A(n){const e={title:n.title,type:n.type};return n.payload!==void 0&&(e.payload=n.payload),e}function T(n,e){const t=[],i=n.props?.actions;if(Array.isArray(i))for(const a of i){const c=_(a);c&&t.push(c)}const o=n.props?.buttons;if(Array.isArray(o))for(const a of o){if(!a||typeof a!="object")continue;const c=a,l=typeof c.label=="string"?c.label:void 0,u=_(c.action,l);u&&t.push(u)}if(n.children)for(const a of n.children){const c=e.elements[a];if(!c||c.type!=="ActionButton")continue;const l=typeof c.props?.label=="string"?c.props.label:void 0,u=_(c.props?.action,l);u&&t.push(u)}const r=new Set;return t.filter(a=>r.has(a.title)?!1:(r.add(a.title),!0))}const C={ButtonRow:({element:n,spec:e,context:t})=>{const i=T(n,e).map(A),o=n.props?.orientation,r={actions:i,onAction:t.onAction,defaultCtaText:t.i18n.defaultCtaText,quickQuestionsAriaLabel:t.i18n.quickQuestionsAriaLabel};return t.onOpenChat!==void 0&&(r.onOpenChat=t.onOpenChat),t.ctaText!==void 0&&(r.ctaText=t.ctaText),(o==="horizontal"||o==="vertical")&&(r.orientation=o),m(r)},ActionButtons:({element:n,spec:e,context:t})=>{const o={actions:T(n,e).map(A),onAction:t.onAction,defaultCtaText:t.i18n.defaultCtaText,quickQuestionsAriaLabel:t.i18n.quickQuestionsAriaLabel};return t.onOpenChat!==void 0&&(o.onOpenChat=t.onOpenChat),t.ctaText!==void 0&&(o.ctaText=t.ctaText),m(o)},ActionButton:({element:n,context:e})=>{const t=document.createElement("button");t.className="gengage-qna-button",t.type="button";const i=n.props?.label;typeof i=="string"?t.textContent=i:t.textContent=e.i18n.defaultCtaText;const o=_(n.props?.action,typeof i=="string"?i:void 0);return o&&t.addEventListener("click",()=>e.onAction(o)),t},TextInput:({element:n,context:e})=>{const t=n.props?.placeholder,i=typeof t=="string"||Array.isArray(t)?t:e.inputPlaceholder,o=typeof n.props?.ctaLabel=="string"?n.props.ctaLabel:void 0,r={onSubmit:e.onAction,askQuestionAriaLabel:e.i18n.askQuestionAriaLabel,defaultInputPlaceholder:e.i18n.defaultInputPlaceholder,sendButtonText:e.i18n.sendButton,sendQuestionAriaLabel:e.i18n.sendQuestionAriaLabel};return i!==void 0&&(r.placeholders=i),o!==void 0&&(r.ctaLabel=o),w(r)},QuestionHeading:({element:n})=>{const e=document.createElement("h3");e.className="gengage-qna-heading";const t=n.props?.text;return e.textContent=typeof t=="string"?t:"",e},ProductCard:()=>null},y=({element:n,renderElement:e})=>{if(!n.children||n.children.length===0)return null;const t=document.createElement("div");for(const i of n.children){const o=e(i);o&&t.appendChild(o)}return t};function E(){return{...C}}function I(n,e,t=C,i=y){return s.renderUISpecWithRegistry({spec:n,context:e,registry:t,containerClassName:"gengage-qna-uispec",unknownRenderer:i})}const S={quickQuestionsAriaLabel:"Hızlı sorular",askQuestionAriaLabel:"Soru sorun",defaultInputPlaceholder:"Bir soru sorun...",sendButton:"Sor",sendQuestionAriaLabel:"Soruyu gönder",defaultCtaText:"Başka bir şey sor"},Q={quickQuestionsAriaLabel:"Quick questions",askQuestionAriaLabel:"Ask a question",defaultInputPlaceholder:"Ask a question...",sendButton:"Ask",sendQuestionAriaLabel:"Send question",defaultCtaText:"Ask something else"};function x(n){return n?n.toLowerCase().split("-")[0]??"tr":"tr"}function L(n){return x(n)==="en"?Q:S}const R=s.object({title:s.string(),type:s.string(),payload:s.unknown().optional()}),N=s.object({label:s.string(),action:R,variant:s._enum(["primary","outline","ghost"]).optional()}),P=s.object({orientation:s._enum(["horizontal","vertical"]).optional(),wrap:s.boolean().optional()}),B=s.object({placeholder:s.union([s.string(),s.array(s.string())]).optional(),ctaLabel:s.string().optional()}),U=s.object({text:s.string()}),O={components:{ActionButton:{schema:N,description:"A single clickable QNA action button."},ButtonRow:{schema:P,description:"Container for a group of QNA action buttons."},TextInput:{schema:B,description:"Free-text input with rotating placeholder and CTA button."},QuestionHeading:{schema:U,description:"A heading displayed above the QNA button group."}}};class v extends s.BaseWidget{constructor(){super(...arguments),this._abortController=null,this._debounceTimer=null,this._contentEl=null,this._i18n=S,this._actionHandler=this._handleAction.bind(this),this._openChatHandler=this._handleOpenChat.bind(this)}async onInit(e){this._i18n=this._resolveI18n(e),this._contentEl=document.createElement("div"),this._contentEl.className="gengage-qna-container",this.root.appendChild(this._contentEl);const t=e.pageContext?.sku;t&&(this._lastSku=t,await this._fetchAndRender(t)),s.trackInit("qna")}onUpdate(e){const t=e.sku;!t||t===this._lastSku||(this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._debounceTimer=null,this._lastSku=t,this._fetchAndRender(t)},50))}onShow(){this._contentEl&&(this._contentEl.style.opacity="0",this._contentEl.style.transition="opacity 0.2s ease-in",requestAnimationFrame(()=>{this._contentEl&&(this._contentEl.style.opacity="1")}))}onHide(){}onDestroy(){this._abort(),this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null),this._contentEl&&(this._cleanupTextInputTimers(),this._contentEl.remove(),this._contentEl=null)}_abort(){this._abortController?.abort(),this._abortController=null}_cleanupTextInputTimers(){if(!this._contentEl)return;const e=this._contentEl.querySelectorAll(".gengage-qna-input-wrapper");for(const t of e)t._cleanup?.()}async _fetchAndRender(e){if(this._abort(),this._abortController=new AbortController,!this._contentEl)return;this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const t=this._createLoadingIndicator();this._contentEl.appendChild(t);const i={middlewareUrl:this.config.middlewareUrl},o=crypto.randomUUID(),r=Date.now();this.track(s.streamStartEvent(this.analyticsContext(),{endpoint:"launcher_action",request_id:o,widget:"qna"}));try{const a={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",sku:e,locale:this.config.locale??"tr"},c=this.config.pageContext?.pageType;c!==void 0&&(a.page_type=c);const l=await q(a,i,this._abortController.signal);if(this.track(s.streamDoneEvent(this.analyticsContext(),{request_id:o,latency_ms:Date.now()-r,chunk_count:l.actions.length,widget:"qna"})),this.track(s.widgetHistorySnapshotEvent(this.analyticsContext(),{message_count:l.actions.length,history_ref:o,redaction_level:"none",widget:"qna"})),!this._contentEl)return;if(this._contentEl.innerHTML="",!this._specIncludesType(l.uiSpecs,"QuestionHeading")&&this.config.showStaticQuestion&&this.config.staticQuestionText){const d=document.createElement("h3");d.className="gengage-qna-heading",d.textContent=this.config.staticQuestionText,this._contentEl.appendChild(d)}const h=this.config.inputPlaceholder;let p;if(h!==!0)p=h??this._i18n.defaultInputPlaceholder;else if(l.actions.length>0){const d=l.actions.filter(f=>f.type==="user_message"||f.title.includes("?")).map(f=>f.title);p=d.length>0?d:this._i18n.defaultInputPlaceholder}else p=this._i18n.defaultInputPlaceholder;const g={onAction:this._actionHandler,i18n:this._i18n};this.config.hideButtonRowCta||(g.onOpenChat=this._openChatHandler,this.config.ctaText!==void 0&&(g.ctaText=this.config.ctaText)),p!==void 0&&(g.inputPlaceholder=p);const k=this._buildFallbackActionsSpec(l.actions),b=(l.uiSpecs.length>0?l.uiSpecs:[k]).filter(d=>Object.keys(d.elements).length>0);for(const d of b){const f=this._renderUISpec(d,g);this._contentEl.appendChild(f)}b.length>0&&s.trackShow("qna"),!this._specIncludesType(b,"TextInput")&&this._appendStandaloneInput(g,p)}catch(a){if(a instanceof DOMException&&a.name==="AbortError")return;if(s.dispatch("gengage:global:error",{source:"qna",code:"FETCH_ERROR",message:s.getGlobalErrorMessage(this.config.locale)}),this.track(s.streamErrorEvent(this.analyticsContext(),{request_id:o,error_code:"FETCH_ERROR",error_message:a instanceof Error?a.message:String(a),widget:"qna"})),this._contentEl){this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const c=this.config.inputPlaceholder===!0?this._i18n.defaultInputPlaceholder:this.config.inputPlaceholder??this._i18n.defaultInputPlaceholder,l={onAction:this._actionHandler,i18n:this._i18n,onOpenChat:this._openChatHandler};this.config.ctaText!==void 0&&(l.ctaText=this.config.ctaText),this._appendStandaloneInput(l,c)}}}_createLoadingIndicator(){const e=document.createElement("div");e.className="gengage-qna-loading";for(let t=0;t<3;t++){const i=document.createElement("div");i.className="gengage-qna-loading-dot",e.appendChild(i)}return e}_resolveI18n(e){return{...L(e.locale),...e.i18n}}_resolveUISpecRegistry(){const e=E();return s.mergeUISpecRegistry(e,this.config.renderer?.registry)}_renderUISpec(e,t){const i=this._resolveUISpecRegistry(),o=this.config.renderer?.unknownRenderer??y,r=(l,u)=>I(l,u,i,o),a=this.config.renderer?.renderUISpec;return a?a(e,t,{registry:i,unknownRenderer:o,defaultRender:r}):r(e,t)}_specIncludesType(e,t){for(const i of e)for(const o of Object.values(i.elements))if(o.type===t)return!0;return!1}_buildFallbackActionsSpec(e){if(e.length===0)return{root:"root",elements:{}};const t={},i=[];for(let o=0;o<e.length;o++){const r=e[o],a=`action-${o}`;i.push(a),t[a]={type:"ActionButton",props:{label:r.title,action:{title:r.title,type:r.type,payload:r.payload}}}}return t.root={type:"ButtonRow",children:i},{root:"root",elements:t}}_appendStandaloneInput(e,t){if(!this._contentEl)return;const i={root:"root",elements:{root:{type:"TextInput",props:{placeholder:t}}}},o=this._renderUISpec(i,e);this._contentEl.appendChild(o)}_handleAction(e){s.trackSuggestedQuestion(e.title,e.type),this.config.onActionSelected?.(e),s.dispatch("gengage:qna:action",e)}_handleOpenChat(){const e=this._contentEl?.querySelector(".gengage-qna-input");e&&e.focus(),this.config.onOpenChat?.(),s.dispatch("gengage:qna:open-chat",{})}}function H(){return new v}exports.GengageQNA=v;exports.createDefaultQnaUISpecRegistry=E;exports.createQNAWidget=H;exports.defaultQnaUnknownUISpecRenderer=y;exports.qnaCatalog=O;exports.renderQnaUISpec=I;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./schemas-DqUVzVDf.cjs");async function q(n,e,t){const i=s.buildChatEndpointUrl("launcher_action",e),o={uiSpecs:[],actions:[]},r={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)};t!==void 0&&(r.signal=t);const a=await fetch(i,r);if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);const c={onEvent:l=>{const u=s.adaptBackendEvent(l);if(u&&(u.type==="ui_spec"&&o.uiSpecs.push(u.spec),u.type==="ui_spec"&&u.spec.elements)){for(const h of Object.values(u.spec.elements))if(h.type==="ActionButton"&&h.props?.action){const p=h.props.action;o.actions.push(p)}}}};return t!==void 0&&(c.signal=t),await s.consumeStream(a,c),o}function m(n){const e=document.createElement("div");e.className="gengage-qna-buttons",e.setAttribute("role","group"),e.setAttribute("aria-label",n.quickQuestionsAriaLabel??"Quick questions"),n.orientation==="vertical"&&(e.style.flexDirection="column");for(const t of n.actions){const i=document.createElement("button");i.className="gengage-qna-button",i.textContent=t.title,i.type="button",i.addEventListener("click",()=>{const o={title:t.title,type:t.type};t.payload!==void 0&&(o.payload=t.payload),n.onAction(o)}),e.appendChild(i)}if(n.ctaText||n.onOpenChat){const t=document.createElement("button");t.className="gengage-qna-cta",t.textContent=n.ctaText??n.defaultCtaText??"Ask something else",t.type="button",t.addEventListener("click",()=>{n.onOpenChat?.()}),e.appendChild(t)}return e}function w(n){const e=document.createElement("div");e.className="gengage-qna-input-wrapper";const t=document.createElement("input");t.type="text",t.className="gengage-qna-input",t.setAttribute("aria-label",n.askQuestionAriaLabel??"Ask a question");const i=Array.isArray(n.placeholders)?n.placeholders:n.placeholders?[n.placeholders]:[n.defaultInputPlaceholder??"Ask a question..."];let o=0;t.placeholder=i[0]??"";let r=null,a=null;i.length>1&&(r=setInterval(()=>{t.classList.add("gengage-qna-input--fade"),a=setTimeout(()=>{o=(o+1)%i.length,t.placeholder=i[o]??"",t.classList.remove("gengage-qna-input--fade")},180)},3e3));const c=document.createElement("button");c.className="gengage-qna-send",c.type="button",c.textContent=n.ctaLabel??n.sendButtonText??"Ask",c.setAttribute("aria-label",n.sendQuestionAriaLabel??"Send question");const l=()=>{const u=t.value.trim();u&&(n.onSubmit({title:u,type:"user_message",payload:u}),t.value="")};return c.addEventListener("click",l),t.addEventListener("keydown",u=>{u.key==="Enter"&&(u.preventDefault(),l())}),e.appendChild(t),e.appendChild(c),e._cleanup=()=>{r&&clearInterval(r),a&&clearTimeout(a)},e}function _(n,e){if(!n||typeof n!="object")return null;const t=n,i=t.type;if(typeof i!="string"||i.length===0)return null;const o=t.title,r=t.payload,a=typeof o=="string"&&o.length>0?o:e;if(!a)return null;const c={title:a,type:i};return r!==void 0&&(c.payload=r),c}function A(n){const e={title:n.title,type:n.type};return n.payload!==void 0&&(e.payload=n.payload),e}function T(n,e){const t=[],i=n.props?.actions;if(Array.isArray(i))for(const a of i){const c=_(a);c&&t.push(c)}const o=n.props?.buttons;if(Array.isArray(o))for(const a of o){if(!a||typeof a!="object")continue;const c=a,l=typeof c.label=="string"?c.label:void 0,u=_(c.action,l);u&&t.push(u)}if(n.children)for(const a of n.children){const c=e.elements[a];if(!c||c.type!=="ActionButton")continue;const l=typeof c.props?.label=="string"?c.props.label:void 0,u=_(c.props?.action,l);u&&t.push(u)}const r=new Set;return t.filter(a=>r.has(a.title)?!1:(r.add(a.title),!0))}const C={ButtonRow:({element:n,spec:e,context:t})=>{const i=T(n,e).map(A),o=n.props?.orientation,r={actions:i,onAction:t.onAction,defaultCtaText:t.i18n.defaultCtaText,quickQuestionsAriaLabel:t.i18n.quickQuestionsAriaLabel};return t.onOpenChat!==void 0&&(r.onOpenChat=t.onOpenChat),t.ctaText!==void 0&&(r.ctaText=t.ctaText),(o==="horizontal"||o==="vertical")&&(r.orientation=o),m(r)},ActionButtons:({element:n,spec:e,context:t})=>{const o={actions:T(n,e).map(A),onAction:t.onAction,defaultCtaText:t.i18n.defaultCtaText,quickQuestionsAriaLabel:t.i18n.quickQuestionsAriaLabel};return t.onOpenChat!==void 0&&(o.onOpenChat=t.onOpenChat),t.ctaText!==void 0&&(o.ctaText=t.ctaText),m(o)},ActionButton:({element:n,context:e})=>{const t=document.createElement("button");t.className="gengage-qna-button",t.type="button";const i=n.props?.label;typeof i=="string"?t.textContent=i:t.textContent=e.i18n.defaultCtaText;const o=_(n.props?.action,typeof i=="string"?i:void 0);return o&&t.addEventListener("click",()=>e.onAction(o)),t},TextInput:({element:n,context:e})=>{const t=n.props?.placeholder,i=typeof t=="string"||Array.isArray(t)?t:e.inputPlaceholder,o=typeof n.props?.ctaLabel=="string"?n.props.ctaLabel:void 0,r={onSubmit:e.onAction,askQuestionAriaLabel:e.i18n.askQuestionAriaLabel,defaultInputPlaceholder:e.i18n.defaultInputPlaceholder,sendButtonText:e.i18n.sendButton,sendQuestionAriaLabel:e.i18n.sendQuestionAriaLabel};return i!==void 0&&(r.placeholders=i),o!==void 0&&(r.ctaLabel=o),w(r)},QuestionHeading:({element:n})=>{const e=document.createElement("h3");e.className="gengage-qna-heading";const t=n.props?.text;return e.textContent=typeof t=="string"?t:"",e},ProductCard:()=>null},y=({element:n,renderElement:e})=>{if(!n.children||n.children.length===0)return null;const t=document.createElement("div");for(const i of n.children){const o=e(i);o&&t.appendChild(o)}return t};function E(){return{...C}}function I(n,e,t=C,i=y){return s.renderUISpecWithRegistry({spec:n,context:e,registry:t,containerClassName:"gengage-qna-uispec",unknownRenderer:i})}const S={quickQuestionsAriaLabel:"Hızlı sorular",askQuestionAriaLabel:"Soru sorun",defaultInputPlaceholder:"Bir soru sorun...",sendButton:"Sor",sendQuestionAriaLabel:"Soruyu gönder",defaultCtaText:"Başka bir şey sor"},Q={quickQuestionsAriaLabel:"Quick questions",askQuestionAriaLabel:"Ask a question",defaultInputPlaceholder:"Ask a question...",sendButton:"Ask",sendQuestionAriaLabel:"Send question",defaultCtaText:"Ask something else"};function x(n){return n?n.toLowerCase().split("-")[0]??"tr":"tr"}function L(n){return x(n)==="en"?Q:S}const R=s.object({title:s.string(),type:s.string(),payload:s.unknown().optional()}),N=s.object({label:s.string(),action:R,variant:s._enum(["primary","outline","ghost"]).optional()}),P=s.object({orientation:s._enum(["horizontal","vertical"]).optional(),wrap:s.boolean().optional()}),B=s.object({placeholder:s.union([s.string(),s.array(s.string())]).optional(),ctaLabel:s.string().optional()}),U=s.object({text:s.string()}),O={components:{ActionButton:{schema:N,description:"A single clickable QNA action button."},ButtonRow:{schema:P,description:"Container for a group of QNA action buttons."},TextInput:{schema:B,description:"Free-text input with rotating placeholder and CTA button."},QuestionHeading:{schema:U,description:"A heading displayed above the QNA button group."}}};class v extends s.BaseWidget{constructor(){super(...arguments),this._abortController=null,this._debounceTimer=null,this._contentEl=null,this._i18n=S,this._actionHandler=this._handleAction.bind(this),this._openChatHandler=this._handleOpenChat.bind(this)}async onInit(e){this._i18n=this._resolveI18n(e),this._contentEl=document.createElement("div"),this._contentEl.className="gengage-qna-container",this.root.appendChild(this._contentEl);const t=e.pageContext?.sku;t&&(this._lastSku=t,await this._fetchAndRender(t)),s.trackInit("qna")}onUpdate(e){const t=e.sku;!t||t===this._lastSku||(this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._debounceTimer=null,this._lastSku=t,this._fetchAndRender(t)},50))}onShow(){this._contentEl&&(this._contentEl.style.opacity="0",this._contentEl.style.transition="opacity 0.2s ease-in",requestAnimationFrame(()=>{this._contentEl&&(this._contentEl.style.opacity="1")}))}onHide(){}onDestroy(){this._abort(),this._debounceTimer&&(clearTimeout(this._debounceTimer),this._debounceTimer=null),this._contentEl&&(this._cleanupTextInputTimers(),this._contentEl.remove(),this._contentEl=null)}_abort(){this._abortController?.abort(),this._abortController=null}_cleanupTextInputTimers(){if(!this._contentEl)return;const e=this._contentEl.querySelectorAll(".gengage-qna-input-wrapper");for(const t of e)t._cleanup?.()}async _fetchAndRender(e){if(this._abort(),this._abortController=new AbortController,!this._contentEl)return;this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const t=this._createLoadingIndicator();this._contentEl.appendChild(t);const i={middlewareUrl:this.config.middlewareUrl},o=crypto.randomUUID(),r=Date.now();this.track(s.streamStartEvent(this.analyticsContext(),{endpoint:"launcher_action",request_id:o,widget:"qna"}));try{const a={account_id:this.config.accountId,session_id:this.config.session?.sessionId??"",correlation_id:this.config.session?.sessionId??"",sku:e,locale:this.config.locale??"tr"},c=this.config.pageContext?.pageType;c!==void 0&&(a.page_type=c);const l=await q(a,i,this._abortController.signal);if(this.track(s.streamDoneEvent(this.analyticsContext(),{request_id:o,latency_ms:Date.now()-r,chunk_count:l.actions.length,widget:"qna"})),this.track(s.widgetHistorySnapshotEvent(this.analyticsContext(),{message_count:l.actions.length,history_ref:o,redaction_level:"none",widget:"qna"})),!this._contentEl)return;if(this._contentEl.innerHTML="",!this._specIncludesType(l.uiSpecs,"QuestionHeading")&&this.config.showStaticQuestion&&this.config.staticQuestionText){const d=document.createElement("h3");d.className="gengage-qna-heading",d.textContent=this.config.staticQuestionText,this._contentEl.appendChild(d)}const h=this.config.inputPlaceholder;let p;if(h!==!0)p=h??this._i18n.defaultInputPlaceholder;else if(l.actions.length>0){const d=l.actions.filter(f=>f.type==="user_message"||f.title.includes("?")).map(f=>f.title);p=d.length>0?d:this._i18n.defaultInputPlaceholder}else p=this._i18n.defaultInputPlaceholder;const g={onAction:this._actionHandler,i18n:this._i18n};this.config.hideButtonRowCta||(g.onOpenChat=this._openChatHandler,this.config.ctaText!==void 0&&(g.ctaText=this.config.ctaText)),p!==void 0&&(g.inputPlaceholder=p);const k=this._buildFallbackActionsSpec(l.actions),b=(l.uiSpecs.length>0?l.uiSpecs:[k]).filter(d=>Object.keys(d.elements).length>0);for(const d of b){const f=this._renderUISpec(d,g);this._contentEl.appendChild(f)}b.length>0&&s.trackShow("qna"),!this._specIncludesType(b,"TextInput")&&this._appendStandaloneInput(g,p)}catch(a){if(a instanceof DOMException&&a.name==="AbortError")return;if(s.dispatch("gengage:global:error",{source:"qna",code:"FETCH_ERROR",message:s.getGlobalErrorMessage(this.config.locale)}),this.track(s.streamErrorEvent(this.analyticsContext(),{request_id:o,error_code:"FETCH_ERROR",error_message:a instanceof Error?a.message:String(a),widget:"qna"})),this._contentEl){this._cleanupTextInputTimers(),this._contentEl.innerHTML="";const c=this.config.inputPlaceholder===!0?this._i18n.defaultInputPlaceholder:this.config.inputPlaceholder??this._i18n.defaultInputPlaceholder,l={onAction:this._actionHandler,i18n:this._i18n,onOpenChat:this._openChatHandler};this.config.ctaText!==void 0&&(l.ctaText=this.config.ctaText),this._appendStandaloneInput(l,c)}}}_createLoadingIndicator(){const e=document.createElement("div");e.className="gengage-qna-loading";for(let t=0;t<3;t++){const i=document.createElement("div");i.className="gengage-qna-loading-dot",e.appendChild(i)}return e}_resolveI18n(e){return{...L(e.locale),...e.i18n}}_resolveUISpecRegistry(){const e=E();return s.mergeUISpecRegistry(e,this.config.renderer?.registry)}_renderUISpec(e,t){const i=this._resolveUISpecRegistry(),o=this.config.renderer?.unknownRenderer??y,r=(l,u)=>I(l,u,i,o),a=this.config.renderer?.renderUISpec;return a?a(e,t,{registry:i,unknownRenderer:o,defaultRender:r}):r(e,t)}_specIncludesType(e,t){for(const i of e)for(const o of Object.values(i.elements))if(o.type===t)return!0;return!1}_buildFallbackActionsSpec(e){if(e.length===0)return{root:"root",elements:{}};const t={},i=[];for(let o=0;o<e.length;o++){const r=e[o],a=`action-${o}`;i.push(a),t[a]={type:"ActionButton",props:{label:r.title,action:{title:r.title,type:r.type,payload:r.payload}}}}return t.root={type:"ButtonRow",children:i},{root:"root",elements:t}}_appendStandaloneInput(e,t){if(!this._contentEl)return;const i={root:"root",elements:{root:{type:"TextInput",props:{placeholder:t}}}},o=this._renderUISpec(i,e);this._contentEl.appendChild(o)}_handleAction(e){s.trackSuggestedQuestion(e.title,e.type),this.config.onActionSelected?.(e),s.dispatch("gengage:qna:action",e)}_handleOpenChat(){const e=this._contentEl?.querySelector(".gengage-qna-input");e&&e.focus(),this.config.onOpenChat?.(),s.dispatch("gengage:qna:open-chat",{})}}function H(){return new v}exports.GengageQNA=v;exports.createDefaultQnaUISpecRegistry=E;exports.createQNAWidget=H;exports.defaultQnaUnknownUISpecRenderer=y;exports.qnaCatalog=O;exports.renderQnaUISpec=I;
2
2
  //# sourceMappingURL=qna.cjs.map
package/dist/qna.css CHANGED
@@ -1 +1 @@
1
- .gengage-qna-container{font-family:var(--gengage-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);font-size:var(--gengage-font-size, 14px);color:var(--gengage-foreground-color, #333);--_gengage-border-color: var(--gengage-border-color, #e5e7eb)}.gengage-qna-uispec{display:flex;flex-direction:column;gap:8px}.gengage-qna-uispec>*{animation:gengage-qna-enter .15s cubic-bezier(.2,.72,.2,1) both}@keyframes gengage-qna-enter{0%{opacity:0;transform:translateY(4px) scale(.995)}to{opacity:1;transform:translateY(0) scale(1)}}.gengage-qna-buttons{display:flex;flex-wrap:wrap;gap:8px;padding:8px 0 12px}.gengage-qna-button{display:inline-flex;align-items:center;justify-content:center;min-height:40px;padding:8px 14px;border:none;border-radius:var(--gengage-qna-pill-radius, 999px);background:var(--gengage-primary-color, #3b82f6);color:var(--gengage-primary-foreground, #fff);font-size:13px;font-weight:600;font-family:inherit;cursor:pointer;transition:filter .14s ease,transform .12s ease;text-align:left;line-height:1.25}.gengage-qna-button:hover{filter:brightness(1.06);transform:translateY(-1px)}.gengage-qna-button:active{transform:translateY(1px) scale(.988)}.gengage-qna-button:focus-visible{outline:2px solid var(--gengage-primary-color, #3b82f6);outline-offset:2px}.gengage-qna-cta{display:inline-flex;align-items:center;min-height:40px;padding:8px 14px;border:1px solid color-mix(in srgb,var(--gengage-primary-color, #3b82f6) 65%,#cbd5e1 35%);border-radius:var(--gengage-qna-pill-radius, 999px);background:transparent;color:var(--gengage-primary-color, #3b82f6);font-size:13px;font-weight:600;font-family:inherit;cursor:pointer;opacity:.92;transition:opacity .12s ease,transform .12s ease;white-space:nowrap}.gengage-qna-cta:hover{opacity:1;transform:translateY(-1px)}.gengage-qna-cta:focus-visible{outline:2px solid var(--gengage-primary-color, #3b82f6);outline-offset:2px}.gengage-qna-input-wrapper{display:flex;gap:8px;padding:6px 0 2px;align-items:stretch}.gengage-qna-input{flex:1;min-width:0;height:48px;padding:0 14px 0 40px;border:1px solid var(--_gengage-border-color);border-radius:var(--gengage-qna-input-radius, 14px);font-size:15px;font-family:inherit;outline:none;background:#fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") 14px center no-repeat;transition:border-color .14s ease,box-shadow .14s ease}.gengage-qna-input::placeholder{transition:opacity .18s ease}.gengage-qna-input--fade::placeholder{opacity:0}.gengage-qna-input:focus{border-color:var(--gengage-primary-color, #3b82f6);box-shadow:0 0 0 3px color-mix(in srgb,var(--gengage-primary-color, #3b82f6) 18%,transparent)}.gengage-qna-send{min-width:44px;min-height:44px;height:48px;padding:0 16px;border:1px solid var(--gengage-qna-primary, var(--gengage-primary-color, #3b82f6));border-radius:var(--gengage-qna-pill-radius, 999px);background:transparent;color:var(--gengage-primary-color, #3b82f6);font-size:13px;font-weight:600;font-family:inherit;cursor:pointer;opacity:.92;transition:opacity .12s ease,transform .12s ease;white-space:nowrap}.gengage-qna-send:hover{opacity:1;transform:translateY(-1px)}.gengage-qna-send:focus-visible{outline:2px solid var(--gengage-primary-color, #3b82f6);outline-offset:2px}.gengage-qna-send:active{transform:translateY(1px)}.gengage-qna-heading{font-size:1.04em;font-weight:700;margin:0 0 6px;color:var(--gengage-foreground-color, #333)}.gengage-qna-loading{display:flex;gap:4px;padding:12px 0}.gengage-qna-loading-dot{width:7px;height:7px;border-radius:50%;background:var(--gengage-primary-color, #3b82f6);opacity:.4;animation:gengage-qna-pulse 1.4s infinite ease-in-out both}.gengage-qna-loading-dot:nth-child(1){animation-delay:0s}.gengage-qna-loading-dot:nth-child(2){animation-delay:.16s}.gengage-qna-loading-dot:nth-child(3){animation-delay:.32s}@keyframes gengage-qna-pulse{0%,80%,to{opacity:.4;transform:scale(.8)}40%{opacity:1;transform:scale(1)}}@media(max-width:768px){.gengage-qna-buttons{gap:10px;padding:10px 0 14px}.gengage-qna-button,.gengage-qna-cta{min-height:44px;padding:10px 16px;font-size:14px;line-height:1.2}.gengage-qna-input-wrapper{flex-direction:column;gap:10px}.gengage-qna-input{width:100%;height:52px;padding-left:42px;font-size:16px}.gengage-qna-send{width:100%;min-height:48px;font-size:14px}}@media(prefers-reduced-motion:reduce){.gengage-qna-uispec>*,.gengage-qna-button,.gengage-qna-cta,.gengage-qna-send{animation:none!important;transition:none!important;transform:none!important}}
1
+ .gengage-qna-container{font-family:var( --gengage-font-family, "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif );font-size:var(--gengage-font-size, 14px);color:var(--gengage-foreground-color, #191c1d);--_gengage-border-color: var(--gengage-border-color, #edeeef)}.gengage-qna-uispec{display:flex;flex-direction:column;gap:8px}.gengage-qna-uispec>*{animation:gengage-qna-enter .15s cubic-bezier(.2,.72,.2,1) both}@keyframes gengage-qna-enter{0%{opacity:0;transform:translateY(4px) scale(.995)}to{opacity:1;transform:translateY(0) scale(1)}}.gengage-qna-buttons{display:flex;flex-wrap:wrap;gap:8px;padding:8px 0 12px}.gengage-qna-button{display:inline-flex;align-items:center;justify-content:center;min-height:40px;padding:8px 14px;border:none;border-radius:var(--gengage-qna-pill-radius, 999px);background:var(--gengage-primary-color, #b7102a);color:var(--gengage-primary-foreground, #fff);font-size:13px;font-weight:600;font-family:inherit;cursor:pointer;transition:filter .14s ease,transform .12s ease;text-align:left;line-height:1.25}.gengage-qna-button:hover{filter:brightness(1.06);transform:translateY(-1px)}.gengage-qna-button:active{transform:translateY(1px) scale(.988)}.gengage-qna-button:focus-visible{outline:2px solid var(--gengage-primary-color, #b7102a);outline-offset:2px}.gengage-qna-cta{display:inline-flex;align-items:center;min-height:40px;padding:8px 14px;border:1px solid color-mix(in srgb,var(--gengage-primary-color, #b7102a) 65%,#cbd5e1 35%);border-radius:var(--gengage-qna-pill-radius, 999px);background:transparent;color:var(--gengage-primary-color, #b7102a);font-size:13px;font-weight:600;font-family:inherit;cursor:pointer;opacity:.92;transition:opacity .12s ease,transform .12s ease;white-space:nowrap}.gengage-qna-cta:hover{opacity:1;transform:translateY(-1px)}.gengage-qna-cta:focus-visible{outline:2px solid var(--gengage-primary-color, #b7102a);outline-offset:2px}.gengage-qna-input-wrapper{display:flex;gap:8px;padding:6px 0 2px;align-items:stretch}.gengage-qna-input{flex:1;min-width:0;height:48px;padding:0 14px 0 40px;border:1px solid var(--_gengage-border-color);border-radius:var(--gengage-qna-input-radius, 14px);font-size:15px;font-family:inherit;outline:none;background:#fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") 14px center no-repeat;transition:border-color .14s ease,box-shadow .14s ease}.gengage-qna-input::placeholder{transition:opacity .18s ease}.gengage-qna-input--fade::placeholder{opacity:0}.gengage-qna-input:focus{border-color:var(--gengage-primary-color, #b7102a);box-shadow:0 0 0 3px color-mix(in srgb,var(--gengage-primary-color, #b7102a) 18%,transparent)}.gengage-qna-send{min-width:44px;min-height:44px;height:48px;padding:0 16px;border:1px solid var(--gengage-qna-primary, var(--gengage-primary-color, #b7102a));border-radius:var(--gengage-qna-pill-radius, 999px);background:transparent;color:var(--gengage-primary-color, #b7102a);font-size:13px;font-weight:600;font-family:inherit;cursor:pointer;opacity:.92;transition:opacity .12s ease,transform .12s ease;white-space:nowrap}.gengage-qna-send:hover{opacity:1;transform:translateY(-1px)}.gengage-qna-send:focus-visible{outline:2px solid var(--gengage-primary-color, #b7102a);outline-offset:2px}.gengage-qna-send:active{transform:translateY(1px)}.gengage-qna-heading{font-size:1.04em;font-weight:700;margin:0 0 6px;color:var(--gengage-foreground-color, #191c1d)}.gengage-qna-loading{display:flex;gap:4px;padding:12px 0}.gengage-qna-loading-dot{width:7px;height:7px;border-radius:50%;background:var(--gengage-primary-color, #b7102a);opacity:.4;animation:gengage-qna-pulse 1.4s infinite ease-in-out both}.gengage-qna-loading-dot:nth-child(1){animation-delay:0s}.gengage-qna-loading-dot:nth-child(2){animation-delay:.16s}.gengage-qna-loading-dot:nth-child(3){animation-delay:.32s}@keyframes gengage-qna-pulse{0%,80%,to{opacity:.4;transform:scale(.8)}40%{opacity:1;transform:scale(1)}}@media(max-width:768px){.gengage-qna-buttons{gap:10px;padding:10px 0 14px}.gengage-qna-button,.gengage-qna-cta{min-height:44px;padding:10px 16px;font-size:14px;line-height:1.2}.gengage-qna-input-wrapper{flex-direction:column;gap:10px}.gengage-qna-input{flex:none;width:100%;height:52px;padding-left:42px;font-size:16px}.gengage-qna-send{width:100%;min-height:48px;font-size:14px}}@media(prefers-reduced-motion:reduce){.gengage-qna-uispec>*,.gengage-qna-button,.gengage-qna-cta,.gengage-qna-send{animation:none!important;transition:none!important;transform:none!important}}
package/dist/qna.iife.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(x){"use strict";const Ft=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const o of e.children){const r=t(o);r&&n.appendChild(r)}return n};function Mt(e){const t=document.createElement("div");if(t.className=e.containerClassName,!e.spec.elements[e.spec.root])return t;const o=e.unknownRenderer??Ft,r=i=>{const a=e.spec.elements[i];if(!a)return null;const c=e.registry[a.type];return c?c({elementId:i,element:a,spec:e.spec,context:e.context,renderElement:r}):o({elementId:i,element:a,spec:e.spec,context:e.context,renderElement:r})},s=r(e.spec.root);return s&&t.appendChild(s),t}function Bt(e,t){if(!t)return e;const n={...e};for(const[o,r]of Object.entries(t))r&&(n[o]=r);return n}function Jt(e,t){const n={event_name:"stream.start",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{endpoint:t.endpoint,request_id:t.request_id}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function Qt(e,t){const n={event_name:"stream.done",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,latency_ms:t.latency_ms,chunk_count:t.chunk_count}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function Ht(e,t){const n={event_name:"stream.error",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,error_code:t.error_code,error_message:t.error_message}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function Wt(e,t){const n={event_name:"metering.summary",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{meter_key:t.meter_key,quantity:t.quantity,unit:t.unit}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function Vt(e,t){const n={event_name:"widget.history.snapshot",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.widget,payload:{message_count:t.message_count,history_ref:t.history_ref,redaction_level:t.redaction_level}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function Gt(e,t){const n={event_name:"checkout.start",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function Kt(e,t){const n={event_name:"checkout.complete",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function fe(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!1}))}function Ce(e,t){const n=o=>{t(o.detail)};return window.addEventListener(e,n),()=>window.removeEventListener(e,n)}function Yt(){const t=window.__gengageSessionId??sessionStorage.getItem("gengage_session_id")??null??crypto.randomUUID();return window.__gengageSessionId=t,sessionStorage.setItem("gengage_session_id",t),window.gengage||(window.gengage={}),window.gengage.sessionId=t,t}function Xt(e){return{sessionId:e?.sessionId??Yt(),...e}}const Pe={"--gengage-chat-offset":"20px","--gengage-chat-launcher-size":"56px","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"12px","--gengage-chat-header-height":"60px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"860px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"14px","--gengage-simrel-card-radius":"14px"};function en(e){return e?{...Pe,...e}:{...Pe}}const j="gengage-global-toast-root",Re="gengage-global-toast-style",he="gengage-global-toast-root--visible",tn=4200,nn=1500,on=15e3;let Ne=!1,U=null;function rn(e){return typeof e=="string"&&e.toLowerCase().startsWith("tr")?"Bağlantı sorunu oluştu. Lütfen tekrar deneyin.":"Connection issue. Please try again."}function sn(){Ne||typeof window>"u"||typeof document>"u"||(Ne=!0,Ce("gengage:global:error",e=>{an(e)}))}function an(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;pn();const n=dn();n.innerHTML="";const o=document.createElement("section");o.className="gengage-global-toast gengage-global-toast--error",o.setAttribute("role","status"),o.setAttribute("aria-live","polite");const r=document.createElement("div");r.className="gengage-global-toast-title",r.textContent=un(e.source);const s=document.createElement("div");s.className="gengage-global-toast-message",s.textContent=t,o.appendChild(r),o.appendChild(s),n.appendChild(o),n.classList.add(he),U&&(clearTimeout(U),U=null),U=setTimeout(()=>{cn()},ln(e.durationMs))}function cn(){if(typeof document>"u")return;const e=document.getElementById(j);e&&(e.classList.remove(he),e.innerHTML="",U&&(clearTimeout(U),U=null))}function un(e){switch(e){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function dn(){const e=document.getElementById(j);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=j,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function ln(e){return typeof e!="number"||!Number.isFinite(e)?tn:Math.min(on,Math.max(nn,Math.round(e)))}function pn(){if(document.getElementById(Re))return;const e=document.createElement("style");e.id=Re,e.textContent=`
1
+ (function(x){"use strict";const Ft=({element:e,renderElement:t})=>{if(!e.children||e.children.length===0)return null;const n=document.createElement("div");for(const o of e.children){const r=t(o);r&&n.appendChild(r)}return n};function Mt(e){const t=document.createElement("div");if(t.className=e.containerClassName,!e.spec.elements[e.spec.root])return t;const o=e.unknownRenderer??Ft,r=i=>{const a=e.spec.elements[i];if(!a)return null;const c=e.registry[a.type];return c?c({elementId:i,element:a,spec:e.spec,context:e.context,renderElement:r}):o({elementId:i,element:a,spec:e.spec,context:e.context,renderElement:r})},s=r(e.spec.root);return s&&t.appendChild(s),t}function Bt(e,t){if(!t)return e;const n={...e};for(const[o,r]of Object.entries(t))r&&(n[o]=r);return n}function Jt(e,t){const n={event_name:"stream.start",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{endpoint:t.endpoint,request_id:t.request_id}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function Qt(e,t){const n={event_name:"stream.done",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,latency_ms:t.latency_ms,chunk_count:t.chunk_count}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function Ht(e,t){const n={event_name:"stream.error",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{request_id:t.request_id,error_code:t.error_code,error_message:t.error_message}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),t.widget!==void 0&&(n.widget=t.widget),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function Wt(e,t){const n={event_name:"metering.summary",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,payload:{meter_key:t.meter_key,quantity:t.quantity,unit:t.unit}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function Vt(e,t){const n={event_name:"widget.history.snapshot",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.widget,payload:{message_count:t.message_count,history_ref:t.history_ref,redaction_level:t.redaction_level}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function Gt(e,t){const n={event_name:"checkout.start",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function Kt(e,t){const n={event_name:"checkout.complete",account_id:e.account_id,session_id:e.session_id,correlation_id:e.correlation_id,widget:t.attribution_source,payload:{attribution_source:t.attribution_source,attribution_action_id:t.attribution_action_id,cart_value:t.cart_value,currency:t.currency,line_items:t.line_items}};return e.view_id!==void 0&&(n.view_id=e.view_id),e.user_id!==void 0&&(n.user_id=e.user_id),e.page_type!==void 0&&(n.page_type=e.page_type),e.sku!==void 0&&(n.sku=e.sku),n}function fe(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!1}))}function Ce(e,t){const n=o=>{t(o.detail)};return window.addEventListener(e,n),()=>window.removeEventListener(e,n)}function Yt(){const t=window.__gengageSessionId??sessionStorage.getItem("gengage_session_id")??null??crypto.randomUUID();return window.__gengageSessionId=t,sessionStorage.setItem("gengage_session_id",t),window.gengage||(window.gengage={}),window.gengage.sessionId=t,t}function Xt(e){return{sessionId:e?.sessionId??Yt(),...e}}const Pe={"--gengage-chat-offset":"20px","--gengage-chat-launcher-size":"56px","--gengage-chat-width":"400px","--gengage-chat-shell-radius":"1rem","--gengage-chat-header-height":"60px","--gengage-chat-conversation-width":"396px","--gengage-chat-panel-min-width":"320px","--gengage-chat-panel-max-width":"860px","--gengage-chat-input-height":"48px","--gengage-qna-pill-radius":"999px","--gengage-qna-input-radius":"0.75rem","--gengage-simrel-card-radius":"0.75rem"};function en(e){return e?{...Pe,...e}:{...Pe}}const j="gengage-global-toast-root",Re="gengage-global-toast-style",he="gengage-global-toast-root--visible",tn=4200,nn=1500,on=15e3;let Ne=!1,U=null;function rn(e){return typeof e=="string"&&e.toLowerCase().startsWith("tr")?"Bağlantı sorunu oluştu. Lütfen tekrar deneyin.":"Connection issue. Please try again."}function sn(){Ne||typeof window>"u"||typeof document>"u"||(Ne=!0,Ce("gengage:global:error",e=>{an(e)}))}function an(e){if(typeof document>"u")return;const t=e.message.trim();if(!t)return;pn();const n=dn();n.innerHTML="";const o=document.createElement("section");o.className="gengage-global-toast gengage-global-toast--error",o.setAttribute("role","status"),o.setAttribute("aria-live","polite");const r=document.createElement("div");r.className="gengage-global-toast-title",r.textContent=un(e.source);const s=document.createElement("div");s.className="gengage-global-toast-message",s.textContent=t,o.appendChild(r),o.appendChild(s),n.appendChild(o),n.classList.add(he),U&&(clearTimeout(U),U=null),U=setTimeout(()=>{cn()},ln(e.durationMs))}function cn(){if(typeof document>"u")return;const e=document.getElementById(j);e&&(e.classList.remove(he),e.innerHTML="",U&&(clearTimeout(U),U=null))}function un(e){switch(e){case"chat":return"Chat warning";case"qna":return"QnA warning";case"simrel":return"Widget warning";default:return"Connection warning"}}function dn(){const e=document.getElementById(j);if(e instanceof HTMLElement)return e;const t=document.createElement("div");return t.id=j,t.className="gengage-global-toast-root",document.body.appendChild(t),t}function ln(e){return typeof e!="number"||!Number.isFinite(e)?tn:Math.min(on,Math.max(nn,Math.round(e)))}function pn(){if(document.getElementById(Re))return;const e=document.createElement("style");e.id=Re,e.textContent=`
2
2
  #${j} {
3
3
  position: fixed;
4
4
  top: 16px;