@askly/widget 3.4.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/loader.js CHANGED
@@ -1 +1 @@
1
- !function(){"use strict";function t(t,e=[],o=[]){return e.length>0?e.some(e=>t.startsWith(e)):!(o.length>0)||!o.some(e=>t.startsWith(e))}const e="askly_scope_",o={};function n(t){delete o[t];try{window.localStorage.removeItem(t)}catch{}}function a(t){const r=t||"detect",s=function(t){var e;try{const e=window.localStorage.getItem(t);if(null!==e)return e}catch{}return null!==(e=o[t])&&void 0!==e?e:null}(e+r);s&&s!==r&&a(s),n("askly_visitor_"+r),n("askly_threads_"+r);for(const t of Object.keys(o))t.includes(r)&&!t.startsWith(e)&&delete o[t];try{const t=[];for(let e=0;e<window.localStorage.length;e++){const o=window.localStorage.key(e);o&&o.startsWith(`askly_conversations_${r}`)&&t.push(o)}t.forEach(t=>window.localStorage.removeItem(t))}catch{}}const r=["init","identify","reset","shutdown","unmount","open","close","toggle","show","hide","on","off","once","showSpace","showNewMessage","sendMessage","showArticle","startVoiceInput","stopVoiceInput","update","setLocale","updateTexts"],s={isOpen:!1,getUnreadCount:0,getVisitorId:""},i=["identify","open","toggle","show","showSpace","showNewMessage","sendMessage","showArticle","startVoiceInput","update"],l="#0f172a",d="http://www.w3.org/2000/svg";const u=":host{all:initial}.askly-chat-button{position:fixed;bottom:var(--ob,24px);width:60px;height:60px;border:0;padding:0;display:flex;align-items:center;justify-content:center;cursor:pointer;color:#fff;background:var(--a,"+l+");border-radius:23%;box-shadow:0 12px 32px rgba(15,23,42,.28),0 4px 10px rgba(15,23,42,.16);z-index:99999;font:28px -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;transition:transform .28s cubic-bezier(.2,.8,.2,1)}.shape-round{border-radius:50%}.askly-chat-button:hover{transform:translateY(-3px) scale(1.05)}.askly-chat-button:focus-visible{outline:3px solid var(--a,"+l+");outline-offset:3px}.r{right:var(--os,24px)}.l{left:var(--os,24px)}@media (max-width:600px){.askly-chat-button{bottom:var(--ob,16px)}.r{right:var(--os,16px)}.l{left:var(--os,16px)}}@media (prefers-reduced-motion:reduce){.askly-chat-button{transition:none}}";function c(t){try{const e=JSON.parse(t||"[]");return Array.isArray(e)&&e.some(t=>t&&Array.isArray(t.messages)&&t.messages.some(t=>t&&"user"===t.role))}catch{return!1}}function p(t,e){const o=t.getAttribute("data-org-server-route")||void 0,n=e=>{const o=t.getAttribute(e);return null===o?void 0:"true"===o};return{appId:e,orgServerRoute:o,organizationName:t.getAttribute("data-org-name")||void 0,position:t.getAttribute("data-position")||void 0,locale:t.getAttribute("data-locale")||void 0,hideLauncher:n("data-hide-launcher"),customLauncherSelector:t.getAttribute("data-custom-launcher-selector")||void 0,offset:(()=>{const e=t.getAttribute("data-offset-bottom"),o=t.getAttribute("data-offset-side");if(null!==e||null!==o)return{bottom:null===e||isNaN(parseInt(e))?void 0:parseInt(e),side:null===o||isNaN(parseInt(o))?void 0:parseInt(o)}})(),themeColor:t.getAttribute("data-theme-color")||void 0,theme:t.getAttribute("data-theme")||void 0,enableVoiceChat:t.getAttribute("data-enable-voice")?"true"===t.getAttribute("data-enable-voice"):void 0,voiceInput:(()=>{const e=t.getAttribute("data-voice-input");return"off"!==e&&"false"!==e&&("review"===e||"auto-send"===e?e:void 0)})(),welcomeMessage:t.getAttribute("data-welcome-message")||void 0,placeholderText:t.getAttribute("data-placeholder-text")||void 0,organizationLogo:t.getAttribute("data-logo")||void 0,buttonIcon:t.getAttribute("data-button-icon")||void 0,buttonShape:t.getAttribute("data-button-shape")||void 0,autoOpen:n("data-auto-open"),greeting:(()=>{if("false"===t.getAttribute("data-greeting"))return!1;const e=t.getAttribute("data-greeting-message")||void 0,o=t.getAttribute("data-greeting-delay"),a=null===o||isNaN(parseInt(o))?void 0:parseInt(o);return void 0!==e||void 0!==a?{message:e,delayMs:a}:n("data-greeting")})(),showTimestamp:n("data-show-timestamp"),soundEnabled:n("data-sound-enabled"),debug:n("data-debug"),soundVolume:t.getAttribute("data-sound-volume")?parseFloat(t.getAttribute("data-sound-volume")):void 0,poweredBy:t.getAttribute("data-powered-by")||void 0,userId:t.getAttribute("data-user-id")||void 0,timestamp:t.getAttribute("data-timestamp")?parseInt(t.getAttribute("data-timestamp")):void 0,signature:t.getAttribute("data-signature")||void 0,turnstileSiteKey:t.getAttribute("data-turnstile-sitekey")||void 0,excludePaths:t.getAttribute("data-exclude-paths")?t.getAttribute("data-exclude-paths").split(",").map(t=>t.trim()):void 0,includePaths:t.getAttribute("data-include-paths")?t.getAttribute("data-include-paths").split(",").map(t=>t.trim()):void 0}}const g="3.4.0",h=`https://unpkg.com/@askly/widget@${g}/dist/app/askly-app.js`,m=window,f=function(){const t=document.currentScript;if(t&&t.src)return t;const e=Array.from(document.querySelectorAll("script[src]")).filter(t=>/(^|\/)(widget|loader)\.js([?#]|$)/.test(t.src));return e.find(t=>t.hasAttribute("data-app-id")||t.hasAttribute("data-widget-id")||t.hasAttribute("data-org-id"))||e[0]||null}();let b;var y,v,w;m.Askly&&"function"==typeof m.Askly.init?(b=m.Askly,3===b.v&&b.q||console.warn("[Askly] The widget script is included twice; the second copy is ignored.")):(b=function(e){let o=e;const n={q:[],v:3,_r:[],_t:0};let p=null,g=!1,h=null,m=!1,f=null,b=[],y=!1,v=!1;const w=(...t)=>{h&&h.debug&&console.log("[Askly]",...t)},A=t=>t&&(t.appId||t.widgetId||t.orgId)||"detect",k=()=>{b.forEach(clearTimeout),b=[],f&&f.remove(),f=null},S=()=>{if(!h)return g=!0,Promise.resolve();if(!p){const t=(e,o)=>(w("Loading the widget from",e),import(/* webpackIgnore: true */ /* @vite-ignore */e).catch(n=>{if(o&&o!==e)return console.warn(`[Askly] Could not load the widget from ${e}; trying ${o}.`),t(o);p=null,k(),console.error("[Askly] The widget could not be loaded:",n)}));p=t(o.appUrl,o.fallbackUrl)}return p};let x=!1;const I=(t,e)=>{if("undefined"==typeof document||f)return;if(!document.body)return void document.addEventListener("DOMContentLoaded",()=>{!m||f||p||_(t)},{once:!0});const o=t.themeColor||e&&e.themeColor||l,a=t.buttonShape||e&&e.buttonShape||"round";f=document.createElement("askly-loader");const r=f.attachShadow({mode:"open"});let s=!1;try{const t=new CSSStyleSheet;t.replaceSync(u),r.adoptedStyleSheets=[t],s=!0}catch{}if(!s){const t=document.createElement("style");t.textContent=u,r.appendChild(t)}const i=document.createElement("button");i.className=`askly-chat-button shape-${a} ${"left"===t.position?"l":"r"}`,i.type="button",i.setAttribute("aria-label","Open support chat"),i.setAttribute("aria-expanded","false"),i.setAttribute("lang","en"),i.title="Open support chat",i.style.setProperty("--a",`var(--askly-brand, ${o})`),t.offset&&"number"==typeof t.offset.bottom&&i.style.setProperty("--ob",`${t.offset.bottom}px`),t.offset&&"number"==typeof t.offset.side&&i.style.setProperty("--os",`${t.offset.side}px`),t.buttonIcon&&"💬"!==t.buttonIcon?i.textContent=t.buttonIcon:i.appendChild(function(){const t=document.createElementNS(d,"svg");t.setAttribute("width","32"),t.setAttribute("height","32"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none");const e=document.createElementNS(d,"g");e.setAttribute("transform","translate(24 0) scale(-1 1)");const o=document.createElementNS(d,"path");return o.setAttribute("fill","currentColor"),o.setAttribute("fill-rule","evenodd"),o.setAttribute("clip-rule","evenodd"),o.setAttribute("d","M16 2H8C4 2 2 4 2 8V21C2 21.55 2.45 22 3 22H16C20 22 22 20 22 16V8C22 4 20 2 16 2ZM15.5 12.75H8.5C8.09 12.75 7.75 12.41 7.75 12C7.75 11.59 8.09 11.25 8.5 11.25H15.5C15.91 11.25 16.25 11.59 16.25 12C16.25 12.41 15.91 12.75 15.5 12.75Z"),e.appendChild(o),t.appendChild(e),t}()),i.addEventListener("mouseenter",()=>{S()}),i.addEventListener("focus",()=>{S()}),i.addEventListener("click",()=>{n.open()}),r.appendChild(i),document.body.appendChild(f)};let C=!1;const _=t=>{C=!0;const e=t.appId||t.widgetId||t.orgId,a=(t.orgServerRoute||"https://api.askly.co.in/api/messages/widget").replace(/\/widget$/,""),r=`askly_config_${e||"detect"}`;let s=null;try{s=JSON.parse(sessionStorage.getItem(r)||"null")}catch{}t.hideLauncher||I(t,s);let i=null;const l=o=>{i&&clearTimeout(i),i=null;const a=t.greeting;if(!0!==a&&(!1===a||o&&!1===o.greetingEnabled)||t.hideLauncher||function(t){try{return"1"===window.sessionStorage.getItem(`askly_greeting_dismissed_${t}`)}catch{return!1}}(e||"detect"))return;const r="object"==typeof a&&"number"==typeof a.delayMs?a.delayMs:o&&"number"==typeof o.greetingDelayMs?o.greetingDelayMs:3e3;i=setTimeout(()=>{S()},Math.max(0,r-400-(Date.now()-n._t))),b.push(i)};l(s);let d=!1;try{const t=`askly_conversations_${e||"detect"}`;for(let e=0;e<localStorage.length;e++){const o=localStorage.key(e)||"";if(0===o.indexOf(t)&&c(localStorage.getItem(o))){d=!0;break}}}catch{}(t=>{const e=window.requestIdleCallback;e?e(t,{timeout:4e3}):b.push(setTimeout(t,1500))})(()=>{m&&!p&&(d?S():((()=>{if(p||x||"undefined"==typeof document)return;x=!0;const t=document.createElement("link");t.rel="modulepreload",t.href=o.appUrl,document.head.appendChild(t)})(),s||y||(y=!0,fetch(`${a}/widget/config${e?`?org_id=${encodeURIComponent(e)}`:""}`).then(t=>t.ok?t.json():null).then(e=>{if(e&&m){try{sessionStorage.setItem(r,JSON.stringify(e))}catch{}if(e.disabled)return w("Disabled by configuration."),k(),n.q=null,void(m=!1);p||(f&&!t.hideLauncher&&(f.remove(),f=null,I(t,e)),l(e))}}).catch(()=>{}))))})};let E=!1;const $=e=>{if(E||!e.includePaths&&!e.excludePaths)return;E=!0;const o=()=>{m&&!p&&(t(window.location.pathname,e.includePaths,e.excludePaths)?C||_(e):(k(),C=!1))},n=t=>{const e=history[t];history[t]=function(...t){const n=e.apply(this,t);return setTimeout(o,0),n}};n("pushState"),n("replaceState"),window.addEventListener("popstate",o)};return r.forEach(e=>{const r=(...s)=>n[e]!==r?n[e](...s):(n.q&&n.q.push([e,s]),"init"===e?((e={})=>{if(h=e,m=!0,n._t=Date.now(),e.appUrl&&(o={...o,appUrl:e.appUrl}),e.appId||e.widgetId||e.orgId||console.error("[Askly] Missing required `appId`. The widget cannot load without it."),"undefined"!=typeof window){if(g||e.autoOpen||e.userId)return g=!1,void S();if($(e),e.customLauncherSelector&&!v){let t=!0;try{document.querySelector(e.customLauncherSelector)}catch{t=!1}t||console.warn(`[Askly] customLauncherSelector is not a valid selector: ${e.customLauncherSelector}`),v=!0,t&&document.addEventListener("click",t=>{if(!(m&&h&&h.customLauncherSelector&&n.q))return;const e=t.target;let o=null;try{o=e&&e.closest?e.closest(h.customLauncherSelector):null}catch{return}o&&("A"===o.tagName&&"#"===(o.getAttribute("href")||"#").charAt(0)&&t.preventDefault(),n.q.some(t=>"open"===t[0]||"toggle"===t[0])||n.open())})}t(window.location.pathname,e.includePaths,e.excludePaths)?_(e):w("Hidden on this path.")}})(s[0]):"reset"===e?a(A(h)):"shutdown"===e||"unmount"===e?("shutdown"===e&&a(A(h)),m=!1,k(),n.q=[]):-1!==i.indexOf(e)&&S(),"on"===e||"once"===e?()=>{n.q?n.q=n.q.filter(t=>!(t[0]===e&&t[1][0]===s[0]&&t[1][1]===s[1])):n.off(s[0],s[1])}:void 0);n[e]=r}),Object.keys(s).forEach(t=>{const e=()=>n[t]!==e?n[t]():s[t];n[t]=e}),n.ready=()=>(S(),new Promise(t=>n._r.push(t))),n._unpaint=k,n}({appUrl:(y=f&&f.src,v=g,w=h,y?y.replace(/[?#].*$/,"").replace(/[^/]*$/,"").replace(/(\/@askly\/widget)(@[^/]*)?(\/)/,(t,e,o,n)=>`${e}@${v}${n}`)+"app/askly-app.js":w),fallbackUrl:h}),m.Askly=b);const A=function(t){if(t)return t.getAttribute("data-app-id")||t.getAttribute("data-widget-id")||t.getAttribute("data-org-id")||void 0}(f);f&&A&&b.init(p(f,A)),m.customElements&&!m.customElements.get("askly-chat")&&m.customElements.define("askly-chat",class extends HTMLElement{constructor(){super(...arguments),this._gone=null}connectedCallback(){if(this._gone)return clearTimeout(this._gone),void(this._gone=null);const t=this.getAttribute("app-id");if(!t)return;const e=document.createElement("script");Array.from(this.attributes).forEach(t=>e.setAttribute(`data-${t.name}`,t.value)),m.Askly.init(p(e,t))}disconnectedCallback(){this._gone=setTimeout(()=>{this._gone=null,m.Askly.unmount()},0)}})}();
1
+ !function(){"use strict";function t(t,e=[],o=[]){return e.length>0?e.some(e=>t.startsWith(e)):!(o.length>0)||!o.some(e=>t.startsWith(e))}const e="askly_scope_",o={};function n(t){delete o[t];try{window.localStorage.removeItem(t)}catch{}}function a(t){const r=t||"detect",s=function(t){var e;try{const e=window.localStorage.getItem(t);if(null!==e)return e}catch{}return null!==(e=o[t])&&void 0!==e?e:null}(e+r);s&&s!==r&&a(s),n("askly_visitor_"+r),n("askly_threads_"+r);for(const t of Object.keys(o))t.includes(r)&&!t.startsWith(e)&&delete o[t];try{const t=[];for(let e=0;e<window.localStorage.length;e++){const o=window.localStorage.key(e);o&&o.startsWith(`askly_conversations_${r}`)&&t.push(o)}t.forEach(t=>window.localStorage.removeItem(t))}catch{}}const r=["init","identify","reset","shutdown","unmount","open","close","toggle","show","hide","on","off","once","showSpace","showNewMessage","sendMessage","showArticle","startVoiceInput","stopVoiceInput","requestHuman","update","setLocale","updateTexts"],s={isOpen:!1,getUnreadCount:0,getVisitorId:""},i=["identify","open","toggle","show","showSpace","showNewMessage","sendMessage","showArticle","startVoiceInput","requestHuman","update"],l="#0f172a",d="http://www.w3.org/2000/svg";const u=":host{all:initial}.askly-chat-button{position:fixed;bottom:var(--ob,24px);width:60px;height:60px;border:0;padding:0;display:flex;align-items:center;justify-content:center;cursor:pointer;color:#fff;background:var(--a,"+l+");border-radius:23%;box-shadow:0 12px 32px rgba(15,23,42,.28),0 4px 10px rgba(15,23,42,.16);z-index:99999;font:28px -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;transition:transform .28s cubic-bezier(.2,.8,.2,1)}.shape-round{border-radius:50%}.askly-chat-button:hover{transform:translateY(-3px) scale(1.05)}.askly-chat-button:focus-visible{outline:3px solid var(--a,"+l+");outline-offset:3px}.r{right:var(--os,24px)}.l{left:var(--os,24px)}@media (max-width:600px){.askly-chat-button{bottom:var(--ob,16px)}.r{right:var(--os,16px)}.l{left:var(--os,16px)}}@media (prefers-reduced-motion:reduce){.askly-chat-button{transition:none}}";function c(t){try{const e=JSON.parse(t||"[]");return Array.isArray(e)&&e.some(t=>t&&Array.isArray(t.messages)&&t.messages.some(t=>t&&"user"===t.role))}catch{return!1}}function p(t,e){const o=t.getAttribute("data-org-server-route")||void 0,n=e=>{const o=t.getAttribute(e);return null===o?void 0:"true"===o};return{appId:e,orgServerRoute:o,organizationName:t.getAttribute("data-org-name")||void 0,position:t.getAttribute("data-position")||void 0,locale:t.getAttribute("data-locale")||void 0,hideLauncher:n("data-hide-launcher"),customLauncherSelector:t.getAttribute("data-custom-launcher-selector")||void 0,offset:(()=>{const e=t.getAttribute("data-offset-bottom"),o=t.getAttribute("data-offset-side");if(null!==e||null!==o)return{bottom:null===e||isNaN(parseInt(e))?void 0:parseInt(e),side:null===o||isNaN(parseInt(o))?void 0:parseInt(o)}})(),themeColor:t.getAttribute("data-theme-color")||void 0,theme:t.getAttribute("data-theme")||void 0,enableVoiceChat:t.getAttribute("data-enable-voice")?"true"===t.getAttribute("data-enable-voice"):void 0,voiceInput:(()=>{const e=t.getAttribute("data-voice-input");return"off"!==e&&"false"!==e&&("review"===e||"auto-send"===e?e:void 0)})(),welcomeMessage:t.getAttribute("data-welcome-message")||void 0,placeholderText:t.getAttribute("data-placeholder-text")||void 0,organizationLogo:t.getAttribute("data-logo")||void 0,buttonIcon:t.getAttribute("data-button-icon")||void 0,buttonShape:t.getAttribute("data-button-shape")||void 0,autoOpen:n("data-auto-open"),greeting:(()=>{if("false"===t.getAttribute("data-greeting"))return!1;const e=t.getAttribute("data-greeting-message")||void 0,o=t.getAttribute("data-greeting-delay"),a=null===o||isNaN(parseInt(o))?void 0:parseInt(o);return void 0!==e||void 0!==a?{message:e,delayMs:a}:n("data-greeting")})(),showTimestamp:n("data-show-timestamp"),soundEnabled:n("data-sound-enabled"),debug:n("data-debug"),soundVolume:t.getAttribute("data-sound-volume")?parseFloat(t.getAttribute("data-sound-volume")):void 0,poweredBy:t.getAttribute("data-powered-by")||void 0,userId:t.getAttribute("data-user-id")||void 0,timestamp:t.getAttribute("data-timestamp")?parseInt(t.getAttribute("data-timestamp")):void 0,signature:t.getAttribute("data-signature")||void 0,turnstileSiteKey:t.getAttribute("data-turnstile-sitekey")||void 0,excludePaths:t.getAttribute("data-exclude-paths")?t.getAttribute("data-exclude-paths").split(",").map(t=>t.trim()):void 0,includePaths:t.getAttribute("data-include-paths")?t.getAttribute("data-include-paths").split(",").map(t=>t.trim()):void 0}}const g="3.5.0",h=`https://unpkg.com/@askly/widget@${g}/dist/app/askly-app.js`,m=window,f=function(){const t=document.currentScript;if(t&&t.src)return t;const e=Array.from(document.querySelectorAll("script[src]")).filter(t=>/(^|\/)(widget|loader)\.js([?#]|$)/.test(t.src));return e.find(t=>t.hasAttribute("data-app-id")||t.hasAttribute("data-widget-id")||t.hasAttribute("data-org-id"))||e[0]||null}();let b;var y,v,w;m.Askly&&"function"==typeof m.Askly.init?(b=m.Askly,3===b.v&&b.q||console.warn("[Askly] The widget script is included twice; the second copy is ignored.")):(b=function(e){let o=e;const n={q:[],v:3,_r:[],_t:0};let p=null,g=!1,h=null,m=!1,f=null,b=[],y=!1,v=!1;const w=(...t)=>{h&&h.debug&&console.log("[Askly]",...t)},A=t=>t&&(t.appId||t.widgetId||t.orgId)||"detect",k=()=>{b.forEach(clearTimeout),b=[],f&&f.remove(),f=null},S=()=>{if(!h)return g=!0,Promise.resolve();if(!p){const t=(e,o)=>(w("Loading the widget from",e),import(/* webpackIgnore: true */ /* @vite-ignore */e).catch(n=>{if(o&&o!==e)return console.warn(`[Askly] Could not load the widget from ${e}; trying ${o}.`),t(o);p=null,k(),console.error("[Askly] The widget could not be loaded:",n)}));p=t(o.appUrl,o.fallbackUrl)}return p};let x=!1;const I=(t,e)=>{if("undefined"==typeof document||f)return;if(!document.body)return void document.addEventListener("DOMContentLoaded",()=>{!m||f||p||_(t)},{once:!0});const o=t.themeColor||e&&e.themeColor||l,a=t.buttonShape||e&&e.buttonShape||"round";f=document.createElement("askly-loader");const r=f.attachShadow({mode:"open"});let s=!1;try{const t=new CSSStyleSheet;t.replaceSync(u),r.adoptedStyleSheets=[t],s=!0}catch{}if(!s){const t=document.createElement("style");t.textContent=u,r.appendChild(t)}const i=document.createElement("button");i.className=`askly-chat-button shape-${a} ${"left"===t.position?"l":"r"}`,i.type="button",i.setAttribute("aria-label","Open support chat"),i.setAttribute("aria-expanded","false"),i.setAttribute("lang","en"),i.title="Open support chat",i.style.setProperty("--a",`var(--askly-brand, ${o})`),t.offset&&"number"==typeof t.offset.bottom&&i.style.setProperty("--ob",`${t.offset.bottom}px`),t.offset&&"number"==typeof t.offset.side&&i.style.setProperty("--os",`${t.offset.side}px`),t.buttonIcon&&"💬"!==t.buttonIcon?i.textContent=t.buttonIcon:i.appendChild(function(){const t=document.createElementNS(d,"svg");t.setAttribute("width","32"),t.setAttribute("height","32"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none");const e=document.createElementNS(d,"g");e.setAttribute("transform","translate(24 0) scale(-1 1)");const o=document.createElementNS(d,"path");return o.setAttribute("fill","currentColor"),o.setAttribute("fill-rule","evenodd"),o.setAttribute("clip-rule","evenodd"),o.setAttribute("d","M16 2H8C4 2 2 4 2 8V21C2 21.55 2.45 22 3 22H16C20 22 22 20 22 16V8C22 4 20 2 16 2ZM15.5 12.75H8.5C8.09 12.75 7.75 12.41 7.75 12C7.75 11.59 8.09 11.25 8.5 11.25H15.5C15.91 11.25 16.25 11.59 16.25 12C16.25 12.41 15.91 12.75 15.5 12.75Z"),e.appendChild(o),t.appendChild(e),t}()),i.addEventListener("mouseenter",()=>{S()}),i.addEventListener("focus",()=>{S()}),i.addEventListener("click",()=>{n.open()}),r.appendChild(i),document.body.appendChild(f)};let C=!1;const _=t=>{C=!0;const e=t.appId||t.widgetId||t.orgId,a=(t.orgServerRoute||"https://api.askly.co.in/api/messages/widget").replace(/\/widget$/,""),r=`askly_config_${e||"detect"}`;let s=null;try{s=JSON.parse(sessionStorage.getItem(r)||"null")}catch{}t.hideLauncher||I(t,s);let i=null;const l=o=>{i&&clearTimeout(i),i=null;const a=t.greeting;if(!0!==a&&(!1===a||o&&!1===o.greetingEnabled)||t.hideLauncher||function(t){try{return"1"===window.sessionStorage.getItem(`askly_greeting_dismissed_${t}`)}catch{return!1}}(e||"detect"))return;const r="object"==typeof a&&"number"==typeof a.delayMs?a.delayMs:o&&"number"==typeof o.greetingDelayMs?o.greetingDelayMs:3e3;i=setTimeout(()=>{S()},Math.max(0,r-400-(Date.now()-n._t))),b.push(i)};l(s);let d=!1;try{const t=`askly_conversations_${e||"detect"}`;for(let e=0;e<localStorage.length;e++){const o=localStorage.key(e)||"";if(0===o.indexOf(t)&&c(localStorage.getItem(o))){d=!0;break}}}catch{}(t=>{const e=window.requestIdleCallback;e?e(t,{timeout:4e3}):b.push(setTimeout(t,1500))})(()=>{m&&!p&&(d?S():((()=>{if(p||x||"undefined"==typeof document)return;x=!0;const t=document.createElement("link");t.rel="modulepreload",t.href=o.appUrl,document.head.appendChild(t)})(),s||y||(y=!0,fetch(`${a}/widget/config${e?`?org_id=${encodeURIComponent(e)}`:""}`).then(t=>t.ok?t.json():null).then(e=>{if(e&&m){try{sessionStorage.setItem(r,JSON.stringify(e))}catch{}if(e.disabled)return w("Disabled by configuration."),k(),n.q=null,void(m=!1);p||(f&&!t.hideLauncher&&(f.remove(),f=null,I(t,e)),l(e))}}).catch(()=>{}))))})};let E=!1;const $=e=>{if(E||!e.includePaths&&!e.excludePaths)return;E=!0;const o=()=>{m&&!p&&(t(window.location.pathname,e.includePaths,e.excludePaths)?C||_(e):(k(),C=!1))},n=t=>{const e=history[t];history[t]=function(...t){const n=e.apply(this,t);return setTimeout(o,0),n}};n("pushState"),n("replaceState"),window.addEventListener("popstate",o)};return r.forEach(e=>{const r=(...s)=>n[e]!==r?n[e](...s):(n.q&&n.q.push([e,s]),"init"===e?((e={})=>{if(h=e,m=!0,n._t=Date.now(),e.appUrl&&(o={...o,appUrl:e.appUrl}),e.appId||e.widgetId||e.orgId||console.error("[Askly] Missing required `appId`. The widget cannot load without it."),"undefined"!=typeof window){if(g||e.autoOpen||e.userId)return g=!1,void S();if($(e),e.customLauncherSelector&&!v){let t=!0;try{document.querySelector(e.customLauncherSelector)}catch{t=!1}t||console.warn(`[Askly] customLauncherSelector is not a valid selector: ${e.customLauncherSelector}`),v=!0,t&&document.addEventListener("click",t=>{if(!(m&&h&&h.customLauncherSelector&&n.q))return;const e=t.target;let o=null;try{o=e&&e.closest?e.closest(h.customLauncherSelector):null}catch{return}o&&("A"===o.tagName&&"#"===(o.getAttribute("href")||"#").charAt(0)&&t.preventDefault(),n.q.some(t=>"open"===t[0]||"toggle"===t[0])||n.open())})}t(window.location.pathname,e.includePaths,e.excludePaths)?_(e):w("Hidden on this path.")}})(s[0]):"reset"===e?a(A(h)):"shutdown"===e||"unmount"===e?("shutdown"===e&&a(A(h)),m=!1,k(),n.q=[]):-1!==i.indexOf(e)&&S(),"on"===e||"once"===e?()=>{n.q?n.q=n.q.filter(t=>!(t[0]===e&&t[1][0]===s[0]&&t[1][1]===s[1])):n.off(s[0],s[1])}:void 0);n[e]=r}),Object.keys(s).forEach(t=>{const e=()=>n[t]!==e?n[t]():s[t];n[t]=e}),n.ready=()=>(S(),new Promise(t=>n._r.push(t))),n._unpaint=k,n}({appUrl:(y=f&&f.src,v=g,w=h,y?y.replace(/[?#].*$/,"").replace(/[^/]*$/,"").replace(/(\/@askly\/widget)(@[^/]*)?(\/)/,(t,e,o,n)=>`${e}@${v}${n}`)+"app/askly-app.js":w),fallbackUrl:h}),m.Askly=b);const A=function(t){if(t)return t.getAttribute("data-app-id")||t.getAttribute("data-widget-id")||t.getAttribute("data-org-id")||void 0}(f);f&&A&&b.init(p(f,A)),m.customElements&&!m.customElements.get("askly-chat")&&m.customElements.define("askly-chat",class extends HTMLElement{constructor(){super(...arguments),this._gone=null}connectedCallback(){if(this._gone)return clearTimeout(this._gone),void(this._gone=null);const t=this.getAttribute("app-id");if(!t)return;const e=document.createElement("script");Array.from(this.attributes).forEach(t=>e.setAttribute(`data-${t.name}`,t.value)),m.Askly.init(p(e,t))}disconnectedCallback(){this._gone=setTimeout(()=>{this._gone=null,m.Askly.unmount()},0)}})}();
@@ -25,6 +25,8 @@ export interface AsklyApi {
25
25
  sendMessage: (text: string) => void;
26
26
  showArticle: (articleId: string) => void;
27
27
  startVoiceInput: () => void;
28
+ /** Ask for a person on the current conversation: the thread goes to your team. */
29
+ requestHuman: (reason?: string) => void;
28
30
  stopVoiceInput: () => void;
29
31
  update: (config: Record<string, any>) => void;
30
32
  /** Switch the widget's language (BCP 47 tag). Applied asynchronously; unknown tags fall back to English. */
@@ -49,6 +49,16 @@ export interface AsklyEventMap {
49
49
  articleId: string;
50
50
  rating: "yes" | "somewhat" | "no";
51
51
  };
52
+ /** The visitor asked to talk to a person (or `Askly.requestHuman()` was called). */
53
+ "handoff:requested": {
54
+ conversationId: string;
55
+ };
56
+ /** The visitor opened one of a reply's sources. */
57
+ "citation:opened": {
58
+ id: string;
59
+ title: string;
60
+ articleId?: string;
61
+ };
52
62
  /** A conversation was closed, taken over by an agent, or reopened. */
53
63
  "conversation:status": {
54
64
  conversationId: string;
@@ -122,6 +132,9 @@ export type AsklyCommand = {
122
132
  articleId: string;
123
133
  } | {
124
134
  type: "startVoiceInput";
135
+ } | {
136
+ type: "requestHuman";
137
+ reason?: string;
125
138
  } | {
126
139
  type: "stopVoiceInput";
127
140
  } | {
@@ -3,7 +3,7 @@
3
3
  * the browser's copy (see ./storage.ts) is a cache of it plus what has not reached the
4
4
  * server yet: the welcome line, and messages still sending or not sent.
5
5
  */
6
- import type { ConversationStatus, Message, SavedConversation } from "./types";
6
+ import type { Citation, ConversationStatus, Message, SavedConversation } from "./types";
7
7
  /** One message as the widget API returns it. */
8
8
  export interface ServerMessage {
9
9
  role: string;
@@ -16,7 +16,12 @@ export interface ServerMessage {
16
16
  rating?: string | null;
17
17
  comment?: string | null;
18
18
  } | null;
19
+ citations?: any[] | null;
20
+ sender?: {
21
+ name?: string | null;
22
+ } | null;
19
23
  }
24
+ export declare function toCitations(raw: unknown): Citation[];
20
25
  /** One row of GET /widget/conversations. */
21
26
  export interface ServerThread {
22
27
  thread_key: string;
@@ -59,6 +59,15 @@ export interface Message {
59
59
  status?: MessageStatus;
60
60
  attachments?: Attachment[];
61
61
  feedback?: MessageFeedback;
62
+ citations?: Citation[];
63
+ sender?: {
64
+ name: string;
65
+ };
66
+ }
67
+ export interface Citation {
68
+ id: string;
69
+ title: string;
70
+ articleId?: string;
62
71
  }
63
72
  export interface Attachment {
64
73
  url: string;
@@ -154,6 +154,11 @@ declare const en: {
154
154
  help_updated_on: string;
155
155
  help_open_site: string;
156
156
  help_article_unavailable: string;
157
+ citations_label: string;
158
+ handoff_button: string;
159
+ handoff_requesting: string;
160
+ handoff_unavailable: string;
161
+ handoff_failed: string;
157
162
  hours_away_until: string;
158
163
  hours_away: string;
159
164
  link_opens_new_tab: string;
@@ -1,10 +1,14 @@
1
1
  import React from "react";
2
- import type { Message } from "../core/types";
2
+ import type { Citation, Message } from "../core/types";
3
3
  export interface MessageListProps {
4
4
  /** Which chat is on screen; the comment box and the thanks note belong to one chat. */
5
5
  chatKey: string | null;
6
6
  copiedMsgIndex: string | null;
7
7
  messages: Message[];
8
+ /** Whether a source opens something (an article); otherwise it is shown by title only. */
9
+ canOpenCitation: (c: Citation) => boolean;
10
+ /** Open one of a reply's sources. */
11
+ openCitation: (c: Citation) => void;
8
12
  /** Rate a reply; null withdraws the rating. */
9
13
  rateMessage: (m: Message, rating: "up" | "down" | null, comment?: string) => void | Promise<void>;
10
14
  setCopiedMsgIndex: React.Dispatch<React.SetStateAction<string | null>>;
package/dist/widget.js CHANGED
@@ -1 +1 @@
1
- !function(){"use strict";function t(t,e=[],o=[]){return e.length>0?e.some(e=>t.startsWith(e)):!(o.length>0)||!o.some(e=>t.startsWith(e))}const e="askly_scope_",o={};function n(t){delete o[t];try{window.localStorage.removeItem(t)}catch{}}function a(t){const r=t||"detect",s=function(t){var e;try{const e=window.localStorage.getItem(t);if(null!==e)return e}catch{}return null!==(e=o[t])&&void 0!==e?e:null}(e+r);s&&s!==r&&a(s),n("askly_visitor_"+r),n("askly_threads_"+r);for(const t of Object.keys(o))t.includes(r)&&!t.startsWith(e)&&delete o[t];try{const t=[];for(let e=0;e<window.localStorage.length;e++){const o=window.localStorage.key(e);o&&o.startsWith(`askly_conversations_${r}`)&&t.push(o)}t.forEach(t=>window.localStorage.removeItem(t))}catch{}}const r=["init","identify","reset","shutdown","unmount","open","close","toggle","show","hide","on","off","once","showSpace","showNewMessage","sendMessage","showArticle","startVoiceInput","stopVoiceInput","update","setLocale","updateTexts"],s={isOpen:!1,getUnreadCount:0,getVisitorId:""},i=["identify","open","toggle","show","showSpace","showNewMessage","sendMessage","showArticle","startVoiceInput","update"],l="#0f172a",d="http://www.w3.org/2000/svg";const u=":host{all:initial}.askly-chat-button{position:fixed;bottom:var(--ob,24px);width:60px;height:60px;border:0;padding:0;display:flex;align-items:center;justify-content:center;cursor:pointer;color:#fff;background:var(--a,"+l+");border-radius:23%;box-shadow:0 12px 32px rgba(15,23,42,.28),0 4px 10px rgba(15,23,42,.16);z-index:99999;font:28px -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;transition:transform .28s cubic-bezier(.2,.8,.2,1)}.shape-round{border-radius:50%}.askly-chat-button:hover{transform:translateY(-3px) scale(1.05)}.askly-chat-button:focus-visible{outline:3px solid var(--a,"+l+");outline-offset:3px}.r{right:var(--os,24px)}.l{left:var(--os,24px)}@media (max-width:600px){.askly-chat-button{bottom:var(--ob,16px)}.r{right:var(--os,16px)}.l{left:var(--os,16px)}}@media (prefers-reduced-motion:reduce){.askly-chat-button{transition:none}}";function c(t){try{const e=JSON.parse(t||"[]");return Array.isArray(e)&&e.some(t=>t&&Array.isArray(t.messages)&&t.messages.some(t=>t&&"user"===t.role))}catch{return!1}}function p(t,e){const o=t.getAttribute("data-org-server-route")||void 0,n=e=>{const o=t.getAttribute(e);return null===o?void 0:"true"===o};return{appId:e,orgServerRoute:o,organizationName:t.getAttribute("data-org-name")||void 0,position:t.getAttribute("data-position")||void 0,locale:t.getAttribute("data-locale")||void 0,hideLauncher:n("data-hide-launcher"),customLauncherSelector:t.getAttribute("data-custom-launcher-selector")||void 0,offset:(()=>{const e=t.getAttribute("data-offset-bottom"),o=t.getAttribute("data-offset-side");if(null!==e||null!==o)return{bottom:null===e||isNaN(parseInt(e))?void 0:parseInt(e),side:null===o||isNaN(parseInt(o))?void 0:parseInt(o)}})(),themeColor:t.getAttribute("data-theme-color")||void 0,theme:t.getAttribute("data-theme")||void 0,enableVoiceChat:t.getAttribute("data-enable-voice")?"true"===t.getAttribute("data-enable-voice"):void 0,voiceInput:(()=>{const e=t.getAttribute("data-voice-input");return"off"!==e&&"false"!==e&&("review"===e||"auto-send"===e?e:void 0)})(),welcomeMessage:t.getAttribute("data-welcome-message")||void 0,placeholderText:t.getAttribute("data-placeholder-text")||void 0,organizationLogo:t.getAttribute("data-logo")||void 0,buttonIcon:t.getAttribute("data-button-icon")||void 0,buttonShape:t.getAttribute("data-button-shape")||void 0,autoOpen:n("data-auto-open"),greeting:(()=>{if("false"===t.getAttribute("data-greeting"))return!1;const e=t.getAttribute("data-greeting-message")||void 0,o=t.getAttribute("data-greeting-delay"),a=null===o||isNaN(parseInt(o))?void 0:parseInt(o);return void 0!==e||void 0!==a?{message:e,delayMs:a}:n("data-greeting")})(),showTimestamp:n("data-show-timestamp"),soundEnabled:n("data-sound-enabled"),debug:n("data-debug"),soundVolume:t.getAttribute("data-sound-volume")?parseFloat(t.getAttribute("data-sound-volume")):void 0,poweredBy:t.getAttribute("data-powered-by")||void 0,userId:t.getAttribute("data-user-id")||void 0,timestamp:t.getAttribute("data-timestamp")?parseInt(t.getAttribute("data-timestamp")):void 0,signature:t.getAttribute("data-signature")||void 0,turnstileSiteKey:t.getAttribute("data-turnstile-sitekey")||void 0,excludePaths:t.getAttribute("data-exclude-paths")?t.getAttribute("data-exclude-paths").split(",").map(t=>t.trim()):void 0,includePaths:t.getAttribute("data-include-paths")?t.getAttribute("data-include-paths").split(",").map(t=>t.trim()):void 0}}const g="3.4.0",h=`https://unpkg.com/@askly/widget@${g}/dist/app/askly-app.js`,m=window,f=function(){const t=document.currentScript;if(t&&t.src)return t;const e=Array.from(document.querySelectorAll("script[src]")).filter(t=>/(^|\/)(widget|loader)\.js([?#]|$)/.test(t.src));return e.find(t=>t.hasAttribute("data-app-id")||t.hasAttribute("data-widget-id")||t.hasAttribute("data-org-id"))||e[0]||null}();let b;var y,v,w;m.Askly&&"function"==typeof m.Askly.init?(b=m.Askly,3===b.v&&b.q||console.warn("[Askly] The widget script is included twice; the second copy is ignored.")):(b=function(e){let o=e;const n={q:[],v:3,_r:[],_t:0};let p=null,g=!1,h=null,m=!1,f=null,b=[],y=!1,v=!1;const w=(...t)=>{h&&h.debug&&console.log("[Askly]",...t)},A=t=>t&&(t.appId||t.widgetId||t.orgId)||"detect",k=()=>{b.forEach(clearTimeout),b=[],f&&f.remove(),f=null},S=()=>{if(!h)return g=!0,Promise.resolve();if(!p){const t=(e,o)=>(w("Loading the widget from",e),import(/* webpackIgnore: true */ /* @vite-ignore */e).catch(n=>{if(o&&o!==e)return console.warn(`[Askly] Could not load the widget from ${e}; trying ${o}.`),t(o);p=null,k(),console.error("[Askly] The widget could not be loaded:",n)}));p=t(o.appUrl,o.fallbackUrl)}return p};let x=!1;const I=(t,e)=>{if("undefined"==typeof document||f)return;if(!document.body)return void document.addEventListener("DOMContentLoaded",()=>{!m||f||p||_(t)},{once:!0});const o=t.themeColor||e&&e.themeColor||l,a=t.buttonShape||e&&e.buttonShape||"round";f=document.createElement("askly-loader");const r=f.attachShadow({mode:"open"});let s=!1;try{const t=new CSSStyleSheet;t.replaceSync(u),r.adoptedStyleSheets=[t],s=!0}catch{}if(!s){const t=document.createElement("style");t.textContent=u,r.appendChild(t)}const i=document.createElement("button");i.className=`askly-chat-button shape-${a} ${"left"===t.position?"l":"r"}`,i.type="button",i.setAttribute("aria-label","Open support chat"),i.setAttribute("aria-expanded","false"),i.setAttribute("lang","en"),i.title="Open support chat",i.style.setProperty("--a",`var(--askly-brand, ${o})`),t.offset&&"number"==typeof t.offset.bottom&&i.style.setProperty("--ob",`${t.offset.bottom}px`),t.offset&&"number"==typeof t.offset.side&&i.style.setProperty("--os",`${t.offset.side}px`),t.buttonIcon&&"💬"!==t.buttonIcon?i.textContent=t.buttonIcon:i.appendChild(function(){const t=document.createElementNS(d,"svg");t.setAttribute("width","32"),t.setAttribute("height","32"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none");const e=document.createElementNS(d,"g");e.setAttribute("transform","translate(24 0) scale(-1 1)");const o=document.createElementNS(d,"path");return o.setAttribute("fill","currentColor"),o.setAttribute("fill-rule","evenodd"),o.setAttribute("clip-rule","evenodd"),o.setAttribute("d","M16 2H8C4 2 2 4 2 8V21C2 21.55 2.45 22 3 22H16C20 22 22 20 22 16V8C22 4 20 2 16 2ZM15.5 12.75H8.5C8.09 12.75 7.75 12.41 7.75 12C7.75 11.59 8.09 11.25 8.5 11.25H15.5C15.91 11.25 16.25 11.59 16.25 12C16.25 12.41 15.91 12.75 15.5 12.75Z"),e.appendChild(o),t.appendChild(e),t}()),i.addEventListener("mouseenter",()=>{S()}),i.addEventListener("focus",()=>{S()}),i.addEventListener("click",()=>{n.open()}),r.appendChild(i),document.body.appendChild(f)};let C=!1;const _=t=>{C=!0;const e=t.appId||t.widgetId||t.orgId,a=(t.orgServerRoute||"https://api.askly.co.in/api/messages/widget").replace(/\/widget$/,""),r=`askly_config_${e||"detect"}`;let s=null;try{s=JSON.parse(sessionStorage.getItem(r)||"null")}catch{}t.hideLauncher||I(t,s);let i=null;const l=o=>{i&&clearTimeout(i),i=null;const a=t.greeting;if(!0!==a&&(!1===a||o&&!1===o.greetingEnabled)||t.hideLauncher||function(t){try{return"1"===window.sessionStorage.getItem(`askly_greeting_dismissed_${t}`)}catch{return!1}}(e||"detect"))return;const r="object"==typeof a&&"number"==typeof a.delayMs?a.delayMs:o&&"number"==typeof o.greetingDelayMs?o.greetingDelayMs:3e3;i=setTimeout(()=>{S()},Math.max(0,r-400-(Date.now()-n._t))),b.push(i)};l(s);let d=!1;try{const t=`askly_conversations_${e||"detect"}`;for(let e=0;e<localStorage.length;e++){const o=localStorage.key(e)||"";if(0===o.indexOf(t)&&c(localStorage.getItem(o))){d=!0;break}}}catch{}(t=>{const e=window.requestIdleCallback;e?e(t,{timeout:4e3}):b.push(setTimeout(t,1500))})(()=>{m&&!p&&(d?S():((()=>{if(p||x||"undefined"==typeof document)return;x=!0;const t=document.createElement("link");t.rel="modulepreload",t.href=o.appUrl,document.head.appendChild(t)})(),s||y||(y=!0,fetch(`${a}/widget/config${e?`?org_id=${encodeURIComponent(e)}`:""}`).then(t=>t.ok?t.json():null).then(e=>{if(e&&m){try{sessionStorage.setItem(r,JSON.stringify(e))}catch{}if(e.disabled)return w("Disabled by configuration."),k(),n.q=null,void(m=!1);p||(f&&!t.hideLauncher&&(f.remove(),f=null,I(t,e)),l(e))}}).catch(()=>{}))))})};let E=!1;const $=e=>{if(E||!e.includePaths&&!e.excludePaths)return;E=!0;const o=()=>{m&&!p&&(t(window.location.pathname,e.includePaths,e.excludePaths)?C||_(e):(k(),C=!1))},n=t=>{const e=history[t];history[t]=function(...t){const n=e.apply(this,t);return setTimeout(o,0),n}};n("pushState"),n("replaceState"),window.addEventListener("popstate",o)};return r.forEach(e=>{const r=(...s)=>n[e]!==r?n[e](...s):(n.q&&n.q.push([e,s]),"init"===e?((e={})=>{if(h=e,m=!0,n._t=Date.now(),e.appUrl&&(o={...o,appUrl:e.appUrl}),e.appId||e.widgetId||e.orgId||console.error("[Askly] Missing required `appId`. The widget cannot load without it."),"undefined"!=typeof window){if(g||e.autoOpen||e.userId)return g=!1,void S();if($(e),e.customLauncherSelector&&!v){let t=!0;try{document.querySelector(e.customLauncherSelector)}catch{t=!1}t||console.warn(`[Askly] customLauncherSelector is not a valid selector: ${e.customLauncherSelector}`),v=!0,t&&document.addEventListener("click",t=>{if(!(m&&h&&h.customLauncherSelector&&n.q))return;const e=t.target;let o=null;try{o=e&&e.closest?e.closest(h.customLauncherSelector):null}catch{return}o&&("A"===o.tagName&&"#"===(o.getAttribute("href")||"#").charAt(0)&&t.preventDefault(),n.q.some(t=>"open"===t[0]||"toggle"===t[0])||n.open())})}t(window.location.pathname,e.includePaths,e.excludePaths)?_(e):w("Hidden on this path.")}})(s[0]):"reset"===e?a(A(h)):"shutdown"===e||"unmount"===e?("shutdown"===e&&a(A(h)),m=!1,k(),n.q=[]):-1!==i.indexOf(e)&&S(),"on"===e||"once"===e?()=>{n.q?n.q=n.q.filter(t=>!(t[0]===e&&t[1][0]===s[0]&&t[1][1]===s[1])):n.off(s[0],s[1])}:void 0);n[e]=r}),Object.keys(s).forEach(t=>{const e=()=>n[t]!==e?n[t]():s[t];n[t]=e}),n.ready=()=>(S(),new Promise(t=>n._r.push(t))),n._unpaint=k,n}({appUrl:(y=f&&f.src,v=g,w=h,y?y.replace(/[?#].*$/,"").replace(/[^/]*$/,"").replace(/(\/@askly\/widget)(@[^/]*)?(\/)/,(t,e,o,n)=>`${e}@${v}${n}`)+"app/askly-app.js":w),fallbackUrl:h}),m.Askly=b);const A=function(t){if(t)return t.getAttribute("data-app-id")||t.getAttribute("data-widget-id")||t.getAttribute("data-org-id")||void 0}(f);f&&A&&b.init(p(f,A)),m.customElements&&!m.customElements.get("askly-chat")&&m.customElements.define("askly-chat",class extends HTMLElement{constructor(){super(...arguments),this._gone=null}connectedCallback(){if(this._gone)return clearTimeout(this._gone),void(this._gone=null);const t=this.getAttribute("app-id");if(!t)return;const e=document.createElement("script");Array.from(this.attributes).forEach(t=>e.setAttribute(`data-${t.name}`,t.value)),m.Askly.init(p(e,t))}disconnectedCallback(){this._gone=setTimeout(()=>{this._gone=null,m.Askly.unmount()},0)}})}();
1
+ !function(){"use strict";function t(t,e=[],o=[]){return e.length>0?e.some(e=>t.startsWith(e)):!(o.length>0)||!o.some(e=>t.startsWith(e))}const e="askly_scope_",o={};function n(t){delete o[t];try{window.localStorage.removeItem(t)}catch{}}function a(t){const r=t||"detect",s=function(t){var e;try{const e=window.localStorage.getItem(t);if(null!==e)return e}catch{}return null!==(e=o[t])&&void 0!==e?e:null}(e+r);s&&s!==r&&a(s),n("askly_visitor_"+r),n("askly_threads_"+r);for(const t of Object.keys(o))t.includes(r)&&!t.startsWith(e)&&delete o[t];try{const t=[];for(let e=0;e<window.localStorage.length;e++){const o=window.localStorage.key(e);o&&o.startsWith(`askly_conversations_${r}`)&&t.push(o)}t.forEach(t=>window.localStorage.removeItem(t))}catch{}}const r=["init","identify","reset","shutdown","unmount","open","close","toggle","show","hide","on","off","once","showSpace","showNewMessage","sendMessage","showArticle","startVoiceInput","stopVoiceInput","requestHuman","update","setLocale","updateTexts"],s={isOpen:!1,getUnreadCount:0,getVisitorId:""},i=["identify","open","toggle","show","showSpace","showNewMessage","sendMessage","showArticle","startVoiceInput","requestHuman","update"],l="#0f172a",d="http://www.w3.org/2000/svg";const u=":host{all:initial}.askly-chat-button{position:fixed;bottom:var(--ob,24px);width:60px;height:60px;border:0;padding:0;display:flex;align-items:center;justify-content:center;cursor:pointer;color:#fff;background:var(--a,"+l+");border-radius:23%;box-shadow:0 12px 32px rgba(15,23,42,.28),0 4px 10px rgba(15,23,42,.16);z-index:99999;font:28px -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;transition:transform .28s cubic-bezier(.2,.8,.2,1)}.shape-round{border-radius:50%}.askly-chat-button:hover{transform:translateY(-3px) scale(1.05)}.askly-chat-button:focus-visible{outline:3px solid var(--a,"+l+");outline-offset:3px}.r{right:var(--os,24px)}.l{left:var(--os,24px)}@media (max-width:600px){.askly-chat-button{bottom:var(--ob,16px)}.r{right:var(--os,16px)}.l{left:var(--os,16px)}}@media (prefers-reduced-motion:reduce){.askly-chat-button{transition:none}}";function c(t){try{const e=JSON.parse(t||"[]");return Array.isArray(e)&&e.some(t=>t&&Array.isArray(t.messages)&&t.messages.some(t=>t&&"user"===t.role))}catch{return!1}}function p(t,e){const o=t.getAttribute("data-org-server-route")||void 0,n=e=>{const o=t.getAttribute(e);return null===o?void 0:"true"===o};return{appId:e,orgServerRoute:o,organizationName:t.getAttribute("data-org-name")||void 0,position:t.getAttribute("data-position")||void 0,locale:t.getAttribute("data-locale")||void 0,hideLauncher:n("data-hide-launcher"),customLauncherSelector:t.getAttribute("data-custom-launcher-selector")||void 0,offset:(()=>{const e=t.getAttribute("data-offset-bottom"),o=t.getAttribute("data-offset-side");if(null!==e||null!==o)return{bottom:null===e||isNaN(parseInt(e))?void 0:parseInt(e),side:null===o||isNaN(parseInt(o))?void 0:parseInt(o)}})(),themeColor:t.getAttribute("data-theme-color")||void 0,theme:t.getAttribute("data-theme")||void 0,enableVoiceChat:t.getAttribute("data-enable-voice")?"true"===t.getAttribute("data-enable-voice"):void 0,voiceInput:(()=>{const e=t.getAttribute("data-voice-input");return"off"!==e&&"false"!==e&&("review"===e||"auto-send"===e?e:void 0)})(),welcomeMessage:t.getAttribute("data-welcome-message")||void 0,placeholderText:t.getAttribute("data-placeholder-text")||void 0,organizationLogo:t.getAttribute("data-logo")||void 0,buttonIcon:t.getAttribute("data-button-icon")||void 0,buttonShape:t.getAttribute("data-button-shape")||void 0,autoOpen:n("data-auto-open"),greeting:(()=>{if("false"===t.getAttribute("data-greeting"))return!1;const e=t.getAttribute("data-greeting-message")||void 0,o=t.getAttribute("data-greeting-delay"),a=null===o||isNaN(parseInt(o))?void 0:parseInt(o);return void 0!==e||void 0!==a?{message:e,delayMs:a}:n("data-greeting")})(),showTimestamp:n("data-show-timestamp"),soundEnabled:n("data-sound-enabled"),debug:n("data-debug"),soundVolume:t.getAttribute("data-sound-volume")?parseFloat(t.getAttribute("data-sound-volume")):void 0,poweredBy:t.getAttribute("data-powered-by")||void 0,userId:t.getAttribute("data-user-id")||void 0,timestamp:t.getAttribute("data-timestamp")?parseInt(t.getAttribute("data-timestamp")):void 0,signature:t.getAttribute("data-signature")||void 0,turnstileSiteKey:t.getAttribute("data-turnstile-sitekey")||void 0,excludePaths:t.getAttribute("data-exclude-paths")?t.getAttribute("data-exclude-paths").split(",").map(t=>t.trim()):void 0,includePaths:t.getAttribute("data-include-paths")?t.getAttribute("data-include-paths").split(",").map(t=>t.trim()):void 0}}const g="3.5.0",h=`https://unpkg.com/@askly/widget@${g}/dist/app/askly-app.js`,m=window,f=function(){const t=document.currentScript;if(t&&t.src)return t;const e=Array.from(document.querySelectorAll("script[src]")).filter(t=>/(^|\/)(widget|loader)\.js([?#]|$)/.test(t.src));return e.find(t=>t.hasAttribute("data-app-id")||t.hasAttribute("data-widget-id")||t.hasAttribute("data-org-id"))||e[0]||null}();let b;var y,v,w;m.Askly&&"function"==typeof m.Askly.init?(b=m.Askly,3===b.v&&b.q||console.warn("[Askly] The widget script is included twice; the second copy is ignored.")):(b=function(e){let o=e;const n={q:[],v:3,_r:[],_t:0};let p=null,g=!1,h=null,m=!1,f=null,b=[],y=!1,v=!1;const w=(...t)=>{h&&h.debug&&console.log("[Askly]",...t)},A=t=>t&&(t.appId||t.widgetId||t.orgId)||"detect",k=()=>{b.forEach(clearTimeout),b=[],f&&f.remove(),f=null},S=()=>{if(!h)return g=!0,Promise.resolve();if(!p){const t=(e,o)=>(w("Loading the widget from",e),import(/* webpackIgnore: true */ /* @vite-ignore */e).catch(n=>{if(o&&o!==e)return console.warn(`[Askly] Could not load the widget from ${e}; trying ${o}.`),t(o);p=null,k(),console.error("[Askly] The widget could not be loaded:",n)}));p=t(o.appUrl,o.fallbackUrl)}return p};let x=!1;const I=(t,e)=>{if("undefined"==typeof document||f)return;if(!document.body)return void document.addEventListener("DOMContentLoaded",()=>{!m||f||p||_(t)},{once:!0});const o=t.themeColor||e&&e.themeColor||l,a=t.buttonShape||e&&e.buttonShape||"round";f=document.createElement("askly-loader");const r=f.attachShadow({mode:"open"});let s=!1;try{const t=new CSSStyleSheet;t.replaceSync(u),r.adoptedStyleSheets=[t],s=!0}catch{}if(!s){const t=document.createElement("style");t.textContent=u,r.appendChild(t)}const i=document.createElement("button");i.className=`askly-chat-button shape-${a} ${"left"===t.position?"l":"r"}`,i.type="button",i.setAttribute("aria-label","Open support chat"),i.setAttribute("aria-expanded","false"),i.setAttribute("lang","en"),i.title="Open support chat",i.style.setProperty("--a",`var(--askly-brand, ${o})`),t.offset&&"number"==typeof t.offset.bottom&&i.style.setProperty("--ob",`${t.offset.bottom}px`),t.offset&&"number"==typeof t.offset.side&&i.style.setProperty("--os",`${t.offset.side}px`),t.buttonIcon&&"💬"!==t.buttonIcon?i.textContent=t.buttonIcon:i.appendChild(function(){const t=document.createElementNS(d,"svg");t.setAttribute("width","32"),t.setAttribute("height","32"),t.setAttribute("viewBox","0 0 24 24"),t.setAttribute("fill","none");const e=document.createElementNS(d,"g");e.setAttribute("transform","translate(24 0) scale(-1 1)");const o=document.createElementNS(d,"path");return o.setAttribute("fill","currentColor"),o.setAttribute("fill-rule","evenodd"),o.setAttribute("clip-rule","evenodd"),o.setAttribute("d","M16 2H8C4 2 2 4 2 8V21C2 21.55 2.45 22 3 22H16C20 22 22 20 22 16V8C22 4 20 2 16 2ZM15.5 12.75H8.5C8.09 12.75 7.75 12.41 7.75 12C7.75 11.59 8.09 11.25 8.5 11.25H15.5C15.91 11.25 16.25 11.59 16.25 12C16.25 12.41 15.91 12.75 15.5 12.75Z"),e.appendChild(o),t.appendChild(e),t}()),i.addEventListener("mouseenter",()=>{S()}),i.addEventListener("focus",()=>{S()}),i.addEventListener("click",()=>{n.open()}),r.appendChild(i),document.body.appendChild(f)};let C=!1;const _=t=>{C=!0;const e=t.appId||t.widgetId||t.orgId,a=(t.orgServerRoute||"https://api.askly.co.in/api/messages/widget").replace(/\/widget$/,""),r=`askly_config_${e||"detect"}`;let s=null;try{s=JSON.parse(sessionStorage.getItem(r)||"null")}catch{}t.hideLauncher||I(t,s);let i=null;const l=o=>{i&&clearTimeout(i),i=null;const a=t.greeting;if(!0!==a&&(!1===a||o&&!1===o.greetingEnabled)||t.hideLauncher||function(t){try{return"1"===window.sessionStorage.getItem(`askly_greeting_dismissed_${t}`)}catch{return!1}}(e||"detect"))return;const r="object"==typeof a&&"number"==typeof a.delayMs?a.delayMs:o&&"number"==typeof o.greetingDelayMs?o.greetingDelayMs:3e3;i=setTimeout(()=>{S()},Math.max(0,r-400-(Date.now()-n._t))),b.push(i)};l(s);let d=!1;try{const t=`askly_conversations_${e||"detect"}`;for(let e=0;e<localStorage.length;e++){const o=localStorage.key(e)||"";if(0===o.indexOf(t)&&c(localStorage.getItem(o))){d=!0;break}}}catch{}(t=>{const e=window.requestIdleCallback;e?e(t,{timeout:4e3}):b.push(setTimeout(t,1500))})(()=>{m&&!p&&(d?S():((()=>{if(p||x||"undefined"==typeof document)return;x=!0;const t=document.createElement("link");t.rel="modulepreload",t.href=o.appUrl,document.head.appendChild(t)})(),s||y||(y=!0,fetch(`${a}/widget/config${e?`?org_id=${encodeURIComponent(e)}`:""}`).then(t=>t.ok?t.json():null).then(e=>{if(e&&m){try{sessionStorage.setItem(r,JSON.stringify(e))}catch{}if(e.disabled)return w("Disabled by configuration."),k(),n.q=null,void(m=!1);p||(f&&!t.hideLauncher&&(f.remove(),f=null,I(t,e)),l(e))}}).catch(()=>{}))))})};let E=!1;const $=e=>{if(E||!e.includePaths&&!e.excludePaths)return;E=!0;const o=()=>{m&&!p&&(t(window.location.pathname,e.includePaths,e.excludePaths)?C||_(e):(k(),C=!1))},n=t=>{const e=history[t];history[t]=function(...t){const n=e.apply(this,t);return setTimeout(o,0),n}};n("pushState"),n("replaceState"),window.addEventListener("popstate",o)};return r.forEach(e=>{const r=(...s)=>n[e]!==r?n[e](...s):(n.q&&n.q.push([e,s]),"init"===e?((e={})=>{if(h=e,m=!0,n._t=Date.now(),e.appUrl&&(o={...o,appUrl:e.appUrl}),e.appId||e.widgetId||e.orgId||console.error("[Askly] Missing required `appId`. The widget cannot load without it."),"undefined"!=typeof window){if(g||e.autoOpen||e.userId)return g=!1,void S();if($(e),e.customLauncherSelector&&!v){let t=!0;try{document.querySelector(e.customLauncherSelector)}catch{t=!1}t||console.warn(`[Askly] customLauncherSelector is not a valid selector: ${e.customLauncherSelector}`),v=!0,t&&document.addEventListener("click",t=>{if(!(m&&h&&h.customLauncherSelector&&n.q))return;const e=t.target;let o=null;try{o=e&&e.closest?e.closest(h.customLauncherSelector):null}catch{return}o&&("A"===o.tagName&&"#"===(o.getAttribute("href")||"#").charAt(0)&&t.preventDefault(),n.q.some(t=>"open"===t[0]||"toggle"===t[0])||n.open())})}t(window.location.pathname,e.includePaths,e.excludePaths)?_(e):w("Hidden on this path.")}})(s[0]):"reset"===e?a(A(h)):"shutdown"===e||"unmount"===e?("shutdown"===e&&a(A(h)),m=!1,k(),n.q=[]):-1!==i.indexOf(e)&&S(),"on"===e||"once"===e?()=>{n.q?n.q=n.q.filter(t=>!(t[0]===e&&t[1][0]===s[0]&&t[1][1]===s[1])):n.off(s[0],s[1])}:void 0);n[e]=r}),Object.keys(s).forEach(t=>{const e=()=>n[t]!==e?n[t]():s[t];n[t]=e}),n.ready=()=>(S(),new Promise(t=>n._r.push(t))),n._unpaint=k,n}({appUrl:(y=f&&f.src,v=g,w=h,y?y.replace(/[?#].*$/,"").replace(/[^/]*$/,"").replace(/(\/@askly\/widget)(@[^/]*)?(\/)/,(t,e,o,n)=>`${e}@${v}${n}`)+"app/askly-app.js":w),fallbackUrl:h}),m.Askly=b);const A=function(t){if(t)return t.getAttribute("data-app-id")||t.getAttribute("data-widget-id")||t.getAttribute("data-org-id")||void 0}(f);f&&A&&b.init(p(f,A)),m.customElements&&!m.customElements.get("askly-chat")&&m.customElements.define("askly-chat",class extends HTMLElement{constructor(){super(...arguments),this._gone=null}connectedCallback(){if(this._gone)return clearTimeout(this._gone),void(this._gone=null);const t=this.getAttribute("app-id");if(!t)return;const e=document.createElement("script");Array.from(this.attributes).forEach(t=>e.setAttribute(`data-${t.name}`,t.value)),m.Askly.init(p(e,t))}disconnectedCallback(){this._gone=setTimeout(()=>{this._gone=null,m.Askly.unmount()},0)}})}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askly/widget",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "description": "Embeddable AI support chat widget for React \u2014 drop-in customer support chatbot with voice, RAG (docs-grounded) answers, and human handoff. One line to install.",
5
5
  "main": "dist/index.umd.js",
6
6
  "module": "dist/index.esm.js",
@@ -1 +0,0 @@
1
- var e,t,n,o,r,i,a,s,l,_,u,c,p,d,f,h={},m=[],g=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,v=Array.isArray;function y(e,t){for(var n in t)e[n]=t[n];return e}function w(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function b(t,n,o){var r,i,a,s={};for(a in n)"key"==a?r=n[a]:"ref"==a?i=n[a]:s[a]=n[a];if(arguments.length>2&&(s.children=arguments.length>3?e.call(arguments,2):o),"function"==typeof t&&null!=t.defaultProps)for(a in t.defaultProps)void 0===s[a]&&(s[a]=t.defaultProps[a]);return k(t,s,r,i,null)}function k(e,o,r,i,a){var s={type:e,props:o,key:r,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==a?++n:a,__i:-1,__u:0};return null==a&&null!=t.vnode&&t.vnode(s),s}function C(e){return e.children}function S(e,t){this.props=e,this.context=t}function x(e,t){if(null==t)return e.__?x(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if(null!=(n=e.__k[t])&&null!=n.__e)return n.__e;return"function"==typeof e.type?x(e):null}function N(e){if(e.__P&&e.__d){var n=e.__v,o=n.__e,r=[],i=[],a=y({},n);a.__v=n.__v+1,t.vnode&&t.vnode(a),L(e.__P,a,n,e.__n,e.__P.namespaceURI,32&n.__u?[o]:null,r,null==o?x(n):o,!!(32&n.__u),i),a.__v=n.__v,a.__.__k[a.__i]=a,O(r,a,i),n.__e=n.__=null,a.__e!=o&&M(a)}}function M(e){if(null!=(e=e.__)&&null!=e.__c)return e.__e=e.__c.base=null,e.__k.some(function(t){if(null!=t&&null!=t.__e)return e.__e=e.__c.base=t.__e}),M(e)}function I(e){(!e.__d&&(e.__d=!0)&&o.push(e)&&!$.__r++||r!=t.debounceRendering)&&((r=t.debounceRendering)||i)($)}function $(){try{for(var e,t=1;o.length;)o.length>t&&o.sort(a),e=o.shift(),t=o.length,N(e)}finally{o.length=$.__r=0}}function T(e,t,n,o,r,i,a,s,l,_,u){var c,p,d,f,g,y,w=o&&o.__k||m,b=t.length;for(l=function(e,t,n,o,r){var i,a,s,l,_,u=n.length,c=u,p=0;for(e.__k=new Array(r),i=0;i<r;i++)null!=(a=t[i])&&"boolean"!=typeof a&&"function"!=typeof a?("string"==typeof a||"number"==typeof a||"bigint"==typeof a||a.constructor==String?a=e.__k[i]=k(null,a,null,null,null):v(a)?a=e.__k[i]=k(C,{children:a},null,null,null):void 0===a.constructor&&a.__b>0?a=e.__k[i]=k(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):e.__k[i]=a,l=i+p,a.__=e,a.__b=e.__b+1,s=null,-1!=(_=a.__i=P(a,n,l,c))&&(c--,(s=n[_])&&(s.__u|=2)),null==s||null==s.__v?(-1==_&&(r>u?p--:r<u&&p++),"function"!=typeof a.type&&(a.__u|=4)):_!=l&&(_==l-1?p--:_==l+1?p++:(_>l?p--:p++,a.__u|=4))):e.__k[i]=null;if(c)for(i=0;i<u;i++)null!=(s=n[i])&&!(2&s.__u)&&(s.__e==o&&(o=x(s)),z(s,s));return o}(n,t,w,l,b),c=0;c<b;c++)null!=(d=n.__k[c])&&(p=-1!=d.__i&&w[d.__i]||h,d.__i=c,y=L(e,d,p,r,i,a,s,l,_,u),f=d.__e,d.ref&&p.ref!=d.ref&&(p.ref&&V(p.ref,null,d),u.push(d.ref,d.__c||f,d)),null==g&&null!=f&&(g=f),4&d.__u?(l=A(d,l,e),p.__e&&(p.__e=null)):"function"==typeof d.type&&void 0!==y?l=y:f&&(l=f.nextSibling),d.__u&=-7);return n.__e=g,l}function A(e,t,n){var o,r;if("function"==typeof e.type){for(o=e.__k,r=0;o&&r<o.length;r++)o[r]&&(o[r].__=e,t=A(o[r],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=x(e)),t=n.insertBefore(e.__e,t||null));do{t=t&&t.nextSibling}while(null!=t&&8==t.nodeType);return t}function H(e,t){return t=t||[],null==e||"boolean"==typeof e||(v(e)?e.some(function(e){H(e,t)}):t.push(e)),t}function P(e,t,n,o){var r,i,a,s=e.key,l=e.type,_=t[n],u=null!=_&&!(2&_.__u);if(null===_&&null==s||u&&s==_.key&&l==_.type)return n;if(o>(u?1:0))for(r=n-1,i=n+1;r>=0||i<t.length;)if(null!=(_=t[a=r>=0?r--:i++])&&!(2&_.__u)&&s==_.key&&l==_.type)return a;return-1}function E(e,t,n){"-"==t[0]?e.setProperty(t,null==n?"":n):e[t]=null==n?"":"number"!=typeof n||g.test(t)?n:n+"px"}function U(e,t,n,o,r){var i,a;e:if("style"==t)if("string"==typeof n)e.style.cssText=n;else{if("string"==typeof o&&(e.style.cssText=o=""),o)for(t in o)n&&t in n||E(e.style,t,"");if(n)for(t in n)o&&n[t]==o[t]||E(e.style,t,n[t])}else if("o"==t[0]&&"n"==t[1])i=t!=(t=t.replace(u,"$1")),a=t.toLowerCase(),t=a in e||"onFocusOut"==t||"onFocusIn"==t?a.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+i]=n,n?o?n[_]=o[_]:(n[_]=c,e.addEventListener(t,i?d:p,i)):e.removeEventListener(t,i?d:p,i);else{if("http://www.w3.org/2000/svg"==r)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=t&&"height"!=t&&"href"!=t&&"list"!=t&&"form"!=t&&"tabIndex"!=t&&"download"!=t&&"rowSpan"!=t&&"colSpan"!=t&&"role"!=t&&"popover"!=t&&t in e)try{e[t]=null==n?"":n;break e}catch(e){}"function"==typeof n||(null==n||!1===n&&"-"!=t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==n?"":n))}}function D(e){return function(n){if(this.l){var o=this.l[n.type+e];if(null==n[l])n[l]=c++;else if(n[l]<o[_])return;return o(t.event?t.event(n):n)}}}function L(e,n,o,r,i,a,s,l,_,u){var c,p,d,f,h,g,b,k,N,M,I,$,A,H,P,E,U=n.type;if(void 0!==n.constructor)return null;128&o.__u&&(_=!!(32&o.__u),a=[l=n.__e=o.__e]),(c=t.__b)&&c(n);e:if("function"==typeof U){p=s.length;try{if(N=n.props,M=U.prototype&&U.prototype.render,I=(c=U.contextType)&&r[c.__c],$=c?I?I.props.value:c.__:r,o.__c?k=(d=n.__c=o.__c).__=d.__E:(M?n.__c=d=new U(N,$):(n.__c=d=new S(N,$),d.constructor=U,d.render=W),I&&I.sub(d),d.state||(d.state={}),d.__n=r,f=d.__d=!0,d.__h=[],d._sb=[]),M&&null==d.__s&&(d.__s=d.state),M&&null!=U.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=y({},d.__s)),y(d.__s,U.getDerivedStateFromProps(N,d.__s))),h=d.props,g=d.state,d.__v=n,f)M&&null==U.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),M&&null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(M&&null==U.getDerivedStateFromProps&&N!==h&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(N,$),n.__v==o.__v||!d.__e&&null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(N,d.__s,$)){n.__v!=o.__v&&(d.props=N,d.state=d.__s,d.__d=!1),n.__e=o.__e,n.__k=o.__k,n.__k.some(function(e){e&&(e.__=n)}),m.push.apply(d.__h,d._sb),d._sb=[],d.__h.length&&s.push(d),l=x(o);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(N,d.__s,$),M&&null!=d.componentDidUpdate&&d.__h.push(function(){d.componentDidUpdate(h,g,b)})}if(d.context=$,d.props=N,d.__P=e,d.__e=!1,A=t.__r,H=0,M)d.state=d.__s,d.__d=!1,A&&A(n),c=d.render(d.props,d.state,d.context),m.push.apply(d.__h,d._sb),d._sb=[];else do{d.__d=!1,A&&A(n),c=d.render(d.props,d.state,d.context),d.state=d.__s}while(d.__d&&++H<25);d.state=d.__s,null!=d.getChildContext&&(r=y(y({},r),d.getChildContext())),M&&!f&&null!=d.getSnapshotBeforeUpdate&&(b=d.getSnapshotBeforeUpdate(h,g)),P=null!=c&&c.type===C&&null==c.key?F(c.props.children):c,l=T(e,v(P)?P:[P],n,o,r,i,a,s,l,_,u),d.base=n.__e,n.__u&=-161,d.__h.length&&s.push(d),k&&(d.__E=d.__=null)}catch(e){if(s.length=p,n.__v=null,_||null!=a){if(e.then){for(n.__u|=_?160:128;l&&8==l.nodeType&&l.nextSibling;)l=l.nextSibling;null!=a&&(a[a.indexOf(l)]=null),n.__e=l}else if(null!=a)for(E=a.length;E--;)w(a[E])}else n.__e=o.__e;null==n.__k&&(n.__k=o.__k||[]),e.then||R(n),t.__e(e,n,o)}}else null==a&&n.__v==o.__v?(n.__k=o.__k,n.__e=o.__e):l=n.__e=j(o.__e,n,o,r,i,a,s,_,u);return(c=t.diffed)&&c(n),128&n.__u?void 0:l}function R(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(R))}function O(e,n,o){for(var r=0;r<o.length;r++)V(o[r],o[++r],o[++r]);t.__c&&t.__c(n,e),e.some(function(n){try{e=n.__h,n.__h=[],e.some(function(e){e.call(n)})}catch(e){t.__e(e,n.__v)}})}function F(e){return"object"!=typeof e||null==e||e.__b>0?e:v(e)?e.map(F):void 0!==e.constructor?null:y({},e)}function j(n,o,r,i,a,s,l,_,u){var c,p,d,f,m,g,y,b=r.props||h,k=o.props,C=o.type;if("svg"==C?a="http://www.w3.org/2000/svg":"math"==C?a="http://www.w3.org/1998/Math/MathML":a||(a="http://www.w3.org/1999/xhtml"),null!=s)for(c=0;c<s.length;c++)if((m=s[c])&&"setAttribute"in m==!!C&&(C?m.localName==C:3==m.nodeType)){n=m,s[c]=null;break}if(null==n){if(null==C)return document.createTextNode(k);n=document.createElementNS(a,C,k.is&&k),_&&(t.__m&&t.__m(o,s),_=!1),s=null}if(null==C)b===k||_&&n.data==k||(n.data=k);else{if(s="textarea"==C&&null!=k.defaultValue?null:s&&e.call(n.childNodes),!_&&null!=s)for(b={},c=0;c<n.attributes.length;c++)b[(m=n.attributes[c]).name]=m.value;for(c in b)m=b[c],"dangerouslySetInnerHTML"==c?d=m:"children"==c||c in k||"value"==c&&"defaultValue"in k||"checked"==c&&"defaultChecked"in k||U(n,c,null,m,a);for(c in k)m=k[c],"children"==c?f=m:"dangerouslySetInnerHTML"==c?p=m:"value"==c?g=m:"checked"==c?y=m:_&&"function"!=typeof m||b[c]===m||U(n,c,m,b[c],a);if(p)_||d&&(p.__html==d.__html||p.__html==n.innerHTML)||(n.innerHTML=p.__html),o.__k=[];else if(d&&(n.innerHTML=""),T("template"==o.type?n.content:n,v(f)?f:[f],o,r,i,"foreignObject"==C?"http://www.w3.org/1999/xhtml":a,s,l,s?s[0]:r.__k&&x(r,0),_,u),null!=s)for(c=s.length;c--;)w(s[c]);_&&"textarea"!=C||(c="value","progress"==C&&null==g?n.removeAttribute("value"):null!=g&&(g!==n[c]||"progress"==C&&!g||"option"==C&&g!=b[c])&&U(n,c,g,b[c],a),c="checked",null!=y&&y!=n[c]&&U(n,c,y,b[c],a))}return n}function V(e,n,o){try{if("function"==typeof e){var r="function"==typeof e.__u;r&&e.__u(),r&&null==n||(e.__u=e(n))}else e.current=n}catch(e){t.__e(e,o)}}function z(e,n,o){var r,i;if(t.unmount&&t.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||V(r,null,n)),null!=(r=e.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){t.__e(e,n)}r.base=r.__P=r.__n=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&z(r[i],n,o||"function"!=typeof e.type);o||w(e.__e),e.__c=e.__=e.__e=void 0}function W(e,t,n){return this.constructor(e,n)}function q(n,o,r){var i,a,s,l;o==document&&(o=document.documentElement),t.__&&t.__(n,o),a=(i="function"==typeof r)?null:r&&r.__k||o.__k,s=[],l=[],L(o,n=(!i&&r||o).__k=b(C,null,[n]),a||h,h,o.namespaceURI,!i&&r?[r]:a?null:o.firstChild?e.call(o.childNodes):null,s,!i&&r?r:a?a.__e:o.firstChild,i,l),O(s,n,l),n.props.children=null}function B(e,t){q(e,t,B)}function Z(t,n,o){var r,i,a,s,l=y({},t.props);for(a in t.type&&t.type.defaultProps&&(s=t.type.defaultProps),n)"key"==a?r=n[a]:"ref"==a?i=n[a]:l[a]=void 0===n[a]&&null!=s?s[a]:n[a];return arguments.length>2&&(l.children=arguments.length>3?e.call(arguments,2):o),k(t.type,l,r||t.key,i||t.ref,null)}e=m.slice,t={__e:function(e,t,n,o){for(var r,i,a;t=t.__;)if((r=t.__c)&&!r.__)try{if((i=r.constructor)&&null!=i.getDerivedStateFromError&&(r.setState(i.getDerivedStateFromError(e)),a=r.__d),null!=r.componentDidCatch&&(r.componentDidCatch(e,o||{}),a=r.__d),a)return r.__E=r}catch(t){e=t}throw e}},n=0,S.prototype.setState=function(e,t){var n;n=null!=this.__s&&this.__s!=this.state?this.__s:this.__s=y({},this.state),"function"==typeof e&&(e=e(y({},n),this.props)),e&&y(n,e),null!=e&&this.__v&&(t&&this._sb.push(t),I(this))},S.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),I(this))},S.prototype.render=C,o=[],i="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,a=function(e,t){return e.__v.__b-t.__v.__b},$.__r=0,s=Math.random().toString(8),l="__d"+s,_="__a"+s,u=/(PointerCapture)$|Capture$/i,c=0,p=D(!1),d=D(!0),f=0;var Y,J,G,Q,K=0,X=[],ee=t,te=ee.__b,ne=ee.__r,oe=ee.diffed,re=ee.__c,ie=ee.unmount,ae=ee.__;function se(e,t){ee.__h&&ee.__h(J,e,K||t),K=0;var n=J.__H||(J.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function le(e){return K=1,_e(xe,e)}function _e(e,t,n){var o=se(Y++,2);if(o.t=e,!o.__c&&(o.__=[n?n(t):xe(void 0,t),function(e){var t=o.__N?o.__N[0]:o.__[0],n=o.t(t,e);t!==n&&(o.__N=[n,o.__[1]],o.__c.setState({}))}],o.__c=J,!J.__f)){var r=function(e,t,n){if(!o.__c.__H)return!0;var r=!1,a=o.__c.props!==e;if(o.__c.__H.__.some(function(e){if(e.__N){r=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(a=!0)}}),i){var s=i.call(this,e,t,n);return r?s||a:s}return!r||a};J.__f=!0;var i=J.shouldComponentUpdate,a=J.componentWillUpdate;J.componentWillUpdate=function(e,t,n){if(this.__e){var o=i;i=void 0,r(e,t,n),i=o}a&&a.call(this,e,t,n)},J.shouldComponentUpdate=r}return o.__N||o.__}function ue(e,t){var n=se(Y++,3);!ee.__s&&Se(n.__H,t)&&(n.__=e,n.u=t,J.__H.__h.push(n))}function ce(e,t){var n=se(Y++,4);!ee.__s&&Se(n.__H,t)&&(n.__=e,n.u=t,J.__h.push(n))}function pe(e){return K=5,fe(function(){return{current:e}},[])}function de(e,t,n){K=6,ce(function(){if("function"==typeof e){var n=e(t());return function(){e(null),n&&"function"==typeof n&&n()}}if(e)return e.current=t(),function(){return e.current=null}},null==n?n:n.concat(e))}function fe(e,t){var n=se(Y++,7);return Se(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function he(e,t){return K=8,fe(function(){return e},t)}function me(e){var t=J.context[e.__c],n=se(Y++,9);return n.c=e,t?(null==n.__&&(n.__=!0,t.sub(J)),t.props.value):e.__}function ge(e,t){ee.useDebugValue&&ee.useDebugValue(t?t(e):e)}function ve(){var e=se(Y++,11);if(!e.__){for(var t=J.__v;null!==t&&!t.__m&&null!==t.__;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__="P"+n[0]+"-"+n[1]++}return e.__}function ye(){for(var e;e=X.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(ke),t.__h.some(Ce),t.__h=[]}catch(n){t.__h=[],ee.__e(n,e.__v)}}}ee.__b=function(e){J=null,te&&te(e)},ee.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ae&&ae(e,t)},ee.__r=function(e){ne&&ne(e),Y=0;var t=(J=e.__c).__H;t&&(G===J?(t.__h=[],J.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(ke),t.__h.some(Ce),t.__h=[],Y=0)),G=J},ee.diffed=function(e){oe&&oe(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(1!==X.push(t)&&Q===ee.requestAnimationFrame||((Q=ee.requestAnimationFrame)||be)(ye)),t.__H.__.some(function(e){e.u&&(e.__H=e.u,e.u=void 0)})),G=J=null},ee.__c=function(e,t){t.some(function(e){try{e.__h.some(ke),e.__h=e.__h.filter(function(e){return!e.__||Ce(e)})}catch(n){t.some(function(e){e.__h&&(e.__h=[])}),t=[],ee.__e(n,e.__v)}}),re&&re(e,t)},ee.unmount=function(e){ie&&ie(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{ke(e)}catch(e){t=e}}),n.__H=void 0,t&&ee.__e(t,n.__v))};var we="function"==typeof requestAnimationFrame;function be(e){var t,n=function(){clearTimeout(o),we&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(n,35);we&&(t=requestAnimationFrame(n))}function ke(e){var t=J,n=e.__c;"function"==typeof n&&(e.__c=void 0,n()),J=t}function Ce(e){var t=J;e.__c=e.__(),J=t}function Se(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function xe(e,t){return"function"==typeof t?t(e):t}function Ne(e,t){for(var n in t)e[n]=t[n];return e}function Me(e,t){for(var n in e)if("__source"!==n&&!(n in t))return!0;for(var o in t)if("__source"!==o&&e[o]!==t[o])return!0;return!1}function Ie(e,t){var n=t(),o=le({t:{__:n,u:t}}),r=o[0].t,i=o[1];return ce(function(){r.__=n,r.u=t,$e(r)&&i({t:r})},[e,n,t]),ue(function(){return $e(r)&&i({t:r}),e(function(){$e(r)&&i({t:r})})},[e]),n}function $e(e){try{return!((t=e.__)===(n=e.u())&&(0!==t||1/t==1/n)||t!=t&&n!=n)}catch(e){return!0}var t,n}function Te(e){e()}function Ae(e){return e}function He(){return[!1,Te]}var Pe=ce;function Ee(e,t){this.props=e,this.context=t}(Ee.prototype=new S).isPureReactComponent=!0,Ee.prototype.shouldComponentUpdate=function(e,t){return Me(this.props,e)||Me(this.state,t)};var Ue=t.__b;t.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Ue&&Ue(e)};var De="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.forward_ref")||3911;var Le=function(e,t){return null==e?null:H(H(e).map(t))},Re={map:Le,forEach:Le,count:function(e){return e?H(e).length:0},only:function(e){var t=H(e);if(1!==t.length)throw"Children.only";return t[0]},toArray:H},Oe=t.__e;t.__e=function(e,t,n,o){if(e.then)for(var r,i=t;i=i.__;)if((r=i.__c)&&r.__c)return null==t.__e&&(t.__e=n.__e,t.__k=n.__k||[]),r.__c(e,t);Oe(e,t,n,o)};var Fe=t.unmount;function je(e,t,n){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(e){"function"==typeof e.__c&&e.__c()}),e.__c.__H=null),null!=(e=Ne({},e)).__c&&(e.__c.__P===n&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(e){return je(e,t,n)})),e}function Ve(e,t,n){return e&&n&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(e){return Ve(e,t,n)}),e.__c&&e.__c.__P===t&&(e.__e&&n.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=n)),e}function ze(){this.__u=0,this.o=null,this.__b=null}function We(e){var t=e.__&&e.__.__c;return t&&t.__a&&t.__a(e)}function qe(e){var t,n,o,r=null;function i(i){if(t||(t=e()).then(function(e){e&&(r=e.default||e),o=!0},function(e){n=e,o=!0}),n)throw n;if(!o)throw t;return r?b(r,i):null}return i.displayName="Lazy",i.__f=!0,i}function Be(){this.i=null,this.l=null}t.unmount=function(e){var t=e.__c;t&&(t.__z=!0),t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Fe&&Fe(e)},(ze.prototype=new S).__c=function(e,t){var n=t.__c,o=this;null==o.o&&(o.o=[]),o.o.push(n);var r=We(o.__v),i=!1,a=function(){i||o.__z||(i=!0,n.__R=null,r?r(l):l())};n.__R=a;var s=n.__P;n.__P=null;var l=function(){if(! --o.__u){if(o.state.__a){var e=o.state.__a;o.__v.__k[0]=Ve(e,e.__c.__P,e.__c.__O)}var t;for(o.setState({__a:o.__b=null});t=o.o.pop();)t.__P=s,t.forceUpdate()}};o.__u++||32&t.__u||o.setState({__a:o.__b=o.__v.__k[0]}),e.then(a,a)},ze.prototype.componentWillUnmount=function(){this.o=[]},ze.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var n=document.createElement("div"),o=this.__v.__k[0].__c;this.__v.__k[0]=je(this.__b,n,o.__O=o.__P)}this.__b=null}var r=t.__a&&b(C,null,e.fallback);return r&&(r.__u&=-33),[b(C,null,t.__a?null:e.children),r]};var Ze=function(e,t,n){if(++n[1]===n[0]&&e.l.delete(t),e.props.revealOrder&&("t"!==e.props.revealOrder[0]||!e.l.size))for(n=e.i;n;){for(;n.length>3;)n.pop()();if(n[1]<n[0])break;e.i=n=n[2]}};function Ye(e){return this.getChildContext=function(){return e.context},e.children}function Je(e){var t=this,n=e.h;if(t.componentWillUnmount=function(){q(null,t.v),t.v=null,t.h=null},t.h&&t.h!==n&&t.componentWillUnmount(),!t.v){for(var o=t.__v;null!==o&&!o.__m&&null!==o.__;)o=o.__;t.h=n,t.v={nodeType:1,parentNode:n,childNodes:[],__k:{__m:o.__m},contains:function(){return!0},namespaceURI:n.namespaceURI,insertBefore:function(e,n){this.childNodes.push(e),t.h.insertBefore(e,n)},removeChild:function(e){this.childNodes.splice(this.childNodes.indexOf(e)>>>1,1),t.h.removeChild(e)}}}q(b(Ye,{context:t.context},e.__v),t.v)}(Be.prototype=new S).__a=function(e){var t=this,n=We(t.__v),o=t.l.get(e);return o[0]++,function(r){var i=function(){t.props.revealOrder?(o.push(r),Ze(t,e,o)):r()};n?n(i):i()}},Be.prototype.render=function(e){this.i=null,this.l=new Map;var t=H(e.children);e.revealOrder&&"b"===e.revealOrder[0]&&t.reverse();for(var n=t.length;n--;)this.l.set(t[n],this.i=[1,0,this.i]);return e.children},Be.prototype.componentDidUpdate=Be.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,n){Ze(e,n,t)})};var Ge="undefined"!=typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,Qe=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,Ke=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Xe=/[A-Z0-9]/g,et="undefined"!=typeof document,tt=function(e){return("undefined"!=typeof Symbol&&"symbol"==typeof Symbol()?/fil|che|rad/:/fil|che|ra/).test(e)};function nt(e,t,n){return null==t.__k&&(t.textContent=""),q(e,t),"function"==typeof n&&n(),e?e.__c:null}S.prototype.isReactComponent=!0,["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(S.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var ot=t.event;t.event=function(e){return ot&&(e=ot(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var rt,it={configurable:!0,get:function(){return this.class}},at=t.vnode;t.vnode=function(e){"string"==typeof e.type&&function(e){var t=e.props,n=e.type,o={},r=-1==n.indexOf("-");for(var i in t){var a=t[i];if(!("value"===i&&"defaultValue"in t&&null==a||et&&"children"===i&&"noscript"===n||"class"===i||"className"===i)){var s=i.toLowerCase();"defaultValue"===i&&"value"in t&&null==t.value?i="value":"download"===i&&!0===a?a="":"translate"===s&&"no"===a?a=!1:"o"===s[0]&&"n"===s[1]?"ondoubleclick"===s?i="ondblclick":"onchange"!==s||"input"!==n&&"textarea"!==n||tt(t.type)?"onfocus"===s?i="onfocusin":"onblur"===s?i="onfocusout":Ke.test(i)&&(i=s):s=i="oninput":r&&Qe.test(i)?i=i.replace(Xe,"-$&").toLowerCase():null===a&&(a=void 0),"oninput"===s&&o[i=s]&&(i="oninputCapture"),o[i]=a}}"select"==n&&(o.multiple&&Array.isArray(o.value)&&(o.value=H(t.children).forEach(function(e){e.props.selected=-1!=o.value.indexOf(e.props.value)})),null!=o.defaultValue&&(o.value=H(t.children).forEach(function(e){e.props.selected=o.multiple?-1!=o.defaultValue.indexOf(e.props.value):o.defaultValue==e.props.value}))),t.class&&!t.className?(o.class=t.class,Object.defineProperty(o,"className",it)):t.className&&(o.class=o.className=t.className),e.props=o}(e),e.$$typeof=Ge,at&&at(e)};var st=t.__r;t.__r=function(e){st&&st(e),rt=e.__c};var lt=t.diffed;t.diffed=function(e){lt&&lt(e);var t=e.props,n=e.__e;null!=n&&"textarea"===e.type&&"value"in t&&t.value!==n.value&&(n.value=null==t.value?"":t.value),rt=null};var _t={ReactCurrentDispatcher:{current:{readContext:function(e){return rt.__n[e.__c].props.value},useCallback:he,useContext:me,useDebugValue:ge,useDeferredValue:Ae,useEffect:ue,useId:ve,useImperativeHandle:de,useInsertionEffect:Pe,useLayoutEffect:ce,useMemo:fe,useReducer:_e,useRef:pe,useState:le,useSyncExternalStore:Ie,useTransition:He}}};function ut(e){return!!e&&e.$$typeof===Ge}function ct(e){return!!e.__k&&(q(null,e),!0)}var pt={useState:le,useId:ve,useReducer:_e,useEffect:ue,useLayoutEffect:ce,useInsertionEffect:Pe,useTransition:He,useDeferredValue:Ae,useSyncExternalStore:Ie,startTransition:Te,useRef:pe,useImperativeHandle:de,useMemo:fe,useCallback:he,useContext:me,useDebugValue:ge,version:"18.3.1",Children:Re,render:nt,hydrate:function(e,t,n){return B(e,t),"function"==typeof n&&n(),e?e.__c:null},unmountComponentAtNode:ct,createPortal:function(e,t){var n=b(Je,{__v:e,h:t});return n.containerInfo=t,n},createElement:b,createContext:function(e){function t(e){var n,o;return this.getChildContext||(n=new Set,(o={})[t.__c]=this,this.getChildContext=function(){return o},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach(function(e){e.__e=!0,I(e)})},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.delete(e),t&&t.call(e)}}),e.children}return t.__c="__cC"+f++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t},createFactory:function(e){return b.bind(null,e)},cloneElement:function(e){return ut(e)?Z.apply(null,arguments):e},createRef:function(){return{current:null}},Fragment:C,isValidElement:ut,isElement:ut,isFragment:function(e){return ut(e)&&e.type===C},isMemo:function(e){return!!e&&"string"==typeof e.displayName&&0==e.displayName.indexOf("Memo(")},findDOMNode:function(e){return e&&(e.base||1===e.nodeType&&e)||null},Component:S,PureComponent:Ee,memo:function(e,t){function n(e){var n=this.props.ref;return n!=e.ref&&n&&("function"==typeof n?n(null):n.current=null),t?!t(this.props,e)||n!=e.ref:Me(this.props,e)}function o(t){return this.shouldComponentUpdate=n,b(e,t)}return o.displayName="Memo("+(e.displayName||e.name)+")",o.__f=o.prototype.isReactComponent=!0,o.type=e,o},forwardRef:function(e){function t(t){var n=Ne({},t);return delete n.ref,e(n,t.ref||null)}return t.$$typeof=De,t.render=e,t.prototype.isReactComponent=t.__f=!0,t.displayName="ForwardRef("+(e.displayName||e.name)+")",t},flushSync:function(e,n){var o,r=t.debounceRendering;t.debounceRendering=function(e){o=e};try{var i=e(n);return o&&o(),i}finally{t.debounceRendering=r}},unstable_batchedUpdates:function(e,t){return e(t)},StrictMode:C,Suspense:ze,SuspenseList:Be,lazy:qe,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:_t};function dt(e){return{render:function(t){nt(t,e)},unmount:function(){ct(e)}}}const ft=e=>({size:t=24,color:n="currentColor",strokeWidth:o=2,...r})=>pt.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:n,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",...r},e.map(([e,t],n)=>pt.createElement(e,{key:n,...t}))),ht=ft([["path",{d:"M18 6 6 18"}],["path",{d:"m6 6 12 12"}]]),mt=ft([["path",{d:"M5 12h14"}]]),gt=ft([["path",{d:"m5 12 7-7 7 7"}],["path",{d:"M12 19V5"}]]),vt=ft([["path",{d:"M12 19v3"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3"}]]),yt=ft([["path",{d:"M15 3h6v6"}],["path",{d:"m21 3-7 7"}],["path",{d:"m3 21 7-7"}],["path",{d:"M9 21H3v-6"}]]),wt=ft([["path",{d:"m14 10 7-7"}],["path",{d:"M20 10h-6V4"}],["path",{d:"m3 21 7-7"}],["path",{d:"M4 14h6v6"}]]),bt=ft([["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551"}]]),kt=ft([["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9"}]]),Ct=ft([["path",{d:"m9 18 6-6-6-6"}]]),St=ft([["path",{d:"m15 18-6-6 6-6"}]]),xt=ft([["path",{d:"M12 7v14"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z"}]]),Nt=ft([["path",{d:"m6 9 6 6 6-6"}]]),Mt=ft([["path",{d:"M7 10v12"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"}]]),It=ft([["path",{d:"M17 14V2"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z"}]]),$t=ft([["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"}]]),Tt=ft([["path",{d:"M20 6 9 17l-5-5"}]]),At=ft([["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .962 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.962 0z"}],["path",{d:"M20 3v4"}],["path",{d:"M22 5h-4"}]]),Ht=({size:e=22,className:t,style:n},o,r)=>pt.createElement("svg",{width:e,height:e,viewBox:o,fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,style:n,"aria-hidden":"true",focusable:"false"},r),Pt=e=>Ht(e,"0 0 128 128",pt.createElement("g",{fill:"currentColor"},pt.createElement("path",{d:"M109,55c0-29.8-24.2-54-54-54C25.2,1,1,25.2,1,55s24.2,54,54,54c13.5,0,25.8-5,35.2-13.1l25.4,25.4l5.7-5.7L95.9,90.2C104,80.8,109,68.5,109,55z M55,101C29.6,101,9,80.4,9,55S29.6,9,55,9s46,20.6,46,46S80.4,101,55,101z"}),pt.createElement("path",{d:"M25.6,30.9l6.2,5.1C37.5,29,46,25,55,25v-8C43.6,17,32.9,22.1,25.6,30.9z"}),pt.createElement("path",{d:"M17,55h8c0-2.1,0.2-4.1,0.6-6.1l-7.8-1.6C17.3,49.8,17,52.4,17,55z"}))),Et=e=>Ht(e,"0 0 24 24",pt.createElement("path",{fill:"currentColor",d:"M16 2H8C4 2 2 4 2 8V21C2 21.55 2.45 22 3 22H16C20 22 22 20 22 16V8C22 4 20 2 16 2ZM14 15.25H7C6.59 15.25 6.25 14.91 6.25 14.5C6.25 14.09 6.59 13.75 7 13.75H14C14.41 13.75 14.75 14.09 14.75 14.5C14.75 14.91 14.41 15.25 14 15.25ZM17 10.25H7C6.59 10.25 6.25 9.91 6.25 9.5C6.25 9.09 6.59 8.75 7 8.75H17C17.41 8.75 17.75 9.09 17.75 9.5C17.75 9.91 17.41 10.25 17 10.25Z"})),Ut=({size:e=26,className:t,style:n})=>pt.createElement("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,style:n,"aria-hidden":"true",focusable:"false"},pt.createElement("g",{transform:"translate(24 0) scale(-1 1)"},pt.createElement("path",{fill:"currentColor",fillRule:"evenodd",clipRule:"evenodd",d:"M16 2H8C4 2 2 4 2 8V21C2 21.55 2.45 22 3 22H16C20 22 22 20 22 16V8C22 4 20 2 16 2ZM15.5 12.75H8.5C8.09 12.75 7.75 12.41 7.75 12C7.75 11.59 8.09 11.25 8.5 11.25H15.5C15.91 11.25 16.25 11.59 16.25 12C16.25 12.41 15.91 12.75 15.5 12.75Z"}))),Dt=e=>Ht(e,"0 0 24 24",pt.createElement(pt.Fragment,null,pt.createElement("path",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",d:"M12 20H12.01"}),pt.createElement("path",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",d:"M7 9C7 7.87439 7.37194 6.83566 7.99963 6C8.91184 4.78555 10.3642 4 12 4C14.7614 4 17 6.23858 17 9C17 11.4212 15.279 13.4405 12.9936 13.9013C12.4522 14.0104 12 14.4477 12 15V15V16"}))),Lt={launcher_open:"Open support chat",launcher_close:"Close support chat",launcher_open_unread_one:"Open support chat, {count} new message",launcher_open_unread_other:"Open support chat, {count} new messages",launcher_unread_overflow:"{count}+",panel_label:"{organizationName} support",header_messages:"Messages",header_help_center:"Help Center",header_back_to_conversations:"Back to conversations",header_expand:"Expand window",header_collapse:"Collapse window",header_close:"Close",conversation_label:"Conversation",sending_to_team:"Sending to the team…",uploading_attachment:"Uploading attachment…",new_messages_one:"{count} new message",new_messages_other:"{count} new messages",reaction_helpful:"Helpful",reaction_not_helpful:"Not helpful",copy_message:"Copy message",copied:"Copied",message_from_agent:"Agent",message_from_you:"You",terms_notice:"By chatting, you agree to our {terms}",terms_link:"Terms",powered_by:"Powered by {brand}",tab_explore:"Explore",tab_messages:"Messages",tab_help:"Help",tabs_label:"Sections",conversations_empty_title:"No conversations yet",conversations_empty_desc:"Start a chat and our AI agent & team will help you out.",conversation_no_messages:"No messages yet",conversation_title:"Chat #{number}",conversation_closed_chip:"Closed",start_new_chat:"Ask a Question",message_not_sent:"Not sent",message_retry:"Retry",conversation_closed:"This conversation was closed. Send a message to reopen it, or start a new one.",conversation_with_agent:"This conversation has been passed to our team. Replies may take a little longer.",composer_label:"Message",composer_placeholder:"Type your message…",composer_placeholder_lead_required:"Add your email above to continue…",composer_placeholder_security_check:"Verify security check to chat…",composer_hint:"Press Enter to send, Shift+Enter for a new line",attach_file:"Attach a file (10 MB max)",insert_emoji:"Insert emoji",emoji_picker_label:"Choose an emoji",send_message:"Send message",attachment_image_alt:"Image attachment",attachment_file_label:"File attachment: {name}",attachment_remove:"Remove {name}",attachment_uploading:"Uploading {name}, {percent}%",attachment_too_large:"Too large (10 MB limit)",attachment_failed:"Upload failed",attachment_rejected:"File type not allowed",attachment_limit:"You can attach up to {count} files per message.",attachment_drop_hint:"Drop files to attach them",attachment_open:"Open {name}",attachments_summary_one:"{count} attachment",attachments_summary_other:"{count} attachments",feedback_comment_prompt:"What was wrong? (optional)",feedback_comment_placeholder:"Tell us a little more…",feedback_comment_send:"Send",feedback_comment_skip:"Skip",feedback_thanks:"Thanks for your feedback",notice_security_check_required:"Please complete the security check first.",voice_start:"Voice input",voice_finish:"Finish recording",voice_status_waiting:"Waiting for the microphone…",voice_status_listening:"Listening…",voice_status_transcribing:"Transcribing…",voice_seconds_left_one:"{count} second left",voice_seconds_left_other:"{count} seconds left",voice_countdown:"{count}s",voice_cancel:"Cancel voice input",voice_stop:"Stop and transcribe",voice_retry:"Try again",voice_error_insecure:"Voice input needs a secure (https) page.",voice_error_unsupported:"Voice input isn't supported in this browser.",voice_error_denied:"Microphone access is blocked. Allow it in your browser's site settings to use voice input.",voice_error_no_microphone:"No microphone was found.",voice_error_no_speech:"I didn't catch that. Please try again.",voice_error_no_audio:"No sound is coming from your microphone. Check that it isn't muted and that the right one is selected.",voice_error_limit:"Voice input isn't available right now. Please type your message.",voice_error_disabled:"Voice input is turned off.",voice_error_network:"Your recording couldn't be transcribed. Check your connection and try again.",voice_error_failed:"Your recording couldn't be transcribed. Please try again or type your message.",lead_prompt:"Leave your email and we'll reply there if you've gone.",lead_email_placeholder:"you@example.com",lead_email_label:"Your email address",lead_save:"Save",lead_saving:"Saving…",lead_dismiss:"No thanks",lead_error_invalid_email:"That doesn't look like an email address.",lead_error_save_failed:"Couldn't save that just now. You can carry on chatting.",greeting_default:"Hi from {organizationName}. How can we help?",greeting_default_persona:"Hi, I'm {ai_name} from {organizationName}. How can I help?",greeting_dismiss:"Dismiss greeting",welcome_default:"Hi! How can I help you today?",explore_hero_title:"Hello there",explore_hero_subtitle:"How can we help?",explore_search_placeholder:"Search for help…",explore_cta_title:"Ask our AI Agent",explore_cta_sub:"Instant answers, 24/7 — or reach the team",explore_tile_help_title:"Help Center",explore_tile_help_sub:"Guides & docs",explore_tile_messages_title:"Messages",explore_tile_messages_sub:"Your conversations",explore_popular_questions:"Popular questions",explore_ask_ai_about_this:"Ask AI Agent about this",explore_recommended_reading:"Recommended reading",help_search_placeholder:"Search for articles…",help_search_label:"Search articles",help_searching:"Searching…",help_search_no_results:"No articles matching “{query}”",help_all_collections:"All Collections",help_back_to_articles:"Back to articles",help_document_type_fallback:"Guide",help_written_by:"Written by the {organizationName} support team",help_updated_recently:"Updated recently",help_read_time_one:"{count} min read",help_read_time_other:"{count} min read",help_feedback_title:"Did this answer your question?",help_feedback_thanks:"Thank you for your feedback!",help_feedback_yes:"Yes",help_feedback_somewhat:"Somewhat",help_feedback_no:"No",help_handoff_title:"Still have questions?",help_handoff_desc:"Ask our AI Agent for instant answers",help_handoff_prefill:"I have a question about the article “{title}”: ",help_collection_articles:"{collection} articles ({count})",help_article_count_one:"{count} article",help_article_count_other:"{count} articles",help_empty_title:"Help Documentation",help_empty_desc:"Search above to fetch instant solutions from our knowledge base.",help_collection_guide_title:"Guides & Tutorials",help_collection_guide_desc:"Setup walkthroughs, rules, and getting started guides",help_collection_faq_title:"Frequently Asked Questions",help_collection_faq_desc:"Quick answers to common account and service questions",help_collection_troubleshooting_title:"Troubleshooting & Support",help_collection_troubleshooting_desc:"Step-by-step solutions for technical issues",help_collection_other_title:"Rules & Documentation",help_collection_other_desc:"Official terms, rules, and policy documentation",help_featured_article:"Featured Article",help_untitled_article:"Untitled Article",help_unavailable:"The help centre couldn't be loaded. Check your connection and try again.",help_updated_on:"Updated {date}",help_open_site:"Open in Help Centre",help_article_unavailable:"This article couldn't be loaded.",hours_away_until:"We're away right now and will be back {time}. Leave a message and we'll reply by email.",hours_away:"We're away right now. Leave a message and we'll reply by email.",link_opens_new_tab:"(opens in a new tab)",error_search_rate_limited:"You're searching too fast. Please wait a moment and try again.",error_search_unavailable:"Search is unavailable right now. Please try again shortly.",error_send_rate_limited:"You're sending messages too quickly. Please wait a moment and try again.",error_attachment_rejected:"That file can't be attached. It may be too large (10 MB limit) or a type that isn't allowed.",error_attachment_upload_failed:"That attachment couldn't be uploaded. Please try again."},Rt={ar:()=>import("./ar-DWu25Uo_.js"),de:()=>import("./de-CXvx-VOw.js"),es:()=>import("./es-B8CNwk2c.js"),fr:()=>import("./fr-CVfeNRtY.js"),hi:()=>import("./hi-fJomdKtz.js"),pt:()=>import("./pt-BcilM4jM.js")},Ot=["ar","he","fa","ur","ps","sd","yi","dv","ug"];let Ft="en",jt=0,Vt={},zt={};const Wt=new Set,qt={en:{}};function Bt(){Wt.forEach(e=>{try{e()}catch{}})}function Zt(){return Ft}function Yt(){return-1!==Ot.indexOf(Ft.split("-")[0].toLowerCase())?"rtl":"ltr"}function Jt(e){if(!e)return"en";const t=String(e).trim(),n=t.split(/[-_]/)[0].toLowerCase(),o=t.replace("_","-");return"en"===n||Rt[n]?o:"en"}async function Gt(e){let t=Jt(e),n=t.split("-")[0];const o=++jt;if(void 0===qt[n])try{const e=(await Rt[n]()).default;qt[n]=e}catch(e){console.warn(`[Askly] Could not load the "${n}" translations; staying in English.`,e),t="en",n="en"}return o!==jt||(Ft=t,Vt=qt[n],Bt()),Ft}function Qt(e){zt={...zt,...e},Bt()}function Kt(e){return Wt.add(e),()=>{Wt.delete(e)}}function Xt(e,t){return t?e.replace(/\{(\w+)\}/g,(e,n)=>n in t?String(t[n]):e):e}function en(e,t){var n,o,r;return Xt(null!==(r=null!==(o=null!==(n=zt[e])&&void 0!==n?n:Vt[e])&&void 0!==o?o:Lt[e])&&void 0!==r?r:e,t)}function tn(e,t,n){var o,r;let i="other";try{i=new Intl.PluralRules(Ft).select(t)}catch{}const a=[`${e}_${i}`,`${e}_other`,`${e}_one`];let s;for(const e of a)if(s=null!==(r=null!==(o=zt[e])&&void 0!==o?o:Vt[e])&&void 0!==r?r:Lt[e],void 0!==s)break;return Xt(null!=s?s:e,{count:nn(t)})}function nn(e){try{return new Intl.NumberFormat(Ft).format(e)}catch{return String(e)}}function on(e){if(!e)return"";const t=new Date(e);if(isNaN(t.getTime()))return"";try{return new Intl.DateTimeFormat(Ft,{year:"numeric",month:"short",day:"numeric"}).format(t)}catch{return t.toLocaleDateString()}}function rn(e){if(!e)return"";const t=new Date(e);if(isNaN(t.getTime()))return"";try{const e=new Date,n=t.toDateString()===e.toDateString();return new Intl.DateTimeFormat(Ft,n?{hour:"numeric",minute:"2-digit"}:{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(t)}catch{return t.toLocaleTimeString()}}const an={};function sn(e,t){return(an[e]=an[e]||[]).push(t),()=>ln(e,t)}function ln(e,t){const n=an[e];if(n)for(let e=n.length-1;e>=0;e--)n[e]!==t&&n[e].original!==t||n.splice(e,1)}function _n(e,t){const n=o=>{ln(e,n),t(o)};return n.original=t,sn(e,n)}function un(e,...t){const n=an[e];if(n)for(const o of n.slice())try{o(t[0])}catch(t){console.error(`[Askly] "${e}" handler failed:`,t)}}let cn=null,pn=[],dn=!1;function fn(){dn=!0}function hn(e){cn?cn(e):dn?pn.push(e):console.warn(`[Askly] ${e.type}() ignored: the widget is not initialised on this page.`)}function mn(e){cn=e,dn=!1;const t=pn;return pn=[],t.forEach(e),()=>{cn===e&&(cn=null)}}function gn(){pn=[],dn=!1}const vn={ready:!1,open:!1,unread:0,visitorId:""};function yn(){vn.ready=!1,vn.open=!1,vn.unread=0,vn.visitorId=""}function wn(e,t){if(!e||"string"!=typeof e.id||"string"!=typeof e.title)return null;const n=("string"==typeof e.collection?e.collection:"guide").toLowerCase();return{id:e.id,title:e.title,content:"string"==typeof e.content?e.content:"",document_type:kn(n,t),collection:n,excerpt:"string"==typeof e.excerpt?e.excerpt:void 0,updatedAt:"string"==typeof e.updated_at?e.updated_at:void 0,url:"string"==typeof e.url&&/^https?:\/\//i.test(e.url)?e.url:void 0,featured:!!e.featured,source:"help",score:"number"==typeof e.score?e.score:0}}function bn(e){return e&&"string"==typeof e.id?{id:e.id.toLowerCase(),name:"string"==typeof e.name?e.name:e.id,description:"string"==typeof e.description?e.description:"",parentId:"string"==typeof e.parent_id?e.parent_id.toLowerCase():void 0,icon:"string"==typeof e.icon?e.icon:"folder"}:null}function kn(e,t){let n=e;for(let e=0;e<4;e++){const e=t.find(e=>e.id===n);if(!e||!e.parentId)return n;n=e.parentId}return n}function Cn(e){if(!e||"object"!=typeof e||"string"!=typeof e.timezone||"object"!=typeof e.schedule||!e.schedule)return null;const t={};for(const n of Object.keys(e.schedule)){const o=Array.isArray(e.schedule[n])?e.schedule[n]:[];t[n]=o.filter(e=>e&&"string"==typeof e.start&&"string"==typeof e.end).map(e=>({start:e.start,end:e.end}))}return{timezone:e.timezone,schedule:t,outsideMessage:"string"==typeof e.outsideMessage&&e.outsideMessage.trim()?e.outsideMessage:null,open:!!e.open,nextChangeAt:"string"==typeof e.nextChangeAt?e.nextChangeAt:null}}const Sn=["sun","mon","tue","wed","thu","fri","sat"];const xn=e=>{const[t,n]=e.split(":").map(e=>parseInt(e,10));return 60*t+n};function Nn(e,t=new Date){const n=function(e,t){try{const n=new Intl.DateTimeFormat("en-US",{timeZone:t,weekday:"short",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(e),o=e=>{var t;return(null===(t=n.find(t=>t.type===e))||void 0===t?void 0:t.value)||""},r=o("weekday").slice(0,3).toLowerCase(),i=60*parseInt(o("hour"),10)+parseInt(o("minute"),10);return Sn.includes(r)&&!isNaN(i)?{day:r,minutes:i}:null}catch{return null}}(t,e.timezone);if(!n)return{open:e.open,nextChange:e.nextChangeAt?new Date(e.nextChangeAt):null};const o=e.schedule[n.day]||[];for(const e of o){const o=xn(e.start),r=xn(e.end);if(o<=n.minutes&&n.minutes<r)return{open:!0,nextChange:new Date(t.getTime()+6e4*(r-n.minutes))}}const r=Sn.indexOf(n.day);for(let o=0;o<15;o++){const i=Sn[(r+o)%7];for(const r of e.schedule[i]||[]){const e=xn(r.start);if(0===o&&e<=n.minutes)continue;const i=1440*o+e-n.minutes;return{open:!1,nextChange:new Date(t.getTime()+6e4*i)}}}return{open:!1,nextChange:null}}function Mn(e,t){const n=e.getTime()-Date.now()<72e6;try{return new Intl.DateTimeFormat(t,n?{hour:"numeric",minute:"2-digit"}:{weekday:"short",hour:"numeric",minute:"2-digit"}).format(e)}catch{return e.toLocaleString()}}function In(e){try{const t=window.localStorage.getItem(e),n=t?JSON.parse(t):[];return Array.isArray(n)?n.map(e=>Array.isArray(e.messages)&&e.messages.some(e=>e&&"sending"===e.status)?{...e,messages:e.messages.map(e=>"sending"===e.status?{...e,status:"failed"}:e)}:e):[]}catch{return[]}}function $n(e,t){try{return void window.localStorage.setItem(e,JSON.stringify(t))}catch{}try{const n=t.filter(e=>e.messages.some(e=>"user"===e.role)).slice(0,30).map(e=>e.messages.length>200?{...e,messages:e.messages.slice(-200)}:e);window.localStorage.setItem(e,JSON.stringify(n))}catch{}}const Tn=5,An=10485760,Hn=e=>!!e&&/^image\/(png|jpe?g|gif|webp)$/i.test(e);function Pn(e,t){if(!(e>0))return"";const n=["B","KB","MB"];let o=e,r=0;for(;o>=1024&&r<n.length-1;)o/=1024,r++;const i=0===r?0:o<10?1:0;let a;try{a=o.toLocaleString(t,{maximumFractionDigits:i,minimumFractionDigits:0})}catch{a=o.toFixed(i)}return`${a} ${n[r]}`}function En(e){return e&&"string"==typeof e.url&&/^https?:\/\//i.test(e.url)?{url:e.url,name:"string"==typeof e.filename&&e.filename?e.filename:"string"==typeof e.name&&e.name?e.name:"file",type:"string"==typeof e.content_type?e.content_type:"string"==typeof e.type?e.type:"application/octet-stream",size:"number"==typeof e.size?e.size:0}:null}const Un=["active","escalated","resolved"];function Dn(e){return Un.includes(e)?e:"active"}function Ln(){return`m_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`}function Rn(e){if("string"!=typeof e||!e)return;const t=/(?:[zZ]|[+-]\d\d:?\d\d)$/.test(e)||!/^\d{4}-\d\d-\d\dT/.test(e),n=new Date(t?e:e+"Z");return isNaN(n.getTime())?void 0:n}function On(e){if(!e||!e.message_id)return null;if("user"!==e.role&&"agent"!==e.role&&"human"!==e.role)return null;if("string"!=typeof e.content&&null!==e.content&&void 0!==e.content)return null;const t={role:"user"===e.role?"user":"agent",content:e.content||"",timestamp:Rn(e.timestamp)||new Date,messageId:e.message_id,format:"markdown"===e.format?"markdown":"text"},n=(Array.isArray(e.attachments)?e.attachments:[]).map(En).filter(Boolean);return n.length&&(t.attachments=n),!e.feedback||"up"!==e.feedback.rating&&"down"!==e.feedback.rating||(t.feedback={rating:e.feedback.rating,...e.feedback.comment?{comment:e.feedback.comment}:{}}),t.content||t.attachments?t:null}function Fn(e,t){var n;const o=new Map(e.map(e=>[e.id,e])),r=[],i=new Set;for(const e of t){if(!e||"string"!=typeof e.thread_key||i.has(e.thread_key))continue;i.add(e.thread_key);const t=Dn(e.conversation_status),a=Rn(e.updated_at),s=a?a.toISOString():void 0,l=o.get(e.thread_key);if(l){const e=Date.parse(l.lastUpdated)||0,o=!!a&&a.getTime()-e>2e3;r.push({...l,status:t,hydrated:!o&&(null===(n=l.hydrated)||void 0===n||n),lastUpdated:o?s:l.lastUpdated});continue}const _=e.last_message?On(e.last_message):null;r.push({id:e.thread_key,messages:_?[_]:[],lastUpdated:s||(new Date).toISOString(),status:t,hydrated:!1})}for(const t of e)i.has(t.id)||r.push(t);return r.sort((e,t)=>e.lastUpdated<t.lastUpdated?1:e.lastUpdated>t.lastUpdated?-1:0)}function jn(e,t){const n=new Set(t.map(e=>e.messageId)),o=e.findIndex(e=>"user"===e.role),r=(-1===o?e:e.slice(0,o)).filter(e=>"agent"===e.role&&!e.messageId),i=e=>e.timestamp&&new Date(e.timestamp).getTime()||0,a=t.reduce((e,t)=>Math.max(e,i(t)),0),s=e=>e.content||(e.attachments||[]).map(e=>e.url).join("\n"),l=new Set(t.filter(e=>"user"===e.role).map(s).filter(Boolean)),_=e.filter(e=>e.messageId&&!n.has(e.messageId)&&i(e)>a||"user"===e.role&&("sending"===e.status||"failed"===e.status)&&!e.messageId&&!l.has(s(e)));return[...r,...t,..._]}class Vn{constructor(e){this.options=e,this.token=null,this.supported=!0,this.userId=null,this.human=!1,this.pending=null,this.lastFailure=null}apply(e){e&&"string"==typeof e.session_token&&(this.token=e.session_token,this.userId=e.session_verified&&"string"==typeof e.session_user_id?e.session_user_id:null,this.human=!!e.session_human,this.options.onChange())}clear(){this.token=null,this.pending=null,this.userId=null,this.human=!1,this.options.onChange()}start(e){const t=this.options.getOrganizationId();if(!this.supported||!t)return Promise.resolve(null);if(this.pending)return this.pending;const n=this.options.getVisitorId();let o=null;return o=(async()=>{try{const o=await fetch(this.options.api("/session"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e?{organization_id:t,token:e}:{organization_id:t,visitor_id:n})});if(404===o.status||405===o.status)return this.supported=!1,null;if(!o.ok)return this.lastFailure=401===o.status?"rejected":"transient",null;this.lastFailure=null;const r=await o.json();return n!==this.options.getVisitorId()?null:(this.token&&this.token!==e||this.apply(r),this.token)}catch{return this.lastFailure="transient",null}finally{this.pending===o&&(this.pending=null)}})(),this.pending=o,o}async request(e,t={}){var n;const o=n=>fetch("function"==typeof e?e(!!n):e,{...t,headers:{...t.headers,...n?{Authorization:`Bearer ${n}`}:{}}}),r=null!==(n=this.token)&&void 0!==n?n:await this.start(),i=await o(r);if(401!==i.status||!r)return{res:i,token:r};let a=await this.start(r);if(!a||a===r){const e=this.token;if(e&&e!==r)a=e;else{if("rejected"!==this.lastFailure)return{res:i,token:r};this.clear(),a=await this.start()}}return{res:await o(a),token:a}}async fetch(e,t={}){return(await this.request(e,t)).res}}let zn;function Wn(){if(void 0===zn){const e="undefined"!=typeof window?window.trustedTypes:void 0;if(zn=null,e&&e.createPolicy)try{zn=e.createPolicy("askly",{createHTML:e=>e,createScriptURL:e=>e})}catch{zn=null}}return zn}function qn(e){const t=Wn();return t?t.createHTML(e):e}function Bn(e){const t=Wn();return t?t.createScriptURL(e):e}function Zn(e){return!1===e||"off"===e?"off":!0===e||"review"===e?"review":"auto-send"===e?"auto-send":void 0}function Yn(e){switch(e){case"insecure":return en("voice_error_insecure");case"unsupported":return en("voice_error_unsupported");case"denied":return en("voice_error_denied");case"no-microphone":return en("voice_error_no_microphone");case"no-speech":return en("voice_error_no_speech");case"no-audio":return en("voice_error_no_audio");case"limit":return en("voice_error_limit");case"disabled":return en("voice_error_disabled");case"network":return en("voice_error_network");default:return en("voice_error_failed")}}const Jn=3e3,Gn=3;function Qn(e,t,n){const o=en("greeting_default");let r="string"==typeof e&&e.trim()?e:t?en("greeting_default_persona"):o;return t||-1===r.indexOf("{ai_name}")||(r=o),r.replace(/\{ai_name\}/g,()=>t||"").replace(/\{organizationName\}/g,()=>n).trim()}function Kn(e){try{return"1"===window.sessionStorage.getItem(`askly_greeting_dismissed_${e}`)}catch{return!1}}function Xn(e){try{window.sessionStorage.setItem(`askly_greeting_dismissed_${e}`,"1")}catch{}}function eo(e){un("shown"===e?"greeting:shown":"clicked"===e?"greeting:clicked":"greeting:dismissed");try{window.dispatchEvent(new Event(`askly:greeting:${e}`))}catch{}}const to={headings:!1,blockquotes:!1,images:!1},no={headings:!0,blockquotes:!0,images:!0};function oo(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ro(e){const t=e.trim();return/^(https?:\/\/|mailto:|tel:)/i.test(t)&&!/[\s\0-]/.test(t)}function io(e,t){return`<a href="${oo(e.trim())}" target="_blank" rel="noopener noreferrer" class="message-inline-link">${t}</a>`}class ao{constructor(){this.items=[]}put(e){return this.items.push(e),`${this.items.length-1}`}restore(e){return e.replace(/(\d+)/g,(e,t)=>this.items[Number(t)])}}const so=/`([^`\n]+)`/g,lo=/!\[([^\]\n]*)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/g,_o=/\[([^\]\n]+)\]\(((?:[^()\s]|\([^()\s]*\))+)\)/g,uo=/(^|[^\w"'=/\]\(])(https?:\/\/[^\s<>()]*[^\s<>().,;:!?'"])/g,co=/\*\*(?=\S)([\s\S]*?\S)\*\*/g,po=/(^|[^\w*])\*(?=\S)([^*\n]*?\S)\*(?![\w*])/g,fo=/(^|[^\w_])_(?=\S)([^_\n]*?\S)_(?![\w_])/g;function ho(e,t){const n=new ao;let o=e;return t.emphasis&&(o=o.replace(so,(e,t)=>n.put(`<code class="inline-code">${oo(t)}</code>`))),t.images?o=o.replace(lo,(e,t,o)=>function(e){const t=e.trim();return/^https:\/\//i.test(t)&&!/[\s\0-]/.test(t)}(o)?n.put(`<img src="${oo(o.trim())}" alt="${oo(t)}" class="message-inline-image" />`):n.put(oo(t))):t.links&&(o=o.replace(lo,(e,t,o)=>n.put(ro(o)?io(o,oo(t||o)):oo(t||o)))),t.links&&(o=o.replace(_o,(e,t,o)=>n.put(ro(o)?io(o,oo(t)):oo(t)))),o=o.replace(uo,(e,t,o)=>t+n.put(io(o,oo(o)))),o=oo(o),t.emphasis&&(o=o.replace(co,"<strong>$1</strong>"),o=o.replace(po,"$1<em>$2</em>"),o=o.replace(fo,"$1<em>$2</em>")),o=o.replace(/\n/g,"<br />"),n.restore(o)}const mo=/^\s{0,3}```\s*([\w+-]*)\s*$/,go=/^\s{0,3}```\s*$/,vo=/^\s{0,3}(#{1,3})\s+(.+?)\s*#*\s*$/,yo=/^\s{0,3}>\s?(.*)$/,wo=/^\s*([-*+]|\d{1,3}[.)])\s+(.*)$/,bo=/^\s{2,}\S/;function ko(e,t){const n={emphasis:!0,links:!0,images:t.images},o=e.replace(/\r\n?/g,"\n").split("\n"),r=[];let i=0;const a=e=>mo.test(e)||wo.test(e)||t.headings&&vo.test(e)||t.blockquotes&&yo.test(e);for(;i<o.length;){const e=o[i];if(""===e.trim()){i++;continue}const s=e.match(mo);if(s){const e=s[1],t=[];for(i++;i<o.length&&!go.test(o[i]);)t.push(o[i]),i++;for(i++;t.length&&""===t[t.length-1].trim();)t.pop();const n=e?` class="language-${e}"`:"";r.push(`<pre><code${n}>${oo(t.join("\n"))}</code></pre>`);continue}if(t.headings){const t=e.match(vo);if(t){const e=t[1].length;r.push(`<h${e}>${ho(t[2],n)}</h${e}>`),i++;continue}}if(t.blockquotes&&yo.test(e)){const e=[];for(;i<o.length;){const t=o[i].match(yo);if(!t)break;e.push(t[1]),i++}r.push(`<blockquote><p>${ho(e.join("\n"),n)}</p></blockquote>`);continue}const l=e.match(wo);if(l){const e=/\d/.test(l[1]),t=e?parseInt(l[1],10):1,a=[];for(;i<o.length;){const e=o[i].match(wo);if(e)a.push(e[2]),i++;else{if(!a.length||!bo.test(o[i]))break;a[a.length-1]+=" "+o[i].trim(),i++}}const s=e?"ol":"ul",_=e&&1!==t?` start="${t}"`:"";r.push(`<${s}${_}>${a.map(e=>`<li>${ho(e,n)}</li>`).join("")}</${s}>`);continue}const _=[e];for(i++;i<o.length&&""!==o[i].trim()&&!a(o[i]);)_.push(o[i]),i++;r.push(`<p>${ho(_.join("\n"),n)}</p>`)}return r.join("")}function Co(e){return e?ko(e,to):""}function So(e){return e?ko(e,no):""}function xo(e){return e?ho(e,{emphasis:!1,links:!1,images:!1}):""}function No(e){return e?e.replace(/```[\s\S]*?```/g," [Code] ").replace(/!\[[^\]]*\]\([^)]*\)/g,"[Image]").replace(/\[[^\]]*\]\([^)]*\)/g,"[Link]").replace(/`([^`]*)`/g,"$1").replace(/\*\*([^*]*)\*\*/g,"$1").replace(/(^|[^\w*])\*([^*\n]+)\*(?![\w*])/g,"$1$2").replace(/(^|[^\w_])_([^_\n]+)_(?![\w_])/g,"$1$2").replace(/^\s{0,3}#{1,6}\s+/gm,"").replace(/^\s*(?:[-*+]|\d{1,3}[.)])\s+/gm,"").replace(/^\s{0,3}>\s?/gm,"").replace(/\s+/g," ").trim():""}export{Fn as $,pe as A,xt as B,Ct as C,$t as D,Co as E,xo as F,Gn as G,Zt as H,Kt as I,Jt as J,Gt as K,Ut as L,Tn as M,In as N,Nn as O,bt as P,bn as Q,wn as R,kt as S,Et as T,$n as U,Qn as V,Vn as W,ht as X,Kn as Y,eo as Z,Xn as _,rn as a,On as a0,Dn as a1,jn as a2,un as a3,Bn as a4,ce as a5,Qt as a6,Zn as a7,mn as a8,vn as a9,yn as aa,Cn as ab,Ln as ac,Mn as ad,Yn as ae,An as af,Jn as ag,hn as ah,_n as ai,ln as aj,sn as ak,dt as al,gn as am,fn as an,on as ao,So as ap,At as aq,tn as b,Nt as c,Pt as d,Dt as e,nn as f,pt as g,Yt as h,vt as i,gt as j,ze as k,mt as l,wt as m,yt as n,St as o,le as p,ue as q,qn as r,No as s,en as t,Hn as u,Pn as v,Mt as w,It as x,Tt as y,qe as z};