arcy.js 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{arcy.chat.3968644db103.js → arcy.chat.39921845e233.js} +34 -34
- package/dist/arcy.legacy.7037dec7a67f.js +568 -0
- package/dist/arcy.loader.js +1 -1
- package/dist/arcy.modern.0ffea3108a8d.js +568 -0
- package/dist/{chat-BK57WIAA.js → chat-IU4IJMGO.js} +3 -10
- package/dist/{chunk-6HBSGVRN.js → chunk-DW3GUQ6J.js} +16 -1
- package/dist/index.cjs +69 -46
- package/dist/index.js +30 -22
- package/package.json +1 -1
- package/dist/arcy.legacy.b4005932a6cc.js +0 -568
- package/dist/arcy.modern.a51b9a32dd28.js +0 -568
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(exports){'use strict';/* arcy.js — https://arcyai.com */
|
|
2
|
-
var
|
|
2
|
+
var _t="__arcyChat";var St=["image/png","image/jpeg","image/webp"],Lt="--_arcy-font-key",It="arcy-chat-policy",Rt="arcy-bar-tray",Mt={historyTitle:"Recent chats",historyEmpty:"No conversations yet.",newChat:"New chat",flowsTitle:"What I can do",flowsEmpty:"Nothing to run yet.",collapse:"Collapse",back:"Back",closeSheet:"Close",settingsTitle:"Settings",dockChat:"Dock to the corner",dockChatHint:"Shrink ARCY to a button in the bottom-right corner.",language:"Language",openChat:"Open chat",moveBar:"Move the chat bar",send:"Send",flowRunning:"Running",flowStep:"Step {step} of {total}",flowStop:"Stop",flowFailed:"Sorry, I could not finish that for you this time. You can ask me here and I will help you do it.",attachMenu:"Add",attachImage:"Attach an image",removeImage:"Remove image",imageTooLarge:"That image is too large. Each image must be under 5 MB.",imageWrongType:"That file type is not supported. Use PNG, JPEG or WEBP.",imageTooMany:"You can attach up to 3 images.",imageFailed:"That image could not be uploaded. Please try again.",likeAnswer:"Good answer",dislikeAnswer:"Bad answer",answering:"Answering",aiDisclaimer:"{app} is AI and can make mistakes",consentNotice:"Your messages are processed to answer your question.",consentWithPolicy:"{policy}",disclaimerJoin:" \xB7 ",privacyPolicy:"Privacy Policy",poweredBy:"Powered by ARCY",genericError:"Something went wrong. Please try again.",userCapReached:"You've reached today's limit for questions. Please try again tomorrow.",imageConversation:"Image",searchedSourcesLabel:"Searched {count} sources",sourcesLabel:"Sources:",flowOfferHint:"You can do this in one click with the Quick Flow below.",fillConfirm:"Confirm",fillYes:"Yes",fillNo:"No",fillRequired:"This field needs an answer.",fillInvalidNumber:"Please enter a number.",fillNumberTooSmall:"Please enter {min} or more.",fillNumberTooLarge:"Please enter {max} or less.",fillInvalidEmail:"Please enter a valid email address.",fillInvalidUrl:"Please enter a valid link.",fillInvalidDate:"Please enter a valid date.",fillInvalidTime:"Please enter a valid time.",fillDateTooEarly:"Please pick {min} or later.",fillDateTooLate:"Please pick {max} or earlier.",fillTooLong:"Please keep it under {max} characters.",fillInvalidOption:"Please pick one of the options.",fillInvalid:"That does not look right. Please try again."};function Ye(e){let t=e.dataTransfer;if(!t)return false;let n=t.types;if(!n)return false;for(let r=0;r<n.length;r+=1)if(n[r]==="Files")return true;return false}function Ft(e){let t=e.dataTransfer;return Array.from(t?.files??[])}var Pt=`
|
|
3
3
|
[data-tip] {
|
|
4
4
|
position: relative;
|
|
5
5
|
}
|
|
@@ -64,11 +64,11 @@ var Tt="__arcyChat";var _t=["image/png","image/jpeg","image/webp"],St="--_arcy-f
|
|
|
64
64
|
transition: none;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
`;function
|
|
68
|
-
${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAttribute(
|
|
67
|
+
`;function Nt(e){typeof console<"u"&&console.warn&&console.warn(`[arcy] ${e}`);}function Yn(e){try{let n=e.currentScript?.nonce;if(typeof n=="string"&&n.length>0)return n;let r=e.getElementsByTagName("script");for(let o=0;o<r.length;o++){let i=r[o].nonce;if(typeof i=="string"&&i.length>0)return i}return null}catch{return null}}var Kn=typeof document<"u"?Yn(document):null;function Xn(){return Kn}function Le(e){let t=Xn();if(t)try{e.nonce=t,e.setAttribute("nonce",t);}catch{}}var $t="data-arcy-style";function Ke(e,t){if(!e.isolated)return false;try{let n=e.root.querySelector(`[${$t}]`);if(n)return n.textContent=`${n.textContent??""}
|
|
68
|
+
${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAttribute($t,""),r.textContent=t,e.root.appendChild(r),!0}catch(n){return Nt(`The widget could not apply its styles. ${String(n)}`),false}}var Qn=/^(#{1,3})\s+(.*)$/,Jn=/^[-*]\s+(.*)$/,Zn=/^\d+\.\s+(.*)$/;var Ot=/`([^`]+)`|\*\*(.+?)\*\*|\*(.+?)\*|\[([^\]]+)\]\(([^)]+)\)/g;function er(e){return /^https?:\/\//i.test(e)}function Ie(e,t,n){let r=0;Ot.lastIndex=0;let o;for(;o=Ot.exec(n);){o.index>r&&t.appendChild(e.createTextNode(n.slice(r,o.index)));let[i,s,h,C,g,c]=o;if(s!==void 0){let l=e.createElement("code");l.textContent=s,t.appendChild(l);}else if(h!==void 0){let l=e.createElement("strong");l.textContent=h,t.appendChild(l);}else if(C!==void 0){let l=e.createElement("em");l.textContent=C,t.appendChild(l);}else if(g!==void 0&&c!==void 0)if(er(c)){let l=e.createElement("a");l.setAttribute("href",c),l.setAttribute("target","_blank"),l.setAttribute("rel","noopener noreferrer"),l.textContent=g,t.appendChild(l);}else t.appendChild(e.createTextNode(g));r=o.index+i.length;}r<n.length&&t.appendChild(e.createTextNode(n.slice(r)));}function tr(e){let t=[],n=false;for(let r of e){if(!r.includes("```")){t.push(r);continue}r.split("```").forEach((i,s)=>{s>0&&(t.push("```"),n=!n),!(n&&s>0&&/^\s*[A-Za-z0-9+#-]*\s*$/.test(i))&&i!==""&&t.push(i);});}return t}function Dt(e,t,n){try{for(;t.firstChild;)t.removeChild(t.firstChild);let r=tr(n.split(`
|
|
69
69
|
`)),o=[],i=null,s=null,h=()=>{if(o.length===0)return;let c=e.createElement("p");Ie(e,c,o.join(" ")),t.appendChild(c),o=[];},C=()=>{i=null;},g=()=>{if(s===null)return;let c=e.createElement("pre"),l=e.createElement("code");for(;s.length>0&&s[0].trim()==="";)s.shift();for(;s.length>0&&s[s.length-1].trim()==="";)s.pop();l.textContent=s.join(`
|
|
70
|
-
`),c.appendChild(l),t.appendChild(c),s=null;};for(let c of r){if(c.trim()==="```"){s===null?(h(),C(),s=[]):g();continue}if(s!==null){s.push(c);continue}let l=c.trim();if(l===""){h(),C();continue}let v=Qn.exec(l);if(v){h(),C();let w=Math.max(2,v[1].length),m=e.createElement(`h${w}`);Ie(e,m,v[2]),t.appendChild(m);continue}let d=Jn.exec(l);if(d){h(),(!i||i.kind!=="ul")&&(i={kind:"ul",el:e.createElement("ul")},t.appendChild(i.el));let w=e.createElement("li");Ie(e,w,d[1]),i.el.appendChild(w);continue}let u=Zn.exec(l);if(u){h(),(!i||i.kind!=="ol")&&(i={kind:"ol",el:e.createElement("ol")},t.appendChild(i.el));let w=e.createElement("li");Ie(e,w,u[1]),i.el.appendChild(w);continue}C(),o.push(l);}g(),h();}catch{}}var
|
|
71
|
-
.${
|
|
70
|
+
`),c.appendChild(l),t.appendChild(c),s=null;};for(let c of r){if(c.trim()==="```"){s===null?(h(),C(),s=[]):g();continue}if(s!==null){s.push(c);continue}let l=c.trim();if(l===""){h(),C();continue}let v=Qn.exec(l);if(v){h(),C();let w=Math.max(2,v[1].length),m=e.createElement(`h${w}`);Ie(e,m,v[2]),t.appendChild(m);continue}let d=Jn.exec(l);if(d){h(),(!i||i.kind!=="ul")&&(i={kind:"ul",el:e.createElement("ul")},t.appendChild(i.el));let w=e.createElement("li");Ie(e,w,d[1]),i.el.appendChild(w);continue}let u=Zn.exec(l);if(u){h(),(!i||i.kind!=="ol")&&(i={kind:"ol",el:e.createElement("ol")},t.appendChild(i.el));let w=e.createElement("li");Ie(e,w,u[1]),i.el.appendChild(w);continue}C(),o.push(l);}g(),h();}catch{}}var Ht="arcy-flow-offer",Ut="arcy-flow-offer-hint",ae="arcy-flow-offer-button",zt="arcy-flow-offer-icon",Bt="http://www.w3.org/2000/svg",nr="M13 3L5 14h6l-1 7 8-11h-6l1-7z";function rr(e){let t=e.createElementNS(Bt,"svg");t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("aria-hidden","true"),t.setAttribute("width","15"),t.setAttribute("height","15"),t.setAttribute("class",zt);let n=e.createElementNS(Bt,"path");return n.setAttribute("d",nr),n.setAttribute("fill","none"),n.setAttribute("stroke","currentColor"),n.setAttribute("stroke-width","2"),n.setAttribute("stroke-linecap","round"),n.setAttribute("stroke-linejoin","round"),t.appendChild(n),t}var Vt=`
|
|
71
|
+
.${Ht} {
|
|
72
72
|
display: flex;
|
|
73
73
|
flex-direction: column;
|
|
74
74
|
align-items: flex-start;
|
|
@@ -76,7 +76,7 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
76
76
|
margin-top: 10px;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
.${
|
|
79
|
+
.${Ut} {
|
|
80
80
|
font-size: 13px;
|
|
81
81
|
line-height: 1.4;
|
|
82
82
|
}
|
|
@@ -104,7 +104,7 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
104
104
|
transition: background 120ms ease;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
.${
|
|
107
|
+
.${zt} {
|
|
108
108
|
flex-shrink: 0;
|
|
109
109
|
}
|
|
110
110
|
|
|
@@ -126,8 +126,8 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
126
126
|
transition: none;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
`;function
|
|
130
|
-
.${
|
|
129
|
+
`;function Wt(e,t,n,r){if(t.length===0)return null;let o=e.createElement("div");if(o.className=Ht,n){let i=e.createElement("div");i.className=Ut,i.textContent=n,o.appendChild(i);}for(let i of t.slice(0,1)){let s=e.createElement("button");s.type="button",s.className=ae,s.appendChild(rr(e));let h=e.createElement("span");h.textContent=i.publicName??"Start",s.appendChild(h),s.addEventListener("click",()=>{s.disabled=true;try{r(i.flowCvid);}catch{}}),o.appendChild(s);}return o}var Gt="arcy-chat-list",M="arcy-chat-msg",Yt="arcy-chat-msg-images",qe="arcy-chat-msg-thumbs",Kt="arcy-chat-msg-meta",qt="arcy-chat-msg-time",se="arcy-chat-rate",le="arcy-chat-msg-group",Xt="arcy-chat-citations",me="arcy-chat-citation-link",Qt="arcy-chat-citation-label",ce="arcy-chat-pending",or="M7 10v10H4V10zM7 10l4.5-7a2 2 0 0 1 3.4 2L13.5 9H19a2 2 0 0 1 2 2.3l-1 6A2 2 0 0 1 18 19H7",ir="M7 14V4H4v10zM7 14l4.5 7a2 2 0 0 0 3.4-2L13.5 15H19a2 2 0 0 0 2-2.3l-1-6A2 2 0 0 0 18 5H7",jt="http://www.w3.org/2000/svg";function ar(e,t){let n=e.createElementNS(jt,"svg");n.setAttribute("viewBox","0 0 24 24"),n.setAttribute("aria-hidden","true"),n.setAttribute("width","14"),n.setAttribute("height","14");let r=e.createElementNS(jt,"path");return r.setAttribute("d",t),r.setAttribute("fill","none"),r.setAttribute("stroke","currentColor"),r.setAttribute("stroke-width","2"),r.setAttribute("stroke-linecap","round"),r.setAttribute("stroke-linejoin","round"),n.appendChild(r),n}function sr(e){try{return e.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}catch{return ""}}var Jt=`
|
|
130
|
+
.${Gt} {
|
|
131
131
|
display: flex;
|
|
132
132
|
flex-direction: column;
|
|
133
133
|
gap: 8px;
|
|
@@ -226,7 +226,7 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
/* Above the bubble, as a sibling of it: see addMessage(). */
|
|
229
|
-
.${
|
|
229
|
+
.${Yt} {
|
|
230
230
|
display: block;
|
|
231
231
|
font-size: 11px;
|
|
232
232
|
opacity: 0.75;
|
|
@@ -285,7 +285,7 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
285
285
|
align-self: auto;
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
-
.${
|
|
288
|
+
.${Kt} {
|
|
289
289
|
display: flex;
|
|
290
290
|
align-items: center;
|
|
291
291
|
gap: 2px;
|
|
@@ -293,7 +293,7 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
293
293
|
min-height: 20px;
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
-
.${
|
|
296
|
+
.${qt} {
|
|
297
297
|
font-size: 11px;
|
|
298
298
|
line-height: 1;
|
|
299
299
|
color: color-mix(in srgb, var(--_arcy-main-text, #101828) 45%, transparent);
|
|
@@ -343,7 +343,7 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
343
343
|
|
|
344
344
|
/* \u2500\u2500 Citations (D1023, ADR 0129) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
345
345
|
|
|
346
|
-
.${
|
|
346
|
+
.${Xt} {
|
|
347
347
|
display: flex;
|
|
348
348
|
flex-wrap: wrap;
|
|
349
349
|
gap: 6px;
|
|
@@ -352,7 +352,7 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
352
352
|
color: color-mix(in srgb, var(--_arcy-main-text, #101828) 55%, transparent);
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
-
.${
|
|
355
|
+
.${Qt} {
|
|
356
356
|
font-weight: 600;
|
|
357
357
|
}
|
|
358
358
|
|
|
@@ -433,7 +433,7 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
433
433
|
opacity: 0.55;
|
|
434
434
|
}
|
|
435
435
|
}
|
|
436
|
-
`;function
|
|
436
|
+
`;function Zt(e,t,n={}){let r=t.createElement("div");r.className=Gt,e.appendChild(r);let o=false,i=[];function s(){for(;i.length>0;){let u=i.pop();if(u)try{URL.revokeObjectURL(u);}catch{}}}function h(){try{e.scrollTop=e.scrollHeight;}catch{}}let C=0,g=null;function c(u){if(!o)try{if(!u){g?.remove(),g=null;return}if(g)return;let w=t.createElement("div");w.className=ce,w.setAttribute("role","status"),w.setAttribute("aria-live","polite"),w.setAttribute("aria-label",n.answeringLabel?.()??"Answering");for(let m=0;m<3;m+=1)w.appendChild(t.createElement("span"));r.appendChild(w),g=w,h();}catch{}}function l(u,w,m){let x=n.labels;if(!x)return;let A=m,E=(N,U,$)=>{let y=t.createElement("button");return y.type="button",y.className=se,y.setAttribute("aria-label",U),y.setAttribute("data-tip",U),y.setAttribute("aria-pressed",m===N?"true":"false"),y.appendChild(ar(t,$)),y.addEventListener("click",()=>{try{A=A===N?null:N,L.setAttribute("aria-pressed",A==="up"?"true":"false"),H.setAttribute("aria-pressed",A==="down"?"true":"false"),n.onFeedback?.(A,w);}catch{}}),y},L=E("up",x.likeAnswer,or),H=E("down",x.dislikeAnswer,ir);u.appendChild(L),u.appendChild(H);}function v(u,w){let m=n.searchedSourcesLabel;if(!m||w.length===0)return;let x=t.createElement("div");if(x.className=Xt,n.sourcesLabel){let E=t.createElement("span");E.className=Qt,E.textContent=n.sourcesLabel,x.appendChild(E);}let A=0;for(let E of w)if(E.sourceUrl){let L=t.createElement("a");L.className=me,L.setAttribute("href",E.sourceUrl),L.setAttribute("target","_blank"),L.setAttribute("rel","noopener noreferrer"),L.textContent=E.title,x.appendChild(L);}else A+=1;if(A>0){let E=t.createElement("span");E.textContent=m.replace("{count}",String(A)),x.appendChild(E);}u.appendChild(x);}function d(u,w,m={}){if(!o)try{let{images:x=0,imageUrls:A=[],at:E,messageId:L=null,feedback:H=null,citedSources:N=[],flowOffers:U=[]}=m,$=t.createElement("div");$.className=le,$.setAttribute("data-role",u);let y=t.createElement("div");y.className=M,y.setAttribute("data-role",u),u==="assistant"?Dt(t,y,w):y.textContent=w;let k=null;if(A.length>0){k=t.createElement("div"),k.className=qe;for(let T of A){let I=t.createElement("img");I.src=T,I.alt="",k.appendChild(I),i.push(T);}}else x>0&&(k=t.createElement("div"),k.className=Yt,k.textContent=x===1?"1 image":`${x} images`);if(k&&$.appendChild(k),u==="assistant"&&U.length>0&&n.onStartFlow){let T=n.onStartFlow.bind(n),I=Wt(t,U,n.flowOfferHint?.(),T);I&&y.appendChild(I);}if((w!==""||!k)&&$.appendChild(y),u==="assistant"&&N.length>0&&v($,N),u!=="system"){let T=t.createElement("div");T.className=Kt;let I=t.createElement("span");I.className=qt,I.textContent=sr(E??n.now?.()??new Date),T.appendChild(I),u==="assistant"&&l(T,L,H),$.appendChild(T);}r.insertBefore($,g),C+=1,h();}catch{}}return {addMessage:d,setPending:c,isEmpty:()=>C===0,scrollToEnd:h,clear(){if(!o)try{for(;r.firstChild;)r.removeChild(r.firstChild);s(),C=0,g=null;}catch{}},destroy(){if(!o){o=true;try{s(),r.remove();}catch{}}}}}var be="arcy-drawer",Re="arcy-drawer-scrim",tn="arcy-drawer-header",Xe="arcy-drawer-back",Qe="arcy-drawer-close",nn="arcy-drawer-title",rn="arcy-drawer-list",Me="arcy-drawer-item",on="arcy-drawer-item-title",an="arcy-drawer-item-sub",ye="arcy-drawer-item-tip",sn="arcy-drawer-item-icon",ln="arcy-drawer-item-text",cn="arcy-drawer-empty",Je="arcy-drawer-action",Ze="arcy-drawer-footer",dn=`
|
|
437
437
|
/* A sheet over PART of the panel, sliding in from the left (D899). It used
|
|
438
438
|
to be inset:0 and appear instantly, so opening Recent chats replaced the
|
|
439
439
|
whole surface with no sense of where the conversation went or how to get
|
|
@@ -506,7 +506,7 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
508
|
|
|
509
|
-
.${
|
|
509
|
+
.${tn} {
|
|
510
510
|
display: flex;
|
|
511
511
|
align-items: center;
|
|
512
512
|
gap: 8px;
|
|
@@ -534,7 +534,7 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
534
534
|
background: color-mix(in srgb, var(--_arcy-main-text, #101828) 8%, transparent);
|
|
535
535
|
}
|
|
536
536
|
|
|
537
|
-
.${
|
|
537
|
+
.${nn} {
|
|
538
538
|
font-weight: 600;
|
|
539
539
|
font-size: 14px;
|
|
540
540
|
min-width: 0;
|
|
@@ -544,7 +544,7 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
544
544
|
white-space: nowrap;
|
|
545
545
|
}
|
|
546
546
|
|
|
547
|
-
.${
|
|
547
|
+
.${rn} {
|
|
548
548
|
flex: 1 1 auto;
|
|
549
549
|
min-height: 0;
|
|
550
550
|
overflow: auto;
|
|
@@ -589,7 +589,7 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
589
589
|
|
|
590
590
|
/* Dimmer than the title it sits beside: it labels the kind of row, and a
|
|
591
591
|
mark at full strength competes with the name a visitor is reading. */
|
|
592
|
-
.${
|
|
592
|
+
.${sn} {
|
|
593
593
|
flex: 0 0 auto;
|
|
594
594
|
display: flex;
|
|
595
595
|
align-items: center;
|
|
@@ -599,7 +599,7 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
599
599
|
/* The min-width: 0 is what keeps the ellipsis working: without it a flex
|
|
600
600
|
item refuses to shrink below its content, and a long flow name pushes the
|
|
601
601
|
row wider than the sheet instead of truncating. */
|
|
602
|
-
.${
|
|
602
|
+
.${ln} {
|
|
603
603
|
display: flex;
|
|
604
604
|
flex-direction: column;
|
|
605
605
|
gap: 2px;
|
|
@@ -607,14 +607,14 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
607
607
|
flex: 1 1 auto;
|
|
608
608
|
}
|
|
609
609
|
|
|
610
|
-
.${
|
|
610
|
+
.${on} {
|
|
611
611
|
font-size: 13px;
|
|
612
612
|
overflow: hidden;
|
|
613
613
|
text-overflow: ellipsis;
|
|
614
614
|
white-space: nowrap;
|
|
615
615
|
}
|
|
616
616
|
|
|
617
|
-
.${
|
|
617
|
+
.${an} {
|
|
618
618
|
font-size: 11.5px;
|
|
619
619
|
color: color-mix(in srgb, var(--_arcy-main-text, #101828) 55%, transparent);
|
|
620
620
|
overflow: hidden;
|
|
@@ -679,7 +679,7 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
679
679
|
}
|
|
680
680
|
}
|
|
681
681
|
|
|
682
|
-
.${
|
|
682
|
+
.${cn} {
|
|
683
683
|
flex: 1 1 auto;
|
|
684
684
|
display: flex;
|
|
685
685
|
flex-direction: column;
|
|
@@ -720,7 +720,7 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
720
720
|
.${Ze} .${Je} {
|
|
721
721
|
width: 100%;
|
|
722
722
|
}
|
|
723
|
-
`,
|
|
723
|
+
`,en="http://www.w3.org/2000/svg",ge=8,lr=240,cr=120;function et(e,t,n,r=2){let o=e.createElementNS(en,"svg");o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("width",String(n)),o.setAttribute("height",String(n)),o.setAttribute("aria-hidden","true");for(let i of t){let s=e.createElementNS(en,"path");s.setAttribute("d",i),s.setAttribute("fill","none"),s.setAttribute("stroke","currentColor"),s.setAttribute("stroke-width",String(r)),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),o.appendChild(s);}return o}function dr(e,t){return et(e,[t==="right"?"M9 5l7 7-7 7":"M15 5l-7 7 7 7"],16)}function pr(e){return et(e,["M18 6L6 18","M6 6l12 12"],16)}function ur(e){return et(e,["M12 5v14M5 12h14"],14,2.5)}function Fe(e,t,n){let r=n.emptyText??"",o=n.actionLabel??null,i=[],s=false,h=n.side??"left",C=n.subtitleTips!==false,g=t.createElement("div");g.className=be,g.setAttribute("role","group"),g.setAttribute("data-side",h);let c=t.createElement("div");c.className=tn;let l=t.createElement("button");l.type="button",l.className=Xe,l.setAttribute("aria-label",n.backLabel),l.setAttribute("data-tip",n.backLabel),l.setAttribute("data-tip-placement","below"),l.setAttribute("data-tip-align","start"),l.appendChild(dr(t,h));let v=t.createElement("span");v.className=nn,v.textContent=n.title;let d=t.createElement("button");d.type="button",d.className=Qe,d.setAttribute("aria-label",n.closeLabel),d.setAttribute("data-tip",n.closeLabel),d.setAttribute("data-tip-placement","below"),d.setAttribute("data-tip-align","end"),d.appendChild(pr(t)),c.appendChild(l),c.appendChild(v),c.appendChild(d);let u=t.createElement("div");u.className=rn,g.appendChild(c),g.appendChild(u);let w=t.createElement("button");w.type="button",w.className=Re,w.setAttribute("aria-hidden","true"),w.tabIndex=-1,e.appendChild(w),e.appendChild(g);let m=t.createElement("div");m.className=ye,m.setAttribute("aria-hidden","true"),g.appendChild(m);function x(){m.removeAttribute("data-open");}function A(y,k){try{let T=g.getBoundingClientRect(),I=e.getBoundingClientRect(),q=y.getBoundingClientRect();if(T.width===0||I.width===0)return;let W=(h==="right"?T.left-I.left:I.right-T.right)-ge*2;if(W<cr){x();return}m.textContent=k,m.style.maxWidth=`${Math.min(lr,W)}px`;let j=`${T.width+ge}px`;m.style.left=h==="right"?"auto":j,m.style.right=h==="right"?j:"auto",m.style.top="0px";let pe=m.offsetHeight,P=q.top-T.top,z=Math.max(ge,T.height-pe-ge);m.style.top=`${Math.min(Math.max(P,ge),z)}px`,m.setAttribute("data-open","");}catch{x();}}u.addEventListener("scroll",x);let E=()=>{try{n.onBack();}catch{}};l.addEventListener("click",E),d.addEventListener("click",E),w.addEventListener("click",E);let L=null;function H(){L?.remove(),L=null;}function N(){if(!s){for(x();u.firstChild;)u.removeChild(u.firstChild);if(H(),i.length===0){let y=t.createElement("div");y.className=cn;let k=t.createElement("span");k.textContent=r,y.appendChild(k),o&&y.appendChild(U(false)),u.appendChild(y);return}for(let y of i){let k=t.createElement("button");k.type="button",k.className=Me,y.active&&(k.setAttribute("data-active",""),k.setAttribute("aria-current","true"));let T=y.icon??n.itemIcon;if(T)try{let W=T(t);if(W){let j=t.createElement("span");j.className=sn,j.appendChild(W),k.appendChild(j);}}catch{}let I=t.createElement("span");I.className=ln;let q=t.createElement("span");if(q.className=on,q.textContent=y.title,I.appendChild(q),y.subtitle){let W=t.createElement("span");W.className=an,W.textContent=y.subtitle,I.appendChild(W);let j=y.subtitle;C&&(k.addEventListener("mouseenter",()=>A(k,j)),k.addEventListener("focus",()=>A(k,j)),k.addEventListener("mouseleave",x),k.addEventListener("blur",x));}k.appendChild(I),k.addEventListener("click",()=>{try{n.onSelect(y.id);}catch{}}),u.appendChild(k);}o&&(L=t.createElement("div"),L.className=Ze,L.appendChild(U(true)),g.appendChild(L));}}function U(y){let k=t.createElement("button");return k.type="button",k.className=Je,y&&k.appendChild(ur(t)),k.appendChild(t.createTextNode(o??"")),k.addEventListener("click",()=>{try{n.onAction?.();}catch{}}),k}N();function $(y){try{for(let k of Array.from(e.children))k===g||k===w||(y?k.setAttribute("inert",""):k.removeAttribute("inert"));}catch{}}return {open(){if(!s){g.setAttribute("data-open",""),w.setAttribute("data-open",""),$(true);try{l.focus();}catch{}}},close(){s||(x(),g.removeAttribute("data-open"),w.removeAttribute("data-open"),$(false));},isOpen:()=>g.hasAttribute("data-open"),setItems(y){i=y,N();},setTitle(y){v.textContent=y;},setTexts(y){y.emptyText!==void 0&&(r=y.emptyText),y.actionLabel!==void 0&&(o=y.actionLabel),y.backLabel!==void 0&&(l.setAttribute("aria-label",y.backLabel),l.setAttribute("data-tip",y.backLabel)),y.closeLabel!==void 0&&(d.setAttribute("aria-label",y.closeLabel),d.setAttribute("data-tip",y.closeLabel)),N();},destroy(){if(!s){s=true;try{$(!1),u.removeEventListener("scroll",x),l.removeEventListener("click",E),d.removeEventListener("click",E),w.removeEventListener("click",E),m.remove(),g.remove(),w.remove();}catch{}}}}}var Pe=e=>typeof e=="number"&&Number.isFinite(e)&&e>0?e:0;var fr=560,hr=640;function Ne(e,t){let n=Pe(t.width);if(!n)return fr;if(n<640)return Math.max(0,n-24);let r=Math.round(e/100*n);return Math.min(r,n-32)}function pn(e,t,n){let r=Pe(t);if(!r)return hr;let o=Math.round(e/100*r),i=r-n-16;return Math.max(0,Math.min(o,i))}function we(e){return e.x===0&&e.y===0?"none":`translate(${e.x}px, ${e.y}px)`}function $e(e,t,n){let r=Pe(n);if(!r)return e;let o=Math.max(0,(r-Pe(t))/2);return Math.min(o,Math.max(-o,e))}var S="arcy-fill-card",un=`
|
|
724
724
|
.${S} {
|
|
725
725
|
position: absolute;
|
|
726
726
|
display: flex;
|
|
@@ -837,8 +837,8 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
837
837
|
transition: none;
|
|
838
838
|
}
|
|
839
839
|
}
|
|
840
|
-
`,mr={required:"fillRequired",invalid_number:"fillInvalidNumber",number_too_small:"fillNumberTooSmall",number_too_large:"fillNumberTooLarge",invalid_email:"fillInvalidEmail",invalid_url:"fillInvalidUrl",invalid_date:"fillInvalidDate",invalid_time:"fillInvalidTime",date_too_early:"fillDateTooEarly",date_too_late:"fillDateTooLate",too_long:"fillTooLong",invalid_option:"fillInvalidOption",invalid:"fillInvalid"},gr={date:"date",time:"time",datetime:"datetime-local",month:"month",week:"week"};function un(e,t){let n=e.host.ownerDocument,r=n.createElement("div");r.className=S,r.setAttribute("role","dialog");let o=n.createElement("div");o.className=`${S}-question`;let i=n.createElement("div");i.className=`${S}-error`,i.setAttribute("role","alert"),i.style.setProperty("display","none");let s=n.createElement("div");s.className=`${S}-controls`,r.appendChild(o),r.appendChild(i),r.appendChild(s),e.root.appendChild(r);let h=null;function C(l){let d=t()[mr[l]];return (typeof d=="string"?d:"").replace("{min}",h?.min??"").replace("{max}",h?.max??String(h?.maxLength??""))}function g(){let l;try{l=e.bar.getMetrics();}catch{return}let v=l.bottomOffset+l.keyboardOffset+l.height+8,d=r.style;if(d.setProperty("bottom",`${v}px`),d.setProperty("left","50%"),d.setProperty("translate","-50%"),l.isMobile){d.setProperty("width",`calc(100% - ${24}px)`),d.setProperty("max-width","none"),d.setProperty("transform","none");return}let u=Ne(l.widthPercent,{width:l.viewportWidth,height:l.viewportHeight});d.setProperty("width",`${u}px`),d.setProperty("max-width",`calc(100vw - ${32}px)`),d.setProperty("transform",we({x:$e(l.offset.x,u,l.viewportWidth),y:l.offset.y}));}function c(l,v){s.textContent="";let d=t(),u=(m,x)=>{let A=n.createElement("button");A.type="button",A.className=`${S}-pill`,A.textContent=m,A.addEventListener("click",()=>v.onAnswer(x)),s.appendChild(A);},w=(m,x)=>{let A=n.createElement("button");A.type="button",A.className=`${S}-confirm`,A.textContent=d.fillConfirm,A.addEventListener("click",()=>v.onAnswer(x())),m.addEventListener("keydown",E=>{E.key==="Enter"&&(E.preventDefault(),v.onAnswer(x()));}),s.appendChild(m),s.appendChild(A);};switch(l.kind){case "select":case "radio":{for(let m of l.options??[])u(m.label,m.value);return}case "checkbox":{u(d.fillYes,"true"),u(d.fillNo,"false");return}case "range":{let m=n.createElement("input");m.type="range",m.className=`${S}-range`,l.min!==null&&(m.min=l.min),l.max!==null&&(m.max=l.max),l.step!==null&&(m.step=l.step);let x=n.createElement("span");x.className=`${S}-range-value`,x.textContent=m.value,m.addEventListener("input",()=>{x.textContent=m.value;});let A=n.createElement("button");A.type="button",A.className=`${S}-confirm`,A.textContent=d.fillConfirm,A.addEventListener("click",()=>v.onAnswer(m.value)),s.appendChild(m),s.appendChild(x),s.appendChild(A);return}case "password":{let m=n.createElement("input");m.type="password",m.className=`${S}-input`,m.autocomplete="off",w(m,()=>m.value);try{m.focus();}catch{}return}default:{let m=gr[l.kind];if(!m)return;let x=n.createElement("input");x.type=m,x.className=`${S}-input`,l.min!==null&&(x.min=l.min),l.max!==null&&(x.max=l.max),l.step!==null&&(x.step=l.step),w(x,()=>x.value);}}}return {show(l,v){h=l,o.textContent=l.question,c(l,v),this.setError(l.errorCode),g(),r.setAttribute("data-open","");},setError(l){l===null?(i.textContent="",i.style.setProperty("display","none")):(i.textContent=C(l),i.style.setProperty("display","block")),r.hasAttribute("data-open")&&g();},hide(){h=null,r.removeAttribute("data-open"),s.textContent="",i.textContent="",i.style.setProperty("display","none");},reposition(){r.hasAttribute("data-open")&&g();},isVisible:()=>r.hasAttribute("data-open"),destroy(){try{r.remove();}catch{}}}}var br=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,yr=/^\d{4}-\d{2}-\d{2}$/,wr=/^([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/,vr=/^\d{4}-\d{2}-\d{2}T([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/,xr=/^\d{4}-\d{2}$/,Cr=/^\d{4}-W\d{2}$/,kr=/^\+?[\d\s().-]{3,}$/;function Ar(e){let t=Date.parse(e);return Number.isFinite(t)}function Er(e,t){if(t.min!==null){let n=Number(t.min);if(Number.isFinite(n)&&e<n)return "number_too_small"}if(t.max!==null){let n=Number(t.max);if(Number.isFinite(n)&&e>n)return "number_too_large"}return null}function rt(e){return /^\d:/.test(e)?`0${e}`:e}function ve(e,t){return t.min!==null&&t.min.length>0&&e<t.min?"date_too_early":t.max!==null&&t.max.length>0&&e>t.max?"date_too_late":null}function fn(e,t){let n=t.kind==="password"?e:e.trim();if(n.length===0)return t.required?"required":null;if(t.maxLength!==null&&n.length>t.maxLength)return "too_long";switch(t.kind){case "number":case "range":{let r=Number(n);return Number.isFinite(r)?Er(r,t):"invalid_number"}case "email":return br.test(n)?null:"invalid_email";case "url":try{let r=new URL(n);return r.protocol==="http:"||r.protocol==="https:"?null:"invalid_url"}catch{return "invalid_url"}case "tel":return kr.test(n)?null:"invalid";case "date":return !yr.test(n)||!Ar(n)?"invalid_date":ve(n,t);case "datetime":return vr.test(n)?ve(n,t):"invalid_date";case "month":return xr.test(n)?ve(n,t):"invalid_date";case "week":return Cr.test(n)?ve(n,t):"invalid_date";case "time":return wr.test(n)?ve(rt(n),{...t,min:t.min!==null?rt(t.min):null,max:t.max!==null?rt(t.max):null}):"invalid_time";case "select":case "radio":return (t.options??[]).some(o=>o.value===n)?null:"invalid_option";case "checkbox":return n==="true"||n==="false"?null:"invalid_option";default:{if(t.pattern)try{if(!new RegExp(`^(?:${t.pattern})$`).test(n))return "invalid"}catch{}return null}}}function hn(e,t){if(!t||t.length===0)return e;let n=e.trim();if(t.some(i=>i.value===n))return n;let r=n.toLowerCase(),o=t.find(i=>i.label.trim().toLowerCase()===r);return o?o.value:e}var Tr="https://api.arcyai.com",_r="/api/v1/sdk/flows/catalog";function Sr(e){return e!==void 0?e:typeof fetch<"u"?fetch.bind(globalThis):null}function Lr(e,t,n,r){return new Promise(o=>{let i=false,s=h=>{i||(i=true,o(h));};e.then(s,()=>s(r));try{n(()=>s(r),t);}catch{}})}function Ir(e){if(!e||typeof e!="object")return false;let t=e;return typeof t.cvid=="string"&&(t.publicName===null||typeof t.publicName=="string")&&(t.summary===null||typeof t.summary=="string")&&(t.firstStepRoute===void 0||t.firstStepRoute===null||typeof t.firstStepRoute=="string")}function Rr(e){if(!e||typeof e!="object")return false;let t=e;return typeof t.cvid=="string"&&typeof t.publicName=="string"&&t.publicName.trim().length>0&&(t.summary===null||t.summary===void 0||typeof t.summary=="string")}function Mr(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e.flows;if(!Array.isArray(t))return null;let n=[];for(let i of t)Ir(i)&&n.push({...i,firstStepRoute:i.firstStepRoute??null});let r=e.starterFlows,o=Array.isArray(r)?r.filter(Rr).map(i=>({cvid:i.cvid,publicName:i.publicName,summary:i.summary??null})):[];return {flows:n,starterFlows:o}}function Fr(e){return {"Content-Type":"application/json",Authorization:`Bearer ${e}`}}async function mn(e){let{apiBase:t=Tr,sessionToken:n,sessionId:r,setTimeoutImpl:o=(C,g)=>setTimeout(C,g),timeoutMs:i=8e3}=e,s=Sr(e.fetchImpl);if(!s)return {ok:false,reason:"unusable"};let h=(async()=>{let C;try{C=await s(`${t}${_r}`,{method:"POST",headers:Fr(n),body:JSON.stringify(r?{sessionId:r}:{}),credentials:"omit"});}catch{return {ok:false,reason:"network"}}if(!C.ok)return {ok:false,reason:"rejected"};let g;try{g=await C.json();}catch{return {ok:false,reason:"unusable"}}let c=Mr(g);return c?{ok:true,...c}:{ok:false,reason:"unusable"}})();return Lr(h,i,o,{ok:false,reason:"network"})}function gn(e){let t=[];for(let n of e){let r=n.publicName?.trim()??"";r&&t.push({...n,publicName:r});}return t}var $="https://api.arcyai.com",Pr="/api/v1/sdk/agent/query";function Nr(e){return e!==void 0?e:typeof fetch<"u"?fetch.bind(globalThis):null}function $r(e,t,n,r){return new Promise(o=>{let i=false,s=h=>{i||(i=true,o(h));};e.then(s,()=>s(r));try{n(()=>s(r),t);}catch{}})}var Or=new Set(["credits_exhausted","lapsed","org_cap_exceeded","user_cap_exceeded","anon_org_cap_exceeded","anon_user_cap_exceeded"]);function Dr(e){return typeof e=="string"&&Or.has(e)}function Br(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;if(t.responseType!=="chat")return null;let n=t.chatResponse;if(!n||typeof n!="object"||Array.isArray(n))return null;let r=n;if(typeof r.message!="string")return null;let o=[];if(Array.isArray(r.flowsOffered))for(let s of r.flowsOffered){if(!s||typeof s!="object"||Array.isArray(s))continue;let h=s;typeof h.flowCvid=="string"&&(h.publicName!==null&&typeof h.publicName!="string"||o.push({flowCvid:h.flowCvid,publicName:h.publicName??null}));}let i=[];if(Array.isArray(r.citedSources))for(let s of r.citedSources){if(!s||typeof s!="object"||Array.isArray(s))continue;let h=s;typeof h.documentId!="string"||typeof h.title!="string"||h.sourceUrl!==null&&typeof h.sourceUrl!="string"||i.push({documentId:h.documentId,title:h.title,sourceUrl:h.sourceUrl??null});}return {ok:true,message:r.message,messageId:typeof r.messageId=="string"&&r.messageId.length>0?r.messageId:null,isFallback:r.isFallback===true,flowsOffered:o,citedSources:i}}function Hr(e){return {"Content-Type":"application/json",Authorization:`Bearer ${e}`}}async function bn(e){let{apiBase:t=$,publicKey:n,sessionId:r,sessionToken:o,query:i,route:s,conversationId:h,attachments:C=[],setTimeoutImpl:g=(d,u)=>setTimeout(d,u),timeoutMs:c=2e4}=e,l=Nr(e.fetchImpl);if(!l)return {ok:false,reason:"unusable"};let v=(async()=>{let d;try{d=await l(`${t}${Pr}`,{method:"POST",headers:Hr(o),body:JSON.stringify({publicKey:n,sessionId:r,query:i,route:s,conversationId:h,...C.length>0?{attachments:C}:{}}),credentials:"omit"});}catch{return {ok:false,reason:"network"}}if(d.status===402){let m;try{m=await d.json();}catch{return {ok:false,reason:"unusable"}}let x=m&&typeof m=="object"&&!Array.isArray(m)?m.reason:void 0;return Dr(x)?{ok:false,reason:"cap_denied",capReason:x}:{ok:false,reason:"unusable"}}if(!d.ok)return {ok:false,reason:"rejected"};let u;try{u=await d.json();}catch{return {ok:false,reason:"unusable"}}return Br(u)??{ok:false,reason:"unusable"}})();return $r(v,c,g,{ok:false,reason:"network"})}var wn='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';function V(e,t=wn){return {family:e,fallback:t,stack:`"${e}", ${t}`}}var vn={system:{stack:wn},serif:{stack:'Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif'},mono:{stack:'ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace'},humanist:{stack:'Seravek, "Gill Sans Nova", Ubuntu, Calibri, "DejaVu Sans", sans-serif'},rounded:{stack:'ui-rounded, "Hiragino Maru Gothic ProN", Quicksand, Comfortaa, "Arial Rounded MT Bold", Calibri, sans-serif'},inter:V("Inter"),roboto:V("Roboto"),"open-sans":V("Open Sans"),lato:V("Lato"),poppins:V("Poppins"),montserrat:V("Montserrat"),nunito:V("Nunito"),"source-sans-3":V("Source Sans 3"),"work-sans":V("Work Sans"),"dm-sans":V("DM Sans"),manrope:V("Manrope"),"playfair-display":V("Playfair Display","Georgia, serif"),"ibm-plex-sans":V("IBM Plex Sans")},Ur=[["latin","U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"],["latin-ext","U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF"]];var De="--_arcy-font",yn="data-arcy-font";function zr(e,t=$){let n=vn[e];return n?.family?Ur.map(([r,o])=>`@font-face{font-family:"${n.family}";font-style:normal;font-weight:400;font-display:swap;src:url("${t}/fonts/${e}-${r}.woff2") format("woff2");unicode-range:${o};}`).join(`
|
|
841
|
-
`):""}function ot(e,t,n=$){try{let r=e.style.getPropertyValue(St).trim(),o=r?vn[r]:void 0;if(!o){e.style.removeProperty(De);return}if(e.style.setProperty(De,o.stack),!o.family)return;let i=t.head||t.documentElement;if(!i||i.querySelector(`style[${yn}="${r}"]`))return;let s=t.createElement("style");Le(s),s.setAttribute(yn,r),s.textContent=zr(r,n),i.appendChild(s);}catch{}}var Vr="/api/v1/sdk/conversations",Wr=15e3,jr=20,xn=60;function Gr(e){return e!==void 0?e:typeof fetch<"u"?fetch.bind(globalThis):null}function Yr(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e.conversations;if(!Array.isArray(t))return null;let n=[];for(let r of t){if(n.length>=jr)break;if(!r||typeof r!="object"||Array.isArray(r))continue;let o=r;if(typeof o.id!="string"||o.id.length===0)continue;let i=o.lastMessageAt,s=typeof i=="number"&&Number.isFinite(i)?i:typeof i=="string"?Date.parse(i):NaN;n.push({id:o.id,firstMessage:typeof o.firstMessage=="string"&&o.firstMessage.length>0?o.firstMessage:null,hasImage:o.hasImage===true,lastMessageAt:Number.isFinite(s)?s:0});}return n}function Cn(e){if(!e)return "";try{return new Date(e).toLocaleDateString()}catch{return ""}}function Kr(e,t){let n=e.firstMessage?.trim()??"";if(n.length>0)return n.length>xn?`${n.slice(0,xn-1).trimEnd()}\u2026`:n;let r=Cn(e.lastMessageAt);return e.hasImage?r?`${t} ${r}`:t:r||t}function it(e,t,n){return e.map(r=>({id:r.id,title:Kr(r,t),subtitle:Cn(r.lastMessageAt),active:!!(n&&r.id===n)}))}async function kn(e){let{apiBase:t=$,sessionToken:n,visitorId:r,setTimeoutImpl:o=(C,g)=>setTimeout(C,g),timeoutMs:i=Wr}=e,s=Gr(e.fetchImpl);if(!s||!n||!r)return {ok:false};let h=(async()=>{let C;try{C=await s(`${t}${Vr}?visitorId=${encodeURIComponent(r)}`,{method:"GET",headers:{Authorization:`Bearer ${n}`},credentials:"omit"});}catch{return {ok:false}}if(!C.ok)return {ok:false};let g;try{g=await C.json();}catch{return {ok:false}}let c=Yr(g);return c?{ok:true,conversations:c}:{ok:false}})();return new Promise(C=>{let g=false,c=l=>{g||(g=true,C(l));};h.then(c,()=>c({ok:false}));try{o(()=>c({ok:!1}),i);}catch{}})}var qr="/api/v1/sdk/conversations/{conversationId}/messages",Xr=15e3,Qr=200;function Jr(e){return e!==void 0?e:typeof fetch<"u"?fetch.bind(globalThis):null}function Zr(e){return qr.replace("{conversationId}",encodeURIComponent(e))}function An(e){return e==="agent"?"assistant":"user"}function eo(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e.messages;if(!Array.isArray(t))return null;let n=[];for(let r of t){if(n.length>=Qr)break;if(!r||typeof r!="object"||Array.isArray(r))continue;let o=r;if(typeof o.id!="string"||o.id.length===0||o.role!=="user"&&o.role!=="agent"||typeof o.text!="string")continue;let i=o.occurredAt,s=typeof i=="number"&&Number.isFinite(i)?i:typeof i=="string"?Date.parse(i):NaN,h=typeof o.images=="number"&&Number.isFinite(o.images)?Math.max(0,Math.floor(o.images)):0;n.push({id:o.id,role:o.role,text:o.text,occurredAt:Number.isFinite(s)?s:0,images:h,feedback:o.feedback==="up"||o.feedback==="down"?o.feedback:null});}return n}async function En(e){let{apiBase:t=$,sessionToken:n,conversationId:r,visitorId:o,setTimeoutImpl:i=(g,c)=>setTimeout(g,c),timeoutMs:s=Xr}=e,h=Jr(e.fetchImpl);if(!h||!n||!r)return {ok:false};let C=(async()=>{let g;try{let v=o?`?visitorId=${encodeURIComponent(o)}`:"";g=await h(`${t}${Zr(r)}${v}`,{method:"GET",headers:{Authorization:`Bearer ${n}`},credentials:"omit"});}catch{return {ok:false}}if(!g.ok)return {ok:false};let c;try{c=await g.json();}catch{return {ok:false}}let l=eo(c);return l?{ok:true,messages:l}:{ok:false}})();return new Promise(g=>{let c=false,l=v=>{c||(c=true,g(v));};C.then(l,()=>l({ok:false}));try{i(()=>l({ok:!1}),s);}catch{}})}var to="/api/v1/sdk/conversations/{conversationId}/messages/{messageId}/feedback",no=1e4;function ro(e){return e!==void 0?e:typeof fetch<"u"?fetch.bind(globalThis):null}function oo(e,t){return to.replace("{conversationId}",encodeURIComponent(e)).replace("{messageId}",encodeURIComponent(t))}async function Tn(e){let{apiBase:t=$,sessionToken:n,conversationId:r,messageId:o,value:i,visitorId:s,setTimeoutImpl:h=(l,v)=>setTimeout(l,v),timeoutMs:C=no}=e,g=ro(e.fetchImpl);if(!g||!n||!r||!o)return {ok:false};let c=(async()=>{try{let l=s?`?visitorId=${encodeURIComponent(s)}`:"";return {ok:(await g(`${t}${oo(r,o)}${l}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({value:i}),credentials:"omit"})).ok}}catch{return {ok:false}}})();return new Promise(l=>{let v=false,d=u=>{v||(v=true,l(u));};c.then(d,()=>d({ok:false}));try{h(()=>d({ok:!1}),C);}catch{}})}var io="<svg width='476' height='139' viewBox='0 0 476 139' fill='none' xmlns='http://www.w3.org/2000/svg'><path d='M0 24.69C0 11.0541 11.0541 0 24.69 0H451.311C464.946 0 476 11.0537 476 24.6892V114.311C476 127.946 464.946 139 451.311 139H24.69C11.0541 139 0 127.946 0 114.31V24.69Z' fill='#12161A'/><path d='M132.047 84.6159L108.384 42.3014C101.224 29.4986 82.7988 29.502 75.6456 42.3116L52.0065 84.6362C43.8531 99.2299 63.7247 113.114 74.6251 100.436C83.7854 89.7891 100.271 89.7857 109.435 100.429C120.342 113.1 140.207 99.2096 132.047 84.6159Z' stroke='white' stroke-width='9.11833'/><path d='M232.67 100H221.885V85.398H183.969V100H173.183V70.2567C173.183 65.9148 173.93 61.9186 175.424 58.2681C176.917 54.6176 178.991 51.4787 181.646 48.8514C184.301 46.2242 187.44 44.1777 191.063 42.7119C194.685 41.2462 198.64 40.5133 202.927 40.5133H227.236C227.983 40.5133 228.688 40.6516 229.351 40.9282C230.015 41.2047 230.596 41.5919 231.094 42.0897C231.592 42.5875 231.979 43.1682 232.255 43.832C232.532 44.4957 232.67 45.2009 232.67 45.9476V100ZM183.969 74.6124H221.885V51.2989H202.927C202.595 51.2989 201.89 51.3542 200.811 51.4649C199.76 51.5478 198.53 51.7829 197.119 52.1701C195.736 52.5572 194.271 53.1518 192.722 53.9538C191.173 54.7558 189.749 55.8621 188.449 57.2725C187.149 58.6829 186.071 60.4528 185.214 62.5823C184.384 64.6841 183.969 67.2422 183.969 70.2567V74.6124ZM304.685 60.5082C304.685 62.9695 304.38 65.1681 303.772 67.104C303.164 69.0398 302.334 70.7545 301.283 72.2479C300.26 73.7136 299.071 74.9719 297.716 76.0228C296.36 77.0737 294.936 77.9449 293.443 78.6362C291.977 79.3 290.484 79.7839 288.963 80.0881C287.469 80.3924 286.059 80.5445 284.731 80.5445L307.257 100H290.58L268.097 80.5445H260.339V69.7589H284.731C286.086 69.6482 287.317 69.3717 288.423 68.9292C289.557 68.4591 290.525 67.8368 291.327 67.0625C292.157 66.2881 292.793 65.3617 293.235 64.2831C293.678 63.1769 293.899 61.9186 293.899 60.5082V53.7049C293.899 53.0965 293.816 52.6402 293.65 52.336C293.512 52.0041 293.318 51.7691 293.069 51.6308C292.848 51.4649 292.599 51.3681 292.323 51.3404C292.074 51.3128 291.839 51.2989 291.617 51.2989H256.025V100H245.239V45.9476C245.239 45.2009 245.378 44.4957 245.654 43.832C245.931 43.1682 246.304 42.5875 246.774 42.0897C247.272 41.5919 247.853 41.2047 248.517 40.9282C249.18 40.6516 249.899 40.5133 250.674 40.5133H291.617C294.024 40.5133 296.056 40.9558 297.716 41.8408C299.375 42.6981 300.716 43.7905 301.739 45.118C302.79 46.4178 303.537 47.8282 303.979 49.3492C304.45 50.8703 304.685 52.2945 304.685 53.622V60.5082ZM368.776 100H329.865C328.869 100 327.791 99.8894 326.629 99.6681C325.495 99.4192 324.361 99.0459 323.228 98.5481C322.121 98.0503 321.057 97.4142 320.033 96.6399C319.01 95.8379 318.098 94.8838 317.295 93.7775C316.521 92.6437 315.899 91.3439 315.429 89.8781C314.959 88.3848 314.724 86.7116 314.724 84.8587V55.6546C314.724 54.659 314.834 53.5943 315.055 52.4604C315.304 51.2989 315.678 50.1651 316.175 49.0588C316.673 47.925 317.323 46.8464 318.125 45.8232C318.927 44.7999 319.881 43.9011 320.987 43.1268C322.121 42.3248 323.421 41.6887 324.887 41.2185C326.353 40.7484 328.012 40.5133 329.865 40.5133H368.776V51.2989H329.865C328.454 51.2989 327.376 51.6723 326.629 52.419C325.882 53.1657 325.509 54.2719 325.509 55.7376V84.8587C325.509 86.2415 325.882 87.32 326.629 88.0944C327.404 88.8411 328.482 89.2144 329.865 89.2144H368.776V100ZM435.647 60.4252C435.647 62.8865 435.329 65.0851 434.692 67.021C434.084 68.9569 433.268 70.6715 432.245 72.1649C431.222 73.6306 430.019 74.8889 428.636 75.9398C427.281 76.9907 425.87 77.8619 424.405 78.5533C422.939 79.217 421.446 79.701 419.925 80.0052C418.431 80.3094 417.021 80.4615 415.693 80.4615H411.338V100H400.469V80.4615H396.155C394.827 80.4615 393.403 80.3094 391.882 80.0052C390.389 79.701 388.895 79.217 387.402 78.5533C385.936 77.8619 384.526 76.9907 383.171 75.9398C381.815 74.8889 380.612 73.6306 379.562 72.1649C378.538 70.6715 377.709 68.9569 377.073 67.021C376.464 65.0575 376.16 62.8589 376.16 60.4252V40.5133H386.946V60.4252C386.946 61.8356 387.167 63.1078 387.609 64.2416C388.052 65.3478 388.674 66.302 389.476 67.104C390.278 67.906 391.246 68.5282 392.38 68.9707C393.541 69.3855 394.827 69.5929 396.238 69.5929H415.693C416.716 69.427 417.767 69.2196 418.846 68.9707C419.925 68.6941 420.906 68.2378 421.791 67.6018C422.676 66.9657 423.409 66.0807 423.99 64.9468C424.571 63.813 424.861 62.3058 424.861 60.4252V40.5133H435.647V60.4252Z' fill='white'/></svg>";function _n(e){try{let n=new DOMParser().parseFromString(io,"image/svg+xml").documentElement;if(!n||n.nodeName==="parsererror")return null;let r=e.importNode(n,!0);return r.setAttribute("aria-hidden","true"),r.setAttribute("focusable","false"),r}catch{return null}}var ao="/api/v1/sdk/uploads",so="/api/v1/sdk/uploads/discard",lo=3,co=5*1024*1024,po=1568,uo=_t,fo=3e4;function at(e,t){return uo.includes(e.type)?e.size>co?{ok:false,reason:"size"}:t>=lo?{ok:false,reason:"count"}:{ok:true}:{ok:false,reason:"type"}}function ho(e,t,n=po){let r=Math.max(e,t);if(!(r>n)||!(r>0))return {width:Math.round(e),height:Math.round(t)};let o=n/r;return {width:Math.max(1,Math.round(e*o)),height:Math.max(1,Math.round(t*o))}}function Sn(e,t=typeof fetch<"u"?fetch.bind(globalThis):null){return {createImageBitmap:n=>createImageBitmap(n),createCanvas(n,r){let o=e.createElement("canvas");o.width=n,o.height=r;let i=o.getContext("2d");return {drawImage(s,h,C){i?.drawImage(s,0,0,h,C);},toBlob(s,h){return new Promise(C=>{try{o.toBlob(g=>C(g),s,h);}catch{C(null);}})}}},fetchImpl:t}}async function mo(e,t){let n={blob:e,contentType:e.type,width:0,height:0};try{let r=await t.createImageBitmap(e),o=ho(r.width,r.height);if(o.width===r.width&&o.height===r.height)return r.close?.(),{...n,width:r.width,height:r.height};let i=t.createCanvas(o.width,o.height);i.drawImage(r,o.width,o.height);let s=await i.toBlob("image/jpeg",.85);return r.close?.(),s?{blob:s,contentType:"image/jpeg",width:o.width,height:o.height}:n}catch{return n}}function go(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e.objectKey;return typeof t=="string"&&t.length>0?t:null}function bo(e,t,n,r){return new Promise(o=>{let i=false,s=h=>{i||(i=true,o(h));};e.then(s,()=>s(r));try{n(()=>s(r),t);}catch{}})}async function Ln(e,t,n){let r=at(e,t);if(!r.ok)return {ok:false,reason:r.reason};let{apiBase:o=$,sessionToken:i,env:s,timeoutMs:h=fo}=n,C=s.setTimeoutImpl??((l,v)=>setTimeout(l,v)),g=s.fetchImpl;if(!g||!i)return {ok:false,reason:"failed"};let c=(async()=>{let l=await mo(e,s),v;try{v=new FormData,v.append("file",l.blob,"image");}catch{return {ok:false,reason:"failed"}}let d;try{d=await g(`${o}${ao}`,{method:"POST",headers:{Authorization:`Bearer ${i}`},body:v,credentials:"omit"});}catch{return {ok:false,reason:"failed"}}if(!d.ok)return {ok:false,reason:"failed"};let u;try{u=await d.json();}catch{return {ok:false,reason:"failed"}}let w=go(u);return w?{ok:true,attachment:{objectKey:w,contentType:l.contentType,width:l.width,height:l.height}}:{ok:false,reason:"failed"}})();return bo(c,h,C,{ok:false,reason:"failed"})}async function In(e,t){let{apiBase:n=$,sessionToken:r,fetchImpl:o}=t;if(!o||!r||!e)return false;try{return (await o(`${n}${so}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({objectKey:e}),credentials:"omit"})).ok}catch{return false}}var de="arcy-chat-panel",st="arcy-chat-header",Nn="arcy-chat-icon",$n="arcy-chat-name",He="arcy-chat-hbtn",ne="arcy-chat-body",On="arcy-chat-strip",Dn="arcy-chat-main",xe="arcy-chat-mark",Ce="arcy-chat-mark-link",Mi=Lt;function Rn(e,t){return typeof e!="string"||e.length===0?null:/^https:\/\//i.test(e)?e:e.startsWith("/")&&!e.startsWith("//")?`${(t??$).replace(/\/+$/,"")}${e}`:null}var wo="https://arcyai.com",re="arcy-chat-welcome",Ue="arcy-chat-starter",lt="arcy-chat-starters",ct="arcy-chat-chips",J="arcy-chat-chip",vo=new Set(["org_cap_exceeded","anon_org_cap_exceeded","credits_exhausted","lapsed"]),xo=60,Co=2500,ko=Ft+`
|
|
840
|
+
`,mr={required:"fillRequired",invalid_number:"fillInvalidNumber",number_too_small:"fillNumberTooSmall",number_too_large:"fillNumberTooLarge",invalid_email:"fillInvalidEmail",invalid_url:"fillInvalidUrl",invalid_date:"fillInvalidDate",invalid_time:"fillInvalidTime",date_too_early:"fillDateTooEarly",date_too_late:"fillDateTooLate",too_long:"fillTooLong",invalid_option:"fillInvalidOption",invalid:"fillInvalid"},gr={date:"date",time:"time",datetime:"datetime-local",month:"month",week:"week"};function fn(e,t){let n=e.host.ownerDocument,r=n.createElement("div");r.className=S,r.setAttribute("role","dialog");let o=n.createElement("div");o.className=`${S}-question`;let i=n.createElement("div");i.className=`${S}-error`,i.setAttribute("role","alert"),i.style.setProperty("display","none");let s=n.createElement("div");s.className=`${S}-controls`,r.appendChild(o),r.appendChild(i),r.appendChild(s),e.root.appendChild(r);let h=null;function C(l){let d=t()[mr[l]];return (typeof d=="string"?d:"").replace("{min}",h?.min??"").replace("{max}",h?.max??String(h?.maxLength??""))}function g(){let l;try{l=e.bar.getMetrics();}catch{return}let v=l.bottomOffset+l.keyboardOffset+l.height+8,d=r.style;if(d.setProperty("bottom",`${v}px`),d.setProperty("left","50%"),d.setProperty("translate","-50%"),l.isMobile){d.setProperty("width",`calc(100% - ${24}px)`),d.setProperty("max-width","none"),d.setProperty("transform","none");return}let u=Ne(l.widthPercent,{width:l.viewportWidth,height:l.viewportHeight});d.setProperty("width",`${u}px`),d.setProperty("max-width",`calc(100vw - ${32}px)`),d.setProperty("transform",we({x:$e(l.offset.x,u,l.viewportWidth),y:l.offset.y}));}function c(l,v){s.textContent="";let d=t(),u=(m,x)=>{let A=n.createElement("button");A.type="button",A.className=`${S}-pill`,A.textContent=m,A.addEventListener("click",()=>v.onAnswer(x)),s.appendChild(A);},w=(m,x)=>{let A=n.createElement("button");A.type="button",A.className=`${S}-confirm`,A.textContent=d.fillConfirm,A.addEventListener("click",()=>v.onAnswer(x())),m.addEventListener("keydown",E=>{E.key==="Enter"&&(E.preventDefault(),v.onAnswer(x()));}),s.appendChild(m),s.appendChild(A);};switch(l.kind){case "select":case "radio":{for(let m of l.options??[])u(m.label,m.value);return}case "checkbox":{u(d.fillYes,"true"),u(d.fillNo,"false");return}case "range":{let m=n.createElement("input");m.type="range",m.className=`${S}-range`,l.min!==null&&(m.min=l.min),l.max!==null&&(m.max=l.max),l.step!==null&&(m.step=l.step);let x=n.createElement("span");x.className=`${S}-range-value`,x.textContent=m.value,m.addEventListener("input",()=>{x.textContent=m.value;});let A=n.createElement("button");A.type="button",A.className=`${S}-confirm`,A.textContent=d.fillConfirm,A.addEventListener("click",()=>v.onAnswer(m.value)),s.appendChild(m),s.appendChild(x),s.appendChild(A);return}case "password":{let m=n.createElement("input");m.type="password",m.className=`${S}-input`,m.autocomplete="off",w(m,()=>m.value);try{m.focus();}catch{}return}default:{let m=gr[l.kind];if(!m)return;let x=n.createElement("input");x.type=m,x.className=`${S}-input`,l.min!==null&&(x.min=l.min),l.max!==null&&(x.max=l.max),l.step!==null&&(x.step=l.step),w(x,()=>x.value);}}}return {show(l,v){h=l,o.textContent=l.question,c(l,v),this.setError(l.errorCode),g(),r.setAttribute("data-open","");},setError(l){l===null?(i.textContent="",i.style.setProperty("display","none")):(i.textContent=C(l),i.style.setProperty("display","block")),r.hasAttribute("data-open")&&g();},hide(){h=null,r.removeAttribute("data-open"),s.textContent="",i.textContent="",i.style.setProperty("display","none");},reposition(){r.hasAttribute("data-open")&&g();},isVisible:()=>r.hasAttribute("data-open"),destroy(){try{r.remove();}catch{}}}}var br=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,yr=/^\d{4}-\d{2}-\d{2}$/,wr=/^([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/,vr=/^\d{4}-\d{2}-\d{2}T([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/,xr=/^\d{4}-\d{2}$/,Cr=/^\d{4}-W\d{2}$/,kr=/^\+?[\d\s().-]{3,}$/;function Ar(e){let t=Date.parse(e);return Number.isFinite(t)}function Er(e,t){if(t.min!==null){let n=Number(t.min);if(Number.isFinite(n)&&e<n)return "number_too_small"}if(t.max!==null){let n=Number(t.max);if(Number.isFinite(n)&&e>n)return "number_too_large"}return null}function rt(e){return /^\d:/.test(e)?`0${e}`:e}function ve(e,t){return t.min!==null&&t.min.length>0&&e<t.min?"date_too_early":t.max!==null&&t.max.length>0&&e>t.max?"date_too_late":null}function hn(e,t){let n=t.kind==="password"?e:e.trim();if(n.length===0)return t.required?"required":null;if(t.maxLength!==null&&n.length>t.maxLength)return "too_long";switch(t.kind){case "number":case "range":{let r=Number(n);return Number.isFinite(r)?Er(r,t):"invalid_number"}case "email":return br.test(n)?null:"invalid_email";case "url":try{let r=new URL(n);return r.protocol==="http:"||r.protocol==="https:"?null:"invalid_url"}catch{return "invalid_url"}case "tel":return kr.test(n)?null:"invalid";case "date":return !yr.test(n)||!Ar(n)?"invalid_date":ve(n,t);case "datetime":return vr.test(n)?ve(n,t):"invalid_date";case "month":return xr.test(n)?ve(n,t):"invalid_date";case "week":return Cr.test(n)?ve(n,t):"invalid_date";case "time":return wr.test(n)?ve(rt(n),{...t,min:t.min!==null?rt(t.min):null,max:t.max!==null?rt(t.max):null}):"invalid_time";case "select":case "radio":return (t.options??[]).some(o=>o.value===n)?null:"invalid_option";case "checkbox":return n==="true"||n==="false"?null:"invalid_option";default:{if(t.pattern)try{if(!new RegExp(`^(?:${t.pattern})$`).test(n))return "invalid"}catch{}return null}}}function mn(e,t){if(!t||t.length===0)return e;let n=e.trim();if(t.some(i=>i.value===n))return n;let r=n.toLowerCase(),o=t.find(i=>i.label.trim().toLowerCase()===r);return o?o.value:e}var Tr="https://api.arcyai.com",_r="/api/v1/sdk/flows/catalog";function Sr(e){return e!==void 0?e:typeof fetch<"u"?fetch.bind(globalThis):null}function Lr(e,t,n,r){return new Promise(o=>{let i=false,s=h=>{i||(i=true,o(h));};e.then(s,()=>s(r));try{n(()=>s(r),t);}catch{}})}function Ir(e){if(!e||typeof e!="object")return false;let t=e;return typeof t.cvid=="string"&&(t.publicName===null||typeof t.publicName=="string")&&(t.summary===null||typeof t.summary=="string")&&(t.firstStepRoute===void 0||t.firstStepRoute===null||typeof t.firstStepRoute=="string")}function Rr(e){if(!e||typeof e!="object")return false;let t=e;return typeof t.cvid=="string"&&typeof t.publicName=="string"&&t.publicName.trim().length>0&&(t.summary===null||t.summary===void 0||typeof t.summary=="string")}function Mr(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e.flows;if(!Array.isArray(t))return null;let n=[];for(let i of t)Ir(i)&&n.push({...i,firstStepRoute:i.firstStepRoute??null});let r=e.starterFlows,o=Array.isArray(r)?r.filter(Rr).map(i=>({cvid:i.cvid,publicName:i.publicName,summary:i.summary??null})):[];return {flows:n,starterFlows:o}}function Fr(e){return {"Content-Type":"application/json",Authorization:`Bearer ${e}`}}async function gn(e){let{apiBase:t=Tr,sessionToken:n,sessionId:r,setTimeoutImpl:o=(C,g)=>setTimeout(C,g),timeoutMs:i=8e3}=e,s=Sr(e.fetchImpl);if(!s)return {ok:false,reason:"unusable"};let h=(async()=>{let C;try{C=await s(`${t}${_r}`,{method:"POST",headers:Fr(n),body:JSON.stringify(r?{sessionId:r}:{}),credentials:"omit"});}catch{return {ok:false,reason:"network"}}if(!C.ok)return {ok:false,reason:"rejected"};let g;try{g=await C.json();}catch{return {ok:false,reason:"unusable"}}let c=Mr(g);return c?{ok:true,...c}:{ok:false,reason:"unusable"}})();return Lr(h,i,o,{ok:false,reason:"network"})}function bn(e){let t=[];for(let n of e){let r=n.publicName?.trim()??"";r&&t.push({...n,publicName:r});}return t}var D="https://api.arcyai.com",Pr="/api/v1/sdk/agent/query";function Nr(e){return e!==void 0?e:typeof fetch<"u"?fetch.bind(globalThis):null}function $r(e,t,n,r){return new Promise(o=>{let i=false,s=h=>{i||(i=true,o(h));};e.then(s,()=>s(r));try{n(()=>s(r),t);}catch{}})}var Or=new Set(["credits_exhausted","lapsed","org_cap_exceeded","user_cap_exceeded","anon_org_cap_exceeded","anon_user_cap_exceeded"]);function Dr(e){return typeof e=="string"&&Or.has(e)}function Br(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;if(t.responseType!=="chat")return null;let n=t.chatResponse;if(!n||typeof n!="object"||Array.isArray(n))return null;let r=n;if(typeof r.message!="string")return null;let o=[];if(Array.isArray(r.flowsOffered))for(let s of r.flowsOffered){if(!s||typeof s!="object"||Array.isArray(s))continue;let h=s;typeof h.flowCvid=="string"&&(h.publicName!==null&&typeof h.publicName!="string"||o.push({flowCvid:h.flowCvid,publicName:h.publicName??null}));}let i=[];if(Array.isArray(r.citedSources))for(let s of r.citedSources){if(!s||typeof s!="object"||Array.isArray(s))continue;let h=s;typeof h.documentId!="string"||typeof h.title!="string"||h.sourceUrl!==null&&typeof h.sourceUrl!="string"||i.push({documentId:h.documentId,title:h.title,sourceUrl:h.sourceUrl??null});}return {ok:true,message:r.message,messageId:typeof r.messageId=="string"&&r.messageId.length>0?r.messageId:null,isFallback:r.isFallback===true,flowsOffered:o,citedSources:i}}function Hr(e){return {"Content-Type":"application/json",Authorization:`Bearer ${e}`}}async function yn(e){let{apiBase:t=D,publicKey:n,sessionId:r,sessionToken:o,query:i,route:s,conversationId:h,attachments:C=[],setTimeoutImpl:g=(d,u)=>setTimeout(d,u),timeoutMs:c=2e4}=e,l=Nr(e.fetchImpl);if(!l)return {ok:false,reason:"unusable"};let v=(async()=>{let d;try{d=await l(`${t}${Pr}`,{method:"POST",headers:Hr(o),body:JSON.stringify({publicKey:n,sessionId:r,query:i,route:s,conversationId:h,...C.length>0?{attachments:C}:{}}),credentials:"omit"});}catch{return {ok:false,reason:"network"}}if(d.status===402){let m;try{m=await d.json();}catch{return {ok:false,reason:"unusable"}}let x=m&&typeof m=="object"&&!Array.isArray(m)?m.reason:void 0;return Dr(x)?{ok:false,reason:"cap_denied",capReason:x}:{ok:false,reason:"unusable"}}if(!d.ok)return {ok:false,reason:"rejected"};let u;try{u=await d.json();}catch{return {ok:false,reason:"unusable"}}return Br(u)??{ok:false,reason:"unusable"}})();return $r(v,c,g,{ok:false,reason:"network"})}var Ur="https://api.arcyai.com";function zr(e){return typeof e!="string"||e.length===0||e.length>2048?false:/^https:\/\//i.test(e)?true:e.startsWith("/")&&!e.startsWith("//")}function ot(e,t){return zr(e)?/^https:\/\//i.test(e)?e:`${(t??Ur).replace(/\/+$/,"")}${e}`:null}var vn='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';function V(e,t=vn){return {family:e,fallback:t,stack:`"${e}", ${t}`}}var xn={system:{stack:vn},serif:{stack:'Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif'},mono:{stack:'ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace'},humanist:{stack:'Seravek, "Gill Sans Nova", Ubuntu, Calibri, "DejaVu Sans", sans-serif'},rounded:{stack:'ui-rounded, "Hiragino Maru Gothic ProN", Quicksand, Comfortaa, "Arial Rounded MT Bold", Calibri, sans-serif'},inter:V("Inter"),roboto:V("Roboto"),"open-sans":V("Open Sans"),lato:V("Lato"),poppins:V("Poppins"),montserrat:V("Montserrat"),nunito:V("Nunito"),"source-sans-3":V("Source Sans 3"),"work-sans":V("Work Sans"),"dm-sans":V("DM Sans"),manrope:V("Manrope"),"playfair-display":V("Playfair Display","Georgia, serif"),"ibm-plex-sans":V("IBM Plex Sans")},Vr=[["latin","U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD"],["latin-ext","U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF"]];var De="--_arcy-font",wn="data-arcy-font";function Wr(e,t=D){let n=xn[e];return n?.family?Vr.map(([r,o])=>`@font-face{font-family:"${n.family}";font-style:normal;font-weight:400;font-display:swap;src:url("${t}/fonts/${e}-${r}.woff2") format("woff2");unicode-range:${o};}`).join(`
|
|
841
|
+
`):""}function it(e,t,n=D){try{let r=e.style.getPropertyValue(Lt).trim(),o=r?xn[r]:void 0;if(!o){e.style.removeProperty(De);return}if(e.style.setProperty(De,o.stack),!o.family)return;let i=t.head||t.documentElement;if(!i||i.querySelector(`style[${wn}="${r}"]`))return;let s=t.createElement("style");Le(s),s.setAttribute(wn,r),s.textContent=Wr(r,n),i.appendChild(s);}catch{}}var jr="/api/v1/sdk/conversations",Gr=15e3,Yr=20,Cn=60;function Kr(e){return e!==void 0?e:typeof fetch<"u"?fetch.bind(globalThis):null}function qr(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e.conversations;if(!Array.isArray(t))return null;let n=[];for(let r of t){if(n.length>=Yr)break;if(!r||typeof r!="object"||Array.isArray(r))continue;let o=r;if(typeof o.id!="string"||o.id.length===0)continue;let i=o.lastMessageAt,s=typeof i=="number"&&Number.isFinite(i)?i:typeof i=="string"?Date.parse(i):NaN;n.push({id:o.id,firstMessage:typeof o.firstMessage=="string"&&o.firstMessage.length>0?o.firstMessage:null,hasImage:o.hasImage===true,lastMessageAt:Number.isFinite(s)?s:0});}return n}function kn(e){if(!e)return "";try{return new Date(e).toLocaleDateString()}catch{return ""}}function Xr(e,t){let n=e.firstMessage?.trim()??"";if(n.length>0)return n.length>Cn?`${n.slice(0,Cn-1).trimEnd()}\u2026`:n;let r=kn(e.lastMessageAt);return e.hasImage?r?`${t} ${r}`:t:r||t}function at(e,t,n){return e.map(r=>({id:r.id,title:Xr(r,t),subtitle:kn(r.lastMessageAt),active:!!(n&&r.id===n)}))}async function An(e){let{apiBase:t=D,sessionToken:n,visitorId:r,setTimeoutImpl:o=(C,g)=>setTimeout(C,g),timeoutMs:i=Gr}=e,s=Kr(e.fetchImpl);if(!s||!n||!r)return {ok:false};let h=(async()=>{let C;try{C=await s(`${t}${jr}?visitorId=${encodeURIComponent(r)}`,{method:"GET",headers:{Authorization:`Bearer ${n}`},credentials:"omit"});}catch{return {ok:false}}if(!C.ok)return {ok:false};let g;try{g=await C.json();}catch{return {ok:false}}let c=qr(g);return c?{ok:true,conversations:c}:{ok:false}})();return new Promise(C=>{let g=false,c=l=>{g||(g=true,C(l));};h.then(c,()=>c({ok:false}));try{o(()=>c({ok:!1}),i);}catch{}})}var Qr="/api/v1/sdk/conversations/{conversationId}/messages",Jr=15e3,Zr=200;function eo(e){return e!==void 0?e:typeof fetch<"u"?fetch.bind(globalThis):null}function to(e){return Qr.replace("{conversationId}",encodeURIComponent(e))}function En(e){return e==="agent"?"assistant":"user"}function no(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e.messages;if(!Array.isArray(t))return null;let n=[];for(let r of t){if(n.length>=Zr)break;if(!r||typeof r!="object"||Array.isArray(r))continue;let o=r;if(typeof o.id!="string"||o.id.length===0||o.role!=="user"&&o.role!=="agent"||typeof o.text!="string")continue;let i=o.occurredAt,s=typeof i=="number"&&Number.isFinite(i)?i:typeof i=="string"?Date.parse(i):NaN,h=typeof o.images=="number"&&Number.isFinite(o.images)?Math.max(0,Math.floor(o.images)):0;n.push({id:o.id,role:o.role,text:o.text,occurredAt:Number.isFinite(s)?s:0,images:h,feedback:o.feedback==="up"||o.feedback==="down"?o.feedback:null});}return n}async function Tn(e){let{apiBase:t=D,sessionToken:n,conversationId:r,visitorId:o,setTimeoutImpl:i=(g,c)=>setTimeout(g,c),timeoutMs:s=Jr}=e,h=eo(e.fetchImpl);if(!h||!n||!r)return {ok:false};let C=(async()=>{let g;try{let v=o?`?visitorId=${encodeURIComponent(o)}`:"";g=await h(`${t}${to(r)}${v}`,{method:"GET",headers:{Authorization:`Bearer ${n}`},credentials:"omit"});}catch{return {ok:false}}if(!g.ok)return {ok:false};let c;try{c=await g.json();}catch{return {ok:false}}let l=no(c);return l?{ok:true,messages:l}:{ok:false}})();return new Promise(g=>{let c=false,l=v=>{c||(c=true,g(v));};C.then(l,()=>l({ok:false}));try{i(()=>l({ok:!1}),s);}catch{}})}var ro="/api/v1/sdk/conversations/{conversationId}/messages/{messageId}/feedback",oo=1e4;function io(e){return e!==void 0?e:typeof fetch<"u"?fetch.bind(globalThis):null}function ao(e,t){return ro.replace("{conversationId}",encodeURIComponent(e)).replace("{messageId}",encodeURIComponent(t))}async function _n(e){let{apiBase:t=D,sessionToken:n,conversationId:r,messageId:o,value:i,visitorId:s,setTimeoutImpl:h=(l,v)=>setTimeout(l,v),timeoutMs:C=oo}=e,g=io(e.fetchImpl);if(!g||!n||!r||!o)return {ok:false};let c=(async()=>{try{let l=s?`?visitorId=${encodeURIComponent(s)}`:"";return {ok:(await g(`${t}${ao(r,o)}${l}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify({value:i}),credentials:"omit"})).ok}}catch{return {ok:false}}})();return new Promise(l=>{let v=false,d=u=>{v||(v=true,l(u));};c.then(d,()=>d({ok:false}));try{h(()=>d({ok:!1}),C);}catch{}})}var so="<svg width='476' height='139' viewBox='0 0 476 139' fill='none' xmlns='http://www.w3.org/2000/svg'><path d='M0 24.69C0 11.0541 11.0541 0 24.69 0H451.311C464.946 0 476 11.0537 476 24.6892V114.311C476 127.946 464.946 139 451.311 139H24.69C11.0541 139 0 127.946 0 114.31V24.69Z' fill='#12161A'/><path d='M132.047 84.6159L108.384 42.3014C101.224 29.4986 82.7988 29.502 75.6456 42.3116L52.0065 84.6362C43.8531 99.2299 63.7247 113.114 74.6251 100.436C83.7854 89.7891 100.271 89.7857 109.435 100.429C120.342 113.1 140.207 99.2096 132.047 84.6159Z' stroke='white' stroke-width='9.11833'/><path d='M232.67 100H221.885V85.398H183.969V100H173.183V70.2567C173.183 65.9148 173.93 61.9186 175.424 58.2681C176.917 54.6176 178.991 51.4787 181.646 48.8514C184.301 46.2242 187.44 44.1777 191.063 42.7119C194.685 41.2462 198.64 40.5133 202.927 40.5133H227.236C227.983 40.5133 228.688 40.6516 229.351 40.9282C230.015 41.2047 230.596 41.5919 231.094 42.0897C231.592 42.5875 231.979 43.1682 232.255 43.832C232.532 44.4957 232.67 45.2009 232.67 45.9476V100ZM183.969 74.6124H221.885V51.2989H202.927C202.595 51.2989 201.89 51.3542 200.811 51.4649C199.76 51.5478 198.53 51.7829 197.119 52.1701C195.736 52.5572 194.271 53.1518 192.722 53.9538C191.173 54.7558 189.749 55.8621 188.449 57.2725C187.149 58.6829 186.071 60.4528 185.214 62.5823C184.384 64.6841 183.969 67.2422 183.969 70.2567V74.6124ZM304.685 60.5082C304.685 62.9695 304.38 65.1681 303.772 67.104C303.164 69.0398 302.334 70.7545 301.283 72.2479C300.26 73.7136 299.071 74.9719 297.716 76.0228C296.36 77.0737 294.936 77.9449 293.443 78.6362C291.977 79.3 290.484 79.7839 288.963 80.0881C287.469 80.3924 286.059 80.5445 284.731 80.5445L307.257 100H290.58L268.097 80.5445H260.339V69.7589H284.731C286.086 69.6482 287.317 69.3717 288.423 68.9292C289.557 68.4591 290.525 67.8368 291.327 67.0625C292.157 66.2881 292.793 65.3617 293.235 64.2831C293.678 63.1769 293.899 61.9186 293.899 60.5082V53.7049C293.899 53.0965 293.816 52.6402 293.65 52.336C293.512 52.0041 293.318 51.7691 293.069 51.6308C292.848 51.4649 292.599 51.3681 292.323 51.3404C292.074 51.3128 291.839 51.2989 291.617 51.2989H256.025V100H245.239V45.9476C245.239 45.2009 245.378 44.4957 245.654 43.832C245.931 43.1682 246.304 42.5875 246.774 42.0897C247.272 41.5919 247.853 41.2047 248.517 40.9282C249.18 40.6516 249.899 40.5133 250.674 40.5133H291.617C294.024 40.5133 296.056 40.9558 297.716 41.8408C299.375 42.6981 300.716 43.7905 301.739 45.118C302.79 46.4178 303.537 47.8282 303.979 49.3492C304.45 50.8703 304.685 52.2945 304.685 53.622V60.5082ZM368.776 100H329.865C328.869 100 327.791 99.8894 326.629 99.6681C325.495 99.4192 324.361 99.0459 323.228 98.5481C322.121 98.0503 321.057 97.4142 320.033 96.6399C319.01 95.8379 318.098 94.8838 317.295 93.7775C316.521 92.6437 315.899 91.3439 315.429 89.8781C314.959 88.3848 314.724 86.7116 314.724 84.8587V55.6546C314.724 54.659 314.834 53.5943 315.055 52.4604C315.304 51.2989 315.678 50.1651 316.175 49.0588C316.673 47.925 317.323 46.8464 318.125 45.8232C318.927 44.7999 319.881 43.9011 320.987 43.1268C322.121 42.3248 323.421 41.6887 324.887 41.2185C326.353 40.7484 328.012 40.5133 329.865 40.5133H368.776V51.2989H329.865C328.454 51.2989 327.376 51.6723 326.629 52.419C325.882 53.1657 325.509 54.2719 325.509 55.7376V84.8587C325.509 86.2415 325.882 87.32 326.629 88.0944C327.404 88.8411 328.482 89.2144 329.865 89.2144H368.776V100ZM435.647 60.4252C435.647 62.8865 435.329 65.0851 434.692 67.021C434.084 68.9569 433.268 70.6715 432.245 72.1649C431.222 73.6306 430.019 74.8889 428.636 75.9398C427.281 76.9907 425.87 77.8619 424.405 78.5533C422.939 79.217 421.446 79.701 419.925 80.0052C418.431 80.3094 417.021 80.4615 415.693 80.4615H411.338V100H400.469V80.4615H396.155C394.827 80.4615 393.403 80.3094 391.882 80.0052C390.389 79.701 388.895 79.217 387.402 78.5533C385.936 77.8619 384.526 76.9907 383.171 75.9398C381.815 74.8889 380.612 73.6306 379.562 72.1649C378.538 70.6715 377.709 68.9569 377.073 67.021C376.464 65.0575 376.16 62.8589 376.16 60.4252V40.5133H386.946V60.4252C386.946 61.8356 387.167 63.1078 387.609 64.2416C388.052 65.3478 388.674 66.302 389.476 67.104C390.278 67.906 391.246 68.5282 392.38 68.9707C393.541 69.3855 394.827 69.5929 396.238 69.5929H415.693C416.716 69.427 417.767 69.2196 418.846 68.9707C419.925 68.6941 420.906 68.2378 421.791 67.6018C422.676 66.9657 423.409 66.0807 423.99 64.9468C424.571 63.813 424.861 62.3058 424.861 60.4252V40.5133H435.647V60.4252Z' fill='white'/></svg>";function Sn(e){try{let n=new DOMParser().parseFromString(so,"image/svg+xml").documentElement;if(!n||n.nodeName==="parsererror")return null;let r=e.importNode(n,!0);return r.setAttribute("aria-hidden","true"),r.setAttribute("focusable","false"),r}catch{return null}}var lo="/api/v1/sdk/uploads",co="/api/v1/sdk/uploads/discard",po=3,uo=5*1024*1024,fo=1568,ho=St,mo=3e4;function st(e,t){return ho.includes(e.type)?e.size>uo?{ok:false,reason:"size"}:t>=po?{ok:false,reason:"count"}:{ok:true}:{ok:false,reason:"type"}}function go(e,t,n=fo){let r=Math.max(e,t);if(!(r>n)||!(r>0))return {width:Math.round(e),height:Math.round(t)};let o=n/r;return {width:Math.max(1,Math.round(e*o)),height:Math.max(1,Math.round(t*o))}}function Ln(e,t=typeof fetch<"u"?fetch.bind(globalThis):null){return {createImageBitmap:n=>createImageBitmap(n),createCanvas(n,r){let o=e.createElement("canvas");o.width=n,o.height=r;let i=o.getContext("2d");return {drawImage(s,h,C){i?.drawImage(s,0,0,h,C);},toBlob(s,h){return new Promise(C=>{try{o.toBlob(g=>C(g),s,h);}catch{C(null);}})}}},fetchImpl:t}}async function bo(e,t){let n={blob:e,contentType:e.type,width:0,height:0};try{let r=await t.createImageBitmap(e),o=go(r.width,r.height);if(o.width===r.width&&o.height===r.height)return r.close?.(),{...n,width:r.width,height:r.height};let i=t.createCanvas(o.width,o.height);i.drawImage(r,o.width,o.height);let s=await i.toBlob("image/jpeg",.85);return r.close?.(),s?{blob:s,contentType:"image/jpeg",width:o.width,height:o.height}:n}catch{return n}}function yo(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e.objectKey;return typeof t=="string"&&t.length>0?t:null}function wo(e,t,n,r){return new Promise(o=>{let i=false,s=h=>{i||(i=true,o(h));};e.then(s,()=>s(r));try{n(()=>s(r),t);}catch{}})}async function In(e,t,n){let r=st(e,t);if(!r.ok)return {ok:false,reason:r.reason};let{apiBase:o=D,sessionToken:i,env:s,timeoutMs:h=mo}=n,C=s.setTimeoutImpl??((l,v)=>setTimeout(l,v)),g=s.fetchImpl;if(!g||!i)return {ok:false,reason:"failed"};let c=(async()=>{let l=await bo(e,s),v;try{v=new FormData,v.append("file",l.blob,"image");}catch{return {ok:false,reason:"failed"}}let d;try{d=await g(`${o}${lo}`,{method:"POST",headers:{Authorization:`Bearer ${i}`},body:v,credentials:"omit"});}catch{return {ok:false,reason:"failed"}}if(!d.ok)return {ok:false,reason:"failed"};let u;try{u=await d.json();}catch{return {ok:false,reason:"failed"}}let w=yo(u);return w?{ok:true,attachment:{objectKey:w,contentType:l.contentType,width:l.width,height:l.height}}:{ok:false,reason:"failed"}})();return wo(c,h,C,{ok:false,reason:"failed"})}async function Rn(e,t){let{apiBase:n=D,sessionToken:r,fetchImpl:o}=t;if(!o||!r||!e)return false;try{return (await o(`${n}${co}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({objectKey:e}),credentials:"omit"})).ok}catch{return false}}var de="arcy-chat-panel",lt="arcy-chat-header",Nn="arcy-chat-icon",$n="arcy-chat-name",He="arcy-chat-hbtn",ne="arcy-chat-body",On="arcy-chat-strip",Dn="arcy-chat-main",xe="arcy-chat-mark",Ce="arcy-chat-mark-link",$i=It;var xo="https://arcyai.com",re="arcy-chat-welcome",Ue="arcy-chat-starter",ct="arcy-chat-starters",dt="arcy-chat-chips",J="arcy-chat-chip",Co=new Set(["org_cap_exceeded","anon_org_cap_exceeded","credits_exhausted","lapsed"]),ko=60,Ao=2500,Eo=Pt+`
|
|
842
842
|
/* Stays mounted and animates open/shut in place (D929/D979) rather than
|
|
843
843
|
toggling "display": the bar glides the panel the last few pixels rather
|
|
844
844
|
than having it appear or vanish. "visibility" (not "pointer-events",
|
|
@@ -900,7 +900,7 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
900
900
|
border-bottom: 0;
|
|
901
901
|
}
|
|
902
902
|
|
|
903
|
-
.${
|
|
903
|
+
.${lt} {
|
|
904
904
|
display: flex;
|
|
905
905
|
align-items: center;
|
|
906
906
|
gap: 4px;
|
|
@@ -934,7 +934,7 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
934
934
|
/* The identity sits in the middle, between the two controls on the left and
|
|
935
935
|
the one on the right, so the panel reads as the operator's rather than as
|
|
936
936
|
a third party's. */
|
|
937
|
-
.${
|
|
937
|
+
.${lt} .arcy-chat-identity {
|
|
938
938
|
flex: 1 1 auto;
|
|
939
939
|
display: flex;
|
|
940
940
|
align-items: center;
|
|
@@ -1072,7 +1072,7 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
1072
1072
|
color: color-mix(in srgb, var(--_arcy-main-text, #101828) 70%, transparent);
|
|
1073
1073
|
}
|
|
1074
1074
|
|
|
1075
|
-
.${
|
|
1075
|
+
.${ct} {
|
|
1076
1076
|
display: flex;
|
|
1077
1077
|
flex-wrap: wrap;
|
|
1078
1078
|
justify-content: center;
|
|
@@ -1084,7 +1084,7 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
1084
1084
|
row of height until that answers is what stops the greeting sliding up the
|
|
1085
1085
|
panel while somebody is reading it. Released either way: an operator who
|
|
1086
1086
|
has featured nothing must not be left with a permanent gap. */
|
|
1087
|
-
.${
|
|
1087
|
+
.${ct}[data-pending] {
|
|
1088
1088
|
min-height: 34px;
|
|
1089
1089
|
}
|
|
1090
1090
|
|
|
@@ -1117,7 +1117,7 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
1117
1117
|
|
|
1118
1118
|
/* \u2500\u2500 Attachments waiting to be sent \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
|
|
1119
1119
|
|
|
1120
|
-
.${
|
|
1120
|
+
.${dt} {
|
|
1121
1121
|
display: flex;
|
|
1122
1122
|
flex-wrap: wrap;
|
|
1123
1123
|
gap: 6px;
|
|
@@ -1126,7 +1126,7 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
1126
1126
|
|
|
1127
1127
|
/* In the tray the bar owns the insets; the rule above is the D845 fallback
|
|
1128
1128
|
for a core with no tray. */
|
|
1129
|
-
.${
|
|
1129
|
+
.${Rt} .${dt} {
|
|
1130
1130
|
flex: 1 1 auto;
|
|
1131
1131
|
min-width: 0;
|
|
1132
1132
|
padding: 0;
|
|
@@ -1267,5 +1267,5 @@ ${t}`,!0;let r=e.host.ownerDocument.createElement("style");return Le(r),r.setAtt
|
|
|
1267
1267
|
transition: none;
|
|
1268
1268
|
}
|
|
1269
1269
|
}
|
|
1270
|
-
`+Qt+zt+cn,Mn="http://www.w3.org/2000/svg";function te(e,t,n=17){let r=e.createElementNS(Mn,"svg");r.setAttribute("viewBox","0 0 24 24"),r.setAttribute("aria-hidden","true"),r.setAttribute("width",String(n)),r.setAttribute("height",String(n));for(let o of typeof t=="string"?[t]:t){let i=e.createElementNS(Mn,"path");i.setAttribute("d",o),i.setAttribute("fill","none"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),r.appendChild(i);}return r}var Ao="M12 21a9 9 0 100-18 9 9 0 000 18zM12 7v5l3 2",Fn="M13 3L5 14h6l-1 7 8-11h-6l1-7z",Eo="M6 9l6 6 6-6",To="M18 6L6 18M6 6l12 12",_o=["M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z","M9 12a3 3 0 1 0 6 0 3 3 0 1 0-6 0"],So=["M19 13V19H13","M5 5L19 19"],Pn=["M5 8h10","M9 4v4","M12 20l4-9 4 9","M13.5 17h5","M13 8a10 10 0 0 1-8 8","M8 11a10 10 0 0 0 5 5"],Lo="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z";function Be(e,t){let n=e.style,r=t.bar.getMetrics(),o=t.getMaxHeightPercent?.()??xo,i=r.bottomOffset+r.keyboardOffset+r.height+8;if(n.setProperty("bottom",`${i}px`),n.setProperty("left","50%"),n.setProperty("translate","-50%"),n.setProperty("transform",we(r.offset)),r.isMobile){e.setAttribute("data-sheet",""),n.setProperty("width",`calc(100% - ${24}px)`),n.setProperty("max-width","none"),n.setProperty("height",`calc(100% - ${i+12}px)`),n.setProperty("max-height","none");return}e.removeAttribute("data-sheet");let s=Ne(r.widthPercent,{width:r.viewportWidth,height:r.viewportHeight});n.setProperty("width",`${s}px`),n.setProperty("max-width",`calc(100vw - ${32}px)`),n.setProperty("transform",we({x:$e(r.offset.x,s,r.viewportWidth),y:r.offset.y}));let h=i-r.offset.y,C=dn(o,r.viewportHeight,h);n.setProperty("height",`${C}px`),n.setProperty("max-height",`${C}px`);}function Io(e){try{let ee=function(){try{for(;Q.firstChild;)Q.removeChild(Q.firstChild);Q.style.setProperty("display",F.length>0?"flex":"none");let a=d().removeImage;for(let p of F){let f=c.createElement("div");if(f.className=J,f.setAttribute("data-state",p.attachment?"ready":"uploading"),p.previewUrl){let _=c.createElement("img");_.src=p.previewUrl,_.alt="",f.appendChild(_);}let b=c.createElement("button");b.type="button",b.setAttribute("aria-label",a),b.setAttribute("data-tip",a),b.appendChild(te(c,To,12)),b.addEventListener("click",()=>{F=F.filter(_=>_!==p),ht(p),ee();}),f.appendChild(b),Q.appendChild(f);}e.bar.setAttachmentCount(F.length);}catch{}},bt=function(){e.setConversationId?.(null),P.clear(),mt(),X();},ue=function(a){let p=ie;p&&(ie=null,oe.hide(),e.bar.setAwaitingInput?.(!1),e.bar.setDisabled(Te),e.bar.setPlaceholder(v()?.inputPlaceholder??null),p.resolve(a));},We=function(a){let p=ie;if(!p)return;let f=p.request,b=f.kind==="select"||f.kind==="radio"?hn(a,f.options):f.kind==="password"?a:a.trim(),_=fn(b,f);if(_!==null){oe.setError(_);return}ue(b);},xt=function(a){if(Te)return;let p=F.filter(f=>f.attachment!==null);F=F.filter(f=>f.attachment===null),ee(),P.addMessage("user",a,{images:p.length,imageUrls:p.map(f=>f.previewUrl).filter(f=>f!==null)}),X(),Te=!0,e.bar.setDisabled(!0),P.setPending(!0),bn({apiBase:e.apiBase??$,publicKey:e.publicKey??"",sessionId:e.getSessionId?.()??"",sessionToken:e.getSessionToken?.()??"",query:a,route:e.getRoute?.()??l?.location?.pathname??"",conversationId:e.getConversationId?.()??"",attachments:p.map(f=>({objectKey:f.attachment.objectKey}))}).then(f=>{let b=d();if(f.ok){P.addMessage("assistant",f.message,{messageId:f.messageId,citedSources:f.citedSources,flowOffers:f.flowsOffered}),e.touchConversation?.(),f.isFallback&&e.track?.("fallback_triggered",{},{question:a});for(let _ of f.flowsOffered)e.track?.("flow_suggested",{},{flowCvid:_.flowCvid});return}if(f.reason==="cap_denied"){vo.has(f.capReason)?e.onOrgCapExceeded?.():P.addMessage("system",b.userCapReached);return}P.addMessage("system",b.genericError);}).finally(()=>{Te=!1,P.setPending(!1),e.bar.setDisabled(!1);});},he=function(){if(!u.hasAttribute("data-open")){Ge(),ot(e.host,c,e.apiBase),e.bar.setMode("open"),Be(u,e),u.setAttribute("data-open","");try{let a=e.isolated?e.root:c,p=e.isolated?a.activeElement:c.activeElement;_e=(e.isolated?p!==null:!!(p&&e.host.contains(p)))?null:c.activeElement,e.bar.focusInput();}catch{}}},Ge=function(){let a=v(),p=d();O(),W(),ie||e.bar.setPlaceholder(a?.inputPlaceholder??null),e.bar.setAttachEnabled(a?.allowImageUpload===!0),e.bar.setDisclaimer(j());for(let[f,b]of [[x,p.historyTitle],[A,p.flowsTitle],[N,p.settingsTitle],[U,p.collapse]])f.setAttribute("aria-label",b),f.setAttribute("data-tip",b);for(let f of [D,G,B])f.setTexts({backLabel:p.back,closeLabel:p.closeSheet});X();},Et=function(){if(u.hasAttribute("data-open")){u.removeAttribute("data-open"),D.close(),G.close(),B.close(),Z="root",e.bar.setMode("idle"),e.bar.setDisclaimer(null);try{let a=_e;_e=null;let p=u.getRootNode();(p instanceof ShadowRoot?p.activeElement:document.activeElement!==null&&document.activeElement!==document.body)&&a&&a.isConnected&&typeof a.focus=="function"&&a.focus();}catch{}}};var t=ee,n=bt,r=ue,o=We,i=xt,s=he,h=Ge,C=Et;let g={host:e.host,root:e.root,isolated:e.isolated,destroy(){}};Ke(g,ko),Ke(g,pn);let c=e.host.ownerDocument,l=c.defaultView,v=()=>{try{return e.getWidget?.()??null}catch{return null}},d=()=>v()?.chrome??Rt,u=c.createElement("div");u.className=de,u.setAttribute("role","dialog"),u.setAttribute("aria-label","ARCY chat"),u.tabIndex=-1,u.style.setProperty("position","absolute","important"),u.style.setProperty("pointer-events","auto","important"),u.style.setProperty("box-sizing","border-box");let w=c.createElement("div");w.className=st;let m=(a,p,f)=>{let b=c.createElement("button");return b.type="button",b.className=He,b.setAttribute("aria-label",a),b.setAttribute("data-tip",a),b.setAttribute("data-tip-placement","below"),b.setAttribute("data-tip-align",f),b.appendChild(te(c,p)),b},x=m(d().historyTitle,Ao,"start"),A=m(d().flowsTitle,Fn,"start");A.style.setProperty("display","none");let E=c.createElement("div");E.className="arcy-chat-identity";let L=c.createElement("span"),H=c.createElement("span");H.className=$n,E.appendChild(L),E.appendChild(H);let N=m(d().settingsTitle,_o,"end");e.bar.dock||N.style.setProperty("display","none");let U=m(d().collapse,Eo,"end");w.appendChild(x),w.appendChild(A),w.appendChild(E),w.appendChild(N),w.appendChild(U);let O=()=>{let a=v(),p=Rn(a?.logoUrl,e.apiBase);if(H.textContent=p?"":a?.name??"",H.style.setProperty("display",p?"none":"block"),p&&L.getAttribute("data-src")===p)return;let f=p?c.createElement("img"):c.createElement("span");if(f.className=p?Nn:"",p){let b=f;b.alt=a?.name??"",b.decoding="async",b.onerror=()=>{try{let _=c.createElement("span");b.replaceWith(_),L=_,H.textContent=a?.name??"",H.style.setProperty("display","block");}catch{}},b.setAttribute("data-src",p),b.src=p;}L.replaceWith(f),L=f;},y=c.createElement("div");y.className=ne;let k=c.createElement("div");k.className=On;let T=c.createElement("a");T.className=Ce,T.href=wo,T.target="_blank",T.rel="noopener noreferrer";let I=c.createElement("span"),q=_n(c);q&&q.setAttribute("class",xe),T.appendChild(I),q&&T.appendChild(q),k.appendChild(T);let W=()=>{let a=d();I.textContent=a.poweredBy.replace(/\s*ARCY\s*$/i,""),T.setAttribute("aria-label",a.poweredBy);},j=()=>{let a=v(),p=d(),f=a?.privacyPolicyUrl,b=a?.name?p.aiDisclaimer.replace("{app}",a.name):p.aiDisclaimer;if(typeof f=="string"&&/^https:\/\//i.test(f)){let _=p.consentWithPolicy.indexOf("{policy}"),Y=_>=0?p.consentWithPolicy.slice(0,_):`${p.consentWithPolicy} `,R=_>=0?p.consentWithPolicy.slice(_+8):"";return {before:`${b}${p.disclaimerJoin}${Y}`,linkLabel:p.privacyPolicy,linkHref:f,after:R}}return b},pe=c.createElement("div");pe.className=Dn,pe.appendChild(y),u.appendChild(w),u.appendChild(pe),u.appendChild(k),e.root.appendChild(u),ot(e.host,c,e.apiBase),Be(u,e);let P=Jt(y,c,{labels:{likeAnswer:d().likeAnswer,dislikeAnswer:d().dislikeAnswer},answeringLabel:()=>d().answering,searchedSourcesLabel:d().searchedSourcesLabel,sourcesLabel:d().sourcesLabel,flowOfferHint:()=>d().flowOfferHint,onStartFlow:a=>{e.track?.("flow_pill_clicked",{},{flowCvid:a}),e.onStartFlow?.(a);},onFeedback:(a,p)=>{e.track?.("answer_feedback",{},{value:a});let f=e.getSessionToken?.()??"",b=e.getConversationId?.()??"";!p||!f||!b||Tn({apiBase:e.apiBase,sessionToken:f,conversationId:b,messageId:p,value:a,visitorId:e.getVisitorId?.()??void 0});}}),z=c.createElement("div");z.className=re,y.insertBefore(z,y.firstChild);let dt=[],ke=!0,pt=null,X=()=>{try{for(;z.firstChild;)z.removeChild(z.firstChild);if(!P.isEmpty()){z.style.setProperty("display","none");return}z.style.setProperty("display","flex");let a=v(),p=c.createElement("div");p.className="arcy-chat-welcome-icon";let f=Rn(a?.welcomeIconUrl,e.apiBase);if(f&&f!==pt){let R=c.createElement("img");R.src=f,R.alt="",R.addEventListener("error",()=>{pt=f,X();},{once:!0}),p.appendChild(R);}else p.appendChild(te(c,Lo,18));z.appendChild(p);let b=a?.welcomeHeadline?.trim()??"",_=a?.welcomeMessage?.trim()??"";if(b){let R=c.createElement("div");R.className="arcy-chat-headline",R.textContent=b,z.appendChild(R);}if(_){let R=c.createElement("div");R.className="arcy-chat-greeting",R.textContent=_,z.appendChild(R);}let Y=c.createElement("div");Y.className=lt,ke&&Y.setAttribute("data-pending","");for(let R of dt){let K=c.createElement("button");K.type="button",K.className=Ue,K.textContent=R.publicName,K.addEventListener("click",()=>{e.track?.("starter_flow_clicked",{},{flowCvid:R.cvid}),e.onStartFlow?.(R.cvid);}),Y.appendChild(K);}z.appendChild(Y);}catch{}},Q=c.createElement("div");Q.className=ct,Q.style.setProperty("display","none");let ut=e.bar.attachmentSlot?.()??null;ut?ut.appendChild(Q):y.insertBefore(Q,y.firstChild);let F=[],ft=Sn(c),Bn=ft.fetchImpl??(typeof fetch<"u"?fetch.bind(globalThis):null),Hn=a=>{try{return l?.URL?.createObjectURL?.(a)??URL.createObjectURL(a)}catch{return null}},ze=a=>{if(a.previewUrl){try{(l?.URL??URL).revokeObjectURL(a.previewUrl);}catch{}a.previewUrl=null;}},ht=a=>{ze(a);let p=a.attachment?.objectKey;p&&In(p,{apiBase:e.apiBase,sessionToken:e.getSessionToken?.()??"",fetchImpl:Bn});},mt=()=>{let a=F;F=[];for(let p of a)ht(p);ee();},Ae=Promise.resolve(),gt=a=>{Ae=Ae.then(async()=>{for(let p of a){let f=e.getSessionToken?.()??"",b=K=>{let Se=d();P.addMessage("system",K==="type"?Se.imageWrongType:K==="size"?Se.imageTooLarge:K==="count"?Se.imageTooMany:Se.imageFailed);},_=at(p,F.length);if(!_.ok){b(_.reason),X();continue}let Y={previewUrl:Hn(p),attachment:null};F=[...F,Y],ee();let R=await Ln(p,F.length-1,{apiBase:e.apiBase,sessionToken:f,env:ft});if(R.ok){Y.attachment=R.attachment,ee();continue}F=F.filter(K=>K!==Y),ze(Y),ee(),b(R.reason),X();}}),Ae=Ae.catch(()=>{});},Ve=[],D=Fe(u,c,{title:d().historyTitle,emptyText:d().historyEmpty,actionLabel:d().newChat,subtitleTips:!1,backLabel:d().back,closeLabel:d().closeSheet,onBack:()=>D.close(),onAction:()=>{bt(),D.close();},onSelect:a=>{if((e.getConversationId?.()??"")===a){D.close();return}e.setConversationId?.(a),P.clear(),mt(),X(),D.close(),Un(a);}});async function Un(a){let p=e.getSessionToken?.()??"";if(!p)return;let f=await En({apiBase:e.apiBase,sessionToken:p,conversationId:a,visitorId:e.getVisitorId?.()??void 0});if(f.ok&&(e.getConversationId?.()??"")===a){P.clear();for(let b of f.messages)P.addMessage(An(b.role),b.text,{images:b.images,at:b.occurredAt?new Date(b.occurredAt):void 0,messageId:b.id,feedback:b.feedback});X(),P.scrollToEnd();}}let G=Fe(u,c,{title:d().flowsTitle,emptyText:d().flowsEmpty,actionLabel:null,backLabel:d().back,closeLabel:d().closeSheet,itemIcon:a=>te(a,Fn,16),onBack:()=>G.close(),onSelect:a=>{G.close(),e.onStartFlow?.(a);}}),Z="root",B=Fe(u,c,{title:d().settingsTitle,side:"right",actionLabel:null,backLabel:d().back,closeLabel:d().closeSheet,onBack:()=>{if(Z==="language"){Z="root",Ee();return}B.close();},onSelect:a=>{if(Z==="language"){B.close(),Z="root",e.onSelectLocale?.(a);return}if(a==="language"){Z="language",Ee();return}a==="dock"&&(B.close(),e.onRequestClose(),e.bar.dock?.());}}),zn=()=>{if(!e.onSelectLocale)return [];let a=v()?.locales??[];return a.length>=2?a:[]},Ee=()=>{let a=d(),p=zn();if(Z==="language"){B.setTitle(a.language),B.setItems(p.map(b=>({id:b.code,title:b.label,active:b.code===v()?.activeLocale,icon:_=>te(_,Pn,16)})));return}B.setTitle(a.settingsTitle);let f=p.find(b=>b.code===v()?.activeLocale);B.setItems([...p.length?[{id:"language",title:a.language,subtitle:f?.label??null,icon:b=>te(b,Pn,16)}]:[],{id:"dock",title:a.dockChat,subtitle:a.dockChatHint,icon:b=>te(b,So,16)}]);},yt=()=>{let a=d();D.setTitle(a.historyTitle),D.setTexts({emptyText:a.historyEmpty,actionLabel:a.newChat}),D.setItems(it(Ve,a.imageConversation,e.getConversationId?.())),D.open(),Vn();};async function Vn(){let a=e.getSessionToken?.()??"",p=e.getVisitorId?.()??"";if(!a||!p)return;let f=await kn({apiBase:e.apiBase,sessionToken:a,visitorId:p});f.ok&&(Ve=f.conversations,D.isOpen()&&D.setItems(it(Ve,d().imageConversation,e.getConversationId?.())));}x.addEventListener("click",yt),A.addEventListener("click",()=>{let a=d();G.setTitle(a.flowsTitle),G.setTexts({emptyText:a.flowsEmpty}),G.open();});let wt=()=>{Z="root",Ee(),B.open();};N.addEventListener("click",wt);let vt=()=>e.onRequestClose();U.addEventListener("click",vt);let oe=un(e,()=>d()),ie=null,Te=!1;e.bar.onSubmit(a=>{if(ie){We(a);return}he(),xt(a);}),e.bar.onFiles?.(a=>{he(),gt(a);});let Wn=()=>v()?.allowImageUpload===!0,jn=a=>{Ye(a)&&a.preventDefault();},Gn=a=>{if(!Ye(a)||(a.preventDefault(),!Wn()))return;let p=Mt(a);p.length>0&>(p);};u.addEventListener("dragover",jn),u.addEventListener("drop",Gn);let fe=a=>{dt=a,ke=!1,X();},Ct=!1,je=()=>{if(Ct)return !0;let a=e.getSessionToken?.();return a?(Ct=!0,mn({apiBase:e.apiBase,sessionToken:a,sessionId:e.getSessionId?.()}).then(p=>{if(!p.ok){fe([]);return}let f=gn(p.flows);fe(p.starterFlows),f.length!==0&&(A.style.setProperty("display","flex"),G.setItems(f.map(b=>({id:b.cvid,title:b.publicName,subtitle:b.summary}))));}).catch(()=>{fe([]);}),!0):!1};if(!je())try{l?.setTimeout(()=>{!je()&&ke&&fe([]);},Co);}catch{}let kt=a=>{if(a.key==="Escape"){if(a.stopPropagation(),D.isOpen()){D.close();return}if(G.isOpen()){G.close();return}if(B.isOpen()){B.close();return}e.onRequestClose();}};u.addEventListener("keydown",kt);let At=()=>{u.hasAttribute("data-open")&&Be(u,e),oe.reposition();};l?.addEventListener("resize",At);let _e=null;return {open:he,close:Et,reposition(){u.hasAttribute("data-open")&&Be(u,e),oe.reposition();},refreshChrome(){!je()&&ke&&fe([]),u.hasAttribute("data-open")&&(Ge(),B.isOpen()&&Ee());},destroy(){x.removeEventListener("click",yt),N.removeEventListener("click",wt),U.removeEventListener("click",vt),u.removeEventListener("keydown",kt),l?.removeEventListener("resize",At),_e=null,ue(null),oe.destroy(),D.destroy(),G.destroy(),B.destroy(),P.destroy();for(let a of F)ze(a);F=[],Q.remove(),e.bar.setAttachmentCount(0),u.remove();},promptFill(a){return new Promise(p=>{ue(null),e.onRequestClose(),oe.show(a,{onAnswer:f=>We(f)}),e.bar.setAwaitingInput?.(!0),a.kind==="password"?e.bar.setDisabled(!0):(e.bar.setPlaceholder(a.question),e.bar.focusInput()),ie={resolve:p,request:a};})},cancelFill(){ue(null);},showFlowFailure(){he(),P.addMessage("assistant",d().flowFailed),X();}}}catch{return null}}var Ro={contract:4,mount:Io};if(typeof window<"u")try{window[Tt]=Ro;}catch{}
|
|
1271
|
-
exports.ARCY_HOME_URL=
|
|
1270
|
+
`+Jt+Vt+dn,Mn="http://www.w3.org/2000/svg";function te(e,t,n=17){let r=e.createElementNS(Mn,"svg");r.setAttribute("viewBox","0 0 24 24"),r.setAttribute("aria-hidden","true"),r.setAttribute("width",String(n)),r.setAttribute("height",String(n));for(let o of typeof t=="string"?[t]:t){let i=e.createElementNS(Mn,"path");i.setAttribute("d",o),i.setAttribute("fill","none"),i.setAttribute("stroke","currentColor"),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),r.appendChild(i);}return r}var To="M12 21a9 9 0 100-18 9 9 0 000 18zM12 7v5l3 2",Fn="M13 3L5 14h6l-1 7 8-11h-6l1-7z",_o="M6 9l6 6 6-6",So="M18 6L6 18M6 6l12 12",Lo=["M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z","M9 12a3 3 0 1 0 6 0 3 3 0 1 0-6 0"],Io=["M19 13V19H13","M5 5L19 19"],Pn=["M5 8h10","M9 4v4","M12 20l4-9 4 9","M13.5 17h5","M13 8a10 10 0 0 1-8 8","M8 11a10 10 0 0 0 5 5"],Ro="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z";function Be(e,t){let n=e.style,r=t.bar.getMetrics(),o=t.getMaxHeightPercent?.()??ko,i=r.bottomOffset+r.keyboardOffset+r.height+8;if(n.setProperty("bottom",`${i}px`),n.setProperty("left","50%"),n.setProperty("translate","-50%"),n.setProperty("transform",we(r.offset)),r.isMobile){e.setAttribute("data-sheet",""),n.setProperty("width",`calc(100% - ${24}px)`),n.setProperty("max-width","none"),n.setProperty("height",`calc(100% - ${i+12}px)`),n.setProperty("max-height","none");return}e.removeAttribute("data-sheet");let s=Ne(r.widthPercent,{width:r.viewportWidth,height:r.viewportHeight});n.setProperty("width",`${s}px`),n.setProperty("max-width",`calc(100vw - ${32}px)`),n.setProperty("transform",we({x:$e(r.offset.x,s,r.viewportWidth),y:r.offset.y}));let h=i-r.offset.y,C=pn(o,r.viewportHeight,h);n.setProperty("height",`${C}px`),n.setProperty("max-height",`${C}px`);}function Mo(e){try{let ee=function(){try{for(;Q.firstChild;)Q.removeChild(Q.firstChild);Q.style.setProperty("display",F.length>0?"flex":"none");let a=d().removeImage;for(let p of F){let f=c.createElement("div");if(f.className=J,f.setAttribute("data-state",p.attachment?"ready":"uploading"),p.previewUrl){let _=c.createElement("img");_.src=p.previewUrl,_.alt="",f.appendChild(_);}let b=c.createElement("button");b.type="button",b.setAttribute("aria-label",a),b.setAttribute("data-tip",a),b.appendChild(te(c,So,12)),b.addEventListener("click",()=>{F=F.filter(_=>_!==p),mt(p),ee();}),f.appendChild(b),Q.appendChild(f);}e.bar.setAttachmentCount(F.length);}catch{}},yt=function(){e.setConversationId?.(null),P.clear(),gt(),X();},ue=function(a){let p=ie;p&&(ie=null,oe.hide(),e.bar.setAwaitingInput?.(!1),e.bar.setDisabled(Te),e.bar.setPlaceholder(v()?.inputPlaceholder??null),p.resolve(a));},We=function(a){let p=ie;if(!p)return;let f=p.request,b=f.kind==="select"||f.kind==="radio"?mn(a,f.options):f.kind==="password"?a:a.trim(),_=hn(b,f);if(_!==null){oe.setError(_);return}ue(b);},Ct=function(a){if(Te)return;let p=F.filter(f=>f.attachment!==null);F=F.filter(f=>f.attachment===null),ee(),P.addMessage("user",a,{images:p.length,imageUrls:p.map(f=>f.previewUrl).filter(f=>f!==null)}),X(),Te=!0,e.bar.setDisabled(!0),P.setPending(!0),yn({apiBase:e.apiBase??D,publicKey:e.publicKey??"",sessionId:e.getSessionId?.()??"",sessionToken:e.getSessionToken?.()??"",query:a,route:e.getRoute?.()??l?.location?.pathname??"",conversationId:e.getConversationId?.()??"",attachments:p.map(f=>({objectKey:f.attachment.objectKey}))}).then(f=>{let b=d();if(f.ok){P.addMessage("assistant",f.message,{messageId:f.messageId,citedSources:f.citedSources,flowOffers:f.flowsOffered}),e.touchConversation?.(),f.isFallback&&e.track?.("fallback_triggered",{},{question:a});for(let _ of f.flowsOffered)e.track?.("flow_suggested",{},{flowCvid:_.flowCvid});return}if(f.reason==="cap_denied"){Co.has(f.capReason)?e.onOrgCapExceeded?.():P.addMessage("system",b.userCapReached);return}P.addMessage("system",b.genericError);}).finally(()=>{Te=!1,P.setPending(!1),e.bar.setDisabled(!1);});},he=function(){if(!u.hasAttribute("data-open")){Ge(),it(e.host,c,e.apiBase),e.bar.setMode("open"),Be(u,e),u.setAttribute("data-open","");try{let a=e.isolated?e.root:c,p=e.isolated?a.activeElement:c.activeElement;_e=(e.isolated?p!==null:!!(p&&e.host.contains(p)))?null:c.activeElement,e.bar.focusInput();}catch{}}},Ge=function(){let a=v(),p=d();$(),W(),ie||e.bar.setPlaceholder(a?.inputPlaceholder??null),e.bar.setAttachEnabled(a?.allowImageUpload===!0),e.bar.setDisclaimer(j());for(let[f,b]of [[x,p.historyTitle],[A,p.flowsTitle],[N,p.settingsTitle],[U,p.collapse]])f.setAttribute("aria-label",b),f.setAttribute("data-tip",b);for(let f of [O,G,B])f.setTexts({backLabel:p.back,closeLabel:p.closeSheet});X();},Tt=function(){if(u.hasAttribute("data-open")){u.removeAttribute("data-open"),O.close(),G.close(),B.close(),Z="root",e.bar.setMode("idle"),e.bar.setDisclaimer(null);try{let a=_e;_e=null;let p=u.getRootNode();(p instanceof ShadowRoot?p.activeElement:document.activeElement!==null&&document.activeElement!==document.body)&&a&&a.isConnected&&typeof a.focus=="function"&&a.focus();}catch{}}};var t=ee,n=yt,r=ue,o=We,i=Ct,s=he,h=Ge,C=Tt;let g={host:e.host,root:e.root,isolated:e.isolated,destroy(){}};Ke(g,Eo),Ke(g,un);let c=e.host.ownerDocument,l=c.defaultView,v=()=>{try{return e.getWidget?.()??null}catch{return null}},d=()=>v()?.chrome??Mt,u=c.createElement("div");u.className=de,u.setAttribute("role","dialog"),u.setAttribute("aria-label","ARCY chat"),u.tabIndex=-1,u.style.setProperty("position","absolute","important"),u.style.setProperty("pointer-events","auto","important"),u.style.setProperty("box-sizing","border-box");let w=c.createElement("div");w.className=lt;let m=(a,p,f)=>{let b=c.createElement("button");return b.type="button",b.className=He,b.setAttribute("aria-label",a),b.setAttribute("data-tip",a),b.setAttribute("data-tip-placement","below"),b.setAttribute("data-tip-align",f),b.appendChild(te(c,p)),b},x=m(d().historyTitle,To,"start"),A=m(d().flowsTitle,Fn,"start");A.style.setProperty("display","none");let E=c.createElement("div");E.className="arcy-chat-identity";let L=c.createElement("span"),H=c.createElement("span");H.className=$n,E.appendChild(L),E.appendChild(H);let N=m(d().settingsTitle,Lo,"end");e.bar.dock||N.style.setProperty("display","none");let U=m(d().collapse,_o,"end");w.appendChild(x),w.appendChild(A),w.appendChild(E),w.appendChild(N),w.appendChild(U);let $=()=>{let a=v(),p=ot(a?.logoUrl,e.apiBase);if(H.textContent=p?"":a?.name??"",H.style.setProperty("display",p?"none":"block"),p&&L.getAttribute("data-src")===p)return;let f=p?c.createElement("img"):c.createElement("span");if(f.className=p?Nn:"",p){let b=f;b.alt=a?.name??"",b.decoding="async",b.onerror=()=>{try{let _=c.createElement("span");b.replaceWith(_),L=_,H.textContent=a?.name??"",H.style.setProperty("display","block");}catch{}},b.setAttribute("data-src",p),b.src=p;}L.replaceWith(f),L=f;},y=c.createElement("div");y.className=ne;let k=c.createElement("div");k.className=On;let T=c.createElement("a");T.className=Ce,T.href=xo,T.target="_blank",T.rel="noopener noreferrer";let I=c.createElement("span"),q=Sn(c);q&&q.setAttribute("class",xe),T.appendChild(I),q&&T.appendChild(q),k.appendChild(T);let W=()=>{let a=d();I.textContent=a.poweredBy.replace(/\s*ARCY\s*$/i,""),T.setAttribute("aria-label",a.poweredBy);},j=()=>{let a=v(),p=d(),f=a?.privacyPolicyUrl,b=a?.name?p.aiDisclaimer.replace("{app}",a.name):p.aiDisclaimer;if(typeof f=="string"&&/^https:\/\//i.test(f)){let _=p.consentWithPolicy.indexOf("{policy}"),Y=_>=0?p.consentWithPolicy.slice(0,_):`${p.consentWithPolicy} `,R=_>=0?p.consentWithPolicy.slice(_+8):"";return {before:`${b}${p.disclaimerJoin}${Y}`,linkLabel:p.privacyPolicy,linkHref:f,after:R}}return b},pe=c.createElement("div");pe.className=Dn,pe.appendChild(y),u.appendChild(w),u.appendChild(pe),u.appendChild(k),e.root.appendChild(u),it(e.host,c,e.apiBase),Be(u,e);let P=Zt(y,c,{labels:{likeAnswer:d().likeAnswer,dislikeAnswer:d().dislikeAnswer},answeringLabel:()=>d().answering,searchedSourcesLabel:d().searchedSourcesLabel,sourcesLabel:d().sourcesLabel,flowOfferHint:()=>d().flowOfferHint,onStartFlow:a=>{e.track?.("flow_pill_clicked",{},{flowCvid:a}),e.onStartFlow?.(a);},onFeedback:(a,p)=>{e.track?.("answer_feedback",{},{value:a});let f=e.getSessionToken?.()??"",b=e.getConversationId?.()??"";!p||!f||!b||_n({apiBase:e.apiBase,sessionToken:f,conversationId:b,messageId:p,value:a,visitorId:e.getVisitorId?.()??void 0});}}),z=c.createElement("div");z.className=re,y.insertBefore(z,y.firstChild);let pt=[],ke=!0,ut=null,X=()=>{try{for(;z.firstChild;)z.removeChild(z.firstChild);if(!P.isEmpty()){z.style.setProperty("display","none");return}z.style.setProperty("display","flex");let a=v(),p=c.createElement("div");p.className="arcy-chat-welcome-icon";let f=ot(a?.welcomeIconUrl,e.apiBase);if(f&&f!==ut){let R=c.createElement("img");R.src=f,R.alt="",R.addEventListener("error",()=>{ut=f,X();},{once:!0}),p.appendChild(R);}else p.appendChild(te(c,Ro,18));z.appendChild(p);let b=a?.welcomeHeadline?.trim()??"",_=a?.welcomeMessage?.trim()??"";if(b){let R=c.createElement("div");R.className="arcy-chat-headline",R.textContent=b,z.appendChild(R);}if(_){let R=c.createElement("div");R.className="arcy-chat-greeting",R.textContent=_,z.appendChild(R);}let Y=c.createElement("div");Y.className=ct,ke&&Y.setAttribute("data-pending","");for(let R of pt){let K=c.createElement("button");K.type="button",K.className=Ue,K.textContent=R.publicName,K.addEventListener("click",()=>{e.track?.("starter_flow_clicked",{},{flowCvid:R.cvid}),e.onStartFlow?.(R.cvid);}),Y.appendChild(K);}z.appendChild(Y);}catch{}},Q=c.createElement("div");Q.className=dt,Q.style.setProperty("display","none");let ft=e.bar.attachmentSlot?.()??null;ft?ft.appendChild(Q):y.insertBefore(Q,y.firstChild);let F=[],ht=Ln(c),Bn=ht.fetchImpl??(typeof fetch<"u"?fetch.bind(globalThis):null),Hn=a=>{try{return l?.URL?.createObjectURL?.(a)??URL.createObjectURL(a)}catch{return null}},ze=a=>{if(a.previewUrl){try{(l?.URL??URL).revokeObjectURL(a.previewUrl);}catch{}a.previewUrl=null;}},mt=a=>{ze(a);let p=a.attachment?.objectKey;p&&Rn(p,{apiBase:e.apiBase,sessionToken:e.getSessionToken?.()??"",fetchImpl:Bn});},gt=()=>{let a=F;F=[];for(let p of a)mt(p);ee();},Ae=Promise.resolve(),bt=a=>{Ae=Ae.then(async()=>{for(let p of a){let f=e.getSessionToken?.()??"",b=K=>{let Se=d();P.addMessage("system",K==="type"?Se.imageWrongType:K==="size"?Se.imageTooLarge:K==="count"?Se.imageTooMany:Se.imageFailed);},_=st(p,F.length);if(!_.ok){b(_.reason),X();continue}let Y={previewUrl:Hn(p),attachment:null};F=[...F,Y],ee();let R=await In(p,F.length-1,{apiBase:e.apiBase,sessionToken:f,env:ht});if(R.ok){Y.attachment=R.attachment,ee();continue}F=F.filter(K=>K!==Y),ze(Y),ee(),b(R.reason),X();}}),Ae=Ae.catch(()=>{});},Ve=[],O=Fe(u,c,{title:d().historyTitle,emptyText:d().historyEmpty,actionLabel:d().newChat,subtitleTips:!1,backLabel:d().back,closeLabel:d().closeSheet,onBack:()=>O.close(),onAction:()=>{yt(),O.close();},onSelect:a=>{if((e.getConversationId?.()??"")===a){O.close();return}e.setConversationId?.(a),P.clear(),gt(),X(),O.close(),Un(a);}});async function Un(a){let p=e.getSessionToken?.()??"";if(!p)return;let f=await Tn({apiBase:e.apiBase,sessionToken:p,conversationId:a,visitorId:e.getVisitorId?.()??void 0});if(f.ok&&(e.getConversationId?.()??"")===a){P.clear();for(let b of f.messages)P.addMessage(En(b.role),b.text,{images:b.images,at:b.occurredAt?new Date(b.occurredAt):void 0,messageId:b.id,feedback:b.feedback});X(),P.scrollToEnd();}}let G=Fe(u,c,{title:d().flowsTitle,emptyText:d().flowsEmpty,actionLabel:null,backLabel:d().back,closeLabel:d().closeSheet,itemIcon:a=>te(a,Fn,16),onBack:()=>G.close(),onSelect:a=>{G.close(),e.onStartFlow?.(a);}}),Z="root",B=Fe(u,c,{title:d().settingsTitle,side:"right",actionLabel:null,backLabel:d().back,closeLabel:d().closeSheet,onBack:()=>{if(Z==="language"){Z="root",Ee();return}B.close();},onSelect:a=>{if(Z==="language"){B.close(),Z="root",e.onSelectLocale?.(a);return}if(a==="language"){Z="language",Ee();return}a==="dock"&&(B.close(),e.onRequestClose(),e.bar.dock?.());}}),zn=()=>{if(!e.onSelectLocale)return [];let a=v()?.locales??[];return a.length>=2?a:[]},Ee=()=>{let a=d(),p=zn();if(Z==="language"){B.setTitle(a.language),B.setItems(p.map(b=>({id:b.code,title:b.label,active:b.code===v()?.activeLocale,icon:_=>te(_,Pn,16)})));return}B.setTitle(a.settingsTitle);let f=p.find(b=>b.code===v()?.activeLocale);B.setItems([...p.length?[{id:"language",title:a.language,subtitle:f?.label??null,icon:b=>te(b,Pn,16)}]:[],{id:"dock",title:a.dockChat,subtitle:a.dockChatHint,icon:b=>te(b,Io,16)}]);},wt=()=>{let a=d();O.setTitle(a.historyTitle),O.setTexts({emptyText:a.historyEmpty,actionLabel:a.newChat}),O.setItems(at(Ve,a.imageConversation,e.getConversationId?.())),O.open(),Vn();};async function Vn(){let a=e.getSessionToken?.()??"",p=e.getVisitorId?.()??"";if(!a||!p)return;let f=await An({apiBase:e.apiBase,sessionToken:a,visitorId:p});f.ok&&(Ve=f.conversations,O.isOpen()&&O.setItems(at(Ve,d().imageConversation,e.getConversationId?.())));}x.addEventListener("click",wt),A.addEventListener("click",()=>{let a=d();G.setTitle(a.flowsTitle),G.setTexts({emptyText:a.flowsEmpty}),G.open();});let vt=()=>{Z="root",Ee(),B.open();};N.addEventListener("click",vt);let xt=()=>e.onRequestClose();U.addEventListener("click",xt);let oe=fn(e,()=>d()),ie=null,Te=!1;e.bar.onSubmit(a=>{if(ie){We(a);return}he(),Ct(a);}),e.bar.onFiles?.(a=>{he(),bt(a);});let Wn=()=>v()?.allowImageUpload===!0,jn=a=>{Ye(a)&&a.preventDefault();},Gn=a=>{if(!Ye(a)||(a.preventDefault(),!Wn()))return;let p=Ft(a);p.length>0&&bt(p);};u.addEventListener("dragover",jn),u.addEventListener("drop",Gn);let fe=a=>{pt=a,ke=!1,X();},kt=!1,je=()=>{if(kt)return !0;let a=e.getSessionToken?.();return a?(kt=!0,gn({apiBase:e.apiBase,sessionToken:a,sessionId:e.getSessionId?.()}).then(p=>{if(!p.ok){fe([]);return}let f=bn(p.flows);fe(p.starterFlows),f.length!==0&&(A.style.setProperty("display","flex"),G.setItems(f.map(b=>({id:b.cvid,title:b.publicName,subtitle:b.summary}))));}).catch(()=>{fe([]);}),!0):!1};if(!je())try{l?.setTimeout(()=>{!je()&&ke&&fe([]);},Ao);}catch{}let At=a=>{if(a.key==="Escape"){if(a.stopPropagation(),O.isOpen()){O.close();return}if(G.isOpen()){G.close();return}if(B.isOpen()){B.close();return}e.onRequestClose();}};u.addEventListener("keydown",At);let Et=()=>{u.hasAttribute("data-open")&&Be(u,e),oe.reposition();};l?.addEventListener("resize",Et);let _e=null;return {open:he,close:Tt,reposition(){u.hasAttribute("data-open")&&Be(u,e),oe.reposition();},refreshChrome(){!je()&&ke&&fe([]),u.hasAttribute("data-open")&&(Ge(),B.isOpen()&&Ee());},destroy(){x.removeEventListener("click",wt),N.removeEventListener("click",vt),U.removeEventListener("click",xt),u.removeEventListener("keydown",At),l?.removeEventListener("resize",Et),_e=null,ue(null),oe.destroy(),O.destroy(),G.destroy(),B.destroy(),P.destroy();for(let a of F)ze(a);F=[],Q.remove(),e.bar.setAttachmentCount(0),u.remove();},promptFill(a){return new Promise(p=>{ue(null),e.onRequestClose(),oe.show(a,{onAnswer:f=>We(f)}),e.bar.setAwaitingInput?.(!0),a.kind==="password"?e.bar.setDisabled(!0):(e.bar.setPlaceholder(a.question),e.bar.focusInput()),ie={resolve:p,request:a};})},cancelFill(){ue(null);},showFlowFailure(){he(),P.addMessage("assistant",d().flowFailed),X();}}}catch{return null}}var Fo={contract:4,mount:Mo};if(typeof window<"u")try{window[_t]=Fo;}catch{}
|
|
1271
|
+
exports.ARCY_HOME_URL=xo;exports.BODY_CLASS=ne;exports.CATALOG_RETRY_MS=Ao;exports.CHAT_CSS=Eo;exports.CHIPS_CLASS=dt;exports.CHIP_CLASS=J;exports.HEADER_BUTTON_CLASS=He;exports.HEADER_CLASS=lt;exports.HEADER_ICON_CLASS=Nn;exports.HEADER_NAME_CLASS=$n;exports.MAIN_CLASS=Dn;exports.MARK_CLASS=xe;exports.MARK_LINK_CLASS=Ce;exports.PANEL_CLASS=de;exports.POLICY_CLASS=$i;exports.STARTER_CLASS=Ue;exports.STARTER_ROW_CLASS=ct;exports.STRIP_CLASS=On;exports.WELCOME_CLASS=re;exports.mount=Mo;exports.resolveImageUrl=ot;return exports;})({});
|