@decocms/mesh 2.13.0 → 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/dist/client/assets/{AlertCircle-CtP28Oyz.js → AlertCircle-DeHvJZzp.js} +1 -1
  2. package/dist/client/assets/{ArrowLeft-Bps-R0_t.js → ArrowLeft-Dan_IIKP.js} +1 -1
  3. package/dist/client/assets/ArrowUp-B2eKsIZo.js +1 -0
  4. package/dist/client/assets/{Check-Bkw0Gz-n.js → Check-VfxUlV5P.js} +1 -1
  5. package/dist/client/assets/{ChevronDown-mvTJP4-S.js → ChevronDown-OK90XtVB.js} +1 -1
  6. package/dist/client/assets/{Clock-DiHiAbv6.js → Clock-CRgmR_1n.js} +1 -1
  7. package/dist/client/assets/{Code01-CTUZx8UP.js → Code01-B9DNMb5j.js} +1 -1
  8. package/dist/client/assets/{Copy01-BctGx-5E.js → Copy01-dbjgqDL6.js} +1 -1
  9. package/dist/client/assets/{DotsHorizontal-MMZ1EZhB.js → DotsHorizontal-BpvBcoMa.js} +1 -1
  10. package/dist/client/assets/{DotsVertical-CzCtj25W.js → DotsVertical-XnGZcIeo.js} +1 -1
  11. package/dist/client/assets/Download01-C8jw9jFZ.js +1 -0
  12. package/dist/client/assets/{Edit01-BD5iJRQz.js → Edit01-Ddbn6DsS.js} +1 -1
  13. package/dist/client/assets/{File06-nV81V8TD.js → File06-DCHrHfbn.js} +1 -1
  14. package/dist/client/assets/FilterLines-BzWlfPby.js +1 -0
  15. package/dist/client/assets/{FlipBackward-CpWoOBPz.js → FlipBackward-Bum_Ktlp.js} +1 -1
  16. package/dist/client/assets/{GitBranch01-DWYSSAGj.js → GitBranch01-CVAiK8ZD.js} +1 -1
  17. package/dist/client/assets/Grid01-AMlhaaWH.js +1 -0
  18. package/dist/client/assets/Home02-CnvrJTir.js +1 -0
  19. package/dist/client/assets/Image01-Bch9iOev.js +1 -0
  20. package/dist/client/assets/{Inbox01-DkMyh-FB.js → Inbox01-y9RgqkXP.js} +1 -1
  21. package/dist/client/assets/{InfoCircle-BXctEVkS.js → InfoCircle-HrYndWCZ.js} +1 -1
  22. package/dist/client/assets/{Key01-ChIWeKNh.js → Key01-DS2WWoiQ.js} +1 -1
  23. package/dist/client/assets/{LinkExternal01-By7zx70s.js → LinkExternal01-DzBB4jwo.js} +1 -1
  24. package/dist/client/assets/List-BDW462gC.js +1 -0
  25. package/dist/client/assets/{Loading01-CdaWSExX.js → Loading01-OB_JRXd5.js} +1 -1
  26. package/dist/client/assets/{Lock01-txD_UwBx.js → Lock01-B_KYH87b.js} +1 -1
  27. package/dist/client/assets/{Play-CjVz5-Yt.js → Play-VfPQ9yON.js} +1 -1
  28. package/dist/client/assets/{Plus-CovnOzP9.js → Plus-CgcZFggs.js} +1 -1
  29. package/dist/client/assets/{SearchMd-YxKkBPG0.js → SearchMd-DRJ07Awx.js} +1 -1
  30. package/dist/client/assets/{Terminal-DYwA22tz.js → Terminal-FTJQx4pc.js} +1 -1
  31. package/dist/client/assets/{Trash01-DopdNXEu.js → Trash01-BDWyzvD2.js} +1 -1
  32. package/dist/client/assets/Upload01-CB1SFmVO.js +1 -0
  33. package/dist/client/assets/{X-DcqsnRSe.js → X-CVhiWYv-.js} +1 -1
  34. package/dist/client/assets/{XClose-D0utLGU3.js → XClose-C895iFVX.js} +1 -1
  35. package/dist/client/assets/{alert-dialog-B2ogXLEp.js → alert-dialog-D9k51qgG.js} +2 -2
  36. package/dist/client/assets/{auth-catchall-BG5YjEP_.js → auth-catchall-BDKZr3VK.js} +1 -1
  37. package/dist/client/assets/avatar-BLmwViC3.js +1 -0
  38. package/dist/client/assets/badge-CMZTNGZo.js +1 -0
  39. package/dist/client/assets/binder-Bcr51BHa.js +1 -0
  40. package/dist/client/assets/button-2azNqzUx.js +1 -0
  41. package/dist/client/assets/card-WAuUk8Uz.js +1 -0
  42. package/dist/client/assets/checkbox-E6g3eWVz.js +1 -0
  43. package/dist/client/assets/{collection-detail-BJvqsPlx.js → collection-detail-DiFfTEhG.js} +2 -2
  44. package/dist/client/assets/collection-display-button-B3beugJ4.js +1 -0
  45. package/dist/client/assets/collection-header-MCgfYSgE.js +1 -0
  46. package/dist/client/assets/{collection-page-C8c74lBQ.js → collection-page-CB_Az4GO.js} +1 -1
  47. package/dist/client/assets/collection-search-DL-7oL5d.js +1 -0
  48. package/dist/client/assets/collection-tab-C_pl92IS.js +1 -0
  49. package/dist/client/assets/collection-table-wrapper-CAH6fKB1.js +1 -0
  50. package/dist/client/assets/connection-CXC8d3Ae.js +2 -0
  51. package/dist/client/assets/connection-card-BTOP5EHD.js +1 -0
  52. package/dist/client/assets/connection-detail-BHduC6at.js +1 -0
  53. package/dist/client/assets/connections-Cm-7oBJu.js +1 -0
  54. package/dist/client/assets/constants-B-ATh8ff.js +1 -0
  55. package/dist/client/assets/create-organization-dialog-MS4oQ7Sl.js +1 -0
  56. package/dist/client/assets/dialog-DSU0GEtE.js +1 -0
  57. package/dist/client/assets/dropdown-menu-DRkETp4T.js +1 -0
  58. package/dist/client/assets/dynamic-plugin-layout-CXggkl7m.js +1 -0
  59. package/dist/client/assets/empty-state-C3NzxCFI.js +1 -0
  60. package/dist/client/assets/empty-state-DKa1iDdq.js +1 -0
  61. package/dist/client/assets/env-vars-editor-D54i65KN.js +1 -0
  62. package/dist/client/assets/error-boundary-DU6_J5et.js +1 -0
  63. package/dist/client/assets/{extract-connection-data-DMhfaAiL.js → extract-connection-data-Hjw19oaR.js} +1 -1
  64. package/dist/client/assets/file-browser-B8xb3wGm.js +2 -0
  65. package/dist/client/assets/form-DM9msJYn.js +1 -0
  66. package/dist/client/assets/gateway-detail-6QzPV4MT.js +1 -0
  67. package/dist/client/assets/gateways-DcbIYmOg.js +1 -0
  68. package/dist/client/assets/grid-view-DjeV3XAc.js +1 -0
  69. package/dist/client/assets/home-BkFYrMbJ.js +1 -0
  70. package/dist/client/assets/{index-Cw3bkeXO.js → index-BQiKVu3k.js} +1 -1
  71. package/dist/client/assets/{index-BuPukvJG.js → index-C5xxIZ3a.js} +17 -17
  72. package/dist/client/assets/{index-o28bnKR9.js → index-CYR9-1-4.js} +1 -1
  73. package/dist/client/assets/{index-K2EwRRk6.js → index-DUfEAj2z.js} +2 -2
  74. package/dist/client/assets/index-Dk3lubBQ.js +174 -0
  75. package/dist/client/assets/index-fFpUC2Bx.css +1 -0
  76. package/dist/client/assets/infiniteQueryObserver-CUXkVkPG.js +1 -0
  77. package/dist/client/assets/input-CBrhxHNe.js +1 -0
  78. package/dist/client/assets/layout-MOaKucBL.js +1 -0
  79. package/dist/client/assets/{lazy-highlighter-C5pGkBnk.js → lazy-highlighter-C2ClCxhY.js} +1 -1
  80. package/dist/client/assets/localstorage-keys-BJk6gyyN.js +1 -0
  81. package/dist/client/assets/login-RFCnTbJl.js +1 -0
  82. package/dist/client/assets/mcp-oauth-CuMRVoyP.js +1 -0
  83. package/dist/client/assets/mcp-server-card-DYesFUUw.js +1 -0
  84. package/dist/client/assets/mcp-server-detail-CBjpnL21.js +1 -0
  85. package/dist/client/assets/members-wdr88rOm.js +3 -0
  86. package/dist/client/assets/{monaco-editor-BmVBfnK5.js → monaco-editor-B2ZJ-0S4.js} +3 -3
  87. package/dist/client/assets/{monitoring-7ik3wQUY.js → monitoring-Cr82twHN.js} +10 -10
  88. package/dist/client/assets/oauth-callback-BddKzzFQ.js +1 -0
  89. package/dist/client/assets/page-D_NhUEfH.js +1 -0
  90. package/dist/client/assets/{page-yu9K5Vtj.js → page-DhI0Qooi.js} +2 -2
  91. package/dist/client/assets/pin-to-sidebar-button-CVN6Bdsp.js +1 -0
  92. package/dist/client/assets/plugin-empty-state-srmGKRQU.js +1 -0
  93. package/dist/client/assets/plugin-header-Dg9-cQAj.js +1 -0
  94. package/dist/client/assets/plugins-Dawnh_sQ.js +1 -0
  95. package/dist/client/assets/popover-HE15ABOl.js +1 -0
  96. package/dist/client/assets/project-context-provider-B1gr9e2f.js +1 -0
  97. package/dist/client/assets/{registry-utils-BIzwINzW.js → registry-utils-COqteFH4.js} +1 -1
  98. package/dist/client/assets/resizable-B8j7Xubf.js +1 -0
  99. package/dist/client/assets/resource-tabs-B1oXSRkv.js +1 -0
  100. package/dist/client/assets/select-DkAjMxeq.js +1 -0
  101. package/dist/client/assets/settings-Clme5cH0.js +1 -0
  102. package/dist/client/assets/shell-layout-BuirxVot.js +3 -0
  103. package/dist/client/assets/spinner-Dwr2EFZD.js +1 -0
  104. package/dist/client/assets/switch-C9XtHYD0.js +1 -0
  105. package/dist/client/assets/textarea-CyM57U4B.js +1 -0
  106. package/dist/client/assets/{thread-history-popover-BKo2wskT.js → thread-history-popover-DlGwptvV.js} +4 -4
  107. package/dist/client/assets/tool-set-selector-B9-4X5pd.js +1 -0
  108. package/dist/client/assets/tools-list-DJqzZm19.js +1 -0
  109. package/dist/client/assets/tooltip-DHS6wGWv.js +1 -0
  110. package/dist/client/assets/use-binding-Cn24Ren1.js +23 -0
  111. package/dist/client/assets/use-collections-CbsNEj5T.js +1 -0
  112. package/dist/client/assets/use-connection-BhdfednN.js +1 -0
  113. package/dist/client/assets/{use-connection-resources-C8cAy7Nl.js → use-connection-resources-D6kK3b1i.js} +1 -1
  114. package/dist/client/assets/{use-create-gateway-D8vNiD2K.js → use-create-gateway-dtd5LmVR.js} +1 -1
  115. package/dist/client/assets/use-gateway-Ck94EUZ3.js +1 -0
  116. package/dist/client/assets/{use-gateway-system-prompt-uetw6YB3.js → use-gateway-system-prompt-C9-1moLN.js} +1 -1
  117. package/dist/client/assets/{use-list-state-CAv4RNZg.js → use-list-state-CQtVDn-T.js} +1 -1
  118. package/dist/client/assets/use-mcp-C1X3fEnH.js +1 -0
  119. package/dist/client/assets/{use-members-9nvpFN_1.js → use-members-Bh37cZiw.js} +1 -1
  120. package/dist/client/assets/{use-mobile-sd5ko6M_.js → use-mobile-CuBmA9jm.js} +1 -1
  121. package/dist/client/assets/use-organization-settings-BNK4p5TK.js +1 -0
  122. package/dist/client/assets/{use-tool-call-BLplGau6.js → use-tool-call-DzBMga46.js} +1 -1
  123. package/dist/client/assets/useInfiniteQuery-B7UO0aOm.js +1 -0
  124. package/dist/client/assets/useMutation-BEX5R6ly.js +1 -0
  125. package/dist/client/assets/useQuery-BbeI5BfO.js +1 -0
  126. package/dist/client/assets/value-UH6V0tmj.js +1 -0
  127. package/dist/client/assets/view-mode-toggle-kdDPGpPT.js +1 -0
  128. package/dist/client/assets/workflow-DgZwuETF.js +1 -0
  129. package/dist/client/index.html +2 -2
  130. package/dist/server/cli.js +193 -193
  131. package/dist/server/migrate.js +128 -128
  132. package/dist/server/server.js +191 -191
  133. package/package.json +4 -4
  134. package/dist/client/assets/FilterLines-CBfbdjv3.js +0 -1
  135. package/dist/client/assets/Grid01-BEpepbVy.js +0 -1
  136. package/dist/client/assets/auth-CNkA6dk2.js +0 -1
  137. package/dist/client/assets/avatar-KT16fAYd.js +0 -1
  138. package/dist/client/assets/badge-8BCP2QJ_.js +0 -1
  139. package/dist/client/assets/card-XgDm8_H9.js +0 -1
  140. package/dist/client/assets/checkbox-B9Ss6ffk.js +0 -1
  141. package/dist/client/assets/collection-display-button-DroTLKfu.js +0 -1
  142. package/dist/client/assets/collection-header-CUphFaJM.js +0 -1
  143. package/dist/client/assets/collection-search-DIEJ7x7R.js +0 -1
  144. package/dist/client/assets/collection-tab-BQr3sv8I.js +0 -1
  145. package/dist/client/assets/collection-table-wrapper-x8zydyA0.js +0 -1
  146. package/dist/client/assets/connection-card-CTMXB5Zh.js +0 -1
  147. package/dist/client/assets/connection-detail-BU82m59Z.js +0 -1
  148. package/dist/client/assets/connections-B-zsqKwM.js +0 -1
  149. package/dist/client/assets/constants-8DEiLmV-.js +0 -1
  150. package/dist/client/assets/create-organization-dialog-CHS4cOdy.js +0 -1
  151. package/dist/client/assets/dialog-D9LHhl79.js +0 -1
  152. package/dist/client/assets/dropdown-menu-DjFWyTtD.js +0 -1
  153. package/dist/client/assets/empty-state-DSGxvcRL.js +0 -1
  154. package/dist/client/assets/empty-state-DgOO5bI1.js +0 -2
  155. package/dist/client/assets/env-vars-editor-mM2KyO-W.js +0 -1
  156. package/dist/client/assets/error-boundary-uBvOVTCE.js +0 -1
  157. package/dist/client/assets/form-orY-xngM.js +0 -1
  158. package/dist/client/assets/gateway-detail-Bnl2H9_J.js +0 -1
  159. package/dist/client/assets/gateways-RS5E135D.js +0 -1
  160. package/dist/client/assets/home-HRdtfNlr.js +0 -1
  161. package/dist/client/assets/index-9MwexYU6.css +0 -1
  162. package/dist/client/assets/index-Bz1LU39D.js +0 -163
  163. package/dist/client/assets/input-CtiQUsvV.js +0 -1
  164. package/dist/client/assets/layout-C8G6tSLB.js +0 -1
  165. package/dist/client/assets/localstorage-keys-5oG1CfEQ.js +0 -1
  166. package/dist/client/assets/login-BvQHpiOu.js +0 -1
  167. package/dist/client/assets/mcp-oauth-BzcB2WNx.js +0 -1
  168. package/dist/client/assets/mcp-server-card-BawKO-ZK.js +0 -1
  169. package/dist/client/assets/mcp-server-detail-CxrhH1J8.js +0 -1
  170. package/dist/client/assets/members-C0iWKqGR.js +0 -3
  171. package/dist/client/assets/oauth-callback-Coasa0XK.js +0 -1
  172. package/dist/client/assets/page-DsAOPS13.js +0 -1
  173. package/dist/client/assets/pin-to-sidebar-button-C-akIZzz.js +0 -1
  174. package/dist/client/assets/popover-QWczrvYc.js +0 -1
  175. package/dist/client/assets/project-context-provider-_aLYBfO9.js +0 -1
  176. package/dist/client/assets/resizable-djk090hC.js +0 -1
  177. package/dist/client/assets/resource-tabs-GXDudjH9.js +0 -1
  178. package/dist/client/assets/select-Bxj6_TSM.js +0 -1
  179. package/dist/client/assets/settings-0nIjjKRi.js +0 -1
  180. package/dist/client/assets/shell-layout-BFIjeoYr.js +0 -3
  181. package/dist/client/assets/spinner-C7HX4n17.js +0 -1
  182. package/dist/client/assets/switch-zovYrKoi.js +0 -1
  183. package/dist/client/assets/textarea-D76YOeHc.js +0 -1
  184. package/dist/client/assets/tool-set-selector-Dfdgsx2h.js +0 -1
  185. package/dist/client/assets/tools-list-C2S7XIkI.js +0 -1
  186. package/dist/client/assets/use-binding-UNVemCFv.js +0 -34
  187. package/dist/client/assets/use-connection-BXdeHsm0.js +0 -1
  188. package/dist/client/assets/use-gateway-BhC1hXIm.js +0 -1
  189. package/dist/client/assets/use-mcp-kCjFuvFP.js +0 -1
  190. package/dist/client/assets/use-organization-settings-DBRSoBd0.js +0 -1
  191. package/dist/client/assets/value-DxHsXzsm.js +0 -1
  192. package/dist/client/assets/view-mode-toggle-CVcyaB_S.js +0 -1
  193. package/dist/client/assets/workflow-BUV3CQv_.js +0 -1
@@ -1,4 +1,4 @@
1
- import{r as z,z as Zi,B as Wi,j as m,c as pe,f as Vt,k as Gi,a as qi,t as Ki}from"./index-Bz1LU39D.js";import{j as Ui,f as Qn,g as Qi,i as Ji,C as le,G as Jn,M as eo,U as ea,k as ta}from"./index-BuPukvJG.js";import{D as na,u as oa,b as ra,a as sa,c as ia,N as aa,d as to,G as tn,T as ca}from"./thread-history-popover-BKo2wskT.js";import{E as fn}from"./error-boundary-uBvOVTCE.js";import{u as tr}from"./use-connection-BXdeHsm0.js";import{u as nr,i as la}from"./use-gateway-BhC1hXIm.js";import{u as ua}from"./use-binding-UNVemCFv.js";import{u as no,L as da}from"./localstorage-keys-5oG1CfEQ.js";import{u as Cn}from"./project-context-provider-_aLYBfO9.js";import{c as or,B as rr}from"./input-CtiQUsvV.js";import{V as fa}from"./view-mode-toggle-CVcyaB_S.js";import{i as ha}from"./GitBranch01-DWYSSAGj.js";import{s as ga}from"./Plus-CovnOzP9.js";import{c as pa,I as sr,n as ma}from"./empty-state-DgOO5bI1.js";import{u as ya}from"./use-tool-call-BLplGau6.js";import{i as He,a as oo,b as xa,c as ro,d as nn,T as on,e as wa}from"./value-DxHsXzsm.js";import"./popover-QWczrvYc.js";import"./Check-Bkw0Gz-n.js";import"./SearchMd-YxKkBPG0.js";import"./use-create-gateway-D8vNiD2K.js";import"./AlertCircle-CtP28Oyz.js";import"./X-DcqsnRSe.js";import"./Grid01-BEpepbVy.js";import"./textarea-D76YOeHc.js";import"./Copy01-BctGx-5E.js";import"./Terminal-DYwA22tz.js";import"./monaco-editor-BmVBfnK5.js";import"./spinner-C7HX4n17.js";import"./alert-dialog-B2ogXLEp.js";import"./select-Bxj6_TSM.js";import"./ChevronDown-mvTJP4-S.js";import"./use-mobile-sd5ko6M_.js";import"./File06-nV81V8TD.js";import"./InfoCircle-BXctEVkS.js";import"./use-gateway-system-prompt-uetw6YB3.js";import"./Edit01-BD5iJRQz.js";import"./well-known-mcp-D13f-8h2.js";import"./generate-id-Dyweu44Y.js";import"./Clock-DiHiAbv6.js";import"./Trash01-DopdNXEu.js";import"./auth-CNkA6dk2.js";const Nn=({size:e=24,color:t="currentColor",...n})=>z.createElement("svg",{viewBox:"0 0 24 24",width:e,height:e,stroke:t,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},z.createElement("path",{d:"m10 15-3.075 3.114c-.43.434-.644.651-.828.666a.5.5 0 0 1-.421-.172c-.12-.14-.12-.446-.12-1.056v-1.56c0-.548-.449-.944-.99-1.024v0a3 3 0 0 1-2.534-2.533C2 12.219 2 11.96 2 11.445V6.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C4.28 2 5.12 2 6.8 2h7.4c1.68 0 2.52 0 3.162.327a3 3 0 0 1 1.311 1.311C19 4.28 19 5.12 19 6.8V11m0 11-2.176-1.513c-.306-.213-.46-.32-.626-.395a2.002 2.002 0 0 0-.462-.145c-.18-.033-.367-.033-.74-.033H13.2c-1.12 0-1.68 0-2.108-.218a2 2 0 0 1-.874-.874C10 18.394 10 17.834 10 16.714V14.2c0-1.12 0-1.68.218-2.108a2 2 0 0 1 .874-.874C11.52 11 12.08 11 13.2 11h5.6c1.12 0 1.68 0 2.108.218a2 2 0 0 1 .874.874C22 12.52 22 13.08 22 14.2v2.714c0 .932 0 1.398-.152 1.766a2 2 0 0 1-1.083 1.082c-.367.152-.833.152-1.765.152V22Z"}));Nn.displayName="MessageChatSquare";function ae(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=ae(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var va={value:()=>{}};function Ot(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new Nt(n)}function Nt(e){this._=e}function _a(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",r=n.indexOf(".");if(r>=0&&(o=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}Nt.prototype=Ot.prototype={constructor:Nt,on:function(e,t){var n=this._,o=_a(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i<s;)if((r=(e=o[i]).type)&&(r=ba(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=o[i]).type)n[r]=so(n[r],e.name,t);else if(t==null)for(r in n)n[r]=so(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Nt(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),o=0,r,i;o<r;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],o=0,r=i.length;o<r;++o)i[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)}};function ba(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function so(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=va,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var hn="http://www.w3.org/1999/xhtml";const io={svg:"http://www.w3.org/2000/svg",xhtml:hn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Bt(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),io.hasOwnProperty(t)?{space:io[t],local:e}:e}function Sa(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===hn&&t.documentElement.namespaceURI===hn?t.createElement(e):t.createElementNS(n,e)}}function Ea(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function ir(e){var t=Bt(e);return(t.local?Ea:Sa)(t)}function Ca(){}function Mn(e){return e==null?Ca:function(){return this.querySelector(e)}}function Na(e){typeof e!="function"&&(e=Mn(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=new Array(s),l,c,u=0;u<s;++u)(l=i[u])&&(c=e.call(l,l.__data__,u,i))&&("__data__"in l&&(c.__data__=l.__data__),a[u]=c);return new ge(o,this._parents)}function Ma(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Ia(){return[]}function ar(e){return e==null?Ia:function(){return this.querySelectorAll(e)}}function ka(e){return function(){return Ma(e.apply(this,arguments))}}function Aa(e){typeof e=="function"?e=ka(e):e=ar(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var s=t[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&(o.push(e.call(l,l.__data__,c,s)),r.push(l));return new ge(o,r)}function cr(e){return function(){return this.matches(e)}}function lr(e){return function(t){return t.matches(e)}}var Pa=Array.prototype.find;function Ta(e){return function(){return Pa.call(this.children,e)}}function Da(){return this.firstElementChild}function $a(e){return this.select(e==null?Da:Ta(typeof e=="function"?e:lr(e)))}var za=Array.prototype.filter;function La(){return Array.from(this.children)}function Ha(e){return function(){return za.call(this.children,e)}}function Ra(e){return this.selectAll(e==null?La:Ha(typeof e=="function"?e:lr(e)))}function ja(e){typeof e!="function"&&(e=cr(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new ge(o,this._parents)}function ur(e){return new Array(e.length)}function Va(){return new ge(this._enter||this._groups.map(ur),this._parents)}function Pt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Pt.prototype={constructor:Pt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Oa(e){return function(){return e}}function Ba(e,t,n,o,r,i){for(var s=0,a,l=t.length,c=i.length;s<c;++s)(a=t[s])?(a.__data__=i[s],o[s]=a):n[s]=new Pt(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function Fa(e,t,n,o,r,i,s){var a,l,c=new Map,u=t.length,f=i.length,d=new Array(u),h;for(a=0;a<u;++a)(l=t[a])&&(d[a]=h=s.call(l,l.__data__,a,t)+"",c.has(h)?r[a]=l:c.set(h,l));for(a=0;a<f;++a)h=s.call(e,i[a],a,i)+"",(l=c.get(h))?(o[a]=l,l.__data__=i[a],c.delete(h)):n[a]=new Pt(e,i[a]);for(a=0;a<u;++a)(l=t[a])&&c.get(d[a])===l&&(r[a]=l)}function Xa(e){return e.__data__}function Ya(e,t){if(!arguments.length)return Array.from(this,Xa);var n=t?Fa:Ba,o=this._parents,r=this._groups;typeof e!="function"&&(e=Oa(e));for(var i=r.length,s=new Array(i),a=new Array(i),l=new Array(i),c=0;c<i;++c){var u=o[c],f=r[c],d=f.length,h=Za(e.call(u,u&&u.__data__,c,o)),g=h.length,v=a[c]=new Array(g),_=s[c]=new Array(g),y=l[c]=new Array(d);n(u,f,v,_,y,h,t);for(var b=0,p=0,w,N;b<g;++b)if(w=v[b]){for(b>=p&&(p=b+1);!(N=_[p])&&++p<g;);w._next=N||null}}return s=new ge(s,o),s._enter=a,s._exit=l,s}function Za(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Wa(){return new ge(this._exit||this._groups.map(ur),this._parents)}function Ga(e,t,n){var o=this.enter(),r=this,i=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?i.remove():n(i),o&&r?o.merge(r).order():r}function qa(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,i=o.length,s=Math.min(r,i),a=new Array(r),l=0;l<s;++l)for(var c=n[l],u=o[l],f=c.length,d=a[l]=new Array(f),h,g=0;g<f;++g)(h=c[g]||u[g])&&(d[g]=h);for(;l<r;++l)a[l]=n[l];return new ge(a,this._parents)}function Ka(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],r=o.length-1,i=o[r],s;--r>=0;)(s=o[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Ua(e){e||(e=Qa);function t(f,d){return f&&d?e(f.__data__,d.__data__):!f-!d}for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var s=n[i],a=s.length,l=r[i]=new Array(a),c,u=0;u<a;++u)(c=s[u])&&(l[u]=c);l.sort(t)}return new ge(r,this._parents).order()}function Qa(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ja(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ec(){return Array.from(this)}function tc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length;r<i;++r){var s=o[r];if(s)return s}return null}function nc(){let e=0;for(const t of this)++e;return e}function oc(){return!this.node()}function rc(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r=t[n],i=0,s=r.length,a;i<s;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function sc(e){return function(){this.removeAttribute(e)}}function ic(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ac(e,t){return function(){this.setAttribute(e,t)}}function cc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function lc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function uc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function dc(e,t){var n=Bt(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?ic:sc:typeof t=="function"?n.local?uc:lc:n.local?cc:ac)(n,t))}function dr(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function fc(e){return function(){this.style.removeProperty(e)}}function hc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function gc(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function pc(e,t,n){return arguments.length>1?this.each((t==null?fc:typeof t=="function"?gc:hc)(e,t,n??"")):We(this.node(),e)}function We(e,t){return e.style.getPropertyValue(t)||dr(e).getComputedStyle(e,null).getPropertyValue(t)}function mc(e){return function(){delete this[e]}}function yc(e,t){return function(){this[e]=t}}function xc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function wc(e,t){return arguments.length>1?this.each((t==null?mc:typeof t=="function"?xc:yc)(e,t)):this.node()[e]}function fr(e){return e.trim().split(/^|\s+/)}function In(e){return e.classList||new hr(e)}function hr(e){this._node=e,this._names=fr(e.getAttribute("class")||"")}hr.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function gr(e,t){for(var n=In(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function pr(e,t){for(var n=In(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function vc(e){return function(){gr(this,e)}}function _c(e){return function(){pr(this,e)}}function bc(e,t){return function(){(t.apply(this,arguments)?gr:pr)(this,e)}}function Sc(e,t){var n=fr(e+"");if(arguments.length<2){for(var o=In(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?bc:t?vc:_c)(n,t))}function Ec(){this.textContent=""}function Cc(e){return function(){this.textContent=e}}function Nc(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Mc(e){return arguments.length?this.each(e==null?Ec:(typeof e=="function"?Nc:Cc)(e)):this.node().textContent}function Ic(){this.innerHTML=""}function kc(e){return function(){this.innerHTML=e}}function Ac(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Pc(e){return arguments.length?this.each(e==null?Ic:(typeof e=="function"?Ac:kc)(e)):this.node().innerHTML}function Tc(){this.nextSibling&&this.parentNode.appendChild(this)}function Dc(){return this.each(Tc)}function $c(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function zc(){return this.each($c)}function Lc(e){var t=typeof e=="function"?e:ir(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Hc(){return null}function Rc(e,t){var n=typeof e=="function"?e:ir(e),o=t==null?Hc:typeof t=="function"?t:Mn(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function jc(){var e=this.parentNode;e&&e.removeChild(this)}function Vc(){return this.each(jc)}function Oc(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Bc(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Fc(e){return this.select(e?Bc:Oc)}function Xc(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Yc(e){return function(t){e.call(this,t,this.__data__)}}function Zc(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function Wc(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,r=t.length,i;n<r;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++o]=i;++o?t.length=o:delete this.__on}}}function Gc(e,t,n){return function(){var o=this.__on,r,i=Yc(t);if(o){for(var s=0,a=o.length;s<a;++s)if((r=o[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=n),r.value=t;return}}this.addEventListener(e.type,i,n),r={type:e.type,name:e.name,value:t,listener:i,options:n},o?o.push(r):this.__on=[r]}}function qc(e,t,n){var o=Zc(e+""),r,i=o.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,u;l<c;++l)for(r=0,u=a[l];r<i;++r)if((s=o[r]).type===u.type&&s.name===u.name)return u.value}return}for(a=t?Gc:Wc,r=0;r<i;++r)this.each(a(o[r],t,n));return this}function mr(e,t,n){var o=dr(e),r=o.CustomEvent;typeof r=="function"?r=new r(t,n):(r=o.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function Kc(e,t){return function(){return mr(this,e,t)}}function Uc(e,t){return function(){return mr(this,e,t.apply(this,arguments))}}function Qc(e,t){return this.each((typeof t=="function"?Uc:Kc)(e,t))}function*Jc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length,s;r<i;++r)(s=o[r])&&(yield s)}var yr=[null];function ge(e,t){this._groups=e,this._parents=t}function ht(){return new ge([[document.documentElement]],yr)}function el(){return this}ge.prototype=ht.prototype={constructor:ge,select:Na,selectAll:Aa,selectChild:$a,selectChildren:Ra,filter:ja,data:Ya,enter:Va,exit:Wa,join:Ga,merge:qa,selection:el,order:Ka,sort:Ua,call:Ja,nodes:ec,node:tc,size:nc,empty:oc,each:rc,attr:dc,style:pc,property:wc,classed:Sc,text:Mc,html:Pc,raise:Dc,lower:zc,append:Lc,insert:Rc,remove:Vc,clone:Fc,datum:Xc,on:qc,dispatch:Qc,[Symbol.iterator]:Jc};function he(e){return typeof e=="string"?new ge([[document.querySelector(e)]],[document.documentElement]):new ge([[e]],yr)}function tl(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ve(e,t){if(e=tl(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const nl={passive:!1},it={capture:!0,passive:!1};function rn(e){e.stopImmediatePropagation()}function Ze(e){e.preventDefault(),e.stopImmediatePropagation()}function xr(e){var t=e.document.documentElement,n=he(e).on("dragstart.drag",Ze,it);"onselectstart"in t?n.on("selectstart.drag",Ze,it):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function wr(e,t){var n=e.document.documentElement,o=he(e).on("dragstart.drag",null);t&&(o.on("click.drag",Ze,it),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const xt=e=>()=>e;function gn(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:a,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}gn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function ol(e){return!e.ctrlKey&&!e.button}function rl(){return this.parentNode}function sl(e,t){return t??{x:e.x,y:e.y}}function il(){return navigator.maxTouchPoints||"ontouchstart"in this}function vr(){var e=ol,t=rl,n=sl,o=il,r={},i=Ot("start","drag","end"),s=0,a,l,c,u,f=0;function d(w){w.on("mousedown.drag",h).filter(o).on("touchstart.drag",_).on("touchmove.drag",y,nl).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(w,N){if(!(u||!e.call(this,w,N))){var S=p(this,t.call(this,w,N),w,N,"mouse");S&&(he(w.view).on("mousemove.drag",g,it).on("mouseup.drag",v,it),xr(w.view),rn(w),c=!1,a=w.clientX,l=w.clientY,S("start",w))}}function g(w){if(Ze(w),!c){var N=w.clientX-a,S=w.clientY-l;c=N*N+S*S>f}r.mouse("drag",w)}function v(w){he(w.view).on("mousemove.drag mouseup.drag",null),wr(w.view,c),Ze(w),r.mouse("end",w)}function _(w,N){if(e.call(this,w,N)){var S=w.changedTouches,E=t.call(this,w,N),T=S.length,P,O;for(P=0;P<T;++P)(O=p(this,E,w,N,S[P].identifier,S[P]))&&(rn(w),O("start",w,S[P]))}}function y(w){var N=w.changedTouches,S=N.length,E,T;for(E=0;E<S;++E)(T=r[N[E].identifier])&&(Ze(w),T("drag",w,N[E]))}function b(w){var N=w.changedTouches,S=N.length,E,T;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),E=0;E<S;++E)(T=r[N[E].identifier])&&(rn(w),T("end",w,N[E]))}function p(w,N,S,E,T,P){var O=i.copy(),k=ve(P||S,N),$,L,x;if((x=n.call(w,new gn("beforestart",{sourceEvent:S,target:d,identifier:T,active:s,x:k[0],y:k[1],dx:0,dy:0,dispatch:O}),E))!=null)return $=x.x-k[0]||0,L=x.y-k[1]||0,function M(C,A,I){var D=k,H;switch(C){case"start":r[T]=M,H=s++;break;case"end":delete r[T],--s;case"drag":k=ve(I||A,N),H=s;break}O.call(C,w,new gn(C,{sourceEvent:A,subject:x,target:d,identifier:T,active:H,x:k[0]+$,y:k[1]+L,dx:k[0]-D[0],dy:k[1]-D[1],dispatch:O}),E)}}return d.filter=function(w){return arguments.length?(e=typeof w=="function"?w:xt(!!w),d):e},d.container=function(w){return arguments.length?(t=typeof w=="function"?w:xt(w),d):t},d.subject=function(w){return arguments.length?(n=typeof w=="function"?w:xt(w),d):n},d.touchable=function(w){return arguments.length?(o=typeof w=="function"?w:xt(!!w),d):o},d.on=function(){var w=i.on.apply(i,arguments);return w===i?d:w},d.clickDistance=function(w){return arguments.length?(f=(w=+w)*w,d):Math.sqrt(f)},d}var ao=180/Math.PI,pn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function _r(e,t,n,o,r,i){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*n+t*o)&&(n-=e*l,o-=t*l),(a=Math.sqrt(n*n+o*o))&&(n/=a,o/=a,l/=a),e*o<t*n&&(e=-e,t=-t,l=-l,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*ao,skewX:Math.atan(l)*ao,scaleX:s,scaleY:a}}var wt;function al(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?pn:_r(t.a,t.b,t.c,t.d,t.e,t.f)}function cl(e){return e==null||(wt||(wt=document.createElementNS("http://www.w3.org/2000/svg","g")),wt.setAttribute("transform",e),!(e=wt.transform.baseVal.consolidate()))?pn:(e=e.matrix,_r(e.a,e.b,e.c,e.d,e.e,e.f))}function br(e,t,n,o){function r(c){return c.length?c.pop()+" ":""}function i(c,u,f,d,h,g){if(c!==f||u!==d){var v=h.push("translate(",null,t,null,n);g.push({i:v-4,x:He(c,f)},{i:v-2,x:He(u,d)})}else(f||d)&&h.push("translate("+f+t+d+n)}function s(c,u,f,d){c!==u?(c-u>180?u+=360:u-c>180&&(c+=360),d.push({i:f.push(r(f)+"rotate(",null,o)-2,x:He(c,u)})):u&&f.push(r(f)+"rotate("+u+o)}function a(c,u,f,d){c!==u?d.push({i:f.push(r(f)+"skewX(",null,o)-2,x:He(c,u)}):u&&f.push(r(f)+"skewX("+u+o)}function l(c,u,f,d,h,g){if(c!==f||u!==d){var v=h.push(r(h)+"scale(",null,",",null,")");g.push({i:v-4,x:He(c,f)},{i:v-2,x:He(u,d)})}else(f!==1||d!==1)&&h.push(r(h)+"scale("+f+","+d+")")}return function(c,u){var f=[],d=[];return c=e(c),u=e(u),i(c.translateX,c.translateY,u.translateX,u.translateY,f,d),s(c.rotate,u.rotate,f,d),a(c.skewX,u.skewX,f,d),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,f,d),c=u=null,function(h){for(var g=-1,v=d.length,_;++g<v;)f[(_=d[g]).i]=_.x(h);return f.join("")}}}var ll=br(al,"px, ","px)","deg)"),ul=br(cl,", ",")",")"),dl=1e-12;function co(e){return((e=Math.exp(e))+1/e)/2}function fl(e){return((e=Math.exp(e))-1/e)/2}function hl(e){return((e=Math.exp(2*e))-1)/(e+1)}const Mt=(function e(t,n,o){function r(i,s){var a=i[0],l=i[1],c=i[2],u=s[0],f=s[1],d=s[2],h=u-a,g=f-l,v=h*h+g*g,_,y;if(v<dl)y=Math.log(d/c)/t,_=function(E){return[a+E*h,l+E*g,c*Math.exp(t*E*y)]};else{var b=Math.sqrt(v),p=(d*d-c*c+o*v)/(2*c*n*b),w=(d*d-c*c-o*v)/(2*d*n*b),N=Math.log(Math.sqrt(p*p+1)-p),S=Math.log(Math.sqrt(w*w+1)-w);y=(S-N)/t,_=function(E){var T=E*y,P=co(N),O=c/(n*b)*(P*hl(t*T+N)-fl(N));return[a+O*h,l+O*g,c*P/co(t*T+N)]}}return _.duration=y*1e3*t/Math.SQRT2,_}return r.rho=function(i){var s=Math.max(.001,+i),a=s*s,l=a*a;return e(s,a,l)},r})(Math.SQRT2,2,4);var Ge=0,nt=0,et=0,Sr=1e3,Tt,ot,Dt=0,Ve=0,Ft=0,at=typeof performance=="object"&&performance.now?performance:Date,Er=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function kn(){return Ve||(Er(gl),Ve=at.now()+Ft)}function gl(){Ve=0}function $t(){this._call=this._time=this._next=null}$t.prototype=Cr.prototype={constructor:$t,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?kn():+n)+(t==null?0:+t),!this._next&&ot!==this&&(ot?ot._next=this:Tt=this,ot=this),this._call=e,this._time=n,mn()},stop:function(){this._call&&(this._call=null,this._time=1/0,mn())}};function Cr(e,t,n){var o=new $t;return o.restart(e,t,n),o}function pl(){kn(),++Ge;for(var e=Tt,t;e;)(t=Ve-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ge}function lo(){Ve=(Dt=at.now())+Ft,Ge=nt=0;try{pl()}finally{Ge=0,yl(),Ve=0}}function ml(){var e=at.now(),t=e-Dt;t>Sr&&(Ft-=t,Dt=e)}function yl(){for(var e,t=Tt,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Tt=n);ot=e,mn(o)}function mn(e){if(!Ge){nt&&(nt=clearTimeout(nt));var t=e-Ve;t>24?(e<1/0&&(nt=setTimeout(lo,e-at.now()-Ft)),et&&(et=clearInterval(et))):(et||(Dt=at.now(),et=setInterval(ml,Sr)),Ge=1,Er(lo))}}function uo(e,t,n){var o=new $t;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var xl=Ot("start","end","cancel","interrupt"),wl=[],Nr=0,fo=1,yn=2,It=3,ho=4,xn=5,kt=6;function Xt(e,t,n,o,r,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;vl(e,n,{name:t,index:o,group:r,on:xl,tween:wl,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Nr})}function An(e,t){var n=Se(e,t);if(n.state>Nr)throw new Error("too late; already scheduled");return n}function Ce(e,t){var n=Se(e,t);if(n.state>It)throw new Error("too late; already running");return n}function Se(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function vl(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=Cr(i,0,n.time);function i(c){n.state=fo,n.timer.restart(s,n.delay,n.time),n.delay<=c&&s(c-n.delay)}function s(c){var u,f,d,h;if(n.state!==fo)return l();for(u in o)if(h=o[u],h.name===n.name){if(h.state===It)return uo(s);h.state===ho?(h.state=kt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete o[u]):+u<t&&(h.state=kt,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete o[u])}if(uo(function(){n.state===It&&(n.state=ho,n.timer.restart(a,n.delay,n.time),a(c))}),n.state=yn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===yn){for(n.state=It,r=new Array(d=n.tween.length),u=0,f=-1;u<d;++u)(h=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(r[++f]=h);r.length=f+1}}function a(c){for(var u=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(l),n.state=xn,1),f=-1,d=r.length;++f<d;)r[f].call(e,u);n.state===xn&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=kt,n.timer.stop(),delete o[t];for(var c in o)return;delete e.__transition}}function At(e,t){var n=e.__transition,o,r,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((o=n[s]).name!==t){i=!1;continue}r=o.state>yn&&o.state<xn,o.state=kt,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[s]}i&&delete e.__transition}}function _l(e){return this.each(function(){At(this,e)})}function bl(e,t){var n,o;return function(){var r=Ce(this,e),i=r.tween;if(i!==n){o=n=i;for(var s=0,a=o.length;s<a;++s)if(o[s].name===t){o=o.slice(),o.splice(s,1);break}}r.tween=o}}function Sl(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var i=Ce(this,e),s=i.tween;if(s!==o){r=(o=s).slice();for(var a={name:t,value:n},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=a;break}l===c&&r.push(a)}i.tween=r}}function El(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=Se(this.node(),n).tween,r=0,i=o.length,s;r<i;++r)if((s=o[r]).name===e)return s.value;return null}return this.each((t==null?bl:Sl)(n,e,t))}function Pn(e,t,n){var o=e._id;return e.each(function(){var r=Ce(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return Se(r,o).value[t]}}function Mr(e,t){var n;return(typeof t=="number"?He:t instanceof ro?oo:(n=ro(t))?(t=n,oo):xa)(e,t)}function Cl(e){return function(){this.removeAttribute(e)}}function Nl(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ml(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===o?i:i=t(o=s,n)}}function Il(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===o?i:i=t(o=s,n)}}function kl(e,t,n){var o,r,i;return function(){var s,a=n(this),l;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),l=a+"",s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a)))}}function Al(e,t,n){var o,r,i;return function(){var s,a=n(this),l;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),l=a+"",s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a)))}}function Pl(e,t){var n=Bt(e),o=n==="transform"?ul:Mr;return this.attrTween(e,typeof t=="function"?(n.local?Al:kl)(n,o,Pn(this,"attr."+e,t)):t==null?(n.local?Nl:Cl)(n):(n.local?Il:Ml)(n,o,t))}function Tl(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Dl(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function $l(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Dl(e,i)),n}return r._value=t,r}function zl(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Tl(e,i)),n}return r._value=t,r}function Ll(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var o=Bt(e);return this.tween(n,(o.local?$l:zl)(o,t))}function Hl(e,t){return function(){An(this,e).delay=+t.apply(this,arguments)}}function Rl(e,t){return t=+t,function(){An(this,e).delay=t}}function jl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Hl:Rl)(t,e)):Se(this.node(),t).delay}function Vl(e,t){return function(){Ce(this,e).duration=+t.apply(this,arguments)}}function Ol(e,t){return t=+t,function(){Ce(this,e).duration=t}}function Bl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Vl:Ol)(t,e)):Se(this.node(),t).duration}function Fl(e,t){if(typeof t!="function")throw new Error;return function(){Ce(this,e).ease=t}}function Xl(e){var t=this._id;return arguments.length?this.each(Fl(t,e)):Se(this.node(),t).ease}function Yl(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ce(this,e).ease=n}}function Zl(e){if(typeof e!="function")throw new Error;return this.each(Yl(this._id,e))}function Wl(e){typeof e!="function"&&(e=cr(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new Ie(o,this._parents,this._name,this._id)}function Gl(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,i=Math.min(o,r),s=new Array(o),a=0;a<i;++a)for(var l=t[a],c=n[a],u=l.length,f=s[a]=new Array(u),d,h=0;h<u;++h)(d=l[h]||c[h])&&(f[h]=d);for(;a<o;++a)s[a]=t[a];return new Ie(s,this._parents,this._name,this._id)}function ql(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Kl(e,t,n){var o,r,i=ql(t)?An:Ce;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}function Ul(e,t){var n=this._id;return arguments.length<2?Se(this.node(),n).on.on(e):this.each(Kl(n,e,t))}function Ql(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Jl(){return this.on("end.remove",Ql(this._id))}function eu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Mn(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s<r;++s)for(var a=o[s],l=a.length,c=i[s]=new Array(l),u,f,d=0;d<l;++d)(u=a[d])&&(f=e.call(u,u.__data__,d,a))&&("__data__"in u&&(f.__data__=u.__data__),c[d]=f,Xt(c[d],t,n,d,c,Se(u,n)));return new Ie(i,this._parents,t,n)}function tu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ar(e));for(var o=this._groups,r=o.length,i=[],s=[],a=0;a<r;++a)for(var l=o[a],c=l.length,u,f=0;f<c;++f)if(u=l[f]){for(var d=e.call(u,u.__data__,f,l),h,g=Se(u,n),v=0,_=d.length;v<_;++v)(h=d[v])&&Xt(h,t,n,v,d,g);i.push(d),s.push(u)}return new Ie(i,s,t,n)}var nu=ht.prototype.constructor;function ou(){return new nu(this._groups,this._parents)}function ru(e,t){var n,o,r;return function(){var i=We(this,e),s=(this.style.removeProperty(e),We(this,e));return i===s?null:i===n&&s===o?r:r=t(n=i,o=s)}}function Ir(e){return function(){this.style.removeProperty(e)}}function su(e,t,n){var o,r=n+"",i;return function(){var s=We(this,e);return s===r?null:s===o?i:i=t(o=s,n)}}function iu(e,t,n){var o,r,i;return function(){var s=We(this,e),a=n(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),We(this,e))),s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a))}}function au(e,t){var n,o,r,i="style."+t,s="end."+i,a;return function(){var l=Ce(this,e),c=l.on,u=l.value[i]==null?a||(a=Ir(t)):void 0;(c!==n||r!==u)&&(o=(n=c).copy()).on(s,r=u),l.on=o}}function cu(e,t,n){var o=(e+="")=="transform"?ll:Mr;return t==null?this.styleTween(e,ru(e,o)).on("end.style."+e,Ir(e)):typeof t=="function"?this.styleTween(e,iu(e,o,Pn(this,"style."+e,t))).each(au(this._id,e)):this.styleTween(e,su(e,o,t),n).on("end.style."+e,null)}function lu(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function uu(e,t,n){var o,r;function i(){var s=t.apply(this,arguments);return s!==r&&(o=(r=s)&&lu(e,s,n)),o}return i._value=t,i}function du(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,uu(e,t,n??""))}function fu(e){return function(){this.textContent=e}}function hu(e){return function(){var t=e(this);this.textContent=t??""}}function gu(e){return this.tween("text",typeof e=="function"?hu(Pn(this,"text",e)):fu(e==null?"":e+""))}function pu(e){return function(t){this.textContent=e.call(this,t)}}function mu(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&pu(r)),t}return o._value=e,o}function yu(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,mu(e))}function xu(){for(var e=this._name,t=this._id,n=kr(),o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,l,c=0;c<a;++c)if(l=s[c]){var u=Se(l,t);Xt(l,e,n,c,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Ie(o,this._parents,e,n)}function wu(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(i,s){var a={value:s},l={value:function(){--r===0&&i()}};n.each(function(){var c=Ce(this,o),u=c.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),c.on=t}),r===0&&i()})}var vu=0;function Ie(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function kr(){return++vu}var Ne=ht.prototype;Ie.prototype={constructor:Ie,select:eu,selectAll:tu,selectChild:Ne.selectChild,selectChildren:Ne.selectChildren,filter:Wl,merge:Gl,selection:ou,transition:xu,call:Ne.call,nodes:Ne.nodes,node:Ne.node,size:Ne.size,empty:Ne.empty,each:Ne.each,on:Ul,attr:Pl,attrTween:Ll,style:cu,styleTween:du,text:gu,textTween:yu,remove:Jl,tween:El,delay:jl,duration:Bl,ease:Xl,easeVarying:Zl,end:wu,[Symbol.iterator]:Ne[Symbol.iterator]};function _u(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var bu={time:null,delay:0,duration:250,ease:_u};function Su(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Eu(e){var t,n;e instanceof Ie?(t=e._id,e=e._name):(t=kr(),(n=bu).time=kn(),e=e==null?null:e+"");for(var o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&Xt(l,e,t,c,s,n||Su(l,t));return new Ie(o,this._parents,e,t)}ht.prototype.interrupt=_l;ht.prototype.transition=Eu;const vt=e=>()=>e;function Cu(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function Me(e,t,n){this.k=e,this.x=t,this.y=n}Me.prototype={constructor:Me,scale:function(e){return e===1?this:new Me(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Me(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Yt=new Me(1,0,0);Ar.prototype=Me.prototype;function Ar(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Yt;return e.__zoom}function sn(e){e.stopImmediatePropagation()}function tt(e){e.preventDefault(),e.stopImmediatePropagation()}function Nu(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Mu(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function go(){return this.__zoom||Yt}function Iu(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function ku(){return navigator.maxTouchPoints||"ontouchstart"in this}function Au(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function Pr(){var e=Nu,t=Mu,n=Au,o=Iu,r=ku,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,l=Mt,c=Ot("start","zoom","end"),u,f,d,h=500,g=150,v=0,_=10;function y(x){x.property("__zoom",go).on("wheel.zoom",T,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",O).filter(r).on("touchstart.zoom",k).on("touchmove.zoom",$).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(x,M,C,A){var I=x.selection?x.selection():x;I.property("__zoom",go),x!==I?N(x,M,C,A):I.interrupt().each(function(){S(this,arguments).event(A).start().zoom(null,typeof M=="function"?M.apply(this,arguments):M).end()})},y.scaleBy=function(x,M,C,A){y.scaleTo(x,function(){var I=this.__zoom.k,D=typeof M=="function"?M.apply(this,arguments):M;return I*D},C,A)},y.scaleTo=function(x,M,C,A){y.transform(x,function(){var I=t.apply(this,arguments),D=this.__zoom,H=C==null?w(I):typeof C=="function"?C.apply(this,arguments):C,V=D.invert(H),R=typeof M=="function"?M.apply(this,arguments):M;return n(p(b(D,R),H,V),I,s)},C,A)},y.translateBy=function(x,M,C,A){y.transform(x,function(){return n(this.__zoom.translate(typeof M=="function"?M.apply(this,arguments):M,typeof C=="function"?C.apply(this,arguments):C),t.apply(this,arguments),s)},null,A)},y.translateTo=function(x,M,C,A,I){y.transform(x,function(){var D=t.apply(this,arguments),H=this.__zoom,V=A==null?w(D):typeof A=="function"?A.apply(this,arguments):A;return n(Yt.translate(V[0],V[1]).scale(H.k).translate(typeof M=="function"?-M.apply(this,arguments):-M,typeof C=="function"?-C.apply(this,arguments):-C),D,s)},A,I)};function b(x,M){return M=Math.max(i[0],Math.min(i[1],M)),M===x.k?x:new Me(M,x.x,x.y)}function p(x,M,C){var A=M[0]-C[0]*x.k,I=M[1]-C[1]*x.k;return A===x.x&&I===x.y?x:new Me(x.k,A,I)}function w(x){return[(+x[0][0]+ +x[1][0])/2,(+x[0][1]+ +x[1][1])/2]}function N(x,M,C,A){x.on("start.zoom",function(){S(this,arguments).event(A).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(A).end()}).tween("zoom",function(){var I=this,D=arguments,H=S(I,D).event(A),V=t.apply(I,D),R=C==null?w(V):typeof C=="function"?C.apply(I,D):C,j=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),F=I.__zoom,W=typeof M=="function"?M.apply(I,D):M,K=l(F.invert(R).concat(j/F.k),W.invert(R).concat(j/W.k));return function(X){if(X===1)X=W;else{var B=K(X),Y=j/B[2];X=new Me(Y,R[0]-B[0]*Y,R[1]-B[1]*Y)}H.zoom(null,X)}})}function S(x,M,C){return!C&&x.__zooming||new E(x,M)}function E(x,M){this.that=x,this.args=M,this.active=0,this.sourceEvent=null,this.extent=t.apply(x,M),this.taps=0}E.prototype={event:function(x){return x&&(this.sourceEvent=x),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(x,M){return this.mouse&&x!=="mouse"&&(this.mouse[1]=M.invert(this.mouse[0])),this.touch0&&x!=="touch"&&(this.touch0[1]=M.invert(this.touch0[0])),this.touch1&&x!=="touch"&&(this.touch1[1]=M.invert(this.touch1[0])),this.that.__zoom=M,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(x){var M=he(this.that).datum();c.call(x,this.that,new Cu(x,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:c}),M)}};function T(x,...M){if(!e.apply(this,arguments))return;var C=S(this,M).event(x),A=this.__zoom,I=Math.max(i[0],Math.min(i[1],A.k*Math.pow(2,o.apply(this,arguments)))),D=ve(x);if(C.wheel)(C.mouse[0][0]!==D[0]||C.mouse[0][1]!==D[1])&&(C.mouse[1]=A.invert(C.mouse[0]=D)),clearTimeout(C.wheel);else{if(A.k===I)return;C.mouse=[D,A.invert(D)],At(this),C.start()}tt(x),C.wheel=setTimeout(H,g),C.zoom("mouse",n(p(b(A,I),C.mouse[0],C.mouse[1]),C.extent,s));function H(){C.wheel=null,C.end()}}function P(x,...M){if(d||!e.apply(this,arguments))return;var C=x.currentTarget,A=S(this,M,!0).event(x),I=he(x.view).on("mousemove.zoom",R,!0).on("mouseup.zoom",j,!0),D=ve(x,C),H=x.clientX,V=x.clientY;xr(x.view),sn(x),A.mouse=[D,this.__zoom.invert(D)],At(this),A.start();function R(F){if(tt(F),!A.moved){var W=F.clientX-H,K=F.clientY-V;A.moved=W*W+K*K>v}A.event(F).zoom("mouse",n(p(A.that.__zoom,A.mouse[0]=ve(F,C),A.mouse[1]),A.extent,s))}function j(F){I.on("mousemove.zoom mouseup.zoom",null),wr(F.view,A.moved),tt(F),A.event(F).end()}}function O(x,...M){if(e.apply(this,arguments)){var C=this.__zoom,A=ve(x.changedTouches?x.changedTouches[0]:x,this),I=C.invert(A),D=C.k*(x.shiftKey?.5:2),H=n(p(b(C,D),A,I),t.apply(this,M),s);tt(x),a>0?he(this).transition().duration(a).call(N,H,A,x):he(this).call(y.transform,H,A,x)}}function k(x,...M){if(e.apply(this,arguments)){var C=x.touches,A=C.length,I=S(this,M,x.changedTouches.length===A).event(x),D,H,V,R;for(sn(x),H=0;H<A;++H)V=C[H],R=ve(V,this),R=[R,this.__zoom.invert(R),V.identifier],I.touch0?!I.touch1&&I.touch0[2]!==R[2]&&(I.touch1=R,I.taps=0):(I.touch0=R,D=!0,I.taps=1+!!u);u&&(u=clearTimeout(u)),D&&(I.taps<2&&(f=R[0],u=setTimeout(function(){u=null},h)),At(this),I.start())}}function $(x,...M){if(this.__zooming){var C=S(this,M).event(x),A=x.changedTouches,I=A.length,D,H,V,R;for(tt(x),D=0;D<I;++D)H=A[D],V=ve(H,this),C.touch0&&C.touch0[2]===H.identifier?C.touch0[0]=V:C.touch1&&C.touch1[2]===H.identifier&&(C.touch1[0]=V);if(H=C.that.__zoom,C.touch1){var j=C.touch0[0],F=C.touch0[1],W=C.touch1[0],K=C.touch1[1],X=(X=W[0]-j[0])*X+(X=W[1]-j[1])*X,B=(B=K[0]-F[0])*B+(B=K[1]-F[1])*B;H=b(H,Math.sqrt(X/B)),V=[(j[0]+W[0])/2,(j[1]+W[1])/2],R=[(F[0]+K[0])/2,(F[1]+K[1])/2]}else if(C.touch0)V=C.touch0[0],R=C.touch0[1];else return;C.zoom("touch",n(p(H,V,R),C.extent,s))}}function L(x,...M){if(this.__zooming){var C=S(this,M).event(x),A=x.changedTouches,I=A.length,D,H;for(sn(x),d&&clearTimeout(d),d=setTimeout(function(){d=null},h),D=0;D<I;++D)H=A[D],C.touch0&&C.touch0[2]===H.identifier?delete C.touch0:C.touch1&&C.touch1[2]===H.identifier&&delete C.touch1;if(C.touch1&&!C.touch0&&(C.touch0=C.touch1,delete C.touch1),C.touch0)C.touch0[1]=this.__zoom.invert(C.touch0[0]);else if(C.end(),C.taps===2&&(H=ve(H,this),Math.hypot(f[0]-H[0],f[1]-H[1])<_)){var V=he(this).on("dblclick.zoom");V&&V.apply(this,arguments)}}}return y.wheelDelta=function(x){return arguments.length?(o=typeof x=="function"?x:vt(+x),y):o},y.filter=function(x){return arguments.length?(e=typeof x=="function"?x:vt(!!x),y):e},y.touchable=function(x){return arguments.length?(r=typeof x=="function"?x:vt(!!x),y):r},y.extent=function(x){return arguments.length?(t=typeof x=="function"?x:vt([[+x[0][0],+x[0][1]],[+x[1][0],+x[1][1]]]),y):t},y.scaleExtent=function(x){return arguments.length?(i[0]=+x[0],i[1]=+x[1],y):[i[0],i[1]]},y.translateExtent=function(x){return arguments.length?(s[0][0]=+x[0][0],s[1][0]=+x[1][0],s[0][1]=+x[0][1],s[1][1]=+x[1][1],y):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},y.constrain=function(x){return arguments.length?(n=x,y):n},y.duration=function(x){return arguments.length?(a=+x,y):a},y.interpolate=function(x){return arguments.length?(l=x,y):l},y.on=function(){var x=c.on.apply(c,arguments);return x===c?y:x},y.clickDistance=function(x){return arguments.length?(v=(x=+x)*x,y):Math.sqrt(v)},y.tapDistance=function(x){return arguments.length?(_=+x,y):_},y}const Ee={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},ct=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Tr=["Enter"," ","Escape"],Dr={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var qe;(function(e){e.Strict="strict",e.Loose="loose"})(qe||(qe={}));var je;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(je||(je={}));var lt;(function(e){e.Partial="partial",e.Full="full"})(lt||(lt={}));const $r={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var De;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(De||(De={}));var zt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(zt||(zt={}));var Z;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Z||(Z={}));const po={[Z.Left]:Z.Right,[Z.Right]:Z.Left,[Z.Top]:Z.Bottom,[Z.Bottom]:Z.Top};function zr(e){return e===null?null:e?"valid":"invalid"}const Lr=e=>"id"in e&&"source"in e&&"target"in e,Pu=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Tn=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),gt=(e,t=[0,0])=>{const{width:n,height:o}=ke(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},Tu=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,r)=>{const i=typeof r=="string";let s=!t.nodeLookup&&!i?r:void 0;t.nodeLookup&&(s=i?t.nodeLookup.get(r):Tn(r)?r:t.nodeLookup.get(r.id));const a=s?Lt(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Zt(o,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Wt(n)},pt=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=Zt(n,Lt(r)),o=!0)}),o?Wt(n):{x:0,y:0,width:0,height:0}},Dn=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const a={...yt(t,[n,o,r]),width:t.width/r,height:t.height/r},l=[];for(const c of e.values()){const{measured:u,selectable:f=!0,hidden:d=!1}=c;if(s&&!f||d)continue;const h=u.width??c.width??c.initialWidth??null,g=u.height??c.height??c.initialHeight??null,v=ut(a,Ue(c)),_=(h??0)*(g??0),y=i&&v>0;(!c.internals.handleBounds||y||v>=_||c.dragging)&&l.push(c)}return l},Du=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function $u(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&(t?.includeHiddenNodes||!r.hidden)&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function zu({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return Promise.resolve(!0);const a=$u(e,s),l=pt(a),c=$n(l,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return await o.setViewport(c,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),Promise.resolve(!0)}function Hr({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:l,y:c}=a?a.internals.positionAbsolute:{x:0,y:0},u=s.origin??o;let f=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)i?.("005",Ee.error005());else{const h=a.measured.width,g=a.measured.height;h&&g&&(f=[[l,c],[l+h,c+g]])}else a&&Qe(s.extent)&&(f=[[s.extent[0][0]+l,s.extent[0][1]+c],[s.extent[1][0]+l,s.extent[1][1]+c]]);const d=Qe(f)?Oe(t,f,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&i?.("015",Ee.error015()),{position:{x:d.x-l+(s.measured.width??0)*u[0],y:d.y-c+(s.measured.height??0)*u[1]},positionAbsolute:d}}async function Lu({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map(d=>d.id)),s=[];for(const d of n){if(d.deletable===!1)continue;const h=i.has(d.id),g=!h&&d.parentId&&s.find(v=>v.id===d.parentId);(h||g)&&s.push(d)}const a=new Set(t.map(d=>d.id)),l=o.filter(d=>d.deletable!==!1),u=Du(s,l);for(const d of l)a.has(d.id)&&!u.find(g=>g.id===d.id)&&u.push(d);if(!r)return{edges:u,nodes:s};const f=await r({nodes:s,edges:u});return typeof f=="boolean"?f?{edges:u,nodes:s}:{edges:[],nodes:[]}:f}const Ke=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Oe=(e={x:0,y:0},t,n)=>({x:Ke(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Ke(e.y,t[0][1],t[1][1]-(n?.height??0))});function Rr(e,t,n){const{width:o,height:r}=ke(n),{x:i,y:s}=n.internals.positionAbsolute;return Oe(e,[[i,s],[i+o,s+r]],t)}const mo=(e,t,n)=>e<t?Ke(Math.abs(e-t),1,t)/t:e>n?-Ke(Math.abs(e-n),1,t)/t:0,jr=(e,t,n=15,o=40)=>{const r=mo(e.x,o,t.width-o)*n,i=mo(e.y,o,t.height-o)*n;return[r,i]},Zt=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),wn=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),Wt=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Ue=(e,t=[0,0])=>{const{x:n,y:o}=Tn(e)?e.internals.positionAbsolute:gt(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Lt=(e,t=[0,0])=>{const{x:n,y:o}=Tn(e)?e.internals.positionAbsolute:gt(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},Vr=(e,t)=>Wt(Zt(wn(e),wn(t))),ut=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},yo=e=>_e(e.width)&&_e(e.height)&&_e(e.x)&&_e(e.y),_e=e=>!isNaN(e)&&isFinite(e),Hu=(e,t)=>{},mt=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),yt=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-o)/r};return i?mt(a,s):a},Ht=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function Fe(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Ru(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Fe(e,n),r=Fe(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=Fe(e.top??e.y??0,n),r=Fe(e.bottom??e.y??0,n),i=Fe(e.left??e.x??0,t),s=Fe(e.right??e.x??0,t);return{top:o,right:s,bottom:r,left:i,x:i+s,y:o+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function ju(e,t,n,o,r,i){const{x:s,y:a}=Ht(e,[t,n,o]),{x:l,y:c}=Ht({x:e.x+e.width,y:e.y+e.height},[t,n,o]),u=r-l,f=i-c;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(u),bottom:Math.floor(f)}}const $n=(e,t,n,o,r,i)=>{const s=Ru(i,t,n),a=(t-s.x)/e.width,l=(n-s.y)/e.height,c=Math.min(a,l),u=Ke(c,o,r),f=e.x+e.width/2,d=e.y+e.height/2,h=t/2-f*u,g=n/2-d*u,v=ju(e,h,g,u,t,n),_={left:Math.min(v.left-s.left,0),top:Math.min(v.top-s.top,0),right:Math.min(v.right-s.right,0),bottom:Math.min(v.bottom-s.bottom,0)};return{x:h-_.left+_.right,y:g-_.top+_.bottom,zoom:u}},dt=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Qe(e){return e!=null&&e!=="parent"}function ke(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Or(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Br(e,t={width:0,height:0},n,o,r){const i={...e},s=o.get(n);if(s){const a=s.origin||r;i.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function xo(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Vu(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function Ou(e){return{...Dr,...e||{}}}function rt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:s}=be(e),a=yt({x:i-(r?.left??0),y:s-(r?.top??0)},o),{x:l,y:c}=n?mt(a,t):a;return{xSnapped:l,ySnapped:c,...a}}const zn=e=>({width:e.offsetWidth,height:e.offsetHeight}),Fr=e=>e?.getRootNode?.()||window?.document,Bu=["INPUT","SELECT","TEXTAREA"];function Xr(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:Bu.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Yr=e=>"clientX"in e,be=(e,t)=>{const n=Yr(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},wo=(e,t,n,o,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:r,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/o,y:(a.top-n.top)/o,...zn(s)}})};function Zr({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:a}){const l=e*.125+r*.375+s*.375+n*.125,c=t*.125+i*.375+a*.375+o*.125,u=Math.abs(l-e),f=Math.abs(c-t);return[l,c,u,f]}function _t(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function vo({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case Z.Left:return[t-_t(t-o,i),n];case Z.Right:return[t+_t(o-t,i),n];case Z.Top:return[t,n-_t(n-r,i)];case Z.Bottom:return[t,n+_t(r-n,i)]}}function Wr({sourceX:e,sourceY:t,sourcePosition:n=Z.Bottom,targetX:o,targetY:r,targetPosition:i=Z.Top,curvature:s=.25}){const[a,l]=vo({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[c,u]=vo({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[f,d,h,g]=Zr({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${e},${t} C${a},${l} ${c},${u} ${o},${r}`,f,d,h,g]}function Gr({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,s=Math.abs(o-t)/2,a=o<t?o+s:o-s;return[i,a,r,s]}function Fu({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1,zIndexMode:i="basic"}){if(i==="manual")return o;const s=r&&n?o+1e3:o,a=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return s+a}function Xu({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=Zt(Lt(e),Lt(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:o/r[2]};return ut(s,Wt(i))>0}const Yu=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,Zu=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Wu=(e,t,n={})=>{if(!e.source||!e.target)return t;const o=n.getEdgeId||Yu;let r;return Lr(e)?r={...e}:r={...e,id:o(e)},Zu(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function qr({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=Gr({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const _o={[Z.Left]:{x:-1,y:0},[Z.Right]:{x:1,y:0},[Z.Top]:{x:0,y:-1},[Z.Bottom]:{x:0,y:1}},Gu=({source:e,sourcePosition:t=Z.Bottom,target:n})=>t===Z.Left||t===Z.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},bo=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function qu({source:e,sourcePosition:t=Z.Bottom,target:n,targetPosition:o=Z.Top,center:r,offset:i,stepPosition:s}){const a=_o[t],l=_o[o],c={x:e.x+a.x*i,y:e.y+a.y*i},u={x:n.x+l.x*i,y:n.y+l.y*i},f=Gu({source:c,sourcePosition:t,target:u}),d=f.x!==0?"x":"y",h=f[d];let g=[],v,_;const y={x:0,y:0},b={x:0,y:0},[,,p,w]=Gr({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[d]*l[d]===-1){d==="x"?(v=r.x??c.x+(u.x-c.x)*s,_=r.y??(c.y+u.y)/2):(v=r.x??(c.x+u.x)/2,_=r.y??c.y+(u.y-c.y)*s);const S=[{x:v,y:c.y},{x:v,y:u.y}],E=[{x:c.x,y:_},{x:u.x,y:_}];a[d]===h?g=d==="x"?S:E:g=d==="x"?E:S}else{const S=[{x:c.x,y:u.y}],E=[{x:u.x,y:c.y}];if(d==="x"?g=a.x===h?E:S:g=a.y===h?S:E,t===o){const $=Math.abs(e[d]-n[d]);if($<=i){const L=Math.min(i-1,i-$);a[d]===h?y[d]=(c[d]>e[d]?-1:1)*L:b[d]=(u[d]>n[d]?-1:1)*L}}if(t!==o){const $=d==="x"?"y":"x",L=a[d]===l[$],x=c[$]>u[$],M=c[$]<u[$];(a[d]===1&&(!L&&x||L&&M)||a[d]!==1&&(!L&&M||L&&x))&&(g=d==="x"?S:E)}const T={x:c.x+y.x,y:c.y+y.y},P={x:u.x+b.x,y:u.y+b.y},O=Math.max(Math.abs(T.x-g[0].x),Math.abs(P.x-g[0].x)),k=Math.max(Math.abs(T.y-g[0].y),Math.abs(P.y-g[0].y));O>=k?(v=(T.x+P.x)/2,_=g[0].y):(v=g[0].x,_=(T.y+P.y)/2)}return[[e,{x:c.x+y.x,y:c.y+y.y},...g,{x:u.x+b.x,y:u.y+b.y},n],v,_,p,w]}function Ku(e,t,n,o){const r=Math.min(bo(e,t)/2,bo(t,n)/2,o),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const c=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${i+r*c},${s}Q ${i},${s} ${i},${s+r*u}`}const a=e.x<n.x?1:-1,l=e.y<n.y?-1:1;return`L ${i},${s+r*l}Q ${i},${s} ${i+r*a},${s}`}function vn({sourceX:e,sourceY:t,sourcePosition:n=Z.Bottom,targetX:o,targetY:r,targetPosition:i=Z.Top,borderRadius:s=5,centerX:a,centerY:l,offset:c=20,stepPosition:u=.5}){const[f,d,h,g,v]=qu({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:a,y:l},offset:c,stepPosition:u});return[f.reduce((y,b,p)=>{let w="";return p>0&&p<f.length-1?w=Ku(f[p-1],b,f[p+1],s):w=`${p===0?"M":"L"}${b.x} ${b.y}`,y+=w,y},""),d,h,g,v]}function So(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Uu(e){const{sourceNode:t,targetNode:n}=e;if(!So(t)||!So(n))return null;const o=t.internals.handleBounds||Eo(t.handles),r=n.internals.handleBounds||Eo(n.handles),i=Co(o?.source??[],e.sourceHandle),s=Co(e.connectionMode===qe.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!i||!s)return e.onError?.("008",Ee.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=i?.position||Z.Bottom,l=s?.position||Z.Top,c=Be(t,i,a),u=Be(n,s,l);return{sourceX:c.x,sourceY:c.y,targetX:u.x,targetY:u.y,sourcePosition:a,targetPosition:l}}function Eo(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function Be(e,t,n=Z.Left,o=!1){const r=(t?.x??0)+e.internals.positionAbsolute.x,i=(t?.y??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??ke(e);if(o)return{x:r+s/2,y:i+a/2};switch(t?.position??n){case Z.Top:return{x:r+s/2,y:i};case Z.Right:return{x:r+s,y:i+a/2};case Z.Bottom:return{x:r+s/2,y:i+a};case Z.Left:return{x:r,y:i+a/2}}}function Co(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function _n(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function Qu(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const i=new Set;return e.reduce((s,a)=>([a.markerStart||o,a.markerEnd||r].forEach(l=>{if(l&&typeof l=="object"){const c=_n(l,t);i.has(c)||(s.push({id:c,color:l.color||n,...l}),i.add(c))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const Kr=1e3,Ju=10,Ln={nodeOrigin:[0,0],nodeExtent:ct,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},ed={...Ln,checkEquality:!0};function Hn(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function td(e,t,n){const o=Hn(Ln,n);for(const r of e.values())if(r.parentId)jn(r,e,t,o);else{const i=gt(r,o.nodeOrigin),s=Qe(r.extent)?r.extent:o.nodeExtent,a=Oe(i,s,ke(r));r.internals.positionAbsolute=a}}function nd(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const r of e.handles){const i={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(i):r.type==="target"&&o.push(i)}return{source:n,target:o}}function Rn(e){return e==="manual"}function bn(e,t,n,o={}){const r=Hn(ed,o),i={i:0},s=new Map(t),a=r?.elevateNodesOnSelect&&!Rn(r.zIndexMode)?Kr:0;let l=e.length>0;t.clear(),n.clear();for(const c of e){let u=s.get(c.id);if(r.checkEquality&&c===u?.internals.userNode)t.set(c.id,u);else{const f=gt(c,r.nodeOrigin),d=Qe(c.extent)?c.extent:r.nodeExtent,h=Oe(f,d,ke(c));u={...r.defaults,...c,measured:{width:c.measured?.width,height:c.measured?.height},internals:{positionAbsolute:h,handleBounds:nd(c,u),z:Ur(c,a,r.zIndexMode),userNode:c}},t.set(c.id,u)}(u.measured===void 0||u.measured.width===void 0||u.measured.height===void 0)&&!u.hidden&&(l=!1),c.parentId&&jn(u,t,n,o,i)}return l}function od(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function jn(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:l}=Hn(Ln,o),c=e.parentId,u=t.get(c);if(!u){console.warn(`Parent node ${c} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}od(e,n),r&&!u.parentId&&u.internals.rootParentIndex===void 0&&l==="auto"&&(u.internals.rootParentIndex=++r.i,u.internals.z=u.internals.z+r.i*Ju),r&&u.internals.rootParentIndex!==void 0&&(r.i=u.internals.rootParentIndex);const f=i&&!Rn(l)?Kr:0,{x:d,y:h,z:g}=rd(e,u,s,a,f,l),{positionAbsolute:v}=e.internals,_=d!==v.x||h!==v.y;(_||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:_?{x:d,y:h}:v,z:g}})}function Ur(e,t,n){const o=_e(e.zIndex)?e.zIndex:0;return Rn(n)?o:o+(e.selected?t:0)}function rd(e,t,n,o,r,i){const{x:s,y:a}=t.internals.positionAbsolute,l=ke(e),c=gt(e,n),u=Qe(e.extent)?Oe(c,e.extent,l):c;let f=Oe({x:s+u.x,y:a+u.y},o,l);e.extent==="parent"&&(f=Rr(f,l,t));const d=Ur(e,r,i),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=d?h+1:d}}function Vn(e,t,n,o=[0,0]){const r=[],i=new Map;for(const s of e){const a=t.get(s.parentId);if(!a)continue;const l=i.get(s.parentId)?.expandedRect??Ue(a),c=Vr(l,s.rect);i.set(s.parentId,{expandedRect:c,parent:a})}return i.size>0&&i.forEach(({expandedRect:s,parent:a},l)=>{const c=a.internals.positionAbsolute,u=ke(a),f=a.origin??o,d=s.x<c.x?Math.round(Math.abs(c.x-s.x)):0,h=s.y<c.y?Math.round(Math.abs(c.y-s.y)):0,g=Math.max(u.width,Math.round(s.width)),v=Math.max(u.height,Math.round(s.height)),_=(g-u.width)*f[0],y=(v-u.height)*f[1];(d>0||h>0||_||y)&&(r.push({id:l,type:"position",position:{x:a.position.x-d+_,y:a.position.y-h+y}}),n.get(l)?.forEach(b=>{e.some(p=>p.id===b.id)||r.push({id:b.id,type:"position",position:{x:b.position.x+d,y:b.position.y+h}})})),(u.width<s.width||u.height<s.height||d||h)&&r.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:g+(d?f[0]*d-_:0),height:v+(h?f[1]*h-y:0)}})}),r}function sd(e,t,n,o,r,i,s){const a=o?.querySelector(".xyflow__viewport");let l=!1;if(!a)return{changes:[],updatedInternals:l};const c=[],u=window.getComputedStyle(a),{m22:f}=new window.DOMMatrixReadOnly(u.transform),d=[];for(const h of e.values()){const g=t.get(h.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),l=!0;continue}const v=zn(h.nodeElement),_=g.measured.width!==v.width||g.measured.height!==v.height;if(!!(v.width&&v.height&&(_||!g.internals.handleBounds||h.force))){const b=h.nodeElement.getBoundingClientRect(),p=Qe(g.extent)?g.extent:i;let{positionAbsolute:w}=g.internals;g.parentId&&g.extent==="parent"?w=Rr(w,v,t.get(g.parentId)):p&&(w=Oe(w,p,v));const N={...g,measured:v,internals:{...g.internals,positionAbsolute:w,handleBounds:{source:wo("source",h.nodeElement,b,f,g.id),target:wo("target",h.nodeElement,b,f,g.id)}}};t.set(g.id,N),g.parentId&&jn(N,t,n,{nodeOrigin:r,zIndexMode:s}),l=!0,_&&(c.push({id:g.id,type:"dimensions",dimensions:v}),g.expandParent&&g.parentId&&d.push({id:g.id,parentId:g.parentId,rect:Ue(N,r)}))}}if(d.length>0){const h=Vn(d,t,n,r);c.push(...h)}return{changes:c,updatedInternals:l}}async function id({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o),a=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(a)}function No(e,t,n,o,r,i){let s=r;const a=o.get(s)||new Map;o.set(s,a.set(n,t)),s=`${r}-${e}`;const l=o.get(s)||new Map;if(o.set(s,l.set(n,t)),i){s=`${r}-${e}-${i}`;const c=o.get(s)||new Map;o.set(s,c.set(n,t))}}function Qr(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:i,sourceHandle:s=null,targetHandle:a=null}=o,l={edgeId:o.id,source:r,target:i,sourceHandle:s,targetHandle:a},c=`${r}-${s}--${i}-${a}`,u=`${i}-${a}--${r}-${s}`;No("source",l,u,e,r,s),No("target",l,c,e,i,a),t.set(o.id,o)}}function Jr(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Jr(n,t):!1}function Mo(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function ad(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!Jr(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(i);a&&r.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return r}function an({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[s,a]of t){const l=n.get(s)?.internals.userNode;l&&r.push({...l,position:a.position,dragging:o})}if(!e)return[r[0],r];const i=n.get(e)?.internals.userNode;return[i?{...i,position:t.get(e)?.position||i.position,dragging:o}:r[0],r]}function cd({dragItems:e,snapGrid:t,x:n,y:o}){const r=e.values().next().value;if(!r)return null;const i={x:n-r.distance.x,y:o-r.distance.y},s=mt(i,t);return{x:s.x-i.x,y:s.y-i.y}}function ld({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,a=new Map,l=!1,c={x:0,y:0},u=null,f=!1,d=null,h=!1,g=!1,v=null;function _({noDragClassName:b,handleSelector:p,domNode:w,isSelectable:N,nodeId:S,nodeClickDistance:E=0}){d=he(w);function T({x:$,y:L}){const{nodeLookup:x,nodeExtent:M,snapGrid:C,snapToGrid:A,nodeOrigin:I,onNodeDrag:D,onSelectionDrag:H,onError:V,updateNodePositions:R}=t();i={x:$,y:L};let j=!1;const F=a.size>1,W=F&&M?wn(pt(a)):null,K=F&&A?cd({dragItems:a,snapGrid:C,x:$,y:L}):null;for(const[X,B]of a){if(!x.has(X))continue;let Y={x:$-B.distance.x,y:L-B.distance.y};A&&(Y=K?{x:Math.round(Y.x+K.x),y:Math.round(Y.y+K.y)}:mt(Y,C));let U=null;if(F&&M&&!B.extent&&W){const{positionAbsolute:q}=B.internals,J=q.x-W.x+M[0][0],ne=q.x+B.measured.width-W.x2+M[1][0],te=q.y-W.y+M[0][1],se=q.y+B.measured.height-W.y2+M[1][1];U=[[J,te],[ne,se]]}const{position:Q,positionAbsolute:G}=Hr({nodeId:X,nextPosition:Y,nodeLookup:x,nodeExtent:U||M,nodeOrigin:I,onError:V});j=j||B.position.x!==Q.x||B.position.y!==Q.y,B.position=Q,B.internals.positionAbsolute=G}if(g=g||j,!!j&&(R(a,!0),v&&(o||D||!S&&H))){const[X,B]=an({nodeId:S,dragItems:a,nodeLookup:x});o?.(v,a,X,B),D?.(v,X,B),S||H?.(v,B)}}async function P(){if(!u)return;const{transform:$,panBy:L,autoPanSpeed:x,autoPanOnNodeDrag:M}=t();if(!M){l=!1,cancelAnimationFrame(s);return}const[C,A]=jr(c,u,x);(C!==0||A!==0)&&(i.x=(i.x??0)-C/$[2],i.y=(i.y??0)-A/$[2],await L({x:C,y:A})&&T(i)),s=requestAnimationFrame(P)}function O($){const{nodeLookup:L,multiSelectionActive:x,nodesDraggable:M,transform:C,snapGrid:A,snapToGrid:I,selectNodesOnDrag:D,onNodeDragStart:H,onSelectionDragStart:V,unselectNodesAndEdges:R}=t();f=!0,(!D||!N)&&!x&&S&&(L.get(S)?.selected||R()),N&&D&&S&&e?.(S);const j=rt($.sourceEvent,{transform:C,snapGrid:A,snapToGrid:I,containerBounds:u});if(i=j,a=ad(L,M,j,S),a.size>0&&(n||H||!S&&V)){const[F,W]=an({nodeId:S,dragItems:a,nodeLookup:L});n?.($.sourceEvent,a,F,W),H?.($.sourceEvent,F,W),S||V?.($.sourceEvent,W)}}const k=vr().clickDistance(E).on("start",$=>{const{domNode:L,nodeDragThreshold:x,transform:M,snapGrid:C,snapToGrid:A}=t();u=L?.getBoundingClientRect()||null,h=!1,g=!1,v=$.sourceEvent,x===0&&O($),i=rt($.sourceEvent,{transform:M,snapGrid:C,snapToGrid:A,containerBounds:u}),c=be($.sourceEvent,u)}).on("drag",$=>{const{autoPanOnNodeDrag:L,transform:x,snapGrid:M,snapToGrid:C,nodeDragThreshold:A,nodeLookup:I}=t(),D=rt($.sourceEvent,{transform:x,snapGrid:M,snapToGrid:C,containerBounds:u});if(v=$.sourceEvent,($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1||S&&!I.has(S))&&(h=!0),!h){if(!l&&L&&f&&(l=!0,P()),!f){const H=be($.sourceEvent,u),V=H.x-c.x,R=H.y-c.y;Math.sqrt(V*V+R*R)>A&&O($)}(i.x!==D.xSnapped||i.y!==D.ySnapped)&&a&&f&&(c=be($.sourceEvent,u),T(D))}}).on("end",$=>{if(!(!f||h)&&(l=!1,f=!1,cancelAnimationFrame(s),a.size>0)){const{nodeLookup:L,updateNodePositions:x,onNodeDragStop:M,onSelectionDragStop:C}=t();if(g&&(x(a,!1),g=!1),r||M||!S&&C){const[A,I]=an({nodeId:S,dragItems:a,nodeLookup:L,dragging:!1});r?.($.sourceEvent,a,A,I),M?.($.sourceEvent,A,I),S||C?.($.sourceEvent,I)}}}).filter($=>{const L=$.target;return!$.button&&(!b||!Mo(L,`.${b}`,w))&&(!p||Mo(L,p,w))});d.call(k)}function y(){d?.on(".drag",null)}return{update:_,destroy:y}}function ud(e,t,n){const o=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())ut(r,Ue(i))>0&&o.push(i);return o}const dd=250;function fd(e,t,n,o){let r=[],i=1/0;const s=ud(e,n,t+dd);for(const a of s){const l=[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]];for(const c of l){if(o.nodeId===c.nodeId&&o.type===c.type&&o.id===c.id)continue;const{x:u,y:f}=Be(a,c,c.position,!0),d=Math.sqrt(Math.pow(u-e.x,2)+Math.pow(f-e.y,2));d>t||(d<i?(r=[{...c,x:u,y:f}],i=d):d===i&&r.push({...c,x:u,y:f}))}}if(!r.length)return null;if(r.length>1){const a=o.type==="source"?"target":"source";return r.find(l=>l.type===a)??r[0]}return r[0]}function es(e,t,n,o,r,i=!1){const s=o.get(e);if(!s)return null;const a=r==="strict"?s.internals.handleBounds?.[t]:[...s.internals.handleBounds?.source??[],...s.internals.handleBounds?.target??[]],l=(n?a?.find(c=>c.id===n):a?.[0])??null;return l&&i?{...l,...Be(s,l,l.position,!0)}:l}function ts(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function hd(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const ns=()=>!0;function gd(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:l,lib:c,autoPanOnConnect:u,flowId:f,panBy:d,cancelConnection:h,onConnectStart:g,onConnect:v,onConnectEnd:_,isValidConnection:y=ns,onReconnectEnd:b,updateConnection:p,getTransform:w,getFromHandle:N,autoPanSpeed:S,dragThreshold:E=1,handleDomNode:T}){const P=Fr(e.target);let O=0,k;const{x:$,y:L}=be(e),x=ts(i,T),M=a?.getBoundingClientRect();let C=!1;if(!M||!x)return;const A=es(r,x,o,l,t);if(!A)return;let I=be(e,M),D=!1,H=null,V=!1,R=null;function j(){if(!u||!M)return;const[Q,G]=jr(I,M,S);d({x:Q,y:G}),O=requestAnimationFrame(j)}const F={...A,nodeId:r,type:x,position:A.position},W=l.get(r);let X={inProgress:!0,isValid:null,from:Be(W,F,Z.Left,!0),fromHandle:F,fromPosition:F.position,fromNode:W,to:I,toHandle:null,toPosition:po[F.position],toNode:null,pointer:I};function B(){C=!0,p(X),g?.(e,{nodeId:r,handleId:o,handleType:x})}E===0&&B();function Y(Q){if(!C){const{x:se,y:fe}=be(Q),ue=se-$,de=fe-L;if(!(ue*ue+de*de>E*E))return;B()}if(!N()||!F){U(Q);return}const G=w();I=be(Q,M),k=fd(yt(I,G,!1,[1,1]),n,l,F),D||(j(),D=!0);const q=os(Q,{handle:k,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:y,doc:P,lib:c,flowId:f,nodeLookup:l});R=q.handleDomNode,H=q.connection,V=hd(!!k,q.isValid);const J=l.get(r),ne=J?Be(J,F,Z.Left,!0):X.from,te={...X,from:ne,isValid:V,to:q.toHandle&&V?Ht({x:q.toHandle.x,y:q.toHandle.y},G):I,toHandle:q.toHandle,toPosition:V&&q.toHandle?q.toHandle.position:po[F.position],toNode:q.toHandle?l.get(q.toHandle.nodeId):null,pointer:I};p(te),X=te}function U(Q){if(!("touches"in Q&&Q.touches.length>0)){if(C){(k||R)&&H&&V&&v?.(H);const{inProgress:G,...q}=X,J={...q,toPosition:X.toHandle?X.toPosition:null};_?.(Q,J),i&&b?.(Q,J)}h(),cancelAnimationFrame(O),D=!1,V=!1,H=null,R=null,P.removeEventListener("mousemove",Y),P.removeEventListener("mouseup",U),P.removeEventListener("touchmove",Y),P.removeEventListener("touchend",U)}}P.addEventListener("mousemove",Y),P.addEventListener("mouseup",U),P.addEventListener("touchmove",Y),P.addEventListener("touchend",U)}function os(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:a,flowId:l,isValidConnection:c=ns,nodeLookup:u}){const f=i==="target",d=t?s.querySelector(`.${a}-flow__handle[data-id="${l}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:g}=be(e),v=s.elementFromPoint(h,g),_=v?.classList.contains(`${a}-flow__handle`)?v:d,y={handleDomNode:_,isValid:!1,connection:null,toHandle:null};if(_){const b=ts(void 0,_),p=_.getAttribute("data-nodeid"),w=_.getAttribute("data-handleid"),N=_.classList.contains("connectable"),S=_.classList.contains("connectableend");if(!p||!b)return y;const E={source:f?p:o,sourceHandle:f?w:r,target:f?o:p,targetHandle:f?r:w};y.connection=E;const P=N&&S&&(n===qe.Strict?f&&b==="source"||!f&&b==="target":p!==o||w!==r);y.isValid=P&&c(E),y.toHandle=es(p,b,w,u,n,!0)}return y}const Sn={onPointerDown:gd,isValid:os};function pd({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=he(e);function i({translateExtent:a,width:l,height:c,zoomStep:u=1,pannable:f=!0,zoomable:d=!0,inversePan:h=!1}){const g=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const w=n(),N=p.sourceEvent.ctrlKey&&dt()?10:1,S=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*u,E=w[2]*Math.pow(2,S*N);t.scaleTo(E)};let v=[0,0];const _=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(v=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},y=p=>{const w=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const N=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],S=[N[0]-v[0],N[1]-v[1]];v=N;const E=o()*Math.max(w[2],Math.log(w[2]))*(h?-1:1),T={x:w[0]-S[0]*E,y:w[1]-S[1]*E},P=[[0,0],[l,c]];t.setViewportConstrained({x:T.x,y:T.y,zoom:w[2]},P,a)},b=Pr().on("start",_).on("zoom",f?y:null).on("zoom.wheel",d?g:null);r.call(b,{})}function s(){r.on("zoom",null)}return{update:i,destroy:s,pointer:ve}}const Gt=e=>({x:e.x,y:e.y,zoom:e.k}),cn=({x:e,y:t,zoom:n})=>Yt.translate(e,t).scale(n),Xe=(e,t)=>e.target.closest(`.${t}`),rs=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),md=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,ln=(e,t=0,n=md,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},ss=e=>{const t=e.ctrlKey&&dt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function yd({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:l,onPanZoomEnd:c}){return u=>{if(Xe(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(u.ctrlKey&&s){const _=ve(u),y=ss(u),b=f*Math.pow(2,y);o.scaleTo(n,b,_,u);return}const d=u.deltaMode===1?20:1;let h=r===je.Vertical?0:u.deltaX*d,g=r===je.Horizontal?0:u.deltaY*d;!dt()&&u.shiftKey&&r!==je.Vertical&&(h=u.deltaY*d,g=0),o.translateBy(n,-(h/f)*i,-(g/f)*i,{internal:!0});const v=Gt(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(l?.(u,v),e.panScrollTimeout=setTimeout(()=>{c?.(u,v),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a?.(u,v))}}function xd({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const i=o.type==="wheel",s=!t&&i&&!o.ctrlKey,a=Xe(o,e);if(o.ctrlKey&&i&&a&&o.preventDefault(),s||a)return null;o.preventDefault(),n.call(this,o,r)}}function wd({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=Gt(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,r)}}function vd({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&rs(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,Gt(i.transform))}}function _d({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&rs(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const a=Gt(s.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(s.sourceEvent,a)},n?150:0)}}}function bd({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:a,noPanClassName:l,lib:c,connectionInProgress:u}){return f=>{const d=e||t,h=n&&f.ctrlKey,g=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(Xe(f,`${c}-flow__node`)||Xe(f,`${c}-flow__edge`)))return!0;if(!o&&!d&&!r&&!i&&!n||s||u&&!g||Xe(f,a)&&g||Xe(f,l)&&(!g||r&&g&&!e)||!n&&f.ctrlKey&&g)return!1;if(!n&&f.type==="touchstart"&&f.touches?.length>1)return f.preventDefault(),!1;if(!d&&!r&&!h&&g||!o&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(o)&&!o.includes(f.button)&&f.type==="mousedown")return!1;const v=Array.isArray(o)&&o.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||g)&&v}}function Sd({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:l}){const c={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),f=Pr().scaleExtent([t,n]).translateExtent(o),d=he(e).call(f);b({x:r.x,y:r.y,zoom:Ke(r.zoom,t,n)},[[0,0],[u.width,u.height]],o);const h=d.on("wheel.zoom"),g=d.on("dblclick.zoom");f.wheelDelta(ss);function v(k,$){return d?new Promise(L=>{f?.interpolate($?.interpolate==="linear"?nn:Mt).transform(ln(d,$?.duration,$?.ease,()=>L(!0)),k)}):Promise.resolve(!1)}function _({noWheelClassName:k,noPanClassName:$,onPaneContextMenu:L,userSelectionActive:x,panOnScroll:M,panOnDrag:C,panOnScrollMode:A,panOnScrollSpeed:I,preventScrolling:D,zoomOnPinch:H,zoomOnScroll:V,zoomOnDoubleClick:R,zoomActivationKeyPressed:j,lib:F,onTransformChange:W,connectionInProgress:K,paneClickDistance:X,selectionOnDrag:B}){x&&!c.isZoomingOrPanning&&y();const Y=M&&!j&&!x;f.clickDistance(B?1/0:!_e(X)||X<0?0:X);const U=Y?yd({zoomPanValues:c,noWheelClassName:k,d3Selection:d,d3Zoom:f,panOnScrollMode:A,panOnScrollSpeed:I,zoomOnPinch:H,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):xd({noWheelClassName:k,preventScrolling:D,d3ZoomHandler:h});if(d.on("wheel.zoom",U,{passive:!1}),!x){const G=wd({zoomPanValues:c,onDraggingChange:l,onPanZoomStart:s});f.on("start",G);const q=vd({zoomPanValues:c,panOnDrag:C,onPaneContextMenu:!!L,onPanZoom:i,onTransformChange:W});f.on("zoom",q);const J=_d({zoomPanValues:c,panOnDrag:C,panOnScroll:M,onPaneContextMenu:L,onPanZoomEnd:a,onDraggingChange:l});f.on("end",J)}const Q=bd({zoomActivationKeyPressed:j,panOnDrag:C,zoomOnScroll:V,panOnScroll:M,zoomOnDoubleClick:R,zoomOnPinch:H,userSelectionActive:x,noPanClassName:$,noWheelClassName:k,lib:F,connectionInProgress:K});f.filter(Q),R?d.on("dblclick.zoom",g):d.on("dblclick.zoom",null)}function y(){f.on("zoom",null)}async function b(k,$,L){const x=cn(k),M=f?.constrain()(x,$,L);return M&&await v(M),new Promise(C=>C(M))}async function p(k,$){const L=cn(k);return await v(L,$),new Promise(x=>x(L))}function w(k){if(d){const $=cn(k),L=d.property("__zoom");(L.k!==k.zoom||L.x!==k.x||L.y!==k.y)&&f?.transform(d,$,null,{sync:!0})}}function N(){const k=d?Ar(d.node()):{x:0,y:0,k:1};return{x:k.x,y:k.y,zoom:k.k}}function S(k,$){return d?new Promise(L=>{f?.interpolate($?.interpolate==="linear"?nn:Mt).scaleTo(ln(d,$?.duration,$?.ease,()=>L(!0)),k)}):Promise.resolve(!1)}function E(k,$){return d?new Promise(L=>{f?.interpolate($?.interpolate==="linear"?nn:Mt).scaleBy(ln(d,$?.duration,$?.ease,()=>L(!0)),k)}):Promise.resolve(!1)}function T(k){f?.scaleExtent(k)}function P(k){f?.translateExtent(k)}function O(k){const $=!_e(k)||k<0?0:k;f?.clickDistance($)}return{update:_,destroy:y,setViewport:p,setViewportConstrained:b,getViewport:N,scaleTo:S,scaleBy:E,setScaleExtent:T,setTranslateExtent:P,syncViewport:w,setClickDistance:O}}var Je;(function(e){e.Line="line",e.Handle="handle"})(Je||(Je={}));function Ed({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,a=n-o,l=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(l[0]=l[0]*-1),a&&i&&(l[1]=l[1]*-1),l}function Io(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:r}}function Pe(e,t){return Math.max(0,t-e)}function Te(e,t){return Math.max(0,e-t)}function bt(e,t,n){return Math.max(0,t-e,e-n)}function ko(e,t){return e?!t:t}function Cd(e,t,n,o,r,i,s,a){let{affectsX:l,affectsY:c}=t;const{isHorizontal:u,isVertical:f}=t,d=u&&f,{xSnapped:h,ySnapped:g}=n,{minWidth:v,maxWidth:_,minHeight:y,maxHeight:b}=o,{x:p,y:w,width:N,height:S,aspectRatio:E}=e;let T=Math.floor(u?h-e.pointerX:0),P=Math.floor(f?g-e.pointerY:0);const O=N+(l?-T:T),k=S+(c?-P:P),$=-i[0]*N,L=-i[1]*S;let x=bt(O,v,_),M=bt(k,y,b);if(s){let I=0,D=0;l&&T<0?I=Pe(p+T+$,s[0][0]):!l&&T>0&&(I=Te(p+O+$,s[1][0])),c&&P<0?D=Pe(w+P+L,s[0][1]):!c&&P>0&&(D=Te(w+k+L,s[1][1])),x=Math.max(x,I),M=Math.max(M,D)}if(a){let I=0,D=0;l&&T>0?I=Te(p+T,a[0][0]):!l&&T<0&&(I=Pe(p+O,a[1][0])),c&&P>0?D=Te(w+P,a[0][1]):!c&&P<0&&(D=Pe(w+k,a[1][1])),x=Math.max(x,I),M=Math.max(M,D)}if(r){if(u){const I=bt(O/E,y,b)*E;if(x=Math.max(x,I),s){let D=0;!l&&!c||l&&!c&&d?D=Te(w+L+O/E,s[1][1])*E:D=Pe(w+L+(l?T:-T)/E,s[0][1])*E,x=Math.max(x,D)}if(a){let D=0;!l&&!c||l&&!c&&d?D=Pe(w+O/E,a[1][1])*E:D=Te(w+(l?T:-T)/E,a[0][1])*E,x=Math.max(x,D)}}if(f){const I=bt(k*E,v,_)/E;if(M=Math.max(M,I),s){let D=0;!l&&!c||c&&!l&&d?D=Te(p+k*E+$,s[1][0])/E:D=Pe(p+(c?P:-P)*E+$,s[0][0])/E,M=Math.max(M,D)}if(a){let D=0;!l&&!c||c&&!l&&d?D=Pe(p+k*E,a[1][0])/E:D=Te(p+(c?P:-P)*E,a[0][0])/E,M=Math.max(M,D)}}}P=P+(P<0?M:-M),T=T+(T<0?x:-x),r&&(d?O>k*E?P=(ko(l,c)?-T:T)/E:T=(ko(l,c)?-P:P)*E:u?(P=T/E,c=l):(T=P*E,l=c));const C=l?p+T:p,A=c?w+P:w;return{width:N+(l?-T:T),height:S+(c?-P:P),x:i[0]*T*(l?-1:1)+C,y:i[1]*P*(c?-1:1)+A}}const is={width:0,height:0,x:0,y:0},Nd={...is,pointerX:0,pointerY:0,aspectRatio:1};function Md(e){return[[0,0],[e.measured.width,e.measured.height]]}function Id(e,t,n){const o=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,a=n[0]*i,l=n[1]*s;return[[o-a,r-l],[o+i-a,r+s-l]]}function kd({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=he(e);let s={controlDirection:Io("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:c,boundaries:u,keepAspectRatio:f,resizeDirection:d,onResizeStart:h,onResize:g,onResizeEnd:v,shouldResize:_}){let y={...is},b={...Nd};s={boundaries:u,resizeDirection:d,keepAspectRatio:f,controlDirection:Io(c)};let p,w=null,N=[],S,E,T,P=!1;const O=vr().on("start",k=>{const{nodeLookup:$,transform:L,snapGrid:x,snapToGrid:M,nodeOrigin:C,paneDomNode:A}=n();if(p=$.get(t),!p)return;w=A?.getBoundingClientRect()??null;const{xSnapped:I,ySnapped:D}=rt(k.sourceEvent,{transform:L,snapGrid:x,snapToGrid:M,containerBounds:w});y={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},b={...y,pointerX:I,pointerY:D,aspectRatio:y.width/y.height},S=void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(S=$.get(p.parentId),E=S&&p.extent==="parent"?Md(S):void 0),N=[],T=void 0;for(const[H,V]of $)if(V.parentId===t&&(N.push({id:H,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const R=Id(V,p,V.origin??C);T?T=[[Math.min(R[0][0],T[0][0]),Math.min(R[0][1],T[0][1])],[Math.max(R[1][0],T[1][0]),Math.max(R[1][1],T[1][1])]]:T=R}h?.(k,{...y})}).on("drag",k=>{const{transform:$,snapGrid:L,snapToGrid:x,nodeOrigin:M}=n(),C=rt(k.sourceEvent,{transform:$,snapGrid:L,snapToGrid:x,containerBounds:w}),A=[];if(!p)return;const{x:I,y:D,width:H,height:V}=y,R={},j=p.origin??M,{width:F,height:W,x:K,y:X}=Cd(b,s.controlDirection,C,s.boundaries,s.keepAspectRatio,j,E,T),B=F!==H,Y=W!==V,U=K!==I&&B,Q=X!==D&&Y;if(!U&&!Q&&!B&&!Y)return;if((U||Q||j[0]===1||j[1]===1)&&(R.x=U?K:y.x,R.y=Q?X:y.y,y.x=R.x,y.y=R.y,N.length>0)){const ne=K-I,te=X-D;for(const se of N)se.position={x:se.position.x-ne+j[0]*(F-H),y:se.position.y-te+j[1]*(W-V)},A.push(se)}if((B||Y)&&(R.width=B&&(!s.resizeDirection||s.resizeDirection==="horizontal")?F:y.width,R.height=Y&&(!s.resizeDirection||s.resizeDirection==="vertical")?W:y.height,y.width=R.width,y.height=R.height),S&&p.expandParent){const ne=j[0]*(R.width??0);R.x&&R.x<ne&&(y.x=ne,b.x=b.x-(R.x-ne));const te=j[1]*(R.height??0);R.y&&R.y<te&&(y.y=te,b.y=b.y-(R.y-te))}const G=Ed({width:y.width,prevWidth:H,height:y.height,prevHeight:V,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),q={...y,direction:G};_?.(k,q)!==!1&&(P=!0,g?.(k,q),o(R,A))}).on("end",k=>{P&&(v?.(k,{...y}),r?.({...y}),P=!1)});i.call(O)}function l(){i.on(".drag",null)}return{update:a,destroy:l}}const Ad={},Ao=e=>{let t;const n=new Set,o=(u,f)=>{const d=typeof u=="function"?u(t):u;if(!Object.is(d,t)){const h=t;t=f??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(g=>g(t,h))}},r=()=>t,l={setState:o,getState:r,getInitialState:()=>c,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(Ad?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},c=t=e(o,r,l);return l},Pd=e=>e?Ao(e):Ao,{useDebugValue:Td}=Wi,{useSyncExternalStoreWithSelector:Dd}=Zi,$d=e=>e;function as(e,t=$d,n){const o=Dd(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Td(o),o}const Po=(e,t)=>{const n=Pd(e),o=(r,i=t)=>as(n,r,i);return Object.assign(o,n),o},zd=(e,t)=>e?Po(e,t):Po;function oe(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,r]of e)if(!Object.is(r,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}const qt=z.createContext(null),Ld=qt.Provider,cs=Ee.error001();function ee(e,t){const n=z.useContext(qt);if(n===null)throw new Error(cs);return as(n,e,t)}function re(){const e=z.useContext(qt);if(e===null)throw new Error(cs);return z.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const To={display:"none"},Hd={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},ls="react-flow__node-desc",us="react-flow__edge-desc",Rd="react-flow__aria-live",jd=e=>e.ariaLiveMessage,Vd=e=>e.ariaLabelConfig;function Od({rfId:e}){const t=ee(jd);return m.jsx("div",{id:`${Rd}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Hd,children:t})}function Bd({rfId:e,disableKeyboardA11y:t}){const n=ee(Vd);return m.jsxs(m.Fragment,{children:[m.jsx("div",{id:`${ls}-${e}`,style:To,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),m.jsx("div",{id:`${us}-${e}`,style:To,children:n["edge.a11yDescription.default"]}),!t&&m.jsx(Od,{rfId:e})]})}const Kt=z.forwardRef(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{const s=`${e}`.split("-");return m.jsx("div",{className:ae(["react-flow__panel",n,...s]),style:o,ref:i,...r,children:t})});Kt.displayName="Panel";function Fd({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:m.jsx(Kt,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:m.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Xd=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},St=e=>e.id;function Yd(e,t){return oe(e.selectedNodes.map(St),t.selectedNodes.map(St))&&oe(e.selectedEdges.map(St),t.selectedEdges.map(St))}function Zd({onSelectionChange:e}){const t=re(),{selectedNodes:n,selectedEdges:o}=ee(Xd,Yd);return z.useEffect(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const Wd=e=>!!e.onSelectionChangeHandlers;function Gd({onSelectionChange:e}){const t=ee(Wd);return e||t?m.jsx(Zd,{onSelectionChange:e}):null}const ds=[0,0],qd={x:0,y:0,zoom:1},Kd=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],Do=[...Kd,"rfId"],Ud=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),$o={translateExtent:ct,nodeOrigin:ds,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Qd(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:l}=ee(Ud,oe),c=re();z.useEffect(()=>(l(e.defaultNodes,e.defaultEdges),()=>{u.current=$o,a()}),[]);const u=z.useRef($o);return z.useEffect(()=>{for(const f of Do){const d=e[f],h=u.current[f];d!==h&&(typeof e[f]>"u"||(f==="nodes"?t(d):f==="edges"?n(d):f==="minZoom"?o(d):f==="maxZoom"?r(d):f==="translateExtent"?i(d):f==="nodeExtent"?s(d):f==="ariaLabelConfig"?c.setState({ariaLabelConfig:Ou(d)}):f==="fitView"?c.setState({fitViewQueued:d}):f==="fitViewOptions"?c.setState({fitViewOptions:d}):c.setState({[f]:d})))}u.current=e},Do.map(f=>e[f])),null}function zo(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Jd(e){const[t,n]=z.useState(e==="system"?null:e);return z.useEffect(()=>{if(e!=="system"){n(e);return}const o=zo(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:zo()?.matches?"dark":"light"}const Lo=typeof document<"u"?document:null;function ft(e=null,t={target:Lo,actInsideInputWithModifier:!0}){const[n,o]=z.useState(!1),r=z.useRef(!1),i=z.useRef(new Set([])),[s,a]=z.useMemo(()=>{if(e!==null){const c=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
1
+ import{r as z,B as Zi,E as Wi,j as m,c as pe,f as Vt,k as Gi,a as qi,t as Ki}from"./index-Dk3lubBQ.js";import{j as Ui,f as Qn,g as Qi,i as Ji,C as le,G as Jn,M as eo,U as ea,k as ta}from"./index-C5xxIZ3a.js";import{D as na,u as oa,b as ra,a as sa,c as ia,N as aa,d as to,G as tn,T as ca}from"./thread-history-popover-DlGwptvV.js";import{E as fn}from"./error-boundary-DU6_J5et.js";import{u as tr}from"./use-connection-BhdfednN.js";import{u as nr,i as la}from"./use-gateway-Ck94EUZ3.js";import{u as ua}from"./use-binding-Cn24Ren1.js";import{u as no,L as da}from"./localstorage-keys-BJk6gyyN.js";import{u as Cn}from"./project-context-provider-B1gr9e2f.js";import{c as or,B as rr}from"./button-2azNqzUx.js";import{V as fa}from"./view-mode-toggle-kdDPGpPT.js";import{i as ha}from"./GitBranch01-CVAiK8ZD.js";import{s as ga}from"./Plus-CgcZFggs.js";import{c as pa}from"./connection-CXC8d3Ae.js";import{I as sr,n as ma}from"./empty-state-C3NzxCFI.js";import{u as ya}from"./use-tool-call-DzBMga46.js";import{i as He,a as oo,b as xa,c as ro,d as nn,T as on,e as wa}from"./value-UH6V0tmj.js";import"./input-CBrhxHNe.js";import"./popover-HE15ABOl.js";import"./tooltip-DHS6wGWv.js";import"./Check-VfxUlV5P.js";import"./SearchMd-DRJ07Awx.js";import"./use-create-gateway-dtd5LmVR.js";import"./AlertCircle-DeHvJZzp.js";import"./X-CVhiWYv-.js";import"./ArrowUp-B2eKsIZo.js";import"./textarea-CyM57U4B.js";import"./useMutation-BEX5R6ly.js";import"./Grid01-AMlhaaWH.js";import"./Copy01-dbjgqDL6.js";import"./Terminal-FTJQx4pc.js";import"./monaco-editor-B2ZJ-0S4.js";import"./spinner-Dwr2EFZD.js";import"./alert-dialog-D9k51qgG.js";import"./select-DkAjMxeq.js";import"./ChevronDown-OK90XtVB.js";import"./use-mobile-CuBmA9jm.js";import"./File06-DCHrHfbn.js";import"./Image01-Bch9iOev.js";import"./InfoCircle-HrYndWCZ.js";import"./use-collections-CbsNEj5T.js";import"./use-gateway-system-prompt-C9-1moLN.js";import"./Edit01-Ddbn6DsS.js";import"./well-known-mcp-D13f-8h2.js";import"./generate-id-Dyweu44Y.js";import"./Clock-CRgmR_1n.js";import"./Trash01-BDWyzvD2.js";import"./binder-Bcr51BHa.js";import"./useQuery-BbeI5BfO.js";const Nn=({size:e=24,color:t="currentColor",...n})=>z.createElement("svg",{viewBox:"0 0 24 24",width:e,height:e,stroke:t,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},z.createElement("path",{d:"m10 15-3.075 3.114c-.43.434-.644.651-.828.666a.5.5 0 0 1-.421-.172c-.12-.14-.12-.446-.12-1.056v-1.56c0-.548-.449-.944-.99-1.024v0a3 3 0 0 1-2.534-2.533C2 12.219 2 11.96 2 11.445V6.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C4.28 2 5.12 2 6.8 2h7.4c1.68 0 2.52 0 3.162.327a3 3 0 0 1 1.311 1.311C19 4.28 19 5.12 19 6.8V11m0 11-2.176-1.513c-.306-.213-.46-.32-.626-.395a2.002 2.002 0 0 0-.462-.145c-.18-.033-.367-.033-.74-.033H13.2c-1.12 0-1.68 0-2.108-.218a2 2 0 0 1-.874-.874C10 18.394 10 17.834 10 16.714V14.2c0-1.12 0-1.68.218-2.108a2 2 0 0 1 .874-.874C11.52 11 12.08 11 13.2 11h5.6c1.12 0 1.68 0 2.108.218a2 2 0 0 1 .874.874C22 12.52 22 13.08 22 14.2v2.714c0 .932 0 1.398-.152 1.766a2 2 0 0 1-1.083 1.082c-.367.152-.833.152-1.765.152V22Z"}));Nn.displayName="MessageChatSquare";function ae(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=ae(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var va={value:()=>{}};function Ot(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new Nt(n)}function Nt(e){this._=e}function _a(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",r=n.indexOf(".");if(r>=0&&(o=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}Nt.prototype=Ot.prototype={constructor:Nt,on:function(e,t){var n=this._,o=_a(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i<s;)if((r=(e=o[i]).type)&&(r=ba(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=o[i]).type)n[r]=so(n[r],e.name,t);else if(t==null)for(r in n)n[r]=so(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Nt(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),o=0,r,i;o<r;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],o=0,r=i.length;o<r;++o)i[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)}};function ba(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function so(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=va,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var hn="http://www.w3.org/1999/xhtml";const io={svg:"http://www.w3.org/2000/svg",xhtml:hn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Bt(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),io.hasOwnProperty(t)?{space:io[t],local:e}:e}function Sa(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===hn&&t.documentElement.namespaceURI===hn?t.createElement(e):t.createElementNS(n,e)}}function Ea(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function ir(e){var t=Bt(e);return(t.local?Ea:Sa)(t)}function Ca(){}function Mn(e){return e==null?Ca:function(){return this.querySelector(e)}}function Na(e){typeof e!="function"&&(e=Mn(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=new Array(s),l,c,u=0;u<s;++u)(l=i[u])&&(c=e.call(l,l.__data__,u,i))&&("__data__"in l&&(c.__data__=l.__data__),a[u]=c);return new ge(o,this._parents)}function Ma(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Ia(){return[]}function ar(e){return e==null?Ia:function(){return this.querySelectorAll(e)}}function ka(e){return function(){return Ma(e.apply(this,arguments))}}function Aa(e){typeof e=="function"?e=ka(e):e=ar(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var s=t[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&(o.push(e.call(l,l.__data__,c,s)),r.push(l));return new ge(o,r)}function cr(e){return function(){return this.matches(e)}}function lr(e){return function(t){return t.matches(e)}}var Pa=Array.prototype.find;function Ta(e){return function(){return Pa.call(this.children,e)}}function Da(){return this.firstElementChild}function $a(e){return this.select(e==null?Da:Ta(typeof e=="function"?e:lr(e)))}var za=Array.prototype.filter;function La(){return Array.from(this.children)}function Ha(e){return function(){return za.call(this.children,e)}}function Ra(e){return this.selectAll(e==null?La:Ha(typeof e=="function"?e:lr(e)))}function ja(e){typeof e!="function"&&(e=cr(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new ge(o,this._parents)}function ur(e){return new Array(e.length)}function Va(){return new ge(this._enter||this._groups.map(ur),this._parents)}function Pt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Pt.prototype={constructor:Pt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Oa(e){return function(){return e}}function Ba(e,t,n,o,r,i){for(var s=0,a,l=t.length,c=i.length;s<c;++s)(a=t[s])?(a.__data__=i[s],o[s]=a):n[s]=new Pt(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function Fa(e,t,n,o,r,i,s){var a,l,c=new Map,u=t.length,f=i.length,d=new Array(u),h;for(a=0;a<u;++a)(l=t[a])&&(d[a]=h=s.call(l,l.__data__,a,t)+"",c.has(h)?r[a]=l:c.set(h,l));for(a=0;a<f;++a)h=s.call(e,i[a],a,i)+"",(l=c.get(h))?(o[a]=l,l.__data__=i[a],c.delete(h)):n[a]=new Pt(e,i[a]);for(a=0;a<u;++a)(l=t[a])&&c.get(d[a])===l&&(r[a]=l)}function Xa(e){return e.__data__}function Ya(e,t){if(!arguments.length)return Array.from(this,Xa);var n=t?Fa:Ba,o=this._parents,r=this._groups;typeof e!="function"&&(e=Oa(e));for(var i=r.length,s=new Array(i),a=new Array(i),l=new Array(i),c=0;c<i;++c){var u=o[c],f=r[c],d=f.length,h=Za(e.call(u,u&&u.__data__,c,o)),g=h.length,v=a[c]=new Array(g),_=s[c]=new Array(g),y=l[c]=new Array(d);n(u,f,v,_,y,h,t);for(var b=0,p=0,w,N;b<g;++b)if(w=v[b]){for(b>=p&&(p=b+1);!(N=_[p])&&++p<g;);w._next=N||null}}return s=new ge(s,o),s._enter=a,s._exit=l,s}function Za(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Wa(){return new ge(this._exit||this._groups.map(ur),this._parents)}function Ga(e,t,n){var o=this.enter(),r=this,i=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?i.remove():n(i),o&&r?o.merge(r).order():r}function qa(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,i=o.length,s=Math.min(r,i),a=new Array(r),l=0;l<s;++l)for(var c=n[l],u=o[l],f=c.length,d=a[l]=new Array(f),h,g=0;g<f;++g)(h=c[g]||u[g])&&(d[g]=h);for(;l<r;++l)a[l]=n[l];return new ge(a,this._parents)}function Ka(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],r=o.length-1,i=o[r],s;--r>=0;)(s=o[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Ua(e){e||(e=Qa);function t(f,d){return f&&d?e(f.__data__,d.__data__):!f-!d}for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var s=n[i],a=s.length,l=r[i]=new Array(a),c,u=0;u<a;++u)(c=s[u])&&(l[u]=c);l.sort(t)}return new ge(r,this._parents).order()}function Qa(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Ja(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ec(){return Array.from(this)}function tc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length;r<i;++r){var s=o[r];if(s)return s}return null}function nc(){let e=0;for(const t of this)++e;return e}function oc(){return!this.node()}function rc(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r=t[n],i=0,s=r.length,a;i<s;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function sc(e){return function(){this.removeAttribute(e)}}function ic(e){return function(){this.removeAttributeNS(e.space,e.local)}}function ac(e,t){return function(){this.setAttribute(e,t)}}function cc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function lc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function uc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function dc(e,t){var n=Bt(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?ic:sc:typeof t=="function"?n.local?uc:lc:n.local?cc:ac)(n,t))}function dr(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function fc(e){return function(){this.style.removeProperty(e)}}function hc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function gc(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function pc(e,t,n){return arguments.length>1?this.each((t==null?fc:typeof t=="function"?gc:hc)(e,t,n??"")):We(this.node(),e)}function We(e,t){return e.style.getPropertyValue(t)||dr(e).getComputedStyle(e,null).getPropertyValue(t)}function mc(e){return function(){delete this[e]}}function yc(e,t){return function(){this[e]=t}}function xc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function wc(e,t){return arguments.length>1?this.each((t==null?mc:typeof t=="function"?xc:yc)(e,t)):this.node()[e]}function fr(e){return e.trim().split(/^|\s+/)}function In(e){return e.classList||new hr(e)}function hr(e){this._node=e,this._names=fr(e.getAttribute("class")||"")}hr.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function gr(e,t){for(var n=In(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function pr(e,t){for(var n=In(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function vc(e){return function(){gr(this,e)}}function _c(e){return function(){pr(this,e)}}function bc(e,t){return function(){(t.apply(this,arguments)?gr:pr)(this,e)}}function Sc(e,t){var n=fr(e+"");if(arguments.length<2){for(var o=In(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?bc:t?vc:_c)(n,t))}function Ec(){this.textContent=""}function Cc(e){return function(){this.textContent=e}}function Nc(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Mc(e){return arguments.length?this.each(e==null?Ec:(typeof e=="function"?Nc:Cc)(e)):this.node().textContent}function Ic(){this.innerHTML=""}function kc(e){return function(){this.innerHTML=e}}function Ac(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Pc(e){return arguments.length?this.each(e==null?Ic:(typeof e=="function"?Ac:kc)(e)):this.node().innerHTML}function Tc(){this.nextSibling&&this.parentNode.appendChild(this)}function Dc(){return this.each(Tc)}function $c(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function zc(){return this.each($c)}function Lc(e){var t=typeof e=="function"?e:ir(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Hc(){return null}function Rc(e,t){var n=typeof e=="function"?e:ir(e),o=t==null?Hc:typeof t=="function"?t:Mn(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function jc(){var e=this.parentNode;e&&e.removeChild(this)}function Vc(){return this.each(jc)}function Oc(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Bc(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Fc(e){return this.select(e?Bc:Oc)}function Xc(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Yc(e){return function(t){e.call(this,t,this.__data__)}}function Zc(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function Wc(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,r=t.length,i;n<r;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++o]=i;++o?t.length=o:delete this.__on}}}function Gc(e,t,n){return function(){var o=this.__on,r,i=Yc(t);if(o){for(var s=0,a=o.length;s<a;++s)if((r=o[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=n),r.value=t;return}}this.addEventListener(e.type,i,n),r={type:e.type,name:e.name,value:t,listener:i,options:n},o?o.push(r):this.__on=[r]}}function qc(e,t,n){var o=Zc(e+""),r,i=o.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,u;l<c;++l)for(r=0,u=a[l];r<i;++r)if((s=o[r]).type===u.type&&s.name===u.name)return u.value}return}for(a=t?Gc:Wc,r=0;r<i;++r)this.each(a(o[r],t,n));return this}function mr(e,t,n){var o=dr(e),r=o.CustomEvent;typeof r=="function"?r=new r(t,n):(r=o.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function Kc(e,t){return function(){return mr(this,e,t)}}function Uc(e,t){return function(){return mr(this,e,t.apply(this,arguments))}}function Qc(e,t){return this.each((typeof t=="function"?Uc:Kc)(e,t))}function*Jc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length,s;r<i;++r)(s=o[r])&&(yield s)}var yr=[null];function ge(e,t){this._groups=e,this._parents=t}function ht(){return new ge([[document.documentElement]],yr)}function el(){return this}ge.prototype=ht.prototype={constructor:ge,select:Na,selectAll:Aa,selectChild:$a,selectChildren:Ra,filter:ja,data:Ya,enter:Va,exit:Wa,join:Ga,merge:qa,selection:el,order:Ka,sort:Ua,call:Ja,nodes:ec,node:tc,size:nc,empty:oc,each:rc,attr:dc,style:pc,property:wc,classed:Sc,text:Mc,html:Pc,raise:Dc,lower:zc,append:Lc,insert:Rc,remove:Vc,clone:Fc,datum:Xc,on:qc,dispatch:Qc,[Symbol.iterator]:Jc};function he(e){return typeof e=="string"?new ge([[document.querySelector(e)]],[document.documentElement]):new ge([[e]],yr)}function tl(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ve(e,t){if(e=tl(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const nl={passive:!1},it={capture:!0,passive:!1};function rn(e){e.stopImmediatePropagation()}function Ze(e){e.preventDefault(),e.stopImmediatePropagation()}function xr(e){var t=e.document.documentElement,n=he(e).on("dragstart.drag",Ze,it);"onselectstart"in t?n.on("selectstart.drag",Ze,it):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function wr(e,t){var n=e.document.documentElement,o=he(e).on("dragstart.drag",null);t&&(o.on("click.drag",Ze,it),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const xt=e=>()=>e;function gn(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:a,dx:l,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}gn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function ol(e){return!e.ctrlKey&&!e.button}function rl(){return this.parentNode}function sl(e,t){return t??{x:e.x,y:e.y}}function il(){return navigator.maxTouchPoints||"ontouchstart"in this}function vr(){var e=ol,t=rl,n=sl,o=il,r={},i=Ot("start","drag","end"),s=0,a,l,c,u,f=0;function d(w){w.on("mousedown.drag",h).filter(o).on("touchstart.drag",_).on("touchmove.drag",y,nl).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(w,N){if(!(u||!e.call(this,w,N))){var S=p(this,t.call(this,w,N),w,N,"mouse");S&&(he(w.view).on("mousemove.drag",g,it).on("mouseup.drag",v,it),xr(w.view),rn(w),c=!1,a=w.clientX,l=w.clientY,S("start",w))}}function g(w){if(Ze(w),!c){var N=w.clientX-a,S=w.clientY-l;c=N*N+S*S>f}r.mouse("drag",w)}function v(w){he(w.view).on("mousemove.drag mouseup.drag",null),wr(w.view,c),Ze(w),r.mouse("end",w)}function _(w,N){if(e.call(this,w,N)){var S=w.changedTouches,E=t.call(this,w,N),T=S.length,P,O;for(P=0;P<T;++P)(O=p(this,E,w,N,S[P].identifier,S[P]))&&(rn(w),O("start",w,S[P]))}}function y(w){var N=w.changedTouches,S=N.length,E,T;for(E=0;E<S;++E)(T=r[N[E].identifier])&&(Ze(w),T("drag",w,N[E]))}function b(w){var N=w.changedTouches,S=N.length,E,T;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),E=0;E<S;++E)(T=r[N[E].identifier])&&(rn(w),T("end",w,N[E]))}function p(w,N,S,E,T,P){var O=i.copy(),k=ve(P||S,N),$,L,x;if((x=n.call(w,new gn("beforestart",{sourceEvent:S,target:d,identifier:T,active:s,x:k[0],y:k[1],dx:0,dy:0,dispatch:O}),E))!=null)return $=x.x-k[0]||0,L=x.y-k[1]||0,function M(C,A,I){var D=k,H;switch(C){case"start":r[T]=M,H=s++;break;case"end":delete r[T],--s;case"drag":k=ve(I||A,N),H=s;break}O.call(C,w,new gn(C,{sourceEvent:A,subject:x,target:d,identifier:T,active:H,x:k[0]+$,y:k[1]+L,dx:k[0]-D[0],dy:k[1]-D[1],dispatch:O}),E)}}return d.filter=function(w){return arguments.length?(e=typeof w=="function"?w:xt(!!w),d):e},d.container=function(w){return arguments.length?(t=typeof w=="function"?w:xt(w),d):t},d.subject=function(w){return arguments.length?(n=typeof w=="function"?w:xt(w),d):n},d.touchable=function(w){return arguments.length?(o=typeof w=="function"?w:xt(!!w),d):o},d.on=function(){var w=i.on.apply(i,arguments);return w===i?d:w},d.clickDistance=function(w){return arguments.length?(f=(w=+w)*w,d):Math.sqrt(f)},d}var ao=180/Math.PI,pn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function _r(e,t,n,o,r,i){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*n+t*o)&&(n-=e*l,o-=t*l),(a=Math.sqrt(n*n+o*o))&&(n/=a,o/=a,l/=a),e*o<t*n&&(e=-e,t=-t,l=-l,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*ao,skewX:Math.atan(l)*ao,scaleX:s,scaleY:a}}var wt;function al(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?pn:_r(t.a,t.b,t.c,t.d,t.e,t.f)}function cl(e){return e==null||(wt||(wt=document.createElementNS("http://www.w3.org/2000/svg","g")),wt.setAttribute("transform",e),!(e=wt.transform.baseVal.consolidate()))?pn:(e=e.matrix,_r(e.a,e.b,e.c,e.d,e.e,e.f))}function br(e,t,n,o){function r(c){return c.length?c.pop()+" ":""}function i(c,u,f,d,h,g){if(c!==f||u!==d){var v=h.push("translate(",null,t,null,n);g.push({i:v-4,x:He(c,f)},{i:v-2,x:He(u,d)})}else(f||d)&&h.push("translate("+f+t+d+n)}function s(c,u,f,d){c!==u?(c-u>180?u+=360:u-c>180&&(c+=360),d.push({i:f.push(r(f)+"rotate(",null,o)-2,x:He(c,u)})):u&&f.push(r(f)+"rotate("+u+o)}function a(c,u,f,d){c!==u?d.push({i:f.push(r(f)+"skewX(",null,o)-2,x:He(c,u)}):u&&f.push(r(f)+"skewX("+u+o)}function l(c,u,f,d,h,g){if(c!==f||u!==d){var v=h.push(r(h)+"scale(",null,",",null,")");g.push({i:v-4,x:He(c,f)},{i:v-2,x:He(u,d)})}else(f!==1||d!==1)&&h.push(r(h)+"scale("+f+","+d+")")}return function(c,u){var f=[],d=[];return c=e(c),u=e(u),i(c.translateX,c.translateY,u.translateX,u.translateY,f,d),s(c.rotate,u.rotate,f,d),a(c.skewX,u.skewX,f,d),l(c.scaleX,c.scaleY,u.scaleX,u.scaleY,f,d),c=u=null,function(h){for(var g=-1,v=d.length,_;++g<v;)f[(_=d[g]).i]=_.x(h);return f.join("")}}}var ll=br(al,"px, ","px)","deg)"),ul=br(cl,", ",")",")"),dl=1e-12;function co(e){return((e=Math.exp(e))+1/e)/2}function fl(e){return((e=Math.exp(e))-1/e)/2}function hl(e){return((e=Math.exp(2*e))-1)/(e+1)}const Mt=(function e(t,n,o){function r(i,s){var a=i[0],l=i[1],c=i[2],u=s[0],f=s[1],d=s[2],h=u-a,g=f-l,v=h*h+g*g,_,y;if(v<dl)y=Math.log(d/c)/t,_=function(E){return[a+E*h,l+E*g,c*Math.exp(t*E*y)]};else{var b=Math.sqrt(v),p=(d*d-c*c+o*v)/(2*c*n*b),w=(d*d-c*c-o*v)/(2*d*n*b),N=Math.log(Math.sqrt(p*p+1)-p),S=Math.log(Math.sqrt(w*w+1)-w);y=(S-N)/t,_=function(E){var T=E*y,P=co(N),O=c/(n*b)*(P*hl(t*T+N)-fl(N));return[a+O*h,l+O*g,c*P/co(t*T+N)]}}return _.duration=y*1e3*t/Math.SQRT2,_}return r.rho=function(i){var s=Math.max(.001,+i),a=s*s,l=a*a;return e(s,a,l)},r})(Math.SQRT2,2,4);var Ge=0,nt=0,et=0,Sr=1e3,Tt,ot,Dt=0,Ve=0,Ft=0,at=typeof performance=="object"&&performance.now?performance:Date,Er=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function kn(){return Ve||(Er(gl),Ve=at.now()+Ft)}function gl(){Ve=0}function $t(){this._call=this._time=this._next=null}$t.prototype=Cr.prototype={constructor:$t,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?kn():+n)+(t==null?0:+t),!this._next&&ot!==this&&(ot?ot._next=this:Tt=this,ot=this),this._call=e,this._time=n,mn()},stop:function(){this._call&&(this._call=null,this._time=1/0,mn())}};function Cr(e,t,n){var o=new $t;return o.restart(e,t,n),o}function pl(){kn(),++Ge;for(var e=Tt,t;e;)(t=Ve-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ge}function lo(){Ve=(Dt=at.now())+Ft,Ge=nt=0;try{pl()}finally{Ge=0,yl(),Ve=0}}function ml(){var e=at.now(),t=e-Dt;t>Sr&&(Ft-=t,Dt=e)}function yl(){for(var e,t=Tt,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Tt=n);ot=e,mn(o)}function mn(e){if(!Ge){nt&&(nt=clearTimeout(nt));var t=e-Ve;t>24?(e<1/0&&(nt=setTimeout(lo,e-at.now()-Ft)),et&&(et=clearInterval(et))):(et||(Dt=at.now(),et=setInterval(ml,Sr)),Ge=1,Er(lo))}}function uo(e,t,n){var o=new $t;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var xl=Ot("start","end","cancel","interrupt"),wl=[],Nr=0,fo=1,yn=2,It=3,ho=4,xn=5,kt=6;function Xt(e,t,n,o,r,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;vl(e,n,{name:t,index:o,group:r,on:xl,tween:wl,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Nr})}function An(e,t){var n=Se(e,t);if(n.state>Nr)throw new Error("too late; already scheduled");return n}function Ce(e,t){var n=Se(e,t);if(n.state>It)throw new Error("too late; already running");return n}function Se(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function vl(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=Cr(i,0,n.time);function i(c){n.state=fo,n.timer.restart(s,n.delay,n.time),n.delay<=c&&s(c-n.delay)}function s(c){var u,f,d,h;if(n.state!==fo)return l();for(u in o)if(h=o[u],h.name===n.name){if(h.state===It)return uo(s);h.state===ho?(h.state=kt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete o[u]):+u<t&&(h.state=kt,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete o[u])}if(uo(function(){n.state===It&&(n.state=ho,n.timer.restart(a,n.delay,n.time),a(c))}),n.state=yn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===yn){for(n.state=It,r=new Array(d=n.tween.length),u=0,f=-1;u<d;++u)(h=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(r[++f]=h);r.length=f+1}}function a(c){for(var u=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(l),n.state=xn,1),f=-1,d=r.length;++f<d;)r[f].call(e,u);n.state===xn&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=kt,n.timer.stop(),delete o[t];for(var c in o)return;delete e.__transition}}function At(e,t){var n=e.__transition,o,r,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((o=n[s]).name!==t){i=!1;continue}r=o.state>yn&&o.state<xn,o.state=kt,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[s]}i&&delete e.__transition}}function _l(e){return this.each(function(){At(this,e)})}function bl(e,t){var n,o;return function(){var r=Ce(this,e),i=r.tween;if(i!==n){o=n=i;for(var s=0,a=o.length;s<a;++s)if(o[s].name===t){o=o.slice(),o.splice(s,1);break}}r.tween=o}}function Sl(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var i=Ce(this,e),s=i.tween;if(s!==o){r=(o=s).slice();for(var a={name:t,value:n},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=a;break}l===c&&r.push(a)}i.tween=r}}function El(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=Se(this.node(),n).tween,r=0,i=o.length,s;r<i;++r)if((s=o[r]).name===e)return s.value;return null}return this.each((t==null?bl:Sl)(n,e,t))}function Pn(e,t,n){var o=e._id;return e.each(function(){var r=Ce(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return Se(r,o).value[t]}}function Mr(e,t){var n;return(typeof t=="number"?He:t instanceof ro?oo:(n=ro(t))?(t=n,oo):xa)(e,t)}function Cl(e){return function(){this.removeAttribute(e)}}function Nl(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Ml(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===o?i:i=t(o=s,n)}}function Il(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===o?i:i=t(o=s,n)}}function kl(e,t,n){var o,r,i;return function(){var s,a=n(this),l;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),l=a+"",s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a)))}}function Al(e,t,n){var o,r,i;return function(){var s,a=n(this),l;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),l=a+"",s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a)))}}function Pl(e,t){var n=Bt(e),o=n==="transform"?ul:Mr;return this.attrTween(e,typeof t=="function"?(n.local?Al:kl)(n,o,Pn(this,"attr."+e,t)):t==null?(n.local?Nl:Cl)(n):(n.local?Il:Ml)(n,o,t))}function Tl(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Dl(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function $l(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Dl(e,i)),n}return r._value=t,r}function zl(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Tl(e,i)),n}return r._value=t,r}function Ll(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var o=Bt(e);return this.tween(n,(o.local?$l:zl)(o,t))}function Hl(e,t){return function(){An(this,e).delay=+t.apply(this,arguments)}}function Rl(e,t){return t=+t,function(){An(this,e).delay=t}}function jl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Hl:Rl)(t,e)):Se(this.node(),t).delay}function Vl(e,t){return function(){Ce(this,e).duration=+t.apply(this,arguments)}}function Ol(e,t){return t=+t,function(){Ce(this,e).duration=t}}function Bl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Vl:Ol)(t,e)):Se(this.node(),t).duration}function Fl(e,t){if(typeof t!="function")throw new Error;return function(){Ce(this,e).ease=t}}function Xl(e){var t=this._id;return arguments.length?this.each(Fl(t,e)):Se(this.node(),t).ease}function Yl(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ce(this,e).ease=n}}function Zl(e){if(typeof e!="function")throw new Error;return this.each(Yl(this._id,e))}function Wl(e){typeof e!="function"&&(e=cr(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new Ie(o,this._parents,this._name,this._id)}function Gl(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,i=Math.min(o,r),s=new Array(o),a=0;a<i;++a)for(var l=t[a],c=n[a],u=l.length,f=s[a]=new Array(u),d,h=0;h<u;++h)(d=l[h]||c[h])&&(f[h]=d);for(;a<o;++a)s[a]=t[a];return new Ie(s,this._parents,this._name,this._id)}function ql(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function Kl(e,t,n){var o,r,i=ql(t)?An:Ce;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}function Ul(e,t){var n=this._id;return arguments.length<2?Se(this.node(),n).on.on(e):this.each(Kl(n,e,t))}function Ql(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Jl(){return this.on("end.remove",Ql(this._id))}function eu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Mn(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s<r;++s)for(var a=o[s],l=a.length,c=i[s]=new Array(l),u,f,d=0;d<l;++d)(u=a[d])&&(f=e.call(u,u.__data__,d,a))&&("__data__"in u&&(f.__data__=u.__data__),c[d]=f,Xt(c[d],t,n,d,c,Se(u,n)));return new Ie(i,this._parents,t,n)}function tu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ar(e));for(var o=this._groups,r=o.length,i=[],s=[],a=0;a<r;++a)for(var l=o[a],c=l.length,u,f=0;f<c;++f)if(u=l[f]){for(var d=e.call(u,u.__data__,f,l),h,g=Se(u,n),v=0,_=d.length;v<_;++v)(h=d[v])&&Xt(h,t,n,v,d,g);i.push(d),s.push(u)}return new Ie(i,s,t,n)}var nu=ht.prototype.constructor;function ou(){return new nu(this._groups,this._parents)}function ru(e,t){var n,o,r;return function(){var i=We(this,e),s=(this.style.removeProperty(e),We(this,e));return i===s?null:i===n&&s===o?r:r=t(n=i,o=s)}}function Ir(e){return function(){this.style.removeProperty(e)}}function su(e,t,n){var o,r=n+"",i;return function(){var s=We(this,e);return s===r?null:s===o?i:i=t(o=s,n)}}function iu(e,t,n){var o,r,i;return function(){var s=We(this,e),a=n(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),We(this,e))),s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a))}}function au(e,t){var n,o,r,i="style."+t,s="end."+i,a;return function(){var l=Ce(this,e),c=l.on,u=l.value[i]==null?a||(a=Ir(t)):void 0;(c!==n||r!==u)&&(o=(n=c).copy()).on(s,r=u),l.on=o}}function cu(e,t,n){var o=(e+="")=="transform"?ll:Mr;return t==null?this.styleTween(e,ru(e,o)).on("end.style."+e,Ir(e)):typeof t=="function"?this.styleTween(e,iu(e,o,Pn(this,"style."+e,t))).each(au(this._id,e)):this.styleTween(e,su(e,o,t),n).on("end.style."+e,null)}function lu(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function uu(e,t,n){var o,r;function i(){var s=t.apply(this,arguments);return s!==r&&(o=(r=s)&&lu(e,s,n)),o}return i._value=t,i}function du(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,uu(e,t,n??""))}function fu(e){return function(){this.textContent=e}}function hu(e){return function(){var t=e(this);this.textContent=t??""}}function gu(e){return this.tween("text",typeof e=="function"?hu(Pn(this,"text",e)):fu(e==null?"":e+""))}function pu(e){return function(t){this.textContent=e.call(this,t)}}function mu(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&pu(r)),t}return o._value=e,o}function yu(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,mu(e))}function xu(){for(var e=this._name,t=this._id,n=kr(),o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,l,c=0;c<a;++c)if(l=s[c]){var u=Se(l,t);Xt(l,e,n,c,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Ie(o,this._parents,e,n)}function wu(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(i,s){var a={value:s},l={value:function(){--r===0&&i()}};n.each(function(){var c=Ce(this,o),u=c.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),c.on=t}),r===0&&i()})}var vu=0;function Ie(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function kr(){return++vu}var Ne=ht.prototype;Ie.prototype={constructor:Ie,select:eu,selectAll:tu,selectChild:Ne.selectChild,selectChildren:Ne.selectChildren,filter:Wl,merge:Gl,selection:ou,transition:xu,call:Ne.call,nodes:Ne.nodes,node:Ne.node,size:Ne.size,empty:Ne.empty,each:Ne.each,on:Ul,attr:Pl,attrTween:Ll,style:cu,styleTween:du,text:gu,textTween:yu,remove:Jl,tween:El,delay:jl,duration:Bl,ease:Xl,easeVarying:Zl,end:wu,[Symbol.iterator]:Ne[Symbol.iterator]};function _u(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var bu={time:null,delay:0,duration:250,ease:_u};function Su(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Eu(e){var t,n;e instanceof Ie?(t=e._id,e=e._name):(t=kr(),(n=bu).time=kn(),e=e==null?null:e+"");for(var o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&Xt(l,e,t,c,s,n||Su(l,t));return new Ie(o,this._parents,e,t)}ht.prototype.interrupt=_l;ht.prototype.transition=Eu;const vt=e=>()=>e;function Cu(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function Me(e,t,n){this.k=e,this.x=t,this.y=n}Me.prototype={constructor:Me,scale:function(e){return e===1?this:new Me(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Me(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Yt=new Me(1,0,0);Ar.prototype=Me.prototype;function Ar(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Yt;return e.__zoom}function sn(e){e.stopImmediatePropagation()}function tt(e){e.preventDefault(),e.stopImmediatePropagation()}function Nu(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Mu(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function go(){return this.__zoom||Yt}function Iu(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function ku(){return navigator.maxTouchPoints||"ontouchstart"in this}function Au(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function Pr(){var e=Nu,t=Mu,n=Au,o=Iu,r=ku,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,l=Mt,c=Ot("start","zoom","end"),u,f,d,h=500,g=150,v=0,_=10;function y(x){x.property("__zoom",go).on("wheel.zoom",T,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",O).filter(r).on("touchstart.zoom",k).on("touchmove.zoom",$).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(x,M,C,A){var I=x.selection?x.selection():x;I.property("__zoom",go),x!==I?N(x,M,C,A):I.interrupt().each(function(){S(this,arguments).event(A).start().zoom(null,typeof M=="function"?M.apply(this,arguments):M).end()})},y.scaleBy=function(x,M,C,A){y.scaleTo(x,function(){var I=this.__zoom.k,D=typeof M=="function"?M.apply(this,arguments):M;return I*D},C,A)},y.scaleTo=function(x,M,C,A){y.transform(x,function(){var I=t.apply(this,arguments),D=this.__zoom,H=C==null?w(I):typeof C=="function"?C.apply(this,arguments):C,V=D.invert(H),R=typeof M=="function"?M.apply(this,arguments):M;return n(p(b(D,R),H,V),I,s)},C,A)},y.translateBy=function(x,M,C,A){y.transform(x,function(){return n(this.__zoom.translate(typeof M=="function"?M.apply(this,arguments):M,typeof C=="function"?C.apply(this,arguments):C),t.apply(this,arguments),s)},null,A)},y.translateTo=function(x,M,C,A,I){y.transform(x,function(){var D=t.apply(this,arguments),H=this.__zoom,V=A==null?w(D):typeof A=="function"?A.apply(this,arguments):A;return n(Yt.translate(V[0],V[1]).scale(H.k).translate(typeof M=="function"?-M.apply(this,arguments):-M,typeof C=="function"?-C.apply(this,arguments):-C),D,s)},A,I)};function b(x,M){return M=Math.max(i[0],Math.min(i[1],M)),M===x.k?x:new Me(M,x.x,x.y)}function p(x,M,C){var A=M[0]-C[0]*x.k,I=M[1]-C[1]*x.k;return A===x.x&&I===x.y?x:new Me(x.k,A,I)}function w(x){return[(+x[0][0]+ +x[1][0])/2,(+x[0][1]+ +x[1][1])/2]}function N(x,M,C,A){x.on("start.zoom",function(){S(this,arguments).event(A).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(A).end()}).tween("zoom",function(){var I=this,D=arguments,H=S(I,D).event(A),V=t.apply(I,D),R=C==null?w(V):typeof C=="function"?C.apply(I,D):C,j=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),F=I.__zoom,W=typeof M=="function"?M.apply(I,D):M,K=l(F.invert(R).concat(j/F.k),W.invert(R).concat(j/W.k));return function(X){if(X===1)X=W;else{var B=K(X),Y=j/B[2];X=new Me(Y,R[0]-B[0]*Y,R[1]-B[1]*Y)}H.zoom(null,X)}})}function S(x,M,C){return!C&&x.__zooming||new E(x,M)}function E(x,M){this.that=x,this.args=M,this.active=0,this.sourceEvent=null,this.extent=t.apply(x,M),this.taps=0}E.prototype={event:function(x){return x&&(this.sourceEvent=x),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(x,M){return this.mouse&&x!=="mouse"&&(this.mouse[1]=M.invert(this.mouse[0])),this.touch0&&x!=="touch"&&(this.touch0[1]=M.invert(this.touch0[0])),this.touch1&&x!=="touch"&&(this.touch1[1]=M.invert(this.touch1[0])),this.that.__zoom=M,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(x){var M=he(this.that).datum();c.call(x,this.that,new Cu(x,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:c}),M)}};function T(x,...M){if(!e.apply(this,arguments))return;var C=S(this,M).event(x),A=this.__zoom,I=Math.max(i[0],Math.min(i[1],A.k*Math.pow(2,o.apply(this,arguments)))),D=ve(x);if(C.wheel)(C.mouse[0][0]!==D[0]||C.mouse[0][1]!==D[1])&&(C.mouse[1]=A.invert(C.mouse[0]=D)),clearTimeout(C.wheel);else{if(A.k===I)return;C.mouse=[D,A.invert(D)],At(this),C.start()}tt(x),C.wheel=setTimeout(H,g),C.zoom("mouse",n(p(b(A,I),C.mouse[0],C.mouse[1]),C.extent,s));function H(){C.wheel=null,C.end()}}function P(x,...M){if(d||!e.apply(this,arguments))return;var C=x.currentTarget,A=S(this,M,!0).event(x),I=he(x.view).on("mousemove.zoom",R,!0).on("mouseup.zoom",j,!0),D=ve(x,C),H=x.clientX,V=x.clientY;xr(x.view),sn(x),A.mouse=[D,this.__zoom.invert(D)],At(this),A.start();function R(F){if(tt(F),!A.moved){var W=F.clientX-H,K=F.clientY-V;A.moved=W*W+K*K>v}A.event(F).zoom("mouse",n(p(A.that.__zoom,A.mouse[0]=ve(F,C),A.mouse[1]),A.extent,s))}function j(F){I.on("mousemove.zoom mouseup.zoom",null),wr(F.view,A.moved),tt(F),A.event(F).end()}}function O(x,...M){if(e.apply(this,arguments)){var C=this.__zoom,A=ve(x.changedTouches?x.changedTouches[0]:x,this),I=C.invert(A),D=C.k*(x.shiftKey?.5:2),H=n(p(b(C,D),A,I),t.apply(this,M),s);tt(x),a>0?he(this).transition().duration(a).call(N,H,A,x):he(this).call(y.transform,H,A,x)}}function k(x,...M){if(e.apply(this,arguments)){var C=x.touches,A=C.length,I=S(this,M,x.changedTouches.length===A).event(x),D,H,V,R;for(sn(x),H=0;H<A;++H)V=C[H],R=ve(V,this),R=[R,this.__zoom.invert(R),V.identifier],I.touch0?!I.touch1&&I.touch0[2]!==R[2]&&(I.touch1=R,I.taps=0):(I.touch0=R,D=!0,I.taps=1+!!u);u&&(u=clearTimeout(u)),D&&(I.taps<2&&(f=R[0],u=setTimeout(function(){u=null},h)),At(this),I.start())}}function $(x,...M){if(this.__zooming){var C=S(this,M).event(x),A=x.changedTouches,I=A.length,D,H,V,R;for(tt(x),D=0;D<I;++D)H=A[D],V=ve(H,this),C.touch0&&C.touch0[2]===H.identifier?C.touch0[0]=V:C.touch1&&C.touch1[2]===H.identifier&&(C.touch1[0]=V);if(H=C.that.__zoom,C.touch1){var j=C.touch0[0],F=C.touch0[1],W=C.touch1[0],K=C.touch1[1],X=(X=W[0]-j[0])*X+(X=W[1]-j[1])*X,B=(B=K[0]-F[0])*B+(B=K[1]-F[1])*B;H=b(H,Math.sqrt(X/B)),V=[(j[0]+W[0])/2,(j[1]+W[1])/2],R=[(F[0]+K[0])/2,(F[1]+K[1])/2]}else if(C.touch0)V=C.touch0[0],R=C.touch0[1];else return;C.zoom("touch",n(p(H,V,R),C.extent,s))}}function L(x,...M){if(this.__zooming){var C=S(this,M).event(x),A=x.changedTouches,I=A.length,D,H;for(sn(x),d&&clearTimeout(d),d=setTimeout(function(){d=null},h),D=0;D<I;++D)H=A[D],C.touch0&&C.touch0[2]===H.identifier?delete C.touch0:C.touch1&&C.touch1[2]===H.identifier&&delete C.touch1;if(C.touch1&&!C.touch0&&(C.touch0=C.touch1,delete C.touch1),C.touch0)C.touch0[1]=this.__zoom.invert(C.touch0[0]);else if(C.end(),C.taps===2&&(H=ve(H,this),Math.hypot(f[0]-H[0],f[1]-H[1])<_)){var V=he(this).on("dblclick.zoom");V&&V.apply(this,arguments)}}}return y.wheelDelta=function(x){return arguments.length?(o=typeof x=="function"?x:vt(+x),y):o},y.filter=function(x){return arguments.length?(e=typeof x=="function"?x:vt(!!x),y):e},y.touchable=function(x){return arguments.length?(r=typeof x=="function"?x:vt(!!x),y):r},y.extent=function(x){return arguments.length?(t=typeof x=="function"?x:vt([[+x[0][0],+x[0][1]],[+x[1][0],+x[1][1]]]),y):t},y.scaleExtent=function(x){return arguments.length?(i[0]=+x[0],i[1]=+x[1],y):[i[0],i[1]]},y.translateExtent=function(x){return arguments.length?(s[0][0]=+x[0][0],s[1][0]=+x[1][0],s[0][1]=+x[0][1],s[1][1]=+x[1][1],y):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},y.constrain=function(x){return arguments.length?(n=x,y):n},y.duration=function(x){return arguments.length?(a=+x,y):a},y.interpolate=function(x){return arguments.length?(l=x,y):l},y.on=function(){var x=c.on.apply(c,arguments);return x===c?y:x},y.clickDistance=function(x){return arguments.length?(v=(x=+x)*x,y):Math.sqrt(v)},y.tapDistance=function(x){return arguments.length?(_=+x,y):_},y}const Ee={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},ct=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Tr=["Enter"," ","Escape"],Dr={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var qe;(function(e){e.Strict="strict",e.Loose="loose"})(qe||(qe={}));var je;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(je||(je={}));var lt;(function(e){e.Partial="partial",e.Full="full"})(lt||(lt={}));const $r={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var De;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(De||(De={}));var zt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(zt||(zt={}));var Z;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Z||(Z={}));const po={[Z.Left]:Z.Right,[Z.Right]:Z.Left,[Z.Top]:Z.Bottom,[Z.Bottom]:Z.Top};function zr(e){return e===null?null:e?"valid":"invalid"}const Lr=e=>"id"in e&&"source"in e&&"target"in e,Pu=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Tn=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),gt=(e,t=[0,0])=>{const{width:n,height:o}=ke(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},Tu=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,r)=>{const i=typeof r=="string";let s=!t.nodeLookup&&!i?r:void 0;t.nodeLookup&&(s=i?t.nodeLookup.get(r):Tn(r)?r:t.nodeLookup.get(r.id));const a=s?Lt(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Zt(o,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Wt(n)},pt=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=Zt(n,Lt(r)),o=!0)}),o?Wt(n):{x:0,y:0,width:0,height:0}},Dn=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const a={...yt(t,[n,o,r]),width:t.width/r,height:t.height/r},l=[];for(const c of e.values()){const{measured:u,selectable:f=!0,hidden:d=!1}=c;if(s&&!f||d)continue;const h=u.width??c.width??c.initialWidth??null,g=u.height??c.height??c.initialHeight??null,v=ut(a,Ue(c)),_=(h??0)*(g??0),y=i&&v>0;(!c.internals.handleBounds||y||v>=_||c.dragging)&&l.push(c)}return l},Du=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function $u(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&(t?.includeHiddenNodes||!r.hidden)&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function zu({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return Promise.resolve(!0);const a=$u(e,s),l=pt(a),c=$n(l,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return await o.setViewport(c,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),Promise.resolve(!0)}function Hr({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:l,y:c}=a?a.internals.positionAbsolute:{x:0,y:0},u=s.origin??o;let f=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)i?.("005",Ee.error005());else{const h=a.measured.width,g=a.measured.height;h&&g&&(f=[[l,c],[l+h,c+g]])}else a&&Qe(s.extent)&&(f=[[s.extent[0][0]+l,s.extent[0][1]+c],[s.extent[1][0]+l,s.extent[1][1]+c]]);const d=Qe(f)?Oe(t,f,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&i?.("015",Ee.error015()),{position:{x:d.x-l+(s.measured.width??0)*u[0],y:d.y-c+(s.measured.height??0)*u[1]},positionAbsolute:d}}async function Lu({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map(d=>d.id)),s=[];for(const d of n){if(d.deletable===!1)continue;const h=i.has(d.id),g=!h&&d.parentId&&s.find(v=>v.id===d.parentId);(h||g)&&s.push(d)}const a=new Set(t.map(d=>d.id)),l=o.filter(d=>d.deletable!==!1),u=Du(s,l);for(const d of l)a.has(d.id)&&!u.find(g=>g.id===d.id)&&u.push(d);if(!r)return{edges:u,nodes:s};const f=await r({nodes:s,edges:u});return typeof f=="boolean"?f?{edges:u,nodes:s}:{edges:[],nodes:[]}:f}const Ke=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Oe=(e={x:0,y:0},t,n)=>({x:Ke(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Ke(e.y,t[0][1],t[1][1]-(n?.height??0))});function Rr(e,t,n){const{width:o,height:r}=ke(n),{x:i,y:s}=n.internals.positionAbsolute;return Oe(e,[[i,s],[i+o,s+r]],t)}const mo=(e,t,n)=>e<t?Ke(Math.abs(e-t),1,t)/t:e>n?-Ke(Math.abs(e-n),1,t)/t:0,jr=(e,t,n=15,o=40)=>{const r=mo(e.x,o,t.width-o)*n,i=mo(e.y,o,t.height-o)*n;return[r,i]},Zt=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),wn=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),Wt=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Ue=(e,t=[0,0])=>{const{x:n,y:o}=Tn(e)?e.internals.positionAbsolute:gt(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Lt=(e,t=[0,0])=>{const{x:n,y:o}=Tn(e)?e.internals.positionAbsolute:gt(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},Vr=(e,t)=>Wt(Zt(wn(e),wn(t))),ut=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},yo=e=>_e(e.width)&&_e(e.height)&&_e(e.x)&&_e(e.y),_e=e=>!isNaN(e)&&isFinite(e),Hu=(e,t)=>{},mt=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),yt=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-o)/r};return i?mt(a,s):a},Ht=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function Fe(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Ru(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Fe(e,n),r=Fe(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=Fe(e.top??e.y??0,n),r=Fe(e.bottom??e.y??0,n),i=Fe(e.left??e.x??0,t),s=Fe(e.right??e.x??0,t);return{top:o,right:s,bottom:r,left:i,x:i+s,y:o+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function ju(e,t,n,o,r,i){const{x:s,y:a}=Ht(e,[t,n,o]),{x:l,y:c}=Ht({x:e.x+e.width,y:e.y+e.height},[t,n,o]),u=r-l,f=i-c;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(u),bottom:Math.floor(f)}}const $n=(e,t,n,o,r,i)=>{const s=Ru(i,t,n),a=(t-s.x)/e.width,l=(n-s.y)/e.height,c=Math.min(a,l),u=Ke(c,o,r),f=e.x+e.width/2,d=e.y+e.height/2,h=t/2-f*u,g=n/2-d*u,v=ju(e,h,g,u,t,n),_={left:Math.min(v.left-s.left,0),top:Math.min(v.top-s.top,0),right:Math.min(v.right-s.right,0),bottom:Math.min(v.bottom-s.bottom,0)};return{x:h-_.left+_.right,y:g-_.top+_.bottom,zoom:u}},dt=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Qe(e){return e!=null&&e!=="parent"}function ke(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Or(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Br(e,t={width:0,height:0},n,o,r){const i={...e},s=o.get(n);if(s){const a=s.origin||r;i.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function xo(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Vu(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function Ou(e){return{...Dr,...e||{}}}function rt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:s}=be(e),a=yt({x:i-(r?.left??0),y:s-(r?.top??0)},o),{x:l,y:c}=n?mt(a,t):a;return{xSnapped:l,ySnapped:c,...a}}const zn=e=>({width:e.offsetWidth,height:e.offsetHeight}),Fr=e=>e?.getRootNode?.()||window?.document,Bu=["INPUT","SELECT","TEXTAREA"];function Xr(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:Bu.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Yr=e=>"clientX"in e,be=(e,t)=>{const n=Yr(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},wo=(e,t,n,o,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:r,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/o,y:(a.top-n.top)/o,...zn(s)}})};function Zr({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:a}){const l=e*.125+r*.375+s*.375+n*.125,c=t*.125+i*.375+a*.375+o*.125,u=Math.abs(l-e),f=Math.abs(c-t);return[l,c,u,f]}function _t(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function vo({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case Z.Left:return[t-_t(t-o,i),n];case Z.Right:return[t+_t(o-t,i),n];case Z.Top:return[t,n-_t(n-r,i)];case Z.Bottom:return[t,n+_t(r-n,i)]}}function Wr({sourceX:e,sourceY:t,sourcePosition:n=Z.Bottom,targetX:o,targetY:r,targetPosition:i=Z.Top,curvature:s=.25}){const[a,l]=vo({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[c,u]=vo({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[f,d,h,g]=Zr({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${e},${t} C${a},${l} ${c},${u} ${o},${r}`,f,d,h,g]}function Gr({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,s=Math.abs(o-t)/2,a=o<t?o+s:o-s;return[i,a,r,s]}function Fu({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1,zIndexMode:i="basic"}){if(i==="manual")return o;const s=r&&n?o+1e3:o,a=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return s+a}function Xu({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=Zt(Lt(e),Lt(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:o/r[2]};return ut(s,Wt(i))>0}const Yu=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,Zu=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Wu=(e,t,n={})=>{if(!e.source||!e.target)return t;const o=n.getEdgeId||Yu;let r;return Lr(e)?r={...e}:r={...e,id:o(e)},Zu(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function qr({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=Gr({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const _o={[Z.Left]:{x:-1,y:0},[Z.Right]:{x:1,y:0},[Z.Top]:{x:0,y:-1},[Z.Bottom]:{x:0,y:1}},Gu=({source:e,sourcePosition:t=Z.Bottom,target:n})=>t===Z.Left||t===Z.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},bo=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function qu({source:e,sourcePosition:t=Z.Bottom,target:n,targetPosition:o=Z.Top,center:r,offset:i,stepPosition:s}){const a=_o[t],l=_o[o],c={x:e.x+a.x*i,y:e.y+a.y*i},u={x:n.x+l.x*i,y:n.y+l.y*i},f=Gu({source:c,sourcePosition:t,target:u}),d=f.x!==0?"x":"y",h=f[d];let g=[],v,_;const y={x:0,y:0},b={x:0,y:0},[,,p,w]=Gr({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[d]*l[d]===-1){d==="x"?(v=r.x??c.x+(u.x-c.x)*s,_=r.y??(c.y+u.y)/2):(v=r.x??(c.x+u.x)/2,_=r.y??c.y+(u.y-c.y)*s);const S=[{x:v,y:c.y},{x:v,y:u.y}],E=[{x:c.x,y:_},{x:u.x,y:_}];a[d]===h?g=d==="x"?S:E:g=d==="x"?E:S}else{const S=[{x:c.x,y:u.y}],E=[{x:u.x,y:c.y}];if(d==="x"?g=a.x===h?E:S:g=a.y===h?S:E,t===o){const $=Math.abs(e[d]-n[d]);if($<=i){const L=Math.min(i-1,i-$);a[d]===h?y[d]=(c[d]>e[d]?-1:1)*L:b[d]=(u[d]>n[d]?-1:1)*L}}if(t!==o){const $=d==="x"?"y":"x",L=a[d]===l[$],x=c[$]>u[$],M=c[$]<u[$];(a[d]===1&&(!L&&x||L&&M)||a[d]!==1&&(!L&&M||L&&x))&&(g=d==="x"?S:E)}const T={x:c.x+y.x,y:c.y+y.y},P={x:u.x+b.x,y:u.y+b.y},O=Math.max(Math.abs(T.x-g[0].x),Math.abs(P.x-g[0].x)),k=Math.max(Math.abs(T.y-g[0].y),Math.abs(P.y-g[0].y));O>=k?(v=(T.x+P.x)/2,_=g[0].y):(v=g[0].x,_=(T.y+P.y)/2)}return[[e,{x:c.x+y.x,y:c.y+y.y},...g,{x:u.x+b.x,y:u.y+b.y},n],v,_,p,w]}function Ku(e,t,n,o){const r=Math.min(bo(e,t)/2,bo(t,n)/2,o),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const c=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${i+r*c},${s}Q ${i},${s} ${i},${s+r*u}`}const a=e.x<n.x?1:-1,l=e.y<n.y?-1:1;return`L ${i},${s+r*l}Q ${i},${s} ${i+r*a},${s}`}function vn({sourceX:e,sourceY:t,sourcePosition:n=Z.Bottom,targetX:o,targetY:r,targetPosition:i=Z.Top,borderRadius:s=5,centerX:a,centerY:l,offset:c=20,stepPosition:u=.5}){const[f,d,h,g,v]=qu({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:a,y:l},offset:c,stepPosition:u});return[f.reduce((y,b,p)=>{let w="";return p>0&&p<f.length-1?w=Ku(f[p-1],b,f[p+1],s):w=`${p===0?"M":"L"}${b.x} ${b.y}`,y+=w,y},""),d,h,g,v]}function So(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Uu(e){const{sourceNode:t,targetNode:n}=e;if(!So(t)||!So(n))return null;const o=t.internals.handleBounds||Eo(t.handles),r=n.internals.handleBounds||Eo(n.handles),i=Co(o?.source??[],e.sourceHandle),s=Co(e.connectionMode===qe.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!i||!s)return e.onError?.("008",Ee.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=i?.position||Z.Bottom,l=s?.position||Z.Top,c=Be(t,i,a),u=Be(n,s,l);return{sourceX:c.x,sourceY:c.y,targetX:u.x,targetY:u.y,sourcePosition:a,targetPosition:l}}function Eo(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function Be(e,t,n=Z.Left,o=!1){const r=(t?.x??0)+e.internals.positionAbsolute.x,i=(t?.y??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??ke(e);if(o)return{x:r+s/2,y:i+a/2};switch(t?.position??n){case Z.Top:return{x:r+s/2,y:i};case Z.Right:return{x:r+s,y:i+a/2};case Z.Bottom:return{x:r+s/2,y:i+a};case Z.Left:return{x:r,y:i+a/2}}}function Co(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function _n(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function Qu(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const i=new Set;return e.reduce((s,a)=>([a.markerStart||o,a.markerEnd||r].forEach(l=>{if(l&&typeof l=="object"){const c=_n(l,t);i.has(c)||(s.push({id:c,color:l.color||n,...l}),i.add(c))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const Kr=1e3,Ju=10,Ln={nodeOrigin:[0,0],nodeExtent:ct,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},ed={...Ln,checkEquality:!0};function Hn(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function td(e,t,n){const o=Hn(Ln,n);for(const r of e.values())if(r.parentId)jn(r,e,t,o);else{const i=gt(r,o.nodeOrigin),s=Qe(r.extent)?r.extent:o.nodeExtent,a=Oe(i,s,ke(r));r.internals.positionAbsolute=a}}function nd(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const r of e.handles){const i={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(i):r.type==="target"&&o.push(i)}return{source:n,target:o}}function Rn(e){return e==="manual"}function bn(e,t,n,o={}){const r=Hn(ed,o),i={i:0},s=new Map(t),a=r?.elevateNodesOnSelect&&!Rn(r.zIndexMode)?Kr:0;let l=e.length>0;t.clear(),n.clear();for(const c of e){let u=s.get(c.id);if(r.checkEquality&&c===u?.internals.userNode)t.set(c.id,u);else{const f=gt(c,r.nodeOrigin),d=Qe(c.extent)?c.extent:r.nodeExtent,h=Oe(f,d,ke(c));u={...r.defaults,...c,measured:{width:c.measured?.width,height:c.measured?.height},internals:{positionAbsolute:h,handleBounds:nd(c,u),z:Ur(c,a,r.zIndexMode),userNode:c}},t.set(c.id,u)}(u.measured===void 0||u.measured.width===void 0||u.measured.height===void 0)&&!u.hidden&&(l=!1),c.parentId&&jn(u,t,n,o,i)}return l}function od(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function jn(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:l}=Hn(Ln,o),c=e.parentId,u=t.get(c);if(!u){console.warn(`Parent node ${c} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}od(e,n),r&&!u.parentId&&u.internals.rootParentIndex===void 0&&l==="auto"&&(u.internals.rootParentIndex=++r.i,u.internals.z=u.internals.z+r.i*Ju),r&&u.internals.rootParentIndex!==void 0&&(r.i=u.internals.rootParentIndex);const f=i&&!Rn(l)?Kr:0,{x:d,y:h,z:g}=rd(e,u,s,a,f,l),{positionAbsolute:v}=e.internals,_=d!==v.x||h!==v.y;(_||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:_?{x:d,y:h}:v,z:g}})}function Ur(e,t,n){const o=_e(e.zIndex)?e.zIndex:0;return Rn(n)?o:o+(e.selected?t:0)}function rd(e,t,n,o,r,i){const{x:s,y:a}=t.internals.positionAbsolute,l=ke(e),c=gt(e,n),u=Qe(e.extent)?Oe(c,e.extent,l):c;let f=Oe({x:s+u.x,y:a+u.y},o,l);e.extent==="parent"&&(f=Rr(f,l,t));const d=Ur(e,r,i),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=d?h+1:d}}function Vn(e,t,n,o=[0,0]){const r=[],i=new Map;for(const s of e){const a=t.get(s.parentId);if(!a)continue;const l=i.get(s.parentId)?.expandedRect??Ue(a),c=Vr(l,s.rect);i.set(s.parentId,{expandedRect:c,parent:a})}return i.size>0&&i.forEach(({expandedRect:s,parent:a},l)=>{const c=a.internals.positionAbsolute,u=ke(a),f=a.origin??o,d=s.x<c.x?Math.round(Math.abs(c.x-s.x)):0,h=s.y<c.y?Math.round(Math.abs(c.y-s.y)):0,g=Math.max(u.width,Math.round(s.width)),v=Math.max(u.height,Math.round(s.height)),_=(g-u.width)*f[0],y=(v-u.height)*f[1];(d>0||h>0||_||y)&&(r.push({id:l,type:"position",position:{x:a.position.x-d+_,y:a.position.y-h+y}}),n.get(l)?.forEach(b=>{e.some(p=>p.id===b.id)||r.push({id:b.id,type:"position",position:{x:b.position.x+d,y:b.position.y+h}})})),(u.width<s.width||u.height<s.height||d||h)&&r.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:g+(d?f[0]*d-_:0),height:v+(h?f[1]*h-y:0)}})}),r}function sd(e,t,n,o,r,i,s){const a=o?.querySelector(".xyflow__viewport");let l=!1;if(!a)return{changes:[],updatedInternals:l};const c=[],u=window.getComputedStyle(a),{m22:f}=new window.DOMMatrixReadOnly(u.transform),d=[];for(const h of e.values()){const g=t.get(h.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),l=!0;continue}const v=zn(h.nodeElement),_=g.measured.width!==v.width||g.measured.height!==v.height;if(!!(v.width&&v.height&&(_||!g.internals.handleBounds||h.force))){const b=h.nodeElement.getBoundingClientRect(),p=Qe(g.extent)?g.extent:i;let{positionAbsolute:w}=g.internals;g.parentId&&g.extent==="parent"?w=Rr(w,v,t.get(g.parentId)):p&&(w=Oe(w,p,v));const N={...g,measured:v,internals:{...g.internals,positionAbsolute:w,handleBounds:{source:wo("source",h.nodeElement,b,f,g.id),target:wo("target",h.nodeElement,b,f,g.id)}}};t.set(g.id,N),g.parentId&&jn(N,t,n,{nodeOrigin:r,zIndexMode:s}),l=!0,_&&(c.push({id:g.id,type:"dimensions",dimensions:v}),g.expandParent&&g.parentId&&d.push({id:g.id,parentId:g.parentId,rect:Ue(N,r)}))}}if(d.length>0){const h=Vn(d,t,n,r);c.push(...h)}return{changes:c,updatedInternals:l}}async function id({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o),a=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(a)}function No(e,t,n,o,r,i){let s=r;const a=o.get(s)||new Map;o.set(s,a.set(n,t)),s=`${r}-${e}`;const l=o.get(s)||new Map;if(o.set(s,l.set(n,t)),i){s=`${r}-${e}-${i}`;const c=o.get(s)||new Map;o.set(s,c.set(n,t))}}function Qr(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:i,sourceHandle:s=null,targetHandle:a=null}=o,l={edgeId:o.id,source:r,target:i,sourceHandle:s,targetHandle:a},c=`${r}-${s}--${i}-${a}`,u=`${i}-${a}--${r}-${s}`;No("source",l,u,e,r,s),No("target",l,c,e,i,a),t.set(o.id,o)}}function Jr(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Jr(n,t):!1}function Mo(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function ad(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!Jr(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(i);a&&r.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return r}function an({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[s,a]of t){const l=n.get(s)?.internals.userNode;l&&r.push({...l,position:a.position,dragging:o})}if(!e)return[r[0],r];const i=n.get(e)?.internals.userNode;return[i?{...i,position:t.get(e)?.position||i.position,dragging:o}:r[0],r]}function cd({dragItems:e,snapGrid:t,x:n,y:o}){const r=e.values().next().value;if(!r)return null;const i={x:n-r.distance.x,y:o-r.distance.y},s=mt(i,t);return{x:s.x-i.x,y:s.y-i.y}}function ld({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,a=new Map,l=!1,c={x:0,y:0},u=null,f=!1,d=null,h=!1,g=!1,v=null;function _({noDragClassName:b,handleSelector:p,domNode:w,isSelectable:N,nodeId:S,nodeClickDistance:E=0}){d=he(w);function T({x:$,y:L}){const{nodeLookup:x,nodeExtent:M,snapGrid:C,snapToGrid:A,nodeOrigin:I,onNodeDrag:D,onSelectionDrag:H,onError:V,updateNodePositions:R}=t();i={x:$,y:L};let j=!1;const F=a.size>1,W=F&&M?wn(pt(a)):null,K=F&&A?cd({dragItems:a,snapGrid:C,x:$,y:L}):null;for(const[X,B]of a){if(!x.has(X))continue;let Y={x:$-B.distance.x,y:L-B.distance.y};A&&(Y=K?{x:Math.round(Y.x+K.x),y:Math.round(Y.y+K.y)}:mt(Y,C));let U=null;if(F&&M&&!B.extent&&W){const{positionAbsolute:q}=B.internals,J=q.x-W.x+M[0][0],ne=q.x+B.measured.width-W.x2+M[1][0],te=q.y-W.y+M[0][1],se=q.y+B.measured.height-W.y2+M[1][1];U=[[J,te],[ne,se]]}const{position:Q,positionAbsolute:G}=Hr({nodeId:X,nextPosition:Y,nodeLookup:x,nodeExtent:U||M,nodeOrigin:I,onError:V});j=j||B.position.x!==Q.x||B.position.y!==Q.y,B.position=Q,B.internals.positionAbsolute=G}if(g=g||j,!!j&&(R(a,!0),v&&(o||D||!S&&H))){const[X,B]=an({nodeId:S,dragItems:a,nodeLookup:x});o?.(v,a,X,B),D?.(v,X,B),S||H?.(v,B)}}async function P(){if(!u)return;const{transform:$,panBy:L,autoPanSpeed:x,autoPanOnNodeDrag:M}=t();if(!M){l=!1,cancelAnimationFrame(s);return}const[C,A]=jr(c,u,x);(C!==0||A!==0)&&(i.x=(i.x??0)-C/$[2],i.y=(i.y??0)-A/$[2],await L({x:C,y:A})&&T(i)),s=requestAnimationFrame(P)}function O($){const{nodeLookup:L,multiSelectionActive:x,nodesDraggable:M,transform:C,snapGrid:A,snapToGrid:I,selectNodesOnDrag:D,onNodeDragStart:H,onSelectionDragStart:V,unselectNodesAndEdges:R}=t();f=!0,(!D||!N)&&!x&&S&&(L.get(S)?.selected||R()),N&&D&&S&&e?.(S);const j=rt($.sourceEvent,{transform:C,snapGrid:A,snapToGrid:I,containerBounds:u});if(i=j,a=ad(L,M,j,S),a.size>0&&(n||H||!S&&V)){const[F,W]=an({nodeId:S,dragItems:a,nodeLookup:L});n?.($.sourceEvent,a,F,W),H?.($.sourceEvent,F,W),S||V?.($.sourceEvent,W)}}const k=vr().clickDistance(E).on("start",$=>{const{domNode:L,nodeDragThreshold:x,transform:M,snapGrid:C,snapToGrid:A}=t();u=L?.getBoundingClientRect()||null,h=!1,g=!1,v=$.sourceEvent,x===0&&O($),i=rt($.sourceEvent,{transform:M,snapGrid:C,snapToGrid:A,containerBounds:u}),c=be($.sourceEvent,u)}).on("drag",$=>{const{autoPanOnNodeDrag:L,transform:x,snapGrid:M,snapToGrid:C,nodeDragThreshold:A,nodeLookup:I}=t(),D=rt($.sourceEvent,{transform:x,snapGrid:M,snapToGrid:C,containerBounds:u});if(v=$.sourceEvent,($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1||S&&!I.has(S))&&(h=!0),!h){if(!l&&L&&f&&(l=!0,P()),!f){const H=be($.sourceEvent,u),V=H.x-c.x,R=H.y-c.y;Math.sqrt(V*V+R*R)>A&&O($)}(i.x!==D.xSnapped||i.y!==D.ySnapped)&&a&&f&&(c=be($.sourceEvent,u),T(D))}}).on("end",$=>{if(!(!f||h)&&(l=!1,f=!1,cancelAnimationFrame(s),a.size>0)){const{nodeLookup:L,updateNodePositions:x,onNodeDragStop:M,onSelectionDragStop:C}=t();if(g&&(x(a,!1),g=!1),r||M||!S&&C){const[A,I]=an({nodeId:S,dragItems:a,nodeLookup:L,dragging:!1});r?.($.sourceEvent,a,A,I),M?.($.sourceEvent,A,I),S||C?.($.sourceEvent,I)}}}).filter($=>{const L=$.target;return!$.button&&(!b||!Mo(L,`.${b}`,w))&&(!p||Mo(L,p,w))});d.call(k)}function y(){d?.on(".drag",null)}return{update:_,destroy:y}}function ud(e,t,n){const o=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())ut(r,Ue(i))>0&&o.push(i);return o}const dd=250;function fd(e,t,n,o){let r=[],i=1/0;const s=ud(e,n,t+dd);for(const a of s){const l=[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]];for(const c of l){if(o.nodeId===c.nodeId&&o.type===c.type&&o.id===c.id)continue;const{x:u,y:f}=Be(a,c,c.position,!0),d=Math.sqrt(Math.pow(u-e.x,2)+Math.pow(f-e.y,2));d>t||(d<i?(r=[{...c,x:u,y:f}],i=d):d===i&&r.push({...c,x:u,y:f}))}}if(!r.length)return null;if(r.length>1){const a=o.type==="source"?"target":"source";return r.find(l=>l.type===a)??r[0]}return r[0]}function es(e,t,n,o,r,i=!1){const s=o.get(e);if(!s)return null;const a=r==="strict"?s.internals.handleBounds?.[t]:[...s.internals.handleBounds?.source??[],...s.internals.handleBounds?.target??[]],l=(n?a?.find(c=>c.id===n):a?.[0])??null;return l&&i?{...l,...Be(s,l,l.position,!0)}:l}function ts(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function hd(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const ns=()=>!0;function gd(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:l,lib:c,autoPanOnConnect:u,flowId:f,panBy:d,cancelConnection:h,onConnectStart:g,onConnect:v,onConnectEnd:_,isValidConnection:y=ns,onReconnectEnd:b,updateConnection:p,getTransform:w,getFromHandle:N,autoPanSpeed:S,dragThreshold:E=1,handleDomNode:T}){const P=Fr(e.target);let O=0,k;const{x:$,y:L}=be(e),x=ts(i,T),M=a?.getBoundingClientRect();let C=!1;if(!M||!x)return;const A=es(r,x,o,l,t);if(!A)return;let I=be(e,M),D=!1,H=null,V=!1,R=null;function j(){if(!u||!M)return;const[Q,G]=jr(I,M,S);d({x:Q,y:G}),O=requestAnimationFrame(j)}const F={...A,nodeId:r,type:x,position:A.position},W=l.get(r);let X={inProgress:!0,isValid:null,from:Be(W,F,Z.Left,!0),fromHandle:F,fromPosition:F.position,fromNode:W,to:I,toHandle:null,toPosition:po[F.position],toNode:null,pointer:I};function B(){C=!0,p(X),g?.(e,{nodeId:r,handleId:o,handleType:x})}E===0&&B();function Y(Q){if(!C){const{x:se,y:fe}=be(Q),ue=se-$,de=fe-L;if(!(ue*ue+de*de>E*E))return;B()}if(!N()||!F){U(Q);return}const G=w();I=be(Q,M),k=fd(yt(I,G,!1,[1,1]),n,l,F),D||(j(),D=!0);const q=os(Q,{handle:k,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:y,doc:P,lib:c,flowId:f,nodeLookup:l});R=q.handleDomNode,H=q.connection,V=hd(!!k,q.isValid);const J=l.get(r),ne=J?Be(J,F,Z.Left,!0):X.from,te={...X,from:ne,isValid:V,to:q.toHandle&&V?Ht({x:q.toHandle.x,y:q.toHandle.y},G):I,toHandle:q.toHandle,toPosition:V&&q.toHandle?q.toHandle.position:po[F.position],toNode:q.toHandle?l.get(q.toHandle.nodeId):null,pointer:I};p(te),X=te}function U(Q){if(!("touches"in Q&&Q.touches.length>0)){if(C){(k||R)&&H&&V&&v?.(H);const{inProgress:G,...q}=X,J={...q,toPosition:X.toHandle?X.toPosition:null};_?.(Q,J),i&&b?.(Q,J)}h(),cancelAnimationFrame(O),D=!1,V=!1,H=null,R=null,P.removeEventListener("mousemove",Y),P.removeEventListener("mouseup",U),P.removeEventListener("touchmove",Y),P.removeEventListener("touchend",U)}}P.addEventListener("mousemove",Y),P.addEventListener("mouseup",U),P.addEventListener("touchmove",Y),P.addEventListener("touchend",U)}function os(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:a,flowId:l,isValidConnection:c=ns,nodeLookup:u}){const f=i==="target",d=t?s.querySelector(`.${a}-flow__handle[data-id="${l}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:g}=be(e),v=s.elementFromPoint(h,g),_=v?.classList.contains(`${a}-flow__handle`)?v:d,y={handleDomNode:_,isValid:!1,connection:null,toHandle:null};if(_){const b=ts(void 0,_),p=_.getAttribute("data-nodeid"),w=_.getAttribute("data-handleid"),N=_.classList.contains("connectable"),S=_.classList.contains("connectableend");if(!p||!b)return y;const E={source:f?p:o,sourceHandle:f?w:r,target:f?o:p,targetHandle:f?r:w};y.connection=E;const P=N&&S&&(n===qe.Strict?f&&b==="source"||!f&&b==="target":p!==o||w!==r);y.isValid=P&&c(E),y.toHandle=es(p,b,w,u,n,!0)}return y}const Sn={onPointerDown:gd,isValid:os};function pd({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=he(e);function i({translateExtent:a,width:l,height:c,zoomStep:u=1,pannable:f=!0,zoomable:d=!0,inversePan:h=!1}){const g=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const w=n(),N=p.sourceEvent.ctrlKey&&dt()?10:1,S=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*u,E=w[2]*Math.pow(2,S*N);t.scaleTo(E)};let v=[0,0];const _=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(v=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},y=p=>{const w=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const N=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],S=[N[0]-v[0],N[1]-v[1]];v=N;const E=o()*Math.max(w[2],Math.log(w[2]))*(h?-1:1),T={x:w[0]-S[0]*E,y:w[1]-S[1]*E},P=[[0,0],[l,c]];t.setViewportConstrained({x:T.x,y:T.y,zoom:w[2]},P,a)},b=Pr().on("start",_).on("zoom",f?y:null).on("zoom.wheel",d?g:null);r.call(b,{})}function s(){r.on("zoom",null)}return{update:i,destroy:s,pointer:ve}}const Gt=e=>({x:e.x,y:e.y,zoom:e.k}),cn=({x:e,y:t,zoom:n})=>Yt.translate(e,t).scale(n),Xe=(e,t)=>e.target.closest(`.${t}`),rs=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),md=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,ln=(e,t=0,n=md,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},ss=e=>{const t=e.ctrlKey&&dt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function yd({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:l,onPanZoomEnd:c}){return u=>{if(Xe(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(u.ctrlKey&&s){const _=ve(u),y=ss(u),b=f*Math.pow(2,y);o.scaleTo(n,b,_,u);return}const d=u.deltaMode===1?20:1;let h=r===je.Vertical?0:u.deltaX*d,g=r===je.Horizontal?0:u.deltaY*d;!dt()&&u.shiftKey&&r!==je.Vertical&&(h=u.deltaY*d,g=0),o.translateBy(n,-(h/f)*i,-(g/f)*i,{internal:!0});const v=Gt(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(l?.(u,v),e.panScrollTimeout=setTimeout(()=>{c?.(u,v),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a?.(u,v))}}function xd({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const i=o.type==="wheel",s=!t&&i&&!o.ctrlKey,a=Xe(o,e);if(o.ctrlKey&&i&&a&&o.preventDefault(),s||a)return null;o.preventDefault(),n.call(this,o,r)}}function wd({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=Gt(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,r)}}function vd({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&rs(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,Gt(i.transform))}}function _d({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&rs(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const a=Gt(s.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(s.sourceEvent,a)},n?150:0)}}}function bd({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:a,noPanClassName:l,lib:c,connectionInProgress:u}){return f=>{const d=e||t,h=n&&f.ctrlKey,g=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(Xe(f,`${c}-flow__node`)||Xe(f,`${c}-flow__edge`)))return!0;if(!o&&!d&&!r&&!i&&!n||s||u&&!g||Xe(f,a)&&g||Xe(f,l)&&(!g||r&&g&&!e)||!n&&f.ctrlKey&&g)return!1;if(!n&&f.type==="touchstart"&&f.touches?.length>1)return f.preventDefault(),!1;if(!d&&!r&&!h&&g||!o&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(o)&&!o.includes(f.button)&&f.type==="mousedown")return!1;const v=Array.isArray(o)&&o.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||g)&&v}}function Sd({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:l}){const c={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),f=Pr().scaleExtent([t,n]).translateExtent(o),d=he(e).call(f);b({x:r.x,y:r.y,zoom:Ke(r.zoom,t,n)},[[0,0],[u.width,u.height]],o);const h=d.on("wheel.zoom"),g=d.on("dblclick.zoom");f.wheelDelta(ss);function v(k,$){return d?new Promise(L=>{f?.interpolate($?.interpolate==="linear"?nn:Mt).transform(ln(d,$?.duration,$?.ease,()=>L(!0)),k)}):Promise.resolve(!1)}function _({noWheelClassName:k,noPanClassName:$,onPaneContextMenu:L,userSelectionActive:x,panOnScroll:M,panOnDrag:C,panOnScrollMode:A,panOnScrollSpeed:I,preventScrolling:D,zoomOnPinch:H,zoomOnScroll:V,zoomOnDoubleClick:R,zoomActivationKeyPressed:j,lib:F,onTransformChange:W,connectionInProgress:K,paneClickDistance:X,selectionOnDrag:B}){x&&!c.isZoomingOrPanning&&y();const Y=M&&!j&&!x;f.clickDistance(B?1/0:!_e(X)||X<0?0:X);const U=Y?yd({zoomPanValues:c,noWheelClassName:k,d3Selection:d,d3Zoom:f,panOnScrollMode:A,panOnScrollSpeed:I,zoomOnPinch:H,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):xd({noWheelClassName:k,preventScrolling:D,d3ZoomHandler:h});if(d.on("wheel.zoom",U,{passive:!1}),!x){const G=wd({zoomPanValues:c,onDraggingChange:l,onPanZoomStart:s});f.on("start",G);const q=vd({zoomPanValues:c,panOnDrag:C,onPaneContextMenu:!!L,onPanZoom:i,onTransformChange:W});f.on("zoom",q);const J=_d({zoomPanValues:c,panOnDrag:C,panOnScroll:M,onPaneContextMenu:L,onPanZoomEnd:a,onDraggingChange:l});f.on("end",J)}const Q=bd({zoomActivationKeyPressed:j,panOnDrag:C,zoomOnScroll:V,panOnScroll:M,zoomOnDoubleClick:R,zoomOnPinch:H,userSelectionActive:x,noPanClassName:$,noWheelClassName:k,lib:F,connectionInProgress:K});f.filter(Q),R?d.on("dblclick.zoom",g):d.on("dblclick.zoom",null)}function y(){f.on("zoom",null)}async function b(k,$,L){const x=cn(k),M=f?.constrain()(x,$,L);return M&&await v(M),new Promise(C=>C(M))}async function p(k,$){const L=cn(k);return await v(L,$),new Promise(x=>x(L))}function w(k){if(d){const $=cn(k),L=d.property("__zoom");(L.k!==k.zoom||L.x!==k.x||L.y!==k.y)&&f?.transform(d,$,null,{sync:!0})}}function N(){const k=d?Ar(d.node()):{x:0,y:0,k:1};return{x:k.x,y:k.y,zoom:k.k}}function S(k,$){return d?new Promise(L=>{f?.interpolate($?.interpolate==="linear"?nn:Mt).scaleTo(ln(d,$?.duration,$?.ease,()=>L(!0)),k)}):Promise.resolve(!1)}function E(k,$){return d?new Promise(L=>{f?.interpolate($?.interpolate==="linear"?nn:Mt).scaleBy(ln(d,$?.duration,$?.ease,()=>L(!0)),k)}):Promise.resolve(!1)}function T(k){f?.scaleExtent(k)}function P(k){f?.translateExtent(k)}function O(k){const $=!_e(k)||k<0?0:k;f?.clickDistance($)}return{update:_,destroy:y,setViewport:p,setViewportConstrained:b,getViewport:N,scaleTo:S,scaleBy:E,setScaleExtent:T,setTranslateExtent:P,syncViewport:w,setClickDistance:O}}var Je;(function(e){e.Line="line",e.Handle="handle"})(Je||(Je={}));function Ed({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,a=n-o,l=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(l[0]=l[0]*-1),a&&i&&(l[1]=l[1]*-1),l}function Io(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:r}}function Pe(e,t){return Math.max(0,t-e)}function Te(e,t){return Math.max(0,e-t)}function bt(e,t,n){return Math.max(0,t-e,e-n)}function ko(e,t){return e?!t:t}function Cd(e,t,n,o,r,i,s,a){let{affectsX:l,affectsY:c}=t;const{isHorizontal:u,isVertical:f}=t,d=u&&f,{xSnapped:h,ySnapped:g}=n,{minWidth:v,maxWidth:_,minHeight:y,maxHeight:b}=o,{x:p,y:w,width:N,height:S,aspectRatio:E}=e;let T=Math.floor(u?h-e.pointerX:0),P=Math.floor(f?g-e.pointerY:0);const O=N+(l?-T:T),k=S+(c?-P:P),$=-i[0]*N,L=-i[1]*S;let x=bt(O,v,_),M=bt(k,y,b);if(s){let I=0,D=0;l&&T<0?I=Pe(p+T+$,s[0][0]):!l&&T>0&&(I=Te(p+O+$,s[1][0])),c&&P<0?D=Pe(w+P+L,s[0][1]):!c&&P>0&&(D=Te(w+k+L,s[1][1])),x=Math.max(x,I),M=Math.max(M,D)}if(a){let I=0,D=0;l&&T>0?I=Te(p+T,a[0][0]):!l&&T<0&&(I=Pe(p+O,a[1][0])),c&&P>0?D=Te(w+P,a[0][1]):!c&&P<0&&(D=Pe(w+k,a[1][1])),x=Math.max(x,I),M=Math.max(M,D)}if(r){if(u){const I=bt(O/E,y,b)*E;if(x=Math.max(x,I),s){let D=0;!l&&!c||l&&!c&&d?D=Te(w+L+O/E,s[1][1])*E:D=Pe(w+L+(l?T:-T)/E,s[0][1])*E,x=Math.max(x,D)}if(a){let D=0;!l&&!c||l&&!c&&d?D=Pe(w+O/E,a[1][1])*E:D=Te(w+(l?T:-T)/E,a[0][1])*E,x=Math.max(x,D)}}if(f){const I=bt(k*E,v,_)/E;if(M=Math.max(M,I),s){let D=0;!l&&!c||c&&!l&&d?D=Te(p+k*E+$,s[1][0])/E:D=Pe(p+(c?P:-P)*E+$,s[0][0])/E,M=Math.max(M,D)}if(a){let D=0;!l&&!c||c&&!l&&d?D=Pe(p+k*E,a[1][0])/E:D=Te(p+(c?P:-P)*E,a[0][0])/E,M=Math.max(M,D)}}}P=P+(P<0?M:-M),T=T+(T<0?x:-x),r&&(d?O>k*E?P=(ko(l,c)?-T:T)/E:T=(ko(l,c)?-P:P)*E:u?(P=T/E,c=l):(T=P*E,l=c));const C=l?p+T:p,A=c?w+P:w;return{width:N+(l?-T:T),height:S+(c?-P:P),x:i[0]*T*(l?-1:1)+C,y:i[1]*P*(c?-1:1)+A}}const is={width:0,height:0,x:0,y:0},Nd={...is,pointerX:0,pointerY:0,aspectRatio:1};function Md(e){return[[0,0],[e.measured.width,e.measured.height]]}function Id(e,t,n){const o=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,a=n[0]*i,l=n[1]*s;return[[o-a,r-l],[o+i-a,r+s-l]]}function kd({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=he(e);let s={controlDirection:Io("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:c,boundaries:u,keepAspectRatio:f,resizeDirection:d,onResizeStart:h,onResize:g,onResizeEnd:v,shouldResize:_}){let y={...is},b={...Nd};s={boundaries:u,resizeDirection:d,keepAspectRatio:f,controlDirection:Io(c)};let p,w=null,N=[],S,E,T,P=!1;const O=vr().on("start",k=>{const{nodeLookup:$,transform:L,snapGrid:x,snapToGrid:M,nodeOrigin:C,paneDomNode:A}=n();if(p=$.get(t),!p)return;w=A?.getBoundingClientRect()??null;const{xSnapped:I,ySnapped:D}=rt(k.sourceEvent,{transform:L,snapGrid:x,snapToGrid:M,containerBounds:w});y={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},b={...y,pointerX:I,pointerY:D,aspectRatio:y.width/y.height},S=void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(S=$.get(p.parentId),E=S&&p.extent==="parent"?Md(S):void 0),N=[],T=void 0;for(const[H,V]of $)if(V.parentId===t&&(N.push({id:H,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const R=Id(V,p,V.origin??C);T?T=[[Math.min(R[0][0],T[0][0]),Math.min(R[0][1],T[0][1])],[Math.max(R[1][0],T[1][0]),Math.max(R[1][1],T[1][1])]]:T=R}h?.(k,{...y})}).on("drag",k=>{const{transform:$,snapGrid:L,snapToGrid:x,nodeOrigin:M}=n(),C=rt(k.sourceEvent,{transform:$,snapGrid:L,snapToGrid:x,containerBounds:w}),A=[];if(!p)return;const{x:I,y:D,width:H,height:V}=y,R={},j=p.origin??M,{width:F,height:W,x:K,y:X}=Cd(b,s.controlDirection,C,s.boundaries,s.keepAspectRatio,j,E,T),B=F!==H,Y=W!==V,U=K!==I&&B,Q=X!==D&&Y;if(!U&&!Q&&!B&&!Y)return;if((U||Q||j[0]===1||j[1]===1)&&(R.x=U?K:y.x,R.y=Q?X:y.y,y.x=R.x,y.y=R.y,N.length>0)){const ne=K-I,te=X-D;for(const se of N)se.position={x:se.position.x-ne+j[0]*(F-H),y:se.position.y-te+j[1]*(W-V)},A.push(se)}if((B||Y)&&(R.width=B&&(!s.resizeDirection||s.resizeDirection==="horizontal")?F:y.width,R.height=Y&&(!s.resizeDirection||s.resizeDirection==="vertical")?W:y.height,y.width=R.width,y.height=R.height),S&&p.expandParent){const ne=j[0]*(R.width??0);R.x&&R.x<ne&&(y.x=ne,b.x=b.x-(R.x-ne));const te=j[1]*(R.height??0);R.y&&R.y<te&&(y.y=te,b.y=b.y-(R.y-te))}const G=Ed({width:y.width,prevWidth:H,height:y.height,prevHeight:V,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),q={...y,direction:G};_?.(k,q)!==!1&&(P=!0,g?.(k,q),o(R,A))}).on("end",k=>{P&&(v?.(k,{...y}),r?.({...y}),P=!1)});i.call(O)}function l(){i.on(".drag",null)}return{update:a,destroy:l}}const Ad={},Ao=e=>{let t;const n=new Set,o=(u,f)=>{const d=typeof u=="function"?u(t):u;if(!Object.is(d,t)){const h=t;t=f??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(g=>g(t,h))}},r=()=>t,l={setState:o,getState:r,getInitialState:()=>c,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(Ad?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},c=t=e(o,r,l);return l},Pd=e=>e?Ao(e):Ao,{useDebugValue:Td}=Wi,{useSyncExternalStoreWithSelector:Dd}=Zi,$d=e=>e;function as(e,t=$d,n){const o=Dd(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Td(o),o}const Po=(e,t)=>{const n=Pd(e),o=(r,i=t)=>as(n,r,i);return Object.assign(o,n),o},zd=(e,t)=>e?Po(e,t):Po;function oe(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,r]of e)if(!Object.is(r,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}const qt=z.createContext(null),Ld=qt.Provider,cs=Ee.error001();function ee(e,t){const n=z.useContext(qt);if(n===null)throw new Error(cs);return as(n,e,t)}function re(){const e=z.useContext(qt);if(e===null)throw new Error(cs);return z.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const To={display:"none"},Hd={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},ls="react-flow__node-desc",us="react-flow__edge-desc",Rd="react-flow__aria-live",jd=e=>e.ariaLiveMessage,Vd=e=>e.ariaLabelConfig;function Od({rfId:e}){const t=ee(jd);return m.jsx("div",{id:`${Rd}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Hd,children:t})}function Bd({rfId:e,disableKeyboardA11y:t}){const n=ee(Vd);return m.jsxs(m.Fragment,{children:[m.jsx("div",{id:`${ls}-${e}`,style:To,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),m.jsx("div",{id:`${us}-${e}`,style:To,children:n["edge.a11yDescription.default"]}),!t&&m.jsx(Od,{rfId:e})]})}const Kt=z.forwardRef(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{const s=`${e}`.split("-");return m.jsx("div",{className:ae(["react-flow__panel",n,...s]),style:o,ref:i,...r,children:t})});Kt.displayName="Panel";function Fd({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:m.jsx(Kt,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:m.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Xd=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},St=e=>e.id;function Yd(e,t){return oe(e.selectedNodes.map(St),t.selectedNodes.map(St))&&oe(e.selectedEdges.map(St),t.selectedEdges.map(St))}function Zd({onSelectionChange:e}){const t=re(),{selectedNodes:n,selectedEdges:o}=ee(Xd,Yd);return z.useEffect(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const Wd=e=>!!e.onSelectionChangeHandlers;function Gd({onSelectionChange:e}){const t=ee(Wd);return e||t?m.jsx(Zd,{onSelectionChange:e}):null}const ds=[0,0],qd={x:0,y:0,zoom:1},Kd=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],Do=[...Kd,"rfId"],Ud=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),$o={translateExtent:ct,nodeOrigin:ds,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Qd(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:l}=ee(Ud,oe),c=re();z.useEffect(()=>(l(e.defaultNodes,e.defaultEdges),()=>{u.current=$o,a()}),[]);const u=z.useRef($o);return z.useEffect(()=>{for(const f of Do){const d=e[f],h=u.current[f];d!==h&&(typeof e[f]>"u"||(f==="nodes"?t(d):f==="edges"?n(d):f==="minZoom"?o(d):f==="maxZoom"?r(d):f==="translateExtent"?i(d):f==="nodeExtent"?s(d):f==="ariaLabelConfig"?c.setState({ariaLabelConfig:Ou(d)}):f==="fitView"?c.setState({fitViewQueued:d}):f==="fitViewOptions"?c.setState({fitViewOptions:d}):c.setState({[f]:d})))}u.current=e},Do.map(f=>e[f])),null}function zo(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Jd(e){const[t,n]=z.useState(e==="system"?null:e);return z.useEffect(()=>{if(e!=="system"){n(e);return}const o=zo(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:zo()?.matches?"dark":"light"}const Lo=typeof document<"u"?document:null;function ft(e=null,t={target:Lo,actInsideInputWithModifier:!0}){const[n,o]=z.useState(!1),r=z.useRef(!1),i=z.useRef(new Set([])),[s,a]=z.useMemo(()=>{if(e!==null){const c=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
2
2
  `).replace(`
3
3
 
4
4
  `,`
@@ -32,4 +32,4 @@ import{r as z,z as Zi,B as Wi,j as m,c as pe,f as Vt,k as Gi,a as qi,t as Ki}fro
32
32
  width: var(--typewriter-max-width);
33
33
  }
34
34
  }
35
- `}),t[6]=g):g=t[6];let v;return t[7]!==i||t[8]!==d||t[9]!==h||t[10]!==n?(v=m.jsxs("span",{className:i,style:d,children:[h,g]},n),t[7]=i,t[8]=d,t[9]=h,t[10]=n,t[11]=v):v=t[11],v}function pg(){const e=pe.c(95),{org:t,locator:n}=Cn(),{data:o}=qi.useSession(),r=o?.user,i=Vt(),{inputValue:s,setInputValue:a,createThread:l,activeThreadId:c,setActiveThreadId:u,hideThread:f}=Qn(),{threads:d,refetch:h}=Qi(),[g,v]=no(`${n}:home-view-mode`,"chat"),_=nr(),y=Ji(),b=tr();let p;e[0]!==b?(p={connections:b,binding:"LLMS"},e[0]=b,e[1]=p):p=e[1];const[w]=ua(p),N=!!w;let S;e[2]!==n?(S=da.chatSelectedModel(n),e[2]=n,e[3]=S):S=e[3];const[E,T]=oa(S,y,mg),[P,O]=no(`${n}:selected-gateway-id`,null);let k;e[4]!==_||e[5]!==P?(k=P?_.find(ie=>ie.id===P)??null:null,e[4]=_,e[5]=P,e[6]=k):k=e[6];const $=k,L=$?.id??null,x=!L;let M;e[7]!==T?(M=ie=>{T(ie)},e[7]=T,e[8]=M):M=e[8];const C=M;let A;e[9]!==O?(A=ie=>{O(ie)},e[9]=O,e[10]=A):A=e[10];const I=A,D=ra(),H=sa(L),V=L??void 0;let R;e[11]!==c||e[12]!==H||e[13]!==D||e[14]!==V?(R={threadId:c,gatewayId:V,systemPrompt:H,onToolCall:D},e[11]=c,e[12]=H,e[13]=D,e[14]=V,e[15]=R):R=e[15];const j=ia(R),{branchContext:F,clearBranch:W}=Qn();let K;e[16]!==c||e[17]!==j||e[18]!==W||e[19]!==L||e[20]!==E||e[21]!==a||e[22]!==r?.image||e[23]!==r?.name?(K=async ie=>{if(!E){Ki.error("No model configured");return}a(""),W();const ce={created_at:new Date().toISOString(),thread_id:c,model:{id:E.id,connectionId:E.connectionId,provider:E.provider??void 0,limits:E.limits??void 0},gateway:{id:L},user:{avatar:r?.image??void 0,name:r?.name??"you"}};await j.sendMessage(ie,ce)},e[16]=c,e[17]=j,e[18]=W,e[19]=L,e[20]=E,e[21]=a,e[22]=r?.image,e[23]=r?.name,e[24]=K):K=e[24];const X=K;let B;e[25]!==r?.name?(B=r?.name?.split(" ")[0]||"there",e[25]=r?.name,e[26]=B):B=e[26];const Y=B;let U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=hg(),e[27]=U):U=e[27];const Q=U;let G;e[28]!==c||e[29]!==d?(G=d?.find(ie=>ie.id===c),e[28]=c,e[29]=d,e[30]=G):G=e[30];const q=G,J=j.status==="submitted"||j.status==="streaming";if(!N){const ie=r?.id||"";let ce;e[31]!==b?(ce=b??[],e[31]=b,e[32]=ce):ce=e[32];let we;e[33]!==i||e[34]!==t.slug?(we=()=>{i({to:"/$org/mcps",params:{org:t.slug},search:{action:"create"}})},e[33]=i,e[34]=t.slug,e[35]=we):we=e[35];let Le;return e[36]!==t.id||e[37]!==t.slug||e[38]!==ie||e[39]!==ce||e[40]!==we?(Le=m.jsx("div",{className:"flex flex-col size-full bg-background items-center justify-center",children:m.jsx(aa,{orgSlug:t.slug,orgId:t.id,userId:ie,allConnections:ce,onInstallMcpServer:we})}),e[36]=t.id,e[37]=t.slug,e[38]=ie,e[39]=ce,e[40]=we,e[41]=Le):Le=e[41],Le}let ne;e[42]!==q||e[43]!==j.isEmpty||e[44]!==g?(ne=m.jsx(le.Header.Left,{children:g==="graph"?m.jsx("span",{className:"text-sm font-medium text-foreground",children:"Summary"}):!j.isEmpty&&q?.title?m.jsx(gg,{text:q.title,className:"text-sm font-medium text-foreground"}):m.jsx("span",{className:"text-sm font-medium text-foreground",children:"Chat"})}),e[42]=q,e[43]=j.isEmpty,e[44]=g,e[45]=ne):ne=e[45];let te;e[46]!==g?(te=g==="graph"&&m.jsx(ig,{}),e[46]=g,e[47]=te):te=e[47];let se;e[48]!==c||e[49]!==l||e[50]!==f||e[51]!==h||e[52]!==u||e[53]!==d||e[54]!==g?(se=g!=="graph"&&m.jsxs(m.Fragment,{children:[m.jsx(rr,{type:"button",variant:"outline",size:"icon",className:"size-7 border border-input",onClick:()=>l(),"aria-label":"New chat",children:m.jsx(ga,{size:16})}),m.jsx(ca,{threads:d,activeThreadId:c,onSelectThread:u,onRemoveThread:f,onOpen:()=>h(),variant:"outline"})]}),e[48]=c,e[49]=l,e[50]=f,e[51]=h,e[52]=u,e[53]=d,e[54]=g,e[55]=se):se=e[55];let fe;e[56]===Symbol.for("react.memo_cache_sentinel")?(fe={value:"chat",icon:m.jsx(Nn,{})},e[56]=fe):fe=e[56];let ue;e[57]===Symbol.for("react.memo_cache_sentinel")?(ue=[fe,{value:"graph",icon:m.jsx(ha,{})}],e[57]=ue):ue=e[57];let de;e[58]!==v||e[59]!==g?(de=m.jsx(fa,{value:g,onValueChange:v,size:"sm",options:ue}),e[58]=v,e[59]=g,e[60]=de):de=e[60];let me;e[61]!==te||e[62]!==se||e[63]!==de?(me=m.jsxs(le.Header.Right,{children:[te,se,de]}),e[61]=te,e[62]=se,e[63]=de,e[64]=me):me=e[64];let ye;e[65]!==ne||e[66]!==me?(ye=m.jsxs(le.Header,{children:[ne,me]}),e[65]=ne,e[66]=me,e[67]=ye):ye=e[67];let xe;e[68]!==F||e[69]!==j.clearError||e[70]!==j.clearFinishReason||e[71]!==j.error||e[72]!==j.finishReason||e[73]!==j.isEmpty||e[74]!==j.messages||e[75]!==j.status||e[76]!==j.stop||e[77]!==W||e[78]!==I||e[79]!==C||e[80]!==X||e[81]!==s||e[82]!==J||e[83]!==$||e[84]!==L||e[85]!==E||e[86]!==u||e[87]!==a||e[88]!==x||e[89]!==Y||e[90]!==g?(xe=g==="graph"?m.jsx("div",{className:"flex-1 overflow-hidden relative",children:m.jsx(fn,{fallback:m.jsx("div",{className:"bg-background p-5 text-sm text-muted-foreground h-full flex items-center justify-center",children:"Failed to load mesh visualization"}),children:m.jsx(z.Suspense,{fallback:m.jsx(ug,{}),children:m.jsx(ag,{})})})}):j.isEmpty?m.jsx("div",{className:"flex-1 min-h-0 flex flex-col items-center justify-center px-10 py-10",children:m.jsxs("div",{className:"flex flex-col items-center gap-6 w-full max-w-[550px]",children:[m.jsxs("div",{className:"text-center",children:[m.jsxs("p",{className:"text-lg font-medium text-foreground",children:[Q," ",Y,","]}),m.jsx("p",{className:"text-base text-muted-foreground",children:"What are we building today?"})]}),m.jsx(to,{gateway:$??void 0,onGatewayChange:I,disabled:J,children:m.jsxs(ta,{value:s,onChange:a,placeholder:"Ask anything or @ for context",maxTextHeight:"65px",onSubmit:async()=>{s.trim()&&await X(s.trim())},children:[x&&m.jsx(Jn,{selectedGatewayId:L,onGatewayChange:I,placeholder:"Agent",disabled:J}),m.jsx(eo,{selectedModel:E??void 0,onModelChange:C,placeholder:"Model",variant:"borderless"})]})}),m.jsx(tn.Container,{className:"w-full",children:L&&m.jsx(fn,{fallback:null,children:m.jsx(z.Suspense,{fallback:m.jsx(tn.Fallback,{}),children:m.jsx(tn,{gatewayId:L,onSelect:ie=>{X(ie.description??ie.name)}})})},L)})]})}):m.jsxs(m.Fragment,{children:[m.jsx(le.Main,{children:m.jsx(le.Messages,{messages:j.messages,status:j.status,minHeightOffset:280})}),m.jsx(le.Footer,{children:m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsx(le.ErrorBanner,{error:j.error,onFixInChat:()=>{j.error&&X(`I encountered this error: ${j.error.message}. Can you help me fix it?`)},onDismiss:j.clearError}),m.jsx(le.FinishReasonWarning,{finishReason:j.finishReason,onContinue:()=>{X("Please continue.")},onDismiss:j.clearFinishReason}),m.jsx(le.BranchPreview,{branchContext:F,clearBranchContext:W,onGoToOriginalMessage:()=>{F&&(u(F.originalThreadId),W(),a(""))},setInputValue:a}),m.jsx(to,{gateway:$??void 0,onGatewayChange:I,disabled:J,children:m.jsxs(le.Input,{value:s,onChange:a,onSubmit:async()=>{s.trim()&&await X(s.trim())},onStop:j.stop,disabled:!E,isStreaming:J,placeholder:E?"Ask anything or @ for context":"Select a model to start chatting",children:[x&&m.jsx(Jn,{selectedGatewayId:L,onGatewayChange:I,placeholder:"Agent",disabled:J}),m.jsx(eo,{selectedModel:E??void 0,onModelChange:C,placeholder:"Model",variant:"borderless"}),m.jsx(ea,{messages:j.messages})]})})]})})]}),e[68]=F,e[69]=j.clearError,e[70]=j.clearFinishReason,e[71]=j.error,e[72]=j.finishReason,e[73]=j.isEmpty,e[74]=j.messages,e[75]=j.status,e[76]=j.stop,e[77]=W,e[78]=I,e[79]=C,e[80]=X,e[81]=s,e[82]=J,e[83]=$,e[84]=L,e[85]=E,e[86]=u,e[87]=a,e[88]=x,e[89]=Y,e[90]=g,e[91]=xe):xe=e[91];let Ae;return e[92]!==ye||e[93]!==xe?(Ae=m.jsx(Uh,{children:m.jsxs(le,{children:[ye,xe]})}),e[92]=ye,e[93]=xe,e[94]=Ae):Ae=e[94],Ae}function mg(e,t){return e.id===t.id&&e.connectionId===t.connectionId}function yg(e){const t=pe.c(14),{error:n,onRetry:o}=e,r=n?.message?.includes("401")||n?.message?.toLowerCase().includes("unauthorized");let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsxs(le.Header,{children:[m.jsx(le.Header.Left,{children:m.jsx("span",{className:"text-sm font-medium text-foreground",children:"Chat"})}),m.jsx(le.Header.Right,{})]}),t[0]=i):i=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=m.jsx("div",{className:"bg-destructive/10 p-3 rounded-full mx-auto w-fit",children:m.jsx(Nn,{className:"h-6 w-6 text-destructive"})}),t[1]=s):s=t[1];const a=r?"Unable to load models":"Something went wrong";let l;t[2]!==a?(l=m.jsx("h3",{className:"text-lg font-medium",children:a}),t[2]=a,t[3]=l):l=t[3];const c=r?"There was an authentication error while loading the models. This might be due to an expired session or invalid API key.":n?.message||"An unexpected error occurred";let u;t[4]!==c?(u=m.jsx("p",{className:"text-sm text-muted-foreground",children:c}),t[4]=c,t[5]=u):u=t[5];let f;t[6]!==l||t[7]!==u?(f=m.jsxs("div",{className:"space-y-2",children:[l,u]}),t[6]=l,t[7]=u,t[8]=f):f=t[8];let d;t[9]!==o?(d=m.jsx(rr,{variant:"outline",onClick:o,children:"Try again"}),t[9]=o,t[10]=d):d=t[10];let h;return t[11]!==f||t[12]!==d?(h=m.jsxs(le,{children:[i,m.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center",children:m.jsxs("div",{className:"max-w-sm space-y-4",children:[s,f,d]})})]}),t[11]=f,t[12]=d,t[13]=h):h=t[13],h}function xg(){const e=pe.c(1);let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=m.jsx(fn,{fallback:wg,children:m.jsx(z.Suspense,{fallback:m.jsx(na,{}),children:m.jsx(pg,{})})}),e[0]=t):t=e[0],t}function wg(e){const{error:t,resetError:n}=e;return m.jsx(yg,{error:t,onRetry:n})}function ap(){const e=pe.c(3),t=Gi();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=m.jsx(xg,{}),e[0]=n):n=e[0];let o;return e[1]!==t.location.pathname?(o=m.jsx(Ui,{children:n},t.location.pathname),e[1]=t.location.pathname,e[2]=o):o=e[2],o}export{ap as default};
35
+ `}),t[6]=g):g=t[6];let v;return t[7]!==i||t[8]!==d||t[9]!==h||t[10]!==n?(v=m.jsxs("span",{className:i,style:d,children:[h,g]},n),t[7]=i,t[8]=d,t[9]=h,t[10]=n,t[11]=v):v=t[11],v}function pg(){const e=pe.c(95),{org:t,locator:n}=Cn(),{data:o}=qi.useSession(),r=o?.user,i=Vt(),{inputValue:s,setInputValue:a,createThread:l,activeThreadId:c,setActiveThreadId:u,hideThread:f}=Qn(),{threads:d,refetch:h}=Qi(),[g,v]=no(`${n}:home-view-mode`,"chat"),_=nr(),y=Ji(),b=tr();let p;e[0]!==b?(p={connections:b,binding:"LLMS"},e[0]=b,e[1]=p):p=e[1];const[w]=ua(p),N=!!w;let S;e[2]!==n?(S=da.chatSelectedModel(n),e[2]=n,e[3]=S):S=e[3];const[E,T]=oa(S,y,mg),[P,O]=no(`${n}:selected-gateway-id`,null);let k;e[4]!==_||e[5]!==P?(k=P?_.find(ie=>ie.id===P)??null:null,e[4]=_,e[5]=P,e[6]=k):k=e[6];const $=k,L=$?.id??null,x=!L;let M;e[7]!==T?(M=ie=>{T(ie)},e[7]=T,e[8]=M):M=e[8];const C=M;let A;e[9]!==O?(A=ie=>{O(ie)},e[9]=O,e[10]=A):A=e[10];const I=A,D=ra(),H=sa(L),V=L??void 0;let R;e[11]!==c||e[12]!==H||e[13]!==D||e[14]!==V?(R={threadId:c,gatewayId:V,systemPrompt:H,onToolCall:D},e[11]=c,e[12]=H,e[13]=D,e[14]=V,e[15]=R):R=e[15];const j=ia(R),{branchContext:F,clearBranch:W}=Qn();let K;e[16]!==c||e[17]!==j||e[18]!==W||e[19]!==L||e[20]!==E||e[21]!==a||e[22]!==r?.image||e[23]!==r?.name?(K=async ie=>{if(!E){Ki.error("No model configured");return}a(""),W();const ce={created_at:new Date().toISOString(),thread_id:c,model:{id:E.id,connectionId:E.connectionId,provider:E.provider??void 0,limits:E.limits??void 0},gateway:{id:L},user:{avatar:r?.image??void 0,name:r?.name??"you"}};await j.sendMessage(ie,ce)},e[16]=c,e[17]=j,e[18]=W,e[19]=L,e[20]=E,e[21]=a,e[22]=r?.image,e[23]=r?.name,e[24]=K):K=e[24];const X=K;let B;e[25]!==r?.name?(B=r?.name?.split(" ")[0]||"there",e[25]=r?.name,e[26]=B):B=e[26];const Y=B;let U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=hg(),e[27]=U):U=e[27];const Q=U;let G;e[28]!==c||e[29]!==d?(G=d?.find(ie=>ie.id===c),e[28]=c,e[29]=d,e[30]=G):G=e[30];const q=G,J=j.status==="submitted"||j.status==="streaming";if(!N){const ie=r?.id||"";let ce;e[31]!==b?(ce=b??[],e[31]=b,e[32]=ce):ce=e[32];let we;e[33]!==i||e[34]!==t.slug?(we=()=>{i({to:"/$org/mcps",params:{org:t.slug},search:{action:"create"}})},e[33]=i,e[34]=t.slug,e[35]=we):we=e[35];let Le;return e[36]!==t.id||e[37]!==t.slug||e[38]!==ie||e[39]!==ce||e[40]!==we?(Le=m.jsx("div",{className:"flex flex-col size-full bg-background items-center justify-center",children:m.jsx(aa,{orgSlug:t.slug,orgId:t.id,userId:ie,allConnections:ce,onInstallMcpServer:we})}),e[36]=t.id,e[37]=t.slug,e[38]=ie,e[39]=ce,e[40]=we,e[41]=Le):Le=e[41],Le}let ne;e[42]!==q||e[43]!==j.isEmpty||e[44]!==g?(ne=m.jsx(le.Header.Left,{children:g==="graph"?m.jsx("span",{className:"text-sm font-medium text-foreground",children:"Summary"}):!j.isEmpty&&q?.title?m.jsx(gg,{text:q.title,className:"text-sm font-medium text-foreground"}):m.jsx("span",{className:"text-sm font-medium text-foreground",children:"Chat"})}),e[42]=q,e[43]=j.isEmpty,e[44]=g,e[45]=ne):ne=e[45];let te;e[46]!==g?(te=g==="graph"&&m.jsx(ig,{}),e[46]=g,e[47]=te):te=e[47];let se;e[48]!==c||e[49]!==l||e[50]!==f||e[51]!==h||e[52]!==u||e[53]!==d||e[54]!==g?(se=g!=="graph"&&m.jsxs(m.Fragment,{children:[m.jsx(rr,{type:"button",variant:"outline",size:"icon",className:"size-7 border border-input",onClick:()=>l(),"aria-label":"New chat",children:m.jsx(ga,{size:16})}),m.jsx(ca,{threads:d,activeThreadId:c,onSelectThread:u,onRemoveThread:f,onOpen:()=>h(),variant:"outline"})]}),e[48]=c,e[49]=l,e[50]=f,e[51]=h,e[52]=u,e[53]=d,e[54]=g,e[55]=se):se=e[55];let fe;e[56]===Symbol.for("react.memo_cache_sentinel")?(fe={value:"chat",icon:m.jsx(Nn,{})},e[56]=fe):fe=e[56];let ue;e[57]===Symbol.for("react.memo_cache_sentinel")?(ue=[fe,{value:"graph",icon:m.jsx(ha,{})}],e[57]=ue):ue=e[57];let de;e[58]!==v||e[59]!==g?(de=m.jsx(fa,{value:g,onValueChange:v,size:"sm",options:ue}),e[58]=v,e[59]=g,e[60]=de):de=e[60];let me;e[61]!==te||e[62]!==se||e[63]!==de?(me=m.jsxs(le.Header.Right,{children:[te,se,de]}),e[61]=te,e[62]=se,e[63]=de,e[64]=me):me=e[64];let ye;e[65]!==ne||e[66]!==me?(ye=m.jsxs(le.Header,{children:[ne,me]}),e[65]=ne,e[66]=me,e[67]=ye):ye=e[67];let xe;e[68]!==F||e[69]!==j.clearError||e[70]!==j.clearFinishReason||e[71]!==j.error||e[72]!==j.finishReason||e[73]!==j.isEmpty||e[74]!==j.messages||e[75]!==j.status||e[76]!==j.stop||e[77]!==W||e[78]!==I||e[79]!==C||e[80]!==X||e[81]!==s||e[82]!==J||e[83]!==$||e[84]!==L||e[85]!==E||e[86]!==u||e[87]!==a||e[88]!==x||e[89]!==Y||e[90]!==g?(xe=g==="graph"?m.jsx("div",{className:"flex-1 overflow-hidden relative",children:m.jsx(fn,{fallback:m.jsx("div",{className:"bg-background p-5 text-sm text-muted-foreground h-full flex items-center justify-center",children:"Failed to load mesh visualization"}),children:m.jsx(z.Suspense,{fallback:m.jsx(ug,{}),children:m.jsx(ag,{})})})}):j.isEmpty?m.jsx("div",{className:"flex-1 min-h-0 flex flex-col items-center justify-center px-10 py-10",children:m.jsxs("div",{className:"flex flex-col items-center gap-6 w-full max-w-[550px]",children:[m.jsxs("div",{className:"text-center",children:[m.jsxs("p",{className:"text-lg font-medium text-foreground",children:[Q," ",Y,","]}),m.jsx("p",{className:"text-base text-muted-foreground",children:"What are we building today?"})]}),m.jsx(to,{gateway:$??void 0,onGatewayChange:I,disabled:J,children:m.jsxs(ta,{value:s,onChange:a,placeholder:"Ask anything or @ for context",maxTextHeight:"65px",onSubmit:async()=>{s.trim()&&await X(s.trim())},children:[x&&m.jsx(Jn,{selectedGatewayId:L,onGatewayChange:I,placeholder:"Agent",disabled:J}),m.jsx(eo,{selectedModel:E??void 0,onModelChange:C,placeholder:"Model",variant:"borderless"})]})}),m.jsx(tn.Container,{className:"w-full",children:L&&m.jsx(fn,{fallback:null,children:m.jsx(z.Suspense,{fallback:m.jsx(tn.Fallback,{}),children:m.jsx(tn,{gatewayId:L,onSelect:ie=>{X(ie.description??ie.name)}})})},L)})]})}):m.jsxs(m.Fragment,{children:[m.jsx(le.Main,{children:m.jsx(le.Messages,{messages:j.messages,status:j.status,minHeightOffset:280})}),m.jsx(le.Footer,{children:m.jsxs("div",{className:"flex flex-col gap-2",children:[m.jsx(le.ErrorBanner,{error:j.error,onFixInChat:()=>{j.error&&X(`I encountered this error: ${j.error.message}. Can you help me fix it?`)},onDismiss:j.clearError}),m.jsx(le.FinishReasonWarning,{finishReason:j.finishReason,onContinue:()=>{X("Please continue.")},onDismiss:j.clearFinishReason}),m.jsx(le.BranchPreview,{branchContext:F,clearBranchContext:W,onGoToOriginalMessage:()=>{F&&(u(F.originalThreadId),W(),a(""))},setInputValue:a}),m.jsx(to,{gateway:$??void 0,onGatewayChange:I,disabled:J,children:m.jsxs(le.Input,{value:s,onChange:a,onSubmit:async()=>{s.trim()&&await X(s.trim())},onStop:j.stop,disabled:!E,isStreaming:J,placeholder:E?"Ask anything or @ for context":"Select a model to start chatting",children:[x&&m.jsx(Jn,{selectedGatewayId:L,onGatewayChange:I,placeholder:"Agent",disabled:J}),m.jsx(eo,{selectedModel:E??void 0,onModelChange:C,placeholder:"Model",variant:"borderless"}),m.jsx(ea,{messages:j.messages})]})})]})})]}),e[68]=F,e[69]=j.clearError,e[70]=j.clearFinishReason,e[71]=j.error,e[72]=j.finishReason,e[73]=j.isEmpty,e[74]=j.messages,e[75]=j.status,e[76]=j.stop,e[77]=W,e[78]=I,e[79]=C,e[80]=X,e[81]=s,e[82]=J,e[83]=$,e[84]=L,e[85]=E,e[86]=u,e[87]=a,e[88]=x,e[89]=Y,e[90]=g,e[91]=xe):xe=e[91];let Ae;return e[92]!==ye||e[93]!==xe?(Ae=m.jsx(Uh,{children:m.jsxs(le,{children:[ye,xe]})}),e[92]=ye,e[93]=xe,e[94]=Ae):Ae=e[94],Ae}function mg(e,t){return e.id===t.id&&e.connectionId===t.connectionId}function yg(e){const t=pe.c(14),{error:n,onRetry:o}=e,r=n?.message?.includes("401")||n?.message?.toLowerCase().includes("unauthorized");let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=m.jsxs(le.Header,{children:[m.jsx(le.Header.Left,{children:m.jsx("span",{className:"text-sm font-medium text-foreground",children:"Chat"})}),m.jsx(le.Header.Right,{})]}),t[0]=i):i=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=m.jsx("div",{className:"bg-destructive/10 p-3 rounded-full mx-auto w-fit",children:m.jsx(Nn,{className:"h-6 w-6 text-destructive"})}),t[1]=s):s=t[1];const a=r?"Unable to load models":"Something went wrong";let l;t[2]!==a?(l=m.jsx("h3",{className:"text-lg font-medium",children:a}),t[2]=a,t[3]=l):l=t[3];const c=r?"There was an authentication error while loading the models. This might be due to an expired session or invalid API key.":n?.message||"An unexpected error occurred";let u;t[4]!==c?(u=m.jsx("p",{className:"text-sm text-muted-foreground",children:c}),t[4]=c,t[5]=u):u=t[5];let f;t[6]!==l||t[7]!==u?(f=m.jsxs("div",{className:"space-y-2",children:[l,u]}),t[6]=l,t[7]=u,t[8]=f):f=t[8];let d;t[9]!==o?(d=m.jsx(rr,{variant:"outline",onClick:o,children:"Try again"}),t[9]=o,t[10]=d):d=t[10];let h;return t[11]!==f||t[12]!==d?(h=m.jsxs(le,{children:[i,m.jsx("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center",children:m.jsxs("div",{className:"max-w-sm space-y-4",children:[s,f,d]})})]}),t[11]=f,t[12]=d,t[13]=h):h=t[13],h}function xg(){const e=pe.c(1);let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=m.jsx(fn,{fallback:wg,children:m.jsx(z.Suspense,{fallback:m.jsx(na,{}),children:m.jsx(pg,{})})}),e[0]=t):t=e[0],t}function wg(e){const{error:t,resetError:n}=e;return m.jsx(yg,{error:t,onRetry:n})}function pp(){const e=pe.c(3),t=Gi();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=m.jsx(xg,{}),e[0]=n):n=e[0];let o;return e[1]!==t.location.pathname?(o=m.jsx(Ui,{children:n},t.location.pathname),e[1]=t.location.pathname,e[2]=o):o=e[2],o}export{pp as default};
@@ -0,0 +1 @@
1
+ import{r as _,c as v,j as r}from"./index-Dk3lubBQ.js";import{B as z}from"./button-2azNqzUx.js";import{b as k,T as y,a as E,c as B}from"./tooltip-DHS6wGWv.js";import{u as S,a as w}from"./use-organization-settings-BNK4p5TK.js";import{u as A}from"./project-context-provider-B1gr9e2f.js";const C=({size:c=24,color:e="currentColor",...n})=>_.createElement("svg",{viewBox:"0 0 24 24",width:c,height:c,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},_.createElement("path",{d:"M12 15v7M8 7.308v2.13c0 .209 0 .313-.02.412a1.001 1.001 0 0 1-.09.254c-.045.09-.11.172-.24.334L6.08 12.4c-.666.833-.999 1.249-.999 1.599a1 1 0 0 0 .376.782C5.731 15 6.264 15 7.33 15h9.342c1.066 0 1.599 0 1.873-.219A1 1 0 0 0 18.92 14c0-.35-.333-.766-1-1.599l-1.569-1.962c-.13-.162-.195-.243-.241-.334a1.004 1.004 0 0 1-.09-.254C16 9.75 16 9.647 16 9.44V7.31c0-.116 0-.174.007-.23.006-.05.015-.1.029-.15a2.02 2.02 0 0 1 .079-.215l1.008-2.52c.294-.735.44-1.102.38-1.397a1 1 0 0 0-.427-.63C16.825 2 16.429 2 15.637 2H8.364c-.792 0-1.188 0-1.44.167a1 1 0 0 0-.426.63c-.06.295.086.662.38 1.397l1.008 2.52c.043.107.064.16.08.215a1 1 0 0 1 .028.15c.006.056.006.114.006.23Z"}));C.displayName="Pin01";function R(c){const e=v.c(19),{title:n,url:t,icon:f}=c,{org:P}=A(),i=S(P.id),h=w(P.id);let l;e[0]!==i?.sidebar_items||e[1]!==t?(l=i?.sidebar_items?.some(p=>p.url===t),e[0]=i?.sidebar_items,e[1]=t,e[2]=l):l=e[2];const a=!!l;let d;e[3]!==h.update||e[4]!==f||e[5]!==a||e[6]!==i?.sidebar_items||e[7]!==n||e[8]!==t?(d=async()=>{const p=i?.sidebar_items||[];let j;a?j=p.filter(T=>T.url!==t):j=[...p,{title:n,url:t,icon:f}],await h.update.mutateAsync({sidebar_items:j})},e[3]=h.update,e[4]=f,e[5]=a,e[6]=i?.sidebar_items,e[7]=n,e[8]=t,e[9]=d):d=e[9];const b=d,x=a?"secondary":"outline";let m;e[10]===Symbol.for("react.memo_cache_sentinel")?(m=r.jsx(C,{size:16}),e[10]=m):m=e[10];let s;e[11]!==b||e[12]!==x?(s=r.jsx(k,{asChild:!0,children:r.jsx(z,{onClick:b,size:"icon",variant:x,className:"size-7 border border-input",children:m})}),e[11]=b,e[12]=x,e[13]=s):s=e[13];const g=a?"Pinned":"Pin to sidebar";let o;e[14]!==g?(o=r.jsx(y,{children:g}),e[14]=g,e[15]=o):o=e[15];let u;return e[16]!==s||e[17]!==o?(u=r.jsx(E,{children:r.jsxs(B,{children:[s,o]})}),e[16]=s,e[17]=o,e[18]=u):u=e[18],u}export{R as P};
@@ -0,0 +1 @@
1
+ import{c as n,j as t,bJ as o}from"./index-Dk3lubBQ.js";function c(){const s=n.c(1);let e;return s[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsxs("div",{className:"flex flex-col items-center justify-center h-full p-8",children:[t.jsx(o,{size:48,className:"text-muted-foreground mb-4"}),t.jsx("h3",{className:"text-lg font-medium mb-2",children:"No storage connected"}),t.jsx("p",{className:"text-muted-foreground text-center max-w-md",children:"Connect an S3-compatible storage service to browse and manage files."})]}),s[0]=e):e=s[0],e}export{c as default};
@@ -0,0 +1 @@
1
+ import{c as w,j as s,r as S,bJ as v}from"./index-Dk3lubBQ.js";import{i as _}from"./Check-VfxUlV5P.js";import{t as k}from"./ChevronDown-OK90XtVB.js";function E(x){const e=w.c(32),{connections:l,selectedConnectionId:r,onConnectionChange:N}=x,[n,y]=S.useState(!1),C=S.useRef(null);let p;if(e[0]!==l||e[1]!==r){let t;e[3]!==r?(t=u=>u.id===r,e[3]=r,e[4]=t):t=e[4],p=l.find(t),e[0]=l,e[1]=r,e[2]=p}else p=e[2];const i=p;let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=t=>{C.current?.contains(t.relatedTarget)||y(!1)},e[5]=b):b=e[5];const R=b;if(l.length===1){let t;e[6]!==i?(t=i?.icon?s.jsx("img",{src:i.icon,alt:"",className:"size-4 rounded"}):s.jsx(v,{size:16}),e[6]=i,e[7]=t):t=e[7];const u=i?.title||"Storage";let f;e[8]!==u?(f=s.jsx("span",{children:u}),e[8]=u,e[9]=f):f=e[9];let h;return e[10]!==t||e[11]!==f?(h=s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[t,f]}),e[10]=t,e[11]=f,e[12]=h):h=e[12],h}let o;e[13]!==n?(o=()=>y(!n),e[13]=n,e[14]=o):o=e[14];let c;e[15]!==i?(c=i?.icon?s.jsx("img",{src:i.icon,alt:"",className:"size-4 rounded"}):s.jsx(v,{size:16}),e[15]=i,e[16]=c):c=e[16];const z=i?.title||"Select storage";let a;e[17]!==z?(a=s.jsx("span",{children:z}),e[17]=z,e[18]=a):a=e[18];let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j=s.jsx(k,{size:14}),e[19]=j):j=e[19];let d;e[20]!==o||e[21]!==c||e[22]!==a?(d=s.jsxs("button",{type:"button",onClick:o,className:"inline-flex items-center gap-2 px-3 py-1.5 text-sm font-medium rounded-md border border-border bg-background hover:bg-accent transition-colors",children:[c,a,j]}),e[20]=o,e[21]=c,e[22]=a,e[23]=d):d=e[23];let m;e[24]!==l||e[25]!==n||e[26]!==N||e[27]!==r?(m=n&&s.jsx("div",{className:"absolute left-0 top-full mt-1 z-50 min-w-48 rounded-md border border-border bg-popover p-1 shadow-md",children:l.map(t=>s.jsxs("button",{type:"button",onClick:()=>{N(t.id),y(!1)},className:"flex items-center gap-2 w-full px-2 py-1.5 text-sm rounded-sm hover:bg-accent transition-colors",children:[t.icon?s.jsx("img",{src:t.icon,alt:"",className:"size-4 rounded"}):s.jsx(v,{size:16}),s.jsx("span",{className:"flex-1 text-left",children:t.title}),t.id===r&&s.jsx(_,{size:14,className:"text-primary"})]},t.id))}),e[24]=l,e[25]=n,e[26]=N,e[27]=r,e[28]=m):m=e[28];let g;return e[29]!==d||e[30]!==m?(g=s.jsxs("div",{className:"relative",ref:C,onBlur:R,children:[d,m]}),e[29]=d,e[30]=m,e[31]=g):g=e[31],g}function O(x){const e=w.c(2);let l;return e[0]!==x?(l=s.jsx("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border",children:s.jsx(E,{...x})}),e[0]=x,e[1]=l):l=e[1],l}export{O as default};
@@ -0,0 +1 @@
1
+ import{r as p,c as u,j as r,i as L,f as O,a3 as A,a4 as h,t as N,p as R}from"./index-Dk3lubBQ.js";import{C as D}from"./collection-header-MCgfYSgE.js";import{C as I}from"./collection-page-CB_Az4GO.js";import{u as M,a as F}from"./use-organization-settings-BNK4p5TK.js";import{u as H}from"./project-context-provider-B1gr9e2f.js";import{c as f,B as j}from"./button-2azNqzUx.js";import{S as T}from"./switch-C9XtHYD0.js";import{i as W}from"./ArrowLeft-Dan_IIKP.js";import"./collection-display-button-B3beugJ4.js";import"./dropdown-menu-DRkETp4T.js";import"./Grid01-AMlhaaWH.js";import"./ArrowUp-B2eKsIZo.js";import"./Check-VfxUlV5P.js";import"./List-BDW462gC.js";import"./tooltip-DHS6wGWv.js";import"./view-mode-toggle-kdDPGpPT.js";import"./useMutation-BEX5R6ly.js";import"./connection-CXC8d3Ae.js";const S=({size:n=24,color:e="currentColor",...s})=>p.createElement("svg",{viewBox:"0 0 24 24",width:n,height:n,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},p.createElement("path",{d:"M7 22 17 2"}));S.displayName="SlashDivider";function q(n){const e=u.c(4);let s;e[0]!==n?({...s}=n,e[0]=n,e[1]=s):s=e[1];let t;return e[2]!==s?(t=r.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...s}),e[2]=s,e[3]=t):t=e[3],t}function G(n){const e=u.c(8);let s,t;e[0]!==n?({className:s,...t}=n,e[0]=n,e[1]=s,e[2]=t):(s=e[1],t=e[2]);let i;e[3]!==s?(i=f("flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2",s),e[3]=s,e[4]=i):i=e[4];let a;return e[5]!==t||e[6]!==i?(a=r.jsx("ol",{"data-slot":"breadcrumb-list",className:i,...t}),e[5]=t,e[6]=i,e[7]=a):a=e[7],a}function C(n){const e=u.c(8);let s,t;e[0]!==n?({className:s,...t}=n,e[0]=n,e[1]=s,e[2]=t):(s=e[1],t=e[2]);let i;e[3]!==s?(i=f("inline-flex items-center gap-1.5",s),e[3]=s,e[4]=i):i=e[4];let a;return e[5]!==t||e[6]!==i?(a=r.jsx("li",{"data-slot":"breadcrumb-item",className:i,...t}),e[5]=t,e[6]=i,e[7]=a):a=e[7],a}function J(n){const e=u.c(10);let s,t,i;e[0]!==n?({asChild:s,className:t,...i}=n,e[0]=n,e[1]=s,e[2]=t,e[3]=i):(s=e[1],t=e[2],i=e[3]);const a=s?L:"a";let o;e[4]!==t?(o=f("hover:text-foreground transition-colors",t),e[4]=t,e[5]=o):o=e[5];let d;return e[6]!==a||e[7]!==i||e[8]!==o?(d=r.jsx(a,{"data-slot":"breadcrumb-link",className:o,...i}),e[6]=a,e[7]=i,e[8]=o,e[9]=d):d=e[9],d}function K(n){const e=u.c(8);let s,t;e[0]!==n?({className:s,...t}=n,e[0]=n,e[1]=s,e[2]=t):(s=e[1],t=e[2]);let i;e[3]!==s?(i=f("text-foreground font-normal",s),e[3]=s,e[4]=i):i=e[4];let a;return e[5]!==t||e[6]!==i?(a=r.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:i,...t}),e[5]=t,e[6]=i,e[7]=a):a=e[7],a}function Q(n){const e=u.c(12);let s,t,i;e[0]!==n?({children:s,className:t,...i}=n,e[0]=n,e[1]=s,e[2]=t,e[3]=i):(s=e[1],t=e[2],i=e[3]);let a;e[4]!==t?(a=f("[&>svg]:size-3.5 text-muted-foreground -rotate-12 opacity-50 list-none",t),e[4]=t,e[5]=a):a=e[5];let o;e[6]!==s?(o=s??r.jsx(S,{}),e[6]=s,e[7]=o):o=e[7];let d;return e[8]!==i||e[9]!==a||e[10]!==o?(d=r.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:a,...i,children:o}),e[8]=i,e[9]=a,e[10]=o,e[11]=d):d=e[11],d}function ue(){const{org:n}=H(),e=O(),s=M(n.id),{update:t}=F(n.id),[i,a]=p.useState({}),[o,d]=p.useState(!1),x=s?.enabled_plugins??[],k=l=>{const c=i[l];return c!==void 0?c:x.includes(l)},w=()=>{const l=new Set(x);for(const[c,m]of Object.entries(i))m?l.add(c):l.delete(c);return Array.from(l)},b=Object.keys(i).length>0,y=(l,c)=>{const m=x.includes(l);a(c===m?g=>{const{[l]:v,...$}=g;return $}:g=>({...g,[l]:c}))},P=async()=>{d(!0);try{await t.mutateAsync({enabled_plugins:w()}),a({}),N.success("Plugin settings saved")}catch{N.error("Failed to save plugin settings")}finally{d(!1)}},E=()=>{a({})},z=l=>R.find(c=>c.pluginId===l),B=l=>h.find(m=>m.id===l)?.description??null;return r.jsxs(I,{children:[r.jsx(D,{title:r.jsx(q,{children:r.jsxs(G,{children:[r.jsx(C,{children:r.jsx(J,{asChild:!0,children:r.jsx(A,{to:"/$org/settings",params:{org:n.slug},children:"Settings"})})}),r.jsx(Q,{}),r.jsx(C,{children:r.jsx(K,{children:"Plugins"})})]})}),leftElement:r.jsx(j,{variant:"ghost",size:"icon",className:"size-8 text-muted-foreground",onClick:()=>e({to:"/$org/settings",params:{org:n.slug}}),children:r.jsx(W,{className:"size-4"})})}),r.jsx("div",{className:"flex-1 overflow-auto",children:r.jsx("div",{className:"flex h-full",children:r.jsx("div",{className:"flex-1 overflow-auto",children:r.jsx("div",{className:"p-5 max-w-2xl",children:r.jsxs("div",{className:"space-y-6",children:[r.jsx("div",{children:r.jsx("p",{className:"text-sm text-muted-foreground",children:"Enable or disable plugins for your organization."})}),r.jsx("div",{className:"divide-y divide-border border-y border-border",children:h.map(l=>{const c=z(l.id),m=B(l.id),g=k(l.id);return r.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[r.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[c?.icon&&r.jsx("div",{className:"flex-shrink-0 text-muted-foreground [&>svg]:size-4",children:c.icon}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("div",{className:"text-sm font-medium text-foreground",children:c?.label??l.id}),m&&r.jsx("p",{className:"text-xs text-muted-foreground",children:m})]})]}),r.jsx(T,{checked:g,onCheckedChange:v=>y(l.id,v),disabled:o})]},l.id)})}),h.length===0&&r.jsx("p",{className:"text-sm text-muted-foreground",children:"No plugins available."}),r.jsxs("div",{className:"flex items-center gap-3 pt-4",children:[r.jsx(j,{onClick:P,disabled:!b||o,className:"min-w-24",children:o?"Saving...":"Save Changes"}),b&&r.jsx(j,{variant:"outline",onClick:E,disabled:o,children:"Cancel"})]})]})})})})})]})}export{ue as default};