@spencerboucher/switchyard 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/switchyard.mjs +7073 -5396
- package/dist/terminal/holder.js +30 -4
- package/package.json +1 -1
- package/web-dist/assets/AutomationView-BsTwLnMp.js +2 -0
- package/web-dist/assets/{AutomationView-D7Syv1En.js.map → AutomationView-BsTwLnMp.js.map} +1 -1
- package/web-dist/assets/Card-CAFxHoHd.js +2 -0
- package/web-dist/assets/Card-CAFxHoHd.js.map +1 -0
- package/web-dist/assets/Checkbox-rDvnQnxc.js +2 -0
- package/web-dist/assets/Checkbox-rDvnQnxc.js.map +1 -0
- package/web-dist/assets/Copy-D8xhl7eJ.js +2 -0
- package/web-dist/assets/{Copy-B6XSAIUd.js.map → Copy-D8xhl7eJ.js.map} +1 -1
- package/web-dist/assets/DangerZone-og55TRug.js +2 -0
- package/web-dist/assets/DangerZone-og55TRug.js.map +1 -0
- package/web-dist/assets/{Field-D-Ty7fKT.js → Field-Dbg_8KTt.js} +2 -2
- package/web-dist/assets/{Field-D-Ty7fKT.js.map → Field-Dbg_8KTt.js.map} +1 -1
- package/web-dist/assets/{InteractionCard-DF1EcSpm.js → InteractionCard-Yu5wgLC3.js} +4 -4
- package/web-dist/assets/{InteractionCard-DF1EcSpm.js.map → InteractionCard-Yu5wgLC3.js.map} +1 -1
- package/web-dist/assets/Menu-euseM8yR.js +2 -0
- package/web-dist/assets/Menu-euseM8yR.js.map +1 -0
- package/web-dist/assets/Overlay-BNPvMjLX.js +2 -0
- package/web-dist/assets/{Overlay-DUQwh6_b.js.map → Overlay-BNPvMjLX.js.map} +1 -1
- package/web-dist/assets/Priority-Ca1B2yFr.js +2 -0
- package/web-dist/assets/{Priority-CHmzfoHg.js.map → Priority-Ca1B2yFr.js.map} +1 -1
- package/web-dist/assets/{SegmentedControl-C_hEVQMB.js → SegmentedControl-D2d-NEr-.js} +2 -2
- package/web-dist/assets/{SegmentedControl-C_hEVQMB.js.map → SegmentedControl-D2d-NEr-.js.map} +1 -1
- package/web-dist/assets/{Select-Cfql4Nwu.js → Select-C9L1HKMm.js} +2 -2
- package/web-dist/assets/{Select-Cfql4Nwu.js.map → Select-C9L1HKMm.js.map} +1 -1
- package/web-dist/assets/StatusChip-BYuVxYS7.js +2 -0
- package/web-dist/assets/StatusChip-BYuVxYS7.js.map +1 -0
- package/web-dist/assets/{Switch-DBfzmqkm.js → Switch-DAcUcSbH.js} +2 -2
- package/web-dist/assets/{Switch-DBfzmqkm.js.map → Switch-DAcUcSbH.js.map} +1 -1
- package/web-dist/assets/{Tabs-BNuL3_Et.js → Tabs-xtagjtA5.js} +2 -2
- package/web-dist/assets/{Tabs-BNuL3_Et.js.map → Tabs-xtagjtA5.js.map} +1 -1
- package/web-dist/assets/{TextArea-CKybrQyn.js → TextArea-CKGHwURx.js} +2 -2
- package/web-dist/assets/{TextArea-CKybrQyn.js.map → TextArea-CKGHwURx.js.map} +1 -1
- package/web-dist/assets/{TextLink-OzzyP2-p.js → TextLink-Bub7sMxr.js} +2 -2
- package/web-dist/assets/{TextLink-OzzyP2-p.js.map → TextLink-Bub7sMxr.js.map} +1 -1
- package/web-dist/assets/attention-CI4dHY81.js +2 -0
- package/web-dist/assets/{attention-V86Gye3I.js.map → attention-CI4dHY81.js.map} +1 -1
- package/web-dist/assets/auth-308hUVgi.js +2 -0
- package/web-dist/assets/auth-308hUVgi.js.map +1 -0
- package/web-dist/assets/automations-BzpsJoa3.js +2 -0
- package/web-dist/assets/{automations-Cw5Gacgm.js.map → automations-BzpsJoa3.js.map} +1 -1
- package/web-dist/assets/bell-DSwa2PAb.js +2 -0
- package/web-dist/assets/bell-DSwa2PAb.js.map +1 -0
- package/web-dist/assets/board-CeJxBVHC.js +10 -0
- package/web-dist/assets/board-CeJxBVHC.js.map +1 -0
- package/web-dist/assets/code-DkNQvMI9.js +12 -0
- package/web-dist/assets/code-DkNQvMI9.js.map +1 -0
- package/web-dist/assets/describe-CVXeUClF.js +5 -0
- package/web-dist/assets/{describe-D6KLGKWa.js.map → describe-CVXeUClF.js.map} +1 -1
- package/web-dist/assets/enroll-jnKygG4L.js +2 -0
- package/web-dist/assets/{enroll-DwT7AcuS.js.map → enroll-jnKygG4L.js.map} +1 -1
- package/web-dist/assets/index-BHGZTS2e.js +16 -0
- package/web-dist/assets/index-BHGZTS2e.js.map +1 -0
- package/web-dist/assets/index-D2ml031z.css +2 -0
- package/web-dist/assets/{more-DQR5uu1c.js → more-DvKHMdBk.js} +2 -2
- package/web-dist/assets/{more-DQR5uu1c.js.map → more-DvKHMdBk.js.map} +1 -1
- package/web-dist/assets/queue-B2Vl0uSh.js +2 -0
- package/web-dist/assets/{queue-DUg1rS8t.js.map → queue-B2Vl0uSh.js.map} +1 -1
- package/web-dist/assets/repo-BDS8RBxq.js +2 -0
- package/web-dist/assets/repo-BDS8RBxq.js.map +1 -0
- package/web-dist/assets/settings-CLt7x9u8.js +8 -0
- package/web-dist/assets/settings-CLt7x9u8.js.map +1 -0
- package/web-dist/assets/states-C773NlHo.js +56 -0
- package/web-dist/assets/states-C773NlHo.js.map +1 -0
- package/web-dist/assets/{terminal-login-S5CAd5xA.js → terminal-login-BK5UjUir.js} +2 -2
- package/web-dist/assets/{terminal-login-S5CAd5xA.js.map → terminal-login-BK5UjUir.js.map} +1 -1
- package/web-dist/assets/useBreakpoint-BphHBrzF.js +2 -0
- package/web-dist/assets/useBreakpoint-BphHBrzF.js.map +1 -0
- package/web-dist/assets/useNow-Cm-tdyod.js +2 -0
- package/web-dist/assets/{useNow-Dj7oEiwn.js.map → useNow-Cm-tdyod.js.map} +1 -1
- package/web-dist/assets/{useResource-CDGSq2At.js → useResource-BBqCoY2q.js} +2 -2
- package/web-dist/assets/{useResource-CDGSq2At.js.map → useResource-BBqCoY2q.js.map} +1 -1
- package/web-dist/index.html +7 -3
- package/web-dist/sw.js +1 -1
- package/web-dist/sw.js.map +1 -1
- package/web-dist/assets/AutomationView-D7Syv1En.js +0 -2
- package/web-dist/assets/Checkbox-D6tRfEeI.js +0 -2
- package/web-dist/assets/Checkbox-D6tRfEeI.js.map +0 -1
- package/web-dist/assets/Copy-B6XSAIUd.js +0 -2
- package/web-dist/assets/DangerZone-DfYlxDC1.js +0 -2
- package/web-dist/assets/DangerZone-DfYlxDC1.js.map +0 -1
- package/web-dist/assets/Menu-BfOszNC4.js +0 -2
- package/web-dist/assets/Menu-BfOszNC4.js.map +0 -1
- package/web-dist/assets/Overlay-DUQwh6_b.js +0 -2
- package/web-dist/assets/Priority-CHmzfoHg.js +0 -2
- package/web-dist/assets/attention-V86Gye3I.js +0 -2
- package/web-dist/assets/automations-Cw5Gacgm.js +0 -2
- package/web-dist/assets/board-B8X7TYYR.js +0 -10
- package/web-dist/assets/board-B8X7TYYR.js.map +0 -1
- package/web-dist/assets/code-BKroYJmR.js +0 -12
- package/web-dist/assets/code-BKroYJmR.js.map +0 -1
- package/web-dist/assets/describe-D6KLGKWa.js +0 -5
- package/web-dist/assets/enroll-DwT7AcuS.js +0 -2
- package/web-dist/assets/index-B3F7WcYf.css +0 -2
- package/web-dist/assets/index-hxvDvCS7.js +0 -12
- package/web-dist/assets/index-hxvDvCS7.js.map +0 -1
- package/web-dist/assets/queue-DUg1rS8t.js +0 -2
- package/web-dist/assets/repo-XzzzEI0d.js +0 -2
- package/web-dist/assets/repo-XzzzEI0d.js.map +0 -1
- package/web-dist/assets/search-C6cn5WOo.js +0 -2
- package/web-dist/assets/search-C6cn5WOo.js.map +0 -1
- package/web-dist/assets/settings-DyUu0tJM.js +0 -8
- package/web-dist/assets/settings-DyUu0tJM.js.map +0 -1
- package/web-dist/assets/states-ZhrxQa3K.js +0 -56
- package/web-dist/assets/states-ZhrxQa3K.js.map +0 -1
- package/web-dist/assets/useNow-Dj7oEiwn.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Copy-
|
|
1
|
+
{"version":3,"file":"Copy-D8xhl7eJ.js","names":["__iconData","useState","useRef","__toESM","require_react","require_jsx_runtime","Button","toast","__iconData$1","Check","createLucideIcon","__iconData","Copy","import_react","import_jsx_runtime","copyText","text","success","CopyButton","copied","setCopied","timer","toastMessage","label","CopyBlock","copyLabel"],"sources":["../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/check.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/copy.mjs","../../src/components/ui/Copy.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"check\",\n size: 24,\n node: [[\"path\", { d: \"M20 6 9 17l-5-5\", key: \"1gmf2c\" }]]\n};\n__iconData.node;\nconst Check = createLucideIcon(__iconData);\n\nexport { __iconData, Check as default };\n//# sourceMappingURL=check.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"copy\",\n size: 24,\n node: [\n [\"rect\", { width: \"14\", height: \"14\", x: \"8\", y: \"8\", rx: \"2\", ry: \"2\", key: \"17jyea\" }],\n [\"path\", { d: \"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\", key: \"zix9uf\" }]\n ]\n};\n__iconData.node;\nconst Copy = createLucideIcon(__iconData);\n\nexport { __iconData, Copy as default };\n//# sourceMappingURL=copy.mjs.map\n","import { Check, Copy } from \"lucide-react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { Button } from \"./Button\";\nimport { toast } from \"./Toast\";\n\n/** Copy text to the clipboard with a toast; pass `false` to stay silent on success. */\nexport async function copyText(\n text: string,\n success: string | false = \"Copied to clipboard\",\n): Promise<boolean> {\n try {\n await navigator.clipboard.writeText(text);\n if (success) toast.success(success);\n return true;\n } catch {\n toast.error(\"Could not copy. Select the text and copy it manually.\");\n return false;\n }\n}\n\nexport function CopyButton({\n text,\n label = \"Copy\",\n toastMessage,\n size = \"sm\",\n}: {\n text: string;\n label?: string;\n toastMessage?: string;\n size?: \"sm\" | \"md\";\n}) {\n const [copied, setCopied] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n useEffect(() => () => void (timer.current && clearTimeout(timer.current)), []);\n return (\n <Button\n size={size}\n icon={copied ? <Check className=\"size-4\" /> : <Copy className=\"size-4\" />}\n onClick={async () => {\n if (await copyText(text, toastMessage)) {\n setCopied(true);\n if (timer.current) clearTimeout(timer.current);\n timer.current = setTimeout(() => setCopied(false), 2000);\n }\n }}\n >\n {copied ? \"Copied\" : label}\n </Button>\n );\n}\n\n/** A monospace command or URL with a copy button; wraps instead of overflowing. */\nexport function CopyBlock({\n text,\n label,\n copyLabel = \"Copy\",\n}: {\n text: string;\n /** Accessible name of the code block. */\n label: string;\n copyLabel?: string;\n}) {\n return (\n <figure className=\"m-0 flex min-w-0 flex-col gap-2 sm:flex-row sm:items-start\">\n <figcaption className=\"sr-only\">{label}</figcaption>\n <pre className=\"min-w-0 flex-1 whitespace-pre-wrap break-all rounded-md border border-border bg-surface-2 px-3 py-2 font-mono text-sm\">\n {text}\n </pre>\n <CopyButton text={text} label={copyLabel} />\n </figure>\n );\n}\n"],"ignoreList":[0,1],"mappings":"A,uJASA,IAAMA,EAAa,CACjB,KAAM,QACN,KAAM,GACN,KAAM,CAAC,CAAC,OAAQ,CAAE,EAAG,kBAAmB,IAAK,QAAS,CAAC,CAAC,CAC1D,EACAA,EAAW,KACX,IAAMS,EAAQC,EAAiBV,CAAU,ECNnCW,EAAa,CACjB,KAAM,OACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,MAAO,KAAM,OAAQ,KAAM,EAAG,IAAK,EAAG,IAAK,GAAI,IAAK,GAAI,IAAK,IAAK,QAAS,CAAC,EACvF,CAAC,OAAQ,CAAE,EAAG,0DAA2D,IAAK,QAAS,CAAC,CAC1F,CACF,EACAA,EAAW,KACX,IAAMC,EAAOF,EAAiBC,CAAU,E,iBCZxC,eAAsBI,EACpB,EACA,EAA0B,sBACR,CAClB,GAAI,CAGF,OAFA,MAAM,UAAU,UAAU,UAAUC,CAAI,EACpCC,GAASV,EAAM,QAAQU,CAAO,EAC3B,EACT,MAAQ,CAEN,OADAV,EAAM,MAAM,uDAAuD,EAC5D,EACT,CACF,CAEA,SAAgBW,EAAW,CACzB,OACA,QAAQ,OACR,eACA,OAAO,MAMN,CACD,GAAM,CAACC,EAAQC,IAAA,EAAanB,EAAAA,SAAAA,CAAS,EAAK,EACpCoB,GAAA,EAAQnB,EAAAA,OAAAA,CAA6C,IAAI,EAE/D,OADA,EAAAW,EAAA,UAAA,SAAsB,KAAMQ,EAAM,SAAW,aAAaA,EAAM,OAAO,GAAI,CAAC,CAAC,GAE3E,EAAAP,EAAA,IAAA,CAACR,EAAD,CACQ,OACN,KAAMa,GAAS,EAAAL,EAAA,IAAA,CAACL,EAAD,CAAO,UAAU,QAAU,CAAA,GAAI,EAAAK,EAAA,IAAA,CAACF,EAAD,CAAM,UAAU,QAAU,CAAA,EACxE,QAAS,SAAY,CACf,MAAMG,EAASC,EAAMM,CAAY,IACnCF,EAAU,EAAI,EACVC,EAAM,SAAS,aAAaA,EAAM,OAAO,EAC7C,EAAM,QAAU,eAAiBD,EAAU,EAAK,EAAG,GAAI,EAE3D,EAEC,SAAAD,EAAS,SAAWI,CACf,CAAA,CAEZ,CAGA,SAAgBC,EAAU,CACxB,OACA,QACA,YAAY,QAMX,CACD,OACE,EAAAV,EAAA,KAAA,CAAC,SAAD,CAAQ,UAAU,6DAAlB,SAAA,EACE,EAAAA,EAAA,IAAA,CAAC,aAAD,CAAY,UAAU,UAAW,SAAAS,CAAkB,CAAA,GACnD,EAAAT,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,wHACZ,SAAAE,CACE,CAAA,GACL,EAAAF,EAAA,IAAA,CAACI,EAAD,CAAkB,OAAM,MAAOO,CAAY,CAAA,CACrC,C,EAEZ,C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{_ as e,m as t,n,t as r}from"./jsx-runtime-D13aM9HY.js";var i={name:`save`,size:24,node:[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]};i.node;var a=n(i),o=e(t(),1),s=r();function c({description:e,children:t}){let n=(0,o.useId)();return(0,s.jsxs)(`section`,{"aria-labelledby":n,"data-testid":`danger-zone`,className:`min-w-0 rounded-lg border border-danger/50 bg-surface p-4`,children:[(0,s.jsx)(`h2`,{id:n,className:`text-base font-semibold text-danger`,children:`Danger zone`}),e&&(0,s.jsx)(`p`,{className:`text-sm text-muted`,children:e}),(0,s.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:t})]})}export{a as n,c as t};
|
|
2
|
+
//# sourceMappingURL=DangerZone-og55TRug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DangerZone-og55TRug.js","names":["useId","__toESM","require_react","require_jsx_runtime","__iconData","Save","createLucideIcon","import_react","import_jsx_runtime","DangerZone","id","description"],"sources":["../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/save.mjs","../../src/components/ui/DangerZone.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"save\",\n size: 24,\n node: [\n [\n \"path\",\n {\n d: \"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z\",\n key: \"1c8476\"\n }\n ],\n [\"path\", { d: \"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7\", key: \"1ydtos\" }],\n [\"path\", { d: \"M7 3v4a1 1 0 0 0 1 1h7\", key: \"t51u73\" }]\n ]\n};\n__iconData.node;\nconst Save = createLucideIcon(__iconData);\n\nexport { __iconData, Save as default };\n//# sourceMappingURL=save.mjs.map\n","import { type ReactNode, useId } from \"react\";\n\n/** Destructive actions, set apart at the bottom of a detail page. */\nexport function DangerZone({\n description,\n children,\n}: {\n description?: ReactNode;\n children: ReactNode;\n}) {\n const id = useId();\n return (\n <section\n aria-labelledby={id}\n data-testid=\"danger-zone\"\n className=\"min-w-0 rounded-lg border border-danger/50 bg-surface p-4\"\n >\n <h2 id={id} className=\"text-base font-semibold text-danger\">\n Danger zone\n </h2>\n {description && <p className=\"text-sm text-muted\">{description}</p>}\n <div className=\"mt-3 flex flex-wrap items-center gap-2\">{children}</div>\n </section>\n );\n}\n"],"ignoreList":[0],"mappings":"A,8DASA,IAAMI,EAAa,CACjB,KAAM,OACN,KAAM,GACN,KAAM,CACJ,CACE,OACA,CACE,EAAG,qGACH,IAAK,QACP,CACF,EACA,CAAC,OAAQ,CAAE,EAAG,4CAA6C,IAAK,QAAS,CAAC,EAC1E,CAAC,OAAQ,CAAE,EAAG,yBAA0B,IAAK,QAAS,CAAC,CACzD,CACF,EACAA,EAAW,KACX,IAAMC,EAAOC,EAAiBF,CAAU,E,iBCtBxC,SAAgBK,EAAW,CACzB,cACA,YAIC,CACD,IAAMC,GAAA,EAAKV,EAAAA,MAAAA,CAAM,EACjB,OACE,EAAAQ,EAAA,KAAA,CAAC,UAAD,CACE,kBAAiBE,EACjB,cAAY,cACZ,UAAU,4DAHZ,SAAA,EAKE,EAAAF,EAAA,IAAA,CAAC,KAAD,CAAQ,KAAI,UAAU,sCAAsC,SAAA,aAExD,CAAA,EACHG,IAAe,EAAAH,EAAA,IAAA,CAAC,IAAD,CAAG,UAAU,qBAAsB,SAAAG,CAAe,CAAA,GAClE,EAAAH,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,yCAA0C,UAAc,CAAA,CAChE,C,EAEb,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as e,m as t,n,t as r}from"./jsx-runtime-D13aM9HY.js";import{_ as i,v as a}from"./states-
|
|
2
|
-
//# sourceMappingURL=Field-
|
|
1
|
+
import{_ as e,m as t,n,t as r}from"./jsx-runtime-D13aM9HY.js";import{_ as i,v as a}from"./states-C773NlHo.js";var o={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};o.node;var s=n(o),c={name:`trash`,size:24,node:[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]],aliases:[`trash-2`]};c.node;var l=n(c),u=e(t(),1),d=r();function f(e,t){let n=[t.hint&&`${e}-hint`,t.error&&`${e}-error`].filter(Boolean);return{"aria-describedby":n.length?n.join(` `):void 0,"aria-invalid":t.error?!0:void 0}}function p({id:e,children:t}){return(0,d.jsxs)(`p`,{id:e,className:`flex items-start gap-1 text-xs text-danger`,"data-field-error":!0,children:[(0,d.jsx)(a,{"aria-hidden":!0,className:`mt-0.5 size-3.5 shrink-0`}),(0,d.jsx)(`span`,{className:`min-w-0 whitespace-pre-line break-words`,children:t})]})}function m({label:e,hint:t,error:n,optional:r,id:a,className:o,children:s}){let c=(0,u.useId)(),l=a??c;return(0,d.jsxs)(`div`,{className:i(`flex w-full min-w-0 max-w-2xl flex-col gap-1`,o),children:[(0,d.jsxs)(`label`,{htmlFor:l,className:`text-sm font-medium`,children:[e,r&&(0,d.jsx)(`span`,{className:`font-normal text-muted`,children:` (optional)`})]}),typeof s==`function`?s({id:l,...f(l,{hint:!!t,error:n})}):s,t&&(0,d.jsx)(`p`,{id:`${l}-hint`,className:`text-xs text-muted`,children:t}),n&&(0,d.jsx)(p,{id:`${l}-error`,children:n})]})}export{s as a,l as i,p as n,f as r,m as t};
|
|
2
|
+
//# sourceMappingURL=Field-Dbg_8KTt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field-
|
|
1
|
+
{"version":3,"file":"Field-Dbg_8KTt.js","names":["__iconData","useId","__toESM","require_react","require_jsx_runtime","cn","TriangleAlert","__iconData$1","ArrowLeft","createLucideIcon","__iconData","Trash","import_react","import_jsx_runtime","fieldControlProps","ids","opts","id","FieldError","Field","generated","controlId","className","label","optional","children","hint","error"],"sources":["../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/arrow-left.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/trash.mjs","../../src/components/ui/Field.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"arrow-left\",\n size: 24,\n node: [\n [\"path\", { d: \"m12 19-7-7 7-7\", key: \"1l729n\" }],\n [\"path\", { d: \"M19 12H5\", key: \"x3x0zl\" }]\n ]\n};\n__iconData.node;\nconst ArrowLeft = createLucideIcon(__iconData);\n\nexport { __iconData, ArrowLeft as default };\n//# sourceMappingURL=arrow-left.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"trash\",\n size: 24,\n node: [\n [\"path\", { d: \"M10 11v6\", key: \"nco0om\" }],\n [\"path\", { d: \"M14 11v6\", key: \"outv1u\" }],\n [\"path\", { d: \"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6\", key: \"miytrc\" }],\n [\"path\", { d: \"M3 6h18\", key: \"d0wm0j\" }],\n [\"path\", { d: \"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2\", key: \"e791ji\" }]\n ],\n aliases: [\"trash-2\"]\n};\n__iconData.node;\nconst Trash = createLucideIcon(__iconData);\n\nexport { __iconData, Trash as default };\n//# sourceMappingURL=trash.mjs.map\n","import { TriangleAlert } from \"lucide-react\";\nimport { type ReactElement, type ReactNode, useId } from \"react\";\nimport { cn } from \"../../lib/cn\";\n\n/** Props to spread on the control inside a Field. */\nexport interface FieldControlProps {\n id: string;\n \"aria-invalid\"?: true;\n \"aria-describedby\"?: string;\n}\n\nexport interface FieldProps {\n label: ReactNode;\n hint?: ReactNode;\n error?: string | null;\n /** Appends \" (optional)\" in muted text. */\n optional?: boolean;\n /** Control id; defaults to a generated one. */\n id?: string;\n className?: string;\n /** The control, or a render function that receives the props to spread on it. */\n children: ReactNode | ((p: FieldControlProps) => ReactElement);\n}\n\n/** aria-describedby / aria-invalid props for the control of a Field with this id. */\nexport function fieldControlProps(\n id: string,\n opts: { hint?: boolean; error?: string | null },\n): Omit<FieldControlProps, \"id\"> {\n const ids = [opts.hint && `${id}-hint`, opts.error && `${id}-error`].filter(Boolean);\n return {\n \"aria-describedby\": ids.length ? ids.join(\" \") : undefined,\n \"aria-invalid\": opts.error ? true : undefined,\n };\n}\n\n/** Inline field error with an icon (the icon keeps it from relying on colour). */\nexport function FieldError({ id, children }: { id?: string; children: ReactNode }) {\n return (\n <p id={id} className=\"flex items-start gap-1 text-xs text-danger\" data-field-error>\n <TriangleAlert aria-hidden className=\"mt-0.5 size-3.5 shrink-0\" />\n <span className=\"min-w-0 whitespace-pre-line break-words\">{children}</span>\n </p>\n );\n}\n\n/** Label, control, hint and error. Controls must use the `id` and described-by props. */\nexport function Field({ label, hint, error, optional, id, className, children }: FieldProps) {\n const generated = useId();\n const controlId = id ?? generated;\n return (\n <div className={cn(\"flex w-full min-w-0 max-w-2xl flex-col gap-1\", className)}>\n <label htmlFor={controlId} className=\"text-sm font-medium\">\n {label}\n {optional && <span className=\"font-normal text-muted\"> (optional)</span>}\n </label>\n {typeof children === \"function\"\n ? children({ id: controlId, ...fieldControlProps(controlId, { hint: !!hint, error }) })\n : children}\n {hint && (\n <p id={`${controlId}-hint`} className=\"text-xs text-muted\">\n {hint}\n </p>\n )}\n {error && <FieldError id={`${controlId}-error`}>{error}</FieldError>}\n </div>\n );\n}\n"],"ignoreList":[0,1],"mappings":"A,8GASA,IAAMA,EAAa,CACjB,KAAM,aACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,EAAG,iBAAkB,IAAK,QAAS,CAAC,EAC/C,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAS,CAAC,CAC3C,CACF,EACAA,EAAW,KACX,IAAMQ,EAAYC,EAAiBT,CAAU,ECTvCU,EAAa,CACjB,KAAM,QACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAS,CAAC,EACzC,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAS,CAAC,EACzC,CAAC,OAAQ,CAAE,EAAG,2CAA4C,IAAK,QAAS,CAAC,EACzE,CAAC,OAAQ,CAAE,EAAG,UAAW,IAAK,QAAS,CAAC,EACxC,CAAC,OAAQ,CAAE,EAAG,yCAA0C,IAAK,QAAS,CAAC,CACzE,EACA,QAAS,CAAC,SAAS,CACrB,EACAA,EAAW,KACX,IAAMC,EAAQF,EAAiBC,CAAU,E,iBCGzC,SAAgBI,EACd,EACA,EAC+B,CAC/B,IAAMC,EAAM,CAACC,EAAK,MAAQ,GAAGC,EAAG,OAAQD,EAAK,OAAS,GAAGC,EAAG,OAAO,CAAC,CAAC,OAAO,OAAO,EACnF,MAAO,CACL,mBAAoBF,EAAI,OAASA,EAAI,KAAK,GAAG,EAAI,IAAA,GACjD,eAAgBC,EAAK,MAAQ,GAAO,IAAA,EACtC,CACF,CAGA,SAAgBE,EAAW,CAAE,KAAI,YAAkD,CACjF,OACE,EAAAL,EAAA,KAAA,CAAC,IAAD,CAAO,KAAI,UAAU,6CAA6C,mBAAA,GAAlE,SAAA,EACE,EAAAA,EAAA,IAAA,CAACP,EAAD,CAAe,cAAA,GAAY,UAAU,0BAA4B,CAAA,GACjE,EAAAO,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,0CAA2C,UAAe,CAAA,CACzE,C,EAEP,CAGA,SAAgBM,EAAM,CAAE,QAAO,OAAM,QAAO,WAAU,KAAI,YAAW,YAAwB,CAC3F,IAAMC,GAAA,EAAYnB,EAAAA,MAAAA,CAAM,EAClBoB,EAAYJ,GAAMG,EACxB,OACE,EAAAP,EAAA,KAAA,CAAC,MAAD,CAAK,UAAWR,EAAG,+CAAgDiB,CAAS,EAA5E,SAAA,EACE,EAAAT,EAAA,KAAA,CAAC,QAAD,CAAO,QAASQ,EAAW,UAAU,sBAArC,SAAA,CACGE,EACAC,IAAY,EAAAX,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,yBAAyB,SAAA,aAAiB,CAAA,CAClE,C,GACN,OAAOY,GAAa,WACjBA,EAAS,CAAE,GAAIJ,EAAW,GAAGP,EAAkBO,EAAW,CAAE,KAAM,CAAC,CAACK,EAAM,OAAM,CAAC,CAAE,CAAC,EACpFD,EACHC,IACC,EAAAb,EAAA,IAAA,CAAC,IAAD,CAAG,GAAI,GAAGQ,EAAU,OAAQ,UAAU,qBACnC,SAAAK,CACA,CAAA,EAEJC,IAAS,EAAAd,EAAA,IAAA,CAACK,EAAD,CAAY,GAAI,GAAGG,EAAU,QAAU,SAAAM,CAAkB,CAAA,CAChE,C,EAET,C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{_ as e,m as t,n,t as r}from"./jsx-runtime-D13aM9HY.js";import{
|
|
1
|
+
import{_ as e,m as t,n,t as r}from"./jsx-runtime-D13aM9HY.js";import{m as i,o as a}from"./StatusChip-BYuVxYS7.js";import{_ as o,bt as s,d as c,ft as l,h as u,n as d,p as f,vt as p,yt as m,z as h}from"./states-C773NlHo.js";import{t as g}from"./arrow-up-Dj-VTKx4.js";import{i as _}from"./Copy-D8xhl7eJ.js";import{t as v}from"./chevron-right-evVLS6hq.js";import{l as y,t as b,u as x}from"./useBreakpoint-BphHBrzF.js";import{i as S,o as C}from"./Overlay-BNPvMjLX.js";import{n as w,r as T}from"./TextArea-CKGHwURx.js";import{t as E}from"./TextLink-Bub7sMxr.js";import{a as D,i as O,n as k,r as A,t as j}from"./Tabs-xtagjtA5.js";var M={name:`file-code`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]};M.node;var N=n(M),P=e(t(),1),F=(0,P.createContext)({}),I=()=>(0,P.useContext)(F),L=r();function R({node:e}){let{onRespond:t,busy:n,disabled:r}=I();return(0,L.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,L.jsx)(A,{text:e.message}),!r&&(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,L.jsx)(c,{variant:e.destructive?`danger`:`primary`,busy:n,onClick:()=>t?.({kind:`confirm`,confirmed:!0}),children:e.confirmLabel||`Confirm`}),(0,L.jsx)(c,{disabled:n,onClick:()=>t?.({kind:`confirm`,confirmed:!1}),children:e.cancelLabel||`Cancel`})]})]})}function z(e){let t=e.trim().split(` `)[0];return t===`/dev/null`?null:t.replace(/^[ab]\//,``)}var B=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;function V(e){let t=[],n=null,r=0,i=0,a=0,o=0,s=!1,c=()=>{a<=0&&o<=0&&(s=!1)},l=(e=``)=>{let n={path:e,oldPath:null,newPath:null,status:`modified`,additions:0,deletions:0,lines:[]};return t.push(n),s=!1,n},u=e.replace(/\r\n/g,`
|
|
2
2
|
`).split(`
|
|
3
|
-
`);u[u.length-1]===``&&u.pop();for(let e of u){if(e.startsWith(`diff --git `)){let t=/^diff --git a\/(.+?) b\/(.+)$/.exec(e);n=l(t?.[2]??``),t&&(n.oldPath=t[1],n.newPath=t[2]);continue}if(!s&&e.startsWith(`--- `)){(!n||n.lines.some(e=>e.kind!==`meta`))&&(n=l()),n.oldPath=z(e.slice(4)),n.oldPath===null&&(n.status=`added`);continue}if(!s&&e.startsWith(`+++ `)&&n){n.newPath=z(e.slice(4)),n.newPath===null&&(n.status=`deleted`),n.path=n.newPath??n.oldPath??n.path;continue}let t=B.exec(e);t?(n||=l(),r=Number(t[1]),i=Number(t[3]),a=t[2]===void 0?1:Number(t[2]),o=t[4]===void 0?1:Number(t[4]),s=a>0||o>0,n.lines.push({kind:`hunk`,text:e,oldLine:null,newLine:null})):(n||=l(),s&&e.startsWith(`+`)?(n.lines.push({kind:`add`,text:e.slice(1),oldLine:null,newLine:i++}),n.additions++,o--,c()):s&&e.startsWith(`-`)?(n.lines.push({kind:`del`,text:e.slice(1),oldLine:r++,newLine:null}),n.deletions++,a--,c()):s&&(e.startsWith(` `)||e===``)?(n.lines.push({kind:`context`,text:e.slice(1),oldLine:r++,newLine:i++}),a--,o--,c()):(e.startsWith(`\\`)||(s=!1,e.startsWith(`new file mode`)?n.status=`added`:e.startsWith(`deleted file mode`)?n.status=`deleted`:e.startsWith(`rename from `)?(n.status=`renamed`,n.oldPath=e.slice(12)):e.startsWith(`rename to `)?(n.status=`renamed`,n.newPath=e.slice(10),n.path=n.newPath):e.startsWith(`Binary files`)&&(n.status=`binary`)),n.lines.push({kind:`meta`,text:e,oldLine:null,newLine:null})))}return t}var ee={add:`+`,del:`-`,context:` `,hunk:``,meta:``},te={add:`bg-diff-add`,del:`bg-diff-del`,hunk:`bg-diff-hunk`,context:`bg-surface`,meta:`bg-surface`};function H({patch:e,files:t,showFileHeaders:n=!0,onLineClick:r,isLineMarked:a,className:o}){let s=(0,P.useMemo)(()=>t??V(e??``),[t,e]);return s.length===0?(0,L.jsx)(`p`,{className:`text-sm text-muted`,children:`No changes.`}):(0,L.jsx)(`div`,{className:i(`flex min-w-0 flex-col gap-3`,o),children:s.map((e,t)=>(0,L.jsxs)(`section`,{className:`min-w-0 overflow-hidden rounded-md border border-border`,"aria-label":`Diff of ${e.path||`file`}`,children:[n&&(0,L.jsxs)(`header`,{className:`flex min-w-0 items-center gap-2 border-b border-border bg-surface-2 px-3 py-1.5 text-sm`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,title:e.path,children:e.status===`renamed`&&e.oldPath?`${e.oldPath} → ${e.path}`:e.path}),(0,L.jsxs)(`span`,{className:`shrink-0 font-mono text-xs`,children:[(0,L.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions,(0,L.jsx)(`span`,{className:`sr-only`,children:` added`})]}),` `,(0,L.jsxs)(`span`,{className:`text-danger`,children:[`-`,e.deletions,(0,L.jsx)(`span`,{className:`sr-only`,children:` deleted`})]})]})]}),e.status===`binary`?(0,L.jsx)(`p`,{className:`px-3 py-2 text-sm text-muted`,children:`Binary file not shown.`}):(0,L.jsx)(`div`,{className:`max-w-full overflow-x-auto overscroll-x-contain`,children:(0,L.jsx)(`table`,{className:`w-full border-collapse font-mono text-xs leading-5`,children:(0,L.jsx)(`tbody`,{children:e.lines.map((t,n)=>{let o={file:e.path,line:t},s=!!r&&(t.kind===`add`||t.kind===`del`||t.kind===`context`),c=a?.(o)??!1;return(0,L.jsxs)(`tr`,{className:i(t.kind===`add`&&`bg-diff-add`,t.kind===`del`&&`bg-diff-del`,t.kind===`hunk`&&`bg-diff-hunk text-muted`,t.kind===`meta`&&`text-muted`,c&&`outline outline-1 -outline-offset-1 outline-warning`),children:[(0,L.jsx)(`td`,{className:i(`sticky left-0 z-[1] w-[6.25rem] min-w-[6.25rem] select-none whitespace-nowrap p-0`,te[t.kind]),children:(0,L.jsxs)(`span`,{className:`flex`,children:[(0,L.jsx)(`span`,{className:`w-10 shrink-0 border-r border-border px-1.5 text-right text-subtle tabular-nums`,children:t.oldLine??``}),(0,L.jsx)(`span`,{className:`w-10 shrink-0 border-r border-border px-1.5 text-right text-subtle tabular-nums`,children:t.newLine??``}),(0,L.jsx)(`span`,{"aria-hidden":!0,className:i(`w-5 shrink-0 text-center`,t.kind===`add`&&`text-success`,t.kind===`del`&&`text-danger`),children:ee[t.kind]}),(t.kind===`add`||t.kind===`del`)&&(0,L.jsx)(`span`,{className:`sr-only`,children:t.kind===`add`?`added`:`deleted`})]})}),(0,L.jsx)(`td`,{className:`whitespace-pre pr-3`,children:s?(0,L.jsx)(`button`,{type:`button`,"data-diff-line":t.newLine??t.oldLine??void 0,className:`block w-full scroll-ml-[6.25rem] cursor-pointer text-left whitespace-pre hover:underline focus-visible:underline`,onMouseDown:e=>e.preventDefault(),onClick:e=>{e.currentTarget.focus({preventScroll:!0}),r?.(o)},"aria-label":`Comment on line ${t.newLine??t.oldLine}`,children:t.text||` `}):t.text})]},n)})})})})]},`${e.path}-${t}`))})}function ne(e){let t={};for(let n of e)t[n.name]={selected:[],otherChosen:!1,otherText:``,text:n.kind===`text`?n.prefill??``:``};return t}function U(e,t){if(t)switch(e.kind){case`text`:return t.text;case`select`:return t.otherChosen?{other:t.otherText}:t.selected[0];case`multiselect`:{let e=[...t.selected];return t.otherChosen&&t.otherText.trim()&&e.push(t.otherText.trim()),e}}}function W(e,t){let n={},r=[];for(let i of e)s(i,n)&&(r.push(i),n[i.name]=U(i,t[i.name]));return r}function re(e,t){let n={};for(let r of W(e,t)){let e=U(r,t[r.name]);e!==void 0&&(n[r.name]=e)}return n}function ie(e,t){let n={};for(let r of W(e,t)){let e=t[r.name];if(e){if(r.kind===`select`)e.otherChosen?e.otherText.trim()||(n[r.name]=`Enter a value or choose an option`):e.selected.length===0&&(n[r.name]=`Choose an option`);else if(r.kind===`multiselect`){let t=e.selected.length+(e.otherChosen&&e.otherText.trim()?1:0);e.otherChosen&&!e.otherText.trim()?n[r.name]=`Enter a value for Other`:r.min!==void 0&&t<r.min?n[r.name]=`Choose at least ${r.min}`:r.max!==void 0&&t>r.max&&(n[r.name]=`Choose at most ${r.max}`)}}}return n}function ae(e,t){return{...e,selected:[t],otherChosen:!1}}function oe(e){return{...e,selected:[],otherChosen:!0}}function se(e,t,n){if(e.selected.includes(t))return{...e,selected:e.selected.filter(e=>e!==t)};let r=e.selected.length+ +!!e.otherChosen;return n!==void 0&&r>=n?e:{...e,selected:[...e.selected,t]}}function ce({node:e,className:t}){let{onRespond:n,busy:r,disabled:a}=I(),[s,c]=(0,P.useState)(()=>ne(e.fields)),[l,u]=(0,P.useState)(!1),d=(0,P.useMemo)(()=>W(e.fields,s),[e.fields,s]),f=(0,P.useMemo)(()=>ie(e.fields,s),[e.fields,s]),p=a||r,m=(e,t)=>c(n=>({...n,[e]:t}));return(0,L.jsxs)(`form`,{className:i(`flex flex-col gap-4`,t),noValidate:!0,onSubmit:t=>{t.preventDefault(),u(!0),!(Object.keys(f).length>0||p)&&n?.({kind:`form`,values:re(e.fields,s)})},children:[d.map(e=>(0,L.jsx)(le,{field:e,state:s[e.name],onChange:t=>m(e.name,t),error:l?f[e.name]:void 0,disabled:p},e.name)),!a&&(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(o,{type:`submit`,variant:`primary`,busy:r,children:e.submitLabel||`Submit`}),(0,L.jsx)(o,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>n?.({kind:`cancel`}),children:e.cancelLabel||`Cancel`}),l&&Object.keys(f).length>0&&(0,L.jsx)(`span`,{role:`alert`,className:`text-sm text-danger`,children:`Complete the highlighted fields.`})]})]})}function le({field:e,state:t,onChange:n,error:r,disabled:i}){let a=(0,P.useId)(),o=`${a}-err`;if(e.kind===`text`){let s={id:a,value:t.text,placeholder:e.placeholder,disabled:i,"aria-invalid":!!r||void 0,"aria-describedby":r?o:void 0};return(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsx)(`label`,{htmlFor:a,className:`text-sm font-medium`,children:e.label}),e.multiline?(0,L.jsx)(w,{...s,minRows:3,onChange:e=>n({...t,text:e.target.value})}):(0,L.jsx)(T,{...s,onChange:e=>n({...t,text:e.target.value})}),r&&(0,L.jsx)(`p`,{id:o,className:`text-sm text-danger`,children:r})]})}let s=e.kind===`multiselect`,c=!s&&t.selected[0]?e.options.find(e=>e.value===t.selected[0])?.preview:void 0,l=s&&(e.min!==void 0||e.max!==void 0)?e.min!==void 0&&e.max!==void 0?`Choose ${e.min}–${e.max}`:e.min===void 0?`Choose up to ${e.max}`:`Choose at least ${e.min}`:s?`Choose any`:void 0;return(0,L.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-2`,"aria-describedby":r?o:void 0,"aria-invalid":!!r||void 0,children:[(0,L.jsxs)(`legend`,{className:`mb-2 text-sm font-medium`,children:[e.label,l&&(0,L.jsx)(`span`,{className:`ml-2 font-normal text-muted`,children:l})]}),(0,L.jsxs)(`div`,{className:`grid gap-2`,children:[e.options.map(r=>(0,L.jsx)(G,{name:a,option:r,multi:s,checked:t.selected.includes(r.value),disabled:i,onToggle:()=>n(s?se(t,r.value,e.kind===`multiselect`?e.max:void 0):ae(t,r.value))},r.value)),e.allowOther&&(0,L.jsx)(G,{name:a,option:{value:`__other__`,label:e.allowOther.label||`Other`},multi:s,checked:t.otherChosen,disabled:i,onToggle:()=>n(s?{...t,otherChosen:!t.otherChosen}:oe(t))})]}),e.allowOther&&t.otherChosen&&(0,L.jsx)(T,{"aria-label":e.allowOther.label||`Other`,placeholder:e.allowOther.placeholder??`Type your answer`,value:t.otherText,disabled:i,autoFocus:!0,onChange:e=>n({...t,otherText:e.target.value})}),c&&(0,L.jsx)(`pre`,{className:`max-h-64 max-w-full overflow-auto rounded-md border border-border bg-surface-2 px-3 py-2 text-xs leading-5`,children:c}),r&&(0,L.jsx)(`p`,{id:o,className:`text-sm text-danger`,children:r})]})}function G({name:e,option:t,multi:n,checked:r,disabled:a,onToggle:o}){return(0,L.jsxs)(`label`,{className:i(`tap flex min-w-0 cursor-pointer items-start gap-3 rounded-lg border px-3 py-2.5 text-sm`,`has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-accent`,r?`border-accent bg-accent-soft`:`border-border bg-surface hover:bg-surface-2`,a&&`cursor-not-allowed opacity-70`),children:[(0,L.jsx)(`input`,{type:n?`checkbox`:`radio`,name:e,value:t.value,checked:r,disabled:a,onChange:o,className:`sr-only`}),(0,L.jsx)(`span`,{"aria-hidden":!0,className:i(`mt-0.5 inline-flex size-4 shrink-0 items-center justify-center border`,n?`rounded`:`rounded-full`,r?`border-accent bg-accent text-accent-fg`:`border-border-strong bg-surface`),children:r&&(n?(0,L.jsx)(h,{className:`size-3`}):(0,L.jsx)(`span`,{className:`size-1.5 rounded-full bg-accent-fg`}))}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`block font-medium break-words`,children:t.label}),t.description&&(0,L.jsx)(`span`,{className:`block text-muted break-words`,children:t.description})]})]})}function K({node:e,className:t,...n}){let r=I(),a=Object.values(n).some(e=>e!==void 0),o=(0,L.jsx)(`div`,{className:i(`flex min-w-0 flex-col gap-3`,t),children:(0,L.jsx)(q,{node:e})});return a?(0,L.jsx)(F.Provider,{value:{...r,...ue(n)},children:o}):o}function ue(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}var de={default:`text-text`,muted:`text-muted`,success:`text-success`,warning:`text-warning`,danger:`text-danger`};function q({node:e}){switch(e.t){case`text`:return(0,L.jsx)(`p`,{className:i(`text-sm break-words whitespace-pre-wrap`,de[e.tone??`default`]),children:e.text});case`markdown`:return(0,L.jsx)(A,{text:e.text});case`code`:return(0,L.jsx)(D,{text:e.text,lang:e.lang,maxHeight:`24rem`});case`diff`:return(0,L.jsx)(H,{patch:e.patch});case`list`:return(0,L.jsx)(fe,{node:e});case`table`:return(0,L.jsx)(`div`,{className:`max-w-full overflow-x-auto overscroll-x-contain rounded-md border border-border`,children:(0,L.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,L.jsx)(`thead`,{className:`bg-surface-2`,children:(0,L.jsx)(`tr`,{children:e.columns.map((e,t)=>(0,L.jsx)(`th`,{scope:`col`,className:`border-b border-border px-3 py-1.5 text-left font-medium`,children:e},t))})}),(0,L.jsx)(`tbody`,{children:e.rows.map((e,t)=>(0,L.jsx)(`tr`,{className:`border-b border-border last:border-b-0`,children:e.map((e,t)=>(0,L.jsx)(`td`,{className:`px-3 py-1.5 align-top break-words`,children:e},t))},t))})]})});case`section`:return(0,L.jsx)(pe,{node:e});case`tabs`:return(0,L.jsx)(me,{node:e});case`progress`:return(0,L.jsx)(he,{node:e});case`ref`:return(0,L.jsx)(_e,{refValue:e.ref,label:e.label});case`form`:return(0,L.jsx)(ce,{node:e});case`confirm`:return(0,L.jsx)(R,{node:e});case`actions`:return(0,L.jsx)(ve,{node:e});default:return null}}function J({nodes:e}){return(0,L.jsx)(L.Fragment,{children:e.map((e,t)=>(0,L.jsx)(q,{node:e},t))})}function fe({node:e}){let t=e.ordered?`ol`:`ul`;return(0,L.jsx)(t,{className:i(`flex flex-col gap-1.5 pl-5 text-sm`,e.ordered?`list-decimal`:`list-disc`),children:e.items.map((e,t)=>(0,L.jsx)(`li`,{className:`min-w-0`,children:(0,L.jsx)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:(0,L.jsx)(q,{node:e})})},t))})}function pe({node:e}){return e.collapsible?(0,L.jsxs)(`details`,{className:`group min-w-0`,open:!0,children:[(0,L.jsxs)(`summary`,{className:`tap flex cursor-pointer list-none items-center gap-1.5 py-1 text-sm font-medium [&::-webkit-details-marker]:hidden`,children:[(0,L.jsx)(g,{"aria-hidden":!0,className:`size-4 shrink-0 transition-transform group-open:rotate-90`}),e.title??`Details`]}),(0,L.jsx)(`div`,{className:`flex min-w-0 flex-col gap-3 border-l border-border pl-3 ml-2 mt-1`,children:(0,L.jsx)(J,{nodes:e.children})})]}):(0,L.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-2`,children:[e.title&&(0,L.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.title}),(0,L.jsx)(J,{nodes:e.children})]})}function me({node:e}){let t=(0,P.useId)(),[n,r]=(0,P.useState)(e.tabs[0]?.id??``),i=e.tabs.find(e=>e.id===n)??e.tabs[0];return i?(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,L.jsx)(k,{label:`Sections`,idPrefix:t,tabs:e.tabs.map(e=>({id:e.id,label:e.label})),value:i.id,onChange:r,scrollable:!0}),(0,L.jsx)(j,{idPrefix:t,id:i.id,className:`flex min-w-0 flex-col gap-3`,children:(0,L.jsx)(J,{nodes:i.children})})]}):null}function he({node:e}){let t=e.status??`running`,n=t===`ok`?b:t===`error`?y:_,r=t===`ok`?`Done`:t===`error`?`Failed`:`In progress`,a=e.value===void 0?null:Math.round(e.value*100);return(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[t===`running`?(0,L.jsx)(u,{className:`size-4 text-info`}):(0,L.jsx)(n,{"aria-hidden":!0,className:i(`size-4 shrink-0`,t===`ok`&&`text-success`,t===`error`&&`text-danger`)}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),(0,L.jsxs)(`span`,{className:`shrink-0 text-xs text-muted`,children:[r,a===null?``:` · ${a}%`]})]}),a!==null&&(0,L.jsx)(`div`,{role:`progressbar`,"aria-label":e.label,"aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":100,className:`h-1.5 overflow-hidden rounded-full bg-surface-3`,children:(0,L.jsx)(`div`,{className:i(`h-full rounded-full`,t===`error`?`bg-danger`:t===`ok`?`bg-success`:`bg-accent`),style:{width:`${a}%`}})})]})}function ge(e){switch(e.kind){case`session`:return`/code/${encodeURIComponent(e.sessionId)}`;case`task`:return`/tasks/${encodeURIComponent(e.taskId)}`;default:return null}}function _e({refValue:e,label:t}){let{onOpenFile:n}=I(),r=ge(e);return r?(0,L.jsx)(E,{to:r,size:`sm`,children:t}):e.kind===`file`?n?(0,L.jsx)(E,{size:`sm`,variant:`inline`,icon:(0,L.jsx)(N,{"aria-hidden":!0,className:`size-4 shrink-0`}),onClick:()=>n(e.path),children:(0,L.jsx)(`span`,{className:`truncate`,children:t||e.path})}):(0,L.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1 font-mono text-sm`,title:e.path,children:[(0,L.jsx)(N,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted`}),(0,L.jsx)(`span`,{className:`truncate`,children:t||e.path})]}):e.kind===`native_session`?(0,L.jsxs)(`span`,{className:`text-sm`,title:e.sessionFile,children:[t,` `,(0,L.jsx)(`span`,{className:`text-muted`,children:`(native Pi session, not imported)`})]}):(0,L.jsx)(`span`,{className:`text-sm`,children:t})}function ve({node:e}){let{onRespond:t,onAction:n,busy:r,disabled:i}=I();return i?null:(0,L.jsx)(`div`,{className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:flex-wrap`,children:e.actions.map(e=>(0,L.jsx)(o,{className:`h-auto min-h-9 min-w-0 justify-start py-1.5 text-left whitespace-normal sm:justify-center sm:text-center`,variant:e.tone===`primary`?`primary`:e.tone===`danger`?`danger`:`secondary`,disabled:r||!t&&!n,onClick:()=>{t?t({kind:`action`,actionId:e.id}):n?.(e.id)},children:e.label},e.id))})}var ye=`An extension opened a terminal-only dialog. In RPC mode Pi gave it no answer, so the extension continued without one.`,be=[{id:`abort`,label:`Stop the run`,tone:`danger`},{id:`message`,label:`Send a message to Pi`,tone:`primary`}];function Y(e){if(e.t===`actions`)return e;if(e.t===`section`)for(let t of e.children){let e=Y(t);if(e)return e}return null}function xe(e){return e.state===`unsupported`||e.source.kind===`unsupported_custom`}function Se(e){let t=(Y(e.presentation)?.actions??[]).filter(e=>e.id===`abort`||e.id===`message`).map(e=>({id:e.id,label:e.label,tone:e.tone==="default"?`secondary`:e.tone??(e.id===`abort`?`danger`:`primary`)}));return{answerable:e.state===`unsupported`&&e.resolution===null,actions:t.length>0?t:be,copy:ye}}function Ce(e){return e===`running`||e===`waiting_input`?`followUp`:`prompt`}function X(e){switch(e.t){case`form`:case`confirm`:case`actions`:return!0;case`list`:return e.items.some(X);case`section`:return e.children.some(X);case`tabs`:return e.tabs.some(e=>e.children.some(X));default:return!1}}function Z(e){return e===`host`?`the host`:e===`pi`?`Pi`:`a device`}function we({interaction:e,readOnlyReason:t,className:n,onAnswered:r,id:s,sticky:u,flush:m}){let h=p(e=>e.upsertInteraction),[g,_]=(0,P.useState)(!1),[y,b]=(0,P.useState)(null),[S,C]=(0,P.useState)(null),[w,T]=(0,P.useState)(null),[E,D]=(0,P.useState)(null),O=E&&E.id===e.id&&E.revision>e.revision?E:e,k=O.state===`pending`,A=xe(O),j=p(e=>e.sessions[O.sessionId]?.runtime),[M,N]=(0,P.useState)(!1),[F,I]=(0,P.useState)(``),R=async e=>{_(!0),b(null),T(e);try{let t=await d(`/api/interactions/${encodeURIComponent(O.id)}/answer`,{revision:O.revision,response:e});return t?.interaction&&(h(t.interaction),D(t.interaction),r?.(t.interaction)),!0}catch(e){if(a(e,`already_answered`)){let t=e.details?.interaction;t&&(h(t),D(t)),C(t?.resolution?.summary??`answered on another device`)}else b(e);return!1}finally{_(!1)}},z=async()=>{let e=F.trim();if(e){_(!0),b(null);try{await d(`/api/sessions/${encodeURIComponent(O.sessionId)}/prompt`,{text:e,mode:Ce(j)})}catch(e){b(e),_(!1);return}_(!1),await R({kind:`action`,actionId:`message`})&&(N(!1),I(``))}},B=x();return k&&!S&&!A&&Oe(O.presentation)?(0,L.jsx)(Me,{id:s,interaction:O,node:O.presentation,onRespond:e=>void R(e),busy:g,disabled:!!t,mobile:B===`mobile`,sticky:u??!0,flush:m??!1,className:n}):(0,L.jsxs)(`article`,{id:s,"aria-label":`Question: ${O.title}`,className:i(`flex min-w-0 flex-col gap-3 border-l-2 py-1 pl-3`,k?`border-warning`:`border-border`,n),children:[(0,L.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,L.jsx)(`h3`,{className:`min-w-0 flex-1 text-sm font-semibold break-words`,children:O.title}),(0,L.jsx)(v,{kind:`interaction`,value:O.state,size:`sm`})]}),S&&(0,L.jsxs)(`p`,{role:`status`,className:`rounded-md bg-surface-2 px-3 py-2 text-sm`,children:[`Already answered: `,S]}),A?(0,L.jsx)(Te,{interaction:O,readOnlyReason:t??null,busy:g,answered:S!==null,composing:M,message:F,setMessage:I,onAction:e=>{e===`message`?N(!0):R({kind:`action`,actionId:e})},onSend:()=>void z(),onCancelMessage:()=>N(!1)}):k&&!S?(0,L.jsxs)(L.Fragment,{children:[t&&(0,L.jsx)(`p`,{className:`text-sm text-muted`,children:t}),(0,L.jsx)(K,{node:O.presentation,onRespond:e=>void R(e),busy:g,disabled:!!t}),!t&&!X(O.presentation)&&(0,L.jsx)(`div`,{children:(0,L.jsx)(o,{busy:g,onClick:()=>void R({kind:`cancel`}),children:`Dismiss`})}),g&&(0,L.jsx)(`p`,{role:`status`,className:`text-sm text-muted`,children:`Sending answer… waiting for the host to confirm.`})]}):S?null:O.resolution?(0,L.jsxs)(`p`,{className:`text-sm text-muted`,children:[O.state===`resolved`?`Answered`:`Closed`,` by`,` `,Z(O.resolution.by),` `,c(O.resolution.at),`:`,` `,(0,L.jsx)(`span`,{className:`text-text`,children:O.resolution.summary})]}):(0,L.jsx)(`p`,{className:`text-sm text-muted`,children:O.state===`expired`?`This question expired before it was answered (Pi closed the dialog).`:`This question was canceled.`}),y!==null&&(0,L.jsx)(l,{compact:!0,title:`Answer not delivered`,error:f(y),onRetry:w?()=>void R(w):void 0})]})}function Te({interaction:e,readOnlyReason:t,busy:n,answered:r,composing:i,message:a,setMessage:s,onAction:l,onSend:u,onCancelMessage:d}){let f=Se(e);return(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,L.jsx)(`p`,{className:`text-sm text-muted`,children:f.copy}),e.resolution?(0,L.jsxs)(`p`,{className:`text-sm text-muted`,children:[`Chosen by `,Z(e.resolution.by),` `,c(e.resolution.at),`: `,(0,L.jsx)(`span`,{className:`text-text`,children:e.resolution.summary})]}):!f.answerable||r?null:t?(0,L.jsx)(`p`,{className:`text-sm text-muted`,children:t}):i?(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,L.jsx)(w,{"aria-label":`Message for Pi`,value:a,onChange:e=>s(e.target.value),rows:3,autoFocus:!0,placeholder:`Tell Pi what to do instead`}),(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,L.jsx)(o,{variant:`primary`,busy:n,disabled:!a.trim(),onClick:u,children:`Send message`}),(0,L.jsx)(o,{disabled:n,onClick:d,children:`Cancel`})]})]}):(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:f.actions.map(e=>(0,L.jsx)(o,{variant:e.tone,busy:n&&e.id===`abort`,disabled:n,onClick:()=>l(e.id),children:e.label},e.id))})]})}function Q(e){if(e.t!==`section`||e.children.length<2)return null;let t=e.children[e.children.length-1];if(t?.t!==`actions`)return null;let n=e.children.slice(0,-1);return n.some(X)?null:{body:{...e,children:n},actions:t}}function $(e,t){let n=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches;e?.scrollIntoView({behavior:n?`auto`:`smooth`,block:t})}function Ee(e){let[t,n]=(0,P.useState)(!0);return(0,P.useEffect)(()=>{let t=e.current;if(!t||typeof IntersectionObserver>`u`)return;let r=new IntersectionObserver(([e])=>n(!!e?.isIntersecting));return r.observe(t),()=>r.disconnect()},[e]),t}function De(e){if(e.t===`markdown`)return e.text;if(e.t===`section`)for(let t of e.children){let e=De(t);if(e!==null)return e}return null}function Oe(e){if(!Q(e))return!1;let t=De(e);return t!==null&&(t.length>=400||t.split(`
|
|
3
|
+
`);u[u.length-1]===``&&u.pop();for(let e of u){if(e.startsWith(`diff --git `)){let t=/^diff --git a\/(.+?) b\/(.+)$/.exec(e);n=l(t?.[2]??``),t&&(n.oldPath=t[1],n.newPath=t[2]);continue}if(!s&&e.startsWith(`--- `)){(!n||n.lines.some(e=>e.kind!==`meta`))&&(n=l()),n.oldPath=z(e.slice(4)),n.oldPath===null&&(n.status=`added`);continue}if(!s&&e.startsWith(`+++ `)&&n){n.newPath=z(e.slice(4)),n.newPath===null&&(n.status=`deleted`),n.path=n.newPath??n.oldPath??n.path;continue}let t=B.exec(e);t?(n||=l(),r=Number(t[1]),i=Number(t[3]),a=t[2]===void 0?1:Number(t[2]),o=t[4]===void 0?1:Number(t[4]),s=a>0||o>0,n.lines.push({kind:`hunk`,text:e,oldLine:null,newLine:null})):(n||=l(),s&&e.startsWith(`+`)?(n.lines.push({kind:`add`,text:e.slice(1),oldLine:null,newLine:i++}),n.additions++,o--,c()):s&&e.startsWith(`-`)?(n.lines.push({kind:`del`,text:e.slice(1),oldLine:r++,newLine:null}),n.deletions++,a--,c()):s&&(e.startsWith(` `)||e===``)?(n.lines.push({kind:`context`,text:e.slice(1),oldLine:r++,newLine:i++}),a--,o--,c()):(e.startsWith(`\\`)||(s=!1,e.startsWith(`new file mode`)?n.status=`added`:e.startsWith(`deleted file mode`)?n.status=`deleted`:e.startsWith(`rename from `)?(n.status=`renamed`,n.oldPath=e.slice(12)):e.startsWith(`rename to `)?(n.status=`renamed`,n.newPath=e.slice(10),n.path=n.newPath):e.startsWith(`Binary files`)&&(n.status=`binary`)),n.lines.push({kind:`meta`,text:e,oldLine:null,newLine:null})))}return t}var ee={add:`+`,del:`-`,context:` `,hunk:``,meta:``},te={add:`bg-diff-add`,del:`bg-diff-del`,hunk:`bg-diff-hunk`,context:`bg-surface`,meta:`bg-surface`};function H({patch:e,files:t,showFileHeaders:n=!0,onLineClick:r,isLineMarked:i,className:a}){let s=(0,P.useMemo)(()=>t??V(e??``),[t,e]);return s.length===0?(0,L.jsx)(`p`,{className:`text-sm text-muted`,children:`No changes.`}):(0,L.jsx)(`div`,{className:o(`flex min-w-0 flex-col gap-3`,a),children:s.map((e,t)=>(0,L.jsxs)(`section`,{className:`min-w-0 overflow-hidden rounded-md border border-border`,"aria-label":`Diff of ${e.path||`file`}`,children:[n&&(0,L.jsxs)(`header`,{className:`flex min-w-0 items-center gap-2 border-b border-border bg-surface-2 px-3 py-1.5 text-sm`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono`,title:e.path,children:e.status===`renamed`&&e.oldPath?`${e.oldPath} → ${e.path}`:e.path}),(0,L.jsxs)(`span`,{className:`shrink-0 font-mono text-xs`,children:[(0,L.jsxs)(`span`,{className:`text-success`,children:[`+`,e.additions,(0,L.jsx)(`span`,{className:`sr-only`,children:` added`})]}),` `,(0,L.jsxs)(`span`,{className:`text-danger`,children:[`-`,e.deletions,(0,L.jsx)(`span`,{className:`sr-only`,children:` deleted`})]})]})]}),e.status===`binary`?(0,L.jsx)(`p`,{className:`px-3 py-2 text-sm text-muted`,children:`Binary file not shown.`}):(0,L.jsx)(`div`,{className:`max-w-full overflow-x-auto overscroll-x-contain`,children:(0,L.jsx)(`table`,{className:`w-full border-collapse font-mono text-xs leading-5`,children:(0,L.jsx)(`tbody`,{children:e.lines.map((t,n)=>{let a={file:e.path,line:t},s=!!r&&(t.kind===`add`||t.kind===`del`||t.kind===`context`),c=i?.(a)??!1;return(0,L.jsxs)(`tr`,{className:o(t.kind===`add`&&`bg-diff-add`,t.kind===`del`&&`bg-diff-del`,t.kind===`hunk`&&`bg-diff-hunk text-muted`,t.kind===`meta`&&`text-muted`,c&&`outline outline-1 -outline-offset-1 outline-warning`),children:[(0,L.jsx)(`td`,{className:o(`sticky left-0 z-[1] w-[6.25rem] min-w-[6.25rem] select-none whitespace-nowrap p-0`,te[t.kind]),children:(0,L.jsxs)(`span`,{className:`flex`,children:[(0,L.jsx)(`span`,{className:`w-10 shrink-0 border-r border-border px-1.5 text-right text-subtle tabular-nums`,children:t.oldLine??``}),(0,L.jsx)(`span`,{className:`w-10 shrink-0 border-r border-border px-1.5 text-right text-subtle tabular-nums`,children:t.newLine??``}),(0,L.jsx)(`span`,{"aria-hidden":!0,className:o(`w-5 shrink-0 text-center`,t.kind===`add`&&`text-success`,t.kind===`del`&&`text-danger`),children:ee[t.kind]}),(t.kind===`add`||t.kind===`del`)&&(0,L.jsx)(`span`,{className:`sr-only`,children:t.kind===`add`?`added`:`deleted`})]})}),(0,L.jsx)(`td`,{className:`whitespace-pre pr-3`,children:s?(0,L.jsx)(`button`,{type:`button`,"data-diff-line":t.newLine??t.oldLine??void 0,className:`block w-full scroll-ml-[6.25rem] cursor-pointer text-left whitespace-pre hover:underline focus-visible:underline`,onMouseDown:e=>e.preventDefault(),onClick:e=>{e.currentTarget.focus({preventScroll:!0}),r?.(a)},"aria-label":`Comment on line ${t.newLine??t.oldLine}`,children:t.text||` `}):t.text})]},n)})})})})]},`${e.path}-${t}`))})}function ne(e){let t={};for(let n of e)t[n.name]={selected:[],otherChosen:!1,otherText:``,text:n.kind===`text`?n.prefill??``:``};return t}function U(e,t){if(t)switch(e.kind){case`text`:return t.text;case`select`:return t.otherChosen?{other:t.otherText}:t.selected[0];case`multiselect`:{let e=[...t.selected];return t.otherChosen&&t.otherText.trim()&&e.push(t.otherText.trim()),e}}}function W(e,t){let n={},r=[];for(let i of e)l(i,n)&&(r.push(i),n[i.name]=U(i,t[i.name]));return r}function re(e,t){let n={};for(let r of W(e,t)){let e=U(r,t[r.name]);e!==void 0&&(n[r.name]=e)}return n}function ie(e,t){let n={};for(let r of W(e,t)){let e=t[r.name];if(e){if(r.kind===`select`)e.otherChosen?e.otherText.trim()||(n[r.name]=`Enter a value or choose an option`):e.selected.length===0&&(n[r.name]=`Choose an option`);else if(r.kind===`multiselect`){let t=e.selected.length+(e.otherChosen&&e.otherText.trim()?1:0);e.otherChosen&&!e.otherText.trim()?n[r.name]=`Enter a value for Other`:r.min!==void 0&&t<r.min?n[r.name]=`Choose at least ${r.min}`:r.max!==void 0&&t>r.max&&(n[r.name]=`Choose at most ${r.max}`)}}}return n}function ae(e,t){return{...e,selected:[t],otherChosen:!1}}function oe(e){return{...e,selected:[],otherChosen:!0}}function se(e,t,n){if(e.selected.includes(t))return{...e,selected:e.selected.filter(e=>e!==t)};let r=e.selected.length+ +!!e.otherChosen;return n!==void 0&&r>=n?e:{...e,selected:[...e.selected,t]}}function ce({node:e,className:t}){let{onRespond:n,busy:r,disabled:i}=I(),[a,s]=(0,P.useState)(()=>ne(e.fields)),[l,u]=(0,P.useState)(!1),d=(0,P.useMemo)(()=>W(e.fields,a),[e.fields,a]),f=(0,P.useMemo)(()=>ie(e.fields,a),[e.fields,a]),p=i||r,m=(e,t)=>s(n=>({...n,[e]:t}));return(0,L.jsxs)(`form`,{className:o(`flex flex-col gap-4`,t),noValidate:!0,onSubmit:t=>{t.preventDefault(),u(!0),!(Object.keys(f).length>0||p)&&n?.({kind:`form`,values:re(e.fields,a)})},children:[d.map(e=>(0,L.jsx)(le,{field:e,state:a[e.name],onChange:t=>m(e.name,t),error:l?f[e.name]:void 0,disabled:p},e.name)),!i&&(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(c,{type:`submit`,variant:`primary`,busy:r,children:e.submitLabel||`Submit`}),(0,L.jsx)(c,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>n?.({kind:`cancel`}),children:e.cancelLabel||`Cancel`}),l&&Object.keys(f).length>0&&(0,L.jsx)(`span`,{role:`alert`,className:`text-sm text-danger`,children:`Complete the highlighted fields.`})]})]})}function le({field:e,state:t,onChange:n,error:r,disabled:i}){let a=(0,P.useId)(),o=`${a}-err`;if(e.kind===`text`){let s={id:a,value:t.text,placeholder:e.placeholder,disabled:i,"aria-invalid":!!r||void 0,"aria-describedby":r?o:void 0};return(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsx)(`label`,{htmlFor:a,className:`text-sm font-medium`,children:e.label}),e.multiline?(0,L.jsx)(w,{...s,minRows:3,onChange:e=>n({...t,text:e.target.value})}):(0,L.jsx)(T,{...s,onChange:e=>n({...t,text:e.target.value})}),r&&(0,L.jsx)(`p`,{id:o,className:`text-sm text-danger`,children:r})]})}let s=e.kind===`multiselect`,c=!s&&t.selected[0]?e.options.find(e=>e.value===t.selected[0])?.preview:void 0,l=s&&(e.min!==void 0||e.max!==void 0)?e.min!==void 0&&e.max!==void 0?`Choose ${e.min}–${e.max}`:e.min===void 0?`Choose up to ${e.max}`:`Choose at least ${e.min}`:s?`Choose any`:void 0;return(0,L.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-2`,"aria-describedby":r?o:void 0,"aria-invalid":!!r||void 0,children:[(0,L.jsxs)(`legend`,{className:`mb-2 text-sm font-medium`,children:[e.label,l&&(0,L.jsx)(`span`,{className:`ml-2 font-normal text-muted`,children:l})]}),(0,L.jsxs)(`div`,{className:`grid gap-2`,children:[e.options.map(r=>(0,L.jsx)(G,{name:a,option:r,multi:s,checked:t.selected.includes(r.value),disabled:i,onToggle:()=>n(s?se(t,r.value,e.kind===`multiselect`?e.max:void 0):ae(t,r.value))},r.value)),e.allowOther&&(0,L.jsx)(G,{name:a,option:{value:`__other__`,label:e.allowOther.label||`Other`},multi:s,checked:t.otherChosen,disabled:i,onToggle:()=>n(s?{...t,otherChosen:!t.otherChosen}:oe(t))})]}),e.allowOther&&t.otherChosen&&(0,L.jsx)(T,{"aria-label":e.allowOther.label||`Other`,placeholder:e.allowOther.placeholder??`Type your answer`,value:t.otherText,disabled:i,autoFocus:!0,onChange:e=>n({...t,otherText:e.target.value})}),c&&(0,L.jsx)(`pre`,{className:`max-h-64 max-w-full overflow-auto rounded-md border border-border bg-surface-2 px-3 py-2 text-xs leading-5`,children:c}),r&&(0,L.jsx)(`p`,{id:o,className:`text-sm text-danger`,children:r})]})}function G({name:e,option:t,multi:n,checked:r,disabled:i,onToggle:a}){return(0,L.jsxs)(`label`,{className:o(`tap flex min-w-0 cursor-pointer items-start gap-3 rounded-lg border px-3 py-2.5 text-sm`,`has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-accent`,r?`border-accent bg-accent-soft`:`border-border bg-surface hover:bg-surface-2`,i&&`cursor-not-allowed opacity-70`),children:[(0,L.jsx)(`input`,{type:n?`checkbox`:`radio`,name:e,value:t.value,checked:r,disabled:i,onChange:a,className:`sr-only`}),(0,L.jsx)(`span`,{"aria-hidden":!0,className:o(`mt-0.5 inline-flex size-4 shrink-0 items-center justify-center border`,n?`rounded`:`rounded-full`,r?`border-accent bg-accent text-accent-fg`:`border-border-strong bg-surface`),children:r&&(n?(0,L.jsx)(_,{className:`size-3`}):(0,L.jsx)(`span`,{className:`size-1.5 rounded-full bg-accent-fg`}))}),(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`block font-medium break-words`,children:t.label}),t.description&&(0,L.jsx)(`span`,{className:`block text-muted break-words`,children:t.description})]})]})}function K({node:e,className:t,...n}){let r=I(),i=Object.values(n).some(e=>e!==void 0),a=(0,L.jsx)(`div`,{className:o(`flex min-w-0 flex-col gap-3`,t),children:(0,L.jsx)(q,{node:e})});return i?(0,L.jsx)(F.Provider,{value:{...r,...ue(n)},children:a}):a}function ue(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0))}var de={default:`text-text`,muted:`text-muted`,success:`text-success`,warning:`text-warning`,danger:`text-danger`};function q({node:e}){switch(e.t){case`text`:return(0,L.jsx)(`p`,{className:o(`text-sm break-words whitespace-pre-wrap`,de[e.tone??`default`]),children:e.text});case`markdown`:return(0,L.jsx)(A,{text:e.text});case`code`:return(0,L.jsx)(D,{text:e.text,lang:e.lang,maxHeight:`24rem`});case`diff`:return(0,L.jsx)(H,{patch:e.patch});case`list`:return(0,L.jsx)(fe,{node:e});case`table`:return(0,L.jsx)(`div`,{className:`max-w-full overflow-x-auto overscroll-x-contain rounded-md border border-border`,children:(0,L.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,L.jsx)(`thead`,{className:`bg-surface-2`,children:(0,L.jsx)(`tr`,{children:e.columns.map((e,t)=>(0,L.jsx)(`th`,{scope:`col`,className:`border-b border-border px-3 py-1.5 text-left font-medium`,children:e},t))})}),(0,L.jsx)(`tbody`,{children:e.rows.map((e,t)=>(0,L.jsx)(`tr`,{className:`border-b border-border last:border-b-0`,children:e.map((e,t)=>(0,L.jsx)(`td`,{className:`px-3 py-1.5 align-top break-words`,children:e},t))},t))})]})});case`section`:return(0,L.jsx)(pe,{node:e});case`tabs`:return(0,L.jsx)(me,{node:e});case`progress`:return(0,L.jsx)(he,{node:e});case`ref`:return(0,L.jsx)(_e,{refValue:e.ref,label:e.label});case`form`:return(0,L.jsx)(ce,{node:e});case`confirm`:return(0,L.jsx)(R,{node:e});case`actions`:return(0,L.jsx)(ve,{node:e});default:return null}}function J({nodes:e}){return(0,L.jsx)(L.Fragment,{children:e.map((e,t)=>(0,L.jsx)(q,{node:e},t))})}function fe({node:e}){let t=e.ordered?`ol`:`ul`;return(0,L.jsx)(t,{className:o(`flex flex-col gap-1.5 pl-5 text-sm`,e.ordered?`list-decimal`:`list-disc`),children:e.items.map((e,t)=>(0,L.jsx)(`li`,{className:`min-w-0`,children:(0,L.jsx)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:(0,L.jsx)(q,{node:e})})},t))})}function pe({node:e}){return e.collapsible?(0,L.jsxs)(`details`,{className:`group min-w-0`,open:!0,children:[(0,L.jsxs)(`summary`,{className:`tap flex cursor-pointer list-none items-center gap-1.5 py-1 text-sm font-medium [&::-webkit-details-marker]:hidden`,children:[(0,L.jsx)(v,{"aria-hidden":!0,className:`size-4 shrink-0 transition-transform group-open:rotate-90`}),e.title??`Details`]}),(0,L.jsx)(`div`,{className:`flex min-w-0 flex-col gap-3 border-l border-border pl-3 ml-2 mt-1`,children:(0,L.jsx)(J,{nodes:e.children})})]}):(0,L.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-2`,children:[e.title&&(0,L.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.title}),(0,L.jsx)(J,{nodes:e.children})]})}function me({node:e}){let t=(0,P.useId)(),[n,r]=(0,P.useState)(e.tabs[0]?.id??``),i=e.tabs.find(e=>e.id===n)??e.tabs[0];return i?(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,L.jsx)(k,{label:`Sections`,idPrefix:t,tabs:e.tabs.map(e=>({id:e.id,label:e.label})),value:i.id,onChange:r,scrollable:!0}),(0,L.jsx)(j,{idPrefix:t,id:i.id,className:`flex min-w-0 flex-col gap-3`,children:(0,L.jsx)(J,{nodes:i.children})})]}):null}function he({node:e}){let t=e.status??`running`,n=t===`ok`?x:t===`error`?y:i,r=t===`ok`?`Done`:t===`error`?`Failed`:`In progress`,a=e.value===void 0?null:Math.round(e.value*100);return(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[t===`running`?(0,L.jsx)(f,{className:`size-4 text-info`}):(0,L.jsx)(n,{"aria-hidden":!0,className:o(`size-4 shrink-0`,t===`ok`&&`text-success`,t===`error`&&`text-danger`)}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),(0,L.jsxs)(`span`,{className:`shrink-0 text-xs text-muted`,children:[r,a===null?``:` · ${a}%`]})]}),a!==null&&(0,L.jsx)(`div`,{role:`progressbar`,"aria-label":e.label,"aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":100,className:`h-1.5 overflow-hidden rounded-full bg-surface-3`,children:(0,L.jsx)(`div`,{className:o(`h-full rounded-full`,t===`error`?`bg-danger`:t===`ok`?`bg-success`:`bg-accent`),style:{width:`${a}%`}})})]})}function ge(e){switch(e.kind){case`session`:return`/code/${encodeURIComponent(e.sessionId)}`;case`task`:return`/tasks/${encodeURIComponent(e.taskId)}`;default:return null}}function _e({refValue:e,label:t}){let{onOpenFile:n}=I(),r=ge(e);return r?(0,L.jsx)(E,{to:r,size:`sm`,children:t}):e.kind===`file`?n?(0,L.jsx)(E,{size:`sm`,variant:`inline`,icon:(0,L.jsx)(N,{"aria-hidden":!0,className:`size-4 shrink-0`}),onClick:()=>n(e.path),children:(0,L.jsx)(`span`,{className:`truncate`,children:t||e.path})}):(0,L.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1 font-mono text-sm`,title:e.path,children:[(0,L.jsx)(N,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted`}),(0,L.jsx)(`span`,{className:`truncate`,children:t||e.path})]}):e.kind===`native_session`?(0,L.jsxs)(`span`,{className:`text-sm`,title:e.sessionFile,children:[t,` `,(0,L.jsx)(`span`,{className:`text-muted`,children:`(native Pi session, not imported)`})]}):(0,L.jsx)(`span`,{className:`text-sm`,children:t})}function ve({node:e}){let{onRespond:t,onAction:n,busy:r,disabled:i}=I();return i?null:(0,L.jsx)(`div`,{className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:flex-wrap`,children:e.actions.map(e=>(0,L.jsx)(c,{className:`h-auto min-h-9 min-w-0 justify-start py-1.5 text-left whitespace-normal sm:justify-center sm:text-center`,variant:e.tone===`primary`?`primary`:e.tone===`danger`?`danger`:`secondary`,disabled:r||!t&&!n,onClick:()=>{t?t({kind:`action`,actionId:e.id}):n?.(e.id)},children:e.label},e.id))})}var ye=`An extension opened a terminal-only dialog. In RPC mode Pi gave it no answer, so the extension continued without one.`,be=[{id:`abort`,label:`Stop the run`,tone:`danger`},{id:`message`,label:`Send a message to Pi`,tone:`primary`}];function Y(e){if(e.t===`actions`)return e;if(e.t===`section`)for(let t of e.children){let e=Y(t);if(e)return e}return null}function xe(e){return e.state===`unsupported`||e.source.kind===`unsupported_custom`}function Se(e){let t=(Y(e.presentation)?.actions??[]).filter(e=>e.id===`abort`||e.id===`message`).map(e=>({id:e.id,label:e.label,tone:e.tone==="default"?`secondary`:e.tone??(e.id===`abort`?`danger`:`primary`)}));return{answerable:e.state===`unsupported`&&e.resolution===null,actions:t.length>0?t:be,copy:ye}}function Ce(e){return e===`running`||e===`waiting_input`?`followUp`:`prompt`}function X(e){switch(e.t){case`form`:case`confirm`:case`actions`:return!0;case`list`:return e.items.some(X);case`section`:return e.children.some(X);case`tabs`:return e.tabs.some(e=>e.children.some(X));default:return!1}}function Z(e){return e===`host`?`the host`:e===`pi`?`Pi`:`a device`}function we({interaction:e,readOnlyReason:t,className:n,onAnswered:r,id:i,sticky:l,flush:f}){let g=h(e=>e.upsertInteraction),[_,v]=(0,P.useState)(!1),[y,x]=(0,P.useState)(null),[S,C]=(0,P.useState)(null),[w,T]=(0,P.useState)(null),[E,D]=(0,P.useState)(null),O=E&&E.id===e.id&&E.revision>e.revision?E:e,k=O.state===`pending`,A=xe(O),j=h(e=>e.sessions[O.sessionId]?.runtime),[M,N]=(0,P.useState)(!1),[F,I]=(0,P.useState)(``),R=async e=>{v(!0),x(null),T(e);try{let t=await p(`/api/interactions/${encodeURIComponent(O.id)}/answer`,{revision:O.revision,response:e});return t?.interaction&&(g(t.interaction),D(t.interaction),r?.(t.interaction)),!0}catch(e){if(s(e,`already_answered`)){let t=e.details?.interaction;t&&(g(t),D(t)),C(t?.resolution?.summary??`answered on another device`)}else x(e);return!1}finally{v(!1)}},z=async()=>{let e=F.trim();if(e){v(!0),x(null);try{await p(`/api/sessions/${encodeURIComponent(O.sessionId)}/prompt`,{text:e,mode:Ce(j)})}catch(e){x(e),v(!1);return}v(!1),await R({kind:`action`,actionId:`message`})&&(N(!1),I(``))}},B=b();return k&&!S&&!A&&$(O.presentation)?(0,L.jsx)(Me,{id:i,interaction:O,node:O.presentation,onRespond:e=>void R(e),busy:_,disabled:!!t,mobile:B===`mobile`,sticky:l??!0,flush:f??!1,className:n}):(0,L.jsxs)(`article`,{id:i,"aria-label":`Question: ${O.title}`,className:o(`flex min-w-0 flex-col gap-3 border-l-2 py-1 pl-3`,k?`border-warning`:`border-border`,n),children:[(0,L.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[(0,L.jsx)(`h3`,{className:`min-w-0 flex-1 text-sm font-semibold break-words`,children:O.title}),(0,L.jsx)(a,{kind:`interaction`,value:O.state,size:`sm`})]}),S&&(0,L.jsxs)(`p`,{role:`status`,className:`rounded-md bg-surface-2 px-3 py-2 text-sm`,children:[`Already answered: `,S]}),A?(0,L.jsx)(Te,{interaction:O,readOnlyReason:t??null,busy:_,answered:S!==null,composing:M,message:F,setMessage:I,onAction:e=>{e===`message`?N(!0):R({kind:`action`,actionId:e})},onSend:()=>void z(),onCancelMessage:()=>N(!1)}):k&&!S?(0,L.jsxs)(L.Fragment,{children:[t&&(0,L.jsx)(`p`,{className:`text-sm text-muted`,children:t}),(0,L.jsx)(K,{node:O.presentation,onRespond:e=>void R(e),busy:_,disabled:!!t}),!t&&!X(O.presentation)&&(0,L.jsx)(`div`,{children:(0,L.jsx)(c,{busy:_,onClick:()=>void R({kind:`cancel`}),children:`Dismiss`})}),_&&(0,L.jsx)(`p`,{role:`status`,className:`text-sm text-muted`,children:`Sending answer… waiting for the host to confirm.`})]}):S?null:O.resolution?(0,L.jsxs)(`p`,{className:`text-sm text-muted`,children:[O.state===`resolved`?`Answered`:`Closed`,` by`,` `,Z(O.resolution.by),` `,u(O.resolution.at),`:`,` `,(0,L.jsx)(`span`,{className:`text-text`,children:O.resolution.summary})]}):(0,L.jsx)(`p`,{className:`text-sm text-muted`,children:O.state===`expired`?`This question expired before it was answered (Pi closed the dialog).`:`This question was canceled.`}),y!==null&&(0,L.jsx)(d,{compact:!0,title:`Answer not delivered`,error:m(y),onRetry:w?()=>void R(w):void 0})]})}function Te({interaction:e,readOnlyReason:t,busy:n,answered:r,composing:i,message:a,setMessage:o,onAction:s,onSend:l,onCancelMessage:d}){let f=Se(e);return(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,L.jsx)(`p`,{className:`text-sm text-muted`,children:f.copy}),e.resolution?(0,L.jsxs)(`p`,{className:`text-sm text-muted`,children:[`Chosen by `,Z(e.resolution.by),` `,u(e.resolution.at),`: `,(0,L.jsx)(`span`,{className:`text-text`,children:e.resolution.summary})]}):!f.answerable||r?null:t?(0,L.jsx)(`p`,{className:`text-sm text-muted`,children:t}):i?(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,L.jsx)(w,{"aria-label":`Message for Pi`,value:a,onChange:e=>o(e.target.value),rows:3,autoFocus:!0,placeholder:`Tell Pi what to do instead`}),(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,L.jsx)(c,{variant:`primary`,busy:n,disabled:!a.trim(),onClick:l,children:`Send message`}),(0,L.jsx)(c,{disabled:n,onClick:d,children:`Cancel`})]})]}):(0,L.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:f.actions.map(e=>(0,L.jsx)(c,{variant:e.tone,busy:n&&e.id===`abort`,disabled:n,onClick:()=>s(e.id),children:e.label},e.id))})]})}function Q(e){if(e.t!==`section`||e.children.length<2)return null;let t=e.children[e.children.length-1];if(t?.t!==`actions`)return null;let n=e.children.slice(0,-1);return n.some(X)?null:{body:{...e,children:n},actions:t}}function Ee(e,t){let n=window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches;e?.scrollIntoView({behavior:n?`auto`:`smooth`,block:t})}function De(e){let[t,n]=(0,P.useState)(!0);return(0,P.useEffect)(()=>{let t=e.current;if(!t||typeof IntersectionObserver>`u`)return;let r=new IntersectionObserver(([e])=>n(!!e?.isIntersecting));return r.observe(t),()=>r.disconnect()},[e]),t}function Oe(e){if(e.t===`markdown`)return e.text;if(e.t===`section`)for(let t of e.children){let e=Oe(t);if(e!==null)return e}return null}function $(e){if(!Q(e))return!1;let t=Oe(e);return t!==null&&(t.length>=400||t.split(`
|
|
4
4
|
`).length>=12)}function ke(e){let t=/^\s*#{1,6}\s+(.+?)\s*(?:\n+|$)/.exec(e);return t?.[1]?{title:t[1],rest:e.slice(t[0].length)}:{title:null,rest:e}}function Ae(e){let t=[],n=!1;for(let r of e.split(`
|
|
5
|
-
`)){/^\s*```/.test(r)&&(n=!n);let e=n?null:/^##\s+(.+?)\s*$/.exec(r);e?.[1]&&t.push({text:e[1],id:O(e[1])})}return t}function je(e,t){let[n,r]=(0,P.useState)(null),[i,a]=(0,P.useState)(null),o=e.join(`|`);(0,P.useEffect)(()=>{if(typeof IntersectionObserver>`u`||!e.length)return;let n=e.map(e=>t.current?.querySelector(`#${CSS.escape(e)}`)).filter(e=>!!e),i=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&r(t.target.id)},{rootMargin:`-56px 0px -70% 0px`});for(let e of n)i.observe(e);let o=()=>a(null);return window.addEventListener(`wheel`,o,{passive:!0}),window.addEventListener(`touchmove`,o,{passive:!0}),window.addEventListener(`keydown`,o),()=>{i.disconnect(),window.removeEventListener(`wheel`,o),window.removeEventListener(`touchmove`,o),window.removeEventListener(`keydown`,o)}},[o,t]);let s=i??n;return(0,P.useEffect)(()=>{let e=t.current;if(e){for(let t of e.querySelectorAll(`h2[data-active]`))delete t.dataset.active;if(s){let t=e.querySelector(`#${CSS.escape(s)}`);t&&(t.dataset.active=`true`)}}},[s,o,t]),[s,a]}function Me({id:e,interaction:t,node:n,onRespond:r,busy:
|
|
6
|
-
//# sourceMappingURL=InteractionCard-
|
|
5
|
+
`)){/^\s*```/.test(r)&&(n=!n);let e=n?null:/^##\s+(.+?)\s*$/.exec(r);e?.[1]&&t.push({text:e[1],id:O(e[1])})}return t}function je(e,t){let[n,r]=(0,P.useState)(null),[i,a]=(0,P.useState)(null),o=e.join(`|`);(0,P.useEffect)(()=>{if(typeof IntersectionObserver>`u`||!e.length)return;let n=e.map(e=>t.current?.querySelector(`#${CSS.escape(e)}`)).filter(e=>!!e),i=new IntersectionObserver(e=>{for(let t of e)t.isIntersecting&&r(t.target.id)},{rootMargin:`-56px 0px -70% 0px`});for(let e of n)i.observe(e);let o=()=>a(null);return window.addEventListener(`wheel`,o,{passive:!0}),window.addEventListener(`touchmove`,o,{passive:!0}),window.addEventListener(`keydown`,o),()=>{i.disconnect(),window.removeEventListener(`wheel`,o),window.removeEventListener(`touchmove`,o),window.removeEventListener(`keydown`,o)}},[o,t]);let s=i??n;return(0,P.useEffect)(()=>{let e=t.current;if(e){for(let t of e.querySelectorAll(`h2[data-active]`))delete t.dataset.active;if(s){let t=e.querySelector(`#${CSS.escape(s)}`);t&&(t.dataset.active=`true`)}}},[s,o,t]),[s,a]}function Me({id:e,interaction:t,node:n,onRespond:r,busy:i,disabled:s,mobile:l,sticky:u,flush:d,className:f}){let p=(0,P.useRef)(null),m=(0,P.useRef)(null),h=(0,P.useRef)(null),_=De(h),[v,y]=(0,P.useState)(!1),b=Q(n),{title:x,rest:w}=ke((b?.body.t===`section`?b.body.children.find(e=>e.t===`markdown`):void 0)?.text??``),T=Ae(w),[D,O]=je(T.map(e=>e.id),p);if(b?.body.t!==`section`)return null;let k=b.actions.actions,j=b.body.children.find(e=>e.t===`section`),M=t.title,N=x??M,F=e=>{y(!1),r({kind:`action`,actionId:e})},I=(e,t)=>e===0||t===`primary`?`primary`:t===`danger`?`danger`:`secondary`,R=!s&&!_,z=`h-auto! min-h-9 min-w-0 py-1.5 text-left leading-tight whitespace-normal!`,B=e=>Ee(e,`start`);return(0,L.jsxs)(`article`,{id:e,"data-testid":`document-interaction`,"aria-label":`Question: ${M}`,className:o(`w-full min-w-0 self-stretch border-t border-border`,f),children:[(0,L.jsxs)(`header`,{className:o(`z-10 flex min-w-0 items-center gap-2 border-b border-border bg-bg px-4 py-2 md:px-6`,u&&(d?`md:sticky md:top-0`:`max-md:static md:sticky md:-top-3`)),children:[(0,L.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-[15px] leading-snug font-semibold md:text-sm`,children:N}),l&&(0,L.jsx)(a,{kind:`interaction`,value:t.state,size:`sm`,className:`[&>span]:sr-only`}),!s&&!_&&(0,L.jsx)(E,{size:`xs`,className:`shrink-0`,onClick:()=>Ee(h.current,`center`),children:`Jump to options ↓`})]}),j&&(0,L.jsx)(`aside`,{className:`mx-4 mt-3 rounded-md bg-warning-soft px-3 py-2 text-sm md:mx-6`,children:(0,L.jsx)(K,{node:j})}),(0,L.jsxs)(`div`,{className:`px-4 py-4 md:grid md:grid-cols-[13rem_minmax(0,1fr)] 2xl:grid-cols-[15rem_minmax(0,1fr)] md:gap-8 md:px-6`,children:[T.length>0&&(0,L.jsx)(`nav`,{"aria-label":`Plan sections`,className:`hidden md:block`,children:(0,L.jsxs)(`ol`,{className:`sticky top-16 flex flex-col gap-0.5 border-l border-border text-sm`,children:[(0,L.jsx)(`li`,{children:(0,L.jsx)(`button`,{type:`button`,className:`-ml-px block w-full truncate border-l-2 border-transparent py-1 pl-3 text-left text-muted hover:text-text`,onClick:()=>B(m.current),children:`Start`})}),T.map(e=>(0,L.jsx)(`li`,{children:(0,L.jsx)(`button`,{type:`button`,"aria-current":D===e.id,className:`-ml-px block w-full truncate border-l-2 border-transparent py-1 pl-3 text-left text-muted hover:text-text aria-[current=true]:border-accent aria-[current=true]:text-text`,onClick:()=>{O(e.id),B(p.current?.querySelector(`#${CSS.escape(e.id)}`)??null)},children:e.text})},e.id))]})}),(0,L.jsx)(`div`,{ref:m,className:`min-w-0 scroll-mt-14`,children:(0,L.jsx)(`div`,{ref:p,className:`sy-prose-compact max-w-[80ch] min-w-0 2xl:max-w-[100ch] min-[1800px]:text-base [&_h2]:scroll-mt-14`,children:(0,L.jsx)(A,{text:w,headingIds:!0,className:`text-inherit`})})})]}),(0,L.jsxs)(`section`,{ref:h,"data-testid":`plan-options`,"aria-label":M,className:`border-t border-border px-4 py-3 md:px-6`,children:[(0,L.jsx)(`p`,{className:`mb-2 text-sm font-medium`,children:M}),!s&&(0,L.jsx)(`div`,{className:`flex min-w-0 flex-col gap-2 md:flex-row md:flex-wrap`,children:k.map((e,t)=>(0,L.jsx)(c,{variant:I(t,e.tone),size:`md`,disabled:i,className:o(z,`md:text-center`),onClick:()=>F(e.id),children:e.label},e.id))}),(0,L.jsx)(E,{size:`xs`,className:`mt-2`,icon:(0,L.jsx)(g,{"aria-hidden":!0,className:`size-3.5`}),onClick:()=>B(m.current),children:`Back to the plan start`})]}),R&&(0,L.jsx)(`div`,{"data-testid":`answer-bar`,className:o(`z-10 flex min-w-0 items-center gap-2 border-t border-border bg-bg px-4 py-2 md:gap-3 md:px-6`,u&&!d?`sticky -bottom-3`:`sticky bottom-0`),children:l?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(C,{label:`Plan start`,icon:(0,L.jsx)(g,{className:`size-4`}),variant:`secondary`,onClick:()=>B(m.current)}),k.length>2?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(c,{variant:`primary`,disabled:i,className:o(z,`flex-1`),onClick:()=>F(k[0].id),children:k[0].label}),(0,L.jsxs)(c,{variant:`secondary`,onClick:()=>y(!0),children:[`More (`,k.length-1,`)`]})]}):k.map((e,t)=>(0,L.jsx)(c,{variant:I(t,e.tone),disabled:i,className:o(z,`flex-1`),onClick:()=>F(e.id),children:e.label},e.id))]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`max-w-[16rem] min-w-0 shrink truncate text-sm font-medium`,title:M,children:M}),(0,L.jsx)(`div`,{className:`grid min-w-0 flex-1 grid-cols-[repeat(auto-fit,minmax(11rem,1fr))] gap-2`,children:k.map((e,t)=>(0,L.jsx)(c,{variant:I(t,e.tone),disabled:i,className:o(z,`w-full md:text-center`),onClick:()=>F(e.id),children:e.label},e.id))}),(0,L.jsx)(C,{label:`Plan start`,icon:(0,L.jsx)(g,{className:`size-4`}),variant:`secondary`,size:`sm`,onClick:()=>B(m.current)})]})}),(0,L.jsx)(S,{open:v,onClose:()=>y(!1),title:M,children:(0,L.jsx)(`div`,{className:`flex flex-col gap-2`,children:k.map((e,t)=>(0,L.jsx)(c,{block:!0,variant:I(t,e.tone),disabled:i,className:z,onClick:()=>F(e.id),children:e.label},e.id))})})]})}export{V as a,H as i,$ as n,N as o,K as r,we as t};
|
|
6
|
+
//# sourceMappingURL=InteractionCard-Yu5wgLC3.js.map
|