@nexlylab/widget 1.32.15 → 1.32.16

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.
Files changed (67) hide show
  1. package/dist/INSTALL.txt +1 -1
  2. package/dist/runtime/{1.32.15/chunks/ClickToLoadEmbed-CDdotCS8-W2yBrg7b.js → 1.32.16/chunks/ClickToLoadEmbed-CVZbpoTT-CKUzZ7gL.js} +2 -2
  3. package/dist/runtime/{1.32.15/chunks/PanelInfoVideo-BKn3ucAb-BrU-Qlul.js → 1.32.16/chunks/PanelInfoVideo-BKq2v0QM-BrU-Qlul.js} +1 -1
  4. package/dist/runtime/{1.32.15/chunks/assistant-link-components-MZWf5ty7-C44wlQAi.js → 1.32.16/chunks/assistant-link-components-DkuhHIF9-CPkAMFv6.js} +2 -2
  5. package/dist/runtime/{1.32.15/chunks/assistant-link-policy-DWaWTnGr-Cc-yj-a-.js → 1.32.16/chunks/assistant-link-policy-CS93s-vA-Cc-yj-a-.js} +1 -1
  6. package/dist/runtime/{1.32.15/chunks/block-rating-DH7mp-_R-CoiP5C2K.js → 1.32.16/chunks/block-rating-DGpoz2o3-CoiP5C2K.js} +1 -1
  7. package/dist/runtime/{1.32.15/chunks/external-url-LRu_ntew-CJQjg_od.js → 1.32.16/chunks/external-url-BzUbjdMo-CJQjg_od.js} +1 -1
  8. package/dist/runtime/{1.32.15/chunks/index-C1WD1dlq-Dm9kbc85.js → 1.32.16/chunks/index-6HKNPucI-Dm9kbc85.js} +1 -1
  9. package/dist/runtime/{1.32.15/chunks/index-Bu9Gh6Nc-BfWdQCT7.js → 1.32.16/chunks/index-BCtNBIxP-CcsFQ7Dx.js} +2 -2
  10. package/dist/runtime/{1.32.15/chunks/index-BD-jPdzs-ZRnEJoQe.js → 1.32.16/chunks/index-BIMK2_g0-ZRnEJoQe.js} +1 -1
  11. package/dist/runtime/{1.32.15/chunks/index-BSoCdILD-D6wzHiS0.js → 1.32.16/chunks/index-BJClDxSC-D6wzHiS0.js} +1 -1
  12. package/dist/runtime/{1.32.15/chunks/index-CNJUK2bK-C0OfCXUx.js → 1.32.16/chunks/index-BLT1bBjC-6c5Ar61I.js} +2 -2
  13. package/dist/runtime/{1.32.15/chunks/index-C6_8JGpJ-BqZmEVev.js → 1.32.16/chunks/index-BW-8QNI--BqZmEVev.js} +1 -1
  14. package/dist/runtime/{1.32.15/chunks/index-C75hX_dj-VhJcCfAC.js → 1.32.16/chunks/index-BncytMlP-VhJcCfAC.js} +1 -1
  15. package/dist/runtime/{1.32.15/chunks/index-k-jZV_MQ-H31PHMqm.js → 1.32.16/chunks/index-BoVToqY3-H31PHMqm.js} +1 -1
  16. package/dist/runtime/{1.32.15/chunks/index-B8aKMeg5-BLxOZxZv.js → 1.32.16/chunks/index-C5MpFJwF-BLxOZxZv.js} +1 -1
  17. package/dist/runtime/{1.32.15/chunks/index-Dh0aThiP-Aqz1AnQ5.js → 1.32.16/chunks/index-CISMnUXx-Aqz1AnQ5.js} +1 -1
  18. package/dist/runtime/{1.32.15/chunks/index-Dkv5YXXW-pkywvGDF.js → 1.32.16/chunks/index-CIe60p_E-pkywvGDF.js} +1 -1
  19. package/dist/runtime/{1.32.15/chunks/index-1o6W5wiJ-I68tb-d3.js → 1.32.16/chunks/index-CIgDHLEK-I68tb-d3.js} +1 -1
  20. package/dist/runtime/{1.32.15/chunks/index-DP_6HfDM-DAdxCQyi.js → 1.32.16/chunks/index-CUGV3nk2-DAdxCQyi.js} +1 -1
  21. package/dist/runtime/{1.32.15/chunks/index-DO0-ht8E-DUgMllqN.js → 1.32.16/chunks/index-CbGT4d5Q-DUgMllqN.js} +1 -1
  22. package/dist/runtime/{1.32.15/chunks/index-DTVlG27U-DP0QKkgf.js → 1.32.16/chunks/index-Cdmdsj1E-DP0QKkgf.js} +1 -1
  23. package/dist/runtime/{1.32.15/chunks/index-D-ZhVFzi-A3rpkVmQ.js → 1.32.16/chunks/index-Cf4eQF9g-mnUzfS1e.js} +2 -2
  24. package/dist/runtime/{1.32.15/chunks/index-CMFQhtEe-BcW8HKb8.js → 1.32.16/chunks/index-ChL-bSAN-BcW8HKb8.js} +1 -1
  25. package/dist/runtime/{1.32.15/chunks/index-qpVhJY7A-Cgivx3vY.js → 1.32.16/chunks/index-Chn4ATvZ-CSI6_0RJ.js} +2 -2
  26. package/dist/runtime/{1.32.15/chunks/index-Dt6OpItC-R_xuAEQV.js → 1.32.16/chunks/index-Cmt7uZiE-R_xuAEQV.js} +1 -1
  27. package/dist/runtime/{1.32.15/chunks/index-Czz6Gyh_-C3bBvEcm.js → 1.32.16/chunks/index-CogJkGmU-C3bBvEcm.js} +1 -1
  28. package/dist/runtime/1.32.16/chunks/index-CsoMgZU8-C1BzRUwZ.js +2 -0
  29. package/dist/runtime/{1.32.15/chunks/index-D72orqXX-C_0Ll4qr.js → 1.32.16/chunks/index-Cxwd1OKy-C_0Ll4qr.js} +1 -1
  30. package/dist/runtime/{1.32.15/chunks/index-BylVnv7X-DBhSkJ7i.js → 1.32.16/chunks/index-D-uANagm-DBhSkJ7i.js} +1 -1
  31. package/dist/runtime/{1.32.15/chunks/index-DDEE3QfX-3B-eE3K7.js → 1.32.16/chunks/index-DG-KS4AB-3B-eE3K7.js} +1 -1
  32. package/dist/runtime/{1.32.15/chunks/index-V1EfdiK7-bdo5pwX-.js → 1.32.16/chunks/index-DHdp5nGO-bdo5pwX-.js} +1 -1
  33. package/dist/runtime/{1.32.15/chunks/index-hHQjRGar-TEMHje2B.js → 1.32.16/chunks/index-DL04XhIK-TEMHje2B.js} +1 -1
  34. package/dist/runtime/{1.32.15/chunks/index-IW3aNe-y-W1lJrIDD.js → 1.32.16/chunks/index-DNwWHPWp-W1lJrIDD.js} +1 -1
  35. package/dist/runtime/{1.32.15/chunks/index-D9grn5WJ-Dp5AxBD4.js → 1.32.16/chunks/index-DO5eKOOB-Dp5AxBD4.js} +1 -1
  36. package/dist/runtime/{1.32.15/chunks/index-B9ozeox8-oy07dUaV.js → 1.32.16/chunks/index-Dc8zecP4-oy07dUaV.js} +1 -1
  37. package/dist/runtime/{1.32.15/chunks/index-csHaX5dv-BpgnWlB8.js → 1.32.16/chunks/index-DchTua3m-BpgnWlB8.js} +1 -1
  38. package/dist/runtime/{1.32.15/chunks/index-CmYYEi7N-Dr1V6OGz.js → 1.32.16/chunks/index-DdI8qMqt-Dr1V6OGz.js} +1 -1
  39. package/dist/runtime/{1.32.15/chunks/index-DphwDFW6-C9wFr7fa.js → 1.32.16/chunks/index-Dfcx_9km-C9wFr7fa.js} +1 -1
  40. package/dist/runtime/{1.32.15/chunks/index-Gi-3UOyp-DuzPeEIz.js → 1.32.16/chunks/index-DhYv8bbj-DGasnsaZ.js} +2 -2
  41. package/dist/runtime/{1.32.15/chunks/index-CqV8rHvG-DS9JaGVN.js → 1.32.16/chunks/index-Dtiss_wT-CLkn_6EY.js} +2 -2
  42. package/dist/runtime/{1.32.15/chunks/index-uM4Y0lxc-Dsa9X9U7.js → 1.32.16/chunks/index-MAmLiP1_-Dsa9X9U7.js} +1 -1
  43. package/dist/runtime/{1.32.15/chunks/index-Chy2Zmo5-CiRb-0NX.js → 1.32.16/chunks/index-Or6sA2eF-CiRb-0NX.js} +1 -1
  44. package/dist/runtime/{1.32.15/chunks/index-DPNGQF5b-_M0CWPEY.js → 1.32.16/chunks/index-PSL_6OT1-_M0CWPEY.js} +1 -1
  45. package/dist/runtime/{1.32.15/chunks/index-B1ef1IlE-QeFj7CR9.js → 1.32.16/chunks/index-SgPuWMUv-QeFj7CR9.js} +1 -1
  46. package/dist/runtime/{1.32.15/chunks/index-CwbUW6dx-BLBDoJCM.js → 1.32.16/chunks/index-fotohjEP-BLBDoJCM.js} +1 -1
  47. package/dist/runtime/{1.32.15/chunks/index-BnKOhYKk-CkemNrch.js → 1.32.16/chunks/index-pQ7fPgLl-JdphAk2-.js} +2 -2
  48. package/dist/runtime/{1.32.15/chunks/index-BvlAsO4n-DbuSZfeK.js → 1.32.16/chunks/index-svAzoy0Y-DbuSZfeK.js} +1 -1
  49. package/dist/runtime/{1.32.15/chunks/index-DZKtK9hT-DQBGsPwB.js → 1.32.16/chunks/index-tAu73-sK-DQBGsPwB.js} +1 -1
  50. package/dist/runtime/1.32.16/nexly.js +61 -0
  51. package/dist/v1.js +1 -1
  52. package/package.json +1 -1
  53. package/dist/runtime/1.32.15/chunks/index-BljIlfbh-D9I6jaso.js +0 -2
  54. package/dist/runtime/1.32.15/nexly.js +0 -61
  55. /package/dist/runtime/{1.32.15 → 1.32.16}/chunks/PanelVideoOverlay-BY__oBYV-B8OPC1xh.js +0 -0
  56. /package/dist/runtime/{1.32.15 → 1.32.16}/chunks/_commonjsHelpers-C6fGbg64-BC8KDfbh.js +0 -0
  57. /package/dist/runtime/{1.32.15 → 1.32.16}/chunks/accent-legibility-BJF2VO5n-CDPQ7suO.js +0 -0
  58. /package/dist/runtime/{1.32.15 → 1.32.16}/chunks/allowed-elements-BXnLJV1S-C-_lr2zm.js +0 -0
  59. /package/dist/runtime/{1.32.15 → 1.32.16}/chunks/block-helpers-Cg_zAqG6-DnN2COvk.js +0 -0
  60. /package/dist/runtime/{1.32.15 → 1.32.16}/chunks/index-BPDIV1BN-DINkyYvc.js +0 -0
  61. /package/dist/runtime/{1.32.15 → 1.32.16}/chunks/index-BcsmWDTX-Dw9WA5Ac.js +0 -0
  62. /package/dist/runtime/{1.32.15 → 1.32.16}/chunks/index-C262wwK4-DpyhuXqd.js +0 -0
  63. /package/dist/runtime/{1.32.15 → 1.32.16}/chunks/index-DMQkz1bV-BuMYksln.js +0 -0
  64. /package/dist/runtime/{1.32.15 → 1.32.16}/chunks/index-DZADUAKv-DPfvWVuj.js +0 -0
  65. /package/dist/runtime/{1.32.15 → 1.32.16}/chunks/index.modern-CioVZ357-BA5NTOmY.js +0 -0
  66. /package/dist/runtime/{1.32.15 → 1.32.16}/chunks/inert-assistant-components-B6Cx9pG5-DWb6n3Yq.js +0 -0
  67. /package/dist/runtime/{1.32.15 → 1.32.16}/chunks/use-deferred-rating-XlgCUwcY-DDVOwURi.js +0 -0
@@ -1,2 +1,2 @@
1
1
  import{a as w,r as t,j as e,Q as k}from"../nexly.js";const S={slug:"qa",name:"AI Q&A",version:"1.0.0",category:"interactive",requiredService:"ai-orchestrator",configSchema:{properties:{readAloudEnabled:{type:"boolean",default:!1},placeholder:{type:"string",default:""},maxQuestionsPerSession:{type:"number",default:5},responseLanguage:{type:"string",default:"en"}}},defaultConfig:{readAloudEnabled:!1,placeholder:"",maxQuestionsPerSession:5,responseLanguage:"en"},dataContract:{serviceSlug:"ai-orchestrator",inputSchema:{type:"object",properties:{answer:{type:"string",description:"AI answer to the user question"},question:{type:"string",description:"The question that was asked"}},required:["answer"]},previewDataOverride:{answer:"This product is made from 100% organic cotton and is machine washable. It comes in sizes XS-XXL.",question:"What materials is this made from?"}},fields:[{id:"readAloudEnabled",type:"toggle",label:"Read this panel aloud",default:!1,group:"Voice"},{id:"placeholder",type:"localized-text",label:"Input placeholder",default:"",placeholder:'Leave empty to use translated default (e.g. "Ask a question about this product...")',group:"Content"},{id:"maxQuestionsPerSession",type:"range",label:"Max questions per session",default:5,min:1,max:20,step:1,group:"Behavior"},{id:"responseLanguage",type:"select",label:"Response language",default:"en",options:[{label:"English",value:"en"},{label:"Korean",value:"ko"},{label:"Spanish",value:"es"},{label:"French",value:"fr"},{label:"German",value:"de"}],group:"Behavior"}],events:{emits:[{name:"qa:questionAsked",description:"User submitted a question"},{name:"qa:answerReceived",description:"AI answer received"}],listens:[{name:"qa:clear",description:"Clear Q&A history"}]},sizing:{minWidth:240,preferredHeight:"auto",scrollable:!0},supportedPlacements:["main","sidebar"]};function A({config:u,actions:h,i18n:m}){const s=m?.t??(a=>a),f=m?.currentLanguage??"en",x=w(u.placeholder,f,{t:s,fallbackKey:"qa.input_placeholder",enDefault:"Ask a question about this product..."}),i=u.maxQuestionsPerSession??5,[d,_]=t.useState(""),[o,v]=t.useState([]),[n,g]=t.useState(!1),[q,c]=t.useState(null),b=t.useRef(null),r=o.length>=i,p=t.useCallback(async()=>{const a=d.trim();if(!(!a||n||r)){g(!0),c(null);try{const l=await h.call("ask",{question:a,language:u.responseLanguage??"en"});l?.error?c(l.error):l?.answer?(v(j=>[...j,{question:a,answer:l.answer}]),_(""),setTimeout(()=>{b.current?.scrollIntoView({behavior:"smooth"})},50)):c(s("qa.error_no_answer"))}catch{c(s("qa.error_generic"))}finally{g(!1)}}},[d,n,r,h,u.responseLanguage]),y=t.useCallback(a=>{a.key==="Enter"&&(a.preventDefault(),p())},[p]);return e.jsxs(k,{blockType:"qa",children:[e.jsxs("div",{className:"es-block__body",children:[o.length===0&&!n&&e.jsx("div",{className:"es-block__empty es-qa__empty",children:s("qa.empty_state")}),o.length>0&&e.jsxs("div",{className:"es-qa__history",children:[o.map((a,l)=>e.jsxs("div",{className:"es-qa__entry",children:[e.jsxs("div",{className:"es-qa__question",children:[e.jsx("span",{className:"es-qa__question-label","aria-hidden":"true",children:"Q"}),e.jsx("span",{className:"es-qa__question-text",children:a.question})]}),e.jsxs("div",{className:"es-qa__answer",children:[e.jsx("span",{className:"es-qa__answer-label","aria-hidden":"true",children:"A"}),e.jsx("span",{className:"es-qa__answer-text",children:a.answer})]})]},l)),e.jsx("div",{ref:b})]}),q&&e.jsx("div",{className:"es-qa__error",role:"alert",children:q}),r&&e.jsx("div",{className:"es-qa__limit-notice",children:s("qa.limit_reached",{count:i})})]}),e.jsxs("div",{className:"es-block__footer",children:[e.jsxs("div",{className:"es-qa__input-row",children:[e.jsx("input",{className:"es-qa__input",type:"text",value:d,onChange:a=>_(a.target.value),onKeyDown:y,placeholder:r?s("qa.limit_reached",{count:i}):x,disabled:n||r,"aria-label":s("qa.input_aria_label")}),e.jsx("button",{className:"es-qa__btn",onClick:p,disabled:!d.trim()||n||r,type:"button","aria-label":s("qa.submit_aria_label"),children:s(n?"qa.loading":"qa.ask_button")})]}),i>0&&e.jsx("div",{className:"es-qa__counter",children:s("qa.counter",{used:o.length,max:i})})]})]})}export{A as Component,S as manifest};
2
- //# sourceMappingURL=index-Dh0aThiP-Aqz1AnQ5.js.map
2
+ //# sourceMappingURL=index-CISMnUXx-Aqz1AnQ5.js.map
@@ -1,2 +1,2 @@
1
1
  import{r as d,j as e,Q as n}from"../nexly.js";const M={slug:"presentation-trainer",name:"Presentation Training",version:"1.0.0",category:"interactive",requiredService:"presentation-training",configSchema:{properties:{timeWarningPercent:{type:"number",default:20},showHints:{type:"boolean",default:!0}}},defaultConfig:{timeWarningPercent:20,showHints:!0},dataContract:{serviceSlug:"presentation-training",inputSchema:{type:"object",properties:{scenarios:{type:"array",description:"Live scenarios in the learner’s language, in author order"},remainingToday:{type:"number",description:"Sessions the learner may still start today"},dailyLimit:{type:"number",description:"Configured sessions per user per day"},productBudgetSpent:{type:"boolean",description:"True when the product’s monthly audio budget is exhausted"}}}},sizing:{minWidth:280,preferredHeight:"auto",scrollable:!0},supportedPlacements:["main"]},T={state:"idle",errorKey:null,turns:[],elapsedSec:0,maxSessionSec:0,hint:null,report:null,gradeErrorKey:null};function f(p){return p.trim().split(/\s+/).filter(Boolean).slice(0,2).map(o=>o[0]?.toUpperCase()??"").join("")||"—"}function $(p){const o=Math.floor(p/60),x=p%60;return`${o}:${String(x).padStart(2,"0")}`}function E({data:p,config:o,actions:x,i18n:N}){const t=N?.t??(s=>s),r=x?.externalContext?.trainer,m=p??{},g=d.useMemo(()=>m.scenarios??[],[m.scenarios]),h=m.remainingToday??0,y=m.dailyLimit??0,[u,_]=d.useState(null),[k,l]=d.useState(!1),[a,S]=d.useState(r?.get()??T);d.useEffect(()=>r?.subscribe(S),[r]),d.useEffect(()=>()=>r?.stop(),[r]);const i=g.find(s=>s.id===u)??null,b=a.state==="connecting"||a.state==="speaking"||a.state==="listening",C=Math.max(30,Math.min(60,Math.round(a.maxSessionSec*(o.timeWarningPercent??20)/100))),w=Math.max(0,a.maxSessionSec-a.elapsedSec),v=b&&a.maxSessionSec>0&&w<=C,j=d.useCallback(()=>{u&&r?.start(u)},[u,r]);if(m.productBudgetSpent)return e.jsx(n,{blockType:"presentation-trainer",children:e.jsx("div",{className:"es-pt","data-testid":"pt-budget-spent",children:e.jsx("p",{className:"es-pt__notice es-pt__notice--warn",children:t("training.product_budget_spent")})})});if(g.length===0)return e.jsx(n,{blockType:"presentation-trainer",children:e.jsx("div",{className:"es-pt","data-testid":"pt-empty",children:e.jsx("p",{className:"es-pt__empty",children:t("training.no_scenarios")})})});if(i&&(a.state==="grading"||a.report||a.gradeErrorKey)){if(a.state==="grading")return e.jsx(n,{blockType:"presentation-trainer",children:e.jsx("div",{className:"es-pt","data-testid":"pt-grading",children:e.jsx("p",{className:"es-pt__muted",children:t("training.grading")})})});if(!a.report)return e.jsx(n,{blockType:"presentation-trainer",children:e.jsxs("div",{className:"es-pt","data-testid":"pt-grade-failed",children:[e.jsx("p",{className:"es-pt__notice es-pt__notice--warn",children:t(`training.grade_${a.gradeErrorKey??"grader_failed"}`)}),e.jsx("button",{type:"button",className:"es-pt__cta es-pt__cta--ghost",onClick:()=>{l(!1),_(null)},children:t("training.back_to_list")})]})});const s=a.report;return e.jsx(n,{blockType:"presentation-trainer",children:e.jsxs("div",{className:"es-pt","data-testid":"pt-report",children:[e.jsxs("div",{className:"es-pt__score",children:[e.jsxs("span",{className:`es-pt__score-value${s.passed?"":" es-pt__score-value--fail"}`,"data-testid":"pt-score",children:[s.totalScore,"%"]}),e.jsx("span",{className:"es-pt__muted",children:s.passed?t("training.passed",{threshold:s.passThreshold}):t("training.not_passed",{threshold:s.passThreshold})})]}),s.feedback&&e.jsxs("div",{className:"es-pt__feedback","data-testid":"pt-feedback",children:[e.jsx("span",{className:"es-pt__turn-who",children:t("training.to_improve")}),s.feedback.headline,s.feedback.quote&&e.jsx("q",{className:"es-pt__quote",children:s.feedback.quote})]}),e.jsx("div",{className:"es-pt__criteria",children:s.criteria.map(c=>e.jsxs("div",{className:"es-pt__criterion",children:[e.jsxs("div",{className:"es-pt__criterion-row",children:[e.jsx("span",{className:"es-pt__criterion-label",children:c.label}),e.jsxs("span",{className:"es-pt__criterion-score",children:[c.score,"/4"]})]}),e.jsx("p",{className:"es-pt__muted",children:c.rationale}),c.quote&&e.jsx("q",{className:"es-pt__quote",children:c.quote})]},c.key))}),s.delivery&&e.jsxs("div",{className:"es-pt__delivery","data-testid":"pt-delivery",children:[e.jsx("span",{className:"es-pt__turn-who",children:t("training.how_you_spoke")}),e.jsxs("div",{className:"es-pt__delivery-grid",children:[e.jsxs("div",{children:[e.jsx("span",{children:t("training.longest_monologue")}),e.jsxs("b",{children:[s.delivery.longestMonologueSec,"s"]})]}),e.jsxs("div",{children:[e.jsx("span",{children:t("training.talk_share")}),e.jsxs("b",{children:[s.delivery.talkSharePercent,"%"]})]}),e.jsxs("div",{children:[e.jsx("span",{children:t("training.response_delay")}),e.jsxs("b",{children:[s.delivery.medianResponseDelaySec,"s"]})]}),e.jsxs("div",{children:[e.jsx("span",{children:t("training.exchanges")}),e.jsx("b",{children:s.delivery.exchanges})]}),e.jsxs("div",{children:[e.jsx("span",{children:t(`training.rate_${s.delivery.rateUnit}`)}),e.jsx("b",{children:s.delivery.rate})]})]})]}),e.jsx("button",{type:"button",className:"es-pt__cta",onClick:j,"data-testid":"pt-retry",children:t("training.try_again")}),e.jsx("button",{type:"button",className:"es-pt__cta es-pt__cta--ghost",onClick:()=>{l(!1),_(null)},children:t("training.back_to_list")})]})})}if(i&&(b||a.state==="ending"||a.state==="error"||a.state==="closed"))return a.state==="error"?e.jsx(n,{blockType:"presentation-trainer",children:e.jsxs("div",{className:"es-pt","data-testid":"pt-error",children:[e.jsx("p",{className:"es-pt__notice es-pt__notice--bad",children:t(`training.error_${a.errorKey??"generic"}`)}),e.jsx("button",{type:"button",className:"es-pt__cta",onClick:j,children:t("training.try_again")}),e.jsx("button",{type:"button",className:"es-pt__cta es-pt__cta--ghost",onClick:()=>{l(!1),_(null)},children:t("training.back_to_list")})]})}):e.jsx(n,{blockType:"presentation-trainer",children:e.jsxs("div",{className:"es-pt","data-testid":"pt-conversation",children:[e.jsxs("div",{className:"es-pt__strip",children:[e.jsx("div",{className:`es-pt__avatar${a.state==="speaking"?" es-pt__avatar--speaking":""}`,"aria-hidden":"true",children:f(i.personaName)}),e.jsxs("div",{className:"es-pt__strip-meta",children:[e.jsx("div",{className:"es-pt__strip-name",children:i.personaName}),e.jsxs("div",{className:"es-pt__strip-state",children:[a.state==="connecting"&&t("training.state_connecting"),a.state==="speaking"&&t("training.state_speaking"),a.state==="listening"&&t("training.state_listening"),a.state==="ending"&&t("training.state_ending"),a.state==="closed"&&t("training.state_closed")]})]})]}),e.jsx("div",{className:"es-pt__transcript","data-testid":"pt-transcript","aria-live":"polite",children:a.turns.length===0?e.jsx("p",{className:"es-pt__muted",children:t("training.transcript_empty")}):a.turns.map((s,c)=>e.jsxs("div",{className:`es-pt__turn es-pt__turn--${s.role}${s.final?"":" es-pt__turn--live"}`,children:[e.jsx("span",{className:"es-pt__turn-who",children:s.role==="persona"?i.personaName:t("training.you")}),s.text]},c))}),o.showHints!==!1&&a.hint&&e.jsx("p",{className:"es-pt__hint","data-testid":"pt-hint",children:a.hint}),v&&!a.hint&&e.jsx("p",{className:"es-pt__hint","data-testid":"pt-time-warning",children:t("training.time_almost_up")}),e.jsxs("div",{className:"es-pt__controls",children:[e.jsx("span",{className:`es-pt__timer${v?" es-pt__timer--warn":""}`,"data-testid":"pt-timer",children:$(a.elapsedSec)}),a.state==="closed"?e.jsx("button",{type:"button",className:"es-pt__cta es-pt__cta--ghost",onClick:()=>{l(!1),_(null)},children:t("training.back_to_list")}):e.jsx("button",{type:"button",className:"es-pt__end",onClick:()=>r?.stop(),children:t("training.end_conversation")})]})]})});if(i&&k)return e.jsx(n,{blockType:"presentation-trainer",children:e.jsxs("div",{className:"es-pt","data-testid":"pt-history",children:[e.jsxs("div",{className:"es-pt__strip",children:[e.jsx("button",{type:"button",className:"es-pt__back",onClick:()=>l(!1),"aria-label":t("training.back"),children:"←"}),e.jsxs("div",{className:"es-pt__strip-meta",children:[e.jsx("div",{className:"es-pt__strip-name",children:t("training.your_attempts")}),e.jsx("div",{className:"es-pt__strip-state",children:i.title})]})]}),i.history.length===0?e.jsx("p",{className:"es-pt__muted",children:t("training.no_attempts_yet")}):e.jsx("ul",{className:"es-pt__attempts",children:i.history.map(s=>e.jsxs("li",{className:"es-pt__attempt",children:[e.jsx("span",{className:"es-pt__attempt-date",children:new Intl.DateTimeFormat(N?.currentLanguage??"en",{day:"numeric",month:"short"}).format(new Date(s.at))}),e.jsx("span",{className:"es-pt__attempt-score",children:s.score===null?t("training.not_scored"):`${s.score}%`}),s.status!=="completed"&&e.jsx("span",{className:"es-pt__pill",children:t(`training.status_${s.status}`)})]},s.sessionId))})]})});if(i){const s=h<=0;return e.jsx(n,{blockType:"presentation-trainer",children:e.jsxs("div",{className:"es-pt","data-testid":"pt-brief",children:[e.jsxs("div",{className:"es-pt__strip",children:[e.jsx("button",{type:"button",className:"es-pt__back",onClick:()=>{l(!1),_(null)},"aria-label":t("training.back_to_list"),children:"←"}),e.jsx("div",{className:"es-pt__avatar","aria-hidden":"true",children:f(i.personaName)}),e.jsxs("div",{className:"es-pt__strip-meta",children:[e.jsx("div",{className:"es-pt__strip-name",children:i.personaName}),e.jsx("div",{className:"es-pt__strip-state",children:i.title})]}),e.jsxs("div",{className:"es-pt__strip-right",children:[e.jsx("span",{className:`es-pt__pill es-pt__pill--${i.difficulty}`,children:t(`training.difficulty_${i.difficulty}`)}),e.jsx("span",{className:"es-pt__strip-time",children:t("training.minutes",{count:Math.round(i.maxDurationSec/60)})})]})]}),e.jsx("div",{className:"es-pt__situation",children:i.situation}),e.jsx("p",{className:"es-pt__muted",children:t("training.sessions_left",{count:h,total:y})}),s?e.jsx("p",{className:"es-pt__notice es-pt__notice--warn",children:t("training.daily_limit_reached")}):e.jsx("button",{type:"button",className:"es-pt__cta",onClick:j,"data-testid":"pt-start",children:t("training.start_conversation")}),i.attempts>0&&e.jsx("button",{type:"button",className:"es-pt__cta es-pt__cta--ghost",onClick:()=>l(!0),"data-testid":"pt-history-open",children:t("training.see_attempts",{count:i.attempts})})]})})}return e.jsx(n,{blockType:"presentation-trainer",children:e.jsxs("div",{className:"es-pt","data-testid":"pt-list",children:[e.jsxs("div",{className:"es-pt__quota",children:[e.jsx("span",{children:t("training.sessions_today")}),e.jsx("b",{children:t("training.sessions_left_short",{count:h,total:y})})]}),g.map(s=>e.jsxs("button",{type:"button",className:"es-pt__scenario",onClick:()=>_(s.id),disabled:h<=0,children:[e.jsxs("span",{className:"es-pt__scenario-row",children:[e.jsx("span",{className:"es-pt__scenario-title",children:s.title}),e.jsx("span",{className:`es-pt__pill es-pt__pill--${s.difficulty}`,children:t(`training.difficulty_${s.difficulty}`)})]}),e.jsxs("span",{className:"es-pt__scenario-meta",children:[t("training.minutes",{count:Math.round(s.maxDurationSec/60)}),s.attempts>0&&e.jsxs(e.Fragment,{children:[" · ",t("training.best_score",{score:s.bestScore??0})," · ",t("training.last_score",{score:s.lastScore??0})," · ",t("training.attempts",{count:s.attempts})]}),s.attempts===0&&e.jsxs(e.Fragment,{children:[" · ",t("training.not_attempted")]})]})]},s.id)),h<=0&&e.jsx("p",{className:"es-pt__notice es-pt__notice--warn",children:t("training.daily_limit_reached")})]})})}export{E as Component,M as manifest};
2
- //# sourceMappingURL=index-Dkv5YXXW-pkywvGDF.js.map
2
+ //# sourceMappingURL=index-CIe60p_E-pkywvGDF.js.map
@@ -1,2 +1,2 @@
1
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-1o6W5wiJ-I68tb-d3.js.map
2
+ //# sourceMappingURL=index-CIgDHLEK-I68tb-d3.js.map
@@ -1,2 +1,2 @@
1
1
  import{j as e,Q as u}from"../nexly.js";const y={slug:"demo-shipping-returns",name:"DEMO — Contact details",version:"0.1.0",category:"content",configSchema:{properties:{rows:{type:"array",items:{type:"object",properties:{label:{type:"string"},value:{type:"string"},note:{type:"string"}},required:["label","value"]},default:[]}}},defaultConfig:{rows:[]},sizing:{minWidth:240,preferredHeight:"auto",scrollable:!1},supportedPlacements:["main","sidebar"]};function _(t){return Array.isArray(t)?t.flatMap(s=>{if(typeof s!="object"||s===null)return[];const n=s,d=typeof n.label=="string"?n.label.trim():"",a=typeof n.value=="string"?n.value.trim():"";if(!d||!a)return[];const c=typeof n.note=="string"?n.note.trim():"";return[{label:d,value:a,...c?{note:c}:{}}]}):[]}function i(t){if(typeof t!="string")return null;const s=t.trim();return s.length>0?s:null}function x(t){const s=i(t);if(!s||/\s/.test(s))return null;const n=s.indexOf("@");return n>0&&n<s.length-1?s:null}function j(t){const s=i(t);return!s||!/[0-9]/.test(s)?null:s}function f(t){return t.split(/\s+/).filter(s=>/[\p{L}\p{N}]/u.test(s)).slice(0,2).map(s=>s[0].toUpperCase()).join("")}function v({data:t,config:s,i18n:n}){const d=n?.t??(o=>o),a=t?.rows?t:s??{},c=_(a.rows),m=i(a.company),p=i(a.tagline),r=x(a.email),l=j(a.phone),h=i(a.note);return!m&&!r&&!l&&c.length===0?e.jsx(u,{blockType:"demo-shipping-returns",children:e.jsx("div",{className:"es-block__body",children:e.jsx("div",{className:"es-block__empty",children:d("demoTerms.empty")})})}):e.jsx(u,{blockType:"demo-shipping-returns",children:e.jsxs("div",{className:"es-block__body es-democontact",children:[e.jsxs("div",{className:"es-democontact__card",children:[m&&e.jsxs("div",{className:"es-democontact__identity",children:[e.jsx("div",{className:"es-democontact__coin","aria-hidden":"true",children:f(m)}),e.jsxs("div",{className:"es-democontact__names",children:[e.jsx("p",{className:"es-democontact__company",children:m}),p&&e.jsx("p",{className:"es-democontact__tagline",children:p})]})]}),c.length>0&&e.jsx("dl",{className:"es-democontact__grid",children:c.map(o=>e.jsxs("div",{className:"es-democontact__cell",children:[e.jsx("dt",{className:"es-democontact__label",children:o.label}),e.jsx("dd",{className:"es-democontact__value",children:o.value}),o.note&&e.jsx("dd",{className:"es-democontact__note",children:o.note})]},o.label))}),(r||l)&&e.jsxs("div",{className:"es-democontact__actions",children:[r&&e.jsxs("a",{className:"es-democontact__action",href:`mailto:${r}`,children:[e.jsxs("svg",{className:"es-democontact__glyph",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("rect",{x:"2.5",y:"4.5",width:"19",height:"15",rx:"2.5"}),e.jsx("path",{d:"M3 7l9 6 9-6"})]}),e.jsx("span",{className:"es-democontact__action-text",children:r})]}),l&&e.jsxs("a",{className:"es-democontact__action",href:`tel:${l.replace(/\s+/g,"")}`,children:[e.jsx("svg",{className:"es-democontact__glyph",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M6.5 3.5h3l1.5 4-2 1.5a11 11 0 006 6l1.5-2 4 1.5v3a2 2 0 01-2.2 2A17 17 0 014.5 5.7 2 2 0 016.5 3.5z"})}),e.jsx("span",{className:"es-democontact__action-text",children:l})]})]})]}),h&&e.jsxs("div",{className:"es-democontact__reassurance",children:[e.jsxs("svg",{className:"es-democontact__glyph",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M12 3l7.5 3v5.5c0 4.6-3.1 8.4-7.5 9.5-4.4-1.1-7.5-4.9-7.5-9.5V6z"}),e.jsx("path",{d:"M9 12.2l2.2 2.2 4-4.2"})]}),e.jsx("p",{className:"es-democontact__reassurance-text",children:h})]})]})})}export{v as Component,y as manifest};
2
- //# sourceMappingURL=index-DP_6HfDM-DAdxCQyi.js.map
2
+ //# sourceMappingURL=index-CUGV3nk2-DAdxCQyi.js.map
@@ -1,2 +1,2 @@
1
1
  import{r as i,j as e,Q as m}from"../nexly.js";const f={slug:"faq",name:"FAQ",version:"1.0.0",category:"content",requiredService:"knowledge-search",configSchema:{properties:{readAloudEnabled:{type:"boolean",default:!1},limit:{type:"number",default:10}}},defaultConfig:{readAloudEnabled:!1,limit:10},dataContract:{serviceSlug:"knowledge-search",inputSchema:{type:"object",properties:{items:{type:"array",items:{type:"object",properties:{question:{type:"string"},answer:{type:"string"},category:{type:"string"}}}},total:{type:"number"}},required:["items"]},previewDataOverride:{items:[{question:"What is your return policy?",answer:"We accept returns within 30 days of purchase.",category:"Returns"},{question:"How long does shipping take?",answer:"Standard shipping takes 3-5 business days.",category:"Shipping"},{question:"Do you offer international shipping?",answer:"Yes, we ship to over 50 countries worldwide.",category:"Shipping"},{question:"How do I track my order?",answer:"You will receive a tracking link via email once your order ships.",category:"Orders"},{question:"Can I change or cancel my order?",answer:"Orders can be modified or cancelled within 1 hour of placement.",category:"Orders"}],total:5}},fields:[{id:"readAloudEnabled",type:"toggle",label:"Read this panel aloud",default:!1,group:"Voice"},{id:"limit",type:"range",label:"Number of FAQs",default:10,min:1,max:50,step:1,group:"Content"}],events:{emits:[{name:"faq:itemExpanded",description:"User expanded a FAQ item"},{name:"faq:itemCollapsed",description:"User collapsed a FAQ item"}],listens:[{name:"faq:refresh",description:"Reload FAQ content from service"}]},sizing:{minWidth:240,preferredHeight:"auto",scrollable:!1},supportedPlacements:["main","sidebar"]};function g({data:n,config:o,i18n:l}){const d=l?.t??(a=>a),t=n.items??o.items??[],[r,c]=i.useState(null),p=i.useCallback(a=>{c(s=>s===a?null:a)},[]);return e.jsx(m,{blockType:"faq",children:e.jsxs("div",{className:"es-block__body",children:[t.length===0&&e.jsx("div",{className:"es-block__empty",children:d("faq.empty")}),t.map((a,s)=>e.jsxs("div",{className:"es-faq__item",children:[e.jsxs("button",{className:"es-faq__question",onClick:()=>p(s),type:"button",children:[e.jsx("span",{children:a.question}),e.jsx("span",{className:"es-faq__chevron",children:r===s?"▲":"▼"})]}),r===s&&e.jsx("div",{className:"es-faq__answer",children:a.answer})]},s))]})})}export{g as Component,f as manifest};
2
- //# sourceMappingURL=index-DO0-ht8E-DUgMllqN.js.map
2
+ //# sourceMappingURL=index-CbGT4d5Q-DUgMllqN.js.map
@@ -1,2 +1,2 @@
1
1
  import{r as S,j as e,Q as _,o as C}from"../nexly.js";const D={slug:"new-member-onboarding-tracker",name:"New Member Onboarding Tracker",version:"1.0.0",category:"interactive",requiredService:"new-member-onboarding-tracker",configSchema:{properties:{mode:{type:"string",default:"basic"},showStreak:{type:"boolean",default:!0}}},defaultConfig:{mode:"basic",showStreak:!0},sizing:{minWidth:280,preferredHeight:"auto",scrollable:!0},supportedPlacements:["main","sidebar"],dataContract:{serviceSlug:"new-member-onboarding-tracker",inputSchema:{type:"object",properties:{steps:{type:"array",items:{type:"object",properties:{id:{type:"string"},label:{type:"string"},completed:{type:"boolean"},timeEstimate:{type:"string"}}}},completedCount:{type:"number"},totalCount:{type:"number"},daysSinceJoin:{type:"number"},aiMessage:{type:"string"},streak:{type:"number"},mode:{type:"string",enum:["basic","pro"]}}},previewDataOverride:{mode:"pro",daysSinceJoin:2,completedCount:2,totalCount:6,streak:3,aiMessage:"Great progress! Setting up your profile is key — it helps your upline and new contacts understand your focus area. Takes about 5 minutes.",steps:[{id:"1",label:"Watch welcome video",completed:!0,timeEstimate:"5 min"},{id:"2",label:"Complete your profile",completed:!0,timeEstimate:"10 min"},{id:"3",label:"Join the team chat group",completed:!1,timeEstimate:"2 min"},{id:"4",label:"Schedule your first 1-on-1 with upline",completed:!1,timeEstimate:"5 min"},{id:"5",label:"Place your first personal purchase",completed:!1,timeEstimate:"15 min"},{id:"6",label:"Share your first product post",completed:!1,timeEstimate:"10 min"}]}},fields:[{id:"mode",type:"select",label:"Display mode",default:"basic",options:[{label:"Basic — checklist + next action",value:"basic"},{label:"Pro — guided steps with AI coaching",value:"pro"}],group:"Display"},{id:"showStreak",type:"toggle",label:"Show streak counter (pro mode)",default:!0,group:"Display"}],events:{emits:[{name:"nmot:stepFocused",description:"User focused a step in pro mode"},{name:"nmot:stepCompleted",description:"User marked a step as done"}],listens:[{name:"nmot:refresh",description:"Force refresh onboarding step data"}]}};function J({data:t,config:b,actions:d,metadata:u,i18n:f}){const a=f?.t??(s=>s),o=b.mode??t.mode??"basic",v=b.showStreak??!0,n=t.steps??[],m=t.completedCount??n.filter(s=>s.completed).length,i=t.totalCount??n.length,g=t.daysSinceJoin??0,h=t.aiMessage,x=t.streak??0,[y,j]=S.useState(()=>n.find(s=>!s.completed)?.id??null);if(n.length===0&&!t.error)return e.jsx(_,{blockType:"new-member-onboarding-tracker",children:e.jsxs("div",{className:"es-block__body es-nmot__body",children:[e.jsx("div",{className:"es-nmot__header",children:e.jsx("div",{className:"es-nmot__day-badge",children:a("onboarding.day_badge",{n:1})})}),e.jsxs("div",{className:"es-nmot__progress-wrap",children:[e.jsxs("div",{className:"es-nmot__progress-label",children:[e.jsx("span",{children:u?.dataQuality==="none"?a("onboarding.signin_prompt"):a("onboarding.getting_started")}),e.jsx("span",{children:"0/0"})]}),e.jsx("div",{className:"es-nmot__progress-bar",role:"progressbar","aria-valuenow":0,"aria-valuemin":0,"aria-valuemax":100,children:e.jsx("div",{className:"es-nmot__progress-fill",style:{width:"0%"}})})]}),e.jsx("p",{style:{fontSize:13,color:"var(--es-color-on-surface-muted, #4B5563)",margin:"8px 0 0"},children:u?.dataQuality==="none"?a("onboarding.signin_steps_hint"):a("onboarding.empty")})]})});if(t.error)return e.jsx(_,{blockType:"new-member-onboarding-tracker",error:C(t.error)});const c=i>0?Math.round(m/i*100):0,l=m>=i;n.find(s=>s.id===y);function N(s){o==="pro"&&(j(s.id),d.emit("nmot:stepFocused",{stepId:s.id}))}function k(s){d.call("completeStep",{stepId:s}).catch(()=>{}),d.emit("nmot:stepCompleted",{stepId:s});const p=n.find(r=>!r.completed&&r.id!==s);j(p?.id??null)}return e.jsx(_,{blockType:"new-member-onboarding-tracker",children:e.jsxs("div",{className:"es-block__body es-nmot__body",children:[e.jsxs("div",{className:"es-nmot__header",children:[e.jsx("div",{className:"es-nmot__day-badge",children:a("onboarding.day_badge",{n:g+1})}),o==="pro"&&v&&x>0&&e.jsxs("div",{className:"es-nmot__streak",children:[e.jsx("span",{className:"es-nmot__streak-icon","aria-hidden":"true",children:"🔥"}),e.jsx("span",{className:"es-nmot__streak-count",children:x}),e.jsx("span",{className:"es-nmot__streak-label",children:a("onboarding.day_streak")})]})]}),e.jsxs("div",{className:"es-nmot__progress-wrap",children:[e.jsxs("div",{className:"es-nmot__progress-label",children:[e.jsx("span",{children:a(l?"onboarding.complete":"onboarding.getting_started")}),e.jsxs("span",{children:[m,"/",i]})]}),e.jsx("div",{className:"es-nmot__progress-bar",role:"progressbar","aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a("onboarding.progress_aria",{percent:c}),children:e.jsx("div",{className:`es-nmot__progress-fill${l?" es-nmot__progress-fill--done":""}`,style:{width:`${c}%`}})})]}),e.jsx("ul",{className:"es-nmot__steps",role:"list",children:n.map((s,p)=>{const r=o==="pro"&&s.id===y,w=["es-nmot__step",s.completed?"es-nmot__step--done":"",r?"es-nmot__step--active":""].filter(Boolean).join(" ");return e.jsxs("li",{className:w,children:[e.jsxs("button",{className:"es-nmot__step-row",onClick:()=>N(s),"aria-current":r?"step":void 0,disabled:o==="basic",children:[e.jsx("span",{className:"es-nmot__step-check","aria-hidden":"true",children:s.completed?"✓":e.jsx("span",{className:"es-nmot__step-num",children:p+1})}),e.jsx("span",{className:"es-nmot__step-label",children:s.label}),s.timeEstimate&&e.jsx("span",{className:"es-nmot__step-time",children:s.timeEstimate})]}),o==="pro"&&r&&!s.completed&&e.jsxs("div",{className:"es-nmot__step-detail",children:[h&&e.jsxs("div",{className:"es-nmot__ai-message",children:[e.jsx("span",{className:"es-nmot__ai-label",children:a("onboarding.ai_coach_label")}),e.jsx("p",{className:"es-nmot__ai-text",children:h})]}),e.jsx("button",{className:"es-nmot__complete-btn",onClick:()=>k(s.id),children:a("onboarding.mark_done")})]})]},s.id)})}),o==="basic"&&!l&&e.jsxs("div",{className:"es-nmot__next-prompt",children:[e.jsx("span",{className:"es-nmot__next-label",children:a("onboarding.next_up")}),e.jsx("span",{className:"es-nmot__next-text",children:n.find(s=>!s.completed)?.label??a("onboarding.all_steps_complete")})]}),l&&e.jsxs("div",{className:"es-nmot__done-banner",children:[e.jsx("span",{className:"es-nmot__done-icon","aria-hidden":"true",children:"🎉"}),e.jsx("span",{children:a("onboarding.done_banner",{n:g+1})})]})]})})}export{J as Component,D as manifest};
2
- //# sourceMappingURL=index-DTVlG27U-DP0QKkgf.js.map
2
+ //# sourceMappingURL=index-Cdmdsj1E-DP0QKkgf.js.map
@@ -1,6 +1,6 @@
1
- import{r as s,j as t,a as kt,b as Te,Q as ts,_ as Ws,t as Xs}from"../nexly.js";import{H as Js,P as Vs}from"./use-deferred-rating-XlgCUwcY-DDVOwURi.js";import{j as Ys}from"./PanelInfoVideo-BKn3ucAb-BrU-Qlul.js";import{x as Zs,s as Gs,c as en,a as tn}from"./allowed-elements-BXnLJV1S-C-_lr2zm.js";import{f as sn}from"./assistant-link-components-MZWf5ty7-C44wlQAi.js";import{j as nn,X as an}from"./ClickToLoadEmbed-CDdotCS8-W2yBrg7b.js";import"./_commonjsHelpers-C6fGbg64-BC8KDfbh.js";import"./assistant-link-policy-DWaWTnGr-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(Zs,{remarkPlugins:[...en],allowedElements:[...Gs],transformLinkUri:o=>tn(o)??"",transformImageUri:()=>"",components:{input:({node:o,type:i,checked:l,...f})=>i==="checkbox"?t.jsx("input",{...f,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),f=s.useMemo(()=>nn(n,{allowEmbeds:a,allowedImageHosts:o}),[n,a,l]);return t.jsx(rn,{media:f,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 f=Math.round(l/24);return a("time.days_ago",{count:f})}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:f,t:v}=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:v(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:v("support_chat.tickets_empty")}):i.map(m=>t.jsx(us,{card:m,t:v,onSelect:f},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:f,disabled:v=!1,streaming:m,voiceStream:g,baseText:b,onText:r}){const[p]=s.useState(pn),[_,k]=s.useState("idle"),[w,E]=s.useState(null),[U,H]=s.useState("idle"),x=!!(m&&g&&b&&r),T=s.useRef(null),ee=s.useRef(null),X=s.useRef([]),J=s.useRef(!0);s.useEffect(()=>()=>{J.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(()=>{ee.current?.getTracks().forEach(I=>I.stop()),ee.current=null,T.current=null,X.current=[]},[]);s.useEffect(()=>le,[le]);const R=s.useRef(()=>{});R.current=()=>{x&&(U==="connecting"||U==="listening")&&g?.stop()},s.useEffect(()=>()=>R.current(),[]);const O=s.useCallback(async I=>{const{baseUrl:F,apiKey:V,jwt:Y,language:$,onTranscript:P}=ce.current,te=new FormData;te.append("audio",I,"recording.webm"),te.append("language",$);const ae={};V&&(ae["X-API-Key"]=V),Y&&(ae.Authorization=`Bearer ${Y}`);const ke=await fetch(`${F}/api/widget/transcribe`,{method:"POST",headers:ae,credentials:"include",body:te});if(!ke.ok){const Q=new Error(`HTTP ${ke.status}`);throw Q.status=ke.status,Q}const Ie=await ke.json();P(Ie.text??"")},[]),pe=s.useCallback(async()=>{E(null);let I;try{I=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{k("error"),E("voice.permission_denied");return}const F=fn();let V;try{V=F?new MediaRecorder(I,{mimeType:F}):new MediaRecorder(I)}catch{I.getTracks().forEach(Y=>Y.stop()),k("error"),E("voice.error_generic");return}ee.current=I,T.current=V,X.current=[],V.ondataavailable=Y=>{Y.data&&Y.data.size>0&&X.current.push(Y.data)},V.onstop=async()=>{const Y=V.mimeType||F||"audio/webm",$=new Blob(X.current,{type:Y});if(le(),$.size===0){k("idle");return}k("transcribing");try{if(await O($),!J.current)return;k("idle"),E(null)}catch(P){if(!J.current)return;const te=P.status;k("error"),E(te===413?"voice.error_too_large":"voice.error_generic")}},V.start(),k("recording")},[le,O]),ue=s.useCallback(()=>{const I=T.current;I&&I.state!=="inactive"?I.stop():(le(),k("idle"))},[le]),ne=s.useCallback(()=>{p&&(x?U==="connecting"||U==="listening"?(g.stop(),H("idle")):(E(null),g.start({language:i,baseText:b,onText:r,onState:I=>H(I),onError:I=>{E(I),H("error")}})):_==="recording"?ue():(_==="idle"||_==="error")&&pe())},[p,x,U,_,i,b,r,g,pe,ue]);if(!p)return null;const fe=x?U==="connecting"||U==="listening":_==="recording",he=!x&&_==="transcribing",Oe=x?U==="error":_==="error",xe=f(fe?"voice.stop":"voice.start"),me=w?f(w):he?f("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||v,"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",f=s.useCallback(()=>{if(l==="idle"||l==="error"){o();return}l!=="loading"&&a.togglePause()},[l,o,a]),v=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:f,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:v,"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,f={ended:new Set},v=g=>{for(const b of[...f[g]])b()},m=g=>{g.onended=null,Xs(()=>g.stop())};return{push(g){const b=new Uint8Array(g);let r;i&&i.length>0?(r=new Uint8Array(i.length+b.length),r.set(i,0),r.set(b,i.length),i=null):r=b;const p=r.length-r.length%2;if(p<r.length&&(i=r.slice(p)),p===0)return;const _=new Int16Array(r.buffer,r.byteOffset,p/2);if(_.length===0)return;a??(a=new AudioContext({sampleRate:n}));const k=a.createBuffer(1,_.length,n);k.getChannelData(0).set(Float32Array.from(_,U=>U/32768));const w=a.createBufferSource();w.buffer=k,w.connect(a.destination),w.onended=()=>{l.delete(w),l.size===0&&v("ended")},l.add(w);const E=Math.max(a.currentTime,o);w.start(E),o=E+k.duration},reset(){for(const g of[...l])m(g);l.clear(),o=0,i=null},pause(){a?.suspend()},resume(){a?.resume()},on(g,b){return f[g].add(b),()=>{f[g].delete(b)}},close(){for(const g of[...l])m(g);l.clear(),a?.close(),a=null,o=0,f.ended.clear()}}}function yn({baseUrl:n,apiKey:a,getJwt:o}){const[i,l]=s.useState(null),[f,v]=s.useState("idle"),m=s.useRef(null),g=s.useRef(null),b=s.useRef([]),r=s.useRef(!1),p=s.useRef(!1),_=s.useRef(!1),k=s.useRef(0),w=s.useRef(null),E=s.useRef(null),U=s.useCallback(()=>{E.current&&(clearTimeout(E.current),E.current=null)},[]),H=s.useCallback(()=>{w.current?.abort(),w.current=null,E.current&&(clearTimeout(E.current),E.current=null),g.current?.close(),g.current=null,b.current=[],r.current=!1,p.current=!1,_.current=!1},[]),x=s.useCallback(()=>{k.current+=1,H(),m.current=null,l(null),v("idle")},[H]),T=s.useCallback(()=>{const R=g.current;R&&v(O=>O==="playing"?(R.pause(),"paused"):O==="paused"?(R.resume(),"playing"):O)},[]),ee=s.useCallback(R=>{if(m.current===R)return;H(),k.current+=1,w.current=new AbortController,m.current=R,l(R),v("loading");const O=k.current;E.current=setTimeout(()=>{O===k.current&&(w.current?.abort(),v("error"))},12e3)},[H]),X=s.useCallback(async R=>{if(!R)return;const O=o?.();await Te(fetch(`${n}/api/widget/read-aloud-play`,{method:"POST",headers:{"Content-Type":"application/json",...a?{"X-API-Key":a}:{},...O?{Authorization:`Bearer ${O}`}:{}},body:JSON.stringify({messageId:R})}))},[n,a,o]),J=s.useCallback((R,O)=>{r.current||(r.current=!0,(async()=>{for(;b.current.length>0;){if(R!==k.current){r.current=!1;return}const pe=b.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:O,messageId:m.current??void 0}),signal:w.current?.signal}));if(R!==k.current){r.current=!1;return}if(fe||!ne||!ne.ok||!ne.body){v("error"),r.current=!1;return}const he=ne.headers.get("X-Audio-Encoding");if(he&&he!=="pcm16"){v("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",()=>{R===k.current&&(!p.current||b.current.length>0||r.current||x())})}const Oe=g.current,xe=ne.body.getReader();for(;;){const[me,ye]=await Te(xe.read());if(R!==k.current){r.current=!1;return}if(ye){v("error"),r.current=!1;return}const{done:I,value:F}=me;if(I)break;F&&F.byteLength>0&&(Oe.push(F.buffer.slice(F.byteOffset,F.byteOffset+F.byteLength)),_.current||(_.current=!0,U(),v("playing"),X(m.current)))}}r.current=!1,p.current&&!_.current&&R===k.current&&x()})())},[n,a,o,x,X]),ce=s.useCallback((R,O,pe)=>{if(m.current!==R)return;const ue=O.trim();ue&&(b.current.push(ue),J(k.current,pe))},[J]),le=s.useCallback(R=>{m.current===R&&(p.current=!0,b.current.length===0&&!r.current&&!_.current&&x())},[x]);return s.useEffect(()=>()=>x(),[x]),{activeId:i,status:f,activate:ee,feed:ce,finish:le,togglePause:T,stop:x}}const kn=1200;function wn(n={language:"en"}){const{voiceStream:a,language:o,silenceMs:i=kn}=n;let l=null,f=null,v="",m=!1;const g=()=>{f&&clearTimeout(f),f=null},b=()=>{!a||!m||(v="",a.start({language:o,baseText:()=>"",onText:r=>{const p=r.trim();!p||p===v||(v=p,l?.({type:"user_partial",text:p}),g(),f=setTimeout(()=>{const _=v;_&&(v="",l?.({type:"user_final",text:_}),a.stop(),b())},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,b()},stop(){m=!1,g(),v="",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};n.jwt&&(l.Authorization=`Bearer ${n.jwt}`);const f=n.getSessionId?.()??null,v=await fetch(`${n.baseUrl}/api/widget/realtime-voice`,{method:"POST",headers:l,body:JSON.stringify({language:n.language,...f?{sessionId:f}:{}})});if(!v.ok)throw new Error("eleven token refused");const m=await v.json(),g=m.data?.token;if(m.data?.provider!=="elevenlabs"||!g)throw new Error("not an elevenlabs session");m.data?.sessionId&&n.onSessionId?.(m.data.sessionId);const b=m.data?.endUserToken??"",{Conversation:r}=await Ws(async()=>{const{Conversation:x}=await import("./index-DMQkz1bV-BuMYksln.js");return{Conversation:x}},[]);let p=!1,_=null;const k=.6,w=.35,E=x=>{x!==p&&(p=x,o?.({type:"user_speaking",active:x}))};let U="";const H=x=>{const T=x?.trim();T&&(E(!1),o?.({type:"thinking"}),T!==U&&(U=T,n.onUserTurnEnd?.()))};a=await r.startSession({conversationToken:g,connectionType:"webrtc",customLlmExtraBody:{end_user_token:b},onModeChange:({mode:x})=>{o?.(x==="speaking"?{type:"agent_delta",text:""}:{type:"agent_done"})},onVadScore:({vadScore:x})=>{x>=k?(_&&(clearTimeout(_),_=null),E(!0)):x<=w&&p&&!_&&(_=setTimeout(()=>{_=null,E(!1)},600))},onMessage:({message:x,role:T})=>{const ee=x?.trim();ee&&(T==="user"?H(ee):(n.onTranscript({role:"assistant",text:ee,streaming:!1}),U=""))},onIncomingEvent:x=>{x?.type==="user_transcript"&&H(x.user_transcription_event?.user_transcript)},onAgentTyping:()=>o?.({type:"thinking"}),onAgentChatResponsePart:x=>{const T=x?.text??"";T&&n.onTranscript({role:"assistant",text:T,streaming:!0})},onInterruption:()=>o?.({type:"interrupted"}),onError:x=>{console.warn("[voice] eleven blad:",x),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:f,t:v}){return!a||o||i||!n||n.length===0?null:t.jsx("div",{className:"es-sc__followups",role:"list","aria-label":v("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:()=>f(m.message),children:m.label},m.message))})}function Cn(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},Sn={email:"",phone:"",note:""};function Nn(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,f]=s.useState(Sn),[v,m]=s.useState(!1),[g,b]=s.useState(null),r=s.useRef(null),p=Nn(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:p===null?i("support_chat.handoff.queued"):i("support_chat.handoff.waiting",{seconds:p})})]}):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 _=>{if(_.preventDefault(),v)return;if(l.email.trim().length===0&&l.phone.trim().length===0){b(i("support_chat.handoff.contact_validation")),r.current?.focus();return}m(!0),b(null);const k=await a({email:l.email.trim(),phone:l.phone.trim(),note:l.note.trim()});m(!1),k||b(i("support_chat.handoff.contact_error"))},noValidate:!0,children:[t.jsx("p",{className:"es-sc__handoff-title",children:i(Cn(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:_=>f(k=>({...k,email:_.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:_=>f(k=>({...k,phone:_.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:_=>f(k=>({...k,note:_.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:v,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((b,r)=>o.set(b.id,r));let i=null;const l=[];let f=!1;for(const b of a){const r=o.get(b.id);if(r===void 0){l.push(b),b.role==="assistant"&&(f=!0);continue}const p=n[r];En(p,b)&&(i??(i=[...n]),i[r]={...p,...b})}if(l.length===0)return i??n;const v=i??[...n],m=f?v.filter(b=>!De(b)):v,g=m.filter(De);return[...m.filter(b=>!De(b)),...l,...g]}function In({transport:n,agentId:a,onUserMessage:o,onStopPlayback:i}){const[l,f]=s.useState("idle"),[v,m]=s.useState(null),[g,b]=s.useState(!1),[r,p]=s.useState(null),_=s.useRef(o);_.current=o;const k=s.useRef(i);k.current=i;const w=s.useCallback(x=>{switch(x.type){case"user_partial":k.current(),m(x.text),f("listening");return;case"user_final":m(null),b(!1),f("listening"),x.text.trim()&&_.current(x.text);return;case"user_speaking":b(x.active),x.active&&(k.current(),f("listening"));return;case"thinking":m(null),b(!1),f("thinking");return;case"agent_delta":f("speaking");return;case"agent_done":f("listening");return;case"interrupted":k.current(),f("listening");return;case"error":p(x.message),f("error");return}},[]),E=s.useCallback(async()=>{if(!n.available){p("voice_conv.error"),f("error");return}p(null),f("connecting"),k.current();const[,x]=await Te(n.start({agentId:a,onEvent:w}));if(x){p("voice_conv.error"),f("error");return}f("listening")},[n,a,w]),U=s.useCallback(()=>{n.stop(),m(null),b(!1),f("idle")},[n]),H=s.useRef(n);return H.current=n,s.useEffect(()=>()=>H.current.stop(),[]),{state:l,draft:v,userSpeaking:g,error:r,start:E,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:f,transcript:v,onToggleMute:m,onEnd:g,onRetry:b,t:r}){const p=s.useRef(null);if(s.useEffect(()=>{const w=p.current;w&&(w.scrollTop=w.scrollHeight)},[v]),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:b,"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 _=!i&&(!!l||!!(a&&a.trim())),k=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":k,"data-active":_?"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_${k}`)}),t.jsx("div",{className:"es-vm__orb-hint",children:r(`voice_conv.state_${k}_hint`)})]}),t.jsx("div",{className:"es-vm__transcript","data-testid":"voice-mode-transcript",ref:p,children:f?v: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,f=n.slice(o,l).trim();f&&a.push(f),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(v=>v?.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 Xn(n){let a=null;const o=[];for(const i of n.split(`
1
+ import{r as s,j as t,a as kt,b as Te,Q as ts,_ as Ws,t as Xs}from"../nexly.js";import{H as Js,P as Vs}from"./use-deferred-rating-XlgCUwcY-DDVOwURi.js";import{j as Ys}from"./PanelInfoVideo-BKq2v0QM-BrU-Qlul.js";import{x as Zs,s as Gs,c as en,a as tn}from"./allowed-elements-BXnLJV1S-C-_lr2zm.js";import{f as sn}from"./assistant-link-components-DkuhHIF9-CPkAMFv6.js";import{j as nn,X as an}from"./ClickToLoadEmbed-CVZbpoTT-CKUzZ7gL.js";import"./_commonjsHelpers-C6fGbg64-BC8KDfbh.js";import"./assistant-link-policy-CS93s-vA-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(Zs,{remarkPlugins:[...en],allowedElements:[...Gs],transformLinkUri:o=>tn(o)??"",transformImageUri:()=>"",components:{input:({node:o,type:i,checked:l,...f})=>i==="checkbox"?t.jsx("input",{...f,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),f=s.useMemo(()=>nn(n,{allowEmbeds:a,allowedImageHosts:o}),[n,a,l]);return t.jsx(rn,{media:f,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 f=Math.round(l/24);return a("time.days_ago",{count:f})}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:f,t:v}=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:v(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:v("support_chat.tickets_empty")}):i.map(m=>t.jsx(us,{card:m,t:v,onSelect:f},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:f,disabled:v=!1,streaming:m,voiceStream:g,baseText:b,onText:r}){const[p]=s.useState(pn),[_,k]=s.useState("idle"),[w,E]=s.useState(null),[U,H]=s.useState("idle"),x=!!(m&&g&&b&&r),T=s.useRef(null),ee=s.useRef(null),X=s.useRef([]),J=s.useRef(!0);s.useEffect(()=>()=>{J.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(()=>{ee.current?.getTracks().forEach(I=>I.stop()),ee.current=null,T.current=null,X.current=[]},[]);s.useEffect(()=>le,[le]);const R=s.useRef(()=>{});R.current=()=>{x&&(U==="connecting"||U==="listening")&&g?.stop()},s.useEffect(()=>()=>R.current(),[]);const O=s.useCallback(async I=>{const{baseUrl:F,apiKey:V,jwt:Y,language:$,onTranscript:P}=ce.current,te=new FormData;te.append("audio",I,"recording.webm"),te.append("language",$);const ae={};V&&(ae["X-API-Key"]=V),Y&&(ae.Authorization=`Bearer ${Y}`);const ke=await fetch(`${F}/api/widget/transcribe`,{method:"POST",headers:ae,credentials:"include",body:te});if(!ke.ok){const Q=new Error(`HTTP ${ke.status}`);throw Q.status=ke.status,Q}const Ie=await ke.json();P(Ie.text??"")},[]),pe=s.useCallback(async()=>{E(null);let I;try{I=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{k("error"),E("voice.permission_denied");return}const F=fn();let V;try{V=F?new MediaRecorder(I,{mimeType:F}):new MediaRecorder(I)}catch{I.getTracks().forEach(Y=>Y.stop()),k("error"),E("voice.error_generic");return}ee.current=I,T.current=V,X.current=[],V.ondataavailable=Y=>{Y.data&&Y.data.size>0&&X.current.push(Y.data)},V.onstop=async()=>{const Y=V.mimeType||F||"audio/webm",$=new Blob(X.current,{type:Y});if(le(),$.size===0){k("idle");return}k("transcribing");try{if(await O($),!J.current)return;k("idle"),E(null)}catch(P){if(!J.current)return;const te=P.status;k("error"),E(te===413?"voice.error_too_large":"voice.error_generic")}},V.start(),k("recording")},[le,O]),ue=s.useCallback(()=>{const I=T.current;I&&I.state!=="inactive"?I.stop():(le(),k("idle"))},[le]),ne=s.useCallback(()=>{p&&(x?U==="connecting"||U==="listening"?(g.stop(),H("idle")):(E(null),g.start({language:i,baseText:b,onText:r,onState:I=>H(I),onError:I=>{E(I),H("error")}})):_==="recording"?ue():(_==="idle"||_==="error")&&pe())},[p,x,U,_,i,b,r,g,pe,ue]);if(!p)return null;const fe=x?U==="connecting"||U==="listening":_==="recording",he=!x&&_==="transcribing",Oe=x?U==="error":_==="error",xe=f(fe?"voice.stop":"voice.start"),me=w?f(w):he?f("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||v,"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",f=s.useCallback(()=>{if(l==="idle"||l==="error"){o();return}l!=="loading"&&a.togglePause()},[l,o,a]),v=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:f,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:v,"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,f={ended:new Set},v=g=>{for(const b of[...f[g]])b()},m=g=>{g.onended=null,Xs(()=>g.stop())};return{push(g){const b=new Uint8Array(g);let r;i&&i.length>0?(r=new Uint8Array(i.length+b.length),r.set(i,0),r.set(b,i.length),i=null):r=b;const p=r.length-r.length%2;if(p<r.length&&(i=r.slice(p)),p===0)return;const _=new Int16Array(r.buffer,r.byteOffset,p/2);if(_.length===0)return;a??(a=new AudioContext({sampleRate:n}));const k=a.createBuffer(1,_.length,n);k.getChannelData(0).set(Float32Array.from(_,U=>U/32768));const w=a.createBufferSource();w.buffer=k,w.connect(a.destination),w.onended=()=>{l.delete(w),l.size===0&&v("ended")},l.add(w);const E=Math.max(a.currentTime,o);w.start(E),o=E+k.duration},reset(){for(const g of[...l])m(g);l.clear(),o=0,i=null},pause(){a?.suspend()},resume(){a?.resume()},on(g,b){return f[g].add(b),()=>{f[g].delete(b)}},close(){for(const g of[...l])m(g);l.clear(),a?.close(),a=null,o=0,f.ended.clear()}}}function yn({baseUrl:n,apiKey:a,getJwt:o}){const[i,l]=s.useState(null),[f,v]=s.useState("idle"),m=s.useRef(null),g=s.useRef(null),b=s.useRef([]),r=s.useRef(!1),p=s.useRef(!1),_=s.useRef(!1),k=s.useRef(0),w=s.useRef(null),E=s.useRef(null),U=s.useCallback(()=>{E.current&&(clearTimeout(E.current),E.current=null)},[]),H=s.useCallback(()=>{w.current?.abort(),w.current=null,E.current&&(clearTimeout(E.current),E.current=null),g.current?.close(),g.current=null,b.current=[],r.current=!1,p.current=!1,_.current=!1},[]),x=s.useCallback(()=>{k.current+=1,H(),m.current=null,l(null),v("idle")},[H]),T=s.useCallback(()=>{const R=g.current;R&&v(O=>O==="playing"?(R.pause(),"paused"):O==="paused"?(R.resume(),"playing"):O)},[]),ee=s.useCallback(R=>{if(m.current===R)return;H(),k.current+=1,w.current=new AbortController,m.current=R,l(R),v("loading");const O=k.current;E.current=setTimeout(()=>{O===k.current&&(w.current?.abort(),v("error"))},12e3)},[H]),X=s.useCallback(async R=>{if(!R)return;const O=o?.();await Te(fetch(`${n}/api/widget/read-aloud-play`,{method:"POST",headers:{"Content-Type":"application/json",...a?{"X-API-Key":a}:{},...O?{Authorization:`Bearer ${O}`}:{}},body:JSON.stringify({messageId:R})}))},[n,a,o]),J=s.useCallback((R,O)=>{r.current||(r.current=!0,(async()=>{for(;b.current.length>0;){if(R!==k.current){r.current=!1;return}const pe=b.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:O,messageId:m.current??void 0}),signal:w.current?.signal}));if(R!==k.current){r.current=!1;return}if(fe||!ne||!ne.ok||!ne.body){v("error"),r.current=!1;return}const he=ne.headers.get("X-Audio-Encoding");if(he&&he!=="pcm16"){v("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",()=>{R===k.current&&(!p.current||b.current.length>0||r.current||x())})}const Oe=g.current,xe=ne.body.getReader();for(;;){const[me,ye]=await Te(xe.read());if(R!==k.current){r.current=!1;return}if(ye){v("error"),r.current=!1;return}const{done:I,value:F}=me;if(I)break;F&&F.byteLength>0&&(Oe.push(F.buffer.slice(F.byteOffset,F.byteOffset+F.byteLength)),_.current||(_.current=!0,U(),v("playing"),X(m.current)))}}r.current=!1,p.current&&!_.current&&R===k.current&&x()})())},[n,a,o,x,X]),ce=s.useCallback((R,O,pe)=>{if(m.current!==R)return;const ue=O.trim();ue&&(b.current.push(ue),J(k.current,pe))},[J]),le=s.useCallback(R=>{m.current===R&&(p.current=!0,b.current.length===0&&!r.current&&!_.current&&x())},[x]);return s.useEffect(()=>()=>x(),[x]),{activeId:i,status:f,activate:ee,feed:ce,finish:le,togglePause:T,stop:x}}const kn=1200;function wn(n={language:"en"}){const{voiceStream:a,language:o,silenceMs:i=kn}=n;let l=null,f=null,v="",m=!1;const g=()=>{f&&clearTimeout(f),f=null},b=()=>{!a||!m||(v="",a.start({language:o,baseText:()=>"",onText:r=>{const p=r.trim();!p||p===v||(v=p,l?.({type:"user_partial",text:p}),g(),f=setTimeout(()=>{const _=v;_&&(v="",l?.({type:"user_final",text:_}),a.stop(),b())},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,b()},stop(){m=!1,g(),v="",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};n.jwt&&(l.Authorization=`Bearer ${n.jwt}`);const f=n.getSessionId?.()??null,v=await fetch(`${n.baseUrl}/api/widget/realtime-voice`,{method:"POST",headers:l,body:JSON.stringify({language:n.language,...f?{sessionId:f}:{}})});if(!v.ok)throw new Error("eleven token refused");const m=await v.json(),g=m.data?.token;if(m.data?.provider!=="elevenlabs"||!g)throw new Error("not an elevenlabs session");m.data?.sessionId&&n.onSessionId?.(m.data.sessionId);const b=m.data?.endUserToken??"",{Conversation:r}=await Ws(async()=>{const{Conversation:x}=await import("./index-DMQkz1bV-BuMYksln.js");return{Conversation:x}},[]);let p=!1,_=null;const k=.6,w=.35,E=x=>{x!==p&&(p=x,o?.({type:"user_speaking",active:x}))};let U="";const H=x=>{const T=x?.trim();T&&(E(!1),o?.({type:"thinking"}),T!==U&&(U=T,n.onUserTurnEnd?.()))};a=await r.startSession({conversationToken:g,connectionType:"webrtc",customLlmExtraBody:{end_user_token:b},onModeChange:({mode:x})=>{o?.(x==="speaking"?{type:"agent_delta",text:""}:{type:"agent_done"})},onVadScore:({vadScore:x})=>{x>=k?(_&&(clearTimeout(_),_=null),E(!0)):x<=w&&p&&!_&&(_=setTimeout(()=>{_=null,E(!1)},600))},onMessage:({message:x,role:T})=>{const ee=x?.trim();ee&&(T==="user"?H(ee):(n.onTranscript({role:"assistant",text:ee,streaming:!1}),U=""))},onIncomingEvent:x=>{x?.type==="user_transcript"&&H(x.user_transcription_event?.user_transcript)},onAgentTyping:()=>o?.({type:"thinking"}),onAgentChatResponsePart:x=>{const T=x?.text??"";T&&n.onTranscript({role:"assistant",text:T,streaming:!0})},onInterruption:()=>o?.({type:"interrupted"}),onError:x=>{console.warn("[voice] eleven blad:",x),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:f,t:v}){return!a||o||i||!n||n.length===0?null:t.jsx("div",{className:"es-sc__followups",role:"list","aria-label":v("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:()=>f(m.message),children:m.label},m.message))})}function Cn(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},Sn={email:"",phone:"",note:""};function Nn(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,f]=s.useState(Sn),[v,m]=s.useState(!1),[g,b]=s.useState(null),r=s.useRef(null),p=Nn(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:p===null?i("support_chat.handoff.queued"):i("support_chat.handoff.waiting",{seconds:p})})]}):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 _=>{if(_.preventDefault(),v)return;if(l.email.trim().length===0&&l.phone.trim().length===0){b(i("support_chat.handoff.contact_validation")),r.current?.focus();return}m(!0),b(null);const k=await a({email:l.email.trim(),phone:l.phone.trim(),note:l.note.trim()});m(!1),k||b(i("support_chat.handoff.contact_error"))},noValidate:!0,children:[t.jsx("p",{className:"es-sc__handoff-title",children:i(Cn(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:_=>f(k=>({...k,email:_.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:_=>f(k=>({...k,phone:_.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:_=>f(k=>({...k,note:_.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:v,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((b,r)=>o.set(b.id,r));let i=null;const l=[];let f=!1;for(const b of a){const r=o.get(b.id);if(r===void 0){l.push(b),b.role==="assistant"&&(f=!0);continue}const p=n[r];En(p,b)&&(i??(i=[...n]),i[r]={...p,...b})}if(l.length===0)return i??n;const v=i??[...n],m=f?v.filter(b=>!De(b)):v,g=m.filter(De);return[...m.filter(b=>!De(b)),...l,...g]}function In({transport:n,agentId:a,onUserMessage:o,onStopPlayback:i}){const[l,f]=s.useState("idle"),[v,m]=s.useState(null),[g,b]=s.useState(!1),[r,p]=s.useState(null),_=s.useRef(o);_.current=o;const k=s.useRef(i);k.current=i;const w=s.useCallback(x=>{switch(x.type){case"user_partial":k.current(),m(x.text),f("listening");return;case"user_final":m(null),b(!1),f("listening"),x.text.trim()&&_.current(x.text);return;case"user_speaking":b(x.active),x.active&&(k.current(),f("listening"));return;case"thinking":m(null),b(!1),f("thinking");return;case"agent_delta":f("speaking");return;case"agent_done":f("listening");return;case"interrupted":k.current(),f("listening");return;case"error":p(x.message),f("error");return}},[]),E=s.useCallback(async()=>{if(!n.available){p("voice_conv.error"),f("error");return}p(null),f("connecting"),k.current();const[,x]=await Te(n.start({agentId:a,onEvent:w}));if(x){p("voice_conv.error"),f("error");return}f("listening")},[n,a,w]),U=s.useCallback(()=>{n.stop(),m(null),b(!1),f("idle")},[n]),H=s.useRef(n);return H.current=n,s.useEffect(()=>()=>H.current.stop(),[]),{state:l,draft:v,userSpeaking:g,error:r,start:E,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:f,transcript:v,onToggleMute:m,onEnd:g,onRetry:b,t:r}){const p=s.useRef(null);if(s.useEffect(()=>{const w=p.current;w&&(w.scrollTop=w.scrollHeight)},[v]),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:b,"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 _=!i&&(!!l||!!(a&&a.trim())),k=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":k,"data-active":_?"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_${k}`)}),t.jsx("div",{className:"es-vm__orb-hint",children:r(`voice_conv.state_${k}_hint`)})]}),t.jsx("div",{className:"es-vm__transcript","data-testid":"voice-mode-transcript",ref:p,children:f?v: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,f=n.slice(o,l).trim();f&&a.push(f),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(v=>v?.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 Xn(n){let a=null;const o=[];for(const i of n.split(`
2
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
3
  `)}}const Jn=12e4,cs=1500,Vn=6e4,ls=120,Yn=25e3,Zn=600;function Gn({value:n,onChange:a,disabled:o,t:i}){const[l,f]=s.useState(null),v=n??0,m=!o&&l!==null?l:v;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&&f(null),children:[1,2,3,4,5].map(g=>{const b=g<=m;return t.jsx("button",{type:"button",role:"radio","aria-checked":g===v,"aria-label":i("support_chat.rate_star",{count:g}),disabled:o,onMouseEnter:()=>!o&&f(g),onFocus:()=>!o&&f(g),onBlur:()=>!o&&f(null),onClick:()=>!o&&a?.(g),className:`es-sc__rating-star${b?" 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:b?"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:f,supportSessionId:v,auth:m,readOnly:g}){const b=g===!0,r=f?.t??(e=>e),p=i?.apiKey??"",_=s.useRef(m?.jwt);s.useEffect(()=>{_.current=m?.jwt},[m?.jwt]);const k=i?.voice,w=f?.currentLanguage??"en",E=!!k?.enabled&&(k?.languages??[]).includes(w),U=n.voiceConversationEnabled===!0,H=n.voiceReadAloudEnabled===!0,x=i?.voiceOutput,T=yn({baseUrl:o,apiKey:p,getJwt:()=>_.current}),ee=s.useRef(T);ee.current=T;const X=H&&!!x?.enabled&&(x?.languages??[]).includes(w),J=s.useRef(0),ce=i?.userContext??void 0,le=i?.resetSession??!1,R=i?.showTicketsTab??!1,O=kt(n.welcomeMessage,w,{t:r,fallbackKey:"support_chat.welcome_message",enDefault:"Hi! How can I help you today?"}),pe=kt(n.placeholder,w,{t:r,fallbackKey:"support_chat.input_placeholder",enDefault:"Ask a question..."}),ue=n.showSuggestedQuestions??!0,ne=Dn(n.localizedSuggestedQuestions,w,n.suggestedQuestions??[]),fe=n.escalationLabel||r("support_chat.escalation_label"),he=n.humanHandoffButton===!0,Oe=kt(n.headerTitle,w,{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,I=typeof n._draft=="string"?n._draft:void 0,F=n._autoSend===!0,V=Array.isArray(n._quickChips)?n._quickChips:[],Y=JSON.stringify(V),[$,P]=s.useState([]);s.useEffect(()=>{if(!X)return;const e=T.activeId;if(!e){J.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>J.current){const h=u.slice(J.current),{complete:d,remainder:j}=Un(h);if(d.length>0){J.current=u.length-j.length;for(const C of d)T.feed(e,C,w)}}if(!c.isPending){const h=u.slice(J.current).trim();h&&(T.feed(e,h,w),J.current=u.length),T.finish(e)}},[$,T,X,w]);const[te,ae]=s.useState(""),[ke,Ie]=s.useState([]),[Q,qe]=s.useState(!1),[Ct,Ye]=s.useState(null),[Be,Ze]=s.useState(null),[W,Ne]=s.useState(v??null),[Me,it]=s.useState(null),[ot,ps]=s.useState(!1),[Re,St]=s.useState(null),[fs,Nt]=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}=Js(),Z=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){St(null),Nt(0);return}Nt(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([]),Ye(null),Ze(null),qe(!1),Ne(null),st.current=null,et.current=!0}),[a,we]),s.useEffect(()=>{a.emit("support-chat:session",{sessionId:W})},[a,W]);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 C=Date.now()+(d?6e3:Vn),S=async()=>{if(h.cancelled)return;let D=null;try{const y=_.current,M=await fetch(`${o}/api/support-chat/sessions/${e}/messages?limit=50`,{headers:{...p?{"X-API-Key":p}:{},...y?{Authorization:`Bearer ${y}`}:{}}});if(M.ok){const z=await M.json(),ve=z.success&&z.data?z.data.messages:[];for(let A=ve.length-1;A>=0;A--){const K=ve[A];if(K.role!=="assistant")continue;const N=K.createdAt?Date.parse(K.createdAt):NaN;if(Number.isFinite(N)&&N>c){D=K;break}}}}catch{}if(!h.cancelled){if(D){const y=D.metadata??{},M=y.confidence,z=typeof M=="number"?is(M):void 0;P(ve=>ve.map(A=>A.id===j?{...A,id:D.id,serverId:D.id,promptLogId:D.promptLogId??null,text:D.content,isPending:!1,confidence:M,confidenceLevel:z,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}:A)),Pe(),$e.current=null;return}if(Date.now()>=C){d||P(y=>y.map(M=>M.id===j?{...M,text:r("support_chat.error_message"),isPending:!1}:M)),$e.current=null;return}setTimeout(S,cs)}};setTimeout(S,cs)},[p,o,we,Pe,r]),Ke=s.useCallback(async(e,c)=>{try{const u=_.current,h=await fetch(`${o}/api/support-chat/sessions/${e}/messages?limit=50`,{headers:{...p?{"X-API-Key":p}:{},...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 M=y.metadata??void 0,z=M?.ticketCards&&M.ticketCards.length>0?M.ticketCards:void 0;return{id:y.id,role:y.role,text:y.content,promptLogId:y.promptLogId??null,rating:y.userScore??null,...z?{ticketCards:z}:{},...M?.suggestedFollowUps&&M.suggestedFollowUps.length>0?{suggestedFollowUps:M.suggestedFollowUps}:{},...M?.refusalReason?{refusalReason:M.refusalReason,refusalProductName:M.refusalProductName}:{}}}),C=j.length-1,S=C>=0?j[C]:void 0;if(S&&S.role==="assistant"){const y=d.data.messages[d.data.messages.length-1]?.metadata;y?.quickReplies&&y.quickReplies.length>0&&(j[C]={...S,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<Jn&&It(e,y,c)}}catch{}},[p,o,It]),_e=s.useCallback(async e=>{if(!R)return[];try{const c=_.current,u=await fetch(`${o}/api/widget/support-chat/tickets?status=${e}`,{headers:{...p?{"X-API-Key":p}:{},...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,p,R]);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||v&&m?.jwt&&(Mt.current=!0,Ke(v))},[m?.jwt,v,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([]),Ye(null),Ze(null),qe(!1),Ne(c),Ke(c))}),[a,Ke]);const je=s.useCallback(()=>{const e=Z.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(C=>C.id===e?{...C,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}:C))},[]),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;St(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})},[]),Ce=s.useCallback(()=>{ct.current&&(ct.current=!1,a.emit("chat:draftConsumed",void 0))},[a]),G=s.useCallback(async(e,c)=>{const u=e.trim();if(!u)return;Ce(),we(),ge.current?.abort(),ge.current=new AbortController,Ye(null),Ze(null),ae(""),Ie([]),Z.current&&(Z.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(A=>[...A,h,j]),Pe(),qe(!0),tt.current=d;const C=Date.now(),S=async()=>{const A=Zn-(Date.now()-C);A>0&&await new Promise(K=>setTimeout(K,A))};a.emit("support-chat:messageSent",{text:u});const[D]=await Te(async()=>await m?.ensureValidToken?.()??null),y=D??_.current,M={"Content-Type":"application/json",...p?{"X-API-Key":p}:{},...y?{Authorization:`Bearer ${y}`}:{}},z=et.current||W===null;let ve=!1;try{if(c?.quickReplyClick){const q=await fetch(`${o}/api/widget/support-chat/message`,{method:"POST",headers:M,body:JSON.stringify({message:u,productId:l,...z?{newSession:!0}:{},...ce?{userContext:os(ce)}:{},quickReplyClick:c.quickReplyClick}),signal:ge.current.signal}),B=await q.json();if(q.status===429&&B?.error?.code==="DAILY_TOKEN_LIMIT_EXCEEDED"){await S(),ut(d,B.error.resetAtMs);return}if(q.status===429&&B?.error?.code==="DEMO_QUOTA_EXCEEDED"){await S(),At(d);return}if(q.status===429&&B?.error?.code==="RATE_LIMITED"){await S(),dt(d,B.error.retryAfterMs);return}if(q.status===409&&B?.error?.code==="HANDOFF_ACTIVE"){await S(),Pt(d,B.data?.handoffState),B.data?.sessionId&&Ne(B.data.sessionId);return}if(!q.ok||!B.success||!B.data)throw new Error(B.error?.message??`HTTP ${q.status}`);Ne(B.data.sessionId),et.current=!1,lt(d,B.data.assistantMessage),c.quickReplyClick.payload==="confirm_handoff"&&((B.data.assistantMessage.metadata?.toolCalls?.includes("request_human_handoff")??!1)||(ie({kind:"idle"}),Ee.current=null)),_e(Ae).then(bt=>He(bt));return}let A;const K=()=>{A&&clearTimeout(A),A=setTimeout(()=>{ve=!0,ge.current?.abort()},Yn)};K();const N=ge.current;if(!N){clearTimeout(A);return}const[Se,Zt]=await Te(async()=>{const q=await fetch(`${o}/api/widget/support-chat/stream`,{method:"POST",headers:M,body:JSON.stringify({message:u,productId:l,...z?{newSession:!0}:{},...ce?{userContext:os(ce)}:{}}),signal:N.signal});if(!q.ok||!q.body){const se=await q.json().catch(()=>null);if(q.status===429&&se?.error?.code==="DAILY_TOKEN_LIMIT_EXCEEDED")return{dailyLimitResetAtMs:se.error.resetAtMs};if(q.status===429&&se?.error?.code==="DEMO_QUOTA_EXCEEDED")return{demoQuotaExhausted:!0};if(q.status===429&&se?.error?.code==="RATE_LIMITED")return{rateLimitRetryAfterMs:se.error.retryAfterMs??6e4};if(q.status===409&&se?.error?.code==="HANDOFF_ACTIVE")return se.data?.sessionId&&Ne(se.data.sessionId),{handoffState:se.data?.handoffState??null};throw new Error(se?.error?.message??`HTTP ${q.status}`)}const B=q.body.getReader(),bt=new TextDecoder;let Xe="",Gt="",es=!1;for(;;){const{done:se,value:Ks}=await B.read();if(se)break;K(),Xe+=bt.decode(Ks,{stream:!0});let vt;for(;(vt=Xe.indexOf(`
4
4
 
5
5
  `))!==-1;){const zs=Xe.slice(0,vt);Xe=Xe.slice(vt+2);const{event:Je,data:Ve}=Xn(zs);if(!(!Je||!Ve)){if(Je==="start"){const de=JSON.parse(Ve);de.sessionId&&(Ne(de.sessionId),st.current=de.sessionId),et.current=!1}else if(Je==="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(Je==="meta"){const de=JSON.parse(Ve);lt(d,de.assistantMessage),_e(Ae).then(xt=>He(xt)),es=!0}else if(Je==="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(A&&clearTimeout(A),Zt)throw Zt;if(Se&&"handoffState"in Se){await S(),Pt(d,Se.handoffState);return}if(Se?.dailyLimitResetAtMs!==void 0){await S(),ut(d,Se.dailyLimitResetAtMs);return}if(Se?.demoQuotaExhausted){await S(),At(d);return}if(Se?.rateLimitRetryAfterMs!==void 0){await S(),dt(d,Se.rateLimitRetryAfterMs);return}}catch(A){if(A instanceof Error&&A.name==="AbortError"&&!ve){P(K=>K.filter(N=>N.id!==d));return}await S(),P(K=>K.filter(N=>N.id!==d)),tt.current===d&&(Ze({text:u,options:c}),Ye(r("support_chat.error_message")))}finally{tt.current===d&&qe(!1)}},[a,o,ce,p,l,r,lt,ut,dt,_e,Ae,Pe,m,we,Ce]),be=k?.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(W);Ut.current=W;const Dt=k?.realtime===!0,Ot=s.useRef(i?.voiceStream);Ot.current=i?.voiceStream;const qt=s.useMemo(()=>{if(be){const e=jn({baseUrl:o,apiKey:p,jwt:_.current,language:w,enabled:!0,getSessionId:()=>Ut.current,onSessionId:c=>{ht.current=c,Ne(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:w})},[be,o,p,w]),L=In({transport:qt,agentId:i?.voiceAgentId??"",onUserMessage:e=>{G(e)},onStopPlayback:()=>ee.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??W;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(C=!1)=>{const S=ht.current??W;if(!S||e)return!1;const D=_.current;let y=null;try{const N=await fetch(`${o}/api/support-chat/sessions/${S}/messages?limit=30`,{headers:{...p?{"X-API-Key":p}:{},...D?{Authorization:`Bearer ${D}`}:{}}});if(!N.ok)return!1;y=await N.json()}catch{return!1}if(e)return!1;const M=y?.data?.messages??[],z=Lt.current;if(!Qe.current){if(!C)return!1;for(const N of M)N.id&&mt.current.add(N.id),N.role==="user"&&N.id&&z.add(N.id);return Qe.current=!0,!1}const ve=mt.current,A=M.filter(N=>N.id&&N.content?.trim()&&(N.role==="user"||N.role==="assistant")&&!ve.has(N.id)).map(N=>({id:N.id,role:N.role,text:N.content,...N.metadata?{metadata:N.metadata}:{}}));if(A.length===0)return!1;ft(N=>Tn(N,A));const K=A.filter(N=>N.role==="user"&&!z.has(N.id));if(K.length===0)return!1;for(const N of K)z.add(N.id);return at.current=!0,!0},h=async()=>{if(!(c||e)){c=!0;for(let C=0;C<10&&!e&&!await u(!1);C++)await new Promise(S=>setTimeout(S,500));c=!1}};let d=0;const j=5e3;return Le.current=()=>{if(at.current)return;const C=Date.now();C-d<j||(d=C,h())},gt.current=async()=>{for(let C=0;C<6&&!e;C+=1){if(await u(!1),!ze.current.some(De))return;await new Promise(S=>setTimeout(S,700))}},(async()=>{for(let C=0;C<4&&!e&&!Qe.current;C+=1){if(await u(!0),Qe.current)return;await new Promise(S=>setTimeout(S,300))}})(),()=>{e=!0,Le.current=null,gt.current=null}},[be,oe,W,o,p]);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||!T||!X)return;const e=$[$.length-1];!e||e.role!=="assistant"||Wt.current!==e.id&&(Wt.current=e.id,T.activate(e.id))},[$,Bt,T,X]);const _t=s.useCallback(()=>{const e=i?.voiceStream;e?.getState&&e.getState()!=="idle"&&e.stop(),G(te)},[te,G,i]),Cs=s.useCallback(()=>{ge.current?.abort(),qe(!1);const e=tt.current;e&&P(c=>c.filter(u=>u.id!==e))},[]),Ss=s.useCallback(()=>{Be&&G(Be.text,Be.options)},[Be,G]),Ns=s.useCallback(e=>{if(e.autoSend){G(e.message);return}Ie([]),ae(""),Ce(),Z.current&&(Z.current.style.height="auto",Z.current.focus())},[G,Ce]);s.useEffect(()=>{if(!(I!==void 0||V.length>0))return;const e=`${I}${String(F)}${Y}`;if(Et.current!==e){if(Et.current=e,ct.current=!0,F&&I!==void 0){Ie([]),G(I);return}Ie(V),I!==void 0&&(ae(I),requestAnimationFrame(()=>{je(),Z.current?.focus()}))}},[I,F,Y,G]),s.useEffect(()=>{const e=i?.voiceStream;e?.getState&&e.getState()!=="idle"&&e.stop()},[v]);const Rs=s.useCallback(e=>{e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),_t())},[_t]),Es=s.useCallback(e=>{Ce(),ae(e.target.value),je()},[je,Ce]),Ts=s.useCallback(()=>{Ce(),ae(""),Z.current&&(Z.current.style.height="auto",Z.current.focus())},[Ce]),Is=s.useCallback(e=>{const c=e.trim();c&&(ae(u=>u?`${u} ${c}`:c),requestAnimationFrame(()=>{je(),Z.current?.focus()}))},[je]),Ms=s.useCallback(e=>{a.emit("support-chat:escalated",{messageId:e})},[a]),Xt=s.useRef($);s.useEffect(()=>{Xt.current=$},[$]);const As=s.useCallback(({messageId:e,rating:c},{keepalive:u})=>{const h=Xt.current.find(d=>d.id===e);!h||!h.promptLogId||_.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",...p?{"X-API-Key":p}:{},Authorization:`Bearer ${_.current}`},body:JSON.stringify({promptLogId:h.promptLogId,rating:c})}));if(!j&&d.status===409){P(C=>C.map(S=>S.id===e?{...S,rating:c,ratingPending:!1}:S));return}if(j||!d.ok){P(C=>C.map(S=>S.id===e?{...S,rating:null,ratingPending:!1}:S));return}P(C=>C.map(S=>S.id===e?{...S,rating:c,ratingPending:!1}:S)),a.emit("support-chat:feedbackSubmitted",{messageId:e,rating:c})})())},[a,p,o]),{pending:Jt,rate:Vt,undo:Ps}=Vs({submit:As}),$s=s.useCallback((e,c)=>{const u=$.find(h=>h.id===e);!u||!u.promptLogId||u.ratingPending||_.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(!W)return;const e=_.current;try{const c=await fetch(`${o}/api/widget/support-chat/handoff/request`,{method:"POST",headers:{"Content-Type":"application/json",...p?{"X-API-Key":p}:{},...e?{Authorization:`Bearer ${e}`}:{}},body:JSON.stringify({sessionId:W,productId:l,conversationLanguage:w})}),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"})}},[p,o,w,l,W]),Ds=s.useCallback(async e=>{if(!W)return!1;const c=_.current;try{const u=await fetch(`${o}/api/widget/support-chat/handoff/contact`,{method:"POST",headers:{"Content-Type":"application/json",...p?{"X-API-Key":p}:{},...c?{Authorization:`Bearer ${c}`}:{}},body:JSON.stringify({sessionId:W,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}},[p,o,l,W]),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(()=>R?a.on("support-chat:showTickets",()=>{rt()}):void 0,[a,rt,R]);const Hs=s.useCallback((e,c,u)=>{P(j=>j.map(C=>C.id===e?{...C,quickReplyAnswered:c}:C));const h=$.find(j=>j.id===e)?.awaitingConfirmation,d=Hn.includes(u);u==="confirm_handoff"&&ie({kind:"waiting",until:Ee.current}),G(c,{...d?{quickReplyClick:{payload:u,summary:h?.summary,details:h?.details??void 0,priority:h?.priority,sourceMessageId:e}}:{}})},[$,G]),Fs=s.useCallback(()=>{a.emit("support-chat:showHistory",void 0)},[a]),Yt=$.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:R&&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")}),R&&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(Ys,{panelKey:"support-chat",baseUrl:o,apiKey:p||void 0,t:r})]})]}),t.jsx("div",{className:"es-block__body es-sc__body",children:R&&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:[Yt&&t.jsx("div",{className:"es-sc__welcome",children:t.jsx("div",{className:"es-sc__welcome-text",children:O})}),$.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}),X&&t.jsx(vn,{id:e.id,session:T,onActivate:()=>T.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 C=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||Q,onClick:()=>Hs(e.id,d.value,d.payload??""),className:`es-sc__quick-reply-btn${j?" es-sc__quick-reply-btn--clicked":""}`,children:C},d.value)})}),e.role==="assistant"&&t.jsx(ns,{followUps:e.suggestedFollowUps,isNewest:u,isPending:!!e.isPending,hasQuickReplies:!!e.quickReplies?.length,isSending:Q,onSelect:d=>G(d),t:r}),e.role==="assistant"&&!e.isPending&&e.text&&t.jsxs(t.Fragment,{children:[e.promptLogId&&_.current&&(()=>{const d=Jt?.messageId===e.id?Jt.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)}),Ct&&t.jsxs("div",{className:"es-sc__error",role:"alert",children:[t.jsx("span",{className:"es-sc__error-text",children:Ct}),Be&&t.jsx("button",{type:"button",className:"es-sc__error-retry",onClick:Ss,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:()=>Ns(e),type:"button",disabled:Q||b,children:e.labelKey?r(e.labelKey):e.label},`${e.labelKey??e.label}-${c}`))}),re!=="tickets"&&ke.length===0&&Yt&&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:()=>G(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||E)&&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:Z,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:Q||b||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:Q,type:"button","aria-label":r("support_chat.clear_input_aria"),children:t.jsx("span",{"aria-hidden":"true",children:"✕"})})]}),E&&!b&&t.jsx(hn,{baseUrl:o,apiKey:p,jwt:_.current,language:w,onTranscript:Is,t:r,disabled:Q||Me!=null||Re!=null||ot,streaming:k?.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(),Z.current?.focus()})}}),t.jsx("button",{className:`es-sc__send${Q?" es-sc__send--stop":""}`,onClick:Q?Cs:_t,disabled:!Q&&(b||!te.trim()||Me!=null||Re!=null||ot),type:"button","aria-label":r(Q?"support_chat.stop_aria":"chat.send_aria"),children:Q?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-D-ZhVFzi-A3rpkVmQ.js.map
6
+ //# sourceMappingURL=index-Cf4eQF9g-mnUzfS1e.js.map
@@ -1,2 +1,2 @@
1
1
  import{j as e,Q as a}from"../nexly.js";const t={slug:"user-profile",name:"User Profile",version:"1.0.0",category:"content",configSchema:{},defaultConfig:{},dataContract:{serviceSlug:null,inputSchema:{type:"object",properties:{}}},fields:[],sizing:{minWidth:240,preferredHeight:"auto",scrollable:!1},supportedPlacements:["main"]};function c({i18n:r,auth:l}){const i=r?.t??(d=>d);if(!l?.isAuthenticated||!l.user)return e.jsx(a,{blockType:"user-profile",children:e.jsx("div",{className:"es-widget__profile",children:e.jsx("div",{className:"es-widget__profile-empty",children:e.jsx("p",{children:i("profile.not_logged_in")})})})});const{user:s}=l;return e.jsx(a,{blockType:"user-profile",children:e.jsxs("div",{className:"es-widget__profile",children:[e.jsx("div",{className:"es-widget__panel-header",children:e.jsx("div",{className:"es-widget__panel-header-left",children:e.jsx("h2",{className:"es-widget__panel-header-title",children:i("profile.title")})})}),e.jsx("div",{className:"es-widget__profile-body",children:e.jsxs("div",{className:"es-widget__profile-info",children:[s.name&&e.jsxs("div",{className:"es-widget__profile-field",children:[e.jsx("span",{className:"es-widget__profile-field-label",children:i("profile.name")}),e.jsx("span",{className:"es-widget__profile-field-value",children:s.name})]}),s.email&&e.jsxs("div",{className:"es-widget__profile-field",children:[e.jsx("span",{className:"es-widget__profile-field-label",children:i("profile.email")}),e.jsx("span",{className:"es-widget__profile-field-value",children:s.email})]})]})})]})})}export{c as Component,t as manifest};
2
- //# sourceMappingURL=index-CMFQhtEe-BcW8HKb8.js.map
2
+ //# sourceMappingURL=index-ChL-bSAN-BcW8HKb8.js.map
@@ -1,4 +1,4 @@
1
- import{r as o,b as T,j as e,Q}from"../nexly.js";import{x as oe,s as me,c as de,a as ue}from"./allowed-elements-BXnLJV1S-C-_lr2zm.js";import{p as he,c as _e}from"./external-url-LRu_ntew-CJQjg_od.js";import{f as pe}from"./assistant-link-components-MZWf5ty7-C44wlQAi.js";import{C as ge}from"./block-rating-DH7mp-_R-CoiP5C2K.js";import"./_commonjsHelpers-C6fGbg64-BC8KDfbh.js";import"./assistant-link-policy-DWaWTnGr-Cc-yj-a-.js";const Te={slug:"market-insights",name:"Market Insights",version:"2.3.0",category:"data",requiredService:"crypto-intel",configSchema:{properties:{proMode:{type:"boolean",default:!1},showFearGreed:{type:"boolean",default:!0},showNews:{type:"boolean",default:!0},showBtcPrice:{type:"boolean",default:!0},newsLimit:{type:"number",default:5},confirmExternalLinks:{type:"boolean",default:!0}}},defaultConfig:{proMode:!1,showFearGreed:!0,showNews:!0,showBtcPrice:!0,newsLimit:5,confirmExternalLinks:!0},sizing:{minWidth:240,preferredHeight:"auto",scrollable:!1},dataContract:{serviceSlug:"crypto-intel",inputSchema:{type:"object",properties:{fearGreedIndex:{type:"number"},fearGreedLabel:{type:"string"},btcPrice:{type:"number"},btcChange24h:{type:"number"},dominance:{type:"number"},news:{type:"array",items:{type:"object",properties:{title:{type:"string"},source:{type:"string"},publishedAt:{type:"string"},url:{type:"string"},tagline:{type:"string"},articleSummary:{type:"string"}}}},summary:{type:"string"}},required:["summary"]},previewDataOverride:{fearGreedIndex:72,fearGreedLabel:"Greed",btcPrice:68900,btcChange24h:3.15,dominance:54.2,news:[{title:"Bitcoin surges past $68K on strong ETF inflows",source:"CoinDesk",publishedAt:"2026-04-03T08:00:00Z",url:"https://example.com/news/btc-surges"},{title:"Ethereum developers confirm next upgrade timeline",source:"The Block",publishedAt:"2026-04-03T06:30:00Z",url:"https://example.com/news/eth-upgrade"},{title:"DeFi total value locked hits new all-time high",source:"DeFiLlama",publishedAt:"2026-04-02T22:00:00Z",url:"https://example.com/news/defi-tvl"},{title:"South Korea advances crypto regulation framework",source:"Decrypt",publishedAt:"2026-04-02T18:00:00Z",url:"https://example.com/news/sk-crypto"},{title:"MicroStrategy adds 1,000 BTC to corporate treasury",source:"Bloomberg",publishedAt:"2026-04-02T14:00:00Z",url:"https://example.com/news/mstr-btc"}],summary:`Market Sentiment: 72 (Greed)
1
+ import{r as o,b as T,j as e,Q}from"../nexly.js";import{x as oe,s as me,c as de,a as ue}from"./allowed-elements-BXnLJV1S-C-_lr2zm.js";import{p as he,c as _e}from"./external-url-BzUbjdMo-CJQjg_od.js";import{f as pe}from"./assistant-link-components-DkuhHIF9-CPkAMFv6.js";import{C as ge}from"./block-rating-DGpoz2o3-CoiP5C2K.js";import"./_commonjsHelpers-C6fGbg64-BC8KDfbh.js";import"./assistant-link-policy-CS93s-vA-Cc-yj-a-.js";const Te={slug:"market-insights",name:"Market Insights",version:"2.3.0",category:"data",requiredService:"crypto-intel",configSchema:{properties:{proMode:{type:"boolean",default:!1},showFearGreed:{type:"boolean",default:!0},showNews:{type:"boolean",default:!0},showBtcPrice:{type:"boolean",default:!0},newsLimit:{type:"number",default:5},confirmExternalLinks:{type:"boolean",default:!0}}},defaultConfig:{proMode:!1,showFearGreed:!0,showNews:!0,showBtcPrice:!0,newsLimit:5,confirmExternalLinks:!0},sizing:{minWidth:240,preferredHeight:"auto",scrollable:!1},dataContract:{serviceSlug:"crypto-intel",inputSchema:{type:"object",properties:{fearGreedIndex:{type:"number"},fearGreedLabel:{type:"string"},btcPrice:{type:"number"},btcChange24h:{type:"number"},dominance:{type:"number"},news:{type:"array",items:{type:"object",properties:{title:{type:"string"},source:{type:"string"},publishedAt:{type:"string"},url:{type:"string"},tagline:{type:"string"},articleSummary:{type:"string"}}}},summary:{type:"string"}},required:["summary"]},previewDataOverride:{fearGreedIndex:72,fearGreedLabel:"Greed",btcPrice:68900,btcChange24h:3.15,dominance:54.2,news:[{title:"Bitcoin surges past $68K on strong ETF inflows",source:"CoinDesk",publishedAt:"2026-04-03T08:00:00Z",url:"https://example.com/news/btc-surges"},{title:"Ethereum developers confirm next upgrade timeline",source:"The Block",publishedAt:"2026-04-03T06:30:00Z",url:"https://example.com/news/eth-upgrade"},{title:"DeFi total value locked hits new all-time high",source:"DeFiLlama",publishedAt:"2026-04-02T22:00:00Z",url:"https://example.com/news/defi-tvl"},{title:"South Korea advances crypto regulation framework",source:"Decrypt",publishedAt:"2026-04-02T18:00:00Z",url:"https://example.com/news/sk-crypto"},{title:"MicroStrategy adds 1,000 BTC to corporate treasury",source:"Bloomberg",publishedAt:"2026-04-02T14:00:00Z",url:"https://example.com/news/mstr-btc"}],summary:`Market Sentiment: 72 (Greed)
2
2
 
3
3
  BTC: $68,900 | 24h: +3.15% | Dominance: 54.2%`}},fields:[{id:"proMode",type:"toggle",label:"Pro mode (full analysis with context)",default:!1,group:"Display"},{id:"showFearGreed",type:"toggle",label:"Show Fear & Greed index",default:!0,group:"Display"},{id:"showBtcPrice",type:"toggle",label:"Show BTC price",default:!0,group:"Display"},{id:"showNews",type:"toggle",label:"Show news feed",default:!0,group:"Display"},{id:"newsLimit",type:"range",label:"Max news items",default:5,min:1,max:15,step:1,group:"Display"},{id:"confirmExternalLinks",type:"toggle",label:"Confirm before opening external news links",default:!0,group:"Display"}],events:{emits:[{name:"market:newsClicked",description:"User clicked on a news headline"},{name:"market:sentimentViewed",description:"Fear & Greed index was viewed"},{name:"chat:draft",description:"Seed the chat composer with a draft message + quick-reply chips"}],listens:[{name:"market:refresh",description:"Force refresh market data"}]},supportedPlacements:["main","sidebar"]},xe=1e4,D={price:null,change24h:null,ts:null,live:!1};function ye({baseUrl:a,apiKey:n,enabled:l=!0,intervalMs:c=xe}){const[_,d]=o.useState(D),x=o.useRef(a),S=o.useRef(n);return x.current=a,S.current=n,o.useEffect(()=>{if(!l){d(D);return}let t=!1;const M=async()=>{if(typeof document<"u"&&document.hidden||typeof fetch!="function")return;const k=S.current,[$,y]=await T(fetch(`${x.current}/api/widget/market/btc-price`,{headers:k?{"X-API-Key":k}:void 0}));if(t)return;if(y||!$.ok){d(u=>u.live?D:u);return}const[g,b]=await T($.json());if(!t){if(b||g?.price==null){d(u=>u.live?D:u);return}d({price:g.price,change24h:g.change24h??null,ts:g.ts??null,live:!0})}};M();const v=setInterval(()=>{M()},c);return()=>{t=!0,clearInterval(v)}},[l,c]),_}function W(a){return _e(a)}function R(a){return he(a)}const be="var(--es-color-warning, #9C5300)";function we(a){return a<=25?"var(--es-color-error, #AD2C26)":a<=55?be:"var(--es-color-success, #00672B)"}function fe(a){return a==null?"--":`$${a.toLocaleString("en-US",{maximumFractionDigits:0})}`}function ve(a){if(a==null)return{text:"--",positive:!0};const n=a>=0;return{text:`${n?"+":""}${a.toFixed(1)}%`,positive:n}}function H(a){return a==null?"--":a>=1e12?`$${(a/1e12).toFixed(2)}T`:a>=1e9?`$${(a/1e9).toFixed(1)}B`:a>=1e6?`$${(a/1e6).toFixed(0)}M`:`$${a.toLocaleString()}`}function ke(a){if(!a)return"";const n=Date.now()-new Date(a).getTime(),l=Math.floor(n/6e4);if(l<60)return`${l}m`;const c=Math.floor(l/60);return c<24?`${c}h`:`${Math.floor(c/24)}d`}function je(){return e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),e.jsx("polyline",{points:"15 3 21 3 21 9"}),e.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}function Ge({data:a,config:n,i18n:l,actions:c,baseUrl:_,externalContext:d,auth:x,previewMode:S}){const t=l?.t??(s=>s),M=a.promptLogId,v=n.proMode??!1,k=n.showFearGreed??!0,$=v&&(n.showNews??!0),y=n.showBtcPrice??!0,g=n.confirmExternalLinks??!0,[b,u]=o.useState(null),X=n.newsLimit??5,j=d?.apiKey??"",J=d?.hasChatView===!0,[G,Y]=o.useState(()=>new Set),[B,L]=o.useState(()=>new Map),w=a.fearGreedIndex,ee=a.fearGreedLabel,P=(a.news??[]).slice(0,X),Z=a.btcPrice,se=a.btcChange24h,A=a.btcVolume,E=a.btcMarketCap,I=a.dominance,K=a.aiSummary,q=w!=null?we(w):void 0,F=ye({baseUrl:_,apiKey:j,enabled:y}),U=F.live&&F.price!=null,V=U?F.price:Z,ae=U?F.change24h:se,O=ve(ae),N=a._errors??[],te=w!=null||Z!=null||P.length>0,ie=typeof K=="string"&&K.trim().length>0,z=o.useCallback(async(s,i)=>{L(C=>{const p=new Map(C);return p.set(s,{status:"loading"}),p});const[m,h]=await T(fetch(`${_}/api/widget/crypto-intel/article-summary`,{method:"POST",headers:{"Content-Type":"application/json",...j?{"X-API-Key":j}:{}},body:JSON.stringify({title:i.title,url:i.url,source:i.source,publishedAt:i.publishedAt,tagline:i.tagline})})),r=()=>L(C=>{const p=new Map(C);return p.set(s,{status:"error"}),p});if(h||!m.ok)return r();const[f,ce]=await T(m.json());if(ce||!f?.summary)return r();L(C=>{const p=new Map(C);return p.set(s,{status:"ready",text:f.summary}),p})},[j,_]),re=o.useCallback((s,i)=>{if(Y(h=>{const r=new Set(h);return r.has(s)?(r.delete(s),r):(r.add(s),r)}),G.has(s)||B.has(s))return;const m=i.articleSummary?.trim();if(m){L(h=>{const r=new Map(h);return r.set(s,{status:"ready",text:m}),r});return}z(s,i)},[G,B,z]),ne=o.useCallback(s=>{c.emit("chat:draft",{message:t("market_insights.gaio_draft",{title:s.title,source:s.source??"",url:s.url??""}),autoSend:!1,quickChips:[{label:t("market_insights.chip.analyze"),message:t("market_insights.chip.analyze_msg",{url:s.url??""}),autoSend:!0},{label:t("market_insights.chip.summarize"),message:t("market_insights.chip.summarize_msg",{url:s.url??""}),autoSend:!0},{label:t("market_insights.chip.conclusions"),message:t("market_insights.chip.conclusions_msg",{url:s.url??""}),autoSend:!0},{label:t("market_insights.chip.other"),message:"",autoSend:!1}]})},[c,t]),le=o.useCallback(s=>{const i=R(s.url);if(!i)return;if(g){u({url:i,source:s.source||W(i)});return}const m=window.open(i,"_blank","noopener,noreferrer");m&&(m.opener=null)},[g]);return te?e.jsxs(Q,{blockType:"market-insights",children:[e.jsxs("div",{className:"es-block__body",children:[e.jsx(ge,{promptLogId:M,baseUrl:_,apiKey:j,jwt:x?.jwt,previewMode:S,t}),(y||k)&&e.jsxs("div",{className:"es-mi__header",children:[y&&V!=null&&e.jsxs("div",{className:"es-mi__card es-mi__card--btc",children:[e.jsx("span",{className:"es-mi__icon","aria-hidden":"true",children:"B"}),e.jsxs("div",{className:"es-mi__card-label",children:[t("market_insights.bitcoin_label"),U&&e.jsxs("span",{className:"es-mi__live",title:t("market_insights.live_aria"),children:[e.jsx("span",{className:"es-mi__live-dot","aria-hidden":"true"}),t("market_insights.live")]})]}),e.jsx("div",{className:"es-mi__card-value",children:fe(V)}),e.jsx("div",{className:`es-mi__delta ${O.positive?"es-mi__delta--up":"es-mi__delta--down"}`,children:O.text})]}),k&&w!=null&&e.jsxs("div",{className:"es-mi__card es-mi__card--fg",children:[e.jsx("span",{className:"es-mi__icon","aria-hidden":"true",children:"FG"}),e.jsx("div",{className:"es-mi__card-label",children:"Fear & Greed"}),e.jsx("div",{className:"es-mi__card-value es-mi__card-value--fg",style:{color:q},children:w}),e.jsx("div",{className:"es-mi__card-tag",style:{color:q},children:ee}),e.jsx("div",{className:"es-mi__card-bar",children:e.jsx("div",{className:"es-mi__card-bar-fill",style:{width:`${w}%`}})})]})]}),v&&y&&(A!=null||E!=null||I!=null)&&e.jsxs("div",{className:"es-mi__stats",children:[A!=null&&e.jsxs("div",{className:"es-mi__stat",children:[e.jsx("span",{className:"es-mi__stat-label",children:t("market_insights.vol_24h")}),e.jsx("span",{className:"es-mi__stat-value",children:H(A)})]}),E!=null&&e.jsxs("div",{className:"es-mi__stat",children:[e.jsx("span",{className:"es-mi__stat-label",children:t("market_insights.market_cap")}),e.jsx("span",{className:"es-mi__stat-value",children:H(E)})]}),I!=null&&e.jsxs("div",{className:"es-mi__stat",children:[e.jsx("span",{className:"es-mi__stat-label",children:t("market_insights.btc_dominance")}),e.jsxs("span",{className:"es-mi__stat-value",children:[I,"%"]})]})]}),v&&ie&&e.jsxs("div",{className:"es-mi__summary",children:[e.jsx("div",{className:"es-mi__summary-eyebrow",children:t("market_insights.summary_eyebrow")}),e.jsx("div",{className:"es-mi__summary-body es-mi__summary-markdown",children:e.jsx(oe,{remarkPlugins:[...de],allowedElements:[...me],transformLinkUri:s=>ue(s)??"",components:{...pe()},children:K})})]}),$&&P.length>0&&e.jsxs("div",{className:"es-mi__news",children:[e.jsx("div",{className:"es-mi__news-header",children:t("market_insights.news_header")}),e.jsx("ul",{className:"es-mi__news-list",children:P.map((s,i)=>{const m=R(s.url)!==null,h=G.has(i),r=B.get(i),f=r?.status==="loading";return e.jsxs("li",{className:"es-mi__news-item",children:[e.jsx("span",{className:"es-mi__news-stripe","aria-hidden":"true"}),e.jsxs("div",{className:"es-mi__news-body",children:[e.jsx("span",{className:"es-mi__news-title",children:s.title}),e.jsxs("div",{className:"es-mi__news-meta",children:[s.source&&e.jsx("span",{className:"es-mi__news-source",children:s.source}),s.publishedAt&&e.jsx("span",{className:"es-mi__news-time",children:ke(s.publishedAt)})]}),s.tagline&&s.tagline.trim().length>0&&e.jsx("div",{className:"es-mi__news-tagline",children:s.tagline}),e.jsxs("div",{className:"es-mi__news-actions",role:"group","aria-label":t("market_insights.actions_aria"),children:[e.jsxs("button",{type:"button",className:"es-mi__news-btn","aria-expanded":h,"aria-busy":f,disabled:f,onClick:()=>re(i,s),children:[t(f?"market_insights.summary_loading":h?"market_insights.hide":"market_insights.read_more"),e.jsx("span",{className:"es-mi__news-btn-caret","aria-hidden":"true",children:"▾"})]}),J&&e.jsx("button",{type:"button",className:"es-mi__news-btn es-mi__news-btn--gaio",onClick:()=>ne(s),children:t("market_insights.talk_to_gaio")}),m&&e.jsxs("button",{type:"button",className:"es-mi__news-btn",onClick:()=>le(s),children:[t("market_insights.open_link"),e.jsx(je,{})]})]}),e.jsx("div",{className:`es-mi__news-summary${h?" es-mi__news-summary--open":""}${r?.status==="error"?" es-mi__news-summary--error":""}`,children:e.jsx("div",{className:"es-mi__news-summary-inner",children:e.jsxs("div",{className:"es-mi__news-summary-panel",children:[r?.status==="loading"&&e.jsxs("div",{className:"es-mi__news-skeleton","aria-label":t("market_insights.summary_loading"),children:[e.jsx("span",{className:"es-mi__news-skeleton-line"}),e.jsx("span",{className:"es-mi__news-skeleton-line"}),e.jsx("span",{className:"es-mi__news-skeleton-line"})]}),r?.status==="ready"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"es-mi__news-summary-eyebrow",children:t("market_insights.summary_eyebrow")}),e.jsx("div",{className:"es-mi__news-summary-body",children:r.text})]}),r?.status==="error"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"es-mi__news-summary-error-text",children:t("market_insights.summary_error")}),e.jsx("button",{type:"button",className:"es-mi__news-retry",onClick:()=>{z(i,s)},children:t("market_insights.summary_retry")})]})]})})})]})]},i)})})]})]}),b&&e.jsx(Ne,{url:b.url,source:b.source,t,onCancel:()=>u(null),onContinue:()=>{const s=window.open(b.url,"_blank","noopener,noreferrer");s&&(s.opener=null),u(null)}})]}):e.jsx(Q,{blockType:"market-insights",children:e.jsxs("div",{className:"es-block__body",children:[e.jsx("div",{className:"es-block__empty",children:N.length>0?`Data sources unavailable (${N.length} error${N.length>1?"s":""})`:"No market data available"}),N.length>0&&e.jsx("ul",{className:"es-mi__errors",children:N.map((s,i)=>e.jsx("li",{className:"es-mi__error-item",children:s},i))})]})})}function Ne({url:a,source:n,t:l,onCancel:c,onContinue:_}){const d=W(a);return e.jsx("div",{className:"es-mi__leave-backdrop",role:"dialog","aria-modal":"true","aria-labelledby":"es-mi-leave-title",onClick:c,children:e.jsxs("div",{className:"es-mi__leave-card",onClick:x=>x.stopPropagation(),children:[e.jsx("div",{className:"es-mi__leave-icon","aria-hidden":"true",children:e.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}),e.jsx("h2",{id:"es-mi-leave-title",className:"es-mi__leave-title",children:l("market_insights.external_link.title")}),e.jsx("p",{className:"es-mi__leave-body",children:l("market_insights.external_link.body")}),e.jsxs("div",{className:"es-mi__leave-source",title:a,children:[e.jsx("span",{className:"es-mi__leave-source-label",children:n}),e.jsx("span",{className:"es-mi__leave-source-host",children:d})]}),e.jsxs("div",{className:"es-mi__leave-actions",children:[e.jsx("button",{type:"button",className:"es-mi__leave-btn es-mi__leave-btn--cancel",onClick:c,children:l("market_insights.external_link.cancel")}),e.jsx("button",{type:"button",className:"es-mi__leave-btn es-mi__leave-btn--primary",onClick:_,autoFocus:!0,children:l("market_insights.external_link.continue")})]})]})})}export{Ge as Component,Te as manifest};
4
- //# sourceMappingURL=index-qpVhJY7A-Cgivx3vY.js.map
4
+ //# sourceMappingURL=index-Chn4ATvZ-CSI6_0RJ.js.map
@@ -1,2 +1,2 @@
1
1
  import{r as t,j as e,Q as N}from"../nexly.js";const S={slug:"chat-session-nav",name:"Chat Session Navigator",version:"1.0.0",category:"interactive",configSchema:{},defaultConfig:{},sizing:{minWidth:200,preferredHeight:"fill",scrollable:!0},supportedPlacements:["sidebar","main"],events:{emits:[{name:"chat:select-session",description:"User selected a past chat session"}]}};function E(a,i){const d=Date.now()-new Date(a).getTime(),o=Math.floor(d/6e4);if(o<1)return i("time.just_now");if(o<60)return i("time.minutes_ago",{count:o});const c=Math.floor(o/60);return c<24?i("time.hours_ago",{count:c}):i("time.days_ago",{count:Math.floor(c/24)})}function H({actions:a,baseUrl:i,productId:d,i18n:o,auth:c,sessionId:v}){const n=o?.t??(s=>s),f=c?.jwt,[p,l]=t.useState(!1),[x,w]=t.useState([]),[h,b]=t.useState(!1),[j,g]=t.useState(null),[u,_]=t.useState(v??null);t.useEffect(()=>{_(v??null)},[v]);const m=t.useCallback(async()=>{b(!0),g(null);try{const s=await fetch(`${i}/api/chat/sessions?productId=${encodeURIComponent(d||"")}`,{headers:{...f?{Authorization:`Bearer ${f}`}:{}},credentials:"include"});if(!s.ok)throw new Error(`HTTP ${s.status}`);const r=await s.json();if(!r.success)throw new Error("Invalid response");w(r.data?.sessions??[])}catch{g(n("chat_session_nav.load_error"))}finally{b(!1)}},[i,f,d,n]);t.useEffect(()=>a.on("chat:session",s=>{const{sessionId:r}=s;r&&_(r),p&&m()}),[a,m,p]),t.useEffect(()=>a.on("chat:showHistory",()=>{l(!0),m()}),[a,m]),t.useEffect(()=>a.on("chat:clearHistory",()=>{l(!1)}),[a]);const y=t.useCallback(s=>{s!==u&&(_(s),a.emit("chat:select-session",{sessionId:s}),l(!1))},[a,u]),k=t.useCallback(()=>{a.emit("chat:clearHistory",void 0),_(null),l(!1)},[a]),C=t.useCallback(()=>{l(!1)},[]);return p?e.jsxs(N,{blockType:"chat-session-nav",children:[e.jsxs("div",{className:"es-csn__header",children:[e.jsx("span",{className:"es-csn__header-title",children:n("chat_session_nav.title")}),e.jsxs("div",{className:"es-csn__header-actions",children:[e.jsx("button",{type:"button",className:"es-csn__action-btn","aria-label":n("chat_session_nav.new_session"),title:n("chat_session_nav.new_session"),onClick:k,children:e.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:[e.jsx("path",{d:"M12 5H5a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7"}),e.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"})]})}),e.jsx("button",{type:"button",className:"es-csn__close-btn","aria-label":n("chat_session_nav.close"),onClick:C,children:"✕"})]})]}),e.jsx("div",{className:"es-block__body",children:e.jsxs("div",{className:"es-csn__list",role:"list","aria-label":n("chat_session_nav.list_aria"),children:[h&&e.jsx("div",{className:"es-csn__loading",role:"status",children:n("chat_session_nav.loading")}),j&&!h&&e.jsx("div",{className:"es-csn__error",role:"alert",children:j}),!h&&!j&&x.length===0&&e.jsx("div",{className:"es-csn__empty",children:n("chat_session_nav.empty")}),!h&&x.map(s=>e.jsxs("button",{role:"listitem",type:"button",className:`es-csn__item${s.id===u?" es-csn__item--active":""}`,onClick:()=>y(s.id),"aria-current":s.id===u?"true":void 0,children:[e.jsx("div",{className:"es-csn__item-preview",children:s.lastUserMessage??n("chat_session_nav.no_preview")}),e.jsxs("div",{className:"es-csn__item-meta",children:[e.jsx("span",{children:E(s.updatedAt,n)}),s.messageCount>0&&e.jsx("span",{children:n("chat_session_nav.message_count",{count:s.messageCount})})]})]},s.id))]})})]}):null}export{H as Component,S as manifest};
2
- //# sourceMappingURL=index-Dt6OpItC-R_xuAEQV.js.map
2
+ //# sourceMappingURL=index-Cmt7uZiE-R_xuAEQV.js.map
@@ -1,2 +1,2 @@
1
1
  import{r as p,j as e,Q as n}from"../nexly.js";const a=o=>`$${o.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:0})}`;function M({data:o,config:h,actions:l,metadata:x,i18n:j}){const s=j?.t??(i=>i),u=h.mode??o.mode??"basic",c=o.forecast,t=o.aiTip,[m,d]=p.useState("idle"),[N,b]=p.useState(!1);if(!c&&!o.error)return e.jsx(n,{blockType:"commission-forecast",children:e.jsx("div",{className:"cf-block",children:e.jsxs("div",{className:"cf-hero",children:[e.jsx("div",{className:"cf-hero-label",children:s("commission_forecast.estimated_commission")}),e.jsx("div",{className:"cf-hero-amount",style:{color:"var(--es-color-on-surface-muted, #4B5563)"},children:"—"}),e.jsx("div",{className:"cf-hero-sub",style:{color:"var(--es-color-on-surface-muted, #4B5563)"},children:x?.dataQuality==="none"?s("commission_forecast.signin_prompt"):s("commission_forecast.calculating")})]})})});if(o.error||!c)return e.jsx(n,{blockType:"commission-forecast",children:e.jsx("p",{style:{color:"var(--es-color-error, #AD2C26)",fontSize:13},children:s("commission_forecast.load_error")})});const r=c.deltaVsLastMonth,v=c.projectedMonthEnd>0?Math.min(100,Math.round(c.totalEstimated/c.projectedMonthEnd*100)):0,_=Math.round((c.scenarioOneMember-c.projectedMonthEnd)/Math.max(1,c.projectedMonthEnd)*100),g=()=>{t&&(navigator.clipboard.writeText(t).catch(()=>{}),d("copied"),l?.emit?.("cf:tipCopied",{tip:t}),setTimeout(()=>d("idle"),2e3))},f=()=>{b(!0),l?.emit?.("cf:scenarioViewed",{scenarioOneMember:c.scenarioOneMember})};return e.jsx(n,{blockType:"commission-forecast",children:e.jsxs("div",{className:"cf-block",children:[e.jsxs("div",{className:"cf-hero",children:[e.jsx("div",{className:"cf-hero-label",children:s("commission_forecast.estimated_commission")}),e.jsx("div",{className:"cf-hero-amount",children:a(c.totalEstimated)}),e.jsxs("div",{className:"cf-hero-sub",children:[e.jsxs("span",{children:[s("commission_forecast.projected_month_end_label")," ",e.jsx("strong",{children:a(c.projectedMonthEnd)})]}),r!==null&&e.jsxs("span",{className:`cf-delta-badge ${r>=0?"cf-delta--positive":"cf-delta--negative"}`,children:[r>=0?"↑":"↓"," ",a(Math.abs(r))," ",s("commission_forecast.vs_last_month")]})]})]}),e.jsxs("div",{className:"cf-forecast-row",children:[e.jsxs("div",{className:"cf-forecast-labels",children:[e.jsxs("span",{children:[s("commission_forecast.current_label")," ",a(c.totalEstimated)]}),e.jsxs("span",{children:[s("commission_forecast.target_label")," ",a(c.projectedMonthEnd)]})]}),e.jsx("div",{className:"cf-forecast-bar-track",children:e.jsx("div",{className:"cf-forecast-bar-fill",style:{width:`${v}%`}})}),e.jsx("div",{className:"cf-days-left",children:s("commission_forecast.days_left_run_rate",{days:c.daysLeft,rate:a(c.dailyRunRate)})})]}),e.jsxs("div",{className:"cf-scenario",onClick:f,onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),f())},tabIndex:0,role:"button",children:[e.jsx("div",{className:"cf-scenario-label",children:s("commission_forecast.scenario_title")}),e.jsxs("div",{className:"cf-scenario-row",children:[e.jsx("span",{className:"cf-scenario-desc",children:s("commission_forecast.scenario_desc")}),e.jsx("span",{className:"cf-scenario-value",children:a(c.scenarioOneMember)})]}),e.jsx("div",{className:"cf-scenario-uplift",children:s("commission_forecast.uplift",{pct:_,amount:a(c.scenarioOneMember-c.projectedMonthEnd)})})]}),u==="pro"&&c.tiers.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"cf-section-title",children:s("commission_forecast.by_tier",{count:c.tiers.length})}),e.jsx("div",{className:"cf-tier-list",children:c.tiers.map(i=>e.jsxs("div",{className:`cf-tier${i.status==="unreachable"?" cf-tier--unreachable":""}`,children:[e.jsxs("div",{className:"cf-tier-header",children:[e.jsx("span",{className:"cf-tier-engine",children:s("commission_forecast.engine_number",{id:i.engineId})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{className:`cf-tier-status cf-status--${i.status==="in progress"?"in-progress":"unreachable"}`,children:i.status==="in progress"?s("commission_forecast.status.in_progress"):s("commission_forecast.status.unreachable")}),e.jsx("span",{className:"cf-tier-amount",children:a(i.estimatedCommission)})]})]}),e.jsx("div",{className:"cf-tier-progress-track",children:e.jsx("div",{className:"cf-tier-progress-fill",style:{width:`${i.progressPct}%`}})}),e.jsxs("div",{className:"cf-tier-meta",children:[e.jsx("span",{children:s("commission_forecast.volume_label",{current:i.salesVolume.toLocaleString(),max:i.salesVolumeMax.toLocaleString()})}),e.jsx("span",{children:s("commission_forecast.points_label",{current:i.personalPoints,max:i.personalPointsMax})})]})]},i.engineId))})]}),t&&e.jsxs("div",{className:"cf-tip-box",children:[e.jsxs("div",{className:"cf-tip-header",children:[e.jsx("span",{className:"cf-tip-label",children:s("commission_forecast.ai_coach_label")}),e.jsx("button",{className:`cf-copy-btn${m==="copied"?" cf-copied":""}`,onClick:g,children:m==="copied"?`✓ ${s("common.copied")}`:s("common.copy")})]}),e.jsx("p",{className:"cf-tip-text",children:t})]})]})})}const k={slug:"commission-forecast",name:"Commission Forecast",version:"1.0.0",category:"data",requiredService:"commission-forecast",configSchema:{properties:{mode:{type:"string",default:"basic"}}},defaultConfig:{mode:"basic"},sizing:{minWidth:260,preferredHeight:"auto",scrollable:!0},supportedPlacements:["main","sidebar"],dataContract:{serviceSlug:"commission-forecast",inputSchema:{type:"object",properties:{forecast:{type:"object"},aiTip:{type:"string"},mode:{type:"string"}},required:["forecast","mode"]}},events:{emits:[{name:"cf:tipCopied",description:"User copied the AI commission tip"},{name:"cf:scenarioViewed",description:"User viewed the +1 member scenario projection"}]}};export{M as CommissionForecastBlock,M as Component,k as manifest};
2
- //# sourceMappingURL=index-Czz6Gyh_-C3bBvEcm.js.map
2
+ //# sourceMappingURL=index-CogJkGmU-C3bBvEcm.js.map
@@ -0,0 +1,2 @@
1
+ import{r as d,b as a,t as s}from"../nexly.js";const S={slug:"guest-auth",name:"Guest Authentication",version:"1.0.0",category:"content",requiredService:"",configSchema:{properties:{}},defaultConfig:{},sizing:{minWidth:0,preferredHeight:0,scrollable:!1},dataContract:{serviceSlug:"",inputSchema:{type:"object",properties:{fingerprint:{type:"string"}},required:["fingerprint"]},previewDataOverride:{fingerprint:"00000000-0000-4000-a000-000000000000"}},fields:[],events:{emits:[{name:"auth:guest",description:"Guest session created — carries { user: { id }, accessToken }"}],listens:[]},supportedPlacements:["main"]};function m(e){return`es-widget-guest-fp:${e}`}function y(){if(typeof crypto>"u")return null;if(typeof crypto.randomUUID=="function"){const[t]=s(()=>crypto.randomUUID());if(t)return t}if(typeof crypto.getRandomValues!="function")return null;const[e]=s(()=>crypto.getRandomValues(new Uint8Array(16)));if(!e)return null;e[6]=e[6]&15|64,e[8]=e[8]&63|128;const r=Array.from(e,t=>t.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}function h(e,r){if(e)return e;if(typeof window>"u")return;const t=m(r),[i]=s(()=>window.localStorage.getItem(t));if(i)return i;const n=y();if(n)return s(()=>window.localStorage.setItem(t,n)),n}function $({baseUrl:e,actions:r,externalContext:t,productId:i}){const n=d.useRef(!1);return d.useEffect(()=>{if(n.current)return;const c=t?.apiKey;if(!c)return;const u=h(t?.fp,i);u&&(n.current=!0,(async()=>{const[o,f]=await a(fetch(`${e}/api/widget/auth/guest`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":c},body:JSON.stringify({fingerprint:u})}));if(f||!o){console.error("[guest-auth] Error:",f);return}if(!o.ok){const[g]=await a(o.text());console.error("[guest-auth] Auth failed:",o.status,g??"");return}const[p]=await a(o.json()),l=p?.data?.user?.id;l&&r.emit("auth:guest",{user:{id:l},accessToken:p?.data?.accessToken})})())},[e,r,t,i]),null}export{$ as Component,S as manifest};
2
+ //# sourceMappingURL=index-CsoMgZU8-C1BzRUwZ.js.map
@@ -1,2 +1,2 @@
1
1
  import{r as l,j as e,Q as w}from"../nexly.js";import{S as z,I,L as T,j as W,_ as q,k as D,m as O}from"./index.modern-CioVZ357-BA5NTOmY.js";import"./_commonjsHelpers-C6fGbg64-BC8KDfbh.js";const Z={slug:"venue-map",name:"Venue Map",version:"1.0.0",category:"interactive",requiredService:"venue-discovery",configSchema:{properties:{zoom:{type:"number",default:13},showRadius:{type:"boolean",default:!0}}},defaultConfig:{zoom:13,showRadius:!0},dataContract:{serviceSlug:"venue-discovery",inputSchema:{type:"object",properties:{venues:{type:"array",items:{type:"object",properties:{id:{type:"string"},name:{type:"string"},category:{type:"string"},lat:{type:"number"},lng:{type:"number"},rating:{type:"number"},distanceKm:{type:"number"}}}},centerLat:{type:"number"},centerLng:{type:"number"},radiusKm:{type:"number"}},required:["venues"]},previewDataOverride:{venues:[{id:"v-1",name:"Blue Bottle Coffee",category:"cafe",lat:37.5172,lng:127.0473,rating:4.5,distanceKm:.3},{id:"v-2",name:"Coexartium Gallery",category:"gallery",lat:37.5118,lng:127.059,rating:4.2,distanceKm:.8},{id:"v-3",name:"Oakwood Premier COEX",category:"hotel",lat:37.5133,lng:127.0585,rating:4.7,distanceKm:1.1}],centerLat:37.515,centerLng:127.053,radiusKm:2}},fields:[{id:"zoom",type:"range",label:"Default zoom level",default:13,min:8,max:18,step:1,group:"Map"},{id:"showRadius",type:"toggle",label:"Show search radius circle",default:!0,group:"Display"}],events:{emits:[{name:"venueMap:markerClicked",description:"User clicked on a venue marker"},{name:"venueMap:viewChanged",description:"Map viewport moved or zoomed"}],listens:[{name:"venue:locationChanged",description:"Re-center map on new user location"},{name:"venues:refresh",description:"Reload venue pins on the map"}]},sizing:{minWidth:240,preferredHeight:"auto",scrollable:!1},supportedPlacements:["main"]},P={lat:37.5665,lng:126.978};let A=0;function F(){return e.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:[e.jsx("circle",{cx:"12",cy:"12",r:"3.5"}),e.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"5"}),e.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"22"}),e.jsx("line",{x1:"2",y1:"12",x2:"5",y2:"12"}),e.jsx("line",{x1:"19",y1:"12",x2:"22",y2:"12"})]})}function G(){return e.jsx("svg",{className:"es-venuemap__spinner",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5","aria-hidden":"true",children:e.jsx("path",{d:"M12 3 a9 9 0 1 0 9 9",strokeLinecap:"round"})})}function H({open:i}){return e.jsx("svg",{className:`es-venuemap__chevron${i?" es-venuemap__chevron--open":""}`,width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("polyline",{points:"9 18 15 12 9 6"})})}function $({data:i,i18n:x,actions:d}){const r=x?.t??(a=>a),L=x?.currentLanguage??i.language??"en",[m,M]=l.useState(null),[o,S]=l.useState(!0),[p,y]=l.useState(!1),v=l.useState(()=>`es-venue-map-body-${A++}`)[0],j=l.useRef(null),K=z(j,"--es-color-on-primary","#ffffff"),R=l.useCallback(()=>{d?.emit&&(y(!0),d.emit("geo:request",void 0))},[d]);l.useEffect(()=>{if(!d?.on)return;const a=d.on("geo:status",t=>{const c=t?.state;(c==="granted"||c==="denied"||c==="unavailable")&&y(!1)});return()=>a()},[d]);const h=i.venues??[],u=h.length,b=i.googleMapsApiKey,g=i.googleMapsMapId??void 0,B=!!g,s=l.useMemo(()=>h.map(a=>{const t=a.coordinates?.lat??a.lat,c=a.coordinates?.lng??a.lng;return typeof t=="number"&&typeof c=="number"?{...a,lat:t,lng:c}:null}).filter(a=>a!==null),[h]),E=l.useMemo(()=>{const a=i.center;return a&&typeof a.lat=="number"&&typeof a.lng=="number"?{lat:a.lat,lng:a.lng}:s.length>0?{lat:s[0].lat,lng:s[0].lng}:P},[i.center,s]),n=m!=null?s[m]??null:null,_=l.useCallback(a=>M(a),[]),f=r(o?"venue_map.hide_map":"venue_map.show_map"),k=r("venue_map.use_my_location"),N=e.jsxs("div",{className:"es-venuemap__bar",children:[e.jsx("button",{type:"button",className:"es-venuemap__locate",onClick:R,disabled:p,"aria-label":k,"aria-busy":p,title:k,children:p?e.jsx(G,{}):e.jsx(F,{})}),e.jsxs("button",{type:"button",className:"es-venuemap__toggle",onClick:()=>S(a=>!a),"aria-expanded":o,"aria-controls":v,"aria-label":f,children:[e.jsx("span",{className:"es-venuemap__toggle-label",children:f}),e.jsx(H,{open:o})]})]}),C=o?void 0:"es-venuemap--collapsed";return b?e.jsxs(w,{blockType:"venue-map",className:C,children:[e.jsx("div",{id:v,className:"es-block__body es-block__body--map",hidden:!o,ref:j,children:o&&e.jsxs(e.Fragment,{children:[e.jsx(I,{apiKey:b,language:L,children:e.jsx(T,{className:"es-venuemap__canvas",defaultCenter:E,defaultZoom:s.length>0?13:11,mapTypeControl:!1,fullscreenControl:!1,streetViewControl:!1,...g?{mapId:g}:{},children:s.map((a,t)=>B?e.jsx(W,{position:{lat:a.lat,lng:a.lng},title:a.name,onClick:()=>_(t),children:e.jsx(q,{background:t===m?"var(--es-color-interactive, #2563EB)":"var(--es-color-primary, #2563EB)",borderColor:D,glyphColor:K,scale:t===m?1.25:1})},t):e.jsx(O,{position:{lat:a.lat,lng:a.lng},title:a.name,onClick:()=>_(t)},t))})}),s.length>0&&u>s.length&&e.jsxs("div",{className:"es-venuemap__no-coords-badge",role:"note",children:[e.jsx("span",{"aria-hidden":"true",children:"📍"})," ",r("venue_map.partial_no_coords_badge",{count:u-s.length})]}),u>0&&s.length===0&&e.jsxs("div",{className:"es-venuemap__no-coords-overlay",role:"note",children:[e.jsx("div",{"aria-hidden":"true",children:"📍"}),e.jsx("div",{children:r("venue_map.no_coords_notice")})]}),n&&e.jsxs("div",{className:"es-venuemap__detail",role:"dialog","aria-label":n.name,children:[e.jsx("button",{type:"button",className:"es-venuemap__detail-close",onClick:()=>_(null),"aria-label":r("venue_map.close_details"),children:"×"}),e.jsx("h3",{className:"es-venuemap__detail-title",children:n.name}),e.jsxs("div",{className:"es-venuemap__detail-meta",children:[n.rating!=null&&e.jsxs("span",{className:"es-venuemap__detail-meta-item",children:["★"," ",n.rating.toFixed(1)]}),(n.type||n.types?.[0])&&e.jsx("span",{className:"es-venuemap__detail-meta-item",children:n.type??n.types?.[0]})]}),n.address&&e.jsx("div",{className:"es-venuemap__detail-address",children:n.address}),n.url&&e.jsxs("a",{href:n.url,className:"es-venuemap__detail-cta",target:"_blank",rel:"noopener noreferrer",children:[r("venue_list.view_details")," →"]})]})]})}),N]}):e.jsxs(w,{blockType:"venue-map",className:C,children:[e.jsx("div",{id:v,className:"es-block__body",hidden:!o,children:e.jsxs("div",{className:"es-map-placeholder",children:[e.jsx("div",{className:"es-map-placeholder__icon","aria-hidden":"true",children:"🗺"}),e.jsx("div",{className:"es-map-placeholder__message",children:r("venue_map.no_api_key")}),u>0&&e.jsx("div",{className:"es-map-placeholder__count",children:r("venue_map.venues_available",{count:u})}),e.jsx("div",{className:"es-map-placeholder__hint",children:r("venue_map.use_list_hint")})]})}),N]})}export{$ as Component,Z as manifest};
2
- //# sourceMappingURL=index-D72orqXX-C_0Ll4qr.js.map
2
+ //# sourceMappingURL=index-Cxwd1OKy-C_0Ll4qr.js.map
@@ -1,2 +1,2 @@
1
1
  import{r as x,j as e,Q as p}from"../nexly.js";const _={network:"#e0e7ff",sales:"#dcfce7",social:"#fef3c7",personal:"#f3e8ff",team:"#ffedd5"},S={network:"#4338ca",sales:"#137136",social:"#9e4908",personal:"#7129eb",team:"#ab390b"},T={high:"var(--es-color-error, #AD2C26)",medium:"var(--es-color-warning, #9C5300)",low:"var(--es-color-success, #00672B)"},C={high:3,medium:2,low:1};function R({data:c,config:j,actions:h,metadata:g,i18n:b}){const t=b?.t??(a=>a),N=j.mode??c.mode??"basic",m=c.plan,o=c.aiInsight,[v,k]=x.useState(new Set),[r,u]=x.useState(0);if(!m&&!c.error)return e.jsx(p,{blockType:"weekly-rhythm-planner",children:e.jsxs("div",{className:"wrp-block",children:[e.jsxs("div",{className:"wrp-goal",children:[e.jsx("span",{className:"wrp-goal-icon",children:"🎯"}),e.jsx("span",{className:"wrp-goal-text",style:{color:"var(--es-color-on-surface-muted, #4B5563)"},children:g?.dataQuality==="none"?t("weekly_planner.sign_in_prompt"):t("weekly_planner.preparing")})]}),e.jsxs("div",{className:"wrp-basic",children:[e.jsx("div",{className:"wrp-section-label",children:t("weekly_planner.todays_top_actions")}),[1,2,3].map(a=>e.jsxs("div",{className:"wrp-action",style:{opacity:.35},children:[e.jsx("div",{className:"wrp-action-check"}),e.jsx("div",{className:"wrp-action-body",children:e.jsx("span",{className:"wrp-action-title",style:{background:"var(--es-color-surface-elevated, #f5f5f5)",borderRadius:4,display:"block",height:14,width:`${50+a*20}%`}})})]},a))]})]})});if(c.error)return e.jsx(p,{blockType:"weekly-rhythm-planner",children:e.jsx("p",{style:{color:"var(--es-color-error, #AD2C26)",fontSize:13},children:t("weekly_planner.error_generate")})});const s=m,y=(a,i,d)=>{k(l=>{const n=new Set(l);return n.has(a)?n.delete(a):n.add(a),h?.emit?.("wrp:actionToggled",{id:a,title:d,dayIndex:i,checked:!l.has(a)}),n})},f=a=>{u(a),h?.emit?.("wrp:daySelected",{dayIndex:a,dayLabel:s.days[a]?.dayLabel})},w=(a,i)=>{const d=v.has(a.id);return e.jsxs("div",{className:`wrp-action${d?" wrp-action--done":""}`,onClick:()=>y(a.id,i,a.title),onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),y(a.id,i,a.title))},tabIndex:0,role:"checkbox","aria-checked":d,children:[e.jsx("div",{className:"wrp-action-check",children:d?"✓":""}),e.jsxs("div",{className:"wrp-action-body",children:[e.jsx("span",{className:"wrp-action-title",children:a.title}),e.jsxs("div",{className:"wrp-action-meta",children:[a.time&&e.jsx("span",{className:"wrp-action-time",children:a.time}),e.jsx("span",{className:"wrp-cat-badge",style:{background:_[a.category],color:S[a.category]},children:a.category})]})]}),e.jsx("div",{className:"wrp-priority",role:"img","aria-label":a.priority,title:a.priority,children:Array.from({length:C[a.priority]},(l,n)=>e.jsx("span",{className:"wrp-priority-dot",style:{background:T[a.priority]}},n))})]},a.id)};return e.jsx(p,{blockType:"weekly-rhythm-planner",children:e.jsxs("div",{className:"wrp-block",children:[s.weeklyGoal&&e.jsxs("div",{className:"wrp-goal",children:[e.jsx("span",{className:"wrp-goal-icon",children:"🎯"}),e.jsx("span",{className:"wrp-goal-text",children:s.weeklyGoal})]}),N==="basic"?e.jsxs("div",{className:"wrp-basic",children:[e.jsx("div",{className:"wrp-section-label",children:t("weekly_planner.todays_top_actions")}),e.jsx("div",{className:"wrp-action-list",children:s.topThreeToday.map(a=>w(a,0))}),o&&e.jsxs("div",{className:"wrp-insight",children:[e.jsx("span",{className:"wrp-insight-icon",children:"💡"}),e.jsx("span",{children:o})]})]}):e.jsxs("div",{className:"wrp-pro",children:[e.jsx("div",{className:"wrp-day-tabs",children:s.days.map((a,i)=>e.jsxs("button",{className:`wrp-day-tab${r===i?" wrp-day-tab--active":""}`,onClick:()=>f(i),children:[e.jsx("span",{className:"wrp-tab-label",children:a.dayLabel.slice(0,3)}),e.jsx("span",{className:"wrp-tab-count",children:a.actions.length})]},a.date))}),s.days[r]&&e.jsxs("div",{className:"wrp-day-panel",children:[e.jsxs("div",{className:"wrp-day-header",children:[e.jsx("span",{className:"wrp-day-title",children:s.days[r].dayLabel}),e.jsx("span",{className:"wrp-day-date",children:s.days[r].date})]}),e.jsx("div",{className:"wrp-action-list",children:s.days[r].actions.map(a=>w(a,r))}),s.days[r].focusTip&&e.jsxs("div",{className:"wrp-focus-tip",children:[e.jsx("span",{children:"✨"}),e.jsx("span",{children:s.days[r].focusTip})]})]}),o&&e.jsxs("div",{className:"wrp-insight",children:[e.jsx("span",{className:"wrp-insight-icon",children:"💡"}),e.jsx("span",{children:o})]})]})]})})}const B={slug:"weekly-rhythm-planner",name:"Weekly Rhythm Planner",version:"1.0.0",category:"interactive",requiredService:"weekly-rhythm-planner",configSchema:{properties:{mode:{type:"string",default:"basic"}}},defaultConfig:{mode:"basic"},sizing:{minWidth:280,preferredHeight:"auto",scrollable:!0},supportedPlacements:["main","sidebar"],dataContract:{serviceSlug:"weekly-rhythm-planner",inputSchema:{type:"object",properties:{plan:{type:"object"},aiInsight:{type:"string"},mode:{type:"string"}},required:["plan","mode"]}},events:{emits:[{name:"wrp:actionToggled",description:"User toggled an action checkbox"},{name:"wrp:daySelected",description:"User selected a different day in pro mode"}]}};export{R as Component,R as WeeklyRhythmPlannerBlock,B as manifest};
2
- //# sourceMappingURL=index-BylVnv7X-DBhSkJ7i.js.map
2
+ //# sourceMappingURL=index-D-uANagm-DBhSkJ7i.js.map
@@ -1,2 +1,2 @@
1
1
  import{j as e,Q as d}from"../nexly.js";const u={slug:"venue-list",name:"Venue List",version:"1.0.0",category:"content",requiredService:"venue-discovery",configSchema:{properties:{radiusKm:{type:"number",default:10},limit:{type:"number",default:10},hidden:{type:"boolean",default:!1}}},defaultConfig:{radiusKm:10,limit:10,hidden:!1},dataContract:{serviceSlug:"venue-discovery",inputSchema:{type:"object",properties:{venues:{type:"array",items:{type:"object",properties:{id:{type:"string"},name:{type:"string"},category:{type:"string"},address:{type:"string"},rating:{type:"number"},reviewCount:{type:"number"},distanceKm:{type:"number"},photoUrl:{type:"string"}}}},total:{type:"number"}},required:["venues"]},previewDataOverride:{venues:[{id:"v-1",name:"Blue Bottle Coffee",category:"cafe",address:"123 Teheran-ro, Gangnam-gu",rating:4.5,reviewCount:312,distanceKm:.3,photoUrl:""},{id:"v-2",name:"Coexartium Gallery",category:"gallery",address:"456 Samsung-dong, Gangnam-gu",rating:4.2,reviewCount:198,distanceKm:.8,photoUrl:""},{id:"v-3",name:"Oakwood Premier COEX",category:"hotel",address:"789 Bongeunsa-ro, Gangnam-gu",rating:4.7,reviewCount:567,distanceKm:1.1,photoUrl:""}],total:3}},fields:[{id:"radiusKm",type:"range",label:"Search radius (km)",default:10,min:1,max:50,step:1,group:"Search"},{id:"limit",type:"range",label:"Max venues to show",default:10,min:1,max:50,step:1,group:"Content"},{id:"hidden",type:"toggle",label:"Hidden (collect data only, render nothing)",default:!1,group:"Behavior"}],events:{emits:[{name:"venues:venueSelected",description:"User clicked on a venue in the list"},{name:"venues:radiusChanged",description:"User changed the search radius"}],listens:[{name:"venue:locationChanged",description:"Re-run venue search at new user location"},{name:"venues:refresh",description:"Reload venue list from discovery service"}]},sizing:{minWidth:240,preferredHeight:"auto",scrollable:!1},supportedPlacements:["main","sidebar"]};function c({data:n,config:a,i18n:i}){const r=i?.t??(s=>s),t=n.venues??[];return a?.hidden===!0?null:e.jsx(d,{blockType:"venue-list",children:e.jsxs("div",{className:"es-block__body",children:[t.length===0&&e.jsx("div",{className:"es-block__empty",children:r("venue_list.empty")}),t.length>0&&e.jsx("ul",{className:"es-vlist__items",children:t.map((s,l)=>e.jsxs("li",{className:"es-vlist__item",children:[e.jsx("div",{className:"es-vlist__name",children:s.name}),e.jsxs("div",{className:"es-vlist__meta",children:[s.type&&e.jsx("span",{className:"es-vlist__type",children:s.type}),s.rating!=null&&e.jsxs("span",{className:"es-vlist__rating",children:["★"," ",s.rating.toFixed(1)]})]}),s.address&&e.jsx("div",{className:"es-vlist__address",children:s.address})]},l))})]})})}export{c as Component,u as manifest};
2
- //# sourceMappingURL=index-DDEE3QfX-3B-eE3K7.js.map
2
+ //# sourceMappingURL=index-DG-KS4AB-3B-eE3K7.js.map