@shepai/cli 1.103.1 → 1.104.0-pr299.a2cc06c

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 (215) hide show
  1. package/dist/packages/core/src/application/use-cases/upgrade/upgrade-cli.use-case.d.ts +27 -0
  2. package/dist/packages/core/src/application/use-cases/upgrade/upgrade-cli.use-case.d.ts.map +1 -0
  3. package/dist/packages/core/src/application/use-cases/upgrade/upgrade-cli.use-case.js +128 -0
  4. package/dist/packages/core/src/infrastructure/di/container.d.ts.map +1 -1
  5. package/dist/packages/core/src/infrastructure/di/container.js +5 -0
  6. package/dist/packages/core/src/infrastructure/services/agents/common/executors/dev-executor.service.d.ts.map +1 -1
  7. package/dist/packages/core/src/infrastructure/services/agents/common/executors/dev-executor.service.js +5 -3
  8. package/dist/packages/core/src/infrastructure/services/agents/sessions/claude-code-session.repository.js +1 -1
  9. package/dist/packages/core/src/infrastructure/services/deployment/deployment.service.d.ts +1 -1
  10. package/dist/packages/core/src/infrastructure/services/deployment/deployment.service.d.ts.map +1 -1
  11. package/dist/packages/core/src/infrastructure/services/deployment/deployment.service.js +8 -7
  12. package/dist/packages/core/src/infrastructure/services/ide-launchers/json-driven-ide-launcher.service.d.ts.map +1 -1
  13. package/dist/packages/core/src/infrastructure/services/ide-launchers/json-driven-ide-launcher.service.js +6 -8
  14. package/dist/packages/core/src/infrastructure/services/process/tree-kill.d.ts +12 -0
  15. package/dist/packages/core/src/infrastructure/services/process/tree-kill.d.ts.map +1 -0
  16. package/dist/packages/core/src/infrastructure/services/process/tree-kill.js +11 -0
  17. package/dist/packages/core/src/infrastructure/services/spec/spec-initializer.service.js +1 -1
  18. package/dist/packages/core/src/infrastructure/services/tool-installer/binary-exists.d.ts +25 -0
  19. package/dist/packages/core/src/infrastructure/services/tool-installer/binary-exists.d.ts.map +1 -0
  20. package/dist/packages/core/src/infrastructure/services/tool-installer/binary-exists.js +32 -0
  21. package/dist/packages/core/src/infrastructure/services/tool-installer/tool-installer.service.d.ts.map +1 -1
  22. package/dist/packages/core/src/infrastructure/services/tool-installer/tool-installer.service.js +4 -27
  23. package/dist/packages/core/src/infrastructure/services/tool-installer/tools/alacritty.json +3 -2
  24. package/dist/packages/core/src/infrastructure/services/tool-installer/tools/claude-code.json +3 -2
  25. package/dist/packages/core/src/infrastructure/services/tool-installer/tools/cursor-cli.json +3 -2
  26. package/dist/packages/core/src/infrastructure/services/tool-installer/tools/cursor.json +2 -1
  27. package/dist/packages/core/src/infrastructure/services/tool-installer/tools/gh.json +2 -1
  28. package/dist/packages/core/src/infrastructure/services/tool-installer/tools/git.json +2 -1
  29. package/dist/packages/core/src/infrastructure/services/tool-installer/tools/vscode.json +2 -1
  30. package/dist/packages/core/src/infrastructure/services/tool-installer/tools/warp.json +3 -2
  31. package/dist/packages/core/src/infrastructure/services/tool-installer/tools/windsurf.json +3 -2
  32. package/dist/packages/core/src/infrastructure/services/tool-installer/tools/zed.json +3 -2
  33. package/dist/src/presentation/cli/commands/daemon/start-daemon.d.ts.map +1 -1
  34. package/dist/src/presentation/cli/commands/daemon/start-daemon.js +1 -0
  35. package/dist/src/presentation/cli/commands/daemon/stop-daemon.d.ts.map +1 -1
  36. package/dist/src/presentation/cli/commands/daemon/stop-daemon.js +5 -4
  37. package/dist/src/presentation/cli/ui/symbols.d.ts +1 -1
  38. package/dist/src/presentation/web/app/actions/deploy-repository.d.ts.map +1 -1
  39. package/dist/src/presentation/web/app/actions/deploy-repository.js +2 -1
  40. package/dist/src/presentation/web/app/actions/open-folder.d.ts.map +1 -1
  41. package/dist/src/presentation/web/app/actions/open-folder.js +4 -2
  42. package/dist/src/presentation/web/app/actions/open-ide.d.ts.map +1 -1
  43. package/dist/src/presentation/web/app/actions/open-ide.js +2 -1
  44. package/dist/src/presentation/web/app/actions/open-shell.d.ts.map +1 -1
  45. package/dist/src/presentation/web/app/actions/open-shell.js +4 -2
  46. package/dist/src/presentation/web/app/api/cli-upgrade/route.d.ts +3 -0
  47. package/dist/src/presentation/web/app/api/cli-upgrade/route.d.ts.map +1 -0
  48. package/dist/src/presentation/web/app/api/cli-upgrade/route.js +31 -0
  49. package/dist/src/presentation/web/components/common/control-center-drawer/feature-drawer-client.d.ts.map +1 -1
  50. package/dist/src/presentation/web/components/common/control-center-drawer/feature-drawer-client.js +1 -1
  51. package/dist/src/presentation/web/components/common/feature-drawer-tabs/activity-tab.d.ts.map +1 -1
  52. package/dist/src/presentation/web/components/common/feature-drawer-tabs/activity-tab.js +50 -8
  53. package/dist/src/presentation/web/components/common/feature-drawer-tabs/feature-drawer-tabs.d.ts +4 -1
  54. package/dist/src/presentation/web/components/common/feature-drawer-tabs/feature-drawer-tabs.d.ts.map +1 -1
  55. package/dist/src/presentation/web/components/common/feature-drawer-tabs/feature-drawer-tabs.js +31 -11
  56. package/dist/src/presentation/web/components/common/feature-drawer-tabs/overview-tab.d.ts.map +1 -1
  57. package/dist/src/presentation/web/components/common/feature-drawer-tabs/overview-tab.js +35 -2
  58. package/dist/src/presentation/web/components/common/merge-review/diff-view.js +1 -1
  59. package/dist/src/presentation/web/components/common/version-badge/version-badge.d.ts.map +1 -1
  60. package/dist/src/presentation/web/components/common/version-badge/version-badge.js +6 -2
  61. package/dist/src/presentation/web/components/common/version-badge/version-badge.stories.d.ts +2 -2
  62. package/dist/src/presentation/web/components/common/version-badge/version-badge.stories.d.ts.map +1 -1
  63. package/dist/src/presentation/web/components/common/version-badge/version-badge.stories.js +20 -3
  64. package/dist/src/presentation/web/hooks/use-cli-upgrade.d.ts +11 -0
  65. package/dist/src/presentation/web/hooks/use-cli-upgrade.d.ts.map +1 -0
  66. package/dist/src/presentation/web/hooks/use-cli-upgrade.js +73 -0
  67. package/dist/tsconfig.build.tsbuildinfo +1 -1
  68. package/package.json +3 -1
  69. package/web/.next/BUILD_ID +1 -1
  70. package/web/.next/app-path-routes-manifest.json +1 -0
  71. package/web/.next/build-manifest.json +2 -2
  72. package/web/.next/fallback-build-manifest.json +2 -2
  73. package/web/.next/prerender-manifest.json +3 -3
  74. package/web/.next/required-server-files.js +3 -3
  75. package/web/.next/required-server-files.json +3 -3
  76. package/web/.next/routes-manifest.json +6 -0
  77. package/web/.next/server/app/(dashboard)/@drawer/create/page/server-reference-manifest.json +20 -20
  78. package/web/.next/server/app/(dashboard)/@drawer/create/page.js.nft.json +1 -1
  79. package/web/.next/server/app/(dashboard)/@drawer/create/page_client-reference-manifest.js +1 -1
  80. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page/server-reference-manifest.json +25 -25
  81. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page.js.nft.json +1 -1
  82. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page_client-reference-manifest.js +1 -1
  83. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page/server-reference-manifest.json +25 -25
  84. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page.js.nft.json +1 -1
  85. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page_client-reference-manifest.js +1 -1
  86. package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page/server-reference-manifest.json +18 -18
  87. package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page.js.nft.json +1 -1
  88. package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page_client-reference-manifest.js +1 -1
  89. package/web/.next/server/app/(dashboard)/create/page/server-reference-manifest.json +20 -20
  90. package/web/.next/server/app/(dashboard)/create/page.js.nft.json +1 -1
  91. package/web/.next/server/app/(dashboard)/create/page_client-reference-manifest.js +1 -1
  92. package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page/server-reference-manifest.json +25 -25
  93. package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page.js.nft.json +1 -1
  94. package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page_client-reference-manifest.js +1 -1
  95. package/web/.next/server/app/(dashboard)/feature/[featureId]/page/server-reference-manifest.json +25 -25
  96. package/web/.next/server/app/(dashboard)/feature/[featureId]/page.js.nft.json +1 -1
  97. package/web/.next/server/app/(dashboard)/feature/[featureId]/page_client-reference-manifest.js +1 -1
  98. package/web/.next/server/app/(dashboard)/page/server-reference-manifest.json +18 -18
  99. package/web/.next/server/app/(dashboard)/page.js.nft.json +1 -1
  100. package/web/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
  101. package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page/server-reference-manifest.json +18 -18
  102. package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page.js.nft.json +1 -1
  103. package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page_client-reference-manifest.js +1 -1
  104. package/web/.next/server/app/_global-error.html +2 -2
  105. package/web/.next/server/app/_global-error.rsc +1 -1
  106. package/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  107. package/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  108. package/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  109. package/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  110. package/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  111. package/web/.next/server/app/_not-found/page/server-reference-manifest.json +1 -1
  112. package/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  113. package/web/.next/server/app/api/attachments/preview/route.js.nft.json +1 -1
  114. package/web/.next/server/app/api/cli-upgrade/route/app-paths-manifest.json +3 -0
  115. package/web/.next/server/app/api/cli-upgrade/route/build-manifest.json +11 -0
  116. package/web/.next/server/app/api/cli-upgrade/route/server-reference-manifest.json +4 -0
  117. package/web/.next/server/app/api/cli-upgrade/route.js +6 -0
  118. package/web/.next/server/app/api/cli-upgrade/route.js.map +5 -0
  119. package/web/.next/server/app/api/cli-upgrade/route.js.nft.json +1 -0
  120. package/web/.next/server/app/api/cli-upgrade/route_client-reference-manifest.js +2 -0
  121. package/web/.next/server/app/api/evidence/route.js.nft.json +1 -1
  122. package/web/.next/server/app/settings/page/server-reference-manifest.json +5 -5
  123. package/web/.next/server/app/settings/page.js.nft.json +1 -1
  124. package/web/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  125. package/web/.next/server/app/skills/page/server-reference-manifest.json +6 -6
  126. package/web/.next/server/app/skills/page.js.nft.json +1 -1
  127. package/web/.next/server/app/skills/page_client-reference-manifest.js +1 -1
  128. package/web/.next/server/app/tools/page/server-reference-manifest.json +6 -6
  129. package/web/.next/server/app/tools/page.js.nft.json +1 -1
  130. package/web/.next/server/app/tools/page_client-reference-manifest.js +1 -1
  131. package/web/.next/server/app/version/page/server-reference-manifest.json +1 -1
  132. package/web/.next/server/app/version/page_client-reference-manifest.js +1 -1
  133. package/web/.next/server/app-paths-manifest.json +1 -0
  134. package/web/.next/server/chunks/744ca_web__next-internal_server_app_api_cli-upgrade_route_actions_dc509b52.js +3 -0
  135. package/web/.next/server/chunks/744ca_web__next-internal_server_app_api_cli-upgrade_route_actions_dc509b52.js.map +1 -0
  136. package/web/.next/server/chunks/[root-of-the-server]__d2c18946._.js +11 -0
  137. package/web/.next/server/chunks/[root-of-the-server]__d2c18946._.js.map +1 -0
  138. package/web/.next/server/chunks/[root-of-the-server]__f47bb8a5._.js +1 -1
  139. package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_create-drawer-client_tsx_5e26fc0a._.js +1 -1
  140. package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_create-drawer-client_tsx_5e26fc0a._.js.map +1 -1
  141. package/web/.next/server/chunks/ssr/8ba4b_server_app_(dashboard)_@drawer_repository_[repositoryId]_page_actions_0a7546ed.js +1 -1
  142. package/web/.next/server/chunks/ssr/8ba4b_server_app_(dashboard)_@drawer_repository_[repositoryId]_page_actions_0a7546ed.js.map +1 -1
  143. package/web/.next/server/chunks/ssr/8ba4b_server_app_(dashboard)_repository_[repositoryId]_page_actions_978cbb4c.js +1 -1
  144. package/web/.next/server/chunks/ssr/8ba4b_server_app_(dashboard)_repository_[repositoryId]_page_actions_978cbb4c.js.map +1 -1
  145. package/web/.next/server/chunks/ssr/[root-of-the-server]__11033878._.js +1 -1
  146. package/web/.next/server/chunks/ssr/[root-of-the-server]__11033878._.js.map +1 -1
  147. package/web/.next/server/chunks/ssr/[root-of-the-server]__24dd0927._.js +2 -2
  148. package/web/.next/server/chunks/ssr/[root-of-the-server]__24dd0927._.js.map +1 -1
  149. package/web/.next/server/chunks/ssr/[root-of-the-server]__357d99f9._.js +1 -1
  150. package/web/.next/server/chunks/ssr/[root-of-the-server]__51fc98b0._.js +1 -1
  151. package/web/.next/server/chunks/ssr/[root-of-the-server]__51fc98b0._.js.map +1 -1
  152. package/web/.next/server/chunks/ssr/[root-of-the-server]__57f37786._.js +1 -1
  153. package/web/.next/server/chunks/ssr/[root-of-the-server]__57f37786._.js.map +1 -1
  154. package/web/.next/server/chunks/ssr/[root-of-the-server]__5d87af2e._.js +1 -1
  155. package/web/.next/server/chunks/ssr/[root-of-the-server]__708dcad1._.js +1 -1
  156. package/web/.next/server/chunks/ssr/[root-of-the-server]__708dcad1._.js.map +1 -1
  157. package/web/.next/server/chunks/ssr/[root-of-the-server]__845a9d2a._.js +1 -1
  158. package/web/.next/server/chunks/ssr/[root-of-the-server]__845a9d2a._.js.map +1 -1
  159. package/web/.next/server/chunks/ssr/[root-of-the-server]__89e8a5cc._.js +2 -2
  160. package/web/.next/server/chunks/ssr/[root-of-the-server]__89e8a5cc._.js.map +1 -1
  161. package/web/.next/server/chunks/ssr/[root-of-the-server]__8e002910._.js +1 -1
  162. package/web/.next/server/chunks/ssr/[root-of-the-server]__8e002910._.js.map +1 -1
  163. package/web/.next/server/chunks/ssr/[root-of-the-server]__aad040c0._.js +2 -2
  164. package/web/.next/server/chunks/ssr/[root-of-the-server]__aad040c0._.js.map +1 -1
  165. package/web/.next/server/chunks/ssr/[root-of-the-server]__fdc75809._.js +1 -1
  166. package/web/.next/server/chunks/ssr/[root-of-the-server]__fdc75809._.js.map +1 -1
  167. package/web/.next/server/chunks/ssr/_135edb9c._.js +1 -1
  168. package/web/.next/server/chunks/ssr/_135edb9c._.js.map +1 -1
  169. package/web/.next/server/chunks/ssr/{_82e0cb85._.js → _2e3ec01b._.js} +2 -2
  170. package/web/.next/server/chunks/ssr/{_82e0cb85._.js.map → _2e3ec01b._.js.map} +1 -1
  171. package/web/.next/server/chunks/ssr/{_b3352e34._.js → _4038d4ba._.js} +2 -2
  172. package/web/.next/server/chunks/ssr/{_b3352e34._.js.map → _4038d4ba._.js.map} +1 -1
  173. package/web/.next/server/chunks/ssr/{_23e5ab2c._.js → _606f5d13._.js} +2 -2
  174. package/web/.next/server/chunks/ssr/{_23e5ab2c._.js.map → _606f5d13._.js.map} +1 -1
  175. package/web/.next/server/chunks/ssr/_8dacd1e7._.js +1 -1
  176. package/web/.next/server/chunks/ssr/_8dacd1e7._.js.map +1 -1
  177. package/web/.next/server/chunks/ssr/_cc77a143._.js +1 -1
  178. package/web/.next/server/chunks/ssr/_cc77a143._.js.map +1 -1
  179. package/web/.next/server/chunks/ssr/b1a17_presentation_web_components_features_settings_settings-page-client_tsx_6ed9d5f8._.js +1 -1
  180. package/web/.next/server/chunks/ssr/b1a17_presentation_web_components_features_settings_settings-page-client_tsx_6ed9d5f8._.js.map +1 -1
  181. package/web/.next/server/chunks/ssr/src_presentation_web_7275ce5d._.js +2 -2
  182. package/web/.next/server/chunks/ssr/src_presentation_web_7275ce5d._.js.map +1 -1
  183. package/web/.next/server/chunks/ssr/src_presentation_web_758dfa10._.js +2 -2
  184. package/web/.next/server/chunks/ssr/src_presentation_web_758dfa10._.js.map +1 -1
  185. package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_(dashboard)_page_actions_84803221.js +1 -1
  186. package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_(dashboard)_page_actions_84803221.js.map +1 -1
  187. package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_skills_page_actions_1fa8042e.js +1 -1
  188. package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_skills_page_actions_1fa8042e.js.map +1 -1
  189. package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_tools_page_actions_24684200.js +1 -1
  190. package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_tools_page_actions_24684200.js.map +1 -1
  191. package/web/.next/server/chunks/ssr/src_presentation_web_components_bf50c527._.js +1 -1
  192. package/web/.next/server/chunks/ssr/src_presentation_web_components_de814675._.js +1 -1
  193. package/web/.next/server/chunks/ssr/src_presentation_web_components_e599bb8c._.js +1 -1
  194. package/web/.next/server/chunks/ssr/src_presentation_web_components_e599bb8c._.js.map +1 -1
  195. package/web/.next/server/chunks/ssr/src_presentation_web_components_features_control-center_7ac3562e._.js +1 -1
  196. package/web/.next/server/chunks/ssr/src_presentation_web_components_features_control-center_7ac3562e._.js.map +1 -1
  197. package/web/.next/server/pages/500.html +2 -2
  198. package/web/.next/server/server-reference-manifest.js +1 -1
  199. package/web/.next/server/server-reference-manifest.json +30 -30
  200. package/web/.next/static/chunks/{a0f87e10178f4c0e.js → 04f85d1bb4c9bd9f.js} +1 -1
  201. package/web/.next/static/chunks/{d7cc1b6cf702a840.js → 106f17ea546b4873.js} +2 -2
  202. package/web/.next/static/chunks/{4fd27329675da3a8.js → 3a19191db405a122.js} +1 -1
  203. package/web/.next/static/chunks/3bb35e0689e8b6b7.js +1 -0
  204. package/web/.next/static/chunks/{2e2bbd77e10e036c.js → 57a806a72d427ce2.js} +1 -1
  205. package/web/.next/static/chunks/{2016bacd1f5fcc12.js → 58f603517ee8f671.js} +1 -1
  206. package/web/.next/static/chunks/{396a8b5222dfe0f1.js → 5cd861cac966b22e.js} +1 -1
  207. package/web/.next/static/chunks/{8d98f1d9341e7698.js → 7e08e1d6fc515719.js} +1 -1
  208. package/web/.next/static/chunks/{3e1f5c0f67be293f.js → 9ae5355ecbb986c4.js} +1 -1
  209. package/web/.next/static/chunks/{8b1d0f725365fc83.js → ad4c597b1d9f2868.js} +1 -1
  210. package/web/.next/static/chunks/fe424cb940ac3b65.js +2 -0
  211. package/web/.next/static/chunks/0c1c3c49b2145c9b.js +0 -2
  212. package/web/.next/static/chunks/2a6f05312c4f37ce.js +0 -1
  213. /package/web/.next/static/{7gAZbyat8KbbWMGw1K8nJ → KRcEMJYZ0qHENkXOfvNU-}/_buildManifest.js +0 -0
  214. /package/web/.next/static/{7gAZbyat8KbbWMGw1K8nJ → KRcEMJYZ0qHENkXOfvNU-}/_clientMiddlewareManifest.json +0 -0
  215. /package/web/.next/static/{7gAZbyat8KbbWMGw1K8nJ → KRcEMJYZ0qHENkXOfvNU-}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,17840,e=>{"use strict";var t=e.i(79054),r=e.i(31406),n=e.i(60112),o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),a=o((e,t)=>{var r=Object.defineProperty,n=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),o=(e,t,n)=>{let o;return(o="symbol"!=typeof t?t+"":t)in e?r(e,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[o]=n},a=n((e,t)=>{function r(e,t){e[t]?e[t]++:e[t]=1}function n(e,t){--e[t]||delete e[t]}function a(e,t,r,n){var o=""+t,a=""+r;if(!e&&o>a){var s=o;o=a,a=s}return o+"\x01"+a+"\x01"+(void 0===n?"\0":n)}function s(e,t){return a(e,t.v,t.w,t.name)}t.exports=class{constructor(e){o(this,"_isDirected",!0),o(this,"_isMultigraph",!1),o(this,"_isCompound",!1),o(this,"_label"),o(this,"_defaultNodeLabelFn",()=>{}),o(this,"_defaultEdgeLabelFn",()=>{}),o(this,"_nodes",{}),o(this,"_in",{}),o(this,"_preds",{}),o(this,"_out",{}),o(this,"_sucs",{}),o(this,"_edgeObjs",{}),o(this,"_edgeLabels",{}),o(this,"_nodeCount",0),o(this,"_edgeCount",0),o(this,"_parent"),o(this,"_children"),e&&(this._isDirected=!Object.hasOwn(e,"directed")||e.directed,this._isMultigraph=!!Object.hasOwn(e,"multigraph")&&e.multigraph,this._isCompound=!!Object.hasOwn(e,"compound")&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=e,"function"!=typeof e&&(this._defaultNodeLabelFn=()=>e),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var e=this;return this.nodes().filter(t=>0===Object.keys(e._in[t]).length)}sinks(){var e=this;return this.nodes().filter(t=>0===Object.keys(e._out[t]).length)}setNodes(e,t){var r=arguments,n=this;return e.forEach(function(e){r.length>1?n.setNode(e,t):n.setNode(e)}),this}setNode(e,t){return Object.hasOwn(this._nodes,e)?arguments.length>1&&(this._nodes[e]=t):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount),this}node(e){return this._nodes[e]}hasNode(e){return Object.hasOwn(this._nodes,e)}removeNode(e){var t=this;if(Object.hasOwn(this._nodes,e)){var r=e=>t.removeEdge(t._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(function(e){t.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(r),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(r),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error("Cannot set parent in a non-compound graph");if(void 0===t)t="\0";else{t+="";for(var r=t;void 0!==r;r=this.parent(r))if(r===e)throw Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}parent(e){if(this._isCompound){var t=this._parent[e];if("\0"!==t)return t}}children(e="\0"){if(this._isCompound){var t=this._children[e];if(t)return Object.keys(t)}else{if("\0"===e)return this.nodes();if(this.hasNode(e))return[]}}predecessors(e){var t=this._preds[e];if(t)return Object.keys(t)}successors(e){var t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){var t=this.predecessors(e);if(t){let n=new Set(t);for(var r of this.successors(e))n.add(r);return Array.from(n.values())}}isLeaf(e){return 0===(this.isDirected()?this.successors(e):this.neighbors(e)).length}filterNodes(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var r=this;Object.entries(this._nodes).forEach(function([r,n]){e(r)&&t.setNode(r,n)}),Object.values(this._edgeObjs).forEach(function(e){t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,r.edge(e))});var n={};return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,function e(o){var a=r.parent(o);return void 0===a||t.hasNode(a)?(n[o]=a,a):a in n?n[a]:e(a)}(e))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=e,"function"!=typeof e&&(this._defaultEdgeLabelFn=()=>e),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){var r=this,n=arguments;return e.reduce(function(e,o){return n.length>1?r.setEdge(e,o,t):r.setEdge(e,o),o}),this}setEdge(){var e,t,n,o,s=!1,i=arguments[0];"object"==typeof i&&null!==i&&"v"in i?(e=i.v,t=i.w,n=i.name,2==arguments.length&&(o=arguments[1],s=!0)):(e=i,t=arguments[1],n=arguments[3],arguments.length>2&&(o=arguments[2],s=!0)),e=""+e,t=""+t,void 0!==n&&(n=""+n);var d=a(this._isDirected,e,t,n);if(Object.hasOwn(this._edgeLabels,d))return s&&(this._edgeLabels[d]=o),this;if(void 0!==n&&!this._isMultigraph)throw Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(t),this._edgeLabels[d]=s?o:this._defaultEdgeLabelFn(e,t,n);var l=function(e,t,r,n){var o=""+t,a=""+r;if(!e&&o>a){var s=o;o=a,a=s}var i={v:o,w:a};return n&&(i.name=n),i}(this._isDirected,e,t,n);return e=l.v,t=l.w,Object.freeze(l),this._edgeObjs[d]=l,r(this._preds[t],e),r(this._sucs[e],t),this._in[t][d]=l,this._out[e][d]=l,this._edgeCount++,this}edge(e,t,r){var n=1==arguments.length?s(this._isDirected,arguments[0]):a(this._isDirected,e,t,r);return this._edgeLabels[n]}edgeAsObj(){let e=this.edge(...arguments);return"object"!=typeof e?{label:e}:e}hasEdge(e,t,r){var n=1==arguments.length?s(this._isDirected,arguments[0]):a(this._isDirected,e,t,r);return Object.hasOwn(this._edgeLabels,n)}removeEdge(e,t,r){var o=1==arguments.length?s(this._isDirected,arguments[0]):a(this._isDirected,e,t,r),i=this._edgeObjs[o];return i&&(e=i.v,t=i.w,delete this._edgeLabels[o],delete this._edgeObjs[o],n(this._preds[t],e),n(this._sucs[e],t),delete this._in[t][o],delete this._out[e][o],this._edgeCount--),this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}filterEdges(e,t,r){if(e){var n=Object.values(e);return r?n.filter(function(e){return e.v===t&&e.w===r||e.v===r&&e.w===t}):n}}}}),s=n((e,t)=>{t.exports="3.0.2"}),i=n((e,t)=>{t.exports={Graph:a(),version:s()}}),d=n((e,t)=>{var r=a();t.exports={write:function(e){var t,r,n={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:(t=e).nodes().map(function(e){var r=t.node(e),n=t.parent(e),o={v:e};return void 0!==r&&(o.value=r),void 0!==n&&(o.parent=n),o}),edges:(r=e).edges().map(function(e){var t=r.edge(e),n={v:e.v,w:e.w};return void 0!==e.name&&(n.name=e.name),void 0!==t&&(n.value=t),n})};return void 0!==e.graph()&&(n.value=structuredClone(e.graph())),n},read:function(e){var t=new r(e.options).setGraph(e.value);return e.nodes.forEach(function(e){t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(function(e){t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}}}),l=n((e,t)=>{t.exports=function(e,t,n,o){return function(e,t,r,n){var o={},a=!0,s=0,i=e.nodes(),d=function(e){var t=r(e);o[e.v].distance+t<o[e.w].distance&&(o[e.w]={distance:o[e.v].distance+t,predecessor:e.v},a=!0)},l=function(){i.forEach(function(e){n(e).forEach(function(t){var r=t.v===e?t.v:t.w,n=r===t.v?t.w:t.v;d({v:r,w:n})})})};i.forEach(function(e){o[e]={distance:e===t?0:1/0}});for(var c=i.length,u=1;u<c&&(a=!1,s++,l(),a);u++);if(s===c-1&&(a=!1,l(),a))throw Error("The graph contains a negative weight cycle");return o}(e,String(t),n||r,o||function(t){return e.outEdges(t)})};var r=()=>1}),c=n((e,t)=>{t.exports=function(e){var t,r={},n=[];return e.nodes().forEach(function(o){t=[],function n(o){Object.hasOwn(r,o)||(r[o]=!0,t.push(o),e.successors(o).forEach(n),e.predecessors(o).forEach(n))}(o),t.length&&n.push(t)}),n}}),u=n((e,t)=>{t.exports=class{constructor(){o(this,"_arr",[]),o(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(e){return e.key})}has(e){return Object.hasOwn(this._keyIndices,e)}priority(e){var t=this._keyIndices[e];if(void 0!==t)return this._arr[t].priority}min(){if(0===this.size())throw Error("Queue underflow");return this._arr[0].key}add(e,t){var r=this._keyIndices;if(!Object.hasOwn(r,e=String(e))){var n=this._arr,o=n.length;return r[e]=o,n.push({key:e,priority:t}),this._decrease(o),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){var r=this._keyIndices[e];if(t>this._arr[r].priority)throw Error("New priority is greater than current priority. Key: "+e+" Old: "+this._arr[r].priority+" New: "+t);this._arr[r].priority=t,this._decrease(r)}_heapify(e){var t=this._arr,r=2*e,n=r+1,o=e;r<t.length&&(o=t[r].priority<t[o].priority?r:o,n<t.length&&(o=t[n].priority<t[o].priority?n:o),o!==e&&(this._swap(e,o),this._heapify(o)))}_decrease(e){for(var t,r=this._arr,n=r[e].priority;0!==e&&!(r[t=e>>1].priority<n);)this._swap(e,t),e=t}_swap(e,t){var r=this._arr,n=this._keyIndices,o=r[e],a=r[t];r[e]=a,r[t]=o,n[a.key]=e,n[o.key]=t}}}),h=n((e,t)=>{var r=u();t.exports=function(e,t,o,a){return function(e,t,n,o){var a,s,i={},d=new r,l=function(e){var t=e.v!==a?e.v:e.w,r=i[t],o=n(e),l=s.distance+o;if(o<0)throw Error("dijkstra does not allow negative edge weights. Bad edge: "+e+" Weight: "+o);l<r.distance&&(r.distance=l,r.predecessor=a,d.decrease(t,l))};for(e.nodes().forEach(function(e){var r=e===t?0:1/0;i[e]={distance:r},d.add(e,r)});d.size()>0&&(s=i[a=d.removeMin()]).distance!==1/0;)o(a).forEach(l);return i}(e,String(t),o||n,a||function(t){return e.outEdges(t)})};var n=()=>1}),f=n((e,t)=>{var r=h();t.exports=function(e,t,n){return e.nodes().reduce(function(o,a){return o[a]=r(e,a,t,n),o},{})}}),p=n((e,t)=>{t.exports=function(e,t,r){if(void 0!==e[t].predecessor)throw Error("Invalid source vertex");if(void 0===e[r].predecessor&&r!==t)throw Error("Invalid destination vertex");return{weight:e[r].distance,path:function(e,t,r){for(var n=[],o=r;o!==t;)n.push(o),o=e[o].predecessor;return n.push(t),n.reverse()}(e,t,r)}}}),g=n((e,t)=>{t.exports=function(e){var t=0,r=[],n={},o=[];return e.nodes().forEach(function(a){Object.hasOwn(n,a)||function a(s){var i=n[s]={onStack:!0,lowlink:t,index:t++};if(r.push(s),e.successors(s).forEach(function(e){Object.hasOwn(n,e)?n[e].onStack&&(i.lowlink=Math.min(i.lowlink,n[e].index)):(a(e),i.lowlink=Math.min(i.lowlink,n[e].lowlink))}),i.lowlink===i.index){var d,l=[];do n[d=r.pop()].onStack=!1,l.push(d);while(s!==d)o.push(l)}}(a)}),o}}),m=n((e,t)=>{var r=g();t.exports=function(e){return r(e).filter(function(t){return t.length>1||1===t.length&&e.hasEdge(t[0],t[0])})}}),v=n((e,t)=>{t.exports=function(e,t,n){var o,a,s,i,d;return o=e,a=t||r,s=n||function(t){return e.outEdges(t)},i={},(d=o.nodes()).forEach(function(e){i[e]={},i[e][e]={distance:0},d.forEach(function(t){e!==t&&(i[e][t]={distance:1/0})}),s(e).forEach(function(t){var r=t.v===e?t.w:t.v,n=a(t);i[e][r]={distance:n,predecessor:e}})}),d.forEach(function(e){var t=i[e];d.forEach(function(r){var n=i[r];d.forEach(function(r){var o=n[e],a=t[r],s=n[r],i=o.distance+a.distance;i<s.distance&&(s.distance=i,s.predecessor=a.predecessor)})})}),i};var r=()=>1}),x=n((e,t)=>{function r(e){var t={},r={},o=[];if(e.sinks().forEach(function a(s){if(Object.hasOwn(r,s))throw new n;Object.hasOwn(t,s)||(r[s]=!0,t[s]=!0,e.predecessors(s).forEach(a),delete r[s],o.push(s))}),Object.keys(t).length!==e.nodeCount())throw new n;return o}var n=class extends Error{constructor(){super(...arguments)}};t.exports=r,r.CycleException=n}),b=n((e,t)=>{var r=x();t.exports=function(e){try{r(e)}catch(e){if(e instanceof r.CycleException)return!1;throw e}return!0}}),y=n((e,t)=>{t.exports=function(e,t,r,n,o){Array.isArray(t)||(t=[t]);var a=(e.isDirected()?e.successors:e.neighbors).bind(e),s={};return t.forEach(function(t){if(!e.hasNode(t))throw Error("Graph does not have node: "+t);o=function e(t,r,n,o,a,s,i){return Object.hasOwn(o,r)||(o[r]=!0,n||(i=s(i,r)),a(r).forEach(function(r){i=e(t,r,n,o,a,s,i)}),n&&(i=s(i,r))),i}(e,t,"post"===r,s,a,n,o)}),o}}),w=n((e,t)=>{var r=y();t.exports=function(e,t,n){return r(e,t,n,function(e,t){return e.push(t),e},[])}}),E=n((e,t)=>{var r=w();t.exports=function(e,t){return r(e,t,"post")}}),k=n((e,t)=>{var r=w();t.exports=function(e,t){return r(e,t,"pre")}}),j=n((e,t)=>{var r=a(),n=u();t.exports=function(e,t){var o,a=new r,s={},i=new n;function d(e){var r=e.v===o?e.w:e.v,n=i.priority(r);if(void 0!==n){var a=t(e);a<n&&(s[r]=o,i.decrease(r,a))}}if(0===e.nodeCount())return a;e.nodes().forEach(function(e){i.add(e,1/0),a.setNode(e)}),i.decrease(e.nodes()[0],0);for(var l=!1;i.size()>0;){if(Object.hasOwn(s,o=i.removeMin()))a.setEdge(o,s[o]);else{if(l)throw Error("Input graph is not connected: "+e);l=!0}e.nodeEdges(o).forEach(d)}return a}}),N=n((e,t)=>{var r=h(),n=l();t.exports=function(e,t,o,a){return function(e,t,o,a){if(void 0===o)return r(e,t,o,a);for(var s=!1,i=e.nodes(),d=0;d<i.length;d++){for(var l=a(i[d]),c=0;c<l.length;c++){var u=l[c],h=u.v===i[d]?u.v:u.w,f=h===u.v?u.w:u.v;0>o({v:h,w:f})&&(s=!0)}if(s)return n(e,t,o,a)}return r(e,t,o,a)}(e,t,o,a||function(t){return e.outEdges(t)})}}),C=n((e,t)=>{t.exports={bellmanFord:l(),components:c(),dijkstra:h(),dijkstraAll:f(),extractPath:p(),findCycles:m(),floydWarshall:v(),isAcyclic:b(),postorder:E(),preorder:k(),prim:j(),shortestPaths:N(),reduce:y(),tarjan:g(),topsort:x()}}),_=i();t.exports={Graph:_.Graph,json:d(),alg:C(),version:_.version}}),s=o((e,t)=>{function r(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function n(e,t){if("_next"!==e&&"_prev"!==e)return t}t.exports=class{constructor(){let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return r(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&r(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,r=t._prev;for(;r!==t;)e.push(JSON.stringify(r,n)),r=r._prev;return"["+e.join(", ")+"]"}}}),i=o((e,t)=>{var r=a().Graph,n=s();t.exports=function(e,t){var a,s;let l,c,u,h,f;if(1>=e.nodeCount())return[];let p=(a=e,s=t||o,l=new r,c=0,u=0,a.nodes().forEach(e=>{l.setNode(e,{v:e,in:0,out:0})}),a.edges().forEach(e=>{let t=l.edge(e.v,e.w)||0,r=s(e);l.setEdge(e.v,e.w,t+r),u=Math.max(u,l.node(e.v).out+=r),c=Math.max(c,l.node(e.w).in+=r)}),h=(function(e){let t=[];for(let r=0;r<e;r++)t.push(r);return t})(u+c+3).map(()=>new n),f=c+1,l.nodes().forEach(e=>{d(h,f,l.node(e))}),{graph:l,buckets:h,zeroIdx:f});return(function(e,t,r){let n=[],o=t[t.length-1],a=t[0],s;for(;e.nodeCount();){for(;s=a.dequeue();)i(e,t,r,s);for(;s=o.dequeue();)i(e,t,r,s);if(e.nodeCount()){for(let o=t.length-2;o>0;--o)if(s=t[o].dequeue()){n=n.concat(i(e,t,r,s,!0));break}}}return n})(p.graph,p.buckets,p.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w))};var o=()=>1;function i(e,t,r,n,o){let a=o?[]:void 0;return e.inEdges(n.v).forEach(n=>{let s=e.edge(n),i=e.node(n.v);o&&a.push({v:n.v,w:n.w}),i.out-=s,d(t,r,i)}),e.outEdges(n.v).forEach(n=>{let o=e.edge(n),a=n.w,s=e.node(a);s.in-=o,d(t,r,s)}),e.removeNode(n.v),a}function d(e,t,r){r.out?r.in?e[r.out-r.in+t].enqueue(r):e[e.length-1].enqueue(r):e[0].enqueue(r)}}),d=o((e,t)=>{var r=a().Graph;function n(e,t,r,n){for(var o=n;e.hasNode(o);)o=d(n);return r.dummy=t,e.setNode(o,r),o}t.exports={addBorderNode:function(e,t,r,o){let a={width:0,height:0};return arguments.length>=4&&(a.rank=r,a.order=o),n(e,"border",a,t)},addDummyNode:n,applyWithChunking:o,asNonCompoundGraph:function(e){let t=new r({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(r=>{e.children(r).length||t.setNode(r,e.node(r))}),e.edges().forEach(r=>{t.setEdge(r,e.edge(r))}),t},buildLayerMatrix:function(e){let t=l(s(e)+1).map(()=>[]);return e.nodes().forEach(r=>{let n=e.node(r),o=n.rank;void 0!==o&&(t[o][n.order]=r)}),t},intersectRect:function(e,t){let r,n,o=e.x,a=e.y,s=t.x-o,i=t.y-a,d=e.width/2,l=e.height/2;if(!s&&!i)throw Error("Not possible to find intersection inside of the rectangle");return Math.abs(i)*d>Math.abs(s)*l?(i<0&&(l=-l),r=l*s/i,n=l):(s<0&&(d=-d),r=d,n=d*i/s),{x:o+r,y:a+n}},mapValues:function(e,t){let r=t;return"string"==typeof t&&(r=e=>e[t]),Object.entries(e).reduce((e,[t,n])=>(e[t]=r(n,t),e),{})},maxRank:s,normalizeRanks:function(e){let t=o(Math.min,e.nodes().map(t=>{let r=e.node(t).rank;return void 0===r?Number.MAX_VALUE:r}));e.nodes().forEach(r=>{let n=e.node(r);Object.hasOwn(n,"rank")&&(n.rank-=t)})},notime:function(e,t){return t()},partition:function(e,t){let r={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?r.lhs.push(e):r.rhs.push(e)}),r},pick:function(e,t){let r={};for(let n of t)void 0!==e[n]&&(r[n]=e[n]);return r},predecessorWeights:function(e){let t=e.nodes().map(t=>{let r={};return e.inEdges(t).forEach(t=>{r[t.v]=(r[t.v]||0)+e.edge(t).weight}),r});return c(e.nodes(),t)},range:l,removeEmptyRanks:function(e){let t=o(Math.min,e.nodes().map(t=>e.node(t).rank).filter(e=>void 0!==e)),r=[];e.nodes().forEach(n=>{let o=e.node(n).rank-t;r[o]||(r[o]=[]),r[o].push(n)});let n=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,r)=>{void 0===t&&r%a!=0?--n:void 0!==t&&n&&t.forEach(t=>e.node(t).rank+=n)})},simplify:function(e){let t=new r().setGraph(e.graph());return e.nodes().forEach(r=>t.setNode(r,e.node(r))),e.edges().forEach(r=>{let n=t.edge(r.v,r.w)||{weight:0,minlen:1},o=e.edge(r);t.setEdge(r.v,r.w,{weight:n.weight+o.weight,minlen:Math.max(n.minlen,o.minlen)})}),t},successorWeights:function(e){let t=e.nodes().map(t=>{let r={};return e.outEdges(t).forEach(t=>{r[t.w]=(r[t.w]||0)+e.edge(t).weight}),r});return c(e.nodes(),t)},time:function(e,t){let r=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-r)+"ms")}},uniqueId:d,zipObject:c};function o(e,t){if(!(t.length>65535))return e.apply(null,t);{let r=function(e,t=65535){let r=[];for(let n=0;n<e.length;n+=t){let o=e.slice(n,n+t);r.push(o)}return r}(t);return e.apply(null,r.map(t=>e.apply(null,t)))}}function s(e){return o(Math.max,e.nodes().map(t=>{let r=e.node(t).rank;return void 0===r?5e-324:r}))}var i=0;function d(e){return e+""+ ++i}function l(e,t,r=1){null==t&&(t=e,e=0);let n=e=>e<t;r<0&&(n=e=>t<e);let o=[];for(let t=e;n(t);t+=r)o.push(t);return o}function c(e,t){return e.reduce((e,r,n)=>(e[r]=t[n],e),{})}}),l=o((e,t)=>{var r=i(),n=d().uniqueId;t.exports={run:function(e){var t,o;let a,s,i;("greedy"===e.graph().acyclicer?r(e,(t=e,e=>t.edge(e).weight)):(a=[],s={},i={},(o=e).nodes().forEach(function e(t){Object.hasOwn(i,t)||(i[t]=!0,s[t]=!0,o.outEdges(t).forEach(t=>{Object.hasOwn(s,t.w)?a.push(t):e(t.w)}),delete s[t])}),a)).forEach(t=>{let r=e.edge(t);e.removeEdge(t),r.forwardName=t.name,r.reversed=!0,e.setEdge(t.w,t.v,r,n("rev"))})},undo:function(e){e.edges().forEach(t=>{let r=e.edge(t);if(r.reversed){e.removeEdge(t);let n=r.forwardName;delete r.reversed,delete r.forwardName,e.setEdge(t.w,t.v,r,n)}})}}}),c=o((e,t)=>{var r=d();t.exports={run:function(e){e.graph().dummyChains=[],e.edges().forEach(t=>(function(e,t){let n,o,a,s=t.v,i=e.node(s).rank,d=t.w,l=e.node(d).rank,c=t.name,u=e.edge(t),h=u.labelRank;if(l!==i+1){for(e.removeEdge(t),a=0,++i;i<l;++a,++i)u.points=[],o={width:0,height:0,edgeLabel:u,edgeObj:t,rank:i},n=r.addDummyNode(e,"edge",o,"_d"),i===h&&(o.width=u.width,o.height=u.height,o.dummy="edge-label",o.labelpos=u.labelpos),e.setEdge(s,n,{weight:u.weight},c),0===a&&e.graph().dummyChains.push(n),s=n;e.setEdge(s,d,{weight:u.weight},c)}})(e,t))},undo:function(e){e.graph().dummyChains.forEach(t=>{let r=e.node(t),n=r.edgeLabel,o;for(e.setEdge(r.edgeObj,n);r.dummy;)o=e.successors(t)[0],e.removeNode(t),n.points.push({x:r.x,y:r.y}),"edge-label"===r.dummy&&(n.x=r.x,n.y=r.y,n.width=r.width,n.height=r.height),t=o,r=e.node(t)})}}}),u=o((e,t)=>{var{applyWithChunking:r}=d();t.exports={longestPath:function(e){var t={};e.sources().forEach(function n(o){var a=e.node(o);if(Object.hasOwn(t,o))return a.rank;t[o]=!0;var s=r(Math.min,e.outEdges(o).map(t=>null==t?1/0:n(t.w)-e.edge(t).minlen));return s===1/0&&(s=0),a.rank=s})},slack:function(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}}}),h=o((e,t)=>{var r=a().Graph,n=u().slack;t.exports=function(e){var t,o,a,s,i=new r({directed:!1}),d=e.nodes()[0],l=e.nodeCount();for(i.setNode(d,{});t=i,o=e,t.nodes().forEach(function e(r){o.nodeEdges(r).forEach(a=>{var s=a.v,i=r===s?a.w:s;t.hasNode(i)||n(o,a)||(t.setNode(i,{}),t.setEdge(r,i,{}),e(i))})}),t.nodeCount()<l;)a=function(e,t){return t.edges().reduce((r,o)=>{let a=1/0;return e.hasNode(o.v)!==e.hasNode(o.w)&&(a=n(t,o)),a<r[0]?[a,o]:r},[1/0,null])[1]}(i,e),s=i.hasNode(a.v)?n(e,a):-n(e,a),function(e,t,r){e.nodes().forEach(e=>t.node(e).rank+=r)}(i,e,s);return i}}),f=o((e,t)=>{var r=h(),n=u().slack,o=u().longestPath,s=a().alg.preorder,i=a().alg.postorder,l=d().simplify;function c(e){o(e=l(e));var t,n,a=r(e);for(g(a),f(a,e);t=m(a);)n=v(a,e,t),x(a,e,t,n)}function f(e,t){var r=i(e,e.nodes());(r=r.slice(0,r.length-1)).forEach(r=>{var n,o,a,s;return n=e,o=t,a=r,s=n.node(a).parent,void(n.edge(a,s).cutvalue=p(n,o,a))})}function p(e,t,r){var n=e.node(r).parent,o=!0,a=t.edge(r,n),s=0;return a||(o=!1,a=t.edge(n,r)),s=a.weight,t.nodeEdges(r).forEach(a=>{var i=a.v===r,d=i?a.w:a.v;if(d!==n){var l,c,u,h=i===o,f=t.edge(a).weight;if(s+=h?f:-f,l=e,c=r,u=d,l.hasEdge(c,u)){var p=e.edge(r,d).cutvalue;s+=h?-p:p}}}),s}function g(e,t){arguments.length<2&&(t=e.nodes()[0]),function e(t,r,n,o,a){var s=n,i=t.node(o);return r[o]=!0,t.neighbors(o).forEach(a=>{Object.hasOwn(r,a)||(n=e(t,r,n,a,o))}),i.low=s,i.lim=n++,a?i.parent=a:delete i.parent,n}(e,{},1,t)}function m(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function v(e,t,r){var o=r.v,a=r.w;t.hasEdge(o,a)||(o=r.w,a=r.v);var s=e.node(o),i=e.node(a),d=s,l=!1;return s.lim>i.lim&&(d=i,l=!0),t.edges().filter(t=>l===b(e,e.node(t.v),d)&&l!==b(e,e.node(t.w),d)).reduce((e,r)=>n(t,r)<n(t,e)?r:e)}function x(e,t,r,n){var o,a,i,d,l=r.v,c=r.w;e.removeEdge(l,c),e.setEdge(n.v,n.w,{}),g(e),f(e,t),o=e,a=t,i=o.nodes().find(e=>!a.node(e).parent),(d=(d=s(o,i)).slice(1)).forEach(e=>{var t=o.node(e).parent,r=a.edge(e,t),n=!1;r||(r=a.edge(t,e),n=!0),a.node(e).rank=a.node(t).rank+(n?r.minlen:-r.minlen)})}function b(e,t,r){return r.low<=t.lim&&t.lim<=r.lim}t.exports=c,c.initLowLimValues=g,c.initCutValues=f,c.calcCutValue=p,c.leaveEdge=m,c.enterEdge=v,c.exchangeEdges=x}),p=o((e,t)=>{var r=u().longestPath,n=h(),o=f();t.exports=function(e){var t,s=e.graph().ranker;if(s instanceof Function)return s(e);switch(e.graph().ranker){case"network-simplex":default:o(e);break;case"tight-tree":r(t=e),n(t);break;case"longest-path":a(e);case"none":}};var a=r}),g=o((e,t)=>{t.exports=function(e){var t;let r,n,o=(r={},n=0,(t=e).children().forEach(function e(o){let a=n;t.children(o).forEach(e),r[o]={low:a,lim:n++}}),r);e.graph().dummyChains.forEach(t=>{let r=e.node(t),n=r.edgeObj,a=function(e,t,r,n){let o=[],a=[],s=Math.min(t[r].low,t[n].low),i=Math.max(t[r].lim,t[n].lim),d,l;d=r;do o.push(d=e.parent(d));while(d&&(t[d].low>s||i>t[d].lim))for(l=d,d=n;(d=e.parent(d))!==l;)a.push(d);return{path:o.concat(a.reverse()),lca:l}}(e,o,n.v,n.w),s=a.path,i=a.lca,d=0,l=s[0],c=!0;for(;t!==n.w;){if(r=e.node(t),c){for(;(l=s[d])!==i&&e.node(l).maxRank<r.rank;)d++;l===i&&(c=!1)}if(!c){for(;d<s.length-1&&e.node(l=s[d+1]).minRank<=r.rank;)d++;l=s[d]}e.setParent(t,l),t=e.successors(t)[0]}})}}),m=o((e,t)=>{var r=d();t.exports={run:function(e){var t,n,o;let a=r.addDummyNode(e,"root",{},"_root"),s=(n={},(t=e).children().forEach(e=>(function e(r,o){var a=t.children(r);a&&a.length&&a.forEach(t=>e(t,o+1)),n[r]=o})(e,1)),n),i=Object.values(s),d=r.applyWithChunking(Math.max,i)-1,l=2*d+1;e.graph().nestingRoot=a,e.edges().forEach(t=>e.edge(t).minlen*=l);let c=(o=e).edges().reduce((e,t)=>e+o.edge(t).weight,0)+1;e.children().forEach(t=>(function e(t,n,o,a,s,i,d){let l=t.children(d);if(!l.length){d!==n&&t.setEdge(n,d,{weight:0,minlen:o});return}let c=r.addBorderNode(t,"_bt"),u=r.addBorderNode(t,"_bb"),h=t.node(d);t.setParent(c,d),h.borderTop=c,t.setParent(u,d),h.borderBottom=u,l.forEach(r=>{e(t,n,o,a,s,i,r);let l=t.node(r),h=l.borderTop?l.borderTop:r,f=l.borderBottom?l.borderBottom:r,p=l.borderTop?a:2*a,g=h!==f?1:s-i[d]+1;t.setEdge(c,h,{weight:p,minlen:g,nestingEdge:!0}),t.setEdge(f,u,{weight:p,minlen:g,nestingEdge:!0})}),t.parent(d)||t.setEdge(n,c,{weight:0,minlen:s+i[d]})})(e,a,l,c,d,s,t)),e.graph().nodeRankFactor=l},cleanup:function(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}}}),v=o((e,t)=>{var r=d();function n(e,t,n,o,a,s){let i=a[t][s-1],d=r.addDummyNode(e,"border",{width:0,height:0,rank:s,borderType:t},n);a[t][s]=d,e.setParent(d,o),i&&e.setEdge(i,d,{weight:1})}t.exports=function(e){e.children().forEach(function t(r){let o=e.children(r),a=e.node(r);if(o.length&&o.forEach(t),Object.hasOwn(a,"minRank")){a.borderLeft=[],a.borderRight=[];for(let t=a.minRank,o=a.maxRank+1;t<o;++t)n(e,"borderLeft","_bl",r,a,t),n(e,"borderRight","_br",r,a,t)}})}}),x=o((e,t)=>{function r(e){e.nodes().forEach(t=>n(e.node(t))),e.edges().forEach(t=>n(e.edge(t)))}function n(e){let t=e.width;e.width=e.height,e.height=t}function o(e){e.y=-e.y}function a(e){let t=e.x;e.x=e.y,e.y=t}t.exports={adjust:function(e){let t=e.graph().rankdir.toLowerCase();("lr"===t||"rl"===t)&&r(e)},undo:function(e){var t,n;let s=e.graph().rankdir.toLowerCase();("bt"===s||"rl"===s)&&((t=e).nodes().forEach(e=>o(t.node(e))),t.edges().forEach(e=>{let r=t.edge(e);r.points.forEach(o),Object.hasOwn(r,"y")&&o(r)})),("lr"===s||"rl"===s)&&((n=e).nodes().forEach(e=>a(n.node(e))),n.edges().forEach(e=>{let t=n.edge(e);t.points.forEach(a),Object.hasOwn(t,"x")&&a(t)}),r(e))}}}),b=o((e,t)=>{var r=d();t.exports=function(e){let t={},n=e.nodes().filter(t=>!e.children(t).length),o=n.map(t=>e.node(t).rank),a=r.applyWithChunking(Math.max,o),s=r.range(a+1).map(()=>[]);return n.sort((t,r)=>e.node(t).rank-e.node(r).rank).forEach(function r(n){t[n]||(t[n]=!0,s[e.node(n).rank].push(n),e.successors(n).forEach(r))}),s}}),y=o((e,t)=>{var r=d().zipObject;t.exports=function(e,t){let n=0;for(let o=1;o<t.length;++o)n+=function(e,t,n){let o=r(n,n.map((e,t)=>t)),a=t.flatMap(t=>e.outEdges(t).map(t=>({pos:o[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos)),s=1;for(;s<n.length;)s<<=1;let i=2*s-1;s-=1;let d=Array(i).fill(0),l=0;return a.forEach(e=>{let t=e.pos+s;d[t]+=e.weight;let r=0;for(;t>0;)t%2&&(r+=d[t+1]),t=t-1>>1,d[t]+=e.weight;l+=e.weight*r}),l}(e,t[o-1],t[o]);return n}}),w=o((e,t)=>{t.exports=function(e,t=[]){return t.map(t=>{let r=e.inEdges(t);if(!r.length)return{v:t};{let n=r.reduce((t,r)=>{let n=e.edge(r),o=e.node(r.v);return{sum:t.sum+n.weight*o.order,weight:t.weight+n.weight}},{sum:0,weight:0});return{v:t,barycenter:n.sum/n.weight,weight:n.weight}}})}}),E=o((e,t)=>{var r=d();t.exports=function(e,t){let n={};return e.forEach((e,t)=>{let r=n[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:t};void 0!==e.barycenter&&(r.barycenter=e.barycenter,r.weight=e.weight)}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];void 0!==t&&void 0!==r&&(r.indegree++,t.out.push(n[e.w]))}),function(e){let t=[];for(;e.length;){let r=e.pop();t.push(r),r.in.reverse().forEach(function(e){return t=>{t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&function(e,t){let r=0,n=0;e.weight&&(r+=e.barycenter*e.weight,n+=e.weight),t.weight&&(r+=t.barycenter*t.weight,n+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=r/n,e.weight=n,e.i=Math.min(t.i,e.i),t.merged=!0}(e,t)}}(r)),r.out.forEach(function(t){return r=>{r.in.push(t),0==--r.indegree&&e.push(r)}}(r))}return t.filter(e=>!e.merged).map(e=>r.pick(e,["vs","i","barycenter","weight"]))}(Object.values(n).filter(e=>!e.indegree))}}),k=o((e,t)=>{var r=d();function n(e,t,r){let n;for(;t.length&&(n=t[t.length-1]).i<=r;)t.pop(),e.push(n.vs),r++;return r}t.exports=function(e,t){var o;let a=r.partition(e,e=>Object.hasOwn(e,"barycenter")),s=a.lhs,i=a.rhs.sort((e,t)=>t.i-e.i),d=[],l=0,c=0,u=0;s.sort((o=!!t,(e,t)=>e.barycenter<t.barycenter?-1:e.barycenter>t.barycenter?1:o?t.i-e.i:e.i-t.i)),u=n(d,i,u),s.forEach(e=>{u+=e.vs.length,d.push(e.vs),l+=e.barycenter*e.weight,c+=e.weight,u=n(d,i,u)});let h={vs:d.flat(!0)};return c&&(h.barycenter=l/c,h.weight=c),h}}),j=o((e,t)=>{var r=w(),n=E(),o=k();t.exports=function e(t,a,s,i){var d,l;let c=t.children(a),u=t.node(a),h=u?u.borderLeft:void 0,f=u?u.borderRight:void 0,p={};h&&(c=c.filter(e=>e!==h&&e!==f));let g=r(t,c);g.forEach(r=>{if(t.children(r.v).length){var n,o;let a=e(t,r.v,s,i);p[r.v]=a,Object.hasOwn(a,"barycenter")&&(n=r,o=a,void 0!==n.barycenter?(n.barycenter=(n.barycenter*n.weight+o.barycenter*o.weight)/(n.weight+o.weight),n.weight+=o.weight):(n.barycenter=o.barycenter,n.weight=o.weight))}});let m=n(g,s);d=m,l=p,d.forEach(e=>{e.vs=e.vs.flatMap(e=>l[e]?l[e].vs:e)});let v=o(m,i);if(h&&(v.vs=[h,v.vs,f].flat(!0),t.predecessors(h).length)){let e=t.node(t.predecessors(h)[0]),r=t.node(t.predecessors(f)[0]);Object.hasOwn(v,"barycenter")||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+e.order+r.order)/(v.weight+2),v.weight+=2}return v}}),N=o((e,t)=>{var r=a().Graph,n=d();t.exports=function(e,t,o,a){a||(a=e.nodes());let s=function(e){for(var t;e.hasNode(t=n.uniqueId("_root")););return t}(e),i=new r({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(t=>e.node(t));return a.forEach(r=>{let n=e.node(r),a=e.parent(r);(n.rank===t||n.minRank<=t&&t<=n.maxRank)&&(i.setNode(r),i.setParent(r,a||s),e[o](r).forEach(t=>{let n=t.v===r?t.w:t.v,o=i.edge(n,r),a=void 0!==o?o.weight:0;i.setEdge(n,r,{weight:e.edge(t).weight+a})}),Object.hasOwn(n,"minRank")&&i.setNode(r,{borderLeft:n.borderLeft[t],borderRight:n.borderRight[t]}))}),i}}),C=o((e,t)=>{t.exports=function(e,t,r){let n={},o;r.forEach(r=>{let a=e.parent(r),s,i;for(;a;){if((s=e.parent(a))?(i=n[s],n[s]=a):(i=o,o=a),i&&i!==a)return void t.setEdge(i,a);a=s}})}}),_=o((e,t)=>{var r=b(),n=y(),o=j(),s=N(),i=C(),l=a().Graph,c=d();function u(e,t,r){let n=new Map,o=(e,t)=>{n.has(e)||n.set(e,[]),n.get(e).push(t)};for(let t of e.nodes()){let r=e.node(t);if("number"==typeof r.rank&&o(r.rank,t),"number"==typeof r.minRank&&"number"==typeof r.maxRank)for(let e=r.minRank;e<=r.maxRank;e++)e!==r.rank&&o(e,t)}return t.map(function(t){return s(e,t,r,n.get(t)||[])})}function h(e,t){Object.values(t).forEach(t=>t.forEach((t,r)=>e.node(t).order=r))}t.exports=function e(t,a={}){if("function"==typeof a.customOrder)return void a.customOrder(t,e);let s=c.maxRank(t),d=u(t,c.range(1,s+1),"inEdges"),f=u(t,c.range(s-1,-1,-1),"outEdges"),p=r(t);if(h(t,p),a.disableOptimalOrderHeuristic)return;let g=1/0,m,v=a.constraints||[];for(let e=0,r=0;r<4;++e,++r){(function(e,t,r){let n=new l;e.forEach(function(e){r.forEach(e=>n.setEdge(e.left,e.right));let a=e.graph().root,s=o(e,a,n,t);s.vs.forEach((t,r)=>e.node(t).order=r),i(e,n,s.vs)})})(e%2?d:f,e%4>=2,v),p=c.buildLayerMatrix(t);let a=n(t,p);a<g?(r=0,m=Object.assign({},p),g=a):a===g&&(m=structuredClone(p))}h(t,m)}}),O=o((e,t)=>{var r=a().Graph,n=d();function o(e,t){let r={};return t.length&&t.reduce(function(t,n){let o=0,a=0,s=t.length,d=n[n.length-1];return n.forEach((t,l)=>{let c=function(e,t){if(e.node(t).dummy)return e.predecessors(t).find(t=>e.node(t).dummy)}(e,t),u=c?e.node(c).order:s;(c||t===d)&&(n.slice(a,l+1).forEach(t=>{e.predecessors(t).forEach(n=>{let a=e.node(n),s=a.order;(s<o||u<s)&&!(a.dummy&&e.node(t).dummy)&&i(r,n,t)})}),a=l+1,o=u)}),n}),r}function s(e,t){let r={};function o(t,o,a,s,d){let l;n.range(o,a).forEach(n=>{l=t[n],e.node(l).dummy&&e.predecessors(l).forEach(t=>{let n=e.node(t);n.dummy&&(n.order<s||n.order>d)&&i(r,t,l)})})}return t.length&&t.reduce(function(t,r){let n=-1,a,s=0;return r.forEach((i,d)=>{if("border"===e.node(i).dummy){let t=e.predecessors(i);t.length&&(a=e.node(t[0]).order,o(r,s,d,n,a),s=d,n=a)}o(r,s,r.length,a,t.length)}),r}),r}function i(e,t,r){if(t>r){let e=t;t=r,r=e}let n=e[t];n||(e[t]=n={}),n[r]=!0}function l(e,t,r){if(t>r){let e=t;t=r,r=e}return!!e[t]&&Object.hasOwn(e[t],r)}function c(e,t,r,n){let o={},a={},s={};return t.forEach(e=>{e.forEach((e,t)=>{o[e]=e,a[e]=e,s[e]=t})}),t.forEach(e=>{let t=-1;e.forEach(e=>{let i=n(e);if(i.length){let n=((i=i.sort((e,t)=>s[e]-s[t])).length-1)/2;for(let d=Math.floor(n),c=Math.ceil(n);d<=c;++d){let n=i[d];a[e]===e&&t<s[n]&&!l(r,e,n)&&(a[n]=e,a[e]=o[e]=o[n],t=s[n])}}})}),{root:o,align:a}}function u(e,t,n,o,a){var s,i,d,l,c,u,h;let f,p,g,m={},v=(s=e,i=t,d=n,l=a,f=new r,g=(c=(p=s.graph()).nodesep,u=p.edgesep,h=l,(e,t,r)=>{let n=e.node(t),o=e.node(r),a,s;if(a=0+n.width/2,Object.hasOwn(n,"labelpos"))switch(n.labelpos.toLowerCase()){case"l":s=-n.width/2;break;case"r":s=n.width/2}if(s&&(a+=h?s:-s),s=0,a+=(n.dummy?u:c)/2,a+=(o.dummy?u:c)/2,a+=o.width/2,Object.hasOwn(o,"labelpos"))switch(o.labelpos.toLowerCase()){case"l":s=o.width/2;break;case"r":s=-o.width/2}return s&&(a+=h?s:-s),s=0,a}),i.forEach(e=>{let t;e.forEach(e=>{let r=d[e];if(f.setNode(r),t){var n=d[t],o=f.edge(n,r);f.setEdge(n,r,Math.max(g(s,e,t),o||0))}t=e})}),f),x=a?"borderLeft":"borderRight";function b(e,t){let r=v.nodes().slice(),n={},o=r.pop();for(;o;){if(n[o])e(o);else for(let e of(n[o]=!0,r.push(o),t(o)))r.push(e);o=r.pop()}}return b(function(e){m[e]=v.inEdges(e).reduce((e,t)=>Math.max(e,m[t.v]+v.edge(t)),0)},v.predecessors.bind(v)),b(function(t){let r=v.outEdges(t).reduce((e,t)=>Math.min(e,m[t.w]-v.edge(t)),1/0),n=e.node(t);r!==1/0&&n.borderType!==x&&(m[t]=Math.max(m[t],r))},v.successors.bind(v)),Object.keys(o).forEach(e=>m[e]=m[n[e]]),m}function h(e,t){return Object.values(t).reduce((t,r)=>{let n=-1/0,o=1/0;Object.entries(r).forEach(([t,r])=>{var a,s;let i=(a=e,s=t,a.node(s).width/2);n=Math.max(r+i,n),o=Math.min(r-i,o)});let a=n-o;return a<t[0]&&(t=[a,r]),t},[1/0,null])[1]}function f(e,t){let r=Object.values(t),o=n.applyWithChunking(Math.min,r),a=n.applyWithChunking(Math.max,r);["u","d"].forEach(r=>{["l","r"].forEach(s=>{let i=r+s,d=e[i];if(d===t)return;let l=Object.values(d),c=o-n.applyWithChunking(Math.min,l);"l"!==s&&(c=a-n.applyWithChunking(Math.max,l)),c&&(e[i]=n.mapValues(d,e=>e+c))})})}function p(e,t){return n.mapValues(e.ul,(r,n)=>{if(t)return e[t.toLowerCase()][n];{let t=Object.values(e).map(e=>e[n]).sort((e,t)=>e-t);return(t[1]+t[2])/2}})}t.exports={positionX:function(e){let t=n.buildLayerMatrix(e),r=Object.assign(o(e,t),s(e,t)),a={},i;["u","d"].forEach(o=>{i="u"===o?t:Object.values(t).reverse(),["l","r"].forEach(t=>{"r"===t&&(i=i.map(e=>Object.values(e).reverse()));let s=("u"===o?e.predecessors:e.successors).bind(e),d=c(e,i,r,s),l=u(e,i,d.root,d.align,"r"===t);"r"===t&&(l=n.mapValues(l,e=>-e)),a[o+t]=l})});let d=h(e,a);return f(a,d),p(a,e.graph().align)},findType1Conflicts:o,findType2Conflicts:s,addConflict:i,hasConflict:l,verticalAlignment:c,horizontalCompaction:u,alignCoordinates:f,findSmallestWidthAlignment:h,balance:p}}),R=o((e,t)=>{var r=d(),n=O().positionX;t.exports=function(e){var t;let o,a,s,i;t=e=r.asNonCompoundGraph(e),o=r.buildLayerMatrix(t),a=t.graph().ranksep,s=t.graph().rankalign,i=0,o.forEach(e=>{let r=e.reduce((e,r)=>{let n=t.node(r).height;return e>n?e:n},0);e.forEach(e=>{let n=t.node(e);"top"===s?n.y=i+n.height/2:"bottom"===s?n.y=i+r-n.height/2:n.y=i+r/2}),i+=r+a}),Object.entries(n(e)).forEach(([t,r])=>e.node(t).x=r)}}),M=o((e,t)=>{var r=l(),n=c(),o=p(),s=d().normalizeRanks,i=g(),u=d().removeEmptyRanks,h=m(),f=v(),b=x(),y=_(),w=R(),E=d(),k=a().Graph;t.exports=function(e,t={}){let a=t.debugTiming?E.time:E.notime;return a("layout",()=>{let d=a(" buildLayoutGraph",()=>{var t;let r,n;return t=e,r=new k({multigraph:!0,compound:!0}),n=D(t.graph()),r.setGraph(Object.assign({},N,L(n,j),E.pick(n,C))),t.nodes().forEach(e=>{let n=L(D(t.node(e)),O);Object.keys(M).forEach(e=>{void 0===n[e]&&(n[e]=M[e])}),r.setNode(e,n),r.setParent(e,t.parent(e))}),t.edges().forEach(e=>{let n=D(t.edge(e));r.setEdge(e,Object.assign({},P,L(n,S),E.pick(n,T)))}),r});return a(" runLayout",()=>{var e,l,c;return e=d,l=a,c=t,void(l(" makeSpaceForEdgeLabels",()=>{var t;let r;return r=(t=e).graph(),void(r.ranksep/=2,t.edges().forEach(e=>{let n=t.edge(e);n.minlen*=2,"c"!==n.labelpos.toLowerCase()&&("TB"===r.rankdir||"BT"===r.rankdir?n.width+=n.labeloffset:n.height+=n.labeloffset)}))}),l(" removeSelfEdges",()=>{var t;(t=e).edges().forEach(e=>{if(e.v===e.w){var r=t.node(e.v);r.selfEdges||(r.selfEdges=[]),r.selfEdges.push({e:e,label:t.edge(e)}),t.removeEdge(e)}})}),l(" acyclic",()=>r.run(e)),l(" nestingGraph.run",()=>h.run(e)),l(" rank",()=>o(E.asNonCompoundGraph(e))),l(" injectEdgeLabelProxies",()=>{var t;(t=e).edges().forEach(e=>{let r=t.edge(e);if(r.width&&r.height){let r=t.node(e.v),n={rank:(t.node(e.w).rank-r.rank)/2+r.rank,e:e};E.addDummyNode(t,"edge-proxy",n,"_ep")}})}),l(" removeEmptyRanks",()=>u(e)),l(" nestingGraph.cleanup",()=>h.cleanup(e)),l(" normalizeRanks",()=>s(e)),l(" assignRankMinMax",()=>{var t;let r;return r=0,void((t=e).nodes().forEach(e=>{let n=t.node(e);n.borderTop&&(n.minRank=t.node(n.borderTop).rank,n.maxRank=t.node(n.borderBottom).rank,r=Math.max(r,n.maxRank))}),t.graph().maxRank=r)}),l(" removeEdgeLabelProxies",()=>{var t;(t=e).nodes().forEach(e=>{let r=t.node(e);"edge-proxy"===r.dummy&&(t.edge(r.e).labelRank=r.rank,t.removeNode(e))})}),l(" normalize.run",()=>n.run(e)),l(" parentDummyChains",()=>i(e)),l(" addBorderSegments",()=>f(e)),l(" order",()=>y(e,c)),l(" insertSelfEdges",()=>{var t;return t=e,void E.buildLayerMatrix(t).forEach(e=>{var r=0;e.forEach((e,n)=>{var o=t.node(e);o.order=n+r,(o.selfEdges||[]).forEach(e=>{E.addDummyNode(t,"selfedge",{width:e.label.width,height:e.label.height,rank:o.rank,order:n+ ++r,e:e.e,label:e.label},"_se")}),delete o.selfEdges})})}),l(" adjustCoordinateSystem",()=>b.adjust(e)),l(" position",()=>w(e)),l(" positionSelfEdges",()=>{var t;(t=e).nodes().forEach(e=>{var r=t.node(e);if("selfedge"===r.dummy){var n=t.node(r.e.v),o=n.x+n.width/2,a=n.y,s=r.x-o,i=n.height/2;t.setEdge(r.e,r.label),t.removeNode(e),r.label.points=[{x:o+2*s/3,y:a-i},{x:o+5*s/6,y:a-i},{x:o+s,y:a},{x:o+5*s/6,y:a+i},{x:o+2*s/3,y:a+i}],r.label.x=r.x,r.label.y=r.y}})}),l(" removeBorderNodes",()=>{var t;(t=e).nodes().forEach(e=>{if(t.children(e).length){let r=t.node(e),n=t.node(r.borderTop),o=t.node(r.borderBottom),a=t.node(r.borderLeft[r.borderLeft.length-1]),s=t.node(r.borderRight[r.borderRight.length-1]);r.width=Math.abs(s.x-a.x),r.height=Math.abs(o.y-n.y),r.x=a.x+r.width/2,r.y=n.y+r.height/2}}),t.nodes().forEach(e=>{"border"===t.node(e).dummy&&t.removeNode(e)})}),l(" normalize.undo",()=>n.undo(e)),l(" fixupEdgeLabelCoords",()=>{var t;(t=e).edges().forEach(e=>{let r=t.edge(e);if(Object.hasOwn(r,"x"))switch(("l"===r.labelpos||"r"===r.labelpos)&&(r.width-=r.labeloffset),r.labelpos){case"l":r.x-=r.width/2+r.labeloffset;break;case"r":r.x+=r.width/2+r.labeloffset}})}),l(" undoCoordinateSystem",()=>b.undo(e)),l(" translateGraph",()=>(function(e){let t=1/0,r=0,n=1/0,o=0,a=e.graph(),s=a.marginx||0,i=a.marginy||0;function d(e){let a=e.x,s=e.y,i=e.width,d=e.height;t=Math.min(t,a-i/2),r=Math.max(r,a+i/2),n=Math.min(n,s-d/2),o=Math.max(o,s+d/2)}e.nodes().forEach(t=>d(e.node(t))),e.edges().forEach(t=>{let r=e.edge(t);Object.hasOwn(r,"x")&&d(r)}),t-=s,n-=i,e.nodes().forEach(r=>{let o=e.node(r);o.x-=t,o.y-=n}),e.edges().forEach(r=>{let o=e.edge(r);o.points.forEach(e=>{e.x-=t,e.y-=n}),Object.hasOwn(o,"x")&&(o.x-=t),Object.hasOwn(o,"y")&&(o.y-=n)}),a.width=r-t+s,a.height=o-n+i})(e)),l(" assignNodeIntersects",()=>{var t;(t=e).edges().forEach(e=>{let r=t.edge(e),n=t.node(e.v),o=t.node(e.w),a,s;r.points?(a=r.points[0],s=r.points[r.points.length-1]):(r.points=[],a=o,s=n),r.points.unshift(E.intersectRect(n,a)),r.points.push(E.intersectRect(o,s))})}),l(" reversePoints",()=>{var t;(t=e).edges().forEach(e=>{let r=t.edge(e);r.reversed&&r.points.reverse()})}),l(" acyclic.undo",()=>r.undo(e)))}),a(" updateInputGraph",()=>{var t,r;return t=e,r=d,void(t.nodes().forEach(e=>{let n=t.node(e),o=r.node(e);n&&(n.x=o.x,n.y=o.y,n.order=o.order,n.rank=o.rank,r.children(e).length&&(n.width=o.width,n.height=o.height))}),t.edges().forEach(e=>{let n=t.edge(e),o=r.edge(e);n.points=o.points,Object.hasOwn(o,"x")&&(n.x=o.x,n.y=o.y)}),t.graph().width=r.graph().width,t.graph().height=r.graph().height)}),d})};var j=["nodesep","edgesep","ranksep","marginx","marginy"],N={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb",rankalign:"center"},C=["acyclicer","ranker","rankdir","align","rankalign"],O=["width","height","rank"],M={width:0,height:0},S=["minlen","weight","width","height","labeloffset"],P={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},T=["labelpos"];function L(e,t){return E.mapValues(E.pick(e,t),Number)}function D(e){var t={};return e&&Object.entries(e).forEach(([e,r])=>{"string"==typeof e&&(e=e.toLowerCase()),t[e]=r}),t}}),S=o((e,t)=>{var r=d(),n=a().Graph;t.exports={debugOrdering:function(e){let t=r.buildLayerMatrix(e),o=new n({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(t=>{o.setNode(t,{label:t}),o.setParent(t,"layer"+e.node(t).rank)}),e.edges().forEach(e=>o.setEdge(e.v,e.w,{},e.name)),t.forEach((e,t)=>{o.setNode("layer"+t,{rank:"same"}),e.reduce((e,t)=>(o.setEdge(e,t,{style:"invis"}),t))}),o}}}),P=o((e,t)=>{t.exports="2.0.4"});let T=o((e,t)=>{t.exports={graphlib:a(),layout:M(),debug:S(),util:{time:d().time,notime:d().notime},version:P()}})(),L={direction:"LR",ranksep:200,nodesep:15},D={featureNode:{width:288,height:140},repositoryNode:{width:328,height:50}};function A(e,t){let r=e.data;return r&&"number"==typeof r.width&&"number"==typeof r.height?{width:r.width,height:r.height}:D[e.type??""]??t}function I(e,t,r={}){let{direction:n="TB",nodeSize:o={width:172,height:36},ranksep:a=80,nodesep:s=30}=r;if(0===e.length)return{nodes:[],edges:[]};let i=new T.graphlib.Graph({multigraph:!0});i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:n,ranksep:a,nodesep:s});let d=new Set;for(let e of t)d.add(e.source),d.add(e.target);let l=e.filter(e=>d.has(e.id)),c=e.filter(e=>!d.has(e.id));for(let e of l){let t=A(e,o);i.setNode(e.id,{width:t.width,height:t.height})}for(let e of t)i.hasNode(e.source)&&i.hasNode(e.target)&&i.setEdge(e.source,e.target,{},e.id);T.layout(i);let{targetPosition:u,sourcePosition:h}=function(e){switch(e){case"LR":return{targetPosition:"left",sourcePosition:"right"};case"RL":return{targetPosition:"right",sourcePosition:"left"};case"BT":return{targetPosition:"bottom",sourcePosition:"top"};default:return{targetPosition:"top",sourcePosition:"bottom"}}}(n),f="LR"===n||"RL"===n,p=new Map;for(let e of l){let t=i.node(e.id),r=A(e,o);p.set(e.id,{cx:t.x,cy:t.y,w:r.width,h:r.height})}let g=0;for(let e of p.values()){g=f?e.cx:e.cy;break}for(let e of c){let t=A(e,o);p.set(e.id,{cx:f?g:0,cy:f?0:g,w:t.width,h:t.height})}let m=new Map;for(let e of t)p.has(e.source)&&p.has(e.target)&&(m.has(e.source)||m.set(e.source,[]),m.get(e.source).push(e.target));let v=new Map;for(let t=0;t<e.length;t++)v.set(e[t].id,t);for(let[,e]of m)e.sort((e,t)=>(v.get(e)??0)-(v.get(t)??0));let x=new Set;for(let e of m.values())for(let t of e)x.add(t);let b=[...[...d].filter(e=>p.has(e)&&!x.has(e)),...c.map(e=>e.id)];b.sort((e,t)=>(v.get(e)??0)-(v.get(t)??0));let y=new Map;for(let e of b)!function e(t){if(y.has(t))return y.get(t);let r=p.get(t),n=f?r.h:r.w,o=m.get(t);if(!o||0===o.length)return y.set(t,n),n;let a=0;for(let t of o)a+=e(t);let i=Math.max(n,a+=(o.length-1)*s);return y.set(t,i),i}(e);let w=0;for(let e of b){let t=y.get(e)??0;!function e(t,r){let n=p.get(t);f?n.cy=r:n.cx=r;let o=m.get(t);if(!o||0===o.length)return;let a=0;for(let e of o)a+=y.get(e)??0;let i=r-(a+=(o.length-1)*s)/2;for(let t of o){let r=y.get(t)??0;e(t,i+r/2),i+=r+s}}(e,w+t/2),w+=t+s}let E=[];for(let t of e){let e=p.get(t.id);e&&E.push({...t,targetPosition:u,sourcePosition:h,position:{x:e.cx-e.w/2,y:e.cy-e.h/2}})}return{nodes:E,edges:[...t]}}var F=e.i(479),$=e.i(21023);let z=(0,$.createServerReference)("408808ce5a060db74dbbceb0c3c24e0db9fd72fa49",$.callServer,void 0,$.findSourceMapURL,"addRepository"),B=(0,$.createServerReference)("405eb1d3d6f4f0001bb87e48640359592a70b9fd4b",$.callServer,void 0,$.findSourceMapURL,"deleteRepository"),G=(0,$.createServerReference)("40e2cf8bbfe0f89fc1d25344689bb2264314c08b5b",$.callServer,void 0,$.findSourceMapURL,"getFeatureMetadata"),q=(0,$.createServerReference)("001e3b6d1d17d4bb4a95631c5b3c6dde160da5c60e",$.callServer,void 0,$.findSourceMapURL,"fetchGraphData");var W=e.i(39443),V=e.i(8361),U=e.i(18354),H=e.i(99045);function X(e,t){let r=new Map;for(let e of t)"dependencyEdge"===e.type&&r.set(e.target,e.source);let n=new Map,o=new Map;for(let t of e)"featureNode"===t.type?n.set(t.id,{nodeId:t.id,data:t.data,parentNodeId:r.get(t.id)}):"repositoryNode"===t.type&&o.set(t.id,{nodeId:t.id,data:t.data});return{featureMap:n,repoMap:o}}function K(e,t){return(void 0===t.state||t.state===e.state)&&(void 0===t.lifecycle||t.lifecycle===e.lifecycle)&&(void 0===t.name||t.name===e.name)&&(void 0===t.description||t.description===e.description)}let Y=(0,U.createLogger)("[Polling]"),J=0,Q=0;function Z(e,o){let a=(0,r.useRouter)(),s=(0,V.useSoundAction)("delete"),i=(0,V.useSoundAction)("create"),{nodes:d,edges:l,reconcile:c,updateFeature:u,addPendingFeature:h,removeFeature:f,restoreFeature:p,addRepository:g,removeRepository:m,replaceRepository:v,getFeatureRepositoryPath:x,getRepositoryData:b,getRepoMapSize:y,setCallbacks:w}=function(e,r){let n=(0,t.useMemo)(()=>X(e,r),[]),[o,a]=(0,t.useState)(n.featureMap),[s,i]=(0,t.useState)(n.repoMap),[d,l]=(0,t.useState)(new Map),c=(0,t.useRef)(new Map),u=(0,t.useRef)(new Set),h=(0,t.useRef)(new Set),f=(0,t.useRef)({}),p=(0,t.useMemo)(()=>({onNodeAction:e=>f.current.onNodeAction?.(e),onNodeSettings:e=>f.current.onNodeSettings?.(e),onFeatureDelete:e=>f.current.onFeatureDelete?.(e),onRepositoryAdd:e=>f.current.onRepositoryAdd?.(e),onRepositoryClick:e=>f.current.onRepositoryClick?.(e),onRepositoryDelete:e=>f.current.onRepositoryDelete?.(e)}),[]),g=(0,t.useRef)(o);g.current=o;let m=(0,t.useRef)(s);m.current=s;let v=(0,t.useMemo)(()=>(function(e,t,r,n){let o=[],a=[],s=new Map;for(let[e,r]of t)r.data.repositoryPath&&s.set(r.data.repositoryPath,e);let i=new Map;for(let[e,r]of[...t.entries()].sort((e,t)=>(e[1].data.createdAt??0)-(t[1].data.createdAt??0))){let t={...r.data,...n?.onRepositoryAdd&&{onAdd:()=>n.onRepositoryAdd(e)},...n?.onRepositoryClick&&{onClick:()=>n.onRepositoryClick(e)},...n?.onRepositoryDelete&&{onDelete:n.onRepositoryDelete}};o.push({id:e,type:"repositoryNode",position:{x:0,y:0},data:t})}for(let[t,d,l]of[...[...e.entries()].map(([e,t])=>[e,t,!1]),...[...r.entries()].filter(([t])=>!e.has(t)).map(([e,t])=>[e,t,!0])]){let e="creating"===d.data.state||l,r={...d.data,...!e&&n?.onNodeAction&&{onAction:()=>n.onNodeAction(t)},...!e&&n?.onNodeSettings&&{onSettings:()=>n.onNodeSettings(t)},...!e&&n?.onFeatureDelete&&{onDelete:n.onFeatureDelete}};if(o.push({id:t,type:"featureNode",position:{x:0,y:0},data:r}),d.parentNodeId)a.push({id:`dep-${d.parentNodeId}-${t}`,source:d.parentNodeId,target:t,type:"dependencyEdge"});else{let e=d.data.repositoryPath,r=s.get(e)??function(e){if(i.has(e))return i.get(e);let t=`virtual-repo-${e}`,r=e.split("/").filter(Boolean).at(-1)??e;return o.push({id:t,type:"repositoryNode",position:{x:0,y:0},data:{name:r,repositoryPath:e}}),i.set(e,t),t}(e);a.push({id:`edge-${r}-${t}`,source:r,target:t,style:{strokeDasharray:"5 5"}})}}let d=a.length>0;for(let e of o)e.data.showHandles=d;return{nodes:o,edges:a}})(o,s,d,p),[o,s,d,p]),x=(0,t.useRef)({key:"",positions:new Map}),{nodes:b,edges:y}=(0,t.useMemo)(()=>{let e=v.nodes.map(e=>e.id).sort().join(","),t=v.edges.map(e=>`${e.source}-${e.target}`).sort().join(","),r=`${e}|${t}`;if(r!==x.current.key){let e=I(v.nodes,v.edges,L),t=new Map;for(let r of e.nodes)t.set(r.id,{position:r.position,targetPosition:r.targetPosition,sourcePosition:r.sourcePosition});let n=x.current.positions;if(n.size>0){let r=0,o=0;for(let[e,a]of t){let t=n.get(e);if(t){r=t.position.x-a.position.x,o=t.position.y-a.position.y;break}}if(0!==r||0!==o){for(let e of t.values())e.position={x:e.position.x+r,y:e.position.y+o};for(let t of e.nodes)t.position={x:t.position.x+r,y:t.position.y+o}}}return x.current={key:r,positions:t},e}let{positions:n}=x.current;return{nodes:v.nodes.map(e=>{let t=n.get(e.id);return t?{...e,...t}:e}),edges:v.edges}},[v]),w=(0,t.useCallback)((e,t)=>{let{featureMap:r,repoMap:n}=X(e,t),o=new Set([...r.values()].map(e=>`${e.data.name}\0${e.data.repositoryPath}`));a(e=>{let t=[...e.entries()].filter(([,e])=>"creating"===e.data.state),n=new Map(r);for(let[e,r]of t){let t=`${r.data.name}\0${r.data.repositoryPath}`;o.has(t)||n.set(e,r)}let a=new Set;for(let[t,r]of e)"deleting"===r.data.state&&(n.has(t)?n.set(t,{...n.get(t),data:{...n.get(t).data,state:"deleting"}}):h.current.has(t)||(n.set(t,r),a.add(t)));for(let[e,t]of(h.current=a,c.current)){let r=n.get(e);r&&(n.set(e,{...r,data:{...r.data,...t}}),c.current.delete(e))}return n}),l(e=>{if(0===e.size)return e;let t=!1,r=new Map(e);for(let[n,a]of e){let e=`${a.data.name}\0${a.data.repositoryPath}`;o.has(e)&&(r.delete(n),t=!0)}return t?r:e}),i(e=>{let t=new Map(n),r=new Set([...n.values()].map(e=>e.data.repositoryPath));for(let[n,o]of e){if(t.has(n)||r.has(o.data.repositoryPath)){u.current.delete(n);continue}(n.startsWith("repo-temp-")||u.current.has(n))&&t.set(n,o)}return t})},[]),E=(0,t.useCallback)((e,t)=>{a(r=>{let n=r.get(e);if(!n)return c.current.set(e,{...c.current.get(e),...t}),r;if(c.current.delete(e),K(n.data,t))return r;let o=new Map(r);return o.set(e,{...n,data:{...n.data,...t}}),o}),l(r=>{let n=r.get(e);if(!n||K(n.data,t))return r;let o=new Map(r);return o.set(e,{...n,data:{...n.data,...t}}),o})},[]),k=(0,t.useCallback)((e,t,r)=>{l(n=>{let o=new Map(n);return o.set(e,{nodeId:e,data:t,parentNodeId:r}),o})},[]),j=(0,t.useCallback)(e=>{l(t=>{if(!t.has(e))return t;let r=new Map(t);return r.delete(e),r})},[]),N=(0,t.useCallback)(e=>{a(t=>{if(!t.has(e))return t;let r=new Map(t);return r.delete(e),r})},[]),C=(0,t.useCallback)((e,t)=>{a(r=>{let n=new Map(r);return n.set(e,t),n})},[]),_=(0,t.useCallback)((e,t)=>{u.current.add(e),i(r=>{let n=new Map(r);return n.set(e,{nodeId:e,data:t}),n})},[]),O=(0,t.useCallback)(e=>{u.current.delete(e),i(t=>{if(!t.has(e))return t;let r=new Map(t);return r.delete(e),r})},[]),R=(0,t.useCallback)((e,t,r)=>{u.current.delete(e),u.current.add(t),i(n=>{if(!n.has(e))return n;let o=new Map(n);return o.delete(e),o.set(t,{nodeId:t,data:r}),o})},[]),M=(0,t.useCallback)(e=>g.current.get(e)?.data.repositoryPath,[]),S=(0,t.useCallback)(e=>m.current.get(e)?.data,[]);return{nodes:b,edges:y,reconcile:w,updateFeature:E,addPendingFeature:k,removePendingFeature:j,removeFeature:N,restoreFeature:C,addRepository:_,removeRepository:O,replaceRepository:R,getFeatureRepositoryPath:M,getRepositoryData:S,getRepoMapSize:(0,t.useCallback)(()=>m.current.size,[]),setCallbacks:(0,t.useCallback)(e=>{f.current=e},[])}}(e,o),E=(0,t.useRef)(d),k=(0,t.useRef)(l);(0,t.useEffect)(()=>{E.current=d,k.current=l},[d,l]);let j=(0,t.useMemo)(()=>e.map(e=>e.id).sort().join(","),[e]),N=(0,t.useMemo)(()=>e.filter(e=>"featureNode"===e.type).map(e=>{let t=e.data;return`${e.id}:${t.state}:${t.lifecycle}`}).sort().join(","),[e]),C=(0,t.useRef)("");(0,t.useEffect)(()=>{let t=`${j}|${N}`;t!==C.current&&(C.current=t,c(e,o))},[j,N,e,o,c]);let _=(0,t.useRef)(new Map),{events:O}=(0,W.useAgentEventsContext)();(0,t.useEffect)(()=>{let t=_.current;for(let r of e){if("featureNode"!==r.type)continue;let e=r.data,o=t.get(r.id);void 0!==o&&o!==e.state&&(O.some(t=>t.featureId===e.featureId&&(0,H.mapEventTypeToState)(t.eventType)===e.state)||("done"===e.state?n.toast.success(e.name,{description:"Feature completed!"}):"action-required"===e.state?n.toast.warning(e.name,{description:"Waiting for your approval",action:{label:"Review",onClick:()=>a.push(`/feature/${e.featureId}`)}}):"error"===e.state&&n.toast.error(e.name,{description:e.errorMessage??"Agent failed"}))),t.set(r.id,e.state)}},[N,e,O,a]);let R=(0,t.useRef)(0);(0,t.useEffect)(()=>{if(R.current>O.length&&(R.current=0),O.length<=R.current)return;let e=O.slice(R.current);for(let{featureId:t,state:r,lifecycle:n}of(R.current=O.length,(0,H.resolveSseEventUpdates)(e)))if(void 0!==r||void 0!==n){let e=`feat-${t}`,o=E.current.find(t=>t.id===e);if(o&&"deleting"===o.data.state)continue;u(e,{...void 0!==r&&{state:r},...void 0!==n&&{lifecycle:n}})}},[O,u]),(0,t.useEffect)(()=>{let e=e=>{let{featureId:t}=e.detail;u(`feat-${t}`,{state:"running"})};return window.addEventListener("shep:feature-approved",e),()=>window.removeEventListener("shep:feature-approved",e)},[u]);let M=(0,t.useRef)(new Set),S=(0,t.useRef)(0);(0,t.useEffect)(()=>{if(S.current>O.length&&(S.current=0),O.length<=S.current)return;let e=O.slice(S.current);for(let t of(S.current=O.length,e)){if("Feature metadata updated"!==t.message||M.current.has(t.featureId))continue;M.current.add(t.featureId);let e=`feat-${t.featureId}`;G(t.featureId).then(t=>{t&&u(e,{name:t.name,description:t.description})}).catch(()=>{})}},[O,u]),(0,t.useEffect)(()=>{Y.debug("polling enabled (3000ms interval)");let e=setInterval(async()=>{try{let{nodes:e,edges:t}=await q();c(e,t)}catch{Y.warn("poll fetch failed — will retry next interval")}},3e3);return()=>{Y.debug("polling disabled"),clearInterval(e)}},[c]);let P=(0,t.useCallback)(e=>{},[]),T=(0,t.useCallback)(e=>{},[]),D=(0,t.useCallback)((e,t,r)=>{let n=t?.featureId?`feat-${t.featureId}`:`feature-${Date.now()}-${J++}`,o={name:t?.name??"New Feature",description:t?.description??"Describe what this feature does",featureId:t?.featureId??`#${n.slice(-4)}`,lifecycle:"requirements",state:t?.state??"running",progress:0,repositoryPath:t?.repositoryPath??"",branch:t?.branch??""};return h(n,o,"dependencyEdge"===r&&e?e:void 0),n},[h]),A=(0,t.useCallback)((e,t)=>{let r=`feat-${e}`,o=[],i=[r];for(;i.length>0;){let e=i.shift();for(let t of k.current)"dependencyEdge"===t.type&&t.source===e&&(o.push(t.target),i.push(t.target))}let d=new Map;for(let e of[r,...o]){let t=E.current.find(t=>t.id===e);t&&d.set(e,t.data.state)}for(let e of(u(r,{state:"deleting"}),o))u(e,{state:"deleting"});s.play(),a.push("/"),(0,F.deleteFeature)(e,t).then(e=>{if(e.error){for(let[e,t]of d)t&&u(e,{state:t});n.toast.error(e.error)}else for(let e of(f(r),o))f(e)}).catch(()=>{for(let[e,t]of d)t&&u(e,{state:t});n.toast.error("Failed to delete feature")})},[a,s,u,f]),$=(0,t.useCallback)(async e=>{let t=`repo-${e}`,r=new Set(k.current.filter(e=>e.source===t).map(e=>e.target)),o=b(t),a=new Map;for(let e of r){let t=E.current.find(t=>t.id===e);t&&a.set(e,{nodeId:e,data:t.data})}let i=()=>{for(let[e,r]of(o&&g(t,o),a))p(e,r)};for(let e of(m(t),r))f(e);try{let t=await B(e);if(!t.success){n.toast.error(t.error??"Failed to remove repository"),i();return}s.play()}catch{n.toast.error("Failed to remove repository"),i()}},[s,m,f,g,p,b]),U=(0,t.useCallback)(e=>{let t=I(E.current,k.current,{...L,direction:e});c(t.nodes,t.edges)},[c]);return{nodes:d,edges:l,onNodesChange:P,handleConnect:T,handleAddRepository:(0,t.useCallback)(e=>{let t=0===y(),r=`repo-temp-${++Q}`,o=e.replace(/[\\/]+$/,"").split(/[\\/]/).pop()??e;return g(r,{name:o,repositoryPath:e,id:r,createdAt:Date.now()}),z({path:e,name:o}).then(e=>{if(e.error){m(r),n.toast.error(e.error);return}let t=e.repository;v(r,`repo-${t.id}`,{name:t.name,repositoryPath:t.path,id:t.id,createdAt:t.createdAt instanceof Date?t.createdAt.getTime():Number(t.createdAt)}),i.play()}).catch(()=>{m(r),n.toast.error("Failed to add repository")}),{wasEmpty:t,repoPath:e}},[g,m,v,i,y]),handleLayout:U,handleDeleteFeature:A,handleDeleteRepository:$,createFeatureNode:D,getFeatureRepositoryPath:x,getRepositoryData:b,setCallbacks:w}}e.s(["useControlCenterState",()=>Z],17840)},48246,e=>{"use strict";var t=e.i(20314),r=e.i(53271),n=e.i(79054),o=e.i(31406),a=e.i(3214),s=e.i(3645);let i=(0,s.default)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);var d=e.i(31777),l=e.i(35364);e.i(54793);var c=e.i(7729);e.i(47506);var u=e.i(89313),h=e.i(92002);let f=(0,s.default)("github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);var p=e.i(8986),g=e.i(38573),m=e.i(19933),v=e.i(67669),x=e.i(24042),b=e.i(64970);e.i(81803);var y=e.i(72714),w=e.i(2287),E=e.i(2828);e.i(99348);var k=e.i(17466),j=e.i(8537),N=e.i(75921),C=e.i(76852);function _({data:e}){let o=(0,N.useFeatureFlags)(),[s,i]=(0,n.useState)(!1),c=(0,C.useRepositoryActions)(e.repositoryPath?{repositoryPath:e.repositoryPath}:null),u=(0,j.useDeployAction)(e.repositoryPath?{targetId:e.repositoryPath,targetType:"repository",repositoryPath:e.repositoryPath}:null),_="Booting"===u.status||"Ready"===u.status;return(0,t.jsxs)("div",{className:(0,d.cn)("group relative",e.onDelete&&e.id&&"pl-10"),children:[e.showHandles?(0,t.jsx)(r.Handle,{type:"target",position:h.Position.Left,isConnectable:!1,className:"opacity-0!"}):null,e.onDelete&&e.id?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"absolute top-1/2 left-0 -translate-y-1/2 opacity-0 transition-opacity group-hover:opacity-100",children:(0,t.jsx)(E.TooltipProvider,{children:(0,t.jsxs)(E.Tooltip,{children:[(0,t.jsx)(E.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("button",{"aria-label":"Remove repository","data-testid":"repository-node-delete-button",onClick:e=>{e.stopPropagation(),i(!0)},className:"bg-card text-muted-foreground hover:border-destructive hover:text-destructive flex h-7 w-7 cursor-pointer items-center justify-center rounded-full border shadow-sm transition-colors",children:(0,t.jsx)(v.Trash2,{className:"h-3.5 w-3.5"})})}),(0,t.jsx)(E.TooltipContent,{children:"Remove repository"})]})})}),(0,t.jsx)(w.Dialog,{open:s,onOpenChange:i,children:(0,t.jsxs)(w.DialogContent,{className:"max-w-xs",children:[(0,t.jsxs)(w.DialogHeader,{children:[(0,t.jsx)(w.DialogTitle,{children:"Remove repository?"}),(0,t.jsxs)(w.DialogDescription,{children:["This will remove ",(0,t.jsx)("strong",{children:e.name})," and all its features from your workspace. The repository files on disk won't be affected."]})]}),(0,t.jsxs)(w.DialogFooter,{className:"grid grid-cols-2 gap-2 sm:flex-none",children:[(0,t.jsx)(w.DialogClose,{asChild:!0,children:(0,t.jsx)(l.Button,{variant:"outline",children:"Cancel"})}),(0,t.jsx)(l.Button,{variant:"destructive",onClick:()=>{i(!1),e.onDelete?.(e.id)},children:"Remove"})]})]})})]}):null,(0,t.jsxs)("div",{role:"button",tabIndex:0,"data-testid":"repository-node-card","data-repo-name":e.name,onClick:t=>{t.stopPropagation(),e.onClick?.()},onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),t.stopPropagation(),e.onClick?.())},className:"nodrag bg-card flex min-w-[18rem] cursor-pointer items-center gap-3 rounded-full border px-4 py-3 shadow-sm",children:[(0,t.jsx)(f,{className:"text-muted-foreground h-5 w-5 shrink-0"}),(0,t.jsx)("span",{"data-testid":"repository-node-name",className:"min-w-0 truncate text-sm font-medium",children:e.name}),(0,t.jsxs)("div",{className:(0,d.cn)("flex shrink-0 items-center gap-2",(e.repositoryPath??e.onAdd)&&"ml-auto"),onClick:e=>e.stopPropagation(),children:[e.repositoryPath?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(E.TooltipProvider,{children:(0,t.jsxs)(E.Tooltip,{children:[(0,t.jsx)(E.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(y.ActionButton,{label:"Open in IDE",onClick:c.openInIde,loading:c.ideLoading,error:!!c.ideError,icon:p.Code2,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(E.TooltipContent,{children:"Open in IDE"})]})}),(0,t.jsx)(E.TooltipProvider,{children:(0,t.jsxs)(E.Tooltip,{children:[(0,t.jsx)(E.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(y.ActionButton,{label:"Open in Shell",onClick:c.openInShell,loading:c.shellLoading,error:!!c.shellError,icon:g.Terminal,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(E.TooltipContent,{children:"Open in Shell"})]})}),(0,t.jsx)(E.TooltipProvider,{children:(0,t.jsxs)(E.Tooltip,{children:[(0,t.jsx)(E.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(y.ActionButton,{label:"Open Folder",onClick:c.openFolder,loading:c.folderLoading,error:!!c.folderError,icon:m.FolderOpen,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(E.TooltipContent,{children:"Open Folder"})]})}),o.envDeploy?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(E.TooltipProvider,{children:(0,t.jsxs)(E.Tooltip,{children:[(0,t.jsx)(E.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(y.ActionButton,{label:_?"Stop Dev Server":"Start Dev Server",onClick:_?u.stop:u.deploy,loading:u.deployLoading||u.stopLoading,error:!!u.deployError,icon:_?b.Square:x.Play,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(E.TooltipContent,{children:_?"Stop Dev Server":"Start Dev Server"})]})}),_?(0,t.jsx)(k.DeploymentStatusBadge,{status:u.status,url:u.url,targetId:e.repositoryPath}):null]}):null]}):null,e.onAdd?(0,t.jsx)(E.TooltipProvider,{children:(0,t.jsxs)(E.Tooltip,{children:[(0,t.jsx)(E.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("button",{"aria-label":"Add feature","data-testid":"repository-node-add-button",onClick:t=>{t.stopPropagation(),e.onAdd?.()},className:(0,d.cn)("text-muted-foreground hover:bg-accent dark:hover:bg-accent/50 flex h-6 w-6 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors hover:text-blue-500",e.pulseAdd&&"animate-pulse-cta bg-blue-100 text-blue-500 dark:bg-blue-900/40"),children:(0,t.jsx)(a.Plus,{className:"h-3.5 w-3.5"})})}),(0,t.jsx)(E.TooltipContent,{children:"Add feature"})]})}):null]})]}),e.onAdd||e.showHandles?(0,t.jsx)(r.Handle,{type:"source",position:h.Position.Right,isConnectable:!e.showHandles,className:"opacity-0!"}):null]})}function O(e){let[n]=(0,h.getBezierPath)({sourceX:e.sourceX,sourceY:e.sourceY,targetX:e.targetX,targetY:e.targetY,sourcePosition:e.sourcePosition,targetPosition:e.targetPosition});return(0,t.jsx)(r.BaseEdge,{id:e.id,path:n,style:{strokeDasharray:"5 5"}})}e.i(1650),e.i(45811),e.i(25235);let R={x:30,y:30,zoom:.85};function M({onResetViewport:e}){let{setViewport:o}=(0,r.useReactFlow)(),a=(0,n.useCallback)(()=>{o(e(),{duration:400})},[e,o]);return(0,t.jsx)(r.ControlButton,{onClick:a,title:"Reset view","aria-label":"Reset view",children:(0,t.jsx)(i,{style:{fill:"none"}})})}function S({nodes:e,edges:o,selectedFeatureId:s,defaultViewport:i,onNodesChange:h,onAddFeature:f,onConnect:p,onNodeClick:g,onPaneClick:m,onCanvasDrag:v,onMoveEnd:x,onResetViewport:b,toolbar:y,emptyState:w}){let E=(0,n.useMemo)(()=>({featureNode:u.FeatureNode,repositoryNode:_}),[]),k=(0,n.useMemo)(()=>({dependencyEdge:O}),[]),j=(0,n.useMemo)(()=>null==s?e:e.map(e=>"featureNode"===e.type&&e.data.featureId===s?{...e,selected:!0}:e),[e,s]),N=0===e.length,[C,S]=(0,n.useState)(N),[P,T]=(0,n.useState)(!1),L=(0,n.useRef)(N);(0,n.useEffect)(()=>{if(L.current&&!N){T(!0);let e=setTimeout(()=>{S(!1),T(!1)},300);return L.current=N,()=>clearTimeout(e)}!L.current&&N&&S(!0),L.current=N},[N]);let D=N&&!w?(0,t.jsx)(c.EmptyState,{title:"No features yet",description:"Get started by creating your first feature.",action:(0,t.jsxs)(l.Button,{onClick:f,children:[(0,t.jsx)(a.Plus,{className:"mr-2 h-4 w-4"}),"New Feature"]})}):null,A=w??D;return(0,t.jsxs)("div",{"data-testid":N?"features-canvas-empty":"features-canvas","data-no-drawer-close":!0,className:"dark:bg-background pointer-events-auto relative h-full w-full bg-[#f6f7f8]",children:[(0,t.jsxs)(r.ReactFlow,{nodes:j,edges:o,nodeTypes:E,edgeTypes:k,onConnect:p,onNodesChange:h,onNodeClick:g,onPaneClick:m,onMoveStart:v,onMoveEnd:x,defaultViewport:i??R,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,proOptions:{hideAttribution:!0},children:[(0,t.jsx)(r.Background,{variant:r.BackgroundVariant.Dots,gap:24,size:1,color:"#b8bcc4",className:"dark:[&_circle]:!fill-white/[0.1]"}),!N&&(0,t.jsx)(r.Controls,{showInteractive:!1,children:b?(0,t.jsx)(M,{onResetViewport:b}):null}),y]}),C&&A?(0,t.jsx)("div",{className:(0,d.cn)("pointer-events-none absolute inset-0 z-10 flex items-center justify-center transition-opacity duration-300",P?"opacity-0":"animate-in fade-in opacity-100 duration-200"),children:(0,t.jsx)("div",{className:"pointer-events-auto",children:A})}):null]})}var P=e.i(5147),T=e.i(8361),L=e.i(30153);let D="shep-canvas-viewport",A={x:30,y:30,zoom:.85},I=(0,s.default)("square-terminal",[["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"}]]);var F=e.i(33548),$=e.i(23925),z=e.i(83428),B=e.i(35e3),G=e.i(79687),q=e.i(78521),W=e.i(21023);let V=(0,W.createServerReference)("003b6b81a3608636f4d4fa075454403df57033a0c6",W.callServer,void 0,W.findSourceMapURL,"isAgentSetupComplete"),U=(0,W.createServerReference)("0016e7b80b99aef89d0e2adcceb7f11f65f8cd173c",W.callServer,void 0,W.findSourceMapURL,"checkAgentAuth");var H=e.i(76016),X=e.i(11345),K=e.i(26370),Y=e.i(74096),J=e.i(31466),Q=e.i(86782),Z=e.i(29847);let ee=["select-agent","select-model"];function et({onComplete:e,className:r}){let o,[a,s]=(0,n.useState)([]),[i,l]=(0,n.useState)(!0),[c,u]=(0,n.useState)("select-agent"),[h,f]=(0,n.useState)(null),[p,g]=(0,n.useState)(!1),[m,v]=(0,n.useState)(!1),[x,b]=(0,n.useState)(!0),y=(0,n.useRef)(void 0);(0,n.useEffect)(()=>{(0,Y.getAllAgentModels)().then(s).finally(()=>l(!1))},[]);let w=h?a.find(e=>e.agentType===h):null,E=(0,n.useCallback)((e,t)=>{v(!0),b(!1),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{t?.(),u(e),requestAnimationFrame(()=>{b(!0),v(!1)})},150)},[]);(0,n.useEffect)(()=>()=>{y.current&&clearTimeout(y.current)},[]);let k=(0,n.useCallback)(async(t,r)=>{g(!0);try{await (0,J.updateAgentAndModel)(t,r),e()}finally{g(!1)}},[e]),j=(0,n.useCallback)(e=>{let t=a.find(t=>t.agentType===e);t&&t.models.length>0?E("select-model",()=>{f(e)}):k(e,null)},[a,E,k]),N=(0,n.useCallback)(e=>{h&&k(h,e)},[h,k]),C=(0,n.useCallback)(()=>{"select-model"===c&&E("select-agent",()=>{f(null)})},[c,E]);if(i)return(0,t.jsxs)("div",{"data-testid":"welcome-agent-setup",className:(0,d.cn)("flex flex-col items-center justify-center gap-3",r),children:[(0,t.jsx)(z.Loader2,{className:"text-muted-foreground h-4 w-4 animate-spin"}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:"Loading agents…"})]});let _=ee.indexOf(c);return(0,t.jsxs)("div",{"data-testid":"welcome-agent-setup",className:(0,d.cn)("flex flex-col items-center gap-4","w-72",r),children:[(0,t.jsx)("div",{className:"flex flex-col items-center gap-1",children:(0,t.jsxs)("div",{className:"text-muted-foreground flex items-center gap-2",children:["select-agent"===c&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(K.Bot,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{className:"text-[10px] font-semibold tracking-widest uppercase",children:"Choose your agent"})]}),"select-model"===c&&w?(o=(0,Q.getAgentTypeIcon)(w.agentType),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o,{className:"h-3.5 w-3.5"}),(0,t.jsxs)("span",{className:"text-[10px] font-semibold tracking-widest uppercase",children:[w.label," — Pick a model"]})]})):null]})}),(0,t.jsx)("div",{className:"flex w-full items-center gap-1",children:ee.map((e,r)=>(0,t.jsx)("div",{className:(0,d.cn)("h-0.5 flex-1 rounded-full transition-colors duration-300",r<=_?"bg-foreground/60":"bg-muted")},e))}),(0,t.jsxs)("div",{className:(0,d.cn)("flex w-full flex-col items-center transition-opacity duration-150",x&&!m?"opacity-100":"opacity-0"),children:["select-agent"===c&&(0,t.jsx)("div",{"data-testid":"agent-list",className:"flex w-full flex-col gap-1.5",children:a.map(e=>{let r=(0,Q.getAgentTypeIcon)(e.agentType);return(0,t.jsxs)("button",{type:"button",disabled:p,"data-testid":`agent-option-${e.agentType}`,className:"border-border hover:border-foreground/40 flex w-full cursor-pointer items-center gap-2.5 rounded-md border border-dashed px-4 py-2.5 transition-colors disabled:opacity-50",onClick:()=>j(e.agentType),children:[(0,t.jsx)(r,{className:"text-muted-foreground h-4 w-4 shrink-0"}),(0,t.jsx)("span",{className:"flex-1 text-left text-xs font-medium",children:e.label}),(0,t.jsx)(H.ChevronRight,{className:"text-muted-foreground h-3 w-3"})]},e.agentType)})}),"select-model"===c&&w?(0,t.jsxs)("div",{"data-testid":"model-list",className:"flex w-full flex-col gap-1.5",children:[(0,t.jsxs)("button",{type:"button",disabled:p,className:"text-muted-foreground hover:text-foreground mb-0.5 flex cursor-pointer items-center gap-1 self-start text-[10px] font-medium transition-colors",onClick:C,children:[(0,t.jsx)(X.ChevronLeft,{className:"h-3 w-3"}),"Back"]}),(0,t.jsx)("div",{className:"flex max-h-48 w-full flex-col gap-1.5 overflow-y-auto",children:w.models.map(e=>{let r=(0,Z.getModelMeta)(e.id);return(0,t.jsxs)("button",{type:"button",disabled:p,"data-testid":`model-option-${e.id}`,className:"border-border hover:border-foreground/40 flex w-full cursor-pointer items-center gap-2.5 rounded-md border border-dashed px-4 py-2.5 text-left transition-colors disabled:opacity-50",onClick:()=>N(e.id),children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[(0,t.jsx)("span",{className:"text-xs font-medium",children:r.displayName||e.displayName}),(0,t.jsx)("span",{className:"text-muted-foreground text-[10px] leading-tight",children:r.description||e.description})]}),(0,t.jsx)(H.ChevronRight,{className:"text-muted-foreground h-3 w-3 shrink-0"})]},e.id)})})]}):null]})]})}let er=["cd ~/my-repo",'shep feat new "sleek dashboard"'];function en({onRepositorySelect:e,className:r}){let[o,s]=(0,n.useState)(!1),[i,l]=(0,n.useState)(!1),[c,u]=(0,n.useState)(null),[h,p]=(0,n.useState)(null);async function g(){if(!i){l(!0);try{let t=await (0,q.pickFolder)();t&&e?.(t)}finally{l(!1)}}}(0,n.useEffect)(()=>{V().then(e=>{u(e)})},[]),(0,n.useEffect)(()=>{c&&U().then(p)},[c]);let m=(0,n.useCallback)(async()=>{await navigator.clipboard.writeText(er.join("\n")),s(!0),setTimeout(()=>s(!1),2e3)},[]),v=(0,n.useCallback)(()=>{u(!0)},[]),x=(0,n.useCallback)(()=>{p(null),U().then(p)},[]);return null===c?null:(0,t.jsx)("div",{"data-testid":"control-center-empty-state",className:(0,d.cn)("flex flex-col items-center justify-center",r),children:(0,t.jsx)("div",{className:"animate-in fade-in slide-in-from-bottom-2 w-96 rounded-2xl border border-white/30 bg-white/50 px-8 py-8 shadow-lg backdrop-blur-xl duration-300 dark:border-white/10 dark:bg-white/5",children:(0,t.jsxs)("div",{className:"flex flex-col items-center gap-4",children:[(0,t.jsxs)("div",{className:"mb-2 text-center",children:[(0,t.jsx)("h1",{className:"text-xl font-bold tracking-tight",children:"Features"}),(0,t.jsx)("p",{className:"text-muted-foreground text-sm font-light",children:"Control Center"})]}),c?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eo,{status:h,onRetry:x}),(0,t.jsxs)("div",{className:"text-muted-foreground flex items-center gap-2",children:[(0,t.jsx)(f,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{className:"text-[10px] font-semibold tracking-widest uppercase",children:"Repositories"})]}),(0,t.jsxs)("button",{type:"button","data-testid":"empty-state-add-repository",onClick:g,disabled:i,className:"border-border hover:border-foreground/40 flex w-full cursor-pointer items-center gap-2.5 rounded-md border border-dashed px-4 py-2.5 transition-colors disabled:cursor-wait disabled:opacity-50",children:[i?(0,t.jsx)(z.Loader2,{className:"text-muted-foreground h-4 w-4 animate-spin"}):(0,t.jsx)(a.Plus,{className:"text-muted-foreground h-4 w-4"}),(0,t.jsx)("span",{className:"text-xs font-medium",children:i?"Opening…":"Add Repository"})]}),(0,t.jsxs)("div",{className:"text-muted-foreground flex items-center gap-2",children:[(0,t.jsx)("div",{className:"bg-border h-px w-10"}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(I,{className:"h-3 w-3"}),(0,t.jsx)("span",{className:"text-[10px] font-semibold tracking-widest uppercase",children:"Or via CLI"})]}),(0,t.jsx)("div",{className:"bg-border h-px w-10"})]}),(0,t.jsxs)("div",{"data-testid":"cli-code-block",className:"relative w-full rounded-md bg-zinc-900 px-3 py-2 font-mono text-[11px] text-zinc-300",children:[(0,t.jsx)("button",{type:"button","data-testid":"cli-code-block-copy",onClick:m,className:"absolute top-2 right-2 cursor-pointer rounded p-1 text-zinc-500 transition-colors hover:bg-zinc-800 hover:text-zinc-300","aria-label":"Copy commands",children:o?(0,t.jsx)($.Check,{className:"h-3 w-3"}):(0,t.jsx)(F.Copy,{className:"h-3 w-3"})}),(0,t.jsx)("div",{className:"space-y-0.5",children:er.map(e=>(0,t.jsxs)("div",{className:"whitespace-nowrap",children:[(0,t.jsx)("span",{className:"text-zinc-500 select-none",children:"$ "}),(0,t.jsx)("span",{children:e})]},e))})]}),(0,t.jsx)("p",{className:"text-muted-foreground text-[10px]",children:"Feature will appear on canvas once created"})]}):(0,t.jsx)(et,{onComplete:v,className:"w-full"})]})})})}function eo({status:e,onRetry:r}){return e?e.installed&&e.authenticated?(0,t.jsxs)("div",{className:"animate-in fade-in flex w-full items-center gap-2 rounded-md bg-emerald-500/10 px-3 py-1.5",children:[(0,t.jsx)(B.CheckCircle2,{className:"h-3 w-3 text-emerald-600 dark:text-emerald-400"}),(0,t.jsxs)("span",{className:"text-[10px] text-emerald-700 dark:text-emerald-300",children:[e.label," ready"]})]}):e.installed?(0,t.jsxs)("div",{className:"flex w-full flex-col gap-2 rounded-md bg-amber-500/10 px-3 py-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(G.AlertCircle,{className:"h-3 w-3 text-amber-600 dark:text-amber-400"}),(0,t.jsxs)("span",{className:"text-[10px] font-medium text-amber-700 dark:text-amber-300",children:[e.label," needs authentication"]})]}),e.authCommand?(0,t.jsxs)("div",{className:"rounded bg-zinc-900 px-2 py-1 font-mono text-[10px] text-zinc-300",children:[(0,t.jsx)("span",{className:"text-zinc-500 select-none",children:"$ "}),e.authCommand]}):null,(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[e.binaryName?(0,t.jsxs)("button",{type:"button","data-testid":"auth-banner-open-terminal",onClick:async()=>{try{let t="claude-code"===e.agentType?"claude-code":e.agentType;await fetch(`/api/tools/${t}/launch`,{method:"POST"})}catch{}},className:"flex items-center gap-1 rounded border border-amber-600/30 px-2 py-0.5 text-[10px] font-medium text-amber-700 transition-colors hover:bg-amber-500/10 dark:text-amber-300",children:[(0,t.jsx)(g.Terminal,{className:"h-2.5 w-2.5"}),"Open ",e.label]}):null,(0,t.jsx)("button",{type:"button",onClick:r,className:"text-[10px] font-medium text-amber-700 underline underline-offset-2 hover:text-amber-900 dark:text-amber-300 dark:hover:text-amber-100",children:"Re-check"})]})]}):(0,t.jsxs)("div",{className:"flex w-full flex-col gap-2 rounded-md bg-amber-500/10 px-3 py-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(G.AlertCircle,{className:"h-3 w-3 text-amber-600 dark:text-amber-400"}),(0,t.jsxs)("span",{className:"text-[10px] font-medium text-amber-700 dark:text-amber-300",children:[e.label," not installed"]})]}),e.binaryName?(0,t.jsxs)("div",{className:"rounded bg-zinc-900 px-2 py-1 font-mono text-[10px] text-zinc-300",children:[(0,t.jsx)("span",{className:"text-zinc-500 select-none",children:"$ "}),"npm install -g ",e.binaryName]}):null,(0,t.jsx)("button",{type:"button",onClick:r,className:"self-start text-[10px] font-medium text-amber-700 underline underline-offset-2 hover:text-amber-900 dark:text-amber-300 dark:hover:text-amber-100",children:"Re-check"})]}):(0,t.jsxs)("div",{className:"bg-muted/50 flex w-full items-center gap-2 rounded-md px-3 py-1.5",children:[(0,t.jsx)(z.Loader2,{className:"text-muted-foreground h-3 w-3 animate-spin"}),(0,t.jsx)("span",{className:"text-muted-foreground text-[10px]",children:"Checking agent setup…"})]})}var ea=e.i(17840);let es={maxZoom:1,padding:.5,duration:500};function ei({initialNodes:e,initialEdges:a}){let s,i,d,l=(0,o.useRouter)(),c=(0,o.usePathname)(),u=(s=(0,o.usePathname)().match(/^\/feature\/([^/]+)/),s?.[1]??null),h=(0,T.useSoundAction)("click"),{guardedNavigate:f}=(0,L.useDrawerCloseGuard)(),{fitView:p}=(0,r.useReactFlow)(),g=(0,n.useRef)(null),{defaultViewport:m,onMoveEnd:v,resetViewport:x}=(i=(0,n.useRef)(function(){try{let e=localStorage.getItem(D);if(null==e)return A;let t=JSON.parse(e);return!(null==t||"object"!=typeof t||Array.isArray(t))&&"number"==typeof t.x&&"number"==typeof t.y&&"number"==typeof t.zoom&&Number.isFinite(t.x)&&Number.isFinite(t.y)&&Number.isFinite(t.zoom)&&t.zoom>0?t:A}catch{return A}}()).current,d=(0,n.useRef)(null),(0,n.useEffect)(()=>()=>{null!=d.current&&clearTimeout(d.current)},[]),{defaultViewport:i,onMoveEnd:(0,n.useCallback)(e=>{null!=d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{try{localStorage.setItem(D,JSON.stringify(e))}catch{}},500)},[]),resetViewport:(0,n.useCallback)(()=>{try{localStorage.removeItem(D)}catch{}return A},[])}),{nodes:b,edges:y,onNodesChange:w,handleConnect:E,handleAddRepository:k,handleDeleteFeature:j,handleDeleteRepository:N,createFeatureNode:C,setCallbacks:_}=(0,ea.useControlCenterState)(e,a),{setFeatures:O}=(0,P.useSidebarFeaturesContext)(),R=(0,n.useMemo)(()=>b.filter(e=>"featureNode"===e.type),[b]),M=(0,n.useMemo)(()=>R.map(e=>{let t=e.data;return`${t.featureId}:${t.state}:${t.name}`}).sort().join(","),[R]);(0,n.useEffect)(()=>{O(R.map(e=>{let t=e.data,r=(0,P.mapNodeStateToSidebarStatus)(t.state);return r?{featureId:t.featureId,name:t.name,status:r,...null!=t.startedAt&&{startedAt:t.startedAt},...null!=t.runtime&&{duration:t.runtime},...t.agentType&&{agentType:t.agentType},...t.modelId&&{modelId:t.modelId}}:null}).filter(Boolean))},[M,R,O]);let I=(0,n.useCallback)((e,t)=>{if("featureNode"===t.type){let r=t.data;"creating"!==r.state&&"deleting"!==r.state&&e.target.closest('[data-testid="feature-node-card"]')&&f(()=>{h.play(),l.push(`/feature/${r.featureId}`)})}},[l,h,f]),F=(0,n.useCallback)(()=>{h.play(),l.push("/create")},[l,h]),$=(0,n.useCallback)(e=>{h.play();let t=b.find(t=>t.id===e),r=t?.data?.repositoryPath;r?l.push(`/create?repo=${encodeURIComponent(r)}`):l.push("/create")},[b,l,h]),z=(0,n.useCallback)(e=>{let t=e.startsWith("feat-")?e.slice(5):e,r=y.find(t=>t.target===e),n=r?b.find(e=>e.id===r.source):null,o=n?.data?.repositoryPath;h.play();let a=new URLSearchParams;o&&a.set("repo",o),a.set("parent",t),l.push(`/create?${a.toString()}`)},[b,y,l,h]),B=(0,n.useCallback)(e=>{let t=b.find(t=>t.id===e);if(t?.type==="repositoryNode"){let e=t.data;e.id&&f(()=>l.push(`/repository/${e.id}`))}},[b,l,f]),G=(0,n.useCallback)(()=>{"/"!==c&&f(()=>l.push("/"))},[l,c,f]);(0,n.useEffect)(()=>{let e=e=>{let{wasEmpty:t,repoPath:r}=k(e.detail.path);t&&setTimeout(()=>{p(es),g.current=setTimeout(()=>{f(()=>l.push(`/create?repo=${encodeURIComponent(r)}`))},600)},0)};return window.addEventListener("shep:add-repository",e),()=>{window.removeEventListener("shep:add-repository",e),null!=g.current&&clearTimeout(g.current)}},[k,p,f,l]),(0,n.useEffect)(()=>{let e=e=>{let t=e.detail;if(t.parentId)return void C(`feat-${t.parentId}`,{state:"creating",featureId:t.featureId,name:t.name,description:t.description,repositoryPath:t.repositoryPath},"dependencyEdge");let r=b.find(e=>"repositoryNode"===e.type&&e.data.repositoryPath===t.repositoryPath);C(r?.id??null,{state:"running",featureId:t.featureId,name:t.name,description:t.description,repositoryPath:t.repositoryPath})};return window.addEventListener("shep:feature-created",e),()=>window.removeEventListener("shep:feature-created",e)},[b,C]),(0,n.useEffect)(()=>{_({onNodeAction:z,onFeatureDelete:j,onRepositoryAdd:$,onRepositoryClick:B,onRepositoryDelete:N})},[_,z,j,$,B,N]);let q=(0,n.useCallback)((e,t)=>{v(t)},[v]),W=b.some(e=>"repositoryNode"===e.type),[V,U]=(0,n.useState)(W),H=(0,n.useRef)(null);(0,n.useEffect)(()=>(W?(H.current&&(clearTimeout(H.current),H.current=null),U(!0)):V&&(H.current=setTimeout(()=>{U(!1),H.current=null},500)),()=>{H.current&&clearTimeout(H.current)}),[W,V]);let X=c.startsWith("/create"),K=(0,n.useMemo)(()=>{let e=b.filter(e=>"repositoryNode"===e.type),t=b.some(e=>"featureNode"===e.type);return 1!==e.length||t||X?b:b.map(e=>"repositoryNode"===e.type?{...e,data:{...e.data,pulseAdd:!0}}:e)},[b,X]);return(0,t.jsx)(S,{nodes:V?K:[],edges:V?y:[],selectedFeatureId:u,defaultViewport:m,onNodesChange:w,onConnect:E,onAddFeature:F,onNodeClick:I,onPaneClick:G,onMoveEnd:q,onResetViewport:x,emptyState:(0,t.jsx)(en,{onRepositorySelect:k})})}function ed({initialNodes:e,initialEdges:n,drawer:o}){return(0,t.jsxs)("div",{"data-testid":"control-center",className:"h-full w-full",children:[(0,t.jsx)(r.ReactFlowProvider,{children:(0,t.jsx)(ei,{initialNodes:e,initialEdges:n})}),(0,t.jsx)("div",{children:o},"drawer")]})}e.s(["ControlCenter",()=>ed],48246)}]);
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,17840,e=>{"use strict";var t=e.i(79054),r=e.i(31406),n=e.i(60112),o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),a=o((e,t)=>{var r=Object.defineProperty,n=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),o=(e,t,n)=>{let o;return(o="symbol"!=typeof t?t+"":t)in e?r(e,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[o]=n},a=n((e,t)=>{function r(e,t){e[t]?e[t]++:e[t]=1}function n(e,t){--e[t]||delete e[t]}function a(e,t,r,n){var o=""+t,a=""+r;if(!e&&o>a){var s=o;o=a,a=s}return o+"\x01"+a+"\x01"+(void 0===n?"\0":n)}function s(e,t){return a(e,t.v,t.w,t.name)}t.exports=class{constructor(e){o(this,"_isDirected",!0),o(this,"_isMultigraph",!1),o(this,"_isCompound",!1),o(this,"_label"),o(this,"_defaultNodeLabelFn",()=>{}),o(this,"_defaultEdgeLabelFn",()=>{}),o(this,"_nodes",{}),o(this,"_in",{}),o(this,"_preds",{}),o(this,"_out",{}),o(this,"_sucs",{}),o(this,"_edgeObjs",{}),o(this,"_edgeLabels",{}),o(this,"_nodeCount",0),o(this,"_edgeCount",0),o(this,"_parent"),o(this,"_children"),e&&(this._isDirected=!Object.hasOwn(e,"directed")||e.directed,this._isMultigraph=!!Object.hasOwn(e,"multigraph")&&e.multigraph,this._isCompound=!!Object.hasOwn(e,"compound")&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=e,"function"!=typeof e&&(this._defaultNodeLabelFn=()=>e),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var e=this;return this.nodes().filter(t=>0===Object.keys(e._in[t]).length)}sinks(){var e=this;return this.nodes().filter(t=>0===Object.keys(e._out[t]).length)}setNodes(e,t){var r=arguments,n=this;return e.forEach(function(e){r.length>1?n.setNode(e,t):n.setNode(e)}),this}setNode(e,t){return Object.hasOwn(this._nodes,e)?arguments.length>1&&(this._nodes[e]=t):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount),this}node(e){return this._nodes[e]}hasNode(e){return Object.hasOwn(this._nodes,e)}removeNode(e){var t=this;if(Object.hasOwn(this._nodes,e)){var r=e=>t.removeEdge(t._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(function(e){t.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(r),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(r),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error("Cannot set parent in a non-compound graph");if(void 0===t)t="\0";else{t+="";for(var r=t;void 0!==r;r=this.parent(r))if(r===e)throw Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}parent(e){if(this._isCompound){var t=this._parent[e];if("\0"!==t)return t}}children(e="\0"){if(this._isCompound){var t=this._children[e];if(t)return Object.keys(t)}else{if("\0"===e)return this.nodes();if(this.hasNode(e))return[]}}predecessors(e){var t=this._preds[e];if(t)return Object.keys(t)}successors(e){var t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){var t=this.predecessors(e);if(t){let n=new Set(t);for(var r of this.successors(e))n.add(r);return Array.from(n.values())}}isLeaf(e){return 0===(this.isDirected()?this.successors(e):this.neighbors(e)).length}filterNodes(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var r=this;Object.entries(this._nodes).forEach(function([r,n]){e(r)&&t.setNode(r,n)}),Object.values(this._edgeObjs).forEach(function(e){t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,r.edge(e))});var n={};return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,function e(o){var a=r.parent(o);return void 0===a||t.hasNode(a)?(n[o]=a,a):a in n?n[a]:e(a)}(e))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=e,"function"!=typeof e&&(this._defaultEdgeLabelFn=()=>e),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){var r=this,n=arguments;return e.reduce(function(e,o){return n.length>1?r.setEdge(e,o,t):r.setEdge(e,o),o}),this}setEdge(){var e,t,n,o,s=!1,i=arguments[0];"object"==typeof i&&null!==i&&"v"in i?(e=i.v,t=i.w,n=i.name,2==arguments.length&&(o=arguments[1],s=!0)):(e=i,t=arguments[1],n=arguments[3],arguments.length>2&&(o=arguments[2],s=!0)),e=""+e,t=""+t,void 0!==n&&(n=""+n);var d=a(this._isDirected,e,t,n);if(Object.hasOwn(this._edgeLabels,d))return s&&(this._edgeLabels[d]=o),this;if(void 0!==n&&!this._isMultigraph)throw Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(t),this._edgeLabels[d]=s?o:this._defaultEdgeLabelFn(e,t,n);var l=function(e,t,r,n){var o=""+t,a=""+r;if(!e&&o>a){var s=o;o=a,a=s}var i={v:o,w:a};return n&&(i.name=n),i}(this._isDirected,e,t,n);return e=l.v,t=l.w,Object.freeze(l),this._edgeObjs[d]=l,r(this._preds[t],e),r(this._sucs[e],t),this._in[t][d]=l,this._out[e][d]=l,this._edgeCount++,this}edge(e,t,r){var n=1==arguments.length?s(this._isDirected,arguments[0]):a(this._isDirected,e,t,r);return this._edgeLabels[n]}edgeAsObj(){let e=this.edge(...arguments);return"object"!=typeof e?{label:e}:e}hasEdge(e,t,r){var n=1==arguments.length?s(this._isDirected,arguments[0]):a(this._isDirected,e,t,r);return Object.hasOwn(this._edgeLabels,n)}removeEdge(e,t,r){var o=1==arguments.length?s(this._isDirected,arguments[0]):a(this._isDirected,e,t,r),i=this._edgeObjs[o];return i&&(e=i.v,t=i.w,delete this._edgeLabels[o],delete this._edgeObjs[o],n(this._preds[t],e),n(this._sucs[e],t),delete this._in[t][o],delete this._out[e][o],this._edgeCount--),this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}filterEdges(e,t,r){if(e){var n=Object.values(e);return r?n.filter(function(e){return e.v===t&&e.w===r||e.v===r&&e.w===t}):n}}}}),s=n((e,t)=>{t.exports="3.0.2"}),i=n((e,t)=>{t.exports={Graph:a(),version:s()}}),d=n((e,t)=>{var r=a();t.exports={write:function(e){var t,r,n={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:(t=e).nodes().map(function(e){var r=t.node(e),n=t.parent(e),o={v:e};return void 0!==r&&(o.value=r),void 0!==n&&(o.parent=n),o}),edges:(r=e).edges().map(function(e){var t=r.edge(e),n={v:e.v,w:e.w};return void 0!==e.name&&(n.name=e.name),void 0!==t&&(n.value=t),n})};return void 0!==e.graph()&&(n.value=structuredClone(e.graph())),n},read:function(e){var t=new r(e.options).setGraph(e.value);return e.nodes.forEach(function(e){t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(function(e){t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}}}),l=n((e,t)=>{t.exports=function(e,t,n,o){return function(e,t,r,n){var o={},a=!0,s=0,i=e.nodes(),d=function(e){var t=r(e);o[e.v].distance+t<o[e.w].distance&&(o[e.w]={distance:o[e.v].distance+t,predecessor:e.v},a=!0)},l=function(){i.forEach(function(e){n(e).forEach(function(t){var r=t.v===e?t.v:t.w,n=r===t.v?t.w:t.v;d({v:r,w:n})})})};i.forEach(function(e){o[e]={distance:e===t?0:1/0}});for(var c=i.length,u=1;u<c&&(a=!1,s++,l(),a);u++);if(s===c-1&&(a=!1,l(),a))throw Error("The graph contains a negative weight cycle");return o}(e,String(t),n||r,o||function(t){return e.outEdges(t)})};var r=()=>1}),c=n((e,t)=>{t.exports=function(e){var t,r={},n=[];return e.nodes().forEach(function(o){t=[],function n(o){Object.hasOwn(r,o)||(r[o]=!0,t.push(o),e.successors(o).forEach(n),e.predecessors(o).forEach(n))}(o),t.length&&n.push(t)}),n}}),u=n((e,t)=>{t.exports=class{constructor(){o(this,"_arr",[]),o(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(e){return e.key})}has(e){return Object.hasOwn(this._keyIndices,e)}priority(e){var t=this._keyIndices[e];if(void 0!==t)return this._arr[t].priority}min(){if(0===this.size())throw Error("Queue underflow");return this._arr[0].key}add(e,t){var r=this._keyIndices;if(!Object.hasOwn(r,e=String(e))){var n=this._arr,o=n.length;return r[e]=o,n.push({key:e,priority:t}),this._decrease(o),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){var r=this._keyIndices[e];if(t>this._arr[r].priority)throw Error("New priority is greater than current priority. Key: "+e+" Old: "+this._arr[r].priority+" New: "+t);this._arr[r].priority=t,this._decrease(r)}_heapify(e){var t=this._arr,r=2*e,n=r+1,o=e;r<t.length&&(o=t[r].priority<t[o].priority?r:o,n<t.length&&(o=t[n].priority<t[o].priority?n:o),o!==e&&(this._swap(e,o),this._heapify(o)))}_decrease(e){for(var t,r=this._arr,n=r[e].priority;0!==e&&!(r[t=e>>1].priority<n);)this._swap(e,t),e=t}_swap(e,t){var r=this._arr,n=this._keyIndices,o=r[e],a=r[t];r[e]=a,r[t]=o,n[a.key]=e,n[o.key]=t}}}),h=n((e,t)=>{var r=u();t.exports=function(e,t,o,a){return function(e,t,n,o){var a,s,i={},d=new r,l=function(e){var t=e.v!==a?e.v:e.w,r=i[t],o=n(e),l=s.distance+o;if(o<0)throw Error("dijkstra does not allow negative edge weights. Bad edge: "+e+" Weight: "+o);l<r.distance&&(r.distance=l,r.predecessor=a,d.decrease(t,l))};for(e.nodes().forEach(function(e){var r=e===t?0:1/0;i[e]={distance:r},d.add(e,r)});d.size()>0&&(s=i[a=d.removeMin()]).distance!==1/0;)o(a).forEach(l);return i}(e,String(t),o||n,a||function(t){return e.outEdges(t)})};var n=()=>1}),f=n((e,t)=>{var r=h();t.exports=function(e,t,n){return e.nodes().reduce(function(o,a){return o[a]=r(e,a,t,n),o},{})}}),p=n((e,t)=>{t.exports=function(e,t,r){if(void 0!==e[t].predecessor)throw Error("Invalid source vertex");if(void 0===e[r].predecessor&&r!==t)throw Error("Invalid destination vertex");return{weight:e[r].distance,path:function(e,t,r){for(var n=[],o=r;o!==t;)n.push(o),o=e[o].predecessor;return n.push(t),n.reverse()}(e,t,r)}}}),g=n((e,t)=>{t.exports=function(e){var t=0,r=[],n={},o=[];return e.nodes().forEach(function(a){Object.hasOwn(n,a)||function a(s){var i=n[s]={onStack:!0,lowlink:t,index:t++};if(r.push(s),e.successors(s).forEach(function(e){Object.hasOwn(n,e)?n[e].onStack&&(i.lowlink=Math.min(i.lowlink,n[e].index)):(a(e),i.lowlink=Math.min(i.lowlink,n[e].lowlink))}),i.lowlink===i.index){var d,l=[];do n[d=r.pop()].onStack=!1,l.push(d);while(s!==d)o.push(l)}}(a)}),o}}),m=n((e,t)=>{var r=g();t.exports=function(e){return r(e).filter(function(t){return t.length>1||1===t.length&&e.hasEdge(t[0],t[0])})}}),v=n((e,t)=>{t.exports=function(e,t,n){var o,a,s,i,d;return o=e,a=t||r,s=n||function(t){return e.outEdges(t)},i={},(d=o.nodes()).forEach(function(e){i[e]={},i[e][e]={distance:0},d.forEach(function(t){e!==t&&(i[e][t]={distance:1/0})}),s(e).forEach(function(t){var r=t.v===e?t.w:t.v,n=a(t);i[e][r]={distance:n,predecessor:e}})}),d.forEach(function(e){var t=i[e];d.forEach(function(r){var n=i[r];d.forEach(function(r){var o=n[e],a=t[r],s=n[r],i=o.distance+a.distance;i<s.distance&&(s.distance=i,s.predecessor=a.predecessor)})})}),i};var r=()=>1}),x=n((e,t)=>{function r(e){var t={},r={},o=[];if(e.sinks().forEach(function a(s){if(Object.hasOwn(r,s))throw new n;Object.hasOwn(t,s)||(r[s]=!0,t[s]=!0,e.predecessors(s).forEach(a),delete r[s],o.push(s))}),Object.keys(t).length!==e.nodeCount())throw new n;return o}var n=class extends Error{constructor(){super(...arguments)}};t.exports=r,r.CycleException=n}),b=n((e,t)=>{var r=x();t.exports=function(e){try{r(e)}catch(e){if(e instanceof r.CycleException)return!1;throw e}return!0}}),y=n((e,t)=>{t.exports=function(e,t,r,n,o){Array.isArray(t)||(t=[t]);var a=(e.isDirected()?e.successors:e.neighbors).bind(e),s={};return t.forEach(function(t){if(!e.hasNode(t))throw Error("Graph does not have node: "+t);o=function e(t,r,n,o,a,s,i){return Object.hasOwn(o,r)||(o[r]=!0,n||(i=s(i,r)),a(r).forEach(function(r){i=e(t,r,n,o,a,s,i)}),n&&(i=s(i,r))),i}(e,t,"post"===r,s,a,n,o)}),o}}),w=n((e,t)=>{var r=y();t.exports=function(e,t,n){return r(e,t,n,function(e,t){return e.push(t),e},[])}}),E=n((e,t)=>{var r=w();t.exports=function(e,t){return r(e,t,"post")}}),k=n((e,t)=>{var r=w();t.exports=function(e,t){return r(e,t,"pre")}}),j=n((e,t)=>{var r=a(),n=u();t.exports=function(e,t){var o,a=new r,s={},i=new n;function d(e){var r=e.v===o?e.w:e.v,n=i.priority(r);if(void 0!==n){var a=t(e);a<n&&(s[r]=o,i.decrease(r,a))}}if(0===e.nodeCount())return a;e.nodes().forEach(function(e){i.add(e,1/0),a.setNode(e)}),i.decrease(e.nodes()[0],0);for(var l=!1;i.size()>0;){if(Object.hasOwn(s,o=i.removeMin()))a.setEdge(o,s[o]);else{if(l)throw Error("Input graph is not connected: "+e);l=!0}e.nodeEdges(o).forEach(d)}return a}}),N=n((e,t)=>{var r=h(),n=l();t.exports=function(e,t,o,a){return function(e,t,o,a){if(void 0===o)return r(e,t,o,a);for(var s=!1,i=e.nodes(),d=0;d<i.length;d++){for(var l=a(i[d]),c=0;c<l.length;c++){var u=l[c],h=u.v===i[d]?u.v:u.w,f=h===u.v?u.w:u.v;0>o({v:h,w:f})&&(s=!0)}if(s)return n(e,t,o,a)}return r(e,t,o,a)}(e,t,o,a||function(t){return e.outEdges(t)})}}),C=n((e,t)=>{t.exports={bellmanFord:l(),components:c(),dijkstra:h(),dijkstraAll:f(),extractPath:p(),findCycles:m(),floydWarshall:v(),isAcyclic:b(),postorder:E(),preorder:k(),prim:j(),shortestPaths:N(),reduce:y(),tarjan:g(),topsort:x()}}),_=i();t.exports={Graph:_.Graph,json:d(),alg:C(),version:_.version}}),s=o((e,t)=>{function r(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function n(e,t){if("_next"!==e&&"_prev"!==e)return t}t.exports=class{constructor(){let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return r(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&r(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,r=t._prev;for(;r!==t;)e.push(JSON.stringify(r,n)),r=r._prev;return"["+e.join(", ")+"]"}}}),i=o((e,t)=>{var r=a().Graph,n=s();t.exports=function(e,t){var a,s;let l,c,u,h,f;if(1>=e.nodeCount())return[];let p=(a=e,s=t||o,l=new r,c=0,u=0,a.nodes().forEach(e=>{l.setNode(e,{v:e,in:0,out:0})}),a.edges().forEach(e=>{let t=l.edge(e.v,e.w)||0,r=s(e);l.setEdge(e.v,e.w,t+r),u=Math.max(u,l.node(e.v).out+=r),c=Math.max(c,l.node(e.w).in+=r)}),h=(function(e){let t=[];for(let r=0;r<e;r++)t.push(r);return t})(u+c+3).map(()=>new n),f=c+1,l.nodes().forEach(e=>{d(h,f,l.node(e))}),{graph:l,buckets:h,zeroIdx:f});return(function(e,t,r){let n=[],o=t[t.length-1],a=t[0],s;for(;e.nodeCount();){for(;s=a.dequeue();)i(e,t,r,s);for(;s=o.dequeue();)i(e,t,r,s);if(e.nodeCount()){for(let o=t.length-2;o>0;--o)if(s=t[o].dequeue()){n=n.concat(i(e,t,r,s,!0));break}}}return n})(p.graph,p.buckets,p.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w))};var o=()=>1;function i(e,t,r,n,o){let a=o?[]:void 0;return e.inEdges(n.v).forEach(n=>{let s=e.edge(n),i=e.node(n.v);o&&a.push({v:n.v,w:n.w}),i.out-=s,d(t,r,i)}),e.outEdges(n.v).forEach(n=>{let o=e.edge(n),a=n.w,s=e.node(a);s.in-=o,d(t,r,s)}),e.removeNode(n.v),a}function d(e,t,r){r.out?r.in?e[r.out-r.in+t].enqueue(r):e[e.length-1].enqueue(r):e[0].enqueue(r)}}),d=o((e,t)=>{var r=a().Graph;function n(e,t,r,n){for(var o=n;e.hasNode(o);)o=d(n);return r.dummy=t,e.setNode(o,r),o}t.exports={addBorderNode:function(e,t,r,o){let a={width:0,height:0};return arguments.length>=4&&(a.rank=r,a.order=o),n(e,"border",a,t)},addDummyNode:n,applyWithChunking:o,asNonCompoundGraph:function(e){let t=new r({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(r=>{e.children(r).length||t.setNode(r,e.node(r))}),e.edges().forEach(r=>{t.setEdge(r,e.edge(r))}),t},buildLayerMatrix:function(e){let t=l(s(e)+1).map(()=>[]);return e.nodes().forEach(r=>{let n=e.node(r),o=n.rank;void 0!==o&&(t[o][n.order]=r)}),t},intersectRect:function(e,t){let r,n,o=e.x,a=e.y,s=t.x-o,i=t.y-a,d=e.width/2,l=e.height/2;if(!s&&!i)throw Error("Not possible to find intersection inside of the rectangle");return Math.abs(i)*d>Math.abs(s)*l?(i<0&&(l=-l),r=l*s/i,n=l):(s<0&&(d=-d),r=d,n=d*i/s),{x:o+r,y:a+n}},mapValues:function(e,t){let r=t;return"string"==typeof t&&(r=e=>e[t]),Object.entries(e).reduce((e,[t,n])=>(e[t]=r(n,t),e),{})},maxRank:s,normalizeRanks:function(e){let t=o(Math.min,e.nodes().map(t=>{let r=e.node(t).rank;return void 0===r?Number.MAX_VALUE:r}));e.nodes().forEach(r=>{let n=e.node(r);Object.hasOwn(n,"rank")&&(n.rank-=t)})},notime:function(e,t){return t()},partition:function(e,t){let r={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?r.lhs.push(e):r.rhs.push(e)}),r},pick:function(e,t){let r={};for(let n of t)void 0!==e[n]&&(r[n]=e[n]);return r},predecessorWeights:function(e){let t=e.nodes().map(t=>{let r={};return e.inEdges(t).forEach(t=>{r[t.v]=(r[t.v]||0)+e.edge(t).weight}),r});return c(e.nodes(),t)},range:l,removeEmptyRanks:function(e){let t=o(Math.min,e.nodes().map(t=>e.node(t).rank).filter(e=>void 0!==e)),r=[];e.nodes().forEach(n=>{let o=e.node(n).rank-t;r[o]||(r[o]=[]),r[o].push(n)});let n=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,r)=>{void 0===t&&r%a!=0?--n:void 0!==t&&n&&t.forEach(t=>e.node(t).rank+=n)})},simplify:function(e){let t=new r().setGraph(e.graph());return e.nodes().forEach(r=>t.setNode(r,e.node(r))),e.edges().forEach(r=>{let n=t.edge(r.v,r.w)||{weight:0,minlen:1},o=e.edge(r);t.setEdge(r.v,r.w,{weight:n.weight+o.weight,minlen:Math.max(n.minlen,o.minlen)})}),t},successorWeights:function(e){let t=e.nodes().map(t=>{let r={};return e.outEdges(t).forEach(t=>{r[t.w]=(r[t.w]||0)+e.edge(t).weight}),r});return c(e.nodes(),t)},time:function(e,t){let r=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-r)+"ms")}},uniqueId:d,zipObject:c};function o(e,t){if(!(t.length>65535))return e.apply(null,t);{let r=function(e,t=65535){let r=[];for(let n=0;n<e.length;n+=t){let o=e.slice(n,n+t);r.push(o)}return r}(t);return e.apply(null,r.map(t=>e.apply(null,t)))}}function s(e){return o(Math.max,e.nodes().map(t=>{let r=e.node(t).rank;return void 0===r?5e-324:r}))}var i=0;function d(e){return e+""+ ++i}function l(e,t,r=1){null==t&&(t=e,e=0);let n=e=>e<t;r<0&&(n=e=>t<e);let o=[];for(let t=e;n(t);t+=r)o.push(t);return o}function c(e,t){return e.reduce((e,r,n)=>(e[r]=t[n],e),{})}}),l=o((e,t)=>{var r=i(),n=d().uniqueId;t.exports={run:function(e){var t,o;let a,s,i;("greedy"===e.graph().acyclicer?r(e,(t=e,e=>t.edge(e).weight)):(a=[],s={},i={},(o=e).nodes().forEach(function e(t){Object.hasOwn(i,t)||(i[t]=!0,s[t]=!0,o.outEdges(t).forEach(t=>{Object.hasOwn(s,t.w)?a.push(t):e(t.w)}),delete s[t])}),a)).forEach(t=>{let r=e.edge(t);e.removeEdge(t),r.forwardName=t.name,r.reversed=!0,e.setEdge(t.w,t.v,r,n("rev"))})},undo:function(e){e.edges().forEach(t=>{let r=e.edge(t);if(r.reversed){e.removeEdge(t);let n=r.forwardName;delete r.reversed,delete r.forwardName,e.setEdge(t.w,t.v,r,n)}})}}}),c=o((e,t)=>{var r=d();t.exports={run:function(e){e.graph().dummyChains=[],e.edges().forEach(t=>(function(e,t){let n,o,a,s=t.v,i=e.node(s).rank,d=t.w,l=e.node(d).rank,c=t.name,u=e.edge(t),h=u.labelRank;if(l!==i+1){for(e.removeEdge(t),a=0,++i;i<l;++a,++i)u.points=[],o={width:0,height:0,edgeLabel:u,edgeObj:t,rank:i},n=r.addDummyNode(e,"edge",o,"_d"),i===h&&(o.width=u.width,o.height=u.height,o.dummy="edge-label",o.labelpos=u.labelpos),e.setEdge(s,n,{weight:u.weight},c),0===a&&e.graph().dummyChains.push(n),s=n;e.setEdge(s,d,{weight:u.weight},c)}})(e,t))},undo:function(e){e.graph().dummyChains.forEach(t=>{let r=e.node(t),n=r.edgeLabel,o;for(e.setEdge(r.edgeObj,n);r.dummy;)o=e.successors(t)[0],e.removeNode(t),n.points.push({x:r.x,y:r.y}),"edge-label"===r.dummy&&(n.x=r.x,n.y=r.y,n.width=r.width,n.height=r.height),t=o,r=e.node(t)})}}}),u=o((e,t)=>{var{applyWithChunking:r}=d();t.exports={longestPath:function(e){var t={};e.sources().forEach(function n(o){var a=e.node(o);if(Object.hasOwn(t,o))return a.rank;t[o]=!0;var s=r(Math.min,e.outEdges(o).map(t=>null==t?1/0:n(t.w)-e.edge(t).minlen));return s===1/0&&(s=0),a.rank=s})},slack:function(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}}}),h=o((e,t)=>{var r=a().Graph,n=u().slack;t.exports=function(e){var t,o,a,s,i=new r({directed:!1}),d=e.nodes()[0],l=e.nodeCount();for(i.setNode(d,{});t=i,o=e,t.nodes().forEach(function e(r){o.nodeEdges(r).forEach(a=>{var s=a.v,i=r===s?a.w:s;t.hasNode(i)||n(o,a)||(t.setNode(i,{}),t.setEdge(r,i,{}),e(i))})}),t.nodeCount()<l;)a=function(e,t){return t.edges().reduce((r,o)=>{let a=1/0;return e.hasNode(o.v)!==e.hasNode(o.w)&&(a=n(t,o)),a<r[0]?[a,o]:r},[1/0,null])[1]}(i,e),s=i.hasNode(a.v)?n(e,a):-n(e,a),function(e,t,r){e.nodes().forEach(e=>t.node(e).rank+=r)}(i,e,s);return i}}),f=o((e,t)=>{var r=h(),n=u().slack,o=u().longestPath,s=a().alg.preorder,i=a().alg.postorder,l=d().simplify;function c(e){o(e=l(e));var t,n,a=r(e);for(g(a),f(a,e);t=m(a);)n=v(a,e,t),x(a,e,t,n)}function f(e,t){var r=i(e,e.nodes());(r=r.slice(0,r.length-1)).forEach(r=>{var n,o,a,s;return n=e,o=t,a=r,s=n.node(a).parent,void(n.edge(a,s).cutvalue=p(n,o,a))})}function p(e,t,r){var n=e.node(r).parent,o=!0,a=t.edge(r,n),s=0;return a||(o=!1,a=t.edge(n,r)),s=a.weight,t.nodeEdges(r).forEach(a=>{var i=a.v===r,d=i?a.w:a.v;if(d!==n){var l,c,u,h=i===o,f=t.edge(a).weight;if(s+=h?f:-f,l=e,c=r,u=d,l.hasEdge(c,u)){var p=e.edge(r,d).cutvalue;s+=h?-p:p}}}),s}function g(e,t){arguments.length<2&&(t=e.nodes()[0]),function e(t,r,n,o,a){var s=n,i=t.node(o);return r[o]=!0,t.neighbors(o).forEach(a=>{Object.hasOwn(r,a)||(n=e(t,r,n,a,o))}),i.low=s,i.lim=n++,a?i.parent=a:delete i.parent,n}(e,{},1,t)}function m(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function v(e,t,r){var o=r.v,a=r.w;t.hasEdge(o,a)||(o=r.w,a=r.v);var s=e.node(o),i=e.node(a),d=s,l=!1;return s.lim>i.lim&&(d=i,l=!0),t.edges().filter(t=>l===b(e,e.node(t.v),d)&&l!==b(e,e.node(t.w),d)).reduce((e,r)=>n(t,r)<n(t,e)?r:e)}function x(e,t,r,n){var o,a,i,d,l=r.v,c=r.w;e.removeEdge(l,c),e.setEdge(n.v,n.w,{}),g(e),f(e,t),o=e,a=t,i=o.nodes().find(e=>!a.node(e).parent),(d=(d=s(o,i)).slice(1)).forEach(e=>{var t=o.node(e).parent,r=a.edge(e,t),n=!1;r||(r=a.edge(t,e),n=!0),a.node(e).rank=a.node(t).rank+(n?r.minlen:-r.minlen)})}function b(e,t,r){return r.low<=t.lim&&t.lim<=r.lim}t.exports=c,c.initLowLimValues=g,c.initCutValues=f,c.calcCutValue=p,c.leaveEdge=m,c.enterEdge=v,c.exchangeEdges=x}),p=o((e,t)=>{var r=u().longestPath,n=h(),o=f();t.exports=function(e){var t,s=e.graph().ranker;if(s instanceof Function)return s(e);switch(e.graph().ranker){case"network-simplex":default:o(e);break;case"tight-tree":r(t=e),n(t);break;case"longest-path":a(e);case"none":}};var a=r}),g=o((e,t)=>{t.exports=function(e){var t;let r,n,o=(r={},n=0,(t=e).children().forEach(function e(o){let a=n;t.children(o).forEach(e),r[o]={low:a,lim:n++}}),r);e.graph().dummyChains.forEach(t=>{let r=e.node(t),n=r.edgeObj,a=function(e,t,r,n){let o=[],a=[],s=Math.min(t[r].low,t[n].low),i=Math.max(t[r].lim,t[n].lim),d,l;d=r;do o.push(d=e.parent(d));while(d&&(t[d].low>s||i>t[d].lim))for(l=d,d=n;(d=e.parent(d))!==l;)a.push(d);return{path:o.concat(a.reverse()),lca:l}}(e,o,n.v,n.w),s=a.path,i=a.lca,d=0,l=s[0],c=!0;for(;t!==n.w;){if(r=e.node(t),c){for(;(l=s[d])!==i&&e.node(l).maxRank<r.rank;)d++;l===i&&(c=!1)}if(!c){for(;d<s.length-1&&e.node(l=s[d+1]).minRank<=r.rank;)d++;l=s[d]}e.setParent(t,l),t=e.successors(t)[0]}})}}),m=o((e,t)=>{var r=d();t.exports={run:function(e){var t,n,o;let a=r.addDummyNode(e,"root",{},"_root"),s=(n={},(t=e).children().forEach(e=>(function e(r,o){var a=t.children(r);a&&a.length&&a.forEach(t=>e(t,o+1)),n[r]=o})(e,1)),n),i=Object.values(s),d=r.applyWithChunking(Math.max,i)-1,l=2*d+1;e.graph().nestingRoot=a,e.edges().forEach(t=>e.edge(t).minlen*=l);let c=(o=e).edges().reduce((e,t)=>e+o.edge(t).weight,0)+1;e.children().forEach(t=>(function e(t,n,o,a,s,i,d){let l=t.children(d);if(!l.length){d!==n&&t.setEdge(n,d,{weight:0,minlen:o});return}let c=r.addBorderNode(t,"_bt"),u=r.addBorderNode(t,"_bb"),h=t.node(d);t.setParent(c,d),h.borderTop=c,t.setParent(u,d),h.borderBottom=u,l.forEach(r=>{e(t,n,o,a,s,i,r);let l=t.node(r),h=l.borderTop?l.borderTop:r,f=l.borderBottom?l.borderBottom:r,p=l.borderTop?a:2*a,g=h!==f?1:s-i[d]+1;t.setEdge(c,h,{weight:p,minlen:g,nestingEdge:!0}),t.setEdge(f,u,{weight:p,minlen:g,nestingEdge:!0})}),t.parent(d)||t.setEdge(n,c,{weight:0,minlen:s+i[d]})})(e,a,l,c,d,s,t)),e.graph().nodeRankFactor=l},cleanup:function(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}}}),v=o((e,t)=>{var r=d();function n(e,t,n,o,a,s){let i=a[t][s-1],d=r.addDummyNode(e,"border",{width:0,height:0,rank:s,borderType:t},n);a[t][s]=d,e.setParent(d,o),i&&e.setEdge(i,d,{weight:1})}t.exports=function(e){e.children().forEach(function t(r){let o=e.children(r),a=e.node(r);if(o.length&&o.forEach(t),Object.hasOwn(a,"minRank")){a.borderLeft=[],a.borderRight=[];for(let t=a.minRank,o=a.maxRank+1;t<o;++t)n(e,"borderLeft","_bl",r,a,t),n(e,"borderRight","_br",r,a,t)}})}}),x=o((e,t)=>{function r(e){e.nodes().forEach(t=>n(e.node(t))),e.edges().forEach(t=>n(e.edge(t)))}function n(e){let t=e.width;e.width=e.height,e.height=t}function o(e){e.y=-e.y}function a(e){let t=e.x;e.x=e.y,e.y=t}t.exports={adjust:function(e){let t=e.graph().rankdir.toLowerCase();("lr"===t||"rl"===t)&&r(e)},undo:function(e){var t,n;let s=e.graph().rankdir.toLowerCase();("bt"===s||"rl"===s)&&((t=e).nodes().forEach(e=>o(t.node(e))),t.edges().forEach(e=>{let r=t.edge(e);r.points.forEach(o),Object.hasOwn(r,"y")&&o(r)})),("lr"===s||"rl"===s)&&((n=e).nodes().forEach(e=>a(n.node(e))),n.edges().forEach(e=>{let t=n.edge(e);t.points.forEach(a),Object.hasOwn(t,"x")&&a(t)}),r(e))}}}),b=o((e,t)=>{var r=d();t.exports=function(e){let t={},n=e.nodes().filter(t=>!e.children(t).length),o=n.map(t=>e.node(t).rank),a=r.applyWithChunking(Math.max,o),s=r.range(a+1).map(()=>[]);return n.sort((t,r)=>e.node(t).rank-e.node(r).rank).forEach(function r(n){t[n]||(t[n]=!0,s[e.node(n).rank].push(n),e.successors(n).forEach(r))}),s}}),y=o((e,t)=>{var r=d().zipObject;t.exports=function(e,t){let n=0;for(let o=1;o<t.length;++o)n+=function(e,t,n){let o=r(n,n.map((e,t)=>t)),a=t.flatMap(t=>e.outEdges(t).map(t=>({pos:o[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos)),s=1;for(;s<n.length;)s<<=1;let i=2*s-1;s-=1;let d=Array(i).fill(0),l=0;return a.forEach(e=>{let t=e.pos+s;d[t]+=e.weight;let r=0;for(;t>0;)t%2&&(r+=d[t+1]),t=t-1>>1,d[t]+=e.weight;l+=e.weight*r}),l}(e,t[o-1],t[o]);return n}}),w=o((e,t)=>{t.exports=function(e,t=[]){return t.map(t=>{let r=e.inEdges(t);if(!r.length)return{v:t};{let n=r.reduce((t,r)=>{let n=e.edge(r),o=e.node(r.v);return{sum:t.sum+n.weight*o.order,weight:t.weight+n.weight}},{sum:0,weight:0});return{v:t,barycenter:n.sum/n.weight,weight:n.weight}}})}}),E=o((e,t)=>{var r=d();t.exports=function(e,t){let n={};return e.forEach((e,t)=>{let r=n[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:t};void 0!==e.barycenter&&(r.barycenter=e.barycenter,r.weight=e.weight)}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];void 0!==t&&void 0!==r&&(r.indegree++,t.out.push(n[e.w]))}),function(e){let t=[];for(;e.length;){let r=e.pop();t.push(r),r.in.reverse().forEach(function(e){return t=>{t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&function(e,t){let r=0,n=0;e.weight&&(r+=e.barycenter*e.weight,n+=e.weight),t.weight&&(r+=t.barycenter*t.weight,n+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=r/n,e.weight=n,e.i=Math.min(t.i,e.i),t.merged=!0}(e,t)}}(r)),r.out.forEach(function(t){return r=>{r.in.push(t),0==--r.indegree&&e.push(r)}}(r))}return t.filter(e=>!e.merged).map(e=>r.pick(e,["vs","i","barycenter","weight"]))}(Object.values(n).filter(e=>!e.indegree))}}),k=o((e,t)=>{var r=d();function n(e,t,r){let n;for(;t.length&&(n=t[t.length-1]).i<=r;)t.pop(),e.push(n.vs),r++;return r}t.exports=function(e,t){var o;let a=r.partition(e,e=>Object.hasOwn(e,"barycenter")),s=a.lhs,i=a.rhs.sort((e,t)=>t.i-e.i),d=[],l=0,c=0,u=0;s.sort((o=!!t,(e,t)=>e.barycenter<t.barycenter?-1:e.barycenter>t.barycenter?1:o?t.i-e.i:e.i-t.i)),u=n(d,i,u),s.forEach(e=>{u+=e.vs.length,d.push(e.vs),l+=e.barycenter*e.weight,c+=e.weight,u=n(d,i,u)});let h={vs:d.flat(!0)};return c&&(h.barycenter=l/c,h.weight=c),h}}),j=o((e,t)=>{var r=w(),n=E(),o=k();t.exports=function e(t,a,s,i){var d,l;let c=t.children(a),u=t.node(a),h=u?u.borderLeft:void 0,f=u?u.borderRight:void 0,p={};h&&(c=c.filter(e=>e!==h&&e!==f));let g=r(t,c);g.forEach(r=>{if(t.children(r.v).length){var n,o;let a=e(t,r.v,s,i);p[r.v]=a,Object.hasOwn(a,"barycenter")&&(n=r,o=a,void 0!==n.barycenter?(n.barycenter=(n.barycenter*n.weight+o.barycenter*o.weight)/(n.weight+o.weight),n.weight+=o.weight):(n.barycenter=o.barycenter,n.weight=o.weight))}});let m=n(g,s);d=m,l=p,d.forEach(e=>{e.vs=e.vs.flatMap(e=>l[e]?l[e].vs:e)});let v=o(m,i);if(h&&(v.vs=[h,v.vs,f].flat(!0),t.predecessors(h).length)){let e=t.node(t.predecessors(h)[0]),r=t.node(t.predecessors(f)[0]);Object.hasOwn(v,"barycenter")||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+e.order+r.order)/(v.weight+2),v.weight+=2}return v}}),N=o((e,t)=>{var r=a().Graph,n=d();t.exports=function(e,t,o,a){a||(a=e.nodes());let s=function(e){for(var t;e.hasNode(t=n.uniqueId("_root")););return t}(e),i=new r({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(t=>e.node(t));return a.forEach(r=>{let n=e.node(r),a=e.parent(r);(n.rank===t||n.minRank<=t&&t<=n.maxRank)&&(i.setNode(r),i.setParent(r,a||s),e[o](r).forEach(t=>{let n=t.v===r?t.w:t.v,o=i.edge(n,r),a=void 0!==o?o.weight:0;i.setEdge(n,r,{weight:e.edge(t).weight+a})}),Object.hasOwn(n,"minRank")&&i.setNode(r,{borderLeft:n.borderLeft[t],borderRight:n.borderRight[t]}))}),i}}),C=o((e,t)=>{t.exports=function(e,t,r){let n={},o;r.forEach(r=>{let a=e.parent(r),s,i;for(;a;){if((s=e.parent(a))?(i=n[s],n[s]=a):(i=o,o=a),i&&i!==a)return void t.setEdge(i,a);a=s}})}}),_=o((e,t)=>{var r=b(),n=y(),o=j(),s=N(),i=C(),l=a().Graph,c=d();function u(e,t,r){let n=new Map,o=(e,t)=>{n.has(e)||n.set(e,[]),n.get(e).push(t)};for(let t of e.nodes()){let r=e.node(t);if("number"==typeof r.rank&&o(r.rank,t),"number"==typeof r.minRank&&"number"==typeof r.maxRank)for(let e=r.minRank;e<=r.maxRank;e++)e!==r.rank&&o(e,t)}return t.map(function(t){return s(e,t,r,n.get(t)||[])})}function h(e,t){Object.values(t).forEach(t=>t.forEach((t,r)=>e.node(t).order=r))}t.exports=function e(t,a={}){if("function"==typeof a.customOrder)return void a.customOrder(t,e);let s=c.maxRank(t),d=u(t,c.range(1,s+1),"inEdges"),f=u(t,c.range(s-1,-1,-1),"outEdges"),p=r(t);if(h(t,p),a.disableOptimalOrderHeuristic)return;let g=1/0,m,v=a.constraints||[];for(let e=0,r=0;r<4;++e,++r){(function(e,t,r){let n=new l;e.forEach(function(e){r.forEach(e=>n.setEdge(e.left,e.right));let a=e.graph().root,s=o(e,a,n,t);s.vs.forEach((t,r)=>e.node(t).order=r),i(e,n,s.vs)})})(e%2?d:f,e%4>=2,v),p=c.buildLayerMatrix(t);let a=n(t,p);a<g?(r=0,m=Object.assign({},p),g=a):a===g&&(m=structuredClone(p))}h(t,m)}}),O=o((e,t)=>{var r=a().Graph,n=d();function o(e,t){let r={};return t.length&&t.reduce(function(t,n){let o=0,a=0,s=t.length,d=n[n.length-1];return n.forEach((t,l)=>{let c=function(e,t){if(e.node(t).dummy)return e.predecessors(t).find(t=>e.node(t).dummy)}(e,t),u=c?e.node(c).order:s;(c||t===d)&&(n.slice(a,l+1).forEach(t=>{e.predecessors(t).forEach(n=>{let a=e.node(n),s=a.order;(s<o||u<s)&&!(a.dummy&&e.node(t).dummy)&&i(r,n,t)})}),a=l+1,o=u)}),n}),r}function s(e,t){let r={};function o(t,o,a,s,d){let l;n.range(o,a).forEach(n=>{l=t[n],e.node(l).dummy&&e.predecessors(l).forEach(t=>{let n=e.node(t);n.dummy&&(n.order<s||n.order>d)&&i(r,t,l)})})}return t.length&&t.reduce(function(t,r){let n=-1,a,s=0;return r.forEach((i,d)=>{if("border"===e.node(i).dummy){let t=e.predecessors(i);t.length&&(a=e.node(t[0]).order,o(r,s,d,n,a),s=d,n=a)}o(r,s,r.length,a,t.length)}),r}),r}function i(e,t,r){if(t>r){let e=t;t=r,r=e}let n=e[t];n||(e[t]=n={}),n[r]=!0}function l(e,t,r){if(t>r){let e=t;t=r,r=e}return!!e[t]&&Object.hasOwn(e[t],r)}function c(e,t,r,n){let o={},a={},s={};return t.forEach(e=>{e.forEach((e,t)=>{o[e]=e,a[e]=e,s[e]=t})}),t.forEach(e=>{let t=-1;e.forEach(e=>{let i=n(e);if(i.length){let n=((i=i.sort((e,t)=>s[e]-s[t])).length-1)/2;for(let d=Math.floor(n),c=Math.ceil(n);d<=c;++d){let n=i[d];a[e]===e&&t<s[n]&&!l(r,e,n)&&(a[n]=e,a[e]=o[e]=o[n],t=s[n])}}})}),{root:o,align:a}}function u(e,t,n,o,a){var s,i,d,l,c,u,h;let f,p,g,m={},v=(s=e,i=t,d=n,l=a,f=new r,g=(c=(p=s.graph()).nodesep,u=p.edgesep,h=l,(e,t,r)=>{let n=e.node(t),o=e.node(r),a,s;if(a=0+n.width/2,Object.hasOwn(n,"labelpos"))switch(n.labelpos.toLowerCase()){case"l":s=-n.width/2;break;case"r":s=n.width/2}if(s&&(a+=h?s:-s),s=0,a+=(n.dummy?u:c)/2,a+=(o.dummy?u:c)/2,a+=o.width/2,Object.hasOwn(o,"labelpos"))switch(o.labelpos.toLowerCase()){case"l":s=o.width/2;break;case"r":s=-o.width/2}return s&&(a+=h?s:-s),s=0,a}),i.forEach(e=>{let t;e.forEach(e=>{let r=d[e];if(f.setNode(r),t){var n=d[t],o=f.edge(n,r);f.setEdge(n,r,Math.max(g(s,e,t),o||0))}t=e})}),f),x=a?"borderLeft":"borderRight";function b(e,t){let r=v.nodes().slice(),n={},o=r.pop();for(;o;){if(n[o])e(o);else for(let e of(n[o]=!0,r.push(o),t(o)))r.push(e);o=r.pop()}}return b(function(e){m[e]=v.inEdges(e).reduce((e,t)=>Math.max(e,m[t.v]+v.edge(t)),0)},v.predecessors.bind(v)),b(function(t){let r=v.outEdges(t).reduce((e,t)=>Math.min(e,m[t.w]-v.edge(t)),1/0),n=e.node(t);r!==1/0&&n.borderType!==x&&(m[t]=Math.max(m[t],r))},v.successors.bind(v)),Object.keys(o).forEach(e=>m[e]=m[n[e]]),m}function h(e,t){return Object.values(t).reduce((t,r)=>{let n=-1/0,o=1/0;Object.entries(r).forEach(([t,r])=>{var a,s;let i=(a=e,s=t,a.node(s).width/2);n=Math.max(r+i,n),o=Math.min(r-i,o)});let a=n-o;return a<t[0]&&(t=[a,r]),t},[1/0,null])[1]}function f(e,t){let r=Object.values(t),o=n.applyWithChunking(Math.min,r),a=n.applyWithChunking(Math.max,r);["u","d"].forEach(r=>{["l","r"].forEach(s=>{let i=r+s,d=e[i];if(d===t)return;let l=Object.values(d),c=o-n.applyWithChunking(Math.min,l);"l"!==s&&(c=a-n.applyWithChunking(Math.max,l)),c&&(e[i]=n.mapValues(d,e=>e+c))})})}function p(e,t){return n.mapValues(e.ul,(r,n)=>{if(t)return e[t.toLowerCase()][n];{let t=Object.values(e).map(e=>e[n]).sort((e,t)=>e-t);return(t[1]+t[2])/2}})}t.exports={positionX:function(e){let t=n.buildLayerMatrix(e),r=Object.assign(o(e,t),s(e,t)),a={},i;["u","d"].forEach(o=>{i="u"===o?t:Object.values(t).reverse(),["l","r"].forEach(t=>{"r"===t&&(i=i.map(e=>Object.values(e).reverse()));let s=("u"===o?e.predecessors:e.successors).bind(e),d=c(e,i,r,s),l=u(e,i,d.root,d.align,"r"===t);"r"===t&&(l=n.mapValues(l,e=>-e)),a[o+t]=l})});let d=h(e,a);return f(a,d),p(a,e.graph().align)},findType1Conflicts:o,findType2Conflicts:s,addConflict:i,hasConflict:l,verticalAlignment:c,horizontalCompaction:u,alignCoordinates:f,findSmallestWidthAlignment:h,balance:p}}),R=o((e,t)=>{var r=d(),n=O().positionX;t.exports=function(e){var t;let o,a,s,i;t=e=r.asNonCompoundGraph(e),o=r.buildLayerMatrix(t),a=t.graph().ranksep,s=t.graph().rankalign,i=0,o.forEach(e=>{let r=e.reduce((e,r)=>{let n=t.node(r).height;return e>n?e:n},0);e.forEach(e=>{let n=t.node(e);"top"===s?n.y=i+n.height/2:"bottom"===s?n.y=i+r-n.height/2:n.y=i+r/2}),i+=r+a}),Object.entries(n(e)).forEach(([t,r])=>e.node(t).x=r)}}),M=o((e,t)=>{var r=l(),n=c(),o=p(),s=d().normalizeRanks,i=g(),u=d().removeEmptyRanks,h=m(),f=v(),b=x(),y=_(),w=R(),E=d(),k=a().Graph;t.exports=function(e,t={}){let a=t.debugTiming?E.time:E.notime;return a("layout",()=>{let d=a(" buildLayoutGraph",()=>{var t;let r,n;return t=e,r=new k({multigraph:!0,compound:!0}),n=D(t.graph()),r.setGraph(Object.assign({},N,L(n,j),E.pick(n,C))),t.nodes().forEach(e=>{let n=L(D(t.node(e)),O);Object.keys(M).forEach(e=>{void 0===n[e]&&(n[e]=M[e])}),r.setNode(e,n),r.setParent(e,t.parent(e))}),t.edges().forEach(e=>{let n=D(t.edge(e));r.setEdge(e,Object.assign({},P,L(n,S),E.pick(n,T)))}),r});return a(" runLayout",()=>{var e,l,c;return e=d,l=a,c=t,void(l(" makeSpaceForEdgeLabels",()=>{var t;let r;return r=(t=e).graph(),void(r.ranksep/=2,t.edges().forEach(e=>{let n=t.edge(e);n.minlen*=2,"c"!==n.labelpos.toLowerCase()&&("TB"===r.rankdir||"BT"===r.rankdir?n.width+=n.labeloffset:n.height+=n.labeloffset)}))}),l(" removeSelfEdges",()=>{var t;(t=e).edges().forEach(e=>{if(e.v===e.w){var r=t.node(e.v);r.selfEdges||(r.selfEdges=[]),r.selfEdges.push({e:e,label:t.edge(e)}),t.removeEdge(e)}})}),l(" acyclic",()=>r.run(e)),l(" nestingGraph.run",()=>h.run(e)),l(" rank",()=>o(E.asNonCompoundGraph(e))),l(" injectEdgeLabelProxies",()=>{var t;(t=e).edges().forEach(e=>{let r=t.edge(e);if(r.width&&r.height){let r=t.node(e.v),n={rank:(t.node(e.w).rank-r.rank)/2+r.rank,e:e};E.addDummyNode(t,"edge-proxy",n,"_ep")}})}),l(" removeEmptyRanks",()=>u(e)),l(" nestingGraph.cleanup",()=>h.cleanup(e)),l(" normalizeRanks",()=>s(e)),l(" assignRankMinMax",()=>{var t;let r;return r=0,void((t=e).nodes().forEach(e=>{let n=t.node(e);n.borderTop&&(n.minRank=t.node(n.borderTop).rank,n.maxRank=t.node(n.borderBottom).rank,r=Math.max(r,n.maxRank))}),t.graph().maxRank=r)}),l(" removeEdgeLabelProxies",()=>{var t;(t=e).nodes().forEach(e=>{let r=t.node(e);"edge-proxy"===r.dummy&&(t.edge(r.e).labelRank=r.rank,t.removeNode(e))})}),l(" normalize.run",()=>n.run(e)),l(" parentDummyChains",()=>i(e)),l(" addBorderSegments",()=>f(e)),l(" order",()=>y(e,c)),l(" insertSelfEdges",()=>{var t;return t=e,void E.buildLayerMatrix(t).forEach(e=>{var r=0;e.forEach((e,n)=>{var o=t.node(e);o.order=n+r,(o.selfEdges||[]).forEach(e=>{E.addDummyNode(t,"selfedge",{width:e.label.width,height:e.label.height,rank:o.rank,order:n+ ++r,e:e.e,label:e.label},"_se")}),delete o.selfEdges})})}),l(" adjustCoordinateSystem",()=>b.adjust(e)),l(" position",()=>w(e)),l(" positionSelfEdges",()=>{var t;(t=e).nodes().forEach(e=>{var r=t.node(e);if("selfedge"===r.dummy){var n=t.node(r.e.v),o=n.x+n.width/2,a=n.y,s=r.x-o,i=n.height/2;t.setEdge(r.e,r.label),t.removeNode(e),r.label.points=[{x:o+2*s/3,y:a-i},{x:o+5*s/6,y:a-i},{x:o+s,y:a},{x:o+5*s/6,y:a+i},{x:o+2*s/3,y:a+i}],r.label.x=r.x,r.label.y=r.y}})}),l(" removeBorderNodes",()=>{var t;(t=e).nodes().forEach(e=>{if(t.children(e).length){let r=t.node(e),n=t.node(r.borderTop),o=t.node(r.borderBottom),a=t.node(r.borderLeft[r.borderLeft.length-1]),s=t.node(r.borderRight[r.borderRight.length-1]);r.width=Math.abs(s.x-a.x),r.height=Math.abs(o.y-n.y),r.x=a.x+r.width/2,r.y=n.y+r.height/2}}),t.nodes().forEach(e=>{"border"===t.node(e).dummy&&t.removeNode(e)})}),l(" normalize.undo",()=>n.undo(e)),l(" fixupEdgeLabelCoords",()=>{var t;(t=e).edges().forEach(e=>{let r=t.edge(e);if(Object.hasOwn(r,"x"))switch(("l"===r.labelpos||"r"===r.labelpos)&&(r.width-=r.labeloffset),r.labelpos){case"l":r.x-=r.width/2+r.labeloffset;break;case"r":r.x+=r.width/2+r.labeloffset}})}),l(" undoCoordinateSystem",()=>b.undo(e)),l(" translateGraph",()=>(function(e){let t=1/0,r=0,n=1/0,o=0,a=e.graph(),s=a.marginx||0,i=a.marginy||0;function d(e){let a=e.x,s=e.y,i=e.width,d=e.height;t=Math.min(t,a-i/2),r=Math.max(r,a+i/2),n=Math.min(n,s-d/2),o=Math.max(o,s+d/2)}e.nodes().forEach(t=>d(e.node(t))),e.edges().forEach(t=>{let r=e.edge(t);Object.hasOwn(r,"x")&&d(r)}),t-=s,n-=i,e.nodes().forEach(r=>{let o=e.node(r);o.x-=t,o.y-=n}),e.edges().forEach(r=>{let o=e.edge(r);o.points.forEach(e=>{e.x-=t,e.y-=n}),Object.hasOwn(o,"x")&&(o.x-=t),Object.hasOwn(o,"y")&&(o.y-=n)}),a.width=r-t+s,a.height=o-n+i})(e)),l(" assignNodeIntersects",()=>{var t;(t=e).edges().forEach(e=>{let r=t.edge(e),n=t.node(e.v),o=t.node(e.w),a,s;r.points?(a=r.points[0],s=r.points[r.points.length-1]):(r.points=[],a=o,s=n),r.points.unshift(E.intersectRect(n,a)),r.points.push(E.intersectRect(o,s))})}),l(" reversePoints",()=>{var t;(t=e).edges().forEach(e=>{let r=t.edge(e);r.reversed&&r.points.reverse()})}),l(" acyclic.undo",()=>r.undo(e)))}),a(" updateInputGraph",()=>{var t,r;return t=e,r=d,void(t.nodes().forEach(e=>{let n=t.node(e),o=r.node(e);n&&(n.x=o.x,n.y=o.y,n.order=o.order,n.rank=o.rank,r.children(e).length&&(n.width=o.width,n.height=o.height))}),t.edges().forEach(e=>{let n=t.edge(e),o=r.edge(e);n.points=o.points,Object.hasOwn(o,"x")&&(n.x=o.x,n.y=o.y)}),t.graph().width=r.graph().width,t.graph().height=r.graph().height)}),d})};var j=["nodesep","edgesep","ranksep","marginx","marginy"],N={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb",rankalign:"center"},C=["acyclicer","ranker","rankdir","align","rankalign"],O=["width","height","rank"],M={width:0,height:0},S=["minlen","weight","width","height","labeloffset"],P={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},T=["labelpos"];function L(e,t){return E.mapValues(E.pick(e,t),Number)}function D(e){var t={};return e&&Object.entries(e).forEach(([e,r])=>{"string"==typeof e&&(e=e.toLowerCase()),t[e]=r}),t}}),S=o((e,t)=>{var r=d(),n=a().Graph;t.exports={debugOrdering:function(e){let t=r.buildLayerMatrix(e),o=new n({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(t=>{o.setNode(t,{label:t}),o.setParent(t,"layer"+e.node(t).rank)}),e.edges().forEach(e=>o.setEdge(e.v,e.w,{},e.name)),t.forEach((e,t)=>{o.setNode("layer"+t,{rank:"same"}),e.reduce((e,t)=>(o.setEdge(e,t,{style:"invis"}),t))}),o}}}),P=o((e,t)=>{t.exports="2.0.4"});let T=o((e,t)=>{t.exports={graphlib:a(),layout:M(),debug:S(),util:{time:d().time,notime:d().notime},version:P()}})(),L={direction:"LR",ranksep:200,nodesep:15},D={featureNode:{width:288,height:140},repositoryNode:{width:328,height:50}};function A(e,t){let r=e.data;return r&&"number"==typeof r.width&&"number"==typeof r.height?{width:r.width,height:r.height}:D[e.type??""]??t}function I(e,t,r={}){let{direction:n="TB",nodeSize:o={width:172,height:36},ranksep:a=80,nodesep:s=30}=r;if(0===e.length)return{nodes:[],edges:[]};let i=new T.graphlib.Graph({multigraph:!0});i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:n,ranksep:a,nodesep:s});let d=new Set;for(let e of t)d.add(e.source),d.add(e.target);let l=e.filter(e=>d.has(e.id)),c=e.filter(e=>!d.has(e.id));for(let e of l){let t=A(e,o);i.setNode(e.id,{width:t.width,height:t.height})}for(let e of t)i.hasNode(e.source)&&i.hasNode(e.target)&&i.setEdge(e.source,e.target,{},e.id);T.layout(i);let{targetPosition:u,sourcePosition:h}=function(e){switch(e){case"LR":return{targetPosition:"left",sourcePosition:"right"};case"RL":return{targetPosition:"right",sourcePosition:"left"};case"BT":return{targetPosition:"bottom",sourcePosition:"top"};default:return{targetPosition:"top",sourcePosition:"bottom"}}}(n),f="LR"===n||"RL"===n,p=new Map;for(let e of l){let t=i.node(e.id),r=A(e,o);p.set(e.id,{cx:t.x,cy:t.y,w:r.width,h:r.height})}let g=0;for(let e of p.values()){g=f?e.cx:e.cy;break}for(let e of c){let t=A(e,o);p.set(e.id,{cx:f?g:0,cy:f?0:g,w:t.width,h:t.height})}let m=new Map;for(let e of t)p.has(e.source)&&p.has(e.target)&&(m.has(e.source)||m.set(e.source,[]),m.get(e.source).push(e.target));let v=new Map;for(let t=0;t<e.length;t++)v.set(e[t].id,t);for(let[,e]of m)e.sort((e,t)=>(v.get(e)??0)-(v.get(t)??0));let x=new Set;for(let e of m.values())for(let t of e)x.add(t);let b=[...[...d].filter(e=>p.has(e)&&!x.has(e)),...c.map(e=>e.id)];b.sort((e,t)=>(v.get(e)??0)-(v.get(t)??0));let y=new Map;for(let e of b)!function e(t){if(y.has(t))return y.get(t);let r=p.get(t),n=f?r.h:r.w,o=m.get(t);if(!o||0===o.length)return y.set(t,n),n;let a=0;for(let t of o)a+=e(t);let i=Math.max(n,a+=(o.length-1)*s);return y.set(t,i),i}(e);let w=0;for(let e of b){let t=y.get(e)??0;!function e(t,r){let n=p.get(t);f?n.cy=r:n.cx=r;let o=m.get(t);if(!o||0===o.length)return;let a=0;for(let e of o)a+=y.get(e)??0;let i=r-(a+=(o.length-1)*s)/2;for(let t of o){let r=y.get(t)??0;e(t,i+r/2),i+=r+s}}(e,w+t/2),w+=t+s}let E=[];for(let t of e){let e=p.get(t.id);e&&E.push({...t,targetPosition:u,sourcePosition:h,position:{x:e.cx-e.w/2,y:e.cy-e.h/2}})}return{nodes:E,edges:[...t]}}var F=e.i(43650),$=e.i(21023);let z=(0,$.createServerReference)("40354e2a03e3f8992c96fb360a69c61f0b924fdc7f",$.callServer,void 0,$.findSourceMapURL,"addRepository"),B=(0,$.createServerReference)("400b212f0071830df29a1144bc7939cf5fa7b87ed5",$.callServer,void 0,$.findSourceMapURL,"deleteRepository"),G=(0,$.createServerReference)("402b3f4219fbf18d6dffa8e9be8c8adad05fa4d730",$.callServer,void 0,$.findSourceMapURL,"getFeatureMetadata"),q=(0,$.createServerReference)("005d2d91ec86464711a548b4dd4a606532ceab97a6",$.callServer,void 0,$.findSourceMapURL,"fetchGraphData");var W=e.i(39443),V=e.i(8361),U=e.i(18354),H=e.i(99045);function X(e,t){let r=new Map;for(let e of t)"dependencyEdge"===e.type&&r.set(e.target,e.source);let n=new Map,o=new Map;for(let t of e)"featureNode"===t.type?n.set(t.id,{nodeId:t.id,data:t.data,parentNodeId:r.get(t.id)}):"repositoryNode"===t.type&&o.set(t.id,{nodeId:t.id,data:t.data});return{featureMap:n,repoMap:o}}function K(e,t){return(void 0===t.state||t.state===e.state)&&(void 0===t.lifecycle||t.lifecycle===e.lifecycle)&&(void 0===t.name||t.name===e.name)&&(void 0===t.description||t.description===e.description)}let Y=(0,U.createLogger)("[Polling]"),J=0,Q=0;function Z(e,o){let a=(0,r.useRouter)(),s=(0,V.useSoundAction)("delete"),i=(0,V.useSoundAction)("create"),{nodes:d,edges:l,reconcile:c,updateFeature:u,addPendingFeature:h,removeFeature:f,restoreFeature:p,addRepository:g,removeRepository:m,replaceRepository:v,getFeatureRepositoryPath:x,getRepositoryData:b,getRepoMapSize:y,setCallbacks:w}=function(e,r){let n=(0,t.useMemo)(()=>X(e,r),[]),[o,a]=(0,t.useState)(n.featureMap),[s,i]=(0,t.useState)(n.repoMap),[d,l]=(0,t.useState)(new Map),c=(0,t.useRef)(new Map),u=(0,t.useRef)(new Set),h=(0,t.useRef)(new Set),f=(0,t.useRef)({}),p=(0,t.useMemo)(()=>({onNodeAction:e=>f.current.onNodeAction?.(e),onNodeSettings:e=>f.current.onNodeSettings?.(e),onFeatureDelete:e=>f.current.onFeatureDelete?.(e),onRepositoryAdd:e=>f.current.onRepositoryAdd?.(e),onRepositoryClick:e=>f.current.onRepositoryClick?.(e),onRepositoryDelete:e=>f.current.onRepositoryDelete?.(e)}),[]),g=(0,t.useRef)(o);g.current=o;let m=(0,t.useRef)(s);m.current=s;let v=(0,t.useMemo)(()=>(function(e,t,r,n){let o=[],a=[],s=new Map;for(let[e,r]of t)r.data.repositoryPath&&s.set(r.data.repositoryPath,e);let i=new Map;for(let[e,r]of[...t.entries()].sort((e,t)=>(e[1].data.createdAt??0)-(t[1].data.createdAt??0))){let t={...r.data,...n?.onRepositoryAdd&&{onAdd:()=>n.onRepositoryAdd(e)},...n?.onRepositoryClick&&{onClick:()=>n.onRepositoryClick(e)},...n?.onRepositoryDelete&&{onDelete:n.onRepositoryDelete}};o.push({id:e,type:"repositoryNode",position:{x:0,y:0},data:t})}for(let[t,d,l]of[...[...e.entries()].map(([e,t])=>[e,t,!1]),...[...r.entries()].filter(([t])=>!e.has(t)).map(([e,t])=>[e,t,!0])]){let e="creating"===d.data.state||l,r={...d.data,...!e&&n?.onNodeAction&&{onAction:()=>n.onNodeAction(t)},...!e&&n?.onNodeSettings&&{onSettings:()=>n.onNodeSettings(t)},...!e&&n?.onFeatureDelete&&{onDelete:n.onFeatureDelete}};if(o.push({id:t,type:"featureNode",position:{x:0,y:0},data:r}),d.parentNodeId)a.push({id:`dep-${d.parentNodeId}-${t}`,source:d.parentNodeId,target:t,type:"dependencyEdge"});else{let e=d.data.repositoryPath,r=s.get(e)??function(e){if(i.has(e))return i.get(e);let t=`virtual-repo-${e}`,r=e.split("/").filter(Boolean).at(-1)??e;return o.push({id:t,type:"repositoryNode",position:{x:0,y:0},data:{name:r,repositoryPath:e}}),i.set(e,t),t}(e);a.push({id:`edge-${r}-${t}`,source:r,target:t,style:{strokeDasharray:"5 5"}})}}let d=a.length>0;for(let e of o)e.data.showHandles=d;return{nodes:o,edges:a}})(o,s,d,p),[o,s,d,p]),x=(0,t.useRef)({key:"",positions:new Map}),{nodes:b,edges:y}=(0,t.useMemo)(()=>{let e=v.nodes.map(e=>e.id).sort().join(","),t=v.edges.map(e=>`${e.source}-${e.target}`).sort().join(","),r=`${e}|${t}`;if(r!==x.current.key){let e=I(v.nodes,v.edges,L),t=new Map;for(let r of e.nodes)t.set(r.id,{position:r.position,targetPosition:r.targetPosition,sourcePosition:r.sourcePosition});let n=x.current.positions;if(n.size>0){let r=0,o=0;for(let[e,a]of t){let t=n.get(e);if(t){r=t.position.x-a.position.x,o=t.position.y-a.position.y;break}}if(0!==r||0!==o){for(let e of t.values())e.position={x:e.position.x+r,y:e.position.y+o};for(let t of e.nodes)t.position={x:t.position.x+r,y:t.position.y+o}}}return x.current={key:r,positions:t},e}let{positions:n}=x.current;return{nodes:v.nodes.map(e=>{let t=n.get(e.id);return t?{...e,...t}:e}),edges:v.edges}},[v]),w=(0,t.useCallback)((e,t)=>{let{featureMap:r,repoMap:n}=X(e,t),o=new Set([...r.values()].map(e=>`${e.data.name}\0${e.data.repositoryPath}`));a(e=>{let t=[...e.entries()].filter(([,e])=>"creating"===e.data.state),n=new Map(r);for(let[e,r]of t){let t=`${r.data.name}\0${r.data.repositoryPath}`;o.has(t)||n.set(e,r)}let a=new Set;for(let[t,r]of e)"deleting"===r.data.state&&(n.has(t)?n.set(t,{...n.get(t),data:{...n.get(t).data,state:"deleting"}}):h.current.has(t)||(n.set(t,r),a.add(t)));for(let[e,t]of(h.current=a,c.current)){let r=n.get(e);r&&(n.set(e,{...r,data:{...r.data,...t}}),c.current.delete(e))}return n}),l(e=>{if(0===e.size)return e;let t=!1,r=new Map(e);for(let[n,a]of e){let e=`${a.data.name}\0${a.data.repositoryPath}`;o.has(e)&&(r.delete(n),t=!0)}return t?r:e}),i(e=>{let t=new Map(n),r=new Set([...n.values()].map(e=>e.data.repositoryPath));for(let[n,o]of e){if(t.has(n)||r.has(o.data.repositoryPath)){u.current.delete(n);continue}(n.startsWith("repo-temp-")||u.current.has(n))&&t.set(n,o)}return t})},[]),E=(0,t.useCallback)((e,t)=>{a(r=>{let n=r.get(e);if(!n)return c.current.set(e,{...c.current.get(e),...t}),r;if(c.current.delete(e),K(n.data,t))return r;let o=new Map(r);return o.set(e,{...n,data:{...n.data,...t}}),o}),l(r=>{let n=r.get(e);if(!n||K(n.data,t))return r;let o=new Map(r);return o.set(e,{...n,data:{...n.data,...t}}),o})},[]),k=(0,t.useCallback)((e,t,r)=>{l(n=>{let o=new Map(n);return o.set(e,{nodeId:e,data:t,parentNodeId:r}),o})},[]),j=(0,t.useCallback)(e=>{l(t=>{if(!t.has(e))return t;let r=new Map(t);return r.delete(e),r})},[]),N=(0,t.useCallback)(e=>{a(t=>{if(!t.has(e))return t;let r=new Map(t);return r.delete(e),r})},[]),C=(0,t.useCallback)((e,t)=>{a(r=>{let n=new Map(r);return n.set(e,t),n})},[]),_=(0,t.useCallback)((e,t)=>{u.current.add(e),i(r=>{let n=new Map(r);return n.set(e,{nodeId:e,data:t}),n})},[]),O=(0,t.useCallback)(e=>{u.current.delete(e),i(t=>{if(!t.has(e))return t;let r=new Map(t);return r.delete(e),r})},[]),R=(0,t.useCallback)((e,t,r)=>{u.current.delete(e),u.current.add(t),i(n=>{if(!n.has(e))return n;let o=new Map(n);return o.delete(e),o.set(t,{nodeId:t,data:r}),o})},[]),M=(0,t.useCallback)(e=>g.current.get(e)?.data.repositoryPath,[]),S=(0,t.useCallback)(e=>m.current.get(e)?.data,[]);return{nodes:b,edges:y,reconcile:w,updateFeature:E,addPendingFeature:k,removePendingFeature:j,removeFeature:N,restoreFeature:C,addRepository:_,removeRepository:O,replaceRepository:R,getFeatureRepositoryPath:M,getRepositoryData:S,getRepoMapSize:(0,t.useCallback)(()=>m.current.size,[]),setCallbacks:(0,t.useCallback)(e=>{f.current=e},[])}}(e,o),E=(0,t.useRef)(d),k=(0,t.useRef)(l);(0,t.useEffect)(()=>{E.current=d,k.current=l},[d,l]);let j=(0,t.useMemo)(()=>e.map(e=>e.id).sort().join(","),[e]),N=(0,t.useMemo)(()=>e.filter(e=>"featureNode"===e.type).map(e=>{let t=e.data;return`${e.id}:${t.state}:${t.lifecycle}`}).sort().join(","),[e]),C=(0,t.useRef)("");(0,t.useEffect)(()=>{let t=`${j}|${N}`;t!==C.current&&(C.current=t,c(e,o))},[j,N,e,o,c]);let _=(0,t.useRef)(new Map),{events:O}=(0,W.useAgentEventsContext)();(0,t.useEffect)(()=>{let t=_.current;for(let r of e){if("featureNode"!==r.type)continue;let e=r.data,o=t.get(r.id);void 0!==o&&o!==e.state&&(O.some(t=>t.featureId===e.featureId&&(0,H.mapEventTypeToState)(t.eventType)===e.state)||("done"===e.state?n.toast.success(e.name,{description:"Feature completed!"}):"action-required"===e.state?n.toast.warning(e.name,{description:"Waiting for your approval",action:{label:"Review",onClick:()=>a.push(`/feature/${e.featureId}`)}}):"error"===e.state&&n.toast.error(e.name,{description:e.errorMessage??"Agent failed"}))),t.set(r.id,e.state)}},[N,e,O,a]);let R=(0,t.useRef)(0);(0,t.useEffect)(()=>{if(R.current>O.length&&(R.current=0),O.length<=R.current)return;let e=O.slice(R.current);for(let{featureId:t,state:r,lifecycle:n}of(R.current=O.length,(0,H.resolveSseEventUpdates)(e)))if(void 0!==r||void 0!==n){let e=`feat-${t}`,o=E.current.find(t=>t.id===e);if(o&&"deleting"===o.data.state)continue;u(e,{...void 0!==r&&{state:r},...void 0!==n&&{lifecycle:n}})}},[O,u]),(0,t.useEffect)(()=>{let e=e=>{let{featureId:t}=e.detail;u(`feat-${t}`,{state:"running"})};return window.addEventListener("shep:feature-approved",e),()=>window.removeEventListener("shep:feature-approved",e)},[u]);let M=(0,t.useRef)(new Set),S=(0,t.useRef)(0);(0,t.useEffect)(()=>{if(S.current>O.length&&(S.current=0),O.length<=S.current)return;let e=O.slice(S.current);for(let t of(S.current=O.length,e)){if("Feature metadata updated"!==t.message||M.current.has(t.featureId))continue;M.current.add(t.featureId);let e=`feat-${t.featureId}`;G(t.featureId).then(t=>{t&&u(e,{name:t.name,description:t.description})}).catch(()=>{})}},[O,u]),(0,t.useEffect)(()=>{Y.debug("polling enabled (3000ms interval)");let e=setInterval(async()=>{try{let{nodes:e,edges:t}=await q();c(e,t)}catch{Y.warn("poll fetch failed — will retry next interval")}},3e3);return()=>{Y.debug("polling disabled"),clearInterval(e)}},[c]);let P=(0,t.useCallback)(e=>{},[]),T=(0,t.useCallback)(e=>{},[]),D=(0,t.useCallback)((e,t,r)=>{let n=t?.featureId?`feat-${t.featureId}`:`feature-${Date.now()}-${J++}`,o={name:t?.name??"New Feature",description:t?.description??"Describe what this feature does",featureId:t?.featureId??`#${n.slice(-4)}`,lifecycle:"requirements",state:t?.state??"running",progress:0,repositoryPath:t?.repositoryPath??"",branch:t?.branch??""};return h(n,o,"dependencyEdge"===r&&e?e:void 0),n},[h]),A=(0,t.useCallback)((e,t)=>{let r=`feat-${e}`,o=[],i=[r];for(;i.length>0;){let e=i.shift();for(let t of k.current)"dependencyEdge"===t.type&&t.source===e&&(o.push(t.target),i.push(t.target))}let d=new Map;for(let e of[r,...o]){let t=E.current.find(t=>t.id===e);t&&d.set(e,t.data.state)}for(let e of(u(r,{state:"deleting"}),o))u(e,{state:"deleting"});s.play(),a.push("/"),(0,F.deleteFeature)(e,t).then(e=>{if(e.error){for(let[e,t]of d)t&&u(e,{state:t});n.toast.error(e.error)}else for(let e of(f(r),o))f(e)}).catch(()=>{for(let[e,t]of d)t&&u(e,{state:t});n.toast.error("Failed to delete feature")})},[a,s,u,f]),$=(0,t.useCallback)(async e=>{let t=`repo-${e}`,r=new Set(k.current.filter(e=>e.source===t).map(e=>e.target)),o=b(t),a=new Map;for(let e of r){let t=E.current.find(t=>t.id===e);t&&a.set(e,{nodeId:e,data:t.data})}let i=()=>{for(let[e,r]of(o&&g(t,o),a))p(e,r)};for(let e of(m(t),r))f(e);try{let t=await B(e);if(!t.success){n.toast.error(t.error??"Failed to remove repository"),i();return}s.play()}catch{n.toast.error("Failed to remove repository"),i()}},[s,m,f,g,p,b]),U=(0,t.useCallback)(e=>{let t=I(E.current,k.current,{...L,direction:e});c(t.nodes,t.edges)},[c]);return{nodes:d,edges:l,onNodesChange:P,handleConnect:T,handleAddRepository:(0,t.useCallback)(e=>{let t=0===y(),r=`repo-temp-${++Q}`,o=e.replace(/[\\/]+$/,"").split(/[\\/]/).pop()??e;return g(r,{name:o,repositoryPath:e,id:r,createdAt:Date.now()}),z({path:e,name:o}).then(e=>{if(e.error){m(r),n.toast.error(e.error);return}let t=e.repository;v(r,`repo-${t.id}`,{name:t.name,repositoryPath:t.path,id:t.id,createdAt:t.createdAt instanceof Date?t.createdAt.getTime():Number(t.createdAt)}),i.play()}).catch(()=>{m(r),n.toast.error("Failed to add repository")}),{wasEmpty:t,repoPath:e}},[g,m,v,i,y]),handleLayout:U,handleDeleteFeature:A,handleDeleteRepository:$,createFeatureNode:D,getFeatureRepositoryPath:x,getRepositoryData:b,setCallbacks:w}}e.s(["useControlCenterState",()=>Z],17840)},48246,e=>{"use strict";var t=e.i(20314),r=e.i(53271),n=e.i(79054),o=e.i(31406),a=e.i(3214),s=e.i(3645);let i=(0,s.default)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);var d=e.i(31777),l=e.i(35364);e.i(54793);var c=e.i(7729);e.i(47506);var u=e.i(89313),h=e.i(92002);let f=(0,s.default)("github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);var p=e.i(8986),g=e.i(38573),m=e.i(19933),v=e.i(67669),x=e.i(24042),b=e.i(64970);e.i(81803);var y=e.i(72714),w=e.i(2287),E=e.i(2828);e.i(99348);var k=e.i(17466),j=e.i(8537),N=e.i(75921),C=e.i(76852);function _({data:e}){let o=(0,N.useFeatureFlags)(),[s,i]=(0,n.useState)(!1),c=(0,C.useRepositoryActions)(e.repositoryPath?{repositoryPath:e.repositoryPath}:null),u=(0,j.useDeployAction)(e.repositoryPath?{targetId:e.repositoryPath,targetType:"repository",repositoryPath:e.repositoryPath}:null),_="Booting"===u.status||"Ready"===u.status;return(0,t.jsxs)("div",{className:(0,d.cn)("group relative",e.onDelete&&e.id&&"pl-10"),children:[e.showHandles?(0,t.jsx)(r.Handle,{type:"target",position:h.Position.Left,isConnectable:!1,className:"opacity-0!"}):null,e.onDelete&&e.id?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"absolute top-1/2 left-0 -translate-y-1/2 opacity-0 transition-opacity group-hover:opacity-100",children:(0,t.jsx)(E.TooltipProvider,{children:(0,t.jsxs)(E.Tooltip,{children:[(0,t.jsx)(E.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("button",{"aria-label":"Remove repository","data-testid":"repository-node-delete-button",onClick:e=>{e.stopPropagation(),i(!0)},className:"bg-card text-muted-foreground hover:border-destructive hover:text-destructive flex h-7 w-7 cursor-pointer items-center justify-center rounded-full border shadow-sm transition-colors",children:(0,t.jsx)(v.Trash2,{className:"h-3.5 w-3.5"})})}),(0,t.jsx)(E.TooltipContent,{children:"Remove repository"})]})})}),(0,t.jsx)(w.Dialog,{open:s,onOpenChange:i,children:(0,t.jsxs)(w.DialogContent,{className:"max-w-xs",children:[(0,t.jsxs)(w.DialogHeader,{children:[(0,t.jsx)(w.DialogTitle,{children:"Remove repository?"}),(0,t.jsxs)(w.DialogDescription,{children:["This will remove ",(0,t.jsx)("strong",{children:e.name})," and all its features from your workspace. The repository files on disk won't be affected."]})]}),(0,t.jsxs)(w.DialogFooter,{className:"grid grid-cols-2 gap-2 sm:flex-none",children:[(0,t.jsx)(w.DialogClose,{asChild:!0,children:(0,t.jsx)(l.Button,{variant:"outline",children:"Cancel"})}),(0,t.jsx)(l.Button,{variant:"destructive",onClick:()=>{i(!1),e.onDelete?.(e.id)},children:"Remove"})]})]})})]}):null,(0,t.jsxs)("div",{role:"button",tabIndex:0,"data-testid":"repository-node-card","data-repo-name":e.name,onClick:t=>{t.stopPropagation(),e.onClick?.()},onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),t.stopPropagation(),e.onClick?.())},className:"nodrag bg-card flex min-w-[18rem] cursor-pointer items-center gap-3 rounded-full border px-4 py-3 shadow-sm",children:[(0,t.jsx)(f,{className:"text-muted-foreground h-5 w-5 shrink-0"}),(0,t.jsx)("span",{"data-testid":"repository-node-name",className:"min-w-0 truncate text-sm font-medium",children:e.name}),(0,t.jsxs)("div",{className:(0,d.cn)("flex shrink-0 items-center gap-2",(e.repositoryPath??e.onAdd)&&"ml-auto"),onClick:e=>e.stopPropagation(),children:[e.repositoryPath?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(E.TooltipProvider,{children:(0,t.jsxs)(E.Tooltip,{children:[(0,t.jsx)(E.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(y.ActionButton,{label:"Open in IDE",onClick:c.openInIde,loading:c.ideLoading,error:!!c.ideError,icon:p.Code2,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(E.TooltipContent,{children:"Open in IDE"})]})}),(0,t.jsx)(E.TooltipProvider,{children:(0,t.jsxs)(E.Tooltip,{children:[(0,t.jsx)(E.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(y.ActionButton,{label:"Open in Shell",onClick:c.openInShell,loading:c.shellLoading,error:!!c.shellError,icon:g.Terminal,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(E.TooltipContent,{children:"Open in Shell"})]})}),(0,t.jsx)(E.TooltipProvider,{children:(0,t.jsxs)(E.Tooltip,{children:[(0,t.jsx)(E.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(y.ActionButton,{label:"Open Folder",onClick:c.openFolder,loading:c.folderLoading,error:!!c.folderError,icon:m.FolderOpen,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(E.TooltipContent,{children:"Open Folder"})]})}),o.envDeploy?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(E.TooltipProvider,{children:(0,t.jsxs)(E.Tooltip,{children:[(0,t.jsx)(E.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(y.ActionButton,{label:_?"Stop Dev Server":"Start Dev Server",onClick:_?u.stop:u.deploy,loading:u.deployLoading||u.stopLoading,error:!!u.deployError,icon:_?b.Square:x.Play,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(E.TooltipContent,{children:_?"Stop Dev Server":"Start Dev Server"})]})}),_?(0,t.jsx)(k.DeploymentStatusBadge,{status:u.status,url:u.url,targetId:e.repositoryPath}):null]}):null]}):null,e.onAdd?(0,t.jsx)(E.TooltipProvider,{children:(0,t.jsxs)(E.Tooltip,{children:[(0,t.jsx)(E.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("button",{"aria-label":"Add feature","data-testid":"repository-node-add-button",onClick:t=>{t.stopPropagation(),e.onAdd?.()},className:(0,d.cn)("text-muted-foreground hover:bg-accent dark:hover:bg-accent/50 flex h-6 w-6 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors hover:text-blue-500",e.pulseAdd&&"animate-pulse-cta bg-blue-100 text-blue-500 dark:bg-blue-900/40"),children:(0,t.jsx)(a.Plus,{className:"h-3.5 w-3.5"})})}),(0,t.jsx)(E.TooltipContent,{children:"Add feature"})]})}):null]})]}),e.onAdd||e.showHandles?(0,t.jsx)(r.Handle,{type:"source",position:h.Position.Right,isConnectable:!e.showHandles,className:"opacity-0!"}):null]})}function O(e){let[n]=(0,h.getBezierPath)({sourceX:e.sourceX,sourceY:e.sourceY,targetX:e.targetX,targetY:e.targetY,sourcePosition:e.sourcePosition,targetPosition:e.targetPosition});return(0,t.jsx)(r.BaseEdge,{id:e.id,path:n,style:{strokeDasharray:"5 5"}})}e.i(1650),e.i(45811),e.i(25235);let R={x:30,y:30,zoom:.85};function M({onResetViewport:e}){let{setViewport:o}=(0,r.useReactFlow)(),a=(0,n.useCallback)(()=>{o(e(),{duration:400})},[e,o]);return(0,t.jsx)(r.ControlButton,{onClick:a,title:"Reset view","aria-label":"Reset view",children:(0,t.jsx)(i,{style:{fill:"none"}})})}function S({nodes:e,edges:o,selectedFeatureId:s,defaultViewport:i,onNodesChange:h,onAddFeature:f,onConnect:p,onNodeClick:g,onPaneClick:m,onCanvasDrag:v,onMoveEnd:x,onResetViewport:b,toolbar:y,emptyState:w}){let E=(0,n.useMemo)(()=>({featureNode:u.FeatureNode,repositoryNode:_}),[]),k=(0,n.useMemo)(()=>({dependencyEdge:O}),[]),j=(0,n.useMemo)(()=>null==s?e:e.map(e=>"featureNode"===e.type&&e.data.featureId===s?{...e,selected:!0}:e),[e,s]),N=0===e.length,[C,S]=(0,n.useState)(N),[P,T]=(0,n.useState)(!1),L=(0,n.useRef)(N);(0,n.useEffect)(()=>{if(L.current&&!N){T(!0);let e=setTimeout(()=>{S(!1),T(!1)},300);return L.current=N,()=>clearTimeout(e)}!L.current&&N&&S(!0),L.current=N},[N]);let D=N&&!w?(0,t.jsx)(c.EmptyState,{title:"No features yet",description:"Get started by creating your first feature.",action:(0,t.jsxs)(l.Button,{onClick:f,children:[(0,t.jsx)(a.Plus,{className:"mr-2 h-4 w-4"}),"New Feature"]})}):null,A=w??D;return(0,t.jsxs)("div",{"data-testid":N?"features-canvas-empty":"features-canvas","data-no-drawer-close":!0,className:"dark:bg-background pointer-events-auto relative h-full w-full bg-[#f6f7f8]",children:[(0,t.jsxs)(r.ReactFlow,{nodes:j,edges:o,nodeTypes:E,edgeTypes:k,onConnect:p,onNodesChange:h,onNodeClick:g,onPaneClick:m,onMoveStart:v,onMoveEnd:x,defaultViewport:i??R,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,proOptions:{hideAttribution:!0},children:[(0,t.jsx)(r.Background,{variant:r.BackgroundVariant.Dots,gap:24,size:1,color:"#b8bcc4",className:"dark:[&_circle]:!fill-white/[0.1]"}),!N&&(0,t.jsx)(r.Controls,{showInteractive:!1,children:b?(0,t.jsx)(M,{onResetViewport:b}):null}),y]}),C&&A?(0,t.jsx)("div",{className:(0,d.cn)("pointer-events-none absolute inset-0 z-10 flex items-center justify-center transition-opacity duration-300",P?"opacity-0":"animate-in fade-in opacity-100 duration-200"),children:(0,t.jsx)("div",{className:"pointer-events-auto",children:A})}):null]})}var P=e.i(5147),T=e.i(8361),L=e.i(30153);let D="shep-canvas-viewport",A={x:30,y:30,zoom:.85},I=(0,s.default)("square-terminal",[["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"}]]);var F=e.i(33548),$=e.i(23925),z=e.i(83428),B=e.i(35e3),G=e.i(79687),q=e.i(78521),W=e.i(21023);let V=(0,W.createServerReference)("009a5b1dd03add7d9a6fd6eac70640ba64c51dcc8a",W.callServer,void 0,W.findSourceMapURL,"isAgentSetupComplete"),U=(0,W.createServerReference)("00a3887493a145362644060b92f0410f7cae04fe2b",W.callServer,void 0,W.findSourceMapURL,"checkAgentAuth");var H=e.i(76016),X=e.i(11345),K=e.i(26370),Y=e.i(66747),J=e.i(18271),Q=e.i(86782),Z=e.i(29847);let ee=["select-agent","select-model"];function et({onComplete:e,className:r}){let o,[a,s]=(0,n.useState)([]),[i,l]=(0,n.useState)(!0),[c,u]=(0,n.useState)("select-agent"),[h,f]=(0,n.useState)(null),[p,g]=(0,n.useState)(!1),[m,v]=(0,n.useState)(!1),[x,b]=(0,n.useState)(!0),y=(0,n.useRef)(void 0);(0,n.useEffect)(()=>{(0,Y.getAllAgentModels)().then(s).finally(()=>l(!1))},[]);let w=h?a.find(e=>e.agentType===h):null,E=(0,n.useCallback)((e,t)=>{v(!0),b(!1),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{t?.(),u(e),requestAnimationFrame(()=>{b(!0),v(!1)})},150)},[]);(0,n.useEffect)(()=>()=>{y.current&&clearTimeout(y.current)},[]);let k=(0,n.useCallback)(async(t,r)=>{g(!0);try{await (0,J.updateAgentAndModel)(t,r),e()}finally{g(!1)}},[e]),j=(0,n.useCallback)(e=>{let t=a.find(t=>t.agentType===e);t&&t.models.length>0?E("select-model",()=>{f(e)}):k(e,null)},[a,E,k]),N=(0,n.useCallback)(e=>{h&&k(h,e)},[h,k]),C=(0,n.useCallback)(()=>{"select-model"===c&&E("select-agent",()=>{f(null)})},[c,E]);if(i)return(0,t.jsxs)("div",{"data-testid":"welcome-agent-setup",className:(0,d.cn)("flex flex-col items-center justify-center gap-3",r),children:[(0,t.jsx)(z.Loader2,{className:"text-muted-foreground h-4 w-4 animate-spin"}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:"Loading agents…"})]});let _=ee.indexOf(c);return(0,t.jsxs)("div",{"data-testid":"welcome-agent-setup",className:(0,d.cn)("flex flex-col items-center gap-4","w-72",r),children:[(0,t.jsx)("div",{className:"flex flex-col items-center gap-1",children:(0,t.jsxs)("div",{className:"text-muted-foreground flex items-center gap-2",children:["select-agent"===c&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(K.Bot,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{className:"text-[10px] font-semibold tracking-widest uppercase",children:"Choose your agent"})]}),"select-model"===c&&w?(o=(0,Q.getAgentTypeIcon)(w.agentType),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o,{className:"h-3.5 w-3.5"}),(0,t.jsxs)("span",{className:"text-[10px] font-semibold tracking-widest uppercase",children:[w.label," — Pick a model"]})]})):null]})}),(0,t.jsx)("div",{className:"flex w-full items-center gap-1",children:ee.map((e,r)=>(0,t.jsx)("div",{className:(0,d.cn)("h-0.5 flex-1 rounded-full transition-colors duration-300",r<=_?"bg-foreground/60":"bg-muted")},e))}),(0,t.jsxs)("div",{className:(0,d.cn)("flex w-full flex-col items-center transition-opacity duration-150",x&&!m?"opacity-100":"opacity-0"),children:["select-agent"===c&&(0,t.jsx)("div",{"data-testid":"agent-list",className:"flex w-full flex-col gap-1.5",children:a.map(e=>{let r=(0,Q.getAgentTypeIcon)(e.agentType);return(0,t.jsxs)("button",{type:"button",disabled:p,"data-testid":`agent-option-${e.agentType}`,className:"border-border hover:border-foreground/40 flex w-full cursor-pointer items-center gap-2.5 rounded-md border border-dashed px-4 py-2.5 transition-colors disabled:opacity-50",onClick:()=>j(e.agentType),children:[(0,t.jsx)(r,{className:"text-muted-foreground h-4 w-4 shrink-0"}),(0,t.jsx)("span",{className:"flex-1 text-left text-xs font-medium",children:e.label}),(0,t.jsx)(H.ChevronRight,{className:"text-muted-foreground h-3 w-3"})]},e.agentType)})}),"select-model"===c&&w?(0,t.jsxs)("div",{"data-testid":"model-list",className:"flex w-full flex-col gap-1.5",children:[(0,t.jsxs)("button",{type:"button",disabled:p,className:"text-muted-foreground hover:text-foreground mb-0.5 flex cursor-pointer items-center gap-1 self-start text-[10px] font-medium transition-colors",onClick:C,children:[(0,t.jsx)(X.ChevronLeft,{className:"h-3 w-3"}),"Back"]}),(0,t.jsx)("div",{className:"flex max-h-48 w-full flex-col gap-1.5 overflow-y-auto",children:w.models.map(e=>{let r=(0,Z.getModelMeta)(e.id);return(0,t.jsxs)("button",{type:"button",disabled:p,"data-testid":`model-option-${e.id}`,className:"border-border hover:border-foreground/40 flex w-full cursor-pointer items-center gap-2.5 rounded-md border border-dashed px-4 py-2.5 text-left transition-colors disabled:opacity-50",onClick:()=>N(e.id),children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[(0,t.jsx)("span",{className:"text-xs font-medium",children:r.displayName||e.displayName}),(0,t.jsx)("span",{className:"text-muted-foreground text-[10px] leading-tight",children:r.description||e.description})]}),(0,t.jsx)(H.ChevronRight,{className:"text-muted-foreground h-3 w-3 shrink-0"})]},e.id)})})]}):null]})]})}let er=["cd ~/my-repo",'shep feat new "sleek dashboard"'];function en({onRepositorySelect:e,className:r}){let[o,s]=(0,n.useState)(!1),[i,l]=(0,n.useState)(!1),[c,u]=(0,n.useState)(null),[h,p]=(0,n.useState)(null);async function g(){if(!i){l(!0);try{let t=await (0,q.pickFolder)();t&&e?.(t)}finally{l(!1)}}}(0,n.useEffect)(()=>{V().then(e=>{u(e)})},[]),(0,n.useEffect)(()=>{c&&U().then(p)},[c]);let m=(0,n.useCallback)(async()=>{await navigator.clipboard.writeText(er.join("\n")),s(!0),setTimeout(()=>s(!1),2e3)},[]),v=(0,n.useCallback)(()=>{u(!0)},[]),x=(0,n.useCallback)(()=>{p(null),U().then(p)},[]);return null===c?null:(0,t.jsx)("div",{"data-testid":"control-center-empty-state",className:(0,d.cn)("flex flex-col items-center justify-center",r),children:(0,t.jsx)("div",{className:"animate-in fade-in slide-in-from-bottom-2 w-96 rounded-2xl border border-white/30 bg-white/50 px-8 py-8 shadow-lg backdrop-blur-xl duration-300 dark:border-white/10 dark:bg-white/5",children:(0,t.jsxs)("div",{className:"flex flex-col items-center gap-4",children:[(0,t.jsxs)("div",{className:"mb-2 text-center",children:[(0,t.jsx)("h1",{className:"text-xl font-bold tracking-tight",children:"Features"}),(0,t.jsx)("p",{className:"text-muted-foreground text-sm font-light",children:"Control Center"})]}),c?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eo,{status:h,onRetry:x}),(0,t.jsxs)("div",{className:"text-muted-foreground flex items-center gap-2",children:[(0,t.jsx)(f,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{className:"text-[10px] font-semibold tracking-widest uppercase",children:"Repositories"})]}),(0,t.jsxs)("button",{type:"button","data-testid":"empty-state-add-repository",onClick:g,disabled:i,className:"border-border hover:border-foreground/40 flex w-full cursor-pointer items-center gap-2.5 rounded-md border border-dashed px-4 py-2.5 transition-colors disabled:cursor-wait disabled:opacity-50",children:[i?(0,t.jsx)(z.Loader2,{className:"text-muted-foreground h-4 w-4 animate-spin"}):(0,t.jsx)(a.Plus,{className:"text-muted-foreground h-4 w-4"}),(0,t.jsx)("span",{className:"text-xs font-medium",children:i?"Opening…":"Add Repository"})]}),(0,t.jsxs)("div",{className:"text-muted-foreground flex items-center gap-2",children:[(0,t.jsx)("div",{className:"bg-border h-px w-10"}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)(I,{className:"h-3 w-3"}),(0,t.jsx)("span",{className:"text-[10px] font-semibold tracking-widest uppercase",children:"Or via CLI"})]}),(0,t.jsx)("div",{className:"bg-border h-px w-10"})]}),(0,t.jsxs)("div",{"data-testid":"cli-code-block",className:"relative w-full rounded-md bg-zinc-900 px-3 py-2 font-mono text-[11px] text-zinc-300",children:[(0,t.jsx)("button",{type:"button","data-testid":"cli-code-block-copy",onClick:m,className:"absolute top-2 right-2 cursor-pointer rounded p-1 text-zinc-500 transition-colors hover:bg-zinc-800 hover:text-zinc-300","aria-label":"Copy commands",children:o?(0,t.jsx)($.Check,{className:"h-3 w-3"}):(0,t.jsx)(F.Copy,{className:"h-3 w-3"})}),(0,t.jsx)("div",{className:"space-y-0.5",children:er.map(e=>(0,t.jsxs)("div",{className:"whitespace-nowrap",children:[(0,t.jsx)("span",{className:"text-zinc-500 select-none",children:"$ "}),(0,t.jsx)("span",{children:e})]},e))})]}),(0,t.jsx)("p",{className:"text-muted-foreground text-[10px]",children:"Feature will appear on canvas once created"})]}):(0,t.jsx)(et,{onComplete:v,className:"w-full"})]})})})}function eo({status:e,onRetry:r}){return e?e.installed&&e.authenticated?(0,t.jsxs)("div",{className:"animate-in fade-in flex w-full items-center gap-2 rounded-md bg-emerald-500/10 px-3 py-1.5",children:[(0,t.jsx)(B.CheckCircle2,{className:"h-3 w-3 text-emerald-600 dark:text-emerald-400"}),(0,t.jsxs)("span",{className:"text-[10px] text-emerald-700 dark:text-emerald-300",children:[e.label," ready"]})]}):e.installed?(0,t.jsxs)("div",{className:"flex w-full flex-col gap-2 rounded-md bg-amber-500/10 px-3 py-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(G.AlertCircle,{className:"h-3 w-3 text-amber-600 dark:text-amber-400"}),(0,t.jsxs)("span",{className:"text-[10px] font-medium text-amber-700 dark:text-amber-300",children:[e.label," needs authentication"]})]}),e.authCommand?(0,t.jsxs)("div",{className:"rounded bg-zinc-900 px-2 py-1 font-mono text-[10px] text-zinc-300",children:[(0,t.jsx)("span",{className:"text-zinc-500 select-none",children:"$ "}),e.authCommand]}):null,(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[e.binaryName?(0,t.jsxs)("button",{type:"button","data-testid":"auth-banner-open-terminal",onClick:async()=>{try{let t="claude-code"===e.agentType?"claude-code":e.agentType;await fetch(`/api/tools/${t}/launch`,{method:"POST"})}catch{}},className:"flex items-center gap-1 rounded border border-amber-600/30 px-2 py-0.5 text-[10px] font-medium text-amber-700 transition-colors hover:bg-amber-500/10 dark:text-amber-300",children:[(0,t.jsx)(g.Terminal,{className:"h-2.5 w-2.5"}),"Open ",e.label]}):null,(0,t.jsx)("button",{type:"button",onClick:r,className:"text-[10px] font-medium text-amber-700 underline underline-offset-2 hover:text-amber-900 dark:text-amber-300 dark:hover:text-amber-100",children:"Re-check"})]})]}):(0,t.jsxs)("div",{className:"flex w-full flex-col gap-2 rounded-md bg-amber-500/10 px-3 py-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(G.AlertCircle,{className:"h-3 w-3 text-amber-600 dark:text-amber-400"}),(0,t.jsxs)("span",{className:"text-[10px] font-medium text-amber-700 dark:text-amber-300",children:[e.label," not installed"]})]}),e.binaryName?(0,t.jsxs)("div",{className:"rounded bg-zinc-900 px-2 py-1 font-mono text-[10px] text-zinc-300",children:[(0,t.jsx)("span",{className:"text-zinc-500 select-none",children:"$ "}),"npm install -g ",e.binaryName]}):null,(0,t.jsx)("button",{type:"button",onClick:r,className:"self-start text-[10px] font-medium text-amber-700 underline underline-offset-2 hover:text-amber-900 dark:text-amber-300 dark:hover:text-amber-100",children:"Re-check"})]}):(0,t.jsxs)("div",{className:"bg-muted/50 flex w-full items-center gap-2 rounded-md px-3 py-1.5",children:[(0,t.jsx)(z.Loader2,{className:"text-muted-foreground h-3 w-3 animate-spin"}),(0,t.jsx)("span",{className:"text-muted-foreground text-[10px]",children:"Checking agent setup…"})]})}var ea=e.i(17840);let es={maxZoom:1,padding:.5,duration:500};function ei({initialNodes:e,initialEdges:a}){let s,i,d,l=(0,o.useRouter)(),c=(0,o.usePathname)(),u=(s=(0,o.usePathname)().match(/^\/feature\/([^/]+)/),s?.[1]??null),h=(0,T.useSoundAction)("click"),{guardedNavigate:f}=(0,L.useDrawerCloseGuard)(),{fitView:p}=(0,r.useReactFlow)(),g=(0,n.useRef)(null),{defaultViewport:m,onMoveEnd:v,resetViewport:x}=(i=(0,n.useRef)(function(){try{let e=localStorage.getItem(D);if(null==e)return A;let t=JSON.parse(e);return!(null==t||"object"!=typeof t||Array.isArray(t))&&"number"==typeof t.x&&"number"==typeof t.y&&"number"==typeof t.zoom&&Number.isFinite(t.x)&&Number.isFinite(t.y)&&Number.isFinite(t.zoom)&&t.zoom>0?t:A}catch{return A}}()).current,d=(0,n.useRef)(null),(0,n.useEffect)(()=>()=>{null!=d.current&&clearTimeout(d.current)},[]),{defaultViewport:i,onMoveEnd:(0,n.useCallback)(e=>{null!=d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{try{localStorage.setItem(D,JSON.stringify(e))}catch{}},500)},[]),resetViewport:(0,n.useCallback)(()=>{try{localStorage.removeItem(D)}catch{}return A},[])}),{nodes:b,edges:y,onNodesChange:w,handleConnect:E,handleAddRepository:k,handleDeleteFeature:j,handleDeleteRepository:N,createFeatureNode:C,setCallbacks:_}=(0,ea.useControlCenterState)(e,a),{setFeatures:O}=(0,P.useSidebarFeaturesContext)(),R=(0,n.useMemo)(()=>b.filter(e=>"featureNode"===e.type),[b]),M=(0,n.useMemo)(()=>R.map(e=>{let t=e.data;return`${t.featureId}:${t.state}:${t.name}`}).sort().join(","),[R]);(0,n.useEffect)(()=>{O(R.map(e=>{let t=e.data,r=(0,P.mapNodeStateToSidebarStatus)(t.state);return r?{featureId:t.featureId,name:t.name,status:r,...null!=t.startedAt&&{startedAt:t.startedAt},...null!=t.runtime&&{duration:t.runtime},...t.agentType&&{agentType:t.agentType},...t.modelId&&{modelId:t.modelId}}:null}).filter(Boolean))},[M,R,O]);let I=(0,n.useCallback)((e,t)=>{if("featureNode"===t.type){let r=t.data;"creating"!==r.state&&"deleting"!==r.state&&e.target.closest('[data-testid="feature-node-card"]')&&f(()=>{h.play(),l.push(`/feature/${r.featureId}`)})}},[l,h,f]),F=(0,n.useCallback)(()=>{h.play(),l.push("/create")},[l,h]),$=(0,n.useCallback)(e=>{h.play();let t=b.find(t=>t.id===e),r=t?.data?.repositoryPath;r?l.push(`/create?repo=${encodeURIComponent(r)}`):l.push("/create")},[b,l,h]),z=(0,n.useCallback)(e=>{let t=e.startsWith("feat-")?e.slice(5):e,r=y.find(t=>t.target===e),n=r?b.find(e=>e.id===r.source):null,o=n?.data?.repositoryPath;h.play();let a=new URLSearchParams;o&&a.set("repo",o),a.set("parent",t),l.push(`/create?${a.toString()}`)},[b,y,l,h]),B=(0,n.useCallback)(e=>{let t=b.find(t=>t.id===e);if(t?.type==="repositoryNode"){let e=t.data;e.id&&f(()=>l.push(`/repository/${e.id}`))}},[b,l,f]),G=(0,n.useCallback)(()=>{"/"!==c&&f(()=>l.push("/"))},[l,c,f]);(0,n.useEffect)(()=>{let e=e=>{let{wasEmpty:t,repoPath:r}=k(e.detail.path);t&&setTimeout(()=>{p(es),g.current=setTimeout(()=>{f(()=>l.push(`/create?repo=${encodeURIComponent(r)}`))},600)},0)};return window.addEventListener("shep:add-repository",e),()=>{window.removeEventListener("shep:add-repository",e),null!=g.current&&clearTimeout(g.current)}},[k,p,f,l]),(0,n.useEffect)(()=>{let e=e=>{let t=e.detail;if(t.parentId)return void C(`feat-${t.parentId}`,{state:"creating",featureId:t.featureId,name:t.name,description:t.description,repositoryPath:t.repositoryPath},"dependencyEdge");let r=b.find(e=>"repositoryNode"===e.type&&e.data.repositoryPath===t.repositoryPath);C(r?.id??null,{state:"running",featureId:t.featureId,name:t.name,description:t.description,repositoryPath:t.repositoryPath})};return window.addEventListener("shep:feature-created",e),()=>window.removeEventListener("shep:feature-created",e)},[b,C]),(0,n.useEffect)(()=>{_({onNodeAction:z,onFeatureDelete:j,onRepositoryAdd:$,onRepositoryClick:B,onRepositoryDelete:N})},[_,z,j,$,B,N]);let q=(0,n.useCallback)((e,t)=>{v(t)},[v]),W=b.some(e=>"repositoryNode"===e.type),[V,U]=(0,n.useState)(W),H=(0,n.useRef)(null);(0,n.useEffect)(()=>(W?(H.current&&(clearTimeout(H.current),H.current=null),U(!0)):V&&(H.current=setTimeout(()=>{U(!1),H.current=null},500)),()=>{H.current&&clearTimeout(H.current)}),[W,V]);let X=c.startsWith("/create"),K=(0,n.useMemo)(()=>{let e=b.filter(e=>"repositoryNode"===e.type),t=b.some(e=>"featureNode"===e.type);return 1!==e.length||t||X?b:b.map(e=>"repositoryNode"===e.type?{...e,data:{...e.data,pulseAdd:!0}}:e)},[b,X]);return(0,t.jsx)(S,{nodes:V?K:[],edges:V?y:[],selectedFeatureId:u,defaultViewport:m,onNodesChange:w,onConnect:E,onAddFeature:F,onNodeClick:I,onPaneClick:G,onMoveEnd:q,onResetViewport:x,emptyState:(0,t.jsx)(en,{onRepositorySelect:k})})}function ed({initialNodes:e,initialEdges:n,drawer:o}){return(0,t.jsxs)("div",{"data-testid":"control-center",className:"h-full w-full",children:[(0,t.jsx)(r.ReactFlowProvider,{children:(0,t.jsx)(ei,{initialNodes:e,initialEdges:n})}),(0,t.jsx)("div",{children:o},"drawer")]})}e.s(["ControlCenter",()=>ed],48246)}]);
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,87292,e=>{"use strict";var t=e.i(20314),r=e.i(79054),a=e.i(31406),i=e.i(94237),n=e.i(3645);let o=(0,n.default)("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);var l=e.i(5240),s=e.i(31777),d=e.i(35364);e.i(98127),e.i(25235);var c=e.i(48249),u=e.i(90033);function p({...e}){return(0,t.jsx)(u.Dialog.Root,{"data-slot":"sheet",...e})}function f({...e}){return(0,t.jsx)(u.Dialog.Portal,{"data-slot":"sheet-portal",...e})}function h({className:e,...r}){return(0,t.jsx)(u.Dialog.Overlay,{"data-slot":"sheet-overlay",className:(0,s.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...r})}function m({className:e,children:r,side:a="right",showCloseButton:i=!0,...n}){return(0,t.jsxs)(f,{children:[(0,t.jsx)(h,{}),(0,t.jsxs)(u.Dialog.Content,{"data-slot":"sheet-content",className:(0,s.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500","right"===a&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm","left"===a&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm","top"===a&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b","bottom"===a&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",e),...n,children:[r,i?(0,t.jsxs)(u.Dialog.Close,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none",children:[(0,t.jsx)(c.XIcon,{className:"size-4"}),(0,t.jsx)("span",{className:"sr-only",children:"Close"})]}):null]})]})}function g({className:e,...r}){return(0,t.jsx)("div",{"data-slot":"sheet-header",className:(0,s.cn)("flex flex-col gap-1.5 p-4",e),...r})}function b({className:e,...r}){return(0,t.jsx)(u.Dialog.Title,{"data-slot":"sheet-title",className:(0,s.cn)("text-foreground font-semibold",e),...r})}function x({className:e,...r}){return(0,t.jsx)(u.Dialog.Description,{"data-slot":"sheet-description",className:(0,s.cn)("text-muted-foreground text-sm",e),...r})}var v=e.i(2828);let w="shep-sidebar-open",C=r.createContext(null);function j(){let e=r.useContext(C);if(!e)throw Error("useSidebar must be used within a SidebarProvider.");return e}function y({defaultOpen:e=!0,open:a,onOpenChange:i,className:n,style:o,children:l,...d}){let c=function(){let[e,t]=r.useState(void 0);return r.useEffect(()=>{let e=window.matchMedia("(max-width: 767px)"),r=()=>{t(window.innerWidth<768)};return e.addEventListener("change",r),t(window.innerWidth<768),()=>e.removeEventListener("change",r)},[]),!!e}(),[u,p]=r.useState(!1),[f,h]=r.useState(e),m=a??f;r.useEffect(()=>{if(void 0!==a)return;let t=function(e){try{let t=localStorage.getItem(w);if("true"===t)return!0;if("false"===t)return!1;return e}catch{return e}}(e);t!==e&&h(t)},[]);let g=r.useCallback(e=>{let t="function"==typeof e?e(m):e;i?i(t):h(t);try{localStorage.setItem(w,String(t))}catch{}},[i,m]),b=r.useCallback(()=>c?p(e=>!e):g(e=>!e),[c,g,p]);r.useEffect(()=>{let e=e=>{"b"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),b())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[b]);let x=m?"expanded":"collapsed",j=r.useMemo(()=>({state:x,open:m,setOpen:g,isMobile:c,openMobile:u,setOpenMobile:p,toggleSidebar:b}),[x,m,g,c,u,p,b]);return(0,t.jsx)(C.Provider,{value:j,children:(0,t.jsx)(v.TooltipProvider,{delayDuration:0,children:(0,t.jsx)("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":"16rem","--sidebar-width-icon":"3rem",...o},className:(0,s.cn)("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full",n),...d,children:l})})})}function S({side:e="left",variant:r="sidebar",collapsible:a="offcanvas",className:i,children:n,...o}){let{isMobile:l,state:d,openMobile:c,setOpenMobile:u}=j();return"none"===a?(0,t.jsx)("div",{"data-slot":"sidebar",className:(0,s.cn)("bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",i),...o,children:n}):l?(0,t.jsx)(p,{open:c,onOpenChange:u,...o,children:(0,t.jsxs)(m,{"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden",style:{"--sidebar-width":"18rem"},side:e,children:[(0,t.jsxs)(g,{className:"sr-only",children:[(0,t.jsx)(b,{children:"Sidebar"}),(0,t.jsx)(x,{children:"Displays the mobile sidebar."})]}),(0,t.jsx)("div",{className:"flex h-full w-full flex-col",children:n})]})}):(0,t.jsxs)("div",{className:"group peer text-sidebar-foreground hidden md:block","data-state":d,"data-collapsible":"collapsed"===d?a:"","data-variant":r,"data-side":e,"data-slot":"sidebar",children:[(0,t.jsx)("div",{"data-slot":"sidebar-gap",className:(0,s.cn)("relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180","floating"===r||"inset"===r?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon)")}),(0,t.jsx)("div",{"data-slot":"sidebar-container",className:(0,s.cn)("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex","left"===e?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]","floating"===r||"inset"===r?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",i),...o,children:(0,t.jsx)("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm",children:n})})]})}function N({className:e,...r}){let{toggleSidebar:a}=j();return(0,t.jsx)("button",{"data-sidebar":"rail","data-slot":"sidebar-rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:a,title:"Toggle Sidebar",className:(0,s.cn)("hover:after:bg-sidebar-border absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] sm:flex","in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...r})}function k({className:e,...r}){return(0,t.jsx)("main",{"data-slot":"sidebar-inset",className:(0,s.cn)("bg-background relative flex w-full flex-1 flex-col","md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",e),...r})}function T({className:e,...r}){return(0,t.jsx)("div",{"data-slot":"sidebar-header","data-sidebar":"header",className:(0,s.cn)("flex flex-col gap-2 p-2",e),...r})}function E({className:e,...r}){return(0,t.jsx)("div",{"data-slot":"sidebar-footer","data-sidebar":"footer",className:(0,s.cn)("flex flex-col gap-2 p-2",e),...r})}function R({className:e,...r}){return(0,t.jsx)("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:(0,s.cn)("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...r})}function A({className:e,...r}){return(0,t.jsx)("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:(0,s.cn)("relative flex w-full min-w-0 flex-col p-2",e),...r})}function P({className:e,asChild:r=!1,...a}){let i=r?l.Slot.Root:"div";return(0,t.jsx)(i,{"data-slot":"sidebar-group-label","data-sidebar":"group-label",className:(0,s.cn)("text-sidebar-foreground/70 ring-sidebar-ring flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...a})}function L({className:e,...r}){return(0,t.jsx)("div",{"data-slot":"sidebar-group-content","data-sidebar":"group-content",className:(0,s.cn)("w-full text-sm",e),...r})}function D({className:e,...r}){return(0,t.jsx)("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:(0,s.cn)("flex w-full min-w-0 flex-col gap-1",e),...r})}function z({className:e,...r}){return(0,t.jsx)("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:(0,s.cn)("group/menu-item relative",e),...r})}let M=(0,i.cva)("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function _({asChild:e=!1,isActive:r=!1,variant:a="default",size:i="default",tooltip:n,className:o,...d}){let c=e?l.Slot.Root:"button",{isMobile:u,state:p}=j(),f=(0,t.jsx)(c,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":i,"data-active":r,className:(0,s.cn)(M({variant:a,size:i}),o),...d});return n?("string"==typeof n&&(n={children:n}),(0,t.jsxs)(v.Tooltip,{children:[(0,t.jsx)(v.TooltipTrigger,{asChild:!0,children:f}),(0,t.jsx)(v.TooltipContent,{side:"right",align:"center",hidden:"collapsed"!==p||u,...n})]})):f}let I=(0,n.default)("house",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]]);var H=e.i(81975),W=e.i(12103),O=e.i(3214);let B=(0,n.default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);var U=e.i(87620),F=e.i(85995),$=e.i(22528),V=e.i(5978),X=e.i(29297),Y=e.i(66033),q=e.i(5192),Z=e.i(27069),K=e.i(91967),G="ScrollArea",[J,Q]=(0,$.createContextScope)(G),[ee,et]=J(G),er=r.forwardRef((e,a)=>{let{__scopeScrollArea:i,type:n="hover",dir:o,scrollHideDelay:l=600,...s}=e,[d,c]=r.useState(null),[u,p]=r.useState(null),[f,h]=r.useState(null),[m,g]=r.useState(null),[b,x]=r.useState(null),[v,w]=r.useState(0),[C,j]=r.useState(0),[y,S]=r.useState(!1),[N,k]=r.useState(!1),T=(0,V.useComposedRefs)(a,e=>c(e)),E=(0,Y.useDirection)(o);return(0,t.jsx)(ee,{scope:i,type:n,dir:E,scrollHideDelay:l,scrollArea:d,viewport:u,onViewportChange:p,content:f,onContentChange:h,scrollbarX:m,onScrollbarXChange:g,scrollbarXEnabled:y,onScrollbarXEnabledChange:S,scrollbarY:b,onScrollbarYChange:x,scrollbarYEnabled:N,onScrollbarYEnabledChange:k,onCornerWidthChange:w,onCornerHeightChange:j,children:(0,t.jsx)(U.Primitive.div,{dir:E,...s,ref:T,style:{position:"relative","--radix-scroll-area-corner-width":v+"px","--radix-scroll-area-corner-height":C+"px",...e.style}})})});er.displayName=G;var ea="ScrollAreaViewport",ei=r.forwardRef((e,a)=>{let{__scopeScrollArea:i,children:n,nonce:o,...l}=e,s=et(ea,i),d=r.useRef(null),c=(0,V.useComposedRefs)(a,d,s.onViewportChange);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),(0,t.jsx)(U.Primitive.div,{"data-radix-scroll-area-viewport":"",...l,ref:c,style:{overflowX:s.scrollbarXEnabled?"scroll":"hidden",overflowY:s.scrollbarYEnabled?"scroll":"hidden",...e.style},children:(0,t.jsx)("div",{ref:s.onContentChange,style:{minWidth:"100%",display:"table"},children:n})})]})});ei.displayName=ea;var en="ScrollAreaScrollbar",eo=r.forwardRef((e,a)=>{let{forceMount:i,...n}=e,o=et(en,e.__scopeScrollArea),{onScrollbarXEnabledChange:l,onScrollbarYEnabledChange:s}=o,d="horizontal"===e.orientation;return r.useEffect(()=>(d?l(!0):s(!0),()=>{d?l(!1):s(!1)}),[d,l,s]),"hover"===o.type?(0,t.jsx)(el,{...n,ref:a,forceMount:i}):"scroll"===o.type?(0,t.jsx)(es,{...n,ref:a,forceMount:i}):"auto"===o.type?(0,t.jsx)(ed,{...n,ref:a,forceMount:i}):"always"===o.type?(0,t.jsx)(ec,{...n,ref:a}):null});eo.displayName=en;var el=r.forwardRef((e,a)=>{let{forceMount:i,...n}=e,o=et(en,e.__scopeScrollArea),[l,s]=r.useState(!1);return r.useEffect(()=>{let e=o.scrollArea,t=0;if(e){let r=()=>{window.clearTimeout(t),s(!0)},a=()=>{t=window.setTimeout(()=>s(!1),o.scrollHideDelay)};return e.addEventListener("pointerenter",r),e.addEventListener("pointerleave",a),()=>{window.clearTimeout(t),e.removeEventListener("pointerenter",r),e.removeEventListener("pointerleave",a)}}},[o.scrollArea,o.scrollHideDelay]),(0,t.jsx)(F.Presence,{present:i||l,children:(0,t.jsx)(ed,{"data-state":l?"visible":"hidden",...n,ref:a})})}),es=r.forwardRef((e,a)=>{var i;let{forceMount:n,...o}=e,l=et(en,e.__scopeScrollArea),s="horizontal"===e.orientation,d=eE(()=>u("SCROLL_END"),100),[c,u]=(i={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},r.useReducer((e,t)=>i[e][t]??e,"hidden"));return r.useEffect(()=>{if("idle"===c){let e=window.setTimeout(()=>u("HIDE"),l.scrollHideDelay);return()=>window.clearTimeout(e)}},[c,l.scrollHideDelay,u]),r.useEffect(()=>{let e=l.viewport,t=s?"scrollLeft":"scrollTop";if(e){let r=e[t],a=()=>{let a=e[t];r!==a&&(u("SCROLL"),d()),r=a};return e.addEventListener("scroll",a),()=>e.removeEventListener("scroll",a)}},[l.viewport,s,u,d]),(0,t.jsx)(F.Presence,{present:n||"hidden"!==c,children:(0,t.jsx)(ec,{"data-state":"hidden"===c?"hidden":"visible",...o,ref:a,onPointerEnter:(0,K.composeEventHandlers)(e.onPointerEnter,()=>u("POINTER_ENTER")),onPointerLeave:(0,K.composeEventHandlers)(e.onPointerLeave,()=>u("POINTER_LEAVE"))})})}),ed=r.forwardRef((e,a)=>{let i=et(en,e.__scopeScrollArea),{forceMount:n,...o}=e,[l,s]=r.useState(!1),d="horizontal"===e.orientation,c=eE(()=>{if(i.viewport){let e=i.viewport.offsetWidth<i.viewport.scrollWidth,t=i.viewport.offsetHeight<i.viewport.scrollHeight;s(d?e:t)}},10);return eR(i.viewport,c),eR(i.content,c),(0,t.jsx)(F.Presence,{present:n||l,children:(0,t.jsx)(ec,{"data-state":l?"visible":"hidden",...o,ref:a})})}),ec=r.forwardRef((e,a)=>{let{orientation:i="vertical",...n}=e,o=et(en,e.__scopeScrollArea),l=r.useRef(null),s=r.useRef(0),[d,c]=r.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=ey(d.viewport,d.content),p={...n,sizes:d,onSizesChange:c,hasThumb:!!(u>0&&u<1),onThumbChange:e=>l.current=e,onThumbPointerUp:()=>s.current=0,onThumbPointerDown:e=>s.current=e};function f(e,t){return function(e,t,r,a="ltr"){let i=eS(r),n=t||i/2,o=r.scrollbar.paddingStart+n,l=r.scrollbar.size-r.scrollbar.paddingEnd-(i-n),s=r.content-r.viewport;return ek([o,l],"ltr"===a?[0,s]:[-1*s,0])(e)}(e,s.current,d,t)}return"horizontal"===i?(0,t.jsx)(eu,{...p,ref:a,onThumbPositionChange:()=>{if(o.viewport&&l.current){let e=eN(o.viewport.scrollLeft,d,o.dir);l.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{o.viewport&&(o.viewport.scrollLeft=e)},onDragScroll:e=>{o.viewport&&(o.viewport.scrollLeft=f(e,o.dir))}}):"vertical"===i?(0,t.jsx)(ep,{...p,ref:a,onThumbPositionChange:()=>{if(o.viewport&&l.current){let e=eN(o.viewport.scrollTop,d);l.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{o.viewport&&(o.viewport.scrollTop=e)},onDragScroll:e=>{o.viewport&&(o.viewport.scrollTop=f(e))}}):null}),eu=r.forwardRef((e,a)=>{let{sizes:i,onSizesChange:n,...o}=e,l=et(en,e.__scopeScrollArea),[s,d]=r.useState(),c=r.useRef(null),u=(0,V.useComposedRefs)(a,c,l.onScrollbarXChange);return r.useEffect(()=>{c.current&&d(getComputedStyle(c.current))},[c]),(0,t.jsx)(em,{"data-orientation":"horizontal",...o,ref:u,sizes:i,style:{bottom:0,left:"rtl"===l.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===l.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":eS(i)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,r)=>{if(l.viewport){var a,i;let n=l.viewport.scrollLeft+t.deltaX;e.onWheelScroll(n),a=n,i=r,a>0&&a<i&&t.preventDefault()}},onResize:()=>{c.current&&l.viewport&&s&&n({content:l.viewport.scrollWidth,viewport:l.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:ej(s.paddingLeft),paddingEnd:ej(s.paddingRight)}})}})}),ep=r.forwardRef((e,a)=>{let{sizes:i,onSizesChange:n,...o}=e,l=et(en,e.__scopeScrollArea),[s,d]=r.useState(),c=r.useRef(null),u=(0,V.useComposedRefs)(a,c,l.onScrollbarYChange);return r.useEffect(()=>{c.current&&d(getComputedStyle(c.current))},[c]),(0,t.jsx)(em,{"data-orientation":"vertical",...o,ref:u,sizes:i,style:{top:0,right:"ltr"===l.dir?0:void 0,left:"rtl"===l.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":eS(i)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,r)=>{if(l.viewport){var a,i;let n=l.viewport.scrollTop+t.deltaY;e.onWheelScroll(n),a=n,i=r,a>0&&a<i&&t.preventDefault()}},onResize:()=>{c.current&&l.viewport&&s&&n({content:l.viewport.scrollHeight,viewport:l.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:ej(s.paddingTop),paddingEnd:ej(s.paddingBottom)}})}})}),[ef,eh]=J(en),em=r.forwardRef((e,a)=>{let{__scopeScrollArea:i,sizes:n,hasThumb:o,onThumbChange:l,onThumbPointerUp:s,onThumbPointerDown:d,onThumbPositionChange:c,onDragScroll:u,onWheelScroll:p,onResize:f,...h}=e,m=et(en,i),[g,b]=r.useState(null),x=(0,V.useComposedRefs)(a,e=>b(e)),v=r.useRef(null),w=r.useRef(""),C=m.viewport,j=n.content-n.viewport,y=(0,X.useCallbackRef)(p),S=(0,X.useCallbackRef)(c),N=eE(f,10);function k(e){v.current&&u({x:e.clientX-v.current.left,y:e.clientY-v.current.top})}return r.useEffect(()=>{let e=e=>{let t=e.target;g?.contains(t)&&y(e,j)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})},[C,g,j,y]),r.useEffect(S,[n,S]),eR(g,N),eR(m.content,N),(0,t.jsx)(ef,{scope:i,scrollbar:g,hasThumb:o,onThumbChange:(0,X.useCallbackRef)(l),onThumbPointerUp:(0,X.useCallbackRef)(s),onThumbPositionChange:S,onThumbPointerDown:(0,X.useCallbackRef)(d),children:(0,t.jsx)(U.Primitive.div,{...h,ref:x,style:{position:"absolute",...h.style},onPointerDown:(0,K.composeEventHandlers)(e.onPointerDown,e=>{0===e.button&&(e.target.setPointerCapture(e.pointerId),v.current=g.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),k(e))}),onPointerMove:(0,K.composeEventHandlers)(e.onPointerMove,k),onPointerUp:(0,K.composeEventHandlers)(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=w.current,m.viewport&&(m.viewport.style.scrollBehavior=""),v.current=null})})})}),eg="ScrollAreaThumb",eb=r.forwardRef((e,r)=>{let{forceMount:a,...i}=e,n=eh(eg,e.__scopeScrollArea);return(0,t.jsx)(F.Presence,{present:a||n.hasThumb,children:(0,t.jsx)(ex,{ref:r,...i})})}),ex=r.forwardRef((e,a)=>{let{__scopeScrollArea:i,style:n,...o}=e,l=et(eg,i),s=eh(eg,i),{onThumbPositionChange:d}=s,c=(0,V.useComposedRefs)(a,e=>s.onThumbChange(e)),u=r.useRef(void 0),p=eE(()=>{u.current&&(u.current(),u.current=void 0)},100);return r.useEffect(()=>{let e=l.viewport;if(e){let t=()=>{p(),u.current||(u.current=eT(e,d),d())};return d(),e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)}},[l.viewport,p,d]),(0,t.jsx)(U.Primitive.div,{"data-state":s.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...n},onPointerDownCapture:(0,K.composeEventHandlers)(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),r=e.clientX-t.left,a=e.clientY-t.top;s.onThumbPointerDown({x:r,y:a})}),onPointerUp:(0,K.composeEventHandlers)(e.onPointerUp,s.onThumbPointerUp)})});eb.displayName=eg;var ev="ScrollAreaCorner",ew=r.forwardRef((e,r)=>{let a=et(ev,e.__scopeScrollArea),i=!!(a.scrollbarX&&a.scrollbarY);return"scroll"!==a.type&&i?(0,t.jsx)(eC,{...e,ref:r}):null});ew.displayName=ev;var eC=r.forwardRef((e,a)=>{let{__scopeScrollArea:i,...n}=e,o=et(ev,i),[l,s]=r.useState(0),[d,c]=r.useState(0),u=!!(l&&d);return eR(o.scrollbarX,()=>{let e=o.scrollbarX?.offsetHeight||0;o.onCornerHeightChange(e),c(e)}),eR(o.scrollbarY,()=>{let e=o.scrollbarY?.offsetWidth||0;o.onCornerWidthChange(e),s(e)}),u?(0,t.jsx)(U.Primitive.div,{...n,ref:a,style:{width:l,height:d,position:"absolute",right:"ltr"===o.dir?0:void 0,left:"rtl"===o.dir?0:void 0,bottom:0,...e.style}}):null});function ej(e){return e?parseInt(e,10):0}function ey(e,t){let r=e/t;return isNaN(r)?0:r}function eS(e){let t=ey(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd;return Math.max((e.scrollbar.size-r)*t,18)}function eN(e,t,r="ltr"){let a=eS(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=t.scrollbar.size-i,o=t.content-t.viewport,l=(0,Z.clamp)(e,"ltr"===r?[0,o]:[-1*o,0]);return ek([0,o],[0,n-a])(l)}function ek(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let a=(t[1]-t[0])/(e[1]-e[0]);return t[0]+a*(r-e[0])}}var eT=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},a=0;return!function i(){let n={left:e.scrollLeft,top:e.scrollTop},o=r.left!==n.left,l=r.top!==n.top;(o||l)&&t(),r=n,a=window.requestAnimationFrame(i)}(),()=>window.cancelAnimationFrame(a)};function eE(e,t){let a=(0,X.useCallbackRef)(e),i=r.useRef(0);return r.useEffect(()=>()=>window.clearTimeout(i.current),[]),r.useCallback(()=>{window.clearTimeout(i.current),i.current=window.setTimeout(a,t)},[a,t])}function eR(e,t){let r=(0,X.useCallbackRef)(t);(0,q.useLayoutEffect)(()=>{let t=0;if(e){let a=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(r)});return a.observe(e),()=>{window.cancelAnimationFrame(t),a.unobserve(e)}}},[e,r])}e.s(["Corner",()=>ew,"Root",()=>er,"ScrollArea",()=>er,"ScrollAreaCorner",()=>ew,"ScrollAreaScrollbar",()=>eo,"ScrollAreaThumb",()=>eb,"ScrollAreaViewport",()=>ei,"Scrollbar",()=>eo,"Thumb",()=>eb,"Viewport",()=>ei,"createScrollAreaScope",()=>Q],87516);var eA=e.i(87516),eA=eA;function eP({className:e,children:r,...a}){return(0,t.jsxs)(eA.Root,{"data-slot":"scroll-area",className:(0,s.cn)("relative",e),...a,children:[(0,t.jsx)(eA.Viewport,{"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1 [&>div]:block!",children:r}),(0,t.jsx)(eL,{}),(0,t.jsx)(eA.Corner,{})]})}function eL({className:e,orientation:r="vertical",...a}){return(0,t.jsx)(eA.ScrollAreaScrollbar,{"data-slot":"scroll-area-scrollbar",orientation:r,className:(0,s.cn)("flex touch-none p-px transition-colors select-none","vertical"===r&&"h-full w-2.5 border-l border-l-transparent","horizontal"===r&&"h-2.5 flex-col border-t border-t-transparent",e),...a,children:(0,t.jsx)(eA.ScrollAreaThumb,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})})}var eD=e.i(24035),ez=e.i(8361);function eM({icon:e,label:r,href:a,active:i=!1}){let n=(0,ez.useSoundAction)("navigate");return(0,t.jsx)(z,{"data-testid":"sidebar-nav-item",children:(0,t.jsx)(_,{asChild:!0,isActive:i,tooltip:r,children:(0,t.jsxs)(eD.default,{href:a,onClick:()=>n.play(),children:[(0,t.jsx)(e,{}),(0,t.jsx)("span",{children:r})]})})})}function e_({className:e}){let{toggleSidebar:r,open:a}=j(),i=(0,ez.useSoundAction)("expand"),n=(0,ez.useSoundAction)("collapse");return(0,t.jsx)("div",{className:(0,s.cn)("flex",e),children:(0,t.jsx)(d.Button,{"data-testid":"sidebar-collapse-toggle",variant:"ghost",size:"icon",className:"size-7 cursor-pointer group-data-[collapsible=icon]:size-8!",onClick:()=>{a?n.play():i.play(),r()},"aria-label":a?"Collapse sidebar":"Expand sidebar",children:(0,t.jsx)(o,{className:"size-4"})})})}function eI({className:e,size:r=24,variant:a="default"}){return(0,t.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 194 200",width:r,height:r,className:(0,s.cn)("shrink-0","dev"===a&&"text-cyan-400",e),"aria-hidden":"true",children:(0,t.jsx)("g",{transform:"matrix(1, 0, 0, 1, -111, -208)",children:(0,t.jsx)("path",{d:"M 198 406 C196,405 194,403 193,401 C192,399 191,398 186,398 C178,397 174,394 170,387 L 168 381 L 163 381 C156,381 150,377 147,370 C144,364 143,359 146,353 C148,348 148,347 147,347 C145,347 140,343 138,339 C133,329 139,314 149,311 L 152 311 L 149 307 C145,302 145,294 149,290 C151,288 152,287 151,286 C150,283 152,278 155,276 C156,275 159,274 162,273 C165,273 166,273 168,276 C171,278 171,280 172,287 C173,294 174,297 177,304 C180,309 182,314 183,316 C186,327 193,336 199,339 C204,342 211,342 216,340 C222,336 231,324 234,314 C235,312 237,307 239,302 C240,298 242,292 242,289 C243,281 245,278 247,275 C250,273 251,273 255,273 C261,274 264,278 264,282 C264,284 264,286 263,287 C262,287 263,288 265,290 C272,295 272,303 267,309 L 265 312 L 269 314 C276,317 279,323 279,332 C279,339 277,343 272,347 C268,351 268,351 269,354 C272,358 271,366 269,371 C266,376 259,381 254,381 C252,381 251,382 248,386 C242,395 234,400 227,399 C224,398 223,398 221,401 C220,403 217,405 216,406 C211,409 203,409 198,406 ZM 136 271 C123,267 115,262 113,256 C111,251 111,251 113,251 C118,254 124,254 132,252 C136,252 141,251 144,251 C149,251 157,253 162,256 C166,258 166,258 166,264 L 166 269 L 160 270 C149,272 142,272 136,271 ZM 264 271 C263,271 259,270 256,270 L 250 270 L 250 265 C249,259 250,257 259,254 C265,251 272,251 289,252 C297,253 299,253 302,252 C305,250 305,250 305,252 C305,255 301,262 297,264 C289,270 272,273 264,271 ZM 162 249 C160,247 159,245 159,242 C159,236 164,230 169,230 C170,230 171,228 171,225 C171,216 176,210 184,209 C189,209 195,211 195,213 C195,214 196,213 197,212 C201,209 204,208 208,208 C212,208 217,210 219,212 C220,214 220,213 223,211 C226,208 234,208 239,211 C243,214 246,221 246,226 C245,230 245,230 247,230 C253,230 258,238 257,244 C256,249 251,252 245,252 C241,252 237,251 234,248 C232,247 232,247 228,249 C225,251 222,252 220,252 C216,252 212,250 210,247 C209,246 209,246 206,248 C201,252 192,253 185,248 C183,247 183,247 178,249 C172,253 166,253 162,249 ZM 116 249 C112,248 114,247 119,247 C122,247 127,246 130,245 C138,242 146,242 152,245 L 158 248 L 148 247 C142,247 138,247 133,248 C128,250 120,250 116,249 ZM 284 248 C281,247 277,247 270,247 L 260 248 L 263 246 C269,243 276,242 284,245 C289,246 295,247 298,247 C303,247 304,247 303,248 C301,250 289,250 284,248 Z",fill:"currentColor"})})})}function eH({version:e,branch:a,commitHash:i,isDev:n=!1,packageName:o="@shepai/cli",description:l,instancePath:s}){let d=i?.slice(0,7),{latest:c,updateAvailable:u}=function(e){let[t,a]=(0,r.useState)(null),[i,n]=(0,r.useState)(!0);(0,r.useEffect)(()=>{let e=!1;return async function(){try{let t=await fetch("/api/npm-version");if(!t.ok)return;let r=await t.json();!e&&r.latest&&a(r.latest)}catch{}finally{e||n(!1)}}(),()=>{e=!0}},[]);let o=null!==t&&function(e,t){let r=e=>e.split("-")[0].split(".").map(Number),a=r(e),i=r(t);for(let e=0;e<3;e++){let t=a[e]??0,r=i[e]??0;if(t>r)return 1;if(t<r)return -1}return 0}(t,e)>0;return{latest:t,updateAvailable:o,loading:i}}(e),{status:p,startUpgrade:f}=function(){let[e,t]=(0,r.useState)("idle"),[a,i]=(0,r.useState)(""),[n,o]=(0,r.useState)(),l=(0,r.useRef)(null),s=(0,r.useCallback)(()=>{if("upgrading"===e)return;t("upgrading"),i(""),o(void 0);let r=new AbortController;return l.current=r,fetch("/api/cli-upgrade",{method:"POST",signal:r.signal}).then(async e=>{if(!e.ok||!e.body){t("error"),o(`Server returned ${e.status}`);return}let r=e.body.getReader(),a=new TextDecoder,n="";for(;;){let{done:e,value:l}=await r.read();if(e)break;let s=(n+=a.decode(l,{stream:!0})).split("\n");for(let e of(n=s.pop()??"",s))if(!e.startsWith("event: done")&&e.startsWith("data: ")){let r=e.slice(6);try{let e=JSON.parse(r);"upgraded"===e.status?t("upgraded"):"up-to-date"===e.status?t("up-to-date"):"error"===e.status&&(t("error"),o(e.errorMessage))}catch{i(e=>e+r)}}}}).catch(e=>{e instanceof DOMException&&"AbortError"===e.name||(t("error"),o(e instanceof Error?e.message:"Upgrade failed"))}),()=>{r.abort()}},[e]);return{status:e,output:a,errorMessage:n,startUpgrade:s}}(),h=n?`${e}-dev`:`v${e}`,m="upgrading"===p,g="upgraded"===p;return(0,t.jsx)(v.TooltipProvider,{delayDuration:200,children:(0,t.jsxs)(v.Tooltip,{children:[(0,t.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,t.jsxs)("span",{className:"text-muted-foreground/80 hover:text-muted-foreground relative cursor-default text-[11px] leading-tight transition-colors","data-testid":"version-label",children:[h,u&&!g?(0,t.jsx)("span",{className:"absolute -top-0.5 -right-1.5 size-1.5 rounded-full bg-emerald-400","data-testid":"update-dot"}):null]})}),(0,t.jsxs)(v.TooltipContent,{side:"right",className:"max-w-[280px] space-y-1 p-3 text-left",children:[(0,t.jsx)("div",{className:"mb-1.5 text-xs font-semibold",children:o}),l?(0,t.jsx)("div",{className:"text-[10px] leading-snug opacity-70",children:l}):null,(0,t.jsxs)("div",{className:"border-t border-white/10 pt-1.5",children:[(0,t.jsx)(eW,{label:"Version",value:h}),n&&a?(0,t.jsx)(eW,{label:"Branch",value:a}):null,n&&d?(0,t.jsx)(eW,{label:"Commit",value:d,mono:!0}):null,n&&s?(0,t.jsx)(eW,{label:"Path",value:s,mono:!0}):null,c?(0,t.jsx)(eW,{label:"Latest",value:`v${c}`,highlight:u}):null]}),g?(0,t.jsx)("div",{className:"border-t border-white/10 pt-1.5",children:(0,t.jsx)("span",{className:"text-[10px] font-medium text-emerald-400","data-testid":"upgrade-success",children:"Upgraded successfully — restart to apply"})}):"error"===p?(0,t.jsx)("div",{className:"border-t border-white/10 pt-1.5",children:(0,t.jsx)("span",{className:"text-[10px] font-medium text-red-400","data-testid":"upgrade-error",children:"Upgrade failed"})}):u?(0,t.jsx)("div",{className:"border-t border-white/10 pt-1.5",children:(0,t.jsx)("button",{type:"button",onClick:f,disabled:m,className:"inline-flex items-center gap-1 text-[10px] font-medium text-emerald-400 transition-colors hover:text-emerald-300 disabled:opacity-50","data-testid":"upgrade-button",children:m?"Upgrading...":`Upgrade to v${c}`})}):null]})]})})}function eW({label:e,value:r,highlight:a,mono:i}){return(0,t.jsxs)("div",{className:"flex items-center justify-between gap-4 text-[10px]",children:[(0,t.jsx)("span",{className:"opacity-60",children:e}),(0,t.jsx)("span",{className:[a?"font-medium text-emerald-400":"",i||!a?"font-mono":""].filter(Boolean).join(" "),children:r})]})}function eO({startedAt:e}){let[a,i]=(0,r.useState)(()=>Date.now()-e);return(0,r.useEffect)(()=>{let t=setInterval(()=>{(0,r.startTransition)(()=>i(Date.now()-e))},1e3);return()=>clearInterval(t)},[e]),(0,t.jsx)("span",{"data-testid":"elapsed-time",className:"tabular-nums",children:function(e){let t=Math.floor(e/1e3);if(t>=3600){let e=Math.floor(t/3600);return`${e}h`}let r=Math.floor(t/60);return`${String(r).padStart(2,"0")}:${String(t%60).padStart(2,"0")}`}(a)})}var eB=e.i(51251),eU=e.i(83428),eF=e.i(10942),e$=e.i(94819),eV=e.i(54277);let eX={"action-needed":{icon:eB.CircleAlert,iconClass:"text-amber-500",bgClass:"bg-amber-500/10",label:"Action Needed"},"in-progress":{icon:eU.Loader2,iconClass:"text-blue-500 animate-spin",bgClass:"bg-blue-500/10",label:"In Progress"},blocked:{icon:e$.Ban,iconClass:"text-gray-400",bgClass:"bg-gray-400/10",label:"Blocked"},error:{icon:eV.CircleX,iconClass:"text-red-500",bgClass:"bg-red-500/10",label:"Error"},done:{icon:eF.CircleCheck,iconClass:"text-emerald-500",bgClass:"bg-emerald-500/10",label:"Done"}},eY=["action-needed","error","blocked","in-progress","done"];var eq=e.i(86782),eZ=e.i(29847);function eK({name:e,status:r,startedAt:a,duration:i,agentType:n,modelId:o,onClick:l}){let{icon:s,iconClass:d}=eX[r],c=n?(0,eq.getAgentTypeIcon)(n):null;return(0,t.jsx)(z,{"data-testid":"feature-list-item",children:(0,t.jsxs)(_,{size:"sm",onClick:l,tooltip:e,className:"cursor-pointer",children:[(0,t.jsx)(s,{className:d}),(0,t.jsx)("span",{className:"flex-1 truncate font-medium",children:e}),"in-progress"===r&&null!=a?(0,t.jsx)("span",{"data-testid":"feature-list-item-meta",className:"text-muted-foreground ml-auto text-xs tabular-nums",children:(0,t.jsx)(eO,{startedAt:a})}):null,"done"===r&&i?(0,t.jsx)("span",{"data-testid":"feature-list-item-meta",className:"text-muted-foreground ml-auto text-xs tabular-nums",children:i}):null,c?(0,t.jsx)(v.TooltipProvider,{children:(0,t.jsxs)(v.Tooltip,{children:[(0,t.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"ml-auto shrink-0",children:(0,t.jsx)(c,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(v.TooltipContent,{side:"right",children:[(0,t.jsx)("span",{className:"font-medium",children:eq.agentTypeLabels[n]??n}),o?(0,t.jsxs)("span",{className:"ml-1 opacity-70",children:["· ",(0,eZ.getModelMeta)(o).displayName||o]}):null]})]})}):null]})})}function eG({label:e,count:r,children:a}){return(0,t.jsxs)(A,{"data-testid":"feature-status-group",className:"px-2 py-1",children:[(0,t.jsxs)(P,{className:"text-muted-foreground h-6 px-2 text-[0.65rem] font-semibold tracking-wider uppercase",children:[e,(0,t.jsx)("span",{"aria-label":`${r} items`,className:"bg-sidebar-accent text-sidebar-accent-foreground ml-1.5 inline-flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.6rem] font-medium tabular-nums",role:"img",children:r})]}),(0,t.jsx)(L,{children:(0,t.jsx)(D,{className:"gap-0.5",children:a})})]})}function eJ({label:e,className:r}){return(0,t.jsx)(A,{"data-testid":"sidebar-section-header",className:(0,s.cn)("px-2 py-1",r),children:(0,t.jsx)("div",{className:"text-sidebar-foreground flex h-7 w-full shrink-0 items-center px-2 text-sm font-medium",children:(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e})})})}let eQ={version:"unknown",packageName:"@shepai/cli",description:"Autonomous AI Native SDLC Platform",branch:"",commitHash:"",instancePath:"",isDev:!1};function e0({features:e,featureFlags:i,showNewFeature:n=!1,onNewFeature:o,onFeatureClick:l}){let s=(0,a.usePathname)(),{state:d}=j(),{mounted:c,visible:u}=function(e,t){let[a,i]=(0,r.useState)(!e),[n,o]=(0,r.useState)(!e);return(0,r.useEffect)(()=>{if(!e){i(!0);let e=requestAnimationFrame(()=>o(!0));return()=>cancelAnimationFrame(e)}o(!1);let t=window.setTimeout(()=>i(!1),200);return()=>window.clearTimeout(t)},[e,200]),{mounted:a,visible:n}}("collapsed"===d,0),p=function(){let[e,t]=(0,r.useState)(eQ);return(0,r.useEffect)(()=>{let e=!1;return async function(){try{let r=await fetch("/api/version");if(!r.ok)return;let a=await r.json();e||t(a)}catch{}}(),()=>{e=!0}},[]),e}(),f=eY.map(t=>{let{label:r}=eX[t],a=e.filter(e=>e.status===t);return{key:t,label:r,items:a}});return(0,t.jsxs)(S,{"data-testid":"app-sidebar","data-no-drawer-close":!0,collapsible:"icon",children:[(0,t.jsx)(T,{children:(0,t.jsxs)(D,{children:[(0,t.jsx)(z,{children:(0,t.jsxs)("div",{className:"flex h-8 items-center group-data-[collapsible=icon]:justify-center",children:[c?(0,t.jsxs)("div",{className:["flex min-w-0 flex-1 items-center gap-2 overflow-hidden px-2 transition-opacity duration-200 ease-out",u?"opacity-100":"opacity-0"].join(" "),"aria-hidden":!u,children:[(0,t.jsx)(eI,{className:"shrink-0",size:20,variant:p.isDev?"dev":"default"}),(0,t.jsx)("span",{className:"truncate text-sm font-semibold tracking-tight",children:"Shep"}),(0,t.jsx)(eH,{version:p.version,branch:p.branch||void 0,commitHash:p.commitHash||void 0,isDev:p.isDev,packageName:p.packageName,description:p.description,instancePath:p.instancePath||void 0})]}):null,(0,t.jsx)(e_,{className:"shrink-0 transition-all duration-200"})]})}),(0,t.jsx)(eM,{icon:I,label:"Control Center",href:"/",active:"/"===s}),(0,t.jsx)(eM,{icon:H.Wrench,label:"Tools",href:"/tools",active:"/tools"===s}),i.skills?(0,t.jsx)(eM,{icon:W.Puzzle,label:"Skills",href:"/skills",active:"/skills"===s}):null,(0,t.jsx)(eM,{icon:B,label:"Settings",href:"/settings",active:"/settings"===s})]})}),(0,t.jsx)(R,{children:c?(0,t.jsxs)("div",{className:["min-w-0 overflow-hidden transition-opacity duration-200 ease-out [&_[data-sidebar=group-label]]:!mt-0 [&_[data-sidebar=group-label]]:!opacity-100 [&_[data-sidebar=group-label]]:!transition-none",u?"opacity-100":"opacity-0"].join(" "),children:[(0,t.jsx)(eJ,{label:"Features"}),(0,t.jsx)(eP,{children:f.map(({key:e,label:r,items:a})=>a.length>0?(0,t.jsx)(eG,{label:r,count:a.length,children:a.map(e=>(0,t.jsx)(eK,{name:e.name,status:e.status,startedAt:e.startedAt,duration:e.duration,agentType:e.agentType,modelId:e.modelId,onClick:l?()=>l(e.featureId):void 0},e.featureId))},e):null)})]}):null}),n?(0,t.jsx)(E,{children:(0,t.jsx)(D,{children:(0,t.jsx)(z,{children:(0,t.jsxs)(_,{onClick:o,tooltip:"New feature",children:[(0,t.jsx)(O.Plus,{}),(0,t.jsx)("span",{children:"New feature"})]})})})}):null,(0,t.jsx)(N,{})]})}let e2=(0,n.default)("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);var e1=e.i(78521);function e3({onSelect:e}){let[a,i]=(0,r.useState)(!1);async function n(){if(!a){i(!0);try{let t=await (0,e1.pickFolder)();t&&e?.(t)}finally{i(!1)}}}return(0,t.jsx)(v.TooltipProvider,{children:(0,t.jsxs)(v.Tooltip,{children:[(0,t.jsx)(v.TooltipTrigger,{asChild:!0,children:(0,t.jsx)(d.Button,{variant:"ghost",size:"icon","aria-label":"Add Repository","data-testid":"add-repository-button",onClick:n,disabled:a,children:a?(0,t.jsx)(eU.Loader2,{className:"h-5 w-5 animate-spin"}):(0,t.jsx)(e2,{className:"h-5 w-5"})})}),(0,t.jsx)(v.TooltipContent,{children:"Add Repository"})]})})}let e4=(0,n.default)("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]),e5=(0,n.default)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),e7="shep-theme";function e6(){let{theme:e,resolvedTheme:a,setTheme:i}=function(){let[e,t]=(0,r.useState)("system"),[a,i]=(0,r.useState)("light"),n=(0,r.useCallback)(()=>window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",[]),o=(0,r.useCallback)(e=>"system"===e?n():e,[n]),l=(0,r.useCallback)(e=>{if("u"<typeof document)return;let t=document.documentElement;t.classList.remove("light","dark"),t.classList.add(e),i(e)},[]),s=(0,r.useCallback)(e=>{t(e),"u">typeof localStorage&&localStorage.setItem(e7,e),l(o(e))},[o,l]);return(0,r.useEffect)(()=>{let e=localStorage.getItem(e7)??"system";t(e),l(o(e))},[o,l]),(0,r.useEffect)(()=>{let t=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>{"system"===e&&l(o("system"))};return t.addEventListener("change",r),()=>t.removeEventListener("change",r)},[e,o,l]),{theme:e,resolvedTheme:a,setTheme:s}}(),n=(0,ez.useSoundAction)("toggle-on"),o=(0,ez.useSoundAction)("toggle-off");return(0,t.jsxs)(d.Button,{variant:"ghost",size:"icon",onClick:t=>{let r="system"===e?"dark"===a?"light":"dark":"dark"===e?"light":"dark";"dark"!==("system"===e?a:e)?n.play():o.play();let l=window.matchMedia("(prefers-reduced-motion: reduce)").matches;!document.startViewTransition||l?i(r):(document.documentElement.style.setProperty("--x",`${t.clientX}px`),document.documentElement.style.setProperty("--y",`${t.clientY}px`),document.startViewTransition(()=>{i(r)}))},"aria-label":`Switch to ${"dark"===a?"light":"dark"} mode`,children:[(0,t.jsx)(e5,{className:"h-5 w-5 scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90"}),(0,t.jsx)(e4,{className:"absolute h-5 w-5 scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0"}),(0,t.jsx)("span",{className:"sr-only",children:"Toggle theme"})]})}let e8=(0,n.default)("volume-2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]),e9=(0,n.default)("volume-off",[["path",{d:"M16 9a5 5 0 0 1 .95 2.293",key:"1fgyg8"}],["path",{d:"M19.364 5.636a9 9 0 0 1 1.889 9.96",key:"l3zxae"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"m7 7-.587.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298V11",key:"1gbwow"}],["path",{d:"M9.828 4.172A.686.686 0 0 1 11 4.657v.686",key:"s2je0y"}]]);var te=e.i(73709);function tt(){let{enabled:e,toggle:r}=(0,te.useSoundEnabled)();return(0,t.jsxs)(d.Button,{variant:"ghost",size:"icon",onClick:r,"aria-label":e?"Mute sounds":"Unmute sounds",children:[e?(0,t.jsx)(e8,{className:"h-5 w-5"}):(0,t.jsx)(e9,{className:"h-5 w-5"}),(0,t.jsx)("span",{className:"sr-only",children:"Toggle sound"})]})}var tr=e.i(39443),ta=e.i(30153),ti=e.i(5147),tn=e.i(60112),to=e.i(17406);let tl={[to.NotificationSeverity.Success]:"success",[to.NotificationSeverity.Error]:"error",[to.NotificationSeverity.Warning]:"warning",[to.NotificationSeverity.Info]:"info"},ts={[to.NotificationSeverity.Success]:"notification-success",[to.NotificationSeverity.Error]:"notification-error",[to.NotificationSeverity.Warning]:"notification-warning",[to.NotificationSeverity.Info]:"notification-info"};var td=e.i(75921);function tc({children:e}){let i=(0,a.useRouter)(),{guardedNavigate:n}=(0,ta.useDrawerCloseGuard)(),o=(0,td.useFeatureFlags)();!function(){let e=(0,a.useRouter)(),{events:t}=(0,tr.useAgentEventsContext)(),i=(0,ez.useSoundAction)("notification-success"),n=(0,ez.useSoundAction)("notification-error"),o=(0,ez.useSoundAction)("notification-warning"),l=(0,ez.useSoundAction)("notification-info"),s=(0,r.useMemo)(()=>({"notification-success":i,"notification-error":n,"notification-warning":o,"notification-info":l}),[i,n,o,l]),d=(0,r.useRef)(0);(0,r.useEffect)(()=>{if(t.length<=d.current)return;let r=t.slice(d.current);for(let a of(d.current=t.length,r)){if(a.severity!==to.NotificationSeverity.Error&&a.severity!==to.NotificationSeverity.Warning&&a.severity!==to.NotificationSeverity.Success)continue;!function(e,t){let r=tl[e.severity]??"info",a=e.eventType===to.NotificationEventType.WaitingApproval;tn.toast[r](e.featureName,{description:e.message,...a&&t&&{action:{label:"Review",onClick:()=>{t(`/feature/${e.featureId}`)}}}})}(a,t=>e.push(t));let t=ts[a.severity];s[t]?.play()}},[t,s,e])}();let{features:l}=(0,ti.useSidebarFeaturesContext)(),s=(0,r.useCallback)(()=>{n(()=>i.push("/create"))},[i,n]),d=(0,r.useCallback)(e=>{n(()=>i.push(`/feature/${e}`))},[i,n]),c=(0,r.useCallback)(e=>{window.dispatchEvent(new CustomEvent("shep:add-repository",{detail:{path:e}}))},[]);return(0,t.jsxs)(y,{defaultOpen:!1,children:[(0,t.jsx)(e0,{features:l,featureFlags:o,onNewFeature:s,onFeatureClick:d}),(0,t.jsx)(k,{children:(0,t.jsxs)("div",{className:"relative h-full",children:[(0,t.jsxs)("div",{className:"absolute top-3 right-3 z-50 flex gap-1",children:[(0,t.jsx)(e3,{onSelect:c}),(0,t.jsx)(tt,{}),(0,t.jsx)(e6,{})]}),(0,t.jsx)("main",{className:"h-full",children:e})]})})]})}function tu({children:e}){return(0,t.jsx)(tr.AgentEventsProvider,{children:(0,t.jsx)(ta.DrawerCloseGuardProvider,{children:(0,t.jsx)(ti.SidebarFeaturesProvider,{children:(0,t.jsx)(tc,{children:e})})})})}e.s(["AppShell",()=>tu],87292)},25251,e=>{"use strict";var t=e.i(20314),r=e.i(60112);let a=({...e})=>(0,t.jsx)(r.Toaster,{className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e});e.s(["Toaster",()=>a])}]);