@decocms/mesh 2.79.1 → 2.80.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/dist/client/assets/{AlertCircle-CjljO9_K.js → AlertCircle-I0ZBgfYQ.js} +1 -1
  2. package/dist/client/assets/{ArrowUp-DlHoNDRH.js → ArrowUp-CWbsgzJx.js} +1 -1
  3. package/dist/client/assets/{Calendar-BzfXEzG1.js → Calendar-Br-of9Bx.js} +1 -1
  4. package/dist/client/assets/{Check-Cx0Fc2ER.js → Check-7XDeaAob.js} +1 -1
  5. package/dist/client/assets/{CheckCircle-BHqfI-oc.js → CheckCircle-DsyljJow.js} +1 -1
  6. package/dist/client/assets/{CheckDone01-JeEywSHq.js → CheckDone01-BrCJwe9L.js} +1 -1
  7. package/dist/client/assets/{ChevronDown-CYzQevGE.js → ChevronDown-DjYKb0ti.js} +1 -1
  8. package/dist/client/assets/{ChevronRight-ZFn5_7l2.js → ChevronRight-CDMOoq_T.js} +1 -1
  9. package/dist/client/assets/{Code01-BHoiimgb.js → Code01-rhSbsId_.js} +1 -1
  10. package/dist/client/assets/{Copy01-DMVE1jMt.js → Copy01-By0DJI4e.js} +1 -1
  11. package/dist/client/assets/{DotsHorizontal-B8VSxmKN.js → DotsHorizontal-CZypQTS8.js} +1 -1
  12. package/dist/client/assets/{DotsVertical-DmgtVWCP.js → DotsVertical-Dfeh91OM.js} +1 -1
  13. package/dist/client/assets/{Download01-DZAgFAa5.js → Download01-zqhRm8tL.js} +1 -1
  14. package/dist/client/assets/{Edit01-xS3_fhS5.js → Edit01-CeHpCCTm.js} +1 -1
  15. package/dist/client/assets/{File02-CPn42A_T.js → File02-sgq05FIn.js} +1 -1
  16. package/dist/client/assets/{File06-BHrPxaod.js → File06-O7Gdjw1T.js} +1 -1
  17. package/dist/client/assets/{FilterLines-OjKAkVgU.js → FilterLines-CXFrYLpl.js} +1 -1
  18. package/dist/client/assets/{Globe02-DANRNzsK.js → Globe02-iONIGvXX.js} +1 -1
  19. package/dist/client/assets/{Grid01-DfoEVHbX.js → Grid01-ybQAfHJf.js} +1 -1
  20. package/dist/client/assets/{Home02-mm2kWrdz.js → Home02-xOKzuBSl.js} +1 -1
  21. package/dist/client/assets/{Image01-BqS-Pbmk.js → Image01-faQziuY3.js} +1 -1
  22. package/dist/client/assets/{Inbox01-GbeCfKmy.js → Inbox01-Bf9_1DuB.js} +1 -1
  23. package/dist/client/assets/{InfoCircle-B8VcezQA.js → InfoCircle-BHznnG-5.js} +1 -1
  24. package/dist/client/assets/{LinkExternal01-Ba4Ansgj.js → LinkExternal01-_13hZ2Iz.js} +1 -1
  25. package/dist/client/assets/{List-C89gZK5m.js → List-nW4S0vIZ.js} +1 -1
  26. package/dist/client/assets/{Loading01-nhRm_OwM.js → Loading01-DKAt3l4d.js} +1 -1
  27. package/dist/client/assets/{Lock01-BIksl5Jz.js → Lock01-DiEUeHnC.js} +1 -1
  28. package/dist/client/assets/{Pin01-B9_xrwWT.js → Pin01-CML1Eqb9.js} +1 -1
  29. package/dist/client/assets/{Play-YTrai4me.js → Play-C1IlOUyZ.js} +1 -1
  30. package/dist/client/assets/{Plus-DVfCRM0e.js → Plus-pcHQuXb3.js} +1 -1
  31. package/dist/client/assets/{RefreshCcw01-DhKbWajd.js → RefreshCcw01-DRtvZr0B.js} +1 -1
  32. package/dist/client/assets/{SearchMd-Btq9JQM1.js → SearchMd-Byp7pziY.js} +1 -1
  33. package/dist/client/assets/{Settings01-n5GEFijK.js → Settings01-0c_f3iIf.js} +1 -1
  34. package/dist/client/assets/{Settings02-DmQ47Bo8.js → Settings02-DvEEdVgo.js} +1 -1
  35. package/dist/client/assets/{Share07-C0an8t9N.js → Share07-tm51RiqH.js} +1 -1
  36. package/dist/client/assets/{Terminal-COlc6e5_.js → Terminal-pExMIuGo.js} +1 -1
  37. package/dist/client/assets/{Tool01-syn058fN.js → Tool01-Ck61MGrd.js} +1 -1
  38. package/dist/client/assets/{Trash01-pKL0Dwki.js → Trash01-CiRdS40R.js} +1 -1
  39. package/dist/client/assets/{Upload01-Cny6KgII.js → Upload01-CmDl2ilr.js} +1 -1
  40. package/dist/client/assets/{Users03-DxSocU5u.js → Users03-YOMeBBa4.js} +1 -1
  41. package/dist/client/assets/{X-orwHLQvA.js → X-BWvwnU21.js} +1 -1
  42. package/dist/client/assets/{XClose-BvifwoiV.js → XClose-BfW13oFQ.js} +1 -1
  43. package/dist/client/assets/{agent-connections-preview-Ci_AKj2E.js → agent-connections-preview-CQujgSuC.js} +1 -1
  44. package/dist/client/assets/{agent-detail-BJ18jZ58.js → agent-detail-BR7gtqWa.js} +1 -1
  45. package/dist/client/assets/{agents-PSoG53JZ.js → agents-DTsWRoqo.js} +1 -1
  46. package/dist/client/assets/{alert-dialog-DWDyfsZl.js → alert-dialog-BNDRb9kX.js} +1 -1
  47. package/dist/client/assets/auth-catchall-DDqOmfvc.js +1 -0
  48. package/dist/client/assets/{avatar-CHzxmS3u.js → avatar-D7owUHWk.js} +1 -1
  49. package/dist/client/assets/{badge-DjX7aMc2.js → badge-CHLTvrSA.js} +1 -1
  50. package/dist/client/assets/{binder-boG-N4DJ.js → binder-BE0IXnZN.js} +1 -1
  51. package/dist/client/assets/{breadcrumb-C8uFp6Bl.js → breadcrumb-D2BLU7j-.js} +1 -1
  52. package/dist/client/assets/{button-jVZoVSEf.js → button-BZ2r6pCO.js} +1 -1
  53. package/dist/client/assets/{card-B1o7ZI1_.js → card-CrGrXuuQ.js} +1 -1
  54. package/dist/client/assets/{checkbox-DBFzFvmQ.js → checkbox-633rjAF0.js} +1 -1
  55. package/dist/client/assets/{circle-alert-BFldEkBf.js → circle-alert-DAU4eFZZ.js} +1 -1
  56. package/dist/client/assets/{collection-detail-V5sA0ljc.js → collection-detail-B2knGpZ-.js} +1 -1
  57. package/dist/client/assets/{collection-search-BcVP-V1Z.js → collection-search-BUqN_a8F.js} +1 -1
  58. package/dist/client/assets/{collection-tab-Ch7kudcF.js → collection-tab-XPIM1FTb.js} +1 -1
  59. package/dist/client/assets/{collection-table-wrapper-DuHnl5-M.js → collection-table-wrapper-DzPVsPcN.js} +1 -1
  60. package/dist/client/assets/{collection-tabs-BoHGtImC.js → collection-tabs-Cjkh8GZz.js} +1 -1
  61. package/dist/client/assets/{command-CyNsts_0.js → command-Bt5r_pbi.js} +1 -1
  62. package/dist/client/assets/{connect-TCaIRpLI.js → connect-CRavlYUd.js} +1 -1
  63. package/dist/client/assets/{connection-card-DvxLz7vp.js → connection-card-DAfdX0gX.js} +1 -1
  64. package/dist/client/assets/{connection-detail-BcHSi6_W.js → connection-detail-8t2CVc2K.js} +1 -1
  65. package/dist/client/assets/{connections-DhYeAlGi.js → connections-gKckc8If.js} +1 -1
  66. package/dist/client/assets/constants-BM_55h3t.js +1 -0
  67. package/dist/client/assets/{constants-B1K1ZOHV.js → constants-DIcFGsBt.js} +1 -1
  68. package/dist/client/assets/{create-organization-dialog-uaL-GIH0.js → create-organization-dialog-B4qE4EPP.js} +1 -1
  69. package/dist/client/assets/{create-project-dialog-CF32CwsT.js → create-project-dialog-CfuFqMTv.js} +1 -1
  70. package/dist/client/assets/{dialog-CD9Wwmjj.js → dialog-CIIi-UQx.js} +1 -1
  71. package/dist/client/assets/{dropdown-menu-1_TCBXfB.js → dropdown-menu-DLplFZtD.js} +1 -1
  72. package/dist/client/assets/{dynamic-plugin-layout-DATDpm42.js → dynamic-plugin-layout-CEvpW3PG.js} +1 -1
  73. package/dist/client/assets/{empty-state-BbUfTlym.js → empty-state-DYJ5Rr6Z.js} +1 -1
  74. package/dist/client/assets/{empty-state-Diyqgtl1.js → empty-state-DobHu_4R.js} +1 -1
  75. package/dist/client/assets/{env-vars-editor-C3mU-QJJ.js → env-vars-editor-BG_gXbGu.js} +1 -1
  76. package/dist/client/assets/{error-boundary-BmGvCwcM.js → error-boundary-D6xcaUnH.js} +1 -1
  77. package/dist/client/assets/{extract-connection-data-B-iX5ruo.js → extract-connection-data-CxFzgz9O.js} +1 -1
  78. package/dist/client/assets/{file-browser-8RURV0zK.js → file-browser-C36Tw4J4.js} +2 -2
  79. package/dist/client/assets/{form-CuPB-18q.js → form-BchiTH9Y.js} +1 -1
  80. package/dist/client/assets/{grid-view-rXagJOfe.js → grid-view-ozKNYSOV.js} +1 -1
  81. package/dist/client/assets/{home-C-ymc_Us.js → home-DgTK-KLO.js} +1 -1
  82. package/dist/client/assets/{index-C2FQIz_S.js → index-B1k63ajN.js} +1 -1
  83. package/dist/client/assets/{index-DUZGLwaX.js → index-BTBgIJM9.js} +1 -1
  84. package/dist/client/assets/{index-D3nlG5Bn.js → index-B_moDQPJ.js} +3 -3
  85. package/dist/client/assets/{index-DNnTxMe0.js → index-C0QGNbj0.js} +1 -1
  86. package/dist/client/assets/{index-CFsUbpkt.js → index-CpD2u8w7.js} +1 -1
  87. package/dist/client/assets/{index-Cl_5HyRE.js → index-Cs6OK7ZJ.js} +1 -1
  88. package/dist/client/assets/{index-BfmXZUrD.js → index-Dr7IE29U.js} +1 -1
  89. package/dist/client/assets/{index-Dlv6gV0o.js → index-FLCAXklL.js} +1 -1
  90. package/dist/client/assets/{index-BZHmd1qO.js → index-nKZ7l-qD.js} +1 -1
  91. package/dist/client/assets/{infiniteQueryObserver-C_2kO8fk.js → infiniteQueryObserver-DDQolF9c.js} +1 -1
  92. package/dist/client/assets/{input-Cfb0z5LB.js → input-H56RLaPs.js} +1 -1
  93. package/dist/client/assets/{integration-icon-DgoP3aRm.js → integration-icon-CmcbLTLF.js} +1 -1
  94. package/dist/client/assets/{label-DLjBs6VT.js → label-CnEH-wHx.js} +1 -1
  95. package/dist/client/assets/{layout-CGitH7Eg.js → layout-E39v_45d.js} +1 -1
  96. package/dist/client/assets/{localstorage-keys-Dcw7WgCK.js → localstorage-keys-2A5BuCMP.js} +1 -1
  97. package/dist/client/assets/{login-uEE_LxIh.js → login-DUOewX13.js} +1 -1
  98. package/dist/client/assets/{mcp-oauth-DcMlPST3.js → mcp-oauth-CUiS6EXj.js} +1 -1
  99. package/dist/client/assets/{mcp-server-card-Dp5-CXOE.js → mcp-server-card-CrJvkvRI.js} +1 -1
  100. package/dist/client/assets/{mcp-server-detail-CxmJ9qyx.js → mcp-server-detail-EKwGhUK0.js} +2 -2
  101. package/dist/client/assets/{members-Fnrk53kf.js → members-BEhN7KWY.js} +1 -1
  102. package/dist/client/assets/{monaco-editor-4bQew_dQ.js → monaco-editor-ie5OYDaT.js} +1 -1
  103. package/dist/client/assets/{monitoring-zeSCmmDz.js → monitoring-C9Og_05l.js} +1 -1
  104. package/dist/client/assets/{oauth-callback-BSP6Sdix.js → oauth-callback-DTiXu8j-.js} +1 -1
  105. package/dist/client/assets/{page-BPzxTPAI.js → page-BlOVdlvB.js} +1 -1
  106. package/dist/client/assets/{page-CXTaRAHP.js → page-CoINftxz.js} +1 -1
  107. package/dist/client/assets/{plugin-empty-state-BlSVDzFR.js → plugin-empty-state-DYY7MksH.js} +1 -1
  108. package/dist/client/assets/{plugin-header-CRX8X2CA.js → plugin-header-D0TUJ_dh.js} +1 -1
  109. package/dist/client/assets/{popover-DZy413j4.js → popover-DUi0j93T.js} +1 -1
  110. package/dist/client/assets/{project-layout-CJ4kCybp.js → project-layout-Bs2TseF0.js} +1 -1
  111. package/dist/client/assets/{project-settings-DFgohQs-.js → project-settings-BFe8kbwe.js} +1 -1
  112. package/dist/client/assets/{projects-list-C0t46Vb3.js → projects-list-BZJ4kuSu.js} +1 -1
  113. package/dist/client/assets/{registry-utils-CTumh--w.js → registry-utils-Dbwaq0MT.js} +1 -1
  114. package/dist/client/assets/{resizable-Do2pmnrG.js → resizable-DARULNUT.js} +1 -1
  115. package/dist/client/assets/{select-Dl5SsVsF.js → select-0DIfFHya.js} +1 -1
  116. package/dist/client/assets/shell-layout-DkiMKDsd.js +12 -0
  117. package/dist/client/assets/{spinner-DA06y-h7.js → spinner-UQinwvDE.js} +1 -1
  118. package/dist/client/assets/{store-invite-DbeHutGf.js → store-invite-m9V1Apll.js} +1 -1
  119. package/dist/client/assets/{switch-CQszwSv3.js → switch-DLJnhL10.js} +1 -1
  120. package/dist/client/assets/{table-Cc1VTSqr.js → table-ChVmeXId.js} +1 -1
  121. package/dist/client/assets/{tasks-2vErKOnA.js → tasks-FpVnuQAi.js} +1 -1
  122. package/dist/client/assets/{textarea-CQw4c4vg.js → textarea-D3j_8Boy.js} +1 -1
  123. package/dist/client/assets/{tools-list-BDp18Pgp.js → tools-list-BO-HUe9R.js} +1 -1
  124. package/dist/client/assets/{topbar-portal-BgZ57TAJ.js → topbar-portal-BNldIEFO.js} +1 -1
  125. package/dist/client/assets/{typewriter-title-B5Ki7tQ5.js → typewriter-title-CGFefZ4P.js} +1 -1
  126. package/dist/client/assets/{use-binding-TgcVoQAA.js → use-binding-ctUHW8Gb.js} +1 -1
  127. package/dist/client/assets/{use-connection-Crfe-Ixd.js → use-connection-BfSp7yqR.js} +1 -1
  128. package/dist/client/assets/{use-create-virtual-mcp-dLbcBuVS.js → use-create-virtual-mcp-CzlywnDr.js} +1 -1
  129. package/dist/client/assets/{use-deco-chat-open-D-wIsSOI.js → use-deco-chat-open-DT_oT7ZX.js} +1 -1
  130. package/dist/client/assets/{use-install-from-registry-CNM1pBya.js → use-install-from-registry-Cq-7Wuu6.js} +1 -1
  131. package/dist/client/assets/{use-list-state-COXmj0f_.js → use-list-state-DuC-NtF1.js} +1 -1
  132. package/dist/client/assets/{use-llm-rvFAkGsK.js → use-llm-BiBRQzNZ.js} +1 -1
  133. package/dist/client/assets/{use-mcp-prompts-DC9szL21.js → use-mcp-prompts-W5CaGZMT.js} +1 -1
  134. package/dist/client/assets/{use-mcp-tools-CvRTK2tY.js → use-mcp-tools-Cpu_8UKM.js} +1 -1
  135. package/dist/client/assets/{use-mobile-Do_29jRD.js → use-mobile-CrC3E0q9.js} +1 -1
  136. package/dist/client/assets/{use-organization-settings-CuBKNeOw.js → use-organization-settings-DrXO6yHJ.js} +1 -1
  137. package/dist/client/assets/{use-project-HGqdCewl.js → use-project-CpOEhNT2.js} +1 -1
  138. package/dist/client/assets/{use-virtual-mcp-VgOM6PoP.js → use-virtual-mcp-U8Yy28A_.js} +1 -1
  139. package/dist/client/assets/useInfiniteQuery-BBirx5Sx.js +1 -0
  140. package/dist/client/assets/{useMutation-9v6OVjLU.js → useMutation-C21m4k3n.js} +1 -1
  141. package/dist/client/assets/useQuery-ChGnYrGf.js +1 -0
  142. package/dist/client/assets/utils-BnM7sr5H.js +1 -0
  143. package/dist/client/assets/{view-mode-toggle-B7iYwEYq.js → view-mode-toggle-ZCV9ZCCk.js} +1 -1
  144. package/dist/client/assets/{workflow-BkMudwRR.js → workflow-BbxZqJ7t.js} +1 -1
  145. package/dist/client/index.html +1 -1
  146. package/dist/server/cli.js +1 -1
  147. package/dist/server/migrate.js +1 -1
  148. package/dist/server/server.js +1 -1
  149. package/package.json +1 -1
  150. package/dist/client/assets/auth-catchall-ePyrAyIw.js +0 -1
  151. package/dist/client/assets/constants-BeVRY8ix.js +0 -1
  152. package/dist/client/assets/shell-layout-FBb2Axq6.js +0 -12
  153. package/dist/client/assets/useInfiniteQuery-DKdNavme.js +0 -1
  154. package/dist/client/assets/useQuery-CQyI9lob.js +0 -1
  155. package/dist/client/assets/utils-ChMoRSU0.js +0 -1
@@ -1192,7 +1192,7 @@ Please refer to the documentation here: https://better-auth.com/docs/plugins/org
1192
1192
  </script>
1193
1193
  <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference" ${J}></script>
1194
1194
  </body>
1195
- </html>`},Zo=(Y)=>{let X=Y?.path??"/reference";return{id:"open-api",endpoints:{generateOpenAPISchema:f0("/open-api/generate-schema",{method:"GET"},async(Q)=>{let J=await YT0(Q.context,Q.context.options);return Q.json(J)}),openAPIReference:f0(X,{method:"GET",metadata:{isAction:!1}},async(Q)=>{if(Y?.disableDefaultReference)throw new i("NOT_FOUND");let J=await YT0(Q.context,Q.context.options);return new Response(Gt6(J,Y?.theme,Y?.nonce),{headers:{"Content-Type":"text/html"}})})}}};TY();ZG();f8();L9();_0();var vE1=i4(async()=>{return{}}),_E1=i4({use:[Y8]},async(Y)=>{return{session:Y.context.session}}),yE1=P1({YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_ORGANIZATION:"You are not allowed to create a new organization",YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS:"You have reached the maximum number of organizations",ORGANIZATION_ALREADY_EXISTS:"Organization already exists",ORGANIZATION_SLUG_ALREADY_TAKEN:"Organization slug already taken",ORGANIZATION_NOT_FOUND:"Organization not found",USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION:"User is not a member of the organization",YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_ORGANIZATION:"You are not allowed to update this organization",YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_ORGANIZATION:"You are not allowed to delete this organization",NO_ACTIVE_ORGANIZATION:"No active organization",USER_IS_ALREADY_A_MEMBER_OF_THIS_ORGANIZATION:"User is already a member of this organization",MEMBER_NOT_FOUND:"Member not found",ROLE_NOT_FOUND:"Role not found",YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM:"You are not allowed to create a new team",TEAM_ALREADY_EXISTS:"Team already exists",TEAM_NOT_FOUND:"Team not found",YOU_CANNOT_LEAVE_THE_ORGANIZATION_AS_THE_ONLY_OWNER:"You cannot leave the organization as the only owner",YOU_CANNOT_LEAVE_THE_ORGANIZATION_WITHOUT_AN_OWNER:"You cannot leave the organization without an owner",YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_MEMBER:"You are not allowed to delete this member",YOU_ARE_NOT_ALLOWED_TO_INVITE_USERS_TO_THIS_ORGANIZATION:"You are not allowed to invite users to this organization",USER_IS_ALREADY_INVITED_TO_THIS_ORGANIZATION:"User is already invited to this organization",INVITATION_NOT_FOUND:"Invitation not found",YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION:"You are not the recipient of the invitation",EMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION:"Email verification required before accepting or rejecting invitation",YOU_ARE_NOT_ALLOWED_TO_CANCEL_THIS_INVITATION:"You are not allowed to cancel this invitation",INVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION:"Inviter is no longer a member of the organization",YOU_ARE_NOT_ALLOWED_TO_INVITE_USER_WITH_THIS_ROLE:"You are not allowed to invite a user with this role",FAILED_TO_RETRIEVE_INVITATION:"Failed to retrieve invitation",YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_TEAMS:"You have reached the maximum number of teams",UNABLE_TO_REMOVE_LAST_TEAM:"Unable to remove last team",YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_MEMBER:"You are not allowed to update this member",ORGANIZATION_MEMBERSHIP_LIMIT_REACHED:"Organization membership limit reached",YOU_ARE_NOT_ALLOWED_TO_CREATE_TEAMS_IN_THIS_ORGANIZATION:"You are not allowed to create teams in this organization",YOU_ARE_NOT_ALLOWED_TO_DELETE_TEAMS_IN_THIS_ORGANIZATION:"You are not allowed to delete teams in this organization",YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_TEAM:"You are not allowed to update this team",YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_TEAM:"You are not allowed to delete this team",INVITATION_LIMIT_REACHED:"Invitation limit reached",TEAM_MEMBER_LIMIT_REACHED:"Team member limit reached",USER_IS_NOT_A_MEMBER_OF_THE_TEAM:"User is not a member of the team",YOU_CAN_NOT_ACCESS_THE_MEMBERS_OF_THIS_TEAM:"You are not allowed to list the members of this team",YOU_DO_NOT_HAVE_AN_ACTIVE_TEAM:"You do not have an active team",YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM_MEMBER:"You are not allowed to create a new member",YOU_ARE_NOT_ALLOWED_TO_REMOVE_A_TEAM_MEMBER:"You are not allowed to remove a team member",YOU_ARE_NOT_ALLOWED_TO_ACCESS_THIS_ORGANIZATION:"You are not allowed to access this organization as an owner",YOU_ARE_NOT_A_MEMBER_OF_THIS_ORGANIZATION:"You are not a member of this organization",MISSING_AC_INSTANCE:"Dynamic Access Control requires a pre-defined ac instance on the server auth plugin. Read server logs for more information",YOU_MUST_BE_IN_AN_ORGANIZATION_TO_CREATE_A_ROLE:"You must be in an organization to create a role",YOU_ARE_NOT_ALLOWED_TO_CREATE_A_ROLE:"You are not allowed to create a role",YOU_ARE_NOT_ALLOWED_TO_UPDATE_A_ROLE:"You are not allowed to update a role",YOU_ARE_NOT_ALLOWED_TO_DELETE_A_ROLE:"You are not allowed to delete a role",YOU_ARE_NOT_ALLOWED_TO_READ_A_ROLE:"You are not allowed to read a role",YOU_ARE_NOT_ALLOWED_TO_LIST_A_ROLE:"You are not allowed to list a role",YOU_ARE_NOT_ALLOWED_TO_GET_A_ROLE:"You are not allowed to get a role",TOO_MANY_ROLES:"This organization has too many roles",INVALID_RESOURCE:"The provided permission includes an invalid resource",ROLE_NAME_IS_ALREADY_TAKEN:"That role name is already taken",CANNOT_DELETE_A_PRE_DEFINED_ROLE:"Cannot delete a pre-defined role"});var fE1=Number.POSITIVE_INFINITY;var QT0=w(),Zt6=$6(["pending","accepted","rejected","canceled"]).default("pending"),hE1=p({id:w().default(o8),name:w(),slug:w(),logo:w().nullish().optional(),metadata:o0(w(),t4()).or(w().transform((Y)=>JSON.parse(Y))).optional(),createdAt:p6()}),bE1=p({id:w().default(o8),organizationId:w(),userId:j6.string(),role:QT0,createdAt:p6().default(()=>new Date)}),xE1=p({id:w().default(o8),organizationId:w(),email:w(),role:QT0,status:Zt6,teamId:w().nullish(),inviterId:w(),expiresAt:p6(),createdAt:p6().default(()=>new Date)}),uE1=p({id:w().default(o8),name:w().min(1),organizationId:w(),createdAt:p6(),updatedAt:p6().optional()}),gE1=p({id:w().default(o8),teamId:w(),userId:w(),createdAt:p6().default(()=>new Date)}),mE1=p({id:w().default(o8),organizationId:w(),role:w(),permission:o0(w(),M0(w())),createdAt:p6().default(()=>new Date),updatedAt:p6().optional()}),XT0=["admin","member","owner"],lE1=i6([$6(XT0),M0($6(XT0))]);G8();f8();L9();var tE1=P1({INVALID_PHONE_NUMBER:"Invalid phone number",PHONE_NUMBER_EXIST:"Phone number already exists",PHONE_NUMBER_NOT_EXIST:"phone number isn't registered",INVALID_PHONE_NUMBER_OR_PASSWORD:"Invalid phone number or password",UNEXPECTED_ERROR:"Unexpected error",OTP_NOT_FOUND:"OTP not found",OTP_EXPIRED:"OTP expired",INVALID_OTP:"Invalid OTP",PHONE_NUMBER_NOT_VERIFIED:"Phone number not verified",PHONE_NUMBER_CANNOT_BE_UPDATED:"Phone number cannot be updated",SEND_OTP_NOT_IMPLEMENTED:"sendOTP not implemented",TOO_MANY_ATTEMPTS:"Too many attempts"});G8();AY();f8();L9();U9();l1();var Kt6=P1({OTP_NOT_ENABLED:"OTP not enabled",OTP_HAS_EXPIRED:"OTP has expired",TOTP_NOT_ENABLED:"TOTP not enabled",TWO_FACTOR_NOT_ENABLED:"Two factor isn't enabled",BACKUP_CODES_NOT_ENABLED:"Backup codes aren't enabled",INVALID_BACKUP_CODE:"Invalid backup code",INVALID_CODE:"Invalid code",TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE:"Too many attempts. Please request a new code.",INVALID_TWO_FACTOR_COOKIE:"Invalid two factor cookie"});f8();L9();var Ht6=P1({INVALID_USERNAME_OR_PASSWORD:"Invalid username or password",EMAIL_NOT_VERIFIED:"Email not verified",UNEXPECTED_ERROR:"Unexpected error",USERNAME_IS_ALREADY_TAKEN:"Username is already taken. Please try another.",USERNAME_TOO_SHORT:"Username is too short",USERNAME_TOO_LONG:"Username is too long",INVALID_USERNAME:"Username is invalid",INVALID_DISPLAY_USERNAME:"Display username is invalid"});var Qz={enabled:!0,batchSize:250,flushIntervalMs:300,maxQueueSize:1e4,redactor:"regex"};import{existsSync as JT0,readFileSync as GT0}from"fs";var qk={emailAndPassword:{enabled:!0}},WT0=process.env.CONFIG_PATH||"./config.json",ZT0=process.env.AUTH_CONFIG_PATH||"./auth-config.json";function Ft6(){if(JT0(WT0))try{let Y=GT0(WT0,"utf-8"),X=JSON.parse(Y);return{auth:qk,monitoring:Qz,...X}}catch{return{auth:qk,monitoring:Qz}}if(JT0(ZT0))try{let Y=GT0(ZT0,"utf-8");return{auth:JSON.parse(Y),monitoring:Qz}}catch{return{auth:qk,monitoring:Qz}}return{auth:qk,monitoring:Qz}}var Ko=Ft6();import{existsSync as nl4,mkdirSync as il4}from"fs";import{Kysely as MZ6,PostgresDialect as wZ6,sql as F90}from"kysely";import{BunWorkerDialect as PZ6}from"kysely-bun-worker";import*as TZ6 from"path";var LJ=y1(go(),1),t21=LJ.default.Client,po=LJ.default.Pool,e21=LJ.default.Connection,YR1=LJ.default.types,XR1=LJ.default.Query,QR1=LJ.default.DatabaseError,JR1=LJ.default.escapeIdentifier,GR1=LJ.default.escapeLiteral,WR1=LJ.default.Result,ZR1=LJ.default.TypeOverrides,KR1=LJ.default.defaults;var JV=y1(l0(),1),SB=y1(_k(),1);var Eg0=y1(Cx0(),1);var It=y1(Ou0(),1);var Mu0=y1(Oz(),1);function Nu0(Y){if(Y>=48&&Y<=57)return Y-48;if(Y>=97&&Y<=102)return Y-87;return Y-55}function ek(Y){let X=new Uint8Array(Y.length/2),Q=0;for(let J=0;J<Y.length;J+=2){let G=Nu0(Y.charCodeAt(J)),K=Nu0(Y.charCodeAt(J+1));X[Q++]=G<<4|K}return X}function wu0(Y){let X=BigInt(1e9);return BigInt(Math.trunc(Y[0]))*X+BigInt(Math.trunc(Y[1]))}function uF4(Y){let X=Number(BigInt.asUintN(32,Y)),Q=Number(BigInt.asUintN(32,Y>>BigInt(32)));return{low:X,high:Q}}function Pu0(Y){let X=wu0(Y);return uF4(X)}function gF4(Y){return wu0(Y).toString()}var mF4=typeof BigInt<"u"?gF4:Mu0.hrTimeToNanoseconds;function Lu0(Y){return Y}function Tu0(Y){if(Y===void 0)return;return ek(Y)}var lF4={encodeHrTime:Pu0,encodeSpanContext:ek,encodeOptionalSpanContext:Tu0};function Au0(Y){if(Y===void 0)return lF4;let X=Y.useLongBits??!0,Q=Y.useHex??!1;return{encodeHrTime:X?Pu0:mF4,encodeSpanContext:Q?Lu0:ek,encodeOptionalSpanContext:Q?Lu0:Tu0}}function Eu0(Y){let X={attributes:dF4(Y.attributes),droppedAttributesCount:0},Q=Y.schemaUrl;if(Q&&Q!=="")X.schemaUrl=Q;return X}function Cu0(Y){return{name:Y.name,version:Y.version}}function dF4(Y){return Object.keys(Y).map((X)=>Yv(X,Y[X]))}function Yv(Y,X){return{key:Y,value:Xv(X)}}function Xv(Y){let X=typeof Y;if(X==="string")return{stringValue:Y};if(X==="number"){if(!Number.isInteger(Y))return{doubleValue:Y};return{intValue:Y}}if(X==="boolean")return{boolValue:Y};if(Y instanceof Uint8Array)return{bytesValue:Y};if(Array.isArray(Y))return{arrayValue:{values:Y.map(Xv)}};if(X==="object"&&Y!=null)return{kvlistValue:{values:Object.entries(Y).map(([Q,J])=>Yv(Q,J))}};return{}}function Iu0(Y,X){let Q=Au0(X);return{resourceLogs:cF4(Y,Q)}}function pF4(Y){let X=new Map;for(let Q of Y){let{resource:J,instrumentationScope:{name:G,version:K="",schemaUrl:W=""}}=Q,Z=X.get(J);if(!Z)Z=new Map,X.set(J,Z);let H=`${G}@${K}:${W}`,F=Z.get(H);if(!F)F=[],Z.set(H,F);F.push(Q)}return X}function cF4(Y,X){let Q=pF4(Y);return Array.from(Q,([J,G])=>{let K=Eu0(J);return{resource:K,scopeLogs:Array.from(G,([,W])=>{return{scope:Cu0(W[0].instrumentationScope),logRecords:W.map((Z)=>nF4(Z,X)),schemaUrl:W[0].instrumentationScope.schemaUrl}}),schemaUrl:K.schemaUrl}})}function nF4(Y,X){return{timeUnixNano:X.encodeHrTime(Y.hrTime),observedTimeUnixNano:X.encodeHrTime(Y.hrTimeObserved),severityNumber:iF4(Y.severityNumber),severityText:Y.severityText,body:Xv(Y.body),eventName:Y.eventName,attributes:aF4(Y.attributes),droppedAttributesCount:Y.droppedAttributesCount,flags:Y.spanContext?.traceFlags,traceId:X.encodeOptionalSpanContext(Y.spanContext?.traceId),spanId:X.encodeOptionalSpanContext(Y.spanContext?.spanId)}}function iF4(Y){return Y}function aF4(Y){return Object.keys(Y).map((X)=>Yv(X,Y[X]))}var rF4=It.opentelemetry.proto.collector.logs.v1.ExportLogsServiceResponse,oF4=It.opentelemetry.proto.collector.logs.v1.ExportLogsServiceRequest,Qv={serializeRequest:(Y)=>{let X=Iu0(Y);return oF4.encode(X).finish()},deserializeResponse:(Y)=>{return rF4.decode(Y)}};var Wv=y1(kt(),1);class Mz extends Eg0.OTLPExporterBase{constructor(Y={}){super(Wv.createOtlpHttpExportDelegate(Wv.convertLegacyHttpOptions(Y,"LOGS","v1/logs",{"Content-Type":"application/x-protobuf"}),Qv))}}var zZ6=y1(si0(),1),BZ6=y1(U00(),1),UZ6=y1(ze0(),1);var cG=y1(l0(),1);var lA4=globalThis.fetch;async function dA4(Y,X){let Q,J;if(Y instanceof Request)Q=new URL(Y.url),J=X?.method??Y.method;else if(Y instanceof URL)Q=Y,J=X?.method??"GET";else Q=new URL(Y),J=X?.method??"GET";let G=`${J} ${Q.host}`;return i00.startActiveSpan(G,{kind:cG.SpanKind.CLIENT,attributes:{"http.request.method":J,"url.full":Q.href,"url.scheme":Q.protocol.replace(":",""),"url.path":Q.pathname,"url.query":Q.search||void 0,"server.address":Q.hostname,"server.port":Q.port?Number(Q.port):void 0}},async(K)=>{try{let W=new Headers(X?.headers??(Y instanceof Request?Y.headers:{}));cG.propagation.inject(cG.context.active(),W,{set:(F,V,q)=>F.set(V,q)});let Z={...X,headers:W},H=await lA4(Y,Z);if(K.setAttribute("http.response.status_code",H.status),H.status>=400)K.setStatus({code:cG.SpanStatusCode.ERROR,message:`HTTP ${H.status}`});else K.setStatus({code:cG.SpanStatusCode.OK});return H}catch(W){throw K.recordException(W),K.setStatus({code:cG.SpanStatusCode.ERROR,message:W instanceof Error?W.message:"Fetch failed"}),W}finally{K.end()}})}function Be0(){globalThis.fetch=dA4}var Ue0=y1(l0(),1),y9=y1(Oz(),1);class a00{_maxExportBatchSize;_maxQueueSize;_scheduledDelayMillis;_exportTimeoutMillis;_exporter;_isExporting=!1;_finishedLogRecords=[];_timer;_shutdownOnce;constructor(Y,X){if(this._exporter=Y,this._maxExportBatchSize=X?.maxExportBatchSize??y9.getNumberFromEnv("OTEL_BLRP_MAX_EXPORT_BATCH_SIZE")??512,this._maxQueueSize=X?.maxQueueSize??y9.getNumberFromEnv("OTEL_BLRP_MAX_QUEUE_SIZE")??2048,this._scheduledDelayMillis=X?.scheduledDelayMillis??y9.getNumberFromEnv("OTEL_BLRP_SCHEDULE_DELAY")??5000,this._exportTimeoutMillis=X?.exportTimeoutMillis??y9.getNumberFromEnv("OTEL_BLRP_EXPORT_TIMEOUT")??30000,this._shutdownOnce=new y9.BindOnceFuture(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize)Ue0.diag.warn("BatchLogRecordProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize"),this._maxExportBatchSize=this._maxQueueSize}onEmit(Y){if(this._shutdownOnce.isCalled)return;this._addToBuffer(Y)}forceFlush(){if(this._shutdownOnce.isCalled)return this._shutdownOnce.promise;return this._flushAll()}shutdown(){return this._shutdownOnce.call()}async _shutdown(){this.onShutdown(),await this._flushAll(),await this._exporter.shutdown()}_addToBuffer(Y){if(this._finishedLogRecords.length>=this._maxQueueSize)return;this._finishedLogRecords.push(Y),this._maybeStartTimer()}_flushAll(){return new Promise((Y,X)=>{let Q=[],J=Math.ceil(this._finishedLogRecords.length/this._maxExportBatchSize);for(let G=0;G<J;G++)Q.push(this._flushOneBatch());Promise.all(Q).then(()=>{Y()}).catch(X)})}_flushOneBatch(){if(this._clearTimer(),this._finishedLogRecords.length===0)return Promise.resolve();return y9.callWithTimeout(this._export(this._finishedLogRecords.splice(0,this._maxExportBatchSize)),this._exportTimeoutMillis)}_maybeStartTimer(){if(this._isExporting)return;let Y=()=>{this._isExporting=!0,this._flushOneBatch().then(()=>{if(this._isExporting=!1,this._finishedLogRecords.length>0)this._clearTimer(),this._maybeStartTimer()}).catch((X)=>{this._isExporting=!1,y9.globalErrorHandler(X)})};if(this._finishedLogRecords.length>=this._maxExportBatchSize)return Y();if(this._timer!==void 0)return;if(this._timer=setTimeout(()=>Y(),this._scheduledDelayMillis),typeof this._timer!=="number")this._timer.unref()}_clearTimer(){if(this._timer!==void 0)clearTimeout(this._timer),this._timer=void 0}_export(Y){let X=()=>y9.internal._export(this._exporter,Y).then((J)=>{if(J.code!==y9.ExportResultCode.SUCCESS)y9.globalErrorHandler(J.error??Error(`BatchLogRecordProcessor: log record export failed (status ${J})`))}).catch(y9.globalErrorHandler),Q=[];for(let J=0;J<Y.length;J++){let G=Y[J].resource;if(G.asyncAttributesPending&&typeof G.waitForAsyncAttributes==="function")Q.push(G.waitForAsyncAttributes())}if(Q.length===0)return X();else return Promise.all(Q).then(X,y9.globalErrorHandler)}}class lz extends a00{onShutdown(){}}var DZ6=y1(qZ6(),1);var K7;(function(Y){Y[Y.NOT_RECORD=0]="NOT_RECORD",Y[Y.RECORD=1]="RECORD",Y[Y.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"})(K7||(K7={}));var ul4="__d",gl4=JV.createContextKey("Current request"),ml4=0.1,$Z6=(Y)=>{let Q=new URL(Y.url).searchParams.get(ul4);if(Q==="")return crypto.randomUUID();if(!Q)Q=Y.headers.get("x-trace-debug-id");return Q};class OZ6{inner;constructor(Y){this.inner=Y}shouldSample(Y,X,Q,J,G,K){let W=Y.getValue(gl4);if(!W){if(this.inner)return this.inner.shouldSample(Y,X,Q,J,G,K);return{decision:K7.RECORD_AND_SAMPLED}}let Z=$Z6(W);if(Z)return{decision:K7.RECORD_AND_SAMPLED,attributes:{"trace.debug.id":Z}};if(this.inner){let H=this.inner.shouldSample(Y,X,Q,J,G,K);if(H.decision===K7.RECORD_AND_SAMPLED){let F=crypto.randomUUID();H.attributes={...H.attributes??{},"trace.debug.id":F}}return H}return{decision:K7.NOT_RECORD}}toString(){return"DebugSampler"}}class NZ6{ratio;constructor(Y){this.ratio=Y}shouldSample(){if(Math.random()<this.ratio)return{decision:K7.RECORD_AND_SAMPLED};return{decision:K7.NOT_RECORD}}toString(){return`RatioSampler(${this.ratio})`}}var ll4=new zZ6.PrometheusExporter({preventServerStart:!0}),dl4=new OZ6(new NZ6(ml4)),pl4=new DZ6.NodeSDK({serviceName:process.env.OTEL_SERVICE_NAME??"mesh",traceExporter:new BZ6.OTLPTraceExporter,metricReader:ll4,sampler:dl4,logRecordProcessors:[new lz(new Mz)],instrumentations:[new UZ6.RuntimeNodeInstrumentation]});pl4.start();Be0();var i00=JV.trace.getTracer("mesh","1.0.0"),LZ6=JV.metrics.getMeter("mesh","1.0.0"),cl4=SB.logs.getLogger("mesh","1.0.0"),K90=(Y,X,Q)=>{let J={},G=Q,K=Q[Q.length-1];if(K!==null&&typeof K==="object"&&!Array.isArray(K)&&!(K instanceof Error)&&Object.getPrototypeOf(K)===Object.prototype)J=K,G=Q.slice(0,-1);let W=G.map((Z)=>{if(Z instanceof Error)return`${Z.name}: ${Z.message}`;if(typeof Z==="object")try{return JSON.stringify(Z)}catch{return"[Object]"}return String(Z)}).join(" ");cl4.emit({severityNumber:Y,severityText:X,body:W,attributes:{"log.source":"console",...J}})},H90={error:console.error.bind(console),warn:console.warn.bind(console),debug:console.debug.bind(console)};console.error=(...Y)=>{K90(SB.SeverityNumber.ERROR,"ERROR",Y),H90.error(...Y)};console.warn=(...Y)=>{K90(SB.SeverityNumber.WARN,"WARN",Y),H90.warn(...Y)};console.debug=(...Y)=>{K90(SB.SeverityNumber.DEBUG,"DEBUG",Y),H90.debug(...Y)};var al4=LZ6.createHistogram("db.query.duration",{description:"Database query execution duration in milliseconds",unit:"ms"}),rl4=["PRAGMA busy_timeout = ?;"],ol4=400,AZ6=(Y)=>{let X={"db.statement":Y.query.sql,"db.status":Y.level==="error"?"error":"success"};if(Y.queryDurationMillis>ol4)console.error("Slow query detected:",{durationMs:Y.queryDurationMillis,sql:Y.query.sql,params:Y.query.parameters});if(al4.record(Y.queryDurationMillis,X),Y.level==="error"&&!rl4.includes(Y.query.sql))console.error("Query failed:",{durationMs:Y.queryDurationMillis,error:Y.error,sql:Y.query.sql})},EZ6={keepAlive:!0,keepAliveInitialDelayMillis:1e4,idleTimeoutMillis:300000,connectionTimeoutMillis:30000,allowExitOnIdle:!0};function sl4(Y){let X=new po({connectionString:Y.connectionString,max:Y.options?.maxConnections||10,ssl:process.env.DATABASE_PG_SSL==="true"?!0:!1,...EZ6}),Q=new wZ6({pool:X});return{type:"postgres",db:new MZ6({dialect:Q,log:AZ6}),pool:X}}function CZ6(Y){if(Y===":memory:")return":memory:";if(Y.includes("://"))return new URL(Y).pathname;return Y}function IZ6(Y){if(Y!==":memory:"&&Y!=="/"&&Y){let X=Y.substring(0,Y.lastIndexOf("/"));if(X&&X!=="/"&&!nl4(X))try{il4(X,{recursive:!0})}catch{return console.warn(`Failed to create directory ${X}, using in-memory database`),":memory:"}}return Y}function tl4(Y){let X=CZ6(Y.connectionString);X=IZ6(X);let Q=new PZ6({url:X||":memory:"}),J=new MZ6({dialect:Q,log:AZ6});if(!0)F90`PRAGMA foreign_keys = ON;`.execute(J).catch(()=>{});if(X!==":memory:"&&Y.options?.enableWAL!==!1)F90`PRAGMA journal_mode = WAL;`.execute(J).catch(()=>{});if(X!==":memory:"){let K=Y.options?.busyTimeout||5000;F90`PRAGMA busy_timeout = ${K};`.execute(J).catch(()=>{})}return{type:"sqlite",db:J}}function RZ6(Y){let X=Y||"file:./data/mesh.db";if(X===":memory:")return{type:"sqlite",connectionString:":memory:"};X=X.startsWith("/")?`file://${X}`:X;let Q=URL.canParse(X)?new URL(X):null,J=Q?.protocol.replace(":","")??X.split("://")[0];switch(J){case"postgres":case"postgresql":return{type:"postgres",connectionString:X};case"sqlite":case"file":if(!Q?.pathname)throw Error("Invalid database URL: "+X);return{type:"sqlite",connectionString:Q.pathname};default:throw Error(`Unsupported database protocol: ${J}. Supported protocols: postgres://, postgresql://, sqlite://, file://`)}}function q90(){return process.env.DATABASE_URL||`file:${TZ6.join(process.cwd(),"data/mesh.db")}`}function SZ6(Y){let X=RZ6(Y);if(X.type==="postgres")return new wZ6({pool:new po({connectionString:X.connectionString,max:X.options?.maxConnections||10,ssl:process.env.DATABASE_PG_SSL==="true"?!0:!1,...EZ6})});let Q=CZ6(X.connectionString);return Q=IZ6(Q),new PZ6({url:Q||":memory:"})}function el4(Y){let X=RZ6(Y);if(X.type==="postgres")return sl4(X);return tl4(X)}async function jZ6(Y){if(await Y.db.destroy(),Y.type==="postgres"&&!Y.pool.ended)await Y.pool.end()}var V90=null;function zP(){if(!V90)V90=el4(q90());return V90}class $90{apiKey;constructor(Y){this.apiKey=Y}async sendEmail({to:Y,from:X,subject:Q,html:J}){let G=await fetch("https://api.resend.com/emails",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({to:Y,from:X,subject:Q,html:J})});if(!G.ok)throw Error(`Failed to send email: ${G.statusText}`)}}class z90{apiKey;constructor(Y){this.apiKey=Y}async sendEmail({to:Y,from:X,subject:Q,html:J}){let G=await fetch("https://api.sendgrid.com/v3/mail/send",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({personalizations:[{to:[{email:Y}]}],from:{email:X},subject:Q,content:[{type:"text/html",value:J}]})});if(!G.ok){let K=await G.text();throw Error(`Failed to send email via SendGrid: ${G.statusText} - ${K}`)}}}var Yd4=(Y)=>{let X=new $90(Y.config.apiKey);return async({to:Q,subject:J,html:G})=>{await X.sendEmail({to:Q,from:Y.config.fromEmail,subject:J,html:G})}},Xd4=(Y)=>{let X=new z90(Y.config.apiKey);return async({to:Q,subject:J,html:G})=>{await X.sendEmail({to:Q,from:Y.config.fromEmail,subject:J,html:G})}},Qd4={resend:Yd4,sendgrid:Xd4};function Vf(Y){let X=Qd4[Y.provider];if(!X)throw Error(`Unknown email provider: ${Y.provider}`);return X(Y)}function qf(Y,X){return Y.find((Q)=>Q.id===X)}var kZ6=(Y,X)=>{let Q=qf(X,Y.emailProviderId);if(!Q)throw Error(`Email provider with id '${Y.emailProviderId}' not found`);let J=Vf(Q);return{sendMagicLink:async({email:G,url:K})=>{await J({to:G,subject:"Magic Link",html:`<p>Click <a href="${K}">here</a> to login</p>`})}}};I7();import{createCipheriv as Jd4,createDecipheriv as Gd4,randomBytes as vZ6}from"crypto";var _Z6="aes-256-gcm",BP=16,yZ6=16,fZ6=32;class B90{key;constructor(Y){if(Buffer.from(Y,"base64").length===fZ6)this.key=Buffer.from(Y,"base64");else{let X=q0("crypto");this.key=X.createHash("sha256").update(Y).digest()}}async encrypt(Y){let X=vZ6(BP),Q=Jd4(_Z6,this.key,X),J=Q.update(Y,"utf8");J=Buffer.concat([J,Q.final()]);let G=Q.getAuthTag();return Buffer.concat([X,G,J]).toString("base64")}async decrypt(Y){let X=Buffer.from(Y,"base64"),Q=X.subarray(0,BP),J=X.subarray(BP,BP+yZ6),G=X.subarray(BP+yZ6),K=Gd4(_Z6,this.key,Q);K.setAuthTag(J);let W=K.update(G);return W=Buffer.concat([W,K.final()]),W.toString("utf8")}static generateKey(){return vZ6(fZ6).toString("base64")}}eK();UP();I7();var Wd4=["connection_headers","oauth_config","configuration_scopes","metadata","tools","bindings"];class U90{db;vault;constructor(Y,X){this.db=Y;this.vault=X}async create(Y){let X=Y.id??Y3("conn"),Q=new Date().toISOString(),J=await this.findById(X);if(J){if(J.organization_id!==Y.organization_id)throw Error("Connection ID already exists");return this.update(X,Y)}let G=await this.serializeConnection({...Y,id:Y.id??X,status:"active",created_at:Q,updated_at:Q});await this.db.insertInto("connections").values(G).execute();let K=await this.findById(X);if(!K)throw Error(`Failed to create connection with id: ${X}`);return K}async findById(Y,X){let Q=jd(Y);if(Q)return kd(X??Q);let J=this.db.selectFrom("connections").selectAll().where("id","=",Y);if(X)J=J.where("organization_id","=",X);let G=await J.executeTakeFirst();return G?this.deserializeConnection(G):null}async list(Y,X){let Q=this.db.selectFrom("connections").selectAll().where("organization_id","=",Y);if(!X?.includeVirtual)Q=Q.where("connection_type","!=","VIRTUAL");let J=await Q.execute();return Promise.all(J.map((G)=>this.deserializeConnection(G)))}async update(Y,X){if(Object.keys(X).length===0){let G=await this.findById(Y);if(!G)throw Error("Connection not found");return G}let Q=await this.serializeConnection({...X,updated_at:new Date().toISOString()});await this.db.updateTable("connections").set(Q).where("id","=",Y).execute();let J=await this.findById(Y);if(!J)throw Error("Connection not found after update");return J}async delete(Y){await this.db.deleteFrom("connections").where("id","=",Y).execute()}async testConnection(Y,X){let Q=await this.findById(Y);if(!Q)throw Error("Connection not found");let J=Date.now();if(Q.connection_type==="STDIO")return{healthy:!0,latencyMs:Date.now()-J};if(!Q.connection_url)return{healthy:!1,latencyMs:Date.now()-J};try{let G=Q.connection_headers,K=await fetch(Q.connection_url,{method:"POST",headers:{"Content-Type":"application/json",...Q.connection_token&&{Authorization:`Bearer ${Q.connection_token}`},...G?.headers,...X},body:JSON.stringify({jsonrpc:"2.0",method:"ping",id:1})});return{healthy:K.ok||K.status===404,latencyMs:Date.now()-J}}catch{return{healthy:!1,latencyMs:Date.now()-J}}}async serializeConnection(Y){let X={};for(let[Q,J]of Object.entries(Y)){if(J===void 0)continue;if(Q==="connection_token"&&J)X[Q]=await this.vault.encrypt(J);else if(Q==="configuration_state"&&J){let G=JSON.stringify(J);X[Q]=await this.vault.encrypt(G)}else if(Q==="connection_headers"&&J){let G=J;if(wZ(G)&&G.envVars){let K={};for(let[W,Z]of Object.entries(G.envVars))K[W]=await this.vault.encrypt(Z);X[Q]=JSON.stringify({...G,envVars:K})}else X[Q]=JSON.stringify(G)}else if(Wd4.includes(Q))X[Q]=J?JSON.stringify(J):null;else X[Q]=J}return X}async deserializeConnection(Y){let X=null;if(Y.connection_token)try{X=await this.vault.decrypt(Y.connection_token)}catch(K){console.error("Failed to decrypt connection token:",K)}let Q=null;if(Y.configuration_state)try{let K=await this.vault.decrypt(Y.configuration_state);Q=JSON.parse(K)}catch(K){console.error("Failed to decrypt configuration state:",K)}let J=null;if(Y.connection_headers)try{let K=JSON.parse(Y.connection_headers);if(wZ(K)&&K.envVars){let W={};for(let[Z,H]of Object.entries(K.envVars))try{W[Z]=await this.vault.decrypt(H)}catch{W[Z]=H}J={...K,envVars:W}}else J=K}catch(K){console.error("Failed to parse connection_headers:",K)}let G=(K)=>{if(K===null)return null;if(typeof K==="string")try{return JSON.parse(K)}catch{return null}return K};return{id:Y.id,organization_id:Y.organization_id,created_by:Y.created_by,updated_by:Y.updated_by??void 0,title:Y.title,description:Y.description,icon:Y.icon,app_name:Y.app_name,app_id:Y.app_id,connection_type:Y.connection_type,connection_url:Y.connection_url,connection_token:X,connection_headers:J,oauth_config:G(Y.oauth_config),configuration_state:Q,configuration_scopes:G(Y.configuration_scopes),metadata:G(Y.metadata),tools:G(Y.tools),bindings:G(Y.bindings),status:Y.status,created_at:Y.created_at,updated_at:Y.updated_at}}}UP();class D90{db;constructor(Y){this.db=Y}parseRow(Y){return{id:Y.id,organizationId:Y.organization_id,slug:Y.slug,name:Y.name,description:Y.description,enabledPlugins:Y.enabled_plugins?typeof Y.enabled_plugins==="string"?JSON.parse(Y.enabled_plugins):Y.enabled_plugins:null,ui:Y.ui?typeof Y.ui==="string"?JSON.parse(Y.ui):Y.ui:null,createdAt:Y.created_at,updatedAt:Y.updated_at}}async list(Y){return(await this.db.selectFrom("projects").selectAll().where("organization_id","=",Y).orderBy("created_at","asc").execute()).map((Q)=>this.parseRow(Q))}async get(Y){let X=await this.db.selectFrom("projects").selectAll().where("id","=",Y).executeTakeFirst();return X?this.parseRow(X):null}async getBySlug(Y,X){let Q=await this.db.selectFrom("projects").selectAll().where("organization_id","=",Y).where("slug","=",X).executeTakeFirst();return Q?this.parseRow(Q):null}async create(Y){let X=new Date().toISOString(),Q=Y3("proj");await this.db.insertInto("projects").values({id:Q,organization_id:Y.organizationId,slug:Y.slug,name:Y.name,description:Y.description??null,enabled_plugins:Y.enabledPlugins?JSON.stringify(Y.enabledPlugins):null,ui:Y.ui?JSON.stringify(Y.ui):null,created_at:X,updated_at:X}).execute();let J=await this.get(Q);if(!J)throw Error("Failed to create project");return J}async update(Y,X){let Q={updated_at:new Date().toISOString()};if(X.name!==void 0)Q.name=X.name;if(X.description!==void 0)Q.description=X.description;if(X.enabledPlugins!==void 0)Q.enabled_plugins=X.enabledPlugins?JSON.stringify(X.enabledPlugins):null;if(X.ui!==void 0)Q.ui=X.ui?JSON.stringify(X.ui):null;return await this.db.updateTable("projects").set(Q).where("id","=",Y).execute(),this.get(Y)}async delete(Y){return((await this.db.deleteFrom("projects").where("id","=",Y).executeTakeFirst()).numDeletedRows??0n)>0n}}Df();_0();function vi4(Y){return[{permissions:{self:["*"]},getTools:async()=>{let{ALL_TOOLS:X}=await Promise.resolve().then(() => (tV6(),sV6));return X.map((Q)=>{return{name:Q.name,inputSchema:N.toJSONSchema(Q.inputSchema,{unrepresentable:"any"}),outputSchema:Q.outputSchema?N.toJSONSchema(Q.outputSchema,{unrepresentable:"any"}):void 0,description:Q.description}})},data:Rd(B5(),Y)},{data:Id()},{data:Cd(Y)}]}async function eV6(Y,X){try{let Q=zP(),J=new B90(process.env.ENCRYPTION_KEY||""),G=new U90(Q.db,J),K=new D90(Q.db),W=vi4(Y);try{await K.create({organizationId:Y,slug:xJ,name:OV,description:"Organization administration and settings",enabledPlugins:null,ui:null})}catch(Z){console.warn("Could not create org-admin project (may already exist):",Z)}await Promise.all(W.map(async(Z)=>{let H=null;if(Z.permissions)H=(await oB.api.createApiKey({body:{name:`${Z.data.app_name??crypto.randomUUID()}-mcp`,userId:X,permissions:Z.permissions,rateLimitEnabled:!1,metadata:{organization:{id:Y},purpose:"default-org-connections"}}}))?.key;let F=await Z.getTools?.()??await xB({id:"pending",title:Z.data.title,connection_type:Z.data.connection_type,connection_url:Z.data.connection_url,connection_token:Z.data.connection_token,connection_headers:Z.data.connection_headers}).catch(()=>null),V=Z.data.id?Z.data.id.startsWith(`${Y}_`)?Z.data.id:`${Y}_${Z.data.id}`:void 0;await G.create({...Z.data,id:V,tools:F,organization_id:Y,created_by:X,connection_token:Z.data.connection_token??H})}))}catch(Q){console.error("Error creating default MCP connections:",Q)}}var Yq6=["owner","admin"];var _i4=(Y)=>{return{defaultSSO:[{domain:Y.domain,providerId:Y.providerId,oidcConfig:{issuer:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/v2.0`,pkce:!0,clientId:Y.MS_CLIENT_ID,clientSecret:Y.MS_CLIENT_SECRET,discoveryEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/v2.0/.well-known/openid-configuration`,authorizationEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/oauth2/v2.0/authorize`,tokenEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/oauth2/v2.0/token`,jwksEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/discovery/v2.0/keys`,userInfoEndpoint:"https://graph.microsoft.com/oidc/userinfo",tokenEndpointAuthentication:"client_secret_post",scopes:Y.scopes,mapping:{id:"sub",email:"email",emailVerified:"email_verified",name:"name",image:"picture",extraFields:{emailVerified:"email_verified"}}}}]}},Xq6=(Y)=>{if(Y.providerId==="microsoft")return _i4(Y);throw Error(`Unsupported provider: ${Y.providerId}`)};function yi4(Y){return Y.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Qq6=["labs","agent","studio","workspace","systems","core","cloud","works"],Jq6=["capybara","guarana","deco","samba","feijoada","capoeira","carnival"];function fi4(){let Y=Math.floor(Math.random()*Jq6.length),X=Math.floor(Math.random()*Qq6.length),Q=Jq6[Y]??"deco",J=Qq6[X]??"studio";return`${Q}-${J}`}var hi4=Object.values(Dc()).map((Y)=>Y.map((X)=>X.name)).flat(),bi4={...sj,self:["*",...hi4]},bf=hG(bi4),xi4=bf.newRole({self:["*"],...dL.statements}),ui4=bf.newRole({self:["*"],...dL.statements}),gi4=bf.newRole({self:["*"],...dL.statements}),Gq6=Object.values(Dc()).map((Y)=>Y.map((X)=>`self:${X.name}`)).flat(),vQ=Ko.auth,Wq6=void 0;if(vQ.inviteEmailProviderId&&vQ.emailProviders&&vQ.emailProviders.length>0){let Y=qf(vQ.emailProviders,vQ.inviteEmailProviderId);if(Y){let X=Vf(Y);Wq6=async(Q)=>{let J=Q.inviter.user?.name||Q.inviter.user?.email,G=`${B5()}/auth/accept-invitation?invitationId=${Q.invitation.id}`;await X({to:Q.email,subject:`Invitation to join ${Q.organization.name}`,html:`
1195
+ </html>`},Zo=(Y)=>{let X=Y?.path??"/reference";return{id:"open-api",endpoints:{generateOpenAPISchema:f0("/open-api/generate-schema",{method:"GET"},async(Q)=>{let J=await YT0(Q.context,Q.context.options);return Q.json(J)}),openAPIReference:f0(X,{method:"GET",metadata:{isAction:!1}},async(Q)=>{if(Y?.disableDefaultReference)throw new i("NOT_FOUND");let J=await YT0(Q.context,Q.context.options);return new Response(Gt6(J,Y?.theme,Y?.nonce),{headers:{"Content-Type":"text/html"}})})}}};TY();ZG();f8();L9();_0();var vE1=i4(async()=>{return{}}),_E1=i4({use:[Y8]},async(Y)=>{return{session:Y.context.session}}),yE1=P1({YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_ORGANIZATION:"You are not allowed to create a new organization",YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS:"You have reached the maximum number of organizations",ORGANIZATION_ALREADY_EXISTS:"Organization already exists",ORGANIZATION_SLUG_ALREADY_TAKEN:"Organization slug already taken",ORGANIZATION_NOT_FOUND:"Organization not found",USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION:"User is not a member of the organization",YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_ORGANIZATION:"You are not allowed to update this organization",YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_ORGANIZATION:"You are not allowed to delete this organization",NO_ACTIVE_ORGANIZATION:"No active organization",USER_IS_ALREADY_A_MEMBER_OF_THIS_ORGANIZATION:"User is already a member of this organization",MEMBER_NOT_FOUND:"Member not found",ROLE_NOT_FOUND:"Role not found",YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM:"You are not allowed to create a new team",TEAM_ALREADY_EXISTS:"Team already exists",TEAM_NOT_FOUND:"Team not found",YOU_CANNOT_LEAVE_THE_ORGANIZATION_AS_THE_ONLY_OWNER:"You cannot leave the organization as the only owner",YOU_CANNOT_LEAVE_THE_ORGANIZATION_WITHOUT_AN_OWNER:"You cannot leave the organization without an owner",YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_MEMBER:"You are not allowed to delete this member",YOU_ARE_NOT_ALLOWED_TO_INVITE_USERS_TO_THIS_ORGANIZATION:"You are not allowed to invite users to this organization",USER_IS_ALREADY_INVITED_TO_THIS_ORGANIZATION:"User is already invited to this organization",INVITATION_NOT_FOUND:"Invitation not found",YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION:"You are not the recipient of the invitation",EMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION:"Email verification required before accepting or rejecting invitation",YOU_ARE_NOT_ALLOWED_TO_CANCEL_THIS_INVITATION:"You are not allowed to cancel this invitation",INVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION:"Inviter is no longer a member of the organization",YOU_ARE_NOT_ALLOWED_TO_INVITE_USER_WITH_THIS_ROLE:"You are not allowed to invite a user with this role",FAILED_TO_RETRIEVE_INVITATION:"Failed to retrieve invitation",YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_TEAMS:"You have reached the maximum number of teams",UNABLE_TO_REMOVE_LAST_TEAM:"Unable to remove last team",YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_MEMBER:"You are not allowed to update this member",ORGANIZATION_MEMBERSHIP_LIMIT_REACHED:"Organization membership limit reached",YOU_ARE_NOT_ALLOWED_TO_CREATE_TEAMS_IN_THIS_ORGANIZATION:"You are not allowed to create teams in this organization",YOU_ARE_NOT_ALLOWED_TO_DELETE_TEAMS_IN_THIS_ORGANIZATION:"You are not allowed to delete teams in this organization",YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_TEAM:"You are not allowed to update this team",YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_TEAM:"You are not allowed to delete this team",INVITATION_LIMIT_REACHED:"Invitation limit reached",TEAM_MEMBER_LIMIT_REACHED:"Team member limit reached",USER_IS_NOT_A_MEMBER_OF_THE_TEAM:"User is not a member of the team",YOU_CAN_NOT_ACCESS_THE_MEMBERS_OF_THIS_TEAM:"You are not allowed to list the members of this team",YOU_DO_NOT_HAVE_AN_ACTIVE_TEAM:"You do not have an active team",YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM_MEMBER:"You are not allowed to create a new member",YOU_ARE_NOT_ALLOWED_TO_REMOVE_A_TEAM_MEMBER:"You are not allowed to remove a team member",YOU_ARE_NOT_ALLOWED_TO_ACCESS_THIS_ORGANIZATION:"You are not allowed to access this organization as an owner",YOU_ARE_NOT_A_MEMBER_OF_THIS_ORGANIZATION:"You are not a member of this organization",MISSING_AC_INSTANCE:"Dynamic Access Control requires a pre-defined ac instance on the server auth plugin. Read server logs for more information",YOU_MUST_BE_IN_AN_ORGANIZATION_TO_CREATE_A_ROLE:"You must be in an organization to create a role",YOU_ARE_NOT_ALLOWED_TO_CREATE_A_ROLE:"You are not allowed to create a role",YOU_ARE_NOT_ALLOWED_TO_UPDATE_A_ROLE:"You are not allowed to update a role",YOU_ARE_NOT_ALLOWED_TO_DELETE_A_ROLE:"You are not allowed to delete a role",YOU_ARE_NOT_ALLOWED_TO_READ_A_ROLE:"You are not allowed to read a role",YOU_ARE_NOT_ALLOWED_TO_LIST_A_ROLE:"You are not allowed to list a role",YOU_ARE_NOT_ALLOWED_TO_GET_A_ROLE:"You are not allowed to get a role",TOO_MANY_ROLES:"This organization has too many roles",INVALID_RESOURCE:"The provided permission includes an invalid resource",ROLE_NAME_IS_ALREADY_TAKEN:"That role name is already taken",CANNOT_DELETE_A_PRE_DEFINED_ROLE:"Cannot delete a pre-defined role"});var fE1=Number.POSITIVE_INFINITY;var QT0=w(),Zt6=$6(["pending","accepted","rejected","canceled"]).default("pending"),hE1=p({id:w().default(o8),name:w(),slug:w(),logo:w().nullish().optional(),metadata:o0(w(),t4()).or(w().transform((Y)=>JSON.parse(Y))).optional(),createdAt:p6()}),bE1=p({id:w().default(o8),organizationId:w(),userId:j6.string(),role:QT0,createdAt:p6().default(()=>new Date)}),xE1=p({id:w().default(o8),organizationId:w(),email:w(),role:QT0,status:Zt6,teamId:w().nullish(),inviterId:w(),expiresAt:p6(),createdAt:p6().default(()=>new Date)}),uE1=p({id:w().default(o8),name:w().min(1),organizationId:w(),createdAt:p6(),updatedAt:p6().optional()}),gE1=p({id:w().default(o8),teamId:w(),userId:w(),createdAt:p6().default(()=>new Date)}),mE1=p({id:w().default(o8),organizationId:w(),role:w(),permission:o0(w(),M0(w())),createdAt:p6().default(()=>new Date),updatedAt:p6().optional()}),XT0=["admin","member","owner"],lE1=i6([$6(XT0),M0($6(XT0))]);G8();f8();L9();var tE1=P1({INVALID_PHONE_NUMBER:"Invalid phone number",PHONE_NUMBER_EXIST:"Phone number already exists",PHONE_NUMBER_NOT_EXIST:"phone number isn't registered",INVALID_PHONE_NUMBER_OR_PASSWORD:"Invalid phone number or password",UNEXPECTED_ERROR:"Unexpected error",OTP_NOT_FOUND:"OTP not found",OTP_EXPIRED:"OTP expired",INVALID_OTP:"Invalid OTP",PHONE_NUMBER_NOT_VERIFIED:"Phone number not verified",PHONE_NUMBER_CANNOT_BE_UPDATED:"Phone number cannot be updated",SEND_OTP_NOT_IMPLEMENTED:"sendOTP not implemented",TOO_MANY_ATTEMPTS:"Too many attempts"});G8();AY();f8();L9();U9();l1();var Kt6=P1({OTP_NOT_ENABLED:"OTP not enabled",OTP_HAS_EXPIRED:"OTP has expired",TOTP_NOT_ENABLED:"TOTP not enabled",TWO_FACTOR_NOT_ENABLED:"Two factor isn't enabled",BACKUP_CODES_NOT_ENABLED:"Backup codes aren't enabled",INVALID_BACKUP_CODE:"Invalid backup code",INVALID_CODE:"Invalid code",TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE:"Too many attempts. Please request a new code.",INVALID_TWO_FACTOR_COOKIE:"Invalid two factor cookie"});f8();L9();var Ht6=P1({INVALID_USERNAME_OR_PASSWORD:"Invalid username or password",EMAIL_NOT_VERIFIED:"Email not verified",UNEXPECTED_ERROR:"Unexpected error",USERNAME_IS_ALREADY_TAKEN:"Username is already taken. Please try another.",USERNAME_TOO_SHORT:"Username is too short",USERNAME_TOO_LONG:"Username is too long",INVALID_USERNAME:"Username is invalid",INVALID_DISPLAY_USERNAME:"Display username is invalid"});var Qz={enabled:!0,batchSize:250,flushIntervalMs:300,maxQueueSize:1e4,redactor:"regex"};import{existsSync as JT0,readFileSync as GT0}from"fs";var qk={emailAndPassword:{enabled:!0}},WT0=process.env.CONFIG_PATH||"./config.json",ZT0=process.env.AUTH_CONFIG_PATH||"./auth-config.json";function Ft6(){if(JT0(WT0))try{let Y=GT0(WT0,"utf-8"),X=JSON.parse(Y);return{auth:qk,monitoring:Qz,...X}}catch{return{auth:qk,monitoring:Qz}}if(JT0(ZT0))try{let Y=GT0(ZT0,"utf-8");return{auth:JSON.parse(Y),monitoring:Qz}}catch{return{auth:qk,monitoring:Qz}}return{auth:qk,monitoring:Qz}}var Ko=Ft6();import{existsSync as nl4,mkdirSync as il4}from"fs";import{Kysely as MZ6,PostgresDialect as wZ6,sql as F90}from"kysely";import{BunWorkerDialect as PZ6}from"kysely-bun-worker";import*as TZ6 from"path";var LJ=y1(go(),1),t21=LJ.default.Client,po=LJ.default.Pool,e21=LJ.default.Connection,YR1=LJ.default.types,XR1=LJ.default.Query,QR1=LJ.default.DatabaseError,JR1=LJ.default.escapeIdentifier,GR1=LJ.default.escapeLiteral,WR1=LJ.default.Result,ZR1=LJ.default.TypeOverrides,KR1=LJ.default.defaults;var JV=y1(l0(),1),SB=y1(_k(),1);var Eg0=y1(Cx0(),1);var It=y1(Ou0(),1);var Mu0=y1(Oz(),1);function Nu0(Y){if(Y>=48&&Y<=57)return Y-48;if(Y>=97&&Y<=102)return Y-87;return Y-55}function ek(Y){let X=new Uint8Array(Y.length/2),Q=0;for(let J=0;J<Y.length;J+=2){let G=Nu0(Y.charCodeAt(J)),K=Nu0(Y.charCodeAt(J+1));X[Q++]=G<<4|K}return X}function wu0(Y){let X=BigInt(1e9);return BigInt(Math.trunc(Y[0]))*X+BigInt(Math.trunc(Y[1]))}function uF4(Y){let X=Number(BigInt.asUintN(32,Y)),Q=Number(BigInt.asUintN(32,Y>>BigInt(32)));return{low:X,high:Q}}function Pu0(Y){let X=wu0(Y);return uF4(X)}function gF4(Y){return wu0(Y).toString()}var mF4=typeof BigInt<"u"?gF4:Mu0.hrTimeToNanoseconds;function Lu0(Y){return Y}function Tu0(Y){if(Y===void 0)return;return ek(Y)}var lF4={encodeHrTime:Pu0,encodeSpanContext:ek,encodeOptionalSpanContext:Tu0};function Au0(Y){if(Y===void 0)return lF4;let X=Y.useLongBits??!0,Q=Y.useHex??!1;return{encodeHrTime:X?Pu0:mF4,encodeSpanContext:Q?Lu0:ek,encodeOptionalSpanContext:Q?Lu0:Tu0}}function Eu0(Y){let X={attributes:dF4(Y.attributes),droppedAttributesCount:0},Q=Y.schemaUrl;if(Q&&Q!=="")X.schemaUrl=Q;return X}function Cu0(Y){return{name:Y.name,version:Y.version}}function dF4(Y){return Object.keys(Y).map((X)=>Yv(X,Y[X]))}function Yv(Y,X){return{key:Y,value:Xv(X)}}function Xv(Y){let X=typeof Y;if(X==="string")return{stringValue:Y};if(X==="number"){if(!Number.isInteger(Y))return{doubleValue:Y};return{intValue:Y}}if(X==="boolean")return{boolValue:Y};if(Y instanceof Uint8Array)return{bytesValue:Y};if(Array.isArray(Y))return{arrayValue:{values:Y.map(Xv)}};if(X==="object"&&Y!=null)return{kvlistValue:{values:Object.entries(Y).map(([Q,J])=>Yv(Q,J))}};return{}}function Iu0(Y,X){let Q=Au0(X);return{resourceLogs:cF4(Y,Q)}}function pF4(Y){let X=new Map;for(let Q of Y){let{resource:J,instrumentationScope:{name:G,version:K="",schemaUrl:W=""}}=Q,Z=X.get(J);if(!Z)Z=new Map,X.set(J,Z);let H=`${G}@${K}:${W}`,F=Z.get(H);if(!F)F=[],Z.set(H,F);F.push(Q)}return X}function cF4(Y,X){let Q=pF4(Y);return Array.from(Q,([J,G])=>{let K=Eu0(J);return{resource:K,scopeLogs:Array.from(G,([,W])=>{return{scope:Cu0(W[0].instrumentationScope),logRecords:W.map((Z)=>nF4(Z,X)),schemaUrl:W[0].instrumentationScope.schemaUrl}}),schemaUrl:K.schemaUrl}})}function nF4(Y,X){return{timeUnixNano:X.encodeHrTime(Y.hrTime),observedTimeUnixNano:X.encodeHrTime(Y.hrTimeObserved),severityNumber:iF4(Y.severityNumber),severityText:Y.severityText,body:Xv(Y.body),eventName:Y.eventName,attributes:aF4(Y.attributes),droppedAttributesCount:Y.droppedAttributesCount,flags:Y.spanContext?.traceFlags,traceId:X.encodeOptionalSpanContext(Y.spanContext?.traceId),spanId:X.encodeOptionalSpanContext(Y.spanContext?.spanId)}}function iF4(Y){return Y}function aF4(Y){return Object.keys(Y).map((X)=>Yv(X,Y[X]))}var rF4=It.opentelemetry.proto.collector.logs.v1.ExportLogsServiceResponse,oF4=It.opentelemetry.proto.collector.logs.v1.ExportLogsServiceRequest,Qv={serializeRequest:(Y)=>{let X=Iu0(Y);return oF4.encode(X).finish()},deserializeResponse:(Y)=>{return rF4.decode(Y)}};var Wv=y1(kt(),1);class Mz extends Eg0.OTLPExporterBase{constructor(Y={}){super(Wv.createOtlpHttpExportDelegate(Wv.convertLegacyHttpOptions(Y,"LOGS","v1/logs",{"Content-Type":"application/x-protobuf"}),Qv))}}var zZ6=y1(si0(),1),BZ6=y1(U00(),1),UZ6=y1(ze0(),1);var cG=y1(l0(),1);var lA4=globalThis.fetch;async function dA4(Y,X){let Q,J;if(Y instanceof Request)Q=new URL(Y.url),J=X?.method??Y.method;else if(Y instanceof URL)Q=Y,J=X?.method??"GET";else Q=new URL(Y),J=X?.method??"GET";let G=`${J} ${Q.host}`;return i00.startActiveSpan(G,{kind:cG.SpanKind.CLIENT,attributes:{"http.request.method":J,"url.full":Q.href,"url.scheme":Q.protocol.replace(":",""),"url.path":Q.pathname,"url.query":Q.search||void 0,"server.address":Q.hostname,"server.port":Q.port?Number(Q.port):void 0}},async(K)=>{try{let W=new Headers(X?.headers??(Y instanceof Request?Y.headers:{}));cG.propagation.inject(cG.context.active(),W,{set:(F,V,q)=>F.set(V,q)});let Z={...X,headers:W},H=await lA4(Y,Z);if(K.setAttribute("http.response.status_code",H.status),H.status>=400)K.setStatus({code:cG.SpanStatusCode.ERROR,message:`HTTP ${H.status}`});else K.setStatus({code:cG.SpanStatusCode.OK});return H}catch(W){throw K.recordException(W),K.setStatus({code:cG.SpanStatusCode.ERROR,message:W instanceof Error?W.message:"Fetch failed"}),W}finally{K.end()}})}function Be0(){globalThis.fetch=dA4}var Ue0=y1(l0(),1),y9=y1(Oz(),1);class a00{_maxExportBatchSize;_maxQueueSize;_scheduledDelayMillis;_exportTimeoutMillis;_exporter;_isExporting=!1;_finishedLogRecords=[];_timer;_shutdownOnce;constructor(Y,X){if(this._exporter=Y,this._maxExportBatchSize=X?.maxExportBatchSize??y9.getNumberFromEnv("OTEL_BLRP_MAX_EXPORT_BATCH_SIZE")??512,this._maxQueueSize=X?.maxQueueSize??y9.getNumberFromEnv("OTEL_BLRP_MAX_QUEUE_SIZE")??2048,this._scheduledDelayMillis=X?.scheduledDelayMillis??y9.getNumberFromEnv("OTEL_BLRP_SCHEDULE_DELAY")??5000,this._exportTimeoutMillis=X?.exportTimeoutMillis??y9.getNumberFromEnv("OTEL_BLRP_EXPORT_TIMEOUT")??30000,this._shutdownOnce=new y9.BindOnceFuture(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize)Ue0.diag.warn("BatchLogRecordProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize"),this._maxExportBatchSize=this._maxQueueSize}onEmit(Y){if(this._shutdownOnce.isCalled)return;this._addToBuffer(Y)}forceFlush(){if(this._shutdownOnce.isCalled)return this._shutdownOnce.promise;return this._flushAll()}shutdown(){return this._shutdownOnce.call()}async _shutdown(){this.onShutdown(),await this._flushAll(),await this._exporter.shutdown()}_addToBuffer(Y){if(this._finishedLogRecords.length>=this._maxQueueSize)return;this._finishedLogRecords.push(Y),this._maybeStartTimer()}_flushAll(){return new Promise((Y,X)=>{let Q=[],J=Math.ceil(this._finishedLogRecords.length/this._maxExportBatchSize);for(let G=0;G<J;G++)Q.push(this._flushOneBatch());Promise.all(Q).then(()=>{Y()}).catch(X)})}_flushOneBatch(){if(this._clearTimer(),this._finishedLogRecords.length===0)return Promise.resolve();return y9.callWithTimeout(this._export(this._finishedLogRecords.splice(0,this._maxExportBatchSize)),this._exportTimeoutMillis)}_maybeStartTimer(){if(this._isExporting)return;let Y=()=>{this._isExporting=!0,this._flushOneBatch().then(()=>{if(this._isExporting=!1,this._finishedLogRecords.length>0)this._clearTimer(),this._maybeStartTimer()}).catch((X)=>{this._isExporting=!1,y9.globalErrorHandler(X)})};if(this._finishedLogRecords.length>=this._maxExportBatchSize)return Y();if(this._timer!==void 0)return;if(this._timer=setTimeout(()=>Y(),this._scheduledDelayMillis),typeof this._timer!=="number")this._timer.unref()}_clearTimer(){if(this._timer!==void 0)clearTimeout(this._timer),this._timer=void 0}_export(Y){let X=()=>y9.internal._export(this._exporter,Y).then((J)=>{if(J.code!==y9.ExportResultCode.SUCCESS)y9.globalErrorHandler(J.error??Error(`BatchLogRecordProcessor: log record export failed (status ${J})`))}).catch(y9.globalErrorHandler),Q=[];for(let J=0;J<Y.length;J++){let G=Y[J].resource;if(G.asyncAttributesPending&&typeof G.waitForAsyncAttributes==="function")Q.push(G.waitForAsyncAttributes())}if(Q.length===0)return X();else return Promise.all(Q).then(X,y9.globalErrorHandler)}}class lz extends a00{onShutdown(){}}var DZ6=y1(qZ6(),1);var K7;(function(Y){Y[Y.NOT_RECORD=0]="NOT_RECORD",Y[Y.RECORD=1]="RECORD",Y[Y.RECORD_AND_SAMPLED=2]="RECORD_AND_SAMPLED"})(K7||(K7={}));var ul4="__d",gl4=JV.createContextKey("Current request"),ml4=0.1,$Z6=(Y)=>{let Q=new URL(Y.url).searchParams.get(ul4);if(Q==="")return crypto.randomUUID();if(!Q)Q=Y.headers.get("x-trace-debug-id");return Q};class OZ6{inner;constructor(Y){this.inner=Y}shouldSample(Y,X,Q,J,G,K){let W=Y.getValue(gl4);if(!W){if(this.inner)return this.inner.shouldSample(Y,X,Q,J,G,K);return{decision:K7.RECORD_AND_SAMPLED}}let Z=$Z6(W);if(Z)return{decision:K7.RECORD_AND_SAMPLED,attributes:{"trace.debug.id":Z}};if(this.inner){let H=this.inner.shouldSample(Y,X,Q,J,G,K);if(H.decision===K7.RECORD_AND_SAMPLED){let F=crypto.randomUUID();H.attributes={...H.attributes??{},"trace.debug.id":F}}return H}return{decision:K7.NOT_RECORD}}toString(){return"DebugSampler"}}class NZ6{ratio;constructor(Y){this.ratio=Y}shouldSample(){if(Math.random()<this.ratio)return{decision:K7.RECORD_AND_SAMPLED};return{decision:K7.NOT_RECORD}}toString(){return`RatioSampler(${this.ratio})`}}var ll4=new zZ6.PrometheusExporter({preventServerStart:!0}),dl4=new OZ6(new NZ6(ml4)),pl4=new DZ6.NodeSDK({serviceName:process.env.OTEL_SERVICE_NAME??"mesh",traceExporter:new BZ6.OTLPTraceExporter,metricReader:ll4,sampler:dl4,logRecordProcessors:[new lz(new Mz)],instrumentations:[new UZ6.RuntimeNodeInstrumentation]});pl4.start();Be0();var i00=JV.trace.getTracer("mesh","1.0.0"),LZ6=JV.metrics.getMeter("mesh","1.0.0"),cl4=SB.logs.getLogger("mesh","1.0.0"),K90=(Y,X,Q)=>{let J={},G=Q,K=Q[Q.length-1];if(K!==null&&typeof K==="object"&&!Array.isArray(K)&&!(K instanceof Error)&&Object.getPrototypeOf(K)===Object.prototype)J=K,G=Q.slice(0,-1);let W=G.map((Z)=>{if(Z instanceof Error)return`${Z.name}: ${Z.message}`;if(typeof Z==="object")try{return JSON.stringify(Z)}catch{return"[Object]"}return String(Z)}).join(" ");cl4.emit({severityNumber:Y,severityText:X,body:W,attributes:{"log.source":"console",...J}})},H90={error:console.error.bind(console),warn:console.warn.bind(console),debug:console.debug.bind(console)};console.error=(...Y)=>{K90(SB.SeverityNumber.ERROR,"ERROR",Y),H90.error(...Y)};console.warn=(...Y)=>{K90(SB.SeverityNumber.WARN,"WARN",Y),H90.warn(...Y)};console.debug=(...Y)=>{K90(SB.SeverityNumber.DEBUG,"DEBUG",Y),H90.debug(...Y)};var al4=LZ6.createHistogram("db.query.duration",{description:"Database query execution duration in milliseconds",unit:"ms"}),rl4=["PRAGMA busy_timeout = ?;"],ol4=400,AZ6=(Y)=>{let X={"db.statement":Y.query.sql,"db.status":Y.level==="error"?"error":"success"};if(Y.queryDurationMillis>ol4)console.error("Slow query detected:",{durationMs:Y.queryDurationMillis,sql:Y.query.sql,params:Y.query.parameters});if(al4.record(Y.queryDurationMillis,X),Y.level==="error"&&!rl4.includes(Y.query.sql))console.error("Query failed:",{durationMs:Y.queryDurationMillis,error:Y.error,sql:Y.query.sql})},EZ6={keepAlive:!0,keepAliveInitialDelayMillis:1e4,idleTimeoutMillis:300000,connectionTimeoutMillis:30000,allowExitOnIdle:!0};function sl4(Y){let X=new po({connectionString:Y.connectionString,max:Y.options?.maxConnections||10,ssl:process.env.DATABASE_PG_SSL==="true"?!0:!1,...EZ6}),Q=new wZ6({pool:X});return{type:"postgres",db:new MZ6({dialect:Q,log:AZ6}),pool:X}}function CZ6(Y){if(Y===":memory:")return":memory:";if(Y.includes("://"))return new URL(Y).pathname;return Y}function IZ6(Y){if(Y!==":memory:"&&Y!=="/"&&Y){let X=Y.substring(0,Y.lastIndexOf("/"));if(X&&X!=="/"&&!nl4(X))try{il4(X,{recursive:!0})}catch{return console.warn(`Failed to create directory ${X}, using in-memory database`),":memory:"}}return Y}function tl4(Y){let X=CZ6(Y.connectionString);X=IZ6(X);let Q=new PZ6({url:X||":memory:"}),J=new MZ6({dialect:Q,log:AZ6});if(!0)F90`PRAGMA foreign_keys = ON;`.execute(J).catch(()=>{});if(X!==":memory:"&&Y.options?.enableWAL!==!1)F90`PRAGMA journal_mode = WAL;`.execute(J).catch(()=>{});if(X!==":memory:"){let K=Y.options?.busyTimeout||5000;F90`PRAGMA busy_timeout = ${K};`.execute(J).catch(()=>{})}return{type:"sqlite",db:J}}function RZ6(Y){let X=Y||"file:./data/mesh.db";if(X===":memory:")return{type:"sqlite",connectionString:":memory:"};X=X.startsWith("/")?`file://${X}`:X;let Q=URL.canParse(X)?new URL(X):null,J=Q?.protocol.replace(":","")??X.split("://")[0];switch(J){case"postgres":case"postgresql":return{type:"postgres",connectionString:X};case"sqlite":case"file":if(!Q?.pathname)throw Error("Invalid database URL: "+X);return{type:"sqlite",connectionString:Q.pathname};default:throw Error(`Unsupported database protocol: ${J}. Supported protocols: postgres://, postgresql://, sqlite://, file://`)}}function q90(){return process.env.DATABASE_URL||`file:${TZ6.join(process.cwd(),"data/mesh.db")}`}function SZ6(Y){let X=RZ6(Y);if(X.type==="postgres")return new wZ6({pool:new po({connectionString:X.connectionString,max:X.options?.maxConnections||10,ssl:process.env.DATABASE_PG_SSL==="true"?!0:!1,...EZ6})});let Q=CZ6(X.connectionString);return Q=IZ6(Q),new PZ6({url:Q||":memory:"})}function el4(Y){let X=RZ6(Y);if(X.type==="postgres")return sl4(X);return tl4(X)}async function jZ6(Y){if(await Y.db.destroy(),Y.type==="postgres"&&!Y.pool.ended)await Y.pool.end()}var V90=null;function zP(){if(!V90)V90=el4(q90());return V90}class $90{apiKey;constructor(Y){this.apiKey=Y}async sendEmail({to:Y,from:X,subject:Q,html:J}){let G=await fetch("https://api.resend.com/emails",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({to:Y,from:X,subject:Q,html:J})});if(!G.ok)throw Error(`Failed to send email: ${G.statusText}`)}}class z90{apiKey;constructor(Y){this.apiKey=Y}async sendEmail({to:Y,from:X,subject:Q,html:J}){let G=await fetch("https://api.sendgrid.com/v3/mail/send",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({personalizations:[{to:[{email:Y}]}],from:{email:X},subject:Q,content:[{type:"text/html",value:J}]})});if(!G.ok){let K=await G.text();throw Error(`Failed to send email via SendGrid: ${G.statusText} - ${K}`)}}}var Yd4=(Y)=>{let X=new $90(Y.config.apiKey);return async({to:Q,subject:J,html:G})=>{await X.sendEmail({to:Q,from:Y.config.fromEmail,subject:J,html:G})}},Xd4=(Y)=>{let X=new z90(Y.config.apiKey);return async({to:Q,subject:J,html:G})=>{await X.sendEmail({to:Q,from:Y.config.fromEmail,subject:J,html:G})}},Qd4={resend:Yd4,sendgrid:Xd4};function Vf(Y){let X=Qd4[Y.provider];if(!X)throw Error(`Unknown email provider: ${Y.provider}`);return X(Y)}function qf(Y,X){return Y.find((Q)=>Q.id===X)}var kZ6=(Y,X)=>{let Q=qf(X,Y.emailProviderId);if(!Q)throw Error(`Email provider with id '${Y.emailProviderId}' not found`);let J=Vf(Q);return{sendMagicLink:async({email:G,url:K})=>{await J({to:G,subject:"Magic Link",html:`<p>Click <a href="${K}">here</a> to login</p>`})}}};I7();import{createCipheriv as Jd4,createDecipheriv as Gd4,randomBytes as vZ6}from"crypto";var _Z6="aes-256-gcm",BP=16,yZ6=16,fZ6=32;class B90{key;constructor(Y){if(Buffer.from(Y,"base64").length===fZ6)this.key=Buffer.from(Y,"base64");else{let X=q0("crypto");this.key=X.createHash("sha256").update(Y).digest()}}async encrypt(Y){let X=vZ6(BP),Q=Jd4(_Z6,this.key,X),J=Q.update(Y,"utf8");J=Buffer.concat([J,Q.final()]);let G=Q.getAuthTag();return Buffer.concat([X,G,J]).toString("base64")}async decrypt(Y){let X=Buffer.from(Y,"base64"),Q=X.subarray(0,BP),J=X.subarray(BP,BP+yZ6),G=X.subarray(BP+yZ6),K=Gd4(_Z6,this.key,Q);K.setAuthTag(J);let W=K.update(G);return W=Buffer.concat([W,K.final()]),W.toString("utf8")}static generateKey(){return vZ6(fZ6).toString("base64")}}eK();UP();I7();var Wd4=["connection_headers","oauth_config","configuration_scopes","metadata","tools","bindings"];class U90{db;vault;constructor(Y,X){this.db=Y;this.vault=X}async create(Y){let X=Y.id??Y3("conn"),Q=new Date().toISOString(),J=await this.findById(X);if(J){if(J.organization_id!==Y.organization_id)throw Error("Connection ID already exists");return this.update(X,Y)}let G=await this.serializeConnection({...Y,id:Y.id??X,status:"active",created_at:Q,updated_at:Q});await this.db.insertInto("connections").values(G).execute();let K=await this.findById(X);if(!K)throw Error(`Failed to create connection with id: ${X}`);return K}async findById(Y,X){let Q=jd(Y);if(Q)return kd(X??Q);let J=this.db.selectFrom("connections").selectAll().where("id","=",Y);if(X)J=J.where("organization_id","=",X);let G=await J.executeTakeFirst();return G?this.deserializeConnection(G):null}async list(Y,X){let Q=this.db.selectFrom("connections").selectAll().where("organization_id","=",Y);if(!X?.includeVirtual)Q=Q.where("connection_type","!=","VIRTUAL");let J=await Q.execute();return Promise.all(J.map((G)=>this.deserializeConnection(G)))}async update(Y,X){if(Object.keys(X).length===0){let G=await this.findById(Y);if(!G)throw Error("Connection not found");return G}let Q=await this.serializeConnection({...X,updated_at:new Date().toISOString()});await this.db.updateTable("connections").set(Q).where("id","=",Y).execute();let J=await this.findById(Y);if(!J)throw Error("Connection not found after update");return J}async delete(Y){await this.db.deleteFrom("connections").where("id","=",Y).execute()}async testConnection(Y,X){let Q=await this.findById(Y);if(!Q)throw Error("Connection not found");let J=Date.now();if(Q.connection_type==="STDIO")return{healthy:!0,latencyMs:Date.now()-J};if(!Q.connection_url)return{healthy:!1,latencyMs:Date.now()-J};try{let G=Q.connection_headers,K=await fetch(Q.connection_url,{method:"POST",headers:{"Content-Type":"application/json",...Q.connection_token&&{Authorization:`Bearer ${Q.connection_token}`},...G?.headers,...X},body:JSON.stringify({jsonrpc:"2.0",method:"ping",id:1})});return{healthy:K.ok||K.status===404,latencyMs:Date.now()-J}}catch{return{healthy:!1,latencyMs:Date.now()-J}}}async serializeConnection(Y){let X={};for(let[Q,J]of Object.entries(Y)){if(J===void 0)continue;if(Q==="connection_token"&&J)X[Q]=await this.vault.encrypt(J);else if(Q==="configuration_state"&&J){let G=JSON.stringify(J);X[Q]=await this.vault.encrypt(G)}else if(Q==="connection_headers"&&J){let G=J;if(wZ(G)&&G.envVars){let K={};for(let[W,Z]of Object.entries(G.envVars))K[W]=await this.vault.encrypt(Z);X[Q]=JSON.stringify({...G,envVars:K})}else X[Q]=JSON.stringify(G)}else if(Wd4.includes(Q))X[Q]=J?JSON.stringify(J):null;else X[Q]=J}return X}async deserializeConnection(Y){let X=null;if(Y.connection_token)try{X=await this.vault.decrypt(Y.connection_token)}catch(K){console.error("Failed to decrypt connection token:",K)}let Q=null;if(Y.configuration_state)try{let K=await this.vault.decrypt(Y.configuration_state);Q=JSON.parse(K)}catch(K){console.error("Failed to decrypt configuration state:",K)}let J=null;if(Y.connection_headers)try{let K=JSON.parse(Y.connection_headers);if(wZ(K)&&K.envVars){let W={};for(let[Z,H]of Object.entries(K.envVars))try{W[Z]=await this.vault.decrypt(H)}catch{W[Z]=H}J={...K,envVars:W}}else J=K}catch(K){console.error("Failed to parse connection_headers:",K)}let G=(K)=>{if(K===null)return null;if(typeof K==="string")try{return JSON.parse(K)}catch{return null}return K};return{id:Y.id,organization_id:Y.organization_id,created_by:Y.created_by,updated_by:Y.updated_by??void 0,title:Y.title,description:Y.description,icon:Y.icon,app_name:Y.app_name,app_id:Y.app_id,connection_type:Y.connection_type,connection_url:Y.connection_url,connection_token:X,connection_headers:J,oauth_config:G(Y.oauth_config),configuration_state:Q,configuration_scopes:G(Y.configuration_scopes),metadata:G(Y.metadata),tools:G(Y.tools),bindings:G(Y.bindings),status:Y.status,created_at:Y.created_at,updated_at:Y.updated_at}}}UP();class D90{db;constructor(Y){this.db=Y}parseRow(Y){return{id:Y.id,organizationId:Y.organization_id,slug:Y.slug,name:Y.name,description:Y.description,enabledPlugins:Y.enabled_plugins?typeof Y.enabled_plugins==="string"?JSON.parse(Y.enabled_plugins):Y.enabled_plugins:null,ui:Y.ui?typeof Y.ui==="string"?JSON.parse(Y.ui):Y.ui:null,createdAt:Y.created_at,updatedAt:Y.updated_at}}async list(Y){return(await this.db.selectFrom("projects").selectAll().where("organization_id","=",Y).orderBy("created_at","asc").execute()).map((Q)=>this.parseRow(Q))}async get(Y){let X=await this.db.selectFrom("projects").selectAll().where("id","=",Y).executeTakeFirst();return X?this.parseRow(X):null}async getBySlug(Y,X){let Q=await this.db.selectFrom("projects").selectAll().where("organization_id","=",Y).where("slug","=",X).executeTakeFirst();return Q?this.parseRow(Q):null}async create(Y){let X=new Date().toISOString(),Q=Y3("proj");await this.db.insertInto("projects").values({id:Q,organization_id:Y.organizationId,slug:Y.slug,name:Y.name,description:Y.description??null,enabled_plugins:Y.enabledPlugins?JSON.stringify(Y.enabledPlugins):null,ui:Y.ui?JSON.stringify(Y.ui):null,created_at:X,updated_at:X}).execute();let J=await this.get(Q);if(!J)throw Error("Failed to create project");return J}async update(Y,X){let Q={updated_at:new Date().toISOString()};if(X.name!==void 0)Q.name=X.name;if(X.description!==void 0)Q.description=X.description;if(X.enabledPlugins!==void 0)Q.enabled_plugins=X.enabledPlugins?JSON.stringify(X.enabledPlugins):null;if(X.ui!==void 0)Q.ui=X.ui?JSON.stringify(X.ui):null;return await this.db.updateTable("projects").set(Q).where("id","=",Y).execute(),this.get(Y)}async delete(Y){return((await this.db.deleteFrom("projects").where("id","=",Y).executeTakeFirst()).numDeletedRows??0n)>0n}}Df();_0();function vi4(Y){return[{permissions:{self:["*"]},getTools:async()=>{let{ALL_TOOLS:X}=await Promise.resolve().then(() => (tV6(),sV6));return X.map((Q)=>{return{name:Q.name,inputSchema:N.toJSONSchema(Q.inputSchema,{unrepresentable:"any"}),outputSchema:Q.outputSchema?N.toJSONSchema(Q.outputSchema,{unrepresentable:"any"}):void 0,description:Q.description}})},data:Rd(B5(),Y)},{data:Id()},{data:Cd(Y)}]}async function eV6(Y,X){try{let Q=zP(),J=new B90(process.env.ENCRYPTION_KEY||""),G=new U90(Q.db,J),K=new D90(Q.db),W=vi4(Y);try{await K.create({organizationId:Y,slug:xJ,name:OV,description:"Organization administration and settings",enabledPlugins:null,ui:null})}catch(Z){console.warn("Could not create org-admin project (may already exist):",Z)}await Promise.all(W.map(async(Z)=>{let H=null;if(Z.permissions)H=(await oB.api.createApiKey({body:{name:`${Z.data.app_name??crypto.randomUUID()}-mcp`,userId:X,permissions:Z.permissions,rateLimitEnabled:!1,metadata:{organization:{id:Y},purpose:"default-org-connections"}}}))?.key;let F=await Z.getTools?.()??await xB({id:"pending",title:Z.data.title,connection_type:Z.data.connection_type,connection_url:Z.data.connection_url,connection_token:Z.data.connection_token,connection_headers:Z.data.connection_headers}).catch(()=>null),V=Z.data.id?Z.data.id.startsWith(`${Y}_`)?Z.data.id:`${Y}_${Z.data.id}`:void 0;await G.create({...Z.data,id:V,tools:F,organization_id:Y,created_by:X,connection_token:Z.data.connection_token??H})}))}catch(Q){console.error("Error creating default MCP connections:",Q)}}var Yq6=["owner","admin"];var _i4=(Y)=>{return{defaultSSO:[{domain:Y.domain,providerId:Y.providerId,oidcConfig:{issuer:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/v2.0`,pkce:!0,clientId:Y.MS_CLIENT_ID,clientSecret:Y.MS_CLIENT_SECRET,discoveryEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/v2.0/.well-known/openid-configuration`,authorizationEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/oauth2/v2.0/authorize`,tokenEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/oauth2/v2.0/token`,jwksEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/discovery/v2.0/keys`,userInfoEndpoint:"https://graph.microsoft.com/oidc/userinfo",tokenEndpointAuthentication:"client_secret_post",scopes:Y.scopes,mapping:{id:"sub",email:"email",emailVerified:"email_verified",name:"name",image:"picture",extraFields:{emailVerified:"email_verified"}}}}]}},Xq6=(Y)=>{if(Y.providerId==="microsoft")return _i4(Y);throw Error(`Unsupported provider: ${Y.providerId}`)};function yi4(Y){return Y.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Qq6=["labs","agent","studio","workspace","systems","core","cloud","works"],Jq6=["capybara","guarana","deco","samba","feijoada","capoeira","carnival"];function fi4(){let Y=Math.floor(Math.random()*Jq6.length),X=Math.floor(Math.random()*Qq6.length),Q=Jq6[Y]??"deco",J=Qq6[X]??"studio";return`${Q}-${J}`}var hi4=Object.values(Dc()).map((Y)=>Y.map((X)=>X.name)).flat(),bi4={...sj,self:["*",...hi4]},bf=hG(bi4),xi4=bf.newRole({self:["*"],...dL.statements}),ui4=bf.newRole({self:["*"],...dL.statements}),gi4=bf.newRole({self:["*"],...dL.statements}),Gq6=Object.values(Dc()).map((Y)=>Y.map((X)=>`self:${X.name}`)).flat(),vQ=Ko.auth,Wq6=void 0;if(vQ.inviteEmailProviderId&&vQ.emailProviders&&vQ.emailProviders.length>0){let Y=qf(vQ.emailProviders,vQ.inviteEmailProviderId);if(Y){let X=Vf(Y);Wq6=async(Q)=>{let J=Q.inviter.user?.name||Q.inviter.user?.email,G=`${B5()}/auth/accept-invitation?invitationId=${Q.invitation.id}&redirectTo=/`;await X({to:Q.email,subject:`Invitation to join ${Q.organization.name}`,html:`
1196
1196
  <h2>You've been invited!</h2>
1197
1197
  <p>${J} has invited you to join <strong>${Q.organization.name}</strong>.</p>
1198
1198
  <p><a href="${G}">Click here to accept the invitation</a></p>
@@ -1044,7 +1044,7 @@ Please refer to the documentation here: https://better-auth.com/docs/plugins/org
1044
1044
  </script>
1045
1045
  <script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference" ${J}></script>
1046
1046
  </body>
1047
- </html>`},qX0=(Y)=>{let X=Y?.path??"/reference";return{id:"open-api",endpoints:{generateOpenAPISchema:g0("/open-api/generate-schema",{method:"GET"},async(Q)=>{let J=await pK1(Q.context,Q.context.options);return Q.json(J)}),openAPIReference:g0(X,{method:"GET",metadata:{isAction:!1}},async(Q)=>{if(Y?.disableDefaultReference)throw new i("NOT_FOUND");let J=await pK1(Q.context,Q.context.options);return new Response(pi6(J,Y?.theme,Y?.nonce),{headers:{"Content-Type":"text/html"}})})}}};hX();y7();K9();XY();h0();var A98=Z4(async()=>{return{}}),P98=Z4({use:[q8]},async(Y)=>{return{session:Y.context.session}}),T98=y4({YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_ORGANIZATION:"You are not allowed to create a new organization",YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS:"You have reached the maximum number of organizations",ORGANIZATION_ALREADY_EXISTS:"Organization already exists",ORGANIZATION_SLUG_ALREADY_TAKEN:"Organization slug already taken",ORGANIZATION_NOT_FOUND:"Organization not found",USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION:"User is not a member of the organization",YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_ORGANIZATION:"You are not allowed to update this organization",YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_ORGANIZATION:"You are not allowed to delete this organization",NO_ACTIVE_ORGANIZATION:"No active organization",USER_IS_ALREADY_A_MEMBER_OF_THIS_ORGANIZATION:"User is already a member of this organization",MEMBER_NOT_FOUND:"Member not found",ROLE_NOT_FOUND:"Role not found",YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM:"You are not allowed to create a new team",TEAM_ALREADY_EXISTS:"Team already exists",TEAM_NOT_FOUND:"Team not found",YOU_CANNOT_LEAVE_THE_ORGANIZATION_AS_THE_ONLY_OWNER:"You cannot leave the organization as the only owner",YOU_CANNOT_LEAVE_THE_ORGANIZATION_WITHOUT_AN_OWNER:"You cannot leave the organization without an owner",YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_MEMBER:"You are not allowed to delete this member",YOU_ARE_NOT_ALLOWED_TO_INVITE_USERS_TO_THIS_ORGANIZATION:"You are not allowed to invite users to this organization",USER_IS_ALREADY_INVITED_TO_THIS_ORGANIZATION:"User is already invited to this organization",INVITATION_NOT_FOUND:"Invitation not found",YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION:"You are not the recipient of the invitation",EMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION:"Email verification required before accepting or rejecting invitation",YOU_ARE_NOT_ALLOWED_TO_CANCEL_THIS_INVITATION:"You are not allowed to cancel this invitation",INVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION:"Inviter is no longer a member of the organization",YOU_ARE_NOT_ALLOWED_TO_INVITE_USER_WITH_THIS_ROLE:"You are not allowed to invite a user with this role",FAILED_TO_RETRIEVE_INVITATION:"Failed to retrieve invitation",YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_TEAMS:"You have reached the maximum number of teams",UNABLE_TO_REMOVE_LAST_TEAM:"Unable to remove last team",YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_MEMBER:"You are not allowed to update this member",ORGANIZATION_MEMBERSHIP_LIMIT_REACHED:"Organization membership limit reached",YOU_ARE_NOT_ALLOWED_TO_CREATE_TEAMS_IN_THIS_ORGANIZATION:"You are not allowed to create teams in this organization",YOU_ARE_NOT_ALLOWED_TO_DELETE_TEAMS_IN_THIS_ORGANIZATION:"You are not allowed to delete teams in this organization",YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_TEAM:"You are not allowed to update this team",YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_TEAM:"You are not allowed to delete this team",INVITATION_LIMIT_REACHED:"Invitation limit reached",TEAM_MEMBER_LIMIT_REACHED:"Team member limit reached",USER_IS_NOT_A_MEMBER_OF_THE_TEAM:"User is not a member of the team",YOU_CAN_NOT_ACCESS_THE_MEMBERS_OF_THIS_TEAM:"You are not allowed to list the members of this team",YOU_DO_NOT_HAVE_AN_ACTIVE_TEAM:"You do not have an active team",YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM_MEMBER:"You are not allowed to create a new member",YOU_ARE_NOT_ALLOWED_TO_REMOVE_A_TEAM_MEMBER:"You are not allowed to remove a team member",YOU_ARE_NOT_ALLOWED_TO_ACCESS_THIS_ORGANIZATION:"You are not allowed to access this organization as an owner",YOU_ARE_NOT_A_MEMBER_OF_THIS_ORGANIZATION:"You are not a member of this organization",MISSING_AC_INSTANCE:"Dynamic Access Control requires a pre-defined ac instance on the server auth plugin. Read server logs for more information",YOU_MUST_BE_IN_AN_ORGANIZATION_TO_CREATE_A_ROLE:"You must be in an organization to create a role",YOU_ARE_NOT_ALLOWED_TO_CREATE_A_ROLE:"You are not allowed to create a role",YOU_ARE_NOT_ALLOWED_TO_UPDATE_A_ROLE:"You are not allowed to update a role",YOU_ARE_NOT_ALLOWED_TO_DELETE_A_ROLE:"You are not allowed to delete a role",YOU_ARE_NOT_ALLOWED_TO_READ_A_ROLE:"You are not allowed to read a role",YOU_ARE_NOT_ALLOWED_TO_LIST_A_ROLE:"You are not allowed to list a role",YOU_ARE_NOT_ALLOWED_TO_GET_A_ROLE:"You are not allowed to get a role",TOO_MANY_ROLES:"This organization has too many roles",INVALID_RESOURCE:"The provided permission includes an invalid resource",ROLE_NAME_IS_ALREADY_TAKEN:"That role name is already taken",CANNOT_DELETE_A_PRE_DEFINED_ROLE:"Cannot delete a pre-defined role"});var E98=Number.POSITIVE_INFINITY;var nK1=M(),ni6=z1(["pending","accepted","rejected","canceled"]).default("pending"),C98=p({id:M().default(M9),name:M(),slug:M(),logo:M().nullish().optional(),metadata:Y1(M(),V4()).or(M().transform((Y)=>JSON.parse(Y))).optional(),createdAt:X6()}),I98=p({id:M().default(M9),organizationId:M(),userId:h1.string(),role:nK1,createdAt:X6().default(()=>new Date)}),R98=p({id:M().default(M9),organizationId:M(),email:M(),role:nK1,status:ni6,teamId:M().nullish(),inviterId:M(),expiresAt:X6(),createdAt:X6().default(()=>new Date)}),S98=p({id:M().default(M9),name:M().min(1),organizationId:M(),createdAt:X6(),updatedAt:X6().optional()}),j98=p({id:M().default(M9),teamId:M(),userId:M(),createdAt:X6().default(()=>new Date)}),k98=p({id:M().default(M9),organizationId:M(),role:M(),permission:Y1(M(),P0(M())),createdAt:X6().default(()=>new Date),updatedAt:X6().optional()}),cK1=["admin","member","owner"],v98=Q6([z1(cK1),P0(z1(cK1))]);E8();K9();XY();var l98=y4({INVALID_PHONE_NUMBER:"Invalid phone number",PHONE_NUMBER_EXIST:"Phone number already exists",PHONE_NUMBER_NOT_EXIST:"phone number isn't registered",INVALID_PHONE_NUMBER_OR_PASSWORD:"Invalid phone number or password",UNEXPECTED_ERROR:"Unexpected error",OTP_NOT_FOUND:"OTP not found",OTP_EXPIRED:"OTP expired",INVALID_OTP:"Invalid OTP",PHONE_NUMBER_NOT_VERIFIED:"Phone number not verified",PHONE_NUMBER_CANNOT_BE_UPDATED:"Phone number cannot be updated",SEND_OTP_NOT_IMPLEMENTED:"sendOTP not implemented",TOO_MANY_ATTEMPTS:"Too many attempts"});E8();bX();K9();XY();s9();G8();var ii6=y4({OTP_NOT_ENABLED:"OTP not enabled",OTP_HAS_EXPIRED:"OTP has expired",TOTP_NOT_ENABLED:"TOTP not enabled",TWO_FACTOR_NOT_ENABLED:"Two factor isn't enabled",BACKUP_CODES_NOT_ENABLED:"Backup codes aren't enabled",INVALID_BACKUP_CODE:"Invalid backup code",INVALID_CODE:"Invalid code",TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE:"Too many attempts. Please request a new code.",INVALID_TWO_FACTOR_COOKIE:"Invalid two factor cookie"});K9();XY();var ai6=y4({INVALID_USERNAME_OR_PASSWORD:"Invalid username or password",EMAIL_NOT_VERIFIED:"Email not verified",UNEXPECTED_ERROR:"Unexpected error",USERNAME_IS_ALREADY_TAKEN:"Username is already taken. Please try another.",USERNAME_TOO_SHORT:"Username is too short",USERNAME_TOO_LONG:"Username is too long",INVALID_USERNAME:"Username is invalid",INVALID_DISPLAY_USERNAME:"Display username is invalid"});var VV={enabled:!0,batchSize:250,flushIntervalMs:300,maxQueueSize:1e4,redactor:"regex"};import{existsSync as iK1,readFileSync as aK1}from"fs";var Nb={emailAndPassword:{enabled:!0}},rK1=process.env.CONFIG_PATH||"./config.json",oK1=process.env.AUTH_CONFIG_PATH||"./auth-config.json";function ri6(){if(iK1(rK1))try{let Y=aK1(rK1,"utf-8"),X=JSON.parse(Y);return{auth:Nb,monitoring:VV,...X}}catch{return{auth:Nb,monitoring:VV}}if(iK1(oK1))try{let Y=aK1(oK1,"utf-8");return{auth:JSON.parse(Y),monitoring:VV}}catch{return{auth:Nb,monitoring:VV}}return{auth:Nb,monitoring:VV}}var aP=ri6();function sK1(){return{...VV,...aP.monitoring}}function tK1(){return aP.theme}import{existsSync as Qt6,mkdirSync as Jt6}from"fs";import{Kysely as TF1,PostgresDialect as EF1,sql as rX0}from"kysely";import{BunWorkerDialect as CF1}from"kysely-bun-worker";import*as IF1 from"path";var F5=l6(cX0(),1),gQ8=F5.default.Client,aX0=F5.default.Pool,mQ8=F5.default.Connection,lQ8=F5.default.types,dQ8=F5.default.Query,pQ8=F5.default.DatabaseError,cQ8=F5.default.escapeIdentifier,nQ8=F5.default.escapeLiteral,iQ8=F5.default.Result,aQ8=F5.default.TypeOverrides,rQ8=F5.default.defaults;var Gt6=XR.createHistogram("db.query.duration",{description:"Database query execution duration in milliseconds",unit:"ms"}),Wt6=["PRAGMA busy_timeout = ?;"],Zt6=400,RF1=(Y)=>{let X={"db.statement":Y.query.sql,"db.status":Y.level==="error"?"error":"success"};if(Y.queryDurationMillis>Zt6)console.error("Slow query detected:",{durationMs:Y.queryDurationMillis,sql:Y.query.sql,params:Y.query.parameters});if(Gt6.record(Y.queryDurationMillis,X),Y.level==="error"&&!Wt6.includes(Y.query.sql))console.error("Query failed:",{durationMs:Y.queryDurationMillis,error:Y.error,sql:Y.query.sql})},SF1={keepAlive:!0,keepAliveInitialDelayMillis:1e4,idleTimeoutMillis:300000,connectionTimeoutMillis:30000,allowExitOnIdle:!0};function Kt6(Y){let X=new aX0({connectionString:Y.connectionString,max:Y.options?.maxConnections||10,ssl:process.env.DATABASE_PG_SSL==="true"?!0:!1,...SF1}),Q=new EF1({pool:X});return{type:"postgres",db:new TF1({dialect:Q,log:RF1}),pool:X}}function jF1(Y){if(Y===":memory:")return":memory:";if(Y.includes("://"))return new URL(Y).pathname;return Y}function kF1(Y){if(Y!==":memory:"&&Y!=="/"&&Y){let X=Y.substring(0,Y.lastIndexOf("/"));if(X&&X!=="/"&&!Qt6(X))try{Jt6(X,{recursive:!0})}catch{return console.warn(`Failed to create directory ${X}, using in-memory database`),":memory:"}}return Y}function Ht6(Y){let X=jF1(Y.connectionString);X=kF1(X);let Q=new CF1({url:X||":memory:"}),J=new TF1({dialect:Q,log:RF1});if(!0)rX0`PRAGMA foreign_keys = ON;`.execute(J).catch(()=>{});if(X!==":memory:"&&Y.options?.enableWAL!==!1)rX0`PRAGMA journal_mode = WAL;`.execute(J).catch(()=>{});if(X!==":memory:"){let K=Y.options?.busyTimeout||5000;rX0`PRAGMA busy_timeout = ${K};`.execute(J).catch(()=>{})}return{type:"sqlite",db:J}}function vF1(Y){let X=Y||"file:./data/mesh.db";if(X===":memory:")return{type:"sqlite",connectionString:":memory:"};X=X.startsWith("/")?`file://${X}`:X;let Q=URL.canParse(X)?new URL(X):null,J=Q?.protocol.replace(":","")??X.split("://")[0];switch(J){case"postgres":case"postgresql":return{type:"postgres",connectionString:X};case"sqlite":case"file":if(!Q?.pathname)throw Error("Invalid database URL: "+X);return{type:"sqlite",connectionString:Q.pathname};default:throw Error(`Unsupported database protocol: ${J}. Supported protocols: postgres://, postgresql://, sqlite://, file://`)}}function sX0(){return process.env.DATABASE_URL||`file:${IF1.join(process.cwd(),"data/mesh.db")}`}function _F1(Y){let X=vF1(Y);if(X.type==="postgres")return new EF1({pool:new aX0({connectionString:X.connectionString,max:X.options?.maxConnections||10,ssl:process.env.DATABASE_PG_SSL==="true"?!0:!1,...SF1})});let Q=jF1(X.connectionString);return Q=kF1(Q),new CF1({url:Q||":memory:"})}function Ft6(Y){let X=vF1(Y);if(X.type==="postgres")return Kt6(X);return Ht6(X)}var oX0=null;function vb(){if(!oX0)oX0=Ft6(sX0());return oX0}class tX0{apiKey;constructor(Y){this.apiKey=Y}async sendEmail({to:Y,from:X,subject:Q,html:J}){let G=await fetch("https://api.resend.com/emails",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({to:Y,from:X,subject:Q,html:J})});if(!G.ok)throw Error(`Failed to send email: ${G.statusText}`)}}class eX0{apiKey;constructor(Y){this.apiKey=Y}async sendEmail({to:Y,from:X,subject:Q,html:J}){let G=await fetch("https://api.sendgrid.com/v3/mail/send",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({personalizations:[{to:[{email:Y}]}],from:{email:X},subject:Q,content:[{type:"text/html",value:J}]})});if(!G.ok){let K=await G.text();throw Error(`Failed to send email via SendGrid: ${G.statusText} - ${K}`)}}}var $t6=(Y)=>{let X=new tX0(Y.config.apiKey);return async({to:Q,subject:J,html:G})=>{await X.sendEmail({to:Q,from:Y.config.fromEmail,subject:J,html:G})}},Vt6=(Y)=>{let X=new eX0(Y.config.apiKey);return async({to:Q,subject:J,html:G})=>{await X.sendEmail({to:Q,from:Y.config.fromEmail,subject:J,html:G})}},qt6={resend:$t6,sendgrid:Vt6};function _b(Y){let X=qt6[Y.provider];if(!X)throw Error(`Unknown email provider: ${Y.provider}`);return X(Y)}function yb(Y,X){return Y.find((Q)=>Q.id===X)}var yF1=(Y,X)=>{let Q=yb(X,Y.emailProviderId);if(!Q)throw Error(`Email provider with id '${Y.emailProviderId}' not found`);let J=_b(Q);return{sendMagicLink:async({email:G,url:K})=>{await J({to:G,subject:"Magic Link",html:`<p>Click <a href="${K}">here</a> to login</p>`})}}};wX();import{createCipheriv as Bt6,createDecipheriv as zt6,randomBytes as fF1}from"crypto";var hF1="aes-256-gcm",GT=16,bF1=16,xF1=32;class zV{key;constructor(Y){if(Buffer.from(Y,"base64").length===xF1)this.key=Buffer.from(Y,"base64");else{let X=F0("crypto");this.key=X.createHash("sha256").update(Y).digest()}}async encrypt(Y){let X=fF1(GT),Q=Bt6(hF1,this.key,X),J=Q.update(Y,"utf8");J=Buffer.concat([J,Q.final()]);let G=Q.getAuthTag();return Buffer.concat([X,G,J]).toString("base64")}async decrypt(Y){let X=Buffer.from(Y,"base64"),Q=X.subarray(0,GT),J=X.subarray(GT,GT+bF1),G=X.subarray(GT+bF1),K=zt6(hF1,this.key,Q);K.setAuthTag(J);let W=K.update(G);return W=Buffer.concat([W,K.final()]),W.toString("utf8")}static generateKey(){return fF1(xF1).toString("base64")}}CZ();$5();wX();var Ot6=["connection_headers","oauth_config","configuration_scopes","metadata","tools","bindings"];class WT{db;vault;constructor(Y,X){this.db=Y;this.vault=X}async create(Y){let X=Y.id??k4("conn"),Q=new Date().toISOString(),J=await this.findById(X);if(J){if(J.organization_id!==Y.organization_id)throw Error("Connection ID already exists");return this.update(X,Y)}let G=await this.serializeConnection({...Y,id:Y.id??X,status:"active",created_at:Q,updated_at:Q});await this.db.insertInto("connections").values(G).execute();let K=await this.findById(X);if(!K)throw Error(`Failed to create connection with id: ${X}`);return K}async findById(Y,X){let Q=mW(Y);if(Q)return S00(X??Q);let J=this.db.selectFrom("connections").selectAll().where("id","=",Y);if(X)J=J.where("organization_id","=",X);let G=await J.executeTakeFirst();return G?this.deserializeConnection(G):null}async list(Y,X){let Q=this.db.selectFrom("connections").selectAll().where("organization_id","=",Y);if(!X?.includeVirtual)Q=Q.where("connection_type","!=","VIRTUAL");let J=await Q.execute();return Promise.all(J.map((G)=>this.deserializeConnection(G)))}async update(Y,X){if(Object.keys(X).length===0){let G=await this.findById(Y);if(!G)throw Error("Connection not found");return G}let Q=await this.serializeConnection({...X,updated_at:new Date().toISOString()});await this.db.updateTable("connections").set(Q).where("id","=",Y).execute();let J=await this.findById(Y);if(!J)throw Error("Connection not found after update");return J}async delete(Y){await this.db.deleteFrom("connections").where("id","=",Y).execute()}async testConnection(Y,X){let Q=await this.findById(Y);if(!Q)throw Error("Connection not found");let J=Date.now();if(Q.connection_type==="STDIO")return{healthy:!0,latencyMs:Date.now()-J};if(!Q.connection_url)return{healthy:!1,latencyMs:Date.now()-J};try{let G=Q.connection_headers,K=await fetch(Q.connection_url,{method:"POST",headers:{"Content-Type":"application/json",...Q.connection_token&&{Authorization:`Bearer ${Q.connection_token}`},...G?.headers,...X},body:JSON.stringify({jsonrpc:"2.0",method:"ping",id:1})});return{healthy:K.ok||K.status===404,latencyMs:Date.now()-J}}catch{return{healthy:!1,latencyMs:Date.now()-J}}}async serializeConnection(Y){let X={};for(let[Q,J]of Object.entries(Y)){if(J===void 0)continue;if(Q==="connection_token"&&J)X[Q]=await this.vault.encrypt(J);else if(Q==="configuration_state"&&J){let G=JSON.stringify(J);X[Q]=await this.vault.encrypt(G)}else if(Q==="connection_headers"&&J){let G=J;if(H7(G)&&G.envVars){let K={};for(let[W,Z]of Object.entries(G.envVars))K[W]=await this.vault.encrypt(Z);X[Q]=JSON.stringify({...G,envVars:K})}else X[Q]=JSON.stringify(G)}else if(Ot6.includes(Q))X[Q]=J?JSON.stringify(J):null;else X[Q]=J}return X}async deserializeConnection(Y){let X=null;if(Y.connection_token)try{X=await this.vault.decrypt(Y.connection_token)}catch(K){console.error("Failed to decrypt connection token:",K)}let Q=null;if(Y.configuration_state)try{let K=await this.vault.decrypt(Y.configuration_state);Q=JSON.parse(K)}catch(K){console.error("Failed to decrypt configuration state:",K)}let J=null;if(Y.connection_headers)try{let K=JSON.parse(Y.connection_headers);if(H7(K)&&K.envVars){let W={};for(let[Z,H]of Object.entries(K.envVars))try{W[Z]=await this.vault.decrypt(H)}catch{W[Z]=H}J={...K,envVars:W}}else J=K}catch(K){console.error("Failed to parse connection_headers:",K)}let G=(K)=>{if(K===null)return null;if(typeof K==="string")try{return JSON.parse(K)}catch{return null}return K};return{id:Y.id,organization_id:Y.organization_id,created_by:Y.created_by,updated_by:Y.updated_by??void 0,title:Y.title,description:Y.description,icon:Y.icon,app_name:Y.app_name,app_id:Y.app_id,connection_type:Y.connection_type,connection_url:Y.connection_url,connection_token:X,connection_headers:J,oauth_config:G(Y.oauth_config),configuration_state:Q,configuration_scopes:G(Y.configuration_scopes),metadata:G(Y.metadata),tools:G(Y.tools),bindings:G(Y.bindings),status:Y.status,created_at:Y.created_at,updated_at:Y.updated_at}}}$5();class ZT{db;constructor(Y){this.db=Y}parseRow(Y){return{id:Y.id,organizationId:Y.organization_id,slug:Y.slug,name:Y.name,description:Y.description,enabledPlugins:Y.enabled_plugins?typeof Y.enabled_plugins==="string"?JSON.parse(Y.enabled_plugins):Y.enabled_plugins:null,ui:Y.ui?typeof Y.ui==="string"?JSON.parse(Y.ui):Y.ui:null,createdAt:Y.created_at,updatedAt:Y.updated_at}}async list(Y){return(await this.db.selectFrom("projects").selectAll().where("organization_id","=",Y).orderBy("created_at","asc").execute()).map((Q)=>this.parseRow(Q))}async get(Y){let X=await this.db.selectFrom("projects").selectAll().where("id","=",Y).executeTakeFirst();return X?this.parseRow(X):null}async getBySlug(Y,X){let Q=await this.db.selectFrom("projects").selectAll().where("organization_id","=",Y).where("slug","=",X).executeTakeFirst();return Q?this.parseRow(Q):null}async create(Y){let X=new Date().toISOString(),Q=k4("proj");await this.db.insertInto("projects").values({id:Q,organization_id:Y.organizationId,slug:Y.slug,name:Y.name,description:Y.description??null,enabled_plugins:Y.enabledPlugins?JSON.stringify(Y.enabledPlugins):null,ui:Y.ui?JSON.stringify(Y.ui):null,created_at:X,updated_at:X}).execute();let J=await this.get(Q);if(!J)throw Error("Failed to create project");return J}async update(Y,X){let Q={updated_at:new Date().toISOString()};if(X.name!==void 0)Q.name=X.name;if(X.description!==void 0)Q.description=X.description;if(X.enabledPlugins!==void 0)Q.enabled_plugins=X.enabledPlugins?JSON.stringify(X.enabledPlugins):null;if(X.ui!==void 0)Q.ui=X.ui?JSON.stringify(X.ui):null;return await this.db.updateTable("projects").set(Q).where("id","=",Y).execute(),this.get(Y)}async delete(Y){return((await this.db.deleteFrom("projects").where("id","=",Y).executeTakeFirst()).numDeletedRows??0n)>0n}}gb();h0();function d64(Y){return[{permissions:{self:["*"]},getTools:async()=>{let{ALL_TOOLS:X}=await Promise.resolve().then(() => (O50(),oz1));return X.map((Q)=>{return{name:Q.name,inputSchema:B.toJSONSchema(Q.inputSchema,{unrepresentable:"any"}),outputSchema:Q.outputSchema?B.toJSONSchema(Q.outputSchema,{unrepresentable:"any"}):void 0,description:Q.description}})},data:I00(JJ(),Y)},{data:C00()},{data:E00(Y)}]}async function sz1(Y,X){try{let Q=vb(),J=new zV(process.env.ENCRYPTION_KEY||""),G=new WT(Q.db,J),K=new ZT(Q.db),W=d64(Y);try{await K.create({organizationId:Y,slug:TW,name:GR,description:"Organization administration and settings",enabledPlugins:null,ui:null})}catch(Z){console.warn("Could not create org-admin project (may already exist):",Z)}await Promise.all(W.map(async(Z)=>{let H=null;if(Z.permissions)H=(await bZ.api.createApiKey({body:{name:`${Z.data.app_name??crypto.randomUUID()}-mcp`,userId:X,permissions:Z.permissions,rateLimitEnabled:!1,metadata:{organization:{id:Y},purpose:"default-org-connections"}}}))?.key;let F=await Z.getTools?.()??await OD({id:"pending",title:Z.data.title,connection_type:Z.data.connection_type,connection_url:Z.data.connection_url,connection_token:Z.data.connection_token,connection_headers:Z.data.connection_headers}).catch(()=>null),$=Z.data.id?Z.data.id.startsWith(`${Y}_`)?Z.data.id:`${Y}_${Z.data.id}`:void 0;await G.create({...Z.data,id:$,tools:F,organization_id:Y,created_by:X,connection_token:Z.data.connection_token??H})}))}catch(Q){console.error("Error creating default MCP connections:",Q)}}var N50=["owner","admin","user"],zx=["owner","admin"];var p64=(Y)=>{return{defaultSSO:[{domain:Y.domain,providerId:Y.providerId,oidcConfig:{issuer:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/v2.0`,pkce:!0,clientId:Y.MS_CLIENT_ID,clientSecret:Y.MS_CLIENT_SECRET,discoveryEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/v2.0/.well-known/openid-configuration`,authorizationEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/oauth2/v2.0/authorize`,tokenEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/oauth2/v2.0/token`,jwksEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/discovery/v2.0/keys`,userInfoEndpoint:"https://graph.microsoft.com/oidc/userinfo",tokenEndpointAuthentication:"client_secret_post",scopes:Y.scopes,mapping:{id:"sub",email:"email",emailVerified:"email_verified",name:"name",image:"picture",extraFields:{emailVerified:"email_verified"}}}}]}},tz1=(Y)=>{if(Y.providerId==="microsoft")return p64(Y);throw Error(`Unsupported provider: ${Y.providerId}`)};function c64(Y){return Y.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var ez1=["labs","agent","studio","workspace","systems","core","cloud","works"],YU1=["capybara","guarana","deco","samba","feijoada","capoeira","carnival"];function n64(){let Y=Math.floor(Math.random()*YU1.length),X=Math.floor(Math.random()*ez1.length),Q=YU1[Y]??"deco",J=ez1[X]??"studio";return`${Q}-${J}`}var i64=Object.values(bM()).map((Y)=>Y.map((X)=>X.name)).flat(),a64={...Gb,self:["*",...i64]},Ux=c7(a64),r64=Ux.newRole({self:["*"],...gP.statements}),o64=Ux.newRole({self:["*"],...gP.statements}),s64=Ux.newRole({self:["*"],...gP.statements}),XU1=Object.values(bM()).map((Y)=>Y.map((X)=>`self:${X.name}`)).flat(),V9=aP.auth,QU1=void 0;if(V9.inviteEmailProviderId&&V9.emailProviders&&V9.emailProviders.length>0){let Y=yb(V9.emailProviders,V9.inviteEmailProviderId);if(Y){let X=_b(Y);QU1=async(Q)=>{let J=Q.inviter.user?.name||Q.inviter.user?.email,G=`${JJ()}/auth/accept-invitation?invitationId=${Q.invitation.id}`;await X({to:Q.email,subject:`Invitation to join ${Q.organization.name}`,html:`
1047
+ </html>`},qX0=(Y)=>{let X=Y?.path??"/reference";return{id:"open-api",endpoints:{generateOpenAPISchema:g0("/open-api/generate-schema",{method:"GET"},async(Q)=>{let J=await pK1(Q.context,Q.context.options);return Q.json(J)}),openAPIReference:g0(X,{method:"GET",metadata:{isAction:!1}},async(Q)=>{if(Y?.disableDefaultReference)throw new i("NOT_FOUND");let J=await pK1(Q.context,Q.context.options);return new Response(pi6(J,Y?.theme,Y?.nonce),{headers:{"Content-Type":"text/html"}})})}}};hX();y7();K9();XY();h0();var A98=Z4(async()=>{return{}}),P98=Z4({use:[q8]},async(Y)=>{return{session:Y.context.session}}),T98=y4({YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_ORGANIZATION:"You are not allowed to create a new organization",YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS:"You have reached the maximum number of organizations",ORGANIZATION_ALREADY_EXISTS:"Organization already exists",ORGANIZATION_SLUG_ALREADY_TAKEN:"Organization slug already taken",ORGANIZATION_NOT_FOUND:"Organization not found",USER_IS_NOT_A_MEMBER_OF_THE_ORGANIZATION:"User is not a member of the organization",YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_ORGANIZATION:"You are not allowed to update this organization",YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_ORGANIZATION:"You are not allowed to delete this organization",NO_ACTIVE_ORGANIZATION:"No active organization",USER_IS_ALREADY_A_MEMBER_OF_THIS_ORGANIZATION:"User is already a member of this organization",MEMBER_NOT_FOUND:"Member not found",ROLE_NOT_FOUND:"Role not found",YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM:"You are not allowed to create a new team",TEAM_ALREADY_EXISTS:"Team already exists",TEAM_NOT_FOUND:"Team not found",YOU_CANNOT_LEAVE_THE_ORGANIZATION_AS_THE_ONLY_OWNER:"You cannot leave the organization as the only owner",YOU_CANNOT_LEAVE_THE_ORGANIZATION_WITHOUT_AN_OWNER:"You cannot leave the organization without an owner",YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_MEMBER:"You are not allowed to delete this member",YOU_ARE_NOT_ALLOWED_TO_INVITE_USERS_TO_THIS_ORGANIZATION:"You are not allowed to invite users to this organization",USER_IS_ALREADY_INVITED_TO_THIS_ORGANIZATION:"User is already invited to this organization",INVITATION_NOT_FOUND:"Invitation not found",YOU_ARE_NOT_THE_RECIPIENT_OF_THE_INVITATION:"You are not the recipient of the invitation",EMAIL_VERIFICATION_REQUIRED_BEFORE_ACCEPTING_OR_REJECTING_INVITATION:"Email verification required before accepting or rejecting invitation",YOU_ARE_NOT_ALLOWED_TO_CANCEL_THIS_INVITATION:"You are not allowed to cancel this invitation",INVITER_IS_NO_LONGER_A_MEMBER_OF_THE_ORGANIZATION:"Inviter is no longer a member of the organization",YOU_ARE_NOT_ALLOWED_TO_INVITE_USER_WITH_THIS_ROLE:"You are not allowed to invite a user with this role",FAILED_TO_RETRIEVE_INVITATION:"Failed to retrieve invitation",YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_TEAMS:"You have reached the maximum number of teams",UNABLE_TO_REMOVE_LAST_TEAM:"Unable to remove last team",YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_MEMBER:"You are not allowed to update this member",ORGANIZATION_MEMBERSHIP_LIMIT_REACHED:"Organization membership limit reached",YOU_ARE_NOT_ALLOWED_TO_CREATE_TEAMS_IN_THIS_ORGANIZATION:"You are not allowed to create teams in this organization",YOU_ARE_NOT_ALLOWED_TO_DELETE_TEAMS_IN_THIS_ORGANIZATION:"You are not allowed to delete teams in this organization",YOU_ARE_NOT_ALLOWED_TO_UPDATE_THIS_TEAM:"You are not allowed to update this team",YOU_ARE_NOT_ALLOWED_TO_DELETE_THIS_TEAM:"You are not allowed to delete this team",INVITATION_LIMIT_REACHED:"Invitation limit reached",TEAM_MEMBER_LIMIT_REACHED:"Team member limit reached",USER_IS_NOT_A_MEMBER_OF_THE_TEAM:"User is not a member of the team",YOU_CAN_NOT_ACCESS_THE_MEMBERS_OF_THIS_TEAM:"You are not allowed to list the members of this team",YOU_DO_NOT_HAVE_AN_ACTIVE_TEAM:"You do not have an active team",YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_TEAM_MEMBER:"You are not allowed to create a new member",YOU_ARE_NOT_ALLOWED_TO_REMOVE_A_TEAM_MEMBER:"You are not allowed to remove a team member",YOU_ARE_NOT_ALLOWED_TO_ACCESS_THIS_ORGANIZATION:"You are not allowed to access this organization as an owner",YOU_ARE_NOT_A_MEMBER_OF_THIS_ORGANIZATION:"You are not a member of this organization",MISSING_AC_INSTANCE:"Dynamic Access Control requires a pre-defined ac instance on the server auth plugin. Read server logs for more information",YOU_MUST_BE_IN_AN_ORGANIZATION_TO_CREATE_A_ROLE:"You must be in an organization to create a role",YOU_ARE_NOT_ALLOWED_TO_CREATE_A_ROLE:"You are not allowed to create a role",YOU_ARE_NOT_ALLOWED_TO_UPDATE_A_ROLE:"You are not allowed to update a role",YOU_ARE_NOT_ALLOWED_TO_DELETE_A_ROLE:"You are not allowed to delete a role",YOU_ARE_NOT_ALLOWED_TO_READ_A_ROLE:"You are not allowed to read a role",YOU_ARE_NOT_ALLOWED_TO_LIST_A_ROLE:"You are not allowed to list a role",YOU_ARE_NOT_ALLOWED_TO_GET_A_ROLE:"You are not allowed to get a role",TOO_MANY_ROLES:"This organization has too many roles",INVALID_RESOURCE:"The provided permission includes an invalid resource",ROLE_NAME_IS_ALREADY_TAKEN:"That role name is already taken",CANNOT_DELETE_A_PRE_DEFINED_ROLE:"Cannot delete a pre-defined role"});var E98=Number.POSITIVE_INFINITY;var nK1=M(),ni6=z1(["pending","accepted","rejected","canceled"]).default("pending"),C98=p({id:M().default(M9),name:M(),slug:M(),logo:M().nullish().optional(),metadata:Y1(M(),V4()).or(M().transform((Y)=>JSON.parse(Y))).optional(),createdAt:X6()}),I98=p({id:M().default(M9),organizationId:M(),userId:h1.string(),role:nK1,createdAt:X6().default(()=>new Date)}),R98=p({id:M().default(M9),organizationId:M(),email:M(),role:nK1,status:ni6,teamId:M().nullish(),inviterId:M(),expiresAt:X6(),createdAt:X6().default(()=>new Date)}),S98=p({id:M().default(M9),name:M().min(1),organizationId:M(),createdAt:X6(),updatedAt:X6().optional()}),j98=p({id:M().default(M9),teamId:M(),userId:M(),createdAt:X6().default(()=>new Date)}),k98=p({id:M().default(M9),organizationId:M(),role:M(),permission:Y1(M(),P0(M())),createdAt:X6().default(()=>new Date),updatedAt:X6().optional()}),cK1=["admin","member","owner"],v98=Q6([z1(cK1),P0(z1(cK1))]);E8();K9();XY();var l98=y4({INVALID_PHONE_NUMBER:"Invalid phone number",PHONE_NUMBER_EXIST:"Phone number already exists",PHONE_NUMBER_NOT_EXIST:"phone number isn't registered",INVALID_PHONE_NUMBER_OR_PASSWORD:"Invalid phone number or password",UNEXPECTED_ERROR:"Unexpected error",OTP_NOT_FOUND:"OTP not found",OTP_EXPIRED:"OTP expired",INVALID_OTP:"Invalid OTP",PHONE_NUMBER_NOT_VERIFIED:"Phone number not verified",PHONE_NUMBER_CANNOT_BE_UPDATED:"Phone number cannot be updated",SEND_OTP_NOT_IMPLEMENTED:"sendOTP not implemented",TOO_MANY_ATTEMPTS:"Too many attempts"});E8();bX();K9();XY();s9();G8();var ii6=y4({OTP_NOT_ENABLED:"OTP not enabled",OTP_HAS_EXPIRED:"OTP has expired",TOTP_NOT_ENABLED:"TOTP not enabled",TWO_FACTOR_NOT_ENABLED:"Two factor isn't enabled",BACKUP_CODES_NOT_ENABLED:"Backup codes aren't enabled",INVALID_BACKUP_CODE:"Invalid backup code",INVALID_CODE:"Invalid code",TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE:"Too many attempts. Please request a new code.",INVALID_TWO_FACTOR_COOKIE:"Invalid two factor cookie"});K9();XY();var ai6=y4({INVALID_USERNAME_OR_PASSWORD:"Invalid username or password",EMAIL_NOT_VERIFIED:"Email not verified",UNEXPECTED_ERROR:"Unexpected error",USERNAME_IS_ALREADY_TAKEN:"Username is already taken. Please try another.",USERNAME_TOO_SHORT:"Username is too short",USERNAME_TOO_LONG:"Username is too long",INVALID_USERNAME:"Username is invalid",INVALID_DISPLAY_USERNAME:"Display username is invalid"});var VV={enabled:!0,batchSize:250,flushIntervalMs:300,maxQueueSize:1e4,redactor:"regex"};import{existsSync as iK1,readFileSync as aK1}from"fs";var Nb={emailAndPassword:{enabled:!0}},rK1=process.env.CONFIG_PATH||"./config.json",oK1=process.env.AUTH_CONFIG_PATH||"./auth-config.json";function ri6(){if(iK1(rK1))try{let Y=aK1(rK1,"utf-8"),X=JSON.parse(Y);return{auth:Nb,monitoring:VV,...X}}catch{return{auth:Nb,monitoring:VV}}if(iK1(oK1))try{let Y=aK1(oK1,"utf-8");return{auth:JSON.parse(Y),monitoring:VV}}catch{return{auth:Nb,monitoring:VV}}return{auth:Nb,monitoring:VV}}var aP=ri6();function sK1(){return{...VV,...aP.monitoring}}function tK1(){return aP.theme}import{existsSync as Qt6,mkdirSync as Jt6}from"fs";import{Kysely as TF1,PostgresDialect as EF1,sql as rX0}from"kysely";import{BunWorkerDialect as CF1}from"kysely-bun-worker";import*as IF1 from"path";var F5=l6(cX0(),1),gQ8=F5.default.Client,aX0=F5.default.Pool,mQ8=F5.default.Connection,lQ8=F5.default.types,dQ8=F5.default.Query,pQ8=F5.default.DatabaseError,cQ8=F5.default.escapeIdentifier,nQ8=F5.default.escapeLiteral,iQ8=F5.default.Result,aQ8=F5.default.TypeOverrides,rQ8=F5.default.defaults;var Gt6=XR.createHistogram("db.query.duration",{description:"Database query execution duration in milliseconds",unit:"ms"}),Wt6=["PRAGMA busy_timeout = ?;"],Zt6=400,RF1=(Y)=>{let X={"db.statement":Y.query.sql,"db.status":Y.level==="error"?"error":"success"};if(Y.queryDurationMillis>Zt6)console.error("Slow query detected:",{durationMs:Y.queryDurationMillis,sql:Y.query.sql,params:Y.query.parameters});if(Gt6.record(Y.queryDurationMillis,X),Y.level==="error"&&!Wt6.includes(Y.query.sql))console.error("Query failed:",{durationMs:Y.queryDurationMillis,error:Y.error,sql:Y.query.sql})},SF1={keepAlive:!0,keepAliveInitialDelayMillis:1e4,idleTimeoutMillis:300000,connectionTimeoutMillis:30000,allowExitOnIdle:!0};function Kt6(Y){let X=new aX0({connectionString:Y.connectionString,max:Y.options?.maxConnections||10,ssl:process.env.DATABASE_PG_SSL==="true"?!0:!1,...SF1}),Q=new EF1({pool:X});return{type:"postgres",db:new TF1({dialect:Q,log:RF1}),pool:X}}function jF1(Y){if(Y===":memory:")return":memory:";if(Y.includes("://"))return new URL(Y).pathname;return Y}function kF1(Y){if(Y!==":memory:"&&Y!=="/"&&Y){let X=Y.substring(0,Y.lastIndexOf("/"));if(X&&X!=="/"&&!Qt6(X))try{Jt6(X,{recursive:!0})}catch{return console.warn(`Failed to create directory ${X}, using in-memory database`),":memory:"}}return Y}function Ht6(Y){let X=jF1(Y.connectionString);X=kF1(X);let Q=new CF1({url:X||":memory:"}),J=new TF1({dialect:Q,log:RF1});if(!0)rX0`PRAGMA foreign_keys = ON;`.execute(J).catch(()=>{});if(X!==":memory:"&&Y.options?.enableWAL!==!1)rX0`PRAGMA journal_mode = WAL;`.execute(J).catch(()=>{});if(X!==":memory:"){let K=Y.options?.busyTimeout||5000;rX0`PRAGMA busy_timeout = ${K};`.execute(J).catch(()=>{})}return{type:"sqlite",db:J}}function vF1(Y){let X=Y||"file:./data/mesh.db";if(X===":memory:")return{type:"sqlite",connectionString:":memory:"};X=X.startsWith("/")?`file://${X}`:X;let Q=URL.canParse(X)?new URL(X):null,J=Q?.protocol.replace(":","")??X.split("://")[0];switch(J){case"postgres":case"postgresql":return{type:"postgres",connectionString:X};case"sqlite":case"file":if(!Q?.pathname)throw Error("Invalid database URL: "+X);return{type:"sqlite",connectionString:Q.pathname};default:throw Error(`Unsupported database protocol: ${J}. Supported protocols: postgres://, postgresql://, sqlite://, file://`)}}function sX0(){return process.env.DATABASE_URL||`file:${IF1.join(process.cwd(),"data/mesh.db")}`}function _F1(Y){let X=vF1(Y);if(X.type==="postgres")return new EF1({pool:new aX0({connectionString:X.connectionString,max:X.options?.maxConnections||10,ssl:process.env.DATABASE_PG_SSL==="true"?!0:!1,...SF1})});let Q=jF1(X.connectionString);return Q=kF1(Q),new CF1({url:Q||":memory:"})}function Ft6(Y){let X=vF1(Y);if(X.type==="postgres")return Kt6(X);return Ht6(X)}var oX0=null;function vb(){if(!oX0)oX0=Ft6(sX0());return oX0}class tX0{apiKey;constructor(Y){this.apiKey=Y}async sendEmail({to:Y,from:X,subject:Q,html:J}){let G=await fetch("https://api.resend.com/emails",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({to:Y,from:X,subject:Q,html:J})});if(!G.ok)throw Error(`Failed to send email: ${G.statusText}`)}}class eX0{apiKey;constructor(Y){this.apiKey=Y}async sendEmail({to:Y,from:X,subject:Q,html:J}){let G=await fetch("https://api.sendgrid.com/v3/mail/send",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({personalizations:[{to:[{email:Y}]}],from:{email:X},subject:Q,content:[{type:"text/html",value:J}]})});if(!G.ok){let K=await G.text();throw Error(`Failed to send email via SendGrid: ${G.statusText} - ${K}`)}}}var $t6=(Y)=>{let X=new tX0(Y.config.apiKey);return async({to:Q,subject:J,html:G})=>{await X.sendEmail({to:Q,from:Y.config.fromEmail,subject:J,html:G})}},Vt6=(Y)=>{let X=new eX0(Y.config.apiKey);return async({to:Q,subject:J,html:G})=>{await X.sendEmail({to:Q,from:Y.config.fromEmail,subject:J,html:G})}},qt6={resend:$t6,sendgrid:Vt6};function _b(Y){let X=qt6[Y.provider];if(!X)throw Error(`Unknown email provider: ${Y.provider}`);return X(Y)}function yb(Y,X){return Y.find((Q)=>Q.id===X)}var yF1=(Y,X)=>{let Q=yb(X,Y.emailProviderId);if(!Q)throw Error(`Email provider with id '${Y.emailProviderId}' not found`);let J=_b(Q);return{sendMagicLink:async({email:G,url:K})=>{await J({to:G,subject:"Magic Link",html:`<p>Click <a href="${K}">here</a> to login</p>`})}}};wX();import{createCipheriv as Bt6,createDecipheriv as zt6,randomBytes as fF1}from"crypto";var hF1="aes-256-gcm",GT=16,bF1=16,xF1=32;class zV{key;constructor(Y){if(Buffer.from(Y,"base64").length===xF1)this.key=Buffer.from(Y,"base64");else{let X=F0("crypto");this.key=X.createHash("sha256").update(Y).digest()}}async encrypt(Y){let X=fF1(GT),Q=Bt6(hF1,this.key,X),J=Q.update(Y,"utf8");J=Buffer.concat([J,Q.final()]);let G=Q.getAuthTag();return Buffer.concat([X,G,J]).toString("base64")}async decrypt(Y){let X=Buffer.from(Y,"base64"),Q=X.subarray(0,GT),J=X.subarray(GT,GT+bF1),G=X.subarray(GT+bF1),K=zt6(hF1,this.key,Q);K.setAuthTag(J);let W=K.update(G);return W=Buffer.concat([W,K.final()]),W.toString("utf8")}static generateKey(){return fF1(xF1).toString("base64")}}CZ();$5();wX();var Ot6=["connection_headers","oauth_config","configuration_scopes","metadata","tools","bindings"];class WT{db;vault;constructor(Y,X){this.db=Y;this.vault=X}async create(Y){let X=Y.id??k4("conn"),Q=new Date().toISOString(),J=await this.findById(X);if(J){if(J.organization_id!==Y.organization_id)throw Error("Connection ID already exists");return this.update(X,Y)}let G=await this.serializeConnection({...Y,id:Y.id??X,status:"active",created_at:Q,updated_at:Q});await this.db.insertInto("connections").values(G).execute();let K=await this.findById(X);if(!K)throw Error(`Failed to create connection with id: ${X}`);return K}async findById(Y,X){let Q=mW(Y);if(Q)return S00(X??Q);let J=this.db.selectFrom("connections").selectAll().where("id","=",Y);if(X)J=J.where("organization_id","=",X);let G=await J.executeTakeFirst();return G?this.deserializeConnection(G):null}async list(Y,X){let Q=this.db.selectFrom("connections").selectAll().where("organization_id","=",Y);if(!X?.includeVirtual)Q=Q.where("connection_type","!=","VIRTUAL");let J=await Q.execute();return Promise.all(J.map((G)=>this.deserializeConnection(G)))}async update(Y,X){if(Object.keys(X).length===0){let G=await this.findById(Y);if(!G)throw Error("Connection not found");return G}let Q=await this.serializeConnection({...X,updated_at:new Date().toISOString()});await this.db.updateTable("connections").set(Q).where("id","=",Y).execute();let J=await this.findById(Y);if(!J)throw Error("Connection not found after update");return J}async delete(Y){await this.db.deleteFrom("connections").where("id","=",Y).execute()}async testConnection(Y,X){let Q=await this.findById(Y);if(!Q)throw Error("Connection not found");let J=Date.now();if(Q.connection_type==="STDIO")return{healthy:!0,latencyMs:Date.now()-J};if(!Q.connection_url)return{healthy:!1,latencyMs:Date.now()-J};try{let G=Q.connection_headers,K=await fetch(Q.connection_url,{method:"POST",headers:{"Content-Type":"application/json",...Q.connection_token&&{Authorization:`Bearer ${Q.connection_token}`},...G?.headers,...X},body:JSON.stringify({jsonrpc:"2.0",method:"ping",id:1})});return{healthy:K.ok||K.status===404,latencyMs:Date.now()-J}}catch{return{healthy:!1,latencyMs:Date.now()-J}}}async serializeConnection(Y){let X={};for(let[Q,J]of Object.entries(Y)){if(J===void 0)continue;if(Q==="connection_token"&&J)X[Q]=await this.vault.encrypt(J);else if(Q==="configuration_state"&&J){let G=JSON.stringify(J);X[Q]=await this.vault.encrypt(G)}else if(Q==="connection_headers"&&J){let G=J;if(H7(G)&&G.envVars){let K={};for(let[W,Z]of Object.entries(G.envVars))K[W]=await this.vault.encrypt(Z);X[Q]=JSON.stringify({...G,envVars:K})}else X[Q]=JSON.stringify(G)}else if(Ot6.includes(Q))X[Q]=J?JSON.stringify(J):null;else X[Q]=J}return X}async deserializeConnection(Y){let X=null;if(Y.connection_token)try{X=await this.vault.decrypt(Y.connection_token)}catch(K){console.error("Failed to decrypt connection token:",K)}let Q=null;if(Y.configuration_state)try{let K=await this.vault.decrypt(Y.configuration_state);Q=JSON.parse(K)}catch(K){console.error("Failed to decrypt configuration state:",K)}let J=null;if(Y.connection_headers)try{let K=JSON.parse(Y.connection_headers);if(H7(K)&&K.envVars){let W={};for(let[Z,H]of Object.entries(K.envVars))try{W[Z]=await this.vault.decrypt(H)}catch{W[Z]=H}J={...K,envVars:W}}else J=K}catch(K){console.error("Failed to parse connection_headers:",K)}let G=(K)=>{if(K===null)return null;if(typeof K==="string")try{return JSON.parse(K)}catch{return null}return K};return{id:Y.id,organization_id:Y.organization_id,created_by:Y.created_by,updated_by:Y.updated_by??void 0,title:Y.title,description:Y.description,icon:Y.icon,app_name:Y.app_name,app_id:Y.app_id,connection_type:Y.connection_type,connection_url:Y.connection_url,connection_token:X,connection_headers:J,oauth_config:G(Y.oauth_config),configuration_state:Q,configuration_scopes:G(Y.configuration_scopes),metadata:G(Y.metadata),tools:G(Y.tools),bindings:G(Y.bindings),status:Y.status,created_at:Y.created_at,updated_at:Y.updated_at}}}$5();class ZT{db;constructor(Y){this.db=Y}parseRow(Y){return{id:Y.id,organizationId:Y.organization_id,slug:Y.slug,name:Y.name,description:Y.description,enabledPlugins:Y.enabled_plugins?typeof Y.enabled_plugins==="string"?JSON.parse(Y.enabled_plugins):Y.enabled_plugins:null,ui:Y.ui?typeof Y.ui==="string"?JSON.parse(Y.ui):Y.ui:null,createdAt:Y.created_at,updatedAt:Y.updated_at}}async list(Y){return(await this.db.selectFrom("projects").selectAll().where("organization_id","=",Y).orderBy("created_at","asc").execute()).map((Q)=>this.parseRow(Q))}async get(Y){let X=await this.db.selectFrom("projects").selectAll().where("id","=",Y).executeTakeFirst();return X?this.parseRow(X):null}async getBySlug(Y,X){let Q=await this.db.selectFrom("projects").selectAll().where("organization_id","=",Y).where("slug","=",X).executeTakeFirst();return Q?this.parseRow(Q):null}async create(Y){let X=new Date().toISOString(),Q=k4("proj");await this.db.insertInto("projects").values({id:Q,organization_id:Y.organizationId,slug:Y.slug,name:Y.name,description:Y.description??null,enabled_plugins:Y.enabledPlugins?JSON.stringify(Y.enabledPlugins):null,ui:Y.ui?JSON.stringify(Y.ui):null,created_at:X,updated_at:X}).execute();let J=await this.get(Q);if(!J)throw Error("Failed to create project");return J}async update(Y,X){let Q={updated_at:new Date().toISOString()};if(X.name!==void 0)Q.name=X.name;if(X.description!==void 0)Q.description=X.description;if(X.enabledPlugins!==void 0)Q.enabled_plugins=X.enabledPlugins?JSON.stringify(X.enabledPlugins):null;if(X.ui!==void 0)Q.ui=X.ui?JSON.stringify(X.ui):null;return await this.db.updateTable("projects").set(Q).where("id","=",Y).execute(),this.get(Y)}async delete(Y){return((await this.db.deleteFrom("projects").where("id","=",Y).executeTakeFirst()).numDeletedRows??0n)>0n}}gb();h0();function d64(Y){return[{permissions:{self:["*"]},getTools:async()=>{let{ALL_TOOLS:X}=await Promise.resolve().then(() => (O50(),oz1));return X.map((Q)=>{return{name:Q.name,inputSchema:B.toJSONSchema(Q.inputSchema,{unrepresentable:"any"}),outputSchema:Q.outputSchema?B.toJSONSchema(Q.outputSchema,{unrepresentable:"any"}):void 0,description:Q.description}})},data:I00(JJ(),Y)},{data:C00()},{data:E00(Y)}]}async function sz1(Y,X){try{let Q=vb(),J=new zV(process.env.ENCRYPTION_KEY||""),G=new WT(Q.db,J),K=new ZT(Q.db),W=d64(Y);try{await K.create({organizationId:Y,slug:TW,name:GR,description:"Organization administration and settings",enabledPlugins:null,ui:null})}catch(Z){console.warn("Could not create org-admin project (may already exist):",Z)}await Promise.all(W.map(async(Z)=>{let H=null;if(Z.permissions)H=(await bZ.api.createApiKey({body:{name:`${Z.data.app_name??crypto.randomUUID()}-mcp`,userId:X,permissions:Z.permissions,rateLimitEnabled:!1,metadata:{organization:{id:Y},purpose:"default-org-connections"}}}))?.key;let F=await Z.getTools?.()??await OD({id:"pending",title:Z.data.title,connection_type:Z.data.connection_type,connection_url:Z.data.connection_url,connection_token:Z.data.connection_token,connection_headers:Z.data.connection_headers}).catch(()=>null),$=Z.data.id?Z.data.id.startsWith(`${Y}_`)?Z.data.id:`${Y}_${Z.data.id}`:void 0;await G.create({...Z.data,id:$,tools:F,organization_id:Y,created_by:X,connection_token:Z.data.connection_token??H})}))}catch(Q){console.error("Error creating default MCP connections:",Q)}}var N50=["owner","admin","user"],zx=["owner","admin"];var p64=(Y)=>{return{defaultSSO:[{domain:Y.domain,providerId:Y.providerId,oidcConfig:{issuer:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/v2.0`,pkce:!0,clientId:Y.MS_CLIENT_ID,clientSecret:Y.MS_CLIENT_SECRET,discoveryEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/v2.0/.well-known/openid-configuration`,authorizationEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/oauth2/v2.0/authorize`,tokenEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/oauth2/v2.0/token`,jwksEndpoint:`https://login.microsoftonline.com/${Y.MS_TENANT_ID}/discovery/v2.0/keys`,userInfoEndpoint:"https://graph.microsoft.com/oidc/userinfo",tokenEndpointAuthentication:"client_secret_post",scopes:Y.scopes,mapping:{id:"sub",email:"email",emailVerified:"email_verified",name:"name",image:"picture",extraFields:{emailVerified:"email_verified"}}}}]}},tz1=(Y)=>{if(Y.providerId==="microsoft")return p64(Y);throw Error(`Unsupported provider: ${Y.providerId}`)};function c64(Y){return Y.toLowerCase().trim().replace(/[^a-z0-9\s_-]+/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var ez1=["labs","agent","studio","workspace","systems","core","cloud","works"],YU1=["capybara","guarana","deco","samba","feijoada","capoeira","carnival"];function n64(){let Y=Math.floor(Math.random()*YU1.length),X=Math.floor(Math.random()*ez1.length),Q=YU1[Y]??"deco",J=ez1[X]??"studio";return`${Q}-${J}`}var i64=Object.values(bM()).map((Y)=>Y.map((X)=>X.name)).flat(),a64={...Gb,self:["*",...i64]},Ux=c7(a64),r64=Ux.newRole({self:["*"],...gP.statements}),o64=Ux.newRole({self:["*"],...gP.statements}),s64=Ux.newRole({self:["*"],...gP.statements}),XU1=Object.values(bM()).map((Y)=>Y.map((X)=>`self:${X.name}`)).flat(),V9=aP.auth,QU1=void 0;if(V9.inviteEmailProviderId&&V9.emailProviders&&V9.emailProviders.length>0){let Y=yb(V9.emailProviders,V9.inviteEmailProviderId);if(Y){let X=_b(Y);QU1=async(Q)=>{let J=Q.inviter.user?.name||Q.inviter.user?.email,G=`${JJ()}/auth/accept-invitation?invitationId=${Q.invitation.id}&redirectTo=/`;await X({to:Q.email,subject:`Invitation to join ${Q.organization.name}`,html:`
1048
1048
  <h2>You've been invited!</h2>
1049
1049
  <p>${J} has invited you to join <strong>${Q.organization.name}</strong>.</p>
1050
1050
  <p><a href="${G}">Click here to accept the invitation</a></p>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/mesh",
3
- "version": "2.79.1",
3
+ "version": "2.80.1",
4
4
  "description": "MCP Mesh - Self-hostable MCP Gateway for managing AI connections and tools",
5
5
  "author": "Deco team",
6
6
  "license": "MIT",
@@ -1 +0,0 @@
1
- import{c as r,a as m,j as n,A as o}from"./index-D3nlG5Bn.js";function i(){const e=r.c(3);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={from:"/auth/$pathname"},e[0]=t):t=e[0];const{pathname:s}=m(t);let a;return e[1]!==s?(a=n.jsx("main",{className:"container mx-auto flex grow flex-col items-center justify-center gap-3 self-center p-4 md:p-6",children:n.jsx(o,{pathname:s})}),e[1]=s,e[2]=a):a=e[2],a}export{i as default};
@@ -1 +0,0 @@
1
- import{M as t,Q as a}from"./index-D3nlG5Bn.js";const e=t(a,{target:"draft-7"});export{e as B};
@@ -1,12 +0,0 @@
1
- import{r as N,c as w,j as n,u as ae,m as ke,br as Re,L as ye,bn as qt,bA as Jt,O as ne,a4 as Xt,q as Qt,x as es,g as re,t as oe,aZ as ts,bB as ot,a as Ye,bC as ss,b1 as it,bD as _e,b as ns,S as lt,d as rs,e as os,N as is,y as ls,K as as,l as at,P as cs}from"./index-D3nlG5Bn.js";import{C as te,i as ds,u as ms}from"./index-DNnTxMe0.js";import{I as fs,n as us,a as Me,c as ct,T as Ee,b as Ae}from"./integration-icon-DgoP3aRm.js";import{P as Se}from"./index-DUZGLwaX.js";import{b as He,u as ps,S as de,d as dt}from"./use-deco-chat-open-D-wIsSOI.js";import{c as _}from"./utils-ChMoRSU0.js";import{d as hs}from"./constants-B1K1ZOHV.js";import{T as xs,i as gs,b as bs,S as js,c as vs,d as ws,e as Ns,f as Ss,t as mt}from"./typewriter-title-B5Ki7tQ5.js";import{s as ft}from"./Plus-DVfCRM0e.js";import{t as ut}from"./Users03-DxSocU5u.js";import{i as Le}from"./X-orwHLQvA.js";import{E as pt}from"./error-boundary-BmGvCwcM.js";import{C as ys}from"./create-project-dialog-CF32CwsT.js";import{n as Cs}from"./CheckDone01-JeEywSHq.js";import{a as ks}from"./Home02-mm2kWrdz.js";import{u as _s}from"./use-project-HGqdCewl.js";import{u as $e}from"./use-mobile-Do_29jRD.js";import{t as ht}from"./ChevronDown-CYzQevGE.js";import{B as X}from"./button-jVZoVSEf.js";import{A as le}from"./avatar-CHzxmS3u.js";import{b as qe,P as Je,a as Xe}from"./popover-DZy413j4.js";import{n as Qe}from"./Inbox01-GbeCfKmy.js";import{B as et}from"./badge-DjX7aMc2.js";import{i as De}from"./Check-Cx0Fc2ER.js";import{s as tt}from"./XClose-BvifwoiV.js";import{i as zs}from"./ChevronRight-ZFn5_7l2.js";import{a as xt}from"./Settings02-DmQ47Bo8.js";import{C as gt}from"./create-organization-dialog-uaL-GIH0.js";import{c as $s,b as Is,g as Os,a as Ts,D as Ps}from"./dialog-CD9Wwmjj.js";import{L as Ms}from"./label-DLjBs6VT.js";import{S as Es}from"./switch-CQszwSv3.js";import{i as As}from"./Code01-BHoiimgb.js";import{a as bt}from"./Copy01-DMVE1jMt.js";import{u as jt,a as Ls}from"./use-organization-settings-CuBKNeOw.js";import{i as Ds}from"./File06-BHrPxaod.js";import{I as Rs}from"./input-Cfb0z5LB.js";import{c as Hs}from"./Grid01-DfoEVHbX.js";import{a as Bs,T as Us}from"./topbar-portal-BgZ57TAJ.js";import{a as Ws,b as Fs,D as Vs,c as Gs,g as st}from"./dropdown-menu-1_TCBXfB.js";import{n as nt}from"./LinkExternal01-Ba4Ansgj.js";import{t as Ks}from"./Settings01-n5GEFijK.js";import{u as vt,L as wt}from"./localstorage-keys-Dcw7WgCK.js";import{R as Zs,a as Nt,b as Ys}from"./resizable-Do2pmnrG.js";import"./spinner-DA06y-h7.js";import"./use-mcp-prompts-DC9szL21.js";import"./useQuery-CQyI9lob.js";import"./form-CuPB-18q.js";import"./AlertCircle-CjljO9_K.js";import"./ArrowUp-DlHoNDRH.js";import"./Edit01-xS3_fhS5.js";import"./usage-B8eRkRZY.js";import"./Terminal-COlc6e5_.js";import"./monaco-editor-4bQew_dQ.js";import"./empty-state-BbUfTlym.js";import"./use-connection-Crfe-Ixd.js";import"./useMutation-9v6OVjLU.js";import"./generate-id-Dyweu44Y.js";import"./SearchMd-Btq9JQM1.js";import"./Trash01-pKL0Dwki.js";import"./use-virtual-mcp-VgOM6PoP.js";import"./use-create-virtual-mcp-dLbcBuVS.js";import"./index-CFsUbpkt.js";import"./use-llm-rvFAkGsK.js";import"./use-binding-TgcVoQAA.js";import"./binder-boG-N4DJ.js";import"./select-Dl5SsVsF.js";import"./Image01-BqS-Pbmk.js";import"./RefreshCcw01-DhKbWajd.js";import"./textarea-CQw4c4vg.js";import"./alert-dialog-DWDyfsZl.js";import"./infiniteQueryObserver-C_2kO8fk.js";const Ve=({size:t=24,color:e="currentColor",...s})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},N.createElement("path",{d:"M7 17 17 7m0 0H7m10 0v10"}));Ve.displayName="ArrowUpRight";const St=({size:t=24,color:e="currentColor",...s})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},N.createElement("path",{d:"M9 7H4.6c-.56 0-.84 0-1.054.109a1 1 0 0 0-.437.437C3 7.76 3 8.04 3 8.6v10.8c0 .56 0 .84.109 1.054a1 1 0 0 0 .437.437C3.76 21 4.04 21 4.6 21H9m0 0h6m-6 0V4.6c0-.56 0-.84.109-1.054a1 1 0 0 1 .437-.437C9.76 3 10.04 3 10.6 3h2.8c.56 0 .84 0 1.054.109a1 1 0 0 1 .437.437C15 3.76 15 4.04 15 4.6V21m0-10h4.4c.56 0 .84 0 1.054.109a1 1 0 0 1 .437.437C21 11.76 21 12.04 21 12.6v6.8c0 .56 0 .84-.109 1.054a1 1 0 0 1-.437.437C20.24 21 19.96 21 19.4 21H15"}));St.displayName="BarChart10";const yt=({size:t=24,color:e="currentColor",...s})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},N.createElement("path",{d:"m12 21-.1-.15c-.695-1.042-1.042-1.563-1.5-1.94a4 4 0 0 0-1.378-.737C8.453 18 7.827 18 6.575 18H5.2c-1.12 0-1.68 0-2.108-.218a2 2 0 0 1-.874-.874C2 16.48 2 15.92 2 14.8V6.2c0-1.12 0-1.68.218-2.108a2 2 0 0 1 .874-.874C3.52 3 4.08 3 5.2 3h.4c2.24 0 3.36 0 4.216.436a4 4 0 0 1 1.748 1.748C12 6.04 12 7.16 12 9.4M12 21V9.4M12 21l.1-.15c.695-1.042 1.042-1.563 1.5-1.94a3.999 3.999 0 0 1 1.378-.737C15.547 18 16.173 18 17.425 18H18.8c1.12 0 1.68 0 2.108-.218a2 2 0 0 0 .874-.874C22 16.48 22 15.92 22 14.8V6.2c0-1.12 0-1.68-.218-2.108a2 2 0 0 0-.874-.874C20.48 3 19.92 3 18.8 3h-.4c-2.24 0-3.36 0-4.216.436a4 4 0 0 0-1.748 1.748C12 6.04 12 7.16 12 9.4"}));yt.displayName="BookOpen01";const Ct=({size:t=24,color:e="currentColor",...s})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},N.createElement("path",{d:"M15 21v-5.4c0-.56 0-.84-.109-1.054a1 1 0 0 0-.437-.437C14.24 14 13.96 14 13.4 14h-2.8c-.56 0-.84 0-1.054.109a1 1 0 0 0-.437.437C9 14.76 9 15.04 9 15.6V21M3 7a3 3 0 0 0 6 0 3 3 0 1 0 6 0 3 3 0 1 0 6 0M6.2 21h11.6c1.12 0 1.68 0 2.108-.218a2 2 0 0 0 .874-.874C21 19.48 21 18.92 21 17.8V6.2c0-1.12 0-1.68-.218-2.108a2 2 0 0 0-.874-.874C19.48 3 18.92 3 17.8 3H6.2c-1.12 0-1.68 0-2.108.218a2 2 0 0 0-.874.874C3 4.52 3 5.08 3 6.2v11.6c0 1.12 0 1.68.218 2.108a2 2 0 0 0 .874.874C4.52 21 5.08 21 6.2 21Z"}));Ct.displayName="Building02";const kt=({size:t=24,color:e="currentColor",...s})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},N.createElement("path",{d:"m18 17-5-5 5-5m-7 10-5-5 5-5"}));kt.displayName="ChevronLeftDouble";const _t=({size:t=24,color:e="currentColor",...s})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},N.createElement("path",{d:"m6 17 5-5-5-5m7 10 5-5-5-5"}));_t.displayName="ChevronRightDouble";const Ge=({size:t=24,color:e="currentColor",...s})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},N.createElement("path",{d:"M11 4.5h7.3c1.12 0 1.68 0 2.108.218a2 2 0 0 1 .874.874c.218.428.218.988.218 2.108V9c0 .932 0 1.398-.152 1.765a2 2 0 0 1-1.083 1.083C19.898 12 19.432 12 18.5 12M13 19.5H5.7c-1.12 0-1.68 0-2.108-.218a2 2 0 0 1-.874-.874C2.5 17.98 2.5 17.42 2.5 16.3V15c0-.932 0-1.398.152-1.765a2 2 0 0 1 1.083-1.083C4.102 12 4.568 12 5.5 12m4.8 2.5h3.4c.28 0 .42 0 .527-.055a.5.5 0 0 0 .218-.218c.055-.107.055-.247.055-.527v-3.4c0-.28 0-.42-.055-.527a.5.5 0 0 0-.218-.218C14.12 9.5 13.98 9.5 13.7 9.5h-3.4c-.28 0-.42 0-.527.055a.5.5 0 0 0-.218.218c-.055.107-.055.247-.055.527v3.4c0 .28 0 .42.055.527a.5.5 0 0 0 .218.218c.107.055.247.055.527.055Zm7.5 7.5h3.4c.28 0 .42 0 .527-.055a.5.5 0 0 0 .218-.218C22 21.62 22 21.48 22 21.2v-3.4c0-.28 0-.42-.055-.527a.5.5 0 0 0-.218-.218C21.62 17 21.48 17 21.2 17h-3.4c-.28 0-.42 0-.527.055a.5.5 0 0 0-.218.218C17 17.38 17 17.52 17 17.8v3.4c0 .28 0 .42.055.527a.5.5 0 0 0 .218.218c.107.055.247.055.527.055ZM2.8 7h3.4c.28 0 .42 0 .527-.054a.5.5 0 0 0 .218-.219C7 6.62 7 6.48 7 6.2V2.8c0-.28 0-.42-.054-.527a.5.5 0 0 0-.219-.219C6.62 2 6.48 2 6.2 2H2.8c-.28 0-.42 0-.527.054a.5.5 0 0 0-.219.219C2 2.38 2 2.52 2 2.8v3.4c0 .28 0 .42.054.527a.5.5 0 0 0 .219.218C2.38 7 2.52 7 2.8 7Z"}));Ge.displayName="Dataflow03";const zt=({size:t=24,color:e="currentColor",...s})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},N.createElement("path",{d:"M8 14s1.5 2 4 2 4-2 4-2m-1-5h.01M9 9h.01M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Zm-6.5-3a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Zm-6 0a.5.5 0 1 1-1 0 .5.5 0 0 1 1 0Z"}));zt.displayName="FaceSmile";const $t=({size:t=24,color:e="currentColor",...s})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},N.createElement("path",{d:"M2 12h20M2 12c0 5.523 4.477 10 10 10M2 12C2 6.477 6.477 2 12 2m10 10c0 5.523-4.477 10-10 10m10-10c0-5.523-4.477-10-10-10m0 0a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10m0-20a15.3 15.3 0 0 0-4 10 15.3 15.3 0 0 0 4 10"}));$t.displayName="Globe01";const It=({size:t=24,color:e="currentColor",...s})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},N.createElement("path",{d:"M15 3v18M7.8 3h8.4c1.68 0 2.52 0 3.162.327a3 3 0 0 1 1.311 1.311C21 5.28 21 6.12 21 7.8v8.4c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.72 21 17.88 21 16.2 21H7.8c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3 18.72 3 17.88 3 16.2V7.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C5.28 3 6.12 3 7.8 3Z"}));It.displayName="LayoutRight";const Ot=({size:t=24,color:e="currentColor",...s})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},N.createElement("path",{d:"m16 17 5-5m0 0-5-5m5 5H9m0-9H7.8c-1.68 0-2.52 0-3.162.327a3 3 0 0 0-1.311 1.311C3 5.28 3 6.12 3 7.8v8.4c0 1.68 0 2.52.327 3.162a3 3 0 0 0 1.311 1.311C5.28 21 6.12 21 7.8 21H9"}));Ot.displayName="LogOut01";const Tt=({size:t=24,color:e="currentColor",...s})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},N.createElement("path",{d:"m16 17 5-5m0 0-5-5m5 5H9m3 5c0 .93 0 1.395-.102 1.776a3 3 0 0 1-2.122 2.122C9.395 21 8.93 21 8 21h-.5c-1.398 0-2.097 0-2.648-.228a3 3 0 0 1-1.624-1.624C3 18.597 3 17.898 3 16.5v-9c0-1.398 0-2.097.228-2.648a3 3 0 0 1 1.624-1.624C5.403 3 6.102 3 7.5 3H8c.93 0 1.395 0 1.776.102a3 3 0 0 1 2.122 2.122C12 5.605 12 6.07 12 7"}));Tt.displayName="LogOut02";const Pt=({size:t=24,color:e="currentColor",...s})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},N.createElement("path",{d:"m2 7 8.165 5.715c.661.463.992.695 1.351.784a2 2 0 0 0 .968 0c.36-.09.69-.32 1.351-.784L22 7M6.8 20h10.4c1.68 0 2.52 0 3.162-.327a3 3 0 0 0 1.311-1.311C22 17.72 22 16.88 22 15.2V8.8c0-1.68 0-2.52-.327-3.162a3 3 0 0 0-1.311-1.311C19.72 4 18.88 4 17.2 4H6.8c-1.68 0-2.52 0-3.162.327a3 3 0 0 0-1.311 1.311C2 6.28 2 7.12 2 8.8v6.4c0 1.68 0 2.52.327 3.162a3 3 0 0 0 1.311 1.311C4.28 20 5.12 20 6.8 20Z"}));Pt.displayName="Mail01";const Mt=({size:t=24,color:e="currentColor",...s})=>N.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...s},N.createElement("path",{d:"M3 8h12m0 0a3 3 0 1 0 6 0 3 3 0 0 0-6 0Zm-6 8h12M9 16a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"}));Mt.displayName="Settings04";function qs(){const t=w.c(65),{org:e}=ae(),[,s]=He(),{selectedVirtualMcp:r,modelsConnections:o,isChatEmpty:i,activeThreadId:l,createThread:a,switchToThread:c,threads:d}=ps();let m;if(t[0]!==l||t[1]!==d){let F;t[3]!==l?(F=I=>I.id===l,t[3]=l,t[4]=F):F=t[4],m=d.find(F),t[0]=l,t[1]=d,t[2]=m}else m=t[2];const f=m,[u,p]=N.useState(!1),[x,h]=N.useTransition();let b;t[5]!==e.id?(b=hs(e.id),t[5]=e.id,t[6]=b):b=t[6];const j=r??b;let v;t[7]!==a?(v=()=>{h(()=>{a()})},t[7]=a,t[8]=v):v=t[8];const S=v;if(o.length===0){let F;t[9]===Symbol.for("react.memo_cache_sentinel")?(F=n.jsx(Se.Header.Left,{className:"gap-2"}),t[9]=F):F=t[9];let I;t[10]!==s?(I=()=>s(!1),t[10]=s,t[11]=I):I=t[11];let D;t[12]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(Le,{size:16,className:"text-muted-foreground group-hover:text-foreground transition-colors"}),t[12]=D):D=t[12];let G;t[13]!==I?(G=n.jsxs(Se.Header,{className:"flex-none",children:[F,n.jsx(Se.Header.Right,{className:"gap-1",children:n.jsx("button",{type:"button",onClick:I,className:"flex size-6 items-center justify-center rounded-full p-1 hover:bg-transparent transition-colors group cursor-pointer",title:"Close chat",children:D})})]}),t[13]=I,t[14]=G):G=t[14];let Y;t[15]!==e?(Y=n.jsx(te.Main,{className:"flex flex-col items-center",children:n.jsx(te.EmptyState,{children:n.jsx(te.NoLlmBindingEmptyState,{title:"No model provider connected",description:"Connect to a model provider to unlock AI-powered features.",org:e})})}),t[15]=e,t[16]=Y):Y=t[16];let J;return t[17]!==G||t[18]!==Y?(J=n.jsxs(te,{children:[G,Y]}),t[17]=G,t[18]=Y,t[19]=J):J=t[19],J}const C=u?"duration-300 opacity-0 -translate-x-4 pointer-events-none":x?"duration-200 opacity-0 pointer-events-none":"duration-300 opacity-100 translate-x-0";let y;t[20]!==C?(y=_("absolute inset-0 flex flex-col transition-all ease-in-out",C),t[20]=C,t[21]=y):y=t[21];let z;t[22]!==f||t[23]!==i?(z=!i&&f?.title&&n.jsx(xs,{text:f.title,className:"text-sm font-medium text-foreground"}),t[22]=f,t[23]=i,t[24]=z):z=t[24];let O;t[25]!==z?(O=n.jsx(Se.Header.Left,{className:"gap-2",children:z}),t[25]=z,t[26]=O):O=t[26];let $;t[27]===Symbol.for("react.memo_cache_sentinel")?($=n.jsx(ft,{size:16,className:"text-muted-foreground group-hover:text-foreground transition-colors"}),t[27]=$):$=t[27];let k;t[28]!==S||t[29]!==x?(k=n.jsx("button",{type:"button",onClick:S,disabled:x,className:"flex size-6 items-center justify-center rounded-full p-1 hover:bg-transparent group cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",title:"New chat",children:$}),t[28]=S,t[29]=x,t[30]=k):k=t[30];let T;t[31]===Symbol.for("react.memo_cache_sentinel")?(T=()=>p(!0),t[31]=T):T=t[31];let P;t[32]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsx("button",{type:"button",onClick:T,className:"flex size-6 items-center justify-center rounded-full p-1 hover:bg-transparent group cursor-pointer",title:"Chat history",children:n.jsx(gs,{size:16,className:"text-muted-foreground group-hover:text-foreground transition-colors"})}),t[32]=P):P=t[32];let M;t[33]!==s?(M=()=>s(!1),t[33]=s,t[34]=M):M=t[34];let L;t[35]===Symbol.for("react.memo_cache_sentinel")?(L=n.jsx(Le,{size:16,className:"text-muted-foreground group-hover:text-foreground transition-colors"}),t[35]=L):L=t[35];let A;t[36]!==M?(A=n.jsx("button",{type:"button",onClick:M,className:"flex size-6 items-center justify-center rounded-full p-1 hover:bg-transparent transition-colors group cursor-pointer",title:"Close chat",children:L}),t[36]=M,t[37]=A):A=t[37];let E;t[38]!==A||t[39]!==k?(E=n.jsxs(Se.Header.Right,{className:"gap-1",children:[k,P,A]}),t[38]=A,t[39]=k,t[40]=E):E=t[40];let B;t[41]!==E||t[42]!==O?(B=n.jsxs(Se.Header,{className:"flex-none",children:[O,E]}),t[41]=E,t[42]=O,t[43]=B):B=t[43];let K;t[44]!==j||t[45]!==i?(K=n.jsx(te.Main,{children:i?n.jsx(te.EmptyState,{children:n.jsxs("div",{className:"flex flex-col items-center gap-6 w-full px-4",children:[n.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 p-0 text-center",children:[n.jsx(fs,{icon:j.icon,name:j.title,size:"lg",fallbackIcon:n.jsx(ut,{size:32}),className:"size-[60px]! rounded-[18px]!"}),n.jsx("h3",{className:"text-xl font-medium text-foreground",children:j.title}),n.jsx("div",{className:"text-muted-foreground text-center text-sm max-w-md",children:j.description??"Ask anything about configuring model providers or using MCP Mesh."})]}),n.jsx(te.IceBreakers,{})]})}):n.jsx(te.Messages,{})}),t[44]=j,t[45]=i,t[46]=K):K=t[46];let U;t[47]===Symbol.for("react.memo_cache_sentinel")?(U=n.jsx(te.Footer,{children:n.jsx(te.Input,{})}),t[47]=U):U=t[47];let R;t[48]!==B||t[49]!==K||t[50]!==y?(R=n.jsxs("div",{className:y,children:[B,K,U]}),t[48]=B,t[49]=K,t[50]=y,t[51]=R):R=t[51];const H=u?"opacity-100 translate-x-0":"opacity-0 translate-x-4 pointer-events-none";let W;t[52]!==H?(W=_("absolute inset-0 flex flex-col transition-all duration-300 ease-in-out",H),t[52]=H,t[53]=W):W=t[53];let V;t[54]===Symbol.for("react.memo_cache_sentinel")?(V=()=>p(!1),t[54]=V):V=t[54];let Z;t[55]!==l||t[56]!==c||t[57]!==d?(Z=n.jsx(bs,{threads:d,activeThreadId:l,onThreadSelect:c,onClose:V}),t[55]=l,t[56]=c,t[57]=d,t[58]=Z):Z=t[58];let se;t[59]!==W||t[60]!==Z?(se=n.jsx("div",{className:W,children:Z}),t[59]=W,t[60]=Z,t[61]=se):se=t[61];let q;return t[62]!==R||t[63]!==se?(q=n.jsxs(te,{className:"relative overflow-hidden",children:[R,se]}),t[62]=R,t[63]=se,t[64]=q):q=t[64],q}function Js(){const t=w.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(te.Skeleton,{}),t[0]=e):e=t[0];let s;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(pt,{fallback:e,children:n.jsx(N.Suspense,{fallback:n.jsx(te.Skeleton,{}),children:n.jsx(qs,{})})}),t[1]=s):s=t[1],s}const Xs=!1;function Qs(){const t=w.c(33),{locator:e,org:s}=ae(),r=ke(),o=Re(),{org:i,project:l}=ye.parse(e),a=ye.isOrgAdminProject(e),{data:c}=_s(s.id,l);let d;t[0]!==c?.enabledPlugins?(d=c?.enabledPlugins??[],t[0]=c?.enabledPlugins,t[1]=d):d=t[1];const m=d;let f;t[2]!==m?(f=I=>m.includes(I.pluginId),t[2]=m,t[3]=f):f=t[3];const u=qt.filter(f),p=o.location.pathname===`/${i}/${l}`||o.location.pathname===`/${i}/${l}/`;let x;t[4]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(ks,{}),t[4]=x):x=t[4];const h={key:"home",label:"Home",icon:x,onClick:()=>{p?window.dispatchEvent(new CustomEvent("reset-home-view")):r({to:"/$org/$project",params:{org:i,project:l}})}};let b;t[5]===Symbol.for("react.memo_cache_sentinel")?(b=n.jsx(Cs,{}),t[5]=b):b=t[5];const g={key:"tasks",label:"Tasks",icon:b,onClick:()=>r({to:"/$org/$project/tasks",params:{org:i,project:ne}})};let j;t[6]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(us,{}),t[6]=j):j=t[6];const v={key:"mcps",label:"Connections",icon:j,onClick:()=>r({to:"/$org/$project/mcps",params:{org:i,project:ne}})};let S;t[7]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(Xt,{}),t[7]=S):S=t[7];let C;t[8]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsx(Ct,{}),t[8]=C):C=t[8];const y={key:"store",label:"Store",icon:C,onClick:()=>r({to:"/$org/$project/store",params:{org:i,project:ne}})};let z;t[9]===Symbol.for("react.memo_cache_sentinel")?(z=n.jsx(ut,{}),t[9]=z):z=t[9];const O={key:"agents",label:"Agents",icon:z,onClick:()=>r({to:"/$org/$project/agents",params:{org:i,project:ne}})};let $;t[10]===Symbol.for("react.memo_cache_sentinel")?($=n.jsx(St,{}),t[10]=$):$=t[10];const k={key:"monitoring",label:"Monitor",icon:$,onClick:()=>r({to:"/$org/$project/monitoring",params:{org:i,project:ne}})};let T;t[11]===Symbol.for("react.memo_cache_sentinel")?(T=n.jsx(Ge,{}),t[11]=T):T=t[11];const P={key:"workflows",label:"Workflows",icon:T,onClick:()=>r({to:"/$org/$project/workflows",params:{org:i,project:ne}})};let M;t[12]===Symbol.for("react.memo_cache_sentinel")?(M=n.jsx(zt,{}),t[12]=M):M=t[12];const A=[g,v,P,y,O,k,{key:"members",label:"Members",icon:M,onClick:()=>r({to:"/$org/$project/members",params:{org:i,project:ne}})}],E=u.map(I=>({key:I.pluginId,label:I.label,icon:I.icon,onClick:()=>r({to:"/$org/$project/$pluginId",params:{org:i,project:l,pluginId:I.pluginId}})}));let B;t[13]!==m?(B=I=>m.includes(I.pluginId),t[13]=m,t[14]=B):B=t[14];const U=Jt.filter(B).map(I=>({type:"group",group:{id:`${I.pluginId}-${I.id}`,label:I.label,items:I.items.map((D,G)=>({key:`${I.pluginId}-${I.id}-${G}`,label:D.label,icon:D.icon,onClick:()=>r({to:"/$org/$project/$pluginId",params:{org:i,project:l,pluginId:I.pluginId}})})),defaultExpanded:I.defaultExpanded??!0}}));if(a){const I=[{type:"items",items:[h,...A]}];if(E.length>0){let D;t[15]===Symbol.for("react.memo_cache_sentinel")?(D={type:"divider"},t[15]=D):D=t[15],I.push(D);let G;t[16]!==E?(G={type:"items",items:E},t[16]=E,t[17]=G):G=t[17],I.push(G)}if(U.length>0){if(E.length===0){let D;t[18]===Symbol.for("react.memo_cache_sentinel")?(D={type:"divider"},t[18]=D):D=t[18],I.push(D)}I.push(...U)}return I}let R;t[19]===Symbol.for("react.memo_cache_sentinel")?(R=n.jsx(ds,{}),t[19]=R):R=t[19];let H;t[20]!==r||t[21]!==i||t[22]!==l?(H={key:"tasks",label:"Tasks",icon:R,onClick:()=>r({to:"/$org/$project/tasks",params:{org:i,project:l}})},t[20]=r,t[21]=i,t[22]=l,t[23]=H):H=t[23];const W=H;let V;t[24]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx(Ge,{}),t[24]=V):V=t[24];let Z;t[25]!==r||t[26]!==i||t[27]!==l?(Z={key:"workflows",label:"Workflows",icon:V,onClick:()=>r({to:"/$org/$project/workflows",params:{org:i,project:l}})},t[25]=r,t[26]=i,t[27]=l,t[28]=Z):Z=t[28];const F=[{type:"items",items:[h,W,Z]}];if(E.length>0){let I;t[29]===Symbol.for("react.memo_cache_sentinel")?(I={type:"divider"},t[29]=I):I=t[29],F.push(I);let D;t[30]!==E?(D={type:"items",items:E},t[30]=E,t[31]=D):D=t[31],F.push(D)}if(U.length>0){if(E.length===0){let I;t[32]===Symbol.for("react.memo_cache_sentinel")?(I={type:"divider"},t[32]=I):I=t[32],F.push(I)}F.push(...U)}return F}const en="sidebar_state",tn=3600*24*7,sn="16rem",nn="18rem",rn="3rem",on="b",Et=N.createContext(null);function Be(){const t=N.useContext(Et);if(!t)throw new Error("useSidebar must be used within a SidebarProvider.");return t}function ln(t){const e=w.c(21),{defaultOpen:s,open:r,onOpenChange:o,children:i}=t,l=s===void 0?!0:s,a=$e(),[c,d]=N.useState(!1),[m,f]=N.useState(l),u=r??m;let p;e[0]!==u||e[1]!==o?(p=O=>{const $=typeof O=="function"?O(u):O;o?o($):f($),document.cookie=`${en}=${$}; path=/; max-age=${tn}`},e[0]=u,e[1]=o,e[2]=p):p=e[2];const x=p;let h;e[3]!==a||e[4]!==x?(h=()=>a?d(cn):x(an),e[3]=a,e[4]=x,e[5]=h):h=e[5];const b=h;let g,j;e[6]!==b?(g=()=>{const O=$=>{if($.key===on&&($.metaKey||$.ctrlKey)){const k=$.target;if(k.tagName==="INPUT"||k.tagName==="TEXTAREA"||k.isContentEditable)return;$.preventDefault(),b()}};return globalThis.addEventListener("keydown",O),()=>globalThis.removeEventListener("keydown",O)},j=[b],e[6]=b,e[7]=g,e[8]=j):(g=e[7],j=e[8]),N.useEffect(g,j);const v=u?"expanded":"collapsed";let S;e[9]!==a||e[10]!==u||e[11]!==c||e[12]!==x||e[13]!==v||e[14]!==b?(S={state:v,open:u,setOpen:x,isMobile:a,openMobile:c,setOpenMobile:d,toggleSidebar:b},e[9]=a,e[10]=u,e[11]=c,e[12]=x,e[13]=v,e[14]=b,e[15]=S):S=e[15];const C=S;let y;e[16]!==i?(y=n.jsx(ct,{delayDuration:0,children:i}),e[16]=i,e[17]=y):y=e[17];let z;return e[18]!==C||e[19]!==y?(z=n.jsx(Et.Provider,{value:C,children:y}),e[18]=C,e[19]=y,e[20]=z):z=e[20],z}function an(t){return!t}function cn(t){return!t}function dn(t){const e=w.c(14);let s,r,o,i;e[0]!==t?({className:r,style:i,children:s,...o}=t,e[0]=t,e[1]=s,e[2]=r,e[3]=o,e[4]=i):(s=e[1],r=e[2],o=e[3],i=e[4]);let l;e[5]!==i?(l={"--sidebar-width":sn,"--sidebar-width-icon":rn,...i},e[5]=i,e[6]=l):l=e[6];const a=l;let c;e[7]!==r?(c=_("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex h-full w-full",r),e[7]=r,e[8]=c):c=e[8];let d;return e[9]!==s||e[10]!==o||e[11]!==a||e[12]!==c?(d=n.jsx("div",{"data-slot":"sidebar-wrapper",style:a,className:c,...o,children:s}),e[9]=s,e[10]=o,e[11]=a,e[12]=c,e[13]=d):d=e[13],d}function mn(t){const e=w.c(46);let s,r,o,i,l,a;e[0]!==t?({side:i,variant:l,collapsible:a,className:r,children:s,...o}=t,e[0]=t,e[1]=s,e[2]=r,e[3]=o,e[4]=i,e[5]=l,e[6]=a):(s=e[1],r=e[2],o=e[3],i=e[4],l=e[5],a=e[6]);const c=i===void 0?"left":i,d=l===void 0?"sidebar":l,m=a===void 0?"offcanvas":a,{isMobile:f,state:u,openMobile:p,setOpenMobile:x}=Be();if(m==="none"){let $;e[7]!==r?($=_("bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col",r),e[7]=r,e[8]=$):$=e[8];let k;return e[9]!==s||e[10]!==o||e[11]!==$?(k=n.jsx("div",{"data-slot":"sidebar",className:$,...o,children:s}),e[9]=s,e[10]=o,e[11]=$,e[12]=k):k=e[12],k}if(f){let $;e[13]===Symbol.for("react.memo_cache_sentinel")?($={"--sidebar-width":nn},e[13]=$):$=e[13];let k;e[14]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsxs(vs,{className:"sr-only",children:[n.jsx(ws,{children:"Sidebar"}),n.jsx(Ns,{children:"Displays the mobile sidebar."})]}),e[14]=k):k=e[14];let T;e[15]!==s?(T=n.jsx("div",{className:"flex h-full w-full flex-col",children:s}),e[15]=s,e[16]=T):T=e[16];let P;e[17]!==c||e[18]!==T?(P=n.jsxs(Ss,{"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden",style:$,side:c,children:[k,T]}),e[17]=c,e[18]=T,e[19]=P):P=e[19];let M;return e[20]!==p||e[21]!==o||e[22]!==x||e[23]!==P?(M=n.jsx(js,{open:p,onOpenChange:x,...o,children:P}),e[20]=p,e[21]=o,e[22]=x,e[23]=P,e[24]=M):M=e[24],M}const h=u==="collapsed"?m:"",b=d==="floating"||d==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon)";let g;e[25]!==b?(g=_("relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",b),e[25]=b,e[26]=g):g=e[26];let j;e[27]!==g?(j=n.jsx("div",{"data-slot":"sidebar-gap",className:g}),e[27]=g,e[28]=j):j=e[28];const v=c==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",S=d==="floating"||d==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon)";let C;e[29]!==r||e[30]!==v||e[31]!==S?(C=_("fixed top-12 bottom-0 z-10 hidden w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex",v,S,r),e[29]=r,e[30]=v,e[31]=S,e[32]=C):C=e[32];let y;e[33]!==s?(y=n.jsx("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"bg-sidebar group-data-[variant=floating]:border-sidebar-border pt-2 flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm",children:s}),e[33]=s,e[34]=y):y=e[34];let z;e[35]!==o||e[36]!==C||e[37]!==y?(z=n.jsx("div",{"data-slot":"sidebar-container",className:C,...o,children:y}),e[35]=o,e[36]=C,e[37]=y,e[38]=z):z=e[38];let O;return e[39]!==c||e[40]!==u||e[41]!==z||e[42]!==h||e[43]!==j||e[44]!==d?(O=n.jsxs("div",{className:"group peer text-foreground hidden md:block","data-state":u,"data-collapsible":h,"data-variant":d,"data-side":c,"data-slot":"sidebar",children:[j,z]}),e[39]=c,e[40]=u,e[41]=z,e[42]=h,e[43]=j,e[44]=d,e[45]=O):O=e[45],O}function fn(t){const e=w.c(8);let s,r;e[0]!==t?({className:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);let o;e[3]!==s?(o=_("bg-background relative flex w-full flex-1 flex-col min-w-0","md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",s),e[3]=s,e[4]=o):o=e[4];let i;return e[5]!==r||e[6]!==o?(i=n.jsx("main",{"data-slot":"sidebar-inset",className:o,...r}),e[5]=r,e[6]=o,e[7]=i):i=e[7],i}function At(t){const e=w.c(8);let s,r;e[0]!==t?({className:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);let o;e[3]!==s?(o=_("flex flex-col gap-2 p-2",s),e[3]=s,e[4]=o):o=e[4];let i;return e[5]!==r||e[6]!==o?(i=n.jsx("div",{"data-slot":"sidebar-header","data-sidebar":"header",className:o,...r}),e[5]=r,e[6]=o,e[7]=i):i=e[7],i}function un(t){const e=w.c(8);let s,r;e[0]!==t?({className:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);let o;e[3]!==s?(o=_("flex flex-col gap-2 px-2 items-start justify-start",s),e[3]=s,e[4]=o):o=e[4];let i;return e[5]!==r||e[6]!==o?(i=n.jsx("div",{"data-slot":"sidebar-footer","data-sidebar":"footer",className:o,...r}),e[5]=r,e[6]=o,e[7]=i):i=e[7],i}function Lt(t){const e=w.c(8);let s,r;e[0]!==t?({className:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);let o;e[3]!==s?(o=_("h-4 m-0! w-full",s),e[3]=s,e[4]=o):o=e[4];let i;return e[5]!==r||e[6]!==o?(i=n.jsx("div",{"data-sidebar":"separator",className:o,...r}),e[5]=r,e[6]=o,e[7]=i):i=e[7],i}function pn(t){const e=w.c(8);let s,r;e[0]!==t?({className:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);let o;e[3]!==s?(o=_("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",s),e[3]=s,e[4]=o):o=e[4];let i;return e[5]!==r||e[6]!==o?(i=n.jsx("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:o,...r}),e[5]=r,e[6]=o,e[7]=i):i=e[7],i}function Dt(t){const e=w.c(8);let s,r;e[0]!==t?({className:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);let o;e[3]!==s?(o=_("relative flex w-full min-w-0 flex-col px-2 py-2 md:py-0",s),e[3]=s,e[4]=o):o=e[4];let i;return e[5]!==r||e[6]!==o?(i=n.jsx("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:o,...r}),e[5]=r,e[6]=o,e[7]=i):i=e[7],i}function Rt(t){const e=w.c(8);let s,r;e[0]!==t?({className:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);let o;e[3]!==s?(o=_("w-full text-sm",s),e[3]=s,e[4]=o):o=e[4];let i;return e[5]!==r||e[6]!==o?(i=n.jsx("div",{"data-slot":"sidebar-group-content","data-sidebar":"group-content",className:o,...r}),e[5]=r,e[6]=o,e[7]=i):i=e[7],i}function Ce(t){const e=w.c(8);let s,r;e[0]!==t?({className:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);let o;e[3]!==s?(o=_("flex w-full min-w-0 flex-col gap-1",s),e[3]=s,e[4]=o):o=e[4];let i;return e[5]!==r||e[6]!==o?(i=n.jsx("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:o,...r}),e[5]=r,e[6]=o,e[7]=i):i=e[7],i}function me(t){const e=w.c(8);let s,r;e[0]!==t?({className:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);let o;e[3]!==s?(o=_("group/menu-item relative",s),e[3]=s,e[4]=o):o=e[4];let i;return e[5]!==r||e[6]!==o?(i=n.jsx("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:o,...r}),e[5]=r,e[6]=o,e[7]=i):i=e[7],i}const hn=es("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-lg px-2 py-1.5 text-left text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding,colors] transition-colors duration-150 ease-out hover:transition-none focus-visible:ring-2 active:bg-sidebar-accent/75 disabled:pointer-events-none disabled:opacity-50 group-has-data-[sidebar=menu-action]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent/75 [&>span:last-child]:truncate [&>svg]:size-[18px] [&>svg]:shrink-0 [&>svg]:text-muted-foreground",{variants:{variant:{default:"hover:bg-sidebar-accent text-sidebar-foreground/80 active:text-sidebar-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-7 text-sm font-[450]",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function Ue(t){const e=w.c(28);let s,r,o,i,l,a,c;e[0]!==t?({asChild:o,isActive:i,variant:l,size:a,tooltip:c,className:s,...r}=t,e[0]=t,e[1]=s,e[2]=r,e[3]=o,e[4]=i,e[5]=l,e[6]=a,e[7]=c):(s=e[1],r=e[2],o=e[3],i=e[4],l=e[5],a=e[6],c=e[7]);const d=o===void 0?!1:o,m=i===void 0?!1:i,f=l===void 0?"default":l,u=a===void 0?"default":a,p=d?Qt:"button",{isMobile:x,state:h}=Be();let b;e[8]!==s||e[9]!==u||e[10]!==f?(b=_(hn({variant:f,size:u}),s),e[8]=s,e[9]=u,e[10]=f,e[11]=b):b=e[11];let g;e[12]!==p||e[13]!==m||e[14]!==r||e[15]!==u||e[16]!==b?(g=n.jsx(p,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":u,"data-active":m,className:b,...r}),e[12]=p,e[13]=m,e[14]=r,e[15]=u,e[16]=b,e[17]=g):g=e[17];const j=g;if(!c)return j;if(typeof c=="string"){let z;e[18]!==c?(z={children:c},e[18]=c,e[19]=z):z=e[19],c=z}let v;e[20]!==j?(v=n.jsx(Ee,{asChild:!0,children:j}),e[20]=j,e[21]=v):v=e[21];const S=h!=="collapsed"||x;let C;e[22]!==S||e[23]!==c?(C=n.jsx(Me,{side:"right",align:"center",hidden:S,...c}),e[22]=S,e[23]=c,e[24]=C):C=e[24];let y;return e[25]!==v||e[26]!==C?(y=n.jsxs(Ae,{children:[v,C]}),e[25]=v,e[26]=C,e[27]=y):y=e[27],y}function xn(t){const e=w.c(18),{label:s,children:r,defaultExpanded:o}=t,i=o===void 0?!0:o,[l,a]=N.useState(i);let c;e[0]!==l?(c=()=>a(!l),e[0]=l,e[1]=c):c=e[1];let d;e[2]!==s?(d=n.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:s}),e[2]=s,e[3]=d):d=e[3];const m=!l&&"-rotate-90";let f;e[4]!==m?(f=_("text-muted-foreground transition-transform duration-200",m),e[4]=m,e[5]=f):f=e[5];let u;e[6]!==f?(u=n.jsx(ht,{size:12,className:f}),e[6]=f,e[7]=u):u=e[7];let p;e[8]!==c||e[9]!==d||e[10]!==u?(p=n.jsx(Ce,{children:n.jsx(me,{children:n.jsxs(Ue,{className:"h-6 cursor-pointer select-none",onClick:c,children:[d,u]})})}),e[8]=c,e[9]=d,e[10]=u,e[11]=p):p=e[11];let x;e[12]!==r||e[13]!==l?(x=l&&n.jsx(Rt,{children:n.jsx(Ce,{className:"gap-0.5",children:r})}),e[12]=r,e[13]=l,e[14]=x):x=e[14];let h;return e[15]!==p||e[16]!==x?(h=n.jsxs(Dt,{className:"py-0",children:[p,x]}),e[15]=p,e[16]=x,e[17]=h):h=e[17],h}function Ht(t){const e=w.c(13),{item:s}=t;let r;e[0]!==s.icon?(r=n.jsx("span",{className:"text-muted-foreground group-hover/nav-item:text-foreground transition-colors [&>svg]:size-4",children:s.icon}),e[0]=s.icon,e[1]=r):r=e[1];let o;e[2]!==s.label?(o=n.jsx("span",{className:"truncate",children:s.label}),e[2]=s.label,e[3]=o):o=e[3];let i;e[4]!==s.isActive||e[5]!==s.label||e[6]!==s.onClick||e[7]!==r||e[8]!==o?(i=n.jsxs(Ue,{className:"group/nav-item cursor-pointer text-foreground/90 hover:text-foreground",onClick:s.onClick,isActive:s.isActive,tooltip:s.label,children:[r,o]}),e[4]=s.isActive,e[5]=s.label,e[6]=s.onClick,e[7]=r,e[8]=o,e[9]=i):i=e[9];let l;return e[10]!==s.key||e[11]!==i?(l=n.jsx(me,{children:i},s.key),e[10]=s.key,e[11]=i,e[12]=l):l=e[12],l}function gn(t){const e=w.c(12),{section:s}=t;switch(s.type){case"divider":{let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Lt,{className:"my-2"}),e[0]=r):r=e[0],r}case"spacer":{let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx("div",{className:"flex-1"}),e[1]=r):r=e[1],r}case"group":{const r=s.group.label,o=s.group.defaultExpanded;let i;e[2]!==s.group.items?(i=s.group.items.map(jn),e[2]=s.group.items,e[3]=i):i=e[3];let l;return e[4]!==s.group.defaultExpanded||e[5]!==s.group.label||e[6]!==i?(l=n.jsx(xn,{label:r,defaultExpanded:o,children:i}),e[4]=s.group.defaultExpanded,e[5]=s.group.label,e[6]=i,e[7]=l):l=e[7],l}case"items":{let r;e[8]!==s.items?(r=s.items.map(bn),e[8]=s.items,e[9]=r):r=e[9];let o;return e[10]!==r?(o=n.jsx(Dt,{className:"py-0",children:n.jsx(Rt,{children:n.jsx(Ce,{className:"gap-0.5",children:r})})}),e[10]=r,e[11]=o):o=e[11],o}}}function bn(t){return n.jsx(Ht,{item:t},t.key)}function jn(t){return n.jsx(Ht,{item:t},t.key)}function Bt(t){const e=w.c(14),{sections:s,header:r,footer:o,additionalContent:i,variant:l,collapsible:a,contentClassName:c}=t,d=l===void 0?"sidebar":l,m=a===void 0?"icon":a;let f;e[0]!==c?(f=_("flex flex-col flex-1 overflow-x-hidden font-medium border-r pb-2",c),e[0]=c,e[1]=f):f=e[1];let u;e[2]!==s?(u=s.map(vn),e[2]=s,e[3]=u):u=e[3];let p;e[4]!==i||e[5]!==f||e[6]!==u?(p=n.jsxs(pn,{className:f,children:[u,i]}),e[4]=i,e[5]=f,e[6]=u,e[7]=p):p=e[7];let x;return e[8]!==m||e[9]!==o||e[10]!==r||e[11]!==p||e[12]!==d?(x=n.jsxs(mn,{variant:d,collapsible:m,children:[r,p,o]}),e[8]=m,e[9]=o,e[10]=r,e[11]=p,e[12]=d,e[13]=x):x=e[13],x}function vn(t,e){return n.jsx(gn,{section:t},e)}Bt.Skeleton=function(){return n.jsx("div",{className:"flex flex-col gap-0.5",children:Array.from({length:8}).map((e,s)=>n.jsx("div",{className:"w-full h-8",children:n.jsx(de,{className:"h-full bg-sidebar-accent rounded-md"})},s))})};const wn="w-full h-8 justify-start gap-2 px-2 text-sm font-[450] text-sidebar-foreground hover:text-sidebar-foreground hover:bg-sidebar-accent active:bg-sidebar-accent/75 [&>svg]:size-[18px] [&>svg]:text-muted-foreground hover:[&>svg]:text-sidebar-foreground";function ze(t){const e=w.c(8);let s,r;e[0]!==t?({className:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);let o;e[3]!==s?(o=_(wn,s),e[3]=s,e[4]=o):o=e[4];let i;return e[5]!==r||e[6]!==o?(i=n.jsx(X,{variant:"ghost",size:"sm",className:o,...r}),e[5]=r,e[6]=o,e[7]=i):i=e[7],i}function Nn({invitation:t,onStatusChange:e}){const[s,r]=N.useState(!1),[o,i]=N.useState(!1),l=ke(),a=async()=>{r(!0);try{const p=await re.organization.acceptInvitation({invitationId:t.id});if(p.error)oe.error(p.error.message),r(!1);else{e(t.id,"accepted");const x=await re.organization.setActive({organizationId:t.organizationId});x?.data?.slug?(oe.success("Invitation accepted!"),l({to:"/$org",params:{org:x.data.slug}})):(oe.success("Invitation accepted! Redirecting..."),l({to:"/"}))}}catch{oe.error("Failed to accept invitation"),r(!1)}},c=async()=>{i(!0);try{const p=await re.organization.rejectInvitation({invitationId:t.id});p.error?(oe.error(p.error.message),i(!1)):(oe.success("Invitation rejected"),e(t.id,"rejected"),i(!1))}catch{oe.error("Failed to reject invitation"),i(!1)}},d=t.organizationName||t.organizationId,m=t.status==="pending",f=t.status==="accepted",u=t.status==="rejected";return n.jsxs("div",{className:_("flex items-center gap-3 px-3 py-2 h-12 border-b border-border/50 last:border-b-0",!m&&"opacity-50"),children:[n.jsx("div",{className:"shrink-0 size-5 flex items-center justify-center",children:n.jsx(Pt,{size:16,className:"text-muted-foreground"})}),n.jsxs("p",{className:"flex-1 text-sm text-foreground min-w-0 whitespace-nowrap overflow-hidden",children:["You have been invited to ",n.jsx("span",{className:"font-semibold inline-block max-w-[200px] truncate align-bottom",children:d})]}),n.jsx("div",{className:"flex items-center gap-1 shrink-0",children:m?n.jsxs(n.Fragment,{children:[n.jsx(X,{variant:"ghost",size:"icon",onClick:c,disabled:s||o,className:"h-8 w-8",children:n.jsx(tt,{size:14})}),n.jsx(X,{variant:"outline",size:"icon",onClick:a,disabled:s||o,className:"h-8 w-8",children:n.jsx(De,{size:14})})]}):f?n.jsxs(et,{variant:"outline",className:"h-6 px-2 text-xs",children:[n.jsx(De,{size:12}),"Accepted"]}):u?n.jsxs(et,{variant:"outline",className:"h-6 px-2 text-xs",children:[n.jsx(tt,{size:12}),"Declined"]}):null})]})}function Sn(){const[t,e]=N.useState(!1),s=N.useContext(ts),{data:r}=s.hooks.useListUserInvitations(),{data:o}=re.useListOrganizations(),[i,l]=N.useState({}),m=(r??[]).filter(h=>new Date(h.expiresAt)>new Date).map(h=>{const b=(o??[]).find(g=>g.id===h.organizationId);return{...h,organizationSlug:b?.slug||h.organizationSlug,organizationName:b?.name||h.organizationName}}).map(h=>({...h,status:i[h.id]||h.status})),f=[...m].sort((h,b)=>{const g={pending:0,accepted:1,rejected:2};return(g[h.status]??999)-(g[b.status]??999)}),p=m.filter(h=>h.status==="pending").length>0,x=(h,b)=>{l(g=>({...g,[h]:b}))};return n.jsxs(qe,{open:t,onOpenChange:e,children:[n.jsx(Je,{asChild:!0,children:n.jsxs(ze,{children:[n.jsx(Qe,{size:18}),"Inbox",p&&n.jsx("span",{className:"ml-auto h-2 w-2 rounded-full bg-destructive"})]})}),n.jsxs(Xe,{side:"right",align:"start",className:"w-[400px] p-0 overflow-hidden",children:[n.jsx("div",{className:"px-4 py-3 border-b border-border",children:n.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Inbox"})}),n.jsx("div",{className:"max-h-96 overflow-auto",children:f.length>0?f.map(h=>n.jsx(Nn,{invitation:h,onStatusChange:x},h.id)):n.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[n.jsx(Qe,{size:32,className:"text-muted-foreground/40 mb-2"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"No invitations at the moment"})]})})]})]})}function yn(t){const e=w.c(28),{user:s,userImage:r,onOpenSettings:o}=t;let i;e[0]!==s?(i=async()=>{if(!s)return;const y=`ID: ${s.id}
2
- Name: ${s.name||"N/A"}
3
- Email: ${s.email}`;try{await navigator.clipboard.writeText(y),oe.success("User info copied to clipboard")}catch{oe.error("Failed to copy user info to clipboard")}},e[0]=s,e[1]=i):i=e[1];const l=i,a=s.name||s.email||"U";let c;e[2]!==a||e[3]!==r?(c=n.jsx(le,{url:r,fallback:a,shape:"circle",size:"sm",className:"size-8 shrink-0"}),e[2]=a,e[3]=r,e[4]=c):c=e[4];const d=s.name||"User";let m;e[5]!==d?(m=n.jsx("span",{className:"text-sm text-sidebar-foreground truncate font-[450]",children:d}),e[5]=d,e[6]=m):m=e[6];let f;e[7]!==s.email?(f=n.jsx("span",{className:"text-xs text-muted-foreground truncate font-normal",children:s.email}),e[7]=s.email,e[8]=f):f=e[8];let u;e[9]!==m||e[10]!==f?(u=n.jsxs("div",{className:"flex flex-col min-w-0 text-left",children:[m,f]}),e[9]=m,e[10]=f,e[11]=u):u=e[11];let p;e[12]!==l||e[13]!==c||e[14]!==u?(p=n.jsxs(X,{variant:"ghost",onClick:l,className:"h-auto p-2 m-1 mb-0 justify-start gap-2 hover:bg-sidebar-accent hover:text-inherit active:bg-sidebar-accent/75",children:[c,u]}),e[12]=l,e[13]=c,e[14]=u,e[15]=p):p=e[15];let x;e[16]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(Sn,{}),e[16]=x):x=e[16];let h;e[17]===Symbol.for("react.memo_cache_sentinel")?(h=n.jsx(Mt,{size:18}),e[17]=h):h=e[17];let b;e[18]!==o?(b=n.jsxs(ze,{onClick:o,children:[h,"Preferences"]}),e[18]=o,e[19]=b):b=e[19];let g;e[20]===Symbol.for("react.memo_cache_sentinel")?(g=n.jsx(ze,{asChild:!0,children:n.jsxs("a",{href:"https://www.decocms.com/terms-of-use",target:"_blank",rel:"noopener noreferrer",children:[n.jsx(yt,{size:18}),n.jsx("span",{className:"flex-1",children:"Terms & Conditions"}),n.jsx(Ve,{size:14})]})}),e[20]=g):g=e[20];let j;e[21]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx(ze,{asChild:!0,children:n.jsxs("a",{href:"https://github.com/decocms/mesh",target:"_blank",rel:"noopener noreferrer",children:[n.jsx(ot,{className:"size-[18px]"}),n.jsx("span",{className:"flex-1",children:"decocms/mesh"}),n.jsx(Ve,{size:14})]})}),e[21]=j):j=e[21];let v;e[22]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsxs(ze,{onClick:Cn,children:[n.jsx(Tt,{size:18}),"Log out"]}),e[22]=v):v=e[22];let S;e[23]!==b?(S=n.jsxs("div",{className:"p-1 flex flex-col",children:[x,b,g,j,v]}),e[23]=b,e[24]=S):S=e[24];let C;return e[25]!==S||e[26]!==p?(C=n.jsx(n.Fragment,{children:n.jsxs("div",{className:"flex flex-col gap-0.5 bg-sidebar min-w-[250px]",children:[p,S]})}),e[25]=S,e[26]=p,e[27]=C):C=e[27],C}function Cn(){return re.signOut()}function kn(t){const e=w.c(26),{org:s,isActive:r,isHovered:o,onClick:i,onSettings:l,onHover:a}=t,c=r,d=o&&!r,m=o&&"bg-accent/50",f=r&&!o&&"bg-accent hover:bg-accent";let u;e[0]!==m||e[1]!==f?(u=_("flex items-center gap-2 w-full justify-start font-normal h-10 px-2 rounded-lg cursor-pointer transition-colors",m,f),e[0]=m,e[1]=f,e[2]=u):u=e[2];let p;e[3]!==i?(p=S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),i?.())},e[3]=i,e[4]=p):p=e[4];let x;e[5]!==a||e[6]!==s.id?(x=()=>a?.(s.id),e[5]=a,e[6]=s.id,e[7]=x):x=e[7];const h=s.logo??void 0;let b;e[8]!==s.name||e[9]!==h?(b=n.jsx(le,{url:h,fallback:s.name,size:"sm",className:"size-6 shrink-0 rounded-md",objectFit:"cover"}),e[8]=s.name,e[9]=h,e[10]=b):b=e[10];let g;e[11]!==s.name?(g=n.jsx("span",{className:"flex-1 text-sm text-foreground truncate text-left min-w-0",children:s.name}),e[11]=s.name,e[12]=g):g=e[12];let j;e[13]!==l||e[14]!==s.name||e[15]!==d||e[16]!==c?(j=l&&c?n.jsx("button",{type:"button","aria-label":`${s.name} settings`,className:"size-5 shrink-0 flex items-center justify-center rounded-md transition-colors hover:bg-foreground/10",onClick:S=>{S.stopPropagation(),l()},children:n.jsx(xt,{size:16,className:"text-muted-foreground"})}):d?n.jsx(zs,{size:16,className:"text-muted-foreground shrink-0"}):n.jsx("span",{className:"size-5 shrink-0","aria-hidden":"true"}),e[13]=l,e[14]=s.name,e[15]=d,e[16]=c,e[17]=j):j=e[17];let v;return e[18]!==i||e[19]!==u||e[20]!==p||e[21]!==x||e[22]!==b||e[23]!==g||e[24]!==j?(v=n.jsxs("div",{role:"button",tabIndex:0,className:u,onClick:i,onKeyDown:p,onMouseEnter:x,children:[b,g,j]}),e[18]=i,e[19]=u,e[20]=p,e[21]=x,e[22]=b,e[23]=g,e[24]=j,e[25]=v):v=e[25],v}function _n(t){const e=w.c(34),{currentOrgSlug:s,hoveredOrgId:r,onOrgSelect:o,onOrgSettings:i,onPopoverClose:l,onCreateOrganization:a,onOrgHover:c}=t,{data:d}=re.useListOrganizations();let m,f,u,p;if(e[0]!==s||e[1]!==r||e[2]!==a||e[3]!==c||e[4]!==o||e[5]!==i||e[6]!==l||e[7]!==d){let b;e[12]!==s?(b=(y,z)=>y.slug===s?-1:z.slug===s?1:y.name.localeCompare(z.name),e[12]=s,e[13]=b):b=e[13];const g=[...d??[]].sort(b);u="flex flex-col min-w-[240px] border-l border-border";let j;e[14]===Symbol.for("react.memo_cache_sentinel")?(j=n.jsx("span",{className:"text-xs text-muted-foreground truncate",children:"Your Organizations"}),e[14]=j):j=e[14];let v;e[15]!==a||e[16]!==l?(v=()=>{l(),a()},e[15]=a,e[16]=l,e[17]=v):v=e[17];let S;e[18]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(ft,{size:16,className:"text-muted-foreground"}),e[18]=S):S=e[18],e[19]!==v?(p=n.jsxs("div",{className:"flex items-center justify-between h-10 px-3 border-b border-border",children:[j,n.jsx(X,{variant:"ghost",size:"icon",className:"size-5",onClick:v,children:S})]}),e[19]=v,e[20]=p):p=e[20],m="flex flex-col gap-0.5 p-1 flex-1 overflow-y-auto";let C;e[21]!==s||e[22]!==r||e[23]!==c||e[24]!==o||e[25]!==i?(C=y=>n.jsx(kn,{org:y,isActive:y.slug===s,isHovered:y.id===r,onClick:()=>o(y.slug),onSettings:()=>i(y.slug),onHover:c},y.slug),e[21]=s,e[22]=r,e[23]=c,e[24]=o,e[25]=i,e[26]=C):C=e[26],f=g.map(C),e[0]=s,e[1]=r,e[2]=a,e[3]=c,e[4]=o,e[5]=i,e[6]=l,e[7]=d,e[8]=m,e[9]=f,e[10]=u,e[11]=p}else m=e[8],f=e[9],u=e[10],p=e[11];let x;e[27]!==m||e[28]!==f?(x=n.jsx("div",{className:m,children:f}),e[27]=m,e[28]=f,e[29]=x):x=e[29];let h;return e[30]!==u||e[31]!==p||e[32]!==x?(h=n.jsxs("div",{className:u,children:[p,x]}),e[30]=u,e[31]=p,e[32]=x,e[33]=h):h=e[33],h}function Ut(t){const e=w.c(48),{open:s,onOpenChange:r,user:o,userImage:i}=t,[l,a]=ms(),[c,d]=N.useState(!1);let m;e[0]!==o.id?(m=()=>{navigator.clipboard.writeText(o.id),d(!0),setTimeout(()=>d(!1),2e3)},e[0]=o.id,e[1]=m):m=e[1];const f=m;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=n.jsx($s,{className:"text-base",children:"Profile Settings"}),e[2]=u):u=e[2];let p;e[3]===Symbol.for("react.memo_cache_sentinel")?(p=n.jsxs(Is,{className:"px-6 pt-6 pb-4 border-b border-border shrink-0 relative",children:[u,n.jsxs(Os,{className:"absolute top-1/2 right-4 -translate-y-1/2 cursor-pointer rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[n.jsx(Le,{size:16}),n.jsx("span",{className:"sr-only",children:"Close"})]})]}),e[3]=p):p=e[3];const x=o.name||"U";let h;e[4]!==x||e[5]!==i?(h=n.jsx(le,{url:i,fallback:x,shape:"circle",size:"xl",className:"h-16 w-16"}),e[4]=x,e[5]=i,e[6]=h):h=e[6];const b=o.name||"User";let g;e[7]!==b?(g=n.jsx("span",{className:"text-base font-medium text-foreground",children:b}),e[7]=b,e[8]=g):g=e[8];let j;e[9]!==o.email?(j=n.jsx("span",{className:"text-sm text-muted-foreground",children:o.email}),e[9]=o.email,e[10]=j):j=e[10];let v;e[11]!==g||e[12]!==j?(v=n.jsxs("div",{className:"flex flex-col gap-1",children:[g,j]}),e[11]=g,e[12]=j,e[13]=v):v=e[13];let S;e[14]!==h||e[15]!==v?(S=n.jsxs("div",{className:"flex items-center gap-4",children:[h,v]}),e[14]=h,e[15]=v,e[16]=S):S=e[16];let C;e[17]!==l||e[18]!==a?(C=()=>a(!l),e[17]=l,e[18]=a,e[19]=C):C=e[19];let y;e[20]===Symbol.for("react.memo_cache_sentinel")?(y=n.jsxs("div",{className:"flex flex-col gap-1 flex-1 min-w-0",children:[n.jsxs(Ms,{className:"text-sm font-medium text-foreground flex items-center gap-2 pointer-events-none",children:[n.jsx(As,{size:16,className:"text-muted-foreground"}),"Developer Mode"]}),n.jsx("p",{className:"text-xs text-muted-foreground pointer-events-none",children:"Show technical details like JSON input/output for tool calls"})]}),e[20]=y):y=e[20];let z;e[21]!==l||e[22]!==a?(z=n.jsx("div",{onClick:zn,children:n.jsx(Es,{checked:l,onCheckedChange:a})}),e[21]=l,e[22]=a,e[23]=z):z=e[23];let O;e[24]!==C||e[25]!==z?(O=n.jsxs("button",{type:"button",onClick:C,className:"flex items-center justify-between gap-4 p-4 rounded-lg border border-border hover:bg-accent/50 transition-colors text-left w-full cursor-pointer",children:[y,z]}),e[24]=C,e[25]=z,e[26]=O):O=e[26];let $;e[27]!==S||e[28]!==O?($=n.jsxs("div",{className:"p-5 space-y-6 min-h-[225px]",children:[S,O]}),e[27]=S,e[28]=O,e[29]=$):$=e[29];let k;e[30]!==o.id?(k=n.jsx("span",{className:"font-mono text-xs",children:o.id}),e[30]=o.id,e[31]=k):k=e[31];let T;e[32]!==c?(T=c?n.jsx(De,{size:14,className:"text-green-600"}):n.jsx(bt,{size:14,className:"opacity-0 group-hover:opacity-100 transition-opacity"}),e[32]=c,e[33]=T):T=e[33];let P;e[34]!==f||e[35]!==k||e[36]!==T?(P=n.jsx(Ee,{asChild:!0,children:n.jsxs("button",{type:"button",onClick:f,className:"group flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[k,T]})}),e[34]=f,e[35]=k,e[36]=T,e[37]=P):P=e[37];let M;e[38]===Symbol.for("react.memo_cache_sentinel")?(M=n.jsx(Me,{side:"top",children:n.jsx("p",{className:"text-xs",children:"Copy user ID"})}),e[38]=M):M=e[38];let L;e[39]!==P?(L=n.jsx("div",{className:"border-t border-border px-5 py-4 flex items-center shrink-0",children:n.jsx(ct,{children:n.jsxs(Ae,{children:[P,M]})})}),e[39]=P,e[40]=L):L=e[40];let A;e[41]!==$||e[42]!==L?(A=n.jsxs(Ts,{className:"sm:max-w-lg sm:max-h-[85vh] p-0 flex flex-col",closeButtonClassName:"hidden",children:[p,n.jsxs("div",{className:"flex flex-col",children:[$,L]})]}),e[41]=$,e[42]=L,e[43]=A):A=e[43];let E;return e[44]!==r||e[45]!==s||e[46]!==A?(E=n.jsx(Ps,{open:s,onOpenChange:r,children:A}),e[44]=r,e[45]=s,e[46]=A,e[47]=E):E=e[47],E}function zn(t){return t.stopPropagation()}function Wt(t){const e=w.c(76),{isCollapsed:s,variant:r,onCreateProject:o}=t,i=s===void 0?!1:s,l=r===void 0?"light":r;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={strict:!1},e[0]=a):a=e[0];const{org:c,project:d}=Ye(a),{data:m}=re.useListOrganizations(),{data:f}=re.useSession(),u=ke(),p=l==="dark",h=ae()?.project;let b;e[1]!==c||e[2]!==m?(b=m?.find(Q=>Q.slug===c),e[1]=c,e[2]=m,e[3]=b):b=e[3];const g=b,[j,v]=N.useState(!1),[S,C]=N.useState(!1),[y,z]=N.useState(!1),[O,$]=N.useState(null),k=f?.user,T=k?.image;let P;e[4]!==g||e[5]!==O||e[6]!==m?(P=O?m?.find(Q=>Q.id===O):g,e[4]=g,e[5]=O,e[6]=m,e[7]=P):P=e[7];const M=P;let L;e[8]!==u?(L=Q=>{v(!1),u({to:"/$org/$project/settings",params:{org:Q,project:ne}})},e[8]=u,e[9]=L):L=e[9];const A=L;let E;e[10]!==u?(E=Q=>{v(!1),u({to:"/$org/$project",params:{org:Q,project:ne}})},e[10]=u,e[11]=E):E=e[11];const B=E;let K;e[12]!==u?(K=(Q,Fe)=>{v(!1),u({to:"/$org/$project",params:{org:Q,project:Fe}})},e[12]=u,e[13]=K):K=e[13];const U=K;let R;e[14]!==u?(R=(Q,Fe)=>{v(!1),u({to:"/$org/$project/settings",params:{org:Q,project:Fe}})},e[14]=u,e[15]=R):R=e[15];const H=R;let W;e[16]!==o?(W=o?()=>{v(!1),o()}:void 0,e[16]=o,e[17]=W):W=e[17];const V=W;let Z;e[18]===Symbol.for("react.memo_cache_sentinel")?(Z=Q=>{v(Q),Q||$(null)},e[18]=Z):Z=e[18];const se=Z;let q;e[19]!==g?(q=()=>{g&&$(g.id)},e[19]=g,e[20]=q):q=e[20];const F=q,I=p?"hover:bg-zinc-800 text-white":"hover:bg-sidebar-accent",D=i?"justify-center":"justify-start",G=i?"":"pl-0.5! px-1.5 gap-1.5";let Y;e[21]!==I||e[22]!==D||e[23]!==G?(Y=_("h-7 min-w-0 max-w-full",I,D,G),e[21]=I,e[22]=D,e[23]=G,e[24]=Y):Y=e[24];const J=g?.logo??"",ce=g?.name??"",We=p&&"border-none";let fe;e[25]!==We?(fe=_("shrink-0 rounded-[5px]",We),e[25]=We,e[26]=fe):fe=e[26];let ue;e[27]!==J||e[28]!==ce||e[29]!==fe?(ue=n.jsx(le,{url:J,fallback:ce,size:"xs",className:fe,objectFit:"cover"}),e[27]=J,e[28]=ce,e[29]=fe,e[30]=ue):ue=e[30];let pe;e[31]!==g?.name||e[32]!==h||e[33]!==i||e[34]!==p?(pe=!i&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:_("min-w-0 text-left",p&&"flex-1"),children:p&&h?n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-[10px] text-zinc-500 leading-none truncate",children:g?.name??"Select org"}),n.jsx("p",{className:"text-sm text-white font-normal leading-tight mt-0.5 truncate",children:h.name??h.slug})]}):n.jsx("span",{className:"truncate text-[14px] tracking-[-0.00625rem] font-medium text-foreground",children:g?.name??"Select org"})}),p?n.jsx(dt,{className:"size-3 text-zinc-500 shrink-0"}):n.jsx(ht,{className:"size-3.5 text-muted-foreground shrink-0"})]}),e[31]=g?.name,e[32]=h,e[33]=i,e[34]=p,e[35]=pe):pe=e[35];let he;e[36]!==F||e[37]!==Y||e[38]!==ue||e[39]!==pe?(he=n.jsx(Je,{asChild:!0,children:n.jsxs(X,{variant:"ghost",size:"sm",onClick:F,className:Y,children:[ue,pe]})}),e[36]=F,e[37]=Y,e[38]=ue,e[39]=pe,e[40]=he):he=e[40];let xe;e[41]!==k||e[42]!==T?(xe=k&&n.jsx(yn,{user:k,userImage:T,onOpenSettings:()=>{C(!0),v(!1)}}),e[41]=k,e[42]=T,e[43]=xe):xe=e[43];let Ie,Oe;e[44]===Symbol.for("react.memo_cache_sentinel")?(Ie=()=>v(!1),Oe=()=>z(!0),e[44]=Ie,e[45]=Oe):(Ie=e[44],Oe=e[45]);let ge;e[46]!==A||e[47]!==B||e[48]!==O||e[49]!==c?(ge=n.jsx(_n,{currentOrgSlug:c,hoveredOrgId:O,onOrgSelect:B,onOrgSettings:A,onPopoverClose:Ie,onCreateOrganization:Oe,onOrgHover:$}),e[46]=A,e[47]=B,e[48]=O,e[49]=c,e[50]=ge):ge=e[50];let be;e[51]!==V||e[52]!==H||e[53]!==U||e[54]!==M||e[55]!==c||e[56]!==d?(be=Xs,e[51]=V,e[52]=H,e[53]=U,e[54]=M,e[55]=c,e[56]=d,e[57]=be):be=e[57];let je;e[58]!==xe||e[59]!==ge||e[60]!==be?(je=n.jsxs(Xe,{align:"start",side:"bottom",className:"p-0 flex w-auto h-88 overflow-hidden",children:[xe,ge,be]}),e[58]=xe,e[59]=ge,e[60]=be,e[61]=je):je=e[61];let ve;e[62]!==j||e[63]!==he||e[64]!==je?(ve=n.jsxs(qe,{open:j,onOpenChange:se,children:[he,je]}),e[62]=j,e[63]=he,e[64]=je,e[65]=ve):ve=e[65];let we;e[66]!==S||e[67]!==k||e[68]!==T?(we=k&&S&&k.email&&n.jsx(Ut,{open:S,onOpenChange:C,user:{...k,name:k.name??void 0,email:k.email},userImage:T}),e[66]=S,e[67]=k,e[68]=T,e[69]=we):we=e[69];let Ne;e[70]!==y?(Ne=n.jsx(gt,{open:y,onOpenChange:z}),e[70]=y,e[71]=Ne):Ne=e[71];let Te;return e[72]!==ve||e[73]!==we||e[74]!==Ne?(Te=n.jsxs(n.Fragment,{children:[ve,we,Ne]}),e[72]=ve,e[73]=we,e[74]=Ne,e[75]=Te):Te=e[75],Te}Wt.Skeleton=function({variant:e="light"}){const s=e==="dark";return n.jsxs("div",{className:_("flex items-center gap-1.5 h-7 px-1.5 w-full",s&&"text-white"),children:[n.jsx(de,{className:_("size-5 rounded-[5px] shrink-0",s&&"bg-zinc-800")}),n.jsx(de,{className:_("h-3.5 flex-1",s&&"bg-zinc-800")})]})};function Ke(t){const e=w.c(71),{onCreateProject:s}=t,{state:r,toggleSidebar:o}=Be(),i=r==="collapsed",[l,a]=He(),{locator:c}=ae();let d;e[0]!==c?(d=ye.isOrgAdminProject(c),e[0]=c,e[1]=d):d=e[1];const f=!d;let u;e[2]!==a?(u=()=>{a($n)},e[2]=a,e[3]=u):u=e[3];const p=u,x=f&&"bg-[#030302] border-b border-zinc-800";let h;e[4]!==x?(h=_("h-12 gap-0 pt-0 border-r",x),e[4]=x,e[5]=h):h=e[5];const b=i&&"group-hover/switcher:opacity-0 group-hover/switcher:pointer-events-none group-hover/switcher:invisible";let g;e[6]!==b?(g=_("w-full min-w-0 transition-opacity",b),e[6]=b,e[7]=g):g=e[7];const j=f?"dark":"light";let v;e[8]!==i||e[9]!==s||e[10]!==j?(v=n.jsx(Wt,{isCollapsed:i,variant:j,onCreateProject:s}),e[8]=i,e[9]=s,e[10]=j,e[11]=v):v=e[11];let S;e[12]!==g||e[13]!==v?(S=n.jsx("div",{className:g,children:v}),e[12]=g,e[13]=v,e[14]=S):S=e[14];const C=f?"hover:bg-zinc-800 text-zinc-400":"hover:bg-sidebar-accent",y=i?"opacity-0 invisible pointer-events-none group-hover/switcher:opacity-100 group-hover/switcher:visible group-hover/switcher:pointer-events-auto":"opacity-0 invisible pointer-events-none";let z;e[15]!==C||e[16]!==y?(z=_("absolute inset-0 m-auto size-7 transition-opacity",C,y),e[15]=C,e[16]=y,e[17]=z):z=e[17];const O=!i,$=f?"text-zinc-400":"text-muted-foreground";let k;e[18]!==$?(k=_("size-4 shrink-0",$),e[18]=$,e[19]=k):k=e[19];let T;e[20]!==k?(T=n.jsx(_t,{className:k}),e[20]=k,e[21]=T):T=e[21];let P;e[22]!==z||e[23]!==O||e[24]!==T||e[25]!==o?(P=n.jsx(X,{variant:"ghost",size:"icon",className:z,onClick:o,"aria-label":"Expand sidebar",disabled:O,children:T}),e[22]=z,e[23]=O,e[24]=T,e[25]=o,e[26]=P):P=e[26];let M;e[27]!==P||e[28]!==S?(M=n.jsxs("div",{className:"group/switcher relative flex items-center justify-center gap-1.5 min-w-0 flex-1 overflow-hidden",children:[S,P]}),e[27]=P,e[28]=S,e[29]=M):M=e[29];const L=i&&"hidden";let A;e[30]!==L?(A=_("flex items-center gap-0.5 shrink-0",L),e[30]=L,e[31]=A):A=e[31];const E=f?"hover:bg-zinc-800 text-zinc-400 hover:text-white":"hover:bg-sidebar-accent";let B;e[32]!==E?(B=_("size-7",E),e[32]=E,e[33]=B):B=e[33];const K=f?"text-zinc-400":"text-muted-foreground";let U;e[34]!==K?(U=_("size-4",K),e[34]=K,e[35]=U):U=e[35];let R;e[36]!==U?(R=n.jsx(kt,{className:U}),e[36]=U,e[37]=R):R=e[37];let H;e[38]!==i||e[39]!==B||e[40]!==R||e[41]!==o?(H=n.jsx(Ee,{asChild:!0,children:n.jsx(X,{variant:"ghost",size:"icon",className:B,onClick:o,"aria-label":"Collapse sidebar",disabled:i,children:R})}),e[38]=i,e[39]=B,e[40]=R,e[41]=o,e[42]=H):H=e[42];let W;e[43]===Symbol.for("react.memo_cache_sentinel")?(W=n.jsx(Me,{side:"bottom",children:"Collapse sidebar"}),e[43]=W):W=e[43];let V;e[44]!==H?(V=n.jsxs(Ae,{children:[H,W]}),e[44]=H,e[45]=V):V=e[45];let Z;e[46]!==l||e[47]!==f?(Z=_("size-7",f?_("hover:bg-zinc-800 text-zinc-400 hover:text-white",l&&"bg-zinc-800 text-white"):_("hover:bg-sidebar-accent",l&&"bg-sidebar-accent")),e[46]=l,e[47]=f,e[48]=Z):Z=e[48];const se=f?"text-inherit":"text-muted-foreground";let q;e[49]!==se?(q=_(se),e[49]=se,e[50]=q):q=e[50];let F;e[51]!==q?(F=n.jsx(mt,{size:11,className:q}),e[51]=q,e[52]=F):F=e[52];let I;e[53]!==i||e[54]!==Z||e[55]!==F||e[56]!==p?(I=n.jsx(Ee,{asChild:!0,children:n.jsx(X,{variant:"ghost",size:"icon",className:Z,onClick:p,"aria-label":"Toggle Decopilot",disabled:i,children:F})}),e[53]=i,e[54]=Z,e[55]=F,e[56]=p,e[57]=I):I=e[57];let D;e[58]===Symbol.for("react.memo_cache_sentinel")?(D=n.jsx(Me,{side:"bottom",children:"Toggle Decopilot"}),e[58]=D):D=e[58];let G;e[59]!==I?(G=n.jsxs(Ae,{children:[I,D]}),e[59]=I,e[60]=G):G=e[60];let Y;e[61]!==A||e[62]!==V||e[63]!==G?(Y=n.jsxs("div",{className:A,children:[V,G]}),e[61]=A,e[62]=V,e[63]=G,e[64]=Y):Y=e[64];let J;e[65]!==M||e[66]!==Y?(J=n.jsx(Ce,{children:n.jsx(me,{children:n.jsxs("div",{className:"flex items-center justify-between w-full h-12",children:[M,Y]})})}),e[65]=M,e[66]=Y,e[67]=J):J=e[67];let ce;return e[68]!==J||e[69]!==h?(ce=n.jsx(At,{className:h,children:J}),e[68]=J,e[69]=h,e[70]=ce):ce=e[70],ce}function $n(t){return!t}Ke.Skeleton=function({isDark:e=!1}){return n.jsx(At,{className:_("h-12 gap-0 pt-0",e&&"bg-[#030302] border-b border-zinc-800"),children:n.jsx(Ce,{children:n.jsx(me,{children:n.jsxs("div",{className:"flex items-center justify-between w-full h-12",children:[n.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1 px-1.5",children:[n.jsx(de,{className:_("size-5 rounded-[5px] shrink-0",e&&"bg-zinc-800")}),n.jsx(de,{className:_("h-3.5 w-16",e&&"bg-zinc-800")})]}),n.jsxs("div",{className:"flex items-center gap-0.5",children:[n.jsx(de,{className:_("size-7 rounded-lg",e&&"bg-zinc-800")}),n.jsx(de,{className:_("size-7 rounded-lg",e&&"bg-zinc-800")})]})]})})})})};function In(){const t=w.c(10),{locator:e}=ae(),s=ke(),o=Re().location.pathname;let i;t[0]!==o?(i=o.includes("/settings"),t[0]=o,t[1]=i):i=t[1];const l=i;let a;t[2]!==e||t[3]!==s?(a=()=>{s({to:"/$org/$project/settings",params:ye.parse(e)})},t[2]=e,t[3]=s,t[4]=a):a=t[4];const c=a;let d,m;t[5]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx("span",{className:"text-muted-foreground group-hover/nav-item:text-foreground transition-colors [&>svg]:size-4",children:n.jsx(xt,{})}),m=n.jsx("span",{className:"truncate",children:"Settings"}),t[5]=d,t[6]=m):(d=t[5],m=t[6]);let f;return t[7]!==c||t[8]!==l?(f=n.jsx(un,{className:"py-2 border-r",children:n.jsx(Ce,{children:n.jsx(me,{children:n.jsxs(Ue,{className:"group/nav-item cursor-pointer text-foreground/90 hover:text-foreground",onClick:c,isActive:l,tooltip:"Settings",children:[d,m]})})})}),t[7]=c,t[8]=l,t[9]=f):f=t[9],f}function Ft(t){const e=w.c(4),{children:s}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(Lt,{className:"my-2 -ml-1"}),e[0]=r):r=e[0];let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx(me,{children:n.jsx("div",{className:"group-data-[collapsible=icon]:hidden px-2 py-0 text-xs font-medium h-6 text-muted-foreground flex items-center justify-between",children:n.jsx("span",{className:"whitespace-nowrap",children:"Pinned Views"})})}),e[1]=o):o=e[1];let i;return e[2]!==s?(i=n.jsxs(n.Fragment,{children:[r,o,s]}),e[2]=s,e[3]=i):i=e[3],i}function On(t){const e=w.c(26),{item:s}=t,r=ke(),{org:o}=ae(),i=jt(o.id),l=Ls(o.id);let a;e[0]!==l.update||e[1]!==s.url||e[2]!==i?.sidebar_items?(a=async()=>{const S=(i?.sidebar_items||[]).filter(C=>C.url!==s.url);await l.update.mutateAsync({sidebar_items:S})},e[0]=l.update,e[1]=s.url,e[2]=i?.sidebar_items,e[3]=a):a=e[3];const c=a;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=/^https?:\/\/.+/,e[4]=d):d=e[4];let m;e[5]!==s.icon?(m=d.test(s.icon),e[5]=s.icon,e[6]=m):m=e[6];const f=m;let u;e[7]!==s.url||e[8]!==r?(u=()=>{r({to:s.url})},e[7]=s.url,e[8]=r,e[9]=u):u=e[9];const p=s.title;let x;e[10]!==f||e[11]!==s.icon||e[12]!==s.title?(x=n.jsx("div",{className:"flex items-center justify-center shrink-0",children:f?n.jsx("img",{src:s.icon,alt:s.title,className:"h-4 w-4 rounded object-cover"}):n.jsx(Ds,{size:16,className:"text-muted-foreground group-hover/item:text-foreground transition-colors"})}),e[10]=f,e[11]=s.icon,e[12]=s.title,e[13]=x):x=e[13];let h;e[14]!==s.title?(h=s.title.toLocaleLowerCase(),e[14]=s.title,e[15]=h):h=e[15];let b;e[16]!==h?(b=n.jsx("div",{className:"flex-1 min-w-0 flex flex-col items-start",children:n.jsx("span",{className:"truncate text-sm w-full capitalize",children:h})}),e[16]=h,e[17]=b):b=e[17];let g;e[18]!==c?(g=n.jsx(Le,{size:16,className:"text-muted-foreground opacity-0 group-hover/item:opacity-50 hover:opacity-100 cursor-pointer",onClick:v=>{v.preventDefault(),v.stopPropagation(),c()}}),e[18]=c,e[19]=g):g=e[19];let j;return e[20]!==s.title||e[21]!==u||e[22]!==x||e[23]!==b||e[24]!==g?(j=n.jsx(me,{children:n.jsxs(Ue,{className:"w-full pr-2 group/item relative cursor-pointer text-foreground/90 hover:text-foreground",onClick:u,tooltip:p,children:[x,b,g]})}),e[20]=s.title,e[21]=u,e[22]=x,e[23]=b,e[24]=g,e[25]=j):j=e[25],j}function rt(){const t=w.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(me,{children:n.jsx("div",{className:"flex items-center gap-2 px-4 py-2",children:n.jsx(de,{className:"h-4 flex-1"})})}),t[0]=e):e=t[0],e}function Tn(){const t=w.c(4),{org:e}=ae(),r=jt(e.id)?.sidebar_items;if(!r?.length)return null;let o;t[0]!==r?(o=r.map(Pn),t[0]=r,t[1]=o):o=t[1];let i;return t[2]!==o?(i=n.jsx(Ft,{children:o}),t[2]=o,t[3]=i):i=t[3],i}function Pn(t){return n.jsx(On,{item:t},t.url)}function Mn(){const t=w.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(N.Suspense,{fallback:n.jsxs(Ft,{children:[n.jsx(rt,{}),n.jsx(rt,{})]}),children:n.jsx(Tn,{})}),t[0]=e):e=t[0],e}function En(t){const e=w.c(15),{onCreateProject:s}=t,r=Qs(),{locator:o}=ae();let i;e[0]!==o?(i=ye.isOrgAdminProject(o),e[0]=o,e[1]=i):i=e[1];const l=i;let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx(Ke.Skeleton,{}),e[2]=a):a=e[2];let c;e[3]!==s?(c=n.jsx(N.Suspense,{fallback:a,children:n.jsx(Ke,{onCreateProject:s})}),e[3]=s,e[4]=c):c=e[4];let d;e[5]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(In,{}),e[5]=d):d=e[5];let m;e[6]!==l?(m=l?null:n.jsx(Mn,{}),e[6]=l,e[7]=m):m=e[7];let f;e[8]!==m?(f=n.jsx(pt,{children:n.jsx(N.Suspense,{fallback:null,children:m})}),e[8]=m,e[9]=f):f=e[9];const u=l?void 0:"pt-3";let p;return e[10]!==r||e[11]!==c||e[12]!==f||e[13]!==u?(p=n.jsx(Bt,{sections:r,header:c,footer:d,additionalContent:f,contentClassName:u}),e[10]=r,e[11]=c,e[12]=f,e[13]=u,e[14]=p):p=e[14],p}function An(t){const e=w.c(12);let s,r,o,i;e[0]!==t?({className:s,orientation:o,decorative:i,...r}=t,e[0]=t,e[1]=s,e[2]=r,e[3]=o,e[4]=i):(s=e[1],r=e[2],o=e[3],i=e[4]);const l=o===void 0?"horizontal":o,a=i===void 0?!0:i;let c;e[5]!==s?(c=_("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",s),e[5]=s,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==l||e[9]!==r||e[10]!==c?(d=n.jsx(ss,{"data-slot":"separator-root",decorative:a,orientation:l,className:c,...r}),e[7]=a,e[8]=l,e[9]=r,e[10]=c,e[11]=d):d=e[11],d}const Vt=N.createContext(null);function Ln(){const t=N.useContext(Vt);if(!t)throw new Error("TopbarSwitcher compound components must be used within TopbarSwitcher.Root");return t}function Dn(t){const e=w.c(10),{children:s,onItemHover:r}=t,[o,i]=N.useState(null);let l;e[0]!==r?(l=f=>{i(f),r?.(f)},e[0]=r,e[1]=l):l=e[1];const a=l;let c;e[2]!==o||e[3]!==a?(c={hoveredItem:o,setHoveredItem:a},e[2]=o,e[3]=a,e[4]=c):c=e[4];let d;e[5]!==s?(d=n.jsx(qe,{children:s}),e[5]=s,e[6]=d):d=e[6];let m;return e[7]!==c||e[8]!==d?(m=n.jsx(Vt.Provider,{value:c,children:d}),e[7]=c,e[8]=d,e[9]=m):m=e[9],m}function Rn(t){const e=w.c(6),{children:s,onClick:r}=t;let o;e[0]!==s||e[1]!==r?(o=n.jsx(X,{variant:"link",className:"p-0.5 h-auto",onClick:r,type:"button",children:s}),e[0]=s,e[1]=r,e[2]=o):o=e[2];let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Je,{asChild:!0,children:n.jsx(X,{size:"icon",variant:"ghost",className:"w-6 h-6 p-0",children:n.jsx(dt,{size:16,className:"opacity-50"})})}),e[3]=i):i=e[3];let l;return e[4]!==o?(l=n.jsxs("div",{className:"flex items-center gap-1",children:[o,i]}),e[4]=o,e[5]=l):l=e[5],l}function Hn(t){const e=w.c(8),{item:s,fallback:r}=t,o=r===void 0?"":r,i=s?.avatarUrl??"",l=s?.name??o;let a;e[0]!==i||e[1]!==l?(a=n.jsx(le,{url:i,fallback:l,size:"xs",objectFit:"contain"}),e[0]=i,e[1]=l,e[2]=a):a=e[2];const c=s?.name??o;let d;e[3]!==c?(d=n.jsx("span",{children:c}),e[3]=c,e[4]=d):d=e[4];let m;return e[5]!==a||e[6]!==d?(m=n.jsxs("div",{className:"flex items-center gap-2",children:[a,d]}),e[5]=a,e[6]=d,e[7]=m):m=e[7],m}function Bn(t){const e=w.c(6),{children:s,align:r}=t,o=r===void 0?"start":r,l=N.Children.toArray(s).filter(Un).length===1?"280px":"480px";let a;e[0]!==l?(a={width:l},e[0]=l,e[1]=a):a=e[1];let c;return e[2]!==o||e[3]!==s||e[4]!==a?(c=n.jsx(Xe,{align:o,className:"p-0 flex items-start",style:a,children:s}),e[2]=o,e[3]=s,e[4]=a,e[5]=c):c=e[5],c}function Un(t){return N.isValidElement(t)&&(t.type===Kt||t.type===Gt)}function Gt(t){const e=w.c(5),{children:s,className:r}=t;let o;e[0]!==r?(o=_("flex flex-col border-border w-[240px] border-r last:border-r-0 last:w-full",r),e[0]=r,e[1]=o):o=e[1];let i;return e[2]!==s||e[3]!==o?(i=n.jsx("div",{className:o,children:s}),e[2]=s,e[3]=o,e[4]=i):i=e[4],i}const Kt=Gt;function Wn(t){const e=w.c(6),{placeholder:s,value:r,onChange:o}=t,i=s===void 0?"Search...":s;let l;e[0]!==o?(l=c=>o(c.target.value),e[0]=o,e[1]=l):l=e[1];let a;return e[2]!==i||e[3]!==l||e[4]!==r?(a=n.jsx(Rs,{placeholder:i,value:r,onChange:l,className:"rounded-none border-t-0 border-x-0 focus-visible:border-border focus-visible:ring-0"}),e[2]=i,e[3]=l,e[4]=r,e[5]=a):a=e[5],a}function Fn(t){const e=w.c(6),{children:s,emptyMessage:r}=t,o=r===void 0?"No items found.":r,i=N.Children.count(s)>0;let l;e[0]!==o||e[1]!==i?(l=!i&&n.jsx("div",{className:"text-muted-foreground text-sm px-1 py-8 text-center",children:o}),e[0]=o,e[1]=i,e[2]=l):l=e[2];let a;return e[3]!==s||e[4]!==l?(a=n.jsxs("div",{className:"flex flex-col gap-0.5 p-1 max-h-44 overflow-y-auto",children:[l,s]}),e[3]=s,e[4]=l,e[5]=a):a=e[5],a}function Vn(t){const e=w.c(15),{item:s,onClick:r,onHover:o,children:i}=t,l=Ln();let a;e[0]!==l||e[1]!==s||e[2]!==o?(a=()=>{l.setHoveredItem(s.slug),o?.(s)},e[0]=l,e[1]=s,e[2]=o,e[3]=a):a=e[3];const c=a;let d;e[4]!==s||e[5]!==r?(d=()=>r(s),e[4]=s,e[5]=r,e[6]=d):d=e[6];let m;e[7]!==i||e[8]!==s.avatarUrl||e[9]!==s.name?(m=i||n.jsxs(n.Fragment,{children:[n.jsx(le,{url:s.avatarUrl??"",fallback:s.name,size:"xs",className:"w-[22px]! h-[22px]!",objectFit:"contain"}),n.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:s.name})]}),e[7]=i,e[8]=s.avatarUrl,e[9]=s.name,e[10]=m):m=e[10];let f;return e[11]!==c||e[12]!==d||e[13]!==m?(f=n.jsx(X,{onClick:d,onMouseEnter:c,variant:"ghost",size:"sm",className:"w-full justify-start font-normal",children:m}),e[11]=c,e[12]=d,e[13]=m,e[14]=f):f=e[14],f}function Gn(t){const e=w.c(2),{children:s}=t;let r;return e[0]!==s?(r=n.jsx("div",{className:"px-1 pb-1 pt-0.5",children:s}),e[0]=s,e[1]=r):r=e[1],r}function Kn(t){const e=w.c(11),{onClick:s,icon:r,children:o,variant:i}=t,a=(i===void 0?"default":i)==="muted"&&"text-muted-foreground";let c;e[0]!==a?(c=_("w-full justify-start font-normal",a),e[0]=a,e[1]=c):c=e[1];let d;e[2]!==r?(d=r&&n.jsx("span",{className:"[&>svg]:size-4",children:r}),e[2]=r,e[3]=d):d=e[3];let m;e[4]!==o?(m=n.jsx("span",{children:o}),e[4]=o,e[5]=m):m=e[5];let f;return e[6]!==s||e[7]!==c||e[8]!==d||e[9]!==m?(f=n.jsxs(X,{variant:"ghost",size:"sm",className:c,onClick:s,children:[d,m]}),e[6]=s,e[7]=c,e[8]=d,e[9]=m,e[10]=f):f=e[10],f}function Zn(){const t=w.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(An,{}),t[0]=e):e=t[0],e}function Yn(){const t=w.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"h-4 w-16 bg-accent rounded-full animate-pulse"}),t[0]=e):e=t[0],e}const ee=Object.assign(Dn,{Trigger:Rn,CurrentItem:Hn,Content:Bn,Panel:Kt,Search:Wn,Items:Fn,Item:Vn,Actions:Gn,Action:Kn,Separator:Zn,Skeleton:Yn});function Ze(){const t=w.c(59);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={strict:!1},t[0]=e):e=t[0];const{org:s}=Ye(e),{data:r}=re.useListOrganizations(),o=ke();let i;t[1]!==s||t[2]!==r?(i=r?.find(L=>L.slug===s),t[1]=s,t[2]=r,t[3]=i):i=t[3];const l=i,[a,c]=N.useState(""),[d,m]=N.useState(!1);let f,u,p,x,h,b,g,j;if(t[4]!==l||t[5]!==o||t[6]!==s||t[7]!==a||t[8]!==r){const A=(r?(()=>{const H=r.filter(W=>W.name.toLowerCase().includes(a.toLowerCase()));if(s){const W=H.findIndex(V=>V.slug===s);if(W>0){const V=H[W];V&&(H.splice(W,1),H.unshift(V))}}return H})():[]).map(qn);let E;t[17]!==l?(E=l?{slug:l.slug,name:l.name,avatarUrl:l.logo}:void 0,t[17]=l,t[18]=E):E=t[18];const B=E;x=ee;let K;t[19]!==o||t[20]!==s?(K=()=>o({to:"/$org",params:{org:s??""}}),t[19]=o,t[20]=s,t[21]=K):K=t[21];let U;t[22]!==B?(U=n.jsx(ee.CurrentItem,{item:B}),t[22]=B,t[23]=U):U=t[23],t[24]!==K||t[25]!==U?(j=n.jsx(ee.Trigger,{onClick:K,children:U}),t[24]=K,t[25]=U,t[26]=j):j=t[26],p=ee.Content,u=ee.Panel,t[27]!==a?(g=n.jsx(ee.Search,{placeholder:"Search organizations...",value:a,onChange:c}),t[27]=a,t[28]=g):g=t[28],f=ee.Items,h="No organizations found.";let R;t[29]!==o?(R=H=>n.jsx(ee.Item,{item:H,onClick:W=>o({to:"/$org",params:{org:W.slug}})},H.slug),t[29]=o,t[30]=R):R=t[30],b=A.map(R),t[4]=l,t[5]=o,t[6]=s,t[7]=a,t[8]=r,t[9]=f,t[10]=u,t[11]=p,t[12]=x,t[13]=h,t[14]=b,t[15]=g,t[16]=j}else f=t[9],u=t[10],p=t[11],x=t[12],h=t[13],b=t[14],g=t[15],j=t[16];let v;t[31]!==f||t[32]!==h||t[33]!==b?(v=n.jsx(f,{emptyMessage:h,children:b}),t[31]=f,t[32]=h,t[33]=b,t[34]=v):v=t[34];let S,C;t[35]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(ee.Actions,{children:n.jsx(ee.Action,{onClick:()=>m(!0),variant:"muted",children:"+ Create organization"})}),C=n.jsx(ee.Separator,{}),t[35]=S,t[36]=C):(S=t[35],C=t[36]);let y;t[37]!==o?(y=()=>o({to:"/"}),t[37]=o,t[38]=y):y=t[38];let z;t[39]===Symbol.for("react.memo_cache_sentinel")?(z=n.jsx(Hs,{}),t[39]=z):z=t[39];let O;t[40]!==y?(O=n.jsx(ee.Actions,{children:n.jsx(ee.Action,{onClick:y,icon:z,children:"See all organizations"})}),t[40]=y,t[41]=O):O=t[41];let $;t[42]!==u||t[43]!==O||t[44]!==g||t[45]!==v?($=n.jsxs(u,{children:[g,v,S,C,O]}),t[42]=u,t[43]=O,t[44]=g,t[45]=v,t[46]=$):$=t[46];let k;t[47]!==p||t[48]!==$?(k=n.jsx(p,{children:$}),t[47]=p,t[48]=$,t[49]=k):k=t[49];let T;t[50]!==x||t[51]!==k||t[52]!==j?(T=n.jsxs(x,{children:[j,k]}),t[50]=x,t[51]=k,t[52]=j,t[53]=T):T=t[53];let P;t[54]!==d?(P=n.jsx(gt,{open:d,onOpenChange:m}),t[54]=d,t[55]=P):P=t[55];let M;return t[56]!==T||t[57]!==P?(M=n.jsxs(n.Fragment,{children:[T,P]}),t[56]=T,t[57]=P,t[58]=M):M=t[58],M}function qn(t){return{slug:t.slug,name:t.name,avatarUrl:t.logo}}Ze.Skeleton=ee.Skeleton;function Jn(){const t=w.c(10),{locator:e}=ae(),s=Bs();if(ye.isOrgAdminProject(e))return null;const o=s?.leftRef;let i;t[0]!==o?(i=n.jsx("div",{ref:o,className:"flex items-center gap-2 flex-1 min-w-0"}),t[0]=o,t[1]=i):i=t[1];const l=s?.centerRef;let a;t[2]!==l?(a=n.jsx("div",{ref:l,className:"flex flex-1 h-full items-center justify-center px-4 min-w-0 [&:empty]:hidden"}),t[2]=l,t[3]=a):a=t[3];const c=s?.rightRef;let d;t[4]!==c?(d=n.jsx("div",{ref:c,className:"flex flex-1 gap-2 h-full items-center justify-end min-w-0 [&:empty]:hidden"}),t[4]=c,t[5]=d):d=t[5];let m;return t[6]!==i||t[7]!==a||t[8]!==d?(m=n.jsx("div",{className:"dark",children:n.jsxs("header",{className:"sticky top-0 z-50 h-12 bg-background flex items-center px-4 shrink-0",children:[i,a,d]})}),t[6]=i,t[7]=a,t[8]=d,t[9]=m):m=t[9],m}function Xn({prop:t,defaultProp:e,onChange:s=()=>{}}){const[r,o]=Qn({defaultProp:e,onChange:s}),i=t!==void 0,l=i?t:r,a=it(s),c=N.useCallback(d=>{if(i){const f=typeof d=="function"?d(t):d;f!==t&&a(f)}else o(d)},[i,t,o,a]);return[l,c]}function Qn({defaultProp:t,onChange:e}){const s=N.useState(t),[r]=s,o=N.useRef(r),i=it(e);return N.useEffect(()=>{o.current!==r&&(i(r),o.current=r)},[r,o,i]),s}function er(t){const e=w.c(4);let s;e[0]!==t?({...s}=t,e[0]=t,e[1]=s):s=e[1];let r;return e[2]!==s?(r=n.jsx(_e.Root,{"data-slot":"drawer",...s}),e[2]=s,e[3]=r):r=e[3],r}function tr(t){const e=w.c(4);let s;e[0]!==t?({...s}=t,e[0]=t,e[1]=s):s=e[1];let r;return e[2]!==s?(r=n.jsx(_e.Trigger,{"data-slot":"drawer-trigger",...s}),e[2]=s,e[3]=r):r=e[3],r}function sr(t){const e=w.c(4);let s;e[0]!==t?({...s}=t,e[0]=t,e[1]=s):s=e[1];let r;return e[2]!==s?(r=n.jsx(_e.Portal,{"data-slot":"drawer-portal",...s}),e[2]=s,e[3]=r):r=e[3],r}function nr(t){const e=w.c(8);let s,r;e[0]!==t?({className:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);let o;e[3]!==s?(o=_("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",s),e[3]=s,e[4]=o):o=e[4];let i;return e[5]!==r||e[6]!==o?(i=n.jsx(_e.Overlay,{"data-slot":"drawer-overlay",className:o,...r}),e[5]=r,e[6]=o,e[7]=i):i=e[7],i}function rr(t){const e=w.c(12);let s,r,o;e[0]!==t?({className:r,children:s,...o}=t,e[0]=t,e[1]=s,e[2]=r,e[3]=o):(s=e[1],r=e[2],o=e[3]);let i;e[4]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(nr,{}),e[4]=i):i=e[4];let l;e[5]!==r?(l=_("group/drawer-content bg-background fixed z-50 flex h-auto flex-col","data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=top]:rounded-b-lg data-[vaul-drawer-direction=top]:border-b","data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=bottom]:rounded-t-lg data-[vaul-drawer-direction=bottom]:border-t","data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:border-l data-[vaul-drawer-direction=right]:sm:max-w-sm","data-[vaul-drawer-direction=left]:inset-y-0 data-[vaul-drawer-direction=left]:left-0 data-[vaul-drawer-direction=left]:w-3/4 data-[vaul-drawer-direction=left]:border-r data-[vaul-drawer-direction=left]:sm:max-w-sm",r),e[5]=r,e[6]=l):l=e[6];let a;e[7]===Symbol.for("react.memo_cache_sentinel")?(a=n.jsx("div",{className:"bg-muted mx-auto mt-4 hidden h-2 w-[100px] shrink-0 rounded-full group-data-[vaul-drawer-direction=bottom]/drawer-content:block"}),e[7]=a):a=e[7];let c;return e[8]!==s||e[9]!==o||e[10]!==l?(c=n.jsxs(sr,{"data-slot":"drawer-portal",children:[i,n.jsxs(_e.Content,{"data-slot":"drawer-content",className:l,...o,children:[a,s]})]}),e[8]=s,e[9]=o,e[10]=l,e[11]=c):c=e[11],c}function or(t){const e=w.c(8);let s,r;e[0]!==t?({className:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);let o;e[3]!==s?(o=_("flex flex-col gap-1.5 px-4 py-2",s),e[3]=s,e[4]=o):o=e[4];let i;return e[5]!==r||e[6]!==o?(i=n.jsx("div",{"data-slot":"drawer-header",className:o,...r}),e[5]=r,e[6]=o,e[7]=i):i=e[7],i}function ir(t){const e=w.c(8);let s,r;e[0]!==t?({className:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);let o;e[3]!==s?(o=_("text-foreground font-semibold",s),e[3]=s,e[4]=o):o=e[4];let i;return e[5]!==r||e[6]!==o?(i=n.jsx(_e.Title,{"data-slot":"drawer-title",className:o,...r}),e[5]=r,e[6]=o,e[7]=i):i=e[7],i}const Zt=N.createContext({setOpen:()=>{}}),lr=()=>N.useContext(Zt),ar=t=>{const e=w.c(25);let s,r,o,i,l;e[0]!==t?({children:s,defaultOpen:r,open:i,onOpenChange:o,...l}=t,e[0]=t,e[1]=s,e[2]=r,e[3]=o,e[4]=i,e[5]=l):(s=e[1],r=e[2],o=e[3],i=e[4],l=e[5]);const a=r??!1;let c;e[6]!==o||e[7]!==i||e[8]!==a?(c={prop:i,defaultProp:a,onChange:o},e[6]=o,e[7]=i,e[8]=a,e[9]=c):c=e[9];const[d,m]=Xn(c);let f;e[10]!==m?(f={setOpen:m},e[10]=m,e[11]=f):f=e[11];let u;e[12]!==s||e[13]!==d||e[14]!==l||e[15]!==m?(u=n.jsx(er,{open:d,onOpenChange:m,...l,children:s}),e[12]=s,e[13]=d,e[14]=l,e[15]=m,e[16]=u):u=e[16];let p;e[17]!==d||e[18]!==l||e[19]!==m||e[20]!==u?(p=n.jsx(Vs,{open:d,onOpenChange:m,...l,children:u}),e[17]=d,e[18]=l,e[19]=m,e[20]=u,e[21]=p):p=e[21];let x;return e[22]!==f||e[23]!==p?(x=n.jsx(Zt.Provider,{value:f,children:p}),e[22]=f,e[23]=p,e[24]=x):x=e[24],x},cr=t=>{const{children:e,title:s,...r}=t,o=$e(),{className:i,...l}=r;return o?n.jsxs(rr,{...l,children:[n.jsx(or,{className:"hidden",children:n.jsx(ir,{children:s})}),n.jsx("div",{className:_("flex flex-col gap-2 p-2 py-4",i),children:e})]}):n.jsx(Fs,{...r,children:e})},dr=t=>{const{children:e,...s}=t,{setOpen:r}=lr(),o=$e(),{className:i,...l}=s;return o?n.jsx("div",{...l,onClick:a=>{r(!1);const{onClick:c}=l;c?.(a)},className:_("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-lg px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",i),children:e}):n.jsx(Gs,{...s,children:e})},mr=t=>{const e=w.c(7);let s,r;e[0]!==t?({children:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);const o=$e();let i;return e[3]!==s||e[4]!==o||e[5]!==r?(i=o?n.jsx(tr,{asChild:!0,children:s}):n.jsx(Ws,{...r,children:s}),e[3]=s,e[4]=o,e[5]=r,e[6]=i):i=e[6],i},fr=t=>{const e=w.c(7);let s,r;e[0]!==t?({className:s,...r}=t,e[0]=t,e[1]=s,e[2]=r):(s=e[1],r=e[2]);const o=$e();let i;return e[3]!==s||e[4]!==o||e[5]!==r?(i=o?n.jsx(st,{className:_(s),...r}):n.jsx(st,{className:_(s),...r}),e[3]=s,e[4]=o,e[5]=r,e[6]=i):i=e[6],i};function ur(t){const e=w.c(11),{user:s,trigger:r,align:o,children:i}=t,l=o===void 0?"start":o;let a;e[0]!==r||e[1]!==s?(a=r(s),e[0]=r,e[1]=s,e[2]=a):a=e[2];let c;e[3]!==a?(c=n.jsx(mr,{asChild:!0,children:n.jsx("div",{children:a})}),e[3]=a,e[4]=c):c=e[4];let d;e[5]!==l||e[6]!==i?(d=n.jsx(cr,{side:"top",align:l,className:"md:w-[240px]",children:i}),e[5]=l,e[6]=i,e[7]=d):d=e[7];let m;return e[8]!==c||e[9]!==d?(m=n.jsxs(ar,{children:[c,d]}),e[8]=c,e[9]=d,e[10]=m):m=e[10],m}function pr(t){const e=w.c(8),{children:s,onClick:r,className:o,asChild:i}=t;let l;e[0]!==i||e[1]!==s||e[2]!==r?(l=i?s:n.jsx("button",{type:"button",className:"flex items-center gap-2 text-sm w-full cursor-pointer",onClick:r,children:s}),e[0]=i,e[1]=s,e[2]=r,e[3]=l):l=e[3];let a;return e[4]!==i||e[5]!==o||e[6]!==l?(a=n.jsx(dr,{asChild:i,className:o,children:l}),e[4]=i,e[5]=o,e[6]=l,e[7]=a):a=e[7],a}function hr(t){const e=w.c(2),{className:s}=t;let r;return e[0]!==s?(r=n.jsx(fr,{className:s}),e[0]=s,e[1]=r):r=e[1],r}function xr(){const t=w.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"w-8 h-8 bg-muted rounded-full animate-pulse"}),t[0]=e):e=t[0],e}const ie=Object.assign(ur,{Item:pr,Separator:hr,Skeleton:xr});function gr(t){const e=w.c(47),{user:s,userImage:r}=t,[o,i]=N.useState(!1),[l,a]=N.useState(!1);let c;e[0]!==s.email||e[1]!==s.id||e[2]!==s.name?(c=()=>{const E=`ID: ${s.id}
4
- Name: ${s.name||"N/A"}
5
- Email: ${s.email}`;navigator.clipboard.writeText(E),a(!0),oe.success("User info copied to clipboard"),setTimeout(()=>a(!1),2e3)},e[0]=s.email,e[1]=s.id,e[2]=s.name,e[3]=c):c=e[3];const d=c;let m;e[4]!==s.email||e[5]!==s.name||e[6]!==r?(m=()=>n.jsx(le,{url:r,fallback:s.name||s.email||"U",shape:"circle",size:"sm",className:"cursor-pointer hover:ring-2 ring-muted-foreground transition-all h-7 w-7"}),e[4]=s.email,e[5]=s.name,e[6]=r,e[7]=m):m=e[7];const f=s.name||s.email||"U";let u;e[8]!==f||e[9]!==r?(u=n.jsx(le,{url:r,fallback:f,shape:"circle",size:"sm"}),e[8]=f,e[9]=r,e[10]=u):u=e[10];const p=s.name||"User";let x;e[11]!==p?(x=n.jsx("div",{className:"text-sm font-medium truncate",children:p}),e[11]=p,e[12]=x):x=e[12];let h;e[13]!==s.email?(h=n.jsx("div",{className:"text-xs text-muted-foreground truncate",children:s.email}),e[13]=s.email,e[14]=h):h=e[14];let b;e[15]!==x||e[16]!==h?(b=n.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[x,h]}),e[15]=x,e[16]=h,e[17]=b):b=e[17];let g;e[18]!==l?(g=n.jsx("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:l?n.jsx(De,{size:16,className:"text-green-600"}):n.jsx(bt,{size:16,className:"text-muted-foreground"})}),e[18]=l,e[19]=g):g=e[19];let j;e[20]!==u||e[21]!==b||e[22]!==g?(j=n.jsxs("div",{className:"group flex items-center gap-3 w-full py-1",children:[u,b,g]}),e[20]=u,e[21]=b,e[22]=g,e[23]=j):j=e[23];let v;e[24]!==d||e[25]!==j?(v=n.jsx(ie.Item,{onClick:d,children:j}),e[24]=d,e[25]=j,e[26]=v):v=e[26];let S;e[27]===Symbol.for("react.memo_cache_sentinel")?(S=n.jsx(ie.Separator,{}),e[27]=S):S=e[27];let C,y;e[28]===Symbol.for("react.memo_cache_sentinel")?(C=n.jsxs(ie.Item,{onClick:()=>i(!0),children:[n.jsx(Ks,{className:"text-muted-foreground",size:18}),"Profile Settings"]}),y=n.jsx(ie.Separator,{}),e[28]=C,e[29]=y):(C=e[28],y=e[29]);let z;e[30]===Symbol.for("react.memo_cache_sentinel")?(z=n.jsx(ot,{className:"w-4 h-4 text-muted-foreground"}),e[30]=z):z=e[30];let O;e[31]===Symbol.for("react.memo_cache_sentinel")?(O=n.jsx(ie.Item,{asChild:!0,children:n.jsxs("a",{href:"https://github.com/decocms/admin",target:"_blank",rel:"noopener noreferrer",className:"flex w-full items-center gap-2 text-sm cursor-pointer",children:[z,"decocms/admin",n.jsx(nt,{size:18,className:"text-muted-foreground ml-auto"})]})}),e[31]=O):O=e[31];let $;e[32]===Symbol.for("react.memo_cache_sentinel")?($=n.jsx($t,{className:"text-muted-foreground",size:18}),e[32]=$):$=e[32];let k,T;e[33]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(ie.Item,{asChild:!0,children:n.jsxs("a",{href:"https://decocms.com",target:"_blank",rel:"noopener noreferrer",className:"flex w-full items-center gap-2 text-sm cursor-pointer",children:[$,"Homepage",n.jsx(nt,{size:18,className:"ml-auto text-muted-foreground"})]})}),T=n.jsx(ie.Separator,{}),e[33]=k,e[34]=T):(k=e[33],T=e[34]);let P;e[35]===Symbol.for("react.memo_cache_sentinel")?(P=n.jsxs(ie.Item,{onClick:br,children:[n.jsx(Ot,{size:18,className:"text-muted-foreground"}),"Log out"]}),e[35]=P):P=e[35];let M;e[36]!==v||e[37]!==m||e[38]!==s?(M=n.jsxs(ie,{user:s,trigger:m,align:"end",children:[v,S,C,y,O,k,T,P]}),e[36]=v,e[37]=m,e[38]=s,e[39]=M):M=e[39];let L;e[40]!==o||e[41]!==s||e[42]!==r?(L=o&&n.jsx(Ut,{open:o,onOpenChange:i,user:s,userImage:r}),e[40]=o,e[41]=s,e[42]=r,e[43]=L):L=e[43];let A;return e[44]!==M||e[45]!==L?(A=n.jsxs(n.Fragment,{children:[M,L]}),e[44]=M,e[45]=L,e[46]=A):A=e[46],A}function br(){return re.signOut()}function jr(){const t=w.c(7),{data:e}=re.useSession();if(!e?.user){let c;return t[0]===Symbol.for("react.memo_cache_sentinel")?(c=n.jsx(le,{url:void 0,fallback:"U",shape:"circle",size:"sm",className:"cursor-pointer h-7 w-7",muted:!0}),t[0]=c):c=t[0],c}const s=e.user,r=s.name??void 0;let o;t[1]!==r||t[2]!==s?(o={...s,name:r},t[1]=r,t[2]=s,t[3]=o):o=t[3];const i=o,l=s.image;let a;return t[4]!==l||t[5]!==i?(a=n.jsx(gr,{user:i,userImage:l}),t[4]=l,t[5]=i,t[6]=a):a=t[6],a}function vr(){const t=w.c(2),s=Re().location.href;let r;return t[0]!==s?(r=n.jsx(is,{to:"/login",search:{next:s},replace:!0}),t[0]=s,t[1]=r):r=t[1],r}function wr(t){const e=w.c(6),{children:s}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsx(ns,{children:n.jsx(lt,{})}),e[0]=r):r=e[0];let o;e[1]!==s?(o=n.jsx(rs,{children:s}),e[1]=s,e[2]=o):o=e[2];let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(os,{children:n.jsx(vr,{})}),e[3]=i):i=e[3];let l;return e[4]!==o?(l=n.jsxs(n.Fragment,{children:[r,o,i]}),e[4]=o,e[5]=l):l=e[5],l}function Nr(t){const e=w.c(5),{children:s,className:r}=t;let o;e[0]!==r?(o=_("fixed top-0 left-0 right-0 z-20 bg-background flex items-center w-full h-12 border-b border-border",r),e[0]=r,e[1]=o):o=e[1];let i;return e[2]!==s||e[3]!==o?(i=n.jsx("div",{className:o,children:s}),e[2]=s,e[3]=o,e[4]=i):i=e[4],i}function Sr(t){const e=w.c(5),{children:s,className:r}=t;let o;e[0]!==r?(o=_("flex items-center justify-center px-2.5 h-full border-r border-border",r),e[0]=r,e[1]=o):o=e[1];let i;return e[2]!==s||e[3]!==o?(i=n.jsx("div",{className:o,children:s}),e[2]=s,e[3]=o,e[4]=i):i=e[4],i}function yr(t){const e=w.c(5),{children:s,className:r}=t;let o;e[0]!==r?(o=_("flex items-center gap-2 px-2 h-full",r),e[0]=r,e[1]=o):o=e[1];let i;return e[2]!==s||e[3]!==o?(i=n.jsx("div",{className:o,children:s}),e[2]=s,e[3]=o,e[4]=i):i=e[4],i}function Cr(t){const e=w.c(5),{children:s,className:r}=t;let o;e[0]!==r?(o=_("flex items-center gap-2 px-2 h-full flex-1",r),e[0]=r,e[1]=o):o=e[1];let i;return e[2]!==s||e[3]!==o?(i=n.jsx("div",{className:o,children:s}),e[2]=s,e[3]=o,e[4]=i):i=e[4],i}function kr(t){const e=w.c(5),{children:s,className:r}=t;let o;e[0]!==r?(o=_("flex items-center gap-2 px-2 h-full ml-auto",r),e[0]=r,e[1]=o):o=e[1];let i;return e[2]!==s||e[3]!==o?(i=n.jsx("div",{className:o,children:s}),e[2]=s,e[3]=o,e[4]=i):i=e[4],i}function _r(){const t=w.c(3);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx("div",{className:"flex items-center justify-center px-2 h-full border-r border-border",children:n.jsx("div",{className:"w-8 h-8 bg-muted rounded-md animate-pulse"})}),t[0]=e):e=t[0];let s;t[1]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx("div",{className:"flex items-center gap-2 px-2 h-full",children:n.jsx("div",{className:"w-32 h-6 bg-muted rounded-md animate-pulse"})}),t[1]=s):s=t[1];let r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=n.jsxs("div",{className:"fixed top-0 left-0 right-0 z-20 bg-background flex items-center w-full h-12 border-b border-border",children:[e,s,n.jsx("div",{className:"flex items-center gap-2 px-2 h-full ml-auto",children:n.jsx("div",{className:"w-8 h-8 bg-muted rounded-full animate-pulse"})})]}),t[2]=r):r=t[2],r}const Pe=Object.assign(Nr,{Sidebar:Sr,Left:yr,Center:Cr,Right:kr,Skeleton:_r});function Yt(){const t=w.c(3),{toggleSidebar:e}=Be();let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=n.jsx(It,{className:"text-muted-foreground/85 group-hover:text-foreground transition-colors",size:18}),t[0]=s):s=t[0];let r;return t[1]!==e?(r=n.jsx(n.Fragment,{children:n.jsx(X,{onClick:e,size:"icon",variant:"ghost",className:"w-7 h-7 rounded-md",children:s})}),t[1]=e,t[2]=r):r=t[2],r}Yt.Skeleton=function(){return n.jsx("div",{className:"w-7 h-7 bg-muted rounded-md animate-pulse"})};function zr({showSidebarToggle:t=!1,showOrgSwitcher:e=!1,showDecoChat:s=!1,disableDecoChat:r=!1}){const[o,i]=He(),l=N.useRef(r);r&&o&&l.current!==r&&i(!1),l.current=r;const a=()=>{r||i(c=>!c)};return n.jsxs(Pe,{children:[t&&n.jsx(Pe.Sidebar,{children:n.jsx(Yt,{})}),n.jsx(Pe.Left,{children:e&&n.jsx(N.Suspense,{fallback:n.jsx(Ze.Skeleton,{}),children:n.jsx(Ze,{})})}),n.jsxs(Pe.Right,{className:"gap-2",children:[s&&!r&&n.jsxs(X,{size:"sm",variant:"default",onClick:a,className:"h-7 gap-2",children:[n.jsx(mt,{size:16}),"Chat"]}),n.jsx(jr,{})]})]})}function $r(t){const e=w.c(10),{children:s,className:r}=t,[,o]=N.useTransition();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=wt.decoChatPanelWidth(),e[0]=i):i=e[0];const[l,a]=vt(i,30);let c;e[1]!==a?(c=u=>o(()=>a(u)),e[1]=a,e[2]=c):c=e[2];const d=c;let m;e[3]!==r?(m=_("min-w-0",r),e[3]=r,e[4]=m):m=e[4];let f;return e[5]!==l||e[6]!==s||e[7]!==d||e[8]!==m?(f=n.jsx(Nt,{defaultSize:l,minSize:20,className:m,onResize:d,children:s}),e[5]=l,e[6]=s,e[7]=d,e[8]=m,e[9]=f):f=e[9],f}function Ir(t){const e=w.c(5),{children:s}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=wt.sidebarOpen(),e[0]=r):r=e[0];const[o,i]=vt(r,!0);let l;return e[1]!==s||e[2]!==i||e[3]!==o?(l=n.jsx(ln,{open:o,onOpenChange:i,children:s}),e[1]=s,e[2]=i,e[3]=o,e[4]=l):l=e[4],l}function Or(t){const e=w.c(6),{disableChat:s}=t,r=s===void 0?!1:s,[o]=He();let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx(Nt,{className:"bg-background",children:n.jsx(at,{})}),e[0]=i):i=e[0];let l;e[1]!==o||e[2]!==r?(l=!r&&n.jsxs(n.Fragment,{children:[n.jsx(Zs,{withHandle:o}),n.jsx($r,{className:_(o?"max-w-none":"max-w-0"),children:n.jsx(Js,{})})]}),e[1]=o,e[2]=r,e[3]=l):l=e[3];let a;return e[4]!==l?(a=n.jsxs(Ys,{direction:"horizontal",children:[i,l]}),e[4]=l,e[5]=a):a=e[5],a}function Tr(){const{org:t,project:e}=Ye({strict:!1}),s=Re(),[r,o]=N.useState(!1),i=s.location.pathname===`/${t}/${e}`||s.location.pathname===`/${t}/${e}/`,l=e??ne,{data:a}=ls({queryKey:as.activeOrganization(t),queryFn:async()=>{if(!t)return null;const{data:d}=await re.organization.setActive({organizationSlug:t});return{org:d,project:{slug:l,isOrgAdmin:l===ne}}},gcTime:1/0,staleTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1});if(!a)return n.jsxs("div",{className:"min-h-screen bg-background",children:[n.jsx(zr,{}),n.jsx("div",{className:"pt-12",children:n.jsx(at,{})})]});if(!a.org)return window.location.pathname!=="/"&&(window.location.href="/"),null;const c={...a,project:{...a.project,slug:l,isOrgAdmin:l===ne}};return n.jsxs(cs,{...c,children:[n.jsx(Ir,{children:n.jsxs("div",{className:"flex flex-col h-screen",style:{"--project-topbar-height":l===ne?"0px":"48px"},children:[n.jsx("style",{children:`
6
- [data-slot="sidebar-container"] {
7
- top: 0 !important;
8
- }
9
- [data-slot="sidebar-inner"] {
10
- padding-top: 0 !important;
11
- }
12
- `}),n.jsx(te.Provider,{children:n.jsxs(dn,{className:"flex-1 bg-sidebar",style:{"--sidebar-width":"13rem","--sidebar-width-mobile":"11rem"},children:[n.jsx(En,{onCreateProject:()=>o(!0)}),n.jsx(fn,{className:"flex flex-col",children:n.jsxs(Us,{children:[n.jsx(Jn,{}),n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(Or,{disableChat:i})})]})})]})})]})}),n.jsx(ys,{open:r,onOpenChange:o})]})}function Jo(){const t=w.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(wr,{children:n.jsx(N.Suspense,{fallback:n.jsx(lt,{}),children:n.jsx(Tr,{})})}),t[0]=e):e=t[0],e}export{Jo as default};
@@ -1 +0,0 @@
1
- import{I as u}from"./infiniteQueryObserver-C_2kO8fk.js";import{a5 as i}from"./index-D3nlG5Bn.js";function t(e,r){return i(e,u,r)}export{t as u};
@@ -1 +0,0 @@
1
- import{a5 as u,a8 as s}from"./index-D3nlG5Bn.js";function o(e,r){return u(e,s,r)}export{o as u};
@@ -1 +0,0 @@
1
- import{ac as a,ad as c}from"./index-D3nlG5Bn.js";function e(...r){return a(c(r))}export{e as c};