@spencerboucher/switchyard 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/README.md +9 -7
  2. package/dist/bridge/pi-model.js +44 -0
  3. package/dist/bridge/switchyard-bridge.js +24 -2
  4. package/dist/bridge/switchyard-terminal.js +146 -4
  5. package/dist/switchyard.mjs +1301 -700
  6. package/package.json +1 -1
  7. package/web-dist/assets/AutomationView-BIW_pO0M.js +2 -0
  8. package/web-dist/assets/AutomationView-BIW_pO0M.js.map +1 -0
  9. package/web-dist/assets/Badge-BiDp7NKI.js +2 -0
  10. package/web-dist/assets/Badge-BiDp7NKI.js.map +1 -0
  11. package/web-dist/assets/InteractionCard-CWxyDv81.js +6 -0
  12. package/web-dist/assets/InteractionCard-CWxyDv81.js.map +1 -0
  13. package/web-dist/assets/{Menu-C4GUY_ym.js → Menu-BDt1bxwz.js} +2 -2
  14. package/web-dist/assets/Menu-BDt1bxwz.js.map +1 -0
  15. package/web-dist/assets/{SegmentedControl-ChdVilXb.js → SegmentedControl-D-2BCZzd.js} +2 -2
  16. package/web-dist/assets/{SegmentedControl-ChdVilXb.js.map → SegmentedControl-D-2BCZzd.js.map} +1 -1
  17. package/web-dist/assets/Tabs-ByiPklAw.js +184 -0
  18. package/web-dist/assets/Tabs-ByiPklAw.js.map +1 -0
  19. package/web-dist/assets/TextArea-BYr88SnV.js +2 -0
  20. package/web-dist/assets/TextArea-BYr88SnV.js.map +1 -0
  21. package/web-dist/assets/attention-Bya8XHKI.js +2 -0
  22. package/web-dist/assets/attention-Bya8XHKI.js.map +1 -0
  23. package/web-dist/assets/automations-DiXKRcnE.js +2 -0
  24. package/web-dist/assets/automations-DiXKRcnE.js.map +1 -0
  25. package/web-dist/assets/board-BrLaJwLJ.js +10 -0
  26. package/web-dist/assets/board-BrLaJwLJ.js.map +1 -0
  27. package/web-dist/assets/c-Cz4nF6n_.js +1 -0
  28. package/web-dist/assets/c-SSSlmE39.js +2 -0
  29. package/web-dist/assets/c-SSSlmE39.js.map +1 -0
  30. package/web-dist/assets/code-DKLO8bzz.js +11 -0
  31. package/web-dist/assets/code-DKLO8bzz.js.map +1 -0
  32. package/web-dist/assets/cpp-Cts1PyIS.js +2 -0
  33. package/web-dist/assets/cpp-Cts1PyIS.js.map +1 -0
  34. package/web-dist/assets/cpp-DzjeI0uH.js +1 -0
  35. package/web-dist/assets/css-BGIxQoYs.js +2 -0
  36. package/web-dist/assets/css-BGIxQoYs.js.map +1 -0
  37. package/web-dist/assets/css-DgaLhXQH.js +1 -0
  38. package/web-dist/assets/describe-DnvH6_fl.js +5 -0
  39. package/web-dist/assets/describe-DnvH6_fl.js.map +1 -0
  40. package/web-dist/assets/diff-woXpYk--.js +2 -0
  41. package/web-dist/assets/diff-woXpYk--.js.map +1 -0
  42. package/web-dist/assets/dist-BE_V9dwJ.js +56 -0
  43. package/web-dist/assets/dist-BE_V9dwJ.js.map +1 -0
  44. package/web-dist/assets/dockerfile-IyjqRm3v.js +2 -0
  45. package/web-dist/assets/dockerfile-IyjqRm3v.js.map +1 -0
  46. package/web-dist/assets/enroll-DUDpbJoB.js +2 -0
  47. package/web-dist/assets/enroll-DUDpbJoB.js.map +1 -0
  48. package/web-dist/assets/github-dark-C-LZuMrd.js +2 -0
  49. package/web-dist/assets/github-dark-C-LZuMrd.js.map +1 -0
  50. package/web-dist/assets/github-light-EUqPIrTm.js +2 -0
  51. package/web-dist/assets/github-light-EUqPIrTm.js.map +1 -0
  52. package/web-dist/assets/go-rLFTqkRN.js +2 -0
  53. package/web-dist/assets/go-rLFTqkRN.js.map +1 -0
  54. package/web-dist/assets/html-BMn1ogTm.js +2 -0
  55. package/web-dist/assets/html-BMn1ogTm.js.map +1 -0
  56. package/web-dist/assets/html-BWDvXlHg.js +1 -0
  57. package/web-dist/assets/index-DvRcMGEe.css +2 -0
  58. package/web-dist/assets/index-vIzH1m8u.js +11 -0
  59. package/web-dist/assets/index-vIzH1m8u.js.map +1 -0
  60. package/web-dist/assets/java-BtIQNnN0.js +2 -0
  61. package/web-dist/assets/java-BtIQNnN0.js.map +1 -0
  62. package/web-dist/assets/java-_ATy9zCa.js +1 -0
  63. package/web-dist/assets/javascript-BzbQS41l.js +2 -0
  64. package/web-dist/assets/javascript-BzbQS41l.js.map +1 -0
  65. package/web-dist/assets/javascript-CpIGwZ_Y.js +1 -0
  66. package/web-dist/assets/json-qhed-kSA.js +2 -0
  67. package/web-dist/assets/json-qhed-kSA.js.map +1 -0
  68. package/web-dist/assets/jsonc-CYpm1nAK.js +2 -0
  69. package/web-dist/assets/jsonc-CYpm1nAK.js.map +1 -0
  70. package/web-dist/assets/jsx-C4yDKi0A.js +1 -0
  71. package/web-dist/assets/jsx-D3KKoC5L.js +2 -0
  72. package/web-dist/assets/jsx-D3KKoC5L.js.map +1 -0
  73. package/web-dist/assets/logic-xb-QF00E.js +2 -0
  74. package/web-dist/assets/logic-xb-QF00E.js.map +1 -0
  75. package/web-dist/assets/lua-DjuecEsk.js +2 -0
  76. package/web-dist/assets/lua-DjuecEsk.js.map +1 -0
  77. package/web-dist/assets/lua-fPRBWD-V.js +1 -0
  78. package/web-dist/assets/{more-syTnSpW3.js → more-BP5x45cs.js} +2 -2
  79. package/web-dist/assets/{more-syTnSpW3.js.map → more-BP5x45cs.js.map} +1 -1
  80. package/web-dist/assets/now--XjJC37b.js +2 -0
  81. package/web-dist/assets/now--XjJC37b.js.map +1 -0
  82. package/web-dist/assets/python-gzcpVVnB.js +2 -0
  83. package/web-dist/assets/python-gzcpVVnB.js.map +1 -0
  84. package/web-dist/assets/ruby-Bx-U2qjP.js +2 -0
  85. package/web-dist/assets/ruby-Bx-U2qjP.js.map +1 -0
  86. package/web-dist/assets/rust-DpiIf5JO.js +2 -0
  87. package/web-dist/assets/rust-DpiIf5JO.js.map +1 -0
  88. package/web-dist/assets/scss-8bKmll0B.js +2 -0
  89. package/web-dist/assets/scss-8bKmll0B.js.map +1 -0
  90. package/web-dist/assets/send-BKjswHxB.js +2 -0
  91. package/web-dist/assets/send-BKjswHxB.js.map +1 -0
  92. package/web-dist/assets/settings-D8T1esWq.js +7 -0
  93. package/web-dist/assets/settings-D8T1esWq.js.map +1 -0
  94. package/web-dist/assets/shared-CZ7fcu_B.js +3 -0
  95. package/web-dist/assets/shared-CZ7fcu_B.js.map +1 -0
  96. package/web-dist/assets/shellscript-CVTB3cr6.js +1 -0
  97. package/web-dist/assets/shellscript-CqHdAlCp.js +2 -0
  98. package/web-dist/assets/shellscript-CqHdAlCp.js.map +1 -0
  99. package/web-dist/assets/sliders-horizontal-DAoirila.js +2 -0
  100. package/web-dist/assets/sliders-horizontal-DAoirila.js.map +1 -0
  101. package/web-dist/assets/sql-CNu3Or2W.js +2 -0
  102. package/web-dist/assets/sql-CNu3Or2W.js.map +1 -0
  103. package/web-dist/assets/sql-CfM2IJm3.js +1 -0
  104. package/web-dist/assets/states--geW2Ntl.js +2 -0
  105. package/web-dist/assets/states--geW2Ntl.js.map +1 -0
  106. package/web-dist/assets/swift-CyEgAFGc.js +2 -0
  107. package/web-dist/assets/swift-CyEgAFGc.js.map +1 -0
  108. package/web-dist/assets/terminal-login-BJxV78au.js +2 -0
  109. package/web-dist/assets/terminal-login-BJxV78au.js.map +1 -0
  110. package/web-dist/assets/toml-CcmNWLt0.js +2 -0
  111. package/web-dist/assets/toml-CcmNWLt0.js.map +1 -0
  112. package/web-dist/assets/tsx-BOvsFOI6.js +2 -0
  113. package/web-dist/assets/tsx-BOvsFOI6.js.map +1 -0
  114. package/web-dist/assets/tsx-CGosfAUg.js +1 -0
  115. package/web-dist/assets/typescript-Bb1J8qyy.js +1 -0
  116. package/web-dist/assets/typescript-j_1H8WHN.js +2 -0
  117. package/web-dist/assets/typescript-j_1H8WHN.js.map +1 -0
  118. package/web-dist/assets/useNow-jxdoOC_1.js +2 -0
  119. package/web-dist/assets/{useNow-BQpDYijR.js.map → useNow-jxdoOC_1.js.map} +1 -1
  120. package/web-dist/assets/xml-DuKfbPI6.js +1 -0
  121. package/web-dist/assets/xml-WY0zc4PG.js +2 -0
  122. package/web-dist/assets/xml-WY0zc4PG.js.map +1 -0
  123. package/web-dist/assets/yaml-DDA_XMNu.js +1 -0
  124. package/web-dist/assets/yaml-DijMHRDA.js +2 -0
  125. package/web-dist/assets/yaml-DijMHRDA.js.map +1 -0
  126. package/web-dist/index.html +4 -3
  127. package/web-dist/sw.js +1 -1
  128. package/web-dist/sw.js.map +1 -1
  129. package/web-dist/assets/AutomationView-CFohp0SQ.js +0 -2
  130. package/web-dist/assets/AutomationView-CFohp0SQ.js.map +0 -1
  131. package/web-dist/assets/InteractionCard-B-xmpTNG.js +0 -4
  132. package/web-dist/assets/InteractionCard-B-xmpTNG.js.map +0 -1
  133. package/web-dist/assets/Markdown-jXkvZeRp.js +0 -31
  134. package/web-dist/assets/Markdown-jXkvZeRp.js.map +0 -1
  135. package/web-dist/assets/Menu-C4GUY_ym.js.map +0 -1
  136. package/web-dist/assets/Overlay--v0ur2lj.js +0 -2
  137. package/web-dist/assets/Overlay--v0ur2lj.js.map +0 -1
  138. package/web-dist/assets/TextArea-BsQHOQMe.js +0 -2
  139. package/web-dist/assets/TextArea-BsQHOQMe.js.map +0 -1
  140. package/web-dist/assets/attention-q6_xlnT4.js +0 -2
  141. package/web-dist/assets/attention-q6_xlnT4.js.map +0 -1
  142. package/web-dist/assets/automations-CyA83OAD.js +0 -2
  143. package/web-dist/assets/automations-CyA83OAD.js.map +0 -1
  144. package/web-dist/assets/board-BFvNcFhk.js +0 -10
  145. package/web-dist/assets/board-BFvNcFhk.js.map +0 -1
  146. package/web-dist/assets/code-DavnmlQN.js +0 -8
  147. package/web-dist/assets/code-DavnmlQN.js.map +0 -1
  148. package/web-dist/assets/describe-BirsjlUl.js +0 -5
  149. package/web-dist/assets/describe-BirsjlUl.js.map +0 -1
  150. package/web-dist/assets/dist-C-h8FC-n.js +0 -56
  151. package/web-dist/assets/dist-C-h8FC-n.js.map +0 -1
  152. package/web-dist/assets/enroll-C7UBC20s.js +0 -2
  153. package/web-dist/assets/enroll-C7UBC20s.js.map +0 -1
  154. package/web-dist/assets/index-ByiuDoG0.css +0 -2
  155. package/web-dist/assets/index-IdzOP9GE.js +0 -11
  156. package/web-dist/assets/index-IdzOP9GE.js.map +0 -1
  157. package/web-dist/assets/logic-D_Eq9DMW.js +0 -2
  158. package/web-dist/assets/logic-D_Eq9DMW.js.map +0 -1
  159. package/web-dist/assets/now-BqsLS-tK.js +0 -2
  160. package/web-dist/assets/now-BqsLS-tK.js.map +0 -1
  161. package/web-dist/assets/settings-DRj7UPtP.js +0 -8
  162. package/web-dist/assets/settings-DRj7UPtP.js.map +0 -1
  163. package/web-dist/assets/sliders-horizontal-S3tmwxsP.js +0 -2
  164. package/web-dist/assets/sliders-horizontal-S3tmwxsP.js.map +0 -1
  165. package/web-dist/assets/states-DrTQuYXw.js +0 -2
  166. package/web-dist/assets/states-DrTQuYXw.js.map +0 -1
  167. package/web-dist/assets/useNow-BQpDYijR.js +0 -2
@@ -1 +0,0 @@
1
- {"version":3,"file":"Menu-C4GUY_ym.js","names":["__iconData","__iconData","useState","useId","useRef","__toESM","require_react","require_jsx_runtime","cn","Check","__iconData$2","ArrowDown","createLucideIcon","__iconData$1","ChevronDown","__iconData","PanelRightOpen","import_react","import_jsx_runtime","Menu","open","setOpen","id","btnRef","menuRef","focusItem","focusMenuItem","dir","onDoc","close","refocus","trigger","o","label","align","items","item","i","els","menu","idx","next"],"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-down.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/chevron-down.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/panel-right-open.mjs","../../src/components/ui/Menu.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-down\",\n size: 24,\n node: [\n [\"path\", { d: \"M12 5v14\", key: \"s699le\" }],\n [\"path\", { d: \"m19 12-7 7-7-7\", key: \"1idqje\" }]\n ]\n};\n__iconData.node;\nconst ArrowDown = createLucideIcon(__iconData);\n\nexport { __iconData, ArrowDown as default };\n//# sourceMappingURL=arrow-down.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: \"chevron-down\",\n size: 24,\n node: [[\"path\", { d: \"m6 9 6 6 6-6\", key: \"qrunsl\" }]]\n};\n__iconData.node;\nconst ChevronDown = createLucideIcon(__iconData);\n\nexport { __iconData, ChevronDown as default };\n//# sourceMappingURL=chevron-down.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: \"panel-right-open\",\n size: 24,\n node: [\n [\"rect\", { width: \"18\", height: \"18\", x: \"3\", y: \"3\", rx: \"2\", key: \"afitv7\" }],\n [\"path\", { d: \"M15 3v18\", key: \"14nvp0\" }],\n [\"path\", { d: \"m10 15-3-3 3-3\", key: \"1pgupc\" }]\n ]\n};\n__iconData.node;\nconst PanelRightOpen = createLucideIcon(__iconData);\n\nexport { __iconData, PanelRightOpen as default };\n//# sourceMappingURL=panel-right-open.mjs.map\n","import { Check } from \"lucide-react\";\nimport { type ReactNode, useEffect, useId, useRef, useState } from \"react\";\nimport { cn } from \"../../lib/cn\";\n\nexport interface MenuItem {\n id: string;\n label: string;\n icon?: ReactNode;\n onSelect: () => void;\n danger?: boolean;\n disabled?: boolean;\n /** Short explanation shown under the label (e.g. why it is disabled). */\n hint?: string;\n /** A radio or checkbox item shows a check mark when `checked`. */\n kind?: \"radio\" | \"checkbox\";\n checked?: boolean;\n}\n\n/** A non-interactive label above a group of items. */\nexport interface MenuHeading {\n id: string;\n heading: string;\n}\n\nexport interface MenuProps {\n /** Render the trigger; spread the given props onto a button. */\n trigger: (props: {\n ref: React.Ref<HTMLButtonElement>;\n onClick: () => void;\n onKeyDown: (e: React.KeyboardEvent) => void;\n \"aria-haspopup\": \"menu\";\n \"aria-expanded\": boolean;\n \"aria-controls\": string;\n }) => ReactNode;\n items: (MenuItem | MenuHeading | \"separator\")[];\n align?: \"start\" | \"end\";\n /** Accessible name of the menu. */\n label: string;\n}\n\n/** Popup menu with arrow-key navigation, Escape and outside click to close. */\nexport function Menu({ trigger, items, align = \"end\", label }: MenuProps) {\n const [open, setOpen] = useState(false);\n const id = useId();\n const btnRef = useRef<HTMLButtonElement>(null);\n const menuRef = useRef<HTMLDivElement>(null);\n\n const focusItem = (dir: 1 | -1 | \"first\" | \"last\") => focusMenuItem(menuRef.current, dir);\n\n useEffect(() => {\n if (!open) return;\n requestAnimationFrame(() => focusMenuItem(menuRef.current, \"first\"));\n const onDoc = (e: PointerEvent) => {\n if (\n !menuRef.current?.contains(e.target as Node) &&\n !btnRef.current?.contains(e.target as Node)\n ) {\n setOpen(false);\n }\n };\n document.addEventListener(\"pointerdown\", onDoc);\n return () => document.removeEventListener(\"pointerdown\", onDoc);\n }, [open]);\n\n const close = (refocus = true) => {\n setOpen(false);\n if (refocus) btnRef.current?.focus();\n };\n\n return (\n <div className=\"relative inline-flex\">\n {trigger({\n ref: btnRef,\n onClick: () => setOpen((o) => !o),\n onKeyDown: (e) => {\n if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n e.preventDefault();\n setOpen(true);\n }\n },\n \"aria-haspopup\": \"menu\",\n \"aria-expanded\": open,\n \"aria-controls\": id,\n })}\n {open && (\n <div\n ref={menuRef}\n id={id}\n role=\"menu\"\n aria-label={label}\n tabIndex={-1}\n className={cn(\n \"absolute top-full z-40 mt-1 min-w-48 max-w-[min(20rem,calc(100vw-1rem))] rounded-lg border border-border bg-surface py-1 shadow-pop\",\n align === \"end\" ? \"right-0\" : \"left-0\",\n )}\n onKeyDown={(e) => {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n focusItem(1);\n } else if (e.key === \"ArrowUp\") {\n e.preventDefault();\n focusItem(-1);\n } else if (e.key === \"Home\") {\n e.preventDefault();\n focusItem(\"first\");\n } else if (e.key === \"End\") {\n e.preventDefault();\n focusItem(\"last\");\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n e.stopPropagation();\n close();\n } else if (e.key === \"Tab\") {\n close(false);\n }\n }}\n >\n {items.map((item, i) =>\n item === \"separator\" ? (\n // biome-ignore lint/suspicious/noArrayIndexKey: separators have no identity\n <hr key={`sep-${i}`} className=\"my-1 border-t border-border\" />\n ) : \"heading\" in item ? (\n <div\n key={item.id}\n role=\"presentation\"\n className=\"px-3 pt-1.5 pb-1 text-xs font-medium text-muted\"\n >\n {item.heading}\n </div>\n ) : (\n // biome-ignore lint/a11y/useAriaPropsSupportedByRole: aria-checked is only set with the menuitemradio/menuitemcheckbox roles\n <button\n key={item.id}\n type=\"button\"\n role={\n item.kind === \"radio\"\n ? \"menuitemradio\"\n : item.kind === \"checkbox\"\n ? \"menuitemcheckbox\"\n : \"menuitem\"\n }\n aria-checked={item.kind ? !!item.checked : undefined}\n disabled={item.disabled}\n className={cn(\n \"tap flex w-full items-start gap-2 px-3 py-2 text-left text-sm hover:bg-surface-2 focus:bg-surface-2 focus:outline-none disabled:opacity-55\",\n item.danger ? \"text-danger\" : \"text-text\",\n )}\n onClick={() => {\n close();\n item.onSelect();\n }}\n >\n {item.kind ? (\n <span aria-hidden className=\"mt-0.5 size-4 shrink-0\">\n {item.checked && <Check className=\"size-4\" />}\n </span>\n ) : (\n item.icon && <span className=\"mt-0.5 shrink-0\">{item.icon}</span>\n )}\n <span className=\"min-w-0\">\n <span className=\"block\">{item.label}</span>\n {item.hint && <span className=\"block text-xs text-muted\">{item.hint}</span>}\n </span>\n </button>\n ),\n )}\n </div>\n )}\n </div>\n );\n}\n\nfunction focusMenuItem(menu: HTMLElement | null, dir: 1 | -1 | \"first\" | \"last\"): void {\n const els = [\n ...(menu?.querySelectorAll<HTMLElement>('[role^=\"menuitem\"]:not([disabled])') ?? []),\n ];\n if (els.length === 0) return;\n const idx = els.indexOf(document.activeElement as HTMLElement);\n let next = 0;\n if (dir === \"first\") next = 0;\n else if (dir === \"last\") next = els.length - 1;\n else next = (idx + dir + els.length) % els.length;\n els[next]!.focus();\n}\n"],"ignoreList":[0,1,2],"mappings":"A,gJASA,IAAMA,EAAa,CACjB,KAAM,aACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAS,CAAC,EACzC,CAAC,OAAQ,CAAE,EAAG,iBAAkB,IAAK,QAAS,CAAC,CACjD,CACF,EACAA,EAAW,KACX,IAAMW,EAAYC,EAAiBZ,CAAU,ECTvCC,EAAa,CACjB,KAAM,eACN,KAAM,GACN,KAAM,CAAC,CAAC,OAAQ,CAAE,EAAG,eAAgB,IAAK,QAAS,CAAC,CAAC,CACvD,EACAA,EAAW,KACX,IAAMa,EAAcF,EAAiBX,CAAU,ECNzCc,EAAa,CACjB,KAAM,mBACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,MAAO,KAAM,OAAQ,KAAM,EAAG,IAAK,EAAG,IAAK,GAAI,IAAK,IAAK,QAAS,CAAC,EAC9E,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAS,CAAC,EACzC,CAAC,OAAQ,CAAE,EAAG,iBAAkB,IAAK,QAAS,CAAC,CACjD,CACF,EACAA,EAAW,KACX,IAAMC,EAAiBJ,EAAiBG,CAAU,E,iBCsBlD,SAAgBI,EAAK,CAAE,UAAS,QAA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ACzCA,EAAK,OAAQ,EAAAlB,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,2BAA4B,SAAAkB,EAAK,IAAW,CAAA,CACtE,CACA,CAAA,CAAA,CA/BD,EAAAA,EAAK,EA+BJ,CAEZ,CACG,CAAA,CAEJ,C,EAET,CAEA,SAASV,EAAc,EAA0B,EAAsC,CACrF,IAAMY,EAAM,CACV,GAAIC,GAAM,iBAA8B,oCAAoC,GAAK,CAAC,CACpF,EACA,GAAID,EAAI,SAAW,EAAG,OACtB,IAAME,EAAMF,EAAI,QAAQ,SAAS,aAA4B,EACzDG,EAAO,EACX,AAEKA,EAFDd,IAAQ,QAAgB,EACnBA,IAAQ,OAAeW,EAAI,OAAS,GAChCE,EAAMb,EAAMW,EAAI,QAAUA,EAAI,OAC3CA,EAAIG,EAAK,CAAE,MAAM,CACnB,C"}
@@ -1,2 +0,0 @@
1
- import{_ as e,m as t,t as n}from"./jsx-runtime-D13aM9HY.js";import{h as r}from"./states-DrTQuYXw.js";import{U as i,g as a}from"./index-IdzOP9GE.js";var o=i(),s=e(t(),1),c=n(),l=(0,s.forwardRef)(function({label:e,icon:t,variant:n=`ghost`,size:i=`md`,className:a,type:o,...s},l){return(0,c.jsx)(`button`,{ref:l,type:o??`button`,"aria-label":e,title:e,className:r(`tap inline-flex shrink-0 items-center justify-center rounded-md border transition-colors`,`disabled:opacity-55 disabled:pointer-events-none`,i===`sm`?`size-8`:`size-9`,n===`ghost`&&`border-transparent text-muted hover:bg-surface-2 hover:text-text`,n===`secondary`&&`border-border bg-surface text-text hover:bg-surface-2`,n===`danger`&&`border-transparent text-danger hover:bg-danger-soft`,a),...s,children:t})}),u=`a[href], area[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), iframe, [tabindex]:not([tabindex="-1"]), [contenteditable="true"]`;function d(e){return[...e.querySelectorAll(u)].filter(e=>!e.hasAttribute(`inert`)&&e.getClientRects().length>0)}function f(e,t,n,r){let i=(0,s.useRef)(n);i.current=n;let a=(0,s.useRef)(null),o=(0,s.useRef)(!1);t&&!o.current&&typeof document<`u`&&(a.current=document.activeElement),o.current=t,(0,s.useEffect)(()=>{if(!t)return;let n=e.current;if(!n)return;let o=a.current,s=o&&!n.contains(o)?o:document.activeElement,c=r?.current??d(n)[0]??n,l=requestAnimationFrame(()=>{(r?.current||!n.contains(document.activeElement))&&c.focus({preventScroll:!0})}),u=e=>{if(e.key===`Escape`&&i.current){e.stopPropagation(),i.current();return}if(e.key!==`Tab`)return;let t=d(n);if(t.length===0){e.preventDefault(),n.focus();return}let r=t[0],a=t[t.length-1],o=document.activeElement;e.shiftKey&&(o===r||!n.contains(o))?(e.preventDefault(),a.focus()):e.shiftKey||o!==a&&n.contains(o)||(e.preventDefault(),r.focus())};return n.addEventListener(`keydown`,u),()=>{cancelAnimationFrame(l),n.removeEventListener(`keydown`,u),s&&document.contains(s)&&s.focus({preventScroll:!0})}},[t,e,r])}function p(e){(0,s.useEffect)(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=t}},[e])}function m({placement:e,open:t,onClose:n,title:i,description:u,children:d,footer:m,initialFocus:h,dismissOnBackdrop:g=!0,headerActions:_,className:v,style:y}){let b=(0,s.useRef)(null),x=(0,s.useId)(),S=(0,s.useId)();return f(b,t,n,h),p(t),t?(0,o.createPortal)((0,c.jsxs)(`div`,{className:r(`fixed inset-0 z-50 flex`,e===`right`&&`justify-end`,e===`bottom`&&`items-end`,e===`center`&&`items-center justify-center p-4`),children:[(0,c.jsx)(`div`,{className:`absolute inset-0 bg-overlay`,"aria-hidden":!0,onClick:g?n:void 0}),(0,c.jsxs)(`div`,{ref:b,role:`dialog`,"aria-modal":`true`,"aria-labelledby":x,"aria-describedby":u?S:void 0,tabIndex:-1,style:y,className:r(`relative flex flex-col bg-surface text-text shadow-pop outline-none`,e===`right`&&`h-full max-w-full border-l border-border safe-pt safe-pb`,e===`bottom`&&`max-h-[90dvh] w-full rounded-t-xl border-t border-border safe-pb`,e===`center`&&`max-h-[min(90dvh,720px)] w-full max-w-lg rounded-xl border border-border`,v),children:[e===`bottom`&&(0,c.jsx)(`div`,{className:`flex justify-center pt-2`,"aria-hidden":!0,children:(0,c.jsx)(`div`,{className:`h-1 w-10 rounded-full bg-border-strong`})}),(0,c.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-border px-4 py-3`,children:[(0,c.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,c.jsx)(`h2`,{id:x,className:`text-base font-semibold leading-6`,children:i}),u&&(0,c.jsx)(`p`,{id:S,className:`text-sm text-muted`,children:u})]}),_,(0,c.jsx)(l,{label:`Close`,icon:(0,c.jsx)(a,{className:`size-4`}),onClick:n})]}),(0,c.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 py-3`,children:d}),m&&(0,c.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 border-t border-border px-4 py-3`,children:m})]})]}),document.body):null}function h({width:e=520,...t}){return(0,c.jsx)(m,{...t,placement:`right`,style:{width:`min(${e}px, 100vw)`}})}function g(e){return(0,c.jsx)(m,{...e,placement:`bottom`})}function _(e){return(0,c.jsx)(m,{...e,placement:`center`})}export{l as i,h as n,g as r,_ as t};
2
- //# sourceMappingURL=Overlay--v0ur2lj.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Overlay--v0ur2lj.js","names":["forwardRef","useRef","useRef","useId","createPortal","__toESM","require_react","require_jsx_runtime","cn","require_react_dom","X","import_react_dom","import_react","import_jsx_runtime","IconButton","rest","type","label","size","variant","className","icon","FOCUSABLE","focusableWithin","root","el","useFocusTrap","escRef","onEscape","triggerRef","wasActive","active","ref","captured","previous","target","initialFocus","raf","onKey","items","first","last","activeEl","useScrollLock","prev","Surface","titleId","descId","open","onClose","placement","dismissOnBackdrop","description","title","headerActions","footer","Drawer","props","width","Sheet","Dialog"],"sources":["../../src/components/ui/IconButton.tsx","../../src/components/ui/useFocusTrap.ts","../../src/components/ui/Overlay.tsx"],"sourcesContent":["import { type ButtonHTMLAttributes, forwardRef, type ReactNode } from \"react\";\nimport { cn } from \"../../lib/cn\";\n\nexport interface IconButtonProps\n extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"aria-label\"> {\n /** Accessible name (also the tooltip). Required: icon-only controls need a label. */\n label: string;\n icon: ReactNode;\n variant?: \"ghost\" | \"secondary\" | \"danger\";\n size?: \"sm\" | \"md\";\n}\n\nexport const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(function IconButton(\n { label, icon, variant = \"ghost\", size = \"md\", className, type, ...rest },\n ref,\n) {\n return (\n <button\n ref={ref}\n type={type ?? \"button\"}\n aria-label={label}\n title={label}\n className={cn(\n \"tap inline-flex shrink-0 items-center justify-center rounded-md border transition-colors\",\n \"disabled:opacity-55 disabled:pointer-events-none\",\n size === \"sm\" ? \"size-8\" : \"size-9\",\n variant === \"ghost\" && \"border-transparent text-muted hover:bg-surface-2 hover:text-text\",\n variant === \"secondary\" && \"border-border bg-surface text-text hover:bg-surface-2\",\n variant === \"danger\" && \"border-transparent text-danger hover:bg-danger-soft\",\n className,\n )}\n {...rest}\n >\n {icon}\n </button>\n );\n});\n","import { type RefObject, useEffect, useRef } from \"react\";\n\nconst FOCUSABLE =\n 'a[href], area[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), iframe, [tabindex]:not([tabindex=\"-1\"]), [contenteditable=\"true\"]';\n\nexport function focusableWithin(root: HTMLElement): HTMLElement[] {\n return [...root.querySelectorAll<HTMLElement>(FOCUSABLE)].filter(\n (el) => !el.hasAttribute(\"inert\") && el.getClientRects().length > 0,\n );\n}\n\n/**\n * Modal focus management: moves focus into `ref` when `active`, keeps Tab\n * inside it, closes on Escape, and returns focus to the element that had it\n * (the trigger) when deactivated.\n */\nexport function useFocusTrap(\n ref: RefObject<HTMLElement | null>,\n active: boolean,\n onEscape?: () => void,\n initialFocus?: RefObject<HTMLElement | null>,\n): void {\n const escRef = useRef(onEscape);\n escRef.current = onEscape;\n // Remember the trigger while rendering the opening frame: by the time effects run, an\n // `autoFocus` field inside the surface has already taken focus.\n const triggerRef = useRef<HTMLElement | null>(null);\n const wasActive = useRef(false);\n if (active && !wasActive.current && typeof document !== \"undefined\") {\n triggerRef.current = document.activeElement as HTMLElement | null;\n }\n wasActive.current = active;\n useEffect(() => {\n if (!active) return;\n const root = ref.current;\n if (!root) return;\n const captured = triggerRef.current;\n const previous =\n captured && !root.contains(captured)\n ? captured\n : (document.activeElement as HTMLElement | null);\n const target = initialFocus?.current ?? focusableWithin(root)[0] ?? root;\n // Defer so the element is laid out (portals, transitions).\n // An `autoFocus` field inside keeps its focus unless an explicit initial focus was given.\n const raf = requestAnimationFrame(() => {\n if (!initialFocus?.current && root.contains(document.activeElement)) return;\n target.focus({ preventScroll: true });\n });\n const onKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\" && escRef.current) {\n e.stopPropagation();\n escRef.current();\n return;\n }\n if (e.key !== \"Tab\") return;\n const items = focusableWithin(root);\n if (items.length === 0) {\n e.preventDefault();\n root.focus();\n return;\n }\n const first = items[0]!;\n const last = items[items.length - 1]!;\n const activeEl = document.activeElement;\n if (e.shiftKey && (activeEl === first || !root.contains(activeEl))) {\n e.preventDefault();\n last.focus();\n } else if (!e.shiftKey && (activeEl === last || !root.contains(activeEl))) {\n e.preventDefault();\n first.focus();\n }\n };\n root.addEventListener(\"keydown\", onKey);\n return () => {\n cancelAnimationFrame(raf);\n root.removeEventListener(\"keydown\", onKey);\n if (previous && document.contains(previous)) previous.focus({ preventScroll: true });\n };\n }, [active, ref, initialFocus]);\n}\n\n/** Lock body scroll while a modal surface is open. */\nexport function useScrollLock(active: boolean): void {\n useEffect(() => {\n if (!active) return;\n const prev = document.body.style.overflow;\n document.body.style.overflow = \"hidden\";\n return () => {\n document.body.style.overflow = prev;\n };\n }, [active]);\n}\n","import { X } from \"lucide-react\";\nimport { type ReactNode, type RefObject, useId, useRef } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { cn } from \"../../lib/cn\";\nimport { IconButton } from \"./IconButton\";\nimport { useFocusTrap, useScrollLock } from \"./useFocusTrap\";\n\nexport interface OverlayProps {\n open: boolean;\n onClose: () => void;\n /** Visible heading; also the accessible name. */\n title: ReactNode;\n /** Accessible description shown under the title. */\n description?: ReactNode;\n children?: ReactNode;\n /** Sticky footer (actions). */\n footer?: ReactNode;\n /** Element to focus first (defaults to the first focusable). */\n initialFocus?: RefObject<HTMLElement | null>;\n /** Close when the backdrop is clicked (default true). */\n dismissOnBackdrop?: boolean;\n /** Extra header controls before the close button. */\n headerActions?: ReactNode;\n className?: string;\n}\n\ntype Placement = \"right\" | \"bottom\" | \"center\";\n\nfunction Surface({\n placement,\n open,\n onClose,\n title,\n description,\n children,\n footer,\n initialFocus,\n dismissOnBackdrop = true,\n headerActions,\n className,\n style,\n}: OverlayProps & { placement: Placement; style?: React.CSSProperties }) {\n const ref = useRef<HTMLDivElement>(null);\n const titleId = useId();\n const descId = useId();\n useFocusTrap(ref, open, onClose, initialFocus);\n useScrollLock(open);\n if (!open) return null;\n return createPortal(\n <div\n className={cn(\n \"fixed inset-0 z-50 flex\",\n placement === \"right\" && \"justify-end\",\n placement === \"bottom\" && \"items-end\",\n placement === \"center\" && \"items-center justify-center p-4\",\n )}\n >\n <div\n className=\"absolute inset-0 bg-overlay\"\n aria-hidden\n onClick={dismissOnBackdrop ? onClose : undefined}\n />\n <div\n ref={ref}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={titleId}\n aria-describedby={description ? descId : undefined}\n tabIndex={-1}\n style={style}\n className={cn(\n \"relative flex flex-col bg-surface text-text shadow-pop outline-none\",\n placement === \"right\" && \"h-full max-w-full border-l border-border safe-pt safe-pb\",\n placement === \"bottom\" &&\n \"max-h-[90dvh] w-full rounded-t-xl border-t border-border safe-pb\",\n placement === \"center\" &&\n \"max-h-[min(90dvh,720px)] w-full max-w-lg rounded-xl border border-border\",\n className,\n )}\n >\n {placement === \"bottom\" && (\n <div className=\"flex justify-center pt-2\" aria-hidden>\n <div className=\"h-1 w-10 rounded-full bg-border-strong\" />\n </div>\n )}\n <div className=\"flex items-start gap-2 border-b border-border px-4 py-3\">\n <div className=\"min-w-0 flex-1\">\n <h2 id={titleId} className=\"text-base font-semibold leading-6\">\n {title}\n </h2>\n {description && (\n <p id={descId} className=\"text-sm text-muted\">\n {description}\n </p>\n )}\n </div>\n {headerActions}\n <IconButton label=\"Close\" icon={<X className=\"size-4\" />} onClick={onClose} />\n </div>\n <div className=\"min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 py-3\">\n {children}\n </div>\n {footer && (\n <div className=\"flex flex-wrap items-center justify-end gap-2 border-t border-border px-4 py-3\">\n {footer}\n </div>\n )}\n </div>\n </div>,\n document.body,\n );\n}\n\nexport interface DrawerProps extends OverlayProps {\n /** Width in px (default 520, the task drawer width). Never wider than the viewport. */\n width?: number;\n}\n\n/** Right-side drawer with focus trap, Escape to close, and focus returned to the trigger. */\nexport function Drawer({ width = 520, ...props }: DrawerProps) {\n return <Surface {...props} placement=\"right\" style={{ width: `min(${width}px, 100vw)` }} />;\n}\n\n/** Bottom sheet for mobile; same accessibility behavior as Drawer. */\nexport function Sheet(props: OverlayProps) {\n return <Surface {...props} placement=\"bottom\" />;\n}\n\n/** Centered modal dialog. */\nexport function Dialog(props: OverlayProps) {\n return <Surface {...props} placement=\"center\" />;\n}\n"],"mappings":"A,+KAYac,GAAA,EAAad,EAAAA,WAAAA,CAA+C,SACvE,CAAE,QAAO,OAAM,UAAU,QAAS,OAAO,KAAM,YAAW,OAAM,GAAGe,GACnE,EACA,CACA,OACE,EAAAF,EAAA,IAAA,CAAC,SAAD,CACO,MACL,KAAMG,GAAQ,SACd,aAAYC,EACZ,MAAOA,EACP,UAAWT,EACT,2FACA,mDACAU,IAAS,KAAO,SAAW,SAC3BC,IAAY,SAAW,mEACvBA,IAAY,aAAe,wDAC3BA,IAA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AAA5C,EAAA,IAAA,CAACgC,EAAD,CAAS,GAAIY,EAAO,UAAU,QAAQ,MAAO,CAAE,MAAO,OAAOC,EAAM,WAAY,CAAI,CAAA,CAC5F,CAGA,SAAgBC,EAAM,EAAqB,CACzC,OAAO,EAAA9C,EAAA,IAAA,CAACgC,EAAD,CAAS,GAAIY,EAAO,UAAU,QAAU,CAAA,CACjD,CAGA,SAAgBG,EAAO,EAAqB,CAC1C,OAAO,EAAA/C,EAAA,IAAA,CAACgC,EAAD,CAAS,GAAIY,EAAO,UAAU,QAAU,CAAA,CACjD,C"}
@@ -1,2 +0,0 @@
1
- import{_ as e,m as t,t as n}from"./jsx-runtime-D13aM9HY.js";import{h as r}from"./states-DrTQuYXw.js";var i=e(t(),1),a=n(),o=(0,i.forwardRef)(function({maxHeight:e=`33vh`,minRows:t=1,className:n,value:o,style:s,...c},l){let u=(0,i.useRef)(null),d=(0,i.useCallback)(e=>{u.current=e,typeof l==`function`?l(e):l&&(l.current=e)},[l]);return(0,i.useLayoutEffect)(()=>{let e=u.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight+(e.offsetHeight-e.clientHeight)}px`)},[o]),(0,a.jsx)(`textarea`,{ref:d,rows:t,value:o,style:{maxHeight:e,...s},className:r(`block w-full resize-none overflow-y-auto rounded-md border border-border bg-surface px-3 py-2 text-base text-text placeholder:text-subtle md:text-sm`,`focus:border-accent focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-0`,n),...c})}),s=(0,i.forwardRef)(function({className:e,...t},n){return(0,a.jsx)(`input`,{ref:n,className:r(`tap block h-9 w-full rounded-md border border-border bg-surface px-3 text-base text-text placeholder:text-subtle md:text-sm`,`focus:border-accent focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-0`,e),...t})});export{s as n,o as t};
2
- //# sourceMappingURL=TextArea-BsQHOQMe.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TextArea-BsQHOQMe.js","names":["forwardRef","useRef","useCallback","__toESM","require_react","require_jsx_runtime","cn","import_react","import_jsx_runtime","TextArea","rest","inner","setRef","el","ref","value","minRows","style","className","TextInput"],"sources":["../../src/components/ui/TextArea.tsx"],"sourcesContent":["import {\n forwardRef,\n type TextareaHTMLAttributes,\n useCallback,\n useLayoutEffect,\n useRef,\n} from \"react\";\nimport { cn } from \"../../lib/cn\";\n\nexport interface TextAreaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {\n /** Max height before scrolling internally (CSS length; default \"33vh\"). */\n maxHeight?: string;\n /** Minimum rows (default 1). */\n minRows?: number;\n}\n\n/** Auto-growing textarea that scrolls internally past `maxHeight`. */\nexport const TextArea = forwardRef<HTMLTextAreaElement, TextAreaProps>(function TextArea(\n { maxHeight = \"33vh\", minRows = 1, className, value, style, ...rest },\n ref,\n) {\n const inner = useRef<HTMLTextAreaElement | null>(null);\n const setRef = useCallback(\n (el: HTMLTextAreaElement | null) => {\n inner.current = el;\n if (typeof ref === \"function\") ref(el);\n else if (ref) ref.current = el;\n },\n [ref],\n );\n // biome-ignore lint/correctness/useExhaustiveDependencies: re-measure when the value changes\n useLayoutEffect(() => {\n const el = inner.current;\n if (!el) return;\n el.style.height = \"auto\";\n el.style.height = `${el.scrollHeight + (el.offsetHeight - el.clientHeight)}px`;\n }, [value]);\n return (\n <textarea\n ref={setRef}\n rows={minRows}\n value={value}\n style={{ maxHeight, ...style }}\n className={cn(\n \"block w-full resize-none overflow-y-auto rounded-md border border-border bg-surface px-3 py-2 text-base text-text placeholder:text-subtle md:text-sm\",\n \"focus:border-accent focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-0\",\n className,\n )}\n {...rest}\n />\n );\n});\n\n/** Single-line input with the same styling. */\nexport const TextInput = forwardRef<HTMLInputElement, React.InputHTMLAttributes<HTMLInputElement>>(\n function TextInput({ className, ...rest }, ref) {\n return (\n <input\n ref={ref}\n className={cn(\n \"tap block h-9 w-full rounded-md border border-border bg-surface px-3 text-base text-text placeholder:text-subtle md:text-sm\",\n \"focus:border-accent focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-0\",\n className,\n )}\n {...rest}\n />\n );\n },\n);\n"],"mappings":"A,0HAiBaS,GAAA,EAAWT,EAAAA,WAAAA,CAA+C,SACrE,CAAE,YAAY,OAAQ,UAAU,EAAG,YAAW,QAAO,QAAO,GAAGU,GAC/D,EACA,CACA,IAAMC,GAAA,EAAQV,EAAAA,OAAAA,CAAmC,IAAI,EAC/CW,GAAA,EAASV,EAAAA,YAAAA,CACZ,GAAmC,CAClC,EAAM,QAAUW,EACZ,OAAOC,GAAQ,WAAYA,EAAID,CAAE,EAC5BC,IAAK,EAAI,QAAUD,EAC9B,EACA,CAACC,CAAG,CACN,EAQA,OANA,EAAAP,EAAA,gBAAA,KAAsB,CACpB,IAAMM,EAAKF,EAAM,QACZE,IACL,EAAG,MAAM,OAAS,OAClB,EAAG,MAAM,OAAS,GAAGA,EAAG,cAAgBA,EAAG,aAAeA,EAAG,cAAc,IAC7E,EAAG,CAACE,CAAK,CAAC,GAER,EAAAP,EAAA,IAAA,CAAC,WAAD,CACE,IAAKI,EACL,KAAMI,EACC,QACP,MAAO,CAAE,YAAW,GAAGC,CAAM,EAC7B,UAAWX,EACT,uJACA,gGACAY,CACF,EACA,GAAIR,CACL,CAAA,CAEL,CAAC,EAGYS,GAAA,EAAYnB,EAAAA,WAAAA,CACvB,SAAmB,CAAE,YAAW,GAAGU,GAAQ,EAAK,CAC9C,OACE,EAAAF,EAAA,IAAA,CAAC,QAAD,CACO,MACL,UAAWF,EACT,8HACA,gGACAY,CACF,EACA,GAAIR,CACL,CAAA,CAEL,CACF,E"}
@@ -1,2 +0,0 @@
1
- import{_ as e,i as t,m as n,n as r,t as i}from"./jsx-runtime-D13aM9HY.js";import{D as a,P as o,T as s,U as c,W as l,c as u,d,i as f,l as p,n as m,o as h,p as g,t as _}from"./states-DrTQuYXw.js";import{t as v}from"./server-SxFxIScj.js";import{t as y}from"./external-link-3jjTxo92.js";import{t as b}from"./InteractionCard-B-xmpTNG.js";import{E as x,I as S,L as C,c as w,d as T,l as E,o as D,t as O}from"./index-IdzOP9GE.js";import{t as k}from"./SegmentedControl-ChdVilXb.js";var A={name:`list-todo`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]};A.node;var j=r(A),M=e(n(),1),N=i(),P=[`needs_input`,`failed`,`ready_for_review`,`unsupported_interaction`,`host_unreachable`],F={needs_input:`Answer here; the answer goes to the same runtime question.`,failed:`Runs that failed or were blocked. Open the task to see why.`,ready_for_review:`Finished runs waiting for your review.`,unsupported_interaction:`Questions this client cannot display. Answer them in a terminal attached to the session.`,host_unreachable:`Running work on hosts that stopped responding. Nothing is restarted elsewhere.`};function I(e){let t=Object.fromEntries(P.map(e=>[e,[]]));for(let n of e)t[n.reason]?.push(n);return t}function L(){let e=a(),t=o(e=>e.hydrated),n=s(),[r,i]=D(`attention`,`all`),c=(0,M.useMemo)(()=>r===`new`?e.filter(e=>!e.acknowledgedAt):e,[e,r]),l=(0,M.useMemo)(()=>I(c),[c]);return(0,N.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl min-w-0 flex-col gap-4 px-4 py-4 safe-pt`,children:[(0,N.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-3`,children:[(0,N.jsx)(`h1`,{className:`flex-1 text-lg font-semibold`,children:`Attention`}),(0,N.jsx)(k,{label:`Show`,value:r,onChange:i,options:[{value:`all`,label:`All open`},{value:`new`,label:`Not acknowledged`}]})]}),n.state!==`live`&&t&&(0,N.jsx)(`p`,{className:`text-sm text-muted`,role:`status`,children:`Showing the last known attention items; answers are sent once the connection is back.`}),t?c.length===0?(0,N.jsx)(_,{icon:(0,N.jsx)(C,{className:`size-8`}),title:e.length>0?`Nothing new`:`Nothing needs your attention`,description:e.length>0?`${e.length} acknowledged ${e.length===1?`item is`:`items are`} still open.`:`Questions, failures and finished work show up here.`,action:e.length>0?{label:`Show all open`,onClick:()=>i(`all`)}:{label:`Go to Board`,to:O.board}}):P.filter(e=>l[e].length>0).map(e=>{let t=E[e],n=t.icon;return(0,N.jsxs)(`section`,{"data-testid":`attention-group-${e}`,"aria-labelledby":`att-${e}`,className:`flex min-w-0 flex-col gap-2`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`h2`,{id:`att-${e}`,className:`flex items-center gap-2 text-base font-semibold`,children:[(0,N.jsx)(n,{"aria-hidden":!0,className:`size-4 text-muted`}),t.label,(0,N.jsxs)(`span`,{className:`text-sm font-normal text-muted`,children:[`(`,l[e].length,`)`]})]}),(0,N.jsx)(`p`,{className:`text-sm text-muted`,children:F[e]})]}),(0,N.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:l[e].map(e=>(0,N.jsx)(`li`,{children:(0,N.jsx)(R,{item:e})},e.id))})]},e)}):(0,N.jsx)(h,{label:`Loading attention…`})]})}function R({item:e}){let n=o(t=>e.projectId?t.projects[e.projectId]:void 0),r=o(t=>e.taskId?t.tasks[e.taskId]:void 0),i=o(t=>e.sessionId?t.sessions[e.sessionId]:void 0),a=o(e=>i?e.hosts[i.hostId]:void 0),s=o(t=>e.interactionId?t.interactions[e.interactionId]:void 0),[h,_]=(0,M.useState)(!1),[C,D]=(0,M.useState)(null),k=async()=>{_(!0),D(null);try{let t=await c(`/api/attention/${encodeURIComponent(e.id)}/acknowledge`),n=t&&typeof t==`object`&&`id`in t?t:{...e,acknowledgedAt:new Date().toISOString()};o.setState(t=>t.attention[e.id]?{attention:{...t.attention,[e.id]:n}}:{}),w.success(`Acknowledged. It stays open until the underlying task or question is resolved.`)}catch(e){D(e)}finally{_(!1)}},A=e.sessionId?e.interactionId?O.interaction(e.sessionId,e.interactionId):O.session(e.sessionId):null,P=!!a&&a.connectivity!==`connected`,F=null;switch(e.reason){case`needs_input`:F=s&&s.state===`pending`?(0,N.jsx)(b,{interaction:s,readOnlyReason:P?`Host ${a?.name} is offline. You can answer once it reconnects.`:i?.readOnly?`This session is read-only.`:null}):s?(0,N.jsx)(b,{interaction:s}):A?(0,N.jsxs)(t,{to:A,className:d(`primary`,`sm`),children:[(0,N.jsx)(y,{"aria-hidden":!0,className:`size-3.5`}),`Answer in session`]}):null;break;case`failed`:F=e.taskId?(0,N.jsxs)(t,{to:O.task(e.taskId),className:d(`primary`,`sm`),children:[(0,N.jsx)(j,{"aria-hidden":!0,className:`size-3.5`}),`Open task`]}):null;break;case`ready_for_review`:F=e.sessionId?(0,N.jsxs)(t,{to:`${O.session(e.sessionId)}?tab=changes`,className:d(`primary`,`sm`),children:[(0,N.jsx)(x,{"aria-hidden":!0,className:`size-3.5`}),`Review changes`]}):e.taskId?(0,N.jsxs)(t,{to:O.task(e.taskId),className:d(`primary`,`sm`),children:[(0,N.jsx)(x,{"aria-hidden":!0,className:`size-3.5`}),`Open review`]}):null;break;case`unsupported_interaction`:F=s?(0,N.jsx)(b,{interaction:s,readOnlyReason:P?`Host ${a?.name} is offline. You can choose once it reconnects.`:i?.readOnly?`This session is read-only.`:null}):(0,N.jsx)(u,{capability:`This dialog`,reason:`An extension opened a terminal-only dialog. In RPC mode Pi gave it no answer, so the extension continued without one.`});break;case`host_unreachable`:F=a?(0,N.jsx)(f,{compact:!0,hostName:a.name,connectivity:a.connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:a.lastSeenAt}):null}return(0,N.jsxs)(`article`,{"aria-label":`${E[e.reason].label}: ${r?.title??i?.title??e.summary}`,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3`,children:[(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,N.jsx)(T,{kind:`attention`,value:e.reason,size:`sm`}),(0,N.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-muted`,children:[n?.name,r?.title,i&&i.title!==r?.title?i.title:null].filter(Boolean).join(` · `)||`Switchyard`}),(0,N.jsx)(`time`,{dateTime:e.createdAt,className:`shrink-0 text-xs text-subtle`,children:g(e.createdAt)})]}),(0,N.jsx)(`p`,{className:`min-w-0 text-sm break-words`,children:e.summary}),F&&(0,N.jsx)(`div`,{className:`flex min-w-0 flex-col items-start`,children:F}),(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[e.reason!==`failed`&&e.taskId&&(0,N.jsxs)(t,{to:O.task(e.taskId),className:d(`ghost`,`sm`),children:[(0,N.jsx)(j,{"aria-hidden":!0,className:`size-3.5`}),`Task`]}),A&&(0,N.jsxs)(t,{to:A,className:d(`ghost`,`sm`),children:[(0,N.jsx)(y,{"aria-hidden":!0,className:`size-3.5`}),`Open session`]}),e.reason===`host_unreachable`&&a&&(0,N.jsxs)(t,{to:`${O.settings(`hosts`)}/${encodeURIComponent(a.id)}`,className:d(`ghost`,`sm`),children:[(0,N.jsx)(v,{"aria-hidden":!0,className:`size-3.5`}),`Host details`]}),(0,N.jsx)(`span`,{className:`ml-auto`}),e.acknowledgedAt?(0,N.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-muted`,children:[(0,N.jsx)(S,{"aria-hidden":!0,className:`size-3.5`}),`Acknowledged `,g(e.acknowledgedAt)]}):(0,N.jsx)(p,{size:`sm`,busy:h,onClick:()=>void k(),title:`Hide the alert without resolving the task`,children:`Acknowledge`})]}),C!==null&&(0,N.jsx)(m,{compact:!0,title:`Could not acknowledge`,error:l(C),onRetry:()=>void k()})]})}export{P as ATTENTION_GROUPS,L as default,I as groupAttention};
2
- //# sourceMappingURL=attention-q6_xlnT4.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attention-q6_xlnT4.js","names":["useMemo","useState","__toESM","Link","require_react","createLucideIcon","require_jsx_runtime","useOpenAttention","useSyncStore","useConnection","apiPost","errorMessage","UnsupportedCapability","HostUnavailable","Button","ErrorState","LoadingState","formatRelative","EmptyState","Server","ExternalLink","InteractionCard","Eye","CircleCheck","Bell","toast","StatusChip","ATTENTION_STATUS","useFilter","ROUTES","SegmentedControl","__iconData","ListTodo","import_react","import_jsx_runtime","ATTENTION_GROUPS","GROUP_HINT","groupAttention","out","r","a","items","AttentionView","all","hydrated","s","connection","show","setShow","groups","info","reason","Icon","AttentionRow","project","item","task","session","host","interaction","busy","setBusy","ackError","setAckError","acknowledge","res","next","sessionHref","hostOffline","action","buttonClasses"],"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/list-todo.mjs","../../src/features/attention/index.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: \"list-todo\",\n size: 24,\n node: [\n [\"path\", { d: \"M13 5h8\", key: \"a7qcls\" }],\n [\"path\", { d: \"M13 12h8\", key: \"h98zly\" }],\n [\"path\", { d: \"M13 19h8\", key: \"c3s6r1\" }],\n [\"path\", { d: \"m3 17 2 2 4-4\", key: \"1jhpwq\" }],\n [\"rect\", { x: \"3\", y: \"4\", width: \"6\", height: \"6\", rx: \"1\", key: \"cif1o7\" }]\n ]\n};\n__iconData.node;\nconst ListTodo = createLucideIcon(__iconData);\n\nexport { __iconData, ListTodo as default };\n//# sourceMappingURL=list-todo.mjs.map\n","import type { AttentionItem, AttentionReason } from \"@switchyard/protocol\";\nimport { Bell, CircleCheck, ExternalLink, Eye, ListTodo, Server } from \"lucide-react\";\nimport { useMemo, useState } from \"react\";\nimport { Link } from \"react-router\";\nimport { ROUTES } from \"../../app/routes\";\nimport { InteractionCard } from \"../../components/intent/InteractionCard\";\nimport { Button, buttonClasses } from \"../../components/ui/Button\";\nimport { SegmentedControl } from \"../../components/ui/SegmentedControl\";\nimport { ATTENTION_STATUS, StatusChip } from \"../../components/ui/StatusChip\";\nimport {\n EmptyState,\n ErrorState,\n HostUnavailable,\n LoadingState,\n UnsupportedCapability,\n} from \"../../components/ui/states\";\nimport { toast } from \"../../components/ui/Toast\";\nimport { formatRelative } from \"../../lib/time\";\nimport { useFilter } from \"../../prefs\";\nimport { apiPost, errorMessage } from \"../../sync/api\";\nimport { useConnection, useOpenAttention, useSyncStore } from \"../../sync/store\";\n\nexport const ATTENTION_GROUPS: AttentionReason[] = [\n \"needs_input\",\n \"failed\",\n \"ready_for_review\",\n \"unsupported_interaction\",\n \"host_unreachable\",\n];\n\nconst GROUP_HINT: Record<AttentionReason, string> = {\n needs_input: \"Answer here; the answer goes to the same runtime question.\",\n failed: \"Runs that failed or were blocked. Open the task to see why.\",\n ready_for_review: \"Finished runs waiting for your review.\",\n unsupported_interaction:\n \"Questions this client cannot display. Answer them in a terminal attached to the session.\",\n host_unreachable:\n \"Running work on hosts that stopped responding. Nothing is restarted elsewhere.\",\n};\n\n/** Group open attention by reason, keeping newest first within a group. */\nexport function groupAttention(items: AttentionItem[]): Record<AttentionReason, AttentionItem[]> {\n const out = Object.fromEntries(ATTENTION_GROUPS.map((r) => [r, [] as AttentionItem[]])) as Record<\n AttentionReason,\n AttentionItem[]\n >;\n for (const a of items) out[a.reason]?.push(a);\n return out;\n}\n\n/** /attention: Needs input, Failed, Ready for review (plus unsupported and unreachable). */\nexport default function AttentionView() {\n const all = useOpenAttention();\n const hydrated = useSyncStore((s) => s.hydrated);\n const connection = useConnection();\n const [show, setShow] = useFilter<\"all\" | \"new\">(\"attention\", \"all\");\n const items = useMemo(\n () => (show === \"new\" ? all.filter((a) => !a.acknowledgedAt) : all),\n [all, show],\n );\n const groups = useMemo(() => groupAttention(items), [items]);\n\n return (\n <div className=\"mx-auto flex w-full max-w-3xl min-w-0 flex-col gap-4 px-4 py-4 safe-pt\">\n <header className=\"flex min-w-0 flex-wrap items-center gap-3\">\n <h1 className=\"flex-1 text-lg font-semibold\">Attention</h1>\n <SegmentedControl\n label=\"Show\"\n value={show}\n onChange={setShow}\n options={[\n { value: \"all\", label: \"All open\" },\n { value: \"new\", label: \"Not acknowledged\" },\n ]}\n />\n </header>\n {connection.state !== \"live\" && hydrated && (\n <p className=\"text-sm text-muted\" role=\"status\">\n Showing the last known attention items; answers are sent once the connection is back.\n </p>\n )}\n {!hydrated ? (\n <LoadingState label=\"Loading attention…\" />\n ) : items.length === 0 ? (\n <EmptyState\n icon={<Bell className=\"size-8\" />}\n title={all.length > 0 ? \"Nothing new\" : \"Nothing needs your attention\"}\n description={\n all.length > 0\n ? `${all.length} acknowledged ${all.length === 1 ? \"item is\" : \"items are\"} still open.`\n : \"Questions, failures and finished work show up here.\"\n }\n action={\n all.length > 0\n ? { label: \"Show all open\", onClick: () => setShow(\"all\") }\n : { label: \"Go to Board\", to: ROUTES.board }\n }\n />\n ) : (\n ATTENTION_GROUPS.filter((r) => groups[r].length > 0).map((reason) => {\n const info = ATTENTION_STATUS[reason];\n const Icon = info.icon;\n return (\n <section\n key={reason}\n data-testid={`attention-group-${reason}`}\n aria-labelledby={`att-${reason}`}\n className=\"flex min-w-0 flex-col gap-2\"\n >\n <div>\n <h2\n id={`att-${reason}`}\n className=\"flex items-center gap-2 text-base font-semibold\"\n >\n <Icon aria-hidden className=\"size-4 text-muted\" />\n {info.label}\n <span className=\"text-sm font-normal text-muted\">({groups[reason].length})</span>\n </h2>\n <p className=\"text-sm text-muted\">{GROUP_HINT[reason]}</p>\n </div>\n <ul className=\"flex min-w-0 flex-col gap-2\">\n {groups[reason].map((a) => (\n <li key={a.id}>\n <AttentionRow item={a} />\n </li>\n ))}\n </ul>\n </section>\n );\n })\n )}\n </div>\n );\n}\n\nfunction AttentionRow({ item }: { item: AttentionItem }) {\n const project = useSyncStore((s) => (item.projectId ? s.projects[item.projectId] : undefined));\n const task = useSyncStore((s) => (item.taskId ? s.tasks[item.taskId] : undefined));\n const session = useSyncStore((s) => (item.sessionId ? s.sessions[item.sessionId] : undefined));\n const host = useSyncStore((s) => (session ? s.hosts[session.hostId] : undefined));\n const interaction = useSyncStore((s) =>\n item.interactionId ? s.interactions[item.interactionId] : undefined,\n );\n const [busy, setBusy] = useState(false);\n const [ackError, setAckError] = useState<unknown>(null);\n\n const acknowledge = async () => {\n setBusy(true);\n setAckError(null);\n try {\n const res = await apiPost<AttentionItem>(\n `/api/attention/${encodeURIComponent(item.id)}/acknowledge`,\n );\n const next =\n res && typeof res === \"object\" && \"id\" in res\n ? res\n : { ...item, acknowledgedAt: new Date().toISOString() };\n useSyncStore.setState((s) =>\n s.attention[item.id] ? { attention: { ...s.attention, [item.id]: next } } : {},\n );\n toast.success(\n \"Acknowledged. It stays open until the underlying task or question is resolved.\",\n );\n } catch (e) {\n setAckError(e);\n } finally {\n setBusy(false);\n }\n };\n\n const sessionHref = item.sessionId\n ? item.interactionId\n ? ROUTES.interaction(item.sessionId, item.interactionId)\n : ROUTES.session(item.sessionId)\n : null;\n const hostOffline = !!host && host.connectivity !== \"connected\";\n\n let action: React.ReactNode = null;\n switch (item.reason) {\n case \"needs_input\":\n action =\n interaction && interaction.state === \"pending\" ? (\n <InteractionCard\n interaction={interaction}\n readOnlyReason={\n hostOffline\n ? `Host ${host?.name} is offline. You can answer once it reconnects.`\n : session?.readOnly\n ? \"This session is read-only.\"\n : null\n }\n />\n ) : interaction ? (\n <InteractionCard interaction={interaction} />\n ) : sessionHref ? (\n <Link to={sessionHref} className={buttonClasses(\"primary\", \"sm\")}>\n <ExternalLink aria-hidden className=\"size-3.5\" />\n Answer in session\n </Link>\n ) : null;\n break;\n case \"failed\":\n action = item.taskId ? (\n <Link to={ROUTES.task(item.taskId)} className={buttonClasses(\"primary\", \"sm\")}>\n <ListTodo aria-hidden className=\"size-3.5\" />\n Open task\n </Link>\n ) : null;\n break;\n case \"ready_for_review\":\n action = item.sessionId ? (\n <Link\n to={`${ROUTES.session(item.sessionId)}?tab=changes`}\n className={buttonClasses(\"primary\", \"sm\")}\n >\n <Eye aria-hidden className=\"size-3.5\" />\n Review changes\n </Link>\n ) : item.taskId ? (\n <Link to={ROUTES.task(item.taskId)} className={buttonClasses(\"primary\", \"sm\")}>\n <Eye aria-hidden className=\"size-3.5\" />\n Open review\n </Link>\n ) : null;\n break;\n case \"unsupported_interaction\":\n action = interaction ? (\n <InteractionCard\n interaction={interaction}\n readOnlyReason={\n hostOffline\n ? `Host ${host?.name} is offline. You can choose once it reconnects.`\n : session?.readOnly\n ? \"This session is read-only.\"\n : null\n }\n />\n ) : (\n <UnsupportedCapability\n capability=\"This dialog\"\n reason=\"An extension opened a terminal-only dialog. In RPC mode Pi gave it no answer, so the extension continued without one.\"\n />\n );\n break;\n case \"host_unreachable\":\n action = host ? (\n <HostUnavailable\n compact\n hostName={host.name}\n connectivity={host.connectivity === \"reconnecting\" ? \"reconnecting\" : \"unreachable\"}\n lastSeenAt={host.lastSeenAt}\n />\n ) : null;\n break;\n }\n\n return (\n <article\n aria-label={`${ATTENTION_STATUS[item.reason].label}: ${task?.title ?? session?.title ?? item.summary}`}\n className=\"flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3\"\n >\n <div className=\"flex min-w-0 flex-wrap items-center gap-2\">\n <StatusChip kind=\"attention\" value={item.reason} size=\"sm\" />\n <span className=\"min-w-0 flex-1 truncate text-sm text-muted\">\n {[\n project?.name,\n task?.title,\n session && session.title !== task?.title ? session.title : null,\n ]\n .filter(Boolean)\n .join(\" · \") || \"Switchyard\"}\n </span>\n <time dateTime={item.createdAt} className=\"shrink-0 text-xs text-subtle\">\n {formatRelative(item.createdAt)}\n </time>\n </div>\n <p className=\"min-w-0 text-sm break-words\">{item.summary}</p>\n {action && <div className=\"flex min-w-0 flex-col items-start\">{action}</div>}\n <div className=\"flex min-w-0 flex-wrap items-center gap-2\">\n {item.reason !== \"failed\" && item.taskId && (\n <Link to={ROUTES.task(item.taskId)} className={buttonClasses(\"ghost\", \"sm\")}>\n <ListTodo aria-hidden className=\"size-3.5\" />\n Task\n </Link>\n )}\n {sessionHref && (\n <Link to={sessionHref} className={buttonClasses(\"ghost\", \"sm\")}>\n <ExternalLink aria-hidden className=\"size-3.5\" />\n Open session\n </Link>\n )}\n {item.reason === \"host_unreachable\" && host && (\n <Link\n to={`${ROUTES.settings(\"hosts\")}/${encodeURIComponent(host.id)}`}\n className={buttonClasses(\"ghost\", \"sm\")}\n >\n <Server aria-hidden className=\"size-3.5\" />\n Host details\n </Link>\n )}\n <span className=\"ml-auto\" />\n {item.acknowledgedAt ? (\n <span className=\"inline-flex items-center gap-1 text-xs text-muted\">\n <CircleCheck aria-hidden className=\"size-3.5\" />\n Acknowledged {formatRelative(item.acknowledgedAt)}\n </span>\n ) : (\n <Button\n size=\"sm\"\n busy={busy}\n onClick={() => void acknowledge()}\n title=\"Hide the alert without resolving the task\"\n >\n Acknowledge\n </Button>\n )}\n </div>\n {ackError !== null && (\n <ErrorState\n compact\n title=\"Could not acknowledge\"\n error={errorMessage(ackError)}\n onRetry={() => void acknowledge()}\n />\n )}\n </article>\n );\n}\n"],"ignoreList":[0],"mappings":"A,ydASA,IAAM+B,EAAa,CACjB,KAAM,YACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,EAAG,UAAW,IAAK,QAAS,CAAC,EACxC,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAS,CAAC,EACzC,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAS,CAAC,EACzC,CAAC,OAAQ,CAAE,EAAG,gBAAiB,IAAK,QAAS,CAAC,EAC9C,CAAC,OAAQ,CAAE,EAAG,IAAK,EAAG,IAAK,MAAO,IAAK,OAAQ,IAAK,GAAI,IAAK,IAAK,QAAS,CAAC,CAC9E,CACF,EACAA,EAAW,KACX,IAAMC,EAAW3B,EAAiB0B,CAAU,E,iBCC/BI,EAAsC,CACjD,cACA,SACA,mBACA,0BACA,kBACF,EAEMC,EAA8C,CAClD,YAAa,6DACb,OAAQ,8DACR,iBAAkB,yCAClB,wBACE,2FACF,iB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C,OACN,YAAe,KAAKkD,EAAY,EAChC,MAAM,4CACP,SAAA,aAEO,CAAA,CAEP,C,GACJF,IAAa,OACZ,EAAA5B,EAAA,IAAA,CAACnB,EAAD,CACE,QAAA,GACA,MAAM,wBACN,MAAOJ,EAAamD,CAAQ,EAC5B,YAAe,KAAKE,EAAY,CACjC,CAAA,CAEI,C,EAEb,C"}
@@ -1,2 +0,0 @@
1
- import{_ as e,i as t,m as n,n as r,t as i}from"./jsx-runtime-D13aM9HY.js";import{P as a,V as o,d as s,h as c,l,n as u,o as d,p as f,r as p,t as m}from"./states-DrTQuYXw.js";import{t as h}from"./calendar-clock-B8zE4JsX.js";import{t as g}from"./chevron-right-evVLS6hq.js";import{t as _}from"./hand-UPoHamrn.js";import{t as v}from"./link-2-CaMlUDRG.js";import{A as y,C as b,F as x,I as S,M as C,P as w,_ as T,c as E,p as D,w as O}from"./describe-BirsjlUl.js";import{t as k}from"./play-CjoDg3ws.js";import{t as A}from"./plus-BLP-wIYD.js";import{_ as j,k as M,n as N,v as P}from"./index-IdzOP9GE.js";import{a as F}from"./dist-C-h8FC-n.js";var I={name:`webhook`,size:24,node:[[`path`,{d:`M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2`,key:`q3hayz`}],[`path`,{d:`m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06`,key:`1go1hn`}],[`path`,{d:`m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8`,key:`qlwsc0`}]]};I.node;var L=r(I),R=e(n(),1),z=i(),B=`/automations/new`,V=e=>`/automations/${encodeURIComponent(e)}`,H={manual:_,once:M,cron:h,webhook:L,dependency:v};function U(){let e=a(e=>e.hydrated),n=w(),r=a(e=>e.projects),i=a(e=>e.hosts),c=a(e=>e.tasks),l=N(),[f,h]=(0,R.useState)({status:`idle`}),g=(0,R.useCallback)(async()=>{h({status:`loading`});try{let e=await o(`/api/automations`),t=Array.isArray(e)?e:e&&typeof e==`object`&&Array.isArray(e.items)?e.items:null,n=t?F.array().safeParse(t):null;if(!n?.success){h({status:`fatal`,error:Error(`The coordinator returned automations in an unexpected format.`)});return}C.getState().putMany(n.data),h({status:`done`})}catch(e){h({status:`error`,error:e})}},[]);(0,R.useEffect)(()=>{e||g()},[e,g]);let _=(0,R.useMemo)(()=>Object.values(n).sort((e,t)=>e.name.localeCompare(t.name)),[n]),v=e||f.status===`done`,y;return y=v?_.length===0?(0,z.jsx)(m,{icon:(0,z.jsx)(j,{className:`size-8`}),title:`No automations yet`,description:`Automations create tasks on a schedule, from a webhook, or when another task is done.`,action:{label:`Create an automation`,to:B,icon:(0,z.jsx)(A,{className:`size-4`})}}):(0,z.jsx)(G,{automations:_,projects:r,hosts:i,tasks:c,table:l===`desktop`}):f.status===`fatal`?(0,z.jsx)(p,{error:f.error}):f.status===`error`?(0,z.jsx)(u,{title:`Could not load automations`,error:f.error,onRetry:()=>void g()}):(0,z.jsx)(d,{label:`Loading automations…`}),(0,z.jsxs)(`div`,{className:`mx-auto flex w-full max-w-6xl min-w-0 flex-col gap-4 px-4 py-4 md:px-6`,children:[(0,z.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Automations`}),(0,z.jsx)(`p`,{className:`text-sm text-muted`,children:`Scheduled, webhook and dependency automations. Routine successes stay in each automation's history.`})]}),(0,z.jsxs)(t,{to:B,className:s(`primary`),children:[(0,z.jsx)(A,{"aria-hidden":!0,className:`size-4`}),`New automation`]})]}),(0,z.jsx)(b,{}),y]})}var W=`grid grid-cols-[minmax(0,2.4fr)_minmax(0,1fr)_5.5rem_minmax(0,1.2fr)_minmax(0,1.4fr)_7.5rem_7rem_auto] items-center gap-3`;function G({automations:e,projects:t,hosts:n,tasks:r,table:i}){let{busy:a,toggle:o}=S(),{busy:s,run:l}=x(),u=(0,R.useCallback)(e=>r[e]?.title,[r]);return(0,z.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-lg border border-border bg-surface`,children:[i&&(0,z.jsxs)(`div`,{"aria-hidden":!0,className:c(W,`border-b border-border bg-surface-2 px-4 py-2 text-xs font-medium text-muted`),children:[(0,z.jsx)(`span`,{children:`Automation`}),(0,z.jsx)(`span`,{children:`Project`}),(0,z.jsx)(`span`,{children:`Mode`}),(0,z.jsx)(`span`,{children:`Next occurrence`}),(0,z.jsx)(`span`,{children:`Last outcome`}),(0,z.jsx)(`span`,{children:`Failures`}),(0,z.jsx)(`span`,{children:`Enabled`}),(0,z.jsx)(`span`,{className:`sr-only`,children:`Actions`})]}),(0,z.jsx)(`ul`,{"data-testid":`automations-list`,className:`divide-y divide-border`,children:e.map(e=>{let r=t[e.projectId],c=e.hostId??r?.defaultHostId??null,d=c?n[c]:void 0,f={automation:e,projectName:r?.name??`Unknown project`,host:d,trigger:E(e.trigger,{taskTitle:u}),toggling:!!a[e.id],running:!!s[e.id],onToggle:t=>void o(e,t),onRun:()=>void l(e)};return(0,z.jsx)(`li`,{"data-testid":`automation-row`,"data-automation-id":e.id,children:i?(0,z.jsx)(X,{...f}):(0,z.jsx)(Z,{...f})},e.id)})})]})}function K({automation:e,trigger:t}){let n=H[e.trigger.kind];return(0,z.jsxs)(`span`,{className:`flex min-w-0 items-start gap-1.5 text-sm text-muted`,children:[(0,z.jsx)(n,{"aria-hidden":!0,className:`mt-0.5 size-3.5 shrink-0`}),(0,z.jsx)(`span`,{className:`min-w-0 break-words`,children:t})]})}function q({automation:e}){if(!e.enabled)return(0,z.jsx)(`span`,{className:`text-sm text-muted`,children:`Paused (disabled)`});if(!e.nextAt){let t=e.trigger.kind;return(0,z.jsx)(`span`,{className:`text-sm text-muted`,children:t===`manual`?`On demand`:t===`webhook`?`On webhook`:t===`dependency`?`When the task is done`:`None scheduled`})}return(0,z.jsxs)(`span`,{className:`flex min-w-0 flex-col text-sm`,children:[(0,z.jsx)(`span`,{children:f(e.nextAt)}),(0,z.jsx)(`time`,{dateTime:e.nextAt,className:`text-xs text-muted`,children:D(e.nextAt)})]})}function J({host:e}){return!e||e.connectivity===`connected`?null:(0,z.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-danger`,children:[(0,z.jsx)(P,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,z.jsxs)(`span`,{className:`min-w-0 break-words`,children:[`Host `,e.name,` `,e.connectivity===`reconnecting`?`reconnecting`:`unreachable`]})]})}function Y({running:e,onRun:t,name:n}){return(0,z.jsx)(l,{size:`sm`,busy:e,icon:(0,z.jsx)(k,{className:`size-3.5`}),onClick:t,"aria-label":`Run ${n} now`,children:`Run now`})}function X(e){let n=e.automation;return(0,z.jsxs)(`div`,{className:c(W,`px-4 py-3`),children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,z.jsx)(t,{to:V(n.id),className:`truncate font-medium text-text hover:underline focus-visible:underline`,children:n.name}),(0,z.jsx)(K,{automation:n,trigger:e.trigger})]}),(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:`Project: `}),(0,z.jsx)(`span`,{className:`truncate text-sm`,children:e.projectName}),(0,z.jsx)(J,{host:e.host})]}),(0,z.jsxs)(`span`,{className:`text-sm`,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:`Mode: `}),T(n.mode)]}),(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:`Next occurrence: `}),(0,z.jsx)(q,{automation:n})]}),(0,z.jsxs)(`div`,{className:`min-w-0 text-sm break-words`,children:[(0,z.jsx)(`span`,{className:`sr-only`,children:`Last outcome: `}),n.lastOutcome??(0,z.jsx)(`span`,{className:`text-muted`,children:`No runs yet`})]}),(0,z.jsx)(O,{count:n.failureCount}),(0,z.jsx)(y,{checked:n.enabled,onChange:e.onToggle,busy:e.toggling,label:`Enable ${n.name}`,onText:`Enabled`,offText:`Disabled`}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(Y,{running:e.running,onRun:e.onRun,name:n.name}),(0,z.jsx)(t,{to:V(n.id),"aria-label":`Edit ${n.name}`,title:`Edit`,className:`tap inline-flex size-9 items-center justify-center rounded-md text-muted hover:bg-surface-2 hover:text-text`,children:(0,z.jsx)(g,{"aria-hidden":!0,className:`size-4`})})]})]})}function Z(e){let n=e.automation;return(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 px-4 py-3`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,z.jsx)(t,{to:V(n.id),className:`font-medium break-words text-text hover:underline focus-visible:underline`,children:n.name}),(0,z.jsx)(K,{automation:n,trigger:e.trigger})]}),(0,z.jsx)(y,{checked:n.enabled,onChange:e.onToggle,busy:e.toggling,label:`Enable ${n.name}`,onText:`Enabled`,offText:`Disabled`})]}),(0,z.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-sm`,children:[(0,z.jsx)(`dt`,{className:`text-muted`,children:`Project`}),(0,z.jsxs)(`dd`,{className:`flex min-w-0 flex-col break-words`,children:[e.projectName,(0,z.jsx)(J,{host:e.host})]}),(0,z.jsx)(`dt`,{className:`text-muted`,children:`Mode`}),(0,z.jsx)(`dd`,{children:T(n.mode)}),(0,z.jsx)(`dt`,{className:`text-muted`,children:`Next`}),(0,z.jsx)(`dd`,{className:`min-w-0`,children:(0,z.jsx)(q,{automation:n})}),(0,z.jsx)(`dt`,{className:`text-muted`,children:`Last outcome`}),(0,z.jsx)(`dd`,{className:`min-w-0 break-words`,children:n.lastOutcome??(0,z.jsx)(`span`,{className:`text-muted`,children:`No runs yet`})}),(0,z.jsx)(`dt`,{className:`text-muted`,children:`Failures`}),(0,z.jsx)(`dd`,{children:(0,z.jsx)(O,{count:n.failureCount})})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,z.jsx)(Y,{running:e.running,onRun:e.onRun,name:n.name}),(0,z.jsxs)(t,{to:V(n.id),className:s(`ghost`,`sm`),children:[`Edit`,(0,z.jsx)(g,{"aria-hidden":!0,className:`size-3.5`})]})]})]})}export{U as default};
2
- //# sourceMappingURL=automations-CyA83OAD.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"automations-CyA83OAD.js","names":["useState","useCallback","useMemo","__toESM","Link","require_react","createLucideIcon","require_jsx_runtime","useSyncStore","apiGet","buttonClasses","cn","ErrorState","LoadingState","formatRelative","FatalError","EmptyState","CalendarClock","ChevronRight","Hand","Link2","Switch","ConnectionNote","useRunNow","useToggleEnabled","useLocalAutomations","useMergedAutomations","modeLabel","describeTrigger","formatAbsolute","FailureCount","Play","Plus","Workflow","Clock","useBreakpoint","WifiOff","Automation","__iconData","Webhook","import_react","import_jsx_runtime","NEW_PATH","editPath","id","TRIGGER_ICONS","AutomationsView","hydrated","s","automations","projects","hosts","tasks","bp","fetchState","setFetchState","load","res","list","parsed","rows","a","b","haveData","body","AutomationRows","TABLE_COLS","toggling","running","taskTitle","table","project","hostId","host","props","toggle","next","run","TableRow","CardRow","TriggerText","Icon","automation","trigger","NextOccurrence","k","HostWarning","RunButton","Button","onRun","name","p"],"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/webhook.mjs","../../src/features/automations/index.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: \"webhook\",\n size: 24,\n node: [\n [\n \"path\",\n {\n d: \"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2\",\n key: \"q3hayz\"\n }\n ],\n [\"path\", { d: \"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06\", key: \"1go1hn\" }],\n [\"path\", { d: \"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8\", key: \"qlwsc0\" }]\n ]\n};\n__iconData.node;\nconst Webhook = createLucideIcon(__iconData);\n\nexport { __iconData, Webhook as default };\n//# sourceMappingURL=webhook.mjs.map\n","import { Automation, type Host, type Project, type Task } from \"@switchyard/protocol\";\nimport {\n CalendarClock,\n ChevronRight,\n Clock,\n Hand,\n Link2,\n type LucideIcon,\n Play,\n Plus,\n Webhook,\n WifiOff,\n Workflow,\n} from \"lucide-react\";\nimport { type ReactNode, useCallback, useEffect, useMemo, useState } from \"react\";\nimport { Link } from \"react-router\";\nimport { useBreakpoint } from \"../../app/useBreakpoint\";\nimport { Button, buttonClasses } from \"../../components/ui/Button\";\nimport { EmptyState, ErrorState, FatalError, LoadingState } from \"../../components/ui/states\";\nimport { cn } from \"../../lib/cn\";\nimport { formatRelative } from \"../../lib/time\";\nimport { apiGet } from \"../../sync/api\";\nimport { useSyncStore } from \"../../sync/store\";\nimport {\n ConnectionNote,\n FailureCount,\n Switch,\n useLocalAutomations,\n useMergedAutomations,\n useRunNow,\n useToggleEnabled,\n} from \"./controls\";\nimport { describeTrigger, formatAbsolute, modeLabel, type TriggerKind } from \"./describe\";\n\nconst NEW_PATH = \"/automations/new\";\nconst editPath = (id: string) => `/automations/${encodeURIComponent(id)}`;\n\nconst TRIGGER_ICONS: Record<TriggerKind, LucideIcon> = {\n manual: Hand,\n once: Clock,\n cron: CalendarClock,\n webhook: Webhook,\n dependency: Link2,\n};\n\ntype FetchState =\n | { status: \"idle\" | \"loading\" | \"done\" }\n | { status: \"error\"; error: unknown }\n | { status: \"fatal\"; error: unknown };\n\n/** Automations list (spec 15): enabled state, trigger, next occurrence, last outcome, failures. */\nexport default function AutomationsView() {\n const hydrated = useSyncStore((s) => s.hydrated);\n const automations = useMergedAutomations();\n const projects = useSyncStore((s) => s.projects);\n const hosts = useSyncStore((s) => s.hosts);\n const tasks = useSyncStore((s) => s.tasks);\n const bp = useBreakpoint();\n const [fetchState, setFetchState] = useState<FetchState>({ status: \"idle\" });\n\n // REST fallback while the sync snapshot has not arrived (and for retry after a failure).\n const load = useCallback(async () => {\n setFetchState({ status: \"loading\" });\n try {\n const res = await apiGet<unknown>(\"/api/automations\");\n const list = Array.isArray(res)\n ? res\n : res && typeof res === \"object\" && Array.isArray((res as { items?: unknown }).items)\n ? (res as { items: unknown[] }).items\n : null;\n const parsed = list ? Automation.array().safeParse(list) : null;\n if (!parsed?.success) {\n setFetchState({\n status: \"fatal\",\n error: new Error(\"The coordinator returned automations in an unexpected format.\"),\n });\n return;\n }\n useLocalAutomations.getState().putMany(parsed.data);\n setFetchState({ status: \"done\" });\n } catch (e) {\n setFetchState({ status: \"error\", error: e });\n }\n }, []);\n\n useEffect(() => {\n if (!hydrated) void load();\n }, [hydrated, load]);\n\n const rows = useMemo(\n () => Object.values(automations).sort((a, b) => a.name.localeCompare(b.name)),\n [automations],\n );\n\n const haveData = hydrated || fetchState.status === \"done\";\n\n let body: ReactNode;\n if (!haveData) {\n if (fetchState.status === \"fatal\") body = <FatalError error={fetchState.error} />;\n else if (fetchState.status === \"error\")\n body = (\n <ErrorState\n title=\"Could not load automations\"\n error={fetchState.error}\n onRetry={() => void load()}\n />\n );\n else body = <LoadingState label=\"Loading automations…\" />;\n } else if (rows.length === 0) {\n body = (\n <EmptyState\n icon={<Workflow className=\"size-8\" />}\n title=\"No automations yet\"\n description=\"Automations create tasks on a schedule, from a webhook, or when another task is done.\"\n action={{ label: \"Create an automation\", to: NEW_PATH, icon: <Plus className=\"size-4\" /> }}\n />\n );\n } else {\n body = (\n <AutomationRows\n automations={rows}\n projects={projects}\n hosts={hosts}\n tasks={tasks}\n table={bp === \"desktop\"}\n />\n );\n }\n\n return (\n <div className=\"mx-auto flex w-full max-w-6xl min-w-0 flex-col gap-4 px-4 py-4 md:px-6\">\n <header className=\"flex flex-wrap items-center justify-between gap-3\">\n <div className=\"min-w-0\">\n <h1 className=\"text-lg font-semibold\">Automations</h1>\n <p className=\"text-sm text-muted\">\n Scheduled, webhook and dependency automations. Routine successes stay in each\n automation's history.\n </p>\n </div>\n <Link to={NEW_PATH} className={buttonClasses(\"primary\")}>\n <Plus aria-hidden className=\"size-4\" />\n New automation\n </Link>\n </header>\n <ConnectionNote />\n {body}\n </div>\n );\n}\n\nconst TABLE_COLS =\n \"grid grid-cols-[minmax(0,2.4fr)_minmax(0,1fr)_5.5rem_minmax(0,1.2fr)_minmax(0,1.4fr)_7.5rem_7rem_auto] items-center gap-3\";\n\nfunction AutomationRows({\n automations,\n projects,\n hosts,\n tasks,\n table,\n}: {\n automations: Automation[];\n projects: Record<string, Project>;\n hosts: Record<string, Host>;\n tasks: Record<string, Task>;\n table: boolean;\n}) {\n const { busy: toggling, toggle } = useToggleEnabled();\n const { busy: running, run } = useRunNow();\n const taskTitle = useCallback((id: string) => tasks[id]?.title, [tasks]);\n\n return (\n <div className=\"min-w-0 overflow-hidden rounded-lg border border-border bg-surface\">\n {table && (\n <div\n aria-hidden\n className={cn(\n TABLE_COLS,\n \"border-b border-border bg-surface-2 px-4 py-2 text-xs font-medium text-muted\",\n )}\n >\n <span>Automation</span>\n <span>Project</span>\n <span>Mode</span>\n <span>Next occurrence</span>\n <span>Last outcome</span>\n <span>Failures</span>\n <span>Enabled</span>\n <span className=\"sr-only\">Actions</span>\n </div>\n )}\n <ul data-testid=\"automations-list\" className=\"divide-y divide-border\">\n {automations.map((a) => {\n const project = projects[a.projectId];\n const hostId = a.hostId ?? project?.defaultHostId ?? null;\n const host = hostId ? hosts[hostId] : undefined;\n const props: RowProps = {\n automation: a,\n projectName: project?.name ?? \"Unknown project\",\n host,\n trigger: describeTrigger(a.trigger, { taskTitle }),\n toggling: !!toggling[a.id],\n running: !!running[a.id],\n onToggle: (next) => void toggle(a, next),\n onRun: () => void run(a),\n };\n return (\n <li key={a.id} data-testid=\"automation-row\" data-automation-id={a.id}>\n {table ? <TableRow {...props} /> : <CardRow {...props} />}\n </li>\n );\n })}\n </ul>\n </div>\n );\n}\n\ninterface RowProps {\n automation: Automation;\n projectName: string;\n host: Host | undefined;\n trigger: string;\n toggling: boolean;\n running: boolean;\n onToggle: (next: boolean) => void;\n onRun: () => void;\n}\n\nfunction TriggerText({ automation, trigger }: { automation: Automation; trigger: string }) {\n const Icon = TRIGGER_ICONS[automation.trigger.kind];\n return (\n <span className=\"flex min-w-0 items-start gap-1.5 text-sm text-muted\">\n <Icon aria-hidden className=\"mt-0.5 size-3.5 shrink-0\" />\n <span className=\"min-w-0 break-words\">{trigger}</span>\n </span>\n );\n}\n\nfunction NextOccurrence({ automation }: { automation: Automation }) {\n if (!automation.enabled) return <span className=\"text-sm text-muted\">Paused (disabled)</span>;\n if (!automation.nextAt) {\n const k = automation.trigger.kind;\n const text =\n k === \"manual\"\n ? \"On demand\"\n : k === \"webhook\"\n ? \"On webhook\"\n : k === \"dependency\"\n ? \"When the task is done\"\n : \"None scheduled\";\n return <span className=\"text-sm text-muted\">{text}</span>;\n }\n return (\n <span className=\"flex min-w-0 flex-col text-sm\">\n <span>{formatRelative(automation.nextAt)}</span>\n <time dateTime={automation.nextAt} className=\"text-xs text-muted\">\n {formatAbsolute(automation.nextAt)}\n </time>\n </span>\n );\n}\n\nfunction HostWarning({ host }: { host: Host | undefined }) {\n if (!host || host.connectivity === \"connected\") return null;\n return (\n <span className=\"flex items-center gap-1 text-xs text-danger\">\n <WifiOff aria-hidden className=\"size-3.5 shrink-0\" />\n <span className=\"min-w-0 break-words\">\n Host {host.name} {host.connectivity === \"reconnecting\" ? \"reconnecting\" : \"unreachable\"}\n </span>\n </span>\n );\n}\n\nfunction RunButton({\n running,\n onRun,\n name,\n}: {\n running: boolean;\n onRun: () => void;\n name: string;\n}) {\n return (\n <Button\n size=\"sm\"\n busy={running}\n icon={<Play className=\"size-3.5\" />}\n onClick={onRun}\n aria-label={`Run ${name} now`}\n >\n Run now\n </Button>\n );\n}\n\nfunction TableRow(p: RowProps) {\n const a = p.automation;\n return (\n <div className={cn(TABLE_COLS, \"px-4 py-3\")}>\n <div className=\"flex min-w-0 flex-col gap-0.5\">\n <Link\n to={editPath(a.id)}\n className=\"truncate font-medium text-text hover:underline focus-visible:underline\"\n >\n {a.name}\n </Link>\n <TriggerText automation={a} trigger={p.trigger} />\n </div>\n <div className=\"flex min-w-0 flex-col gap-0.5\">\n <span className=\"sr-only\">Project: </span>\n <span className=\"truncate text-sm\">{p.projectName}</span>\n <HostWarning host={p.host} />\n </div>\n <span className=\"text-sm\">\n <span className=\"sr-only\">Mode: </span>\n {modeLabel(a.mode)}\n </span>\n <div className=\"min-w-0\">\n <span className=\"sr-only\">Next occurrence: </span>\n <NextOccurrence automation={a} />\n </div>\n <div className=\"min-w-0 text-sm break-words\">\n <span className=\"sr-only\">Last outcome: </span>\n {a.lastOutcome ?? <span className=\"text-muted\">No runs yet</span>}\n </div>\n <FailureCount count={a.failureCount} />\n <Switch\n checked={a.enabled}\n onChange={p.onToggle}\n busy={p.toggling}\n label={`Enable ${a.name}`}\n onText=\"Enabled\"\n offText=\"Disabled\"\n />\n <div className=\"flex items-center gap-1\">\n <RunButton running={p.running} onRun={p.onRun} name={a.name} />\n <Link\n to={editPath(a.id)}\n aria-label={`Edit ${a.name}`}\n title=\"Edit\"\n className=\"tap inline-flex size-9 items-center justify-center rounded-md text-muted hover:bg-surface-2 hover:text-text\"\n >\n <ChevronRight aria-hidden className=\"size-4\" />\n </Link>\n </div>\n </div>\n );\n}\n\nfunction CardRow(p: RowProps) {\n const a = p.automation;\n return (\n <div className=\"flex min-w-0 flex-col gap-2 px-4 py-3\">\n <div className=\"flex min-w-0 items-start justify-between gap-2\">\n <div className=\"flex min-w-0 flex-col gap-0.5\">\n <Link\n to={editPath(a.id)}\n className=\"font-medium break-words text-text hover:underline focus-visible:underline\"\n >\n {a.name}\n </Link>\n <TriggerText automation={a} trigger={p.trigger} />\n </div>\n <Switch\n checked={a.enabled}\n onChange={p.onToggle}\n busy={p.toggling}\n label={`Enable ${a.name}`}\n onText=\"Enabled\"\n offText=\"Disabled\"\n />\n </div>\n <dl className=\"grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-sm\">\n <dt className=\"text-muted\">Project</dt>\n <dd className=\"flex min-w-0 flex-col break-words\">\n {p.projectName}\n <HostWarning host={p.host} />\n </dd>\n <dt className=\"text-muted\">Mode</dt>\n <dd>{modeLabel(a.mode)}</dd>\n <dt className=\"text-muted\">Next</dt>\n <dd className=\"min-w-0\">\n <NextOccurrence automation={a} />\n </dd>\n <dt className=\"text-muted\">Last outcome</dt>\n <dd className=\"min-w-0 break-words\">\n {a.lastOutcome ?? <span className=\"text-muted\">No runs yet</span>}\n </dd>\n <dt className=\"text-muted\">Failures</dt>\n <dd>\n <FailureCount count={a.failureCount} />\n </dd>\n </dl>\n <div className=\"flex flex-wrap gap-2\">\n <RunButton running={p.running} onRun={p.onRun} name={a.name} />\n <Link to={editPath(a.id)} className={buttonClasses(\"ghost\", \"sm\")}>\n Edit\n <ChevronRight aria-hidden className=\"size-3.5\" />\n </Link>\n </div>\n </div>\n );\n}\n"],"ignoreList":[0],"mappings":"A,0nBASA,IAAMsC,EAAa,CACjB,KAAM,UACN,KAAM,GACN,KAAM,CACJ,CACE,OACA,CACE,EAAG,2EACH,IAAK,QACP,CACF,EACA,CAAC,OAAQ,CAAE,EAAG,4DAA6D,IAAK,QAAS,CAAC,EAC1F,CAAC,OAAQ,CAAE,EAAG,yDAA0D,IAAK,QAAS,CAAC,CACzF,CACF,EACAA,EAAW,KACX,IAAMC,EAAUjC,EAAiBgC,CAAU,E,iBCSrCI,EAAW,mBACXC,EAAY,GAAe,gBAAgB,mBAAmBC,CAAE,IAEhEC,EAAiD,CACrD,OAAQ1B,EACR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AASkB,EAAE,EAAE,EAAG,UAAWnD,EAAc,QAAS,IAAI,EAAhE,SAAA,CAAmE,QAEjE,EAAA+B,EAAA,IAAA,CAACvB,EAAD,CAAc,cAAA,GAAY,UAAU,UAAY,CAAA,CAC5C,CACH,CAAA,CAAA,C,EACF,C,EAET,C"}
@@ -1,10 +0,0 @@
1
- import{_ as e,d as t,f as n,i as r,m as i,n as a,t as o,u as s}from"./jsx-runtime-D13aM9HY.js";import{A as c,E as l,F as u,G as d,P as f,S as p,W as m,a as h,b as g,c as _,d as v,f as y,h as b,i as x,l as S,m as C,n as w,o as T,p as E,t as D,u as O,x as k,y as A}from"./states-DrTQuYXw.js";import{i as j,n as M,r as N,t as P}from"./Menu-C4GUY_ym.js";import{t as F}from"./arrow-left-C6YWM6y6.js";import{t as I}from"./server-SxFxIScj.js";import{t as ee}from"./chevron-right-evVLS6hq.js";import{t as te}from"./external-link-3jjTxo92.js";import{A as ne,C as L,D as re,E as ie,M as ae,N as R,O as oe,P as se,S as ce,T as le,_ as ue,a as z,b as de,c as fe,d as pe,f as B,g as me,h as he,i as ge,j as _e,k as ve,l as ye,m as be,n as xe,o as Se,p as Ce,r as we,s as Te,t as Ee,u as De,v as Oe,w as ke,x as Ae,y as je}from"./useNow-BQpDYijR.js";import{n as Me,t as Ne}from"./pencil-DI8QbCN8.js";import{t as Pe}from"./link-2-CaMlUDRG.js";import{t as Fe}from"./play-CjoDg3ws.js";import{t as Ie}from"./plus-BLP-wIYD.js";import{t as Le}from"./trash-C6X2OLrI.js";import{D as Re,E as ze,I as Be,L as Ve,N as He,U as Ue,b as We,c as V,d as Ge,f as Ke,i as qe,k as Je,l as Ye,n as Xe,o as Ze,p as Qe,s as $e,t as H,u as et,x as tt}from"./index-IdzOP9GE.js";import{n as nt,t as rt}from"./TextArea-BsQHOQMe.js";import{i as it,r as at,t as ot}from"./Markdown-jXkvZeRp.js";import{c as st}from"./dist-C-h8FC-n.js";import{t as ct}from"./SegmentedControl-ChdVilXb.js";import{i as lt,n as ut,r as dt,t as ft}from"./Overlay--v0ur2lj.js";var pt={name:`arrow-right-left`,size:24,node:[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]};pt.node;var mt=a(pt),ht={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};ht.node;var gt=a(ht),_t={name:`chevrons-up`,size:24,node:[[`path`,{d:`m17 11-5-5-5 5`,key:`e8nh98`}],[`path`,{d:`m17 18-5-5-5 5`,key:`2avn1x`}]]};_t.node;var vt=a(_t),yt={name:`columns-3`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]],aliases:[`panels-left-right`]};yt.node;var bt=a(yt),xt={name:`grip-vertical`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]};xt.node;var St=a(xt),Ct={name:`list`,size:24,node:[[`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`}]]};Ct.node;var wt=a(Ct),Tt={name:`message-square-warning`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 15h.01`,key:`q59x07`}],[`path`,{d:`M12 7v4`,key:`xawao1`}]]};Tt.node;var Et=a(Tt),Dt={name:`minus`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]};Dt.node;var Ot=a(Dt),kt={name:`rotate-ccw`,size:24,node:[[`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`}]]};kt.node;var At=a(kt),jt=Ue(),U=e(i()),Mt=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Nt(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function Pt(e){return`nodeType`in e}function W(e){return e?Nt(e)?e:Pt(e)?e.ownerDocument?.defaultView??window:window:window}function Ft(e){let{Document:t}=W(e);return e instanceof t}function It(e){return!Nt(e)&&e instanceof W(e).HTMLElement}function Lt(e){return e instanceof W(e).SVGElement}function Rt(e){return e?Nt(e)?e.document:Pt(e)?Ft(e)?e:It(e)||Lt(e)?e.ownerDocument:document:document:document}var G=Mt?U.useLayoutEffect:U.useEffect;function zt(e){let t=(0,U.useRef)(e);return G(()=>{t.current=e}),(0,U.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function Bt(){let e=(0,U.useRef)(null);return[(0,U.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,U.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function Vt(e,t){t===void 0&&(t=[e]);let n=(0,U.useRef)(e);return G(()=>{n.current!==e&&(n.current=e)},t),n}function Ht(e,t){let n=(0,U.useRef)();return(0,U.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function Ut(e){let t=zt(e),n=(0,U.useRef)(null);return[n,(0,U.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function Wt(e){let t=(0,U.useRef)();return(0,U.useEffect)(()=>{t.current=e},[e]),t.current}var Gt={};function Kt(e,t){return(0,U.useMemo)(()=>{if(t)return t;let n=Gt[e]==null?0:Gt[e]+1;return Gt[e]=n,e+`-`+n},[e,t])}function qt(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var Jt=qt(1),Yt=qt(-1);function Xt(e){return`clientX`in e&&`clientY`in e}function Zt(e){if(!e)return!1;let{KeyboardEvent:t}=W(e.target);return t&&e instanceof t}function Qt(e){if(!e)return!1;let{TouchEvent:t}=W(e.target);return t&&e instanceof t}function $t(e){if(Qt(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Xt(e)?{x:e.clientX,y:e.clientY}:null}var en=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[en.Translate.toString(e),en.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),tn=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function nn(e){return e.matches(tn)?e:e.querySelector(tn)}var rn={display:`none`};function an(e){let{id:t,value:n}=e;return U.createElement(`div`,{id:t,style:rn},n)}function on(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return U.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function sn(){let[e,t]=(0,U.useState)(``);return{announce:(0,U.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var cn=(0,U.createContext)(null);function ln(e){let t=(0,U.useContext)(cn);(0,U.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function un(){let[e]=(0,U.useState)(()=>new Set),t=(0,U.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,U.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var dn={draggable:`
2
- To pick up a draggable item, press the space bar.
3
- While dragging, use the arrow keys to move the item.
4
- Press space again to drop the item in its new position, or press escape to cancel.
5
- `},fn={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function pn(e){let{announcements:t=fn,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=dn}=e,{announce:a,announcement:o}=sn(),s=Kt(`DndLiveRegion`),[c,l]=(0,U.useState)(!1);if((0,U.useEffect)(()=>{l(!0)},[]),ln((0,U.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=U.createElement(U.Fragment,null,U.createElement(an,{id:r,value:i.draggable}),U.createElement(on,{id:s,announcement:o}));return n?(0,jt.createPortal)(u,n):u}var K;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(K||={});function mn(){}function hn(e,t){return(0,U.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function gn(){var e=[...arguments];return(0,U.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var q=Object.freeze({x:0,y:0});function _n(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function vn(e,t){let n=$t(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function yn(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function bn(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function xn(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function Sn(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function Cn(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var wn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=Cn(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=_n(Cn(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(yn)};function Tn(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var En=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=Tn(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(bn)};function Dn(e,t){let{top:n,left:r,bottom:i,right:a}=t;return n<=e.y&&e.y<=i&&r<=e.x&&e.x<=a}var On=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(!r)return[];let i=[];for(let e of t){let{id:t}=e,a=n.get(t);if(a&&Dn(r,a)){let n=xn(a).reduce((e,t)=>e+_n(r,t),0),o=Number((n/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:o}})}}return i.sort(yn)};function kn(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function An(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:q}function jn(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var Mn=jn(1);function Nn(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Pn(e,t,n){let r=Nn(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var Fn={ignoreTransform:!1};function In(e,t){t===void 0&&(t=Fn);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=W(e).getComputedStyle(e);t&&(n=Pn(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function Ln(e){return In(e,{ignoreTransform:!0})}function Rn(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function zn(e,t){return t===void 0&&(t=W(e).getComputedStyle(e)),t.position===`fixed`}function Bn(e,t){t===void 0&&(t=W(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`&&n.test(r)})}function Vn(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(Ft(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!It(i)||Lt(i)||n.includes(i))return n;let a=W(e).getComputedStyle(i);return i!==e&&Bn(i,a)&&n.push(i),zn(i,a)?n:r(i.parentNode)}return e?r(e):n}function Hn(e){let[t]=Vn(e,1);return t??null}function Un(e){return!Mt||!e?null:Nt(e)?e:Pt(e)?Ft(e)||e===Rt(e).scrollingElement?window:It(e)?e:null:null}function Wn(e){return Nt(e)?e.scrollX:e.scrollLeft}function Gn(e){return Nt(e)?e.scrollY:e.scrollTop}function Kn(e){return{x:Wn(e),y:Gn(e)}}var J;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(J||={});function qn(e){return!Mt||!e?!1:e===document.scrollingElement}function Jn(e){let t={x:0,y:0},n=qn(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var Yn={x:.2,y:.2};function Xn(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=Yn);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=Jn(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=J.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=J.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=J.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=J.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function Zn(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function Qn(e){return e.reduce((e,t)=>Jt(e,Kn(t)),q)}function $n(e){return e.reduce((e,t)=>e+Wn(t),0)}function er(e){return e.reduce((e,t)=>e+Gn(t),0)}function tr(e,t){if(t===void 0&&(t=In),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);Hn(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var nr=[[`x`,[`left`,`right`],$n],[`y`,[`top`,`bottom`],er]],rr=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=Vn(t),r=Qn(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of nr)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},ir=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function ar(e){let{EventTarget:t}=W(e);return e instanceof t?e:Rt(e)}function or(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t&&r>t.y}var Y;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(Y||={});function sr(e){e.preventDefault()}function cr(e){e.stopPropagation()}var X;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(X||={});var lr={start:[X.Space,X.Enter],cancel:[X.Esc],end:[X.Space,X.Enter,X.Tab]},ur=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case X.Right:return{...n,x:n.x+25};case X.Left:return{...n,x:n.x-25};case X.Down:return{...n,y:n.y+25};case X.Up:return{...n,y:n.y-25}}},dr=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new ir(Rt(t)),this.windowListeners=new ir(W(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Y.Resize,this.handleCancel),this.windowListeners.add(Y.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Y.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&tr(n),t(q)}handleKeyDown(e){if(Zt(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=lr,coordinateGetter:a=ur,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:q;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=Yt(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=Jn(n),p=Zn(n),m={x:Math.min(i===X.Right?p.right-p.width/2:p.right,Math.max(i===X.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===X.Down?p.bottom-p.height/2:p.bottom,Math.max(i===X.Down?p.top:p.top+p.height/2,u.y))},h=i===X.Right&&!s||i===X.Left&&!c,g=i===X.Down&&!l||i===X.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===X.Right&&e<=d.x||i===X.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}r.x=a?n.scrollLeft-e:i===X.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===X.Down&&e<=d.y||i===X.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}r.y=a?n.scrollTop-e:i===X.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,Jt(Yt(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};dr.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=lr,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function fr(e){return!!(e&&`distance`in e)}function pr(e){return!!(e&&`delay`in e)}var mr=class{constructor(e,t,n){n===void 0&&(n=ar(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=Rt(i),this.documentListeners=new ir(this.document),this.listeners=new ir(n),this.windowListeners=new ir(W(i)),this.initialCoordinates=$t(r)??q,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Y.Resize,this.handleCancel),this.windowListeners.add(Y.DragStart,sr),this.windowListeners.add(Y.VisibilityChange,this.handleCancel),this.windowListeners.add(Y.ContextMenu,sr),this.documentListeners.add(Y.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(pr(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(fr(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(Y.Click,cr,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Y.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=$t(e)??q,s=Yt(n,o);if(!t&&a){if(fr(a)){if(a.tolerance!=null&&or(s,a.tolerance))return this.handleCancel();if(or(s,a.distance))return this.handleStart()}if(pr(a)&&or(s,a.tolerance))return this.handleCancel();this.handlePending(a,s)}else e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===X.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},hr={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},gr=class extends mr{constructor(e){let{event:t}=e,n=Rt(t.target);super(e,hr,n)}};gr.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var _r={move:{name:`mousemove`},end:{name:`mouseup`}},vr;(function(e){e[e.RightClick=2]=`RightClick`})(vr||={});var yr=class extends mr{constructor(e){super(e,_r,Rt(e.event.target))}};yr.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button!==vr.RightClick&&(r?.({event:n}),!0)}}];var br={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},xr=class extends mr{constructor(e){super(e,br)}static setup(){return window.addEventListener(br.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(br.move.name,e)};function e(){}}};xr.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var Sr;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(Sr||={});var Cr;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(Cr||={});function wr(e){let{acceleration:t,activator:n=Sr.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=Cr.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=Er({delta:d,disabled:!a}),[m,h]=Bt(),g=(0,U.useRef)({x:0,y:0}),_=(0,U.useRef)({x:0,y:0}),v=(0,U.useMemo)(()=>{switch(n){case Sr.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Sr.DraggableRect:return i}},[n,i,c]),y=(0,U.useRef)(null),b=(0,U.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,U.useMemo)(()=>s===Cr.TreeOrder?[...l].reverse():l,[s,l]);(0,U.useEffect)(()=>{if(!a||!l.length||!v)h();else{for(let e of x){if(r?.(e)===!1)continue;let n=l.indexOf(e),i=u[n];if(!i)continue;let{direction:a,speed:s}=Xn(e,i,v,t,f);for(let e of[`x`,`y`])p[e][a[e]]||(s[e]=0,a[e]=0);if(s.x>0||s.y>0){h(),y.current=e,m(b,o),g.current=s,_.current=a;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()}},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var Tr={x:{[J.Backward]:!1,[J.Forward]:!1},y:{[J.Backward]:!1,[J.Forward]:!1}};function Er(e){let{delta:t,disabled:n}=e,r=Wt(t);return Ht(e=>{if(n||!r||!e)return Tr;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[J.Backward]:e.x[J.Backward]||i.x===-1,[J.Forward]:e.x[J.Forward]||i.x===1},y:{[J.Backward]:e.y[J.Backward]||i.y===-1,[J.Forward]:e.y[J.Forward]||i.y===1}}},[n,t,r])}function Dr(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return Ht(e=>t==null?null:r??e??null,[r,t])}function Or(e,t){return(0,U.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var kr;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(kr||={});var Ar;(function(e){e.Optimized=`optimized`})(Ar||={});var jr=new Map;function Mr(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,U.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,U.useRef)(e),d=g(),f=Vt(d),p=(0,U.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,U.useRef)(null),h=Ht(t=>{if(d&&!n)return jr;if(!t||t===jr||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new rr(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,U.useEffect)(()=>{u.current=e},[e]),(0,U.useEffect)(()=>{d||p()},[n,d]),(0,U.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,U.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case kr.Always:return!1;case kr.BeforeDragging:return n;default:return!n}}}function Nr(e,t){return Ht(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function Pr(e,t){return Nr(e,t)}function Fr(e){let{callback:t,disabled:n}=e,r=zt(t),i=(0,U.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,U.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Ir(e){let{callback:t,disabled:n}=e,r=zt(t),i=(0,U.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,U.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Lr(e){return new rr(In(e),e)}function Rr(e,t,n){t===void 0&&(t=Lr);let[r,i]=(0,U.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=Fr({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=Ir({callback:a});return G(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function zr(e){return An(e,Nr(e))}var Br=[];function Vr(e){let t=(0,U.useRef)(e),n=Ht(n=>e?n&&n!==Br&&e&&t.current&&e.parentNode===t.current.parentNode?n:Vn(e):Br,[e]);return(0,U.useEffect)(()=>{t.current=e},[e]),n}function Hr(e){let[t,n]=(0,U.useState)(null),r=(0,U.useRef)(e),i=(0,U.useCallback)(e=>{let t=Un(e.target);t&&n(e=>e?(e.set(t,Kn(t)),new Map(e)):null)},[]);return(0,U.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=Un(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,Kn(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{Un(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,U.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>Jt(e,t),q):Qn(e):q,[e,t])}function Ur(e,t){t===void 0&&(t=[]);let n=(0,U.useRef)(null);return(0,U.useEffect)(()=>{n.current=null},t),(0,U.useEffect)(()=>{let t=e!==q;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?Yt(e,n.current):q}function Wr(e){(0,U.useEffect)(()=>{if(!Mt)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function Gr(e,t){return(0,U.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function Kr(e){return(0,U.useMemo)(()=>e?Rn(e):null,[e])}var qr=[];function Jr(e,t){t===void 0&&(t=In);let[n]=e,r=Kr(n?W(n):null),[i,a]=(0,U.useState)(qr);function o(){a(()=>e.length?e.map(e=>qn(e)?r:new rr(t(e),e)):qr)}let s=Ir({callback:o});return G(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function Yr(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return It(t)?t:e}function Xr(e){let{measure:t}=e,[n,r]=(0,U.useState)(null),i=Ir({callback:(0,U.useCallback)(e=>{for(let{target:n}of e)if(It(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=Ut((0,U.useCallback)(e=>{let n=Yr(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,U.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var Zr=[{sensor:gr,options:{}},{sensor:dr,options:{}}],Qr={current:{}},$r={draggable:{measure:Ln},droppable:{measure:Ln,strategy:kr.WhileDragging,frequency:Ar.Optimized},dragOverlay:{measure:In}},ei=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},ti={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new ei,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:mn},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:$r,measureDroppableContainers:mn,windowRect:null,measuringScheduled:!1},ni={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:mn,draggableNodes:new Map,over:null,measureDroppableContainers:mn},ri=(0,U.createContext)(ni),ii=(0,U.createContext)(ti);function ai(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new ei}}}function oi(e,t){switch(t.type){case K.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case K.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case K.DragEnd:case K.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case K.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new ei(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case K.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new ei(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case K.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new ei(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function si(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,U.useContext)(ri),a=Wt(r),o=Wt(n?.id);return(0,U.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!Zt(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=nn(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function ci(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function li(e){return(0,U.useMemo)(()=>({draggable:{...$r.draggable,...e?.draggable},droppable:{...$r.droppable,...e?.droppable},dragOverlay:{...$r.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function ui(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,U.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;G(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=An(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=Hn(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var di=(0,U.createContext)({...q,scaleX:1,scaleY:1}),fi;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(fi||={});var pi=(0,U.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=Zr,collisionDetection:o=En,measuring:s,modifiers:c,...l}=e,[u,d]=(0,U.useReducer)(oi,void 0,ai),[f,p]=un(),[m,h]=(0,U.useState)(fi.Uninitialized),g=m===fi.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,U.useRef)({initial:null,translated:null}),C=(0,U.useMemo)(()=>_==null?null:{id:_,data:x?.data??Qr,rect:S},[_,x]),w=(0,U.useRef)(null),[T,E]=(0,U.useState)(null),[D,O]=(0,U.useState)(null),k=Vt(l,Object.values(l)),A=Kt(`DndDescribedBy`,t),j=(0,U.useMemo)(()=>b.getEnabled(),[b]),M=li(s),{droppableRects:N,measureDroppableContainers:P,measuringScheduled:F}=Mr(j,{dragging:g,dependencies:[y.x,y.y],config:M.droppable}),I=Dr(v,_),ee=(0,U.useMemo)(()=>D?$t(D):null,[D]),te=Oe(),ne=Pr(I,M.draggable.measure);ui({activeNode:_==null?null:v.get(_),config:te.layoutShiftCompensation,initialRect:ne,measure:M.draggable.measure});let L=Rr(I,M.draggable.measure,ne),re=Rr(I?I.parentElement:null),ie=(0,U.useRef)({activatorEvent:null,active:null,activeNode:I,collisionRect:null,collisions:null,droppableRects:N,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ae=b.getNodeFor(ie.current.over?.id),R=Xr({measure:M.dragOverlay.measure}),oe=R.nodeRef.current??I,se=g?R.rect??L:null,ce=!!(R.nodeRef.current&&R.rect),le=zr(ce?null:L),ue=Kr(oe?W(oe):null),z=Vr(g?ae??I:null),de=Jr(z),fe=ci(c,{transform:{x:y.x-le.x,y:y.y-le.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:L,containerNodeRect:re,draggingNodeRect:se,over:ie.current.over,overlayNodeRect:R.rect,scrollableAncestors:z,scrollableAncestorRects:de,windowRect:ue}),pe=ee?Jt(ee,y):null,B=Hr(z),me=Ur(B),he=Ur(B,[L]),ge=Jt(fe,me),_e=se?Mn(se,fe):null,ve=C&&_e?o({active:C,collisionRect:_e,droppableRects:N,droppableContainers:j,pointerCoordinates:pe}):null,ye=Sn(ve,`id`),[be,xe]=(0,U.useState)(null),Se=kn(ce?fe:Jt(fe,he),be?.rect??null,L),Ce=(0,U.useRef)(null),we=(0,U.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent,o=new n({active:w.current,activeNode:i,event:a,options:r,context:ie,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=k.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=k.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=k.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,jt.unstable_batchedUpdates)(()=>{r?.(i),h(fi.Initializing),d({type:K.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(Ce.current),O(a)})},onMove(e){d({type:K.DragMove,coordinates:e})},onEnd:s(K.DragEnd),onCancel:s(K.DragCancel)});Ce.current=o;function s(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=ie.current,o=null;if(t&&i){let{cancelDrop:s}=k.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===K.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=K.DragCancel)}w.current=null,(0,jt.unstable_batchedUpdates)(()=>{d({type:e}),h(fi.Uninitialized),xe(null),E(null),O(null),Ce.current=null;let t=e===K.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=k.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),Te=Or(a,(0,U.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,we(n,t))},[v,we]));Wr(a),G(()=>{L&&m===fi.Initializing&&h(fi.Initialized)},[L,m]),(0,U.useEffect)(()=>{let{onDragMove:e}=k.current,{active:t,activatorEvent:n,collisions:r,over:i}=ie.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:ge.x,y:ge.y},over:i};(0,jt.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[ge.x,ge.y]),(0,U.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=ie.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=k.current,o=r.get(ye),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,jt.unstable_batchedUpdates)(()=>{xe(s),a?.(c),f({type:`onDragOver`,event:c})})},[ye]),G(()=>{ie.current={activatorEvent:D,active:C,activeNode:I,collisionRect:_e,collisions:ve,droppableRects:N,draggableNodes:v,draggingNode:oe,draggingNodeRect:se,droppableContainers:b,over:be,scrollableAncestors:z,scrollAdjustedTranslate:ge},S.current={initial:se,translated:_e}},[C,I,ve,_e,v,oe,se,N,b,be,z,ge]),wr({...te,delta:y,draggingRect:_e,pointerCoordinates:pe,scrollableAncestors:z,scrollableAncestorRects:de});let Ee=(0,U.useMemo)(()=>({active:C,activeNode:I,activeNodeRect:L,activatorEvent:D,collisions:ve,containerNodeRect:re,dragOverlay:R,draggableNodes:v,droppableContainers:b,droppableRects:N,over:be,measureDroppableContainers:P,scrollableAncestors:z,scrollableAncestorRects:de,measuringConfiguration:M,measuringScheduled:F,windowRect:ue}),[C,I,L,D,ve,re,R,v,b,N,be,P,z,de,M,F,ue]),De=(0,U.useMemo)(()=>({activatorEvent:D,activators:Te,active:C,activeNodeRect:L,ariaDescribedById:{draggable:A},dispatch:d,draggableNodes:v,over:be,measureDroppableContainers:P}),[D,Te,C,L,d,A,v,be,P]);return U.createElement(cn.Provider,{value:p},U.createElement(ri.Provider,{value:De},U.createElement(ii.Provider,{value:Ee},U.createElement(di.Provider,{value:Se},i)),U.createElement(si,{disabled:n?.restoreFocus===!1})),U.createElement(pn,{...n,hiddenTextDescribedById:A}));function Oe(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),mi=(0,U.createContext)(null),hi=`button`,gi=`Draggable`;function _i(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=Kt(gi),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,U.useContext)(ri),{role:p=hi,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,U.useContext)(g?di:mi),[v,y]=Ut(),[b,x]=Ut(),S=Gr(o,t),C=Vt(n);return G(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,U.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===hi?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function vi(){return(0,U.useContext)(ii)}var yi=`Droppable`,bi={timeout:25};function xi(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=Kt(yi),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,U.useContext)(ri),u=(0,U.useRef)({disabled:n}),d=(0,U.useRef)(!1),f=(0,U.useRef)(null),p=(0,U.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...bi,...i},_=Vt(h??r),v=Ir({callback:(0,U.useCallback)(()=>{d.current?(p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)):d.current=!0},[g]),disabled:m||!o}),[y,b]=Ut((0,U.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=Vt(t);return(0,U.useEffect)(()=>{v&&y.current&&(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,U.useEffect)(()=>(s({type:K.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:K.UnregisterDroppable,key:a,id:r})),[r]),(0,U.useEffect)(()=>{n!==u.current.disabled&&(s({type:K.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function Si(e){let{animation:t,children:n}=e,[r,i]=(0,U.useState)(null),[a,o]=(0,U.useState)(null),s=Wt(n);return!n&&!r&&s&&i(s),G(()=>{if(!a)return;let e=r?.key,n=r?.props.id;e==null||n==null?i(null):Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),U.createElement(U.Fragment,null,n,r?(0,U.cloneElement)(r,{ref:o}):null)}var Ci={x:0,y:0,scaleX:1,scaleY:1};function wi(e){let{children:t}=e;return U.createElement(ri.Provider,{value:ni},U.createElement(di.Provider,{value:Ci},t))}var Ti={position:`fixed`,touchAction:`none`},Ei=e=>Zt(e)?`transform 250ms ease`:void 0,Di=(0,U.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=Ei}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...Ti,width:s.width,height:s.height,top:s.top,left:s.left,transform:en.Transform.toString(d),transformOrigin:i&&r?vn(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return U.createElement(n,{className:o,style:f,ref:t},a)}),Oi={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:en.Transform.toString(t)},{transform:en.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function ki(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return zt((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=Yr(a);if(!c)return;let{transform:l}=W(a).getComputedStyle(a),u=Nn(l);if(!u)return;let d=typeof t==`function`?t:Ai(t);return tr(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function Ai(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...Oi,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var ji=0;function Mi(e){return(0,U.useMemo)(()=>{if(e!=null)return ji++,ji},[e])}var Ni=U.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:v,scrollableAncestors:y,scrollableAncestorRects:b,windowRect:x}=vi(),S=(0,U.useContext)(di),C=Mi(d?.id),w=ci(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:y,scrollableAncestorRects:b,transform:S,windowRect:x}),T=Nr(f),E=ki({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return U.createElement(wi,null,U.createElement(Si,{animation:E},d&&C?U.createElement(Di,{key:C,id:d.id,ref:D,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:T,style:{zIndex:l,...i},transform:w},n):null))}),Z=o(),Pi=(0,U.createContext)(null);function Fi(){let e=(0,U.useContext)(Pi);if(!e)throw Error(`useTaskMover must be used inside <MoveProvider>`);return e}var Ii=`Accepting marks the task Done. It does not merge or push.`;function Li({children:e}){let[t,n]=(0,U.useState)({}),[r,i]=(0,U.useState)(null),[a,o]=(0,U.useState)(null),s=(0,U.useCallback)(async(e,t)=>{n(t=>({...t,[e]:!0}));try{await t()}finally{n(t=>{let{[e]:n,...r}=t;return r})}},[]),c=(0,U.useCallback)(async(e,t)=>{if(t===`ready`)try{let t=await re(e.id);V.success(`Moved to Ready. ${me(t)}.`)}catch{V.success(`Moved to Ready. The dispatcher starts it when it is eligible.`)}else V.success(`Moved "${e.title}" to ${B[t]}`)},[]),l=(0,U.useCallback)(async(e,t,n)=>{try{return await ve(e.id,{to:t,...n}),await c(e,t),!0}catch(r){return!n.onRunning&&_e(r)?(i({kind:`choice`,task:e,to:t,position:n.position,reasons:[],carry:{confirm:n.confirm}}),!1):!n.confirm&&ne(r)?(i({kind:`confirm_done`,task:e,to:t,position:n.position,reasons:[m(r)],carry:{onRunning:n.onRunning}}),!1):(V.error(`Could not move "${e.title}": ${m(r)}`),!1)}},[c]),u=(0,U.useCallback)(e=>s(e.id,async()=>{try{await R(e.id,`run-now`),V.info(`Dispatch requested for "${e.title}". Waiting for the host to confirm.`)}catch(t){V.error(`Cannot run "${e.title}" now: ${m(t)}`)}}),[s]),p=(0,U.useCallback)(e=>s(e.id,async()=>{try{await R(e.id,`new-attempt`),V.info(`New attempt requested for "${e.title}".`)}catch(t){if(d(t,`native_session_missing`)){i({kind:`fresh_attempt`,task:e,to:`in_progress`,reasons:[m(t)]});return}V.error(`Could not start a new attempt: ${m(t)}`)}}),[s]),h=(0,U.useCallback)(async(e,t,n={})=>{let r=e.currentRunId?f.getState().runs[e.currentRunId]:void 0,a=Ae(e,t,r);switch(a.kind){case`noop`:return;case`invalid`:V.error(a.reason);return;case`run_now`:return u(e);case`new_attempt`:return p(e);case`choose_running`:i({kind:`choice`,task:e,to:t,position:n.position,reasons:[]});return;case`confirm_done`:i({kind:`confirm_done`,task:e,to:t,position:n.position,reasons:a.reasons});return;case`move`:await s(e.id,async()=>{await l(e,t,{position:n.position})})}},[u,p,l,s]),g=(0,U.useCallback)((e,t)=>s(e.id,async()=>{try{await se(e.id,{position:t})}catch(e){V.error(`Could not reorder: ${m(e)}`)}}),[s]),_=async e=>{if(!r)return;let t=r;o(e);try{if(t.kind===`fresh_attempt`)try{await R(t.task.id,`new-attempt`,{},`?fresh=true`),V.info(`New attempt in a fresh session requested for "${t.task.title}".`)}catch(e){V.error(`Could not start a new attempt: ${m(e)}`)}else t.via===`accept`?await s(t.task.id,async()=>{try{await R(t.task.id,`accept`,{confirm:!0}),V.success(`Accepted "${t.task.title}". It is Done.`)}catch(e){V.error(`Could not accept: ${m(e)}`)}}):await s(t.task.id,async()=>{await l(t.task,t.to,{position:t.position,...t.carry,...e===`confirm`?{confirm:!0}:{onRunning:e}})})}finally{o(null),i(e=>e===t?null:e)}},v=(0,U.useCallback)(e=>s(e.id,async()=>{try{await R(e.id,`accept`,{}),V.success(`Accepted "${e.title}". It is Done.`)}catch(t){if(ne(t)){i({kind:`confirm_done`,task:e,to:`done`,reasons:[m(t)],via:`accept`});return}V.error(`Could not accept: ${m(t)}`)}}),[s]),y=(0,U.useMemo)(()=>({move:h,runNow:u,newAttempt:p,reorder:g,accept:v,isBusy:e=>!!t[e]}),[h,u,p,g,v,t]),b=()=>{a||i(null)};return(0,Z.jsxs)(Pi.Provider,{value:y,children:[e,(0,Z.jsx)(ft,{open:r?.kind===`choice`,onClose:b,title:`This task is running`,description:r?`Moving "${r.task.title}" to ${B[r.to]} needs a decision about its active run. Nothing changes until you choose.`:void 0,footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(S,{onClick:b,disabled:!!a,children:`Keep running`}),(0,Z.jsx)(S,{icon:(0,Z.jsx)(He,{className:`size-4`}),busy:a===`pause`,disabled:!!a,onClick:()=>void _(`pause`),children:`Pause automation`}),(0,Z.jsx)(S,{variant:`danger`,icon:(0,Z.jsx)(We,{className:`size-4`}),busy:a===`stop`,disabled:!!a,onClick:()=>void _(`stop`),children:`Stop execution`})]}),children:(0,Z.jsxs)(`ul`,{className:`flex flex-col gap-2 text-sm`,children:[(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:`Pause automation`}),`: you take over the session. The agent keeps its current turn, and automatic continuations, retries and successor runs stop until you return it to automation.`]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:`Stop execution`}),`: aborts the current run. The session and its workspace are kept.`]})]})}),(0,Z.jsxs)(ft,{open:r?.kind===`confirm_done`,onClose:b,title:`Accept and mark Done?`,description:Ii,footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(S,{onClick:b,disabled:!!a,children:`Cancel`}),(0,Z.jsx)(S,{variant:`primary`,busy:a===`confirm`,disabled:!!a,onClick:()=>void _(`confirm`),children:`Accept and mark Done`})]}),children:[(0,Z.jsx)(`p`,{className:`mb-2 text-sm`,children:`These items are unresolved:`}),(0,Z.jsx)(`ul`,{className:`list-disc space-y-1 pl-5 text-sm`,children:r?.reasons.map(e=>(0,Z.jsx)(`li`,{children:e},e))}),r&&r.task.acceptanceCriteria.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`mt-3 mb-1 text-sm font-medium`,children:`Acceptance criteria`}),(0,Z.jsx)(`ul`,{className:`list-disc space-y-1 pl-5 text-sm text-muted`,children:r.task.acceptanceCriteria.map(e=>(0,Z.jsx)(`li`,{children:e},e))})]})]}),(0,Z.jsx)(ft,{open:r?.kind===`fresh_attempt`,onClose:b,title:`Start a fresh session?`,description:r?.reasons[0],footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(S,{onClick:b,disabled:!!a,children:`Cancel`}),(0,Z.jsx)(S,{variant:`primary`,busy:a===`confirm`,onClick:()=>void _(`confirm`),children:`Start fresh session`})]}),children:(0,Z.jsx)(`p`,{className:`text-sm`,children:`The previous Pi session is no longer available on the host, so the new attempt cannot continue it. A fresh session starts with the task objective and your review feedback.`})})]})}var Ri={0:{label:st[0],icon:vt,tone:`danger`},1:{label:st[1],icon:gt,tone:`warning`},2:{label:st[2],icon:Ot,tone:`neutral`},3:{label:st[3],icon:j,tone:`neutral`}};function zi(e){let t=f(e=>e.runs),n=f(e=>e.hosts),r=f(e=>e.sessions),i=f(e=>e.workspaces),a=f(e=>e.projects),o=f(e=>e.attention),s=f(e=>e.interactions);return(0,U.useMemo)(()=>{if(!e)return{run:void 0,hostName:null,hostOffline:!1,branch:null,projectName:null,attention:[],pendingInteraction:void 0};let c=e.currentRunId?t[e.currentRunId]:void 0,l=e.sessionId?r[e.sessionId]:void 0,u=c?.hostId??l?.hostId??e.policy.hostId??null,d=u?n[u]:void 0,f=(l?.workspaceId?i[l.workspaceId]:void 0)?.branch??(e.policy.workspace.mode===`new_worktree`?e.policy.workspace.branch:null)??(e.policy.workspace.mode===`existing`?i[e.policy.workspace.workspaceId]?.branch??null:null),p=Object.values(o).filter(t=>!t.resolvedAt&&(t.taskId===e.id||!!e.sessionId&&t.sessionId===e.sessionId)),m=e.sessionId?Object.values(s).filter(t=>t.sessionId===e.sessionId&&t.state===`pending`).sort((e,t)=>e.createdAt.localeCompare(t.createdAt))[0]:void 0;return{run:c,hostName:d?.name??null,hostOffline:!!d&&d.connectivity!==`connected`,branch:f??null,projectName:a[e.projectId]?.name??null,attention:p,pendingInteraction:m}},[e,t,n,r,i,a,o,s])}function Bi(e,t,n){if(e.blocked)return{icon:k,text:`Blocked: ${e.blocked.reason}`,tone:`danger`};if(e.state===`in_progress`&&t){let e=et[t.state],n=t.controlMode===`human`?` · You have control`:``;return{icon:e.icon,text:`${e.label}${n}`,tone:e.tone,spin:e.spin}}return e.state===`ready`?n&&!n.eligible?{icon:Je,text:n.message||Ce[n.wait],tone:`warning`}:n?.eligible?{icon:Je,text:`Starting on ${n.hostName}`,tone:`info`}:{icon:Je,text:`Queued for dispatch`,tone:`neutral`}:e.state===`review`?e.review.changesRequested?{icon:k,text:`Changes requested`,tone:`warning`}:t?.outcome?{icon:et.succeeded.icon,text:t.outcome.summary||`Ready for review`,tone:`info`}:{icon:et.succeeded.icon,text:`Ready for review`,tone:`info`}:null}var Vi=`Accepting marks the task Done. It does not merge or push.`;function Hi(e){return e.sessionId?`${H.session(e.sessionId)}?tab=changes`:null}function Ui(e){let t=!!e&&(e.state===`ready`||e.state===`backlog`),n=t?`${e.id}:${e.state}:${e.updatedAt}`:null,r=xe(n,t=>re(e.id,t)),i=f(e=>e.hosts),a=f(e=>e.tasks),o=f(e=>e.projects),s=f(e=>e.runs),c=f(e=>e.dispatchPaused),l=(0,U.useMemo)(()=>{if(!e)return;let t={};for(let e of Object.values(s)){if(!ue(e))continue;let n=a[e.taskId]?.projectId;n&&(t[n]=(t[n]??0)+1)}return L({project:o[e.projectId],hostId:e.policy.hostId,dependencies:e.dependencies,notBefore:e.notBefore},{hosts:i,tasks:a,dispatchPaused:c,runningByProject:t})},[e,i,a,o,s,c]),u=r.data,d;return t?u?d=!u.eligible&&u.wait===`not_ready`?l:u:r.error&&(d=l):d=void 0,{eligibility:d,loading:r.loading&&!r.data,error:r.error,estimated:!!d&&d===l}}function Wi({title:e,children:t,action:n}){let r=(0,U.useId)();return(0,Z.jsxs)(`section`,{"aria-labelledby":r,className:`flex min-w-0 flex-col gap-2 border-b border-border py-4 last:border-b-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`h3`,{id:r,className:`min-w-0 flex-1 text-sm font-semibold`,children:e}),n]}),t]})}function Q({label:e,children:t}){return(0,Z.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(7rem,auto)_1fr] gap-x-3 text-sm`,children:[(0,Z.jsx)(`dt`,{className:`text-muted`,children:e}),(0,Z.jsx)(`dd`,{className:`min-w-0 break-words`,children:t})]})}function Gi({task:e,eligibility:t,block:n}){let i=Fi(),a=i.isBusy(e.id),[o,s]=(0,U.useState)(!1),c=t?(0,Z.jsx)(Ki,{e:t,prefix:e.state===`backlog`?`If made ready: `:``}):null;switch(e.state){case`backlog`:return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Z.jsx)(S,{variant:`primary`,block:n,busy:a,icon:(0,Z.jsx)(Fe,{className:`size-4`}),onClick:()=>void i.move(e,`ready`),children:`Make ready`}),c]});case`ready`:return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Z.jsx)(S,{variant:`primary`,block:n,busy:a,icon:(0,Z.jsx)(Fe,{className:`size-4`}),onClick:()=>void i.runNow(e),children:`Run now`}),c]});case`in_progress`:return e.sessionId?(0,Z.jsxs)(r,{to:H.session(e.sessionId),className:v(`primary`,`md`,n?`w-full`:void 0),children:[(0,Z.jsx)(te,{"aria-hidden":!0,className:`size-4`}),`Open session`]}):(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:e.blocked?`No session is attached to this task.`:`The session is starting; Open session appears once the host confirms the launch.`});case`review`:{let t=Hi(e);return t?(0,Z.jsxs)(r,{to:t,className:v(`primary`,`md`,n?`w-full`:void 0),children:[(0,Z.jsx)(ze,{"aria-hidden":!0,className:`size-4`}),`Review changes`]}):(0,Z.jsxs)(`a`,{href:`#task-review`,className:v(`primary`,`md`,n?`w-full`:void 0),children:[(0,Z.jsx)(ze,{"aria-hidden":!0,className:`size-4`}),`Review changes`]})}case`done`:return(0,Z.jsx)(S,{variant:`primary`,block:n,busy:o,icon:(0,Z.jsx)(At,{className:`size-4`}),onClick:async()=>{s(!0);try{await R(e.id,`reopen`),V.success(`Reopened "${e.title}"`)}catch(e){V.error(`Could not reopen: ${m(e)}`)}finally{s(!1)}},children:`Reopen`});case`canceled`:return(0,Z.jsx)(S,{variant:`primary`,block:n,busy:a,icon:(0,Z.jsx)(At,{className:`size-4`}),onClick:()=>void i.move(e,`backlog`),children:`Restore to Backlog`})}}function Ki({e,prefix:t=``}){let n=e.eligible?Be:Je;return(0,Z.jsxs)(`p`,{role:`status`,className:b(`flex items-start gap-1.5 text-sm`,e.eligible?`text-success`:`text-warning`),children:[(0,Z.jsx)(n,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0`}),(0,Z.jsxs)(`span`,{className:`min-w-0 break-words text-text`,children:[t,me(e)]})]})}function qi({task:e,onDeleted:t}){let n=zi(e),{eligibility:i,error:a}=Ui(e),o=f(e=>e.tasks),s=f(e=>e.hosts),c=f(e=>e.profiles),l=f(e=>e.projects),u=f(e=>e.workspaces),g=f(e=>e.runs),b=xe(`${e.id}:${e.currentRunId??``}`,t=>oe(e.id,t)),T=(0,U.useMemo)(()=>{let t=new Map;for(let e of b.data??[])t.set(e.id,e);for(let n of p(g,e.id)){let e=t.get(n.id);(!e||e.updatedAt<=n.updatedAt)&&t.set(n.id,n)}return[...t.values()].sort((e,t)=>t.attempt-e.attempt||t.createdAt.localeCompare(e.createdAt))},[b.data,g,e.id]),[D,O]=(0,U.useState)(!1),A=l[e.projectId],j=n.run,M=Bi(e,j,i),N=e.policy.hostId??A?.defaultHostId??null,P=N?s[N]:void 0,F=j?.hostId?s[j.hostId]:void 0,I=F&&F.connectivity!==`connected`?F:void 0,ee=Ri[e.priority],ne=ee.icon,L=e.policy.profileId??A?.defaultProfileId??null,re=f(t=>e.sessionId?Object.values(t.interactions).filter(t=>t.sessionId===e.sessionId&&t.state===`pending`).length:0);return(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col`,"data-testid":`task-detail`,children:[re>0&&e.sessionId&&n.pendingInteraction&&(0,Z.jsx)(h,{count:re,to:H.interaction(e.sessionId,n.pendingInteraction.id),className:`mt-3`}),I&&(0,Z.jsx)(x,{compact:!0,className:`mt-3`,hostName:I.name,connectivity:I.connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:I.lastSeenAt,detail:`The run keeps its last known state. Switchyard does not restart it on another host.`}),(0,Z.jsx)(Wi,{title:`Objective and acceptance criteria`,action:!D&&(0,Z.jsx)(S,{size:`sm`,variant:`ghost`,icon:(0,Z.jsx)(Ne,{className:`size-3.5`}),onClick:()=>O(!0),children:`Edit`}),children:D?(0,Z.jsx)(Zi,{task:e,onDone:()=>O(!1)}):(0,Z.jsxs)(Z.Fragment,{children:[e.objective.trim()?(0,Z.jsx)(ot,{text:e.objective}):(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No objective yet. Edit the task to describe what done looks like.`}),(0,Z.jsx)(`h4`,{className:`pt-1 text-xs font-semibold tracking-wide text-muted uppercase`,children:`Acceptance criteria`}),e.acceptanceCriteria.length>0?(0,Z.jsx)(`ul`,{className:`list-disc space-y-1 pl-5 text-sm`,children:e.acceptanceCriteria.map(e=>(0,Z.jsx)(`li`,{className:`break-words`,children:e},e))}):(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No acceptance criteria.`})]})}),(0,Z.jsxs)(Wi,{title:`State`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(Ge,{kind:`task`,value:e.state}),(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-sm text-muted`,children:[(0,Z.jsx)(ne,{"aria-hidden":!0,className:`size-4`}),ee.label,` priority`]})]}),e.blocked&&(0,Z.jsxs)(`p`,{className:`flex items-start gap-1.5 rounded-md bg-danger-soft px-3 py-2 text-sm`,children:[(0,Z.jsx)(k,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-danger`}),(0,Z.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:`Blocked:`}),` `,e.blocked.reason]})]}),M&&!e.blocked&&!(e.state===`ready`&&i)&&(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:M.text}),(e.state===`ready`||e.state===`backlog`)&&i&&(0,Z.jsx)(Ki,{e:i,prefix:e.state===`backlog`?`If made ready: `:``}),a!==null&&d(a)&&a.status===404&&(0,Z.jsx)(`p`,{className:`text-xs text-muted`,children:`Eligibility is estimated on this device; the coordinator did not report it.`}),e.notBefore&&(0,Z.jsxs)(`p`,{className:`text-sm text-muted`,children:[`Not before `,C(e.notBefore)]})]}),(0,Z.jsxs)(Wi,{title:`Current run`,children:[j?(0,Z.jsxs)(`dl`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(Q,{label:`Status`,children:(0,Z.jsx)(Ge,{kind:`run`,value:j.state,size:`sm`})}),(0,Z.jsx)(Q,{label:`Attempt`,children:j.attempt}),(0,Z.jsx)(Q,{label:`Control`,children:j.controlMode===`human`?`You (automation paused)`:`Automation`}),F&&(0,Z.jsx)(Q,{label:`Host`,children:F.name}),j.startedAt&&(0,Z.jsx)(Q,{label:`Started`,children:E(j.startedAt)}),(0,Z.jsx)(Q,{label:`Continuations`,children:j.continuationsUsed}),(0,Z.jsx)(Q,{label:`Usage`,children:j.usage.accounting===`available`?`${j.usage.tokens??0} tokens${j.usage.costUsd===null?``:` · $${j.usage.costUsd.toFixed(2)}`}`:j.usage.note??`Token/cost accounting not reported`}),j.outcome&&(0,Z.jsx)(Q,{label:`Outcome`,children:j.outcome.summary})]}):(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No run yet.`}),e.sessionId&&(0,Z.jsx)(`div`,{children:(0,Z.jsxs)(r,{to:H.session(e.sessionId),className:v(`secondary`,`sm`),children:[(0,Z.jsx)(te,{"aria-hidden":!0,className:`size-3.5`}),`Open session`]})})]}),e.state===`review`&&(0,Z.jsx)(Xi,{task:e}),(0,Z.jsx)(Wi,{title:`Dependencies`,children:e.dependencies.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No dependencies.`}):(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.dependencies.map(e=>{let t=o[e];return(0,Z.jsx)(`li`,{className:`flex min-w-0 items-center gap-2 text-sm`,children:t?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ge,{kind:`task`,value:t.state,size:`sm`}),(0,Z.jsx)(r,{to:H.task(e),className:`min-w-0 truncate text-accent hover:underline`,children:t.title})]}):(0,Z.jsx)(`span`,{className:`text-muted`,children:`A task that is no longer available`})},e)})})}),(0,Z.jsxs)(Wi,{title:`Host, profile and workspace`,children:[(0,Z.jsxs)(`dl`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(Q,{label:`Project`,children:A?.name??`Unknown project`}),(0,Z.jsx)(Q,{label:`Host`,children:e.policy.hostId?P?.name??`Unknown host`:`Project default${P?` (${P.name})`:``}`}),(0,Z.jsx)(Q,{label:`Profile`,children:e.policy.profileId?c[e.policy.profileId]?.name??`Unknown profile`:`Project default${L&&c[L]?` (${c[L].name})`:``}`}),(0,Z.jsx)(Q,{label:`Workspace`,children:e.policy.workspace.mode===`existing`?`Existing: ${u[e.policy.workspace.workspaceId]?.branch??u[e.policy.workspace.workspaceId]?.path??`unknown workspace`}`:`New worktree${e.policy.workspace.branch?` on ${e.policy.workspace.branch}`:``}${e.policy.workspace.base?` from ${e.policy.workspace.base}`:``}`}),A&&(0,Z.jsx)(Q,{label:`Sharing`,children:A.workspaceSharing===`single_writer`?`Single writer`:`Shared`})]}),P&&!P.piCompatible&&(0,Z.jsx)(_,{capability:`Running on this host`,reason:`Pi ${P.piVersion??`(unknown version)`} on ${P.name} is not compatible with Switchyard.`})]}),(0,Z.jsxs)(Wi,{title:`Limits and completion`,children:[(0,Z.jsxs)(`dl`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(Q,{label:`Continuation`,children:e.policy.continuation.enabled?`Up to ${e.policy.continuation.maxContinuations} continuations within ${e.policy.continuation.maxElapsedMinutes} min${e.policy.continuation.maxTokens?`, ${e.policy.continuation.maxTokens} tokens`:``}${e.policy.continuation.maxCostUsd?`, $${e.policy.continuation.maxCostUsd}`:``}`:`Off`}),(0,Z.jsx)(Q,{label:`Checks`,children:e.policy.completion.checks===null?`Project default${A?.checks.length?` (${A.checks.join(`, `)})`:` (none)`}`:e.policy.completion.checks.length>0?e.policy.completion.checks.join(`, `):`None`}),(0,Z.jsx)(Q,{label:`Human review`,children:e.policy.completion.requireHumanReview?`Required`:`Not required`})]}),j&&j.checks.length>0&&(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1 text-sm`,children:j.checks.map(e=>(0,Z.jsxs)(`li`,{className:`flex min-w-0 items-start gap-1.5`,children:[e.exitCode===0?(0,Z.jsx)(Be,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-success`}):(0,Z.jsx)(k,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-danger`}),(0,Z.jsx)(`span`,{className:`min-w-0 break-all font-mono text-xs`,children:e.command}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-muted`,children:e.exitCode===0?`Passed`:`Failed (${e.exitCode??`no exit code`})`})]},e.command))})]}),(0,Z.jsxs)(Wi,{title:`Run history and activity`,children:[b.error!==null&&!b.data&&T.length===0&&(0,Z.jsx)(w,{compact:!0,title:`Could not load run history`,error:m(b.error),onRetry:b.reload}),T.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:b.loading?`Loading runs…`:`No runs yet.`}):(0,Z.jsx)(`ol`,{className:`flex flex-col gap-2`,children:T.map(e=>(0,Z.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-0.5 rounded-md border border-border px-3 py-2 text-sm`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`span`,{className:`font-medium`,children:[`Attempt `,e.attempt]}),(0,Z.jsx)(Ge,{kind:`run`,value:e.state,size:`sm`})]}),e.outcome&&(0,Z.jsx)(`p`,{className:`break-words text-muted`,children:e.outcome.summary}),(0,Z.jsxs)(`p`,{className:`text-xs text-subtle`,children:[e.startedAt?`Started ${C(e.startedAt)}`:`Created ${C(e.createdAt)}`,e.startedAt&&e.endedAt?` · ${y(Date.parse(e.endedAt)-Date.parse(e.startedAt))}`:``,e.infraRetries>0?` · ${e.infraRetries} infrastructure retries`:``]})]},e.id))}),e.review.feedback.length>0&&(0,Z.jsxs)(`div`,{className:`text-sm`,children:[(0,Z.jsx)(`p`,{className:`font-medium`,children:`Review feedback`}),(0,Z.jsx)(`ul`,{className:`list-disc pl-5 text-muted`,children:e.review.feedback.map(e=>(0,Z.jsx)(`li`,{className:`break-words`,children:e},e))})]}),(0,Z.jsxs)(`p`,{className:`text-xs text-subtle`,children:[`Created `,C(e.createdAt),` · last activity `,E(e.lastActivityAt),e.origin.kind===`automation`?` · created by an automation`:``]})]}),(0,Z.jsx)(Ji,{task:e,onDeleted:t})]})}function Ji({task:e,onDeleted:t}){let[n,r]=(0,U.useState)(!1),[i,a]=(0,U.useState)(!1);return e.state!==`backlog`&&e.state!==`canceled`&&e.state!==`done`?null:(0,Z.jsxs)(`div`,{className:`py-4`,children:[(0,Z.jsx)(S,{variant:`ghost`,size:`sm`,icon:(0,Z.jsx)(Le,{className:`size-4`}),className:`text-danger`,onClick:()=>r(!0),children:`Delete task`}),(0,Z.jsx)(ft,{open:n,onClose:()=>!i&&r(!1),title:`Delete this task?`,description:`"${e.title}" and its history are removed from the board. Sessions and workspaces are kept.`,footer:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(S,{onClick:()=>r(!1),disabled:i,children:`Cancel`}),(0,Z.jsx)(S,{variant:`danger`,busy:i,onClick:async()=>{a(!0);try{await ie(e.id),V.success(`Deleted "${e.title}"`),r(!1),t?.()}catch(e){V.error(`Could not delete: ${m(e)}`)}finally{a(!1)}},children:`Delete task`})]})})]})}var Yi=e=>`sy:feedback:${e}`;function Xi({task:e}){let t=Fi(),r=n(),[i,a]=(0,U.useState)(()=>sessionStorage.getItem(Yi(e.id))??``),[o,s]=(0,U.useState)(null),c=(0,U.useId)();(0,U.useEffect)(()=>{i?sessionStorage.setItem(Yi(e.id),i):sessionStorage.removeItem(Yi(e.id))},[i,e.id]);let l=Hi(e),u=i.split(`
6
- `).map(e=>e.replace(/^[-*]\s*/,``).trim()).filter(Boolean);return(0,Z.jsxs)(`section`,{id:`task-review`,"aria-labelledby":`${c}-h`,className:`flex min-w-0 flex-col gap-3 border-b border-border py-4`,children:[(0,Z.jsx)(`h3`,{id:`${c}-h`,className:`text-sm font-semibold`,children:`Review`}),l&&(0,Z.jsx)(`div`,{children:(0,Z.jsx)(S,{size:`sm`,icon:(0,Z.jsx)(ze,{className:`size-3.5`}),onClick:()=>r(l),children:`Review changes`})}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`label`,{htmlFor:c,className:`text-sm font-medium`,children:`Feedback for the next attempt`}),(0,Z.jsx)(rt,{id:c,minRows:3,maxHeight:`40vh`,placeholder:`One change per line`,value:i,onChange:e=>a(e.target.value)}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(S,{icon:(0,Z.jsx)(Et,{className:`size-4`}),busy:o===`changes`,disabled:o!==null||u.length===0,onClick:async()=>{s(`changes`);try{await ae(e.id,u),a(``),V.success(`Changes requested. Start a new attempt when ready.`)}catch(e){V.error(`Could not request changes: ${m(e)}`)}finally{s(null)}},children:`Request changes`}),(0,Z.jsx)(S,{icon:(0,Z.jsx)(At,{className:`size-4`}),busy:t.isBusy(e.id),disabled:o!==null,onClick:()=>void t.newAttempt(e),children:`Start new attempt`})]}),u.length===0&&(0,Z.jsx)(`p`,{className:`text-xs text-muted`,children:`Write at least one line of feedback to request changes.`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(S,{variant:`primary`,icon:(0,Z.jsx)(Be,{className:`size-4`}),busy:t.isBusy(e.id),disabled:o!==null,onClick:()=>void t.accept(e),children:`Accept task`}),(0,Z.jsx)(`p`,{className:`text-xs text-muted`,children:Vi})]})]})}function Zi({task:e,onDone:t}){let n=f(e=>e.tasks),[r,i]=(0,U.useState)(e.title),[a,o]=(0,U.useState)(e.objective),[s,c]=(0,U.useState)(e.acceptanceCriteria.join(`
7
- `)),[l,u]=(0,U.useState)(e.priority),[d,p]=(0,U.useState)(e.dependencies),[h,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)(null),y=(0,U.useId)(),b=Object.values(n).filter(t=>t.projectId===e.projectId&&t.id!==e.id&&t.state!==`canceled`&&!t.hiddenFromBoard).sort((e,t)=>e.title.localeCompare(t.title));return(0,Z.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:async n=>{if(n.preventDefault(),!r.trim())v(`Title is required.`);else{g(!0),v(null);try{await se(e.id,{title:r.trim(),objective:a,acceptanceCriteria:s.split(`
8
- `).map(e=>e.trim()).filter(Boolean),priority:l,dependencies:d}),V.success(`Task saved`),t()}catch(e){v(m(e))}finally{g(!1)}}},children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`label`,{htmlFor:`${y}-title`,className:`text-sm font-medium`,children:`Title`}),(0,Z.jsx)(nt,{id:`${y}-title`,value:r,onChange:e=>i(e.target.value),required:!0})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`label`,{htmlFor:`${y}-obj`,className:`text-sm font-medium`,children:`Objective`}),(0,Z.jsx)(rt,{id:`${y}-obj`,minRows:4,maxHeight:`40vh`,value:a,onChange:e=>o(e.target.value)})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`label`,{htmlFor:`${y}-crit`,className:`text-sm font-medium`,children:`Acceptance criteria (one per line)`}),(0,Z.jsx)(rt,{id:`${y}-crit`,minRows:2,maxHeight:`30vh`,value:s,onChange:e=>c(e.target.value)})]}),(0,Z.jsx)(Qi,{id:`${y}-prio`,value:l,onChange:u}),(0,Z.jsx)($i,{candidates:b,value:d,onChange:p}),_&&(0,Z.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:_}),(0,Z.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Z.jsx)(S,{type:`submit`,variant:`primary`,busy:h,children:`Save`}),(0,Z.jsx)(S,{onClick:t,disabled:h,children:`Cancel`})]})]})}function Qi({id:e,value:t,onChange:n}){return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`label`,{htmlFor:e,className:`text-sm font-medium`,children:`Priority`}),(0,Z.jsx)(`select`,{id:e,value:t,onChange:e=>n(Number(e.target.value)),className:`tap h-9 rounded-md border border-border bg-surface px-2 text-base md:text-sm`,children:st.map((e,t)=>(0,Z.jsx)(`option`,{value:t,children:e},e))})]})}function $i({candidates:e,value:t,onChange:n}){let[r,i]=(0,U.useState)(``),a=(0,U.useId)(),o=e.filter(e=>t.includes(e.id)||e.title.toLowerCase().includes(r.toLowerCase())).slice(0,50);return(0,Z.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,Z.jsx)(`legend`,{className:`text-sm font-medium`,children:`Dependencies`}),e.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-muted`,children:`No other tasks in this project.`}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`label`,{htmlFor:a,className:`sr-only`,children:`Filter tasks`}),(0,Z.jsx)(nt,{id:a,placeholder:`Filter tasks`,value:r,onChange:e=>i(e.target.value)}),(0,Z.jsx)(`ul`,{className:`max-h-48 overflow-y-auto rounded-md border border-border`,children:o.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`label`,{className:`tap flex min-w-0 items-center gap-2 px-3 py-1.5 text-sm hover:bg-surface-2`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:t.includes(e.id),onChange:r=>n(r.target.checked?[...t,e.id]:t.filter(t=>t!==e.id))}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-muted`,children:B[e.state]})]})},e.id))}),t.length>0&&(0,Z.jsxs)(`p`,{className:`text-xs text-muted`,children:[t.length,` selected. The task waits until they are Done.`]})]})]})}var ea=`sy:new-task-draft`;function ta(e){return{title:``,objective:``,projectId:e,advanced:!1,priority:2,dependencies:[],hostId:``,profileId:``,branch:``,criteria:``,continuation:!1,contObjective:``,maxContinuations:`3`,maxMinutes:`60`,maxTokens:``,maxCost:``,checks:``,checksMode:`default`,humanReview:!0}}function na(e){try{let t=sessionStorage.getItem(ea);if(t)return{...ta(e),...JSON.parse(t)}}catch{}return ta(e)}var ra=e=>e.split(`
9
- `).map(e=>e.trim()).filter(Boolean);function ia(e){let t={},n={};if(e.hostId&&(n.hostId=e.hostId),e.profileId&&(n.profileId=e.profileId),e.branch.trim()&&(n.workspace={mode:`new_worktree`,branch:e.branch.trim(),base:null}),e.continuation){let r=Number(e.maxContinuations),i=Number(e.maxMinutes),a=e.maxTokens.trim()?Number(e.maxTokens):null,o=e.maxCost.trim()?Number(e.maxCost):null;e.contObjective.trim()||(t.contObjective=`Continuation needs an objective.`),(!Number.isInteger(r)||r<1||r>50)&&(t.maxContinuations=`Use 1 to 50.`),(!Number.isInteger(i)||i<1||i>1440)&&(t.maxMinutes=`Use 1 to 1440 minutes.`),a!==null&&(!Number.isInteger(a)||a<=0)&&(t.maxTokens=`Use a positive whole number.`),o!==null&&(!Number.isFinite(o)||o<=0)&&(t.maxCost=`Use a positive amount.`),n.continuation={enabled:!0,objective:e.contObjective.trim(),maxContinuations:r,maxElapsedMinutes:i,maxTokens:a,maxCostUsd:o}}return e.checksMode!==`custom`&&e.humanReview||(n.completion={checks:e.checksMode===`custom`?ra(e.checks):null,requireHumanReview:e.humanReview}),{policy:n,errors:t}}function aa({defaultProjectId:e,onCreated:t,onCancel:n}){let r=c(),i=l(),a=f(e=>e.profiles),o=f(e=>e.tasks),s=f(e=>e.runs),u=f(e=>e.hosts),d=f(e=>e.dispatchPaused),[p,h]=(0,U.useState)(()=>na(e??r[0]?.id??``)),[_,v]=(0,U.useState)(null),[y,b]=(0,U.useState)({}),[x,C]=(0,U.useState)(null),w=(0,U.useId)(),T=(e,t)=>h(n=>({...n,[e]:t}));(0,U.useEffect)(()=>{!p.projectId&&r[0]&&h(e=>({...e,projectId:r[0].id}))},[p.projectId,r]),(0,U.useEffect)(()=>{sessionStorage.setItem(ea,JSON.stringify(p))},[p]);let E=r.find(e=>e.id===p.projectId),D=E?.defaultHostId?u[E.defaultHostId]:void 0,O=E?.defaultProfileId?a[E.defaultProfileId]:void 0,k=Object.values(o).filter(e=>e.projectId===p.projectId&&e.state!==`canceled`&&!e.hiddenFromBoard).sort((e,t)=>e.title.localeCompare(t.title)),A=(0,U.useMemo)(()=>{let e={};for(let t of Object.values(s)){if(!ue(t))continue;let n=o[t.taskId]?.projectId;n&&(e[n]=(e[n]??0)+1)}return L({project:E,hostId:p.hostId||null,dependencies:p.dependencies},{hosts:u,tasks:o,dispatchPaused:d,runningByProject:e})},[E,p.hostId,p.dependencies,u,o,s,d]),j=async e=>{let n={};p.title.trim()||(n.title=`Give the task a title.`),E||(n.projectId=`Choose a project.`);let{policy:r,errors:i}=ia(p);if(Object.assign(n,i),b(n),Object.keys(n).length>0)Object.keys(i).length>0&&T(`advanced`,!0);else{v(e),C(null);try{let n=await le({projectId:p.projectId,title:p.title.trim(),objective:p.objective,acceptanceCriteria:ra(p.criteria),dependencies:p.dependencies,priority:p.priority,state:e,...Object.keys(r).length>0?{policy:r}:{}});if(sessionStorage.removeItem(ea),e===`ready`){let e=me(A);try{e=me(await re(n.id))}catch{}V.success(`Created "${n.title}" in Ready. ${e}.`)}else V.success(`Created "${n.title}" in Backlog.`);t(n)}catch(e){C(m(e))}finally{v(null)}}},M=e=>y[e]?(0,Z.jsx)(`p`,{id:`${w}-${e}-err`,className:`text-xs text-danger`,children:y[e]}):null,P=`tap h-9 w-full rounded-md border border-border bg-surface px-2 text-base md:text-sm`;return(0,Z.jsxs)(`form`,{"data-testid":`new-task-form`,className:`flex min-w-0 flex-col gap-4`,onSubmit:e=>{e.preventDefault(),j(`backlog`)},children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`label`,{htmlFor:`${w}-title`,className:`text-sm font-medium`,children:`Title`}),(0,Z.jsx)(nt,{id:`${w}-title`,value:p.title,autoFocus:!0,"aria-invalid":!!y.title,"aria-describedby":y.title?`${w}-title-err`:void 0,onChange:e=>T(`title`,e.target.value),placeholder:`What should be done?`}),M(`title`)]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`label`,{htmlFor:`${w}-objective`,className:`text-sm font-medium`,children:`Objective`}),(0,Z.jsx)(rt,{id:`${w}-objective`,minRows:3,maxHeight:`35vh`,value:p.objective,onChange:e=>T(`objective`,e.target.value),placeholder:`Context, constraints and what done looks like`})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`label`,{htmlFor:`${w}-project`,className:`text-sm font-medium`,children:`Project`}),(0,Z.jsxs)(`select`,{id:`${w}-project`,className:P,value:p.projectId,"aria-invalid":!!y.projectId,onChange:e=>h(t=>({...t,projectId:e.target.value,dependencies:[]})),children:[r.length===0&&(0,Z.jsx)(`option`,{value:``,children:`No projects yet`}),r.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),M(`projectId`)]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`button`,{type:`button`,className:`tap inline-flex items-center gap-1 rounded text-sm font-medium text-accent`,"aria-expanded":p.advanced,"aria-controls":`${w}-adv`,onClick:()=>T(`advanced`,!p.advanced),children:[p.advanced?(0,Z.jsx)(N,{"aria-hidden":!0,className:`size-4`}):(0,Z.jsx)(ee,{"aria-hidden":!0,className:`size-4`}),`Advanced options`]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted`,children:`Unset options inherit the project defaults.`})]}),p.advanced&&(0,Z.jsxs)(`div`,{id:`${w}-adv`,className:`flex flex-col gap-4 rounded-lg border border-border p-3`,children:[(0,Z.jsx)(Qi,{id:`${w}-prio`,value:p.priority,onChange:e=>T(`priority`,e)}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`label`,{htmlFor:`${w}-criteria`,className:`text-sm font-medium`,children:`Acceptance criteria (one per line)`}),(0,Z.jsx)(rt,{id:`${w}-criteria`,minRows:2,maxHeight:`25vh`,value:p.criteria,onChange:e=>T(`criteria`,e.target.value)})]}),(0,Z.jsx)($i,{candidates:k,value:p.dependencies,onChange:e=>T(`dependencies`,e)}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`label`,{htmlFor:`${w}-host`,className:`text-sm font-medium`,children:`Host`}),(0,Z.jsxs)(`select`,{id:`${w}-host`,className:P,value:p.hostId,onChange:e=>T(`hostId`,e.target.value),children:[(0,Z.jsxs)(`option`,{value:``,children:[`Project default`,D?` (${D.name})`:``]}),i.map(e=>(0,Z.jsxs)(`option`,{value:e.id,children:[e.name,e.connectivity===`connected`?``:` (offline)`]},e.id))]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`label`,{htmlFor:`${w}-profile`,className:`text-sm font-medium`,children:`Pi profile`}),(0,Z.jsxs)(`select`,{id:`${w}-profile`,className:P,value:p.profileId,onChange:e=>T(`profileId`,e.target.value),children:[(0,Z.jsxs)(`option`,{value:``,children:[`Project default`,O?` (${O.name})`:``]}),Object.values(a).map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`label`,{htmlFor:`${w}-branch`,className:`text-sm font-medium`,children:`Branch`}),(0,Z.jsx)(nt,{id:`${w}-branch`,value:p.branch,placeholder:`Generated from the title`,onChange:e=>T(`branch`,e.target.value)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted`,children:`Work happens in a new worktree on this branch.`})]}),(0,Z.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`legend`,{className:`text-sm font-medium`,children:`Continuation limits`}),(0,Z.jsxs)(`label`,{className:`tap flex items-center gap-2 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:p.continuation,onChange:e=>T(`continuation`,e.target.checked)}),`Continue automatically until done (off by default)`]}),p.continuation&&(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1 sm:col-span-2`,children:[(0,Z.jsx)(`label`,{htmlFor:`${w}-cobj`,className:`text-sm`,children:`Continuation objective`}),(0,Z.jsx)(nt,{id:`${w}-cobj`,value:p.contObjective,"aria-invalid":!!y.contObjective,onChange:e=>T(`contObjective`,e.target.value)}),M(`contObjective`)]}),(0,Z.jsx)(oa,{id:`${w}-cmax`,label:`Max continuations`,value:p.maxContinuations,onChange:e=>T(`maxContinuations`,e),error:M(`maxContinuations`)}),(0,Z.jsx)(oa,{id:`${w}-cmin`,label:`Max minutes`,value:p.maxMinutes,onChange:e=>T(`maxMinutes`,e),error:M(`maxMinutes`)}),(0,Z.jsx)(oa,{id:`${w}-ctok`,label:`Max tokens (optional)`,value:p.maxTokens,onChange:e=>T(`maxTokens`,e),error:M(`maxTokens`)}),(0,Z.jsx)(oa,{id:`${w}-ccost`,label:`Max cost USD (optional)`,value:p.maxCost,onChange:e=>T(`maxCost`,e),error:M(`maxCost`)}),(0,Z.jsx)(`p`,{className:`text-xs text-muted sm:col-span-2`,children:`Token and cost limits apply only when the Pi provider reports usage.`})]})]}),(0,Z.jsxs)(`fieldset`,{className:`flex flex-col gap-2`,children:[(0,Z.jsx)(`legend`,{className:`text-sm font-medium`,children:`Checks and review`}),(0,Z.jsxs)(`label`,{className:`tap flex items-center gap-2 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:p.checksMode===`custom`,onChange:e=>T(`checksMode`,e.target.checked?`custom`:`default`)}),`Use custom checks instead of the project's`,E?.checks.length?` (${E.checks.join(`, `)})`:` (none)`]}),p.checksMode===`custom`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`label`,{htmlFor:`${w}-checks`,className:`text-sm`,children:`Check commands (one per line; empty means no checks)`}),(0,Z.jsx)(rt,{id:`${w}-checks`,minRows:2,className:`font-mono`,value:p.checks,onChange:e=>T(`checks`,e.target.value)})]}),(0,Z.jsxs)(`label`,{className:`tap flex items-center gap-2 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:p.humanReview,onChange:e=>T(`humanReview`,e.target.checked)}),`Require human review before Done`]})]})]}),x&&(0,Z.jsxs)(`p`,{role:`alert`,className:`rounded-md bg-danger-soft px-3 py-2 text-sm`,children:[`Could not create the task: `,x]}),(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-border pt-3`,children:[(0,Z.jsx)(Ki,{e:A,prefix:`Make ready: `}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(S,{type:`submit`,icon:(0,Z.jsx)(g,{className:`size-4`}),busy:_===`backlog`,disabled:_!==null,children:`Save to Backlog`}),(0,Z.jsx)(S,{variant:`primary`,icon:(0,Z.jsx)(Fe,{className:`size-4`}),busy:_===`ready`,disabled:_!==null,onClick:()=>void j(`ready`),children:`Make ready`}),(0,Z.jsx)(S,{variant:`ghost`,onClick:n,disabled:_!==null,children:`Cancel`})]}),(0,Z.jsx)(`p`,{className:`text-xs text-muted`,children:`Make ready authorizes dispatch. Nothing starts until the coordinator confirms.`})]})]})}function oa({id:e,label:t,value:n,onChange:r,error:i}){return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Z.jsx)(`label`,{htmlFor:e,className:`text-sm`,children:t}),(0,Z.jsx)(nt,{id:e,inputMode:`decimal`,value:n,onChange:e=>r(e.target.value)}),i]})}var sa={neutral:`text-muted`,info:`text-info`,success:`text-success`,warning:`text-warning`,danger:`text-danger`,accent:`text-accent`};function ca({task:e,showProject:t,wait:i,onOpen:a,drag:o,full:s,selected:c}){let l=zi(e),u=f(e=>e.tasks),d=Fi(),p=n(),m=d.isBusy(e.id),h=Ri[e.priority],g=h.icon,_=Bi(e,l.run,i),v=he(e,u),y=l.attention[0],x=[{id:`open`,label:`Open details`,icon:(0,Z.jsx)(M,{className:`size-4`}),onSelect:()=>a(e)}];if(e.sessionId){let t=e.sessionId;x.push({id:`session`,label:`Open session`,icon:(0,Z.jsx)(te,{className:`size-4`}),onSelect:()=>p(H.session(t))})}x.push(`separator`);for(let t of Oe(e))x.push({id:`move-${t}`,label:da(e.state,t),icon:(0,Z.jsx)(ua,{state:t}),onSelect:()=>void d.move(e,t)});return(0,Z.jsxs)(`article`,{ref:o?.setNodeRef,"data-testid":`task-card`,"data-task-id":e.id,"aria-label":e.title,"aria-busy":m||void 0,style:o?.style,...o?.cardProps,className:b(`group relative flex min-w-0 flex-col gap-1.5 rounded-lg border bg-surface p-3 text-sm shadow-sm`,c?`border-accent`:`border-border`,o?.dragging&&`opacity-60`,s?`w-full`:``),children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1`,children:[o&&(0,Z.jsx)(`button`,{type:`button`,ref:o.setHandleRef,...o.handleProps,"aria-label":`Drag ${e.title}`,title:`Drag to move (Space to pick up, arrows to move, Space to drop)`,className:`tap -ml-1.5 inline-flex h-7 w-5 shrink-0 cursor-grab items-center justify-center rounded text-subtle hover:bg-surface-2 hover:text-text`,children:(0,Z.jsx)(St,{"aria-hidden":!0,className:`size-4`})}),(0,Z.jsx)(`button`,{type:`button`,"data-card-open":e.id,onClick:()=>a(e),className:`tap min-w-0 flex-1 rounded text-left font-medium leading-snug`,children:(0,Z.jsx)(`span`,{className:`line-clamp-2 break-words`,children:e.title})}),m&&(0,Z.jsx)(O,{label:`Updating`,className:`mt-0.5 shrink-0`}),(0,Z.jsx)(P,{label:`Actions for ${e.title}`,items:x,trigger:t=>(0,Z.jsx)(`button`,{type:`button`,...t,"aria-label":`Move to… and other actions for ${e.title}`,title:`Move to…`,className:`tap -mr-1.5 inline-flex size-7 shrink-0 items-center justify-center rounded text-muted hover:bg-surface-2 hover:text-text`,children:(0,Z.jsx)(Re,{"aria-hidden":!0,className:`size-4`})})})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted`,children:[(0,Z.jsxs)(`span`,{className:b(`inline-flex items-center gap-1`,sa[h.tone]),children:[(0,Z.jsx)(g,{"aria-hidden":!0,className:`size-3.5`}),h.label]}),t&&l.projectName&&(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:l.projectName})]}),_&&(0,Z.jsx)(la,{icon:(0,Z.jsx)(_.icon,{"aria-hidden":!0,className:b(`size-3.5`,_.spin&&`animate-spin`)}),className:sa[_.tone],children:_.text}),(l.hostName||l.branch)&&(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted`,children:[l.hostName&&(0,Z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[(0,Z.jsx)(I,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,Z.jsxs)(`span`,{className:`truncate`,children:[l.hostName,l.hostOffline?` (offline)`:``]})]}),l.branch&&(0,Z.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[(0,Z.jsx)(Me,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`truncate`,children:l.branch})]})]}),v&&(0,Z.jsx)(la,{icon:(0,Z.jsx)(Pe,{"aria-hidden":!0,className:`size-3.5`}),className:`text-muted`,children:v}),l.pendingInteraction&&e.sessionId?(0,Z.jsxs)(r,{to:H.interaction(e.sessionId,l.pendingInteraction.id),className:`tap inline-flex min-w-0 items-center gap-1 rounded text-xs font-medium text-warning hover:underline`,children:[(0,Z.jsx)(A,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,Z.jsxs)(`span`,{className:`truncate`,children:[`Needs input: `,l.pendingInteraction.title]})]}):y?(0,Z.jsxs)(la,{icon:(0,Z.jsx)(Ve,{"aria-hidden":!0,className:`size-3.5`}),className:sa[Ye[y.reason].tone],children:[Ye[y.reason].label,l.attention.length>1?` (+${l.attention.length-1})`:``]}):null,(0,Z.jsxs)(`div`,{className:`text-xs text-subtle`,children:[`Updated `,(0,Z.jsx)(`time`,{dateTime:e.lastActivityAt,children:E(e.lastActivityAt)})]})]})}function la({icon:e,children:t,className:n}){return(0,Z.jsxs)(`div`,{className:b(`flex min-w-0 items-start gap-1 text-xs`,n),children:[(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:e}),(0,Z.jsx)(`span`,{className:`min-w-0 break-words line-clamp-2`,children:t})]})}function ua({state:e,className:t}){let n=Ke[e].icon;return(0,Z.jsx)(n,{"aria-hidden":!0,className:b(`size-4`,t)})}function da(e,t){return e===`ready`&&t===`in_progress`?`Run now (In progress)`:e===`review`&&t===`in_progress`?`Start new attempt (In progress)`:e===`backlog`&&t===`ready`?`Make ready`:(e===`done`||e===`canceled`)&&t!==`canceled`?`Reopen to ${B[t]}`:t===`canceled`?`Cancel task`:t===`done`?`Accept (Done)`:`Move to ${B[t]}`}function fa(){let e=$e(e=>e.filters.board),t=$e(e=>e.setFilter),n=$e(e=>e.selectedProjectId),r=$e(e=>e.set),i=(0,U.useMemo)(()=>je(e),[e]),a=f(e=>e.tasks),o=f(e=>e.runs),s=f(e=>e.attention),c=f(e=>e.projects),l=Ee(),u=n&&c[n]?n:null,d=(0,U.useMemo)(()=>{let e=new Set(de(s).keys());return be(a,i,{projectId:u,runs:o,attentionTaskIds:e})},[a,i,u,o,s]),p=(0,U.useMemo)(()=>{let e=new Map;for(let t of l.data?.queued??[])e.set(t.taskId,t.eligibility);return e},[l.data]),m=(0,U.useMemo)(()=>l.data?l.data.queued.filter(e=>!u||a[e.taskId]?.projectId===u).length:Object.values(a).filter(e=>e.state===`ready`&&!e.hiddenFromBoard&&(!u||e.projectId===u)).length,[l.data,a,u]),h=ke(i),g=(0,U.useMemo)(()=>Object.values(a).filter(e=>!e.hiddenFromBoard&&(!u||e.projectId===u)).length,[a,u]),_=h.reduce((e,t)=>e+d[t].length,0);return{filters:i,setFilters:e=>t(`board`,e),projectId:u,setProjectId:e=>r(`selectedProjectId`,e),columns:d,states:h,waits:p,queueCount:m,now:l,showProject:!u&&Object.keys(c).length>1,totalTasks:g,visibleCount:_}}var $={mainScrollTop:0,boardScrollLeft:0,columnScroll:{},focusTaskId:null},pa=`col:`,ma=`card:`,ha=`task:`,ga=(e,{currentCoordinates:t,context:n})=>{if(e.code===`ArrowDown`)return{...t,y:t.y+72};if(e.code===`ArrowUp`)return{...t,y:t.y-72};if(e.code!==`ArrowRight`&&e.code!==`ArrowLeft`)return;e.preventDefault();let r=n.droppableContainers.toArray().filter(e=>String(e.id).startsWith(pa)).map(e=>({id:e.id,rect:n.droppableRects.get(e.id)})).filter(e=>!!e.rect).sort((e,t)=>e.rect.left-t.rect.left);if(r.length===0)return;let i=n.collisionRect?.width??0,a=t.x+i/2,o=r.findIndex(e=>a>=e.rect.left&&a<=e.rect.left+e.rect.width);o<0&&(o=0);let s=r[Math.max(0,Math.min(r.length-1,o+(e.code===`ArrowRight`?1:-1)))];return{x:s.rect.left+(s.rect.width-i)/2,y:t.y}},_a=e=>{let t=On(e);if(t.length>0){let e=t.find(e=>String(e.id).startsWith(ma));return e?[e]:t}return wn(e)};function va(e,t){if(e.startsWith(pa))return{state:e.slice(4),beforeId:null};if(e.startsWith(ma)){let n=t[e.slice(5)];return n?{state:n.state,beforeId:n.id}:null}return null}function ya({taskId:e}){let t=fa(),r=f(e=>e.hydrated),i=f(e=>e.projects),a=f(e=>e.tasks),o=Fi(),c=n(),l=s(),u=$e(e=>e.paneSizes.boardColumn),[d,p]=(0,U.useState)(null),[m,h]=(0,U.useState)(!1),g=gn(hn(gr,{activationConstraint:{distance:6}}),hn(dr,{coordinateGetter:ga,keyboardCodes:{start:[`Space`],cancel:[`Escape`],end:[`Space`,`Enter`]}})),_=(0,U.useCallback)(e=>{e&&(e.scrollLeft=$.boardScrollLeft)},[]);(0,U.useEffect)(()=>{if(e||!$.focusTaskId)return;let t=$.focusTaskId;$.focusTaskId=null,requestAnimationFrame(()=>document.querySelector(`[data-card-open="${CSS.escape(t)}"]`)?.focus({preventScroll:!1}))},[e]);let v=e=>{$.focusTaskId=e.id,c(H.task(e.id),{state:{fromBoard:!0}})},y=()=>{e&&($.focusTaskId=e),l.state?.fromBoard?c(-1):c(H.board)},b=e=>p(String(e.active.id).slice(5)),x=e=>{p(null);let n=String(e.active.id).slice(5),r=a[n];if(!r||!e.over)return;let i=va(String(e.over.id),a);if(!i||i.beforeId===n)return;let s=t.columns[i.state],c=ce(s,i.beforeId,n);i.state===r.state?t.filters.sort===`priority`&&o.reorder(r,c):o.move(r,i.state,{position:c})},C={onDragStart:({active:e})=>`Picked up ${xa(e.id,a)}.`,onDragOver:({active:e,over:t})=>t?`${xa(e.id,a)} is over ${Sa(String(t.id),a)}.`:void 0,onDragEnd:({active:e,over:t})=>t?`Dropped ${xa(e.id,a)} on ${Sa(String(t.id),a)}.`:`Dropped ${xa(e.id,a)}. It did not move.`,onDragCancel:({active:e})=>`Moving ${xa(e.id,a)} was canceled.`},w=d?a[d]:void 0,E=e?a[e]:void 0,O=r&&Object.keys(i).length===0;return(0,Z.jsxs)(`div`,{"data-testid":`board`,className:`absolute inset-0 flex min-w-0 flex-col`,children:[(0,Z.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-2 border-b border-border px-4 py-2.5`,children:[(0,Z.jsx)(`h1`,{className:`mr-2 text-lg font-semibold`,children:`Board`}),(0,Z.jsx)(fe,{board:t}),(0,Z.jsx)(ye,{board:t,className:`w-56 max-w-full`}),(0,Z.jsx)(Se,{board:t}),(0,Z.jsx)(`div`,{className:`ml-auto`,children:(0,Z.jsx)(S,{variant:`primary`,icon:(0,Z.jsx)(Ie,{className:`size-4`}),onClick:()=>h(!0),disabled:O,title:O?`Add a project first`:void 0,children:`New task`})})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-5 gap-y-2 border-b border-border px-4 py-2`,children:[(0,Z.jsx)(z,{}),(0,Z.jsxs)(`span`,{className:`text-sm text-muted`,role:`status`,children:[t.queueCount,` queued`]}),(0,Z.jsx)(De,{board:t}),(0,Z.jsx)(ge,{board:t}),(0,Z.jsx)(Te,{board:t})]}),(0,Z.jsx)(we,{board:t}),r?O?(0,Z.jsx)(D,{icon:(0,Z.jsx)(tt,{className:`size-8`}),title:`No projects yet`,description:`Tasks belong to a project. Add a project from a host checkout to start planning work.`,action:{label:`Add a project`,to:H.settings(`projects`)}}):t.totalTasks===0?(0,Z.jsx)(D,{icon:(0,Z.jsx)(tt,{className:`size-8`}),title:`No tasks yet`,description:`Create a task in Backlog, or make it ready so the dispatcher starts it.`,action:{label:`New task`,onClick:()=>h(!0)}}):(0,Z.jsxs)(pi,{sensors:g,collisionDetection:_a,onDragStart:b,onDragEnd:x,onDragCancel:()=>p(null),accessibility:{announcements:C,screenReaderInstructions:{draggable:`To move a task, press Space to pick it up, use the arrow keys to move between columns, then press Space to drop or Escape to cancel. The task menu offers Move to… without dragging.`}},children:[t.visibleCount===0&&(0,Z.jsxs)(`p`,{role:`status`,className:`px-4 pt-3 text-sm text-muted`,children:[`No tasks match the filters.`,` `,(0,Z.jsx)(`button`,{type:`button`,className:`tap font-medium text-accent`,onClick:()=>t.setFilters({...pe,sort:t.filters.sort}),children:`Clear filters`})]}),(0,Z.jsx)(`section`,{ref:_,"aria-label":`Board columns`,onScroll:e=>{$.boardScrollLeft=e.currentTarget.scrollLeft},className:`min-h-0 flex-1 overflow-x-auto overflow-y-hidden overscroll-x-contain`,children:(0,Z.jsx)(`div`,{className:`flex h-full w-max gap-3 p-4`,children:t.states.map(n=>(0,Z.jsx)(Ca,{state:n,board:t,width:u,onOpen:v,selectedId:e,onNew:()=>h(!0)},n))})}),(0,Z.jsx)(Ni,{dropAnimation:null,children:w&&(0,Z.jsx)(`div`,{className:`rotate-1 shadow-pop`,style:{width:`clamp(272px, ${u-16}px, 344px)`},children:(0,Z.jsx)(ca,{task:w,showProject:t.showProject,wait:t.waits.get(w.id),onOpen:()=>void 0})})})]}):(0,Z.jsx)(T,{label:`Loading tasks…`}),(0,Z.jsx)(ut,{open:!!e,onClose:y,width:520,title:E?.title??(r?`Task not found`:`Loading task…`),description:E?B[E.state]:void 0,footer:E?(0,Z.jsx)(ba,{task:E}):void 0,children:(0,Z.jsx)(`div`,{"data-testid":`task-drawer`,className:`min-w-0`,children:E?(0,Z.jsx)(qi,{task:E,onDeleted:()=>c(H.board,{replace:!0})}):r?(0,Z.jsx)(D,{title:`Task not found`,description:`It may have been deleted, or this link is from another coordinator.`,action:{label:`Back to board`,to:H.board}}):(0,Z.jsx)(T,{label:`Loading task…`})})}),(0,Z.jsx)(ft,{open:m,onClose:()=>h(!1),title:`New task`,className:`max-w-xl`,children:(0,Z.jsx)(aa,{defaultProjectId:t.projectId,onCancel:()=>h(!1),onCreated:e=>{h(!1),$.focusTaskId=e.id,requestAnimationFrame(()=>document.querySelector(`[data-card-open="${CSS.escape(e.id)}"]`)?.focus())}})})]})}function ba({task:e}){let{eligibility:t}=Ui(e);return(0,Z.jsx)(`div`,{className:`w-full min-w-0`,children:(0,Z.jsx)(Gi,{task:e,eligibility:t})})}function xa(e,t){let n=t[String(e).replace(ha,``)];return n?`task ${n.title}`:`task`}function Sa(e,t){if(e.startsWith(pa))return`the ${B[e.slice(4)]} column`;let n=t[e.slice(5)];return n?`${n.title} in ${B[n.state]}`:`a task`}function Ca({state:e,board:t,width:n,onOpen:r,selectedId:i,onNew:a}){let{setNodeRef:o,isOver:s}=xi({id:`${pa}${e}`}),[c,l]=(0,U.useState)(!1),u=t.columns[e],d=Ke[e].icon,f=e===`done`&&!t.filters.showCompleted&&!c,p=`col-${e}-title`,m=(0,U.useCallback)(t=>{t&&(t.scrollTop=$.columnScroll[e]??0)},[e]);return(0,Z.jsx)(`section`,{ref:o,"data-testid":`column-${e}`,"aria-labelledby":p,style:{width:`clamp(288px, ${n}px, 360px)`},className:`flex h-full shrink-0 flex-col rounded-lg border bg-surface-2 ${s?`border-accent`:`border-border`}`,children:(0,Z.jsxs)(`div`,{ref:m,"data-column-scroll":e,onScroll:t=>{$.columnScroll[e]=t.currentTarget.scrollTop},className:`min-h-0 flex-1 overflow-y-auto overscroll-y-contain`,children:[(0,Z.jsxs)(`h2`,{id:p,className:`sticky top-0 z-10 flex items-center gap-2 rounded-t-lg border-b border-border bg-surface-2 px-3 py-2 text-sm font-semibold`,children:[(0,Z.jsx)(d,{"aria-hidden":!0,className:`size-4 text-muted`}),(0,Z.jsx)(`span`,{className:`flex-1`,children:B[e]}),(0,Z.jsxs)(`span`,{className:`rounded-full bg-surface px-2 text-xs font-medium text-muted tabular-nums`,children:[u.length,(0,Z.jsx)(`span`,{className:`sr-only`,children:` tasks`})]})]}),(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2 p-2`,children:f?(0,Z.jsxs)(`li`,{className:`flex flex-col items-start gap-1 px-1 py-2 text-sm text-muted`,children:[u.length,` completed `,u.length===1?`task is`:`tasks are`,` hidden.`,u.length>0&&(0,Z.jsx)(`button`,{type:`button`,className:`tap font-medium text-accent`,onClick:()=>l(!0),children:`Show completed`})]}):u.length===0?(0,Z.jsx)(`li`,{className:`px-1 py-2 text-sm text-muted`,children:e===`backlog`?(0,Z.jsxs)(`button`,{type:`button`,className:`tap inline-flex items-center gap-1 font-medium text-accent`,onClick:a,children:[(0,Z.jsx)(Ie,{"aria-hidden":!0,className:`size-4`}),` New task`]}):`No tasks`}):u.map(e=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(wa,{task:e,board:t,onOpen:r,selected:e.id===i})},e.id))})]})})}function wa({task:e,board:t,onOpen:n,selected:r}){let i=_i({id:`${ha}${e.id}`}),a=xi({id:`${ma}${e.id}`,disabled:i.isDragging}),{onPointerDown:o,onKeyDown:s}=i.listeners??{},c={setNodeRef:e=>{i.setNodeRef(e),a.setNodeRef(e)},setHandleRef:i.setActivatorNodeRef,cardProps:{onPointerDown:o},handleProps:{...i.attributes,onKeyDown:s},dragging:i.isDragging,style:a.isOver?{boxShadow:`0 -3px 0 0 var(--sy-accent)`}:void 0};return(0,Z.jsx)(ca,{task:e,showProject:t.showProject,wait:t.waits.get(e.id),onOpen:n,drag:c,selected:r})}var Ta=()=>document.getElementById(`main`);function Ea(){let e=fa(),t=f(e=>e.hydrated),r=f(e=>e.projects),i=n(),[a,o]=Ze(`board-mobile`,{tab:`ready`,layout:`column`}),[s,c]=(0,U.useState)(!1),l=e.states.includes(a.tab)?a.tab:`ready`;(0,U.useLayoutEffect)(()=>{if(!t)return;let e=Ta(),n=$.mainScrollTop;e&&(e.scrollTop=n);let r=requestAnimationFrame(()=>{r=requestAnimationFrame(()=>{e&&e.scrollTop<n&&(e.scrollTop=n)})}),i=$.focusTaskId;return $.focusTaskId=null,i&&requestAnimationFrame(()=>document.querySelector(`[data-card-open="${CSS.escape(i)}"]`)?.focus({preventScroll:!0})),()=>cancelAnimationFrame(r)},[t]);let u=e=>{$.mainScrollTop=Ta()?.scrollTop??0,$.focusTaskId=e.id,i(H.task(e.id),{state:{fromBoard:!0}})},d=t&&Object.keys(r).length===0,p=(t,n)=>t.length===0?(0,Z.jsxs)(`p`,{className:`px-1 py-3 text-sm text-muted`,children:[`No `,B[n],` tasks.`]}):(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2`,children:t.map(t=>(0,Z.jsx)(`li`,{children:(0,Z.jsx)(ca,{task:t,full:!0,showProject:e.showProject,wait:e.waits.get(t.id),onOpen:u})},t.id))});return(0,Z.jsxs)(`div`,{"data-testid":`board`,className:`flex min-w-0 flex-col`,children:[(0,Z.jsxs)(`header`,{className:`flex min-w-0 flex-col gap-2 border-b border-border bg-bg px-3 pt-3 pb-0 safe-pt`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`h1`,{className:`flex-1 text-lg font-semibold`,children:`Board`}),(0,Z.jsx)(S,{variant:`primary`,icon:(0,Z.jsx)(Ie,{className:`size-4`}),onClick:()=>c(!0),disabled:d,children:`New task`})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(fe,{board:e,className:`min-w-0 flex-1`}),(0,Z.jsx)(Se,{board:e,mobile:!0})]}),(0,Z.jsx)(ye,{board:e}),(0,Z.jsx)(Te,{board:e}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsx)(z,{compact:!0}),(0,Z.jsxs)(`span`,{className:`text-sm text-muted`,children:[e.queueCount,` queued`]})]}),(0,Z.jsx)(ct,{label:`Board layout`,block:!0,value:a.layout,onChange:e=>o({...a,layout:e}),options:[{value:`column`,label:`Columns`,icon:(0,Z.jsx)(bt,{"aria-hidden":!0,className:`size-4`})},{value:`list`,label:`List`,icon:(0,Z.jsx)(wt,{"aria-hidden":!0,className:`size-4`})}]}),a.layout===`column`&&(0,Z.jsx)(`div`,{"data-testid":`status-tabs`,className:`-mx-3 px-1`,children:(0,Z.jsx)(it,{label:`Task status`,idPrefix:`board-tab`,scrollable:!0,className:`border-b-0`,value:l,onChange:e=>o({...a,tab:e}),tabs:e.states.map(t=>{let n=Ke[t].icon;return{id:t,label:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(n,{"aria-hidden":!0,className:`size-4`}),B[t]]}),badge:(0,Z.jsx)(Qe,{label:`${e.columns[t].length} tasks`,children:e.columns[t].length})}})})})]}),(0,Z.jsx)(we,{board:e}),(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-col gap-3 px-3 py-3`,children:t?d?(0,Z.jsx)(D,{icon:(0,Z.jsx)(tt,{className:`size-8`}),title:`No projects yet`,description:`Tasks belong to a project. Add a project from a host checkout first.`,action:{label:`Add a project`,to:H.settings(`projects`)}}):e.totalTasks===0?(0,Z.jsx)(D,{icon:(0,Z.jsx)(tt,{className:`size-8`}),title:`No tasks yet`,description:`Create a task in Backlog, or make it ready so the dispatcher starts it.`,action:{label:`New task`,onClick:()=>c(!0)}}):e.visibleCount===0?(0,Z.jsx)(D,{title:`No tasks match the filters`,action:{label:`Clear filters`,onClick:()=>e.setFilters({...pe,sort:e.filters.sort})}}):a.layout===`column`?(0,Z.jsx)(at,{idPrefix:`board-tab`,id:l,children:l===`done`&&!e.filters.showCompleted?(0,Z.jsxs)(`p`,{className:`text-sm text-muted`,children:[`Completed tasks are hidden.`,` `,(0,Z.jsx)(`button`,{type:`button`,className:`tap font-medium text-accent`,onClick:()=>e.setFilters({...e.filters,showCompleted:!0}),children:`Show completed`})]}):p(e.columns[l],l)}):e.states.filter(t=>t!==`done`||e.filters.showCompleted).map(t=>(0,Z.jsxs)(`section`,{"aria-labelledby":`grp-${t}`,"data-testid":`column-${t}`,className:`flex flex-col gap-2`,children:[(0,Z.jsxs)(`h2`,{id:`grp-${t}`,className:`flex items-center gap-2 pt-1 text-sm font-semibold`,children:[(0,Z.jsx)(ua,{state:t,className:`text-muted`}),B[t],(0,Z.jsxs)(`span`,{className:`text-muted`,children:[`(`,e.columns[t].length,`)`]})]}),p(e.columns[t],t)]},t)):(0,Z.jsx)(T,{label:`Loading tasks…`})}),(0,Z.jsx)(dt,{open:s,onClose:()=>c(!1),title:`New task`,children:(0,Z.jsx)(aa,{defaultProjectId:e.projectId,onCancel:()=>c(!1),onCreated:e=>{c(!1),o({...a,tab:e.state})}})})]})}function Da({taskId:e}){qe();let t=u(e),r=f(e=>e.hydrated),i=n(),a=s(),[o,c]=(0,U.useState)(!1),{eligibility:l}=Ui(t);return(0,U.useLayoutEffect)(()=>{let e=Ta();e&&(e.scrollTop=0)},[]),(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col`,"data-testid":`task-page`,children:[(0,Z.jsxs)(`header`,{className:`sticky top-0 z-20 flex min-w-0 items-center gap-1 border-b border-border bg-surface px-1 py-1 safe-pt`,children:[(0,Z.jsx)(lt,{label:`Back to board`,icon:(0,Z.jsx)(F,{className:`size-5`}),onClick:()=>{a.state?.fromBoard?i(-1):i(H.board)}}),(0,Z.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-base font-semibold`,children:t?.title??`Task`}),t&&(0,Z.jsx)(S,{size:`sm`,icon:(0,Z.jsx)(mt,{className:`size-4`}),onClick:()=>c(!0),children:`Move task`})]}),t?(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col px-4 pt-3 pb-8`,children:[(0,Z.jsx)(`div`,{children:(0,Z.jsx)(Gi,{task:t,eligibility:l,block:!0})}),(0,Z.jsx)(qi,{task:t,onDeleted:()=>i(H.board,{replace:!0})}),(0,Z.jsx)(Oa,{task:t,open:o,onClose:()=>c(!1)})]}):r?(0,Z.jsx)(D,{title:`Task not found`,description:`It may have been deleted.`,action:{label:`Back to board`,to:H.board}}):(0,Z.jsx)(T,{label:`Loading task…`})]})}function Oa({task:e,open:t,onClose:n}){let r=Fi(),i=f(e=>e.runs),a=e.currentRunId?i[e.currentRunId]:void 0,o=[`backlog`,`ready`,`in_progress`,`review`,`done`,`canceled`],s=new Set(Oe(e));return(0,Z.jsx)(dt,{open:t,onClose:n,title:`Move task`,description:`Currently ${B[e.state]}`,children:(0,Z.jsx)(`ul`,{"data-testid":`move-sheet`,className:`flex flex-col`,children:o.filter(t=>t!==e.state).map(t=>{let i=Ae(e,t,a),o=i.kind===`invalid`?i.reason:i.kind===`choose_running`?`Asks whether to pause automation or stop execution.`:i.kind===`confirm_done`?`Asks you to confirm acceptance.`:i.kind===`run_now`?`Starts now if the task is eligible.`:null;return(0,Z.jsx)(`li`,{children:(0,Z.jsxs)(`button`,{type:`button`,disabled:!s.has(t),onClick:()=>{n(),r.move(e,t)},className:`tap flex w-full items-start gap-3 rounded-md px-2 py-3 text-left hover:bg-surface-2 disabled:opacity-60`,children:[(0,Z.jsx)(ua,{state:t,className:`mt-0.5 text-muted`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block font-medium`,children:da(e.state,t)}),o&&(0,Z.jsx)(`span`,{className:`block text-sm text-muted`,children:o})]})]})},t)})})})}function ka(){let e=Xe(),n=t(`/tasks/:taskId`)?.params.taskId;return(0,Z.jsx)(Li,{children:e===`mobile`?n?(0,Z.jsx)(Da,{taskId:n},n):(0,Z.jsx)(Ea,{}):(0,Z.jsx)(ya,{taskId:n})})}export{ka as default};
10
- //# sourceMappingURL=board-BFvNcFhk.js.map