@prodantix/sdk 0.8.0 → 0.9.0-beta.783
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/README.md +2 -2
- package/dist/chat.cjs +3 -5
- package/dist/chat.d.cts +10 -7
- package/dist/chat.d.ts +10 -7
- package/dist/chat.js +3 -5
- package/dist/chunk-3S3BR7QH.js +2 -0
- package/dist/{chunk-ODN4ZELX.js → chunk-5WTMO52O.js} +2 -2
- package/dist/{client-vogZuHfD.d.cts → client-C8r0UAth.d.cts} +1 -1
- package/dist/{client-Cz7M6XJC.d.ts → client-DnfOdWQo.d.ts} +1 -1
- package/dist/{config-C8WD1Pge.d.cts → config-CUWitmwr.d.cts} +10 -1
- package/dist/{config-Bhwwo-uC.d.ts → config-DsYOO9JC.d.ts} +10 -1
- package/dist/consent.iife.js +45 -14
- package/dist/ctas.iife.js +3 -3
- package/dist/forms.iife.js +2 -2
- package/dist/{http-BCh716Vs.d.cts → http-CAOViYSh.d.cts} +1 -0
- package/dist/{http-BCh716Vs.d.ts → http-CAOViYSh.d.ts} +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/messenger-help.iife.js +1 -1
- package/dist/messenger-tickets.iife.js +1 -1
- package/dist/messenger.d.cts +2 -2
- package/dist/messenger.d.ts +2 -2
- package/dist/messenger.iife.js +2 -4
- package/dist/messenger.js +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +1 -1
- package/dist/pages.iife.js +1 -1
- package/dist/prodantix-push-sw.js +1 -1
- package/dist/{transport-C9C4hqlF.d.cts → transport-BBYpAuVK.d.cts} +4 -2
- package/dist/{transport-C4mkCaix.d.ts → transport-BZDcmleq.d.ts} +4 -2
- package/dist/web.cjs +4 -4
- package/dist/web.d.cts +3 -3
- package/dist/web.d.ts +3 -3
- package/dist/web.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-YHIIKYUP.js +0 -2
package/README.md
CHANGED
|
@@ -40,8 +40,8 @@ if (await prodantix.isFeatureEnabled('new-checkout')) {
|
|
|
40
40
|
registrable domain, so `xyz.com`, `app.xyz.com` and `console.xyz.com` see one person; the
|
|
41
41
|
identified id stays per origin in `localStorage` and never enters the cookie. Pass `cookieDomain`
|
|
42
42
|
to name the domain (a site whose subdomains belong to different tenants must), or `sharedStorage`
|
|
43
|
-
to write no cookie. The queue persists in `localStorage`,
|
|
44
|
-
|
|
43
|
+
to write no cookie. The queue persists in `localStorage`, a batch sent while the page is
|
|
44
|
+
hidden goes by a `keepalive` fetch so it outlives the page, and pageviews and clicks are autocaptured. Pass `autocapture: false` to disable
|
|
45
45
|
capture, or `autocaptureOptions: { pageviews, clicks }` to tune it.
|
|
46
46
|
|
|
47
47
|
Autocapture collects no customer content by default. A click records the element's tag, id and
|
package/dist/chat.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
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 o=(n,e,t)=>X(n,typeof e!="symbol"?e+"":e,t);var P=class extends Error{constructor(t,r,i){super(r,i);o(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);o(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 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;o(this,"fetchImpl");o(this,"fileFetchImpl");o(this,"host");o(this,"storage");o(this,"handle");o(this,"identity",null);o(this,"fromArticle",null);this.fetchImpl=$(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,t){if(!await this.ensureThread())return null;let r=this.handle;return r?this.fileRequest("POST",`/v1/conversations/${encodeURIComponent(r.conversationId)}/attachments?name=${encodeURIComponent(e.name)}`,r.token,async i=>JSON.parse(await i.text()),e,t):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,s){let l={authorization:`Bearer ${this.options.apiKey}`,[U]:r};a&&(l["content-type"]=a.type||"application/octet-stream");try{let h=await this.fileFetchImpl(`${this.host}${t}`,{body:a,headers:l,method:e});if(h.ok)return await i(h);let u=s?.(await h.text());if(u)return u;this.options.onError?.(new k(`prodantix chat ${t}: ${h.status}`,h.status));}catch(h){this.options.onError?.(h);}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 s=await i(`${this.host}${t}`,{body:r.body===void 0?void 0:JSON.stringify(r.body),headers:a,method:e}),l=await s.text();return s.ok?l?JSON.parse(l):{}:(this.options.onError?.(new k(`prodantix chat ${t}: ${s.status}`,s.status)),null)}catch(s){return this.options.onError?.(s),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??"",s=`${i}:${a}`;return n.windows.some(l=>l.days.includes(r)&&l.open<=s&&s<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"],se=["avatar","glyph","team_faces"],oe=["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],s=typeof e.timestampStyle=="string"?e.timestampStyle:void 0,l=s===void 0?void 0:ue[s],h=typeof e.skin=="string"?e.skin:void 0,u=h===void 0?void 0:me[h],d=typeof e.bubbleStyle=="string"?e.bubbleStyle:void 0,c=d===void 0?void 0:ge[d],p={bubbleFill:y(e.bubbleFill,re,c?.[1]??f.bubbleFill),bubbleShape:y(e.bubbleShape,ne,c?.[0]??f.bubbleShape),composerShape:y(e.composerShape,te,u?.[1]??f.composerShape),dayDividers:K(e.dayDividers,l?.[0]??f.dayDividers),launcherContent:y(e.launcherContent,se,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,oe,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}"},Me=".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
|
-
--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 $e(n){return n==="light"?"":n==="dark"?`:host { ${q} }`:`@media (prefers-color-scheme: dark) {
|
|
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 O(n){if(n)return n;let e=globalThis.fetch;if(typeof e=="function")return e.bind(globalThis)}function $(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=O(e.fetchImpl),this.fileFetchImpl=e.fileFetchImpl??((t,r)=>fetch(t,r)),this.host=$(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,t){if(!await this.ensureThread())return null;let r=this.handle;return r?this.fileRequest("POST",`/v1/conversations/${encodeURIComponent(r.conversationId)}/attachments?name=${encodeURIComponent(e.name)}`,r.token,async i=>JSON.parse(await i.text()),e,t):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,o){let l={authorization:`Bearer ${this.options.apiKey}`,[U]:r};a&&(l["content-type"]=a.type||"application/octet-stream");try{let h=await this.fileFetchImpl(`${this.host}${t}`,{body:a,headers:l,method:e});if(h.ok)return await i(h);let u=o?.(await h.text());if(u)return u;this.options.onError?.(new k(`prodantix chat ${t}: ${h.status}`,h.status));}catch(h){this.options.onError?.(h);}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 A(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],d=typeof e.bubbleStyle=="string"?e.bubbleStyle:void 0,c=d===void 0?void 0:ge[d],p={bubbleFill:y(e.bubbleFill,re,c?.[1]??f.bubbleFill),bubbleShape:y(e.bubbleShape,ne,c?.[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:var(--oa);",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);color:var(--oa);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 Ae(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 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:var(--oa);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}"},Me=".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);--fill:rgba(255,255,255,.06);--hairline:rgba(255,255,255,.13);--ink-2:rgba(255,255,255,.70);--online:oklch(72% 0.13 163.23);--at:var(--atd)";function Oe(n){return n==="light"?"":n==="dark"?`:host { ${q} }`:`@media (prefers-color-scheme: dark) {
|
|
4
2
|
:host {
|
|
5
3
|
${q}
|
|
6
4
|
}
|
|
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 s=document.createElement("a");s.href=a,s.target="_blank",s.rel="noopener noreferrer",s.textContent=a,n.append(s),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}}${$e(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.system{align-self:center;font-size:12px;color:var(--ink-3)}.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"?Me:""}`}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;o(this,"root");o(this,"strings");o(this,"settings");o(this,"appearance");o(this,"launcher");o(this,"badge");o(this,"panel",null);o(this,"scrim",null);o(this,"lastFocused",null);o(this,"unread",0);o(this,"pendingTurns",0);o(this,"openNow");o(this,"styles");o(this,"scheme");o(this,"picked",null);o(this,"objectUrls",[]);o(this,"helpLoader");o(this,"kit",null);o(this,"kitLoad",null);o(this,"filesLoader");o(this,"filesKit",null);o(this,"filesLoad",null);o(this,"ticketsLoader");o(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 s=document.createElement("h2");s.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(s,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 d=document.createElement("div");d.className="log",d.setAttribute("role","log"),d.setAttribute("aria-live","polite"),d.setAttribute("aria-label",this.strings.title);let c=document.createElement("form");c.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),c.append(p,m),c.addEventListener("submit",b=>{b.preventDefault(),this.submit(p,d);}),e.append(t,d,c),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},c,p,d,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,c),x&&this.appearance.tickets&&x.ticketsTab(e,this.client,this.appearance.tickets.words),g&&g.turns.length>0?this.renderThread(d,g):this.renderFirstRun(d,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 d=document.createElement("div");d.className="promptwords",d.id=`prompt-${h}`;let c=document.createElement("template");c.innerHTML=l.html,qe(c.content)?d.append(c.content):d.textContent=l.text;for(let m of d.querySelectorAll("a"))m.target="_blank",m.rel="noopener noreferrer";let p=document.createElement("button");p.className="promptpress",p.type="button",p.setAttribute("aria-labelledby",d.id),p.addEventListener("click",()=>{t.value=l.text,this.submit(t,e);}),u.append(d,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,this.filesKit?.uploadRefusalOf):void 0;if(a&&"refusal"in a){this.filesKit?.markRefused(i,a.refusal,this.appearance.attachments,()=>this.sendBody(e,t,r));return}let s=a===null?null:await this.client.send(t,Ye(),a?[a.id]:void 0);if(i.removeAttribute("data-pending"),s){i.dataset.turnId=s.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){if(e.querySelector(".empty")?.remove(),t.authorKind==="system"){let c=document.createElement("div");return c.className="turn system",c.dataset.turnId=t.id,c.textContent=t.body,e.append(c),c}let i=je.includes(t.authorKind)?t.authorKind:"agent",a=this.settings,s=document.createElement("div");if(s.className=`turn ${i}`,s.dataset.turnId=t.id,i!=="end_user"&&a.nameAvatar){let c=document.createElement("span");if(c.className=i==="ai"?"av bot":"av",c.setAttribute("aria-hidden","true"),i==="agent"&&t.authorAvatarUrl){let p=document.createElement("img");p.alt="",p.src=this.client.avatarUrl(t.authorAvatarUrl),c.append(p);}else {c.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&&(c.style.background=p);}s.append(c);}let h=document.createElement("div");if(h.className="body",i==="end_user"){let c=this.filesKit,p=m=>this.objectUrl(m);r&&c?.drawFile(h,r.name,r.type,r.size,Promise.resolve(r),p);for(let m of t.attachments??[])c?.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",d=document.createElement("div");if(i==="ai"?ze(d,t.body):d.textContent=t.body,u||i==="ai"&&a.namePlacement==="hidden"){let c=document.createElement("div");c.className=i==="ai"?"author ai":"author",c.textContent=i==="ai"?this.strings.aiLabel:this.agentName(t),a.stampPlacement==="beside_name"&&c.append(this.stamp(t)),a.namePlacement==="inline"?(c.classList.add("below"),h.append(d,c)):h.append(c,d);}else t.body&&h.append(d);return a.stampPlacement==="under_turn"&&h.append(this.stamp(t)),s.append(h),e.append(s),e.scrollTop=e.scrollHeight,s}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],s=i[i.length-1],l=this.root.activeElement;e.shiftKey&&l===a?(e.preventDefault(),s.focus()):!e.shiftKey&&l===s?(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 s=a.offset>Math.min(72,n.getBoundingClientRect().height*.4),l=a.offset/Math.max(1,i.timeStamp-a.at)>.5&&a.offset>16;s||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 s=M(t);return {kind:"open",pingInterval:typeof s?.pingInterval=="number"?s.pingInterval:25e3,pingTimeout:typeof s?.pingTimeout=="number"?s.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 s=M(i);return {kind:"connectError",message:typeof s?.message=="string"?s.message:"refused"}}if(r!=="2")return {kind:"other"};let a=M(i);return !Array.isArray(a)||typeof a[0]!="string"?{kind:"other"}:{kind:"event",name:a[0],payload:a[1]}}function M(n){try{return JSON.parse(n)}catch{return null}}var Ze="/socket.io/?EIO=4&transport=websocket",F=class{constructor(e){this.options=e;o(this,"socket",null);o(this,"heartbeat",null);o(this,"ready",false);o(this,"closed",false);o(this,"heartbeatWindow",45e3);o(this,"factory");o(this,"setTimer");o(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,s,l=()=>{i.setOpenNow(_(a,new Date)),s=setTimeout(l,et);};l();let h=new Set,u,d=null,c=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||c<=0||(u=setInterval(()=>void m(),c));},S=()=>{u&&clearInterval(u),u=void 0;},C=()=>{if(d||!n.socketHost)return;let g=r.socketAuth;g&&(d=new F({auth:g,host:n.socketHost,onClosed:x=>{d=null,E(),x&&C();},onReady:S,onTurn:p,socketFactory:n.socketFactory}),d.open());};return E(),C(),{close:()=>i.close(),destroy:()=>{S(),clearTimeout(s),d?.close(),d=null,i.close(),t.remove();},identify:g=>r.identify(g),open:()=>{i.open().then(C);}}}
|
|
8
|
-
exports.ChatClient=w;exports.ChatPanel=
|
|
5
|
+
}`}var $e=/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($e)){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=A(n),r=n.launcherPosition==="bottom_left"?"left":"right",i=n.accentColor;return `${`:host{all:initial;z-index:2147483000;--a:${i};--oa:${n.onAccent||"#fff"};--at:${n.accentInk||i};--atd:${n.accentInkDark||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}}${Oe(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;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:color-mix(in srgb,currentColor 80%,transparent)}.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:var(--oa)}.turn.agent,.turn.ai{align-self:flex-start;background:var(--fill);color:var(--ink)}.turn.system{align-self:center;font-size:12px;color:var(--ink-3)}.turn.ai a{color:var(--at);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:var(--at);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:var(--at);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 var(--at);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 var(--at)}.composer button{display:inline-flex;align-items:center;justify-content:center;gap:0;min-width:56px;height:36px;padding:0 14px;background:${i};color:var(--oa);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}.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]}${Le[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"?Me:""}`}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>',L=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=A({...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=A(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 d=document.createElement("div");d.className="log",d.setAttribute("role","log"),d.setAttribute("aria-live","polite"),d.setAttribute("aria-label",this.strings.title);let c=document.createElement("form");c.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),c.append(p,m),c.addEventListener("submit",b=>{b.preventDefault(),this.submit(p,d);}),e.append(t,d,c),this.appearance.poweredBy&&e.append(Ae(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},c,p,d,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,c),x&&this.appearance.tickets&&x.ticketsTab(e,this.client,this.appearance.tickets.words),g&&g.turns.length>0?this.renderThread(d,g):this.renderFirstRun(d,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 d=document.createElement("div");d.className="promptwords",d.id=`prompt-${h}`;let c=document.createElement("template");c.innerHTML=l.html,qe(c.content)?d.append(c.content):d.textContent=l.text;for(let m of d.querySelectorAll("a"))m.target="_blank",m.rel="noopener noreferrer";let p=document.createElement("button");p.className="promptpress",p.type="button",p.setAttribute("aria-labelledby",d.id),p.addEventListener("click",()=>{t.value=l.text,this.submit(t,e);}),u.append(d,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,this.filesKit?.uploadRefusalOf):void 0;if(a&&"refusal"in a){this.filesKit?.markRefused(i,a.refusal,this.appearance.attachments,()=>this.sendBody(e,t,r));return}let 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){if(e.querySelector(".empty")?.remove(),t.authorKind==="system"){let c=document.createElement("div");return c.className="turn system",c.dataset.turnId=t.id,c.textContent=t.body,e.append(c),c}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 c=document.createElement("span");if(c.className=i==="ai"?"av bot":"av",c.setAttribute("aria-hidden","true"),i==="agent"&&t.authorAvatarUrl){let p=document.createElement("img");p.alt="",p.src=this.client.avatarUrl(t.authorAvatarUrl),c.append(p);}else {c.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&&(c.style.background=p);}o.append(c);}let h=document.createElement("div");if(h.className="body",i==="end_user"){let c=this.filesKit,p=m=>this.objectUrl(m);r&&c?.drawFile(h,r.name,r.type,r.size,Promise.resolve(r),p);for(let m of t.attachments??[])c?.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",d=document.createElement("div");if(i==="ai"?ze(d,t.body):d.textContent=t.body,u||i==="ai"&&a.namePlacement==="hidden"){let c=document.createElement("div");c.className=i==="ai"?"author ai":"author",c.textContent=i==="ai"?this.strings.aiLabel:this.agentName(t),a.stampPlacement==="beside_name"&&c.append(this.stamp(t)),a.namePlacement==="inline"?(c.classList.add("below"),h.append(d,c)):h.append(c,d);}else t.body&&h.append(d);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=M(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=M(i);return {kind:"connectError",message:typeof o?.message=="string"?o.message:"refused"}}if(r!=="2")return {kind:"other"};let a=M(i);return !Array.isArray(a)||typeof a[0]!="string"?{kind:"other"}:{kind:"event",name:a[0],payload:a[1]}}function M(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 At(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 L(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,d=null,c=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||c<=0||(u=setInterval(()=>void m(),c));},S=()=>{u&&clearInterval(u),u=void 0;},C=()=>{if(d||!n.socketHost)return;let g=r.socketAuth;g&&(d=new F({auth:g,host:n.socketHost,onClosed:x=>{d=null,E(),x&&C();},onReady:S,onTurn:p,socketFactory:n.socketFactory}),d.open());};return E(),C(),{close:()=>i.close(),destroy:()=>{S(),clearTimeout(o),d?.close(),d=null,i.close(),t.remove();},identify:g=>r.identify(g),open:()=>{i.open().then(C);}}}
|
|
6
|
+
exports.ChatClient=w;exports.ChatPanel=L;exports.DEFAULT_APPEARANCE=T;exports.DEFAULT_APPEARANCE_SETTINGS=f;exports.mountChat=At;exports.panelStyles=j;exports.resolveAppearance=A;//# sourceMappingURL=chat.cjs.map
|
|
9
7
|
//# sourceMappingURL=chat.cjs.map
|
package/dist/chat.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { A as ArticleRef, a as ArticleReaction, b as ArticleHit, c as ArticleCollection, H as HelpWords, M as MessengerAttachments, d as AppearanceSettings, U as UploadRefusalCode, C as ChatUploadRefusal, T as TicketWords, e as ChatThread, P as PageContext, f as ChatTurn, g as ChatUpload, h as ChatIdentity, i as MessengerConfig, j as ChatClientOptions } from './config-
|
|
2
|
-
export { B as BubbleFill, k as BubbleShape, l as ChatAttachment, m as ChatClient, n as ChatStorage, o as ComposerShape, D as DEFAULT_APPEARANCE_SETTINGS, F as FileFetchLike, p as FileResponseLike, L as LauncherContent, q as LauncherFill, r as LauncherShape, s as LauncherSize, t as MessengerSkin, N as NamePlacement, S as StampContent, u as StampPlacement, v as resolveAppearance } from './config-
|
|
1
|
+
import { A as ArticleRef, a as ArticleReaction, b as ArticleHit, c as ArticleCollection, H as HelpWords, M as MessengerAttachments, d as AppearanceSettings, U as UploadRefusalCode, C as ChatUploadRefusal, T as TicketWords, e as ChatThread, P as PageContext, f as ChatTurn, g as ChatUpload, h as ChatIdentity, i as MessengerConfig, j as ChatClientOptions } from './config-CUWitmwr.cjs';
|
|
2
|
+
export { B as BubbleFill, k as BubbleShape, l as ChatAttachment, m as ChatClient, n as ChatStorage, o as ComposerShape, D as DEFAULT_APPEARANCE_SETTINGS, F as FileFetchLike, p as FileResponseLike, L as LauncherContent, q as LauncherFill, r as LauncherShape, s as LauncherSize, t as MessengerSkin, N as NamePlacement, S as StampContent, u as StampPlacement, v as resolveAppearance } from './config-CUWitmwr.cjs';
|
|
3
3
|
import { S as SocketFactory } from './types-BUXFV_aE.cjs';
|
|
4
|
-
import './http-
|
|
4
|
+
import './http-CAOViYSh.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
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(--
|
|
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(--at);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(--at);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(--at)}.htab svg{display:block;width:22px;height:22px;fill:currentColor}.htab:focus-visible{outline:2px solid var(--at);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(--at)}.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:var(--oa);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(--at);background:color-mix(in srgb,var(--a) 14%,transparent)}.hface:focus-visible{outline:2px solid var(--at);outline-offset:2px}.hrow,.htab,.hmore,.hlabel,.hnone,.hsugg p{line-height:1.45}";
|
|
11
11
|
declare function searchBox(words: HelpWords, onWords: (words: string) => void): HTMLElement;
|
|
12
12
|
declare function paused(run: (words: string) => void): (words: string) => void;
|
|
13
13
|
declare const isReadable: (hit: ArticleHit) => boolean;
|
|
@@ -144,6 +144,7 @@ interface CustomerTicket {
|
|
|
144
144
|
title: string;
|
|
145
145
|
typeName: string;
|
|
146
146
|
stateLabel: string;
|
|
147
|
+
stateCategory: 'in_progress' | 'resolved' | 'submitted' | 'waiting_on_customer';
|
|
147
148
|
conversationId: string | null;
|
|
148
149
|
updatedAt: string;
|
|
149
150
|
}
|
|
@@ -151,11 +152,12 @@ interface Opened {
|
|
|
151
152
|
conversationId: string;
|
|
152
153
|
token: string;
|
|
153
154
|
}
|
|
154
|
-
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(--
|
|
155
|
+
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(--at)}.htab svg{display:block;width:22px;height:22px;fill:currentColor}.htab:focus-visible{outline:2px solid var(--at);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(--at)}.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)}.thead{display:flex;align-items:center;gap:8px;width:100%}.thead span:first-child{flex:1;min-width:0;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tpill{flex:none;padding:1px 8px;font-size:11.5px;font-weight:600;line-height:1.6;border-radius:999px;color:var(--at);background:color-mix(in srgb,var(--a) 14%,transparent)}.tpill[data-category=\"waiting_on_customer\"]{color:var(--ink);background:color-mix(in srgb,#f59e0b 28%,transparent)}.tpill[data-category=\"resolved\"]{color:var(--ink-3);background:var(--fill)}.trow:focus-visible{outline:2px solid var(--at);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(--at);outline-offset:1px}.tsend{align-self:flex-start;min-height:44px;padding:0 18px;font:inherit;font-size:14px;font-weight:600;color:var(--oa);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}";
|
|
155
156
|
declare function ticketsTab(panel: HTMLElement, client: ChatSource, words: TicketWords): void;
|
|
156
157
|
type Call = <T>(path: string, body?: unknown, token?: string) => Promise<T | null>;
|
|
157
158
|
type Visitor = NonNullable<ChatSource['visitor']>;
|
|
158
159
|
declare function updatedAgo(at: string, now: number, locale?: string): string;
|
|
160
|
+
declare function timeLine(ticket: Pick<CustomerTicket, 'stateCategory' | 'updatedAt'>, words: Pick<TicketWords, 'asked' | 'closed' | 'updated'>, now: number, locale?: string): string;
|
|
159
161
|
declare function list(view: HTMLElement, call: Call, visitor: Visitor, words: TicketWords): Promise<void>;
|
|
160
162
|
declare function control(field: FormField, words: TicketWords): HTMLElement;
|
|
161
163
|
declare function valuesOf(form: HTMLFormElement, fields: readonly FormField[]): Record<string, unknown>;
|
|
@@ -173,10 +175,11 @@ declare const Tickets_conversation: typeof conversation;
|
|
|
173
175
|
declare const Tickets_form: typeof form;
|
|
174
176
|
declare const Tickets_list: typeof list;
|
|
175
177
|
declare const Tickets_ticketsTab: typeof ticketsTab;
|
|
178
|
+
declare const Tickets_timeLine: typeof timeLine;
|
|
176
179
|
declare const Tickets_updatedAgo: typeof updatedAgo;
|
|
177
180
|
declare const Tickets_valuesOf: typeof valuesOf;
|
|
178
181
|
declare namespace Tickets {
|
|
179
|
-
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 };
|
|
182
|
+
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_timeLine as timeLine, Tickets_updatedAgo as updatedAgo, Tickets_valuesOf as valuesOf };
|
|
180
183
|
}
|
|
181
184
|
|
|
182
185
|
interface ChatStrings {
|
|
@@ -198,7 +201,7 @@ interface ChatStrings {
|
|
|
198
201
|
removeFileLabel: string;
|
|
199
202
|
fileRefusal: (size: string, limit: string) => string;
|
|
200
203
|
}
|
|
201
|
-
type MessengerAppearance = Pick<MessengerConfig, 'accentColor' | 'attachments' | 'availability' | 'awayMessage' | 'greeting' | 'launcherOffsetX' | 'launcherOffsetY' | 'launcherPosition' | 'help' | 'poweredBy' | 'starterPrompts' | 'team' | 'tickets'> & AppearanceSettings;
|
|
204
|
+
type MessengerAppearance = Pick<MessengerConfig, 'accentColor' | 'accentInk' | 'accentInkDark' | 'attachments' | 'availability' | 'awayMessage' | 'greeting' | 'launcherOffsetX' | 'launcherOffsetY' | 'launcherPosition' | 'help' | 'onAccent' | 'poweredBy' | 'starterPrompts' | 'team' | 'tickets'> & AppearanceSettings;
|
|
202
205
|
declare const DEFAULT_APPEARANCE: MessengerAppearance;
|
|
203
206
|
interface ChatSource {
|
|
204
207
|
avatarUrl(url: string): string;
|
package/dist/chat.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { A as ArticleRef, a as ArticleReaction, b as ArticleHit, c as ArticleCollection, H as HelpWords, M as MessengerAttachments, d as AppearanceSettings, U as UploadRefusalCode, C as ChatUploadRefusal, T as TicketWords, e as ChatThread, P as PageContext, f as ChatTurn, g as ChatUpload, h as ChatIdentity, i as MessengerConfig, j as ChatClientOptions } from './config-
|
|
2
|
-
export { B as BubbleFill, k as BubbleShape, l as ChatAttachment, m as ChatClient, n as ChatStorage, o as ComposerShape, D as DEFAULT_APPEARANCE_SETTINGS, F as FileFetchLike, p as FileResponseLike, L as LauncherContent, q as LauncherFill, r as LauncherShape, s as LauncherSize, t as MessengerSkin, N as NamePlacement, S as StampContent, u as StampPlacement, v as resolveAppearance } from './config-
|
|
1
|
+
import { A as ArticleRef, a as ArticleReaction, b as ArticleHit, c as ArticleCollection, H as HelpWords, M as MessengerAttachments, d as AppearanceSettings, U as UploadRefusalCode, C as ChatUploadRefusal, T as TicketWords, e as ChatThread, P as PageContext, f as ChatTurn, g as ChatUpload, h as ChatIdentity, i as MessengerConfig, j as ChatClientOptions } from './config-DsYOO9JC.js';
|
|
2
|
+
export { B as BubbleFill, k as BubbleShape, l as ChatAttachment, m as ChatClient, n as ChatStorage, o as ComposerShape, D as DEFAULT_APPEARANCE_SETTINGS, F as FileFetchLike, p as FileResponseLike, L as LauncherContent, q as LauncherFill, r as LauncherShape, s as LauncherSize, t as MessengerSkin, N as NamePlacement, S as StampContent, u as StampPlacement, v as resolveAppearance } from './config-DsYOO9JC.js';
|
|
3
3
|
import { S as SocketFactory } from './types-BUXFV_aE.js';
|
|
4
|
-
import './http-
|
|
4
|
+
import './http-CAOViYSh.js';
|
|
5
5
|
|
|
6
6
|
declare const SEARCH_PAUSE_MS = 300;
|
|
7
7
|
declare const TYPED_MINIMUM = 3;
|
|
8
8
|
declare const SUGGESTED = 3;
|
|
9
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(--
|
|
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(--at);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(--at);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(--at)}.htab svg{display:block;width:22px;height:22px;fill:currentColor}.htab:focus-visible{outline:2px solid var(--at);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(--at)}.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:var(--oa);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(--at);background:color-mix(in srgb,var(--a) 14%,transparent)}.hface:focus-visible{outline:2px solid var(--at);outline-offset:2px}.hrow,.htab,.hmore,.hlabel,.hnone,.hsugg p{line-height:1.45}";
|
|
11
11
|
declare function searchBox(words: HelpWords, onWords: (words: string) => void): HTMLElement;
|
|
12
12
|
declare function paused(run: (words: string) => void): (words: string) => void;
|
|
13
13
|
declare const isReadable: (hit: ArticleHit) => boolean;
|
|
@@ -144,6 +144,7 @@ interface CustomerTicket {
|
|
|
144
144
|
title: string;
|
|
145
145
|
typeName: string;
|
|
146
146
|
stateLabel: string;
|
|
147
|
+
stateCategory: 'in_progress' | 'resolved' | 'submitted' | 'waiting_on_customer';
|
|
147
148
|
conversationId: string | null;
|
|
148
149
|
updatedAt: string;
|
|
149
150
|
}
|
|
@@ -151,11 +152,12 @@ interface Opened {
|
|
|
151
152
|
conversationId: string;
|
|
152
153
|
token: string;
|
|
153
154
|
}
|
|
154
|
-
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(--
|
|
155
|
+
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(--at)}.htab svg{display:block;width:22px;height:22px;fill:currentColor}.htab:focus-visible{outline:2px solid var(--at);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(--at)}.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)}.thead{display:flex;align-items:center;gap:8px;width:100%}.thead span:first-child{flex:1;min-width:0;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tpill{flex:none;padding:1px 8px;font-size:11.5px;font-weight:600;line-height:1.6;border-radius:999px;color:var(--at);background:color-mix(in srgb,var(--a) 14%,transparent)}.tpill[data-category=\"waiting_on_customer\"]{color:var(--ink);background:color-mix(in srgb,#f59e0b 28%,transparent)}.tpill[data-category=\"resolved\"]{color:var(--ink-3);background:var(--fill)}.trow:focus-visible{outline:2px solid var(--at);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(--at);outline-offset:1px}.tsend{align-self:flex-start;min-height:44px;padding:0 18px;font:inherit;font-size:14px;font-weight:600;color:var(--oa);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}";
|
|
155
156
|
declare function ticketsTab(panel: HTMLElement, client: ChatSource, words: TicketWords): void;
|
|
156
157
|
type Call = <T>(path: string, body?: unknown, token?: string) => Promise<T | null>;
|
|
157
158
|
type Visitor = NonNullable<ChatSource['visitor']>;
|
|
158
159
|
declare function updatedAgo(at: string, now: number, locale?: string): string;
|
|
160
|
+
declare function timeLine(ticket: Pick<CustomerTicket, 'stateCategory' | 'updatedAt'>, words: Pick<TicketWords, 'asked' | 'closed' | 'updated'>, now: number, locale?: string): string;
|
|
159
161
|
declare function list(view: HTMLElement, call: Call, visitor: Visitor, words: TicketWords): Promise<void>;
|
|
160
162
|
declare function control(field: FormField, words: TicketWords): HTMLElement;
|
|
161
163
|
declare function valuesOf(form: HTMLFormElement, fields: readonly FormField[]): Record<string, unknown>;
|
|
@@ -173,10 +175,11 @@ declare const Tickets_conversation: typeof conversation;
|
|
|
173
175
|
declare const Tickets_form: typeof form;
|
|
174
176
|
declare const Tickets_list: typeof list;
|
|
175
177
|
declare const Tickets_ticketsTab: typeof ticketsTab;
|
|
178
|
+
declare const Tickets_timeLine: typeof timeLine;
|
|
176
179
|
declare const Tickets_updatedAgo: typeof updatedAgo;
|
|
177
180
|
declare const Tickets_valuesOf: typeof valuesOf;
|
|
178
181
|
declare namespace Tickets {
|
|
179
|
-
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 };
|
|
182
|
+
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_timeLine as timeLine, Tickets_updatedAgo as updatedAgo, Tickets_valuesOf as valuesOf };
|
|
180
183
|
}
|
|
181
184
|
|
|
182
185
|
interface ChatStrings {
|
|
@@ -198,7 +201,7 @@ interface ChatStrings {
|
|
|
198
201
|
removeFileLabel: string;
|
|
199
202
|
fileRefusal: (size: string, limit: string) => string;
|
|
200
203
|
}
|
|
201
|
-
type MessengerAppearance = Pick<MessengerConfig, 'accentColor' | 'attachments' | 'availability' | 'awayMessage' | 'greeting' | 'launcherOffsetX' | 'launcherOffsetY' | 'launcherPosition' | 'help' | 'poweredBy' | 'starterPrompts' | 'team' | 'tickets'> & AppearanceSettings;
|
|
204
|
+
type MessengerAppearance = Pick<MessengerConfig, 'accentColor' | 'accentInk' | 'accentInkDark' | 'attachments' | 'availability' | 'awayMessage' | 'greeting' | 'launcherOffsetX' | 'launcherOffsetY' | 'launcherPosition' | 'help' | 'onAccent' | 'poweredBy' | 'starterPrompts' | 'team' | 'tickets'> & AppearanceSettings;
|
|
202
205
|
declare const DEFAULT_APPEARANCE: MessengerAppearance;
|
|
203
206
|
interface ChatSource {
|
|
204
207
|
avatarUrl(url: string): string;
|