@rubytech/create-sitedesk-code 0.1.610 → 0.1.611
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/package.json +1 -1
- package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +45 -23
- package/payload/platform/plugins/admin/skills/whats-new/SKILL.md +5 -0
- package/payload/platform/plugins/docs/references/telegram-guide.md +44 -22
- package/payload/server/public/activity.html +6 -6
- package/payload/server/public/agents.html +5 -5
- package/payload/server/public/assets/{AdminLoginScreens-uk2gBvI9.js → AdminLoginScreens-Bjsr45ed.js} +1 -1
- package/payload/server/public/assets/AdminLoginScreens-Bjsr45ed.js.br +0 -0
- package/payload/server/public/assets/AdminLoginScreens-Bjsr45ed.js.gz +0 -0
- package/payload/server/public/assets/{AdminShell-DyOPTLdb.js → AdminShell-Dm_nY4jF.js} +1 -1
- package/payload/server/public/assets/AdminShell-Dm_nY4jF.js.br +0 -0
- package/payload/server/public/assets/AdminShell-Dm_nY4jF.js.gz +0 -0
- package/payload/server/public/assets/{activity-DfIud5UH.js → activity-Dz5eWZze.js} +1 -1
- package/payload/server/public/assets/activity-Dz5eWZze.js.br +0 -0
- package/payload/server/public/assets/activity-Dz5eWZze.js.gz +0 -0
- package/payload/server/public/assets/{admin-Duy2d3ks.js → admin-B2IkUoSc.js} +1 -1
- package/payload/server/public/assets/admin-B2IkUoSc.js.br +0 -0
- package/payload/server/public/assets/admin-B2IkUoSc.js.gz +0 -0
- package/payload/server/public/assets/{agents-Rcdk-pni.js → agents-DjDwemOg.js} +1 -1
- package/payload/server/public/assets/agents-DjDwemOg.js.br +0 -0
- package/payload/server/public/assets/agents-DjDwemOg.js.gz +0 -0
- package/payload/server/public/assets/{browser-Bt6h1Pjb.js → browser-BDFx14YM.js} +1 -1
- package/payload/server/public/assets/browser-BDFx14YM.js.br +0 -0
- package/payload/server/public/assets/browser-BDFx14YM.js.gz +0 -0
- package/payload/server/public/assets/{calendar-Di0yArmc.js → calendar-BbUsdMKW.js} +1 -1
- package/payload/server/public/assets/calendar-BbUsdMKW.js.br +0 -0
- package/payload/server/public/assets/calendar-BbUsdMKW.js.gz +0 -0
- package/payload/server/public/assets/chat-fP4sE4pU.js +1 -0
- package/payload/server/public/assets/chat-fP4sE4pU.js.br +2 -0
- package/payload/server/public/assets/chat-fP4sE4pU.js.gz +0 -0
- package/payload/server/public/assets/{chevron-left-QGcFX-3R.js → chevron-left-D3_hiHLC.js} +1 -1
- package/payload/server/public/assets/chevron-left-D3_hiHLC.js.br +0 -0
- package/payload/server/public/assets/clock-kLje910u.js +1 -0
- package/payload/server/public/assets/clock-kLje910u.js.br +0 -0
- package/payload/server/public/assets/clock-kLje910u.js.gz +0 -0
- package/payload/server/public/assets/{copy-RSaF-402.js → copy-Dnw0TkVh.js} +1 -1
- package/payload/server/public/assets/copy-Dnw0TkVh.js.br +0 -0
- package/payload/server/public/assets/copy-Dnw0TkVh.js.gz +0 -0
- package/payload/server/public/assets/data-DKz9_73S.js +1 -0
- package/payload/server/public/assets/data-DKz9_73S.js.br +1 -0
- package/payload/server/public/assets/data-DKz9_73S.js.gz +0 -0
- package/payload/server/public/assets/{field-nfpVNHyk.js → field-mhgbdofr.js} +1 -1
- package/payload/server/public/assets/field-mhgbdofr.js.br +0 -0
- package/payload/server/public/assets/field-mhgbdofr.js.gz +0 -0
- package/payload/server/public/assets/{file-text-Cws2LExM.js → file-text-CVZAL3Er.js} +1 -1
- package/payload/server/public/assets/file-text-CVZAL3Er.js.br +0 -0
- package/payload/server/public/assets/file-text-CVZAL3Er.js.gz +0 -0
- package/payload/server/public/assets/{graph-56nTCvKa.js → graph-NmOxFNdx.js} +1 -1
- package/payload/server/public/assets/graph-NmOxFNdx.js.br +0 -0
- package/payload/server/public/assets/graph-NmOxFNdx.js.gz +0 -0
- package/payload/server/public/assets/{graph-labels-qHDVYalh.js → graph-labels-BTFUSc63.js} +1 -1
- package/payload/server/public/assets/graph-labels-BTFUSc63.js.br +0 -0
- package/payload/server/public/assets/graph-labels-BTFUSc63.js.gz +0 -0
- package/payload/server/public/assets/{jsx-runtime-B5zQuMcr.css → jsx-runtime-dao9WPN0.css} +1 -1
- package/payload/server/public/assets/jsx-runtime-dao9WPN0.css.br +0 -0
- package/payload/server/public/assets/{jsx-runtime-B5zQuMcr.css.gz → jsx-runtime-dao9WPN0.css.gz} +0 -0
- package/payload/server/public/assets/{operator-D-P6oemk.js → operator-CO5ma-ky.js} +1 -1
- package/payload/server/public/assets/operator-CO5ma-ky.js.br +0 -0
- package/payload/server/public/assets/operator-CO5ma-ky.js.gz +0 -0
- package/payload/server/public/assets/{page-8goE0IWS.js → page-BBRWbFzG.js} +1 -1
- package/payload/server/public/assets/page-BBRWbFzG.js.br +0 -0
- package/payload/server/public/assets/page-BBRWbFzG.js.gz +0 -0
- package/payload/server/public/assets/page-CdRrpkky.js +1 -0
- package/payload/server/public/assets/page-CdRrpkky.js.br +0 -0
- package/payload/server/public/assets/page-CdRrpkky.js.gz +0 -0
- package/payload/server/public/assets/play-eeQX0FtC.js +1 -0
- package/payload/server/public/assets/play-eeQX0FtC.js.br +0 -0
- package/payload/server/public/assets/play-eeQX0FtC.js.gz +0 -0
- package/payload/server/public/assets/{public-BwfIj7tM.js → public-2mLo4k7L.js} +1 -1
- package/payload/server/public/assets/public-2mLo4k7L.js.br +0 -0
- package/payload/server/public/assets/public-2mLo4k7L.js.gz +0 -0
- package/payload/server/public/assets/{rotate-ccw-X7-7vE7t.js → rotate-ccw-D-2d4YGp.js} +1 -1
- package/payload/server/public/assets/rotate-ccw-D-2d4YGp.js.br +0 -0
- package/payload/server/public/assets/rotate-ccw-D-2d4YGp.js.gz +0 -0
- package/payload/server/public/assets/{routines-sFud5tka.js → routines-CMW8sm10.js} +1 -1
- package/payload/server/public/assets/routines-CMW8sm10.js.br +0 -0
- package/payload/server/public/assets/routines-CMW8sm10.js.gz +0 -0
- package/payload/server/public/assets/{skills-_Dc3eG9T.js → skills-BQC7SM0J.js} +1 -1
- package/payload/server/public/assets/skills-BQC7SM0J.js.br +0 -0
- package/payload/server/public/assets/skills-BQC7SM0J.js.gz +0 -0
- package/payload/server/public/assets/{tasks-C0u8AtqT.js → tasks-CIs0y00-.js} +1 -1
- package/payload/server/public/assets/tasks-CIs0y00-.js.br +0 -0
- package/payload/server/public/assets/tasks-CIs0y00-.js.gz +0 -0
- package/payload/server/public/assets/{triangle-alert-DD4kSK45.js → triangle-alert-C_68TrTq.js} +1 -1
- package/payload/server/public/assets/triangle-alert-C_68TrTq.js.br +0 -0
- package/payload/server/public/assets/triangle-alert-C_68TrTq.js.gz +0 -0
- package/payload/server/public/assets/{useCopyFeedback-Dq-Putj7.js → useCopyFeedback-1MKNUzp3.js} +1 -1
- package/payload/server/public/assets/useCopyFeedback-1MKNUzp3.js.br +0 -0
- package/payload/server/public/assets/useCopyFeedback-1MKNUzp3.js.gz +0 -0
- package/payload/server/public/assets/{useMediaQuery-Cm_fvNIH.js → useMediaQuery-e4ciNiuO.js} +1 -1
- package/payload/server/public/assets/useMediaQuery-e4ciNiuO.js.br +0 -0
- package/payload/server/public/assets/useMediaQuery-e4ciNiuO.js.gz +0 -0
- package/payload/server/public/assets/{useVoiceRecorder-C6xqnm7i.js → useVoiceRecorder-D7_wLtrS.js} +1 -1
- package/payload/server/public/assets/useVoiceRecorder-D7_wLtrS.js.br +0 -0
- package/payload/server/public/assets/{useVoiceRecorder-C6xqnm7i.js.gz → useVoiceRecorder-D7_wLtrS.js.gz} +0 -0
- package/payload/server/public/assets/{wrench-Bjw6eVl_.js → wrench-BI28h1JF.js} +1 -1
- package/payload/server/public/assets/wrench-BI28h1JF.js.br +0 -0
- package/payload/server/public/assets/wrench-BI28h1JF.js.gz +0 -0
- package/payload/server/public/browser.html +5 -5
- package/payload/server/public/calendar.html +8 -8
- package/payload/server/public/chat.html +14 -14
- package/payload/server/public/data.html +12 -12
- package/payload/server/public/field.html +3 -3
- package/payload/server/public/graph.html +10 -10
- package/payload/server/public/index.html +14 -14
- package/payload/server/public/operator.html +16 -16
- package/payload/server/public/public.html +14 -14
- package/payload/server/public/routines.html +8 -8
- package/payload/server/public/skills.html +6 -6
- package/payload/server/public/tasks.html +7 -7
- package/payload/server/server.js +650 -528
- package/payload/server/public/assets/AdminLoginScreens-uk2gBvI9.js.br +0 -0
- package/payload/server/public/assets/AdminLoginScreens-uk2gBvI9.js.gz +0 -0
- package/payload/server/public/assets/AdminShell-DyOPTLdb.js.br +0 -0
- package/payload/server/public/assets/AdminShell-DyOPTLdb.js.gz +0 -0
- package/payload/server/public/assets/activity-DfIud5UH.js.br +0 -0
- package/payload/server/public/assets/activity-DfIud5UH.js.gz +0 -0
- package/payload/server/public/assets/admin-Duy2d3ks.js.br +0 -0
- package/payload/server/public/assets/admin-Duy2d3ks.js.gz +0 -0
- package/payload/server/public/assets/agents-Rcdk-pni.js.br +0 -0
- package/payload/server/public/assets/agents-Rcdk-pni.js.gz +0 -0
- package/payload/server/public/assets/browser-Bt6h1Pjb.js.br +0 -0
- package/payload/server/public/assets/browser-Bt6h1Pjb.js.gz +0 -0
- package/payload/server/public/assets/calendar-Di0yArmc.js.br +0 -0
- package/payload/server/public/assets/calendar-Di0yArmc.js.gz +0 -0
- package/payload/server/public/assets/chat-xJTrFY2U.js +0 -1
- package/payload/server/public/assets/chat-xJTrFY2U.js.br +0 -1
- package/payload/server/public/assets/chat-xJTrFY2U.js.gz +0 -0
- package/payload/server/public/assets/chevron-left-QGcFX-3R.js.br +0 -0
- package/payload/server/public/assets/clock-PkEm8y4i.js +0 -1
- package/payload/server/public/assets/clock-PkEm8y4i.js.br +0 -0
- package/payload/server/public/assets/clock-PkEm8y4i.js.gz +0 -0
- package/payload/server/public/assets/copy-RSaF-402.js.br +0 -0
- package/payload/server/public/assets/copy-RSaF-402.js.gz +0 -0
- package/payload/server/public/assets/data-CLmmCyzs.js +0 -1
- package/payload/server/public/assets/data-CLmmCyzs.js.br +0 -1
- package/payload/server/public/assets/data-CLmmCyzs.js.gz +0 -0
- package/payload/server/public/assets/field-nfpVNHyk.js.br +0 -0
- package/payload/server/public/assets/field-nfpVNHyk.js.gz +0 -0
- package/payload/server/public/assets/file-text-Cws2LExM.js.br +0 -0
- package/payload/server/public/assets/file-text-Cws2LExM.js.gz +0 -0
- package/payload/server/public/assets/graph-56nTCvKa.js.br +0 -0
- package/payload/server/public/assets/graph-56nTCvKa.js.gz +0 -0
- package/payload/server/public/assets/graph-labels-qHDVYalh.js.br +0 -0
- package/payload/server/public/assets/graph-labels-qHDVYalh.js.gz +0 -0
- package/payload/server/public/assets/jsx-runtime-B5zQuMcr.css.br +0 -0
- package/payload/server/public/assets/operator-D-P6oemk.js.br +0 -2
- package/payload/server/public/assets/operator-D-P6oemk.js.gz +0 -0
- package/payload/server/public/assets/page-8goE0IWS.js.br +0 -0
- package/payload/server/public/assets/page-8goE0IWS.js.gz +0 -0
- package/payload/server/public/assets/page-iL446JAc.js +0 -1
- package/payload/server/public/assets/page-iL446JAc.js.br +0 -0
- package/payload/server/public/assets/page-iL446JAc.js.gz +0 -0
- package/payload/server/public/assets/play-B8bxRax6.js +0 -1
- package/payload/server/public/assets/play-B8bxRax6.js.br +0 -0
- package/payload/server/public/assets/play-B8bxRax6.js.gz +0 -0
- package/payload/server/public/assets/public-BwfIj7tM.js.br +0 -0
- package/payload/server/public/assets/public-BwfIj7tM.js.gz +0 -0
- package/payload/server/public/assets/rotate-ccw-X7-7vE7t.js.br +0 -0
- package/payload/server/public/assets/rotate-ccw-X7-7vE7t.js.gz +0 -0
- package/payload/server/public/assets/routines-sFud5tka.js.br +0 -0
- package/payload/server/public/assets/routines-sFud5tka.js.gz +0 -0
- package/payload/server/public/assets/skills-_Dc3eG9T.js.br +0 -0
- package/payload/server/public/assets/skills-_Dc3eG9T.js.gz +0 -0
- package/payload/server/public/assets/tasks-C0u8AtqT.js.br +0 -0
- package/payload/server/public/assets/tasks-C0u8AtqT.js.gz +0 -0
- package/payload/server/public/assets/triangle-alert-DD4kSK45.js.br +0 -0
- package/payload/server/public/assets/triangle-alert-DD4kSK45.js.gz +0 -0
- package/payload/server/public/assets/useCopyFeedback-Dq-Putj7.js.br +0 -0
- package/payload/server/public/assets/useCopyFeedback-Dq-Putj7.js.gz +0 -0
- package/payload/server/public/assets/useMediaQuery-Cm_fvNIH.js.br +0 -0
- package/payload/server/public/assets/useMediaQuery-Cm_fvNIH.js.gz +0 -0
- package/payload/server/public/assets/useVoiceRecorder-C6xqnm7i.js.br +0 -0
- package/payload/server/public/assets/wrench-Bjw6eVl_.js.br +0 -0
- package/payload/server/public/assets/wrench-Bjw6eVl_.js.gz +0 -0
- /package/payload/server/public/assets/{jsx-runtime-DeRQuYlX.js → jsx-runtime-BY35JYDT.js} +0 -0
- /package/payload/server/public/assets/{jsx-runtime-DeRQuYlX.js.br → jsx-runtime-BY35JYDT.js.br} +0 -0
- /package/payload/server/public/assets/{jsx-runtime-DeRQuYlX.js.gz → jsx-runtime-BY35JYDT.js.gz} +0 -0
|
Binary file
|
package/payload/server/public/assets/{jsx-runtime-B5zQuMcr.css.gz → jsx-runtime-dao9WPN0.css.gz}
RENAMED
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-BycB0eMI.js";import{i as t,n,t as r}from"./jsx-runtime-
|
|
1
|
+
import{o as e}from"./chunk-BycB0eMI.js";import{i as t,n,t as r}from"./jsx-runtime-BY35JYDT.js";import"./useMediaQuery-e4ciNiuO.js";import{n as i,t as a}from"./AdminLoginScreens-Bjsr45ed.js";import"./useVoiceRecorder-D7_wLtrS.js";import"./AdminShell-Dm_nY4jF.js";import{t as o}from"./page-BBRWbFzG.js";import"./useCopyFeedback-1MKNUzp3.js";var s=n(),c=e(t(),1),l=r();function u(){let e=i(`operator`),t=(0,c.useRef)(null);return(0,c.useEffect)(()=>{e.appState!==`chat`&&t.current!==e.appState&&(t.current=e.appState)},[e.appState]),e.appState===`chat`?(0,l.jsx)(o,{variant:`operator`,forceCanonicalSession:window.location.pathname!==`/chat`}):(0,l.jsx)(a,{auth:e})}(0,s.createRoot)(document.getElementById(`root`)).render((0,l.jsx)(u,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-DA-Gezeo.js","assets/preload-helper-eAV8hweq.js","assets/dist-DjYA4E4S.js","assets/chunk-BycB0eMI.js","assets/chunk-U2HBQHQK-DcqGPXEy.js","assets/src-BvINb2fL.js","assets/chunk-5PVQY5BW-C0bRnMKQ.js","assets/chunk-ICPOFSXX-BP8A8zb1.js","assets/_baseFor-BApe6Tla.js","assets/isEmpty-DY_Xp9Na.js","assets/chunk-336JU56O-ChGDYu_S.js","assets/chunk-5FUZZQ4R-B3s1YuQa.js","assets/chunk-X2U36JSP-DtRi7n5Z.js","assets/chunk-ZZ45TVLE-teET41Yh.js","assets/rough.esm-ec8xsRC7.js","assets/chunk-ENJZ2VHE-BdPfdZYB.js","assets/line-K8229GLG.js","assets/path-DY2qBuPM.js","assets/array-eiH4WfvY.js","assets/chunk-BSJP7CBP-0xBlnKJN.js","assets/chunk-426QAEUC-DLLi1nAr.js","assets/chunk-XPW4576I-DmuDCcY3.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e,r as t,t as n}from"./chunk-BycB0eMI.js";import{i as r,t as i}from"./jsx-runtime-
|
|
2
|
+
import{o as e,r as t,t as n}from"./chunk-BycB0eMI.js";import{i as r,t as i}from"./jsx-runtime-BY35JYDT.js";import{$ as a,C as o,F as s,H as c,I as l,K as u,L as d,N as f,P as p,Q as m,R as h,S as g,V as _,a as v,at as y,ct as b,rt as x,u as S,w as C}from"./useMediaQuery-e4ciNiuO.js";import{A as w,C as T,D as E,E as D,M as O,N as ee,O as te,S as ne,_ as k,a as A,b as re,c as ie,d as j,f as ae,g as M,h as oe,i as N,j as se,k as ce,l as le,m as ue,n as de,o as fe,r as pe,s as me,t as he,u as ge,v as _e,w as ve,x as ye,y as be}from"./useVoiceRecorder-D7_wLtrS.js";import{D as P,E as xe,S as Se,T as Ce,b as we,c as Te,d as F,k as Ee,l as De,n as Oe,o as ke,r as Ae,s as je,t as Me,u as Ne,w as Pe,y as Fe}from"./AdminShell-Dm_nY4jF.js";import{t as Ie}from"./chevron-left-D3_hiHLC.js";import{t as Le}from"./copy-Dnw0TkVh.js";import{t as Re}from"./file-text-CVZAL3Er.js";import{t as ze}from"./play-eeQX0FtC.js";import{t as Be}from"./rotate-ccw-D-2d4YGp.js";import{t as Ve}from"./wrench-BI28h1JF.js";import{t as He}from"./preload-helper-eAV8hweq.js";import{t as Ue}from"./useCopyFeedback-1MKNUzp3.js";var We=x(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),Ge=x(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Ke=x(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),qe=x(`graduation-cap`,[[`path`,{d:`M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z`,key:`j76jl0`}],[`path`,{d:`M22 10v6`,key:`1lu8f3`}],[`path`,{d:`M6 12.5V16a6 3 0 0 0 12 0v-3.5`,key:`1r8lef`}]]),Je=x(`inbox`,[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]),Ye=x(`lightbulb`,[[`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,key:`1gvzjb`}],[`path`,{d:`M9 18h6`,key:`x1upvd`}],[`path`,{d:`M10 22h4`,key:`ceow96`}]]),Xe=x(`shield`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}]]);function Ze(e,t,n){if(t!==n)return null;let r=t,i=e.lastIndexOf(`
|
|
3
3
|
`,r-1)+1,a=e.indexOf(`
|
|
4
4
|
`,r),o=a===-1?e.length:a;if(r!==o)return null;let s=e.slice(i,o),c=s.match(/^(\s*)(\d+)\.[ \t]*$/);if(c){let t=c[1];return{value:e.slice(0,i)+t+e.slice(o),caret:i+t.length}}let l=s.match(/^(\s*)(\d+)\.[ \t]/);if(l){let t=`\n${l[1]}${parseInt(l[2],10)+1}. `;return{value:e.slice(0,r)+t+e.slice(r),caret:r+t.length}}return null}function Qe(e,t){let n=[];for(let r of e){if(r.kind!==`file`)continue;let e=r.getAsFile();if(e)if(e.name===``||e.name===`image.png`){let r=e.type.split(`/`)[1]?.replace(`jpeg`,`jpg`)||`png`;n.push(new File([e],`pasted-image-${t}.${r}`,{type:e.type}))}else n.push(e)}return n}function $e(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var et=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,tt=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,nt={};function I(e,t){return((t||nt).jsx?tt:et).test(e)}var rt=/[ \t\n\f\r]/g;function it(e){return typeof e==`object`?e.type===`text`?at(e.value):!1:at(e)}function at(e){return e.replace(rt,``)===``}var ot=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};ot.prototype.normal={},ot.prototype.property={},ot.prototype.space=void 0;function st(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new ot(n,r,t)}function ct(e){return e.toLowerCase()}var L=class{constructor(e,t){this.attribute=t,this.property=e}};L.prototype.attribute=``,L.prototype.booleanish=!1,L.prototype.boolean=!1,L.prototype.commaOrSpaceSeparated=!1,L.prototype.commaSeparated=!1,L.prototype.defined=!1,L.prototype.mustUseProperty=!1,L.prototype.number=!1,L.prototype.overloadedBoolean=!1,L.prototype.property=``,L.prototype.spaceSeparated=!1,L.prototype.space=void 0;var lt=t({boolean:()=>R,booleanish:()=>z,commaOrSpaceSeparated:()=>H,commaSeparated:()=>ft,number:()=>B,overloadedBoolean:()=>dt,spaceSeparated:()=>V}),ut=0,R=pt(),z=pt(),dt=pt(),B=pt(),V=pt(),ft=pt(),H=pt();function pt(){return 2**++ut}var mt=Object.keys(lt),ht=class extends L{constructor(e,t,n,r){let i=-1;if(super(e,t),gt(this,`space`,r),typeof n==`number`)for(;++i<mt.length;){let e=mt[i];gt(this,mt[i],(n<[e])===lt[e])}}};ht.prototype.defined=!0;function gt(e,t,n){n&&(e[t]=n)}function _t(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new ht(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[ct(r)]=r,n[ct(a.attribute)]=r}return new ot(t,n,e.space)}var vt=_t({properties:{ariaActiveDescendant:null,ariaAtomic:z,ariaAutoComplete:null,ariaBusy:z,ariaChecked:z,ariaColCount:B,ariaColIndex:B,ariaColSpan:B,ariaControls:V,ariaCurrent:null,ariaDescribedBy:V,ariaDetails:null,ariaDisabled:z,ariaDropEffect:V,ariaErrorMessage:null,ariaExpanded:z,ariaFlowTo:V,ariaGrabbed:z,ariaHasPopup:null,ariaHidden:z,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:V,ariaLevel:B,ariaLive:null,ariaModal:z,ariaMultiLine:z,ariaMultiSelectable:z,ariaOrientation:null,ariaOwns:V,ariaPlaceholder:null,ariaPosInSet:B,ariaPressed:z,ariaReadOnly:z,ariaRelevant:null,ariaRequired:z,ariaRoleDescription:V,ariaRowCount:B,ariaRowIndex:B,ariaRowSpan:B,ariaSelected:z,ariaSetSize:B,ariaSort:null,ariaValueMax:B,ariaValueMin:B,ariaValueNow:B,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function yt(e,t){return t in e?e[t]:t}function bt(e,t){return yt(e,t.toLowerCase())}var xt=_t({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:ft,acceptCharset:V,accessKey:V,action:null,allow:null,allowFullScreen:R,allowPaymentRequest:R,allowUserMedia:R,alt:null,as:null,async:R,autoCapitalize:null,autoComplete:V,autoFocus:R,autoPlay:R,blocking:V,capture:null,charSet:null,checked:R,cite:null,className:V,cols:B,colSpan:null,content:null,contentEditable:z,controls:R,controlsList:V,coords:B|ft,crossOrigin:null,data:null,dateTime:null,decoding:null,default:R,defer:R,dir:null,dirName:null,disabled:R,download:dt,draggable:z,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:R,formTarget:null,headers:V,height:B,hidden:dt,high:B,href:null,hrefLang:null,htmlFor:V,httpEquiv:V,id:null,imageSizes:null,imageSrcSet:null,inert:R,inputMode:null,integrity:null,is:null,isMap:R,itemId:null,itemProp:V,itemRef:V,itemScope:R,itemType:V,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:R,low:B,manifest:null,max:null,maxLength:B,media:null,method:null,min:null,minLength:B,multiple:R,muted:R,name:null,nonce:null,noModule:R,noValidate:R,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:R,optimum:B,pattern:null,ping:V,placeholder:null,playsInline:R,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:R,referrerPolicy:null,rel:V,required:R,reversed:R,rows:B,rowSpan:B,sandbox:V,scope:null,scoped:R,seamless:R,selected:R,shadowRootClonable:R,shadowRootDelegatesFocus:R,shadowRootMode:null,shape:null,size:B,sizes:null,slot:null,span:B,spellCheck:z,src:null,srcDoc:null,srcLang:null,srcSet:null,start:B,step:null,style:null,tabIndex:B,target:null,title:null,translate:null,type:null,typeMustMatch:R,useMap:null,value:z,width:B,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:V,axis:null,background:null,bgColor:null,border:B,borderColor:null,bottomMargin:B,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:R,declare:R,event:null,face:null,frame:null,frameBorder:null,hSpace:B,leftMargin:B,link:null,longDesc:null,lowSrc:null,marginHeight:B,marginWidth:B,noResize:R,noHref:R,noShade:R,noWrap:R,object:null,profile:null,prompt:null,rev:null,rightMargin:B,rules:null,scheme:null,scrolling:z,standby:null,summary:null,text:null,topMargin:B,valueType:null,version:null,vAlign:null,vLink:null,vSpace:B,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:R,disableRemotePlayback:R,prefix:null,property:null,results:B,security:null,unselectable:null},space:`html`,transform:bt}),St=_t({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:H,accentHeight:B,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:B,amplitude:B,arabicForm:null,ascent:B,attributeName:null,attributeType:null,azimuth:B,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:B,by:null,calcMode:null,capHeight:B,className:V,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:B,diffuseConstant:B,direction:null,display:null,dur:null,divisor:B,dominantBaseline:null,download:R,dx:null,dy:null,edgeMode:null,editable:null,elevation:B,enableBackground:null,end:null,event:null,exponent:B,externalResourcesRequired:null,fill:null,fillOpacity:B,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:ft,g2:ft,glyphName:ft,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:B,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:B,horizOriginX:B,horizOriginY:B,id:null,ideographic:B,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:B,k:B,k1:B,k2:B,k3:B,k4:B,kernelMatrix:H,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:B,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:B,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:B,overlineThickness:B,paintOrder:null,panose1:null,path:null,pathLength:B,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:V,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:B,pointsAtY:B,pointsAtZ:B,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:H,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:H,rev:H,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:H,requiredFeatures:H,requiredFonts:H,requiredFormats:H,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:B,specularExponent:B,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:B,strikethroughThickness:B,string:null,stroke:null,strokeDashArray:H,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:B,strokeOpacity:B,strokeWidth:null,style:null,surfaceScale:B,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:H,tabIndex:B,tableValues:null,target:null,targetX:B,targetY:B,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:H,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:B,underlineThickness:B,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:B,values:null,vAlphabetic:B,vMathematical:B,vectorEffect:null,vHanging:B,vIdeographic:B,version:null,vertAdvY:B,vertOriginX:B,vertOriginY:B,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:B,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:yt}),Ct=_t({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),wt=_t({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:bt}),Tt=_t({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),Et={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},Dt=/[A-Z]/g,Ot=/-[a-z]/g,kt=/^data[-\w.:]+$/i;function At(e,t){let n=ct(t),r=t,i=L;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&kt.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(Ot,Mt);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!Ot.test(e)){let n=e.replace(Dt,jt);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=ht}return new i(r,t)}function jt(e){return`-`+e.toLowerCase()}function Mt(e){return e.charAt(1).toUpperCase()}var Nt=st([vt,xt,Ct,wt,Tt],`html`),Pt=st([vt,St,Ct,wt,Tt],`svg`);function U(e){return e.join(` `).trim()}var Ft=n(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=`
|
|
5
5
|
`,d=`/`,f=`*`,p=``,m=`comment`,h=`declaration`;function g(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,g=1;function v(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);g=~n?e.length-n:g+e.length}function y(){var e={line:l,column:g};return function(t){return t.position=new b(e),C(),t}}function b(e){this.start=e,this.end={line:l,column:g},this.source=t.source}b.prototype.content=e;function x(n){var r=Error(t.source+`:`+l+`:`+g+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=g,r.source=e,!t.silent)throw r}function S(t){var n=t.exec(e);if(n){var r=n[0];return v(r),e=e.slice(r.length),n}}function C(){S(i)}function w(e){var t;for(e||=[];t=T();)t!==!1&&e.push(t);return e}function T(){var t=y();if(!(d!=e.charAt(0)||f!=e.charAt(1))){for(var n=2;p!=e.charAt(n)&&(f!=e.charAt(n)||d!=e.charAt(n+1));)++n;if(n+=2,p===e.charAt(n-1))return x(`End of comment missing`);var r=e.slice(2,n-2);return g+=2,v(r),e=e.slice(n),g+=2,t({type:m,comment:r})}}function E(){var e=y(),t=S(a);if(t){if(T(),!S(o))return x(`property missing ':'`);var r=S(s),i=e({type:h,property:_(t[0].replace(n,p)),value:r?_(r[0].replace(n,p)):p});return S(c),i}}function D(){var e=[];w(e);for(var t;t=E();)t!==!1&&(e.push(t),w(e));return e}return C(),D()}function _(e){return e?e.replace(l,p):p}t.exports=g})),It=n((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,`__esModule`,{value:!0}),e.default=r;var n=t(Ft());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),Lt=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),Rt=n(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(It()),r=Lt();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),zt=Vt(`end`),Bt=Vt(`start`);function Vt(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function Ht(e){let t=Bt(e),n=zt(e);if(t&&n)return{start:t,end:n}}function Ut(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?Gt(e.position):`start`in e||`end`in e?Gt(e):`line`in e||`column`in e?Wt(e):``}function Wt(e){return Kt(e&&e.line)+`:`+Kt(e&&e.column)}function Gt(e){return Wt(e&&e.start)+`-`+Wt(e&&e.end)}function Kt(e){return e&&typeof e==`number`?e:1}var W=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=Ut(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};W.prototype.file=``,W.prototype.name=``,W.prototype.reason=``,W.prototype.message=``,W.prototype.stack=``,W.prototype.column=void 0,W.prototype.line=void 0,W.prototype.ancestors=void 0,W.prototype.cause=void 0,W.prototype.fatal=void 0,W.prototype.place=void 0,W.prototype.ruleId=void 0,W.prototype.source=void 0;var qt=e(Rt(),1),Jt={}.hasOwnProperty,Yt=new Map,Xt=/[A-Z]/g,Zt=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),Qt=new Set([`td`,`th`]),$t=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function en(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=fn(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=dn(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?Pt:Nt,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=tn(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function tn(e,t,n){if(t.type===`element`)return nn(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return rn(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return on(e,t,n);if(t.type===`mdxjsEsm`)return an(e,t);if(t.type===`root`)return sn(e,t,n);if(t.type===`text`)return cn(e,t)}function nn(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=Pt,e.schema=i),e.ancestors.push(t);let a=vn(e,t.tagName,!1),o=pn(e,t),s=hn(e,t);return Zt.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!it(e):!0})),ln(e,o,a,t),un(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function rn(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}yn(e,t.position)}function an(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);yn(e,t.position)}function on(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=Pt,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:vn(e,t.name,!0),o=mn(e,t),s=hn(e,t);return ln(e,o,a,t),un(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function sn(e,t,n){let r={};return un(r,hn(e,t)),e.create(t,e.Fragment,r,n)}function cn(e,t){return t.value}function ln(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function un(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function dn(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function fn(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=Bt(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function pn(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&Jt.call(t.properties,i)){let a=gn(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&Qt.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function mn(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else yn(e,t.position);else{let i=r.name,a;if(r.value&&typeof r.value==`object`)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else yn(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function hn(e,t){let n=[],r=-1,i=e.passKeys?new Map:Yt;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=tn(e,a,o);s!==void 0&&n.push(s)}return n}function gn(e,t,n){let r=At(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?$e(n):U(n)),r.property===`style`){let t=typeof n==`object`?n:_n(e,String(n));return e.stylePropertyNameCase===`css`&&(t=bn(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?Et[r.property]||r.property:r.attribute,n]}}function _n(e,t){try{return(0,qt.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new W("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=$t+`#cannot-parse-style-attribute`,r}}function vn(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=I(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=I(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return Jt.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);yn(e)}function yn(e,t){let n=new W("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=$t+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function bn(e){let t={},n;for(n in e)Jt.call(e,n)&&(t[xn(n)]=e[n]);return t}function xn(e){let t=e.replace(Xt,Sn);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function Sn(e){return`-`+e.toLowerCase()}var Cn={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},wn={};function Tn(e,t){let n=t||wn;return En(e,typeof n.includeImageAlt==`boolean`?n.includeImageAlt:!0,typeof n.includeHtml==`boolean`?n.includeHtml:!0)}function En(e,t,n){if(On(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return Dn(e.children,t,n)}return Array.isArray(e)?Dn(e,t,n):``}function Dn(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=En(e[i],t,n);return r.join(``)}function On(e){return!!(e&&typeof e==`object`)}var kn=document.createElement(`i`);function An(e){let t=`&`+e+`;`;kn.innerHTML=t;let n=kn.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`||n===t?!1:n}function jn(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function Mn(e,t){return e.length>0?(jn(e,e.length,0,t),e):t}var Nn={}.hasOwnProperty;function Pn(e){let t={},n=-1;for(;++n<e.length;)Fn(t,e[n]);return t}function Fn(e,t){let n;for(n in t){let r=(Nn.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){Nn.call(r,a)||(r[a]=[]);let e=i[a];In(r[a],Array.isArray(e)?e:e?[e]:[])}}}function In(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);jn(e,0,0,r)}function Ln(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function Rn(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var G=Kn(/[A-Za-z]/),K=Kn(/[\dA-Za-z]/),zn=Kn(/[#-'*+\--9=?A-Z^-~]/);function Bn(e){return e!==null&&(e<32||e===127)}var Vn=Kn(/\d/),Hn=Kn(/[\dA-Fa-f]/),Un=Kn(/[!-/:-@[-`{-~]/);function q(e){return e!==null&&e<-2}function J(e){return e!==null&&(e<0||e===32)}function Y(e){return e===-2||e===-1||e===32}var Wn=Kn(/\p{P}|\p{S}/u),Gn=Kn(/\s/);function Kn(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function qn(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&K(e.charCodeAt(n+1))&&K(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function X(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return Y(r)?(e.enter(n),s(r)):t(r)}function s(r){return Y(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var Jn={tokenize:Yn};function Yn(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),X(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return q(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var Xn={tokenize:Qn},Zn={tokenize:$n};function Qn(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return jn(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Zn,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(Zn,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return q(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;jn(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-- >r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function $n(e,t,n){return X(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function er(e){if(e===null||J(e)||Gn(e))return 1;if(Wn(e))return 2}function tr(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var nr={name:`attention`,resolveAll:rr,tokenize:ir};function rr(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};ar(d,-c),ar(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=Mn(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=Mn(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=Mn(l,tr(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=Mn(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=Mn(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,jn(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function ir(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=er(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=er(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function ar(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var or={name:`autolink`,tokenize:sr};function sr(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return G(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||K(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||K(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||Bn(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):zn(t)?(e.consume(t),l):n(t)}function u(e){return K(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||K(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var cr={partial:!0,tokenize:lr};function lr(e,t,n){return r;function r(t){return Y(t)?X(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||q(e)?t(e):n(e)}}var ur={continuation:{tokenize:fr},exit:pr,name:`blockQuote`,tokenize:dr};function dr(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return Y(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function fr(e,t,n){let r=this;return i;function i(t){return Y(t)?X(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(ur,t,n)(r)}}function pr(e){e.exit(`blockQuote`)}var mr={name:`characterEscape`,tokenize:hr};function hr(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return Un(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var gr={name:`characterReference`,tokenize:_r};function _r(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=K,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=Hn,u):(e.enter(`characterReferenceValue`),a=7,o=Vn,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===K&&!An(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var vr={partial:!0,tokenize:xr},yr={concrete:!0,name:`codeFenced`,tokenize:br};function br(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),Y(t)?X(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||q(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(vr,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||q(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):Y(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),X(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||q(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||q(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&Y(t)?X(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||q(t)?e.check(vr,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||q(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),Y(t)?X(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),Y(t)?X(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||q(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function xr(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var Sr={name:`codeIndented`,tokenize:wr},Cr={partial:!0,tokenize:Tr};function wr(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),X(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):q(t)?e.attempt(Cr,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||q(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function Tr(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):X(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):q(e)?i(e):n(e)}}var Er={name:`codeText`,previous:Or,resolve:Dr,tokenize:kr};function Dr(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Or(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function kr(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||q(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var Ar=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&jr(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),jr(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),jr(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let t=this.left.splice(e,1/0);jr(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);jr(this.left,t.reverse())}}};function jr(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function Mr(e){let t={},n=-1,r,i,a,o,s,c,l,u=new Ar(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,Nr(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(!(o[1].type===`linePrefix`||o[1].type===`listItemIndent`))break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return jn(e,0,1/0,u.slice(0)),!l}function Nr(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var Pr={resolve:Ir,tokenize:Lr},Fr={partial:!0,tokenize:Rr};function Ir(e){return Mr(e),e}function Lr(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):q(t)?e.check(Fr,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function Rr(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),X(e,a,`linePrefix`)}function a(i){if(i===null||q(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function zr(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||Bn(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||q(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||J(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||Bn(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function Br(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):q(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||q(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!Y(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function Vr(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),X(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||q(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function Hr(e,t){let n;return r;function r(i){return q(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):Y(i)?X(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var Ur={name:`definition`,tokenize:Gr},Wr={partial:!0,tokenize:Kr};function Gr(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return Br.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=Rn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return J(t)?Hr(e,l)(t):l(t)}function l(t){return zr(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(Wr,d,d)(t)}function d(t){return Y(t)?X(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||q(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function Kr(e,t,n){return r;function r(t){return J(t)?Hr(e,i)(t):n(t)}function i(t){return Vr(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return Y(t)?X(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||q(e)?t(e):n(e)}}var qr={name:`hardBreakEscape`,tokenize:Jr};function Jr(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return q(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var Yr={name:`headingAtx`,resolve:Xr,tokenize:Zr};function Xr(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},jn(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function Zr(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||J(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||q(n)?(e.exit(`atxHeading`),t(n)):Y(n)?X(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||J(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var Qr=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),$r=[`pre`,`script`,`style`,`textarea`],ei={concrete:!0,name:`htmlFlow`,resolveTo:ri,tokenize:ii},ti={partial:!0,tokenize:oi},ni={partial:!0,tokenize:ai};function ri(e){let t=e.length;for(;t--&&!(e[t][0]===`enter`&&e[t][1].type===`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function ii(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:j):G(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):G(a)?(e.consume(a),i=4,r.interrupt?t:j):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:j):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return G(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||J(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&$r.includes(l)?(i=1,r.interrupt?t(s):O(s)):Qr.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||K(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return Y(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||G(t)?(e.consume(t),b):Y(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||K(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):Y(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):Y(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||q(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||J(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||Y(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||q(t)?O(t):Y(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),k):t===60&&i===1?(e.consume(t),A):t===62&&i===4?(e.consume(t),ae):t===63&&i===3?(e.consume(t),j):t===93&&i===5?(e.consume(t),ie):q(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(ti,M,ee)(t)):t===null||q(t)?(e.exit(`htmlFlowData`),ee(t)):(e.consume(t),O)}function ee(t){return e.check(ni,te,M)(t)}function te(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),ne}function ne(t){return t===null||q(t)?ee(t):(e.enter(`htmlFlowData`),O(t))}function k(t){return t===45?(e.consume(t),j):O(t)}function A(t){return t===47?(e.consume(t),o=``,re):O(t)}function re(t){if(t===62){let n=o.toLowerCase();return $r.includes(n)?(e.consume(t),ae):O(t)}return G(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),re):O(t)}function ie(t){return t===93?(e.consume(t),j):O(t)}function j(t){return t===62?(e.consume(t),ae):t===45&&i===2?(e.consume(t),j):O(t)}function ae(t){return t===null||q(t)?(e.exit(`htmlFlowData`),M(t)):(e.consume(t),ae)}function M(n){return e.exit(`htmlFlow`),t(n)}}function ai(e,t,n){let r=this;return i;function i(t){return q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function oi(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(cr,t,n)}}var si={name:`htmlText`,tokenize:ci};function ci(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):G(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):G(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):q(t)?(o=d,A(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?k(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):q(t)?(o=h,A(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?k(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?k(t):q(t)?(o=v,A(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):q(t)?(o=y,A(t)):(e.consume(t),y)}function b(e){return e===62?k(e):y(e)}function x(t){return G(t)?(e.consume(t),S):n(t)}function S(t){return t===45||K(t)?(e.consume(t),S):C(t)}function C(t){return q(t)?(o=C,A(t)):Y(t)?(e.consume(t),C):k(t)}function w(t){return t===45||K(t)?(e.consume(t),w):t===47||t===62||J(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),k):t===58||t===95||G(t)?(e.consume(t),E):q(t)?(o=T,A(t)):Y(t)?(e.consume(t),T):k(t)}function E(t){return t===45||t===46||t===58||t===95||K(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):q(t)?(o=D,A(t)):Y(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,ee):q(t)?(o=O,A(t)):Y(t)?(e.consume(t),O):(e.consume(t),te)}function ee(t){return t===i?(e.consume(t),i=void 0,ne):t===null?n(t):q(t)?(o=ee,A(t)):(e.consume(t),ee)}function te(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||J(t)?T(t):(e.consume(t),te)}function ne(e){return e===47||e===62||J(e)?T(e):n(e)}function k(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function A(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),re}function re(t){return Y(t)?X(e,ie,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):ie(t)}function ie(t){return e.enter(`htmlTextData`),o(t)}}var li={name:`labelEnd`,resolveAll:pi,resolveTo:mi,tokenize:hi},ui={tokenize:gi},di={tokenize:_i},fi={tokenize:vi};function pi(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&jn(e,0,e.length,n),e}function mi(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=Mn(s,e.slice(a+1,a+r+3)),s=Mn(s,[[`enter`,u,t]]),s=Mn(s,tr(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=Mn(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=Mn(s,e.slice(o+1)),s=Mn(s,[[`exit`,c,t]]),jn(e,a,e.length,s),e}function hi(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(Rn(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(ui,u,o?u:d)(t):t===91?e.attempt(di,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(fi,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function gi(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return J(t)?Hr(e,a)(t):a(t)}function a(t){return t===41?u(t):zr(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return J(t)?Hr(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?Vr(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return J(t)?Hr(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function _i(e,t,n){let r=this;return i;function i(t){return Br.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(Rn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function vi(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var yi={name:`labelStartImage`,resolveAll:li.resolveAll,tokenize:bi};function bi(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var xi={name:`labelStartLink`,resolveAll:li.resolveAll,tokenize:Si};function Si(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var Ci={name:`lineEnding`,tokenize:wi};function wi(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),X(e,t,`linePrefix`)}}var Ti={name:`thematicBreak`,tokenize:Ei};function Ei(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||q(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),Y(t)?X(e,s,`whitespace`)(t):s(t))}}var Z={continuation:{tokenize:Ai},exit:Mi,name:`list`,tokenize:ki},Di={partial:!0,tokenize:Ni},Oi={partial:!0,tokenize:ji};function ki(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:Vn(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(Ti,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return Vn(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(cr,r.interrupt?n:u,e.attempt(Di,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return Y(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function Ai(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(cr,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,X(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!Y(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Oi,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,X(e,e.attempt(Z,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function ji(e,t,n){let r=this;return X(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function Mi(e){e.exit(this.containerState.type)}function Ni(e,t,n){let r=this;return X(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!Y(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var Pi={name:`setextUnderline`,resolveTo:Fi,tokenize:Ii};function Fi(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function Ii(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),Y(t)?X(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||q(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var Li={tokenize:Ri};function Ri(e){let t=this,n=e.attempt(cr,r,e.attempt(this.parser.constructs.flowInitial,i,X(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Pr,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var zi={resolveAll:Ui()},Bi=Hi(`string`),Vi=Hi(`text`);function Hi(e){return{resolveAll:Ui(e===`text`?Wi:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function Ui(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function Wi(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var Gi=t({attentionMarkers:()=>$i,contentInitial:()=>qi,disable:()=>ea,document:()=>Ki,flow:()=>Yi,flowInitial:()=>Ji,insideSpan:()=>Qi,string:()=>Xi,text:()=>Zi}),Ki={42:Z,43:Z,45:Z,48:Z,49:Z,50:Z,51:Z,52:Z,53:Z,54:Z,55:Z,56:Z,57:Z,62:ur},qi={91:Ur},Ji={[-2]:Sr,[-1]:Sr,32:Sr},Yi={35:Yr,42:Ti,45:[Pi,Ti],60:ei,61:Pi,95:Ti,96:yr,126:yr},Xi={38:gr,92:mr},Zi={[-5]:Ci,[-4]:Ci,[-3]:Ci,33:yi,38:gr,42:nr,60:[or,si],91:xi,92:[qr,mr],93:li,95:nr,96:Er},Qi={null:[nr,zi]},$i={null:[42,95]},ea={null:[]};function ta(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=Mn(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=tr(a,l.events,l),l.events):[]}function f(e,t){return ra(p(e),t)}function p(e){return na(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){q(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&jn(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function na(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function ra(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./chunk-BycB0eMI.js";import{i as t,r as n,t as r}from"./jsx-runtime-BY35JYDT.js";import{A as i,B as a,C as o,H as s,I as c,K as l,L as u,N as d,P as f,R as p,S as m,V as h,X as ee,Y as g,f as _,g as v,h as y,n as te,p as b,rt as x,t as ne,tt as re,ut as S,x as C,y as w,z as ie}from"./useMediaQuery-e4ciNiuO.js";import{A as ae,M as T,N as E,T as oe,c as D,k as se,n as O,p as k,r as A}from"./useVoiceRecorder-D7_wLtrS.js";import{t as j}from"./chevron-left-D3_hiHLC.js";import{t as ce}from"./file-text-CVZAL3Er.js";import{i as le,t as M}from"./graph-labels-BTFUSc63.js";import{t as ue}from"./triangle-alert-C_68TrTq.js";import{i as de,n as fe,t as pe}from"./file-download-B7zwa78w.js";var me=x(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),he=x(`folder-plus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`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`}]]),N=x(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),ge=x(`layout-grid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),_e=x(`list`,[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]),ve=x(`send-horizontal`,[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),P=x(`smile`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 14s1.5 2 4 2 4-2 4-2`,key:`1y1vjs`}],[`line`,{x1:`9`,x2:`9.01`,y1:`9`,y2:`9`,key:`yxxnd0`}],[`line`,{x1:`15`,x2:`15.01`,y1:`9`,y2:`9`,key:`1p4y9e`}]]),ye=x(`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`}]]),F=e(t(),1);function be(){let[e,t]=(0,F.useState)([]),[n,r]=(0,F.useState)(!1),[i,a]=(0,F.useState)(null),o=(0,F.useRef)(null),s=(0,F.useCallback)(e=>{a(null);let n=e.find(e=>!A(e.type,E));if(n){a(`Unsupported file type: "${n.type}". Supported: images, PDF, plain text, markdown, CSV, calendar, zip, voice notes.`);return}let r=e.find(e=>e.size>T);if(r){a(`"${r.name}" exceeds the 50 MB limit.`);return}t(t=>[...t,...e].slice(0,5))},[]);return{pendingFiles:e,setPendingFiles:t,isDragOver:n,attachError:i,setAttachError:a,fileInputRef:o,addFiles:s,clearFiles:(0,F.useCallback)(()=>{t([]),a(null)},[]),removeFile:(0,F.useCallback)(e=>{t(t=>t.filter((t,n)=>n!==e))},[]),onDragOver:(0,F.useCallback)(e=>{e.preventDefault(),r(!0)},[]),onDragLeave:(0,F.useCallback)(()=>{r(!1)},[]),onDrop:(0,F.useCallback)(e=>{e.preventDefault(),r(!1),s([...e.dataTransfer.files])},[s])}}var xe=[[128512],[128515],[128516],[128513],[128518],[128517],[128514],[129315],[128578],[128579],[128521],[128522],[128519],[128525],[128536],[128535],[128540],[128541],[129303],[129300],[128528],[128566],[128564],[128526],[129395],[128546],[128557],[128548],[128544],[128533],[128556],[129393],[128077],[128078],[128076],[128591],[128079],[128588],[128170],[128075],[129309],[10084,65039],[128293],[11088],[127881],[10024],[128175],[128064]].map(e=>String.fromCodePoint(...e));function Se(e,t,n,r){let i=e.length,a=Math.max(0,Math.min(n??i,i)),o=Math.max(a,Math.min(r??a,i));return{value:e.slice(0,a)+t+e.slice(o),caret:a+t.length}}var I=r();function Ce({onSelect:e}){return(0,I.jsx)(`div`,{className:`wa-emoji-popover`,role:`menu`,"aria-label":`Emoji picker`,children:xe.map((t,n)=>(0,I.jsx)(`button`,{type:`button`,role:`menuitem`,className:`wa-emoji-item`,onClick:()=>e(t),children:t},n))})}function we({sessionKey:e,onPick:t,onClose:n}){let[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(null),[s,l]=(0,F.useState)(null),[u,d]=(0,F.useState)(!1),f=(0,F.useCallback)(t=>{d(!0),l(null),fetch(`/api/admin/files?path=${encodeURIComponent(t)}&session_key=${encodeURIComponent(e)}`).then(async e=>{let t=await e.json().catch(()=>({}));if(!e.ok)throw Error(t.error??`Could not list files`);return t}).then(e=>{o(e),i(e.path===`.`?``:e.path)}).catch(e=>l(e instanceof Error?e.message:String(e))).finally(()=>d(!1))},[e]);(0,F.useEffect)(()=>{f(``)},[f]);let p=e=>f(r?`${r}/${e}`:e),m=()=>{let e=r.split(`/`).filter(Boolean);e.pop(),f(e.join(`/`))},h=e=>{let n=e.entryPath??e.name;t({path:r?`${r}/${n}`:n,name:e.displayName??e.name})};return(0,I.jsx)(`div`,{className:`wa-picker-backdrop`,role:`dialog`,"aria-label":`Choose a device file`,onClick:n,children:(0,I.jsxs)(`div`,{className:`wa-picker`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`div`,{className:`wa-picker-head`,children:[r&&(0,I.jsx)(`button`,{type:`button`,className:`wa-picker-icon-btn`,onClick:m,"aria-label":`Up one folder`,children:(0,I.jsx)(j,{size:18})}),(0,I.jsx)(`span`,{className:`wa-picker-title`,children:r||`Device storage`}),(0,I.jsx)(`button`,{type:`button`,className:`wa-picker-icon-btn`,onClick:n,"aria-label":`Close file picker`,children:(0,I.jsx)(c,{size:18})})]}),s&&(0,I.jsx)(`p`,{className:`wa-picker-error`,role:`alert`,children:s}),u&&(0,I.jsx)(`p`,{className:`wa-picker-empty`,children:`Loading…`}),a&&!u&&(0,I.jsxs)(`ul`,{className:`wa-picker-list`,children:[a.entries.length===0&&(0,I.jsx)(`li`,{className:`wa-picker-empty`,children:`This folder is empty.`}),a.entries.map(e=>(0,I.jsx)(`li`,{children:e.kind===`directory`?(0,I.jsxs)(`button`,{type:`button`,className:`wa-picker-row`,onClick:()=>p(e.name),children:[(0,I.jsx)(g,{size:16,"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`wa-picker-name`,children:e.displayName??e.name})]}):e.kind===`file`?(0,I.jsxs)(`button`,{type:`button`,className:`wa-picker-row`,onClick:()=>h(e),children:[(0,I.jsx)(ce,{size:16,"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`wa-picker-name`,children:e.displayName??e.name})]}):null},e.name))]})]})})}var Te=n();function Ee(e){return`${Math.floor(e/60)}:${String(e%60).padStart(2,`0`)}`}function L({transport:e,sessionKey:t,replyTo:n,onClearReply:r,features:i}){let a=i?.attachments!==!1,o=i?.voice!==!1,s=i?.deviceFiles!==!1,l=i?.quote!==!1,[d,f]=(0,F.useState)(``),[m,ee]=(0,F.useState)(!1),[g,_]=(0,F.useState)(null),[v,y]=(0,F.useState)(null),[te,b]=(0,F.useState)(!1),[x,re]=(0,F.useState)(!1),[S,C]=(0,F.useState)(!1),[w,ie]=(0,F.useState)([]),T=(0,F.useRef)(null),{pendingFiles:E,attachError:oe,setAttachError:D,addFiles:k,removeFile:A,clearFiles:j}=be(),{state:le,elapsedSeconds:M,errorMessage:ue,start:de,send:fe,discard:pe}=O(),me=le===`recording`||le===`paused`,he=(0,F.useCallback)(()=>{de()},[de]),ge=(0,F.useCallback)(async()=>{let e=await fe();if(e){let t=e.type===`audio/ogg`?`.ogg`:e.type===`audio/mp4`?`.m4a`:`.webm`;k([new File([e],`voice-note${t}`,{type:e.type})])}},[M,fe,k]),_e=(0,F.useCallback)(()=>{pe()},[M,pe]),ye=(0,F.useRef)(!1),xe=()=>Math.round((typeof window>`u`?900:window.innerHeight)/3),[L,R]=(0,F.useState)(null),[z,De]=(0,F.useState)(null),B=(0,F.useRef)(null),V=(0,F.useCallback)(e=>{let t=B.current;t&&R(Math.min(xe(),Math.max(44,t.startH+(t.startY-e.clientY))))},[]),Oe=(0,F.useCallback)(()=>{B.current=null,window.removeEventListener(`pointermove`,V),window.removeEventListener(`pointerup`,Oe)},[V]),ke=(0,F.useCallback)(e=>{B.current={startY:e.clientY,startH:T.current?.offsetHeight??44},window.addEventListener(`pointermove`,V),window.addEventListener(`pointerup`,Oe),e.preventDefault()},[V,Oe]),H=(0,F.useCallback)(e=>{let t=L??T.current?.offsetHeight??44,n=null;e.key===`ArrowUp`?(e.preventDefault(),n=Math.min(xe(),t+24)):e.key===`ArrowDown`&&(e.preventDefault(),n=Math.max(44,t-24)),n!==null&&R(n)},[L]),Ae=(0,F.useRef)(``);(0,F.useEffect)(()=>{let e=T.current;if(!e)return;let t=Ae.current!==``&&d===``;if(Ae.current=d,L!==null){t&&R(null);return}let n=e.style.height;e.style.height=`auto`;let r=Math.min(xe(),Math.max(44,e.scrollHeight));e.style.height=n,De(r)},[d,L]);let je=(d.trim().length>0||E.length>0||w.length>0)&&!m,Me=(0,F.useCallback)(async()=>{if(!ye.current&&!(d.trim().length===0&&E.length===0&&w.length===0)){ye.current=!0,ee(!0),_(null),y(null);try{let i=`${e.endpoint}?session_key=${encodeURIComponent(t)}`,a;if(E.length>0||w.length>0){let t=new FormData;for(let[n,r]of Object.entries(e.fields))t.append(n,r);d.trim()&&t.append(`text`,d);for(let e of E)t.append(`files`,e);for(let e of w)t.append(`fileRefs`,e.path);n&&t.append(`quotedId`,n.msgKeyId),a=await fetch(i,{method:`POST`,body:t})}else a=await fetch(i,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({...e.fields,text:d,...n?{quotedId:n.msgKeyId}:{}})});let o=await a.json().catch(()=>({}));if(!a.ok){_(o.error??`Send failed.`),console.warn(`[operator-ui] op=reply-fail endpoint=${e.endpoint} error=${o.error??`unknown`}`);return}let s=o.context;s&&s.written===!1&&(y(`Sent. The agent's record was not updated: ${s.reason??`unknown`}.`),console.warn(`[operator-ui] op=context-not-written endpoint=${e.endpoint} reason=${s.reason??`unknown`}`)),f(``),j(),ie([]),r?.()}catch(t){_(`Could not reach the server. Try again.`),console.warn(`[operator-ui] op=reply-fail endpoint=${e.endpoint} error=${String(t)}`)}finally{ye.current=!1,ee(!1)}}},[d,E,w,n,r,e,t,j]),Ne=(0,F.useCallback)(e=>{let t=T.current,{value:n,caret:r}=Se(d,e,t?t.selectionStart:null,t?t.selectionEnd:null);f(n),b(!1),requestAnimationFrame(()=>{let e=T.current;e&&(e.focus(),e.setSelectionRange(r,r))})},[d]),Pe=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),je&&Me())},Fe=e=>e.dataTransfer.types.includes(`Files`),Ie=(0,F.useCallback)(e=>{Fe(e)&&(e.preventDefault(),a&&C(!0))},[a]),Le=(0,F.useCallback)(()=>C(!1),[]),Re=(0,F.useCallback)(e=>{if(!Fe(e))return;e.preventDefault(),C(!1);let t=[...e.dataTransfer.files];if(t.length!==0){if(!a){D(`This conversation takes text only. Attachments cannot be sent here.`);return}Math.max(0,E.length+t.length-5),k(t)}},[E.length,k,a,D]),ze=e=>e.startsWith(`image/`)?(0,I.jsx)(N,{size:14}):e===`application/pdf`?(0,I.jsx)(ce,{size:14}):(0,I.jsx)(ae,{size:14}),Be=ne(`(max-width: 720px)`),[Ve,U]=(0,F.useState)(null);(0,F.useEffect)(()=>{U(Be?document.querySelector(`.admin-footer`):null)},[Be]);let W=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:`wa-reply-emoji`,onClick:()=>b(e=>!e),disabled:m,"aria-label":`Emoji`,"aria-expanded":te,children:(0,I.jsx)(P,{size:22})}),(a||s)&&(0,I.jsx)(`button`,{type:`button`,className:`wa-reply-attach`,onClick:()=>re(!0),disabled:m,"aria-label":`Attach files`,children:(0,I.jsx)(h,{size:22})})]});return(0,I.jsxs)(`div`,{className:`wa-reply${S?` wa-reply-drag-over`:``}`,onDragOver:Ie,onDragLeave:Le,onDrop:Re,children:[x&&(0,I.jsx)(we,{sessionKey:t,onPick:e=>{ie(t=>[...t,e].slice(0,5)),re(!1)},onClose:()=>re(!1)}),te&&(0,I.jsx)(Ce,{onSelect:Ne}),g&&(0,I.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:g}),v&&(0,I.jsx)(`p`,{className:`wa-reply-notice`,role:`status`,children:v}),oe&&(0,I.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:oe}),le===`error`&&ue&&(0,I.jsx)(`p`,{className:`wa-reply-error`,role:`alert`,children:ue}),(E.length>0||w.length>0)&&(0,I.jsxs)(`div`,{className:`wa-reply-attachments`,children:[E.map((e,t)=>(0,I.jsxs)(`div`,{className:`wa-reply-chip`,children:[ze(e.type),(0,I.jsx)(`span`,{className:`wa-reply-chip-name`,children:e.name}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>A(t),"aria-label":`Remove ${e.name}`,children:(0,I.jsx)(c,{size:12})})]},`f-${t}`)),w.map((e,t)=>(0,I.jsxs)(`div`,{className:`wa-reply-chip wa-reply-chip-ref`,children:[(0,I.jsx)(ce,{size:14}),(0,I.jsx)(`span`,{className:`wa-reply-chip-name`,children:e.name}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>ie(e=>e.filter((e,n)=>n!==t)),"aria-label":`Remove ${e.name}`,children:(0,I.jsx)(c,{size:12})})]},`r-${t}`))]}),l&&n&&(0,I.jsxs)(`div`,{className:`wa-reply-quote`,children:[(0,I.jsxs)(`div`,{className:`wa-reply-quote-body`,children:[(0,I.jsx)(`span`,{className:`wa-reply-quote-who`,children:n.fromMe?`You`:n.senderName??`Contact`}),(0,I.jsx)(`span`,{className:`wa-reply-quote-text`,children:n.body||`Message`})]}),(0,I.jsx)(`button`,{type:`button`,className:`wa-reply-quote-cancel`,onClick:()=>r?.(),"aria-label":`Cancel reply`,children:(0,I.jsx)(c,{size:14})})]}),!me&&(0,I.jsx)(`div`,{className:`wa-reply-resize-handle`,role:`separator`,"aria-orientation":`horizontal`,"aria-label":`Resize input — drag up to enlarge`,tabIndex:0,onPointerDown:ke,onKeyDown:H}),(0,I.jsx)(`div`,{className:`wa-reply-row`,children:me?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:`wa-reply-attach`,onClick:_e,"aria-label":`Cancel recording`,children:(0,I.jsx)(u,{size:20})}),(0,I.jsxs)(`span`,{className:`wa-rec-live`,role:`status`,children:[(0,I.jsx)(`span`,{className:`wa-rec-dot`,"aria-hidden":!0}),Ee(M)]}),(0,I.jsx)(`button`,{type:`button`,className:`wa-reply-send`,onClick:()=>void ge(),"aria-label":`Stop recording`,children:(0,I.jsx)(p,{size:20})})]}):(0,I.jsxs)(I.Fragment,{children:[Ve?(0,Te.createPortal)((0,I.jsx)(`div`,{className:`wa-reply-footer-actions`,children:W}),Ve):W,(0,I.jsxs)(`div`,{className:`wa-reply-inputwrap`,children:[(0,I.jsx)(`textarea`,{ref:T,className:`wa-reply-input`,value:d,rows:1,style:{height:`${L??z??44}px`},placeholder:`Type a message`,disabled:m,onChange:e=>f(e.target.value),onKeyDown:Pe}),o&&d.length===0&&(0,I.jsx)(`button`,{type:`button`,className:`wa-reply-mic`,onClick:()=>void he(),disabled:m,"aria-label":`Record voice note`,children:(0,I.jsx)(se,{size:22})})]}),(0,I.jsx)(`button`,{type:`button`,className:`wa-reply-send`,onClick:()=>void Me(),disabled:!je,"aria-label":`Send`,children:(0,I.jsx)(ve,{size:20})})]})})]})}function R({accountId:e,channelKey:t,contactName:n,sessionKey:r,sendable:i=!0,onBack:a}){let o=t.slice(t.indexOf(`:`)+1),s=n===o?void 0:o;return(0,I.jsxs)(`div`,{className:`wa-web tg-web`,children:[(0,I.jsxs)(`header`,{className:`wa-web-header`,children:[a&&(0,I.jsx)(`button`,{type:`button`,className:`wa-web-back`,onClick:a,"aria-label":`Back`,children:(0,I.jsx)(j,{size:20})}),(0,I.jsx)(`span`,{className:`wa-web-avatar`,"aria-hidden":!0,children:(0,I.jsx)(oe,{size:20})}),(0,I.jsxs)(`div`,{className:`wa-web-titles`,children:[(0,I.jsx)(`span`,{className:`wa-web-name`,children:n}),s&&(0,I.jsx)(`span`,{className:`wa-web-subtitle`,children:s})]})]}),(0,I.jsx)(`div`,{className:`wa-web-body`,"data-testid":`telegram-web-conversation`,children:(0,I.jsx)(D,{sessionId:``,projectDir:``,sessionKey:r,forceDeliveredOnly:!0,suppressDirectives:!0,store:{channel:`telegram`,accountId:e,channelKey:t}})}),i&&(0,I.jsx)(L,{transport:{endpoint:`/api/telegram-reader/send`,fields:{accountId:e,channelKey:t}},sessionKey:r,features:{attachments:!1,voice:!1,deviceFiles:!1,quote:!1}})]})}function z({accountId:e,remoteJid:t,contactName:n,sessionKey:r,onBack:i}){let a=v(t),o=t.split(`@`)[0],s=a?`Group`:n===`+${o}`?void 0:`+${o}`,[l,u]=(0,F.useState)(!1),[d,f]=(0,F.useState)(``),p=()=>{u(!1),f(``)},[m,h]=(0,F.useState)(null);return(0,I.jsxs)(`div`,{className:`wa-web`,children:[(0,I.jsxs)(`header`,{className:`wa-web-header`,children:[i&&(0,I.jsx)(`button`,{type:`button`,className:`wa-web-back`,onClick:i,"aria-label":`Back`,children:(0,I.jsx)(j,{size:20})}),(0,I.jsx)(k,{accountId:e,jid:t,sessionKey:r}),l?(0,I.jsxs)(`div`,{className:`wa-web-search`,children:[(0,I.jsx)(le,{size:18,"aria-hidden":!0}),(0,I.jsx)(`input`,{className:`wa-web-search-input`,type:`text`,autoFocus:!0,placeholder:`Search messages`,"aria-label":`Search messages`,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Escape`&&p()}}),(0,I.jsx)(`button`,{type:`button`,className:`wa-web-search-close`,onClick:p,"aria-label":`Close search`,children:(0,I.jsx)(c,{size:18})})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`wa-web-titles`,children:[(0,I.jsx)(`span`,{className:`wa-web-name`,children:n}),s&&(0,I.jsx)(`span`,{className:`wa-web-subtitle`,children:s})]}),(0,I.jsx)(`button`,{type:`button`,className:`wa-web-search-toggle`,onClick:()=>u(!0),"aria-label":`Search messages`,children:(0,I.jsx)(le,{size:20})})]})]}),(0,I.jsx)(`div`,{className:`wa-web-body`,children:(0,I.jsx)(D,{sessionId:``,projectDir:``,sessionKey:r,forceDeliveredOnly:!0,suppressDirectives:!0,store:{channel:`whatsapp`,accountId:e,remoteJid:t},search:l?d:void 0,onReplyTo:h,groupThread:a})}),(0,I.jsx)(L,{transport:{endpoint:`/api/whatsapp-reader/reply`,fields:{accountId:e,remoteJid:t}},sessionKey:r,replyTo:m,onClearReply:()=>h(null)})]})}function De(e){let t=new Set,n=[];for(let r of e)for(let e of r.labels)e&&(t.has(e)||M.has(e)&&(t.add(e),n.push(e)));return n}function B(e,t){return m(e,t)}function V({conversations:e,sessionKey:t,onBack:n}){let{zone:r}=o(),[i,a]=(0,F.useState)(null),s=_(e);return i?i.source===`store`&&i.channel===`telegram`&&i.accountId&&i.channelKey?(0,I.jsx)(R,{accountId:i.accountId,channelKey:i.channelKey,contactName:b(i),sessionKey:t,onBack:()=>a(null)},y(i)):i.source===`store`&&i.accountId&&i.remoteJid?(0,I.jsx)(z,{accountId:i.accountId,remoteJid:i.remoteJid,contactName:b(i),sessionKey:t,onBack:()=>a(null)},y(i)):(0,I.jsxs)(`div`,{className:`op-conv op-conv-reader`,children:[(0,I.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`op-conv-back`,onClick:()=>a(null),"aria-label":`Back to conversations`,children:[(0,I.jsx)(j,{size:16}),` Back`]}),(0,I.jsx)(`span`,{className:`op-conv-title`,children:b(i)})]}),(0,I.jsx)(D,{sessionId:i.sessionId,projectDir:i.projectDir,sessionKey:t,forceDeliveredOnly:!0,suppressDirectives:i.source===`store`,store:i.source===`store`?{channel:`whatsapp`,accountId:i.accountId,remoteJid:i.remoteJid}:void 0},y(i))]}):(0,I.jsxs)(`div`,{className:`op-conv op-conv-list`,children:[(0,I.jsxs)(`div`,{className:`op-conv-bar`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`op-conv-back`,onClick:n,"aria-label":`Back to chat`,children:[(0,I.jsx)(j,{size:16}),` Chat`]}),(0,I.jsx)(`span`,{className:`op-conv-title`,children:`Conversations`})]}),s.map(e=>(0,I.jsxs)(`div`,{className:`op-conv-group`,children:[(0,I.jsxs)(`div`,{className:`op-conv-group-head`,children:[(0,I.jsx)(w,{channel:e.channel,size:14}),e.label]}),e.rows.map(e=>(0,I.jsxs)(`button`,{type:`button`,className:`op-conv-row`,onClick:()=>{a(e)},children:[e.source===`store`&&e.accountId&&e.remoteJid&&(0,I.jsx)(k,{accountId:e.accountId,jid:e.remoteJid,sessionKey:t,className:`op-conv-avatar`,size:16}),(0,I.jsx)(`span`,{className:`op-conv-name`,children:b(e)}),e.modelGated&&(0,I.jsx)(`span`,{className:`op-conv-gated`,role:`img`,"aria-label":`Model unavailable`,children:(0,I.jsx)(ue,{size:13})}),(0,I.jsx)(`span`,{className:`op-conv-when`,children:B(e.lastMessageAt,r)})]},y(e)))]},e.channel))]})}var Oe=/\.(png|jpe?g|gif|webp|svg)$/i;function ke(e){return Oe.test(e)}function H(e){return e.entryPath??e.name}var Ae=`maxy-data-view`,je=95*1024*1024,Me=48*1024*1024;function Ne(){return typeof window>`u`?`list`:window.localStorage.getItem(Ae)===`grid`?`grid`:`list`}function Pe(){let[e,t]=(0,F.useState)(null),[n,r]=(0,F.useState)(!1);return(0,F.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(i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]),n?e?(0,I.jsx)(f,{cacheKey:e,surface:`data`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=data`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,I.jsx)(C,{cacheKey:e,children:(0,I.jsx)(`div`,{className:`data-page data-page-full`,children:(0,I.jsx)(Fe,{cacheKey:e})})})}):(0,I.jsx)(`div`,{className:`data-page`,children:(0,I.jsxs)(`div`,{className:`data-empty`,children:[(0,I.jsx)(`p`,{children:`You are not signed in.`}),(0,I.jsxs)(`p`,{children:[`Open the `,(0,I.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,I.jsx)(d,{surface:`gate`})}function Fe({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:r}=S({initialCacheKey:e,surface:`data`});return(0,I.jsx)(W,{adminFetch:t,cacheKey:n,sessionRefetchNonce:r})}function Ie(){if(typeof window>`u`)return`@home`;let e=new URLSearchParams(window.location.hash.replace(/^#/,``)).get(`path`);return e&&e.length>0?e:`@home`}function Le(e){if(typeof window>`u`)return;let t=new URL(window.location.href);t.hash=e===`.`||e===`@home`?``:`path=${encodeURIComponent(e)}`,window.history.replaceState(window.history.state,``,t.toString())}function Re(e){return new Promise((t,n)=>{let r=[],i=()=>e.readEntries(e=>{e.length===0?t(r):(r.push(...e),i())},n);i()})}function ze(e){return new Promise((t,n)=>e.file(t,n))}async function Be(e,t=``){let n=[];for(let r of e){if(!r)continue;let e=t?`${t}/${r.name}`:r.name;if(r.isFile)n.push({file:await ze(r),relpath:e});else if(r.isDirectory){let t=await Re(r.createReader());n.push(...await Be(t,e))}}return n}function Ve(e,t){if(e===422&&typeof t==`string`){if(/exceeds the .* limit/i.test(t))return`size`;if(/unsupported file type/i.test(t))return`mime`}return`http=${e}`}function U({adminFetch:e,cacheKey:t,sessionRefetchNonce:n}){let{zone:r}=o(),[i,f]=(0,F.useState)(``),p=(0,F.useRef)(null),[m,h]=(0,F.useState)(``),[_,v]=(0,F.useState)(null),[y,te]=(0,F.useState)(`hybrid`),[b,x]=(0,F.useState)(!1),[ne,S]=(0,F.useState)(null),[C,w]=(0,F.useState)(null),[ae,T]=(0,F.useState)(0),[E,oe]=(0,F.useState)(!1),[D,se]=(0,F.useState)(()=>Ie()),[O,k]=(0,F.useState)(null),[A,j]=(0,F.useState)(()=>Ne()),[M,ue]=(0,F.useState)(null),[N,ve]=(0,F.useState)([]),[P,be]=(0,F.useState)(null),[xe,Se]=(0,F.useState)(0),[Ce,we]=(0,F.useState)(null),Te=(0,F.useRef)(null),Ee=N.slice(0,-1).map(e=>e.name).join(`/`),L=(()=>{let e=N.map(e=>e.name);return e.length>=2&&e[0]===`accounts`?`${e[0]}/${e[1]}`:null})(),R=P?Ee:D,z=(0,F.useCallback)(e=>R===`.`||R===``?e:`${R}/${e}`,[R]),[B,V]=(0,F.useState)(!1),[Oe,Pe]=(0,F.useState)(!1),[Fe,Re]=(0,F.useState)(null),[ze,U]=(0,F.useState)(!1),[W,G]=(0,F.useState)(null),[We,Ge]=(0,F.useState)(null),[Ke,Ye]=(0,F.useState)(null),[Xe,Ze]=(0,F.useState)(!1),[Qe,$e]=(0,F.useState)(null),et=(0,F.useRef)(null),[tt,nt]=(0,F.useState)(0),[rt,it]=(0,F.useState)(!1),[at,ot]=(0,F.useState)(``),[st,ct]=(0,F.useState)(null),[lt,ut]=(0,F.useState)(``),[dt,ft]=(0,F.useState)(null),K=(()=>{let e=D===`.`?[]:D.split(`/`).filter(Boolean);return e.some(e=>e.startsWith(`@`))?!1:e.length>=2&&e[0]===`accounts`})(),[pt,mt]=(0,F.useState)(!1),ht=(0,F.useRef)(null),[gt,q]=(0,F.useState)(!1),_t=(0,F.useRef)(null);(0,F.useEffect)(()=>{let e=i.trim();if(!e){h(``),v(null),S(null);return}oe(!1);let t=setTimeout(()=>h(e),300);return()=>clearTimeout(t)},[i]),(0,F.useEffect)(()=>{if(!m){x(!1);return}let t=!1;return x(!0),S(null),e(`/api/admin/graph-search?q=${encodeURIComponent(m)}&labels=FileArtifact&limit=20${E?`&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||(v(e.results),te(e.mode??`hybrid`),T(typeof e.suppressed==`number`?e.suppressed:0))}).catch(e=>{t||S(e instanceof Error?e.message:String(e))}).finally(()=>{t||x(!1)}),()=>{t=!0}},[m,e,n,E]);let vt=(0,F.useMemo)(()=>_?De(_):[],[_]),yt=C&&vt.includes(C)?C:null,bt=(0,F.useMemo)(()=>_?yt?_.filter(e=>e.labels.includes(yt)):_:null,[_,yt]),xt=(0,F.useCallback)(e=>{let n=e.properties.relativePath;if(typeof n!=`string`||n.length===0)return;let r=`/api/admin/files/download?session_key=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}`,i=document.createElement(`a`);i.href=r,i.rel=`noopener noreferrer`,document.body.appendChild(i),i.click(),i.remove()},[t]);(0,F.useEffect)(()=>{if(!_)return;let e=_.filter(e=>{let t=e.properties.relativePath;return typeof t!=`string`||t.length===0});e.length>0&&console.warn(`[data-search] op=locate-link-missing nodeId=${e.map(e=>e.nodeId).join(`,`)}`)},[_]),(0,F.useEffect)(()=>{let t=!1;return V(!0),Re(null),e(`/api/admin/files?path=${encodeURIComponent(D===`.`?``:D)}`).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||(k(e.entries),ve(e.displayPath??[]),be(e.view??null),Se(typeof e.systemCount==`number`?e.systemCount:0))}).catch(e=>{t||(k([]),ve([]),be(null),Se(0),Re(e instanceof Error?e.message:String(e)))}).finally(()=>{t||(V(!1),Pe(!0))}),()=>{t=!0}},[e,D,tt,n]),(0,F.useEffect)(()=>{if(P!==null||!L||Te.current===L)return;Te.current=L;let t=!1;return e(`/api/admin/files?path=${encodeURIComponent(`${L}/@home`)}`).then(e=>e.ok?e.json():null).then(e=>{t||!e||we((e.entries??[]).map(e=>e.name))}).catch(e=>{console.warn(`[data-ui] op=rail-buckets status=error reason="${e instanceof Error?e.message:String(e)}"`)}),()=>{t=!0}},[e,P,L]),(0,F.useEffect)(()=>{Le(D)},[D]);let St=(0,F.useCallback)(()=>{nt(e=>e+1)},[]),J=(0,F.useCallback)(e=>{mt(!1),se(e)},[]),Ct=(0,F.useCallback)(e=>{let t=e.properties.relativePath;if(typeof t!=`string`||t.length===0)return;let n=t.lastIndexOf(`/`),r=n===-1?`.`:t.slice(0,n);f(``),S(null),w(null),J(r)},[J]),wt=(0,F.useCallback)(()=>{if(!D.split(`/`).some(e=>e.startsWith(`@`))){if(D===`.`||D===``)return;let e=D.split(`/`).filter(Boolean);e.pop(),se(e.length===0?`.`:e.join(`/`));return}N.length!==0&&se(N.length>=2?N.slice(0,N.length-1).map(e=>e.name).join(`/`):`.`)},[D,N]),Tt=(0,F.useCallback)(e=>{fe(t,z(H(e)))},[z,t]),[Y,Et]=(0,F.useState)(!1),[X,Dt]=(0,F.useState)(new Set),Ot=(0,F.useRef)(null),Z=(0,F.useRef)(!1),kt=typeof navigator<`u`&&typeof navigator.share==`function`&&typeof navigator.canShare==`function`,At=(0,F.useCallback)(e=>{Et(!0),Dt(new Set([e]))},[]),Q=(0,F.useCallback)(e=>{Et(!1),Dt(new Set)},[]),jt=(0,F.useCallback)(e=>{Dt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Mt=(0,F.useCallback)(e=>{Z.current=!1,Ot.current=setTimeout(()=>{Z.current=!0,At(e)},500)},[At]),$=(0,F.useCallback)(()=>{Ot.current&&=(clearTimeout(Ot.current),null)},[]),Nt=(0,F.useCallback)(e=>{if(Z.current){Z.current=!1;return}if(Y){jt(e.name);return}Tt(e)},[Y,jt,Tt]),Pt=(0,F.useCallback)(e=>{j(e),typeof window<`u`&&window.localStorage.setItem(Ae,e)},[]),Ft=(0,F.useCallback)(e=>{if(Z.current){Z.current=!1;return}if(Y){jt(e.name);return}ue({src:pe(t,z(H(e))),alt:e.displayName??e.name})},[Y,jt,z,t]),It=(0,F.useCallback)(()=>(O??[]).filter(e=>e.kind===`file`&&X.has(e.name)),[O,X]),Lt=(0,F.useCallback)(()=>{if(X.size!==1)return null;let e=(O??[]).find(e=>X.has(e.name));return e&&!e.entryPath?e:null},[O,X]),Rt=(0,F.useCallback)(()=>(O??[]).filter(e=>(e.kind===`file`||e.kind===`directory`)&&X.has(e.name)),[O,X]),zt=(0,F.useCallback)(()=>{let e=Rt(),n=e.some(e=>e.kind===`directory`);e.length===1&&!n?Tt(e[0]):e.length>=1&&de(t,e.map(e=>z(H(e)))),Q(`action`)},[Rt,Tt,z,t,Q]),Bt=(0,F.useCallback)(async()=>{let t=It(),n=t.filter(e=>!e.protected),r=t.length-n.length;$e(r>0?`${r} protected file(s) kept`:null);for(let t of n){let n=z(H(t));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}`)}catch(e){$e(e instanceof Error?e.message:String(e))}}nt(e=>e+1),Q(`action`)},[It,z,e,Q]),Vt=(0,F.useCallback)(async()=>{let e=It();if(kt)try{let n=await Promise.all(e.map(async e=>{let n=z(H(e)),r=`/api/admin/files/download?session_key=${encodeURIComponent(t)}&path=${encodeURIComponent(n)}`,i=await(await fetch(r)).blob();return new File([i],e.displayName??e.name,{type:i.type||`application/octet-stream`})}));navigator.canShare({files:n})&&await navigator.share({files:n})}catch(e){console.warn(`[data-ui] op=share-failed err=${e instanceof Error?e.message:String(e)}`)}},[It,kt,z,t]),Ht=(0,F.useCallback)(()=>{et.current?.click()},[]),Ut=(0,F.useCallback)((e,n={})=>{let r=(r,i,a)=>{let o=new URLSearchParams({session_key:t,path:D===`.`?``:D,filename:e.name});n.relpath&&o.set(`relpath`,n.relpath),n.token&&o.set(`token`,n.token);for(let[e,t]of Object.entries(i))o.set(e,t);return new Promise(t=>{let n=new XMLHttpRequest;n.open(`POST`,`/api/admin/files/upload?${o.toString()}`),n.setRequestHeader(`Content-Type`,e.type||`application/octet-stream`),a&&(n.upload.onprogress=e=>{e.lengthComputable&&a(e.loaded)}),n.onload=()=>{let e={};try{e=JSON.parse(n.responseText)}catch{}t({status:n.status,data:e})},n.onerror=()=>t({status:0,data:{}}),n.onabort=()=>t({status:0,data:{error:`aborted`}}),n.send(r)})};if(e.size<=je)return r(e,{},t=>n.onProgress?.(t,e.size));let i=`${Date.now().toString(36)}-${Math.random().toString(16).slice(2,10)}`,a=Math.ceil(e.size/Me);return(async()=>{let t={status:0,data:{}};for(let o=0;o<a;o++){let s=o*Me;if(t=await r(e.slice(s,Math.min(s+Me,e.size)),{uploadId:i,seq:String(o),total:String(a)},t=>n.onProgress?.(s+t,e.size)),!(t.status>=200&&t.status<300))return t}return t})()},[t,D]),Wt=(0,F.useCallback)(async e=>{Ge(null),U(!0),G({loaded:0,total:e.size});try{let{status:t,data:n}=await Ut(e,{onProgress:(e,t)=>G({loaded:e,total:t})});t>=200&&t<300&&n.path?(se(n.path.split(`/`).slice(0,-1).join(`/`)||`.`),nt(e=>e+1)):Ge(t===0?`Network error during upload — the connection failed before the server responded.`:n.error??`Upload failed (HTTP ${t}).`)}finally{U(!1),G(null),et.current&&(et.current.value=``)}},[Ut]),Gt=(0,F.useCallback)(e=>{K&&Array.from(e.dataTransfer.types).includes(`Files`)&&(e.preventDefault(),Ze(!0))},[K]),Kt=(0,F.useCallback)(e=>{e.currentTarget.contains(e.relatedTarget)||Ze(!1)},[]),qt=(0,F.useCallback)(async e=>{e.preventDefault(),Ze(!1);let t=Math.random().toString(16).slice(2,10),n=Array.from(e.dataTransfer.items);if(n.length===0)return;if(!K){Ge(`Open a folder inside your account to upload`);return}let r=n.map(e=>e.webkitGetAsEntry?.()).filter(e=>!!e);U(!0),Ge(null),Ye(null);try{let e=await Be(r),n=0,i=[];for(let r=0;r<e.length;r++){let{file:a,relpath:o}=e[r];G({loaded:0,total:a.size});let{status:s,data:c}=await Ut(a,{relpath:o,token:t,onProgress:(e,t)=>G({loaded:e,total:t})});if(s>=200&&s<300)n++;else{let e=s===0?`http=0`:Ve(s,c.error);i.push(`${o} (${e})`)}}Ye(`Uploaded ${n}, skipped ${i.length}${i.length?`: ${i.join(`, `)}`:``}`),nt(e=>e+1)}catch(e){Ge(e instanceof Error?e.message:String(e))}finally{U(!1),G(null)}},[K,Ut]),Jt=(0,F.useCallback)(async()=>{let t=at.trim();if(t){ft(null);try{let n=await e(`/api/admin/files/folder`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:D===`.`?``:D,name:t})}),r=await n.json().catch(()=>({error:`HTTP ${n.status}`}));if(!n.ok)throw Error(r.error??`HTTP ${n.status}`);it(!1),ot(``),nt(e=>e+1)}catch(e){ft(e instanceof Error?e.message:String(e))}}},[e,at,D]),Yt=(0,F.useCallback)(async()=>{if(!st)return;let t=lt.trim();if(!t)return;ft(null);let n=z(st);try{let r=await e(`/api/admin/files/rename`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({path:n,newName:t})}),i=await r.json().catch(()=>({error:`HTTP ${r.status}`}));if(!r.ok)throw Error(i.error??`HTTP ${r.status}`);ct(null),ut(``),Q(`action`),nt(e=>e+1)}catch(e){ft(e instanceof Error?e.message:String(e))}},[e,lt,st,z,Q]);(0,F.useEffect)(()=>{if(!pt)return;let e=e=>{ht.current&&!ht.current.contains(e.target)&&mt(!1)},t=e=>{e.key===`Escape`&&mt(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[pt]),(0,F.useEffect)(()=>{if(!gt)return;let e=e=>{_t.current&&!_t.current.contains(e.target)&&q(!1)},t=e=>{e.key===`Escape`&&q(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[gt]);let Xt=(0,F.useCallback)(e=>N.slice(0,e+1).map(e=>e.name).join(`/`),[N]),Zt=N.length>=2,Qt=Zt?[{name:`.`,label:`data`},...N.slice(0,N.length-2).map((e,t)=>({name:Xt(t),label:e.displayName??e.name}))]:[];return Oe?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`data-toolbar`,children:[Y?(0,I.jsxs)(`button`,{type:`button`,className:`data-select-cancel`,onClick:()=>Q(`cancel`),"aria-label":`Cancel selection`,children:[(0,I.jsx)(c,{size:14}),` Cancel`]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`data-search-input`,children:[i===``&&(0,I.jsx)(le,{size:14}),(0,I.jsx)(`input`,{ref:p,type:`text`,value:i,onChange:e=>f(e.target.value),autoFocus:!0,autoComplete:`off`,spellCheck:!1}),b&&(0,I.jsx)(l,{size:14,className:`spin`}),i!==``&&(0,I.jsx)(`button`,{type:`button`,className:`data-search-inline-btn`,onClick:()=>{f(``),p.current?.focus()},title:`Clear search`,"aria-label":`Clear search`,children:(0,I.jsx)(c,{size:14})})]}),(0,I.jsxs)(`div`,{className:`data-toolbar-actions`,ref:_t,children:[(0,I.jsx)(`button`,{type:`button`,className:`data-action-overflow`,onClick:()=>q(e=>!e),"aria-haspopup":`menu`,"aria-expanded":gt,"aria-label":`File actions`,title:`File actions`,children:(0,I.jsx)(me,{size:16})}),(0,I.jsxs)(`div`,{className:`data-action-group`,role:`group`,"aria-label":`File actions`,"data-open":gt?`true`:void 0,children:[(0,I.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{St(),q(!1)},disabled:B,title:`Refresh this folder`,"aria-label":`Refresh this folder`,children:[B?(0,I.jsx)(l,{size:16,className:`spin`}):(0,I.jsx)(a,{size:16}),(0,I.jsx)(`span`,{className:`data-action-label`,children:`Refresh`})]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-action-btn admin-btn-cta`,onClick:()=>{Ht(),q(!1)},disabled:ze||!K,title:K?`Upload a file`:`Open a folder inside your account to upload`,"aria-label":`Upload a file`,children:[ze?W&&W.total>0?(0,I.jsxs)(`span`,{className:`data-upload-pct`,children:[Math.round(W.loaded/W.total*100),`%`]}):(0,I.jsx)(l,{size:16,className:`spin`}):(0,I.jsx)(ye,{size:16}),(0,I.jsx)(`span`,{className:`data-action-label`,children:`Upload`})]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{it(e=>!e),ot(``),ft(null),q(!1)},disabled:ze||!K,title:K?`New folder`:`Open a folder inside your account to create one`,"aria-label":`New folder`,children:[(0,I.jsx)(he,{size:16}),(0,I.jsx)(`span`,{className:`data-action-label`,children:`New folder`})]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-action-btn`,onClick:()=>{Pt(A===`grid`?`list`:`grid`),q(!1)},title:A===`grid`?`List view`:`Grid view`,"aria-label":A===`grid`?`Switch to list view`:`Switch to grid view`,"aria-pressed":A===`grid`,children:[A===`grid`?(0,I.jsx)(_e,{size:16}):(0,I.jsx)(ge,{size:16}),(0,I.jsx)(`span`,{className:`data-action-label`,children:A===`grid`?`List view`:`Grid view`})]})]})]})]}),(0,I.jsxs)(`div`,{className:`data-breadcrumbs`,children:[D!==`.`&&(0,I.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost data-back-btn`,onClick:wt,title:`Up one level`,"aria-label":`Up one level`,children:(0,I.jsx)(re,{size:14})}),Zt?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`data-crumb-wrap`,ref:ht,children:[(0,I.jsx)(`button`,{type:`button`,className:`data-crumb data-crumb-ellipsis`,onClick:()=>mt(e=>!e),"aria-haspopup":`menu`,"aria-expanded":pt,"aria-label":`Show parent folders`,title:`Show parent folders`,children:`…`}),pt&&(0,I.jsx)(`div`,{className:`data-crumb-menu`,role:`menu`,children:Qt.map(e=>(0,I.jsx)(`button`,{type:`button`,role:`menuitem`,className:`data-crumb-menu-item`,onClick:()=>J(e.name),title:e.label,children:e.label},e.name))})]}),[N.length-2,N.length-1].map(e=>{let t=N[e];return(0,I.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,I.jsx)(`span`,{className:`data-crumb-sep`,children:`›`}),(0,I.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>J(Xt(e)),title:t.name,children:t.displayName??t.name})]},Xt(e))})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>J(`.`),children:`data`}),N.map((e,t)=>(0,I.jsxs)(`span`,{className:`data-crumb-wrap`,children:[(0,I.jsx)(`span`,{className:`data-crumb-sep`,children:`›`}),(0,I.jsx)(`button`,{type:`button`,className:`data-crumb`,onClick:()=>J(Xt(t)),title:e.name,children:e.displayName??e.name})]},Xt(t)))]})]}),rt&&(0,I.jsxs)(`div`,{className:`data-inline-form`,children:[(0,I.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`Folder name`,value:at,autoFocus:!0,onChange:e=>ot(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Jt(),e.key===`Escape`&&it(!1)}}),(0,I.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Jt,children:`Create`}),(0,I.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>it(!1),children:`Cancel`})]}),st&&(0,I.jsxs)(`div`,{className:`data-inline-form`,children:[(0,I.jsx)(`input`,{type:`text`,className:`data-inline-input`,placeholder:`New name`,value:lt,autoFocus:!0,onChange:e=>ut(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Yt(),e.key===`Escape`&&ct(null)}}),(0,I.jsx)(`button`,{type:`button`,className:`data-btn`,onClick:Yt,children:`Rename`}),(0,I.jsx)(`button`,{type:`button`,className:`data-btn data-btn-ghost`,onClick:()=>ct(null),children:`Cancel`})]}),dt&&(0,I.jsx)(`div`,{className:`data-error`,children:dt}),(0,I.jsx)(`input`,{type:`file`,ref:et,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&Wt(t)}})]}),(0,I.jsxs)(`div`,{className:`data-body`,"data-drag-active":Xe?`true`:void 0,onDragEnter:Gt,onDragOver:Gt,onDragLeave:Kt,onDrop:qt,children:[P===null&&L&&Ce&&Ce.length>0&&(0,I.jsxs)(`aside`,{className:`data-rail`,"aria-label":`Folders`,children:[(0,I.jsx)(`span`,{className:`data-rail-label`,children:`Folders`}),(0,I.jsx)(`ul`,{className:`data-rail-list`,children:Ce.map(e=>{let t=`${L}/${e}`,n=D===t||D.startsWith(`${t}/`);return(0,I.jsx)(`li`,{children:(0,I.jsxs)(`button`,{type:`button`,className:`data-rail-item`,"aria-current":n?`true`:void 0,onClick:()=>J(t),children:[(0,I.jsx)(g,{size:13}),(0,I.jsx)(`span`,{className:`data-rail-item-name`,children:e})]})},e)})})]}),(0,I.jsxs)(`div`,{className:`data-content`,children:[(ne!==null||_!==null)&&(0,I.jsxs)(`section`,{className:`data-panel admin-card`,children:[ne&&(0,I.jsxs)(`div`,{className:`data-error`,children:[`Search failed: `,ne]}),vt.length>0&&(0,I.jsx)(`div`,{className:`data-chip-row`,role:`group`,"aria-label":`Filter by type`,children:vt.map(e=>{let t=e===yt;return(0,I.jsx)(`button`,{type:`button`,className:`data-chip`,"data-active":t,onClick:()=>w(t?null:e),children:Ue([e])??e},e)})}),_&&!b&&(0,I.jsxs)(`div`,{className:`data-results-meta`,children:[bt.length,` of `,_.length,` result`,_.length===1?``:`s`]}),_&&!b&&!yt&&ae>0&&!E&&(0,I.jsxs)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>oe(!0),children:[ae,` low-confidence result`,ae===1?``:`s`,` hidden — show all`]}),_&&!b&&!yt&&E&&(0,I.jsx)(`button`,{type:`button`,className:`data-suppressed-banner`,onClick:()=>oe(!1),children:`Showing all results — hide low-confidence`}),_&&_.length===0&&!b&&(0,I.jsx)(`div`,{className:`data-empty-results`,children:`No matches. Try a different keyword.`}),bt&&bt.length>0&&(0,I.jsx)(`ul`,{className:`data-results`,children:bt.map(e=>(0,I.jsx)(He,{hit:e,mode:y,onDownload:xt,onLocate:Ct},e.nodeId))})]}),(0,I.jsxs)(`section`,{className:P===`home`?`data-panel data-panel--wide`:`data-panel data-panel--wide admin-card`,children:[W&&(0,I.jsxs)(`div`,{className:`data-upload-progress`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":W.total>0?Math.round(W.loaded/W.total*100):void 0,children:[(0,I.jsx)(`div`,{className:`data-upload-progress-track`,children:(0,I.jsx)(`div`,{className:`data-upload-progress-fill`,style:{width:`${W.total>0?Math.round(W.loaded/W.total*100):0}%`}})}),(0,I.jsxs)(`span`,{className:`data-upload-progress-label`,children:[`Uploading… `,W.total>0?`${Math.round(W.loaded/W.total*100)}%`:``]})]}),We&&(0,I.jsxs)(`div`,{className:`data-error`,children:[`Upload failed: `,We]}),Ke&&(0,I.jsx)(`div`,{className:`data-status`,children:Ke}),Qe&&(0,I.jsxs)(`div`,{className:`data-error`,children:[`Delete failed: `,Qe]}),Fe&&(0,I.jsx)(`div`,{className:`data-error`,children:Fe}),B&&(0,I.jsxs)(`div`,{className:`data-loading`,children:[(0,I.jsx)(l,{size:14,className:`spin`}),` Loading…`]}),!B&&P!==`home`&&O&&O.length===0&&!Fe&&(0,I.jsx)(`div`,{className:`data-empty-results`,children:`Empty directory.`}),!B&&P===`home`&&O&&(0,I.jsxs)(`ul`,{className:`routine-list data-home-list`,children:[O.map(e=>(0,I.jsxs)(`li`,{className:`data-home-card`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`data-home-card-head`,onClick:()=>J(z(e.name)),children:[(0,I.jsx)(`span`,{className:`data-home-card-title`,children:e.name}),(0,I.jsx)(`span`,{className:`data-home-card-count`,children:e.childCount===null||e.childCount===void 0?`—`:`${e.childCount} ${e.childCount===1?`item`:`items`}`})]}),(0,I.jsxs)(`ul`,{className:`data-home-card-children`,children:[e.childCount===null&&(0,I.jsx)(`li`,{className:`data-home-card-error`,children:`Could not read this folder.`}),e.childCount===0&&(0,I.jsx)(`li`,{className:`data-home-card-empty`,children:`Empty.`}),(e.children??[]).map(e=>(0,I.jsxs)(`li`,{className:`data-home-card-child`,children:[e.kind===`directory`?(0,I.jsx)(g,{size:12}):(0,I.jsx)(ce,{size:12}),(0,I.jsx)(`span`,{className:`data-home-card-child-name`,children:e.name})]},e.name)),typeof e.childCount==`number`&&e.childCount>(e.children?.length??0)&&(0,I.jsxs)(`li`,{className:`data-home-card-more`,children:[`+`,e.childCount-(e.children?.length??0),` more`]})]})]},e.name)),(0,I.jsxs)(`li`,{className:`data-home-card`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`data-home-card-head`,onClick:()=>J(z(`@system`)),children:[(0,I.jsx)(`span`,{className:`data-home-card-title`,children:`system`}),(0,I.jsxs)(`span`,{className:`data-home-card-count`,children:[xe,` `,xe===1?`item`:`items`]})]}),(0,I.jsx)(`ul`,{className:`data-home-card-children`,children:(0,I.jsx)(`li`,{className:`data-home-card-empty`,children:`Platform and plugin folders.`})})]})]}),!B&&P!==`home`&&O&&O.length>0&&A===`grid`&&(0,I.jsx)(`ul`,{className:`data-grid`,children:O.map(e=>{let n=e.displayName??e.name,r=Y&&X.has(e.name);if(e.kind===`directory`)return(0,I.jsx)(`li`,{className:`data-grid-cell`,"data-selected":r?`true`:void 0,children:(0,I.jsxs)(`button`,{type:`button`,className:`data-grid-tile`,onPointerDown:()=>Mt(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>{if(Z.current){Z.current=!1;return}if(Y){jt(e.name);return}J(z(e.name))},children:[Y&&(0,I.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,I.jsx)(g,{size:28,className:`data-grid-glyph`}),(0,I.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:n})]})},e.name);if(e.kind===`file`){let i=ke(H(e)),a=z(H(e));return(0,I.jsx)(`li`,{className:`data-grid-cell`,"data-selected":r?`true`:void 0,children:(0,I.jsxs)(`button`,{type:`button`,className:`data-grid-tile${i?` data-grid-tile-image`:``}`,onPointerDown:()=>Mt(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>i?Ft(e):Nt(e),title:Y?void 0:i?`Preview ${n}`:`Download ${n}`,children:[Y&&(0,I.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),i?(0,I.jsx)(`img`,{className:`data-grid-thumb`,src:pe(t,a),alt:n,loading:`lazy`,onError:()=>console.warn(`[data] op=thumb-error path=${a}`)}):(0,I.jsx)(ce,{size:28,className:`data-grid-glyph`}),(0,I.jsx)(`span`,{className:`data-grid-label`,title:e.name,children:n}),!i&&(0,I.jsx)(`span`,{className:`data-grid-sub`,children:qe(e.sizeBytes)})]})},e.name)}return(0,I.jsx)(`li`,{className:`data-grid-cell`,children:(0,I.jsxs)(`div`,{className:`data-grid-tile data-entry-disabled`,children:[(0,I.jsx)(ce,{size:28,className:`data-grid-glyph`}),(0,I.jsx)(`span`,{className:`data-grid-label`,children:n}),(0,I.jsx)(`span`,{className:`data-grid-sub`,children:`special`})]})},e.name)})}),!B&&P!==`home`&&O&&O.length>0&&A===`list`&&(0,I.jsx)(`ul`,{className:`data-entries`,children:O.map(e=>{let t=e.displayName??e.name;if(e.kind===`directory`){let n=Y&&X.has(e.name);return(0,I.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,I.jsxs)(`button`,{type:`button`,className:`data-entry-btn`,onPointerDown:()=>Mt(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>{if(Z.current){Z.current=!1;return}if(Y){jt(e.name);return}J(z(e.name))},children:[Y&&(0,I.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,I.jsx)(g,{size:14}),(0,I.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t})]})},e.name)}if(e.kind===`file`){let n=Y&&X.has(e.name);return(0,I.jsx)(`li`,{className:`data-entry`,"data-selected":n?`true`:void 0,children:(0,I.jsxs)(`button`,{type:`button`,className:`data-entry-btn data-entry-file`,onPointerDown:()=>Mt(e.name),onPointerUp:$,onPointerMove:$,onPointerLeave:$,onPointerCancel:$,onClick:()=>Nt(e),title:Y?void 0:`Download ${t}`,children:[Y&&(0,I.jsx)(`span`,{className:`data-entry-select-indicator`,"aria-hidden":`true`}),(0,I.jsxs)(`span`,{className:`data-entry-text`,children:[(0,I.jsx)(`span`,{className:`data-entry-name`,title:e.name,children:t}),(0,I.jsxs)(`span`,{className:`data-entry-meta`,title:`Modified ${Je(e.modifiedAt,r)}`,children:[qe(e.sizeBytes),` · `,Je(e.modifiedAt,r)]})]})]})},e.name)}return(0,I.jsx)(`li`,{className:`data-entry`,children:(0,I.jsx)(`div`,{className:`data-entry-btn data-entry-file data-entry-disabled`,children:(0,I.jsxs)(`span`,{className:`data-entry-text`,children:[(0,I.jsx)(`span`,{className:`data-entry-name`,children:t}),(0,I.jsx)(`span`,{className:`data-entry-meta`,children:`special`})]})})},e.name)})})]})]})]}),Y&&(0,I.jsx)(`div`,{className:`data-select-bar`,role:`toolbar`,"aria-label":`Selection actions`,children:(0,I.jsxs)(`div`,{className:`data-select-bar-inner`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:Vt,disabled:!kt||X.size===0,title:kt?`Share selected files`:`Sharing is not supported on this device`,children:[(0,I.jsx)(ie,{size:16}),` Share`]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:zt,disabled:X.size===0,children:[(0,I.jsx)(ee,{size:16}),` Download`]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-select-action`,onClick:()=>{let e=Lt();e&&(ct(e.name),ut(e.name))},disabled:!Lt(),children:[(0,I.jsx)(s,{size:16}),` Rename`]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-select-action data-select-delete`,onClick:Bt,disabled:X.size===0,children:[(0,I.jsx)(u,{size:16}),` Delete`]})]})}),M&&(0,I.jsx)(`div`,{className:`chat-attachment-overlay`,role:`dialog`,"aria-label":M.alt,onClick:()=>ue(null),children:(0,I.jsx)(`img`,{className:`chat-attachment-overlay-image`,src:M.src,alt:M.alt})})]}):(0,I.jsx)(d,{surface:`gate`})}function W({adminFetch:e,cacheKey:t,sessionRefetchNonce:n}){let r=(0,F.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),a=(0,F.useCallback)(e=>{e===`chat`&&(window.location.href=`/`)},[]),[o,s]=(0,F.useState)([]),[c,l]=(0,F.useState)(`files`),{subAccounts:u,activeAccountId:d,switching:f,switchAccount:p}=te(t);return(0,F.useEffect)(()=>{if(!t)return;let e=!1;return fetch(`/api/operator-conversations/conversations?session_key=${encodeURIComponent(t)}`).then(e=>e.ok?e.json():{conversations:[]}).then(t=>{e||s(t.conversations??[])}).catch(()=>{}),()=>{e=!0}},[t]),(0,I.jsxs)(`main`,{className:`data-main`,children:[(0,I.jsx)(i,{variant:`operator`,onNavigate:a,onOpenConversations:o.length>0?()=>l(`conversations`):void 0,onToggleSidebar:()=>{},sidebarOpen:!1,onLogout:r,onDisconnect:async()=>!0,disconnecting:!1,subAccounts:u,activeAccountId:d,switchingAccount:f,onSwitchAccount:p}),c===`conversations`?(0,I.jsx)(V,{conversations:o,sessionKey:t,onBack:()=>l(`files`)}):(0,I.jsx)(U,{adminFetch:e,cacheKey:t,sessionRefetchNonce:n})]})}function G({cacheKey:e}){let{adminFetch:t,cacheKey:n,sessionRefetchNonce:r}=S({initialCacheKey:e,surface:`data`});return(0,I.jsx)(`div`,{className:`data-page`,children:(0,I.jsx)(`main`,{className:`data-main`,children:(0,I.jsx)(U,{adminFetch:t,cacheKey:n,sessionRefetchNonce:r})})})}function He({hit:e,mode:t,onDownload:n,onLocate:r}){let{zone:i}=o(),a=We(e.properties),s=Ge(e.properties),c=Ue(e.labels),l=Ke(e.properties),[u,d]=(0,F.useState)(!1),f=s&&s.length>280,p=u||!f?s:s?.slice(0,280)+`…`,m=t===`bm25`?`bm25 ${e.bm25Score.toFixed(2)}`:`vector ${e.vectorScore.toFixed(2)} · bm25 ${e.bm25Score.toFixed(2)} · combined ${e.score.toFixed(2)}`,h=e.properties.relativePath,ee=typeof h==`string`&&h.length>0,_=ee?h.lastIndexOf(`/`):-1,v=ee?_===-1?`data`:h.slice(0,_):null;return(0,I.jsxs)(`li`,{className:`data-result`,children:[(0,I.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":`Download ${a??c??`file`}`,children:[c&&(0,I.jsx)(`div`,{className:`data-result-header`,children:(0,I.jsx)(`span`,{className:`data-result-labels`,children:c})}),a&&(0,I.jsx)(`div`,{className:`data-result-title`,children:a}),s&&(0,I.jsx)(`pre`,{className:`data-result-body`,children:p}),(0,I.jsxs)(`div`,{className:`data-result-scores`,children:[l&&(0,I.jsxs)(`span`,{className:`data-result-updated`,children:[`Updated `,Je(l,i),` · `]}),m]})]}),ee&&(0,I.jsxs)(`button`,{type:`button`,className:`data-result-locate`,onClick:()=>r(e),title:`Locate in ${v}`,"aria-label":`Locate in ${v}`,children:[(0,I.jsx)(g,{size:12}),v]}),f&&(0,I.jsx)(`button`,{type:`button`,className:`data-result-toggle`,onClick:()=>d(e=>!e),children:u?`Show less`:`Show more`})]})}function Ue(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 We(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 Ge(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 Ke(e){for(let t of[`updatedAt`,`modifiedAt`,`fetchedAt`,`createdAt`,`lastModified`]){let n=e[t];if(typeof n==`string`&&n.length>0)return n}return null}function qe(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 Je(e,t){return m(e,t)||`—`}export{R as i,G as n,z as r,Pe as t};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{rt as e}from"./useMediaQuery-e4ciNiuO.js";var t=e(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]);export{t};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./chunk-BycB0eMI.js";import{i as t,n,t as r}from"./jsx-runtime-
|
|
1
|
+
import{o as e}from"./chunk-BycB0eMI.js";import{i as t,n,t as r}from"./jsx-runtime-BY35JYDT.js";import{c as i}from"./useMediaQuery-e4ciNiuO.js";import"./useVoiceRecorder-D7_wLtrS.js";import{D as a}from"./AdminShell-Dm_nY4jF.js";import{a as o,c as s,i as c,o as l,r as u,s as d}from"./page-BBRWbFzG.js";import"./useCopyFeedback-1MKNUzp3.js";var f=n(),p=e(t(),1),m=r();function h({gateState:e,setGateState:t,grantInfo:n,resolvedSlugRef:r}){let[i,o]=(0,p.useState)(``),[s,c]=(0,p.useState)(!1),[l,u]=(0,p.useState)(null);async function d(e){e.preventDefault();let n=i.trim().toLowerCase();if(!n){u(`Enter the email you were invited on.`);return}c(!0),u(null);try{let e=await fetch(`/api/access/request-magic-link`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({contactValue:n,agentSlug:r.current})});if(e.status===429){u((await e.json().catch(()=>({})))?.error||`Too many requests. Try again later.`);return}t(`request-sent`)}catch{u(`Could not reach the server. Check your connection and try again.`)}finally{c(!1)}}return(0,m.jsxs)(`div`,{className:`access-gate`,children:[e===`verifying`&&(0,m.jsxs)(`div`,{className:`access-gate-message`,children:[(0,m.jsx)(`h2`,{children:`Verifying your link…`}),(0,m.jsx)(`p`,{children:`This takes a moment.`})]}),e===`verify-failed`&&(0,m.jsxs)(`div`,{className:`access-gate-message`,children:[(0,m.jsx)(`h2`,{children:`That link did not work`}),(0,m.jsx)(`p`,{children:`It may have expired, already been used, or been for a different agent. You can request a fresh one below.`}),(0,m.jsx)(a,{onClick:()=>{t(`request-link`),u(null)},children:`Request a new link`})]}),e===`request-link`&&(0,m.jsxs)(`form`,{className:`access-gate-form`,onSubmit:d,children:[(0,m.jsx)(`h2`,{children:n?.displayName?`Welcome back, ${n.displayName}`:`Sign in`}),(0,m.jsx)(`p`,{children:`Enter the email you were invited on and we will send you a fresh link.`}),(0,m.jsx)(`label`,{htmlFor:`access-email`,children:`Email`}),(0,m.jsx)(`input`,{id:`access-email`,type:`email`,inputMode:`email`,autoComplete:`email`,value:i,onChange:e=>o(e.target.value),disabled:s}),l&&(0,m.jsx)(`p`,{className:`access-gate-error`,children:l}),(0,m.jsx)(a,{type:`submit`,disabled:s||!i.trim(),children:s?`Sending…`:`Send me a link`})]}),e===`request-sent`&&(0,m.jsxs)(`div`,{className:`access-gate-message`,children:[(0,m.jsx)(`h2`,{children:`Check your email`}),(0,m.jsx)(`p`,{children:`If that address is on the invite list, a fresh link is on the way. It expires in 15 minutes.`}),(0,m.jsx)(a,{onClick:()=>{t(`request-link`),o(``),u(null)},children:`Try a different email`})]})]})}function g(){let[e,t]=(0,p.useState)(null),[n,r]=(0,p.useState)(null),[i,a]=(0,p.useState)(`loading`),[u,f]=(0,p.useState)(``),[m,h]=(0,p.useState)(null),[g,_]=(0,p.useState)(null),[v,y]=(0,p.useState)(!1),[b,x]=(0,p.useState)(null),S=(0,p.useMemo)(()=>o(),[]),C=(0,p.useRef)(S||``),w=(0,p.useRef)(null),T=(0,p.useRef)(null),E=(0,p.useRef)(!1),D=(0,p.useRef)(null),[O,k]=(0,p.useState)(`request-link`),[A,j]=(0,p.useState)(null),M=(0,p.useRef)(null),N=(0,p.useRef)(null);(0,p.useEffect)(()=>{try{let e=sessionStorage.getItem(`maxy_session`);e&&(N.current=e)}catch{}},[]),(0,p.useEffect)(()=>{try{let e=l();e&&sessionStorage.setItem(c,e)}catch{}},[]);let P=(0,p.useCallback)(e=>{w.current=e,t(e);try{sessionStorage.setItem(`maxy_session`,e)}catch{}a(`chat`)},[]),F=(0,p.useCallback)(()=>{w.current=null;try{sessionStorage.removeItem(`maxy_session`)}catch{}t(null),a(`auth-required`),k(`request-link`)},[]),I=(0,p.useCallback)(async e=>{k(`verifying`);try{let t=C.current,n=await fetch(`/api/access/verify-token`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:e,agentSlug:t})});if(window.history.replaceState({},``,window.location.pathname),n.ok){let e=await n.json().catch(()=>({}));return e?.displayName&&j({displayName:e.displayName,contactValue:``,expiresAt:null,status:`active`}),!0}return k(`verify-failed`),!1}catch{return k(`verify-failed`),!1}},[]),L=(0,p.useCallback)(async()=>{if(w.current)return w.current;if(T.current)return T.current;let e=(async()=>{try{let e=N.current,n=await fetch(`/api/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({session_id:d(),...S?{agent:S}:{},...e?{session_key:e}:{}})});if(!n.ok){let e=await n.json().catch(()=>({error:``}));return s&&console.error(`[session] POST /api/session failed: ${n.status} ${n.statusText}`,e),n.status===404?r(e.error||`Agent not found`):n.status===503&&r(e.error||`Service unavailable`),null}let i=await n.json();if(i.auth_required){i.agent_id&&(C.current=i.agent_id),f(i.displayName||``),i.agentImage&&h(i.agentImage),i.agentImageShape&&_(i.agentImageShape),i.showAgentName&&y(i.showAgentName),i.branding&&x(i.branding),a(`auth-required`);let e=new URLSearchParams(window.location.search).get(`token`);return e?await I(e)&&window.location.reload():k(`request-link`),null}w.current=i.session_key,t(i.session_key),i.displayName&&f(i.displayName),i.agentImage&&h(i.agentImage),i.agentImageShape&&_(i.agentImageShape),i.showAgentName&&y(i.showAgentName),i.branding&&x(i.branding),a(`chat`),i.resumed&&i.messages&&(E.current=!0,D.current=i.messages);try{sessionStorage.setItem(`maxy_session`,i.session_key)}catch{}return i.session_key}catch(e){return s&&console.error(`[session] fetch /api/session threw:`,e),r(`Unable to connect. Please check your connection and try again.`),null}finally{T.current=null}})();return T.current=e,e},[S,I]);return{sessionId:e,cacheKeyRef:w,sessionError:n,pageState:i,setPageState:a,agentDisplayName:u,agentImage:m,agentImageShape:g,showAgentName:v,agentSlug:S,branding:b,resolvedSlugRef:C,ensureSession:L,startNewSession:(0,p.useCallback)(async()=>{w.current=null,T.current=null,N.current=null,E.current=!1,D.current=null,t(null),r(null);try{sessionStorage.removeItem(`maxy_session`)}catch{}await L()},[L]),enterChat:P,enterGate:F,resumedRef:E,resumeMessagesRef:D,gateState:O,setGateState:k,grantInfo:A,setGrantInfo:j,gateCacheKeyRef:M}}function _(){let{ensureSession:e,pageState:t,gateState:n,setGateState:r,grantInfo:a,resolvedSlugRef:o}=g();return(0,p.useEffect)(()=>{e()},[e]),(0,p.useEffect)(()=>{if(!(typeof window>`u`))return i(document,window)},[]),t===`loading`?(0,m.jsx)(`div`,{className:`public-loading`,children:`Loading…`}):t===`auth-required`?(0,m.jsx)(h,{gateState:n,setGateState:r,grantInfo:a,resolvedSlugRef:o}):(0,m.jsx)(`div`,{className:`public-shell`,children:(0,m.jsx)(u,{cacheKey:``,variant:`public`})})}(0,f.createRoot)(document.getElementById(`root`)).render((0,m.jsx)(_,{}));
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{rt as e}from"./useMediaQuery-
|
|
1
|
+
import{rt as e}from"./useMediaQuery-e4ciNiuO.js";var t=e(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]);export{t};
|
|
Binary file
|
|
Binary file
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{o as e,t}from"./chunk-BycB0eMI.js";import{i as n,n as r,t as i}from"./jsx-runtime-DeRQuYlX.js";import{B as a,C as o,H as s,I as c,K as l,L as u,N as d,P as f,S as p,X as m,rt as h,tt as g,ut as _,v,y}from"./useMediaQuery-Cm_fvNIH.js";import{k as b,m as x,t as S}from"./AdminShell-DyOPTLdb.js";import{t as C}from"./clock-PkEm8y4i.js";import{t as w}from"./triangle-alert-DD4kSK45.js";import{t as ee}from"./wrench-Bjw6eVl_.js";import{r as T}from"./file-download-B7zwa78w.js";var te=h(`circle-pause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),ne=h(`circle-play`,[[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),E=h(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),D=r(),O=e(n(),1),k=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function A(e,t){if(e===`*`)return{kind:`any`,value:0,rangeStart:null,rangeEnd:null,step:1};let n=e.match(/^(\*|\d+-\d+)\/(\d+)$/);if(n){let e=Number(n[2]);if(e<1)return null;if(n[1]===`*`)return{kind:`step`,value:0,rangeStart:null,rangeEnd:null,step:e};let[r,i]=n[1].split(`-`).map(Number);return r>t||i>t||r>i?null:{kind:`step`,value:0,rangeStart:r,rangeEnd:i,step:e}}let r=e.match(/^(\d+)-(\d+)$/);if(r){let e=Number(r[1]),n=Number(r[2]);return e>t||n>t||e>n?null:{kind:`step`,value:0,rangeStart:e,rangeEnd:n,step:1}}if(/^\d+$/.test(e)){let n=Number(e);return n>t?null:{kind:`fixed`,value:n,rangeStart:null,rangeEnd:null,step:1}}return null}function j(e){return String(e).padStart(2,`0`)}function M(e){if(e===`*`)return null;let t=e.match(/^(\d+)-(\d+)$/);if(t){let e=Number(t[1]),n=Number(t[2]);return e>7||n>7||e>n?`invalid`:`${k[e%7]} to ${k[n%7]}`}let n=e.split(`,`);return n.length>0&&n.every(e=>/^\d+$/.test(e)&&Number(e)<=7)?n.map(e=>k[Number(e)%7]).join(`, `):`invalid`}function N(e){let t=e.trim().split(/\s+/);if(t.length!==5)return e;let[n,r,i,a,o]=t;if(a!==`*`||i!==`*`&&!/^\d+$/.test(i)||i!==`*`&&(Number(i)<1||Number(i)>31))return e;let s=A(n,59),c=A(r,23);if(!s||!c)return e;let l=M(o);if(l===`invalid`||s.kind===`step`&&s.rangeStart!==null||(s.kind===`any`&&(s={kind:`step`,value:0,rangeStart:null,rangeEnd:null,step:1}),c.kind===`step`&&c.step===1&&c.rangeStart===null&&(c={kind:`any`,value:0,rangeStart:null,rangeEnd:null,step:1}),i!==`*`&&!(s.kind===`fixed`&&c.kind===`fixed`&&o===`*`))||s.kind===`step`&&c.kind===`step`&&c.step>1)return e;let u=l?`, ${l}`:``,d=e=>e.rangeStart+Math.floor((e.rangeEnd-e.rangeStart)/e.step)*e.step;if(s.kind===`step`){let e=s.step===1?`Every minute`:`Every ${s.step} minutes`;return c.kind===`any`?`${e}${u}`:c.kind===`fixed`?`${e}, ${j(c.value)}:00 to ${j(c.value)}:59${u}`:`${e}, ${j(c.rangeStart)}:00 to ${j(d(c))}:00${u}`}if(c.kind===`step`){let e=j(s.value),t=s.value===0?``:` at :${e}`;return c.rangeStart===null?`Every ${c.step} hours${t}${u}`:c.step===1?`Hourly, ${j(c.rangeStart)}:${e} to ${j(c.rangeEnd)}:${e}${u}`:`Every ${c.step} hours, ${j(c.rangeStart)}:${e} to ${j(d(c))}:${e}${u}`}if(c.kind===`any`)return`${s.value===0?`Every hour`:`Every hour at :${j(s.value)}`}${u}`;let f=`${j(c.value)}:${j(s.value)}`;return i===`*`?l?`${l} at ${f}`:`Daily at ${f}`:`Monthly on day ${Number(i)} at ${f}`}var P={timeMode:`at`,minute:0,hour:9,interval:1,window:null,dayMode:`every`,weekdays:[],dayOfMonth:1};function F(e){let t=e.match(/^(\d+)-(\d+)$/);if(t){let e=Number(t[1]),n=Number(t[2]);if(e>7||n>7||e>n)return null;let r=[];for(let t=e;t<=n;t+=1)r.push(t%7);return[...new Set(r)].sort((e,t)=>e-t)}let n=e.split(`,`);return n.every(e=>/^\d+$/.test(e)&&Number(e)<=7)?[...new Set(n.map(e=>Number(e)%7))].sort((e,t)=>e-t):null}function I(e){let t=e.trim().split(/\s+/);if(t.length!==5)return null;let[n,r,i,a,o]=t;if(a!==`*`||i!==`*`&&!/^\d+$/.test(i))return null;let s=A(n,59),c=A(r,23);if(!s||!c||s.kind===`step`&&s.rangeStart!==null)return null;let l=`every`,u=[],d=1;if(i!==`*`){if(o!==`*`)return null;let e=Number(i);if(e<1||e>31||s.kind!==`fixed`||c.kind!==`fixed`)return null;l=`dayOfMonth`,d=e}else if(o!==`*`){let e=F(o);if(e===null)return null;l=`weekdays`,u=e}let f={dayMode:l,weekdays:u,dayOfMonth:d};if(s.kind===`any`||s.kind===`step`){if(c.kind===`step`&&c.step>1)return null;let e=s.kind===`any`?1:s.step,t=c.kind===`any`?null:c.kind===`fixed`?{start:c.value,end:c.value}:{start:c.rangeStart,end:c.rangeEnd};return{...P,...f,timeMode:`everyMinutes`,minute:0,interval:e,window:t}}return c.kind===`fixed`?{...P,...f,timeMode:`at`,minute:s.value,hour:c.value}:c.kind===`any`?{...P,...f,timeMode:`everyHours`,minute:s.value,interval:1,window:null}:{...P,...f,timeMode:`everyHours`,minute:s.value,interval:c.step,window:c.rangeStart===null?null:{start:c.rangeStart,end:c.rangeEnd}}}function L(e){return e.dayMode===`dayOfMonth`?[String(e.dayOfMonth),`*`]:e.dayMode===`weekdays`&&e.weekdays.length>0?[`*`,[...e.weekdays].sort((e,t)=>e-t).join(`,`)]:[`*`,`*`]}function R(e){let[t,n]=L(e);if(e.timeMode===`everyMinutes`){let r=e.window===null?`*`:e.window.start===e.window.end?String(e.window.start):`${e.window.start}-${e.window.end}`;return`*/${e.interval} ${r} ${t} * ${n}`}if(e.timeMode===`everyHours`){let r=e.window===null?e.interval===1?`*`:`*/${e.interval}`:e.interval===1?`${e.window.start}-${e.window.end}`:`${e.window.start}-${e.window.end}/${e.interval}`;return`${e.minute} ${r} ${t} * ${n}`}return`${e.minute} ${e.hour} ${t} * ${n}`}var z={scheduled:`live`,suspended:`stood-down`,due:`inert`,cancelled:`inert`,completed:`inert`};function B(e){return e==null||!Object.hasOwn(z,e)?`unknown`:z[e]}var V={scheduled:{control:`suspend`,note:null},suspended:{control:`resume`,note:null},due:{control:`none`,note:`This one-time routine has already been dispatched. It will not run again.`},cancelled:{control:`none`,note:`This routine was cancelled and cannot be restarted. Delete it, or create a new one.`},completed:{control:`none`,note:`This routine has finished and will not run again.`}},H={control:`none`,note:`This routine's status is not one this dashboard recognises, so no start or stop is offered.`};function re(e){return e==null||!Object.hasOwn(V,e)?H:V[e]}var U={finished:`live`,gated:`live`,started:`in-flight`,accepted:`in-flight`,open:`in-flight`,failed:`error`,"no-destination":`warning`};function ie(e){return e==null||!Object.hasOwn(U,e)?`unknown`:U[e]}function W(e){return e===`gated`?`skipped: no work`:e??`unknown`}var G=i(),ae=[{value:1,label:`Mon`},{value:2,label:`Tue`},{value:3,label:`Wed`},{value:4,label:`Thu`},{value:5,label:`Fri`},{value:6,label:`Sat`},{value:0,label:`Sun`}],K=Array.from({length:24},(e,t)=>t),q=e=>String(e).padStart(2,`0`),J={timeMode:`at`,minute:0,hour:9,interval:1,window:null,dayMode:`every`,weekdays:[],dayOfMonth:1};function oe({recurrence:e,onChange:t,disabled:n}){let r=e?I(e):J,[i,a]=(0,O.useState)(r??J),[o]=(0,O.useState)(e!=null&&r==null),[s,c]=(0,O.useState)(e??``);if((0,O.useEffect)(()=>{fetch(`/api/_client-error`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`event`,source:`routines`,op:`schedule-editor`,mode:o?`raw`:`builder`}),keepalive:!0}).catch(()=>{})},[o]),o)return(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Schedule (advanced)`}),(0,G.jsx)(`input`,{type:`text`,className:`routine-raw-cron`,value:s,disabled:n,onChange:e=>{c(e.target.value),t(e.target.value)},"aria-label":`Cron expression`}),(0,G.jsx)(`span`,{className:`routine-raw-note`,children:`This routine uses an advanced schedule, edited as a raw cron expression.`})]});let l=e=>{a(e),t(R(e))},u=e=>{let t=e!==`at`&&i.dayMode===`dayOfMonth`?`every`:i.dayMode;l({...i,timeMode:e,dayMode:t})},d=e=>{let t=e===`weekdays`&&i.weekdays.length===0?[1]:i.weekdays;l({...i,dayMode:e,weekdays:t})},f=e=>{let[t,n]=e.split(`:`);l({...i,hour:Number(t)||0,minute:Number(n)||0})},p=e=>{let t=i.weekdays.includes(e);if(t&&i.weekdays.length===1)return;let n=t?i.weekdays.filter(t=>t!==e):[...i.weekdays,e];l({...i,weekdays:n})},m=e=>l({...i,window:e?{start:0,end:23}:null}),h=(e,t)=>{let n={...i.window??{start:0,end:23},[e]:Number(t)};n.start>n.end&&(e===`start`?n.end=n.start:n.start=n.end),l({...i,window:n})},g=(e,t,n)=>Math.min(n,Math.max(t,Number(e)||t));return(0,G.jsxs)(`div`,{className:`routine-sched`,children:[(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`How often`}),(0,G.jsxs)(`select`,{"aria-label":`How often`,value:i.timeMode,disabled:n,onChange:e=>u(e.target.value),children:[(0,G.jsx)(`option`,{value:`at`,children:`At a time of day`}),(0,G.jsx)(`option`,{value:`everyMinutes`,children:`Every few minutes`}),(0,G.jsx)(`option`,{value:`everyHours`,children:`Every few hours`})]})]}),i.timeMode===`at`&&(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Time of day`}),(0,G.jsx)(`input`,{type:`time`,"aria-label":`Time of day`,value:`${q(i.hour)}:${q(i.minute)}`,disabled:n,onChange:e=>f(e.target.value)})]}),i.timeMode===`everyMinutes`&&(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Minutes between runs`}),(0,G.jsx)(`input`,{type:`number`,min:1,max:59,"aria-label":`Minutes between runs`,value:i.interval,disabled:n,onChange:e=>l({...i,interval:g(e.target.value,1,59)})})]}),i.timeMode===`everyHours`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Hours between runs`}),(0,G.jsx)(`input`,{type:`number`,min:1,max:23,"aria-label":`Hours between runs`,value:i.interval,disabled:n,onChange:e=>l({...i,interval:g(e.target.value,1,23)})})]}),(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Minute of the hour`}),(0,G.jsx)(`input`,{type:`number`,min:0,max:59,"aria-label":`Minute of the hour`,value:i.minute,disabled:n,onChange:e=>l({...i,minute:g(e.target.value,0,59)})})]})]}),i.timeMode!==`at`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`cal-modal-field routine-sched-check`,children:[(0,G.jsx)(`input`,{type:`checkbox`,"aria-label":`Only between certain hours`,checked:i.window!==null,disabled:n,onChange:e=>m(e.target.checked)}),(0,G.jsx)(`span`,{children:`Only between certain hours`})]}),i.window!==null&&(0,G.jsxs)(`div`,{className:`routine-sched-row`,children:[(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`From hour`}),(0,G.jsx)(`select`,{"aria-label":`From hour`,value:i.window.start,disabled:n,onChange:e=>h(`start`,e.target.value),children:K.map(e=>(0,G.jsxs)(`option`,{value:e,children:[q(e),`:00`]},e))})]}),(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`To hour`}),(0,G.jsx)(`select`,{"aria-label":`To hour`,value:i.window.end,disabled:n,onChange:e=>h(`end`,e.target.value),children:K.map(e=>(0,G.jsxs)(`option`,{value:e,children:[q(e),`:00`]},e))})]})]})]}),(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Which days`}),(0,G.jsxs)(`select`,{"aria-label":`Which days`,value:i.dayMode,disabled:n,onChange:e=>d(e.target.value),children:[(0,G.jsx)(`option`,{value:`every`,children:`Every day`}),(0,G.jsx)(`option`,{value:`weekdays`,children:`Specific days`}),i.timeMode===`at`&&(0,G.jsx)(`option`,{value:`dayOfMonth`,children:`A day of the month`})]})]}),i.dayMode===`weekdays`&&(0,G.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Days`}),(0,G.jsx)(`div`,{className:`routine-weekdays`,children:ae.map(e=>(0,G.jsx)(`button`,{type:`button`,className:`routine-weekday${i.weekdays.includes(e.value)?` routine-weekday-on`:``}`,"aria-pressed":i.weekdays.includes(e.value),disabled:n,onClick:()=>p(e.value),children:e.label},e.value))})]}),i.dayMode===`dayOfMonth`&&(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Day of month`}),(0,G.jsx)(`select`,{"aria-label":`Day of month`,value:i.dayOfMonth,disabled:n,onChange:e=>l({...i,dayOfMonth:Number(e.target.value)||1}),children:Array.from({length:31},(e,t)=>t+1).map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]})]})}function Y(e){let t=e.trim().replace(/[\s\-().]/g,``).replace(/^\+/,``);return/^\d{11,15}$/.test(t)?`+${t.slice(0,2)} ${t.slice(2,6)} ${t.slice(6)}`:e}function se(e){if(e.name)return`${e.name} · ${e.label}`;let t=e.channel===`whatsapp`?Y(e.destination):e.destination;return`${e.label} · ${t}`}function ce({eventStatus:e}){let t=B(e);return(0,G.jsx)(`span`,{className:`routine-status-dot is-${t}`,"data-state":t,"aria-hidden":`true`})}function le(e){return e.agentChannel==null?e.actionPlugin==null?`trigger`:`deterministic`:e.gateTool==null?`agent-every-fire`:`checked-agent`}var ue={"checked-agent":`checks first, model only when there is work`,"agent-every-fire":`model every fire`,deterministic:`runs a tool, no model`,trigger:null};function de(e){return e.agentChannel&&e.agentDestination&&e.agentPrompt?`model`:e.actionPlugin&&e.actionTool?`tool`:`none`}function fe(e){let t=e.filter(e=>e.eventStatus===`scheduled`&&e.recurrence!=null),n={live:t.length,model:0,tool:0,none:0};for(let e of t)n[de(e)]++;return n}function pe(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}let n=t?.checks;return Array.isArray(n)?n.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e;return typeof t.type==`string`?[{kind:t.type,target:X(t.type,t)}]:[]}):[]}function X(e,t){let n=e=>typeof t[e]==`string`?t[e]:null;if(e===`mail`){let e=n(`mailbox`);if(e===null)return null;let t=n(`folder`);return t?`${e}/${t}`:e}return e===`d1`?n(`database`):e===`whatsapp`?n(`scope`):e===`calendar`?n(`connector`):null}function me(e,t){if(!e)return null;let n=Date.parse(e);if(!Number.isFinite(n))return null;let r=Math.max(t-n,0);return r<6e4?`${Math.round(r/1e3)}s ago`:r<36e5?`${Math.round(r/6e4)}m ago`:`${Math.round(r/36e5)}h ago`}function he(e,t){if(!e)return`—`;let n=Date.parse(e);return Number.isFinite(n)?p(new Date(n).toISOString(),t):e}function ge(e){return e?e.split(`
|
|
1
|
+
import{o as e,t}from"./chunk-BycB0eMI.js";import{i as n,n as r,t as i}from"./jsx-runtime-BY35JYDT.js";import{B as a,C as o,H as s,I as c,K as l,L as u,N as d,P as f,S as p,X as m,rt as h,tt as g,ut as _,v,y}from"./useMediaQuery-e4ciNiuO.js";import{k as b,m as x,t as S}from"./AdminShell-Dm_nY4jF.js";import{t as C}from"./clock-kLje910u.js";import{t as w}from"./triangle-alert-C_68TrTq.js";import{t as ee}from"./wrench-BI28h1JF.js";import{r as T}from"./file-download-B7zwa78w.js";var te=h(`circle-pause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),ne=h(`circle-play`,[[`path`,{d:`M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z`,key:`kmsa83`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),E=h(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),D=r(),O=e(n(),1),k=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function A(e,t){if(e===`*`)return{kind:`any`,value:0,rangeStart:null,rangeEnd:null,step:1};let n=e.match(/^(\*|\d+-\d+)\/(\d+)$/);if(n){let e=Number(n[2]);if(e<1)return null;if(n[1]===`*`)return{kind:`step`,value:0,rangeStart:null,rangeEnd:null,step:e};let[r,i]=n[1].split(`-`).map(Number);return r>t||i>t||r>i?null:{kind:`step`,value:0,rangeStart:r,rangeEnd:i,step:e}}let r=e.match(/^(\d+)-(\d+)$/);if(r){let e=Number(r[1]),n=Number(r[2]);return e>t||n>t||e>n?null:{kind:`step`,value:0,rangeStart:e,rangeEnd:n,step:1}}if(/^\d+$/.test(e)){let n=Number(e);return n>t?null:{kind:`fixed`,value:n,rangeStart:null,rangeEnd:null,step:1}}return null}function j(e){return String(e).padStart(2,`0`)}function M(e){if(e===`*`)return null;let t=e.match(/^(\d+)-(\d+)$/);if(t){let e=Number(t[1]),n=Number(t[2]);return e>7||n>7||e>n?`invalid`:`${k[e%7]} to ${k[n%7]}`}let n=e.split(`,`);return n.length>0&&n.every(e=>/^\d+$/.test(e)&&Number(e)<=7)?n.map(e=>k[Number(e)%7]).join(`, `):`invalid`}function N(e){let t=e.trim().split(/\s+/);if(t.length!==5)return e;let[n,r,i,a,o]=t;if(a!==`*`||i!==`*`&&!/^\d+$/.test(i)||i!==`*`&&(Number(i)<1||Number(i)>31))return e;let s=A(n,59),c=A(r,23);if(!s||!c)return e;let l=M(o);if(l===`invalid`||s.kind===`step`&&s.rangeStart!==null||(s.kind===`any`&&(s={kind:`step`,value:0,rangeStart:null,rangeEnd:null,step:1}),c.kind===`step`&&c.step===1&&c.rangeStart===null&&(c={kind:`any`,value:0,rangeStart:null,rangeEnd:null,step:1}),i!==`*`&&!(s.kind===`fixed`&&c.kind===`fixed`&&o===`*`))||s.kind===`step`&&c.kind===`step`&&c.step>1)return e;let u=l?`, ${l}`:``,d=e=>e.rangeStart+Math.floor((e.rangeEnd-e.rangeStart)/e.step)*e.step;if(s.kind===`step`){let e=s.step===1?`Every minute`:`Every ${s.step} minutes`;return c.kind===`any`?`${e}${u}`:c.kind===`fixed`?`${e}, ${j(c.value)}:00 to ${j(c.value)}:59${u}`:`${e}, ${j(c.rangeStart)}:00 to ${j(d(c))}:00${u}`}if(c.kind===`step`){let e=j(s.value),t=s.value===0?``:` at :${e}`;return c.rangeStart===null?`Every ${c.step} hours${t}${u}`:c.step===1?`Hourly, ${j(c.rangeStart)}:${e} to ${j(c.rangeEnd)}:${e}${u}`:`Every ${c.step} hours, ${j(c.rangeStart)}:${e} to ${j(d(c))}:${e}${u}`}if(c.kind===`any`)return`${s.value===0?`Every hour`:`Every hour at :${j(s.value)}`}${u}`;let f=`${j(c.value)}:${j(s.value)}`;return i===`*`?l?`${l} at ${f}`:`Daily at ${f}`:`Monthly on day ${Number(i)} at ${f}`}var P={timeMode:`at`,minute:0,hour:9,interval:1,window:null,dayMode:`every`,weekdays:[],dayOfMonth:1};function F(e){let t=e.match(/^(\d+)-(\d+)$/);if(t){let e=Number(t[1]),n=Number(t[2]);if(e>7||n>7||e>n)return null;let r=[];for(let t=e;t<=n;t+=1)r.push(t%7);return[...new Set(r)].sort((e,t)=>e-t)}let n=e.split(`,`);return n.every(e=>/^\d+$/.test(e)&&Number(e)<=7)?[...new Set(n.map(e=>Number(e)%7))].sort((e,t)=>e-t):null}function I(e){let t=e.trim().split(/\s+/);if(t.length!==5)return null;let[n,r,i,a,o]=t;if(a!==`*`||i!==`*`&&!/^\d+$/.test(i))return null;let s=A(n,59),c=A(r,23);if(!s||!c||s.kind===`step`&&s.rangeStart!==null)return null;let l=`every`,u=[],d=1;if(i!==`*`){if(o!==`*`)return null;let e=Number(i);if(e<1||e>31||s.kind!==`fixed`||c.kind!==`fixed`)return null;l=`dayOfMonth`,d=e}else if(o!==`*`){let e=F(o);if(e===null)return null;l=`weekdays`,u=e}let f={dayMode:l,weekdays:u,dayOfMonth:d};if(s.kind===`any`||s.kind===`step`){if(c.kind===`step`&&c.step>1)return null;let e=s.kind===`any`?1:s.step,t=c.kind===`any`?null:c.kind===`fixed`?{start:c.value,end:c.value}:{start:c.rangeStart,end:c.rangeEnd};return{...P,...f,timeMode:`everyMinutes`,minute:0,interval:e,window:t}}return c.kind===`fixed`?{...P,...f,timeMode:`at`,minute:s.value,hour:c.value}:c.kind===`any`?{...P,...f,timeMode:`everyHours`,minute:s.value,interval:1,window:null}:{...P,...f,timeMode:`everyHours`,minute:s.value,interval:c.step,window:c.rangeStart===null?null:{start:c.rangeStart,end:c.rangeEnd}}}function L(e){return e.dayMode===`dayOfMonth`?[String(e.dayOfMonth),`*`]:e.dayMode===`weekdays`&&e.weekdays.length>0?[`*`,[...e.weekdays].sort((e,t)=>e-t).join(`,`)]:[`*`,`*`]}function R(e){let[t,n]=L(e);if(e.timeMode===`everyMinutes`){let r=e.window===null?`*`:e.window.start===e.window.end?String(e.window.start):`${e.window.start}-${e.window.end}`;return`*/${e.interval} ${r} ${t} * ${n}`}if(e.timeMode===`everyHours`){let r=e.window===null?e.interval===1?`*`:`*/${e.interval}`:e.interval===1?`${e.window.start}-${e.window.end}`:`${e.window.start}-${e.window.end}/${e.interval}`;return`${e.minute} ${r} ${t} * ${n}`}return`${e.minute} ${e.hour} ${t} * ${n}`}var z={scheduled:`live`,suspended:`stood-down`,due:`inert`,cancelled:`inert`,completed:`inert`};function B(e){return e==null||!Object.hasOwn(z,e)?`unknown`:z[e]}var V={scheduled:{control:`suspend`,note:null},suspended:{control:`resume`,note:null},due:{control:`none`,note:`This one-time routine has already been dispatched. It will not run again.`},cancelled:{control:`none`,note:`This routine was cancelled and cannot be restarted. Delete it, or create a new one.`},completed:{control:`none`,note:`This routine has finished and will not run again.`}},H={control:`none`,note:`This routine's status is not one this dashboard recognises, so no start or stop is offered.`};function re(e){return e==null||!Object.hasOwn(V,e)?H:V[e]}var U={finished:`live`,gated:`live`,started:`in-flight`,accepted:`in-flight`,open:`in-flight`,failed:`error`,"no-destination":`warning`};function ie(e){return e==null||!Object.hasOwn(U,e)?`unknown`:U[e]}function W(e){return e===`gated`?`skipped: no work`:e??`unknown`}var G=i(),ae=[{value:1,label:`Mon`},{value:2,label:`Tue`},{value:3,label:`Wed`},{value:4,label:`Thu`},{value:5,label:`Fri`},{value:6,label:`Sat`},{value:0,label:`Sun`}],K=Array.from({length:24},(e,t)=>t),q=e=>String(e).padStart(2,`0`),J={timeMode:`at`,minute:0,hour:9,interval:1,window:null,dayMode:`every`,weekdays:[],dayOfMonth:1};function oe({recurrence:e,onChange:t,disabled:n}){let r=e?I(e):J,[i,a]=(0,O.useState)(r??J),[o]=(0,O.useState)(e!=null&&r==null),[s,c]=(0,O.useState)(e??``);if((0,O.useEffect)(()=>{fetch(`/api/_client-error`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:`event`,source:`routines`,op:`schedule-editor`,mode:o?`raw`:`builder`}),keepalive:!0}).catch(()=>{})},[o]),o)return(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Schedule (advanced)`}),(0,G.jsx)(`input`,{type:`text`,className:`routine-raw-cron`,value:s,disabled:n,onChange:e=>{c(e.target.value),t(e.target.value)},"aria-label":`Cron expression`}),(0,G.jsx)(`span`,{className:`routine-raw-note`,children:`This routine uses an advanced schedule, edited as a raw cron expression.`})]});let l=e=>{a(e),t(R(e))},u=e=>{let t=e!==`at`&&i.dayMode===`dayOfMonth`?`every`:i.dayMode;l({...i,timeMode:e,dayMode:t})},d=e=>{let t=e===`weekdays`&&i.weekdays.length===0?[1]:i.weekdays;l({...i,dayMode:e,weekdays:t})},f=e=>{let[t,n]=e.split(`:`);l({...i,hour:Number(t)||0,minute:Number(n)||0})},p=e=>{let t=i.weekdays.includes(e);if(t&&i.weekdays.length===1)return;let n=t?i.weekdays.filter(t=>t!==e):[...i.weekdays,e];l({...i,weekdays:n})},m=e=>l({...i,window:e?{start:0,end:23}:null}),h=(e,t)=>{let n={...i.window??{start:0,end:23},[e]:Number(t)};n.start>n.end&&(e===`start`?n.end=n.start:n.start=n.end),l({...i,window:n})},g=(e,t,n)=>Math.min(n,Math.max(t,Number(e)||t));return(0,G.jsxs)(`div`,{className:`routine-sched`,children:[(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`How often`}),(0,G.jsxs)(`select`,{"aria-label":`How often`,value:i.timeMode,disabled:n,onChange:e=>u(e.target.value),children:[(0,G.jsx)(`option`,{value:`at`,children:`At a time of day`}),(0,G.jsx)(`option`,{value:`everyMinutes`,children:`Every few minutes`}),(0,G.jsx)(`option`,{value:`everyHours`,children:`Every few hours`})]})]}),i.timeMode===`at`&&(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Time of day`}),(0,G.jsx)(`input`,{type:`time`,"aria-label":`Time of day`,value:`${q(i.hour)}:${q(i.minute)}`,disabled:n,onChange:e=>f(e.target.value)})]}),i.timeMode===`everyMinutes`&&(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Minutes between runs`}),(0,G.jsx)(`input`,{type:`number`,min:1,max:59,"aria-label":`Minutes between runs`,value:i.interval,disabled:n,onChange:e=>l({...i,interval:g(e.target.value,1,59)})})]}),i.timeMode===`everyHours`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Hours between runs`}),(0,G.jsx)(`input`,{type:`number`,min:1,max:23,"aria-label":`Hours between runs`,value:i.interval,disabled:n,onChange:e=>l({...i,interval:g(e.target.value,1,23)})})]}),(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Minute of the hour`}),(0,G.jsx)(`input`,{type:`number`,min:0,max:59,"aria-label":`Minute of the hour`,value:i.minute,disabled:n,onChange:e=>l({...i,minute:g(e.target.value,0,59)})})]})]}),i.timeMode!==`at`&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`cal-modal-field routine-sched-check`,children:[(0,G.jsx)(`input`,{type:`checkbox`,"aria-label":`Only between certain hours`,checked:i.window!==null,disabled:n,onChange:e=>m(e.target.checked)}),(0,G.jsx)(`span`,{children:`Only between certain hours`})]}),i.window!==null&&(0,G.jsxs)(`div`,{className:`routine-sched-row`,children:[(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`From hour`}),(0,G.jsx)(`select`,{"aria-label":`From hour`,value:i.window.start,disabled:n,onChange:e=>h(`start`,e.target.value),children:K.map(e=>(0,G.jsxs)(`option`,{value:e,children:[q(e),`:00`]},e))})]}),(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`To hour`}),(0,G.jsx)(`select`,{"aria-label":`To hour`,value:i.window.end,disabled:n,onChange:e=>h(`end`,e.target.value),children:K.map(e=>(0,G.jsxs)(`option`,{value:e,children:[q(e),`:00`]},e))})]})]})]}),(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Which days`}),(0,G.jsxs)(`select`,{"aria-label":`Which days`,value:i.dayMode,disabled:n,onChange:e=>d(e.target.value),children:[(0,G.jsx)(`option`,{value:`every`,children:`Every day`}),(0,G.jsx)(`option`,{value:`weekdays`,children:`Specific days`}),i.timeMode===`at`&&(0,G.jsx)(`option`,{value:`dayOfMonth`,children:`A day of the month`})]})]}),i.dayMode===`weekdays`&&(0,G.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Days`}),(0,G.jsx)(`div`,{className:`routine-weekdays`,children:ae.map(e=>(0,G.jsx)(`button`,{type:`button`,className:`routine-weekday${i.weekdays.includes(e.value)?` routine-weekday-on`:``}`,"aria-pressed":i.weekdays.includes(e.value),disabled:n,onClick:()=>p(e.value),children:e.label},e.value))})]}),i.dayMode===`dayOfMonth`&&(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Day of month`}),(0,G.jsx)(`select`,{"aria-label":`Day of month`,value:i.dayOfMonth,disabled:n,onChange:e=>l({...i,dayOfMonth:Number(e.target.value)||1}),children:Array.from({length:31},(e,t)=>t+1).map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]})]})}function Y(e){let t=e.trim().replace(/[\s\-().]/g,``).replace(/^\+/,``);return/^\d{11,15}$/.test(t)?`+${t.slice(0,2)} ${t.slice(2,6)} ${t.slice(6)}`:e}function se(e){if(e.name)return`${e.name} · ${e.label}`;let t=e.channel===`whatsapp`?Y(e.destination):e.destination;return`${e.label} · ${t}`}function ce({eventStatus:e}){let t=B(e);return(0,G.jsx)(`span`,{className:`routine-status-dot is-${t}`,"data-state":t,"aria-hidden":`true`})}function le(e){return e.agentChannel==null?e.actionPlugin==null?`trigger`:`deterministic`:e.gateTool==null?`agent-every-fire`:`checked-agent`}var ue={"checked-agent":`checks first, model only when there is work`,"agent-every-fire":`model every fire`,deterministic:`runs a tool, no model`,trigger:null};function de(e){return e.agentChannel&&e.agentDestination&&e.agentPrompt?`model`:e.actionPlugin&&e.actionTool?`tool`:`none`}function fe(e){let t=e.filter(e=>e.eventStatus===`scheduled`&&e.recurrence!=null),n={live:t.length,model:0,tool:0,none:0};for(let e of t)n[de(e)]++;return n}function pe(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}let n=t?.checks;return Array.isArray(n)?n.flatMap(e=>{if(typeof e!=`object`||!e)return[];let t=e;return typeof t.type==`string`?[{kind:t.type,target:X(t.type,t)}]:[]}):[]}function X(e,t){let n=e=>typeof t[e]==`string`?t[e]:null;if(e===`mail`){let e=n(`mailbox`);if(e===null)return null;let t=n(`folder`);return t?`${e}/${t}`:e}return e===`d1`?n(`database`):e===`whatsapp`?n(`scope`):e===`calendar`?n(`connector`):null}function me(e,t){if(!e)return null;let n=Date.parse(e);if(!Number.isFinite(n))return null;let r=Math.max(t-n,0);return r<6e4?`${Math.round(r/1e3)}s ago`:r<36e5?`${Math.round(r/6e4)}m ago`:`${Math.round(r/36e5)}h ago`}function he(e,t){if(!e)return`—`;let n=Date.parse(e);return Number.isFinite(n)?p(new Date(n).toISOString(),t):e}function ge(e){return e?e.split(`
|
|
2
2
|
`).filter(e=>e.trim()!==``).reverse():[]}function Z({routine:e,adminFetch:t,onClose:n,onSaved:r,onDeleted:i,onViewRuns:a}){let{zone:d}=o(),[f,p]=(0,O.useState)(!1),[m,h]=(0,O.useState)(!1),[g,_]=(0,O.useState)(null),[b,S]=(0,O.useState)(e),[w,T]=(0,O.useState)(!1),D=b.agentChannel!=null,k=le(b),A=pe(b.gateArgs),j=me(b.gateLastCommitAt,Date.now()),M=re(b.eventStatus),P=M.control===`resume`,[F,I]=(0,O.useState)(!1),[L,R]=(0,O.useState)(e.agentPrompt??``),[z,B]=(0,O.useState)(e.name??``),[V,H]=(0,O.useState)(e.description??``),[U,ie]=(0,O.useState)(e.recurrence),[W,ae]=(0,O.useState)(e.agentChannel??``),[K,q]=(0,O.useState)(e.agentDestination??``),[J,Y]=(0,O.useState)(null),[de,fe]=(0,O.useState)(null),X=D||b.actionPlugin==null,Z=ge(b.notes);(0,O.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!m&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[m,n]),(0,O.useEffect)(()=>{if(!f||!X||J!==null)return;let e=!1;return t(`/api/admin/dispatch-destinations`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return await e.json()}).then(t=>{e||Y(t.destinations)}).catch(t=>{e||(Y([]),fe(t instanceof Error?t.message:`Could not load destinations`))}),()=>{e=!0}},[f,X,J,t]);let Q=(J??[]).filter(e=>e.channel===W),_e=W.length>0&&K.length>0,ve=z.trim().length===0&&(b.name??``).length>0||W.length>0&&K.length===0||_e&&L.trim().length===0,ye=(0,O.useCallback)(()=>{let e={},t=W.length>0&&K.length>0,n=z.trim();n!==(b.name??``)&&(e.name=n),(D||t)&&L!==(b.agentPrompt??``)&&(e.agentPrompt=L);let r=V.trim().length>0?V:null;return r!==(b.description??null)&&(e.description=r),U!=null&&U!==(b.recurrence??null)&&(e.recurrence=U),t&&(W!==(b.agentChannel??``)||K!==(b.agentDestination??``))?(e.agentChannel=W,e.agentDestination=K):!t&&W===``&&(b.agentChannel??``)!==``&&(e.agentChannel=null,e.agentDestination=null),e},[D,z,L,V,U,W,K,b]),be=(0,O.useCallback)(async()=>{let n=ye();if(Object.keys(n).length===0){p(!1);return}h(!0),_(null);try{let i=await t(`/api/admin/routines/${encodeURIComponent(e.eventId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??`HTTP ${i.status}`)}let a=await i.json();S(a.routine),B(a.routine.name??``),R(a.routine.agentPrompt??``),H(a.routine.description??``),ie(a.routine.recurrence),ae(a.routine.agentChannel??``),q(a.routine.agentDestination??``),r(a.routine),p(!1)}catch(e){_(e instanceof Error?e.message:`Save failed`)}finally{h(!1)}},[t,ye,e.eventId,r]),xe=(0,O.useCallback)(async()=>{if(m)return;if(!F){T(!1),I(!0);return}let n=P?`resume`:`suspend`;h(!0),_(null);try{let i=await t(`/api/admin/routines/${encodeURIComponent(e.eventId)}/${n}`,{method:`POST`});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??`HTTP ${i.status}`)}let a=await i.json();S(a.routine),r(a.routine),I(!1)}catch(e){_(e instanceof Error?e.message:`${n} failed`),I(!1)}finally{h(!1)}},[t,m,F,P,e.eventId,r]),Se=(0,O.useCallback)(async()=>{if(!m){if(!w){I(!1),T(!0);return}h(!0),_(null);try{let n=await t(`/api/admin/routines/${encodeURIComponent(e.eventId)}`,{method:`DELETE`});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`HTTP ${n.status}`)}i(e.eventId)}catch(e){_(e instanceof Error?e.message:`Delete failed`),T(!1)}finally{h(!1)}}},[t,m,w,e.eventId,i]);return(0,G.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{m||n()},children:(0,G.jsxs)(`div`,{className:`cal-modal ${!f||D||_e?`cal-modal-wide`:`cal-modal-dispatch`}`,role:`dialog`,"aria-modal":`true`,"aria-label":f?`Edit routine`:`Routine detail`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,G.jsxs)(`span`,{className:`cal-modal-kind`,children:[(0,G.jsx)(x,{size:13}),` Routine`]}),(0,G.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:n,"aria-label":`Close`,autoFocus:!0,disabled:m,children:(0,G.jsx)(c,{size:16})})]}),!f&&(0,G.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,G.jsx)(`div`,{className:`cal-modal-title`,children:b.name??`Untitled routine`}),(0,G.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,G.jsx)(C,{size:14}),(0,G.jsx)(`span`,{children:b.recurrence?N(b.recurrence):`One-time`})]}),(0,G.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,G.jsx)(ce,{eventStatus:b.eventStatus}),(0,G.jsxs)(`span`,{children:[`Status: `,b.eventStatus??`unknown`]})]}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsxs)(`span`,{children:[`Next run: `,he(b.nextRun,d)]})}),(0,G.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,G.jsx)(E,{size:14}),(0,G.jsxs)(`span`,{children:[`Last run: `,he(b.lastTriggered,d),b.lastDispatchResult?` (${b.lastDispatchResult})`:``]})]}),b.description&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsx)(`span`,{children:`Description`})}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-row-top routine-prose`,children:(0,G.jsx)(`span`,{children:b.description})})]}),ue[k]&&(0,G.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,"data-testid":`routine-mode`,children:[(0,G.jsx)(x,{size:14}),(0,G.jsxs)(`span`,{children:[ue[k],k===`agent-every-fire`&&b.gateWaived?`: ${b.gateWaived}`:``]})]}),b.gateClassified===!1&&b.gateTool==null&&(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,"data-testid":`gate-unclassified`,children:(0,G.jsx)(`span`,{children:`No check is set and no reason is recorded, so every fire spends a model turn.`})}),D?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,G.jsx)(y,{channel:b.agentChannel,size:14}),(0,G.jsxs)(`span`,{children:[v[b.agentChannel]??b.agentChannel,` to `,b.agentDestination??`—`]})]}),b.gateTool!=null&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsx)(`span`,{children:`Checks before the agent runs`})}),(0,G.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,G.jsx)(ee,{size:14}),(0,G.jsxs)(`span`,{children:[b.gatePlugin,`.`,b.gateTool]})]}),A.map((e,t)=>(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,"data-testid":`gate-check`,children:(0,G.jsxs)(`span`,{children:[e.kind,e.target?` · ${e.target}`:``]})},t)),b.lastTriggered!=null&&(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,"data-testid":`gate-commit-age`,children:(0,G.jsx)(`span`,{children:j===null?`This gate has never committed, so it reports work on every fire.`:`Checks last committed ${j} (${he(b.gateLastCommitAt,d)})`})})]}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsx)(`span`,{children:`Instruction sent to the agent`})}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-row-top routine-prose`,children:(0,G.jsx)(`span`,{children:b.agentPrompt??`No instruction sent to the agent.`})})]}):b.actionPlugin?(0,G.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,G.jsx)(ee,{size:14}),(0,G.jsxs)(`span`,{children:[b.actionPlugin,`.`,b.actionTool,b.actionArgs?` ${b.actionArgs}`:``]})]}):(0,G.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,G.jsx)(C,{size:14}),(0,G.jsx)(`span`,{children:`Scheduled trigger (no dispatch)`})]}),Z.length===0?(0,G.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,G.jsx)(E,{size:14}),(0,G.jsx)(`span`,{children:`No history recorded.`})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,G.jsx)(E,{size:14}),(0,G.jsxs)(`span`,{children:[`History (`,Z.length,` `,Z.length===1?`entry`:`entries`,`)`]})]}),(0,G.jsx)(`div`,{className:`routine-history`,children:Z.map((e,t)=>(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:e},t))})]})]}),f&&(0,G.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Name`}),(0,G.jsx)(`input`,{type:`text`,value:z,onChange:e=>B(e.target.value),disabled:m,maxLength:200,placeholder:`The routine's title, shown on the card`})]}),X&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Send to`}),(0,G.jsxs)(`div`,{className:`cal-modal-field-inline`,children:[(0,G.jsxs)(`select`,{value:W,disabled:m,onChange:e=>{ae(e.target.value),q(``)},children:[(0,G.jsx)(`option`,{value:``,children:`None (no dispatch)`}),(0,G.jsx)(`option`,{value:`whatsapp`,children:`WhatsApp`}),(0,G.jsx)(`option`,{value:`telegram`,children:`Telegram`})]}),W!==``&&(0,G.jsx)(y,{channel:W,size:16})]})]}),W!==``&&(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Destination`}),(0,G.jsxs)(`select`,{value:K,disabled:m||J===null,onChange:e=>q(e.target.value),children:[(0,G.jsx)(`option`,{value:``,children:J===null?`Loading destinations`:Q.length===0?`No registered destinations`:`Choose a destination`}),K!==``&&!Q.some(e=>e.destination===K)&&(0,G.jsxs)(`option`,{value:K,children:[K,` (not in the current list)`]}),Q.map(e=>(0,G.jsx)(`option`,{value:e.destination,children:se(e)},e.destination))]})]}),de&&(0,G.jsxs)(`div`,{className:`cal-modal-error`,children:[`Could not load destinations: `,de]})]}),(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Description`}),(0,G.jsx)(`input`,{type:`text`,value:V,onChange:e=>H(e.target.value),disabled:m,placeholder:`One line: what this routine is for`})]}),(D||_e)&&(0,G.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,G.jsx)(`span`,{children:`Instruction sent to the agent`}),(0,G.jsx)(`textarea`,{className:`cal-modal-textarea`,value:L,onChange:e=>R(e.target.value),disabled:m,rows:16,placeholder:`What should the agent do when this routine fires?`})]}),(0,G.jsx)(oe,{recurrence:b.recurrence,onChange:ie,disabled:m})]}),g&&(0,G.jsx)(`div`,{className:`cal-modal-error`,children:g}),(0,G.jsxs)(`div`,{className:`cal-modal-actions`,children:[!f&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{T(!1),I(!1),p(!0)},disabled:m,children:[(0,G.jsx)(s,{size:14}),` Edit`]}),(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>a(b),disabled:m,children:[(0,G.jsx)(E,{size:14}),` Runs`]}),M.control===`none`?(0,G.jsx)(`span`,{className:`cal-modal-confirm-text`,children:M.note}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:xe,disabled:m,children:[m&&F?(0,G.jsx)(l,{size:14,className:`spin`}):P?(0,G.jsx)(ne,{size:14}):(0,G.jsx)(te,{size:14}),F?P?`Confirm resume`:`Confirm suspend`:P?`Resume`:`Suspend`]}),F&&(0,G.jsx)(`span`,{className:`cal-modal-confirm-text`,children:P?`This routine will run at its next scheduled time. It will not run for the times it missed.`:`This routine stops running until you resume it. Nothing is deleted.`})]}),(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:Se,disabled:m,children:[m&&w?(0,G.jsx)(l,{size:14,className:`spin`}):(0,G.jsx)(u,{size:14}),w?`Confirm delete`:`Delete`]})]}),f&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:be,disabled:m||ve,children:[m?(0,G.jsx)(l,{size:14,className:`spin`}):null,` Save`]}),(0,G.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{p(!1),_(null)},disabled:m,children:`Cancel`})]})]})]})})}function Q(e,t){if(!e)return`—`;let n=Date.parse(e);return Number.isFinite(n)?p(new Date(n).toISOString(),t):e}function _e(e){return e===null?`—`:e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`}function ve({run:e,routineName:t,onClose:n}){let{zone:r}=o();return(0,O.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,G.jsx)(`div`,{className:`cal-modal-overlay`,onClick:n,children:(0,G.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":`Run detail`,onClick:e=>e.stopPropagation(),children:[(0,G.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,G.jsx)(`span`,{className:`cal-modal-kind`,children:`Run`}),(0,G.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:n,"aria-label":`Close`,autoFocus:!0,children:(0,G.jsx)(c,{size:16})})]}),(0,G.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,G.jsx)(`div`,{className:`cal-modal-title`,children:t??`Untitled routine`}),e.outputExcerpt!==null&&(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-row-top routine-prose`,"data-testid":`run-output`,children:(0,G.jsx)(`span`,{children:e.outputExcerpt})}),e.outputExcerpt===null&&e.status===`finished`&&(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,"data-testid":`run-output-none`,children:(0,G.jsx)(`span`,{children:`This run finished without sending anything.`})}),(0,G.jsx)(`div`,{className:`cal-modal-row`,children:(0,G.jsx)(`span`,{children:W(e.status)})}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsxs)(`span`,{children:[`Due: `,Q(e.scheduledFor,r)]})}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsxs)(`span`,{children:[`Started: `,Q(e.startedAt,r)]})}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsxs)(`span`,{children:[`Dispatch ended: `,Q(e.endedAt,r),` (`,_e(e.ranMs),`)`]})}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsxs)(`span`,{children:[`Output seen: `,Q(e.finishedAt,r)]})}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsxs)(`span`,{children:[`Sent to: `,e.target,` · `,e.mode,` · `,e.kind]})}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsxs)(`span`,{children:[`Transport: `,e.dispatchResult??`—`,e.httpStatus===null?``:` (HTTP ${e.httpStatus})`]})}),e.error&&(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-row-top routine-prose`,children:(0,G.jsx)(`span`,{children:e.error})}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsxs)(`span`,{children:[`Conversation: `,e.sessionKey??`—`,e.transcriptOffset===null?``:` at byte ${e.transcriptOffset}`]})}),!e.bounded&&e.status!==`gated`&&(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsx)(`span`,{children:`This run shares its conversation with other traffic, so what it produced cannot be separated out. Its status stays at whatever the dispatch reported.`})}),(0,G.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,G.jsxs)(`span`,{children:[`Run `,e.runId]})})]})]})})}function ye({status:e}){let t=ie(e);return(0,G.jsx)(`span`,{className:`routine-status-dot is-${t}`,"data-state":t,"aria-hidden":`true`})}var be=500;function xe(e,t){if(!e)return`—`;let n=Date.parse(e);return Number.isFinite(n)?p(new Date(n).toISOString(),t):e}function Se(e){return e===null?`—`:e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`}var Ce={channel:`a channel`,destination:`a destination`,prompt:`an instruction`};function we(e){if(e===`no-dispatch-configured`)return`This routine has no dispatch set up, so there was nothing to do.`;if(e===`no-action-plugin`)return`The tool action names no plugin, so nothing ran.`;if(e===`no-action-tool`)return`The tool action names no tool, so nothing ran.`;let t=e.startsWith(`no-`)?e.slice(3).split(`+`):[];if(t.length>0&&t.every(e=>e in Ce)){let e=t.map(e=>Ce[e]);return`This routine has no ${(e.length===1?e[0]:`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`).replace(/^an? /,``)} set, so nothing was sent.`}return e}function Te(e){return e.status===`no-destination`?e.error?we(e.error):`Nothing was dispatched, and no reason was recorded.`:e.status===`failed`?e.error??e.dispatchResult??`The dispatch failed.`:e.status===`open`?`Opened and never closed. The dispatch did not report back.`:null}function Ee(e){let t=e.indexOf(`:`);return t<=0?{channel:null,destination:e}:{channel:e.slice(0,t),destination:e.slice(t+1)}}function De(e){return e.outputExcerpt===null?e.status===`finished`?`Finished and sent nothing.`:null:e.outputExcerpt}function Oe({routine:e,adminFetch:t,cacheKey:n,from:r=`card`,onBack:i}){let{zone:s}=o(),[c,u]=(0,O.useState)([]),[d,f]=(0,O.useState)(!0),[p,h]=(0,O.useState)(null),[_,b]=(0,O.useState)(null),x=(0,O.useRef)(0),S=(0,O.useCallback)(()=>{let n=!1,i=++x.current,a=()=>n||i!==x.current;return f(!0),h(null),t(`/api/admin/routines/${encodeURIComponent(e.eventId)}/runs?limit=${be}&from=${r}`).then(async e=>{if(a())return;if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();a()||u(Array.isArray(t.runs)?t.runs:[])}).catch(e=>{a()||(h(e instanceof Error?e.message:`Failed to load`),u([]))}).finally(()=>{a()||f(!1)}),()=>{n=!0}},[t,e.eventId,r]);(0,O.useEffect)(()=>S(),[S]);let C=(0,O.useCallback)(()=>{T(n,e.eventId)},[n,e.eventId]);return(0,G.jsxs)(`div`,{className:`cal-page`,children:[(0,G.jsx)(`header`,{className:`cal-header`,children:(0,G.jsxs)(`div`,{className:`cal-nav`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:i,children:[(0,G.jsx)(g,{size:14}),` Routines`]}),(0,G.jsx)(`span`,{className:`cal-range-label runs-title`,"data-testid":`runs-title`,title:e.name??`Untitled routine`,children:e.name??`Untitled routine`}),(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,"data-testid":`runs-refresh`,onClick:S,disabled:d,title:`Refresh runs`,"aria-label":`Refresh runs`,children:[d?(0,G.jsx)(l,{size:14,className:`spin`}):(0,G.jsx)(a,{size:14}),` Refresh`]}),c.length>0&&(0,G.jsx)(`div`,{className:`routine-bulk-actions`,children:(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:C,children:[(0,G.jsx)(m,{size:14}),` Download all runs`]})})]})}),(0,G.jsxs)(`div`,{className:`cal-body`,children:[p&&(0,G.jsxs)(`div`,{className:`cal-error`,children:[`Could not load runs: `,p]}),!p&&!d&&c.length===0&&(0,G.jsxs)(`div`,{className:`cal-empty`,"data-testid":`runs-empty`,children:[(0,G.jsx)(`p`,{children:`Nothing to show for this routine.`}),(0,G.jsx)(`p`,{children:`That means one of three things, and this page cannot tell them apart: it has never run, it ran but no record was written, or every run it did have is older than the 30 days records are kept for.`}),(0,G.jsxs)(`p`,{children:[`For a repeating routine, the server log settles the middle one: a`,(0,G.jsx)(`code`,{children:` fires-without-records `}),` count above zero names a routine that fired and left no record. It does not distinguish the other two, and it does not cover a one-time routine.`]})]}),c.length>=be&&(0,G.jsxs)(`div`,{className:`cal-modal-confirm-text`,"data-testid":`runs-capped`,children:[`Showing the most recent `,be,` runs. There may be more; the download has everything still on record.`]}),(0,G.jsx)(`div`,{className:`routine-list`,children:c.map(e=>{let t=Te(e),n=De(e),{channel:r,destination:i}=Ee(e.target);return(0,G.jsxs)(`button`,{type:`button`,className:`admin-card admin-card--padded routine-card`,"data-testid":`run-row-${e.runId}`,onClick:()=>b(e),children:[(0,G.jsxs)(`span`,{className:`admin-card-title routine-card-title run-card-title`,children:[(0,G.jsx)(ye,{status:e.status}),` `,W(e.status)]}),(0,G.jsx)(`span`,{className:`routine-card-sched`,children:Se(e.ranMs)}),(0,G.jsx)(`span`,{className:`routine-card-target`,children:r?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(y,{channel:r,size:13}),` `,v[r]??r,` to `,r===`whatsapp`?Y(i):i]}):i}),(0,G.jsxs)(`span`,{className:`routine-card-meta`,children:[`Due `,xe(e.scheduledFor,s)]}),n&&(0,G.jsx)(`span`,{className:`routine-card-meta run-card-output`,children:n}),t&&(0,G.jsx)(`span`,{className:`routine-card-meta run-card-detail`,children:t})]},e.runId)})})]}),_&&(0,G.jsx)(ve,{run:_,routineName:e.name,onClose:()=>b(null)})]})}var ke=500;function Ae(e,t){if(!e)return`—`;let n=Date.parse(e);return Number.isFinite(n)?p(new Date(n).toISOString(),t):e}function je(e){return e===null?`—`:e<1e3?`${e} ms`:`${(e/1e3).toFixed(1)} s`}function Me({adminFetch:e,onBack:t}){let{zone:n}=o(),[r,i]=(0,O.useState)([]),[s,c]=(0,O.useState)(!0),[u,d]=(0,O.useState)(null),[f,p]=(0,O.useState)(null),m=(0,O.useRef)(0),h=(0,O.useCallback)(()=>{let t=!1,n=++m.current,r=()=>t||n!==m.current;return c(!0),d(null),e(`/api/admin/routines/runs?limit=${ke}`).then(async e=>{if(r())return;if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();r()||i(Array.isArray(t.runs)?t.runs:[])}).catch(e=>{r()||(d(e instanceof Error?e.message:`Failed to load`),i([]))}).finally(()=>{r()||c(!1)}),()=>{t=!0}},[e]);return(0,O.useEffect)(()=>h(),[h]),(0,G.jsxs)(`div`,{className:`cal-page`,children:[(0,G.jsx)(`header`,{className:`cal-header`,children:(0,G.jsxs)(`div`,{className:`cal-nav`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:t,children:[(0,G.jsx)(g,{size:14}),` Routines`]}),(0,G.jsx)(`span`,{className:`cal-range-label runs-title`,"data-testid":`all-runs-title`,children:`All routine runs`}),(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,"data-testid":`all-runs-refresh`,onClick:h,disabled:s,title:`Refresh runs`,"aria-label":`Refresh runs`,children:[s?(0,G.jsx)(l,{size:14,className:`spin`}):(0,G.jsx)(a,{size:14}),` Refresh`]})]})}),(0,G.jsxs)(`div`,{className:`cal-body`,children:[u&&(0,G.jsxs)(`div`,{className:`cal-error`,children:[`Could not load runs: `,u]}),!u&&!s&&r.length===0&&(0,G.jsx)(`div`,{className:`cal-empty`,"data-testid":`all-runs-empty`,children:(0,G.jsx)(`p`,{children:`No routine has run yet.`})}),r.length>=ke&&(0,G.jsxs)(`div`,{className:`cal-modal-confirm-text`,"data-testid":`all-runs-capped`,children:[`Showing the most recent `,ke,` runs. There may be more on record.`]}),(0,G.jsx)(`div`,{className:`routine-list`,children:r.map(e=>{let t=Te(e),r=De(e),{channel:i,destination:a}=Ee(e.target);return(0,G.jsxs)(`button`,{type:`button`,className:`admin-card admin-card--padded routine-card`,"data-testid":`all-run-row-${e.runId}`,onClick:()=>p(e),children:[(0,G.jsxs)(`span`,{className:`admin-card-title routine-card-title run-card-title`,children:[(0,G.jsx)(ye,{status:e.status}),` `,e.eventName]}),(0,G.jsxs)(`span`,{className:`routine-card-sched`,children:[W(e.status),` · `,je(e.ranMs)]}),(0,G.jsx)(`span`,{className:`routine-card-target`,children:i?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(y,{channel:i,size:13}),` `,v[i]??i,` to `,i===`whatsapp`?Y(a):a]}):a}),(0,G.jsxs)(`span`,{className:`routine-card-meta`,children:[`Due `,Ae(e.scheduledFor,n)]}),r&&(0,G.jsx)(`span`,{className:`routine-card-meta run-card-output`,children:r}),t&&(0,G.jsx)(`span`,{className:`routine-card-meta run-card-detail`,children:t})]},e.runId)})})]}),f&&(0,G.jsx)(ve,{run:f,routineName:f.eventName,onClose:()=>p(null)})]})}t(((e,t)=>{t.exports={}}))();function Ne(e){return e.agentChannel&&e.agentDestination&&e.agentPrompt?!0:!!(e.actionPlugin&&e.actionTool)}function Pe(e){if(e.agentChannel||e.agentDestination||e.agentPrompt){let t=[];return e.agentChannel||t.push(`channel`),e.agentDestination||t.push(`destination`),e.agentPrompt||t.push(`prompt`),`no-${t.join(`+`)}`}return e.actionPlugin||e.actionTool?e.actionTool?`no-action-plugin`:`no-action-tool`:`no-dispatch-configured`}var $=`maxy-admin-session-key`;function Fe(e){return e?N(e):`One-time`}function Ie(e,t){if(!e)return`—`;let n=Date.parse(e);return Number.isFinite(n)?p(new Date(n).toISOString(),t):e}function Le(){let[e,t]=(0,O.useState)(null),[n,r]=(0,O.useState)(!1),[i,a]=(0,O.useState)(void 0),[o,s]=(0,O.useState)(null),[c,l]=(0,O.useState)(void 0),[u,p]=(0,O.useState)(null),[m,h]=(0,O.useState)(null);(0,O.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem($)}catch{}if(!n){r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&a(e.businessName),e.sessionId!==void 0&&s(e.sessionId??null),h(e.role??null),l(e.userName===void 0?null:e.userName),p(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let g=(0,O.useCallback)(()=>{try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},[]),[_,v]=(0,O.useState)(!1),y=(0,O.useCallback)(async()=>{v(!0);try{let e=await b();if(e){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`}return e}finally{v(!1)}},[]);return n?e?(0,G.jsx)(f,{cacheKey:e,surface:`routines`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=routines`);try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},children:(0,G.jsx)(S,{cacheKey:e,businessName:i,sessionId:o,onLogout:g,onDisconnect:y,disconnecting:_,userName:c,userAvatar:u,role:m,children:(0,G.jsx)(Re,{cacheKey:e})})}):(0,G.jsx)(`div`,{className:`cal-page`,children:(0,G.jsxs)(`div`,{className:`cal-empty`,children:[(0,G.jsx)(`p`,{children:`You are not signed in.`}),(0,G.jsxs)(`p`,{children:[`Open the `,(0,G.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,G.jsx)(d,{surface:`gate`})}function Re({cacheKey:e}){let{zone:t}=o(),{adminFetch:n,cacheKey:r,sessionRefetchNonce:i}=_({initialCacheKey:e,surface:`routines`}),[s,c]=(0,O.useState)([]),[u,f]=(0,O.useState)(null),[p,m]=(0,O.useState)(!1),[h,g]=(0,O.useState)(!1),[b,S]=(0,O.useState)(null),[T,D]=(0,O.useState)(null),[k,A]=(0,O.useState)(null),[j,M]=(0,O.useState)(!1),N=(0,O.useCallback)(()=>{let e=!1;return m(!0),S(null),n(`/api/admin/routines`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();c(Array.isArray(n.routines)?n.routines:[]),f(typeof n.workflowRuns24h==`number`?n.workflowRuns24h:null)}).catch(t=>{e||(S(t instanceof Error?t.message:`Failed to load`),c([]),f(null))}).finally(()=>{e||(m(!1),g(!0))}),()=>{e=!0}},[n]);(0,O.useEffect)(()=>N(),[N,i]);let P=(0,O.useCallback)(e=>{c(t=>t.map(t=>t.eventId===e.eventId?e:t)),D(e)},[]),F=(0,O.useCallback)(e=>{c(t=>t.filter(t=>t.eventId!==e)),D(null)},[]),[I,L]=(0,O.useState)(!1),[R,z]=(0,O.useState)(null),B=s.filter(e=>e.eventStatus===`scheduled`).length,V=s.filter(e=>e.suspendedInBulk).length,H=(0,O.useCallback)(async e=>{L(!0),z(null);try{let t=await n(`/api/admin/routines/${e}`,{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`HTTP ${t.status}`)}let r=await t.json(),i=r.refused?.length??0;z(e===`suspend-all`?`Suspended ${r.suspended??0}. Nothing runs on its own until you resume it.`:`Resumed ${r.restored??0}${i>0?`. ${i} could not be resumed and stayed suspended`:``}. Routines you suspended one at a time are still suspended.`),N()}catch(e){z(e instanceof Error?e.message:`Failed`)}finally{L(!1)}},[n,N]);return h?j?(0,G.jsx)(Me,{adminFetch:n,onBack:()=>M(!1)}):k?(0,G.jsx)(Oe,{routine:k,adminFetch:n,cacheKey:r,from:`modal`,onBack:()=>A(null)}):(0,G.jsxs)(`div`,{className:`cal-page`,children:[(0,G.jsx)(`header`,{className:`cal-header`,children:(0,G.jsxs)(`div`,{className:`cal-nav`,children:[(0,G.jsxs)(`span`,{className:`cal-range-label`,children:[(0,G.jsx)(x,{size:16}),` Routines`]}),(0,G.jsxs)(`div`,{className:`routine-bulk-actions`,children:[(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,"data-testid":`routines-refresh`,onClick:N,disabled:p,title:`Refresh routines`,"aria-label":`Refresh routines`,children:[p?(0,G.jsx)(l,{size:14,className:`spin`}):(0,G.jsx)(a,{size:14}),` Refresh`]}),(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,"data-testid":`routines-history`,onClick:()=>M(!0),title:`All routine runs`,"aria-label":`All routine runs`,children:[(0,G.jsx)(E,{size:14}),` History`]}),(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>H(`suspend-all`),disabled:I||B===0,children:[(0,G.jsx)(te,{size:14}),` Suspend all (`,B,`)`]}),(0,G.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>H(`resume-all`),disabled:I||V===0,children:[(0,G.jsx)(ne,{size:14}),` Resume all (`,V,`)`]})]})]})}),(0,G.jsxs)(`div`,{className:`cal-body`,children:[!b&&(()=>{let e=fe(s);return(0,G.jsxs)(`div`,{className:`routine-rail-strip`,"data-testid":`routine-rail-strip`,children:[`Live recurring: `,e.live,` · `,e.model,` model · `,e.tool,` tool · `,e.none,` no dispatch`,` · `,`Workflow runs (24h): `,u===null?`—`:u]})})(),R&&(0,G.jsx)(`div`,{className:`cal-modal-confirm-text`,children:R}),b&&(0,G.jsxs)(`div`,{className:`cal-error`,children:[`Could not load routines: `,b]}),!b&&!p&&s.length===0&&(0,G.jsx)(`div`,{className:`cal-empty`,children:(0,G.jsx)(`p`,{children:`No routines yet.`})}),(0,G.jsx)(`div`,{className:`routine-list`,children:s.map(e=>{let n=e.eventStatus===`scheduled`&&!Ne(e)?Pe(e):null;return(0,G.jsxs)(`div`,{role:`button`,tabIndex:0,className:`admin-card admin-card--padded routine-card`,"data-testid":`routine-card-${e.eventId}`,onClick:()=>D(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),D(e))},children:[(0,G.jsx)(`span`,{className:`admin-card-title routine-card-title`,title:e.name??`Untitled routine`,children:e.name??`Untitled routine`}),(0,G.jsxs)(`span`,{className:`routine-card-sched`,children:[(0,G.jsx)(C,{size:13}),` `,Fe(e.recurrence)]}),e.description&&(0,G.jsx)(`span`,{className:`routine-card-desc`,children:e.description}),n===null?(0,G.jsx)(`span`,{className:`routine-card-target`,children:e.agentChannel?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(y,{channel:e.agentChannel,size:13}),` `,v[e.agentChannel]??e.agentChannel,` to `,e.agentDestination??`—`]}):e.actionPlugin?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ee,{size:13}),` `,e.actionPlugin,`.`,e.actionTool]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(C,{size:13}),` Scheduled trigger`]})}):(0,G.jsxs)(`span`,{className:`routine-card-target routine-card-target--gap`,children:[(0,G.jsx)(w,{size:13}),` `,we(n)]}),e.dispatchFailing===!0&&n===null&&(0,G.jsxs)(`span`,{className:`routine-card-target routine-card-target--gap`,"data-testid":`routine-dispatch-${e.eventId}`,children:[(0,G.jsx)(w,{size:13}),` Last dispatch failed: `,e.lastDispatchResult]}),(()=>{let t=[],n=ue[le(e)];n&&t.push(n),e.runs24h>0&&t.push(`24h: ${e.runs24h} ${e.runs24h===1?`fire`:`fires`}, ${e.gated24h} skipped`);let r=e.gateNeverGates===!0&&e.dispatchFailing!==!0;return r&&t.push(`this gate is decoration`),t.length===0?null:(0,G.jsx)(`span`,{className:r?`routine-card-gate routine-card-target--gap`:`routine-card-gate`,"data-testid":`routine-gate-${e.eventId}`,children:r?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(w,{size:13}),` `,t.join(` · `)]}):t.join(` · `)})})(),(0,G.jsxs)(`span`,{className:`routine-card-meta`,children:[(0,G.jsx)(ce,{eventStatus:e.eventStatus}),`Next: `,Ie(e.nextRun,t),` · `,e.eventStatus??`unknown`]})]},e.eventId)})})]}),T&&(0,G.jsx)(Z,{routine:T,adminFetch:n,onClose:()=>D(null),onSaved:P,onDeleted:F,onViewRuns:e=>{D(null),A(e)}})]}):(0,G.jsx)(d,{surface:`gate`})}(0,D.createRoot)(document.getElementById(`root`)).render((0,G.jsx)(Le,{}));
|
|
Binary file
|
|
Binary file
|