@rubytech/create-maxy-code 0.1.108 → 0.1.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +11 -125
- package/dist/snap-chromium.js +1 -2
- package/dist/uninstall.js +10 -9
- package/package.json +1 -1
- package/payload/platform/plugins/admin/PLUGIN.md +1 -0
- package/payload/platform/plugins/admin/mcp/dist/index.js +1 -1
- package/payload/platform/plugins/admin/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/admin/skills/upgrade/SKILL.md +34 -0
- package/payload/platform/plugins/cloudflare/.claude-plugin/plugin.json +1 -1
- package/payload/platform/plugins/cloudflare/PLUGIN.md +9 -16
- package/payload/platform/plugins/cloudflare/mcp/dist/index.js +7 -12
- package/payload/platform/plugins/cloudflare/mcp/dist/index.js.map +1 -1
- package/payload/platform/plugins/cloudflare/references/dashboard-guide.md +3 -3
- package/payload/platform/plugins/cloudflare/references/manual-setup.md +16 -51
- package/payload/platform/plugins/cloudflare/references/reset-guide.md +24 -25
- package/payload/platform/plugins/cloudflare/skills/setup-tunnel/SKILL.md +29 -144
- package/payload/platform/plugins/docs/references/admin-session.md +1 -1
- package/payload/platform/plugins/docs/references/admin-ui.md +1 -1
- package/payload/platform/plugins/docs/references/cloudflare.md +20 -29
- package/payload/platform/plugins/docs/references/platform.md +4 -22
- package/payload/platform/plugins/docs/references/plugins-guide.md +1 -1
- package/payload/platform/plugins/docs/references/troubleshooting.md +4 -316
- package/payload/platform/plugins/venture-studio/PLUGIN.md +35 -4
- package/payload/platform/plugins/venture-studio/bin/scaffold.sh +104 -0
- package/payload/platform/plugins/venture-studio/skills/investor-data-room/SKILL.md +3 -1
- package/payload/platform/plugins/work/mcp/dist/cli/project-create-cli.d.ts +2 -0
- package/payload/platform/plugins/work/mcp/dist/cli/project-create-cli.d.ts.map +1 -0
- package/payload/platform/plugins/work/mcp/dist/cli/project-create-cli.js +78 -0
- package/payload/platform/plugins/work/mcp/dist/cli/project-create-cli.js.map +1 -0
- package/payload/platform/scripts/check-no-task-id-leaks.mjs +1 -1
- package/payload/platform/scripts/vnc.sh +4 -3
- package/payload/platform/templates/agents/admin/IDENTITY.md +1 -1
- package/payload/premium-plugins/venture-studio/PLUGIN.md +35 -4
- package/payload/premium-plugins/venture-studio/bin/scaffold.sh +104 -0
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/SKILL.md +3 -1
- package/payload/server/{chunk-AGFS3TVN.js → chunk-FSPPVVWM.js} +1303 -496
- package/payload/server/maxy-edge.js +21 -259
- package/payload/server/public/assets/{ChatInput-DJsqm_Gf.js → ChatInput-CsnIedhS.js} +1 -5
- package/payload/server/public/assets/{Checkbox-DGZG9BKc.js → Checkbox-CWugFyFT.js} +1 -1
- package/payload/server/public/assets/admin-D3gZuyUn.js +217 -0
- package/payload/server/public/assets/{architectureDiagram-Q4EWVU46-Dw16BhiX.js → architectureDiagram-Q4EWVU46-CeTRKWDb.js} +1 -1
- package/payload/server/public/assets/{blockDiagram-DXYQGD6D-DIOpmf5Y.js → blockDiagram-DXYQGD6D-DeeIX5U3.js} +1 -1
- package/payload/server/public/assets/{c4Diagram-AHTNJAMY-Tdb_HZeX.js → c4Diagram-AHTNJAMY-CFsqZuil.js} +1 -1
- package/payload/server/public/assets/channel-CrSx5mnG.js +1 -0
- package/payload/server/public/assets/{chunk-336JU56O-CebpwDDe.js → chunk-336JU56O-DpIXuFM0.js} +2 -2
- package/payload/server/public/assets/{chunk-426QAEUC-BtRCmfDU.js → chunk-426QAEUC-Qk8qqrvA.js} +1 -1
- package/payload/server/public/assets/{chunk-4TB4RGXK-BZ3GEWs3.js → chunk-4TB4RGXK-DtM8-CUn.js} +1 -1
- package/payload/server/public/assets/{chunk-5FUZZQ4R-iDI6Xu0U.js → chunk-5FUZZQ4R-CrSQ4ySU.js} +1 -1
- package/payload/server/public/assets/{chunk-5PVQY5BW-SQD_EpYa.js → chunk-5PVQY5BW-Bn2nQwdj.js} +1 -1
- package/payload/server/public/assets/{chunk-EDXVE4YY-CtCcA7_e.js → chunk-EDXVE4YY-CzCPnR0P.js} +1 -1
- package/payload/server/public/assets/{chunk-ENJZ2VHE-pXVGVCbb.js → chunk-ENJZ2VHE-CgZj9RoG.js} +1 -1
- package/payload/server/public/assets/{chunk-ICPOFSXX-Dkzg9o2N.js → chunk-ICPOFSXX-wy-eNjwW.js} +1 -1
- package/payload/server/public/assets/{chunk-OYMX7WX6-1ZZWzf9F.js → chunk-OYMX7WX6-CMmJtL8S.js} +1 -1
- package/payload/server/public/assets/{chunk-U2HBQHQK-CpQ3kzO0.js → chunk-U2HBQHQK-CFCW7OaT.js} +1 -1
- package/payload/server/public/assets/{chunk-X2U36JSP-C2LkxroC.js → chunk-X2U36JSP-Bgh-CJSN.js} +1 -1
- package/payload/server/public/assets/{chunk-YZCP3GAM-Bl5jBOt5.js → chunk-YZCP3GAM-BXKwZ4vN.js} +1 -1
- package/payload/server/public/assets/{chunk-ZZ45TVLE-CHtnptPS.js → chunk-ZZ45TVLE-BiOuK5NP.js} +1 -1
- package/payload/server/public/assets/classDiagram-6PBFFD2Q-C3IDJsqN.js +1 -0
- package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-BOIrJ5Zb.js +1 -0
- package/payload/server/public/assets/clone-P8Fkz7JD.js +1 -0
- package/payload/server/public/assets/{dagre-BziN0Nkh.js → dagre-DyCxa9Q2.js} +1 -1
- package/payload/server/public/assets/{dagre-KV5264BT-B7OG1g1Y.js → dagre-KV5264BT-Cffo_hmf.js} +1 -1
- package/payload/server/public/assets/data-DRfwJPja.js +1 -0
- package/payload/server/public/assets/{diagram-5BDNPKRD-Bf31nIDs.js → diagram-5BDNPKRD-Bt93Du3V.js} +1 -1
- package/payload/server/public/assets/{diagram-G4DWMVQ6-DQu85hhH.js → diagram-G4DWMVQ6-v4r-tBsC.js} +1 -1
- package/payload/server/public/assets/{diagram-MMDJMWI5-5tstbs4y.js → diagram-MMDJMWI5-DKrVPOP-.js} +1 -1
- package/payload/server/public/assets/{diagram-TYMM5635--MOV1U4o.js → diagram-TYMM5635-B1PzWQb9.js} +1 -1
- package/payload/server/public/assets/{erDiagram-SMLLAGMA-BtAnOJmd.js → erDiagram-SMLLAGMA-ClQzsQAs.js} +1 -1
- package/payload/server/public/assets/{flowDiagram-DWJPFMVM-CybiCIih.js → flowDiagram-DWJPFMVM-h3IbpN_7.js} +1 -1
- package/payload/server/public/assets/{ganttDiagram-T4ZO3ILL-B44jN7Cy.js → ganttDiagram-T4ZO3ILL-ClaxOJi8.js} +1 -1
- package/payload/server/public/assets/{gitGraphDiagram-UUTBAWPF-CT7iYcwg.js → gitGraphDiagram-UUTBAWPF-pM-U4ClD.js} +1 -1
- package/payload/server/public/assets/graph-B4FFYwus.js +1 -0
- package/payload/server/public/assets/graph-labels-Cpk9Ktt0.js +1 -0
- package/payload/server/public/assets/{graphlib-DP4o0pYL.js → graphlib-CwimOv_M.js} +1 -1
- package/payload/server/public/assets/{infoDiagram-42DDH7IO-CvxFpFHN.js → infoDiagram-42DDH7IO-DcO3Giwe.js} +1 -1
- package/payload/server/public/assets/{ishikawaDiagram-UXIWVN3A-CUwWLPeR.js → ishikawaDiagram-UXIWVN3A-BcdSL5VS.js} +1 -1
- package/payload/server/public/assets/{journeyDiagram-VCZTEJTY-y-OnGgLi.js → journeyDiagram-VCZTEJTY-CYahHYzf.js} +1 -1
- package/payload/server/public/assets/{kanban-definition-6JOO6SKY-BhrSe8R4.js → kanban-definition-6JOO6SKY-Cl5KhoS4.js} +1 -1
- package/payload/server/public/assets/lib--yuBd0Xi.js +33 -0
- package/payload/server/public/assets/{line-C9uS7z4J.js → line-d_2oTxLp.js} +1 -1
- package/payload/server/public/assets/{mermaid-parser.core-Cg4ZdKp-.js → mermaid-parser.core-CMMDGv3x.js} +1 -1
- package/payload/server/public/assets/{mermaid.core-BHdKOsex.js → mermaid.core-DK9ENGbr.js} +3 -3
- package/payload/server/public/assets/{mindmap-definition-QFDTVHPH-NBYiXHo7.js → mindmap-definition-QFDTVHPH-mA3x3MFG.js} +1 -1
- package/payload/server/public/assets/page-CgDmg_fX.js +1 -0
- package/payload/server/public/assets/{page-D9YpwhIu.js → page-D9lluVl7.js} +2 -2
- package/payload/server/public/assets/{pieDiagram-DEJITSTG-CbojC64C.js → pieDiagram-DEJITSTG-CW1nGFlY.js} +1 -1
- package/payload/server/public/assets/public-DdLMkNdS.js +7 -0
- package/payload/server/public/assets/{quadrantDiagram-34T5L4WZ-CnnoZXcL.js → quadrantDiagram-34T5L4WZ-DI5igJhR.js} +1 -1
- package/payload/server/public/assets/{requirementDiagram-MS252O5E-DFRFRtyJ.js → requirementDiagram-MS252O5E-DyVeI4e_.js} +1 -1
- package/payload/server/public/assets/{sankeyDiagram-XADWPNL6-DU5gcpzO.js → sankeyDiagram-XADWPNL6-CCTTBYKY.js} +1 -1
- package/payload/server/public/assets/{sequenceDiagram-FGHM5R23-BN7HZ6Hq.js → sequenceDiagram-FGHM5R23-hVVf35ly.js} +1 -1
- package/payload/server/public/assets/{stateDiagram-FHFEXIEX-DG6cCjvg.js → stateDiagram-FHFEXIEX-CSLuQDUX.js} +1 -1
- package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-C5JejhQU.js +1 -0
- package/payload/server/public/assets/{timeline-definition-GMOUNBTQ-qmV-8SEV.js → timeline-definition-GMOUNBTQ-sxC3W8Q4.js} +1 -1
- package/payload/server/public/assets/{vennDiagram-DHZGUBPP-BMXQ1s3n.js → vennDiagram-DHZGUBPP-Ro-ton6Z.js} +1 -1
- package/payload/server/public/assets/{wardleyDiagram-NUSXRM2D-CoAdP1Gw.js → wardleyDiagram-NUSXRM2D-T-dKD0Zx.js} +1 -1
- package/payload/server/public/assets/{xychartDiagram-5P7HB3ND-CZlfGTEn.js → xychartDiagram-5P7HB3ND-CfProPts.js} +1 -1
- package/payload/server/public/data.html +4 -4
- package/payload/server/public/graph.html +5 -5
- package/payload/server/public/index.html +7 -7
- package/payload/server/public/public.html +4 -4
- package/payload/server/server.js +299 -1392
- package/payload/platform/plugins/cloudflare/scripts/__tests__/tunnel-ingress.test.ts +0 -241
- package/payload/platform/plugins/cloudflare/scripts/_stream-log.sh +0 -154
- package/payload/platform/plugins/cloudflare/scripts/list-cf-domains.sh +0 -98
- package/payload/platform/plugins/cloudflare/scripts/list-cf-domains.ts +0 -749
- package/payload/platform/plugins/cloudflare/scripts/reset-tunnel.sh +0 -107
- package/payload/platform/plugins/cloudflare/scripts/setup-tunnel.sh +0 -854
- package/payload/platform/plugins/cloudflare/scripts/tunnel-ingress.ts +0 -291
- package/payload/server/chunk-BDFOTLPW.js +0 -759
- package/payload/server/chunk-JRBCOVA4.js +0 -1305
- package/payload/server/cloudflare-task-tracker-M5ONAGUT.js +0 -22
- package/payload/server/public/assets/admin-BvzMvMGo.js +0 -217
- package/payload/server/public/assets/channel-DThrH4QF.js +0 -1
- package/payload/server/public/assets/classDiagram-6PBFFD2Q-BC6oGTNX.js +0 -1
- package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-COwC5Umh.js +0 -1
- package/payload/server/public/assets/clone-Chp7hvnA.js +0 -1
- package/payload/server/public/assets/data-BAgaPs4j.js +0 -1
- package/payload/server/public/assets/graph-Cma7EArf.js +0 -1
- package/payload/server/public/assets/graph-labels-DyKk6Sxf.js +0 -1
- package/payload/server/public/assets/lib-CpkYtEDz.js +0 -29
- package/payload/server/public/assets/page-B4IWl3aZ.js +0 -1
- package/payload/server/public/assets/public-BtOXjy3A.js +0 -8
- package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-CvVd1Q_q.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-DD-I1_y5.js";import{d as t,f as n,v as r,x as i}from"./ChatInput-DJsqm_Gf.js";import{S as a,_ as o,a as s,l as c,p as l,t as u,w as d}from"./graph-labels-DyKk6Sxf.js";var f=r(`circle-arrow-up`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]]),p=r(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),m=r(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),h=r(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),g=r(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]);function _(e){let t=new Set,n=[];for(let r of e)for(let e of r.labels)e&&(t.has(e)||u.has(e)&&(t.add(e),n.push(e)));return n}var v=80;function y(e){let t=b(e.properties)??e.labels[0]??``,n=t.length>v?t.slice(0,v):t;return`/graph?${new URLSearchParams({nodeId:e.nodeId,label:n}).toString()}`}function b(e){for(let t of[`title`,`name`,`summary`,`headline`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}var x=e(i(),1),S=t();function C(){let[e,t]=(0,x.useState)(null),[n,r]=(0,x.useState)(!1),[i,o]=(0,x.useState)(void 0),[c,u]=(0,x.useState)(null),[f,p]=(0,x.useState)(void 0),[m,h]=(0,x.useState)(null),[g,_]=(0,x.useState)(null);(0,x.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&o(e.businessName),e.conversationId!==void 0&&u(e.conversationId??null),_(e.role??null),p(e.userName===void 0?null:e.userName),h(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let v=(0,x.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]);return n?e?(0,S.jsxs)(s,{cacheKey:e,businessName:i,conversationId:c,onLogout:v,userName:f,userAvatar:m,role:g,children:[(0,S.jsx)(l,{}),(0,S.jsxs)(`div`,{className:`data-page`,children:[(0,S.jsx)(`header`,{className:`data-header`,children:(0,S.jsxs)(`h1`,{className:`data-title`,children:[(0,S.jsx)(d,{size:18}),` Data`]})}),(0,S.jsx)(w,{cacheKey:e})]})]}):(0,S.jsxs)(`div`,{className:`data-page`,children:[(0,S.jsx)(`header`,{className:`data-header`,children:(0,S.jsxs)(`h1`,{className:`data-title`,children:[(0,S.jsx)(d,{size:18}),` Data`]})}),(0,S.jsxs)(`div`,{className:`data-empty`,children:[(0,S.jsx)(`p`,{children:`You are not signed in.`}),(0,S.jsxs)(`p`,{children:[`Open the `,(0,S.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})]}):(0,S.jsx)(`div`,{className:`data-page`,children:(0,S.jsxs)(`div`,{className:`data-loading`,children:[(0,S.jsx)(a,{size:18,className:`spin`}),` Loading…`]})})}function w({cacheKey:e,onOpenInGraph:t}){let{adminFetch:n,cacheKey:r,sessionRefetchNonce:i,banner:a,reloadToLogin:o}=c({initialCacheKey:e,surface:`data`});return(0,S.jsxs)(`main`,{className:`data-main`,children:[a&&(0,S.jsx)(`button`,{type:`button`,className:`data-session-banner`,onClick:o,"data-reason":a.reason,children:a.message}),(0,S.jsx)(T,{adminFetch:n,sessionRefetchNonce:i,onOpenInGraph:t}),(0,S.jsx)(A,{adminFetch:n,cacheKey:r,sessionRefetchNonce:i})]})}function T({adminFetch:e,sessionRefetchNonce:t,onOpenInGraph:n}){let[r,i]=(0,x.useState)(``),[s,c]=(0,x.useState)(``),[l,u]=(0,x.useState)(null),[d,f]=(0,x.useState)(`hybrid`),[p,m]=(0,x.useState)(!1),[h,g]=(0,x.useState)(null),[v,b]=(0,x.useState)(null),[C,w]=(0,x.useState)(0),[T,O]=(0,x.useState)(!1);(0,x.useEffect)(()=>{let e=r.trim();if(!e){c(``),u(null);return}O(!1);let t=setTimeout(()=>c(e),300);return()=>clearTimeout(t)},[r]),(0,x.useEffect)(()=>{if(!s)return;let t=!1;return m(!0),g(null),e(`/api/admin/graph-search?q=${encodeURIComponent(s)}&labels=*&limit=20${T?`&threshold=0`:``}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(u(e.results),f(e.mode??`hybrid`),w(typeof e.suppressed==`number`?e.suppressed:0))}).catch(e=>{t||g(e instanceof Error?e.message:String(e))}).finally(()=>{t||m(!1)}),()=>{t=!0}},[s,e,t,T]);let k=(0,x.useMemo)(()=>l?_(l):[],[l]),A=v&&k.includes(v)?v:null,j=(0,x.useMemo)(()=>l?A?l.filter(e=>e.labels.includes(A)):l:null,[l,A]),M=(0,x.useCallback)(e=>{if(n){n(e);return}window.location.href=y(e)},[n]);return(0,S.jsxs)(`section`,{className:`data-panel`,children:[(0,S.jsx)(`h2`,{className:`data-panel-title`,children:`Search`}),(0,S.jsx)(`p`,{className:`data-panel-subtitle`,children:`Find anything in your knowledge base by keyword.`}),(0,S.jsxs)(`div`,{className:`data-search-input`,children:[(0,S.jsx)(o,{size:14}),(0,S.jsx)(`input`,{type:`text`,placeholder:`Search your knowledge…`,value:r,onChange:e=>i(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),p&&(0,S.jsx)(a,{size:14,className:`spin`})]}),h&&(0,S.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,h]}),k.length>0&&(0,S.jsx)(`div`,{className:`data-chip-row`,role:`group`,"aria-label":`Filter by type`,children:k.map(e=>{let t=e===A;return(0,S.jsx)(`button`,{type:`button`,className:`data-chip`,"data-active":t,onClick:()=>b(t?null:e),children:D([e])??e},e)})}),l&&!p&&(0,S.jsxs)(`div`,{className:`data-results-meta`,children:[j.length,` of `,l.length,` result`,l.length===1?``:`s`]}),l&&!p&&!A&&C>0&&!T&&(0,S.jsxs)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>O(!0),children:[C,` low-confidence result`,C===1?``:`s`,` hidden — show all`]}),l&&!p&&!A&&T&&(0,S.jsx)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>O(!1),children:`Showing all results — hide low-confidence`}),l&&l.length===0&&!p&&(0,S.jsx)(`div`,{className:`data-empty-results`,children:`No matches. Try a different keyword.`}),j&&j.length>0&&(0,S.jsx)(`ul`,{className:`data-results`,children:j.map(e=>(0,S.jsx)(E,{hit:e,mode:d,onOpenInGraph:M},e.nodeId))})]})}function E({hit:e,mode:t,onOpenInGraph:n}){let r=O(e.properties),i=k(e.properties),a=D(e.labels),[o,s]=(0,x.useState)(!1),c=i&&i.length>280,l=o||!c?i:i?.slice(0,280)+`…`,u=t===`bm25`?`bm25 ${e.bm25Score.toFixed(2)}`:`vector ${e.vectorScore.toFixed(2)} · bm25 ${e.bm25Score.toFixed(2)} · combined ${e.score.toFixed(2)}`;return(0,S.jsxs)(`li`,{className:`data-result`,children:[(0,S.jsxs)(`div`,{role:`button`,tabIndex:0,className:`data-result-open`,onClick:()=>n(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e))},"aria-label":`Open ${r??a??`node`} in graph`,children:[a&&(0,S.jsx)(`div`,{className:`data-result-header`,children:(0,S.jsx)(`span`,{className:`data-result-labels`,children:a})}),r&&(0,S.jsx)(`div`,{className:`data-result-title`,children:r}),i&&(0,S.jsx)(`pre`,{className:`data-result-body`,children:l}),(0,S.jsx)(`div`,{className:`data-result-scores`,children:u})]}),c&&(0,S.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>s(e=>!e),children:o?`Show less`:`Show more`})]})}function D(e){if(e.length===0)return null;let t=e[0].replace(/([a-z])([A-Z])/g,`$1 $2`);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function O(e){for(let t of[`title`,`name`,`summary`,`headline`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n.length>140?n.slice(0,140)+`…`:n}return null}function k(e){for(let t of[`content`,`summary`,`body`,`description`,`text`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function A({adminFetch:e,cacheKey:t,sessionRefetchNonce:r}){let[i,o]=(0,x.useState)(`.`),[s,c]=(0,x.useState)(null),[l,u]=(0,x.useState)([]),[d,_]=(0,x.useState)(!1),[v,y]=(0,x.useState)(null),[b,C]=(0,x.useState)(!1),[w,T]=(0,x.useState)(null),[E,D]=(0,x.useState)(null),[O,k]=(0,x.useState)(null),[A,N]=(0,x.useState)(null),P=(0,x.useRef)(null),[F,I]=(0,x.useState)(0);(0,x.useEffect)(()=>{let t=!1;return _(!0),y(null),e(`/api/admin/files?path=${encodeURIComponent(i===`.`?``:i)}`).then(async e=>{let t=await e.json().catch(()=>({error:`HTTP ${e.status}`}));if(!e.ok)throw Error(t.error??`HTTP ${e.status}`);return t}).then(e=>{t||(c(e.entries),u(e.displayPath??[]))}).catch(e=>{t||(c([]),u([]),y(e instanceof Error?e.message:String(e)))}).finally(()=>{t||_(!1)}),()=>{t=!0}},[e,i,F,r]);let L=(0,x.useCallback)(e=>{o(e)},[]),R=(0,x.useCallback)(()=>{if(i===`.`||i===``)return;let e=i.split(`/`).filter(Boolean);e.pop(),o(e.length===0?`.`:e.join(`/`))},[i]),z=(0,x.useCallback)(e=>{let n=i===`.`?e.name:`${i}/${e.name}`,r=`/api/admin/files/download?session_key=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}`,a=document.createElement(`a`);a.href=r,a.rel=`noopener noreferrer`,document.body.appendChild(a),a.click(),a.remove()},[i,t]),B=(0,x.useCallback)(()=>{P.current?.click()},[]),V=(0,x.useCallback)(e=>{D(null),N(e.name)},[]),H=(0,x.useCallback)(()=>{N(null)},[]),U=(0,x.useCallback)(async t=>{let n=i===`.`?t.name:`${i}/${t.name}`;D(null),N(null),k(t.name);try{let t=await e(`/api/admin/files?path=${encodeURIComponent(n)}`,{method:`DELETE`}),r=await t.json().catch(()=>({error:`HTTP ${t.status}`}));if(!t.ok)throw Error(r.error??`HTTP ${t.status}`);I(e=>e+1)}catch(e){D(e instanceof Error?e.message:String(e))}finally{k(null)}},[i,e]);(0,x.useEffect)(()=>{if(!A)return;let e=e=>{e.key===`Escape`&&N(null)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[A]);let W=(0,x.useCallback)(async e=>{T(null),C(!0);try{let n=new FormData;n.append(`session_key`,t),n.append(`file`,e);let r=await fetch(`/api/admin/files/upload`,{method:`POST`,body:n}),i=await r.json().catch(()=>({error:`HTTP ${r.status}`}));if(!r.ok)throw Error(i.error??`HTTP ${r.status}`);o(i.path.split(`/`).slice(0,-1).join(`/`)||`.`),I(e=>e+1)}catch(e){T(e instanceof Error?e.message:String(e))}finally{C(!1),P.current&&(P.current.value=``)}},[t]);return(0,S.jsxs)(`section`,{className:`data-panel`,children:[(0,S.jsxs)(`div`,{className:`data-panel-heading`,children:[(0,S.jsx)(`h2`,{className:`data-panel-title`,children:`Files`}),(0,S.jsxs)(`div`,{className:`data-file-actions`,children:[(0,S.jsxs)(`button`,{type:`button`,className:`data-btn`,onClick:B,disabled:b,children:[b?(0,S.jsx)(a,{size:14,className:`spin`}):(0,S.jsx)(g,{size:14}),` Upload`]}),(0,S.jsx)(`input`,{type:`file`,ref:P,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&W(t)}})]})]}),(0,S.jsxs)(`p`,{className:`data-panel-subtitle`,children:[`Everything under your install's `,(0,S.jsx)(`code`,{children:`data/`}),` directory. Click a folder to open it, a file to download it. Uploads go to `,(0,S.jsx)(`code`,{children:`data/uploads/`}),`.`]}),(0,S.jsxs)(`div`,{className:`data-breadcrumbs`,children:[(0,S.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>L(`.`),children:`data`}),l.map((e,t)=>{let n=l.slice(0,t+1).map(e=>e.name).join(`/`);return(0,S.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,S.jsx)(`span`,{className:`data-crumb-sep`,children:`/`}),(0,S.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>L(n),title:e.name,children:e.displayName??e.name})]},n)}),i!==`.`&&(0,S.jsxs)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-up-btn`,onClick:R,children:[(0,S.jsx)(f,{size:14}),` Up`]})]}),w&&(0,S.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,w]}),E&&(0,S.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,E]}),v&&(0,S.jsx)(`div`,{className:`data-error`,children:v}),d&&(0,S.jsxs)(`div`,{className:`data-loading`,children:[(0,S.jsx)(a,{size:14,className:`spin`}),` Loading…`]}),!d&&s&&s.length===0&&!v&&(0,S.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!d&&s&&s.length>0&&(0,S.jsx)(`ul`,{className:`data-entries`,children:s.map(e=>{let t=e.displayName??e.name,r=O===e.name,o=A===e.name;return(0,S.jsx)(`li`,{className:`data-entry`,children:e.kind===`directory`?(0,S.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onClick:()=>L(i===`.`?e.name:`${i}/${e.name}`),children:[(0,S.jsx)(h,{size:14}),(0,S.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t})]}):e.kind===`file`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onClick:()=>z(e),title:`Download ${t}`,disabled:o,children:[(0,S.jsx)(m,{size:14}),(0,S.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t}),(0,S.jsxs)(`span`,{className:`data-entry-meta`,title:`Modified ${M(e.modifiedAt)}`,children:[j(e.sizeBytes),` · `,M(e.modifiedAt)]}),(0,S.jsx)(p,{size:12,className:`data-entry-download-icon`})]}),o?(0,S.jsxs)(`div`,{className:`data-entry-confirm`,role:`group`,"aria-label":`Confirm delete ${t}`,children:[(0,S.jsx)(`span`,{className:`data-entry-confirm-label`,children:`Delete?`}),(0,S.jsx)(`button`,{type:`button`,className:`data-entry-confirm-yes`,onClick:()=>U(e),autoFocus:!0,children:`Yes`}),(0,S.jsx)(`button`,{type:`button`,className:`data-entry-confirm-no`,onClick:H,children:`No`})]}):(0,S.jsx)(`button`,{type:`button`,className:`data-entry-delete`,onClick:()=>V(e),disabled:r,title:`Delete ${t}`,"aria-label":`Delete ${t}`,children:r?(0,S.jsx)(a,{size:14,className:`spin`}):(0,S.jsx)(n,{size:14})})]}):(0,S.jsxs)(`div`,{className:`data-entry-btn data-entry-disabled`,children:[(0,S.jsx)(m,{size:14}),(0,S.jsx)(`span`,{className:`data-entry-name`,children:t}),(0,S.jsx)(`span`,{className:`data-entry-meta`,children:`special`})]})},e.name)})})]})}function j(e){return e==null?``:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(1)} GB`}function M(e){try{let t=new Date(e);if(isNaN(t.getTime()))return`—`;let n=typeof navigator<`u`?navigator.languages&&navigator.languages.length>0?[...navigator.languages]:[navigator.language]:void 0;return t.toLocaleString(n,{dateStyle:`medium`,timeStyle:`short`})}catch{return`—`}}export{p as i,w as n,b as r,C as t};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-BHdKOsex.js","assets/dist-Bd4S37oi.js","assets/chunk-DD-I1_y5.js","assets/chunk-U2HBQHQK-CpQ3kzO0.js","assets/src-B6XdH6xq.js","assets/chunk-5PVQY5BW-SQD_EpYa.js","assets/chunk-ICPOFSXX-Dkzg9o2N.js","assets/_baseFor-BHtDrjIo.js","assets/isEmpty-BWl67LAZ.js","assets/chunk-336JU56O-CebpwDDe.js","assets/chunk-5FUZZQ4R-iDI6Xu0U.js","assets/chunk-X2U36JSP-C2LkxroC.js","assets/chunk-ZZ45TVLE-CHtnptPS.js","assets/rough.esm-DKRO8IF-.js","assets/chunk-ENJZ2VHE-pXVGVCbb.js","assets/line-C9uS7z4J.js","assets/path-B0Ik7Tu9.js","assets/array-DetWRiSa.js","assets/chunk-BSJP7CBP-DP7LTBll.js","assets/chunk-426QAEUC-BtRCmfDU.js","assets/chunk-XPW4576I-m1Y_r88I.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e}from"./chunk-DD-I1_y5.js";import{_ as t,a as n,c as r,d as i,f as a,g as o,h as s,i as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,u as g,v as _,x as v,y}from"./ChatInput-DJsqm_Gf.js";import{i as b,n as x,r as S,t as C}from"./lib-CpkYtEDz.js";import{t as w}from"./Checkbox-DGZG9BKc.js";var T=_(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),E=_(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),D=_(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),O=_(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),k=_(`square-check-big`,[[`path`,{d:`M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344`,key:`2acyp4`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),A=_(`square-plus`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),j=y(),M=e(v(),1),N=`image/jpeg,image/png,image/gif,image/webp,application/pdf,text/plain,text/markdown,text/csv,text/html,text/calendar,audio/ogg,audio/opus,audio/mp4,audio/mpeg,audio/webm,audio/wav,.opus,.ogg,.m4a,.mp3,.wav,.webm`,P=new Set(N.split(`,`).filter(e=>!e.startsWith(`.`))),F=50*1024*1024,I=typeof window<`u`&&/^(localhost|127\.0\.0\.1|[a-z0-9-]+\.local)(:|$)/.test(window.location.hostname);function L(){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function R(){let e=window.location.pathname;if(e.startsWith(`/g/`))return;let t=e.match(/^\/([a-z][a-z0-9-]{2,49})$/);return t?t[1]:void 0}function z(){let e=window.location.pathname.match(/^\/g\/([a-z0-9][a-z0-9-]{0,49})$/);return e?e[1]:void 0}function B(e){return[{key:`length`,label:`At least 8 characters`,met:e.length>=8},{key:`number`,label:`Contains a number`,met:/\d/.test(e)},{key:`special`,label:`Contains a special character`,met:/[^A-Za-z0-9]/.test(e)},{key:`whitespace`,label:`No spaces`,met:e.length>0&&!/\s/.test(e)}]}function V(e,t){if(t===`phone`)return e.length>4?e.slice(0,e.length-4).replace(/\d/g,`•`)+` `+e.slice(-4):e;let n=e.indexOf(`@`);return n<=2?e:e.slice(0,2)+`•••`+e.slice(n)}function ee(e){let[t,n]=(0,M.useState)(null),[r,i]=(0,M.useState)(null),[a,o]=(0,M.useState)(`loading`),[s,c]=(0,M.useState)(``),[l,u]=(0,M.useState)(null),[d,f]=(0,M.useState)(null),[p,m]=(0,M.useState)(!1),[h,g]=(0,M.useState)(null),_=(0,M.useMemo)(()=>R(),[]),v=(0,M.useMemo)(()=>z(),[]),[y,b]=(0,M.useState)(null),x=(0,M.useRef)(_||``),S=(0,M.useRef)(null),C=(0,M.useRef)(null),w=(0,M.useRef)(!1),T=(0,M.useRef)(null),[E,D]=(0,M.useState)(`sign-in`),[O,k]=(0,M.useState)(null),A=(0,M.useRef)(null),j=(0,M.useRef)(null);(0,M.useEffect)(()=>{try{let e=sessionStorage.getItem(`maxy_session`);e&&(j.current=e)}catch{}},[]);let N=(0,M.useCallback)(t=>{S.current=t,n(t);try{sessionStorage.setItem(`maxy_session`,t)}catch{}o(`chat`),e(t)},[e]),P=(0,M.useCallback)(()=>{S.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}n(null),o(`auth-required`),D(`sign-in`)},[]),F=(0,M.useCallback)(async e=>{try{let t=x.current,n=await fetch(`/api/access/verify-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:e,agentSlug:t})}),r=await n.json();n.ok?(A.current=r.session_key,k(r.grant),D(`set-password`),window.history.replaceState({},``,window.location.pathname)):D(`link-expired`)}catch{D(`sign-in`)}},[]),B=(0,M.useCallback)(async()=>{if(S.current)return S.current;if(C.current)return C.current;let e=(async()=>{try{let e=j.current,t=await fetch(`/api/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_id:L(),..._?{agent:_}:{},...v?{group_slug:v}:{},...e?{session_key:e}:{}})});if(!t.ok){let e=await t.json().catch(()=>({error:``}));return I&&console.error(`[session] POST /api/session failed: ${t.status} ${t.statusText}`,e),t.status===404?i(e.error||`Agent not found`):t.status===503&&i(e.error||`Service unavailable`),null}let r=await t.json();if(r.auth_required){r.agent_id&&(x.current=r.agent_id),c(r.displayName||``),r.agentImage&&u(r.agentImage),r.agentImageShape&&f(r.agentImageShape),r.showAgentName&&m(r.showAgentName),r.branding&&g(r.branding),o(`auth-required`);let e=new URLSearchParams(window.location.search).get(`token`);return e?F(e):D(`sign-in`),null}S.current=r.session_key,n(r.session_key),r.displayName&&c(r.displayName),r.agentImage&&u(r.agentImage),r.agentImageShape&&f(r.agentImageShape),r.showAgentName&&m(r.showAgentName),r.branding&&g(r.branding),o(`chat`),r.resumed&&r.messages&&(w.current=!0,T.current=r.messages),r.group&&b({groupSlug:r.groupSlug,groupName:r.groupName,participants:r.participants??[]});try{sessionStorage.setItem(`maxy_session`,r.session_key)}catch{}return r.session_key}catch(e){return I&&console.error(`[session] fetch /api/session threw:`,e),i(`Unable to connect. Please check your connection and try again.`),null}finally{C.current=null}})();return C.current=e,e},[_,v,F]);return{sessionId:t,cacheKeyRef:S,sessionError:r,pageState:a,setPageState:o,agentDisplayName:s,agentImage:l,agentImageShape:d,showAgentName:p,agentSlug:_,branding:h,resolvedSlugRef:x,ensureSession:B,startNewSession:(0,M.useCallback)(async()=>{S.current=null,C.current=null,j.current=null,w.current=!1,T.current=null,n(null),i(null);try{sessionStorage.removeItem(`maxy_session`)}catch{}let t=await B();t&&e(t)},[B,e]),enterChat:N,enterGate:P,resumedRef:w,resumeMessagesRef:T,gateState:E,setGateState:D,grantInfo:O,setGrantInfo:k,gateCacheKeyRef:A,groupContext:y,groupSlug:v}}async function*H(e){let t=e.body?.getReader();if(!t)throw Error(`No response stream`);let n=new TextDecoder,r=``;try{for(;;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.split(`
|
|
3
|
-
`);r=a.pop();for(let e of a){if(!e.startsWith(`data: `))continue;let t=e.slice(6);if(t===`[DONE]`)continue;let n;try{n=JSON.parse(t)}catch{continue}yield n}}}finally{t.cancel()}}function te({cacheKeyRef:e,ensureSession:t,sessionError:n,pageState:r,inputRef:i}){let[a,o]=(0,M.useState)([]),[s,c]=(0,M.useState)(!1),l=(0,M.useRef)(!1),u=e=>{l.current=e,c(e)},d=(0,M.useCallback)(async a=>{if(!l.current){u(!0),o([{role:`maxy`,content:``,timestamp:Date.now()}]);try{let n=await fetch(`/api/chat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({greeting:!0,session_key:a})});if(n.status===401){e.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}I&&console.warn(`[greeting] stale session, retrying with fresh session`);let r=await t();if(!r)return;n=await fetch(`/api/chat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({greeting:!0,session_key:r})})}if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Something went wrong`)}let r=``,i=``,s=()=>{i&&(r+=i,i=``,o(e=>{let t=[...e];return t[0]={...t[0],content:r},t}))},c=setInterval(s,60);try{for await(let e of H(n)){if(e.error)throw Object.assign(Error(e.error),{fromSSE:!0});e.text&&(i+=e.text),e.type===`component`&&(s(),o(t=>{let n=[...t],r={...n[0]},i=[...r.components||[]];return i.push({name:e.name,data:e.data,submitted:!1}),n[0]={...r,components:i},n}))}}finally{clearInterval(c),s()}}catch(e){if(I&&console.error(`[chat] greeting failed:`,e),r===`auth-required`)return;let t=e instanceof Error?e.message:String(e);o([{role:`maxy`,content:e instanceof Error&&e.fromSSE?t:n??`I'm having trouble connecting right now. Try refreshing the page.`,timestamp:Date.now()}])}finally{u(!1),r===`chat`&&i.current?.focus()}}},[e,t,n,r,i]),f=(0,M.useCallback)(async(a,s)=>{let c=s?.hidden??!1,d=s?.files??[];if(!a&&d.length===0||l.current)return;u(!0);let f=d.map(e=>({filename:e.name,mimeType:e.type})),p={role:`visitor`,content:a,attachments:f.length>0?f:void 0,timestamp:Date.now(),hidden:c},m;o(e=>{let t=[...e,p,{role:`maxy`,content:``,timestamp:Date.now()}];return m=t.length-1,t});try{let n=await t();if(!n)throw Error(`session`);let r=e=>{if(d.length>0){let t=new FormData;t.append(`message`,a),t.append(`session_key`,e);for(let e of d)t.append(`attachments`,e);return{body:t,headers:{}}}return{body:JSON.stringify({message:a,session_key:e}),headers:{"Content-Type":`application/json`}}},{body:i,headers:s}=r(n),c=await fetch(`/api/chat`,{method:`POST`,headers:s,body:i});if(c.status===401){e.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}I&&console.warn(`[session-expired] stale key cleared, retrying with fresh session`);let n=await t();if(!n)throw Error(`session`);({body:i,headers:s}=r(n)),c=await fetch(`/api/chat`,{method:`POST`,headers:s,body:i})}if(!c.ok){let e=await c.json().catch(()=>({}));throw Error(e.error||`Something went wrong`)}let l=``,u=``,f=()=>{u&&(l+=u,u=``,o(e=>{let t=[...e];return t[m]={...t[m],content:l},t}))},p=setInterval(f,60);try{for await(let e of H(c)){if(e.error)throw Object.assign(Error(e.error),{fromSSE:!0});e.text&&(u+=e.text),e.type===`component`&&(f(),o(t=>{let n=[...t],r={...n[m]},i=[...r.components||[]];return i.push({name:e.name,data:e.data,submitted:!1}),n[m]={...r,components:i},n}))}}finally{clearInterval(p),f()}}catch(e){if(I&&console.error(`[chat] sendMessage failed:`,e),r===`auth-required`)return;let t=e instanceof Error?e.message:String(e),i=e instanceof Error&&e.fromSSE;o(e=>{let r=[...e];return r[m]={...r[m],content:i?t:t===`session`?n??`I'm having trouble connecting right now. Try refreshing the page.`:`Sorry, I hit a snag. Try again in a moment.`},r})}finally{u(!1),r===`chat`&&i.current?.focus()}},[e,t,n,r,i]);return{messages:a,setMessages:o,isStreaming:s,sendMessage:f,sendGreeting:d,handleComponentSubmit:(0,M.useCallback)((e,t,n)=>{o(n=>{let r=[...n],i={...r[e]},a=[...i.components||[]];return a[t]={...a[t],submitted:!0},r[e]={...i,components:a},r}),f(n,{hidden:!0})},[f])}}function ne({cacheKeyRef:e,groupSlug:t,isStreaming:n,setMessages:r}){let i=(0,M.useRef)(new Date().toISOString()),a=(0,M.useRef)(!0);(0,M.useEffect)(()=>{let e=()=>{a.current=document.visibilityState===`visible`};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]);let o=(0,M.useCallback)(async()=>{let n=e.current;if(!(!n||!t))try{let e=await fetch(`/api/group/messages?session_key=${encodeURIComponent(n)}&since=${encodeURIComponent(i.current)}`);if(!e.ok)return;let t=await e.json();if(!t.messages||t.messages.length===0)return;let a=t.messages[t.messages.length-1];a.timestamp&&(i.current=new Date(a.timestamp).toISOString()),r(e=>{let n=new Set(e.filter(e=>e.messageId).map(e=>e.messageId)),r=t.messages.filter(e=>!n.has(e.messageId)).map(e=>({role:e.role,content:e.content,timestamp:e.timestamp,senderName:e.senderName??void 0,senderVisitorId:e.senderVisitorId??void 0,messageId:e.messageId}));if(r.length===0)return e;let i=[...e,...r];return i.sort((e,t)=>e.timestamp-t.timestamp),i})}catch(e){console.error(`[group-poll] failed: ${e instanceof Error?e.message:String(e)}`)}},[e,t,r]);(0,M.useEffect)(()=>{if(!t)return;let e,r=!1;function i(){if(r)return;let t=a.current?3e3:3e4;e=setTimeout(async()=>{n||await o(),i()},t)}return i(),()=>{r=!0,clearTimeout(e)}},[t,n,o])}var U=i();function W({value:e,onChange:t,onComplete:n,disabled:r}){let i=(0,M.useRef)([]);function a(n,r){r.key===`Backspace`?(r.preventDefault(),e[n]?t(e.slice(0,n)+e.slice(n+1)):n>0&&(t(e.slice(0,n-1)+e.slice(n)),i.current[n-1]?.focus())):r.key===`ArrowLeft`&&n>0?i.current[n-1]?.focus():r.key===`ArrowRight`&&n<5&&i.current[n+1]?.focus()}function o(r,a){let o=a.nativeEvent.data;if(!o||!/^\d$/.test(o))return;let s=e.split(``);for(s[r]=o;s.length<r;)s.push(``);let c=s.join(``).replace(/\D/g,``).slice(0,6);t(c),c.length===6?n(c):r<5&&i.current[r+1]?.focus()}function s(e){e.preventDefault();let r=e.clipboardData.getData(`text`).replace(/\D/g,``).slice(0,6);r&&(t(r),r.length===6?n(r):i.current[r.length]?.focus())}return(0,U.jsx)(`div`,{className:`gate-otp-field`,children:Array.from({length:6}).map((t,n)=>(0,U.jsx)(`input`,{ref:e=>{i.current[n]=e},type:`text`,inputMode:`numeric`,className:`pin-box${e[n]?` pin-box-filled`:``}`,value:e[n]||``,onKeyDown:e=>a(n,e),onInput:e=>o(n,e),onPaste:s,onFocus:e=>e.target.select(),autoFocus:n===0,autoComplete:`off`,maxLength:1,disabled:r,"aria-label":`Code digit ${n+1}`},n))})}function re({gateState:e,setGateState:t,grantInfo:n,setGrantInfo:r,gateCacheKeyRef:i,resolvedSlugRef:a,onAuthenticated:o}){let[s,c]=(0,M.useState)(``),[l,u]=(0,M.useState)(``),[d,f]=(0,M.useState)(``),[p,m]=(0,M.useState)(!1),[h,_]=(0,M.useState)(``),[v,y]=(0,M.useState)(``),[b,x]=(0,M.useState)(!1),[S,C]=(0,M.useState)(null),[T,E]=(0,M.useState)(null),[D,O]=(0,M.useState)(!1);async function k(e){if(e.preventDefault(),!D){C(null),O(!0);try{let e=a.current,n=await fetch(`/api/access/login`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({contact:s,password:l,agentSlug:e})}),i=await n.json();n.ok?o(i.session_key):n.status===401?i.error?.includes(`setup not complete`)||i.error?.includes(`invitation link`)?(t(`private-agent`),C(null)):C(i.error||`Invalid credentials`):n.status===403?(t(`access-expired`),i.expiresAt&&r(e=>e?{...e,expiresAt:i.expiresAt}:{displayName:null,contactValue:s,contactMethod:`email`,expiresAt:i.expiresAt,status:`expired`})):n.status===429?C(i.error||`Too many attempts. Please try again later.`):C(i.error||`Something went wrong`)}catch{C(`Unable to connect. Please try again.`)}finally{O(!1)}}}async function A(e){if(!D){C(null),O(!0);try{let n=a.current,o=await fetch(`/api/access/verify-otp`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({phone:v,code:e,agentSlug:n})}),s=await o.json();o.ok?(i.current=s.session_key,r(s.grant),t(`set-password`)):o.status===429?t(`otp-failed`):(C(s.error||`Invalid code`),_(``))}catch{C(`Unable to connect. Please try again.`)}finally{O(!1)}}}async function j(e){if(e.preventDefault(),!D){if(C(null),l!==d){C(`Passwords do not match`);return}if(!B(l).every(e=>e.met)){C(`Password does not meet requirements`);return}O(!0);try{let e=i.current;if(!e){C(`Session expired. Please use your invitation link again.`);return}let t=await fetch(`/api/access/create-credentials`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_key:e,password:l})}),n=await t.json();t.ok?o(n.session_key):t.status===400&&n.requirements?C(n.requirements.filter(e=>!e.met).map(e=>e.label).join(`, `)):C(n.error||`Something went wrong`)}catch{C(`Unable to connect. Please try again.`)}finally{O(!1)}}}async function N(e){if(e.preventDefault(),!(D||!s)){C(null),O(!0);try{let e=a.current,t=await fetch(`/api/access/forgot-password`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({contact:s,agentSlug:e})});t.status===429?C((await t.json()).error||`Too many attempts. Please try again later.`):(E(`If an account exists, a reset link has been sent.`),setTimeout(()=>{x(!1),E(null)},4e3))}catch{C(`Unable to connect. Please try again.`)}finally{O(!1)}}}switch(e){case`set-password`:{let e=B(l),t=e.every(e=>e.met),r=l===d,i=t&&r&&d.length>0;return(0,U.jsx)(`div`,{className:`gate-wrap`,children:(0,U.jsxs)(`div`,{className:`gate-card`,children:[n?.expiresAt&&(0,U.jsxs)(`div`,{className:`gate-expiry-badge`,children:[`Access until `,new Date(n.expiresAt).toLocaleDateString(`en-GB`,{day:`numeric`,month:`short`,year:`numeric`})]}),(0,U.jsxs)(`h2`,{className:`gate-title`,children:[`Welcome, `,n?.displayName||`there`]}),(0,U.jsx)(`p`,{className:`gate-subtitle`,children:`Create a password to access this agent in the future.`}),(0,U.jsxs)(`form`,{className:`gate-form`,onSubmit:j,children:[(0,U.jsxs)(`div`,{className:`gate-field`,children:[(0,U.jsx)(`label`,{htmlFor:`gate-display-name`,children:`Display name`}),(0,U.jsx)(`input`,{id:`gate-display-name`,type:`text`,value:n?.displayName||``,disabled:!0})]}),(0,U.jsxs)(`div`,{className:`gate-field gate-pw-row`,children:[(0,U.jsx)(`label`,{htmlFor:`gate-pw`,children:`Password`}),(0,U.jsx)(`div`,{className:`gate-pw-toggle`,children:(0,U.jsx)(w,{checked:p,onChange:m,label:`Show`})}),(0,U.jsx)(`input`,{id:`gate-pw`,type:p?`text`:`password`,value:l,onChange:e=>u(e.target.value),placeholder:`Your password`,autoFocus:!0,autoComplete:`new-password`}),l.length>0&&(0,U.jsx)(`div`,{className:`gate-strength`,children:e.map(e=>(0,U.jsxs)(`span`,{className:`gate-strength-item${e.met?` met`:``}`,children:[e.met?`✓`:`○`,` `,e.label]},e.key))})]}),(0,U.jsxs)(`div`,{className:`gate-field`,children:[(0,U.jsx)(`label`,{htmlFor:`gate-pw-confirm`,children:`Confirm password`}),(0,U.jsx)(`input`,{id:`gate-pw-confirm`,type:p?`text`:`password`,value:d,onChange:e=>f(e.target.value),placeholder:`Confirm your password`,autoComplete:`new-password`}),d.length>0&&!r&&(0,U.jsx)(`div`,{className:`gate-error`,children:`Passwords do not match`})]}),S&&(0,U.jsx)(`div`,{className:`gate-error`,children:S}),(0,U.jsx)(`div`,{className:`gate-submit`,children:(0,U.jsx)(g,{variant:`primary`,type:`submit`,fullWidth:!0,disabled:!i||D,loading:D,children:`Create account & enter chat`})})]})]})})}case`enter-otp`:return(0,U.jsx)(`div`,{className:`gate-wrap`,children:(0,U.jsxs)(`div`,{className:`gate-card`,children:[(0,U.jsx)(`h2`,{className:`gate-title`,children:`Enter your code`}),(0,U.jsxs)(`p`,{className:`gate-subtitle`,children:[`Enter the 6-digit code sent to `,V(v,`phone`)]}),(0,U.jsx)(W,{value:h,onChange:_,onComplete:A,disabled:D}),S&&(0,U.jsx)(`div`,{className:`gate-error`,children:S}),D&&(0,U.jsxs)(`div`,{className:`gate-loading`,children:[(0,U.jsx)(`span`,{className:`spinner`}),`Verifying...`]}),(0,U.jsx)(`div`,{className:`gate-resend`,children:(0,U.jsx)(`button`,{type:`button`,className:`gate-link`,onClick:()=>{t(`sign-in`),_(``),C(null)},children:`Use a different number`})})]})});case`sign-in`:case`private-agent`:return(0,U.jsx)(`div`,{className:`gate-wrap`,children:(0,U.jsxs)(`div`,{className:`gate-card`,children:[(0,U.jsx)(`h2`,{className:`gate-title`,children:e===`private-agent`?`Private Agent`:`Welcome back`}),(0,U.jsx)(`p`,{className:`gate-subtitle`,children:e===`private-agent`?`This agent is invitation-only. If you have an account, sign in below.`:`Sign in to continue your conversation.`}),b?(0,U.jsxs)(`form`,{className:`gate-form`,onSubmit:N,children:[(0,U.jsxs)(`div`,{className:`gate-field`,children:[(0,U.jsx)(`label`,{htmlFor:`gate-forgot-contact`,children:`Email or phone`}),(0,U.jsx)(`input`,{id:`gate-forgot-contact`,type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`you@example.com`,autoFocus:!0,autoComplete:`email`})]}),S&&(0,U.jsx)(`div`,{className:`gate-error`,children:S}),T&&(0,U.jsx)(`div`,{className:`gate-success`,children:T}),(0,U.jsx)(`div`,{className:`gate-submit`,children:(0,U.jsx)(g,{variant:`primary`,type:`submit`,fullWidth:!0,disabled:!s.trim()||D,loading:D,children:`Send reset link`})}),(0,U.jsx)(`div`,{className:`gate-actions`,children:(0,U.jsx)(`button`,{type:`button`,className:`gate-link`,onClick:()=>{x(!1),C(null),E(null)},children:`Back to sign in`})})]}):(0,U.jsxs)(`form`,{className:`gate-form`,onSubmit:k,children:[(0,U.jsxs)(`div`,{className:`gate-field`,children:[(0,U.jsx)(`label`,{htmlFor:`gate-contact`,children:`Email or phone`}),(0,U.jsx)(`input`,{id:`gate-contact`,type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`you@example.com`,autoFocus:!0,autoComplete:`email`})]}),(0,U.jsxs)(`div`,{className:`gate-field gate-pw-row`,children:[(0,U.jsx)(`label`,{htmlFor:`gate-login-pw`,children:`Password`}),(0,U.jsx)(`div`,{className:`gate-pw-toggle`,children:(0,U.jsx)(w,{checked:p,onChange:m,label:`Show`})}),(0,U.jsx)(`input`,{id:`gate-login-pw`,type:p?`text`:`password`,value:l,onChange:e=>u(e.target.value),placeholder:`Your password`,autoComplete:`current-password`})]}),S&&(0,U.jsx)(`div`,{className:`gate-error`,children:S}),(0,U.jsx)(`div`,{className:`gate-submit`,children:(0,U.jsx)(g,{variant:`primary`,type:`submit`,fullWidth:!0,disabled:!s.trim()||!l||D,loading:D,children:`Sign in`})}),(0,U.jsx)(`div`,{className:`gate-actions`,children:(0,U.jsx)(`button`,{type:`button`,className:`gate-link`,onClick:()=>{x(!0),C(null)},children:`Forgot password?`})})]}),e===`private-agent`&&(0,U.jsx)(`p`,{className:`gate-hint`,children:`No account? You need an invitation from the agent owner.`})]})});case`access-expired`:return(0,U.jsx)(`div`,{className:`gate-wrap`,children:(0,U.jsxs)(`div`,{className:`gate-card`,children:[(0,U.jsx)(`div`,{className:`gate-icon`,children:`⏰`}),(0,U.jsx)(`h2`,{className:`gate-title`,children:`Access expired`}),(0,U.jsxs)(`p`,{className:`gate-subtitle`,children:[n?.expiresAt?`Your access expired on ${new Date(n.expiresAt).toLocaleDateString(`en-GB`,{day:`numeric`,month:`long`,year:`numeric`})}.`:`Your access to this agent has expired.`,` `,`Contact the agent owner to renew.`]}),(0,U.jsx)(`div`,{className:`gate-actions`,children:(0,U.jsx)(g,{variant:`secondary`,onClick:()=>{t(`sign-in`),C(null),u(``)},children:`Sign in with a different account`})})]})});case`link-expired`:return(0,U.jsx)(`div`,{className:`gate-wrap`,children:(0,U.jsxs)(`div`,{className:`gate-card`,children:[(0,U.jsx)(`div`,{className:`gate-icon`,children:`⚠️`}),(0,U.jsx)(`h2`,{className:`gate-title`,children:`Link expired`}),(0,U.jsx)(`p`,{className:`gate-subtitle`,children:`This invitation link has expired or has already been used. If you already set your password, sign in below. Otherwise, ask the agent owner to send a new invitation.`}),(0,U.jsx)(`div`,{className:`gate-actions`,children:(0,U.jsx)(g,{variant:`primary`,onClick:()=>{t(`sign-in`),C(null)},children:`Go to sign in`})})]})});case`otp-failed`:return(0,U.jsx)(`div`,{className:`gate-wrap`,children:(0,U.jsxs)(`div`,{className:`gate-card`,children:[(0,U.jsx)(`div`,{className:`gate-icon`,children:`⛔`}),(0,U.jsx)(`h2`,{className:`gate-title`,children:`Too many attempts`}),(0,U.jsx)(`p`,{className:`gate-subtitle`,children:`You've entered the wrong code too many times. Ask the agent owner to send a new code.`}),(0,U.jsx)(`div`,{className:`gate-actions`,children:(0,U.jsx)(g,{variant:`secondary`,onClick:()=>{t(`sign-in`),C(null),_(``)},children:`Back to sign in`})})]})})}}var G=100;function K(e){let t;try{t=JSON.parse(e)}catch(e){return{ok:!1,reason:`invalid JSON: ${e instanceof Error?e.message:String(e)}`}}if(typeof t!=`object`||!t||Array.isArray(t))return{ok:!1,reason:`payload is not a JSON object`};let n=t;if(typeof n.url!=`string`||n.url.length===0)return{ok:!1,reason:`url is required`};let r;try{r=new URL(n.url)}catch{return{ok:!1,reason:`url is not a valid URL`}}if(r.protocol!==`http:`&&r.protocol!==`https:`)return{ok:!1,reason:`url scheme ${r.protocol} is not permitted (http/https only)`};if(typeof n.intent!=`string`||n.intent.length===0)return{ok:!1,reason:`intent is required`};if(n.intent.length>G)return{ok:!1,reason:`intent exceeds ${G} chars`};let i;if(n.hostname!==void 0){if(typeof n.hostname!=`string`)return{ok:!1,reason:`hostname must be a string when provided`};i=n.hostname}return{ok:!0,payload:i?{url:n.url,intent:n.intent,hostname:i}:{url:n.url,intent:n.intent}}}var ie=(0,M.createContext)(null);function q(){return(0,M.useContext)(ie)}var J={ok:`succeeded`,timeout:`navigation timed out`,"cdp-unreachable":`device browser is not responding`,error:`navigation error`};async function Y(e,t){try{await fetch(`/api/admin/events`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({event:e,fields:t})})}catch(t){console.error(`[device-url:event] failed to post event`,e,t)}}function X({raw:e,reason:t}){return(0,M.useEffect)(()=>{Y(`device-url:malformed`,{reason:t.slice(0,200),length:e.length})},[e,t]),(0,U.jsx)(`pre`,{className:`md-pre md-device-url-malformed`,children:(0,U.jsxs)(`code`,{className:`md-code`,children:[(0,U.jsxs)(`span`,{className:`md-device-url-malformed-label`,children:[(0,U.jsx)(S,{size:12}),` device-URL block is malformed: `,t]}),`
|
|
4
|
-
`,e]})})}function Z({payload:e,reason:n}){let[r,i]=(0,M.useState)(`idle`);(0,M.useEffect)(()=>{Y(`device-url:fallback-shown`,{intent:e.intent,reason:n,hostname:e.hostname??``})},[e.intent,e.hostname,n]);let a=async()=>{if(await p(e.url)){i(`copied`),window.setTimeout(()=>i(`idle`),2e3);return}i(`failed`),Y(`device-url:fallback-shown`,{intent:e.intent,reason:`clipboard-write-failed`,hostname:e.hostname??``})},o=e.hostname?` on the device (${e.hostname})`:` on the device`;return(0,U.jsxs)(`div`,{className:`md-device-url md-device-url-fallback`,role:`group`,children:[(0,U.jsxs)(`div`,{className:`md-device-url-fallback-message`,children:[(0,U.jsx)(S,{size:14}),(0,U.jsxs)(`span`,{children:[`Could not open `,(0,U.jsx)(`strong`,{children:e.intent}),o,` automatically (`,n,`). Copy the URL and open it in a browser on the device:`]})]}),(0,U.jsxs)(`div`,{className:`md-device-url-fallback-url`,children:[(0,U.jsx)(`code`,{children:e.url}),(0,U.jsxs)(`button`,{type:`button`,className:`md-device-url-fallback-copy`,onClick:a,"aria-label":`Copy URL`,children:[r===`copied`?(0,U.jsx)(t,{size:14}):(0,U.jsx)(b,{size:14}),r===`copied`?`Copied`:r===`failed`?`Copy failed`:`Copy`]})]}),r===`failed`&&(0,U.jsx)(`div`,{className:`md-device-url-fallback-copy-failed`,children:`Your browser blocked the copy action. Select the URL text above manually to copy it.`})]})}function ae({payload:e}){let t=q(),[n,r]=(0,M.useState)({phase:`idle`});(0,M.useEffect)(()=>{Y(`device-url:render`,{intent:e.intent,url:e.url,hostname:e.hostname??``,origin:`tool`})},[e.intent,e.url,e.hostname]);let i=async()=>{if(n.phase!==`navigating`){r({phase:`navigating`});try{let n=await fetch(`/api/admin/device-browser/navigate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),i=await n.json().catch(()=>({}));if(n.ok&&i.ok){r({phase:`succeeded`}),t&&(t.onShowVnc(),Y(`device-url:vnc-surface-shown`,{intent:e.intent})),window.setTimeout(()=>r({phase:`idle`}),2500);return}r({phase:`fallback`,reason:i.navigateResult?J[i.navigateResult]:i.detail?i.detail.slice(0,80):`navigation failed`})}catch(e){r({phase:`fallback`,reason:(e instanceof Error?e.message:String(e)).slice(0,80)})}}},a=n.phase===`navigating`,o=n.phase===`succeeded`;return(0,U.jsxs)(`div`,{className:`md-device-url`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`md-device-url-button`,onClick:i,disabled:a,"aria-label":`Open ${e.intent} on the device's browser`,title:e.hostname?`Opens on device: ${e.hostname}`:`Opens on the device running Maxy`,children:[(0,U.jsx)(l,{size:16,className:`md-device-url-icon`}),(0,U.jsx)(`span`,{className:`md-device-url-label`,children:a?`Opening…`:o?`Opened on device`:`Open ${e.intent} on device`})]}),n.phase===`fallback`&&(0,U.jsx)(Z,{payload:e,reason:n.reason})]})}function oe({source:e}){let t=K(e.trim());return t.ok?(0,U.jsx)(ae,{payload:t.payload}):(0,U.jsx)(X,{raw:e,reason:t.reason})}var Q=`modulepreload`,se=function(e){return`/`+e},ce={},le=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=se(t,n),t in ce)return;ce[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:Q,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},ue=null;function de(){return ue||=le(async()=>{let{default:e}=await import(`./mermaid.core-BHdKOsex.js`);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20])).then(({default:e})=>(e.initialize({startOnLoad:!1,theme:`neutral`}),e)),ue}function fe({source:e}){let t=(0,M.useRef)(null),[n,r]=(0,M.useState)(null);return(0,M.useEffect)(()=>{let n=!1,i=`mermaid-${Math.random().toString(36).slice(2,9)}`;return de().then(t=>t.render(i,e)).then(({svg:e})=>{!n&&t.current&&(t.current.innerHTML=e)}).catch(t=>{n||(console.error(`[MermaidBlock] render failed:`,e,t),r(t instanceof Error?t.message:`Diagram render failed`))}),()=>{n=!0}},[e]),n?(0,U.jsxs)(`div`,{className:`md-mermaid md-mermaid-error`,children:[(0,U.jsx)(`div`,{className:`md-mermaid-error-label`,children:`Diagram render error`}),(0,U.jsx)(`pre`,{className:`md-pre`,children:(0,U.jsx)(`code`,{className:`md-code`,children:e})})]}):(0,U.jsx)(`div`,{className:`md-mermaid`,ref:t})}var pe=/\.(mp4|webm|mov)(\?.*)?$/i,me=/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/,he=/vimeo\.com\/(\d+)/;function ge(e){return!!e&&pe.test(e)}function _e(e){if(!e)return null;let t=e.match(me);return t?t[1]:null}function ve(e){if(!e)return null;let t=e.match(he);return t?t[1]:null}function ye({src:e}){return(0,U.jsx)(`video`,{className:`md-video`,controls:!0,playsInline:!0,preload:`metadata`,children:(0,U.jsx)(`source`,{src:e})})}function be({videoId:e}){return(0,U.jsx)(`div`,{className:`md-video-iframe`,children:(0,U.jsx)(`iframe`,{src:`https://www.youtube-nocookie.com/embed/${e}`,allow:`accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture`,allowFullScreen:!0,loading:`lazy`})})}function xe({videoId:e}){return(0,U.jsx)(`div`,{className:`md-video-iframe`,children:(0,U.jsx)(`iframe`,{src:`https://player.vimeo.com/video/${e}`,allow:`autoplay; fullscreen; picture-in-picture`,allowFullScreen:!0,loading:`lazy`})})}function Se(e){if(ge(e))return(0,U.jsx)(ye,{src:e});let t=_e(e);if(t)return(0,U.jsx)(be,{videoId:t});let n=ve(e);return n?(0,U.jsx)(xe,{videoId:n}):null}var Ce={p:({children:e})=>(0,U.jsx)(`p`,{className:`md-p`,children:e}),h1:({children:e})=>(0,U.jsx)(`h1`,{className:`md-heading`,children:e}),h2:({children:e})=>(0,U.jsx)(`h2`,{className:`md-heading`,children:e}),h3:({children:e})=>(0,U.jsx)(`h3`,{className:`md-heading`,children:e}),code:({children:e,className:t})=>t===`language-mermaid`?(0,U.jsx)(fe,{source:String(e).replace(/\n$/,``)}):t===`language-maxy-device-url`?(0,U.jsx)(oe,{source:String(e).replace(/\n$/,``)}):(0,U.jsx)(`code`,{className:`md-code ${t||``}`.trim(),children:e}),pre:({children:e,node:t})=>{let n=t?.children?.[0];if(n?.type===`element`&&n.tagName===`code`){let t=n.properties?.className??[];if(t.includes(`language-mermaid`)||t.includes(`language-maxy-device-url`))return(0,U.jsx)(U.Fragment,{children:e})}return(0,U.jsx)(`pre`,{className:`md-pre`,children:e})},ul:({children:e})=>(0,U.jsx)(`ul`,{className:`md-list`,children:e}),ol:({children:e})=>(0,U.jsx)(`ol`,{className:`md-list md-list-ordered`,children:e}),li:({children:e})=>(0,U.jsx)(`li`,{className:`md-list-item`,children:e}),hr:()=>(0,U.jsx)(`hr`,{className:`md-hr`}),strong:({children:e})=>(0,U.jsx)(`strong`,{className:`md-strong`,children:e}),img:({src:e,alt:t})=>Se(e)||(0,U.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,children:(0,U.jsx)(`img`,{className:`md-img`,src:e,alt:t||``,loading:`lazy`})}),a:({href:e,children:t})=>Se(e)||(0,U.jsx)(`a`,{href:e,className:`md-link`,target:`_blank`,rel:`noopener noreferrer`,children:t}),table:({children:e})=>(0,U.jsx)(`table`,{className:`md-table`,children:e}),thead:({children:e})=>(0,U.jsx)(`thead`,{className:`md-thead`,children:e}),tbody:({children:e})=>(0,U.jsx)(`tbody`,{children:e}),tr:({children:e})=>(0,U.jsx)(`tr`,{className:`md-tr`,children:e}),th:({children:e})=>(0,U.jsx)(`th`,{className:`md-th`,children:e}),td:({children:e})=>(0,U.jsx)(`td`,{className:`md-td`,children:e})};function we({content:e,elapsedSeconds:t,timestamp:n}){return(0,U.jsxs)(`div`,{className:`markdown-message`,children:[(0,U.jsx)(x,{remarkPlugins:[C],components:Ce,children:e}),t!==void 0&&(0,U.jsxs)(`div`,{className:`message-meta`,children:[t,`s`]}),n&&(0,U.jsx)(`span`,{className:`message-timestamp`,children:n})]})}function $({submitted:e,submittedLabel:t=`Submitted`,actions:n,children:r}){return(0,U.jsxs)(`div`,{className:`component-card${e?` component-card--submitted`:``}`,children:[r,(0,U.jsx)(`div`,{className:`component-card__actions`,children:e?(0,U.jsx)(`span`,{className:`component-card__done-label`,children:t}):n.map((e,t)=>(0,U.jsx)(g,{variant:e.variant,size:`sm`,disabled:e.disabled,onClick:e.onClick,children:e.label},t))})]})}function Te({data:e,onSubmit:t,submitted:n}){let r=e,i=Array.isArray(r?.options)?r.options:[],[a,o]=(0,M.useState)(null),[s,c]=(0,M.useState)(`Submitted`);if(i.length===0)return null;let l=e=>{n||o(e)},u=()=>{if(!a||n)return;let e=i.find(e=>e.value===a);c(e?.label??`Submitted`),t((r?.submitMessage??`Selected: {{value}}`).replace(`{{value}}`,a).replace(`{{label}}`,e?.label??a))},d=()=>{n||(c(r?.backLabel??`Back`),t(r?.backMessage??``))},f=(e,t)=>{if(!n)if(e.key===`ArrowDown`||e.key===`ArrowRight`){e.preventDefault();let n=(t+1)%i.length;l(i[n].value),(e.currentTarget.parentElement?.children[n])?.focus()}else if(e.key===`ArrowUp`||e.key===`ArrowLeft`){e.preventDefault();let n=(t-1+i.length)%i.length;l(i[n].value),(e.currentTarget.parentElement?.children[n])?.focus()}else (e.key===` `||e.key===`Enter`)&&(e.preventDefault(),l(i[t].value))};return(0,U.jsx)($,{submitted:n,submittedLabel:s,actions:[...r?.backLabel&&r?.backMessage?[{label:r.backLabel,variant:`ghost`,onClick:d}]:[],{label:r?.submitLabel??`Confirm`,variant:`primary`,disabled:!a,onClick:u}],children:(0,U.jsxs)(`div`,{className:`single-select`,role:`radiogroup`,"aria-label":r?.title??`Select one`,children:[r?.title&&(0,U.jsx)(`div`,{className:`single-select__title`,children:r.title}),i.map((e,t)=>(0,U.jsxs)(`div`,{className:`single-select__row${a===e.value?` single-select__row--selected`:``}`,role:`radio`,"aria-checked":a===e.value,tabIndex:a===e.value||!a&&t===0?0:-1,onClick:()=>l(e.value),onKeyDown:e=>f(e,t),children:[(0,U.jsx)(`span`,{className:`single-select__radio${a===e.value?` single-select__radio--checked`:``}`}),(0,U.jsxs)(`div`,{className:`single-select__info`,children:[(0,U.jsxs)(`span`,{className:`single-select__label`,children:[e.icon&&(0,U.jsx)(`span`,{className:`single-select__icon`,children:e.icon}),e.label]}),e.description&&(0,U.jsx)(`span`,{className:`single-select__desc`,children:e.description})]})]},e.value))]})})}function Ee({data:e,onSubmit:t,submitted:n}){let r=e,i=Array.isArray(r?.options)?r.options:[],[a,o]=(0,M.useState)(i.map(e=>!!e.locked||!!e.defaultSelected)),[s,c]=(0,M.useState)(`Submitted`);if(i.length===0)return null;let l=i.some(e=>e.locked),u=i.every((e,t)=>e.locked||a[t]),d=e=>{n||i[e].locked||o(t=>t.map((t,n)=>n===e?!t:t))},f=()=>{n||o(i.map((e,t)=>e.locked?a[t]:!u))},p=i.filter((e,t)=>!e.locked&&a[t]).map(e=>e.value),m=p.length>0||l,h=()=>{if(!(!m||n)){if(c(`Submitted`),p.length===0){t(`No optional plugins selected`);return}t((r?.submitMessage??`Selected: {{values}}`).replace(`{{values}}`,p.join(`, `)))}},g=()=>{n||(c(`Skipped`),t(r?.skipMessage??`Skipped`))},_=()=>{n||(c(r?.backLabel??`Back`),t(r?.backMessage??``))},v=[];return r?.backLabel&&r?.backMessage&&v.push({label:r.backLabel,variant:`ghost`,onClick:_}),r?.skipLabel&&v.push({label:r.skipLabel,variant:`ghost`,onClick:g}),v.push({label:r?.submitLabel??`Confirm`,variant:`primary`,disabled:!m,onClick:h}),(0,U.jsx)($,{submitted:n,submittedLabel:s,actions:v,children:(0,U.jsxs)(`div`,{className:`multi-select`,children:[r?.title&&(0,U.jsx)(`div`,{className:`multi-select__title`,children:r.title}),r?.selectAll&&(0,U.jsx)(`div`,{className:`multi-select__header`,children:(0,U.jsx)(w,{checked:u,onChange:f,label:`Select all`,disabled:n})}),(0,U.jsx)(`div`,{className:`multi-select__list`,role:`group`,"aria-label":r?.title??`Select options`,children:i.map((e,t)=>{let r=e.group&&(t===0||e.group!==i[t-1].group),o=!!e.locked;return(0,U.jsxs)(M.Fragment,{children:[r&&(0,U.jsx)(`div`,{className:`multi-select__group-header`,children:e.group}),(0,U.jsxs)(`div`,{className:`multi-select__row${o?` multi-select__row--locked`:``}`,role:`checkbox`,"aria-checked":a[t],"aria-disabled":o||void 0,tabIndex:o?-1:0,onClick:()=>d(t),onKeyDown:e=>{n||o||(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),d(t))},children:[(0,U.jsx)(w,{checked:a[t],onChange:()=>d(t),disabled:n||o}),(0,U.jsxs)(`div`,{className:`multi-select__info`,children:[(0,U.jsxs)(`span`,{className:`multi-select__label`,children:[e.label,e.badge&&(0,U.jsx)(`span`,{className:`multi-select__badge`,children:e.badge})]}),e.description&&(0,U.jsx)(`span`,{className:`multi-select__desc`,children:e.description})]})]})]},e.value)})})]})})}function De({data:e,onSubmit:t,submitted:n}){let r=e,i=Array.isArray(r?.buttons)?r.buttons:[],[a,o]=(0,M.useState)(`Submitted`);if(i.length===0)return null;let s=e=>{n||(o(e.label),t(e.value))};return(0,U.jsx)($,{submitted:n,submittedLabel:a,actions:i.map(e=>({label:e.label,variant:`primary`,onClick:()=>s(e)})),children:(0,U.jsx)(U.Fragment,{})})}var Oe={"single-select":Te,"multi-select":Ee,"action-buttons":De};function ke({name:e,data:t,onSubmit:n,submitted:r}){let i=Oe[e];return i?(0,U.jsx)(i,{data:t,onSubmit:n,submitted:r}):(console.warn(`[PublicComponentRenderer] Unknown component: "${e}". Registered: ${Object.keys(Oe).join(`, `)}`),(0,U.jsx)(`div`,{className:`component-card component-card--error`,children:(0,U.jsxs)(`p`,{style:{fontFamily:`var(--font-body)`,fontSize:12,color:`var(--text-secondary)`},children:[`Component “`,e,`” is not available. This may require a platform update.`]})}))}function Ae(e){let t=new Date(e),n=new Date,r=String(t.getHours()).padStart(2,`0`),i=String(t.getMinutes()).padStart(2,`0`),a=String(t.getSeconds()).padStart(2,`0`);return t.toDateString()===n.toDateString()?`${r}:${i}:${a}`:`${String(t.getDate()).padStart(2,`0`)}-${String(t.getMonth()+1).padStart(2,`0`)}-${t.getFullYear()} ${r}:${i}:${a}`}function je({messages:e,isStreaming:t,sessionError:n,selectionMode:r,selectedItems:i,toggleSelectItem:a,onComponentSubmit:c,remainingSuggestions:l,onSuggestionClick:u,isAtBottom:d,setIsAtBottom:f,isGroup:p,sessionId:m}){let[h,_]=(0,M.useState)(new Set),[v,y]=(0,M.useState)(new Set),b=(0,M.useRef)(null),x=(0,M.useRef)(null),S=(0,M.useRef)(null),C=(0,M.useRef)(!1),E=(0,M.useRef)(!1),D=(0,M.useRef)(!1),O=(0,M.useRef)(0),k=(0,M.useRef)(!1),A=(0,M.useRef)(new Map);k.current=t,(0,M.useEffect)(()=>{t&&!C.current&&d&&(E.current=!0)},[t,d]),(0,M.useEffect)(()=>{if(!E.current&&!d){C.current=t,D.current=!1;return}if(C.current&&!t&&S.current&&x.current){let e=S.current;if(e.offsetHeight>x.current.clientHeight){E.current=!1,D.current=!0,e.scrollIntoView({behavior:`smooth`,block:`start`}),C.current=t;return}}(d||E.current)&&!D.current&&b.current?.scrollIntoView({behavior:`smooth`}),C.current&&!t&&(E.current=!1),C.current=t},[e,d,t]),(0,M.useEffect)(()=>{let e=x.current;if(!e)return;let t=()=>{let t=e.scrollTop;k.current&&t<O.current&&(E.current=!1),O.current=t,f(e.scrollHeight-e.scrollTop-e.clientHeight<80)};return e.addEventListener(`scroll`,t,{passive:!0}),t(),()=>e.removeEventListener(`scroll`,t)},[f]),(0,M.useEffect)(()=>{function e(){y(e=>{let t=new Set;return A.current.forEach((n,r)=>{n.isConnected&&(h.has(r)?e.has(r)&&t.add(r):n.scrollHeight>n.clientHeight+2&&t.add(r))}),e.size===t.size&&[...e].every(e=>t.has(e))?e:t})}e();let t=new ResizeObserver(e);return A.current.forEach(e=>t.observe(e)),()=>t.disconnect()},[e.length,h]);let j=[...e].sort((e,t)=>e.timestamp-t.timestamp);(0,M.useEffect)(()=>{r&&console.log(`[selection] entered`,{conversationId:m??`unknown`,order:j.map(e=>({ts:e.timestamp,role:e.role,id:e.messageId}))})},[r]);let N=j.reduce((e,t,n)=>t.role===`maxy`&&!t.hidden?n:e,-1);return(0,U.jsxs)(`div`,{className:`chat-messages-wrap`,children:[r&&(0,U.jsx)(`div`,{className:`selection-overlay-band`}),(0,U.jsxs)(`div`,{className:`chat-messages`,ref:x,children:[n&&e.length===0&&(0,U.jsx)(`div`,{className:`session-error`,children:(0,U.jsx)(`p`,{children:n})}),j.map((e,n)=>{if(e.hidden)return null;let l=t&&n===j.length-1,u=`${e.timestamp}_${e.role}`,d=i.has(u);return(0,U.jsxs)(`div`,{ref:n===N?S:void 0,className:`message ${e.role}${d?` selected`:``}`,children:[r&&!l&&(0,U.jsx)(`div`,{className:`message-select-check`,children:(0,U.jsx)(w,{checked:d,onChange:()=>a(u)})}),(0,U.jsxs)(`div`,{className:`bubble`,children:[p&&e.role===`visitor`&&e.senderName&&(0,U.jsx)(`span`,{className:`bubble-sender`,children:e.senderName}),e.role===`visitor`&&e.content?(()=>{let t=h.has(n),r=v.has(n);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{ref:e=>{e?A.current.set(n,e):A.current.delete(n)},className:t?`bubble-content`:`bubble-content clamped${r?` overflowing`:``}`,children:e.content}),r&&(0,U.jsx)(`div`,{className:`bubble-expand`,children:(0,U.jsx)(g,{variant:`icon`,className:t?`expanded`:``,onClick:()=>_(e=>{let t=new Set(e);return t.has(n)?t.delete(n):t.add(n),t}),"aria-label":t?`Collapse message`:`Expand message`,children:(0,U.jsx)(o,{size:14})})})]})})():e.content?(0,U.jsx)(we,{content:e.content,timestamp:Ae(e.timestamp)}):(0,U.jsxs)(`span`,{className:`typing-indicator`,children:[(0,U.jsx)(`span`,{className:`typing-dot`}),(0,U.jsx)(`span`,{className:`typing-dot`}),(0,U.jsx)(`span`,{className:`typing-dot`})]}),e.attachments&&e.attachments.length>0&&(0,U.jsx)(`div`,{className:`message-attachments`,children:e.attachments.map((e,t)=>(0,U.jsxs)(`span`,{className:`message-attachment-chip no-action`,children:[e.mimeType===`application/pdf`?(0,U.jsx)(s,{size:12}):e.mimeType.startsWith(`text/`)?(0,U.jsx)(T,{size:12}):null,(0,U.jsx)(`span`,{children:e.filename})]},t))}),e.role===`visitor`&&(0,U.jsx)(`span`,{className:`message-timestamp`,children:Ae(e.timestamp)})]}),e.role===`maxy`&&e.components&&e.components.length>0&&(0,U.jsx)(`div`,{className:`public-components`,children:e.components.map((e,t)=>(0,U.jsx)(`div`,{className:`public-component-enter`,children:(0,U.jsx)(ke,{name:e.name,data:e.data,onSubmit:e=>c(n,t,e),submitted:e.submitted})},t))})]},n)}),!t&&l.length>0&&(0,U.jsx)(`div`,{className:`chat-suggestions`,children:l.map(e=>(0,U.jsx)(g,{variant:`suggestion`,onClick:()=>u(e),children:e},e))}),(0,U.jsx)(`div`,{ref:b})]}),!d&&(0,U.jsx)(`button`,{className:`scroll-to-bottom`,onClick:()=>b.current?.scrollIntoView({behavior:`smooth`}),"aria-label":`Scroll to bottom`,children:(0,U.jsx)(o,{size:18})})]})}function Me({selectedItems:e,messages:t,isStreaming:n,copySelected:r,selectAll:i,exitSelection:a,showCopyToast:o}){let[s,c]=(0,M.useState)(!1),l=(0,M.useRef)(null),u=(0,M.useRef)(!1);function d(e){let n=e.lastIndexOf(`_`),r=e.slice(0,n),i=e.slice(n+1),a=parseInt(r,10);return t.find(e=>e.timestamp===a&&e.role===i)?.content??``}function f(e,t){return parseInt(e.slice(0,e.lastIndexOf(`_`)),10)-parseInt(t.slice(0,t.lastIndexOf(`_`)),10)}function m(){let e=[...t].sort((e,t)=>e.timestamp-t.timestamp),n=[];for(let t of e){if(t.hidden||!t.content)continue;let e=t.role===`visitor`?`Visitor`:`Maxy`;n.push(`${e}:\n${t.content}`)}return n.join(`
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
`)}M.useEffect(()=>{if(!s)return;let e=e=>{e.target.closest(`.selection-copy-wrap`)||c(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[s]);function h(){l.current!==null&&(clearTimeout(l.current),l.current=null)}let g=[...t].sort((e,t)=>e.timestamp-t.timestamp),_=g.reduce((e,t,r)=>(t.hidden||n&&r===g.length-1||e.push(`${t.timestamp}_${t.role}`),e),[]),v=_.length>0&&_.every(t=>e.has(t));return(0,U.jsx)(`div`,{className:`chat-input-area`,children:(0,U.jsxs)(`div`,{className:`selection-bar`,children:[(0,U.jsxs)(`div`,{className:`selection-bar-left`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`selection-select-all`,onClick:()=>i(_),disabled:_.length===0,"aria-label":v?`Deselect all`:`Select all`,title:v?`Deselect all`:`Select all`,children:[(0,U.jsx)(k,{size:16}),(0,U.jsx)(`span`,{children:v?`Deselect all`:`Select all`})]}),(0,U.jsxs)(`span`,{className:`selection-count`,children:[e.size,` Selected`]})]}),(0,U.jsxs)(`div`,{className:`selection-copy-wrap`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`selection-copy`,onPointerDown:()=>{if(s){c(!1);return}u.current=!1,l.current=setTimeout(()=>{u.current=!0,c(!0),l.current=null},500)},onPointerUp:h,onPointerLeave:h,onPointerCancel:h,onClick:async()=>{u.current||await r(d,f)},children:[(0,U.jsx)(b,{size:18}),(0,U.jsx)(`span`,{children:`Copy`})]}),s&&(0,U.jsx)(`div`,{className:`copy-menu`,children:(0,U.jsx)(`button`,{type:`button`,className:`copy-menu-item`,onClick:async()=>{let e=m();e&&o(await p(e)),a()},children:`Copy all`})})]}),(0,U.jsx)(`button`,{type:`button`,className:`selection-cancel`,onClick:a,children:`Cancel`})]})})}function Ne(e){return`${Math.floor(e/60)}:${(e%60).toString().padStart(2,`0`)}`}function Pe({data:e,active:t}){let n=[];if(e&&e.length>0&&t){let t=Math.floor(e.length/24);for(let r=0;r<24;r++){let i=e[r*t]??128,a=Math.abs(i-128)/128;n.push(Math.max(.15,a))}}else for(let e=0;e<24;e++)n.push(.15);return(0,U.jsx)(`div`,{className:`voice-waveform`,"aria-hidden":`true`,children:n.map((e,t)=>(0,U.jsx)(`div`,{className:`voice-waveform-bar`,style:{height:`${Math.round(e*100)}%`}},t))})}function Fe({state:e,elapsedSeconds:t,waveform:n,onTogglePause:r,onDiscard:i,onSend:o}){if(e===`idle`||e===`error`)return null;let s=e===`recording`,c=e===`paused`,l=e===`sending`;return(0,U.jsxs)(`div`,{className:`voice-recorder`,role:`region`,"aria-label":`Voice recording`,"aria-live":`polite`,children:[(0,U.jsx)(`button`,{type:`button`,className:`voice-trash`,onClick:i,disabled:l,"aria-label":`Discard recording`,children:(0,U.jsx)(a,{size:16})}),(0,U.jsx)(`span`,{className:`voice-timer`,"aria-live":`polite`,"aria-atomic":`true`,children:Ne(t)}),(0,U.jsx)(Pe,{data:n,active:s}),(0,U.jsx)(`button`,{type:`button`,className:`voice-pause`,onClick:r,disabled:l,"aria-label":c?`Resume recording`:`Pause recording`,children:c?(0,U.jsx)(f,{size:14}):(0,U.jsx)(O,{size:14})}),(0,U.jsx)(g,{variant:`send`,type:`button`,onClick:o,disabled:l,loading:l,"aria-label":`Send voice note`,children:(0,U.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,U.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]})}var Ie=[`audio/ogg;codecs=opus`,`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`];function Le(){for(let e of Ie)if(MediaRecorder.isTypeSupported(e))return e;return``}function Re(e){return e.split(`;`)[0]}function ze(){let[e,t]=(0,M.useState)(`idle`),[n,r]=(0,M.useState)(0),[i,a]=(0,M.useState)(null),[o,s]=(0,M.useState)(null),c=(0,M.useRef)(null),l=(0,M.useRef)(null),u=(0,M.useRef)([]),d=(0,M.useRef)(``),f=(0,M.useRef)(null),p=(0,M.useRef)(0),m=(0,M.useRef)(0),h=(0,M.useRef)(null),g=(0,M.useRef)(null),_=(0,M.useRef)(0),v=(0,M.useCallback)(()=>{if(f.current&&=(clearInterval(f.current),null),_.current&&=(cancelAnimationFrame(_.current),0),c.current&&c.current.state!==`inactive`)try{c.current.stop()}catch{}c.current=null,u.current=[],l.current&&=(l.current.getTracks().forEach(e=>e.stop()),null),h.current&&(h.current.close().catch(()=>{}),h.current=null,g.current=null),m.current=0,p.current=0},[]);(0,M.useEffect)(()=>v,[v]);let y=(0,M.useCallback)(()=>{p.current=Date.now(),f.current=setInterval(()=>{let e=Date.now()-p.current,t=m.current+e;r(Math.floor(t/1e3))},200)},[]),b=(0,M.useCallback)(()=>{f.current&&=(clearInterval(f.current),null);let e=Date.now()-p.current;m.current+=e},[]),x=(0,M.useCallback)(()=>{let e=g.current;if(!e)return;let t=new Uint8Array(e.frequencyBinCount),n=()=>{e.getByteTimeDomainData(t),a(new Uint8Array(t)),_.current=requestAnimationFrame(n)};n()},[]),S=(0,M.useCallback)(()=>{_.current&&=(cancelAnimationFrame(_.current),0)},[]),C=(0,M.useCallback)(async()=>{if(!(e!==`idle`&&e!==`error`)){if(s(null),typeof window<`u`&&!window.isSecureContext){t(`error`),s(`Voice recording requires a secure connection (HTTPS). Use your tunnel URL for voice notes.`);return}if(typeof navigator>`u`||!navigator.mediaDevices?.getUserMedia){t(`error`),s(`Voice recording is not supported in this browser.`);return}if(typeof MediaRecorder>`u`){t(`error`),s(`Voice recording is not supported in this browser.`);return}try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});l.current=e;let n=new AudioContext;h.current=n;let i=n.createMediaStreamSource(e),o=n.createAnalyser();o.fftSize=256,i.connect(o),g.current=o;let s=Le();d.current=s;let f=new MediaRecorder(e,s?{mimeType:s}:void 0);c.current=f,u.current=[],f.ondataavailable=e=>{e.data.size>0&&u.current.push(e.data)},e.getAudioTracks()[0]?.addEventListener(`ended`,()=>{v(),t(`idle`),r(0),a(null)}),f.start(1e3),t(`recording`),r(0),y(),x()}catch(e){v(),t(`error`),e instanceof DOMException?e.name===`NotAllowedError`?s(`Microphone access was denied. Check your browser permissions to enable voice recording.`):e.name===`NotFoundError`?s(`No microphone found. Connect a microphone to use voice recording.`):s(`Microphone error: ${e.message}`):s(`Could not start recording.`)}}},[e,v,y,x]),w=(0,M.useCallback)(()=>{let n=c.current;n&&(e===`recording`&&n.state===`recording`?(n.pause(),b(),S(),t(`paused`)):e===`paused`&&n.state===`paused`&&(n.resume(),y(),x(),t(`recording`)))},[e,b,y,x,S]),T=(0,M.useCallback)(()=>{e!==`recording`&&e!==`paused`||(v(),t(`idle`),r(0),a(null))},[e,v]),E=(0,M.useCallback)(async()=>{if(e!==`recording`&&e!==`paused`)return null;let n=c.current;if(!n)return null;let i=e===`recording`?Date.now()-p.current:0;return m.current+i<1e3?(T(),null):(t(`sending`),b(),S(),new Promise(e=>{n.onstop=()=>{let i=d.current||n.mimeType||`audio/webm`,o=new Blob(u.current,{type:Re(i)});v(),t(`idle`),r(0),a(null),e(o.size>0?o:null)},n.stop()}))},[e,T,b,S,v]);return(0,M.useEffect)(()=>{if(e!==`error`)return;let n=setTimeout(()=>{t(`idle`),s(null)},8e3);return()=>clearTimeout(n)},[e]),{state:e,elapsedSeconds:n,waveform:i,errorMessage:o,start:C,togglePause:w,discard:T,send:E}}function Be(e,t){let n=e.split(`;`)[0].trim().toLowerCase();return t.has(n)}function Ve({input:e,setInput:t,isStreaming:n,pendingFiles:r,setPendingFiles:i,attachError:a,setAttachError:o,isDragOver:c,setIsDragOver:l,inputRef:d,onSubmit:f,onSendVoiceNote:p}){let m=(0,M.useRef)(null),_=ze(),v=_.state===`recording`||_.state===`paused`||_.state===`sending`,y=!v&&!n&&!e.trim()&&r.length===0;async function b(){let e=await _.send();if(!e)return;let t=e.type===`audio/ogg`?`.ogg`:e.type===`audio/mp4`?`.m4a`:`.webm`;p(new File([e],`voice-note${t}`,{type:e.type}))}function x(e){o(null);let t=e.find(e=>!Be(e.type,P));if(t){o(`Unsupported file type: "${t.type}". Supported: images, PDF, plain text, markdown, CSV, calendar, voice notes.`);return}let n=e.find(e=>e.size>F);if(n){o(`"${n.name}" exceeds the 50 MB limit.`);return}i(t=>[...t,...e].slice(0,5))}function S(e){e.preventDefault(),l(!0)}function C(){l(!1)}function w(e){e.preventDefault(),l(!1),x([...e.dataTransfer.files])}return(0,U.jsxs)(`div`,{className:`chat-input-area`,children:[(0,U.jsx)(`input`,{ref:m,type:`file`,multiple:!0,accept:N,style:{display:`none`},onChange:e=>{e.target.files&&x([...e.target.files]),e.target.value=``}}),r.length>0&&(0,U.jsx)(`div`,{className:`attachment-strip`,children:r.map((e,t)=>(0,U.jsxs)(`div`,{className:`attachment-chip`,children:[e.type.startsWith(`image/`)?(0,U.jsx)(`img`,{src:URL.createObjectURL(e),alt:e.name,className:`attachment-chip-thumb`}):e.type.startsWith(`audio/`)?(0,U.jsx)(E,{size:14}):e.type===`application/pdf`?(0,U.jsx)(s,{size:14}):(0,U.jsx)(T,{size:14}),(0,U.jsx)(`span`,{className:`attachment-chip-name`,children:e.name}),(0,U.jsx)(`button`,{type:`button`,className:`attachment-chip-remove`,onClick:()=>i(e=>e.filter((e,n)=>n!==t)),"aria-label":`Remove ${e.name}`,children:`×`})]},t))}),a&&(0,U.jsx)(`p`,{className:`attach-error`,children:a}),_.state===`error`&&_.errorMessage&&(0,U.jsxs)(`p`,{className:`voice-error`,role:`alert`,children:[(0,U.jsx)(E,{size:14}),_.errorMessage]}),(0,U.jsx)(u,{inputRef:d}),v?(0,U.jsx)(`div`,{className:`chat-form voice-active`,children:(0,U.jsx)(Fe,{state:_.state,elapsedSeconds:_.elapsedSeconds,waveform:_.waveform,onTogglePause:_.togglePause,onDiscard:_.discard,onSend:b})}):(0,U.jsxs)(`form`,{className:`chat-form${c?` drag-over`:``}`,onSubmit:f,onDragOver:S,onDragLeave:C,onDrop:w,onPaste:e=>{let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e of t){if(e.kind!==`file`)continue;let t=e.getAsFile();if(!t)continue;let r=t.type.split(`/`)[1]?.replace(`jpeg`,`jpg`)||`png`;n.push(new File([t],`pasted-image-${Date.now()}.${r}`,{type:t.type}))}n.length>0&&x(n)},children:[(0,U.jsx)(g,{variant:`icon`,type:`button`,onClick:()=>m.current?.click(),disabled:n,"aria-label":`Attach file`,children:(0,U.jsx)(D,{size:14})}),(0,U.jsx)(h,{ref:d,value:e,onChange:t}),y?(0,U.jsx)(g,{variant:`send`,type:`button`,onClick:_.start,disabled:n,"aria-label":`Record voice note`,children:(0,U.jsx)(E,{size:14})}):(0,U.jsx)(g,{variant:`send`,type:`submit`,disabled:n||!e.trim()&&r.length===0,"aria-label":`Send message`,children:(0,U.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,U.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,U.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]})]})}var He=[];function Ue(){let[e,t]=(0,M.useState)(``),[i,a]=(0,M.useState)([]),[o,s]=(0,M.useState)(!1),[l,u]=(0,M.useState)(null),[f,p]=(0,M.useState)(He),[h,g]=(0,M.useState)(!0),_=(0,M.useRef)(null),{selectionMode:v,selectedItems:y,copyToast:b,exitSelection:x,enterSelection:S,toggleSelectItem:C,selectAll:w,copySelected:T,showCopyToast:E}=c(),D=(0,M.useRef)(()=>{}),O=ee((0,M.useCallback)(e=>{D.current(e)},[])),{sessionId:j,cacheKeyRef:N,sessionError:P,pageState:F,agentDisplayName:I,agentImage:L,agentImageShape:R,showAgentName:z,branding:B,ensureSession:V,startNewSession:H,resumedRef:W,resumeMessagesRef:G,groupContext:K,groupSlug:ie}=O,{messages:q,setMessages:J,isStreaming:Y,sendMessage:X,sendGreeting:Z,handleComponentSubmit:ae}=te({cacheKeyRef:N,ensureSession:V,sessionError:P,pageState:F,inputRef:_});(0,M.useEffect)(()=>{D.current=Z},[Z]),ne({cacheKeyRef:N,groupSlug:ie,isStreaming:Y,setMessages:J}),(0,M.useEffect)(()=>{let e=!1;return(async()=>{let t=await V();if(!e&&t){if(W.current&&G.current&&G.current.length>0){let e=G.current.map(e=>({role:e.role,content:e.content,timestamp:e.timestamp}));e.sort((e,t)=>e.timestamp-t.timestamp),J(e),G.current=null;return}Z(t)}})(),()=>{e=!0}},[]),(0,M.useEffect)(()=>{F===`chat`&&_.current?.focus()},[F]),(0,M.useEffect)(()=>{if(F!==`chat`)return;history.pushState({maxyChat:!0},``);function e(){history.pushState({maxyChat:!0},``)}return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[F]),(0,M.useEffect)(()=>{if(!B)return;let e=document.documentElement;if(B.primaryColor&&(e.style.setProperty(`--sage`,B.primaryColor),e.style.setProperty(`--sage-hover`,B.primaryColor),e.style.setProperty(`--sage-subtle`,B.primaryColor+`14`),e.style.setProperty(`--sage-glow`,B.primaryColor+`26`)),B.accentColor&&e.style.setProperty(`--visitor-bubble`,B.accentColor),B.backgroundColor&&e.style.setProperty(`--bg`,B.backgroundColor),document.title=B.name,B.primaryColor){let e=document.querySelector(`meta[name="theme-color"]`);e||(e=document.createElement(`meta`),e.name=`theme-color`,document.head.appendChild(e)),e.content=B.primaryColor}if(B.faviconUrl){let e=document.querySelector(`link[rel="icon"]`);e||(e=document.createElement(`link`),e.rel=`icon`,document.head.appendChild(e)),e.href=B.faviconUrl}},[B]),(0,M.useEffect)(()=>{function e(e){e.key===`Escape`&&v&&x()}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[v,x]);function oe(){Y||(J([]),p(He),H())}function Q(e){if(!e&&i.length===0||Y)return;J(e=>e.map(e=>e.components?.some(e=>!e.submitted)?{...e,components:e.components.map(e=>e.submitted?e:{...e,submitted:!0})}:e)),p(t=>t.filter(t=>t!==e)),g(!0);let n=[...i];t(``),a([]),u(null),X(e,{files:n})}function se(t){t.preventDefault(),Q(e.trim()),_.current?.resetHeight()}return(0,U.jsxs)(`div`,{className:`chat-page`,children:[(0,U.jsxs)(`header`,{className:`chat-header`,children:[(0,U.jsx)(`img`,{src:L||B?.logoUrl||r,alt:B?.name||n.productName,className:`chat-logo${L&&R===`circle`?` chat-logo--circle`:``}${L&&R===`rounded`?` chat-logo--rounded`:``}`,onError:e=>{e.target.src=B?.logoUrl||r}}),(0,U.jsxs)(`div`,{className:`chat-header-text`,children:[z!==`none`&&(0,U.jsx)(`h1`,{className:`chat-tagline`,children:K?.groupName||z&&I||B?.name||n.productName}),(0,U.jsx)(`p`,{className:`chat-intro`,children:K?`${K.participants.length} participants`:B?.tagline||``}),(0,U.jsx)(`p`,{className:`chat-ai-indicator`,children:`AI assistant`})]}),F===`chat`&&!v&&(0,U.jsxs)(`div`,{className:`chat-header-actions`,children:[(0,U.jsx)(`button`,{className:`chat-header-action`,onClick:oe,disabled:Y,title:`New conversation`,"aria-label":`New conversation`,children:(0,U.jsx)(A,{size:16})}),(0,U.jsx)(`button`,{className:`chat-header-action`,onClick:S,title:`Select messages`,"aria-label":`Select messages`,children:(0,U.jsx)(k,{size:16})})]})]}),F===`loading`&&(0,U.jsx)(`div`,{className:`gate-wrap`,children:(0,U.jsx)(`div`,{className:`gate-loading`,children:(0,U.jsx)(`span`,{className:`spinner`})})}),F===`auth-required`&&(0,U.jsx)(re,{gateState:O.gateState,setGateState:O.setGateState,grantInfo:O.grantInfo,setGrantInfo:O.setGrantInfo,gateCacheKeyRef:O.gateCacheKeyRef,resolvedSlugRef:O.resolvedSlugRef,onAuthenticated:O.enterChat}),F===`chat`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(je,{messages:q,isStreaming:Y,sessionError:P,selectionMode:v,selectedItems:y,toggleSelectItem:C,onComponentSubmit:ae,remainingSuggestions:f,onSuggestionClick:Q,isAtBottom:h,setIsAtBottom:g,isGroup:!!K,sessionId:j}),v?(0,U.jsx)(Me,{selectedItems:y,messages:q,isStreaming:Y,copySelected:T,selectAll:w,exitSelection:x,showCopyToast:E}):(0,U.jsx)(Ve,{input:e,setInput:t,isStreaming:Y,pendingFiles:i,setPendingFiles:a,attachError:l,setAttachError:u,isDragOver:o,setIsDragOver:s,inputRef:_,onSubmit:se,onSendVoiceNote:e=>{t(``),a([]),u(null),X(`[Voice note]`,{files:[e]})}})]}),b&&(0,U.jsx)(`span`,{className:`copy-toast${b===`failed`?` copy-toast-failed`:``}`,children:b===`copied`?`Copied`:`Copy failed`}),(0,U.jsxs)(`footer`,{className:`chat-footer`,children:[(0,U.jsxs)(`a`,{href:m,children:[d,` `,`↗`]}),j&&(0,U.jsxs)(`span`,{style:{opacity:.35,fontSize:`10px`,fontFamily:`monospace`,marginLeft:`1rem`},children:[`Conversation · `,j.slice(0,8)]})]})]})}(0,j.createRoot)(document.getElementById(`root`)).render((0,U.jsx)(Ue,{}));export{le as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as e}from"./src-B6XdH6xq.js";import"./chunk-ICPOFSXX-Dkzg9o2N.js";import"./dist-Bd4S37oi.js";import"./chunk-5PVQY5BW-SQD_EpYa.js";import"./chunk-U2HBQHQK-CpQ3kzO0.js";import"./chunk-BSJP7CBP-DP7LTBll.js";import"./chunk-ZZ45TVLE-CHtnptPS.js";import"./chunk-55IACEB6-BRJOZLpU.js";import"./chunk-EDXVE4YY-CtCcA7_e.js";import"./chunk-X2U36JSP-C2LkxroC.js";import"./chunk-5FUZZQ4R-iDI6Xu0U.js";import"./chunk-ENJZ2VHE-pXVGVCbb.js";import"./chunk-336JU56O-CebpwDDe.js";import{i as t,n,r,t as i}from"./chunk-OYMX7WX6-1ZZWzf9F.js";var a={parser:n,get db(){return new i(2)},renderer:r,styles:t,init:e(e=>{e.state||={},e.state.arrowMarkerAbsolute=e.arrowMarkerAbsolute},`init`)};export{a as diagram};
|