@aikaara/chat-sdk 1.1.6 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{MountTenant-qcl3eez7.mjs → MountTenant-8zB0FoEP.mjs} +5 -1
- package/dist/{MountTenant-5d4HXHTv.cjs → MountTenant-CP_CYdl8.cjs} +4 -1
- package/dist/cdn/aikaara-chat.iife.js +4 -1
- package/dist/headless.cjs +1 -1
- package/dist/headless.mjs +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +2 -2
- package/dist/ui.cjs +1 -1
- package/dist/ui.mjs +1 -1
- package/package.json +1 -1
|
@@ -13154,6 +13154,9 @@ class Jh extends HTMLElement {
|
|
|
13154
13154
|
opacity: 0.8;
|
|
13155
13155
|
transition: opacity 200ms, background 200ms;
|
|
13156
13156
|
}
|
|
13157
|
+
.close-btn {
|
|
13158
|
+
display: var(--aikaara-close-btn-display, flex);
|
|
13159
|
+
}
|
|
13157
13160
|
.icon-btn:hover {
|
|
13158
13161
|
opacity: 1;
|
|
13159
13162
|
background: rgba(255,255,255,0.12);
|
|
@@ -16591,7 +16594,7 @@ async function sf(l) {
|
|
|
16591
16594
|
onError: l.onError,
|
|
16592
16595
|
onMessage: l.onMessage
|
|
16593
16596
|
}, y = document.createElement("aikaara-chat-widget");
|
|
16594
|
-
return y.configure(g), g.title && y.setAttribute("title", g.title), g.primaryColor && y.setAttribute("primary-color", g.primaryColor), g.display && y.setAttribute("display", g.display), g.display === "embed" && (y.style.cssText = "display:flex;flex-direction:column;width:100%;height:100%;min-height:0;"), l.container.appendChild(y), {
|
|
16597
|
+
return y.configure(g), g.title && y.setAttribute("title", g.title), g.primaryColor && y.setAttribute("primary-color", g.primaryColor), g.display && y.setAttribute("display", g.display), g.display === "embed" && (y.style.cssText = "display:flex;flex-direction:column;width:100%;height:100%;min-height:0;--aikaara-close-btn-display:none;"), l.container.appendChild(y), {
|
|
16595
16598
|
widget: y,
|
|
16596
16599
|
requestId: a,
|
|
16597
16600
|
config: g,
|
|
@@ -16693,6 +16696,7 @@ async function lf(l) {
|
|
|
16693
16696
|
const I = f;
|
|
16694
16697
|
u = () => I;
|
|
16695
16698
|
}
|
|
16699
|
+
x.captured.userId && (o = x.captured.userId);
|
|
16696
16700
|
}
|
|
16697
16701
|
const g = new jd(s.auth, u);
|
|
16698
16702
|
if (f) {
|
|
@@ -229,6 +229,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
229
229
|
opacity: 0.8;
|
|
230
230
|
transition: opacity 200ms, background 200ms;
|
|
231
231
|
}
|
|
232
|
+
.close-btn {
|
|
233
|
+
display: var(--aikaara-close-btn-display, flex);
|
|
234
|
+
}
|
|
232
235
|
.icon-btn:hover {
|
|
233
236
|
opacity: 1;
|
|
234
237
|
background: rgba(255,255,255,0.12);
|
|
@@ -1455,4 +1458,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1455
1458
|
}
|
|
1456
1459
|
.save-btn:hover { filter: brightness(1.07); }
|
|
1457
1460
|
.save-btn:active { filter: brightness(0.95); }
|
|
1458
|
-
`}}function St(l){return l.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Ye(l){return l.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function oc(){const l=[["aikaara-chat-widget",Ul],["aikaara-chat-bubble",Bl],["aikaara-chat-header",Dl],["aikaara-message-list",$l],["aikaara-message-bubble",Hl],["aikaara-chat-input",Wl],["aikaara-typing-indicator",zl],["aikaara-streaming-message",Vl],["aikaara-error-banner",Gl],["aikaara-template-renderer",Yl],["aikaara-system-pill",Ql],["aikaara-option-list",Jl],["aikaara-submit-action",Xl],["aikaara-modal-action",Zl],["aikaara-chat",ec],["aikaara-link-modal",tc],["aikaara-compare-plans",rc],["aikaara-smart-edit-modal",nc],["aikaara-schema-form",ic]];for(const[e,t]of l)customElements.get(e)||customElements.define(e,t)}oc();function lr(l,e,t=""){if(!e)return t;const r=e.split(".");let s=l;for(const n of r)if(s&&typeof s=="object"&&n in s)s=s[n];else return t;return typeof s=="string"?s:t}function qs(l){try{const e=l.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 Zt(l){return typeof l=="function"?await l():l}class sc{constructor(e,t){this.descriptor=e,this.sessionToken=t}cache=null;inflight=null;reset(){this.cache=null,this.inflight=null}prime(e,t={}){if(!e)return;const r=qs(e)||Date.now()+3600*1e3;this.cache={token:e,requestId:t.requestId??this.cache?.requestId??"",fullName:t.fullName??this.cache?.fullName??"",userId:t.userId??this.cache?.userId??"",expiresAt:r}}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 Zt(this.sessionToken),t=this.descriptor.authHeader??"Authorization",r=this.descriptor.authHeaderTemplate??"Bearer {token}",s={accept:"application/json",...this.descriptor.headers??{},[t]:r.replace("{token}",e)},n=this.descriptor.method??"POST",i={method:n,headers:s};n==="POST"&&(s["content-type"]="application/json",i.body=JSON.stringify(this.descriptor.body??{}));const o=await fetch(this.descriptor.endpoint,i);if(!o.ok){const k=await o.text().catch(()=>"");throw new Error(`Session auth failed: ${o.status} ${k.slice(0,200)}`)}const a=await o.json().catch(()=>({})),c=lr(a,this.descriptor.tokenPath??"data.token"),u=this.descriptor.tokenStripPrefix,h=u?c.replace(new RegExp(`^${u}`,"i"),"").trim():c;if(!h)throw new Error("Session auth response missing token");const p=lr(a,this.descriptor.requestIdPath??"data.requestId"),b=this.cache?.requestId||p||"",f=lr(a,this.descriptor.fullNamePath??"data.fullName"),g=lr(a,this.descriptor.userPath??"data.userId"),y=qs(h)||Date.now()+3600*1e3;return this.cache={token:h,requestId:b,fullName:f,userId:g,expiresAt:y},this.cache}}async function ac(l){const e={};for(const t of l.spec){const r=await qd(t,l.providers);if(r!==void 0&&r!=="")e[t.name]=r;else{if(t.required)throw new Error(`[aikaara-chat-sdk] SSO credential "${t.name}" is required but ${t.source}`+(t.key?`[${t.key}]`:"")+" returned no value");t.default!==void 0&&(e[t.name]=t.default)}}return e}async function qd(l,e){const t=l.key??l.name;switch(l.source){case"cookie":return Hd(t);case"localStorage":return cr(()=>window.localStorage.getItem(t)??void 0);case"sessionStorage":return cr(()=>window.sessionStorage.getItem(t)??void 0);case"url_param":return cr(()=>new URL(window.location.href).searchParams.get(t)??void 0);case"header_meta":return cr(()=>document.querySelector(`meta[name="${Wd(t)}"]`)?.content??void 0);case"callback":{const r=e?.[l.name];if(!r)return;const s=await r();return typeof s=="string"?s:void 0}default:return}}function Hd(l){if(typeof document>"u")return;const e=encodeURIComponent(l),t=document.cookie?document.cookie.split("; "):[];for(const r of t){const s=r.indexOf("=");if(s===-1)continue;const n=r.slice(0,s);if(n===l||n===e)try{return decodeURIComponent(r.slice(s+1))}catch{return r.slice(s+1)}}}function cr(l){try{return l()}catch{return}}function Wd(l){return l.replace(/["\\]/g,"\\$&")}const zd=1800;class lc{constructor(e){this.opts=e,this.cache=this.loadCache()}cache=null;inflight=null;reset(){this.cache=null,this.inflight=null,this.clearCache()}async get(e=!1){if(!e){const t=this.cache;if(t&&(!t.expiresAt||t.expiresAt>Date.now()))return t}return this.inflight?this.inflight:(this.inflight=this.exchange().finally(()=>{this.inflight=null}),this.inflight)}async exchange(){if(!this.opts.descriptor.collect||this.opts.descriptor.collect.length===0)throw new Error("[aikaara-chat-sdk] SsoExchangeAdapter.exchange() requires descriptor.sso.collect; v2 partner-token flow should be handled by TokenDiscoveryReader instead.");const e=await ac({spec:this.opts.descriptor.collect,providers:this.opts.providers}),t=JSON.stringify({credentials:e}),r={accept:"application/json","content-type":"application/json",...this.opts.descriptor.headers??{}};this.opts.descriptor.apiKey&&(r["X-Api-Key"]=this.opts.descriptor.apiKey);const s=this.opts.descriptor.exchangeEndpoint||this.opts.exchangeUrl;if(!s)throw new Error("[aikaara-chat-sdk] SSO exchange URL not resolved — set descriptor.sso.exchangeEndpoint or pass `exchangeUrl` (mountFromSlug derives it from configBase + slug).");const n=await fetch(s,{method:"POST",headers:r,body:t});if(!n.ok){const h=await n.text().catch(()=>"");throw new Error(`SSO exchange failed: ${n.status} ${h.slice(0,240)}`)}const o=(await n.json().catch(()=>({}))).user??{},a=String(o.ext_uid??o.extUid??""),c=String(o.token??o.user_token??o.userToken??"");if(!a)throw new Error("SSO exchange response missing user.ext_uid");if(!c)throw new Error("SSO exchange response missing user.token");const u={id:o.id,extUid:a,userToken:c,email:typeof o.email=="string"?o.email:void 0,displayName:typeof o.display_name=="string"?o.display_name:typeof o.displayName=="string"?o.displayName:void 0,properties:o.properties&&typeof o.properties=="object"?o.properties:void 0,expiresAt:this.computeExpiry()};return this.cache=u,this.persistCache(u),u}computeExpiry(){const e=this.opts.descriptor.cacheTtlSec??zd;if(!(!this.opts.descriptor.cacheKey||e<=0))return Date.now()+e*1e3}loadCache(){const e=this.opts.descriptor.cacheKey;if(!e)return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const r=JSON.parse(t);return r.expiresAt&&r.expiresAt<Date.now()?(window.localStorage.removeItem(e),null):r}catch{return null}}persistCache(e){const t=this.opts.descriptor.cacheKey;if(t)try{window.localStorage.setItem(t,JSON.stringify(e))}catch{}}clearCache(){const e=this.opts.descriptor.cacheKey;if(e)try{window.localStorage.removeItem(e)}catch{}}}const Vd=3e4,Gd=2e3,Kd=100;async function cc(l){const{descriptor:e}=l,t=e.tokenSourceConfig??{};switch(e.tokenSource){case"init":{if(!l.initToken)throw new Ke("init","No init token supplied to Aikaara.init({token})");return{token:l.initToken,source:"init"}}case"query":{const r=typeof t.key=="string"&&t.key?t.key:"token",s=Yd(r);if(!s)throw new Ke("query",`?${r}= not present`);return{token:s,source:"query"}}case"hash":{const r=typeof t.key=="string"&&t.key?t.key:"token",s=Qd(r);if(!s)throw new Ke("hash",`#${r}= not present`);return{token:s,source:"hash"}}case"postmsg":{const r=typeof t.type=="string"?t.type:"",s=typeof t.key=="string"&&t.key?t.key:"token",n=tf(typeof t.origins=="string"?t.origins:""),i=typeof t.timeoutMs=="number"&&t.timeoutMs>0?t.timeoutMs:Vd;return{token:await ef({type:r,key:s,origins:n,timeoutMs:i}),source:"postmsg"}}case"cookie":{const r=typeof t.name=="string"&&t.name?t.name:"";if(!r)throw new Ke("cookie","cookie.name not configured");const s=Jd(r);if(!s)throw new Ke("cookie",`cookie "${r}" not set`);return{token:s,source:"cookie"}}case"storage":{const r=t.store==="session"?"session":"local",s=typeof t.key=="string"&&t.key?t.key:"",n=typeof t.path=="string"?t.path:"";if(!s)throw new Ke("storage","storage.key not configured");const i=Xd(r,s,n);if(!i)throw new Ke("storage",`${r}Storage["${s}"] not set`);return{token:i,source:"storage"}}case"global":{const r=typeof t.path=="string"?t.path:"";if(!r)throw new Ke("global","global.path not configured");const s=typeof t.timeoutMs=="number"&&t.timeoutMs>0?t.timeoutMs:Gd,n=typeof t.intervalMs=="number"&&t.intervalMs>0?t.intervalMs:Kd,i=await Zd(r,s,n);if(!i)throw new Ke("global",`window.${r} not present`);return{token:i,source:"global"}}default:{const r=e.tokenSource;throw new Ke("unknown",`Unknown tokenSource ${JSON.stringify(r)}`)}}}class uc{constructor(e){this.opts=e}cached=null;get descriptor(){return this.opts.descriptor}async get(){if(this.cached)return this.cached;const e=await cc(this.opts);return this.cached=e,e}async refresh(){return this.opts.descriptor.tokenSource==="init"?this.cached?this.cached:this.get():(this.cached=null,this.get())}}class Ke extends Error{constructor(e,t){super(`[aikaara-chat-sdk] token-discovery (${e}): ${t}`),this.source=e,this.name="TokenDiscoveryError"}}function Yd(l){if(!(typeof window>"u"))try{return new URL(window.location.href).searchParams.get(l)??void 0}catch{return}}function Qd(l){if(!(typeof window>"u"))try{const e=window.location.hash.replace(/^#/,"");return new URLSearchParams(e).get(l)??void 0}catch{return}}function Jd(l){if(typeof document>"u")return;const e=encodeURIComponent(l),t=document.cookie?document.cookie.split("; "):[];for(const r of t){const s=r.indexOf("=");if(s===-1)continue;const n=r.slice(0,s);if(n===l||n===e)try{return decodeURIComponent(r.slice(s+1))}catch{return r.slice(s+1)}}}function Xd(l,e,t){if(!(typeof window>"u"))try{const s=(l==="session"?window.sessionStorage:window.localStorage).getItem(e);if(s==null)return;if(!t)return s;let n;try{n=JSON.parse(s)}catch{return s}const i=hc(n,t);return typeof i=="string"?i:void 0}catch{return}}async function Zd(l,e,t){if(typeof window>"u")return;const r=Date.now()+e;for(;Date.now()<r;){const s=hc(window,l);if(typeof s=="string"&&s.length>0)return s;if(typeof s=="function")try{const n=s();if(typeof n=="string"&&n.length>0)return n}catch{}await new Promise(n=>setTimeout(n,t))}}function ef(l){return new Promise((e,t)=>{if(typeof window>"u"){t(new Ke("postmsg","no window"));return}const r=()=>{window.removeEventListener("message",n),clearTimeout(s)},s=setTimeout(()=>{r(),t(new Ke("postmsg",`timeout after ${l.timeoutMs}ms`))},l.timeoutMs),n=i=>{if(l.origins.length>0&&!l.origins.includes(i.origin))return;const o=i.data;if(!o||typeof o!="object")return;const a=o;if(l.type&&a.type!==l.type)return;const c=a[l.key];typeof c=="string"&&c.length>0&&(r(),e(c))};window.addEventListener("message",n)})}function tf(l){return l?l.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean):[]}function hc(l,e){if(!e)return l;const t=e.split(".").filter(Boolean);let r=l;for(const s of t)if(r&&typeof r=="object"&&s in r)r=r[s];else return;return r}function rf(){const l=typeof crypto<"u"?crypto:null;if(l?.randomUUID)return l.randomUUID();if(l?.getRandomValues){const e=new Uint8Array(16);l.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;const t=[...e].map(r=>r.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 nf="aikaara_chat:requestId";function vo(l,e){return`${nf}:${l}:${e}`}function dc(l,e){try{return localStorage.getItem(vo(l,e))}catch{return null}}function of(l,e,t){try{localStorage.setItem(vo(l,e),t)}catch{}}function sf(l,e){try{localStorage.removeItem(vo(l,e))}catch{}}async function af(l,e){console.log("[aikaara-chat-sdk] preflight running",l.length,"steps");const t={userId:e.userId,projectId:e.projectId,slug:e.slug};if(e.identity)for(const[a,c]of Object.entries(e.identity))typeof c=="string"&&(t[a]=c);const r=a=>a.replace(/\{(\w+)\}/g,(c,u)=>u in t?t[u]:""),s=a=>{if(typeof a=="string")return r(a);if(Array.isArray(a))return a.map(s);if(a&&typeof a=="object"){const c={};for(const[u,h]of Object.entries(a))c[u]=s(h);return c}return a},n=await Zt(e.sessionToken),i={},o=[800,1500,3e3,5e3,8e3];for(let a=0;a<l.length;a++){const c=l[a],u=r(c.url),h=c.method??(c.body?"POST":"GET"),p={accept:"application/json",...c.headers??{}};if((c.authHeader??"session")==="session"){const m=c.authHeaderTemplate??"Bearer {token}";p.authorization=m.replace("{token}",n)}const b={method:h,headers:p};c.body&&(p["content-type"]="application/json",b.body=JSON.stringify(s(c.body)));let f=0,g="",y=0,k=null;for(;;)try{const m=await fetch(u,b);if(m.ok){k=m;break}if(f=m.status,g=await m.text().catch(()=>""),y<o.length&&lf(f,g)){const S=o[y++];console.warn(`[aikaara-chat-sdk] preflight #${a} ${h} ${u} → ${f} (transient). Retry #${y} in ${S}ms.`),await new Promise(v=>setTimeout(v,S));continue}const w=`Preflight #${a} ${h} ${u} → ${f} ${g.slice(0,200)}`;if(c.soft){console.warn("[aikaara-chat-sdk]",w);break}throw new Error(w)}catch(m){if(y<o.length){const w=o[y++];console.warn(`[aikaara-chat-sdk] preflight #${a} threw, retry #${y} in ${w}ms`,m),await new Promise(S=>setTimeout(S,w));continue}if(c.soft){console.warn(`[aikaara-chat-sdk] preflight #${a} soft-failed:`,m);break}throw m}if(k&&c.capture&&c.capture.as)try{const m=await k.clone().text();let w=m;try{w=JSON.parse(m)}catch{}if(c.capture.path)for(const S of c.capture.path.split("."))if(w&&typeof w=="object"&&S in w)w=w[S];else{w=void 0;break}if(typeof w=="string"&&w.length>0){let S=w;c.capture.stripPrefix&&S.startsWith(c.capture.stripPrefix)&&(S=S.slice(c.capture.stripPrefix.length)),i[c.capture.as]=S,t[c.capture.as]=S,console.log(`[aikaara-chat-sdk] preflight #${a} captured ${c.capture.as} (${S.slice(0,24)}…)`)}}catch(m){console.warn(`[aikaara-chat-sdk] preflight #${a} capture failed`,m)}}return{captured:i}}function lf(l,e){if(l===503||l===504||l===502)return!0;if(l===401||l===403)return e.trim().length===0;if(l===500){const t=e.toLowerCase();return t.includes("customernew")||t.includes("is null")||t.includes("not yet ready")}return!1}async function fc(l,e){const t=await fetch(l,{method:"GET",headers:{accept:"application/json",...e??{}}});if(!t.ok){const s=await t.text().catch(()=>"");throw new Error(`Widget config fetch failed: ${t.status} ${t.statusText} ${s.slice(0,200)}`)}const r=await t.json();if(r&&typeof r=="object"){if("config"in r)return r.config;if("data"in r)return r.data}return r}function pc(l,e){return l.replace("{projectId}",e).replace("{uuid}",rf().replace(/-/g,""))}function mc(l){const e=l._preload;if(!Array.isArray(e)||e.length===0)return;const t=Array.from(new Set(e.map(r=>r&&typeof r=="object"?r.scriptUrl:null).filter(r=>typeof r=="string"&&r.length>0)));t.length!==0&&Promise.allSettled(t.map(r=>Kl(r)))}async function gc(l){const e={...l.config??(l.configUrl?await fc(l.configUrl,l.configHeaders):{}),...l.overrides??{}};mc(e);const t=e.transport??"tiledesk",r=e.tiledesk;if((t==="tiledesk"||t==="dual")&&!r)throw new Error("mount: descriptor.tiledesk is required for tiledesk/dual transport");const s=r?.projectId??"",n=l.identity.userId,i=l.forceNewConversation?null:dc(n,s),o=r?.requestIdTemplate??"support-group-{projectId}-{uuid}",a=l.conversationId??i??pc(o,s);(!i||l.forceNewConversation)&&s&&of(n,s,a);const c=await l.tokenProvider(),u=l.tokenProvider,h=l.historyTokenProvider??u,p=r?{mqttEndpoint:r.mqttEndpoint,jwtToken:c,userId:n,userName:l.identity.userName,projectId:r.projectId,appId:r.appId,mqttUsername:r.mqttUsername,protocolId:r.protocolId,protocolVersion:r.protocolVersion,keepAliveSec:r.keepAliveSec,connectTimeoutMs:r.connectTimeoutMs,maxReconnectAttempts:r.maxReconnectAttempts,reconnectMaxDelayMs:r.reconnectMaxDelayMs,wildcardSubscribe:r.wildcardSubscribe,enablePresence:r.enablePresence,autoInitiateOnEmpty:r.autoInitiateOnEmpty,chatInitiatedAttributes:r.chatInitiatedAttributes,messageDefaults:{...r.messageDefaults,...l.identity.departmentId?{departmentId:l.identity.departmentId}:r.messageDefaults?.departmentId?{departmentId:r.messageDefaults.departmentId}:{}},fileTemplate:r.fileTemplate,topicTemplates:r.topicTemplates,debug:r.debug,senderFullname:l.identity.senderFullname??l.identity.userName,tokenProvider:u}:void 0,b=l.uploadAdapter??(e.uploadEndpoint?yo({endpoint:e.uploadEndpoint,fieldName:e.uploadFieldName,extraFields:e.uploadExtraFields}):void 0),f=l.historyAdapter??(e.historyApiBase?Ml({apiBase:e.historyApiBase,pageSize:e.historyPageSize??200,pathTemplate:e.historyPathTemplate,extraHeaders:e.historyHeaders,getToken:h}):void 0),g={transport:t,baseUrl:"",userToken:l.userToken??n,conversationId:a,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:l.getLinkBearer,welcomeMessage:e.welcomeMessage,placeholder:e.placeholder,showTimestamps:e.showTimestamps,persistConversation:e.persistConversation,showHeader:e.showHeader,hideSystemMessages:e.hideSystemMessages,timestampFormat:e.timestampFormat,input:e.input,templateLayout:e.templateLayout,tiledesk:p,tiledeskIdentity:{userId:n,userName:l.identity.userName,departmentId:l.identity.departmentId,senderFullname:l.identity.senderFullname??l.identity.userName},templateActionAttributes:e.templateActionAttributes,uploadAdapter:b,historyAdapter:f,onError:l.onError,onMessage:l.onMessage},y=document.createElement("aikaara-chat-widget");return y.configure(g),g.title&&y.setAttribute("title",g.title),g.primaryColor&&y.setAttribute("primary-color",g.primaryColor),g.display&&y.setAttribute("display",g.display),g.display==="embed"&&(y.style.cssText="display:flex;flex-direction:column;width:100%;height:100%;min-height:0;"),l.container.appendChild(y),{widget:y,requestId:a,config:g,destroy(){y.remove()}}}function cf(l){if(typeof l!="string")return l;const e=document.querySelector(l);if(!e)throw new Error(`mountFromSlug: container "${l}" not found`);return e}async function bc(l){const e=(l.configBase??"https://api.aikaara.com").replace(/\/$/,""),t=`${e}/api/v1/widget_configs/${encodeURIComponent(l.slug)}`;let r=null;try{r=await fc(t,l.configHeaders)}catch(x){if(!l.fallbackConfig)throw x;console.warn(`[aikaara-chat-sdk] Widget config fetch failed for slug "${l.slug}" — using fallbackConfig.`,x)}const s={...l.fallbackConfig??{},...r??{},...l.overrides??{}};if(mc(s),s.templates&&Object.keys(s.templates).length>0){s.components={...s.components??{}};for(const[x,I]of Object.entries(s.templates)){const P=`template:${x}`;s.components[P]||!I?.scriptUrl||!I?.render||(s.components[P]={kind:"iife-element",scriptUrl:I.scriptUrl,tag:I.render,...I.props?{props:I.props}:{}})}}const n=window;if(n.__aikaara_descriptor__={...n.__aikaara_descriptor__??{},templates:s.templates,components:s.components,razorpay:s.razorpay,title:s.title,cloud:s.cloud??n.__aikaara_descriptor__?.cloud,upload:s.upload??n.__aikaara_descriptor__?.upload,themeSource:s.themeSource??n.__aikaara_descriptor__?.themeSource,api:s.api,auth:s.auth},!s.auth)throw new Error(`mountFromSlug: widget_configs/${l.slug} descriptor must include "auth" block`);let i=null,o=l.user.id,a=l.user.name,c="",u=l.user.token,h=null;const p=await Zt(l.user.token).catch(()=>""),b=typeof p=="string"&&p.length>0;if(!b&&s.sso?.tokenSource){h=new uc({descriptor:{provider:s.sso.provider,flow:s.sso.flow,skipLogin:s.sso.skipLogin,autoRefresh:s.sso.autoRefresh,tokenSource:s.sso.tokenSource,tokenSourceConfig:s.sso.tokenSourceConfig,fallback:s.sso.fallback,map:s.sso.map},initToken:l.user.partnerToken});const x=await h.get();u=async()=>(await h.get()).token,l.user.identity&&!l.user.identity.partnerToken&&(l.user.identity.partnerToken=x.token)}else if(!b&&s.sso&&s.sso.collect&&s.sso.collect.length>0){const x=`${e}/api/v1/projects/by-slug/${encodeURIComponent(l.slug)}/sso_exchange`;i=await new lc({descriptor:s.sso,providers:l.user.credentialProviders,exchangeUrl:x}).get(),o=i.extUid||o,a=a??i.displayName,c=i.userToken}let f="";if(s.preflight&&s.preflight.length){const x=await af(s.preflight,{sessionToken:u,userId:o,projectId:s.tiledesk?.projectId??"",slug:l.slug,identity:l.user.identity});if(x.captured.sessionToken){f=x.captured.sessionToken;const I=f;u=()=>I}}const g=new sc(s.auth,u);if(f){const x=s.tiledesk?.projectId??"",I=x?dc(o,x):null,P=s.tiledesk?.requestIdTemplate??"support-group-{projectId}-{uuid}",O=I??(x?pc(P,x):"");g.prime(f,{requestId:O,fullName:a})}const y=await g.get();o=o||y.userId;const k=y.fullName||a||o;window.__aikaara_runtime__={getChatJwt:async()=>(await g.get()).token,identity:l.user.identity,slug:l.slug,configBase:e};const m=h&&s.sso?.autoRefresh?async()=>{try{return await h.refresh(),g.reset(),(await g.get()).token}catch(x){return console.warn("[aikaara-chat-sdk] partner auto-refresh failed",x),null}}:null,w=s.upload,S=async()=>`Bearer ${w&&"tokenSource"in w&&w.tokenSource==="chat"?(await g.get()).token:await Zt(l.user.token)}`,v=l.hooks?.upload??(w&&w.mode==="presigned-3step"?Pl({...w,authHeader:S}):w&&w.mode==="direct"?yo({endpoint:w.endpoint,fieldName:w.fieldName,extraFields:w.extraFields,headers:async()=>({authorization:await S()})}):void 0),E=await gc({container:cf(l.container),config:s,userToken:c||void 0,identity:{userId:o,userName:k,departmentId:l.user.departmentId,senderFullname:k},tokenProvider:async()=>(await g.get()).token,historyTokenProvider:async()=>(await g.get()).token,uploadAdapter:v,historyAdapter:l.hooks?.history,conversationId:y.requestId||void 0,onError:l.hooks?.onError,onMessage:l.hooks?.onMessage,getLinkBearer:async x=>x==="none"?null:x==="chat"?(await g.get()).token:Zt(l.user.token)});return Object.assign(E,{fullName:k,requestId:y.requestId,descriptor:s,async refreshAuth(){g.reset(),await g.get()},async refreshPartnerAuth(){return m?m():null}})}exports.ActionCableClient=en;exports.AikaaraChat=ec;exports.AikaaraChatBubble=Bl;exports.AikaaraChatClient=Ol;exports.AikaaraChatHeader=Dl;exports.AikaaraChatInput=Wl;exports.AikaaraChatWidget=Ul;exports.AikaaraComparePlans=rc;exports.AikaaraErrorBanner=Gl;exports.AikaaraLinkModal=tc;exports.AikaaraMessageBubble=Hl;exports.AikaaraMessageList=$l;exports.AikaaraModalAction=Zl;exports.AikaaraOptionList=Jl;exports.AikaaraSchemaForm=ic;exports.AikaaraSmartEditModal=nc;exports.AikaaraStreamingMessage=Vl;exports.AikaaraSubmitAction=Xl;exports.AikaaraSystemPill=Ql;exports.AikaaraTemplateRenderer=Yl;exports.AikaaraTypingIndicator=zl;exports.ApiClient=zs;exports.ChannelSubscription=Hs;exports.ConnectionManager=Ws;exports.ConversationManager=Ks;exports.EventEmitter=to;exports.MessageStore=Vs;exports.SessionAuthAdapter=sc;exports.SsoExchangeAdapter=lc;exports.TiledeskTransport=Al;exports.TokenDiscoveryError=Ke;exports.TokenDiscoveryReader=uc;exports.clearPersistedConversationId=sf;exports.collectSsoCredentials=ac;exports.createFetchUploadAdapter=yo;exports.createPresigned3StepUploadAdapter=Pl;exports.createTiledeskHistoryAdapter=Ml;exports.discoverToken=cc;exports.extractTiledeskFileEnvelope=Cl;exports.inferTiledeskRole=Tl;exports.isTiledeskSelfEcho=Il;exports.mount=gc;exports.mountFromSlug=bc;exports.parseTiledeskTemplate=bo;exports.registerComponents=oc;
|
|
1461
|
+
`}}function St(l){return l.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Ye(l){return l.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function oc(){const l=[["aikaara-chat-widget",Ul],["aikaara-chat-bubble",Bl],["aikaara-chat-header",Dl],["aikaara-message-list",$l],["aikaara-message-bubble",Hl],["aikaara-chat-input",Wl],["aikaara-typing-indicator",zl],["aikaara-streaming-message",Vl],["aikaara-error-banner",Gl],["aikaara-template-renderer",Yl],["aikaara-system-pill",Ql],["aikaara-option-list",Jl],["aikaara-submit-action",Xl],["aikaara-modal-action",Zl],["aikaara-chat",ec],["aikaara-link-modal",tc],["aikaara-compare-plans",rc],["aikaara-smart-edit-modal",nc],["aikaara-schema-form",ic]];for(const[e,t]of l)customElements.get(e)||customElements.define(e,t)}oc();function lr(l,e,t=""){if(!e)return t;const r=e.split(".");let s=l;for(const n of r)if(s&&typeof s=="object"&&n in s)s=s[n];else return t;return typeof s=="string"?s:t}function qs(l){try{const e=l.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 Zt(l){return typeof l=="function"?await l():l}class sc{constructor(e,t){this.descriptor=e,this.sessionToken=t}cache=null;inflight=null;reset(){this.cache=null,this.inflight=null}prime(e,t={}){if(!e)return;const r=qs(e)||Date.now()+3600*1e3;this.cache={token:e,requestId:t.requestId??this.cache?.requestId??"",fullName:t.fullName??this.cache?.fullName??"",userId:t.userId??this.cache?.userId??"",expiresAt:r}}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 Zt(this.sessionToken),t=this.descriptor.authHeader??"Authorization",r=this.descriptor.authHeaderTemplate??"Bearer {token}",s={accept:"application/json",...this.descriptor.headers??{},[t]:r.replace("{token}",e)},n=this.descriptor.method??"POST",i={method:n,headers:s};n==="POST"&&(s["content-type"]="application/json",i.body=JSON.stringify(this.descriptor.body??{}));const o=await fetch(this.descriptor.endpoint,i);if(!o.ok){const k=await o.text().catch(()=>"");throw new Error(`Session auth failed: ${o.status} ${k.slice(0,200)}`)}const a=await o.json().catch(()=>({})),c=lr(a,this.descriptor.tokenPath??"data.token"),u=this.descriptor.tokenStripPrefix,h=u?c.replace(new RegExp(`^${u}`,"i"),"").trim():c;if(!h)throw new Error("Session auth response missing token");const p=lr(a,this.descriptor.requestIdPath??"data.requestId"),b=this.cache?.requestId||p||"",f=lr(a,this.descriptor.fullNamePath??"data.fullName"),g=lr(a,this.descriptor.userPath??"data.userId"),y=qs(h)||Date.now()+3600*1e3;return this.cache={token:h,requestId:b,fullName:f,userId:g,expiresAt:y},this.cache}}async function ac(l){const e={};for(const t of l.spec){const r=await qd(t,l.providers);if(r!==void 0&&r!=="")e[t.name]=r;else{if(t.required)throw new Error(`[aikaara-chat-sdk] SSO credential "${t.name}" is required but ${t.source}`+(t.key?`[${t.key}]`:"")+" returned no value");t.default!==void 0&&(e[t.name]=t.default)}}return e}async function qd(l,e){const t=l.key??l.name;switch(l.source){case"cookie":return Hd(t);case"localStorage":return cr(()=>window.localStorage.getItem(t)??void 0);case"sessionStorage":return cr(()=>window.sessionStorage.getItem(t)??void 0);case"url_param":return cr(()=>new URL(window.location.href).searchParams.get(t)??void 0);case"header_meta":return cr(()=>document.querySelector(`meta[name="${Wd(t)}"]`)?.content??void 0);case"callback":{const r=e?.[l.name];if(!r)return;const s=await r();return typeof s=="string"?s:void 0}default:return}}function Hd(l){if(typeof document>"u")return;const e=encodeURIComponent(l),t=document.cookie?document.cookie.split("; "):[];for(const r of t){const s=r.indexOf("=");if(s===-1)continue;const n=r.slice(0,s);if(n===l||n===e)try{return decodeURIComponent(r.slice(s+1))}catch{return r.slice(s+1)}}}function cr(l){try{return l()}catch{return}}function Wd(l){return l.replace(/["\\]/g,"\\$&")}const zd=1800;class lc{constructor(e){this.opts=e,this.cache=this.loadCache()}cache=null;inflight=null;reset(){this.cache=null,this.inflight=null,this.clearCache()}async get(e=!1){if(!e){const t=this.cache;if(t&&(!t.expiresAt||t.expiresAt>Date.now()))return t}return this.inflight?this.inflight:(this.inflight=this.exchange().finally(()=>{this.inflight=null}),this.inflight)}async exchange(){if(!this.opts.descriptor.collect||this.opts.descriptor.collect.length===0)throw new Error("[aikaara-chat-sdk] SsoExchangeAdapter.exchange() requires descriptor.sso.collect; v2 partner-token flow should be handled by TokenDiscoveryReader instead.");const e=await ac({spec:this.opts.descriptor.collect,providers:this.opts.providers}),t=JSON.stringify({credentials:e}),r={accept:"application/json","content-type":"application/json",...this.opts.descriptor.headers??{}};this.opts.descriptor.apiKey&&(r["X-Api-Key"]=this.opts.descriptor.apiKey);const s=this.opts.descriptor.exchangeEndpoint||this.opts.exchangeUrl;if(!s)throw new Error("[aikaara-chat-sdk] SSO exchange URL not resolved — set descriptor.sso.exchangeEndpoint or pass `exchangeUrl` (mountFromSlug derives it from configBase + slug).");const n=await fetch(s,{method:"POST",headers:r,body:t});if(!n.ok){const h=await n.text().catch(()=>"");throw new Error(`SSO exchange failed: ${n.status} ${h.slice(0,240)}`)}const o=(await n.json().catch(()=>({}))).user??{},a=String(o.ext_uid??o.extUid??""),c=String(o.token??o.user_token??o.userToken??"");if(!a)throw new Error("SSO exchange response missing user.ext_uid");if(!c)throw new Error("SSO exchange response missing user.token");const u={id:o.id,extUid:a,userToken:c,email:typeof o.email=="string"?o.email:void 0,displayName:typeof o.display_name=="string"?o.display_name:typeof o.displayName=="string"?o.displayName:void 0,properties:o.properties&&typeof o.properties=="object"?o.properties:void 0,expiresAt:this.computeExpiry()};return this.cache=u,this.persistCache(u),u}computeExpiry(){const e=this.opts.descriptor.cacheTtlSec??zd;if(!(!this.opts.descriptor.cacheKey||e<=0))return Date.now()+e*1e3}loadCache(){const e=this.opts.descriptor.cacheKey;if(!e)return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const r=JSON.parse(t);return r.expiresAt&&r.expiresAt<Date.now()?(window.localStorage.removeItem(e),null):r}catch{return null}}persistCache(e){const t=this.opts.descriptor.cacheKey;if(t)try{window.localStorage.setItem(t,JSON.stringify(e))}catch{}}clearCache(){const e=this.opts.descriptor.cacheKey;if(e)try{window.localStorage.removeItem(e)}catch{}}}const Vd=3e4,Gd=2e3,Kd=100;async function cc(l){const{descriptor:e}=l,t=e.tokenSourceConfig??{};switch(e.tokenSource){case"init":{if(!l.initToken)throw new Ke("init","No init token supplied to Aikaara.init({token})");return{token:l.initToken,source:"init"}}case"query":{const r=typeof t.key=="string"&&t.key?t.key:"token",s=Yd(r);if(!s)throw new Ke("query",`?${r}= not present`);return{token:s,source:"query"}}case"hash":{const r=typeof t.key=="string"&&t.key?t.key:"token",s=Qd(r);if(!s)throw new Ke("hash",`#${r}= not present`);return{token:s,source:"hash"}}case"postmsg":{const r=typeof t.type=="string"?t.type:"",s=typeof t.key=="string"&&t.key?t.key:"token",n=tf(typeof t.origins=="string"?t.origins:""),i=typeof t.timeoutMs=="number"&&t.timeoutMs>0?t.timeoutMs:Vd;return{token:await ef({type:r,key:s,origins:n,timeoutMs:i}),source:"postmsg"}}case"cookie":{const r=typeof t.name=="string"&&t.name?t.name:"";if(!r)throw new Ke("cookie","cookie.name not configured");const s=Jd(r);if(!s)throw new Ke("cookie",`cookie "${r}" not set`);return{token:s,source:"cookie"}}case"storage":{const r=t.store==="session"?"session":"local",s=typeof t.key=="string"&&t.key?t.key:"",n=typeof t.path=="string"?t.path:"";if(!s)throw new Ke("storage","storage.key not configured");const i=Xd(r,s,n);if(!i)throw new Ke("storage",`${r}Storage["${s}"] not set`);return{token:i,source:"storage"}}case"global":{const r=typeof t.path=="string"?t.path:"";if(!r)throw new Ke("global","global.path not configured");const s=typeof t.timeoutMs=="number"&&t.timeoutMs>0?t.timeoutMs:Gd,n=typeof t.intervalMs=="number"&&t.intervalMs>0?t.intervalMs:Kd,i=await Zd(r,s,n);if(!i)throw new Ke("global",`window.${r} not present`);return{token:i,source:"global"}}default:{const r=e.tokenSource;throw new Ke("unknown",`Unknown tokenSource ${JSON.stringify(r)}`)}}}class uc{constructor(e){this.opts=e}cached=null;get descriptor(){return this.opts.descriptor}async get(){if(this.cached)return this.cached;const e=await cc(this.opts);return this.cached=e,e}async refresh(){return this.opts.descriptor.tokenSource==="init"?this.cached?this.cached:this.get():(this.cached=null,this.get())}}class Ke extends Error{constructor(e,t){super(`[aikaara-chat-sdk] token-discovery (${e}): ${t}`),this.source=e,this.name="TokenDiscoveryError"}}function Yd(l){if(!(typeof window>"u"))try{return new URL(window.location.href).searchParams.get(l)??void 0}catch{return}}function Qd(l){if(!(typeof window>"u"))try{const e=window.location.hash.replace(/^#/,"");return new URLSearchParams(e).get(l)??void 0}catch{return}}function Jd(l){if(typeof document>"u")return;const e=encodeURIComponent(l),t=document.cookie?document.cookie.split("; "):[];for(const r of t){const s=r.indexOf("=");if(s===-1)continue;const n=r.slice(0,s);if(n===l||n===e)try{return decodeURIComponent(r.slice(s+1))}catch{return r.slice(s+1)}}}function Xd(l,e,t){if(!(typeof window>"u"))try{const s=(l==="session"?window.sessionStorage:window.localStorage).getItem(e);if(s==null)return;if(!t)return s;let n;try{n=JSON.parse(s)}catch{return s}const i=hc(n,t);return typeof i=="string"?i:void 0}catch{return}}async function Zd(l,e,t){if(typeof window>"u")return;const r=Date.now()+e;for(;Date.now()<r;){const s=hc(window,l);if(typeof s=="string"&&s.length>0)return s;if(typeof s=="function")try{const n=s();if(typeof n=="string"&&n.length>0)return n}catch{}await new Promise(n=>setTimeout(n,t))}}function ef(l){return new Promise((e,t)=>{if(typeof window>"u"){t(new Ke("postmsg","no window"));return}const r=()=>{window.removeEventListener("message",n),clearTimeout(s)},s=setTimeout(()=>{r(),t(new Ke("postmsg",`timeout after ${l.timeoutMs}ms`))},l.timeoutMs),n=i=>{if(l.origins.length>0&&!l.origins.includes(i.origin))return;const o=i.data;if(!o||typeof o!="object")return;const a=o;if(l.type&&a.type!==l.type)return;const c=a[l.key];typeof c=="string"&&c.length>0&&(r(),e(c))};window.addEventListener("message",n)})}function tf(l){return l?l.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean):[]}function hc(l,e){if(!e)return l;const t=e.split(".").filter(Boolean);let r=l;for(const s of t)if(r&&typeof r=="object"&&s in r)r=r[s];else return;return r}function rf(){const l=typeof crypto<"u"?crypto:null;if(l?.randomUUID)return l.randomUUID();if(l?.getRandomValues){const e=new Uint8Array(16);l.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;const t=[...e].map(r=>r.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 nf="aikaara_chat:requestId";function vo(l,e){return`${nf}:${l}:${e}`}function dc(l,e){try{return localStorage.getItem(vo(l,e))}catch{return null}}function of(l,e,t){try{localStorage.setItem(vo(l,e),t)}catch{}}function sf(l,e){try{localStorage.removeItem(vo(l,e))}catch{}}async function af(l,e){console.log("[aikaara-chat-sdk] preflight running",l.length,"steps");const t={userId:e.userId,projectId:e.projectId,slug:e.slug};if(e.identity)for(const[a,c]of Object.entries(e.identity))typeof c=="string"&&(t[a]=c);const r=a=>a.replace(/\{(\w+)\}/g,(c,u)=>u in t?t[u]:""),s=a=>{if(typeof a=="string")return r(a);if(Array.isArray(a))return a.map(s);if(a&&typeof a=="object"){const c={};for(const[u,h]of Object.entries(a))c[u]=s(h);return c}return a},n=await Zt(e.sessionToken),i={},o=[800,1500,3e3,5e3,8e3];for(let a=0;a<l.length;a++){const c=l[a],u=r(c.url),h=c.method??(c.body?"POST":"GET"),p={accept:"application/json",...c.headers??{}};if((c.authHeader??"session")==="session"){const m=c.authHeaderTemplate??"Bearer {token}";p.authorization=m.replace("{token}",n)}const b={method:h,headers:p};c.body&&(p["content-type"]="application/json",b.body=JSON.stringify(s(c.body)));let f=0,g="",y=0,k=null;for(;;)try{const m=await fetch(u,b);if(m.ok){k=m;break}if(f=m.status,g=await m.text().catch(()=>""),y<o.length&&lf(f,g)){const S=o[y++];console.warn(`[aikaara-chat-sdk] preflight #${a} ${h} ${u} → ${f} (transient). Retry #${y} in ${S}ms.`),await new Promise(v=>setTimeout(v,S));continue}const w=`Preflight #${a} ${h} ${u} → ${f} ${g.slice(0,200)}`;if(c.soft){console.warn("[aikaara-chat-sdk]",w);break}throw new Error(w)}catch(m){if(y<o.length){const w=o[y++];console.warn(`[aikaara-chat-sdk] preflight #${a} threw, retry #${y} in ${w}ms`,m),await new Promise(S=>setTimeout(S,w));continue}if(c.soft){console.warn(`[aikaara-chat-sdk] preflight #${a} soft-failed:`,m);break}throw m}if(k&&c.capture&&c.capture.as)try{const m=await k.clone().text();let w=m;try{w=JSON.parse(m)}catch{}if(c.capture.path)for(const S of c.capture.path.split("."))if(w&&typeof w=="object"&&S in w)w=w[S];else{w=void 0;break}if(typeof w=="string"&&w.length>0){let S=w;c.capture.stripPrefix&&S.startsWith(c.capture.stripPrefix)&&(S=S.slice(c.capture.stripPrefix.length)),i[c.capture.as]=S,t[c.capture.as]=S,console.log(`[aikaara-chat-sdk] preflight #${a} captured ${c.capture.as} (${S.slice(0,24)}…)`)}}catch(m){console.warn(`[aikaara-chat-sdk] preflight #${a} capture failed`,m)}}return{captured:i}}function lf(l,e){if(l===503||l===504||l===502)return!0;if(l===401||l===403)return e.trim().length===0;if(l===500){const t=e.toLowerCase();return t.includes("customernew")||t.includes("is null")||t.includes("not yet ready")}return!1}async function fc(l,e){const t=await fetch(l,{method:"GET",headers:{accept:"application/json",...e??{}}});if(!t.ok){const s=await t.text().catch(()=>"");throw new Error(`Widget config fetch failed: ${t.status} ${t.statusText} ${s.slice(0,200)}`)}const r=await t.json();if(r&&typeof r=="object"){if("config"in r)return r.config;if("data"in r)return r.data}return r}function pc(l,e){return l.replace("{projectId}",e).replace("{uuid}",rf().replace(/-/g,""))}function mc(l){const e=l._preload;if(!Array.isArray(e)||e.length===0)return;const t=Array.from(new Set(e.map(r=>r&&typeof r=="object"?r.scriptUrl:null).filter(r=>typeof r=="string"&&r.length>0)));t.length!==0&&Promise.allSettled(t.map(r=>Kl(r)))}async function gc(l){const e={...l.config??(l.configUrl?await fc(l.configUrl,l.configHeaders):{}),...l.overrides??{}};mc(e);const t=e.transport??"tiledesk",r=e.tiledesk;if((t==="tiledesk"||t==="dual")&&!r)throw new Error("mount: descriptor.tiledesk is required for tiledesk/dual transport");const s=r?.projectId??"",n=l.identity.userId,i=l.forceNewConversation?null:dc(n,s),o=r?.requestIdTemplate??"support-group-{projectId}-{uuid}",a=l.conversationId??i??pc(o,s);(!i||l.forceNewConversation)&&s&&of(n,s,a);const c=await l.tokenProvider(),u=l.tokenProvider,h=l.historyTokenProvider??u,p=r?{mqttEndpoint:r.mqttEndpoint,jwtToken:c,userId:n,userName:l.identity.userName,projectId:r.projectId,appId:r.appId,mqttUsername:r.mqttUsername,protocolId:r.protocolId,protocolVersion:r.protocolVersion,keepAliveSec:r.keepAliveSec,connectTimeoutMs:r.connectTimeoutMs,maxReconnectAttempts:r.maxReconnectAttempts,reconnectMaxDelayMs:r.reconnectMaxDelayMs,wildcardSubscribe:r.wildcardSubscribe,enablePresence:r.enablePresence,autoInitiateOnEmpty:r.autoInitiateOnEmpty,chatInitiatedAttributes:r.chatInitiatedAttributes,messageDefaults:{...r.messageDefaults,...l.identity.departmentId?{departmentId:l.identity.departmentId}:r.messageDefaults?.departmentId?{departmentId:r.messageDefaults.departmentId}:{}},fileTemplate:r.fileTemplate,topicTemplates:r.topicTemplates,debug:r.debug,senderFullname:l.identity.senderFullname??l.identity.userName,tokenProvider:u}:void 0,b=l.uploadAdapter??(e.uploadEndpoint?yo({endpoint:e.uploadEndpoint,fieldName:e.uploadFieldName,extraFields:e.uploadExtraFields}):void 0),f=l.historyAdapter??(e.historyApiBase?Ml({apiBase:e.historyApiBase,pageSize:e.historyPageSize??200,pathTemplate:e.historyPathTemplate,extraHeaders:e.historyHeaders,getToken:h}):void 0),g={transport:t,baseUrl:"",userToken:l.userToken??n,conversationId:a,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:l.getLinkBearer,welcomeMessage:e.welcomeMessage,placeholder:e.placeholder,showTimestamps:e.showTimestamps,persistConversation:e.persistConversation,showHeader:e.showHeader,hideSystemMessages:e.hideSystemMessages,timestampFormat:e.timestampFormat,input:e.input,templateLayout:e.templateLayout,tiledesk:p,tiledeskIdentity:{userId:n,userName:l.identity.userName,departmentId:l.identity.departmentId,senderFullname:l.identity.senderFullname??l.identity.userName},templateActionAttributes:e.templateActionAttributes,uploadAdapter:b,historyAdapter:f,onError:l.onError,onMessage:l.onMessage},y=document.createElement("aikaara-chat-widget");return y.configure(g),g.title&&y.setAttribute("title",g.title),g.primaryColor&&y.setAttribute("primary-color",g.primaryColor),g.display&&y.setAttribute("display",g.display),g.display==="embed"&&(y.style.cssText="display:flex;flex-direction:column;width:100%;height:100%;min-height:0;--aikaara-close-btn-display:none;"),l.container.appendChild(y),{widget:y,requestId:a,config:g,destroy(){y.remove()}}}function cf(l){if(typeof l!="string")return l;const e=document.querySelector(l);if(!e)throw new Error(`mountFromSlug: container "${l}" not found`);return e}async function bc(l){const e=(l.configBase??"https://api.aikaara.com").replace(/\/$/,""),t=`${e}/api/v1/widget_configs/${encodeURIComponent(l.slug)}`;let r=null;try{r=await fc(t,l.configHeaders)}catch(x){if(!l.fallbackConfig)throw x;console.warn(`[aikaara-chat-sdk] Widget config fetch failed for slug "${l.slug}" — using fallbackConfig.`,x)}const s={...l.fallbackConfig??{},...r??{},...l.overrides??{}};if(mc(s),s.templates&&Object.keys(s.templates).length>0){s.components={...s.components??{}};for(const[x,I]of Object.entries(s.templates)){const P=`template:${x}`;s.components[P]||!I?.scriptUrl||!I?.render||(s.components[P]={kind:"iife-element",scriptUrl:I.scriptUrl,tag:I.render,...I.props?{props:I.props}:{}})}}const n=window;if(n.__aikaara_descriptor__={...n.__aikaara_descriptor__??{},templates:s.templates,components:s.components,razorpay:s.razorpay,title:s.title,cloud:s.cloud??n.__aikaara_descriptor__?.cloud,upload:s.upload??n.__aikaara_descriptor__?.upload,themeSource:s.themeSource??n.__aikaara_descriptor__?.themeSource,api:s.api,auth:s.auth},!s.auth)throw new Error(`mountFromSlug: widget_configs/${l.slug} descriptor must include "auth" block`);let i=null,o=l.user.id,a=l.user.name,c="",u=l.user.token,h=null;const p=await Zt(l.user.token).catch(()=>""),b=typeof p=="string"&&p.length>0;if(!b&&s.sso?.tokenSource){h=new uc({descriptor:{provider:s.sso.provider,flow:s.sso.flow,skipLogin:s.sso.skipLogin,autoRefresh:s.sso.autoRefresh,tokenSource:s.sso.tokenSource,tokenSourceConfig:s.sso.tokenSourceConfig,fallback:s.sso.fallback,map:s.sso.map},initToken:l.user.partnerToken});const x=await h.get();u=async()=>(await h.get()).token,l.user.identity&&!l.user.identity.partnerToken&&(l.user.identity.partnerToken=x.token)}else if(!b&&s.sso&&s.sso.collect&&s.sso.collect.length>0){const x=`${e}/api/v1/projects/by-slug/${encodeURIComponent(l.slug)}/sso_exchange`;i=await new lc({descriptor:s.sso,providers:l.user.credentialProviders,exchangeUrl:x}).get(),o=i.extUid||o,a=a??i.displayName,c=i.userToken}let f="";if(s.preflight&&s.preflight.length){const x=await af(s.preflight,{sessionToken:u,userId:o,projectId:s.tiledesk?.projectId??"",slug:l.slug,identity:l.user.identity});if(x.captured.sessionToken){f=x.captured.sessionToken;const I=f;u=()=>I}x.captured.userId&&(o=x.captured.userId)}const g=new sc(s.auth,u);if(f){const x=s.tiledesk?.projectId??"",I=x?dc(o,x):null,P=s.tiledesk?.requestIdTemplate??"support-group-{projectId}-{uuid}",O=I??(x?pc(P,x):"");g.prime(f,{requestId:O,fullName:a})}const y=await g.get();o=o||y.userId;const k=y.fullName||a||o;window.__aikaara_runtime__={getChatJwt:async()=>(await g.get()).token,identity:l.user.identity,slug:l.slug,configBase:e};const m=h&&s.sso?.autoRefresh?async()=>{try{return await h.refresh(),g.reset(),(await g.get()).token}catch(x){return console.warn("[aikaara-chat-sdk] partner auto-refresh failed",x),null}}:null,w=s.upload,S=async()=>`Bearer ${w&&"tokenSource"in w&&w.tokenSource==="chat"?(await g.get()).token:await Zt(l.user.token)}`,v=l.hooks?.upload??(w&&w.mode==="presigned-3step"?Pl({...w,authHeader:S}):w&&w.mode==="direct"?yo({endpoint:w.endpoint,fieldName:w.fieldName,extraFields:w.extraFields,headers:async()=>({authorization:await S()})}):void 0),E=await gc({container:cf(l.container),config:s,userToken:c||void 0,identity:{userId:o,userName:k,departmentId:l.user.departmentId,senderFullname:k},tokenProvider:async()=>(await g.get()).token,historyTokenProvider:async()=>(await g.get()).token,uploadAdapter:v,historyAdapter:l.hooks?.history,conversationId:y.requestId||void 0,onError:l.hooks?.onError,onMessage:l.hooks?.onMessage,getLinkBearer:async x=>x==="none"?null:x==="chat"?(await g.get()).token:Zt(l.user.token)});return Object.assign(E,{fullName:k,requestId:y.requestId,descriptor:s,async refreshAuth(){g.reset(),await g.get()},async refreshPartnerAuth(){return m?m():null}})}exports.ActionCableClient=en;exports.AikaaraChat=ec;exports.AikaaraChatBubble=Bl;exports.AikaaraChatClient=Ol;exports.AikaaraChatHeader=Dl;exports.AikaaraChatInput=Wl;exports.AikaaraChatWidget=Ul;exports.AikaaraComparePlans=rc;exports.AikaaraErrorBanner=Gl;exports.AikaaraLinkModal=tc;exports.AikaaraMessageBubble=Hl;exports.AikaaraMessageList=$l;exports.AikaaraModalAction=Zl;exports.AikaaraOptionList=Jl;exports.AikaaraSchemaForm=ic;exports.AikaaraSmartEditModal=nc;exports.AikaaraStreamingMessage=Vl;exports.AikaaraSubmitAction=Xl;exports.AikaaraSystemPill=Ql;exports.AikaaraTemplateRenderer=Yl;exports.AikaaraTypingIndicator=zl;exports.ApiClient=zs;exports.ChannelSubscription=Hs;exports.ConnectionManager=Ws;exports.ConversationManager=Ks;exports.EventEmitter=to;exports.MessageStore=Vs;exports.SessionAuthAdapter=sc;exports.SsoExchangeAdapter=lc;exports.TiledeskTransport=Al;exports.TokenDiscoveryError=Ke;exports.TokenDiscoveryReader=uc;exports.clearPersistedConversationId=sf;exports.collectSsoCredentials=ac;exports.createFetchUploadAdapter=yo;exports.createPresigned3StepUploadAdapter=Pl;exports.createTiledeskHistoryAdapter=Ml;exports.discoverToken=cc;exports.extractTiledeskFileEnvelope=Cl;exports.inferTiledeskRole=Tl;exports.isTiledeskSelfEcho=Il;exports.mount=gc;exports.mountFromSlug=bc;exports.parseTiledeskTemplate=bo;exports.registerComponents=oc;
|
|
@@ -229,6 +229,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
229
229
|
opacity: 0.8;
|
|
230
230
|
transition: opacity 200ms, background 200ms;
|
|
231
231
|
}
|
|
232
|
+
.close-btn {
|
|
233
|
+
display: var(--aikaara-close-btn-display, flex);
|
|
234
|
+
}
|
|
232
235
|
.icon-btn:hover {
|
|
233
236
|
opacity: 1;
|
|
234
237
|
background: rgba(255,255,255,0.12);
|
|
@@ -1455,7 +1458,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1455
1458
|
}
|
|
1456
1459
|
.save-btn:hover { filter: brightness(1.07); }
|
|
1457
1460
|
.save-btn:active { filter: brightness(0.95); }
|
|
1458
|
-
`}}function Ot(l){return l.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Qe(l){return l.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function yo(){const l=[["aikaara-chat-widget",xl],["aikaara-chat-bubble",Sl],["aikaara-chat-header",El],["aikaara-message-list",Il],["aikaara-message-bubble",Cl],["aikaara-chat-input",Pl],["aikaara-typing-indicator",Ml],["aikaara-streaming-message",Rl],["aikaara-error-banner",Ll],["aikaara-template-renderer",gd],["aikaara-system-pill",vd],["aikaara-option-list",wd],["aikaara-submit-action",_d],["aikaara-modal-action",xd],["aikaara-chat",Sd],["aikaara-link-modal",Ed],["aikaara-compare-plans",Td],["aikaara-smart-edit-modal",Cd],["aikaara-schema-form",Md]];for(const[e,t]of l)customElements.get(e)||customElements.define(e,t)}yo();function Hr(l,e,t=""){if(!e)return t;const r=e.split(".");let s=l;for(const n of r)if(s&&typeof s=="object"&&n in s)s=s[n];else return t;return typeof s=="string"?s:t}function Fl(l){try{const e=l.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 Xt(l){return typeof l=="function"?await l():l}class $l{constructor(e,t){this.descriptor=e,this.sessionToken=t}cache=null;inflight=null;reset(){this.cache=null,this.inflight=null}prime(e,t={}){if(!e)return;const r=Fl(e)||Date.now()+3600*1e3;this.cache={token:e,requestId:t.requestId??this.cache?.requestId??"",fullName:t.fullName??this.cache?.fullName??"",userId:t.userId??this.cache?.userId??"",expiresAt:r}}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 Xt(this.sessionToken),t=this.descriptor.authHeader??"Authorization",r=this.descriptor.authHeaderTemplate??"Bearer {token}",s={accept:"application/json",...this.descriptor.headers??{},[t]:r.replace("{token}",e)},n=this.descriptor.method??"POST",i={method:n,headers:s};n==="POST"&&(s["content-type"]="application/json",i.body=JSON.stringify(this.descriptor.body??{}));const o=await fetch(this.descriptor.endpoint,i);if(!o.ok){const k=await o.text().catch(()=>"");throw new Error(`Session auth failed: ${o.status} ${k.slice(0,200)}`)}const a=await o.json().catch(()=>({})),c=Hr(a,this.descriptor.tokenPath??"data.token"),u=this.descriptor.tokenStripPrefix,h=u?c.replace(new RegExp(`^${u}`,"i"),"").trim():c;if(!h)throw new Error("Session auth response missing token");const p=Hr(a,this.descriptor.requestIdPath??"data.requestId"),b=this.cache?.requestId||p||"",f=Hr(a,this.descriptor.fullNamePath??"data.fullName"),g=Hr(a,this.descriptor.userPath??"data.userId"),y=Fl(h)||Date.now()+3600*1e3;return this.cache={token:h,requestId:b,fullName:f,userId:g,expiresAt:y},this.cache}}async function ql(l){const e={};for(const t of l.spec){const r=await Rd(t,l.providers);if(r!==void 0&&r!=="")e[t.name]=r;else{if(t.required)throw new Error(`[aikaara-chat-sdk] SSO credential "${t.name}" is required but ${t.source}`+(t.key?`[${t.key}]`:"")+" returned no value");t.default!==void 0&&(e[t.name]=t.default)}}return e}async function Rd(l,e){const t=l.key??l.name;switch(l.source){case"cookie":return Ld(t);case"localStorage":return Wr(()=>window.localStorage.getItem(t)??void 0);case"sessionStorage":return Wr(()=>window.sessionStorage.getItem(t)??void 0);case"url_param":return Wr(()=>new URL(window.location.href).searchParams.get(t)??void 0);case"header_meta":return Wr(()=>document.querySelector(`meta[name="${jd(t)}"]`)?.content??void 0);case"callback":{const r=e?.[l.name];if(!r)return;const s=await r();return typeof s=="string"?s:void 0}default:return}}function Ld(l){if(typeof document>"u")return;const e=encodeURIComponent(l),t=document.cookie?document.cookie.split("; "):[];for(const r of t){const s=r.indexOf("=");if(s===-1)continue;const n=r.slice(0,s);if(n===l||n===e)try{return decodeURIComponent(r.slice(s+1))}catch{return r.slice(s+1)}}}function Wr(l){try{return l()}catch{return}}function jd(l){return l.replace(/["\\]/g,"\\$&")}const Nd=1800;class Hl{constructor(e){this.opts=e,this.cache=this.loadCache()}cache=null;inflight=null;reset(){this.cache=null,this.inflight=null,this.clearCache()}async get(e=!1){if(!e){const t=this.cache;if(t&&(!t.expiresAt||t.expiresAt>Date.now()))return t}return this.inflight?this.inflight:(this.inflight=this.exchange().finally(()=>{this.inflight=null}),this.inflight)}async exchange(){if(!this.opts.descriptor.collect||this.opts.descriptor.collect.length===0)throw new Error("[aikaara-chat-sdk] SsoExchangeAdapter.exchange() requires descriptor.sso.collect; v2 partner-token flow should be handled by TokenDiscoveryReader instead.");const e=await ql({spec:this.opts.descriptor.collect,providers:this.opts.providers}),t=JSON.stringify({credentials:e}),r={accept:"application/json","content-type":"application/json",...this.opts.descriptor.headers??{}};this.opts.descriptor.apiKey&&(r["X-Api-Key"]=this.opts.descriptor.apiKey);const s=this.opts.descriptor.exchangeEndpoint||this.opts.exchangeUrl;if(!s)throw new Error("[aikaara-chat-sdk] SSO exchange URL not resolved — set descriptor.sso.exchangeEndpoint or pass `exchangeUrl` (mountFromSlug derives it from configBase + slug).");const n=await fetch(s,{method:"POST",headers:r,body:t});if(!n.ok){const h=await n.text().catch(()=>"");throw new Error(`SSO exchange failed: ${n.status} ${h.slice(0,240)}`)}const o=(await n.json().catch(()=>({}))).user??{},a=String(o.ext_uid??o.extUid??""),c=String(o.token??o.user_token??o.userToken??"");if(!a)throw new Error("SSO exchange response missing user.ext_uid");if(!c)throw new Error("SSO exchange response missing user.token");const u={id:o.id,extUid:a,userToken:c,email:typeof o.email=="string"?o.email:void 0,displayName:typeof o.display_name=="string"?o.display_name:typeof o.displayName=="string"?o.displayName:void 0,properties:o.properties&&typeof o.properties=="object"?o.properties:void 0,expiresAt:this.computeExpiry()};return this.cache=u,this.persistCache(u),u}computeExpiry(){const e=this.opts.descriptor.cacheTtlSec??Nd;if(!(!this.opts.descriptor.cacheKey||e<=0))return Date.now()+e*1e3}loadCache(){const e=this.opts.descriptor.cacheKey;if(!e)return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const r=JSON.parse(t);return r.expiresAt&&r.expiresAt<Date.now()?(window.localStorage.removeItem(e),null):r}catch{return null}}persistCache(e){const t=this.opts.descriptor.cacheKey;if(t)try{window.localStorage.setItem(t,JSON.stringify(e))}catch{}}clearCache(){const e=this.opts.descriptor.cacheKey;if(e)try{window.localStorage.removeItem(e)}catch{}}}const Ud=3e4,Bd=2e3,Dd=100;async function Wl(l){const{descriptor:e}=l,t=e.tokenSourceConfig??{};switch(e.tokenSource){case"init":{if(!l.initToken)throw new Ke("init","No init token supplied to Aikaara.init({token})");return{token:l.initToken,source:"init"}}case"query":{const r=typeof t.key=="string"&&t.key?t.key:"token",s=Fd(r);if(!s)throw new Ke("query",`?${r}= not present`);return{token:s,source:"query"}}case"hash":{const r=typeof t.key=="string"&&t.key?t.key:"token",s=$d(r);if(!s)throw new Ke("hash",`#${r}= not present`);return{token:s,source:"hash"}}case"postmsg":{const r=typeof t.type=="string"?t.type:"",s=typeof t.key=="string"&&t.key?t.key:"token",n=Vd(typeof t.origins=="string"?t.origins:""),i=typeof t.timeoutMs=="number"&&t.timeoutMs>0?t.timeoutMs:Ud;return{token:await zd({type:r,key:s,origins:n,timeoutMs:i}),source:"postmsg"}}case"cookie":{const r=typeof t.name=="string"&&t.name?t.name:"";if(!r)throw new Ke("cookie","cookie.name not configured");const s=qd(r);if(!s)throw new Ke("cookie",`cookie "${r}" not set`);return{token:s,source:"cookie"}}case"storage":{const r=t.store==="session"?"session":"local",s=typeof t.key=="string"&&t.key?t.key:"",n=typeof t.path=="string"?t.path:"";if(!s)throw new Ke("storage","storage.key not configured");const i=Hd(r,s,n);if(!i)throw new Ke("storage",`${r}Storage["${s}"] not set`);return{token:i,source:"storage"}}case"global":{const r=typeof t.path=="string"?t.path:"";if(!r)throw new Ke("global","global.path not configured");const s=typeof t.timeoutMs=="number"&&t.timeoutMs>0?t.timeoutMs:Bd,n=typeof t.intervalMs=="number"&&t.intervalMs>0?t.intervalMs:Dd,i=await Wd(r,s,n);if(!i)throw new Ke("global",`window.${r} not present`);return{token:i,source:"global"}}default:{const r=e.tokenSource;throw new Ke("unknown",`Unknown tokenSource ${JSON.stringify(r)}`)}}}class zl{constructor(e){this.opts=e}cached=null;get descriptor(){return this.opts.descriptor}async get(){if(this.cached)return this.cached;const e=await Wl(this.opts);return this.cached=e,e}async refresh(){return this.opts.descriptor.tokenSource==="init"?this.cached?this.cached:this.get():(this.cached=null,this.get())}}class Ke extends Error{constructor(e,t){super(`[aikaara-chat-sdk] token-discovery (${e}): ${t}`),this.source=e,this.name="TokenDiscoveryError"}}function Fd(l){if(!(typeof window>"u"))try{return new URL(window.location.href).searchParams.get(l)??void 0}catch{return}}function $d(l){if(!(typeof window>"u"))try{const e=window.location.hash.replace(/^#/,"");return new URLSearchParams(e).get(l)??void 0}catch{return}}function qd(l){if(typeof document>"u")return;const e=encodeURIComponent(l),t=document.cookie?document.cookie.split("; "):[];for(const r of t){const s=r.indexOf("=");if(s===-1)continue;const n=r.slice(0,s);if(n===l||n===e)try{return decodeURIComponent(r.slice(s+1))}catch{return r.slice(s+1)}}}function Hd(l,e,t){if(!(typeof window>"u"))try{const s=(l==="session"?window.sessionStorage:window.localStorage).getItem(e);if(s==null)return;if(!t)return s;let n;try{n=JSON.parse(s)}catch{return s}const i=Vl(n,t);return typeof i=="string"?i:void 0}catch{return}}async function Wd(l,e,t){if(typeof window>"u")return;const r=Date.now()+e;for(;Date.now()<r;){const s=Vl(window,l);if(typeof s=="string"&&s.length>0)return s;if(typeof s=="function")try{const n=s();if(typeof n=="string"&&n.length>0)return n}catch{}await new Promise(n=>setTimeout(n,t))}}function zd(l){return new Promise((e,t)=>{if(typeof window>"u"){t(new Ke("postmsg","no window"));return}const r=()=>{window.removeEventListener("message",n),clearTimeout(s)},s=setTimeout(()=>{r(),t(new Ke("postmsg",`timeout after ${l.timeoutMs}ms`))},l.timeoutMs),n=i=>{if(l.origins.length>0&&!l.origins.includes(i.origin))return;const o=i.data;if(!o||typeof o!="object")return;const a=o;if(l.type&&a.type!==l.type)return;const c=a[l.key];typeof c=="string"&&c.length>0&&(r(),e(c))};window.addEventListener("message",n)})}function Vd(l){return l?l.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean):[]}function Vl(l,e){if(!e)return l;const t=e.split(".").filter(Boolean);let r=l;for(const s of t)if(r&&typeof r=="object"&&s in r)r=r[s];else return;return r}function Gd(){const l=typeof crypto<"u"?crypto:null;if(l?.randomUUID)return l.randomUUID();if(l?.getRandomValues){const e=new Uint8Array(16);l.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;const t=[...e].map(r=>r.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 Kd="aikaara_chat:requestId";function vo(l,e){return`${Kd}:${l}:${e}`}function Gl(l,e){try{return localStorage.getItem(vo(l,e))}catch{return null}}function Yd(l,e,t){try{localStorage.setItem(vo(l,e),t)}catch{}}function Qd(l,e){try{localStorage.removeItem(vo(l,e))}catch{}}async function Jd(l,e){console.log("[aikaara-chat-sdk] preflight running",l.length,"steps");const t={userId:e.userId,projectId:e.projectId,slug:e.slug};if(e.identity)for(const[a,c]of Object.entries(e.identity))typeof c=="string"&&(t[a]=c);const r=a=>a.replace(/\{(\w+)\}/g,(c,u)=>u in t?t[u]:""),s=a=>{if(typeof a=="string")return r(a);if(Array.isArray(a))return a.map(s);if(a&&typeof a=="object"){const c={};for(const[u,h]of Object.entries(a))c[u]=s(h);return c}return a},n=await Xt(e.sessionToken),i={},o=[800,1500,3e3,5e3,8e3];for(let a=0;a<l.length;a++){const c=l[a],u=r(c.url),h=c.method??(c.body?"POST":"GET"),p={accept:"application/json",...c.headers??{}};if((c.authHeader??"session")==="session"){const m=c.authHeaderTemplate??"Bearer {token}";p.authorization=m.replace("{token}",n)}const b={method:h,headers:p};c.body&&(p["content-type"]="application/json",b.body=JSON.stringify(s(c.body)));let f=0,g="",y=0,k=null;for(;;)try{const m=await fetch(u,b);if(m.ok){k=m;break}if(f=m.status,g=await m.text().catch(()=>""),y<o.length&&Xd(f,g)){const S=o[y++];console.warn(`[aikaara-chat-sdk] preflight #${a} ${h} ${u} → ${f} (transient). Retry #${y} in ${S}ms.`),await new Promise(v=>setTimeout(v,S));continue}const w=`Preflight #${a} ${h} ${u} → ${f} ${g.slice(0,200)}`;if(c.soft){console.warn("[aikaara-chat-sdk]",w);break}throw new Error(w)}catch(m){if(y<o.length){const w=o[y++];console.warn(`[aikaara-chat-sdk] preflight #${a} threw, retry #${y} in ${w}ms`,m),await new Promise(S=>setTimeout(S,w));continue}if(c.soft){console.warn(`[aikaara-chat-sdk] preflight #${a} soft-failed:`,m);break}throw m}if(k&&c.capture&&c.capture.as)try{const m=await k.clone().text();let w=m;try{w=JSON.parse(m)}catch{}if(c.capture.path)for(const S of c.capture.path.split("."))if(w&&typeof w=="object"&&S in w)w=w[S];else{w=void 0;break}if(typeof w=="string"&&w.length>0){let S=w;c.capture.stripPrefix&&S.startsWith(c.capture.stripPrefix)&&(S=S.slice(c.capture.stripPrefix.length)),i[c.capture.as]=S,t[c.capture.as]=S,console.log(`[aikaara-chat-sdk] preflight #${a} captured ${c.capture.as} (${S.slice(0,24)}…)`)}}catch(m){console.warn(`[aikaara-chat-sdk] preflight #${a} capture failed`,m)}}return{captured:i}}function Xd(l,e){if(l===503||l===504||l===502)return!0;if(l===401||l===403)return e.trim().length===0;if(l===500){const t=e.toLowerCase();return t.includes("customernew")||t.includes("is null")||t.includes("not yet ready")}return!1}async function Kl(l,e){const t=await fetch(l,{method:"GET",headers:{accept:"application/json",...e??{}}});if(!t.ok){const s=await t.text().catch(()=>"");throw new Error(`Widget config fetch failed: ${t.status} ${t.statusText} ${s.slice(0,200)}`)}const r=await t.json();if(r&&typeof r=="object"){if("config"in r)return r.config;if("data"in r)return r.data}return r}function Yl(l,e){return l.replace("{projectId}",e).replace("{uuid}",Gd().replace(/-/g,""))}function Ql(l){const e=l._preload;if(!Array.isArray(e)||e.length===0)return;const t=Array.from(new Set(e.map(r=>r&&typeof r=="object"?r.scriptUrl:null).filter(r=>typeof r=="string"&&r.length>0)));t.length!==0&&Promise.allSettled(t.map(r=>jl(r)))}async function Jl(l){const e={...l.config??(l.configUrl?await Kl(l.configUrl,l.configHeaders):{}),...l.overrides??{}};Ql(e);const t=e.transport??"tiledesk",r=e.tiledesk;if((t==="tiledesk"||t==="dual")&&!r)throw new Error("mount: descriptor.tiledesk is required for tiledesk/dual transport");const s=r?.projectId??"",n=l.identity.userId,i=l.forceNewConversation?null:Gl(n,s),o=r?.requestIdTemplate??"support-group-{projectId}-{uuid}",a=l.conversationId??i??Yl(o,s);(!i||l.forceNewConversation)&&s&&Yd(n,s,a);const c=await l.tokenProvider(),u=l.tokenProvider,h=l.historyTokenProvider??u,p=r?{mqttEndpoint:r.mqttEndpoint,jwtToken:c,userId:n,userName:l.identity.userName,projectId:r.projectId,appId:r.appId,mqttUsername:r.mqttUsername,protocolId:r.protocolId,protocolVersion:r.protocolVersion,keepAliveSec:r.keepAliveSec,connectTimeoutMs:r.connectTimeoutMs,maxReconnectAttempts:r.maxReconnectAttempts,reconnectMaxDelayMs:r.reconnectMaxDelayMs,wildcardSubscribe:r.wildcardSubscribe,enablePresence:r.enablePresence,autoInitiateOnEmpty:r.autoInitiateOnEmpty,chatInitiatedAttributes:r.chatInitiatedAttributes,messageDefaults:{...r.messageDefaults,...l.identity.departmentId?{departmentId:l.identity.departmentId}:r.messageDefaults?.departmentId?{departmentId:r.messageDefaults.departmentId}:{}},fileTemplate:r.fileTemplate,topicTemplates:r.topicTemplates,debug:r.debug,senderFullname:l.identity.senderFullname??l.identity.userName,tokenProvider:u}:void 0,b=l.uploadAdapter??(e.uploadEndpoint?uo({endpoint:e.uploadEndpoint,fieldName:e.uploadFieldName,extraFields:e.uploadExtraFields}):void 0),f=l.historyAdapter??(e.historyApiBase?bl({apiBase:e.historyApiBase,pageSize:e.historyPageSize??200,pathTemplate:e.historyPathTemplate,extraHeaders:e.historyHeaders,getToken:h}):void 0),g={transport:t,baseUrl:"",userToken:l.userToken??n,conversationId:a,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:l.getLinkBearer,welcomeMessage:e.welcomeMessage,placeholder:e.placeholder,showTimestamps:e.showTimestamps,persistConversation:e.persistConversation,showHeader:e.showHeader,hideSystemMessages:e.hideSystemMessages,timestampFormat:e.timestampFormat,input:e.input,templateLayout:e.templateLayout,tiledesk:p,tiledeskIdentity:{userId:n,userName:l.identity.userName,departmentId:l.identity.departmentId,senderFullname:l.identity.senderFullname??l.identity.userName},templateActionAttributes:e.templateActionAttributes,uploadAdapter:b,historyAdapter:f,onError:l.onError,onMessage:l.onMessage},y=document.createElement("aikaara-chat-widget");return y.configure(g),g.title&&y.setAttribute("title",g.title),g.primaryColor&&y.setAttribute("primary-color",g.primaryColor),g.display&&y.setAttribute("display",g.display),g.display==="embed"&&(y.style.cssText="display:flex;flex-direction:column;width:100%;height:100%;min-height:0;"),l.container.appendChild(y),{widget:y,requestId:a,config:g,destroy(){y.remove()}}}function Zd(l){if(typeof l!="string")return l;const e=document.querySelector(l);if(!e)throw new Error(`mountFromSlug: container "${l}" not found`);return e}async function Xl(l){const e=(l.configBase??"https://api.aikaara.com").replace(/\/$/,""),t=`${e}/api/v1/widget_configs/${encodeURIComponent(l.slug)}`;let r=null;try{r=await Kl(t,l.configHeaders)}catch(x){if(!l.fallbackConfig)throw x;console.warn(`[aikaara-chat-sdk] Widget config fetch failed for slug "${l.slug}" — using fallbackConfig.`,x)}const s={...l.fallbackConfig??{},...r??{},...l.overrides??{}};if(Ql(s),s.templates&&Object.keys(s.templates).length>0){s.components={...s.components??{}};for(const[x,I]of Object.entries(s.templates)){const P=`template:${x}`;s.components[P]||!I?.scriptUrl||!I?.render||(s.components[P]={kind:"iife-element",scriptUrl:I.scriptUrl,tag:I.render,...I.props?{props:I.props}:{}})}}const n=window;if(n.__aikaara_descriptor__={...n.__aikaara_descriptor__??{},templates:s.templates,components:s.components,razorpay:s.razorpay,title:s.title,cloud:s.cloud??n.__aikaara_descriptor__?.cloud,upload:s.upload??n.__aikaara_descriptor__?.upload,themeSource:s.themeSource??n.__aikaara_descriptor__?.themeSource,api:s.api,auth:s.auth},!s.auth)throw new Error(`mountFromSlug: widget_configs/${l.slug} descriptor must include "auth" block`);let i=null,o=l.user.id,a=l.user.name,c="",u=l.user.token,h=null;const p=await Xt(l.user.token).catch(()=>""),b=typeof p=="string"&&p.length>0;if(!b&&s.sso?.tokenSource){h=new zl({descriptor:{provider:s.sso.provider,flow:s.sso.flow,skipLogin:s.sso.skipLogin,autoRefresh:s.sso.autoRefresh,tokenSource:s.sso.tokenSource,tokenSourceConfig:s.sso.tokenSourceConfig,fallback:s.sso.fallback,map:s.sso.map},initToken:l.user.partnerToken});const x=await h.get();u=async()=>(await h.get()).token,l.user.identity&&!l.user.identity.partnerToken&&(l.user.identity.partnerToken=x.token)}else if(!b&&s.sso&&s.sso.collect&&s.sso.collect.length>0){const x=`${e}/api/v1/projects/by-slug/${encodeURIComponent(l.slug)}/sso_exchange`;i=await new Hl({descriptor:s.sso,providers:l.user.credentialProviders,exchangeUrl:x}).get(),o=i.extUid||o,a=a??i.displayName,c=i.userToken}let f="";if(s.preflight&&s.preflight.length){const x=await Jd(s.preflight,{sessionToken:u,userId:o,projectId:s.tiledesk?.projectId??"",slug:l.slug,identity:l.user.identity});if(x.captured.sessionToken){f=x.captured.sessionToken;const I=f;u=()=>I}}const g=new $l(s.auth,u);if(f){const x=s.tiledesk?.projectId??"",I=x?Gl(o,x):null,P=s.tiledesk?.requestIdTemplate??"support-group-{projectId}-{uuid}",O=I??(x?Yl(P,x):"");g.prime(f,{requestId:O,fullName:a})}const y=await g.get();o=o||y.userId;const k=y.fullName||a||o;window.__aikaara_runtime__={getChatJwt:async()=>(await g.get()).token,identity:l.user.identity,slug:l.slug,configBase:e};const m=h&&s.sso?.autoRefresh?async()=>{try{return await h.refresh(),g.reset(),(await g.get()).token}catch(x){return console.warn("[aikaara-chat-sdk] partner auto-refresh failed",x),null}}:null,w=s.upload,S=async()=>`Bearer ${w&&"tokenSource"in w&&w.tokenSource==="chat"?(await g.get()).token:await Xt(l.user.token)}`,v=l.hooks?.upload??(w&&w.mode==="presigned-3step"?gl({...w,authHeader:S}):w&&w.mode==="direct"?uo({endpoint:w.endpoint,fieldName:w.fieldName,extraFields:w.extraFields,headers:async()=>({authorization:await S()})}):void 0),E=await Jl({container:Zd(l.container),config:s,userToken:c||void 0,identity:{userId:o,userName:k,departmentId:l.user.departmentId,senderFullname:k},tokenProvider:async()=>(await g.get()).token,historyTokenProvider:async()=>(await g.get()).token,uploadAdapter:v,historyAdapter:l.hooks?.history,conversationId:y.requestId||void 0,onError:l.hooks?.onError,onMessage:l.hooks?.onMessage,getLinkBearer:async x=>x==="none"?null:x==="chat"?(await g.get()).token:Xt(l.user.token)});return Object.assign(E,{fullName:k,requestId:y.requestId,descriptor:s,async refreshAuth(){g.reset(),await g.get()},async refreshPartnerAuth(){return m?m():null}})}function ef(l){yo();const e=document.createElement("aikaara-chat-widget"),t={baseUrl:"base-url",userToken:"user-token",apiKey:"api-key",title:"title",subtitle:"subtitle",theme:"theme",primaryColor:"primary-color",position:"position",width:"width",height:"height",placeholder:"placeholder",welcomeMessage:"welcome-message",avatarUrl:"avatar-url"};for(const[r,s]of Object.entries(t)){const n=l[r];n!=null&&e.setAttribute(s,String(n))}return e.configure(l),document.body.appendChild(e),e}function tf(){const l=document.querySelector("aikaara-chat-widget");l&&l.remove()}class Zl 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=`
|
|
1461
|
+
`}}function Ot(l){return l.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Qe(l){return l.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function yo(){const l=[["aikaara-chat-widget",xl],["aikaara-chat-bubble",Sl],["aikaara-chat-header",El],["aikaara-message-list",Il],["aikaara-message-bubble",Cl],["aikaara-chat-input",Pl],["aikaara-typing-indicator",Ml],["aikaara-streaming-message",Rl],["aikaara-error-banner",Ll],["aikaara-template-renderer",gd],["aikaara-system-pill",vd],["aikaara-option-list",wd],["aikaara-submit-action",_d],["aikaara-modal-action",xd],["aikaara-chat",Sd],["aikaara-link-modal",Ed],["aikaara-compare-plans",Td],["aikaara-smart-edit-modal",Cd],["aikaara-schema-form",Md]];for(const[e,t]of l)customElements.get(e)||customElements.define(e,t)}yo();function Hr(l,e,t=""){if(!e)return t;const r=e.split(".");let s=l;for(const n of r)if(s&&typeof s=="object"&&n in s)s=s[n];else return t;return typeof s=="string"?s:t}function Fl(l){try{const e=l.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 Xt(l){return typeof l=="function"?await l():l}class $l{constructor(e,t){this.descriptor=e,this.sessionToken=t}cache=null;inflight=null;reset(){this.cache=null,this.inflight=null}prime(e,t={}){if(!e)return;const r=Fl(e)||Date.now()+3600*1e3;this.cache={token:e,requestId:t.requestId??this.cache?.requestId??"",fullName:t.fullName??this.cache?.fullName??"",userId:t.userId??this.cache?.userId??"",expiresAt:r}}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 Xt(this.sessionToken),t=this.descriptor.authHeader??"Authorization",r=this.descriptor.authHeaderTemplate??"Bearer {token}",s={accept:"application/json",...this.descriptor.headers??{},[t]:r.replace("{token}",e)},n=this.descriptor.method??"POST",i={method:n,headers:s};n==="POST"&&(s["content-type"]="application/json",i.body=JSON.stringify(this.descriptor.body??{}));const o=await fetch(this.descriptor.endpoint,i);if(!o.ok){const k=await o.text().catch(()=>"");throw new Error(`Session auth failed: ${o.status} ${k.slice(0,200)}`)}const a=await o.json().catch(()=>({})),c=Hr(a,this.descriptor.tokenPath??"data.token"),u=this.descriptor.tokenStripPrefix,h=u?c.replace(new RegExp(`^${u}`,"i"),"").trim():c;if(!h)throw new Error("Session auth response missing token");const p=Hr(a,this.descriptor.requestIdPath??"data.requestId"),b=this.cache?.requestId||p||"",f=Hr(a,this.descriptor.fullNamePath??"data.fullName"),g=Hr(a,this.descriptor.userPath??"data.userId"),y=Fl(h)||Date.now()+3600*1e3;return this.cache={token:h,requestId:b,fullName:f,userId:g,expiresAt:y},this.cache}}async function ql(l){const e={};for(const t of l.spec){const r=await Rd(t,l.providers);if(r!==void 0&&r!=="")e[t.name]=r;else{if(t.required)throw new Error(`[aikaara-chat-sdk] SSO credential "${t.name}" is required but ${t.source}`+(t.key?`[${t.key}]`:"")+" returned no value");t.default!==void 0&&(e[t.name]=t.default)}}return e}async function Rd(l,e){const t=l.key??l.name;switch(l.source){case"cookie":return Ld(t);case"localStorage":return Wr(()=>window.localStorage.getItem(t)??void 0);case"sessionStorage":return Wr(()=>window.sessionStorage.getItem(t)??void 0);case"url_param":return Wr(()=>new URL(window.location.href).searchParams.get(t)??void 0);case"header_meta":return Wr(()=>document.querySelector(`meta[name="${jd(t)}"]`)?.content??void 0);case"callback":{const r=e?.[l.name];if(!r)return;const s=await r();return typeof s=="string"?s:void 0}default:return}}function Ld(l){if(typeof document>"u")return;const e=encodeURIComponent(l),t=document.cookie?document.cookie.split("; "):[];for(const r of t){const s=r.indexOf("=");if(s===-1)continue;const n=r.slice(0,s);if(n===l||n===e)try{return decodeURIComponent(r.slice(s+1))}catch{return r.slice(s+1)}}}function Wr(l){try{return l()}catch{return}}function jd(l){return l.replace(/["\\]/g,"\\$&")}const Nd=1800;class Hl{constructor(e){this.opts=e,this.cache=this.loadCache()}cache=null;inflight=null;reset(){this.cache=null,this.inflight=null,this.clearCache()}async get(e=!1){if(!e){const t=this.cache;if(t&&(!t.expiresAt||t.expiresAt>Date.now()))return t}return this.inflight?this.inflight:(this.inflight=this.exchange().finally(()=>{this.inflight=null}),this.inflight)}async exchange(){if(!this.opts.descriptor.collect||this.opts.descriptor.collect.length===0)throw new Error("[aikaara-chat-sdk] SsoExchangeAdapter.exchange() requires descriptor.sso.collect; v2 partner-token flow should be handled by TokenDiscoveryReader instead.");const e=await ql({spec:this.opts.descriptor.collect,providers:this.opts.providers}),t=JSON.stringify({credentials:e}),r={accept:"application/json","content-type":"application/json",...this.opts.descriptor.headers??{}};this.opts.descriptor.apiKey&&(r["X-Api-Key"]=this.opts.descriptor.apiKey);const s=this.opts.descriptor.exchangeEndpoint||this.opts.exchangeUrl;if(!s)throw new Error("[aikaara-chat-sdk] SSO exchange URL not resolved — set descriptor.sso.exchangeEndpoint or pass `exchangeUrl` (mountFromSlug derives it from configBase + slug).");const n=await fetch(s,{method:"POST",headers:r,body:t});if(!n.ok){const h=await n.text().catch(()=>"");throw new Error(`SSO exchange failed: ${n.status} ${h.slice(0,240)}`)}const o=(await n.json().catch(()=>({}))).user??{},a=String(o.ext_uid??o.extUid??""),c=String(o.token??o.user_token??o.userToken??"");if(!a)throw new Error("SSO exchange response missing user.ext_uid");if(!c)throw new Error("SSO exchange response missing user.token");const u={id:o.id,extUid:a,userToken:c,email:typeof o.email=="string"?o.email:void 0,displayName:typeof o.display_name=="string"?o.display_name:typeof o.displayName=="string"?o.displayName:void 0,properties:o.properties&&typeof o.properties=="object"?o.properties:void 0,expiresAt:this.computeExpiry()};return this.cache=u,this.persistCache(u),u}computeExpiry(){const e=this.opts.descriptor.cacheTtlSec??Nd;if(!(!this.opts.descriptor.cacheKey||e<=0))return Date.now()+e*1e3}loadCache(){const e=this.opts.descriptor.cacheKey;if(!e)return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const r=JSON.parse(t);return r.expiresAt&&r.expiresAt<Date.now()?(window.localStorage.removeItem(e),null):r}catch{return null}}persistCache(e){const t=this.opts.descriptor.cacheKey;if(t)try{window.localStorage.setItem(t,JSON.stringify(e))}catch{}}clearCache(){const e=this.opts.descriptor.cacheKey;if(e)try{window.localStorage.removeItem(e)}catch{}}}const Ud=3e4,Bd=2e3,Dd=100;async function Wl(l){const{descriptor:e}=l,t=e.tokenSourceConfig??{};switch(e.tokenSource){case"init":{if(!l.initToken)throw new Ke("init","No init token supplied to Aikaara.init({token})");return{token:l.initToken,source:"init"}}case"query":{const r=typeof t.key=="string"&&t.key?t.key:"token",s=Fd(r);if(!s)throw new Ke("query",`?${r}= not present`);return{token:s,source:"query"}}case"hash":{const r=typeof t.key=="string"&&t.key?t.key:"token",s=$d(r);if(!s)throw new Ke("hash",`#${r}= not present`);return{token:s,source:"hash"}}case"postmsg":{const r=typeof t.type=="string"?t.type:"",s=typeof t.key=="string"&&t.key?t.key:"token",n=Vd(typeof t.origins=="string"?t.origins:""),i=typeof t.timeoutMs=="number"&&t.timeoutMs>0?t.timeoutMs:Ud;return{token:await zd({type:r,key:s,origins:n,timeoutMs:i}),source:"postmsg"}}case"cookie":{const r=typeof t.name=="string"&&t.name?t.name:"";if(!r)throw new Ke("cookie","cookie.name not configured");const s=qd(r);if(!s)throw new Ke("cookie",`cookie "${r}" not set`);return{token:s,source:"cookie"}}case"storage":{const r=t.store==="session"?"session":"local",s=typeof t.key=="string"&&t.key?t.key:"",n=typeof t.path=="string"?t.path:"";if(!s)throw new Ke("storage","storage.key not configured");const i=Hd(r,s,n);if(!i)throw new Ke("storage",`${r}Storage["${s}"] not set`);return{token:i,source:"storage"}}case"global":{const r=typeof t.path=="string"?t.path:"";if(!r)throw new Ke("global","global.path not configured");const s=typeof t.timeoutMs=="number"&&t.timeoutMs>0?t.timeoutMs:Bd,n=typeof t.intervalMs=="number"&&t.intervalMs>0?t.intervalMs:Dd,i=await Wd(r,s,n);if(!i)throw new Ke("global",`window.${r} not present`);return{token:i,source:"global"}}default:{const r=e.tokenSource;throw new Ke("unknown",`Unknown tokenSource ${JSON.stringify(r)}`)}}}class zl{constructor(e){this.opts=e}cached=null;get descriptor(){return this.opts.descriptor}async get(){if(this.cached)return this.cached;const e=await Wl(this.opts);return this.cached=e,e}async refresh(){return this.opts.descriptor.tokenSource==="init"?this.cached?this.cached:this.get():(this.cached=null,this.get())}}class Ke extends Error{constructor(e,t){super(`[aikaara-chat-sdk] token-discovery (${e}): ${t}`),this.source=e,this.name="TokenDiscoveryError"}}function Fd(l){if(!(typeof window>"u"))try{return new URL(window.location.href).searchParams.get(l)??void 0}catch{return}}function $d(l){if(!(typeof window>"u"))try{const e=window.location.hash.replace(/^#/,"");return new URLSearchParams(e).get(l)??void 0}catch{return}}function qd(l){if(typeof document>"u")return;const e=encodeURIComponent(l),t=document.cookie?document.cookie.split("; "):[];for(const r of t){const s=r.indexOf("=");if(s===-1)continue;const n=r.slice(0,s);if(n===l||n===e)try{return decodeURIComponent(r.slice(s+1))}catch{return r.slice(s+1)}}}function Hd(l,e,t){if(!(typeof window>"u"))try{const s=(l==="session"?window.sessionStorage:window.localStorage).getItem(e);if(s==null)return;if(!t)return s;let n;try{n=JSON.parse(s)}catch{return s}const i=Vl(n,t);return typeof i=="string"?i:void 0}catch{return}}async function Wd(l,e,t){if(typeof window>"u")return;const r=Date.now()+e;for(;Date.now()<r;){const s=Vl(window,l);if(typeof s=="string"&&s.length>0)return s;if(typeof s=="function")try{const n=s();if(typeof n=="string"&&n.length>0)return n}catch{}await new Promise(n=>setTimeout(n,t))}}function zd(l){return new Promise((e,t)=>{if(typeof window>"u"){t(new Ke("postmsg","no window"));return}const r=()=>{window.removeEventListener("message",n),clearTimeout(s)},s=setTimeout(()=>{r(),t(new Ke("postmsg",`timeout after ${l.timeoutMs}ms`))},l.timeoutMs),n=i=>{if(l.origins.length>0&&!l.origins.includes(i.origin))return;const o=i.data;if(!o||typeof o!="object")return;const a=o;if(l.type&&a.type!==l.type)return;const c=a[l.key];typeof c=="string"&&c.length>0&&(r(),e(c))};window.addEventListener("message",n)})}function Vd(l){return l?l.split(/[,\s]+/).map(e=>e.trim()).filter(Boolean):[]}function Vl(l,e){if(!e)return l;const t=e.split(".").filter(Boolean);let r=l;for(const s of t)if(r&&typeof r=="object"&&s in r)r=r[s];else return;return r}function Gd(){const l=typeof crypto<"u"?crypto:null;if(l?.randomUUID)return l.randomUUID();if(l?.getRandomValues){const e=new Uint8Array(16);l.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;const t=[...e].map(r=>r.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 Kd="aikaara_chat:requestId";function vo(l,e){return`${Kd}:${l}:${e}`}function Gl(l,e){try{return localStorage.getItem(vo(l,e))}catch{return null}}function Yd(l,e,t){try{localStorage.setItem(vo(l,e),t)}catch{}}function Qd(l,e){try{localStorage.removeItem(vo(l,e))}catch{}}async function Jd(l,e){console.log("[aikaara-chat-sdk] preflight running",l.length,"steps");const t={userId:e.userId,projectId:e.projectId,slug:e.slug};if(e.identity)for(const[a,c]of Object.entries(e.identity))typeof c=="string"&&(t[a]=c);const r=a=>a.replace(/\{(\w+)\}/g,(c,u)=>u in t?t[u]:""),s=a=>{if(typeof a=="string")return r(a);if(Array.isArray(a))return a.map(s);if(a&&typeof a=="object"){const c={};for(const[u,h]of Object.entries(a))c[u]=s(h);return c}return a},n=await Xt(e.sessionToken),i={},o=[800,1500,3e3,5e3,8e3];for(let a=0;a<l.length;a++){const c=l[a],u=r(c.url),h=c.method??(c.body?"POST":"GET"),p={accept:"application/json",...c.headers??{}};if((c.authHeader??"session")==="session"){const m=c.authHeaderTemplate??"Bearer {token}";p.authorization=m.replace("{token}",n)}const b={method:h,headers:p};c.body&&(p["content-type"]="application/json",b.body=JSON.stringify(s(c.body)));let f=0,g="",y=0,k=null;for(;;)try{const m=await fetch(u,b);if(m.ok){k=m;break}if(f=m.status,g=await m.text().catch(()=>""),y<o.length&&Xd(f,g)){const S=o[y++];console.warn(`[aikaara-chat-sdk] preflight #${a} ${h} ${u} → ${f} (transient). Retry #${y} in ${S}ms.`),await new Promise(v=>setTimeout(v,S));continue}const w=`Preflight #${a} ${h} ${u} → ${f} ${g.slice(0,200)}`;if(c.soft){console.warn("[aikaara-chat-sdk]",w);break}throw new Error(w)}catch(m){if(y<o.length){const w=o[y++];console.warn(`[aikaara-chat-sdk] preflight #${a} threw, retry #${y} in ${w}ms`,m),await new Promise(S=>setTimeout(S,w));continue}if(c.soft){console.warn(`[aikaara-chat-sdk] preflight #${a} soft-failed:`,m);break}throw m}if(k&&c.capture&&c.capture.as)try{const m=await k.clone().text();let w=m;try{w=JSON.parse(m)}catch{}if(c.capture.path)for(const S of c.capture.path.split("."))if(w&&typeof w=="object"&&S in w)w=w[S];else{w=void 0;break}if(typeof w=="string"&&w.length>0){let S=w;c.capture.stripPrefix&&S.startsWith(c.capture.stripPrefix)&&(S=S.slice(c.capture.stripPrefix.length)),i[c.capture.as]=S,t[c.capture.as]=S,console.log(`[aikaara-chat-sdk] preflight #${a} captured ${c.capture.as} (${S.slice(0,24)}…)`)}}catch(m){console.warn(`[aikaara-chat-sdk] preflight #${a} capture failed`,m)}}return{captured:i}}function Xd(l,e){if(l===503||l===504||l===502)return!0;if(l===401||l===403)return e.trim().length===0;if(l===500){const t=e.toLowerCase();return t.includes("customernew")||t.includes("is null")||t.includes("not yet ready")}return!1}async function Kl(l,e){const t=await fetch(l,{method:"GET",headers:{accept:"application/json",...e??{}}});if(!t.ok){const s=await t.text().catch(()=>"");throw new Error(`Widget config fetch failed: ${t.status} ${t.statusText} ${s.slice(0,200)}`)}const r=await t.json();if(r&&typeof r=="object"){if("config"in r)return r.config;if("data"in r)return r.data}return r}function Yl(l,e){return l.replace("{projectId}",e).replace("{uuid}",Gd().replace(/-/g,""))}function Ql(l){const e=l._preload;if(!Array.isArray(e)||e.length===0)return;const t=Array.from(new Set(e.map(r=>r&&typeof r=="object"?r.scriptUrl:null).filter(r=>typeof r=="string"&&r.length>0)));t.length!==0&&Promise.allSettled(t.map(r=>jl(r)))}async function Jl(l){const e={...l.config??(l.configUrl?await Kl(l.configUrl,l.configHeaders):{}),...l.overrides??{}};Ql(e);const t=e.transport??"tiledesk",r=e.tiledesk;if((t==="tiledesk"||t==="dual")&&!r)throw new Error("mount: descriptor.tiledesk is required for tiledesk/dual transport");const s=r?.projectId??"",n=l.identity.userId,i=l.forceNewConversation?null:Gl(n,s),o=r?.requestIdTemplate??"support-group-{projectId}-{uuid}",a=l.conversationId??i??Yl(o,s);(!i||l.forceNewConversation)&&s&&Yd(n,s,a);const c=await l.tokenProvider(),u=l.tokenProvider,h=l.historyTokenProvider??u,p=r?{mqttEndpoint:r.mqttEndpoint,jwtToken:c,userId:n,userName:l.identity.userName,projectId:r.projectId,appId:r.appId,mqttUsername:r.mqttUsername,protocolId:r.protocolId,protocolVersion:r.protocolVersion,keepAliveSec:r.keepAliveSec,connectTimeoutMs:r.connectTimeoutMs,maxReconnectAttempts:r.maxReconnectAttempts,reconnectMaxDelayMs:r.reconnectMaxDelayMs,wildcardSubscribe:r.wildcardSubscribe,enablePresence:r.enablePresence,autoInitiateOnEmpty:r.autoInitiateOnEmpty,chatInitiatedAttributes:r.chatInitiatedAttributes,messageDefaults:{...r.messageDefaults,...l.identity.departmentId?{departmentId:l.identity.departmentId}:r.messageDefaults?.departmentId?{departmentId:r.messageDefaults.departmentId}:{}},fileTemplate:r.fileTemplate,topicTemplates:r.topicTemplates,debug:r.debug,senderFullname:l.identity.senderFullname??l.identity.userName,tokenProvider:u}:void 0,b=l.uploadAdapter??(e.uploadEndpoint?uo({endpoint:e.uploadEndpoint,fieldName:e.uploadFieldName,extraFields:e.uploadExtraFields}):void 0),f=l.historyAdapter??(e.historyApiBase?bl({apiBase:e.historyApiBase,pageSize:e.historyPageSize??200,pathTemplate:e.historyPathTemplate,extraHeaders:e.historyHeaders,getToken:h}):void 0),g={transport:t,baseUrl:"",userToken:l.userToken??n,conversationId:a,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:l.getLinkBearer,welcomeMessage:e.welcomeMessage,placeholder:e.placeholder,showTimestamps:e.showTimestamps,persistConversation:e.persistConversation,showHeader:e.showHeader,hideSystemMessages:e.hideSystemMessages,timestampFormat:e.timestampFormat,input:e.input,templateLayout:e.templateLayout,tiledesk:p,tiledeskIdentity:{userId:n,userName:l.identity.userName,departmentId:l.identity.departmentId,senderFullname:l.identity.senderFullname??l.identity.userName},templateActionAttributes:e.templateActionAttributes,uploadAdapter:b,historyAdapter:f,onError:l.onError,onMessage:l.onMessage},y=document.createElement("aikaara-chat-widget");return y.configure(g),g.title&&y.setAttribute("title",g.title),g.primaryColor&&y.setAttribute("primary-color",g.primaryColor),g.display&&y.setAttribute("display",g.display),g.display==="embed"&&(y.style.cssText="display:flex;flex-direction:column;width:100%;height:100%;min-height:0;--aikaara-close-btn-display:none;"),l.container.appendChild(y),{widget:y,requestId:a,config:g,destroy(){y.remove()}}}function Zd(l){if(typeof l!="string")return l;const e=document.querySelector(l);if(!e)throw new Error(`mountFromSlug: container "${l}" not found`);return e}async function Xl(l){const e=(l.configBase??"https://api.aikaara.com").replace(/\/$/,""),t=`${e}/api/v1/widget_configs/${encodeURIComponent(l.slug)}`;let r=null;try{r=await Kl(t,l.configHeaders)}catch(x){if(!l.fallbackConfig)throw x;console.warn(`[aikaara-chat-sdk] Widget config fetch failed for slug "${l.slug}" — using fallbackConfig.`,x)}const s={...l.fallbackConfig??{},...r??{},...l.overrides??{}};if(Ql(s),s.templates&&Object.keys(s.templates).length>0){s.components={...s.components??{}};for(const[x,I]of Object.entries(s.templates)){const P=`template:${x}`;s.components[P]||!I?.scriptUrl||!I?.render||(s.components[P]={kind:"iife-element",scriptUrl:I.scriptUrl,tag:I.render,...I.props?{props:I.props}:{}})}}const n=window;if(n.__aikaara_descriptor__={...n.__aikaara_descriptor__??{},templates:s.templates,components:s.components,razorpay:s.razorpay,title:s.title,cloud:s.cloud??n.__aikaara_descriptor__?.cloud,upload:s.upload??n.__aikaara_descriptor__?.upload,themeSource:s.themeSource??n.__aikaara_descriptor__?.themeSource,api:s.api,auth:s.auth},!s.auth)throw new Error(`mountFromSlug: widget_configs/${l.slug} descriptor must include "auth" block`);let i=null,o=l.user.id,a=l.user.name,c="",u=l.user.token,h=null;const p=await Xt(l.user.token).catch(()=>""),b=typeof p=="string"&&p.length>0;if(!b&&s.sso?.tokenSource){h=new zl({descriptor:{provider:s.sso.provider,flow:s.sso.flow,skipLogin:s.sso.skipLogin,autoRefresh:s.sso.autoRefresh,tokenSource:s.sso.tokenSource,tokenSourceConfig:s.sso.tokenSourceConfig,fallback:s.sso.fallback,map:s.sso.map},initToken:l.user.partnerToken});const x=await h.get();u=async()=>(await h.get()).token,l.user.identity&&!l.user.identity.partnerToken&&(l.user.identity.partnerToken=x.token)}else if(!b&&s.sso&&s.sso.collect&&s.sso.collect.length>0){const x=`${e}/api/v1/projects/by-slug/${encodeURIComponent(l.slug)}/sso_exchange`;i=await new Hl({descriptor:s.sso,providers:l.user.credentialProviders,exchangeUrl:x}).get(),o=i.extUid||o,a=a??i.displayName,c=i.userToken}let f="";if(s.preflight&&s.preflight.length){const x=await Jd(s.preflight,{sessionToken:u,userId:o,projectId:s.tiledesk?.projectId??"",slug:l.slug,identity:l.user.identity});if(x.captured.sessionToken){f=x.captured.sessionToken;const I=f;u=()=>I}x.captured.userId&&(o=x.captured.userId)}const g=new $l(s.auth,u);if(f){const x=s.tiledesk?.projectId??"",I=x?Gl(o,x):null,P=s.tiledesk?.requestIdTemplate??"support-group-{projectId}-{uuid}",O=I??(x?Yl(P,x):"");g.prime(f,{requestId:O,fullName:a})}const y=await g.get();o=o||y.userId;const k=y.fullName||a||o;window.__aikaara_runtime__={getChatJwt:async()=>(await g.get()).token,identity:l.user.identity,slug:l.slug,configBase:e};const m=h&&s.sso?.autoRefresh?async()=>{try{return await h.refresh(),g.reset(),(await g.get()).token}catch(x){return console.warn("[aikaara-chat-sdk] partner auto-refresh failed",x),null}}:null,w=s.upload,S=async()=>`Bearer ${w&&"tokenSource"in w&&w.tokenSource==="chat"?(await g.get()).token:await Xt(l.user.token)}`,v=l.hooks?.upload??(w&&w.mode==="presigned-3step"?gl({...w,authHeader:S}):w&&w.mode==="direct"?uo({endpoint:w.endpoint,fieldName:w.fieldName,extraFields:w.extraFields,headers:async()=>({authorization:await S()})}):void 0),E=await Jl({container:Zd(l.container),config:s,userToken:c||void 0,identity:{userId:o,userName:k,departmentId:l.user.departmentId,senderFullname:k},tokenProvider:async()=>(await g.get()).token,historyTokenProvider:async()=>(await g.get()).token,uploadAdapter:v,historyAdapter:l.hooks?.history,conversationId:y.requestId||void 0,onError:l.hooks?.onError,onMessage:l.hooks?.onMessage,getLinkBearer:async x=>x==="none"?null:x==="chat"?(await g.get()).token:Xt(l.user.token)});return Object.assign(E,{fullName:k,requestId:y.requestId,descriptor:s,async refreshAuth(){g.reset(),await g.get()},async refreshPartnerAuth(){return m?m():null}})}function ef(l){yo();const e=document.createElement("aikaara-chat-widget"),t={baseUrl:"base-url",userToken:"user-token",apiKey:"api-key",title:"title",subtitle:"subtitle",theme:"theme",primaryColor:"primary-color",position:"position",width:"width",height:"height",placeholder:"placeholder",welcomeMessage:"welcome-message",avatarUrl:"avatar-url"};for(const[r,s]of Object.entries(t)){const n=l[r];n!=null&&e.setAttribute(s,String(n))}return e.configure(l),document.body.appendChild(e),e}function tf(){const l=document.querySelector("aikaara-chat-widget");l&&l.remove()}class Zl 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=`
|
|
1459
1462
|
<style>
|
|
1460
1463
|
:host { display: block; margin-top: 8px; }
|
|
1461
1464
|
button {
|
package/dist/headless.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./MountTenant-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./MountTenant-CP_CYdl8.cjs");class s extends e.EventEmitter{registration=null;pendingEdits=[];constructor(t){super(),this.setupListeners(t)}registerForm(t){this.registration=t;const i=this.pendingEdits.filter(r=>r.entity_type===t.entityType&&String(r.entity_id)===String(t.entityId));if(i.length>0){for(const r of i)t.onFieldUpdate(r.fields),this.emit("edit:applied",{entityType:r.entity_type,entityId:r.entity_id,fields:r.fields});this.pendingEdits=this.pendingEdits.filter(r=>!(r.entity_type===t.entityType&&String(r.entity_id)===String(t.entityId)))}}unregisterForm(t,i){this.registration?.entityType===t&&String(this.registration?.entityId)===String(i)&&(this.registration=null)}get currentForm(){return this.registration}pushFieldUpdates(t,i,r){this.registration&&this.registration.entityType===t&&String(this.registration.entityId)===String(i)?(this.registration.onFieldUpdate(r),this.emit("edit:applied",{entityType:t,entityId:i,fields:r})):(this.pendingEdits.push({action:"edit_entity",entity_type:t,entity_id:i,fields:r}),this.emit("edit:pending",{entityType:t,entityId:i,fields:r}))}async requestSave(){if(!this.registration)return{success:!1,error:"No form registered"};try{return await this.registration.onSave(),this.emit("save:success",{entityType:this.registration.entityType,entityId:this.registration.entityId}),{success:!0}}catch(t){const i=t instanceof Error?t.message:"Save failed";return this.emit("save:error",{entityType:this.registration.entityType,entityId:this.registration.entityId,error:i}),{success:!1,error:i}}}async requestTest(t){if(!this.registration?.onTest)return{success:!1,error:"Current form does not support testing"};try{return await this.registration.onTest(t),{success:!0}}catch(i){return{success:!1,error:i instanceof Error?i.message:"Test failed"}}}setupListeners(t){t.on("action:edit_entity",i=>{this.pushFieldUpdates(i.entity_type,i.entity_id,i.fields)}),t.on("action:save_entity",i=>{this.requestSave()}),t.on("action:test_tool",i=>{this.emit("test:triggered",{toolId:i.tool_id,parameters:i.parameters}),this.requestTest(i.parameters)})}}exports.ActionCableClient=e.ActionCableClient;exports.AikaaraChatClient=e.AikaaraChatClient;exports.ApiClient=e.ApiClient;exports.ChannelSubscription=e.ChannelSubscription;exports.ConnectionManager=e.ConnectionManager;exports.ConversationManager=e.ConversationManager;exports.EventEmitter=e.EventEmitter;exports.MessageStore=e.MessageStore;exports.SessionAuthAdapter=e.SessionAuthAdapter;exports.SsoExchangeAdapter=e.SsoExchangeAdapter;exports.TiledeskTransport=e.TiledeskTransport;exports.TokenDiscoveryError=e.TokenDiscoveryError;exports.TokenDiscoveryReader=e.TokenDiscoveryReader;exports.clearPersistedConversationId=e.clearPersistedConversationId;exports.collectSsoCredentials=e.collectSsoCredentials;exports.createFetchUploadAdapter=e.createFetchUploadAdapter;exports.createPresigned3StepUploadAdapter=e.createPresigned3StepUploadAdapter;exports.createTiledeskHistoryAdapter=e.createTiledeskHistoryAdapter;exports.discoverToken=e.discoverToken;exports.extractTiledeskFileEnvelope=e.extractTiledeskFileEnvelope;exports.inferTiledeskRole=e.inferTiledeskRole;exports.isTiledeskSelfEcho=e.isTiledeskSelfEcho;exports.mountFromSlug=e.mountFromSlug;exports.mountTenantWidget=e.mount;exports.parseTiledeskTemplate=e.parseTiledeskTemplate;exports.FormBridge=s;
|
package/dist/headless.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as s } from "./MountTenant-
|
|
2
|
-
import { A as p, b as l, k as g, C as c, l as h, m as y, M as u, S as m, n as f, T, o as S, p as _, q as v, s as E, t as C, u as F, v as k, w as A, x as I, y as x, z as U, B as q, D as M, F as b } from "./MountTenant-
|
|
1
|
+
import { E as s } from "./MountTenant-8zB0FoEP.mjs";
|
|
2
|
+
import { A as p, b as l, k as g, C as c, l as h, m as y, M as u, S as m, n as f, T, o as S, p as _, q as v, s as E, t as C, u as F, v as k, w as A, x as I, y as x, z as U, B as q, D as M, F as b } from "./MountTenant-8zB0FoEP.mjs";
|
|
3
3
|
class a extends s {
|
|
4
4
|
registration = null;
|
|
5
5
|
pendingEdits = [];
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./MountTenant-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./MountTenant-CP_CYdl8.cjs"),s=require("./headless.cjs");function l(a){e.registerComponents();const t=document.createElement("aikaara-chat-widget"),i={baseUrl:"base-url",userToken:"user-token",apiKey:"api-key",title:"title",subtitle:"subtitle",theme:"theme",primaryColor:"primary-color",position:"position",width:"width",height:"height",placeholder:"placeholder",welcomeMessage:"welcome-message",avatarUrl:"avatar-url"};for(const[o,n]of Object.entries(i)){const r=a[o];r!=null&&t.setAttribute(n,String(r))}return t.configure(a),document.body.appendChild(t),t}function d(){const a=document.querySelector("aikaara-chat-widget");a&&a.remove()}exports.ActionCableClient=e.ActionCableClient;exports.AikaaraChatBubble=e.AikaaraChatBubble;exports.AikaaraChatClient=e.AikaaraChatClient;exports.AikaaraChatHeader=e.AikaaraChatHeader;exports.AikaaraChatInput=e.AikaaraChatInput;exports.AikaaraChatWidget=e.AikaaraChatWidget;exports.AikaaraErrorBanner=e.AikaaraErrorBanner;exports.AikaaraMessageBubble=e.AikaaraMessageBubble;exports.AikaaraMessageList=e.AikaaraMessageList;exports.AikaaraStreamingMessage=e.AikaaraStreamingMessage;exports.AikaaraTypingIndicator=e.AikaaraTypingIndicator;exports.ApiClient=e.ApiClient;exports.ChannelSubscription=e.ChannelSubscription;exports.ConnectionManager=e.ConnectionManager;exports.ConversationManager=e.ConversationManager;exports.EventEmitter=e.EventEmitter;exports.MessageStore=e.MessageStore;exports.SessionAuthAdapter=e.SessionAuthAdapter;exports.SsoExchangeAdapter=e.SsoExchangeAdapter;exports.TiledeskTransport=e.TiledeskTransport;exports.TokenDiscoveryError=e.TokenDiscoveryError;exports.TokenDiscoveryReader=e.TokenDiscoveryReader;exports.clearPersistedConversationId=e.clearPersistedConversationId;exports.collectSsoCredentials=e.collectSsoCredentials;exports.createFetchUploadAdapter=e.createFetchUploadAdapter;exports.createPresigned3StepUploadAdapter=e.createPresigned3StepUploadAdapter;exports.createTiledeskHistoryAdapter=e.createTiledeskHistoryAdapter;exports.discoverToken=e.discoverToken;exports.extractTiledeskFileEnvelope=e.extractTiledeskFileEnvelope;exports.inferTiledeskRole=e.inferTiledeskRole;exports.isTiledeskSelfEcho=e.isTiledeskSelfEcho;exports.mountFromSlug=e.mountFromSlug;exports.mountTenantWidget=e.mount;exports.parseTiledeskTemplate=e.parseTiledeskTemplate;exports.registerComponents=e.registerComponents;exports.FormBridge=s.FormBridge;exports.mount=l;exports.unmount=d;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as o } from "./MountTenant-
|
|
2
|
-
import { A as u, a as m, b as k, c as g, d as h, e as A, f as C, g as T, h as b, i as v, j as f, k as y, C as S, l as w, m as E, E as M, M as x, S as B, n as F, T as U, o as D, p as I, q as j, s as q, t as H, u as P, v as R, w as W, x as z, y as K, z as L, B as O, D as G, F as J } from "./MountTenant-
|
|
1
|
+
import { r as o } from "./MountTenant-8zB0FoEP.mjs";
|
|
2
|
+
import { A as u, a as m, b as k, c as g, d as h, e as A, f as C, g as T, h as b, i as v, j as f, k as y, C as S, l as w, m as E, E as M, M as x, S as B, n as F, T as U, o as D, p as I, q as j, s as q, t as H, u as P, v as R, w as W, x as z, y as K, z as L, B as O, D as G, F as J } from "./MountTenant-8zB0FoEP.mjs";
|
|
3
3
|
import { FormBridge as Q } from "./headless.mjs";
|
|
4
4
|
function l(e) {
|
|
5
5
|
o();
|
package/dist/ui.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./MountTenant-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./MountTenant-CP_CYdl8.cjs");exports.AikaaraChat=a.AikaaraChat;exports.AikaaraChatBubble=a.AikaaraChatBubble;exports.AikaaraChatHeader=a.AikaaraChatHeader;exports.AikaaraChatInput=a.AikaaraChatInput;exports.AikaaraChatWidget=a.AikaaraChatWidget;exports.AikaaraComparePlans=a.AikaaraComparePlans;exports.AikaaraErrorBanner=a.AikaaraErrorBanner;exports.AikaaraLinkModal=a.AikaaraLinkModal;exports.AikaaraMessageBubble=a.AikaaraMessageBubble;exports.AikaaraMessageList=a.AikaaraMessageList;exports.AikaaraModalAction=a.AikaaraModalAction;exports.AikaaraOptionList=a.AikaaraOptionList;exports.AikaaraSchemaForm=a.AikaaraSchemaForm;exports.AikaaraSmartEditModal=a.AikaaraSmartEditModal;exports.AikaaraStreamingMessage=a.AikaaraStreamingMessage;exports.AikaaraSubmitAction=a.AikaaraSubmitAction;exports.AikaaraSystemPill=a.AikaaraSystemPill;exports.AikaaraTemplateRenderer=a.AikaaraTemplateRenderer;exports.AikaaraTypingIndicator=a.AikaaraTypingIndicator;exports.registerComponents=a.registerComponents;
|
package/dist/ui.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as i, a as s, c as e, d as t, e as A, H as k, f as n, I as o, g as m, h as d, J as l, K as g, L as h, N as p, i as C, O as M, P as b, Q as c, j as S, r as u } from "./MountTenant-
|
|
1
|
+
import { G as i, a as s, c as e, d as t, e as A, H as k, f as n, I as o, g as m, h as d, J as l, K as g, L as h, N as p, i as C, O as M, P as b, Q as c, j as S, r as u } from "./MountTenant-8zB0FoEP.mjs";
|
|
2
2
|
export {
|
|
3
3
|
i as AikaaraChat,
|
|
4
4
|
s as AikaaraChatBubble,
|