@spencerboucher/switchyard 0.25.0 → 0.26.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 (132) hide show
  1. package/README.md +1 -1
  2. package/dist/bridge/switchyard-terminal.js +16 -0
  3. package/dist/catalog/worker.js +27 -3
  4. package/dist/policies/worker.js +27 -3
  5. package/dist/switchyard.mjs +123 -10
  6. package/package.json +1 -1
  7. package/web-dist/assets/{AutomationView-I80YGJ3M.js → AutomationView-BdmWs08y.js} +2 -2
  8. package/web-dist/assets/{AutomationView-I80YGJ3M.js.map → AutomationView-BdmWs08y.js.map} +1 -1
  9. package/web-dist/assets/{Checkbox-BdFQsqCG.js → Checkbox-9KyxtvcL.js} +2 -2
  10. package/web-dist/assets/{Checkbox-BdFQsqCG.js.map → Checkbox-9KyxtvcL.js.map} +1 -1
  11. package/web-dist/assets/{DangerZone-C6qU1pp7.js → DangerZone-CT2xbMEx.js} +2 -2
  12. package/web-dist/assets/{DangerZone-C6qU1pp7.js.map → DangerZone-CT2xbMEx.js.map} +1 -1
  13. package/web-dist/assets/{Field-DGV7eljt.js → Field-D4UpWJFx.js} +2 -2
  14. package/web-dist/assets/{Field-DGV7eljt.js.map → Field-D4UpWJFx.js.map} +1 -1
  15. package/web-dist/assets/{NavigationEditor-COtm2NQY.js → NavigationEditor-CcxVgkiR.js} +2 -2
  16. package/web-dist/assets/{NavigationEditor-COtm2NQY.js.map → NavigationEditor-CcxVgkiR.js.map} +1 -1
  17. package/web-dist/assets/{Overlay-hRkfpjK4.js → Overlay-Cfm4AZk1.js} +2 -2
  18. package/web-dist/assets/{Overlay-hRkfpjK4.js.map → Overlay-Cfm4AZk1.js.map} +1 -1
  19. package/web-dist/assets/{Priority-DL3f-tRD.js → Priority-DBLBg1FP.js} +2 -2
  20. package/web-dist/assets/{Priority-DL3f-tRD.js.map → Priority-DBLBg1FP.js.map} +1 -1
  21. package/web-dist/assets/{RadioCards-9YvqB3va.js → RadioCards-DoHz_a-g.js} +2 -2
  22. package/web-dist/assets/{RadioCards-9YvqB3va.js.map → RadioCards-DoHz_a-g.js.map} +1 -1
  23. package/web-dist/assets/{ScopeRepository-BPiPUjHi.js → ScopeRepository-Cg1lXFrM.js} +2 -2
  24. package/web-dist/assets/{ScopeRepository-BPiPUjHi.js.map → ScopeRepository-Cg1lXFrM.js.map} +1 -1
  25. package/web-dist/assets/{ScopeSelect-DmWCXeIf.js → ScopeSelect-DkEghnwv.js} +2 -2
  26. package/web-dist/assets/{ScopeSelect-DmWCXeIf.js.map → ScopeSelect-DkEghnwv.js.map} +1 -1
  27. package/web-dist/assets/{SegmentedControl-CefWecy1.js → SegmentedControl-D6SGXg_K.js} +2 -2
  28. package/web-dist/assets/{SegmentedControl-CefWecy1.js.map → SegmentedControl-D6SGXg_K.js.map} +1 -1
  29. package/web-dist/assets/{Select-CdANXO3X.js → Select-D41sYIWt.js} +2 -2
  30. package/web-dist/assets/{Select-CdANXO3X.js.map → Select-D41sYIWt.js.map} +1 -1
  31. package/web-dist/assets/{StructuredValue-BjKzgQDM.js → StructuredValue-aIPp-NIc.js} +3 -3
  32. package/web-dist/assets/{StructuredValue-BjKzgQDM.js.map → StructuredValue-aIPp-NIc.js.map} +1 -1
  33. package/web-dist/assets/{Switch-DrrWalaQ.js → Switch-D6hfPoPE.js} +2 -2
  34. package/web-dist/assets/{Switch-DrrWalaQ.js.map → Switch-D6hfPoPE.js.map} +1 -1
  35. package/web-dist/assets/{Tabs-Cvyw8P4s.js → Tabs-CRXYaXG7.js} +2 -2
  36. package/web-dist/assets/{Tabs-Cvyw8P4s.js.map → Tabs-CRXYaXG7.js.map} +1 -1
  37. package/web-dist/assets/{TextLink-DMi_ZI43.js → TextLink-DWXZwPZa.js} +2 -2
  38. package/web-dist/assets/{TextLink-DMi_ZI43.js.map → TextLink-DWXZwPZa.js.map} +1 -1
  39. package/web-dist/assets/{UINodeRenderer-CDPAUIOO.js → UINodeRenderer-BVjIBets.js} +3 -3
  40. package/web-dist/assets/UINodeRenderer-BVjIBets.js.map +1 -0
  41. package/web-dist/assets/{UnfilteredNote-CgsOTad1.js → UnfilteredNote-B7TY047m.js} +2 -2
  42. package/web-dist/assets/{UnfilteredNote-CgsOTad1.js.map → UnfilteredNote-B7TY047m.js.map} +1 -1
  43. package/web-dist/assets/{api-Dlk6L3Cu.js → api-C_h6nq6d.js} +2 -2
  44. package/web-dist/assets/{api-Dlk6L3Cu.js.map → api-C_h6nq6d.js.map} +1 -1
  45. package/web-dist/assets/{arrow-down-Cc6k_L7W.js → arrow-down-1LTpTi1H.js} +2 -2
  46. package/web-dist/assets/{arrow-down-Cc6k_L7W.js.map → arrow-down-1LTpTi1H.js.map} +1 -1
  47. package/web-dist/assets/{arrow-up-CW1a5Bhp.js → arrow-up-B4uK6ZGO.js} +2 -2
  48. package/web-dist/assets/{arrow-up-CW1a5Bhp.js.map → arrow-up-B4uK6ZGO.js.map} +1 -1
  49. package/web-dist/assets/{attention-AZ2a-mzO.js → attention--3lxyvUR.js} +2 -2
  50. package/web-dist/assets/{attention-AZ2a-mzO.js.map → attention--3lxyvUR.js.map} +1 -1
  51. package/web-dist/assets/{auth-Dzip9fVv.js → auth-BnOZcMwb.js} +2 -2
  52. package/web-dist/assets/{auth-Dzip9fVv.js.map → auth-BnOZcMwb.js.map} +1 -1
  53. package/web-dist/assets/{automations-BYFgPSs2.js → automations-D-OXGU7s.js} +2 -2
  54. package/web-dist/assets/{automations-BYFgPSs2.js.map → automations-D-OXGU7s.js.map} +1 -1
  55. package/web-dist/assets/{board-D2LALQcR.js → board-B2hNZFQA.js} +2 -2
  56. package/web-dist/assets/{board-D2LALQcR.js.map → board-B2hNZFQA.js.map} +1 -1
  57. package/web-dist/assets/{calendar-clock-CkYP2-Qf.js → calendar-clock-BPYJQFbH.js} +2 -2
  58. package/web-dist/assets/{calendar-clock-CkYP2-Qf.js.map → calendar-clock-BPYJQFbH.js.map} +1 -1
  59. package/web-dist/assets/chevron-right-CmbmRUFj.js +2 -0
  60. package/web-dist/assets/{chevron-right-Q-RTE0ar.js.map → chevron-right-CmbmRUFj.js.map} +1 -1
  61. package/web-dist/assets/code-wpUFOdpF.js +24 -0
  62. package/web-dist/assets/code-wpUFOdpF.js.map +1 -0
  63. package/web-dist/assets/{core.esm-yL4bmFrt.js → core.esm-kWS8EOvg.js} +2 -2
  64. package/web-dist/assets/{core.esm-yL4bmFrt.js.map → core.esm-kWS8EOvg.js.map} +1 -1
  65. package/web-dist/assets/{describe-B1R7Rpb3.js → describe-C6HLxXjb.js} +2 -2
  66. package/web-dist/assets/{describe-B1R7Rpb3.js.map → describe-C6HLxXjb.js.map} +1 -1
  67. package/web-dist/assets/{enroll-BJIkw0lm.js → enroll-ErV_s7ej.js} +2 -2
  68. package/web-dist/assets/{enroll-BJIkw0lm.js.map → enroll-ErV_s7ej.js.map} +1 -1
  69. package/web-dist/assets/{external-link-BHZxy4tb.js → external-link-fqMZHNsZ.js} +2 -2
  70. package/web-dist/assets/{external-link-BHZxy4tb.js.map → external-link-fqMZHNsZ.js.map} +1 -1
  71. package/web-dist/assets/{git-branch-C5Xwi6aW.js → git-branch-Bss2qoIr.js} +2 -2
  72. package/web-dist/assets/{git-branch-C5Xwi6aW.js.map → git-branch-Bss2qoIr.js.map} +1 -1
  73. package/web-dist/assets/{grip-vertical-kzr2x5pf.js → grip-vertical-DiopZ2MX.js} +2 -2
  74. package/web-dist/assets/{grip-vertical-kzr2x5pf.js.map → grip-vertical-DiopZ2MX.js.map} +1 -1
  75. package/web-dist/assets/{hand-DStB4fR7.js → hand-fz9o4rRo.js} +2 -2
  76. package/web-dist/assets/{hand-DStB4fR7.js.map → hand-fz9o4rRo.js.map} +1 -1
  77. package/web-dist/assets/{index-D3WBnjbc.js → index-BHIBqflQ.js} +4 -4
  78. package/web-dist/assets/{index-D3WBnjbc.js.map → index-BHIBqflQ.js.map} +1 -1
  79. package/web-dist/assets/index-CJ9yttLk.css +2 -0
  80. package/web-dist/assets/{link-2-Cny9mRKW.js → link-2-CM14Jk-Z.js} +2 -2
  81. package/web-dist/assets/{link-2-Cny9mRKW.js.map → link-2-CM14Jk-Z.js.map} +1 -1
  82. package/web-dist/assets/{logic-BOdOYgZ4.js → logic-C4E3wcuR.js} +2 -2
  83. package/web-dist/assets/{logic-BOdOYgZ4.js.map → logic-C4E3wcuR.js.map} +1 -1
  84. package/web-dist/assets/{logic-CHh1lc3G.js → logic-CxNUn_Si.js} +2 -2
  85. package/web-dist/assets/{logic-CHh1lc3G.js.map → logic-CxNUn_Si.js.map} +1 -1
  86. package/web-dist/assets/{more-BrHzsSfh.js → more-DPa20EIw.js} +2 -2
  87. package/web-dist/assets/{more-BrHzsSfh.js.map → more-DPa20EIw.js.map} +1 -1
  88. package/web-dist/assets/{pencil-BmHgPcCk.js → pencil-C7o6vJgq.js} +2 -2
  89. package/web-dist/assets/{pencil-BmHgPcCk.js.map → pencil-C7o6vJgq.js.map} +1 -1
  90. package/web-dist/assets/{play-Dul6ZDzY.js → play-CFs0JI3B.js} +2 -2
  91. package/web-dist/assets/{play-Dul6ZDzY.js.map → play-CFs0JI3B.js.map} +1 -1
  92. package/web-dist/assets/{plus-DzBRN9tc.js → plus-DEaNWSMA.js} +2 -2
  93. package/web-dist/assets/{plus-DzBRN9tc.js.map → plus-DEaNWSMA.js.map} +1 -1
  94. package/web-dist/assets/{policyLogic-DVorBdH6.js → policyLogic-1QWs7S1X.js} +2 -2
  95. package/web-dist/assets/{policyLogic-DVorBdH6.js.map → policyLogic-1QWs7S1X.js.map} +1 -1
  96. package/web-dist/assets/{prefs-CUMuH2EM.js → prefs-C0L6OJW2.js} +2 -2
  97. package/web-dist/assets/{prefs-CUMuH2EM.js.map → prefs-C0L6OJW2.js.map} +1 -1
  98. package/web-dist/assets/{preload-helper-vwPq19u5.js → preload-helper-B7-Z6Kuc.js} +2 -2
  99. package/web-dist/assets/{preload-helper-vwPq19u5.js.map → preload-helper-B7-Z6Kuc.js.map} +1 -1
  100. package/web-dist/assets/{queue-hRZWM_pM.js → queue-BGH7kGf3.js} +2 -2
  101. package/web-dist/assets/{queue-hRZWM_pM.js.map → queue-BGH7kGf3.js.map} +1 -1
  102. package/web-dist/assets/{rotate-ccw-ByDiAA6o.js → rotate-ccw-7XsjGljp.js} +2 -2
  103. package/web-dist/assets/{rotate-ccw-ByDiAA6o.js.map → rotate-ccw-7XsjGljp.js.map} +1 -1
  104. package/web-dist/assets/{search-DarT116I.js → search-cJqErX2K.js} +2 -2
  105. package/web-dist/assets/{search-DarT116I.js.map → search-cJqErX2K.js.map} +1 -1
  106. package/web-dist/assets/{settings-DHfdrqxv.js → settings-BWvrxYxe.js} +2 -2
  107. package/web-dist/assets/settings-BWvrxYxe.js.map +1 -0
  108. package/web-dist/assets/{states-hcvSpyb1.js → states-BtAXMBKP.js} +5 -5
  109. package/web-dist/assets/states-BtAXMBKP.js.map +1 -0
  110. package/web-dist/assets/{terminal-BmpsRI95.js → terminal-CMO1fwr6.js} +2 -2
  111. package/web-dist/assets/{terminal-BmpsRI95.js.map → terminal-CMO1fwr6.js.map} +1 -1
  112. package/web-dist/assets/{terminal-login-COaZPzQx.js → terminal-login-B4ilxY0w.js} +2 -2
  113. package/web-dist/assets/{terminal-login-COaZPzQx.js.map → terminal-login-B4ilxY0w.js.map} +1 -1
  114. package/web-dist/assets/{useBreakpoint-CXotoLeq.js → useBreakpoint-DQmHoUda.js} +2 -2
  115. package/web-dist/assets/{useBreakpoint-CXotoLeq.js.map → useBreakpoint-DQmHoUda.js.map} +1 -1
  116. package/web-dist/assets/{useNow-BweXkeWc.js → useNow-DAkRYkgZ.js} +2 -2
  117. package/web-dist/assets/{useNow-BweXkeWc.js.map → useNow-DAkRYkgZ.js.map} +1 -1
  118. package/web-dist/assets/{useResource-DAMkbbuf.js → useResource-BYljUzPs.js} +2 -2
  119. package/web-dist/assets/{useResource-DAMkbbuf.js.map → useResource-BYljUzPs.js.map} +1 -1
  120. package/web-dist/assets/{useSwipeTabs-3qLCxSS7.js → useSwipeTabs-DEx87Ogc.js} +2 -2
  121. package/web-dist/assets/{useSwipeTabs-3qLCxSS7.js.map → useSwipeTabs-DEx87Ogc.js.map} +1 -1
  122. package/web-dist/assets/{workboard-BEcRsjyQ.js → workboard-6c73HyIJ.js} +2 -2
  123. package/web-dist/assets/{workboard-BEcRsjyQ.js.map → workboard-6c73HyIJ.js.map} +1 -1
  124. package/web-dist/index.html +8 -8
  125. package/web-dist/sw.js +1 -1
  126. package/web-dist/assets/UINodeRenderer-CDPAUIOO.js.map +0 -1
  127. package/web-dist/assets/chevron-right-Q-RTE0ar.js +0 -2
  128. package/web-dist/assets/code-BuAtgr-5.js +0 -24
  129. package/web-dist/assets/code-BuAtgr-5.js.map +0 -1
  130. package/web-dist/assets/index-Bm6tklht.css +0 -2
  131. package/web-dist/assets/settings-DHfdrqxv.js.map +0 -1
  132. package/web-dist/assets/states-hcvSpyb1.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"SegmentedControl-CefWecy1.js","names":["__iconData","useState","useRef","useRef","useRef","__toESM","createLucideIcon","Button","require_jsx_runtime","cn","require_react","toast","__iconData$1","Check","__iconData","Copy","import_react","import_jsx_runtime","copyText","text","success","CopyButton","copied","setCopied","timer","toastMessage","label","CopyBlock","copyLabel","EASE","useIndicator","indicator","placed","valueRef","value","items","list","el","place","animate","x","w","toSelected","sel","root","ro","progress","f","all","i","cur","next","t","SegmentedControl","thumb","idx","options","o","block","className","e","onChange","selected"],"sources":["../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/check.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/copy.mjs","../../src/components/ui/Copy.tsx","../../src/components/ui/useIndicator.ts","../../src/components/ui/SegmentedControl.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"check\",\n size: 24,\n node: [[\"path\", { d: \"M20 6 9 17l-5-5\", key: \"1gmf2c\" }]]\n};\n__iconData.node;\nconst Check = createLucideIcon(__iconData);\n\nexport { __iconData, Check as default };\n//# sourceMappingURL=check.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"copy\",\n size: 24,\n node: [\n [\"rect\", { width: \"14\", height: \"14\", x: \"8\", y: \"8\", rx: \"2\", ry: \"2\", key: \"17jyea\" }],\n [\"path\", { d: \"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\", key: \"zix9uf\" }]\n ]\n};\n__iconData.node;\nconst Copy = createLucideIcon(__iconData);\n\nexport { __iconData, Copy as default };\n//# sourceMappingURL=copy.mjs.map\n","import { Check, Copy } from \"lucide-react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { Button } from \"./Button\";\nimport { toast } from \"./Toast\";\n\n/** Copy text to the clipboard with a toast; pass `false` to stay silent on success. */\nexport async function copyText(\n text: string,\n success: string | false = \"Copied to clipboard\",\n): Promise<boolean> {\n try {\n await navigator.clipboard.writeText(text);\n if (success) toast.success(success);\n return true;\n } catch {\n toast.error(\"Could not copy. Select the text and copy it manually.\");\n return false;\n }\n}\n\nexport function CopyButton({\n text,\n label = \"Copy\",\n toastMessage,\n size = \"sm\",\n}: {\n text: string;\n label?: string;\n toastMessage?: string;\n size?: \"sm\" | \"md\";\n}) {\n const [copied, setCopied] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n useEffect(() => () => void (timer.current && clearTimeout(timer.current)), []);\n return (\n <Button\n size={size}\n icon={copied ? <Check className=\"size-4\" /> : <Copy className=\"size-4\" />}\n onClick={async () => {\n if (await copyText(text, toastMessage)) {\n setCopied(true);\n if (timer.current) clearTimeout(timer.current);\n timer.current = setTimeout(() => setCopied(false), 2000);\n }\n }}\n >\n {copied ? \"Copied\" : label}\n </Button>\n );\n}\n\n/** A monospace command or URL with a copy button; wraps instead of overflowing. */\nexport function CopyBlock({\n text,\n label,\n copyLabel = \"Copy\",\n}: {\n text: string;\n /** Accessible name of the code block. */\n label: string;\n copyLabel?: string;\n}) {\n return (\n <figure className=\"m-0 flex min-w-0 flex-col gap-2 sm:flex-row sm:items-start\">\n <figcaption className=\"sr-only\">{label}</figcaption>\n <pre className=\"min-w-0 flex-1 whitespace-pre-wrap break-all rounded-md border border-border bg-surface-2 px-3 py-2 font-mono text-sm\">\n {text}\n </pre>\n <CopyButton text={text} label={copyLabel} />\n </figure>\n );\n}\n","import { type RefObject, useEffect, useLayoutEffect, useRef } from \"react\";\nimport type { SwipeProgress } from \"../../lib/swipeProgress\";\n\nconst EASE = \"cubic-bezier(0.2, 0.9, 0.25, 1)\";\n\n/**\n * A selection indicator (a tab underline, a segmented control's thumb) that slides between the\n * items of `list` marked `data-indicator-key`, and follows a swipe's `progress` live.\n */\nexport function useIndicator(\n list: RefObject<HTMLElement | null>,\n value: string,\n progress?: SwipeProgress,\n): RefObject<HTMLSpanElement | null> {\n const indicator = useRef<HTMLSpanElement>(null);\n const placed = useRef(false);\n const valueRef = useRef(value);\n valueRef.current = value;\n\n const items = () =>\n [...(list.current?.querySelectorAll<HTMLElement>(\"[data-indicator-key]\") ?? [])].filter(\n (el) => el.closest(\"[data-indicator-root]\") === list.current,\n );\n const place = (x: number, w: number, animate: boolean) => {\n const el = indicator.current;\n if (!el) return;\n el.style.transition = animate ? `transform 260ms ${EASE}, width 260ms ${EASE}` : \"none\";\n el.style.transform = `translateX(${x}px)`;\n el.style.width = `${w}px`;\n el.style.opacity = w > 0 ? \"1\" : \"0\";\n };\n const toSelected = (animate: boolean) => {\n const sel = items().find((el) => el.dataset.indicatorKey === valueRef.current);\n if (!sel) return place(0, 0, false);\n place(sel.offsetLeft, sel.offsetWidth, animate && placed.current);\n placed.current = true;\n };\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: placement follows the selection\n useLayoutEffect(() => toSelected(true), [value]);\n\n // Labels and counts change width; the list resizes with the window.\n // biome-ignore lint/correctness/useExhaustiveDependencies: observers read the latest value\n useEffect(() => {\n const root = list.current;\n if (!root || typeof ResizeObserver === \"undefined\") return;\n const ro = new ResizeObserver(() => toSelected(false));\n ro.observe(root);\n for (const el of items()) ro.observe(el);\n return () => ro.disconnect();\n });\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: subscribe once per progress channel\n useEffect(() => {\n if (!progress) return;\n return progress.listen((f) => {\n if (f === null) return toSelected(true);\n const all = items();\n const i = all.findIndex((el) => el.dataset.indicatorKey === valueRef.current);\n const cur = all[i];\n const next = all[i + (f > 0 ? 1 : -1)];\n if (!cur || !next) return;\n const t = Math.min(1, Math.abs(f));\n place(\n cur.offsetLeft + (next.offsetLeft - cur.offsetLeft) * t,\n cur.offsetWidth + (next.offsetWidth - cur.offsetWidth) * t,\n false,\n );\n });\n }, [progress]);\n\n return indicator;\n}\n","import { type ReactNode, useRef } from \"react\";\nimport { cn } from \"../../lib/cn\";\nimport type { SwipeProgress } from \"../../lib/swipeProgress\";\nimport { useIndicator } from \"./useIndicator\";\n\nexport interface SegmentOption<T extends string> {\n value: T;\n label: ReactNode;\n icon?: ReactNode;\n badge?: ReactNode;\n /** Tooltip. */\n title?: string;\n}\n\nexport interface SegmentedControlProps<T extends string> {\n options: SegmentOption<T>[];\n value: T;\n onChange: (value: T) => void;\n /** Accessible name. */\n label: string;\n className?: string;\n block?: boolean;\n /** A swipe between the options' panels; the selection follows it. */\n progress?: SwipeProgress;\n}\n\n/** Radio-group style switcher (e.g. mobile Chat / Changes / Details). */\nexport function SegmentedControl<T extends string>({\n options,\n value,\n onChange,\n label,\n className,\n block,\n progress,\n}: SegmentedControlProps<T>) {\n const root = useRef<HTMLDivElement>(null);\n const thumb = useIndicator(root, value, progress);\n const idx = options.findIndex((o) => o.value === value);\n return (\n <div\n ref={root}\n role=\"radiogroup\"\n aria-label={label}\n data-indicator-root\n className={cn(\n \"relative inline-flex rounded-lg border border-border bg-surface-2 p-0.5\",\n block && \"flex w-full\",\n className,\n )}\n onKeyDown={(e) => {\n let next = -1;\n if (e.key === \"ArrowRight\" || e.key === \"ArrowDown\") next = (idx + 1) % options.length;\n else if (e.key === \"ArrowLeft\" || e.key === \"ArrowUp\")\n next = (idx - 1 + options.length) % options.length;\n if (next < 0) return;\n e.preventDefault();\n onChange(options[next]!.value);\n const btns = e.currentTarget.querySelectorAll<HTMLElement>('[role=\"radio\"]');\n btns[next]?.focus();\n }}\n >\n {/* The selection: one thumb that slides between the options. */}\n <span\n ref={thumb}\n aria-hidden\n className=\"pointer-events-none absolute inset-y-0.5 left-0 rounded-md border border-border bg-surface opacity-0 shadow-sm\"\n />\n {options.map((o) => {\n const selected = o.value === value;\n return (\n // biome-ignore lint/a11y/useSemanticElements: button-based radio group (WAI-ARIA radio pattern)\n <button\n key={o.value}\n type=\"button\"\n role=\"radio\"\n aria-checked={selected}\n title={o.title}\n tabIndex={selected ? 0 : -1}\n data-indicator-key={o.value}\n onClick={() => onChange(o.value)}\n className={cn(\n \"tap relative inline-flex min-h-8 flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-3 text-sm font-medium whitespace-nowrap transition-colors\",\n selected ? \"text-text\" : \"text-muted hover:text-text\",\n )}\n >\n {o.icon}\n {o.label}\n {o.badge}\n </button>\n );\n })}\n </div>\n );\n}\n"],"ignoreList":[0,1],"mappings":"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"}
1
+ {"version":3,"file":"SegmentedControl-D6SGXg_K.js","names":["__iconData","useState","useRef","useRef","useRef","__toESM","createLucideIcon","Button","require_jsx_runtime","cn","require_react","toast","__iconData$1","Check","__iconData","Copy","import_react","import_jsx_runtime","copyText","text","success","CopyButton","copied","setCopied","timer","toastMessage","label","CopyBlock","copyLabel","EASE","useIndicator","indicator","placed","valueRef","value","items","list","el","place","animate","x","w","toSelected","sel","root","ro","progress","f","all","i","cur","next","t","SegmentedControl","thumb","idx","options","o","block","className","e","onChange","selected"],"sources":["../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/check.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/copy.mjs","../../src/components/ui/Copy.tsx","../../src/components/ui/useIndicator.ts","../../src/components/ui/SegmentedControl.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"check\",\n size: 24,\n node: [[\"path\", { d: \"M20 6 9 17l-5-5\", key: \"1gmf2c\" }]]\n};\n__iconData.node;\nconst Check = createLucideIcon(__iconData);\n\nexport { __iconData, Check as default };\n//# sourceMappingURL=check.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"copy\",\n size: 24,\n node: [\n [\"rect\", { width: \"14\", height: \"14\", x: \"8\", y: \"8\", rx: \"2\", ry: \"2\", key: \"17jyea\" }],\n [\"path\", { d: \"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\", key: \"zix9uf\" }]\n ]\n};\n__iconData.node;\nconst Copy = createLucideIcon(__iconData);\n\nexport { __iconData, Copy as default };\n//# sourceMappingURL=copy.mjs.map\n","import { Check, Copy } from \"lucide-react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { Button } from \"./Button\";\nimport { toast } from \"./Toast\";\n\n/** Copy text to the clipboard with a toast; pass `false` to stay silent on success. */\nexport async function copyText(\n text: string,\n success: string | false = \"Copied to clipboard\",\n): Promise<boolean> {\n try {\n await navigator.clipboard.writeText(text);\n if (success) toast.success(success);\n return true;\n } catch {\n toast.error(\"Could not copy. Select the text and copy it manually.\");\n return false;\n }\n}\n\nexport function CopyButton({\n text,\n label = \"Copy\",\n toastMessage,\n size = \"sm\",\n}: {\n text: string;\n label?: string;\n toastMessage?: string;\n size?: \"sm\" | \"md\";\n}) {\n const [copied, setCopied] = useState(false);\n const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n useEffect(() => () => void (timer.current && clearTimeout(timer.current)), []);\n return (\n <Button\n size={size}\n icon={copied ? <Check className=\"size-4\" /> : <Copy className=\"size-4\" />}\n onClick={async () => {\n if (await copyText(text, toastMessage)) {\n setCopied(true);\n if (timer.current) clearTimeout(timer.current);\n timer.current = setTimeout(() => setCopied(false), 2000);\n }\n }}\n >\n {copied ? \"Copied\" : label}\n </Button>\n );\n}\n\n/** A monospace command or URL with a copy button; wraps instead of overflowing. */\nexport function CopyBlock({\n text,\n label,\n copyLabel = \"Copy\",\n}: {\n text: string;\n /** Accessible name of the code block. */\n label: string;\n copyLabel?: string;\n}) {\n return (\n <figure className=\"m-0 flex min-w-0 flex-col gap-2 sm:flex-row sm:items-start\">\n <figcaption className=\"sr-only\">{label}</figcaption>\n <pre className=\"min-w-0 flex-1 whitespace-pre-wrap break-all rounded-md border border-border bg-surface-2 px-3 py-2 font-mono text-sm\">\n {text}\n </pre>\n <CopyButton text={text} label={copyLabel} />\n </figure>\n );\n}\n","import { type RefObject, useEffect, useLayoutEffect, useRef } from \"react\";\nimport type { SwipeProgress } from \"../../lib/swipeProgress\";\n\nconst EASE = \"cubic-bezier(0.2, 0.9, 0.25, 1)\";\n\n/**\n * A selection indicator (a tab underline, a segmented control's thumb) that slides between the\n * items of `list` marked `data-indicator-key`, and follows a swipe's `progress` live.\n */\nexport function useIndicator(\n list: RefObject<HTMLElement | null>,\n value: string,\n progress?: SwipeProgress,\n): RefObject<HTMLSpanElement | null> {\n const indicator = useRef<HTMLSpanElement>(null);\n const placed = useRef(false);\n const valueRef = useRef(value);\n valueRef.current = value;\n\n const items = () =>\n [...(list.current?.querySelectorAll<HTMLElement>(\"[data-indicator-key]\") ?? [])].filter(\n (el) => el.closest(\"[data-indicator-root]\") === list.current,\n );\n const place = (x: number, w: number, animate: boolean) => {\n const el = indicator.current;\n if (!el) return;\n el.style.transition = animate ? `transform 260ms ${EASE}, width 260ms ${EASE}` : \"none\";\n el.style.transform = `translateX(${x}px)`;\n el.style.width = `${w}px`;\n el.style.opacity = w > 0 ? \"1\" : \"0\";\n };\n const toSelected = (animate: boolean) => {\n const sel = items().find((el) => el.dataset.indicatorKey === valueRef.current);\n if (!sel) return place(0, 0, false);\n place(sel.offsetLeft, sel.offsetWidth, animate && placed.current);\n placed.current = true;\n };\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: placement follows the selection\n useLayoutEffect(() => toSelected(true), [value]);\n\n // Labels and counts change width; the list resizes with the window.\n // biome-ignore lint/correctness/useExhaustiveDependencies: observers read the latest value\n useEffect(() => {\n const root = list.current;\n if (!root || typeof ResizeObserver === \"undefined\") return;\n const ro = new ResizeObserver(() => toSelected(false));\n ro.observe(root);\n for (const el of items()) ro.observe(el);\n return () => ro.disconnect();\n });\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: subscribe once per progress channel\n useEffect(() => {\n if (!progress) return;\n return progress.listen((f) => {\n if (f === null) return toSelected(true);\n const all = items();\n const i = all.findIndex((el) => el.dataset.indicatorKey === valueRef.current);\n const cur = all[i];\n const next = all[i + (f > 0 ? 1 : -1)];\n if (!cur || !next) return;\n const t = Math.min(1, Math.abs(f));\n place(\n cur.offsetLeft + (next.offsetLeft - cur.offsetLeft) * t,\n cur.offsetWidth + (next.offsetWidth - cur.offsetWidth) * t,\n false,\n );\n });\n }, [progress]);\n\n return indicator;\n}\n","import { type ReactNode, useRef } from \"react\";\nimport { cn } from \"../../lib/cn\";\nimport type { SwipeProgress } from \"../../lib/swipeProgress\";\nimport { useIndicator } from \"./useIndicator\";\n\nexport interface SegmentOption<T extends string> {\n value: T;\n label: ReactNode;\n icon?: ReactNode;\n badge?: ReactNode;\n /** Tooltip. */\n title?: string;\n}\n\nexport interface SegmentedControlProps<T extends string> {\n options: SegmentOption<T>[];\n value: T;\n onChange: (value: T) => void;\n /** Accessible name. */\n label: string;\n className?: string;\n block?: boolean;\n /** A swipe between the options' panels; the selection follows it. */\n progress?: SwipeProgress;\n}\n\n/** Radio-group style switcher (e.g. mobile Chat / Changes / Details). */\nexport function SegmentedControl<T extends string>({\n options,\n value,\n onChange,\n label,\n className,\n block,\n progress,\n}: SegmentedControlProps<T>) {\n const root = useRef<HTMLDivElement>(null);\n const thumb = useIndicator(root, value, progress);\n const idx = options.findIndex((o) => o.value === value);\n return (\n <div\n ref={root}\n role=\"radiogroup\"\n aria-label={label}\n data-indicator-root\n className={cn(\n \"relative inline-flex rounded-lg border border-border bg-surface-2 p-0.5\",\n block && \"flex w-full\",\n className,\n )}\n onKeyDown={(e) => {\n let next = -1;\n if (e.key === \"ArrowRight\" || e.key === \"ArrowDown\") next = (idx + 1) % options.length;\n else if (e.key === \"ArrowLeft\" || e.key === \"ArrowUp\")\n next = (idx - 1 + options.length) % options.length;\n if (next < 0) return;\n e.preventDefault();\n onChange(options[next]!.value);\n const btns = e.currentTarget.querySelectorAll<HTMLElement>('[role=\"radio\"]');\n btns[next]?.focus();\n }}\n >\n {/* The selection: one thumb that slides between the options. */}\n <span\n ref={thumb}\n aria-hidden\n className=\"pointer-events-none absolute inset-y-0.5 left-0 rounded-md border border-border bg-surface opacity-0 shadow-sm\"\n />\n {options.map((o) => {\n const selected = o.value === value;\n return (\n // biome-ignore lint/a11y/useSemanticElements: button-based radio group (WAI-ARIA radio pattern)\n <button\n key={o.value}\n type=\"button\"\n role=\"radio\"\n aria-checked={selected}\n title={o.title}\n tabIndex={selected ? 0 : -1}\n data-indicator-key={o.value}\n onClick={() => onChange(o.value)}\n className={cn(\n \"tap relative inline-flex min-h-8 flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-3 text-sm font-medium whitespace-nowrap transition-colors\",\n selected ? \"text-text\" : \"text-muted hover:text-text\",\n )}\n >\n {o.icon}\n {o.label}\n {o.badge}\n </button>\n );\n })}\n </div>\n );\n}\n"],"ignoreList":[0,1],"mappings":"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"}
@@ -1,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{m as t,v as n,yn as r}from"./states-hcvSpyb1.js";import{U as i}from"./index-D3WBnjbc.js";var a=e(r(),1),o=t(),s=(0,a.forwardRef)(function({className:e,width:t=`full`,children:r,...a},s){return(0,o.jsx)(`select`,{ref:s,className:n(`tap block h-9 min-w-0 px-2.5`,t===`auto`?`w-auto`:`w-full`,i,e),...a,children:r})});export{s as t};
2
- //# sourceMappingURL=Select-CdANXO3X.js.map
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{m as t,v as n,yn as r}from"./states-BtAXMBKP.js";import{U as i}from"./index-BHIBqflQ.js";var a=e(r(),1),o=t(),s=(0,a.forwardRef)(function({className:e,width:t=`full`,children:r,...a},s){return(0,o.jsx)(`select`,{ref:s,className:n(`tap block h-9 min-w-0 px-2.5`,t===`auto`?`w-auto`:`w-full`,i,e),...a,children:r})});export{s as t};
2
+ //# sourceMappingURL=Select-D41sYIWt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Select-CdANXO3X.js","names":["forwardRef","__toESM","require_jsx_runtime","cn","require_react","CONTROL_CLASSES","import_react","import_jsx_runtime","Select","rest","width","className"],"sources":["../../src/components/ui/Select.tsx"],"sourcesContent":["import { forwardRef, type SelectHTMLAttributes } from \"react\";\nimport { cn } from \"../../lib/cn\";\nimport { CONTROL_CLASSES } from \"./TextArea\";\n\nexport interface SelectProps extends SelectHTMLAttributes<HTMLSelectElement> {\n /** \"full\" (default) fills its container; \"auto\" sizes to content for inline toolbars. */\n width?: \"full\" | \"auto\";\n}\n\n/** Native select with the same look, focus ring and invalid state as TextInput. */\nexport const Select = forwardRef<HTMLSelectElement, SelectProps>(function Select(\n { className, width = \"full\", children, ...rest },\n ref,\n) {\n return (\n <select\n ref={ref}\n className={cn(\n \"tap block h-9 min-w-0 px-2.5\",\n width === \"auto\" ? \"w-auto\" : \"w-full\",\n CONTROL_CLASSES,\n className,\n )}\n {...rest}\n >\n {children}\n </select>\n );\n});\n"],"mappings":"A,wKAUaQ,GAAA,EAASR,EAAAA,WAAAA,CAA2C,SAC/D,CAAE,YAAW,QAAQ,OAAQ,WAAU,GAAGS,GAC1C,EACA,CACA,OACE,EAAAF,EAAA,IAAA,CAAC,SAAD,CACO,MACL,UAAWJ,EACT,+BACAO,IAAU,OAAS,SAAW,SAC9BL,EACAM,CACF,EACA,GAAIF,EAEH,UACK,CAAA,CAEZ,CAAC,E"}
1
+ {"version":3,"file":"Select-D41sYIWt.js","names":["forwardRef","__toESM","require_jsx_runtime","cn","require_react","CONTROL_CLASSES","import_react","import_jsx_runtime","Select","rest","width","className"],"sources":["../../src/components/ui/Select.tsx"],"sourcesContent":["import { forwardRef, type SelectHTMLAttributes } from \"react\";\nimport { cn } from \"../../lib/cn\";\nimport { CONTROL_CLASSES } from \"./TextArea\";\n\nexport interface SelectProps extends SelectHTMLAttributes<HTMLSelectElement> {\n /** \"full\" (default) fills its container; \"auto\" sizes to content for inline toolbars. */\n width?: \"full\" | \"auto\";\n}\n\n/** Native select with the same look, focus ring and invalid state as TextInput. */\nexport const Select = forwardRef<HTMLSelectElement, SelectProps>(function Select(\n { className, width = \"full\", children, ...rest },\n ref,\n) {\n return (\n <select\n ref={ref}\n className={cn(\n \"tap block h-9 min-w-0 px-2.5\",\n width === \"auto\" ? \"w-auto\" : \"w-full\",\n CONTROL_CLASSES,\n className,\n )}\n {...rest}\n >\n {children}\n </select>\n );\n});\n"],"mappings":"A,wKAUaQ,GAAA,EAASR,EAAAA,WAAAA,CAA2C,SAC/D,CAAE,YAAW,QAAQ,OAAQ,WAAU,GAAGS,GAC1C,EACA,CACA,OACE,EAAAF,EAAA,IAAA,CAAC,SAAD,CACO,MACL,UAAWJ,EACT,+BACAO,IAAU,OAAS,SAAW,SAC9BL,EACAM,CACF,EACA,GAAIF,EAEH,UACK,CAAA,CAEZ,CAAC,E"}
@@ -1,5 +1,5 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$t as t,Bt as n,D as r,F as i,G as a,It as o,Lt as s,Mt as c,Qt as l,Rt as u,S as d,_ as f,a as p,c as m,cn as h,d as g,en as _,f as v,g as y,gn as b,in as x,m as S,n as C,rn as w,tn as T,v as E,yn as D,z as O}from"./states-hcvSpyb1.js";import{a as k,n as A,t as j,y as M}from"./Overlay-hRkfpjK4.js";import{s as N}from"./auth-Dzip9fVv.js";import{y as P}from"./preload-helper-vwPq19u5.js";import{a as ee,o as F}from"./SegmentedControl-CefWecy1.js";import{t as I}from"./external-link-BHZxy4tb.js";import{t as te}from"./plus-DzBRN9tc.js";import{t as ne}from"./search-DarT116I.js";import{F as re,G as L,K as R,O as z,W as B,ct as ie,j as V,t as ae,u as oe}from"./index-D3WBnjbc.js";import{t as H}from"./TextLink-DMi_ZI43.js";import{r as se,t as U}from"./Field-DGV7eljt.js";import{n as W,t as ce}from"./RadioCards-9YvqB3va.js";import{t as le}from"./Select-CdANXO3X.js";import{n as G}from"./Switch-DrrWalaQ.js";import{n as ue}from"./ScopeSelect-DmWCXeIf.js";import{t as K}from"./Checkbox-BdFQsqCG.js";var de={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};de.node;var fe=r(de),pe={name:`square-terminal`,size:24,node:[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]],aliases:[`terminal-square`]};pe.node;var me=r(pe),q=e(D(),1),J=S();function he({value:e,min:t,max:n,onChange:r,label:i,pane:a=`before`,step:o=16,onReset:s,orientation:c=`vertical`,className:l}){let u=(0,q.useRef)(null),d=e=>Math.round(Math.min(n,Math.max(t,e))),f=a===`before`?1:-1,p=c===`horizontal`,m=p?`ArrowDown`:`ArrowRight`,h=p?`ArrowUp`:`ArrowLeft`;return(0,J.jsx)(`div`,{role:`separator`,"aria-orientation":c,"aria-label":i,"aria-valuenow":Math.round(e),"aria-valuemin":t,"aria-valuemax":n,tabIndex:0,className:E(`group relative z-10 shrink-0 touch-none select-none`,p?`h-1.5 w-full cursor-row-resize`:`w-1.5 cursor-col-resize`,`focus-visible:outline-none`,l),onPointerDown:t=>{t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),u.current={x:p?t.clientY:t.clientX,value:e}},onPointerMove:e=>{if(!u.current)return;let t=p?e.clientY:e.clientX;r(d(u.current.value+f*(t-u.current.x)))},onPointerUp:e=>{u.current=null,e.currentTarget.releasePointerCapture(e.pointerId)},onPointerCancel:()=>{u.current=null},onDoubleClick:s,onKeyDown:i=>{let a=i.shiftKey?o*4:o;if(i.key===m)r(d(e+f*a));else if(i.key===h)r(d(e-f*a));else if(i.key===`Home`)r(t);else if(i.key===`End`)r(n);else if(i.key===`Enter`&&s)s();else return;i.preventDefault()},children:(0,J.jsx)(`div`,{"aria-hidden":!0,className:E(`absolute bg-border group-hover:bg-accent group-focus-visible:bg-accent`,p?`inset-x-0 top-1/2 h-px -translate-y-1/2 group-hover:h-0.5 group-focus-visible:h-0.5`:`inset-y-0 left-1/2 w-px -translate-x-1/2 group-hover:w-0.5 group-focus-visible:w-0.5`)})})}var Y=`/api/catalog/connections`,X=V(`projects`),Z=V(`projects/connect`),ge=V(`projects/connect/pat`);function _e(e=`github.com`){return`https://${e}/settings/tokens/new?scopes=repo,read:org,project&description=Switchyard`}var ve=_e(),ye={to:X,label:`Projects`};function Q(e){if(e)try{let t=new URL(e);if(t.protocol===`https:`&&!t.username&&!t.password)return t.href}catch{}}function be(){let[e,n]=(0,q.useState)(null),[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(0);return(0,q.useEffect)(()=>{let e=new AbortController;return t(Y,void 0,e.signal).then(t=>{e.signal.aborted||(n(t),i(null))},t=>{e.signal.aborted||(x(t)&&(t.status===404||t.code===`unsupported_capability`)?(n({available:!1,connections:[],conflicts:[]}),i(null)):i(t))}),()=>e.abort()},[a]),(0,q.useEffect)(()=>{let e=window.setInterval(()=>o(e=>e+1),6e4);return()=>window.clearInterval(e)},[]),{inventory:e,error:r,reload:()=>o(e=>e+1)}}function xe(e){return`${e.account} · ${e.kind===`pat`?`Personal token`:`GitHub App`}`}var Se={pending:`Waiting for installation or organization approval`,ready:`Connected`,stale:`Sync failed. Showing the last known repositories.`,suspended:`Installation suspended. Check its status on GitHub.`,removed:`Installation removed on GitHub`,disconnected:`Disconnected from Switchyard`},Ce={ready:`success`,pending:`warning`,stale:`warning`,suspended:`danger`,removed:`danger`,disconnected:`neutral`};function we(e){if(e.kind!==`pat`)return null;let t=e.selection?.owners??[],n=e.selection?.repositories??[],r=[];return t.length>0&&r.push(t.join(`, `)),n.length>0&&r.push(`${n.length} repo${n.length===1?``:`s`}`),r.length>0?r.join(` · `):`No repositories selected yet`}function Te({catalog:{inventory:e,error:t,reload:n},projects:r}){return!e&&!t?(0,J.jsx)(m,{label:`Loading repository connections…`}):(0,J.jsxs)(W,{title:`Repository connections`,description:`Connect with the GitHub App for personal accounts, or add a Personal Access Token for work organizations.`,actions:e?.available&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(h,{to:Z,className:v(`primary`,`sm`),children:[(0,J.jsx)(te,{"aria-hidden":!0,className:`size-3.5`}),`Connect GitHub`]}),(0,J.jsxs)(h,{to:ge,className:v(`secondary`,`sm`),children:[(0,J.jsx)(ie,{"aria-hidden":!0,className:`size-3.5`}),`Add Personal Token`]})]}),children:[t!=null&&(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(p,{error:t}),(0,J.jsx)(g,{size:`sm`,onClick:n,children:`Reload connections`})]}),e&&!e.available&&(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`The repository connector is unavailable. Existing projects show the last known catalog.`}),e?.available&&e.connections.length===0&&(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`No GitHub accounts connected.`}),e&&e.connections.length>0&&(0,J.jsx)(`div`,{className:`divide-y divide-border`,children:e.connections.map(t=>(0,J.jsx)(Ee,{connection:t,available:e.available,reload:n},t.id))}),e?.conflicts.map(t=>(0,J.jsx)(De,{conflict:t,projects:r,disabled:!e.available,reload:n},JSON.stringify([t.connectionId,t.externalId])))]})}function Ee({connection:e,available:t,reload:n}){let[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(null),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1),m=(0,q.useRef)(!1),h=e.kind===`pat`,_=e.state===`disconnected`,b=!h&&!_&&(e.state===`pending`||e.state===`removed`)?Q(e.installUrl):void 0,x=_?void 0:Q(e.manageUrl),S=async t=>{if(!r){i(t),o(null);try{await T(`${Y}/${encodeURIComponent(e.id)}/${t}`),t===`disconnect`&&c(!1)}catch(e){o(e)}finally{n(),i(null)}}};(0,q.useEffect)(()=>{if(!t||_)return;let e=()=>{document.visibilityState===`visible`&&m.current&&(m.current=!1,S(`refresh`))};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}});let C=we(e);return(0,J.jsxs)(`div`,{"data-testid":`catalog-connection-${e.id}`,"data-account":e.account,className:`space-y-3 py-4 first:pt-1 last:pb-1`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,J.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.account}),(0,J.jsx)(M,{tone:`neutral`,children:h?`Personal token`:`GitHub App`}),(0,J.jsx)(`span`,{role:`status`,children:(0,J.jsx)(M,{tone:Ce[e.state],children:Se[e.state]})})]}),e.lastSyncedAt&&(0,J.jsxs)(`span`,{className:`text-xs text-subtle`,children:[`Synced`,` `,(0,J.jsx)(`time`,{dateTime:e.lastSyncedAt,title:f(e.lastSyncedAt),children:y(e.lastSyncedAt)})]})]}),C&&(0,J.jsx)(`p`,{className:`truncate text-xs text-muted`,children:C}),e.lastError&&(0,J.jsx)(`p`,{className:`break-words text-sm text-warning`,children:e.lastError}),b&&(0,J.jsx)(`p`,{className:`text-xs text-muted`,children:`Install the app, select repositories on GitHub, then return here and refresh.`}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-0.5`,children:[b&&(0,J.jsxs)(`a`,{href:b,target:`_blank`,rel:`noopener noreferrer`,className:v(`primary`,`sm`),onClick:()=>{m.current=!0},children:[(0,J.jsx)(I,{"aria-hidden":!0,className:`size-3.5`}),`Install on GitHub`]}),h&&t&&!_&&(0,J.jsx)(g,{size:`sm`,disabled:!!r,onClick:()=>u(!0),children:`Edit repositories`}),x&&!b&&(0,J.jsxs)(`a`,{href:x,target:`_blank`,rel:`noopener noreferrer`,className:v(`secondary`,`sm`),onClick:()=>{m.current=!0},children:[(0,J.jsx)(I,{"aria-hidden":!0,className:`size-3.5`}),h?`Manage token on GitHub`:`Manage repositories on GitHub`]}),t&&!_&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(g,{size:`sm`,icon:(0,J.jsx)(d,{className:`size-3.5`}),busy:r===`refresh`,disabled:r===`disconnect`,onClick:()=>void S(`refresh`),children:e.state===`pending`||b?`Refresh connection`:`Refresh`}),(0,J.jsx)(g,{size:`sm`,variant:`ghost`,className:`ml-auto text-muted hover:text-danger`,disabled:!!r,onClick:()=>{o(null),c(!0)},children:`Disconnect`})]})]}),e.lastError?.startsWith(`Reconnect provider`)&&(0,J.jsx)(H,{to:h?ge:Z,variant:`action`,children:`Reconnect provider`}),!s&&(0,J.jsx)(p,{error:a}),(0,J.jsx)(j,{open:s,title:`Disconnect ${e.account}?`,onClose:()=>{r||c(!1)},onConfirm:()=>S(`disconnect`),confirmLabel:`Disconnect`,busy:r===`disconnect`,error:a,children:(0,J.jsx)(`p`,{className:`text-sm`,children:`Repositories shared only by this connection will move to Previous projects. Checkouts and session history will remain.`})}),h&&(0,J.jsx)(A,{open:l,onClose:()=>u(!1),title:`Edit repositories · ${e.account}`,description:`Choose organizations and individual repositories to include in Switchyard.`,children:(0,J.jsx)(Me,{connectionId:e.id,initialSelection:e.selection,onSaved:()=>{u(!1),n(),R.success(`Repositories updated`)},onCancel:()=>u(!1)})})]})}function De({conflict:e,projects:t,disabled:n,reload:r}){let i=(0,q.useId)(),[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(null),d=e.projectIds.filter(e=>t.some(t=>t.id===e));return(0,J.jsxs)(`form`,{className:`space-y-2 border-t border-border pt-3`,onSubmit:async t=>{if(t.preventDefault(),!(s||n||!d.includes(a))){c(!0),u(null);try{await T(`${Y}/${encodeURIComponent(e.connectionId)}/resolve-history`,{externalId:e.externalId,projectId:a}),r(),R.success(`Existing history selected`)}catch(e){u(e)}finally{c(!1)}}},children:[(0,J.jsx)(U,{id:i,label:`Choose existing history`,hint:`More than one previous project matches ${e.fullName}. Choose which history to keep using for this repository. The others remain available separately.`,children:(0,J.jsxs)(le,{id:i,value:d.includes(a)?a:``,disabled:n||s,onChange:e=>o(e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:`Choose a previous project`}),d.map(e=>(0,J.jsxs)(`option`,{value:e,children:[t.find(t=>t.id===e)?.name,` · `,e]},e))]})}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(g,{size:`sm`,type:`submit`,busy:s,disabled:n||!d.includes(a),children:`Use selected history`}),d.includes(a)&&(0,J.jsx)(H,{to:V(`projects/${encodeURIComponent(a)}`),target:`_blank`,rel:`noreferrer`,children:`View selected project`})]}),(0,J.jsx)(p,{error:l})]})}function Oe({connection:e,onReady:t}){let[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(null),o=Q(e.installUrl),s=(0,q.useRef)(!1),c=async()=>{if(!n){r(!0),a(null);try{(await T(`${Y}/${encodeURIComponent(e.id)}/refresh`)).connections.find(t=>t.id===e.id)?.state===`ready`&&(R.success(`GitHub repositories synced`),t())}catch(e){a(e)}finally{r(!1)}}};return(0,q.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&s.current&&c()};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}}),(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Signed in as `,e.account]}),(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`Choose which repositories to share on GitHub. Switchyard syncs them automatically when you return to this tab.`}),(0,J.jsx)(p,{error:i}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[o&&(0,J.jsxs)(`a`,{href:o,target:`_blank`,rel:`noreferrer`,className:v(`primary`),onClick:()=>{s.current=!0},children:[(0,J.jsx)(I,{"aria-hidden":!0,className:`size-4`}),`Choose repositories on GitHub`]}),(0,J.jsx)(g,{size:`sm`,busy:n,onClick:c,children:`Check now`}),(0,J.jsx)(h,{className:v(`secondary`),to:X,replace:!0,children:`Open Projects`})]})]})}function ke(){let e=b(),[t,n]=(0,q.useState)(null),[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(null),h=(0,q.useRef)(!1),_=async()=>{if(!l){u(!0),f(null),i(null);try{let e=await T(`${Y}/begin`,{});if(e.mode===`oauth`){let t=Q(e.authorizeUrl);if(!t)throw Error(`GitHub did not return a valid sign-in URL.`);o(!0),window.location.assign(t);return}let t=Q(e.verificationUri);if(!t)throw Error(`GitHub did not return a valid sign-in URL.`);n({...e,verificationUri:t})}catch(e){f(e)}finally{u(!1)}}};return(0,q.useEffect)(()=>{h.current||(h.current=!0,_())},[]),(0,q.useEffect)(()=>{if(!t||r)return;let a=!0,o,s=r=>{o=window.setTimeout(async()=>{try{let r=await T(`${Y}/poll`,{flowId:t.flowId});if(!a)return;r.status===`complete`?(n(null),R.success(`Connected GitHub as ${r.connection.account}`),r.connection.state===`ready`?e(X,{replace:!0}):i(r.connection)):s(r.interval??t.interval)}catch(e){if(!a)return;f(e),n(null)}},Math.max(1,r)*1e3)};return s(t.interval),()=>{a=!1,o!==void 0&&window.clearTimeout(o)}},[t,r,e]),(0,J.jsx)(z,{title:`Connect GitHub`,description:`Sign in with GitHub once to list repositories across your personal account and organizations.`,back:ye,children:(0,J.jsx)(W,{children:a||l&&!t&&!d?(0,J.jsx)(m,{label:`Redirecting to GitHub…`}):r?(0,J.jsx)(Oe,{connection:r,onReady:()=>e(X,{replace:!0})}):t?(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`Enter this code on GitHub to authorize Switchyard. This page updates automatically once you approve it.`}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,J.jsx)(`code`,{"data-testid":`github-device-code`,className:`rounded-md border border-border bg-surface-2 px-3 py-2 font-mono text-lg font-semibold tracking-widest`,children:t.userCode}),(0,J.jsx)(g,{size:`sm`,icon:s?(0,J.jsx)(F,{className:`size-4`}):(0,J.jsx)(ee,{className:`size-4`}),onClick:async()=>{try{await navigator.clipboard.writeText(t.userCode),c(!0),window.setTimeout(()=>c(!1),2e3)}catch{R.error(`Could not copy code`)}},children:s?`Copied`:`Copy code`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`a`,{href:t.verificationUri,target:`_blank`,rel:`noreferrer`,className:v(`primary`),children:[(0,J.jsx)(I,{"aria-hidden":!0,className:`size-4`}),`Open GitHub`]}),(0,J.jsx)(g,{onClick:()=>{n(null),f(null)},children:`Cancel`})]}),(0,J.jsx)(`p`,{className:`text-xs text-subtle`,children:`Waiting for GitHub approval…`})]}):(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsx)(p,{error:d}),(0,J.jsx)(g,{variant:`primary`,busy:l,onClick:_,children:`Sign in with GitHub`})]})})})}function Ae(){let e=b(),t=N(e=>e.status===`authenticated`),n=(0,q.useRef)(null),[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!t)return;if(!n.current){let e=oe();if(!e){o(!0);return}n.current=T(`${Y}/complete`,e)}let r=!0;return n.current.then(({connection:t})=>{r&&(R.success(`Connected GitHub as ${t.account}`),t.state===`ready`?e(X,{replace:!0}):i(t))},()=>{r&&o(!0)}),()=>{r=!1}},[t,e]),(0,J.jsx)(z,{title:`Connect GitHub`,back:ye,children:r?(0,J.jsx)(W,{children:(0,J.jsx)(Oe,{connection:r,onReady:()=>e(X,{replace:!0})})}):a?(0,J.jsxs)(W,{title:`Could not complete GitHub sign-in`,children:[(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`This sign-in expired or was cancelled. Try connecting GitHub again from this device.`}),(0,J.jsx)(`div`,{children:(0,J.jsx)(h,{className:v(`primary`),to:Z,replace:!0,children:`Try again`})})]}):(0,J.jsx)(m,{label:`Connecting GitHub…`})})}function je(e,t,n){let r=new Set(e);return n?r.add(t):r.delete(t),r}function Me({connectionId:e,initialSelection:n,onSaved:r,onCancel:i}){let[a,o]=(0,q.useState)(null),[s,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(null),[d,f]=(0,q.useState)(!1),[h,v]=(0,q.useState)(``),[y,b]=(0,q.useState)(()=>new Set(n?.owners??[])),[x,S]=(0,q.useState)(()=>new Set(n?.repositories??[])),[C,w]=(0,q.useState)(0),T=(0,q.useCallback)(()=>w(e=>e+1),[]);(0,q.useEffect)(()=>{let n=new AbortController;return o(null),c(null),t(`${Y}/${encodeURIComponent(e)}/available`,void 0,n.signal).then(e=>{n.signal.aborted||o(e)},e=>{n.signal.aborted||c(e)}),()=>n.abort()},[e,C]);let E=h.trim().toLowerCase(),D=(0,q.useMemo)(()=>a?E?a.owners.filter(e=>e.login.toLowerCase().includes(E)||a.repositories.some(t=>t.owner.toLowerCase()===e.login.toLowerCase()&&`${t.owner}/${t.name}`.toLowerCase().includes(E))):a.owners:[],[a,E]),O=(0,q.useMemo)(()=>{if(!a)return[];let e=[...a.repositories].sort((e,t)=>`${e.owner}/${e.name}`.localeCompare(`${t.owner}/${t.name}`));return E?e.filter(e=>`${e.owner}/${e.name}`.toLowerCase().includes(E)):e},[a,E]),k=async()=>{if(!d){f(!0),u(null);try{await _(`${Y}/${encodeURIComponent(e)}/selection`,{selection:{owners:[...y],repositories:[...x]}}),r()}catch(e){u(e)}finally{f(!1)}}};if(!a&&!s)return(0,J.jsx)(m,{label:`Loading accessible organizations and repositories…`});if(s)return(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsx)(p,{error:s}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsx)(g,{size:`sm`,onClick:T,children:`Retry`}),i&&(0,J.jsx)(g,{size:`sm`,variant:`ghost`,onClick:i,children:`Cancel`})]})]});if(!a)return null;let A=O.slice(0,200);return(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(ne,{"aria-hidden":!0,className:`pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-subtle`}),(0,J.jsx)(L,{type:`search`,"aria-label":`Search organizations or repositories`,placeholder:`Search organizations or repositories`,value:h,onChange:e=>v(e.target.value),className:`pl-8`})]}),(0,J.jsxs)(`p`,{className:`text-xs text-muted`,children:[y.size,` organization`,y.size===1?``:`s`,` and `,x.size,` individual repositor`,x.size===1?`y`:`ies`,` selected.`]}),D.length>0&&(0,J.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,J.jsx)(`legend`,{className:`text-sm font-medium`,children:`Organizations & accounts`}),(0,J.jsx)(`p`,{className:`text-xs text-muted`,children:`Checking an account includes all repositories in it.`}),(0,J.jsx)(`div`,{className:`max-h-44 divide-y divide-border overflow-y-auto rounded-lg border border-border bg-surface-2/40`,children:D.map(e=>(0,J.jsx)(`div`,{className:`px-3 py-2`,children:(0,J.jsx)(K,{label:(0,J.jsxs)(`span`,{children:[e.login,` `,(0,J.jsxs)(`span`,{className:`text-xs text-muted`,children:[`(`,e.type,`)`]})]}),checked:y.has(e.login),onChange:t=>b(n=>je(n,e.login,t))})},e.login))})]}),(0,J.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,J.jsx)(`legend`,{className:`text-sm font-medium`,children:`Repositories`}),A.length===0?(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:a.repositories.length===0?`No accessible repositories returned by this token.`:`No repositories match your search.`}):(0,J.jsxs)(`div`,{className:`max-h-64 divide-y divide-border overflow-y-auto rounded-lg border border-border bg-surface-2/40`,children:[A.map(e=>{let t=`${e.owner}/${e.name}`,n=y.has(e.owner);return(0,J.jsx)(`div`,{className:`px-3 py-2`,children:(0,J.jsx)(K,{label:(0,J.jsxs)(`span`,{children:[t,n&&(0,J.jsxs)(`span`,{className:`ml-1.5 text-xs text-muted`,children:[`(via `,e.owner,`)`]})]}),checked:x.has(t),onChange:e=>S(n=>je(n,t,e))})},e.externalId)}),O.length>A.length&&(0,J.jsxs)(`p`,{className:`px-3 py-2 text-xs text-muted`,children:[`Showing first `,A.length,` of `,O.length,` matches. Search to narrow the list.`]})]})]}),(0,J.jsx)(p,{error:l}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 border-t border-border pt-4`,children:[i&&(0,J.jsx)(g,{disabled:d,onClick:i,children:`Cancel`}),(0,J.jsx)(g,{variant:`primary`,busy:d,onClick:()=>void k(),children:`Save selection`})]})]})}function Ne(){let e=b(),[t,n]=(0,q.useState)(``),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(null),[s,c]=(0,q.useState)(null),l=async e=>{if(e.preventDefault(),r)return;let a=t.trim();if(a.length<10)o(Error(`Paste a valid GitHub Personal Access Token.`));else{i(!0),o(null);try{let e=await T(`${Y}/pat`,{token:a});n(``),R.success(`Connected GitHub as ${e.connection.account}`),c(e.connection)}catch(e){o(e)}finally{i(!1)}}};return(0,J.jsx)(z,{title:s?`Choose repositories · ${s.account}`:`Connect with Personal Access Token`,description:s?`Choose which organizations and individual repositories to include in Switchyard.`:`Use a Classic or Fine-Grained Personal Access Token to access work organizations without installing an app.`,back:ye,children:(0,J.jsx)(W,{children:s?(0,J.jsx)(Me,{connectionId:s.id,initialSelection:s.selection,onSaved:()=>{R.success(`Repositories updated`),e(X,{replace:!0})},onCancel:()=>e(X,{replace:!0})}):(0,J.jsxs)(`form`,{className:`max-w-xl space-y-5`,onSubmit:e=>void l(e),children:[(0,J.jsxs)(`div`,{className:`space-y-2.5 rounded-lg border border-border bg-surface-2/50 p-3.5`,children:[(0,J.jsxs)(`p`,{className:`text-sm text-muted`,children:[`Classic PATs need `,(0,J.jsx)(`code`,{className:`text-xs`,children:`repo`}),`,`,` `,(0,J.jsx)(`code`,{className:`text-xs`,children:`read:org`}),`, and`,` `,(0,J.jsx)(`code`,{className:`text-xs`,children:`project`}),` scopes. Fine-Grained PATs are also supported.`]}),(0,J.jsx)(`div`,{children:(0,J.jsxs)(`a`,{href:ve,target:`_blank`,rel:`noopener noreferrer`,className:v(`secondary`,`sm`),children:[(0,J.jsx)(I,{"aria-hidden":!0,className:`size-3.5`}),`Create a Classic PAT on GitHub`]})})]}),(0,J.jsx)(U,{label:`Personal access token`,hint:`Your token is stored only on the coordinator.`,children:e=>(0,J.jsx)(L,{...e,type:`password`,autoComplete:`off`,spellCheck:!1,placeholder:`ghp_… or github_pat_…`,value:t,onChange:e=>n(e.target.value)})}),(0,J.jsx)(p,{error:a}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[(0,J.jsx)(g,{type:`submit`,variant:`primary`,busy:r,disabled:!t.trim(),children:`Continue`}),(0,J.jsx)(h,{className:v(`secondary`),to:X,children:`Cancel`})]})]})})})}function Pe({draft:e,errors:t,set:n,connections:r,hosts:i,columns:a}){let o=(0,q.useId)(),{inventory:s}=be(),c=r??s?.connections??[],l=e.board.trim()!==``,u=c.some(t=>t.id===e.connectionId)?e.connectionId:``;return(0,q.useEffect)(()=>{if(r===void 0&&s&&!s.connections.some(t=>t.id===e.connectionId)&&(!e.connectionId||e.connectionId.startsWith(`hst_`))){let t=(s.connections.find(e=>e.state===`ready`)??s.connections[0])?.id??``;t!==e.connectionId&&n(`connectionId`,t)}},[r,s,e.connectionId,n]),(0,J.jsxs)(`div`,{"data-testid":`github-source-form`,className:`flex flex-col gap-3`,children:[(0,J.jsx)(U,{label:`GitHub connection`,hint:c.length===0&&(r!==void 0||s!==null)?(0,J.jsxs)(J.Fragment,{children:[`No GitHub connections yet.`,` `,(0,J.jsx)(H,{to:V(`projects`),variant:`inline`,children:`Connect GitHub in Settings › Projects`}),`.`]}):`Reads issues and moves board cards for this scope.`,error:t.connectionId,children:e=>(0,J.jsxs)(le,{...e,value:u,onChange:e=>n(`connectionId`,e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:`Choose a GitHub connection`}),c.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.account,` (`,e.kind===`pat`?`Personal token`:`GitHub App`,`)`]},e.id))]})}),(0,J.jsx)(U,{label:`GitHub owner`,hint:`An organization or user, such as fieldgoalco.`,error:t.owner,children:t=>(0,J.jsx)(L,{...t,value:e.owner,spellCheck:!1,onChange:e=>n(`owner`,e.target.value)})}),(0,J.jsx)(U,{label:`Repositories`,optional:!0,hint:`One owner/name per line. Leave empty for every repository of the owner.`,error:t.repositories,children:t=>(0,J.jsx)(B,{...t,rows:3,value:e.repositories,spellCheck:!1,onChange:e=>n(`repositories`,e.target.value)})}),(0,J.jsx)(U,{label:`Repositories of other owners`,optional:!0,hint:`One owner/name per line. Their projects join this scope, and issues assigned to you there are tracked too.`,error:t.extraRepositories,children:t=>(0,J.jsx)(B,{...t,rows:2,value:e.extraRepositories,spellCheck:!1,onChange:e=>n(`extraRepositories`,e.target.value)})}),(0,J.jsxs)(`fieldset`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(`legend`,{className:`text-sm font-semibold`,children:`Projects board`}),(0,J.jsx)(U,{label:`Board number`,optional:!0,hint:`A GitHub Projects board of the owner. Needs Projects permission on the selected GitHub connection.`,error:t.board,children:t=>(0,J.jsx)(L,{...t,inputMode:`numeric`,value:e.board,onChange:e=>n(`board`,e.target.value)})}),l&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`datalist`,{id:o,children:a.map(e=>(0,J.jsx)(`option`,{value:e},e))}),(0,J.jsx)(U,{label:`Issues to follow`,hint:`On the board, issues need no assignee.`,children:t=>(0,J.jsxs)(le,{...t,value:e.follow,onChange:e=>n(`follow`,e.target.value),children:[(0,J.jsx)(`option`,{value:`assigned`,children:`Assigned to me`}),(0,J.jsx)(`option`,{value:`board`,children:`Every open issue on the board`})]})}),(0,J.jsx)(U,{label:`Status field`,children:t=>(0,J.jsx)(L,{...t,value:e.statusField,onChange:e=>n(`statusField`,e.target.value)})}),(0,J.jsx)(U,{label:`Column when work starts`,optional:!0,children:t=>(0,J.jsx)(L,{...t,list:o,value:e.onStart,onChange:e=>n(`onStart`,e.target.value)})}),(0,J.jsx)(U,{label:`Column when a pull request opens`,optional:!0,children:t=>(0,J.jsx)(L,{...t,list:o,value:e.onReview,onChange:e=>n(`onReview`,e.target.value)})}),(0,J.jsx)(U,{label:`Backlog columns`,optional:!0,hint:`Cards in these columns are not tracked until they have a branch or pull request. Separate names with commas.`,error:t.backlog,children:t=>(0,J.jsx)(L,{...t,value:e.backlog,onChange:e=>n(`backlog`,e.target.value)})}),(0,J.jsx)(U,{label:`Priority field`,optional:!0,hint:`A single-select field, such as Priority. Not-started issues are listed by it.`,children:t=>(0,J.jsx)(L,{...t,value:e.priorityField,onChange:e=>n(`priorityField`,e.target.value)})}),(0,J.jsx)(G,{label:`Move cards on GitHub`,description:e.follow===`board`?`Cards assigned to you or to nobody, only the status field, and only from the column Switchyard last saw.`:`Only cards assigned to you, only the status field, and only from the column Switchyard last saw.`,checked:e.writeBack,onChange:e=>n(`writeBack`,e)}),e.writeBack&&(0,J.jsx)(G,{label:`Also move cards assigned to others too`,checked:e.moveShared,onChange:e=>n(`moveShared`,e)})]})]}),(0,J.jsx)(G,{label:`Make worktrees for issue branches`,description:`Off: Switchyard only links the worktrees you make and never creates one.`,checked:e.worktrees,onChange:e=>n(`worktrees`,e)}),(0,J.jsx)(G,{label:`Sync this scope`,checked:e.enabled,onChange:e=>n(`enabled`,e)}),(0,J.jsx)(`p`,{className:`text-xs text-muted`,children:`Its projects are the ones in Settings › Projects whose repositories this covers.`})]})}var Fe=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean),$=e=>e.split(`
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{$t as t,Bt as n,D as r,F as i,G as a,It as o,Lt as s,Mt as c,Qt as l,Rt as u,S as d,_ as f,a as p,c as m,cn as h,d as g,en as _,f as v,g as y,gn as b,in as x,m as S,n as C,rn as w,tn as T,v as E,yn as D,z as O}from"./states-BtAXMBKP.js";import{a as k,n as A,t as j,y as M}from"./Overlay-Cfm4AZk1.js";import{s as N}from"./auth-BnOZcMwb.js";import{y as P}from"./preload-helper-B7-Z6Kuc.js";import{a as ee,o as F}from"./SegmentedControl-D6SGXg_K.js";import{t as I}from"./external-link-fqMZHNsZ.js";import{t as te}from"./plus-DEaNWSMA.js";import{t as ne}from"./search-cJqErX2K.js";import{F as re,G as L,K as R,O as z,W as B,ct as ie,j as V,t as ae,u as oe}from"./index-BHIBqflQ.js";import{t as H}from"./TextLink-DWXZwPZa.js";import{r as se,t as U}from"./Field-D4UpWJFx.js";import{n as W,t as ce}from"./RadioCards-DoHz_a-g.js";import{t as le}from"./Select-D41sYIWt.js";import{n as G}from"./Switch-D6hfPoPE.js";import{n as ue}from"./ScopeSelect-DkEghnwv.js";import{t as K}from"./Checkbox-9KyxtvcL.js";var de={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};de.node;var fe=r(de),pe={name:`square-terminal`,size:24,node:[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]],aliases:[`terminal-square`]};pe.node;var me=r(pe),q=e(D(),1),J=S();function he({value:e,min:t,max:n,onChange:r,label:i,pane:a=`before`,step:o=16,onReset:s,orientation:c=`vertical`,className:l}){let u=(0,q.useRef)(null),d=e=>Math.round(Math.min(n,Math.max(t,e))),f=a===`before`?1:-1,p=c===`horizontal`,m=p?`ArrowDown`:`ArrowRight`,h=p?`ArrowUp`:`ArrowLeft`;return(0,J.jsx)(`div`,{role:`separator`,"aria-orientation":c,"aria-label":i,"aria-valuenow":Math.round(e),"aria-valuemin":t,"aria-valuemax":n,tabIndex:0,className:E(`group relative z-10 shrink-0 touch-none select-none`,p?`h-1.5 w-full cursor-row-resize`:`w-1.5 cursor-col-resize`,`focus-visible:outline-none`,l),onPointerDown:t=>{t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),u.current={x:p?t.clientY:t.clientX,value:e}},onPointerMove:e=>{if(!u.current)return;let t=p?e.clientY:e.clientX;r(d(u.current.value+f*(t-u.current.x)))},onPointerUp:e=>{u.current=null,e.currentTarget.releasePointerCapture(e.pointerId)},onPointerCancel:()=>{u.current=null},onDoubleClick:s,onKeyDown:i=>{let a=i.shiftKey?o*4:o;if(i.key===m)r(d(e+f*a));else if(i.key===h)r(d(e-f*a));else if(i.key===`Home`)r(t);else if(i.key===`End`)r(n);else if(i.key===`Enter`&&s)s();else return;i.preventDefault()},children:(0,J.jsx)(`div`,{"aria-hidden":!0,className:E(`absolute bg-border group-hover:bg-accent group-focus-visible:bg-accent`,p?`inset-x-0 top-1/2 h-px -translate-y-1/2 group-hover:h-0.5 group-focus-visible:h-0.5`:`inset-y-0 left-1/2 w-px -translate-x-1/2 group-hover:w-0.5 group-focus-visible:w-0.5`)})})}var Y=`/api/catalog/connections`,X=V(`projects`),Z=V(`projects/connect`),ge=V(`projects/connect/pat`);function _e(e=`github.com`){return`https://${e}/settings/tokens/new?scopes=repo,read:org,project&description=Switchyard`}var ve=_e(),ye={to:X,label:`Projects`};function Q(e){if(e)try{let t=new URL(e);if(t.protocol===`https:`&&!t.username&&!t.password)return t.href}catch{}}function be(){let[e,n]=(0,q.useState)(null),[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(0);return(0,q.useEffect)(()=>{let e=new AbortController;return t(Y,void 0,e.signal).then(t=>{e.signal.aborted||(n(t),i(null))},t=>{e.signal.aborted||(x(t)&&(t.status===404||t.code===`unsupported_capability`)?(n({available:!1,connections:[],conflicts:[]}),i(null)):i(t))}),()=>e.abort()},[a]),(0,q.useEffect)(()=>{let e=window.setInterval(()=>o(e=>e+1),6e4);return()=>window.clearInterval(e)},[]),{inventory:e,error:r,reload:()=>o(e=>e+1)}}function xe(e){return`${e.account} · ${e.kind===`pat`?`Personal token`:`GitHub App`}`}var Se={pending:`Waiting for installation or organization approval`,ready:`Connected`,stale:`Sync failed. Showing the last known repositories.`,suspended:`Installation suspended. Check its status on GitHub.`,removed:`Installation removed on GitHub`,disconnected:`Disconnected from Switchyard`},Ce={ready:`success`,pending:`warning`,stale:`warning`,suspended:`danger`,removed:`danger`,disconnected:`neutral`};function we(e){if(e.kind!==`pat`)return null;let t=e.selection?.owners??[],n=e.selection?.repositories??[],r=[];return t.length>0&&r.push(t.join(`, `)),n.length>0&&r.push(`${n.length} repo${n.length===1?``:`s`}`),r.length>0?r.join(` · `):`No repositories selected yet`}function Te({catalog:{inventory:e,error:t,reload:n},projects:r}){return!e&&!t?(0,J.jsx)(m,{label:`Loading repository connections…`}):(0,J.jsxs)(W,{title:`Repository connections`,description:`Connect with the GitHub App for personal accounts, or add a Personal Access Token for work organizations.`,actions:e?.available&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(h,{to:Z,className:v(`primary`,`sm`),children:[(0,J.jsx)(te,{"aria-hidden":!0,className:`size-3.5`}),`Connect GitHub`]}),(0,J.jsxs)(h,{to:ge,className:v(`secondary`,`sm`),children:[(0,J.jsx)(ie,{"aria-hidden":!0,className:`size-3.5`}),`Add Personal Token`]})]}),children:[t!=null&&(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsx)(p,{error:t}),(0,J.jsx)(g,{size:`sm`,onClick:n,children:`Reload connections`})]}),e&&!e.available&&(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`The repository connector is unavailable. Existing projects show the last known catalog.`}),e?.available&&e.connections.length===0&&(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`No GitHub accounts connected.`}),e&&e.connections.length>0&&(0,J.jsx)(`div`,{className:`divide-y divide-border`,children:e.connections.map(t=>(0,J.jsx)(Ee,{connection:t,available:e.available,reload:n},t.id))}),e?.conflicts.map(t=>(0,J.jsx)(De,{conflict:t,projects:r,disabled:!e.available,reload:n},JSON.stringify([t.connectionId,t.externalId])))]})}function Ee({connection:e,available:t,reload:n}){let[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(null),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1),m=(0,q.useRef)(!1),h=e.kind===`pat`,_=e.state===`disconnected`,b=!h&&!_&&(e.state===`pending`||e.state===`removed`)?Q(e.installUrl):void 0,x=_?void 0:Q(e.manageUrl),S=async t=>{if(!r){i(t),o(null);try{await T(`${Y}/${encodeURIComponent(e.id)}/${t}`),t===`disconnect`&&c(!1)}catch(e){o(e)}finally{n(),i(null)}}};(0,q.useEffect)(()=>{if(!t||_)return;let e=()=>{document.visibilityState===`visible`&&m.current&&(m.current=!1,S(`refresh`))};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}});let C=we(e);return(0,J.jsxs)(`div`,{"data-testid":`catalog-connection-${e.id}`,"data-account":e.account,className:`space-y-3 py-4 first:pt-1 last:pb-1`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1.5`,children:[(0,J.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,J.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e.account}),(0,J.jsx)(M,{tone:`neutral`,children:h?`Personal token`:`GitHub App`}),(0,J.jsx)(`span`,{role:`status`,children:(0,J.jsx)(M,{tone:Ce[e.state],children:Se[e.state]})})]}),e.lastSyncedAt&&(0,J.jsxs)(`span`,{className:`text-xs text-subtle`,children:[`Synced`,` `,(0,J.jsx)(`time`,{dateTime:e.lastSyncedAt,title:f(e.lastSyncedAt),children:y(e.lastSyncedAt)})]})]}),C&&(0,J.jsx)(`p`,{className:`truncate text-xs text-muted`,children:C}),e.lastError&&(0,J.jsx)(`p`,{className:`break-words text-sm text-warning`,children:e.lastError}),b&&(0,J.jsx)(`p`,{className:`text-xs text-muted`,children:`Install the app, select repositories on GitHub, then return here and refresh.`}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-0.5`,children:[b&&(0,J.jsxs)(`a`,{href:b,target:`_blank`,rel:`noopener noreferrer`,className:v(`primary`,`sm`),onClick:()=>{m.current=!0},children:[(0,J.jsx)(I,{"aria-hidden":!0,className:`size-3.5`}),`Install on GitHub`]}),h&&t&&!_&&(0,J.jsx)(g,{size:`sm`,disabled:!!r,onClick:()=>u(!0),children:`Edit repositories`}),x&&!b&&(0,J.jsxs)(`a`,{href:x,target:`_blank`,rel:`noopener noreferrer`,className:v(`secondary`,`sm`),onClick:()=>{m.current=!0},children:[(0,J.jsx)(I,{"aria-hidden":!0,className:`size-3.5`}),h?`Manage token on GitHub`:`Manage repositories on GitHub`]}),t&&!_&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(g,{size:`sm`,icon:(0,J.jsx)(d,{className:`size-3.5`}),busy:r===`refresh`,disabled:r===`disconnect`,onClick:()=>void S(`refresh`),children:e.state===`pending`||b?`Refresh connection`:`Refresh`}),(0,J.jsx)(g,{size:`sm`,variant:`ghost`,className:`ml-auto text-muted hover:text-danger`,disabled:!!r,onClick:()=>{o(null),c(!0)},children:`Disconnect`})]})]}),e.lastError?.startsWith(`Reconnect provider`)&&(0,J.jsx)(H,{to:h?ge:Z,variant:`action`,children:`Reconnect provider`}),!s&&(0,J.jsx)(p,{error:a}),(0,J.jsx)(j,{open:s,title:`Disconnect ${e.account}?`,onClose:()=>{r||c(!1)},onConfirm:()=>S(`disconnect`),confirmLabel:`Disconnect`,busy:r===`disconnect`,error:a,children:(0,J.jsx)(`p`,{className:`text-sm`,children:`Repositories shared only by this connection will move to Previous projects. Checkouts and session history will remain.`})}),h&&(0,J.jsx)(A,{open:l,onClose:()=>u(!1),title:`Edit repositories · ${e.account}`,description:`Choose organizations and individual repositories to include in Switchyard.`,children:(0,J.jsx)(Me,{connectionId:e.id,initialSelection:e.selection,onSaved:()=>{u(!1),n(),R.success(`Repositories updated`)},onCancel:()=>u(!1)})})]})}function De({conflict:e,projects:t,disabled:n,reload:r}){let i=(0,q.useId)(),[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(null),d=e.projectIds.filter(e=>t.some(t=>t.id===e));return(0,J.jsxs)(`form`,{className:`space-y-2 border-t border-border pt-3`,onSubmit:async t=>{if(t.preventDefault(),!(s||n||!d.includes(a))){c(!0),u(null);try{await T(`${Y}/${encodeURIComponent(e.connectionId)}/resolve-history`,{externalId:e.externalId,projectId:a}),r(),R.success(`Existing history selected`)}catch(e){u(e)}finally{c(!1)}}},children:[(0,J.jsx)(U,{id:i,label:`Choose existing history`,hint:`More than one previous project matches ${e.fullName}. Choose which history to keep using for this repository. The others remain available separately.`,children:(0,J.jsxs)(le,{id:i,value:d.includes(a)?a:``,disabled:n||s,onChange:e=>o(e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:`Choose a previous project`}),d.map(e=>(0,J.jsxs)(`option`,{value:e,children:[t.find(t=>t.id===e)?.name,` · `,e]},e))]})}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(g,{size:`sm`,type:`submit`,busy:s,disabled:n||!d.includes(a),children:`Use selected history`}),d.includes(a)&&(0,J.jsx)(H,{to:V(`projects/${encodeURIComponent(a)}`),target:`_blank`,rel:`noreferrer`,children:`View selected project`})]}),(0,J.jsx)(p,{error:l})]})}function Oe({connection:e,onReady:t}){let[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(null),o=Q(e.installUrl),s=(0,q.useRef)(!1),c=async()=>{if(!n){r(!0),a(null);try{(await T(`${Y}/${encodeURIComponent(e.id)}/refresh`)).connections.find(t=>t.id===e.id)?.state===`ready`&&(R.success(`GitHub repositories synced`),t())}catch(e){a(e)}finally{r(!1)}}};return(0,q.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&s.current&&c()};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}}),(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Signed in as `,e.account]}),(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`Choose which repositories to share on GitHub. Switchyard syncs them automatically when you return to this tab.`}),(0,J.jsx)(p,{error:i}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[o&&(0,J.jsxs)(`a`,{href:o,target:`_blank`,rel:`noreferrer`,className:v(`primary`),onClick:()=>{s.current=!0},children:[(0,J.jsx)(I,{"aria-hidden":!0,className:`size-4`}),`Choose repositories on GitHub`]}),(0,J.jsx)(g,{size:`sm`,busy:n,onClick:c,children:`Check now`}),(0,J.jsx)(h,{className:v(`secondary`),to:X,replace:!0,children:`Open Projects`})]})]})}function ke(){let e=b(),[t,n]=(0,q.useState)(null),[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(null),h=(0,q.useRef)(!1),_=async()=>{if(!l){u(!0),f(null),i(null);try{let e=await T(`${Y}/begin`,{});if(e.mode===`oauth`){let t=Q(e.authorizeUrl);if(!t)throw Error(`GitHub did not return a valid sign-in URL.`);o(!0),window.location.assign(t);return}let t=Q(e.verificationUri);if(!t)throw Error(`GitHub did not return a valid sign-in URL.`);n({...e,verificationUri:t})}catch(e){f(e)}finally{u(!1)}}};return(0,q.useEffect)(()=>{h.current||(h.current=!0,_())},[]),(0,q.useEffect)(()=>{if(!t||r)return;let a=!0,o,s=r=>{o=window.setTimeout(async()=>{try{let r=await T(`${Y}/poll`,{flowId:t.flowId});if(!a)return;r.status===`complete`?(n(null),R.success(`Connected GitHub as ${r.connection.account}`),r.connection.state===`ready`?e(X,{replace:!0}):i(r.connection)):s(r.interval??t.interval)}catch(e){if(!a)return;f(e),n(null)}},Math.max(1,r)*1e3)};return s(t.interval),()=>{a=!1,o!==void 0&&window.clearTimeout(o)}},[t,r,e]),(0,J.jsx)(z,{title:`Connect GitHub`,description:`Sign in with GitHub once to list repositories across your personal account and organizations.`,back:ye,children:(0,J.jsx)(W,{children:a||l&&!t&&!d?(0,J.jsx)(m,{label:`Redirecting to GitHub…`}):r?(0,J.jsx)(Oe,{connection:r,onReady:()=>e(X,{replace:!0})}):t?(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`Enter this code on GitHub to authorize Switchyard. This page updates automatically once you approve it.`}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,J.jsx)(`code`,{"data-testid":`github-device-code`,className:`rounded-md border border-border bg-surface-2 px-3 py-2 font-mono text-lg font-semibold tracking-widest`,children:t.userCode}),(0,J.jsx)(g,{size:`sm`,icon:s?(0,J.jsx)(F,{className:`size-4`}):(0,J.jsx)(ee,{className:`size-4`}),onClick:async()=>{try{await navigator.clipboard.writeText(t.userCode),c(!0),window.setTimeout(()=>c(!1),2e3)}catch{R.error(`Could not copy code`)}},children:s?`Copied`:`Copy code`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,J.jsxs)(`a`,{href:t.verificationUri,target:`_blank`,rel:`noreferrer`,className:v(`primary`),children:[(0,J.jsx)(I,{"aria-hidden":!0,className:`size-4`}),`Open GitHub`]}),(0,J.jsx)(g,{onClick:()=>{n(null),f(null)},children:`Cancel`})]}),(0,J.jsx)(`p`,{className:`text-xs text-subtle`,children:`Waiting for GitHub approval…`})]}):(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsx)(p,{error:d}),(0,J.jsx)(g,{variant:`primary`,busy:l,onClick:_,children:`Sign in with GitHub`})]})})})}function Ae(){let e=b(),t=N(e=>e.status===`authenticated`),n=(0,q.useRef)(null),[r,i]=(0,q.useState)(null),[a,o]=(0,q.useState)(!1);return(0,q.useEffect)(()=>{if(!t)return;if(!n.current){let e=oe();if(!e){o(!0);return}n.current=T(`${Y}/complete`,e)}let r=!0;return n.current.then(({connection:t})=>{r&&(R.success(`Connected GitHub as ${t.account}`),t.state===`ready`?e(X,{replace:!0}):i(t))},()=>{r&&o(!0)}),()=>{r=!1}},[t,e]),(0,J.jsx)(z,{title:`Connect GitHub`,back:ye,children:r?(0,J.jsx)(W,{children:(0,J.jsx)(Oe,{connection:r,onReady:()=>e(X,{replace:!0})})}):a?(0,J.jsxs)(W,{title:`Could not complete GitHub sign-in`,children:[(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:`This sign-in expired or was cancelled. Try connecting GitHub again from this device.`}),(0,J.jsx)(`div`,{children:(0,J.jsx)(h,{className:v(`primary`),to:Z,replace:!0,children:`Try again`})})]}):(0,J.jsx)(m,{label:`Connecting GitHub…`})})}function je(e,t,n){let r=new Set(e);return n?r.add(t):r.delete(t),r}function Me({connectionId:e,initialSelection:n,onSaved:r,onCancel:i}){let[a,o]=(0,q.useState)(null),[s,c]=(0,q.useState)(null),[l,u]=(0,q.useState)(null),[d,f]=(0,q.useState)(!1),[h,v]=(0,q.useState)(``),[y,b]=(0,q.useState)(()=>new Set(n?.owners??[])),[x,S]=(0,q.useState)(()=>new Set(n?.repositories??[])),[C,w]=(0,q.useState)(0),T=(0,q.useCallback)(()=>w(e=>e+1),[]);(0,q.useEffect)(()=>{let n=new AbortController;return o(null),c(null),t(`${Y}/${encodeURIComponent(e)}/available`,void 0,n.signal).then(e=>{n.signal.aborted||o(e)},e=>{n.signal.aborted||c(e)}),()=>n.abort()},[e,C]);let E=h.trim().toLowerCase(),D=(0,q.useMemo)(()=>a?E?a.owners.filter(e=>e.login.toLowerCase().includes(E)||a.repositories.some(t=>t.owner.toLowerCase()===e.login.toLowerCase()&&`${t.owner}/${t.name}`.toLowerCase().includes(E))):a.owners:[],[a,E]),O=(0,q.useMemo)(()=>{if(!a)return[];let e=[...a.repositories].sort((e,t)=>`${e.owner}/${e.name}`.localeCompare(`${t.owner}/${t.name}`));return E?e.filter(e=>`${e.owner}/${e.name}`.toLowerCase().includes(E)):e},[a,E]),k=async()=>{if(!d){f(!0),u(null);try{await _(`${Y}/${encodeURIComponent(e)}/selection`,{selection:{owners:[...y],repositories:[...x]}}),r()}catch(e){u(e)}finally{f(!1)}}};if(!a&&!s)return(0,J.jsx)(m,{label:`Loading accessible organizations and repositories…`});if(s)return(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsx)(p,{error:s}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,J.jsx)(g,{size:`sm`,onClick:T,children:`Retry`}),i&&(0,J.jsx)(g,{size:`sm`,variant:`ghost`,onClick:i,children:`Cancel`})]})]});if(!a)return null;let A=O.slice(0,200);return(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(ne,{"aria-hidden":!0,className:`pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-subtle`}),(0,J.jsx)(L,{type:`search`,"aria-label":`Search organizations or repositories`,placeholder:`Search organizations or repositories`,value:h,onChange:e=>v(e.target.value),className:`pl-8`})]}),(0,J.jsxs)(`p`,{className:`text-xs text-muted`,children:[y.size,` organization`,y.size===1?``:`s`,` and `,x.size,` individual repositor`,x.size===1?`y`:`ies`,` selected.`]}),D.length>0&&(0,J.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,J.jsx)(`legend`,{className:`text-sm font-medium`,children:`Organizations & accounts`}),(0,J.jsx)(`p`,{className:`text-xs text-muted`,children:`Checking an account includes all repositories in it.`}),(0,J.jsx)(`div`,{className:`max-h-44 divide-y divide-border overflow-y-auto rounded-lg border border-border bg-surface-2/40`,children:D.map(e=>(0,J.jsx)(`div`,{className:`px-3 py-2`,children:(0,J.jsx)(K,{label:(0,J.jsxs)(`span`,{children:[e.login,` `,(0,J.jsxs)(`span`,{className:`text-xs text-muted`,children:[`(`,e.type,`)`]})]}),checked:y.has(e.login),onChange:t=>b(n=>je(n,e.login,t))})},e.login))})]}),(0,J.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,J.jsx)(`legend`,{className:`text-sm font-medium`,children:`Repositories`}),A.length===0?(0,J.jsx)(`p`,{className:`text-sm text-muted`,children:a.repositories.length===0?`No accessible repositories returned by this token.`:`No repositories match your search.`}):(0,J.jsxs)(`div`,{className:`max-h-64 divide-y divide-border overflow-y-auto rounded-lg border border-border bg-surface-2/40`,children:[A.map(e=>{let t=`${e.owner}/${e.name}`,n=y.has(e.owner);return(0,J.jsx)(`div`,{className:`px-3 py-2`,children:(0,J.jsx)(K,{label:(0,J.jsxs)(`span`,{children:[t,n&&(0,J.jsxs)(`span`,{className:`ml-1.5 text-xs text-muted`,children:[`(via `,e.owner,`)`]})]}),checked:x.has(t),onChange:e=>S(n=>je(n,t,e))})},e.externalId)}),O.length>A.length&&(0,J.jsxs)(`p`,{className:`px-3 py-2 text-xs text-muted`,children:[`Showing first `,A.length,` of `,O.length,` matches. Search to narrow the list.`]})]})]}),(0,J.jsx)(p,{error:l}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 border-t border-border pt-4`,children:[i&&(0,J.jsx)(g,{disabled:d,onClick:i,children:`Cancel`}),(0,J.jsx)(g,{variant:`primary`,busy:d,onClick:()=>void k(),children:`Save selection`})]})]})}function Ne(){let e=b(),[t,n]=(0,q.useState)(``),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(null),[s,c]=(0,q.useState)(null),l=async e=>{if(e.preventDefault(),r)return;let a=t.trim();if(a.length<10)o(Error(`Paste a valid GitHub Personal Access Token.`));else{i(!0),o(null);try{let e=await T(`${Y}/pat`,{token:a});n(``),R.success(`Connected GitHub as ${e.connection.account}`),c(e.connection)}catch(e){o(e)}finally{i(!1)}}};return(0,J.jsx)(z,{title:s?`Choose repositories · ${s.account}`:`Connect with Personal Access Token`,description:s?`Choose which organizations and individual repositories to include in Switchyard.`:`Use a Classic or Fine-Grained Personal Access Token to access work organizations without installing an app.`,back:ye,children:(0,J.jsx)(W,{children:s?(0,J.jsx)(Me,{connectionId:s.id,initialSelection:s.selection,onSaved:()=>{R.success(`Repositories updated`),e(X,{replace:!0})},onCancel:()=>e(X,{replace:!0})}):(0,J.jsxs)(`form`,{className:`max-w-xl space-y-5`,onSubmit:e=>void l(e),children:[(0,J.jsxs)(`div`,{className:`space-y-2.5 rounded-lg border border-border bg-surface-2/50 p-3.5`,children:[(0,J.jsxs)(`p`,{className:`text-sm text-muted`,children:[`Classic PATs need `,(0,J.jsx)(`code`,{className:`text-xs`,children:`repo`}),`,`,` `,(0,J.jsx)(`code`,{className:`text-xs`,children:`read:org`}),`, and`,` `,(0,J.jsx)(`code`,{className:`text-xs`,children:`project`}),` scopes. Fine-Grained PATs are also supported.`]}),(0,J.jsx)(`div`,{children:(0,J.jsxs)(`a`,{href:ve,target:`_blank`,rel:`noopener noreferrer`,className:v(`secondary`,`sm`),children:[(0,J.jsx)(I,{"aria-hidden":!0,className:`size-3.5`}),`Create a Classic PAT on GitHub`]})})]}),(0,J.jsx)(U,{label:`Personal access token`,hint:`Your token is stored only on the coordinator.`,children:e=>(0,J.jsx)(L,{...e,type:`password`,autoComplete:`off`,spellCheck:!1,placeholder:`ghp_… or github_pat_…`,value:t,onChange:e=>n(e.target.value)})}),(0,J.jsx)(p,{error:a}),(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[(0,J.jsx)(g,{type:`submit`,variant:`primary`,busy:r,disabled:!t.trim(),children:`Continue`}),(0,J.jsx)(h,{className:v(`secondary`),to:X,children:`Cancel`})]})]})})})}function Pe({draft:e,errors:t,set:n,connections:r,hosts:i,columns:a}){let o=(0,q.useId)(),{inventory:s}=be(),c=r??s?.connections??[],l=e.board.trim()!==``,u=c.some(t=>t.id===e.connectionId)?e.connectionId:``;return(0,q.useEffect)(()=>{if(r===void 0&&s&&!s.connections.some(t=>t.id===e.connectionId)&&(!e.connectionId||e.connectionId.startsWith(`hst_`))){let t=(s.connections.find(e=>e.state===`ready`)??s.connections[0])?.id??``;t!==e.connectionId&&n(`connectionId`,t)}},[r,s,e.connectionId,n]),(0,J.jsxs)(`div`,{"data-testid":`github-source-form`,className:`flex flex-col gap-3`,children:[(0,J.jsx)(U,{label:`GitHub connection`,hint:c.length===0&&(r!==void 0||s!==null)?(0,J.jsxs)(J.Fragment,{children:[`No GitHub connections yet.`,` `,(0,J.jsx)(H,{to:V(`projects`),variant:`inline`,children:`Connect GitHub in Settings › Projects`}),`.`]}):`Reads issues and moves board cards for this scope.`,error:t.connectionId,children:e=>(0,J.jsxs)(le,{...e,value:u,onChange:e=>n(`connectionId`,e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:`Choose a GitHub connection`}),c.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.account,` (`,e.kind===`pat`?`Personal token`:`GitHub App`,`)`]},e.id))]})}),(0,J.jsx)(U,{label:`GitHub owner`,hint:`An organization or user, such as fieldgoalco.`,error:t.owner,children:t=>(0,J.jsx)(L,{...t,value:e.owner,spellCheck:!1,onChange:e=>n(`owner`,e.target.value)})}),(0,J.jsx)(U,{label:`Repositories`,optional:!0,hint:`One owner/name per line. Leave empty for every repository of the owner.`,error:t.repositories,children:t=>(0,J.jsx)(B,{...t,rows:3,value:e.repositories,spellCheck:!1,onChange:e=>n(`repositories`,e.target.value)})}),(0,J.jsx)(U,{label:`Repositories of other owners`,optional:!0,hint:`One owner/name per line. Their projects join this scope, and issues assigned to you there are tracked too.`,error:t.extraRepositories,children:t=>(0,J.jsx)(B,{...t,rows:2,value:e.extraRepositories,spellCheck:!1,onChange:e=>n(`extraRepositories`,e.target.value)})}),(0,J.jsxs)(`fieldset`,{className:`flex flex-col gap-3`,children:[(0,J.jsx)(`legend`,{className:`text-sm font-semibold`,children:`Projects board`}),(0,J.jsx)(U,{label:`Board number`,optional:!0,hint:`A GitHub Projects board of the owner. Needs Projects permission on the selected GitHub connection.`,error:t.board,children:t=>(0,J.jsx)(L,{...t,inputMode:`numeric`,value:e.board,onChange:e=>n(`board`,e.target.value)})}),l&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`datalist`,{id:o,children:a.map(e=>(0,J.jsx)(`option`,{value:e},e))}),(0,J.jsx)(U,{label:`Issues to follow`,hint:`On the board, issues need no assignee.`,children:t=>(0,J.jsxs)(le,{...t,value:e.follow,onChange:e=>n(`follow`,e.target.value),children:[(0,J.jsx)(`option`,{value:`assigned`,children:`Assigned to me`}),(0,J.jsx)(`option`,{value:`board`,children:`Every open issue on the board`})]})}),(0,J.jsx)(U,{label:`Status field`,children:t=>(0,J.jsx)(L,{...t,value:e.statusField,onChange:e=>n(`statusField`,e.target.value)})}),(0,J.jsx)(U,{label:`Column when work starts`,optional:!0,children:t=>(0,J.jsx)(L,{...t,list:o,value:e.onStart,onChange:e=>n(`onStart`,e.target.value)})}),(0,J.jsx)(U,{label:`Column when a pull request opens`,optional:!0,children:t=>(0,J.jsx)(L,{...t,list:o,value:e.onReview,onChange:e=>n(`onReview`,e.target.value)})}),(0,J.jsx)(U,{label:`Backlog columns`,optional:!0,hint:`Cards in these columns are not tracked until they have a branch or pull request. Separate names with commas.`,error:t.backlog,children:t=>(0,J.jsx)(L,{...t,value:e.backlog,onChange:e=>n(`backlog`,e.target.value)})}),(0,J.jsx)(U,{label:`Priority field`,optional:!0,hint:`A single-select field, such as Priority. Not-started issues are listed by it.`,children:t=>(0,J.jsx)(L,{...t,value:e.priorityField,onChange:e=>n(`priorityField`,e.target.value)})}),(0,J.jsx)(G,{label:`Move cards on GitHub`,description:e.follow===`board`?`Cards assigned to you or to nobody, only the status field, and only from the column Switchyard last saw.`:`Only cards assigned to you, only the status field, and only from the column Switchyard last saw.`,checked:e.writeBack,onChange:e=>n(`writeBack`,e)}),e.writeBack&&(0,J.jsx)(G,{label:`Also move cards assigned to others too`,checked:e.moveShared,onChange:e=>n(`moveShared`,e)})]})]}),(0,J.jsx)(G,{label:`Make worktrees for issue branches`,description:`Off: Switchyard only links the worktrees you make and never creates one.`,checked:e.worktrees,onChange:e=>n(`worktrees`,e)}),(0,J.jsx)(G,{label:`Sync this scope`,checked:e.enabled,onChange:e=>n(`enabled`,e)}),(0,J.jsx)(`p`,{className:`text-xs text-muted`,children:`Its projects are the ones in Settings › Projects whose repositories this covers.`})]})}var Fe=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean),$=e=>e.split(`
2
2
  `).map(e=>e.trim()).filter(Boolean);function Ie(e,t=``){let n=e?.source??null;return n?{name:e?.name??``,connectionId:n.connectionId??t,owner:n.owner,repositories:(n.repositories??[]).join(`
3
3
  `),extraRepositories:(n.extraRepositories??[]).join(`
4
- `),board:n.board?String(n.board.projectNumber):``,statusField:n.board?.statusField??`Status`,onStart:n.board?.onStart??``,onReview:n.board?.onReview??``,follow:s(n),backlog:o(n).join(`, `),priorityField:n.board?.priorityField??``,writeBack:n.writeBack,moveShared:n.moveShared,worktrees:u(n),enabled:n.enabled}:{name:e?.name??``,connectionId:t,owner:``,repositories:``,extraRepositories:``,board:``,statusField:`Status`,onStart:``,onReview:``,follow:`assigned`,backlog:``,priorityField:``,writeBack:!1,moveShared:!0,worktrees:!0,enabled:!0}}function Le(e){let t={},r=e.name.trim();r?r.length>60&&(t.name=`Use 60 characters or fewer.`):t.name=`Enter a name.`,e.connectionId||(t.connectionId=`Choose a GitHub connection.`),c.safeParse(e.owner.trim()).success||(t.owner=`Enter a GitHub organization or user name.`),$(e.repositories).some(e=>!n.safeParse(e).success)&&(t.repositories=`Use owner/name, one per line.`);let i=$(e.extraRepositories);i.some(e=>!n.safeParse(e).success)?t.extraRepositories=`Use owner/name, one per line.`:i.length>20&&(t.extraRepositories=`Use 20 repositories or fewer.`);let a=e.board.trim();return a&&!/^[1-9][0-9]*$/.test(a)&&(t.board=`Enter the board's number, as in its URL.`),Fe(e.backlog).length>20&&(t.backlog=`Use 20 columns or fewer.`),t}function Re(e){let t=$(e.repositories),n=e.board.trim(),r={connectionId:e.connectionId,owner:e.owner.trim(),repositories:t.length?t:null,extraRepositories:$(e.extraRepositories),board:n?{projectNumber:Number(n),statusField:e.statusField.trim()||`Status`,onStart:e.onStart.trim()||null,onReview:e.onReview.trim()||null,backlog:Fe(e.backlog),priorityField:e.priorityField.trim()||null}:null,follow:n?e.follow:`assigned`,writeBack:n?e.writeBack:!1,moveShared:e.moveShared,worktrees:e.worktrees,enabled:e.enabled};return{name:e.name.trim(),source:r}}function ze(e,t){let n=(()=>{if(!e.writeBack||!e.board)return`Off`;let t=[e.board.onStart?`To "${e.board.onStart}" when work starts`:null,e.board.onReview?`${e.board.onStart?`to`:`To`} "${e.board.onReview}" when a pull request opens`:null].filter(e=>!!e);return t.length===0?`On, but no columns are set`:`${t.join(`, `)}${e.moveShared?``:`; never shared cards`}`})(),r=t?e.login?`${t}, signed in as ${e.login}`:`${t}, not synced yet`:e.login?`Signed in as ${e.login}`:e.connectionId?`${e.connectionId}, not synced yet`:`Not connected (select a GitHub connection)`,i=[[`GitHub`,`${e.owner}${e.repositories?`: ${e.repositories.join(`, `)}`:` (all repositories)`}${e.extraRepositories?.length?`, plus ${e.extraRepositories.join(`, `)}`:``}`],[`Connection`,r]];return e.board&&(i.push([`Board`,`#${e.board.projectNumber}, field ${e.board.statusField}${e.board.priorityField?`, priority ${e.board.priorityField}`:``}${o(e).length?`; hides ${o(e).join(`, `)} until started`:``}`]),i.push([`Moves cards`,n])),i}var Be=[{value:`projects`,label:`Projects you choose`,explanation:`Sessions in the projects you check, plus any session you pin.`},{value:`pins`,label:`Pins only`,explanation:`Only the sessions you pin to it.`},{value:`github`,label:`GitHub issues`,explanation:`Issues assigned to you or on a Projects board, and the sessions working on them.`}];function Ve(e){return e?.source?`github`:e?.mode===`pinned`?`pins`:`projects`}function He(e,t){return{name:e?.name??``,contents:Ve(e),projectIds:e?.projectIds??[],hostIds:e?.hostIds??[],github:Ie(e,t)}}function Ue(e){let t=Le({...e.github,name:e.name});return e.contents===`github`?t:t.name?{name:t.name}:{}}function We(e,t){let n=e.name.trim(),r=e.hostIds.length?e.hostIds:null;return e.contents===`github`?{name:n,mode:`all`,hostIds:r,source:Re({...e.github,name:n}).source}:{name:n,mode:e.contents===`pins`?`pinned`:`all`,projectIds:e.projectIds.length?e.projectIds:null,hostIds:r,...t?.source?{source:null}:{}}}function Ge(e,t){return!!t?.source&&e.contents!==`github`}function Ke({scope:e,describe:t,onNavigate:n}){let r=a(e=>e.clients),i=a(e=>e.hosts),o=P(e,Object.values(r),i),s=e.name.trim().replace(/\s+/g,`-`);return(0,J.jsxs)(`dl`,{"data-testid":`scope-about`,className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 rounded-md bg-surface-2 px-3 py-2 text-sm`,children:[(0,J.jsx)(`dt`,{className:`text-muted`,children:`Contains`}),(0,J.jsx)(`dd`,{className:`min-w-0`,children:t(e)}),(0,J.jsx)(`dt`,{className:`text-muted`,children:`Mirrored in`}),(0,J.jsxs)(`dd`,{className:`flex min-w-0 flex-col gap-0.5`,children:[o??(0,J.jsx)(`span`,{children:`No client.`}),!o&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`text-muted`,children:[`To mirror it in herdr, choose it in`,` `,(0,J.jsx)(H,{to:ae.settings(`clients`),onClick:n,children:`Settings › Clients`}),`, or run:`]}),(0,J.jsxs)(`code`,{className:`block break-all text-xs`,children:[`switchyard clients bind herdr:`,s,` --scope `,e.name]})]})]})]})}function qe(e,t,n){return n?[...e,t]:e.filter(e=>e!==t)}function Je({editing:e,onClose:t,onSaved:n}){let{scopes:r,describe:o}=ue(),s=O(),c=i(),{inventory:u}=be(),d=u?.connections??[],f=a(e=>e.issues),p=(d.find(e=>e.state===`ready`)??d[0])?.id??``,m=e&&e!==`new`?r[e]??null:null,h=e??`closed`,[v,y]=(0,q.useState)(null),[b,S]=(0,q.useState)(()=>He(null,p)),[E,D]=(0,q.useState)({}),[k,M]=(0,q.useState)(!1),[N,P]=(0,q.useState)(null),[ee,F]=(0,q.useState)(!1);v!==h&&(y(h),S(He(m,p)),D({}),P(null),F(!1));let I=(0,q.useMemo)(()=>m?Object.values(f).find(e=>e.scopeId===m.id&&e.board)?.board?.options.map(e=>e.name)??[]:[],[f,m]),te=(e,t)=>S(n=>({...n,github:{...n.github,[e]:t}})),ne=async()=>{let e=Ue(b);if(D(e),Object.keys(e).length>0)return;M(!0),P(null);let r=We(b,m);try{let e=m?await _(`/api/scopes/${encodeURIComponent(m.id)}`,r):await T(`/api/scopes`,r);R.success(`Scope ${e.name} saved`),n(e.id),t()}catch(e){P(e)}finally{M(!1)}},re=async()=>{if(m){M(!0);try{await l(`/api/scopes/${encodeURIComponent(m.id)}`),R.success(`Scope ${m.name} deleted`),F(!1),t()}catch(e){P(e)}finally{M(!1)}}},z=x(N,`conflict`)?w(N):null,B=e!==null;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{open:B&&!ee,onClose:t,title:m?`Edit scope`:`New scope`,description:`A scope is a named part of your work, shown on Sessions and the Board.`,footer:(0,J.jsxs)(J.Fragment,{children:[m&&(0,J.jsx)(g,{variant:`danger`,onClick:()=>F(!0),className:`mr-auto`,children:`Delete`}),(0,J.jsx)(g,{onClick:t,children:`Cancel`}),(0,J.jsx)(g,{variant:`primary`,busy:k,disabled:!b.name.trim(),onClick:()=>void ne(),children:Ge(b,m)?`Save and disconnect GitHub`:`Save`})]}),children:(0,J.jsxs)(`div`,{"data-testid":`scope-form`,className:`flex flex-col gap-3`,children:[m&&(0,J.jsx)(Ke,{scope:m,describe:o,onNavigate:t}),(0,J.jsx)(U,{label:`Name`,id:`sy-scope-name`,error:E.name??z,children:e=>(0,J.jsx)(L,{...e,value:b.name,maxLength:60,onChange:e=>S({...b,name:e.target.value})})}),(0,J.jsx)(ce,{legend:`Contains`,columns:1,value:b.contents,options:Be,onChange:e=>S({...b,contents:e})}),Ge(b,m)&&(0,J.jsx)(`p`,{role:`status`,className:`rounded-md border border-border bg-warning-soft px-3 py-2 text-sm`,children:`Saving disconnects GitHub: this scope's issues leave the Board. Its sessions and worktrees stay.`}),b.contents===`projects`&&(0,J.jsxs)(`fieldset`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`legend`,{className:`text-sm font-medium`,children:`Projects (none checked: any)`}),s.map(e=>(0,J.jsx)(K,{label:e.name,checked:b.projectIds.includes(e.id),onChange:t=>S({...b,projectIds:qe(b.projectIds,e.id,t)})},e.id))]}),b.contents===`github`&&(0,J.jsx)(Pe,{draft:b.github,errors:E,set:te,connections:d,columns:I}),b.contents!==`pins`&&!!m?.hostIds?.length&&(0,J.jsxs)(`fieldset`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`legend`,{className:`text-sm font-medium`,children:`Hosts (none checked: any)`}),c.map(e=>(0,J.jsx)(K,{label:e.name,checked:b.hostIds.includes(e.id),onChange:t=>S({...b,hostIds:qe(b.hostIds,e.id,t)})},e.id))]}),N!==null&&!z&&(0,J.jsx)(C,{compact:!0,title:`Could not save`,error:w(N)})]})}),(0,J.jsx)(j,{open:B&&ee,onClose:()=>F(!1),title:`Delete this scope?`,description:`Sessions are not affected. Clients mirroring it then mirror nothing and keep their tabs.${m?.source?` Its issues are removed from the Board.`:``}`,confirmLabel:`Delete scope`,busy:k,error:N,onConfirm:()=>void re()})]})}function Ye({open:e,onOpenChange:t,trigger:n,label:r,side:i=`bottom`,align:a=`start`,initialFocus:o,className:s,fitViewport:c,children:l}){let u=(0,q.useId)(),d=(0,q.useRef)(null),f=(0,q.useRef)(null);k(d,e,()=>t(!1),o);let[p,m]=(0,q.useState)(null);return(0,q.useLayoutEffect)(()=>{if(!e||!c){m(null);return}let t=()=>{let e=f.current?.getBoundingClientRect();if(!e)return;let t=Math.min(288,window.innerWidth-16),n=Math.min(Math.max(e.left,8),window.innerWidth-t-8);m(i===`top`?{position:`fixed`,width:t,left:n,bottom:window.innerHeight-e.top+4,maxHeight:e.top-12}:{position:`fixed`,width:t,left:n,top:e.bottom+4,maxHeight:window.innerHeight-e.bottom-12})};return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e,c,i]),(0,q.useEffect)(()=>{if(!e)return;let n=e=>{let n=e.target;!d.current?.contains(n)&&!f.current?.contains(n)&&t(!1)};return document.addEventListener(`pointerdown`,n),()=>document.removeEventListener(`pointerdown`,n)},[e,t]),(0,J.jsxs)(`div`,{className:`relative inline-flex`,children:[n({ref:f,onClick:()=>t(!e),"aria-haspopup":`dialog`,"aria-expanded":e,"aria-controls":u}),e&&(0,J.jsx)(`div`,{ref:d,id:u,role:`dialog`,"aria-label":r,tabIndex:-1,style:p??void 0,className:E(p?`fixed`:`absolute`,`z-40 max-h-[calc(100dvh-2rem)] max-w-[calc(100vw-1rem)] overflow-y-auto overscroll-contain rounded-lg border border-border bg-surface p-3 shadow-pop`,!p&&(i===`top`?`bottom-full mb-1`:`top-full mt-1`),!p&&(a===`end`?`right-0`:`left-0`),s),children:l})]})}function Xe(e){let t=e.trim();return t?t.length>128||t===`.`||t===`..`||/^\.git$/i.test(t)||/[/\\]/.test(t)||[...t].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127)?`Use one folder name, not a path or .git.`:null:`Enter a folder name.`}function Ze(e,t=!1){return e.revokedAt?`${e.name} was revoked. Enroll it again or choose another host.`:e.connectivity===`connected`?!e.checkoutProvision&&!t?`Update this host agent to prepare checkouts, or attach an existing clone.`:null:`${e.name} is offline. Reconnect it or choose another host.`}function Qe({project:e,host:t,hasCheckout:n,attachFallback:r,onBusyChange:i,onPrepared:o}){let s=(0,q.useId)(),[c,l]=(0,q.useState)(null),[u,d]=(0,q.useState)(``),[f,m]=(0,q.useState)(),[h,_]=(0,q.useState)(null),[v,y]=(0,q.useState)(null),b=(0,q.useRef)(!1),[x,S]=(0,q.useState)(null),[C,w]=(0,q.useState)(!1),E=`/api/projects/${encodeURIComponent(e.id)}/checkouts`;if(!t)return(0,J.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,J.jsx)(`p`,{className:`font-medium`,children:`No checkout yet`}),(0,J.jsxs)(`p`,{className:`text-muted`,children:[`Choose or connect a host to prepare a checkout.`,` `,(0,J.jsx)(H,{to:V(`hosts`),target:`_blank`,rel:`noreferrer`,variant:`action`,children:`Open Hosts`})]})]});let D=Ze(t,n),O=!n&&!t.checkoutRoot,k=u.trim()?Xe(u):null,A=r&&!t.revokedAt&&t.connectivity===`connected`&&!h,j=async e=>{if(!(b.current||D||O&&!h)){b.current=!0,y(`preview`),S(null);try{let n=await T(`${E}/preview`,{hostId:t.id,...e===void 0?{}:{folderName:e}});if(h&&n.path!==h)throw Error(`The checkout destination changed. Inspect the original path on the host before preparing a different checkout.`);l(n),m(e),_(null)}catch(e){S(e)}finally{b.current=!1,y(null)}}},M=async()=>{if(!(b.current||D||!c?.previewId||c.action===`collision`)){b.current=!0,y(`apply`),i?.(!0),S(null);try{let e=await T(`${E}/provision`,{previewId:c.previewId});a.getState().recordPreparedCheckout(e.checkout,e.workspaces),l(null),R.success(`Checkout ready`),o?.()}catch(e){_(c.path),l(null),S(e)}finally{b.current=!1,i?.(!1),y(null)}}};return(0,J.jsxs)(`div`,{className:`min-w-0 space-y-2 rounded-md border border-border p-3 text-sm`,children:[(0,J.jsx)(`p`,{className:`font-medium`,children:n?`Prepare checkout`:`No checkout yet`}),(0,J.jsxs)(`p`,{className:`text-muted`,children:[`Host: `,t.name]}),D&&(0,J.jsx)(`p`,{className:`text-muted`,children:D}),O&&(0,J.jsxs)(`p`,{className:`text-muted`,children:[`Set a`,` `,(0,J.jsx)(H,{to:V(`hosts/${encodeURIComponent(t.id)}`),target:`_blank`,rel:`noreferrer`,children:`checkout location`}),` `,`for this host, or attach an existing clone.`]}),h&&(0,J.jsxs)(`p`,{className:`break-words text-muted`,children:[`Check the checkout status at `,(0,J.jsx)(`span`,{className:`font-mono`,children:h}),` before trying again.`]}),(0,J.jsx)(p,{error:x}),c?(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsxs)(`p`,{className:`break-words`,children:[`Destination: `,(0,J.jsx)(`span`,{className:`font-mono`,children:c.path})]}),c.action===`collision`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{children:`Choose another folder. The existing path will not be changed.`}),(0,J.jsx)(U,{label:`Alternative folder name`,id:s,error:k,children:(0,J.jsx)(L,{id:s,value:u,disabled:!!v,onChange:e=>d(e.target.value),autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,...se(s,{error:k})})}),(0,J.jsx)(g,{disabled:!!D||!!v||!u.trim()||!!k||u.trim()===f,onClick:()=>void j(u.trim()),children:`Preview this folder`})]}):c.previewId?(0,J.jsx)(g,{variant:`primary`,busy:v===`apply`,disabled:!!D,onClick:()=>void M(),children:c.action===`reuse`?`Use existing checkout`:`Clone to ${t.name}`}):(0,J.jsx)(`p`,{children:`Cancel this preview and preview again before preparing this checkout.`}),(0,J.jsx)(g,{size:`sm`,variant:`ghost`,disabled:!!v,onClick:()=>{l(null),d(``),S(null)},children:`Cancel preview`})]}):!D&&(!O||h)?(0,J.jsx)(g,{busy:v===`preview`,onClick:()=>void j(h?f:void 0),children:h?`Check checkout status`:`Preview checkout`}):null,A&&(D||O||!t.checkoutProvision)&&(C?(0,J.jsx)($e,{project:e,host:t,onBusyChange:i,onAttached:()=>{w(!1),o?.()}}):(0,J.jsx)(`div`,{children:(0,J.jsx)(g,{onClick:()=>w(!0),children:`Attach existing checkout`})}))]})}function $e({project:e,host:t,onBusyChange:n,onAttached:r}){let i=(0,q.useId)(),o=(0,q.useRef)(!1),[s,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(null),m=re(s);return(0,J.jsxs)(`form`,{className:`space-y-2`,onSubmit:async i=>{if(i.preventDefault(),!(o.current||m)){o.current=!0,u(!0),n?.(!0),f(null);try{let n=await T(`/api/projects/${encodeURIComponent(e.id)}/checkouts`,{hostId:t.id,path:s.trim()});a.getState().recordPreparedCheckout(n.checkout,n.workspaces),R.success(`Checkout attached`),r()}catch(e){f(e)}finally{u(!1),n?.(!1),o.current=!1}}},children:[(0,J.jsx)(U,{id:i,label:`Checkout path on the host`,hint:`Absolute path to an existing clone of this repository.`,children:(0,J.jsx)(L,{id:i,value:s,className:`font-mono`,onChange:e=>c(e.target.value),autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,...se(i,{hint:!0})})}),(0,J.jsx)(p,{error:d}),(0,J.jsx)(g,{type:`submit`,busy:l,disabled:!!m,children:`Attach checkout`})]})}function et(e){return e.startsWith(`local:`)?`Local only`:e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``)}function tt(e,t){let n=t.trim().toLowerCase();return!n||e.name.toLowerCase().includes(n)||e.repoIdentity.toLowerCase().includes(n)}function nt({value:e}){let t=200,n=new Set,r=()=>(0,J.jsx)(`span`,{children:`More data omitted`});function i(e,a){if(t<=0||(t--,a>8))return r();if(e===null)return`None`;if(typeof e==`string`)return e===``?`Empty text`:e.length>4e3?`${e.slice(0,4e3)}…`:e;if(typeof e==`number`)return Number.isFinite(e)?String(e):`Not available`;if(typeof e==`boolean`)return e?`Yes`:`No`;if(typeof e!=`object`)return`Not available`;let o=Array.isArray(e),s=Object.getPrototypeOf(e);if(!o&&s!==Object.prototype&&s!==null)return`Not available`;if(n.has(e))return r();n.add(e);let c=[];if(o)for(let n=0;n<e.length;n++){if(t<=0){c.push((0,J.jsx)(`li`,{children:r()},`omitted`));break}let o=Object.getOwnPropertyDescriptor(e,String(n));c.push((0,J.jsx)(`li`,{children:i(o&&`value`in o?o.value:void 0,a+1)},n))}else for(let n in e){if(!Object.hasOwn(e,n))continue;if(t<=0){c.push((0,J.jsx)(`div`,{children:r()},`omitted`));break}let o=Object.getOwnPropertyDescriptor(e,n);c.push((0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`dt`,{className:`font-medium break-words`,children:n}),(0,J.jsx)(`dd`,{className:`min-w-0 pl-3`,children:i(o&&`value`in o?o.value:void 0,a+1)})]},n))}return n.delete(e),c.length?o?(0,J.jsx)(`ol`,{className:`min-w-0 list-decimal space-y-1 pl-5`,children:c}):(0,J.jsx)(`dl`,{className:`min-w-0 space-y-1`,children:c}):o?`No items`:`No fields`}return(0,J.jsx)(`div`,{className:`min-w-0 text-xs break-words whitespace-pre-wrap`,children:i(e,0)})}export{fe as _,Ye as a,Z as c,Ne as d,Te as f,me as g,he as h,Qe as i,ke as l,be as m,tt as n,Je as o,xe as p,et as r,ze as s,nt as t,Ae as u};
5
- //# sourceMappingURL=StructuredValue-BjKzgQDM.js.map
4
+ `),board:n.board?String(n.board.projectNumber):``,statusField:n.board?.statusField??`Status`,onStart:n.board?.onStart??``,onReview:n.board?.onReview??``,follow:s(n),backlog:o(n).join(`, `),priorityField:n.board?.priorityField??``,writeBack:n.writeBack,moveShared:n.moveShared,worktrees:u(n),enabled:n.enabled}:{name:e?.name??``,connectionId:t,owner:``,repositories:``,extraRepositories:``,board:``,statusField:`Status`,onStart:``,onReview:``,follow:`assigned`,backlog:``,priorityField:``,writeBack:!1,moveShared:!0,worktrees:!0,enabled:!0}}function Le(e){let t={},r=e.name.trim();r?r.length>60&&(t.name=`Use 60 characters or fewer.`):t.name=`Enter a name.`,e.connectionId||(t.connectionId=`Choose a GitHub connection.`),c.safeParse(e.owner.trim()).success||(t.owner=`Enter a GitHub organization or user name.`),$(e.repositories).some(e=>!n.safeParse(e).success)&&(t.repositories=`Use owner/name, one per line.`);let i=$(e.extraRepositories);i.some(e=>!n.safeParse(e).success)?t.extraRepositories=`Use owner/name, one per line.`:i.length>20&&(t.extraRepositories=`Use 20 repositories or fewer.`);let a=e.board.trim();return a&&!/^[1-9][0-9]*$/.test(a)&&(t.board=`Enter the board's number, as in its URL.`),Fe(e.backlog).length>20&&(t.backlog=`Use 20 columns or fewer.`),t}function Re(e){let t=$(e.repositories),n=e.board.trim(),r={connectionId:e.connectionId,owner:e.owner.trim(),repositories:t.length?t:null,extraRepositories:$(e.extraRepositories),board:n?{projectNumber:Number(n),statusField:e.statusField.trim()||`Status`,onStart:e.onStart.trim()||null,onReview:e.onReview.trim()||null,backlog:Fe(e.backlog),priorityField:e.priorityField.trim()||null}:null,follow:n?e.follow:`assigned`,writeBack:n?e.writeBack:!1,moveShared:e.moveShared,worktrees:e.worktrees,enabled:e.enabled};return{name:e.name.trim(),source:r}}function ze(e,t){let n=(()=>{if(!e.writeBack||!e.board)return`Off`;let t=[e.board.onStart?`To "${e.board.onStart}" when work starts`:null,e.board.onReview?`${e.board.onStart?`to`:`To`} "${e.board.onReview}" when a pull request opens`:null].filter(e=>!!e);return t.length===0?`On, but no columns are set`:`${t.join(`, `)}${e.moveShared?``:`; never shared cards`}`})(),r=t?e.login?`${t}, signed in as ${e.login}`:`${t}, not synced yet`:e.login?`Signed in as ${e.login}`:e.connectionId?`${e.connectionId}, not synced yet`:`Not connected (select a GitHub connection)`,i=[[`GitHub`,`${e.owner}${e.repositories?`: ${e.repositories.join(`, `)}`:` (all repositories)`}${e.extraRepositories?.length?`, plus ${e.extraRepositories.join(`, `)}`:``}`],[`Connection`,r]];return e.board&&(i.push([`Board`,`#${e.board.projectNumber}, field ${e.board.statusField}${e.board.priorityField?`, priority ${e.board.priorityField}`:``}${o(e).length?`; hides ${o(e).join(`, `)} until started`:``}`]),i.push([`Moves cards`,n])),i}var Be=[{value:`projects`,label:`Projects you choose`,explanation:`Sessions in the projects you check, plus any session you pin.`},{value:`pins`,label:`Pins only`,explanation:`Only the sessions you pin to it.`},{value:`github`,label:`GitHub issues`,explanation:`Issues assigned to you or on a Projects board, and the sessions working on them.`}];function Ve(e){return e?.source?`github`:e?.mode===`pinned`?`pins`:`projects`}function He(e,t){return{name:e?.name??``,contents:Ve(e),projectIds:e?.projectIds??[],hostIds:e?.hostIds??[],github:Ie(e,t)}}function Ue(e){let t=Le({...e.github,name:e.name});return e.contents===`github`?t:t.name?{name:t.name}:{}}function We(e,t){let n=e.name.trim(),r=e.hostIds.length?e.hostIds:null;return e.contents===`github`?{name:n,mode:`all`,hostIds:r,source:Re({...e.github,name:n}).source}:{name:n,mode:e.contents===`pins`?`pinned`:`all`,projectIds:e.projectIds.length?e.projectIds:null,hostIds:r,...t?.source?{source:null}:{}}}function Ge(e,t){return!!t?.source&&e.contents!==`github`}function Ke({scope:e,describe:t,onNavigate:n}){let r=a(e=>e.clients),i=a(e=>e.hosts),o=P(e,Object.values(r),i),s=e.name.trim().replace(/\s+/g,`-`);return(0,J.jsxs)(`dl`,{"data-testid":`scope-about`,className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 rounded-md bg-surface-2 px-3 py-2 text-sm`,children:[(0,J.jsx)(`dt`,{className:`text-muted`,children:`Contains`}),(0,J.jsx)(`dd`,{className:`min-w-0`,children:t(e)}),(0,J.jsx)(`dt`,{className:`text-muted`,children:`Mirrored in`}),(0,J.jsxs)(`dd`,{className:`flex min-w-0 flex-col gap-0.5`,children:[o??(0,J.jsx)(`span`,{children:`No client.`}),!o&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`text-muted`,children:[`To mirror it in herdr, choose it in`,` `,(0,J.jsx)(H,{to:ae.settings(`clients`),onClick:n,children:`Settings › Clients`}),`, or run:`]}),(0,J.jsxs)(`code`,{className:`block break-all text-xs`,children:[`switchyard clients bind herdr:`,s,` --scope `,e.name]})]})]})]})}function qe(e,t,n){return n?[...e,t]:e.filter(e=>e!==t)}function Je({editing:e,onClose:t,onSaved:n}){let{scopes:r,describe:o}=ue(),s=O(),c=i(),{inventory:u}=be(),d=u?.connections??[],f=a(e=>e.issues),p=(d.find(e=>e.state===`ready`)??d[0])?.id??``,m=e&&e!==`new`?r[e]??null:null,h=e??`closed`,[v,y]=(0,q.useState)(null),[b,S]=(0,q.useState)(()=>He(null,p)),[E,D]=(0,q.useState)({}),[k,M]=(0,q.useState)(!1),[N,P]=(0,q.useState)(null),[ee,F]=(0,q.useState)(!1);v!==h&&(y(h),S(He(m,p)),D({}),P(null),F(!1));let I=(0,q.useMemo)(()=>m?Object.values(f).find(e=>e.scopeId===m.id&&e.board)?.board?.options.map(e=>e.name)??[]:[],[f,m]),te=(e,t)=>S(n=>({...n,github:{...n.github,[e]:t}})),ne=async()=>{let e=Ue(b);if(D(e),Object.keys(e).length>0)return;M(!0),P(null);let r=We(b,m);try{let e=m?await _(`/api/scopes/${encodeURIComponent(m.id)}`,r):await T(`/api/scopes`,r);R.success(`Scope ${e.name} saved`),n(e.id),t()}catch(e){P(e)}finally{M(!1)}},re=async()=>{if(m){M(!0);try{await l(`/api/scopes/${encodeURIComponent(m.id)}`),R.success(`Scope ${m.name} deleted`),F(!1),t()}catch(e){P(e)}finally{M(!1)}}},z=x(N,`conflict`)?w(N):null,B=e!==null;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(A,{open:B&&!ee,onClose:t,title:m?`Edit scope`:`New scope`,description:`A scope is a named part of your work, shown on Sessions and the Board.`,footer:(0,J.jsxs)(J.Fragment,{children:[m&&(0,J.jsx)(g,{variant:`danger`,onClick:()=>F(!0),className:`mr-auto`,children:`Delete`}),(0,J.jsx)(g,{onClick:t,children:`Cancel`}),(0,J.jsx)(g,{variant:`primary`,busy:k,disabled:!b.name.trim(),onClick:()=>void ne(),children:Ge(b,m)?`Save and disconnect GitHub`:`Save`})]}),children:(0,J.jsxs)(`div`,{"data-testid":`scope-form`,className:`flex flex-col gap-3`,children:[m&&(0,J.jsx)(Ke,{scope:m,describe:o,onNavigate:t}),(0,J.jsx)(U,{label:`Name`,id:`sy-scope-name`,error:E.name??z,children:e=>(0,J.jsx)(L,{...e,value:b.name,maxLength:60,onChange:e=>S({...b,name:e.target.value})})}),(0,J.jsx)(ce,{legend:`Contains`,columns:1,value:b.contents,options:Be,onChange:e=>S({...b,contents:e})}),Ge(b,m)&&(0,J.jsx)(`p`,{role:`status`,className:`rounded-md border border-border bg-warning-soft px-3 py-2 text-sm`,children:`Saving disconnects GitHub: this scope's issues leave the Board. Its sessions and worktrees stay.`}),b.contents===`projects`&&(0,J.jsxs)(`fieldset`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`legend`,{className:`text-sm font-medium`,children:`Projects (none checked: any)`}),s.map(e=>(0,J.jsx)(K,{label:e.name,checked:b.projectIds.includes(e.id),onChange:t=>S({...b,projectIds:qe(b.projectIds,e.id,t)})},e.id))]}),b.contents===`github`&&(0,J.jsx)(Pe,{draft:b.github,errors:E,set:te,connections:d,columns:I}),b.contents!==`pins`&&!!m?.hostIds?.length&&(0,J.jsxs)(`fieldset`,{className:`flex flex-col gap-1`,children:[(0,J.jsx)(`legend`,{className:`text-sm font-medium`,children:`Hosts (none checked: any)`}),c.map(e=>(0,J.jsx)(K,{label:e.name,checked:b.hostIds.includes(e.id),onChange:t=>S({...b,hostIds:qe(b.hostIds,e.id,t)})},e.id))]}),N!==null&&!z&&(0,J.jsx)(C,{compact:!0,title:`Could not save`,error:w(N)})]})}),(0,J.jsx)(j,{open:B&&ee,onClose:()=>F(!1),title:`Delete this scope?`,description:`Sessions are not affected. Clients mirroring it then mirror nothing and keep their tabs.${m?.source?` Its issues are removed from the Board.`:``}`,confirmLabel:`Delete scope`,busy:k,error:N,onConfirm:()=>void re()})]})}function Ye({open:e,onOpenChange:t,trigger:n,label:r,side:i=`bottom`,align:a=`start`,initialFocus:o,className:s,fitViewport:c,children:l}){let u=(0,q.useId)(),d=(0,q.useRef)(null),f=(0,q.useRef)(null);k(d,e,()=>t(!1),o);let[p,m]=(0,q.useState)(null);return(0,q.useLayoutEffect)(()=>{if(!e||!c){m(null);return}let t=()=>{let e=f.current?.getBoundingClientRect();if(!e)return;let t=Math.min(288,window.innerWidth-16),n=Math.min(Math.max(e.left,8),window.innerWidth-t-8);m(i===`top`?{position:`fixed`,width:t,left:n,bottom:window.innerHeight-e.top+4,maxHeight:e.top-12}:{position:`fixed`,width:t,left:n,top:e.bottom+4,maxHeight:window.innerHeight-e.bottom-12})};return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e,c,i]),(0,q.useEffect)(()=>{if(!e)return;let n=e=>{let n=e.target;!d.current?.contains(n)&&!f.current?.contains(n)&&t(!1)};return document.addEventListener(`pointerdown`,n),()=>document.removeEventListener(`pointerdown`,n)},[e,t]),(0,J.jsxs)(`div`,{className:`relative inline-flex max-w-full min-w-0 shrink-0`,children:[n({ref:f,onClick:()=>t(!e),"aria-haspopup":`dialog`,"aria-expanded":e,"aria-controls":u}),e&&(0,J.jsx)(`div`,{ref:d,id:u,role:`dialog`,"aria-label":r,tabIndex:-1,style:p??void 0,className:E(p?`fixed`:`absolute`,`z-40 max-h-[calc(100dvh-2rem)] max-w-[calc(100vw-1rem)] overflow-y-auto overscroll-contain rounded-lg border border-border bg-surface p-3 shadow-pop`,!p&&(i===`top`?`bottom-full mb-1`:`top-full mt-1`),!p&&(a===`end`?`right-0`:`left-0`),s),children:l})]})}function Xe(e){let t=e.trim();return t?t.length>128||t===`.`||t===`..`||/^\.git$/i.test(t)||/[/\\]/.test(t)||[...t].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127)?`Use one folder name, not a path or .git.`:null:`Enter a folder name.`}function Ze(e,t=!1){return e.revokedAt?`${e.name} was revoked. Enroll it again or choose another host.`:e.connectivity===`connected`?!e.checkoutProvision&&!t?`Update this host agent to prepare checkouts, or attach an existing clone.`:null:`${e.name} is offline. Reconnect it or choose another host.`}function Qe({project:e,host:t,hasCheckout:n,attachFallback:r,onBusyChange:i,onPrepared:o}){let s=(0,q.useId)(),[c,l]=(0,q.useState)(null),[u,d]=(0,q.useState)(``),[f,m]=(0,q.useState)(),[h,_]=(0,q.useState)(null),[v,y]=(0,q.useState)(null),b=(0,q.useRef)(!1),[x,S]=(0,q.useState)(null),[C,w]=(0,q.useState)(!1),E=`/api/projects/${encodeURIComponent(e.id)}/checkouts`;if(!t)return(0,J.jsxs)(`div`,{className:`space-y-1 text-sm`,children:[(0,J.jsx)(`p`,{className:`font-medium`,children:`No checkout yet`}),(0,J.jsxs)(`p`,{className:`text-muted`,children:[`Choose or connect a host to prepare a checkout.`,` `,(0,J.jsx)(H,{to:V(`hosts`),target:`_blank`,rel:`noreferrer`,variant:`action`,children:`Open Hosts`})]})]});let D=Ze(t,n),O=!n&&!t.checkoutRoot,k=u.trim()?Xe(u):null,A=r&&!t.revokedAt&&t.connectivity===`connected`&&!h,j=async e=>{if(!(b.current||D||O&&!h)){b.current=!0,y(`preview`),S(null);try{let n=await T(`${E}/preview`,{hostId:t.id,...e===void 0?{}:{folderName:e}});if(h&&n.path!==h)throw Error(`The checkout destination changed. Inspect the original path on the host before preparing a different checkout.`);l(n),m(e),_(null)}catch(e){S(e)}finally{b.current=!1,y(null)}}},M=async()=>{if(!(b.current||D||!c?.previewId||c.action===`collision`)){b.current=!0,y(`apply`),i?.(!0),S(null);try{let e=await T(`${E}/provision`,{previewId:c.previewId});a.getState().recordPreparedCheckout(e.checkout,e.workspaces),l(null),R.success(`Checkout ready`),o?.()}catch(e){_(c.path),l(null),S(e)}finally{b.current=!1,i?.(!1),y(null)}}};return(0,J.jsxs)(`div`,{className:`min-w-0 space-y-2 rounded-md border border-border p-3 text-sm`,children:[(0,J.jsx)(`p`,{className:`font-medium`,children:n?`Prepare checkout`:`No checkout yet`}),(0,J.jsxs)(`p`,{className:`text-muted`,children:[`Host: `,t.name]}),D&&(0,J.jsx)(`p`,{className:`text-muted`,children:D}),O&&(0,J.jsxs)(`p`,{className:`text-muted`,children:[`Set a`,` `,(0,J.jsx)(H,{to:V(`hosts/${encodeURIComponent(t.id)}`),target:`_blank`,rel:`noreferrer`,children:`checkout location`}),` `,`for this host, or attach an existing clone.`]}),h&&(0,J.jsxs)(`p`,{className:`break-words text-muted`,children:[`Check the checkout status at `,(0,J.jsx)(`span`,{className:`font-mono`,children:h}),` before trying again.`]}),(0,J.jsx)(p,{error:x}),c?(0,J.jsxs)(`div`,{className:`space-y-2`,children:[(0,J.jsxs)(`p`,{className:`break-words`,children:[`Destination: `,(0,J.jsx)(`span`,{className:`font-mono`,children:c.path})]}),c.action===`collision`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{children:`Choose another folder. The existing path will not be changed.`}),(0,J.jsx)(U,{label:`Alternative folder name`,id:s,error:k,children:(0,J.jsx)(L,{id:s,value:u,disabled:!!v,onChange:e=>d(e.target.value),autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,...se(s,{error:k})})}),(0,J.jsx)(g,{disabled:!!D||!!v||!u.trim()||!!k||u.trim()===f,onClick:()=>void j(u.trim()),children:`Preview this folder`})]}):c.previewId?(0,J.jsx)(g,{variant:`primary`,busy:v===`apply`,disabled:!!D,onClick:()=>void M(),children:c.action===`reuse`?`Use existing checkout`:`Clone to ${t.name}`}):(0,J.jsx)(`p`,{children:`Cancel this preview and preview again before preparing this checkout.`}),(0,J.jsx)(g,{size:`sm`,variant:`ghost`,disabled:!!v,onClick:()=>{l(null),d(``),S(null)},children:`Cancel preview`})]}):!D&&(!O||h)?(0,J.jsx)(g,{busy:v===`preview`,onClick:()=>void j(h?f:void 0),children:h?`Check checkout status`:`Preview checkout`}):null,A&&(D||O||!t.checkoutProvision)&&(C?(0,J.jsx)($e,{project:e,host:t,onBusyChange:i,onAttached:()=>{w(!1),o?.()}}):(0,J.jsx)(`div`,{children:(0,J.jsx)(g,{onClick:()=>w(!0),children:`Attach existing checkout`})}))]})}function $e({project:e,host:t,onBusyChange:n,onAttached:r}){let i=(0,q.useId)(),o=(0,q.useRef)(!1),[s,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(null),m=re(s);return(0,J.jsxs)(`form`,{className:`space-y-2`,onSubmit:async i=>{if(i.preventDefault(),!(o.current||m)){o.current=!0,u(!0),n?.(!0),f(null);try{let n=await T(`/api/projects/${encodeURIComponent(e.id)}/checkouts`,{hostId:t.id,path:s.trim()});a.getState().recordPreparedCheckout(n.checkout,n.workspaces),R.success(`Checkout attached`),r()}catch(e){f(e)}finally{u(!1),n?.(!1),o.current=!1}}},children:[(0,J.jsx)(U,{id:i,label:`Checkout path on the host`,hint:`Absolute path to an existing clone of this repository.`,children:(0,J.jsx)(L,{id:i,value:s,className:`font-mono`,onChange:e=>c(e.target.value),autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,...se(i,{hint:!0})})}),(0,J.jsx)(p,{error:d}),(0,J.jsx)(g,{type:`submit`,busy:l,disabled:!!m,children:`Attach checkout`})]})}function et(e){return e.startsWith(`local:`)?`Local only`:e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``)}function tt(e,t){let n=t.trim().toLowerCase();return!n||e.name.toLowerCase().includes(n)||e.repoIdentity.toLowerCase().includes(n)}function nt({value:e}){let t=200,n=new Set,r=()=>(0,J.jsx)(`span`,{children:`More data omitted`});function i(e,a){if(t<=0||(t--,a>8))return r();if(e===null)return`None`;if(typeof e==`string`)return e===``?`Empty text`:e.length>4e3?`${e.slice(0,4e3)}…`:e;if(typeof e==`number`)return Number.isFinite(e)?String(e):`Not available`;if(typeof e==`boolean`)return e?`Yes`:`No`;if(typeof e!=`object`)return`Not available`;let o=Array.isArray(e),s=Object.getPrototypeOf(e);if(!o&&s!==Object.prototype&&s!==null)return`Not available`;if(n.has(e))return r();n.add(e);let c=[];if(o)for(let n=0;n<e.length;n++){if(t<=0){c.push((0,J.jsx)(`li`,{children:r()},`omitted`));break}let o=Object.getOwnPropertyDescriptor(e,String(n));c.push((0,J.jsx)(`li`,{children:i(o&&`value`in o?o.value:void 0,a+1)},n))}else for(let n in e){if(!Object.hasOwn(e,n))continue;if(t<=0){c.push((0,J.jsx)(`div`,{children:r()},`omitted`));break}let o=Object.getOwnPropertyDescriptor(e,n);c.push((0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`dt`,{className:`font-medium break-words`,children:n}),(0,J.jsx)(`dd`,{className:`min-w-0 pl-3`,children:i(o&&`value`in o?o.value:void 0,a+1)})]},n))}return n.delete(e),c.length?o?(0,J.jsx)(`ol`,{className:`min-w-0 list-decimal space-y-1 pl-5`,children:c}):(0,J.jsx)(`dl`,{className:`min-w-0 space-y-1`,children:c}):o?`No items`:`No fields`}return(0,J.jsx)(`div`,{className:`min-w-0 text-xs break-words whitespace-pre-wrap`,children:i(e,0)})}export{fe as _,Ye as a,Z as c,Ne as d,Te as f,me as g,he as h,Qe as i,ke as l,be as m,tt as n,Je as o,xe as p,et as r,ze as s,nt as t,Ae as u};
5
+ //# sourceMappingURL=StructuredValue-aIPp-NIc.js.map