@ujet/websdk-headless 3.37.2 → 3.37.4

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/index.js CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";var HI=Object.defineProperty;var VI=(e,t,r)=>t in e?HI(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ht=(e,t,r)=>VI(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function KI(e,t){for(var r=0;r<t.length;r++){const n=t[r];if(typeof n!="string"&&!Array.isArray(n)){for(const i in n)if(i!=="default"&&!(i in e)){const a=Object.getOwnPropertyDescriptor(n,i);a&&Object.defineProperty(e,i,a.get?a:{enumerable:!0,get:()=>n[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var to=(e=>(e.WAITING="waiting",e.READY="ready",e.IN_PROGRESS="in_progress",e.FINISHED="finished",e))(to||{});const JI="prod",Qv="3.37.2",ey="https://main.api.ujet.co",Br={companyId:"",tenant:"",trackerId:"",deviceId:"",application:"websdk",version:Qv};/*! @license DOMPurify 3.2.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.4/LICENSE */const{entries:mT,setPrototypeOf:ty,isFrozen:YI,getPrototypeOf:XI,getOwnPropertyDescriptor:QI}=Object;let{freeze:tn,seal:Fn,create:gT}=Object,{apply:hh,construct:vh}=typeof Reflect<"u"&&Reflect;tn||(tn=function(t){return t});Fn||(Fn=function(t){return t});hh||(hh=function(t,r,n){return t.apply(r,n)});vh||(vh=function(t,r){return new t(...r)});const nc=rn(Array.prototype.forEach),ZI=rn(Array.prototype.lastIndexOf),ry=rn(Array.prototype.pop),Ro=rn(Array.prototype.push),eO=rn(Array.prototype.splice),pl=rn(String.prototype.toLowerCase),nd=rn(String.prototype.toString),ny=rn(String.prototype.match),$o=rn(String.prototype.replace),tO=rn(String.prototype.indexOf),rO=rn(String.prototype.trim),Xn=rn(Object.prototype.hasOwnProperty),Xr=rn(RegExp.prototype.test),Io=nO(TypeError);function rn(e){return function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return hh(e,t,n)}}function nO(e){return function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return vh(e,r)}}function xt(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:pl;ty&&ty(e,null);let n=t.length;for(;n--;){let i=t[n];if(typeof i=="string"){const a=r(i);a!==i&&(YI(t)||(t[n]=a),i=a)}e[i]=!0}return e}function iO(e){for(let t=0;t<e.length;t++)Xn(e,t)||(e[t]=null);return e}function Qa(e){const t=gT(null);for(const[r,n]of mT(e))Xn(e,r)&&(Array.isArray(n)?t[r]=iO(n):n&&typeof n=="object"&&n.constructor===Object?t[r]=Qa(n):t[r]=n);return t}function Oo(e,t){for(;e!==null;){const n=QI(e,t);if(n){if(n.get)return rn(n.get);if(typeof n.value=="function")return rn(n.value)}e=XI(e)}function r(){return null}return r}const iy=tn(["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","section","select","shadow","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"]),id=tn(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),ad=tn(["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"]),aO=tn(["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"]),sd=tn(["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"]),sO=tn(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ay=tn(["#text"]),sy=tn(["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","face","for","headers","height","hidden","high","href","hreflang","id","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","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),od=tn(["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","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"]),oy=tn(["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"]),ic=tn(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),oO=Fn(/\{\{[\w\W]*|[\w\W]*\}\}/gm),uO=Fn(/<%[\w\W]*|[\w\W]*%>/gm),cO=Fn(/\$\{[\w\W]*/gm),lO=Fn(/^data-[\-\w.\u00B7-\uFFFF]+$/),fO=Fn(/^aria-[\-\w]+$/),yT=Fn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),dO=Fn(/^(?:\w+script|data):/i),pO=Fn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),bT=Fn(/^html$/i),hO=Fn(/^[a-z][.\w]*(-[.\w]+)+$/i);var uy=Object.freeze({__proto__:null,ARIA_ATTR:fO,ATTR_WHITESPACE:pO,CUSTOM_ELEMENT:hO,DATA_ATTR:lO,DOCTYPE_NAME:bT,ERB_EXPR:uO,IS_ALLOWED_URI:yT,IS_SCRIPT_OR_DATA:dO,MUSTACHE_EXPR:oO,TMPLIT_EXPR:cO});const Ao={element:1,text:3,progressingInstruction:7,comment:8,document:9},vO=function(){return typeof window>"u"?null:window},mO=function(t,r){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let n=null;const i="data-tt-policy-suffix";r&&r.hasAttribute(i)&&(n=r.getAttribute(i));const a="dompurify"+(n?"#"+n:"");try{return t.createPolicy(a,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},cy=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function _T(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:vO();const t=it=>_T(it);if(t.version="3.2.4",t.removed=[],!e||!e.document||e.document.nodeType!==Ao.document||!e.Element)return t.isSupported=!1,t;let{document:r}=e;const n=r,i=n.currentScript,{DocumentFragment:a,HTMLTemplateElement:s,Node:o,Element:u,NodeFilter:c,NamedNodeMap:l=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:v,trustedTypes:m}=e,b=u.prototype,T=Oo(b,"cloneNode"),I=Oo(b,"remove"),R=Oo(b,"nextSibling"),x=Oo(b,"childNodes"),N=Oo(b,"parentNode");if(typeof s=="function"){const it=r.createElement("template");it.content&&it.content.ownerDocument&&(r=it.content.ownerDocument)}let j,X="";const{implementation:J,createNodeIterator:V,createDocumentFragment:D,getElementsByTagName:te}=r,{importNode:ue}=n;let ee=cy();t.isSupported=typeof mT=="function"&&typeof N=="function"&&J&&J.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ge,ERB_EXPR:L,TMPLIT_EXPR:pe,DATA_ATTR:Te,ARIA_ATTR:rt,IS_SCRIPT_OR_DATA:Ke,ATTR_WHITESPACE:Se,CUSTOM_ELEMENT:ce}=uy;let{IS_ALLOWED_URI:he}=uy,P=null;const Ie=xt({},[...iy,...id,...ad,...sd,...ay]);let qe=null;const Ne=xt({},[...sy,...od,...oy,...ic]);let _e=Object.seal(gT(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}})),Q=null,kt=null,Ce=!0,de=!0,Rt=!1,Ue=!0,Dt=!1,mt=!0,ke=!1,ft=!1,St=!1,Oe=!1,Bt=!1,vt=!1,qt=!0,sr=!1;const ze="user-content-";let Tr=!0,mr=!1,Et={},It=null;const bt=xt({},["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 ct=null;const Ft=xt({},["audio","video","img","source","image","track"]);let Pt=null;const cr=xt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Cr="http://www.w3.org/1998/Math/MathML",Dr="http://www.w3.org/2000/svg",gr="http://www.w3.org/1999/xhtml";let zt=gr,lr=!1,ye=null;const we=xt({},[Cr,Dr,gr],nd);let se=xt({},["mi","mo","mn","ms","mtext"]),me=xt({},["annotation-xml"]);const le=xt({},["title","style","font","a","script"]);let be=null;const $e=["application/xhtml+xml","text/html"],re="text/html";let ae=null,K=null;const oe=r.createElement("form"),Y=function(Z){return Z instanceof RegExp||Z instanceof Function},De=function(){let Z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(K&&K===Z)){if((!Z||typeof Z!="object")&&(Z={}),Z=Qa(Z),be=$e.indexOf(Z.PARSER_MEDIA_TYPE)===-1?re:Z.PARSER_MEDIA_TYPE,ae=be==="application/xhtml+xml"?nd:pl,P=Xn(Z,"ALLOWED_TAGS")?xt({},Z.ALLOWED_TAGS,ae):Ie,qe=Xn(Z,"ALLOWED_ATTR")?xt({},Z.ALLOWED_ATTR,ae):Ne,ye=Xn(Z,"ALLOWED_NAMESPACES")?xt({},Z.ALLOWED_NAMESPACES,nd):we,Pt=Xn(Z,"ADD_URI_SAFE_ATTR")?xt(Qa(cr),Z.ADD_URI_SAFE_ATTR,ae):cr,ct=Xn(Z,"ADD_DATA_URI_TAGS")?xt(Qa(Ft),Z.ADD_DATA_URI_TAGS,ae):Ft,It=Xn(Z,"FORBID_CONTENTS")?xt({},Z.FORBID_CONTENTS,ae):bt,Q=Xn(Z,"FORBID_TAGS")?xt({},Z.FORBID_TAGS,ae):{},kt=Xn(Z,"FORBID_ATTR")?xt({},Z.FORBID_ATTR,ae):{},Et=Xn(Z,"USE_PROFILES")?Z.USE_PROFILES:!1,Ce=Z.ALLOW_ARIA_ATTR!==!1,de=Z.ALLOW_DATA_ATTR!==!1,Rt=Z.ALLOW_UNKNOWN_PROTOCOLS||!1,Ue=Z.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Dt=Z.SAFE_FOR_TEMPLATES||!1,mt=Z.SAFE_FOR_XML!==!1,ke=Z.WHOLE_DOCUMENT||!1,Oe=Z.RETURN_DOM||!1,Bt=Z.RETURN_DOM_FRAGMENT||!1,vt=Z.RETURN_TRUSTED_TYPE||!1,St=Z.FORCE_BODY||!1,qt=Z.SANITIZE_DOM!==!1,sr=Z.SANITIZE_NAMED_PROPS||!1,Tr=Z.KEEP_CONTENT!==!1,mr=Z.IN_PLACE||!1,he=Z.ALLOWED_URI_REGEXP||yT,zt=Z.NAMESPACE||gr,se=Z.MATHML_TEXT_INTEGRATION_POINTS||se,me=Z.HTML_INTEGRATION_POINTS||me,_e=Z.CUSTOM_ELEMENT_HANDLING||{},Z.CUSTOM_ELEMENT_HANDLING&&Y(Z.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(_e.tagNameCheck=Z.CUSTOM_ELEMENT_HANDLING.tagNameCheck),Z.CUSTOM_ELEMENT_HANDLING&&Y(Z.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(_e.attributeNameCheck=Z.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),Z.CUSTOM_ELEMENT_HANDLING&&typeof Z.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(_e.allowCustomizedBuiltInElements=Z.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Dt&&(de=!1),Bt&&(Oe=!0),Et&&(P=xt({},ay),qe=[],Et.html===!0&&(xt(P,iy),xt(qe,sy)),Et.svg===!0&&(xt(P,id),xt(qe,od),xt(qe,ic)),Et.svgFilters===!0&&(xt(P,ad),xt(qe,od),xt(qe,ic)),Et.mathMl===!0&&(xt(P,sd),xt(qe,oy),xt(qe,ic))),Z.ADD_TAGS&&(P===Ie&&(P=Qa(P)),xt(P,Z.ADD_TAGS,ae)),Z.ADD_ATTR&&(qe===Ne&&(qe=Qa(qe)),xt(qe,Z.ADD_ATTR,ae)),Z.ADD_URI_SAFE_ATTR&&xt(Pt,Z.ADD_URI_SAFE_ATTR,ae),Z.FORBID_CONTENTS&&(It===bt&&(It=Qa(It)),xt(It,Z.FORBID_CONTENTS,ae)),Tr&&(P["#text"]=!0),ke&&xt(P,["html","head","body"]),P.table&&(xt(P,["tbody"]),delete Q.tbody),Z.TRUSTED_TYPES_POLICY){if(typeof Z.TRUSTED_TYPES_POLICY.createHTML!="function")throw Io('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof Z.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Io('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');j=Z.TRUSTED_TYPES_POLICY,X=j.createHTML("")}else j===void 0&&(j=mO(m,i)),j!==null&&typeof X=="string"&&(X=j.createHTML(""));tn&&tn(Z),K=Z}},Re=xt({},[...id,...ad,...aO]),Je=xt({},[...sd,...sO]),Ge=function(Z){let xe=N(Z);(!xe||!xe.tagName)&&(xe={namespaceURI:zt,tagName:"template"});const Ye=pl(Z.tagName),Mt=pl(xe.tagName);return ye[Z.namespaceURI]?Z.namespaceURI===Dr?xe.namespaceURI===gr?Ye==="svg":xe.namespaceURI===Cr?Ye==="svg"&&(Mt==="annotation-xml"||se[Mt]):!!Re[Ye]:Z.namespaceURI===Cr?xe.namespaceURI===gr?Ye==="math":xe.namespaceURI===Dr?Ye==="math"&&me[Mt]:!!Je[Ye]:Z.namespaceURI===gr?xe.namespaceURI===Dr&&!me[Mt]||xe.namespaceURI===Cr&&!se[Mt]?!1:!Je[Ye]&&(le[Ye]||!Re[Ye]):!!(be==="application/xhtml+xml"&&ye[Z.namespaceURI]):!1},He=function(Z){Ro(t.removed,{element:Z});try{N(Z).removeChild(Z)}catch{I(Z)}},et=function(Z,xe){try{Ro(t.removed,{attribute:xe.getAttributeNode(Z),from:xe})}catch{Ro(t.removed,{attribute:null,from:xe})}if(xe.removeAttribute(Z),Z==="is")if(Oe||Bt)try{He(xe)}catch{}else try{xe.setAttribute(Z,"")}catch{}},nt=function(Z){let xe=null,Ye=null;if(St)Z="<remove></remove>"+Z;else{const Ot=ny(Z,/^[\r\n\t ]+/);Ye=Ot&&Ot[0]}be==="application/xhtml+xml"&&zt===gr&&(Z='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+Z+"</body></html>");const Mt=j?j.createHTML(Z):Z;if(zt===gr)try{xe=new v().parseFromString(Mt,be)}catch{}if(!xe||!xe.documentElement){xe=J.createDocument(zt,"template",null);try{xe.documentElement.innerHTML=lr?X:Mt}catch{}}const nr=xe.body||xe.documentElement;return Z&&Ye&&nr.insertBefore(r.createTextNode(Ye),nr.childNodes[0]||null),zt===gr?te.call(xe,ke?"html":"body")[0]:ke?xe.documentElement:nr},Qe=function(Z){return V.call(Z.ownerDocument||Z,Z,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},tt=function(Z){return Z instanceof p&&(typeof Z.nodeName!="string"||typeof Z.textContent!="string"||typeof Z.removeChild!="function"||!(Z.attributes instanceof l)||typeof Z.removeAttribute!="function"||typeof Z.setAttribute!="function"||typeof Z.namespaceURI!="string"||typeof Z.insertBefore!="function"||typeof Z.hasChildNodes!="function")},at=function(Z){return typeof o=="function"&&Z instanceof o};function st(it,Z,xe){nc(it,Ye=>{Ye.call(t,Z,xe,K)})}const yr=function(Z){let xe=null;if(st(ee.beforeSanitizeElements,Z,null),tt(Z))return He(Z),!0;const Ye=ae(Z.nodeName);if(st(ee.uponSanitizeElement,Z,{tagName:Ye,allowedTags:P}),Z.hasChildNodes()&&!at(Z.firstElementChild)&&Xr(/<[/\w]/g,Z.innerHTML)&&Xr(/<[/\w]/g,Z.textContent)||Z.nodeType===Ao.progressingInstruction||mt&&Z.nodeType===Ao.comment&&Xr(/<[/\w]/g,Z.data))return He(Z),!0;if(!P[Ye]||Q[Ye]){if(!Q[Ye]&&dt(Ye)&&(_e.tagNameCheck instanceof RegExp&&Xr(_e.tagNameCheck,Ye)||_e.tagNameCheck instanceof Function&&_e.tagNameCheck(Ye)))return!1;if(Tr&&!It[Ye]){const Mt=N(Z)||Z.parentNode,nr=x(Z)||Z.childNodes;if(nr&&Mt){const Ot=nr.length;for(let ir=Ot-1;ir>=0;--ir){const Pr=T(nr[ir],!0);Pr.__removalCount=(Z.__removalCount||0)+1,Mt.insertBefore(Pr,R(Z))}}}return He(Z),!0}return Z instanceof u&&!Ge(Z)||(Ye==="noscript"||Ye==="noembed"||Ye==="noframes")&&Xr(/<\/no(script|embed|frames)/i,Z.innerHTML)?(He(Z),!0):(Dt&&Z.nodeType===Ao.text&&(xe=Z.textContent,nc([ge,L,pe],Mt=>{xe=$o(xe,Mt," ")}),Z.textContent!==xe&&(Ro(t.removed,{element:Z.cloneNode()}),Z.textContent=xe)),st(ee.afterSanitizeElements,Z,null),!1)},fr=function(Z,xe,Ye){if(qt&&(xe==="id"||xe==="name")&&(Ye in r||Ye in oe))return!1;if(!(de&&!kt[xe]&&Xr(Te,xe))){if(!(Ce&&Xr(rt,xe))){if(!qe[xe]||kt[xe]){if(!(dt(Z)&&(_e.tagNameCheck instanceof RegExp&&Xr(_e.tagNameCheck,Z)||_e.tagNameCheck instanceof Function&&_e.tagNameCheck(Z))&&(_e.attributeNameCheck instanceof RegExp&&Xr(_e.attributeNameCheck,xe)||_e.attributeNameCheck instanceof Function&&_e.attributeNameCheck(xe))||xe==="is"&&_e.allowCustomizedBuiltInElements&&(_e.tagNameCheck instanceof RegExp&&Xr(_e.tagNameCheck,Ye)||_e.tagNameCheck instanceof Function&&_e.tagNameCheck(Ye))))return!1}else if(!Pt[xe]){if(!Xr(he,$o(Ye,Se,""))){if(!((xe==="src"||xe==="xlink:href"||xe==="href")&&Z!=="script"&&tO(Ye,"data:")===0&&ct[Z])){if(!(Rt&&!Xr(Ke,$o(Ye,Se,"")))){if(Ye)return!1}}}}}}return!0},dt=function(Z){return Z!=="annotation-xml"&&ny(Z,ce)},Wr=function(Z){st(ee.beforeSanitizeAttributes,Z,null);const{attributes:xe}=Z;if(!xe||tt(Z))return;const Ye={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:qe,forceKeepAttr:void 0};let Mt=xe.length;for(;Mt--;){const nr=xe[Mt],{name:Ot,namespaceURI:ir,value:Pr}=nr,Mr=ae(Ot);let dr=Ot==="value"?Pr:rO(Pr);if(Ye.attrName=Mr,Ye.attrValue=dr,Ye.keepAttr=!0,Ye.forceKeepAttr=void 0,st(ee.uponSanitizeAttribute,Z,Ye),dr=Ye.attrValue,sr&&(Mr==="id"||Mr==="name")&&(et(Ot,Z),dr=ze+dr),mt&&Xr(/((--!?|])>)|<\/(style|title)/i,dr)){et(Ot,Z);continue}if(Ye.forceKeepAttr||(et(Ot,Z),!Ye.keepAttr))continue;if(!Ue&&Xr(/\/>/i,dr)){et(Ot,Z);continue}Dt&&nc([ge,L,pe],Gr=>{dr=$o(dr,Gr," ")});const $n=ae(Z.nodeName);if(fr($n,Mr,dr)){if(j&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!ir)switch(m.getAttributeType($n,Mr)){case"TrustedHTML":{dr=j.createHTML(dr);break}case"TrustedScriptURL":{dr=j.createScriptURL(dr);break}}try{ir?Z.setAttributeNS(ir,Ot,dr):Z.setAttribute(Ot,dr),tt(Z)?He(Z):ry(t.removed)}catch{}}}st(ee.afterSanitizeAttributes,Z,null)},cn=function it(Z){let xe=null;const Ye=Qe(Z);for(st(ee.beforeSanitizeShadowDOM,Z,null);xe=Ye.nextNode();)st(ee.uponSanitizeShadowNode,xe,null),yr(xe),Wr(xe),xe.content instanceof a&&it(xe.content);st(ee.afterSanitizeShadowDOM,Z,null)};return t.sanitize=function(it){let Z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},xe=null,Ye=null,Mt=null,nr=null;if(lr=!it,lr&&(it="<!-->"),typeof it!="string"&&!at(it))if(typeof it.toString=="function"){if(it=it.toString(),typeof it!="string")throw Io("dirty is not a string, aborting")}else throw Io("toString is not a function");if(!t.isSupported)return it;if(ft||De(Z),t.removed=[],typeof it=="string"&&(mr=!1),mr){if(it.nodeName){const Pr=ae(it.nodeName);if(!P[Pr]||Q[Pr])throw Io("root node is forbidden and cannot be sanitized in-place")}}else if(it instanceof o)xe=nt("<!---->"),Ye=xe.ownerDocument.importNode(it,!0),Ye.nodeType===Ao.element&&Ye.nodeName==="BODY"||Ye.nodeName==="HTML"?xe=Ye:xe.appendChild(Ye);else{if(!Oe&&!Dt&&!ke&&it.indexOf("<")===-1)return j&&vt?j.createHTML(it):it;if(xe=nt(it),!xe)return Oe?null:vt?X:""}xe&&St&&He(xe.firstChild);const Ot=Qe(mr?it:xe);for(;Mt=Ot.nextNode();)yr(Mt),Wr(Mt),Mt.content instanceof a&&cn(Mt.content);if(mr)return it;if(Oe){if(Bt)for(nr=D.call(xe.ownerDocument);xe.firstChild;)nr.appendChild(xe.firstChild);else nr=xe;return(qe.shadowroot||qe.shadowrootmode)&&(nr=ue.call(n,nr,!0)),nr}let ir=ke?xe.outerHTML:xe.innerHTML;return ke&&P["!doctype"]&&xe.ownerDocument&&xe.ownerDocument.doctype&&xe.ownerDocument.doctype.name&&Xr(bT,xe.ownerDocument.doctype.name)&&(ir="<!DOCTYPE "+xe.ownerDocument.doctype.name+`>
2
- `+ir),Dt&&nc([ge,L,pe],Pr=>{ir=$o(ir,Pr," ")}),j&&vt?j.createHTML(ir):ir},t.setConfig=function(){let it=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};De(it),ft=!0},t.clearConfig=function(){K=null,ft=!1},t.isValidAttribute=function(it,Z,xe){K||De({});const Ye=ae(it),Mt=ae(Z);return fr(Ye,Mt,xe)},t.addHook=function(it,Z){typeof Z=="function"&&Ro(ee[it],Z)},t.removeHook=function(it,Z){if(Z!==void 0){const xe=ZI(ee[it],Z);return xe===-1?void 0:eO(ee[it],xe,1)[0]}return ry(ee[it])},t.removeHooks=function(it){ee[it]=[]},t.removeAllHooks=function(){ee=cy()},t}var gO=_T();const yO={ALLOWED_TAGS:["b","i","em","strong","p","br","ul","ol","li","a"],ALLOWED_ATTR:["href","src","alt","title","target","class","id","style"],ALLOW_DATA_ATTR:!1,FORBID_TAGS:["img","iframe","object","input","style","script","embed","svg","video","audio","body","input","form","link"],FORBID_ATTR:["onerror","onclick","onload","onmouseover","onfocus","onblur","onchange","onsubmit","scr","href","style","action","value"],IN_PLACE:!0},bO="javascript:";function _O(e){return(e==null?void 0:e.constructor)===Object}async function ly(e,t=3){let r=0,n;for(;r<=t;){r+=1;try{return await e()}catch(i){n=i,console.error(i),await wT(1e3*Math.pow(2,r))}}throw n}function wT(e){return new Promise(t=>{setTimeout(()=>{t(0)},e)})}function wO(){return Math.random().toString(36).slice(2)}const SO=new TextDecoder,TO=e=>{const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return SO.decode(r)},CO=e=>e.length===0,EO=(...e)=>e.every(CO),ST=e=>{const t=gO.sanitize(e,yO);return t.includes(bO)?(console.warn("Suspicious content detected and removed."),""):t},fy=[];class $a{constructor(t){ht(this,"channel");this.channel=t}static addHandler(t){fy.push(t)}debug(...t){this._log("debug",...t)}info(...t){this._log("info",...t)}warn(...t){this._log("warn",...t)}error(...t){this._log("error",...t)}_log(t,...r){fy.forEach(n=>{n(this.channel,t,...r)})}}const kO=(e,t,...r)=>{console[t](`[${t}][${e}]`,...r)},RO=e=>{let t=[],r;return(i,a,...s)=>{a==="debug"||i==="communicator"||(t.push($O(i,a,...s)),clearTimeout(r),r=window.setTimeout(()=>{if(t.length){const o={num_of_logs:t.length,logs:t};e(o)}t=[]},2e3))}};function $O(e,t,...r){let n=r.pop();typeof n=="string"&&(r.push(n),n={});const i=r.join(" "),a={loglevel:t,channel:e,timestamp:new Date().toISOString(),application:Br.application,version:Br.version,device:Br.deviceId,tenant:Br.tenant,company_id:Br.companyId,location_url:location.href,data:AO(n),message:Zv(i)};return Br.trackerId&&(a.tracker_id=Br.trackerId),a}const IO=["user","phone","phone_number","phoneNumber","email"],OO=[/(?:3[47]\d|(?:4\d|5[1-5]|65)\d{2}|6011)\d{12}/g,/(?!(000|666|9))\d{3}-(?!00)\d{2}-(?!0000)\d{4}/g,/^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)+$/g];function Zv(e){return typeof e=="string"?OO.forEach(t=>{e=e.replace(t,"__MASKED__")}):e&&_O(e)&&(e={...e},Object.keys(e).forEach(t=>{IO.indexOf(t)!==-1?e[t]="__MASKED__":Zv(e[t])})),e}function AO(e){if(e.error){const t=e.error;return{error:{name:t.name,message:t.message,stack:t.stack}}}return Zv(e.data)}const ud=new $a("communicator");let dy=!1;class PO{constructor(t,r){ht(this,"events");ht(this,"options");ht(this,"channel");ht(this,"authenticate");ht(this,"channelReady",!1);ht(this,"__authed",!1);ht(this,"pending",[]);ht(this,"promises",{});ht(this,"user");ht(this,"iframe");this.authenticate=t.authenticate,this.events=r,this.options=MO(t),this.channel=new MessageChannel,this.useConnect(this.options)}useConnect(t){const r=document.createElement("iframe");r.src=t.bridge,r.setAttribute("style","display:none");let n="*";/^https:/.test(t.bridge)&&(n=new URL(t.bridge).origin),r.addEventListener("load",()=>{if(ud.debug("iframe bridge ready for",n),!this.channelReady){const i={type:"_init",data:t};r.contentWindow.postMessage(i,n,[this.channel.port2])}}),this.channel.port1.onmessage=i=>{this.receiveMessage(i)},document.body.appendChild(r),this.iframe=r}receiveMessage(t){const r=t.data;if(r){if(ud.debug("receiveMessage",r),r.type==="ready")this.channelReady=!0,Br.deviceId=r.result.deviceId,Br.deviceId||console.error("Device Id has not been provided. SDK will not work properly."),this.runPending(),this.events.triggerEvent("ready");else if(r.type==="callback"&&r.callbackId){const[n,i]=this.promises[r.callbackId];r.error?i(r.error):n(r.result),delete this.promises[r.callbackId]}else if(r.type==="refreshToken")this.refreshToken();else if(r.request==="_auth"&&(this.events.triggerEvent("authenticated"),r.result&&r.result.log_proxy_url&&!dy)){dy=!0;const n=RO(i=>{this.postMessage({type:"_log",data:i})});$a.addHandler(n)}}}postMessage(t){this.channel&&this.channelReady?(ud.debug("postMessage",t),this.channel.port1.postMessage(t)):this.pending.push(t)}runPending(){for(;this.pending.length;){const t=this.pending.shift();this.postMessage(t)}}postPromise(t,r){return new Promise((n,i)=>{const a=wO()+"_"+Date.now();this.promises[a]=[n,i];const s={type:t,callbackId:a,data:r};this.postMessage(s)})}async refreshToken(){this.__authed=!0;const t=await this.authenticate(),r=["twilio_chat","nexmo_chat"];this.options.cobrowse&&r.push("cobrowse");const i={type:"_auth",data:{modules:r,user:{token:t.token,company_id:this.options.companyId}}};this.postMessage(i);const a=JSON.parse(TO(t.token.split(".")[1]));if(this.user={identifier:a.identifier,name:a.name,email:a.email},this.events.triggerEvent("authenticate"),a.exp){let s;a.exp.toString().length===13?s=a.exp:a.exp.toString().length===10&&(s=a.exp*1e3),s&&setTimeout(()=>{this.refreshToken()},s-Date.now()-12e4)}}request(t,r){!this.__authed&&t!=="proactive_chat_triggers"&&this.refreshToken();const n={url:t,options:r};return this.postPromise("request",n)}destroy(){delete this.channel,this.iframe&&(document.body.removeChild(this.iframe),this.iframe=void 0)}}function MO(e){var a;let t=e.host;t||(e.tenant?t=ey.replace("main.api",e.tenant+".api"):t=ey);const r=e.lang||"en",n=!!((a=e.cobrowse)!=null&&a.enabled),i=e.bridge||"https://websdk.ujet.co/v3/bridge.html";return{host:t,lang:r,cobrowse:n,companyId:e.companyId,location:location.href,version:e.version||"3.37.2",bridge:i}}class em{constructor(){ht(this,"handlers",{})}addEventListener(t,r){this.handlers[t]||(this.handlers[t]=[]),this.handlers[t].push(r)}triggerEvent(t,r){const n=this.handlers[t];n&&n.forEach(i=>{i(r)})}removeEventListener(t,r){if(this.handlers[t]){const n=this.handlers[t].indexOf(r);n!==-1&&this.handlers[t].splice(n,1)}}destroy(){this.handlers={}}}function xO(e,t){const r={};return t.forEach(n=>{r[n.id]=n}),e.map(n=>{if(n.type==="server_message"){const i=n.message_id,a=r[i];TT(n,a.content)}return n})}function NO(e,t){return TT(e,t.content)}function TT(e,t){return Object.keys(t).forEach(r=>{e[r]=t[r]}),e}const py={photo:2,video:2,audio:1,document:1};function LO(e){const t=e.toSorted((r,n)=>!r.groupMessageId||!n.groupMessageId||r.groupMessageId!==n.groupMessageId?0:(py[n.type]||0)-(py[r.type]||0));return t.forEach((r,n,i)=>{const a=!r.groupMessageId,s=i[n+1];s&&(a&&s.$userId===r.$userId&&r.$time||!a&&s.groupMessageId===r.groupMessageId&&r.$time)&&(s.$time=r.$time,r.$time=null)}),t}const hy=new $a("MediaStore"),DO=window.indexedDB||window.webkitIndexedDB||window.mozIndexedDB||window.OIndexedDB||window.msIndexedDB,jO="chat-media",vy=1,Ol="file";class CT{constructor(){ht(this,"db")}store(){return new Promise((t,r)=>{if(this.db)return t(my(this.db));const n=DO.open(jO,vy);n.onerror=()=>{r(new Error("indexedDB open failed"))},n.onsuccess=()=>{const i=n.result;this.db=i,t(my(i))},n.onupgradeneeded=i=>{const a=n.result;i.oldVersion>0&&i.oldVersion<vy&&(hy.info("deprecating media store"),a.deleteObjectStore(Ol)),hy.info("creating media store"),a.createObjectStore(Ol)}})}async save(t,r){(await this.store()).put({index:t,file:r},t)}async getAll(){const t=await this.store();return await new Promise((r,n)=>{const i=t.getAll();i.onerror=()=>{n(new Error("indexedDB getAll failed"))},i.onsuccess=()=>{r(i.result)}})}async getAllFiles(){const t={};return(await this.getAll()).forEach(n=>{t[n.index]=n.file}),t}async clear(){(await this.store()).clear()}}function my(e){return e.transaction(Ol,"readwrite").objectStore(Ol)}class FO{constructor(){ht(this,"_hostPath","")}setPath(t){this._hostPath=t}getPath(){return this._hostPath}}const ET=new FO,UO=new $a("chat-provider");class tm{constructor(t,r,n){ht(this,"audio");ht(this,"issueChatToken");ht(this,"identity");ht(this,"channelId");ht(this,"region");ht(this,"inTask",!1);ht(this,"muted",!1);ht(this,"events");this.events=t,this.region=r.region,this.issueChatToken=n}ping(){if(!this.muted){if(!this.audio){ET.getPath();const t="https://websdk.ujet.co/v3/ping.mp3";this.audio=new window.Audio(t)}try{this.audio.play()}catch(t){UO.warn("Chat audio play failed",{error:t})}}}on(t,r){this.events.addEventListener(t,r)}off(t,r){this.events.removeEventListener(t,r)}trackInTask(t){t.type==="noti"&&t.event==="taskVaStarted"?this.inTask=!0:t.type==="noti"&&t.event==="taskVaFinished"&&(this.inTask=!1)}}ht(tm,"type","base");const kT={};function rm(e){kT[e.type]=e}function BO(e){return kT[e]}const RT=["assigned","va_assigned"],$T=["dismissed","va_dismissed"],qO=["va_assigned","va_dismissed"],zO=["queued",...RT,...$T],WO=["timeout","canceled","failed","finished"],cd=new $a("Chat");class GO{constructor(t,r){ht(this,"provider");ht(this,"store");ht(this,"globalEvents");ht(this,"state");ht(this,"connected",!1);ht(this,"allowSkipVirtualAgent",!1);ht(this,"inEscalation",!1);ht(this,"events");ht(this,"cachedFiles");this.state=t,this.store=new CT,this.cachedFiles={},this.events=new em;const n=BO(this.state.provider_type);this.provider=new n(this.events,t,r)}_setGlobalEvents(t,r){this.globalEvents=t,this.on("message",n=>{if(n.content=ST(n.content),n.type==="server_message"){const i=n.message_id;r(this.id,i).then(a=>{n=NO(n,a),t.triggerEvent("chat.message",n)})}else n.type==="photo"||n.type==="video"?setTimeout(()=>{const i=n.$index.toString();n.file=this.cachedFiles[i],t.triggerEvent("chat.message",n)},100):(t.triggerEvent("chat.message",n),this.registerMessageEvents(n))}),this.on("memberJoined",n=>{t.triggerEvent("chat.memberJoined",n)}),this.on("memberLeft",n=>{t.triggerEvent("chat.memberLeft",n)}),this.on("typingStarted",n=>{t.triggerEvent("chat.typingStarted",n)}),this.on("typingEnded",n=>{t.triggerEvent("chat.typingEnded",n)})}get id(){var t;return((t=this.state)==null?void 0:t.id)||-1}get menuId(){return this.state?this.state.menus[this.state.menus.length-1].id:-1}get channelId(){var t;return((t=this.state)==null?void 0:t.provider_channel_id)||""}get lang(){var t;return((t=this.state)==null?void 0:t.lang)||""}get virtual(){return qO.indexOf(this.status)!==-1}get muted(){var t;return((t=this.provider)==null?void 0:t.muted)||!1}set muted(t){this.provider&&(this.provider.muted=t)}get agent(){return this.state?this.virtual?this.state.external_agent||this.state.virtual_agent:this.state.agent||this.state.virtual_agent:null}get allAgents(){var t,r;return{virtual:((t=this.state)==null?void 0:t.all_virtual_agents)||[],human:((r=this.state)==null?void 0:r.all_agents)||[]}}get userIdentity(){var t;return((t=this.provider)==null?void 0:t.identity)||""}get status(){var t;return((t=this.state)==null?void 0:t.status)||""}get postSessionStatus(){var t;return((t=this.state)==null?void 0:t.post_session_transfer_status)||""}get statusText(){var t;return((t=this.state)==null?void 0:t.status_text)||""}get cobrowsable(){return this.state?this.state.features.indexOf("cobrowse")!==-1:!1}get ongoing(){return zO.indexOf(this.status)!=-1}get assigned(){return RT.indexOf(this.status)!=-1}get dismissed(){return $T.indexOf(this.status)!=-1}get ended(){return WO.indexOf(this.status)!=-1}get transcriptCount(){var t;return((t=this.state)==null?void 0:t.transcript_requested_count)||0}get createdAt(){var t;return((t=this.state)==null?void 0:t.created_at)||""}get inTask(){var t;return((t=this.provider)==null?void 0:t.inTask)||!1}get feedbackType(){var t;return this.state?this.state.survey_enabled?"survey":(t=this.state.csat_settings)!=null&&t.enabled?"rate":"none":"none"}get optInRequired(){var t;return((t=this.state)==null?void 0:t.post_session_opt_in_required)||!1}get postSessionRequired(){var t;return((t=this.state)==null?void 0:t.post_session_required)||!1}get postSessionInProgress(){return this.state?this.state.post_session_transfer_status===to.IN_PROGRESS:!1}update(t){if(!this.state||this.state.id!==t.id)return;const r=t.menus[t.menus.length-1].id,n=this.state.menus[this.state.menus.length-1].id;this.state=t,r!==n&&this.triggerEvent("_menuChanged",this),t.status==="canceled"?this.triggerEvent("ended",this):this.triggerEvent("updated",this)}on(t,r){this.events.addEventListener(t,r)}off(t,r){this.events.removeEventListener(t,r)}async connect(){if(!this.provider)return cd.info("connecting interrupted"),!1;try{await ly(()=>this.provider.create(),3),await ly(()=>this.provider.join(this.state.provider_channel_id),3),this.connected=!0;const t=await this.fetchMessages(),r={chat:this,messages:t};return this.triggerEvent("connectedMessages",r),this.triggerEvent("connected",this),this.registerProviderEvents(),cd.info("connected with provider",this.state.provider_type),!0}catch{return!1}}async disconnect(){this.connected=!1,this.triggerEvent("disconnected",this),this.events.destroy(),this.provider&&(await this.provider.destroy(),cd.info("disconnect with provider",this.state.provider_type))}async sendMessage(t,r){const n=await this.provider.sendMessage(t);return r&&this.saveMedia(n,r),n}preview(t){if(!this.inTask)return this.provider.preview(t)}async fetchMessages(){if(this.connected){const t=await this.store.getAllFiles();return this.provider.fetchMessages(t)}else throw new Error("Please fetchMessages after chat connected.")}startTyping(){return this.provider.startTyping()}stopTyping(){return this.provider.stopTyping()}saveMedia(t,r){this.cachedFiles[t.toString()]=r,this.store.save(t,r)}async destroy(){await this.clearMediaStore(),this.connected&&await this.disconnect(),this.provider&&(this.triggerEvent("destroyed"),this.provider=null),this.events.destroy(),this.state=null}async clearMediaStore(){await this.store.clear()}_handleChatEndedEvent(t){this.disconnect(),this.state&&(t.timeout?(this.state.status="timeout",this.triggerEvent("timeout",this)):(this.state.status="finished",this.triggerEvent("ended",this)))}triggerEvent(t,r){this.events.triggerEvent(t,r),this.globalEvents&&this.globalEvents.triggerEvent("chat."+t,r)}registerProviderEvents(){this.provider&&this.provider.registerConversationEvents()}registerMessageEvents(t){t.event==="cobrowseRequestedFromAgent"?this.events.triggerEvent("_requestCobrowse","agent"):t.event==="cobrowseRequestedFromEndUser"?this.events.triggerEvent("_requestCobrowse","end_user"):t.event==="chatDismissed"&&this.state?(this.state.status="dismissed",this.triggerEvent("dismissed",this)):t.event==="chatEnded"?this.events.triggerEvent("_chatEnded",t):t.event==="escalationStarted"?this.inEscalation=!0:(t.event==="escalationFailed"||t.event==="escalationAccepted")&&(this.inEscalation=!1)}}function IT(e){return e.map(HO).filter(t=>t.enabled)}function HO(e){const t={id:e.id,enabled:!0,channels:[],hidden:!!e.hidden};if(!e.name||!e.name.trim())return t.enabled=!1,t;t.name=e.name.trim();const r=VO(e);if(r&&(t.redirection=e.redirection),e.children&&e.children.length){const n=IT(e.children);return t.enabled=n.length>0||r,t.children=n,t}if(!e.channels)t.enabled=r;else{const{channels:n,deflection:i}=KO(e.channels);t.deflection=i,r||(t.channels=n),t.enabled=n.length>0||r}return t}function VO(e){let t=!1;const r=e.redirection;return r&&(r.option==="message"||r.option==="url")&&(t=!!r.data),t}function KO(e){let t=null;const r=[],n=e.chat,i=a=>{!a.deflection_type&&a.deflected_reason&&(a.deflection_type=a.deflected_reason),a.deflected===void 0&&a.deflection_type&&(a.deflected=!0),r.push(a)};return n&&n.deflected&&(t={enabled:!0,type:n.deflected_reason}),n&&(n.enabled||n.virtual_agent_available)&&i({...e.chat,type:"chat"}),e.voice_call&&e.voice_call.instant_enabled&&i({...e.voice_call,type:"instant_call"}),e.voice_call&&e.voice_call.schedule_enabled&&i({...e.voice_call,type:"scheduled_call",deflection_type:e.voice_call.schedule_deflection_type}),e.email&&e.email.enabled&&i({...e.email,type:"email"}),n&&n.deflected&&n.deflected_reason==="over_capacity"&&n.keep_waiting&&i({...n,enabled:!0,type:"keep_waiting",deflection_type:n.deflected_reason}),e.external_deflection_link&&e.external_deflection_link.enabled&&e.external_deflection_link.links.forEach(s=>{s.enabled&&i({...s,type:"external_link"})}),{channels:r,deflection:t}}const JO={en:"English (US)","en-CA":"English (Canada)","en-GB":"English (UK)",es:"Español (España)","es-MX":"Español (México)",fr:"Français (France)","fr-CA":"Français (Canada)",de:"Deutsch",ja:"日本語",ko:"한국어",it:"Italiano",zh:"中文 (简体)","zh-Hant":"中文 (繁體)",sv:"Svenska",pt:"Português (Portugal)","pt-BR":"Português (Brasil)",fi:"Suomi",nb:"Norsk",da:"Dansk",nl:"Nederlands",tr:"Türk",vi:"Tiếng Việt",th:"คนไทย",ar:"اَلْعَرَبِيَّةُ",cs:"Czech",pl:"Polish",hu:"Hungarian"};function YO(e){var r,n;return{languages:e.languages.filter(i=>i.enabled).map(i=>({lang:i.lang,name:i.name,localeName:JO[i.lang]})),name:e.display_name,subdomain:e.subdomain,support_email:e.support_email,action_tracking:e.action_tracking_enabled,email_transcripts:e.chat_settings.email_transcripts,message_preview:e.chat_settings.message_preview,email_enhancement:e.email_enhancement_enabled,display_history:((r=e.chat_settings.display_history)==null?void 0:r.enabled)&&((n=e.chat_settings.display_history)==null?void 0:n.to_end_user),use_recording:e.use_recording,use_web:e.use_web,cobrowse_domain:e.cobrowse_domain}}function gy(e){return e.chats=e.chats.map(t=>{const r=t.entries.map((n,i)=>XO(n,`${t.comm_id}-${i}`));return t.entries=LO(r),t}),e}function XO(e,t){var r;return{$index:e.timestamp,$sid:t,$timestamp:new Date(e.timestamp),$userType:e.role,$userId:((r=e.user_data)==null?void 0:r.id)||0,user:e.user_data,type:e.type,...e.body}}const yy=/Chrome/.test(navigator.userAgent);class QO{constructor(t){ht(this,"request");this.request=t}get(t,r){if(r){const n=[];Object.keys(r).forEach(i=>{const a=r[i];a!==void 0&&n.push(`${encodeURIComponent(i)}=${encodeURIComponent(a)}`)}),t+="?"+n.join("&")}return this.request(t,{method:"GET"})}post(t,r){const n={method:"POST"};return n.body=JSON.stringify(r),this.request(t,n)}patch(t,r){const n={method:"PATCH"};return n.body=JSON.stringify(r),this.request(t,n)}put(t,r){const n={method:"PUT"};return n.body=JSON.stringify(r),this.request(t,n)}async getTriggers(t){const r={"UJET-Company-Id":t};return(await this.request("proactive_chat_triggers",{method:"GET",headers:r})).data}trackClientEvents(t){return this.post("/client_events",{events:t})}async getCompany(){const t=await this.get("company");return YO(t.data)}async getMenus(t,r){const n={type:"web_menu",lang:t,direct_access_key:r},i=await this.get("menus",n),a={key:!!r,user:!1},s=i.headers["ujet-direct-access"];return s&&s!="false"&&(a.user=!0),{menus:IT(i.data),direct:a}}async getAfterHourMessage(t){return(await this.get(`audible_messages/${t}`)).data["after_hours.message"].text}async getTimeSlots(t,r="en"){return(await this.get(`menus/${t}/time_slots`,{type:"web_menu",lang:r})).data}async getWaitTimes(t,r="en"){return(await this.get(`menus/${t}/wait_times`,{type:"web_menu",lang:r})).data}async verifyForm(t){try{return await this.post("forms/verify",t),!0}catch{return!1}}async finishChat(t){return(await this.patch(`chats/${t}`,{status:"finished"})).data}async updatePostSession(t,r){const n={post_session_transfer_status:r};try{return(await this.patch(`chats/${t}`,n)).data}catch(i){if(r===to.IN_PROGRESS&&i.status===400)return(await this.patch(`chats/${t}`,n)).data;throw i}}async getChatDeflection(t){const{data:r}=await this.get(`chats/${t}/deflections`);return r&&r.enabled?r:null}sendChatCustomData(t,r){let n;return typeof r=="string"?n={signed:!0,signed_data:r}:n={signed:!1,data:r},this.post(`chats/${t}/custom_data`,n)}async downloadChatTranscript(t){return(await this.post(`chats/${t}/generate_transcript_pdf`,{})).data}async getPdfStatus(t){return await this.get(`chat_transcript_pdfs/${t}/download_transcript`)}sendChatTranscripts(t,r){return this.post(`chats/${t}/transcripts`,{emails:r.join(",")})}async listChatTaskMessages(t){return(await this.get(`chats/${t}/task_va_messages`)).data}async getChatTaskMessage(t,r){return(await this.get(`chats/${t}/task_va_messages/${r}`)).data}async sendChatTaskMessage(t,r){const n={content:{content:r,type:"text"}};return(await this.post(`chats/${t}/task_va_messages`,n)).data}async sendChatTextMessage(t,r){const n={message:{content:r,timestamp:new Date().toISOString()}};await this.post(`chats/${t}/messages`,n)}async sendPreviewMessage(t,r,n){const i={message:{content:r,timestamp:n}},{data:a}=await this.post(`chats/${t}/redact_messages`,i);return a}escalateChat(t,r){return this.post(`chats/${t}/escalations`,r)}trackEscalation(t,r,n){return this.put(`chats/${t}/escalations/${r}`,{escalation_id:r,deflection_channel:n})}requestChatCobrowse(t,r){return this.post(`chats/${t}/cobrowse`,r)}rateChat(t,r){return this.patch(`chats/${t}/rating`,r)}async getChatSurvey(t){return(await this.get(`chats/${t}/survey`)).data}sendChatSurvey(t,r){const n={chat_id:t,answers:r};return this.put(`chats/${t}/survey`,n)}trackChatEndUserEvent(t,r){return this.post(`chats/${t}/end_user_event`,r)}async createChat(t,r,n,i){const a={chat:{menu_id:t,lang:r,email:n.email,greeting:n.greeting,trigger_id:n.trigger_id,ticket_id:n==null?void 0:n.ticket_id,custom_data:n==null?void 0:n.custom_data},cobrowsable:n.cobrowsable},o=(await this.post("chats",a)).data;return this.wrapChat(o,i)}async loadChat(t,r){const n=await this.getChat(t);return this.wrapChat(n,r)}async resumeChat(t,r){const n=await this.patch(`chats/${t}`,{status:"queued"});return this.wrapChat(n.data,r)}async getChatHistory(t=1){if(t===1){const{data:r}=await this.get("/chats/histories?page=1&per_page=2");return gy(r)}else{const{data:r}=await this.get(`/chats/histories?page=${t}&per_page=1`);return gy(r)}}async uploadChatFile(t,r){let n="file";/^image/.test(r.type)?n="photo":/^video/.test(r.type)?n="video":n="file";const i=r.name.replace(/\.[^.]+$/i,""),a=await this.post(`chats/${t}/${n}s/upload`,{filename:i}),s={file:r,fields:a.data.fields};yy&&(s.file=await OT(r));const u=(await this.request(a.data.url,s)).data.key,l=(await this.post(`chats/${t}/${n}s`,{chat_id:t,[n]:{s3_path:u,photo_type:n}})).data;return l.type=n,l}async getChat(t){return(await this.get(`chats/${t}`)).data}async wrapChat(t,r){const n=async()=>(await this.post(`chats/${t.id}/tokens`,{provider_type:t.provider_type,device_id:r})).data,i=new GO(t,n),a=async s=>{if(i.status==="va_assigned"){const o=await this.getSkipVirtualAgentSettings(i.menuId,i.lang);i.allowSkipVirtualAgent=o,i.update(s)}};if(i.channelId)i.connect(),a(t);else{let s;for(;!s;)await this.getChat(i.id).then(o=>{o.provider_channel_id&&i.state?(s=!0,i.update(o),i.connect(),a(o)):(o.status==="canceled"||o.status==="finished")&&(s=!0)}),s||await wT(1500)}return i.on("initialized",async()=>{if(i.status==="queued"){const s=await this.getChat(i.id);i.update(s)}}),i.on("memberJoined",async()=>{const s=await this.getChat(i.id);i.update(s)}),i.on("memberLeft",async()=>{const s=await this.getChat(i.id);i.update(s)}),i.on("_chatEnded",async s=>{const o=await this.getChat(i.id);i.update(o),(!i.state||i.ended)&&i._handleChatEndedEvent(s)}),i.on("_menuChanged",async s=>{const o=await this.getChat(s.id);a(o)}),i}async createCall(t,r,n){const i={type:n.scheduled_at?"web_scheduled_call":"web_instant_call",menu_id:t,lang:r,email:n.email,ticket_id:n.ticket_id,recording_permission:n.recording_permission||"recording_permission_not_asked",scheduled_at:n.scheduled_at,custom_data:n.custom_data,end_user:{phone_number:n.phone_number}},s=(await this.post("calls",{call:i,cobrowsable:!1})).data;return s.menu_id=s.selected_menu.id,s}async fetchCall(t){const n=(await this.get(`calls/${t}`)).data;return n.menu_id=n.selected_menu.id,n}async cancelCall(t){const n=(await this.patch(`calls/${t}`,{status:"failed",fail_reason:"canceled"})).data;return n.menu_id=n.selected_menu.id,n}async listFileTypes(){return(await this.get("email_prohibited_file_types")).data}async createEmail(t,r,n){const i={end_user_email:n.email,email_body:n.content,menu_id:t.toString(),lang:r};return n.name&&(i.end_user_name=n.name),n.recaptcha&&(i.recaptcha_response=n.recaptcha),n.files&&yy?i["email_attachments[]"]=await ZO(n.files):n.files&&(i["email_attachments[]"]=[...n.files]),this.request("emails",{form:i})}async getMedia(t,r){const n=await this.get(`media/${t}?type=${r}`);if(!n.data)return null;const i=n.headers["x-file-name"];return new File([n.data],i,{type:n.data.type})}async getSkipVirtualAgentSettings(t,r){return(await this.get(`menus/${t}/virtual_agent_settings`,{lang:r})).data.allow_skip_virtual_agent}}function ZO(e){return Promise.all(e.map(OT))}function OT(e){return new Promise((t,r)=>{const n=new FileReader;n.onload=()=>{const i=[n.result],a={type:e.type,lastModified:e.lastModified};t({name:e.name,fileBits:i,options:a})},n.onerror=r,n.readAsArrayBuffer(e)})}const ld="ujet:",Kr={set(e,t){return localStorage.setItem(ld+e,t)},get(e){return localStorage.getItem(ld+e)},del(e){return localStorage.removeItem(ld+e)}},eA=Date.now(),AT={href:window.location.href,interval:24*60*60};function tA(e){if(!Array.isArray(e)||!e.length)return null;const t=sA(),r=t===0,n=t+1;return oA(n),e.filter(a=>{const s=nA(a,AT.href),o=iA(a.visitor_type,r),u=n>=a.page_visit_count,c=!aA(a.id);return s&&o&&u&&c}).sort((a,s)=>a.stay_time-s.stay_time)[0]||null}function rA(e,t){const r=e.stay_time*1e3,n=Math.max(r-(Date.now()-eA),0);setTimeout(()=>{t(e),Kr.set(`trigger:${e.id}`,(Date.now()/1e3).toString())},n)}const nA=(e,t)=>{const{keywords_included_or:r=[],keywords_excluded_or:n=[],keywords_included:i=[],keywords_excluded:a=[]}=e;if(EO(r,n,i,a))return!0;if(r.length||n.length){const u=r.some(l=>l.every(p=>t.includes(p))),c=n.length>0&&n.every(l=>l.every(p=>!t.includes(p)));return u||c}const s=i.filter(u=>t.indexOf(u)!==-1).length,o=a.filter(u=>t.indexOf(u)===-1).length;return!!s||!!o};function iA(e,t){return e==="visitor_type_new"?t:e==="visitor_type_returning"?!t:!0}function aA(e){try{const t=parseInt(Kr.get(`trigger:${e}`),10);return Date.now()/1e3-t<AT.interval}catch{return!1}}function sA(){try{const e=Kr.get("visits");return e?parseInt(e,10):0}catch{return 0}}function oA(e){try{Kr.set("visits",e.toString())}catch(t){console.error(t)}}/*!
1
+ "use strict";var HI=Object.defineProperty;var VI=(e,t,r)=>t in e?HI(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ht=(e,t,r)=>VI(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function KI(e,t){for(var r=0;r<t.length;r++){const n=t[r];if(typeof n!="string"&&!Array.isArray(n)){for(const i in n)if(i!=="default"&&!(i in e)){const a=Object.getOwnPropertyDescriptor(n,i);a&&Object.defineProperty(e,i,a.get?a:{enumerable:!0,get:()=>n[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var to=(e=>(e.WAITING="waiting",e.READY="ready",e.IN_PROGRESS="in_progress",e.FINISHED="finished",e))(to||{});const JI="prod",Qv="3.37.4",ey="https://main.api.ujet.co",Br={companyId:"",tenant:"",trackerId:"",deviceId:"",application:"websdk",version:Qv};/*! @license DOMPurify 3.2.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.4/LICENSE */const{entries:mT,setPrototypeOf:ty,isFrozen:YI,getPrototypeOf:XI,getOwnPropertyDescriptor:QI}=Object;let{freeze:tn,seal:Fn,create:gT}=Object,{apply:hh,construct:vh}=typeof Reflect<"u"&&Reflect;tn||(tn=function(t){return t});Fn||(Fn=function(t){return t});hh||(hh=function(t,r,n){return t.apply(r,n)});vh||(vh=function(t,r){return new t(...r)});const nc=rn(Array.prototype.forEach),ZI=rn(Array.prototype.lastIndexOf),ry=rn(Array.prototype.pop),Ro=rn(Array.prototype.push),eO=rn(Array.prototype.splice),pl=rn(String.prototype.toLowerCase),nd=rn(String.prototype.toString),ny=rn(String.prototype.match),$o=rn(String.prototype.replace),tO=rn(String.prototype.indexOf),rO=rn(String.prototype.trim),Xn=rn(Object.prototype.hasOwnProperty),Xr=rn(RegExp.prototype.test),Io=nO(TypeError);function rn(e){return function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return hh(e,t,n)}}function nO(e){return function(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return vh(e,r)}}function xt(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:pl;ty&&ty(e,null);let n=t.length;for(;n--;){let i=t[n];if(typeof i=="string"){const a=r(i);a!==i&&(YI(t)||(t[n]=a),i=a)}e[i]=!0}return e}function iO(e){for(let t=0;t<e.length;t++)Xn(e,t)||(e[t]=null);return e}function Qa(e){const t=gT(null);for(const[r,n]of mT(e))Xn(e,r)&&(Array.isArray(n)?t[r]=iO(n):n&&typeof n=="object"&&n.constructor===Object?t[r]=Qa(n):t[r]=n);return t}function Oo(e,t){for(;e!==null;){const n=QI(e,t);if(n){if(n.get)return rn(n.get);if(typeof n.value=="function")return rn(n.value)}e=XI(e)}function r(){return null}return r}const iy=tn(["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","section","select","shadow","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"]),id=tn(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),ad=tn(["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"]),aO=tn(["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"]),sd=tn(["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"]),sO=tn(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ay=tn(["#text"]),sy=tn(["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","face","for","headers","height","hidden","high","href","hreflang","id","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","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),od=tn(["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","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"]),oy=tn(["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"]),ic=tn(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),oO=Fn(/\{\{[\w\W]*|[\w\W]*\}\}/gm),uO=Fn(/<%[\w\W]*|[\w\W]*%>/gm),cO=Fn(/\$\{[\w\W]*/gm),lO=Fn(/^data-[\-\w.\u00B7-\uFFFF]+$/),fO=Fn(/^aria-[\-\w]+$/),yT=Fn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),dO=Fn(/^(?:\w+script|data):/i),pO=Fn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),bT=Fn(/^html$/i),hO=Fn(/^[a-z][.\w]*(-[.\w]+)+$/i);var uy=Object.freeze({__proto__:null,ARIA_ATTR:fO,ATTR_WHITESPACE:pO,CUSTOM_ELEMENT:hO,DATA_ATTR:lO,DOCTYPE_NAME:bT,ERB_EXPR:uO,IS_ALLOWED_URI:yT,IS_SCRIPT_OR_DATA:dO,MUSTACHE_EXPR:oO,TMPLIT_EXPR:cO});const Ao={element:1,text:3,progressingInstruction:7,comment:8,document:9},vO=function(){return typeof window>"u"?null:window},mO=function(t,r){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let n=null;const i="data-tt-policy-suffix";r&&r.hasAttribute(i)&&(n=r.getAttribute(i));const a="dompurify"+(n?"#"+n:"");try{return t.createPolicy(a,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},cy=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function _T(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:vO();const t=it=>_T(it);if(t.version="3.2.4",t.removed=[],!e||!e.document||e.document.nodeType!==Ao.document||!e.Element)return t.isSupported=!1,t;let{document:r}=e;const n=r,i=n.currentScript,{DocumentFragment:a,HTMLTemplateElement:s,Node:o,Element:u,NodeFilter:c,NamedNodeMap:l=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:v,trustedTypes:m}=e,b=u.prototype,T=Oo(b,"cloneNode"),I=Oo(b,"remove"),R=Oo(b,"nextSibling"),x=Oo(b,"childNodes"),N=Oo(b,"parentNode");if(typeof s=="function"){const it=r.createElement("template");it.content&&it.content.ownerDocument&&(r=it.content.ownerDocument)}let j,X="";const{implementation:J,createNodeIterator:V,createDocumentFragment:D,getElementsByTagName:te}=r,{importNode:ue}=n;let ee=cy();t.isSupported=typeof mT=="function"&&typeof N=="function"&&J&&J.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:ge,ERB_EXPR:L,TMPLIT_EXPR:pe,DATA_ATTR:Te,ARIA_ATTR:rt,IS_SCRIPT_OR_DATA:Ke,ATTR_WHITESPACE:Se,CUSTOM_ELEMENT:ce}=uy;let{IS_ALLOWED_URI:he}=uy,P=null;const Ie=xt({},[...iy,...id,...ad,...sd,...ay]);let qe=null;const Ne=xt({},[...sy,...od,...oy,...ic]);let _e=Object.seal(gT(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}})),Q=null,kt=null,Ce=!0,de=!0,Rt=!1,Ue=!0,Dt=!1,mt=!0,ke=!1,ft=!1,St=!1,Oe=!1,Bt=!1,vt=!1,qt=!0,sr=!1;const ze="user-content-";let Tr=!0,mr=!1,Et={},It=null;const bt=xt({},["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 ct=null;const Ft=xt({},["audio","video","img","source","image","track"]);let Pt=null;const cr=xt({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Cr="http://www.w3.org/1998/Math/MathML",Dr="http://www.w3.org/2000/svg",gr="http://www.w3.org/1999/xhtml";let zt=gr,lr=!1,ye=null;const we=xt({},[Cr,Dr,gr],nd);let se=xt({},["mi","mo","mn","ms","mtext"]),me=xt({},["annotation-xml"]);const le=xt({},["title","style","font","a","script"]);let be=null;const $e=["application/xhtml+xml","text/html"],re="text/html";let ae=null,K=null;const oe=r.createElement("form"),Y=function(Z){return Z instanceof RegExp||Z instanceof Function},De=function(){let Z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(K&&K===Z)){if((!Z||typeof Z!="object")&&(Z={}),Z=Qa(Z),be=$e.indexOf(Z.PARSER_MEDIA_TYPE)===-1?re:Z.PARSER_MEDIA_TYPE,ae=be==="application/xhtml+xml"?nd:pl,P=Xn(Z,"ALLOWED_TAGS")?xt({},Z.ALLOWED_TAGS,ae):Ie,qe=Xn(Z,"ALLOWED_ATTR")?xt({},Z.ALLOWED_ATTR,ae):Ne,ye=Xn(Z,"ALLOWED_NAMESPACES")?xt({},Z.ALLOWED_NAMESPACES,nd):we,Pt=Xn(Z,"ADD_URI_SAFE_ATTR")?xt(Qa(cr),Z.ADD_URI_SAFE_ATTR,ae):cr,ct=Xn(Z,"ADD_DATA_URI_TAGS")?xt(Qa(Ft),Z.ADD_DATA_URI_TAGS,ae):Ft,It=Xn(Z,"FORBID_CONTENTS")?xt({},Z.FORBID_CONTENTS,ae):bt,Q=Xn(Z,"FORBID_TAGS")?xt({},Z.FORBID_TAGS,ae):{},kt=Xn(Z,"FORBID_ATTR")?xt({},Z.FORBID_ATTR,ae):{},Et=Xn(Z,"USE_PROFILES")?Z.USE_PROFILES:!1,Ce=Z.ALLOW_ARIA_ATTR!==!1,de=Z.ALLOW_DATA_ATTR!==!1,Rt=Z.ALLOW_UNKNOWN_PROTOCOLS||!1,Ue=Z.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Dt=Z.SAFE_FOR_TEMPLATES||!1,mt=Z.SAFE_FOR_XML!==!1,ke=Z.WHOLE_DOCUMENT||!1,Oe=Z.RETURN_DOM||!1,Bt=Z.RETURN_DOM_FRAGMENT||!1,vt=Z.RETURN_TRUSTED_TYPE||!1,St=Z.FORCE_BODY||!1,qt=Z.SANITIZE_DOM!==!1,sr=Z.SANITIZE_NAMED_PROPS||!1,Tr=Z.KEEP_CONTENT!==!1,mr=Z.IN_PLACE||!1,he=Z.ALLOWED_URI_REGEXP||yT,zt=Z.NAMESPACE||gr,se=Z.MATHML_TEXT_INTEGRATION_POINTS||se,me=Z.HTML_INTEGRATION_POINTS||me,_e=Z.CUSTOM_ELEMENT_HANDLING||{},Z.CUSTOM_ELEMENT_HANDLING&&Y(Z.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(_e.tagNameCheck=Z.CUSTOM_ELEMENT_HANDLING.tagNameCheck),Z.CUSTOM_ELEMENT_HANDLING&&Y(Z.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(_e.attributeNameCheck=Z.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),Z.CUSTOM_ELEMENT_HANDLING&&typeof Z.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(_e.allowCustomizedBuiltInElements=Z.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Dt&&(de=!1),Bt&&(Oe=!0),Et&&(P=xt({},ay),qe=[],Et.html===!0&&(xt(P,iy),xt(qe,sy)),Et.svg===!0&&(xt(P,id),xt(qe,od),xt(qe,ic)),Et.svgFilters===!0&&(xt(P,ad),xt(qe,od),xt(qe,ic)),Et.mathMl===!0&&(xt(P,sd),xt(qe,oy),xt(qe,ic))),Z.ADD_TAGS&&(P===Ie&&(P=Qa(P)),xt(P,Z.ADD_TAGS,ae)),Z.ADD_ATTR&&(qe===Ne&&(qe=Qa(qe)),xt(qe,Z.ADD_ATTR,ae)),Z.ADD_URI_SAFE_ATTR&&xt(Pt,Z.ADD_URI_SAFE_ATTR,ae),Z.FORBID_CONTENTS&&(It===bt&&(It=Qa(It)),xt(It,Z.FORBID_CONTENTS,ae)),Tr&&(P["#text"]=!0),ke&&xt(P,["html","head","body"]),P.table&&(xt(P,["tbody"]),delete Q.tbody),Z.TRUSTED_TYPES_POLICY){if(typeof Z.TRUSTED_TYPES_POLICY.createHTML!="function")throw Io('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof Z.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Io('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');j=Z.TRUSTED_TYPES_POLICY,X=j.createHTML("")}else j===void 0&&(j=mO(m,i)),j!==null&&typeof X=="string"&&(X=j.createHTML(""));tn&&tn(Z),K=Z}},Re=xt({},[...id,...ad,...aO]),Je=xt({},[...sd,...sO]),Ge=function(Z){let xe=N(Z);(!xe||!xe.tagName)&&(xe={namespaceURI:zt,tagName:"template"});const Ye=pl(Z.tagName),Mt=pl(xe.tagName);return ye[Z.namespaceURI]?Z.namespaceURI===Dr?xe.namespaceURI===gr?Ye==="svg":xe.namespaceURI===Cr?Ye==="svg"&&(Mt==="annotation-xml"||se[Mt]):!!Re[Ye]:Z.namespaceURI===Cr?xe.namespaceURI===gr?Ye==="math":xe.namespaceURI===Dr?Ye==="math"&&me[Mt]:!!Je[Ye]:Z.namespaceURI===gr?xe.namespaceURI===Dr&&!me[Mt]||xe.namespaceURI===Cr&&!se[Mt]?!1:!Je[Ye]&&(le[Ye]||!Re[Ye]):!!(be==="application/xhtml+xml"&&ye[Z.namespaceURI]):!1},He=function(Z){Ro(t.removed,{element:Z});try{N(Z).removeChild(Z)}catch{I(Z)}},et=function(Z,xe){try{Ro(t.removed,{attribute:xe.getAttributeNode(Z),from:xe})}catch{Ro(t.removed,{attribute:null,from:xe})}if(xe.removeAttribute(Z),Z==="is")if(Oe||Bt)try{He(xe)}catch{}else try{xe.setAttribute(Z,"")}catch{}},nt=function(Z){let xe=null,Ye=null;if(St)Z="<remove></remove>"+Z;else{const Ot=ny(Z,/^[\r\n\t ]+/);Ye=Ot&&Ot[0]}be==="application/xhtml+xml"&&zt===gr&&(Z='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+Z+"</body></html>");const Mt=j?j.createHTML(Z):Z;if(zt===gr)try{xe=new v().parseFromString(Mt,be)}catch{}if(!xe||!xe.documentElement){xe=J.createDocument(zt,"template",null);try{xe.documentElement.innerHTML=lr?X:Mt}catch{}}const nr=xe.body||xe.documentElement;return Z&&Ye&&nr.insertBefore(r.createTextNode(Ye),nr.childNodes[0]||null),zt===gr?te.call(xe,ke?"html":"body")[0]:ke?xe.documentElement:nr},Qe=function(Z){return V.call(Z.ownerDocument||Z,Z,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},tt=function(Z){return Z instanceof p&&(typeof Z.nodeName!="string"||typeof Z.textContent!="string"||typeof Z.removeChild!="function"||!(Z.attributes instanceof l)||typeof Z.removeAttribute!="function"||typeof Z.setAttribute!="function"||typeof Z.namespaceURI!="string"||typeof Z.insertBefore!="function"||typeof Z.hasChildNodes!="function")},at=function(Z){return typeof o=="function"&&Z instanceof o};function st(it,Z,xe){nc(it,Ye=>{Ye.call(t,Z,xe,K)})}const yr=function(Z){let xe=null;if(st(ee.beforeSanitizeElements,Z,null),tt(Z))return He(Z),!0;const Ye=ae(Z.nodeName);if(st(ee.uponSanitizeElement,Z,{tagName:Ye,allowedTags:P}),Z.hasChildNodes()&&!at(Z.firstElementChild)&&Xr(/<[/\w]/g,Z.innerHTML)&&Xr(/<[/\w]/g,Z.textContent)||Z.nodeType===Ao.progressingInstruction||mt&&Z.nodeType===Ao.comment&&Xr(/<[/\w]/g,Z.data))return He(Z),!0;if(!P[Ye]||Q[Ye]){if(!Q[Ye]&&dt(Ye)&&(_e.tagNameCheck instanceof RegExp&&Xr(_e.tagNameCheck,Ye)||_e.tagNameCheck instanceof Function&&_e.tagNameCheck(Ye)))return!1;if(Tr&&!It[Ye]){const Mt=N(Z)||Z.parentNode,nr=x(Z)||Z.childNodes;if(nr&&Mt){const Ot=nr.length;for(let ir=Ot-1;ir>=0;--ir){const Pr=T(nr[ir],!0);Pr.__removalCount=(Z.__removalCount||0)+1,Mt.insertBefore(Pr,R(Z))}}}return He(Z),!0}return Z instanceof u&&!Ge(Z)||(Ye==="noscript"||Ye==="noembed"||Ye==="noframes")&&Xr(/<\/no(script|embed|frames)/i,Z.innerHTML)?(He(Z),!0):(Dt&&Z.nodeType===Ao.text&&(xe=Z.textContent,nc([ge,L,pe],Mt=>{xe=$o(xe,Mt," ")}),Z.textContent!==xe&&(Ro(t.removed,{element:Z.cloneNode()}),Z.textContent=xe)),st(ee.afterSanitizeElements,Z,null),!1)},fr=function(Z,xe,Ye){if(qt&&(xe==="id"||xe==="name")&&(Ye in r||Ye in oe))return!1;if(!(de&&!kt[xe]&&Xr(Te,xe))){if(!(Ce&&Xr(rt,xe))){if(!qe[xe]||kt[xe]){if(!(dt(Z)&&(_e.tagNameCheck instanceof RegExp&&Xr(_e.tagNameCheck,Z)||_e.tagNameCheck instanceof Function&&_e.tagNameCheck(Z))&&(_e.attributeNameCheck instanceof RegExp&&Xr(_e.attributeNameCheck,xe)||_e.attributeNameCheck instanceof Function&&_e.attributeNameCheck(xe))||xe==="is"&&_e.allowCustomizedBuiltInElements&&(_e.tagNameCheck instanceof RegExp&&Xr(_e.tagNameCheck,Ye)||_e.tagNameCheck instanceof Function&&_e.tagNameCheck(Ye))))return!1}else if(!Pt[xe]){if(!Xr(he,$o(Ye,Se,""))){if(!((xe==="src"||xe==="xlink:href"||xe==="href")&&Z!=="script"&&tO(Ye,"data:")===0&&ct[Z])){if(!(Rt&&!Xr(Ke,$o(Ye,Se,"")))){if(Ye)return!1}}}}}}return!0},dt=function(Z){return Z!=="annotation-xml"&&ny(Z,ce)},Wr=function(Z){st(ee.beforeSanitizeAttributes,Z,null);const{attributes:xe}=Z;if(!xe||tt(Z))return;const Ye={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:qe,forceKeepAttr:void 0};let Mt=xe.length;for(;Mt--;){const nr=xe[Mt],{name:Ot,namespaceURI:ir,value:Pr}=nr,Mr=ae(Ot);let dr=Ot==="value"?Pr:rO(Pr);if(Ye.attrName=Mr,Ye.attrValue=dr,Ye.keepAttr=!0,Ye.forceKeepAttr=void 0,st(ee.uponSanitizeAttribute,Z,Ye),dr=Ye.attrValue,sr&&(Mr==="id"||Mr==="name")&&(et(Ot,Z),dr=ze+dr),mt&&Xr(/((--!?|])>)|<\/(style|title)/i,dr)){et(Ot,Z);continue}if(Ye.forceKeepAttr||(et(Ot,Z),!Ye.keepAttr))continue;if(!Ue&&Xr(/\/>/i,dr)){et(Ot,Z);continue}Dt&&nc([ge,L,pe],Gr=>{dr=$o(dr,Gr," ")});const $n=ae(Z.nodeName);if(fr($n,Mr,dr)){if(j&&typeof m=="object"&&typeof m.getAttributeType=="function"&&!ir)switch(m.getAttributeType($n,Mr)){case"TrustedHTML":{dr=j.createHTML(dr);break}case"TrustedScriptURL":{dr=j.createScriptURL(dr);break}}try{ir?Z.setAttributeNS(ir,Ot,dr):Z.setAttribute(Ot,dr),tt(Z)?He(Z):ry(t.removed)}catch{}}}st(ee.afterSanitizeAttributes,Z,null)},cn=function it(Z){let xe=null;const Ye=Qe(Z);for(st(ee.beforeSanitizeShadowDOM,Z,null);xe=Ye.nextNode();)st(ee.uponSanitizeShadowNode,xe,null),yr(xe),Wr(xe),xe.content instanceof a&&it(xe.content);st(ee.afterSanitizeShadowDOM,Z,null)};return t.sanitize=function(it){let Z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},xe=null,Ye=null,Mt=null,nr=null;if(lr=!it,lr&&(it="<!-->"),typeof it!="string"&&!at(it))if(typeof it.toString=="function"){if(it=it.toString(),typeof it!="string")throw Io("dirty is not a string, aborting")}else throw Io("toString is not a function");if(!t.isSupported)return it;if(ft||De(Z),t.removed=[],typeof it=="string"&&(mr=!1),mr){if(it.nodeName){const Pr=ae(it.nodeName);if(!P[Pr]||Q[Pr])throw Io("root node is forbidden and cannot be sanitized in-place")}}else if(it instanceof o)xe=nt("<!---->"),Ye=xe.ownerDocument.importNode(it,!0),Ye.nodeType===Ao.element&&Ye.nodeName==="BODY"||Ye.nodeName==="HTML"?xe=Ye:xe.appendChild(Ye);else{if(!Oe&&!Dt&&!ke&&it.indexOf("<")===-1)return j&&vt?j.createHTML(it):it;if(xe=nt(it),!xe)return Oe?null:vt?X:""}xe&&St&&He(xe.firstChild);const Ot=Qe(mr?it:xe);for(;Mt=Ot.nextNode();)yr(Mt),Wr(Mt),Mt.content instanceof a&&cn(Mt.content);if(mr)return it;if(Oe){if(Bt)for(nr=D.call(xe.ownerDocument);xe.firstChild;)nr.appendChild(xe.firstChild);else nr=xe;return(qe.shadowroot||qe.shadowrootmode)&&(nr=ue.call(n,nr,!0)),nr}let ir=ke?xe.outerHTML:xe.innerHTML;return ke&&P["!doctype"]&&xe.ownerDocument&&xe.ownerDocument.doctype&&xe.ownerDocument.doctype.name&&Xr(bT,xe.ownerDocument.doctype.name)&&(ir="<!DOCTYPE "+xe.ownerDocument.doctype.name+`>
2
+ `+ir),Dt&&nc([ge,L,pe],Pr=>{ir=$o(ir,Pr," ")}),j&&vt?j.createHTML(ir):ir},t.setConfig=function(){let it=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};De(it),ft=!0},t.clearConfig=function(){K=null,ft=!1},t.isValidAttribute=function(it,Z,xe){K||De({});const Ye=ae(it),Mt=ae(Z);return fr(Ye,Mt,xe)},t.addHook=function(it,Z){typeof Z=="function"&&Ro(ee[it],Z)},t.removeHook=function(it,Z){if(Z!==void 0){const xe=ZI(ee[it],Z);return xe===-1?void 0:eO(ee[it],xe,1)[0]}return ry(ee[it])},t.removeHooks=function(it){ee[it]=[]},t.removeAllHooks=function(){ee=cy()},t}var gO=_T();const yO={ALLOWED_TAGS:["b","i","em","strong","p","br","ul","ol","li","a"],ALLOWED_ATTR:["href","src","alt","title","target","class","id","style"],ALLOW_DATA_ATTR:!1,FORBID_TAGS:["img","iframe","object","input","style","script","embed","svg","video","audio","body","input","form","link"],FORBID_ATTR:["onerror","onclick","onload","onmouseover","onfocus","onblur","onchange","onsubmit","scr","href","style","action","value"],IN_PLACE:!0},bO="javascript:";function _O(e){return(e==null?void 0:e.constructor)===Object}async function ly(e,t=3){let r=0,n;for(;r<=t;){r+=1;try{return await e()}catch(i){n=i,console.error(i),await wT(1e3*Math.pow(2,r))}}throw n}function wT(e){return new Promise(t=>{setTimeout(()=>{t(0)},e)})}function wO(){return Math.random().toString(36).slice(2)}const SO=new TextDecoder,TO=e=>{const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return SO.decode(r)},CO=e=>e.length===0,EO=(...e)=>e.every(CO),ST=e=>{const t=gO.sanitize(e,yO);return t.includes(bO)?(console.warn("Suspicious content detected and removed."),""):t},fy=[];class $a{constructor(t){ht(this,"channel");this.channel=t}static addHandler(t){fy.push(t)}debug(...t){this._log("debug",...t)}info(...t){this._log("info",...t)}warn(...t){this._log("warn",...t)}error(...t){this._log("error",...t)}_log(t,...r){fy.forEach(n=>{n(this.channel,t,...r)})}}const kO=(e,t,...r)=>{console[t](`[${t}][${e}]`,...r)},RO=e=>{let t=[],r;return(i,a,...s)=>{a==="debug"||i==="communicator"||(t.push($O(i,a,...s)),clearTimeout(r),r=window.setTimeout(()=>{if(t.length){const o={num_of_logs:t.length,logs:t};e(o)}t=[]},2e3))}};function $O(e,t,...r){let n=r.pop();typeof n=="string"&&(r.push(n),n={});const i=r.join(" "),a={loglevel:t,channel:e,timestamp:new Date().toISOString(),application:Br.application,version:Br.version,device:Br.deviceId,tenant:Br.tenant,company_id:Br.companyId,location_url:location.href,data:AO(n),message:Zv(i)};return Br.trackerId&&(a.tracker_id=Br.trackerId),a}const IO=["user","phone","phone_number","phoneNumber","email"],OO=[/(?:3[47]\d|(?:4\d|5[1-5]|65)\d{2}|6011)\d{12}/g,/(?!(000|666|9))\d{3}-(?!00)\d{2}-(?!0000)\d{4}/g,/^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)+$/g];function Zv(e){return typeof e=="string"?OO.forEach(t=>{e=e.replace(t,"__MASKED__")}):e&&_O(e)&&(e={...e},Object.keys(e).forEach(t=>{IO.indexOf(t)!==-1?e[t]="__MASKED__":Zv(e[t])})),e}function AO(e){if(e.error){const t=e.error;return{error:{name:t.name,message:t.message,stack:t.stack}}}return Zv(e.data)}const ud=new $a("communicator");let dy=!1;class PO{constructor(t,r){ht(this,"events");ht(this,"options");ht(this,"channel");ht(this,"authenticate");ht(this,"channelReady",!1);ht(this,"__authed",!1);ht(this,"pending",[]);ht(this,"promises",{});ht(this,"user");ht(this,"iframe");this.authenticate=t.authenticate,this.events=r,this.options=MO(t),this.channel=new MessageChannel,this.useConnect(this.options)}useConnect(t){const r=document.createElement("iframe");r.src=t.bridge,r.setAttribute("style","display:none");let n="*";/^https:/.test(t.bridge)&&(n=new URL(t.bridge).origin),r.addEventListener("load",()=>{if(ud.debug("iframe bridge ready for",n),!this.channelReady){const i={type:"_init",data:t};r.contentWindow.postMessage(i,n,[this.channel.port2])}}),this.channel.port1.onmessage=i=>{this.receiveMessage(i)},document.body.appendChild(r),this.iframe=r}receiveMessage(t){const r=t.data;if(r){if(ud.debug("receiveMessage",r),r.type==="ready")this.channelReady=!0,Br.deviceId=r.result.deviceId,Br.deviceId||console.error("Device Id has not been provided. SDK will not work properly."),this.runPending(),this.events.triggerEvent("ready");else if(r.type==="callback"&&r.callbackId){const[n,i]=this.promises[r.callbackId];r.error?i(r.error):n(r.result),delete this.promises[r.callbackId]}else if(r.type==="refreshToken")this.refreshToken();else if(r.request==="_auth"&&(this.events.triggerEvent("authenticated"),r.result&&r.result.log_proxy_url&&!dy)){dy=!0;const n=RO(i=>{this.postMessage({type:"_log",data:i})});$a.addHandler(n)}}}postMessage(t){this.channel&&this.channelReady?(ud.debug("postMessage",t),this.channel.port1.postMessage(t)):this.pending.push(t)}runPending(){for(;this.pending.length;){const t=this.pending.shift();this.postMessage(t)}}postPromise(t,r){return new Promise((n,i)=>{const a=wO()+"_"+Date.now();this.promises[a]=[n,i];const s={type:t,callbackId:a,data:r};this.postMessage(s)})}async refreshToken(){this.__authed=!0;const t=await this.authenticate(),r=["twilio_chat","nexmo_chat"];this.options.cobrowse&&r.push("cobrowse");const i={type:"_auth",data:{modules:r,user:{token:t.token,company_id:this.options.companyId}}};this.postMessage(i);const a=JSON.parse(TO(t.token.split(".")[1]));if(this.user={identifier:a.identifier,name:a.name,email:a.email},this.events.triggerEvent("authenticate"),a.exp){let s;a.exp.toString().length===13?s=a.exp:a.exp.toString().length===10&&(s=a.exp*1e3),s&&setTimeout(()=>{this.refreshToken()},s-Date.now()-12e4)}}request(t,r){!this.__authed&&t!=="proactive_chat_triggers"&&this.refreshToken();const n={url:t,options:r};return this.postPromise("request",n)}destroy(){delete this.channel,this.iframe&&(document.body.removeChild(this.iframe),this.iframe=void 0)}}function MO(e){var a;let t=e.host;t||(e.tenant?t=ey.replace("main.api",e.tenant+".api"):t=ey);const r=e.lang||"en",n=!!((a=e.cobrowse)!=null&&a.enabled),i=e.bridge||"https://websdk.ujet.co/v3/bridge.html";return{host:t,lang:r,cobrowse:n,companyId:e.companyId,location:location.href,version:e.version||"3.37.4",bridge:i}}class em{constructor(){ht(this,"handlers",{})}addEventListener(t,r){this.handlers[t]||(this.handlers[t]=[]),this.handlers[t].push(r)}triggerEvent(t,r){const n=this.handlers[t];n&&n.forEach(i=>{i(r)})}removeEventListener(t,r){if(this.handlers[t]){const n=this.handlers[t].indexOf(r);n!==-1&&this.handlers[t].splice(n,1)}}destroy(){this.handlers={}}}function xO(e,t){const r={};return t.forEach(n=>{r[n.id]=n}),e.map(n=>{if(n.type==="server_message"){const i=n.message_id,a=r[i];TT(n,a.content)}return n})}function NO(e,t){return TT(e,t.content)}function TT(e,t){return Object.keys(t).forEach(r=>{e[r]=t[r]}),e}const py={photo:2,video:2,audio:1,document:1};function LO(e){const t=e.toSorted((r,n)=>!r.groupMessageId||!n.groupMessageId||r.groupMessageId!==n.groupMessageId?0:(py[n.type]||0)-(py[r.type]||0));return t.forEach((r,n,i)=>{const a=!r.groupMessageId,s=i[n+1];s&&(a&&s.$userId===r.$userId&&r.$time||!a&&s.groupMessageId===r.groupMessageId&&r.$time)&&(s.$time=r.$time,r.$time=null)}),t}const hy=new $a("MediaStore"),DO=window.indexedDB||window.webkitIndexedDB||window.mozIndexedDB||window.OIndexedDB||window.msIndexedDB,jO="chat-media",vy=1,Ol="file";class CT{constructor(){ht(this,"db")}store(){return new Promise((t,r)=>{if(this.db)return t(my(this.db));const n=DO.open(jO,vy);n.onerror=()=>{r(new Error("indexedDB open failed"))},n.onsuccess=()=>{const i=n.result;this.db=i,t(my(i))},n.onupgradeneeded=i=>{const a=n.result;i.oldVersion>0&&i.oldVersion<vy&&(hy.info("deprecating media store"),a.deleteObjectStore(Ol)),hy.info("creating media store"),a.createObjectStore(Ol)}})}async save(t,r){(await this.store()).put({index:t,file:r},t)}async getAll(){const t=await this.store();return await new Promise((r,n)=>{const i=t.getAll();i.onerror=()=>{n(new Error("indexedDB getAll failed"))},i.onsuccess=()=>{r(i.result)}})}async getAllFiles(){const t={};return(await this.getAll()).forEach(n=>{t[n.index]=n.file}),t}async clear(){(await this.store()).clear()}}function my(e){return e.transaction(Ol,"readwrite").objectStore(Ol)}class FO{constructor(){ht(this,"_hostPath","")}setPath(t){this._hostPath=t}getPath(){return this._hostPath}}const ET=new FO,UO=new $a("chat-provider");class tm{constructor(t,r,n){ht(this,"audio");ht(this,"issueChatToken");ht(this,"identity");ht(this,"channelId");ht(this,"region");ht(this,"inTask",!1);ht(this,"muted",!1);ht(this,"events");this.events=t,this.region=r.region,this.issueChatToken=n}ping(){if(!this.muted){if(!this.audio){ET.getPath();const t="https://websdk.ujet.co/v3/ping.mp3";this.audio=new window.Audio(t)}try{this.audio.play()}catch(t){UO.warn("Chat audio play failed",{error:t})}}}on(t,r){this.events.addEventListener(t,r)}off(t,r){this.events.removeEventListener(t,r)}trackInTask(t){t.type==="noti"&&t.event==="taskVaStarted"?this.inTask=!0:t.type==="noti"&&t.event==="taskVaFinished"&&(this.inTask=!1)}}ht(tm,"type","base");const kT={};function rm(e){kT[e.type]=e}function BO(e){return kT[e]}const RT=["assigned","va_assigned"],$T=["dismissed","va_dismissed"],qO=["va_assigned","va_dismissed"],zO=["queued",...RT,...$T],WO=["timeout","canceled","failed","finished"],cd=new $a("Chat");class GO{constructor(t,r){ht(this,"provider");ht(this,"store");ht(this,"globalEvents");ht(this,"state");ht(this,"connected",!1);ht(this,"allowSkipVirtualAgent",!1);ht(this,"inEscalation",!1);ht(this,"events");ht(this,"cachedFiles");this.state=t,this.store=new CT,this.cachedFiles={},this.events=new em;const n=BO(this.state.provider_type);this.provider=new n(this.events,t,r)}_setGlobalEvents(t,r){this.globalEvents=t,this.on("message",n=>{if(n.content=ST(n.content),n.type==="server_message"){const i=n.message_id;r(this.id,i).then(a=>{n=NO(n,a),t.triggerEvent("chat.message",n)})}else n.type==="photo"||n.type==="video"?setTimeout(()=>{const i=n.$index.toString();n.file=this.cachedFiles[i],t.triggerEvent("chat.message",n)},100):(t.triggerEvent("chat.message",n),this.registerMessageEvents(n))}),this.on("memberJoined",n=>{t.triggerEvent("chat.memberJoined",n)}),this.on("memberLeft",n=>{t.triggerEvent("chat.memberLeft",n)}),this.on("typingStarted",n=>{t.triggerEvent("chat.typingStarted",n)}),this.on("typingEnded",n=>{t.triggerEvent("chat.typingEnded",n)})}get id(){var t;return((t=this.state)==null?void 0:t.id)||-1}get menuId(){return this.state?this.state.menus[this.state.menus.length-1].id:-1}get channelId(){var t;return((t=this.state)==null?void 0:t.provider_channel_id)||""}get lang(){var t;return((t=this.state)==null?void 0:t.lang)||""}get virtual(){return qO.indexOf(this.status)!==-1}get muted(){var t;return((t=this.provider)==null?void 0:t.muted)||!1}set muted(t){this.provider&&(this.provider.muted=t)}get agent(){return this.state?this.virtual?this.state.external_agent||this.state.virtual_agent:this.state.agent||this.state.virtual_agent:null}get allAgents(){var t,r;return{virtual:((t=this.state)==null?void 0:t.all_virtual_agents)||[],human:((r=this.state)==null?void 0:r.all_agents)||[]}}get userIdentity(){var t;return((t=this.provider)==null?void 0:t.identity)||""}get status(){var t;return((t=this.state)==null?void 0:t.status)||""}get postSessionStatus(){var t;return((t=this.state)==null?void 0:t.post_session_transfer_status)||""}get statusText(){var t;return((t=this.state)==null?void 0:t.status_text)||""}get cobrowsable(){return this.state?this.state.features.indexOf("cobrowse")!==-1:!1}get ongoing(){return zO.indexOf(this.status)!=-1}get assigned(){return RT.indexOf(this.status)!=-1}get dismissed(){return $T.indexOf(this.status)!=-1}get ended(){return WO.indexOf(this.status)!=-1}get transcriptCount(){var t;return((t=this.state)==null?void 0:t.transcript_requested_count)||0}get createdAt(){var t;return((t=this.state)==null?void 0:t.created_at)||""}get inTask(){var t;return((t=this.provider)==null?void 0:t.inTask)||!1}get feedbackType(){var t;return this.state?this.state.survey_enabled?"survey":(t=this.state.csat_settings)!=null&&t.enabled?"rate":"none":"none"}get optInRequired(){var t;return((t=this.state)==null?void 0:t.post_session_opt_in_required)||!1}get postSessionRequired(){var t;return((t=this.state)==null?void 0:t.post_session_required)||!1}get postSessionInProgress(){return this.state?this.state.post_session_transfer_status===to.IN_PROGRESS:!1}update(t){if(!this.state||this.state.id!==t.id)return;const r=t.menus[t.menus.length-1].id,n=this.state.menus[this.state.menus.length-1].id;this.state=t,r!==n&&this.triggerEvent("_menuChanged",this),t.status==="canceled"?this.triggerEvent("ended",this):this.triggerEvent("updated",this)}on(t,r){this.events.addEventListener(t,r)}off(t,r){this.events.removeEventListener(t,r)}async connect(){if(!this.provider)return cd.info("connecting interrupted"),!1;try{await ly(()=>this.provider.create(),3),await ly(()=>this.provider.join(this.state.provider_channel_id),3),this.connected=!0;const t=await this.fetchMessages(),r={chat:this,messages:t};return this.triggerEvent("connectedMessages",r),this.triggerEvent("connected",this),this.registerProviderEvents(),cd.info("connected with provider",this.state.provider_type),!0}catch{return!1}}async disconnect(){this.connected=!1,this.triggerEvent("disconnected",this),this.events.destroy(),this.provider&&(await this.provider.destroy(),cd.info("disconnect with provider",this.state.provider_type))}async sendMessage(t,r){const n=await this.provider.sendMessage(t);return r&&this.saveMedia(n,r),n}preview(t){if(!this.inTask)return this.provider.preview(t)}async fetchMessages(){if(this.connected){const t=await this.store.getAllFiles();return this.provider.fetchMessages(t)}else throw new Error("Please fetchMessages after chat connected.")}startTyping(){return this.provider.startTyping()}stopTyping(){return this.provider.stopTyping()}saveMedia(t,r){this.cachedFiles[t.toString()]=r,this.store.save(t,r)}async destroy(){await this.clearMediaStore(),this.connected&&await this.disconnect(),this.provider&&(this.triggerEvent("destroyed"),this.provider=null),this.events.destroy(),this.state=null}async clearMediaStore(){await this.store.clear()}_handleChatEndedEvent(t){this.disconnect(),this.state&&(t.timeout?(this.state.status="timeout",this.triggerEvent("timeout",this)):(this.state.status="finished",this.triggerEvent("ended",this)))}triggerEvent(t,r){this.events.triggerEvent(t,r),this.globalEvents&&this.globalEvents.triggerEvent("chat."+t,r)}registerProviderEvents(){this.provider&&this.provider.registerConversationEvents()}registerMessageEvents(t){t.event==="cobrowseRequestedFromAgent"?this.events.triggerEvent("_requestCobrowse","agent"):t.event==="cobrowseRequestedFromEndUser"?this.events.triggerEvent("_requestCobrowse","end_user"):t.event==="chatDismissed"&&this.state?(this.state.status="dismissed",this.triggerEvent("dismissed",this)):t.event==="chatEnded"?this.events.triggerEvent("_chatEnded",t):t.event==="escalationStarted"?this.inEscalation=!0:(t.event==="escalationFailed"||t.event==="escalationAccepted")&&(this.inEscalation=!1)}}function IT(e){return e.map(HO).filter(t=>t.enabled)}function HO(e){const t={id:e.id,enabled:!0,channels:[],hidden:!!e.hidden};if(!e.name||!e.name.trim())return t.enabled=!1,t;t.name=e.name.trim();const r=VO(e);if(r&&(t.redirection=e.redirection),e.children&&e.children.length){const n=IT(e.children);return t.enabled=n.length>0||r,t.children=n,t}if(!e.channels)t.enabled=r;else{const{channels:n,deflection:i}=KO(e.channels);t.deflection=i,r||(t.channels=n),t.enabled=n.length>0||r}return t}function VO(e){let t=!1;const r=e.redirection;return r&&(r.option==="message"||r.option==="url")&&(t=!!r.data),t}function KO(e){let t=null;const r=[],n=e.chat,i=a=>{!a.deflection_type&&a.deflected_reason&&(a.deflection_type=a.deflected_reason),a.deflected===void 0&&a.deflection_type&&(a.deflected=!0),r.push(a)};return n&&n.deflected&&(t={enabled:!0,type:n.deflected_reason}),n&&(n.enabled||n.virtual_agent_available)&&i({...e.chat,type:"chat"}),e.voice_call&&e.voice_call.instant_enabled&&i({...e.voice_call,type:"instant_call"}),e.voice_call&&e.voice_call.schedule_enabled&&i({...e.voice_call,type:"scheduled_call",deflection_type:e.voice_call.schedule_deflection_type}),e.email&&e.email.enabled&&i({...e.email,type:"email"}),n&&n.deflected&&n.deflected_reason==="over_capacity"&&n.keep_waiting&&i({...n,enabled:!0,type:"keep_waiting",deflection_type:n.deflected_reason}),e.external_deflection_link&&e.external_deflection_link.enabled&&e.external_deflection_link.links.forEach(s=>{s.enabled&&i({...s,type:"external_link"})}),{channels:r,deflection:t}}const JO={en:"English (US)","en-CA":"English (Canada)","en-GB":"English (UK)",es:"Español (España)","es-MX":"Español (México)",fr:"Français (France)","fr-CA":"Français (Canada)",de:"Deutsch",ja:"日本語",ko:"한국어",it:"Italiano",zh:"中文 (简体)","zh-Hant":"中文 (繁體)",sv:"Svenska",pt:"Português (Portugal)","pt-BR":"Português (Brasil)",fi:"Suomi",nb:"Norsk",da:"Dansk",nl:"Nederlands",tr:"Türk",vi:"Tiếng Việt",th:"คนไทย",ar:"اَلْعَرَبِيَّةُ",cs:"Czech",pl:"Polish",hu:"Hungarian"};function YO(e){var r,n;return{languages:e.languages.filter(i=>i.enabled).map(i=>({lang:i.lang,name:i.name,localeName:JO[i.lang]})),name:e.display_name,subdomain:e.subdomain,support_email:e.support_email,action_tracking:e.action_tracking_enabled,email_transcripts:e.chat_settings.email_transcripts,message_preview:e.chat_settings.message_preview,email_enhancement:e.email_enhancement_enabled,display_history:((r=e.chat_settings.display_history)==null?void 0:r.enabled)&&((n=e.chat_settings.display_history)==null?void 0:n.to_end_user),use_recording:e.use_recording,use_web:e.use_web,cobrowse_domain:e.cobrowse_domain}}function gy(e){return e.chats=e.chats.map(t=>{const r=t.entries.map((n,i)=>XO(n,`${t.comm_id}-${i}`));return t.entries=LO(r),t}),e}function XO(e,t){var r;return{$index:e.timestamp,$sid:t,$timestamp:new Date(e.timestamp),$userType:e.role,$userId:((r=e.user_data)==null?void 0:r.id)||0,user:e.user_data,type:e.type,...e.body}}const yy=/Chrome/.test(navigator.userAgent);class QO{constructor(t){ht(this,"request");this.request=t}get(t,r){if(r){const n=[];Object.keys(r).forEach(i=>{const a=r[i];a!==void 0&&n.push(`${encodeURIComponent(i)}=${encodeURIComponent(a)}`)}),t+="?"+n.join("&")}return this.request(t,{method:"GET"})}post(t,r){const n={method:"POST"};return n.body=JSON.stringify(r),this.request(t,n)}patch(t,r){const n={method:"PATCH"};return n.body=JSON.stringify(r),this.request(t,n)}put(t,r){const n={method:"PUT"};return n.body=JSON.stringify(r),this.request(t,n)}async getTriggers(t){const r={"UJET-Company-Id":t};return(await this.request("proactive_chat_triggers",{method:"GET",headers:r})).data}trackClientEvents(t){return this.post("/client_events",{events:t})}async getCompany(){const t=await this.get("company");return YO(t.data)}async getMenus(t,r){const n={type:"web_menu",lang:t,direct_access_key:r},i=await this.get("menus",n),a={key:!!r,user:!1},s=i.headers["ujet-direct-access"];return s&&s!="false"&&(a.user=!0),{menus:IT(i.data),direct:a}}async getAfterHourMessage(t){return(await this.get(`audible_messages/${t}`)).data["after_hours.message"].text}async getTimeSlots(t,r="en"){return(await this.get(`menus/${t}/time_slots`,{type:"web_menu",lang:r})).data}async getWaitTimes(t,r="en"){return(await this.get(`menus/${t}/wait_times`,{type:"web_menu",lang:r})).data}async verifyForm(t){try{return await this.post("forms/verify",t),!0}catch{return!1}}async finishChat(t){return(await this.patch(`chats/${t}`,{status:"finished"})).data}async updatePostSession(t,r){const n={post_session_transfer_status:r};try{return(await this.patch(`chats/${t}`,n)).data}catch(i){if(r===to.IN_PROGRESS&&i.status===400)return(await this.patch(`chats/${t}`,n)).data;throw i}}async getChatDeflection(t){const{data:r}=await this.get(`chats/${t}/deflections`);return r&&r.enabled?r:null}sendChatCustomData(t,r){let n;return typeof r=="string"?n={signed:!0,signed_data:r}:n={signed:!1,data:r},this.post(`chats/${t}/custom_data`,n)}async downloadChatTranscript(t){return(await this.post(`chats/${t}/generate_transcript_pdf`,{})).data}async getPdfStatus(t){return await this.get(`chat_transcript_pdfs/${t}/download_transcript`)}sendChatTranscripts(t,r){return this.post(`chats/${t}/transcripts`,{emails:r.join(",")})}async listChatTaskMessages(t){return(await this.get(`chats/${t}/task_va_messages`)).data}async getChatTaskMessage(t,r){return(await this.get(`chats/${t}/task_va_messages/${r}`)).data}async sendChatTaskMessage(t,r){const n={content:{content:r,type:"text"}};return(await this.post(`chats/${t}/task_va_messages`,n)).data}async sendChatTextMessage(t,r){const n={message:{content:r,timestamp:new Date().toISOString()}};await this.post(`chats/${t}/messages`,n)}async sendPreviewMessage(t,r,n){const i={message:{content:r,timestamp:n}},{data:a}=await this.post(`chats/${t}/redact_messages`,i);return a}escalateChat(t,r){return this.post(`chats/${t}/escalations`,r)}trackEscalation(t,r,n){return this.put(`chats/${t}/escalations/${r}`,{escalation_id:r,deflection_channel:n})}requestChatCobrowse(t,r){return this.post(`chats/${t}/cobrowse`,r)}rateChat(t,r){return this.patch(`chats/${t}/rating`,r)}async getChatSurvey(t){return(await this.get(`chats/${t}/survey`)).data}sendChatSurvey(t,r){const n={chat_id:t,answers:r};return this.put(`chats/${t}/survey`,n)}trackChatEndUserEvent(t,r){return this.post(`chats/${t}/end_user_event`,r)}async createChat(t,r,n,i){const a={chat:{menu_id:t,lang:r,email:n.email,greeting:n.greeting,trigger_id:n.trigger_id,ticket_id:n==null?void 0:n.ticket_id,custom_data:n==null?void 0:n.custom_data},cobrowsable:n.cobrowsable},o=(await this.post("chats",a)).data;return this.wrapChat(o,i)}async loadChat(t,r){const n=await this.getChat(t);return this.wrapChat(n,r)}async resumeChat(t,r){const n=await this.patch(`chats/${t}`,{status:"queued"});return this.wrapChat(n.data,r)}async getChatHistory(t=1){if(t===1){const{data:r}=await this.get("/chats/histories?page=1&per_page=2");return gy(r)}else{const{data:r}=await this.get(`/chats/histories?page=${t}&per_page=1`);return gy(r)}}async uploadChatFile(t,r){let n="file";/^image/.test(r.type)?n="photo":/^video/.test(r.type)?n="video":n="file";const i=r.name.replace(/\.[^.]+$/i,""),a=await this.post(`chats/${t}/${n}s/upload`,{filename:i}),s={file:r,fields:a.data.fields};yy&&(s.file=await OT(r));const u=(await this.request(a.data.url,s)).data.key,l=(await this.post(`chats/${t}/${n}s`,{chat_id:t,[n]:{s3_path:u,photo_type:n}})).data;return l.type=n,l}async getChat(t){return(await this.get(`chats/${t}`)).data}async wrapChat(t,r){const n=async()=>(await this.post(`chats/${t.id}/tokens`,{provider_type:t.provider_type,device_id:r})).data,i=new GO(t,n),a=async s=>{if(i.status==="va_assigned"){const o=await this.getSkipVirtualAgentSettings(i.menuId,i.lang);i.allowSkipVirtualAgent=o,i.update(s)}};if(i.channelId)i.connect(),a(t);else{let s;for(;!s;)await this.getChat(i.id).then(o=>{o.provider_channel_id&&i.state?(s=!0,i.update(o),i.connect(),a(o)):(o.status==="canceled"||o.status==="finished")&&(s=!0)}),s||await wT(1500)}return i.on("initialized",async()=>{if(i.status==="queued"){const s=await this.getChat(i.id);i.update(s)}}),i.on("memberJoined",async()=>{const s=await this.getChat(i.id);i.update(s)}),i.on("memberLeft",async()=>{const s=await this.getChat(i.id);i.update(s)}),i.on("_chatEnded",async s=>{const o=await this.getChat(i.id);i.update(o),(!i.state||i.ended)&&i._handleChatEndedEvent(s)}),i.on("_menuChanged",async s=>{const o=await this.getChat(s.id);a(o)}),i}async createCall(t,r,n){const i={type:n.scheduled_at?"web_scheduled_call":"web_instant_call",menu_id:t,lang:r,email:n.email,ticket_id:n.ticket_id,recording_permission:n.recording_permission||"recording_permission_not_asked",scheduled_at:n.scheduled_at,custom_data:n.custom_data,end_user:{phone_number:n.phone_number}},s=(await this.post("calls",{call:i,cobrowsable:!1})).data;return s.menu_id=s.selected_menu.id,s}async fetchCall(t){const n=(await this.get(`calls/${t}`)).data;return n.menu_id=n.selected_menu.id,n}async cancelCall(t){const n=(await this.patch(`calls/${t}`,{status:"failed",fail_reason:"canceled"})).data;return n.menu_id=n.selected_menu.id,n}async listFileTypes(){return(await this.get("email_prohibited_file_types")).data}async createEmail(t,r,n){const i={end_user_email:n.email,email_body:n.content,menu_id:t.toString(),lang:r};return n.name&&(i.end_user_name=n.name),n.recaptcha&&(i.recaptcha_response=n.recaptcha),n.files&&yy?i["email_attachments[]"]=await ZO(n.files):n.files&&(i["email_attachments[]"]=[...n.files]),this.request("emails",{form:i})}async getMedia(t,r){const n=await this.get(`media/${t}?type=${r}`);if(!n.data)return null;const i=n.headers["x-file-name"];return new File([n.data],i,{type:n.data.type})}async getSkipVirtualAgentSettings(t,r){return(await this.get(`menus/${t}/virtual_agent_settings`,{lang:r})).data.allow_skip_virtual_agent}}function ZO(e){return Promise.all(e.map(OT))}function OT(e){return new Promise((t,r)=>{const n=new FileReader;n.onload=()=>{const i=[n.result],a={type:e.type,lastModified:e.lastModified};t({name:e.name,fileBits:i,options:a})},n.onerror=r,n.readAsArrayBuffer(e)})}const ld="ujet:",Kr={set(e,t){return localStorage.setItem(ld+e,t)},get(e){return localStorage.getItem(ld+e)},del(e){return localStorage.removeItem(ld+e)}},eA=Date.now(),AT={href:window.location.href,interval:24*60*60};function tA(e){if(!Array.isArray(e)||!e.length)return null;const t=sA(),r=t===0,n=t+1;return oA(n),e.filter(a=>{const s=nA(a,AT.href),o=iA(a.visitor_type,r),u=n>=a.page_visit_count,c=!aA(a.id);return s&&o&&u&&c}).sort((a,s)=>a.stay_time-s.stay_time)[0]||null}function rA(e,t){const r=e.stay_time*1e3,n=Math.max(r-(Date.now()-eA),0);setTimeout(()=>{t(e),Kr.set(`trigger:${e.id}`,(Date.now()/1e3).toString())},n)}const nA=(e,t)=>{const{keywords_included_or:r=[],keywords_excluded_or:n=[],keywords_included:i=[],keywords_excluded:a=[]}=e;if(EO(r,n,i,a))return!0;if(r.length||n.length){const u=r.some(l=>l.every(p=>t.includes(p))),c=n.length>0&&n.every(l=>l.every(p=>!t.includes(p)));return u||c}const s=i.filter(u=>t.indexOf(u)!==-1).length,o=a.filter(u=>t.indexOf(u)===-1).length;return!!s||!!o};function iA(e,t){return e==="visitor_type_new"?t:e==="visitor_type_returning"?!t:!0}function aA(e){try{const t=parseInt(Kr.get(`trigger:${e}`),10);return Date.now()/1e3-t<AT.interval}catch{return!1}}function sA(){try{const e=Kr.get("visits");return e?parseInt(e,10):0}catch{return 0}}function oA(e){try{Kr.set("visits",e.toString())}catch(t){console.error(t)}}/*!
3
3
  * tabbable 6.2.0
4
4
  * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
5
5
  */var PT=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],Al=PT.join(","),MT=typeof Element>"u",as=MT?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Pl=!MT&&Element.prototype.getRootNode?function(e){var t;return e==null||(t=e.getRootNode)===null||t===void 0?void 0:t.call(e)}:function(e){return e==null?void 0:e.ownerDocument},Ml=function e(t,r){var n;r===void 0&&(r=!0);var i=t==null||(n=t.getAttribute)===null||n===void 0?void 0:n.call(t,"inert"),a=i===""||i==="true",s=a||r&&t&&e(t.parentNode);return s},uA=function(t){var r,n=t==null||(r=t.getAttribute)===null||r===void 0?void 0:r.call(t,"contenteditable");return n===""||n==="true"},xT=function(t,r,n){if(Ml(t))return[];var i=Array.prototype.slice.apply(t.querySelectorAll(Al));return r&&as.call(t,Al)&&i.unshift(t),i=i.filter(n),i},NT=function e(t,r,n){for(var i=[],a=Array.from(t);a.length;){var s=a.shift();if(!Ml(s,!1))if(s.tagName==="SLOT"){var o=s.assignedElements(),u=o.length?o:s.children,c=e(u,!0,n);n.flatten?i.push.apply(i,c):i.push({scopeParent:s,candidates:c})}else{var l=as.call(s,Al);l&&n.filter(s)&&(r||!t.includes(s))&&i.push(s);var p=s.shadowRoot||typeof n.getShadowRoot=="function"&&n.getShadowRoot(s),v=!Ml(p,!1)&&(!n.shadowRootFilter||n.shadowRootFilter(s));if(p&&v){var m=e(p===!0?s.children:p.children,!0,n);n.flatten?i.push.apply(i,m):i.push({scopeParent:s,candidates:m})}else a.unshift.apply(a,s.children)}}return i},LT=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},Za=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||uA(t))&&!LT(t)?0:t.tabIndex},cA=function(t,r){var n=Za(t);return n<0&&r&&!LT(t)?0:n},lA=function(t,r){return t.tabIndex===r.tabIndex?t.documentOrder-r.documentOrder:t.tabIndex-r.tabIndex},DT=function(t){return t.tagName==="INPUT"},fA=function(t){return DT(t)&&t.type==="hidden"},dA=function(t){var r=t.tagName==="DETAILS"&&Array.prototype.slice.apply(t.children).some(function(n){return n.tagName==="SUMMARY"});return r},pA=function(t,r){for(var n=0;n<t.length;n++)if(t[n].checked&&t[n].form===r)return t[n]},hA=function(t){if(!t.name)return!0;var r=t.form||Pl(t),n=function(o){return r.querySelectorAll('input[type="radio"][name="'+o+'"]')},i;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")i=n(window.CSS.escape(t.name));else try{i=n(t.name)}catch(s){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",s.message),!1}var a=pA(i,t.form);return!a||a===t},vA=function(t){return DT(t)&&t.type==="radio"},mA=function(t){return vA(t)&&!hA(t)},gA=function(t){var r,n=t&&Pl(t),i=(r=n)===null||r===void 0?void 0:r.host,a=!1;if(n&&n!==t){var s,o,u;for(a=!!((s=i)!==null&&s!==void 0&&(o=s.ownerDocument)!==null&&o!==void 0&&o.contains(i)||t!=null&&(u=t.ownerDocument)!==null&&u!==void 0&&u.contains(t));!a&&i;){var c,l,p;n=Pl(i),i=(c=n)===null||c===void 0?void 0:c.host,a=!!((l=i)!==null&&l!==void 0&&(p=l.ownerDocument)!==null&&p!==void 0&&p.contains(i))}}return a},by=function(t){var r=t.getBoundingClientRect(),n=r.width,i=r.height;return n===0&&i===0},yA=function(t,r){var n=r.displayCheck,i=r.getShadowRoot;if(getComputedStyle(t).visibility==="hidden")return!0;var a=as.call(t,"details>summary:first-of-type"),s=a?t.parentElement:t;if(as.call(s,"details:not([open]) *"))return!0;if(!n||n==="full"||n==="legacy-full"){if(typeof i=="function"){for(var o=t;t;){var u=t.parentElement,c=Pl(t);if(u&&!u.shadowRoot&&i(u)===!0)return by(t);t.assignedSlot?t=t.assignedSlot:!u&&c!==t.ownerDocument?t=c.host:t=u}t=o}if(gA(t))return!t.getClientRects().length;if(n!=="legacy-full")return!0}else if(n==="non-zero-area")return by(t);return!1},bA=function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var r=t.parentElement;r;){if(r.tagName==="FIELDSET"&&r.disabled){for(var n=0;n<r.children.length;n++){var i=r.children.item(n);if(i.tagName==="LEGEND")return as.call(r,"fieldset[disabled] *")?!0:!i.contains(t)}return!0}r=r.parentElement}return!1},xl=function(t,r){return!(r.disabled||Ml(r)||fA(r)||yA(r,t)||dA(r)||bA(r))},mh=function(t,r){return!(mA(r)||Za(r)<0||!xl(t,r))},_A=function(t){var r=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(r)||r>=0)},wA=function e(t){var r=[],n=[];return t.forEach(function(i,a){var s=!!i.scopeParent,o=s?i.scopeParent:i,u=cA(o,s),c=s?e(i.candidates):o;u===0?s?r.push.apply(r,c):r.push(o):n.push({documentOrder:a,tabIndex:u,item:i,isScope:s,content:c})}),n.sort(lA).reduce(function(i,a){return a.isScope?i.push.apply(i,a.content):i.push(a.content),i},[]).concat(r)},SA=function(t,r){r=r||{};var n;return r.getShadowRoot?n=NT([t],r.includeContainer,{filter:mh.bind(null,r),flatten:!1,getShadowRoot:r.getShadowRoot,shadowRootFilter:_A}):n=xT(t,r.includeContainer,mh.bind(null,r)),wA(n)},TA=function(t,r){r=r||{};var n;return r.getShadowRoot?n=NT([t],r.includeContainer,{filter:xl.bind(null,r),flatten:!0,getShadowRoot:r.getShadowRoot}):n=xT(t,r.includeContainer,xl.bind(null,r)),n},Es=function(t,r){if(r=r||{},!t)throw new Error("No node provided");return as.call(t,Al)===!1?!1:mh(r,t)},CA=PT.concat("iframe").join(","),fd=function(t,r){if(r=r||{},!t)throw new Error("No node provided");return as.call(t,CA)===!1?!1:xl(r,t)};/*!
package/dist/index.mjs CHANGED
@@ -18,7 +18,7 @@ function VI(e, t) {
18
18
  return Object.freeze(Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }));
19
19
  }
20
20
  var lu = /* @__PURE__ */ ((e) => (e.WAITING = "waiting", e.READY = "ready", e.IN_PROGRESS = "in_progress", e.FINISHED = "finished", e))(lu || {});
21
- const Ite = "prod", pT = "3.37.2", Xg = "https://main.api.ujet.co", Kr = {
21
+ const Ite = "prod", pT = "3.37.4", Xg = "https://main.api.ujet.co", Kr = {
22
22
  companyId: "",
23
23
  tenant: "",
24
24
  trackerId: "",
@@ -845,7 +845,7 @@ function OO(e) {
845
845
  cobrowse: n,
846
846
  companyId: e.companyId,
847
847
  location: location.href,
848
- version: e.version || "3.37.2",
848
+ version: e.version || "3.37.4",
849
849
  bridge: i
850
850
  };
851
851
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ujet/websdk-headless",
3
- "version": "3.37.2",
3
+ "version": "3.37.4",
4
4
  "types": "dist/index.d.ts",
5
5
  "files": [
6
6
  "dist/index.mjs",