@shepai/cli 1.131.0 → 1.131.1

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 (140) hide show
  1. package/README.md +1 -1
  2. package/dist/src/presentation/web/app/actions/get-merge-review-data.d.ts.map +1 -1
  3. package/dist/src/presentation/web/app/actions/get-merge-review-data.js +15 -4
  4. package/dist/tsconfig.build.tsbuildinfo +1 -1
  5. package/package.json +1 -1
  6. package/web/.next/BUILD_ID +1 -1
  7. package/web/.next/build-manifest.json +2 -2
  8. package/web/.next/fallback-build-manifest.json +2 -2
  9. package/web/.next/prerender-manifest.json +3 -3
  10. package/web/.next/required-server-files.js +2 -2
  11. package/web/.next/required-server-files.json +2 -2
  12. package/web/.next/server/app/(dashboard)/@drawer/adopt/page/server-reference-manifest.json +24 -24
  13. package/web/.next/server/app/(dashboard)/@drawer/adopt/page.js.nft.json +1 -1
  14. package/web/.next/server/app/(dashboard)/@drawer/adopt/page_client-reference-manifest.js +1 -1
  15. package/web/.next/server/app/(dashboard)/@drawer/create/page/server-reference-manifest.json +24 -24
  16. package/web/.next/server/app/(dashboard)/@drawer/create/page.js.nft.json +1 -1
  17. package/web/.next/server/app/(dashboard)/@drawer/create/page_client-reference-manifest.js +1 -1
  18. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page/server-reference-manifest.json +30 -30
  19. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page.js.nft.json +1 -1
  20. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page_client-reference-manifest.js +1 -1
  21. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page/server-reference-manifest.json +30 -30
  22. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page.js.nft.json +1 -1
  23. package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page_client-reference-manifest.js +1 -1
  24. package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page/server-reference-manifest.json +22 -22
  25. package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page.js.nft.json +1 -1
  26. package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page_client-reference-manifest.js +1 -1
  27. package/web/.next/server/app/(dashboard)/create/page/server-reference-manifest.json +24 -24
  28. package/web/.next/server/app/(dashboard)/create/page.js.nft.json +1 -1
  29. package/web/.next/server/app/(dashboard)/create/page_client-reference-manifest.js +1 -1
  30. package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page/server-reference-manifest.json +30 -30
  31. package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page.js.nft.json +1 -1
  32. package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page_client-reference-manifest.js +1 -1
  33. package/web/.next/server/app/(dashboard)/feature/[featureId]/page/server-reference-manifest.json +30 -30
  34. package/web/.next/server/app/(dashboard)/feature/[featureId]/page.js.nft.json +1 -1
  35. package/web/.next/server/app/(dashboard)/feature/[featureId]/page_client-reference-manifest.js +1 -1
  36. package/web/.next/server/app/(dashboard)/page/server-reference-manifest.json +22 -22
  37. package/web/.next/server/app/(dashboard)/page.js.nft.json +1 -1
  38. package/web/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
  39. package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page/server-reference-manifest.json +22 -22
  40. package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page.js.nft.json +1 -1
  41. package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page_client-reference-manifest.js +1 -1
  42. package/web/.next/server/app/_global-error.html +2 -2
  43. package/web/.next/server/app/_global-error.rsc +1 -1
  44. package/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  45. package/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  46. package/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  47. package/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  48. package/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  49. package/web/.next/server/app/_not-found/page/server-reference-manifest.json +3 -3
  50. package/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  51. package/web/.next/server/app/settings/page/server-reference-manifest.json +8 -8
  52. package/web/.next/server/app/settings/page.js.nft.json +1 -1
  53. package/web/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  54. package/web/.next/server/app/skills/page/server-reference-manifest.json +8 -8
  55. package/web/.next/server/app/skills/page_client-reference-manifest.js +1 -1
  56. package/web/.next/server/app/tools/page/server-reference-manifest.json +8 -8
  57. package/web/.next/server/app/tools/page_client-reference-manifest.js +1 -1
  58. package/web/.next/server/app/version/page/server-reference-manifest.json +3 -3
  59. package/web/.next/server/app/version/page_client-reference-manifest.js +1 -1
  60. package/web/.next/server/chunks/[root-of-the-server]__a402b567._.js +1 -1
  61. package/web/.next/server/chunks/ssr/744ca_web__next-internal_server_app_(dashboard)_@drawer_adopt_page_actions_4e741df2.js +1 -1
  62. package/web/.next/server/chunks/ssr/744ca_web__next-internal_server_app_(dashboard)_@drawer_adopt_page_actions_4e741df2.js.map +1 -1
  63. package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_create-drawer-client_tsx_5e26fc0a._.js +1 -1
  64. package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_create-drawer-client_tsx_5e26fc0a._.js.map +1 -1
  65. package/web/.next/server/chunks/ssr/8ba4b_server_app_(dashboard)_@drawer_repository_[repositoryId]_page_actions_026fdffa.js +1 -1
  66. package/web/.next/server/chunks/ssr/8ba4b_server_app_(dashboard)_@drawer_repository_[repositoryId]_page_actions_026fdffa.js.map +1 -1
  67. package/web/.next/server/chunks/ssr/8ba4b_server_app_(dashboard)_repository_[repositoryId]_page_actions_8b91e197.js +1 -1
  68. package/web/.next/server/chunks/ssr/8ba4b_server_app_(dashboard)_repository_[repositoryId]_page_actions_8b91e197.js.map +1 -1
  69. package/web/.next/server/chunks/ssr/[root-of-the-server]__2c791c42._.js +2 -2
  70. package/web/.next/server/chunks/ssr/[root-of-the-server]__357d99f9._.js +1 -1
  71. package/web/.next/server/chunks/ssr/[root-of-the-server]__3ef34e4c._.js +1 -1
  72. package/web/.next/server/chunks/ssr/[root-of-the-server]__43f51aa6._.js +1 -1
  73. package/web/.next/server/chunks/ssr/[root-of-the-server]__43f51aa6._.js.map +1 -1
  74. package/web/.next/server/chunks/ssr/[root-of-the-server]__6bb00d90._.js +2 -2
  75. package/web/.next/server/chunks/ssr/[root-of-the-server]__6bb00d90._.js.map +1 -1
  76. package/web/.next/server/chunks/ssr/[root-of-the-server]__755cfe02._.js +1 -1
  77. package/web/.next/server/chunks/ssr/[root-of-the-server]__755cfe02._.js.map +1 -1
  78. package/web/.next/server/chunks/ssr/[root-of-the-server]__7894f27f._.js +1 -1
  79. package/web/.next/server/chunks/ssr/[root-of-the-server]__7894f27f._.js.map +1 -1
  80. package/web/.next/server/chunks/ssr/[root-of-the-server]__815546bd._.js +1 -1
  81. package/web/.next/server/chunks/ssr/[root-of-the-server]__815546bd._.js.map +1 -1
  82. package/web/.next/server/chunks/ssr/[root-of-the-server]__96670392._.js +2 -2
  83. package/web/.next/server/chunks/ssr/[root-of-the-server]__a628fb91._.js +1 -1
  84. package/web/.next/server/chunks/ssr/[root-of-the-server]__a628fb91._.js.map +1 -1
  85. package/web/.next/server/chunks/ssr/[root-of-the-server]__bfba58e6._.js +1 -1
  86. package/web/.next/server/chunks/ssr/[root-of-the-server]__bfba58e6._.js.map +1 -1
  87. package/web/.next/server/chunks/ssr/[root-of-the-server]__c3ab8422._.js +1 -1
  88. package/web/.next/server/chunks/ssr/[root-of-the-server]__c3ab8422._.js.map +1 -1
  89. package/web/.next/server/chunks/ssr/_02ec1aea._.js +1 -1
  90. package/web/.next/server/chunks/ssr/_02ec1aea._.js.map +1 -1
  91. package/web/.next/server/chunks/ssr/{_1ff3035b._.js → _16ef149e._.js} +2 -2
  92. package/web/.next/server/chunks/ssr/{_1ff3035b._.js.map → _16ef149e._.js.map} +1 -1
  93. package/web/.next/server/chunks/ssr/_7dca1882._.js +1 -1
  94. package/web/.next/server/chunks/ssr/_7dca1882._.js.map +1 -1
  95. package/web/.next/server/chunks/ssr/{_4a4b4e1a._.js → _8bceaf55._.js} +2 -2
  96. package/web/.next/server/chunks/ssr/{_4a4b4e1a._.js.map → _8bceaf55._.js.map} +1 -1
  97. package/web/.next/server/chunks/ssr/_a9f57758._.js +1 -1
  98. package/web/.next/server/chunks/ssr/_d8575088._.js +1 -1
  99. package/web/.next/server/chunks/ssr/_d8575088._.js.map +1 -1
  100. package/web/.next/server/chunks/ssr/_f39a1adb._.js +1 -1
  101. package/web/.next/server/chunks/ssr/_f39a1adb._.js.map +1 -1
  102. package/web/.next/server/chunks/ssr/b1a17_presentation_web_components_features_settings_settings-page-client_tsx_6ed9d5f8._.js +1 -1
  103. package/web/.next/server/chunks/ssr/b1a17_presentation_web_components_features_settings_settings-page-client_tsx_6ed9d5f8._.js.map +1 -1
  104. package/web/.next/server/chunks/ssr/{src_presentation_web_1769b67a._.js → src_presentation_web_0045d310._.js} +2 -2
  105. package/web/.next/server/chunks/ssr/{src_presentation_web_1769b67a._.js.map → src_presentation_web_0045d310._.js.map} +1 -1
  106. package/web/.next/server/chunks/ssr/src_presentation_web_8e7fe0d1._.js +2 -2
  107. package/web/.next/server/chunks/ssr/src_presentation_web_8e7fe0d1._.js.map +1 -1
  108. package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_(dashboard)_page_actions_ca051134.js +1 -1
  109. package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_(dashboard)_page_actions_ca051134.js.map +1 -1
  110. package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_skills_page_actions_1b176e3c.js +1 -1
  111. package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_skills_page_actions_1b176e3c.js.map +1 -1
  112. package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_tools_page_actions_bd9f0dda.js +1 -1
  113. package/web/.next/server/chunks/ssr/src_presentation_web__next-internal_server_app_tools_page_actions_bd9f0dda.js.map +1 -1
  114. package/web/.next/server/chunks/ssr/src_presentation_web_b9023017._.js +2 -2
  115. package/web/.next/server/chunks/ssr/src_presentation_web_b9023017._.js.map +1 -1
  116. package/web/.next/server/chunks/ssr/src_presentation_web_components_e599bb8c._.js +1 -1
  117. package/web/.next/server/chunks/ssr/src_presentation_web_components_e599bb8c._.js.map +1 -1
  118. package/web/.next/server/chunks/ssr/src_presentation_web_components_features_control-center_7ac3562e._.js +1 -1
  119. package/web/.next/server/chunks/ssr/src_presentation_web_components_features_control-center_7ac3562e._.js.map +1 -1
  120. package/web/.next/server/pages/500.html +2 -2
  121. package/web/.next/server/server-reference-manifest.js +1 -1
  122. package/web/.next/server/server-reference-manifest.json +38 -38
  123. package/web/.next/static/chunks/08fe95f4d4aa563f.js +1 -0
  124. package/web/.next/static/chunks/{ecfe17fa09ff543e.js → 22ae980d8aac10f1.js} +1 -1
  125. package/web/.next/static/chunks/3f16e12adcd8b74c.js +2 -0
  126. package/web/.next/static/chunks/{5541ee6e8c3dfbc0.js → 66aeb95d8f7c4cea.js} +1 -1
  127. package/web/.next/static/chunks/{24ab1a6841758200.js → 6b50d1b354c18cbf.js} +1 -1
  128. package/web/.next/static/chunks/{554010ffa090b3cb.js → 9e967a66f56f18e0.js} +1 -1
  129. package/web/.next/static/chunks/be53c17c52e3f4ec.js +1 -0
  130. package/web/.next/static/chunks/{bd5910aa46e4f7f8.js → becc612a0fd16dbe.js} +1 -1
  131. package/web/.next/static/chunks/{431ebee69d487093.js → c64555bf30144084.js} +1 -1
  132. package/web/.next/static/chunks/{665bc0be216c6374.js → d69e172a4137599a.js} +1 -1
  133. package/web/.next/static/chunks/{1e7aa4fc00db4d85.js → f237664803f2aa48.js} +2 -2
  134. package/web/.next/static/chunks/{81e8a59652c53338.js → fd07085f271e62ad.js} +1 -1
  135. package/web/.next/static/chunks/46488328b6d76dcf.js +0 -1
  136. package/web/.next/static/chunks/5f401fd30f6e8a29.js +0 -1
  137. package/web/.next/static/chunks/a90d02d0338ca269.js +0 -2
  138. /package/web/.next/static/{fBDTRerkah3YOaOkhqEUT → bHwwAJ0fv-Jcs5NRAjOmY}/_buildManifest.js +0 -0
  139. /package/web/.next/static/{fBDTRerkah3YOaOkhqEUT → bHwwAJ0fv-Jcs5NRAjOmY}/_clientMiddlewareManifest.json +0 -0
  140. /package/web/.next/static/{fBDTRerkah3YOaOkhqEUT → bHwwAJ0fv-Jcs5NRAjOmY}/_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 l=a(this._isDirected,e,t,n);if(Object.hasOwn(this._edgeLabels,l))return s&&(this._edgeLabels[l]=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[l]=s?o:this._defaultEdgeLabelFn(e,t,n);var d=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=d.v,t=d.w,Object.freeze(d),this._edgeObjs[l]=d,r(this._preds[t],e),r(this._sucs[e],t),this._in[t][l]=d,this._out[e][l]=d,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()}}),l=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}}}),d=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(),l=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)},d=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;l({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++,d(),a);u++);if(s===c-1&&(a=!1,d(),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={},l=new r,d=function(e){var t=e.v!==a?e.v:e.w,r=i[t],o=n(e),d=s.distance+o;if(o<0)throw Error("dijkstra does not allow negative edge weights. Bad edge: "+e+" Weight: "+o);d<r.distance&&(r.distance=d,r.predecessor=a,l.decrease(t,d))};for(e.nodes().forEach(function(e){var r=e===t?0:1/0;i[e]={distance:r},l.add(e,r)});l.size()>0&&(s=i[a=l.removeMin()]).distance!==1/0;)o(a).forEach(d);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 l,d=[];do n[l=r.pop()].onStack=!1,d.push(l);while(s!==l)o.push(d)}}(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,l;return o=e,a=t||r,s=n||function(t){return e.outEdges(t)},i={},(l=o.nodes()).forEach(function(e){i[e]={},i[e][e]={distance:0},l.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}})}),l.forEach(function(e){var t=i[e];l.forEach(function(r){var n=i[r];l.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}),y=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}}),b=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=b();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 l(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 d=!1;i.size()>0;){if(Object.hasOwn(s,o=i.removeMin()))a.setEdge(o,s[o]);else{if(d)throw Error("Input graph is not connected: "+e);d=!0}e.nodeEdges(o).forEach(l)}return a}}),N=n((e,t)=>{var r=h(),n=d();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(),l=0;l<i.length;l++){for(var d=a(i[l]),c=0;c<d.length;c++){var u=d[c],h=u.v===i[l]?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:d(),components:c(),dijkstra:h(),dijkstraAll:f(),extractPath:p(),findCycles:m(),floydWarshall:v(),isAcyclic:y(),postorder:E(),preorder:k(),prim:j(),shortestPaths:N(),reduce:b(),tarjan:g(),topsort:x()}}),_=i();t.exports={Graph:_.Graph,json:l(),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 d,c,u,h,f;if(1>=e.nodeCount())return[];let p=(a=e,s=t||o,d=new r,c=0,u=0,a.nodes().forEach(e=>{d.setNode(e,{v:e,in:0,out:0})}),a.edges().forEach(e=>{let t=d.edge(e.v,e.w)||0,r=s(e);d.setEdge(e.v,e.w,t+r),u=Math.max(u,d.node(e.v).out+=r),c=Math.max(c,d.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,d.nodes().forEach(e=>{l(h,f,d.node(e))}),{graph:d,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,l(t,r,i)}),e.outEdges(n.v).forEach(n=>{let o=e.edge(n),a=n.w,s=e.node(a);s.in-=o,l(t,r,s)}),e.removeNode(n.v),a}function l(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)}}),l=o((e,t)=>{var r=a().Graph;function n(e,t,r,n){for(var o=n;e.hasNode(o);)o=l(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=d(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,l=e.width/2,d=e.height/2;if(!s&&!i)throw Error("Not possible to find intersection inside of the rectangle");return Math.abs(i)*l>Math.abs(s)*d?(i<0&&(d=-d),r=d*s/i,n=d):(s<0&&(l=-l),r=l,n=l*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:d,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:l,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 l(e){return e+""+ ++i}function d(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),{})}}),d=o((e,t)=>{var r=i(),n=l().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=l();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,l=t.w,d=e.node(l).rank,c=t.name,u=e.edge(t),h=u.labelRank;if(d!==i+1){for(e.removeEdge(t),a=0,++i;i<d;++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,l,{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}=l();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}),l=e.nodes()[0],d=e.nodeCount();for(i.setNode(l,{});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()<d;)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,d=l().simplify;function c(e){o(e=d(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,l=i?a.w:a.v;if(l!==n){var d,c,u,h=i===o,f=t.edge(a).weight;if(s+=h?f:-f,d=e,c=r,u=l,d.hasEdge(c,u)){var p=e.edge(r,l).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),l=s,d=!1;return s.lim>i.lim&&(l=i,d=!0),t.edges().filter(t=>d===y(e,e.node(t.v),l)&&d!==y(e,e.node(t.w),l)).reduce((e,r)=>n(t,r)<n(t,e)?r:e)}function x(e,t,r,n){var o,a,i,l,d=r.v,c=r.w;e.removeEdge(d,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),(l=(l=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 y(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),l,d;l=r;do o.push(l=e.parent(l));while(l&&(t[l].low>s||i>t[l].lim))for(d=l,l=n;(l=e.parent(l))!==d;)a.push(l);return{path:o.concat(a.reverse()),lca:d}}(e,o,n.v,n.w),s=a.path,i=a.lca,l=0,d=s[0],c=!0;for(;t!==n.w;){if(r=e.node(t),c){for(;(d=s[l])!==i&&e.node(d).maxRank<r.rank;)l++;d===i&&(c=!1)}if(!c){for(;l<s.length-1&&e.node(d=s[l+1]).minRank<=r.rank;)l++;d=s[l]}e.setParent(t,d),t=e.successors(t)[0]}})}}),m=o((e,t)=>{var r=l();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),l=r.applyWithChunking(Math.max,i)-1,d=2*l+1;e.graph().nestingRoot=a,e.edges().forEach(t=>e.edge(t).minlen*=d);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,l){let d=t.children(l);if(!d.length){l!==n&&t.setEdge(n,l,{weight:0,minlen:o});return}let c=r.addBorderNode(t,"_bt"),u=r.addBorderNode(t,"_bb"),h=t.node(l);t.setParent(c,l),h.borderTop=c,t.setParent(u,l),h.borderBottom=u,d.forEach(r=>{e(t,n,o,a,s,i,r);let d=t.node(r),h=d.borderTop?d.borderTop:r,f=d.borderBottom?d.borderBottom:r,p=d.borderTop?a:2*a,g=h!==f?1:s-i[l]+1;t.setEdge(c,h,{weight:p,minlen:g,nestingEdge:!0}),t.setEdge(f,u,{weight:p,minlen:g,nestingEdge:!0})}),t.parent(l)||t.setEdge(n,c,{weight:0,minlen:s+i[l]})})(e,a,d,c,l,s,t)),e.graph().nodeRankFactor=d},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=l();function n(e,t,n,o,a,s){let i=a[t][s-1],l=r.addDummyNode(e,"border",{width:0,height:0,rank:s,borderType:t},n);a[t][s]=l,e.setParent(l,o),i&&e.setEdge(i,l,{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))}}}),y=o((e,t)=>{var r=l();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}}),b=o((e,t)=>{var r=l().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 l=Array(i).fill(0),d=0;return a.forEach(e=>{let t=e.pos+s;l[t]+=e.weight;let r=0;for(;t>0;)t%2&&(r+=l[t+1]),t=t-1>>1,l[t]+=e.weight;d+=e.weight*r}),d}(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=l();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=l();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),l=[],d=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(l,i,u),s.forEach(e=>{u+=e.vs.length,l.push(e.vs),d+=e.barycenter*e.weight,c+=e.weight,u=n(l,i,u)});let h={vs:l.flat(!0)};return c&&(h.barycenter=d/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 l,d;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);l=m,d=p,l.forEach(e=>{e.vs=e.vs.flatMap(e=>d[e]?d[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=l();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=y(),n=b(),o=j(),s=N(),i=C(),d=a().Graph,c=l();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),l=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 d;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?l: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=l();function o(e,t){let r={};return t.length&&t.reduce(function(t,n){let o=0,a=0,s=t.length,l=n[n.length-1];return n.forEach((t,d)=>{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===l)&&(n.slice(a,d+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=d+1,o=u)}),n}),r}function s(e,t){let r={};function o(t,o,a,s,l){let d;n.range(o,a).forEach(n=>{d=t[n],e.node(d).dummy&&e.predecessors(d).forEach(t=>{let n=e.node(t);n.dummy&&(n.order<s||n.order>l)&&i(r,t,d)})})}return t.length&&t.reduce(function(t,r){let n=-1,a,s=0;return r.forEach((i,l)=>{if("border"===e.node(i).dummy){let t=e.predecessors(i);t.length&&(a=e.node(t[0]).order,o(r,s,l,n,a),s=l,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 d(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 l=Math.floor(n),c=Math.ceil(n);l<=c;++l){let n=i[l];a[e]===e&&t<s[n]&&!d(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,l,d,c,u,h;let f,p,g,m={},v=(s=e,i=t,l=n,d=a,f=new r,g=(c=(p=s.graph()).nodesep,u=p.edgesep,h=d,(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=l[e];if(f.setNode(r),t){var n=l[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 y(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 y(function(e){m[e]=v.inEdges(e).reduce((e,t)=>Math.max(e,m[t.v]+v.edge(t)),0)},v.predecessors.bind(v)),y(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,l=e[i];if(l===t)return;let d=Object.values(l),c=o-n.applyWithChunking(Math.min,d);"l"!==s&&(c=a-n.applyWithChunking(Math.max,d)),c&&(e[i]=n.mapValues(l,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),l=c(e,i,r,s),d=u(e,i,l.root,l.align,"r"===t);"r"===t&&(d=n.mapValues(d,e=>-e)),a[o+t]=d})});let l=h(e,a);return f(a,l),p(a,e.graph().align)},findType1Conflicts:o,findType2Conflicts:s,addConflict:i,hasConflict:d,verticalAlignment:c,horizontalCompaction:u,alignCoordinates:f,findSmallestWidthAlignment:h,balance:p}}),R=o((e,t)=>{var r=l(),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)}}),S=o((e,t)=>{var r=d(),n=c(),o=p(),s=l().normalizeRanks,i=g(),u=l().removeEmptyRanks,h=m(),f=v(),y=x(),b=_(),w=R(),E=l(),k=a().Graph;t.exports=function(e,t={}){let a=t.debugTiming?E.time:E.notime;return a("layout",()=>{let l=a(" buildLayoutGraph",()=>{var t;let r,n;return t=e,r=new k({multigraph:!0,compound:!0}),n=F(t.graph()),r.setGraph(Object.assign({},N,L(n,j),E.pick(n,C))),t.nodes().forEach(e=>{let n=L(F(t.node(e)),O);Object.keys(S).forEach(e=>{void 0===n[e]&&(n[e]=S[e])}),r.setNode(e,n),r.setParent(e,t.parent(e))}),t.edges().forEach(e=>{let n=F(t.edge(e));r.setEdge(e,Object.assign({},P,L(n,M),E.pick(n,T)))}),r});return a(" runLayout",()=>{var e,d,c;return e=l,d=a,c=t,void(d(" 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)}))}),d(" 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)}})}),d(" acyclic",()=>r.run(e)),d(" nestingGraph.run",()=>h.run(e)),d(" rank",()=>o(E.asNonCompoundGraph(e))),d(" 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")}})}),d(" removeEmptyRanks",()=>u(e)),d(" nestingGraph.cleanup",()=>h.cleanup(e)),d(" normalizeRanks",()=>s(e)),d(" 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)}),d(" 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))})}),d(" normalize.run",()=>n.run(e)),d(" parentDummyChains",()=>i(e)),d(" addBorderSegments",()=>f(e)),d(" order",()=>b(e,c)),d(" 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})})}),d(" adjustCoordinateSystem",()=>y.adjust(e)),d(" position",()=>w(e)),d(" 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}})}),d(" 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)})}),d(" normalize.undo",()=>n.undo(e)),d(" 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}})}),d(" undoCoordinateSystem",()=>y.undo(e)),d(" 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 l(e){let a=e.x,s=e.y,i=e.width,l=e.height;t=Math.min(t,a-i/2),r=Math.max(r,a+i/2),n=Math.min(n,s-l/2),o=Math.max(o,s+l/2)}e.nodes().forEach(t=>l(e.node(t))),e.edges().forEach(t=>{let r=e.edge(t);Object.hasOwn(r,"x")&&l(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)),d(" 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))})}),d(" reversePoints",()=>{var t;(t=e).edges().forEach(e=>{let r=t.edge(e);r.reversed&&r.points.reverse()})}),d(" acyclic.undo",()=>r.undo(e)))}),a(" updateInputGraph",()=>{var t,r;return t=e,r=l,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)}),l})};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"],S={width:0,height:0},M=["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 F(e){var t={};return e&&Object.entries(e).forEach(([e,r])=>{"string"==typeof e&&(e=e.toLowerCase()),t[e]=r}),t}}),M=o((e,t)=>{var r=l(),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:S(),debug:M(),util:{time:l().time,notime:l().notime},version:P()}})(),L={direction:"LR",ranksep:200,nodesep:30},F={featureNode:{width:288,height:140},repositoryNode:{width:400,height:140}};function D(e,t){let r=e.data;return r&&"number"==typeof r.width&&"number"==typeof r.height?{width:r.width,height:r.height}:F[e.type??""]??t}function A(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 l=new Set;for(let e of t)l.add(e.source),l.add(e.target);let d=e.filter(e=>l.has(e.id)),c=e.filter(e=>!l.has(e.id));for(let e of d){let t=D(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 d){let t=i.node(e.id),r=D(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=D(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 y=[...[...l].filter(e=>p.has(e)&&!x.has(e)),...c.map(e=>e.id)];y.sort((e,t)=>(v.get(e)??0)-(v.get(t)??0));let b=new Map;for(let e of y)!function e(t){if(b.has(t))return b.get(t);let r=p.get(t),n=f?r.h:r.w,o=m.get(t);if(!o||0===o.length)return b.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 b.set(t,i),i}(e);let w=0;for(let e of y){let t=b.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+=b.get(e)??0;let i=r-(a+=(o.length-1)*s)/2;for(let t of o){let r=b.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 I=e.i(21023);let $=(0,I.createServerReference)("78c04c8f47695b3fc5238e8367cb0ae21950aeb0ae",I.callServer,void 0,I.findSourceMapURL,"deleteFeature");var z=e.i(65181),G=e.i(41383);let B=(0,I.createServerReference)("40935a7e5482a5d0791f0ae90a49cf07b6c5361cd2",I.callServer,void 0,I.findSourceMapURL,"stopFeature");var q=e.i(9700);let W=(0,I.createServerReference)("40e54d68cc272390ab043ca883426ab0a5e4afc684",I.callServer,void 0,I.findSourceMapURL,"deleteRepository"),U=(0,I.createServerReference)("40eb7406f36b58d3c450c1a106f8b3120443992908",I.callServer,void 0,I.findSourceMapURL,"getFeatureMetadata");var V=e.i(39443),H=e.i(8361),X=e.i(18354),J=e.i(99045);function K(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 Y(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)}function Q(e,t){if(e.size!==t.size)return!1;for(let[r,n]of e){let e=t.get(r);if(!e||n.parentNodeId!==e.parentNodeId||n.data!==e.data&&JSON.stringify(n.data)!==JSON.stringify(e.data))return!1}return!0}let Z=(0,X.createLogger)("[Polling]"),ee=0,et=0;function er(e,o){let a=(0,r.useRouter)(),s=(0,H.useSoundAction)("delete"),i=(0,H.useSoundAction)("create"),{nodes:l,edges:d,reconcile:c,updateFeature:u,addPendingFeature:h,removeFeature:f,restoreFeature:p,addRepository:g,removeRepository:m,replaceRepository:v,getFeatureRepositoryPath:x,getRepositoryData:y,getRepoMapSize:b,setCallbacks:w,beginMutation:E,endMutation:k,isMutating:j}=function(e,r){let n=(0,t.useMemo)(()=>K(e,r),[]),[o,a]=(0,t.useState)(n.featureMap),[s,i]=(0,t.useState)(n.repoMap),[l,d]=(0,t.useState)(new Map),c=(0,t.useRef)(new Map),u=(0,t.useRef)(new Set),h=(0,t.useRef)(0),f=(0,t.useRef)(new Set),p=(0,t.useRef)(new Set),g=(0,t.useRef)({}),m=(0,t.useMemo)(()=>({onNodeAction:e=>g.current.onNodeAction?.(e),onNodeSettings:e=>g.current.onNodeSettings?.(e),onFeatureDelete:(e,t,r,n)=>g.current.onFeatureDelete?.(e,t,r,n),onRepositoryAdd:e=>g.current.onRepositoryAdd?.(e),onRepositoryClick:e=>g.current.onRepositoryClick?.(e),onRepositoryDelete:e=>g.current.onRepositoryDelete?.(e),onRetryFeature:e=>g.current.onRetryFeature?.(e),onStartFeature:e=>g.current.onStartFeature?.(e)}),[]),v=(0,t.useRef)(o);v.current=o;let x=(0,t.useRef)(s);x.current=s;let y=(0,t.useMemo)(()=>(function(e,t,r,n){let o=[],a=[],s=e=>e.replace(/\\/g,"/"),i=new Map;for(let[e,r]of t)r.data.repositoryPath&&i.set(s(r.data.repositoryPath),e);let l=new Map;for(let[e,r]of[...t.entries()].sort((e,t)=>{let r=e[1].data.createdAt,n=t[1].data.createdAt;return("number"!=typeof r||Number.isNaN(r)?1/0:r)-("number"!=typeof n||Number.isNaN(n)?1/0:n)})){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,c]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||c,r={...d.data,...!e&&n?.onNodeAction&&{onAction:()=>n.onNodeAction(t)},...!e&&n?.onNodeSettings&&{onSettings:()=>n.onNodeSettings(t)},...!e&&n?.onFeatureDelete&&{onDelete:n.onFeatureDelete},...!e&&"error"===d.data.state&&n?.onRetryFeature&&{onRetry:n.onRetryFeature},...!e&&"pending"===d.data.state&&n?.onStartFeature&&{onStart:n.onStartFeature},...!e&&("running"===d.data.state||"action-required"===d.data.state)&&n?.onStopFeature&&{onStop:n.onStopFeature}};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=s(d.data.repositoryPath),r=i.get(e)??function(e){if(l.has(e))return l.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}}),l.set(e,t),t}(e);a.push({id:`edge-${r}-${t}`,source:r,target:t,style:{strokeDasharray:"5 5"}})}}let d=new Set;for(let e of a)"dependencyEdge"===e.type&&d.add(e.source);let c=a.length>0;for(let e of o){let t=e.data;t.showHandles=c,"featureNode"===e.type&&(t.hasChildren=d.has(e.id))}return{nodes:o,edges:a}})(o,s,l,m),[o,s,l,m]),b=(0,t.useRef)({key:"",positions:new Map}),{nodes:w,edges:E}=(0,t.useMemo)(()=>{let e=y.nodes.map(e=>e.id).sort().join(","),t=y.edges.map(e=>`${e.source}-${e.target}`).sort().join(","),r=`${e}|${t}`;if(r!==b.current.key){let e=A(y.nodes,y.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=b.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 b.current={key:r,positions:t},e}let{positions:n}=b.current;return{nodes:y.nodes.map(e=>{let t=n.get(e.id);return t?{...e,...t}:e}),edges:y.edges}},[y]),k=(0,t.useCallback)((e,t)=>{if(h.current>0)return;let{featureMap:r,repoMap:n}=K(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"}}):p.current.has(t)||(n.set(t,r),a.add(t)));for(let[e,t]of(p.current=a,c.current)){let r=n.get(e);r&&(n.set(e,{...r,data:{...r.data,...t}}),c.current.delete(e))}return Q(e,n)?e:n}),d(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 Q(e,t)?e:t})},[]),j=(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),Y(n.data,t))return r;let o=new Map(r);return o.set(e,{...n,data:{...n.data,...t}}),o}),d(r=>{let n=r.get(e);if(!n||Y(n.data,t))return r;let o=new Map(r);return o.set(e,{...n,data:{...n.data,...t}}),o})},[]),N=(0,t.useCallback)((e,t,r)=>{d(n=>{let o=new Map(n);return o.set(e,{nodeId:e,data:t,parentNodeId:r}),o})},[]),C=(0,t.useCallback)(e=>{d(t=>{if(!t.has(e))return t;let r=new Map(t);return r.delete(e),r})},[]),_=(0,t.useCallback)(e=>{a(t=>{if(!t.has(e))return t;let r=new Map(t);return r.delete(e),r})},[]),O=(0,t.useCallback)((e,t)=>{a(r=>{let n=new Map(r);return n.set(e,t),n})},[]),R=(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})},[]),S=(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})},[]),M=(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})},[]),P=(0,t.useCallback)(e=>v.current.get(e)?.data.repositoryPath,[]),T=(0,t.useCallback)(e=>x.current.get(e)?.data,[]),F=(0,t.useCallback)(()=>x.current.size,[]),D=(0,t.useCallback)(e=>{g.current=e},[]),I=(0,t.useCallback)(()=>{h.current++},[]),$=(0,t.useCallback)((e=3e3)=>{let t=setTimeout(()=>{h.current=Math.max(0,h.current-1),f.current.delete(t)},e);f.current.add(t)},[]),z=(0,t.useCallback)(()=>h.current>0,[]);return(0,t.useEffect)(()=>{let e=f.current;return()=>{for(let t of e)clearTimeout(t);e.clear()}},[]),{nodes:w,edges:E,reconcile:k,updateFeature:j,addPendingFeature:N,removePendingFeature:C,removeFeature:_,restoreFeature:O,addRepository:R,removeRepository:S,replaceRepository:M,getFeatureRepositoryPath:P,getRepositoryData:T,getRepoMapSize:F,setCallbacks:D,beginMutation:I,endMutation:$,isMutating:z}}(e,o),N=(0,t.useRef)(l),C=(0,t.useRef)(d);(0,t.useEffect)(()=>{N.current=l,C.current=d},[l,d]);let _=(0,t.useMemo)(()=>e.map(e=>e.id).sort().join(","),[e]),O=(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]),R=(0,t.useRef)("");(0,t.useEffect)(()=>{let t=`${_}|${O}`;t!==R.current&&(R.current=t,c(e,o))},[_,O,e,o,c]);let S=(0,t.useRef)(new Map),{events:M}=(0,V.useAgentEventsContext)();(0,t.useEffect)(()=>{let t=S.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&&(M.some(t=>t.featureId===e.featureId&&(0,J.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)}},[O,e,M,a]);let P=(0,t.useRef)(0);(0,t.useEffect)(()=>{if(P.current>M.length&&(P.current=0),M.length<=P.current)return;let e=M.slice(P.current);for(let{featureId:t,state:r,lifecycle:n}of(P.current=M.length,(0,J.resolveSseEventUpdates)(e)))if(void 0!==r||void 0!==n){let e=`feat-${t}`,o=N.current.find(t=>t.id===e),a=o?o.data.state:void 0;if("deleting"===a||"error"===r&&j()&&"running"===a)continue;u(e,{...void 0!==r&&{state:r},...void 0!==n&&{lifecycle:n}})}},[M,u,j]),(0,t.useEffect)(()=>{let e=e=>{let{featureId:t}=e.detail;E(),u(`feat-${t}`,{state:"running"}),k()};return window.addEventListener("shep:feature-approved",e),()=>window.removeEventListener("shep:feature-approved",e)},[u,E,k]);let T=(0,t.useRef)(new Set),F=(0,t.useRef)(0);(0,t.useEffect)(()=>{if(F.current>M.length&&(F.current=0),M.length<=F.current)return;let e=M.slice(F.current);for(let t of(F.current=M.length,e)){if("Feature metadata updated"!==t.message||T.current.has(t.featureId))continue;T.current.add(t.featureId);let e=`feat-${t.featureId}`;U(t.featureId).then(t=>{t&&u(e,{name:t.name,description:t.description})}).catch(()=>{})}},[M,u]),(0,t.useEffect)(()=>{Z.debug("polling enabled (3000ms interval)");let e=setInterval(async()=>{if(!j())try{let e=await fetch("/api/graph-data");if(!e.ok)throw Error(`status ${e.status}`);let{nodes:t,edges:r}=await e.json();c(t,r)}catch{Z.warn("poll fetch failed — will retry next interval")}},3e3);return()=>{Z.debug("polling disabled"),clearInterval(e)}},[c,j]);let D=(0,t.useCallback)(e=>{},[]),I=(0,t.useCallback)(e=>{},[]),X=(0,t.useCallback)((e,t,r)=>{let n=t?.featureId?`feat-${t.featureId}`:`feature-${Date.now()}-${ee++}`,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]),er=(0,t.useCallback)(e=>{let t=`feat-${e}`;E(),u(t,{state:"running"}),(0,z.resumeFeature)(e).then(e=>{e.error?(u(t,{state:"error"}),n.toast.error(e.error)):n.toast.success("Feature resumed")}).catch(()=>{u(t,{state:"error"}),n.toast.error("Failed to resume feature")}).finally(()=>k())},[u,E,k]),en=(0,t.useCallback)(e=>{let t=`feat-${e}`;E(),u(t,{state:"running"}),(0,G.startFeature)(e).then(e=>{e.error?(u(t,{state:"pending"}),n.toast.error(e.error)):n.toast.success("Feature started")}).catch(()=>{u(t,{state:"pending"}),n.toast.error("Failed to start feature")}).finally(()=>k())},[u,E,k]),eo=(0,t.useCallback)(e=>{E(),B(e).then(e=>{e.error?n.toast.error(e.error):n.toast.success("Agent stopped")}).catch(()=>{n.toast.error("Failed to stop agent")}).finally(()=>k())},[E,k]),ea=(0,t.useCallback)((e,t,r,o)=>{let i=`feat-${e}`,l=[];if(!0===r){let e=[i];for(;e.length>0;){let t=e.shift();for(let r of C.current)"dependencyEdge"===r.type&&r.source===t&&(l.push(r.target),e.push(r.target))}}let d=new Map;for(let e of[i,...l]){let t=N.current.find(t=>t.id===e);t&&d.set(e,t.data.state)}for(let e of(E(),u(i,{state:"deleting"}),l))u(e,{state:"deleting"});s.play(),a.push("/"),$(e,t,r,o).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(i),l))f(e)}).catch(()=>{for(let[e,t]of d)t&&u(e,{state:t});n.toast.error("Failed to delete feature")}).finally(()=>k())},[a,s,u,f,E,k]),es=(0,t.useCallback)(async e=>{let t=`repo-${e}`,r=new Set(C.current.filter(e=>e.source===t).map(e=>e.target)),o=y(t),a=new Map;for(let e of r){let t=N.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(E(),m(t),r))f(e);try{let t=await W(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()}finally{k()}},[s,m,f,g,p,y,E,k]),ei=(0,t.useCallback)(e=>{let t=A(N.current,C.current,{...L,direction:e});c(t.nodes,t.edges)},[c]);return{nodes:l,edges:d,onNodesChange:D,handleConnect:I,handleAddRepository:(0,t.useCallback)(e=>{let t=0===b(),r=`repo-temp-${++et}`,o=e.replace(/[\\/]+$/,"").split(/[\\/]/).pop()??e;return E(),g(r,{name:o,repositoryPath:e,id:r,createdAt:Date.now(),gitInfoStatus:"loading"}),(0,q.addRepository)({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")}).finally(()=>k()),{wasEmpty:t,repoPath:e}},[g,m,v,i,b,E,k]),handleLayout:ei,handleDeleteFeature:ea,handleRetryFeature:er,handleStartFeature:en,handleStopFeature:eo,handleDeleteRepository:es,createFeatureNode:X,getFeatureRepositoryPath:x,getRepositoryData:y,setCallbacks:w}}e.s(["useControlCenterState",()=>er],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(38227),i=e.i(31777),l=e.i(35364);e.i(54793);var d=e.i(7729);e.i(47506);var c=e.i(89313),u=e.i(92002),h=e.i(82569),f=e.i(8986),p=e.i(38573),g=e.i(19933),m=e.i(67669),v=e.i(24042),x=e.i(64970),y=e.i(49228),b=e.i(65530),w=e.i(7311);let E=(0,e.i(3645).default)("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);e.i(81803);var k=e.i(72714),j=e.i(2287),N=e.i(2828),C=e.i(8537),_=e.i(75921),O=e.i(76852),R=e.i(80519);function S({data:e}){let d=(0,o.useRouter)(),c=(0,_.useFeatureFlags)(),[S,M]=(0,n.useState)(!1),P=(0,O.useRepositoryActions)(e.repositoryPath?{repositoryPath:e.repositoryPath}:null),T=(0,C.useDeployAction)(e.repositoryPath?{targetId:e.repositoryPath,targetType:"repository",repositoryPath:e.repositoryPath}:null),L="Booting"===T.status||"Ready"===T.status,F=(0,n.useCallback)((t,r)=>{if(!e.repositoryPath)return;let n=t.preview?t.preview.slice(0,200):"Unknown conversation",o=["Continue work from a previous agent session.","","## Session Context",`- Session ID: ${t.id}`,`- Messages: ${t.messageCount}`,t.lastMessageAt?`- Last active: ${t.lastMessageAt}`:"",`- Conversation file: ${r}`,"","## Session Preview",`> ${n}`,"","## Instructions","1. Read the full conversation history from the file above",`2. Analyze the current state of the repository — what was done, what remains`,"3. Create or update spec files to accurately reflect the current state and remaining work","4. Continue implementing any unfinished work from the conversation"].filter(Boolean).join("\n"),a=new URLSearchParams({repo:e.repositoryPath,prompt:o});d.push(`/create?${a.toString()}`)},[e.repositoryPath,d]);return(0,t.jsxs)("div",{className:(0,i.cn)("group relative",e.onDelete&&e.id&&"pl-10"),children:[e.showHandles?(0,t.jsx)(r.Handle,{type:"target",position:u.Position.Left,isConnectable:!1,className:"opacity-0!",style:{top:70}}):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)(N.TooltipProvider,{children:(0,t.jsxs)(N.Tooltip,{children:[(0,t.jsx)(N.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("button",{"aria-label":"Remove repository","data-testid":"repository-node-delete-button",onClick:e=>{e.stopPropagation(),M(!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)(m.Trash2,{className:"h-3.5 w-3.5"})})}),(0,t.jsx)(N.TooltipContent,{children:"Remove repository"})]})})}),(0,t.jsx)(j.Dialog,{open:S,onOpenChange:M,children:(0,t.jsxs)(j.DialogContent,{className:"max-w-xs",children:[(0,t.jsxs)(j.DialogHeader,{children:[(0,t.jsx)(j.DialogTitle,{children:"Remove repository?"}),(0,t.jsxs)(j.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)(j.DialogFooter,{className:"grid grid-cols-2 gap-2 sm:flex-none",children:[(0,t.jsx)(j.DialogClose,{asChild:!0,children:(0,t.jsx)(l.Button,{variant:"outline",children:"Cancel"})}),(0,t.jsx)(l.Button,{variant:"destructive",onClick:()=>{M(!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 w-[26rem] cursor-pointer flex-col overflow-hidden rounded-xl border shadow-sm",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3",children:[(0,t.jsx)(h.Github,{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,i.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)(N.TooltipProvider,{children:(0,t.jsxs)(N.Tooltip,{children:[(0,t.jsx)(N.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(k.ActionButton,{label:"Open in IDE",onClick:P.openInIde,loading:P.ideLoading,error:!!P.ideError,icon:f.Code2,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(N.TooltipContent,{children:"Open in IDE"})]})}),(0,t.jsx)(N.TooltipProvider,{children:(0,t.jsxs)(N.Tooltip,{children:[(0,t.jsx)(N.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(k.ActionButton,{label:"Open in Shell",onClick:P.openInShell,loading:P.shellLoading,error:!!P.shellError,icon:p.Terminal,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(N.TooltipContent,{children:"Open in Shell"})]})}),(0,t.jsx)(N.TooltipProvider,{children:(0,t.jsxs)(N.Tooltip,{children:[(0,t.jsx)(N.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(k.ActionButton,{label:"Open Folder",onClick:P.openFolder,loading:P.folderLoading,error:!!P.folderError,icon:g.FolderOpen,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(N.TooltipContent,{children:"Open Folder"})]})}),(0,t.jsx)(R.FeatureSessionsDropdown,{repositoryPath:e.repositoryPath,onCreateFromSession:F})]}):null,e.onAdd?(0,t.jsx)(N.TooltipProvider,{children:(0,t.jsxs)(N.Tooltip,{children:[(0,t.jsx)(N.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,i.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)(N.TooltipContent,{children:"Add feature"})]})}):null]})]}),e.branch?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{"data-testid":"repository-node-git-info",className:"text-muted-foreground border-t px-4 py-2",children:(0,t.jsxs)("div",{className:"flex items-center gap-3 text-xs",children:[(0,t.jsxs)("span",{className:"flex items-center gap-1 truncate","data-testid":"repository-node-branch",children:[(0,t.jsx)(y.GitBranch,{className:"h-3 w-3 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:e.branch})]}),null!=e.behindCount&&e.behindCount>0?(0,t.jsxs)("span",{className:"flex shrink-0 items-center gap-1 whitespace-nowrap text-amber-500","data-testid":"repository-node-behind",children:[(0,t.jsx)(w.ArrowDown,{className:"h-3 w-3 shrink-0"}),e.behindCount," behind"]}):null]})}),e.commitMessage?(0,t.jsx)("div",{"data-testid":"repository-node-commit-info",className:"text-muted-foreground border-t px-4 py-2",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,t.jsx)(b.GitCommitHorizontal,{className:"h-3 w-3 shrink-0"}),(0,t.jsx)("span",{className:"min-w-0 truncate","data-testid":"repository-node-commit-message",children:e.commitMessage}),e.committer?(0,t.jsxs)("span",{className:"text-muted-foreground/70 ml-auto flex shrink-0 items-center gap-1","data-testid":"repository-node-committer",children:[(0,t.jsx)(E,{className:"h-3 w-3 shrink-0"}),(0,t.jsx)("span",{children:e.committer})]}):null]})}):null]}):"not-a-repo"===e.gitInfoStatus?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{"data-testid":"repository-node-not-repo",className:"text-muted-foreground border-t px-4 py-2",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,t.jsx)(g.FolderOpen,{className:"h-3 w-3 shrink-0"}),(0,t.jsx)("span",{className:"min-w-0 truncate opacity-60",children:e.repositoryPath??"Unknown path"})]})}),(0,t.jsx)("div",{className:"text-muted-foreground border-t px-4 py-2",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs opacity-40",children:[(0,t.jsx)(y.GitBranch,{className:"h-3 w-3 shrink-0"}),(0,t.jsx)("span",{children:"Not a git repository"})]})})]}):"ready"!==e.gitInfoStatus?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{"data-testid":"repository-node-git-loading",className:"border-t px-4 py-2",children:(0,t.jsxs)("div",{className:"flex h-4 items-center gap-2 text-xs",children:[(0,t.jsx)(y.GitBranch,{className:"text-muted-foreground h-3 w-3 shrink-0"}),(0,t.jsx)("span",{className:"bg-muted h-3 w-20 animate-pulse rounded"})]})}),(0,t.jsx)("div",{className:"border-t px-4 py-2",children:(0,t.jsxs)("div",{className:"flex h-4 items-center gap-2 text-xs",children:[(0,t.jsx)(b.GitCommitHorizontal,{className:"text-muted-foreground h-3 w-3 shrink-0"}),(0,t.jsx)("span",{className:"bg-muted h-3 w-36 animate-pulse rounded"})]})})]}):null,c.envDeploy&&e.repositoryPath?(0,t.jsx)("div",{"data-testid":"repository-node-dev-preview",className:"border-t px-4 py-2",onClick:e=>e.stopPropagation(),children:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[T.deployError?(0,t.jsx)("span",{className:"truncate text-xs text-red-500",children:T.deployError}):L?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"mr-0.5 inline-block h-2 w-2 shrink-0 rounded-full bg-green-500"}),T.url?(0,t.jsx)("a",{href:T.url,target:"_blank",rel:"noopener noreferrer",className:"truncate text-green-700 hover:underline dark:text-green-400",children:T.url}):(0,t.jsx)("span",{className:"text-muted-foreground",children:"Starting..."})]}):(0,t.jsxs)("span",{className:"text-muted-foreground",children:["Run",(0,t.jsx)("span",{className:"text-muted-foreground/50 ml-2 text-[10px]",children:"start local environment"})]}),(0,t.jsx)(N.TooltipProvider,{children:(0,t.jsxs)(N.Tooltip,{children:[(0,t.jsx)(N.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"ml-auto flex items-center",children:(0,t.jsx)(k.ActionButton,{label:T.deployError?"Retry":L?"Stop Dev Server":"Start Dev Server",onClick:L?T.stop:T.deploy,loading:T.deployLoading||T.stopLoading,error:!1,icon:T.deployError?s.RotateCcw:L?x.Square:v.Play,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(N.TooltipContent,{children:L?"Stop Dev Server":"Start Dev Server"})]})})]})}):null]}),e.onAdd||e.showHandles?(0,t.jsx)(r.Handle,{type:"source",position:u.Position.Right,isConnectable:!e.showHandles,className:"opacity-0!",style:{top:70}}):null]})}function M(e){let[n]=(0,u.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 P={x:30,y:30,zoom:.85};function T({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)(s.RotateCcw,{style:{fill:"none"}})})}function L({nodes:e,edges:o,selectedFeatureId:s,defaultViewport:u,onNodesChange:h,onAddFeature:f,onConnect:p,onNodeClick:g,onPaneClick:m,onCanvasDrag:v,onMoveEnd:x,onResetViewport:y,toolbar:b,emptyState:w}){let E=(0,n.useMemo)(()=>({featureNode:c.FeatureNode,repositoryNode:S}),[]),k=(0,n.useMemo)(()=>({dependencyEdge:M}),[]),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,_]=(0,n.useState)(N),[O,R]=(0,n.useState)(!1),L=(0,n.useRef)(N);(0,n.useEffect)(()=>{if(L.current&&!N){R(!0);let e=setTimeout(()=>{_(!1),R(!1)},300);return L.current=N,()=>clearTimeout(e)}!L.current&&N&&_(!0),L.current=N},[N]);let F=N&&!w?(0,t.jsx)(d.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,D=w??F;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:u??P,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:y?(0,t.jsx)(T,{onResetViewport:y}):null}),b]}),C&&D?(0,t.jsx)("div",{className:(0,i.cn)("pointer-events-none absolute inset-0 z-10 flex items-center justify-center transition-opacity duration-300",O?"opacity-0":"animate-in fade-in opacity-100 duration-200"),children:(0,t.jsx)("div",{className:"pointer-events-auto h-full w-full",children:D})}):null]})}var F=e.i(5147),D=e.i(8361),A=e.i(30153);let I="shep-canvas-viewport",$={x:30,y:30,zoom:.85};var z=e.i(33548),G=e.i(23925),B=e.i(83428),q=e.i(35e3),W=e.i(79687),U=e.i(99105),V=e.i(78521);e.i(13322);var H=e.i(61201),X=e.i(21023);let J=(0,X.createServerReference)("00875a46d41de7040c7bf410e8efc3e8c8d6af0577",X.callServer,void 0,X.findSourceMapURL,"isAgentSetupComplete"),K=(0,X.createServerReference)("00fb61b550212f6c1f44b82a392192e5d127a7e51c",X.callServer,void 0,X.findSourceMapURL,"checkAgentAuth");var Y=e.i(11345),Q=e.i(5231),Z=e.i(730),ee=e.i(86782),et=e.i(29847);let er=["select-agent","select-model"];function en({onComplete:e,className:r}){let[o,a]=(0,n.useState)([]),[s,l]=(0,n.useState)(!0),[d,c]=(0,n.useState)("select-agent"),[u,h]=(0,n.useState)(null),[f,p]=(0,n.useState)(!1),[g,m]=(0,n.useState)(!1),[v,x]=(0,n.useState)(!0),y=(0,n.useRef)(void 0);(0,n.useEffect)(()=>{(0,Q.getAllAgentModels)().then(a).finally(()=>l(!1))},[]);let b=u?o.find(e=>e.agentType===u):null,w=(0,n.useCallback)((e,t)=>{m(!0),x(!1),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{t?.(),c(e),requestAnimationFrame(()=>{x(!0),m(!1)})},150)},[]);(0,n.useEffect)(()=>()=>{y.current&&clearTimeout(y.current)},[]);let E=(0,n.useCallback)(async(t,r)=>{p(!0);try{await (0,Z.updateAgentAndModel)(t,r),x(!1),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{e()},200)}catch{p(!1)}},[e]),k=(0,n.useCallback)(e=>{let t=o.find(t=>t.agentType===e);t&&t.models.length>0?w("select-model",()=>{h(e)}):E(e,null)},[o,w,E]),j=(0,n.useCallback)(e=>{u&&E(u,e)},[u,E]),N=(0,n.useCallback)(()=>{"select-model"===d&&w("select-agent",()=>{h(null)})},[d,w]);if(s)return(0,t.jsxs)("div",{"data-testid":"welcome-agent-setup",className:(0,i.cn)("flex flex-col items-center justify-center gap-4",r),children:[(0,t.jsx)(B.Loader2,{className:"text-muted-foreground h-5 w-5 animate-spin"}),(0,t.jsx)("p",{className:"text-muted-foreground text-sm",children:"Loading agents…"})]});let C=er.indexOf(d),_="select-agent"===d?"Choose your agent":"Pick a model",O="select-agent"===d?"Select the AI coding agent you want Shep to use.":b?`Choose which ${b.label} model to run.`:"";return(0,t.jsxs)("div",{"data-testid":"welcome-agent-setup",className:(0,i.cn)("flex w-full flex-col items-center",r),children:[(0,t.jsx)("div",{className:"mb-8 flex w-full max-w-xs items-center gap-1.5",children:er.map((e,r)=>(0,t.jsx)("div",{className:(0,i.cn)("h-[3px] flex-1 rounded-full transition-colors duration-300",r<=C?"bg-foreground/60":"bg-muted")},e))}),(0,t.jsxs)("div",{className:(0,i.cn)("flex w-full flex-col items-center transition-opacity duration-200",v&&!g?"opacity-100":"opacity-0"),children:[(0,t.jsx)("h1",{className:"text-foreground/90 text-center text-5xl font-extralight tracking-tight",children:_}),(0,t.jsx)("p",{className:"text-muted-foreground mt-3 text-center text-lg leading-relaxed font-light",children:O}),(0,t.jsxs)("div",{className:"mt-8 flex w-full flex-col items-center",children:["select-agent"===d&&(0,t.jsx)("div",{"data-testid":"agent-list",className:"grid w-full max-w-lg gap-3",style:{gridTemplateColumns:`repeat(${Math.min(o.length,4)}, minmax(0, 1fr))`},children:o.map(e=>{let r=(0,ee.getAgentTypeIcon)(e.agentType);return(0,t.jsxs)("button",{type:"button",disabled:f,"data-testid":`agent-option-${e.agentType}`,className:"border-border hover:bg-accent hover:border-foreground/20 flex cursor-pointer flex-col items-center gap-3 rounded-2xl border px-4 py-5 transition-all duration-150 active:scale-[0.97] disabled:opacity-50",onClick:()=>k(e.agentType),children:[(0,t.jsx)(r,{className:"text-foreground/70 h-7 w-7"}),(0,t.jsx)("span",{className:"text-sm font-medium",children:e.label})]},e.agentType)})}),"select-model"===d&&b?(0,t.jsxs)("div",{"data-testid":"model-list",className:"flex w-full max-w-lg flex-col items-center gap-4",children:[(0,t.jsxs)("button",{type:"button",disabled:f,className:"text-muted-foreground hover:text-foreground flex cursor-pointer items-center gap-1.5 self-start text-sm transition-colors",onClick:N,children:[(0,t.jsx)(Y.ChevronLeft,{className:"h-4 w-4"}),"Back"]}),(0,t.jsx)("div",{className:"grid w-full gap-3",style:{gridTemplateColumns:`repeat(${Math.min(b.models.length,3)}, minmax(0, 1fr))`},children:b.models.map(e=>{let r=(0,et.getModelMeta)(e.id);return(0,t.jsxs)("button",{type:"button",disabled:f,"data-testid":`model-option-${e.id}`,className:"border-border hover:bg-accent hover:border-foreground/20 flex cursor-pointer flex-col items-center gap-2 rounded-2xl border px-4 py-5 text-center transition-all duration-150 active:scale-[0.97] disabled:opacity-50",onClick:()=>j(e.id),children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:r.displayName||e.displayName}),(0,t.jsx)("span",{className:"text-muted-foreground text-xs leading-tight",children:r.description||e.description})]},e.id)})})]}):null]})]})]})}let eo=["cd ~/my-repo",'shep feat new "sleek dashboard"'];function ea({onRepositorySelect:e,className:r}){let[o,a]=(0,n.useState)(!1),[s,l]=(0,n.useState)(!1),[d,c]=(0,n.useState)(!1),[u,h]=(0,n.useState)(null),[f,m]=(0,n.useState)(null),[v,x]=(0,n.useState)(!1),{reactFileManager:y}=(0,_.useFeatureFlags)();async function b(){if(!s){if(y)return void c(!0);l(!0);try{let t=await (0,V.pickFolder)();t&&e?.(t)}catch{c(!0)}finally{l(!1)}}}(0,n.useEffect)(()=>{J().then(e=>{h(e)})},[]),(0,n.useEffect)(()=>{u&&K().then(m)},[u]);let w=(0,n.useCallback)(async()=>{await navigator.clipboard.writeText(eo.join("\n")),a(!0),setTimeout(()=>a(!1),2e3)},[]),E=(0,n.useCallback)(()=>{h(!0)},[]),k=(0,n.useCallback)(()=>{m(null),K().then(m)},[]);return null===u?null:(0,t.jsxs)("div",{"data-testid":"control-center-empty-state",className:(0,i.cn)("relative flex h-full w-full flex-col items-center justify-center px-8",r),children:[u?(0,t.jsxs)("div",{className:"animate-in fade-in flex w-full max-w-md flex-col items-center duration-300",children:[(0,t.jsx)("h1",{className:"text-foreground/90 text-center text-5xl font-extralight tracking-tight",children:"Add a project"}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-3 text-center text-lg leading-relaxed font-light",children:["Add your project folder to unlock feature creation.",(0,t.jsx)("br",{}),"Describe what you need — Shep handles the rest."]}),(0,t.jsx)("div",{className:"mt-8",children:(0,t.jsx)(es,{status:f,onRetry:k})}),(0,t.jsxs)("button",{type:"button","data-testid":"empty-state-add-repository",onClick:b,disabled:s,className:"bg-foreground text-background hover:bg-foreground/90 mt-10 flex w-full cursor-pointer items-center justify-center gap-2.5 rounded-xl px-6 py-4 text-base font-medium shadow-lg transition-all duration-200 hover:shadow-xl active:scale-[0.98] disabled:cursor-wait disabled:opacity-50",children:[s?(0,t.jsx)(B.Loader2,{className:"h-5 w-5 animate-spin"}):(0,t.jsx)(g.FolderOpen,{className:"h-5 w-5"}),s?"Opening…":"Choose a Folder"]}),(0,t.jsx)("p",{className:"text-muted-foreground/60 mt-3 text-center text-sm",children:"Any folder works — git will be initialized automatically if needed."})]}):(0,t.jsx)(en,{onComplete:E}),u?(0,t.jsxs)("div",{className:"absolute bottom-8 flex flex-col items-center",style:{animationDelay:"400ms",animationDuration:"600ms",animationFillMode:"both"},children:[(0,t.jsxs)("button",{type:"button",onClick:()=>x(!v),className:"text-muted-foreground hover:text-foreground flex cursor-pointer items-center gap-1.5 transition-colors duration-200",children:[(0,t.jsx)(p.Terminal,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{className:"text-sm",children:"or use the CLI"}),(0,t.jsx)(U.ChevronDown,{className:(0,i.cn)("h-3.5 w-3.5 transition-transform duration-200",v?"":"rotate-180")})]}),v?(0,t.jsx)("div",{className:"animate-in fade-in slide-in-from-top-1 mt-3 w-80 duration-200",children:(0,t.jsxs)("div",{"data-testid":"cli-code-block",className:"relative rounded-xl bg-zinc-900 px-5 py-4 font-mono text-[13px] leading-relaxed text-zinc-400",children:[(0,t.jsx)("button",{type:"button","data-testid":"cli-code-block-copy",onClick:w,className:"absolute top-3 right-3 cursor-pointer rounded-md p-1.5 text-zinc-600 transition-colors hover:bg-zinc-800 hover:text-zinc-300","aria-label":"Copy commands",children:o?(0,t.jsx)(G.Check,{className:"h-3.5 w-3.5 text-emerald-400"}):(0,t.jsx)(z.Copy,{className:"h-3.5 w-3.5"})}),(0,t.jsx)("div",{className:"space-y-1",children:eo.map(e=>(0,t.jsxs)("div",{className:"whitespace-nowrap",children:[(0,t.jsx)("span",{className:"text-zinc-600 select-none",children:"$ "}),(0,t.jsx)("span",{className:"text-zinc-300",children:e})]},e))})]})}):null]}):null,(0,t.jsx)(H.ReactFileManagerDialog,{open:d,onOpenChange:e=>{e||c(!1)},onSelect:function(t){t&&e?.(t),c(!1)}})]})}function es({status:e,onRetry:r}){return e?e.installed&&e.authenticated?(0,t.jsxs)("div",{className:"animate-in fade-in flex items-center gap-2",children:[(0,t.jsx)(q.CheckCircle2,{className:"h-4 w-4 text-emerald-500"}),(0,t.jsxs)("span",{className:"text-sm text-emerald-600 dark:text-emerald-400",children:[e.label," ready"]})]}):e.installed?(0,t.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(W.AlertCircle,{className:"h-4 w-4 text-amber-500"}),(0,t.jsxs)("span",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:[e.label," needs authentication"]})]}),e.authCommand?(0,t.jsx)("code",{className:"rounded-lg bg-zinc-100 px-3 py-1.5 text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400",children:e.authCommand}):null,(0,t.jsxs)("div",{className:"flex items-center gap-3",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.5 text-xs font-medium text-amber-600 underline underline-offset-2 hover:text-amber-800 dark:text-amber-400",children:[(0,t.jsx)(p.Terminal,{className:"h-3 w-3"}),"Open ",e.label]}):null,(0,t.jsx)("button",{type:"button",onClick:r,className:"text-xs text-amber-600 underline underline-offset-2 hover:text-amber-800 dark:text-amber-400",children:"Re-check"})]})]}):(0,t.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(W.AlertCircle,{className:"h-4 w-4 text-amber-500"}),(0,t.jsxs)("span",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:[e.label," not installed"]})]}),e.binaryName?(0,t.jsxs)("code",{className:"rounded-lg bg-zinc-100 px-3 py-1.5 text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400",children:["npm install -g ",e.binaryName]}):null,(0,t.jsx)("button",{type:"button",onClick:r,className:"text-xs text-amber-600 underline underline-offset-2 hover:text-amber-800 dark:text-amber-400",children:"Re-check"})]}):(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(B.Loader2,{className:"text-muted-foreground/50 h-3.5 w-3.5 animate-spin"}),(0,t.jsx)("span",{className:"text-muted-foreground/50 text-sm",children:"Checking setup…"})]})}var ei=e.i(17840);let el={maxZoom:1,padding:.5,duration:500};function ed({initialNodes:e,initialEdges:a}){let s,i,l,d=(0,o.useRouter)(),c=(0,o.usePathname)(),u=(s=(0,o.usePathname)().match(/^\/feature\/([^/]+)/),s?.[1]??null),h=(0,D.useSoundAction)("click"),{guardedNavigate:f}=(0,A.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(I);if(null==e)return $;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:$}catch{return $}}()).current,l=(0,n.useRef)(null),(0,n.useEffect)(()=>()=>{null!=l.current&&clearTimeout(l.current)},[]),{defaultViewport:i,onMoveEnd:(0,n.useCallback)(e=>{null!=l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{try{localStorage.setItem(I,JSON.stringify(e))}catch{}},500)},[]),resetViewport:(0,n.useCallback)(()=>{try{localStorage.removeItem(I)}catch{}return $},[])}),{nodes:y,edges:b,onNodesChange:w,handleConnect:E,handleAddRepository:k,handleDeleteFeature:j,handleRetryFeature:N,handleStartFeature:C,handleStopFeature:_,handleDeleteRepository:O,createFeatureNode:R,setCallbacks:S}=(0,ei.useControlCenterState)(e,a),{setFeatures:M,setHasRepositories:P}=(0,F.useSidebarFeaturesContext)(),T=(0,n.useMemo)(()=>y.filter(e=>"featureNode"===e.type),[y]),z=(0,n.useMemo)(()=>T.map(e=>{let t=e.data;return`${t.featureId}:${t.state}:${t.name}`}).sort().join(","),[T]);(0,n.useEffect)(()=>{M(T.map(e=>{let t=e.data,r=(0,F.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))},[z,T,M]);let G=(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(),d.push(`/feature/${r.featureId}`)})}},[d,h,f]),B=(0,n.useCallback)(()=>{h.play(),d.push("/create")},[d,h]),q=(0,n.useCallback)(e=>{h.play();let t=y.find(t=>t.id===e),r=t?.data?.repositoryPath;r?d.push(`/create?repo=${encodeURIComponent(r)}`):d.push("/create")},[y,d,h]),W=(0,n.useCallback)(e=>{let t=e.startsWith("feat-")?e.slice(5):e,r=b.find(t=>t.target===e),n=r?y.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),d.push(`/create?${a.toString()}`)},[y,b,d,h]),U=(0,n.useCallback)(e=>{let t=y.find(t=>t.id===e);if(t?.type==="repositoryNode"){let e=t.data;e.id&&f(()=>d.push(`/repository/${e.id}`))}},[y,d,f]),V=(0,n.useCallback)(()=>{"/"!==c&&f(()=>d.push("/"))},[d,c,f]),H=(0,n.useCallback)(e=>{setTimeout(()=>{p(el),g.current=setTimeout(()=>{f(()=>d.push(`/create?repo=${encodeURIComponent(e)}`))},600)},0)},[p,f,d]),X=(0,n.useCallback)(e=>{let{wasEmpty:t,repoPath:r}=k(e);t&&H(r)},[k,H]);(0,n.useEffect)(()=>{let e=e=>{X(e.detail.path)};return window.addEventListener("shep:add-repository",e),()=>{window.removeEventListener("shep:add-repository",e),null!=g.current&&clearTimeout(g.current)}},[X]),(0,n.useEffect)(()=>{let e=e=>{let t=e.detail;if(t.parentId)return void R(`feat-${t.parentId}`,{state:"creating",featureId:t.featureId,name:t.name,description:t.description,repositoryPath:t.repositoryPath},"dependencyEdge");let r=y.find(e=>"repositoryNode"===e.type&&e.data.repositoryPath===t.repositoryPath);R(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)},[y,R]),(0,n.useEffect)(()=>{let e=e=>{let{featureId:t,cleanup:r,cascadeDelete:n,closePr:o}=e.detail;j(t,r,n,o)};return window.addEventListener("shep:feature-delete-requested",e),()=>window.removeEventListener("shep:feature-delete-requested",e)},[j]),(0,n.useEffect)(()=>{S({onNodeAction:W,onFeatureDelete:j,onRetryFeature:N,onStartFeature:C,onStopFeature:_,onRepositoryAdd:q,onRepositoryClick:U,onRepositoryDelete:O})},[S,W,j,N,C,_,q,U,O]);let J=(0,n.useCallback)((e,t)=>{v(t)},[v]),K=y.some(e=>"repositoryNode"===e.type);(0,n.useEffect)(()=>{P(K)},[K,P]);let[Y,Q]=(0,n.useState)(K),Z=(0,n.useRef)(null);(0,n.useEffect)(()=>(K?(Z.current&&(clearTimeout(Z.current),Z.current=null),Q(!0)):Y&&(x(),Z.current=setTimeout(()=>{Q(!1),Z.current=null},500)),()=>{Z.current&&clearTimeout(Z.current)}),[K,Y,x]);let ee=c.startsWith("/create"),et=(0,n.useMemo)(()=>{let e=y.filter(e=>"repositoryNode"===e.type),t=y.some(e=>"featureNode"===e.type);return 1!==e.length||t||ee?y:y.map(e=>"repositoryNode"===e.type?{...e,data:{...e.data,pulseAdd:!0}}:e)},[y,ee]);return(0,t.jsx)(L,{nodes:Y?et:[],edges:Y?b:[],selectedFeatureId:u,defaultViewport:m,onNodesChange:w,onConnect:E,onAddFeature:B,onNodeClick:G,onPaneClick:V,onMoveEnd:J,onResetViewport:x,emptyState:(0,t.jsx)(ea,{onRepositorySelect:X})})}function ec({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)(ed,{initialNodes:e,initialEdges:n})}),(0,t.jsx)("div",{children:o},"drawer")]})}e.s(["ControlCenter",()=>ec],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 l=a(this._isDirected,e,t,n);if(Object.hasOwn(this._edgeLabels,l))return s&&(this._edgeLabels[l]=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[l]=s?o:this._defaultEdgeLabelFn(e,t,n);var d=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=d.v,t=d.w,Object.freeze(d),this._edgeObjs[l]=d,r(this._preds[t],e),r(this._sucs[e],t),this._in[t][l]=d,this._out[e][l]=d,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()}}),l=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}}}),d=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(),l=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)},d=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;l({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++,d(),a);u++);if(s===c-1&&(a=!1,d(),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={},l=new r,d=function(e){var t=e.v!==a?e.v:e.w,r=i[t],o=n(e),d=s.distance+o;if(o<0)throw Error("dijkstra does not allow negative edge weights. Bad edge: "+e+" Weight: "+o);d<r.distance&&(r.distance=d,r.predecessor=a,l.decrease(t,d))};for(e.nodes().forEach(function(e){var r=e===t?0:1/0;i[e]={distance:r},l.add(e,r)});l.size()>0&&(s=i[a=l.removeMin()]).distance!==1/0;)o(a).forEach(d);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 l,d=[];do n[l=r.pop()].onStack=!1,d.push(l);while(s!==l)o.push(d)}}(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,l;return o=e,a=t||r,s=n||function(t){return e.outEdges(t)},i={},(l=o.nodes()).forEach(function(e){i[e]={},i[e][e]={distance:0},l.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}})}),l.forEach(function(e){var t=i[e];l.forEach(function(r){var n=i[r];l.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}),y=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}}),b=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=b();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 l(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 d=!1;i.size()>0;){if(Object.hasOwn(s,o=i.removeMin()))a.setEdge(o,s[o]);else{if(d)throw Error("Input graph is not connected: "+e);d=!0}e.nodeEdges(o).forEach(l)}return a}}),N=n((e,t)=>{var r=h(),n=d();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(),l=0;l<i.length;l++){for(var d=a(i[l]),c=0;c<d.length;c++){var u=d[c],h=u.v===i[l]?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:d(),components:c(),dijkstra:h(),dijkstraAll:f(),extractPath:p(),findCycles:m(),floydWarshall:v(),isAcyclic:y(),postorder:E(),preorder:k(),prim:j(),shortestPaths:N(),reduce:b(),tarjan:g(),topsort:x()}}),_=i();t.exports={Graph:_.Graph,json:l(),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 d,c,u,h,f;if(1>=e.nodeCount())return[];let p=(a=e,s=t||o,d=new r,c=0,u=0,a.nodes().forEach(e=>{d.setNode(e,{v:e,in:0,out:0})}),a.edges().forEach(e=>{let t=d.edge(e.v,e.w)||0,r=s(e);d.setEdge(e.v,e.w,t+r),u=Math.max(u,d.node(e.v).out+=r),c=Math.max(c,d.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,d.nodes().forEach(e=>{l(h,f,d.node(e))}),{graph:d,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,l(t,r,i)}),e.outEdges(n.v).forEach(n=>{let o=e.edge(n),a=n.w,s=e.node(a);s.in-=o,l(t,r,s)}),e.removeNode(n.v),a}function l(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)}}),l=o((e,t)=>{var r=a().Graph;function n(e,t,r,n){for(var o=n;e.hasNode(o);)o=l(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=d(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,l=e.width/2,d=e.height/2;if(!s&&!i)throw Error("Not possible to find intersection inside of the rectangle");return Math.abs(i)*l>Math.abs(s)*d?(i<0&&(d=-d),r=d*s/i,n=d):(s<0&&(l=-l),r=l,n=l*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:d,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:l,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 l(e){return e+""+ ++i}function d(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),{})}}),d=o((e,t)=>{var r=i(),n=l().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=l();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,l=t.w,d=e.node(l).rank,c=t.name,u=e.edge(t),h=u.labelRank;if(d!==i+1){for(e.removeEdge(t),a=0,++i;i<d;++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,l,{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}=l();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}),l=e.nodes()[0],d=e.nodeCount();for(i.setNode(l,{});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()<d;)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,d=l().simplify;function c(e){o(e=d(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,l=i?a.w:a.v;if(l!==n){var d,c,u,h=i===o,f=t.edge(a).weight;if(s+=h?f:-f,d=e,c=r,u=l,d.hasEdge(c,u)){var p=e.edge(r,l).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),l=s,d=!1;return s.lim>i.lim&&(l=i,d=!0),t.edges().filter(t=>d===y(e,e.node(t.v),l)&&d!==y(e,e.node(t.w),l)).reduce((e,r)=>n(t,r)<n(t,e)?r:e)}function x(e,t,r,n){var o,a,i,l,d=r.v,c=r.w;e.removeEdge(d,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),(l=(l=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 y(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),l,d;l=r;do o.push(l=e.parent(l));while(l&&(t[l].low>s||i>t[l].lim))for(d=l,l=n;(l=e.parent(l))!==d;)a.push(l);return{path:o.concat(a.reverse()),lca:d}}(e,o,n.v,n.w),s=a.path,i=a.lca,l=0,d=s[0],c=!0;for(;t!==n.w;){if(r=e.node(t),c){for(;(d=s[l])!==i&&e.node(d).maxRank<r.rank;)l++;d===i&&(c=!1)}if(!c){for(;l<s.length-1&&e.node(d=s[l+1]).minRank<=r.rank;)l++;d=s[l]}e.setParent(t,d),t=e.successors(t)[0]}})}}),m=o((e,t)=>{var r=l();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),l=r.applyWithChunking(Math.max,i)-1,d=2*l+1;e.graph().nestingRoot=a,e.edges().forEach(t=>e.edge(t).minlen*=d);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,l){let d=t.children(l);if(!d.length){l!==n&&t.setEdge(n,l,{weight:0,minlen:o});return}let c=r.addBorderNode(t,"_bt"),u=r.addBorderNode(t,"_bb"),h=t.node(l);t.setParent(c,l),h.borderTop=c,t.setParent(u,l),h.borderBottom=u,d.forEach(r=>{e(t,n,o,a,s,i,r);let d=t.node(r),h=d.borderTop?d.borderTop:r,f=d.borderBottom?d.borderBottom:r,p=d.borderTop?a:2*a,g=h!==f?1:s-i[l]+1;t.setEdge(c,h,{weight:p,minlen:g,nestingEdge:!0}),t.setEdge(f,u,{weight:p,minlen:g,nestingEdge:!0})}),t.parent(l)||t.setEdge(n,c,{weight:0,minlen:s+i[l]})})(e,a,d,c,l,s,t)),e.graph().nodeRankFactor=d},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=l();function n(e,t,n,o,a,s){let i=a[t][s-1],l=r.addDummyNode(e,"border",{width:0,height:0,rank:s,borderType:t},n);a[t][s]=l,e.setParent(l,o),i&&e.setEdge(i,l,{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))}}}),y=o((e,t)=>{var r=l();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}}),b=o((e,t)=>{var r=l().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 l=Array(i).fill(0),d=0;return a.forEach(e=>{let t=e.pos+s;l[t]+=e.weight;let r=0;for(;t>0;)t%2&&(r+=l[t+1]),t=t-1>>1,l[t]+=e.weight;d+=e.weight*r}),d}(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=l();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=l();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),l=[],d=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(l,i,u),s.forEach(e=>{u+=e.vs.length,l.push(e.vs),d+=e.barycenter*e.weight,c+=e.weight,u=n(l,i,u)});let h={vs:l.flat(!0)};return c&&(h.barycenter=d/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 l,d;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);l=m,d=p,l.forEach(e=>{e.vs=e.vs.flatMap(e=>d[e]?d[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=l();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=y(),n=b(),o=j(),s=N(),i=C(),d=a().Graph,c=l();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),l=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 d;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?l: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=l();function o(e,t){let r={};return t.length&&t.reduce(function(t,n){let o=0,a=0,s=t.length,l=n[n.length-1];return n.forEach((t,d)=>{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===l)&&(n.slice(a,d+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=d+1,o=u)}),n}),r}function s(e,t){let r={};function o(t,o,a,s,l){let d;n.range(o,a).forEach(n=>{d=t[n],e.node(d).dummy&&e.predecessors(d).forEach(t=>{let n=e.node(t);n.dummy&&(n.order<s||n.order>l)&&i(r,t,d)})})}return t.length&&t.reduce(function(t,r){let n=-1,a,s=0;return r.forEach((i,l)=>{if("border"===e.node(i).dummy){let t=e.predecessors(i);t.length&&(a=e.node(t[0]).order,o(r,s,l,n,a),s=l,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 d(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 l=Math.floor(n),c=Math.ceil(n);l<=c;++l){let n=i[l];a[e]===e&&t<s[n]&&!d(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,l,d,c,u,h;let f,p,g,m={},v=(s=e,i=t,l=n,d=a,f=new r,g=(c=(p=s.graph()).nodesep,u=p.edgesep,h=d,(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=l[e];if(f.setNode(r),t){var n=l[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 y(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 y(function(e){m[e]=v.inEdges(e).reduce((e,t)=>Math.max(e,m[t.v]+v.edge(t)),0)},v.predecessors.bind(v)),y(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,l=e[i];if(l===t)return;let d=Object.values(l),c=o-n.applyWithChunking(Math.min,d);"l"!==s&&(c=a-n.applyWithChunking(Math.max,d)),c&&(e[i]=n.mapValues(l,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),l=c(e,i,r,s),d=u(e,i,l.root,l.align,"r"===t);"r"===t&&(d=n.mapValues(d,e=>-e)),a[o+t]=d})});let l=h(e,a);return f(a,l),p(a,e.graph().align)},findType1Conflicts:o,findType2Conflicts:s,addConflict:i,hasConflict:d,verticalAlignment:c,horizontalCompaction:u,alignCoordinates:f,findSmallestWidthAlignment:h,balance:p}}),R=o((e,t)=>{var r=l(),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)}}),S=o((e,t)=>{var r=d(),n=c(),o=p(),s=l().normalizeRanks,i=g(),u=l().removeEmptyRanks,h=m(),f=v(),y=x(),b=_(),w=R(),E=l(),k=a().Graph;t.exports=function(e,t={}){let a=t.debugTiming?E.time:E.notime;return a("layout",()=>{let l=a(" buildLayoutGraph",()=>{var t;let r,n;return t=e,r=new k({multigraph:!0,compound:!0}),n=F(t.graph()),r.setGraph(Object.assign({},N,L(n,j),E.pick(n,C))),t.nodes().forEach(e=>{let n=L(F(t.node(e)),O);Object.keys(S).forEach(e=>{void 0===n[e]&&(n[e]=S[e])}),r.setNode(e,n),r.setParent(e,t.parent(e))}),t.edges().forEach(e=>{let n=F(t.edge(e));r.setEdge(e,Object.assign({},P,L(n,M),E.pick(n,T)))}),r});return a(" runLayout",()=>{var e,d,c;return e=l,d=a,c=t,void(d(" 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)}))}),d(" 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)}})}),d(" acyclic",()=>r.run(e)),d(" nestingGraph.run",()=>h.run(e)),d(" rank",()=>o(E.asNonCompoundGraph(e))),d(" 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")}})}),d(" removeEmptyRanks",()=>u(e)),d(" nestingGraph.cleanup",()=>h.cleanup(e)),d(" normalizeRanks",()=>s(e)),d(" 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)}),d(" 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))})}),d(" normalize.run",()=>n.run(e)),d(" parentDummyChains",()=>i(e)),d(" addBorderSegments",()=>f(e)),d(" order",()=>b(e,c)),d(" 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})})}),d(" adjustCoordinateSystem",()=>y.adjust(e)),d(" position",()=>w(e)),d(" 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}})}),d(" 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)})}),d(" normalize.undo",()=>n.undo(e)),d(" 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}})}),d(" undoCoordinateSystem",()=>y.undo(e)),d(" 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 l(e){let a=e.x,s=e.y,i=e.width,l=e.height;t=Math.min(t,a-i/2),r=Math.max(r,a+i/2),n=Math.min(n,s-l/2),o=Math.max(o,s+l/2)}e.nodes().forEach(t=>l(e.node(t))),e.edges().forEach(t=>{let r=e.edge(t);Object.hasOwn(r,"x")&&l(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)),d(" 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))})}),d(" reversePoints",()=>{var t;(t=e).edges().forEach(e=>{let r=t.edge(e);r.reversed&&r.points.reverse()})}),d(" acyclic.undo",()=>r.undo(e)))}),a(" updateInputGraph",()=>{var t,r;return t=e,r=l,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)}),l})};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"],S={width:0,height:0},M=["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 F(e){var t={};return e&&Object.entries(e).forEach(([e,r])=>{"string"==typeof e&&(e=e.toLowerCase()),t[e]=r}),t}}),M=o((e,t)=>{var r=l(),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:S(),debug:M(),util:{time:l().time,notime:l().notime},version:P()}})(),L={direction:"LR",ranksep:200,nodesep:30},F={featureNode:{width:288,height:140},repositoryNode:{width:400,height:140}};function D(e,t){let r=e.data;return r&&"number"==typeof r.width&&"number"==typeof r.height?{width:r.width,height:r.height}:F[e.type??""]??t}function A(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 l=new Set;for(let e of t)l.add(e.source),l.add(e.target);let d=e.filter(e=>l.has(e.id)),c=e.filter(e=>!l.has(e.id));for(let e of d){let t=D(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 d){let t=i.node(e.id),r=D(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=D(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 y=[...[...l].filter(e=>p.has(e)&&!x.has(e)),...c.map(e=>e.id)];y.sort((e,t)=>(v.get(e)??0)-(v.get(t)??0));let b=new Map;for(let e of y)!function e(t){if(b.has(t))return b.get(t);let r=p.get(t),n=f?r.h:r.w,o=m.get(t);if(!o||0===o.length)return b.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 b.set(t,i),i}(e);let w=0;for(let e of y){let t=b.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+=b.get(e)??0;let i=r-(a+=(o.length-1)*s)/2;for(let t of o){let r=b.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 I=e.i(21023);let $=(0,I.createServerReference)("7861416161a8aa75eb00c1db248e3dea626c2c754b",I.callServer,void 0,I.findSourceMapURL,"deleteFeature");var z=e.i(7860),G=e.i(29910);let B=(0,I.createServerReference)("4068a353eb8f4cb7bf8155792c435343b71e0f6b05",I.callServer,void 0,I.findSourceMapURL,"stopFeature");var q=e.i(8636);let W=(0,I.createServerReference)("4089bb9db03a722e7bd75c743f578ec9a6c6c22779",I.callServer,void 0,I.findSourceMapURL,"deleteRepository"),U=(0,I.createServerReference)("4005c21fcc151f2437ef528477a9b60d9cb828e56a",I.callServer,void 0,I.findSourceMapURL,"getFeatureMetadata");var V=e.i(39443),H=e.i(8361),X=e.i(18354),J=e.i(99045);function K(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 Y(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)}function Q(e,t){if(e.size!==t.size)return!1;for(let[r,n]of e){let e=t.get(r);if(!e||n.parentNodeId!==e.parentNodeId||n.data!==e.data&&JSON.stringify(n.data)!==JSON.stringify(e.data))return!1}return!0}let Z=(0,X.createLogger)("[Polling]"),ee=0,et=0;function er(e,o){let a=(0,r.useRouter)(),s=(0,H.useSoundAction)("delete"),i=(0,H.useSoundAction)("create"),{nodes:l,edges:d,reconcile:c,updateFeature:u,addPendingFeature:h,removeFeature:f,restoreFeature:p,addRepository:g,removeRepository:m,replaceRepository:v,getFeatureRepositoryPath:x,getRepositoryData:y,getRepoMapSize:b,setCallbacks:w,beginMutation:E,endMutation:k,isMutating:j}=function(e,r){let n=(0,t.useMemo)(()=>K(e,r),[]),[o,a]=(0,t.useState)(n.featureMap),[s,i]=(0,t.useState)(n.repoMap),[l,d]=(0,t.useState)(new Map),c=(0,t.useRef)(new Map),u=(0,t.useRef)(new Set),h=(0,t.useRef)(0),f=(0,t.useRef)(new Set),p=(0,t.useRef)(new Set),g=(0,t.useRef)({}),m=(0,t.useMemo)(()=>({onNodeAction:e=>g.current.onNodeAction?.(e),onNodeSettings:e=>g.current.onNodeSettings?.(e),onFeatureDelete:(e,t,r,n)=>g.current.onFeatureDelete?.(e,t,r,n),onRepositoryAdd:e=>g.current.onRepositoryAdd?.(e),onRepositoryClick:e=>g.current.onRepositoryClick?.(e),onRepositoryDelete:e=>g.current.onRepositoryDelete?.(e),onRetryFeature:e=>g.current.onRetryFeature?.(e),onStartFeature:e=>g.current.onStartFeature?.(e)}),[]),v=(0,t.useRef)(o);v.current=o;let x=(0,t.useRef)(s);x.current=s;let y=(0,t.useMemo)(()=>(function(e,t,r,n){let o=[],a=[],s=e=>e.replace(/\\/g,"/"),i=new Map;for(let[e,r]of t)r.data.repositoryPath&&i.set(s(r.data.repositoryPath),e);let l=new Map;for(let[e,r]of[...t.entries()].sort((e,t)=>{let r=e[1].data.createdAt,n=t[1].data.createdAt;return("number"!=typeof r||Number.isNaN(r)?1/0:r)-("number"!=typeof n||Number.isNaN(n)?1/0:n)})){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,c]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||c,r={...d.data,...!e&&n?.onNodeAction&&{onAction:()=>n.onNodeAction(t)},...!e&&n?.onNodeSettings&&{onSettings:()=>n.onNodeSettings(t)},...!e&&n?.onFeatureDelete&&{onDelete:n.onFeatureDelete},...!e&&"error"===d.data.state&&n?.onRetryFeature&&{onRetry:n.onRetryFeature},...!e&&"pending"===d.data.state&&n?.onStartFeature&&{onStart:n.onStartFeature},...!e&&("running"===d.data.state||"action-required"===d.data.state)&&n?.onStopFeature&&{onStop:n.onStopFeature}};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=s(d.data.repositoryPath),r=i.get(e)??function(e){if(l.has(e))return l.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}}),l.set(e,t),t}(e);a.push({id:`edge-${r}-${t}`,source:r,target:t,style:{strokeDasharray:"5 5"}})}}let d=new Set;for(let e of a)"dependencyEdge"===e.type&&d.add(e.source);let c=a.length>0;for(let e of o){let t=e.data;t.showHandles=c,"featureNode"===e.type&&(t.hasChildren=d.has(e.id))}return{nodes:o,edges:a}})(o,s,l,m),[o,s,l,m]),b=(0,t.useRef)({key:"",positions:new Map}),{nodes:w,edges:E}=(0,t.useMemo)(()=>{let e=y.nodes.map(e=>e.id).sort().join(","),t=y.edges.map(e=>`${e.source}-${e.target}`).sort().join(","),r=`${e}|${t}`;if(r!==b.current.key){let e=A(y.nodes,y.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=b.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 b.current={key:r,positions:t},e}let{positions:n}=b.current;return{nodes:y.nodes.map(e=>{let t=n.get(e.id);return t?{...e,...t}:e}),edges:y.edges}},[y]),k=(0,t.useCallback)((e,t)=>{if(h.current>0)return;let{featureMap:r,repoMap:n}=K(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"}}):p.current.has(t)||(n.set(t,r),a.add(t)));for(let[e,t]of(p.current=a,c.current)){let r=n.get(e);r&&(n.set(e,{...r,data:{...r.data,...t}}),c.current.delete(e))}return Q(e,n)?e:n}),d(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 Q(e,t)?e:t})},[]),j=(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),Y(n.data,t))return r;let o=new Map(r);return o.set(e,{...n,data:{...n.data,...t}}),o}),d(r=>{let n=r.get(e);if(!n||Y(n.data,t))return r;let o=new Map(r);return o.set(e,{...n,data:{...n.data,...t}}),o})},[]),N=(0,t.useCallback)((e,t,r)=>{d(n=>{let o=new Map(n);return o.set(e,{nodeId:e,data:t,parentNodeId:r}),o})},[]),C=(0,t.useCallback)(e=>{d(t=>{if(!t.has(e))return t;let r=new Map(t);return r.delete(e),r})},[]),_=(0,t.useCallback)(e=>{a(t=>{if(!t.has(e))return t;let r=new Map(t);return r.delete(e),r})},[]),O=(0,t.useCallback)((e,t)=>{a(r=>{let n=new Map(r);return n.set(e,t),n})},[]),R=(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})},[]),S=(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})},[]),M=(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})},[]),P=(0,t.useCallback)(e=>v.current.get(e)?.data.repositoryPath,[]),T=(0,t.useCallback)(e=>x.current.get(e)?.data,[]),F=(0,t.useCallback)(()=>x.current.size,[]),D=(0,t.useCallback)(e=>{g.current=e},[]),I=(0,t.useCallback)(()=>{h.current++},[]),$=(0,t.useCallback)((e=3e3)=>{let t=setTimeout(()=>{h.current=Math.max(0,h.current-1),f.current.delete(t)},e);f.current.add(t)},[]),z=(0,t.useCallback)(()=>h.current>0,[]);return(0,t.useEffect)(()=>{let e=f.current;return()=>{for(let t of e)clearTimeout(t);e.clear()}},[]),{nodes:w,edges:E,reconcile:k,updateFeature:j,addPendingFeature:N,removePendingFeature:C,removeFeature:_,restoreFeature:O,addRepository:R,removeRepository:S,replaceRepository:M,getFeatureRepositoryPath:P,getRepositoryData:T,getRepoMapSize:F,setCallbacks:D,beginMutation:I,endMutation:$,isMutating:z}}(e,o),N=(0,t.useRef)(l),C=(0,t.useRef)(d);(0,t.useEffect)(()=>{N.current=l,C.current=d},[l,d]);let _=(0,t.useMemo)(()=>e.map(e=>e.id).sort().join(","),[e]),O=(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]),R=(0,t.useRef)("");(0,t.useEffect)(()=>{let t=`${_}|${O}`;t!==R.current&&(R.current=t,c(e,o))},[_,O,e,o,c]);let S=(0,t.useRef)(new Map),{events:M}=(0,V.useAgentEventsContext)();(0,t.useEffect)(()=>{let t=S.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&&(M.some(t=>t.featureId===e.featureId&&(0,J.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)}},[O,e,M,a]);let P=(0,t.useRef)(0);(0,t.useEffect)(()=>{if(P.current>M.length&&(P.current=0),M.length<=P.current)return;let e=M.slice(P.current);for(let{featureId:t,state:r,lifecycle:n}of(P.current=M.length,(0,J.resolveSseEventUpdates)(e)))if(void 0!==r||void 0!==n){let e=`feat-${t}`,o=N.current.find(t=>t.id===e),a=o?o.data.state:void 0;if("deleting"===a||"error"===r&&j()&&"running"===a)continue;u(e,{...void 0!==r&&{state:r},...void 0!==n&&{lifecycle:n}})}},[M,u,j]),(0,t.useEffect)(()=>{let e=e=>{let{featureId:t}=e.detail;E(),u(`feat-${t}`,{state:"running"}),k()};return window.addEventListener("shep:feature-approved",e),()=>window.removeEventListener("shep:feature-approved",e)},[u,E,k]);let T=(0,t.useRef)(new Set),F=(0,t.useRef)(0);(0,t.useEffect)(()=>{if(F.current>M.length&&(F.current=0),M.length<=F.current)return;let e=M.slice(F.current);for(let t of(F.current=M.length,e)){if("Feature metadata updated"!==t.message||T.current.has(t.featureId))continue;T.current.add(t.featureId);let e=`feat-${t.featureId}`;U(t.featureId).then(t=>{t&&u(e,{name:t.name,description:t.description})}).catch(()=>{})}},[M,u]),(0,t.useEffect)(()=>{Z.debug("polling enabled (3000ms interval)");let e=setInterval(async()=>{if(!j())try{let e=await fetch("/api/graph-data");if(!e.ok)throw Error(`status ${e.status}`);let{nodes:t,edges:r}=await e.json();c(t,r)}catch{Z.warn("poll fetch failed — will retry next interval")}},3e3);return()=>{Z.debug("polling disabled"),clearInterval(e)}},[c,j]);let D=(0,t.useCallback)(e=>{},[]),I=(0,t.useCallback)(e=>{},[]),X=(0,t.useCallback)((e,t,r)=>{let n=t?.featureId?`feat-${t.featureId}`:`feature-${Date.now()}-${ee++}`,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]),er=(0,t.useCallback)(e=>{let t=`feat-${e}`;E(),u(t,{state:"running"}),(0,z.resumeFeature)(e).then(e=>{e.error?(u(t,{state:"error"}),n.toast.error(e.error)):n.toast.success("Feature resumed")}).catch(()=>{u(t,{state:"error"}),n.toast.error("Failed to resume feature")}).finally(()=>k())},[u,E,k]),en=(0,t.useCallback)(e=>{let t=`feat-${e}`;E(),u(t,{state:"running"}),(0,G.startFeature)(e).then(e=>{e.error?(u(t,{state:"pending"}),n.toast.error(e.error)):n.toast.success("Feature started")}).catch(()=>{u(t,{state:"pending"}),n.toast.error("Failed to start feature")}).finally(()=>k())},[u,E,k]),eo=(0,t.useCallback)(e=>{E(),B(e).then(e=>{e.error?n.toast.error(e.error):n.toast.success("Agent stopped")}).catch(()=>{n.toast.error("Failed to stop agent")}).finally(()=>k())},[E,k]),ea=(0,t.useCallback)((e,t,r,o)=>{let i=`feat-${e}`,l=[];if(!0===r){let e=[i];for(;e.length>0;){let t=e.shift();for(let r of C.current)"dependencyEdge"===r.type&&r.source===t&&(l.push(r.target),e.push(r.target))}}let d=new Map;for(let e of[i,...l]){let t=N.current.find(t=>t.id===e);t&&d.set(e,t.data.state)}for(let e of(E(),u(i,{state:"deleting"}),l))u(e,{state:"deleting"});s.play(),a.push("/"),$(e,t,r,o).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(i),l))f(e)}).catch(()=>{for(let[e,t]of d)t&&u(e,{state:t});n.toast.error("Failed to delete feature")}).finally(()=>k())},[a,s,u,f,E,k]),es=(0,t.useCallback)(async e=>{let t=`repo-${e}`,r=new Set(C.current.filter(e=>e.source===t).map(e=>e.target)),o=y(t),a=new Map;for(let e of r){let t=N.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(E(),m(t),r))f(e);try{let t=await W(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()}finally{k()}},[s,m,f,g,p,y,E,k]),ei=(0,t.useCallback)(e=>{let t=A(N.current,C.current,{...L,direction:e});c(t.nodes,t.edges)},[c]);return{nodes:l,edges:d,onNodesChange:D,handleConnect:I,handleAddRepository:(0,t.useCallback)(e=>{let t=0===b(),r=`repo-temp-${++et}`,o=e.replace(/[\\/]+$/,"").split(/[\\/]/).pop()??e;return E(),g(r,{name:o,repositoryPath:e,id:r,createdAt:Date.now(),gitInfoStatus:"loading"}),(0,q.addRepository)({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")}).finally(()=>k()),{wasEmpty:t,repoPath:e}},[g,m,v,i,b,E,k]),handleLayout:ei,handleDeleteFeature:ea,handleRetryFeature:er,handleStartFeature:en,handleStopFeature:eo,handleDeleteRepository:es,createFeatureNode:X,getFeatureRepositoryPath:x,getRepositoryData:y,setCallbacks:w}}e.s(["useControlCenterState",()=>er],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(38227),i=e.i(31777),l=e.i(35364);e.i(54793);var d=e.i(7729);e.i(47506);var c=e.i(89313),u=e.i(92002),h=e.i(82569),f=e.i(8986),p=e.i(38573),g=e.i(19933),m=e.i(67669),v=e.i(24042),x=e.i(64970),y=e.i(49228),b=e.i(65530),w=e.i(7311);let E=(0,e.i(3645).default)("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);e.i(81803);var k=e.i(72714),j=e.i(2287),N=e.i(2828),C=e.i(8537),_=e.i(75921),O=e.i(76852),R=e.i(80519);function S({data:e}){let d=(0,o.useRouter)(),c=(0,_.useFeatureFlags)(),[S,M]=(0,n.useState)(!1),P=(0,O.useRepositoryActions)(e.repositoryPath?{repositoryPath:e.repositoryPath}:null),T=(0,C.useDeployAction)(e.repositoryPath?{targetId:e.repositoryPath,targetType:"repository",repositoryPath:e.repositoryPath}:null),L="Booting"===T.status||"Ready"===T.status,F=(0,n.useCallback)((t,r)=>{if(!e.repositoryPath)return;let n=t.preview?t.preview.slice(0,200):"Unknown conversation",o=["Continue work from a previous agent session.","","## Session Context",`- Session ID: ${t.id}`,`- Messages: ${t.messageCount}`,t.lastMessageAt?`- Last active: ${t.lastMessageAt}`:"",`- Conversation file: ${r}`,"","## Session Preview",`> ${n}`,"","## Instructions","1. Read the full conversation history from the file above",`2. Analyze the current state of the repository — what was done, what remains`,"3. Create or update spec files to accurately reflect the current state and remaining work","4. Continue implementing any unfinished work from the conversation"].filter(Boolean).join("\n"),a=new URLSearchParams({repo:e.repositoryPath,prompt:o});d.push(`/create?${a.toString()}`)},[e.repositoryPath,d]);return(0,t.jsxs)("div",{className:(0,i.cn)("group relative",e.onDelete&&e.id&&"pl-10"),children:[e.showHandles?(0,t.jsx)(r.Handle,{type:"target",position:u.Position.Left,isConnectable:!1,className:"opacity-0!",style:{top:70}}):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)(N.TooltipProvider,{children:(0,t.jsxs)(N.Tooltip,{children:[(0,t.jsx)(N.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("button",{"aria-label":"Remove repository","data-testid":"repository-node-delete-button",onClick:e=>{e.stopPropagation(),M(!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)(m.Trash2,{className:"h-3.5 w-3.5"})})}),(0,t.jsx)(N.TooltipContent,{children:"Remove repository"})]})})}),(0,t.jsx)(j.Dialog,{open:S,onOpenChange:M,children:(0,t.jsxs)(j.DialogContent,{className:"max-w-xs",children:[(0,t.jsxs)(j.DialogHeader,{children:[(0,t.jsx)(j.DialogTitle,{children:"Remove repository?"}),(0,t.jsxs)(j.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)(j.DialogFooter,{className:"grid grid-cols-2 gap-2 sm:flex-none",children:[(0,t.jsx)(j.DialogClose,{asChild:!0,children:(0,t.jsx)(l.Button,{variant:"outline",children:"Cancel"})}),(0,t.jsx)(l.Button,{variant:"destructive",onClick:()=>{M(!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 w-[26rem] cursor-pointer flex-col overflow-hidden rounded-xl border shadow-sm",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 px-4 py-3",children:[(0,t.jsx)(h.Github,{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,i.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)(N.TooltipProvider,{children:(0,t.jsxs)(N.Tooltip,{children:[(0,t.jsx)(N.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(k.ActionButton,{label:"Open in IDE",onClick:P.openInIde,loading:P.ideLoading,error:!!P.ideError,icon:f.Code2,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(N.TooltipContent,{children:"Open in IDE"})]})}),(0,t.jsx)(N.TooltipProvider,{children:(0,t.jsxs)(N.Tooltip,{children:[(0,t.jsx)(N.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(k.ActionButton,{label:"Open in Shell",onClick:P.openInShell,loading:P.shellLoading,error:!!P.shellError,icon:p.Terminal,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(N.TooltipContent,{children:"Open in Shell"})]})}),(0,t.jsx)(N.TooltipProvider,{children:(0,t.jsxs)(N.Tooltip,{children:[(0,t.jsx)(N.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"flex items-center",children:(0,t.jsx)(k.ActionButton,{label:"Open Folder",onClick:P.openFolder,loading:P.folderLoading,error:!!P.folderError,icon:g.FolderOpen,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(N.TooltipContent,{children:"Open Folder"})]})}),(0,t.jsx)(R.FeatureSessionsDropdown,{repositoryPath:e.repositoryPath,onCreateFromSession:F})]}):null,e.onAdd?(0,t.jsx)(N.TooltipProvider,{children:(0,t.jsxs)(N.Tooltip,{children:[(0,t.jsx)(N.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,i.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)(N.TooltipContent,{children:"Add feature"})]})}):null]})]}),e.branch?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{"data-testid":"repository-node-git-info",className:"text-muted-foreground border-t px-4 py-2",children:(0,t.jsxs)("div",{className:"flex items-center gap-3 text-xs",children:[(0,t.jsxs)("span",{className:"flex items-center gap-1 truncate","data-testid":"repository-node-branch",children:[(0,t.jsx)(y.GitBranch,{className:"h-3 w-3 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:e.branch})]}),null!=e.behindCount&&e.behindCount>0?(0,t.jsxs)("span",{className:"flex shrink-0 items-center gap-1 whitespace-nowrap text-amber-500","data-testid":"repository-node-behind",children:[(0,t.jsx)(w.ArrowDown,{className:"h-3 w-3 shrink-0"}),e.behindCount," behind"]}):null]})}),e.commitMessage?(0,t.jsx)("div",{"data-testid":"repository-node-commit-info",className:"text-muted-foreground border-t px-4 py-2",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,t.jsx)(b.GitCommitHorizontal,{className:"h-3 w-3 shrink-0"}),(0,t.jsx)("span",{className:"min-w-0 truncate","data-testid":"repository-node-commit-message",children:e.commitMessage}),e.committer?(0,t.jsxs)("span",{className:"text-muted-foreground/70 ml-auto flex shrink-0 items-center gap-1","data-testid":"repository-node-committer",children:[(0,t.jsx)(E,{className:"h-3 w-3 shrink-0"}),(0,t.jsx)("span",{children:e.committer})]}):null]})}):null]}):"not-a-repo"===e.gitInfoStatus?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{"data-testid":"repository-node-not-repo",className:"text-muted-foreground border-t px-4 py-2",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,t.jsx)(g.FolderOpen,{className:"h-3 w-3 shrink-0"}),(0,t.jsx)("span",{className:"min-w-0 truncate opacity-60",children:e.repositoryPath??"Unknown path"})]})}),(0,t.jsx)("div",{className:"text-muted-foreground border-t px-4 py-2",children:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs opacity-40",children:[(0,t.jsx)(y.GitBranch,{className:"h-3 w-3 shrink-0"}),(0,t.jsx)("span",{children:"Not a git repository"})]})})]}):"ready"!==e.gitInfoStatus?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{"data-testid":"repository-node-git-loading",className:"border-t px-4 py-2",children:(0,t.jsxs)("div",{className:"flex h-4 items-center gap-2 text-xs",children:[(0,t.jsx)(y.GitBranch,{className:"text-muted-foreground h-3 w-3 shrink-0"}),(0,t.jsx)("span",{className:"bg-muted h-3 w-20 animate-pulse rounded"})]})}),(0,t.jsx)("div",{className:"border-t px-4 py-2",children:(0,t.jsxs)("div",{className:"flex h-4 items-center gap-2 text-xs",children:[(0,t.jsx)(b.GitCommitHorizontal,{className:"text-muted-foreground h-3 w-3 shrink-0"}),(0,t.jsx)("span",{className:"bg-muted h-3 w-36 animate-pulse rounded"})]})})]}):null,c.envDeploy&&e.repositoryPath?(0,t.jsx)("div",{"data-testid":"repository-node-dev-preview",className:"border-t px-4 py-2",onClick:e=>e.stopPropagation(),children:(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[T.deployError?(0,t.jsx)("span",{className:"truncate text-xs text-red-500",children:T.deployError}):L?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"mr-0.5 inline-block h-2 w-2 shrink-0 rounded-full bg-green-500"}),T.url?(0,t.jsx)("a",{href:T.url,target:"_blank",rel:"noopener noreferrer",className:"truncate text-green-700 hover:underline dark:text-green-400",children:T.url}):(0,t.jsx)("span",{className:"text-muted-foreground",children:"Starting..."})]}):(0,t.jsxs)("span",{className:"text-muted-foreground",children:["Run",(0,t.jsx)("span",{className:"text-muted-foreground/50 ml-2 text-[10px]",children:"start local environment"})]}),(0,t.jsx)(N.TooltipProvider,{children:(0,t.jsxs)(N.Tooltip,{children:[(0,t.jsx)(N.TooltipTrigger,{asChild:!0,children:(0,t.jsx)("span",{className:"ml-auto flex items-center",children:(0,t.jsx)(k.ActionButton,{label:T.deployError?"Retry":L?"Stop Dev Server":"Start Dev Server",onClick:L?T.stop:T.deploy,loading:T.deployLoading||T.stopLoading,error:!1,icon:T.deployError?s.RotateCcw:L?x.Square:v.Play,iconOnly:!0,variant:"ghost",size:"icon-xs"})})}),(0,t.jsx)(N.TooltipContent,{children:L?"Stop Dev Server":"Start Dev Server"})]})})]})}):null]}),e.onAdd||e.showHandles?(0,t.jsx)(r.Handle,{type:"source",position:u.Position.Right,isConnectable:!e.showHandles,className:"opacity-0!",style:{top:70}}):null]})}function M(e){let[n]=(0,u.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 P={x:30,y:30,zoom:.85};function T({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)(s.RotateCcw,{style:{fill:"none"}})})}function L({nodes:e,edges:o,selectedFeatureId:s,defaultViewport:u,onNodesChange:h,onAddFeature:f,onConnect:p,onNodeClick:g,onPaneClick:m,onCanvasDrag:v,onMoveEnd:x,onResetViewport:y,toolbar:b,emptyState:w}){let E=(0,n.useMemo)(()=>({featureNode:c.FeatureNode,repositoryNode:S}),[]),k=(0,n.useMemo)(()=>({dependencyEdge:M}),[]),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,_]=(0,n.useState)(N),[O,R]=(0,n.useState)(!1),L=(0,n.useRef)(N);(0,n.useEffect)(()=>{if(L.current&&!N){R(!0);let e=setTimeout(()=>{_(!1),R(!1)},300);return L.current=N,()=>clearTimeout(e)}!L.current&&N&&_(!0),L.current=N},[N]);let F=N&&!w?(0,t.jsx)(d.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,D=w??F;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:u??P,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:y?(0,t.jsx)(T,{onResetViewport:y}):null}),b]}),C&&D?(0,t.jsx)("div",{className:(0,i.cn)("pointer-events-none absolute inset-0 z-10 flex items-center justify-center transition-opacity duration-300",O?"opacity-0":"animate-in fade-in opacity-100 duration-200"),children:(0,t.jsx)("div",{className:"pointer-events-auto h-full w-full",children:D})}):null]})}var F=e.i(5147),D=e.i(8361),A=e.i(30153);let I="shep-canvas-viewport",$={x:30,y:30,zoom:.85};var z=e.i(33548),G=e.i(23925),B=e.i(83428),q=e.i(35e3),W=e.i(79687),U=e.i(99105),V=e.i(78521);e.i(13322);var H=e.i(61201),X=e.i(21023);let J=(0,X.createServerReference)("00d39e54d2a47ac9b19cf2699f8b4f4debc9e72cc4",X.callServer,void 0,X.findSourceMapURL,"isAgentSetupComplete"),K=(0,X.createServerReference)("0078613c2ec15ecf724d707d7c60b40e4f5858d3de",X.callServer,void 0,X.findSourceMapURL,"checkAgentAuth");var Y=e.i(11345),Q=e.i(35126),Z=e.i(74210),ee=e.i(86782),et=e.i(29847);let er=["select-agent","select-model"];function en({onComplete:e,className:r}){let[o,a]=(0,n.useState)([]),[s,l]=(0,n.useState)(!0),[d,c]=(0,n.useState)("select-agent"),[u,h]=(0,n.useState)(null),[f,p]=(0,n.useState)(!1),[g,m]=(0,n.useState)(!1),[v,x]=(0,n.useState)(!0),y=(0,n.useRef)(void 0);(0,n.useEffect)(()=>{(0,Q.getAllAgentModels)().then(a).finally(()=>l(!1))},[]);let b=u?o.find(e=>e.agentType===u):null,w=(0,n.useCallback)((e,t)=>{m(!0),x(!1),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{t?.(),c(e),requestAnimationFrame(()=>{x(!0),m(!1)})},150)},[]);(0,n.useEffect)(()=>()=>{y.current&&clearTimeout(y.current)},[]);let E=(0,n.useCallback)(async(t,r)=>{p(!0);try{await (0,Z.updateAgentAndModel)(t,r),x(!1),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{e()},200)}catch{p(!1)}},[e]),k=(0,n.useCallback)(e=>{let t=o.find(t=>t.agentType===e);t&&t.models.length>0?w("select-model",()=>{h(e)}):E(e,null)},[o,w,E]),j=(0,n.useCallback)(e=>{u&&E(u,e)},[u,E]),N=(0,n.useCallback)(()=>{"select-model"===d&&w("select-agent",()=>{h(null)})},[d,w]);if(s)return(0,t.jsxs)("div",{"data-testid":"welcome-agent-setup",className:(0,i.cn)("flex flex-col items-center justify-center gap-4",r),children:[(0,t.jsx)(B.Loader2,{className:"text-muted-foreground h-5 w-5 animate-spin"}),(0,t.jsx)("p",{className:"text-muted-foreground text-sm",children:"Loading agents…"})]});let C=er.indexOf(d),_="select-agent"===d?"Choose your agent":"Pick a model",O="select-agent"===d?"Select the AI coding agent you want Shep to use.":b?`Choose which ${b.label} model to run.`:"";return(0,t.jsxs)("div",{"data-testid":"welcome-agent-setup",className:(0,i.cn)("flex w-full flex-col items-center",r),children:[(0,t.jsx)("div",{className:"mb-8 flex w-full max-w-xs items-center gap-1.5",children:er.map((e,r)=>(0,t.jsx)("div",{className:(0,i.cn)("h-[3px] flex-1 rounded-full transition-colors duration-300",r<=C?"bg-foreground/60":"bg-muted")},e))}),(0,t.jsxs)("div",{className:(0,i.cn)("flex w-full flex-col items-center transition-opacity duration-200",v&&!g?"opacity-100":"opacity-0"),children:[(0,t.jsx)("h1",{className:"text-foreground/90 text-center text-5xl font-extralight tracking-tight",children:_}),(0,t.jsx)("p",{className:"text-muted-foreground mt-3 text-center text-lg leading-relaxed font-light",children:O}),(0,t.jsxs)("div",{className:"mt-8 flex w-full flex-col items-center",children:["select-agent"===d&&(0,t.jsx)("div",{"data-testid":"agent-list",className:"grid w-full max-w-lg gap-3",style:{gridTemplateColumns:`repeat(${Math.min(o.length,4)}, minmax(0, 1fr))`},children:o.map(e=>{let r=(0,ee.getAgentTypeIcon)(e.agentType);return(0,t.jsxs)("button",{type:"button",disabled:f,"data-testid":`agent-option-${e.agentType}`,className:"border-border hover:bg-accent hover:border-foreground/20 flex cursor-pointer flex-col items-center gap-3 rounded-2xl border px-4 py-5 transition-all duration-150 active:scale-[0.97] disabled:opacity-50",onClick:()=>k(e.agentType),children:[(0,t.jsx)(r,{className:"text-foreground/70 h-7 w-7"}),(0,t.jsx)("span",{className:"text-sm font-medium",children:e.label})]},e.agentType)})}),"select-model"===d&&b?(0,t.jsxs)("div",{"data-testid":"model-list",className:"flex w-full max-w-lg flex-col items-center gap-4",children:[(0,t.jsxs)("button",{type:"button",disabled:f,className:"text-muted-foreground hover:text-foreground flex cursor-pointer items-center gap-1.5 self-start text-sm transition-colors",onClick:N,children:[(0,t.jsx)(Y.ChevronLeft,{className:"h-4 w-4"}),"Back"]}),(0,t.jsx)("div",{className:"grid w-full gap-3",style:{gridTemplateColumns:`repeat(${Math.min(b.models.length,3)}, minmax(0, 1fr))`},children:b.models.map(e=>{let r=(0,et.getModelMeta)(e.id);return(0,t.jsxs)("button",{type:"button",disabled:f,"data-testid":`model-option-${e.id}`,className:"border-border hover:bg-accent hover:border-foreground/20 flex cursor-pointer flex-col items-center gap-2 rounded-2xl border px-4 py-5 text-center transition-all duration-150 active:scale-[0.97] disabled:opacity-50",onClick:()=>j(e.id),children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:r.displayName||e.displayName}),(0,t.jsx)("span",{className:"text-muted-foreground text-xs leading-tight",children:r.description||e.description})]},e.id)})})]}):null]})]})]})}let eo=["cd ~/my-repo",'shep feat new "sleek dashboard"'];function ea({onRepositorySelect:e,className:r}){let[o,a]=(0,n.useState)(!1),[s,l]=(0,n.useState)(!1),[d,c]=(0,n.useState)(!1),[u,h]=(0,n.useState)(null),[f,m]=(0,n.useState)(null),[v,x]=(0,n.useState)(!1),{reactFileManager:y}=(0,_.useFeatureFlags)();async function b(){if(!s){if(y)return void c(!0);l(!0);try{let t=await (0,V.pickFolder)();t&&e?.(t)}catch{c(!0)}finally{l(!1)}}}(0,n.useEffect)(()=>{J().then(e=>{h(e)})},[]),(0,n.useEffect)(()=>{u&&K().then(m)},[u]);let w=(0,n.useCallback)(async()=>{await navigator.clipboard.writeText(eo.join("\n")),a(!0),setTimeout(()=>a(!1),2e3)},[]),E=(0,n.useCallback)(()=>{h(!0)},[]),k=(0,n.useCallback)(()=>{m(null),K().then(m)},[]);return null===u?null:(0,t.jsxs)("div",{"data-testid":"control-center-empty-state",className:(0,i.cn)("relative flex h-full w-full flex-col items-center justify-center px-8",r),children:[u?(0,t.jsxs)("div",{className:"animate-in fade-in flex w-full max-w-md flex-col items-center duration-300",children:[(0,t.jsx)("h1",{className:"text-foreground/90 text-center text-5xl font-extralight tracking-tight",children:"Add a project"}),(0,t.jsxs)("p",{className:"text-muted-foreground mt-3 text-center text-lg leading-relaxed font-light",children:["Add your project folder to unlock feature creation.",(0,t.jsx)("br",{}),"Describe what you need — Shep handles the rest."]}),(0,t.jsx)("div",{className:"mt-8",children:(0,t.jsx)(es,{status:f,onRetry:k})}),(0,t.jsxs)("button",{type:"button","data-testid":"empty-state-add-repository",onClick:b,disabled:s,className:"bg-foreground text-background hover:bg-foreground/90 mt-10 flex w-full cursor-pointer items-center justify-center gap-2.5 rounded-xl px-6 py-4 text-base font-medium shadow-lg transition-all duration-200 hover:shadow-xl active:scale-[0.98] disabled:cursor-wait disabled:opacity-50",children:[s?(0,t.jsx)(B.Loader2,{className:"h-5 w-5 animate-spin"}):(0,t.jsx)(g.FolderOpen,{className:"h-5 w-5"}),s?"Opening…":"Choose a Folder"]}),(0,t.jsx)("p",{className:"text-muted-foreground/60 mt-3 text-center text-sm",children:"Any folder works — git will be initialized automatically if needed."})]}):(0,t.jsx)(en,{onComplete:E}),u?(0,t.jsxs)("div",{className:"absolute bottom-8 flex flex-col items-center",style:{animationDelay:"400ms",animationDuration:"600ms",animationFillMode:"both"},children:[(0,t.jsxs)("button",{type:"button",onClick:()=>x(!v),className:"text-muted-foreground hover:text-foreground flex cursor-pointer items-center gap-1.5 transition-colors duration-200",children:[(0,t.jsx)(p.Terminal,{className:"h-3.5 w-3.5"}),(0,t.jsx)("span",{className:"text-sm",children:"or use the CLI"}),(0,t.jsx)(U.ChevronDown,{className:(0,i.cn)("h-3.5 w-3.5 transition-transform duration-200",v?"":"rotate-180")})]}),v?(0,t.jsx)("div",{className:"animate-in fade-in slide-in-from-top-1 mt-3 w-80 duration-200",children:(0,t.jsxs)("div",{"data-testid":"cli-code-block",className:"relative rounded-xl bg-zinc-900 px-5 py-4 font-mono text-[13px] leading-relaxed text-zinc-400",children:[(0,t.jsx)("button",{type:"button","data-testid":"cli-code-block-copy",onClick:w,className:"absolute top-3 right-3 cursor-pointer rounded-md p-1.5 text-zinc-600 transition-colors hover:bg-zinc-800 hover:text-zinc-300","aria-label":"Copy commands",children:o?(0,t.jsx)(G.Check,{className:"h-3.5 w-3.5 text-emerald-400"}):(0,t.jsx)(z.Copy,{className:"h-3.5 w-3.5"})}),(0,t.jsx)("div",{className:"space-y-1",children:eo.map(e=>(0,t.jsxs)("div",{className:"whitespace-nowrap",children:[(0,t.jsx)("span",{className:"text-zinc-600 select-none",children:"$ "}),(0,t.jsx)("span",{className:"text-zinc-300",children:e})]},e))})]})}):null]}):null,(0,t.jsx)(H.ReactFileManagerDialog,{open:d,onOpenChange:e=>{e||c(!1)},onSelect:function(t){t&&e?.(t),c(!1)}})]})}function es({status:e,onRetry:r}){return e?e.installed&&e.authenticated?(0,t.jsxs)("div",{className:"animate-in fade-in flex items-center gap-2",children:[(0,t.jsx)(q.CheckCircle2,{className:"h-4 w-4 text-emerald-500"}),(0,t.jsxs)("span",{className:"text-sm text-emerald-600 dark:text-emerald-400",children:[e.label," ready"]})]}):e.installed?(0,t.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(W.AlertCircle,{className:"h-4 w-4 text-amber-500"}),(0,t.jsxs)("span",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:[e.label," needs authentication"]})]}),e.authCommand?(0,t.jsx)("code",{className:"rounded-lg bg-zinc-100 px-3 py-1.5 text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400",children:e.authCommand}):null,(0,t.jsxs)("div",{className:"flex items-center gap-3",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.5 text-xs font-medium text-amber-600 underline underline-offset-2 hover:text-amber-800 dark:text-amber-400",children:[(0,t.jsx)(p.Terminal,{className:"h-3 w-3"}),"Open ",e.label]}):null,(0,t.jsx)("button",{type:"button",onClick:r,className:"text-xs text-amber-600 underline underline-offset-2 hover:text-amber-800 dark:text-amber-400",children:"Re-check"})]})]}):(0,t.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(W.AlertCircle,{className:"h-4 w-4 text-amber-500"}),(0,t.jsxs)("span",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:[e.label," not installed"]})]}),e.binaryName?(0,t.jsxs)("code",{className:"rounded-lg bg-zinc-100 px-3 py-1.5 text-xs text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400",children:["npm install -g ",e.binaryName]}):null,(0,t.jsx)("button",{type:"button",onClick:r,className:"text-xs text-amber-600 underline underline-offset-2 hover:text-amber-800 dark:text-amber-400",children:"Re-check"})]}):(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(B.Loader2,{className:"text-muted-foreground/50 h-3.5 w-3.5 animate-spin"}),(0,t.jsx)("span",{className:"text-muted-foreground/50 text-sm",children:"Checking setup…"})]})}var ei=e.i(17840);let el={maxZoom:1,padding:.5,duration:500};function ed({initialNodes:e,initialEdges:a}){let s,i,l,d=(0,o.useRouter)(),c=(0,o.usePathname)(),u=(s=(0,o.usePathname)().match(/^\/feature\/([^/]+)/),s?.[1]??null),h=(0,D.useSoundAction)("click"),{guardedNavigate:f}=(0,A.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(I);if(null==e)return $;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:$}catch{return $}}()).current,l=(0,n.useRef)(null),(0,n.useEffect)(()=>()=>{null!=l.current&&clearTimeout(l.current)},[]),{defaultViewport:i,onMoveEnd:(0,n.useCallback)(e=>{null!=l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{try{localStorage.setItem(I,JSON.stringify(e))}catch{}},500)},[]),resetViewport:(0,n.useCallback)(()=>{try{localStorage.removeItem(I)}catch{}return $},[])}),{nodes:y,edges:b,onNodesChange:w,handleConnect:E,handleAddRepository:k,handleDeleteFeature:j,handleRetryFeature:N,handleStartFeature:C,handleStopFeature:_,handleDeleteRepository:O,createFeatureNode:R,setCallbacks:S}=(0,ei.useControlCenterState)(e,a),{setFeatures:M,setHasRepositories:P}=(0,F.useSidebarFeaturesContext)(),T=(0,n.useMemo)(()=>y.filter(e=>"featureNode"===e.type),[y]),z=(0,n.useMemo)(()=>T.map(e=>{let t=e.data;return`${t.featureId}:${t.state}:${t.name}`}).sort().join(","),[T]);(0,n.useEffect)(()=>{M(T.map(e=>{let t=e.data,r=(0,F.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))},[z,T,M]);let G=(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(),d.push(`/feature/${r.featureId}`)})}},[d,h,f]),B=(0,n.useCallback)(()=>{h.play(),d.push("/create")},[d,h]),q=(0,n.useCallback)(e=>{h.play();let t=y.find(t=>t.id===e),r=t?.data?.repositoryPath;r?d.push(`/create?repo=${encodeURIComponent(r)}`):d.push("/create")},[y,d,h]),W=(0,n.useCallback)(e=>{let t=e.startsWith("feat-")?e.slice(5):e,r=b.find(t=>t.target===e),n=r?y.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),d.push(`/create?${a.toString()}`)},[y,b,d,h]),U=(0,n.useCallback)(e=>{let t=y.find(t=>t.id===e);if(t?.type==="repositoryNode"){let e=t.data;e.id&&f(()=>d.push(`/repository/${e.id}`))}},[y,d,f]),V=(0,n.useCallback)(()=>{"/"!==c&&f(()=>d.push("/"))},[d,c,f]),H=(0,n.useCallback)(e=>{setTimeout(()=>{p(el),g.current=setTimeout(()=>{f(()=>d.push(`/create?repo=${encodeURIComponent(e)}`))},600)},0)},[p,f,d]),X=(0,n.useCallback)(e=>{let{wasEmpty:t,repoPath:r}=k(e);t&&H(r)},[k,H]);(0,n.useEffect)(()=>{let e=e=>{X(e.detail.path)};return window.addEventListener("shep:add-repository",e),()=>{window.removeEventListener("shep:add-repository",e),null!=g.current&&clearTimeout(g.current)}},[X]),(0,n.useEffect)(()=>{let e=e=>{let t=e.detail;if(t.parentId)return void R(`feat-${t.parentId}`,{state:"creating",featureId:t.featureId,name:t.name,description:t.description,repositoryPath:t.repositoryPath},"dependencyEdge");let r=y.find(e=>"repositoryNode"===e.type&&e.data.repositoryPath===t.repositoryPath);R(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)},[y,R]),(0,n.useEffect)(()=>{let e=e=>{let{featureId:t,cleanup:r,cascadeDelete:n,closePr:o}=e.detail;j(t,r,n,o)};return window.addEventListener("shep:feature-delete-requested",e),()=>window.removeEventListener("shep:feature-delete-requested",e)},[j]),(0,n.useEffect)(()=>{S({onNodeAction:W,onFeatureDelete:j,onRetryFeature:N,onStartFeature:C,onStopFeature:_,onRepositoryAdd:q,onRepositoryClick:U,onRepositoryDelete:O})},[S,W,j,N,C,_,q,U,O]);let J=(0,n.useCallback)((e,t)=>{v(t)},[v]),K=y.some(e=>"repositoryNode"===e.type);(0,n.useEffect)(()=>{P(K)},[K,P]);let[Y,Q]=(0,n.useState)(K),Z=(0,n.useRef)(null);(0,n.useEffect)(()=>(K?(Z.current&&(clearTimeout(Z.current),Z.current=null),Q(!0)):Y&&(x(),Z.current=setTimeout(()=>{Q(!1),Z.current=null},500)),()=>{Z.current&&clearTimeout(Z.current)}),[K,Y,x]);let ee=c.startsWith("/create"),et=(0,n.useMemo)(()=>{let e=y.filter(e=>"repositoryNode"===e.type),t=y.some(e=>"featureNode"===e.type);return 1!==e.length||t||ee?y:y.map(e=>"repositoryNode"===e.type?{...e,data:{...e.data,pulseAdd:!0}}:e)},[y,ee]);return(0,t.jsx)(L,{nodes:Y?et:[],edges:Y?b:[],selectedFeatureId:u,defaultViewport:m,onNodesChange:w,onConnect:E,onAddFeature:B,onNodeClick:G,onPaneClick:V,onMoveEnd:J,onResetViewport:x,emptyState:(0,t.jsx)(ea,{onRepositorySelect:X})})}function ec({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)(ed,{initialNodes:e,initialEdges:n})}),(0,t.jsx)("div",{children:o},"drawer")]})}e.s(["ControlCenter",()=>ec],48246)}]);
@@ -1 +1 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,90382,e=>{"use strict";var t=e.i(20314),r=e.i(79054),o=e.i(91967),a=e.i(5978),s=e.i(22528),n=e.i(53532),l=e.i(41687),i=e.i(56720),c=e.i(13123),d=e.i(52740),p=e.i(39979),u=e.i(85995),h=e.i(87620),f=e.i(86874),m=e.i(36589),x=e.i(73772),v=e.i(13044),b="Popover",[g,j]=(0,s.createContextScope)(b,[d.createPopperScope]),C=(0,d.createPopperScope)(),[w,y]=g(b),N=e=>{let{__scopePopover:o,children:a,open:s,defaultOpen:n,onOpenChange:l,modal:i=!1}=e,p=C(o),u=r.useRef(null),[h,f]=r.useState(!1),[x,v]=(0,m.useControllableState)({prop:s,defaultProp:n??!1,onChange:l,caller:b});return(0,t.jsx)(d.Root,{...p,children:(0,t.jsx)(w,{scope:o,contentId:(0,c.useId)(),triggerRef:u,open:x,onOpenChange:v,onOpenToggle:r.useCallback(()=>v(e=>!e),[v]),hasCustomAnchor:h,onCustomAnchorAdd:r.useCallback(()=>f(!0),[]),onCustomAnchorRemove:r.useCallback(()=>f(!1),[]),modal:i,children:a})})};N.displayName=b;var P="PopoverAnchor",R=r.forwardRef((e,o)=>{let{__scopePopover:a,...s}=e,n=y(P,a),l=C(a),{onCustomAnchorAdd:i,onCustomAnchorRemove:c}=n;return r.useEffect(()=>(i(),()=>c()),[i,c]),(0,t.jsx)(d.Anchor,{...l,...s,ref:o})});R.displayName=P;var S="PopoverTrigger",k=r.forwardRef((e,r)=>{let{__scopePopover:s,...n}=e,l=y(S,s),i=C(s),c=(0,a.useComposedRefs)(r,l.triggerRef),p=(0,t.jsx)(h.Primitive.button,{type:"button","aria-haspopup":"dialog","aria-expanded":l.open,"aria-controls":l.contentId,"data-state":z(l.open),...n,ref:c,onClick:(0,o.composeEventHandlers)(e.onClick,l.onOpenToggle)});return l.hasCustomAnchor?p:(0,t.jsx)(d.Anchor,{asChild:!0,...i,children:p})});k.displayName=S;var A="PopoverPortal",[E,D]=g(A,{forceMount:void 0}),O=e=>{let{__scopePopover:r,forceMount:o,children:a,container:s}=e,n=y(A,r);return(0,t.jsx)(E,{scope:r,forceMount:o,children:(0,t.jsx)(u.Presence,{present:o||n.open,children:(0,t.jsx)(p.Portal,{asChild:!0,container:s,children:a})})})};O.displayName=A;var F="PopoverContent",L=r.forwardRef((e,r)=>{let o=D(F,e.__scopePopover),{forceMount:a=o.forceMount,...s}=e,n=y(F,e.__scopePopover);return(0,t.jsx)(u.Presence,{present:a||n.open,children:n.modal?(0,t.jsx)(B,{...s,ref:r}):(0,t.jsx)(I,{...s,ref:r})})});L.displayName=F;var T=(0,f.createSlot)("PopoverContent.RemoveScroll"),B=r.forwardRef((e,s)=>{let n=y(F,e.__scopePopover),l=r.useRef(null),i=(0,a.useComposedRefs)(s,l),c=r.useRef(!1);return r.useEffect(()=>{let e=l.current;if(e)return(0,x.hideOthers)(e)},[]),(0,t.jsx)(v.RemoveScroll,{as:T,allowPinchZoom:!0,children:(0,t.jsx)(U,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:(0,o.composeEventHandlers)(e.onCloseAutoFocus,e=>{e.preventDefault(),c.current||n.triggerRef.current?.focus()}),onPointerDownOutside:(0,o.composeEventHandlers)(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,r=0===t.button&&!0===t.ctrlKey;c.current=2===t.button||r},{checkForDefaultPrevented:!1}),onFocusOutside:(0,o.composeEventHandlers)(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),I=r.forwardRef((e,o)=>{let a=y(F,e.__scopePopover),s=r.useRef(!1),n=r.useRef(!1);return(0,t.jsx)(U,{...e,ref:o,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(s.current||a.triggerRef.current?.focus(),t.preventDefault()),s.current=!1,n.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(s.current=!0,"pointerdown"===t.detail.originalEvent.type&&(n.current=!0));let r=t.target;a.triggerRef.current?.contains(r)&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&n.current&&t.preventDefault()}})}),U=r.forwardRef((e,r)=>{let{__scopePopover:o,trapFocus:a,onOpenAutoFocus:s,onCloseAutoFocus:c,disableOutsidePointerEvents:p,onEscapeKeyDown:u,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:m,...x}=e,v=y(F,o),b=C(o);return(0,l.useFocusGuards)(),(0,t.jsx)(i.FocusScope,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:s,onUnmountAutoFocus:c,children:(0,t.jsx)(n.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:p,onInteractOutside:m,onEscapeKeyDown:u,onPointerDownOutside:h,onFocusOutside:f,onDismiss:()=>v.onOpenChange(!1),children:(0,t.jsx)(d.Content,{"data-state":z(v.open),role:"dialog",id:v.contentId,...b,...x,ref:r,style:{...x.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),_="PopoverClose",H=r.forwardRef((e,r)=>{let{__scopePopover:a,...s}=e,n=y(_,a);return(0,t.jsx)(h.Primitive.button,{type:"button",...s,ref:r,onClick:(0,o.composeEventHandlers)(e.onClick,()=>n.onOpenChange(!1))})});H.displayName=_;var M=r.forwardRef((e,r)=>{let{__scopePopover:o,...a}=e,s=C(o);return(0,t.jsx)(d.Arrow,{...s,...a,ref:r})});function z(e){return e?"open":"closed"}M.displayName="PopoverArrow",e.s(["Anchor",()=>R,"Arrow",()=>M,"Close",()=>H,"Content",()=>L,"Popover",()=>N,"PopoverAnchor",()=>R,"PopoverArrow",()=>M,"PopoverClose",()=>H,"PopoverContent",()=>L,"PopoverPortal",()=>O,"PopoverTrigger",()=>k,"Portal",()=>O,"Root",()=>N,"Trigger",()=>k,"createPopoverScope",()=>j],89920);var G=e.i(89920),G=G,K=e.i(31777);let $=G.Root,W=G.Trigger;G.Anchor;let Z=r.forwardRef(({className:e,align:r="center",sideOffset:o=4,...a},s)=>(0,t.jsx)(G.Portal,{children:(0,t.jsx)(G.Content,{ref:s,align:r,sideOffset:o,className:(0,K.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 rounded-md border p-4 shadow-md outline-none",e),...a})}));Z.displayName=G.Content.displayName,e.s(["Popover",()=>$,"PopoverContent",()=>Z,"PopoverTrigger",()=>W],90382)},83843,e=>{"use strict";let t=(0,e.i(3645).default)("chevrons-up-down",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);e.s(["ChevronsUpDown",()=>t],83843)},36479,e=>{"use strict";var t=e.i(20314),r=e.i(79054),o=e.i(31406),a=e.i(60112),s=e.i(21023);let n=(0,s.createServerReference)("408efb04267fa69e4d4de307fc331779470a867e5c",s.callServer,void 0,s.findSourceMapURL,"adoptBranch"),l=(0,s.createServerReference)("405fee32f34785f1a69351014fb40d12f402a24b50",s.callServer,void 0,s.findSourceMapURL,"listBranches");var i=e.i(23925),c=e.i(97667),d=e.i(83843),p=e.i(49228),u=e.i(83428);e.i(1650);var h=e.i(11495),f=e.i(45811),m=e.i(35364),x=e.i(98127),v=e.i(41957),b=e.i(66459),g=e.i(31777);let j=r.forwardRef(({className:e,...r},o)=>(0,t.jsx)("div",{ref:o,className:(0,g.cn)("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...r}));j.displayName="Command";let C=r.forwardRef(({className:e,...r},o)=>(0,t.jsxs)("div",{className:"flex items-center border-b px-3",children:[(0,t.jsx)(b.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),(0,t.jsx)("input",{ref:o,className:(0,g.cn)("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none disabled:cursor-not-allowed disabled:opacity-50",e),...r})]}));C.displayName="CommandInput";let w=r.forwardRef(({className:e,...r},o)=>(0,t.jsx)("div",{ref:o,className:(0,g.cn)("max-h-[300px] overflow-x-hidden overflow-y-auto",e),...r}));w.displayName="CommandList";let y=r.forwardRef(({className:e,...r},o)=>(0,t.jsx)("div",{ref:o,className:(0,g.cn)("text-muted-foreground py-6 text-center text-sm",e),...r}));y.displayName="CommandEmpty";let N=r.forwardRef(({className:e,...r},o)=>(0,t.jsx)("div",{ref:o,className:(0,g.cn)("text-foreground overflow-hidden p-1",e),...r}));N.displayName="CommandGroup";let P=r.forwardRef(({className:e,selected:r,...o},a)=>(0,t.jsx)("button",{ref:a,type:"button","data-selected":r,className:(0,g.cn)("relative flex w-full cursor-default items-center rounded-sm px-2 py-1.5 text-sm transition-colors outline-none select-none","hover:bg-accent hover:text-accent-foreground","data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground","disabled:pointer-events-none disabled:opacity-50",e),...o}));P.displayName="CommandItem",r.forwardRef(({className:e,...r},o)=>(0,t.jsx)("div",{ref:o,className:(0,g.cn)("bg-border -mx-1 h-px",e),...r})).displayName="CommandSeparator";var R=e.i(90382);function S({open:e,onClose:o,onSubmit:a,isSubmitting:s=!1,error:n,repositories:l=[],selectedRepositoryPath:b,onRepositoryChange:S,branches:k=[],branchesLoading:A=!1}){let[E,D]=(0,r.useState)(""),[O,F]=(0,r.useState)(!1),[L,T]=(0,r.useState)(""),B=(0,r.useRef)(null),[I,U]=(0,r.useState)(!1),[_,H]=(0,r.useState)(""),M=(0,r.useRef)(null),z=l.find(e=>e.path===b),G=!!b;(0,r.useEffect)(()=>{e||(D(""),T(""),F(!1),U(!1),H(""))},[e]),(0,r.useEffect)(()=>{D(""),T("")},[b]);let K=(0,r.useCallback)(e=>{e.preventDefault();let t=E.trim();t&&b&&!s&&a(t,b)},[E,b,s,a]),$=(0,r.useCallback)(()=>{D(""),T(""),o()},[o]),W=(0,r.useCallback)(e=>{D(e),T(e),F(!1)},[]),Z=(0,r.useCallback)(e=>{T(e.target.value),O||F(!0)},[O]),q=(0,r.useCallback)(e=>{if("Enter"===e.key){e.preventDefault();let t=L.trim();t&&(D(t),F(!1))}"Escape"===e.key&&(F(!1),T(E))},[L,E]),J=(0,r.useCallback)(e=>{S?.(e),U(!1),H("")},[S]),Q=k.filter(e=>e.toLowerCase().includes(L.toLowerCase())),V=_.trim()?l.filter(e=>e.name.toLowerCase().includes(_.toLowerCase())||e.path.toLowerCase().includes(_.toLowerCase())):l;(0,r.useEffect)(()=>{I?setTimeout(()=>M.current?.focus(),0):H("")},[I]);let X=!E.trim()||!b||s,Y=(0,t.jsxs)("div",{children:[(0,t.jsxs)(f.DrawerTitle,{className:"flex items-center gap-2",children:[(0,t.jsx)(p.GitBranch,{className:"h-4 w-4"}),"Adopt Branch"]}),(0,t.jsx)(f.DrawerDescription,{className:"text-muted-foreground text-sm",children:"Import an existing git branch into Shep's feature tracking"})]});return(0,t.jsx)(h.BaseDrawer,{open:e,onClose:$,size:"sm",modal:!1,header:Y,"data-testid":"adopt-branch-drawer",children:(0,t.jsxs)("form",{onSubmit:K,className:"flex flex-1 flex-col",children:[(0,t.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(v.Label,{children:"Repository"}),(0,t.jsxs)(R.Popover,{open:I,onOpenChange:U,children:[(0,t.jsx)(R.PopoverTrigger,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",role:"combobox","aria-expanded":I,"aria-label":"Repository",disabled:s,"data-testid":"adopt-repo-combobox",className:(0,g.cn)("border-input bg-background ring-offset-background focus:ring-ring flex h-9 w-full items-center justify-between rounded-md border px-3 py-2 text-sm focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",!z&&"text-muted-foreground"),children:[(0,t.jsx)("span",{className:"truncate",children:z?z.name:"Select repository..."}),(0,t.jsx)(d.ChevronsUpDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),(0,t.jsx)(R.PopoverContent,{className:"w-80 p-0",align:"start","data-testid":"adopt-repo-combobox-content",children:(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("div",{className:"border-b p-2",children:(0,t.jsx)(x.Input,{ref:M,placeholder:"Search repositories...",value:_,onChange:e=>H(e.target.value),className:"h-8 border-0 p-0 text-sm shadow-none focus-visible:ring-0","data-testid":"adopt-repo-search"})}),(0,t.jsx)("div",{className:"max-h-48 overflow-y-auto py-1",role:"listbox","aria-label":"Repositories",children:0===V.length?(0,t.jsx)("p",{className:"text-muted-foreground px-3 py-2 text-sm",children:"No repositories found."}):V.map(e=>(0,t.jsxs)("button",{type:"button",role:"option","aria-selected":b===e.path,onClick:()=>J(e.path),className:(0,g.cn)("hover:bg-accent hover:text-accent-foreground flex w-full items-center gap-2 px-3 py-2 text-sm",b===e.path&&"bg-accent/50"),"data-testid":`adopt-repo-option-${e.id}`,children:[(0,t.jsx)(c.CheckIcon,{className:(0,g.cn)("h-4 w-4 shrink-0",b!==e.path&&"invisible")}),(0,t.jsxs)("span",{className:"flex flex-col items-start truncate",children:[(0,t.jsx)("span",{className:"truncate",children:e.name}),(0,t.jsx)("span",{className:"text-muted-foreground truncate text-xs",children:e.path})]})]},e.id))})]})})]}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:"Select the repository that contains the branch you want to adopt."})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(v.Label,{htmlFor:"branch-name",children:"Branch name"}),(0,t.jsxs)(R.Popover,{open:O,onOpenChange:F,children:[(0,t.jsx)(R.PopoverTrigger,{asChild:!0,children:(0,t.jsxs)(m.Button,{variant:"outline",role:"combobox","aria-expanded":O,disabled:s||!G,className:"w-full justify-between font-normal","data-testid":"adopt-branch-input",children:[(0,t.jsx)("span",{className:"truncate",children:G?A?"Loading branches...":E||"Select a branch...":"Select a repository first..."}),(0,t.jsx)(d.ChevronsUpDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),(0,t.jsx)(R.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:(0,t.jsxs)(j,{children:[(0,t.jsx)(C,{ref:B,placeholder:"Search branches...",value:L,onChange:Z,onKeyDown:q,"data-testid":"adopt-branch-search"}),(0,t.jsxs)(w,{children:[!A&&0===Q.length&&(0,t.jsx)(y,{children:0===k.length?"No branches found.":L?"No match — press Enter to use this value.":"No branches available."}),A?(0,t.jsx)(y,{children:(0,t.jsx)(u.Loader2,{className:"mx-auto h-4 w-4 animate-spin"})}):null,Q.length>0&&(0,t.jsx)(N,{children:Q.map(e=>(0,t.jsxs)(P,{selected:e===E,onClick:()=>W(e),children:[(0,t.jsx)(i.Check,{className:(0,g.cn)("mr-2 h-4 w-4",e===E?"opacity-100":"opacity-0")}),(0,t.jsx)(p.GitBranch,{className:"mr-2 h-3 w-3 opacity-50"}),e]},e))})]})]})})]}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:G?"Select a branch from the dropdown or type to search. Local and remote branches are shown.":"Please select a repository above to see available branches."})]}),n?(0,t.jsx)("p",{className:"text-destructive text-sm","data-testid":"adopt-branch-error",children:n}):null]})}),(0,t.jsx)("div",{className:"border-t p-4",children:(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(m.Button,{type:"button",variant:"outline",onClick:$,disabled:s,className:"flex-1",children:"Cancel"}),(0,t.jsx)(m.Button,{type:"submit",disabled:X,className:"flex-1","data-testid":"adopt-branch-submit",children:s?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(u.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Adopting..."]}):"Adopt Branch"})]})})]})})}function k({repositoryPath:e,repositories:s}){let i=(0,o.useRouter)(),c=(0,o.usePathname)(),[d,p]=(0,r.useState)(!1),[u,h]=(0,r.useState)(),[f,m]=(0,r.useState)([]),[x,v]=(0,r.useState)(!1),[b,g]=(0,r.useState)(e),j=c.startsWith("/adopt"),C=!d&&j;(0,r.useEffect)(()=>{!j&&d&&p(!1)},[j,d]),(0,r.useEffect)(()=>{j&&(h(void 0),g(e))},[j,e]),(0,r.useEffect)(()=>{j&&b?(v(!0),m([]),l(b).then(m).catch(()=>m([])).finally(()=>v(!1))):m([])},[j,b]);let w=(0,r.useCallback)(()=>{i.push("/")},[i]),y=(0,r.useCallback)(e=>{g(e)},[]),N=(0,r.useCallback)((e,t)=>{h(void 0),p(!0),i.push("/"),n({branchName:e,repositoryPath:t}).then(e=>{e.error?a.toast.error(e.error):(window.dispatchEvent(new CustomEvent("shep:feature-created",{detail:{featureId:e.feature.id,name:e.feature.name,description:e.feature.description,repositoryPath:e.feature.repositoryPath}})),a.toast.success(`Branch adopted as "${e.feature.name}"`))}).catch(()=>{a.toast.error("Failed to adopt branch"),p(!1)})},[i]);return(0,t.jsx)(S,{open:C,onClose:w,onSubmit:N,isSubmitting:d,error:u,repositories:s,selectedRepositoryPath:b,onRepositoryChange:y,branches:f,branchesLoading:x})}e.s(["AdoptDrawerClient",()=>k],36479)}]);
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,90382,e=>{"use strict";var t=e.i(20314),r=e.i(79054),o=e.i(91967),a=e.i(5978),s=e.i(22528),n=e.i(53532),l=e.i(41687),i=e.i(56720),c=e.i(13123),d=e.i(52740),p=e.i(39979),u=e.i(85995),h=e.i(87620),f=e.i(86874),m=e.i(36589),x=e.i(73772),v=e.i(13044),b="Popover",[g,j]=(0,s.createContextScope)(b,[d.createPopperScope]),C=(0,d.createPopperScope)(),[w,y]=g(b),N=e=>{let{__scopePopover:o,children:a,open:s,defaultOpen:n,onOpenChange:l,modal:i=!1}=e,p=C(o),u=r.useRef(null),[h,f]=r.useState(!1),[x,v]=(0,m.useControllableState)({prop:s,defaultProp:n??!1,onChange:l,caller:b});return(0,t.jsx)(d.Root,{...p,children:(0,t.jsx)(w,{scope:o,contentId:(0,c.useId)(),triggerRef:u,open:x,onOpenChange:v,onOpenToggle:r.useCallback(()=>v(e=>!e),[v]),hasCustomAnchor:h,onCustomAnchorAdd:r.useCallback(()=>f(!0),[]),onCustomAnchorRemove:r.useCallback(()=>f(!1),[]),modal:i,children:a})})};N.displayName=b;var P="PopoverAnchor",R=r.forwardRef((e,o)=>{let{__scopePopover:a,...s}=e,n=y(P,a),l=C(a),{onCustomAnchorAdd:i,onCustomAnchorRemove:c}=n;return r.useEffect(()=>(i(),()=>c()),[i,c]),(0,t.jsx)(d.Anchor,{...l,...s,ref:o})});R.displayName=P;var S="PopoverTrigger",k=r.forwardRef((e,r)=>{let{__scopePopover:s,...n}=e,l=y(S,s),i=C(s),c=(0,a.useComposedRefs)(r,l.triggerRef),p=(0,t.jsx)(h.Primitive.button,{type:"button","aria-haspopup":"dialog","aria-expanded":l.open,"aria-controls":l.contentId,"data-state":z(l.open),...n,ref:c,onClick:(0,o.composeEventHandlers)(e.onClick,l.onOpenToggle)});return l.hasCustomAnchor?p:(0,t.jsx)(d.Anchor,{asChild:!0,...i,children:p})});k.displayName=S;var A="PopoverPortal",[E,D]=g(A,{forceMount:void 0}),O=e=>{let{__scopePopover:r,forceMount:o,children:a,container:s}=e,n=y(A,r);return(0,t.jsx)(E,{scope:r,forceMount:o,children:(0,t.jsx)(u.Presence,{present:o||n.open,children:(0,t.jsx)(p.Portal,{asChild:!0,container:s,children:a})})})};O.displayName=A;var F="PopoverContent",L=r.forwardRef((e,r)=>{let o=D(F,e.__scopePopover),{forceMount:a=o.forceMount,...s}=e,n=y(F,e.__scopePopover);return(0,t.jsx)(u.Presence,{present:a||n.open,children:n.modal?(0,t.jsx)(B,{...s,ref:r}):(0,t.jsx)(I,{...s,ref:r})})});L.displayName=F;var T=(0,f.createSlot)("PopoverContent.RemoveScroll"),B=r.forwardRef((e,s)=>{let n=y(F,e.__scopePopover),l=r.useRef(null),i=(0,a.useComposedRefs)(s,l),c=r.useRef(!1);return r.useEffect(()=>{let e=l.current;if(e)return(0,x.hideOthers)(e)},[]),(0,t.jsx)(v.RemoveScroll,{as:T,allowPinchZoom:!0,children:(0,t.jsx)(U,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:(0,o.composeEventHandlers)(e.onCloseAutoFocus,e=>{e.preventDefault(),c.current||n.triggerRef.current?.focus()}),onPointerDownOutside:(0,o.composeEventHandlers)(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,r=0===t.button&&!0===t.ctrlKey;c.current=2===t.button||r},{checkForDefaultPrevented:!1}),onFocusOutside:(0,o.composeEventHandlers)(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),I=r.forwardRef((e,o)=>{let a=y(F,e.__scopePopover),s=r.useRef(!1),n=r.useRef(!1);return(0,t.jsx)(U,{...e,ref:o,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(s.current||a.triggerRef.current?.focus(),t.preventDefault()),s.current=!1,n.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(s.current=!0,"pointerdown"===t.detail.originalEvent.type&&(n.current=!0));let r=t.target;a.triggerRef.current?.contains(r)&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&n.current&&t.preventDefault()}})}),U=r.forwardRef((e,r)=>{let{__scopePopover:o,trapFocus:a,onOpenAutoFocus:s,onCloseAutoFocus:c,disableOutsidePointerEvents:p,onEscapeKeyDown:u,onPointerDownOutside:h,onFocusOutside:f,onInteractOutside:m,...x}=e,v=y(F,o),b=C(o);return(0,l.useFocusGuards)(),(0,t.jsx)(i.FocusScope,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:s,onUnmountAutoFocus:c,children:(0,t.jsx)(n.DismissableLayer,{asChild:!0,disableOutsidePointerEvents:p,onInteractOutside:m,onEscapeKeyDown:u,onPointerDownOutside:h,onFocusOutside:f,onDismiss:()=>v.onOpenChange(!1),children:(0,t.jsx)(d.Content,{"data-state":z(v.open),role:"dialog",id:v.contentId,...b,...x,ref:r,style:{...x.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),_="PopoverClose",H=r.forwardRef((e,r)=>{let{__scopePopover:a,...s}=e,n=y(_,a);return(0,t.jsx)(h.Primitive.button,{type:"button",...s,ref:r,onClick:(0,o.composeEventHandlers)(e.onClick,()=>n.onOpenChange(!1))})});H.displayName=_;var M=r.forwardRef((e,r)=>{let{__scopePopover:o,...a}=e,s=C(o);return(0,t.jsx)(d.Arrow,{...s,...a,ref:r})});function z(e){return e?"open":"closed"}M.displayName="PopoverArrow",e.s(["Anchor",()=>R,"Arrow",()=>M,"Close",()=>H,"Content",()=>L,"Popover",()=>N,"PopoverAnchor",()=>R,"PopoverArrow",()=>M,"PopoverClose",()=>H,"PopoverContent",()=>L,"PopoverPortal",()=>O,"PopoverTrigger",()=>k,"Portal",()=>O,"Root",()=>N,"Trigger",()=>k,"createPopoverScope",()=>j],89920);var G=e.i(89920),G=G,K=e.i(31777);let $=G.Root,W=G.Trigger;G.Anchor;let Z=r.forwardRef(({className:e,align:r="center",sideOffset:o=4,...a},s)=>(0,t.jsx)(G.Portal,{children:(0,t.jsx)(G.Content,{ref:s,align:r,sideOffset:o,className:(0,K.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 rounded-md border p-4 shadow-md outline-none",e),...a})}));Z.displayName=G.Content.displayName,e.s(["Popover",()=>$,"PopoverContent",()=>Z,"PopoverTrigger",()=>W],90382)},83843,e=>{"use strict";let t=(0,e.i(3645).default)("chevrons-up-down",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);e.s(["ChevronsUpDown",()=>t],83843)},36479,e=>{"use strict";var t=e.i(20314),r=e.i(79054),o=e.i(31406),a=e.i(60112),s=e.i(21023);let n=(0,s.createServerReference)("4034a250a77092dedd3f748400367f742d1744aee6",s.callServer,void 0,s.findSourceMapURL,"adoptBranch"),l=(0,s.createServerReference)("40abfb91b8c22c734078682e381e7dee34351c57ed",s.callServer,void 0,s.findSourceMapURL,"listBranches");var i=e.i(23925),c=e.i(97667),d=e.i(83843),p=e.i(49228),u=e.i(83428);e.i(1650);var h=e.i(11495),f=e.i(45811),m=e.i(35364),x=e.i(98127),v=e.i(41957),b=e.i(66459),g=e.i(31777);let j=r.forwardRef(({className:e,...r},o)=>(0,t.jsx)("div",{ref:o,className:(0,g.cn)("bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",e),...r}));j.displayName="Command";let C=r.forwardRef(({className:e,...r},o)=>(0,t.jsxs)("div",{className:"flex items-center border-b px-3",children:[(0,t.jsx)(b.Search,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),(0,t.jsx)("input",{ref:o,className:(0,g.cn)("placeholder:text-muted-foreground flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-none disabled:cursor-not-allowed disabled:opacity-50",e),...r})]}));C.displayName="CommandInput";let w=r.forwardRef(({className:e,...r},o)=>(0,t.jsx)("div",{ref:o,className:(0,g.cn)("max-h-[300px] overflow-x-hidden overflow-y-auto",e),...r}));w.displayName="CommandList";let y=r.forwardRef(({className:e,...r},o)=>(0,t.jsx)("div",{ref:o,className:(0,g.cn)("text-muted-foreground py-6 text-center text-sm",e),...r}));y.displayName="CommandEmpty";let N=r.forwardRef(({className:e,...r},o)=>(0,t.jsx)("div",{ref:o,className:(0,g.cn)("text-foreground overflow-hidden p-1",e),...r}));N.displayName="CommandGroup";let P=r.forwardRef(({className:e,selected:r,...o},a)=>(0,t.jsx)("button",{ref:a,type:"button","data-selected":r,className:(0,g.cn)("relative flex w-full cursor-default items-center rounded-sm px-2 py-1.5 text-sm transition-colors outline-none select-none","hover:bg-accent hover:text-accent-foreground","data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground","disabled:pointer-events-none disabled:opacity-50",e),...o}));P.displayName="CommandItem",r.forwardRef(({className:e,...r},o)=>(0,t.jsx)("div",{ref:o,className:(0,g.cn)("bg-border -mx-1 h-px",e),...r})).displayName="CommandSeparator";var R=e.i(90382);function S({open:e,onClose:o,onSubmit:a,isSubmitting:s=!1,error:n,repositories:l=[],selectedRepositoryPath:b,onRepositoryChange:S,branches:k=[],branchesLoading:A=!1}){let[E,D]=(0,r.useState)(""),[O,F]=(0,r.useState)(!1),[L,T]=(0,r.useState)(""),B=(0,r.useRef)(null),[I,U]=(0,r.useState)(!1),[_,H]=(0,r.useState)(""),M=(0,r.useRef)(null),z=l.find(e=>e.path===b),G=!!b;(0,r.useEffect)(()=>{e||(D(""),T(""),F(!1),U(!1),H(""))},[e]),(0,r.useEffect)(()=>{D(""),T("")},[b]);let K=(0,r.useCallback)(e=>{e.preventDefault();let t=E.trim();t&&b&&!s&&a(t,b)},[E,b,s,a]),$=(0,r.useCallback)(()=>{D(""),T(""),o()},[o]),W=(0,r.useCallback)(e=>{D(e),T(e),F(!1)},[]),Z=(0,r.useCallback)(e=>{T(e.target.value),O||F(!0)},[O]),q=(0,r.useCallback)(e=>{if("Enter"===e.key){e.preventDefault();let t=L.trim();t&&(D(t),F(!1))}"Escape"===e.key&&(F(!1),T(E))},[L,E]),J=(0,r.useCallback)(e=>{S?.(e),U(!1),H("")},[S]),Q=k.filter(e=>e.toLowerCase().includes(L.toLowerCase())),V=_.trim()?l.filter(e=>e.name.toLowerCase().includes(_.toLowerCase())||e.path.toLowerCase().includes(_.toLowerCase())):l;(0,r.useEffect)(()=>{I?setTimeout(()=>M.current?.focus(),0):H("")},[I]);let X=!E.trim()||!b||s,Y=(0,t.jsxs)("div",{children:[(0,t.jsxs)(f.DrawerTitle,{className:"flex items-center gap-2",children:[(0,t.jsx)(p.GitBranch,{className:"h-4 w-4"}),"Adopt Branch"]}),(0,t.jsx)(f.DrawerDescription,{className:"text-muted-foreground text-sm",children:"Import an existing git branch into Shep's feature tracking"})]});return(0,t.jsx)(h.BaseDrawer,{open:e,onClose:$,size:"sm",modal:!1,header:Y,"data-testid":"adopt-branch-drawer",children:(0,t.jsxs)("form",{onSubmit:K,className:"flex flex-1 flex-col",children:[(0,t.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(v.Label,{children:"Repository"}),(0,t.jsxs)(R.Popover,{open:I,onOpenChange:U,children:[(0,t.jsx)(R.PopoverTrigger,{asChild:!0,children:(0,t.jsxs)("button",{type:"button",role:"combobox","aria-expanded":I,"aria-label":"Repository",disabled:s,"data-testid":"adopt-repo-combobox",className:(0,g.cn)("border-input bg-background ring-offset-background focus:ring-ring flex h-9 w-full items-center justify-between rounded-md border px-3 py-2 text-sm focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50",!z&&"text-muted-foreground"),children:[(0,t.jsx)("span",{className:"truncate",children:z?z.name:"Select repository..."}),(0,t.jsx)(d.ChevronsUpDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),(0,t.jsx)(R.PopoverContent,{className:"w-80 p-0",align:"start","data-testid":"adopt-repo-combobox-content",children:(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("div",{className:"border-b p-2",children:(0,t.jsx)(x.Input,{ref:M,placeholder:"Search repositories...",value:_,onChange:e=>H(e.target.value),className:"h-8 border-0 p-0 text-sm shadow-none focus-visible:ring-0","data-testid":"adopt-repo-search"})}),(0,t.jsx)("div",{className:"max-h-48 overflow-y-auto py-1",role:"listbox","aria-label":"Repositories",children:0===V.length?(0,t.jsx)("p",{className:"text-muted-foreground px-3 py-2 text-sm",children:"No repositories found."}):V.map(e=>(0,t.jsxs)("button",{type:"button",role:"option","aria-selected":b===e.path,onClick:()=>J(e.path),className:(0,g.cn)("hover:bg-accent hover:text-accent-foreground flex w-full items-center gap-2 px-3 py-2 text-sm",b===e.path&&"bg-accent/50"),"data-testid":`adopt-repo-option-${e.id}`,children:[(0,t.jsx)(c.CheckIcon,{className:(0,g.cn)("h-4 w-4 shrink-0",b!==e.path&&"invisible")}),(0,t.jsxs)("span",{className:"flex flex-col items-start truncate",children:[(0,t.jsx)("span",{className:"truncate",children:e.name}),(0,t.jsx)("span",{className:"text-muted-foreground truncate text-xs",children:e.path})]})]},e.id))})]})})]}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:"Select the repository that contains the branch you want to adopt."})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(v.Label,{htmlFor:"branch-name",children:"Branch name"}),(0,t.jsxs)(R.Popover,{open:O,onOpenChange:F,children:[(0,t.jsx)(R.PopoverTrigger,{asChild:!0,children:(0,t.jsxs)(m.Button,{variant:"outline",role:"combobox","aria-expanded":O,disabled:s||!G,className:"w-full justify-between font-normal","data-testid":"adopt-branch-input",children:[(0,t.jsx)("span",{className:"truncate",children:G?A?"Loading branches...":E||"Select a branch...":"Select a repository first..."}),(0,t.jsx)(d.ChevronsUpDown,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),(0,t.jsx)(R.PopoverContent,{className:"w-[var(--radix-popover-trigger-width)] p-0",align:"start",children:(0,t.jsxs)(j,{children:[(0,t.jsx)(C,{ref:B,placeholder:"Search branches...",value:L,onChange:Z,onKeyDown:q,"data-testid":"adopt-branch-search"}),(0,t.jsxs)(w,{children:[!A&&0===Q.length&&(0,t.jsx)(y,{children:0===k.length?"No branches found.":L?"No match — press Enter to use this value.":"No branches available."}),A?(0,t.jsx)(y,{children:(0,t.jsx)(u.Loader2,{className:"mx-auto h-4 w-4 animate-spin"})}):null,Q.length>0&&(0,t.jsx)(N,{children:Q.map(e=>(0,t.jsxs)(P,{selected:e===E,onClick:()=>W(e),children:[(0,t.jsx)(i.Check,{className:(0,g.cn)("mr-2 h-4 w-4",e===E?"opacity-100":"opacity-0")}),(0,t.jsx)(p.GitBranch,{className:"mr-2 h-3 w-3 opacity-50"}),e]},e))})]})]})})]}),(0,t.jsx)("p",{className:"text-muted-foreground text-xs",children:G?"Select a branch from the dropdown or type to search. Local and remote branches are shown.":"Please select a repository above to see available branches."})]}),n?(0,t.jsx)("p",{className:"text-destructive text-sm","data-testid":"adopt-branch-error",children:n}):null]})}),(0,t.jsx)("div",{className:"border-t p-4",children:(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(m.Button,{type:"button",variant:"outline",onClick:$,disabled:s,className:"flex-1",children:"Cancel"}),(0,t.jsx)(m.Button,{type:"submit",disabled:X,className:"flex-1","data-testid":"adopt-branch-submit",children:s?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(u.Loader2,{className:"mr-2 h-4 w-4 animate-spin"}),"Adopting..."]}):"Adopt Branch"})]})})]})})}function k({repositoryPath:e,repositories:s}){let i=(0,o.useRouter)(),c=(0,o.usePathname)(),[d,p]=(0,r.useState)(!1),[u,h]=(0,r.useState)(),[f,m]=(0,r.useState)([]),[x,v]=(0,r.useState)(!1),[b,g]=(0,r.useState)(e),j=c.startsWith("/adopt"),C=!d&&j;(0,r.useEffect)(()=>{!j&&d&&p(!1)},[j,d]),(0,r.useEffect)(()=>{j&&(h(void 0),g(e))},[j,e]),(0,r.useEffect)(()=>{j&&b?(v(!0),m([]),l(b).then(m).catch(()=>m([])).finally(()=>v(!1))):m([])},[j,b]);let w=(0,r.useCallback)(()=>{i.push("/")},[i]),y=(0,r.useCallback)(e=>{g(e)},[]),N=(0,r.useCallback)((e,t)=>{h(void 0),p(!0),i.push("/"),n({branchName:e,repositoryPath:t}).then(e=>{e.error?a.toast.error(e.error):(window.dispatchEvent(new CustomEvent("shep:feature-created",{detail:{featureId:e.feature.id,name:e.feature.name,description:e.feature.description,repositoryPath:e.feature.repositoryPath}})),a.toast.success(`Branch adopted as "${e.feature.name}"`))}).catch(()=>{a.toast.error("Failed to adopt branch"),p(!1)})},[i]);return(0,t.jsx)(S,{open:C,onClose:w,onSubmit:N,isSubmitting:d,error:u,repositories:s,selectedRepositoryPath:b,onRepositoryChange:y,branches:f,branchesLoading:x})}e.s(["AdoptDrawerClient",()=>k],36479)}]);