@nexlylab/widget 1.32.18 → 1.34.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/INSTALL.txt +1 -1
- package/dist/runtime/{1.32.18/chunks/ClickToLoadEmbed-BLIUFZOn-BwY-LAJ8.js → 1.34.0/chunks/ClickToLoadEmbed-BNWVfZ1y-DuTZcv6f.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/PanelInfoVideo-BNVzih9J-BrU-Qlul.js → 1.34.0/chunks/PanelInfoVideo-Di7qwhV_-qpxDXdLm.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/allowed-elements-BXnLJV1S-C-_lr2zm.js → 1.34.0/chunks/allowed-elements-C0OfX2zF-DIBV8lKu.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/assistant-link-components-DUrLEPUB-DKaQavIJ.js → 1.34.0/chunks/assistant-link-components-DtT0biCl-jR32KHTm.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/assistant-link-policy-DHB-k1Aa-Cc-yj-a-.js → 1.34.0/chunks/assistant-link-policy-B77YPf4E-By6jpR50.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/block-rating-D7hR2gTc-CoiP5C2K.js → 1.34.0/chunks/block-rating-uD_0LK-1-CQMNokIy.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/external-url-qbs1SznX-CJQjg_od.js → 1.34.0/chunks/external-url-Bx_GTDOx-rLiy7c9v.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-BtkNePSj-CiRb-0NX.js → 1.34.0/chunks/index--7VB9nyF-BoVmvEOm.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-OcrS6o5Y-bdo5pwX-.js → 1.34.0/chunks/index-66kR66X--CzwqZYRk.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-kAGaGinD-Dm9kbc85.js → 1.34.0/chunks/index-67cmm3Si-Bhh8_8Oh.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-DiZcd1hz-H31PHMqm.js → 1.34.0/chunks/index-7wlPUbYV-Deg8QEW2.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-B3DeMFo7-BbdAbuAw.js → 1.34.0/chunks/index-B80p2HRD-BHvEiO2X.js} +3 -3
- package/dist/runtime/{1.32.18/chunks/index-DuPFNKhZ-_M0CWPEY.js → 1.34.0/chunks/index-BHphkqVW-CEIHlemy.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-7N5M1HdS-DAdxCQyi.js → 1.34.0/chunks/index-BIeasoH0-BlFXtfQb.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-99heIIoH-QeFj7CR9.js → 1.34.0/chunks/index-BPwttNii-f3F4IxQ5.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-l8Oxwea3-Aqz1AnQ5.js → 1.34.0/chunks/index-BTgHOj2W-D6H0juMn.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-PxSB6BA6-DFxY6dqO.js → 1.34.0/chunks/index-BfGmnBJ0-BOltxOU-.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-CYeJYTiB-BLxOZxZv.js → 1.34.0/chunks/index-BjNWgAJk-B-pT4hKt.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-CZ-JrY2X-TEMHje2B.js → 1.34.0/chunks/index-BlY9hgA--pCzSL4DD.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-C1Fa-E3e-ZRnEJoQe.js → 1.34.0/chunks/index-BmajLlTC-qsVnaLmo.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-DaW9uf4--pkywvGDF.js → 1.34.0/chunks/index-BtBJMXR--DWm0RYZF.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-CF37rhgu-BcW8HKb8.js → 1.34.0/chunks/index-Bz-3E3Sa-B9PuY2Gx.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-qN6oEHVu-C_0Ll4qr.js → 1.34.0/chunks/index-CM2ok1Hp-k8zxZkfU.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-COfQIa8G-D6wzHiS0.js → 1.34.0/chunks/index-CMdx7oFx-bh6F7tw3.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-D1YmJ3gf-3B-eE3K7.js → 1.34.0/chunks/index-COobDdoM-BZw4n83V.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-DAICBUgn-DBhSkJ7i.js → 1.34.0/chunks/index-CQCPJl3S-CV5ZiVsD.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-BKZyJMr2-oy07dUaV.js → 1.34.0/chunks/index-CSsAPgvv-qK4w7DnX.js} +4 -4
- package/dist/runtime/{1.32.18/chunks/index-oxM4Cgtc-R_xuAEQV.js → 1.34.0/chunks/index-CXm6d9l1-BmIQ-NmU.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-D96sEJQ6-Dp5AxBD4.js → 1.34.0/chunks/index-CZcU6ylZ-Bt7j8evJ.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-BKrM_uoq-CABL-0v-.js → 1.34.0/chunks/index-Ce73FsEJ-Ce0fEutJ.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-C5RVj6y1-DUgMllqN.js → 1.34.0/chunks/index-Cf3qMIwZ-PMvqlUvO.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-CSRoJRaW-CoI3p0S7.js → 1.34.0/chunks/index-CqSCG8MM-Yl3jEGAx.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-COTfVuju-DQBGsPwB.js → 1.34.0/chunks/index-CzfX3ctc-qH_mrcVT.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-BZO9Qaiw-DP0QKkgf.js → 1.34.0/chunks/index-DBhWCUM5-DpMzyqHN.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-CCEWGjHV-BTsOZg4v.js → 1.34.0/chunks/index-DT9H1y9L-DladDuuj.js} +4 -4
- package/dist/runtime/{1.32.18/chunks/index-E59S8-Gw-CovGUxIZ.js → 1.34.0/chunks/index-DbY1AG4s-C-OyGFef.js} +4 -4
- package/dist/runtime/{1.32.18/chunks/index-Bf_npmqm-C1BzRUwZ.js → 1.34.0/chunks/index-Ddxqdy4M-CDVtcfdt.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-Dw7QeZq3-Dr1V6OGz.js → 1.34.0/chunks/index-DmV2pHdJ-Dtq7n928.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-Cd1-jHFp-Za3SKEQp.js → 1.34.0/chunks/index-DnWzIgAa-DlTfKZaL.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-BX6ig9BJ-Dsa9X9U7.js → 1.34.0/chunks/index-Dnqtxtmw-CgO1smBF.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-Ce9TuEzb-C3bBvEcm.js → 1.34.0/chunks/index-Dw35VwDs-DX50C5MZ.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index--xfG4CIn-DbuSZfeK.js → 1.34.0/chunks/index-Dydy8_XR-F9_TzvkO.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-cCAzBYyN-W1lJrIDD.js → 1.34.0/chunks/index-FHHrEvNZ-VW9D8cgC.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-BauMKr5c-BpgnWlB8.js → 1.34.0/chunks/index-RyI_7m1j-CavFmRiD.js} +2 -2
- package/dist/runtime/1.34.0/chunks/index-TJEJpVI7-CqZ9_vG_.js +2 -0
- package/dist/runtime/1.34.0/chunks/index-Va_2P_Gg-Kzu4aFqn.js +6 -0
- package/dist/runtime/{1.32.18/chunks/index-BIGVEl9--CSQQTbsg.js → 1.34.0/chunks/index-_wovirve-BzpgdoE8.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-CV2tGt-4-C9wFr7fa.js → 1.34.0/chunks/index-kmVVSAKR-BlRhWcs1.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index-DATkkw3P-VhJcCfAC.js → 1.34.0/chunks/index-xV27oZEe-ErDxRmJu.js} +2 -2
- package/dist/runtime/{1.32.18/chunks/index.modern-CioVZ357-BA5NTOmY.js → 1.34.0/chunks/index.modern-CioVZ357-nfRNslCS.js} +2 -2
- package/dist/runtime/1.34.0/nexly.js +61 -0
- package/dist/v1.js +4 -4
- package/package.json +1 -1
- package/dist/runtime/1.32.18/chunks/index-rblri-2U-I68tb-d3.js +0 -2
- package/dist/runtime/1.32.18/chunks/index-xx1GG5d1-CW29F9vY.js +0 -6
- package/dist/runtime/1.32.18/nexly.js +0 -61
- /package/dist/runtime/{1.32.18 → 1.34.0}/chunks/PanelVideoOverlay-BY__oBYV-B8OPC1xh.js +0 -0
- /package/dist/runtime/{1.32.18 → 1.34.0}/chunks/_commonjsHelpers-C6fGbg64-BC8KDfbh.js +0 -0
- /package/dist/runtime/{1.32.18 → 1.34.0}/chunks/accent-legibility-BJF2VO5n-CDPQ7suO.js +0 -0
- /package/dist/runtime/{1.32.18 → 1.34.0}/chunks/block-helpers-Cg_zAqG6-DnN2COvk.js +0 -0
- /package/dist/runtime/{1.32.18 → 1.34.0}/chunks/index-BPDIV1BN-DINkyYvc.js +0 -0
- /package/dist/runtime/{1.32.18 → 1.34.0}/chunks/index-BcsmWDTX-Dw9WA5Ac.js +0 -0
- /package/dist/runtime/{1.32.18 → 1.34.0}/chunks/index-C262wwK4-DpyhuXqd.js +0 -0
- /package/dist/runtime/{1.32.18 → 1.34.0}/chunks/index-DMQkz1bV-BuMYksln.js +0 -0
- /package/dist/runtime/{1.32.18 → 1.34.0}/chunks/index-DZADUAKv-DPfvWVuj.js +0 -0
- /package/dist/runtime/{1.32.18 → 1.34.0}/chunks/inert-assistant-components-B6Cx9pG5-DWb6n3Yq.js +0 -0
- /package/dist/runtime/{1.32.18 → 1.34.0}/chunks/use-deferred-rating-XlgCUwcY-DDVOwURi.js +0 -0
package/dist/v1.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(){"use strict";(function(){var
|
|
2
|
-
Skopiuj gotowy snippet z panelu (Produkt → Instalacja) — klucz jest w nim już wpisany.`);return}const o={apiKey:u,server:n("server")||"https://e-commerce-studio.nexlylab.dev",theme:n("theme")||"system",position:n("position")||"bottom-right",version:n("version")||"1.
|
|
1
|
+
(function(){"use strict";(function(){var f;const c=document.currentScript;if(!c||window.Nexly)return;const n=e=>c.getAttribute(`data-${e}`),x=()=>{try{return new URL(c.src,location.href).href.replace(/\/[^/]*$/,"")}catch{return""}},u=n("api-key");if(!u){console.error(`[Nexly] Brak data-api-key na tagu skryptu.
|
|
2
|
+
Skopiuj gotowy snippet z panelu (Produkt → Instalacja) — klucz jest w nim już wpisany.`);return}const o={apiKey:u,server:n("server")||"https://e-commerce-studio.nexlylab.dev",theme:n("theme")||"system",position:n("position")||"bottom-right",version:n("version")||"1.34.0",cdn:n("cdn")||x()||"https://cdn.jsdelivr.net/npm/@nexlylab/widget@1.34.0/dist",preload:n("preload")||"hover",debug:n("debug")!==null||/[?&]nexly-debug=1/.test(location.search)},p=n("signed-token");p&&(o.signedToken=p);const y=n("user-context");if(y)try{o.userContext=JSON.parse(y)}catch{console.error("[Nexly] data-user-context nie jest poprawnym JSON-em — pomijam.")}const l=(...e)=>{o.debug&&console.info("[Nexly]",...e)},m=[];let i=null;const g=function(e){if(i)return i(e);m.push(e)};window.Nexly=g;for(const e of[o.cdn,o.server])try{const t=document.createElement("link");t.rel="preconnect",t.href=new URL(e,location.href).origin,t.crossOrigin="",document.head.appendChild(t)}catch{}document.addEventListener("securitypolicyviolation",e=>{const t=e.blockedURI||"";/nexlylab|elevenlabs|livekit|maps\.googleapis/.test(t)&&console.error(`[Nexly] CSP tej strony zablokowało ${t}
|
|
3
3
|
Naruszona dyrektywa: ${e.violatedDirective}
|
|
4
|
-
Gotowy blok CSP do wklejenia: ${o.server}/install/csp?key=${o.apiKey.slice(0,11)}`)});function b(e){const t=document.createElement("button");return t.type="button",t.id="nexly-launcher",t.setAttribute("aria-label","Otwórz czat"),t.style.cssText=["position:fixed","bottom:20px",o.position==="bottom-left"?"left:20px":"right:20px","width:80px","height:80px","border-radius:50%","border:none","cursor:pointer","display:flex","align-items:center","justify-content:center","background:#1c1c1e","color:#f4c95d","box-shadow:0 4px 16px rgba(0,0,0,.28)","z-index:2147483000","padding:0","transition:transform .2s ease"].join(";"),t.innerHTML='<svg width="34" height="34" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M21 11.5a8.4 8.4 0 0 1-9 8.4 9 9 0 0 1-3.5-.7L3 21l1.9-5a8.2 8.2 0 0 1-.9-3.7 8.4 8.4 0 0 1 8.5-8.3 8.4 8.4 0 0 1 8.5 8z" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>',t.addEventListener("click",e),document.body.appendChild(t),t}let s=null,a=!1;function d(e){if(i)return e==null?void 0:e();if(a)return;a=!0;const t=`${o.cdn.replace(/\/$/,"")}/runtime/${o.version}/nexly.js`,
|
|
5
|
-
Sprawdź, czy CSP tej strony zezwala na script-src z tego adresu.`)},document.head.appendChild(r),
|
|
4
|
+
Gotowy blok CSP do wklejenia: ${o.server}/install/csp?key=${o.apiKey.slice(0,11)}`)});function b(e){const t=document.createElement("button");return t.type="button",t.id="nexly-launcher",t.setAttribute("aria-label","Otwórz czat"),t.style.cssText=["position:fixed","bottom:20px",o.position==="bottom-left"?"left:20px":"right:20px","width:80px","height:80px","border-radius:50%","border:none","cursor:pointer","display:flex","align-items:center","justify-content:center","background:#1c1c1e","color:#f4c95d","box-shadow:0 4px 16px rgba(0,0,0,.28)","z-index:2147483000","padding:0","transition:transform .2s ease"].join(";"),t.innerHTML='<svg width="34" height="34" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M21 11.5a8.4 8.4 0 0 1-9 8.4 9 9 0 0 1-3.5-.7L3 21l1.9-5a8.2 8.2 0 0 1-.9-3.7 8.4 8.4 0 0 1 8.5-8.3 8.4 8.4 0 0 1 8.5 8z" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>',t.addEventListener("click",e),document.body.appendChild(t),t}let s=null,a=!1;function d(e){if(i)return e==null?void 0:e();if(a)return;a=!0;const t=`${o.cdn.replace(/\/$/,"")}/runtime/${o.version}/nexly.js`,v=performance.now(),r=document.createElement("script");r.src=t,r.type="module",r.async=!0,r.crossOrigin="anonymous",r.onload=()=>{const w=window.__nexlyRuntime;if(!w){console.error(`[Nexly] Runtime wczytany z ${t}, ale nie zarejestrował się poprawnie.`),a=!1;return}i=w({...o,initialOpen:!0}),l(`runtime gotowy w ${Math.round(performance.now()-v)} ms`),s==null||s.remove();for(const h of m.splice(0))i(h);e==null||e()},r.onerror=()=>{a=!1,console.error(`[Nexly] Nie udało się wczytać runtime z ${t}
|
|
5
|
+
Sprawdź, czy CSP tej strony zezwala na script-src z tego adresu.`)},document.head.appendChild(r),l("pobieram runtime",t)}s=b(()=>d(()=>{var e;return(e=window.Nexly)==null?void 0:e.call(window,"open")})),o.preload==="hover"?s.addEventListener("pointerenter",()=>d(),{once:!0}):o.preload==="idle"&&((f=window.requestIdleCallback)!=null?f:(t=>window.setTimeout(t,2e3)))(()=>d()),l("loader gotowy",{version:o.version,server:o.server,preload:o.preload})})()})();
|
|
6
6
|
//# sourceMappingURL=v1.js.map
|
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{j as e,Q as l}from"../nexly.js";const m={slug:"demo-services",name:"DEMO — Services",version:"0.1.0",category:"content",configSchema:{properties:{items:{type:"array",items:{type:"object",properties:{title:{type:"string"},description:{type:"string"}},required:["title"]},default:[]}}},defaultConfig:{items:[]},sizing:{minWidth:240,preferredHeight:"auto",scrollable:!1},supportedPlacements:["main","sidebar"]};function d(r){return Array.isArray(r)?r.flatMap(t=>{if(typeof t!="object"||t===null)return[];const s=t,c=typeof s.title=="string"?s.title.trim():"";if(!c)return[];const o=typeof s.description=="string"&&s.description.trim().length>0?s.description.trim():void 0;return[{title:c,description:o}]}):[]}function p({data:r,config:t,i18n:s}){const c=s?.t??(i=>i),o=d(r?.items??t?.items);return o.length===0?e.jsx(l,{blockType:"demo-services",children:e.jsx("div",{className:"es-block__body",children:e.jsx("div",{className:"es-block__empty",children:c("demoServices.empty")})})}):e.jsx(l,{blockType:"demo-services",children:e.jsx("div",{className:"es-block__body es-demosvc",children:e.jsx("ul",{className:"es-demosvc__list",children:o.map((i,n)=>e.jsxs("li",{className:"es-demosvc__item",children:[e.jsx("span",{className:"es-demosvc__ordinal","aria-hidden":"true",children:n+1}),e.jsxs("div",{className:"es-demosvc__text",children:[e.jsx("h3",{className:"es-demosvc__title",children:i.title}),i.description&&e.jsx("p",{className:"es-demosvc__desc",children:i.description})]})]},n))})})})}export{p as Component,m as manifest};
|
|
2
|
-
//# sourceMappingURL=index-rblri-2U-I68tb-d3.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{r as s,j as t,a as kt,b as Te,Q as ts,_ as Ws,t as Js}from"../nexly.js";import{H as Xs,P as Vs}from"./use-deferred-rating-XlgCUwcY-DDVOwURi.js";import{j as Zs}from"./PanelInfoVideo-BNVzih9J-BrU-Qlul.js";import{x as Ys,s as Gs,c as en,a as tn}from"./allowed-elements-BXnLJV1S-C-_lr2zm.js";import{f as sn}from"./assistant-link-components-DUrLEPUB-DKaQavIJ.js";import{j as nn,X as an}from"./ClickToLoadEmbed-BLIUFZOn-BwY-LAJ8.js";import"./_commonjsHelpers-C6fGbg64-BC8KDfbh.js";import"./assistant-link-policy-DHB-k1Aa-Cc-yj-a-.js";const ca={slug:"support-chat",name:"Support Chat",version:"1.0.0",category:"interactive",requiredService:"support-chat",configSchema:{properties:{voiceEnabled:{type:"boolean",default:!0},voiceConversationEnabled:{type:"boolean",default:!1},voiceReadAloudEnabled:{type:"boolean",default:!1},welcomeMessage:{type:"string",default:""},headerTitle:{type:"string",default:""},placeholder:{type:"string",default:""},showSuggestedQuestions:{type:"boolean",default:!0},suggestedQuestions:{type:"array",items:{type:"string"},default:[]},escalationLabel:{type:"string",default:""},humanHandoffButton:{type:"boolean",default:!1}}},defaultConfig:{voiceEnabled:!0,voiceConversationEnabled:!1,voiceReadAloudEnabled:!1,welcomeMessage:"",headerTitle:"",placeholder:"",showSuggestedQuestions:!0,suggestedQuestions:[],escalationLabel:"",humanHandoffButton:!1},dataContract:{serviceSlug:"support-chat",inputSchema:{type:"object",properties:{answer:{type:"string",description:"AI response text"},confidence:{type:"number",description:"Confidence score 0-1"},sources:{type:"array",items:{type:"object",properties:{title:{type:"string"},url:{type:"string"},excerpt:{type:"string"}}},description:"Source citations for the answer"}},required:["answer"]},previewDataOverride:{answer:"Our return policy allows returns within 30 days of purchase. Items must be in original condition with tags attached.",confidence:.85,sources:[{title:"Return Policy",url:"/policies/returns",excerpt:"Returns accepted within 30 days."}]}},fields:[{id:"voiceConversationEnabled",type:"toggle",label:"Voice conversation (live)",default:!1,group:"Voice"},{id:"voiceReadAloudEnabled",type:"toggle",label:"Read messages aloud",default:!1,group:"Voice"},{id:"headerTitle",type:"localized-text",label:"Header title",default:"",placeholder:'Leave empty to use translated default (e.g. "Support")',group:"Content"},{id:"welcomeMessage",type:"localized-text",label:"Welcome message",default:"",placeholder:'Leave empty to use translated default (e.g. "Hi! How can I help you today?")',group:"Content"},{id:"placeholder",type:"localized-text",label:"Input placeholder",default:"",placeholder:'Leave empty to use translated default (e.g. "Ask a question...")',group:"Content"},{id:"escalationLabel",type:"text",label:"Escalation button label",default:"",placeholder:'Leave empty to use translated default (e.g. "Contact Support")',group:"Content"},{id:"humanHandoffButton",type:"toggle",label:'Show "Human" button',default:!1,group:"Behavior"},{id:"showSuggestedQuestions",type:"toggle",label:"Show suggested questions",default:!0,group:"Behavior"},{id:"suggestedQuestions",type:"json",label:"Suggested questions",default:[],placeholder:'["What is your return policy?", "Do you ship internationally?"]',group:"Behavior"}],events:{emits:[{name:"support-chat:messageSent",description:"User sent a message"},{name:"support-chat:escalated",description:"User requested escalation to human support"},{name:"support-chat:feedbackSubmitted",description:"User rated helpfulness of answer"}],listens:[{name:"support-chat:clearHistory",description:"Clear chat history"}]},sizing:{minWidth:280,preferredHeight:"fill",scrollable:!0},supportedPlacements:["main","sidebar","fullscreen"]};function ss({text:n,allowedLinkHosts:a}){return t.jsx("div",{className:"es-sc__bubble-text es-sc__bubble-text--md",children:t.jsx(Ys,{remarkPlugins:[...en],allowedElements:[...Gs],transformLinkUri:o=>tn(o)??"",transformImageUri:()=>"",components:{input:({node:o,type:i,checked:l,...p})=>i==="checkbox"?t.jsx("input",{...p,type:"checkbox",checked:!!l,disabled:!0,readOnly:!0,className:"es-sc__md-task"}):null,...sn({allowedHosts:a})},children:n})})}function rn({media:n,t:a}){const{embeds:o,images:i}=n;return o.length===0&&i.length===0?null:t.jsxs("div",{className:"es-sc__media","data-testid":"support-chat-media",children:[o.map(l=>t.jsx(an,{embed:l,t:a,classPrefix:"es-sc"},`${l.provider}:${l.id}`)),i.map(l=>t.jsx("img",{className:"es-sc__media-img",src:l.src,alt:l.alt||a("support_chat.media_image_alt"),loading:"lazy",decoding:"async",referrerPolicy:"no-referrer"},l.src))]})}function wt(n){return n?n.join(","):""}const on=s.memo(function({text:n,allowEmbeds:a,allowedImageHosts:o,t:i}){const l=wt(o),p=s.useMemo(()=>nn(n,{allowEmbeds:a,allowedImageHosts:o}),[n,a,l]);return t.jsx(rn,{media:p,t:i})},(n,a)=>n.text===a.text&&n.allowEmbeds===a.allowEmbeds&&n.t===a.t&&wt(n.allowedImageHosts)===wt(a.allowedImageHosts));function cn(n,a){const o=Math.round((Date.now()-n.getTime())/1e3);if(o<60)return a("time.just_now");const i=Math.round(o/60);if(i<60)return a("time.minutes_ago",{count:i});const l=Math.round(i/60);if(l<24)return a("time.hours_ago",{count:l});const p=Math.round(l/24);return a("time.days_ago",{count:p})}function us({card:n,t:a,onSelect:o}){const i=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"es-sc__ticket-card-head",children:[t.jsxs("span",{className:"es-sc__ticket-card-number",children:["#",n.externalNumber]}),t.jsx("span",{className:`es-sc__ticket-card-status es-sc__ticket-card-status--${n.status}`,children:a(`escalation.status_${n.status}`)})]}),n.summary&&t.jsx("p",{className:"es-sc__ticket-card-summary",title:n.summary,children:n.summary}),t.jsxs("p",{className:"es-sc__ticket-card-meta",children:[cn(new Date(n.createdAt),a),n.priority?` · ${a(`support_chat.priority_${n.priority}`)}`:""]})]});if(o&&n.sessionId){const l=n.sessionId;return t.jsx("button",{type:"button",className:"es-sc__ticket-card es-sc__ticket-card--clickable",onClick:()=>o(l),"aria-label":a("support_chat.open_ticket_conversation"),title:a("support_chat.open_ticket_conversation"),children:i})}return t.jsx("div",{className:"es-sc__ticket-card",children:i})}const ln=[{value:"open",key:"support_chat.filter_open"},{value:"closed",key:"support_chat.filter_closed"},{value:"all",key:"support_chat.filter_all"}];function un(n){const{status:a,loading:o,tickets:i,onSelectStatus:l,onSelectSession:p,t:x}=n;return t.jsxs("div",{className:"es-sc__tickets-view",children:[t.jsx("div",{className:"es-sc__tickets-filters",children:ln.map(m=>t.jsx("button",{type:"button",className:`es-sc__tickets-chip${a===m.value?" es-sc__tickets-chip--active":""}`,onClick:()=>l(m.value),children:x(m.key)},m.value))}),t.jsx("div",{className:"es-sc__tickets-view-list",children:o?t.jsx("p",{className:"es-sc__tickets-empty",role:"status","aria-live":"polite",children:"…"}):i.length===0?t.jsx("p",{className:"es-sc__tickets-empty",children:x("support_chat.tickets_empty")}):i.map(m=>t.jsx(us,{card:m,t:x,onSelect:p},m.externalNumber))})]})}const dn=["audio/webm;codecs=opus","audio/webm","audio/mp4"];function pn(){return typeof navigator>"u"||typeof window>"u"?!1:typeof navigator.mediaDevices?.getUserMedia=="function"&&typeof window.MediaRecorder<"u"}function fn(){if(typeof window>"u"||typeof window.MediaRecorder>"u")return;const n=typeof window.MediaRecorder.isTypeSupported=="function";for(const a of dn)if(!n||window.MediaRecorder.isTypeSupported(a))return a}function hn({baseUrl:n,apiKey:a,jwt:o,language:i,onTranscript:l,t:p,disabled:x=!1,streaming:m,voiceStream:g,baseText:_,onText:r}){const[f]=s.useState(pn),[v,b]=s.useState("idle"),[k,A]=s.useState(null),[U,O]=s.useState("idle"),R=!!(m&&g&&_&&r),w=s.useRef(null),q=s.useRef(null),B=s.useRef([]),V=s.useRef(!0);s.useEffect(()=>()=>{V.current=!1},[]);const ce=s.useRef({baseUrl:n,apiKey:a,jwt:o,language:i,onTranscript:l});s.useEffect(()=>{ce.current={baseUrl:n,apiKey:a,jwt:o,language:i,onTranscript:l}},[n,a,o,i,l]);const le=s.useCallback(()=>{q.current?.getTracks().forEach(T=>T.stop()),q.current=null,w.current=null,B.current=[]},[]);s.useEffect(()=>le,[le]);const E=s.useRef(()=>{});E.current=()=>{R&&(U==="connecting"||U==="listening")&&g?.stop()},s.useEffect(()=>()=>E.current(),[]);const H=s.useCallback(async T=>{const{baseUrl:z,apiKey:Z,jwt:Y,language:$,onTranscript:P}=ce.current,te=new FormData;te.append("audio",T,"recording.webm"),te.append("language",$);const ae={};Z&&(ae["X-API-Key"]=Z),Y&&(ae.Authorization=`Bearer ${Y}`);const ke=await fetch(`${z}/api/widget/transcribe`,{method:"POST",headers:ae,credentials:"include",body:te});if(!ke.ok){const J=new Error(`HTTP ${ke.status}`);throw J.status=ke.status,J}const Ie=await ke.json();P(Ie.text??"")},[]),pe=s.useCallback(async()=>{A(null);let T;try{T=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{b("error"),A("voice.permission_denied");return}const z=fn();let Z;try{Z=z?new MediaRecorder(T,{mimeType:z}):new MediaRecorder(T)}catch{T.getTracks().forEach(Y=>Y.stop()),b("error"),A("voice.error_generic");return}q.current=T,w.current=Z,B.current=[],Z.ondataavailable=Y=>{Y.data&&Y.data.size>0&&B.current.push(Y.data)},Z.onstop=async()=>{const Y=Z.mimeType||z||"audio/webm",$=new Blob(B.current,{type:Y});if(le(),$.size===0){b("idle");return}b("transcribing");try{if(await H($),!V.current)return;b("idle"),A(null)}catch(P){if(!V.current)return;const te=P.status;b("error"),A(te===413?"voice.error_too_large":"voice.error_generic")}},Z.start(),b("recording")},[le,H]),ue=s.useCallback(()=>{const T=w.current;T&&T.state!=="inactive"?T.stop():(le(),b("idle"))},[le]),ne=s.useCallback(()=>{f&&(R?U==="connecting"||U==="listening"?(g.stop(),O("idle")):(A(null),g.start({language:i,baseText:_,onText:r,onState:T=>O(T),onError:T=>{A(T),O("error")}})):v==="recording"?ue():(v==="idle"||v==="error")&&pe())},[f,R,U,v,i,_,r,g,pe,ue]);if(!f)return null;const fe=R?U==="connecting"||U==="listening":v==="recording",he=!R&&v==="transcribing",Oe=R?U==="error":v==="error",xe=p(fe?"voice.stop":"voice.start"),me=k?p(k):he?p("voice.transcribing"):xe,ye=["es-sc__mic",fe&&"es-sc__mic--recording",he&&"es-sc__mic--transcribing",Oe&&"es-sc__mic--error"].filter(Boolean).join(" ");return t.jsx("button",{type:"button",className:ye,onClick:ne,disabled:he||x,"aria-label":xe,"aria-pressed":fe,title:me,children:he?t.jsx("svg",{width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"es-sc__mic-spinner","aria-hidden":"true",children:t.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}):fe?t.jsx("svg",{width:18,height:18,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})}):t.jsxs("svg",{width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"}),t.jsx("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),t.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"22"})]})})}function mn(){return t.jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none","aria-hidden":"true",children:t.jsx("path",{d:"M8 5.14v13.72a1 1 0 0 0 1.5.86l11-6.86a1 1 0 0 0 0-1.72l-11-6.86A1 1 0 0 0 8 5.14Z"})})}function gn(){return t.jsxs("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none","aria-hidden":"true",children:[t.jsx("rect",{x:"6",y:"5",width:"4",height:"14",rx:"1"}),t.jsx("rect",{x:"14",y:"5",width:"4",height:"14",rx:"1"})]})}function _n(){return t.jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none","aria-hidden":"true",children:t.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})})}function bn(){return t.jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"es-sc__readaloud-spinner","aria-hidden":"true",children:t.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}const vn=s.memo(function({id:n,session:a,onActivate:o,t:i}){const l=a.activeId===n?a.status:"idle",p=s.useCallback(()=>{if(l==="idle"||l==="error"){o();return}l!=="loading"&&a.togglePause()},[l,o,a]),x=s.useCallback(()=>a.stop(),[a]),m=i(l==="playing"?"voice_output.pause":"voice_output.play"),g=l==="error"?i("voice_output.error"):m;return t.jsxs("span",{className:"es-sc__readaloud-group",children:[t.jsx("button",{type:"button",className:["es-sc__readaloud-btn",l==="playing"&&"es-sc__readaloud-btn--playing",l==="paused"&&"es-sc__readaloud-btn--paused",l==="error"&&"es-sc__readaloud-btn--error"].filter(Boolean).join(" "),onClick:p,disabled:l==="loading","aria-label":m,"aria-pressed":l==="playing",title:g,children:l==="loading"?t.jsx(bn,{}):l==="playing"?t.jsx(gn,{}):t.jsx(mn,{})}),(l==="playing"||l==="paused")&&t.jsx("button",{type:"button",className:"es-sc__readaloud-btn es-sc__readaloud-btn--stop",onClick:x,"aria-label":i("voice_output.stop"),title:i("voice_output.stop"),children:t.jsx(_n,{})})]})});function xn(n){let a=null,o=0,i=null;const l=new Set,p={ended:new Set},x=g=>{for(const _ of[...p[g]])_()},m=g=>{g.onended=null,Js(()=>g.stop())};return{push(g){const _=new Uint8Array(g);let r;i&&i.length>0?(r=new Uint8Array(i.length+_.length),r.set(i,0),r.set(_,i.length),i=null):r=_;const f=r.length-r.length%2;if(f<r.length&&(i=r.slice(f)),f===0)return;const v=new Int16Array(r.buffer,r.byteOffset,f/2);if(v.length===0)return;a??(a=new AudioContext({sampleRate:n}));const b=a.createBuffer(1,v.length,n);b.getChannelData(0).set(Float32Array.from(v,U=>U/32768));const k=a.createBufferSource();k.buffer=b,k.connect(a.destination),k.onended=()=>{l.delete(k),l.size===0&&x("ended")},l.add(k);const A=Math.max(a.currentTime,o);k.start(A),o=A+b.duration},reset(){for(const g of[...l])m(g);l.clear(),o=0,i=null},pause(){a?.suspend()},resume(){a?.resume()},on(g,_){return p[g].add(_),()=>{p[g].delete(_)}},close(){for(const g of[...l])m(g);l.clear(),a?.close(),a=null,o=0,p.ended.clear()}}}function yn({baseUrl:n,apiKey:a,getJwt:o}){const[i,l]=s.useState(null),[p,x]=s.useState("idle"),m=s.useRef(null),g=s.useRef(null),_=s.useRef([]),r=s.useRef(!1),f=s.useRef(!1),v=s.useRef(!1),b=s.useRef(0),k=s.useRef(null),A=s.useRef(null),U=s.useCallback(()=>{A.current&&(clearTimeout(A.current),A.current=null)},[]),O=s.useCallback(()=>{k.current?.abort(),k.current=null,A.current&&(clearTimeout(A.current),A.current=null),g.current?.close(),g.current=null,_.current=[],r.current=!1,f.current=!1,v.current=!1},[]),R=s.useCallback(()=>{b.current+=1,O(),m.current=null,l(null),x("idle")},[O]),w=s.useCallback(()=>{const E=g.current;E&&x(H=>H==="playing"?(E.pause(),"paused"):H==="paused"?(E.resume(),"playing"):H)},[]),q=s.useCallback(E=>{if(m.current===E)return;O(),b.current+=1,k.current=new AbortController,m.current=E,l(E),x("loading");const H=b.current;A.current=setTimeout(()=>{H===b.current&&(k.current?.abort(),x("error"))},12e3)},[O]),B=s.useCallback(async E=>{if(!E)return;const H=o?.();await Te(fetch(`${n}/api/widget/read-aloud-play`,{method:"POST",headers:{"Content-Type":"application/json",...a?{"X-API-Key":a}:{},...H?{Authorization:`Bearer ${H}`}:{}},body:JSON.stringify({messageId:E})}))},[n,a,o]),V=s.useCallback((E,H)=>{r.current||(r.current=!0,(async()=>{for(;_.current.length>0;){if(E!==b.current){r.current=!1;return}const pe=_.current.shift();if(!pe)continue;const ue=o?.(),[ne,fe]=await Te(fetch(`${n}/api/widget/read-aloud`,{method:"POST",headers:{"Content-Type":"application/json",...a?{"X-API-Key":a}:{},...ue?{Authorization:`Bearer ${ue}`}:{}},body:JSON.stringify({text:pe,language:H,messageId:m.current??void 0}),signal:k.current?.signal}));if(E!==b.current){r.current=!1;return}if(fe||!ne||!ne.ok||!ne.body){x("error"),r.current=!1;return}const he=ne.headers.get("X-Audio-Encoding");if(he&&he!=="pcm16"){x("error"),r.current=!1;return}if(!g.current){const me=Number(ne.headers.get("X-Audio-Sample-Rate"))||24e3,ye=xn(me);g.current=ye,ye.on("ended",()=>{E===b.current&&(!f.current||_.current.length>0||r.current||R())})}const Oe=g.current,xe=ne.body.getReader();for(;;){const[me,ye]=await Te(xe.read());if(E!==b.current){r.current=!1;return}if(ye){x("error"),r.current=!1;return}const{done:T,value:z}=me;if(T)break;z&&z.byteLength>0&&(Oe.push(z.buffer.slice(z.byteOffset,z.byteOffset+z.byteLength)),v.current||(v.current=!0,U(),x("playing"),B(m.current)))}}r.current=!1,f.current&&!v.current&&E===b.current&&R()})())},[n,a,o,R,B]),ce=s.useCallback((E,H,pe)=>{if(m.current!==E)return;const ue=H.trim();ue&&(_.current.push(ue),V(b.current,pe))},[V]),le=s.useCallback(E=>{m.current===E&&(f.current=!0,_.current.length===0&&!r.current&&!v.current&&R())},[R]);return s.useEffect(()=>()=>R(),[R]),{activeId:i,status:p,activate:q,feed:ce,finish:le,togglePause:w,stop:R}}const kn=1200;function wn(n={language:"en"}){const{voiceStream:a,language:o,silenceMs:i=kn}=n;let l=null,p=null,x="",m=!1;const g=()=>{p&&clearTimeout(p),p=null},_=()=>{!a||!m||(x="",a.start({language:o,baseText:()=>"",onText:r=>{const f=r.trim();!f||f===x||(x=f,l?.({type:"user_partial",text:f}),g(),p=setTimeout(()=>{const v=x;v&&(x="",l?.({type:"user_final",text:v}),a.stop(),_())},i))},onError:r=>l?.({type:"error",message:r})}))};return{get available(){return!!a},async start({onEvent:r}){if(!a)throw new Error("conversation transport unavailable");l=r,m=!0,_()},stop(){m=!1,g(),x="",a&&a.stop(),l=null}}}function jn(n){let a=null,o=null;return{get available(){return n.enabled&&typeof RTCPeerConnection<"u"},async start({onEvent:i}){o=i;const l={"Content-Type":"application/json","X-API-Key":n.apiKey},p=n.getJwt?.()??n.jwt;p&&(l.Authorization=`Bearer ${p}`);const x=n.getSessionId?.()??null,m=await fetch(`${n.baseUrl}/api/widget/realtime-voice`,{method:"POST",headers:l,body:JSON.stringify({language:n.language,...x?{sessionId:x}:{}})});if(!m.ok)throw new Error("eleven token refused");const g=await m.json(),_=g.data?.token;if(g.data?.provider!=="elevenlabs"||!_)throw new Error("not an elevenlabs session");g.data?.sessionId&&n.onSessionId?.(g.data.sessionId);const r=g.data?.endUserToken??"",{Conversation:f}=await Ws(async()=>{const{Conversation:w}=await import("./index-DMQkz1bV-BuMYksln.js");return{Conversation:w}},[]);let v=!1,b=null;const k=.6,A=.35,U=w=>{w!==v&&(v=w,o?.({type:"user_speaking",active:w}))};let O="";const R=w=>{const q=w?.trim();q&&(U(!1),o?.({type:"thinking"}),q!==O&&(O=q,n.onUserTurnEnd?.()))};a=await f.startSession({conversationToken:_,connectionType:"webrtc",customLlmExtraBody:{end_user_token:r},onModeChange:({mode:w})=>{o?.(w==="speaking"?{type:"agent_delta",text:""}:{type:"agent_done"})},onVadScore:({vadScore:w})=>{w>=k?(b&&(clearTimeout(b),b=null),U(!0)):w<=A&&v&&!b&&(b=setTimeout(()=>{b=null,U(!1)},600))},onMessage:({message:w,role:q})=>{const B=w?.trim();B&&(q==="user"?R(B):(n.onTranscript({role:"assistant",text:B,streaming:!1}),O=""))},onIncomingEvent:w=>{w?.type==="user_transcript"&&R(w.user_transcription_event?.user_transcript)},onAgentTyping:()=>o?.({type:"thinking"}),onAgentChatResponsePart:w=>{const q=w?.text??"";q&&n.onTranscript({role:"assistant",text:q,streaming:!0})},onInterruption:()=>o?.({type:"interrupted"}),onError:w=>{console.warn("[voice] eleven blad:",w),o?.({type:"error",message:"voice_conv.error"})}})},setMuted(i){a?.setMicMuted?.(i)},sendUserMessage(i){const l=i.trim();return!l||!a||(a.sendUserActivity?.(),!a.sendUserMessage)?!1:(a.sendUserMessage(l),!0)},stop(){o=null;const i=a;a=null,i?.endSession()}}}function ns({followUps:n,isNewest:a,isPending:o,hasQuickReplies:i,isSending:l,onSelect:p,t:x}){return!a||o||i||!n||n.length===0?null:t.jsx("div",{className:"es-sc__followups",role:"list","aria-label":x("support_chat.followups_aria"),"data-es-no-read":!0,children:n.map(m=>t.jsx("button",{type:"button",role:"listitem",disabled:l,className:"es-sc__suggestion es-sc__suggestion--followup",onClick:()=>p(m.message),children:m.label},m.message))})}function Nn(n){switch(n){case"OUT_OF_HOURS":return"support_chat.handoff.out_of_hours";case"QUEUE_FULL":return"support_chat.handoff.queue_full";default:return"support_chat.handoff.no_operator_title"}}const jt={email:254,phone:32,note:2e3},Cn={email:"",phone:"",note:""};function Sn(n){const[a,o]=s.useState(()=>Date.now());return s.useEffect(()=>{if(n===null)return;const i=setInterval(()=>o(Date.now()),1e3);return()=>clearInterval(i)},[n]),n===null?null:Math.max(0,Math.ceil((n-a)/1e3))}function Rn({status:n,onSubmitContact:a,onDismissContact:o,t:i}){const[l,p]=s.useState(Cn),[x,m]=s.useState(!1),[g,_]=s.useState(null),r=s.useRef(null),f=Sn(n.kind==="waiting"?n.until:null);return s.useEffect(()=>{n.kind==="unavailable"&&r.current?.focus()},[n.kind]),n.kind==="idle"?null:n.kind==="waiting"?t.jsxs("div",{className:"es-sc__handoff es-sc__handoff--waiting",role:"status","aria-live":"polite",children:[t.jsx("span",{className:"es-sc__handoff-dot","aria-hidden":"true"}),t.jsx("span",{className:"es-sc__handoff-text",children:f===null?i("support_chat.handoff.queued"):i("support_chat.handoff.waiting",{seconds:f})})]}):n.kind==="human"?t.jsx("div",{className:"es-sc__handoff es-sc__handoff--human",role:"status","aria-live":"polite",children:t.jsx("span",{className:"es-sc__handoff-text",children:n.displayName?i("support_chat.handoff.human_joined",{name:n.displayName}):i("support_chat.handoff.human_joined_unnamed")})}):n.kind==="contact_left"?t.jsx("div",{className:"es-sc__handoff es-sc__handoff--done",role:"status","aria-live":"polite",children:t.jsx("span",{className:"es-sc__handoff-text",children:i("support_chat.handoff.contact_success")})}):t.jsxs("form",{className:"es-sc__handoff es-sc__handoff--form",onSubmit:async v=>{if(v.preventDefault(),x)return;if(l.email.trim().length===0&&l.phone.trim().length===0){_(i("support_chat.handoff.contact_validation")),r.current?.focus();return}m(!0),_(null);const b=await a({email:l.email.trim(),phone:l.phone.trim(),note:l.note.trim()});m(!1),b||_(i("support_chat.handoff.contact_error"))},noValidate:!0,children:[t.jsx("p",{className:"es-sc__handoff-title",children:i(Nn(n.reason))}),t.jsx("p",{className:"es-sc__handoff-text",children:i("support_chat.handoff.contact_prompt")}),t.jsx("label",{className:"es-sc__handoff-label",htmlFor:"es-sc-handoff-email",children:i("support_chat.handoff.contact_email_label")}),t.jsx("input",{id:"es-sc-handoff-email",ref:r,className:"es-sc__handoff-input",type:"email",autoComplete:"email",maxLength:jt.email,value:l.email,"aria-invalid":g!==null,"aria-describedby":g?"es-sc-handoff-error":void 0,onChange:v=>p(b=>({...b,email:v.target.value}))}),t.jsx("label",{className:"es-sc__handoff-label",htmlFor:"es-sc-handoff-phone",children:i("support_chat.handoff.contact_phone_label")}),t.jsx("input",{id:"es-sc-handoff-phone",className:"es-sc__handoff-input",type:"tel",autoComplete:"tel",maxLength:jt.phone,value:l.phone,onChange:v=>p(b=>({...b,phone:v.target.value}))}),t.jsx("label",{className:"es-sc__handoff-label",htmlFor:"es-sc-handoff-note",children:i("support_chat.handoff.contact_note_label")}),t.jsx("textarea",{id:"es-sc-handoff-note",className:"es-sc__handoff-input es-sc__handoff-textarea",rows:3,maxLength:jt.note,value:l.note,onChange:v=>p(b=>({...b,note:v.target.value}))}),g&&t.jsx("p",{className:"es-sc__handoff-error",id:"es-sc-handoff-error",role:"alert",children:g}),t.jsxs("div",{className:"es-sc__handoff-actions",children:[t.jsx("button",{className:"es-sc__handoff-submit",type:"submit",disabled:x,children:i("support_chat.handoff.contact_submit")}),t.jsx("button",{className:"es-sc__handoff-dismiss",type:"button",onClick:o,children:i("support_chat.handoff.contact_dismiss")})]})]})}const ds="live:";function De(n){return n.id.startsWith(ds)}function En(n,a){return n.text!==a.text?!0:JSON.stringify(n.metadata??null)!==JSON.stringify(a.metadata??null)}function Tn(n,a){if(a.length===0)return n;const o=new Map;n.forEach((_,r)=>o.set(_.id,r));let i=null;const l=[];let p=!1;for(const _ of a){const r=o.get(_.id);if(r===void 0){l.push(_),_.role==="assistant"&&(p=!0);continue}const f=n[r];En(f,_)&&(i??(i=[...n]),i[r]={...f,..._})}if(l.length===0)return i??n;const x=i??[...n],m=p?x.filter(_=>!De(_)):x,g=m.filter(De);return[...m.filter(_=>!De(_)),...l,...g]}function In({transport:n,agentId:a,onUserMessage:o,onStopPlayback:i}){const[l,p]=s.useState("idle"),[x,m]=s.useState(null),[g,_]=s.useState(!1),[r,f]=s.useState(null),v=s.useRef(o);v.current=o;const b=s.useRef(i);b.current=i;const k=s.useCallback(R=>{switch(R.type){case"user_partial":b.current(),m(R.text),p("listening");return;case"user_final":m(null),_(!1),p("listening"),R.text.trim()&&v.current(R.text);return;case"user_speaking":_(R.active),R.active&&(b.current(),p("listening"));return;case"thinking":m(null),_(!1),p("thinking");return;case"agent_delta":p("speaking");return;case"agent_done":p("listening");return;case"interrupted":b.current(),p("listening");return;case"error":f(R.message),p("error");return}},[]),A=s.useCallback(async()=>{if(!n.available){f("voice_conv.error"),p("error");return}f(null),p("connecting"),b.current();const[,R]=await Te(n.start({agentId:a,onEvent:k}));if(R){f("voice_conv.error"),p("error");return}p("listening")},[n,a,k]),U=s.useCallback(()=>{n.stop(),m(null),_(!1),p("idle")},[n]),O=s.useRef(n);return O.current=n,s.useEffect(()=>()=>O.current.stop(),[]),{state:l,draft:x,userSpeaking:g,error:r,start:A,stop:U}}const Mn=()=>t.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round","aria-hidden":"true",children:[t.jsx("rect",{x:"9",y:"3",width:"6",height:"11",rx:"3"}),t.jsx("path",{d:"M5 11a7 7 0 0 0 14 0M12 18v3"})]}),as=()=>t.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M4 4l16 16"}),t.jsx("path",{d:"M9 5a3 3 0 0 1 6 0v5m-6 1.5V11"}),t.jsx("path",{d:"M5 11a7 7 0 0 0 10.9 5.8M19 11a7 7 0 0 1-.4 2.3M12 18v3"})]}),An=()=>t.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:t.jsx("path",{d:"M6 6l12 12M18 6L6 18"})});function Pn({running:n}){const[a,o]=s.useState(0);return s.useEffect(()=>{if(!n)return;const i=setInterval(()=>o(l=>l+1),1e3);return()=>clearInterval(i)},[n]),t.jsx("span",{className:"es-vm__elapsed","data-testid":"voice-mode-elapsed",children:$n(a)})}function $n(n){const a=Math.floor(n/60),o=n%60;return`${a}:${String(o).padStart(2,"0")}`}function Ln({state:n,draft:a,error:o,muted:i,listening:l,hasTranscript:p,transcript:x,onToggleMute:m,onEnd:g,onRetry:_,t:r}){const f=s.useRef(null);if(s.useEffect(()=>{const k=f.current;k&&(k.scrollTop=k.scrollHeight)},[x]),n==="error")return t.jsxs("div",{className:"es-vm","data-testid":"voice-mode",children:[t.jsxs("div",{className:"es-vm__top",children:[t.jsx("span",{className:"es-vm__dot es-vm__dot--error"}),t.jsx("span",{className:"es-vm__label",children:r("voice_conv.title")})]}),t.jsxs("div",{className:"es-vm__denied",children:[t.jsx("div",{className:"es-vm__denied-icon",children:t.jsx(as,{})}),t.jsxs("div",{children:[t.jsx("div",{className:"es-vm__denied-title",children:r("voice_conv.denied_title")}),t.jsx("div",{className:"es-vm__denied-body",children:r(o||"voice_conv.denied_body")})]}),t.jsxs("div",{className:"es-vm__denied-actions",children:[t.jsx("button",{type:"button",className:"es-vm__action es-vm__action--primary",onClick:_,"data-testid":"voice-mode-retry",children:r("voice_conv.retry")}),t.jsx("button",{type:"button",className:"es-vm__action",onClick:g,"data-testid":"voice-mode-back",children:r("voice_conv.back_to_typing")})]})]})]});const v=!i&&(!!l||!!(a&&a.trim())),b=i?"muted":n==="speaking"?"speaking":n==="thinking"?"thinking":"listening";return t.jsxs("div",{className:"es-vm","data-testid":"voice-mode","data-state":n,children:[t.jsxs("div",{className:"es-vm__top",children:[t.jsx("span",{className:"es-vm__label",children:r("voice_conv.title")}),t.jsx(Pn,{running:n!=="idle"})]}),t.jsxs("div",{className:"es-vm__orbwrap",children:[t.jsxs("div",{className:"es-vm__orb","data-s":b,"data-active":v?"1":void 0,"data-testid":"voice-mode-orb","aria-hidden":"true",children:[t.jsx("span",{className:"es-vm__orb-halo"}),t.jsx("span",{className:"es-vm__orb-halo es-vm__orb-halo--delayed"}),t.jsx("span",{className:"es-vm__orb-core"})]}),t.jsx("div",{className:"es-vm__orb-state",role:"status","data-testid":"voice-mode-state",children:r(`voice_conv.state_${b}`)}),t.jsx("div",{className:"es-vm__orb-hint",children:r(`voice_conv.state_${b}_hint`)})]}),t.jsx("div",{className:"es-vm__transcript","data-testid":"voice-mode-transcript",ref:f,children:p?x:t.jsx("div",{className:"es-vm__invite","data-testid":"voice-mode-invite",children:r("voice_conv.invite")})}),t.jsxs("div",{className:"es-vm__controls",children:[t.jsx("button",{type:"button",className:`es-vm__btn${i?" es-vm__btn--on":""}`,"aria-label":r(i?"voice_conv.unmute":"voice_conv.mute"),onClick:m,"data-testid":"voice-mode-mute",children:i?t.jsx(as,{}):t.jsx(Mn,{})}),t.jsx("button",{type:"button",className:"es-vm__btn es-vm__btn--end","aria-label":r("voice_conv.end"),onClick:g,"data-testid":"voice-mode-end",children:t.jsx(An,{})})]})]})}const rs=/[.!?]+(?:['")\]]+)?(\s+)/g;function Un(n){const a=[];let o=0;rs.lastIndex=0;let i;for(;i=rs.exec(n);){const l=i.index+i[0].length,p=n.slice(o,l).trim();p&&a.push(p),o=l}return{complete:a,remainder:n.slice(o)}}function Dn(n,a,o){return n===void 0?o:n.map(i=>{const l=i.translations?.[a]?.trim();return l||i.translations?.[i.baseLanguage]?.trim()||(Object.values(i.translations??{}).find(x=>x?.trim())?.trim()??"")}).filter(i=>i.length>0)}function On({size:n=16}){return t.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("polyline",{points:"12 6 12 12 16 14"})]})}function qn({size:n=18}){return t.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M12 5H5a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z"})]})}function Bn({size:n=16}){return t.jsxs("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M2 9a3 3 0 1 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 1 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z"}),t.jsx("path",{d:"m9 12 2 2 4-4"})]})}const Hn=["confirm_escalation","cancel_escalation","confirm_handoff","decline_handoff"],Fn="<followups>",Kn=/<followups>/i;function zn(n){const a=n.search(Kn);if(a!==-1)return n.slice(0,a).trimEnd();const o=n.lastIndexOf("<");return o!==-1&&Fn.startsWith(n.slice(o).toLowerCase())?n.slice(0,o).trimEnd():n}function is(n){return n>=.6?"high":n>=.35?"medium":"low"}function Qn(n){return/^https?:\/\//i.test(n)}function Wn(n){return n==="OUT_OF_HOURS"||n==="QUEUE_FULL"||n==="NO_OPERATOR"?n:null}function os(n){const{metadata:a,...o}=n;return{...o,...a&&typeof a=="object"?a:{}}}function Jn(n){let a=null;const o=[];for(const i of n.split(`
|
|
2
|
-
`))i.startsWith("event:")?a=i.slice(6).trim():i.startsWith("data:")&&o.push(i.slice(5).trimStart());return{event:a,data:o.join(`
|
|
3
|
-
`)}}const Xn=12e4,cs=1500,Vn=6e4,ls=120,Zn=25e3,Yn=600;function Gn({value:n,onChange:a,disabled:o,t:i}){const[l,p]=s.useState(null),x=n??0,m=!o&&l!==null?l:x;return t.jsxs("div",{className:"es-sc__rating-group",children:[t.jsx("div",{className:"es-sc__rating",role:"radiogroup","aria-label":i("support_chat.rate_aria"),onMouseLeave:()=>!o&&p(null),children:[1,2,3,4,5].map(g=>{const _=g<=m;return t.jsx("button",{type:"button",role:"radio","aria-checked":g===x,"aria-label":i("support_chat.rate_star",{count:g}),disabled:o,onMouseEnter:()=>!o&&p(g),onFocus:()=>!o&&p(g),onBlur:()=>!o&&p(null),onClick:()=>!o&&a?.(g),className:`es-sc__rating-star${_?" es-sc__rating-star--filled":""}${o?" es-sc__rating-star--disabled":""}`,children:t.jsx("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:_?"currentColor":"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})})},g)})}),t.jsx("span",{className:"es-sc__rating-label","aria-live":"polite",children:m>0?i(`support_chat.rate_label_${m}`):""})]})}function la({config:n,actions:a,baseUrl:o,externalContext:i,productId:l,i18n:p,supportSessionId:x,auth:m,readOnly:g}){const _=g===!0,r=p?.t??(e=>e),f=i?.apiKey??"",v=s.useRef(m?.jwt);s.useEffect(()=>{v.current=m?.jwt},[m?.jwt]);const b=i?.voice,k=p?.currentLanguage??"en",A=!!b?.enabled&&(b?.languages??[]).includes(k),U=n.voiceConversationEnabled===!0,O=n.voiceReadAloudEnabled===!0,R=i?.voiceOutput,w=yn({baseUrl:o,apiKey:f,getJwt:()=>v.current}),q=s.useRef(w);q.current=w;const B=O&&!!R?.enabled&&(R?.languages??[]).includes(k),V=s.useRef(0),ce=i?.userContext??void 0,le=i?.resetSession??!1,E=i?.showTicketsTab??!1,H=kt(n.welcomeMessage,k,{t:r,fallbackKey:"support_chat.welcome_message",enDefault:"Hi! How can I help you today?"}),pe=kt(n.placeholder,k,{t:r,fallbackKey:"support_chat.input_placeholder",enDefault:"Ask a question..."}),ue=n.showSuggestedQuestions??!0,ne=Dn(n.localizedSuggestedQuestions,k,n.suggestedQuestions??[]),fe=n.escalationLabel||r("support_chat.escalation_label"),he=n.humanHandoffButton===!0,Oe=kt(n.headerTitle,k,{t:r,fallbackKey:"support.title",enDefault:"Support"}),xe=n.allowedLinkHosts,me=s.useMemo(()=>Array.isArray(xe)?xe.filter(e=>typeof e=="string"):void 0,[xe]),ye=n.allowMediaEmbeds===!0,T=typeof n._draft=="string"?n._draft:void 0,z=n._autoSend===!0,Z=Array.isArray(n._quickChips)?n._quickChips:[],Y=JSON.stringify(Z),[$,P]=s.useState([]);s.useEffect(()=>{if(!B)return;const e=w.activeId;if(!e){V.current=0;return}const c=$.find(h=>h.id===e);if(!c)return;const u=c.role==="assistant"&&c.refusalReason?r(`support_chat.refusal_${c.refusalReason}`,{productName:c.refusalProductName??""}):c.text??"";if(u.length>V.current){const h=u.slice(V.current),{complete:d,remainder:j}=Un(h);if(d.length>0){V.current=u.length-j.length;for(const N of d)w.feed(e,N,k)}}if(!c.isPending){const h=u.slice(V.current).trim();h&&(w.feed(e,h,k),V.current=u.length),w.finish(e)}},[$,w,B,k]);const[te,ae]=s.useState(""),[ke,Ie]=s.useState([]),[J,qe]=s.useState(!1),[Nt,Ze]=s.useState(null),[Be,Ye]=s.useState(null),[X,Se]=s.useState(x??null),[Me,it]=s.useState(null),[ot,ps]=s.useState(!1),[Re,Ct]=s.useState(null),[fs,St]=s.useState(0),[Ae,hs]=s.useState("open"),[ms,He]=s.useState([]),[gs,Ge]=s.useState(!1),[re,Fe]=s.useState("chat"),[Rt,ie]=s.useState({kind:"idle"}),Ee=s.useRef(null),et=s.useRef(le),Et=s.useRef(null),ct=s.useRef(!1),{containerRef:_s,isPinned:bs,scrollToBottom:Pe,stickToBottom:Tt}=Xs(),G=s.useRef(null),ge=s.useRef(null),tt=s.useRef(null),st=s.useRef(null);s.useEffect(()=>{Tt()},[$,Tt]),s.useEffect(()=>()=>{ge.current?.abort()},[]),s.useEffect(()=>{if(Me==null)return;const e=Me-Date.now();if(e<=0){it(null);return}const c=setTimeout(()=>it(null),e);return()=>clearTimeout(c)},[Me]),s.useEffect(()=>{if(Re==null)return;const e=()=>{const u=Re-Date.now();if(u<=0){Ct(null),St(0);return}St(Math.ceil(u/1e3))};e();const c=setInterval(e,1e3);return()=>clearInterval(c)},[Re]);const $e=s.useRef(null),we=s.useCallback(()=>{$e.current&&($e.current.cancelled=!0),$e.current=null},[]);s.useEffect(()=>a.on("support-chat:clearHistory",()=>{ge.current?.abort(),we(),P([]),Ze(null),Ye(null),qe(!1),Se(null),st.current=null,et.current=!0}),[a,we]),s.useEffect(()=>{a.emit("support-chat:session",{sessionId:X})},[a,X]);const It=s.useCallback((e,c,u)=>{we();const h={cancelled:!1};$e.current=h;const d=u?.trim()?u:null,j=`resume-${crypto.randomUUID()}`;P(D=>[...D,{id:j,role:"assistant",text:d??"",isPending:!d}]),Pe();const N=Date.now()+(d?6e3:Vn),C=async()=>{if(h.cancelled)return;let D=null;try{const y=v.current,I=await fetch(`${o}/api/support-chat/sessions/${e}/messages?limit=50`,{headers:{...f?{"X-API-Key":f}:{},...y?{Authorization:`Bearer ${y}`}:{}}});if(I.ok){const W=await I.json(),ve=W.success&&W.data?W.data.messages:[];for(let M=ve.length-1;M>=0;M--){const Q=ve[M];if(Q.role!=="assistant")continue;const S=Q.createdAt?Date.parse(Q.createdAt):NaN;if(Number.isFinite(S)&&S>c){D=Q;break}}}}catch{}if(!h.cancelled){if(D){const y=D.metadata??{},I=y.confidence,W=typeof I=="number"?is(I):void 0;P(ve=>ve.map(M=>M.id===j?{...M,id:D.id,serverId:D.id,promptLogId:D.promptLogId??null,text:D.content,isPending:!1,confidence:I,confidenceLevel:W,sources:y.sources&&y.sources.length>0?y.sources:void 0,actions:y.actions&&y.actions.length>0?y.actions:void 0,quickReplies:y.quickReplies&&y.quickReplies.length>0?y.quickReplies:void 0,ticketCards:y.ticketCards&&y.ticketCards.length>0?y.ticketCards:void 0,suggestedFollowUps:y.suggestedFollowUps&&y.suggestedFollowUps.length>0?y.suggestedFollowUps:void 0,awaitingConfirmation:y.awaitingConfirmation,refusalReason:y.refusalReason,refusalProductName:y.refusalProductName}:M)),Pe(),$e.current=null;return}if(Date.now()>=N){d||P(y=>y.map(I=>I.id===j?{...I,text:r("support_chat.error_message"),isPending:!1}:I)),$e.current=null;return}setTimeout(C,cs)}};setTimeout(C,cs)},[f,o,we,Pe,r]),Ke=s.useCallback(async(e,c)=>{try{const u=v.current,h=await fetch(`${o}/api/support-chat/sessions/${e}/messages?limit=50`,{headers:{...f?{"X-API-Key":f}:{},...u?{Authorization:`Bearer ${u}`}:{}}});if(!h.ok)return;const d=await h.json();if(!d.success||!d.data)return;const j=d.data.messages.filter(y=>y.role==="user"||y.role==="assistant").map(y=>{const I=y.metadata??void 0,W=I?.ticketCards&&I.ticketCards.length>0?I.ticketCards:void 0;return{id:y.id,role:y.role,text:y.content,promptLogId:y.promptLogId??null,rating:y.userScore??null,...W?{ticketCards:W}:{},...I?.suggestedFollowUps&&I.suggestedFollowUps.length>0?{suggestedFollowUps:I.suggestedFollowUps}:{},...I?.refusalReason?{refusalReason:I.refusalReason,refusalProductName:I.refusalProductName}:{}}}),N=j.length-1,C=N>=0?j[N]:void 0;if(C&&C.role==="assistant"){const y=d.data.messages[d.data.messages.length-1]?.metadata;y?.quickReplies&&y.quickReplies.length>0&&(j[N]={...C,quickReplies:y.quickReplies,...y.awaitingConfirmation?{awaitingConfirmation:y.awaitingConfirmation}:{}})}P(j),st.current=e;const D=d.data.messages[d.data.messages.length-1];if(D&&D.role==="user"){const y=D.createdAt?Date.parse(D.createdAt):NaN;Number.isFinite(y)&&Date.now()-y<Xn&&It(e,y,c)}}catch{}},[f,o,It]),_e=s.useCallback(async e=>{if(!E)return[];try{const c=v.current,u=await fetch(`${o}/api/widget/support-chat/tickets?status=${e}`,{headers:{...f?{"X-API-Key":f}:{},...c?{Authorization:`Bearer ${c}`}:{}}});if(!u.ok)return[];const h=await u.json();return h.data?.counts&&h.data?.tickets?h.data.tickets:[]}catch{return[]}},[o,f,E]);s.useEffect(()=>{let e=!1;return(async()=>{const c=await _e("open").catch(()=>[]);e||He(c)})(),()=>{e=!0}},[_e,m?.jwt]);const vs=s.useCallback(async e=>{hs(e),Ge(!0);const c=await _e(e).catch(()=>[]);He(c),Ge(!1)},[_e]),Mt=s.useRef(!1);s.useEffect(()=>{Mt.current||x&&m?.jwt&&(Mt.current=!0,Ke(x))},[m?.jwt,x,Ke]),s.useEffect(()=>we,[we]),s.useEffect(()=>a.on("support-chat:select-session",e=>{const{sessionId:c}=e;Fe("chat"),!(!c||c===st.current)&&(ge.current?.abort(),P([]),Ze(null),Ye(null),qe(!1),Se(c),Ke(c))}),[a,Ke]);const je=s.useCallback(()=>{const e=G.current;if(!e)return;e.style.height="auto";const c=e.scrollHeight>ls;e.style.height=`${Math.min(e.scrollHeight,ls)}px`,e.style.overflowY=c?"auto":"hidden"},[]);s.useEffect(()=>{je()},[je]);const lt=s.useCallback((e,c)=>{const u=c.metadata??{},h=u.confidence,d=typeof h=="number"?is(h):void 0;P(j=>j.map(N=>N.id===e?{...N,id:c.id,serverId:c.id,promptLogId:c.promptLogId,rating:null,text:c.content,isPending:!1,confidence:h,confidenceLevel:d,sources:u.sources&&u.sources.length>0?u.sources:void 0,actions:u.actions&&u.actions.length>0?u.actions:void 0,quickReplies:u.quickReplies&&u.quickReplies.length>0?u.quickReplies:void 0,ticketCards:u.ticketCards&&u.ticketCards.length>0?u.ticketCards:void 0,suggestedFollowUps:u.suggestedFollowUps&&u.suggestedFollowUps.length>0?u.suggestedFollowUps:void 0,awaitingConfirmation:u.awaitingConfirmation,refusalReason:u.refusalReason,refusalProductName:u.refusalProductName}:N))},[]),At=s.useCallback(e=>{ps(!0),P(c=>c.map(u=>u.id===e?{...u,role:"assistant",text:r("support_chat.demo_quota_reached"),isPending:!1}:u))},[r]),ut=s.useCallback((e,c)=>{it(c??Date.now()+6e4),P(u=>u.map(h=>h.id===e?{...h,role:"assistant",text:r("support_chat.daily_limit_reached"),isPending:!1}:h))},[r]),dt=s.useCallback((e,c)=>{const u=typeof c=="number"&&c>0?c:6e4;Ct(Date.now()+u);const h=Math.ceil(u/1e3);P(d=>d.map(j=>j.id===e?{...j,role:"assistant",text:r("support_chat.rate_limited",{seconds:String(h)}),isPending:!1}:j))},[r]),Pt=s.useCallback((e,c)=>{P(u=>u.filter(h=>h.id!==e)),ie(c==="human"?{kind:"human",displayName:null}:{kind:"waiting",until:Ee.current})},[]),Ne=s.useCallback(()=>{ct.current&&(ct.current=!1,a.emit("chat:draftConsumed",void 0))},[a]),ee=s.useCallback(async(e,c)=>{const u=e.trim();if(!u)return;Ne(),we(),ge.current?.abort(),ge.current=new AbortController,Ze(null),Ye(null),ae(""),Ie([]),G.current&&(G.current.style.height="auto");const h={id:`user-${crypto.randomUUID()}`,role:"user",text:u},d=`assistant-${crypto.randomUUID()}`,j={id:d,role:"assistant",text:"",isPending:!0};P(M=>[...M,h,j]),Pe(),qe(!0),tt.current=d;const N=Date.now(),C=async()=>{const M=Yn-(Date.now()-N);M>0&&await new Promise(Q=>setTimeout(Q,M))};a.emit("support-chat:messageSent",{text:u});const[D]=await Te(async()=>await m?.ensureValidToken?.()??null),y=D??v.current,I={"Content-Type":"application/json",...f?{"X-API-Key":f}:{},...y?{Authorization:`Bearer ${y}`}:{}},W=et.current||X===null;let ve=!1;try{if(c?.quickReplyClick){const F=await fetch(`${o}/api/widget/support-chat/message`,{method:"POST",headers:I,body:JSON.stringify({message:u,productId:l,...W?{newSession:!0}:{},...ce?{userContext:os(ce)}:{},quickReplyClick:c.quickReplyClick}),signal:ge.current.signal}),K=await F.json();if(F.status===429&&K?.error?.code==="DAILY_TOKEN_LIMIT_EXCEEDED"){await C(),ut(d,K.error.resetAtMs);return}if(F.status===429&&K?.error?.code==="DEMO_QUOTA_EXCEEDED"){await C(),At(d);return}if(F.status===429&&K?.error?.code==="RATE_LIMITED"){await C(),dt(d,K.error.retryAfterMs);return}if(F.status===409&&K?.error?.code==="HANDOFF_ACTIVE"){await C(),Pt(d,K.data?.handoffState),K.data?.sessionId&&Se(K.data.sessionId);return}if(!F.ok||!K.success||!K.data)throw new Error(K.error?.message??`HTTP ${F.status}`);Se(K.data.sessionId),et.current=!1,lt(d,K.data.assistantMessage),c.quickReplyClick.payload==="confirm_handoff"&&((K.data.assistantMessage.metadata?.toolCalls?.includes("request_human_handoff")??!1)||(ie({kind:"idle"}),Ee.current=null)),_e(Ae).then(bt=>He(bt));return}let M;const Q=()=>{M&&clearTimeout(M),M=setTimeout(()=>{ve=!0,ge.current?.abort()},Zn)};Q();const S=ge.current;if(!S){clearTimeout(M);return}const[Ce,Yt]=await Te(async()=>{const F=await fetch(`${o}/api/widget/support-chat/stream`,{method:"POST",headers:I,body:JSON.stringify({message:u,productId:l,...W?{newSession:!0}:{},...ce?{userContext:os(ce)}:{}}),signal:S.signal});if(!F.ok||!F.body){const se=await F.json().catch(()=>null);if(F.status===429&&se?.error?.code==="DAILY_TOKEN_LIMIT_EXCEEDED")return{dailyLimitResetAtMs:se.error.resetAtMs};if(F.status===429&&se?.error?.code==="DEMO_QUOTA_EXCEEDED")return{demoQuotaExhausted:!0};if(F.status===429&&se?.error?.code==="RATE_LIMITED")return{rateLimitRetryAfterMs:se.error.retryAfterMs??6e4};if(F.status===409&&se?.error?.code==="HANDOFF_ACTIVE")return se.data?.sessionId&&Se(se.data.sessionId),{handoffState:se.data?.handoffState??null};throw new Error(se?.error?.message??`HTTP ${F.status}`)}const K=F.body.getReader(),bt=new TextDecoder;let Je="",Gt="",es=!1;for(;;){const{done:se,value:Ks}=await K.read();if(se)break;Q(),Je+=bt.decode(Ks,{stream:!0});let vt;for(;(vt=Je.indexOf(`
|
|
4
|
-
|
|
5
|
-
`))!==-1;){const zs=Je.slice(0,vt);Je=Je.slice(vt+2);const{event:Xe,data:Ve}=Jn(zs);if(!(!Xe||!Ve)){if(Xe==="start"){const de=JSON.parse(Ve);de.sessionId&&(Se(de.sessionId),st.current=de.sessionId),et.current=!1}else if(Xe==="token"){const de=JSON.parse(Ve);Gt+=de.value??"";const xt=zn(Gt);P(Qs=>Qs.map(yt=>yt.id===d?{...yt,text:xt}:yt))}else if(Xe==="meta"){const de=JSON.parse(Ve);lt(d,de.assistantMessage),_e(Ae).then(xt=>He(xt)),es=!0}else if(Xe==="error"){const de=JSON.parse(Ve);if(de.code==="HANDOFF_ACTIVE")return{handoffState:null};throw new Error(de.message??"Stream error")}}}}if(!es)throw new Error("Stream ended before completion");return null});if(M&&clearTimeout(M),Yt)throw Yt;if(Ce&&"handoffState"in Ce){await C(),Pt(d,Ce.handoffState);return}if(Ce?.dailyLimitResetAtMs!==void 0){await C(),ut(d,Ce.dailyLimitResetAtMs);return}if(Ce?.demoQuotaExhausted){await C(),At(d);return}if(Ce?.rateLimitRetryAfterMs!==void 0){await C(),dt(d,Ce.rateLimitRetryAfterMs);return}}catch(M){if(M instanceof Error&&M.name==="AbortError"&&!ve){P(Q=>Q.filter(S=>S.id!==d));return}await C(),P(Q=>Q.filter(S=>S.id!==d)),tt.current===d&&(Ye({text:u,options:c}),Ze(r("support_chat.error_message")))}finally{tt.current===d&&qe(!1)}},[a,o,ce,f,l,r,lt,ut,dt,_e,Ae,Pe,m,we,Ne]),be=b?.realtimeProvider==="elevenlabs",[pt,ft]=s.useState([]),$t=s.useRef(0),ze=s.useRef([]);ze.current=pt;const nt=s.useRef(null),ht=s.useRef(null),Lt=s.useRef(new Set),mt=s.useRef(new Set),Qe=s.useRef(!1),Le=s.useRef(null),gt=s.useRef(null),at=s.useRef(!1),Ut=s.useRef(X);Ut.current=X;const Dt=b?.realtime===!0,Ot=s.useRef(i?.voiceStream);Ot.current=i?.voiceStream;const qt=s.useMemo(()=>{if(be){const e=jn({baseUrl:o,apiKey:f,getJwt:()=>v.current,language:k,enabled:!0,getSessionId:()=>Ut.current,onSessionId:c=>{ht.current=c,Se(c)},onUserTurnEnd:()=>Le.current?.(),onTranscript:c=>ft(u=>{const h=u[u.length-1];if(!(h&&De(h)&&h.streaming&&h.role===c.role)){$t.current+=1;const j=`${ds}${$t.current}`;return[...u,{id:j,role:c.role,text:c.text,streaming:c.streaming}]}const d=c.role==="assistant"&&c.streaming?h.text+c.text:c.text;return[...u.slice(0,-1),{...h,text:d,streaming:c.streaming}]})});return nt.current=e,e}return nt.current=null,wn({voiceStream:Ot.current,language:k})},[be,o,f,k]),L=In({transport:qt,agentId:i?.voiceAgentId??"",onUserMessage:e=>{ee(e)},onStopPlayback:()=>q.current?.stop()}),Bt=L.state!=="idle"&&L.state!=="error",oe=L.state!=="idle",Ht=s.useRef(!1);s.useEffect(()=>{const e=Ht.current;if(Ht.current=oe,!oe){const c=(()=>{const u=ze.current;for(let h=u.length-1;h>=0;h-=1){const d=u[h];if(d&&d.role==="assistant"&&d.text?.trim())return d.text}return null})();if(ft([]),e){const u=ht.current??X;u&&Ke(u,c??void 0)}}},[oe]),s.useEffect(()=>{try{window.dispatchEvent(new CustomEvent("es-support-voice-mode",{detail:{active:oe}}))}catch{}},[oe]),s.useEffect(()=>{if(!be||!oe){Lt.current=new Set,mt.current=new Set,Qe.current=!1,Le.current=null;return}let e=!1,c=!1;at.current=!1;const u=async(N=!1)=>{const C=ht.current??X;if(!C||e)return!1;const D=v.current;let y=null;try{const S=await fetch(`${o}/api/support-chat/sessions/${C}/messages?limit=30`,{headers:{...f?{"X-API-Key":f}:{},...D?{Authorization:`Bearer ${D}`}:{}}});if(!S.ok)return!1;y=await S.json()}catch{return!1}if(e)return!1;const I=y?.data?.messages??[],W=Lt.current;if(!Qe.current){if(!N)return!1;for(const S of I)S.id&&mt.current.add(S.id),S.role==="user"&&S.id&&W.add(S.id);return Qe.current=!0,!1}const ve=mt.current,M=I.filter(S=>S.id&&S.content?.trim()&&(S.role==="user"||S.role==="assistant")&&!ve.has(S.id)).map(S=>({id:S.id,role:S.role,text:S.content,...S.metadata?{metadata:S.metadata}:{}}));if(M.length===0)return!1;ft(S=>Tn(S,M));const Q=M.filter(S=>S.role==="user"&&!W.has(S.id));if(Q.length===0)return!1;for(const S of Q)W.add(S.id);return at.current=!0,!0},h=async()=>{if(!(c||e)){c=!0;for(let N=0;N<10&&!e&&!await u(!1);N++)await new Promise(C=>setTimeout(C,500));c=!1}};let d=0;const j=5e3;return Le.current=()=>{if(at.current)return;const N=Date.now();N-d<j||(d=N,h())},gt.current=async()=>{for(let N=0;N<6&&!e;N+=1){if(await u(!1),!ze.current.some(De))return;await new Promise(C=>setTimeout(C,700))}},(async()=>{for(let N=0;N<4&&!e&&!Qe.current;N+=1){if(await u(!0),Qe.current)return;await new Promise(C=>setTimeout(C,300))}})(),()=>{e=!0,Le.current=null,gt.current=null}},[be,oe,X,o,f]);const Ft=s.useRef(!1);s.useEffect(()=>{const e=Ft.current;Ft.current=L.userSpeaking,!e&&L.userSpeaking&&(at.current=!1),e&&!L.userSpeaking&&Le.current?.()},[L.userSpeaking]);const Kt=s.useRef(L.state);s.useEffect(()=>{const e=Kt.current;Kt.current=L.state,(L.state==="thinking"||L.state==="speaking")&&!(e==="thinking"||e==="speaking")&&Le.current?.()},[L.state]);const We=s.useRef(null);s.useEffect(()=>{if(!be||!oe)return;const e=ze.current[ze.current.length-1];if(!(!e||!De(e)||e.role!=="assistant"||!e.text.trim()))return We.current&&clearTimeout(We.current),We.current=setTimeout(()=>{gt.current?.()},900),()=>{We.current&&clearTimeout(We.current)}},[pt,be,oe]);const[zt,xs]=s.useState(!1),[ys,Qt]=s.useState(!1),ks=s.useCallback(e=>{nt.current?.sendUserMessage(e)&&Qt(!0)},[]);s.useEffect(()=>{(L.state==="thinking"||L.state==="speaking")&&Qt(!1)},[L.state]);const Ue=be?pt.map(e=>({key:e.id,role:e.role,text:e.text,...e.metadata?{metadata:e.metadata}:{},...e.streaming?{streaming:!0}:{}})):$.map(e=>{const c=e.role==="assistant"&&e.refusalReason?r(`support_chat.refusal_${e.refusalReason}`,{productName:e.refusalProductName??""}):e.text;return c?{key:e.id,role:e.role==="assistant"?"assistant":"user",text:c,confidence:e.confidenceLevel}:null}).filter(e=>e!==null),ws=be&&oe&&Ue.length>0&&Ue[Ue.length-1].role==="user",js=t.jsxs("div",{className:"es-sc__messages",children:[Ue.map((e,c)=>{const u=c===Ue.length-1;return t.jsxs("div",{className:`es-sc__bubble es-sc__bubble--${e.role}`,"data-confidence":e.confidence,children:[e.role==="assistant"?t.jsx(ss,{text:e.text,allowedLinkHosts:me}):t.jsx("div",{className:"es-sc__bubble-text",children:e.text}),e.role==="assistant"&&t.jsx(ns,{followUps:e.metadata?.suggestedFollowUps,isNewest:u,isPending:!!e.streaming,hasQuickReplies:!!e.metadata?.quickReplies?.length,isSending:ys,onSelect:ks,t:r})]},e.key)}),ws?t.jsx("div",{className:"es-vm__answer-pending",role:"status","aria-label":r("voice_conv.thinking"),children:t.jsxs("div",{className:"es-vm__answer-wave",children:[t.jsx("span",{}),t.jsx("span",{}),t.jsx("span",{}),t.jsx("span",{}),t.jsx("span",{})]})}):null]}),Wt=s.useRef(null);s.useEffect(()=>{if(Dt||!Bt||!w||!B)return;const e=$[$.length-1];!e||e.role!=="assistant"||Wt.current!==e.id&&(Wt.current=e.id,w.activate(e.id))},[$,Bt,w,B]);const _t=s.useCallback(()=>{const e=i?.voiceStream;e?.getState&&e.getState()!=="idle"&&e.stop(),ee(te)},[te,ee,i]),Ns=s.useCallback(()=>{ge.current?.abort(),qe(!1);const e=tt.current;e&&P(c=>c.filter(u=>u.id!==e))},[]),Cs=s.useCallback(()=>{Be&&ee(Be.text,Be.options)},[Be,ee]),Ss=s.useCallback(e=>{if(e.autoSend){ee(e.message);return}Ie([]),ae(""),Ne(),G.current&&(G.current.style.height="auto",G.current.focus())},[ee,Ne]);s.useEffect(()=>{if(!(T!==void 0||Z.length>0))return;const e=`${T}${String(z)}${Y}`;if(Et.current!==e){if(Et.current=e,ct.current=!0,z&&T!==void 0){Ie([]),ee(T);return}Ie(Z),T!==void 0&&(ae(T),requestAnimationFrame(()=>{je(),G.current?.focus()}))}},[T,z,Y,ee]),s.useEffect(()=>{const e=i?.voiceStream;e?.getState&&e.getState()!=="idle"&&e.stop()},[x]);const Rs=s.useCallback(e=>{e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),_t())},[_t]),Es=s.useCallback(e=>{Ne(),ae(e.target.value),je()},[je,Ne]),Ts=s.useCallback(()=>{Ne(),ae(""),G.current&&(G.current.style.height="auto",G.current.focus())},[Ne]),Is=s.useCallback(e=>{const c=e.trim();c&&(ae(u=>u?`${u} ${c}`:c),requestAnimationFrame(()=>{je(),G.current?.focus()}))},[je]),Ms=s.useCallback(e=>{a.emit("support-chat:escalated",{messageId:e})},[a]),Jt=s.useRef($);s.useEffect(()=>{Jt.current=$},[$]);const As=s.useCallback(({messageId:e,rating:c},{keepalive:u})=>{const h=Jt.current.find(d=>d.id===e);!h||!h.promptLogId||v.current&&(P(d=>d.map(j=>j.id===e?{...j,rating:c,ratingPending:!0}:j)),(async()=>{const[d,j]=await Te(fetch(`${o}/api/widget/ai-feedback`,{method:"POST",keepalive:u,headers:{"Content-Type":"application/json",...f?{"X-API-Key":f}:{},Authorization:`Bearer ${v.current}`},body:JSON.stringify({promptLogId:h.promptLogId,rating:c})}));if(!j&&d.status===409){P(N=>N.map(C=>C.id===e?{...C,rating:c,ratingPending:!1}:C));return}if(j||!d.ok){P(N=>N.map(C=>C.id===e?{...C,rating:null,ratingPending:!1}:C));return}P(N=>N.map(C=>C.id===e?{...C,rating:c,ratingPending:!1}:C)),a.emit("support-chat:feedbackSubmitted",{messageId:e,rating:c})})())},[a,f,o]),{pending:Xt,rate:Vt,undo:Ps}=Vs({submit:As}),$s=s.useCallback((e,c)=>{const u=$.find(h=>h.id===e);!u||!u.promptLogId||u.ratingPending||v.current&&Vt(e,c)},[$,Vt]),Ls=s.useCallback(()=>{Fe("chat"),ie({kind:"idle"}),Ee.current=null,a.emit("support-chat:clearHistory",void 0)},[a]),Us=s.useCallback(async()=>{if(!X)return;const e=v.current;try{const c=await fetch(`${o}/api/widget/support-chat/handoff/request`,{method:"POST",headers:{"Content-Type":"application/json",...f?{"X-API-Key":f}:{},...e?{Authorization:`Bearer ${e}`}:{}},body:JSON.stringify({sessionId:X,productId:l,conversationLanguage:k})}),u=await c.json();if(!c.ok||!u.success){ie({kind:"idle"});return}if(u.data?.outcome==="unavailable"){ie({kind:"unavailable",reason:Wn(u.data.reason)});return}if(u.data?.outcome==="already_active"){ie(u.data.state==="human"?{kind:"human",displayName:null}:{kind:"waiting",until:Ee.current});return}if(u.data?.outcome==="offered"){const h=u.data.acceptTimeoutSec;Ee.current=typeof h=="number"?Date.now()+h*1e3:null,ie({kind:"waiting",until:Ee.current})}}catch{ie({kind:"idle"})}},[f,o,k,l,X]),Ds=s.useCallback(async e=>{if(!X)return!1;const c=v.current;try{const u=await fetch(`${o}/api/widget/support-chat/handoff/contact`,{method:"POST",headers:{"Content-Type":"application/json",...f?{"X-API-Key":f}:{},...c?{Authorization:`Bearer ${c}`}:{}},body:JSON.stringify({sessionId:X,productId:l,...e.email?{email:e.email}:{},...e.phone?{phone:e.phone}:{},...e.note?{note:e.note}:{}})}),h=await u.json();return!u.ok||!h.success?!1:(ie({kind:"contact_left"}),!0)}catch{return!1}},[f,o,l,X]),Os=s.useCallback(()=>{ie({kind:"idle"})},[]),rt=s.useCallback(()=>{Fe("tickets"),Ge(!0),_e(Ae).then(e=>He(e)).catch(()=>{}).finally(()=>Ge(!1))},[_e,Ae]),qs=s.useCallback(()=>{re==="tickets"?Fe("chat"):rt()},[re,rt]),Bs=s.useCallback(e=>{Fe("chat"),a.emit("support-chat:select-session",{sessionId:e})},[a]);s.useEffect(()=>E?a.on("support-chat:showTickets",()=>{rt()}):void 0,[a,rt,E]);const Hs=s.useCallback((e,c,u)=>{P(j=>j.map(N=>N.id===e?{...N,quickReplyAnswered:c}:N));const h=$.find(j=>j.id===e)?.awaitingConfirmation,d=Hn.includes(u);u==="confirm_handoff"&&ie({kind:"waiting",until:Ee.current}),ee(c,{...d?{quickReplyClick:{payload:u,summary:h?.summary,details:h?.details??void 0,priority:h?.priority,sourceMessageId:e}}:{}})},[$,ee]),Fs=s.useCallback(()=>{a.emit("support-chat:showHistory",void 0)},[a]),Zt=$.length===0;return oe?t.jsx(ts,{blockType:"support-chat",children:t.jsx(Ln,{state:L.state,draft:L.draft,error:L.error,muted:zt,listening:L.userSpeaking,hasTranscript:Ue.length>0,transcript:js,onToggleMute:()=>{const e=!zt;xs(e),nt.current?.setMuted(e)},onEnd:()=>L.stop(),onRetry:()=>{L.start()},t:r})}):t.jsxs(ts,{blockType:"support-chat",children:[t.jsxs("div",{className:"es-sc__chat-header",children:[t.jsx("span",{className:"es-sc__chat-header-title",children:E&&re==="tickets"?r("support_chat.tickets_view_title"):Oe}),t.jsxs("div",{className:"es-sc__chat-header-actions",children:[t.jsx("button",{type:"button",className:"es-sc__chat-action-btn","aria-label":r("support_chat.new_conversation_button"),title:r("support_chat.new_conversation_button"),onClick:Ls,children:t.jsx(qn,{size:18})}),t.jsx("button",{type:"button",className:"es-sc__chat-action-btn","aria-label":r("support_chat.history_button"),title:r("support_chat.history_button"),onClick:Fs,children:t.jsx(On,{size:16})}),he&&re==="chat"&&Rt.kind==="idle"&&t.jsx("button",{type:"button",className:"es-sc__chat-action-btn es-sc__chat-action-btn--label","aria-label":r("support_chat.handoff.button_label"),title:r("support_chat.handoff.button_label"),onClick:()=>{Us()},children:r("support_chat.handoff.button_label")}),E&&t.jsx("button",{type:"button",className:`es-sc__chat-action-btn${re==="tickets"?" es-sc__chat-action-btn--active":""}`,"aria-label":r("support_chat.tickets_tab_button"),title:r("support_chat.tickets_tab_button"),"aria-pressed":re==="tickets",onClick:qs,children:t.jsx(Bn,{size:16})}),t.jsx(Zs,{panelKey:"support-chat",baseUrl:o,apiKey:f||void 0,t:r})]})]}),t.jsx("div",{className:"es-block__body es-sc__body",children:E&&re==="tickets"?t.jsx(un,{status:Ae,loading:gs,tickets:ms,onSelectStatus:vs,onSelectSession:Bs,t:r}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"es-sc__messages",ref:_s,children:[Zt&&t.jsx("div",{className:"es-sc__welcome",children:t.jsx("div",{className:"es-sc__welcome-text",children:H})}),$.map((e,c)=>{const u=c===$.length-1,h=e.role==="assistant"&&e.refusalReason?r(`support_chat.refusal_${e.refusalReason}`,{productName:e.refusalProductName??""}):e.text;return t.jsxs("div",{className:`es-sc__bubble es-sc__bubble--${e.role}`,"data-confidence":e.confidenceLevel,children:[h&&(e.role==="assistant"?t.jsxs(t.Fragment,{children:[t.jsx(ss,{text:h,allowedLinkHosts:me}),t.jsx(on,{text:h,allowEmbeds:ye,allowedImageHosts:me,t:r}),B&&t.jsx(vn,{id:e.id,session:w,onActivate:()=>w.activate(e.id),t:r})]}):t.jsx("div",{className:"es-sc__bubble-text",children:h})),e.isPending&&!e.text&&t.jsxs("div",{className:"es-sc__typing","aria-label":r("support_chat.typing_aria"),children:[t.jsx("span",{className:"es-sc__typing-dot"}),t.jsx("span",{className:"es-sc__typing-dot"}),t.jsx("span",{className:"es-sc__typing-dot"})]}),e.actions&&e.actions.length>0&&t.jsx("div",{className:"es-sc__actions","data-es-no-read":!0,children:e.actions.map(d=>t.jsx("a",{href:Qn(d.url)?d.url:"#",target:"_blank",rel:"noopener noreferrer",className:"es-sc__action-btn",children:d.title},d.slug))}),e.ticketCards&&e.ticketCards.length>0&&t.jsx("div",{className:"es-sc__ticket-cards",children:e.ticketCards.map(d=>t.jsx(us,{card:d,t:r},d.externalNumber))}),e.quickReplies&&e.quickReplies.length>0&&t.jsx("div",{className:"es-sc__quick-replies",children:e.quickReplies.map(d=>{const j=e.quickReplyAnswered===d.value;if(e.quickReplyAnswered!==void 0&&!j)return null;const N=d.payload==="confirm_escalation"?r("escalation.confirm_yes"):d.payload==="cancel_escalation"?r("escalation.confirm_no"):d.payload==="confirm_handoff"?r("support_chat.handoff.confirm_yes"):d.payload==="decline_handoff"?r("support_chat.handoff.confirm_no"):d.label;return t.jsx("button",{type:"button",disabled:j||J,onClick:()=>Hs(e.id,d.value,d.payload??""),className:`es-sc__quick-reply-btn${j?" es-sc__quick-reply-btn--clicked":""}`,children:N},d.value)})}),e.role==="assistant"&&t.jsx(ns,{followUps:e.suggestedFollowUps,isNewest:u,isPending:!!e.isPending,hasQuickReplies:!!e.quickReplies?.length,isSending:J,onSelect:d=>ee(d),t:r}),e.role==="assistant"&&!e.isPending&&e.text&&t.jsxs(t.Fragment,{children:[e.promptLogId&&v.current&&(()=>{const d=Xt?.messageId===e.id?Xt.rating:null;return t.jsxs("div",{className:"es-sc__feedback","aria-label":r("support_chat.rate_aria"),"data-es-no-read":!0,children:[t.jsx("span",{className:"es-sc__feedback-label",children:e.rating&&d===null?r("support_chat.feedback_thanks"):r("support_chat.rate_aria")}),t.jsx(Gn,{value:d??e.rating??null,onChange:j=>$s(e.id,j),disabled:d===null&&(!!e.rating||e.ratingPending),t:r}),d!==null&&t.jsxs("div",{className:"es-sc__rating-undo",role:"status",children:[t.jsx("span",{className:"es-sc__rating-undo-text",children:r("support_chat.rating_undo_toast",{rating:d})}),t.jsx("button",{type:"button",className:"es-sc__rating-undo-btn",onClick:Ps,children:r("support_chat.rating_undo_button")})]})]})})(),e.confidenceLevel==="low"&&t.jsxs("div",{className:"es-sc__escalation",children:[t.jsx("span",{className:"es-sc__escalation-text",children:r("support_chat.low_confidence")}),t.jsx("button",{className:"es-sc__escalation-btn",onClick:()=>Ms(e.id),type:"button","aria-label":fe,children:fe})]})]})]},e.id)}),Nt&&t.jsxs("div",{className:"es-sc__error",role:"alert",children:[t.jsx("span",{className:"es-sc__error-text",children:Nt}),Be&&t.jsx("button",{type:"button",className:"es-sc__error-retry",onClick:Cs,children:r("support_chat.retry")})]})]}),!bs&&$.length>0&&t.jsxs("button",{type:"button",className:"es-sc__jump",onClick:()=>Pe(),"aria-label":r("support_chat.jump_to_latest"),title:r("support_chat.jump_to_latest"),children:[t.jsxs("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M12 5v14"}),t.jsx("path",{d:"m19 12-7 7-7-7"})]}),t.jsx("span",{className:"es-sc__jump-label",children:r("support_chat.jump_to_latest")})]})]})}),re!=="tickets"&&ke.length>0&&t.jsx("div",{className:"es-sc__suggestions",role:"group","aria-label":r("support_chat.quick_actions_aria"),children:ke.map((e,c)=>t.jsx("button",{className:"es-sc__suggestion",onClick:()=>Ss(e),type:"button",disabled:J||_,children:e.labelKey?r(e.labelKey):e.label},`${e.labelKey??e.label}-${c}`))}),re!=="tickets"&&ke.length===0&&Zt&&ue&&ne.length>0&&t.jsx("div",{className:"es-sc__suggestions",role:"list","aria-label":r("support_chat.suggestions_aria"),children:ne.map((e,c)=>t.jsx("button",{className:"es-sc__suggestion",onClick:()=>ee(e),type:"button",role:"listitem",children:e},c))}),re!=="tickets"&&t.jsx(Rn,{status:Rt,onSubmitContact:Ds,onDismissContact:Os,t:r}),re!=="tickets"&&t.jsxs("div",{className:"es-block__footer es-sc__footer",children:[t.jsx("div",{className:"es-sc__disclaimer","data-es-no-read":!0,children:r("support_chat.disclaimer")}),t.jsxs("div",{className:"es-sc__input-row",children:[U&&qt.available&&(be||Dt||A)&&t.jsx("button",{type:"button",className:"es-sc__conv-start","data-testid":"conversation-start","aria-label":r("voice_conv.start"),title:r("voice_conv.start"),onClick:()=>{L.start()},children:t.jsx("svg",{width:"19",height:"19",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:t.jsx("path",{d:"M4 10v4M8 6v12M12 3v18M16 6v12M20 10v4"})})}),t.jsxs("div",{className:"es-sc__textarea-wrap",children:[t.jsx("textarea",{ref:G,className:"es-sc__textarea",value:te,onChange:Es,onKeyDown:Rs,placeholder:Re!=null?r("support_chat.rate_limited_wait",{seconds:String(fs)}):pe,rows:1,maxLength:2e3,disabled:J||_||Me!=null||Re!=null||ot,"aria-label":r("support_chat.input_aria")}),te.length>0&&t.jsx("button",{className:"es-sc__clear",onClick:Ts,disabled:J,type:"button","aria-label":r("support_chat.clear_input_aria"),children:t.jsx("span",{"aria-hidden":"true",children:"✕"})})]}),A&&!_&&t.jsx(hn,{baseUrl:o,apiKey:f,jwt:v.current,language:k,onTranscript:Is,t:r,disabled:J||Me!=null||Re!=null||ot,streaming:b?.streaming,voiceStream:i?.voiceStream,baseText:()=>te,onText:e=>{if(ae(e.length>2e3?e.slice(0,2e3):e),e.length>=2e3){const c=i?.voiceStream;c?.getState&&c.getState()!=="idle"&&c.stop()}requestAnimationFrame(()=>{je(),G.current?.focus()})}}),t.jsx("button",{className:`es-sc__send${J?" es-sc__send--stop":""}`,onClick:J?Ns:_t,disabled:!J&&(_||!te.trim()||Me!=null||Re!=null||ot),type:"button","aria-label":r(J?"support_chat.stop_aria":"chat.send_aria"),children:J?t.jsx("span",{className:"es-sc__stop-icon","aria-hidden":"true"}):t.jsx("span",{"aria-hidden":"true",children:"➤"})})]})]})]})}export{on as AssistantMessageMedia,la as Component,ss as MarkdownBubble,rn as MessageMedia,Ln as VoiceModeView,ca as manifest};
|
|
6
|
-
//# sourceMappingURL=index-xx1GG5d1-CW29F9vY.js.map
|