ai12z 3.13.3 → 3.14.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/cjs/ai12z-bot.cjs.entry.js +107 -19
- package/dist/cjs/ai12z-chat-message.cjs.entry.js +17 -46
- package/dist/cjs/ai12z-knowledge-box.cjs.entry.js +14 -60
- package/dist/cjs/index.cjs.js +1 -0
- package/dist/cjs/styleSheetRegistry-7aecMygn.js +175 -0
- package/dist/collection/components/ai12z-bot/ai12z-bot.js +32 -13
- package/dist/collection/components/ai12z-knowledge-box/ai12z-knowledge-box.js +15 -61
- package/dist/collection/components/ai12z-knowledge-box/components/ai12z-chat-message.js +16 -46
- package/dist/collection/utils/liveagents/providers/salesforce.js +75 -6
- package/dist/collection/utils/styleSheetRegistry.js +169 -0
- package/dist/components/ai12z-bot.js +1 -1
- package/dist/components/ai12z-chat-message.js +1 -1
- package/dist/components/ai12z-chat.js +1 -1
- package/dist/components/ai12z-container.js +1 -1
- package/dist/components/ai12z-cta.js +1 -1
- package/dist/components/ai12z-form.js +1 -1
- package/dist/components/ai12z-inline-search.js +1 -1
- package/dist/components/ai12z-input-form.js +1 -1
- package/dist/components/ai12z-knowledge-box.js +1 -1
- package/dist/components/ai12z-search-panel.js +1 -1
- package/dist/components/audio-recorder.js +1 -1
- package/dist/components/dynamic-form.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/interaction-buttons.js +1 -1
- package/dist/components/item-list.js +1 -1
- package/dist/components/{p-DKxaam7U.js → p-3j2aDKYq.js} +1 -1
- package/dist/components/{p-BP8ig03d.js → p-AQ1MS6Ps.js} +1 -1
- package/dist/components/p-B9IJbo4G.js +1 -0
- package/dist/components/{p-DsZWeAcM.js → p-BWMhH2R1.js} +1 -1
- package/dist/components/{p-5UYwpNzl.js → p-BaXs0IIw.js} +1 -1
- package/dist/components/{p-Gr6Q2s96.js → p-Bnj1LjUJ.js} +1 -1
- package/dist/components/p-BwpiW24r.js +1 -0
- package/dist/components/{p-Bo3Ig8oX.js → p-BwqXbNCx.js} +1 -1
- package/dist/components/{p-D2nUK4Pa.js → p-COqFEHJ7.js} +1 -1
- package/dist/components/{p-DA32xa7d.js → p-Ci85xHWQ.js} +1 -1
- package/dist/components/{p-DUaZgAhA.js → p-CrfXJRIo.js} +1 -1
- package/dist/components/{p-DJ68HDol.js → p-DkRAkHLI.js} +2 -2
- package/dist/components/{p-ha1wIlZ-.js → p-Dubjoiw6.js} +1 -1
- package/dist/components/{p-C2wKkcYa.js → p-DvtUY5FW.js} +1 -1
- package/dist/components/{p-J--erGbY.js → p-dQEvevXk.js} +1 -1
- package/dist/{library/p-DAGa-uHD.js → components/p-g36mIk7k.js} +1 -1
- package/dist/components/p-m0Ed3g6I.js +1 -0
- package/dist/components/p-mBjDeFh_.js +1 -0
- package/dist/components/{p-q7YWDP9B.js → p-pOVc-eI8.js} +1 -1
- package/dist/components/{p-BCJzelr9.js → p-qwKoi5kn.js} +1 -1
- package/dist/components/{p-CKAp10SJ.js → p-xTOLReQF.js} +1 -1
- package/dist/components/privacy-modal.js +1 -1
- package/dist/components/search-results-page.js +1 -1
- package/dist/esm/ai12z-bot.entry.js +115 -27
- package/dist/esm/ai12z-category_2.entry.js +3 -3
- package/dist/esm/ai12z-chat-message.entry.js +17 -46
- package/dist/esm/ai12z-chat_2.entry.js +8 -8
- package/dist/esm/ai12z-container.entry.js +3 -3
- package/dist/esm/ai12z-cta.entry.js +4 -4
- package/dist/esm/ai12z-form.entry.js +2 -2
- package/dist/esm/ai12z-inline-search.entry.js +2 -2
- package/dist/esm/ai12z-knowledge-box.entry.js +18 -64
- package/dist/esm/ai12z-search-panel.entry.js +1 -1
- package/dist/esm/chat-avatar_6.entry.js +1 -1
- package/dist/esm/{ctaHelpers-BhM8KbEY.js → ctaHelpers-DrH6S5iU.js} +1 -1
- package/dist/esm/dynamic-form.entry.js +1 -1
- package/dist/esm/{index-BQKLwW-C.js → index-VWr-8RG8.js} +1 -1
- package/dist/esm/index.js +10 -9
- package/dist/esm/item-list.entry.js +2 -2
- package/dist/esm/{keyboard-shortcuts-Bd3LDe9j.js → keyboard-shortcuts-BhKv64FZ.js} +2 -2
- package/dist/esm/{parseHelper-9rP0JS7J.js → parseHelper-kOGOndOe.js} +1 -1
- package/dist/esm/{processCarouselData-Bf2pDFsV.js → processCarouselData-DX152a4X.js} +1 -1
- package/dist/esm/{reCaptchaHelpers-CUcgfdqX.js → reCaptchaHelpers-DUpCzUFb.js} +1 -1
- package/dist/esm/search-results-page.entry.js +4 -4
- package/dist/esm/{socket-service-B1OMbkCM.js → socket-service-D_h5x8Gr.js} +1 -1
- package/dist/esm/styleSheetRegistry-Bfi9VkqK.js +172 -0
- package/dist/esm/{surveyHelpers-CvrZlir1.js → surveyHelpers-D-00eWjv.js} +1 -1
- package/dist/esm/{utils-BTLjNTwP.js → utils-DK_Yhmpx.js} +1 -1
- package/dist/library/index.esm.js +1 -1
- package/dist/library/library.esm.js +1 -1
- package/dist/library/{p-cd764f70.entry.js → p-11c1f91d.entry.js} +1 -1
- package/dist/library/{p-806bfb3d.entry.js → p-1d382046.entry.js} +1 -1
- package/dist/library/{p-0641ba91.entry.js → p-252bb713.entry.js} +2 -2
- package/dist/library/p-25a678ca.entry.js +1 -0
- package/dist/library/p-53edf210.entry.js +1 -0
- package/dist/library/p-646a7eae.entry.js +1 -0
- package/dist/library/p-675d0243.entry.js +1 -0
- package/dist/library/{p-60d5d99f.entry.js → p-6ea05db1.entry.js} +1 -1
- package/dist/library/{p-7f0e306c.entry.js → p-7154a204.entry.js} +1 -1
- package/dist/library/{p-07f11cb8.entry.js → p-72a5eaf2.entry.js} +1 -1
- package/dist/library/{p-2d262192.entry.js → p-8f238b3f.entry.js} +1 -1
- package/dist/library/p-9cffb6fa.entry.js +1 -0
- package/dist/library/{p-y3Go1NSi.js → p-BCkDiHIY.js} +1 -1
- package/dist/{components/p-BhV62IFF.js → library/p-By1gJKXA.js} +1 -1
- package/dist/library/{p-Bbow4UZX.js → p-C0wNDqKO.js} +1 -1
- package/dist/library/p-C3yxqbFh.js +1 -0
- package/dist/library/p-CwZwG6gL.js +1 -0
- package/dist/library/{p-D5m1leH0.js → p-D1IPrgJe.js} +3 -3
- package/dist/library/{p-NAKC5NP9.js → p-KSKiM1sy.js} +1 -1
- package/dist/library/{p-C1eU4fpM.js → p-TJuczvVq.js} +1 -1
- package/dist/library/{p-CnadO0kA.js → p-ZyOWOLs5.js} +1 -1
- package/dist/library/{p-94bf0c7f.entry.js → p-cbfc9f73.entry.js} +1 -1
- package/dist/library/{p-014d5664.entry.js → p-d8506e43.entry.js} +1 -1
- package/dist/library/{p-BZ_koFpE.js → p-n8ydBHE4.js} +1 -1
- package/dist/types/components/ai12z-bot/ai12z-bot.d.ts +1 -0
- package/dist/types/components/ai12z-knowledge-box/ai12z-knowledge-box.d.ts +0 -3
- package/dist/types/components/ai12z-knowledge-box/components/ai12z-chat-message.d.ts +0 -2
- package/dist/types/utils/liveagents/providers/salesforce.d.ts +2 -0
- package/dist/types/utils/styleSheetRegistry.d.ts +40 -0
- package/package.json +2 -2
- package/dist/components/p-B3lv_O-6.js +0 -1
- package/dist/components/p-CLdlCTTp.js +0 -1
- package/dist/components/p-DT0Uarfg.js +0 -1
- package/dist/components/p-zVXADzTq.js +0 -1
- package/dist/library/p-29cd4edc.entry.js +0 -1
- package/dist/library/p-6f3727d3.entry.js +0 -1
- package/dist/library/p-83a71da9.entry.js +0 -1
- package/dist/library/p-DoBD_KPG.js +0 -1
- package/dist/library/p-d3a2acee.entry.js +0 -1
- package/dist/library/p-dc131a5c.entry.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as t,a as e,E as n,e as i,h as r,d as o}from"./p-BNpVu1WU.js";import{
|
|
2
|
-
/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */const{entries:h,setPrototypeOf:g,isFrozen:y,getPrototypeOf:w,getOwnPropertyDescriptor:b}=Object;let{freeze:v,seal:x,create:k}=Object,{apply:T,construct:A}="undefined"!=typeof Reflect&&Reflect;v||(v=function(t){return t}),x||(x=function(t){return t}),T||(T=function(t,e){for(var n=arguments.length,i=new Array(n>2?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];return t.apply(e,i)}),A||(A=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return new t(...n)});const S=U(Array.prototype.forEach),E=U(Array.prototype.lastIndexOf),R=U(Array.prototype.pop),_=U(Array.prototype.push),D=U(Array.prototype.splice),z=U(String.prototype.toLowerCase),L=U(String.prototype.toString),O=U(String.prototype.match),P=U(String.prototype.replace),M=U(String.prototype.indexOf),F=U(String.prototype.trim),N=U(Object.prototype.hasOwnProperty),C=U(RegExp.prototype.test),I=(j=TypeError,function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return A(j,e)});var j;function U(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return T(t,e,i)}}function B(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:z;g&&g(t,null);let i=e.length;for(;i--;){let r=e[i];if("string"==typeof r){const t=n(r);t!==r&&(y(e)||(e[i]=t),r=t)}t[r]=!0}return t}function q(t){for(let e=0;e<t.length;e++)N(t,e)||(t[e]=null);return t}function W(t){const e=k(null);for(const[n,i]of h(t))N(t,n)&&(e[n]=Array.isArray(i)?q(i):i&&"object"==typeof i&&i.constructor===Object?W(i):i);return e}function $(t,e){for(;null!==t;){const n=b(t,e);if(n){if(n.get)return U(n.get);if("function"==typeof n.value)return U(n.value)}t=w(t)}return function(){return null}}const H=v(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),G=v(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Y=v(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),K=v(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),X=v(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),V=v(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Q=v(["#text"]),J=v(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Z=v(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),tt=v(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),et=v(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),nt=x(/\{\{[\w\W]*|[\w\W]*\}\}/gm),it=x(/<%[\w\W]*|[\w\W]*%>/gm),rt=x(/\$\{[\w\W]*/gm),ot=x(/^data-[\-\w.\u00B7-\uFFFF]+$/),at=x(/^aria-[\-\w]+$/),st=x(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),lt=x(/^(?:\w+script|data):/i),ct=x(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ut=x(/^html$/i),ft=x(/^[a-z][.\w]*(-[.\w]+)+$/i);var dt=Object.freeze({__proto__:null,ARIA_ATTR:at,ATTR_WHITESPACE:ct,CUSTOM_ELEMENT:ft,DATA_ATTR:ot,DOCTYPE_NAME:ut,ERB_EXPR:it,IS_ALLOWED_URI:st,IS_SCRIPT_OR_DATA:lt,MUSTACHE_EXPR:nt,TMPLIT_EXPR:rt});const pt=function(){return"undefined"==typeof window?null:window};var mt=function t(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:pt();const n=e=>t(e);if(n.version="3.3.3",n.removed=[],!e||!e.document||9!==e.document.nodeType||!e.Element)return n.isSupported=!1,n;let{document:i}=e;const r=i,o=r.currentScript,{DocumentFragment:a,HTMLTemplateElement:s,Node:l,Element:c,NodeFilter:u,NamedNodeMap:f=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:p,trustedTypes:m}=e,g=c.prototype,y=$(g,"cloneNode"),w=$(g,"remove"),b=$(g,"nextSibling"),x=$(g,"childNodes"),T=$(g,"parentNode");if("function"==typeof s){const t=i.createElement("template");t.content&&t.content.ownerDocument&&(i=t.content.ownerDocument)}let A,j="";const{implementation:U,createNodeIterator:q,createDocumentFragment:nt,getElementsByTagName:it}=i,{importNode:rt}=r;let ot={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof h&&"function"==typeof T&&U&&void 0!==U.createHTMLDocument;const{MUSTACHE_EXPR:at,ERB_EXPR:lt,TMPLIT_EXPR:ct,DATA_ATTR:ft,ARIA_ATTR:mt,IS_SCRIPT_OR_DATA:ht,ATTR_WHITESPACE:gt,CUSTOM_ELEMENT:yt}=dt;let{IS_ALLOWED_URI:wt}=dt,bt=null;const vt=B({},[...H,...G,...Y,...X,...Q]);let xt=null;const kt=B({},[...J,...Z,...tt,...et]);let Tt=Object.seal(k(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),At=null,St=null;const Et=Object.seal(k(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Rt=!0,_t=!0,Dt=!1,zt=!0,Lt=!1,Ot=!0,Pt=!1,Mt=!1,Ft=!1,Nt=!1,Ct=!1,It=!1,jt=!0,Ut=!1,Bt=!0,qt=!1,Wt={},$t=null;const Ht=B({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Gt=null;const Yt=B({},["audio","video","img","source","image","track"]);let Kt=null;const Xt=B({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Vt="http://www.w3.org/1998/Math/MathML",Qt="http://www.w3.org/2000/svg",Jt="http://www.w3.org/1999/xhtml";let Zt=Jt,te=!1,ee=null;const ne=B({},[Vt,Qt,Jt],L);let ie=B({},["mi","mo","mn","ms","mtext"]),re=B({},["annotation-xml"]);const oe=B({},["title","style","font","a","script"]);let ae=null;const se=["application/xhtml+xml","text/html"];let le=null,ce=null;const ue=i.createElement("form"),fe=function(t){return t instanceof RegExp||t instanceof Function},de=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!ce||ce!==t){if(t&&"object"==typeof t||(t={}),t=W(t),ae=-1===se.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,le="application/xhtml+xml"===ae?L:z,bt=N(t,"ALLOWED_TAGS")?B({},t.ALLOWED_TAGS,le):vt,xt=N(t,"ALLOWED_ATTR")?B({},t.ALLOWED_ATTR,le):kt,ee=N(t,"ALLOWED_NAMESPACES")?B({},t.ALLOWED_NAMESPACES,L):ne,Kt=N(t,"ADD_URI_SAFE_ATTR")?B(W(Xt),t.ADD_URI_SAFE_ATTR,le):Xt,Gt=N(t,"ADD_DATA_URI_TAGS")?B(W(Yt),t.ADD_DATA_URI_TAGS,le):Yt,$t=N(t,"FORBID_CONTENTS")?B({},t.FORBID_CONTENTS,le):Ht,At=N(t,"FORBID_TAGS")?B({},t.FORBID_TAGS,le):W({}),St=N(t,"FORBID_ATTR")?B({},t.FORBID_ATTR,le):W({}),Wt=!!N(t,"USE_PROFILES")&&t.USE_PROFILES,Rt=!1!==t.ALLOW_ARIA_ATTR,_t=!1!==t.ALLOW_DATA_ATTR,Dt=t.ALLOW_UNKNOWN_PROTOCOLS||!1,zt=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,Lt=t.SAFE_FOR_TEMPLATES||!1,Ot=!1!==t.SAFE_FOR_XML,Pt=t.WHOLE_DOCUMENT||!1,Nt=t.RETURN_DOM||!1,Ct=t.RETURN_DOM_FRAGMENT||!1,It=t.RETURN_TRUSTED_TYPE||!1,Ft=t.FORCE_BODY||!1,jt=!1!==t.SANITIZE_DOM,Ut=t.SANITIZE_NAMED_PROPS||!1,Bt=!1!==t.KEEP_CONTENT,qt=t.IN_PLACE||!1,wt=t.ALLOWED_URI_REGEXP||st,Zt=t.NAMESPACE||Jt,ie=t.MATHML_TEXT_INTEGRATION_POINTS||ie,re=t.HTML_INTEGRATION_POINTS||re,Tt=t.CUSTOM_ELEMENT_HANDLING||{},t.CUSTOM_ELEMENT_HANDLING&&fe(t.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Tt.tagNameCheck=t.CUSTOM_ELEMENT_HANDLING.tagNameCheck),t.CUSTOM_ELEMENT_HANDLING&&fe(t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Tt.attributeNameCheck=t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),t.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Tt.allowCustomizedBuiltInElements=t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Lt&&(_t=!1),Ct&&(Nt=!0),Wt&&(bt=B({},Q),xt=k(null),!0===Wt.html&&(B(bt,H),B(xt,J)),!0===Wt.svg&&(B(bt,G),B(xt,Z),B(xt,et)),!0===Wt.svgFilters&&(B(bt,Y),B(xt,Z),B(xt,et)),!0===Wt.mathMl&&(B(bt,X),B(xt,tt),B(xt,et))),N(t,"ADD_TAGS")||(Et.tagCheck=null),N(t,"ADD_ATTR")||(Et.attributeCheck=null),t.ADD_TAGS&&("function"==typeof t.ADD_TAGS?Et.tagCheck=t.ADD_TAGS:(bt===vt&&(bt=W(bt)),B(bt,t.ADD_TAGS,le))),t.ADD_ATTR&&("function"==typeof t.ADD_ATTR?Et.attributeCheck=t.ADD_ATTR:(xt===kt&&(xt=W(xt)),B(xt,t.ADD_ATTR,le))),t.ADD_URI_SAFE_ATTR&&B(Kt,t.ADD_URI_SAFE_ATTR,le),t.FORBID_CONTENTS&&($t===Ht&&($t=W($t)),B($t,t.FORBID_CONTENTS,le)),t.ADD_FORBID_CONTENTS&&($t===Ht&&($t=W($t)),B($t,t.ADD_FORBID_CONTENTS,le)),Bt&&(bt["#text"]=!0),Pt&&B(bt,["html","head","body"]),bt.table&&(B(bt,["tbody"]),delete At.tbody),t.TRUSTED_TYPES_POLICY){if("function"!=typeof t.TRUSTED_TYPES_POLICY.createHTML)throw I('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof t.TRUSTED_TYPES_POLICY.createScriptURL)throw I('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');A=t.TRUSTED_TYPES_POLICY,j=A.createHTML("")}else void 0===A&&(A=function(t,e){if("object"!=typeof t||"function"!=typeof t.createPolicy)return null;let n=null;const i="data-tt-policy-suffix";e&&e.hasAttribute(i)&&(n=e.getAttribute(i));const r="dompurify"+(n?"#"+n:"");try{return t.createPolicy(r,{createHTML:t=>t,createScriptURL:t=>t})}catch(t){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(m,o)),null!==A&&"string"==typeof j&&(j=A.createHTML(""));v&&v(t),ce=t}},pe=B({},[...G,...Y,...K]),me=B({},[...X,...V]),he=function(t){_(n.removed,{element:t});try{T(t).removeChild(t)}catch(e){w(t)}},ge=function(t,e){try{_(n.removed,{attribute:e.getAttributeNode(t),from:e})}catch(t){_(n.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t)if(Nt||Ct)try{he(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},ye=function(t){let e=null,n=null;if(Ft)t="<remove></remove>"+t;else{const e=O(t,/^[\r\n\t ]+/);n=e&&e[0]}"application/xhtml+xml"===ae&&Zt===Jt&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");const r=A?A.createHTML(t):t;if(Zt===Jt)try{e=(new p).parseFromString(r,ae)}catch(t){}if(!e||!e.documentElement){e=U.createDocument(Zt,"template",null);try{e.documentElement.innerHTML=te?j:r}catch(t){}}const o=e.body||e.documentElement;return t&&n&&o.insertBefore(i.createTextNode(n),o.childNodes[0]||null),Zt===Jt?it.call(e,Pt?"html":"body")[0]:Pt?e.documentElement:o},we=function(t){return q.call(t.ownerDocument||t,t,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},be=function(t){return t instanceof d&&("string"!=typeof t.nodeName||"string"!=typeof t.textContent||"function"!=typeof t.removeChild||!(t.attributes instanceof f)||"function"!=typeof t.removeAttribute||"function"!=typeof t.setAttribute||"string"!=typeof t.namespaceURI||"function"!=typeof t.insertBefore||"function"!=typeof t.hasChildNodes)},ve=function(t){return"function"==typeof l&&t instanceof l};function xe(t,e,i){S(t,(t=>{t.call(n,e,i,ce)}))}const ke=function(t){let e=null;if(xe(ot.beforeSanitizeElements,t,null),be(t))return he(t),!0;const i=le(t.nodeName);if(xe(ot.uponSanitizeElement,t,{tagName:i,allowedTags:bt}),Ot&&t.hasChildNodes()&&!ve(t.firstElementChild)&&C(/<[/\w!]/g,t.innerHTML)&&C(/<[/\w!]/g,t.textContent))return he(t),!0;if(7===t.nodeType)return he(t),!0;if(Ot&&8===t.nodeType&&C(/<[/\w]/g,t.data))return he(t),!0;if(!(Et.tagCheck instanceof Function&&Et.tagCheck(i))&&(!bt[i]||At[i])){if(!At[i]&&Ae(i)){if(Tt.tagNameCheck instanceof RegExp&&C(Tt.tagNameCheck,i))return!1;if(Tt.tagNameCheck instanceof Function&&Tt.tagNameCheck(i))return!1}if(Bt&&!$t[i]){const e=T(t)||t.parentNode,n=x(t)||t.childNodes;if(n&&e)for(let i=n.length-1;i>=0;--i){const r=y(n[i],!0);r.__removalCount=(t.__removalCount||0)+1,e.insertBefore(r,b(t))}}return he(t),!0}return t instanceof c&&!function(t){let e=T(t);e&&e.tagName||(e={namespaceURI:Zt,tagName:"template"});const n=z(t.tagName),i=z(e.tagName);return!!ee[t.namespaceURI]&&(t.namespaceURI===Qt?e.namespaceURI===Jt?"svg"===n:e.namespaceURI===Vt?"svg"===n&&("annotation-xml"===i||ie[i]):Boolean(pe[n]):t.namespaceURI===Vt?e.namespaceURI===Jt?"math"===n:e.namespaceURI===Qt?"math"===n&&re[i]:Boolean(me[n]):t.namespaceURI===Jt?!(e.namespaceURI===Qt&&!re[i])&&!(e.namespaceURI===Vt&&!ie[i])&&!me[n]&&(oe[n]||!pe[n]):!("application/xhtml+xml"!==ae||!ee[t.namespaceURI]))}(t)?(he(t),!0):"noscript"!==i&&"noembed"!==i&&"noframes"!==i||!C(/<\/no(script|embed|frames)/i,t.innerHTML)?(Lt&&3===t.nodeType&&(e=t.textContent,S([at,lt,ct],(t=>{e=P(e,t," ")})),t.textContent!==e&&(_(n.removed,{element:t.cloneNode()}),t.textContent=e)),xe(ot.afterSanitizeElements,t,null),!1):(he(t),!0)},Te=function(t,e,n){if(St[e])return!1;if(jt&&("id"===e||"name"===e)&&(n in i||n in ue))return!1;if(_t&&!St[e]&&C(ft,e));else if(Rt&&C(mt,e));else if(Et.attributeCheck instanceof Function&&Et.attributeCheck(e,t));else if(!xt[e]||St[e]){if(!(Ae(t)&&(Tt.tagNameCheck instanceof RegExp&&C(Tt.tagNameCheck,t)||Tt.tagNameCheck instanceof Function&&Tt.tagNameCheck(t))&&(Tt.attributeNameCheck instanceof RegExp&&C(Tt.attributeNameCheck,e)||Tt.attributeNameCheck instanceof Function&&Tt.attributeNameCheck(e,t))||"is"===e&&Tt.allowCustomizedBuiltInElements&&(Tt.tagNameCheck instanceof RegExp&&C(Tt.tagNameCheck,n)||Tt.tagNameCheck instanceof Function&&Tt.tagNameCheck(n))))return!1}else if(Kt[e]);else if(C(wt,P(n,gt,"")));else if("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==M(n,"data:")||!Gt[t])if(Dt&&!C(ht,P(n,gt,"")));else if(n)return!1;return!0},Ae=function(t){return"annotation-xml"!==t&&O(t,yt)},Se=function(t){xe(ot.beforeSanitizeAttributes,t,null);const{attributes:e}=t;if(!e||be(t))return;const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:xt,forceKeepAttr:void 0};let r=e.length;for(;r--;){const o=e[r],{name:a,namespaceURI:s,value:l}=o,c=le(a),u=l;let f="value"===a?u:F(u);if(i.attrName=c,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,xe(ot.uponSanitizeAttribute,t,i),f=i.attrValue,!Ut||"id"!==c&&"name"!==c||(ge(a,t),f="user-content-"+f),Ot&&C(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,f)){ge(a,t);continue}if("attributename"===c&&O(f,"href")){ge(a,t);continue}if(i.forceKeepAttr)continue;if(!i.keepAttr){ge(a,t);continue}if(!zt&&C(/\/>/i,f)){ge(a,t);continue}Lt&&S([at,lt,ct],(t=>{f=P(f,t," ")}));const d=le(t.nodeName);if(Te(d,c,f)){if(A&&"object"==typeof m&&"function"==typeof m.getAttributeType)if(s);else switch(m.getAttributeType(d,c)){case"TrustedHTML":f=A.createHTML(f);break;case"TrustedScriptURL":f=A.createScriptURL(f)}if(f!==u)try{s?t.setAttributeNS(s,a,f):t.setAttribute(a,f),be(t)?he(t):R(n.removed)}catch(e){ge(a,t)}}else ge(a,t)}xe(ot.afterSanitizeAttributes,t,null)},Ee=function t(e){let n=null;const i=we(e);for(xe(ot.beforeSanitizeShadowDOM,e,null);n=i.nextNode();)xe(ot.uponSanitizeShadowNode,n,null),ke(n),Se(n),n.content instanceof a&&t(n.content);xe(ot.afterSanitizeShadowDOM,e,null)};return n.sanitize=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null,o=null,s=null,c=null;if(te=!t,te&&(t="\x3c!--\x3e"),"string"!=typeof t&&!ve(t)){if("function"!=typeof t.toString)throw I("toString is not a function");if("string"!=typeof(t=t.toString()))throw I("dirty is not a string, aborting")}if(!n.isSupported)return t;if(Mt||de(e),n.removed=[],"string"==typeof t&&(qt=!1),qt){if(t.nodeName){const e=le(t.nodeName);if(!bt[e]||At[e])throw I("root node is forbidden and cannot be sanitized in-place")}}else if(t instanceof l)i=ye("\x3c!----\x3e"),o=i.ownerDocument.importNode(t,!0),1===o.nodeType&&"BODY"===o.nodeName||"HTML"===o.nodeName?i=o:i.appendChild(o);else{if(!Nt&&!Lt&&!Pt&&-1===t.indexOf("<"))return A&&It?A.createHTML(t):t;if(i=ye(t),!i)return Nt?null:It?j:""}i&&Ft&&he(i.firstChild);const u=we(qt?t:i);for(;s=u.nextNode();)ke(s),Se(s),s.content instanceof a&&Ee(s.content);if(qt)return t;if(Nt){if(Ct)for(c=nt.call(i.ownerDocument);i.firstChild;)c.appendChild(i.firstChild);else c=i;return(xt.shadowroot||xt.shadowrootmode)&&(c=rt.call(r,c,!0)),c}let f=Pt?i.outerHTML:i.innerHTML;return Pt&&bt["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&C(ut,i.ownerDocument.doctype.name)&&(f="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+f),Lt&&S([at,lt,ct],(t=>{f=P(f,t," ")})),A&&It?A.createHTML(f):f},n.setConfig=function(){de(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Mt=!0},n.clearConfig=function(){ce=null,Mt=!1},n.isValidAttribute=function(t,e,n){ce||de({});const i=le(t),r=le(e);return Te(i,r,n)},n.addHook=function(t,e){"function"==typeof e&&_(ot[t],e)},n.removeHook=function(t,e){if(void 0!==e){const n=E(ot[t],e);return-1===n?void 0:D(ot[t],n,1)[0]}return R(ot[t])},n.removeHooks=function(t){ot[t]=[]},n.removeAllHooks=function(){ot={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}();const ht=class{constructor(r){t(this,r),this.responseReceived=e(this,"responseReceived",7),this.errored=e(this,"errored",7),this.isDisconnected=!1,this.dataKey=n.DATA_KEY||"",this.dataMode=n.DATA_MODE||"prod",this.keyName="",this.instanceId="",this.renderType="integration",this.contentTemplate="",this.isLoading=!1,this.error="",this.contentText="",this.htmlWidgetMarkup="",this.domId=`widget-${a()}`,this.registrationKey="",this.requestVersion=0,this.lastKbResponse=null,this.markAsActive=()=>{this.registrationKey&&i.setActive(this.registrationKey)},this.initializeScript=t=>(this.markAsActive(),f(t,this.mainObject))}get mainObject(){return window.ai12z||(window.ai12z={}),window.ai12z}getResolvedKeyName(){var t,e,n,i,r;const o=null===(t=this.keyName)||void 0===t?void 0:t.trim(),a=(null===(n=null===(e=this.el)||void 0===e?void 0:e.getAttribute("key-name"))||void 0===n?void 0:n.trim())||"";if(o)return o;if(a)return a;if("undefined"==typeof window)return"";const s=new URLSearchParams(window.location.search);return(null===(i=s.get("keyName"))||void 0===i?void 0:i.trim())||(null===(r=s.get("keyname"))||void 0===r?void 0:r.trim())||""}waitForNextPaint(t=0){return new Promise((e=>{requestAnimationFrame((()=>{t>0?setTimeout((()=>e()),t):e()}))}))}async renderControl(t){switch(await this.waitForNextPaint(ht.CONTAINER_MOUNT_DELAY_MS),this.renderType){case"carousel":await u({id:`carousel-${this.domId}`},{controlData:t},this.el,(t=>this.hideSpinner(t)),(()=>{}),t.scripts,t.styles,!1,"widget");break;case"template":let e=!1;await new Promise((n=>{const i=()=>{e||(e=!0,n())};d({id:`html-${this.domId}`},{controlData:t,controlType:t.controlType},this.el.shadowRoot,(t=>this.hideSpinner(t)),(async t=>{await this.renderTemplateData(t),i()}),(()=>{this.markAsActive()}),m).then(i)}));break;case"content":{this.lastKbResponse=t;const e=null==t?void 0:t.data;if(!e){this.error="Knowledge base content unavailable.",this.errored.emit(this.error);break}let{question:n="",answer:i=""}=e;if(i=(new c.Converter).makeHtml(i),n=(new c.Converter).makeHtml(n),this.contentTemplate){const t=m.compile(this.contentTemplate);this.contentText=t({question:n,answer:i}),this.contentText=mt.sanitize(this.contentText)}else this.contentText=mt.sanitize(i);break}}}async componentWillLoad(){var t;this.registrationKey=(null===(t=this.instanceId)||void 0===t?void 0:t.trim())||`container-${this.domId}`,i.register(this.registrationKey,this),(this.getResolvedKeyName()&&void 0!==this.parameters||"content"===this.renderType)&&await this.invokeApi()}componentDidLoad(){"undefined"==typeof window||window.Handlebars||(window.Handlebars=m),this.el.addEventListener("focusin",this.markAsActive),this.el.addEventListener("pointerenter",this.markAsActive)}disconnectedCallback(){this.el.removeEventListener("focusin",this.markAsActive),this.el.removeEventListener("pointerenter",this.markAsActive),this.isDisconnected=!0,this.registrationKey&&i.unregister(this.registrationKey)}async onParametersChanged(t,e){t!==e&&this.getResolvedKeyName()&&await this.invokeApi(t)}onContentTemplateChanged(){if("content"!==this.renderType||!this.lastKbResponse)return;const{question:t="",answer:e=""}=this.lastKbResponse.data||{},n=this.contentTemplate?m.compile(this.contentTemplate)({question:t,answer:e}):e;this.contentText=mt.sanitize(n)}async invokeApi(t=this.parameters){this.error="";const e=++this.requestVersion,n=this.getResolvedKeyName();if(!n)return this.error='Key Name is required. Provide the "key-name" attribute or pass "keyName" in the URL.',this.errored.emit(this.error),void(this.isLoading=!1);ht.renderQueueTail=ht.renderQueueTail.then((async()=>{try{if(this.isDisconnected||e!==this.requestVersion)return;let r;if(this.registrationKey&&i.setActive(this.registrationKey),this.isLoading=!0,"content"===this.renderType?r=await s(this.dataKey,this.dataMode,n):(r=await l(this.dataKey,this.dataMode,n,t),this.renderType=r.controlType),this.isDisconnected||e!==this.requestVersion)return;if(this.isLoading=!1,await this.waitForNextPaint(150),await this.renderControl(r),this.isDisconnected||e!==this.requestVersion)return;this.responseReceived.emit(r),await this.waitForNextPaint(600)}catch(t){this.error=(null==t?void 0:t.message)||"Failed to load widget response",console.error("Failed to retrieve data",t),this.errored.emit(this.error)}finally{this.isLoading=!1}})).catch((t=>{console.error("Queue item failed — chain preserved:",t)}))}async renderTemplateData(t){await p(t,this.el,[],this.mainObject,this.initializeScript)}hideSpinner(t){return new Promise((e=>{const n=this.el.shadowRoot.querySelector(`#${t.id}`);if(n){const t=n.querySelector("#spinner");t&&(t.style.display="none")}e(!0)}))}renderSpinner(){return r("div",{class:"widget-spinner",id:"spinner"},r("div",{class:"widget-spinner-pulse"},r("div",{class:"widget-spinner-body"},r("div",{class:"widget-spinner-bar"}),r("div",{class:"widget-spinner-rows"},r("div",{class:"widget-spinner-grid"},r("div",{class:"widget-spinner-col-wide"}),r("div",{class:"widget-spinner-col-narrow"})),r("div",{class:"widget-spinner-bar"})))))}renderByType(){switch(this.renderType){case"carousel":return r("div",{class:"carousel-grid",id:`carousel-${this.domId}`},this.renderSpinner());case"template":return r("div",{class:"html-widget",id:`html-${this.domId}`},this.renderSpinner());default:return r("div",{class:"content-widget",id:`content-${this.domId}`,innerHTML:this.contentText})}}render(){return r("div",{key:"ec7c4261c505fb29882acf30d0c9c10a8703dc51",class:"ai12z-container-root"},this.isLoading&&r("div",{key:"ab3899fe20a637293b1fa5c24b40edf9cc20f333",class:"state-message"},"Loading..."),!this.isLoading&&this.error&&r("div",{key:"d70e83ff89ab6df1b090e7034f021c71466796c6",class:"state-message error"},this.error),!this.isLoading&&!this.error&&this.renderByType())}get el(){return o(this)}static get watchers(){return{parameters:[{onParametersChanged:0}],contentTemplate:[{onContentTemplateChanged:0}]}}};ht.renderQueueTail=Promise.resolve(),ht.CONTAINER_MOUNT_DELAY_MS=150,ht.style=".ai12z-container-root{width:100%;box-sizing:border-box}.state-message{padding:12px;border-radius:8px;background:#f4f7fb;color:#1f2937;font-size:14px}.state-message.error{background:#fdecec;color:#991b1b}.widget-spinner{width:100%;border-radius:6px}.widget-spinner-pulse{display:flex;animation:widget-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;gap:16px}@keyframes widget-pulse{0%,100%{opacity:1}50%{opacity:0.4}}.widget-spinner-body{flex:1;display:flex;flex-direction:column;gap:12px;padding:4px 0}.widget-spinner-bar{height:16px;border-radius:4px;background:#e5e7eb}.widget-spinner-rows{display:flex;flex-direction:column;gap:12px}.widget-spinner-grid{display:grid;grid-template-columns:2fr 1fr;gap:16px}.widget-spinner-col-wide,.widget-spinner-col-narrow{height:16px;border-radius:4px;background:#e5e7eb}";export{ht as ai12z_container}
|
|
1
|
+
import{r as t,a as e,E as n,e as i,h as r,d as o}from"./p-BNpVu1WU.js";import{k as a,N as s,O as l}from"./p-BCkDiHIY.js";import{s as c,p as u}from"./p-CwZwG6gL.js";import{i as f,p as d,r as p}from"./p-B_moTKAE.js";import{H as m}from"./p-D1IPrgJe.js";import"./p-Dj2_voLF.js";
|
|
2
|
+
/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */const{entries:h,setPrototypeOf:g,isFrozen:y,getPrototypeOf:w,getOwnPropertyDescriptor:b}=Object;let{freeze:v,seal:x,create:k}=Object,{apply:T,construct:A}="undefined"!=typeof Reflect&&Reflect;v||(v=function(t){return t}),x||(x=function(t){return t}),T||(T=function(t,e){for(var n=arguments.length,i=new Array(n>2?n-2:0),r=2;r<n;r++)i[r-2]=arguments[r];return t.apply(e,i)}),A||(A=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),i=1;i<e;i++)n[i-1]=arguments[i];return new t(...n)});const S=U(Array.prototype.forEach),E=U(Array.prototype.lastIndexOf),R=U(Array.prototype.pop),_=U(Array.prototype.push),z=U(Array.prototype.splice),D=U(String.prototype.toLowerCase),L=U(String.prototype.toString),O=U(String.prototype.match),P=U(String.prototype.replace),C=U(String.prototype.indexOf),F=U(String.prototype.trim),M=U(Object.prototype.hasOwnProperty),N=U(RegExp.prototype.test),I=(j=TypeError,function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return A(j,e)});var j;function U(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return T(t,e,i)}}function B(t,e){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:D;g&&g(t,null);let i=e.length;for(;i--;){let r=e[i];if("string"==typeof r){const t=n(r);t!==r&&(y(e)||(e[i]=t),r=t)}t[r]=!0}return t}function q(t){for(let e=0;e<t.length;e++)M(t,e)||(t[e]=null);return t}function W(t){const e=k(null);for(const[n,i]of h(t))M(t,n)&&(e[n]=Array.isArray(i)?q(i):i&&"object"==typeof i&&i.constructor===Object?W(i):i);return e}function $(t,e){for(;null!==t;){const n=b(t,e);if(n){if(n.get)return U(n.get);if("function"==typeof n.value)return U(n.value)}t=w(t)}return function(){return null}}const H=v(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Y=v(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),G=v(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),X=v(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),K=v(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),V=v(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),J=v(["#text"]),Q=v(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Z=v(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),tt=v(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),et=v(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),nt=x(/\{\{[\w\W]*|[\w\W]*\}\}/gm),it=x(/<%[\w\W]*|[\w\W]*%>/gm),rt=x(/\$\{[\w\W]*/gm),ot=x(/^data-[\-\w.\u00B7-\uFFFF]+$/),at=x(/^aria-[\-\w]+$/),st=x(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),lt=x(/^(?:\w+script|data):/i),ct=x(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ut=x(/^html$/i),ft=x(/^[a-z][.\w]*(-[.\w]+)+$/i);var dt=Object.freeze({__proto__:null,ARIA_ATTR:at,ATTR_WHITESPACE:ct,CUSTOM_ELEMENT:ft,DATA_ATTR:ot,DOCTYPE_NAME:ut,ERB_EXPR:it,IS_ALLOWED_URI:st,IS_SCRIPT_OR_DATA:lt,MUSTACHE_EXPR:nt,TMPLIT_EXPR:rt});const pt=function(){return"undefined"==typeof window?null:window};var mt=function t(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:pt();const n=e=>t(e);if(n.version="3.3.3",n.removed=[],!e||!e.document||9!==e.document.nodeType||!e.Element)return n.isSupported=!1,n;let{document:i}=e;const r=i,o=r.currentScript,{DocumentFragment:a,HTMLTemplateElement:s,Node:l,Element:c,NodeFilter:u,NamedNodeMap:f=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:p,trustedTypes:m}=e,g=c.prototype,y=$(g,"cloneNode"),w=$(g,"remove"),b=$(g,"nextSibling"),x=$(g,"childNodes"),T=$(g,"parentNode");if("function"==typeof s){const t=i.createElement("template");t.content&&t.content.ownerDocument&&(i=t.content.ownerDocument)}let A,j="";const{implementation:U,createNodeIterator:q,createDocumentFragment:nt,getElementsByTagName:it}=i,{importNode:rt}=r;let ot={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof h&&"function"==typeof T&&U&&void 0!==U.createHTMLDocument;const{MUSTACHE_EXPR:at,ERB_EXPR:lt,TMPLIT_EXPR:ct,DATA_ATTR:ft,ARIA_ATTR:mt,IS_SCRIPT_OR_DATA:ht,ATTR_WHITESPACE:gt,CUSTOM_ELEMENT:yt}=dt;let{IS_ALLOWED_URI:wt}=dt,bt=null;const vt=B({},[...H,...Y,...G,...K,...J]);let xt=null;const kt=B({},[...Q,...Z,...tt,...et]);let Tt=Object.seal(k(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),At=null,St=null;const Et=Object.seal(k(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Rt=!0,_t=!0,zt=!1,Dt=!0,Lt=!1,Ot=!0,Pt=!1,Ct=!1,Ft=!1,Mt=!1,Nt=!1,It=!1,jt=!0,Ut=!1,Bt=!0,qt=!1,Wt={},$t=null;const Ht=B({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Yt=null;const Gt=B({},["audio","video","img","source","image","track"]);let Xt=null;const Kt=B({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Vt="http://www.w3.org/1998/Math/MathML",Jt="http://www.w3.org/2000/svg",Qt="http://www.w3.org/1999/xhtml";let Zt=Qt,te=!1,ee=null;const ne=B({},[Vt,Jt,Qt],L);let ie=B({},["mi","mo","mn","ms","mtext"]),re=B({},["annotation-xml"]);const oe=B({},["title","style","font","a","script"]);let ae=null;const se=["application/xhtml+xml","text/html"];let le=null,ce=null;const ue=i.createElement("form"),fe=function(t){return t instanceof RegExp||t instanceof Function},de=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!ce||ce!==t){if(t&&"object"==typeof t||(t={}),t=W(t),ae=-1===se.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,le="application/xhtml+xml"===ae?L:D,bt=M(t,"ALLOWED_TAGS")?B({},t.ALLOWED_TAGS,le):vt,xt=M(t,"ALLOWED_ATTR")?B({},t.ALLOWED_ATTR,le):kt,ee=M(t,"ALLOWED_NAMESPACES")?B({},t.ALLOWED_NAMESPACES,L):ne,Xt=M(t,"ADD_URI_SAFE_ATTR")?B(W(Kt),t.ADD_URI_SAFE_ATTR,le):Kt,Yt=M(t,"ADD_DATA_URI_TAGS")?B(W(Gt),t.ADD_DATA_URI_TAGS,le):Gt,$t=M(t,"FORBID_CONTENTS")?B({},t.FORBID_CONTENTS,le):Ht,At=M(t,"FORBID_TAGS")?B({},t.FORBID_TAGS,le):W({}),St=M(t,"FORBID_ATTR")?B({},t.FORBID_ATTR,le):W({}),Wt=!!M(t,"USE_PROFILES")&&t.USE_PROFILES,Rt=!1!==t.ALLOW_ARIA_ATTR,_t=!1!==t.ALLOW_DATA_ATTR,zt=t.ALLOW_UNKNOWN_PROTOCOLS||!1,Dt=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,Lt=t.SAFE_FOR_TEMPLATES||!1,Ot=!1!==t.SAFE_FOR_XML,Pt=t.WHOLE_DOCUMENT||!1,Mt=t.RETURN_DOM||!1,Nt=t.RETURN_DOM_FRAGMENT||!1,It=t.RETURN_TRUSTED_TYPE||!1,Ft=t.FORCE_BODY||!1,jt=!1!==t.SANITIZE_DOM,Ut=t.SANITIZE_NAMED_PROPS||!1,Bt=!1!==t.KEEP_CONTENT,qt=t.IN_PLACE||!1,wt=t.ALLOWED_URI_REGEXP||st,Zt=t.NAMESPACE||Qt,ie=t.MATHML_TEXT_INTEGRATION_POINTS||ie,re=t.HTML_INTEGRATION_POINTS||re,Tt=t.CUSTOM_ELEMENT_HANDLING||{},t.CUSTOM_ELEMENT_HANDLING&&fe(t.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Tt.tagNameCheck=t.CUSTOM_ELEMENT_HANDLING.tagNameCheck),t.CUSTOM_ELEMENT_HANDLING&&fe(t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Tt.attributeNameCheck=t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),t.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Tt.allowCustomizedBuiltInElements=t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Lt&&(_t=!1),Nt&&(Mt=!0),Wt&&(bt=B({},J),xt=k(null),!0===Wt.html&&(B(bt,H),B(xt,Q)),!0===Wt.svg&&(B(bt,Y),B(xt,Z),B(xt,et)),!0===Wt.svgFilters&&(B(bt,G),B(xt,Z),B(xt,et)),!0===Wt.mathMl&&(B(bt,K),B(xt,tt),B(xt,et))),M(t,"ADD_TAGS")||(Et.tagCheck=null),M(t,"ADD_ATTR")||(Et.attributeCheck=null),t.ADD_TAGS&&("function"==typeof t.ADD_TAGS?Et.tagCheck=t.ADD_TAGS:(bt===vt&&(bt=W(bt)),B(bt,t.ADD_TAGS,le))),t.ADD_ATTR&&("function"==typeof t.ADD_ATTR?Et.attributeCheck=t.ADD_ATTR:(xt===kt&&(xt=W(xt)),B(xt,t.ADD_ATTR,le))),t.ADD_URI_SAFE_ATTR&&B(Xt,t.ADD_URI_SAFE_ATTR,le),t.FORBID_CONTENTS&&($t===Ht&&($t=W($t)),B($t,t.FORBID_CONTENTS,le)),t.ADD_FORBID_CONTENTS&&($t===Ht&&($t=W($t)),B($t,t.ADD_FORBID_CONTENTS,le)),Bt&&(bt["#text"]=!0),Pt&&B(bt,["html","head","body"]),bt.table&&(B(bt,["tbody"]),delete At.tbody),t.TRUSTED_TYPES_POLICY){if("function"!=typeof t.TRUSTED_TYPES_POLICY.createHTML)throw I('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof t.TRUSTED_TYPES_POLICY.createScriptURL)throw I('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');A=t.TRUSTED_TYPES_POLICY,j=A.createHTML("")}else void 0===A&&(A=function(t,e){if("object"!=typeof t||"function"!=typeof t.createPolicy)return null;let n=null;const i="data-tt-policy-suffix";e&&e.hasAttribute(i)&&(n=e.getAttribute(i));const r="dompurify"+(n?"#"+n:"");try{return t.createPolicy(r,{createHTML:t=>t,createScriptURL:t=>t})}catch(t){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(m,o)),null!==A&&"string"==typeof j&&(j=A.createHTML(""));v&&v(t),ce=t}},pe=B({},[...Y,...G,...X]),me=B({},[...K,...V]),he=function(t){_(n.removed,{element:t});try{T(t).removeChild(t)}catch(e){w(t)}},ge=function(t,e){try{_(n.removed,{attribute:e.getAttributeNode(t),from:e})}catch(t){_(n.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t)if(Mt||Nt)try{he(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},ye=function(t){let e=null,n=null;if(Ft)t="<remove></remove>"+t;else{const e=O(t,/^[\r\n\t ]+/);n=e&&e[0]}"application/xhtml+xml"===ae&&Zt===Qt&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");const r=A?A.createHTML(t):t;if(Zt===Qt)try{e=(new p).parseFromString(r,ae)}catch(t){}if(!e||!e.documentElement){e=U.createDocument(Zt,"template",null);try{e.documentElement.innerHTML=te?j:r}catch(t){}}const o=e.body||e.documentElement;return t&&n&&o.insertBefore(i.createTextNode(n),o.childNodes[0]||null),Zt===Qt?it.call(e,Pt?"html":"body")[0]:Pt?e.documentElement:o},we=function(t){return q.call(t.ownerDocument||t,t,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},be=function(t){return t instanceof d&&("string"!=typeof t.nodeName||"string"!=typeof t.textContent||"function"!=typeof t.removeChild||!(t.attributes instanceof f)||"function"!=typeof t.removeAttribute||"function"!=typeof t.setAttribute||"string"!=typeof t.namespaceURI||"function"!=typeof t.insertBefore||"function"!=typeof t.hasChildNodes)},ve=function(t){return"function"==typeof l&&t instanceof l};function xe(t,e,i){S(t,(t=>{t.call(n,e,i,ce)}))}const ke=function(t){let e=null;if(xe(ot.beforeSanitizeElements,t,null),be(t))return he(t),!0;const i=le(t.nodeName);if(xe(ot.uponSanitizeElement,t,{tagName:i,allowedTags:bt}),Ot&&t.hasChildNodes()&&!ve(t.firstElementChild)&&N(/<[/\w!]/g,t.innerHTML)&&N(/<[/\w!]/g,t.textContent))return he(t),!0;if(7===t.nodeType)return he(t),!0;if(Ot&&8===t.nodeType&&N(/<[/\w]/g,t.data))return he(t),!0;if(!(Et.tagCheck instanceof Function&&Et.tagCheck(i))&&(!bt[i]||At[i])){if(!At[i]&&Ae(i)){if(Tt.tagNameCheck instanceof RegExp&&N(Tt.tagNameCheck,i))return!1;if(Tt.tagNameCheck instanceof Function&&Tt.tagNameCheck(i))return!1}if(Bt&&!$t[i]){const e=T(t)||t.parentNode,n=x(t)||t.childNodes;if(n&&e)for(let i=n.length-1;i>=0;--i){const r=y(n[i],!0);r.__removalCount=(t.__removalCount||0)+1,e.insertBefore(r,b(t))}}return he(t),!0}return t instanceof c&&!function(t){let e=T(t);e&&e.tagName||(e={namespaceURI:Zt,tagName:"template"});const n=D(t.tagName),i=D(e.tagName);return!!ee[t.namespaceURI]&&(t.namespaceURI===Jt?e.namespaceURI===Qt?"svg"===n:e.namespaceURI===Vt?"svg"===n&&("annotation-xml"===i||ie[i]):Boolean(pe[n]):t.namespaceURI===Vt?e.namespaceURI===Qt?"math"===n:e.namespaceURI===Jt?"math"===n&&re[i]:Boolean(me[n]):t.namespaceURI===Qt?!(e.namespaceURI===Jt&&!re[i])&&!(e.namespaceURI===Vt&&!ie[i])&&!me[n]&&(oe[n]||!pe[n]):!("application/xhtml+xml"!==ae||!ee[t.namespaceURI]))}(t)?(he(t),!0):"noscript"!==i&&"noembed"!==i&&"noframes"!==i||!N(/<\/no(script|embed|frames)/i,t.innerHTML)?(Lt&&3===t.nodeType&&(e=t.textContent,S([at,lt,ct],(t=>{e=P(e,t," ")})),t.textContent!==e&&(_(n.removed,{element:t.cloneNode()}),t.textContent=e)),xe(ot.afterSanitizeElements,t,null),!1):(he(t),!0)},Te=function(t,e,n){if(St[e])return!1;if(jt&&("id"===e||"name"===e)&&(n in i||n in ue))return!1;if(_t&&!St[e]&&N(ft,e));else if(Rt&&N(mt,e));else if(Et.attributeCheck instanceof Function&&Et.attributeCheck(e,t));else if(!xt[e]||St[e]){if(!(Ae(t)&&(Tt.tagNameCheck instanceof RegExp&&N(Tt.tagNameCheck,t)||Tt.tagNameCheck instanceof Function&&Tt.tagNameCheck(t))&&(Tt.attributeNameCheck instanceof RegExp&&N(Tt.attributeNameCheck,e)||Tt.attributeNameCheck instanceof Function&&Tt.attributeNameCheck(e,t))||"is"===e&&Tt.allowCustomizedBuiltInElements&&(Tt.tagNameCheck instanceof RegExp&&N(Tt.tagNameCheck,n)||Tt.tagNameCheck instanceof Function&&Tt.tagNameCheck(n))))return!1}else if(Xt[e]);else if(N(wt,P(n,gt,"")));else if("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==C(n,"data:")||!Yt[t])if(zt&&!N(ht,P(n,gt,"")));else if(n)return!1;return!0},Ae=function(t){return"annotation-xml"!==t&&O(t,yt)},Se=function(t){xe(ot.beforeSanitizeAttributes,t,null);const{attributes:e}=t;if(!e||be(t))return;const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:xt,forceKeepAttr:void 0};let r=e.length;for(;r--;){const o=e[r],{name:a,namespaceURI:s,value:l}=o,c=le(a),u=l;let f="value"===a?u:F(u);if(i.attrName=c,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,xe(ot.uponSanitizeAttribute,t,i),f=i.attrValue,!Ut||"id"!==c&&"name"!==c||(ge(a,t),f="user-content-"+f),Ot&&N(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,f)){ge(a,t);continue}if("attributename"===c&&O(f,"href")){ge(a,t);continue}if(i.forceKeepAttr)continue;if(!i.keepAttr){ge(a,t);continue}if(!Dt&&N(/\/>/i,f)){ge(a,t);continue}Lt&&S([at,lt,ct],(t=>{f=P(f,t," ")}));const d=le(t.nodeName);if(Te(d,c,f)){if(A&&"object"==typeof m&&"function"==typeof m.getAttributeType)if(s);else switch(m.getAttributeType(d,c)){case"TrustedHTML":f=A.createHTML(f);break;case"TrustedScriptURL":f=A.createScriptURL(f)}if(f!==u)try{s?t.setAttributeNS(s,a,f):t.setAttribute(a,f),be(t)?he(t):R(n.removed)}catch(e){ge(a,t)}}else ge(a,t)}xe(ot.afterSanitizeAttributes,t,null)},Ee=function t(e){let n=null;const i=we(e);for(xe(ot.beforeSanitizeShadowDOM,e,null);n=i.nextNode();)xe(ot.uponSanitizeShadowNode,n,null),ke(n),Se(n),n.content instanceof a&&t(n.content);xe(ot.afterSanitizeShadowDOM,e,null)};return n.sanitize=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null,o=null,s=null,c=null;if(te=!t,te&&(t="\x3c!--\x3e"),"string"!=typeof t&&!ve(t)){if("function"!=typeof t.toString)throw I("toString is not a function");if("string"!=typeof(t=t.toString()))throw I("dirty is not a string, aborting")}if(!n.isSupported)return t;if(Ct||de(e),n.removed=[],"string"==typeof t&&(qt=!1),qt){if(t.nodeName){const e=le(t.nodeName);if(!bt[e]||At[e])throw I("root node is forbidden and cannot be sanitized in-place")}}else if(t instanceof l)i=ye("\x3c!----\x3e"),o=i.ownerDocument.importNode(t,!0),1===o.nodeType&&"BODY"===o.nodeName||"HTML"===o.nodeName?i=o:i.appendChild(o);else{if(!Mt&&!Lt&&!Pt&&-1===t.indexOf("<"))return A&&It?A.createHTML(t):t;if(i=ye(t),!i)return Mt?null:It?j:""}i&&Ft&&he(i.firstChild);const u=we(qt?t:i);for(;s=u.nextNode();)ke(s),Se(s),s.content instanceof a&&Ee(s.content);if(qt)return t;if(Mt){if(Nt)for(c=nt.call(i.ownerDocument);i.firstChild;)c.appendChild(i.firstChild);else c=i;return(xt.shadowroot||xt.shadowrootmode)&&(c=rt.call(r,c,!0)),c}let f=Pt?i.outerHTML:i.innerHTML;return Pt&&bt["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&N(ut,i.ownerDocument.doctype.name)&&(f="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+f),Lt&&S([at,lt,ct],(t=>{f=P(f,t," ")})),A&&It?A.createHTML(f):f},n.setConfig=function(){de(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Ct=!0},n.clearConfig=function(){ce=null,Ct=!1},n.isValidAttribute=function(t,e,n){ce||de({});const i=le(t),r=le(e);return Te(i,r,n)},n.addHook=function(t,e){"function"==typeof e&&_(ot[t],e)},n.removeHook=function(t,e){if(void 0!==e){const n=E(ot[t],e);return-1===n?void 0:z(ot[t],n,1)[0]}return R(ot[t])},n.removeHooks=function(t){ot[t]=[]},n.removeAllHooks=function(){ot={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}();const ht=class{constructor(r){t(this,r),this.responseReceived=e(this,"responseReceived",7),this.errored=e(this,"errored",7),this.isDisconnected=!1,this.dataKey=n.DATA_KEY||"",this.dataMode=n.DATA_MODE||"prod",this.keyName="",this.instanceId="",this.renderType="integration",this.contentTemplate="",this.isLoading=!1,this.error="",this.contentText="",this.htmlWidgetMarkup="",this.domId=`widget-${a()}`,this.registrationKey="",this.requestVersion=0,this.lastKbResponse=null,this.markAsActive=()=>{this.registrationKey&&i.setActive(this.registrationKey)},this.initializeScript=t=>(this.markAsActive(),f(t,this.mainObject))}get mainObject(){return window.ai12z||(window.ai12z={}),window.ai12z}getResolvedKeyName(){var t,e,n,i,r;const o=null===(t=this.keyName)||void 0===t?void 0:t.trim(),a=(null===(n=null===(e=this.el)||void 0===e?void 0:e.getAttribute("key-name"))||void 0===n?void 0:n.trim())||"";if(o)return o;if(a)return a;if("undefined"==typeof window)return"";const s=new URLSearchParams(window.location.search);return(null===(i=s.get("keyName"))||void 0===i?void 0:i.trim())||(null===(r=s.get("keyname"))||void 0===r?void 0:r.trim())||""}waitForNextPaint(t=0){return new Promise((e=>{requestAnimationFrame((()=>{t>0?setTimeout((()=>e()),t):e()}))}))}async renderControl(t){switch(await this.waitForNextPaint(ht.CONTAINER_MOUNT_DELAY_MS),this.renderType){case"carousel":await u({id:`carousel-${this.domId}`},{controlData:t},this.el,(t=>this.hideSpinner(t)),(()=>{}),t.scripts,t.styles,!1,"widget");break;case"template":let e=!1;await new Promise((n=>{const i=()=>{e||(e=!0,n())};d({id:`html-${this.domId}`},{controlData:t,controlType:t.controlType},this.el.shadowRoot,(t=>this.hideSpinner(t)),(async t=>{await this.renderTemplateData(t),i()}),(()=>{this.markAsActive()}),m).then(i)}));break;case"content":{this.lastKbResponse=t;const e=null==t?void 0:t.data;if(!e){this.error="Knowledge base content unavailable.",this.errored.emit(this.error);break}let{question:n="",answer:i=""}=e;if(i=(new c.Converter).makeHtml(i),n=(new c.Converter).makeHtml(n),this.contentTemplate){const t=m.compile(this.contentTemplate);this.contentText=t({question:n,answer:i}),this.contentText=mt.sanitize(this.contentText)}else this.contentText=mt.sanitize(i);break}}}async componentWillLoad(){var t;this.registrationKey=(null===(t=this.instanceId)||void 0===t?void 0:t.trim())||`container-${this.domId}`,i.register(this.registrationKey,this),(this.getResolvedKeyName()&&void 0!==this.parameters||"content"===this.renderType)&&await this.invokeApi()}componentDidLoad(){"undefined"==typeof window||window.Handlebars||(window.Handlebars=m),this.el.addEventListener("focusin",this.markAsActive),this.el.addEventListener("pointerenter",this.markAsActive)}disconnectedCallback(){this.el.removeEventListener("focusin",this.markAsActive),this.el.removeEventListener("pointerenter",this.markAsActive),this.isDisconnected=!0,this.registrationKey&&i.unregister(this.registrationKey)}async onParametersChanged(t,e){t!==e&&this.getResolvedKeyName()&&await this.invokeApi(t)}onContentTemplateChanged(){if("content"!==this.renderType||!this.lastKbResponse)return;const{question:t="",answer:e=""}=this.lastKbResponse.data||{},n=this.contentTemplate?m.compile(this.contentTemplate)({question:t,answer:e}):e;this.contentText=mt.sanitize(n)}async invokeApi(t=this.parameters){this.error="";const e=++this.requestVersion,n=this.getResolvedKeyName();if(!n)return this.error='Key Name is required. Provide the "key-name" attribute or pass "keyName" in the URL.',this.errored.emit(this.error),void(this.isLoading=!1);ht.renderQueueTail=ht.renderQueueTail.then((async()=>{try{if(this.isDisconnected||e!==this.requestVersion)return;let r;if(this.registrationKey&&i.setActive(this.registrationKey),this.isLoading=!0,"content"===this.renderType?r=await s(this.dataKey,this.dataMode,n):(r=await l(this.dataKey,this.dataMode,n,t),this.renderType=r.controlType),this.isDisconnected||e!==this.requestVersion)return;if(this.isLoading=!1,await this.waitForNextPaint(150),await this.renderControl(r),this.isDisconnected||e!==this.requestVersion)return;this.responseReceived.emit(r),await this.waitForNextPaint(600)}catch(t){this.error=(null==t?void 0:t.message)||"Failed to load widget response",console.error("Failed to retrieve data",t),this.errored.emit(this.error)}finally{this.isLoading=!1}})).catch((t=>{console.error("Queue item failed — chain preserved:",t)}))}async renderTemplateData(t){await p(t,this.el,[],this.mainObject,this.initializeScript)}hideSpinner(t){return new Promise((e=>{const n=this.el.shadowRoot.querySelector(`#${t.id}`);if(n){const t=n.querySelector("#spinner");t&&(t.style.display="none")}e(!0)}))}renderSpinner(){return r("div",{class:"widget-spinner",id:"spinner"},r("div",{class:"widget-spinner-pulse"},r("div",{class:"widget-spinner-body"},r("div",{class:"widget-spinner-bar"}),r("div",{class:"widget-spinner-rows"},r("div",{class:"widget-spinner-grid"},r("div",{class:"widget-spinner-col-wide"}),r("div",{class:"widget-spinner-col-narrow"})),r("div",{class:"widget-spinner-bar"})))))}renderByType(){switch(this.renderType){case"carousel":return r("div",{class:"carousel-grid",id:`carousel-${this.domId}`},this.renderSpinner());case"template":return r("div",{class:"html-widget",id:`html-${this.domId}`},this.renderSpinner());default:return r("div",{class:"content-widget",id:`content-${this.domId}`,innerHTML:this.contentText})}}render(){return r("div",{key:"ec7c4261c505fb29882acf30d0c9c10a8703dc51",class:"ai12z-container-root"},this.isLoading&&r("div",{key:"ab3899fe20a637293b1fa5c24b40edf9cc20f333",class:"state-message"},"Loading..."),!this.isLoading&&this.error&&r("div",{key:"d70e83ff89ab6df1b090e7034f021c71466796c6",class:"state-message error"},this.error),!this.isLoading&&!this.error&&this.renderByType())}get el(){return o(this)}static get watchers(){return{parameters:[{onParametersChanged:0}],contentTemplate:[{onContentTemplateChanged:0}]}}};ht.renderQueueTail=Promise.resolve(),ht.CONTAINER_MOUNT_DELAY_MS=150,ht.style=".ai12z-container-root{width:100%;box-sizing:border-box}.state-message{padding:12px;border-radius:8px;background:#f4f7fb;color:#1f2937;font-size:14px}.state-message.error{background:#fdecec;color:#991b1b}.widget-spinner{width:100%;border-radius:6px}.widget-spinner-pulse{display:flex;animation:widget-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;gap:16px}@keyframes widget-pulse{0%,100%{opacity:1}50%{opacity:0.4}}.widget-spinner-body{flex:1;display:flex;flex-direction:column;gap:12px;padding:4px 0}.widget-spinner-bar{height:16px;border-radius:4px;background:#e5e7eb}.widget-spinner-rows{display:flex;flex-direction:column;gap:12px}.widget-spinner-grid{display:grid;grid-template-columns:2fr 1fr;gap:16px}.widget-spinner-col-wide,.widget-spinner-col-narrow{height:16px;border-radius:4px;background:#e5e7eb}";export{ht as ai12z_container}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as i,a as t,E as s,e as o,h as e,f as a,d as l}from"./p-BNpVu1WU.js";import{P as n,e as h,J as r,L as d,p as c}from"./p-BCkDiHIY.js";import{S as u}from"./p-CkF7XHob.js";import{S as v}from"./p-n8ydBHE4.js";import{b as p}from"./p-odmyXuxx.js";import{e as m}from"./p-C0wNDqKO.js";import{d as g,l as f,a as b,f as w,b as y,r as x,v as k,c as z,g as C,u as S,i as A,e as T,h as j,j as M,k as I,m as E,n as H}from"./p-TJuczvVq.js";import{a as N}from"./p-BQ6J3hmg.js";import"./p-SyQT2Pr3.js";const O=class{constructor(o){i(this,o),this.errored=t(this,"errored",7),this.buttonClicked=t(this,"buttonClicked",7),this.messageSent=t(this,"messageSent",7),this.messageReceived=t(this,"messageReceived",7),this.open=t(this,"open",7),this.close=t(this,"close",7),this.stateChanged=t(this,"stateChanged",7),this.clearResults=t(this,"clearResults",7),this.clearInput=t(this,"clearInput",7),this.stopStream=t(this,"stopStream",7),this.startStream=t(this,"startStream",7),this.survey=t(this,"survey",7),this.formSubmitted=t(this,"formSubmitted",7),this.streamResponse=t(this,"streamResponse",7),this.endResponse=t(this,"endResponse",7),this.isElementAvailable=t(this,"isElementAvailable",7),this.test="123",this.cdnPath="https://cdn.ai12z.net/assets/cta",this.dirty=!1,this.isSubmitted=!1,this.pButtonText="Ask AI",this.pPlaceholder="AI search...",this.pHelpText="Enter text to get started",this.pNoResultsText="No results found",this.errorMsg="Error please try again!",this.pheading="",this.isCta=!1,this.dataKey=s.DATA_KEY||"",this.dataMode=s.DATA_MODE||"prod",this.options={},this.excludeTags=[],this.includeTags=[],this.ctaSettings={},this.showModal=!1,this.questionCounter=0,this.formData={search:"",displayText:""},this.searchResults=[],this.error=null,this.conversationId=null,this.canRender=!0,this.chatHistory=[],this.isChat=!1,this.aiMessageId=null,this.announceMessage="",this.showHistory=!1,this.conversationHistory=[],this.isRendered=!1,this.sendSurveyData=async i=>{this.sendJSON("This JSON is from a form submission"+i.results,i.completeText)},this.detectTextByLang=()=>{const i=g();f(i).then((i=>{this.pButtonText=i.button_text,this.pPlaceholder=i.placeholder_text,this.pHelpText=i.help_text,this.pNoResultsText=i.results_text,this.errorMsg=i.error_message})).catch((i=>{console.error("Error loading language file:",i)}))},this.handleSubmit=async(i,t,s,o,e,a={isHide:!1})=>{var l,h,r,d,c,u;if("history"!==s){if("ask-ai"===s&&(this.questionCounter++,y("ai12z-cta-data",{qCounter:this.questionCounter})),this.dirty=!0,this.isSubmitted=!0,null==i||i.preventDefault(),this.formData=Object.assign(Object.assign({},this.formData),{search:t}),0===this.chatHistory.length&&(null===(h=this.ctaSettings)||void 0===h?void 0:h.autoResetTimer)>0&&"ask-ai"===s&&this.startTimer(),o||"follow-up"!==s||(this.chatHistory=[],this.isChat=!1,this.showHistory=!1,this.displayMessage()),"survey"===s&&(this.chatHistory=x(this.chatHistory)),k(this.formData.search,e))return this.isSubmitted=!1,void this.stateChanged.emit(!1);try{let i={answer:"",formModel:null,insight_id:null};if("ask-ai"===s||this.isChat){this.socketService||(this.socketService=v.createInstance(this.dataMode,this.dataKey),await this.socketService.waitForConnection()),this.isChat=!0,this.chatHistory.push(z(""!==this.formData.displayText?this.formData.displayText:this.formData.search,"user","success",e)),this.chatHistory[this.chatHistory.length-1].isHide=null!==(r=a.isHide)&&void 0!==r&&r,this.aiMessageId="",this.thumbsId=C(),this.chatHistory.push(z('<div class="animate-ping">...</div>',"ai","pending",void 0,this.aiMessageId)),this.imgFiles=e&&e.length>0?e:[],this.chatHistory=x(this.chatHistory),i.answer=(null===(d=this.ctaSettings)||void 0===d?void 0:d.maxQuestion)>0&&this.questionCounter>(null===(c=this.ctaSettings)||void 0===c?void 0:c.maxQuestion)?this.ctaSettings.msgLimit:null==i?void 0:i.answer;const t=z(null==i?void 0:i.answer,"ai","success",void 0,this.aiMessageId,null==i?void 0:i.insight_id,this.thumbsId,null==i?void 0:i.formModel);this.chatHistory=S(this.chatHistory,t),requestAnimationFrame((()=>{var i;A(this.questionCounter,null===(i=this.ctaSettings)||void 0===i?void 0:i.maxQuestion)?this.startStream.emit({search:this.formData.search,maxQuestion:!0,chatData:this.chatHistory[this.chatHistory.length-1]}):this.startStream.emit({search:this.formData.search,imgFiles:this.imgFiles})}))}else(null===(u=this.ctaSettings)||void 0===u?void 0:u.autoSearch)&&(i=await n(this.dataKey,this.dataMode,this.formData.search),this.displaySearchResults(i))}catch(i){console.error(i),this.error=i}finally{this.isSubmitted=!1,this.stateChanged.emit(!1),this.formData.displayText=""}}else{this.showHistory=!0,this.isChat=!1;const i=b("ai12z-cta-history");this.conversationHistory=w(i,null===(l=this.ctaSettings._id)||void 0===l?void 0:l.$oid,this.ctaSettings.pId)}},this.displaySearchResults=i=>{this.searchResults=i.docs,this.isSubmitted=!1,this.showHistory=!1}}async openModal(){var i;this.showModal=!0,this.dirty=!1,o.setActive("cta"),(null===(i=this.ctaSettings)||void 0===i?void 0:i.clearMemory)&&this.clearSearchHistory(),requestAnimationFrame((()=>{var i;this.el.shadowRoot.querySelector("ai12z-input-form").querySelector("textarea").focus(),this.el.shadowRoot.querySelector(".modal-wrapper").classList.add("show-modal"),document.querySelector("ai12z-bot")&&(null===(i=document.querySelector("ai12z-bot").shadowRoot.querySelector(".layout"))||void 0===i||i.classList.add("hide-chatbot"))})),this.open.emit(),this.setLocalData(),this.isElementAvailable.emit(!0)}setLocalData(){y("ai12z-cta-data",{qCounter:this.questionCounter})}async sendMessage(i,t){this.formData.search=i,this.formData.displayText=null!=t?t:i,this.handleSubmit(null,this.formData.search,"ask-ai",!1,null),this.messageSent.emit(i)}async sendJSON(i,t){this.formData.search=JSON.stringify(i),this.formData.displayText=t,this.handleSubmit(null,this.formData.search,"ask-ai",!1,null),this.messageSent.emit(i)}async closeModal(){var i;this.el.shadowRoot.querySelector(".modal-wrapper").classList.remove("show-modal"),document.querySelector("ai12z-bot")&&(null===(i=document.querySelector("ai12z-bot").shadowRoot.querySelector(".layout"))||void 0===i||i.classList.remove("hide-chatbot")),setTimeout((()=>{var i;this.showModal=!1,this.stopStream.emit({socketId:null===(i=this.socketService)||void 0===i?void 0:i.getSocketId()}),this.socketService=null,this.close.emit(),T(this.timer)}),300)}handleKeyDown(i){var t;this.showModal&&((i.metaKey||i.ctrlKey)&&"k"===i.key&&(i.preventDefault(),this.openModal()),"Escape"===i.key&&(i.preventDefault(),(null===(t=this.ctaSettings)||void 0===t?void 0:t.allowClose)?this.closeModal():this.announce("This dialog cannot be closed with Escape. Please complete your interaction.")))}surveyHandler(i){if("button"===i.detail.type)this.formData.displayText="",this.handleSubmit(null,i.detail.results,i.detail.type,!1,null),this.buttonClicked.emit(i.detail.results);else if("carousel"===i.detail.type)this.chatHistory=[...this.chatHistory,i.detail.results];else if("update"===i.detail.type){const t=this.chatHistory.findIndex((t=>t.id===i.detail.results.id));this.chatHistory=S(this.chatHistory,i.detail.results,t)}else if("sendMessage"===i.detail.type)i.detail.results.length>1?this.sendMessage(i.detail.results[0],i.detail.results[1]):this.sendMessage(i.detail.results[0]);else if("sendJSON"===i.detail.type)this.sendJSON(i.detail.results[0],i.detail.results[1]);else{const t=i.detail,s=`This JSON is from a form submission [${t.keyName}]: ${JSON.stringify(t.results,null,2)}. There is no need to show the form [${t.keyName}] again.`;this.formData.search=s,this.formData.displayText=t.completeText,this.handleSubmit(null,this.formData.search,"ask-ai",!1,null,{isHide:!0})}}formSubmittedHandler(i){i.stopPropagation(),this.formSubmitted.emit(i.detail.data)}async componentWillLoad(){h("https://cdn.ai12z.net/assets/bot/v2/tailwind.min.css",this.el),N("cta",this.dataKey,this.dataMode),await this.configCtaSettings();const i=this.el.children;let t=i&&i.length>0;if(this.detectTextByLang(),t)for(var s=0;s<i.length;s++)"cta"!==i[s].tagName.toLowerCase()&&"cta"!==i[s].getAttribute("slot")||(this.isCta=!0)}onDataKeyChange(i){N("cta",this.dataKey,this.dataMode)}onDataModeChange(i){N("cta",this.dataKey,this.dataMode)}clearSearchHistory(){this.searchResults&&this.searchResults.length>0&&(this.searchResults.splice(0,this.searchResults.length),this.searchResults=[...this.searchResults]),this.chatHistory=[],this.isChat=!1,this.clearInput.emit(!1),this.clearResults.emit(!1)}handleOutsideClick(i){var t;j(i,"modal-wrapper")&&((null===(t=this.ctaSettings)||void 0===t?void 0:t.allowClose)?this.closeModal():this.announce("This dialog cannot be closed by clicking outside. Please complete your interaction."))}announce(i){this.announceMessage=i,setTimeout((()=>{this.announceMessage=""}),1e3)}startTimer(){var i;this.timer=M((()=>{this.questionCounter=0,y("ai12z-cta-data",{qCounter:this.questionCounter})}),null===(i=this.ctaSettings)||void 0===i?void 0:i.autoResetTimer)}connectedCallback(){r(this.dataKey,this.dataMode).then((i=>{this.canRender=i}))}async configCtaSettings(){d({apiKey:this.dataKey,configId:this.configId,configType:"search"},this.dataMode).then((i=>{var t,s,o,e,a,l,n,h,r,d,c,u,v;if(i){if(this.ctaSettings=i,(null===(t=null==i?void 0:i.v3)||void 0===t?void 0:t.siteKey)?m(i._id,i.v3.siteKey,"search",this.dataKey,this.dataMode,(i=>{this.errored.emit(i)})).then((i=>{i&&(this.isRendered=!0)})).catch((i=>{console.error("Recaptcha verification failed:",i),this.isRendered=!1})):this.isRendered=!0,void 0===(null===(s=this.ctaSettings)||void 0===s?void 0:s.autoSearch)&&(this.ctaSettings.autoSearch=!0),void 0===(null===(o=this.ctaSettings)||void 0===o?void 0:o.allowClose)&&(this.ctaSettings.allowClose=!0),void 0!==(null===(e=this.options)||void 0===e?void 0:e.allowClose)&&(this.ctaSettings.allowClose=this.options.allowClose),void 0===(null===(a=this.ctaSettings)||void 0===a?void 0:a.clearMemory)&&(this.ctaSettings.clearMemory=!0),void 0===(null===(l=this.ctaSettings)||void 0===l?void 0:l.enableMobileView)&&(this.ctaSettings.enableMobileView=!0),void 0===(null===(n=this.ctaSettings)||void 0===n?void 0:n.categorize)&&(this.ctaSettings.categorize=!0),this.ctaSettings.customCSS&&this.insertCustomCSS(this.ctaSettings.customCSS),this.ctaSettings.customJS&&I(this.el.shadowRoot,this.ctaSettings.customJS),(null===(h=this.ctaSettings.welcome)||void 0===h?void 0:h.styles)&&this.insertCustomCSS(this.ctaSettings.welcome.styles),(null===(r=this.ctaSettings.welcome)||void 0===r?void 0:r.scripts)&&I(this.el.shadowRoot,this.ctaSettings.welcome.scripts),(null!==(d=this.ctaSettings.helpText)&&void 0!==d?d:null===(c=this.ctaSettings.welcome)||void 0===c?void 0:c.message)&&(this.pHelpText=null!==(u=this.ctaSettings.helpText)&&void 0!==u?u:null===(v=this.ctaSettings.welcome)||void 0===v?void 0:v.message),this.ctaSettings.theme){let i="";i="custom"!==this.ctaSettings.theme?`${this.cdnPath}/v2/themes/theme-${this.ctaSettings.theme}.css`:this.ctaSettings.customTheme;const t=document.createElement("link");t.setAttribute("rel","stylesheet"),t.setAttribute("href",i),document.head.appendChild(t)}else{const i=document.createElement("link");i.setAttribute("rel","stylesheet"),i.setAttribute("href",`${this.cdnPath}/v2/themes/theme-default.css`),document.head.appendChild(i)}this.ctaSettings.textareaAtBottom="bottom"===this.ctaSettings.inputFieldPosition}})).catch((i=>{console.error("Error loading configuration:",i)}))}insertCustomCSS(i){E(this.el.shadowRoot,i)}componentDidLoad(){p(this.el),o.register("cta",this)}deleteChatHistoryHandler(i){var t,s,o;const e=b("ai12z-cta-history"),a=w(e,null===(s=null===(t=this.ctaSettings)||void 0===t?void 0:t._id)||void 0===s?void 0:s.$oid,this.ctaSettings.pId),l=e.filter((t=>!a.includes(t)||t.conversationId!==i.detail.conversationId));localStorage.setItem("ai12z-cta-history",JSON.stringify(l)),this.conversationHistory=w(l,null===(o=this.ctaSettings._id)||void 0===o?void 0:o.$oid,this.ctaSettings.pId)}chatClickHandler(i){i.detail.length>0&&(this.chatHistory=i.detail,this.isChat=!0,requestAnimationFrame((()=>{var i;const t=null===(i=this.el.shadowRoot)||void 0===i?void 0:i.querySelector("ai12z-chat");null==t||t.hydrateMessagesFromState()}))),this.showHistory=!1}defaultTemplate(){const i=H();return e("button",{type:"button",class:"flex ring-1 ring-slate-900/10 hover:ring-slate-300 focus:outline-none focus:ring-2 focus:ring-sky-500 shadow-sm custom-button","aria-label":"Open AI Search"},e("svg",{width:"24",height:"24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"flex-none text-slate-300 dark:text-slate-400"},e("path",{d:"m19 19-3.5-3.5"}),e("circle",{cx:"11",cy:"11",r:"6"})),e("span",{class:"flex-auto"},this.pPlaceholder),e("kbd",{class:"font-sans font-semibold text-slate-400"},e("abbr",{title:"Command",class:"no-underline text-slate-400"},i&&e("span",null,"⌘"),!i&&e("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",fill:"currentColor",class:"inline w-4 h-4 mb-1"},e("path",{d:"M3.5 2A1.5 1.5 0 0 0 2 3.5v2A1.5 1.5 0 0 0 3.5 7h2A1.5 1.5 0 0 0 7 5.5v-2A1.5 1.5 0 0 0 5.5 2h-2ZM3.5 9A1.5 1.5 0 0 0 2 10.5v2A1.5 1.5 0 0 0 3.5 14h2A1.5 1.5 0 0 0 7 12.5v-2A1.5 1.5 0 0 0 5.5 9h-2ZM9 3.5A1.5 1.5 0 0 1 10.5 2h2A1.5 1.5 0 0 1 14 3.5v2A1.5 1.5 0 0 1 12.5 7h-2A1.5 1.5 0 0 1 9 5.5v-2ZM10.5 9A1.5 1.5 0 0 0 9 10.5v2a1.5 1.5 0 0 0 1.5 1.5h2a1.5 1.5 0 0 0 1.5-1.5v-2A1.5 1.5 0 0 0 12.5 9h-2Z"}))),"K"))}displayMessage(){var i,t,s,o,a,l;let n=null;return this.error?n=e("p",{class:"text-red-500"},this.errorMsg):this.isSubmitted?n=e("svg",{class:"animate-spin -ml-1 mr-3 h-5 w-5 text-gray-400",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},e("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"4"}),e("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})):(this.dirty&&(n=null!==(t=null===(i=this.ctaSettings)||void 0===i?void 0:i.noResultsText)&&void 0!==t?t:this.pNoResultsText),n=null!==(o=null===(s=this.ctaSettings)||void 0===s?void 0:s.helpText)&&void 0!==o?o:this.pHelpText),(null===(a=this.searchResults)||void 0===a?void 0:a.length)>0||(null===(l=this.chatHistory)||void 0===l?void 0:l.length)>0?null:"string"==typeof n?e("div",{class:"flex prose custom-msg",innerHTML:n}):e("p",{class:"custom-msg flex"},n)}render(){var i,t,s,o,l,n,h,r,d,v,p,m,g,f,b,w,y,x,k,z,C,S,A,T,j,M,I,E,H,N,O,D,J,q,B,F,L,K,$,P,R,U,Z;const Q={width:(null===(i=this.ctaSettings)||void 0===i?void 0:i.enableMobileView)?"100%":null===(t=this.ctaSettings)||void 0===t?void 0:t.dialogWidth,"max-width":null===(s=this.ctaSettings)||void 0===s?void 0:s.dialogMaxWidth,"min-height":this.chatHistory.length>0?"unset":null!==(l=null===(o=this.ctaSettings)||void 0===o?void 0:o.dialogMinHeight)&&void 0!==l?l:"300px","margin-top":null!==(h=null===(n=this.ctaSettings)||void 0===n?void 0:n.dialogTopMargin)&&void 0!==h?h:"5rem"};return this.canRender?e(a,null,this.isRendered&&e("div",{class:"custom-container",onClick:()=>this.openModal()},!this.isCta&&this.defaultTemplate(),this.isCta&&e("slot",{name:"cta"})),e("div",{class:{"bg-smoke-light":!0,"modal-wrapper":!0,"custom-model":!0,"hide-dialog":!this.showModal},onClick:i=>this.handleOutsideClick(i),role:"dialog","aria-modal":"true","aria-label":"Search modal","aria-describedby":(null===(r=this.ctaSettings)||void 0===r?void 0:r.allowClose)?void 0:"modal-close-info"},e("div",{"aria-live":"assertive","aria-atomic":"true",class:"sr-only"},this.announceMessage),!(null===(d=this.ctaSettings)||void 0===d?void 0:d.allowClose)&&e("div",{id:"modal-close-info",class:"sr-only"},"This dialog cannot be closed with Escape key or by clicking outside. Please complete your interaction."),e("div",{class:"skip-links"},e("a",{class:"skip-link",href:"#main-content",onClick:i=>{var t;i.preventDefault();const s=null===(t=this.el.shadowRoot.querySelector("ai12z-chat"))||void 0===t?void 0:t.shadowRoot.querySelector("#main-content");s&&s.focus()}},"Skip to main content"),e("a",{class:"skip-link",href:"#searchInput",onClick:i=>{i.preventDefault();const t=this.el.shadowRoot.querySelector("ai12z-input-form").querySelector("#searchInput");t&&t.focus()}},"Skip to message input")),e("div",{class:"overscroll-contain modal-content-wrapper model-content modal-position",style:Q},this.chatHistory.length>0&&e("span",{class:"btn-left"},e("button",{title:"New Chat","aria-label":"New Chat",onClick:()=>{this.chatHistory=[],this.isChat=!1,this.displayMessage()},class:"modal-home"},e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},e("path",{d:"M21 12a9 9 0 1 1-3-6.7"}),e("polyline",{points:"21 3 21 9 15 9"})))),e("span",{class:"btn-position"},(null===(v=this.ctaSettings)||void 0===v?void 0:v.allowClose)&&e("button",{onClick:()=>this.closeModal(),class:"modal-close","aria-label":"Close AI Search",tabindex:"0",title:"Close AI Search"},e("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.8","stroke-linecap":"round","stroke-linejoin":"round"},e("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e("line",{x1:"6",y1:"6",x2:"18",y2:"18"})))),e("div",{class:"modal-body flex flex-col"},e("h1",{class:"model-heading"},null!==(m=null===(p=this.ctaSettings)||void 0===p?void 0:p.heading)&&void 0!==m?m:this.pheading),e("div",{class:"cta-layout flex flex-col flex-1 "+((null===(g=this.ctaSettings)||void 0===g?void 0:g.textareaAtBottom)?"reverse":"normal")},e("div",{class:"input-wrapper"},e("ai12z-input-form",{onAction:async i=>{const{value:t,type:s,followUp:o,imgFiles:e}=i.detail;await this.handleSubmit(i,t,s,o,e)},isChat:this.isChat,componentType:"cta",chatLength:this.chatHistory.length,placeholder:null!==(b=null===(f=this.ctaSettings)||void 0===f?void 0:f.placeholder)&&void 0!==b?b:this.pPlaceholder,buttonText:(null===(w=this.ctaSettings)||void 0===w?void 0:w.buttonText)?null===(y=this.ctaSettings)||void 0===y?void 0:y.buttonText:""==(null===(x=this.ctaSettings)||void 0===x?void 0:x.buttonText)||!(null===(k=this.ctaSettings)||void 0===k?void 0:k.buttonText)||""==(null===(z=this.ctaSettings)||void 0===z?void 0:z.buttonText)&&""==(null===(C=this.ctaSettings)||void 0===C?void 0:C.iconSrc)?!(null===(S=this.ctaSettings)||void 0===S?void 0:S.buttonText)&&(null===(A=this.ctaSettings)||void 0===A?void 0:A.iconSrc)?"":this.pButtonText:null===(T=this.ctaSettings)||void 0===T?void 0:T.buttonText,iconSrc:null!==(M=null===(j=this.ctaSettings)||void 0===j?void 0:j.iconSrc)&&void 0!==M?M:"",followUpLabel:null!==(E=null===(I=this.ctaSettings)||void 0===I?void 0:I.followUpLabel)&&void 0!==E?E:"Do you have a follow up question?",isImageUpload:null===(N=null===(H=this.ctaSettings)||void 0===H?void 0:H.imageUpload)||void 0===N||N,isEnableMic:null===(D=null===(O=this.ctaSettings)||void 0===O?void 0:O.enableMic)||void 0===D||D,"data-key":this.dataKey,"data-mode":this.dataMode})),e("div",{id:"main-content",class:"content-area"},!this.showHistory&&this.displayMessage(),e("div",{class:"custom-results"},!this.isChat&&!(null===(J=this.ctaSettings)||void 0===J?void 0:J.categorize)&&e(u,{results:this.searchResults}),!this.isChat&&(null===(q=this.ctaSettings)||void 0===q?void 0:q.categorize)&&e("ai12z-category",{categoryList:this.searchResults,linkTarget:null===(B=this.ctaSettings)||void 0===B?void 0:B.linkTarget})),this.isChat&&e("ai12z-chat",{chats:this.chatHistory,env:this.dataMode,query:this.formData.search,apiKey:this.dataKey,aiMessageId:this.aiMessageId,imgFiles:this.imgFiles,target:""===(null===(F=this.ctaSettings)||void 0===F?void 0:F.linkTarget)?"_blank":null===(L=this.ctaSettings)||void 0===L?void 0:L.linkTarget,voiceType:(null===(K=this.ctaSettings)||void 0===K?void 0:K.audioType)||"default",voice:(null===($=this.ctaSettings)||void 0===$?void 0:$.voice)||"Google US English",onFeedback:async i=>{const{feedback:t,insightId:s}=i.detail;c(this.dataKey,this.dataMode,s,t)},componentType:"ctasearch",socketIn:this.socketService,dataAttributes:this.dataAttributes,chatExcludeTags:this.excludeTags,chatIncludeTags:this.includeTags,customstyle:null===(P=this.ctaSettings)||void 0===P?void 0:P.customCSS,customJS:null===(R=this.ctaSettings)||void 0===R?void 0:R.customJS,settings:null!==(U=this.ctaSettings)&&void 0!==U?U:{}}),this.showHistory&&e("chatbot-history",{chatList:this.conversationHistory,botName:null===(Z=this.ctaSettings)||void 0===Z?void 0:Z.name}),!this.isChat&&e("div",{class:"custom-privacy"},e("slot",{name:"custom-privacy"})))))))):e(a,null,e("span",{style:{display:"none"}},"Failed to load ai12z control due to insufficient fund"))}get el(){return l(this)}static get watchers(){return{dataKey:[{onDataKeyChange:0}],dataMode:[{onDataModeChange:0}]}}};O.style=":host{--bg-smoke-light:rgba(0, 0, 0, 0.5);margin-left:20px;font-family:var(--ai12z-search-font-family) var(--ai12z-font-family) !important;font-size:var(--ai12z-search-font-size, var(--ai12z-font-size)) !important;color:var(--ai12z-font-color, black);text-align:var(--ai12z-text-align, left)}.keyboard-shortcuts-btn{vertical-align:middle;padding-right:5px;color:#666}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}.skip-links{position:relative;z-index:9999}.skip-link{position:absolute;top:-40px;left:0;background-color:var(--ai12z-primary-color, #007bff);color:white;padding:8px 16px;text-decoration:none;border-radius:4px;font-weight:500;z-index:10000;opacity:0;pointer-events:none;transition:top 0.2s, opacity 0.2s}.skip-link:focus{top:8px;opacity:1;pointer-events:auto;outline:3px solid var(--ai12z-secondary-accent, #0056b3);outline-offset:2px}.bg-smoke-light{transition:opacity 300ms ease-in-out;position:fixed;top:0;left:0;z-index:200;height:100vh;width:100vw;cursor:auto;flex-direction:column;background-color:#0003;--tw-backdrop-blur:blur(4px);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.modal-content{transition:transform 300ms ease-in-out, opacity 300ms ease-in-out;transform:scale(0.9);opacity:0}.modal-position{position:relative;padding:2rem 1rem 0.5rem 1rem;flex-direction:column}.modal-close:hover{color:rgb(31 41 55)}.model-heading{color:var(--ai12z-heading-color);font-size:var(--ai12z-heading-font-size)}:host(.show-modal) .bg-smoke-light{opacity:1}:host(.show-modal) .modal-content{transform:scale(1);opacity:1}.modal-content-wrapper{background-color:rgb(255 255 255);width:100%;max-width:48rem;border-radius:0.5rem;}.model-wrapper{position:fixed;top:0;left:0;z-index:200;height:100vh;width:100vw;cursor:auto;flex-direction:column;background-color:#0003;padding:1rem;--tw-backdrop-blur:blur(4px);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.custom-model{overflow:auto;inset:0px;position:fixed;min-height:100vh;display:flex;align-items:center;justify-items:center}.hide-dialog{display:none !important}.modal-position .btn-position{position:absolute;right:0px;top:0px;padding:0.25rem 1rem;color:var(--ai12z-secondary-accent, #0056B3)}@media (max-width: 768px){.modal-content-wrapper{width:100%;height:100vh;height:100svh !important;margin:0 !important;border-radius:0;overflow:auto}.custom-privacy{position:fixed !important;bottom:0;left:0;width:100%;padding:10px}.modal-position .btn-position{padding:0.45rem 0.75rem 0.45rem 1rem;position:fixed}.content-area{padding:0px !important}}.btn-left{top:0;left:0;position:absolute;padding:0.35rem 1rem;color:var(--ai12z-secondary-accent, #0056B3)}.custom-privacy{color:var(--ai12z-knowledge-box-privacy-color);text-align:center;margin-top:auto;bottom:0;left:0;right:0}.custom-button{align-items:center;text-align:left;background-color:rgb(255 255 255);color:rgb(148 163 184);border-radius:0.5rem;width:18rem;min-height:3rem;padding-left:1rem;padding-right:1rem;}.custom-msg{text-align:center;color:var(--ai12z-font-mute);justify-content:center;max-width:none !important;}.cta-search-results{border-top-width:1px;border-bottom-width:0px;border-color:rgb(243 244 246)}.cta-search-results-list{position:relative;padding-bottom:1.25rem;padding-top:1.25rem}.cta-search-results-list:hover{background-color:var(--ai12z-hover-bg-color)}.cta-search-container{margin-left:auto;margin-right:auto;display:flex;max-width:56rem;justify-content:space-between;-moz-column-gap:1.5rem;column-gap:1.5rem}.cta-search-container-two{display:flex;min-width:0px;-moz-column-gap:1rem;column-gap:1rem}.cta-search-container-three{min-width:0px;flex:1 1 auto}.cta-search-text{font-weight:600;line-height:1.5rem;font-size:var(--ai12z-search-result-title-font-size);color:var(--ai12z-search-result-title-color)}.cta-search-text-position{position:absolute;left:0px;right:0px;top:-1px;bottom:0px}.cta-search-description{margin-top:0.25rem;display:flex;font-size:var(--ai12z-search-result-description-font-size);line-height:1rem;line-height:1.25rem;color:var(--ai12z-search-result-description-color)}.cta-search-list-arrow{display:flex;align-items:center;flex-shrink:0;-moz-column-gap:1rem;column-gap:1rem}.custom-icon-width{width:4rem}.results-icon svg{width:1.5rem;height:1.5rem}.modal-body{display:flex;flex-direction:column}.cta-layout{display:flex;flex:1;min-height:0}.cta-layout.normal{flex-direction:column}.cta-layout.reverse{flex-direction:column-reverse}.input-wrapper{position:sticky;top:0;bottom:0;z-index:10;background:white;padding:1rem}.content-area{flex:1;padding:0.75rem}";export{O as ai12z_cta}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{E as t,r as i,a as e,e as s,h as o,f as n,d as a}from"./p-BNpVu1WU.js";import{b as r,l}from"./p-SyQT2Pr3.js";import{s as h,p as d}from"./p-CwZwG6gL.js";import{L as c,a as u}from"./p-8-Jaom_c.js";import{c as v,k as p,I as g,j as m,J as f,K as b,u as w,f as y,L as x,l as k,M as C,b as A}from"./p-BCkDiHIY.js";import{H as S}from"./p-D1IPrgJe.js";import{a as E}from"./p-odmyXuxx.js";import{e as z}from"./p-C0wNDqKO.js";import{i as T,g as I,b as L,p as N,r as B,c as M}from"./p-B_moTKAE.js";import{r as $}from"./p-By1gJKXA.js";import{c as O}from"./p-DXBxSLgN.js";import{D,w as _,h as P}from"./p-KSKiM1sy.js";import{f as R,s as j}from"./p-TJuczvVq.js";import{a as U}from"./p-BQ6J3hmg.js";import{e as F,p as G}from"./p-ZyOWOLs5.js";import"./p-Dj2_voLF.js";const H=t.DATA_MODE||"prod";class q extends Error{constructor(t="Live agent session authentication has expired"){super(t),this.name="LiveAgentAuthExpiredError"}}const J=new class{constructor(){this.events=new Map}on(t,i){this.events.has(t)||this.events.set(t,new Set),this.events.get(t).add(i)}off(t,i){var e;null===(e=this.events.get(t))||void 0===e||e.delete(i)}emit(t,i){var e;null===(e=this.events.get(t))||void 0===e||e.forEach((t=>t(i)))}},V=new c("SalesforceLiveAgentProvider",{logLevel:u.Info,remoteLoggingUrl:""});class Z{constructor(){this.configSettings=null,this.sessionContext=null,this.endpointSSE="",this.checkAgentAvailability=async t=>{var i,e,s;this.availabilityAbort=new AbortController;const{signal:o}=this.availabilityAbort,n=Date.now();for(;Date.now()-n<2e4;){if(o.aborted)return!1;const n=await fetch(`${null===(i=this.configSettings)||void 0===i?void 0:i.instanceUrl}/iamessage/api/v2/conversation/${t}/entries`,{method:"GET",signal:o,headers:{"Content-Type":"application/json",Authorization:`Bearer ${null===(e=this.sessionContext)||void 0===e?void 0:e.accessToken}`}});if(!n.ok)return V.warn(`Agent availability check failed: ${n.status} ${n.statusText}`),J.emit("AGENT_UNAVAILABLE",{reason:"request_error"}),!1;const a=await n.json();V.debug("Agent availability check result:",a);const r=null!==(s=null==a?void 0:a.conversationEntries)&&void 0!==s?s:[],l=r.find((t=>"RoutingResult"===t.entryType));if(l){let t=l.entryPayload;if("string"==typeof t)try{t=JSON.parse(t)}catch(t){V.warn("Failed to parse RoutingResult entryPayload")}const i=null==t?void 0:t.failureReason;return i?(V.warn("Routing failed with reason:",i),J.emit("AGENT_UNAVAILABLE",{reason:i}),!1):(V.debug("Agent routed successfully"),!0)}V.debug(`No RoutingResult yet (entries: ${r.length}), retrying in 1500ms…`),await new Promise(((t,i)=>{const e=setTimeout(t,1500);o.addEventListener("abort",(()=>{clearTimeout(e),i()}),{once:!0})})).catch((()=>null))}return V.warn("Timed out waiting for MIAW routing result"),J.emit("AGENT_UNAVAILABLE",{reason:"timeout"}),!1},this.configSettings=null,this.sessionContext=null,this.endpointSSE=v(H)}async authenticate(){var t,i,e;const s=await fetch(`${null===(t=this.configSettings)||void 0===t?void 0:t.instanceUrl}/iamessage/api/v2/authorization/unauthenticated/access-token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({orgId:null===(i=this.configSettings)||void 0===i?void 0:i.orgId,esDeveloperName:null===(e=this.configSettings)||void 0===e?void 0:e.messagingChannelId,capabilitiesVersion:"1",platform:"Web",context:{appName:"DemoMessagingClient",clientVersion:"1.0.0"}})});if(!s.ok)throw new Error(`Failed to authenticate with Salesforce MIAW: [error]: ${s.status} ${s.statusText}`);const o=await s.json();this.sessionContext||(this.sessionContext={}),this.sessionContext.accessToken=o.accessToken,this.sessionContext.sessionId=o.lastEventId}async startSession(){var t,i,e,s,o,n,a,r,l,h,d,c;const u={};if(null===(i=null===(t=this.sessionContext)||void 0===t?void 0:t.extraPrechatFormDetails)||void 0===i?void 0:i.length)for(const t of this.sessionContext.extraPrechatFormDetails)(null==t?void 0:t.label)&&"string"==typeof t.value&&""!==t.value.trim()&&(u[t.label]=t.value);const v=crypto.randomUUID().toLowerCase(),p=await fetch(`${null===(e=this.configSettings)||void 0===e?void 0:e.instanceUrl}/iamessage/api/v2/conversation`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${null===(s=this.sessionContext)||void 0===s?void 0:s.accessToken}`},body:JSON.stringify({conversationId:v,esDeveloperName:null===(o=this.configSettings)||void 0===o?void 0:o.messagingChannelId,routingAttributes:Object.assign({recordId:null===(n=this.sessionContext)||void 0===n?void 0:n.conversationId},u)})});if(!p.ok)throw new Error(`Conversation start failed: ${p.status} ${p.statusText}`);if(p.ok){this.sessionContext.conversationId=v,J.emit("liveAgentReady",void 0),J.emit("AGENT_SESSION_INFO",{sessionId:this.sessionContext.accessToken,conversationId:this.sessionContext.conversationId});let t="";if(null===(r=null===(a=this.sessionContext)||void 0===a?void 0:a.extraPrechatFormDetails)||void 0===r?void 0:r.length){const i=this.sessionContext.extraPrechatFormDetails.filter((t=>(null==t?void 0:t.label)&&"string"==typeof t.value&&""!==t.value.trim()&&!1!==t.displayToAgent)).map((t=>`${t.label}: ${t.value}`));i.length>0&&(t+=`Pre-chat details:\n${i.join("\n")}\n\n`)}(null===(l=this.sessionContext)||void 0===l?void 0:l.initialMessages)&&(null===(h=this.sessionContext)||void 0===h?void 0:h.initialMessages.length)>0&&(null===(d=this.sessionContext.initialMessages[0])||void 0===d||d.messages.forEach((i=>{(null==i?void 0:i.text)&&(i.text=i.text.replace(/<\/?p>/g,""),t+=(null==i?void 0:i.isUser)?`User: ${i.text}\n`:`Bot: ${i.text}\n`)}))),t&&this.sendMessage({isNewSession:!0,sessionId:(null===(c=this.sessionContext)||void 0===c?void 0:c.sessionId)||"",message:t}),await this.checkAgentAvailability(this.sessionContext.conversationId||"")?(V.debug("Agent is available, starting to listen to messages"),this.listenToMessages()):V.warn("No agent assigned — skipping SSE listener setup")}}async initialize(t){var i,e,s;if(V.debug("Initializing Salesforce Live Agent Provider"),this.configSettings||(this.configSettings=(null==t?void 0:t.config)||this.configSettings),!(null===(i=this.configSettings)||void 0===i?void 0:i.instanceUrl)||!(null===(e=this.configSettings)||void 0===e?void 0:e.orgId)||!(null===(s=this.configSettings)||void 0===s?void 0:s.messagingChannelId))throw new Error("Missing required configuration settings for Salesforce Live Agent Provider");this.sessionContext||(this.sessionContext={accessToken:"",lastMessageReadTime:0,sessionId:"",initialMessages:(null==t?void 0:t.messageHistory)||[],isActive:!1,conversationId:(null==t?void 0:t.conversationId)||crypto.randomUUID().toLowerCase(),userId:(null==t?void 0:t.userId)||"",extraPrechatFormDetails:(null==t?void 0:t.extraPrechatFormDetails)||[]});try{await this.authenticate(),await this.startSession()}catch(t){throw V.error("Error initializing Salesforce Live Agent Provider:",t),t}}parseMessageEntries(t){return t.filter((t=>{var i,e,s,o;return"Message"===t.entryType&&(null===(s=null===(e=null===(i=t.entryPayload)||void 0===i?void 0:i.abstractMessage)||void 0===e?void 0:e.staticContent)||void 0===s?void 0:s.text)&&"EndUser"!=(null===(o=t.sender)||void 0===o?void 0:o.role)})).map((t=>({id:t.entryPayload.abstractMessage.id,content:t.entryPayload.abstractMessage.staticContent.text,sender:{role:this.mapSenderRole(t.sender.role),displayName:t.senderDisplayName||"Unknown"},timestamp:t.clientTimestamp})))}handleParticipantChange(t){try{if(V.debug("Participant change event received:",t.data),!t.data)return;const i=JSON.parse(t.data),e=JSON.parse(i.conversationEntry.entryPayload).entries;let s=[];e.forEach((t=>{var i,e;const o=crypto.randomUUID();"add"===t.operation&&"agent"===t.participant.role.toLowerCase()&&s.push({id:o,isUser:!1,conversationId:o,type:"system",text:`${t.displayName} has joined the chat`,timestamp:new Date,sender:{role:"agent",displayName:null!==(i=null==t?void 0:t.displayName)&&void 0!==i?i:"System"}}),"remove"===t.operation&&"agent"===t.participant.role.toLowerCase()&&s.push({id:o,type:"system",text:`${t.displayName} has left the chat`,conversationId:o,isUser:!1,timestamp:new Date,sender:{role:"agent",displayName:null!==(e=null==t?void 0:t.displayName)&&void 0!==e?e:"System"}})})),(null==s?void 0:s.length)>0&&J.emit("AGENT_EVENT",s)}catch(t){V.error("Error handling participant change event:",t)}}mapEntriesToMessages(t){return t.map((t=>({id:t.entryPayload.abstractMessage.id,text:t.entryPayload.abstractMessage.staticContent.text,sender:{role:this.mapSenderRole(t.sender.role),displayName:t.senderDisplayName||"Unknown"},type:"endUser"===t.sender.role?"user":"ai",timestamp:new Date(t.timestamp),isUser:!1,conversationId:t.entryPayload.abstractMessage.id})))}handleParticipantMessage(t){var i,e;try{if(!t.data)return;const s=JSON.parse(t.data);if("EndUser"===(null===(e=null===(i=null==s?void 0:s.conversationEntry)||void 0===i?void 0:i.sender)||void 0===e?void 0:e.role))return void V.debug("Ignoring message from EndUser role");const o=JSON.parse(s.conversationEntry.entryPayload);s.conversationEntry.entryPayload=o;const n=this.mapEntriesToMessages([s.conversationEntry]);(null==n?void 0:n.length)>0&&J.emit("AGENT_MESSAGE",n)}catch(t){V.error("Error handling participant message event:",t)}}mapSenderRole(t){const i=t.toLowerCase();return"chatbot"===i?"agent":"enduser"===i?"endUser":"unknown"}handleSessionStatusChange(t){try{if(!t.data)return;const i=JSON.parse(t.data),e=JSON.parse(i.conversationEntry.entryPayload);V.debug("Session status changed:",null==e?void 0:e.sessionStatus),"Active"===(null==e?void 0:e.sessionStatus)&&J.emit("AGENT_SESSION_CREATED",!0)}catch(t){V.error("Error handling session status change event:",t)}}listenToMessages(){var t,i,e;V.debug("Listening to messages from Salesforce Live Agent");const s=new EventSource(`${this.endpointSSE}/bot/liveagent/sse?token=${null===(t=this.sessionContext)||void 0===t?void 0:t.accessToken}&org_id=${null===(i=this.configSettings)||void 0===i?void 0:i.orgId}&sse_url=${null===(e=this.configSettings)||void 0===e?void 0:e.instanceUrl}`,{withCredentials:!0});if(!s)throw V.error("Failed to create EventSource"),new Error("Failed to create EventSource");s.onerror=()=>{V.error("❌ SSE Error: Connection lost or error occurred"),J.emit("AGENT_ERROR",!0),s.close()},s.onopen=()=>{V.debug("✅ SSE Connection Established")},s.onmessage=t=>{var i,e;try{const o=JSON.parse(t.data);switch(V.debug("📡 Message Received on entrytype:",null===(i=null==o?void 0:o.conversationEntry)||void 0===i?void 0:i.entryType," --- ",t.data),null===(e=null==o?void 0:o.conversationEntry)||void 0===e?void 0:e.entryType){case"RoutingResult":case"RoutingWorkResult":V.debug("Conversation Routing Result:",t.data),J.emit("FINDING_AGENT",t.data);break;case"ParticipantChanged":V.debug("Conversation ParticipantChanged event received:",null==t?void 0:t.data),this.handleParticipantChange(t);break;case"Message":this.handleParticipantMessage(t);break;case"CloseConversation":J.emit("CONVERSATION_CLOSED",!0),s.close();break;case"DeliveryAcknowledgement":case"ReadAcknowledgement":V.debug("Conversation event received:",null==t?void 0:t.data);break;case"TypingStartedIndicator":J.emit("TYPING_STARTED",!0);break;case"TypingStoppedIndicator":V.debug("Typing indicator received:",t.data),J.emit("TYPING_STOPPED",!0);break;case"StreamingToken":V.debug("Streaming token received",t.data);break;case"ProgressIndicator":V.debug("Progress indicator received",t.data);break;case"SessionStatusChanged":V.debug("Session status changed event received",t.data),this.handleSessionStatusChange(t)}}catch(t){return void V.error("Failed to parse event data:",t)}}}async startChat(t){await this.initialize(t)}async resumeChat(t){var i,e,s;if(!(null==t?void 0:t.sessionId)||!(null==t?void 0:t.conversationId))throw new Error("resumeChat requires sessionId (accessToken) and conversationId");if(this.configSettings=(null==t?void 0:t.config)||this.configSettings,!(null===(i=this.configSettings)||void 0===i?void 0:i.instanceUrl)||!(null===(e=this.configSettings)||void 0===e?void 0:e.orgId)||!(null===(s=this.configSettings)||void 0===s?void 0:s.messagingChannelId))throw new Error("Missing required configuration settings for resuming Salesforce Live Agent session");this.sessionContext={accessToken:t.sessionId,conversationId:t.conversationId,userId:t.userId||"",isActive:!0,lastMessageReadTime:0};const o=new URL(`${this.configSettings.instanceUrl}/iamessage/api/v2/conversation/${this.sessionContext.conversationId}/entries`);o.searchParams.set("limit","1"),o.searchParams.set("direction","FromEnd");const n=await fetch(o.toString(),{method:"GET",headers:{Authorization:`Bearer ${this.sessionContext.accessToken}`}});if(401===n.status||403===n.status)throw new q;if(!n.ok)throw new Error(`Session probe failed: ${n.status} ${n.statusText}`);J.emit("liveAgentReady",void 0),this.listenToMessages()}async sendMessage(t){var i,e,s,o;if(!(await fetch(`${null===(i=this.configSettings)||void 0===i?void 0:i.instanceUrl}/iamessage/api/v2/conversation/${null===(e=this.sessionContext)||void 0===e?void 0:e.conversationId}/message`,{method:"POST",headers:{Authorization:`Bearer ${null===(s=this.sessionContext)||void 0===s?void 0:s.accessToken}`,"Content-Type":"application/json"},body:JSON.stringify({message:{id:crypto.randomUUID(),messageType:"StaticContentMessage",staticContent:{formatType:"Text",text:null==t?void 0:t.message}},esDeveloperName:null===(o=this.configSettings)||void 0===o?void 0:o.messagingChannelId,isNewMessagingSession:(null==t?void 0:t.isNewSession)||!1,language:""})})).ok)throw new Error("Failed to send message")}async pollMessages(t){return new Promise((async(t,i)=>{this.sessionContext.lastMessageReadTime=0;const e=async()=>{var s,o,n;try{const i=new URL(`${null===(s=this.configSettings)||void 0===s?void 0:s.instanceUrl}/iamessage/api/v2/conversation/${null===(o=this.sessionContext)||void 0===o?void 0:o.conversationId}/entries`);i.searchParams.append("limit","50"),i.searchParams.append("direction","FromEnd"),i.searchParams.append("startTimestamp",`${this.sessionContext.lastMessageReadTime}`);const a=await fetch(i.toString(),{method:"GET",headers:{Authorization:`Bearer ${null===(n=this.sessionContext)||void 0===n?void 0:n.accessToken}`}}),r=await a.json(),l=this.parseMessageEntries(r.conversationEntries).sort(((t,i)=>t.timestamp-i.timestamp)).map((t=>{var i;return{text:t.content,isUser:!1,id:t.id,timestamp:new Date(t.timestamp),images:[],conversationId:t.id,formModel:"",surveyDomId:"",sender:{role:"endUser"===t.sender.role?"user":"ai",displayName:null===(i=null==t?void 0:t.sender)||void 0===i?void 0:i.displayName}}}));(null==l?void 0:l.length)>0&&(this.sessionContext.lastMessageReadTime=(new Date).getTime(),J.emit("messageReceived",l)),t(l),setTimeout(e,5e3)}catch(t){V.error("Error on Polling",t.toString()),i(t)}};await e()}))}async isChatActive(t){return V.debug("sessionId",t),!!this.sessionContext&&this.sessionContext.isActive}async endChat(t){var i,e,s,o,n,a;if(null===(i=this.availabilityAbort)||void 0===i||i.abort(),null===(e=this.sessionContext)||void 0===e?void 0:e.conversationId){const t=await fetch(`${null===(s=this.configSettings)||void 0===s?void 0:s.instanceUrl}/iamessage/api/v2/conversation/${null===(o=this.sessionContext)||void 0===o?void 0:o.conversationId}?esDeveloperName=${null===(n=this.configSettings)||void 0===n?void 0:n.messagingChannelId}`,{method:"DELETE",headers:{Authorization:`Bearer ${null===(a=this.sessionContext)||void 0===a?void 0:a.accessToken}`,"Content-Type":"application/json"}});(null==t?void 0:t.ok)||V.warn("Failed to end the chat")}}async getTranscript(t){return V.debug("sessionId",t),this.sessionContext&&this.sessionContext.initialMessages||[]}}class K{constructor(){}static getProvider(t){if("salesforce"!==(null!=t?t:this.provider))throw new Error("Unsupported Live Agent provider");return this.providerInstance=new Z,this.providerInstance}}K.provider="salesforce";class Y{constructor(){this.logger=new c("LiveAgentEventHandler",{logLevel:u.Warn}),this.handleAgentMessage=t=>{let i="";if((null==t?void 0:t.length)>0)for(const e of t)i+=(null==e?void 0:e.text)+"\n\n";return i},this.sendMessage=t=>{this.liveAgentProvider?(this.logger.debug("Sending message to Live Agent:",t.message),this.liveAgentProvider.sendMessage(t)):this.logger.warn("Live Agent provider is not initialized. Cannot send message.")},this.disconnectLiveAgent=()=>{this.liveAgentProvider?(this.logger.debug("Disconnecting from Live Agent"),this.liveAgentProvider.endChat("")):this.logger.warn("Live Agent provider is not initialized. Cannot disconnect.")}}addAgentEventMessage(t){const i=document.createElement("div");return t.forEach((t=>{const e=document.createElement("div");e.className="py-2 border-b border-gray-200 text-center";const s=document.createElement("span");s.className="text-[10px] font-medium text-gray-500 tracking-wide",s.textContent=(null==t?void 0:t.text)||"Agent event",e.appendChild(s),i.appendChild(e)})),i}async connectToLiveAgent(t="salesforce",i){try{switch(this.logger.debug("Connected to Live Agent",t," --- ",i),t){case"salesforce":this.logger.debug("Using Salesforce Live Agent Provider"),this.liveAgentProvider=K.getProvider(t),await this.liveAgentProvider.startChat(i);break;case"custom":this.logger.debug("Using Custom Live Agent Provider");break;case"liveagent":this.logger.debug("Using LiveAgent Live Agent Provider");break;default:throw new Error(`Unsupported Live Agent provider: ${t}`)}}catch(t){throw this.logger.error("Error connecting to Live Agent:",t),t}}async resumeLiveAgentSession(t="salesforce",i){try{if(this.logger.debug("Resuming Live Agent session",t," --- ",i),this.liveAgentProvider=K.getProvider(t),!this.liveAgentProvider.resumeChat)throw new Error(`Provider '${t}' does not support session resume`);await this.liveAgentProvider.resumeChat(i)}catch(t){throw this.logger.error("Error resuming Live Agent session:",t),t}}}function Q(t){return!!function(t){return"object"==typeof t&&null!==t}(t)&&Array.isArray(t.messages)&&"boolean"==typeof t.isMinimized&&"boolean"==typeof t.isOpened&&"boolean"==typeof t.isExpanded&&"string"==typeof t.conversationId&&"string"==typeof t.projectId&&"boolean"==typeof t.newChat}function W(t){return"undefined"!=typeof TextEncoder?(new TextEncoder).encode(t).length:t.length}function X(t,i,e={}){var s,o,n,a;if("undefined"==typeof document)return!1;const r=null!==(s=e.path)&&void 0!==s?s:"/",l=null!==(o=e.sameSite)&&void 0!==o?o:"Lax",h=null!==(n=e.secure)&&void 0!==n?n:"undefined"!=typeof window&&"https:"===window.location.protocol,d=e.domain;let c=`${t}=${encodeURIComponent(i)}`;if(d){if(!/^[a-zA-Z0-9._-]+$/.test(d))return console.warn("AI12Z: Invalid cookie domain characters"),!1;c+=`; Domain=${d}`}c+=`; Path=${r}`,c+=`; SameSite=${l}`,c+="; Max-Age="+24*(null!==(a=e.maxAgeDays)&&void 0!==a?a:7)*60*60,h&&(c+="; Secure");const u=W(c);return u>4e3?(console.warn(`AI12Z: Cookie value exceeds safe limit (${u} bytes). Cookie not set.`),!1):(document.cookie=c,!0)}function tt(t,i,e={}){var s,o;const n=Object.assign({},i);(null===(s=n.messages)||void 0===s?void 0:s.length)>0&&(n.messages=[]);const a=JSON.stringify(n),r=encodeURIComponent(a),l=null!==(o=e.maxBytes)&&void 0!==o?o:3800;return W(r)>l?(console.warn(`AI12Z: Cookie '${t}' exceeds size limit and was skipped`),!1):X(t,a,e)}function it(t){if(!t)return;if("undefined"==typeof window)return;const i=t.replace(/^\./,""),e=window.location.hostname;if(e===i||e.endsWith("."+i))return t;console.warn("AI12Z: subDomain does not match current host")}const et=class{constructor(s){i(this,s),this.messageSent=e(this,"messageSent",7),this.messageReceived=e(this,"messageReceived",7),this.close=e(this,"close",7),this.open=e(this,"open",7),this.minimize=e(this,"minimize",7),this.errored=e(this,"errored",7),this.formSubmitted=e(this,"formSubmitted",7),this.isElementAvailable=e(this,"isElementAvailable",7),this.cdnPath="https://cdn.ai12z.net/assets/bot",this.surveyCDNPath="https://cdn.ai12z.net/pkg/surveyjs",this.styles=["https://cdn.jsdelivr.net/npm/@highlightjs/cdn-assets@11.11.1/styles/default.min.css","https://cdn.ai12z.net/assets/bot/v2/tailwind.min.css"],this.liveAgentEventHandler=new Y,this.customStyle="",this.customJS="",this.dataOverrideFunction=null,this.ignoreChunks=!1,this.unreadCount=0,this.liveAgentButtonText="Talk to a Live Agent",this.isLiveAgentEnabled=!1,this.isTypingIndicatorVisible=!1,this.dataKey=t.DATA_KEY||"",this.dataMode=t.DATA_MODE||"prod",this.dataAttributes={},this.excludeTags=[],this.includeTags=[],this.botSettings={},this.canRender=!0,this.voiceType="default",this.voice="en-US",this.showSubmit=!1,this.hideAllButtons=!1,this.showMenu=!1,this.isProse=!0,this.isLiveAgent=!1,this.isConnectingLiveAgent=!1,this.showWelcomeScreen=!0,this.showHistory=!1,this.conversationId="",this.surveyDomId="",this.searchResults={},this.buttons=[],this.currentDomId="",this.messages=[],this.questionCounter=0,this.timestamp="",this.rowCount=1,this.isBot=!1,this.conversationHistory=[],this.query="",this.scriptArray=[],this.imagesBase64List=[],this.focusedIndex=-1,this.isAnimated=!1,this.isMinimized=!1,this.isStreaming=!1,this.showErrorMessage=!1,this.errorMessage="",this.emptyMessageError=!1,this.isOpened=!1,this.isContent=!1,this.isToggled=!1,this.showPrivacy=!1,this.isRendered=!1,this.showShortcutsDialog=!1,this.showLiveAgentEndDialog=!1,this.liveAgentSessionId="",this.liveAgentConversationId="",this.liveAgentProviderName="salesforce",this.liveAgentListenersRegistered=!1,this.shortcuts=D,this.announceMessage="",this.messageRefs=[],this.handlePaste=t=>{var i;t.preventDefault();const e=(null===(i=t.clipboardData)||void 0===i?void 0:i.getData("text"))||"";if(this.inputEl&&e){const t=this.inputEl,i=t.selectionStart,s=t.selectionEnd,o=t.value,n=o.substring(0,i)+e+o.substring(s);t.value=n;const a=i+e.length;t.setSelectionRange(a,a),setTimeout((()=>{this.adjustHeight()}),0)}},this.checkHistory=()=>{const t=localStorage.getItem(`${this.visitorID}`);let i=[];t&&(i=JSON.parse(t),i=i.filter((t=>{var i;return t.projectId===(null===(i=this.botSettings)||void 0===i?void 0:i.pId)}))),this.showHistory=i.length>0&&"v1"===this.botSettings.botVersion},this.initializeScript=t=>T(t,this.mainObject),this.renderSurvey=async t=>{if(this.surveyDomId){await this.assetLoader.loadSurveyDependencies();try{await $({chat:t,surveyDomId:this.surveyDomId,shadowRoot:this.el.shadowRoot,config:{dataKey:this.dataKey,dataMode:this.dataMode,dataAttributes:this.dataAttributes,formSubmitRenderCallback:t=>{this.handleSurveyCompletionRender(t)},onSubmitError:t=>{var i;const e=null===(i=this.el.shadowRoot)||void 0===i?void 0:i.querySelector(`#${this.surveyDomId}`);e?e.innerHTML="Form submission blocked by validation"!==t?"Failed to submit form":"Submission blocked due to suspicious activity.":console.error(`Survey element not found for DOM ID: ${this.surveyDomId}`)}}})}catch(t){console.error("Error rendering survey:",t)}}else console.warn("Survey DOM ID is empty")},this.handleMessage=(t,i)=>{const e=new h.Converter,s=this.el.shadowRoot.querySelector(`#${i}`);if(!s)return void console.error(`Message bubble with ID ${i} not found.`);var o=s.getAttribute("data-bubbleText")||"";s.setAttribute("data-bubbleText",o+=t),s.setAttribute("aria-label",o),s.setAttribute("role","log"),s.setAttribute("aria-live","polite"),s.setAttribute("aria-atomic","false");let n=e.makeHtml(o);s.innerHTML=n},this.updateScreenSize=()=>{window.innerWidth<=767&&(this.isMinimized=!this.isOpened)},this.handleSend=async(t,i={})=>{const{isHide:e=!1,isLiveChatEnded:s=!1}=i;this.emptyMessageError=!1,this.surveyDomId="",this.announce("Message sent successfully"),this.isLiveAgent||(this.questionCounter=this.questionCounter+1,localStorage.setItem("ai12z-bot-data",JSON.stringify({qCounter:this.questionCounter})));const o=t;this.inputEl&&(this.inputEl.value=o),0===this.messages.length&&this.botSettings.autoResetTimer>0&&this.startTimer(),this.showWelcomeScreen&&"v1"===this.botSettings.botVersion&&(this.showWelcomeScreen=!1),0===this.messages.length?await this.socketConnection():this.socket&&this.socket.connected||await this.socketConnection();const n=(new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});this.messages=[...this.messages,{text:o,isUser:!0,id:`user-${p()}`,timestamp:n,images:this.imagesBase64List,conversationId:this.conversationId,isLoading:!1,formModel:{},surveyDomId:"",isHide:null!=e&&e},{text:this.botSettings.maxQuestion>0&&this.questionCounter>this.botSettings.maxQuestion&&!this.isLiveAgent&&!s?""!==this.botSettings.msgLimit?this.botSettings.msgLimit:"Sorry, you have reached the maximum number of questions.":"",isUser:!1,id:"",timestamp:"",isLoading:!(this.botSettings.maxQuestion>0&&this.questionCounter>this.botSettings.maxQuestion&&!this.isLiveAgent&&!s),images:[],conversationId:this.conversationId,formModel:{},surveyDomId:""}],2===this.messages.length&&(this.visitorID=g()),this.checkHistory(),setTimeout((()=>{this.scrollToBottom()}),100),this.botSettings.maxQuestion>0&&this.questionCounter>this.botSettings.maxQuestion&&!this.isLiveAgent&&!s?this.inputEl.value="":(this.currentDomId="",this.isLiveAgent?(this.messages=this.messages.slice(0,-1),this.liveAgentEventHandler.sendMessage({sessionId:"",message:this.inputEl.value}),this.updateBotState(),this.inputEl.value&&(this.inputEl.value=""),this.query=""):(this.checkLiveAgentMode(),this.isStreaming=!0,this.ignoreChunks=!1,this.invokeSocket()));const a=this.el.shadowRoot.querySelector("#previewContainer");a&&(a.innerHTML=""),this.imagesBase64List=[],this.rowCount=1,this.showSubmit=!1},this.agentMessageCreated=t=>{if(""===this.currentDomId){const t=this.messages[this.messages.length-1];if(t.sender&&null!==t.sender&&"system"!==t.type){const{id:t,idChanged:i}=F(this.currentDomId,this.messages,"chatbot");this.currentDomId=t,i&&(this.messages=[...this.messages])}else{const t=m(this.conversationId);this.currentDomId=`chatbot-${p()}`,t.id=this.currentDomId,t.isLoading=!1,this.messages=[...this.messages,t]}}const i=this.liveAgentEventHandler.handleAgentMessage(t);i&&(this.announce("New message received from live agent"),requestAnimationFrame((()=>{var e;const s=null===(e=this.el.shadowRoot)||void 0===e?void 0:e.querySelector(`#${this.currentDomId}`);if(s){const e=new h.Converter;let o=s.getAttribute("data-bubbleText")||"";o=`${o} \n\n ${i}`,s.setAttribute("data-bubbleText",o);let n=e.makeHtml(o);this.updateConversations(n,t[0]),this.updateBotState()}setTimeout((()=>{this.scrollToBottom()}),10)})))},this.addEventMessage=t=>{const i=this.liveAgentEventHandler.addAgentEventMessage([{text:t}]);if(""===this.currentDomId&&this.messages.length>0&&(this.currentDomId=this.messages[this.messages.length-1].id),i&&this.currentDomId){const t=this.el.shadowRoot.querySelector(`#${this.currentDomId}`);if(t)return t.parentNode.appendChild(i),this.currentDomId="",i}return null},this.findingAgent=()=>{this.announce("Finding a live agent for you"),this.isTypingIndicatorVisible=!1,this.removeFindingAgentPlaceholder();const t=this.addEventMessage("Connecting to a live agent...");t&&t.setAttribute("data-finding-agent","true"),this.currentDomId=""},this.handleTypingStarted=t=>{this.isTypingIndicatorVisible=t},this.handleTypingStopped=()=>{this.isTypingIndicatorVisible=!1},this.handleAgentError=()=>{this.addEventMessage("Something went wrong with Live Agent, please try again later"),this.isLiveAgent=!1,this.liveAgentSessionId="",this.liveAgentConversationId="",this.isTypingIndicatorVisible=!1,this.liveAgentEventHandler.disconnectLiveAgent(),this.clearEvents(),this.liveAgentButtonText="Talk to a Live Agent",this.announce("Live agent connection failed")},this.handleAgentConversationEnded=()=>{this.isLiveAgent&&(this.addEventMessage("Conversation closed with Live Agent"),this.announce("Live agent chat ended")),this.isLiveAgent=!1,this.liveAgentSessionId="",this.liveAgentConversationId="",this.isTypingIndicatorVisible=!1,this.liveAgentButtonText="Talk to a Live Agent",this.clearEvents()},this.agentEventHandler=t=>{if(this.isTypingIndicatorVisible=!1,(null==t?void 0:t.length)>0){const i=t.map((t=>({id:t.id||`system-${p()}`,text:t.text||"",type:"system",isUser:!1,isLoading:!1,timestamp:new Date,images:[],conversationId:this.conversationId,formModel:{},surveyDomId:"",sender:t.sender||null})));this.messages=[...this.messages,...i],this.updateBotState(),this.removeFindingAgentPlaceholder(),this.inputEl&&(this.inputEl.value=""),this.currentDomId=""}},this.handleAgentSessionCreated=()=>{this.announce("Connected to live agent"),this.isLiveAgent=!0,this.liveAgentButtonText="End Live Agent chat",requestAnimationFrame((()=>{var t;const i=null===(t=this.el.shadowRoot)||void 0===t?void 0:t.querySelector('[data-testid="user-input-textarea"]');i&&(this.inputEl=i)}))},this.handleAgentSessionInfo=t=>{this.liveAgentSessionId=(null==t?void 0:t.sessionId)||"",this.liveAgentConversationId=(null==t?void 0:t.conversationId)||"",this.isLiveAgent=!0,this.updateBotState()},this.handleAgentUnavailable=()=>{this.addEventMessage("Live Agent is currently unavailable. Please try again later."),this.isTypingIndicatorVisible=!1,this.isLiveAgent=!1,this.liveAgentSessionId="",this.liveAgentConversationId="",this.updateBotState(),this.announce("Live agent is currently unavailable"),this.clearEvents()},this.toggleBot=()=>{this.isToggled=!this.isToggled},this.menuClick=t=>{switch(t.type){case"menu":this.toggleBot(t),this.showHistory=!1,this.showWelcomeScreen=!0,this.isStreaming||this.handleSend(t.button.label);break;case"history":this.toggleBot(t),this.showHistory=!0,this.loadConversation();break;case"end":this.messages=[],this.conversationId="",this.isOpened=!1,this.isMinimized=!this.isExpanded,this.showWelcomeScreen=!0,this.toggleBot(t),this.showHistory=!1,this.close.emit("close");break;case"startover":this.messages=[],this.conversationId="",this.isOpened=!0,this.isMinimized=!1,this.showWelcomeScreen=!0,this.toggleBot(t),this.showHistory=!1,this.updateBotState()}}}get mainObject(){return window.ai12z||(window.ai12z={}),window.ai12z}handleKeyDown(t){var i,e;if(!["Control","Shift","Alt","Meta"].includes(t.key)){if(("?"===t.key||"/"===t.key)&&t.shiftKey&&(t.metaKey||t.ctrlKey)&&!this.isInputFocused())return t.preventDefault(),void(this.showShortcutsDialog=!this.showShortcutsDialog);if(this.showShortcutsDialog&&("Escape"===t.key||("?"===t.key||"/"===t.key)&&t.shiftKey&&(t.metaKey||t.ctrlKey)))return t.preventDefault(),void(this.showShortcutsDialog=!1);if("k"===t.key&&(t.metaKey||t.ctrlKey))return t.preventDefault(),t.stopPropagation(),void this.action("open");if("h"===t.key&&(t.metaKey||t.ctrlKey))return t.preventDefault(),t.stopPropagation(),this.showHistory=!this.showHistory,this.showWelcomeScreen=!1,void this.loadConversation();if("n"===t.key&&(t.metaKey||t.ctrlKey))return t.preventDefault(),t.stopPropagation(),void this.handleNewConversation();"Enter"===t.key&&!t.shiftKey&&this.isOpened&&this.isInputFocused()&&(t.preventDefault(),t.stopPropagation(),(null===(i=this.inputEl)||void 0===i?void 0:i.value.trim().length)>0&&!this.isStreaming?this.handleSend(this.inputEl.value):0===(null===(e=this.inputEl)||void 0===e?void 0:e.value.trim().length)&&0===this.imagesBase64List.length&&(this.emptyMessageError=!0,this.announce("Message cannot be empty. Please enter a message."),this.inputEl&&this.inputEl.focus(),setTimeout((()=>{this.emptyMessageError=!1}),3e3))),"Escape"===t.key&&(this.action("minimize"),this.showPrivacy&&(this.showPrivacy=!1,t.preventDefault()))}}isInputFocused(){var t;const i=(null===(t=this.el.shadowRoot)||void 0===t?void 0:t.activeElement)||document.activeElement;return"TEXTAREA"===(null==i?void 0:i.tagName)||"INPUT"===(null==i?void 0:i.tagName)}handleNewConversation(){this.messages=[],this.conversationId="",this.showWelcomeScreen=!0,this.showHistory=!1,this.isOpened=!0,setTimeout((()=>{var t;null===(t=this.inputEl)||void 0===t||t.focus()}),100)}buttonClickHandler(t){this.showWelcomeScreen=!1,this.query=t.detail.action,this.handleSend(t.detail.label)}sendQueryToBotHandler(t){this.showWelcomeScreen=!1,this.query=t.detail,this.handleSend(t.detail)}deleteChatHistoryHandler(t){var i;const e=this.getConversationHistory().filter((i=>i.conversationId!==t.detail.conversationId));localStorage.setItem(`${this.visitorID}`,JSON.stringify(e)),this.conversationHistory=R(e,null===(i=this.botSettings._id)||void 0===i?void 0:i.$oid,this.botSettings.pId)}chatClickHandler(t){t.detail.length>0&&(this.messages=t.detail,requestAnimationFrame((()=>{this.hydrateMessagesFromState()}))),this.showWelcomeScreen=!1,this.showHistory=!1}openChatHandler(t){}formSubmittedHandler(t){t.stopPropagation(),this.formSubmitted.emit(t.detail.data)}async sendMessage(t,i,e){this.query=t,this.handleSend(null!=i?i:t,e)}async sendQuery(t){console.warn("sendQuery mehtdod is deprecated, use sendMessage instead"),this.handleSend(t)}async sendJSON(t,i){this.query=JSON.stringify(t),this.handleSend(i)}async openBot(t=!1){this.openChat(t)}async action(t,i){var e;"open"===t&&this.openChat(null!==(e=null==i?void 0:i.expanded)&&void 0!==e&&e),"minimize"===t&&this.isOpened&&this.minimizeChat(),this.checkHistory(),"close"===t&&(this.searchResults={},this.surveyDomId="",this.showWelcomeScreen=!0,this.showHistory=this.messages.length>0,this.messages=[],this.conversationId="",this.close.emit("close"),this.announce("Chat closed"),clearInterval(this.timer))}async setProcessDataOverride(t){this.dataOverrideFunction=t}async configureSettings(t){this.botSettings=Object.assign(Object.assign({},this.botSettings),t)}connectedCallback(){f(this.dataKey,this.dataMode).then((t=>{this.canRender=t}))}async componentWillLoad(){this.checkCustomSlot(),this.timestamp=b(new Date),this.updateScreenSize(),await this.configBot(),this.visitorID="ai12z-"+localStorage.getItem("ai12z-visitorId"),this.hydrateStateFromStorage(),U("bot",this.dataKey,this.dataMode)}onDataKeyChange(t){U("bot",this.dataKey,this.dataMode)}onDataModeChange(t){U("bot",this.dataKey,this.dataMode)}hydrateStateFromStorage(){var t,i,e;const s=null===(t=this.botSettings)||void 0===t?void 0:t.pId;if(!s)return void console.warn("AI12Z: Cannot hydrate state - projectId not available");const o=I(s,null===(i=this.botSettings._id)||void 0===i?void 0:i.$oid)||function(t,i){const e=function(t){if("undefined"==typeof document)return null;const i=t.replace(/([.*+?^${}()|[\]\\])/g,"\\$1"),e=document.cookie.match(new RegExp(`(?:^|; )${i}=([^;]*)`));return e?decodeURIComponent(e[1]):null}(t);if(!e)return null;try{const s=JSON.parse(e);return i&&!i(s)?(console.warn(`AI12Z: Cookie '${t}' failed validation`),null):s}catch(t){return console.warn("AI12Z: Failed to parse cookie JSON:",t),null}}(L(s,null===(e=this.botSettings._id)||void 0===e?void 0:e.$oid),Q);o&&(this.isOpened=o.isOpened,this.isMinimized=o.isMinimized,this.isExpanded=o.isExpanded,this.conversationId=o.conversationId,o.newChat||(this.messages=[...o.messages||[]]),o.isLiveAgent&&o.liveAgentSessionId&&o.liveAgentConversationId&&(this.isLiveAgent=o.isLiveAgent||!0,this.liveAgentSessionId=o.liveAgentSessionId,this.liveAgentConversationId=o.liveAgentConversationId,this.liveAgentProviderName=o.liveAgentProviderName||"salesforce",this.liveAgentButtonText="End Live Agent chat",setTimeout((()=>this.recoverLiveAgentSession()),0)),setTimeout((()=>{this.scrollToBottom()}),100))}async recoverLiveAgentSession(){var t,i,e,s,o,n;if(0===Object.keys(null!==(e=null===(i=null===(t=this.botSettings)||void 0===t?void 0:t.liveagent)||void 0===i?void 0:i.providers)&&void 0!==e?e:{}).length||!this.liveAgentSessionId||!this.liveAgentConversationId)return;const a=null!==(n=null===(o=null===(s=this.botSettings)||void 0===s?void 0:s.liveagent)||void 0===o?void 0:o.providers[this.liveAgentProviderName])&&void 0!==n?n:null;if(a)try{this.registerLiveAgentListeners(),await this.liveAgentEventHandler.resumeLiveAgentSession(this.liveAgentProviderName,{sessionId:this.liveAgentSessionId,conversationId:this.liveAgentConversationId,userId:this.visitorID,config:a})}catch(t){t instanceof q?(this.addEventMessage("Your live agent session has expired. Please reconnect."),this.announce("Live agent session expired")):console.warn("AI12Z: Failed to recover live agent session, ending gracefully:",t),this.isLiveAgent=!1,this.liveAgentSessionId="",this.liveAgentConversationId="",this.liveAgentButtonText="Talk to a Live Agent",this.clearEvents()}}componentDidLoad(){E(this.el),"undefined"==typeof window||window.Handlebars||(window.Handlebars=S),s.register("bot",this),window.addEventListener("resize",this.updateScreenSize.bind(this)),document.addEventListener("click",this.handleClickOutside.bind(this));const t=document.createElement("script");t.text='\n var ai12zChat = window["ai12z"] = {}\n ',document.head.appendChild(t),this.el.shadowRoot.appendChild(t),this.assetLoader||this.initializeAssetLoader(),this.messages.length>0&&requestAnimationFrame((()=>{this.hydrateMessagesFromState()})),s.setActive("bot")}async hydrateMessagesFromState(){var t,i,e,s;if((null===(t=this.el)||void 0===t?void 0:t.shadowRoot)&&0!==this.messages.length){await new Promise((t=>requestAnimationFrame((()=>t()))));for(const t of this.messages)if(!t.isUser&&t.id){if("template"===t.controlType)this.processTemplateData(t,t.itemComponent);else if("form"===t.controlType){if(!t.surveyDomId)continue;if(this.surveyDomId=t.surveyDomId,!/^[a-zA-Z][a-zA-Z0-9_-]*$/.test(t.surveyDomId)){console.warn("Invalid surveyDomId, skipping render");continue}t.text=`<div id=${this.surveyDomId} style="width: 100%;" class="survey-container"></div>`,(await _(`#${t.id}`,this.el)).querySelector(`#${t.surveyDomId}`)||await _(`#${t.surveyDomId}`,this.el),await this.renderSurvey(t.itemComponent)}else if("carousel"===t.controlType&&"carousel"===(null===(i=t.itemComponent)||void 0===i?void 0:i.controlType))this.processChatData(t,t.itemComponent);else if(!t.controlType){t.text=w(t.text,(null===(e=this.botSettings)||void 0===e?void 0:e.linkTarget)||"_blank","ai12z-link",null===(s=this.botSettings)||void 0===s?void 0:s.utm,"answer");const i=y(t.text);t.text=i.body,this.buttons=i.buttons,this.addEventListeners(`#${t.id}`)}"form"!==t.controlType&&this.checkHighlightcode(t.id)}}}disconnectedCallback(){document.removeEventListener("click",this.handleClickOutside.bind(this)),window.removeEventListener("resize",this.updateScreenSize)}handleClickOutside(t){this.showMenu&&this.plusIconRef&&!this.plusIconRef.contains(t.target)&&(this.showMenu=!1)}async initializeAssetLoader(){try{this.assetLoader=O({shadowRoot:this.el.shadowRoot,cdnPath:this.cdnPath,surveyCDNPath:this.surveyCDNPath,customStyles:this.styles}),await this.assetLoader.loadBotAssets()}catch(t){console.error("❌ Failed to initialize asset loader:",t)}}async processDataOverride(t){if(this.dataOverrideFunction&&"function"==typeof this.dataOverrideFunction)try{return await this.dataOverrideFunction(t)}catch(t){throw console.error("Error in custom processDataOverride:",t),t}return t}announce(t){this.announceMessage=t,setTimeout((()=>{this.announceMessage=""}),1e3)}openChat(t=!1){var i,e;this.unreadCount=0,s.setActive("bot"),this.isExpanded=t,this.isMinimized=!1,this.isContent=!1,this.isOpened=!0;const o=L(this.botSettings.pId,null===(i=this.botSettings._id)||void 0===i?void 0:i.$oid);if(sessionStorage.getItem(o))this.updateBotState();else{const t={messages:[],isMinimized:this.isMinimized,isOpened:this.isOpened,isExpanded:this.isExpanded,conversationId:this.conversationId,projectId:this.botSettings.pId,configId:null===(e=this.botSettings._id)||void 0===e?void 0:e.$oid,newChat:!0};sessionStorage.setItem(o,JSON.stringify(t)),this.botSettings.cookies&&it(this.botSettings.subDomain)&&tt(o,t,{domain:this.botSettings.subDomain})}setTimeout((()=>{this.announce("Chat opened")}),600),requestAnimationFrame((()=>{requestAnimationFrame((()=>{this.imageUploaderRef&&this.isElementAvailable.emit(!0)}))})),this.open.emit("open")}minimizeChat(){this.isOpened=!1,this.isContent=!!this.isExpanded,this.isMinimized=!this.isExpanded,this.isAnimated=!1,this.updateScreenSize(),this.announce("Chat minimized"),this.minimize.emit("minimize")}adjustHeight(){this.inputEl&&(this.inputEl.style.height="auto",this.inputEl.style.height=this.inputEl.scrollHeight+"px")}async configBot(){var t,i,e,s,o;const n={apiKey:this.dataKey,configId:this.configId,configType:"bot"};try{const a=await x(n,this.dataMode);if(a){if(this.botSettings=a,(null===(i=null===(t=this.botSettings)||void 0===t?void 0:t.v3)||void 0===i?void 0:i.siteKey)?z(a._id,a.v3.siteKey,"bot",this.dataKey,this.dataMode,(t=>{this.errored.emit(t),this.announce("An error occurred while loading the chat.")})).then((t=>{t&&(this.isRendered=!0)})).catch((t=>{console.error("Recaptcha verification failed:",t),this.isRendered=!1})):this.isRendered=!0,"v2"!==this.botSettings.botVersion||this.botSettings.isExpanded||this.isBot||this.isOpened||(this.isMinimized=!0),this.assetLoader||await this.initializeAssetLoader(),this.assetLoader)try{await this.assetLoader.loadBotTheme(this.botSettings)}catch(t){console.error("Failed to load bot theme:",t)}if(this.botSettings.isExpanded&&!this.isBot?(this.isExpanded=!0,this.isMinimized=!1):this.isOpened||(this.isMinimized=!0),this.botSettings.linkTarget||(this.botSettings.linkTarget="_blank"),this.botSettings.customCSS&&(this.customStyle=this.botSettings.customCSS),this.botSettings.customJS&&(this.customJS=this.botSettings.customJS),"v2"===this.botSettings.botVersion){const t=localStorage.getItem("ai12z-visitorId");this.visitorID="ai12z-"+t}if(this.botSettings.privacyTemplate&&""!==this.botSettings.privacyTemplate&&(this.showPrivacy=!0),this.botSettings.audioType&&(this.voiceType=this.botSettings.audioType,this.voice=this.botSettings.voice),this.botSettings&&!(null===(e=this.botSettings)||void 0===e?void 0:e.cookies)){const t=it(this.botSettings.subDomain);!function(t,i={}){const{path:e="/",domain:s}=i;"undefined"!=typeof document&&function(t,i="/",e){X(t,"",{maxAgeDays:0,path:i,domain:e})}(t,e,s)}(L(this.botSettings.pId,null===(o=null===(s=this.botSettings)||void 0===s?void 0:s._id)||void 0===o?void 0:o.$oid),{domain:t})}}}catch(t){console.error("Error loading bot configuration:",t)}}checkCustomSlot(){const t=this.el.children;if(t&&t.length>0)for(var i=0;i<t.length;i++)"bot"!==t[i].tagName.toLowerCase()&&"bot"!==t[i].getAttribute("slot")||(this.isBot=!0,this.isExpanded=!1)}handleSocketResponse(){this.socket.off("response"),this.socket.off("end_response"),this.socket.off("chunk"),this.socket.off("complete"),void 0===this.botSettings.maxQuestion||0===this.botSettings.maxQuestion?(this.botSettings.maxQuestion=0,this.handleBotMessages()):this.questionCounter<=this.botSettings.maxQuestion&&this.handleBotMessages()}hideSpinner(t){return new Promise((i=>{const e=this.el.shadowRoot.querySelector(`#${t.id}`);if(e){const t=e.querySelector("#spinner");t&&(t.style.display="none")}i(!0)}))}async processTemplateData(t,i){await N(t,i,this.el.shadowRoot,(t=>this.hideSpinner(t)),(t=>this.renderTemplateData(t)),(t=>{this.messages=this.messages.map((i=>i.id===t.id?t:i))}),S)}async renderTemplateData(t){await B(t,this.el,this.scriptArray,this.mainObject,this.initializeScript)}async processChatData(t,i){d(t,i,this.el,(t=>this.hideSpinner(t)),(t=>{this.messages=this.messages.map((i=>i.id===t.id?t:i)),this.updateBotState()}),this.customJS,this.customStyle,this.isExpanded)}handleBotMessages(){const t=A(this.dataMode),i="v2"===t?"complete":"end_response";this.socket.on("v2"===t?"chunk":"response",(async i=>{const{id:e,idChanged:s}=F(this.currentDomId,this.messages,"chatbot");this.currentDomId=e,s&&(this.messages=[...this.messages]);const o="v2"===t?i.content:i.data;requestAnimationFrame((()=>{this.ignoreChunks||(this.messages[this.messages.length-1].isLoading=!1,this.handleMessage(o,this.currentDomId))}))})),this.socket.on(i,(async i=>{const e="v2"===t?r(i):i;void 0!==e.showInput&&"boolean"==typeof e.showInput&&(this.botSettings.showInput=e.showInput),this.unreadCount++;const{id:s,idChanged:o,orphaned:n}=F(this.currentDomId,this.messages,"chatbot");this.currentDomId=s,o&&(this.messages=[...this.messages]),n||this.messageReceived.emit({data:e,domId:this.currentDomId}),this.announce(this.isOpened?"New message received":"New message received while chat is minimized"),requestAnimationFrame((async()=>{var t,i,s,o,n,a,r;try{const l={element:this.el,hideSpinner:t=>{this.hideSpinner(t)},updateConversations:(t,i)=>this.updateConversations(t,i),renderSurvey:t=>this.renderSurvey(t),processTemplateData:(t,i)=>this.processTemplateData(t,i),processChatData:(t,i)=>this.processChatData(t,i),checkHighlightcode:t=>this.checkHighlightcode(t),addEventListeners:t=>this.addEventListeners(t),customStyle:this.customStyle,customJS:this.customJS,controlSettings:this.botSettings,utmConfig:null===(t=this.botSettings)||void 0===t?void 0:t.utm,conversationId:this.conversationId};if(await P({data:e,currentDomId:this.currentDomId,inputType:"bot",setMessages:t=>{this.messages=[...this.messages,t],requestAnimationFrame((()=>{setTimeout((()=>{t&&t.id&&this.hideSpinner(t).then((()=>{}))}),0)}))},setSurveyDomId:t=>{this.surveyDomId=t},setButtons:t=>{this.buttons=t},config:l}),e.liveAgent&&!this.isLiveAgent&&!this.isConnectingLiveAgent){this.liveAgentDirective=e.liveAgent,this.isConnectingLiveAgent=!0;try{await this.connectLiveChat()}finally{this.isConnectingLiveAgent=!1}}if(e.liveAgent&&!this.isLiveAgent&&!this.isConnectingLiveAgent){this.isConnectingLiveAgent=!0;try{await this.connectLiveChat()}finally{this.isConnectingLiveAgent=!1}}if(this.conversationId=e.conversationId,j(null===(i=this.botSettings)||void 0===i?void 0:i.pId,this.messages,this.conversationId,null!==(o=null===(s=this.botSettings._id)||void 0===s?void 0:s.$oid)&&void 0!==o?o:"",this.visitorID,"bot",{isMinimized:this.isMinimized,isOpened:this.isOpened,isExpanded:this.isExpanded}),this.visitorID&&2===this.messages.length){const t=L(this.botSettings.pId,null===(n=this.botSettings._id)||void 0===n?void 0:n.$oid);sessionStorage.setItem(t,JSON.stringify({isMinimized:this.isMinimized,isOpened:this.isOpened,isExpanded:this.isExpanded,messages:this.messages,conversationId:this.conversationId,configId:null===(a=this.botSettings._id)||void 0===a?void 0:a.$oid,visitorID:this.visitorID,projectId:null===(r=this.botSettings)||void 0===r?void 0:r.pId,date:new Date}))}else this.updateBotState();this.scrollToBottom(),this.isStreaming=!1,this.currentDomId=""}catch(t){console.error("Error handling end_response:",t),this.isStreaming=!1}}))}))}updateConversations(t,i){var e,s,o,n,a,r;const l={id:this.currentDomId,text:t,isUser:!1,isLoading:!1,timestamp:(new Date).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),images:[],conversationId:this.conversationId,formModel:null!==(n=null!==(o=null===(s=null===(e=i.controlData)||void 0===e?void 0:e.data)||void 0===s?void 0:s.source)&&void 0!==o?o:i.controlData)&&void 0!==n?n:{},surveyDomId:this.surveyDomId,controlType:i.controlType,thumbsId:`${p()}`,showIcon:!i.controlType&&!this.surveyDomId,insightId:null!==(a=null==i?void 0:i.insightId)&&void 0!==a?a:null,sender:null!==(r=null==i?void 0:i.sender)&&void 0!==r?r:null,itemComponent:i};this.messages=this.messages.map((t=>t.id===this.currentDomId?l:t)),requestAnimationFrame((()=>{this.checkHighlightcode(this.currentDomId),this.currentDomId=""}))}checkHighlightcode(t=""){var i;try{if(!t)return console.warn("highlightcodeId is empty"),void(this.isProse=!0);const e=null===(i=this.el.shadowRoot)||void 0===i?void 0:i.querySelector(`#${t}`);if(!e)return console.warn(`Element with id '${t}' not found in shadowRoot`),void(this.isProse=!0);const s=e.querySelectorAll("pre");s.length>0?(e.classList.remove("prose"),import("./p-C3lNE7QP.js").then((function(t){return t.i})).then((({default:t})=>{t.configure({ignoreUnescapedHTML:!0}),s.forEach((i=>{i.dataset.highlighted?console.warn("Element previously highlighted..."):t.highlightElement(i)}))})).catch((t=>console.error("Failed to load highlight.js:",t)))):"form"!==this.messages[this.messages.length-1].controlType&&e.classList.add("prose")}catch(t){console.error("Error in highlightcode:",t),this.isProse=!0}}handleSurveyCompletionRender(t){const i=this.messages.findIndex((i=>i.surveyDomId===t.domId));-1!==i?(this.currentDomId=this.messages[i].id,this.surveyDomId=t.domId,this.updateConversations(t.completedHtml,{}),this.sendMessage(t.jsonData,t.completeText,{isHide:!0}),this.formSubmitted.emit(t.sender.data),this.scrollToBottom()):console.warn("Could not find message to update for survey completion")}addEventListeners(t){const i=this.el.shadowRoot.querySelector(t);i&&this.buttons.forEach((t=>{const e=i.querySelector(`#${t.id}`);if(e){const i=e.getAttribute("data-original-click");if(!i)return void console.warn(`originalClickHandler is not defined for button with id: ${t.id}`);const s=i.match(/^([\w.]+)\s*\(([\s\S]*)\)$/);if(s){const i=s[1],o=s[2],n=this,a=i.includes(".")?i.split(".").pop():i,r=n[a];e.addEventListener("click",(()=>{if("function"==typeof n[a])try{switch(a){case"sendQuery":console.warn("sendQuery is deprecated, use sendMessage instead");const i=G(o);if(!i)return;i[0]=t.label,r.apply(n,i);break;case"sendMessage":const e=G(o);if(!e)return;r.apply(n,e);break;case"sendJSON":const s=G(o);if(!s)return;r.apply(n,s);break;default:console.warn(`Unknown function: ${a}`)}}catch(t){console.error(`Error invoking ${i}:`,t)}else console.warn(`Function ${a} not found on this`)}))}}}))}async socketConnection(){const t=A(this.dataMode);let i=v(this.dataMode);this.socket=l(i,{transports:"v2"===t?["websocket","polling"]:["polling"]}),await new Promise(((i,e)=>{let s=!1;const o=setTimeout((()=>{if(!s){s=!0;const t="Unable to connect to server. Please try again later.";console.error("Socket connection timed out"),this.errored.emit({message:t,code:"CONNECTION_TIMEOUT"}),e(new Error(t))}}),3e4);this.socket.on("connect",(()=>{"v2"===t?(this.socket.emit("authenticate",{api_key:this.dataKey}),this.socket.once("authenticated",(()=>{s||(s=!0,clearTimeout(o)),this.handleSocketResponse(),i()})),this.socket.once("error",(t=>{"AUTH_FAILED"!==t.code&&"AUTH_REQUIRED"!==t.code&&"AUTH_ERROR"!==t.code||(s||(s=!0,clearTimeout(o)),this.errored.emit(t),e(new Error(t.message)))}))):(s||(s=!0,clearTimeout(o)),this.handleSocketResponse(),i())}))})).catch((t=>{console.error("Socket connection failed:",t.message),this.messages.length>0&&(this.messages[this.messages.length-1].text=t.message,this.messages[this.messages.length-1].isLoading=!1,this.messages=[...this.messages]),this.isStreaming=!1})),this.socket.on("connect_error",(t=>{this.errored.emit(t),this.announce("Unable to connect to chat server. Please try again."),console.error("Connection error:",t)})),this.socket.on("disconnect",(()=>{this.socket.off("response"),this.socket.off("chunk")}))}invokeSocket(){var t;let i,e;"v2"===A(this.dataMode)?(e="query",i={query:""!==this.query?this.query:this.inputEl.value,conversation_id:this.conversationId||"",base64_images:(null===(t=this.imagesBase64List)||void 0===t?void 0:t.length)>0?this.imagesBase64List:void 0}):(e="evaluate_query",i={apiKey:this.dataKey,query:""!==this.query?this.query:this.inputEl.value,conversationId:this.conversationId,event:"evaluate_query",attributes:this.dataAttributes,excludeTags:this.excludeTags,includeTags:this.includeTags,base64Images:this.imagesBase64List,meta:k()}),this.processDataOverride(i).then((t=>{null!=t&&(this.messageSent.emit(JSON.stringify(t)),this.socket.emit(e,t,(t=>{t&&(this.errored.emit(t),this.announce("Unable to send message. Please try again."),this.currentDomId=`chatbot-${p()}`,this.messages[this.messages.length-1].id=this.currentDomId,this.messages[this.messages.length-1].text="Error connecting to server. Please try again later.")})),this.inputEl&&(this.inputEl.value="",this.adjustHeight()),this.query="")})).catch((t=>{console.error("Error in processDataOverride:",t),this.errored.emit(t),this.announce("An error occurred while sending your message.")}))}getConversationHistory(){const t=localStorage.getItem(`${this.visitorID}`);return t?JSON.parse(t):[]}loadConversation(){var t;this.showWelcomeScreen=!1;const i=localStorage.getItem(`${this.visitorID}`);i&&(this.conversationHistory=JSON.parse(i),this.conversationHistory=R(this.conversationHistory,null===(t=this.botSettings._id)||void 0===t?void 0:t.$oid,this.botSettings.pId))}startTimer(){this.timer=setInterval((()=>{this.questionCounter=0,localStorage.setItem("ai12z-bot-data",JSON.stringify({qCounter:this.questionCounter}))}),this.botSettings.autoResetTimer)}stopResponse(){this.ignoreChunks=!0,this.isStreaming=!1,this.messages[this.messages.length-1].isLoading=!1}scrollToBottom(){const t=this.el.shadowRoot.querySelector(".chat-body");t&&t.scroll({top:t.scrollHeight,behavior:"smooth"}),this.isOpened&&(this.unreadCount=0)}checkLiveAgentMode(){var t,i,e,s;const o=(null===(i=null===(t=this.botSettings)||void 0===t?void 0:t.liveagent)||void 0===i?void 0:i.providers)&&Object.keys(null===(s=null===(e=this.botSettings)||void 0===e?void 0:e.liveagent)||void 0===s?void 0:s.providers).length>0;this.isLiveAgentEnabled=o&&this.messages.length>1}openEndLiveAgentDialog(){this.isToggled=!1,this.showLiveAgentEndDialog=!0}closeEndLiveAgentDialog(){this.showLiveAgentEndDialog=!1}async handleLiveAgentToolbarAction(){this.isLiveAgent?this.openEndLiveAgentDialog():await this.connectLiveChat()}confirmEndLiveAgent(){this.showLiveAgentEndDialog=!1,this.disconnectLiveChat()}disconnectLiveChat(){var t,i,e,s;this.liveAgentEventHandler.disconnectLiveAgent(),this.isLiveAgent=!1,this.liveAgentSessionId="",this.liveAgentConversationId="",this.liveAgentButtonText="Talk to a Live Agent",this.sendMessage(""!==(null===(t=this.botSettings)||void 0===t?void 0:t.llmMessageOnDisconnect)?null===(i=this.botSettings)||void 0===i?void 0:i.llmMessageOnDisconnect:"The live agent has been disconnected. Please do not initiate the live agent directive again.",""!==(null===(e=this.botSettings)||void 0===e?void 0:e.userMessageOnDisconnect)?null===(s=this.botSettings)||void 0===s?void 0:s.userMessageOnDisconnect:"The live agent has ended the conversation.",{isLiveChatEnded:!0}),this.announce("Live agent chat ended"),this.clearEvents()}removeFindingAgentPlaceholder(){var t;const i=null===(t=this.el.shadowRoot)||void 0===t?void 0:t.querySelector('[data-finding-agent="true"]');if(null==i?void 0:i.parentNode){const t=i.parentNode;t.removeChild(i),t.parentNode&&0===t.childElementCount&&t.parentNode.removeChild(t)}}registerLiveAgentListeners(){this.liveAgentListenersRegistered||(this.liveAgentListenersRegistered=!0,J.on("FINDING_AGENT",this.findingAgent),J.on("AGENT_EVENT",this.agentEventHandler),J.on("AGENT_UNAVAILABLE",this.handleAgentUnavailable),J.on("TYPING_STARTED",this.handleTypingStarted),J.on("TYPING_STOPPED",this.handleTypingStopped),J.on("AGENT_MESSAGE",this.agentMessageCreated),J.on("AGENT_ERROR",this.handleAgentError),J.on("CONVERSATION_CLOSED",this.handleAgentConversationEnded),J.on("AGENT_SESSION_INFO",this.handleAgentSessionInfo))}clearEvents(){this.liveAgentListenersRegistered=!1,J.off("FINDING_AGENT",this.findingAgent),J.off("AGENT_EVENT",this.agentEventHandler),J.off("AGENT_UNAVAILABLE",this.handleAgentUnavailable),J.off("AGENT_MESSAGE",this.agentMessageCreated),J.off("AGENT_ERROR",this.handleAgentError),J.off("CONVERSATION_CLOSED",this.handleAgentConversationEnded),J.off("TYPING_STARTED",this.handleTypingStarted),J.off("TYPING_STOPPED",this.handleTypingStopped),J.off("AGENT_SESSION_CREATED",this.handleAgentSessionCreated),J.off("AGENT_SESSION_INFO",this.handleAgentSessionInfo)}async connectLiveChat(){var t,i,e,s,o,n,a,r,l,h,d,c,u,v,p,g,m,f;this.announce("Connecting to live agent"),this.clearEvents();const b=Object.keys(null!==(e=null===(i=null===(t=this.botSettings)||void 0===t?void 0:t.liveagent)||void 0===i?void 0:i.providers)&&void 0!==e?e:{});if(0===b.length)return console.error("No live agent provider found in bot settings"),void this.announce("Live agent is not configured");b.length>1&&console.warn("Multiple live agent providers found, using the first one");let w=null!==(a=null===(n=null===(o=null===(s=this.botSettings)||void 0===s?void 0:s.liveagent)||void 0===o?void 0:o.providers)||void 0===n?void 0:n[b[0]])&&void 0!==a?a:null,y=null!==(h=null===(l=null===(r=this.botSettings)||void 0===r?void 0:r.liveagent)||void 0===l?void 0:l.businessHours)&&void 0!==h?h:null,x=null!==(u=null===(c=null===(d=this.botSettings)||void 0===d?void 0:d.liveagent)||void 0===c?void 0:c.timezone)&&void 0!==u?u:null;if(!w)return console.error("No live agent settings found for the provider",b[0]),void this.announce("Live agent settings are unavailable");if(w){let t=this.getConversationHistory().filter((t=>{var i;return t.conversationId===this.conversationId&&t.projectId===(null===(i=this.botSettings)||void 0===i?void 0:i.pId)}));const i=Object.entries(this.liveAgentDirective&&"object"==typeof this.liveAgentDirective?this.liveAgentDirective:{}).map((([t,i])=>({label:t.charAt(0).toUpperCase()+t.slice(1),value:i,displayToAgent:!0})));if(this.isTypingIndicatorVisible=!0,w={config:w,userId:this.visitorID,conversationId:this.conversationId,messageHistory:t,extraPrechatFormDetails:i},this.liveAgentProviderName=b[0],y&&x){let t;try{t=M(y,x)}catch(t){return console.error("AI12Z: unexpected error evaluating business hours — blocking live agent connection",t),this.announce("Unexpected error evaluating business hours. Live agent connection blocked."),this.addEventMessage("Unexpected error evaluating business hours. Please try again later."),void(this.isTypingIndicatorVisible=!1)}if(!t){const t=null!==(p=null===(v=w.config)||void 0===v?void 0:v.outsideBusinessHoursMessage)&&void 0!==p?p:"Our live agents are currently offline. Please try again during our business hours.";return this.addEventMessage(t),this.announce("Live agents are currently offline"),void(this.isTypingIndicatorVisible=!1)}}if("liveagent"===b[0]){if(!this.liveAgentRef)return this.isTypingIndicatorVisible=!1,console.error("LiveAgent reference is not set"),void this.announce("Live agent is currently unavailable");await this.liveAgentRef.startChat(),this.isLiveAgent=!0,this.liveAgentButtonText="End Live Agent chat",this.announce("Connected to live agent")}else{const t=Number(null===(g=null==w?void 0:w.config)||void 0===g?void 0:g.maxWaitTime),i=1e3*(Number.isFinite(t)&&t>=5?t:300);this.registerLiveAgentListeners();try{await this.liveAgentEventHandler.connectToLiveAgent(b[0],w)}catch(t){return console.error("Live agent connection error:",t),this.isTypingIndicatorVisible=!1,this.liveAgentSessionId="",this.liveAgentConversationId="",this.updateBotState(),this.addEventMessage("Issue connecting to live agent. Please try again later."),this.announce("Issue connecting to live agent. Please try again later."),this.liveAgentEventHandler.disconnectLiveAgent(),void this.clearEvents()}let e,s=()=>{};try{await new Promise(((t,o)=>{s=()=>{this.handleAgentSessionCreated(),t("SUCCESS")},J.on("AGENT_SESSION_CREATED",s),e=setTimeout((()=>o(new Error("TIMEOUT"))),i)}))}catch(t){this.liveAgentSessionId="",this.liveAgentConversationId="",this.isLiveAgent=!1,this.isTypingIndicatorVisible=!1;const i=null!==(f=null===(m=w.config)||void 0===m?void 0:m.maxWaitMessage)&&void 0!==f?f:"Sorry, no agents are available at the moment.";this.removeFindingAgentPlaceholder(),this.addEventMessage(i),this.liveAgentEventHandler.disconnectLiveAgent(),this.clearEvents(),this.updateBotState(),this.announce("Agents are not available at this time.")}finally{e&&clearTimeout(e),J.off("AGENT_SESSION_CREATED",s)}}}}handleMessageKeyNav(t,i){var e,s;if("ArrowDown"===t.key){t.preventDefault();const s=Math.min(this.messages.length-1,i+1);this.focusedIndex=s,null===(e=this.messageRefs[s])||void 0===e||e.focus()}else if("ArrowUp"===t.key){t.preventDefault();const e=Math.max(0,i-1);this.focusedIndex=e,null===(s=this.messageRefs[e])||void 0===s||s.focus()}}async updateBotState(){var t,i,e,s;const o=L(this.botSettings.pId,null===(t=this.botSettings._id)||void 0===t?void 0:t.$oid);let n=await C(o);if(n||(n=I(this.botSettings.pId,null===(i=this.botSettings._id)||void 0===i?void 0:i.$oid)),"string"==typeof n)try{n=JSON.parse(n)}catch(t){console.error("AI12Z: Failed to parse bot state from sessionStorage:",t)}Array.isArray(n)&&(n=n.find((t=>{var i;return t.projectId===(null===(i=this.botSettings)||void 0===i?void 0:i.pId)}))||null);const a={isMinimized:this.isMinimized,isOpened:this.isOpened,isExpanded:this.isExpanded,messages:this.messages,conversationId:this.conversationId,projectId:null===(e=this.botSettings)||void 0===e?void 0:e.pId,configId:null===(s=this.botSettings)||void 0===s?void 0:s._id.$oid,newChat:0===this.messages.length,isLiveAgent:this.isLiveAgent,liveAgentProviderName:this.liveAgentProviderName,liveAgentSessionId:this.liveAgentSessionId,liveAgentConversationId:this.liveAgentConversationId};0===this.messages.length&&(this.conversationId="");try{sessionStorage.setItem(o,JSON.stringify(a)),this.botSettings.cookies&&it(this.botSettings.subDomain)&&tt(o,function(t,i){var e={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&i.indexOf(s)<0&&(e[s]=t[s]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(s=Object.getOwnPropertySymbols(t);o<s.length;o++)i.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(e[s[o]]=t[s[o]])}return e}(a,["liveAgentSessionId","liveAgentConversationId"]),{domain:this.botSettings.subDomain})}catch(t){console.error("AI12Z: Failed to update bot state in sessionStorage:",t)}}skipTo(t){var i;const e=null===(i=this.el.shadowRoot)||void 0===i?void 0:i.querySelector("#"+t);e&&e.focus()}render(){var t,i,e,s,a,r,l,h,d,c,u,v,p,g,m,f,b,w,y,x,k,C;return this.canRender?o("div",{lang:"en"},o("div",{class:"skip-links "+(this.isOpened?"visible":"hidden")},o("a",{class:"skip-link",href:"#main-content",onClick:()=>this.skipTo("main-content")},"Skip to main content"),o("a",{class:"skip-link",href:"#message-input",onClick:()=>{var t;null===(t=this.inputEl)||void 0===t||t.focus()}},"Skip to message input")),"v1"!==this.botSettings.botVersion&&this.isRendered&&o("div",{class:`pt-0 show-grid ${this.isAnimated?"transition ease-out duration-300":""} layout ${this.isOpened?"is-open":""} ${this.isExpanded?"is-expanded":""} search-flex`,style:{gridTemplateColumns:`0fr minmax(${null!==(t=this.botSettings.minWidth)&&void 0!==t?t:"340px"}, ${null!==(i=this.botSettings.maxWidth)&&void 0!==i?i:"375px"}) 0fr`,paddingTop:null!==(s=null===(e=this.botSettings)||void 0===e?void 0:e.paddingTop)&&void 0!==s?s:"96px"}},o("div",{class:"modal-overlay",role:"none","aria-label":"Close Modal",style:{display:this.isExpanded&&this.isOpened?"grid":"none",opacity:this.isExpanded&&this.isOpened?"1":"0",pointerEvents:this.isExpanded&&this.isOpened?"all":"none"}}),o("div",{class:"modal","data-testid":"modal","aria-hidden":"false",role:"dialog","aria-modal":"true",tabindex:"-1",style:{display:this.isOpened?"grid":"none",opacity:this.isOpened?"1":"0",transform:this.isOpened?"none":"translateY(100%)"}},o("header",{role:"banner"},o("div",{class:"flex bg-white overflow-hidden border-b border-gray-90 border-solid md:pl-3 pl-4 justify-end md:rounded-t-xl items-center toolbar"},o("div",{class:"flex gap-1 toolbar-overflow-actions"},this.isLiveAgentEnabled&&(null===(l=null===(r=null===(a=this.botSettings)||void 0===a?void 0:a.liveagent)||void 0===r?void 0:r.providers)||void 0===l?void 0:l.liveagent)&&o("live-agent-chat",{config:null===(c=null===(d=null===(h=this.botSettings)||void 0===h?void 0:h.liveagent)||void 0===d?void 0:d.providers)||void 0===c?void 0:c.liveagent,ref:t=>this.liveAgentRef=t}),!this.showHistory&&o("button",{class:"rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-transparent hover:bg-blue-95 disabled:bg-transparent disabled:hover:bg-transparent h-6 w-6 bot-btn-primary",tabindex:"0","aria-label":"options menu","aria-haspopup":"menu","aria-expanded":this.isToggled?"true":"false","aria-controls":"dropdown-menu",onClick:t=>{t.preventDefault(),t.stopPropagation(),this.toggleBot(t)}},o("i",{class:"block wes-icon--loading text-body2 modal-toolbar-icon ",title:"Options Menu"},o("svg",{viewBox:"0 0 24 24",id:"align-left-2","data-name":"Flat Line",xmlns:"http://www.w3.org/2000/svg",class:"icon flat-line",fill:"currentColor","aria-hidden":"true"},o("g",{id:"SVGRepo_bgCarrier","stroke-width":"0"}),o("g",{id:"SVGRepo_tracerCarrier","stroke-linecap":"round","stroke-linejoin":"round"}),o("g",{id:"SVGRepo_iconCarrier"},o("path",{id:"primary",d:"M3,12H17M3,6H21M3,18H13",style:{fill:"none",stroke:"currentColor"}}))))),this.showHistory&&o("button",{class:"w-6 h-6 back-btn bot-btn-primary",tabindex:"0","aria-label":"Back",onClick:t=>{t.preventDefault(),t.stopPropagation(),this.showHistory=!1,this.showWelcomeScreen=!0,this.isOpened=!0,this.isMinimized=!1,this.isAnimated=!0}},o("i",{title:"Back"},o("svg",{viewBox:"0 0 200 200","data-name":"Layer 1",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20","aria-hidden":"true"},o("g",{id:"SVGRepo_bgCarrier","stroke-width":"0"}),o("g",{id:"SVGRepo_tracerCarrier","stroke-linecap":"round","stroke-linejoin":"round"}),o("g",{id:"SVGRepo_iconCarrier"},o("title",null),o("path",{d:"M160,89.75H56l53-53a9.67,9.67,0,0,0,0-14,9.67,9.67,0,0,0-14,0l-56,56a30.18,30.18,0,0,0-8.5,18.5c0,1-.5,1.5-.5,2.5a6.34,6.34,0,0,0,.5,3,31.47,31.47,0,0,0,8.5,18.5l56,56a9.9,9.9,0,0,0,14-14l-52.5-53.5H160a10,10,0,0,0,0-20Z"}))))),o("hamburger-menu",{isToggled:this.isToggled,botSettings:this.botSettings,messages:this.messages,liveAgentButtonText:this.liveAgentButtonText,isLiveAgentEnabled:this.isLiveAgentEnabled,onHamburgerMenuClick:t=>{this.menuClick(t.detail)},onHandleByLiveAgent:()=>{this.handleLiveAgentToolbarAction()},onToggledChange:t=>{this.isToggled=t.detail}})),(null===(u=this.botSettings)||void 0===u?void 0:u.botLogo)&&o("img",{src:null===(v=this.botSettings)||void 0===v?void 0:v.botLogo,class:"w-8 h-8 rounded-lg",alt:"Bot Logo"}),o("h2",{class:"flex-1 pl-2 heading text-body1"},null===(p=this.botSettings)||void 0===p?void 0:p.botName),o("div",{class:"buttons flex gap-2 p-[10px]"},this.isLiveAgent&&o("button",{"aria-label":"End Live Agent",title:"End Live Agent",onClick:()=>this.openEndLiveAgentDialog()},o("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24px",viewBox:"0 -960 960 960",width:"24px",fill:"#151313"},o("path",{d:"m136-304-92-90q-12-12-12-28t12-28q88-95 203-142.5T480-640q118 0 232.5 47.5T916-450q12 12 12 28t-12 28l-92 90q-11 11-25.5 12t-26.5-8l-116-88q-8-6-12-14t-4-18v-114q-38-12-78-19t-82-7q-42 0-82 7t-78 19v114q0 10-4 18t-12 14l-116 88q-12 9-26.5 8T136-304Zm104-198q-29 15-56 34.5T128-424l40 40 72-56v-62Zm480 2v60l72 56 40-38q-29-26-56-45t-56-33Zm-480-2Zm480 2Z"}))),this.messages.length>0&&o("button",{class:"rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-transparent hover:bg-blue-95 disabled:bg-transparent disabled:hover:bg-transparent h-6 w-6 bot-btn-primary",tabindex:"0",onClick:t=>{t.preventDefault(),this.messages=[],this.isOpened=!0,this.isMinimized=!1,this.showWelcomeScreen=!0,this.showHistory=!1,this.updateBotState(),this.checkLiveAgentMode()},"aria-label":"Start New Conversation",title:"Start New Conversation"},o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",width:"20",height:"20",class:"modal-toolbar-icon","aria-hidden":"true"},o("circle",{cx:"4",cy:"4",r:"1.5"}),o("circle",{cx:"10",cy:"4",r:"1.5"}),o("circle",{cx:"16",cy:"4",r:"1.5"}),o("circle",{cx:"4",cy:"10",r:"1.5"}),o("circle",{cx:"10",cy:"10",r:"1.5"}),o("circle",{cx:"16",cy:"10",r:"1.5"}),o("circle",{cx:"4",cy:"16",r:"1.5"}),o("circle",{cx:"10",cy:"16",r:"1.5"}),o("circle",{cx:"16",cy:"16",r:"1.5"}))),o("button",{class:"rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-transparent hover:bg-blue-95 disabled:bg-transparent disabled:hover:bg-transparent h-6 w-6 bot-btn-primary",tabindex:"0",onClick:t=>{t.preventDefault(),this.showShortcutsDialog=!0},"aria-label":"Keyboard Shortcuts",title:"Keyboard Shortcuts (Press ? for help)"},o("i",{class:"wes-block wes-icon--loading wes-text-body2 modal-toolbar-icon",title:"Keyboard Shortcuts"},o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true"},o("path",{d:"M3 5C3 3.89543 3.89543 3 5 3H19C20.1046 3 21 3.89543 21 5V14C21 15.1046 20.1046 16 19 16H13L9 21V16H5C3.89543 16 3 15.1046 3 14V5Z",stroke:"currentColor","stroke-width":"2"}),o("circle",{cx:"12",cy:"10",r:"1",fill:"currentColor"}),o("path",{d:"M9 10C9 8.34315 10.3431 7 12 7",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"})))),o("button",{class:"rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-transparent hover:bg-blue-95 disabled:bg-transparent disabled:hover:bg-transparent h-6 w-6 hidden md:flex bot-btn-primary",tabindex:"0",onClick:()=>{this.isExpanded=!this.isExpanded,this.isAnimated=!0,this.updateBotState()},"aria-label":"Collapse Bot to Side Panel","aria-expanded":this.isExpanded?"true":"false","aria-controls":"settings-panel"},o("i",{class:"wes-block wes-icon--loading wes-text-body2 modal-toolbar-icon",title:"Collapse Bot to Side Panel"},this.isExpanded&&o("svg",{viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-hidden":"true"},o("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M18.215 14.7076H27.692C28.3074 14.7076 28.492 14.0307 27.9997 13.5383L24.9843 10.4614L30.5228 4.86149C30.8305 4.5538 30.8305 3.99995 30.5228 3.69226L28.2459 1.41536C27.9382 1.16921 27.4459 1.16921 27.0767 1.4769L21.5381 7.01532L18.3997 3.99995C17.9073 3.50765 17.2304 3.69226 17.2304 4.30764V13.7845C17.2304 14.2153 17.7843 14.7076 18.215 14.7076ZM13.7847 17.2308H4.30766C3.69227 17.2308 3.50765 17.9077 3.99996 18.4L7.01537 21.4769L1.47686 27.0769C1.16917 27.3846 1.16917 27.9384 1.47686 28.2461L3.75381 30.523C4.0615 30.8307 4.55381 30.8307 4.92305 30.523L10.5231 24.923L13.6616 27.9384C14.0924 28.4923 14.7693 28.3076 14.7693 27.6923V18.2769C14.7693 17.8462 14.2154 17.2308 13.7847 17.2308Z"})),!this.isExpanded&&o("svg",{viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-hidden":"true"},o("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M30.0308 1.23071H20.4923C19.8769 1.23071 19.6923 1.78455 20.1846 2.27686L23.2 5.29222L17.6615 10.8306C17.3538 11.1383 17.3538 11.6306 17.6615 11.9999L19.9384 14.2768C20.2461 14.5845 20.7384 14.5845 21.1077 14.2768L26.7077 8.67681L29.7231 11.6922C30.2154 12.1845 30.7692 11.9999 30.7692 11.3845V1.90763C30.7692 1.5384 30.4 1.23071 30.0308 1.23071ZM2.15379 30.7692H11.6307C12.2461 30.7692 12.4307 30.0923 11.9384 29.6L8.92303 26.5231L14.4615 20.9231C14.7692 20.6154 14.7692 20.0616 14.4615 19.7539L12.1846 17.477C11.8769 17.1693 11.3846 17.1693 11.0153 17.477L5.47687 23.0154L2.39995 20C1.8461 19.5077 1.23071 19.6923 1.23071 20.3077V29.7846C1.23071 30.2153 1.72302 30.7692 2.15379 30.7692Z"})))),o("button",{class:"rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-transparent hover:bg-blue-95 disabled:bg-transparent disabled:hover:bg-transparent h-6 w-6 bot-btn-primary","data-testid":"modal-minimize",tabindex:"0","aria-label":"Minimize",onClick:()=>{this.isOpened=!1,this.isContent=!(!this.isExpanded||!this.botSettings.isExpanded),this.isMinimized=!this.isExpanded||!this.botSettings.isExpanded,this.isAnimated=!1,this.updateScreenSize(),this.updateBotState(),this.announce("Chat minimized"),this.minimize.emit("minimize")}},o("i",{class:"block wes-icon--loading text-body2 modal-toolbar-icon",title:"Minimize Bot"},o("svg",{viewBox:"0 0 26 26",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-hidden":"true"},o("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M25 24.25C25 24.65 24.65 25 24.25 25H1.75C1.35 25 1 24.65 1 24.25V22.75C1 22.35 1.35 22 1.75 22H24.25C24.65 22 25 22.35 25 22.75V24.25Z"}))))))),o("div",{class:"flex-1 flex flex-col main",role:"main","aria-labelledby":"chat-main-heading",id:"main-content",tabindex:"-1"},o("h1",{id:"chat-main-heading",class:"sr-only"},"Chat"),o("div",{class:"h-full flex flex-col chat-body"},o("div",{class:"px-5 flex-[1_1_0] min-h-[calc(100%-1px)] flex flex-col gap-y-3 @md:px-3 messages-container",role:"region","aria-labelledby":"messages-region-heading"},o("h2",{id:"messages-region-heading",class:"sr-only"},"Messages"),this.showWelcomeScreen&&o("div",{class:"@md:px-6 pb-3 @md:pb-7 @md:pt-8 pt-5 text-display5",innerHTML:null===(m=null===(g=this.botSettings)||void 0===g?void 0:g.welcome)||void 0===m?void 0:m.message}),this.messages.length>0&&!this.showHistory&&this.messages.map(((t,i)=>{var e,s,n,a;return"system"===t.type?o("div",{class:"flex justify-center pb-3 message-item",role:"listitem",tabindex:-1,ref:t=>this.messageRefs[i]=t,"aria-label":t.text},o("span",{class:"text-[10px] font-medium text-gray-500 tracking-wide border-b border-gray-200 py-1 px-3 text-center"},t.text)):o("div",{class:`flex pb-3 gap-x-2 @md:gap-x-3 \n ${t.isUser?"self-end":""}\n ${t.isUser?"justify-end":""} end-user-message message-item`,style:{opacity:"1",transform:"none"},role:"listitem",tabindex:i===this.focusedIndex?0:-1,onKeyDown:t=>this.handleMessageKeyNav(t,i),ref:t=>this.messageRefs[i]=t,"aria-label":"Message from "+(t.isUser?"User":"Bot")},t.isUser&&!t.isHide&&o("div",{class:"flex flex-col items-end"},o("div",{"data-testid":"message",class:"break-words @md:text-body2 box-border @md:pr-4 flex-1 rounded-lg py-2 px-4 user-msg text-body3",innerHTML:t.text,id:t.id,"aria-live":"polite","aria-atomic":"false","aria-label":t.text,role:"log"},null===(e=null==t?void 0:t.images)||void 0===e?void 0:e.map((t=>o("img",{src:t,class:"thumbnail",alt:"thumbnail images"})))),o("div",{class:"text-gray-30 pt-2 text-right text-body4"},"Sent ",t.timestamp)),!t.isUser&&o("div",{class:"avatar-column"},o("chat-avatar",{id:`la${t.id}`,senderType:(null==t?void 0:t.sender)?"agent":"bot",avatarUrl:null===(s=this.botSettings)||void 0===s?void 0:s.botAvatar})),!t.isUser&&o("div",{class:"flex flex-col",style:{width:"100%"}},o("div",{"data-testid":"message",class:{prose:"form"!==t.controlType,"transition-all":!0,"duration-300":!0,"opacity-100":this.isProse,"opacity-90":!this.isProse,"max-w-full break-words @md:text-body2 box-border @md:pr-4 flex-1 rounded-lg text-gray-30 pr-2 text-body3":!0},innerHTML:t.text,id:t.id},t.isLoading&&o("div",{class:"w-full rounded-md",id:"spinner"},o("div",{class:"flex animate-pulse space-x-4"},o("div",{class:"flex-1 space-y-3 py-1"},o("div",{class:"h-4 rounded bg-gray-200"}),o("div",{class:"space-y-3"},o("div",{class:"grid grid-cols-3 gap-4"},o("div",{class:"col-span-2 h-4 rounded bg-gray-200"}),o("div",{class:"col-span-1 h-4 rounded bg-gray-200"})),o("div",{class:"h-4 rounded bg-gray-200"})))))),""!==t.text&&t.showIcon&&(null===(n=this.botSettings.showMessageIcons)||void 0===n||n)&&o("interaction-buttons",{message:t,chatArray:this.messages,currentIndex:i,dataKey:this.dataKey,dataMode:this.dataMode,voice:this.voice,voiceType:this.voiceType,source:"bot",conversationId:this.conversationId,projectId:(null===(a=this.botSettings)||void 0===a?void 0:a.pId)||""}),o("div",{class:"text-gray-30 pt-2 text-body4"},this.botSettings.botName," • ",t.timestamp)))})),this.showHistory&&o("chatbot-history",{chatList:this.conversationHistory,botName:null===(f=this.botSettings)||void 0===f?void 0:f.botName,styles:this.customStyle,scripts:this.customJS}),o("div",{class:"h-px pt-2px",style:{overflowAnchor:"auto"}})),o("div",{role:"status","aria-live":"polite","aria-atomic":"true",class:"sr-only"},this.announceMessage)))),!1!==(null===(b=this.botSettings)||void 0===b?void 0:b.showInput)&&o("form",{"data-testid":"user-input",class:`relative pointer-events-auto ${this.isOpened?"p-2.5":""} searchform user-input`,"aria-label":"Message Area","aria-hidden":"false",style:{opacity:this.isMinimized?"0":"1",transform:"translateX(0)",pointerEvents:this.isMinimized?"none":"auto"}},!this.isOpened&&o("div",{class:`absolute right-4 md:right-0 border-2 border-white border-solid rounded-full ${this.isContent?"":"top-0"} minimize-input`},o("button",{class:"rounded-full flex items-center justify-center disabled:cursor-not-allowed bg-gray-500 bg-opacity-60 hover:bg-opacity-80 h-5 w-5 bot-btn-primary","aria-label":"Minimize Bot",tabindex:"0",onClick:t=>{t.preventDefault(),this.isMinimized=!this.isMinimized,this.isOpened=!this.isMinimized,this.updateBotState()}},o("i",{class:"block ai-minimize-icon ai-text-caption",title:"Minimize Bot"},o("svg",{xmlns:"http://www.w3.org/2000/svg",height:"52",width:"52",viewBox:"0 0 520 520",fill:"#fff","aria-hidden":"true"},o("path",{d:"M500 275c0 8-7 15-15 15H35c-8 0-15-7-15-15v-30c0-8 7-15 15-15h450c8 0 15 7 15 15z"}))))),o("fieldset",{class:"flex flex-col @md:mx-0 @md:rounded-t-xl transition-colors "+(this.isMinimized&&!this.isExpanded?"":"p-4 user-input-fieldset")},!this.isExpanded&&this.isOpened&&0===this.messages.length&&o("privacy-modal",{show:this.showPrivacy,message:this.botSettings.privacyTemplate}),o("div",{class:"flex-1 align-bottom"},o("div",{"aria-hidden":this.isTypingIndicatorVisible?"false":"true",class:"flex items-center justify-center w-full "+(this.isTypingIndicatorVisible?"h-12 opacity-100":"h-0 opacity-0 pointer-events-none")},o("typing-indicator",null)),o("div",{class:"grow-wrap show-grid after:whitespace-pre-wrap after:invisible relative","data-replicated-value":"","aria-disabled":"false"},this.botSettings.imageUpload&&o("div",{"aria-disabled":"true",class:`absolute flex items-center left-0 bottom-0 h-full pl-4 pr-2 ${this.hideAllButtons?"hidden":""} agent-input-icon`},o("button",{class:"plus-icon bot-btn-primary",tabindex:"0","aria-label":"Add Image",onClick:t=>{t.stopPropagation(),t.preventDefault(),this.showMenu=!this.showMenu}},o("i",{class:"plus-icon wes-block wes-text-body1",title:"Add Image"},o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",width:"20",height:"20","aria-hidden":"true"},o("path",{d:"M10.75 4.75a.75.75 0 0 0-1.5 0v4.5h-4.5a.75.75 0 0 0 0 1.5h4.5v4.5a.75.75 0 0 0 1.5 0v-4.5h4.5a.75.75 0 0 0 0-1.5h-4.5v-4.5Z"})))),o("div",{class:"absolute bottom-6 left-0 w-44 bg-white rounded-lg shadow-lg transition-all duration-300 ease-in-out z-10\n "+(this.showMenu?"opacity-100 scale-100 pointer-events-auto":"opacity-0 scale-90 pointer-events-none")},o("ul",{class:"space-y-2",ref:t=>this.plusIconRef=t},o("li",{class:"px-4 py-2 hover:bg-gray-100 cursor-pointer flex",onClick:()=>{this.showMenu=!1}},o("image-uploader",{maxImages:10,images:this.imagesBase64List,targetElement:this.inputEl,onImagesChange:t=>{this.errorMessage="",this.showErrorMessage=!1,this.imagesBase64List=[...t.detail]},onImageUploadError:t=>{this.errorMessage=t.detail,this.showErrorMessage=!0,this.announce(t.detail||"Image upload failed")},ref:t=>this.imageUploaderRef=t}))))),o("div",{class:"textarea"},this.imagesBase64List.length>0&&o("div",{class:"flex flex-wrap gap-2 mx-1 mt-2.5 mb-1"},this.imagesBase64List.map(((t,i)=>o("div",{class:"image-Container sc-ai12z-input-form",key:i},o("img",{src:t,style:{width:"70px",height:"50px",borderRadius:".75rem"},alt:"uploaded image"}),o("span",{class:"delete-image sc-ai12z-input-form cursor-pointer ml-1",onClick:()=>{this.imagesBase64List=this.imagesBase64List.filter(((t,e)=>e!==i)),this.imageUploaderRef&&"function"==typeof this.imageUploaderRef.removeImageAtIndex&&this.imageUploaderRef.removeImageAtIndex(i),this.imagesBase64List=[...this.imagesBase64List]}},"×"))))),o("textarea",{id:"message-input","aria-invalid":this.emptyMessageError,"aria-describedby":[this.emptyMessageError?"empty-message-error":"","message-hint",0===this.messages.length?"input-enter-tip":""].filter(Boolean).join(" "),"aria-placeholder":this.isLiveAgent?"Type a message to the agent...":""!==(null===(w=this.botSettings)||void 0===w?void 0:w.botPlaceholderText)?null===(y=this.botSettings)||void 0===y?void 0:y.botPlaceholderText:"Ask me anything","aria-label":"Type your message here",class:"resize-none overflow-hidden text-ellipsis focus:outline-none w-full custom-input "+(this.hideAllButtons?"hidden":""),"data-testid":"user-input-textarea",rows:this.rowCount,name:"userMessage",placeholder:this.isLiveAgent?"Type a message to the agent...":""!==(null===(x=this.botSettings)||void 0===x?void 0:x.botPlaceholderText)?null===(k=this.botSettings)||void 0===k?void 0:k.botPlaceholderText:"Ask me anything",ref:t=>this.inputEl=t,onKeyUp:()=>{this.adjustHeight()},onKeyDown:t=>{this.handleKeyDown(t),"Enter"!==t.key||t.shiftKey||(this.isOpened=!0)},onPaste:t=>{this.handlePaste(t)}}),o("span",{id:"message-hint",class:"sr-only"},"Press Enter to send, Shift+Enter for new line")),this.botSettings.enableMic&&o("div",{class:"absolute bottom-0 "+(this.hideAllButtons?"w-full":"right-8")},o("audio-recorder",{"component-type":"bot",onStartRecord:()=>{this.hideAllButtons=!0},onStopRecord:()=>{this.hideAllButtons=!1},onSendTranscript:t=>{setTimeout((()=>{this.inputEl&&(this.inputEl.value=t.detail,this.adjustHeight(),this.showSubmit=!0)}),1e3)},style:{width:this.hideAllButtons?"100%":"10%"}})),o("div",{class:"absolute right-0 bottom-0 "+(this.hideAllButtons?"hidden":"")},!this.isStreaming&&o("button",{class:"text-white transition rounded-full p-1.5 self-center btn-bg-color bot-btn-primary","aria-label":"Send Message",tabindex:"0",id:"message-submit",onClick:t=>{var i,e;if(t.preventDefault(),""===(null===(i=this.inputEl)||void 0===i?void 0:i.value.trim())&&this.imagesBase64List&&0===this.imagesBase64List.length)return this.emptyMessageError=!0,this.announce("Message cannot be empty. Please enter a message."),this.inputEl&&this.inputEl.focus(),void setTimeout((()=>{this.emptyMessageError=!1}),3e3);this.isOpened=!0,this.handleSend(null===(e=this.inputEl)||void 0===e?void 0:e.value)}},o("i",{class:"block ai-icon text-body1",title:"Send Message"},o("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 16 16",fill:"currentColor",class:"size-6","aria-hidden":"true"},o("path",{"fill-rule":"evenodd",d:"M8 14a.75.75 0 0 1-.75-.75V4.56L4.03 7.78a.75.75 0 0 1-1.06-1.06l4.5-4.5a.75.75 0 0 1 1.06 0l4.5 4.5a.75.75 0 0 1-1.06 1.06L8.75 4.56v8.69A.75.75 0 0 1 8 14Z","clip-rule":"evenodd"})))),this.isStreaming&&o("button",{class:"text-white transition rounded-full p-1.5 self-center btn-bg-color bot-btn-primary","aria-label":"Stop Streaming",tabindex:"0",id:"message-submit",onClick:t=>{t.preventDefault(),this.isOpened=!0,this.stopResponse()}},o("i",{class:"block text-body1",title:"Stop Streaming"},o("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",class:"size-6","aria-hidden":"true"},o("path",{d:"M4.5 5.75C4.5 5.05964 5.05964 4.5 5.75 4.5H14.25C14.9404 4.5 15.5 5.05964 15.5 5.75V14.25C15.5 14.9404 14.9404 15.5 14.25 15.5H5.75C5.05964 15.5 4.5 14.9404 4.5 14.25V5.75Z"})))))),this.isExpanded&&!this.isOpened&&o("privacy-modal",{show:this.showPrivacy,message:this.botSettings.privacyTemplate}),0===this.messages.length&&o("div",{id:"input-enter-tip",role:"tooltip",class:"enter-tip"},"Tip: Press Enter to send, Shift+Enter for new line"),this.emptyMessageError&&o("div",{class:"error-message-container"},o("span",{id:"empty-message-error",class:"error-msg",role:"alert"},"Message cannot be empty. Please enter a message to send.")),this.showErrorMessage&&o("p",{class:"error-msg",innerHTML:this.errorMessage}),this.botSettings.buttons&&this.botSettings.buttons.length>0&&!this.isOpened&&o("div",{class:"bot-buttons-container flex flex-wrap gap-2 mt-2.5 mb-1"},this.botSettings.buttons.map(((t,i)=>o("button",{key:i,class:"px-4 py-2 ai12z-btn",onClick:i=>{i.preventDefault(),this.isOpened=!0,this.isContent=!1,this.handleSend(t.label)}},t.label))))))),o("div",{class:"pointer-events-auto fixed right-7 whitespace-nowrap transition-transform duration-300 ease-in-out fab",style:{opacity:this.isMinimized?"1":"0",transform:this.isMinimized?"translateX(0)":"translateX(-100%)",pointerEvents:this.isMinimized?"auto":"none",transformOrigin:"50% 50% 0px"},onClick:()=>{this.openChat()}},this.isBot&&o("slot",{name:"bot"}),!this.isBot&&o("button",{class:"rounded-full flex cursor-pointer items-center pr-[14px] md:gap-x-3 focus:outline focus:outline-2 focus:outline-offset-2 focus:outline-blue-focused bot-btn-primary",tabindex:"0","aria-label":"open Bot"},o("div",{class:"w-10 h-10 flex items-center justify-center bg-white rounded-full border relative"},this.botSettings.botLaunchIcon&&o("img",{src:this.botSettings.botLaunchIcon,alt:"bot icon",class:"w-8 h-8 rounded-lg"}),!this.botSettings.botLaunchIcon&&o("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"#2095ae","aria-hidden":"true"},o("g",{"stroke-width":"0"}),o("g",{"stroke-linecap":"round","stroke-linejoin":"round"}),o("g",null," ",o("path",{d:"M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z",stroke:"#2095ae","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})," "))),o("span",{class:"bot-name"}," ",null===(C=this.botSettings)||void 0===C?void 0:C.botName," ")))),o("keyboard-shortcuts-dialog",{show:this.showShortcutsDialog,shortcuts:this.shortcuts,onCloseDialog:()=>{this.showShortcutsDialog=!1}}),o("delete-confirmation-modal",{show:this.showLiveAgentEndDialog,dialogTitle:"End live agent chat?",message:"You are about to end the current live agent conversation. You can continue chatting with the bot after ending it.",confirmButtonText:"End",onConfirmDelete:()=>{this.confirmEndLiveAgent()},onCancelDelete:()=>{this.closeEndLiveAgentDialog()}})):o(n,null,o("span",{style:{display:"none"}},"Failed to load ai12z bot control due to insufficient fund"))}get el(){return a(this)}static get watchers(){return{dataKey:[{onDataKeyChange:0}],dataMode:[{onDataModeChange:0}]}}};et.style=':host{font-family:var(--ai12zBot-v2-font-family) !important;font-size:var(--ai12zBot-v2-font-size) !important;color:var(--ai12zBot-v2-font-color, black);text-align:var(--ai12zBot-v2-text-align, left)}.chat-body{height:100%;overflow-y:auto;display:flex;flex-direction:column;gap:10px;overflow-x:hidden}.chat-body::-webkit-scrollbar{width:5px;height:5px;}.chat-body::-webkit-scrollbar-thumb{background-color:#888;border-radius:10px;}.message{padding:10px;border-radius:15px;font-size:14px;line-height:1.4;word-wrap:break-word}span.prose{font-size:14px;}.image-Container{position:relative;display:inline-block;margin-right:10px}.delete-image{opacity:3;position:absolute;right:3px;top:0;cursor:pointer;line-height:10px}.ai12zBtn{background-color:var(--ai12zBot-v2-button-background) !important;color:var(--ai12zBot-v2-button-font-color);padding:5px 10px;border:none;border-radius:5px;cursor:pointer;text-decoration:none;margin:5px}.ai12z-btn{background-color:var(--ai12zBot-v2-button-background) !important;color:var(--ai12zBot-v2-button-font-color);padding:5px 10px;border:none;border-radius:5px;cursor:pointer;text-decoration:none;margin:5px}.custom-privacy{color:var(--ai12z-bot-privacy-color);padding-bottom:10px;padding-left:5px;margin-top:auto;}@media (max-width: 768px){.hide-chatbot{display:none !important}}:host{--wes-c-icon-color:#fff;--fab-bottom:26px;--xsf-ai12z-zindex-isexpanded-10:20020;--ai-toolbar-icon-color:#2095ae;--xsf-ai12z-zindex-0:19979;--xsf-ai12z-zindex-10:19989;--xsf-ai12z-fab-bottom:26px}.modal-overlay{position:absolute;height:100%;width:100%;z-index:var(--xsf-ai12z-zindex-0);background-color:#2e2e2e99}.layout{pointer-events:none;position:fixed;inset:0;height:100dvh;width:99dvw;justify-content:flex-end;grid-template-rows:auto 1fr auto;grid-template-areas:"left toolbar right" "left main right" "left footer right";padding-top:96px;transition-property:grid-template-columns, padding-top;z-index:19979}.layout.is-open .modal{pointer-events:auto}.layout.is-expanded ai12z-bot{pointer-events:auto}.layout.is-open.is-expanded .modal{border-top-left-radius:0.75rem;border-top-right-radius:0.75rem;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);z-index:var(--xsf-ai12z-zindex-isexpanded-10)}.layout.is-open .user-input-fieldset{background-image:none;padding:0px;background:none}.layout.is-expanded .user-input-fieldset{border-top-left-radius:0.75rem;border-top-right-radius:0.75rem}.layout.is-open .grow-wrap>.textarea,.layout.is-open .grow-wrap>button,.layout.is-open .grow-wrap:after{border-color:var(--ai12zBot-v2-searchbar-open-border-color);}.layout.is-expanded .grow-wrap:after{display:none}.layout.is-open.is-expanded .user-input{z-index:var(--xsf-ai12z-zindex-isexpanded-10)}.layout.is-open .user-input{z-index:var(--xsf-ai12z-zindex-10)}.text-body2{font-size:16px;line-height:1.5;letter-spacing:-0.12px;font-weight:400}.modal-toolbar-icon{color:var(--ai12zBot-v2-toolbar-icon-color, inherit);width:1rem;height:1rem}.search-flex{flex:1 1 0%}.show-grid{display:grid}.hide-title{padding:0px;opacity:0;height:0px}.user-msg{background-color:var(--ai12zBot-v2-user-bubble-background);color:var(--ai12zBot-v2-user-bubble-font-color)}.text-body4{font-size:var(--ai12zBot-v2-timestamp-font-size);line-height:1.5;letter-spacing:0.03px;font-weight:400;color:var(--ai12zBot-v2-timestamp-font-color)}.isContent{background:var(--ai12zBot-v2-content-background);padding:10px}.default-botAvatar{color:var(--ai12zBot-v2-default-avatar-color)}.searchform{opacity:1;transform:none}.user-input{margin-left:auto;margin-right:auto;width:100%;max-width:840px;min-width:340px;grid-area:footer}.main{margin-left:auto;margin-right:auto;width:100%;max-width:840px;min-width:340px;margin-top:7px}.heading{color:var(--ai12zBot-v2-title-color)}.dropdown-item-button{display:flex;width:100%;cursor:pointer;align-items:center;-moz-column-gap:8px;column-gap:8px;border-radius:0.25rem;--tw-border-opacity:1;--tw-bg-opacity:1;background-color:var(--ai12zBot-v2-dropdown-bgcolor);padding:8px 24px;font-weight:500;--tw-text-opacity:1;color:var(--ai12zBot-v2-dropdown-font-color);transition-property:color, background-color, border-color, text-decoration-color, fill, stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:75ms}.helptext{padding:0px;opacity:0;height:0px}.minimize-input{transform:translateY(calc(-100% - 4px))}.ai-text-caption{font-size:12px;line-height:1.5;letter-spacing:0.2px;font-weight:400}.fab>button{background:var(--ai12zBot-v2-fab-button-background);}.user-input-fieldset{background:var(--ai12zBot-v2-searchbar-background)}.return-text-color{color:rgb(255, 255, 255)}.ai-minimize-icon svg{fill:currentColor;height:1em;width:1em}.hide-form{opacity:0;transform:none}.show-form{opacity:1;transform:none}.ai-minimize-icon{color:var(--wes-c-icon-color, inherit)}.fab{bottom:var(--fab-bottom, 30px)}.text-body1{font-size:var(--ai12zBot-v2-title-font-size);line-height:1.5;letter-spacing:-0.12px;font-weight:400}#message-submit{margin-right:6px;margin-bottom:7px;background-color:var(--ai12zBot-v2-searchbar-submit-bgcolor)}.ai-icon{color:var(--ai12zBot-v2-searchbar-submit-color);font-size:24px;width:1.5rem;height:1.5rem}.plus-icon{color:var(--ai12zBot-v2-searchbar-plus-icon-color);font-size:24px;width:1.5rem;height:1.5rem}.grow-wrap>.textarea,.grow-wrap:after{min-height:48px;align-content:center;border-radius:1.5rem;border-width:1px;border-style:solid;border:1px solid var(--ai12zBot-v2-searchbar-border-color);--tw-bg-opacity:1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1));padding:8px 48px;text-indent:2px;font-size:16px;line-height:1.5;letter-spacing:-0.12px;font-weight:400;--tw-text-opacity:1;color:rgb(46 46 46 / var(--tw-text-opacity, 1));--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);--tw-ring-inset:inset;--tw-ring-offset-width:0px;transition-property:all;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:0.15s}.grow-wrap>.textarea,.grow-wrap:after{grid-area:1 / 1 / 2 / 2}.modal{position:relative;grid-column:span 1 / span 1;grid-column-start:2;grid-row:span 3 / span 3;grid-row-start:1;display:grid;border-top-left-radius:0;border-top-right-radius:0;background-position:center;box-shadow:0 16px 32px -4px #18181829, 0 12px 24px -4px #18181814;background-image:var(--ai12zBot-v2-modal-backgroundImage);background-repeat:no-repeat;background-size:100vw 100vh;grid-template-columns:subgrid;grid-template-rows:subgrid;z-index:var(--xsf-ai12z-zindex-10);transition:0.3sease-out;transition-property:grid-template-columns}.dropdown-menu{pointer-events:none;opacity:0;z-index:10;background-color:var(--ai12zBot-v2-dropdown-bgcolor);transform:translateY(-10px);transition:opacity 0.3s ease, transform 0.3s ease}.dropdown-menu.show{pointer-events:auto;opacity:1;pointer-events:auto;transform:translateY(0);background-color:var(--ai12zBot-v2-dropdown-bgcolor)}.copy-btn{color:var(--ai12zBot-v2-copy-btn-color)}.thumbs-up{fill:var(--ai12zBot-v2-feedback-selected);width:1.5rem}.thumbs-down{fill:var( --ai12zBot-v2-feedback-selected);width:1.5rem}.chat-thumbs-up{color:var(--ai12zBot-v2-feedback-color)}.thumbs-container{justify-content:flex-start;align-items:center}.back-btn svg{fill:var(--ai12zBot-v2-back-button-color)}.dropdown-item{background-color:var(--ai12zBot-v2-dropdown-bgcolor)}button:focus-visible{outline:2px solid var(--ai12zBot-v2-focus-visible-color, #0A2A43);outline-offset:2px}button.bot-btn-primary:focus-visible{outline:2px solid var(--ai12zBot-v2-focus-visible-color-primary, var(--ai12zBot-v2-focus-visible-color, #0A2A43));outline-offset:2px}button.bot-btn-secondary:focus-visible{outline:2px solid var(--ai12zBot-v2-focus-visible-color-secondary, var(--ai12zBot-v2-focus-visible-color, #0A2A43))}.bot-name{color:var(--ai12zBot-v2-fab-name-color, var(--ai12zBot-v2-bot-name-color));font-weight:var(--ai12zBot-v2-fab-font-weight, var(--ai12zBot-v2-bot-name-font-weight))}.ai12z-link{color:var(--ai12zBot-v2-link-color);text-decoration:underline}.ai12z-link:hover{color:var(--ai12zBot-v2-link-hover-color);text-decoration:underline}.toolbar{height:52px;border:#fff;grid-area:toolbar}.skip-link{position:absolute;left:-999px;top:auto;width:1px;height:1px;overflow:hidden}.skip-link:focus{left:10px;top:10px;width:auto;height:auto;z-index:1000}.enter-tip{font-size:12px;color:#666;margin-left:10px}.skip-links.hidden{position:absolute;left:-9999px;}.skip-links.visible{left:auto;position:static;}.error-message-container{margin-top:0.25rem}.error-msg{color:#dc2626;font-size:0.75rem;display:block;animation:slideIn 0.2s ease-out}.ai12z-form-honeypot{position:absolute;left:-10000px;top:auto;width:1px;height:1px;overflow:hidden}@keyframes slideIn{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@media (min-width: 1024px){.modal{background-size:80vw 100vh}}@media (min-width: 1024px){.layout.is-expanded{grid-template-columns:1fr minmax(340px, 80dvw) 1fr !important}}@media (min-width: 768px){.layout.is-expanded{-moz-column-gap:48px;column-gap:48px}}@media (max-width: 767px){.layout.is-open{padding-top:0px !important;grid-template-columns:0fr minmax(340px, 1fr) 0fr !important}}@media (max-width: 767px){.fab{right:30px;bottom:var(--xsf-ai12z-fab-bottom, 26px)}}';export{et as ai12z_bot}
|