@prodantix/sdk 0.7.0-beta.437 → 0.7.0-beta.440
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat.cjs +5 -103
- package/dist/chat.d.cts +93 -8
- package/dist/chat.d.ts +93 -8
- package/dist/chat.js +5 -103
- package/dist/chunk-L4P6GMBC.js +2 -0
- package/dist/client-Cz7M6XJC.d.ts +477 -0
- package/dist/client-vogZuHfD.d.cts +477 -0
- package/dist/{config-6ulvfBFp.d.ts → config-Dmk59mPh.d.ts} +41 -2
- package/dist/{config-g14Jiv1t.d.cts → config-Dxf1vAMu.d.cts} +41 -2
- package/dist/consent.iife.js +20 -0
- package/dist/ctas.iife.js +37 -0
- package/dist/forms.iife.js +16 -0
- package/dist/guides.iife.js +3 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +1 -1
- package/dist/messenger-help.iife.js +1 -1
- package/dist/messenger-tickets.iife.js +3 -0
- package/dist/messenger.cjs +1 -1
- package/dist/messenger.d.cts +1 -1
- package/dist/messenger.d.ts +1 -1
- package/dist/messenger.iife.js +5 -103
- package/dist/messenger.js +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.d.cts +3 -2
- package/dist/node.d.ts +3 -2
- package/dist/node.js +1 -1
- package/dist/pages.iife.js +2 -0
- package/dist/prodantix-push-sw.js +3 -0
- package/dist/surveys.iife.js +2 -0
- package/dist/{transport-DKFvkfX4.d.ts → transport-C4mkCaix.d.ts} +1 -1
- package/dist/{transport-DN9pXyrX.d.cts → transport-C9C4hqlF.d.cts} +1 -1
- package/dist/{types-Q2VNlJbG.d.cts → types-BUXFV_aE.d.cts} +11 -0
- package/dist/{types-Q2VNlJbG.d.ts → types-BUXFV_aE.d.ts} +11 -0
- package/dist/web.cjs +36 -1
- package/dist/web.d.cts +185 -4
- package/dist/web.d.ts +185 -4
- package/dist/web.js +36 -1
- package/package.json +1 -1
- package/dist/chunk-D6PMLUYA.js +0 -2
- package/dist/client-CL6Xvhay.d.cts +0 -135
- package/dist/client-QyKW0LFW.d.ts +0 -135
package/dist/chat.cjs
CHANGED
|
@@ -1,107 +1,9 @@
|
|
|
1
|
-
'use strict';var J=Object.defineProperty;var V=(n,e,t)=>e in n?J(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t;var l=(n,e,t)=>V(n,typeof e!="symbol"?e+"":e,t);var A=class extends Error{constructor(t,r,i){super(r,i);l(this,"code");this.code=t,this.name="ProdantixError";}},P=class extends A{constructor(e){super("config",e),this.name="ConfigError";}};var v=class extends A{constructor(t,r,i){super("transport",t,i);l(this,"status");this.status=r,this.name="TransportError";}};function $(n){if(n)return n;let e=globalThis.fetch;if(typeof e=="function")return e.bind(globalThis)}function M(n){return n.replace(/\/+$/,"")}var O="X-Prodantix-Conversation-Token",F="prodantix.chat.handle";function X(){let n=globalThis.localStorage;if(n)return {get:e=>n.getItem(e),remove:e=>n.removeItem(e),set:(e,t)=>n.setItem(e,t)}}var T=class{constructor(e){this.options=e;l(this,"fetchImpl");l(this,"fileFetchImpl");l(this,"host");l(this,"storage");l(this,"handle");l(this,"identity",null);this.fetchImpl=$(e.fetchImpl),this.fileFetchImpl=e.fileFetchImpl??((t,r)=>fetch(t,r)),this.host=M(e.host),this.storage=e.storage??X(),this.handle=this.readHandle();}get hasThread(){return this.handle!==null}avatarUrl(e){return e.startsWith("/")?`${this.host}${e}?api_key=${encodeURIComponent(this.options.apiKey)}`:e}get socketAuth(){return this.handle?{conversationId:this.handle.conversationId,conversationToken:this.handle.token,projectKey:this.options.apiKey}:null}identify(e){this.identity=e;}async ensureThread(e){if(this.handle)return true;let t=await this.request("POST","/v1/conversations",{body:{distinctId:this.options.distinctId,subject:e,userHash:this.identity?.userHash,userId:this.identity?.userId}});return !t?.conversationId||!t.token?false:(this.handle={conversationId:t.conversationId,token:t.token},this.storage?.set(F,JSON.stringify(this.handle)),true)}async send(e,t,r){if(!await this.ensureThread())return null;let i=this.handle;return i?(await this.request("POST",`/v1/conversations/${encodeURIComponent(i.conversationId)}/turns`,{body:{attachmentIds:r,body:e,pageContext:t},token:i.token}))?.turn??null:null}async upload(e){if(!await this.ensureThread())return null;let t=this.handle;return t?this.fileRequest("POST",`/v1/conversations/${encodeURIComponent(t.conversationId)}/attachments?name=${encodeURIComponent(e.name)}`,t.token,async r=>JSON.parse(await r.text()),e):null}async file(e){let t=this.handle;return t?this.fileRequest("GET",e,t.token,r=>r.blob()):null}async helpCentre(e,t){let r=Object.entries({...t,...this.options.locale?{lang:this.options.locale}:{}}).map(([i,a])=>`${i}=${encodeURIComponent(a)}`).join("&");return this.request("GET",`/v1/messenger/articles${e}${r?`?${r}`:""}`)}async load(){let e=this.handle;return e?this.request("GET",`/v1/conversations/${encodeURIComponent(e.conversationId)}`,{token:e.token}):null}readHandle(){let e=this.storage?.get(F);if(!e)return null;try{let t=JSON.parse(e);if(typeof t.conversationId=="string"&&typeof t.token=="string")return {conversationId:t.conversationId,token:t.token}}catch(t){this.options.onError?.(t);}return this.storage?.remove(F),null}async fileRequest(e,t,r,i,a){let o={authorization:`Bearer ${this.options.apiKey}`,[O]:r};a&&(o["content-type"]=a.type||"application/octet-stream");try{let s=await this.fileFetchImpl(`${this.host}${t}`,{body:a,headers:o,method:e});if(s.ok)return await i(s);this.options.onError?.(new v(`prodantix chat ${t}: ${s.status}`,s.status));}catch(s){this.options.onError?.(s);}return null}async request(e,t,r={}){let i=this.fetchImpl;if(!i)return this.options.onError?.(new v("no fetch available for prodantix chat")),null;let a={authorization:`Bearer ${this.options.apiKey}`,"content-type":"application/json"};r.token&&(a[O]=r.token);try{let o=await i(`${this.host}${t}`,{body:r.body===void 0?void 0:JSON.stringify(r.body),headers:a,method:e}),s=await o.text();return o.ok?s?JSON.parse(s):{}:(this.options.onError?.(new v(`prodantix chat ${t}: ${o.status}`,o.status)),null)}catch(o){return this.options.onError?.(o),null}}};var Z={Fri:"fri",Mon:"mon",Sat:"sat",Sun:"sun",Thu:"thu",Tue:"tue",Wed:"wed"};function N(n,e){let t=new Intl.DateTimeFormat(void 0,{hour:"2-digit",hour12:false,minute:"2-digit",timeZone:n.timezone,weekday:"short"}).formatToParts(e),r=Z[t.find(s=>s.type==="weekday")?.value??""];if(!r)return false;let i=t.find(s=>s.type==="hour")?.value??"",a=t.find(s=>s.type==="minute")?.value??"",o=`${i}:${a}`;return n.windows.some(s=>s.days.includes(r)&&s.open<=o&&o<s.close)}var f={bubbleFill:"filled",bubbleShape:"tailed",composerShape:"round",dayDividers:true,launcherContent:"glyph",launcherFill:"outlined",launcherShape:"circle",launcherSize:"small",nameAvatar:true,namePlacement:"hidden",skin:"standard",stampContent:"time",stampPlacement:"none"},Q=["quiet","standard"],ee=["round","square"],te=["rounded","tailed"],ne=["filled","outlined"],re=["circle","pill","squircle"],ie=["filled","outlined"],ae=["avatar","glyph","team_faces"],oe=["large","medium","small"],se=["above","hidden","inline"],le=["beside_name","none","under_turn"],ce=["time","time_and_latency"],x=(n,e,t)=>typeof n=="string"&&e.includes(n)?n:t,U=(n,e)=>typeof n=="boolean"?n:e,de={avatar_circle:["circle","outlined","avatar","large"],circle_filled:["circle","filled","glyph","medium"],circle_outlined:["circle","outlined","glyph","small"],pill_labelled:["pill","filled","glyph","medium"],pill_team:["pill","outlined","team_faces","medium"],squircle_filled:["squircle","filled","glyph","medium"]},pe={above:["above",false],avatar_only:["hidden",true],gutter:["above",true],hidden:["hidden",false],inline:["inline",false]},he={cluster:[true,"none","time"],latency:[false,"beside_name","time_and_latency"],none:[false,"none","time"],trailing:[false,"under_turn","time"],with_name:[false,"beside_name","time"]},ue={concierge:["standard","round"],console:["standard","square"],quiet:["quiet","square"]},me={hairline:["rounded","outlined"],outlined:["rounded","outlined"],rounded:["rounded","filled"],tailed:["tailed","filled"]};function L(n){let e=typeof n=="object"&&n!==null?n:{},t=typeof e.launcherStyle=="string"?e.launcherStyle:void 0,r=t===void 0?void 0:de[t],i=typeof e.namePlacement=="string"?e.namePlacement:void 0,a=i===void 0?void 0:pe[i],o=typeof e.timestampStyle=="string"?e.timestampStyle:void 0,s=o===void 0?void 0:he[o],h=typeof e.skin=="string"?e.skin:void 0,u=h===void 0?void 0:ue[h],c=typeof e.bubbleStyle=="string"?e.bubbleStyle:void 0,d=c===void 0?void 0:me[c],p={bubbleFill:x(e.bubbleFill,ne,d?.[1]??f.bubbleFill),bubbleShape:x(e.bubbleShape,te,d?.[0]??f.bubbleShape),composerShape:x(e.composerShape,ee,u?.[1]??f.composerShape),dayDividers:U(e.dayDividers,s?.[0]??f.dayDividers),launcherContent:x(e.launcherContent,ae,r?.[2]??f.launcherContent),launcherFill:x(e.launcherFill,ie,r?.[1]??f.launcherFill),launcherShape:x(e.launcherShape,re,r?.[0]??f.launcherShape),launcherSize:x(e.launcherSize,oe,r?.[3]??f.launcherSize),nameAvatar:U(e.nameAvatar,a?.[1]??f.nameAvatar),namePlacement:x(e.namePlacement,se,a?.[0]??f.namePlacement),skin:x(e.skin,Q,u?.[0]??f.skin),stampContent:x(e.stampContent,ce,s?.[2]??f.stampContent),stampPlacement:x(e.stampPlacement,le,s?.[1]??f.stampPlacement)};return p.stampPlacement==="beside_name"&&p.namePlacement==="hidden"&&(p.stampPlacement="under_turn"),p}function K(n){let e=n.split(/\s+/).filter(r=>r.length>0);return (e.length>1?`${e[0]?.slice(0,1)}${e[1]?.slice(0,1)}`:e[0]?.slice(0,2)??"").toUpperCase()}var ge="M20 11.6a7.4 7.4 0 0 1-7.4 7.4H8.2L4 21.8l1-4.1A7.4 7.4 0 1 1 20 11.6Z",fe={large:66,medium:56,small:46},be={circle:"width:var(--fab-size);height:var(--fab-size);border-radius:calc(var(--fab-size) / 2);",pill:"width:auto;height:var(--fab-size);border-radius:calc(var(--fab-size) / 2);padding:0 22px;gap:10px;",squircle:"width:var(--fab-size);height:var(--fab-size);border-radius:16px;"},ye={filled:"background:var(--a);color:#fff;",outlined:"background:var(--paper);border:1px solid var(--hairline);color:var(--ink-2);box-shadow:0 1px 2px rgba(0,0,0,.08);"},xe={avatar:"",glyph:".launcher svg{width:calc(var(--fab-size) * 0.375);height:calc(var(--fab-size) * 0.375);}",team_faces:".launcher .faces{display:flex;}.launcher .faces .av{box-shadow:0 0 0 2px var(--paper);}.launcher .faces .av+.av{margin-left:-10px;}"},ve=".launcher .live{width:10px;height:10px;position:absolute;right:3px;bottom:3px;border-radius:50%;background:var(--online);box-shadow:0 0 0 2px var(--paper);}.launcher.closed .live{display:none}",Se={circle:"",pill:".badge{position:static;box-shadow:none}",squircle:""},ke={filled:"",outlined:".badge{background:var(--a);top:-7px;right:-7px;min-width:19px;height:19px;font-size:11.5px}"},Ce={circle:"",pill:".launcher .label{font-size:14px;font-weight:600;white-space:nowrap;}",squircle:""},Ee={circle:"",pill:"@media (max-width:480px){.launcher{width:var(--fab-size);padding:0}.launcher .label{display:none}}",squircle:""};function z(n,e,t,r){return `.launcher{--fab-size:${fe[r]}px;${be[n]}${ye[e]}}${xe[t]}${ve}${Se[n]}${ke[e]}${Ce[n]}${Ee[n]}`}function B(n,e,t,r=i=>i){let i=document.createDocumentFragment();if(n==="glyph"||t.length===0){let a=document.createElement("span");return a.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${ge}"/></svg>`,i.append(...a.childNodes,I()),i}return n==="avatar"?(i.append(D(t[0],e,r),I()),i):(i.append(H(t,e,r),I()),i)}function H(n,e,t=r=>r){let r=document.createElement("span");r.className="faces";for(let i of n.slice(0,2))r.append(D(i,e,t));return r}function D(n,e,t){let r=document.createElement("span");if(r.className="av",r.setAttribute("aria-hidden","true"),n&&(r.style.background=n.tone),n?.avatarUrl){let i=document.createElement("img");return i.alt="",i.src=t(n.avatarUrl),r.append(i),r}return r.textContent=n?n.initials:e.agentLabel.slice(0,2).toUpperCase(),r}function I(){let n=document.createElement("span");return n.className="live",n.setAttribute("aria-hidden","true"),n}var Te={agentLabel:"Agent",aiLabel:"AI",attachLabel:"Attach a file",awayBody:"We are away right now, but we will reply as soon as we are back.",closeLabel:"Close chat",emptyBody:"We usually reply within a few minutes.",emptyTitle:"Ask us anything.",fileRefusal:(n,e)=>`That file is ${n}. Send a PNG, JPEG, WebP, GIF or PDF up to ${e}.`,inputPlaceholder:"Type a message",launcherLabel:"Chat with us",removeFileLabel:"Remove file",replyTime:"Usually replying in a few minutes",retryLabel:"Not delivered. Retry",sendLabel:"Send",timeLabel:n=>{let e=new Date(n);return Number.isNaN(e.getTime())?"":`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`},title:"Support",unreadLabel:n=>`${n} unread`},E={accentColor:"#5958fc",availability:{timezone:"UTC",windows:[]},awayMessage:"",greeting:"",launcherOffsetX:20,launcherOffsetY:20,launcherPosition:"bottom_right",starterPrompts:[],team:[],...f},Le={quiet:".composer{position:relative;padding:8px 10px 10px}.composer input{padding-right:36px}.composer button{position:absolute;top:50%;right:14px;width:28px;min-width:28px;height:28px;padding:0;background:transparent;color:var(--ink);border-radius:7px;transform:translateY(-50%)}.composer button .sendglyph{display:block;width:16px;height:16px}.composer button .sendtext{display:none}.panel{border-radius:8px;box-shadow:0 2px 8px rgba(0,0,0,.12)}.header{background:var(--paper);color:var(--ink);height:44px;padding:0 8px 0 16px;border-bottom:1px solid var(--hairline)}.header h2{font-size:11px;letter-spacing:.11em;text-transform:uppercase;color:var(--ink-3)}.header .faces,.header .status{display:none}.header .close{top:6px}.close{color:var(--ink-2)}",standard:".panel{border-radius:16px;box-shadow:0 16px 40px rgba(0,0,0,.2)}.header{background:var(--a);color:#fff;flex-direction:column;align-items:flex-start;gap:14px;padding:18px 14px 20px 20px}.header h2{font-size:19px;font-weight:640}"},we={round:".composer{padding:10px 10px 12px;gap:6px}.composer input{height:36px;border-radius:18px;padding:0 14px}.composer button{width:36px;min-width:36px;height:36px;padding:0;border-radius:18px}.composer button .sendglyph{display:block}.composer button .sendtext{display:none}",square:".composer input{height:36px;border-radius:8px;padding:0 12px}"},Ae={rounded:".turn{border-radius:18px;padding:10px 15px}",tailed:".turn.agent,.turn.ai{border-radius:12px 12px 12px 4px}.turn.end_user{border-radius:12px 12px 4px 12px}"},Pe={filled:"",outlined:".turn{background:none;border:1px solid var(--hairline)}.turn.end_user{background:none;border-color:var(--a);color:var(--ink)}"},Ne={above:"",hidden:".turn.agent .author,.turn.ai .author:not(.ai){display:none}",inline:".body .author.below{display:block;margin:4px 0 0;font-size:11.5px;font-weight:500;color:var(--ink-2);text-transform:none;letter-spacing:0;opacity:1}"},_e=".turn.agent,.turn.ai{display:flex;gap:10px;max-width:100%;background:none;padding:0}.turn.agent .body,.turn.ai .body{background:var(--fill);padding:9px 13px;border-radius:inherit}.author{text-transform:none;letter-spacing:0;font-size:12.5px;font-weight:600;opacity:1}",Fe='.divider{display:flex;align-items:center;gap:10px;margin:0;font-size:11px;opacity:.6}.divider:before,.divider:after{content:"";flex:1;height:1px;background:var(--hairline)}',Ie={beside_name:".stamp{font-size:11px;opacity:.7;margin-left:6px}",none:"",under_turn:".stamp{display:block;font-size:11px;opacity:.7;margin-top:4px}.turn.end_user .stamp{text-align:right}"},He=".lat{font-size:11px;opacity:.7;margin-left:6px}",G=`--paper: oklch(24.6% 0.015 257); --ink: #fff; --ink-3: rgba(255,255,255,.55);
|
|
1
|
+
'use strict';var V=Object.defineProperty;var X=(n,e,t)=>e in n?V(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t;var s=(n,e,t)=>X(n,typeof e!="symbol"?e+"":e,t);var P=class extends Error{constructor(t,r,i){super(r,i);s(this,"code");this.code=t,this.name="ProdantixError";}},N=class extends P{constructor(e){super("config",e),this.name="ConfigError";}};var k=class extends P{constructor(t,r,i){super("transport",t,i);s(this,"status");this.status=r,this.name="TransportError";}};function M(n){if(n)return n;let e=globalThis.fetch;if(typeof e=="function")return e.bind(globalThis)}function O(n){return n.replace(/\/+$/,"")}var U="X-Prodantix-Conversation-Token",I="prodantix.chat.handle";function Z(){let n=globalThis.localStorage;if(n)return {get:e=>n.getItem(e),remove:e=>n.removeItem(e),set:(e,t)=>n.setItem(e,t)}}var w=class{constructor(e){this.options=e;s(this,"fetchImpl");s(this,"fileFetchImpl");s(this,"host");s(this,"storage");s(this,"handle");s(this,"identity",null);s(this,"fromArticle",null);this.fetchImpl=M(e.fetchImpl),this.fileFetchImpl=e.fileFetchImpl??((t,r)=>fetch(t,r)),this.host=O(e.host),this.storage=e.storage??Z(),this.handle=this.readHandle();}get hasThread(){return this.handle!==null}avatarUrl(e){return e.startsWith("/")?`${this.host}${e}?api_key=${encodeURIComponent(this.options.apiKey)}`:e}get socketAuth(){return this.handle?{conversationId:this.handle.conversationId,conversationToken:this.handle.token,projectKey:this.options.apiKey}:null}identify(e){this.identity=e;}async ensureThread(e){if(this.handle)return true;let t=await this.request("POST","/v1/conversations",{body:{distinctId:this.options.distinctId,fromArticle:this.fromArticle,subject:e,userHash:this.identity?.userHash,userId:this.identity?.userId}});return !t?.conversationId||!t.token?false:(this.handle={conversationId:t.conversationId,token:t.token},this.fromArticle=null,this.storage?.set(I,JSON.stringify(this.handle)),true)}cameFrom(e){this.fromArticle={language:e.language,pageId:e.pageId};}async send(e,t,r){if(!await this.ensureThread())return null;let i=this.handle;return i?(await this.request("POST",`/v1/conversations/${encodeURIComponent(i.conversationId)}/turns`,{body:{attachmentIds:r,body:e,pageContext:t},token:i.token}))?.turn??null:null}async upload(e){if(!await this.ensureThread())return null;let t=this.handle;return t?this.fileRequest("POST",`/v1/conversations/${encodeURIComponent(t.conversationId)}/attachments?name=${encodeURIComponent(e.name)}`,t.token,async r=>JSON.parse(await r.text()),e):null}async file(e){let t=this.handle;return t?this.fileRequest("GET",e,t.token,r=>r.blob()):null}async helpCentre(e,t,r){let i=new URLSearchParams({...t,...this.options.locale&&{lang:this.options.locale},...this.identity&&{user_hash:this.identity.userHash,user_id:this.identity.userId}}).toString();return this.request(r?"POST":"GET",`/v1/messenger/articles${e}${i?`?${i}`:""}`,r?{body:{...r,distinctId:this.options.distinctId}}:{})}get visitor(){return this.identity&&{...this.identity,distinctId:this.options.distinctId}}edge(e,t,r){return this.request(t?"POST":"GET",e,{body:t,token:r})}async load(){let e=this.handle;return e?this.request("GET",`/v1/conversations/${encodeURIComponent(e.conversationId)}`,{token:e.token}):null}readHandle(){let e=this.storage?.get(I);if(!e)return null;try{let t=JSON.parse(e);if(typeof t.conversationId=="string"&&typeof t.token=="string")return {conversationId:t.conversationId,token:t.token}}catch(t){this.options.onError?.(t);}return this.storage?.remove(I),null}async fileRequest(e,t,r,i,a){let o={authorization:`Bearer ${this.options.apiKey}`,[U]:r};a&&(o["content-type"]=a.type||"application/octet-stream");try{let l=await this.fileFetchImpl(`${this.host}${t}`,{body:a,headers:o,method:e});if(l.ok)return await i(l);this.options.onError?.(new k(`prodantix chat ${t}: ${l.status}`,l.status));}catch(l){this.options.onError?.(l);}return null}async request(e,t,r={}){let i=this.fetchImpl;if(!i)return this.options.onError?.(new k("no fetch available for prodantix chat")),null;let a={authorization:`Bearer ${this.options.apiKey}`,"content-type":"application/json"};r.token&&(a[U]=r.token);try{let o=await i(`${this.host}${t}`,{body:r.body===void 0?void 0:JSON.stringify(r.body),headers:a,method:e}),l=await o.text();return o.ok?l?JSON.parse(l):{}:(this.options.onError?.(new k(`prodantix chat ${t}: ${o.status}`,o.status)),null)}catch(o){return this.options.onError?.(o),null}}};var Q={Fri:"fri",Mon:"mon",Sat:"sat",Sun:"sun",Thu:"thu",Tue:"tue",Wed:"wed"};function _(n,e){let t=new Intl.DateTimeFormat(void 0,{hour:"2-digit",hour12:false,minute:"2-digit",timeZone:n.timezone,weekday:"short"}).formatToParts(e),r=Q[t.find(l=>l.type==="weekday")?.value??""];if(!r)return false;let i=t.find(l=>l.type==="hour")?.value??"",a=t.find(l=>l.type==="minute")?.value??"",o=`${i}:${a}`;return n.windows.some(l=>l.days.includes(r)&&l.open<=o&&o<l.close)}var f={bubbleFill:"filled",bubbleShape:"tailed",composerShape:"round",dayDividers:true,launcherContent:"glyph",launcherFill:"outlined",launcherShape:"circle",launcherSize:"small",nameAvatar:true,namePlacement:"hidden",skin:"standard",stampContent:"time",stampPlacement:"none"},ee=["quiet","standard"],te=["round","square"],ne=["rounded","tailed"],re=["filled","outlined"],ie=["circle","pill","squircle"],ae=["filled","outlined"],oe=["avatar","glyph","team_faces"],se=["large","medium","small"],le=["above","hidden","inline"],ce=["beside_name","none","under_turn"],de=["time","time_and_latency"],y=(n,e,t)=>typeof n=="string"&&e.includes(n)?n:t,K=(n,e)=>typeof n=="boolean"?n:e,pe={avatar_circle:["circle","outlined","avatar","large"],circle_filled:["circle","filled","glyph","medium"],circle_outlined:["circle","outlined","glyph","small"],pill_labelled:["pill","filled","glyph","medium"],pill_team:["pill","outlined","team_faces","medium"],squircle_filled:["squircle","filled","glyph","medium"]},he={above:["above",false],avatar_only:["hidden",true],gutter:["above",true],hidden:["hidden",false],inline:["inline",false]},ue={cluster:[true,"none","time"],latency:[false,"beside_name","time_and_latency"],none:[false,"none","time"],trailing:[false,"under_turn","time"],with_name:[false,"beside_name","time"]},me={concierge:["standard","round"],console:["standard","square"],quiet:["quiet","square"]},ge={hairline:["rounded","outlined"],outlined:["rounded","outlined"],rounded:["rounded","filled"],tailed:["tailed","filled"]};function L(n){let e=typeof n=="object"&&n!==null?n:{},t=typeof e.launcherStyle=="string"?e.launcherStyle:void 0,r=t===void 0?void 0:pe[t],i=typeof e.namePlacement=="string"?e.namePlacement:void 0,a=i===void 0?void 0:he[i],o=typeof e.timestampStyle=="string"?e.timestampStyle:void 0,l=o===void 0?void 0:ue[o],h=typeof e.skin=="string"?e.skin:void 0,u=h===void 0?void 0:me[h],c=typeof e.bubbleStyle=="string"?e.bubbleStyle:void 0,d=c===void 0?void 0:ge[c],p={bubbleFill:y(e.bubbleFill,re,d?.[1]??f.bubbleFill),bubbleShape:y(e.bubbleShape,ne,d?.[0]??f.bubbleShape),composerShape:y(e.composerShape,te,u?.[1]??f.composerShape),dayDividers:K(e.dayDividers,l?.[0]??f.dayDividers),launcherContent:y(e.launcherContent,oe,r?.[2]??f.launcherContent),launcherFill:y(e.launcherFill,ae,r?.[1]??f.launcherFill),launcherShape:y(e.launcherShape,ie,r?.[0]??f.launcherShape),launcherSize:y(e.launcherSize,se,r?.[3]??f.launcherSize),nameAvatar:K(e.nameAvatar,a?.[1]??f.nameAvatar),namePlacement:y(e.namePlacement,le,a?.[0]??f.namePlacement),skin:y(e.skin,ee,u?.[0]??f.skin),stampContent:y(e.stampContent,de,l?.[2]??f.stampContent),stampPlacement:y(e.stampPlacement,ce,l?.[1]??f.stampPlacement)};return p.stampPlacement==="beside_name"&&p.namePlacement==="hidden"&&(p.stampPlacement="under_turn"),p}function z(n){let e=n.split(/\s+/).filter(r=>r.length>0);return (e.length>1?`${e[0]?.slice(0,1)}${e[1]?.slice(0,1)}`:e[0]?.slice(0,2)??"").toUpperCase()}var fe="M20 11.6a7.4 7.4 0 0 1-7.4 7.4H8.2L4 21.8l1-4.1A7.4 7.4 0 1 1 20 11.6Z",be={large:66,medium:56,small:46},ye={circle:"width:var(--fab-size);height:var(--fab-size);border-radius:calc(var(--fab-size) / 2);",pill:"width:auto;height:var(--fab-size);border-radius:calc(var(--fab-size) / 2);padding:0 22px;gap:10px;",squircle:"width:var(--fab-size);height:var(--fab-size);border-radius:16px;"},xe={filled:"background:var(--a);color:#fff;",outlined:"background:var(--paper);border:1px solid var(--hairline);color:var(--ink-2);box-shadow:0 1px 2px rgba(0,0,0,.08);"},ve={avatar:"",glyph:".launcher svg{width:calc(var(--fab-size) * 0.375);height:calc(var(--fab-size) * 0.375);}",team_faces:".launcher .faces{display:flex;}.launcher .faces .av{box-shadow:0 0 0 2px var(--paper);}.launcher .faces .av+.av{margin-left:-10px;}"},ke=".launcher .live{width:10px;height:10px;position:absolute;right:3px;bottom:3px;border-radius:50%;background:var(--online);box-shadow:0 0 0 2px var(--paper);}.launcher.closed .live{display:none}",Se={circle:"",pill:".badge{position:static;box-shadow:none}",squircle:""},Ce={filled:"",outlined:".badge{background:var(--a);top:-7px;right:-7px;min-width:19px;height:19px;font-size:11.5px}"},Ee={circle:"",pill:".launcher .label{font-size:14px;font-weight:600;white-space:nowrap;}",squircle:""},Te={circle:"",pill:"@media (max-width:480px){.launcher{width:var(--fab-size);padding:0}.launcher .label{display:none}}",squircle:""};function B(n,e,t,r){return `.launcher{--fab-size:${be[r]}px;${ye[n]}${xe[e]}}${ve[t]}${ke}${Se[n]}${Ce[e]}${Ee[n]}${Te[n]}`}function D(n,e,t,r=i=>i){let i=document.createDocumentFragment();if(n==="glyph"||t.length===0){let a=document.createElement("span");return a.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${fe}"/></svg>`,i.append(...a.childNodes,R()),i}return n==="avatar"?(i.append(G(t[0],e,r),R()),i):(i.append(H(t,e,r),R()),i)}function H(n,e,t=r=>r){let r=document.createElement("span");r.className="faces";for(let i of n.slice(0,2))r.append(G(i,e,t));return r}function G(n,e,t){let r=document.createElement("span");if(r.className="av",r.setAttribute("aria-hidden","true"),n&&(r.style.background=n.tone),n?.avatarUrl){let i=document.createElement("img");return i.alt="",i.src=t(n.avatarUrl),r.append(i),r}return r.textContent=n?n.initials:e.agentLabel.slice(0,2).toUpperCase(),r}function R(){let n=document.createElement("span");return n.className="live",n.setAttribute("aria-hidden","true"),n}var we={agentLabel:"Agent",aiLabel:"AI",attachLabel:"Attach a file",awayBody:"We are away right now, but we will reply as soon as we are back.",closeLabel:"Close chat",emptyBody:"We usually reply within a few minutes.",emptyTitle:"Ask us anything.",fileRefusal:(n,e)=>`That file is ${n}. Send a PNG, JPEG, WebP, GIF or PDF up to ${e}.`,inputPlaceholder:"Type a message",launcherLabel:"Chat with us",removeFileLabel:"Remove file",replyTime:"Usually replying in a few minutes",retryLabel:"Not delivered. Retry",sendLabel:"Send",timeLabel:n=>{let e=new Date(n);return Number.isNaN(e.getTime())?"":`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`},title:"Support",unreadLabel:n=>`${n} unread`},T={accentColor:"#5958fc",availability:{timezone:"UTC",windows:[]},awayMessage:"",greeting:"",launcherOffsetX:20,launcherOffsetY:20,launcherPosition:"bottom_right",starterPrompts:[],team:[],...f};function Le(n,e){let t=document.createElement("a");t.className="powered",t.href="https://prodantix.com",t.target="_blank",t.rel="noopener";let r=document.createElement("img");return r.src=e,r.alt="",r.width=12,r.height=12,t.append(r,n),t}var Ae={quiet:".composer{position:relative;padding:8px 10px 10px}.composer input{padding-right:36px}.composer button{position:absolute;top:50%;right:14px;width:28px;min-width:28px;height:28px;padding:0;background:transparent;color:var(--ink);border-radius:7px;transform:translateY(-50%)}.composer button .sendglyph{display:block;width:16px;height:16px}.composer button .sendtext{display:none}.panel{border-radius:8px;box-shadow:0 2px 8px rgba(0,0,0,.12)}.header{background:var(--paper);color:var(--ink);height:44px;padding:0 8px 0 16px;border-bottom:1px solid var(--hairline)}.header h2{font-size:11px;letter-spacing:.11em;text-transform:uppercase;color:var(--ink-3)}.header .faces,.header .status{display:none}.header .close{top:6px}.close{color:var(--ink-2)}",standard:".panel{border-radius:16px;box-shadow:0 16px 40px rgba(0,0,0,.2)}.header{background:var(--a);color:#fff;flex-direction:column;align-items:flex-start;gap:14px;padding:18px 14px 20px 20px}.header h2{font-size:19px;font-weight:640}"},Pe={round:".composer{padding:10px 10px 12px;gap:6px}.composer input{height:36px;border-radius:18px;padding:0 14px}.composer button{width:36px;min-width:36px;height:36px;padding:0;border-radius:18px}.composer button .sendglyph{display:block}.composer button .sendtext{display:none}",square:".composer input{height:36px;border-radius:8px;padding:0 12px}"},Ne={rounded:".turn{border-radius:18px;padding:10px 15px}",tailed:".turn.agent,.turn.ai{border-radius:12px 12px 12px 4px}.turn.end_user{border-radius:12px 12px 4px 12px}"},_e={filled:"",outlined:".turn{background:none;border:1px solid var(--hairline)}.turn.end_user{background:none;border-color:var(--a);color:var(--ink)}"},Fe={above:"",hidden:".turn.agent .author,.turn.ai .author:not(.ai){display:none}",inline:".body .author.below{display:block;margin:4px 0 0;font-size:11.5px;font-weight:500;color:var(--ink-2);text-transform:none;letter-spacing:0;opacity:1}"},Ie=".turn.agent,.turn.ai{display:flex;gap:10px;max-width:100%;background:none;padding:0}.turn.agent .body,.turn.ai .body{background:var(--fill);padding:9px 13px;border-radius:inherit}.author{text-transform:none;letter-spacing:0;font-size:12.5px;font-weight:600;opacity:1}",Re='.divider{display:flex;align-items:center;gap:10px;margin:0;font-size:11px;opacity:.6}.divider:before,.divider:after{content:"";flex:1;height:1px;background:var(--hairline)}',He={beside_name:".stamp{font-size:11px;opacity:.7;margin-left:6px}",none:"",under_turn:".stamp{display:block;font-size:11px;opacity:.7;margin-top:4px}.turn.end_user .stamp{text-align:right}"},$e=".lat{font-size:11px;opacity:.7;margin-left:6px}",q=`--paper: oklch(24.6% 0.015 257); --ink: #fff; --ink-3: rgba(255,255,255,.55);
|
|
2
2
|
--fill: rgba(255,255,255,.06); --hairline: rgba(255,255,255,.13); --ink-2: rgba(255,255,255,.70);
|
|
3
|
-
--online: oklch(72% 0.13 163.23);`;function
|
|
3
|
+
--online: oklch(72% 0.13 163.23);`;function Me(n){return n==="light"?"":n==="dark"?`:host { ${q} }`:`@media (prefers-color-scheme: dark) {
|
|
4
4
|
:host {
|
|
5
|
-
${
|
|
5
|
+
${q}
|
|
6
6
|
}
|
|
7
|
-
}`}var $e=/https?:\/\/[^\s<>"]+/g,Me=/[.,;:!?)]$/,Oe=n=>{let e=n;for(;Me.test(e);){let t=e.split("(").length-1,r=e.split(")").length-1;if(e.endsWith(")")&&t>=r)break;e=e.slice(0,-1);}return e};function Ue(n,e){let t=0;for(let r of e.matchAll($e)){let i=r.index??0,a=Oe(r[0]);i>t&&n.append(e.slice(t,i));let o=document.createElement("a");o.href=a,o.target="_blank",o.rel="noopener noreferrer",o.textContent=a,n.append(o),t=i+a.length;}t<e.length&&n.append(e.slice(t));}var Ke=["P","BR","STRONG","EM","A","UL","OL","LI"],ze=n=>typeof n=="object"&&n!==null&&"html"in n&&typeof n.html=="string"&&"text"in n&&typeof n.text=="string",Be=(n,e)=>e.name==="class"||e.name==="data-block-type"?true:n!=="A"?false:e.name==="target"||e.name==="rel"?true:e.name==="href"&&/^https?:\/\//i.test(e.value.trim()),De=n=>[...n.querySelectorAll("*")].every(e=>Ke.includes(e.tagName)&&[...e.attributes].every(t=>Be(e.tagName,t)));function q(n,e="system"){let t=L(n),r=n.launcherPosition==="bottom_left"?"left":"right",i=n.accentColor;return `${`
|
|
8
|
-
|
|
9
|
-
all: initial; z-index: 2147483000; --a: ${i};
|
|
10
|
-
--paper: #fff; --ink: #0f172a; --ink-3: rgba(0,0,0,.55);
|
|
11
|
-
--fill: #f1f5f9; --hairline: #e2e8f0; --ink-2: rgba(0,0,0,.72);
|
|
12
|
-
--online: oklch(53.8% 0.1274 163.23);
|
|
13
|
-
color-scheme: ${e==="system"?"light dark":e};
|
|
14
|
-
}
|
|
15
|
-
${Re(e)}
|
|
16
|
-
* { box-sizing: border-box; font-family: system-ui, sans-serif; }
|
|
17
|
-
.launcher {
|
|
18
|
-
z-index: 2147483000; position: fixed; ${r}: ${n.launcherOffsetX}px; bottom: ${n.launcherOffsetY}px; width: 56px; height: 56px;
|
|
19
|
-
border-radius: 28px; border: none; cursor: pointer;
|
|
20
|
-
display: inline-flex; align-items: center; justify-content: center;
|
|
21
|
-
background: ${i}; color: #fff; font-size: 24px;
|
|
22
|
-
box-shadow: 0 4px 12px rgba(0,0,0,.2);
|
|
23
|
-
}
|
|
24
|
-
.launcher:focus-visible { outline: 3px solid #0b0e14; outline-offset: 2px; }
|
|
25
|
-
.launcher { transition: background-color 120ms ease; }
|
|
26
|
-
.launcher:hover { background: color-mix(in srgb, #000 12%, ${i}); }
|
|
27
|
-
.launcher:active { background: color-mix(in srgb, #000 20%, ${i}); }
|
|
28
|
-
@media (prefers-reduced-motion: reduce) {
|
|
29
|
-
.launcher { transition: none; }
|
|
30
|
-
}
|
|
31
|
-
.badge {
|
|
32
|
-
position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px;
|
|
33
|
-
border-radius: 10px; background: #dc2626; color: #fff; font-size: 12px;
|
|
34
|
-
display: flex; align-items: center; justify-content: center; padding: 0 4px;
|
|
35
|
-
}
|
|
36
|
-
.badge[hidden] { display: none; }
|
|
37
|
-
.panel {
|
|
38
|
-
z-index: 2147483001; position: fixed; ${r}: ${n.launcherOffsetX}px; bottom: ${n.launcherOffsetY+68}px; width: 360px; max-width: calc(100vw - 40px);
|
|
39
|
-
height: 520px; max-height: calc(100vh - 120px); background: var(--paper); color: var(--ink);
|
|
40
|
-
border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,.24);
|
|
41
|
-
display: flex; flex-direction: column; overflow: hidden;
|
|
42
|
-
}
|
|
43
|
-
.header { position: relative; padding: 14px 16px; background: #0b0e14; color: #fff; display: flex; align-items: center; justify-content: space-between; }
|
|
44
|
-
.header h2 { margin: 0; font-size: 15px; }
|
|
45
|
-
.header .faces { display: flex; }
|
|
46
|
-
.header .av { width: 36px; height: 36px; box-shadow: 0 0 0 2px var(--a); }
|
|
47
|
-
.header .av + .av { margin-left: -12px; }
|
|
48
|
-
.headmain { display: flex; flex-direction: column; }
|
|
49
|
-
.header .status { display: flex; align-items: center; gap: 6px; margin: 5px 0 0; font-size: 12.5px; color: rgb(255 255 255 / 80%); }
|
|
50
|
-
.header .status .live { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--online); box-shadow: 0 0 0 2px var(--paper); }
|
|
51
|
-
.panel.closed .status { display: none; }
|
|
52
|
-
.header .close { position: absolute; top: 8px; right: 8px; }
|
|
53
|
-
.close {
|
|
54
|
-
display: inline-flex; align-items: center; justify-content: center;
|
|
55
|
-
width: 32px; height: 32px; padding: 0;
|
|
56
|
-
background: none; border: none; border-radius: 8px;
|
|
57
|
-
color: inherit; cursor: pointer;
|
|
58
|
-
transition: background-color 120ms ease;
|
|
59
|
-
}
|
|
60
|
-
.close svg { display: block; width: 22px; height: 22px; }
|
|
61
|
-
.close:hover { background: color-mix(in srgb, currentColor 14%, transparent); }
|
|
62
|
-
.close:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }
|
|
63
|
-
.log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
|
|
64
|
-
.turn { max-width: 80%; padding: 8px 12px; border-radius: 12px; font-size: 14px; }
|
|
65
|
-
.turn.end_user { align-self: flex-end; background: ${i}; color: #fff; }
|
|
66
|
-
.turn.agent, .turn.ai { align-self: flex-start; background: var(--fill); color: var(--ink); }
|
|
67
|
-
.turn.ai a { color: ${i}; text-decoration: underline; overflow-wrap: anywhere; }
|
|
68
|
-
.author { font-size: 11px; opacity: .7; margin-bottom: 2px; }
|
|
69
|
-
.turn[data-pending] { opacity: .6; }
|
|
70
|
-
.turn[data-failed] { opacity: 1; box-shadow: inset 0 0 0 1px #dc2626; }
|
|
71
|
-
.retry { display: block; margin: 5px 0 0; padding: 0; background: none; border: 0; color: inherit; font: inherit; font-size: 11.5px; text-decoration: underline; cursor: pointer; opacity: .85; }
|
|
72
|
-
.away { display: flex; gap: 10px; align-items: flex-start; margin: 12px 12px 0; padding: 10px 14px; font-size: 13px; line-height: 1.43; color: ${i}; background: color-mix(in srgb, ${i} 12%, transparent); border-radius: 4px; }
|
|
73
|
-
.awayglyph { flex: none; width: 16px; height: 16px; margin-top: 1px; border: 1.5px solid currentColor; border-radius: 50%; }
|
|
74
|
-
.empty { display: flex; flex-direction: column; gap: 8px; padding: 20px 16px; }
|
|
75
|
-
.empty h3 { margin: 0; font-size: 18px; font-weight: 640; letter-spacing: -.015em; }
|
|
76
|
-
.empty > p { margin: 0 0 8px; font-size: 13.5px; color: var(--ink-2); }
|
|
77
|
-
.prompt {
|
|
78
|
-
position: relative; display: flex; align-items: center; min-height: 44px; padding: 10px 14px; text-align: left;
|
|
79
|
-
font-family: inherit; font-size: 13.5px; font-weight: 500; color: var(--ink);
|
|
80
|
-
background: none; border: 1px solid var(--hairline); border-radius: 8px; cursor: pointer;
|
|
81
|
-
}
|
|
82
|
-
.promptwords { min-width: 0; overflow-wrap: anywhere; }
|
|
83
|
-
.promptwords > :last-child { margin-bottom: 0; }
|
|
84
|
-
.prompt p { margin: 0 0 16px; line-height: 1.6; }
|
|
85
|
-
.prompt ul, .prompt ol { margin: 0 0 16px; padding-left: 32px; }
|
|
86
|
-
.prompt li { margin: 8px 0; line-height: 1.6; }
|
|
87
|
-
.prompt a { position: relative; z-index: 1; color: ${i}; text-decoration: underline; overflow-wrap: anywhere; }
|
|
88
|
-
.promptpress { position: absolute; inset: 0; padding: 0; background: none; border: 0; border-radius: inherit; cursor: pointer; }
|
|
89
|
-
.promptpress:focus-visible { outline: 2px solid ${i}; outline-offset: 2px; }
|
|
90
|
-
.av { width: 30px; height: 30px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 650; color: #fff; background: oklch(52% 0.17 22); }
|
|
91
|
-
.av.bot { border-radius: 9px; background: var(--fill); color: var(--ink); }
|
|
92
|
-
.av img { width: 100%; height: 100%; display: block; object-fit: cover; border-radius: inherit; }
|
|
93
|
-
.composer { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--hairline); }
|
|
94
|
-
.composer input { flex: 1; min-width: 0; height: 36px; padding: 0 12px; border: 0; border-radius: 8px; font-size: 14px; background: var(--fill); color: var(--ink); }
|
|
95
|
-
.composer input:focus-visible { outline: 2px solid ${i}; }
|
|
96
|
-
.composer button { display: inline-flex; align-items: center; justify-content: center; gap: 0; min-width: 56px; height: 36px; padding: 0 14px; background: ${i}; color: #fff; border: none; border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 13.5px; font-weight: 550; }
|
|
97
|
-
.composer button:hover { background: color-mix(in srgb, #000 12%, ${i}); }
|
|
98
|
-
.composer button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
|
|
99
|
-
.composer button .sendglyph { display: none; width: 17px; height: 17px; }
|
|
100
|
-
.composer button:focus-visible { outline: 2px solid #0b0e14; }
|
|
101
|
-
@media (prefers-reduced-motion: no-preference) {
|
|
102
|
-
.panel { animation: rise 180ms ease-out; }
|
|
103
|
-
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
|
|
104
|
-
}
|
|
105
|
-
.scrim,.grip{display:none}@media (max-width:770px){.panel{inset:auto 0 0;width:100%;max-width:none;height:86dvh;max-height:86dvh}:host .panel{border-bottom-left-radius:0;border-bottom-right-radius:0}.scrim{display:block;position:fixed;inset:0;z-index:2147483000;background:rgb(15 23 42/.24)}.grip{display:block;position:absolute;top:7px;left:calc(50% - 17px);width:34px;height:4px;border-radius:2px;background:currentColor;opacity:.45}.panel:not([data-dragging]){transition:translate .2s}.composer{padding-bottom:max(12px,env(safe-area-inset-bottom))}}
|
|
106
|
-
`}${we[t.composerShape]}${Le[t.skin]}${z(t.launcherShape,t.launcherFill,t.launcherContent,t.launcherSize)}${Ae[t.bubbleShape]}${Pe[t.bubbleFill]}${Ne[t.namePlacement]}${t.nameAvatar?_e:""}${t.dayDividers?Fe:""}${Ie[t.stampPlacement]}${t.stampContent==="time_and_latency"?He:""}`}var Ge=["end_user","agent","ai"];function qe(){let n=globalThis.location;if(n)return {host:n.host,path:n.pathname,title:document.title}}var je='<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M15.88 9.29 12 13.17 8.12 9.29a.996.996 0 0 0-1.41 0c-.39.39-.39 1.02 0 1.41l4.59 4.59c.39.39 1.02.39 1.41 0l4.59-4.59c.39-.39.39-1.02 0-1.41-.39-.38-1.03-.39-1.42 0"/></svg>',w=class{constructor(e,t,r={},i={},a={}){this.host=e;this.client=t;l(this,"root");l(this,"strings");l(this,"settings");l(this,"appearance");l(this,"launcher");l(this,"badge");l(this,"panel",null);l(this,"scrim",null);l(this,"lastFocused",null);l(this,"unread",0);l(this,"pendingTurns",0);l(this,"openNow");l(this,"styles");l(this,"scheme");l(this,"picked",null);l(this,"objectUrls",[]);l(this,"helpLoader");l(this,"kit",null);l(this,"kitLoad",null);l(this,"filesLoader");l(this,"filesKit",null);l(this,"filesLoad",null);this.strings={...Te,...r},this.appearance={...E,...i},this.settings=L({...E,...i}),this.root=e.attachShadow({mode:a.shadowMode??"closed"}),this.openNow=N(this.appearance.availability,new Date),this.scheme=a.scheme,this.helpLoader=a.help,this.filesLoader=a.files,this.styles=Je(this.root),this.paint(),this.launcher=document.createElement("button"),this.launcher.className="launcher",this.launcher.type="button",this.launcher.setAttribute("aria-haspopup","dialog"),this.launcher.addEventListener("click",()=>this.toggle()),this.badge=document.createElement("span"),this.badge.className="badge",this.badge.hidden=true,this.drawLauncher(),this.root.append(this.launcher);}drawLauncher(){if(this.launcher.setAttribute("aria-label",this.strings.launcherLabel),this.launcher.replaceChildren(),this.launcher.append(B(this.settings.launcherContent,this.strings,this.appearance.team,e=>this.client.avatarUrl(e))),this.settings.launcherShape==="pill"){let e=document.createElement("span");e.className="label",e.textContent=this.strings.launcherLabel,this.launcher.append(e);}this.launcher.append(this.badge),this.launcher.classList.toggle("closed",!this.openNow);}update(e,t){this.appearance={...E,...e},this.settings=L(this.appearance),t!==void 0&&(this.scheme=t),this.paint(),this.drawLauncher(),this.panel&&(this.close(),this.open());}paint(){this.styles(`${q(this.appearance,this.scheme)}${this.kit&&this.appearance.help?this.kit.HELP_CSS:""}${this.filesKit?this.filesKit.filesCss(this.appearance.attachments?.enabled===true,this.settings.composerShape):""}`);}loadKit(){return !this.appearance.help||!this.helpLoader?Promise.resolve(null):(this.kitLoad??(this.kitLoad=this.helpLoader().then(e=>(this.kit=e,this.paint(),e))),this.kitLoad)}loadFiles(){return this.filesLoader?(this.filesLoad??(this.filesLoad=this.filesLoader().then(e=>(this.filesKit=e,this.paint(),e))),this.filesLoad):Promise.resolve(null)}toggle(){this.panel?this.close():this.open();}setOpenNow(e){this.openNow=e,this.launcher.classList.toggle("closed",!e),this.panel?.classList.toggle("closed",!e);}async open(){if(this.panel)return;this.lastFocused=this.host.ownerDocument.activeElement,this.unread=0,this.renderBadge();let e=document.createElement("section");e.className=this.openNow?"panel":"panel closed",e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true"),e.setAttribute("aria-label",this.strings.title);let t=document.createElement("div");t.className="header";let r=document.createElement("span");r.className="grip",r.setAttribute("aria-hidden","true"),t.append(r);let i=this.appearance.team??[];i.length>0&&t.append(H(i,this.strings,y=>this.client.avatarUrl(y)));let a=document.createElement("div");a.className="headmain";let o=document.createElement("h2");o.textContent=this.strings.title;let s=document.createElement("p");s.className="status";let h=document.createElement("span");h.className="live",h.setAttribute("aria-hidden","true"),s.append(h,this.strings.replyTime),a.append(o,s);let u=document.createElement("button");u.className="close",u.type="button",u.setAttribute("aria-label",this.strings.closeLabel),u.innerHTML=je,u.addEventListener("click",()=>this.close()),t.append(a,u);let c=document.createElement("div");c.className="log",c.setAttribute("role","log"),c.setAttribute("aria-live","polite"),c.setAttribute("aria-label",this.strings.title);let d=document.createElement("form");d.className="composer";let p=document.createElement("input");p.type="text",p.setAttribute("aria-label",this.strings.inputPlaceholder),p.placeholder=this.strings.inputPlaceholder;let m=document.createElement("button");m.type="submit",m.setAttribute("aria-label",this.strings.sendLabel),m.innerHTML='<svg class="sendglyph" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4.5 12 20 4.5 15 20l-3.6-5.4L4.5 12Z"/></svg>';let C=document.createElement("span");C.className="sendtext",C.textContent=this.strings.sendLabel,m.append(C),d.append(p,m),d.addEventListener("submit",y=>{y.preventDefault(),this.submit(p,c);}),e.append(t,c,d),e.addEventListener("keydown",y=>this.onKeydown(y,e,u));let S=document.createElement("div");S.className="scrim",S.addEventListener("click",()=>this.close()),this.root.append(S,e),this.panel=e,this.scrim=S,We(e,()=>this.close()),p.focus();let k=this.appearance.attachments,[g]=await Promise.all([this.client.load(),this.loadKit(),k?.enabled&&this.client.upload?this.loadFiles():null]);if(g?.turns.some(y=>y.attachments?.length)&&await this.loadFiles(),this.panel!==e)return;this.filesKit&&k?.enabled&&this.client.upload&&this.filesKit.attachField({attachLabel:this.strings.attachLabel,fileRefusal:this.strings.fileRefusal,hold:y=>{this.picked=y;},objectUrl:y=>this.objectUrl(y),removeFileLabel:this.strings.removeFileLabel,root:this.root},d,p,c,k);let b=this.helpHost();b?.placement==="tab"&&b.host.source.collections&&b.host.source.collectionArticles&&b.kit.helpTab(b.host),b?.placement==="while_typing"&&b.kit.whileTyping(b.host,p,d),g&&g.turns.length>0?this.renderThread(c,g):this.renderFirstRun(c,p),this.openNow||this.renderAway(t);}renderFirstRun(e,t){let r=document.createElement("div");r.className="empty";let i=document.createElement("h3");i.textContent=this.appearance.greeting.trim()||this.strings.emptyTitle,r.append(i);let a=this.helpHost();if(a?.placement==="first_view")a.kit.firstView(a.host,r);else {let s=document.createElement("p");s.textContent=this.strings.emptyBody,r.append(s);}this.appearance.starterPrompts.filter(ze).forEach((s,h)=>{let u=document.createElement("div");u.className="prompt";let c=document.createElement("div");c.className="promptwords",c.id=`prompt-${h}`;let d=document.createElement("template");d.innerHTML=s.html,De(d.content)?c.append(d.content):c.textContent=s.text;for(let m of c.querySelectorAll("a"))m.target="_blank",m.rel="noopener noreferrer";let p=document.createElement("button");p.className="promptpress",p.type="button",p.setAttribute("aria-labelledby",c.id),p.addEventListener("click",()=>{t.value=s.text,this.submit(t,e);}),u.append(c,p),r.append(u);}),e.replaceChildren(r);}helpHost(){let e=this.appearance.help,{kit:t,panel:r}=this,i=e&&t&&r?t.hostOf(this.client,{close:()=>this.close(),closeLabel:this.strings.closeLabel,panel:r,scheme:this.scheme,words:e.words}):null;return i&&t&&e?{host:i,kit:t,placement:e.placement}:null}renderAway(e){let t=document.createElement("div");t.className="away";let r=document.createElement("span");r.className="awayglyph",r.setAttribute("aria-hidden","true");let i=document.createElement("span");i.textContent=this.appearance.awayMessage.trim()||this.strings.awayBody,t.append(r,i),e.after(t);}objectUrl(e){let t=URL.createObjectURL(e);return this.objectUrls.push(t),t}close(){if(this.panel){this.panel.remove(),this.scrim?.remove(),this.panel=null,this.scrim=null,this.picked=null;for(let e of this.objectUrls)URL.revokeObjectURL(e);this.objectUrls=[],this.lastFocused instanceof HTMLElement?this.lastFocused.focus():this.launcher.focus();}}onIncomingTurn(e){if(this.panel&&e.attachments?.length&&!this.filesKit&&this.filesLoader){this.loadFiles().then(()=>this.takeTurn(e));return}this.takeTurn(e);}takeTurn(e){if(this.panel){let t=this.panel.querySelector(".log");t instanceof HTMLElement&&!this.hasTurn(t,e.id)&&this.appendTurn(t,e);return}e.authorKind!=="end_user"&&(this.unread+=1,this.renderBadge());}async submit(e,t){let r=e.value.trim(),i=this.picked;if(!(!r&&!i)){e.value="",this.picked=null;for(let a of this.root.querySelectorAll(".file,.ferr,.hsugg"))a.remove();await this.sendBody(t,r,i);}}async sendBody(e,t,r=null){e.querySelector(".empty")?.remove(),this.pendingTurns+=1;let i=this.appendTurn(e,{authorId:null,authorKind:"end_user",body:t,createdAt:new Date().toISOString(),id:`pending-${this.pendingTurns}`},r);i.setAttribute("data-pending","");let a=r?await this.client.upload?.(r):void 0,o=a===null?null:await this.client.send(t,qe(),a?[a.id]:void 0);if(i.removeAttribute("data-pending"),o){i.dataset.turnId=o.id;return}this.markFailed(e,i,t,r);}markFailed(e,t,r,i){t.setAttribute("data-failed","");let a=document.createElement("button");a.type="button",a.className="retry",a.textContent=this.strings.retryLabel,a.addEventListener("click",()=>{t.remove(),this.sendBody(e,r,i);}),(t.querySelector(".body")??t).append(a);}hasTurn(e,t){for(let r of e.children)if(r instanceof HTMLElement&&r.dataset.turnId===t)return true;return false}renderThread(e,t){e.replaceChildren();for(let r of t.turns)this.appendTurn(e,r);}appendTurn(e,t,r=null){e.querySelector(".empty")?.remove();let i=Ge.includes(t.authorKind)?t.authorKind:"agent",a=this.settings,o=document.createElement("div");if(o.className=`turn ${i}`,o.dataset.turnId=t.id,i!=="end_user"&&a.nameAvatar){let d=document.createElement("span");if(d.className=i==="ai"?"av bot":"av",d.setAttribute("aria-hidden","true"),i==="agent"&&t.authorAvatarUrl){let p=document.createElement("img");p.alt="",p.src=this.client.avatarUrl(t.authorAvatarUrl),d.append(p);}else {d.textContent=i==="ai"?this.strings.aiLabel:K(this.agentName(t));let p=i==="agent"?this.appearance.team?.find(m=>m.name===t.authorName)?.tone:void 0;p&&(d.style.background=p);}o.append(d);}let h=document.createElement("div");if(h.className="body",i==="end_user"){let d=this.filesKit,p=m=>this.objectUrl(m);r&&d?.drawFile(h,r.name,r.type,r.size,Promise.resolve(r),p);for(let m of t.attachments??[])d?.drawFile(h,m.name,m.contentType,m.bytes,this.client.file?.(m.url)??Promise.resolve(null),p);}let u=i!=="end_user"&&a.namePlacement!=="hidden",c=document.createElement("div");if(i==="ai"?Ue(c,t.body):c.textContent=t.body,u||i==="ai"&&a.namePlacement==="hidden"){let d=document.createElement("div");d.className=i==="ai"?"author ai":"author",d.textContent=i==="ai"?this.strings.aiLabel:this.agentName(t),a.stampPlacement==="beside_name"&&d.append(this.stamp(t)),a.namePlacement==="inline"?(d.classList.add("below"),h.append(c,d)):h.append(d,c);}else t.body&&h.append(c);return a.stampPlacement==="under_turn"&&h.append(this.stamp(t)),o.append(h),e.append(o),e.scrollTop=e.scrollHeight,o}agentName(e){return e.authorName||this.strings.agentLabel}stamp(e){let t=document.createElement("span");return t.className="stamp",t.textContent=this.strings.timeLabel(e.createdAt),t}onKeydown(e,t,r){if(e.key==="Escape"){e.preventDefault(),this.close();return}if(e.key!=="Tab")return;let i=[...t.querySelectorAll('button, input, a[href], [tabindex]:not([tabindex="-1"])')].filter(h=>!h.closest("[hidden]")&&!h.hidden);if(i.length===0)return;let a=i[0],o=i[i.length-1],s=this.root.activeElement;e.shiftKey&&s===a?(e.preventDefault(),o.focus()):!e.shiftKey&&s===o?(e.preventDefault(),a.focus()):s===null&&(e.preventDefault(),r.focus());}renderBadge(){this.unread>0?(this.badge.hidden=false,this.badge.textContent=String(this.unread),this.launcher.setAttribute("aria-label",`${this.strings.launcherLabel}, ${this.strings.unreadLabel(this.unread)}`)):(this.badge.hidden=true,this.badge.textContent="",this.launcher.setAttribute("aria-label",this.strings.launcherLabel));}},Ye="(max-width: 770px)";function We(n,e){let t=null;n.addEventListener("pointerdown",i=>{if(t||i.button!==0||!globalThis.matchMedia?.(Ye).matches)return;let a=i.target;if(!a?.closest("a, button, input, textarea, iframe")){for(;a&&a!==n;a=a.parentElement)if(a.scrollTop>0)return;t={at:i.timeStamp,id:i.pointerId,offset:0,startY:i.clientY},n.setPointerCapture?.(i.pointerId),n.dataset.dragging="";}}),n.addEventListener("pointermove",i=>{if(t?.id!==i.pointerId)return;let a=i.clientY-t.startY;t.offset=a>=0?a:-16*(1-Math.exp(a/48)),n.style.translate=`0 ${t.offset}px`;});let r=i=>{let a=t;if(a?.id!==i.pointerId)return;t=null,delete n.dataset.dragging;let o=a.offset>Math.min(72,n.getBoundingClientRect().height*.4),s=a.offset/Math.max(1,i.timeStamp-a.at)>.5&&a.offset>16;o||s?e():n.style.translate="";};n.addEventListener("pointerup",r),n.addEventListener("pointercancel",r);}var Je=n=>{if(typeof CSSStyleSheet=="function"&&"adoptedStyleSheets"in n&&"replaceSync"in CSSStyleSheet.prototype){let t=new CSSStyleSheet;return n.adoptedStyleSheets=[t],r=>t.replaceSync(r)}let e=document.createElement("style");return n.append(e),t=>{e.textContent=t;}};function j(n){return `40${JSON.stringify(n)}`}function Y(){return "3"}function W(n){let e=n.charAt(0),t=n.slice(1);if(e==="2")return {kind:"ping"};if(e==="1")return {kind:"disconnect"};if(e==="0"){let o=R(t);return {kind:"open",pingInterval:typeof o?.pingInterval=="number"?o.pingInterval:25e3,pingTimeout:typeof o?.pingTimeout=="number"?o.pingTimeout:2e4}}if(e!=="4")return {kind:"other"};let r=t.charAt(0),i=t.slice(1);if(r==="0")return {kind:"connected"};if(r==="1")return {kind:"disconnect"};if(r==="4"){let o=R(i);return {kind:"connectError",message:typeof o?.message=="string"?o.message:"refused"}}if(r!=="2")return {kind:"other"};let a=R(i);return !Array.isArray(a)||typeof a[0]!="string"?{kind:"other"}:{kind:"event",name:a[0],payload:a[1]}}function R(n){try{return JSON.parse(n)}catch{return null}}var Ve="/socket.io/?EIO=4&transport=websocket",_=class{constructor(e){this.options=e;l(this,"socket",null);l(this,"heartbeat",null);l(this,"ready",false);l(this,"closed",false);l(this,"heartbeatWindow",45e3);l(this,"factory");l(this,"setTimer");l(this,"clearTimer");this.factory=e.socketFactory??Xe,this.setTimer=e.setTimer??((t,r)=>setTimeout(t,r)),this.clearTimer=e.clearTimer??(t=>clearTimeout(t));}open(){if(this.socket||this.closed)return;let e=`${this.options.host.replace(/^http/,"ws").replace(/\/+$/,"")}${Ve}`,t;try{t=this.factory(e);}catch{this.options.onClosed(false);return}this.socket=t,t.onmessage=r=>this.receive(String(r.data)),t.onerror=()=>t.close(),t.onclose=()=>this.fell();}close(){this.closed=true,this.stopHeartbeat();let e=this.socket;this.socket=null,e?.close();}receive(e){let t=W(e);if(t.kind==="open"){this.armHeartbeat(t.pingInterval+t.pingTimeout),this.socket?.send(j(this.options.auth));return}if(t.kind==="ping"){this.armHeartbeat(),this.socket?.send(Y());return}if(t.kind==="connectError"||t.kind==="disconnect"){this.stopHeartbeat(),this.socket?.close();return}if(t.kind==="event"){if(t.name==="ready"){this.ready=true,this.options.onReady();return}if(t.name==="conversation.turn"){let r=t.payload?.turn;r&&this.options.onTurn(r);}}}fell(){this.stopHeartbeat();let e=this.ready;this.socket=null,this.ready=false,this.closed||this.options.onClosed(e);}armHeartbeat(e){e!==void 0&&(this.heartbeatWindow=e),this.stopHeartbeat(),this.heartbeat=this.setTimer(()=>this.socket?.close(),this.heartbeatWindow);}stopHeartbeat(){this.heartbeat!==null&&this.clearTimer(this.heartbeat),this.heartbeat=null;}};function Xe(n){let e=globalThis.WebSocket;if(!e)throw new v("no WebSocket");return new e(n)}var Ze=6e4;function Tt(n){let e=globalThis.document;if(!e)throw new P("prodantix chat requires a document; mount it in the browser");let t=n.mountPoint??e.createElement("div");n.mountPoint||e.body.append(t);let r=new T(n),i=new w(t,r,n.strings,n.appearance,{files:n.files,help:n.help}),a=n.appearance?.availability??E.availability,o,s=()=>{i.setOpenNow(N(a,new Date)),o=setTimeout(s,Ze);};s();let h=new Set,u,c=null,d=n.pollIntervalMs??15e3,p=g=>{h.has(g.id)||g.authorKind==="end_user"||(h.add(g.id),i.onIncomingTurn(g));},m=async()=>{if(!r.hasThread)return;let g=await r.load();if(g){for(let b of g.turns)p(b);h=new Set(g.turns.map(b=>b.id));}},C=()=>{u||d<=0||(u=setInterval(()=>void m(),d));},S=()=>{u&&clearInterval(u),u=void 0;},k=()=>{if(c||!n.socketHost)return;let g=r.socketAuth;g&&(c=new _({auth:g,host:n.socketHost,onClosed:b=>{c=null,C(),b&&k();},onReady:S,onTurn:p,socketFactory:n.socketFactory}),c.open());};return C(),k(),{close:()=>i.close(),destroy:()=>{S(),clearTimeout(o),c?.close(),c=null,i.close(),t.remove();},identify:g=>r.identify(g),open:()=>{i.open().then(k);}}}exports.ChatClient=T;exports.ChatPanel=w;exports.DEFAULT_APPEARANCE=E;exports.DEFAULT_APPEARANCE_SETTINGS=f;exports.mountChat=Tt;exports.panelStyles=q;exports.resolveAppearance=L;//# sourceMappingURL=chat.cjs.map
|
|
7
|
+
}`}var Oe=/https?:\/\/[^\s<>"]+/g,Ue=/[.,;:!?)]$/,Ke=n=>{let e=n;for(;Ue.test(e);){let t=e.split("(").length-1,r=e.split(")").length-1;if(e.endsWith(")")&&t>=r)break;e=e.slice(0,-1);}return e};function ze(n,e){let t=0;for(let r of e.matchAll(Oe)){let i=r.index??0,a=Ke(r[0]);i>t&&n.append(e.slice(t,i));let o=document.createElement("a");o.href=a,o.target="_blank",o.rel="noopener noreferrer",o.textContent=a,n.append(o),t=i+a.length;}t<e.length&&n.append(e.slice(t));}var Be=["P","BR","STRONG","EM","A","UL","OL","LI"],De=n=>typeof n=="object"&&n!==null&&"html"in n&&typeof n.html=="string"&&"text"in n&&typeof n.text=="string",Ge=(n,e)=>e.name==="class"||e.name==="data-block-type"?true:n!=="A"?false:e.name==="target"||e.name==="rel"?true:e.name==="href"&&/^https?:\/\//i.test(e.value.trim()),qe=n=>[...n.querySelectorAll("*")].every(e=>Be.includes(e.tagName)&&[...e.attributes].every(t=>Ge(e.tagName,t)));function j(n,e="system"){let t=L(n),r=n.launcherPosition==="bottom_left"?"left":"right",i=n.accentColor;return `${`:host{all:initial;z-index:2147483000;--a:${i};--paper:#fff;--ink:#0f172a;--ink-3:rgba(0,0,0,.55);--fill:#f1f5f9;--hairline:#e2e8f0;--ink-2:rgba(0,0,0,.72);--online:oklch(53.8% 0.1274 163.23);color-scheme:${e==="system"?"light dark":e}}${Me(e)}*{box-sizing:border-box;font-family:system-ui,sans-serif}.launcher{z-index:2147483000;position:fixed;${r}:${n.launcherOffsetX}px;bottom:${n.launcherOffsetY}px;width:56px;height:56px;border-radius:28px;border:none;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;background:${i};color:#fff;font-size:24px;box-shadow:0 4px 12px rgba(0,0,0,.2)}.launcher:focus-visible{outline:3px solid #0b0e14;outline-offset:2px}.launcher{transition:background-color 120ms ease}.launcher:hover{background:color-mix(in srgb,#000 12%,${i})}.launcher:active{background:color-mix(in srgb,#000 20%,${i})}@media (prefers-reduced-motion:reduce){.launcher{transition:none}}.badge{position:absolute;top:-4px;right:-4px;min-width:20px;height:20px;border-radius:10px;background:#dc2626;color:#fff;font-size:12px;display:flex;align-items:center;justify-content:center;padding:0 4px}.badge[hidden]{display:none}.panel{z-index:2147483001;position:fixed;${r}:${n.launcherOffsetX}px;bottom:${n.launcherOffsetY+68}px;width:360px;max-width:calc(100vw - 40px);height:520px;max-height:calc(100vh - 120px);background:var(--paper);color:var(--ink);border-radius:12px;box-shadow:0 8px 32px rgba(0,0,0,.24);display:flex;flex-direction:column;overflow:hidden}.header{position:relative;padding:14px 16px;background:#0b0e14;color:#fff;display:flex;align-items:center;justify-content:space-between}.header h2{margin:0;font-size:15px}.header .faces{display:flex}.header .av{width:36px;height:36px;box-shadow:0 0 0 2px var(--a)}.header .av + .av{margin-left:-12px}.headmain{display:flex;flex-direction:column}.header .status{display:flex;align-items:center;gap:6px;margin:5px 0 0;font-size:12.5px;color:rgb(255 255 255 / 80%)}.header .status .live{flex:none;width:10px;height:10px;border-radius:50%;background:var(--online);box-shadow:0 0 0 2px var(--paper)}.panel.closed .status{display:none}.header .close{position:absolute;top:8px;right:8px}.close{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;padding:0;background:none;border:none;border-radius:8px;color:inherit;cursor:pointer;transition:background-color 120ms ease}.close svg{display:block;width:22px;height:22px}.close:hover{background:color-mix(in srgb,currentColor 14%,transparent)}.close:focus-visible{outline:2px solid currentColor;outline-offset:1px}.log{flex:1;overflow-y:auto;padding:12px;display:flex;flex-direction:column;gap:8px}.turn{max-width:80%;padding:8px 12px;border-radius:12px;font-size:14px}.turn.end_user{align-self:flex-end;background:${i};color:#fff}.turn.agent,.turn.ai{align-self:flex-start;background:var(--fill);color:var(--ink)}.turn.ai a{color:${i};text-decoration:underline;overflow-wrap:anywhere}.author{font-size:11px;opacity:.7;margin-bottom:2px}.turn[data-pending]{opacity:.6}.turn[data-failed]{opacity:1;box-shadow:inset 0 0 0 1px #dc2626}.retry{display:block;margin:5px 0 0;padding:0;background:none;border:0;color:inherit;font:inherit;font-size:11.5px;text-decoration:underline;cursor:pointer;opacity:.85}.away{display:flex;gap:10px;align-items:flex-start;margin:12px 12px 0;padding:10px 14px;font-size:13px;line-height:1.43;color:${i};background:color-mix(in srgb,${i}12%,transparent);border-radius:4px}.awayglyph{flex:none;width:16px;height:16px;margin-top:1px;border:1.5px solid currentColor;border-radius:50%}.empty{display:flex;flex-direction:column;gap:8px;padding:20px 16px}.empty h3{margin:0;font-size:18px;font-weight:640;letter-spacing:-.015em}.empty > p{margin:0 0 8px;font-size:13.5px;color:var(--ink-2)}.prompt{position:relative;display:flex;align-items:center;min-height:44px;padding:10px 14px;text-align:left;font-family:inherit;font-size:13.5px;font-weight:500;color:var(--ink);background:none;border:1px solid var(--hairline);border-radius:8px;cursor:pointer}.promptwords{min-width:0;overflow-wrap:anywhere}.promptwords > :last-child{margin-bottom:0}.prompt p{margin:0 0 16px;line-height:1.6}.prompt ul,.prompt ol{margin:0 0 16px;padding-left:32px}.prompt li{margin:8px 0;line-height:1.6}.prompt a{position:relative;z-index:1;color:${i};text-decoration:underline;overflow-wrap:anywhere}.promptpress{position:absolute;inset:0;padding:0;background:none;border:0;border-radius:inherit;cursor:pointer}.promptpress:focus-visible{outline:2px solid ${i};outline-offset:2px}.av{width:30px;height:30px;border-radius:50%;flex:none;display:inline-flex;align-items:center;justify-content:center;font-size:11.5px;font-weight:650;color:#fff;background:oklch(52% 0.17 22)}.av.bot{border-radius:9px;background:var(--fill);color:var(--ink)}.av img{width:100%;height:100%;display:block;object-fit:cover;border-radius:inherit}.composer{display:flex;gap:6px;padding:10px;border-top:1px solid var(--hairline)}.composer input{flex:1;min-width:0;height:36px;padding:0 12px;border:0;border-radius:8px;font-size:14px;background:var(--fill);color:var(--ink)}.composer input:focus-visible{outline:2px solid ${i}}.composer button{display:inline-flex;align-items:center;justify-content:center;gap:0;min-width:56px;height:36px;padding:0 14px;background:${i};color:#fff;border:none;border-radius:8px;cursor:pointer;font-family:inherit;font-size:13.5px;font-weight:550}.composer button:hover{background:color-mix(in srgb,#000 12%,${i})}.composer button:focus-visible{outline:2px solid var(--ink);outline-offset:2px}.composer button .sendglyph{display:none;width:17px;height:17px}.composer button:focus-visible{outline:2px solid #0b0e14}.powered{display:flex;align-items:center;justify-content:center;gap:4px;height:24px;font-size:11px;font-weight:500;color:var(--ink-3);text-decoration:none}.powered:hover{color:var(--ink-2)}.powered:focus-visible{outline:2px solid var(--ink);outline-offset:-2px}.powered img{width:12px;height:12px}@media (prefers-reduced-motion:no-preference){.panel{animation:rise 180ms ease-out}@keyframes rise{from{transform:translateY(8px);opacity:0}to{transform:none;opacity:1}}}.scrim,.grip{display:none}@media (max-width:770px){.panel{inset:auto 0 0;width:100%;max-width:none;height:86dvh;max-height:86dvh}:host .panel{border-bottom-left-radius:0;border-bottom-right-radius:0}.scrim{display:block;position:fixed;inset:0;z-index:2147483000;background:rgb(15 23 42/.24)}.grip{display:block;position:absolute;top:7px;left:calc(50% - 17px);width:34px;height:4px;border-radius:2px;background:currentColor;opacity:.45}.panel:not([data-dragging]){transition:translate .2s}.composer{padding-bottom:max(12px,env(safe-area-inset-bottom))}}`}${Pe[t.composerShape]}${Ae[t.skin]}${B(t.launcherShape,t.launcherFill,t.launcherContent,t.launcherSize)}${Ne[t.bubbleShape]}${_e[t.bubbleFill]}${Fe[t.namePlacement]}${t.nameAvatar?Ie:""}${t.dayDividers?Re:""}${He[t.stampPlacement]}${t.stampContent==="time_and_latency"?$e:""}`}var je=["end_user","agent","ai"];function Ye(){let n=globalThis.location;if(n)return {host:n.host,path:n.pathname,title:document.title}}var We='<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M15.88 9.29 12 13.17 8.12 9.29a.996.996 0 0 0-1.41 0c-.39.39-.39 1.02 0 1.41l4.59 4.59c.39.39 1.02.39 1.41 0l4.59-4.59c.39-.39.39-1.02 0-1.41-.39-.38-1.03-.39-1.42 0"/></svg>',A=class{constructor(e,t,r={},i={},a={}){this.host=e;this.client=t;s(this,"root");s(this,"strings");s(this,"settings");s(this,"appearance");s(this,"launcher");s(this,"badge");s(this,"panel",null);s(this,"scrim",null);s(this,"lastFocused",null);s(this,"unread",0);s(this,"pendingTurns",0);s(this,"openNow");s(this,"styles");s(this,"scheme");s(this,"picked",null);s(this,"objectUrls",[]);s(this,"helpLoader");s(this,"kit",null);s(this,"kitLoad",null);s(this,"filesLoader");s(this,"filesKit",null);s(this,"filesLoad",null);s(this,"ticketsLoader");s(this,"ticketsLoad");this.strings={...we,...r},this.appearance={...T,...i},this.settings=L({...T,...i}),this.root=e.attachShadow({mode:a.shadowMode??"closed"}),this.openNow=_(this.appearance.availability,new Date),this.scheme=a.scheme,this.helpLoader=a.help,this.filesLoader=a.files,this.ticketsLoader=a.tickets,this.styles=Xe(this.root),this.paint(),this.launcher=document.createElement("button"),this.launcher.className="launcher",this.launcher.type="button",this.launcher.setAttribute("aria-haspopup","dialog"),this.launcher.addEventListener("click",()=>this.toggle()),this.badge=document.createElement("span"),this.badge.className="badge",this.badge.hidden=true,this.drawLauncher(),this.root.append(this.launcher);}drawLauncher(){if(this.launcher.setAttribute("aria-label",this.strings.launcherLabel),this.launcher.replaceChildren(),this.launcher.append(D(this.settings.launcherContent,this.strings,this.appearance.team,e=>this.client.avatarUrl(e))),this.settings.launcherShape==="pill"){let e=document.createElement("span");e.className="label",e.textContent=this.strings.launcherLabel,this.launcher.append(e);}this.launcher.append(this.badge),this.launcher.classList.toggle("closed",!this.openNow);}update(e,t){this.appearance={...T,...e},this.settings=L(this.appearance),t!==void 0&&(this.scheme=t),this.paint(),this.drawLauncher(),this.panel&&(this.close(),this.open());}paint(){this.styles(`${j(this.appearance,this.scheme)}${this.kit&&this.appearance.help?this.kit.HELP_CSS:""}${this.filesKit?this.filesKit.filesCss(this.appearance.attachments?.enabled===true,this.settings.composerShape):""}`);}loadKit(){return !this.appearance.help||!this.helpLoader?Promise.resolve(null):(this.kitLoad??(this.kitLoad=this.helpLoader().then(e=>(this.kit=e,this.paint(),e))),this.kitLoad)}loadFiles(){return this.filesLoader?(this.filesLoad??(this.filesLoad=this.filesLoader().then(e=>(this.filesKit=e,this.paint(),e))),this.filesLoad):Promise.resolve(null)}toggle(){this.panel?this.close():this.open();}setOpenNow(e){this.openNow=e,this.launcher.classList.toggle("closed",!e),this.panel?.classList.toggle("closed",!e);}async open(){if(this.panel)return;this.lastFocused=this.host.ownerDocument.activeElement,this.unread=0,this.renderBadge();let e=document.createElement("section");e.className=this.openNow?"panel":"panel closed",e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true"),e.setAttribute("aria-label",this.strings.title);let t=document.createElement("div");t.className="header";let r=document.createElement("span");r.className="grip",r.setAttribute("aria-hidden","true"),t.append(r);let i=this.appearance.team??[];i.length>0&&t.append(H(i,this.strings,b=>this.client.avatarUrl(b)));let a=document.createElement("div");a.className="headmain";let o=document.createElement("h2");o.textContent=this.strings.title;let l=document.createElement("p");l.className="status";let h=document.createElement("span");h.className="live",h.setAttribute("aria-hidden","true"),l.append(h,this.strings.replyTime),a.append(o,l);let u=document.createElement("button");u.className="close",u.type="button",u.setAttribute("aria-label",this.strings.closeLabel),u.innerHTML=We,u.addEventListener("click",()=>this.close()),t.append(a,u);let c=document.createElement("div");c.className="log",c.setAttribute("role","log"),c.setAttribute("aria-live","polite"),c.setAttribute("aria-label",this.strings.title);let d=document.createElement("form");d.className="composer";let p=document.createElement("input");p.type="text",p.setAttribute("aria-label",this.strings.inputPlaceholder),p.placeholder=this.strings.inputPlaceholder;let m=document.createElement("button");m.type="submit",m.setAttribute("aria-label",this.strings.sendLabel),m.innerHTML='<svg class="sendglyph" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4.5 12 20 4.5 15 20l-3.6-5.4L4.5 12Z"/></svg>';let E=document.createElement("span");E.className="sendtext",E.textContent=this.strings.sendLabel,m.append(E),d.append(p,m),d.addEventListener("submit",b=>{b.preventDefault(),this.submit(p,c);}),e.append(t,c,d),this.appearance.poweredBy&&e.append(Le(this.appearance.poweredBy,this.client.avatarUrl("/messenger-mark.png"))),e.addEventListener("keydown",b=>this.onKeydown(b,e,u));let S=document.createElement("div");S.className="scrim",S.addEventListener("click",()=>this.close()),this.root.append(S,e),this.panel=e,this.scrim=S,Ve(e,()=>this.close()),p.focus();let C=this.appearance.attachments,[g,,,x]=await Promise.all([this.client.load(),this.loadKit(),C?.enabled&&this.client.upload?this.loadFiles():null,this.ticketsLoad??(this.ticketsLoad=this.ticketsLoader?.())]);if(g?.turns.some(b=>b.attachments?.length)&&await this.loadFiles(),this.panel!==e)return;this.filesKit&&C?.enabled&&this.client.upload&&this.filesKit.attachField({attachLabel:this.strings.attachLabel,fileRefusal:this.strings.fileRefusal,hold:b=>{this.picked=b;},objectUrl:b=>this.objectUrl(b),removeFileLabel:this.strings.removeFileLabel,root:this.root},d,p,c,C);let v=this.helpHost();v?.placement==="tab"&&v.host.source.collections&&v.host.source.collectionArticles&&v.kit.helpTab(v.host),v?.placement==="while_typing"&&v.kit.whileTyping(v.host,p,d),x&&this.appearance.tickets&&x.ticketsTab(e,this.client,this.appearance.tickets.words),g&&g.turns.length>0?this.renderThread(c,g):this.renderFirstRun(c,p),this.openNow||this.renderAway(t);}renderFirstRun(e,t){let r=document.createElement("div");r.className="empty";let i=document.createElement("h3");i.textContent=this.appearance.greeting.trim()||this.strings.emptyTitle,r.append(i);let a=this.helpHost();if(a?.placement==="first_view")a.kit.firstView(a.host,r);else {let l=document.createElement("p");l.textContent=this.strings.emptyBody,r.append(l);}this.appearance.starterPrompts.filter(De).forEach((l,h)=>{let u=document.createElement("div");u.className="prompt";let c=document.createElement("div");c.className="promptwords",c.id=`prompt-${h}`;let d=document.createElement("template");d.innerHTML=l.html,qe(d.content)?c.append(d.content):c.textContent=l.text;for(let m of c.querySelectorAll("a"))m.target="_blank",m.rel="noopener noreferrer";let p=document.createElement("button");p.className="promptpress",p.type="button",p.setAttribute("aria-labelledby",c.id),p.addEventListener("click",()=>{t.value=l.text,this.submit(t,e);}),u.append(c,p),r.append(u);}),e.replaceChildren(r);}helpHost(){let e=this.appearance.help,{kit:t,panel:r}=this,i=e&&t&&r?t.hostOf(this.client,{close:()=>this.close(),closeLabel:this.strings.closeLabel,panel:r,scheme:this.scheme,words:e.words}):null;return i&&t&&e?{host:i,kit:t,placement:e.placement}:null}renderAway(e){let t=document.createElement("div");t.className="away";let r=document.createElement("span");r.className="awayglyph",r.setAttribute("aria-hidden","true");let i=document.createElement("span");i.textContent=this.appearance.awayMessage.trim()||this.strings.awayBody,t.append(r,i),e.after(t);}objectUrl(e){let t=URL.createObjectURL(e);return this.objectUrls.push(t),t}close(){if(this.panel){this.panel.remove(),this.scrim?.remove(),this.panel=null,this.scrim=null,this.picked=null;for(let e of this.objectUrls)URL.revokeObjectURL(e);this.objectUrls=[],this.lastFocused instanceof HTMLElement?this.lastFocused.focus():this.launcher.focus();}}onIncomingTurn(e){if(this.panel&&e.attachments?.length&&!this.filesKit&&this.filesLoader){this.loadFiles().then(()=>this.takeTurn(e));return}this.takeTurn(e);}takeTurn(e){if(this.panel){let t=this.panel.querySelector(".log");t instanceof HTMLElement&&!this.hasTurn(t,e.id)&&this.appendTurn(t,e);return}e.authorKind!=="end_user"&&(this.unread+=1,this.renderBadge());}async submit(e,t){let r=e.value.trim(),i=this.picked;if(!(!r&&!i)){e.value="",this.picked=null;for(let a of this.root.querySelectorAll(".file,.ferr,.hsugg"))a.remove();await this.sendBody(t,r,i);}}async sendBody(e,t,r=null){e.querySelector(".empty")?.remove(),this.pendingTurns+=1;let i=this.appendTurn(e,{authorId:null,authorKind:"end_user",body:t,createdAt:new Date().toISOString(),id:`pending-${this.pendingTurns}`},r);i.setAttribute("data-pending","");let a=r?await this.client.upload?.(r):void 0,o=a===null?null:await this.client.send(t,Ye(),a?[a.id]:void 0);if(i.removeAttribute("data-pending"),o){i.dataset.turnId=o.id;return}this.markFailed(e,i,t,r);}markFailed(e,t,r,i){t.setAttribute("data-failed","");let a=document.createElement("button");a.type="button",a.className="retry",a.textContent=this.strings.retryLabel,a.addEventListener("click",()=>{t.remove(),this.sendBody(e,r,i);}),(t.querySelector(".body")??t).append(a);}hasTurn(e,t){for(let r of e.children)if(r instanceof HTMLElement&&r.dataset.turnId===t)return true;return false}renderThread(e,t){e.replaceChildren();for(let r of t.turns)this.appendTurn(e,r);}appendTurn(e,t,r=null){e.querySelector(".empty")?.remove();let i=je.includes(t.authorKind)?t.authorKind:"agent",a=this.settings,o=document.createElement("div");if(o.className=`turn ${i}`,o.dataset.turnId=t.id,i!=="end_user"&&a.nameAvatar){let d=document.createElement("span");if(d.className=i==="ai"?"av bot":"av",d.setAttribute("aria-hidden","true"),i==="agent"&&t.authorAvatarUrl){let p=document.createElement("img");p.alt="",p.src=this.client.avatarUrl(t.authorAvatarUrl),d.append(p);}else {d.textContent=i==="ai"?this.strings.aiLabel:z(this.agentName(t));let p=i==="agent"?this.appearance.team?.find(m=>m.name===t.authorName)?.tone:void 0;p&&(d.style.background=p);}o.append(d);}let h=document.createElement("div");if(h.className="body",i==="end_user"){let d=this.filesKit,p=m=>this.objectUrl(m);r&&d?.drawFile(h,r.name,r.type,r.size,Promise.resolve(r),p);for(let m of t.attachments??[])d?.drawFile(h,m.name,m.contentType,m.bytes,this.client.file?.(m.url)??Promise.resolve(null),p);}let u=i!=="end_user"&&a.namePlacement!=="hidden",c=document.createElement("div");if(i==="ai"?ze(c,t.body):c.textContent=t.body,u||i==="ai"&&a.namePlacement==="hidden"){let d=document.createElement("div");d.className=i==="ai"?"author ai":"author",d.textContent=i==="ai"?this.strings.aiLabel:this.agentName(t),a.stampPlacement==="beside_name"&&d.append(this.stamp(t)),a.namePlacement==="inline"?(d.classList.add("below"),h.append(c,d)):h.append(d,c);}else t.body&&h.append(c);return a.stampPlacement==="under_turn"&&h.append(this.stamp(t)),o.append(h),e.append(o),e.scrollTop=e.scrollHeight,o}agentName(e){return e.authorName||this.strings.agentLabel}stamp(e){let t=document.createElement("span");return t.className="stamp",t.textContent=this.strings.timeLabel(e.createdAt),t}onKeydown(e,t,r){if(e.key==="Escape"){e.preventDefault(),this.close();return}if(e.key!=="Tab")return;let i=[...t.querySelectorAll('button, input, a[href], [tabindex]:not([tabindex="-1"])')].filter(h=>!h.closest("[hidden]")&&!h.hidden);if(i.length===0)return;let a=i[0],o=i[i.length-1],l=this.root.activeElement;e.shiftKey&&l===a?(e.preventDefault(),o.focus()):!e.shiftKey&&l===o?(e.preventDefault(),a.focus()):l===null&&(e.preventDefault(),r.focus());}renderBadge(){this.unread>0?(this.badge.hidden=false,this.badge.textContent=String(this.unread),this.launcher.setAttribute("aria-label",`${this.strings.launcherLabel}, ${this.strings.unreadLabel(this.unread)}`)):(this.badge.hidden=true,this.badge.textContent="",this.launcher.setAttribute("aria-label",this.strings.launcherLabel));}},Je="(max-width: 770px)";function Ve(n,e){let t=null;n.addEventListener("pointerdown",i=>{if(t||i.button!==0||!globalThis.matchMedia?.(Je).matches)return;let a=i.target;if(!a?.closest("a, button, input, textarea, iframe")){for(;a&&a!==n;a=a.parentElement)if(a.scrollTop>0)return;t={at:i.timeStamp,id:i.pointerId,offset:0,startY:i.clientY},n.setPointerCapture?.(i.pointerId),n.dataset.dragging="";}}),n.addEventListener("pointermove",i=>{if(t?.id!==i.pointerId)return;let a=i.clientY-t.startY;t.offset=a>=0?a:-16*(1-Math.exp(a/48)),n.style.translate=`0 ${t.offset}px`;});let r=i=>{let a=t;if(a?.id!==i.pointerId)return;t=null,delete n.dataset.dragging;let o=a.offset>Math.min(72,n.getBoundingClientRect().height*.4),l=a.offset/Math.max(1,i.timeStamp-a.at)>.5&&a.offset>16;o||l?e():n.style.translate="";};n.addEventListener("pointerup",r),n.addEventListener("pointercancel",r);}var Xe=n=>{if(typeof CSSStyleSheet=="function"&&"adoptedStyleSheets"in n&&"replaceSync"in CSSStyleSheet.prototype){let t=new CSSStyleSheet;return n.adoptedStyleSheets=[t],r=>t.replaceSync(r)}let e=document.createElement("style");return n.append(e),t=>{e.textContent=t;}};function Y(n){return `40${JSON.stringify(n)}`}function W(){return "3"}function J(n){let e=n.charAt(0),t=n.slice(1);if(e==="2")return {kind:"ping"};if(e==="1")return {kind:"disconnect"};if(e==="0"){let o=$(t);return {kind:"open",pingInterval:typeof o?.pingInterval=="number"?o.pingInterval:25e3,pingTimeout:typeof o?.pingTimeout=="number"?o.pingTimeout:2e4}}if(e!=="4")return {kind:"other"};let r=t.charAt(0),i=t.slice(1);if(r==="0")return {kind:"connected"};if(r==="1")return {kind:"disconnect"};if(r==="4"){let o=$(i);return {kind:"connectError",message:typeof o?.message=="string"?o.message:"refused"}}if(r!=="2")return {kind:"other"};let a=$(i);return !Array.isArray(a)||typeof a[0]!="string"?{kind:"other"}:{kind:"event",name:a[0],payload:a[1]}}function $(n){try{return JSON.parse(n)}catch{return null}}var Ze="/socket.io/?EIO=4&transport=websocket",F=class{constructor(e){this.options=e;s(this,"socket",null);s(this,"heartbeat",null);s(this,"ready",false);s(this,"closed",false);s(this,"heartbeatWindow",45e3);s(this,"factory");s(this,"setTimer");s(this,"clearTimer");this.factory=e.socketFactory??Qe,this.setTimer=e.setTimer??((t,r)=>setTimeout(t,r)),this.clearTimer=e.clearTimer??(t=>clearTimeout(t));}open(){if(this.socket||this.closed)return;let e=`${this.options.host.replace(/^http/,"ws").replace(/\/+$/,"")}${Ze}`,t;try{t=this.factory(e);}catch{this.options.onClosed(false);return}this.socket=t,t.onmessage=r=>this.receive(String(r.data)),t.onerror=()=>t.close(),t.onclose=()=>this.fell();}close(){this.closed=true,this.stopHeartbeat();let e=this.socket;this.socket=null,e?.close();}receive(e){let t=J(e);if(t.kind==="open"){this.armHeartbeat(t.pingInterval+t.pingTimeout),this.socket?.send(Y(this.options.auth));return}if(t.kind==="ping"){this.armHeartbeat(),this.socket?.send(W());return}if(t.kind==="connectError"||t.kind==="disconnect"){this.stopHeartbeat(),this.socket?.close();return}if(t.kind==="event"){if(t.name==="ready"){this.ready=true,this.options.onReady();return}if(t.name==="conversation.turn"){let r=t.payload?.turn;r&&this.options.onTurn(r);}}}fell(){this.stopHeartbeat();let e=this.ready;this.socket=null,this.ready=false,this.closed||this.options.onClosed(e);}armHeartbeat(e){e!==void 0&&(this.heartbeatWindow=e),this.stopHeartbeat(),this.heartbeat=this.setTimer(()=>this.socket?.close(),this.heartbeatWindow);}stopHeartbeat(){this.heartbeat!==null&&this.clearTimer(this.heartbeat),this.heartbeat=null;}};function Qe(n){let e=globalThis.WebSocket;if(!e)throw new k("no WebSocket");return new e(n)}var et=6e4;function Lt(n){let e=globalThis.document;if(!e)throw new N("prodantix chat requires a document; mount it in the browser");let t=n.mountPoint??e.createElement("div");n.mountPoint||e.body.append(t);let r=new w(n),i=new A(t,r,n.strings,n.appearance,{files:n.files,help:n.help,tickets:n.tickets}),a=n.appearance?.availability??T.availability,o,l=()=>{i.setOpenNow(_(a,new Date)),o=setTimeout(l,et);};l();let h=new Set,u,c=null,d=n.pollIntervalMs??15e3,p=g=>{h.has(g.id)||g.authorKind==="end_user"||(h.add(g.id),i.onIncomingTurn(g));},m=async()=>{if(!r.hasThread)return;let g=await r.load();if(g){for(let x of g.turns)p(x);h=new Set(g.turns.map(x=>x.id));}},E=()=>{u||d<=0||(u=setInterval(()=>void m(),d));},S=()=>{u&&clearInterval(u),u=void 0;},C=()=>{if(c||!n.socketHost)return;let g=r.socketAuth;g&&(c=new F({auth:g,host:n.socketHost,onClosed:x=>{c=null,E(),x&&C();},onReady:S,onTurn:p,socketFactory:n.socketFactory}),c.open());};return E(),C(),{close:()=>i.close(),destroy:()=>{S(),clearTimeout(o),c?.close(),c=null,i.close(),t.remove();},identify:g=>r.identify(g),open:()=>{i.open().then(C);}}}
|
|
8
|
+
exports.ChatClient=w;exports.ChatPanel=A;exports.DEFAULT_APPEARANCE=T;exports.DEFAULT_APPEARANCE_SETTINGS=f;exports.mountChat=Lt;exports.panelStyles=j;exports.resolveAppearance=L;//# sourceMappingURL=chat.cjs.map
|
|
107
9
|
//# sourceMappingURL=chat.cjs.map
|
package/dist/chat.d.cts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { B as BubbleFill,
|
|
3
|
-
import { S as SocketFactory } from './types-
|
|
1
|
+
import { A as ArticleRef, a as ArticleReaction, b as ArticleHit, c as ArticleCollection, H as HelpWords, M as MessengerAttachments, d as AppearanceSettings, T as TicketWords, C as ChatThread, P as PageContext, e as ChatTurn, f as ChatUpload, g as ChatIdentity, h as MessengerConfig, i as ChatClientOptions } from './config-Dxf1vAMu.cjs';
|
|
2
|
+
export { B as BubbleFill, j as BubbleShape, k as ChatAttachment, l as ChatClient, m as ChatStorage, n as ComposerShape, D as DEFAULT_APPEARANCE_SETTINGS, F as FileFetchLike, o as FileResponseLike, L as LauncherContent, p as LauncherFill, q as LauncherShape, r as LauncherSize, s as MessengerSkin, N as NamePlacement, S as StampContent, t as StampPlacement, u as resolveAppearance } from './config-Dxf1vAMu.cjs';
|
|
3
|
+
import { S as SocketFactory } from './types-BUXFV_aE.cjs';
|
|
4
4
|
import './http-BCh716Vs.cjs';
|
|
5
5
|
|
|
6
6
|
declare const SEARCH_PAUSE_MS = 300;
|
|
7
7
|
declare const TYPED_MINIMUM = 3;
|
|
8
8
|
declare const SUGGESTED = 3;
|
|
9
|
-
declare const
|
|
9
|
+
declare const REACTIONS: readonly ArticleReaction[];
|
|
10
|
+
declare const HELP_CSS = "[hidden]{display:none!important}.hsearch{display:flex;align-items:center;gap:8px;height:40px;padding:0 12px;color:var(--ink-3);border:1px solid var(--hairline);border-radius:10px}.hsearch:focus-within{border-color:var(--a);box-shadow:0 0 0 3px color-mix(in srgb,var(--a) 20%,transparent)}.hsearch input{flex:1;min-width:0;height:100%;padding:0;border:0;outline:0;background:none;font:inherit;font-size:14px;color:var(--ink)}.hsearch input::placeholder{color:var(--ink-3)}.hsearch svg,.hrow svg{display:block;flex:none;width:16px;height:16px;fill:currentColor}.hlabel{margin:6px 0 0;font-size:12px;font-weight:600;color:var(--ink-3)}.hrows{display:flex;flex-direction:column}.hrow{display:flex;align-items:center;gap:10px;width:100%;padding:10px 2px;font:inherit;font-size:14px;color:var(--ink);text-align:left;background:none;border:0;border-bottom:1px solid var(--hairline);cursor:pointer}.hrow span{flex:1;min-width:0}.hrow small{font-size:12px;color:var(--ink-3)}.hrow svg{color:var(--ink-3)}.hrow:focus-visible{outline:2px solid var(--a);outline-offset:-2px}.hnone{margin:0;padding:10px 2px;font-size:13.5px;color:var(--ink-2)}.hview{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;gap:10px;padding:16px}.htabs{display:grid;grid-template-columns:1fr 1fr;border-top:1px solid var(--hairline)}.htab{display:flex;flex-direction:column;align-items:center;gap:2px;padding:8px 0 10px;font:inherit;font-size:11.5px;font-weight:550;color:var(--ink-3);background:none;border:0;cursor:pointer}.htab[aria-selected=\"true\"]{color:var(--a)}.htab svg{display:block;width:22px;height:22px;fill:currentColor}.htab:focus-visible{outline:2px solid var(--a);outline-offset:-2px}.hsugg{margin:0 10px 8px;padding:10px 12px 4px;border:1px solid var(--hairline);border-radius:10px}.hsugg p{margin:0 0 4px;font-size:12px;font-weight:600;color:var(--ink-3)}.hsugg .hrow{padding:8px 0;font-size:13.5px}.hsugg .hrow:last-child{border-bottom:0}.hreader{flex:1;min-height:0;display:flex;flex-direction:column}.hbar{flex:none;display:flex;align-items:center;gap:6px;height:52px;padding:0 8px;border-bottom:1px solid var(--hairline)}.hbar b{flex:1;min-width:0;font-size:14px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.hbtn{display:grid;place-items:center;flex:none;width:32px;height:32px;padding:0;border:0;border-radius:8px;background:none;color:var(--ink);cursor:pointer}.hbtn svg{display:block;width:20px;height:20px;fill:currentColor}.hbtn:hover{background:color-mix(in srgb,currentColor 14%,transparent)}.hbtn:focus-visible{outline:2px solid var(--a)}.hreader iframe{flex:1;min-height:0;width:100%;border:0}.hblocked{flex:1;display:flex;flex-direction:column;gap:8px;padding:20px 18px}.hblocked h3{margin:0;font-size:18px;font-weight:640;letter-spacing:-.015em}.hblocked a{font-size:14px;color:var(--ink);text-decoration:underline}.hmore{flex:none;display:flex;align-items:center;justify-content:space-between;gap:10px;margin:6px 18px 16px;padding:12px 14px;font-size:13.5px;background:var(--fill);border-radius:10px}.hmore button{padding:7px 14px;font:inherit;font-size:13px;font-weight:600;color:#fff;white-space:nowrap;background:var(--a);border:0;border-radius:8px;cursor:pointer}.hmore button:focus-visible{outline:2px solid var(--ink);outline-offset:2px}.hreact{flex:none;display:flex;align-items:center;justify-content:space-between;gap:10px;margin:10px 18px 0}.hask{font-size:13.5px;line-height:1.45;color:var(--ink-2)}.hfaces{display:flex;gap:6px}.hface{display:grid;place-items:center;width:44px;height:44px;padding:0;border:0;border-radius:10px;background:none;color:var(--ink-3);cursor:pointer}.hface svg{width:24px;height:24px}.hface:hover{color:var(--ink);background:color-mix(in srgb,currentColor 10%,transparent)}.hface[aria-pressed=\"true\"]{color:var(--a);background:color-mix(in srgb,var(--a) 14%,transparent)}.hface:focus-visible{outline:2px solid var(--a);outline-offset:2px}.hrow,.htab,.hmore,.hlabel,.hnone,.hsugg p{line-height:1.45}";
|
|
10
11
|
declare function searchBox(words: HelpWords, onWords: (words: string) => void): HTMLElement;
|
|
11
12
|
declare function paused(run: (words: string) => void): (words: string) => void;
|
|
12
13
|
declare const isReadable: (hit: ArticleHit) => boolean;
|
|
@@ -16,31 +17,43 @@ declare function emptyRows(): HTMLElement;
|
|
|
16
17
|
declare function helpTabs(words: HelpWords, onPick: (help: boolean) => void): HTMLElement;
|
|
17
18
|
declare function suggestions(words: HelpWords, hits: readonly ArticleHit[], onOpen: (hit: ArticleHit) => void): HTMLElement;
|
|
18
19
|
interface ReaderControls {
|
|
20
|
+
address: Promise<string | null> | string;
|
|
19
21
|
back: () => void;
|
|
20
22
|
close: () => void;
|
|
21
23
|
messageUs: () => void;
|
|
24
|
+
react?: (reaction: ArticleReaction) => Promise<boolean>;
|
|
22
25
|
}
|
|
26
|
+
declare function faces(words: HelpWords, react: (reaction: ArticleReaction) => Promise<boolean>): HTMLElement;
|
|
23
27
|
declare function frameAddress(embedUrl: string, scheme: 'dark' | 'light'): string;
|
|
24
28
|
declare function reader(hit: ArticleHit, words: HelpWords, closeLabel: string, scheme: 'dark' | 'light', controls: ReaderControls): HTMLElement;
|
|
25
29
|
interface HelpSource {
|
|
30
|
+
articleFrame?(article: ArticleRef): Promise<string | null>;
|
|
26
31
|
articles?(query: string): Promise<ArticleHit[]>;
|
|
27
32
|
popularArticles?(): Promise<ArticleHit[]>;
|
|
28
33
|
collections?(): Promise<ArticleCollection[]>;
|
|
29
34
|
collectionArticles?(collection: string): Promise<ArticleHit[]>;
|
|
30
35
|
}
|
|
31
|
-
type HelpRead = <T>(suffix: string, params: Record<string, string>) => Promise<T | null>;
|
|
36
|
+
type HelpRead = <T>(suffix: string, params: Record<string, string>, body?: Record<string, string>) => Promise<T | null>;
|
|
32
37
|
declare function helpReads(read: HelpRead): Required<HelpSource>;
|
|
38
|
+
interface ArticleFeedback {
|
|
39
|
+
cameFrom(article: ArticleRef): void;
|
|
40
|
+
opened(article: ArticleRef): Promise<boolean>;
|
|
41
|
+
react(article: ArticleRef, reaction: ArticleReaction): Promise<boolean>;
|
|
42
|
+
}
|
|
33
43
|
interface HelpHost {
|
|
34
44
|
close: () => void;
|
|
35
45
|
closeLabel: string;
|
|
46
|
+
feedback?: ArticleFeedback;
|
|
36
47
|
panel: HTMLElement;
|
|
37
48
|
scheme: 'dark' | 'light' | 'system' | undefined;
|
|
38
49
|
source: HelpSource;
|
|
39
50
|
words: HelpWords;
|
|
40
51
|
}
|
|
41
52
|
type HelpClient = HelpSource & {
|
|
53
|
+
cameFrom?: (article: ArticleRef) => void;
|
|
42
54
|
helpCentre?: HelpRead;
|
|
43
55
|
};
|
|
56
|
+
declare const feedbackOf: (client: HelpClient) => ArticleFeedback | undefined;
|
|
44
57
|
declare function hostOf(client: HelpClient, lent: Omit<HelpHost, 'source'>): HelpHost | null;
|
|
45
58
|
declare function setHelping(panel: HTMLElement, helping: boolean): void;
|
|
46
59
|
declare function showArticle(host: HelpHost, hit: ArticleHit): void;
|
|
@@ -48,11 +61,13 @@ declare function firstView(host: HelpHost, empty: HTMLElement): void;
|
|
|
48
61
|
declare function helpTab(host: HelpHost): void;
|
|
49
62
|
declare function whileTyping(host: HelpHost, input: HTMLInputElement, composer: HTMLElement): void;
|
|
50
63
|
|
|
64
|
+
type Articles_ArticleFeedback = ArticleFeedback;
|
|
51
65
|
declare const Articles_HELP_CSS: typeof HELP_CSS;
|
|
52
66
|
type Articles_HelpClient = HelpClient;
|
|
53
67
|
type Articles_HelpHost = HelpHost;
|
|
54
68
|
type Articles_HelpRead = HelpRead;
|
|
55
69
|
type Articles_HelpSource = HelpSource;
|
|
70
|
+
declare const Articles_REACTIONS: typeof REACTIONS;
|
|
56
71
|
type Articles_ReaderControls = ReaderControls;
|
|
57
72
|
declare const Articles_SEARCH_PAUSE_MS: typeof SEARCH_PAUSE_MS;
|
|
58
73
|
declare const Articles_SUGGESTED: typeof SUGGESTED;
|
|
@@ -60,6 +75,8 @@ declare const Articles_TYPED_MINIMUM: typeof TYPED_MINIMUM;
|
|
|
60
75
|
declare const Articles_articleRows: typeof articleRows;
|
|
61
76
|
declare const Articles_collectionRows: typeof collectionRows;
|
|
62
77
|
declare const Articles_emptyRows: typeof emptyRows;
|
|
78
|
+
declare const Articles_faces: typeof faces;
|
|
79
|
+
declare const Articles_feedbackOf: typeof feedbackOf;
|
|
63
80
|
declare const Articles_firstView: typeof firstView;
|
|
64
81
|
declare const Articles_frameAddress: typeof frameAddress;
|
|
65
82
|
declare const Articles_helpReads: typeof helpReads;
|
|
@@ -75,7 +92,7 @@ declare const Articles_showArticle: typeof showArticle;
|
|
|
75
92
|
declare const Articles_suggestions: typeof suggestions;
|
|
76
93
|
declare const Articles_whileTyping: typeof whileTyping;
|
|
77
94
|
declare namespace Articles {
|
|
78
|
-
export { Articles_HELP_CSS as HELP_CSS, type Articles_HelpClient as HelpClient, type Articles_HelpHost as HelpHost, type Articles_HelpRead as HelpRead, type Articles_HelpSource as HelpSource, type Articles_ReaderControls as ReaderControls, Articles_SEARCH_PAUSE_MS as SEARCH_PAUSE_MS, Articles_SUGGESTED as SUGGESTED, Articles_TYPED_MINIMUM as TYPED_MINIMUM, Articles_articleRows as articleRows, Articles_collectionRows as collectionRows, Articles_emptyRows as emptyRows, Articles_firstView as firstView, Articles_frameAddress as frameAddress, Articles_helpReads as helpReads, Articles_helpTab as helpTab, Articles_helpTabs as helpTabs, Articles_hostOf as hostOf, Articles_isReadable as isReadable, Articles_paused as paused, Articles_reader as reader, Articles_searchBox as searchBox, Articles_setHelping as setHelping, Articles_showArticle as showArticle, Articles_suggestions as suggestions, Articles_whileTyping as whileTyping };
|
|
95
|
+
export { type Articles_ArticleFeedback as ArticleFeedback, Articles_HELP_CSS as HELP_CSS, type Articles_HelpClient as HelpClient, type Articles_HelpHost as HelpHost, type Articles_HelpRead as HelpRead, type Articles_HelpSource as HelpSource, Articles_REACTIONS as REACTIONS, type Articles_ReaderControls as ReaderControls, Articles_SEARCH_PAUSE_MS as SEARCH_PAUSE_MS, Articles_SUGGESTED as SUGGESTED, Articles_TYPED_MINIMUM as TYPED_MINIMUM, Articles_articleRows as articleRows, Articles_collectionRows as collectionRows, Articles_emptyRows as emptyRows, Articles_faces as faces, Articles_feedbackOf as feedbackOf, Articles_firstView as firstView, Articles_frameAddress as frameAddress, Articles_helpReads as helpReads, Articles_helpTab as helpTab, Articles_helpTabs as helpTabs, Articles_hostOf as hostOf, Articles_isReadable as isReadable, Articles_paused as paused, Articles_reader as reader, Articles_searchBox as searchBox, Articles_setHelping as setHelping, Articles_showArticle as showArticle, Articles_suggestions as suggestions, Articles_whileTyping as whileTyping };
|
|
79
96
|
}
|
|
80
97
|
|
|
81
98
|
declare const filesCss: (taking: boolean, composerShape: AppearanceSettings["composerShape"]) => string;
|
|
@@ -100,6 +117,64 @@ declare namespace Files {
|
|
|
100
117
|
export { type Files_FilesHost as FilesHost, Files_attachField as attachField, Files_drawFile as drawFile, Files_filesCss as filesCss, Files_sizeOf as sizeOf };
|
|
101
118
|
}
|
|
102
119
|
|
|
120
|
+
declare const POLL_MS = 15000;
|
|
121
|
+
type FieldType = 'boolean' | 'currency' | 'date' | 'enum' | 'long_text' | 'multi_enum' | 'number' | 'phone' | 'text' | 'url';
|
|
122
|
+
interface FormField {
|
|
123
|
+
key: string;
|
|
124
|
+
label: string;
|
|
125
|
+
attributeType: FieldType;
|
|
126
|
+
options: {
|
|
127
|
+
value: string;
|
|
128
|
+
label: string;
|
|
129
|
+
}[];
|
|
130
|
+
required: boolean;
|
|
131
|
+
}
|
|
132
|
+
interface TicketForm {
|
|
133
|
+
typeId: string;
|
|
134
|
+
name: string;
|
|
135
|
+
description: string | null;
|
|
136
|
+
fields: FormField[];
|
|
137
|
+
}
|
|
138
|
+
interface CustomerTicket {
|
|
139
|
+
number: number;
|
|
140
|
+
title: string;
|
|
141
|
+
typeName: string;
|
|
142
|
+
stateLabel: string;
|
|
143
|
+
conversationId: string | null;
|
|
144
|
+
updatedAt: string;
|
|
145
|
+
}
|
|
146
|
+
interface Opened {
|
|
147
|
+
conversationId: string;
|
|
148
|
+
token: string;
|
|
149
|
+
}
|
|
150
|
+
declare const TICKETS_CSS = "[hidden]{display:none!important}.htabs{display:grid;grid-auto-flow:column;grid-auto-columns:1fr;grid-template-columns:none;border-top:1px solid var(--hairline)}.htab{display:flex;flex-direction:column;align-items:center;gap:2px;padding:8px 0 10px;font:inherit;font-size:11.5px;font-weight:550;line-height:1.45;color:var(--ink-3);background:none;border:0;cursor:pointer}.htab[aria-selected=\"true\"]{color:var(--a)}.htab svg{display:block;width:22px;height:22px;fill:currentColor}.htab:focus-visible{outline:2px solid var(--a);outline-offset:-2px}.tview{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;gap:10px;padding:16px}.tview h3{margin:0;font-size:16px;font-weight:640}.tbar{display:flex;align-items:center;gap:6px}.tbar h3{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tback{display:grid;place-items:center;flex:none;width:44px;height:44px;padding:0;border:0;border-radius:8px;background:none;color:var(--ink);cursor:pointer}.tback svg{width:20px;height:20px;fill:currentColor}.tback:focus-visible{outline:2px solid var(--a)}.trow{display:flex;flex-direction:column;gap:2px;width:100%;min-height:44px;padding:10px 2px;font:inherit;font-size:14px;line-height:1.45;color:var(--ink);text-align:left;background:none;border:0;border-bottom:1px solid var(--hairline);cursor:pointer}.trow small{font-size:12px;color:var(--ink-3)}.trow:focus-visible{outline:2px solid var(--a);outline-offset:-2px}.tnote{margin:0;font-size:13.5px;line-height:1.45;color:var(--ink-2)}.tform{display:flex;flex-direction:column;gap:10px}.tform label{display:flex;flex-direction:column;gap:4px;font-size:12.5px;font-weight:600;color:var(--ink-2)}.tform label.tcheck{flex-direction:row;align-items:center;gap:8px}.tform input,.tform select,.tform textarea{min-height:44px;padding:8px 12px;font:inherit;font-size:14px;font-weight:400;color:var(--ink);background:var(--fill);border:1px solid var(--hairline);border-radius:8px}.tform textarea{min-height:88px;resize:vertical}.tform input[type=\"checkbox\"]{min-height:0;width:20px;height:20px}.tform :focus-visible{outline:2px solid var(--a);outline-offset:1px}.tsend{align-self:flex-start;min-height:44px;padding:0 18px;font:inherit;font-size:14px;font-weight:600;color:#fff;background:var(--a);border:0;border-radius:8px;cursor:pointer}.tsend:disabled{opacity:.6;cursor:default}.tsend:focus-visible{outline:2px solid var(--ink);outline-offset:2px}.tfail{margin:0;padding:10px 12px;font-size:13.5px;color:#b91c1c;background:color-mix(in srgb,#dc2626 12%,transparent);border-radius:8px}.tlog{display:flex;flex-direction:column;gap:8px}";
|
|
151
|
+
declare function ticketsTab(panel: HTMLElement, client: ChatSource, words: TicketWords): void;
|
|
152
|
+
type Call = <T>(path: string, body?: unknown, token?: string) => Promise<T | null>;
|
|
153
|
+
type Visitor = NonNullable<ChatSource['visitor']>;
|
|
154
|
+
declare function updatedAgo(at: string, now: number, locale?: string): string;
|
|
155
|
+
declare function list(view: HTMLElement, call: Call, visitor: Visitor, words: TicketWords): Promise<void>;
|
|
156
|
+
declare function control(field: FormField, words: TicketWords): HTMLElement;
|
|
157
|
+
declare function valuesOf(form: HTMLFormElement, fields: readonly FormField[]): Record<string, unknown>;
|
|
158
|
+
declare function form(view: HTMLElement, call: Call, visitor: Visitor, words: TicketWords): Promise<void>;
|
|
159
|
+
declare function conversation(view: HTMLElement, call: Call, visitor: Visitor, words: TicketWords, title: string, opened: Opened): Promise<void>;
|
|
160
|
+
|
|
161
|
+
type Tickets_CustomerTicket = CustomerTicket;
|
|
162
|
+
type Tickets_FieldType = FieldType;
|
|
163
|
+
type Tickets_FormField = FormField;
|
|
164
|
+
declare const Tickets_POLL_MS: typeof POLL_MS;
|
|
165
|
+
declare const Tickets_TICKETS_CSS: typeof TICKETS_CSS;
|
|
166
|
+
type Tickets_TicketForm = TicketForm;
|
|
167
|
+
declare const Tickets_control: typeof control;
|
|
168
|
+
declare const Tickets_conversation: typeof conversation;
|
|
169
|
+
declare const Tickets_form: typeof form;
|
|
170
|
+
declare const Tickets_list: typeof list;
|
|
171
|
+
declare const Tickets_ticketsTab: typeof ticketsTab;
|
|
172
|
+
declare const Tickets_updatedAgo: typeof updatedAgo;
|
|
173
|
+
declare const Tickets_valuesOf: typeof valuesOf;
|
|
174
|
+
declare namespace Tickets {
|
|
175
|
+
export { type Tickets_CustomerTicket as CustomerTicket, type Tickets_FieldType as FieldType, type Tickets_FormField as FormField, Tickets_POLL_MS as POLL_MS, Tickets_TICKETS_CSS as TICKETS_CSS, type Tickets_TicketForm as TicketForm, Tickets_control as control, Tickets_conversation as conversation, Tickets_form as form, Tickets_list as list, Tickets_ticketsTab as ticketsTab, Tickets_updatedAgo as updatedAgo, Tickets_valuesOf as valuesOf };
|
|
176
|
+
}
|
|
177
|
+
|
|
103
178
|
interface ChatStrings {
|
|
104
179
|
launcherLabel: string;
|
|
105
180
|
title: string;
|
|
@@ -119,7 +194,7 @@ interface ChatStrings {
|
|
|
119
194
|
removeFileLabel: string;
|
|
120
195
|
fileRefusal: (size: string, limit: string) => string;
|
|
121
196
|
}
|
|
122
|
-
type MessengerAppearance = Pick<MessengerConfig, 'accentColor' | 'attachments' | 'availability' | 'awayMessage' | 'greeting' | 'launcherOffsetX' | 'launcherOffsetY' | 'launcherPosition' | 'help' | 'starterPrompts' | 'team'> & AppearanceSettings;
|
|
197
|
+
type MessengerAppearance = Pick<MessengerConfig, 'accentColor' | 'attachments' | 'availability' | 'awayMessage' | 'greeting' | 'launcherOffsetX' | 'launcherOffsetY' | 'launcherPosition' | 'help' | 'poweredBy' | 'starterPrompts' | 'team' | 'tickets'> & AppearanceSettings;
|
|
123
198
|
declare const DEFAULT_APPEARANCE: MessengerAppearance;
|
|
124
199
|
interface ChatSource {
|
|
125
200
|
avatarUrl(url: string): string;
|
|
@@ -127,18 +202,25 @@ interface ChatSource {
|
|
|
127
202
|
send(body: string, pageContext?: PageContext, attachmentIds?: string[]): Promise<ChatTurn | null>;
|
|
128
203
|
upload?(file: File): Promise<ChatUpload | null>;
|
|
129
204
|
file?(path: string): Promise<Blob | null>;
|
|
205
|
+
articleFrame?(article: ArticleRef): Promise<string | null>;
|
|
130
206
|
articles?(query: string): Promise<ArticleHit[]>;
|
|
131
207
|
popularArticles?(): Promise<ArticleHit[]>;
|
|
132
208
|
collections?(): Promise<ArticleCollection[]>;
|
|
133
209
|
collectionArticles?(collection: string): Promise<ArticleHit[]>;
|
|
134
|
-
helpCentre?<T>(suffix: string, params: Record<string, string>): Promise<T | null>;
|
|
210
|
+
helpCentre?<T>(suffix: string, params: Record<string, string>, body?: Record<string, string>): Promise<T | null>;
|
|
211
|
+
edge?<T>(path: string, body?: unknown, token?: string): Promise<T | null>;
|
|
212
|
+
readonly visitor?: (ChatIdentity & {
|
|
213
|
+
distinctId: string;
|
|
214
|
+
}) | null;
|
|
135
215
|
}
|
|
136
216
|
type ChatScheme = 'dark' | 'light' | 'system';
|
|
137
217
|
type HelpKit = typeof Articles;
|
|
138
218
|
type FilesKit = typeof Files;
|
|
219
|
+
type TicketsKit = typeof Tickets;
|
|
139
220
|
interface ChatPanelOptions {
|
|
140
221
|
help?: () => Promise<HelpKit | null>;
|
|
141
222
|
files?: () => Promise<FilesKit | null>;
|
|
223
|
+
tickets?: () => Promise<TicketsKit | null>;
|
|
142
224
|
scheme?: ChatScheme;
|
|
143
225
|
shadowMode?: 'closed' | 'open';
|
|
144
226
|
}
|
|
@@ -168,6 +250,8 @@ declare class ChatPanel {
|
|
|
168
250
|
private readonly filesLoader;
|
|
169
251
|
private filesKit;
|
|
170
252
|
private filesLoad;
|
|
253
|
+
private readonly ticketsLoader;
|
|
254
|
+
private ticketsLoad;
|
|
171
255
|
constructor(host: HTMLElement, client: ChatSource, strings?: Partial<ChatStrings>, appearance?: Partial<MessengerAppearance>, options?: ChatPanelOptions);
|
|
172
256
|
private drawLauncher;
|
|
173
257
|
update(appearance: Partial<MessengerAppearance>, scheme?: ChatScheme): void;
|
|
@@ -227,6 +311,7 @@ interface MountChatOptions extends ChatClientOptions {
|
|
|
227
311
|
socketFactory?: SocketFactory;
|
|
228
312
|
help?: () => Promise<HelpKit | null>;
|
|
229
313
|
files?: () => Promise<FilesKit | null>;
|
|
314
|
+
tickets?: () => Promise<TicketsKit | null>;
|
|
230
315
|
}
|
|
231
316
|
interface ChatHandle {
|
|
232
317
|
open(): void;
|