erdbpro 3.4.7-rc.26 → 3.4.7-rc.28

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 (154) hide show
  1. package/dist/assets/{AdminRoute-CjUFRlRA.js → AdminRoute-CzN7fVs_.js} +2 -2
  2. package/dist/assets/{Combination-2TXYfiVJ.js → Combination-vqN0XDK-.js} +1 -1
  3. package/dist/assets/{DataViewerModeToolbar-DdBnvR3T.js → DataViewerModeToolbar-BQl3KWZ1.js} +1 -1
  4. package/dist/assets/{DbClientEditorRoute-Bb4PK20w.js → DbClientEditorRoute-BhNgJeL_.js} +1 -1
  5. package/dist/assets/{DiagramEditorRoute-fCxXjJah.js → DiagramEditorRoute-AI8FtKWh.js} +1 -1
  6. package/dist/assets/{DrawingEditorRoute-zi8GcdrA.js → DrawingEditorRoute-COiQKwzH.js} +2 -2
  7. package/dist/assets/{DrawingsView-DM0WEv88.js → DrawingsView-DJ09OIzi.js} +1 -1
  8. package/dist/assets/{ERDComments-C8HbR05_.js → ERDComments-Xwt7V4OK.js} +1 -1
  9. package/dist/assets/{ExcalidrawEditor-BJMZ2z1D.js → ExcalidrawEditor-BOhzLASV.js} +8 -8
  10. package/dist/assets/{FileCommentMarkers-DIo-MSED.js → FileCommentMarkers-Laiy6bpC.js} +1 -1
  11. package/dist/assets/{FlowchartEditorRoute-D4wNhGZm.js → FlowchartEditorRoute-CC_bVIdA.js} +1 -1
  12. package/dist/assets/{FlowchartView-esgoLO4T.js → FlowchartView-DHnUjqeM.js} +1 -1
  13. package/dist/assets/{JumpToNode-Cu3WQt8p.js → JumpToNode-6hHRtxhW.js} +1 -1
  14. package/dist/assets/{LibraryRoute-Dsj-HRhp.js → LibraryRoute-RvBxf4iy.js} +1 -1
  15. package/dist/assets/{NoteEditorRoute-cVqk85St.js → NoteEditorRoute-DFlWjtjo.js} +2 -2
  16. package/dist/assets/{NotesCompanionPane-slRR5lKa.js → NotesCompanionPane-T_14fcL8.js} +2 -2
  17. package/dist/assets/{NotesView-C15bRZV2.js → NotesView-t2i5YEBB.js} +3 -3
  18. package/dist/assets/{ProjectFileTabs-7LRUbYsP.js → ProjectFileTabs-Brr9j8Tz.js} +1 -1
  19. package/dist/assets/{TeamInventoryRoute-D8xFvVfH.js → TeamInventoryRoute-Coozl08L.js} +1 -1
  20. package/dist/assets/{TeamManagementRoute-DLEkBy_e.js → TeamManagementRoute-BuSe3hnH.js} +1 -1
  21. package/dist/assets/{TrashView-C1jygZFG.js → TrashView-CLMQhpsm.js} +1 -1
  22. package/dist/assets/{UserManagementRoute-DLUyAAwg.js → UserManagementRoute-C08pHbdA.js} +1 -1
  23. package/dist/assets/WorkspaceProvider-Dc-LU3z8.js +71 -0
  24. package/dist/assets/{abnfDiagram-N423BO3Z-CjiDHFQ_.js → abnfDiagram-N423BO3Z-Jr663qlB.js} +1 -1
  25. package/dist/assets/{ar-SA-G6X2FPQ2-InsguAqB.js → ar-SA-G6X2FPQ2-CCNown9g.js} +1 -1
  26. package/dist/assets/{architectureDiagram-T3A2C74G-tUsneiE3.js → architectureDiagram-T3A2C74G-BsRUx7LT.js} +1 -1
  27. package/dist/assets/{az-AZ-76LH7QW2-BlGw5gMC.js → az-AZ-76LH7QW2-XZtdS929.js} +1 -1
  28. package/dist/assets/{bg-BG-XCXSNQG7-D2DIKH1i.js → bg-BG-XCXSNQG7-Dl5ShODy.js} +1 -1
  29. package/dist/assets/{blockDiagram-VBNYF7ZC-DHKtVpOy.js → blockDiagram-VBNYF7ZC-Bx7xQY6v.js} +1 -1
  30. package/dist/assets/{bn-BD-2XOGV67Q-D5AI-WLC.js → bn-BD-2XOGV67Q-DE8E93c9.js} +1 -1
  31. package/dist/assets/{c4Diagram-5PPSVZJV-BBPO4IWq.js → c4Diagram-5PPSVZJV-Bb4nUqSN.js} +1 -1
  32. package/dist/assets/{ca-ES-6MX7JW3Y-a9dFyY8U.js → ca-ES-6MX7JW3Y-C0nnKfF7.js} +1 -1
  33. package/dist/assets/{calendar-76sQ3D4f.js → calendar-Bjc1jNFb.js} +1 -1
  34. package/dist/assets/channel-wNvhgAnO.js +1 -0
  35. package/dist/assets/{chunk-2GRJ4B5K-Dl1ceHy-.js → chunk-2GRJ4B5K-ChTt0fWn.js} +1 -1
  36. package/dist/assets/{chunk-4I5QYGJK-CB4HdPY6.js → chunk-4I5QYGJK-B1_lo4Yj.js} +1 -1
  37. package/dist/assets/{chunk-5RXB4S5H-MstfWNXU.js → chunk-5RXB4S5H-DeiN1AMZ.js} +1 -1
  38. package/dist/assets/{chunk-6Q2QTUOP-DQdNWX7Z.js → chunk-6Q2QTUOP-DT7f2KOT.js} +1 -1
  39. package/dist/assets/{chunk-7Z6QIM7H-C06OUB6Z.js → chunk-7Z6QIM7H-BAcImS1r.js} +1 -1
  40. package/dist/assets/{chunk-EIO257PC-BUcd0Goz.js → chunk-EIO257PC-B4q0u_p6.js} +1 -1
  41. package/dist/assets/{chunk-GF5L2VYU-DRgCxr0T.js → chunk-GF5L2VYU-CXt4Ivq0.js} +1 -1
  42. package/dist/assets/{chunk-I66GZJ75-DgS1iLCh.js → chunk-I66GZJ75-CMGc7-Zc.js} +1 -1
  43. package/dist/assets/{chunk-JQJVKLGR-Dj_lBDrM.js → chunk-JQJVKLGR-Dc7yuUDt.js} +1 -1
  44. package/dist/assets/{chunk-KBJHAD2P-C9ZtUfZ7.js → chunk-KBJHAD2P-BoBxF8ul.js} +1 -1
  45. package/dist/assets/{chunk-NSK5VX7P-DTj3_M9x.js → chunk-NSK5VX7P-CMtV1Mp-.js} +1 -1
  46. package/dist/assets/{chunk-QR6OTTB3-nxM4lbkc.js → chunk-QR6OTTB3-B2DD6U-r.js} +1 -1
  47. package/dist/assets/{chunk-UBXNYLIW-1z6PPm4m.js → chunk-UBXNYLIW-Dhp806SO.js} +1 -1
  48. package/dist/assets/{chunk-W5SLKNZC-BdIPkSxJ.js → chunk-W5SLKNZC-fnPAfJq6.js} +1 -1
  49. package/dist/assets/{chunk-WRU74C26-C11xtfY1.js → chunk-WRU74C26-Bp6ZUcJ1.js} +1 -1
  50. package/dist/assets/classDiagram-JCYQIIEL-C6KCD6kp.js +1 -0
  51. package/dist/assets/classDiagram-v2-OCEON4UE-C6KCD6kp.js +1 -0
  52. package/dist/assets/{cs-CZ-2BRQDIVT-Cf0JSv1l.js → cs-CZ-2BRQDIVT-DGKYTgTY.js} +1 -1
  53. package/dist/assets/{cynefinDiagram-MW4NZA55-CUlZVdz-.js → cynefinDiagram-MW4NZA55-D9UoNNC9.js} +1 -1
  54. package/dist/assets/{da-DK-5WZEPLOC-BbrWaLeZ.js → da-DK-5WZEPLOC-X-FrKQXQ.js} +1 -1
  55. package/dist/assets/{dagre-VZM6K2ZE-TrKRMuws.js → dagre-VZM6K2ZE-B-l1QcYp.js} +1 -1
  56. package/dist/assets/{de-DE-XR44H4JA-BaNWI6rg.js → de-DE-XR44H4JA-CI6BQ6DE.js} +1 -1
  57. package/dist/assets/{diagram-7IWD3JNH-nosUfBLS.js → diagram-7IWD3JNH-BHYUTn14.js} +1 -1
  58. package/dist/assets/{diagram-B4RE2ZJO-CoUma76L.js → diagram-B4RE2ZJO-DvPJwfZA.js} +1 -1
  59. package/dist/assets/{diagram-LBJQPF4R-BR0TJsBw.js → diagram-LBJQPF4R-Cv-_APit.js} +1 -1
  60. package/dist/assets/{diagram-Q27KOJAE-Bv8tZlly.js → diagram-Q27KOJAE-BuCrjc-_.js} +1 -1
  61. package/dist/assets/{diagram-UB23O5K3-DF6yN-sQ.js → diagram-UB23O5K3-e6qUwa3u.js} +1 -1
  62. package/dist/assets/{dist-BVFUbJwo.js → dist-ByUzt0RB.js} +4 -4
  63. package/dist/assets/{ebnfDiagram-BXEA7PRR-DLCkdtZQ.js → ebnfDiagram-BXEA7PRR-BauTjaFb.js} +1 -1
  64. package/dist/assets/{el-GR-BZB4AONW-CKDah1iQ.js → el-GR-BZB4AONW-BRVBlsL7.js} +1 -1
  65. package/dist/assets/{en-B4ZKOASM-CRlI2sV1.js → en-B4ZKOASM-DzHncHaW.js} +1 -1
  66. package/dist/assets/{erDiagram-JOGREHBK-CMtfcK5q.js → erDiagram-JOGREHBK-CiYhpgEt.js} +1 -1
  67. package/dist/assets/{erd-edge-style-DW4fkZXn.js → erd-edge-style-C9GMC7E4.js} +1 -1
  68. package/dist/assets/{es-ES-U4NZUMDT-CFCZ-FnH.js → es-ES-U4NZUMDT-BUOyiZTV.js} +1 -1
  69. package/dist/assets/{eu-ES-A7QVB2H4-BjCze1dY.js → eu-ES-A7QVB2H4-B-WVP4q-.js} +1 -1
  70. package/dist/assets/{fa-IR-HGAKTJCU-CZb6VAe6.js → fa-IR-HGAKTJCU-BGCBY5YG.js} +1 -1
  71. package/dist/assets/{fi-FI-Z5N7JZ37-BDr21Y96.js → fi-FI-Z5N7JZ37-BUyhWc77.js} +1 -1
  72. package/dist/assets/flowDiagram-UKHOOZJN-D7TtZSdO.js +1 -0
  73. package/dist/assets/{fr-FR-RHASNOE6-DCCz7Z05.js → fr-FR-RHASNOE6-hBQfFXE-.js} +1 -1
  74. package/dist/assets/{ganttDiagram-PKOTCBZU-Bbz1kR71.js → ganttDiagram-PKOTCBZU-DRPJxymK.js} +1 -1
  75. package/dist/assets/{gitGraphDiagram-DS77QQ5N-B-64qgV0.js → gitGraphDiagram-DS77QQ5N-B4-wdJrM.js} +1 -1
  76. package/dist/assets/{gl-ES-HMX3MZ6V-BMmYyzca.js → gl-ES-HMX3MZ6V-CzK7upSm.js} +1 -1
  77. package/dist/assets/{he-IL-6SHJWFNN-Bepm_gRG.js → he-IL-6SHJWFNN-ftl3-s7E.js} +1 -1
  78. package/dist/assets/{hi-IN-IWLTKZ5I-BZkslEow.js → hi-IN-IWLTKZ5I-B_LhBzPz.js} +1 -1
  79. package/dist/assets/{hu-HU-A5ZG7DT2-CKLr--cr.js → hu-HU-A5ZG7DT2-XRaANxlC.js} +1 -1
  80. package/dist/assets/{id-ID-SAP4L64H-Sh_bNfKW.js → id-ID-SAP4L64H-ITjoezEu.js} +1 -1
  81. package/dist/assets/image-GAAHSSAO-BSe7m8Aw.js +1 -0
  82. package/dist/assets/{index-4mHBF5P6.js → index-BL-qAtdL.js} +106 -106
  83. package/dist/assets/{infoDiagram-6WML65LV-DKx13_AF.js → infoDiagram-6WML65LV-DmA0XfF2.js} +1 -1
  84. package/dist/assets/{ishikawaDiagram-WSZJBQD7-BA3-ETOe.js → ishikawaDiagram-WSZJBQD7-BFnR83w3.js} +1 -1
  85. package/dist/assets/{it-IT-JPQ66NNP-C4Ms2Fbc.js → it-IT-JPQ66NNP-Bha0hfr0.js} +1 -1
  86. package/dist/assets/{ja-JP-DBVTYXUO-5957Bz5h.js → ja-JP-DBVTYXUO-D1r1WYQI.js} +1 -1
  87. package/dist/assets/{journeyDiagram-NVQOT4AX-KKhSjpVT.js → journeyDiagram-NVQOT4AX-BLIacaq2.js} +1 -1
  88. package/dist/assets/{kaa-6HZHGXH3-BbAtUvxp.js → kaa-6HZHGXH3-DVbE6J2H.js} +1 -1
  89. package/dist/assets/{kab-KAB-ZGHBKWFO-B2W_AB3R.js → kab-KAB-ZGHBKWFO-DC8uaOsr.js} +1 -1
  90. package/dist/assets/{kanban-definition-27J2QSJJ-Dw0GBEKX.js → kanban-definition-27J2QSJJ-UzJcjT86.js} +1 -1
  91. package/dist/assets/{kk-KZ-P5N5QNE5-D78yC8Ns.js → kk-KZ-P5N5QNE5-SQLJAp93.js} +1 -1
  92. package/dist/assets/{km-KH-HSX4SM5Z-Cg5ZK5wa.js → km-KH-HSX4SM5Z-CBNeUwih.js} +1 -1
  93. package/dist/assets/{ko-KR-MTYHY66A-BRuYBCDl.js → ko-KR-MTYHY66A-BwBzeI7C.js} +1 -1
  94. package/dist/assets/{ku-TR-6OUDTVRD-DrCOxkBN.js → ku-TR-6OUDTVRD-CnTXT8gT.js} +1 -1
  95. package/dist/assets/{line-WTIlrArX.js → line-BKfWClEJ.js} +1 -1
  96. package/dist/assets/{lt-LT-XHIRWOB4-DE2zYtEm.js → lt-LT-XHIRWOB4-H6LBXzmU.js} +1 -1
  97. package/dist/assets/{lv-LV-5QDEKY6T-D9Mcy5Br.js → lv-LV-5QDEKY6T-QFALLrYG.js} +1 -1
  98. package/dist/assets/{mindmap-definition-FAOFIHXS-RiPdrxzD.js → mindmap-definition-FAOFIHXS-DMSXreKO.js} +1 -1
  99. package/dist/assets/{mr-IN-CRQNXWMA-D9IcGRt6.js → mr-IN-CRQNXWMA-51_N75WW.js} +1 -1
  100. package/dist/assets/{my-MM-5M5IBNSE-BFohEl1B.js → my-MM-5M5IBNSE-ptNAALss.js} +1 -1
  101. package/dist/assets/{nb-NO-T6EIAALU-CEdxbjGO.js → nb-NO-T6EIAALU-NAg4Bvaq.js} +1 -1
  102. package/dist/assets/{nl-NL-IS3SIHDZ-DHFZONvE.js → nl-NL-IS3SIHDZ-B6zo7hju.js} +1 -1
  103. package/dist/assets/{nn-NO-6E72VCQL-CJ1CMG89.js → nn-NO-6E72VCQL-CyLigVsi.js} +1 -1
  104. package/dist/assets/{note-importer-DPPovz0N.js → note-importer-bjC4Q04B.js} +2 -2
  105. package/dist/assets/{oc-FR-POXYY2M6-Dw1Q-of7.js → oc-FR-POXYY2M6-CEeBBtoN.js} +1 -1
  106. package/dist/assets/{pa-IN-N4M65BXN-Bs36VjXu.js → pa-IN-N4M65BXN-C90gHKoI.js} +1 -1
  107. package/dist/assets/{pegDiagram-VL7TDLO6-CZczIV2H.js → pegDiagram-VL7TDLO6-DE5CRHBj.js} +1 -1
  108. package/dist/assets/percentages-BXMCSKIN-rKd92ad1.js +1 -0
  109. package/dist/assets/{pieDiagram-7S7Q4E2Y-D8aewLOo.js → pieDiagram-7S7Q4E2Y-DszGnNMP.js} +1 -1
  110. package/dist/assets/{pl-PL-T2D74RX3-1BtcZMG3.js → pl-PL-T2D74RX3-Ck10mRRH.js} +1 -1
  111. package/dist/assets/{pt-BR-5N22H2LF-galcsgOE.js → pt-BR-5N22H2LF-P-V4RL-o.js} +1 -1
  112. package/dist/assets/{pt-PT-UZXXM6DQ-BMfRky7j.js → pt-PT-UZXXM6DQ-CWbx9L13.js} +1 -1
  113. package/dist/assets/{quadrantDiagram-CIZ2JOQS-orSsCsve.js → quadrantDiagram-CIZ2JOQS-Dji9w-QQ.js} +1 -1
  114. package/dist/assets/{railroadDiagram-AXF67PYL-da9CNadl.js → railroadDiagram-AXF67PYL-HbiKJ2aZ.js} +1 -1
  115. package/dist/assets/{requirementDiagram-LRYGKXZP-DiG2wW3n.js → requirementDiagram-LRYGKXZP-CTKPInu5.js} +1 -1
  116. package/dist/assets/{ro-RO-JPDTUUEW-BtenMXpB.js → ro-RO-JPDTUUEW-C8jcBxQk.js} +1 -1
  117. package/dist/assets/{ru-RU-B4JR7IUQ-aIaBlmuG.js → ru-RU-B4JR7IUQ-DZ1D3aws.js} +1 -1
  118. package/dist/assets/{sankeyDiagram-W5VNT64P-B4P8JH3i.js → sankeyDiagram-W5VNT64P-DkDUhzzY.js} +1 -1
  119. package/dist/assets/{sequenceDiagram-SI44F4Z6-BV-05txq.js → sequenceDiagram-SI44F4Z6-CKmmyVWu.js} +1 -1
  120. package/dist/assets/{si-LK-N5RQ5JYF-lYzrJsqY.js → si-LK-N5RQ5JYF-PY4yvqDn.js} +1 -1
  121. package/dist/assets/{sk-SK-C5VTKIMK-Cbgjvckf.js → sk-SK-C5VTKIMK-DJUjpbri.js} +1 -1
  122. package/dist/assets/{sl-SI-NN7IZMDC-B0WccxV9.js → sl-SI-NN7IZMDC-BWZ9TNrO.js} +1 -1
  123. package/dist/assets/{stateDiagram-OKZ733FA-z_Ha4MgW.js → stateDiagram-OKZ733FA-CrT0fjkV.js} +1 -1
  124. package/dist/assets/stateDiagram-v2-UEYNNEHI-Df8No743.js +1 -0
  125. package/dist/assets/subset-shared.chunk-BwV95s5-.js +1 -0
  126. package/dist/assets/{subset-worker.chunk-CSpj-xWN.js → subset-worker.chunk-DaNCfK00.js} +1 -1
  127. package/dist/assets/{sv-SE-XGPEYMSR-C-zqHnxe.js → sv-SE-XGPEYMSR-DaDFuftb.js} +1 -1
  128. package/dist/assets/{swimlanes-SLNWSIFB-C5Z1nxou.js → swimlanes-SLNWSIFB-BO6dmcHX.js} +1 -1
  129. package/dist/assets/swimlanesDiagram-ULZ7WXOC-EigVg1lP.js +8 -0
  130. package/dist/assets/{ta-IN-2NMHFXQM-w7vaNtz8.js → ta-IN-2NMHFXQM-CA2dYinH.js} +1 -1
  131. package/dist/assets/{th-TH-HPSO5L25-DqJ_fkBO.js → th-TH-HPSO5L25-hhJD2Pub.js} +1 -1
  132. package/dist/assets/{timeline-definition-Z64GVDOM-D-koOyAU.js → timeline-definition-Z64GVDOM-CSvuk3yK.js} +1 -1
  133. package/dist/assets/{tr-TR-DEFEU3FU-DMZttEaf.js → tr-TR-DEFEU3FU-DHdEpd3v.js} +1 -1
  134. package/dist/assets/{uk-UA-QMV73CPH-C6yVcx0t.js → uk-UA-QMV73CPH-BHW38nPA.js} +1 -1
  135. package/dist/assets/{vennDiagram-T6HMQDX7-D2BC-sjS.js → vennDiagram-T6HMQDX7-DIcaYevA.js} +1 -1
  136. package/dist/assets/{vi-VN-M7AON7JQ-ri9u0eZP.js → vi-VN-M7AON7JQ-CAlYE4HQ.js} +1 -1
  137. package/dist/assets/{wardleyDiagram-T6FBY63Y-BN_VcvWb.js → wardleyDiagram-T6FBY63Y-CRVxHLHh.js} +1 -1
  138. package/dist/assets/{xychartDiagram-ELKLHX3M-CfVIqSsC.js → xychartDiagram-ELKLHX3M-Bfv5bB1g.js} +1 -1
  139. package/dist/assets/{zh-CN-LNUGB5OW-Dox46P5a.js → zh-CN-LNUGB5OW-BUNG1Boc.js} +1 -1
  140. package/dist/assets/{zh-HK-E62DVLB3-B9vVqewM.js → zh-HK-E62DVLB3-BvuGGstT.js} +1 -1
  141. package/dist/assets/{zh-TW-RAJ6MFWO-DxMuO24m.js → zh-TW-RAJ6MFWO-Q6cMOn14.js} +1 -1
  142. package/dist/index.html +3 -3
  143. package/dist-server/index.js +1 -1
  144. package/package.json +1 -1
  145. package/dist/assets/WorkspaceProvider-Te7g31uC.js +0 -71
  146. package/dist/assets/channel-DiL-wrEh.js +0 -1
  147. package/dist/assets/classDiagram-JCYQIIEL-CQosJJk6.js +0 -1
  148. package/dist/assets/classDiagram-v2-OCEON4UE-CQosJJk6.js +0 -1
  149. package/dist/assets/flowDiagram-UKHOOZJN-Cy_QjLjI.js +0 -1
  150. package/dist/assets/image-GAAHSSAO-DO2uNcbX.js +0 -1
  151. package/dist/assets/percentages-BXMCSKIN-CdaZW95S.js +0 -1
  152. package/dist/assets/stateDiagram-v2-UEYNNEHI-31wIVrUh.js +0 -1
  153. package/dist/assets/subset-shared.chunk-C5yulNxZ.js +0 -1
  154. package/dist/assets/swimlanesDiagram-ULZ7WXOC-Dn10gJds.js +0 -8
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{t as r}from"./check-Uq0GkTkz.js";import{n as i}from"./api-BAQH6VUv.js";import{Kt as a}from"./index-4mHBF5P6.js";var o=e(t(),1),s=n(),c=(0,o.createContext)(null),l=e=>`${e.type}:${e.id}`;function u({config:e,children:t}){let[n,r]=(0,o.useState)(new Map),a=(0,o.useRef)(0),u=`/api/projects/`+encodeURIComponent(e.projectId)+`/comments`,d=`feature_type=`+e.featureType+`&file_id=`+encodeURIComponent(e.fileId),f=(0,o.useCallback)(async()=>{let e=++a.current;try{let t=await i(u+`/markers?`+d),n=await t.json().catch(()=>({}));if(!t.ok)throw Error(n.error||`Could not load comment markers.`);let o=new Map;for(let e of n.markers||[]){let t={anchorType:e.anchorType??e.anchor_type,anchorId:String(e.anchorId??e.anchor_id),status:e.status===`resolved`?`resolved`:`open`,unreadCount:Number(e.unreadCount??e.unread_count??0)};o.set(l({type:t.anchorType,id:t.anchorId}),t)}e===a.current&&r(o)}catch{}},[u,d]);(0,o.useEffect)(()=>{r(new Map),f();let t=t=>{t.teamId&&t.teamId!==e.teamId||t.projectId&&String(t.projectId)!==e.projectId||f()},n=e=>t(e.detail||{}),i=e=>{let n=e.detail;n?.eventType===`cloud.workspace.sync`&&t(n)},o=e=>t(e.detail||{}),s=window.setInterval(()=>{document.visibilityState===`visible`&&f()},15e3);return window.addEventListener(`collaboration-updated`,n),window.addEventListener(`cloud-workspace-sync`,i),window.addEventListener(`cloud-live-sync-reconnected`,o),()=>{a.current++,window.clearInterval(s),window.removeEventListener(`collaboration-updated`,n),window.removeEventListener(`cloud-workspace-sync`,i),window.removeEventListener(`cloud-live-sync-reconnected`,o)}},[e,f]);let p=(0,o.useMemo)(()=>({config:e,markers:n}),[e,n]);return(0,s.jsx)(c.Provider,{value:p,children:t})}function d(){return(0,o.useContext)(c)}function f({anchor:e}){let t=d(),n=t?.markers.get(l(e));if(!t||!n)return null;let i=e.type===`shape`?`Flowchart shape`:`Drawing element`,o=n.status===`resolved`?`, resolved`:n.unreadCount?`, `+n.unreadCount+` unread`:``,c=n.status===`resolved`?`bg-foreground text-background`:`bg-sky-500 text-white dark:bg-sky-400 dark:text-slate-950`;return(0,s.jsx)(`button`,{type:`button`,className:`flex size-11 shrink-0 items-center justify-center rounded-full border-0 bg-transparent p-0 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-sky-500`,"aria-label":i+` comments`+o,title:i+` comments`+o,onPointerDown:e=>e.stopPropagation(),onClick:n=>{n.stopPropagation(),window.dispatchEvent(new CustomEvent(`project-comment-open-request`,{detail:{featureType:t.config.featureType,fileId:t.config.fileId,type:e.type,id:e.id}}))},children:(0,s.jsx)(`span`,{className:`flex size-5 items-center justify-center rounded-full px-1 text-[9px] font-bold leading-none shadow-sm `+c,children:n.status===`resolved`?(0,s.jsx)(r,{"aria-hidden":`true`,className:`size-2.5 stroke-[3]`}):n.unreadCount>0?n.unreadCount>3?`3+`:n.unreadCount:(0,s.jsx)(a,{"aria-hidden":`true`,className:`size-3`})})})}export{u as n,d as r,f as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{t as r}from"./check-Uq0GkTkz.js";import{n as i}from"./api-BAQH6VUv.js";import{Kt as a}from"./index-BL-qAtdL.js";var o=e(t(),1),s=n(),c=(0,o.createContext)(null),l=e=>`${e.type}:${e.id}`;function u({config:e,children:t}){let[n,r]=(0,o.useState)(new Map),a=(0,o.useRef)(0),u=`/api/projects/`+encodeURIComponent(e.projectId)+`/comments`,d=`feature_type=`+e.featureType+`&file_id=`+encodeURIComponent(e.fileId),f=(0,o.useCallback)(async()=>{let e=++a.current;try{let t=await i(u+`/markers?`+d),n=await t.json().catch(()=>({}));if(!t.ok)throw Error(n.error||`Could not load comment markers.`);let o=new Map;for(let e of n.markers||[]){let t={anchorType:e.anchorType??e.anchor_type,anchorId:String(e.anchorId??e.anchor_id),status:e.status===`resolved`?`resolved`:`open`,unreadCount:Number(e.unreadCount??e.unread_count??0)};o.set(l({type:t.anchorType,id:t.anchorId}),t)}e===a.current&&r(o)}catch{}},[u,d]);(0,o.useEffect)(()=>{r(new Map),f();let t=t=>{t.teamId&&t.teamId!==e.teamId||t.projectId&&String(t.projectId)!==e.projectId||f()},n=e=>t(e.detail||{}),i=e=>{let n=e.detail;n?.eventType===`cloud.workspace.sync`&&t(n)},o=e=>t(e.detail||{}),s=window.setInterval(()=>{document.visibilityState===`visible`&&f()},15e3);return window.addEventListener(`collaboration-updated`,n),window.addEventListener(`cloud-workspace-sync`,i),window.addEventListener(`cloud-live-sync-reconnected`,o),()=>{a.current++,window.clearInterval(s),window.removeEventListener(`collaboration-updated`,n),window.removeEventListener(`cloud-workspace-sync`,i),window.removeEventListener(`cloud-live-sync-reconnected`,o)}},[e,f]);let p=(0,o.useMemo)(()=>({config:e,markers:n}),[e,n]);return(0,s.jsx)(c.Provider,{value:p,children:t})}function d(){return(0,o.useContext)(c)}function f({anchor:e}){let t=d(),n=t?.markers.get(l(e));if(!t||!n)return null;let i=e.type===`shape`?`Flowchart shape`:`Drawing element`,o=n.status===`resolved`?`, resolved`:n.unreadCount?`, `+n.unreadCount+` unread`:``,c=n.status===`resolved`?`bg-foreground text-background`:`bg-sky-500 text-white dark:bg-sky-400 dark:text-slate-950`;return(0,s.jsx)(`button`,{type:`button`,className:`flex size-11 shrink-0 items-center justify-center rounded-full border-0 bg-transparent p-0 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-sky-500`,"aria-label":i+` comments`+o,title:i+` comments`+o,onPointerDown:e=>e.stopPropagation(),onClick:n=>{n.stopPropagation(),window.dispatchEvent(new CustomEvent(`project-comment-open-request`,{detail:{featureType:t.config.featureType,fileId:t.config.fileId,type:e.type,id:e.id}}))},children:(0,s.jsx)(`span`,{className:`flex size-5 items-center justify-center rounded-full px-1 text-[9px] font-bold leading-none shadow-sm `+c,children:n.status===`resolved`?(0,s.jsx)(r,{"aria-hidden":`true`,className:`size-2.5 stroke-[3]`}):n.unreadCount>0?n.unreadCount>3?`3+`:n.unreadCount:(0,s.jsx)(a,{"aria-hidden":`true`,className:`size-3`})})})}export{u as n,d as r,f as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{l as r,u as i}from"./chunk-BV7QT456-CCzugQp2.js";import"./WorkspaceProvider-Te7g31uC.js";import{n as a}from"./WorkspaceContext-O7njKDwj.js";import{gn as o}from"./index-4mHBF5P6.js";import{n as s}from"./ERDComments-C8HbR05_.js";import{FlowchartView as c}from"./FlowchartView-esgoLO4T.js";import{t as l}from"./ProjectFileTabs-7LRUbYsP.js";var u=e(t(),1),d=n();function f(){let e=a(),t=r(),{id:n}=i(),{activeFlowchart:f,activeFlowchartId:p,handleFlowchartChange:m,isPublicView:h,isLoading:g,isFlowchartItemLoading:_,handleFlowchartSelect:v,saveFlowchart:y,triggerDebouncedSync:b}=e,x=f?.project_id??f?.projectId,S=f?.uid??p,C=e.projects.find(e=>String(e.id)===String(x)),w=C?.team_id??C?.teamId,T=!!(!h&&!e.isGuest&&e.getFileAccessRole(f)!==`viewer`&&w&&t.activeTeamId&&String(w)===String(t.activeTeamId)),E=(0,u.useMemo)(()=>T&&x!=null&&w&&e.user?.id&&S!=null?{projectId:String(x),teamId:String(w),fileId:String(S),userId:String(e.user.id),featureType:`flowchart`}:null,[T,e.user?.id,S,x,w]),D=(0,u.useRef)(!1);if((0,u.useEffect)(()=>{if(!(h||!n)&&!D.current){if(String(p)===n){D.current=!0;return}p||(D.current=!0,v(n))}},[n,p,h,v]),!h&&!p)return n&&!D.current?(0,d.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:[(0,d.jsx)(`div`,{className:`w-6 h-6 border-2 border-primary/30 border-t-primary rounded-full animate-spin`}),(0,d.jsx)(`p`,{className:`mt-4 text-sm font-medium text-muted-foreground animate-pulse`,children:`Loading flowchart...`})]}):(0,d.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:(0,d.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:`Select a flowchart to view`})});if(!f&&!_)return(0,d.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:[(0,d.jsx)(o,{className:`w-12 h-12 text-muted-foreground/40 mb-4`}),(0,d.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:`Flowchart not found`}),(0,d.jsx)(`p`,{className:`text-xs text-muted-foreground/60 mt-1`,children:`This flowchart may have been deleted or is no longer available.`})]});if(!f)return(0,d.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:[(0,d.jsx)(`div`,{className:`w-6 h-6 border-2 border-primary/30 border-t-primary rounded-full animate-spin`}),(0,d.jsx)(`p`,{className:`mt-4 text-sm font-medium text-muted-foreground animate-pulse`,children:`Loading flowchart...`})]});let O=(0,d.jsx)(c,{isLoading:_,activeFlowchartId:p,activeFlowchart:f,handleFlowchartChange:m,isReadOnly:h||e.isReadOnlyFile(f),commentsEnabled:T,saveFlowchart:y,triggerDebouncedSync:b});return(0,d.jsxs)(`div`,{className:`flex flex-col flex-1 overflow-hidden`,children:[(0,d.jsx)(l,{currentView:`flowchart`}),E?(0,d.jsx)(s,{config:E,children:O},[E.projectId,E.teamId,E.featureType,E.fileId].join(`:`)):O]})}export{f as FlowchartEditorRoute};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{l as r,u as i}from"./chunk-BV7QT456-CCzugQp2.js";import"./WorkspaceProvider-Dc-LU3z8.js";import{n as a}from"./WorkspaceContext-O7njKDwj.js";import{gn as o}from"./index-BL-qAtdL.js";import{n as s}from"./ERDComments-Xwt7V4OK.js";import{FlowchartView as c}from"./FlowchartView-DHnUjqeM.js";import{t as l}from"./ProjectFileTabs-Brr9j8Tz.js";var u=e(t(),1),d=n();function f(){let e=a(),t=r(),{id:n}=i(),{activeFlowchart:f,activeFlowchartId:p,handleFlowchartChange:m,isPublicView:h,isLoading:g,isFlowchartItemLoading:_,handleFlowchartSelect:v,saveFlowchart:y,triggerDebouncedSync:b}=e,x=f?.project_id??f?.projectId,S=f?.uid??p,C=e.projects.find(e=>String(e.id)===String(x)),w=C?.team_id??C?.teamId,T=!!(!h&&!e.isGuest&&e.getFileAccessRole(f)!==`viewer`&&w&&t.activeTeamId&&String(w)===String(t.activeTeamId)),E=(0,u.useMemo)(()=>T&&x!=null&&w&&e.user?.id&&S!=null?{projectId:String(x),teamId:String(w),fileId:String(S),userId:String(e.user.id),featureType:`flowchart`}:null,[T,e.user?.id,S,x,w]),D=(0,u.useRef)(!1);if((0,u.useEffect)(()=>{if(!(h||!n)&&!D.current){if(String(p)===n){D.current=!0;return}p||(D.current=!0,v(n))}},[n,p,h,v]),!h&&!p)return n&&!D.current?(0,d.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:[(0,d.jsx)(`div`,{className:`w-6 h-6 border-2 border-primary/30 border-t-primary rounded-full animate-spin`}),(0,d.jsx)(`p`,{className:`mt-4 text-sm font-medium text-muted-foreground animate-pulse`,children:`Loading flowchart...`})]}):(0,d.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:(0,d.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:`Select a flowchart to view`})});if(!f&&!_)return(0,d.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:[(0,d.jsx)(o,{className:`w-12 h-12 text-muted-foreground/40 mb-4`}),(0,d.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:`Flowchart not found`}),(0,d.jsx)(`p`,{className:`text-xs text-muted-foreground/60 mt-1`,children:`This flowchart may have been deleted or is no longer available.`})]});if(!f)return(0,d.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:[(0,d.jsx)(`div`,{className:`w-6 h-6 border-2 border-primary/30 border-t-primary rounded-full animate-spin`}),(0,d.jsx)(`p`,{className:`mt-4 text-sm font-medium text-muted-foreground animate-pulse`,children:`Loading flowchart...`})]});let O=(0,d.jsx)(c,{isLoading:_,activeFlowchartId:p,activeFlowchart:f,handleFlowchartChange:m,isReadOnly:h||e.isReadOnlyFile(f),commentsEnabled:T,saveFlowchart:y,triggerDebouncedSync:b});return(0,d.jsxs)(`div`,{className:`flex flex-col flex-1 overflow-hidden`,children:[(0,d.jsx)(l,{currentView:`flowchart`}),E?(0,d.jsx)(s,{config:E,children:O},[E.projectId,E.teamId,E.featureType,E.fileId].join(`:`)):O]})}export{f as FlowchartEditorRoute};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{n as r}from"./dist-D0tkMM_Y.js";import{a as i,b as a,c as o,d as s,h as c,i as l,l as u,m as d,n as f,o as p,p as m,r as h,s as ee,t as te,u as ne,x as g,y as _}from"./downloadSVG-C2LckkLx.js";import{a as v,h as re,r as ie}from"./esm-B1WURL1q.js";import{t as y}from"./button-D2dALS3q.js";import{i as b,n as x,o as S,s as C,t as w}from"./select-xSghKb2x.js";import{I as T,b as ae,o as oe}from"./CommentThreadView-Dx7ndjrK.js";import{t as se}from"./check-Uq0GkTkz.js";import{n as E,t as ce}from"./move-BzTcfKj2.js";import{A as D,C as le,M as ue,T as O,j as de,w as k}from"./hover-card-CqLOdc_X.js";import{t as fe}from"./plus-DfXp3YpY.js";import{a as A,c as pe,d as me,i as j,l as M,n as N,o as P,s as F,t as I}from"./dialog-EJdgZKa4.js";import{t as L}from"./trash-2-BmZK7fDJ.js";import{t as he}from"./undo-2-FZYgYKq2.js";import{t as ge}from"./card-DFJ6ytRY.js";import{t as R}from"./input-BUIkeoB3.js";import{n as _e}from"./WorkspaceContext-O7njKDwj.js";import{t as z}from"./label-CCjvjYto.js";import{A as ve,D as ye,Kt as be,O as xe,en as Se,gn as Ce,j as we,k as Te}from"./index-4mHBF5P6.js";import{i as Ee,r as De,t as Oe}from"./ERDComments-C8HbR05_.js";import{t as ke}from"./JumpToNode-Cu3WQt8p.js";var B=e(t(),1),V=n(),H=(0,B.memo)(({data:e,id:t,selected:n})=>{let[r,i]=(0,B.useState)(!1),a=`!w-1.5 !h-1.5 !bg-white !border-none opacity-0 group-hover:opacity-100 transition-opacity z-20 cursor-crosshair`,o=(0,B.useMemo)(()=>{switch(e.shape){case`diamond`:return`min-w-[130px] min-h-[130px] p-8`;case`circle`:return`min-w-[110px] min-h-[110px] p-4`;case`cloud`:return`min-w-[160px] max-w-[240px] min-h-[90px] px-10 py-6`;case`database`:return`min-w-[140px] max-w-[220px] min-h-[100px] px-6 pt-10 pb-6`;case`parallelogram`:return`min-w-[160px] max-w-[240px] min-h-[80px] px-12 py-4`;case`oval`:return`min-w-[140px] max-w-[240px] min-h-[80px] px-10 py-4`;case`document`:return`min-w-[140px] max-w-[220px] min-h-[90px] px-8 pt-4 pb-10`;default:return`min-w-[140px] max-w-[240px] min-h-[80px] px-8 py-4`}},[e.shape]),s=(0,B.useMemo)(()=>{switch(e.shape){case`diamond`:return{width:100,height:100};case`circle`:return{width:80,height:80};default:return{width:100,height:60}}},[e.shape]),c=(0,B.useMemo)(()=>{let t={background:`linear-gradient(135deg, ${e.color}40 0%, ${e.color}10 100%)`,borderColor:e.color,borderWidth:`2px`,borderStyle:`solid`,boxShadow:`none`,transition:`all 0.3s cubic-bezier(0.4, 0, 0.2, 1)`},n=`${e.color}20`,r=e.color,i={filter:`none`,transition:`all 0.3s`};switch(e.shape){case`diamond`:return(0,V.jsx)(`svg`,{className:`absolute inset-0 w-full h-full pointer-events-none overflow-visible`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,children:(0,V.jsx)(`path`,{d:`M50,2 L98,50 L50,98 L2,50 Z`,fill:n,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinejoin:`round`,style:i})});case`parallelogram`:return(0,V.jsx)(`svg`,{className:`absolute inset-0 w-full h-full pointer-events-none overflow-visible`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,children:(0,V.jsx)(`path`,{d:`M20,2 L98,2 L80,98 L2,98 Z`,fill:n,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinejoin:`round`,style:i})});case`oval`:return(0,V.jsx)(`div`,{className:`absolute inset-0 rounded-[50px] pointer-events-none`,style:t});case`circle`:return(0,V.jsx)(`div`,{className:`absolute inset-0 rounded-full pointer-events-none flex items-center justify-center`,style:{...t,background:`radial-gradient(circle at 30% 30%, ${e.color}40 0%, ${e.color}10 100%)`}});case`database`:return(0,V.jsxs)(`svg`,{className:`absolute inset-0 w-full h-full pointer-events-none overflow-visible`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,children:[(0,V.jsx)(`path`,{d:`M2,15 L2,85 C2,95 98,95 98,85 L98,15`,fill:n,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinejoin:`round`,style:i}),(0,V.jsx)(`path`,{d:`M2,15 C2,5 98,5 98,15 C98,25 2,25 2,15 Z`,fill:`${e.color}35`,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`}),(0,V.jsx)(`path`,{d:`M2,50 C2,60 98,60 98,50`,fill:`none`,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,opacity:`0.3`})]});case`document`:return(0,V.jsxs)(`svg`,{className:`absolute inset-0 w-full h-full pointer-events-none overflow-visible`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,children:[(0,V.jsx)(`path`,{d:`M2,2 L70,2 L98,30 L98,85 C98,93 90,98 85,98 L15,98 C7,98 2,93 2,85 Z`,fill:n,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinejoin:`round`,style:i}),(0,V.jsx)(`path`,{d:`M70,2 V30 H98`,fill:`none`,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinejoin:`round`})]});case`cloud`:return(0,V.jsx)(`svg`,{className:`absolute inset-0 w-full h-full pointer-events-none overflow-visible`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,children:(0,V.jsx)(`path`,{d:`M20,80 C5,80 5,60 15,50 C10,20 40,15 55,25 C65,5 95,10 95,40 C105,50 105,80 80,80 Z`,fill:n,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinecap:`round`,strokeLinejoin:`round`,style:i})});default:return(0,V.jsx)(`div`,{className:`absolute inset-0 rounded-md pointer-events-none`,style:t})}},[e.color,e.shape,n]),l=(0,V.jsxs)(`div`,{className:`relative group flex items-center justify-center cursor-pointer transition-all duration-300 hover:scale-[1.02] ${o}`,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{aspectRatio:e.shape===`circle`?`1 / 1`:`auto`},children:[(0,V.jsx)(d,{isVisible:!e._readOnly&&(n||r),keepAspectRatio:e.shape===`circle`,minWidth:s.width,minHeight:s.height,handleStyle:{width:8,height:8,borderRadius:0,backgroundColor:`#0f0f14`,border:`1.5px solid ${e.color}`,zIndex:50},lineStyle:{border:`1px dashed ${e.color}80`}}),c,e._commentsEnabled&&(0,V.jsx)(`div`,{className:`absolute -right-2 -top-2 z-60`,children:(0,V.jsx)(Oe,{anchor:{type:`shape`,id:t}})}),(0,V.jsx)(m,{id:`top`,type:`target`,position:v.Top,className:a}),(0,V.jsx)(m,{id:`top`,type:`source`,position:v.Top,className:a}),(0,V.jsx)(m,{id:`bottom`,type:`target`,position:v.Bottom,className:a}),(0,V.jsx)(m,{id:`bottom`,type:`source`,position:v.Bottom,className:a}),(0,V.jsx)(m,{id:`right`,type:`target`,position:v.Right,className:a}),(0,V.jsx)(m,{id:`right`,type:`source`,position:v.Right,className:a}),(0,V.jsx)(m,{id:`left`,type:`target`,position:v.Left,className:a}),(0,V.jsx)(m,{id:`left`,type:`source`,position:v.Left,className:a}),(0,V.jsx)(`div`,{className:`relative z-10 text-center text-sm font-semibold text-foreground wrap-break-word whitespace-pre-wrap max-w-full flex-1`,children:e.label}),e.section&&(0,V.jsx)(`div`,{className:`absolute -top-7 left-1/2 -translate-x-1/2 z-20 whitespace-nowrap text-[9px] font-medium text-muted-foreground/60 tracking-wider uppercase px-2 py-0.5 rounded-full bg-background/50 backdrop-blur-sm border border-border/30`,children:e.section})]});return e._commentsEnabled?(0,V.jsxs)(le,{children:[(0,V.jsx)(D,{className:`contents`,children:l}),(0,V.jsx)(k,{className:`min-w-36`,positionerClassName:`z-[210]`,children:(0,V.jsxs)(O,{onClick:e=>{e.preventDefault(),e.stopPropagation(),window.dispatchEvent(new CustomEvent(De,{detail:{type:`shape`,id:t}}))},children:[(0,V.jsx)(be,{"aria-hidden":`true`}),`Comment`]})})]}):l}),U=e=>e.trim().toLowerCase().includes(`start`);function Ae({isOpen:e,onOpenChange:t,nodeData:n,onNodeDataChange:r,onConfirm:i}){let a=U(n.label);return(0,V.jsx)(I,{open:e,onOpenChange:t,children:(0,V.jsxs)(j,{className:`sm:max-w-sm`,children:[(0,V.jsxs)(F,{children:[(0,V.jsx)(M,{children:`Create New Symbol`}),(0,V.jsx)(A,{children:`Configure the symbol before placing it on the canvas.`})]}),(0,V.jsxs)(N,{className:`space-y-6`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{children:`Label`}),(0,V.jsx)(R,{value:n.label,onChange:e=>r({...n,label:e.target.value}),placeholder:`Enter symbol label`,className:`bg-muted border-border text-foreground`})]}),a&&(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{children:`Group Title`}),(0,V.jsx)(R,{value:n.section||``,onChange:e=>r({...n,section:e.target.value||void 0}),placeholder:`e.g. Pengajuan Cuti`,className:`bg-muted border-border text-foreground`}),(0,V.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50`,children:`Nama grup untuk alur yang dimulai dari sini.`})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{children:`Shape Type`}),(0,V.jsxs)(w,{value:n.shape,onValueChange:e=>r({...n,shape:e||n.shape}),children:[(0,V.jsx)(S,{className:`w-full bg-muted border-border text-foreground`,children:(0,V.jsx)(C,{placeholder:`Select a shape`,children:n.shape?p[n.shape]:`Select a shape`})}),(0,V.jsxs)(x,{className:`bg-popover border-border text-popover-foreground`,children:[(0,V.jsx)(b,{value:`rectangle`,children:`Rectangle (Process)`}),(0,V.jsx)(b,{value:`oval`,children:`Oval (Start/End)`}),(0,V.jsx)(b,{value:`diamond`,children:`Diamond (Decision)`}),(0,V.jsx)(b,{value:`parallelogram`,children:`Parallelogram (Input/Output)`}),(0,V.jsx)(b,{value:`database`,children:`Cylinder (Database)`}),(0,V.jsx)(b,{value:`document`,children:`Document`}),(0,V.jsx)(b,{value:`cloud`,children:`Cloud (External System)`}),(0,V.jsx)(b,{value:`circle`,children:`Circle (Connector)`})]})]})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{children:`Color`}),(0,V.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:l.map(e=>(0,V.jsx)(`button`,{className:`w-8 h-8 rounded-full border-2 transition-transform hover:scale-110 ${n.color===e?`border-white scale-110`:`border-transparent`}`,style:{backgroundColor:e},onClick:()=>r({...n,color:e})},e))})]})]}),(0,V.jsxs)(P,{children:[(0,V.jsx)(y,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,V.jsx)(y,{onClick:i,className:`bg-primary text-primary-foreground`,children:`Add to Flowchart`})]})]})})}function je(e){return e.data.label.trim().toLowerCase().includes(`start`)}function Me({selectedNodeId:e,onClose:t,selectedNode:n,onUpdateNodeData:r,onDeleteNode:i,onDeleteGroup:a,onValidateSection:o}){let s=n?je(n):!1,[c,u]=(0,B.useState)(()=>n?n.data.code?n.data.code:n.data.shape===`diamond`?`return context.amount > 100 ? 'Yes' : 'No';`:`context.status = 'Approved';`:``),d=e=>{u(e),r({code:e})};return(0,V.jsx)(I,{open:!!e,onOpenChange:e=>{e||t()},children:(0,V.jsxs)(j,{className:`sm:max-w-sm`,children:[(0,V.jsxs)(F,{children:[(0,V.jsx)(M,{children:`Symbol Properties`}),(0,V.jsx)(A,{children:`Customize the name, shape, and color of this symbol.`})]}),n&&(0,V.jsxs)(N,{className:`space-y-6`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{children:`Label`}),(0,V.jsx)(R,{value:n.data.label,onChange:e=>r({label:e.target.value}),placeholder:`Enter symbol label`,className:`bg-muted/50 border-border text-foreground`})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{className:`text-xs font-bold text-zinc-300`,children:`Code Logic (JavaScript)`}),(0,V.jsx)(`textarea`,{value:c,onChange:e=>d(e.target.value),placeholder:n.data.shape===`diamond`?`e.g. return context.amount > 100 ? 'Yes' : 'No';`:`e.g. context.status = 'Approved'; context.tries += 1;`,className:`w-full h-24 bg-muted border border-border rounded-md p-2 text-xs font-mono text-foreground placeholder:text-muted-foreground/50 resize-none focus:outline-none focus:border-ring`}),(0,V.jsxs)(`p`,{className:`text-[9px] text-muted-foreground/50 leading-normal`,children:[`Attached sandbox logic. For Decision diamonds, return the matching branch label (case-sensitive). Process symbols can mutate variables in the `,(0,V.jsx)(`code`,{children:`context`}),` object.`]})]}),s&&(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{children:`Group Title`}),(0,V.jsx)(R,{value:n.data.section||``,onChange:e=>r({section:e.target.value||void 0}),onBlur:e=>{let t=e.target.value;t&&o&&!o(t)&&r({section:void 0})},placeholder:`e.g. Pengajuan Cuti`,className:`bg-muted/50 border-border text-foreground`}),(0,V.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50`,children:`Nama grup untuk alur yang dimulai dari sini.`})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{children:`Shape Type`}),(0,V.jsxs)(w,{value:n.data.shape,onValueChange:e=>e&&r({shape:e}),children:[(0,V.jsx)(S,{className:`w-full bg-muted border-border text-foreground`,children:(0,V.jsx)(C,{placeholder:`Select a shape`,children:n.data.shape?p[n.data.shape]:`Select a shape`})}),(0,V.jsxs)(x,{className:`bg-popover border-border text-popover-foreground`,children:[(0,V.jsx)(b,{value:`rectangle`,children:`Rectangle (Process)`}),(0,V.jsx)(b,{value:`oval`,children:`Oval (Start/End)`}),(0,V.jsx)(b,{value:`diamond`,children:`Diamond (Decision)`}),(0,V.jsx)(b,{value:`parallelogram`,children:`Parallelogram (Input/Output)`}),(0,V.jsx)(b,{value:`database`,children:`Cylinder (Database)`}),(0,V.jsx)(b,{value:`document`,children:`Document`}),(0,V.jsx)(b,{value:`cloud`,children:`Cloud (External System)`}),(0,V.jsx)(b,{value:`circle`,children:`Circle (Connector)`})]})]})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{children:`Color`}),(0,V.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:l.map(e=>(0,V.jsx)(`button`,{className:`w-8 h-8 rounded-full border-2 transition-transform hover:scale-110 ${n.data.color===e?`border-white scale-110`:`border-transparent`}`,style:{backgroundColor:e},onClick:()=>r({color:e})},e))})]}),(0,V.jsxs)(`div`,{className:`pt-2 border-t border-border space-y-2`,children:[(0,V.jsxs)(y,{variant:`destructive`,size:`sm`,className:`w-full gap-2`,onClick:()=>{i(),t()},children:[(0,V.jsx)(L,{className:`size-4`}),`Delete Symbol`]}),s&&n.data.section&&a&&(0,V.jsxs)(y,{variant:`outline`,size:`sm`,className:`w-full gap-2 text-destructive border-destructive/30 hover:bg-destructive/10`,onClick:()=>{a(),t()},children:[(0,V.jsx)(L,{className:`size-4`}),`Delete Group "`,n.data.section,`"`]})]})]},e)]})})}function Ne({selectedEdgeId:e,onClose:t,selectedEdge:n,isDashed:r,arrowType:a,onEdgeTypeChange:o,onArrowChange:s,onLabelChange:c,onDeleteEdge:l}){return(0,V.jsx)(I,{open:!!e,onOpenChange:e=>{e||t()},children:(0,V.jsxs)(j,{className:`sm:max-w-sm`,children:[(0,V.jsx)(F,{children:(0,V.jsxs)(`div`,{className:`flex items-center justify-between pr-8`,children:[(0,V.jsxs)(`div`,{className:`space-y-1 text-left`,children:[(0,V.jsx)(M,{children:`Connector Properties`}),(0,V.jsx)(A,{children:`Format the line style and arrows.`})]}),(0,V.jsx)(y,{variant:`ghost`,size:`icon`,onClick:l,className:`text-destructive hover:bg-destructive/10 -mr-2 shadow-none`,title:`Delete Connector`,children:(0,V.jsx)(L,{className:`w-4 h-4`})})]})}),n&&(0,V.jsxs)(N,{className:`space-y-6`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{children:`Text Label`}),(0,V.jsx)(R,{value:typeof n.label==`string`?n.label:``,onChange:e=>c(e.target.value),placeholder:`e.g. Yes, No, 1, 2...`,className:`bg-muted border-border text-foreground`})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{children:`Line Style`}),(0,V.jsxs)(w,{value:r?`dashed`:`solid`,onValueChange:e=>o(e||``),children:[(0,V.jsx)(S,{className:`w-full bg-muted border-border text-foreground`,children:(0,V.jsx)(C,{placeholder:`Select line style`,children:i[r?`dashed`:`solid`]})}),(0,V.jsxs)(x,{className:`bg-popover border-border text-popover-foreground`,children:[(0,V.jsx)(b,{value:`solid`,children:`Solid Line`}),(0,V.jsx)(b,{value:`dashed`,children:`Dashed Line`})]})]})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{children:`Arrow Style`}),(0,V.jsxs)(w,{value:a,onValueChange:e=>s(e||``),children:[(0,V.jsx)(S,{className:`w-full bg-muted border-border text-foreground`,children:(0,V.jsx)(C,{placeholder:`Select arrow style`,children:h[a]})}),(0,V.jsxs)(x,{className:`bg-popover border-border text-popover-foreground`,children:[(0,V.jsx)(b,{value:`end`,children:`Arrow at End`}),(0,V.jsx)(b,{value:`start`,children:`Arrow at Start (Reverse)`}),(0,V.jsx)(b,{value:`both`,children:`Arrows Both Ends`}),(0,V.jsx)(b,{value:`none`,children:`No Arrows (Line only)`})]})]})]})]})]})})}function Pe({nodes:e,edges:t,onConfirm:n,onCancel:r,confirmLabel:i=`Confirm Append`,canvasGroups:a=[],existingNodes:o=[],existingEdges:s=[]}){let[c,l]=(0,B.useState)(null),u=(0,B.useMemo)(()=>{if(!o.length||!e.length)return null;let n=new Map;for(let e of o)n.set((e.data.label||``).toLowerCase(),e);let r=new Map;for(let t of e)r.set((t.data.label||``).toLowerCase(),t);let i=[];for(let t of e){let e=t.data.label||`Untitled`,r=n.get(e.toLowerCase());if(!r)i.push({type:`header`,label:e,isNew:!0}),i.push({type:`add`,prefix:`+`,field:`shape`,newVal:t.data.shape}),i.push({type:`add`,prefix:`+`,field:`label`,newVal:e}),t.data.color&&i.push({type:`add`,prefix:`+`,field:`color`,newVal:t.data.color});else{let n=r.data.shape!==t.data.shape,a=r.data.color!==t.data.color,o=(r.data.label||``)!==e;(n||a||o)&&(i.push({type:`header`,label:e}),o&&i.push({type:`change`,prefix:`~`,field:`label`,oldVal:r.data.label,newVal:e}),n&&i.push({type:`change`,prefix:`~`,field:`shape`,oldVal:r.data.shape,newVal:t.data.shape}),a&&i.push({type:`change`,prefix:`~`,field:`color`,oldVal:r.data.color,newVal:t.data.color}))}}for(let e of o){let t=e.data.label||``;r.has(t.toLowerCase())||(i.push({type:`header`,label:t,isNew:!1}),i.push({type:`remove`,prefix:`-`,field:`shape`,oldVal:e.data.shape}),i.push({type:`remove`,prefix:`-`,field:`removed`,oldVal:`entire node`}))}let a=new Set(s.map(e=>{let t=o.find(t=>t.id===e.source)?.data.label||e.source,n=o.find(t=>t.id===e.target)?.data.label||e.target;return`${t.toLowerCase()}→${n.toLowerCase()}`})),c=new Set(t.map(t=>{let n=e.find(e=>e.id===t.source)?.data.label||t.source,r=e.find(e=>e.id===t.target)?.data.label||t.target;return`${n.toLowerCase()}→${r.toLowerCase()}`})),l=[...c].filter(e=>!a.has(e)),u=[...a].filter(e=>!c.has(e));if(l.length>0||u.length>0){i.push({type:`header`,label:`Connections`});for(let e of l)i.push({type:`add`,prefix:`+`,field:`connection`,newVal:e});for(let e of u)i.push({type:`remove`,prefix:`-`,field:`connection`,oldVal:e})}return i.length>0?i:null},[o,s,e,t]);return(0,V.jsxs)(I,{open:!0,onOpenChange:e=>{e||r()},children:[(0,V.jsx)(pe,{}),(0,V.jsxs)(j,{size:`2xl`,showCloseButton:!0,children:[(0,V.jsx)(F,{children:(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(`div`,{className:`size-8 rounded-lg bg-indigo-500/10 flex items-center justify-center`,children:(0,V.jsx)(Ce,{className:`size-4 text-indigo-400`})}),(0,V.jsx)(`div`,{children:(0,V.jsx)(M,{children:`Preview Changes`})})]})}),(0,V.jsx)(N,{children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e.length>0&&(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsxs)(`label`,{className:`text-[11px] font-medium text-muted-foreground`,children:[`New Symbols (`,e.length,`)`]}),(0,V.jsx)(`div`,{className:`max-h-75 overflow-y-auto custom-scrollbar space-y-2`,children:e.map(e=>(0,V.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-muted overflow-hidden`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-2 border-b border-border/20 bg-muted/50`,children:[(0,V.jsx)(Ce,{className:`size-3 text-indigo-400 shrink-0`}),(0,V.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground`,children:e.data.label}),(0,V.jsx)(`span`,{className:`text-[9px] text-muted-foreground ml-auto`,children:e.data.shape})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 text-[10px] font-mono`,children:[(0,V.jsx)(`span`,{className:`text-gray-500`,children:`Shape:`}),(0,V.jsx)(`span`,{className:`text-gray-300`,children:e.data.shape}),e.data.color&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`text-gray-500 ml-2`,children:`Color:`}),(0,V.jsx)(`span`,{className:`text-gray-300`,children:e.data.color})]})]})]},e.id))})]}),u&&(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(`label`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Changes`}),(0,V.jsx)(`div`,{className:`rounded-lg border border-border/40 overflow-hidden max-h-75 overflow-y-auto custom-scrollbar text-[10px] font-mono leading-relaxed`,children:(0,V.jsx)(`div`,{className:`divide-y divide-border/10`,children:u.map((e,t)=>{if(e.type===`header`)return(0,V.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-muted border-b border-border/30`,children:[e.isNew&&(0,V.jsx)(`span`,{className:`text-[8px] font-semibold px-1 py-0.5 rounded bg-emerald-500/15 text-emerald-400 border border-emerald-500/30 shrink-0`,children:`NEW`}),(0,V.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground`,children:e.label})]},t);let n=e.type===`add`,r=e.type===`remove`,i=e.type===`change`,a=n?`bg-emerald-900/20`:r?`bg-red-900/20`:i?`bg-amber-900/20`:``,o=n?`text-emerald-400`:r?`text-red-400`:`text-amber-400`,s=n?`text-emerald-300`:r?`text-red-400`:`text-amber-300`,c=n?`text-emerald-400/60`:r?`text-red-400/60`:`text-amber-400/60`;return(0,V.jsxs)(`div`,{className:`flex items-center gap-1 px-3 py-0.5 ${a}`,children:[(0,V.jsx)(`span`,{className:`w-4 shrink-0 select-none ${o}`,children:e.prefix}),(0,V.jsx)(`span`,{className:`w-20 shrink-0 ${c}`,children:e.field}),e.oldVal&&(0,V.jsx)(`span`,{className:`text-red-400/70 line-through`,children:e.oldVal}),e.oldVal&&e.newVal&&(0,V.jsx)(`span`,{className:`text-gray-600`,children:`→`}),e.newVal&&(0,V.jsx)(`span`,{className:s,children:e.newVal})]},t)})})})]}),!u&&!e.length&&(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No changes detected.`})]})}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-6 pt-4 pb-6`,children:[(0,V.jsx)(`div`,{className:`flex items-center gap-3`,children:a.length>0&&(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(E,{className:`size-3.5 text-muted-foreground shrink-0`}),(0,V.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Replace:`}),(0,V.jsxs)(w,{value:c??``,onValueChange:e=>l(e||null),children:[(0,V.jsx)(S,{className:`h-7 text-[12px]`,children:(0,V.jsx)(C,{placeholder:`All Symbols`})}),(0,V.jsxs)(x,{children:[(0,V.jsx)(b,{value:``,children:`All Symbols`}),a.map(e=>(0,V.jsx)(b,{value:e,children:e},e))]})]})]})}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsxs)(y,{variant:`outline`,size:`sm`,onClick:r,className:`gap-2`,children:[(0,V.jsx)(me,{className:`size-4`}),`Cancel`]}),(0,V.jsxs)(y,{size:`sm`,onClick:()=>n(c||void 0),className:`gap-2`,children:[(0,V.jsx)(se,{className:`size-4`}),i]})]})]})]})]})}function W(e){return[{x:e.x+80,y:e.y},{x:e.x+80,y:e.y+70},{x:e.x,y:e.y+35},{x:e.x+160,y:e.y+35}]}function Fe(e,t){return W(e)[[`top`,`bottom`,`left`,`right`].indexOf(t)]}function Ie(e,t){let n=[`top`,`bottom`,`left`,`right`],r=W(e.position),i=W(t.position),a=1/0,o=0,s=0;for(let e=0;e<4;e++)for(let t=0;t<4;t++){let n=r[e].x-i[t].x,c=r[e].y-i[t].y,l=n*n+c*c;l<a&&(a=l,o=e,s=t)}return{sourceHandle:n[o],targetHandle:n[s]}}function Le(e,t,n,r){if(t===`bottom`||t===`top`||r===`bottom`||r===`top`){let t=(e.y+n.y)/2;return`M${e.x},${e.y} L${e.x},${t} L${n.x},${t} L${n.x},${n.y}`}let i=(e.x+n.x)/2;return`M${e.x},${e.y} L${i},${e.y} L${i},${n.y} L${n.x},${n.y}`}function G(e,t,n){switch(e){case`diamond`:return`<polygon points="80,2 158,35 80,68 2,35" fill="url(#grad-${n})" stroke="${t}" stroke-width="2" stroke-linejoin="round" filter="url(#shadow)" />`;case`parallelogram`:return`<polygon points="32,2 158,2 128,68 2,68" fill="url(#grad-${n})" stroke="${t}" stroke-width="2" stroke-linejoin="round" filter="url(#shadow)" />`;case`oval`:return`<ellipse cx="80" cy="35" rx="78" ry="33" fill="url(#grad-${n})" stroke="${t}" stroke-width="2" filter="url(#shadow)" />`;case`circle`:return`<circle cx="80" cy="35" r="33" fill="url(#grad-${n})" stroke="${t}" stroke-width="2" filter="url(#shadow)" />`;case`database`:return`<g>
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{n as r}from"./dist-D0tkMM_Y.js";import{a as i,b as a,c as o,d as s,h as c,i as l,l as u,m as d,n as f,o as p,p as m,r as h,s as ee,t as te,u as ne,x as g,y as _}from"./downloadSVG-C2LckkLx.js";import{a as v,h as re,r as ie}from"./esm-B1WURL1q.js";import{t as y}from"./button-D2dALS3q.js";import{i as b,n as x,o as S,s as C,t as w}from"./select-xSghKb2x.js";import{I as T,b as ae,o as oe}from"./CommentThreadView-Dx7ndjrK.js";import{t as se}from"./check-Uq0GkTkz.js";import{n as E,t as ce}from"./move-BzTcfKj2.js";import{A as D,C as le,M as ue,T as O,j as de,w as k}from"./hover-card-CqLOdc_X.js";import{t as fe}from"./plus-DfXp3YpY.js";import{a as A,c as pe,d as me,i as j,l as M,n as N,o as P,s as F,t as I}from"./dialog-EJdgZKa4.js";import{t as L}from"./trash-2-BmZK7fDJ.js";import{t as he}from"./undo-2-FZYgYKq2.js";import{t as ge}from"./card-DFJ6ytRY.js";import{t as R}from"./input-BUIkeoB3.js";import{n as _e}from"./WorkspaceContext-O7njKDwj.js";import{t as z}from"./label-CCjvjYto.js";import{A as ve,D as ye,Kt as be,O as xe,en as Se,gn as Ce,j as we,k as Te}from"./index-BL-qAtdL.js";import{i as Ee,r as De,t as Oe}from"./ERDComments-Xwt7V4OK.js";import{t as ke}from"./JumpToNode-6hHRtxhW.js";var B=e(t(),1),V=n(),H=(0,B.memo)(({data:e,id:t,selected:n})=>{let[r,i]=(0,B.useState)(!1),a=`!w-1.5 !h-1.5 !bg-white !border-none opacity-0 group-hover:opacity-100 transition-opacity z-20 cursor-crosshair`,o=(0,B.useMemo)(()=>{switch(e.shape){case`diamond`:return`min-w-[130px] min-h-[130px] p-8`;case`circle`:return`min-w-[110px] min-h-[110px] p-4`;case`cloud`:return`min-w-[160px] max-w-[240px] min-h-[90px] px-10 py-6`;case`database`:return`min-w-[140px] max-w-[220px] min-h-[100px] px-6 pt-10 pb-6`;case`parallelogram`:return`min-w-[160px] max-w-[240px] min-h-[80px] px-12 py-4`;case`oval`:return`min-w-[140px] max-w-[240px] min-h-[80px] px-10 py-4`;case`document`:return`min-w-[140px] max-w-[220px] min-h-[90px] px-8 pt-4 pb-10`;default:return`min-w-[140px] max-w-[240px] min-h-[80px] px-8 py-4`}},[e.shape]),s=(0,B.useMemo)(()=>{switch(e.shape){case`diamond`:return{width:100,height:100};case`circle`:return{width:80,height:80};default:return{width:100,height:60}}},[e.shape]),c=(0,B.useMemo)(()=>{let t={background:`linear-gradient(135deg, ${e.color}40 0%, ${e.color}10 100%)`,borderColor:e.color,borderWidth:`2px`,borderStyle:`solid`,boxShadow:`none`,transition:`all 0.3s cubic-bezier(0.4, 0, 0.2, 1)`},n=`${e.color}20`,r=e.color,i={filter:`none`,transition:`all 0.3s`};switch(e.shape){case`diamond`:return(0,V.jsx)(`svg`,{className:`absolute inset-0 w-full h-full pointer-events-none overflow-visible`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,children:(0,V.jsx)(`path`,{d:`M50,2 L98,50 L50,98 L2,50 Z`,fill:n,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinejoin:`round`,style:i})});case`parallelogram`:return(0,V.jsx)(`svg`,{className:`absolute inset-0 w-full h-full pointer-events-none overflow-visible`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,children:(0,V.jsx)(`path`,{d:`M20,2 L98,2 L80,98 L2,98 Z`,fill:n,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinejoin:`round`,style:i})});case`oval`:return(0,V.jsx)(`div`,{className:`absolute inset-0 rounded-[50px] pointer-events-none`,style:t});case`circle`:return(0,V.jsx)(`div`,{className:`absolute inset-0 rounded-full pointer-events-none flex items-center justify-center`,style:{...t,background:`radial-gradient(circle at 30% 30%, ${e.color}40 0%, ${e.color}10 100%)`}});case`database`:return(0,V.jsxs)(`svg`,{className:`absolute inset-0 w-full h-full pointer-events-none overflow-visible`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,children:[(0,V.jsx)(`path`,{d:`M2,15 L2,85 C2,95 98,95 98,85 L98,15`,fill:n,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinejoin:`round`,style:i}),(0,V.jsx)(`path`,{d:`M2,15 C2,5 98,5 98,15 C98,25 2,25 2,15 Z`,fill:`${e.color}35`,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`}),(0,V.jsx)(`path`,{d:`M2,50 C2,60 98,60 98,50`,fill:`none`,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,opacity:`0.3`})]});case`document`:return(0,V.jsxs)(`svg`,{className:`absolute inset-0 w-full h-full pointer-events-none overflow-visible`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,children:[(0,V.jsx)(`path`,{d:`M2,2 L70,2 L98,30 L98,85 C98,93 90,98 85,98 L15,98 C7,98 2,93 2,85 Z`,fill:n,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinejoin:`round`,style:i}),(0,V.jsx)(`path`,{d:`M70,2 V30 H98`,fill:`none`,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinejoin:`round`})]});case`cloud`:return(0,V.jsx)(`svg`,{className:`absolute inset-0 w-full h-full pointer-events-none overflow-visible`,viewBox:`0 0 100 100`,preserveAspectRatio:`none`,children:(0,V.jsx)(`path`,{d:`M20,80 C5,80 5,60 15,50 C10,20 40,15 55,25 C65,5 95,10 95,40 C105,50 105,80 80,80 Z`,fill:n,stroke:r,strokeWidth:`2`,vectorEffect:`non-scaling-stroke`,strokeLinecap:`round`,strokeLinejoin:`round`,style:i})});default:return(0,V.jsx)(`div`,{className:`absolute inset-0 rounded-md pointer-events-none`,style:t})}},[e.color,e.shape,n]),l=(0,V.jsxs)(`div`,{className:`relative group flex items-center justify-center cursor-pointer transition-all duration-300 hover:scale-[1.02] ${o}`,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{aspectRatio:e.shape===`circle`?`1 / 1`:`auto`},children:[(0,V.jsx)(d,{isVisible:!e._readOnly&&(n||r),keepAspectRatio:e.shape===`circle`,minWidth:s.width,minHeight:s.height,handleStyle:{width:8,height:8,borderRadius:0,backgroundColor:`#0f0f14`,border:`1.5px solid ${e.color}`,zIndex:50},lineStyle:{border:`1px dashed ${e.color}80`}}),c,e._commentsEnabled&&(0,V.jsx)(`div`,{className:`absolute -right-2 -top-2 z-60`,children:(0,V.jsx)(Oe,{anchor:{type:`shape`,id:t}})}),(0,V.jsx)(m,{id:`top`,type:`target`,position:v.Top,className:a}),(0,V.jsx)(m,{id:`top`,type:`source`,position:v.Top,className:a}),(0,V.jsx)(m,{id:`bottom`,type:`target`,position:v.Bottom,className:a}),(0,V.jsx)(m,{id:`bottom`,type:`source`,position:v.Bottom,className:a}),(0,V.jsx)(m,{id:`right`,type:`target`,position:v.Right,className:a}),(0,V.jsx)(m,{id:`right`,type:`source`,position:v.Right,className:a}),(0,V.jsx)(m,{id:`left`,type:`target`,position:v.Left,className:a}),(0,V.jsx)(m,{id:`left`,type:`source`,position:v.Left,className:a}),(0,V.jsx)(`div`,{className:`relative z-10 text-center text-sm font-semibold text-foreground wrap-break-word whitespace-pre-wrap max-w-full flex-1`,children:e.label}),e.section&&(0,V.jsx)(`div`,{className:`absolute -top-7 left-1/2 -translate-x-1/2 z-20 whitespace-nowrap text-[9px] font-medium text-muted-foreground/60 tracking-wider uppercase px-2 py-0.5 rounded-full bg-background/50 backdrop-blur-sm border border-border/30`,children:e.section})]});return e._commentsEnabled?(0,V.jsxs)(le,{children:[(0,V.jsx)(D,{className:`contents`,children:l}),(0,V.jsx)(k,{className:`min-w-36`,positionerClassName:`z-[210]`,children:(0,V.jsxs)(O,{onClick:e=>{e.preventDefault(),e.stopPropagation(),window.dispatchEvent(new CustomEvent(De,{detail:{type:`shape`,id:t}}))},children:[(0,V.jsx)(be,{"aria-hidden":`true`}),`Comment`]})})]}):l}),U=e=>e.trim().toLowerCase().includes(`start`);function Ae({isOpen:e,onOpenChange:t,nodeData:n,onNodeDataChange:r,onConfirm:i}){let a=U(n.label);return(0,V.jsx)(I,{open:e,onOpenChange:t,children:(0,V.jsxs)(j,{className:`sm:max-w-sm`,children:[(0,V.jsxs)(F,{children:[(0,V.jsx)(M,{children:`Create New Symbol`}),(0,V.jsx)(A,{children:`Configure the symbol before placing it on the canvas.`})]}),(0,V.jsxs)(N,{className:`space-y-6`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{children:`Label`}),(0,V.jsx)(R,{value:n.label,onChange:e=>r({...n,label:e.target.value}),placeholder:`Enter symbol label`,className:`bg-muted border-border text-foreground`})]}),a&&(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{children:`Group Title`}),(0,V.jsx)(R,{value:n.section||``,onChange:e=>r({...n,section:e.target.value||void 0}),placeholder:`e.g. Pengajuan Cuti`,className:`bg-muted border-border text-foreground`}),(0,V.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50`,children:`Nama grup untuk alur yang dimulai dari sini.`})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{children:`Shape Type`}),(0,V.jsxs)(w,{value:n.shape,onValueChange:e=>r({...n,shape:e||n.shape}),children:[(0,V.jsx)(S,{className:`w-full bg-muted border-border text-foreground`,children:(0,V.jsx)(C,{placeholder:`Select a shape`,children:n.shape?p[n.shape]:`Select a shape`})}),(0,V.jsxs)(x,{className:`bg-popover border-border text-popover-foreground`,children:[(0,V.jsx)(b,{value:`rectangle`,children:`Rectangle (Process)`}),(0,V.jsx)(b,{value:`oval`,children:`Oval (Start/End)`}),(0,V.jsx)(b,{value:`diamond`,children:`Diamond (Decision)`}),(0,V.jsx)(b,{value:`parallelogram`,children:`Parallelogram (Input/Output)`}),(0,V.jsx)(b,{value:`database`,children:`Cylinder (Database)`}),(0,V.jsx)(b,{value:`document`,children:`Document`}),(0,V.jsx)(b,{value:`cloud`,children:`Cloud (External System)`}),(0,V.jsx)(b,{value:`circle`,children:`Circle (Connector)`})]})]})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{children:`Color`}),(0,V.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:l.map(e=>(0,V.jsx)(`button`,{className:`w-8 h-8 rounded-full border-2 transition-transform hover:scale-110 ${n.color===e?`border-white scale-110`:`border-transparent`}`,style:{backgroundColor:e},onClick:()=>r({...n,color:e})},e))})]})]}),(0,V.jsxs)(P,{children:[(0,V.jsx)(y,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,V.jsx)(y,{onClick:i,className:`bg-primary text-primary-foreground`,children:`Add to Flowchart`})]})]})})}function je(e){return e.data.label.trim().toLowerCase().includes(`start`)}function Me({selectedNodeId:e,onClose:t,selectedNode:n,onUpdateNodeData:r,onDeleteNode:i,onDeleteGroup:a,onValidateSection:o}){let s=n?je(n):!1,[c,u]=(0,B.useState)(()=>n?n.data.code?n.data.code:n.data.shape===`diamond`?`return context.amount > 100 ? 'Yes' : 'No';`:`context.status = 'Approved';`:``),d=e=>{u(e),r({code:e})};return(0,V.jsx)(I,{open:!!e,onOpenChange:e=>{e||t()},children:(0,V.jsxs)(j,{className:`sm:max-w-sm`,children:[(0,V.jsxs)(F,{children:[(0,V.jsx)(M,{children:`Symbol Properties`}),(0,V.jsx)(A,{children:`Customize the name, shape, and color of this symbol.`})]}),n&&(0,V.jsxs)(N,{className:`space-y-6`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{children:`Label`}),(0,V.jsx)(R,{value:n.data.label,onChange:e=>r({label:e.target.value}),placeholder:`Enter symbol label`,className:`bg-muted/50 border-border text-foreground`})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{className:`text-xs font-bold text-zinc-300`,children:`Code Logic (JavaScript)`}),(0,V.jsx)(`textarea`,{value:c,onChange:e=>d(e.target.value),placeholder:n.data.shape===`diamond`?`e.g. return context.amount > 100 ? 'Yes' : 'No';`:`e.g. context.status = 'Approved'; context.tries += 1;`,className:`w-full h-24 bg-muted border border-border rounded-md p-2 text-xs font-mono text-foreground placeholder:text-muted-foreground/50 resize-none focus:outline-none focus:border-ring`}),(0,V.jsxs)(`p`,{className:`text-[9px] text-muted-foreground/50 leading-normal`,children:[`Attached sandbox logic. For Decision diamonds, return the matching branch label (case-sensitive). Process symbols can mutate variables in the `,(0,V.jsx)(`code`,{children:`context`}),` object.`]})]}),s&&(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{children:`Group Title`}),(0,V.jsx)(R,{value:n.data.section||``,onChange:e=>r({section:e.target.value||void 0}),onBlur:e=>{let t=e.target.value;t&&o&&!o(t)&&r({section:void 0})},placeholder:`e.g. Pengajuan Cuti`,className:`bg-muted/50 border-border text-foreground`}),(0,V.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50`,children:`Nama grup untuk alur yang dimulai dari sini.`})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{children:`Shape Type`}),(0,V.jsxs)(w,{value:n.data.shape,onValueChange:e=>e&&r({shape:e}),children:[(0,V.jsx)(S,{className:`w-full bg-muted border-border text-foreground`,children:(0,V.jsx)(C,{placeholder:`Select a shape`,children:n.data.shape?p[n.data.shape]:`Select a shape`})}),(0,V.jsxs)(x,{className:`bg-popover border-border text-popover-foreground`,children:[(0,V.jsx)(b,{value:`rectangle`,children:`Rectangle (Process)`}),(0,V.jsx)(b,{value:`oval`,children:`Oval (Start/End)`}),(0,V.jsx)(b,{value:`diamond`,children:`Diamond (Decision)`}),(0,V.jsx)(b,{value:`parallelogram`,children:`Parallelogram (Input/Output)`}),(0,V.jsx)(b,{value:`database`,children:`Cylinder (Database)`}),(0,V.jsx)(b,{value:`document`,children:`Document`}),(0,V.jsx)(b,{value:`cloud`,children:`Cloud (External System)`}),(0,V.jsx)(b,{value:`circle`,children:`Circle (Connector)`})]})]})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{children:`Color`}),(0,V.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:l.map(e=>(0,V.jsx)(`button`,{className:`w-8 h-8 rounded-full border-2 transition-transform hover:scale-110 ${n.data.color===e?`border-white scale-110`:`border-transparent`}`,style:{backgroundColor:e},onClick:()=>r({color:e})},e))})]}),(0,V.jsxs)(`div`,{className:`pt-2 border-t border-border space-y-2`,children:[(0,V.jsxs)(y,{variant:`destructive`,size:`sm`,className:`w-full gap-2`,onClick:()=>{i(),t()},children:[(0,V.jsx)(L,{className:`size-4`}),`Delete Symbol`]}),s&&n.data.section&&a&&(0,V.jsxs)(y,{variant:`outline`,size:`sm`,className:`w-full gap-2 text-destructive border-destructive/30 hover:bg-destructive/10`,onClick:()=>{a(),t()},children:[(0,V.jsx)(L,{className:`size-4`}),`Delete Group "`,n.data.section,`"`]})]})]},e)]})})}function Ne({selectedEdgeId:e,onClose:t,selectedEdge:n,isDashed:r,arrowType:a,onEdgeTypeChange:o,onArrowChange:s,onLabelChange:c,onDeleteEdge:l}){return(0,V.jsx)(I,{open:!!e,onOpenChange:e=>{e||t()},children:(0,V.jsxs)(j,{className:`sm:max-w-sm`,children:[(0,V.jsx)(F,{children:(0,V.jsxs)(`div`,{className:`flex items-center justify-between pr-8`,children:[(0,V.jsxs)(`div`,{className:`space-y-1 text-left`,children:[(0,V.jsx)(M,{children:`Connector Properties`}),(0,V.jsx)(A,{children:`Format the line style and arrows.`})]}),(0,V.jsx)(y,{variant:`ghost`,size:`icon`,onClick:l,className:`text-destructive hover:bg-destructive/10 -mr-2 shadow-none`,title:`Delete Connector`,children:(0,V.jsx)(L,{className:`w-4 h-4`})})]})}),n&&(0,V.jsxs)(N,{className:`space-y-6`,children:[(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{children:`Text Label`}),(0,V.jsx)(R,{value:typeof n.label==`string`?n.label:``,onChange:e=>c(e.target.value),placeholder:`e.g. Yes, No, 1, 2...`,className:`bg-muted border-border text-foreground`})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{children:`Line Style`}),(0,V.jsxs)(w,{value:r?`dashed`:`solid`,onValueChange:e=>o(e||``),children:[(0,V.jsx)(S,{className:`w-full bg-muted border-border text-foreground`,children:(0,V.jsx)(C,{placeholder:`Select line style`,children:i[r?`dashed`:`solid`]})}),(0,V.jsxs)(x,{className:`bg-popover border-border text-popover-foreground`,children:[(0,V.jsx)(b,{value:`solid`,children:`Solid Line`}),(0,V.jsx)(b,{value:`dashed`,children:`Dashed Line`})]})]})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(z,{children:`Arrow Style`}),(0,V.jsxs)(w,{value:a,onValueChange:e=>s(e||``),children:[(0,V.jsx)(S,{className:`w-full bg-muted border-border text-foreground`,children:(0,V.jsx)(C,{placeholder:`Select arrow style`,children:h[a]})}),(0,V.jsxs)(x,{className:`bg-popover border-border text-popover-foreground`,children:[(0,V.jsx)(b,{value:`end`,children:`Arrow at End`}),(0,V.jsx)(b,{value:`start`,children:`Arrow at Start (Reverse)`}),(0,V.jsx)(b,{value:`both`,children:`Arrows Both Ends`}),(0,V.jsx)(b,{value:`none`,children:`No Arrows (Line only)`})]})]})]})]})]})})}function Pe({nodes:e,edges:t,onConfirm:n,onCancel:r,confirmLabel:i=`Confirm Append`,canvasGroups:a=[],existingNodes:o=[],existingEdges:s=[]}){let[c,l]=(0,B.useState)(null),u=(0,B.useMemo)(()=>{if(!o.length||!e.length)return null;let n=new Map;for(let e of o)n.set((e.data.label||``).toLowerCase(),e);let r=new Map;for(let t of e)r.set((t.data.label||``).toLowerCase(),t);let i=[];for(let t of e){let e=t.data.label||`Untitled`,r=n.get(e.toLowerCase());if(!r)i.push({type:`header`,label:e,isNew:!0}),i.push({type:`add`,prefix:`+`,field:`shape`,newVal:t.data.shape}),i.push({type:`add`,prefix:`+`,field:`label`,newVal:e}),t.data.color&&i.push({type:`add`,prefix:`+`,field:`color`,newVal:t.data.color});else{let n=r.data.shape!==t.data.shape,a=r.data.color!==t.data.color,o=(r.data.label||``)!==e;(n||a||o)&&(i.push({type:`header`,label:e}),o&&i.push({type:`change`,prefix:`~`,field:`label`,oldVal:r.data.label,newVal:e}),n&&i.push({type:`change`,prefix:`~`,field:`shape`,oldVal:r.data.shape,newVal:t.data.shape}),a&&i.push({type:`change`,prefix:`~`,field:`color`,oldVal:r.data.color,newVal:t.data.color}))}}for(let e of o){let t=e.data.label||``;r.has(t.toLowerCase())||(i.push({type:`header`,label:t,isNew:!1}),i.push({type:`remove`,prefix:`-`,field:`shape`,oldVal:e.data.shape}),i.push({type:`remove`,prefix:`-`,field:`removed`,oldVal:`entire node`}))}let a=new Set(s.map(e=>{let t=o.find(t=>t.id===e.source)?.data.label||e.source,n=o.find(t=>t.id===e.target)?.data.label||e.target;return`${t.toLowerCase()}→${n.toLowerCase()}`})),c=new Set(t.map(t=>{let n=e.find(e=>e.id===t.source)?.data.label||t.source,r=e.find(e=>e.id===t.target)?.data.label||t.target;return`${n.toLowerCase()}→${r.toLowerCase()}`})),l=[...c].filter(e=>!a.has(e)),u=[...a].filter(e=>!c.has(e));if(l.length>0||u.length>0){i.push({type:`header`,label:`Connections`});for(let e of l)i.push({type:`add`,prefix:`+`,field:`connection`,newVal:e});for(let e of u)i.push({type:`remove`,prefix:`-`,field:`connection`,oldVal:e})}return i.length>0?i:null},[o,s,e,t]);return(0,V.jsxs)(I,{open:!0,onOpenChange:e=>{e||r()},children:[(0,V.jsx)(pe,{}),(0,V.jsxs)(j,{size:`2xl`,showCloseButton:!0,children:[(0,V.jsx)(F,{children:(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(`div`,{className:`size-8 rounded-lg bg-indigo-500/10 flex items-center justify-center`,children:(0,V.jsx)(Ce,{className:`size-4 text-indigo-400`})}),(0,V.jsx)(`div`,{children:(0,V.jsx)(M,{children:`Preview Changes`})})]})}),(0,V.jsx)(N,{children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e.length>0&&(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsxs)(`label`,{className:`text-[11px] font-medium text-muted-foreground`,children:[`New Symbols (`,e.length,`)`]}),(0,V.jsx)(`div`,{className:`max-h-75 overflow-y-auto custom-scrollbar space-y-2`,children:e.map(e=>(0,V.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-muted overflow-hidden`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-2 border-b border-border/20 bg-muted/50`,children:[(0,V.jsx)(Ce,{className:`size-3 text-indigo-400 shrink-0`}),(0,V.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground`,children:e.data.label}),(0,V.jsx)(`span`,{className:`text-[9px] text-muted-foreground ml-auto`,children:e.data.shape})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 text-[10px] font-mono`,children:[(0,V.jsx)(`span`,{className:`text-gray-500`,children:`Shape:`}),(0,V.jsx)(`span`,{className:`text-gray-300`,children:e.data.shape}),e.data.color&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`span`,{className:`text-gray-500 ml-2`,children:`Color:`}),(0,V.jsx)(`span`,{className:`text-gray-300`,children:e.data.color})]})]})]},e.id))})]}),u&&(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(`label`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Changes`}),(0,V.jsx)(`div`,{className:`rounded-lg border border-border/40 overflow-hidden max-h-75 overflow-y-auto custom-scrollbar text-[10px] font-mono leading-relaxed`,children:(0,V.jsx)(`div`,{className:`divide-y divide-border/10`,children:u.map((e,t)=>{if(e.type===`header`)return(0,V.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-muted border-b border-border/30`,children:[e.isNew&&(0,V.jsx)(`span`,{className:`text-[8px] font-semibold px-1 py-0.5 rounded bg-emerald-500/15 text-emerald-400 border border-emerald-500/30 shrink-0`,children:`NEW`}),(0,V.jsx)(`span`,{className:`text-[11px] font-semibold text-foreground`,children:e.label})]},t);let n=e.type===`add`,r=e.type===`remove`,i=e.type===`change`,a=n?`bg-emerald-900/20`:r?`bg-red-900/20`:i?`bg-amber-900/20`:``,o=n?`text-emerald-400`:r?`text-red-400`:`text-amber-400`,s=n?`text-emerald-300`:r?`text-red-400`:`text-amber-300`,c=n?`text-emerald-400/60`:r?`text-red-400/60`:`text-amber-400/60`;return(0,V.jsxs)(`div`,{className:`flex items-center gap-1 px-3 py-0.5 ${a}`,children:[(0,V.jsx)(`span`,{className:`w-4 shrink-0 select-none ${o}`,children:e.prefix}),(0,V.jsx)(`span`,{className:`w-20 shrink-0 ${c}`,children:e.field}),e.oldVal&&(0,V.jsx)(`span`,{className:`text-red-400/70 line-through`,children:e.oldVal}),e.oldVal&&e.newVal&&(0,V.jsx)(`span`,{className:`text-gray-600`,children:`→`}),e.newVal&&(0,V.jsx)(`span`,{className:s,children:e.newVal})]},t)})})})]}),!u&&!e.length&&(0,V.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No changes detected.`})]})}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-6 pt-4 pb-6`,children:[(0,V.jsx)(`div`,{className:`flex items-center gap-3`,children:a.length>0&&(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(E,{className:`size-3.5 text-muted-foreground shrink-0`}),(0,V.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Replace:`}),(0,V.jsxs)(w,{value:c??``,onValueChange:e=>l(e||null),children:[(0,V.jsx)(S,{className:`h-7 text-[12px]`,children:(0,V.jsx)(C,{placeholder:`All Symbols`})}),(0,V.jsxs)(x,{children:[(0,V.jsx)(b,{value:``,children:`All Symbols`}),a.map(e=>(0,V.jsx)(b,{value:e,children:e},e))]})]})]})}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsxs)(y,{variant:`outline`,size:`sm`,onClick:r,className:`gap-2`,children:[(0,V.jsx)(me,{className:`size-4`}),`Cancel`]}),(0,V.jsxs)(y,{size:`sm`,onClick:()=>n(c||void 0),className:`gap-2`,children:[(0,V.jsx)(se,{className:`size-4`}),i]})]})]})]})]})}function W(e){return[{x:e.x+80,y:e.y},{x:e.x+80,y:e.y+70},{x:e.x,y:e.y+35},{x:e.x+160,y:e.y+35}]}function Fe(e,t){return W(e)[[`top`,`bottom`,`left`,`right`].indexOf(t)]}function Ie(e,t){let n=[`top`,`bottom`,`left`,`right`],r=W(e.position),i=W(t.position),a=1/0,o=0,s=0;for(let e=0;e<4;e++)for(let t=0;t<4;t++){let n=r[e].x-i[t].x,c=r[e].y-i[t].y,l=n*n+c*c;l<a&&(a=l,o=e,s=t)}return{sourceHandle:n[o],targetHandle:n[s]}}function Le(e,t,n,r){if(t===`bottom`||t===`top`||r===`bottom`||r===`top`){let t=(e.y+n.y)/2;return`M${e.x},${e.y} L${e.x},${t} L${n.x},${t} L${n.x},${n.y}`}let i=(e.x+n.x)/2;return`M${e.x},${e.y} L${i},${e.y} L${i},${n.y} L${n.x},${n.y}`}function G(e,t,n){switch(e){case`diamond`:return`<polygon points="80,2 158,35 80,68 2,35" fill="url(#grad-${n})" stroke="${t}" stroke-width="2" stroke-linejoin="round" filter="url(#shadow)" />`;case`parallelogram`:return`<polygon points="32,2 158,2 128,68 2,68" fill="url(#grad-${n})" stroke="${t}" stroke-width="2" stroke-linejoin="round" filter="url(#shadow)" />`;case`oval`:return`<ellipse cx="80" cy="35" rx="78" ry="33" fill="url(#grad-${n})" stroke="${t}" stroke-width="2" filter="url(#shadow)" />`;case`circle`:return`<circle cx="80" cy="35" r="33" fill="url(#grad-${n})" stroke="${t}" stroke-width="2" filter="url(#shadow)" />`;case`database`:return`<g>
2
2
  <path d="M2,14 L2,56 C2,68 158,68 158,56 L158,14" fill="url(#grad-${n})" stroke="${t}" stroke-width="2" stroke-linejoin="round" filter="url(#shadow)" />
3
3
  <ellipse cx="80" cy="14" rx="78" ry="10.5" fill="${t}30" stroke="${t}" stroke-width="2" filter="url(#shadow)" />
4
4
  <path d="M2,35 C2,45.5 158,45.5 158,35" fill="none" stroke="${t}" stroke-width="2" opacity="0.3" />
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{a as r}from"./dist-D0tkMM_Y.js";import{S as i}from"./downloadSVG-C2LckkLx.js";import{t as a}from"./button-D2dALS3q.js";import{a as o,d as s,i as c,o as l,r as u,s as d,t as f}from"./dropdown-menu-BrGjsCp0.js";import{h as p}from"./select-xSghKb2x.js";import{s as m}from"./CommentThreadView-Dx7ndjrK.js";import{f as h}from"./dialog-EJdgZKa4.js";import{t as g}from"./input-BUIkeoB3.js";import{Xt as _}from"./index-4mHBF5P6.js";var v=e(t(),1),y=n();function b({nodes:e,className:t,label:n=`Symbol`}){let{fitView:b}=i(),[x,S]=(0,v.useState)(!1),[C,w]=(0,v.useState)(``),T=v.useRef(null);v.useEffect(()=>{x&&setTimeout(()=>T.current?.focus(),100)},[x]);let E=e=>{e.stopPropagation(),e.key===`Escape`&&S(!1)},D=(0,v.useMemo)(()=>{let t=C.trim().toLowerCase();return t?e.filter(e=>{let n=e.data;return(n.name||n.label||``).toLowerCase().includes(t)}):e},[e,C]),O=e=>{S(!1),w(``),e.position.x+(e.measured?.width??200)/2,e.position.y+(e.measured?.height??100)/2,setTimeout(()=>{b({nodes:[{id:e.id}],duration:0,padding:1.5,minZoom:1.2,maxZoom:1.2})},100)};return(0,y.jsxs)(f,{open:x,onOpenChange:S,children:[(0,y.jsx)(s,{render:(0,y.jsxs)(a,{variant:`outline`,size:`sm`,className:r(`h-9 px-3 text-xs font-bold border-border/50 bg-muted/20 hover:bg-muted text-muted-foreground transition-all`,t),children:[(0,y.jsx)(_,{className:`w-3.5 h-3.5 mr-2`}),(0,y.jsxs)(`span`,{className:`hidden sm:inline`,children:[`Jump to `,n]}),(0,y.jsx)(`span`,{className:`sm:hidden`,children:`Jump`}),(0,y.jsx)(p,{className:`w-3 h-3 ml-2 opacity-50`})]})}),(0,y.jsxs)(u,{align:`start`,className:`w-[280px] p-0 shadow-2xl border-border/50 bg-background/95 backdrop-blur-xl`,children:[(0,y.jsx)(`div`,{className:`p-3 pb-2`,onPointerDown:e=>e.stopPropagation(),children:(0,y.jsxs)(`div`,{className:`relative`,children:[(0,y.jsx)(h,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground`}),(0,y.jsx)(g,{ref:T,placeholder:`Search ${n.toLowerCase()}s...`,className:`h-8 pl-8 text-xs bg-muted/50 border-none focus-visible:ring-1 focus-visible:ring-primary/50`,value:C,onChange:e=>w(e.target.value),onKeyDown:E,autoComplete:`off`})]})}),(0,y.jsx)(d,{className:`bg-border/50`}),(0,y.jsxs)(c,{children:[(0,y.jsxs)(l,{className:`px-3 pt-1 text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70`,children:[`Showing `,D.length,` of `,e.length,` `,n.toLowerCase(),`s`]}),(0,y.jsx)(m,{className:`h-[250px] px-1 pb-1`,children:D.length===0?(0,y.jsx)(`div`,{className:`px-3 py-6 text-center text-[11px] text-muted-foreground italic`,children:`No matching items found`}):D.map(e=>{let t=e.data,n=t.name||t.label||`Unnamed component`;return(0,y.jsxs)(o,{onClick:()=>O(e),className:`flex items-center gap-2.5 px-3 py-2 cursor-pointer transition-colors focus:bg-accent focus:text-accent-foreground rounded-lg mx-1`,children:[(0,y.jsx)(`div`,{className:`w-2 h-2 rounded-full`,style:{backgroundColor:e.data.color||`#8b5cf6`}}),(0,y.jsx)(`span`,{className:`text-[13px] font-medium truncate tracking-tight`,children:n})]},e.id)})})]})]})]})}export{b as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{a as r}from"./dist-D0tkMM_Y.js";import{S as i}from"./downloadSVG-C2LckkLx.js";import{t as a}from"./button-D2dALS3q.js";import{a as o,d as s,i as c,o as l,r as u,s as d,t as f}from"./dropdown-menu-BrGjsCp0.js";import{h as p}from"./select-xSghKb2x.js";import{s as m}from"./CommentThreadView-Dx7ndjrK.js";import{f as h}from"./dialog-EJdgZKa4.js";import{t as g}from"./input-BUIkeoB3.js";import{Xt as _}from"./index-BL-qAtdL.js";var v=e(t(),1),y=n();function b({nodes:e,className:t,label:n=`Symbol`}){let{fitView:b}=i(),[x,S]=(0,v.useState)(!1),[C,w]=(0,v.useState)(``),T=v.useRef(null);v.useEffect(()=>{x&&setTimeout(()=>T.current?.focus(),100)},[x]);let E=e=>{e.stopPropagation(),e.key===`Escape`&&S(!1)},D=(0,v.useMemo)(()=>{let t=C.trim().toLowerCase();return t?e.filter(e=>{let n=e.data;return(n.name||n.label||``).toLowerCase().includes(t)}):e},[e,C]),O=e=>{S(!1),w(``),e.position.x+(e.measured?.width??200)/2,e.position.y+(e.measured?.height??100)/2,setTimeout(()=>{b({nodes:[{id:e.id}],duration:0,padding:1.5,minZoom:1.2,maxZoom:1.2})},100)};return(0,y.jsxs)(f,{open:x,onOpenChange:S,children:[(0,y.jsx)(s,{render:(0,y.jsxs)(a,{variant:`outline`,size:`sm`,className:r(`h-9 px-3 text-xs font-bold border-border/50 bg-muted/20 hover:bg-muted text-muted-foreground transition-all`,t),children:[(0,y.jsx)(_,{className:`w-3.5 h-3.5 mr-2`}),(0,y.jsxs)(`span`,{className:`hidden sm:inline`,children:[`Jump to `,n]}),(0,y.jsx)(`span`,{className:`sm:hidden`,children:`Jump`}),(0,y.jsx)(p,{className:`w-3 h-3 ml-2 opacity-50`})]})}),(0,y.jsxs)(u,{align:`start`,className:`w-[280px] p-0 shadow-2xl border-border/50 bg-background/95 backdrop-blur-xl`,children:[(0,y.jsx)(`div`,{className:`p-3 pb-2`,onPointerDown:e=>e.stopPropagation(),children:(0,y.jsxs)(`div`,{className:`relative`,children:[(0,y.jsx)(h,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground`}),(0,y.jsx)(g,{ref:T,placeholder:`Search ${n.toLowerCase()}s...`,className:`h-8 pl-8 text-xs bg-muted/50 border-none focus-visible:ring-1 focus-visible:ring-primary/50`,value:C,onChange:e=>w(e.target.value),onKeyDown:E,autoComplete:`off`})]})}),(0,y.jsx)(d,{className:`bg-border/50`}),(0,y.jsxs)(c,{children:[(0,y.jsxs)(l,{className:`px-3 pt-1 text-[10px] font-bold uppercase tracking-widest text-muted-foreground/70`,children:[`Showing `,D.length,` of `,e.length,` `,n.toLowerCase(),`s`]}),(0,y.jsx)(m,{className:`h-[250px] px-1 pb-1`,children:D.length===0?(0,y.jsx)(`div`,{className:`px-3 py-6 text-center text-[11px] text-muted-foreground italic`,children:`No matching items found`}):D.map(e=>{let t=e.data,n=t.name||t.label||`Unnamed component`;return(0,y.jsxs)(o,{onClick:()=>O(e),className:`flex items-center gap-2.5 px-3 py-2 cursor-pointer transition-colors focus:bg-accent focus:text-accent-foreground rounded-lg mx-1`,children:[(0,y.jsx)(`div`,{className:`w-2 h-2 rounded-full`,style:{backgroundColor:e.data.color||`#8b5cf6`}}),(0,y.jsx)(`span`,{className:`text-[13px] font-medium truncate tracking-tight`,children:n})]},e.id)})})]})]})]})}export{b as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{n as r}from"./dist-D0tkMM_Y.js";import{c as i}from"./chunk-BV7QT456-CCzugQp2.js";import{t as a}from"./button-D2dALS3q.js";import{i as o,n as s,o as c,s as l,t as u}from"./select-xSghKb2x.js";import{t as d}from"./arrow-left-Cfq6LFs7.js";import{s as f}from"./useField-F6rVNyMc.js";import{t as p}from"./ConfirmModal-DqvHDAUo.js";import{t as m}from"./file-image-C1wgTBuF.js";import{t as h}from"./refresh-cw-Bmpxlvmc.js";import{t as g}from"./trash-2-BmZK7fDJ.js";import{t as _}from"./undo-2-FZYgYKq2.js";import{a as v,n as y}from"./api-BAQH6VUv.js";import{a as b,i as x,n as S,o as C,r as w,t as T}from"./table-Bs3EelYM.js";import{Q as E,Z as D,Zn as O}from"./index-4mHBF5P6.js";var k=e(t(),1),A=n(),j=30,M={all:`All files`,unused:`Unused only`},N={size:`Largest first`,date:`Newest first`};function P(){let e=i(),[t,n]=(0,k.useState)(`all`),[P,F]=(0,k.useState)(`size`),[I,L]=(0,k.useState)(null),[R,z]=(0,k.useState)([]),[B,V]=(0,k.useState)(!0),[H,U]=(0,k.useState)(null),[W,G]=(0,k.useState)(1),K=(0,k.useCallback)(async e=>{V(!0);try{let n=await y(`/api/library?filter=${t}&sort=${P}&page=${e}`);if(!n.ok)throw Error();let r=await n.json();if(L(r),r.items.length===0&&e>1){G(e-1);return}z(r.items)}catch{r.error(`The Library could not be loaded.`)}finally{V(!1)}},[t,P]);(0,k.useEffect)(()=>{K(W)},[K,W]);let q=async e=>{if(e.length===1){let t=await(await y(`/api/library/usage?key=${encodeURIComponent(e[0].key)}`)).json().catch(()=>({documents:[]}));if(t.documents?.length){let e=t.documents.map(e=>e.title+(e.isDeleted?` (in Trash)`:``)).join(`, `);r.error(`This image is still used by: ${e}. Remove it from those documents first.`);return}}U({items:e,message:`${e.length===1?`This image`:`${e.length} unused images`} will stop counting toward storage now and be removed for good after ${j} days. You can undo until then.`})},J=async()=>{let e=H?.items??[];U(null);let t=0;for(let n of e)(await y(`/api/library`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:n.key})})).ok||t++;t?r.error(`${t} image${t===1?` is`:`s are`} still in use and ${t===1?`was`:`were`} kept.`):r.success(e.length===1?`Image deleted`:`Unused images deleted`),K(W)},Y=async e=>{let t=await y(`/api/library/restore`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:e.key})}),n=await t.json().catch(()=>({}));if(!t.ok){r.error(n.error||`The image could not be restored.`);return}r.success(`Image restored`),K(W)},X=I?Math.max(1,Math.ceil(I.total/I.page_size)):1,Z=R.filter(e=>e.unused&&e.status===`committed`&&e.can_delete);return(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border bg-background`,children:[(0,A.jsx)(`div`,{className:`shrink-0 border-b p-6`,children:(0,A.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(a,{variant:`ghost`,size:`sm`,className:`-ml-2 mb-2`,onClick:()=>e(-1),children:[(0,A.jsx)(d,{className:`mr-1 size-4`}),` Back`]}),(0,A.jsxs)(`h2`,{className:`flex items-center gap-2 text-2xl font-bold`,children:[(0,A.jsx)(m,{className:`size-6 text-muted-foreground`}),` Library`]}),(0,A.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Files uploaded to `,I?.scope===`user`?`your Personal Workspace`:`this Team workspace by all members`,`. Unused files still count toward storage until deleted.`]})]}),(0,A.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,A.jsxs)(u,{value:t,onValueChange:e=>{e&&(n(e),G(1))},children:[(0,A.jsx)(c,{size:`sm`,"aria-label":`Filter`,className:`w-32`,children:(0,A.jsx)(l,{children:M[t]})}),(0,A.jsxs)(s,{children:[(0,A.jsx)(o,{value:`all`,children:M.all}),(0,A.jsx)(o,{value:`unused`,children:M.unused})]})]}),(0,A.jsxs)(u,{value:P,onValueChange:e=>{e&&(F(e),G(1))},children:[(0,A.jsx)(c,{size:`sm`,"aria-label":`Sort`,className:`w-36`,children:(0,A.jsx)(l,{children:N[P]})}),(0,A.jsxs)(s,{children:[(0,A.jsx)(o,{value:`size`,children:N.size}),(0,A.jsx)(o,{value:`date`,children:N.date})]})]}),(0,A.jsxs)(a,{variant:`outline`,size:`sm`,onClick:()=>void K(W),disabled:B,children:[(0,A.jsx)(h,{className:`mr-1 size-4 ${B?`animate-spin`:``}`}),` Refresh`]}),I?.can_bulk_delete&&Z.length>0&&(0,A.jsxs)(a,{variant:`destructive`,size:`sm`,onClick:()=>void q(Z),children:[(0,A.jsx)(g,{className:`mr-1 size-4`}),` Delete unused (`,Z.length,`)`]})]})]})}),(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-6 custom-scrollbar`,children:[R.length===0?!B&&(0,A.jsx)(`div`,{className:`rounded-lg border border-dashed py-12 text-center text-muted-foreground`,children:t===`unused`?`No unused files.`:`No files uploaded yet.`}):(0,A.jsx)(`div`,{className:`overflow-hidden rounded-lg border`,children:(0,A.jsxs)(T,{children:[(0,A.jsx)(b,{children:(0,A.jsxs)(C,{children:[(0,A.jsx)(x,{className:`w-20`,children:`Preview`}),(0,A.jsx)(x,{children:`File`}),(0,A.jsx)(x,{children:`Size`}),(0,A.jsx)(x,{children:`Uploaded`}),(0,A.jsx)(x,{className:`text-right`,children:`Actions`})]})}),(0,A.jsx)(S,{children:R.map(e=>(0,A.jsxs)(C,{children:[(0,A.jsx)(w,{children:e.mime_type.startsWith(`image/`)&&e.status===`committed`?(0,A.jsx)(`img`,{src:`${v()}/api/serve/${e.key}`,alt:``,loading:`lazy`,decoding:`async`,className:`h-12 w-16 rounded border object-cover`}):(0,A.jsx)(`div`,{className:`flex h-12 w-16 items-center justify-center rounded border text-muted-foreground`,children:(0,A.jsx)(m,{className:`size-5`})})}),(0,A.jsxs)(w,{children:[(0,A.jsx)(`div`,{className:`font-medium`,children:e.key.split(`/`).pop()}),(0,A.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:[(0,A.jsx)(D,{variant:`outline`,className:`capitalize`,children:e.feature}),e.status===`deleted`?(0,A.jsxs)(D,{variant:`destructive`,children:[`Deleted · removed `,new Date(new Date(e.deleted_at||e.created_at).getTime()+j*864e5).toLocaleDateString()]}):e.unused?(0,A.jsx)(D,{variant:`secondary`,children:`Unused`}):null]})]}),(0,A.jsx)(w,{className:`text-sm`,children:E(e.bytes)}),(0,A.jsxs)(w,{className:`text-xs text-muted-foreground`,children:[new Date(e.created_at).toLocaleString(),e.uploaded_by_name&&(0,A.jsx)(`span`,{className:`block`,children:e.uploaded_by_name})]}),(0,A.jsx)(w,{className:`text-right`,children:e.can_delete?e.status===`deleted`?(0,A.jsxs)(a,{variant:`outline`,size:`sm`,onClick:()=>void Y(e),children:[(0,A.jsx)(_,{className:`mr-1 size-4`}),` Undo`]}):(0,A.jsxs)(a,{variant:`destructive`,size:`sm`,onClick:()=>void q([e]),children:[(0,A.jsx)(g,{className:`mr-1 size-4`}),` Delete`]}):(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Uploader or Manager only`})})]},e.key))})]})}),I&&X>1&&(0,A.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,A.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Page `,W,` of `,X,` · `,I.total,` files`]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,A.jsx)(a,{variant:`outline`,size:`icon-xs`,"aria-label":`Previous page`,disabled:W<=1||B,onClick:()=>G(W-1),children:(0,A.jsx)(O,{className:`h-4 w-4`})}),Array.from({length:X},(e,t)=>t+1).filter(e=>e===1||e===X||Math.abs(e-W)<=2).reduce((e,t,n,r)=>(n>0&&t-r[n-1]>1&&e.push(`ellipsis`),e.push(t),e),[]).map((e,t)=>e===`ellipsis`?(0,A.jsx)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:`...`},`e-${t}`):(0,A.jsx)(a,{variant:e===W?`default`:`outline`,size:`icon-xs`,"aria-current":e===W?`page`:void 0,disabled:B,onClick:()=>G(e),className:e===W?``:`text-muted-foreground`,children:e},e)),(0,A.jsx)(a,{variant:`outline`,size:`icon-xs`,"aria-label":`Next page`,disabled:W>=X||B,onClick:()=>G(W+1),children:(0,A.jsx)(f,{className:`h-4 w-4`})})]})]})]}),(0,A.jsx)(p,{isOpen:H!==null,title:`Delete from Library?`,message:H?.message??``,confirmText:`Delete`,onConfirm:()=>void J(),onCancel:()=>U(null)})]})}export{P as LibraryRoute};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{n as r}from"./dist-D0tkMM_Y.js";import{c as i}from"./chunk-BV7QT456-CCzugQp2.js";import{t as a}from"./button-D2dALS3q.js";import{i as o,n as s,o as c,s as l,t as u}from"./select-xSghKb2x.js";import{t as d}from"./arrow-left-Cfq6LFs7.js";import{s as f}from"./useField-F6rVNyMc.js";import{t as p}from"./ConfirmModal-DqvHDAUo.js";import{t as m}from"./file-image-C1wgTBuF.js";import{t as h}from"./refresh-cw-Bmpxlvmc.js";import{t as g}from"./trash-2-BmZK7fDJ.js";import{t as _}from"./undo-2-FZYgYKq2.js";import{a as v,n as y}from"./api-BAQH6VUv.js";import{a as b,i as x,n as S,o as C,r as w,t as T}from"./table-Bs3EelYM.js";import{Q as E,Z as D,Zn as O}from"./index-BL-qAtdL.js";var k=e(t(),1),A=n(),j=30,M={all:`All files`,unused:`Unused only`},N={size:`Largest first`,date:`Newest first`};function P(){let e=i(),[t,n]=(0,k.useState)(`all`),[P,F]=(0,k.useState)(`size`),[I,L]=(0,k.useState)(null),[R,z]=(0,k.useState)([]),[B,V]=(0,k.useState)(!0),[H,U]=(0,k.useState)(null),[W,G]=(0,k.useState)(1),K=(0,k.useCallback)(async e=>{V(!0);try{let n=await y(`/api/library?filter=${t}&sort=${P}&page=${e}`);if(!n.ok)throw Error();let r=await n.json();if(L(r),r.items.length===0&&e>1){G(e-1);return}z(r.items)}catch{r.error(`The Library could not be loaded.`)}finally{V(!1)}},[t,P]);(0,k.useEffect)(()=>{K(W)},[K,W]);let q=async e=>{if(e.length===1){let t=await(await y(`/api/library/usage?key=${encodeURIComponent(e[0].key)}`)).json().catch(()=>({documents:[]}));if(t.documents?.length){let e=t.documents.map(e=>e.title+(e.isDeleted?` (in Trash)`:``)).join(`, `);r.error(`This image is still used by: ${e}. Remove it from those documents first.`);return}}U({items:e,message:`${e.length===1?`This image`:`${e.length} unused images`} will stop counting toward storage now and be removed for good after ${j} days. You can undo until then.`})},J=async()=>{let e=H?.items??[];U(null);let t=0;for(let n of e)(await y(`/api/library`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:n.key})})).ok||t++;t?r.error(`${t} image${t===1?` is`:`s are`} still in use and ${t===1?`was`:`were`} kept.`):r.success(e.length===1?`Image deleted`:`Unused images deleted`),K(W)},Y=async e=>{let t=await y(`/api/library/restore`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:e.key})}),n=await t.json().catch(()=>({}));if(!t.ok){r.error(n.error||`The image could not be restored.`);return}r.success(`Image restored`),K(W)},X=I?Math.max(1,Math.ceil(I.total/I.page_size)):1,Z=R.filter(e=>e.unused&&e.status===`committed`&&e.can_delete);return(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border bg-background`,children:[(0,A.jsx)(`div`,{className:`shrink-0 border-b p-6`,children:(0,A.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(a,{variant:`ghost`,size:`sm`,className:`-ml-2 mb-2`,onClick:()=>e(-1),children:[(0,A.jsx)(d,{className:`mr-1 size-4`}),` Back`]}),(0,A.jsxs)(`h2`,{className:`flex items-center gap-2 text-2xl font-bold`,children:[(0,A.jsx)(m,{className:`size-6 text-muted-foreground`}),` Library`]}),(0,A.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Files uploaded to `,I?.scope===`user`?`your Personal Workspace`:`this Team workspace by all members`,`. Unused files still count toward storage until deleted.`]})]}),(0,A.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,A.jsxs)(u,{value:t,onValueChange:e=>{e&&(n(e),G(1))},children:[(0,A.jsx)(c,{size:`sm`,"aria-label":`Filter`,className:`w-32`,children:(0,A.jsx)(l,{children:M[t]})}),(0,A.jsxs)(s,{children:[(0,A.jsx)(o,{value:`all`,children:M.all}),(0,A.jsx)(o,{value:`unused`,children:M.unused})]})]}),(0,A.jsxs)(u,{value:P,onValueChange:e=>{e&&(F(e),G(1))},children:[(0,A.jsx)(c,{size:`sm`,"aria-label":`Sort`,className:`w-36`,children:(0,A.jsx)(l,{children:N[P]})}),(0,A.jsxs)(s,{children:[(0,A.jsx)(o,{value:`size`,children:N.size}),(0,A.jsx)(o,{value:`date`,children:N.date})]})]}),(0,A.jsxs)(a,{variant:`outline`,size:`sm`,onClick:()=>void K(W),disabled:B,children:[(0,A.jsx)(h,{className:`mr-1 size-4 ${B?`animate-spin`:``}`}),` Refresh`]}),I?.can_bulk_delete&&Z.length>0&&(0,A.jsxs)(a,{variant:`destructive`,size:`sm`,onClick:()=>void q(Z),children:[(0,A.jsx)(g,{className:`mr-1 size-4`}),` Delete unused (`,Z.length,`)`]})]})]})}),(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-6 custom-scrollbar`,children:[R.length===0?!B&&(0,A.jsx)(`div`,{className:`rounded-lg border border-dashed py-12 text-center text-muted-foreground`,children:t===`unused`?`No unused files.`:`No files uploaded yet.`}):(0,A.jsx)(`div`,{className:`overflow-hidden rounded-lg border`,children:(0,A.jsxs)(T,{children:[(0,A.jsx)(b,{children:(0,A.jsxs)(C,{children:[(0,A.jsx)(x,{className:`w-20`,children:`Preview`}),(0,A.jsx)(x,{children:`File`}),(0,A.jsx)(x,{children:`Size`}),(0,A.jsx)(x,{children:`Uploaded`}),(0,A.jsx)(x,{className:`text-right`,children:`Actions`})]})}),(0,A.jsx)(S,{children:R.map(e=>(0,A.jsxs)(C,{children:[(0,A.jsx)(w,{children:e.mime_type.startsWith(`image/`)&&e.status===`committed`?(0,A.jsx)(`img`,{src:`${v()}/api/serve/${e.key}`,alt:``,loading:`lazy`,decoding:`async`,className:`h-12 w-16 rounded border object-cover`}):(0,A.jsx)(`div`,{className:`flex h-12 w-16 items-center justify-center rounded border text-muted-foreground`,children:(0,A.jsx)(m,{className:`size-5`})})}),(0,A.jsxs)(w,{children:[(0,A.jsx)(`div`,{className:`font-medium`,children:e.key.split(`/`).pop()}),(0,A.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:[(0,A.jsx)(D,{variant:`outline`,className:`capitalize`,children:e.feature}),e.status===`deleted`?(0,A.jsxs)(D,{variant:`destructive`,children:[`Deleted · removed `,new Date(new Date(e.deleted_at||e.created_at).getTime()+j*864e5).toLocaleDateString()]}):e.unused?(0,A.jsx)(D,{variant:`secondary`,children:`Unused`}):null]})]}),(0,A.jsx)(w,{className:`text-sm`,children:E(e.bytes)}),(0,A.jsxs)(w,{className:`text-xs text-muted-foreground`,children:[new Date(e.created_at).toLocaleString(),e.uploaded_by_name&&(0,A.jsx)(`span`,{className:`block`,children:e.uploaded_by_name})]}),(0,A.jsx)(w,{className:`text-right`,children:e.can_delete?e.status===`deleted`?(0,A.jsxs)(a,{variant:`outline`,size:`sm`,onClick:()=>void Y(e),children:[(0,A.jsx)(_,{className:`mr-1 size-4`}),` Undo`]}):(0,A.jsxs)(a,{variant:`destructive`,size:`sm`,onClick:()=>void q([e]),children:[(0,A.jsx)(g,{className:`mr-1 size-4`}),` Delete`]}):(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Uploader or Manager only`})})]},e.key))})]})}),I&&X>1&&(0,A.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,A.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Page `,W,` of `,X,` · `,I.total,` files`]}),(0,A.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,A.jsx)(a,{variant:`outline`,size:`icon-xs`,"aria-label":`Previous page`,disabled:W<=1||B,onClick:()=>G(W-1),children:(0,A.jsx)(O,{className:`h-4 w-4`})}),Array.from({length:X},(e,t)=>t+1).filter(e=>e===1||e===X||Math.abs(e-W)<=2).reduce((e,t,n,r)=>(n>0&&t-r[n-1]>1&&e.push(`ellipsis`),e.push(t),e),[]).map((e,t)=>e===`ellipsis`?(0,A.jsx)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:`...`},`e-${t}`):(0,A.jsx)(a,{variant:e===W?`default`:`outline`,size:`icon-xs`,"aria-current":e===W?`page`:void 0,disabled:B,onClick:()=>G(e),className:e===W?``:`text-muted-foreground`,children:e},e)),(0,A.jsx)(a,{variant:`outline`,size:`icon-xs`,"aria-label":`Next page`,disabled:W>=X||B,onClick:()=>G(W+1),children:(0,A.jsx)(f,{className:`h-4 w-4`})})]})]})]}),(0,A.jsx)(p,{isOpen:H!==null,title:`Delete from Library?`,message:H?.message??``,confirmText:`Delete`,onConfirm:()=>void J(),onCancel:()=>U(null)})]})}export{P as LibraryRoute};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/NotesView-C15bRZV2.js","assets/rolldown-runtime-C0FnF6B9.js","assets/jsx-runtime-DSr1VPkp.js","assets/dist-D0tkMM_Y.js","assets/preload-helper-Czpn1I53.js","assets/chunk-BV7QT456-CCzugQp2.js","assets/createLucideIcon-CyOWwA0s.js","assets/alert-dialog-DK2RCz-0.js","assets/useBaseUiId-r-qiwcia.js","assets/button-D2dALS3q.js","assets/dropdown-menu-BrGjsCp0.js","assets/useOnFirstRender-1giFodLk.js","assets/select-xSghKb2x.js","assets/floating-ui.react-dom-OhALwEl4.js","assets/CompositeList-l_GSXRZM.js","assets/check-Uq0GkTkz.js","assets/useField-F6rVNyMc.js","assets/useControlled-CwUHqyRq.js","assets/useCompositeItem-DgcRHBrd.js","assets/CommentThreadView-Dx7ndjrK.js","assets/dialog-EJdgZKa4.js","assets/api-BAQH6VUv.js","assets/link-2-C71ROdND.js","assets/arrow-left-Cfq6LFs7.js","assets/ConfirmModal-DqvHDAUo.js","assets/wand-sparkles-DfkrzvIR.js","assets/calendar-76sQ3D4f.js","assets/note-importer-DPPovz0N.js","assets/image-compression-DagnqRIG.js","assets/index-4mHBF5P6.js","assets/downloadSVG-C2LckkLx.js","assets/esm-B1WURL1q.js","assets/src-B-DeWB10.js","assets/value-Cwm0ChEK.js","assets/vanilla--C5Lp_AM.js","assets/copy-CIp5gOrB.js","assets/hard-drive-B6OfPqtv.js","assets/w3c-keyname-CHFwa9la.js","assets/input-BUIkeoB3.js","assets/plus-DfXp3YpY.js","assets/refresh-cw-Bmpxlvmc.js","assets/sparkles-BKYYqRE2.js","assets/trash-2-BmZK7fDJ.js","assets/card-DFJ6ytRY.js","assets/checkbox-CFF_zUIN.js","assets/minus-d4YlhnV9.js","assets/table-Bs3EelYM.js","assets/fileOwnership-DvxzSccE.js","assets/WorkspaceProvider-Te7g31uC.js","assets/localPersistence-CjYRImp1.js","assets/useAuth-CQkE8axg.js","assets/diagramVersioning-BcJWSqo3.js","assets/dist-js-DXG5pDMi.js","assets/core-DNaw6KYU.js","assets/WorkspaceContext-O7njKDwj.js","assets/label-CCjvjYto.js","assets/textarea-D2E-6RLc.js","assets/extends-CvVTau-c.js","assets/index-CpmJMylY.css","assets/file-image-C1wgTBuF.js","assets/image-rU2A9CMJ.js","assets/move-BzTcfKj2.js","assets/hover-card-CqLOdc_X.js","assets/refresh-ccw-otI6Z4JU.js","assets/undo-2-FZYgYKq2.js","assets/user-x-Drb9lgxy.js","assets/user-cog-DrTVVVeT.js","assets/Combination-2TXYfiVJ.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{l as i,u as a}from"./chunk-BV7QT456-CCzugQp2.js";import{t as o}from"./createLucideIcon-CyOWwA0s.js";import"./WorkspaceProvider-Te7g31uC.js";import{n as s}from"./WorkspaceContext-O7njKDwj.js";import{t as c}from"./ProjectFileTabs-7LRUbYsP.js";var l=o(`file-question-mark`,[[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z`,key:`1mlx9k`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}]]),u=e(t(),1),d=n(),f=u.lazy(()=>r(()=>import(`./NotesView-C15bRZV2.js`).then(e=>({default:e.NotesView})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67])));function p(){let e=s(),t=i(),{id:n}=a(),{activeNote:r,activeNoteUid:o,saveNote:p,handleNoteChange:m,deleteNote:h,isPublicView:g,isLoading:_,isNoteItemLoading:v,handleNoteSelect:y}=e,b=(0,u.useRef)(!1);(0,u.useEffect)(()=>{if(!(g||!n)&&!b.current){if(o===n){b.current=!0;return}o||(b.current=!0,y(n))}},[n,o,g,y]);let x=r?.project_id??r?.projectId,S=e.projects.find(e=>String(e.id)===String(x)),C=S?.team_id??S?.teamId,w=!g&&!e.isGuest&&e.getFileAccessRole(r)!==`viewer`&&C&&t?.activeTeamId&&String(C)===String(t.activeTeamId)&&r?.uid?{projectId:String(x),teamId:String(t.activeTeamId),featureType:`note`,fileId:String(r.uid)}:null;return!g&&!o?n&&!b.current?(0,d.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:[(0,d.jsx)(`div`,{className:`w-6 h-6 border-2 border-primary/30 border-t-primary rounded-full animate-spin`}),(0,d.jsx)(`p`,{className:`mt-4 text-sm font-medium text-muted-foreground animate-pulse`,children:`Loading note...`})]}):(0,d.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:(0,d.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:`Select a note to view`})}):!r&&!v?(0,d.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:[(0,d.jsx)(l,{className:`w-12 h-12 text-muted-foreground/40 mb-4`}),(0,d.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:`Note not found`}),(0,d.jsx)(`p`,{className:`text-xs text-muted-foreground/60 mt-1`,children:`This note may have been deleted or is no longer available.`})]}):r?(0,d.jsxs)(`div`,{className:`flex flex-col flex-1 overflow-hidden`,children:[(0,d.jsx)(c,{currentView:`notes`}),(0,d.jsx)(u.Suspense,{fallback:(0,d.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,d.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,d.jsx)(`div`,{className:`w-6 h-6 border-2 border-primary/30 border-t-primary rounded-full animate-spin`}),(0,d.jsx)(`span`,{className:`text-xs text-muted-foreground/60 animate-pulse`,children:`Loading note...`})]})}),children:(0,d.jsx)(f,{isLoading:v,activeNoteUid:g?null:o,activeNote:r,saveNote:p,handleNoteChange:m,deleteNote:h,isReadOnly:g||e.isReadOnlyFile(r),commentFile:w})})]}):(0,d.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:[(0,d.jsx)(`div`,{className:`w-6 h-6 border-2 border-primary/30 border-t-primary rounded-full animate-spin`}),(0,d.jsx)(`p`,{className:`mt-4 text-sm font-medium text-muted-foreground animate-pulse`,children:`Loading note...`})]})}export{p as NoteEditorRoute,l as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/NotesView-t2i5YEBB.js","assets/rolldown-runtime-C0FnF6B9.js","assets/jsx-runtime-DSr1VPkp.js","assets/dist-D0tkMM_Y.js","assets/preload-helper-Czpn1I53.js","assets/chunk-BV7QT456-CCzugQp2.js","assets/createLucideIcon-CyOWwA0s.js","assets/alert-dialog-DK2RCz-0.js","assets/useBaseUiId-r-qiwcia.js","assets/button-D2dALS3q.js","assets/dropdown-menu-BrGjsCp0.js","assets/useOnFirstRender-1giFodLk.js","assets/select-xSghKb2x.js","assets/floating-ui.react-dom-OhALwEl4.js","assets/CompositeList-l_GSXRZM.js","assets/check-Uq0GkTkz.js","assets/useField-F6rVNyMc.js","assets/useControlled-CwUHqyRq.js","assets/useCompositeItem-DgcRHBrd.js","assets/CommentThreadView-Dx7ndjrK.js","assets/dialog-EJdgZKa4.js","assets/api-BAQH6VUv.js","assets/link-2-C71ROdND.js","assets/arrow-left-Cfq6LFs7.js","assets/ConfirmModal-DqvHDAUo.js","assets/wand-sparkles-DfkrzvIR.js","assets/calendar-Bjc1jNFb.js","assets/note-importer-bjC4Q04B.js","assets/image-compression-DagnqRIG.js","assets/index-BL-qAtdL.js","assets/downloadSVG-C2LckkLx.js","assets/esm-B1WURL1q.js","assets/src-B-DeWB10.js","assets/value-Cwm0ChEK.js","assets/vanilla--C5Lp_AM.js","assets/copy-CIp5gOrB.js","assets/hard-drive-B6OfPqtv.js","assets/w3c-keyname-CHFwa9la.js","assets/input-BUIkeoB3.js","assets/plus-DfXp3YpY.js","assets/refresh-cw-Bmpxlvmc.js","assets/sparkles-BKYYqRE2.js","assets/trash-2-BmZK7fDJ.js","assets/card-DFJ6ytRY.js","assets/checkbox-CFF_zUIN.js","assets/minus-d4YlhnV9.js","assets/table-Bs3EelYM.js","assets/fileOwnership-DvxzSccE.js","assets/WorkspaceProvider-Dc-LU3z8.js","assets/localPersistence-CjYRImp1.js","assets/useAuth-CQkE8axg.js","assets/diagramVersioning-BcJWSqo3.js","assets/dist-js-DXG5pDMi.js","assets/core-DNaw6KYU.js","assets/WorkspaceContext-O7njKDwj.js","assets/label-CCjvjYto.js","assets/textarea-D2E-6RLc.js","assets/extends-CvVTau-c.js","assets/index-CpmJMylY.css","assets/file-image-C1wgTBuF.js","assets/image-rU2A9CMJ.js","assets/move-BzTcfKj2.js","assets/hover-card-CqLOdc_X.js","assets/refresh-ccw-otI6Z4JU.js","assets/undo-2-FZYgYKq2.js","assets/user-x-Drb9lgxy.js","assets/user-cog-DrTVVVeT.js","assets/Combination-vqN0XDK-.js"])))=>i.map(i=>d[i]);
2
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{l as i,u as a}from"./chunk-BV7QT456-CCzugQp2.js";import{t as o}from"./createLucideIcon-CyOWwA0s.js";import"./WorkspaceProvider-Dc-LU3z8.js";import{n as s}from"./WorkspaceContext-O7njKDwj.js";import{t as c}from"./ProjectFileTabs-Brr9j8Tz.js";var l=o(`file-question-mark`,[[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z`,key:`1mlx9k`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}]]),u=e(t(),1),d=n(),f=u.lazy(()=>r(()=>import(`./NotesView-t2i5YEBB.js`).then(e=>({default:e.NotesView})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67])));function p(){let e=s(),t=i(),{id:n}=a(),{activeNote:r,activeNoteUid:o,saveNote:p,handleNoteChange:m,deleteNote:h,isPublicView:g,isLoading:_,isNoteItemLoading:v,handleNoteSelect:y}=e,b=(0,u.useRef)(!1);(0,u.useEffect)(()=>{if(!(g||!n)&&!b.current){if(o===n){b.current=!0;return}o||(b.current=!0,y(n))}},[n,o,g,y]);let x=r?.project_id??r?.projectId,S=e.projects.find(e=>String(e.id)===String(x)),C=S?.team_id??S?.teamId,w=!g&&!e.isGuest&&e.getFileAccessRole(r)!==`viewer`&&C&&t?.activeTeamId&&String(C)===String(t.activeTeamId)&&r?.uid?{projectId:String(x),teamId:String(t.activeTeamId),featureType:`note`,fileId:String(r.uid)}:null;return!g&&!o?n&&!b.current?(0,d.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:[(0,d.jsx)(`div`,{className:`w-6 h-6 border-2 border-primary/30 border-t-primary rounded-full animate-spin`}),(0,d.jsx)(`p`,{className:`mt-4 text-sm font-medium text-muted-foreground animate-pulse`,children:`Loading note...`})]}):(0,d.jsx)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:(0,d.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:`Select a note to view`})}):!r&&!v?(0,d.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:[(0,d.jsx)(l,{className:`w-12 h-12 text-muted-foreground/40 mb-4`}),(0,d.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:`Note not found`}),(0,d.jsx)(`p`,{className:`text-xs text-muted-foreground/60 mt-1`,children:`This note may have been deleted or is no longer available.`})]}):r?(0,d.jsxs)(`div`,{className:`flex flex-col flex-1 overflow-hidden`,children:[(0,d.jsx)(c,{currentView:`notes`}),(0,d.jsx)(u.Suspense,{fallback:(0,d.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,d.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,d.jsx)(`div`,{className:`w-6 h-6 border-2 border-primary/30 border-t-primary rounded-full animate-spin`}),(0,d.jsx)(`span`,{className:`text-xs text-muted-foreground/60 animate-pulse`,children:`Loading note...`})]})}),children:(0,d.jsx)(f,{isLoading:v,activeNoteUid:g?null:o,activeNote:r,saveNote:p,handleNoteChange:m,deleteNote:h,isReadOnly:g||e.isReadOnlyFile(r),commentFile:w})})]}):(0,d.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center border rounded-xl bg-muted/10`,children:[(0,d.jsx)(`div`,{className:`w-6 h-6 border-2 border-primary/30 border-t-primary rounded-full animate-spin`}),(0,d.jsx)(`p`,{className:`mt-4 text-sm font-medium text-muted-foreground animate-pulse`,children:`Loading note...`})]})}export{p as NoteEditorRoute,l as t};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FlowchartView-esgoLO4T.js","assets/rolldown-runtime-C0FnF6B9.js","assets/jsx-runtime-DSr1VPkp.js","assets/dist-D0tkMM_Y.js","assets/downloadSVG-C2LckkLx.js","assets/esm-B1WURL1q.js","assets/src-B-DeWB10.js","assets/value-Cwm0ChEK.js","assets/vanilla--C5Lp_AM.js","assets/button-D2dALS3q.js","assets/createLucideIcon-CyOWwA0s.js","assets/select-xSghKb2x.js","assets/alert-dialog-DK2RCz-0.js","assets/useBaseUiId-r-qiwcia.js","assets/useOnFirstRender-1giFodLk.js","assets/floating-ui.react-dom-OhALwEl4.js","assets/CompositeList-l_GSXRZM.js","assets/check-Uq0GkTkz.js","assets/useField-F6rVNyMc.js","assets/useControlled-CwUHqyRq.js","assets/CommentThreadView-Dx7ndjrK.js","assets/dropdown-menu-BrGjsCp0.js","assets/useCompositeItem-DgcRHBrd.js","assets/dialog-EJdgZKa4.js","assets/api-BAQH6VUv.js","assets/preload-helper-Czpn1I53.js","assets/move-BzTcfKj2.js","assets/hover-card-CqLOdc_X.js","assets/plus-DfXp3YpY.js","assets/trash-2-BmZK7fDJ.js","assets/undo-2-FZYgYKq2.js","assets/card-DFJ6ytRY.js","assets/input-BUIkeoB3.js","assets/WorkspaceContext-O7njKDwj.js","assets/label-CCjvjYto.js","assets/index-4mHBF5P6.js","assets/chunk-BV7QT456-CCzugQp2.js","assets/link-2-C71ROdND.js","assets/arrow-left-Cfq6LFs7.js","assets/ConfirmModal-DqvHDAUo.js","assets/wand-sparkles-DfkrzvIR.js","assets/copy-CIp5gOrB.js","assets/hard-drive-B6OfPqtv.js","assets/w3c-keyname-CHFwa9la.js","assets/refresh-cw-Bmpxlvmc.js","assets/sparkles-BKYYqRE2.js","assets/checkbox-CFF_zUIN.js","assets/minus-d4YlhnV9.js","assets/table-Bs3EelYM.js","assets/fileOwnership-DvxzSccE.js","assets/WorkspaceProvider-Te7g31uC.js","assets/note-importer-DPPovz0N.js","assets/image-compression-DagnqRIG.js","assets/localPersistence-CjYRImp1.js","assets/useAuth-CQkE8axg.js","assets/diagramVersioning-BcJWSqo3.js","assets/dist-js-DXG5pDMi.js","assets/core-DNaw6KYU.js","assets/textarea-D2E-6RLc.js","assets/extends-CvVTau-c.js","assets/index-CpmJMylY.css","assets/ERDComments-C8HbR05_.js","assets/ERDComments-CHpVij2M.css","assets/JumpToNode-Cu3WQt8p.js","assets/ExcalidrawEditor-BJMZ2z1D.js","assets/Combination-2TXYfiVJ.js","assets/FileCommentMarkers-DIo-MSED.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{n as r}from"./dist-D0tkMM_Y.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{_ as a,d as o,h as s,l as c,u as l,v as u,y as d}from"./downloadSVG-C2LckkLx.js";import{ct as ee,h as te,r as ne,t as f}from"./esm-B1WURL1q.js";import{U as p}from"./alert-dialog-DK2RCz-0.js";import{t as m}from"./button-D2dALS3q.js";import{n as re}from"./calendar-76sQ3D4f.js";import{M as ie}from"./hover-card-CqLOdc_X.js";import{t as ae}from"./plus-DfXp3YpY.js";import{n as h}from"./api-BAQH6VUv.js";import{v as g}from"./WorkspaceProvider-Te7g31uC.js";import{E as _,a as v}from"./note-importer-DPPovz0N.js";import{t as y}from"./localPersistence-CjYRImp1.js";import{n as b}from"./WorkspaceContext-O7njKDwj.js";import{I as oe,S as se,en as x}from"./index-4mHBF5P6.js";import"./ERDComments-C8HbR05_.js";import{a as S,i as C,n as w,o as T,r as E,s as D,t as O}from"./erd-edge-style-DW4fkZXn.js";var k=e(t(),1);function A(e){if(!e)return null;try{return typeof e==`string`?JSON.parse(e):e}catch{return null}}function j(e){return{...e,id:String(e.id),is_pk:e.is_pk??e.isPk??!1,is_nullable:e.is_nullable??e.isNullable??!0,is_unique:e.is_unique??e.isUnique??!1,default_value:e.default_value??e.defaultValue??null,enum_values:e.enum_values??e.enumValues??``,max_length:e.max_length??e.maxLength??null,numeric_precision:e.numeric_precision??e.numericPrecision??null,numeric_scale:e.numeric_scale??e.numericScale??null,sort_order:e.sort_order??e.sortOrder??0}}function M(e){let t=e.data??e,n=String(e.id??t.id),r=e.position?.x??e.x??t.x??0,i=e.position?.y??e.y??t.y??0;return{id:n,type:`entity`,position:{x:r,y:i},data:{...t,_notesCompanion:!0,id:n,name:t.name??e.name??`Untitled`,x:r,y:i,color:t.color??e.color??`#6366f1`,columns:(t.columns??e.columns??[]).map(j)}}}function ce(e){let t=A(e.data),n=Array.isArray(e.entities)&&e.entities.length?e.entities:Array.isArray(t?.nodes)?t.nodes:[],r=Array.isArray(e.relationships)&&e.relationships.length?e.relationships:Array.isArray(t?.edges)?t.edges:[],i=n.map(M),a=new Map(i.map(e=>[e.id,e]));return{nodes:i,edges:r.map(e=>{let t=String(e.source??e.source_entity_id??e.sourceEntityId??``),n=String(e.target??e.target_entity_id??e.targetEntityId??``),r=e.sourceHandle??e.source_handle??e.sourceColumnId??e.source_column_id,i=e.targetHandle??e.target_handle??e.targetColumnId??e.target_column_id,o=a.get(t),s=a.get(n),c=(o?.position.x??0)<(s?.position.x??0),l=String(r||``).startsWith(`col-`)?r:r?`col-${r}-${c?`source`:`source-l`}`:void 0,u=String(i||``).startsWith(`col-`)?i:i?`col-${i}-${c?`target`:`target-r`}`:void 0;return{...e,id:String(e.id),source:t,target:n,sourceHandle:l,targetHandle:u,label:e.label,type:e.type??`smoothstep`,data:{...e.data||{},on_delete:e.on_delete??e.onDelete,on_update:e.on_update??e.onUpdate,constraint_name:e.constraint_name??e.constraintName}}})}}function N(e,t){return O(e,t?[t]:[])}var P=n(),F={entity:T},I=(0,k.lazy)(()=>i(()=>import(`./FlowchartView-esgoLO4T.js`).then(e=>({default:e.FlowchartView})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63]))),L=(0,k.lazy)(()=>i(()=>import(`./ExcalidrawEditor-BJMZ2z1D.js`),__vite__mapDeps([64,1,2,3,25,8,9,10,15,24,52,33,59,35,36,4,5,6,7,12,13,14,21,11,16,17,18,19,22,20,23,37,38,39,40,41,42,43,32,28,44,45,29,31,46,47,48,49,50,51,53,54,55,56,57,34,58,60,65,66])));async function R(e,t,n){if(n){let n=e===`erd`?`erd`:e===`flowchart`?`flowchart`:`drawings`;return await y.getResource(t)||((await y.getAllResources(n)).find(e=>String(e.uid??e.id)===t)??null)}let r=await h(`/api/${e===`erd`?`diagrams`:e===`flowchart`?`flowcharts`:`drawings`}/${t}`);return r.ok?r.json():null}function z({document:e,previewSchema:t,previewKey:n}){let i=(0,k.useMemo)(()=>ce(e),[e]),{isGuest:s,resolvedTheme:p}=b(),[x,T]=(0,k.useState)(i.nodes),[O,A]=(0,k.useState)(i.edges),[j,M]=(0,k.useState)(null),[I,L]=(0,k.useState)(null),[R,z]=(0,k.useState)(null),[B,V]=(0,k.useState)([]),[H,U]=(0,k.useState)(!1),W=(0,k.useRef)(x),G=(0,k.useRef)(O),K=(0,k.useRef)(null),q=(0,k.useMemo)(()=>g(e),[e]),J=q??{x:0,y:0,zoom:1},Y=(0,k.useRef)(J);W.current=x,G.current=O;let X=(0,k.useCallback)((t,n)=>{K.current&&clearTimeout(K.current),K.current=setTimeout(async()=>{let i=t.map(e=>({...e.data,x:e.position.x,y:e.position.y})),a=n.map(_),o=v(t,n);try{if(s){let t=await y.getResource(e.uid??e.id);t&&await y.saveResource({...t,entities:i,relationships:a,data:null,dbml_source:o,viewport_x:Y.current.x,viewport_y:Y.current.y,viewport_zoom:Y.current.zoom,updated_at:new Date().toISOString()})}else if(!(await h(`/api/diagrams/save/${e.uid??e.id}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({entities:i,relationships:a,viewport:Y.current,data:null,dbmlSource:o})})).ok)throw Error()}catch{r.error(`Could not save ERD changes`)}},350)},[e.id,e.uid,s]);(0,k.useEffect)(()=>{if(!(!t||!n))try{let e=re(W.current,G.current,`erd-generate-sql`,t);if(!e)throw Error();let n=C(W.current,G.current,e.nodes,e.edges);if(n.changes.length===0){z(null),r.success(`No schema changes found`);return}M(null),L(null),V(n.changes.map(e=>e.id)),U(!1),z({originalNodes:W.current,originalEdges:G.current,proposedNodes:e.nodes,proposedEdges:e.edges,result:n})}catch{r.error(`Could not parse the schema for diff`)}},[n,t]);let le=(0,k.useCallback)(()=>{if(!R)return;let e=E(R.originalNodes,R.originalEdges,R.proposedNodes,R.proposedEdges,R.result,B);T(e.nodes),A(e.edges),z(null),X(e.nodes,e.edges),r.success(`Schema changes merged successfully`)},[B,R,X]),ue=(0,k.useCallback)(e=>{let t=u(e,W.current);T(t),e.some(e=>e.type!==`select`&&e.type!==`dimensions`)&&X(t,G.current)},[X]),de=(0,k.useCallback)(e=>{let t=a(e,G.current);A(t),e.some(e=>e.type!==`select`)&&X(W.current,t)},[X]),fe=(0,k.useCallback)(e=>{let t=te({...e,id:crypto.randomUUID(),type:`smoothstep`,label:`1:N`},G.current);A(t),X(W.current,t)},[X]),pe=(0,k.useCallback)((e,t)=>{let n=typeof t==`string`?{label:t}:t,r=G.current.map(t=>t.id===e?{...t,...n,data:{...t.data||{},...n.data||{}}}:t);A(r),X(W.current,r)},[X]),me=(0,k.useCallback)(e=>{let t=e=>e&&(e.endsWith(`-source`)?e.replace(/-source$/,`-source-l`):e.endsWith(`-source-l`)?e.replace(/-source-l$/,`-source`):e.endsWith(`-target`)?e.replace(/-target$/,`-target-r`):e.endsWith(`-target-r`)?e.replace(/-target-r$/,`-target`):e),n=G.current.map(n=>n.id===e?{...n,sourceHandle:t(n.sourceHandle),targetHandle:t(n.targetHandle)}:n);A(n),X(W.current,n)},[X]),he=(0,k.useCallback)(e=>{let t=G.current.filter(t=>t.id!==e);A(t),L(null),X(W.current,t)},[X]),ge=(0,k.useCallback)((e,t)=>{let n=e=>e?.replace(/^col-/,``).replace(/-(source|target)(-(l|r))?$/,``);if(!t.sourceHandle||!t.targetHandle)return;if(String(t.source)!==String(e.source)||String(t.target)!==String(e.target)||n(t.sourceHandle)!==n(e.sourceHandle)||n(t.targetHandle)!==n(e.targetHandle)){r.info(`Only the connector position can be changed`);return}let i=(e,t)=>{let r=n(t);return W.current.find(t=>String(t.id)===String(e))?.data.columns.find(e=>String(e.id)===String(r))},a=i(t.source,t.sourceHandle),o=i(t.target,t.targetHandle);if(a&&o&&a.type!==o.type){r.error(`Type Mismatch`,{description:`Cannot reconnect ${a.type} to ${o.type}`});return}let s=ee(e,t,G.current);A(s),X(W.current,s)},[X]),_e=(0,k.useCallback)(e=>{let t=W.current.map(t=>t.id===e.id?{...t,data:e}:t);T(t),X(t,G.current)},[X]),ve=(0,k.useCallback)(e=>{let t=W.current.filter(t=>t.id!==e),n=G.current.filter(t=>t.source!==e&&t.target!==e);T(t),A(n),M(null),X(t,n)},[X]),ye=(0,k.useCallback)(()=>{let e=crypto.randomUUID(),t={id:e,name:`new_table`,x:80,y:80,color:`#6366f1`,columns:[]},n=[...W.current,{id:e,type:`entity`,position:{x:80,y:80},data:t}];T(n),M(e),X(n,G.current)},[X]),be=(0,k.useCallback)(()=>{if(W.current.length===0)return;let e=S(W.current,G.current);T(e),X(e,G.current)},[X]),xe=(0,k.useCallback)((e,t)=>{Y.current=t},[]),Z=(0,k.useCallback)((e,t)=>{Y.current=t,e&&X(W.current,G.current)},[X]);(0,k.useEffect)(()=>{let e=e=>M(e.detail?.id??null);return window.addEventListener(D,e),()=>window.removeEventListener(D,e)},[]);let Q=x.find(e=>e.id===j)?.data??null,Se=O.find(e=>e.id===I)??null,Ce=p===`dark`?`#222`:`#ccc`,$=(0,k.useMemo)(()=>({type:`smoothstep`,animated:!1,reconnectable:!0,style:{stroke:`var(--edge-color)`,strokeWidth:2},markerEnd:{type:ne.Arrow,color:`var(--edge-color)`,width:10,height:10}}),[]),we=(0,k.useMemo)(()=>x.map(e=>{let t=e.id===j;return!!e.selected===t?e:{...e,selected:t}}),[x,j]),Te=(0,k.useMemo)(()=>N(O,j),[O,j]),Ee=(0,k.useMemo)(()=>R?N(R.result.edges,null):[],[R]),De=(0,k.useMemo)(()=>R?.result.nodes.map(e=>({...e,data:{...e.data,isDiffMode:!0}}))??[],[R]);return(0,P.jsxs)(`div`,{className:`relative h-full min-h-0 overflow-hidden bg-background`,children:[(0,P.jsxs)(d,{nodes:R?De:we,edges:R?Ee:Te,nodeTypes:F,onNodesChange:ue,onEdgesChange:de,onConnect:fe,onReconnect:ge,nodesDraggable:!R,nodesConnectable:!R,elementsSelectable:!R,edgesReconnectable:!R,defaultEdgeOptions:$,onNodeClick:(e,t)=>{L(null),M(t.id)},onNodeDoubleClick:(e,t)=>{L(null),M(t.id)},onEdgeClick:(e,t)=>{M(null),L(t.id)},onPaneClick:()=>{M(null),L(null)},onMove:xe,onMoveEnd:Z,colorMode:p,connectionLineType:f.SmoothStep,connectionLineStyle:$.style,onlyRenderVisibleElements:!0,defaultViewport:J,fitView:!q,children:[(0,P.jsx)(c,{variant:l.Lines,gap:50,size:1,color:Ce}),(0,P.jsx)(o,{position:`bottom-left`,showInteractive:!1})]}),!R&&(0,P.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-3 z-10 flex justify-center`,children:(0,P.jsxs)(`div`,{className:`pointer-events-auto flex items-center gap-1 rounded-lg border bg-background/95 p-1 shadow-sm backdrop-blur`,children:[(0,P.jsxs)(m,{size:`sm`,onClick:ye,children:[(0,P.jsx)(ae,{}),` Table`]}),(0,P.jsxs)(m,{variant:`outline`,size:`sm`,onClick:be,disabled:x.length===0,title:`Automatically arrange tables`,children:[(0,P.jsx)(ie,{}),` Auto Layout`]})]})}),!R&&Q&&(0,P.jsx)(`aside`,{className:`absolute inset-y-0 right-0 z-20 w-[min(22rem,82%)] border-l bg-background shadow-xl`,children:(0,P.jsx)(se,{selectedEntity:Q,onUpdateEntity:_e,onDeleteEntity:ve,onBackToTables:()=>M(null),propertiesOnly:!0})}),(0,P.jsx)(oe,{isOpen:!R&&!!I,onOpenChange:e=>{e||L(null)},selectedEdge:Se,nodes:x,handleEdgeUpdate:pe,handleEdgeFlip:me,deleteEdge:he}),R&&(0,P.jsx)(w,{diff:R.result,approvedIds:B,showChecklist:H,onApprovedIdsChange:V,onShowChecklistChange:U,onReject:()=>{z(null),r.info(`Schema update rejected`)},onMerge:le})]})}function B({pane:e,document:t}){let{saveFlowchart:n,saveDrawing:r,triggerDebouncedSync:i}=b();return e.type===`erd`?(0,P.jsx)(s,{children:(0,P.jsx)(z,{document:t,previewSchema:e.previewSchema,previewKey:e.previewKey},t.uid??t.id)}):e.type===`flowchart`?(0,P.jsx)(I,{companionMode:!0,activeFlowchartId:t.uid??t.id,activeFlowchart:t,handleFlowchartChange:(e,r)=>void n({...t,data:JSON.stringify({nodes:e,edges:r})}).then(()=>i()),saveFlowchart:n,triggerDebouncedSync:i}):(0,P.jsx)(L,{compact:!0,drawing:t,onSave:r,onChange:e=>void r({...t,data:e}).then(()=>i()),onDelete:()=>{}})}function V({pane:e}){let{isGuest:t}=b(),[n,r]=(0,k.useState)(),[i,a]=(0,k.useState)(`loading`);return(0,k.useEffect)(()=>{let n=!0;return a(`loading`),r(void 0),R(e.type,e.uid,t).then(e=>{n&&(r(e),a(e?`ready`:`missing`))}).catch(()=>{n&&a(`missing`)}),()=>{n=!1}},[t,e.type,e.uid]),i===`loading`?(0,P.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:(0,P.jsx)(x,{className:`size-4 animate-spin`})}):i===`missing`?(0,P.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-xs text-muted-foreground`,children:[(0,P.jsx)(p,{className:`size-5`}),`File unavailable`]}):(0,P.jsx)(B,{pane:e,document:n})}export{V as NotesCompanionPane};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FlowchartView-DHnUjqeM.js","assets/rolldown-runtime-C0FnF6B9.js","assets/jsx-runtime-DSr1VPkp.js","assets/dist-D0tkMM_Y.js","assets/downloadSVG-C2LckkLx.js","assets/esm-B1WURL1q.js","assets/src-B-DeWB10.js","assets/value-Cwm0ChEK.js","assets/vanilla--C5Lp_AM.js","assets/button-D2dALS3q.js","assets/createLucideIcon-CyOWwA0s.js","assets/select-xSghKb2x.js","assets/alert-dialog-DK2RCz-0.js","assets/useBaseUiId-r-qiwcia.js","assets/useOnFirstRender-1giFodLk.js","assets/floating-ui.react-dom-OhALwEl4.js","assets/CompositeList-l_GSXRZM.js","assets/check-Uq0GkTkz.js","assets/useField-F6rVNyMc.js","assets/useControlled-CwUHqyRq.js","assets/CommentThreadView-Dx7ndjrK.js","assets/dropdown-menu-BrGjsCp0.js","assets/useCompositeItem-DgcRHBrd.js","assets/dialog-EJdgZKa4.js","assets/api-BAQH6VUv.js","assets/preload-helper-Czpn1I53.js","assets/move-BzTcfKj2.js","assets/hover-card-CqLOdc_X.js","assets/plus-DfXp3YpY.js","assets/trash-2-BmZK7fDJ.js","assets/undo-2-FZYgYKq2.js","assets/card-DFJ6ytRY.js","assets/input-BUIkeoB3.js","assets/WorkspaceContext-O7njKDwj.js","assets/label-CCjvjYto.js","assets/index-BL-qAtdL.js","assets/chunk-BV7QT456-CCzugQp2.js","assets/link-2-C71ROdND.js","assets/arrow-left-Cfq6LFs7.js","assets/ConfirmModal-DqvHDAUo.js","assets/wand-sparkles-DfkrzvIR.js","assets/copy-CIp5gOrB.js","assets/hard-drive-B6OfPqtv.js","assets/w3c-keyname-CHFwa9la.js","assets/refresh-cw-Bmpxlvmc.js","assets/sparkles-BKYYqRE2.js","assets/checkbox-CFF_zUIN.js","assets/minus-d4YlhnV9.js","assets/table-Bs3EelYM.js","assets/fileOwnership-DvxzSccE.js","assets/WorkspaceProvider-Dc-LU3z8.js","assets/note-importer-bjC4Q04B.js","assets/image-compression-DagnqRIG.js","assets/localPersistence-CjYRImp1.js","assets/useAuth-CQkE8axg.js","assets/diagramVersioning-BcJWSqo3.js","assets/dist-js-DXG5pDMi.js","assets/core-DNaw6KYU.js","assets/textarea-D2E-6RLc.js","assets/extends-CvVTau-c.js","assets/index-CpmJMylY.css","assets/ERDComments-Xwt7V4OK.js","assets/ERDComments-CHpVij2M.css","assets/JumpToNode-6hHRtxhW.js","assets/ExcalidrawEditor-BOhzLASV.js","assets/Combination-vqN0XDK-.js","assets/FileCommentMarkers-Laiy6bpC.js"])))=>i.map(i=>d[i]);
2
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{n as t,t as n}from"./jsx-runtime-DSr1VPkp.js";import{n as r}from"./dist-D0tkMM_Y.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{_ as a,d as o,h as s,l as c,u as l,v as u,y as d}from"./downloadSVG-C2LckkLx.js";import{ct as ee,h as te,r as ne,t as f}from"./esm-B1WURL1q.js";import{U as p}from"./alert-dialog-DK2RCz-0.js";import{t as m}from"./button-D2dALS3q.js";import{n as re}from"./calendar-Bjc1jNFb.js";import{M as ie}from"./hover-card-CqLOdc_X.js";import{t as ae}from"./plus-DfXp3YpY.js";import{n as h}from"./api-BAQH6VUv.js";import{v as g}from"./WorkspaceProvider-Dc-LU3z8.js";import{E as _,a as v}from"./note-importer-bjC4Q04B.js";import{t as y}from"./localPersistence-CjYRImp1.js";import{n as b}from"./WorkspaceContext-O7njKDwj.js";import{I as oe,S as se,en as x}from"./index-BL-qAtdL.js";import"./ERDComments-Xwt7V4OK.js";import{a as S,i as C,n as w,o as T,r as E,s as D,t as O}from"./erd-edge-style-C9GMC7E4.js";var k=e(t(),1);function A(e){if(!e)return null;try{return typeof e==`string`?JSON.parse(e):e}catch{return null}}function j(e){return{...e,id:String(e.id),is_pk:e.is_pk??e.isPk??!1,is_nullable:e.is_nullable??e.isNullable??!0,is_unique:e.is_unique??e.isUnique??!1,default_value:e.default_value??e.defaultValue??null,enum_values:e.enum_values??e.enumValues??``,max_length:e.max_length??e.maxLength??null,numeric_precision:e.numeric_precision??e.numericPrecision??null,numeric_scale:e.numeric_scale??e.numericScale??null,sort_order:e.sort_order??e.sortOrder??0}}function M(e){let t=e.data??e,n=String(e.id??t.id),r=e.position?.x??e.x??t.x??0,i=e.position?.y??e.y??t.y??0;return{id:n,type:`entity`,position:{x:r,y:i},data:{...t,_notesCompanion:!0,id:n,name:t.name??e.name??`Untitled`,x:r,y:i,color:t.color??e.color??`#6366f1`,columns:(t.columns??e.columns??[]).map(j)}}}function ce(e){let t=A(e.data),n=Array.isArray(e.entities)&&e.entities.length?e.entities:Array.isArray(t?.nodes)?t.nodes:[],r=Array.isArray(e.relationships)&&e.relationships.length?e.relationships:Array.isArray(t?.edges)?t.edges:[],i=n.map(M),a=new Map(i.map(e=>[e.id,e]));return{nodes:i,edges:r.map(e=>{let t=String(e.source??e.source_entity_id??e.sourceEntityId??``),n=String(e.target??e.target_entity_id??e.targetEntityId??``),r=e.sourceHandle??e.source_handle??e.sourceColumnId??e.source_column_id,i=e.targetHandle??e.target_handle??e.targetColumnId??e.target_column_id,o=a.get(t),s=a.get(n),c=(o?.position.x??0)<(s?.position.x??0),l=String(r||``).startsWith(`col-`)?r:r?`col-${r}-${c?`source`:`source-l`}`:void 0,u=String(i||``).startsWith(`col-`)?i:i?`col-${i}-${c?`target`:`target-r`}`:void 0;return{...e,id:String(e.id),source:t,target:n,sourceHandle:l,targetHandle:u,label:e.label,type:e.type??`smoothstep`,data:{...e.data||{},on_delete:e.on_delete??e.onDelete,on_update:e.on_update??e.onUpdate,constraint_name:e.constraint_name??e.constraintName}}})}}function N(e,t){return O(e,t?[t]:[])}var P=n(),F={entity:T},I=(0,k.lazy)(()=>i(()=>import(`./FlowchartView-DHnUjqeM.js`).then(e=>({default:e.FlowchartView})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63]))),L=(0,k.lazy)(()=>i(()=>import(`./ExcalidrawEditor-BOhzLASV.js`),__vite__mapDeps([64,1,2,3,25,8,9,10,15,24,52,33,59,35,36,4,5,6,7,12,13,14,21,11,16,17,18,19,22,20,23,37,38,39,40,41,42,43,32,28,44,45,29,31,46,47,48,49,50,51,53,54,55,56,57,34,58,60,65,66])));async function R(e,t,n){if(n){let n=e===`erd`?`erd`:e===`flowchart`?`flowchart`:`drawings`;return await y.getResource(t)||((await y.getAllResources(n)).find(e=>String(e.uid??e.id)===t)??null)}let r=await h(`/api/${e===`erd`?`diagrams`:e===`flowchart`?`flowcharts`:`drawings`}/${t}`);return r.ok?r.json():null}function z({document:e,previewSchema:t,previewKey:n}){let i=(0,k.useMemo)(()=>ce(e),[e]),{isGuest:s,resolvedTheme:p}=b(),[x,T]=(0,k.useState)(i.nodes),[O,A]=(0,k.useState)(i.edges),[j,M]=(0,k.useState)(null),[I,L]=(0,k.useState)(null),[R,z]=(0,k.useState)(null),[B,V]=(0,k.useState)([]),[H,U]=(0,k.useState)(!1),W=(0,k.useRef)(x),G=(0,k.useRef)(O),K=(0,k.useRef)(null),q=(0,k.useMemo)(()=>g(e),[e]),J=q??{x:0,y:0,zoom:1},Y=(0,k.useRef)(J);W.current=x,G.current=O;let X=(0,k.useCallback)((t,n)=>{K.current&&clearTimeout(K.current),K.current=setTimeout(async()=>{let i=t.map(e=>({...e.data,x:e.position.x,y:e.position.y})),a=n.map(_),o=v(t,n);try{if(s){let t=await y.getResource(e.uid??e.id);t&&await y.saveResource({...t,entities:i,relationships:a,data:null,dbml_source:o,viewport_x:Y.current.x,viewport_y:Y.current.y,viewport_zoom:Y.current.zoom,updated_at:new Date().toISOString()})}else if(!(await h(`/api/diagrams/save/${e.uid??e.id}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({entities:i,relationships:a,viewport:Y.current,data:null,dbmlSource:o})})).ok)throw Error()}catch{r.error(`Could not save ERD changes`)}},350)},[e.id,e.uid,s]);(0,k.useEffect)(()=>{if(!(!t||!n))try{let e=re(W.current,G.current,`erd-generate-sql`,t);if(!e)throw Error();let n=C(W.current,G.current,e.nodes,e.edges);if(n.changes.length===0){z(null),r.success(`No schema changes found`);return}M(null),L(null),V(n.changes.map(e=>e.id)),U(!1),z({originalNodes:W.current,originalEdges:G.current,proposedNodes:e.nodes,proposedEdges:e.edges,result:n})}catch{r.error(`Could not parse the schema for diff`)}},[n,t]);let le=(0,k.useCallback)(()=>{if(!R)return;let e=E(R.originalNodes,R.originalEdges,R.proposedNodes,R.proposedEdges,R.result,B);T(e.nodes),A(e.edges),z(null),X(e.nodes,e.edges),r.success(`Schema changes merged successfully`)},[B,R,X]),ue=(0,k.useCallback)(e=>{let t=u(e,W.current);T(t),e.some(e=>e.type!==`select`&&e.type!==`dimensions`)&&X(t,G.current)},[X]),de=(0,k.useCallback)(e=>{let t=a(e,G.current);A(t),e.some(e=>e.type!==`select`)&&X(W.current,t)},[X]),fe=(0,k.useCallback)(e=>{let t=te({...e,id:crypto.randomUUID(),type:`smoothstep`,label:`1:N`},G.current);A(t),X(W.current,t)},[X]),pe=(0,k.useCallback)((e,t)=>{let n=typeof t==`string`?{label:t}:t,r=G.current.map(t=>t.id===e?{...t,...n,data:{...t.data||{},...n.data||{}}}:t);A(r),X(W.current,r)},[X]),me=(0,k.useCallback)(e=>{let t=e=>e&&(e.endsWith(`-source`)?e.replace(/-source$/,`-source-l`):e.endsWith(`-source-l`)?e.replace(/-source-l$/,`-source`):e.endsWith(`-target`)?e.replace(/-target$/,`-target-r`):e.endsWith(`-target-r`)?e.replace(/-target-r$/,`-target`):e),n=G.current.map(n=>n.id===e?{...n,sourceHandle:t(n.sourceHandle),targetHandle:t(n.targetHandle)}:n);A(n),X(W.current,n)},[X]),he=(0,k.useCallback)(e=>{let t=G.current.filter(t=>t.id!==e);A(t),L(null),X(W.current,t)},[X]),ge=(0,k.useCallback)((e,t)=>{let n=e=>e?.replace(/^col-/,``).replace(/-(source|target)(-(l|r))?$/,``);if(!t.sourceHandle||!t.targetHandle)return;if(String(t.source)!==String(e.source)||String(t.target)!==String(e.target)||n(t.sourceHandle)!==n(e.sourceHandle)||n(t.targetHandle)!==n(e.targetHandle)){r.info(`Only the connector position can be changed`);return}let i=(e,t)=>{let r=n(t);return W.current.find(t=>String(t.id)===String(e))?.data.columns.find(e=>String(e.id)===String(r))},a=i(t.source,t.sourceHandle),o=i(t.target,t.targetHandle);if(a&&o&&a.type!==o.type){r.error(`Type Mismatch`,{description:`Cannot reconnect ${a.type} to ${o.type}`});return}let s=ee(e,t,G.current);A(s),X(W.current,s)},[X]),_e=(0,k.useCallback)(e=>{let t=W.current.map(t=>t.id===e.id?{...t,data:e}:t);T(t),X(t,G.current)},[X]),ve=(0,k.useCallback)(e=>{let t=W.current.filter(t=>t.id!==e),n=G.current.filter(t=>t.source!==e&&t.target!==e);T(t),A(n),M(null),X(t,n)},[X]),ye=(0,k.useCallback)(()=>{let e=crypto.randomUUID(),t={id:e,name:`new_table`,x:80,y:80,color:`#6366f1`,columns:[]},n=[...W.current,{id:e,type:`entity`,position:{x:80,y:80},data:t}];T(n),M(e),X(n,G.current)},[X]),be=(0,k.useCallback)(()=>{if(W.current.length===0)return;let e=S(W.current,G.current);T(e),X(e,G.current)},[X]),xe=(0,k.useCallback)((e,t)=>{Y.current=t},[]),Z=(0,k.useCallback)((e,t)=>{Y.current=t,e&&X(W.current,G.current)},[X]);(0,k.useEffect)(()=>{let e=e=>M(e.detail?.id??null);return window.addEventListener(D,e),()=>window.removeEventListener(D,e)},[]);let Q=x.find(e=>e.id===j)?.data??null,Se=O.find(e=>e.id===I)??null,Ce=p===`dark`?`#222`:`#ccc`,$=(0,k.useMemo)(()=>({type:`smoothstep`,animated:!1,reconnectable:!0,style:{stroke:`var(--edge-color)`,strokeWidth:2},markerEnd:{type:ne.Arrow,color:`var(--edge-color)`,width:10,height:10}}),[]),we=(0,k.useMemo)(()=>x.map(e=>{let t=e.id===j;return!!e.selected===t?e:{...e,selected:t}}),[x,j]),Te=(0,k.useMemo)(()=>N(O,j),[O,j]),Ee=(0,k.useMemo)(()=>R?N(R.result.edges,null):[],[R]),De=(0,k.useMemo)(()=>R?.result.nodes.map(e=>({...e,data:{...e.data,isDiffMode:!0}}))??[],[R]);return(0,P.jsxs)(`div`,{className:`relative h-full min-h-0 overflow-hidden bg-background`,children:[(0,P.jsxs)(d,{nodes:R?De:we,edges:R?Ee:Te,nodeTypes:F,onNodesChange:ue,onEdgesChange:de,onConnect:fe,onReconnect:ge,nodesDraggable:!R,nodesConnectable:!R,elementsSelectable:!R,edgesReconnectable:!R,defaultEdgeOptions:$,onNodeClick:(e,t)=>{L(null),M(t.id)},onNodeDoubleClick:(e,t)=>{L(null),M(t.id)},onEdgeClick:(e,t)=>{M(null),L(t.id)},onPaneClick:()=>{M(null),L(null)},onMove:xe,onMoveEnd:Z,colorMode:p,connectionLineType:f.SmoothStep,connectionLineStyle:$.style,onlyRenderVisibleElements:!0,defaultViewport:J,fitView:!q,children:[(0,P.jsx)(c,{variant:l.Lines,gap:50,size:1,color:Ce}),(0,P.jsx)(o,{position:`bottom-left`,showInteractive:!1})]}),!R&&(0,P.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-3 z-10 flex justify-center`,children:(0,P.jsxs)(`div`,{className:`pointer-events-auto flex items-center gap-1 rounded-lg border bg-background/95 p-1 shadow-sm backdrop-blur`,children:[(0,P.jsxs)(m,{size:`sm`,onClick:ye,children:[(0,P.jsx)(ae,{}),` Table`]}),(0,P.jsxs)(m,{variant:`outline`,size:`sm`,onClick:be,disabled:x.length===0,title:`Automatically arrange tables`,children:[(0,P.jsx)(ie,{}),` Auto Layout`]})]})}),!R&&Q&&(0,P.jsx)(`aside`,{className:`absolute inset-y-0 right-0 z-20 w-[min(22rem,82%)] border-l bg-background shadow-xl`,children:(0,P.jsx)(se,{selectedEntity:Q,onUpdateEntity:_e,onDeleteEntity:ve,onBackToTables:()=>M(null),propertiesOnly:!0})}),(0,P.jsx)(oe,{isOpen:!R&&!!I,onOpenChange:e=>{e||L(null)},selectedEdge:Se,nodes:x,handleEdgeUpdate:pe,handleEdgeFlip:me,deleteEdge:he}),R&&(0,P.jsx)(w,{diff:R.result,approvedIds:B,showChecklist:H,onApprovedIdsChange:V,onShowChecklistChange:U,onReject:()=>{z(null),r.info(`Schema update rejected`)},onMerge:le})]})}function B({pane:e,document:t}){let{saveFlowchart:n,saveDrawing:r,triggerDebouncedSync:i}=b();return e.type===`erd`?(0,P.jsx)(s,{children:(0,P.jsx)(z,{document:t,previewSchema:e.previewSchema,previewKey:e.previewKey},t.uid??t.id)}):e.type===`flowchart`?(0,P.jsx)(I,{companionMode:!0,activeFlowchartId:t.uid??t.id,activeFlowchart:t,handleFlowchartChange:(e,r)=>void n({...t,data:JSON.stringify({nodes:e,edges:r})}).then(()=>i()),saveFlowchart:n,triggerDebouncedSync:i}):(0,P.jsx)(L,{compact:!0,drawing:t,onSave:r,onChange:e=>void r({...t,data:e}).then(()=>i()),onDelete:()=>{}})}function V({pane:e}){let{isGuest:t}=b(),[n,r]=(0,k.useState)(),[i,a]=(0,k.useState)(`loading`);return(0,k.useEffect)(()=>{let n=!0;return a(`loading`),r(void 0),R(e.type,e.uid,t).then(e=>{n&&(r(e),a(e?`ready`:`missing`))}).catch(()=>{n&&a(`missing`)}),()=>{n=!1}},[t,e.type,e.uid]),i===`loading`?(0,P.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:(0,P.jsx)(x,{className:`size-4 animate-spin`})}):i===`missing`?(0,P.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-xs text-muted-foreground`,children:[(0,P.jsx)(p,{className:`size-5`}),`File unavailable`]}):(0,P.jsx)(B,{pane:e,document:n})}export{V as NotesCompanionPane};