import{c as e,C as t,a as n,b as r,O as i,i as a,j as s,P as o,B as l,Q as c,f as u,d,k as p,L as g,R as h,J as m,S as f,U as _,z as b,V as v,X as y,x as w,Y as k,Z as x,u as I,y as S,$ as E,A,t as T,N as C,e as z,E as D}from"./7.DaJJFJ3Z.chunk.js";import{k as $,i as M,h as F,s as P,f as R,n as O,g as B,r as j,j as q,l as U,c as N}from"./3.CJvEkDRx.chunk.js";import{a as L,c as V,p as G,b as Z,f as H,d as W,u as Q,k as Y,t as J,s as X,F as K,o as ee,m as te,e as ne,h as re,_ as ie,H as ae,j as se,i as oe,q as le,l as ce,v as ue}from"./2.pu7iWzia.chunk.js";function de(e,t){return t=t||{},new Promise(function(n,r){var i=new XMLHttpRequest,a=[],s=[],o={},l=function(){return{ok:2==(i.status/100|0),statusText:i.statusText,status:i.status,url:i.responseURL,text:function(){return Promise.resolve(i.responseText)},json:function(){return Promise.resolve(i.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([i.response]))},clone:l,headers:{keys:function(){return a},entries:function(){return s},get:function(e){return o[e.toLowerCase()]},has:function(e){return e.toLowerCase()in o}}}};for(var c in i.open(t.method||"get",e,!0),i.onload=function(){i.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,function(e,t,n){a.push(t=t.toLowerCase()),s.push([t,n]),o[t]=o[t]?o[t]+","+n:n}),n(l())},i.onerror=r,i.withCredentials="include"==t.credentials,t.headers)i.setRequestHeader(c,t.headers[c]);i.send(t.body||null)})}function pe(e,t){return[].concat(...t.map(e))}function ge(e,t){return $(t).reduce((n,r)=>(n[r]=e(t[r]),n),{})}function he(e){let t=e.trim();if(0===t.length)return"";if(1===t.length)return t.toLowerCase();if(/^[a-z\d]+$/.test(t))return t;return t!==t.toLowerCase()&&(t=function(e){let t=e,n=!1,r=!1,i=!1;for(let a=0;at.toUpperCase()),t}function me(e){return M(e)?e:[e]}function fe(e){return $(e).map(t=>[t,e[t]])}function _e(e,t){for(let n=t.length-1;n>=0;n--)if(e(t[n]))return t[n]}function be(e,t,n){for(let r=t;r>=0;r--)if(e(n[r]))return r;return-1}function ve(e,t){return be(e,t.length-1,t)}function ye(e,t){if(e<=0)return[];const n=[];for(;e--;)n.push(t);return n}function we(t){const n=e();return F(n,t)?we(t):n}function ke(e,t){const n="string"==typeof e?e.split("."):e;let r=0,i=t;for(;i&&r(t[n[e]]=n,t),{})}function Ie(e){return e.length>0?e[e.length-1]:void 0}function Se(e,t){return $(t).reduce((n,r)=>(Object.defineProperty(n,e(r),{value:t[r],enumerable:!0}),n),{})}function Ee(e){return $(e).map(t=>e[t])}function Ae(e,t){const n="function"==typeof e?e:t=>ke(e,t);return(M(t)?[...t]:Ee(t)).sort((e,t)=>n(e)-n(t))}function Te(e,n){return t((t,n)=>-1!==e.indexOf(n),n)}function Ce(e,t){return e.reduce((e,n)=>(e[n]=t[n],e),{})}function ze(e,t){return e.reduce((e,n)=>(F(n,t)&&(e[n]=t[n]),e),{})}function De(e,t){return t.filter(t=>!e(t))}function $e(e,t){return e===t?0!==e||0!==t||1/e==1/t:e!=e&&t!=t}function Me(e,t){if($e(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let i=0;ie)break;i+=a.length+1,r.push(a)}return 0===r.length?`${t.slice(0,e)}...`:`${r.join(" ")}...`}function Pe(e,t,n){const r=be(t=>!e(t),t,n);return r===t?[]:n.slice(r+1,t+1)}function Re(e){return $(e).map(t=>[t,e[t]])}function Oe(e,t){return e===t?0:e{const r=e(t);return-1===n.indexOf(r)&&(n.push(r),!0)})}function je(e,t,n){return[...n.slice(0,e),t,...n.slice(e+1,n.length)]}function qe(e){return void 0===e&&(e=-1),function(t){return function(n,r){if(0===n){var i,a=!1,s=e,o=function(e,t){i(e,t)};!function e(){t(0,function(t,n){return 0===t?(i=n,a?void o(1):(a=!0,void r(0,o))):2===t&&n&&0!==s?(s--,void e()):void r(t,n)})}()}}}}const Ue={},Ne=e=>t=>(n,r)=>{if(0!==n)return;let i,a,s=!1,o=Ue;t(0,(t,n)=>{if(0===t)return i=n,e(0,(e,t)=>0===e?(a=t,void a(1)):1===e?(o=void 0,a(2),i(2),void(s&&r(2))):void(2===e&&(a=null,t&&(o=t,i(2),s&&r(e,t))))),s=!0,r(0,(e,t)=>{o===Ue&&(2===e&&a&&a(2),i(e,t))}),void(o!==Ue&&r(2,o));2===t&&a(2),r(t,n)})};function Le(){const e=P();return[e,()=>{const t=new Error("Destroyed.");t.code="DESTROYED",e(2,t)}]}function Ve(){const e={};return e.promise=new Promise((t,n)=>{e.resolve=t,e.reject=n}),e}const Ge=e();let Ze=0;const He=e=>{const t=document.createElement("a");if(t.href=e,t.origin)return"null"===t.origin?"*":t.origin;const n=t.protocol.length>4?t.protocol:window.location.protocol;let r;return r=t.host.length?"80"===t.port||"443"===t.port?t.hostname:t.host:window.location.host,`${n}//${r}`};function We(e,t){let{frame:n,targetOrigin:r=He(n.src),handshakeRetry:i={}}=e;void 0===t&&(t={});const[a,s]=L(t),[o,l]=Le(),c=Ze++,u=n.contentWindow,d=V(),p=(e,t)=>ie(Ge,c,e,t),g=e=>{u.postMessage(e,r)},h=G(Z(),H(e=>e.owner===Ge&&e.instance===c),Ne(o),R),m=W(d,h,p,g),f=G(Q(h,g,p(se,s),null),Y(i.interval||500),qe(i.count||5),J(1),X(e=>K in e?G(Q(h,g,p(ae)),te(()=>e.data)):ee(()=>e)),Ne(o),R),_=ne(m,d.emit,g,a);return G(f,X(()=>h),re(_)),{api:m,destroy:l,handshake$:f}}function Qe(){return new Promise(e=>{const t=()=>{document.body?e(document.body):setTimeout(t,100)};t()})}function Ye(e){const{parentNode:t}=e;t&&t.removeChild(e)}const Je=(e,t)=>{const n=document.createElement("iframe");return e.appendChild(n),n.src=t,n};function Xe(e,t){let{onConnected:n,...r}=e;const i=!r.frame,a=(e=>{if(e.frame)return e.frame;const{container:t,url:n}=e;return Je(t,n)})(r),[s,o]=Le();let l;const c=()=>{i&&Ye(a),l?l.destroy():o()};return G(ce(a,"load"),X(()=>le((e,n)=>{let i=function(e,t){const{api:n,destroy:r,handshake$:i}=We(e,t);return{destroy:r,promise:G(i,te(e=>(n.data=e,n.destroy=r,n)),oe)}}({...r,frame:a},t);return i.promise.then(e,n),l=i,i.destroy})),qe(),Ne(s),re(e=>{e.destroy=c,e.frame=a,n(e)})),{destroy:c,frame:a}}const Ke=e=>Re(e).map(e=>e.map(encodeURIComponent).join("=")).join("&"),et=/(?:[^:]+:\/\/)?([^/\s]+)/;function tt(e){const t=e.match(et);return t&&t[1]}const nt=(e,t)=>n(t)[e],rt=/^(?:https?:)?\/\/[^/]+\/([^?#]+)/,it=e=>{const t=e.match(rt);return`/${t&&t[1]||""}`},at=/^((http(s)?:)?\/\/)/,st=e=>{const t=e.match(at);return t?t[2]:null},ot=(e,t)=>{if(0===Object.keys(t).length)return e;const a=r(e),s=it(e),o=i(e)?n(e):{},l=Ke({...o,...t});return e.indexOf("#")>-1?`${a}${s}?${l}#${e.split("#")[1]}`:`${a}${s}?${l}`},lt=(e,t)=>{if(-1===e.indexOf("?"))return e;const r=n(e);if(a(r))return e;if(Object.keys(r).every(e=>!t.includes(e)))return e;t.forEach(e=>delete r[e]);const[i]=e.split("?"),s=ot(i,r);return e.indexOf("#")>-1?`${s}#${e.split("#")[1]}`:s};function ct(){return ct=Object.assign?Object.assign.bind():function(e){for(var t=1;tn)throw new Error(e+" can not be empty and can only be "+n+" characters long.")},mt=function(e){if("string"!=typeof(e=gt(e)))throw new Error("`text` must be a string or a number.");e=e.trim(),ht("`text`",e,pt)},ft=function(e,t){return new Error('Attribute with key "'+e+'" is invalid. '+t)},_t=O,bt=Object.freeze({sendMessage:function(e){var t=e.text,n=e.postback;if(mt(t),void 0!==n){if("string"!=typeof n)throw new Error("`postback` must be a string.");ht("`postback`",n,pt)}},sendSystemMessage:function(e){var t=e.text,n=e.recipients;if(mt(t),void 0!==n&&-1===dt.indexOf(n))throw new Error("`recipients` can only be one of: "+dt+".")},setAttributes:function(e){if(!e||"object"!=typeof e)throw new Error("`attributes` must be a plain object (with shape such as `{ key: 'value' }`).");var t=Object.keys(e);if(t.length>99)throw new Error("The maximum number of attributes is 99.");t.forEach(function(t){var n=gt(e[t]);if(t=gt(t),!/^[\w-]{1,128}$/.test(t))throw ft(t,"Key must be between 1-128 characters long and can only contain alpha-numeric, underscore and dash characters.");if("string"!=typeof n)throw ft(t,"Value must be a string or a number.");ht("Value",n,1024)})},setExternalLink:function(e){if("string"==typeof e){if(!/^https:\/\//.test(e))throw new Error("`externalLink` has to be a HTTPS URL.")}else if(null!==e)throw new Error("`externalLink` has to be a string or null.")},setIsFragile:function(e){if("boolean"!=typeof e)throw new Error("`setIsFragile` argument value can not be empty and must be a boolean.")},getIdentityTransferToken:function(){},updateCustomerData:function(e){if(!e)throw new Error("`updateUserData` arguments values can not be empty.");if(e.email&&"string"!=typeof e.email)throw new Error("`updateUserData` argument `email` has to be a string.");if(e.name&&"string"!=typeof e.name)throw new Error("`updateUserData` argument `name` has to be a string.")},sendPostback:function(e){if(!e||"object"!=typeof e)throw new Error("`postback` must be a plain object.");if("string"!=typeof e.id)throw new Error("`postback.id` has to be a string.");if(ht("`postback.id`",e.id,pt),void 0!==e.type&&"string"!=typeof e.type)throw new Error("`postback.type` has to be a string.");if("string"==typeof e.type&&ht("`postback.type`",e.type,pt),void 0!==e.toggled&&"boolean"!=typeof e.toggled)throw new Error("`postback.toggled` must be a boolean.");if(void 0!==e.ecommerce){if("object"!=typeof e.ecommerce||null===e.ecommerce)throw new Error("`postback.ecommerce` must be a plain object.");if(void 0!==e.ecommerce.optionId&&"string"!=typeof e.ecommerce.optionId)throw new Error("`postback.ecommerce.optionId` must be a string.");if("string"==typeof e.ecommerce.optionId&&ht("`postback.ecommerce.optionId`",e.ecommerce.optionId,pt),void 0!==e.ecommerce.productId&&"string"!=typeof e.ecommerce.productId)throw new Error("`postback.ecommerce.productId` must be a string.");if("string"==typeof e.ecommerce.productId&&ht("`postback.ecommerce.productId`",e.ecommerce.productId,pt),void 0!==e.ecommerce.quantity&&"number"!=typeof e.ecommerce.quantity)throw new Error("`postback.ecommerce.quantity` must be a number.")}},close:_t,setTitle:function(e){if("string"!=typeof e)throw new Error("`setTitle` argument value has to be a string.");ht("`title`",e,1024)}}),vt=function(e){var t=r(e);if(!/chatbot\.com$/.test(t))return e;var n=s(o(i(e)));if(!n.p)return e;try{var a=JSON.parse(atob(n.p));return a.url?decodeURIComponent(a.url):e}catch(l){return e}};function yt(e,t){var n,r=vt(e.url),i=ue(function(e){return"function"==typeof e},t),a=i[0],s=i[1],o=l(function(e,t){return function(){return bt[t].apply(bt,arguments),e.apply(void 0,arguments)}},a),c=Xe(ct({},e,{targetOrigin:"*"}),ct({},s,o,{supportedMethods:Object.keys(o)})),u=c.destroy,d=c.frame;return d.sandbox=ut,{destroy:u,frame:d,title:(n=r,nt("moment-title",n)||tt(n))}}const wt=["xS94WbAZR","pJw7AxJZg"],kt=["DfltarqcrRoA5ZoZ","UsDoxZQESkzF0qds"];function xt(e){return wt.includes(e)}function It(e){return kt.includes(e)}const St=()=>"feade1d6c3f17748ae4c8d917a1e1068",Et=()=>"bb9e5b2f1ab480e4a715977b7b1b4279",At={whatsapp:"ee631a7ff555f8b6e354705201860c81",messenger:"0e655920289dbafb0376a0f4491372d9",apple:"22cc83ef7905d174b6a0eccb9ce404c0",telegram:"b0c559436b7d82f29d971faab4c6c2aa",twilio:"f14e86a88bd213b7b3717c9f76e5e823",instagram:"506038b7a51013790f6c159967b562ae"},Tt=()=>At,Ct=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,zt=/[\0-\x1F\x7F-\x9F]/,Dt=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/,$t=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/;function Mt(e){return Array.prototype.slice.call(arguments,1).forEach(function(t){t&&Object.keys(t).forEach(function(n){e[n]=t[n]})}),e}function Ft(e){return Object.prototype.toString.call(e)}function Pt(e){return"[object Function]"===Ft(e)}function Rt(e){return e.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}const Ot={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};const Bt={"http:":{validate:function(e,t,n){const r=e.slice(t);return n.re.http||(n.re.http=new RegExp(`^\\/\\/${n.re.src_auth}${n.re.src_host_port_strict}${n.re.src_path}`,"i")),n.re.http.test(r)?r.match(n.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(e,t,n){const r=e.slice(t);return n.re.no_http||(n.re.no_http=new RegExp("^"+n.re.src_auth+`(?:localhost|(?:(?:${n.re.src_domain})\\.)+${n.re.src_domain_root})`+n.re.src_port+n.re.src_host_terminator+n.re.src_path,"i")),n.re.no_http.test(r)?t>=3&&":"===e[t-3]||t>=3&&"/"===e[t-3]?0:r.match(n.re.no_http)[0].length:0}},"mailto:":{validate:function(e,t,n){const r=e.slice(t);return n.re.mailto||(n.re.mailto=new RegExp(`^${n.re.src_email_name}@${n.re.src_host_strict}`,"i")),n.re.mailto.test(r)?r.match(n.re.mailto)[0].length:0}}},jt="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function qt(e){const t=e.re=function(e){const t={};e=e||{},t.src_Any=Ct.source,t.src_Cc=zt.source,t.src_Z=$t.source,t.src_P=Dt.source,t.src_ZPCc=[t.src_Z,t.src_P,t.src_Cc].join("|"),t.src_ZCc=[t.src_Z,t.src_Cc].join("|");const n="[><|]";return t.src_pseudo_letter=`(?:(?!${n}|${t.src_ZPCc})${t.src_Any})`,t.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",t.src_auth=`(?:(?:(?!${t.src_ZCc}|[@/\\[\\]()]).){1,50}@)?`,t.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",t.src_host_terminator=`(?=$|${n}|${t.src_ZPCc})(?!${e["---"]?"-(?!--)|":"-|"}_|:\\d|\\.-|\\.(?!$|${t.src_ZPCc}))`,t.src_path=`(?:[/?#](?:(?!${t.src_ZCc}|${n}|[()[\\]{}.,"'?!\\-;]).|\\[(?:(?!${t.src_ZCc}|\\]).)*\\]|\\((?:(?!${t.src_ZCc}|[)]).)*\\)|\\{(?:(?!${t.src_ZCc}|[}]).)*\\}|\\"(?:(?!${t.src_ZCc}|["]).)+\\"|\\'(?:(?!${t.src_ZCc}|[']).)+\\'|\\'(?=${t.src_pseudo_letter}|[-])|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!${t.src_ZCc}|[.]|$)|`+(e["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+`,(?!${t.src_ZCc}|$)|;(?!${t.src_ZCc}|$)|\\!+(?!${t.src_ZCc}|[!]|$)|\\?(?!${t.src_ZCc}|[?]|$))+|\\/)?`,t.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]{0,63}',t.src_xn="xn--[a-z0-9\\-]{1,59}",t.src_domain_root="(?:"+t.src_xn+`|${t.src_pseudo_letter}{1,63})`,t.src_domain="(?:"+t.src_xn+`|(?:${t.src_pseudo_letter})|(?:${t.src_pseudo_letter}(?:-|${t.src_pseudo_letter}){0,61}${t.src_pseudo_letter}))`,t.src_host=`(?:(?:(?:(?:${t.src_domain})\\.)*${t.src_domain}))`,t.tpl_host_fuzzy="(?:"+t.src_ip4+`|(?:(?:(?:${t.src_domain})\\.)+(?:%TLDS%)))`,t.tpl_host_no_ip_fuzzy=`(?:(?:(?:${t.src_domain})\\.)+(?:%TLDS%))`,t.src_host_strict=t.src_host+t.src_host_terminator,t.tpl_host_fuzzy_strict=t.tpl_host_fuzzy+t.src_host_terminator,t.src_host_port_strict=t.src_host+t.src_port+t.src_host_terminator,t.tpl_host_port_fuzzy_strict=t.tpl_host_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_port_no_ip_fuzzy_strict=t.tpl_host_no_ip_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_fuzzy_test=`localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:${t.src_ZPCc}|>|$))`,t.tpl_email_fuzzy=`(^|${n}|"|\\(|${t.src_ZCc})(${t.src_email_name}@${t.tpl_host_fuzzy_strict})`,t.tpl_link_fuzzy=`(^|(?![.:/\\-_@])(?:[$+<=>^\`||]|${t.src_ZPCc}))((?![$+<=>^\`||])${t.tpl_host_port_fuzzy_strict}${t.src_path})`,t.tpl_link_no_ip_fuzzy=`(^|(?![.:/\\-_@])(?:[$+<=>^\`||]|${t.src_ZPCc}))((?![$+<=>^\`||])${t.tpl_host_port_no_ip_fuzzy_strict}${t.src_path})`,t}(e.__opts__),n=e.__tlds__.slice();function r(e){return e.replace("%TLDS%",t.src_tlds)}e.onCompile(),e.__tlds_replaced__||n.push("a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]"),n.push(t.src_xn),t.src_tlds=n.join("|"),t.email_fuzzy=RegExp(r(t.tpl_email_fuzzy),"i"),t.email_fuzzy_global=RegExp(r(t.tpl_email_fuzzy),"ig"),t.link_fuzzy=RegExp(r(t.tpl_link_fuzzy),"i"),t.link_fuzzy_global=RegExp(r(t.tpl_link_fuzzy),"ig"),t.link_no_ip_fuzzy=RegExp(r(t.tpl_link_no_ip_fuzzy),"i"),t.link_no_ip_fuzzy_global=RegExp(r(t.tpl_link_no_ip_fuzzy),"ig"),t.host_fuzzy_test=RegExp(r(t.tpl_host_fuzzy_test),"i");const i=[];function a(e,t){throw new Error(`(LinkifyIt) Invalid schema "${e}": ${t}`)}e.__compiled__={},Object.keys(e.__schemas__).forEach(function(t){const n=e.__schemas__[t];if(null===n)return;const r={validate:null,link:null};if(e.__compiled__[t]=r,"[object Object]"===Ft(n))return!function(e){return"[object RegExp]"===Ft(e)}(n.validate)?Pt(n.validate)?r.validate=n.validate:a(t,n):r.validate=function(e){return function(t,n){const r=t.slice(n);return e.test(r)?r.match(e)[0].length:0}}(n.validate),void(Pt(n.normalize)?r.normalize=n.normalize:n.normalize?a(t,n):r.normalize=function(e,t){t.normalize(e)});!function(e){return"[object String]"===Ft(e)}(n)?a(t,n):i.push(t)}),i.forEach(function(t){e.__compiled__[e.__schemas__[t]]&&(e.__compiled__[t].validate=e.__compiled__[e.__schemas__[t]].validate,e.__compiled__[t].normalize=e.__compiled__[e.__schemas__[t]].normalize)}),e.__compiled__[""]={validate:null,normalize:function(e,t){t.normalize(e)}};const s=Object.keys(e.__compiled__).filter(function(t){return t.length>0&&e.__compiled__[t]}).map(Rt).join("|");e.re.schema_test=RegExp(`(^|(?!_)(?:[><|]|${t.src_ZPCc}))(${s})`,"i"),e.re.schema_search=RegExp(`(^|(?!_)(?:[><|]|${t.src_ZPCc}))(${s})`,"ig"),e.re.schema_at_start=RegExp(`^${e.re.schema_search.source}`,"i"),e.re.pretest=RegExp(`(${e.re.schema_test.source})|(${e.re.host_fuzzy_test.source})|@`,"i")}function Ut(e,t,n,r){const i=e.slice(n,r);this.schema=t.toLowerCase(),this.index=n,this.lastIndex=r,this.raw=i,this.text=i,this.url=i}function Nt(e,t){if(!(this instanceof Nt))return new Nt(e,t);var n;t||(n=e,Object.keys(n||{}).reduce(function(e,t){return e||Ot.hasOwnProperty(t)},!1)&&(t=e,e={})),this.__opts__=Mt({},Ot,t),this.__schemas__=Mt({},Bt,e),this.__compiled__={},this.__tlds__=jt,this.__tlds_replaced__=!1,this.re={},qt(this)}var Lt,Vt;Nt.prototype.add=function(e,t){return this.__schemas__[e]=t,qt(this),this},Nt.prototype.set=function(e){return this.__opts__=Mt(this.__opts__,e),this},Nt.prototype.test=function(e){if(!e.length)return!1;let t,n;if(this.re.schema_test.test(e))for(n=this.re.schema_search,n.lastIndex=0;null!==(t=n.exec(e));)if(this.testSchemaAt(e,t[2],n.lastIndex))return!0;return!!(this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&e.search(this.re.host_fuzzy_test)>=0&&null!==e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))||!!(this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&e.indexOf("@")>=0&&null!==e.match(this.re.email_fuzzy))},Nt.prototype.pretest=function(e){return this.re.pretest.test(e)},Nt.prototype.testSchemaAt=function(e,t,n){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,n,this):0},Nt.prototype.match=function(e){const t=[],n=[],r=[],i=[];let a,s,o;function l(e,t){return e?t?e.index!==t.index?e.index=t.lastIndex?e:t:e:t}if(!e.length)return null;if(this.re.schema_test.test(e))for(o=this.re.schema_search,o.lastIndex=0;null!==(a=o.exec(e));)s=this.testSchemaAt(e,a[2],o.lastIndex),s&&n.push({schema:a[2],index:a.index+a[1].length,lastIndex:a.index+a[0].length+s});if(this.__opts__.fuzzyLink&&this.__compiled__["http:"])for(o=this.__opts__.fuzzyIP?this.re.link_fuzzy_global:this.re.link_no_ip_fuzzy_global,o.lastIndex=0;null!==(a=o.exec(e));)r.push({schema:"",index:a.index+a[1].length,lastIndex:a.index+a[0].length});if(this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"])for(o=this.re.email_fuzzy_global,o.lastIndex=0;null!==(a=o.exec(e));)i.push({schema:"mailto:",index:a.index+a[1].length,lastIndex:a.index+a[0].length});const c=[0,0,0];let u=0;for(;;){const a=[n[c[0]],i[c[1]],r[c[2]]],s=l(l(a[0],a[1]),a[2]);if(!s)break;if(s===a[0]?c[0]++:s===a[1]?c[1]++:c[2]++,s.index{const t=e();t&&c().push(t)},0):j.useEffect(e,t)}function Ht(e,t){return e===t}function Wt(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ht,n=null,r=null;return function(){return function(e,t,n){if(null===t||null===n||t.length!==n.length)return!1;for(var r=t.length,i=0;i1?t-1:0),r=1;r1&&void 0!==arguments[1]?arguments[1]:{},i=void 0,a=void 0;"function"==typeof n?(console.warn('[re-reselect] Deprecation warning: "selectorCreator" argument is discouraged and will be removed in the upcoming major release. Please use "options.selectorCreator" instead.'),i=new r,a=n):(i=n.cacheObject||new r,a=n.selectorCreator||Qt);var s=function(){var n=e.apply(void 0,arguments);if("string"==typeof n||"number"==typeof n){var r=i.get(n);return void 0===r&&(r=a.apply(void 0,t),i.set(n,r)),r.apply(void 0,arguments)}};return s.getMatchingSelector=function(){var t=e.apply(void 0,arguments);return i.get(t)},s.removeMatchingSelector=function(){var t=e.apply(void 0,arguments);i.remove(t)},s.clearCache=function(){i.clear()},s.resultFunc=t[t.length-1],s}}const Xt=(e,t)=>t,Kt=(e,t)=>ke(t.replace(/\//gi,"."),e.views),en=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;re.views.current,nn=e=>e.session.connectionState,rn=e=>e.entities.chats.byIds,an=(e,t)=>rn(e)[t],sn=(e,t,n)=>an(e,t).events.byIds[n],on=(e,t,n)=>sn(e,t,an(e,t).events.serverIdsMapping[n]),ln=(e,t,n)=>!!sn(e,t,n),cn=(e,t)=>an(e,t).events.byIds,un=Jt([(e,t)=>an(e,t).events.orderedIds,cn],(e,t)=>e.map(e=>t[e]))(Xt),dn=Jt([an,un],(e,t)=>({...e,events:t}))(Xt),pn=(e,t)=>!!an(e,t),gn=e=>ge(t=>{let{id:n}=t;return dn(e,n)},rn(e)),hn=e=>e.entities.users.byIds,mn=e=>hn(e)[(e=>e.session.id)(e)],fn=(e,t)=>hn(e)[t],_n=(e,t)=>!!fn(e,t),bn=(e,t)=>{var n;return null==(n=e.views)?void 0:n.Chat[t].timeline},vn=e=>mn(e).id,yn=Jt([un,vn],(e,t)=>_e(e=>{let{delivered:n,author:r}=e;return n&&r===t},e))(Xt),wn=Jt([un,vn],(e,t)=>_e(e=>{let{seen:n,author:r}=e;return n&&r===t},e))(Xt),kn={boosters:!0,form:!0,system_message:!0},xn=Qt([un,e=>mn(e).id],(e,t)=>ve(e=>{const n=e.author===t&&"message"===e.type,r=!!e.properties&&"file"===e.properties.serverType,i=!0===e.seen&&!kn[e.type]&&Boolean(e.serverId);return n&&!r||i},e)),In=(e,t)=>e.author!==t&&!e.seen&&!kn[e.type],Sn=(e,t)=>{const n=xn(e,t),r=mn(e).id;return un(e,t).slice(n+1).filter(e=>In(e,r))},En=(e,t)=>Ie(Sn(e,t)),An=Jt([(e,t)=>an(e,t).participants,hn],(e,t)=>e.map(e=>t[e]))(Xt);function Tn(e,t){if(void 0===t)return e.application;const n=t;return e.application[n]}const Cn=Object.freeze(Object.defineProperty({__proto__:null,getApplicationState:Tn,getChat:dn,getChatByServerId:(e,t)=>dn(e,e.entities.chats.serverIdsMapping[t]),getChatList:e=>{var t;return null==(t=e.views)?void 0:t.ChatList},getChats:gn,getConnectionState:nn,getCurrentView:tn,getDefaultView:en,getEvent:sn,getEventByServerId:on,getEvents:un,getIndexedEvents:cn,getLastDeliveredEvent:yn,getLastEvent:(e,t)=>Ie(un(e,t)),getLastSeenAgentEvent:(e,t)=>{const n=xn(e,t);if(-1===n)return null;const r=mn(e).id,i=un(e,t).slice(n+1);return u(e=>In(e,r),i)},getLastSeenEvent:wn,getLastUnseenEvent:En,getParticipants:An,getSessionUser:mn,getSessionUserId:vn,getTimeline:bn,getUnseenCount:(e,t)=>Sn(e,t).length,getUser:fn,getUserByServerId:(e,t)=>fn(e,e.entities.users.serverIdsMapping[t]),getUsers:hn,getView:Kt,hasChat:pn,hasEvent:ln,hasEventByServerId:(e,t,n)=>!!on(e,t,n),hasUser:_n,localize:(e,t,n,r)=>{let i=e.localization[t];const a=e.application.language;if(void 0===i)return"";if("object"==typeof i&&a){const e=new Intl.PluralRules(a);if(void 0===r)return i[e.select(1)];const t=e.select(r);if(!(t in i))return"";i=i[t]}return n?Object.keys(n).reduce((e,t)=>e.replace(new RegExp(`%${t}%`,"g"),n[t]),i):i}},Symbol.toStringTag,{value:"Module"})),zn="not_initialized";var Dn;Dn="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")();var $n,Mn,Fn=("function"==typeof(Mn=Dn.Symbol)?Mn.observable?$n=Mn.observable:($n=Mn("observable"),Mn.observable=$n):$n="@@observable",$n);const Pn=Object.freeze(Object.defineProperty({__proto__:null,default:Fn},Symbol.toStringTag,{value:"Module"})),Rn=(e,t)=>{const n=function(n){const r=Object.create(n);r.action=(t,r)=>{const i={type:e,payload:t};r&&(i.meta=r),n.dispatch(i)};for(var i=arguments.length,a=new Array(i>1?i-1:0),s=1;se,n},On=(e,t)=>{const n=`REQUEST_${e}`,r=Rn(e,t),i=function(e){for(var i=arguments.length,a=new Array(i>1?i-1:0),s=1;s{const{promise:s,resolve:o,reject:c}=Ve();e.dispatch({type:n,payload:{...t,meta:i,resolve:o,reject:c}}),l=s,l.then(()=>{r(e,...a)},O)},t(o,...a),void 0===l)throw new Error(`You forgot to call \`action\` handler in ${n} creator.`);return l};return i.toString=()=>n,{actionMethod:r,requestActionMethod:i}},Bn=(e,t)=>{if("object"!=typeof e||null===e||Array.isArray(e))throw new Error("bindActionMethods expects a plain object with actionMethods as values.");return ge(e=>((e,t)=>function(){for(var n=arguments.length,r=new Array(n),i=0;i(t[void 0]&&console.warn(["Reducer contains an 'undefined' action type.","Have you misspelled a constant?"].join("\n")),function(n,r){return void 0===n&&(n=e),F(r.type,t)?t[r.type](n,r.payload):n}),qn=(e,t)=>{if("object"!=typeof e||null===e||Array.isArray(e))throw new Error("bindSelectors expects a plain object with selectors as values.");return ge(e=>((e,t)=>function(){for(var n=arguments.length,r=new Array(n),i=0;it.reduce((e,t)=>t(e,n),e)},Nn=e=>{let{id:t,serverId:n=null,active:r=!0,participants:i=[],properties:a}=e;if("string"!=typeof t)throw new Error("Chat ID has to be a string.");if(null!==n&&t!==n)throw new Error(`If serverId is given ("${n}") it should match id ("${t}").`);return{id:t,serverId:n,active:r,participants:i,properties:a}},Ln=e=>{let{id:t,type:n,author:r,content:i,timestamp:a,own:s,serverId:o=null,thread:l=null,serverTimestamp:c=null,delivered:u=!0,seen:d=!1,failed:p=!1,properties:g={}}=e;if("string"!=typeof t)throw new Error("Event ID has to be a string.");if("string"!=typeof n)throw new Error("Event has to have string `type` property.");if(null!==o&&t!==o)throw new Error(`If serverId is given ("${o}") it should match id ("${t}").`);return{id:t,serverId:o,type:n,thread:l,author:r,content:i,own:s,timestamp:a,serverTimestamp:c,delivered:u,seen:d,failed:p,properties:g}},Vn=e=>{let{id:t,serverId:n=t,type:r=null,name:i=null,email:a=null,suggestedEmail:s=null,phoneNumber:o=null,avatar:l=null,properties:c={}}=e;if("string"!=typeof t)throw new Error("User ID has to be a string.");return{id:t,serverId:n,type:r,name:i,email:a,suggestedEmail:s,phoneNumber:o,avatar:l,properties:c}},Gn=["content","delivered","failed","properties","seen","serverTimestamp","thread"],Zn=(e,t)=>e.forEach(e=>{if(F(e,t))throw new Error(`Updating \`${String(e)}\` property is not possible.`)}),Hn=Rn("ADD_VIEW",function(e,t,n){let{action:r,getState:i}=e;if(void 0===n&&(n={}),Kt(i(),t))throw new Error(`There is already the "${t}" view. It has to be unique.`);return r({name:t,data:n}),Kt(i(),t)}),Wn=Rn("SET_CURRENT_VIEW",(e,t)=>{let{action:n,getState:r}=e;if(!Kt(r(),t)){const e=en(r());if(!e)throw new Error(`Given view "${t}" doesn't exist.`);return n({name:e}),tn(r())}return n({name:t}),tn(r())}),Qn=Rn("UPDATE_VIEW",(e,t,n)=>{let{action:r,getState:i}=e;if(!Kt(i(),t))throw new Error(`There is no "${t}" view. You should add it first.`);return r({name:t,data:n}),Kt(i(),t)}),Yn=Rn("SET_DEFAULT_VIEW",(e,t,n)=>{let{action:r,getState:i}=e;return r({name:n,path:t}),Kt(i(),`${t}/${n}`)}),Jn=Rn("ADD_CHAT",(e,t)=>{let{action:n,getState:r}=e;const{events:i=[],...a}=t;if(a.id&&pn(r(),a.id))throw new Error(`There is already a chat with "${a.id}" ID. It has to be unique.`);const s=u(e=>!_n(r(),e),i.map(e=>e.author).concat(a.participants||[]));if(s)throw new Error(`Given user ("${s}") doesn't exist. You should add it first.`);const o=a.id||we(gn(r()));return n({id:o,chat:Nn({...a,id:o}),events:i.map(Ln)}),dn(r(),o)}),Xn=Rn("ADD_EVENT",(e,t,n)=>{let{action:r,getState:i}=e;const{id:a,serverId:s}=n,o=i();if(!a||!s||a===s){if(!pn(o,t))throw new Error(`There is no chat with "${t}" ID. You should add it first.`);if(!ln(o,t,a)){if(!_n(o,n.author))throw new Error(`Specified author ("${n.author}") doesn't exist. You should add it first.`);return r({id:a,chat:t,event:Ln({...n,timestamp:n.timestamp??Date.now(),own:n.author===vn(o)})}),sn(i(),t,a)}}}),Kn=Rn("REMOVE_EVENT",(e,t,n)=>{let{action:r,getState:i}=e;const a=i();if(!pn(a,t))throw new Error(`There is no chat with "${t}" ID. You should add it first.`);if(!ln(a,t,n))throw new Error(`There is no event with "${n}" ID in this chat ("${t}").`);r({id:n,chat:t})}),er=Rn("ADD_HISTORY_EVENTS",(e,t,n)=>{let{action:r,getState:i}=e;const a=i();if(!pn(a,t))throw new Error(`There is no chat with "${t}" ID. You should add it first.`);n.forEach(e=>{if(ln(a,t,e.id))throw new Error(`There is already an event with "${e.id}" ID in this chat ("${t}"). It has to be unique.`);if(!_n(a,e.author))throw new Error(`Specified author ("${e.author}") doesn't exist. You should add it first.`)});const s=vn(a);r({chat:t,events:n.map(e=>Ln({...e,serverId:e.id,own:e.author===s}))})}),tr=Rn("ADD_PARTICIPANT",(e,t,n)=>{let{action:r,getState:i}=e;if(!pn(i(),t))throw new Error(`There is no chat with "${t}" ID. You should add it first.`);if(!_n(i(),n))throw new Error(`Given user ("${n}") doesn't exist. You should add it first.`);return r({chat:t,user:n}),An(i(),t)}),nr=Rn("ADD_USER",(e,t)=>{let{action:n,getState:r}=e;const{id:i}=t;if(_n(r(),i))throw new Error(`There is already a user with "${i}" ID. It has to be unique.`);return n({id:i,user:Vn(t)}),fn(r(),i)}),rr=Rn("FLUSH_CHAT",(e,t)=>{let{action:n,getState:r}=e;if(!pn(r(),t))throw new Error(`There is no chat with "${t}" ID. You should add it first.`);return n({id:t}),dn(r(),t)}),ir=Rn("RECALCULATE_TIMELINE",(e,t)=>{let{action:n,getState:r}=e;if(!pn(r(),t))throw new Error(`There is no chat with "${t}" ID. You should add it first.`);return n({id:t}),bn(r(),t)}),ar=Rn("REMOVE_PARTICIPANT",(e,t,n)=>{let{action:r,getState:i}=e;if(!pn(i(),t))throw new Error(`There is no chat with "${t}" ID. You should add it first.`);if(!_n(i(),n))throw new Error(`Given user ("${n}") doesn't exist. You should add it first.`);return r({chat:t,user:n}),An(i(),t)}),sr=Rn("SEND_EVENT",(e,t,n,r)=>{let{action:i,getState:a}=e;if(!pn(a(),t))throw new Error(`There is no chat with "${t}" ID. You should add it first.`);if(ln(a(),t,n.id))throw new Error(`There is already an event with "${n.id}" ID in this chat ("${t}"). It has to be unique.`);const s=n.id||we(cn(a(),t));return i({id:s,chat:t,event:Ln({...n,author:mn(a()).id,own:!0,id:s,timestamp:Date.now(),delivered:!1})},r),sn(a(),t,s)}),or=Rn("SET_APPLICATION_STATE",(e,t)=>{let{action:n,getApplicationState:r}=e;if(!t||a(t))throw new Error("Given data object is empty.");return n(t),r()}),lr=Rn("UPDATE_FEATURE",(e,t,n)=>{let{action:r,getApplicationState:i}=e;if(!n||!t||a(n))throw new Error("Given data object is empty.");return r({feature:t,data:n}),i()}),cr=Rn("SET_CONNECTION_STATE",(e,t)=>{let{action:n,getState:r}=e;return n({connectionState:t}),nn(r())}),ur=Rn("SET_CHAT_SERVER_ID",(e,t,n)=>{let{action:r,getState:i}=e;if(!pn(i(),t))throw new Error(`There is no chat with "${t}" ID. You should add it first.`);if(null!==dn(i(),t).serverId)throw new Error(`Chat with "${t}" ID has already serverId.`);return r({id:t,serverId:n}),dn(i(),t)}),dr=Rn("CLEAR_CHAT_SERVER_ID",(e,t)=>{let{action:n,getState:r}=e;if(!pn(r(),t))throw new Error(`There is no chat with "${t}" ID. You should add it first.`);return n({id:t}),dn(r(),t)}),pr=Rn("SET_EVENT_DATA",(e,t,n,r)=>{let{action:i,getState:a}=e;if(!pn(a(),t))throw new Error(`There is no chat with "${t}" ID. You should add it first.`);if(!ln(a(),t,n))throw new Error(`There is no "${n}" event in "${t}" chat. You should add it first.`);return Zn(["id","type","own"],r),i({chat:t,id:n,data:{...ze(Gn.concat("author","serverId","timestamp"),r),own:r.author===vn(a())}}),sn(a(),t,n)}),gr=Rn("SET_EVENT_SERVER_ID",(e,t,n,r)=>{let{action:i,getState:a}=e;if(!pn(a(),t))throw new Error(`There is no chat with "${t}" ID. You should add it first.`);if(!ln(a(),t,n))throw new Error(`There is no "${n}" event in "${t}" chat. You should add it first.`);if(null!==sn(a(),t,n).serverId)throw new Error(`Event with "${n}" ID has already serverId.`);return i({chat:t,id:n,serverId:r}),sn(a(),t,n)}),hr=Rn("SET_LOCALIZATION",(e,t)=>{let{action:n}=e;n(t)}),mr=Rn("SET_USER_SERVER_ID",(e,t,n)=>{let{action:r,getState:i}=e;if(!_n(i(),t))throw new Error(`There is no "${t}" user. You should add it first.`);if(null!==fn(i(),t).serverId)throw new Error(`User with "${t}" ID has already serverId.`);return r({id:t,serverId:n}),fn(i(),t)}),fr=Rn("CLEAR_USER_SERVER_ID",(e,t)=>{let{action:n,getState:r}=e;if(!_n(r(),t))throw new Error(`There is no "${t}" user. You should add it first.`);return n({id:t}),fn(r(),t)}),{actionMethod:_r,requestActionMethod:br}=On("SET_USER_PROPERTIES",(e,t,n)=>{let{action:r,getState:i}=e;if(!_n(i(),t))throw new Error(`There is no user with "${t}" ID. You should add it first.`);return r({id:t,properties:n}),fn(i(),t)}),{actionMethod:vr,requestActionMethod:yr}=On("UPDATE_CHAT",(e,t,n,r)=>{let{action:i,getState:a}=e;if(!pn(a(),t))throw new Error(`There is no chat with "${t}" ID. You should add it first.`);return Zn(["id","participants","events"],n),i({id:t,data:ze(["active","properties"],n)},r),dn(a(),t)}),{actionMethod:wr,requestActionMethod:kr}=On("UPDATE_EVENT",(e,t,n,r)=>{let{action:i,getState:a}=e;if(!pn(a(),t))throw new Error(`There is no chat with "${t}" ID. You should add it first.`);if(!ln(a(),t,n))throw new Error(`There is no "${n}" event in "${t}" chat. You should add it first.`);return Zn(["id","type","author","own","timestamp"],r),i({chat:t,id:n,data:ze(Gn,r)}),sn(a(),t,n)}),{actionMethod:xr,requestActionMethod:Ir}=On("UPDATE_USER",(e,t,n)=>{let{action:r,getState:i}=e;if(!_n(i(),t))throw new Error(`There is no user with "${t}" ID. You should add it first.`);return Zn(["id","type"],n),r({id:t,data:ze(["name","email","suggestedEmail","phoneNumber","avatar","properties"],n)}),fn(i(),t)}),Sr=Object.freeze(Object.defineProperty({__proto__:null,addChat:Jn,addEvent:Xn,addHistoryEvents:er,addParticipant:tr,addUser:nr,addView:Hn,clearChatServerId:dr,clearUserServerId:fr,flushChat:rr,recalculateTimeline:ir,removeEvent:Kn,removeParticipant:ar,requestSetUserProperties:br,requestUpdateChat:yr,requestUpdateEvent:kr,requestUpdateUser:Ir,sendEvent:sr,setApplicationState:or,setChatServerId:ur,setConnectionState:cr,setCurrentView:Wn,setDefaultView:Yn,setEventData:pr,setEventServerId:gr,setLocalization:hr,setUserProperties:_r,setUserServerId:mr,updateChat:vr,updateEvent:wr,updateFeature:lr,updateUser:xr,updateView:Qn},Symbol.toStringTag,{value:"Module"})),Er="connected",Ar="disconnected",Tr="fakely_connected",Cr="reconnecting",zr="scheduled_reconnecting",Dr="4c8c0751-837f-4a11-928e-047b2d095307",$r="01a3bafb-f822-4a6e-b2ff-f235d7c7bb63",Mr=e=>1===e||5===e,Fr=(e,t)=>Tn(e,"visibility").state===t,Pr=e=>{var t;const n=Tn(e,"config"),r=!!(null==(t=n.features.textApp)?void 0:t.enabled),i=!!Tn(e,"enableMinimizedMessageInputLayout");return(r||i||(e=>{const{organizationId:t,group:n}=Tn(e);return t===Dr&&void 0!==n&&Mr(n)})(e))&&"circle"===(e=>{const t=Tn(e,"config");return!0===Tn(e,"mobile")?t.mobileMinimizedType:t.minimizedType})(e)&&"smooth"===n.theme.name},Rr=d?1:3,Or="not_ready",Br="ready",jr="bootstrapped",qr="chatbotChatId",Ur="chatbot-agent",Nr=18e5,Lr=d?100:1e3,Vr="From",Gr=(e,t)=>{if(isNaN(e))return null;try{return e.toLocaleString(navigator.language,{currency:t,currencyDisplay:"narrowSymbol",style:"currency"})}catch{return`${e.toFixed(2)} ${t}`}},Zr="_text_cart",Hr="_text_cart_url",Wr=[Zr,Hr],Qr=e=>Array.isArray(e)?e.reduce((e,t)=>e+(e=>{if("object"!=typeof e||null===e)return 0;const{qty:t,quantity:n}=e,r=Number(t??n);return!Number.isFinite(r)||r<=0?0:Math.floor(r)})(t),0):0,Yr=(e,t)=>{if(null===e)return null;if(!t)return e.toString();const n=e/10**(e=>{try{return new Intl.NumberFormat(navigator.language,{style:"currency",currency:e}).resolvedOptions().maximumFractionDigits??2}catch{return 2}})(t);return Gr(n,t)},Jr=e=>{const t=e??{},n=(e=>{if("string"!=typeof e||0===e.length)return null;try{const t=JSON.parse(e);return"object"!=typeof t||null===t||Array.isArray(t)?null:t}catch{return null}})(t[Zr]),r="string"==typeof(i=null==n?void 0:n.version)&&Number(i)>=2?n:null;var i;const a=Qr(null==r?void 0:r.items),s=null==r?void 0:r.currency,o="string"==typeof s&&s.length>0?s:null,l="number"==typeof(c=null==r?void 0:r.total)&&Number.isInteger(c)?c:null;var c;const u=Yr(l,o),d=(e=>{if("string"!=typeof e)return null;try{const t=new URL(e);return"https:"===t.protocol||"http:"===t.protocol?t.href:null}catch{return null}})(t[Hr]);return{count:a,total:l,value:u,currency:o,url:d,isComplete:a>0&&null!==u&&null!==o&&null!==d}},Xr="liveChatChatId",Kr="email_prompt",ei="message_draft",ti=100,ni=20,ri="Invalid `chat.id`",ii="Move chat to mobile",ai={labs:"https://mobile-chat.labs.livechat.com/chat-widget-moment/",staging:"https://mobile-chat.staging.livechat.com/chat-widget-moment/",production:"https://mobile-chat.livechat.com/chat-widget-moment/"},si=1500,oi=100,li="before_send_message",ci=800,ui=".+@.+\\..+",di=e=>{const{currentChat:t}=e.getApplicationState();if(!t)throw new Error("Current chat is not set");return t},pi=(e,t)=>{const n=t.getChat(e).properties.currentAgent;return n?Qa(t,n):null},gi=(e,t)=>t.getApplicationState("config").features[e],hi=e=>gi("continuousChat",e).enabled,mi=e=>gi("chatHistory",e).enabled,fi=e=>Ni(e)&&!hi(e),_i=(e,t,n)=>{let{authorPredicate:r,lastSeenPredicate:i}=t;const a=n.getEvents(e),s=Pe(e=>r(e)||!e.seen,ve(i,a),a);return De(r,s)},bi=(e,t,n)=>{const r=n.getSessionUserId();return _i(e,{authorPredicate:e=>e.author!==r,lastSeenPredicate:e=>(e.serverTimestamp||e.timestamp)<=t},n)},vi=(e,t,n)=>{const r=n.getSessionUserId();return _i(e,{authorPredicate:e=>e.author===r,lastSeenPredicate:e=>e.timestamp<=t},n)},yi=(e,t,n)=>{const r=e.getEvent(t,n);if(r.type===ei&&null===r.serverId){const n=_e(e=>e.type===ei,e.getEvents(t));return r.id===(null==n?void 0:n.id)?e.localize("not_sent_yet"):null}if(!r.own)return null;if(r.failed)return"Message not sent";if(r.seen){const r=e.getLastSeenEvent(t);return r&&n===r.id?e.localize("message_read"):null}const i=e.getLastDeliveredEvent(t);return i&&n===i.id?e.localize("message_delivered"):null},wi=e=>{const t=e.getApplicationState("config");return!0===e.getApplicationState("mobile")?t.mobileMinimizedType:t.minimizedType},ki=e=>{const{config:t}=e.getApplicationState();return!0===e.getApplicationState("mobile")&&t.hasCustomMobileSettings},xi=e=>{const{config:t}=e.getApplicationState();return ki(e)?t.mobileScreenPosition:t.screenPosition},Ii=e=>{const{config:t}=e.getApplicationState();return ki(e)?t.mobileOffset:t.screenOffset},Si=(e,t)=>mi(e)&&e.getChat(t).properties.hasMoreHistory,Ei=(e,t)=>{const{fakeAgentMessageId:n}=e.getChat(t).properties;return n?e.getEvent(t,n):null},Ai=(e,t)=>!!Ei(e,t),Ti=e=>{const{embedded:t,actingAsDirectLink:n,isInCustomContainer:r,isMinimizedForcefullyDisabled:i}=e.getApplicationState();return!(!t||n||r||i)},Ci=(e,t)=>{const{active:n,properties:{queued:r}}=t.getChat(Xr);if(n||r)return!1;const{availability:i,readyState:s,websiteTextSelection:o}=t.getApplicationState();return!(!hi(t)&&"online"!==i)&&((!_s(t)||!o.text)&&(!fs(t)&&(s===Or||(!Fa(t,"maximized")||a(t.getEvents(e))))))},zi=(e,t)=>{if(mi(t))return!1;const{availability:n,embedded:r,actingAsDirectLink:i,isInCustomContainer:a,defaultWidget:s}=t.getApplicationState(),o=t.getChat(e);return"livechat"===s&&r&&!i&&!a&&!o.active&&!o.properties.ended&&"offline"===n&&!Ni(t)},Di=e=>e.getConnectionState()===Er,$i=e=>e.getConnectionState()===Cr||(e=>e.getConnectionState()===Ar)(e),Mi=(e,t,n)=>{const r=e.getChat(t),i=r.properties.lastThread,a=i===n||!i&&!n;return r.active&&a&&!$i(e)},Fi=(e,t)=>{if(t<0)return null;const n=e[t];return n.own&&"message"===n.type?null:"system_message"===n.type||"rich_message_postback"===n.type?Fi(e,t-1):n.properties.quickReplies?n:null},Pi=(e,t)=>{const n=t.getEvents(e),r=Fi(n,n.length-1);if(!r)return null;const{invitation:i,welcomeMessage:a}=r.properties;return i||a||t.getChat(e).active?r:null},Ri=(e,t)=>{const{availability:n}=t.getApplicationState(),{active:r,properties:{queued:i,ended:a}}=t.getChat(e);if(i)return t.localize("embedded_waiting_for_operator");const s=pi(e,t);return r&&s?t.localize("embedded_chat_with",{operator:s.name}):a?t.localize("embedded_chat_ended"):"online"===n?t.localize("embedded_chat_now"):Ni(t)||hi(t)?t.localize("embedded_leave_message"):t.localize("agents_not_available")},Oi=(e,t)=>{var n,r;const i=e.getChat(t),a=hi(e);if(e.getApplicationState().hideTextComposer)return null;if(e.getApplicationState().limitReached)return null;if(aa(e)&&!sa(e))return null;if(t===qr&&!i.properties.ended&&!1===(null==(n=gi("chatbotIntegration",e))?void 0:n.properties.showTextField))return i.properties.isAnsweringQuestion?"text":null;if(i.active){const n=ha(e),i=e.getChat(t).properties.currentAgent;return(null==(r=null==n?void 0:n.properties)?void 0:r.useFixedAnswers)&&(null==n?void 0:n.author)===i?null:"text"}if(Aa(e,t))return null;if(Vi(e)){if(es(e)){const t=_e(e=>"form"===e.type,e.getEvents(Xr));if(t&&"postchat"===t.properties.formType)return Ui(e)?"startChatAgain":"text"}return null}return!i.properties.ended||a&&!Ui(e)&&t!==qr?a||"offline"!==e.getApplicationState().availability?Ai(e,Xr)||((e,t)=>{const{awaitingWelcomeMessage:n}=e.getChat(t).properties;return!!n})(e,t)?Ui(e)&&gi("preChatAfterGreeting",e).enabled?"requestPrechat":((e,t,n)=>{const r=pi(t,e);return(null==r?void 0:r.properties.isBot)&&!n&&"ai_agent"!==(null==r?void 0:r.properties.botType)||Hi(e)})(e,t,i.properties.starting)?"startChat":"text":a?Ui(e)?"offline"===e.getApplicationState().availability?null:"requestPrechat":"text":a&&i.properties.ended?"text":null:null:es(e)&&!Ui(e)?"text":"startChatAgain"},Bi=(e,t)=>!!t.getChat(e).properties.starting,ji=e=>e.getApplicationState("license")===g||e.getApplicationState("organizationId")===Dr,qi=e=>e.getApplicationState("config").theme.name,Ui=e=>e.getApplicationState().config.features.preChatForm.enabled,Ni=e=>e.getApplicationState().config.features.ticketForm.enabled,Li=(e,t)=>{const n=_e(e=>"form"===e.type,e.getEvents(Xr));if(!n)return null;const{properties:r}=n;return!r.answered&&"ask_for_email"!==r.formId&&("string"!=typeof t||r.formType===t)?n.id:null},Vi=(e,t)=>!!Li(e,t),Gi=(e,t)=>{const n=e.getEvents(Xr),r=n.findIndex(e=>e.id===t.id);return n.some((e,n)=>n>r&&e.properties.answered&&e.thread===t.thread&&e.properties.formId===t.properties.formId)},Zi=e=>e.getEvents(Xr).filter(e=>{var t;return null==(t=e.properties)?void 0:t.isPreview}),Hi=e=>{const{properties:{groupHasProbableQueue:t}}=e.getChat(Xr);return!!t},Wi=e=>{const{active:t,properties:{queued:n,ended:r,startChatAgainPending:i,currentAgent:a}}=e.getChat(Xr),{availability:s,limitReached:o}=e.getApplicationState(),l=hi(e),c=Ni(e);return!(!o||c&&!l)||"offline"===s&&(!(r&&!i)&&(l?!a&&!n:!t&&!n&&!c))},Qi=e=>{const t=di(e);return Boolean(pi(t,e))&&!("modern"===qi(e)&&Vi(e))&&!((e,t)=>!!t.getChat(e).properties.queued)(t,e)&&!Wi(e)},Yi=e=>{var t,n;return Boolean(null==(n=null==(t=e.getView("Homescreen"))?void 0:t.apps)?void 0:n.find(e=>xt(e.id)))},Ji=e=>{const t=e.getApplicationState().defaultWidget,n=di(e);return n===qr?!e.getChat(n).properties.agentActivity&&("Chat"===e.getCurrentView()&&ka(e)):("openwidget"!==t||"Chat"===e.getCurrentView())&&(!(!aa(e)||e.getView("Chat/queue"))||!Sa(e)&&ka(e))},Xi=e=>{const t=e.getLastEvent(Xr);return!!t&&("form"===t.type&&"ticket"===t.properties.formType&&t.properties.answered)},Ki=e=>{const{nonProfitLicense:t}=e.getApplicationState("config");return t},ea=e=>{const{actingAsDirectLink:t,isInCustomContainer:n,mobileWrapper:r,embedded:i,hideMinimizeButton:a}=e.getApplicationState();return!t&&!n&&(r||i)&&!a},ta=e=>{const{actingAsDirectLink:t,isInCustomContainer:n,isInShopifyCheckoutUI:r,embedded:i,mobile:a,isPreview:s,isConfigurator:o}=e.getApplicationState();return!t&&i&&!n&&!r&&os(e)&&!a&&(!s||o)},na=e=>{const{isLargeWidget:t,ecommerceExpansionCollapsed:n}=e.getApplicationState();return Fa(e,"maximized")&&!t&&!n},ra=e=>Boolean(e.getApplicationState("invitation").current),ia=e=>{const t=pa(e);return!!Bi(Xr,e)||e.getChat(Xr).active&&t.some(e=>!!e.own||e.properties.welcomeMessage)},aa=e=>e.getChat(Xr).properties.queued,sa=e=>{var t;return Boolean(null==(t=gi("queue",e))?void 0:t.writingInQueueEnabled)},oa=e=>gi("fileSharing",e).enabled,la=e=>!e.getApplicationState("mobile")&&gi("emojiPicker",e).enabled,ca=e=>!$i(e),ua=e=>!$i(e)&&!e.getApplicationState("disableSendingMessage"),da=Qt([e=>un(e,Xr),e=>dn(e,Xr).properties.lastThread],(e,t)=>{return Pe(e=>e.thread===t,(n=e).length-1,n);var n}),pa=e=>da(e.getState()),ga=Qt([e=>da(e),e=>vn(e)],(e,t)=>_e(e=>"system"!==e.author&&e.author!==t,e)),ha=e=>ga(e.getState()),ma=(e,t)=>{if(e.hasEvent(Xr,t)){const{properties:n}=e.getEvent(Xr,t);return n.invitation}return!1},fa=e=>!e.getApplicationState().mobile&&"bar"===wi(e),_a=e=>{const t=Ei(e,Xr);return t&&t.properties.invitation?t:null},ba=function(e,t){void 0===t&&(t=_a(e));const{availability:n,invitation:r}=e.getApplicationState();return!(("offline"!==n||hi(e))&&!fa(e))||(!t||Boolean(t&&p(t.properties.uniqueId,r.hiddenIds)))},va=function(e,t){void 0===t&&(t=_a(e));const{invitation:n}=e.getApplicationState();return Boolean(t&&p(t.properties.uniqueId,n.displayedIds))},ya=e=>{const t=_a(e);return!t||ba(e,t)?null:t.id},wa=e=>{const{formType:t,fields:n,answered:r}=e.properties,i=n.filter(e=>e.answer&&e.label);return"ticket"!==t&&r&&a(i)},ka=e=>{const t=di(e),n=e.getEvents(t);return a(n)||n.every(e=>"form"===e.type&&wa(e))},xa=e=>{const t=di(e),n=e.getEvents(t);return a(n)||n.every(e=>"form"===e.type&&wa(e)||e.properties.invitation||e.properties.welcomeMessage)},Ia=e=>os(e)&&Wi(e)&&(e=>{const t=di(e);return 0===e.getEvents(t).length})(e),Sa=e=>Qi(e)||Wi(e)||aa(e),Ea=(e,t)=>e.getEvents(t).find(e=>e.type===ei&&null===e.serverId)??null,Aa=(e,t)=>Boolean(Ea(e,t)),Ta=(e,t)=>{const n=e.getChat(t).active,r=Ui(e),i=gi("preChatAfterGreeting",e).enabled,a=Boolean(_a(e));return!!r&&(a?i:!n)},Ca=e=>{const{embedded:t,actingAsDirectLink:n}=e.getApplicationState();return!t||n?"direct_link":"code"},za=Qt([e=>un(e,Xr)],e=>e.filter(e=>"file"===e.type&&!e.delivered&&!e.properties.canceled)),Da=e=>za(e.getState()),$a=e=>e.getChat(Xr).serverId,Ma=e=>{const{mobile:t}=e.getApplicationState();return gi(t?"mobileMinimized":"minimized",e).enabled},Fa=(e,t)=>e.getApplicationState("visibility").state===t,Pa=(e,t)=>{const n=e.getApplicationState("config").properties.license;return Object.keys(n).some(e=>n[e][t])},Ra=e=>{const t=e.getApplicationState("integrationName");return gi("hideTrademark",e).enabled||"string"==typeof t&&"shopify"===t.toLowerCase()},Oa=(e,t)=>e.getApplicationState("config").properties.license[t],Ba=e=>{const{language:t,isPreview:n}=e.getApplicationState();if("en"!==t||n)return!1;const r=Oa(e,"a9f288b2883da20306d30e179067406f");return Boolean(null==r?void 0:r.transfer_identity_enabled)},ja=e=>{const t=Oa(e,"632cead4b282481a422dd4e1d1567449");return{url:null==t?void 0:t.widget_message_box_moment_url,height:null==t?void 0:t.widget_message_box_moment_height}},qa=e=>{var t,n;const{url:r}=ja(e);return{disabled:!e.getChat(Xr).active||!pi(Xr,e),visible:Om(r)&&(null==(n=null==(t=e.getView("Moment"))?void 0:t.data)?void 0:n.url)!==r}},Ua=e=>e.getChat(Xr).active?e.getChat(Xr).properties.lastThread:null,Na=e=>e.getView("minimized"),La=e=>{var t;return Boolean(null==(t=e.getApplicationState("recommendations"))?void 0:t.isVisible)},Va=e=>e.localize(e.getApplicationState("limitReached")||!hi(e)?"agents_not_available":"agents_not_available_continuous"),Ga=e=>{const t=e.getView("Chat/queue"),n=t&&t.numberInQueue,r=(e=>{const t=e.localize("user_in_queue"),{fields:n}=e.getView("Chat/prechat");if(!n||a(n))return t;const r=n.find(e=>{let{meta:t}=e;return t&&"groupSelect"===t});if(!r||!r.options||a(r.options))return t;const i=r.options.find(t=>{let{groupNumber:n}=t;return n===e.getApplicationState("group")});return i&&i.queueTemplate?i.queueTemplate:t})(e),i=r.includes("%minutes%");let s=r.replace(/%number%/g,`**${n}**`),o=null;return i&&(o=Math.floor(t.waitingTime/60),s=s.replace(/%minutes%/g,`**${o}**`)),{message:s,waitingTime:o}},Za=e=>{if(e.getApplicationState("isPreview"))return!1;if(!gi("rating",e).enabled)return!1;if($i(e))return!1;const{active:t,properties:{rate:n}}=e.getChat(Xr);if(!t||n)return!1;const r=(e=>{const{properties:{timestamp:t}}=e.getChat(Xr);if(!t)return 0;const n=pa(e);if(!n||0===(null==n?void 0:n.length))return 0;const r=_e(e=>"system_message"!==e.type,n);return r?r.timestamp-t:0})(e)/1e3/60;return r>2&&(e=>pa(e).some(e=>{let{author:t,own:n,properties:r}=e;return!n&&"system"!==t&&!r.invitation&&!r.welcomeMessage}))(e)},Ha=e=>"offline"===e.getApplicationState("availability"),Wa=e=>{if(es(e))return!1;if(!gi("homeScreen",e).enabled)return!1;return!("modern"===qi(e))},Qa=(e,t)=>e.getUser(t),Ya=(e,t)=>{if(!t)return"_blank";if(di(e)!==qr)return"_blank";const{page:n}=e.getApplicationState();return tt(t)===tt(n.url)?"_parent":"_blank"},Ja=e=>{const t=_a(e);return t&&t.properties.quickReplies?t:null},Xa=e=>Ee(Tt()).some(t=>Boolean(((e,t)=>e.getApplicationState("config").properties.group[t])(e,t))),Ka=e=>{const{page:t}=e.getApplicationState(),n=tt(t.url);return!!n&&("text.com"===n||n.endsWith(".text.com"))},es=e=>gi("textApp",e).enabled,ts=e=>"smooth"===qi(e)&&es(e)&&!e.getApplicationState("pipMode")&&!e.getApplicationState("mobile")&&e.getApplicationState("actingAsDirectLink"),ns=e=>"modern"===qi(e)?"modern":ts(e)?"full-viewport":os(e)?e.getApplicationState("isLargeWidget")?"ta-large":"ta-default":"default",rs=e=>{const{organizationId:t,group:n}=e.getApplicationState();return t===Dr&&void 0!==n&&Mr(n)},is=e=>{const{aiAgentActive:t}=e.getApplicationState();return!0===t},as=e=>Fa(e,"minimized")&&hs(e)&&is(e)&&!e.getApplicationState("limitReached")&&!e.getChat(Xr).active&&!ya(e),ss=e=>{if(!is(e))return[];const t=Ei(e,Xr);if(!(null==t?void 0:t.properties.welcomeMessage))return[];const n=t.properties.quickReplies;return(null==n?void 0:n.length)?n.map(e=>e.text):[]},os=e=>es(e)||(e=>{const{organizationId:t,group:n}=e.getApplicationState();return t===Dr&&void 0!==n&&(e=>2===e||27===e)(n)})(e)||rs(e),ls=(e,t)=>{const n=Oi(e,t),r=e.getApplicationState("privacyPolicyBannerState");return(gi("privacyPolicy",e).enabled||rs(e))&&("visible"===r||"closing"===r)&&!!n&&"requestPrechat"!==n},cs=Wt((e,t)=>Jr({[Zr]:e,[Hr]:t})),us=e=>{const t=(e=>{var t;const n=(null==(t=e.getSessionUser())?void 0:t.properties)??{};return Ce(Wr,n)})(e);return cs(t[Zr],t[Hr])},ds=e=>(e=>!pa(e).some(e=>{let{author:t,own:n}=e;return!n&&"system"!==t}))(e),ps=e=>Pr(e.getState()),gs=e=>{const{availability:t}=e.getApplicationState();return ps(e)&&"offline"!==t&&!aa(e)&&!Wi(e)&&!$i(e)},hs=e=>gs(e)&&!e.getApplicationState("minimizedMessageInput").closed,ms=e=>"livechat"===e.getApplicationState("defaultWidget")?e.localize("back"):e.localize("go_back_to_homescreen"),fs=e=>{var t,n;const{isFocused:r}=e.getApplicationState("minimizedMessageInput");return r||!!(null==(n=null==(t=Na(e))?void 0:t.messageInput)?void 0:n.trim())},_s=e=>{const{minimizedMessageInput:t}=e.getApplicationState();return"hidden"!==t.state},bs=e=>{const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.opacity="0",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)},vs=e=>{navigator.clipboard?navigator.clipboard.writeText(e).catch(bs):bs(e)},ys=e=>{var t,n;if(e.__unsafeProperties.enableTextApp)return e.__unsafeProperties.group.offlineMessagesEnabled?"offline_message":"helpdesk";const r="feade1d6c3f17748ae4c8d917a1e1068",i=Boolean(null==(t=e.properties.group[r])?void 0:t.forwardTicketFormToHelpdesk),a=!!e.__unsafeProperties.license&&e.__unsafeProperties.license.licenseinboundForwardingToHelpdeskEnabled,s=null==(n=e.properties.license[r])?void 0:n.hdLicenseID;return"number"==typeof s&&s>-1&&(i||a)?"helpdesk":e.__unsafeProperties.group.offlineMessagesEnabled?"offline_message":"livechat"},ws=(e,t)=>e().then(e=>fetch("https://api.helpdesk.com/v1/externalTickets",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.accessToken}`},body:JSON.stringify(t)}).then(e=>e.ok?e.json():Promise.reject(new Error(`Helpdesk ticket request failed with status ${e.status}`))).then(e=>{let{ID:t}=e;return{id:t}}));var ks,xs;const Is=B(function(){if(xs)return ks;xs=1;const e={};return ks=(...t)=>(n,r)=>{if(0!==n)return;const i=t.length;if(0===i)return r(0,()=>{}),r(1,[]),void r(2);let a=i,s=i,o=i;const l=new Array(i),c=new Array(i),u=(e,t)=>{if(0!==e)for(let n=0;n{l[n]=e,t(0,(t,d)=>{if(0===t)c[n]=d,0===--a&&r(0,u);else if(1===t){const t=s?l[n]===e?--s:s:0;if(l[n]=d,0===t){const e=new Array(i);for(let t=0;t(n,r)=>{if(0!==n)return;let i;r(0,e=>{2===e&&i&&(i.unsubscribe?i.unsubscribe():i())}),t=t[e]?t[e]():t,i=t.subscribe({next:e=>r(1,e),error:e=>r(2,e),complete:()=>r(2)})}}()),$s=e=>(t,n)=>{if(0!==t)return;let r=!1;e.then(e=>{r||(n(1,e),r||n(2))},e=>{r||n(2,e)}),n(0,e=>{2===e&&(r=!0)})};var Ms,Fs;const Ps=B(Fs?Ms:(Fs=1,Ms=function(...e){let t=e[0];for(let n=1,r=e.length;nt=>(n,r)=>{if(0!==n)return;let i;t(0,(t,n)=>{0===t?(i=n,r(0,(e,t)=>{0!==e&&i(e,t)}),r(1,e)):r(t,n)})}));var js,qs;const Us=B(qs?js:(qs=1,js=e=>t=>(n,r)=>{0===n&&t(0,(t,n)=>{r(t,1===t?e(n):n)})}));function Ns(e){return t=>U(Us(e)(t))}var Ls,Vs,Gs=function(){},Zs={};function Hs(e){var t,n,r=[],i=!1,a=Zs;return function(s,o){if(0===s){if(a!==Zs)return o(0,Gs),i&&o(1,n),void o(2,a);r.push(o);var l=function(e,n){if(2!==e)a===Zs&&t(e,n);else{var i=r.indexOf(o);-1!==i&&r.splice(i,1)}};1!==r.length?(o(0,l),i&&a===Zs&&o(1,n)):e(0,function(e,s){if(0===e)return t=s,void o(0,l);1===e&&(i=!0,n=s);var c=r.slice(0);2===e&&(a=s,r=null),c.forEach(function(t){t(e,s)})})}}}const Ws=B(Vs?Ls:(Vs=1,Ls=e=>t=>(n,r)=>{if(0!==n)return;let i,a=0;t(0,(t,n)=>{0===t?(i=n,r(t,n)):1===t&&at=>(n,r)=>{0===n&&t(0,(t,n)=>{1===t&&void 0!==n&&e&&e(n),r(t,n)})},Ys=d?100:600,Js=300,Xs=d?300:5e3,Ks=304,eo=d?500:15e3,to=d?100:1e3,no=d?100:600,ro=eo,io=200,ao=60,so=360,oo=130,lo=h,co=(d?300:5e3)-to,uo=no+eo,po=d?500:15e3,go=d?100:1e3,ho=d?100:600,mo=po,fo=200,_o=60,bo=360,vo=95,yo=h,wo=(d?300:5e3)-go,ko=ho+po,xo=2;function Io(e,t){return Ps(Ds(e),Bs(e.getState()),Us(t),Es(Me))}const So=(e,t)=>Ps(Io(e,e=>e.application.readyState),H(e=>e===t),J(1),Hs);let Eo=0;const Ao=(e,t,n,r)=>{const i=++Eo,a=`${t}-done`,s=t=>{(null==t?void 0:t.correlationId)===i&&(e.off(a,s),n())};return e.on(a,s),e.emit(t,{...r,correlationId:i}),()=>{e.off(a,s)}},To=()=>{if((e=window.matchMedia)&&/native code/.test(String(e))){return!window.matchMedia("(hover: none)").matches}var e;return!0},Co=()=>"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1||p("iPad",navigator.userAgent),zo=()=>p(navigator.platform,["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"]),Do=()=>zo()&&/CriOS/.test(navigator.userAgent),$o=()=>/mobile/gi.test(navigator.userAgent)&&!Co(),Mo=()=>$o()||Co(),Fo=()=>p("Chrome",navigator.userAgent),Po=()=>{const e=navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);return e?parseInt(e[2],10):0},Ro=()=>/Firefox/.test(navigator.userAgent),Oo=()=>!Fo()&&/Safari/.test(navigator.userAgent),Bo=24,jo=6,qo=8,Uo=60,No=40,Lo=296,Vo=228,Go=21,Zo=260,Ho=d?100:400,Wo=d?500:1e4,Qo=300,Yo=d?0:400,Jo=Yo+300-Ho,Xo={width:"320px",height:"116px"},Ko=100,el={width:"320px",height:"186px"},tl={width:"320px",height:"354px"},nl=26,rl=22,il=360,al=296,sl=150,ol=240,ll=7,cl=24,ul=2,dl=200,pl=8,gl=8,hl=8,ml=360,fl=8,_l=20,bl={recommendations:{width:"392px",height:"286px"},mobileRecommendations:{width:"100%",height:"286px"}},vl=(e,t)=>{e.getApplicationState("recommendations").products.length>0||Ps(Io(e,e=>e.application.page),Qs(t=>am(e,t.url)),Us(()=>(e=>{const{history:t,updatedAt:n}=e.getApplicationState("locationHistory");return n-(new Date).getTime()>18e5?[]:t})(e)),H(e=>e.length>=Rr),As(e=>{return $s(Promise.all([Promise.resolve(e),(n=t.call,r=e,n("/v1.0/recommendations/match","POST",{pages:r}))]));var n,r}),J(1),Ns(t=>{let[n,r]=t;return Ps(So(e,Br),Us(()=>[n,r]))}),re(t=>{let[n,r]=t;return function(e,t,n){let{products:r,id:i}=t;void 0===n&&(n=!0);const{recommendations:a}=e.getApplicationState(),s=null==a?void 0:a.hiddenIds.includes(i),o={...a,id:i,products:r};if(e.setApplicationState({recommendations:o}),!s){const t=!n;e.setApplicationState({recommendations:{...o,hasSeen:t,isVisible:t}}),em(e,{},{scheduleRerender:t}),wl(e,"recommendations")}}(e,{products:r,id:`h=${n.join(",")}&t=${(new Date).getTime()}`})}))},yl={visitorCounter:-1,recommendations:-1,googleReviews:-1,contactInvitation:-1,chatBotGreeting:-1},wl=(e,t)=>{if("recommendations"===t)return em(e,{eventsQueue:[t]},{scheduleRerender:!1}),nm(e,{transitionState:"hidden",hidden:!0}),tm(e,{transitionState:"hidden",hidden:!0}),rm(e,{transitionState:"hidden",hidden:!0}),void im(e,{transitionState:"hidden",hidden:!0});const n=e.getView("minimized").eventsQueue??[];em(e,{eventsQueue:[].concat(n,[t])},{scheduleRerender:!1})},kl=(e,t)=>{const n=e.getView("minimized").eventsQueue??[];em(e,{eventsQueue:n.filter(e=>e!==t)},{scheduleRerender:!1})},xl=()=>{Object.values(yl).forEach(e=>window.clearTimeout(e))},Il=(e,t)=>{function n(t){return()=>{Ao(e,"resize-to-theme-size",t)}}xl();const r="visitorCounter"===t&&Boolean(e.getApplicationState("googleReviews")),i=e.getApplicationState("contactInvitation").hasSeen;switch(t){case"visitorCounter":yl.visitorCounter=window.setTimeout(n(()=>{tm(e,{transitionState:"shown"}),yl.visitorCounter=window.setTimeout(()=>{tm(e,{transitionState:"hidden"})},ko)}),r?0:wo);break;case"recommendations":(e=>{const t=$o(),n=t?bl.mobileRecommendations:bl.recommendations,r=e.getApplicationState("recommendations");if(r.hidden)return;em(e,{resizeBubbleAnimation:"shrink"}),e.emit("resize-request",{...n,maximized:!1,ignoreHorizontalOffset:t}),e.once("resize-request-done",()=>e.setApplicationState({recommendations:{...r,isVisible:!0,hasSeen:!0,animation:"show"}}))})(e);break;case"googleReviews":yl.googleReviews=window.setTimeout(n(()=>{nm(e,{transitionState:"shown"}),yl.googleReviews=window.setTimeout(()=>{nm(e,{transitionState:"hidden"})},uo)}),co);break;case"contactInvitation":yl.contactInvitation=window.setTimeout(n(()=>{rm(e,{transitionState:"shown"})}),i?0:Xs);break;case"chatBotGreeting":yl.chatBotGreeting=window.setTimeout(n(()=>{im(e,{transitionState:"shown"})}),0);break;default:return}},Sl=e=>{Ps(So(e,jr),Ns(()=>Io(e,()=>(e=>{const t=e.getView("minimized").eventsQueue;return(null==t?void 0:t.length)?t[0]:null})(e))),H(t=>{if(!t||!Fa(e,"minimized"))return!1;const n=e.getApplicationState(t);return!!n&&!n.isVisible}),re(t=>{Il(e,t)})),Ps(Io(e,e=>e.application.visibility.state),H(e=>"maximized"===e),re(xl)),Ps(Io(e,()=>{var t;return null==(t=e.getApplicationState("visitorCounter"))?void 0:t.transitionState}),H(e=>"hidden"===e),re(()=>{kl(e,"visitorCounter")})),Ps(Io(e,()=>{var t;return null==(t=e.getApplicationState("googleReviews"))?void 0:t.transitionState}),H(e=>"hidden"===e),re(()=>{kl(e,"googleReviews")})),Ps(Io(e,e=>{var t;return(null==(t=e.application.recommendations)?void 0:t.hiddenIds)??[]}),H(t=>{const n=e.getApplicationState("recommendations");return n&&t.includes(n.id)}),re(()=>{kl(e,"recommendations")})),Ps(Io(e,()=>{var t;return null==(t=e.getApplicationState("contactInvitation"))?void 0:t.transitionState}),H(e=>"hidden"===e),re(()=>{kl(e,"contactInvitation")})),Ps(Io(e,()=>{var t;return null==(t=e.getApplicationState("chatBotGreeting"))?void 0:t.transitionState}),H(e=>"hidden"===e),re(()=>{kl(e,"chatBotGreeting")}))};function El(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let Al={async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1};const Tl=/[&<>"']/,Cl=new RegExp(Tl.source,"g"),zl=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,Dl=new RegExp(zl.source,"g"),$l={"&":"&","<":"<",">":">",'"':""","'":"'"},Ml=e=>$l[e];function Fl(e,t){if(t){if(Tl.test(e))return e.replace(Cl,Ml)}else if(zl.test(e))return e.replace(Dl,Ml);return e}const Pl=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function Rl(e){return e.replace(Pl,(e,t)=>"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):"")}const Ol=/(^|[^\[])\^/g;function Bl(e,t){e="string"==typeof e?e:e.source,t=t||"";const n={replace:(t,r)=>(r=(r=r.source||r).replace(Ol,"$1"),e=e.replace(t,r),n),getRegex:()=>new RegExp(e,t)};return n}const jl=/[^\w:]/g,ql=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Ul(e,t,n){if(e){let e;try{e=decodeURIComponent(Rl(n)).replace(jl,"").toLowerCase()}catch(r){return null}if(0===e.indexOf("javascript:")||0===e.indexOf("vbscript:")||0===e.indexOf("data:"))return null}t&&!ql.test(n)&&(n=function(e,t){Nl[" "+e]||(Ll.test(e)?Nl[" "+e]=e+"/":Nl[" "+e]=Ql(e,"/",!0));e=Nl[" "+e];const n=-1===e.indexOf(":");return"//"===t.substring(0,2)?n?t:e.replace(Vl,"$1")+t:"/"===t.charAt(0)?n?t:e.replace(Gl,"$1")+t:e+t}(t,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch(r){return null}return n}const Nl={},Ll=/^[^:]+:\/*[^/]*$/,Vl=/^([^:]+:)[\s\S]*$/,Gl=/^([^:]+:\/*[^/]*)[\s\S]*$/;const Zl={exec:function(){}};function Hl(e){let t,n,r=1;for(;r{let r=!1,i=t;for(;--i>=0&&"\\"===n[i];)r=!r;return r?"|":" |"}).split(/ \|/);let r=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),n.length>t)n.splice(t);else for(;n.length1;)1&t&&(n+=e),t>>=1,e+=e;return n+e}function Xl(e,t,n,r){const i=t.href,a=t.title?Fl(t.title):null,s=e[1].replace(/\\([\[\]])/g,"$1");if("!"!==e[0].charAt(0)){r.state.inLink=!0;const e={type:"link",raw:n,href:i,title:a,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,e}return{type:"image",raw:n,href:i,title:a,text:Fl(s)}}class Kl{constructor(e){this.options=e||Al}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const e=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:Ql(e,"\n")}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const e=t[0],n=function(e,t){const n=e.match(/^(\s+)(?:```)/);if(null===n)return t;const r=n[1];return t.split("\n").map(e=>{const t=e.match(/^\s+/);if(null===t)return e;const[n]=t;return n.length>=r.length?e.slice(r.length):e}).join("\n")}(e,t[3]||"");return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline._escapes,"$1"):t[2],text:n}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(/#$/.test(e)){const t=Ql(e,"#");this.options.pedantic?e=t.trim():t&&!/ $/.test(t)||(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){const e=t[0].replace(/^ *>[ \t]?/gm,""),n=this.lexer.state.top;this.lexer.state.top=!0;const r=this.lexer.blockTokens(e);return this.lexer.state.top=n,{type:"blockquote",raw:t[0],tokens:r,text:e}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n,r,i,a,s,o,l,c,u,d,p,g,h=t[1].trim();const m=h.length>1,f={type:"list",raw:"",ordered:m,start:m?+h.slice(0,-1):"",loose:!1,items:[]};h=m?`\\d{1,9}\\${h.slice(-1)}`:`\\${h}`,this.options.pedantic&&(h=m?h:"[*+-]");const _=new RegExp(`^( {0,3}${h})((?:[\t ][^\\n]*)?(?:\\n|$))`);for(;e&&(g=!1,t=_.exec(e))&&!this.rules.block.hr.test(e);){if(n=t[0],e=e.substring(n.length),c=t[2].split("\n",1)[0].replace(/^\t+/,e=>" ".repeat(3*e.length)),u=e.split("\n",1)[0],this.options.pedantic?(a=2,p=c.trimLeft()):(a=t[2].search(/[^ ]/),a=a>4?1:a,p=c.slice(a),a+=t[1].length),o=!1,!c&&/^ *$/.test(u)&&(n+=u+"\n",e=e.substring(u.length+1),g=!0),!g){const t=new RegExp(`^ {0,${Math.min(3,a-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),r=new RegExp(`^ {0,${Math.min(3,a-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),i=new RegExp(`^ {0,${Math.min(3,a-1)}}(?:\`\`\`|~~~)`),s=new RegExp(`^ {0,${Math.min(3,a-1)}}#`);for(;e&&(d=e.split("\n",1)[0],u=d,this.options.pedantic&&(u=u.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!i.test(u))&&!s.test(u)&&!t.test(u)&&!r.test(e);){if(u.search(/[^ ]/)>=a||!u.trim())p+="\n"+u.slice(a);else{if(o)break;if(c.search(/[^ ]/)>=4)break;if(i.test(c))break;if(s.test(c))break;if(r.test(c))break;p+="\n"+u}o||u.trim()||(o=!0),n+=d+"\n",e=e.substring(d.length+1),c=u.slice(a)}}f.loose||(l?f.loose=!0:/\n *\n *$/.test(n)&&(l=!0)),this.options.gfm&&(r=/^\[[ xX]\] /.exec(p),r&&(i="[ ] "!==r[0],p=p.replace(/^\[[ xX]\] +/,""))),f.items.push({type:"list_item",raw:n,task:!!r,checked:i,loose:!1,text:p}),f.raw+=n}f.items[f.items.length-1].raw=n.trimRight(),f.items[f.items.length-1].text=p.trimRight(),f.raw=f.raw.trimRight();const b=f.items.length;for(s=0;s"space"===e.type),t=e.length>0&&e.some(e=>/\n.*\n/.test(e.raw));f.loose=t}if(f.loose)for(s=0;s$/,"$1").replace(this.rules.inline._escapes,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline._escapes,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:r}}}table(e){const t=this.rules.block.table.exec(e);if(t){const e={type:"table",header:Wl(t[1]).map(e=>({text:e})),align:t[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split("\n"):[]};if(e.header.length===e.align.length){e.raw=t[0];let n,r,i,a,s=e.align.length;for(n=0;n({text:e}));for(s=e.header.length,r=0;r/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(t[0]):Fl(t[0]):t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const e=t[2].trim();if(!this.options.pedantic&&/^$/.test(e))return;const t=Ql(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{const e=function(e,t){if(-1===e.indexOf(t[1]))return-1;const n=e.length;let r=0,i=0;for(;i-1){const n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],r="";if(this.options.pedantic){const e=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):"";return n=n.trim(),/^$/.test(e)?n.slice(1):n.slice(1,-1)),Xl(t,{href:n?n.replace(this.rules.inline._escapes,"$1"):n,title:r?r.replace(this.rules.inline._escapes,"$1"):r},t[0],this.lexer)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=(n[2]||n[1]).replace(/\s+/g," ");if(e=t[e.toLowerCase()],!e){const e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return Xl(n,e,n[0],this.lexer)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrong.lDelim.exec(e);if(!r)return;if(r[3]&&n.match(/[\p{L}\p{N}]/u))return;const i=r[1]||r[2]||"";if(!i||i&&(""===n||this.rules.inline.punctuation.exec(n))){const n=r[0].length-1;let i,a,s=n,o=0;const l="*"===r[0][0]?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+n);null!=(r=l.exec(t));){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=i.length,r[3]||r[4]){s+=a;continue}if((r[5]||r[6])&&n%3&&!((n+a)%3)){o+=a;continue}if(s-=a,s>0)continue;a=Math.min(a,a+s+o);const t=e.slice(0,n+r.index+(r[0].length-i.length)+a);if(Math.min(n,a)%2){const e=t.slice(1,-1);return{type:"em",raw:t,text:e,tokens:this.lexer.inlineTokens(e)}}const l=t.slice(2,-2);return{type:"strong",raw:t,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(/\n/g," ");const n=/[^ ]/.test(e),r=/^ /.test(e)&&/ $/.test(e);return n&&r&&(e=e.substring(1,e.length-1)),e=Fl(e,!0),{type:"codespan",raw:t[0],text:e}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e,t){const n=this.rules.inline.autolink.exec(e);if(n){let e,r;return"@"===n[2]?(e=Fl(this.options.mangle?t(n[1]):n[1]),r="mailto:"+e):(e=Fl(n[1]),r=e),{type:"link",raw:n[0],text:e,href:r,tokens:[{type:"text",raw:e,text:e}]}}}url(e,t){let n;if(n=this.rules.inline.url.exec(e)){let e,r;if("@"===n[2])e=Fl(this.options.mangle?t(n[0]):n[0]),r="mailto:"+e;else{let t;do{t=n[0],n[0]=this.rules.inline._backpedal.exec(n[0])[0]}while(t!==n[0]);e=Fl(n[0]),r="www."===n[1]?"http://"+n[0]:n[0]}return{type:"link",raw:n[0],text:e,href:r,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e,t){const n=this.rules.inline.text.exec(e);if(n){let e;return e=this.lexer.state.inRawBlock?this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):Fl(n[0]):n[0]:Fl(this.options.smartypants?t(n[0]):n[0]),{type:"text",raw:n[0],text:e}}}}const ec={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:Zl,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/,_label:/(?!\s*\])(?:\\.|[^\[\]\\])+/,_title:/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/};ec.def=Bl(ec.def).replace("label",ec._label).replace("title",ec._title).getRegex(),ec.bullet=/(?:[*+-]|\d{1,9}[.)])/,ec.listItemStart=Bl(/^( *)(bull) */).replace("bull",ec.bullet).getRegex(),ec.list=Bl(ec.list).replace(/bull/g,ec.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+ec.def.source+")").getRegex(),ec._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ec._comment=/|$)/,ec.html=Bl(ec.html,"i").replace("comment",ec._comment).replace("tag",ec._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ec.paragraph=Bl(ec._paragraph).replace("hr",ec.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",ec._tag).getRegex(),ec.blockquote=Bl(ec.blockquote).replace("paragraph",ec.paragraph).getRegex(),ec.normal=Hl({},ec),ec.gfm=Hl({},ec.normal,{table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),ec.gfm.table=Bl(ec.gfm.table).replace("hr",ec.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",ec._tag).getRegex(),ec.gfm.paragraph=Bl(ec._paragraph).replace("hr",ec.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",ec.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",ec._tag).getRegex(),ec.pedantic=Hl({},ec.normal,{html:Bl("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",ec._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Zl,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Bl(ec.normal._paragraph).replace("hr",ec.hr).replace("heading"," *#{1,6} *[^\n]").replace("lheading",ec.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});const tc={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Zl,tag:"^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:Zl,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\.5&&(n="x"+n.toString(16)),r+="&#"+n+";";return r}tc._punctuation="!\"#$%&'()+\\-.,/:;<=>?@\\[\\]`^{|}~",tc.punctuation=Bl(tc.punctuation).replace(/punctuation/g,tc._punctuation).getRegex(),tc.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,tc.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,tc._comment=Bl(ec._comment).replace("(?:--\x3e|$)","--\x3e").getRegex(),tc.emStrong.lDelim=Bl(tc.emStrong.lDelim).replace(/punct/g,tc._punctuation).getRegex(),tc.emStrong.rDelimAst=Bl(tc.emStrong.rDelimAst,"g").replace(/punct/g,tc._punctuation).getRegex(),tc.emStrong.rDelimUnd=Bl(tc.emStrong.rDelimUnd,"g").replace(/punct/g,tc._punctuation).getRegex(),tc._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,tc._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,tc._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,tc.autolink=Bl(tc.autolink).replace("scheme",tc._scheme).replace("email",tc._email).getRegex(),tc._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,tc.tag=Bl(tc.tag).replace("comment",tc._comment).replace("attribute",tc._attribute).getRegex(),tc._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,tc._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,tc._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,tc.link=Bl(tc.link).replace("label",tc._label).replace("href",tc._href).replace("title",tc._title).getRegex(),tc.reflink=Bl(tc.reflink).replace("label",tc._label).replace("ref",ec._label).getRegex(),tc.nolink=Bl(tc.nolink).replace("ref",ec._label).getRegex(),tc.reflinkSearch=Bl(tc.reflinkSearch,"g").replace("reflink",tc.reflink).replace("nolink",tc.nolink).getRegex(),tc.normal=Hl({},tc),tc.pedantic=Hl({},tc.normal,{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:Bl(/^!?\[(label)\]\((.*?)\)/).replace("label",tc._label).getRegex(),reflink:Bl(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",tc._label).getRegex()}),tc.gfm=Hl({},tc.normal,{escape:Bl(tc.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\t+" ".repeat(n.length));e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(r=>!!(n=r.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0))))if(n=this.tokenizer.space(e))e=e.substring(n.raw.length),1===n.raw.length&&t.length>0?t[t.length-1].raw+="\n":t.push(n);else if(n=this.tokenizer.code(e))e=e.substring(n.raw.length),r=t[t.length-1],!r||"paragraph"!==r.type&&"text"!==r.type?t.push(n):(r.raw+="\n"+n.raw,r.text+="\n"+n.text,this.inlineQueue[this.inlineQueue.length-1].src=r.text);else if(n=this.tokenizer.fences(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.heading(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.hr(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.blockquote(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.list(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.html(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.def(e))e=e.substring(n.raw.length),r=t[t.length-1],!r||"paragraph"!==r.type&&"text"!==r.type?this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title}):(r.raw+="\n"+n.raw,r.text+="\n"+n.raw,this.inlineQueue[this.inlineQueue.length-1].src=r.text);else if(n=this.tokenizer.table(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.lheading(e))e=e.substring(n.raw.length),t.push(n);else{if(i=e,this.options.extensions&&this.options.extensions.startBlock){let t=1/0;const n=e.slice(1);let r;this.options.extensions.startBlock.forEach(function(e){r=e.call({lexer:this},n),"number"==typeof r&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(n=this.tokenizer.paragraph(i)))r=t[t.length-1],a&&"paragraph"===r.type?(r.raw+="\n"+n.raw,r.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=r.text):t.push(n),a=i.length!==e.length,e=e.substring(n.raw.length);else if(n=this.tokenizer.text(e))e=e.substring(n.raw.length),r=t[t.length-1],r&&"text"===r.type?(r.raw+="\n"+n.raw,r.text+="\n"+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=r.text):t.push(n);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,r,i,a,s,o,l=e;if(this.tokens.links){const e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(a=this.tokenizer.rules.inline.reflinkSearch.exec(l));)e.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(l=l.slice(0,a.index)+"["+Jl("a",a[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(a=this.tokenizer.rules.inline.blockSkip.exec(l));)l=l.slice(0,a.index)+"["+Jl("a",a[0].length-2)+"]"+l.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(a=this.tokenizer.rules.inline.escapedEmSt.exec(l));)l=l.slice(0,a.index+a[0].length-2)+"++"+l.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;e;)if(s||(o=""),s=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(r=>!!(n=r.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0))))if(n=this.tokenizer.escape(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.tag(e))e=e.substring(n.raw.length),r=t[t.length-1],r&&"text"===n.type&&"text"===r.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);else if(n=this.tokenizer.link(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.reflink(e,this.tokens.links))e=e.substring(n.raw.length),r=t[t.length-1],r&&"text"===n.type&&"text"===r.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);else if(n=this.tokenizer.emStrong(e,l,o))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.codespan(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.br(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.del(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.autolink(e,rc))e=e.substring(n.raw.length),t.push(n);else if(this.state.inLink||!(n=this.tokenizer.url(e,rc))){if(i=e,this.options.extensions&&this.options.extensions.startInline){let t=1/0;const n=e.slice(1);let r;this.options.extensions.startInline.forEach(function(e){r=e.call({lexer:this},n),"number"==typeof r&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(n=this.tokenizer.inlineText(i,nc))e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(o=n.raw.slice(-1)),s=!0,r=t[t.length-1],r&&"text"===r.type?(r.raw+=n.raw,r.text+=n.text):t.push(n);else if(e){const t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}else e=e.substring(n.raw.length),t.push(n);return t}}class ac{constructor(e){this.options=e||Al}code(e,t,n){const r=(t||"").match(/\S*/)[0];if(this.options.highlight){const t=this.options.highlight(e,r);null!=t&&t!==e&&(n=!0,e=t)}return e=e.replace(/\n$/,"")+"\n",r?'
'+(n?e:Fl(e,!0))+"
\n":"
"+(n?e:Fl(e,!0))+"
\n"}blockquote(e){return`
\n${e}
\n`}html(e){return e}heading(e,t,n,r){if(this.options.headerIds){return`${e}\n`}return`${e}\n`}hr(){return this.options.xhtml?"
\n":"
\n"}list(e,t,n){const r=t?"ol":"ul";return"<"+r+(t&&1!==n?' start="'+n+'"':"")+">\n"+e+"\n"}listitem(e){return`
  • ${e}
  • \n`}checkbox(e){return" "}paragraph(e){return`

    ${e}

    \n`}table(e,t){return t&&(t=`${t}`),"\n\n"+e+"\n"+t+"
    \n"}tablerow(e){return`\n${e}\n`}tablecell(e,t){const n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`\n`}strong(e){return`${e}`}em(e){return`${e}`}codespan(e){return`${e}`}br(){return this.options.xhtml?"
    ":"
    "}del(e){return`${e}`}link(e,t,n){if(null===(e=Ul(this.options.sanitize,this.options.baseUrl,e)))return n;let r='",r}image(e,t,n){if(null===(e=Ul(this.options.sanitize,this.options.baseUrl,e)))return n;let r=`${n}":">",r}text(e){return e}}class sc{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,n){return""+n}image(e,t,n){return""+n}br(){return""}}class oc{constructor(){this.seen={}}serialize(e){return e.toLowerCase().trim().replace(/<[!\/a-z].*?>/gi,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(e,t){let n=e,r=0;if(this.seen.hasOwnProperty(n)){r=this.seen[e];do{r++,n=e+"-"+r}while(this.seen.hasOwnProperty(n))}return t||(this.seen[e]=r,this.seen[n]=0),n}slug(e,t={}){const n=this.serialize(e);return this.getNextSafeSlug(n,t.dryrun)}}class lc{constructor(e){this.options=e||Al,this.options.renderer=this.options.renderer||new ac,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new sc,this.slugger=new oc}static parse(e,t){return new lc(t).parse(e)}static parseInline(e,t){return new lc(t).parseInline(e)}parse(e,t=!0){let n,r,i,a,s,o,l,c,u,d,p,g,h,m,f,_,b,v,y,w="";const k=e.length;for(n=0;n0&&"paragraph"===f.tokens[0].type?(f.tokens[0].text=v+" "+f.tokens[0].text,f.tokens[0].tokens&&f.tokens[0].tokens.length>0&&"text"===f.tokens[0].tokens[0].type&&(f.tokens[0].tokens[0].text=v+" "+f.tokens[0].tokens[0].text)):f.tokens.unshift({type:"text",text:v}):m+=v),m+=this.parse(f.tokens,h),u+=this.renderer.listitem(m,b,_);w+=this.renderer.list(u,p,g);continue;case"html":w+=this.renderer.html(d.text);continue;case"paragraph":w+=this.renderer.paragraph(this.parseInline(d.tokens));continue;case"text":for(u=d.tokens?this.parseInline(d.tokens):d.text;n+1{r(e.text,e.lang,function(t,n){if(t)return s(t);null!=n&&n!==e.text&&(e.text=n,e.escaped=!0),o--,0===o&&s()})},0))}),void(0===o&&s())}function r(e){if(e.message+="\nPlease report this to https://github.com/markedjs/marked.",t.silent)return"

    An error occurred:

    "+Fl(e.message+"",!0)+"
    ";throw e}try{const n=ic.lex(e,t);if(t.walkTokens){if(t.async)return Promise.all(cc.walkTokens(n,t.walkTokens)).then(()=>lc.parse(n,t)).catch(r);cc.walkTokens(n,t.walkTokens)}return lc.parse(n,t)}catch(i){r(i)}}function uc(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function dc(e,t,n){return t&&function(e,t){for(var n=0;n{const n=Hl({},e);if(n.async=cc.defaults.async||n.async,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if(e.renderer){const n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let r=e.renderer.apply(this,t);return!1===r&&(r=n.apply(this,t)),r}:e.renderer}if(e.tokenizer){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");t[e.level]?t[e.level].unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){const t=cc.defaults.renderer||new ac;for(const n in e.renderer){const r=t[n];t[n]=(...i)=>{let a=e.renderer[n].apply(t,i);return!1===a&&(a=r.apply(t,i)),a}}n.renderer=t}if(e.tokenizer){const t=cc.defaults.tokenizer||new Kl;for(const n in e.tokenizer){const r=t[n];t[n]=(...i)=>{let a=e.tokenizer[n].apply(t,i);return!1===a&&(a=r.apply(t,i)),a}}n.tokenizer=t}if(e.walkTokens){const t=cc.defaults.walkTokens;n.walkTokens=function(n){let r=[];return r.push(e.walkTokens.call(this,n)),t&&(r=r.concat(t.call(this,n))),r}}cc.setOptions(n)})},cc.walkTokens=function(e,t){let n=[];for(const r of e)switch(n=n.concat(t.call(cc,r)),r.type){case"table":for(const e of r.header)n=n.concat(cc.walkTokens(e.tokens,t));for(const e of r.rows)for(const r of e)n=n.concat(cc.walkTokens(r.tokens,t));break;case"list":n=n.concat(cc.walkTokens(r.items,t));break;default:cc.defaults.extensions&&cc.defaults.extensions.childTokens&&cc.defaults.extensions.childTokens[r.type]?cc.defaults.extensions.childTokens[r.type].forEach(function(e){n=n.concat(cc.walkTokens(r[e],t))}):r.tokens&&(n=n.concat(cc.walkTokens(r.tokens,t)))}return n},cc.parseInline=function(e,t){if(null==e)throw new Error("marked.parseInline(): input parameter is undefined or null");if("string"!=typeof e)throw new Error("marked.parseInline(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected");Yl(t=Hl({},cc.defaults,t||{}));try{const n=ic.lexInline(e,t);return t.walkTokens&&cc.walkTokens(n,t.walkTokens),lc.parseInline(n,t)}catch(n){if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",t.silent)return"

    An error occurred:

    "+Fl(n.message+"",!0)+"
    ";throw n}},cc.Parser=lc,cc.parser=lc.parse,cc.Renderer=ac,cc.TextRenderer=sc,cc.Lexer=ic,cc.lexer=ic.lex,cc.Tokenizer=Kl,cc.Slugger=oc,cc.parse=cc,cc.options,cc.setOptions,cc.use,cc.walkTokens,cc.parseInline,lc.parse,ic.lex;const bc=new Nt,vc=["A","UL","OL","LI","STRONG","EM","BR","DEL","CODE","PRE"];let yc=function(){function e(){return uc(this,e),gc(this,e,arguments)}return fc(e,ac),dc(e,[{key:"link",value:function(e,t,n){const r=bc.match(n);return r&&r.length>1?n:`
    ${n}`}}])}(),wc=function(){function e(){return uc(this,e),gc(this,e,arguments)}return fc(e,yc),dc(e,[{key:"list",value:function(e,t,n){let r=n;return e.replace(kc,()=>t?r+++". ":"- ")}},{key:"listitem",value:function(e){return`${kc}${e}`}}])}();const kc="%list-item%",xc=e=>e.replace(/\n+$/,"");function Ic(e,t,n){if(function(e,t){let n=e.parentNode;for(;n;){if(n.nodeName===t)return!0;n=n.parentNode}return!1}(e,"A"))return e.textContent;if(null===e.textContent)return null;const r=bc.match(e.textContent);if(!r||0===r.length)return e.textContent;const[i]=Array.from(r).reduce((t,i,a)=>{let[s,o]=t;return s.push(e.textContent.slice(o,i.index),j.createElement(n??"a",{href:i.url,target:"_blank",rel:"nofollow noopener"},i.text)),a===r.length-1&&s.push(e.textContent.slice(i.lastIndex)),[s,i.lastIndex]},[[],0]);return j.createElement(j.Fragment,{key:t},...i)}function Sc(e){cc.setOptions({renderer:new wc});const t=cc.parse(e),n=new DOMParser,{body:r}=n.parseFromString(t,"text/html");return r?xc(r.textContent||""):""}const Ec=e=>{let{template:t,root:n,preserveLists:r,limit:i,linkComponent:a=null}=e;const s=(null==n?void 0:n.props)??{},o=(null==n?void 0:n.component)??j.Fragment,l=j.useMemo(()=>{try{const e=new DOMParser;cc.setOptions({renderer:r?new wc:new yc});const n=xc(cc.parse(t)),{body:s}=e.parseFromString(n,"text/html");return s?function(e,t,n){let r=0,i=!1;const a=e=>Array.from(e).map((e,s)=>{if("#text"===e.nodeName)return n?i?null:e.textContent&&e.textContent.length+r{const t=r(e);return!!t&&/chatbot\.com$/.test(t)},Tc=e=>{const t=s(o(i(e)));if(t.p)try{return ge(decodeURIComponent,JSON.parse(atob(t.p)))}catch{return null}return null},Cc=/^\s+$/,zc=/^(?:\s+|[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?)*/;function Dc(e){let t=null,n=0;for(;t=zc.exec(e);){const r=t[0];if(e=e.slice(r.length),Cc.test(r)||n++,n>3)return!1}return!e}const $c=e=>{let{id:t,authorId:n,timestamp:r,serverId:i=t,threadId:a=null,seen:s=!1}=e;return{id:t,serverId:i,thread:a,author:n,timestamp:r,seen:s}},Mc=e=>{let{id:t,customId:n,authorId:r,timestamp:i,threadId:a,properties:s,seen:o,serverId:l,type:c,text:u,urlDetails:d,...p}=e;return p},Fc=e=>F("bb9e5b2f1ab480e4a715977b7b1b4279",e.properties)?{reaction:ke("bb9e5b2f1ab480e4a715977b7b1b4279.message_reaction",e.properties)}:null,Pc=e=>{const t=F("aa8151b317737a3e79d8e3384e6082de",e.properties)?ke("aa8151b317737a3e79d8e3384e6082de.use_fixed_answers",e.properties):void 0,n=ke("chats.use_fixed_answers",e.properties);return void 0===t&&void 0===n?null:{useFixedAnswers:Boolean(t)||Boolean(n)}},Rc=e=>{if(e.urlDetails){const{urlDetails:t}=e;return{...$c(e),type:"url_preview",properties:{serverType:e.type,title:t.title,description:t.description,image:{url:t.imageUrl,link:t.url}}}}if(Dc(e.text)){return{...$c(e),type:"emoji",properties:{serverType:e.type,text:e.text,...Mc(e)}}}return{...$c(e),type:"message",properties:{serverType:e.type,text:e.text,customId:e.customId,...Mc(e)}}},Oc=e=>{switch(e.type){case"url":if(m(e.value))return null;if(Ac(e.value)){const t=Tc(e.value);if(t&&t.url)return{...e,proxiedValue:t.url}}return e;case"webview":if(m(e.value))return null;if(Ac(e.value)){const t=Tc(e.value);if(t&&t.url)return{...e,proxiedValue:t.url}}return e;default:return e}},Bc=e=>{const t={};return"string"==typeof e.title&&(t.title=e.title),"string"==typeof e.subtitle&&(t.subtitle=e.subtitle),e.image&&(t.image={...e.image,link:e.image.url}),e.buttons&&(t.buttons=e.buttons.map(Oc).filter(Boolean)),t},jc=e=>{const t={...$c(e),type:"system_message",properties:{serverType:e.type,systemMessageType:e.systemMessageType,defaultText:e.text}};return e.textVars&&(t.properties.textVariables=e.textVars),t},qc=e=>e.replace(/index[0-9]*_/gi,""),Uc=(e,t)=>{const n=u(e=>"groupSelect"===e.meta,e);return Object.keys(t).reduce((r,i)=>{const a=t[i];if("rateComment"===i)return r.rateComment=a,r;if("rating"===i)return r.rate=null===a?a:qc(a),r;const s=u(e=>e.name===i,e),{serverName:o}=s;return n&&o&&o===n.serverName&&(r.choosenGroupIndex=t[n.name].match(/index([0-9]*)_/)[1],r.choosenGroup=parseInt(qc(a),10)),s.options?r.fields[o]=M(a)?a.map(qc):qc(a):r.fields[o]=a,r},{fields:{}})};var Nc="__test_storage_support__",Lc="@@test",Vc=function(e){void 0===e&&(e="local");try{var t="session"===e?window.sessionStorage:window.localStorage;return t.setItem(Nc,Lc),t.getItem(Nc)!==Lc?!1:(t.removeItem(Nc),!0)}catch(n){return!1}},Gc=function(){var e=Object.create(null);return{getItem:function(t){var n=e[t];return"string"==typeof n?n:null},setItem:function(t,n){e[t]=n},removeItem:function(t){delete e[t]},clear:function(){e=Object.create(null)}}}();function Zc(e){const t=function(e){try{return window.localStorage}catch(t){return t instanceof Error&&"SecurityError"===t.name&&e?e:Vc()?window.localStorage:Gc}}(e);return{setItem:(e,n)=>new Promise(r=>r(t.setItem(e,n))),getItem:e=>new Promise(n=>n(t.getItem(e))),removeItem:e=>new Promise(n=>n(t.removeItem(e)))}}Zc();const Hc="file",Wc="form",Qc="filled_form",Yc="message",Jc="rich_message",Xc="system_message",Kc="custom",eu="accept_greeting",tu="cancel_greeting",nu="check_goals",ru="deactivate_chat",iu="delete_chat_properties",au="delete_event_properties",su="delete_thread_properties",ou="get_chat",lu="get_customer",cu="get_form",uu="get_url_info",du="list_chats",pu="list_group_statuses",gu="list_threads",hu="login",mu="mark_events_as_seen",fu="request_welcome_message",_u="resume_chat",bu="send_event",vu="send_greeting_button_clicked",yu="send_customer_actions",wu="send_rich_message_postback",ku="send_sneak_peek",xu="set_customer_session_fields",Iu="start_chat",Su="update_chat_properties",Eu="update_customer",Au="update_customer_page",Tu="update_event_properties",Cu="update_thread_properties",zu="upload_file",Du="chat_deactivated",$u="chat_properties_deleted",Mu="chat_properties_updated",Fu="chat_transferred",Pu="customer_disconnected",Ru="customer_side_storage_updated",Ou="customer_updated",Bu="event_properties_deleted",ju="event_properties_updated",qu="event_updated",Uu="events_marked_as_seen",Nu="greeting_accepted",Lu="greeting_canceled",Vu="groups_status_updated",Gu="incoming_chat",Zu="incoming_event",Hu="incoming_greeting",Wu="incoming_multicast",Qu="incoming_rich_message_postback",Yu="incoming_typing_indicator",Ju="incoming_welcome_message",Xu="queue_position_updated",Ku="thread_properties_deleted",ed="thread_properties_updated",td="user_added_to_chat",nd="user_removed_from_chat",rd="incoming_thinking_indicator",id="incoming_event_preview",ad=Object.freeze(Object.defineProperty({__proto__:null,CHAT_DEACTIVATED:Du,CHAT_PROPERTIES_DELETED:$u,CHAT_PROPERTIES_UPDATED:Mu,CHAT_TRANSFERRED:Fu,CUSTOMER_DISCONNECTED:Pu,CUSTOMER_SIDE_STORAGE_UPDATED:Ru,CUSTOMER_UPDATED:Ou,EVENTS_MARKED_AS_SEEN:Uu,EVENT_PROPERTIES_DELETED:Bu,EVENT_PROPERTIES_UPDATED:ju,EVENT_UPDATED:qu,GREETING_ACCEPTED:Nu,GREETING_CANCELED:Lu,GROUPS_STATUS_UPDATED:Vu,INCOMING_CHAT:Gu,INCOMING_EVENT:Zu,INCOMING_EVENT_PREVIEW:id,INCOMING_GREETING:Hu,INCOMING_MULTICAST:Wu,INCOMING_RICH_MESSAGE_POSTBACK:Qu,INCOMING_THINKING_INDICATOR:rd,INCOMING_TYPING_INDICATOR:Yu,INCOMING_WELCOME_MESSAGE:Ju,QUEUE_POSITION_UPDATED:Xu,THREAD_PROPERTIES_DELETED:Ku,THREAD_PROPERTIES_UPDATED:ed,USER_ADDED_TO_CHAT:td,USER_REMOVED_FROM_CHAT:nd},Symbol.toStringTag,{value:"Module"})),sd="customer",od=Object.freeze({success:!0}),ld=["prechat","postchat","ticket","ask_for_email"],cd=e=>null!==e&&!ld.includes(e),ud=(e,t)=>{const n={id:t.id,authorId:t.author_id,createdAt:t.created_at,threadId:e,properties:t.properties||{}};return void 0!==t.custom_id&&(n.customId=t.custom_id),n},dd=(e,t)=>{let n,r,i,a;t.height>t.width?(n="height",r="width",i=t.height,a=t.width):(n="width",r="height",i=t.width,a=t.height);const s=e/i;return{[n]:Math.ceil(Math.min(i,e)),[r]:Math.ceil(Math.min(s*a,a))}},pd=(e,t)=>void 0!==t.width&&void 0!==t.height?((e,t)=>({...ud(e,t),type:Hc,contentType:t.content_type,url:t.url,name:t.name,width:t.width,height:t.height,thumbnails:{default:{url:t.thumbnail_url,...dd(300,t)},high:{url:t.thumbnail2x_url,...dd(600,t)}},...t.alternative_text&&{alternativeText:t.alternative_text}}))(e,t):{...ud(e,t),type:Hc,contentType:t.content_type,url:t.url,name:t.name},gd=e=>{const t={};if("string"==typeof e.title&&(t.title=e.title),"string"==typeof e.subtitle&&(t.subtitle=e.subtitle),e.image){const{image:n}=e;t.image={url:n.url,name:n.name,...n.alternative_text&&{alternativeText:n.alternative_text}}}return e.ecommerce&&(t.ecommerce={productId:e.ecommerce.product_id,viewType:e.ecommerce.view_type,..."string"==typeof e.ecommerce.label&&{label:e.ecommerce.label},...Array.isArray(e.ecommerce.options)&&{options:e.ecommerce.options.map(e=>({label:e.label,optionId:e.option_id,...void 0!==e.price&&{price:e.price},...void 0!==e.regular_price&&{regularPrice:e.regular_price},...void 0!==e.max_price&&{maxPrice:e.max_price},...void 0!==e.currency&&{currency:e.currency},..."string"==typeof e.color&&{color:e.color},...e.image_url&&{imageUrl:e.image_url,..."string"==typeof e.image_thumbnail_url&&{imageThumbnailUrl:e.image_thumbnail_url}},..."boolean"==typeof e.available&&{available:e.available},..."boolean"==typeof e.selected&&{selected:e.selected}}))},...Array.isArray(e.ecommerce.addons)&&{addons:e.ecommerce.addons.map(e=>"price_range"===e.addon_type?{addonType:e.addon_type,...void 0!==e.range_from&&{rangeFrom:e.range_from},...void 0!==e.range_to&&{rangeTo:e.range_to},..."string"==typeof e.currency&&{currency:e.currency}}:{addonType:e.addon_type})}}),e.buttons&&(t.buttons=e.buttons.map(e=>{switch(e.type){case"message":case"add_to_cart":case"show_gallery":case"copy":case"phone":return{type:e.type,text:e.text,postbackId:e.postback_id,userIds:e.user_ids,value:e.value,role:e.role||"default",...e.button_id&&{buttonId:e.button_id}};case"cancel":return{type:e.type,text:e.text,postbackId:e.postback_id,userIds:e.user_ids,role:e.role||"default",...e.button_id&&{buttonId:e.button_id}};case"url":{const t={type:e.type,text:e.text,postbackId:e.postback_id,userIds:e.user_ids,value:e.value,role:e.role||"default",...e.button_id&&{buttonId:e.button_id}};return e.target&&(t.target=e.target),t}case"open_external":return{type:e.type,text:e.text,postbackId:e.postback_id,userIds:e.user_ids,value:e.value,role:e.role||"default",...e.button_id&&{buttonId:e.button_id},...e.target&&{target:e.target}};case"webview":return{type:e.type,text:e.text,postbackId:e.postback_id,userIds:e.user_ids,value:e.value,role:e.role||"default",...e.button_id&&{buttonId:e.button_id}};default:return{text:e.text,postbackId:e.postback_id,userIds:e.user_ids,role:e.role||"default",...e.button_id&&{buttonId:e.button_id}}}})),t},hd=(e,t)=>{switch(t.type){case Hc:return pd(e,t);case Wc:return((e,t)=>({...ud(e,t),authorId:cd(t.form_type??null)?t.author_id:"system",type:Wc,formId:t.form_id,...t.form_type&&{formType:t.form_type},fields:t.fields}))(e,t);case Qc:return((e,t)=>({...ud(e,t),type:Qc,formId:t.form_id,...t.form_type&&{formType:t.form_type},fields:t.fields.map(e=>{if("group_chooser"===e.type){if(!e.answer)return e;const{group_id:t,...n}=e.answer;return{...e,answer:{...n,groupId:t}}}return e})}))(e,t);case Yc:return((e,t)=>({...ud(e,t),type:Yc,text:t.text}))(e,t);case Jc:return((e,t)=>{switch(t.template_id){case"cards":case"quick_replies":case"sticker":case"ecommerce":return{...ud(e,t),type:Jc,template:t.template_id,..."string"==typeof t.layout&&{layout:t.layout},elements:t.elements.map(gd)};default:return null}})(e,t);case Xc:return((e,t)=>{const n={...ud(e,{...t,author_id:"system"}),type:Xc,text:t.text,systemMessageType:t.system_message_type};return t.text_vars&&(n.textVars=t.text_vars),n})(e,t);case Kc:return((e,t)=>({...ud(e,t),type:Kc,...t.content&&{content:t.content}}))(e,t);default:return null}},md=e=>({id:e.id,addon:e.addon||null,uniqueId:e.unique_id,displayedFirstTime:e.displayed_first_time,isExitIntent:e.is_exit_intent,accepted:e.accepted||!1,subtype:e.subtype||"greeting",event:hd(null,e.event),agent:{id:e.agent.id,name:e.agent.name,avatar:e.agent.avatar,jobTitle:e.agent.job_title,isBot:e.agent.is_bot||!1}}),fd=function(e){return void 0===e&&(e={}),e.group_ids?{groupIds:e.group_ids}:{}},_d=e=>ge(e=>e.events_seen_up_to?e.events_seen_up_to:null,xe("id",e)),bd=(e,t)=>{const n=t.properties||{};return{id:t.id,chatId:e,active:t.active,access:fd(t.access),createdAt:t.created_at,userIds:t.user_ids,events:t.events.map(e=>hd(t.id,e)).filter(Boolean),properties:n,previousThreadId:t.previous_thread_id||null,nextThreadId:t.next_thread_id||null,queue:t.queue?Id(t.queue):null}},vd=e=>({id:e.id,access:fd(e.access),users:e.users.map(Sd),properties:e.properties||{},eventsSeenUpToMap:_d(e.users)}),yd=e=>{const t=ze(["avatar","email","name"],e);return"phone_number"in e&&(t.phoneNumber=e.phone_number),e.session_fields&&(t.sessionFields=e.session_fields.reduce((e,t)=>{const[n]=Object.keys(t);return e[n]=t[n],e},{})),"suggested_email"in e&&(t.suggestedEmail=e.suggested_email),t},wd=e=>{const t=yd(e);return{id:e.id,type:sd,...t,sessionFields:t.sessionFields||{}}},kd=e=>{const{statistics:t}=e;return{...wd(e),statistics:{chatsCount:t.chats_count,threadsCount:t.threads_count,visitsCount:t.visits_count,pageViewsCount:t.page_views_count,greetingsShownCount:t.greetings_shown_count,greetingsAcceptedCount:t.greetings_accepted_count}}},xd=e=>({position:e.position,waitTime:e.wait_time}),Id=e=>({...xd(e),queuedAt:e.queued_at}),Sd=e=>{return e.type===sd?{...wd(n=e),present:n.present}:{id:(t=e).id,type:"agent",name:t.name,avatar:t.avatar,jobTitle:t.job_title,present:t.present};var t,n},Ed=e=>"offline"===e?"offline":"online",Ad=e=>({chatId:e.chat_id,properties:e.properties}),Td=e=>{const t={chatId:e.chat_id,threadId:e.thread_id,transferredTo:{...e.transferred_to.agent_ids&&{agentIds:e.transferred_to.agent_ids},...e.transferred_to.group_ids&&{groupIds:e.transferred_to.group_ids}},queue:e.queue?Id(e.queue):null};return"manual"===e.reason?{...t,reason:e.reason,requesterId:e.requester_id}:{...t,reason:e.reason}},Cd=e=>({id:e.id,...yd(e)}),zd=e=>({chatId:e.chat_id,threadId:e.thread_id,eventId:e.event_id,properties:e.properties}),Dd=e=>({chatId:e.chat_id,threadId:e.thread_id,eventId:e.event_id,properties:e.properties}),$d=e=>{const t=e.thread_id;return{chatId:e.chat_id,threadId:t,event:hd(t,e.event)}},Md=e=>({chatId:e.chat_id,userId:e.user_id,seenUpTo:e.seen_up_to}),Fd=e=>({uniqueId:e.unique_id}),Pd=e=>{const{chat:t}=e;return{chat:{...vd(t),thread:bd(t.id,t.thread)}}},Rd=e=>({chatId:e.chat_id,event:hd(e.thread_id,e.event)}),Od=e=>md(e),Bd=e=>({userId:e.user_id,chatId:e.chat_id,threadId:e.thread_id,eventId:e.event_id,postback:e.postback}),jd=e=>{const{chat_id:t,typing_indicator:n}=e;return{chatId:t,typingIndicator:{authorId:n.author_id,isTyping:n.is_typing}}},qd=e=>{const{chat_id:t,thread_id:n,author_id:r,sent_at:i,custom_id:a,title:s,description:o}=e;return{chatId:t,threadId:n,authorId:r,sentAt:i,...a&&{customId:a},...s&&{title:s},...o&&{description:o}}},Ud=e=>({chatId:e.chat_id,threadId:e.thread_id,event:hd(e.thread_id,e.event)}),Nd=e=>({id:e.id,event:hd(null,e.event)}),Ld=e=>({chatId:e.chat_id,threadId:e.thread_id,queue:xd(e.queue)}),Vd=e=>({chatId:e.chat_id,threadId:e.thread_id,properties:e.properties}),Gd=e=>({chatId:e.chat_id,threadId:e.thread_id,properties:e.properties}),Zd=e=>({chatId:e.chat_id,user:Sd(e.user),present:e.user.present}),Hd=e=>({chatId:e.chat_id,userId:e.user_id,reason:e.reason}),Wd=e=>e.map(e=>{switch(e.type){case"group_chooser":return{...e,options:e.options.map(e=>{let{group_id:t,...n}=e;return{...n,groupId:t}})};case"rating":{const{comment_label:t,...n}=e;return{...n,commentLabel:t}}default:return e}}),Qd=e=>{const t=e.map((e,t)=>({...e,id:String(t)}));return Wd(t)},Yd=e=>{const t=!("id"in e.fields[0]);return{id:e.id,fields:t?Qd(e.fields):Wd(e.fields)}},Jd=e=>e.enabled?{...e,form:Yd(e.form)}:e,Xd=e=>{const t={url:e.url};return e.title&&(t.title=e.title),e.description&&(t.description=e.description),e.image_url&&(t.imageUrl=`https://${f(e.image_url)}`,e.image_width&&e.image_height&&(t.imageWidth=e.image_width,t.imageHeight=e.image_height)),t},Kd=e=>{const{id:t,predicted_agent:n,queue:r}=e;return{id:t,predictedAgent:{id:n.id,type:n.type,name:n.name,avatar:n.avatar,jobTitle:n.job_title,isBot:n.is_bot,botType:n.bot_type},queue:r}},ep=e=>{let{online_groups_ids:t,customer_groups:n}=e;if(!t)return"offline";const r=n.monitoring.id;return p(r,t)?"online":"offline"},tp=e=>{const t=e.chats_summary.map(e=>{let{id:t,active:n,access:r,last_thread_created_at:i,last_thread_id:a,last_event_per_type:s,properties:o={},users:l}=e;const c={id:t,active:n,access:fd(r),properties:o,users:l.map(Sd),lastThreadId:a||null,lastThreadCreatedAt:i||null,eventsSeenUpToMap:_d(l)};if(!s)return c;c.lastEventsPerType=ge(e=>hd(e.thread_id,e.event),s);const u=s,d=Ie(Object.keys(u).map(e=>u[e]).sort((e,t)=>e.thread_id===t.thread_id?Oe(e.event.created_at,t.event.created_at):Oe(e.thread_created_at,t.thread_created_at)));return d&&c.lastEventsPerType&&(c.lastEvent=c.lastEventsPerType[d.event.type]),c});return{chatsSummary:Ae(e=>{let{lastEvent:t,order:n}=e;return-1*((void 0!==t?t.timestamp:n)??0)},t),totalChats:e.total_chats,users:Be(e=>e.id,pe(e=>e.users,t)),previousPageId:e.previous_page_id||null,nextPageId:e.next_page_id||null}},np=e=>e.groups_status,rp=(e,t)=>({threads:t.threads.map(t=>bd(e.payload.chat_id,t)),previousPageId:t.previous_page_id||null,nextPageId:t.next_page_id||null}),ip=e=>{const{__priv_dynamic_config:t,chats:n,greeting:r}=e;return{dynamicConfig:t,customer:kd(e.customer),availability:ep(t),chats:n.map(t=>({id:t.chat_id,active:"has_active_thread"in t?t.has_active_thread:e.has_active_thread,hasUnreadEvents:t.has_unread_events})),...r&&{greeting:md(r)}}},ap=e=>{switch(e.action){case Du:return{action:e.action,payload:{chatId:e.payload.chat_id}};case $u:return{action:e.action,payload:(t=e.payload,{chatId:t.chat_id,properties:t.properties})};case Mu:return{action:e.action,payload:Ad(e.payload)};case Fu:return{action:e.action,payload:Td(e.payload)};case Ru:case Pu:return{action:e.action,payload:e.payload};case Ou:return{action:e.action,payload:Cd(e.payload)};case Bu:return{action:e.action,payload:zd(e.payload)};case ju:return{action:e.action,payload:Dd(e.payload)};case qu:return{action:e.action,payload:$d(e.payload)};case Uu:return{action:e.action,payload:Md(e.payload)};case Nu:case Lu:return{action:e.action,payload:Fd(e.payload)};case Vu:return{action:e.action,payload:e.payload};case Gu:return{action:e.action,payload:Pd(e.payload)};case Zu:return{action:e.action,payload:Rd(e.payload)};case Hu:return{action:e.action,payload:Od(e.payload)};case Wu:return{action:e.action,payload:e.payload};case Qu:return{action:e.action,payload:Bd(e.payload)};case Yu:return{action:e.action,payload:jd(e.payload)};case rd:return{action:e.action,payload:qd(e.payload)};case id:return{action:e.action,payload:Ud(e.payload)};case Ju:return{action:e.action,payload:Nd(e.payload)};case Xu:return{action:e.action,payload:Ld(e.payload)};case Ku:return{action:e.action,payload:Vd(e.payload)};case ed:return{action:e.action,payload:Gd(e.payload)};case td:return{action:e.action,payload:Zd(e.payload)};case nd:return{action:e.action,payload:Hd(e.payload)}}var t},sp=e=>{var t;let{request:n,response:r}=e;switch(r.action){case eu:case tu:case iu:case au:case su:return{action:r.action,payload:od};case ou:return{action:r.action,payload:(i=r.payload,{...vd(i),thread:i.thread?bd(i.id,i.thread):null})};case lu:return{action:r.action,payload:kd(r.payload)};case cu:return{action:r.action,payload:Jd(r.payload)};case uu:return{action:r.action,payload:Xd(r.payload)};case du:return{action:r.action,payload:tp(r.payload)};case pu:return{action:r.action,payload:np(r.payload)};case gu:return{action:r.action,payload:rp(n,r.payload)};case hu:return{action:r.action,payload:ip(r.payload)};case mu:return{action:r.action,payload:od};case fu:return{action:r.action,payload:Kd(r.payload)};case ku:case xu:case vu:case wu:case Su:case Eu:return{action:r.action,payload:od};case Au:return{action:r.action,payload:{...od,groups:null==(t=r.payload)?void 0:t.groups}};case Tu:case Cu:return{action:r.action,payload:od}}var i},op=e=>({code:e.type.toUpperCase(),message:e.message}),lp=["prechat","postchat","ticket"],cp=e=>null!==e&&lp.includes(e),up=e=>{const t=e.fields??[],n=t.filter(e=>"radio"===e.type);return 4===t.length&&2===n.length&&n.every(e=>{var t;return 2===(null==(t=e.options)?void 0:t.length)})&&t.some(e=>"rating"===e.type)&&t.some(e=>"rateComment"===e.name)},dp={question:{type:"text"},checkbox_for_email:{type:"checkbox",meta:"confirm_subscription"},header:{type:"information"},skill:{type:"group_select"}},pp=e=>e.map((e,t)=>{const n={};return F("label",e)&&(n.label=e.label),F("checked",e)&&(n.checked=e.checked),n.value=String(t),F("skill_id",e)&&(n.value=String(e.skill_id)),F("embedded_chat_hide_when_offline",e)&&(n.ticketFormDisabled=Boolean(e.embedded_chat_hide_when_offline)),F("queue_template",e)&&(n.queueTemplate=e.queue_template),n}),gp=e=>{let t=!1;const n={fields:e.fields.sort((e,t)=>e.order-t.order).map((e,n)=>{const r={};if("facebookConnect"===e.type)return t=!0,!1;e.id?r.name=e.id:-1===["header","information"].indexOf(e.type)&&(r.name=String(n)),F("value",e)&&(r.value=e.value),F("label",e)&&(r.label=e.label),F("required",e)&&(r.required=e.required),"rating"===e.type&&(r.commentLabel=e.options[0]),e.skills&&e.skills.length>0?r.options=pp(e.skills):e.options&&e.options.length>0&&(e.options_data?r.options=pp(e.options_data):b(e.options[0])?r.options=e.options.map((e,t)=>{let{label:n}=e;return{label:n,value:String(t)}}):r.options=e.options.map((e,t)=>({label:e,value:String(t)}))),e.serverType&&(r.serverType=e.serverType);const{type:i,meta:a}=(e=>({type:dp[e]&&dp[e].type||e,meta:dp[e]&&dp[e].meta||!1}))(e.type);return r.type=i,a&&(r.meta=a),r}).filter(Boolean)};return e.id&&(n.id=e.id),t&&(n.facebookConnect=!0),n},hp=e=>({...e,fields:e.fields.map(e=>{switch(e.type){case"name":case"subject":return{...e,maxLength:1024};case"email":case"textarea":return{...e,required:!0};default:return e}})}),mp=e=>{let{hdLicenseID:t,organizationId:n,isTextAppEnabled:r,group:i,pageUrl:a,form:s,answers:o,additionalInfo:l}=e;const c=((e,t)=>{const n=Se(e=>"message"===e?"textarea":e,e);return t.fields.map(e=>{if("information"===e.type)return null;const t={type:e.type,text:"undefined"!=typeof document?Sc(e.label):e.label,serverType:e.serverType};return(e.name in n||e.type in n)&&("options"in e?t.value=me(n[e.name]).map(t=>u(e=>e.value===t,e.options).label).join(", "):e.name in n?t.value=n[e.name]:t.value=n[e.type],t.value=_(t.value),t.text=`${t.text} ${t.value}`),t}).filter(Boolean)})(o,s),d=u(e=>"email"===e.type||"email"===e.serverType,c),p=u(e=>"name"===e.type||"name"===e.serverType,c);if(!d)throw new Error("Missing email");if(!u(e=>"textarea"===e.type,c))throw new Error("Missing message");const g=u(e=>"subject"===e.type||"subject"===e.serverType,c),h=c.filter(e=>{let{type:t,serverType:n}=e;return-1===["name","email","subject"].indexOf(n||t)}).map(e=>{let{text:t}=e;return t}).join("\n");return{...g&&g.value&&{subject:g.value},message:{text:h},requester:{email:d.value,...p&&p.value&&{name:p.value}},integration:{type:"livechat",...r?{organizationID:n}:{licenseID:t},teamID:String(i),referenceReason:l.lastDisplayedReason,referenceReasonAt:l.lastDisplayedAt,...a&&{referenceURL:a}}}},fp=(e,t)=>{const{requester:n,message:r,subject:i}=t,{text:a}=r,{name:s,email:o}=n;return{id:e,text:a,...i&&{subject:i},visitor:{name:s||null,email:o||null}}},_p={group_chooser:"select",header:"information",name:"text",question:"text",subject:"text",checkbox_for_email:"checkbox"},bp=(e,t)=>e.getSessionUser().serverId===t.authorId,vp=(e,t)=>bp(e,t)?e.getSessionUser().id:t.authorId,yp=(e,t)=>{if("file"===t.type)return t.id;if(bp(e,t))return"customId"in t&&e.hasEvent(Xr,t.customId)?t.customId:t.id;const n=e.getEventByServerId(Xr,t.id);return n?n.id:t.id},wp=e=>(null==e?void 0:e.groupIds)?e.groupIds[0]:null,kp=e=>"offline"===e?"offline":"online",xp=(e,t)=>{const n=e.getSessionUser().serverId,r=Ie(t.filter(e=>e.present&&e.id!==n));return r?r.id:null},Ip=function(e,t,n){void 0===n&&(n=()=>!1);const r=[],i=new Set;return t.forEach(t=>{const a=Rp(e,{...t,seen:n(t)},r,i);a&&r.push(a)}),r.filter(e=>!i.has(e.id))},Sp=(e,t)=>{let{chat:n,chat:{thread:r,users:i}}=t;return{id:n.id,active:r.active,agent:xp(e,i),events:Ip(e,r.events),group:wp(n.access),thread:r.id,previousThread:r.previousThreadId,properties:Lp(r)}},Ep=e=>{let{id:t,active:n,access:r,lastThreadId:i}=e;return{id:t,active:n,lastThreadId:i,group:wp(r)}},Ap=(t,n)=>({...n,type:t,fields:n.fields.reduce((t,n)=>{let{id:r,...i}=n;const a={...i,type:_p[i.type]||i.type,serverName:r,serverType:i.type};if("information"===a.type)a.value=a.label.replace(//gi,"\n");else if("checkbox_for_email"===i.type)a.meta="confirm_subscription",a.label="",a.options=[{label:i.label,checked:i.checked,value:"index0_0",originalValue:"0"}],i.checked&&(a.defaultValue=[a.options[0].value]);else if(i.options){const e="group_chooser"===i.type;e&&(a.meta="groupSelect"),a.options=a.options.map((t,n)=>{const r=e?t.groupId:t.id;return{...Te(["id","checked"],t),value:`index${n}_${r}`,originalValue:String(r)}})}return a.name=p(i.type,["name","email","rating","phone"])?i.type:`${e()}_${r}`,"rating"===i.type?[].concat(t,[a,{name:"rateComment",type:"textarea",label:a.commentLabel,required:!1,dependOn:"rating"}]):[].concat(t,[a])},[])}),Tp=e=>hp(Ap("ticket",e)),Cp=(e,t)=>{const n=e.getSessionUser().serverId,{[n]:r,...i}=t;return{sessionUserSeenUpTo:r,latestOtherUserSeenUpTo:Ie(Ee(i).filter(Boolean).sort())}},zp=e=>{const t=ve(e=>"systemMessageType"in e&&"rating.chat_commented"===e.systemMessageType,e),n=ve(e=>"systemMessageType"in e&&"rating.chat_rated"===e.systemMessageType,e),r=ve(e=>"systemMessageType"in e&&"rating.chat_rating_canceled"===e.systemMessageType,e);return e.filter((e,i)=>{const a="systemMessageType"in e&&["rating.chat_rated","rating.chat_commented","rating.chat_rating_canceled"].includes(e.systemMessageType),s="filled_form"===e.type&&!e.fields.some(e=>"answer"in e&&Boolean(e.answer));return!a&&!s||i===t||i===n||i===r&&r>n})},Dp=e=>{if(!e)return!1;const{events:t,active:n}=e;if(n)return!0;if(!t.length)return!1;const r=t[0],i=Ie(t);return 2!==t.length||"filled_form"!==r.type||"system_message"!==i.type||"manual_archived_customer"!==i.systemMessageType||r.fields.some(e=>"answer"in e&&Boolean(e.answer))},$p=(e,t)=>{let{thread:n,users:r,eventsSeenUpToMap:i}=t;const a=e.getSessionUser().serverId,s=xp(e,r),{sessionUserSeenUpTo:o,latestOtherUserSeenUpTo:l}=Cp(e,i);if(!Dp(n))return{thread:null,eventsSeenUpToMap:i};const{id:c,active:u,events:d,access:p}=n,g=u?d:zp(d);return{thread:{id:c,active:u,agent:u?s:null,events:Ip(e,g,e=>e.authorId===a?l>=e.createdAt:o>=e.createdAt),group:wp(p),properties:Lp(n)},eventsSeenUpToMap:i}},Mp=(e,t)=>{let{thread:n}=t;const{id:r,active:i,events:a,access:s}=n,{eventsSeenUpToMap:o}=e.getChat(Xr).properties,l=e.getSessionUser().serverId,{sessionUserSeenUpTo:c,latestOtherUserSeenUpTo:u}=Cp(e,o);return Dp(n)?{id:r,active:i,events:Ip(e,zp(a),e=>e.authorId===l?u>=e.createdAt:c>=e.createdAt),group:wp(s),properties:Lp(n)}:null},Fp=e=>{let{properties:t,...n}=e;if("lc2"in t){const e=t.lc2;if("greeting_unique_id"in e)return((e,t)=>{const n=Rc({...e});return n.properties={...n.properties,invitation:!0,subtype:e.subtype,id:t.greeting_id,uniqueId:t.greeting_unique_id},n})(n,e);if(e.welcome_message)return((e,t)=>{var n;return Rc({...e,welcomeMessage:!0,...(null==(n=t.chats)?void 0:n.formatting)&&{formatting:t.chats.formatting},..."bb9e5b2f1ab480e4a715977b7b1b4279"in t&&{reaction:t.bb9e5b2f1ab480e4a715977b7b1b4279.message_reaction},...Pc({properties:t})})})(n,t)}return((e,t)=>{var n;return Rc({...e,...t.url_details&&{urlDetails:t.url_details},...t.translation&&{translation:Hp(t.translation)},...(null==(n=t.chats)?void 0:n.formatting)&&{formatting:t.chats.formatting},..."bb9e5b2f1ab480e4a715977b7b1b4279"in t&&{reaction:t.bb9e5b2f1ab480e4a715977b7b1b4279.message_reaction},...Pc({properties:t})})})(n,t)},Pp=e=>{var t,n;const r=(e=>{var t,n;switch(e.template){case"quick_replies":{const r=e.elements[0];return(null==r?void 0:r.title)||(null==(t=null==r?void 0:r.buttons)?void 0:t.length)?{...$c(e),type:"message",properties:{serverType:e.type,text:r.title??"",...(null==(n=r.buttons)?void 0:n.length)&&{quickReplies:r.buttons.map(e=>({type:e.type,text:e.text,value:e.value,postbackId:e.postbackId,...e.buttonId&&{buttonId:e.buttonId}}))},...Fc(e),...Pc(e)}}:null}case"sticker":{const t=e.elements[0].image;return{...$c(e),type:"sticker",properties:{serverType:e.type,url:t.url,name:t.name,...Fc(e),...Pc(e)}}}case"ecommerce":return{...$c(e),type:"product_cards",properties:{serverType:e.type,...e.layout&&{layout:e.layout},elements:e.elements}};default:{if(e.elements.length>1)return{...$c(e),type:"carousel",properties:{serverType:e.type,cards:e.elements.map(Bc)}};const t=e.elements[0];if(1===Object.keys(t).length&&t.image){const{image:n}=t;return{...$c(e),type:"image_preview",properties:{name:n.name,serverType:e.type,url:n.url,...n.alternativeText&&{alternativeText:n.alternativeText},...Fc(e),...Pc(e)}}}return{...$c(e),type:"rich_message",properties:{serverType:e.type,card:Bc(t),...Fc(e),...Pc(e)}}}}})(e);return r?"lc2"in e.properties&&"greeting_unique_id"in e.properties.lc2?(r.properties={...r.properties,invitation:!0,subtype:e.subtype,id:e.properties.lc2.greeting_id,uniqueId:e.properties.lc2.greeting_unique_id,..."bb9e5b2f1ab480e4a715977b7b1b4279"in e.properties&&{reaction:e.properties.bb9e5b2f1ab480e4a715977b7b1b4279.message_reaction}},r):((null==(t=e.properties.chats)?void 0:t.formatting)&&(r.properties={...r.properties,formatting:e.properties.chats.formatting}),r.properties={...r.properties,...Pc(e)},"lc2"in e.properties&&(null==(n=e.properties.lc2)?void 0:n.welcome_message)&&(r.properties={...r.properties,welcomeMessage:!0}),r):null},Rp=function(e,t,n,r){void 0===n&&(n=[]);const i={...t,id:yp(e,t),serverId:t.id,authorId:vp(e,t),timestamp:new Date(t.createdAt).getTime()};switch(i.type){case"form":return Bp(e,i);case"filled_form":return jp(e,i,n,r);case"message":return Fp(i);case"rich_message":return Pp(i);case"file":return(e=>{if(e.thumbnails){const{thumbnails:t}=e,n={...$c(e),type:"image_preview",properties:{name:e.name,serverType:e.type,...t.default,link:e.url,srcSet:`${t.default.url} 1x, ${t.high.url} 2x`,...Fc(e),...Pc(e)}};return e.alternativeText&&(n.properties.alternativeText=e.alternativeText),n}return{...$c(e),type:"message",properties:{serverType:e.type,text:e.name,url:e.url,...e.alternativeText&&{alternativeText:e.alternativeText},...Fc(e),...Pc(e)}}})(i);case"system_message":return qp(i);case"custom":return Op(i);default:return null}},Op=e=>{const{properties:t,customId:n,content:r}=e;return{...$c(e),type:"custom",properties:{...t,customId:n},...void 0!==r&&{content:r}}},Bp=(t,n)=>{var r;const i={...n,fields:n.fields.map(t=>t.id?t:{...t,id:e()})},{author:a,...s}=$c(i);return{...s,author:t.hasUser(a)?a:"system",type:"form",properties:{answered:!1,formType:i.formType||(null==(r=i.properties.lc2)?void 0:r.form_type)||null,fields:Ap("",i).fields,formId:i.formId.replace(/_[0-9]+/,""),...Pc(i)}}},jp=function(e,t,n,r){var i;void 0===n&&(n=[]);const a=function(e,t,n,r){var i;void 0===n&&(n=[]);const a=t.formType||(null==(i=t.properties.lc2)?void 0:i.form_type)||null;if(!cd(a))return;const s=e.getEvents(Xr),o=_e(e=>"form"===e.type&&!e.properties.answered&&e.properties.formId===t.formId,[].concat(s,n));return o&&(r&&r.add(o.id),s.includes(o)&&e.updateEvent(Xr,o.id,{properties:{...o.properties,answered:!0}})),null==o?void 0:o.author}(e,t,n,r);return{...$c(t),...void 0!==a&&{author:a},type:"form",properties:{answered:!0,formId:t.formId,formType:t.formType||(null==(i=t.properties.lc2)?void 0:i.form_type)||null,fields:t.fields.filter(e=>"answer"in e||"answers"in e&&0!==e.answers.length).map(e=>{if("string"==typeof e.answer)return e;if("answers"in e){const{answers:t,...n}=e;return{...n,answer:t.map(e=>{let{label:t}=e;return t})}}return{...e,answer:e.answer.label}})}}},qp=e=>{switch(e.systemMessageType){case"archived_customer_disconnected":case"routing.archived_inactive":return jc({...e,systemMessageType:"client_inactive"});case"manual_archived_agent":return jc({...e,systemMessageType:"operator_closed_session",textVars:{operator:e.textVars.agent}});case"manual_archived_customer":return jc({...e,systemMessageType:"chat_closed_by_customer"});case"system_archived":case"customer_banned":case"routing.archived_deleted":case"routing.archived_disconnected":case"routing.archived_offline":case"routing.archived_other":case"routing.archived_remotely_signed_out":case"routing.archived_signed_out":return jc({...e,systemMessageType:"chat_session_closed"});case"routing.assigned_other":return jc({...e,systemMessageType:"user_transfer",textVars:{operator:e.textVars.agent}});case"routing.assigned_deleted":case"routing.assigned_disconnected":case"routing.assigned_inactive":case"routing.assigned_remotely_signed_out":case"routing.assigned_signed_out":return jc({...e,systemMessageType:"user_transfer",textVars:{operator:e.textVars.agent_added}});case"chat_transferred":return jc({...e,systemMessageType:"user_transfer",textVars:{operator:e.textVars.targets}});case"agent_joined":case"agent_added":return jc({...e,systemMessageType:"operator_joined_conference",textVars:{operator:e.textVars.agent}});case"agent_left":case"agent_removed":return jc({...e,systemMessageType:"operator_left_conference",textVars:{operator:e.textVars.agent}});case"rating.chat_rated":return jc({...e,systemMessageType:`rate_me_confirmation_${e.textVars.score}`});case"rating.chat_commented":return jc({...e,systemMessageType:"rate_me_comment_added",textVars:{comment:e.textVars.comment}});case"rating.chat_rating_canceled":return jc({...e,systemMessageType:"rate_me_cancel"});case"custom":{const{systemMessageType:t,...n}=e;return jc(n)}default:return null}},Up=e=>{const{score:t,comment:n}=e;return{..."number"==typeof t&&{rate:1===t?"good":"bad"},..."string"==typeof n&&{rateComment:n}}},Np=e=>({position:e.position,waitingTime:e.waitTime}),Lp=e=>({..."rating"in e.properties&&Up(e.properties.rating),...e.queue&&{queue:Np(e.queue)},timestamp:new Date(e.createdAt).getTime()}),Vp=(e,t)=>{const n={event:Rp(e,t.event),author:{...t.agent,type:"agent"}};var r;return n.event.properties={...n.event.properties,invitation:!0,id:t.id,addon:t.addon,uniqueId:t.uniqueId,accepted:t.accepted,type:(r=n.event,r.properties.quickReplies?"quick_replies":"rich_message"===r.type?"card":"plain_text"),subtype:t.subtype,receivedFirstTime:t.displayedFirstTime,isExitIntent:t.isExitIntent},n},Gp=(e,t)=>{const n={...t.event,id:we(e.getIndexedEvents(Xr))},r=Rp(e,n);return{id:n.id,author:vp(e,n),type:"message",thread:null,...r,serverId:null,properties:{text:"",...null==r?void 0:r.properties,welcomeMessage:!0,id:t.id}}},Zp=(e,t)=>{const{type:n,id:r}=t;switch(n){case"filled_form":{const{formId:e,...n}=t;return{customId:n.customId,formId:e,...n}}case"emoji":case"message":case"message_draft":case"url_preview":{const{text:n,triggeredBy:i}=t.properties,a={type:"message",customId:r,text:n};if(i){const t=e.getEvent(Xr,i.event);t&&t.thread&&t.serverId?a.postback={id:i.button.postbackId,type:"message",value:i.button.value,eventId:t.serverId,threadId:t.thread}:a.properties={c5e4f61e1a6c3b1521b541bc5c5a2ac5:{postback_id:i.button.postbackId}}}return a}case"custom_system_message":{const{recipients:e,text:n}=t.properties;return{type:"system_message",customId:r,text:n,recipients:e,systemMessageType:"custom"}}case"file":return{type:"file",customId:r,url:t.properties.serverUrl,alternativeText:t.properties.alternativeText};default:return}},Hp=e=>({sourceLangCode:e.source_lang_code,targetLangCode:e.target_lang_code,targetMessage:e.target_message}),Wp=(e,t)=>{const n=Rp(e,t);return n.id=t.customId,n.properties={...n.properties,isPreview:!0},n},Qp=e=>"subject"===e.serverType?"subject":"name"===e.name?"name":"text"===e.type?"question":e.type,Yp=(e,t)=>{let{id:n,serverId:r,properties:{formType:i,formId:a,fields:s}}=e;const o=Uc(s,t),l=o.fields,c={filledForm:{type:"filled_form",formId:a,formType:i,...!r&&{customId:n},fields:s.filter(e=>void 0!==e.serverName&&"rating"!==e.type&&"information"!==e.type).map(e=>{if("groupSelect"===e.meta)return{type:"group_chooser",id:e.serverName,label:Sc(e.label),answer:{id:String(o.choosenGroupIndex),groupId:o.choosenGroup,label:e.options[o.choosenGroupIndex].label}};if("confirm_subscription"===e.meta){const t=l[e.serverName];return{type:"checkbox_for_email",id:e.serverName,label:e.options[0].label,answer:!!t&&p(e.options[0].originalValue,t)}}if(M(e.options)){const t={type:Qp(e),id:e.serverName,label:Sc(e.label)},n=F(e.serverName,l)?me(l[e.serverName]):[],r=e.options.filter(e=>p(e.originalValue,n)).map(e=>({label:e.label,value:e.originalValue}));if("checkbox"===t.type)t.answers=r.map(e=>{let{label:t,value:n}=e;return{label:t,id:n}});else if(r.length){const e=r[0];t.answer={id:e.value,label:e.label}}return t}return F(e.serverName,l)?{type:Qp(e),id:e.serverName,label:Sc(e.label),answer:l[e.serverName]}:{type:Qp(e),id:e.serverName,label:Sc(e.label)}}),properties:{...i&&cp(i)&&{lc2:{form_type:i}}}}};return void 0!==o.choosenGroup&&(c.choosenGroup=o.choosenGroup),c},Jp=d?0:150,Xp=(e,t)=>e.filter(e=>e.serverName in t).map(e=>({type:e.type,label:e.label,value:e.options?me(t[e.serverName]).map(t=>u(e=>e.originalValue===t,e.options).label).join(", "):t[e.serverName]})),Kp=(e,t,n,r)=>{e.emit(`on_${t}_survey_submitted`,{form_data:Xp(n,r)})},eg=(e,t,n)=>{Kp(e,"prechat",t,n)},tg=(e,t,n)=>{Kp(e,"postchat",t,n)},ng=(e,t)=>{e.emit("on_rating_comment_submitted",t)},rg=(e,t)=>{e.emit("on_rating_submitted",null===t?"none":t)},ig=(e,t,n)=>{e.emit("on_message",{text:t.properties.text,timestamp:n/1e3,user_type:"visitor",visitor_name:e.getSessionUser().name})},ag=(e,t,n,r)=>{let{id:i,text:a,visitor:{email:s,name:o},subject:l}=r;const c={form_data:Xp(t,n),ticket_id:i,text:a,visitor_name:o,visitor_email:s};l&&(c.ticket_subject=l),e.emit("on_ticket_created",c)},sg=()=>"openwidget.com"===window.location.hostname||window.location.hostname.endsWith(".openwidget.com"),og=e=>{let{type:t,license:n,organizationId:r,...i}=e;return{...n?{licence_id:n.toString()}:{},...r?{organization_id:r}:{},event_id:t,message:JSON.stringify(i)}},lg=e=>{if(sg())return Promise.resolve();return de("https://applog.livechatinc.com/logs",{method:"POST",headers:{Accept:"*/*","Content-Type":"application/x-www-form-urlencoded"},body:Ke(og(e))}).then(()=>Promise.resolve()).catch(O)},cg=e=>{if(sg()||!("sendBeacon"in navigator))return;const t=new Blob([Ke(og(e))],{type:"application/x-www-form-urlencoded"});navigator.sendBeacon("https://applog.livechatinc.com/logs",t)},ug=Vc()?window.localStorage:Gc,dg="_livechat_has_visited",pg=[/sendURLToGuardwareProxy/i,/safari-extension:\/\//],gg=new Map,hg=(e,t)=>{let{type:n,errorMessage:r,count:i,source:a}=e;i<=1||fg(a,"Informational","error_throttle_summary",{throttledType:n,throttledErrorMessage:r,totalOccurrences:i},t)},mg=!("true"===ug.getItem(dg));ug.setItem(dg,"true");const fg=function(e,t,n,r,i){void 0===i&&(i=lg);const{timeZone:a}=(new Intl.DateTimeFormat).resolvedOptions(),s=(null==r?void 0:r.license)||bm(),o=vm(),l={type:`${e}_${n}`,...s?{license:s}:{},...o?{organizationId:o}:{},userAgent:navigator.userAgent,mobile:$o(),timeZone:String(a),logVersion:"2026-06-29",firstTimeVisitor:mg,severity:t,lc_env:"production",...r};if(a){const[e]=a.split("/");e!==a&&(l.timeZoneArea=String(e))}return i(l)},_g=function(e,t,n,r){var i;void 0===r&&(r="chat_widget");const a={};if(t instanceof Error?(a.errorMessage=t.message,a.stack=t.stack,a.code=t.code):(null==t?void 0:t.message)?a.errorMessage=t.name?`${t.name}: ${t.message}`:t.message:a.errorMessage=JSON.stringify({error:t}),s=a,pg.some(e=>e.test(`${s.errorMessage} ${s.stack}`)))return;var s;const o=Date.now();(e=>{gg.forEach((t,n)=>{e-t.lastSeenAt>3e5&&(hg(t,lg),gg.delete(n))})})(o);const l=String(a.errorMessage??""),c=`${r}|${e}|${l}`,u=(null==(i=gg.get(c))?void 0:i.count)??0;return 1===u?(gg.set(c,{type:e,errorMessage:l,count:u+1,source:r,lastSeenAt:o}),bg("error_throttle_started",{throttledType:e,throttledErrorMessage:l},r)):u>1?void gg.set(c,{type:e,errorMessage:l,count:u+1,source:r,lastSeenAt:o}):(gg.set(c,{type:e,errorMessage:l,count:1,source:r,lastSeenAt:o}),b(n)||(n={meta:JSON.stringify({info:n})}),fg(r,"Error",e,{...n,...a}))},bg=function(e,t,n){return void 0===n&&(n="chat_widget"),fg(n,"Informational",e,t)},vg=e=>fg("chat_widget","Notice",e);window.addEventListener("pagehide",e=>{e.persisted||gg.forEach(e=>hg(e,cg))});const yg=e=>bg("chat_started",e),wg=e=>bg("chat_rated",e),kg=e=>bg("widget_opened",e),xg=(e,t)=>bg(`potential_connection_problem_${e}`,t),Ig=e=>bg("suggested_question_clicked",e),Sg=()=>ke("webkit.messageHandlers.iosMobileWidget.postMessage",window)?"ios":!!ke("androidMobileWidget.postMessage",window)&&"android",Eg=e=>window.androidMobileWidget.postMessage(JSON.stringify(e)),Ag=e=>window.webkit.messageHandlers.iosMobileWidget.postMessage(e),Tg=(()=>{const e=Sg();return"android"===e?Eg:"ios"===e?Ag:null})(),Cg=()=>Boolean(Sg()),zg=e=>{Tg&&(Tg({messageType:"uiReady"}),e.on("add_event",t=>{let{event:n}=t;if("message"!==n.type)return;const r=e.getUser(n.author).name;Tg({messageType:"newMessage",text:n.properties.text,id:n.id,timestamp:n.timestamp,author:{name:r}})}),e.on("mobile_wrapper_minimize_intent",()=>{Tg({messageType:"hideChatWindow"})}))},Dg={light:{maxModifier:.7},dark:{maxModifier:.5}};function $g(e,t,n){return v(e,n)>v(t,n)?e:t}const Mg=function(e,t,n){void 0===n&&(n=0);const r=v(e,t),i=Im(t),{maxModifier:a}=Dg[i?"light":"dark"];if(n>=5)return e;const s=a-r/4.5*.5;if(r>=4.5)return e;const o=i?y(s,e):w(s,e);return v(o,t)>=4.5?o:Mg(o,t,n+1)},Fg=(e,t,n)=>{const r=Sm(e)?w:y;return E(n,r(t,e))},Pg=(e,t)=>{const n=e.variant||"light",r=I[n],i=e.customJson||{},{agentbarBackgroundColor:a,agentMessageColorBackground:s}=e,o=Sm(e.titlebarBackgroundColor)?"rgba(255, 255, 255, 0.1)":"rgba(0, 0, 0, 0.065)",l=Sm(a)?"rgba(255, 255, 255, 0.2)":"rgba(0, 0, 0, 0.05)",c=Sm(a)?"rgba(255, 255, 255, 0.3)":"rgba(0, 0, 0, 0.2)",u=Sm(a)?"rgba(255, 255, 255, 0.3)":"rgba(0, 0, 0, 0.1)",d=k.primaryTextColor,p=x.primaryTextColor,g=$g(d,p,e.ctaColor),h=Mg(e.ctaColor,r.surface),m=$m(s),f=t?r.chatBackground:e.backgroundColor,_=$g(d,p,f),b=Fg(f,.1,.3),v=Fg(f,.15,.3),y=$g(d,p,b);return S({name:e.name,variant:n,iconTheme:e.name,showMessageAvatar:"modern"!==e.name,colors:{agentBarText:e.agentbarText,agentBarBackground:a,cta:e.ctaColor,ctaText:g,minimizedIcon:e.minimizedColorIcon,minimizedBackground:e.minimizedColorBackground,background:f,visitorMessageText:e.visitorMessageColorText,visitorMessageBackground:e.visitorMessageColorBackground,systemMessage:e.systemMessageColor,agentMessageBackground:s,agentMessageText:e.agentMessageColorText,minimizedText:e.minimizedColorText,titleBarText:e.titlebarText,titleBarBackgroundColor:e.titlebarBackgroundColor,quickRepliesColor:h,lighterOppositeTitleBarColor:o,decorativeOppositeAgentBarColor:l,lighterOppositeAgentBarColor:c,codeBlockBackgroundColor:m,adjustedChatBackground:b,adjustedChatBackgroundHover:v,adjustedChatBackgroundTextColor:y},AgentBar:{css:{background:a,color:e.agentbarText},IconButton:{css:{background:{default:"transparent",active:c}}}},Form:{IconButton:{css:{background:{default:"rgba(0, 0, 0, 0.05)",active:e.ctaColor},color:{default:r.formIconColor,active:g}}}},ChatSummary:{Icon:{color:e.minimizedColorIcon}},Maximized:{css:{background:f}},Message:{own:{Bubble:{css:{background:"modern"===e.name?"transparent":e.visitorMessageColorBackground,color:e.visitorMessageColorText}}},system:{Bubble:{css:{color:e.systemMessageColor}}},Bubble:{css:{background:"modern"===e.name?"transparent":s,color:e.agentMessageColorText}},css:{color:e.systemMessageColor}},TypingIndicator:{css:{color:e.systemMessageColor}},Minimized:{MinimizedBubble:{css:{color:e.minimizedColorText,backgroundColor:e.minimizedColorBackground},Icon:{color:e.minimizedColorIcon}},MinimizedBar:{css:{color:e.minimizedColorText,backgroundColor:e.minimizedColorBackground},Icon:{color:e.minimizedColorIcon}}},TitleBar:{css:{background:"modern"===e.name?e.titlebarBackgroundColor:"transparent",color:"modern"===e.name?e.titlebarText:_},HourGlassLabel:{css:{backgroundColor:l}}},DividerLabel:{css:{color:e.systemMessageColor,borderColor:u}},TextComposer:{IconButton:{css:{background:{active:e.ctaColor}},active:{Icon:{color:g}}}}},i)},Rg=[0,2,4,6,8,1,3,5,7,9],Og=e=>e.replace(/\b(?:\d[ -]*?){8,15}((?:\d[ -]*?){4})\b/g,(e,t)=>{const n=e.replace(/(-|\s)/g,"");return(e=>{if(/[^0-9-\s]+/.test(e))return!1;const t=e.replace(/\D/g,"");let n,r=t.length,i=1,a=0;for(;r;)n=parseInt(t.charAt(--r),10),a+=(i^=1)?Rg[n]:n;return a&&a%10==0})(n)?`${(e=>{const t=e%4,n=t?4-t:0,r=Math.floor(e/4)+(t?1:0)-n-1,i=ye(n,"XXX"),a=ye(r,"XXXX");return i.concat(a).join("-").concat("-")})(n.length)}${t}`:e}),Bg=e=>{let t=0;return e.split("").forEach(e=>{const n=e.charCodeAt(0);t=(t<<5)-t+n,t&=t}),t},jg=(e,t)=>Bg(e)%(1/t)==0;(new Nt).tlds(Gt);const qg=(e,t,n)=>{const r=A(t=>t.name===e,n);return-1!==r?je(r,{...n[r],defaultValue:t},n):n},Ug=(e,t,n)=>{e.addEvent(t,{...n,serverId:n.serverId||null})},Ng=(e,t,n)=>{let{systemMessageType:r,textVariables:i,text:a}=n;Ug(e,t,{id:we(e.getIndexedEvents(Xr)),serverId:null,type:"system_message",author:"system",seen:!0,properties:N({systemMessageType:r,textVariables:i,defaultText:a})})},Lg=e=>{Zh(e),(e=>{Da(e).forEach(t=>{e.emit("cancel_upload",{eventId:t.id})})})(e),e.updateChat(Xr,{active:!1,properties:{ended:!0,queued:!1,agentActivity:null}}),e.setApplicationState({greetingsMuted:!1})},Vg=e=>{e.setApplicationState({eyeCatcher:{...e.getApplicationState().eyeCatcher,hidden:!0}})},Gg=(e,t)=>{const n=e.getApplicationState("lightbox"),r={...n,...t.mode&&t.mode!==n.mode&&{mode:t.mode},...t.state&&t.state!==n.state&&{state:t.state},...void 0!==t.currentImageEventId&&{currentImageEventId:t.currentImageEventId},...void 0!==t.sourceEventId&&{sourceEventId:t.sourceEventId},...t.productImages&&{productImages:t.productImages},..."imagesScrollPosition"in t&&{imagesScrollPosition:t.imagesScrollPosition},...void 0!==t.productAction&&{productAction:t.productAction},...void 0!==t.productActionButton&&{productActionButton:t.productActionButton},...void 0!==t.skipEnterAnimations&&{skipEnterAnimations:t.skipEnterAnimations},...void 0!==t.canScrollLeft&&{canScrollLeft:t.canScrollLeft},...void 0!==t.canScrollRight&&{canScrollRight:t.canScrollRight}};e.setApplicationState({lightbox:r})},Zg=function(e,t,n,r,i,a,s){if(void 0===a&&(a=0),void 0===s&&(s=null),0===n.length)return;const o={},l=n.map(e=>{const n=`i${we(o)}`;return o[n]={eventId:n,link:e,alt:t},n}),c=l[a]??l[0]??null;Gg(e,{mode:"product",state:"initializing",currentImageEventId:c,sourceEventId:i,productImages:{orderedEventIds:l,eventIdDataMap:o},productAction:r,productActionButton:s,imagesScrollPosition:void 0,skipEnterAnimations:!1})},Hg=(e,t,n)=>{if(0===n.length)return;const r=e.getApplicationState("lightbox");if("product"!==r.mode||"closing"===r.state||"closed"===r.state)return;const i=r.currentImageEventId,a=i?r.productImages.eventIdDataMap[i]:null,s=!!(a&&i&&n.includes(a.link));let o=!1;const l={},c=n.map(e=>{if(s&&!o&&a&&i&&e===a.link)return o=!0,l[i]=a,i;const n=`i${we(l)}`;return l[n]={eventId:n,link:e,alt:t},n});Gg(e,{productImages:{orderedEventIds:c,eventIdDataMap:l},...s?{}:{currentImageEventId:c[0]??null},skipEnterAnimations:!0})},Wg=e=>{const t=e.getApplicationState("lightbox").productAction;(null==t?void 0:t.postback)&&Mi(e,Xr,t.thread)&&ch(e,{eventId:t.postback.eventId,postback:t.postback.payload})},Qg=e=>{Di(e)||e.setApplicationState({pendingGreetingHide:!0})},Yg=e=>{const t=_a(e);if(!t||!t.properties.uniqueId||ba(e,t))return;const{invitation:n}=e.getApplicationState();var r;e.setApplicationState({invitation:{...n,hiddenIds:[].concat(n.hiddenIds,[t.properties.uniqueId])}}),em(e,{showIndicator:void 0,greetingImageRendered:!1,greetingEventId:void 0}),jg(e.getSessionUser().serverId,.01)&&(r={minimizedType:wi(e),greetingId:t.properties.id,greetingUniqueId:t.properties.uniqueId,greetingType:t.properties.type,greetingSubtype:t.properties.subtype,greetingAddon:t.properties.addon||"none"},bg("greeting_dismissed",r)),e.emit("render-minimized")},Jg=function(e,t,n){let{skipAnimations:r=!1}=void 0===n?{}:n;if(!ps(e))return void Yg(e);const{closed:i,greetingAnimationState:a,deferred:s}=e.getApplicationState("minimizedMessageInput"),o=()=>{var n,r;e.removeEvent(Xr,t);const a=!(null==(r=null==(n=Na(e))?void 0:n.messageInput)?void 0:r.trim()),o=i||a&&s||!gs(e);cm(e,{state:o?"hidden":a?"classic":"full",closingGreetingId:null,greetingAnimationState:"hidden"},{render:!0,scheduledRender:!0})};r?o():"exit"!==a&&("hidden"!==a?cm(e,{state:"full",closingGreetingId:t,greetingAnimationState:"exit"},{render:!0}):o())},Xg=(e,t)=>{var n,r;const{closingGreetingId:i,closed:a,deferred:s}=e.getApplicationState("minimizedMessageInput"),o=!(null==(r=null==(n=Na(e))?void 0:n.messageInput)?void 0:r.trim());i===t&&(C(),Yg(e),a||o&&s||!gs(e)?cm(e,{state:"hidden",closingGreetingId:null,greetingAnimationState:"hidden"},{render:!0}):(cm(e,{state:o?"retracting":"full",closed:!1,closingGreetingId:null,greetingAnimationState:"hidden"},{render:!0}),o&&Kg(e)))},Kg=e=>{setTimeout(()=>{"retracting"===e.getApplicationState("minimizedMessageInput").state&&cm(e,{state:"classic",closed:!1,closingGreetingId:null,greetingAnimationState:"hidden"},{render:!0})},Ho)},eh=(e,t)=>{e.removeEvent(Xr,t),cm(e,{state:"full",closingGreetingId:null,greetingAnimationState:"hidden"})},th=e=>{const t=_a(e);if(!t||!t.properties.uniqueId||va(e))return;const{invitation:n}=e.getApplicationState();e.setApplicationState({invitation:{...n,displayedIds:[].concat(n.displayedIds,[t.properties.uniqueId]),displayedAt:Date.now()}})},nh=function(e,t){let{shouldMaintainModality:n=!0}=void 0===t?{}:t;Fa(e,"maximized")||e.setApplicationState({visibility:{...e.getApplicationState("visibility"),state:"maximized",...!n&&{interactionModality:"virtual"}},minimizedMessageInput:{...e.getApplicationState("minimizedMessageInput"),isFocused:!1,state:gs(e)?"classic":"hidden",autoExpanded:!1}})},rh=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=!1);const{visibility:r,destroyed:i,isMinimizedForcefullyDisabled:a}=e.getApplicationState();!t&&"hidden"===r.state&&r.forced||"minimized"===r.state||(!Ma(e)||zi(Xr,e)||i||a?e.setApplicationState({visibility:{...e.getApplicationState("visibility"),state:"hidden"}}):n||!e.getView("Moment").show?(e.setApplicationState({visibility:{...e.getApplicationState("visibility"),state:"minimized"}}),em(e,{bubbleHoverState:!1})):e.emit("request_close_moment"))},ih=e=>{Fa(e,"minimized")&&e.setApplicationState({visibility:{...e.getApplicationState("visibility"),state:"hidden"}})},ah=e=>{const t=e.getApplicationState("minimizedMessageInput"),n=t.state;("hidden"!==t.greetingAnimationState||!("classic"===n||"hidden"===n))&&cm(e,{state:t.closed||!gs(e)?"hidden":"classic",greetingAnimationState:"hidden",closingGreetingId:null},{render:!1})},sh=(e,t)=>{let{id:n,active:r=!0,thread:i,previousThread:a,group:s,agent:o,queued:l=!1,timestamp:c}=t;null===e.getChat(Xr).serverId&&e.setChatServerId(Xr,n);const u=e.getChat(Xr).properties.fakeAgentMessageId,d={awaitingWelcomeMessage:!1,ended:!1,queued:l,fakeAgentMessageId:null,lastThread:i,previousThread:a,currentAgent:o,timestamp:c,starting:!1};"number"==typeof s&&(d.group=s),Vg(e),e.setApplicationState({disableSendingMessage:!1}),e.updateChat(Xr,{active:r,properties:d}),u&&ah(e),Lh(e),Vh(e),e.setApplicationState({hidden:!1}),e.getApplicationState("welcomeMessageId")&&e.setApplicationState({welcomeMessageId:null,welcomeMessageScope:null});const{readyState:p}=e.getApplicationState();p===Or||Fa(e,"maximized")||(e.setCurrentView("Chat"),nh(e,{shouldMaintainModality:!1}))},oh=function(e,t,n){void 0===n&&(n={});const r=gi("creditCardMasking",e).enabled?(e=>Og(e.replace(/\/\/(\S*):(\S*)@/g,"//****:****@")))(t):t;return{type:Dc(r)?"emoji":"message",thread:Ua(e),properties:N({text:r,...n})}},lh=function(e,t,n,r,i){void 0===r&&(r=void 0),void 0===i&&(i=void 0),e.sendEvent(t,oh(e,n,{triggeredBy:r,source:i}))},ch=(e,t)=>{let{eventId:n,postback:r}=t;const i=di(e),a=Ua(e);"add_to_cart"===r.type&&e.emit("sending_product_card_postback",{eventId:n,postbackId:r.id}),e.sendEvent(i,{type:"rich_message_postback",thread:a,properties:{eventId:n,postback:r}},void 0)},uh=(e,t,n)=>{switch(e.type){case"show_gallery":return{id:e.postbackId,type:"show_gallery",toggled:!0,ecommerce:{product_id:t}};case"url":return{id:e.postbackId,type:"url",toggled:!0,ecommerce:{product_id:t}};case"add_to_cart":return{id:e.postbackId,type:"add_to_cart",toggled:!0,ecommerce:{option_id:n??e.value,product_id:t,quantity:1}};case"open_external":return{id:e.postbackId,type:"open_external",toggled:!0,ecommerce:{option_id:n??e.value,product_id:t}};default:return null}},dh=e=>{let{urlButton:t,eventId:n,thread:r,productId:i,selectedVariantId:a}=e;if(!t)return null;const s=t.postbackId?uh(t,i,a):null;return{url:t.value,label:t.text,postback:s?{eventId:n,payload:s}:null,thread:r}},ph=e=>{let{actionButton:t,eventId:n,thread:r,addedKey:i,productId:a,selectedVariantId:s}=e;if(!t)return null;const o=t.postbackId?uh(t,a,s):null;return{type:t.type,label:t.text,value:t.value,postback:o?{eventId:n,payload:o}:null,eventId:n,thread:r,addedKey:i}},gh=(e,t)=>{let{eventId:n,button:r,productId:i,selectedVariantId:a}=t;if(!r.postbackId)return;const s=uh(r,i,a);s&&ch(e,{eventId:n,postback:s})},hh=(e,t)=>{var n;let{eventId:r,userId:i,postbackId:a}=t;const s=e.getEventByServerId(Xr,r);i===(null==(n=e.getSessionUser())?void 0:n.serverId)&&e.emit("incoming_rich_message_postback",{eventId:(null==s?void 0:s.id)??r,postbackId:a})},mh=(e,t,n)=>{e.setApplicationState({messageDraft:n,initialMessageDraft:null})},fh=(e,t,n,r)=>{const{quickReplies:i}=n.properties,a=i[r];if(n.properties.welcomeMessage&&Ig({context:"maximized"}),n.properties.invitation){if(e.getApplicationState("isPreview"))return;Qh(e,n.id,a)}else lh(e,t,a.text,{type:"quick_reply",event:n.id,button:a},n.properties.welcomeMessage?"suggested_questions_maximized":void 0)},_h=(e,t,n)=>{const r=Ea(e,t);r?e.updateEvent(t,r.id,{properties:n.properties}):Ug(e,t,{...n,seen:!0,type:ei,author:e.getSessionUserId(),id:we(e.getIndexedEvents(Xr))}),r||kh(e),e.setCurrentView("Chat")},bh=function(e,t,n,r,i){void 0===r&&(r=void 0),void 0===i&&(i=void 0);const a=e.getApplicationState("invitation").current,s=e.getEvent(t,a),o=oh(e,n,{triggeredBy:r,source:i,...s&&{fromGreeting:{...Ce(["id","uniqueId"],s.properties)}}});if(!Ta(e,t))return e.setCurrentView("Chat"),void e.sendEvent(t,o);_h(e,t,o)},vh=(e,t,n)=>{if(Ha(e)&&!hi(e))return;if(!Ta(e,t))return void e.setApplicationState({initialMessageDraft:n});const r=oh(e,n);_h(e,t,r)},yh=(e,t,n)=>{let{text:r,recipients:i="all"}=n;e.sendEvent(t,{type:"custom_system_message",thread:Ua(e),properties:{text:r.trim(),recipients:i}})},wh=(e,t)=>{e.updateChat(Xr,{properties:{currentAgent:t}})},kh=e=>{if(!Vi(e,"prechat")){const t=e.getView("Chat/prechat");Rh(e,t)}},xh=(e,t)=>{const{properties:{rate:n,rateComment:r}}=e.getChat(Xr);let{fields:i,...a}=t;n&&(i=qg("rating",n,i)),r&&(i=qg("rateComment",r,i)),Rh(e,{...a,fields:i})},Ih=e=>{const t=di(e);e.updateChat(t,{properties:{startChatAgainPending:!0}})},Sh=function(e,t,n){let{chatId:r,forced:i}=void 0===n?{}:n;e.updateChat(Xr,{properties:{startChatAgainPending:!1}}),jh(e);const{properties:{lastThread:a},serverId:s}=e.getChat(Xr);if(i||!mi(e)||s&&r!==s)e.flushChat(t),r&&e.setChatServerId(Xr,r);else{Nh(e);const t=Ei(e,Xr);t&&e.removeEvent(Xr,t.id)}e.updateChat(t,{properties:{agentActivity:null,awaitingWelcomeMessage:!1,ended:!1,fakeAgentMessageId:null,lastThread:a,loadingHistory:!1,queued:!1,rate:null,rateComment:null,transcriptSentTo:null}}),e.setApplicationState({disableSendingMessage:!1,greetingsMuted:!1})},Eh=e=>{e.updateChat(Xr,{properties:{rate:null,rateComment:null,transcriptSentTo:null}})},Ah=(e,t)=>{var n,r;const i=t.getApplicationState("config"),a=e.__unsafeProperties.enableTextApp??!1;t.setApplicationState({config:{...i,features:{...i.features,homeScreen:{enabled:Am(e)},utmParams:{enabled:Tm(e)},addToWebsiteButton:{enabled:Cm(e)},fileSharing:{enabled:"1"===e.properties.license.core["attachments.enable_for_visitors"]},agentAvatar:{enabled:e.__unsafeProperties.group.hasAgentAvatarsEnabled},continuousChat:{enabled:"1"===e.properties.license.core.continuous_chat_widget_enabled},chatHistory:{enabled:"1"===e.properties.license.core.customer_history_enabled},rating:{enabled:e.__unsafeProperties.group.ratingEnabled},emailTranscript:{enabled:e.__unsafeProperties.group.transcriptButtonEnabled},logo:e.__unsafeProperties.group.logo.enabled?{enabled:!0,path:e.__unsafeProperties.group.logo.src}:{enabled:!1,path:void 0},linksPreview:{enabled:e.__unsafeProperties.group.linksUnfurlingEnabled},ticketForm:{enabled:"ticketForm"in e,mode:e.__unsafeProperties.ticketFormMode||ys(e)},queue:{writingInQueueEnabled:Em(e)},preChatForm:{enabled:"prechatForm"in e},preChatAfterGreeting:{enabled:e.__unsafeProperties.group.prechatFormAfterGreetingEnabled},creditCardMasking:{enabled:!!e.__unsafeProperties.license&&e.__unsafeProperties.license.creditCardMaskingEnabled},hideTrademark:{enabled:e.__unsafeProperties.group.hasHiddenTrademark||!1===e.isPoweredByEnabled},disableSounds:{enabled:!e.__unsafeProperties.group.hasSoundsEnabled},minimized:{enabled:!e.__unsafeProperties.group.disabledMinimized},mobileMinimized:{enabled:e.__unsafeProperties.group.hasCustomMobileSettings?!e.__unsafeProperties.group.disabledMinimizedOnMobile:!e.__unsafeProperties.group.disabledMinimized},hideOnInit:{enabled:e.__unsafeProperties.group.hideOnInit},textApp:{enabled:a},privacyPolicy:{enabled:(null==(n=e.__unsafeProperties.group.privacyPolicy)?void 0:n.enabled)??!1,text:(null==(r=e.__unsafeProperties.group.privacyPolicy)?void 0:r.text)??""}},minimizedType:e.__unsafeProperties.group.minimizedType,mobileMinimizedType:e.__unsafeProperties.group.minimizedTypeOnMobile,theme:S(i.theme,Pg(e.__unsafeProperties.group.theme,a)),screenPosition:e.__unsafeProperties.group.screenPosition,disabledOnMobile:e.__unsafeProperties.group.disabledOnMobile,disabledMinimized:e.__unsafeProperties.group.disabledMinimized,hasCustomMobileSettings:e.__unsafeProperties.group.hasCustomMobileSettings,mobileScreenPosition:e.__unsafeProperties.group.screenPositionOnMobile,mobileOffset:{x:e.__unsafeProperties.group.offsetXOnMobile,y:e.__unsafeProperties.group.offsetYOnMobile},mobileDisabledMinimized:e.__unsafeProperties.group.disabledMinimizedOnMobile,nonProfitLicense:!!e.__unsafeProperties.license&&e.__unsafeProperties.license.nonProfit,properties:e.properties,screenOffset:{x:e.__unsafeProperties.group.offsetX,y:e.__unsafeProperties.group.offsetY}}}),t.getApplicationState("config").features.disableSounds.enabled&&t.setApplicationState({muted:!0})},Th=(e,t,n)=>{const r=e.getApplicationState("config");e.setApplicationState({config:{...r,features:S(r.features,{[t]:n})}})},Ch=(e,t)=>{Th(e,t,{enabled:!1})},zh=(e,t,n)=>{Th(e,t,{enabled:!0,...n})},Dh=(e,t)=>{try{const n=JSON.parse(t).filter(e=>{let{template_id:t}=e;return"moment"===t||"links"===t});if(a(n))return;zh(e,"boosters",{items:n.map(e=>{if("links"===e.template_id)return{id:e.id,template:e.template_id,links:e.links};const t={type:e.action.type,label:e.action.label,url:e.action.url};return{id:e.id,template:e.template_id,title:e.title,description:e.description,icon:e.icon,action:t}})})}catch(n){}},$h=(e,t,n)=>{const r={answered:!0};n&&(r.fields=n.properties.fields,n.id&&!e.getEvent(Xr,t).serverId&&e.setEventServerId(Xr,t,n.id)),e.updateEvent(Xr,t,{properties:r});const i=e.getEvent(Xr,t);wa(i)&&Promise.resolve().then(()=>{e.hasEvent(Xr,t)&&e.removeEvent(Xr,t)})},Mh=(e,t)=>{var n;t.properties.receivedFirstTime&&jg(e.getSessionUser().serverId,.01)&&(n={minimizedType:wi(e),greetingId:t.properties.id,greetingUniqueId:t.properties.uniqueId,greetingType:t.properties.type,greetingSubtype:t.properties.subtype,greetingAddon:t.properties.addon||"none"},bg("greeting_displayed",n))},Fh=(e,t)=>{var n,r,i,a,s;const{defaultWidget:o,embedded:l,actingAsDirectLink:c,greetingsMuted:u}=e.getApplicationState();wh(e,t.author),"openwidget"===o&&(e=>{const t=e.getApplicationState("recommendations");xl(),em(e,{eventsQueue:[]},{scheduleRerender:!1}),nm(e,{transitionState:"hidden",hidden:!0}),tm(e,{transitionState:"hidden",hidden:!0}),rm(e,{transitionState:"hidden",hidden:!0}),e.setApplicationState({recommendations:{...t,isVisible:!1,hiddenIds:[].concat(t.hiddenIds,[t.id]),hidden:!0}})})(e),"bar"!==wi(e)&&Vg(e),Lh(e),Gh(e);const d=_a(e);var p;d&&(p={minimizedType:wi(e),greetingId:null==(n=d.properties)?void 0:n.id,greetingUniqueId:null==(r=d.properties)?void 0:r.uniqueId,greetingType:null==(i=d.properties)?void 0:i.type,greetingSubtype:null==(a=d.properties)?void 0:a.subtype,greetingAddon:(null==(s=d.properties)?void 0:s.addon)||"none"},bg("greeting_not_canceled",p),ps(e)?eh(e,d.id):e.removeEvent(Xr,d.id)),me(t.properties.cards||t.properties.card).filter(Boolean).forEach(t=>{t.title&&(t.title=xm(e,t.title)),t.subtitle&&(t.subtitle=xm(e,t.subtitle)),t.buttons&&(t.buttons.forEach(e=>e.invitation=!0),l&&!c||t.buttons.filter(e=>"url"===e.type&&"target"in e).forEach(e=>e.target="new"))});const g=we(e.getIndexedEvents(Xr));Ug(e,Xr,{...t,seen:!u,id:g,properties:{...t.properties,...t.properties.text&&{text:xm(e,t.properties.text)}}}),e.updateChat(Xr,{properties:{fakeAgentMessageId:g}}),e.setApplicationState({invitation:{...e.getApplicationState("invitation"),current:g}}),t.properties.receivedFirstTime&&e.setCurrentView("Chat"),Fa(e,"maximized")||(ba(e,t)&&t.properties.receivedFirstTime&&!u?nh(e,{shouldMaintainModality:!1}):ba(e,t)||rh(e,!0)),u||Mh(e,t),e.emit("render-minimized")},Ph=(e,t)=>{const n=(new Date).toISOString();e.setApplicationState({config:{...e.getApplicationState("config"),features:{...e.getApplicationState("config").features,ticketForm:{...e.getApplicationState("config").features.ticketForm,additionalInfo:{lastDisplayedReason:t,lastDisplayedAt:n}}}}}),Rh(e,e.getView("Chat/ticketForm"))},Rh=(e,t)=>{const n={formType:t.type,formId:t.id,fields:t.fields};if(Vi(e)){const{id:t}=e.getLastEvent(Xr);return e.updateEvent(Xr,t,{properties:n})}const r=we(e.getIndexedEvents(Xr));return Ug(e,Xr,{id:r,type:"form",author:"system",properties:n})},Oh=(e,t)=>{const n=e.getView("Moment");if(n.show&&!t.wasTriggeredByGreeting)return n.data.url===t.url?void e.emit("request_expand_moment"):void e.emit("request_expand_moment",{nextMoment:t});Om(t.url)?(e.updateView("Moment",{show:!0,data:t}),n.show&&e.emit("request_expand_moment")):Ng(e,Xr,{text:"Link attached to the button is invalid."})},Bh=e=>{const{productActionButton:t,state:n}=e.getApplicationState("lightbox");if("closing"!==n&&t&&Mi(e,Xr,t.thread)&&("add_to_cart"!==t.type||!e.getApplicationState("pendingProductCardKeys").includes(t.addedKey))&&(Gg(e,{state:"closing"}),t.postback&&ch(e,{eventId:t.postback.eventId,postback:t.postback.payload}),"open_external"===t.type)){const n=e.getEvent(Xr,t.eventId);Oh(e,{url:t.value,title:t.label,source:"product_card",displayMode:"ecommerce",event:n})}},jh=function(e,t){void 0===t&&(t=!1),e.updateView("Moment",{show:!1,data:{}}),t&&rh(e)},qh=(e,t)=>{e.requestUpdateUser(e.getSessionUser().id,t)},Uh=(e,t)=>{const n=e.getSessionUser().id;var r;null!==e.getUser(n).serverId&&e.clearUserServerId(n),e.setUserServerId(n,t),e.setApplicationState({testGroup:(r=t,Bg(r)%2?"A":"B")})},Nh=function(e,t){void 0===t&&(t=void 0);const n=Li(e,t);n&&e.removeEvent(Xr,n)},Lh=e=>{Nh(e,"prechat")},Vh=e=>{Nh(e,"postchat")},Gh=e=>{Nh(e,"ticket")},Zh=e=>{const t=e.getEvents(Xr);for(const n of t)"form"===n.type&&!n.properties.answered&&cd(n.properties.formType)&&e.removeEvent(Xr,n.id)},Hh=(e,t,n)=>{const r=ke("error.details.errors",e);if(!r)return void n();const i=r.reduce((e,n)=>"requester.email"===n.field?{...e,email:t("invalid_email")}:"requester.name"===n.field?{...e,name:n.message}:e,{});a(i)?n():n(i)},Wh=e=>{(e=>{const{lastThread:t,currentAgent:n,queued:r}=e.getChat(Xr).properties;return!(!hi(e)||n||r)&&!_e(e=>{let{type:n,thread:r}=e;return"email_prompt"===n&&r===t},e.getEvents(Xr))})(e)&&(e=>{const t=Kr,{properties:{lastThread:n}}=e.getChat(Xr);e.hasEvent(Xr,t)&&e.removeEvent(Xr,t),pa(e).find(e=>"form"===e.type&&"ask_for_email"===e.properties.formId)||e.addEvent(Xr,{id:t,serverId:null,seen:!0,type:Kr,author:"system",thread:n})})(e)},Qh=function(e,t,n,r){void 0===r&&(r=!1),p(n.type,["message","webview"])&&nh(e);const i=di(e);switch(e.emit("rich_greeting_button_clicked",{button:n,event:e.getEvent(i,t)}),n.type){case"message":bh(e,i,n.text,{event:t,button:n});break;case"webview":Oh(e,{url:n.value,wasTriggeredByGreeting:r,source:r?"targeted_message":"rich_message",event:e.getEvent(i,t)});break;case"cancel":Kh(e,i,t);break;case"copy":return void vs(n.value)}},Yh=e=>{e.emit("start_thread")},Jh=function(e,t,n){void 0===n&&(n="button");const r=e.getChat(Xr),i=p("image",t.type);(p(["clipboard","drag"],n)||Math.random()<.1)&&bg("file_upload_added",{uploadSource:n}),ls(e,Xr)&&lm(e),e.sendEvent(Xr,{type:"file",thread:r.properties.lastThread,properties:{name:t.name.substring(0,255),progress:0,finished:!1,failed:!1,failReason:null,fileType:i?"image":"other",url:i?URL.createObjectURL(t):null,uploadSource:n}},{file:t})},Xh=function(e,t,n){let{force:r=!1,preventMute:i=!1,skipAnimations:a=!1}=void 0===n?{}:n;!i&&va(e)&&fa(e)&&e.setApplicationState({greetingsMuted:!0}),fs(e)&&!r||(ps(e)?Jg(e,t,{skipAnimations:a}):(e.removeEvent(Xr,t),setTimeout(()=>e.emit("render-minimized"),0)))},Kh=(e,t,n)=>{const r=e.getChat(t),{mobile:i}=e.getApplicationState(),a=e.getEvent(t,n);var s;!r.active&&a&&(jg(e.getSessionUser().serverId,.01)&&(s={mobile:i,greetingId:a.properties.id,greetingUniqueId:a.properties.uniqueId,greetingType:a.properties.type,greetingSubtype:a.properties.subtype,greetingAddon:a.properties.addon||"none",minimizedType:wi(e)},bg("greeting_canceled",s)),e.emit("request_cancel_greeting",a))},em=function(e,t,n){let{scheduleRerender:r=!0}=void 0===n?{}:n;const i=e.getView("minimized"),a={...i,...t};JSON.stringify(i)!==JSON.stringify(a)&&(e.updateView("minimized",a),r&&setTimeout(()=>e.emit("render-minimized"),0))},tm=(e,t)=>{const{session:n,transitionState:r}=t,i={...e.getApplicationState("visitorCounter")||{},...n&&{session:n},transitionState:r,...void 0!==t.hidden?{hidden:t.hidden}:{},isVisible:!!r&&"hidden"!==r};e.setApplicationState({visitorCounter:i}),e.emit("render-minimized")},nm=(e,t)=>{const{transitionState:n}=t,r={...e.getApplicationState("googleReviews"),transitionState:n,...void 0!==t.hidden?{hidden:t.hidden}:{},isVisible:!!n&&"hidden"!==n};e.setApplicationState({googleReviews:r}),e.emit("render-minimized")},rm=(e,t)=>{const n=e.getApplicationState("contactInvitation"),r=t.transitionState??n.transitionState,i={...n,transitionState:r,...void 0!==t.hidden?{hidden:t.hidden}:{},isVisible:!!r&&"hidden"!==r,hasSeen:void 0!==t.hasSeen?t.hasSeen:n.hasSeen};e.setApplicationState({contactInvitation:i}),t.transitionState&&e.emit("render-minimized")},im=(e,t)=>{const n=e.getApplicationState("chatBotGreeting"),r=t.transitionState??n.transitionState,i={...n,transitionState:r,isVisible:!!r&&"hidden"!==r,text:void 0!==t.text?t.text:n.text,hidden:void 0!==t.hidden?t.hidden:n.hidden,hasSeen:void 0!==t.hasSeen?t.hasSeen:n.hasSeen};e.setApplicationState({chatBotGreeting:i}),t.transitionState&&e.emit("render-minimized")},am=(e,t)=>{const{history:n}=e.getApplicationState("locationHistory"),r=(new Date).getTime();if(n.length&&Ie(n)===t)return void e.setApplicationState({locationHistory:{history:n,updatedAt:r}});const i=[].concat(n.slice(-10),[t]);e.setApplicationState({locationHistory:{history:i,updatedAt:r}})},sm=T(500,e=>{e.emit("scroll_to_bottom")}),om=e=>{sm(e)},lm=e=>{e.getApplicationState().isPreview||(e.setApplicationState({privacyPolicyBannerState:"closing"}),setTimeout(()=>{e.setApplicationState({privacyPolicyBannerState:"hidden"})},Jp))},cm=function(e,t,n){let{state:r,closed:i,isPrivacyPolicyBannerClosing:a,isSuggestedQuestionsClosing:s,closingGreetingId:o,greetingAnimationState:l,deferred:c,autoExpanded:u}=t;void 0===n&&(n={render:!0,scheduledRender:!1});const d=e.getApplicationState("minimizedMessageInput"),p="boolean"==typeof u?u:"full"===r&&d.autoExpanded;e.setApplicationState({minimizedMessageInput:{...d,state:r,..."boolean"==typeof i&&{closed:i},...void 0!==a&&{isPrivacyPolicyBannerClosing:a},...void 0!==s&&{isSuggestedQuestionsClosing:s},..."full"===r&&{isSuggestedQuestionsClosing:!1},...("string"==typeof o||null===o)&&{closingGreetingId:o},..."string"==typeof l&&{greetingAnimationState:l},..."boolean"==typeof c&&{deferred:c},autoExpanded:p,..."hidden"===r&&{isFocused:!1,autoExpanded:!1}}}),n.render&&(n.scheduledRender?setTimeout(()=>e.emit("render-minimized"),0):e.emit("render-minimized"))},um=(e,t)=>{const n=((e,t)=>{if(t.id===e.getSessionUser().serverId||"customer"===t.type){const e={id:t.id,type:"customer"};return t.name&&"Customer"!==t.name&&(e.name=t.name),t.email&&(e.email=t.email),t.phoneNumber&&(e.phoneNumber=t.phoneNumber),t.sessionFields&&(e.properties=t.sessionFields),e}return{id:t.id,type:t.type,name:t.name,avatar:t.avatar?`https://${f(t.avatar)}`:"",properties:{jobTitle:t.jobTitle,isBot:t.isBot||!1,...t.botType&&{botType:t.botType}}}})(e,t);if(e.getSessionUser().serverId!==n.id)return e.getUser(n.id)?n.properties?(n.properties.isBot&&e.updateUser(n.id,{properties:{isBot:!0}}),void(n.properties.botType&&e.updateUser(n.id,{properties:{botType:n.properties.botType}}))):void _g("no_parsed_user_properties",new Error,{meta:JSON.stringify({user:t,parsedUser:n})}):void e.addUser(n);e.updateUser(e.getSessionUserId(),ze(["name","email","phoneNumber","properties"],n))},dm=(e,t)=>{if(Ai(e,Xr)&&Fa(e,"maximized"))return;if(t.properties.id!==e.getApplicationState("welcomeMessageId"))return;e.setApplicationState({disableSendingMessage:!1}),e.updateChat(Xr,{properties:{agentActivity:null,awaitingWelcomeMessage:!1}});const n=is(e)&&"questions_only"===e.getApplicationState("welcomeMessageScope")&&!Fa(e,"maximized"),r=!ia(e)&&(!Ui(e)||n);if(r){if(is(e)){const t=Ei(e,Xr);if(ya(e))return;t&&e.removeEvent(Xr,t.id)}gm(e,{...t,seen:!0}),e.updateChat(Xr,{properties:{fakeAgentMessageId:t.id}})}const{quickReplies:i}=t.properties;r&&is(e)&&(null==i?void 0:i.length)&&(e.setApplicationState({suggestedQuestions:{animation:{questionIndex:0,phase:"typing"}}}),e.emit("render-minimized"))},pm=(e,t,n)=>{"message"===t&&e.getApplicationState("readyState")!==Or&&((e,t)=>{const{author:n,timestamp:r,properties:{text:i}}=e.getEvent(Xr,t),a=e.getUser(n),s=a.type,o={text:i,timestamp:Math.floor(r/1e3),user_type:"agent"===s?s:"visitor"};"agent"===s?(o.agent_name=a.name,o.agent_login=a.id):o.visitor_name=a.name,e.emit("on_message",o)})(e,n)},gm=(e,t)=>{Ug(e,Xr,t),pm(e,t.properties.serverType,t.id)},hm=e=>{const t=e.getApplicationState("isLargeWidget");e.setApplicationState({isLargeWidget:!t}),e.emit("resize-to-theme-size",{animated:!0})},mm=(e,t)=>{e.setApplicationState({minimizedMessageInput:{...e.getApplicationState("minimizedMessageInput"),isFocused:t}})},fm=e=>{e.emit("resize-to-theme-size"),cm(e,{state:"full",autoExpanded:!0},{render:!0})},_m=e=>{e.setApplicationState({suggestedQuestionsAutoExpandDismissed:!0}),cm(e,{state:"classic",autoExpanded:!1},{render:!0})},bm=()=>{const e=n(window.location.search);return parseInt((()=>{const e=String(window.location).match(/licen(?:s|c)e\/g?(\d+)/);return e?e[1]:null})()||e.license_id,10)},vm=()=>n(window.location.search).organization_id||"",ym=e=>{const t=parseInt(e,10);return t>-1?t:null},wm=e=>"group"in e?ym(e.group):"groups"in e?ym(e.groups):null,km=()=>"1"===nt("unique_groups",window.location.search)||"1"===nt("unique_group",window.location.search),xm=function(e,t,n){var r;void 0===n&&(n={});const i=void 0!==n.name?n.name:(e=>{const{name:t}=e.getSessionUser();return t||e.localize("client")})(e),a=void 0!==n.agent?n.agent:(()=>{try{return(e=>{const t=pi(Xr,e);if(!t)throw new Error("Current chat agent is undefined");if(!t.name)throw new Error("Current chat agent name is undefined");return t.name})(e)}catch{return""}})(),s=(null==(r=e.getSessionUser())?void 0:r.properties)||{};return t.replace(/%name%/g,i).replace(/%agent%/g,a).replace(/%customer-field\.([^%]+)%/g,(e,t)=>String(s[t]??""))},Im=e=>D(e)>.7,Sm=e=>D(e)<=.179,Em=e=>{var t;return Boolean(null==(t=e.properties.license.bb9e5b2f1ab480e4a715977b7b1b4279)?void 0:t.messaging_in_queue_enabled)},Am=e=>{var t;return Boolean(null==(t=e.properties.group.bb9e5b2f1ab480e4a715977b7b1b4279)?void 0:t.homescreen_enabled)},Tm=e=>{var t;return Boolean(null==(t=e.properties.license.bb9e5b2f1ab480e4a715977b7b1b4279)?void 0:t.utm_params_enabled)},Cm=e=>{var t;return Boolean(null==(t=e.properties.license.bb9e5b2f1ab480e4a715977b7b1b4279)?void 0:t.add_to_website_enabled)},zm=e=>`https://${e}.${"api"===e?"livechatinc":"livechat"}.com`,Dm=()=>{const e=document.createElement("video"),t=document.createElement("canvas");return navigator.mediaDevices&&navigator.mediaDevices.getDisplayMedia?navigator.mediaDevices.getDisplayMedia({video:{displaySurface:"browser"},audio:!1}).then(t=>(e.srcObject=t,e.play())).then(()=>new Promise(e=>{setTimeout(e,150)})).then(()=>{t.width=e.videoWidth,t.height=e.videoHeight;t.getContext("2d").drawImage(e,0,0,e.videoWidth,e.videoHeight);const n=((e,t)=>{const[n,r]=e.split(","),i=n.match(/:(.*?);/)[1],a=atob(r);let s=a.length;const o=new Uint8Array(s);for(;s--;)o[s]=a.charCodeAt(s);return new File([o],t,{type:i})})(t.toDataURL("image/png"),"screenshot.png");return e.srcObject.getTracks().forEach(e=>e.stop()),n}):Promise.reject(new Error("Screen sharing is not supported"))},$m=e=>Sm(e)?E(.1,w(.1,e)):E(.2,y(.15,e));function Mm(e,t,n){if(e.startsWith(n))return e;const r=[e,t],i=JSON.stringify(r),a=btoa(i),s=new URL("/v1.0/t/link",n);return s.searchParams.set("d",a),s.toString()}function Fm(e){return"https://cdn.livechat-files.com/api/file/lc/main/default/logo/sz2tt7jpJ6VJwBo.png"===z(e)}const Pm=e=>{const{x:t,y:n,width:r,height:i}=e.target.getBoundingClientRect();return{x:t,y:n,width:r,height:i}},Rm=(e,t)=>{const{name:n,email:r,phoneNumber:i,suggestedEmail:a}=ge(e=>"string"==typeof e?_(e):e,Ce(["email","name","phoneNumber","suggestedEmail"],e)),s={email:r||a,phone:i};return n===t("client")?s:{...s,name:n}},Om=e=>!!e&&(e=>{const t=st(e);return!t||"https:"===t||!1})(vt(e)),Bm=e=>({id:e.id,name:e.title??"",text:e.description,icon:e.icon,action:{label:e.action.label,type:"button",value:e.action.url},properties:{}}),jm=(e,t)=>{var n,r,i,s;const o=gi("logo",e),l=o.enabled?z(o.path):"",c=gi("boosters",e),u=null==(n=c.items)?void 0:n.find(e=>It(e.id)),d=null==(r=c.items)?void 0:r.find(e=>xt(e.id)),p=null==(i=c.items)?void 0:i.find(e=>"links"===e.id),g=null==(s=e.getApplicationState("config").properties.license.feade1d6c3f17748ae4c8d917a1e1068)?void 0:s.hdLicenseID,h="number"==typeof g&&g>-1,m=e.getApplicationState("config").properties.group,f={apps:[],channels:[]};u&&f.apps.push({...Bm(u),trademarkLink:"https://www.knowledgebase.com/?utm_source=chat_window&utm_medium=referral&utm_campaign=home_screen",trademarkLinkAnchor:"Powered by KnowledgeBase"}),d&&h&&(f.apps.push(Bm(d)),e.on("send_helpdesk_form",n=>{t(n).then(t=>e.emit("send_helpdesk_form_success",t)).catch(t=>e.emit("send_helpdesk_form_error",t))}),e.addView("HelpdeskTicketForm",{isLoading:!0,hasFetchingError:!1})),a(m)||fe(Tt()).forEach(e=>{let[t,n]=e;const r=m[n];r&&f.channels.push({name:t,url:r.button_url_v2})}),e.addView("Homescreen",f),zh(e,"livechatIntegration",{name:"livechat_integration",enabled:!0,properties:{organizationId:e.getApplicationState().organizationId}}),p&&zh(e,"links",{enabled:!0,name:"links",properties:{links:p.links}}),e.setApplicationState({header:{text:"",logo:l,backgroundType:"gradient"}})},qm=(e,t)=>{let n;return r=>{const i=e(r);if(void 0===i)return n;const a=t(r,i);return n=a,a}},Um=(e,t)=>document.referrer?f(r(document.referrer)||""):e?`lc${e}`:`orgId${t}`,Nm={};function Lm(e,t){let{query:n={},jsonpParam:r="jsonp",callbackName:i}=void 0===t?{}:t;return new Promise((t,a)=>{Qe().then(s=>{const o=document.createElement("script"),l=i||we(Nm);Nm[l]=!0;const c=`__${l}`,u=window;u[c]=e=>{delete Nm[l],delete u[c],Ye(o),t(e)},o.src=`${e}?${Ke({...n,[r]:c})}`,o.addEventListener("error",()=>{setTimeout(()=>{const e=new Error("JSONP request failed.");e.code="JSONP_REQUEST_FAILED",a(e)},100)}),s.appendChild(o)})})}const Vm=/\.([a-z]{1,})$/i,Gm=e=>{let{__priv:t}=e;const n={enabled:!0,x:parseInt(t.group["embedded_chat.eye_grabber.x"])+15,y:parseInt(t.group["embedded_chat.eye_grabber.y"]),src:z(t.group["embedded_chat.eye_grabber.path"])};if(-1!==n.src.indexOf("/default/eyeCatchers/")){const e=n.src.match(Vm)[1];n.srcset={"1x":n.src,"2x":n.src.replace(new RegExp(`\\.${e}`,"i"),`-2x.${e}`)}}return n},Zm=e=>({"x-region":e.region??""}),Hm=(e,t)=>`${(e=>{let{region:t}=e;return`https://api${(e=>"fra"===e||"eu-west3"===e?"-fra":"")(t)}.livechatinc.com`})(t)}/v3.6/customer/action/${e}`,Wm=e=>{let{licenseId:t,organizationId:n}=e;return Lm(`https://api.livechatinc.com/global-mapper/${t?`lc_license_id/${t}`:`organization_id/${n}`}/region`,{callbackName:"lc_region"}).then(e=>e.region).catch(()=>{const e=new Error("Fetch region failed");throw e.code="FETCH_REGION_FAILED",e})},Qm=["ACCESS_NOT_RESOLVED","CUSTOMER_BANNED","FETCH_REGION_FAILED","JSONP_REQUEST_FAILED"],Ym=e=>{if(!Qm.includes(null==e?void 0:e.code))throw e;console.warn(`[LiveChat] ${e.message}`)},Jm=function(e,t){let{validateDefaultWidget:n=!0}=void 0===t?{}:t;return Lm(Hm("get_dynamic_configuration",e),{query:{...Zm(e),...e.organizationId?{organization_id:e.organizationId}:{},...e.licenseId?{license_id:e.licenseId}:{},client_id:"c5e4f61e1a6c3b1521b541bc5c5a2ac5",url:lt(e.url,["cw_configurator","dev_language","dev_enable_textapp","dev_theme_variant","dev_theme_name","dev_minimized_type","dev_screen_position","dev_offset_x","dev_offset_y","dev_show_logo","dev_show_avatar","dev_sounds_enabled","dev_rating_enabled","dev_transcript_enabled","dev_company_logo_url","dev_agent_avatar_url"]),..."number"==typeof e.groupId&&{group_id:e.groupId},...e.channelType&&{channel_type:e.channelType},...e.skipCodeInstallationTracking&&{test:1},...e.productName&&{origin:e.productName},...e.integrationName&&{implementation_type:e.integrationName}}}).then(t=>{if(t.error)switch(t.error.type){case"misdirected_request":return Jm({...e,region:t.error.data.region});case"license_not_found":{if("direct_link"===e.channelType){const t=Ke({utm_source:"expired_chat_link",utm_medium:"referral",utm_campaign:`lc_${e.licenseId}`});window.location.replace(`https://www.livechat.com/expired-chat-link/?${t}`)}const t=new Error("License not found");throw t.code="LICENSE_NOT_FOUND",t}default:{const e=new Error(t.error.message);throw e.code=t.error.type.toUpperCase(),e}}if(e.licenseId!==g&&e.organizationId!==Dr||(t.default_widget="livechat"),n&&"livechat"!==t.default_widget){const e=new Error(`The 'default_widget' is not 'livechat', but instead: '${t.default_widget}'`);throw e.code="DEFAULT_WIDGET_NOT_LIVECHAT",e.organizationId=t.organization_id,e.defaultWidget=t.default_widget,e}if(!t.livechat_active){if("direct_link"===e.channelType){const t=Ke({utm_source:"expired_chat_link",utm_medium:"referral",utm_campaign:`lc_${e.licenseId}`});window.location.replace(`https://www.livechat.com/expired-chat-link/?${t}`)}const t=new Error("License expired");throw t.code="LICENSE_EXPIRED",t}if(!t.livechat.domain_allowed){const e=new Error("Current domain is not added to the allowlist.");throw e.code="DOMAIN_NOT_ALLOWED",e}return r=t,i=e.region,{organizationId:r.organization_id,groupId:r.livechat.group_id,clientLimitExceeded:r.livechat.client_limit_exceeded,configVersion:r.livechat.config_version,localizationVersion:r.livechat.localization_version,onlineGroupIds:r.livechat.online_group_ids||[],region:i||null,language:r.livechat.language,aiAgentActive:r.livechat.ai_agent_active};var r,i})},Xm=e=>{var t,n;const r="feade1d6c3f17748ae4c8d917a1e1068",i=Boolean(null==(t=e.properties.group[r])?void 0:t.forwardTicketFormToHelpdesk),a="1"===e.__priv.license["helpdesk.inbound_forwarding"],s=null==(n=e.properties.license[r])?void 0:n.hdLicenseID;return"number"==typeof s&&s>-1&&(i||a)},Km=(e,t)=>t.includes(e)?e:t[0],ef=(e,t)=>e,tf=e=>Lm(Hm("get_configuration",e),{callbackName:"lc_static_config",query:{organization_id:e.organizationId,version:e.version,...Zm(e),..."number"==typeof e.groupId&&{group_id:e.groupId}}}).then(e=>(e=>{const{buttons:t,allowed_domains:n,prechat_form:r,ticket_form:i,__priv:a,properties:s,...o}=e,l=a.group,c=ef("boolean"==typeof a.enable_textapp?a.enable_textapp:void 0),u=ef(Km(l["chat_window.new_theme.name"],["smooth","modern"])),d=ef(Km(l["chat_window.new_theme.variant"],["light","dark"])),p=l["chat_window.new_theme.background_color"],g=ef(Km(l["chat_window.theme.minimized"],["circle","bar"])),h=ef("1"===l["chat_window.display_avatar"]),m=ef("0"===l["chat_window.disable_sounds"]),f=ef("1"===l["rate_me.enabled"]),_=ef("1"===l["chat_window.display_transcript_button"]),b=ef("1"===l["chat_window.display_logo"]),v=ef(l["chat_window.logo_path"]),y=ef(l.language),w=ef(Km(l["chat_window.screen_position"],["right","left"])),k=ef(parseInt(l["chat_window.offset_x"])),x=ef(parseInt(l["chat_window.offset_y"])),I="0"===a.group.tickets_enabled,S=!Boolean(a.disable_native_tickets)&&Boolean(i),E=Xm(e),A=c?Boolean(i):I||E||S;return{...o,...r&&{prechatForm:Yd(r)},...A&&i&&{ticketForm:Yd(i)},properties:s,buttons:t.map(e=>"image"===e.type?{id:e.id,type:e.type,onlineValue:z(e.online_value),offlineValue:z(e.offline_value)}:{id:e.id,type:e.type,onlineValue:e.online_value,offlineValue:e.offline_value}),...n&&{allowedDomains:n},__unsafeProperties:{...a.s&&{s:!0},..."boolean"==typeof c?{enableTextApp:c}:{},group:{chatBoosters:a.group.chat_boosters,disabledMinimized:"1"===a.group["chat_window.disable_minimized"],disabledMinimizedOnMobile:"1"===a.group["chat_window.mobile_disable_minimized"],disabledOnMobile:"1"===a.group["chat_window.hide_on_mobile"],eyeCatcher:"1"===a.group["embedded_chat.display_eye_catcher"]?Gm(e):{enabled:!1},hasAgentAvatarsEnabled:h,hasCustomMobileSettings:"1"===a.group["chat_window.custom_mobile_settings"],hasHiddenTrademark:"1"===a.group["chat_window.hide_trademark"],hasSoundsEnabled:m,initiallyHidden:"1"===a.group["chat_window.hide_on_init"]||"1"===a.group["chat_window.disable_minimized"],initiallyHiddenOnMobile:"1"===a.group["chat_window.mobile_hide_on_init"]||"1"===a.group["chat_window.mobile_disable_minimized"],hideOnInit:"1"===a.group["chat_window.hide_on_init"],language:y,linksUnfurlingEnabled:"1"===a.group.links_unfurling,privacyPolicy:{enabled:"1"===a.group["privacy_policy.enabled"],text:a.group["privacy_policy.text"]},logo:b?{enabled:!0,src:v}:{enabled:!1},minimizedType:g,minimizedTypeOnMobile:a.group["chat_window.mobile_minimized_theme"],offlineMessagesEnabled:I,offsetX:k,offsetXOnMobile:parseInt(a.group["chat_window.mobile_offset_x"]),offsetY:x,offsetYOnMobile:parseInt(a.group["chat_window.mobile_offset_y"]),prechatFormAfterGreetingEnabled:"1"===a.group.pre_chat_survey_after_greeting,ratingEnabled:f,screenPosition:w,screenPositionOnMobile:Km(a.group["chat_window.mobile_screen_position"],["right","left"]),transcriptButtonEnabled:_,theme:{name:u,variant:d,customJson:a.group["chat_window.new_theme.custom_json"],agentbarBackgroundColor:a.group["chat_window.new_theme.agentbar_background_color"],agentbarText:a.group["chat_window.new_theme.agentbar_text"],agentMessageColorBackground:a.group["chat_window.new_theme.agent_message_color_background"],agentMessageColorText:a.group["chat_window.new_theme.agent_message_color_text"],backgroundColor:p,ctaColor:a.group["chat_window.new_theme.cta_color"],minimizedColorBackground:a.group["chat_window.new_theme.minimized_color_background"],minimizedColorIcon:a.group["chat_window.new_theme.minimized_color_icon"],minimizedColorText:a.group["chat_window.new_theme.minimized_color_text"],systemMessageColor:a.group["chat_window.new_theme.system_message_color"],titlebarBackgroundColor:a.group["chat_window.new_theme.titlebar_background_color"],titlebarText:a.group["chat_window.new_theme.titlebar_text"],visitorMessageColorBackground:a.group["chat_window.new_theme.visitor_message_color_background"],visitorMessageColorText:a.group["chat_window.new_theme.visitor_message_color_text"]}},license:{creditCardMaskingEnabled:"1"===a.license.mask_credit_cards,nonProfit:"1"===a.license.non_profit,licenseinboundForwardingToHelpdeskEnabled:"1"===a.license["helpdesk.inbound_forwarding"]},helpdeskIntegrationEnabled:E,ticketFormMode:(T=e,C=Boolean(c),void 0===C&&(C=Boolean(T.__priv.enable_textapp)),C?"1"===T.__priv.group.tickets_enabled?"helpdesk":"offline_message":Xm(T)?"helpdesk":"0"===T.__priv.group.tickets_enabled?"offline_message":"livechat")}};var T,C})(e)),nf=e=>Lm(Hm("get_localization",e),{callbackName:"lc_localization",query:{organization_id:e.organizationId,version:e.version,language:e.language,...Zm(e),..."number"==typeof e.groupId&&{group_id:e.groupId}}}).then(e=>Se(e=>e.toLowerCase(),e));export{Wa as $,vl as A,li as B,Er as C,fe as D,Br as E,Ns as F,Bs as G,$s as H,So as I,dn as J,Ws as K,Xr as L,xo as M,Zc as N,Fr as O,kg as P,wi as Q,Cr as R,zr as S,ra as T,hi as U,Sg as V,km as W,mi as X,Si as Y,pa as Z,Ie as _,bg as a,nh as a$,es as a0,yg as a1,ge as a2,Hs as a3,Is as a4,Es as a5,Mo as a6,Ne as a7,cm as a8,me as a9,bh as aA,Ui as aB,Yh as aC,vh as aD,pn as aE,vg as aF,Ma as aG,Vg as aH,Qg as aI,Jg as aJ,bm as aK,wm as aL,jr as aM,Je as aN,We as aO,Ye as aP,nt as aQ,xi as aR,$g as aS,Me as aT,ke as aU,Ec as aV,pi as aW,Ni as aX,xm as aY,os as aZ,Ii as a_,Zt as aa,Or as ab,zg as ac,Cg as ad,Ym as ae,ze as af,we as ag,bl as ah,ps as ai,ns as aj,Fo as ak,oi as al,ba as am,gi as an,ss as ao,_s as ap,tl as aq,el as ar,Xo as as,fm as at,Wo as au,hs as av,ya as aw,fs as ax,En as ay,Ha as az,Et as b,Sr as b$,rh as b0,Pg as b1,Qe as b2,Ap as b3,Dh as b4,jm as b5,Yi as b6,St as b7,Ve as b8,Fn as b9,en as bA,jn as bB,lr as bC,xe as bD,Vn as bE,mr as bF,pr as bG,gr as bH,ar as bI,tr as bJ,er as bK,Kn as bL,Ee as bM,hr as bN,zn as bO,Qn as bP,ir as bQ,Hn as bR,gn as bS,je as bT,Ae as bU,mn as bV,_e as bW,Un as bX,qn as bY,Cn as bZ,Bn as b_,fr as ba,dr as bb,ur as bc,br as bd,Ir as be,_r as bf,xr as bg,wr as bh,vr as bi,Yn as bj,Kt as bk,Wn as bl,cr as bm,nn as bn,or as bo,Tn as bp,sr as bq,kr as br,yr as bs,rr as bt,nr as bu,Xn as bv,Jn as bw,fn as bx,sn as by,tn as bz,he as c,ho as c$,ug as c0,$o as c1,cd as c2,Im as c3,Gg as c4,Oo as c5,Wg as c6,Bh as c7,Mi as c8,Nt as c9,$a as cA,ms as cB,Ra as cC,ea as cD,To as cE,Sc as cF,im as cG,xt as cH,Mm as cI,Ks as cJ,Js as cK,Ys as cL,ao as cM,so as cN,lo as cO,io as cP,no as cQ,to as cR,ro as cS,oo as cT,eo as cU,_o as cV,bo as cW,yo as cX,vo as cY,po as cZ,go as c_,Gt as ca,vs as cb,tt as cc,rl as cd,cc as ce,st as cf,Ya as cg,Po as ch,Ro as ci,qi as cj,Ke as ck,ii as cl,Pm as cm,Oh as cn,ai as co,Ba as cp,vt as cq,yt as cr,it as cs,jh as ct,qh as cu,lh as cv,Pa as cw,yh as cx,ch as cy,di as cz,ot as d,Ng as d$,fo as d0,mo as d1,Na as d2,em as d3,La as d4,il as d5,al as d6,ol as d7,sl as d8,ll as d9,Oi as dA,va as dB,Ig as dC,ah as dD,Yg as dE,Qo as dF,Yo as dG,Jo as dH,_l as dI,dl as dJ,gl as dK,ml as dL,fl as dM,hl as dN,pl as dO,Ri as dP,ts as dQ,oa as dR,ca as dS,Jh as dT,Vc as dU,Da as dV,Qt as dW,zo as dX,qa as dY,mh as dZ,ja as d_,ul as da,cl as db,Fe as dc,Go as dd,Ho as de,Bo as df,jo as dg,qo as dh,Qh as di,_m as dj,Vo as dk,Lo as dl,gs as dm,Uo as dn,rs as dp,No as dq,mm as dr,th as ds,Ao as dt,Xg as du,Zo as dv,nl as dw,lm as dx,Jp as dy,Ko as dz,zh as e,bu as e$,la as e0,ua as e1,$i as e2,Ih as e3,ci as e4,fh as e5,kh as e6,Do as e7,ma as e8,Ia as e9,Ja as eA,Rm as eB,ui as eC,Kr as eD,Di as eE,wa as eF,Gi as eG,Ce as eH,Gr as eI,Vr as eJ,gh as eK,dh as eL,ph as eM,Zg as eN,Hg as eO,up as eP,qm as eQ,Aa as eR,yi as eS,Dm as eT,ha as eU,Re as eV,Kc as eW,Xc as eX,Qc as eY,Hc as eZ,Yc as e_,Va as ea,us as eb,ls as ec,Pi as ed,ei as ee,Jt as ef,Qa as eg,Um as eh,Ka as ei,qr as ej,Za as ek,Qi as el,Wi as em,aa as en,xa as eo,Ga as ep,Fm as eq,Vi as er,hm as es,ta as et,$r as eu,Ki as ev,Ji as ew,De as ex,It as ey,fi as ez,Io as f,Zh as f$,sd as f0,yu as f1,vu as f2,nu as f3,hu as f4,Au as f5,Ed as f6,Pu as f7,ad as f8,du as f9,wu as fA,fu as fB,mu as fC,pu as fD,uu as fE,cu as fF,lu as fG,su as fH,au as fI,iu as fJ,ru as fK,tu as fL,eu as fM,Ar as fN,Zi as fO,ds as fP,Sh as fQ,Uh as fR,zi as fS,ih as fT,Ug as fU,Lh as fV,gm as fW,ti as fX,ni as fY,pe as fZ,Vh as f_,Gu as fa,Du as fb,Zu as fc,ou as fd,od as fe,td as ff,id as fg,rd as fh,Yu as fi,Vu as fj,Ru as fk,ed as fl,Xu as fm,Iu as fn,_u as fo,op as fp,sp as fq,ap as fr,zu as fs,Eu as ft,xu as fu,gu as fv,Cu as fw,Tu as fx,Su as fy,ku as fz,zm as g,as as g$,wh as g0,sh as g1,Lg as g2,xh as g3,Wp as g4,om as g5,Rp as g6,na as g7,Ph as g8,Eh as g9,bi as gA,Xh as gB,xg as gC,Tr as gD,Hp as gE,ji as gF,Np as gG,Up as gH,Uc as gI,Yp as gJ,mp as gK,ag as gL,$h as gM,eg as gN,Ch as gO,tg as gP,Wh as gQ,hp as gR,gp as gS,fp as gT,Hh as gU,Tp as gV,Qs as gW,Xa as gX,Gp as gY,dm as gZ,As as g_,ri as ga,wg as gb,rg as gc,ng as gd,ig as ge,Ei as gf,pm as gg,Zp as gh,ve as gi,um as gj,eh as gk,Fh as gl,Mh as gm,Ci as gn,Bi as go,Xi as gp,Ea as gq,Ai as gr,Gh as gs,ia as gt,Ca as gu,hh as gv,Ti as gw,Vp as gx,Sp as gy,vi as gz,Us as h,_a as h0,si as h1,$p as h2,Mp as h3,Ep as h4,ys as h5,kp as h6,Ur as h7,Ac as h8,Tc as h9,Nr as ha,Lr as hb,rm as i,Fa as j,wl as k,_g as l,Se as m,nm as n,Wm as o,Ps as p,Jm as q,tf as r,ws as s,nf as t,de as u,Te as v,Th as w,tm as x,Ah as y,Sl as z};