@nexlylab/widget 1.32.18 → 1.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/INSTALL.txt +1 -1
  2. package/dist/runtime/{1.32.18/chunks/ClickToLoadEmbed-BLIUFZOn-BwY-LAJ8.js → 1.34.0/chunks/ClickToLoadEmbed-BNWVfZ1y-DuTZcv6f.js} +2 -2
  3. package/dist/runtime/{1.32.18/chunks/PanelInfoVideo-BNVzih9J-BrU-Qlul.js → 1.34.0/chunks/PanelInfoVideo-Di7qwhV_-qpxDXdLm.js} +2 -2
  4. package/dist/runtime/{1.32.18/chunks/allowed-elements-BXnLJV1S-C-_lr2zm.js → 1.34.0/chunks/allowed-elements-C0OfX2zF-DIBV8lKu.js} +2 -2
  5. package/dist/runtime/{1.32.18/chunks/assistant-link-components-DUrLEPUB-DKaQavIJ.js → 1.34.0/chunks/assistant-link-components-DtT0biCl-jR32KHTm.js} +2 -2
  6. package/dist/runtime/{1.32.18/chunks/assistant-link-policy-DHB-k1Aa-Cc-yj-a-.js → 1.34.0/chunks/assistant-link-policy-B77YPf4E-By6jpR50.js} +2 -2
  7. package/dist/runtime/{1.32.18/chunks/block-rating-D7hR2gTc-CoiP5C2K.js → 1.34.0/chunks/block-rating-uD_0LK-1-CQMNokIy.js} +2 -2
  8. package/dist/runtime/{1.32.18/chunks/external-url-qbs1SznX-CJQjg_od.js → 1.34.0/chunks/external-url-Bx_GTDOx-rLiy7c9v.js} +2 -2
  9. package/dist/runtime/{1.32.18/chunks/index-BtkNePSj-CiRb-0NX.js → 1.34.0/chunks/index--7VB9nyF-BoVmvEOm.js} +2 -2
  10. package/dist/runtime/{1.32.18/chunks/index-OcrS6o5Y-bdo5pwX-.js → 1.34.0/chunks/index-66kR66X--CzwqZYRk.js} +2 -2
  11. package/dist/runtime/{1.32.18/chunks/index-kAGaGinD-Dm9kbc85.js → 1.34.0/chunks/index-67cmm3Si-Bhh8_8Oh.js} +2 -2
  12. package/dist/runtime/{1.32.18/chunks/index-DiZcd1hz-H31PHMqm.js → 1.34.0/chunks/index-7wlPUbYV-Deg8QEW2.js} +2 -2
  13. package/dist/runtime/{1.32.18/chunks/index-B3DeMFo7-BbdAbuAw.js → 1.34.0/chunks/index-B80p2HRD-BHvEiO2X.js} +3 -3
  14. package/dist/runtime/{1.32.18/chunks/index-DuPFNKhZ-_M0CWPEY.js → 1.34.0/chunks/index-BHphkqVW-CEIHlemy.js} +2 -2
  15. package/dist/runtime/{1.32.18/chunks/index-7N5M1HdS-DAdxCQyi.js → 1.34.0/chunks/index-BIeasoH0-BlFXtfQb.js} +2 -2
  16. package/dist/runtime/{1.32.18/chunks/index-99heIIoH-QeFj7CR9.js → 1.34.0/chunks/index-BPwttNii-f3F4IxQ5.js} +2 -2
  17. package/dist/runtime/{1.32.18/chunks/index-l8Oxwea3-Aqz1AnQ5.js → 1.34.0/chunks/index-BTgHOj2W-D6H0juMn.js} +2 -2
  18. package/dist/runtime/{1.32.18/chunks/index-PxSB6BA6-DFxY6dqO.js → 1.34.0/chunks/index-BfGmnBJ0-BOltxOU-.js} +2 -2
  19. package/dist/runtime/{1.32.18/chunks/index-CYeJYTiB-BLxOZxZv.js → 1.34.0/chunks/index-BjNWgAJk-B-pT4hKt.js} +2 -2
  20. package/dist/runtime/{1.32.18/chunks/index-CZ-JrY2X-TEMHje2B.js → 1.34.0/chunks/index-BlY9hgA--pCzSL4DD.js} +2 -2
  21. package/dist/runtime/{1.32.18/chunks/index-C1Fa-E3e-ZRnEJoQe.js → 1.34.0/chunks/index-BmajLlTC-qsVnaLmo.js} +2 -2
  22. package/dist/runtime/{1.32.18/chunks/index-DaW9uf4--pkywvGDF.js → 1.34.0/chunks/index-BtBJMXR--DWm0RYZF.js} +2 -2
  23. package/dist/runtime/{1.32.18/chunks/index-CF37rhgu-BcW8HKb8.js → 1.34.0/chunks/index-Bz-3E3Sa-B9PuY2Gx.js} +2 -2
  24. package/dist/runtime/{1.32.18/chunks/index-qN6oEHVu-C_0Ll4qr.js → 1.34.0/chunks/index-CM2ok1Hp-k8zxZkfU.js} +2 -2
  25. package/dist/runtime/{1.32.18/chunks/index-COfQIa8G-D6wzHiS0.js → 1.34.0/chunks/index-CMdx7oFx-bh6F7tw3.js} +2 -2
  26. package/dist/runtime/{1.32.18/chunks/index-D1YmJ3gf-3B-eE3K7.js → 1.34.0/chunks/index-COobDdoM-BZw4n83V.js} +2 -2
  27. package/dist/runtime/{1.32.18/chunks/index-DAICBUgn-DBhSkJ7i.js → 1.34.0/chunks/index-CQCPJl3S-CV5ZiVsD.js} +2 -2
  28. package/dist/runtime/{1.32.18/chunks/index-BKZyJMr2-oy07dUaV.js → 1.34.0/chunks/index-CSsAPgvv-qK4w7DnX.js} +4 -4
  29. package/dist/runtime/{1.32.18/chunks/index-oxM4Cgtc-R_xuAEQV.js → 1.34.0/chunks/index-CXm6d9l1-BmIQ-NmU.js} +2 -2
  30. package/dist/runtime/{1.32.18/chunks/index-D96sEJQ6-Dp5AxBD4.js → 1.34.0/chunks/index-CZcU6ylZ-Bt7j8evJ.js} +2 -2
  31. package/dist/runtime/{1.32.18/chunks/index-BKrM_uoq-CABL-0v-.js → 1.34.0/chunks/index-Ce73FsEJ-Ce0fEutJ.js} +2 -2
  32. package/dist/runtime/{1.32.18/chunks/index-C5RVj6y1-DUgMllqN.js → 1.34.0/chunks/index-Cf3qMIwZ-PMvqlUvO.js} +2 -2
  33. package/dist/runtime/{1.32.18/chunks/index-CSRoJRaW-CoI3p0S7.js → 1.34.0/chunks/index-CqSCG8MM-Yl3jEGAx.js} +2 -2
  34. package/dist/runtime/{1.32.18/chunks/index-COTfVuju-DQBGsPwB.js → 1.34.0/chunks/index-CzfX3ctc-qH_mrcVT.js} +2 -2
  35. package/dist/runtime/{1.32.18/chunks/index-BZO9Qaiw-DP0QKkgf.js → 1.34.0/chunks/index-DBhWCUM5-DpMzyqHN.js} +2 -2
  36. package/dist/runtime/{1.32.18/chunks/index-CCEWGjHV-BTsOZg4v.js → 1.34.0/chunks/index-DT9H1y9L-DladDuuj.js} +4 -4
  37. package/dist/runtime/{1.32.18/chunks/index-E59S8-Gw-CovGUxIZ.js → 1.34.0/chunks/index-DbY1AG4s-C-OyGFef.js} +4 -4
  38. package/dist/runtime/{1.32.18/chunks/index-Bf_npmqm-C1BzRUwZ.js → 1.34.0/chunks/index-Ddxqdy4M-CDVtcfdt.js} +2 -2
  39. package/dist/runtime/{1.32.18/chunks/index-Dw7QeZq3-Dr1V6OGz.js → 1.34.0/chunks/index-DmV2pHdJ-Dtq7n928.js} +2 -2
  40. package/dist/runtime/{1.32.18/chunks/index-Cd1-jHFp-Za3SKEQp.js → 1.34.0/chunks/index-DnWzIgAa-DlTfKZaL.js} +2 -2
  41. package/dist/runtime/{1.32.18/chunks/index-BX6ig9BJ-Dsa9X9U7.js → 1.34.0/chunks/index-Dnqtxtmw-CgO1smBF.js} +2 -2
  42. package/dist/runtime/{1.32.18/chunks/index-Ce9TuEzb-C3bBvEcm.js → 1.34.0/chunks/index-Dw35VwDs-DX50C5MZ.js} +2 -2
  43. package/dist/runtime/{1.32.18/chunks/index--xfG4CIn-DbuSZfeK.js → 1.34.0/chunks/index-Dydy8_XR-F9_TzvkO.js} +2 -2
  44. package/dist/runtime/{1.32.18/chunks/index-cCAzBYyN-W1lJrIDD.js → 1.34.0/chunks/index-FHHrEvNZ-VW9D8cgC.js} +2 -2
  45. package/dist/runtime/{1.32.18/chunks/index-BauMKr5c-BpgnWlB8.js → 1.34.0/chunks/index-RyI_7m1j-CavFmRiD.js} +2 -2
  46. package/dist/runtime/1.34.0/chunks/index-TJEJpVI7-CqZ9_vG_.js +2 -0
  47. package/dist/runtime/1.34.0/chunks/index-Va_2P_Gg-Kzu4aFqn.js +6 -0
  48. package/dist/runtime/{1.32.18/chunks/index-BIGVEl9--CSQQTbsg.js → 1.34.0/chunks/index-_wovirve-BzpgdoE8.js} +2 -2
  49. package/dist/runtime/{1.32.18/chunks/index-CV2tGt-4-C9wFr7fa.js → 1.34.0/chunks/index-kmVVSAKR-BlRhWcs1.js} +2 -2
  50. package/dist/runtime/{1.32.18/chunks/index-DATkkw3P-VhJcCfAC.js → 1.34.0/chunks/index-xV27oZEe-ErDxRmJu.js} +2 -2
  51. package/dist/runtime/{1.32.18/chunks/index.modern-CioVZ357-BA5NTOmY.js → 1.34.0/chunks/index.modern-CioVZ357-nfRNslCS.js} +2 -2
  52. package/dist/runtime/1.34.0/nexly.js +61 -0
  53. package/dist/v1.js +4 -4
  54. package/package.json +1 -1
  55. package/dist/runtime/1.32.18/chunks/index-rblri-2U-I68tb-d3.js +0 -2
  56. package/dist/runtime/1.32.18/chunks/index-xx1GG5d1-CW29F9vY.js +0 -6
  57. package/dist/runtime/1.32.18/nexly.js +0 -61
  58. /package/dist/runtime/{1.32.18 → 1.34.0}/chunks/PanelVideoOverlay-BY__oBYV-B8OPC1xh.js +0 -0
  59. /package/dist/runtime/{1.32.18 → 1.34.0}/chunks/_commonjsHelpers-C6fGbg64-BC8KDfbh.js +0 -0
  60. /package/dist/runtime/{1.32.18 → 1.34.0}/chunks/accent-legibility-BJF2VO5n-CDPQ7suO.js +0 -0
  61. /package/dist/runtime/{1.32.18 → 1.34.0}/chunks/block-helpers-Cg_zAqG6-DnN2COvk.js +0 -0
  62. /package/dist/runtime/{1.32.18 → 1.34.0}/chunks/index-BPDIV1BN-DINkyYvc.js +0 -0
  63. /package/dist/runtime/{1.32.18 → 1.34.0}/chunks/index-BcsmWDTX-Dw9WA5Ac.js +0 -0
  64. /package/dist/runtime/{1.32.18 → 1.34.0}/chunks/index-C262wwK4-DpyhuXqd.js +0 -0
  65. /package/dist/runtime/{1.32.18 → 1.34.0}/chunks/index-DMQkz1bV-BuMYksln.js +0 -0
  66. /package/dist/runtime/{1.32.18 → 1.34.0}/chunks/index-DZADUAKv-DPfvWVuj.js +0 -0
  67. /package/dist/runtime/{1.32.18 → 1.34.0}/chunks/inert-assistant-components-B6Cx9pG5-DWb6n3Yq.js +0 -0
  68. /package/dist/runtime/{1.32.18 → 1.34.0}/chunks/use-deferred-rating-XlgCUwcY-DDVOwURi.js +0 -0
@@ -1,2 +1,2 @@
1
- import{r as g,j as a,Q as B}from"../nexly.js";import{C as K}from"./block-rating-D7hR2gTc-CoiP5C2K.js";import{m as L}from"./block-helpers-Cg_zAqG6-DnN2COvk.js";const v=["G-Miner","Miner","Developer","Team Leader","Manager","Senior Manager","Vice President","President","Chairman"],F={"G-Miner":0,Miner:2,Developer:4,"Team Leader":6,Manager:7,"Senior Manager":8,"Vice President":9,President:10,Chairman:15},W={"G-Miner":0,Miner:2,Developer:4,"Team Leader":6,Manager:8,"Senior Manager":9,"Vice President":10,President:11,Chairman:12},A={"G-Miner":50,Miner:50,Developer:50,"Team Leader":50,Manager:50,"Senior Manager":50,"Vice President":50,President:50,Chairman:75},X=.1,I=50,O=150,Q=5,R=1,$=10,U=5e4,z=100,H=7,q=30,S={paidRank:"Miner",scp1Cycles:1,scp1PerCycle:100,scp2Cycles:1,scp2PerCycle:5,scp3DirectSales:500};function E(e){return typeof e=="string"&&v.includes(e)}function G(e,d){const c=F[d];return!Number.isFinite(e)||e<0?0:Math.min(e,c)}function J(e,d){const c=A[d];return!Number.isFinite(e)||e<0?0:Math.min(e,c)}function Y(e){const d=e.paidRank==="G-Miner",c=d?0:Math.max(0,e.scp1Cycles)*Math.max(0,e.scp1PerCycle),s=d?0:Math.max(0,e.scp2Cycles)*Math.max(0,e.scp2PerCycle),m=Math.round(Math.max(0,e.scp3DirectSales)*X),o=c+s+m,x=o*H,l=o*q;return{scp1Daily:c,scp2Daily:s,scp3Daily:m,totalDaily:o,totalWeekly:x,totalMonthly:l}}function Z(e,d){const c=d.currentPayoutRank,s=e.defaultPaidRank,m=E(c)?c:E(s)?s:v[0],o=e.defaultScp2PerCycle,x=typeof o=="number"&&Number.isFinite(o)?Math.min($,Math.max(R,o)):S.scp2PerCycle;return{...S,paidRank:m,scp1Cycles:G(S.scp1Cycles,m),scp2PerCycle:x}}function p(e,d,c){return`${c}${new Intl.NumberFormat(d,{style:"decimal",minimumFractionDigits:0,maximumFractionDigits:0}).format(e)}`}function N({id:e,label:d,value:c,min:s,max:m,step:o,unit:x,currencySymbol:l,locale:n,disabled:b,onChange:i}){const C=x==="$"?p(c,n,l):c.toLocaleString(n),u=x==="$"?p(s,n,l):String(s),t=x==="$"?p(m,n,l):String(m);return a.jsxs("div",{className:`mlmcalc-slider-row${b?" mlmcalc-slider-row--disabled":""}`,children:[a.jsxs("div",{className:"mlmcalc-slider-header",children:[a.jsx("label",{className:"mlmcalc-slider-label",htmlFor:e,children:d}),a.jsx("span",{className:"mlmcalc-slider-value",children:C})]}),a.jsx("input",{id:e,type:"range",className:"mlmcalc-slider",min:s,max:m,step:o,value:c,disabled:b,onChange:h=>i(Number(h.target.value)),onPointerDown:h=>{if(b)return;const k=h.currentTarget.getBoundingClientRect(),f=h.clientX-k.left,M=m-s;if(M<=0)return;const _=(c-s)/M*k.width;if(Math.abs(f-_)<=12)return;const j=Math.max(0,Math.min(1,f/k.width)),D=s+j*M,P=Math.max(s,Math.min(m,Math.round((D-s)/o)*o+s));let r=P;if(P===c){const y=f>_?1:-1;r=Math.max(s,Math.min(m,c+y*o))}r!==c&&(h.preventDefault(),i(r))},style:{"--mlmcalc-fill":`${m>s?(c-s)/(m-s)*100:0}%`}}),a.jsxs("div",{className:"mlmcalc-slider-bounds",children:[a.jsx("span",{children:u}),a.jsx("span",{children:t})]})]})}function ca({data:e,config:d,i18n:c,baseUrl:s,externalContext:m,auth:o,previewMode:x}){const l=c?.t??(r=>r),n=c?.currentLanguage??"en",b=g.useMemo(()=>Z(d,e),[d,e]),[i,C]=g.useState(b),u=g.useMemo(()=>Y(i),[i]),t=l("mlm_calculator.currency_symbol"),h=i.paidRank==="G-Miner",k=F[i.paidRank],f=A[i.paidRank],M=W[i.paidRank],_=g.useCallback(r=>{C(y=>({...y,paidRank:r,scp1Cycles:G(y.scp1Cycles,r),scp2Cycles:J(y.scp2Cycles,r)}))},[]),j=g.useCallback(r=>y=>{C(w=>({...w,[r]:y}))},[]),D=g.useCallback(()=>{C(b)},[b]),P=v.indexOf(i.paidRank);return a.jsx(B,{blockType:"mlm-calculator",children:a.jsxs("div",{className:"es-block__body",children:[a.jsx(K,{blockSlug:"mlm-calculator",baseUrl:s,apiKey:m?.apiKey,jwt:o?.jwt,previewMode:x,t:l,promptKey:"block_rating.prompt_calculator"}),a.jsxs("div",{className:"mlmcalc-block","aria-label":l("mlm_calculator.aria_label"),children:[a.jsx("div",{className:"mlmcalc-title",children:l("mlm_calculator.title")}),a.jsxs("div",{className:"mlmcalc-rank-bar",children:[a.jsx("span",{className:"mlmcalc-rank-label",children:l("mlm_calculator.paid_rank")}),a.jsx("div",{className:"mlmcalc-rank-track",role:"radiogroup","aria-label":l("mlm_calculator.paid_rank"),children:v.map((r,y)=>{const w=r===i.paidRank,T=y<=P,V=["mlmcalc-rank-node",y%2===0?"mlmcalc-rank-node--above":"mlmcalc-rank-node--below",w?"mlmcalc-rank-node--active":"",T?"mlmcalc-rank-node--past":""].filter(Boolean).join(" ");return a.jsxs("button",{type:"button",role:"radio","aria-checked":w,"aria-label":L(r,l),className:V,onClick:()=>_(r),children:[a.jsx("span",{className:"mlmcalc-rank-dot","aria-hidden":"true"}),a.jsx("span",{className:"mlmcalc-rank-name",children:L(r,l)})]},r)})})]}),a.jsxs("div",{className:"mlmcalc-earnings-grid",children:[a.jsxs("div",{className:"mlmcalc-earnings-card",children:[a.jsx("span",{className:"mlmcalc-earnings-label",children:l("mlm_calculator.weekly")}),a.jsx("span",{className:"mlmcalc-earnings-amount",children:p(u.totalWeekly,n,t)})]}),a.jsxs("div",{className:"mlmcalc-earnings-card",children:[a.jsx("span",{className:"mlmcalc-earnings-label",children:l("mlm_calculator.monthly")}),a.jsx("span",{className:"mlmcalc-earnings-amount mlmcalc-earnings-amount--monthly",children:p(u.totalMonthly,n,t)})]})]}),h&&a.jsx("div",{className:"mlmcalc-warning",role:"alert",children:l("mlm_calculator.warning.g_miner")}),a.jsxs("div",{className:"mlmcalc-scp-group",children:[a.jsxs("div",{className:"mlmcalc-scp-header",children:[a.jsx("span",{className:"mlmcalc-scp-title",children:l("mlm_calculator.scp1.title")}),a.jsx("span",{className:"mlmcalc-scp-subtotal",children:l("mlm_calculator.subtotal_per_day",{amount:p(u.scp1Daily,n,t)})})]}),a.jsx(N,{id:"mlmcalc-scp1-cycles",label:l("mlm_calculator.scp1.cycles"),value:i.scp1Cycles,min:0,max:k,step:1,unit:"",currencySymbol:t,locale:n,disabled:h,onChange:j("scp1Cycles")}),a.jsx(N,{id:"mlmcalc-scp1-per-cycle",label:l("mlm_calculator.scp1.per_cycle"),value:i.scp1PerCycle,min:I,max:O,step:Q,unit:"$",currencySymbol:t,locale:n,disabled:h,onChange:j("scp1PerCycle")})]}),a.jsxs("div",{className:"mlmcalc-scp-group",children:[a.jsxs("div",{className:"mlmcalc-scp-header",children:[a.jsx("span",{className:"mlmcalc-scp-title",children:l("mlm_calculator.scp2.title")}),a.jsx("span",{className:"mlmcalc-scp-subtotal",children:l("mlm_calculator.subtotal_per_day",{amount:p(u.scp2Daily,n,t)})})]}),a.jsx(N,{id:"mlmcalc-scp2-cycles",label:l("mlm_calculator.scp2.cycles",{levels:M}),value:i.scp2Cycles,min:0,max:f,step:1,unit:"",currencySymbol:t,locale:n,disabled:h,onChange:j("scp2Cycles")}),a.jsx(N,{id:"mlmcalc-scp2-per-cycle",label:l("mlm_calculator.scp2.per_cycle"),value:i.scp2PerCycle,min:R,max:$,step:1,unit:"$",currencySymbol:t,locale:n,disabled:h,onChange:j("scp2PerCycle")})]}),a.jsxs("div",{className:"mlmcalc-scp-group",children:[a.jsxs("div",{className:"mlmcalc-scp-header",children:[a.jsx("span",{className:"mlmcalc-scp-title",children:l("mlm_calculator.scp3.title")}),a.jsx("span",{className:"mlmcalc-scp-subtotal",children:l("mlm_calculator.subtotal_per_day",{amount:p(u.scp3Daily,n,t)})})]}),a.jsx(N,{id:"mlmcalc-scp3-sales",label:l("mlm_calculator.scp3.daily_sales"),value:i.scp3DirectSales,min:0,max:U,step:z,unit:"$",currencySymbol:t,locale:n,onChange:j("scp3DirectSales")})]}),a.jsxs("div",{className:"mlmcalc-breakdown",children:[a.jsxs("div",{className:"mlmcalc-breakdown-row",children:[a.jsx("span",{children:l("mlm_calculator.breakdown.scp1")}),a.jsx("span",{children:p(u.scp1Daily,n,t)})]}),a.jsxs("div",{className:"mlmcalc-breakdown-row",children:[a.jsx("span",{children:l("mlm_calculator.breakdown.scp2")}),a.jsx("span",{children:p(u.scp2Daily,n,t)})]}),a.jsxs("div",{className:"mlmcalc-breakdown-row",children:[a.jsx("span",{children:l("mlm_calculator.breakdown.scp3")}),a.jsx("span",{children:p(u.scp3Daily,n,t)})]}),a.jsxs("div",{className:"mlmcalc-breakdown-row mlmcalc-breakdown-row--total",children:[a.jsx("span",{children:l("mlm_calculator.breakdown.total")}),a.jsx("span",{children:p(u.totalDaily,n,t)})]})]}),a.jsx("div",{className:"mlmcalc-actions",children:a.jsx("button",{type:"button",className:"mlmcalc-reset",onClick:D,children:l("mlm_calculator.reset")})}),a.jsx("p",{className:"mlmcalc-disclaimer",children:l("mlm_calculator.disclaimer")})]})]})})}const sa={slug:"mlm-calculator",name:"MLM Commission Calculator",version:"2.0.0",category:"interactive",configSchema:{properties:{readAloudEnabled:{type:"boolean",default:!1},defaultPaidRank:{type:"string",default:"Miner"},defaultScp2PerCycle:{type:"number",default:5}}},defaultConfig:{readAloudEnabled:!1,defaultPaidRank:"Miner",defaultScp2PerCycle:5},sizing:{minWidth:300,preferredHeight:"auto",scrollable:!0},supportedPlacements:["main","sidebar"],fields:[{id:"readAloudEnabled",type:"toggle",label:"Read this panel aloud",default:!1,group:"Voice"},{id:"defaultPaidRank",type:"select",label:"Default paid rank",default:"Miner",options:v.map(e=>({label:e,value:e})),group:"Defaults"},{id:"defaultScp2PerCycle",type:"number",label:"Default SCP2 per-cycle amount",default:5,min:R,max:$,group:"Defaults"}],events:{}};export{ca as Component,ca as MlmCalculatorBlock,v as RANK_ORDER,F as SCP1_MAX_CYCLES,W as SCP2_MAX_LEVELS,Y as computeImineEarnings,sa as manifest};
2
- //# sourceMappingURL=index-PxSB6BA6-DFxY6dqO.js.map
1
+ import{r as g,j as a,e as B}from"../nexly.js";import{C as K}from"./block-rating-uD_0LK-1-CQMNokIy.js";import{m as L}from"./block-helpers-Cg_zAqG6-DnN2COvk.js";const v=["G-Miner","Miner","Developer","Team Leader","Manager","Senior Manager","Vice President","President","Chairman"],F={"G-Miner":0,Miner:2,Developer:4,"Team Leader":6,Manager:7,"Senior Manager":8,"Vice President":9,President:10,Chairman:15},W={"G-Miner":0,Miner:2,Developer:4,"Team Leader":6,Manager:8,"Senior Manager":9,"Vice President":10,President:11,Chairman:12},A={"G-Miner":50,Miner:50,Developer:50,"Team Leader":50,Manager:50,"Senior Manager":50,"Vice President":50,President:50,Chairman:75},X=.1,I=50,O=150,U=5,R=1,$=10,z=5e4,H=100,q=7,J=30,S={paidRank:"Miner",scp1Cycles:1,scp1PerCycle:100,scp2Cycles:1,scp2PerCycle:5,scp3DirectSales:500};function E(e){return typeof e=="string"&&v.includes(e)}function G(e,d){const c=F[d];return!Number.isFinite(e)||e<0?0:Math.min(e,c)}function Q(e,d){const c=A[d];return!Number.isFinite(e)||e<0?0:Math.min(e,c)}function Y(e){const d=e.paidRank==="G-Miner",c=d?0:Math.max(0,e.scp1Cycles)*Math.max(0,e.scp1PerCycle),s=d?0:Math.max(0,e.scp2Cycles)*Math.max(0,e.scp2PerCycle),m=Math.round(Math.max(0,e.scp3DirectSales)*X),o=c+s+m,x=o*q,l=o*J;return{scp1Daily:c,scp2Daily:s,scp3Daily:m,totalDaily:o,totalWeekly:x,totalMonthly:l}}function Z(e,d){const c=d.currentPayoutRank,s=e.defaultPaidRank,m=E(c)?c:E(s)?s:v[0],o=e.defaultScp2PerCycle,x=typeof o=="number"&&Number.isFinite(o)?Math.min($,Math.max(R,o)):S.scp2PerCycle;return{...S,paidRank:m,scp1Cycles:G(S.scp1Cycles,m),scp2PerCycle:x}}function p(e,d,c){return`${c}${new Intl.NumberFormat(d,{style:"decimal",minimumFractionDigits:0,maximumFractionDigits:0}).format(e)}`}function N({id:e,label:d,value:c,min:s,max:m,step:o,unit:x,currencySymbol:l,locale:n,disabled:b,onChange:i}){const C=x==="$"?p(c,n,l):c.toLocaleString(n),u=x==="$"?p(s,n,l):String(s),t=x==="$"?p(m,n,l):String(m);return a.jsxs("div",{className:`mlmcalc-slider-row${b?" mlmcalc-slider-row--disabled":""}`,children:[a.jsxs("div",{className:"mlmcalc-slider-header",children:[a.jsx("label",{className:"mlmcalc-slider-label",htmlFor:e,children:d}),a.jsx("span",{className:"mlmcalc-slider-value",children:C})]}),a.jsx("input",{id:e,type:"range",className:"mlmcalc-slider",min:s,max:m,step:o,value:c,disabled:b,onChange:h=>i(Number(h.target.value)),onPointerDown:h=>{if(b)return;const k=h.currentTarget.getBoundingClientRect(),f=h.clientX-k.left,M=m-s;if(M<=0)return;const _=(c-s)/M*k.width;if(Math.abs(f-_)<=12)return;const j=Math.max(0,Math.min(1,f/k.width)),D=s+j*M,P=Math.max(s,Math.min(m,Math.round((D-s)/o)*o+s));let r=P;if(P===c){const y=f>_?1:-1;r=Math.max(s,Math.min(m,c+y*o))}r!==c&&(h.preventDefault(),i(r))},style:{"--mlmcalc-fill":`${m>s?(c-s)/(m-s)*100:0}%`}}),a.jsxs("div",{className:"mlmcalc-slider-bounds",children:[a.jsx("span",{children:u}),a.jsx("span",{children:t})]})]})}function ca({data:e,config:d,i18n:c,baseUrl:s,externalContext:m,auth:o,previewMode:x}){const l=c?.t??(r=>r),n=c?.currentLanguage??"en",b=g.useMemo(()=>Z(d,e),[d,e]),[i,C]=g.useState(b),u=g.useMemo(()=>Y(i),[i]),t=l("mlm_calculator.currency_symbol"),h=i.paidRank==="G-Miner",k=F[i.paidRank],f=A[i.paidRank],M=W[i.paidRank],_=g.useCallback(r=>{C(y=>({...y,paidRank:r,scp1Cycles:G(y.scp1Cycles,r),scp2Cycles:Q(y.scp2Cycles,r)}))},[]),j=g.useCallback(r=>y=>{C(w=>({...w,[r]:y}))},[]),D=g.useCallback(()=>{C(b)},[b]),P=v.indexOf(i.paidRank);return a.jsx(B,{blockType:"mlm-calculator",children:a.jsxs("div",{className:"es-block__body",children:[a.jsx(K,{blockSlug:"mlm-calculator",baseUrl:s,apiKey:m?.apiKey,jwt:o?.jwt,previewMode:x,t:l,promptKey:"block_rating.prompt_calculator"}),a.jsxs("div",{className:"mlmcalc-block","aria-label":l("mlm_calculator.aria_label"),children:[a.jsx("div",{className:"mlmcalc-title",children:l("mlm_calculator.title")}),a.jsxs("div",{className:"mlmcalc-rank-bar",children:[a.jsx("span",{className:"mlmcalc-rank-label",children:l("mlm_calculator.paid_rank")}),a.jsx("div",{className:"mlmcalc-rank-track",role:"radiogroup","aria-label":l("mlm_calculator.paid_rank"),children:v.map((r,y)=>{const w=r===i.paidRank,T=y<=P,V=["mlmcalc-rank-node",y%2===0?"mlmcalc-rank-node--above":"mlmcalc-rank-node--below",w?"mlmcalc-rank-node--active":"",T?"mlmcalc-rank-node--past":""].filter(Boolean).join(" ");return a.jsxs("button",{type:"button",role:"radio","aria-checked":w,"aria-label":L(r,l),className:V,onClick:()=>_(r),children:[a.jsx("span",{className:"mlmcalc-rank-dot","aria-hidden":"true"}),a.jsx("span",{className:"mlmcalc-rank-name",children:L(r,l)})]},r)})})]}),a.jsxs("div",{className:"mlmcalc-earnings-grid",children:[a.jsxs("div",{className:"mlmcalc-earnings-card",children:[a.jsx("span",{className:"mlmcalc-earnings-label",children:l("mlm_calculator.weekly")}),a.jsx("span",{className:"mlmcalc-earnings-amount",children:p(u.totalWeekly,n,t)})]}),a.jsxs("div",{className:"mlmcalc-earnings-card",children:[a.jsx("span",{className:"mlmcalc-earnings-label",children:l("mlm_calculator.monthly")}),a.jsx("span",{className:"mlmcalc-earnings-amount mlmcalc-earnings-amount--monthly",children:p(u.totalMonthly,n,t)})]})]}),h&&a.jsx("div",{className:"mlmcalc-warning",role:"alert",children:l("mlm_calculator.warning.g_miner")}),a.jsxs("div",{className:"mlmcalc-scp-group",children:[a.jsxs("div",{className:"mlmcalc-scp-header",children:[a.jsx("span",{className:"mlmcalc-scp-title",children:l("mlm_calculator.scp1.title")}),a.jsx("span",{className:"mlmcalc-scp-subtotal",children:l("mlm_calculator.subtotal_per_day",{amount:p(u.scp1Daily,n,t)})})]}),a.jsx(N,{id:"mlmcalc-scp1-cycles",label:l("mlm_calculator.scp1.cycles"),value:i.scp1Cycles,min:0,max:k,step:1,unit:"",currencySymbol:t,locale:n,disabled:h,onChange:j("scp1Cycles")}),a.jsx(N,{id:"mlmcalc-scp1-per-cycle",label:l("mlm_calculator.scp1.per_cycle"),value:i.scp1PerCycle,min:I,max:O,step:U,unit:"$",currencySymbol:t,locale:n,disabled:h,onChange:j("scp1PerCycle")})]}),a.jsxs("div",{className:"mlmcalc-scp-group",children:[a.jsxs("div",{className:"mlmcalc-scp-header",children:[a.jsx("span",{className:"mlmcalc-scp-title",children:l("mlm_calculator.scp2.title")}),a.jsx("span",{className:"mlmcalc-scp-subtotal",children:l("mlm_calculator.subtotal_per_day",{amount:p(u.scp2Daily,n,t)})})]}),a.jsx(N,{id:"mlmcalc-scp2-cycles",label:l("mlm_calculator.scp2.cycles",{levels:M}),value:i.scp2Cycles,min:0,max:f,step:1,unit:"",currencySymbol:t,locale:n,disabled:h,onChange:j("scp2Cycles")}),a.jsx(N,{id:"mlmcalc-scp2-per-cycle",label:l("mlm_calculator.scp2.per_cycle"),value:i.scp2PerCycle,min:R,max:$,step:1,unit:"$",currencySymbol:t,locale:n,disabled:h,onChange:j("scp2PerCycle")})]}),a.jsxs("div",{className:"mlmcalc-scp-group",children:[a.jsxs("div",{className:"mlmcalc-scp-header",children:[a.jsx("span",{className:"mlmcalc-scp-title",children:l("mlm_calculator.scp3.title")}),a.jsx("span",{className:"mlmcalc-scp-subtotal",children:l("mlm_calculator.subtotal_per_day",{amount:p(u.scp3Daily,n,t)})})]}),a.jsx(N,{id:"mlmcalc-scp3-sales",label:l("mlm_calculator.scp3.daily_sales"),value:i.scp3DirectSales,min:0,max:z,step:H,unit:"$",currencySymbol:t,locale:n,onChange:j("scp3DirectSales")})]}),a.jsxs("div",{className:"mlmcalc-breakdown",children:[a.jsxs("div",{className:"mlmcalc-breakdown-row",children:[a.jsx("span",{children:l("mlm_calculator.breakdown.scp1")}),a.jsx("span",{children:p(u.scp1Daily,n,t)})]}),a.jsxs("div",{className:"mlmcalc-breakdown-row",children:[a.jsx("span",{children:l("mlm_calculator.breakdown.scp2")}),a.jsx("span",{children:p(u.scp2Daily,n,t)})]}),a.jsxs("div",{className:"mlmcalc-breakdown-row",children:[a.jsx("span",{children:l("mlm_calculator.breakdown.scp3")}),a.jsx("span",{children:p(u.scp3Daily,n,t)})]}),a.jsxs("div",{className:"mlmcalc-breakdown-row mlmcalc-breakdown-row--total",children:[a.jsx("span",{children:l("mlm_calculator.breakdown.total")}),a.jsx("span",{children:p(u.totalDaily,n,t)})]})]}),a.jsx("div",{className:"mlmcalc-actions",children:a.jsx("button",{type:"button",className:"mlmcalc-reset",onClick:D,children:l("mlm_calculator.reset")})}),a.jsx("p",{className:"mlmcalc-disclaimer",children:l("mlm_calculator.disclaimer")})]})]})})}const sa={slug:"mlm-calculator",name:"MLM Commission Calculator",version:"2.0.0",category:"interactive",configSchema:{properties:{readAloudEnabled:{type:"boolean",default:!1},defaultPaidRank:{type:"string",default:"Miner"},defaultScp2PerCycle:{type:"number",default:5}}},defaultConfig:{readAloudEnabled:!1,defaultPaidRank:"Miner",defaultScp2PerCycle:5},sizing:{minWidth:300,preferredHeight:"auto",scrollable:!0},supportedPlacements:["main","sidebar"],fields:[{id:"readAloudEnabled",type:"toggle",label:"Read this panel aloud",default:!1,group:"Voice"},{id:"defaultPaidRank",type:"select",label:"Default paid rank",default:"Miner",options:v.map(e=>({label:e,value:e})),group:"Defaults"},{id:"defaultScp2PerCycle",type:"number",label:"Default SCP2 per-cycle amount",default:5,min:R,max:$,group:"Defaults"}],events:{}};export{ca as Component,ca as MlmCalculatorBlock,v as RANK_ORDER,F as SCP1_MAX_CYCLES,W as SCP2_MAX_LEVELS,Y as computeImineEarnings,sa as manifest};
2
+ //# sourceMappingURL=index-BfGmnBJ0-BOltxOU-.js.map
@@ -1,2 +1,2 @@
1
- import{r as l,j as e,Q as d}from"../nexly.js";const b={slug:"demo-ticket-form",name:"DEMO — Report an issue",version:"0.1.0",category:"interactive",configSchema:{properties:{categories:{type:"array",items:{type:"string"},default:[]}}},defaultConfig:{categories:[]},sizing:{minWidth:240,preferredHeight:"auto",scrollable:!1},supportedPlacements:["main"]};function f(a){if(typeof a!="string")return null;const t=a.trim();if(!t||/\s/.test(t))return null;const s=t.indexOf("@");return s>0&&s<t.length-1?t:null}function g(a){return Array.isArray(a)?a.flatMap(t=>typeof t=="string"&&t.trim().length>0?[t.trim()]:[]):[]}function j({config:a,i18n:t}){const s=t?.t??(i=>i),o=g(a?.categories),n=f(a?.supportEmail),[m,u]=l.useState(o[0]??""),[c,r]=l.useState(""),[k,p]=l.useState(!1),h=c.trim().length>0,_=l.useCallback(()=>{c.trim().length!==0&&(p(!0),r(""))},[c]);return k?e.jsx(d,{blockType:"demo-ticket-form",children:e.jsx("div",{className:"es-block__body es-demoticket es-demoticket--done",children:e.jsxs("div",{className:"es-demoticket__done",children:[e.jsx("span",{className:"es-demoticket__done-mark","aria-hidden":"true",children:"✓"}),e.jsx("p",{className:"es-demoticket__done-text",children:n?s("demoTicket.sentTo",{email:n}):s("demoTicket.sent")})]})})}):e.jsx(d,{blockType:"demo-ticket-form",children:e.jsxs("div",{className:"es-block__body es-demoticket",children:[e.jsxs("div",{className:"es-demoticket__fields",children:[o.length>0&&e.jsxs("label",{className:"es-demoticket__field",children:[e.jsx("span",{className:"es-demoticket__label",children:s("demoTicket.category")}),e.jsx("select",{className:"es-demoticket__select",value:m,onChange:i=>u(i.target.value),children:o.map(i=>e.jsx("option",{value:i,children:i},i))})]}),e.jsxs("label",{className:"es-demoticket__field es-demoticket__field--grow",children:[e.jsx("span",{className:"es-demoticket__label",children:s("demoTicket.message")}),e.jsx("textarea",{className:"es-demoticket__textarea",value:c,onChange:i=>r(i.target.value),placeholder:s("demoTicket.placeholder")})]})]}),e.jsx("button",{type:"button",className:"es-demoticket__submit",onClick:_,disabled:!h,children:s("demoTicket.submit")})]})})}export{j as Component,b as manifest};
2
- //# sourceMappingURL=index-CYeJYTiB-BLxOZxZv.js.map
1
+ import{r as l,j as e,e as d}from"../nexly.js";const b={slug:"demo-ticket-form",name:"DEMO — Report an issue",version:"0.1.0",category:"interactive",configSchema:{properties:{categories:{type:"array",items:{type:"string"},default:[]}}},defaultConfig:{categories:[]},sizing:{minWidth:240,preferredHeight:"auto",scrollable:!1},supportedPlacements:["main"]};function f(a){if(typeof a!="string")return null;const t=a.trim();if(!t||/\s/.test(t))return null;const s=t.indexOf("@");return s>0&&s<t.length-1?t:null}function g(a){return Array.isArray(a)?a.flatMap(t=>typeof t=="string"&&t.trim().length>0?[t.trim()]:[]):[]}function j({config:a,i18n:t}){const s=t?.t??(i=>i),o=g(a?.categories),n=f(a?.supportEmail),[m,u]=l.useState(o[0]??""),[c,r]=l.useState(""),[k,p]=l.useState(!1),h=c.trim().length>0,_=l.useCallback(()=>{c.trim().length!==0&&(p(!0),r(""))},[c]);return k?e.jsx(d,{blockType:"demo-ticket-form",children:e.jsx("div",{className:"es-block__body es-demoticket es-demoticket--done",children:e.jsxs("div",{className:"es-demoticket__done",children:[e.jsx("span",{className:"es-demoticket__done-mark","aria-hidden":"true",children:"✓"}),e.jsx("p",{className:"es-demoticket__done-text",children:n?s("demoTicket.sentTo",{email:n}):s("demoTicket.sent")})]})})}):e.jsx(d,{blockType:"demo-ticket-form",children:e.jsxs("div",{className:"es-block__body es-demoticket",children:[e.jsxs("div",{className:"es-demoticket__fields",children:[o.length>0&&e.jsxs("label",{className:"es-demoticket__field",children:[e.jsx("span",{className:"es-demoticket__label",children:s("demoTicket.category")}),e.jsx("select",{className:"es-demoticket__select",value:m,onChange:i=>u(i.target.value),children:o.map(i=>e.jsx("option",{value:i,children:i},i))})]}),e.jsxs("label",{className:"es-demoticket__field es-demoticket__field--grow",children:[e.jsx("span",{className:"es-demoticket__label",children:s("demoTicket.message")}),e.jsx("textarea",{className:"es-demoticket__textarea",value:c,onChange:i=>r(i.target.value),placeholder:s("demoTicket.placeholder")})]})]}),e.jsx("button",{type:"button",className:"es-demoticket__submit",onClick:_,disabled:!h,children:s("demoTicket.submit")})]})})}export{j as Component,b as manifest};
2
+ //# sourceMappingURL=index-BjNWgAJk-B-pT4hKt.js.map
@@ -1,2 +1,2 @@
1
- import{r as o,j as e,Q as u}from"../nexly.js";const x=[{value:"post",labelKey:"social_content.type.post"},{value:"story",labelKey:"social_content.type.story"},{value:"dm",labelKey:"social_content.type.dm"},{value:"event_promo",labelKey:"social_content.type.event_promo"}],g=[{value:"instagram",label:"Instagram"},{value:"facebook",label:"Facebook"},{value:"kakao",label:"KakaoTalk"},{value:"line",label:"LINE"},{value:"generic",labelKey:"social_content.platform.generic"}],G=[{value:"professional",labelKey:"social_content.tone.professional"},{value:"casual",labelKey:"social_content.tone.casual"},{value:"energetic",labelKey:"social_content.tone.energetic"},{value:"empathetic",labelKey:"social_content.tone.empathetic"}];function j(t,d){const n=g.find(m=>m.value===d);return n?.labelKey?t(n.labelKey):n?.label??d}function Q({data:t,config:d,actions:n,metadata:m,i18n:_}){const s=_?.t??(c=>c),N=d.mode??t.mode??"basic",f=t.content,k=t.contentType??"post",C=t.platform??"generic",K=t.tone??"professional",S=t.characterCount,[a,T]=o.useState(f??""),[i,w]=o.useState(k),[r,$]=o.useState(C),[p,q]=o.useState(K),[h,v]=o.useState("idle"),[l,b]=o.useState(!1),B=()=>{a&&(navigator.clipboard.writeText(a).catch(()=>{}),v("copied"),n?.emit?.("sc:contentCopied",{content:a,contentType:i,platform:r}),setTimeout(()=>v("idle"),2e3))},y=o.useCallback(async()=>{if(!(l||!n?.request)){b(!0);try{const c=await n.request("sc:regenerate",{contentType:i,platform:r,tone:p});c?.content&&(T(c.content),n?.emit?.("sc:contentGenerated",{contentType:i,platform:r,tone:p}))}finally{b(!1)}}},[l,n,i,r,p]),E=c=>{w(c),n?.emit?.("sc:typeChanged",{contentType:c})};return!a&&!t.error&&!l?e.jsx(u,{blockType:"social-content",children:e.jsxs("div",{className:"sc-block",children:[e.jsxs("div",{className:"sc-content-card",children:[e.jsxs("div",{className:"sc-content-header",children:[e.jsxs("div",{className:"sc-content-meta",children:[e.jsx("span",{className:"sc-meta-badge",children:s("social_content.type.post")}),e.jsx("span",{className:"sc-meta-badge",style:{background:"var(--es-color-success-soft, rgba(0, 103, 43, 0.15))",color:"var(--es-color-success, #00672B)"},children:s("social_content.platform.generic")})]}),e.jsxs("button",{className:"sc-btn sc-btn--primary",onClick:y,disabled:l,children:["↺ ",s("social_content.generate_content")]})]}),e.jsx("div",{className:"sc-content-body",style:{color:"var(--es-color-on-surface-muted, #4B5563)",fontStyle:"italic"},children:e.jsx("p",{className:"sc-content-text",children:m?.dataQuality==="none"?s("social_content.signin_prompt"):s("social_content.empty_cta_hint")})})]}),e.jsxs("div",{className:"sc-compliance-notice",children:[e.jsx("span",{className:"sc-compliance-icon",children:"🛡️"}),e.jsx("span",{children:s("social_content.compliance_notice_short")})]})]})}):t.error?e.jsx(u,{blockType:"social-content",children:e.jsx("p",{style:{color:"var(--es-color-error, #AD2C26)",fontSize:13},children:s("social_content.load_error")})}):e.jsx(u,{blockType:"social-content",children:e.jsxs("div",{className:"sc-block",children:[N==="pro"&&e.jsxs("div",{className:"sc-selectors",children:[e.jsxs("div",{children:[e.jsx("div",{className:"sc-selector-label",children:s("social_content.content_type_label")}),e.jsx("div",{className:"sc-selector-row",children:x.map(c=>e.jsx("button",{className:`sc-chip${i===c.value?" sc-chip--active":""}`,onClick:()=>E(c.value),children:s(c.labelKey)},c.value))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"sc-selector-label",children:s("social_content.platform_label")}),e.jsx("div",{className:"sc-selector-row",children:g.map(c=>e.jsx("button",{className:`sc-chip${r===c.value?" sc-chip--active":""}`,onClick:()=>$(c.value),children:j(s,c.value)},c.value))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"sc-selector-label",children:s("social_content.tone_label")}),e.jsx("div",{className:"sc-selector-row",children:G.map(c=>e.jsx("button",{className:`sc-chip${p===c.value?" sc-chip--active":""}`,onClick:()=>q(c.value),children:s(c.labelKey)},c.value))})]})]}),e.jsxs("div",{className:"sc-content-card",children:[e.jsxs("div",{className:"sc-content-header",children:[e.jsxs("div",{className:"sc-content-meta",children:[e.jsx("span",{className:"sc-meta-badge",children:s(x.find(c=>c.value===i)?.labelKey??"social_content.type.post")}),e.jsx("span",{className:"sc-meta-badge",style:{background:"var(--es-color-success-soft, rgba(0, 103, 43, 0.15))",color:"var(--es-color-success, #00672B)"},children:j(s,r)}),S!==void 0&&e.jsx("span",{className:"sc-char-count",children:s("social_content.char_count",{count:a.length})})]}),e.jsxs("div",{className:"sc-actions",children:[e.jsx("button",{className:`sc-btn${h==="copied"?" sc-btn--copied":""}`,onClick:B,disabled:!a,children:h==="copied"?`✓ ${s("common.copied")}`:s("common.copy")}),e.jsx("button",{className:"sc-btn sc-btn--primary",onClick:y,disabled:l,children:l?"...":`↺ ${s("social_content.regenerate")}`})]})]}),l?e.jsxs("div",{className:"sc-generating",children:[e.jsx("div",{className:"sc-spinner"}),s("social_content.generating")]}):e.jsx("div",{className:"sc-content-body",children:e.jsx("p",{className:"sc-content-text",children:a})})]}),e.jsxs("div",{className:"sc-compliance-notice",children:[e.jsx("span",{className:"sc-compliance-icon",children:"🛡️"}),e.jsx("span",{children:s("social_content.compliance_notice_full")})]})]})})}const z={slug:"social-content",name:"Social Content Generator",version:"1.0.0",category:"interactive",requiredService:"social-content",configSchema:{properties:{mode:{type:"string",default:"basic"}}},defaultConfig:{mode:"basic"},sizing:{minWidth:280,preferredHeight:"auto",scrollable:!0},supportedPlacements:["main","sidebar"],dataContract:{serviceSlug:"social-content",inputSchema:{type:"object",properties:{content:{type:"string"},contentType:{type:"string"},platform:{type:"string"},tone:{type:"string"},mode:{type:"string"},characterCount:{type:"number"}},required:["content","mode"]}},events:{emits:[{name:"sc:contentCopied",description:"User copied generated content"},{name:"sc:contentGenerated",description:"New content was generated (after regenerate)"},{name:"sc:typeChanged",description:"User changed content type in pro mode"}]}};export{Q as Component,Q as SocialContentBlock,z as manifest};
2
- //# sourceMappingURL=index-CZ-JrY2X-TEMHje2B.js.map
1
+ import{r as o,j as e,e as u}from"../nexly.js";const x=[{value:"post",labelKey:"social_content.type.post"},{value:"story",labelKey:"social_content.type.story"},{value:"dm",labelKey:"social_content.type.dm"},{value:"event_promo",labelKey:"social_content.type.event_promo"}],g=[{value:"instagram",label:"Instagram"},{value:"facebook",label:"Facebook"},{value:"kakao",label:"KakaoTalk"},{value:"line",label:"LINE"},{value:"generic",labelKey:"social_content.platform.generic"}],G=[{value:"professional",labelKey:"social_content.tone.professional"},{value:"casual",labelKey:"social_content.tone.casual"},{value:"energetic",labelKey:"social_content.tone.energetic"},{value:"empathetic",labelKey:"social_content.tone.empathetic"}];function j(t,d){const n=g.find(m=>m.value===d);return n?.labelKey?t(n.labelKey):n?.label??d}function z({data:t,config:d,actions:n,metadata:m,i18n:_}){const s=_?.t??(c=>c),N=d.mode??t.mode??"basic",f=t.content,k=t.contentType??"post",C=t.platform??"generic",K=t.tone??"professional",S=t.characterCount,[a,T]=o.useState(f??""),[i,w]=o.useState(k),[r,$]=o.useState(C),[p,q]=o.useState(K),[h,v]=o.useState("idle"),[l,b]=o.useState(!1),B=()=>{a&&(navigator.clipboard.writeText(a).catch(()=>{}),v("copied"),n?.emit?.("sc:contentCopied",{content:a,contentType:i,platform:r}),setTimeout(()=>v("idle"),2e3))},y=o.useCallback(async()=>{if(!(l||!n?.request)){b(!0);try{const c=await n.request("sc:regenerate",{contentType:i,platform:r,tone:p});c?.content&&(T(c.content),n?.emit?.("sc:contentGenerated",{contentType:i,platform:r,tone:p}))}finally{b(!1)}}},[l,n,i,r,p]),E=c=>{w(c),n?.emit?.("sc:typeChanged",{contentType:c})};return!a&&!t.error&&!l?e.jsx(u,{blockType:"social-content",children:e.jsxs("div",{className:"sc-block",children:[e.jsxs("div",{className:"sc-content-card",children:[e.jsxs("div",{className:"sc-content-header",children:[e.jsxs("div",{className:"sc-content-meta",children:[e.jsx("span",{className:"sc-meta-badge",children:s("social_content.type.post")}),e.jsx("span",{className:"sc-meta-badge",style:{background:"var(--es-color-success-soft, rgba(0, 103, 43, 0.15))",color:"var(--es-color-success, #00672B)"},children:s("social_content.platform.generic")})]}),e.jsxs("button",{className:"sc-btn sc-btn--primary",onClick:y,disabled:l,children:["↺ ",s("social_content.generate_content")]})]}),e.jsx("div",{className:"sc-content-body",style:{color:"var(--es-color-on-surface-muted, #4B5563)",fontStyle:"italic"},children:e.jsx("p",{className:"sc-content-text",children:m?.dataQuality==="none"?s("social_content.signin_prompt"):s("social_content.empty_cta_hint")})})]}),e.jsxs("div",{className:"sc-compliance-notice",children:[e.jsx("span",{className:"sc-compliance-icon",children:"🛡️"}),e.jsx("span",{children:s("social_content.compliance_notice_short")})]})]})}):t.error?e.jsx(u,{blockType:"social-content",children:e.jsx("p",{style:{color:"var(--es-color-error, #AD2C26)",fontSize:13},children:s("social_content.load_error")})}):e.jsx(u,{blockType:"social-content",children:e.jsxs("div",{className:"sc-block",children:[N==="pro"&&e.jsxs("div",{className:"sc-selectors",children:[e.jsxs("div",{children:[e.jsx("div",{className:"sc-selector-label",children:s("social_content.content_type_label")}),e.jsx("div",{className:"sc-selector-row",children:x.map(c=>e.jsx("button",{className:`sc-chip${i===c.value?" sc-chip--active":""}`,onClick:()=>E(c.value),children:s(c.labelKey)},c.value))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"sc-selector-label",children:s("social_content.platform_label")}),e.jsx("div",{className:"sc-selector-row",children:g.map(c=>e.jsx("button",{className:`sc-chip${r===c.value?" sc-chip--active":""}`,onClick:()=>$(c.value),children:j(s,c.value)},c.value))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"sc-selector-label",children:s("social_content.tone_label")}),e.jsx("div",{className:"sc-selector-row",children:G.map(c=>e.jsx("button",{className:`sc-chip${p===c.value?" sc-chip--active":""}`,onClick:()=>q(c.value),children:s(c.labelKey)},c.value))})]})]}),e.jsxs("div",{className:"sc-content-card",children:[e.jsxs("div",{className:"sc-content-header",children:[e.jsxs("div",{className:"sc-content-meta",children:[e.jsx("span",{className:"sc-meta-badge",children:s(x.find(c=>c.value===i)?.labelKey??"social_content.type.post")}),e.jsx("span",{className:"sc-meta-badge",style:{background:"var(--es-color-success-soft, rgba(0, 103, 43, 0.15))",color:"var(--es-color-success, #00672B)"},children:j(s,r)}),S!==void 0&&e.jsx("span",{className:"sc-char-count",children:s("social_content.char_count",{count:a.length})})]}),e.jsxs("div",{className:"sc-actions",children:[e.jsx("button",{className:`sc-btn${h==="copied"?" sc-btn--copied":""}`,onClick:B,disabled:!a,children:h==="copied"?`✓ ${s("common.copied")}`:s("common.copy")}),e.jsx("button",{className:"sc-btn sc-btn--primary",onClick:y,disabled:l,children:l?"...":`↺ ${s("social_content.regenerate")}`})]})]}),l?e.jsxs("div",{className:"sc-generating",children:[e.jsx("div",{className:"sc-spinner"}),s("social_content.generating")]}):e.jsx("div",{className:"sc-content-body",children:e.jsx("p",{className:"sc-content-text",children:a})})]}),e.jsxs("div",{className:"sc-compliance-notice",children:[e.jsx("span",{className:"sc-compliance-icon",children:"🛡️"}),e.jsx("span",{children:s("social_content.compliance_notice_full")})]})]})})}const A={slug:"social-content",name:"Social Content Generator",version:"1.0.0",category:"interactive",requiredService:"social-content",configSchema:{properties:{mode:{type:"string",default:"basic"}}},defaultConfig:{mode:"basic"},sizing:{minWidth:280,preferredHeight:"auto",scrollable:!0},supportedPlacements:["main","sidebar"],dataContract:{serviceSlug:"social-content",inputSchema:{type:"object",properties:{content:{type:"string"},contentType:{type:"string"},platform:{type:"string"},tone:{type:"string"},mode:{type:"string"},characterCount:{type:"number"}},required:["content","mode"]}},events:{emits:[{name:"sc:contentCopied",description:"User copied generated content"},{name:"sc:contentGenerated",description:"New content was generated (after regenerate)"},{name:"sc:typeChanged",description:"User changed content type in pro mode"}]}};export{z as Component,z as SocialContentBlock,A as manifest};
2
+ //# sourceMappingURL=index-BlY9hgA--pCzSL4DD.js.map
@@ -1,2 +1,2 @@
1
- import{r as i,j as e,Q as x,o as K}from"../nexly.js";import{m as O}from"./block-helpers-Cg_zAqG6-DnN2COvk.js";const Q={slug:"gaio-coach",name:"GAIO Coach",version:"1.0.0",category:"interactive",requiredService:"gaio-coach",configSchema:{properties:{proMode:{type:"boolean",default:!1},showProgressBar:{type:"boolean",default:!0},showMotivationalMessage:{type:"boolean",default:!0},maxActionsShown:{type:"number",default:3}}},defaultConfig:{proMode:!1,showProgressBar:!0,showMotivationalMessage:!0,maxActionsShown:3},sizing:{minWidth:240,preferredHeight:"auto",scrollable:!0},dataContract:{serviceSlug:"gaio-coach",inputSchema:{type:"object",properties:{plan:{type:"object",properties:{date:{type:"string"},topActions:{type:"array",items:{type:"object",properties:{id:{type:"string"},title:{type:"string"}}}},motivationalMessage:{type:"string"},progressSummary:{type:"string"}}},progress:{type:"object",properties:{currentStreak:{type:"number"},completedActions:{type:"number"},weeklyScore:{type:"number"},rank:{type:"string"},nextMilestone:{type:"string"}}}}},previewDataOverride:{plan:{date:"2026-04-05",topActions:[{id:"a1",type:"recruit",title:"Connect with 3 prospects",description:"Reach out to your warm market list. Send personalized messages to 3 contacts who expressed interest.",estimatedMinutes:30,priority:"high",isCompleted:!1},{id:"a2",type:"attend_event",title:"Attend local networking event",description:"Seoul Tech Meetup at 7pm. Bring business cards and focus on making genuine connections.",estimatedMinutes:120,priority:"high",isCompleted:!1},{id:"a3",type:"contact_downliner",title:"Coach team member Kim",description:"Kim is close to qualifying for the next rank. A 15-minute coaching call can help them cross the threshold.",estimatedMinutes:15,priority:"medium",isCompleted:!1}],motivationalMessage:"Your consistent effort is building momentum — one action at a time!",progressSummary:"You are 2 actions away from your weekly goal."},progress:{currentStreak:5,completedActions:14,weeklyScore:78,rank:"Silver",nextMilestone:"Gold (3 more referrals)"}}},fields:[{id:"proMode",type:"toggle",label:"Pro mode (full chat history)",default:!1,group:"Display"},{id:"showProgressBar",type:"toggle",label:"Show progress bar",default:!0,group:"Display"},{id:"showMotivationalMessage",type:"toggle",label:"Show motivational message",default:!0,group:"Display"},{id:"maxActionsShown",type:"range",label:"Max actions shown",default:3,min:1,max:5,step:1,group:"Display"}],events:{emits:[{name:"gaio:actionCompleted",description:"User marked an action as completed"},{name:"gaio:messageSent",description:"User sent a coaching message (pro mode)"}],listens:[{name:"gaio:refresh",description:"Force refresh coaching plan"}]},supportedPlacements:["main","sidebar"]};function A({item:s,onToggle:r}){return e.jsxs("div",{className:`es-gaio__action es-gaio__action--${s.priority}${s.isCompleted?" es-gaio__action--completed":""}`,onClick:()=>r(s.id),role:"button",tabIndex:0,onKeyDown:n=>n.key==="Enter"&&r(s.id),children:[e.jsx("div",{className:"es-gaio__action-check",children:s.isCompleted?"✓":""}),e.jsxs("div",{className:"es-gaio__action-body",children:[e.jsx("div",{className:"es-gaio__action-title",children:s.title}),e.jsx("div",{className:"es-gaio__action-desc",children:s.description}),e.jsx("div",{className:"es-gaio__action-meta",children:e.jsxs("span",{className:"es-gaio__action-time",children:["~",s.estimatedMinutes,"m"]})})]})]})}function U({data:s,config:r,actions:n,baseUrl:f,productId:v,metadata:D,i18n:$}){const t=$?.t??(a=>a),p=r.proMode??!1,T=r.showProgressBar??!0,I=r.showMotivationalMessage??!0,j=r.maxActionsShown??3,d=s.plan,c=s.progress,[l,b]=i.useState([]),[h,u]=i.useState([]),[m,w]=i.useState(""),[g,k]=i.useState(!1),N=i.useRef(null);i.useEffect(()=>{d?.topActions&&b(d.topActions.slice(0,j))},[d,j]),i.useEffect(()=>{N.current?.scrollIntoView({behavior:"smooth"})},[h]);const S=i.useCallback(async a=>{b(_=>_.map(o=>o.id===a?{...o,isCompleted:!o.isCompleted}:o)),await n.call("complete",{actionId:a}).catch(()=>{}),n.emit("gaio:actionCompleted",{actionId:a})},[n]),M=i.useCallback(async()=>{const a=m.trim();if(!a||g)return;const _={id:`u-${Date.now()}`,role:"user",text:a};u(o=>[...o,_]),w(""),k(!0);try{const o=(await(await fetch(`${f}/api/widget/gaio/coach`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({productId:v,context:{dailyGoal:a}})})).json())?.data?.plan,y=o?.motivationalMessage??o?.progressSummary??t("gaio_coach.default_guidance"),P={id:`a-${Date.now()}`,role:"assistant",text:y};u(B=>[...B,P]),n.emit("gaio:messageSent",{text:a})}catch{const o={id:`e-${Date.now()}`,role:"assistant",text:t("gaio_coach.error_unreachable")};u(y=>[...y,o])}finally{k(!1)}},[m,g,f,v,n]);if(!d&&!s.error)return e.jsx(x,{blockType:"gaio-coach",children:e.jsxs("div",{className:"es-block__body",children:[e.jsx("div",{className:"es-gaio__header",children:e.jsx("span",{className:"es-gaio__title",children:t("gaio_coach.title")})}),e.jsx("div",{className:"es-gaio__motivation",style:{color:"var(--es-color-on-surface-muted, #4B5563)",fontStyle:"italic"},children:D?.dataQuality==="none"?t("gaio_coach.sign_in_prompt"):t("gaio_coach.preparing")}),[1,2,3].map(a=>e.jsxs("div",{className:"es-gaio__action",style:{opacity:.35},children:[e.jsx("div",{className:"es-gaio__action-check"}),e.jsx("div",{className:"es-gaio__action-body",children:e.jsx("div",{className:"es-gaio__action-title",style:{background:"var(--es-color-surface-elevated, #f5f5f5)",borderRadius:4,height:14,width:`${60+a*15}%`}})})]},a))]})});if(s.error)return e.jsx(x,{blockType:"gaio-coach",error:K(s.error)});const C=l.filter(a=>a.isCompleted).length,E=l.length>0?C/l.length*100:0;return e.jsx(x,{blockType:"gaio-coach",children:e.jsxs("div",{className:"es-block__body",children:[e.jsxs("div",{className:"es-gaio__header",children:[e.jsx("span",{className:"es-gaio__title",children:t("gaio_coach.title")}),c?.currentStreak!=null&&c.currentStreak>0&&e.jsxs("span",{className:"es-gaio__streak",children:["🔥 ",e.jsx("span",{className:"es-gaio__streak-value",children:c.currentStreak})," ",t("gaio_coach.day_streak")]})]}),T&&l.length>0&&e.jsxs("div",{className:"es-gaio__progress",children:[e.jsxs("div",{className:"es-gaio__progress-label",children:[e.jsx("span",{children:t("gaio_coach.todays_actions")}),e.jsxs("span",{children:[C,"/",l.length]})]}),e.jsx("div",{className:"es-gaio__progress-bar",children:e.jsx("div",{className:"es-gaio__progress-fill",style:{width:`${E}%`}})})]}),p&&c?.rank&&e.jsxs("div",{className:"es-gaio__summary-card",children:[e.jsxs("div",{className:"es-gaio__summary-rank",children:[t("gaio_coach.current_rank"),": ",O(c.rank,t)]}),c.nextMilestone&&e.jsxs("div",{className:"es-gaio__summary-milestone",children:[t("gaio_coach.next"),": ",c.nextMilestone]})]}),I&&d?.motivationalMessage&&e.jsx("div",{className:"es-gaio__motivation",children:d.motivationalMessage}),!p&&e.jsx("div",{className:"es-gaio__actions",children:l.map(a=>e.jsx(A,{item:a,onToggle:S},a.id))}),p&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"es-gaio__actions",children:l.map(a=>e.jsx(A,{item:a,onToggle:S},a.id))}),h.length>0&&e.jsxs("div",{className:"es-gaio__chat",children:[h.map(a=>e.jsx("div",{className:`es-gaio__chat-msg es-gaio__chat-msg--${a.role}`,children:a.text},a.id)),e.jsx("div",{ref:N})]}),e.jsxs("div",{className:"es-gaio__chat-input-row",children:[e.jsx("textarea",{className:"es-gaio__chat-input",rows:1,placeholder:t("gaio_coach.chat_placeholder"),value:m,onChange:a=>w(a.target.value),onKeyDown:a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),M())}}),e.jsx("button",{className:"es-gaio__chat-send",onClick:M,disabled:g||!m.trim(),children:g?"...":t("gaio_coach.chat_send")})]})]})]})})}export{U as Component,Q as manifest};
2
- //# sourceMappingURL=index-C1Fa-E3e-ZRnEJoQe.js.map
1
+ import{r as o,j as e,e as x,l as K}from"../nexly.js";import{m as O}from"./block-helpers-Cg_zAqG6-DnN2COvk.js";const U={slug:"gaio-coach",name:"GAIO Coach",version:"1.0.0",category:"interactive",requiredService:"gaio-coach",configSchema:{properties:{proMode:{type:"boolean",default:!1},showProgressBar:{type:"boolean",default:!0},showMotivationalMessage:{type:"boolean",default:!0},maxActionsShown:{type:"number",default:3}}},defaultConfig:{proMode:!1,showProgressBar:!0,showMotivationalMessage:!0,maxActionsShown:3},sizing:{minWidth:240,preferredHeight:"auto",scrollable:!0},dataContract:{serviceSlug:"gaio-coach",inputSchema:{type:"object",properties:{plan:{type:"object",properties:{date:{type:"string"},topActions:{type:"array",items:{type:"object",properties:{id:{type:"string"},title:{type:"string"}}}},motivationalMessage:{type:"string"},progressSummary:{type:"string"}}},progress:{type:"object",properties:{currentStreak:{type:"number"},completedActions:{type:"number"},weeklyScore:{type:"number"},rank:{type:"string"},nextMilestone:{type:"string"}}}}},previewDataOverride:{plan:{date:"2026-04-05",topActions:[{id:"a1",type:"recruit",title:"Connect with 3 prospects",description:"Reach out to your warm market list. Send personalized messages to 3 contacts who expressed interest.",estimatedMinutes:30,priority:"high",isCompleted:!1},{id:"a2",type:"attend_event",title:"Attend local networking event",description:"Seoul Tech Meetup at 7pm. Bring business cards and focus on making genuine connections.",estimatedMinutes:120,priority:"high",isCompleted:!1},{id:"a3",type:"contact_downliner",title:"Coach team member Kim",description:"Kim is close to qualifying for the next rank. A 15-minute coaching call can help them cross the threshold.",estimatedMinutes:15,priority:"medium",isCompleted:!1}],motivationalMessage:"Your consistent effort is building momentum — one action at a time!",progressSummary:"You are 2 actions away from your weekly goal."},progress:{currentStreak:5,completedActions:14,weeklyScore:78,rank:"Silver",nextMilestone:"Gold (3 more referrals)"}}},fields:[{id:"proMode",type:"toggle",label:"Pro mode (full chat history)",default:!1,group:"Display"},{id:"showProgressBar",type:"toggle",label:"Show progress bar",default:!0,group:"Display"},{id:"showMotivationalMessage",type:"toggle",label:"Show motivational message",default:!0,group:"Display"},{id:"maxActionsShown",type:"range",label:"Max actions shown",default:3,min:1,max:5,step:1,group:"Display"}],events:{emits:[{name:"gaio:actionCompleted",description:"User marked an action as completed"},{name:"gaio:messageSent",description:"User sent a coaching message (pro mode)"}],listens:[{name:"gaio:refresh",description:"Force refresh coaching plan"}]},supportedPlacements:["main","sidebar"]};function A({item:s,onToggle:r}){return e.jsxs("div",{className:`es-gaio__action es-gaio__action--${s.priority}${s.isCompleted?" es-gaio__action--completed":""}`,onClick:()=>r(s.id),role:"button",tabIndex:0,onKeyDown:n=>n.key==="Enter"&&r(s.id),children:[e.jsx("div",{className:"es-gaio__action-check",children:s.isCompleted?"✓":""}),e.jsxs("div",{className:"es-gaio__action-body",children:[e.jsx("div",{className:"es-gaio__action-title",children:s.title}),e.jsx("div",{className:"es-gaio__action-desc",children:s.description}),e.jsx("div",{className:"es-gaio__action-meta",children:e.jsxs("span",{className:"es-gaio__action-time",children:["~",s.estimatedMinutes,"m"]})})]})]})}function q({data:s,config:r,actions:n,baseUrl:f,productId:v,metadata:D,i18n:$}){const t=$?.t??(a=>a),p=r.proMode??!1,T=r.showProgressBar??!0,I=r.showMotivationalMessage??!0,j=r.maxActionsShown??3,d=s.plan,c=s.progress,[l,b]=o.useState([]),[h,u]=o.useState([]),[m,w]=o.useState(""),[g,k]=o.useState(!1),N=o.useRef(null);o.useEffect(()=>{d?.topActions&&b(d.topActions.slice(0,j))},[d,j]),o.useEffect(()=>{N.current?.scrollIntoView({behavior:"smooth"})},[h]);const S=o.useCallback(async a=>{b(_=>_.map(i=>i.id===a?{...i,isCompleted:!i.isCompleted}:i)),await n.call("complete",{actionId:a}).catch(()=>{}),n.emit("gaio:actionCompleted",{actionId:a})},[n]),M=o.useCallback(async()=>{const a=m.trim();if(!a||g)return;const _={id:`u-${Date.now()}`,role:"user",text:a};u(i=>[...i,_]),w(""),k(!0);try{const i=(await(await fetch(`${f}/api/widget/gaio/coach`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({productId:v,context:{dailyGoal:a}})})).json())?.data?.plan,y=i?.motivationalMessage??i?.progressSummary??t("gaio_coach.default_guidance"),P={id:`a-${Date.now()}`,role:"assistant",text:y};u(B=>[...B,P]),n.emit("gaio:messageSent",{text:a})}catch{const i={id:`e-${Date.now()}`,role:"assistant",text:t("gaio_coach.error_unreachable")};u(y=>[...y,i])}finally{k(!1)}},[m,g,f,v,n]);if(!d&&!s.error)return e.jsx(x,{blockType:"gaio-coach",children:e.jsxs("div",{className:"es-block__body",children:[e.jsx("div",{className:"es-gaio__header",children:e.jsx("span",{className:"es-gaio__title",children:t("gaio_coach.title")})}),e.jsx("div",{className:"es-gaio__motivation",style:{color:"var(--es-color-on-surface-muted, #4B5563)",fontStyle:"italic"},children:D?.dataQuality==="none"?t("gaio_coach.sign_in_prompt"):t("gaio_coach.preparing")}),[1,2,3].map(a=>e.jsxs("div",{className:"es-gaio__action",style:{opacity:.35},children:[e.jsx("div",{className:"es-gaio__action-check"}),e.jsx("div",{className:"es-gaio__action-body",children:e.jsx("div",{className:"es-gaio__action-title",style:{background:"var(--es-color-surface-elevated, #f5f5f5)",borderRadius:4,height:14,width:`${60+a*15}%`}})})]},a))]})});if(s.error)return e.jsx(x,{blockType:"gaio-coach",error:K(s.error)});const C=l.filter(a=>a.isCompleted).length,E=l.length>0?C/l.length*100:0;return e.jsx(x,{blockType:"gaio-coach",children:e.jsxs("div",{className:"es-block__body",children:[e.jsxs("div",{className:"es-gaio__header",children:[e.jsx("span",{className:"es-gaio__title",children:t("gaio_coach.title")}),c?.currentStreak!=null&&c.currentStreak>0&&e.jsxs("span",{className:"es-gaio__streak",children:["🔥 ",e.jsx("span",{className:"es-gaio__streak-value",children:c.currentStreak})," ",t("gaio_coach.day_streak")]})]}),T&&l.length>0&&e.jsxs("div",{className:"es-gaio__progress",children:[e.jsxs("div",{className:"es-gaio__progress-label",children:[e.jsx("span",{children:t("gaio_coach.todays_actions")}),e.jsxs("span",{children:[C,"/",l.length]})]}),e.jsx("div",{className:"es-gaio__progress-bar",children:e.jsx("div",{className:"es-gaio__progress-fill",style:{width:`${E}%`}})})]}),p&&c?.rank&&e.jsxs("div",{className:"es-gaio__summary-card",children:[e.jsxs("div",{className:"es-gaio__summary-rank",children:[t("gaio_coach.current_rank"),": ",O(c.rank,t)]}),c.nextMilestone&&e.jsxs("div",{className:"es-gaio__summary-milestone",children:[t("gaio_coach.next"),": ",c.nextMilestone]})]}),I&&d?.motivationalMessage&&e.jsx("div",{className:"es-gaio__motivation",children:d.motivationalMessage}),!p&&e.jsx("div",{className:"es-gaio__actions",children:l.map(a=>e.jsx(A,{item:a,onToggle:S},a.id))}),p&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"es-gaio__actions",children:l.map(a=>e.jsx(A,{item:a,onToggle:S},a.id))}),h.length>0&&e.jsxs("div",{className:"es-gaio__chat",children:[h.map(a=>e.jsx("div",{className:`es-gaio__chat-msg es-gaio__chat-msg--${a.role}`,children:a.text},a.id)),e.jsx("div",{ref:N})]}),e.jsxs("div",{className:"es-gaio__chat-input-row",children:[e.jsx("textarea",{className:"es-gaio__chat-input",rows:1,placeholder:t("gaio_coach.chat_placeholder"),value:m,onChange:a=>w(a.target.value),onKeyDown:a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),M())}}),e.jsx("button",{className:"es-gaio__chat-send",onClick:M,disabled:g||!m.trim(),children:g?"...":t("gaio_coach.chat_send")})]})]})]})})}export{q as Component,U as manifest};
2
+ //# sourceMappingURL=index-BmajLlTC-qsVnaLmo.js.map
@@ -1,2 +1,2 @@
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-DaW9uf4--pkywvGDF.js.map
1
+ import{r as d,j as e,e 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-BtBJMXR--DWm0RYZF.js.map
@@ -1,2 +1,2 @@
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-CF37rhgu-BcW8HKb8.js.map
1
+ import{j as e,e 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-Bz-3E3Sa-B9PuY2Gx.js.map
@@ -1,2 +1,2 @@
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-qN6oEHVu-C_0Ll4qr.js.map
1
+ import{r as l,j as e,e 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-nfRNslCS.js";import"./_commonjsHelpers-C6fGbg64-BC8KDfbh.js";const $={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 J({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{J as Component,$ as manifest};
2
+ //# sourceMappingURL=index-CM2ok1Hp-k8zxZkfU.js.map
@@ -1,2 +1,2 @@
1
- import{r as i,a as j,j as e,Q as B}from"../nexly.js";const z={slug:"auth-login",name:"User Login",version:"1.0.0",category:"interactive",requiredService:"",configSchema:{properties:{loginMethod:{type:"string",default:"password"},showGuestOption:{type:"boolean",default:!0},submitLabel:{type:"string",default:""}}},defaultConfig:{loginMethod:"password",showGuestOption:!0,submitLabel:""},dataContract:{serviceSlug:"chat-bot",inputSchema:{type:"object",properties:{authenticated:{type:"boolean"}}},previewDataOverride:{authenticated:!1}},fields:[{id:"loginMethod",type:"select",label:"Login method",default:"password",options:[{label:"Password",value:"password"},{label:"Magic Link",value:"magic-link"},{label:"Guest",value:"guest"}],group:"Behavior"},{id:"showGuestOption",type:"toggle",label:"Show guest login option",default:!0,group:"Behavior"},{id:"submitLabel",type:"localized-text",label:"Submit button label",default:"",placeholder:'Leave empty to use translated default (e.g. "Login")',group:"Content"}],events:{emits:[{name:"auth:login",description:"User successfully logged in — carries { user, accessToken }"},{name:"auth:loginFailed",description:"Login attempt failed"},{name:"auth:guestContinued",description:"User chose to continue as guest"}],listens:[{name:"auth:reset",description:"Reset the login form"}]},supportedPlacements:["main"],sizing:{minWidth:280,preferredHeight:"auto",scrollable:!1}};function L({config:u,actions:s,i18n:d}){const r=d?.t??(o=>o),h=d?.currentLanguage??"en",[p,m]=i.useState(""),[g,y]=i.useState(""),[b,v]=i.useState(""),[l,n]=i.useState(!1),[c,t]=i.useState(null),f=u.loginMethod??"password",x=u.showGuestOption??!0,w=j(u.submitLabel,h,{t:r,fallbackKey:"auth.login.submit",enDefault:"Login"});async function S(o){o.preventDefault(),n(!0),t(null);try{let a;f==="api_key"?a=await s.call("login",{apiKey:p}):a=await s.call("login",{email:g,password:b}),a?.error?t({error:a.error}):(s.emit("auth:login",{user:a.user,accessToken:a.accessToken}),t({success:!0,user:a?.user}))}catch{t({error:r("auth.login.error_failed")})}finally{n(!1)}}async function k(){n(!0),t(null);try{const o=await s.call("login",{guest:!0});o?.error?t({error:o.error}):(s.emit("auth:login",{user:o.user}),t({success:!0}))}catch{t({error:r("auth.login.error_guest_failed")})}finally{n(!1)}}return c?.success?null:e.jsx(B,{blockType:"auth-login",children:e.jsxs("div",{className:"es-block__body",style:{padding:16},children:[e.jsxs("form",{onSubmit:S,children:[f==="api_key"?e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"var(--es-color-on-surface-muted, #4B5563)",marginBottom:4},children:r("auth.login.api_key_label")}),e.jsx("input",{type:"text",value:p,onChange:o=>m(o.target.value),placeholder:"eu_live_...",required:!0,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"1px solid var(--es-color-control-border, #6B7280)",background:"var(--es-color-surface-elevated, #f5f5f5)",color:"var(--es-color-on-surface, #1a1a1a)",fontSize:14,outline:"none",fontFamily:"monospace",boxSizing:"border-box"}})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"var(--es-color-on-surface-muted, #4B5563)",marginBottom:4},children:r("auth.email_label")}),e.jsx("input",{type:"email",value:g,onChange:o=>y(o.target.value),placeholder:r("auth.email_placeholder"),required:!0,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"1px solid var(--es-color-control-border, #6B7280)",background:"var(--es-color-surface-elevated, #f5f5f5)",color:"var(--es-color-on-surface, #1a1a1a)",fontSize:14,outline:"none",boxSizing:"border-box"}})]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"var(--es-color-on-surface-muted, #4B5563)",marginBottom:4},children:r("auth.password_label")}),e.jsx("input",{type:"password",value:b,onChange:o=>v(o.target.value),placeholder:r("auth.password_placeholder"),required:!0,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"1px solid var(--es-color-control-border, #6B7280)",background:"var(--es-color-surface-elevated, #f5f5f5)",color:"var(--es-color-on-surface, #1a1a1a)",fontSize:14,outline:"none",boxSizing:"border-box"}})]})]}),c?.error&&e.jsx("div",{style:{fontSize:12,color:"var(--es-color-error, #AD2C26)",marginBottom:8},children:c.error}),e.jsx("button",{type:"submit",disabled:l,style:{width:"100%",padding:"10px 16px",borderRadius:6,border:"none",background:l?"var(--es-color-on-surface-muted, #4B5563)":"var(--es-color-primary, #2563EB)",color:"var(--es-color-on-primary, #ffffff)",fontSize:14,fontWeight:600,cursor:l?"wait":"pointer"},children:l?r("auth.login.submitting"):w})]}),x&&e.jsx("button",{type:"button",onClick:k,disabled:l,style:{width:"100%",marginTop:8,padding:"8px 16px",borderRadius:6,border:"1px solid var(--es-color-control-border, #6B7280)",background:"transparent",color:"var(--es-color-on-surface-muted, #4B5563)",fontSize:13,cursor:l?"wait":"pointer"},children:r("auth.gate.guest_cta")})]})})}export{L as Component,z as manifest};
2
- //# sourceMappingURL=index-COfQIa8G-D6wzHiS0.js.map
1
+ import{r as i,L as B,j as e,e as j}from"../nexly.js";const z={slug:"auth-login",name:"User Login",version:"1.0.0",category:"interactive",requiredService:"",configSchema:{properties:{loginMethod:{type:"string",default:"password"},showGuestOption:{type:"boolean",default:!0},submitLabel:{type:"string",default:""}}},defaultConfig:{loginMethod:"password",showGuestOption:!0,submitLabel:""},dataContract:{serviceSlug:"chat-bot",inputSchema:{type:"object",properties:{authenticated:{type:"boolean"}}},previewDataOverride:{authenticated:!1}},fields:[{id:"loginMethod",type:"select",label:"Login method",default:"password",options:[{label:"Password",value:"password"},{label:"Magic Link",value:"magic-link"},{label:"Guest",value:"guest"}],group:"Behavior"},{id:"showGuestOption",type:"toggle",label:"Show guest login option",default:!0,group:"Behavior"},{id:"submitLabel",type:"localized-text",label:"Submit button label",default:"",placeholder:'Leave empty to use translated default (e.g. "Login")',group:"Content"}],events:{emits:[{name:"auth:login",description:"User successfully logged in — carries { user, accessToken }"},{name:"auth:loginFailed",description:"Login attempt failed"},{name:"auth:guestContinued",description:"User chose to continue as guest"}],listens:[{name:"auth:reset",description:"Reset the login form"}]},supportedPlacements:["main"],sizing:{minWidth:280,preferredHeight:"auto",scrollable:!1}};function L({config:u,actions:s,i18n:d}){const r=d?.t??(o=>o),h=d?.currentLanguage??"en",[p,m]=i.useState(""),[g,y]=i.useState(""),[b,v]=i.useState(""),[l,n]=i.useState(!1),[c,t]=i.useState(null),f=u.loginMethod??"password",x=u.showGuestOption??!0,w=B(u.submitLabel,h,{t:r,fallbackKey:"auth.login.submit",enDefault:"Login"});async function S(o){o.preventDefault(),n(!0),t(null);try{let a;f==="api_key"?a=await s.call("login",{apiKey:p}):a=await s.call("login",{email:g,password:b}),a?.error?t({error:a.error}):(s.emit("auth:login",{user:a.user,accessToken:a.accessToken}),t({success:!0,user:a?.user}))}catch{t({error:r("auth.login.error_failed")})}finally{n(!1)}}async function k(){n(!0),t(null);try{const o=await s.call("login",{guest:!0});o?.error?t({error:o.error}):(s.emit("auth:login",{user:o.user}),t({success:!0}))}catch{t({error:r("auth.login.error_guest_failed")})}finally{n(!1)}}return c?.success?null:e.jsx(j,{blockType:"auth-login",children:e.jsxs("div",{className:"es-block__body",style:{padding:16},children:[e.jsxs("form",{onSubmit:S,children:[f==="api_key"?e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"var(--es-color-on-surface-muted, #4B5563)",marginBottom:4},children:r("auth.login.api_key_label")}),e.jsx("input",{type:"text",value:p,onChange:o=>m(o.target.value),placeholder:"eu_live_...",required:!0,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"1px solid var(--es-color-control-border, #6B7280)",background:"var(--es-color-surface-elevated, #f5f5f5)",color:"var(--es-color-on-surface, #1a1a1a)",fontSize:14,outline:"none",fontFamily:"monospace",boxSizing:"border-box"}})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"var(--es-color-on-surface-muted, #4B5563)",marginBottom:4},children:r("auth.email_label")}),e.jsx("input",{type:"email",value:g,onChange:o=>y(o.target.value),placeholder:r("auth.email_placeholder"),required:!0,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"1px solid var(--es-color-control-border, #6B7280)",background:"var(--es-color-surface-elevated, #f5f5f5)",color:"var(--es-color-on-surface, #1a1a1a)",fontSize:14,outline:"none",boxSizing:"border-box"}})]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"var(--es-color-on-surface-muted, #4B5563)",marginBottom:4},children:r("auth.password_label")}),e.jsx("input",{type:"password",value:b,onChange:o=>v(o.target.value),placeholder:r("auth.password_placeholder"),required:!0,style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"1px solid var(--es-color-control-border, #6B7280)",background:"var(--es-color-surface-elevated, #f5f5f5)",color:"var(--es-color-on-surface, #1a1a1a)",fontSize:14,outline:"none",boxSizing:"border-box"}})]})]}),c?.error&&e.jsx("div",{style:{fontSize:12,color:"var(--es-color-error, #AD2C26)",marginBottom:8},children:c.error}),e.jsx("button",{type:"submit",disabled:l,style:{width:"100%",padding:"10px 16px",borderRadius:6,border:"none",background:l?"var(--es-color-on-surface-muted, #4B5563)":"var(--es-color-primary, #2563EB)",color:"var(--es-color-on-primary, #ffffff)",fontSize:14,fontWeight:600,cursor:l?"wait":"pointer"},children:l?r("auth.login.submitting"):w})]}),x&&e.jsx("button",{type:"button",onClick:k,disabled:l,style:{width:"100%",marginTop:8,padding:"8px 16px",borderRadius:6,border:"1px solid var(--es-color-control-border, #6B7280)",background:"transparent",color:"var(--es-color-on-surface-muted, #4B5563)",fontSize:13,cursor:l?"wait":"pointer"},children:r("auth.gate.guest_cta")})]})})}export{L as Component,z as manifest};
2
+ //# sourceMappingURL=index-CMdx7oFx-bh6F7tw3.js.map
@@ -1,2 +1,2 @@
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-D1YmJ3gf-3B-eE3K7.js.map
1
+ import{j as e,e 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-COobDdoM-BZw4n83V.js.map
@@ -1,2 +1,2 @@
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-DAICBUgn-DBhSkJ7i.js.map
1
+ import{r as x,j as e,e 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-CQCPJl3S-CV5ZiVsD.js.map
@@ -1,6 +1,6 @@
1
- import{r as s,j as e,a as De,b as te,Q as it}from"../nexly.js";import{x as Ke,s as Oe,c as Ue,a as We}from"./allowed-elements-BXnLJV1S-C-_lr2zm.js";import{H as ot,P as ct}from"./use-deferred-rating-XlgCUwcY-DDVOwURi.js";import{r as Fe}from"./inert-assistant-components-B6Cx9pG5-DWb6n3Yq.js";import"./_commonjsHelpers-C6fGbg64-BC8KDfbh.js";const Nt={slug:"chat",name:"Chat",version:"1.0.0",category:"interactive",requiredService:"chat-bot",configSchema:{properties:{placeholder:{type:"string",default:""},welcomeMessage:{type:"string",default:""}}},defaultConfig:{placeholder:"",welcomeMessage:""},dataContract:{serviceSlug:"chat-bot",inputSchema:{type:"object",properties:{message:{type:"string",description:"AI response text"},suggestions:{type:"array",items:{type:"string"},description:"Suggested follow-up questions"}},required:["message"]},previewDataOverride:{message:"Hello! I can help you find the perfect product. What are you looking for today?",suggestions:["Show me trending items","Compare prices for me","Find deals under $50"]}},fields:[{id:"placeholder",type:"localized-text",label:"Input placeholder",default:"",placeholder:'Leave empty to use translated default (e.g. "Type a message...")',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?")',group:"Content"},{id:"showSuggestions",type:"toggle",label:"Show suggestions",default:!0,group:"Behavior"}],events:{emits:[{name:"chat:messageSent",description:"User sent a message"},{name:"chat:messageReceived",description:"AI response received"}],listens:[{name:"chat:clearHistory",description:"Clear chat history"}]},sizing:{minWidth:240,preferredHeight:"fill",scrollable:!0},supportedPlacements:["main","fullscreen"]},lt=["audio/webm;codecs=opus","audio/webm","audio/mp4"];function ut(){return typeof navigator>"u"||typeof window>"u"?!1:typeof navigator.mediaDevices?.getUserMedia=="function"&&typeof window.MediaRecorder<"u"}function dt(){if(typeof window>"u"||typeof window.MediaRecorder>"u")return;const o=typeof window.MediaRecorder.isTypeSupported=="function";for(const i of lt)if(!o||window.MediaRecorder.isTypeSupported(i))return i}function ht({baseUrl:o,apiKey:i,jwt:n,language:p,onTranscript:w,t:b,disabled:y=!1,streaming:j,voiceStream:g,baseText:U,onText:S}){const[r]=s.useState(ut),[u,m]=s.useState("idle"),[G,H]=s.useState(null),[f,z]=s.useState("idle"),I=!!(j&&g&&U&&S),$=s.useRef(null),E=s.useRef(null),k=s.useRef([]),F=s.useRef(!0);s.useEffect(()=>()=>{F.current=!1},[]);const d=s.useRef({baseUrl:o,apiKey:i,jwt:n,language:p,onTranscript:w});s.useEffect(()=>{d.current={baseUrl:o,apiKey:i,jwt:n,language:p,onTranscript:w}},[o,i,n,p,w]);const c=s.useCallback(()=>{E.current?.getTracks().forEach(_=>_.stop()),E.current=null,$.current=null,k.current=[]},[]);s.useEffect(()=>c,[c]);const h=s.useRef(()=>{});h.current=()=>{I&&(f==="connecting"||f==="listening")&&g?.stop()},s.useEffect(()=>()=>h.current(),[]);const T=s.useCallback(async _=>{const{baseUrl:V,apiKey:C,jwt:M,language:v,onTranscript:J}=d.current,R=new FormData;R.append("audio",_,"recording.webm"),R.append("language",v);const Q={};C&&(Q["X-API-Key"]=C),M&&(Q.Authorization=`Bearer ${M}`);const ee=await fetch(`${V}/api/widget/transcribe`,{method:"POST",headers:Q,credentials:"include",body:R});if(!ee.ok){const ae=new Error(`HTTP ${ee.status}`);throw ae.status=ee.status,ae}const le=await ee.json();J(le.text??"")},[]),K=s.useCallback(async()=>{H(null);let _;try{_=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{m("error"),H("voice.permission_denied");return}const V=dt();let C;try{C=V?new MediaRecorder(_,{mimeType:V}):new MediaRecorder(_)}catch{_.getTracks().forEach(M=>M.stop()),m("error"),H("voice.error_generic");return}E.current=_,$.current=C,k.current=[],C.ondataavailable=M=>{M.data&&M.data.size>0&&k.current.push(M.data)},C.onstop=async()=>{const M=C.mimeType||V||"audio/webm",v=new Blob(k.current,{type:M});if(c(),v.size===0){m("idle");return}m("transcribing");try{if(await T(v),!F.current)return;m("idle"),H(null)}catch(J){if(!F.current)return;const R=J.status;m("error"),H(R===413?"voice.error_too_large":"voice.error_generic")}},C.start(),m("recording")},[c,T]),ce=s.useCallback(()=>{const _=$.current;_&&_.state!=="inactive"?_.stop():(c(),m("idle"))},[c]),se=s.useCallback(()=>{r&&(I?f==="connecting"||f==="listening"?(g.stop(),z("idle")):(H(null),g.start({language:p,baseText:U,onText:S,onState:_=>z(_),onError:_=>{H(_),z("error")}})):u==="recording"?ce():(u==="idle"||u==="error")&&K())},[r,I,f,u,p,U,S,g,K,ce]);if(!r)return null;const L=I?f==="connecting"||f==="listening":u==="recording",D=!I&&u==="transcribing",ge=I?f==="error":u==="error",q=b(L?"voice.stop":"voice.start"),me=G?b(G):D?b("voice.transcribing"):q,Z=["es-chat__mic",L&&"es-chat__mic--recording",D&&"es-chat__mic--transcribing",ge&&"es-chat__mic--error"].filter(Boolean).join(" ");return e.jsx("button",{type:"button",className:Z,onClick:se,disabled:D||y,"aria-label":q,"aria-pressed":L,title:me,children:D?e.jsx("svg",{width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"es-chat__mic-spinner","aria-hidden":"true",children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}):L?e.jsx("svg",{width:18,height:18,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})}):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("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"}),e.jsx("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),e.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"22"})]})})}function pt({size:o=16}){return e.jsxs("svg",{width:o,height:o,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:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]})}function gt({size:o=18}){return e.jsxs("svg",{width:o,height:o,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"})]})}function mt({size:o=13}){return e.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"m2 2 20 20"}),e.jsx("path",{d:"M8.5 8.5 7 10a5 5 0 0 0 7 7l1.5-1.5"}),e.jsx("path",{d:"M15.5 15.5 17 14a5 5 0 0 0-7-7l-1.5 1.5"})]})}function ft({value:o,onChange:i,disabled:n,t:p}){const[w,b]=s.useState(null),y=o??0,j=!n&&w!==null?w:y;return e.jsxs("div",{className:"es-chat__rating-group",children:[e.jsx("div",{className:"es-chat__rating",role:"radiogroup","aria-label":p("support_chat.rate_aria"),onMouseLeave:()=>!n&&b(null),children:[1,2,3,4,5].map(g=>{const U=g<=j;return e.jsx("button",{type:"button",role:"radio","aria-checked":g===y,"aria-label":p("support_chat.rate_star",{count:g}),disabled:n,onMouseEnter:()=>!n&&b(g),onFocus:()=>!n&&b(g),onBlur:()=>!n&&b(null),onClick:()=>!n&&i?.(g),className:`es-chat__rating-star${U?" es-chat__rating-star--filled":""}${n?" es-chat__rating-star--disabled":""}`,children:e.jsx("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:U?"currentColor":"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.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)})}),e.jsx("span",{className:"es-chat__rating-label","aria-live":"polite",children:j>0?p(`support_chat.rate_label_${j}`):""})]})}function ze(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}const _t=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,bt=45e3,yt=/https?:\/\/\S+/i;function xt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function jt(o){let i=null;const n=[];for(const p of o.split(`
1
+ import{r as s,j as e,L as Re,K as te,e as it}from"../nexly.js";import{x as ze,s as Oe,c as Ue,a as We}from"./allowed-elements-C0OfX2zF-DIBV8lKu.js";import{H as ot,P as ct}from"./use-deferred-rating-XlgCUwcY-DDVOwURi.js";import{r as Fe}from"./inert-assistant-components-B6Cx9pG5-DWb6n3Yq.js";import"./_commonjsHelpers-C6fGbg64-BC8KDfbh.js";const Nt={slug:"chat",name:"Chat",version:"1.0.0",category:"interactive",requiredService:"chat-bot",configSchema:{properties:{placeholder:{type:"string",default:""},welcomeMessage:{type:"string",default:""}}},defaultConfig:{placeholder:"",welcomeMessage:""},dataContract:{serviceSlug:"chat-bot",inputSchema:{type:"object",properties:{message:{type:"string",description:"AI response text"},suggestions:{type:"array",items:{type:"string"},description:"Suggested follow-up questions"}},required:["message"]},previewDataOverride:{message:"Hello! I can help you find the perfect product. What are you looking for today?",suggestions:["Show me trending items","Compare prices for me","Find deals under $50"]}},fields:[{id:"placeholder",type:"localized-text",label:"Input placeholder",default:"",placeholder:'Leave empty to use translated default (e.g. "Type a message...")',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?")',group:"Content"},{id:"showSuggestions",type:"toggle",label:"Show suggestions",default:!0,group:"Behavior"}],events:{emits:[{name:"chat:messageSent",description:"User sent a message"},{name:"chat:messageReceived",description:"AI response received"}],listens:[{name:"chat:clearHistory",description:"Clear chat history"}]},sizing:{minWidth:240,preferredHeight:"fill",scrollable:!0},supportedPlacements:["main","fullscreen"]},lt=["audio/webm;codecs=opus","audio/webm","audio/mp4"];function ut(){return typeof navigator>"u"||typeof window>"u"?!1:typeof navigator.mediaDevices?.getUserMedia=="function"&&typeof window.MediaRecorder<"u"}function dt(){if(typeof window>"u"||typeof window.MediaRecorder>"u")return;const o=typeof window.MediaRecorder.isTypeSupported=="function";for(const i of lt)if(!o||window.MediaRecorder.isTypeSupported(i))return i}function ht({baseUrl:o,apiKey:i,jwt:n,language:p,onTranscript:w,t:b,disabled:y=!1,streaming:j,voiceStream:g,baseText:U,onText:S}){const[r]=s.useState(ut),[u,m]=s.useState("idle"),[Z,H]=s.useState(null),[f,D]=s.useState("idle"),I=!!(j&&g&&U&&S),$=s.useRef(null),E=s.useRef(null),k=s.useRef([]),F=s.useRef(!0);s.useEffect(()=>()=>{F.current=!1},[]);const d=s.useRef({baseUrl:o,apiKey:i,jwt:n,language:p,onTranscript:w});s.useEffect(()=>{d.current={baseUrl:o,apiKey:i,jwt:n,language:p,onTranscript:w}},[o,i,n,p,w]);const c=s.useCallback(()=>{E.current?.getTracks().forEach(_=>_.stop()),E.current=null,$.current=null,k.current=[]},[]);s.useEffect(()=>c,[c]);const h=s.useRef(()=>{});h.current=()=>{I&&(f==="connecting"||f==="listening")&&g?.stop()},s.useEffect(()=>()=>h.current(),[]);const T=s.useCallback(async _=>{const{baseUrl:V,apiKey:C,jwt:M,language:v,onTranscript:J}=d.current,K=new FormData;K.append("audio",_,"recording.webm"),K.append("language",v);const Y={};C&&(Y["X-API-Key"]=C),M&&(Y.Authorization=`Bearer ${M}`);const ee=await fetch(`${V}/api/widget/transcribe`,{method:"POST",headers:Y,credentials:"include",body:K});if(!ee.ok){const ae=new Error(`HTTP ${ee.status}`);throw ae.status=ee.status,ae}const le=await ee.json();J(le.text??"")},[]),z=s.useCallback(async()=>{H(null);let _;try{_=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{m("error"),H("voice.permission_denied");return}const V=dt();let C;try{C=V?new MediaRecorder(_,{mimeType:V}):new MediaRecorder(_)}catch{_.getTracks().forEach(M=>M.stop()),m("error"),H("voice.error_generic");return}E.current=_,$.current=C,k.current=[],C.ondataavailable=M=>{M.data&&M.data.size>0&&k.current.push(M.data)},C.onstop=async()=>{const M=C.mimeType||V||"audio/webm",v=new Blob(k.current,{type:M});if(c(),v.size===0){m("idle");return}m("transcribing");try{if(await T(v),!F.current)return;m("idle"),H(null)}catch(J){if(!F.current)return;const K=J.status;m("error"),H(K===413?"voice.error_too_large":"voice.error_generic")}},C.start(),m("recording")},[c,T]),ce=s.useCallback(()=>{const _=$.current;_&&_.state!=="inactive"?_.stop():(c(),m("idle"))},[c]),se=s.useCallback(()=>{r&&(I?f==="connecting"||f==="listening"?(g.stop(),D("idle")):(H(null),g.start({language:p,baseText:U,onText:S,onState:_=>D(_),onError:_=>{H(_),D("error")}})):u==="recording"?ce():(u==="idle"||u==="error")&&z())},[r,I,f,u,p,U,S,g,z,ce]);if(!r)return null;const L=I?f==="connecting"||f==="listening":u==="recording",R=!I&&u==="transcribing",ge=I?f==="error":u==="error",q=b(L?"voice.stop":"voice.start"),me=Z?b(Z):R?b("voice.transcribing"):q,Q=["es-chat__mic",L&&"es-chat__mic--recording",R&&"es-chat__mic--transcribing",ge&&"es-chat__mic--error"].filter(Boolean).join(" ");return e.jsx("button",{type:"button",className:Q,onClick:se,disabled:R||y,"aria-label":q,"aria-pressed":L,title:me,children:R?e.jsx("svg",{width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"es-chat__mic-spinner","aria-hidden":"true",children:e.jsx("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})}):L?e.jsx("svg",{width:18,height:18,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:e.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})}):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("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"}),e.jsx("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),e.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"22"})]})})}function pt({size:o=16}){return e.jsxs("svg",{width:o,height:o,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:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]})}function gt({size:o=18}){return e.jsxs("svg",{width:o,height:o,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"})]})}function mt({size:o=13}){return e.jsxs("svg",{width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("path",{d:"m2 2 20 20"}),e.jsx("path",{d:"M8.5 8.5 7 10a5 5 0 0 0 7 7l1.5-1.5"}),e.jsx("path",{d:"M15.5 15.5 17 14a5 5 0 0 0-7-7l-1.5 1.5"})]})}function ft({value:o,onChange:i,disabled:n,t:p}){const[w,b]=s.useState(null),y=o??0,j=!n&&w!==null?w:y;return e.jsxs("div",{className:"es-chat__rating-group",children:[e.jsx("div",{className:"es-chat__rating",role:"radiogroup","aria-label":p("support_chat.rate_aria"),onMouseLeave:()=>!n&&b(null),children:[1,2,3,4,5].map(g=>{const U=g<=j;return e.jsx("button",{type:"button",role:"radio","aria-checked":g===y,"aria-label":p("support_chat.rate_star",{count:g}),disabled:n,onMouseEnter:()=>!n&&b(g),onFocus:()=>!n&&b(g),onBlur:()=>!n&&b(null),onClick:()=>!n&&i?.(g),className:`es-chat__rating-star${U?" es-chat__rating-star--filled":""}${n?" es-chat__rating-star--disabled":""}`,children:e.jsx("svg",{width:16,height:16,viewBox:"0 0 24 24",fill:U?"currentColor":"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.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)})}),e.jsx("span",{className:"es-chat__rating-label","aria-live":"polite",children:j>0?p(`support_chat.rate_label_${j}`):""})]})}function De(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}const _t=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,bt=45e3,yt=/https?:\/\/\S+/i;function xt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function jt(o){let i=null;const n=[];for(const p of o.split(`
2
2
  `))p.startsWith("event:")?i=p.slice(6).trim():p.startsWith("data:")&&n.push(p.slice(5).trimStart());return{event:i,data:n.join(`
3
- `)}}function It({config:o,actions:i,baseUrl:n,i18n:p,auth:w,externalContext:b,productId:y,sessionId:j,sessionMessages:g,readOnly:U}){const S=U===!0,r=p?.t??(t=>t),u=b?.apiKey??"",m=p?.currentLanguage??"en",G=De(o.placeholder,m,{t:r,fallbackKey:"chat.input_placeholder",enDefault:"Type a message..."}),H=De(o.welcomeMessage,m,{t:r,fallbackKey:"chat.empty_state",enDefault:["Hi! How can I help you?","Hello! How can I help you?"]}),f=typeof o._draft=="string"?o._draft:void 0,z=typeof o._draftContext=="string"?o._draftContext:void 0,I=o._autoSend===!0,$=Array.isArray(o._quickChips)?o._quickChips:[],E=JSON.stringify($),k=s.useRef(w?.jwt);s.useEffect(()=>{k.current=w?.jwt},[w?.jwt]);const F=b?.voice,d=!!F?.enabled&&(F?.languages??[]).includes(m),[c,h]=s.useState(()=>g?.map(t=>({id:t.id,role:t.role,text:t.content}))??[]),[T,K]=s.useState(""),[ce,se]=s.useState([]),[L,D]=s.useState(!1),[ge,q]=s.useState(null),[me,Z]=s.useState(!1),{containerRef:_,isPinned:V,scrollToBottom:C,stickToBottom:M}=ot(),v=s.useRef(null),J=s.useRef(null),R=s.useRef(j??ze()),Q=s.useRef(g&&g.length>0?j??null:null),ee=s.useRef(null),le=s.useRef(void 0),ae=s.useRef(!1);s.useEffect(()=>{i.emit("chat:session",{sessionId:R.current})},[i]),s.useEffect(()=>{M()},[c,L,M]);const be=s.useCallback(()=>{const t=v.current;if(!t)return;const a=t.closest(".es-block")?.clientHeight??0,l=a>0?Math.round(a*.4):120;t.style.height="auto",t.style.height=`${Math.min(t.scrollHeight,l)}px`,t.style.overflowY=t.scrollHeight>l?"auto":"hidden"},[]);s.useLayoutEffect(()=>{be()},[T,be]);const re=s.useCallback(()=>{ae.current&&(ae.current=!1,i.emit("chat:draftConsumed",void 0))},[i]),ne=s.useCallback(async t=>{const a=t.trim();if(!a||L)return;re();const l=le.current;le.current=void 0,se([]),Z(!1),J.current?.abort(),J.current=new AbortController;const A=yt.test(a),B=`user-${Date.now()}`,X={id:B,role:"user",text:a,...A?{linkStatus:"reading",linkFailedCount:0}:{}};h(x=>[...x,X]);const O=()=>{A&&h(x=>x.map(W=>W.id===B&&W.linkStatus==="reading"?{...W,linkStatus:"done"}:W))};C(),K(""),D(!0),q(null),v.current&&(v.current.style.height="auto");const N=c.map(x=>({role:x.role,content:x.text})),Te=await w?.ensureValidToken?.()??k.current,st={"Content-Type":"application/json",...u?{"X-API-Key":u}:{},...Te?{Authorization:`Bearer ${Te}`}:{}},ue=`assistant-${Date.now()}`;let ie="",Le=!1,xe=!1;const Ae=()=>{xe||(xe=!0,q(ue),h(x=>[...x,{id:ue,role:"assistant",text:ie}]))},Be=R.current,Pe=_t.test(Be)?Be:void 0,He=xt(),[je,ke]=await te(fetch(`${n}/api/widget/chat-bot/stream`,{method:"POST",headers:st,body:JSON.stringify({text:a,history:N,...Pe?{sessionId:Pe}:{},...y?{productId:y}:{},...He?{timeZone:He}:{},...l?{blockContext:l}:{}}),signal:J.current.signal}));if(ke){if(ke instanceof Error&&ke.name==="AbortError"){O();return}D(!1),q(null),O(),h(x=>[...x,{id:`error-${Date.now()}`,role:"assistant",text:r("chat.error_message")}]);return}if(!je.ok||!je.body){D(!1),q(null),O(),h(x=>[...x,{id:`error-${Date.now()}`,role:"assistant",text:r("chat.error_message")}]);return}const at=je.body.getReader(),rt=new TextDecoder;let de="",_e;const Me=()=>{_e&&clearTimeout(_e),_e=void 0},Re=()=>{Me(),_e=setTimeout(()=>{J.current?.abort(),D(!1),q(null),O()},bt)},[,ve]=await te((async()=>{for(Re();;){const{done:x,value:W}=await at.read();if(Re(),x)break;de+=rt.decode(W,{stream:!0});let we;for(;(we=de.indexOf(`
3
+ `)}}function It({config:o,actions:i,baseUrl:n,i18n:p,auth:w,externalContext:b,productId:y,sessionId:j,sessionMessages:g,readOnly:U}){const S=U===!0,r=p?.t??(t=>t),u=b?.apiKey??"",m=p?.currentLanguage??"en",Z=Re(o.placeholder,m,{t:r,fallbackKey:"chat.input_placeholder",enDefault:"Type a message..."}),H=Re(o.welcomeMessage,m,{t:r,fallbackKey:"chat.empty_state",enDefault:["Hi! How can I help you?","Hello! How can I help you?"]}),f=typeof o._draft=="string"?o._draft:void 0,D=typeof o._draftContext=="string"?o._draftContext:void 0,I=o._autoSend===!0,$=Array.isArray(o._quickChips)?o._quickChips:[],E=JSON.stringify($),k=s.useRef(w?.jwt);s.useEffect(()=>{k.current=w?.jwt},[w?.jwt]);const F=b?.voice,d=!!F?.enabled&&(F?.languages??[]).includes(m),[c,h]=s.useState(()=>g?.map(t=>({id:t.id,role:t.role,text:t.content}))??[]),[T,z]=s.useState(""),[ce,se]=s.useState([]),[L,R]=s.useState(!1),[ge,q]=s.useState(null),[me,Q]=s.useState(!1),{containerRef:_,isPinned:V,scrollToBottom:C,stickToBottom:M}=ot(),v=s.useRef(null),J=s.useRef(null),K=s.useRef(j??De()),Y=s.useRef(g&&g.length>0?j??null:null),ee=s.useRef(null),le=s.useRef(void 0),ae=s.useRef(!1);s.useEffect(()=>{i.emit("chat:session",{sessionId:K.current})},[i]),s.useEffect(()=>{M()},[c,L,M]);const be=s.useCallback(()=>{const t=v.current;if(!t)return;const a=t.closest(".es-block")?.clientHeight??0,l=a>0?Math.round(a*.4):120;t.style.height="auto",t.style.height=`${Math.min(t.scrollHeight,l)}px`,t.style.overflowY=t.scrollHeight>l?"auto":"hidden"},[]);s.useLayoutEffect(()=>{be()},[T,be]);const re=s.useCallback(()=>{ae.current&&(ae.current=!1,i.emit("chat:draftConsumed",void 0))},[i]),ne=s.useCallback(async t=>{const a=t.trim();if(!a||L)return;re();const l=le.current;le.current=void 0,se([]),Q(!1),J.current?.abort(),J.current=new AbortController;const A=yt.test(a),B=`user-${Date.now()}`,X={id:B,role:"user",text:a,...A?{linkStatus:"reading",linkFailedCount:0}:{}};h(x=>[...x,X]);const O=()=>{A&&h(x=>x.map(W=>W.id===B&&W.linkStatus==="reading"?{...W,linkStatus:"done"}:W))};C(),z(""),R(!0),q(null),v.current&&(v.current.style.height="auto");const N=c.map(x=>({role:x.role,content:x.text})),Te=await w?.ensureValidToken?.()??k.current,st={"Content-Type":"application/json",...u?{"X-API-Key":u}:{},...Te?{Authorization:`Bearer ${Te}`}:{}},ue=`assistant-${Date.now()}`;let ie="",Le=!1,xe=!1;const Ae=()=>{xe||(xe=!0,q(ue),h(x=>[...x,{id:ue,role:"assistant",text:ie}]))},Be=K.current,Pe=_t.test(Be)?Be:void 0,He=xt(),[je,ke]=await te(fetch(`${n}/api/widget/chat-bot/stream`,{method:"POST",headers:st,body:JSON.stringify({text:a,history:N,...Pe?{sessionId:Pe}:{},...y?{productId:y}:{},...He?{timeZone:He}:{},...l?{blockContext:l}:{}}),signal:J.current.signal}));if(ke){if(ke instanceof Error&&ke.name==="AbortError"){O();return}R(!1),q(null),O(),h(x=>[...x,{id:`error-${Date.now()}`,role:"assistant",text:r("chat.error_message")}]);return}if(!je.ok||!je.body){R(!1),q(null),O(),h(x=>[...x,{id:`error-${Date.now()}`,role:"assistant",text:r("chat.error_message")}]);return}const at=je.body.getReader(),rt=new TextDecoder;let de="",_e;const Me=()=>{_e&&clearTimeout(_e),_e=void 0},Ke=()=>{Me(),_e=setTimeout(()=>{J.current?.abort(),R(!1),q(null),O()},bt)},[,ve]=await te((async()=>{for(Ke();;){const{done:x,value:W}=await at.read();if(Ke(),x)break;de+=rt.decode(W,{stream:!0});let we;for(;(we=de.indexOf(`
4
4
 
5
- `))!==-1;){const nt=de.slice(0,we);de=de.slice(we+2);const{event:he,data:pe}=jt(nt);if(!(!he||!pe)){if(he==="start"){const P=JSON.parse(pe);P.sessionId&&P.sessionId!==R.current&&(R.current=P.sessionId,Q.current=P.sessionId,i.emit("chat:session",{sessionId:P.sessionId}))}else if(he==="token"){const P=JSON.parse(pe);ie+=P.value??"",Ae();const Se=ie;h(Ce=>Ce.map(Y=>Y.id===ue?{...Y,text:Se}:Y))}else if(he==="meta"){const P=JSON.parse(pe);Le=!0;const Se=P.assistantMessage?.content??ie,Ce=Array.isArray(P.pastedLinks)?P.pastedLinks.filter(Y=>Y.status&&Y.status!=="ok").length:0;Ae(),h(Y=>Y.map(oe=>oe.id===ue?{...oe,text:Se,promptLogId:P.logId}:oe.id===B&&oe.linkStatus==="reading"?{...oe,linkStatus:"done",linkFailedCount:Ce}:oe))}else if(he==="error"){const P=JSON.parse(pe);throw new Error(P.message??"Stream error")}}}}if(!Le&&!ie)throw new Error("Stream ended before completion")})());if(Me(),D(!1),q(null),O(),ve){if(ve instanceof Error&&ve.name==="AbortError"||ie)return;h(xe?x=>x.map(W=>W.id===ue?{...W,text:r("chat.error_message"),promptLogId:void 0}:W):x=>[...x,{id:`error-${Date.now()}`,role:"assistant",text:r("chat.error_message")}])}},[L,i,c,r,u,n,y,C,w,re]),ye=s.useCallback(()=>{const t=b?.voiceStream;t?.getState&&t.getState()!=="idle"&&t.stop(),ne(T)},[ne,T,b]);s.useEffect(()=>{const t=b?.voiceStream;t?.getState&&t.getState()!=="idle"&&t.stop()},[j]);const qe=s.useCallback(t=>{if(t.autoSend){ne(t.message);return}se([]),K(""),re(),v.current&&(v.current.style.height="auto",v.current.focus())},[ne,re]);s.useEffect(()=>{if(!(f!==void 0||$.length>0))return;const t=`${f}${z??""}${String(I)}${E}`;if(ee.current!==t){if(ee.current=t,ae.current=!0,le.current=z,I&&f!==void 0){se([]),ne(f);return}se($),f!==void 0&&(K(f),v.current&&v.current.focus())}},[f,z,I,E,ne]);const Je=s.useCallback(t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),ye())},[ye]),Xe=s.useCallback(t=>{re(),K(t.target.value)},[re]),Qe=s.useCallback(t=>{const a=t.trim();a&&(K(l=>l?`${l} ${a}`:a),requestAnimationFrame(()=>{v.current?.focus()}))},[]);s.useEffect(()=>()=>J.current?.abort(),[]),s.useEffect(()=>i.on("chat:clearHistory",t=>{const a=t;h([]),Z(!1);const l=a?.sessionId??ze();R.current=l,Q.current=l,i.emit("chat:session",{sessionId:l})}),[i]);const Ye=s.useCallback(async()=>{const t=k.current,[a,l]=await te(fetch(`${n}/api/chat/sessions/new`,{method:"POST",headers:{...u?{"X-API-Key":u}:{},...t?{Authorization:`Bearer ${t}`}:{}}}));if(!l&&a.ok){const[A,B]=await te(a.json());if(!B&&A.success&&A.data?.sessionId){i.emit("chat:clearHistory",{sessionId:A.data.sessionId});return}}i.emit("chat:clearHistory",void 0)},[i,u,n]),Ge=s.useCallback(()=>{i.emit("chat:showHistory",void 0)},[i]),fe=s.useCallback(async t=>{R.current=t,i.emit("chat:session",{sessionId:t}),h([]),Z(!1),D(!0);const a=k.current,[l,A]=await te(fetch(`${n}/api/chat/sessions/${encodeURIComponent(t)}/messages?limit=50`,{headers:{...u?{"X-API-Key":u}:{},...a?{Authorization:`Bearer ${a}`}:{}}}));if(D(!1),A||!l.ok){Z(!0);return}const[B,X]=await te(l.json());if(X){Z(!0);return}const O=B.data?.messages??[];h(O.map(N=>({id:N.id,role:N.role,text:N.content,promptLogId:N.promptLogId??void 0,rating:N.userScore??null}))),Q.current=t,C("auto")},[i,u,n,C]);s.useEffect(()=>i.on("chat:select-session",t=>{const{sessionId:a}=t;!a||a===Q.current||fe(a)}),[i,fe]);const Ze=s.useCallback(()=>{fe(R.current)},[fe]),Ie=s.useRef(c);s.useEffect(()=>{Ie.current=c},[c]);const Ve=s.useCallback(({messageId:t,rating:a},{keepalive:l})=>{const A=Ie.current.find(B=>B.id===t);!A||!A.promptLogId||!k.current||(h(B=>B.map(X=>X.id===t?{...X,rating:a,ratingPending:!0}:X)),(async()=>{const[B,X]=await te(fetch(`${n}/api/widget/ai-feedback`,{method:"POST",keepalive:l,headers:{"Content-Type":"application/json",...u?{"X-API-Key":u}:{},Authorization:`Bearer ${k.current}`},body:JSON.stringify({promptLogId:A.promptLogId,rating:a})}));if(X||!(B.ok||B.status===409)){h(O=>O.map(N=>N.id===t?{...N,rating:null,ratingPending:!1}:N));return}h(O=>O.map(N=>N.id===t?{...N,rating:a,ratingPending:!1}:N))})())},[u,n]),{pending:$e,rate:Ee,undo:et}=ct({submit:Ve}),tt=s.useCallback((t,a)=>{const l=c.find(A=>A.id===t);!l||!l.promptLogId||l.ratingPending||!k.current||Ee(t,a)},[c,Ee]);return e.jsxs(it,{blockType:"chat",children:[e.jsxs("div",{className:"es-chat__header",children:[e.jsx("span",{className:"es-chat__header-title",children:r("chat.chat")}),e.jsxs("div",{className:"es-chat__header-actions",children:[e.jsx("button",{type:"button",className:"es-chat__action-btn","aria-label":r("chat.new_session_button"),title:r("chat.new_session_button"),onClick:Ye,children:e.jsx(gt,{size:18})}),e.jsx("button",{type:"button",className:"es-chat__action-btn","aria-label":r("chat.history_button"),title:r("chat.history_button"),onClick:Ge,children:e.jsx(pt,{size:16})})]})]}),e.jsxs("div",{className:"es-block__body es-chat__body",children:[e.jsxs("div",{className:"es-chat__messages",ref:_,children:[c.length===0&&!me&&!L&&e.jsx("div",{className:"es-chat__welcome",children:H}),me&&e.jsxs("div",{className:"es-chat__load-error",role:"alert",children:[e.jsx("span",{className:"es-chat__load-error-text",children:r("chat.load_session_error")}),e.jsx("button",{type:"button",className:"es-chat__load-error-retry",onClick:Ze,children:r("chat.retry")})]}),c.map(t=>e.jsxs("div",{className:`es-chat__bubble es-chat__bubble--${t.role}${t.id===ge?" es-chat__bubble--streaming":""}`,children:[t.role==="assistant"?e.jsx("div",{className:"es-chat__bubble-text es-chat__bubble-text--md",children:e.jsx(Ke,{remarkPlugins:[...Ue],allowedElements:[...Oe],transformLinkUri:a=>We(a)??"",transformImageUri:()=>"",components:Fe,children:t.text})}):e.jsx("div",{className:"es-chat__bubble-text",children:t.text}),t.role==="user"&&t.linkStatus==="reading"&&e.jsxs("div",{className:"es-chat__link-status",role:"status",children:[e.jsx("span",{className:"es-chat__link-status-spinner","aria-hidden":"true"}),e.jsx("span",{className:"es-chat__link-status-text",children:r("chat.reading_link")})]}),t.role==="user"&&t.linkStatus==="done"&&(t.linkFailedCount??0)>0&&e.jsxs("div",{className:"es-chat__link-status es-chat__link-status--failed",children:[e.jsx(mt,{size:13}),e.jsx("span",{className:"es-chat__link-status-text",children:r("chat.link_unreadable")})]}),t.role==="assistant"&&t.promptLogId&&k.current&&(()=>{const a=$e?.messageId===t.id?$e.rating:null;return e.jsxs("div",{className:"es-chat__feedback",children:[e.jsx("span",{className:"es-chat__feedback-label",children:t.rating&&a===null?r("chat.feedback_thanks"):r("support_chat.rate_aria")}),e.jsx(ft,{value:a??t.rating??null,onChange:l=>tt(t.id,l),disabled:a===null&&(!!t.rating||t.ratingPending),t:r}),a!==null&&e.jsxs("div",{className:"es-chat__rating-undo",role:"status",children:[e.jsx("span",{className:"es-chat__rating-undo-text",children:r("support_chat.rating_undo_toast",{rating:a})}),e.jsx("button",{type:"button",className:"es-chat__rating-undo-btn",onClick:et,children:r("support_chat.rating_undo_button")})]})]})})()]},t.id)),L&&ge===null&&e.jsxs("div",{className:"es-chat__typing","aria-label":r("chat.typing_aria"),children:[e.jsx("span",{className:"es-chat__typing-dot"}),e.jsx("span",{className:"es-chat__typing-dot"}),e.jsx("span",{className:"es-chat__typing-dot"})]})]}),!V&&c.length>0&&e.jsxs("button",{type:"button",className:"es-chat__jump",onClick:()=>C(),"aria-label":r("chat.jump_to_latest"),title:r("chat.jump_to_latest"),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 5v14"}),e.jsx("path",{d:"m19 12-7 7-7-7"})]}),e.jsx("span",{className:"es-chat__jump-label",children:r("chat.jump_to_latest")})]})]}),e.jsxs("div",{className:"es-block__footer es-chat__footer",children:[ce.length>0&&e.jsx("div",{className:"es-chat__chips",role:"group","aria-label":r("chat.quick_actions_aria"),children:ce.map((t,a)=>e.jsx("button",{type:"button",className:"es-chat__chip",onClick:()=>qe(t),disabled:L||S,children:t.labelKey?r(t.labelKey):t.label},`${t.labelKey??t.label}-${a}`))}),e.jsx("div",{className:"es-chat__disclaimer",children:r("chat.disclaimer")}),e.jsxs("div",{className:"es-chat__input-row",children:[e.jsx("textarea",{ref:v,className:"es-chat__textarea",value:T,onChange:Xe,onKeyDown:Je,placeholder:G,rows:1,maxLength:2e3,disabled:L||S,"aria-label":r("chat.input_aria")}),d&&!S&&e.jsx(ht,{baseUrl:n,apiKey:u,jwt:k.current,language:m,onTranscript:Qe,t:r,streaming:F?.streaming,voiceStream:b?.voiceStream,baseText:()=>T,onText:t=>{if(K(t.length>2e3?t.slice(0,2e3):t),t.length>=2e3){const a=b?.voiceStream;a?.getState&&a.getState()!=="idle"&&a.stop()}requestAnimationFrame(()=>{be(),v.current?.focus()})}}),e.jsx("button",{className:"es-chat__send",onClick:ye,disabled:!T.trim()||L||S,type:"button","aria-label":r("chat.send_aria"),children:L?e.jsx("span",{className:"es-chat__send-loading","aria-hidden":"true",children:"⋯"}):e.jsx("span",{"aria-hidden":"true",children:"➤"})})]})]})]})}const Ne=50;function $t({sessionId:o,baseUrl:i,jwt:n,isOpen:p,onToggle:w,i18n:b}){const y=b?.t??(d=>d),j=p!==void 0,[g,U]=s.useState(!1),S=j?p:g,[r,u]=s.useState([]),[m,G]=s.useState(null),[H,f]=s.useState(!1),[z,I]=s.useState(null),$=s.useRef(!1),E=s.useCallback(async d=>{if(n){f(!0),I(null);try{const c=`${i}/api/chat/sessions/${o}/messages?limit=${Ne}&offset=${d}`,h=await fetch(c,{headers:{Authorization:`Bearer ${n}`},credentials:"include"});if(!h.ok)throw new Error(`HTTP ${h.status}`);const T=await h.json();if(!T.success)throw new Error(y("chat_history.error"));u(K=>d===0?T.data.messages:[...T.data.messages,...K]),G(T.data.pagination)}catch(c){I(c instanceof Error?c.message:y("chat_history.error"))}finally{f(!1)}}},[i,n,o,y]),k=s.useCallback(()=>{j?w?.():U(d=>{const c=!d;return c&&!$.current&&($.current=!0,E(0)),c})},[j,w,E]),F=s.useCallback(()=>{if(!m)return;const d=Math.max(0,m.total-m.offset-Ne-Ne);E(d)},[E,m]);return s.useEffect(()=>{j&&S&&!$.current&&n&&($.current=!0,E(0))},[j,S,n,E]),s.useEffect(()=>{$.current=!1,u([]),G(null),I(null),S&&n&&($.current=!0,E(0))},[o,n]),e.jsxs("div",{className:"es-chat-history",children:[!j&&e.jsxs("button",{className:"es-chat-history__toggle",type:"button","aria-expanded":S,onClick:k,disabled:!n,children:[e.jsx("span",{className:"es-chat-history__toggle-icon",children:S?"▲":"▼"}),y("chat_history.toggle")]}),S&&e.jsxs("div",{className:"es-chat-history__panel",children:[H&&e.jsxs("div",{className:"es-chat-history__loading",role:"status","aria-label":y("chat_history.loading_aria"),children:[e.jsx("span",{className:"es-chat-history__dot"}),e.jsx("span",{className:"es-chat-history__dot"}),e.jsx("span",{className:"es-chat-history__dot"})]}),z&&!H&&e.jsx("div",{className:"es-chat-history__error",role:"alert",children:z}),!H&&!z&&e.jsxs(e.Fragment,{children:[m?.hasMore&&e.jsx("button",{className:"es-chat-history__load-more",type:"button",onClick:F,"aria-label":y("chat_history.load_older_aria"),children:y("chat_history.load_older")}),e.jsxs("div",{className:"es-chat-history__messages",role:"log","aria-live":"polite","aria-label":y("chat_history.panel_aria"),children:[r.length===0&&e.jsx("div",{className:"es-chat-history__empty",children:y("chat_history.empty")}),r.filter(d=>d.role!=="system").map(d=>e.jsx("div",{className:`es-chat-history__bubble es-chat-history__bubble--${d.role}`,children:d.role==="assistant"?e.jsx("div",{className:"es-chat-history__bubble-md",children:e.jsx(Ke,{remarkPlugins:[...Ue],allowedElements:[...Oe],transformLinkUri:c=>We(c)??"",transformImageUri:()=>"",components:Fe,children:d.content})}):d.content},d.id))]})]})]})]})}export{$t as ChatHistoryBlock,It as Component,Nt as manifest};
6
- //# sourceMappingURL=index-BKZyJMr2-oy07dUaV.js.map
5
+ `))!==-1;){const nt=de.slice(0,we);de=de.slice(we+2);const{event:he,data:pe}=jt(nt);if(!(!he||!pe)){if(he==="start"){const P=JSON.parse(pe);P.sessionId&&P.sessionId!==K.current&&(K.current=P.sessionId,Y.current=P.sessionId,i.emit("chat:session",{sessionId:P.sessionId}))}else if(he==="token"){const P=JSON.parse(pe);ie+=P.value??"",Ae();const Se=ie;h(Ce=>Ce.map(G=>G.id===ue?{...G,text:Se}:G))}else if(he==="meta"){const P=JSON.parse(pe);Le=!0;const Se=P.assistantMessage?.content??ie,Ce=Array.isArray(P.pastedLinks)?P.pastedLinks.filter(G=>G.status&&G.status!=="ok").length:0;Ae(),h(G=>G.map(oe=>oe.id===ue?{...oe,text:Se,promptLogId:P.logId}:oe.id===B&&oe.linkStatus==="reading"?{...oe,linkStatus:"done",linkFailedCount:Ce}:oe))}else if(he==="error"){const P=JSON.parse(pe);throw new Error(P.message??"Stream error")}}}}if(!Le&&!ie)throw new Error("Stream ended before completion")})());if(Me(),R(!1),q(null),O(),ve){if(ve instanceof Error&&ve.name==="AbortError"||ie)return;h(xe?x=>x.map(W=>W.id===ue?{...W,text:r("chat.error_message"),promptLogId:void 0}:W):x=>[...x,{id:`error-${Date.now()}`,role:"assistant",text:r("chat.error_message")}])}},[L,i,c,r,u,n,y,C,w,re]),ye=s.useCallback(()=>{const t=b?.voiceStream;t?.getState&&t.getState()!=="idle"&&t.stop(),ne(T)},[ne,T,b]);s.useEffect(()=>{const t=b?.voiceStream;t?.getState&&t.getState()!=="idle"&&t.stop()},[j]);const qe=s.useCallback(t=>{if(t.autoSend){ne(t.message);return}se([]),z(""),re(),v.current&&(v.current.style.height="auto",v.current.focus())},[ne,re]);s.useEffect(()=>{if(!(f!==void 0||$.length>0))return;const t=`${f}${D??""}${String(I)}${E}`;if(ee.current!==t){if(ee.current=t,ae.current=!0,le.current=D,I&&f!==void 0){se([]),ne(f);return}se($),f!==void 0&&(z(f),v.current&&v.current.focus())}},[f,D,I,E,ne]);const Je=s.useCallback(t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),ye())},[ye]),Xe=s.useCallback(t=>{re(),z(t.target.value)},[re]),Ye=s.useCallback(t=>{const a=t.trim();a&&(z(l=>l?`${l} ${a}`:a),requestAnimationFrame(()=>{v.current?.focus()}))},[]);s.useEffect(()=>()=>J.current?.abort(),[]),s.useEffect(()=>i.on("chat:clearHistory",t=>{const a=t;h([]),Q(!1);const l=a?.sessionId??De();K.current=l,Y.current=l,i.emit("chat:session",{sessionId:l})}),[i]);const Ge=s.useCallback(async()=>{const t=k.current,[a,l]=await te(fetch(`${n}/api/chat/sessions/new`,{method:"POST",headers:{...u?{"X-API-Key":u}:{},...t?{Authorization:`Bearer ${t}`}:{}}}));if(!l&&a.ok){const[A,B]=await te(a.json());if(!B&&A.success&&A.data?.sessionId){i.emit("chat:clearHistory",{sessionId:A.data.sessionId});return}}i.emit("chat:clearHistory",void 0)},[i,u,n]),Ze=s.useCallback(()=>{i.emit("chat:showHistory",void 0)},[i]),fe=s.useCallback(async t=>{K.current=t,i.emit("chat:session",{sessionId:t}),h([]),Q(!1),R(!0);const a=k.current,[l,A]=await te(fetch(`${n}/api/chat/sessions/${encodeURIComponent(t)}/messages?limit=50`,{headers:{...u?{"X-API-Key":u}:{},...a?{Authorization:`Bearer ${a}`}:{}}}));if(R(!1),A||!l.ok){Q(!0);return}const[B,X]=await te(l.json());if(X){Q(!0);return}const O=B.data?.messages??[];h(O.map(N=>({id:N.id,role:N.role,text:N.content,promptLogId:N.promptLogId??void 0,rating:N.userScore??null}))),Y.current=t,C("auto")},[i,u,n,C]);s.useEffect(()=>i.on("chat:select-session",t=>{const{sessionId:a}=t;!a||a===Y.current||fe(a)}),[i,fe]);const Qe=s.useCallback(()=>{fe(K.current)},[fe]),Ie=s.useRef(c);s.useEffect(()=>{Ie.current=c},[c]);const Ve=s.useCallback(({messageId:t,rating:a},{keepalive:l})=>{const A=Ie.current.find(B=>B.id===t);!A||!A.promptLogId||!k.current||(h(B=>B.map(X=>X.id===t?{...X,rating:a,ratingPending:!0}:X)),(async()=>{const[B,X]=await te(fetch(`${n}/api/widget/ai-feedback`,{method:"POST",keepalive:l,headers:{"Content-Type":"application/json",...u?{"X-API-Key":u}:{},Authorization:`Bearer ${k.current}`},body:JSON.stringify({promptLogId:A.promptLogId,rating:a})}));if(X||!(B.ok||B.status===409)){h(O=>O.map(N=>N.id===t?{...N,rating:null,ratingPending:!1}:N));return}h(O=>O.map(N=>N.id===t?{...N,rating:a,ratingPending:!1}:N))})())},[u,n]),{pending:$e,rate:Ee,undo:et}=ct({submit:Ve}),tt=s.useCallback((t,a)=>{const l=c.find(A=>A.id===t);!l||!l.promptLogId||l.ratingPending||!k.current||Ee(t,a)},[c,Ee]);return e.jsxs(it,{blockType:"chat",children:[e.jsxs("div",{className:"es-chat__header",children:[e.jsx("span",{className:"es-chat__header-title",children:r("chat.chat")}),e.jsxs("div",{className:"es-chat__header-actions",children:[e.jsx("button",{type:"button",className:"es-chat__action-btn","aria-label":r("chat.new_session_button"),title:r("chat.new_session_button"),onClick:Ge,children:e.jsx(gt,{size:18})}),e.jsx("button",{type:"button",className:"es-chat__action-btn","aria-label":r("chat.history_button"),title:r("chat.history_button"),onClick:Ze,children:e.jsx(pt,{size:16})})]})]}),e.jsxs("div",{className:"es-block__body es-chat__body",children:[e.jsxs("div",{className:"es-chat__messages",ref:_,children:[c.length===0&&!me&&!L&&e.jsx("div",{className:"es-chat__welcome",children:H}),me&&e.jsxs("div",{className:"es-chat__load-error",role:"alert",children:[e.jsx("span",{className:"es-chat__load-error-text",children:r("chat.load_session_error")}),e.jsx("button",{type:"button",className:"es-chat__load-error-retry",onClick:Qe,children:r("chat.retry")})]}),c.map(t=>e.jsxs("div",{className:`es-chat__bubble es-chat__bubble--${t.role}${t.id===ge?" es-chat__bubble--streaming":""}`,children:[t.role==="assistant"?e.jsx("div",{className:"es-chat__bubble-text es-chat__bubble-text--md",children:e.jsx(ze,{remarkPlugins:[...Ue],allowedElements:[...Oe],transformLinkUri:a=>We(a)??"",transformImageUri:()=>"",components:Fe,children:t.text})}):e.jsx("div",{className:"es-chat__bubble-text",children:t.text}),t.role==="user"&&t.linkStatus==="reading"&&e.jsxs("div",{className:"es-chat__link-status",role:"status",children:[e.jsx("span",{className:"es-chat__link-status-spinner","aria-hidden":"true"}),e.jsx("span",{className:"es-chat__link-status-text",children:r("chat.reading_link")})]}),t.role==="user"&&t.linkStatus==="done"&&(t.linkFailedCount??0)>0&&e.jsxs("div",{className:"es-chat__link-status es-chat__link-status--failed",children:[e.jsx(mt,{size:13}),e.jsx("span",{className:"es-chat__link-status-text",children:r("chat.link_unreadable")})]}),t.role==="assistant"&&t.promptLogId&&k.current&&(()=>{const a=$e?.messageId===t.id?$e.rating:null;return e.jsxs("div",{className:"es-chat__feedback",children:[e.jsx("span",{className:"es-chat__feedback-label",children:t.rating&&a===null?r("chat.feedback_thanks"):r("support_chat.rate_aria")}),e.jsx(ft,{value:a??t.rating??null,onChange:l=>tt(t.id,l),disabled:a===null&&(!!t.rating||t.ratingPending),t:r}),a!==null&&e.jsxs("div",{className:"es-chat__rating-undo",role:"status",children:[e.jsx("span",{className:"es-chat__rating-undo-text",children:r("support_chat.rating_undo_toast",{rating:a})}),e.jsx("button",{type:"button",className:"es-chat__rating-undo-btn",onClick:et,children:r("support_chat.rating_undo_button")})]})]})})()]},t.id)),L&&ge===null&&e.jsxs("div",{className:"es-chat__typing","aria-label":r("chat.typing_aria"),children:[e.jsx("span",{className:"es-chat__typing-dot"}),e.jsx("span",{className:"es-chat__typing-dot"}),e.jsx("span",{className:"es-chat__typing-dot"})]})]}),!V&&c.length>0&&e.jsxs("button",{type:"button",className:"es-chat__jump",onClick:()=>C(),"aria-label":r("chat.jump_to_latest"),title:r("chat.jump_to_latest"),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 5v14"}),e.jsx("path",{d:"m19 12-7 7-7-7"})]}),e.jsx("span",{className:"es-chat__jump-label",children:r("chat.jump_to_latest")})]})]}),e.jsxs("div",{className:"es-block__footer es-chat__footer",children:[ce.length>0&&e.jsx("div",{className:"es-chat__chips",role:"group","aria-label":r("chat.quick_actions_aria"),children:ce.map((t,a)=>e.jsx("button",{type:"button",className:"es-chat__chip",onClick:()=>qe(t),disabled:L||S,children:t.labelKey?r(t.labelKey):t.label},`${t.labelKey??t.label}-${a}`))}),e.jsx("div",{className:"es-chat__disclaimer",children:r("chat.disclaimer")}),e.jsxs("div",{className:"es-chat__input-row",children:[e.jsx("textarea",{ref:v,className:"es-chat__textarea",value:T,onChange:Xe,onKeyDown:Je,placeholder:Z,rows:1,maxLength:2e3,disabled:L||S,"aria-label":r("chat.input_aria")}),d&&!S&&e.jsx(ht,{baseUrl:n,apiKey:u,jwt:k.current,language:m,onTranscript:Ye,t:r,streaming:F?.streaming,voiceStream:b?.voiceStream,baseText:()=>T,onText:t=>{if(z(t.length>2e3?t.slice(0,2e3):t),t.length>=2e3){const a=b?.voiceStream;a?.getState&&a.getState()!=="idle"&&a.stop()}requestAnimationFrame(()=>{be(),v.current?.focus()})}}),e.jsx("button",{className:"es-chat__send",onClick:ye,disabled:!T.trim()||L||S,type:"button","aria-label":r("chat.send_aria"),children:L?e.jsx("span",{className:"es-chat__send-loading","aria-hidden":"true",children:"⋯"}):e.jsx("span",{"aria-hidden":"true",children:"➤"})})]})]})]})}const Ne=50;function $t({sessionId:o,baseUrl:i,jwt:n,isOpen:p,onToggle:w,i18n:b}){const y=b?.t??(d=>d),j=p!==void 0,[g,U]=s.useState(!1),S=j?p:g,[r,u]=s.useState([]),[m,Z]=s.useState(null),[H,f]=s.useState(!1),[D,I]=s.useState(null),$=s.useRef(!1),E=s.useCallback(async d=>{if(n){f(!0),I(null);try{const c=`${i}/api/chat/sessions/${o}/messages?limit=${Ne}&offset=${d}`,h=await fetch(c,{headers:{Authorization:`Bearer ${n}`},credentials:"include"});if(!h.ok)throw new Error(`HTTP ${h.status}`);const T=await h.json();if(!T.success)throw new Error(y("chat_history.error"));u(z=>d===0?T.data.messages:[...T.data.messages,...z]),Z(T.data.pagination)}catch(c){I(c instanceof Error?c.message:y("chat_history.error"))}finally{f(!1)}}},[i,n,o,y]),k=s.useCallback(()=>{j?w?.():U(d=>{const c=!d;return c&&!$.current&&($.current=!0,E(0)),c})},[j,w,E]),F=s.useCallback(()=>{if(!m)return;const d=Math.max(0,m.total-m.offset-Ne-Ne);E(d)},[E,m]);return s.useEffect(()=>{j&&S&&!$.current&&n&&($.current=!0,E(0))},[j,S,n,E]),s.useEffect(()=>{$.current=!1,u([]),Z(null),I(null),S&&n&&($.current=!0,E(0))},[o,n]),e.jsxs("div",{className:"es-chat-history",children:[!j&&e.jsxs("button",{className:"es-chat-history__toggle",type:"button","aria-expanded":S,onClick:k,disabled:!n,children:[e.jsx("span",{className:"es-chat-history__toggle-icon",children:S?"▲":"▼"}),y("chat_history.toggle")]}),S&&e.jsxs("div",{className:"es-chat-history__panel",children:[H&&e.jsxs("div",{className:"es-chat-history__loading",role:"status","aria-label":y("chat_history.loading_aria"),children:[e.jsx("span",{className:"es-chat-history__dot"}),e.jsx("span",{className:"es-chat-history__dot"}),e.jsx("span",{className:"es-chat-history__dot"})]}),D&&!H&&e.jsx("div",{className:"es-chat-history__error",role:"alert",children:D}),!H&&!D&&e.jsxs(e.Fragment,{children:[m?.hasMore&&e.jsx("button",{className:"es-chat-history__load-more",type:"button",onClick:F,"aria-label":y("chat_history.load_older_aria"),children:y("chat_history.load_older")}),e.jsxs("div",{className:"es-chat-history__messages",role:"log","aria-live":"polite","aria-label":y("chat_history.panel_aria"),children:[r.length===0&&e.jsx("div",{className:"es-chat-history__empty",children:y("chat_history.empty")}),r.filter(d=>d.role!=="system").map(d=>e.jsx("div",{className:`es-chat-history__bubble es-chat-history__bubble--${d.role}`,children:d.role==="assistant"?e.jsx("div",{className:"es-chat-history__bubble-md",children:e.jsx(ze,{remarkPlugins:[...Ue],allowedElements:[...Oe],transformLinkUri:c=>We(c)??"",transformImageUri:()=>"",components:Fe,children:d.content})}):d.content},d.id))]})]})]})]})}export{$t as ChatHistoryBlock,It as Component,Nt as manifest};
6
+ //# sourceMappingURL=index-CSsAPgvv-qK4w7DnX.js.map
@@ -1,2 +1,2 @@
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-oxM4Cgtc-R_xuAEQV.js.map
1
+ import{r as t,j as e,e 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-CXm6d9l1-BmIQ-NmU.js.map