@aikaara/chat-sdk 0.7.0 → 0.7.1

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.
@@ -0,0 +1,98 @@
1
+ class u extends HTMLElement {
2
+ shadow;
3
+ payload = null;
4
+ constructor() {
5
+ super(), this.shadow = this.attachShadow({ mode: "open" });
6
+ }
7
+ connectedCallback() {
8
+ this.render();
9
+ }
10
+ setPayload(e) {
11
+ this.payload = e, this.render();
12
+ }
13
+ render() {
14
+ const e = this.payload;
15
+ this.shadow.innerHTML = `
16
+ <style>
17
+ :host { display: block; margin-top: 8px; }
18
+ button {
19
+ display: inline-flex;
20
+ align-items: center;
21
+ gap: 6px;
22
+ padding: 10px 16px;
23
+ background: var(--aikaara-primary, #0f2e5c);
24
+ color: var(--aikaara-primary-contrast, #fff);
25
+ border: none;
26
+ border-radius: var(--aikaara-button-radius, 8px);
27
+ font-family: var(--aikaara-font, system-ui);
28
+ font-size: 14px;
29
+ font-weight: 600;
30
+ cursor: pointer;
31
+ }
32
+ button:hover { background: var(--aikaara-primary-hover, #0a2347); }
33
+ button[disabled] { opacity: 0.5; cursor: not-allowed; }
34
+ </style>
35
+ <button type="button" ${e ? "" : "disabled"}>
36
+ ${c(e?.name ?? "Open")}
37
+ <span aria-hidden="true">↗</span>
38
+ </button>
39
+ `, this.shadow.querySelector("button")?.addEventListener("click", () => this.handleClick());
40
+ }
41
+ handleClick() {
42
+ if (!this.payload) return;
43
+ const { url: e, name: a, openLinkInNewTab: o, orderId: r, extra: i, messageId: n } = this.payload, s = o ? "tab" : "modal", d = new CustomEvent("aikaara-link-action", {
44
+ detail: { url: e, name: a, orderId: r, openedIn: s, extra: i, messageId: n },
45
+ bubbles: !0,
46
+ composed: !0,
47
+ cancelable: !0
48
+ });
49
+ if (this.dispatchEvent(d))
50
+ if (o)
51
+ window.open(e, "_blank", "noopener,noreferrer");
52
+ else {
53
+ const l = p();
54
+ requestAnimationFrame(() => l?.show?.(e, a));
55
+ }
56
+ this.dispatchEvent(
57
+ new CustomEvent("template-action", {
58
+ detail: {
59
+ text: a,
60
+ attributes: {
61
+ action: {
62
+ type: "link",
63
+ url: e,
64
+ orderId: r,
65
+ openedIn: s,
66
+ ...i ?? {}
67
+ },
68
+ ...n ? { message_id: n } : {}
69
+ }
70
+ },
71
+ bubbles: !0,
72
+ composed: !0
73
+ })
74
+ );
75
+ }
76
+ }
77
+ function c(t) {
78
+ return t.replace(
79
+ /[&<>"']/g,
80
+ (e) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[e]
81
+ );
82
+ }
83
+ function p() {
84
+ if (typeof document > "u") return null;
85
+ let t = document.querySelector("aikaara-link-modal");
86
+ if (!t) {
87
+ const e = document.createElement("aikaara-link-modal");
88
+ document.body.appendChild(e), t = e;
89
+ }
90
+ return t;
91
+ }
92
+ function b() {
93
+ typeof customElements > "u" || customElements.get("aikaara-link-button") || customElements.define("aikaara-link-button", u);
94
+ }
95
+ export {
96
+ u as AikaaraLinkButton,
97
+ b as registerAikaaraLinkButton
98
+ };
@@ -0,0 +1,25 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class d extends HTMLElement{shadow;payload=null;constructor(){super(),this.shadow=this.attachShadow({mode:"open"})}connectedCallback(){this.render()}setPayload(e){this.payload=e,this.render()}render(){const e=this.payload;this.shadow.innerHTML=`
2
+ <style>
3
+ :host { display: block; margin-top: 8px; }
4
+ button {
5
+ display: inline-flex;
6
+ align-items: center;
7
+ gap: 6px;
8
+ padding: 10px 16px;
9
+ background: var(--aikaara-primary, #0f2e5c);
10
+ color: var(--aikaara-primary-contrast, #fff);
11
+ border: none;
12
+ border-radius: var(--aikaara-button-radius, 8px);
13
+ font-family: var(--aikaara-font, system-ui);
14
+ font-size: 14px;
15
+ font-weight: 600;
16
+ cursor: pointer;
17
+ }
18
+ button:hover { background: var(--aikaara-primary-hover, #0a2347); }
19
+ button[disabled] { opacity: 0.5; cursor: not-allowed; }
20
+ </style>
21
+ <button type="button" ${e?"":"disabled"}>
22
+ ${c(e?.name??"Open")}
23
+ <span aria-hidden="true">↗</span>
24
+ </button>
25
+ `,this.shadow.querySelector("button")?.addEventListener("click",()=>this.handleClick())}handleClick(){if(!this.payload)return;const{url:e,name:a,openLinkInNewTab:o,orderId:r,extra:i,messageId:n}=this.payload,s=o?"tab":"modal",l=new CustomEvent("aikaara-link-action",{detail:{url:e,name:a,orderId:r,openedIn:s,extra:i,messageId:n},bubbles:!0,composed:!0,cancelable:!0});if(this.dispatchEvent(l))if(o)window.open(e,"_blank","noopener,noreferrer");else{const u=p();requestAnimationFrame(()=>u?.show?.(e,a))}this.dispatchEvent(new CustomEvent("template-action",{detail:{text:a,attributes:{action:{type:"link",url:e,orderId:r,openedIn:s,...i??{}},...n?{message_id:n}:{}}},bubbles:!0,composed:!0}))}}function c(t){return t.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e])}function p(){if(typeof document>"u")return null;let t=document.querySelector("aikaara-link-modal");if(!t){const e=document.createElement("aikaara-link-modal");document.body.appendChild(e),t=e}return t}function m(){typeof customElements>"u"||customElements.get("aikaara-link-button")||customElements.define("aikaara-link-button",d)}exports.AikaaraLinkButton=d;exports.registerAikaaraLinkButton=m;
@@ -263,8 +263,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
263
263
  .message-wrap { display: flex; flex-direction: column; }
264
264
  .message-wrap.user { align-items: flex-end; }
265
265
  .message-wrap.assistant,
266
- .message-wrap.agent,
267
- .message-wrap.system { align-items: flex-start; }
266
+ .message-wrap.agent { align-items: flex-start; }
267
+ .message-wrap.system { align-items: center; text-align: center; }
268
268
  .message-wrap.system .bubble {
269
269
  background: transparent;
270
270
  color: var(--aikaara-text-secondary, #6b7280);
@@ -648,13 +648,14 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
648
648
  <span class="message"></span>
649
649
  <button class="dismiss">Dismiss</button>
650
650
  </div>
651
- `,this.container=this.shadow.querySelector(".banner"),this.shadow.querySelector(".dismiss")?.addEventListener("click",()=>this.hide())}show(e,t){const i=this.container.querySelector(".message");i&&(i.textContent=e),this.container.classList.add("visible"),this.dismissTimer&&clearTimeout(this.dismissTimer),t&&(this.dismissTimer=setTimeout(()=>this.hide(),t))}hide(){this.container.classList.remove("visible"),this.dismissTimer&&(clearTimeout(this.dismissTimer),this.dismissTimer=null)}}const $r=new Map;function bh(u){const e=$r.get(u);if(e)return e;const t=new Promise((i,l)=>{const r=document.querySelector(`script[data-aikaara-src="${CSS.escape(u)}"]`);if(r){r.dataset.aikaaraReady==="1"?i():(r.addEventListener("load",()=>i(),{once:!0}),r.addEventListener("error",()=>l(new Error(`Failed to load ${u}`)),{once:!0}));return}const n=document.createElement("script");n.src=u,n.async=!0,n.crossOrigin="anonymous",n.dataset.aikaaraSrc=u,n.addEventListener("load",()=>{n.dataset.aikaaraReady="1",i()},{once:!0}),n.addEventListener("error",()=>{$r.delete(u),l(new Error(`Failed to load ${u}`))},{once:!0}),document.head.appendChild(n)});return $r.set(u,t),t}function yh(u,e=5e3){return new Promise((t,i)=>{const l=setTimeout(()=>i(new Error(`Custom element <${u}> not registered within ${e}ms`)),e);customElements.whenDefined(u).then(()=>{clearTimeout(l),t()})})}class xl extends HTMLElement{shadow;payloadData=null;innerMessage="";static get observedAttributes(){return["content-type","template-id","message-id"]}constructor(){super(),this.shadow=this.attachShadow({mode:"open"})}connectedCallback(){this.render()}attributeChangedCallback(){this.render()}setPayload(e,t){this.payloadData=e,t!==void 0&&(this.innerMessage=t),this.render()}render(){const e=this.getAttribute("content-type")??"",t=this.getAttribute("template-id")??"";for(this.shadow.innerHTML=`
651
+ `,this.container=this.shadow.querySelector(".banner"),this.shadow.querySelector(".dismiss")?.addEventListener("click",()=>this.hide())}show(e,t){const i=this.container.querySelector(".message");i&&(i.textContent=e),this.container.classList.add("visible"),this.dismissTimer&&clearTimeout(this.dismissTimer),t&&(this.dismissTimer=setTimeout(()=>this.hide(),t))}hide(){this.container.classList.remove("visible"),this.dismissTimer&&(clearTimeout(this.dismissTimer),this.dismissTimer=null)}}const $r=new Map;function bh(u){const e=$r.get(u);if(e)return e;const t=new Promise((i,l)=>{const r=document.querySelector(`script[data-aikaara-src="${CSS.escape(u)}"]`);if(r){r.dataset.aikaaraReady==="1"?i():(r.addEventListener("load",()=>i(),{once:!0}),r.addEventListener("error",()=>l(new Error(`Failed to load ${u}`)),{once:!0}));return}const n=document.createElement("script");n.src=u,n.async=!0,n.crossOrigin="anonymous",n.dataset.aikaaraSrc=u,n.addEventListener("load",()=>{n.dataset.aikaaraReady="1",i()},{once:!0}),n.addEventListener("error",()=>{$r.delete(u),l(new Error(`Failed to load ${u}`))},{once:!0}),document.head.appendChild(n)});return $r.set(u,t),t}function yh(u,e=5e3){return new Promise((t,i)=>{const l=setTimeout(()=>i(new Error(`Custom element <${u}> not registered within ${e}ms`)),e);customElements.whenDefined(u).then(()=>{clearTimeout(l),t()})})}class xl extends HTMLElement{shadow;payloadData=null;innerMessage="";static get observedAttributes(){return["content-type","template-id","message-id"]}constructor(){super(),this.shadow=this.attachShadow({mode:"open"})}connectedCallback(){this.render(),this.addEventListener("template-action",()=>{this.dataset.consumed="true"})}attributeChangedCallback(){this.render()}setPayload(e,t){this.payloadData=e,t!==void 0&&(this.innerMessage=t),this.render()}render(){const e=this.getAttribute("content-type")??"",t=this.getAttribute("template-id")??"";for(this.shadow.innerHTML=`
652
652
  <style>
653
653
  :host { display: block; }
654
+ :host([data-consumed]) ::slotted(*) { display: none !important; }
654
655
  ::slotted(*) { display: block; }
655
656
  </style>
656
657
  <slot></slot>
657
- `;this.firstChild;)this.removeChild(this.firstChild);if(!e)return;const i=t?window.__aikaara_descriptor__?.templates?.[t]:void 0,l=i?.render??(t?`aikaara-template-${t}`:`aikaara-template-${e}`);if(i?.scriptUrl&&!customElements.get(l)&&bh(i.scriptUrl).then(()=>yh(l)).then(()=>this.render()).catch(r=>console.warn(`[aikaara-template-renderer] failed to lazy-load ${i.scriptUrl}`,r)),customElements.get(l)){const r=document.createElement(l);if(i?.props){for(const[n,s]of Object.entries(i.props))if(typeof r[n]=="function")try{r[n](s)}catch(o){console.warn(`[aikaara-template-renderer] props.${n} threw on <${l}>`,o)}}r.setPayload?.(this.payloadData,this.innerMessage),this.appendChild(r);return}if(Array.isArray(this.payloadData)){const r=this.payloadData;if(r.length>0&&r.every(s=>s&&typeof s=="object"&&!Array.isArray(s)&&!("type"in s)&&!("data"in s)&&typeof s.message=="string")){const s=document.createElement("aikaara-option-list");s.setPayload({name:"quick-reply",type:"button",options:r.map(o=>{const a=typeof o.title=="string"?o.title:"",c=o.message;return{label:a||c,value:c}})}),this.appendChild(s);return}for(const s of r)this.mountField(s)}else if(this.payloadData&&typeof this.payloadData=="object"){const r=this.payloadData;typeof r.message=="string"&&(r.okLabel||r.action||r.ok)&&this.mountModal(r)}}mountField(e){if(!e||typeof e!="object")return;const t=e.type??e.data?.type,i=e.data;if(i){if(t==="checkbox"||t==="radio"||t==="button"){const l=document.createElement("aikaara-option-list");l.setPayload({name:i.name??"",title:i.title,options:i.options??[],type:t}),this.appendChild(l);return}if(t==="submit"){const l=document.createElement("aikaara-submit-action"),r=this.getAttribute("message-id")??void 0;l.setPayload({name:i.name??"Submit",action:i.action??{message:i.name??"Submit"},messageId:r}),this.appendChild(l);return}t==="modal"&&this.mountModal({message:i.message??"",okLabel:i.okLabel,cancelLabel:i.cancelLabel,action:i.action})}}mountModal(e){const t=document.createElement("aikaara-modal-action");t.setPayload(e),this.appendChild(t)}}class Al extends HTMLElement{shadow;static get observedAttributes(){return["text","subtext"]}constructor(){super(),this.shadow=this.attachShadow({mode:"open"})}connectedCallback(){this.render()}attributeChangedCallback(){this.render()}render(){const e=this.getAttribute("text")??this.textContent??"",t=this.getAttribute("subtext")??"";this.shadow.innerHTML=`
658
+ `;this.firstChild;)this.removeChild(this.firstChild);if(!e)return;const i=t?window.__aikaara_descriptor__?.templates?.[t]:void 0,l=i?.render??(t?`aikaara-template-${t}`:`aikaara-template-${e}`);if(i?.scriptUrl&&!customElements.get(l)&&bh(i.scriptUrl).then(()=>yh(l)).then(()=>this.render()).catch(r=>console.warn(`[aikaara-template-renderer] failed to lazy-load ${i.scriptUrl}`,r)),customElements.get(l)){const r=document.createElement(l);if(i?.props){for(const[n,s]of Object.entries(i.props))if(typeof r[n]=="function")try{r[n](s)}catch(o){console.warn(`[aikaara-template-renderer] props.${n} threw on <${l}>`,o)}}r.setPayload?.(this.payloadData,this.innerMessage),this.appendChild(r);return}if(Array.isArray(this.payloadData)){const r=this.payloadData;if(r.length>0&&r.every(s=>s&&typeof s=="object"&&!Array.isArray(s)&&!("type"in s)&&!("data"in s)&&typeof s.message=="string")){const s=document.createElement("aikaara-option-list");s.setPayload({name:"quick-reply",type:"button",options:r.map(o=>{const a=typeof o.title=="string"?o.title:"",c=o.message;return{label:a||c,value:c}})}),this.appendChild(s);return}for(const s of r)this.mountField(s)}else if(this.payloadData&&typeof this.payloadData=="object"){const r=this.payloadData;typeof r.message=="string"&&(r.okLabel||r.action||r.ok)&&this.mountModal(r)}}mountField(e){if(!e||typeof e!="object")return;const t=e.type??e.data?.type;if(t==="link"){this.mountLinkButton(e);return}const i=e.data;if(i){if(t==="checkbox"||t==="radio"||t==="button"){const l=document.createElement("aikaara-option-list");l.setPayload({name:i.name??"",title:i.title,options:i.options??[],type:t}),this.appendChild(l);return}if(t==="submit"){const l=document.createElement("aikaara-submit-action"),r=this.getAttribute("message-id")??void 0;l.setPayload({name:i.name??"Submit",action:i.action??{message:i.name??"Submit"},messageId:r}),this.appendChild(l);return}t==="modal"&&this.mountModal({message:i.message??"",okLabel:i.okLabel,cancelLabel:i.cancelLabel,action:i.action})}}mountLinkButton(e){Promise.resolve().then(()=>require("./AikaaraLinkButton-VDNx7RfC.cjs")).then(({registerAikaaraLinkButton:t,AikaaraLinkButton:i})=>{t();const l=document.createElement("aikaara-link-button");l.setPayload({name:e.name??"Open",url:e.url??"",openLinkInNewTab:e.openLinkInNewTab,orderId:e.orderId,extra:wh(e),messageId:this.getAttribute("message-id")??void 0}),this.appendChild(l)})}mountModal(e){const t=document.createElement("aikaara-modal-action");t.setPayload(e),this.appendChild(t)}}const vh=new Set(["type","url","name","openLinkInNewTab","orderId"]);function wh(u){const e={};for(const[t,i]of Object.entries(u))vh.has(t)||(e[t]=i);return e}class Al extends HTMLElement{shadow;static get observedAttributes(){return["text","subtext"]}constructor(){super(),this.shadow=this.attachShadow({mode:"open"})}connectedCallback(){this.render()}attributeChangedCallback(){this.render()}render(){const e=this.getAttribute("text")??this.textContent??"",t=this.getAttribute("subtext")??"";this.shadow.innerHTML=`
658
659
  <style>
659
660
  :host {
660
661
  display: flex;
@@ -785,8 +786,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
785
786
  button:hover { background: var(--aikaara-submit-hover-bg, var(--aikaara-primary-hover, #4f46e5)); }
786
787
  button:disabled { opacity: var(--aikaara-submit-disabled-opacity, 0.5); cursor: not-allowed; }
787
788
  </style>
788
- <button type="button">${vh(e)}</button>
789
- `,this.shadow.querySelector("button").addEventListener("click",()=>this.handleClick())}}function vh(u){return String(u).replace(/[&<>]/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;"})[e])}class Cl extends HTMLElement{shadow;data=null;dismissed=!1;constructor(){super(),this.shadow=this.attachShadow({mode:"open"})}connectedCallback(){this.render()}setPayload(e){this.data=e,this.dismissed=!1,this.render()}dismiss(){this.dismissed=!0,this.render()}handleOk(){if(!this.data)return;const e=this.data.action;this.dispatchEvent(new CustomEvent("template-action",{detail:{text:e?.message??this.data.message,attributes:{action:{confirmed:!0,requestType:e?.requestType??"postBackToBotPlatform"}}},bubbles:!0,composed:!0})),this.dismiss()}render(){if(!this.data||this.dismissed){this.shadow.innerHTML="";return}const e=this.data.okLabel??"Ok",t=this.data.cancelLabel;this.shadow.innerHTML=`
789
+ <button type="button">${_h(e)}</button>
790
+ `,this.shadow.querySelector("button").addEventListener("click",()=>this.handleClick())}}function _h(u){return String(u).replace(/[&<>]/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;"})[e])}class Cl extends HTMLElement{shadow;data=null;dismissed=!1;constructor(){super(),this.shadow=this.attachShadow({mode:"open"})}connectedCallback(){this.render()}setPayload(e){this.data=e,this.dismissed=!1,this.render()}dismiss(){this.dismissed=!0,this.render()}handleOk(){if(!this.data)return;const e=this.data.action;this.dispatchEvent(new CustomEvent("template-action",{detail:{text:e?.message??this.data.message,attributes:{action:{confirmed:!0,requestType:e?.requestType??"postBackToBotPlatform"}}},bubbles:!0,composed:!0})),this.dismiss()}render(){if(!this.data||this.dismissed){this.shadow.innerHTML="";return}const e=this.data.okLabel??"Ok",t=this.data.cancelLabel;this.shadow.innerHTML=`
790
791
  <style>
791
792
  :host { all: initial; }
792
793
  .overlay {
@@ -884,7 +885,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
884
885
  <div class="modal-body-element" style="display:none; flex:1; overflow:auto; padding:18px;"></div>
885
886
  </div>
886
887
  </div>
887
- `,this.root=this.shadow.querySelector(".backdrop"),this.iframe=this.shadow.querySelector("iframe"),this.shadow.querySelector(".modal-close")?.addEventListener("click",()=>this.close()),this.root?.addEventListener("click",t=>{t.target===this.root&&this.close()}),document.addEventListener("keydown",t=>{t.key==="Escape"&&this.classList.contains("open")&&this.close()})}}const wh=[{label:"Self-filing guidance"},{label:"Smart tax suggestions"},{label:"Auto-fetch 26AS / AIS"},{label:"Notice management"},{label:"Dedicated tax expert"},{label:"End-to-end filing"},{label:"Document handling"}],_h=[{label:"DIY",match:["DIY","DIY_SALARY"],selectLabel:"Select DIY — Without Notice (₹{price}/yr)",postback:"Without Notice",features:[!0,!0,!0,!1,!1,!1,!1]},{label:"DIY + Notice",match:["NOTICE_DIY","DIY_NOTICE"],selectLabel:"Select DIY — With Notice (₹{price}/yr)",postback:"With Notice",features:[!0,!0,!0,!0,!1,!1,!1]},{label:"Assisted",match:["ASSISTED"],selectLabel:"Switch to Assisted (₹{price}/yr)",postback:"Assisted",features:[!0,!0,!0,!0,!0,!0,!0]}];class Ml extends HTMLElement{shadow;data=null;columns=_h;features=wh;constructor(){super(),this.shadow=this.attachShadow({mode:"open"})}connectedCallback(){this.render()}setData(e){this.data=e,this.render()}setColumns(e){this.columns=e,this.render()}setFeatures(e){this.features=e,this.render()}priceFor(e){if(!this.data?.data)return null;for(const t of this.data.data)if(e.match.includes(t.planType))return t.planMaster?.basePrice??null;return null}render(){const e=this.columns,t=this.features;this.shadow.innerHTML=`
888
+ `,this.root=this.shadow.querySelector(".backdrop"),this.iframe=this.shadow.querySelector("iframe"),this.shadow.querySelector(".modal-close")?.addEventListener("click",()=>this.close()),this.root?.addEventListener("click",t=>{t.target===this.root&&this.close()}),document.addEventListener("keydown",t=>{t.key==="Escape"&&this.classList.contains("open")&&this.close()})}}const Sh=[{label:"Self-filing guidance"},{label:"Smart tax suggestions"},{label:"Auto-fetch 26AS / AIS"},{label:"Notice management"},{label:"Dedicated tax expert"},{label:"End-to-end filing"},{label:"Document handling"}],kh=[{label:"DIY",match:["DIY","DIY_SALARY"],selectLabel:"Select DIY — Without Notice (₹{price}/yr)",postback:"Without Notice",features:[!0,!0,!0,!1,!1,!1,!1]},{label:"DIY + Notice",match:["NOTICE_DIY","DIY_NOTICE"],selectLabel:"Select DIY — With Notice (₹{price}/yr)",postback:"With Notice",features:[!0,!0,!0,!0,!1,!1,!1]},{label:"Assisted",match:["ASSISTED"],selectLabel:"Switch to Assisted (₹{price}/yr)",postback:"Assisted",features:[!0,!0,!0,!0,!0,!0,!0]}];class Ml extends HTMLElement{shadow;data=null;columns=kh;features=Sh;constructor(){super(),this.shadow=this.attachShadow({mode:"open"})}connectedCallback(){this.render()}setData(e){this.data=e,this.render()}setColumns(e){this.columns=e,this.render()}setFeatures(e){this.features=e,this.render()}priceFor(e){if(!this.data?.data)return null;for(const t of this.data.data)if(e.match.includes(t.planType))return t.planMaster?.basePrice??null;return null}render(){const e=this.columns,t=this.features;this.shadow.innerHTML=`
888
889
  <style>
889
890
  :host {
890
891
  display: block;
@@ -961,4 +962,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
961
962
  <small>Tap to select</small>
962
963
  </button>`}).join("")}
963
964
  </div>
964
- `,this.shadow.querySelectorAll("button.action").forEach(i=>{i.addEventListener("click",()=>{const l=Number(i.dataset.col),r=e[l];r&&this.dispatchEvent(new CustomEvent("aikaara-plan-select",{detail:{planType:r.match[0],message:r.postback,label:r.label},bubbles:!0,composed:!0}))})})}}function qr(u){return u.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e])}function Rl(){const u=[["aikaara-chat-widget",pl],["aikaara-chat-bubble",gl],["aikaara-chat-header",ml],["aikaara-message-list",yl],["aikaara-message-bubble",wl],["aikaara-chat-input",_l],["aikaara-typing-indicator",Sl],["aikaara-streaming-message",kl],["aikaara-error-banner",El],["aikaara-template-renderer",xl],["aikaara-system-pill",Al],["aikaara-option-list",Il],["aikaara-submit-action",Tl],["aikaara-modal-action",Cl],["aikaara-chat",Ol],["aikaara-link-modal",Pl],["aikaara-compare-plans",Ml]];for(const[e,t]of u)customElements.get(e)||customElements.define(e,t)}Rl();function Hr(u,e,t=""){if(!e)return t;const i=e.split(".");let l=u;for(const r of i)if(l&&typeof l=="object"&&r in l)l=l[r];else return t;return typeof l=="string"?l:t}function Sh(u){try{const e=u.split(".")[1];if(!e)return 0;const t=JSON.parse(atob(e.replace(/-/g,"+").replace(/_/g,"/")));return typeof t.exp=="number"?t.exp*1e3:0}catch{return 0}}async function Cr(u){return typeof u=="function"?await u():u}class jl{constructor(e,t){this.descriptor=e,this.sessionToken=t}cache=null;inflight=null;reset(){this.cache=null,this.inflight=null}async get(){const e=this.descriptor.expiryBufferMs??6e4,t=Date.now();return this.cache&&this.cache.expiresAt>t+e?this.cache:this.inflight?this.inflight:(this.inflight=this.fetchOnce().finally(()=>{this.inflight=null}),this.inflight)}async fetchOnce(){const e=await Cr(this.sessionToken),t=this.descriptor.authHeader??"Authorization",i=this.descriptor.authHeaderTemplate??"Bearer {token}",l={accept:"application/json",...this.descriptor.headers??{},[t]:i.replace("{token}",e)},r=this.descriptor.method??"POST",n={method:r,headers:l};r==="POST"&&(l["content-type"]="application/json",n.body=JSON.stringify(this.descriptor.body??{}));const s=await fetch(this.descriptor.endpoint,n);if(!s.ok){const y=await s.text().catch(()=>"");throw new Error(`Session auth failed: ${s.status} ${y.slice(0,200)}`)}const o=await s.json().catch(()=>({})),a=Hr(o,this.descriptor.tokenPath??"data.token"),c=this.descriptor.tokenStripPrefix,d=c?a.replace(new RegExp(`^${c}`,"i"),"").trim():a;if(!d)throw new Error("Session auth response missing token");const p=Hr(o,this.descriptor.requestIdPath??"data.requestId"),b=this.cache?.requestId||p;if(!b)throw new Error("Session auth response missing requestId");const f=Hr(o,this.descriptor.fullNamePath??"data.fullName"),m=Sh(d)||Date.now()+3600*1e3;return this.cache={token:d,requestId:b,fullName:f,expiresAt:m},this.cache}}function kh(){const u=typeof crypto<"u"?crypto:null;if(u?.randomUUID)return u.randomUUID();if(u?.getRandomValues){const e=new Uint8Array(16);u.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;const t=[...e].map(i=>i.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}const Eh="aikaara_chat:requestId";function lo(u,e){return`${Eh}:${u}:${e}`}function xh(u,e){try{return localStorage.getItem(lo(u,e))}catch{return null}}function Ah(u,e,t){try{localStorage.setItem(lo(u,e),t)}catch{}}function Ih(u,e){try{localStorage.removeItem(lo(u,e))}catch{}}async function Th(u,e){console.log("[aikaara-chat-sdk] preflight running",u.length,"steps");const t={userId:e.userId,projectId:e.projectId,slug:e.slug},i=r=>r.replace(/\{(\w+)\}/g,(n,s)=>t[s]??""),l=await Cr(e.sessionToken);for(let r=0;r<u.length;r++){const n=u[r],s=i(n.url),o=n.method??(n.body?"POST":"GET"),a={accept:"application/json",...n.headers??{}};if((n.authHeader??"session")==="session"){const d=n.authHeaderTemplate??"Bearer {token}";a.authorization=d.replace("{token}",l)}const c={method:o,headers:a};n.body&&(a["content-type"]="application/json",c.body=JSON.stringify(n.body));try{const d=await fetch(s,c);if(!d.ok){const p=await d.text().catch(()=>""),b=`Preflight #${r} ${o} ${s} → ${d.status} ${p.slice(0,200)}`;if(n.soft)console.warn("[aikaara-chat-sdk]",b);else throw new Error(b)}}catch(d){if(n.soft){console.warn(`[aikaara-chat-sdk] preflight #${r} soft-failed:`,d);continue}throw d}}}async function Ll(u,e){const t=await fetch(u,{method:"GET",headers:{accept:"application/json",...e??{}}});if(!t.ok){const l=await t.text().catch(()=>"");throw new Error(`Widget config fetch failed: ${t.status} ${t.statusText} ${l.slice(0,200)}`)}const i=await t.json();if(i&&typeof i=="object"){if("config"in i)return i.config;if("data"in i)return i.data}return i}function Ch(u,e){return u.replace("{projectId}",e).replace("{uuid}",kh().replace(/-/g,""))}async function Nl(u){const e={...u.config??(u.configUrl?await Ll(u.configUrl,u.configHeaders):{}),...u.overrides??{}},t=e.transport??"tiledesk",i=e.tiledesk;if((t==="tiledesk"||t==="dual")&&!i)throw new Error("mount: descriptor.tiledesk is required for tiledesk/dual transport");const l=i?.projectId??"",r=u.identity.userId,n=u.forceNewConversation?null:xh(r,l),s=i?.requestIdTemplate??"support-group-{projectId}-{uuid}",o=u.conversationId??n??Ch(s,l);(!n||u.forceNewConversation)&&l&&Ah(r,l,o);const a=await u.tokenProvider(),c=u.tokenProvider,d=u.historyTokenProvider??c,p=i?{mqttEndpoint:i.mqttEndpoint,jwtToken:a,userId:r,userName:u.identity.userName,projectId:i.projectId,appId:i.appId,mqttUsername:i.mqttUsername,protocolId:i.protocolId,protocolVersion:i.protocolVersion,keepAliveSec:i.keepAliveSec,connectTimeoutMs:i.connectTimeoutMs,maxReconnectAttempts:i.maxReconnectAttempts,reconnectMaxDelayMs:i.reconnectMaxDelayMs,wildcardSubscribe:i.wildcardSubscribe,enablePresence:i.enablePresence,autoInitiateOnEmpty:i.autoInitiateOnEmpty,chatInitiatedAttributes:i.chatInitiatedAttributes,messageDefaults:{...i.messageDefaults,...u.identity.departmentId?{departmentId:u.identity.departmentId}:i.messageDefaults?.departmentId?{departmentId:i.messageDefaults.departmentId}:{}},fileTemplate:i.fileTemplate,topicTemplates:i.topicTemplates,debug:i.debug,senderFullname:u.identity.senderFullname??u.identity.userName,tokenProvider:c}:void 0,b=u.uploadAdapter??(e.uploadEndpoint?ao({endpoint:e.uploadEndpoint,fieldName:e.uploadFieldName,extraFields:e.uploadExtraFields}):void 0),f=u.historyAdapter??(e.historyApiBase?dl({apiBase:e.historyApiBase,pageSize:e.historyPageSize??200,pathTemplate:e.historyPathTemplate,extraHeaders:e.historyHeaders,getToken:d}):void 0),m={transport:t,baseUrl:"",userToken:r,conversationId:o,display:e.display??"embed",position:e.position,primaryColor:e.theme?.primary??e.primaryColor,title:e.title,subtitle:e.subtitle,avatarUrl:e.avatarUrl,width:e.width,height:e.height,borderRadius:e.theme?.radius??e.borderRadius,fontFamily:e.theme?.font??e.fontFamily,themeTokens:e.theme,linkHandlers:e.linkHandlers,getLinkBearer:u.getLinkBearer,welcomeMessage:e.welcomeMessage,placeholder:e.placeholder,showTimestamps:e.showTimestamps,persistConversation:e.persistConversation,tiledesk:p,tiledeskIdentity:{userId:r,userName:u.identity.userName,departmentId:u.identity.departmentId,senderFullname:u.identity.senderFullname??u.identity.userName},templateActionAttributes:e.templateActionAttributes,uploadAdapter:b,historyAdapter:f,onError:u.onError},y=document.createElement("aikaara-chat-widget");return y.configure(m),m.title&&y.setAttribute("title",m.title),m.primaryColor&&y.setAttribute("primary-color",m.primaryColor),m.display&&y.setAttribute("display",m.display),m.display==="embed"&&(y.style.cssText="display:flex;flex-direction:column;width:100%;height:100%;min-height:0;"),u.container.appendChild(y),{widget:y,requestId:o,config:m,destroy(){y.remove()}}}function Oh(u){if(typeof u!="string")return u;const e=document.querySelector(u);if(!e)throw new Error(`mountFromSlug: container "${u}" not found`);return e}async function Ul(u){const t=`${(u.configBase??"https://api.aikaara.com").replace(/\/$/,"")}/widget_configs/${encodeURIComponent(u.slug)}`;let i=null;try{i=await Ll(t,u.configHeaders)}catch(p){if(!u.fallbackConfig)throw p;console.warn(`[aikaara-chat-sdk] Widget config fetch failed for slug "${u.slug}" — using fallbackConfig.`,p)}const l={...u.fallbackConfig??{},...i??{},...u.overrides??{}};if(window.__aikaara_descriptor__={templates:l.templates},!l.auth)throw new Error(`mountFromSlug: widget_configs/${u.slug} descriptor must include "auth" block`);l.preflight&&l.preflight.length&&await Th(l.preflight,{sessionToken:u.user.token,userId:u.user.id,projectId:l.tiledesk?.projectId??"",slug:u.slug});const r=new jl(l.auth,u.user.token),n=await r.get(),s=n.fullName||u.user.name||u.user.id,o=l.upload,a=async()=>`Bearer ${o&&"tokenSource"in o&&o.tokenSource==="chat"?(await r.get()).token:await Cr(u.user.token)}`,c=u.hooks?.upload??(o&&o.mode==="presigned-3step"?fl({...o,authHeader:a}):o&&o.mode==="direct"?ao({endpoint:o.endpoint,fieldName:o.fieldName,extraFields:o.extraFields,headers:async()=>({authorization:await a()})}):void 0),d=await Nl({container:Oh(u.container),config:l,identity:{userId:u.user.id,userName:s,departmentId:u.user.departmentId,senderFullname:s},tokenProvider:async()=>(await r.get()).token,historyTokenProvider:async()=>(await r.get()).token,uploadAdapter:c,historyAdapter:u.hooks?.history,conversationId:n.requestId,onError:u.hooks?.onError,getLinkBearer:async p=>p==="none"?null:p==="chat"?(await r.get()).token:Cr(u.user.token)});return Object.assign(d,{fullName:s,requestId:n.requestId,async refreshAuth(){r.reset(),await r.get()}})}exports.ActionCableClient=zr;exports.AikaaraChat=Ol;exports.AikaaraChatBubble=gl;exports.AikaaraChatClient=hl;exports.AikaaraChatHeader=ml;exports.AikaaraChatInput=_l;exports.AikaaraChatWidget=pl;exports.AikaaraComparePlans=Ml;exports.AikaaraErrorBanner=El;exports.AikaaraLinkModal=Pl;exports.AikaaraMessageBubble=wl;exports.AikaaraMessageList=yl;exports.AikaaraModalAction=Cl;exports.AikaaraOptionList=Il;exports.AikaaraStreamingMessage=kl;exports.AikaaraSubmitAction=Tl;exports.AikaaraSystemPill=Al;exports.AikaaraTemplateRenderer=xl;exports.AikaaraTypingIndicator=Sl;exports.ApiClient=Is;exports.ChannelSubscription=xs;exports.ConnectionManager=As;exports.ConversationManager=Cs;exports.EventEmitter=zi;exports.MessageStore=Ts;exports.SessionAuthAdapter=jl;exports.TiledeskTransport=al;exports.clearPersistedConversationId=Ih;exports.createFetchUploadAdapter=ao;exports.createPresigned3StepUploadAdapter=fl;exports.createTiledeskHistoryAdapter=dl;exports.extractTiledeskFileEnvelope=cl;exports.inferTiledeskRole=ul;exports.isTiledeskSelfEcho=ll;exports.mount=Nl;exports.mountFromSlug=Ul;exports.parseTiledeskTemplate=so;exports.registerComponents=Rl;
965
+ `,this.shadow.querySelectorAll("button.action").forEach(i=>{i.addEventListener("click",()=>{const l=Number(i.dataset.col),r=e[l];r&&this.dispatchEvent(new CustomEvent("aikaara-plan-select",{detail:{planType:r.match[0],message:r.postback,label:r.label},bubbles:!0,composed:!0}))})})}}function qr(u){return u.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e])}function Rl(){const u=[["aikaara-chat-widget",pl],["aikaara-chat-bubble",gl],["aikaara-chat-header",ml],["aikaara-message-list",yl],["aikaara-message-bubble",wl],["aikaara-chat-input",_l],["aikaara-typing-indicator",Sl],["aikaara-streaming-message",kl],["aikaara-error-banner",El],["aikaara-template-renderer",xl],["aikaara-system-pill",Al],["aikaara-option-list",Il],["aikaara-submit-action",Tl],["aikaara-modal-action",Cl],["aikaara-chat",Ol],["aikaara-link-modal",Pl],["aikaara-compare-plans",Ml]];for(const[e,t]of u)customElements.get(e)||customElements.define(e,t)}Rl();function Hr(u,e,t=""){if(!e)return t;const i=e.split(".");let l=u;for(const r of i)if(l&&typeof l=="object"&&r in l)l=l[r];else return t;return typeof l=="string"?l:t}function Eh(u){try{const e=u.split(".")[1];if(!e)return 0;const t=JSON.parse(atob(e.replace(/-/g,"+").replace(/_/g,"/")));return typeof t.exp=="number"?t.exp*1e3:0}catch{return 0}}async function Cr(u){return typeof u=="function"?await u():u}class jl{constructor(e,t){this.descriptor=e,this.sessionToken=t}cache=null;inflight=null;reset(){this.cache=null,this.inflight=null}async get(){const e=this.descriptor.expiryBufferMs??6e4,t=Date.now();return this.cache&&this.cache.expiresAt>t+e?this.cache:this.inflight?this.inflight:(this.inflight=this.fetchOnce().finally(()=>{this.inflight=null}),this.inflight)}async fetchOnce(){const e=await Cr(this.sessionToken),t=this.descriptor.authHeader??"Authorization",i=this.descriptor.authHeaderTemplate??"Bearer {token}",l={accept:"application/json",...this.descriptor.headers??{},[t]:i.replace("{token}",e)},r=this.descriptor.method??"POST",n={method:r,headers:l};r==="POST"&&(l["content-type"]="application/json",n.body=JSON.stringify(this.descriptor.body??{}));const s=await fetch(this.descriptor.endpoint,n);if(!s.ok){const y=await s.text().catch(()=>"");throw new Error(`Session auth failed: ${s.status} ${y.slice(0,200)}`)}const o=await s.json().catch(()=>({})),a=Hr(o,this.descriptor.tokenPath??"data.token"),c=this.descriptor.tokenStripPrefix,d=c?a.replace(new RegExp(`^${c}`,"i"),"").trim():a;if(!d)throw new Error("Session auth response missing token");const p=Hr(o,this.descriptor.requestIdPath??"data.requestId"),b=this.cache?.requestId||p;if(!b)throw new Error("Session auth response missing requestId");const f=Hr(o,this.descriptor.fullNamePath??"data.fullName"),m=Eh(d)||Date.now()+3600*1e3;return this.cache={token:d,requestId:b,fullName:f,expiresAt:m},this.cache}}function xh(){const u=typeof crypto<"u"?crypto:null;if(u?.randomUUID)return u.randomUUID();if(u?.getRandomValues){const e=new Uint8Array(16);u.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;const t=[...e].map(i=>i.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}const Ah="aikaara_chat:requestId";function lo(u,e){return`${Ah}:${u}:${e}`}function Ih(u,e){try{return localStorage.getItem(lo(u,e))}catch{return null}}function Th(u,e,t){try{localStorage.setItem(lo(u,e),t)}catch{}}function Ch(u,e){try{localStorage.removeItem(lo(u,e))}catch{}}async function Oh(u,e){console.log("[aikaara-chat-sdk] preflight running",u.length,"steps");const t={userId:e.userId,projectId:e.projectId,slug:e.slug},i=r=>r.replace(/\{(\w+)\}/g,(n,s)=>t[s]??""),l=await Cr(e.sessionToken);for(let r=0;r<u.length;r++){const n=u[r],s=i(n.url),o=n.method??(n.body?"POST":"GET"),a={accept:"application/json",...n.headers??{}};if((n.authHeader??"session")==="session"){const d=n.authHeaderTemplate??"Bearer {token}";a.authorization=d.replace("{token}",l)}const c={method:o,headers:a};n.body&&(a["content-type"]="application/json",c.body=JSON.stringify(n.body));try{const d=await fetch(s,c);if(!d.ok){const p=await d.text().catch(()=>""),b=`Preflight #${r} ${o} ${s} → ${d.status} ${p.slice(0,200)}`;if(n.soft)console.warn("[aikaara-chat-sdk]",b);else throw new Error(b)}}catch(d){if(n.soft){console.warn(`[aikaara-chat-sdk] preflight #${r} soft-failed:`,d);continue}throw d}}}async function Ll(u,e){const t=await fetch(u,{method:"GET",headers:{accept:"application/json",...e??{}}});if(!t.ok){const l=await t.text().catch(()=>"");throw new Error(`Widget config fetch failed: ${t.status} ${t.statusText} ${l.slice(0,200)}`)}const i=await t.json();if(i&&typeof i=="object"){if("config"in i)return i.config;if("data"in i)return i.data}return i}function Ph(u,e){return u.replace("{projectId}",e).replace("{uuid}",xh().replace(/-/g,""))}async function Nl(u){const e={...u.config??(u.configUrl?await Ll(u.configUrl,u.configHeaders):{}),...u.overrides??{}},t=e.transport??"tiledesk",i=e.tiledesk;if((t==="tiledesk"||t==="dual")&&!i)throw new Error("mount: descriptor.tiledesk is required for tiledesk/dual transport");const l=i?.projectId??"",r=u.identity.userId,n=u.forceNewConversation?null:Ih(r,l),s=i?.requestIdTemplate??"support-group-{projectId}-{uuid}",o=u.conversationId??n??Ph(s,l);(!n||u.forceNewConversation)&&l&&Th(r,l,o);const a=await u.tokenProvider(),c=u.tokenProvider,d=u.historyTokenProvider??c,p=i?{mqttEndpoint:i.mqttEndpoint,jwtToken:a,userId:r,userName:u.identity.userName,projectId:i.projectId,appId:i.appId,mqttUsername:i.mqttUsername,protocolId:i.protocolId,protocolVersion:i.protocolVersion,keepAliveSec:i.keepAliveSec,connectTimeoutMs:i.connectTimeoutMs,maxReconnectAttempts:i.maxReconnectAttempts,reconnectMaxDelayMs:i.reconnectMaxDelayMs,wildcardSubscribe:i.wildcardSubscribe,enablePresence:i.enablePresence,autoInitiateOnEmpty:i.autoInitiateOnEmpty,chatInitiatedAttributes:i.chatInitiatedAttributes,messageDefaults:{...i.messageDefaults,...u.identity.departmentId?{departmentId:u.identity.departmentId}:i.messageDefaults?.departmentId?{departmentId:i.messageDefaults.departmentId}:{}},fileTemplate:i.fileTemplate,topicTemplates:i.topicTemplates,debug:i.debug,senderFullname:u.identity.senderFullname??u.identity.userName,tokenProvider:c}:void 0,b=u.uploadAdapter??(e.uploadEndpoint?ao({endpoint:e.uploadEndpoint,fieldName:e.uploadFieldName,extraFields:e.uploadExtraFields}):void 0),f=u.historyAdapter??(e.historyApiBase?dl({apiBase:e.historyApiBase,pageSize:e.historyPageSize??200,pathTemplate:e.historyPathTemplate,extraHeaders:e.historyHeaders,getToken:d}):void 0),m={transport:t,baseUrl:"",userToken:r,conversationId:o,display:e.display??"embed",position:e.position,primaryColor:e.theme?.primary??e.primaryColor,title:e.title,subtitle:e.subtitle,avatarUrl:e.avatarUrl,width:e.width,height:e.height,borderRadius:e.theme?.radius??e.borderRadius,fontFamily:e.theme?.font??e.fontFamily,themeTokens:e.theme,linkHandlers:e.linkHandlers,getLinkBearer:u.getLinkBearer,welcomeMessage:e.welcomeMessage,placeholder:e.placeholder,showTimestamps:e.showTimestamps,persistConversation:e.persistConversation,tiledesk:p,tiledeskIdentity:{userId:r,userName:u.identity.userName,departmentId:u.identity.departmentId,senderFullname:u.identity.senderFullname??u.identity.userName},templateActionAttributes:e.templateActionAttributes,uploadAdapter:b,historyAdapter:f,onError:u.onError},y=document.createElement("aikaara-chat-widget");return y.configure(m),m.title&&y.setAttribute("title",m.title),m.primaryColor&&y.setAttribute("primary-color",m.primaryColor),m.display&&y.setAttribute("display",m.display),m.display==="embed"&&(y.style.cssText="display:flex;flex-direction:column;width:100%;height:100%;min-height:0;"),u.container.appendChild(y),{widget:y,requestId:o,config:m,destroy(){y.remove()}}}function Mh(u){if(typeof u!="string")return u;const e=document.querySelector(u);if(!e)throw new Error(`mountFromSlug: container "${u}" not found`);return e}async function Ul(u){const t=`${(u.configBase??"https://api.aikaara.com").replace(/\/$/,"")}/widget_configs/${encodeURIComponent(u.slug)}`;let i=null;try{i=await Ll(t,u.configHeaders)}catch(p){if(!u.fallbackConfig)throw p;console.warn(`[aikaara-chat-sdk] Widget config fetch failed for slug "${u.slug}" — using fallbackConfig.`,p)}const l={...u.fallbackConfig??{},...i??{},...u.overrides??{}};if(window.__aikaara_descriptor__={templates:l.templates},!l.auth)throw new Error(`mountFromSlug: widget_configs/${u.slug} descriptor must include "auth" block`);l.preflight&&l.preflight.length&&await Oh(l.preflight,{sessionToken:u.user.token,userId:u.user.id,projectId:l.tiledesk?.projectId??"",slug:u.slug});const r=new jl(l.auth,u.user.token),n=await r.get(),s=n.fullName||u.user.name||u.user.id,o=l.upload,a=async()=>`Bearer ${o&&"tokenSource"in o&&o.tokenSource==="chat"?(await r.get()).token:await Cr(u.user.token)}`,c=u.hooks?.upload??(o&&o.mode==="presigned-3step"?fl({...o,authHeader:a}):o&&o.mode==="direct"?ao({endpoint:o.endpoint,fieldName:o.fieldName,extraFields:o.extraFields,headers:async()=>({authorization:await a()})}):void 0),d=await Nl({container:Mh(u.container),config:l,identity:{userId:u.user.id,userName:s,departmentId:u.user.departmentId,senderFullname:s},tokenProvider:async()=>(await r.get()).token,historyTokenProvider:async()=>(await r.get()).token,uploadAdapter:c,historyAdapter:u.hooks?.history,conversationId:n.requestId,onError:u.hooks?.onError,getLinkBearer:async p=>p==="none"?null:p==="chat"?(await r.get()).token:Cr(u.user.token)});return Object.assign(d,{fullName:s,requestId:n.requestId,async refreshAuth(){r.reset(),await r.get()}})}exports.ActionCableClient=zr;exports.AikaaraChat=Ol;exports.AikaaraChatBubble=gl;exports.AikaaraChatClient=hl;exports.AikaaraChatHeader=ml;exports.AikaaraChatInput=_l;exports.AikaaraChatWidget=pl;exports.AikaaraComparePlans=Ml;exports.AikaaraErrorBanner=El;exports.AikaaraLinkModal=Pl;exports.AikaaraMessageBubble=wl;exports.AikaaraMessageList=yl;exports.AikaaraModalAction=Cl;exports.AikaaraOptionList=Il;exports.AikaaraStreamingMessage=kl;exports.AikaaraSubmitAction=Tl;exports.AikaaraSystemPill=Al;exports.AikaaraTemplateRenderer=xl;exports.AikaaraTypingIndicator=Sl;exports.ApiClient=Is;exports.ChannelSubscription=xs;exports.ConnectionManager=As;exports.ConversationManager=Cs;exports.EventEmitter=zi;exports.MessageStore=Ts;exports.SessionAuthAdapter=jl;exports.TiledeskTransport=al;exports.clearPersistedConversationId=Ch;exports.createFetchUploadAdapter=ao;exports.createPresigned3StepUploadAdapter=fl;exports.createTiledeskHistoryAdapter=dl;exports.extractTiledeskFileEnvelope=cl;exports.inferTiledeskRole=ul;exports.isTiledeskSelfEcho=ll;exports.mount=Nl;exports.mountFromSlug=Ul;exports.parseTiledeskTemplate=so;exports.registerComponents=Rl;