@p4code/cli 0.8.27 → 0.8.29

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 (231) hide show
  1. package/dist/bin.mjs +1 -1
  2. package/dist/{binCli-CPTSeXBG.mjs → binCli-CT_2_UUP.mjs} +3 -3
  3. package/dist/client/.vite/manifest.json +1342 -1342
  4. package/dist/client/assets/{AuthSurfaceShell-Io9UMk5e.js → AuthSurfaceShell-Bei7xmsT.js} +2 -2
  5. package/dist/client/assets/{ChatGptUsageButton-C5QxZxAY.js → ChatGptUsageButton-DjtyxX8w.js} +2 -2
  6. package/dist/client/assets/{ChatMarkdown-n-Pmpt9I.js → ChatMarkdown-BWryt4mc.js} +7 -7
  7. package/dist/client/assets/CodexSetupSection.logic-BE9dmagn.js +2 -0
  8. package/dist/client/assets/{CommandBlock-BI6CIDH1.js → CommandBlock-BMCAniYR.js} +2 -2
  9. package/dist/client/assets/{ComposerPromptEditor-3AzcmrcZ.js → ComposerPromptEditor-BAeF4M2Q.js} +6 -6
  10. package/dist/client/assets/{DevicePanel-CglyhaAG.js → DevicePanel-BIK7lU5Q.js} +2 -2
  11. package/dist/client/assets/{DeviceSetup-Bazjz7NZ.js → DeviceSetup-DewZutCc.js} +2 -2
  12. package/dist/client/assets/{DiffCommentAnnotation-aW33-n8Z.js → DiffCommentAnnotation-Ec5St4ET.js} +2 -2
  13. package/dist/client/assets/{DiffFileTree-BUpgXQ-A.js → DiffFileTree-D7UK1g9w.js} +2 -2
  14. package/dist/client/assets/{DiffPanel-C7V9CYKL.js → DiffPanel-CsVOfMuC.js} +2 -2
  15. package/dist/client/assets/{DiffWorkerPoolProvider-DMh_rKAW.js → DiffWorkerPoolProvider-C_AEcdG7.js} +3 -3
  16. package/dist/client/assets/EmbeddedDesign-BW14Z5y6.css +1 -0
  17. package/dist/client/assets/{EmbeddedDesign-C5OUFTlD.js → EmbeddedDesign-etv-YYdL.js} +5 -5
  18. package/dist/client/assets/{FileDiff-CSn7_lgS.js → FileDiff-zDk0hlbP.js} +2 -2
  19. package/dist/client/assets/{FilePreviewPanel-3-FZcESN.js → FilePreviewPanel-4Jooc2SX.js} +5 -5
  20. package/dist/client/assets/{FoldedSettingsSection-f9BtRG8P.js → FoldedSettingsSection-CyFdDOGq.js} +2 -2
  21. package/dist/client/assets/{NoProjectsHero-BvLl09sT.js → NoProjectsHero-DTW4rIeE.js} +2 -2
  22. package/dist/client/assets/{P4ConnectAccountPages-55eXXvOR.js → P4ConnectAccountPages-T4KBK5hd.js} +2 -2
  23. package/dist/client/assets/{P4ConnectSidebarSignIn-CJxHyKxw.js → P4ConnectSidebarSignIn-CI3NSKOn.js} +2 -2
  24. package/dist/client/assets/{PanelLayoutControls-BVds3zWp.js → PanelLayoutControls-BZJgMEaR.js} +7 -7
  25. package/dist/client/assets/{PierreEntryIcon-BfQvfMe4.js → PierreEntryIcon-Dm9NJfpz.js} +2 -2
  26. package/dist/client/assets/PreviewPanel-C-ReuOpI.js +2 -0
  27. package/dist/client/assets/{ProjectDefaultsSettings-CD7_iiCV.js → ProjectDefaultsSettings-DJa4b3cl.js} +2 -2
  28. package/dist/client/assets/{ProjectFavicon-DZ3q6Z0H.js → ProjectFavicon-n6CM3ZfY.js} +3 -3
  29. package/dist/client/assets/{ProjectIconPickerDialog-BHl4mXHB.js → ProjectIconPickerDialog-mnqh2Fb1.js} +2 -2
  30. package/dist/client/assets/{ProviderAuthTerminal-CFc0xySv.js → ProviderAuthTerminal-B0jiV3vR.js} +2 -2
  31. package/dist/client/assets/{ProviderModelPicker-C8efuVrz.js → ProviderModelPicker-B8Pgdnzq.js} +2 -2
  32. package/dist/client/assets/{ProviderSettingsForm-DFLuI_nx.js → ProviderSettingsForm-DLPADUUT.js} +2 -2
  33. package/dist/client/assets/{PullRequestCodeTab-DRVlxTwy.js → PullRequestCodeTab-B6bsuotT.js} +3 -3
  34. package/dist/client/assets/{ReadOnlySourcePreview-Bu2_ZtA-.js → ReadOnlySourcePreview-DfjkD5FY.js} +2 -2
  35. package/dist/client/assets/{RenderErrorBoundary-D4jGtlFT.js → RenderErrorBoundary-C5qHUe4D.js} +2 -2
  36. package/dist/client/assets/{ScheduledTasksSettings-C0hXWVvl.js → ScheduledTasksSettings-CWA5xIMu.js} +4 -4
  37. package/dist/client/assets/{ScopedSwitch-LBZ02wBh.js → ScopedSwitch-CMG5TkJe.js} +2 -2
  38. package/dist/client/assets/{SettingsPanels-DWwikGem.js → SettingsPanels-fePSPeyj.js} +7 -7
  39. package/dist/client/assets/{SettingsPanels.logic-CZpg8aSK.js → SettingsPanels.logic-DAmnd5X8.js} +2 -2
  40. package/dist/client/assets/{SettingsScopeNotice-DjEkL-Ym.js → SettingsScopeNotice-BB-eUW9e.js} +2 -2
  41. package/dist/client/assets/{ThemeEditorPanel-DOEkSOth.js → ThemeEditorPanel-prIKTvqV.js} +2 -2
  42. package/dist/client/assets/{ThreadTerminalDrawer-BZX00N_c.js → ThreadTerminalDrawer-BMD96ec7.js} +3 -3
  43. package/dist/client/assets/{Virtualizer-CJW8pEVT.js → Virtualizer-D6kemKYw.js} +2 -2
  44. package/dist/client/assets/{_chat-Ca7FuMbD.js → _chat-D5CtrZlk.js} +34 -34
  45. package/dist/client/assets/{_chat.design-CDj4DPmx.js → _chat.design-3TkBa35G.js} +2 -2
  46. package/dist/client/assets/{_chat.index-CpvSvFZH.js → _chat.index-U8LYfL3f.js} +2 -2
  47. package/dist/client/assets/{_chat.new-3bIU60mQ.js → _chat.new-C3XhQclF.js} +2 -2
  48. package/dist/client/assets/{_chat.pull-requests-BTLE24EW.js → _chat.pull-requests-DmEWO6n3.js} +2 -2
  49. package/dist/client/assets/{abnfDiagram-VCTEODGH-DS1tb4Dy.js → abnfDiagram-VCTEODGH-fEe8S2YP.js} +2 -2
  50. package/dist/client/assets/architecture-7GRP2DOG-BshO7-1P.js +1 -0
  51. package/dist/client/assets/{architectureDiagram-5GKGNRK7-D0zpK53v.js → architectureDiagram-5GKGNRK7-wgdxOAR3.js} +2 -2
  52. package/dist/client/assets/{assets-BG_JXxWD.js → assets-CLcL_zrG.js} +2 -2
  53. package/dist/client/assets/{blockDiagram-I7D4REHJ-SL4el5ol.js → blockDiagram-I7D4REHJ-Bc-uLpeZ.js} +2 -2
  54. package/dist/client/assets/{browserHistoryStore-TYW6lOuv.js → browserHistoryStore-D-BdR1Vt.js} +2 -2
  55. package/dist/client/assets/{browserLinkTarget-BNoJwTBt.js → browserLinkTarget-Du_TcuMC.js} +2 -2
  56. package/dist/client/assets/{c4Diagram-7LVT6UL2-CWJKC-4H.js → c4Diagram-7LVT6UL2-DEJpkLKU.js} +2 -2
  57. package/dist/client/assets/channel-tXPJaaLI.js +2 -0
  58. package/dist/client/assets/{chunk-4HAMMTFA-BPAna-Wv.js → chunk-4HAMMTFA-B_S93bKu.js} +2 -2
  59. package/dist/client/assets/{chunk-75Z2AOVW-jKPMvGhC.js → chunk-75Z2AOVW-CXI2m4X5.js} +2 -2
  60. package/dist/client/assets/{chunk-DU6HZSFF-DQeySev0.js → chunk-DU6HZSFF-4wwg_XfZ.js} +2 -2
  61. package/dist/client/assets/{chunk-F27PBJKO-jWPdwF7M.js → chunk-F27PBJKO-jn5hv9Ic.js} +2 -2
  62. package/dist/client/assets/{chunk-GMAD6QVW-DpPhOysA.js → chunk-GMAD6QVW-COMeJjBL.js} +2 -2
  63. package/dist/client/assets/{chunk-GVQU2GXP-Ci4jKLcc.js → chunk-GVQU2GXP-Bq9iFxLA.js} +2 -2
  64. package/dist/client/assets/{chunk-IMKFNOWR-D29vnX6w.js → chunk-IMKFNOWR-Cs0NXvvD.js} +2 -2
  65. package/dist/client/assets/{chunk-L3NEJ4N5-C0YH77t5.js → chunk-L3NEJ4N5-CDdN5EmJ.js} +2 -2
  66. package/dist/client/assets/{chunk-OSK3NFVY-DfSRnLdf.js → chunk-OSK3NFVY-kSh_x7RX.js} +2 -2
  67. package/dist/client/assets/{chunk-P2QGCYS3-Bg2pIwSk.js → chunk-P2QGCYS3-D6Uzeqyp.js} +2 -2
  68. package/dist/client/assets/{chunk-POPQ4Y6H-CctNE5Wx.js → chunk-POPQ4Y6H-HO4sIHc5.js} +2 -2
  69. package/dist/client/assets/{chunk-PWAF6VOD-C1f1DGpf.js → chunk-PWAF6VOD-BcLa2sKW.js} +2 -2
  70. package/dist/client/assets/{chunk-SHT3W25Y-xnpqecbr.js → chunk-SHT3W25Y-WZottNhF.js} +2 -2
  71. package/dist/client/assets/{chunk-SVP7TREG-DnMt1uxV.js → chunk-SVP7TREG-Bdn-By9f.js} +2 -2
  72. package/dist/client/assets/{chunk-TICWLB2K-Cu6mah4v.js → chunk-TICWLB2K-BDxRSyk3.js} +2 -2
  73. package/dist/client/assets/classDiagram-ZZMXUADV-DsmJ7Gar.js +2 -0
  74. package/dist/client/assets/classDiagram-v2-VYDZK3BY-DsmJ7Gar.js +2 -0
  75. package/dist/client/assets/{composer-logic-ByYUEP0g.js → composer-logic-BxjlUBgq.js} +2 -2
  76. package/dist/client/assets/{composerDraftUploads-BPBBqP0N.js → composerDraftUploads-C0_qga_3.js} +2 -2
  77. package/dist/client/assets/{connect-rIIk2LpN.js → connect-ByM2h80L.js} +2 -2
  78. package/dist/client/assets/{connect-agent-BHr4rYhL.js → connect-agent-rvzcGrQo.js} +2 -2
  79. package/dist/client/assets/{cynefin-OW5HDTMX-awGYteF9.js → cynefin-OW5HDTMX-mgmlMYU7.js} +1 -1
  80. package/dist/client/assets/{cynefinDiagram-5FMLGOSQ-N1-lLKT-.js → cynefinDiagram-5FMLGOSQ-hQ5qtd1D.js} +2 -2
  81. package/dist/client/assets/{dagre-GXQ25YYZ-DCPL5qNf.js → dagre-GXQ25YYZ-VrvK7-QH.js} +2 -2
  82. package/dist/client/assets/{design-D9pNp4fS.js → design-Bt_NY2zM.js} +2 -2
  83. package/dist/client/assets/{device-DvcJXr0e.js → device-BttF1D2I.js} +2 -2
  84. package/dist/client/assets/{diagram-S7CK7UJ4-DEZdO6ar.js → diagram-S7CK7UJ4-BYQpRDzg.js} +2 -2
  85. package/dist/client/assets/{diagram-UQ7AKVKN-B2XQyTB4.js → diagram-UQ7AKVKN-DTGROUJh.js} +2 -2
  86. package/dist/client/assets/{diagram-VSXAHHWV-DldfdFb5.js → diagram-VSXAHHWV-CKdUZtLB.js} +2 -2
  87. package/dist/client/assets/{diagram-VX7I27RA-CifXMdiI.js → diagram-VX7I27RA-DAajHjRY.js} +2 -2
  88. package/dist/client/assets/{diagram-Z3DM3KII-jXVmEkNO.js → diagram-Z3DM3KII-aZhA2G34.js} +2 -2
  89. package/dist/client/assets/{diffRendering-DxGUmEvq.js → diffRendering-C3mxCQc4.js} +2 -2
  90. package/dist/client/assets/{dist-COvLc5b4.js → dist-BoqCHjAh.js} +2 -2
  91. package/dist/client/assets/{duoViewer-B50bcQwg.js → duoViewer-CbsJlnFU.js} +2 -2
  92. package/dist/client/assets/{dynamic-DDCwZvn2.js → dynamic-D2jjS7tR.js} +2 -2
  93. package/dist/client/assets/{ebnfDiagram-PWID7BFC-CXxPKnge.js → ebnfDiagram-PWID7BFC-D6Uae6gh.js} +2 -2
  94. package/dist/client/assets/{embeddedScripts-Gpq5uvk8.js → embeddedScripts-CWkW5jCC.js} +2 -2
  95. package/dist/client/assets/{entities-CHcmKww2.js → entities-CrdpKvvL.js} +2 -2
  96. package/dist/client/assets/{erDiagram-RLTQ6QDP-Bg12tmzC.js → erDiagram-RLTQ6QDP-DoHtuUMR.js} +2 -2
  97. package/dist/client/assets/eventmodeling-NTZA5JFV-Ca67kyA6.js +1 -0
  98. package/dist/client/assets/{fileLinks-OMeT3EGv.js → fileLinks-D3bZIXUC.js} +2 -2
  99. package/dist/client/assets/{fileTreeExpansion-DlEbR8A9.js → fileTreeExpansion-B1Xe3Ga3.js} +2 -2
  100. package/dist/client/assets/flowDiagram-HODETNUW-CrYHN5WL.js +1 -0
  101. package/dist/client/assets/{ganttDiagram-EL5Y4UJY-Cg6B23Gi.js → ganttDiagram-EL5Y4UJY-B1jwB3ch.js} +2 -2
  102. package/dist/client/assets/{getDiffFileInput-DU7M1ayK.js → getDiffFileInput-exTXKopz.js} +2 -2
  103. package/dist/client/assets/{gitGraph-4MIJSDKK-DY1yzqnv.js → gitGraph-4MIJSDKK-ClvFb2A_.js} +1 -1
  104. package/dist/client/assets/{gitGraphDiagram-WWUBYQGX-CuxKBsR7.js → gitGraphDiagram-WWUBYQGX-B8RhjPsD.js} +2 -2
  105. package/dist/client/assets/{guideRunStore-CtlhC1A4.js → guideRunStore-DGZFG7pG.js} +2 -2
  106. package/dist/client/assets/{index-DT3GBOff.js → index-BiM_L8v1.js} +3 -3
  107. package/dist/client/assets/{info-A6RAGUB7-FELuhJNt.js → info-A6RAGUB7-CdJcQnfX.js} +1 -1
  108. package/dist/client/assets/{infoDiagram-27XIBGKW-Bl4I0Plv.js → infoDiagram-27XIBGKW-DjwiczqG.js} +2 -2
  109. package/dist/client/assets/{ishikawaDiagram-5VMMS53U-UAMqnpij.js → ishikawaDiagram-5VMMS53U-DhFGYac_.js} +2 -2
  110. package/dist/client/assets/{journeyDiagram-3NMN7TZE-J6lpIBGT.js → journeyDiagram-3NMN7TZE-JPZrdM3p.js} +2 -2
  111. package/dist/client/assets/{kanban-definition-UXKFOSKX-BAmj09Ml.js → kanban-definition-UXKFOSKX-Dw3PpZrv.js} +2 -2
  112. package/dist/client/assets/{line-BT7eNXjs.js → line-BLOH5XAm.js} +2 -2
  113. package/dist/client/assets/{linkedPrompt-BVuTIuW9.js → linkedPrompt-DEHQUVk_.js} +2 -2
  114. package/dist/client/assets/main-DIQoY6z5.js +28 -0
  115. package/dist/client/assets/main-DYflPzD9.css +2 -0
  116. package/dist/client/assets/{mediaReference-4ijjnwgU.js → mediaReference-C-etHq_w.js} +2 -2
  117. package/dist/client/assets/{mediaSource-BBXGRYvD.js → mediaSource-CK5LTOwI.js} +2 -2
  118. package/dist/client/assets/{mermaid-parser.core-DEiOK0ka.js → mermaid-parser.core-BW8FRUCt.js} +4 -4
  119. package/dist/client/assets/{mermaid.core-Bx8b2pKm.js → mermaid.core-CzbtwMPf.js} +5 -5
  120. package/dist/client/assets/{mindmap-definition-YA3MSWOX-BXyIIcif.js → mindmap-definition-YA3MSWOX-CIjIlQQJ.js} +2 -2
  121. package/dist/client/assets/{onboarding-D_AA7mEu.js → onboarding-CQJADQff.js} +2 -2
  122. package/dist/client/assets/{openFileInPreview-BX2EPx-W.js → openFileInPreview-DLLPDQrM.js} +2 -2
  123. package/dist/client/assets/{p4ProjectFile-DCsCl5_0.js → p4ProjectFile-DoZgc8hH.js} +2 -2
  124. package/dist/client/assets/{packet-AYTQ26CC-Bqx116EX.js → packet-AYTQ26CC-BrQFVF1k.js} +1 -1
  125. package/dist/client/assets/{pair-B5LOQH2j.js → pair-B2cy7Khf.js} +2 -2
  126. package/dist/client/assets/{pegDiagram-XKGWAZYB-BsvAGr54.js → pegDiagram-XKGWAZYB-BQfKt3Kv.js} +2 -2
  127. package/dist/client/assets/{phoneViewer-BT-wd3b1.js → phoneViewer-B8lxrlqd.js} +2 -2
  128. package/dist/client/assets/{pie-WAS4IAKB-evx-Z-FQ.js → pie-WAS4IAKB-BYwNV5VL.js} +1 -1
  129. package/dist/client/assets/{pieDiagram-E7YTZNPT-CKykWbhU.js → pieDiagram-E7YTZNPT-B-N-6LKP.js} +2 -2
  130. package/dist/client/assets/{pierre-icons-DpUmwZMv.js → pierre-icons-CjBbiGV5.js} +2 -2
  131. package/dist/client/assets/{preview-CgesrIRi.js → preview-B9JaNWNp.js} +2 -2
  132. package/dist/client/assets/{primary-D90_IvSw.js → primary-BFg0aqry.js} +2 -2
  133. package/dist/client/assets/{primaryCloudLinkState-BipC1sbg.js → primaryCloudLinkState-CKEFAH19.js} +2 -2
  134. package/dist/client/assets/{projectFilesQueryState-B0Z25WLd.js → projectFilesQueryState-Bh9hq9TW.js} +2 -2
  135. package/dist/client/assets/projectScriptEditor-CY1vOA7A.js +2 -0
  136. package/dist/client/assets/{providerSkills-WK9rr3PR.js → providerSkills-V4McRHG7.js} +2 -2
  137. package/dist/client/assets/{pullRequestDetail.logic-DU6FbcfP.js → pullRequestDetail.logic-Cjtgtna8.js} +2 -2
  138. package/dist/client/assets/{pullRequests-Cv7P2eIY.js → pullRequests-B3H-yLBA.js} +2 -2
  139. package/dist/client/assets/{quadrantDiagram-AXDQQJYC-DXX_yCol.js → quadrantDiagram-AXDQQJYC-DCPGn0FK.js} +2 -2
  140. package/dist/client/assets/{queries-CzWn4iT1.js → queries-Di_bwktb.js} +2 -2
  141. package/dist/client/assets/{radar-RG4KPBEZ-DVDYLdDv.js → radar-RG4KPBEZ-0dqsckbr.js} +1 -1
  142. package/dist/client/assets/{railroad-74A4TZTK-QbHjzV3H.js → railroad-74A4TZTK-DmU2ySiL.js} +1 -1
  143. package/dist/client/assets/railroad-abnf-HS5TGJTU-D8jIFGdF.js +1 -0
  144. package/dist/client/assets/railroad-ebnf-LZEXJU2U-DLPuHFW-.js +1 -0
  145. package/dist/client/assets/railroad-peg-WCYAUIDC-C_dqA6qc.js +1 -0
  146. package/dist/client/assets/{railroadDiagram-O6MQD6OU-iJ7qhNbR.js → railroadDiagram-O6MQD6OU-C-_Drkco.js} +2 -2
  147. package/dist/client/assets/{renderScheduler-BLVmyLhe.js → renderScheduler-B6YH83Rs.js} +2 -2
  148. package/dist/client/assets/{requirementDiagram-BXWQKSXE-xiWwbUm-.js → requirementDiagram-BXWQKSXE-BnLylqek.js} +2 -2
  149. package/dist/client/assets/{runtime-FrzhE_LH.js → runtime-BWwa38SO.js} +2 -2
  150. package/dist/client/assets/{runtime-D2c--mqA.js → runtime-IzhBj1XN.js} +3 -3
  151. package/dist/client/assets/{sankeyDiagram-P5KCCOFB-0nRyou7P.js → sankeyDiagram-P5KCCOFB-CBOuF9QI.js} +2 -2
  152. package/dist/client/assets/{scheduledTasksSettings.logic-BXS7vhZ-.js → scheduledTasksSettings.logic-D1SmhEa5.js} +2 -2
  153. package/dist/client/assets/{sequenceDiagram-WJ2MYXX4-CC5JdpP4.js → sequenceDiagram-WJ2MYXX4-C7s7QsBy.js} +2 -2
  154. package/dist/client/assets/{server-DZYI6rhH.js → server-CP48yEl0.js} +2 -2
  155. package/dist/client/assets/{session-DhEZhn9K.js → session-T5SqAk8t.js} +2 -2
  156. package/dist/client/assets/{session-logic-6vU9tCVO.js → session-logic-DlVVq2YC.js} +2 -2
  157. package/dist/client/assets/{settings-DHEFuexL.js → settings-D206-FOy.js} +2 -2
  158. package/dist/client/assets/{settings.appearance-5kVeILsJ.js → settings.appearance-uxuzeSTF.js} +2 -2
  159. package/dist/client/assets/settings.archived-D9xP_v0H.js +2 -0
  160. package/dist/client/assets/{settings.computer-use-B_rhtPVE.js → settings.computer-use-2v-8O2zH.js} +2 -2
  161. package/dist/client/assets/{settings.connections-B8NEiau5.js → settings.connections-lKMQ_hew.js} +2 -2
  162. package/dist/client/assets/{settings.data-controls-B9FYgTyX.js → settings.data-controls-7Y8ueGmN.js} +2 -2
  163. package/dist/client/assets/{settings.decisions-B2cCo6C4.js → settings.decisions-C4emob6Z.js} +2 -2
  164. package/dist/client/assets/{settings.designs-B-dMaR0b.js → settings.designs-Dyn2mfcN.js} +2 -2
  165. package/dist/client/assets/{settings.diagnostics-DtokU1DC.js → settings.diagnostics-BCaoJyRg.js} +2 -2
  166. package/dist/client/assets/{settings.general-CEl6ByN_.js → settings.general-D8p__dvb.js} +2 -2
  167. package/dist/client/assets/settings.integrations-CCIv5QJj.js +2 -0
  168. package/dist/client/assets/{settings.keybindings-r4Dy4hkg.js → settings.keybindings-CyInaNpv.js} +2 -2
  169. package/dist/client/assets/{settings.open-source-licenses-BGGKTeAP.js → settings.open-source-licenses-CR6bCGYd.js} +2 -2
  170. package/dist/client/assets/{settings.plugins-C6Q3vhFM.js → settings.plugins-RPVcPTrS.js} +4 -4
  171. package/dist/client/assets/{settings.projects-DtZL3XlK.js → settings.projects-BP7ckasi.js} +3 -3
  172. package/dist/client/assets/{settings.providers-BHl68xr7.js → settings.providers-CfDlLMCi.js} +3 -3
  173. package/dist/client/assets/{settings.scheduled-tasks-DTxlZQAV.js → settings.scheduled-tasks-pczxt37t.js} +2 -2
  174. package/dist/client/assets/{settings.snap-shot-CFuPNtXn.js → settings.snap-shot-Dj4oICBD.js} +2 -2
  175. package/dist/client/assets/settings.source-control-CR5XSZHM.js +2 -0
  176. package/dist/client/assets/{settings.storage-Bw_3CvHq.js → settings.storage-7QvkpMPa.js} +2 -2
  177. package/dist/client/assets/{settingsLayout-C1Jfxbij.js → settingsLayout-Du-dHkyX.js} +2 -2
  178. package/dist/client/assets/{sidebar-BopQa8qy.js → sidebar-tK61bIR5.js} +2 -2
  179. package/dist/client/assets/sidebarProjectGrouping-CW263Rzs.js +2 -0
  180. package/dist/client/assets/{sourceControl-Lsyqeoql.js → sourceControl-C6eXWvfR.js} +2 -2
  181. package/dist/client/assets/{sourceControlClients-DQbmIpu5.js → sourceControlClients-B82L1A8B.js} +2 -2
  182. package/dist/client/assets/{stateDiagram-D77RDMKH-m8Y-mxXE.js → stateDiagram-D77RDMKH-oYRlOQT8.js} +2 -2
  183. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-BSGjPbEj.js +2 -0
  184. package/dist/client/assets/{swimlanes-42K2YHIH-wRxafkPC.js → swimlanes-42K2YHIH-4aFNZA_1.js} +2 -2
  185. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-xJy82rrx.js +9 -0
  186. package/dist/client/assets/{terminalSessions-CYOZNbmk.js → terminalSessions-DoA1DNPr.js} +2 -2
  187. package/dist/client/assets/{timeline-definition-24CTP7MA-rIHAblCw.js → timeline-definition-24CTP7MA-B5mmgIt9.js} +2 -2
  188. package/dist/client/assets/toast-BpFMQUQA.js +2 -0
  189. package/dist/client/assets/toastHelpers-DxXYm50b.js +2 -0
  190. package/dist/client/assets/{treeView-Q6P3EWNA-Bcy74tP0.js → treeView-Q6P3EWNA-C_P8Z3s2.js} +1 -1
  191. package/dist/client/assets/{treemap-WGGIJYW6-CfQsmSnc.js → treemap-WGGIJYW6-CWQSzaDd.js} +1 -1
  192. package/dist/client/assets/{uiStateStore-BvYsbiUI.js → uiStateStore-x5YpOn_O.js} +3 -3
  193. package/dist/client/assets/{usage-DKGEF7z4.js → usage-C-6kMPn4.js} +2 -2
  194. package/dist/client/assets/{use-atom-command-DrwAZaSK.js → use-atom-command-Da7aNqLc.js} +2 -2
  195. package/dist/client/assets/{useHandleNewThread-CX2gg9sv.js → useHandleNewThread-NoutVPDs.js} +2 -2
  196. package/dist/client/assets/{useP4ConnectAuthPrompt-BVHt43id.js → useP4ConnectAuthPrompt-Ds4gxPdc.js} +2 -2
  197. package/dist/client/assets/{usePullRequestActions-CKEsy23v.js → usePullRequestActions-6AR3Bv8v.js} +2 -2
  198. package/dist/client/assets/{useScopedModelAvailability-DxkmmSwB.js → useScopedModelAvailability-4KfG0IrU.js} +2 -2
  199. package/dist/client/assets/useSettings-DPnlKDDE.js +3 -0
  200. package/dist/client/assets/{vcsRefInvalidation-Cp8DmrdA.js → vcsRefInvalidation-DuHBQdu0.js} +2 -2
  201. package/dist/client/assets/{vennDiagram-4TSXK5OY-BYWi9jUi.js → vennDiagram-4TSXK5OY-Dt-xJxP3.js} +2 -2
  202. package/dist/client/assets/{wardley-WFR3VGLG-BQv1A50b.js → wardley-WFR3VGLG-C0eWSs8z.js} +1 -1
  203. package/dist/client/assets/{wardleyDiagram-VM6X3IG4-Cp-BLL4g.js → wardleyDiagram-VM6X3IG4-Ca2nNclr.js} +2 -2
  204. package/dist/client/assets/{welcome-COe2CLyM.js → welcome-BGbg8Pdk.js} +2 -2
  205. package/dist/client/assets/{xychartDiagram-S5SC5T6Z-CNBL0I4g.js → xychartDiagram-S5SC5T6Z-D-yJgS6t.js} +2 -2
  206. package/dist/client/index.html +1 -1
  207. package/package.json +1 -1
  208. package/dist/client/assets/CodexSetupSection.logic-452dIoYg.js +0 -2
  209. package/dist/client/assets/EmbeddedDesign-DYfQOv0y.css +0 -1
  210. package/dist/client/assets/PreviewPanel-Cj2fiJWr.js +0 -2
  211. package/dist/client/assets/architecture-7GRP2DOG-qKmX7534.js +0 -1
  212. package/dist/client/assets/channel-DI-bXazi.js +0 -2
  213. package/dist/client/assets/classDiagram-ZZMXUADV-DrD0Oidb.js +0 -2
  214. package/dist/client/assets/classDiagram-v2-VYDZK3BY-DrD0Oidb.js +0 -2
  215. package/dist/client/assets/eventmodeling-NTZA5JFV-DGgBiDNH.js +0 -1
  216. package/dist/client/assets/flowDiagram-HODETNUW-DvUNziGW.js +0 -1
  217. package/dist/client/assets/main-CSxSeVCm.js +0 -28
  218. package/dist/client/assets/main-CcPhKii6.css +0 -2
  219. package/dist/client/assets/projectScriptEditor-BAAT-cd6.js +0 -2
  220. package/dist/client/assets/railroad-abnf-HS5TGJTU-cPiNHmv2.js +0 -1
  221. package/dist/client/assets/railroad-ebnf-LZEXJU2U-D_qTHfDb.js +0 -1
  222. package/dist/client/assets/railroad-peg-WCYAUIDC-DzNZR6g5.js +0 -1
  223. package/dist/client/assets/settings.archived-jwpZnQSj.js +0 -2
  224. package/dist/client/assets/settings.integrations-B6wNRi_e.js +0 -2
  225. package/dist/client/assets/settings.source-control-DzHVHiHN.js +0 -2
  226. package/dist/client/assets/sidebarProjectGrouping-CTN-1PEY.js +0 -2
  227. package/dist/client/assets/stateDiagram-v2-MP3YSRHH-Co2rfAar.js +0 -2
  228. package/dist/client/assets/swimlanesDiagram-VR7AAH4N-DgApCEOp.js +0 -9
  229. package/dist/client/assets/toast-VoruYA6X.js +0 -2
  230. package/dist/client/assets/toastHelpers-Dsph6LwL.js +0 -2
  231. package/dist/client/assets/useSettings-u7ZNp27u.js +0 -3
@@ -1,4 +1,4 @@
1
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{$o as n,BE as r,Co as i,D as a,Eg as o,Er as s,Es as c,Fw as l,Hu as u,Hw as d,Ir as f,Ix as p,Jc as m,Kc as h,Kw as g,Kx as _,Lr as v,NS as y,Qo as b,RT as x,SS as S,Ss as C,Sv as w,VS as T,W as E,Yc as D,Ys as O,_S as k,ab as A,b as j,bn as M,br as N,cb as P,ds as F,eC as ee,es as te,fr as I,fw as L,gs as ne,hr as re,hs as ie,hv as R,l as ae,lr as oe,mE as se,mr as ce,pr as le,qS as ue,qc as de,rs as fe,ts as pe,ya as me,yn as he,yr as ge}from"./utils-B0w8dSf5.js";import{t as _e}from"./arrow-down-up-B46gw0xW.js";import{t as ve}from"./arrow-down-DvRecXuy.js";import{t as ye}from"./arrow-left-BLE461db.js";import{t as be}from"./arrow-right-CoV5ameY.js";import{t as z}from"./arrow-up-right-C6IM-WPd.js";import{t as xe}from"./arrow-up-3Yp3lsoe.js";import{t as Se}from"./boxes-D4AJ0ucE.js";import{t as Ce}from"./chevron-down-DHV04o66.js";import{t as we}from"./chevron-left-DrNh6cTh.js";import{t as Te}from"./chevron-right-NbahR9_s.js";import{t as Ee}from"./chevron-up-C-w52bD6.js";import{t as B}from"./chevrons-up-down-BMPucOK_.js";import{t as De}from"./circle-alert-B83jEPoh.js";import{t as Oe}from"./circle-4zZlZno3.js";import{t as ke}from"./component-HJu09bM6.js";import{t as Ae}from"./download-BAp4p4A-.js";import{t as je}from"./ellipsis-6x3R4_IB.js";import{t as Me}from"./file-code-corner-Dt6PpZnb.js";import{t as Ne}from"./focus-o7yKOd1j.js";import{t as Pe}from"./folder-CMIvEUJv.js";import{t as Fe}from"./frame-DGUYPXa7.js";import{t as Ie}from"./group-aBPDkCFm.js";import{t as Le}from"./hand-Bz2YZhrG.js";import{t as Re}from"./history-B22_6xEN.js";import{t as ze}from"./image-xUrgiZ2i.js";import{t as Be}from"./layers-BqgDAlx3.js";import{t as Ve}from"./layout-grid-CCkPw5ih.js";import{t as He}from"./library-C8DuZzap.js";import{t as Ue}from"./link-zAXVcUwk.js";import{t as We}from"./map-pin-5mbcayYf.js";import{t as Ge}from"./maximize-2-CHT2IkVy.js";import{t as Ke}from"./message-square-plus-ChUy6onn.js";import{t as qe}from"./message-square-DLzUyuIE.js";import{t as Je}from"./minus-C7W28oE7.js";import{t as Ye}from"./monitor-Ddj8MK6z.js";import{t as Xe}from"./mouse-pointer-2-DbBU41il.js";import{t as Ze}from"./plus-Cr075-cy.js";import{t as Qe}from"./refresh-cw-PY_ECjtI.js";import{t as $e}from"./scan-search-Chb5YdZY.js";import{t as et}from"./scan-BPBcmOMp.js";import{t as tt}from"./search-Cr9eaeTj.js";import{t as nt}from"./settings-CTjEqsg3.js";import{t as rt}from"./spline-EJpY6uhz.js";import{t as it}from"./square-DVrCvZRU.js";import{t as at}from"./swatch-book-CO6HbEgI.js";import{t as ot}from"./type-ChjbxAhu.js";import{t as st}from"./upload-D9-Kv89Z.js";import{t as ct}from"./wifi-off-DtJhRDhE.js";import{t as lt}from"./x-CSwbgjBe.js";import{_ as ut,g as dt}from"./runtime-D2c--mqA.js";import{j as ft,k as pt}from"./entities-CHcmKww2.js";import{t as mt}from"./runtime-FrzhE_LH.js";import{a as ht,c as gt,i as _t,l as vt,n as yt,o as bt,r as xt,s as St,t as Ct,u as wt}from"./SelectScrollUpArrow-CMpd0Jm1.js";import{t as Tt}from"./useNavigate-CSxB1zLo.js";import{S as Et}from"./useSettings-u7ZNp27u.js";import{u as Dt}from"./rightPanelStore-BLSD3K6s.js";import{a as Ot,i as kt,n as At,o as V,r as jt,t as Mt}from"./ClippedText-DoAq5p0h.js";import{n as Nt,t as Pt}from"./CheckboxIndicator-CtJqB7ns.js";import{a as Ft,f as It,i as Lt,l as Rt,n as zt,o as Bt,p as Vt,r as Ht,s as Ut,t as Wt,u as Gt}from"./ComboboxClear-gWUoU_9i.js";import{d as Kt}from"./combobox-CJgXDxx7.js";import{n as qt,t as Jt}from"./ComboboxGroupLabel-PqwekxYO.js";import{t as Yt}from"./Input-BcEftKLM.js";import{a as Xt,i as Zt,n as Qt,r as $t,t as en}from"./ScrollAreaCorner-CpFtD7m1.js";import{c as tn,l as nn,n as rn,o as an,r as on,s as sn,t as cn,u as ln}from"./DialogTitle-B_iSZXaO.js";import{a as un,c as dn,n as fn,o as pn,r as mn,s as hn}from"./PopoverHandle-BUkWn6lX.js";import{t as gn}from"./AlertDialogRoot-uMQTdBRo.js";import{t as _n}from"./DesignPageTile-6OCPIqLU.js";import{c as vn,d as yn,i as bn,l as xn,s as Sn,t as Cn,u as wn}from"./design-D9pNp4fS.js";import{n as Tn}from"./useHandleNewThread-CX2gg9sv.js";var H=e(t(),1),U=r(),En=u(`[&_svg]:-mx-0.5 relative inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-lg border font-medium text-base outline-none transition-colors pointer-coarse:after:absolute pointer-coarse:after:size-full pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-64 sm:text-sm [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0`,{defaultVariants:{size:`default`,variant:`default`},variants:{size:{default:`h-9 px-[calc(--spacing(3)-1px)] sm:h-8`,icon:`size-9 sm:size-8`,"icon-lg":`size-10 sm:size-9`,"icon-micro":`size-5 rounded-sm p-0 [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-8 sm:size-7`,"icon-xl":`size-11 sm:size-10 [&_svg:not([class*='size-'])]:size-5 sm:[&_svg:not([class*='size-'])]:size-4.5`,"icon-xs":`size-7 rounded-md sm:size-6 not-in-data-[slot=input-group]:[&_svg:not([class*='size-'])]:size-4 sm:not-in-data-[slot=input-group]:[&_svg:not([class*='size-'])]:size-3.5`,lg:`h-10 px-[calc(--spacing(3.5)-1px)] sm:h-9`,sm:`h-8 gap-1.5 px-[calc(--spacing(2.5)-1px)] sm:h-7`,xl:`h-11 px-[calc(--spacing(4)-1px)] text-lg sm:h-10 sm:text-base [&_svg:not([class*='size-'])]:size-5 sm:[&_svg:not([class*='size-'])]:size-4.5`,xs:`h-7 gap-1 rounded-md px-[calc(--spacing(2)-1px)] text-sm sm:h-6 sm:text-xs [&_svg:not([class*='size-'])]:size-4 sm:[&_svg:not([class*='size-'])]:size-3.5`},variant:{default:`border-primary bg-primary text-primary-foreground [:active,[data-pressed]]:bg-primary/80 [:hover,[data-pressed]]:bg-primary/90`,destructive:`border-primary bg-primary text-primary-foreground [:active,[data-pressed]]:bg-primary/80 [:hover,[data-pressed]]:bg-primary/90`,"destructive-outline":`border-input bg-popover not-dark:bg-clip-padding text-foreground dark:bg-input/32 [:active,[data-pressed]]:bg-accent/70 [:hover,[data-pressed]]:bg-accent/50 dark:[:hover,[data-pressed]]:bg-input/64 [&_svg:not([class*='text-'])]:text-muted-foreground`,ghost:`border-transparent text-foreground data-pressed:bg-accent [:hover,[data-pressed]]:bg-accent [&_svg:not([class*='text-'])]:text-muted-foreground`,link:`border-transparent underline-offset-4 [:hover,[data-pressed]]:underline`,outline:`border-input bg-popover not-dark:bg-clip-padding text-foreground dark:bg-input/32 [:active,[data-pressed]]:bg-accent/70 [:hover,[data-pressed]]:bg-accent/50 dark:[:hover,[data-pressed]]:bg-input/64 [&_svg:not([class*='text-'])]:text-muted-foreground`,secondary:`border-transparent bg-secondary text-secondary-foreground [:active,[data-pressed]]:bg-secondary/80 [:hover,[data-pressed]]:bg-secondary/90`}}});function W(e){let t=(0,U.c)(9),n,r,a,o;if(t[0]!==e){let{className:s,variant:c,size:l,render:u,...d}=e;n=u;let f=n?void 0:`button`,p={className:V(En({className:s,size:l,variant:c})),"data-slot":`button`,type:f};o=I,r=`button`,a=i(p,d),t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=o}else n=t[1],r=t[2],a=t[3],o=t[4];let s;return t[5]!==n||t[6]!==r||t[7]!==a?(s={defaultTagName:r,props:a,render:n},t[5]=n,t[6]=r,t[7]=a,t[8]=s):s=t[8],o(s)}var G=e(se(),1);function Dn(e){let t=(0,U.c)(30),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:n,size:i,unstyled:a,nativeInput:o,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=i===void 0?`default`:i,c=a!==void 0&&a,l=o!==void 0&&o,u=s===`sm`&&`h-7.5 px-[calc(--spacing(2.5)-1px)] leading-7.5 sm:h-6.5 sm:leading-6.5`,d=s===`lg`&&`h-9.5 leading-9.5 sm:h-8.5 sm:leading-8.5`,f=r.type===`search`&&`[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none [&::-webkit-search-results-button]:appearance-none [&::-webkit-search-results-decoration]:appearance-none`,p=r.type===`file`&&`text-muted-foreground file:me-3 file:bg-transparent file:font-medium file:text-foreground file:text-sm`,m;t[6]!==u||t[7]!==d||t[8]!==f||t[9]!==p?(m=V(`h-8.5 w-full min-w-0 rounded-[inherit] px-[calc(--spacing(3)-1px)] leading-8.5 outline-none placeholder:text-muted-foreground/72 sm:h-7.5 sm:leading-7.5 [transition:background-color_5000000s_ease-in-out_0s]`,u,d,f,p),t[6]=u,t[7]=d,t[8]=f,t[9]=p,t[10]=m):m=t[10];let h=m,g;if(l){let e,n;if(t[11]!==r){let{style:i,onValueChange:a,...o}=r;n=i,e=o,t[11]=r,t[12]=e,t[13]=n}else e=t[12],n=t[13];let i=typeof n==`function`?void 0:n,a=typeof s==`number`?s:void 0,o=e,c;t[14]!==h||t[15]!==i||t[16]!==o||t[17]!==a?(c=(0,G.jsx)(`input`,{className:h,"data-slot":`input`,size:a,style:i,...o}),t[14]=h,t[15]=i,t[16]=o,t[17]=a,t[18]=c):c=t[18],g=c}else{let e=typeof s==`number`?s:void 0,n;t[19]!==h||t[20]!==r||t[21]!==e?(n=(0,G.jsx)(Yt,{className:h,"data-slot":`input`,size:e,...r}),t[19]=h,t[20]=r,t[21]=e,t[22]=n):n=t[22],g=n}let _;t[23]!==n||t[24]!==c?(_=V(!c&&`relative inline-flex w-full rounded-lg border border-input bg-background not-dark:bg-clip-padding text-base text-foreground shadow-xs/5 ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-disabled:not-has-focus-visible:not-has-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] has-focus-visible:has-aria-invalid:border-destructive/64 has-focus-visible:has-aria-invalid:ring-destructive/16 has-aria-invalid:border-destructive/36 has-focus-visible:border-ring has-autofill:bg-foreground/4 has-disabled:opacity-64 has-[:disabled,:focus-visible,[aria-invalid]]:shadow-none has-focus-visible:ring-[3px] sm:text-sm dark:bg-input/32 dark:has-autofill:bg-foreground/8 dark:has-aria-invalid:ring-destructive/24 dark:not-has-disabled:not-has-focus-visible:not-has-aria-invalid:before:shadow-[0_-1px_--theme(--color-white/6%)]`,n)||void 0,t[23]=n,t[24]=c,t[25]=_):_=t[25];let v;return t[26]!==g||t[27]!==s||t[28]!==_?(v=(0,G.jsx)(`span`,{className:_,"data-size":s,"data-slot":`input-control`,children:g}),t[26]=g,t[27]=s,t[28]=_,t[29]=v):v=t[29],v}var On=N;function kn(e){let t=(0,U.c)(8),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;return t[4]!==n||t[5]!==r||t[6]!==i?(a=(0,G.jsx)(re,{className:r,"data-slot":`menu-trigger`,...i,children:n}),t[4]=n,t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function An(e){let t=(0,U.c)(26),n,r,i,a,o,c,l,u,d;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],c=t[6],l=t[7],u=t[8],d=t[9]):({children:i,className:a,sideOffset:l,align:u,alignOffset:n,side:d,anchor:r,disableAnchorTracking:o,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=c,t[7]=l,t[8]=u,t[9]=d);let p=l===void 0?4:l,m=u===void 0?`center`:u,h=d===void 0?`bottom`:d,g;t[10]===a?g=t[11]:(g=V(`dropdown-glass relative flex not-[class*='w-']:min-w-32 origin-(--transform-origin) rounded-lg outline-none transition-[scale,opacity] duration-[140ms] ease-[cubic-bezier(0.23,1,0.32,1)] data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0 data-instant:duration-0 focus:outline-none`,a),t[10]=a,t[11]=g);let _;t[12]===i?_=t[13]:(_=(0,G.jsx)(`div`,{className:`max-h-(--available-height) w-full overflow-y-auto p-1`,children:i}),t[12]=i,t[13]=_);let y;t[14]!==c||t[15]!==g||t[16]!==_?(y=(0,G.jsx)(v,{className:g,"data-slot":`menu-popup`,...c,children:_}),t[14]=c,t[15]=g,t[16]=_,t[17]=y):y=t[17];let b;return t[18]!==m||t[19]!==n||t[20]!==r||t[21]!==o||t[22]!==h||t[23]!==p||t[24]!==y?(b=(0,G.jsx)(f,{children:(0,G.jsx)(s,{align:m,alignOffset:n,anchor:r,disableAnchorTracking:o,className:`z-[60]`,"data-slot":`menu-positioner`,side:h,sideOffset:p,children:y})}),t[18]=m,t[19]=n,t[20]=r,t[21]=o,t[22]=h,t[23]=p,t[24]=y,t[25]=b):b=t[25],b}function jn(e){let t=(0,U.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,inset:r,variant:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?`default`:a,s;t[5]===n?s=t[6]:(s=V(`[&>svg]:-mx-0.5 flex min-h-8 cursor-default select-none items-center gap-2 rounded-sm px-2 py-1 text-base text-foreground outline-none data-disabled:pointer-events-none data-highlighted:bg-accent data-inset:ps-8 data-[variant=destructive]:text-destructive-foreground data-highlighted:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&>svg:not([class*='opacity-'])]:opacity-80 [&>svg:not([class*='size-'])]:size-4.5 sm:[&>svg:not([class*='size-'])]:size-4 [&>svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:[&>svg:not([class*='text-'])]:text-current [&>svg]:pointer-events-none [&>svg]:shrink-0`,n),t[5]=n,t[6]=s);let c;return t[7]!==r||t[8]!==i||t[9]!==s||t[10]!==o?(c=(0,G.jsx)(me,{className:s,"data-inset":r,"data-slot":`menu-item`,"data-variant":o,...i}),t[7]=r,t[8]=i,t[9]=s,t[10]=o,t[11]=c):c=t[11],c}function Mn(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`mx-2 my-1 h-px bg-border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(ce,{className:i,"data-slot":`menu-separator`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Nn(e){let t=(0,U.c)(2),n;return t[0]===e?n=t[1]:(n=(0,G.jsx)(ge,{"data-slot":`menu-sub`,...e}),t[0]=e,t[1]=n),n}function Pn(e){let t=(0,U.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,inset:i,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===r?o=t[6]:(o=V(`flex min-h-8 items-center gap-2 rounded-sm px-2 py-1 text-base text-foreground outline-none data-disabled:pointer-events-none data-highlighted:bg-accent data-popup-open:bg-accent data-inset:ps-8 data-highlighted:text-accent-foreground data-popup-open:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none`,r),t[5]=r,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,G.jsx)(Te,{className:`-me-0.5 ms-auto opacity-80`}),t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==a||t[11]!==o?(c=(0,G.jsxs)(le,{className:o,"data-inset":i,"data-slot":`menu-sub-trigger`,...a,children:[n,s]}),t[8]=n,t[9]=i,t[10]=a,t[11]=o,t[12]=c):c=t[12],c}function Fn(e){let t=(0,U.c)(12),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,sideOffset:a,alignOffset:n,align:o,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=a===void 0?0:a,c=o===void 0?`start`:o,l=n??(c===`center`?void 0:-5),u;return t[6]!==c||t[7]!==r||t[8]!==i||t[9]!==s||t[10]!==l?(u=(0,G.jsx)(An,{align:c,alignOffset:l,className:r,"data-slot":`menu-sub-content`,side:`inline-end`,sideOffset:s,...i}),t[6]=c,t[7]=r,t[8]=i,t[9]=s,t[10]=l,t[11]=u):u=t[11],u}var In=`dialog-backdrop panel-motion fixed inset-0 z-50 transition-all duration-(--panel-duration) data-ending-style:opacity-0 data-starting-style:opacity-0`,Ln=`dialog-glass panel-motion -translate-y-[calc(1.25rem*var(--nested-dialogs))] relative flex min-h-0 w-full min-w-0 scale-[calc(1-0.1*var(--nested-dialogs))] flex-col rounded-2xl border opacity-[calc(1-0.1*var(--nested-dialogs))] outline-none transition-[scale,opacity,translate] duration-(--panel-duration) ease-in-out will-change-transform data-nested:data-ending-style:translate-y-8 data-nested:data-starting-style:translate-y-8 data-nested-dialog-open:origin-top data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0`,Rn=gn,zn=an;function Bn(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(In,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(ln,{forceRender:!0,className:i,"data-slot":`alert-dialog-backdrop`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Vn(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`fixed inset-0 z-50 grid grid-rows-[1fr_auto_1fr] justify-items-center p-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(rn,{className:i,"data-slot":`alert-dialog-viewport`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Hn(e){let t=(0,U.c)(16),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,bottomStickOnMobile:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0||i,o;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,G.jsx)(Bn,{}),t[4]=o):o=t[4];let s=a&&`max-sm:grid-rows-[1fr_auto] max-sm:p-0 max-sm:pt-12`,c;t[5]===s?c=t[6]:(c=V(s),t[5]=s,t[6]=c);let l=a&&`max-sm:max-w-none max-sm:rounded-none max-sm:border-x-0 max-sm:border-t max-sm:border-b-0 max-sm:opacity-[calc(1-min(var(--nested-dialogs),1))] max-sm:data-ending-style:translate-y-4 max-sm:data-starting-style:translate-y-4`,u;t[7]!==n||t[8]!==l?(u=V(Ln,`row-start-2 max-h-full max-w-lg text-popover-foreground`,l,n),t[7]=n,t[8]=l,t[9]=u):u=t[9];let d;t[10]!==r||t[11]!==u?(d=(0,G.jsx)(sn,{className:u,"data-slot":`alert-dialog-popup`,...r}),t[10]=r,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==c||t[14]!==d?(f=(0,G.jsxs)(zn,{children:[o,(0,G.jsx)(Vn,{className:c,children:d})]}),t[13]=c,t[14]=d,t[15]=f):f=t[15],f}function Un(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`flex flex-col gap-2 p-6 text-center max-sm:pb-4 sm:text-left`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(`div`,{className:i,"data-slot":`alert-dialog-header`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Wn(e){let t=(0,U.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,variant:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`default`:i,o=a==="default"&&`border-t bg-muted/72 py-4`,s=a===`bare`&&`pb-6`,c;t[4]!==n||t[5]!==o||t[6]!==s?(c=V(`flex flex-col-reverse gap-2 px-6 sm:flex-row sm:justify-end sm:rounded-b-[calc(var(--radius-2xl)-1px)]`,o,s,n),t[4]=n,t[5]=o,t[6]=s,t[7]=c):c=t[7];let l;return t[8]!==r||t[9]!==c?(l=(0,G.jsx)(`div`,{className:c,"data-slot":`alert-dialog-footer`,...r}),t[8]=r,t[9]=c,t[10]=l):l=t[10],l}function Gn(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`font-heading font-semibold text-xl leading-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(cn,{className:i,"data-slot":`alert-dialog-title`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Kn(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`text-muted-foreground text-sm`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(tn,{className:i,"data-slot":`alert-dialog-description`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var qn=(0,H.createContext)(null);function Jn(e){let t=(0,U.c)(3),{host:n,children:r}=e,i=n,a;return t[0]!==r||t[1]!==i?(a=(0,G.jsx)(qn,{value:i,children:r}),t[0]=r,t[1]=i,t[2]=a):a=t[2],a}function Yn(){let e=(0,H.use)(qn);if(!e)throw Error(`Design workspace rendered outside a DesignHostProvider`);return e}var Xn=fe(C(!1)).pipe(F(`design-query:empty`));function Zn(e){let t=l(e);return t instanceof Error&&t.message.trim().length>0?t.message:`The environment request failed.`}function Qn(e){let t=(0,U.c)(10),r=e??Xn,i=n(r),a=b(r),o;t[0]===i?o=t[1]:(o=x(c(i)),t[0]=i,t[1]=o);let s;t[2]!==i._tag||t[3]!==i.cause?(s=i._tag===`Failure`?Zn(i.cause):null,t[2]=i._tag,t[3]=i.cause,t[4]=s):s=t[4];let l=e!==null&&i.waiting,u;return t[5]!==a||t[6]!==o||t[7]!==s||t[8]!==l?(u={data:o,error:s,isPending:l,refresh:a},t[5]=a,t[6]=o,t[7]=s,t[8]=l,t[9]=u):u=t[9],u}function $n(){let e=Yn(),t=(0,H.useContext)(te);return(0,H.useCallback)(async n=>{let r=e.runtime.atom(n),i=await y(T(_(function*(){return yield*ne(t,r),yield*ie(t,r,{suspendOnWaiting:!0})})));if(L(i))throw l(i.cause);return i.value},[e,t])}function er(e){return e.label?e.label:e.origin===`agent`?`Agent run`:e.origin===`restore`?`Restored`:`Edits`}function tr(e){let t=new Date(e);return t.toDateString()===new Date().toDateString()?t.toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`}):t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function nr(e,t){return[new Date(e.savedAt).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}),`${e.changes} ${e.changes===1?`change`:`changes`}`,t?`Current`:null].filter(Boolean).join(` · `)}var rr=e=>e instanceof Error&&`code`in e?String(e.code):null;function ir(e){let t=(0,U.c)(96),{target:n,path:r,revision:i,fileHash:a,disabled:o,compact:s,onCompare:c}=e,l=s!==void 0&&s,{transport:u}=Yn(),d=$n(),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(null),[g,_]=(0,H.useState)(null),[v,y]=(0,H.useState)(null),[b,x]=(0,H.useState)(null),[S,C]=(0,H.useState)(``),[w,T]=(0,H.useState)(!1),[E,D]=(0,H.useState)(0),O;t[0]!==r||t[1]!==d||t[2]!==n||t[3]!==u?(O=()=>{let e=!0;return _(null),d(u.revisions(n,r)).then(t=>{e&&h(t)},()=>{e&&_(`Could not load revisions.`)}),()=>{e=!1}},t[0]=r,t[1]=d,t[2]=n,t[3]=u,t[4]=O):O=t[4];let k;t[5]!==E||t[6]!==a||t[7]!==f||t[8]!==r||t[9]!==d||t[10]!==n||t[11]!==u?(k=[f,E,n,r,a,u,d],t[5]=E,t[6]=a,t[7]=f,t[8]=r,t[9]=d,t[10]=n,t[11]=u,t[12]=k):k=t[12],(0,H.useEffect)(O,k);let A;if(t[13]!==a||t[14]!==i||t[15]!==m){let e=m?.find(e=>e.fileHash===a);A=e?`${er(e)} · ${tr(e.savedAt)}`:i?`Revision ${i.slice(0,8)}`:`Revisions`,t[13]=a,t[14]=i,t[15]=m,t[16]=A}else A=t[16];let j=A,M;t[17]===w?M=t[18]:(M=()=>{w||(x(null),y(null))},t[17]=w,t[18]=M);let N=M,P;t[19]!==b||t[20]!==w||t[21]!==S||t[22]!==r||t[23]!==d||t[24]!==n||t[25]!==u?(P=()=>{if(!b||w)return;T(!0),y(null);let e=b.kind===`restore`?u.restoreRevision(n,r,b.entry.id,b.expectedFileHash):b.kind===`rename`?u.renameRevision(n,r,b.entry.id,S):u.deleteRevision(n,r,b.entry.id);d(e).then(()=>{x(null),D(ar)},e=>{let t=rr(e);y(b.kind===`restore`&&t===`conflict`?`The design changed. Reopen revisions and try again.`:b.kind===`restore`&&t===`invalid-document`?`This revision cannot be restored with the current libraries and assets.`:b.kind===`delete`&&t===`conflict`?`The current revision can't be deleted. Restore another revision first.`:`Could not ${b.kind} this revision. Reopen revisions and try again.`)}).finally(()=>T(!1))},t[19]=b,t[20]=w,t[21]=S,t[22]=r,t[23]=d,t[24]=n,t[25]=u,t[26]=P):P=t[26];let F=P,ee;t[27]===b?ee=t[28]:(ee=b?er(b.entry):``,t[27]=b,t[28]=ee);let te=ee,I=l?`icon-sm`:`sm`,L=o||w,ne=`Revision history, current: ${j}`,re=l?void 0:`design-revision-trigger`,ie;t[29]!==ne||t[30]!==re||t[31]!==I||t[32]!==L?(ie=(0,G.jsx)(kn,{render:(0,G.jsx)(W,{size:I,variant:`ghost`,disabled:L,"aria-label":ne,className:re})}),t[29]=ne,t[30]=re,t[31]=I,t[32]=L,t[33]=ie):ie=t[33];let R;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,G.jsx)(Re,{"aria-hidden":`true`}),t[34]=R):R=t[34];let ae;t[35]!==l||t[36]!==j?(ae=l?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`design-collapsible-label design-truncate`,children:j}),(0,G.jsx)(Ce,{"aria-hidden":`true`,className:`design-collapsible-label`})]}),t[35]=l,t[36]=j,t[37]=ae):ae=t[37];let oe;t[38]!==ie||t[39]!==ae?(oe=(0,G.jsxs)(Ot,{render:ie,children:[R,ae]}),t[38]=ie,t[39]=ae,t[40]=oe):oe=t[40];let se;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,G.jsx)(kt,{children:`Revision history`}),t[41]=se):se=t[41];let ce;t[42]===oe?ce=t[43]:(ce=(0,G.jsxs)(jt,{children:[oe,se]}),t[42]=oe,t[43]=ce);let le;t[44]!==E||t[45]!==o||t[46]!==a||t[47]!==g||t[48]!==c||t[49]!==m?(le=g?(0,G.jsxs)(jn,{onClick:()=>D(E+1),children:[g,` Retry`]}):m===null?(0,G.jsx)(jn,{disabled:!0,children:`Loading revisions...`}):m.length===0?(0,G.jsx)(jn,{disabled:!0,children:`No saved revisions yet`}):m.map(e=>{let t=e.fileHash===a;return(0,G.jsxs)(Nn,{children:[(0,G.jsx)(Pn,{children:(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,G.jsx)(`span`,{className:`truncate`,children:er(e)}),(0,G.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:nr(e,t)})]})}),(0,G.jsxs)(Fn,{children:[(0,G.jsx)(jn,{disabled:t||o,onClick:()=>{y(null),x({kind:`restore`,entry:e,expectedFileHash:a})},children:`Restore...`}),c?(0,G.jsx)(jn,{disabled:t,onClick:()=>c(e),children:`Compare with current`}):null,(0,G.jsx)(Mn,{}),(0,G.jsx)(jn,{disabled:o,onClick:()=>{y(null),C(e.label??``),x({kind:`rename`,entry:e})},children:`Rename...`}),(0,G.jsx)(jn,{disabled:t||o,onClick:()=>{y(null),x({kind:`delete`,entry:e})},children:`Delete...`})]})]},e.id)}),t[44]=E,t[45]=o,t[46]=a,t[47]=g,t[48]=c,t[49]=m,t[50]=le):le=t[50];let ue;t[51]===le?ue=t[52]:(ue=(0,G.jsx)(An,{align:`start`,className:`max-h-80 w-72 overflow-y-auto`,children:le}),t[51]=le,t[52]=ue);let de;t[53]!==f||t[54]!==ce||t[55]!==ue?(de=(0,G.jsxs)(On,{open:f,onOpenChange:p,children:[ce,ue]}),t[53]=f,t[54]=ce,t[55]=ue,t[56]=de):de=t[56];let fe=b!==null,pe;t[57]===N?pe=t[58]:(pe=e=>e?void 0:N(),t[57]=N,t[58]=pe);let me;t[59]===F?me=t[60]:(me=e=>{e.preventDefault(),F()},t[59]=F,t[60]=me);let he=b?.kind===`restore`?`Restore "${te}"?`:b?.kind===`rename`?`Rename revision`:`Delete "${te}"?`,ge;t[61]===he?ge=t[62]:(ge=(0,G.jsx)(Gn,{children:he}),t[61]=he,t[62]=ge);let _e=b?.kind===`restore`?`Replace this design with that revision. Your current version stays in revision history. Libraries and assets are unchanged.`:b?.kind===`rename`?`Name it so it is easy to find. Leave it empty to show what made it.`:`Its saved versions are removed from history. This cannot be undone.`,ve;t[63]===_e?ve=t[64]:(ve=(0,G.jsx)(Kn,{children:_e}),t[63]=_e,t[64]=ve);let ye;t[65]!==b||t[66]!==S?(ye=b?.kind===`rename`?(0,G.jsx)(Dn,{"aria-label":`Revision name`,value:S,maxLength:80,placeholder:er({...b.entry,label:void 0}),onChange:e=>C(e.currentTarget.value),autoFocus:!0}):null,t[65]=b,t[66]=S,t[67]=ye):ye=t[67];let be;t[68]===v?be=t[69]:(be=v?(0,G.jsx)(`p`,{role:`alert`,className:`design-revision-error`,children:v}):null,t[68]=v,t[69]=be);let z;t[70]!==ge||t[71]!==ve||t[72]!==ye||t[73]!==be?(z=(0,G.jsxs)(Un,{children:[ge,ve,ye,be]}),t[70]=ge,t[71]=ve,t[72]=ye,t[73]=be,t[74]=z):z=t[74];let xe;t[75]!==w||t[76]!==N?(xe=(0,G.jsx)(W,{type:`button`,size:`sm`,variant:`ghost`,disabled:w,onClick:N,children:`Cancel`}),t[75]=w,t[76]=N,t[77]=xe):xe=t[77];let Se=b?.kind===`delete`?`destructive`:`default`,we=w||!b,Te=b?.kind===`restore`?w?`Restoring...`:`Restore revision`:b?.kind===`rename`?w?`Saving...`:`Save name`:w?`Deleting...`:`Delete revision`,Ee;t[78]!==Se||t[79]!==we||t[80]!==Te?(Ee=(0,G.jsx)(W,{type:`submit`,size:`sm`,variant:Se,disabled:we,children:Te}),t[78]=Se,t[79]=we,t[80]=Te,t[81]=Ee):Ee=t[81];let B;t[82]!==xe||t[83]!==Ee?(B=(0,G.jsxs)(Wn,{children:[xe,Ee]}),t[82]=xe,t[83]=Ee,t[84]=B):B=t[84];let De;t[85]!==me||t[86]!==z||t[87]!==B?(De=(0,G.jsx)(Hn,{className:`max-w-md`,children:(0,G.jsxs)(`form`,{onSubmit:me,children:[z,B]})}),t[85]=me,t[86]=z,t[87]=B,t[88]=De):De=t[88];let Oe;t[89]!==fe||t[90]!==pe||t[91]!==De?(Oe=(0,G.jsx)(Rn,{open:fe,onOpenChange:pe,children:De}),t[89]=fe,t[90]=pe,t[91]=De,t[92]=Oe):Oe=t[92];let ke;return t[93]!==de||t[94]!==Oe?(ke=(0,G.jsxs)(G.Fragment,{children:[de,Oe]}),t[93]=de,t[94]=Oe,t[95]=ke):ke=t[95],ke}function ar(e){return e+1}function or(e){let t=new URL(`p4design://open`);if(t.searchParams.set(`project`,e.projectRoot),t.searchParams.set(`file`,e.documentPath),t.searchParams.set(`revision`,e.revision),e.environmentId&&t.searchParams.set(`environment`,e.environmentId),!sr(t.href))throw Error(`Invalid design reference.`);return t.href}function sr(e){if(e.length>16384)return null;try{let t=new URL(e.trim());if(t.protocol!==`p4design:`||t.host!==`open`||t.username||t.password||t.hash||t.pathname)return null;let n=t.searchParams.get(`project`)??``,r=t.searchParams.get(`file`)??``,i=t.searchParams.get(`revision`)??``,a=t.searchParams.get(`environment`);return!/^(\/|[a-z]:[\\/])/i.test(n)||/\p{Cc}/u.test(n)||!r.endsWith(`.p4design`)||/^[\\/]|^[a-z]:/i.test(r)||r.split(/[\\/]/).some(e=>!e||e===`.`||e===`..`)||/\p{Cc}/u.test(r)||!/^[0-9a-f]{64}$/.test(i)||a!==null&&(!a||a.length>200)?null:{projectRoot:n,documentPath:r,revision:i,...a?{environmentId:a}:{}}}catch{return null}}var cr=()=>null;function lr({target:e,path:t,revision:n,compact:r=!1,iconOnly:i=!1}){let{navigation:a}=Yn(),o=(a.useWorkspaceRoot??cr)(e),[s,c]=(0,H.useState)(null);if(!e||!o||!t||!n)return null;let l=or({projectRoot:o,documentPath:t,revision:n,...a.linkEnvironment?{environmentId:e.environmentId}:{}}),u=s?.link===l?s:null,d=()=>{Promise.resolve().then(()=>navigator.clipboard.writeText(l)).then(()=>c({link:l,error:!1}),()=>c({link:l,error:!0}))},f=u!==null&&!u.error;return(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[i?(0,G.jsxs)(jt,{children:[(0,G.jsx)(Ot,{render:(0,G.jsx)(W,{size:`icon-sm`,variant:`ghost`,"aria-label":f?`Link copied`:`Copy design link`,onClick:d}),children:(0,G.jsx)(Ue,{"aria-hidden":`true`})}),(0,G.jsx)(kt,{children:f?`Link copied`:`Copy design link`})]}):(0,G.jsxs)(W,{size:`sm`,variant:r?`ghost`:`outline`,onClick:d,children:[(0,G.jsx)(Ue,{"aria-hidden":`true`}),f?`Link copied`:r?`Copy link`:`Copy design link`]}),u?.error?(0,G.jsx)(`span`,{role:`alert`,className:`text-xs`,children:`Could not copy. Try again.`}):null,u&&!u.error?(0,G.jsx)(`span`,{role:`status`,className:`sr-only`,children:`Paste into a P4 Code thread in this project.`}):null]})}var ur=u(`relative inline-flex shrink-0 items-center justify-center gap-1 whitespace-nowrap rounded-sm border border-transparent font-medium outline-none transition-shadow focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-64 [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-3.5 sm:[&_svg:not([class*='size-'])]:size-3 [&_svg]:pointer-events-none [&_svg]:shrink-0 [button&,a&]:cursor-pointer [button&,a&]:pointer-coarse:after:absolute [button&,a&]:pointer-coarse:after:size-full [button&,a&]:pointer-coarse:after:min-h-11 [button&,a&]:pointer-coarse:after:min-w-11`,{defaultVariants:{size:`default`,variant:`default`},variants:{size:{default:`h-5.5 min-w-5.5 px-[calc(--spacing(1)-1px)] text-sm sm:h-4.5 sm:min-w-4.5 sm:text-xs`,lg:`h-6.5 min-w-6.5 px-[calc(--spacing(1.5)-1px)] text-base sm:h-5.5 sm:min-w-5.5 sm:text-sm`,sm:`h-5 min-w-5 rounded-[.25rem] px-[calc(--spacing(1)-1px)] text-xs sm:h-4 sm:min-w-4 sm:text-[.625rem]`},variant:{default:`bg-primary text-primary-foreground [button&,a&]:hover:bg-primary/90`,destructive:`bg-destructive text-white [button&,a&]:hover:bg-destructive/90`,error:`bg-destructive/8 text-destructive-foreground dark:bg-destructive/16`,info:`bg-info/8 text-info-foreground dark:bg-info/16`,outline:`border-input bg-background text-foreground dark:bg-input/32 [button&,a&]:hover:bg-accent/50 dark:[button&,a&]:hover:bg-input/48`,secondary:`bg-secondary text-secondary-foreground [button&,a&]:hover:bg-secondary/90`,success:`bg-success/8 text-success-foreground dark:bg-success/16`,warning:`bg-warning/8 text-warning-foreground dark:bg-warning/16`}}});function dr(e){let t=(0,U.c)(9),n,r,a,o;if(t[0]!==e){let{className:s,variant:c,size:l,render:u,...d}=e;n=u;let f={className:V(ur({className:s,size:l,variant:c})),"data-slot":`badge`};o=I,r=`span`,a=i(f,d),t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=o}else n=t[1],r=t[2],a=t[3],o=t[4];let s;return t[5]!==n||t[6]!==r||t[7]!==a?(s={defaultTagName:r,props:a,render:n},t[5]=n,t[6]=r,t[7]=a,t[8]=s):s=t[8],o(s)}function fr(e){let t=(0,U.c)(25),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({className:r,children:n,scrollFade:a,scrollbarGutter:o,hideScrollbars:s,chainVerticalScroll:c,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=a!==void 0&&a,u=o!==void 0&&o,d=s!==void 0&&s,f=c!==void 0&&c,p;t[8]===r?p=t[9]:(p=V(`relative size-full min-h-0 overflow-hidden rounded-[inherit]`,r),t[8]=r,t[9]=p);let m=f&&`overscroll-y-auto`,h=l&&`mask-t-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-y-start)))] mask-b-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-y-end)))] mask-l-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-x-start)))] mask-r-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-x-end)))] [--fade-size:1.5rem]`,g=u&&`scrollbar-gutter-stable`,_=d&&`[-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,v;t[10]!==m||t[11]!==h||t[12]!==g||t[13]!==_?(v=V(`h-full max-h-[inherit] overflow-auto overscroll-contain rounded-[inherit] outline-none transition-shadows focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background data-has-overflow-x:overscroll-x-contain`,m,h,g,_),t[10]=m,t[11]=h,t[12]=g,t[13]=_,t[14]=v):v=t[14];let y;t[15]!==n||t[16]!==v?(y=(0,G.jsx)(Zt,{className:v,"data-slot":`scroll-area-viewport`,children:n}),t[15]=n,t[16]=v,t[17]=y):y=t[17];let b;t[18]===d?b=t[19]:(b=!d&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(pr,{orientation:`vertical`}),(0,G.jsx)(pr,{orientation:`horizontal`}),(0,G.jsx)(en,{"data-slot":`scroll-area-corner`})]}),t[18]=d,t[19]=b);let x;return t[20]!==i||t[21]!==y||t[22]!==b||t[23]!==p?(x=(0,G.jsxs)(Xt,{className:p,...i,children:[y,b]}),t[20]=i,t[21]=y,t[22]=b,t[23]=p,t[24]=x):x=t[24],x}function pr(e){let t=(0,U.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,orientation:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`vertical`:i,o;t[4]===n?o=t[5]:(o=V(`flex opacity-0 transition-opacity delay-300 data-[orientation=horizontal]:mx-1 data-[orientation=horizontal]:mb-px data-[orientation=horizontal]:h-1.5 data-[orientation=vertical]:my-1 data-[orientation=vertical]:mr-px data-[orientation=vertical]:w-1.5 data-[orientation=horizontal]:flex-col data-hovering:opacity-100 data-scrolling:opacity-100 data-hovering:delay-0 data-scrolling:delay-0 data-hovering:duration-100 data-scrolling:duration-100`,n),t[4]=n,t[5]=o);let s;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,G.jsx)(Qt,{className:`relative flex-1 rounded-full bg-[var(--app-scrollbar-thumb)] transition-colors hover:bg-[var(--app-scrollbar-thumb-hover)]`,"data-slot":`scroll-area-thumb`}),t[6]=s):s=t[6];let c;return t[7]!==a||t[8]!==r||t[9]!==o?(c=(0,G.jsx)($t,{className:o,"data-slot":`scroll-area-scrollbar`,orientation:a,...r,children:s}),t[7]=a,t[8]=r,t[9]=o,t[10]=c):c=t[10],c}var mr=H.createContext({chipsRef:null,multiple:!1});function hr(e){let t=(0,U.c)(7),n=H.useRef(null),r=!!e.multiple,i;t[0]===r?i=t[1]:(i={chipsRef:n,multiple:r},t[0]=r,t[1]=i);let a=i,o;t[2]===e?o=t[3]:(o=(0,G.jsx)(Kt,{...e}),t[2]=e,t[3]=o);let s;return t[4]!==o||t[5]!==a?(s=(0,G.jsx)(mr,{value:a,children:o}),t[4]=o,t[5]=a,t[6]=s):s=t[6],s}function gr(e){let t=(0,U.c)(36),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({className:n,inputClassName:r,showTrigger:s,showClear:c,startAddon:o,size:a,unstyled:l,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=s===void 0||s,d=c!==void 0&&c,f=l!==void 0&&l,p=a??`default`,m;t[9]===o?m=t[10]:(m=o&&(0,G.jsx)(`div`,{"aria-hidden":`true`,className:`[&_svg]:-mx-0.5 pointer-events-none absolute inset-y-0 start-px z-10 flex items-center ps-[calc(--spacing(3)-1px)] opacity-80 has-[+[data-size=sm]]:ps-[calc(--spacing(2.5)-1px)] [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4`,"data-slot":`combobox-start-addon`,children:o}),t[9]=o,t[10]=m);let h=o&&`data-[size=sm]:*:data-[slot=combobox-input]:ps-[calc(--spacing(7.5)-1px)] *:data-[slot=combobox-input]:ps-[calc(--spacing(8.5)-1px)] sm:data-[size=sm]:*:data-[slot=combobox-input]:ps-[calc(--spacing(7)-1px)] sm:*:data-[slot=combobox-input]:ps-[calc(--spacing(8)-1px)]`,g=p===`sm`?`has-[+[data-slot=combobox-trigger],+[data-slot=combobox-clear]]:*:data-[slot=combobox-input]:pe-6.5`:`has-[+[data-slot=combobox-trigger],+[data-slot=combobox-clear]]:*:data-[slot=combobox-input]:pe-7`,_;t[11]!==n||t[12]!==h||t[13]!==g?(_=V(h,g,n),t[11]=n,t[12]=h,t[13]=g,t[14]=_):_=t[14];let v;t[15]===r?v=t[16]:(v=V(`has-disabled:opacity-100`,r),t[15]=r,t[16]=v);let y;t[17]!==p||t[18]!==v||t[19]!==f?(y=(0,G.jsx)(Dn,{className:v,nativeInput:!0,size:p,unstyled:f}),t[17]=p,t[18]=v,t[19]=f,t[20]=y):y=t[20];let b;t[21]!==i||t[22]!==_||t[23]!==y?(b=(0,G.jsx)(Vt,{className:_,"data-slot":`combobox-input`,render:y,...i}),t[21]=i,t[22]=_,t[23]=y,t[24]=b):b=t[24];let x;t[25]!==u||t[26]!==p?(x=u&&(0,G.jsx)(_r,{className:V(`-translate-y-1/2 absolute top-1/2 inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md border border-transparent opacity-80 outline-none transition-opacity pointer-coarse:after:absolute pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 hover:opacity-100 has-[+[data-slot=combobox-clear]]:hidden sm:size-7 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0`,p===`sm`?`end-0`:`end-0.5`),children:(0,G.jsx)(Lt,{"data-slot":`combobox-icon`,children:(0,G.jsx)(B,{})})}),t[25]=u,t[26]=p,t[27]=x):x=t[27];let S;t[28]!==d||t[29]!==p?(S=d&&(0,G.jsx)(wr,{className:V(`-translate-y-1/2 absolute top-1/2 inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md border border-transparent opacity-80 outline-none transition-opacity pointer-coarse:after:absolute pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 hover:opacity-100 has-[+[data-slot=combobox-clear]]:hidden sm:size-7 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0`,p===`sm`?`end-0`:`end-0.5`),children:(0,G.jsx)(lt,{})}),t[28]=d,t[29]=p,t[30]=S):S=t[30];let C;return t[31]!==b||t[32]!==x||t[33]!==S||t[34]!==m?(C=(0,G.jsxs)(`div`,{className:`relative not-has-[>*.w-full]:w-fit w-full text-foreground has-disabled:opacity-64`,children:[m,b,x,S]}),t[31]=b,t[32]=x,t[33]=S,t[34]=m,t[35]=C):C=t[35],C}function _r(e){let t=(0,U.c)(8),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;return t[4]!==n||t[5]!==r||t[6]!==i?(a=(0,G.jsx)(It,{className:r,"data-slot":`combobox-trigger`,...i,children:n}),t[4]=n,t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function vr(e){let t=(0,U.c)(22),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({className:a,children:i,side:s,sideOffset:c,alignOffset:n,align:l,anchor:r,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=s===void 0?`bottom`:s,d=c===void 0?4:c,f=l===void 0?`start`:l,{chipsRef:p}=H.use(mr),m=r??p,h;t[9]===a?h=t[10]:(h=V(`dropdown-glass relative flex max-h-[min(var(--available-height),23rem)] min-w-(--anchor-width) max-w-(--available-width) flex-1 flex-col origin-(--transform-origin) rounded-lg text-foreground transition-[scale,opacity] duration-[140ms] ease-[cubic-bezier(0.23,1,0.32,1)] data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0 data-instant:duration-0`,a),t[9]=a,t[10]=h);let g;t[11]!==i||t[12]!==o||t[13]!==h?(g=(0,G.jsx)(Ft,{className:h,"data-slot":`combobox-popup`,...o,children:i}),t[11]=i,t[12]=o,t[13]=h,t[14]=g):g=t[14];let _;return t[15]!==f||t[16]!==n||t[17]!==m||t[18]!==u||t[19]!==d||t[20]!==g?(_=(0,G.jsx)(Ut,{children:(0,G.jsx)(Bt,{align:f,alignOffset:n,anchor:m,className:`z-50 select-none`,"data-slot":`combobox-positioner`,side:u,sideOffset:d,children:g})}),t[15]=f,t[16]=n,t[17]=m,t[18]=u,t[19]=d,t[20]=g,t[21]=_):_=t[21],_}function yr(e){let t=(0,U.c)(17),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,contentClassName:i,children:n,hideIndicator:o,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===r?s=t[7]:(s=V(`flex min-h-8 in-data-[side=none]:min-w-[calc(var(--anchor-width)+1.25rem)] cursor-default items-center rounded-sm px-2 py-1 text-base outline-none hover:bg-accent data-disabled:pointer-events-none data-selected:bg-foreground/[0.08] data-selected:text-foreground data-highlighted:bg-accent data-highlighted:text-accent-foreground [&[data-highlighted][data-selected]]:bg-accent [&[data-highlighted][data-selected]]:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0`,r),t[6]=r,t[7]=s);let c;t[8]===i?c=t[9]:(c=V(`min-w-0 flex-1 [&_svg:not([class*='text-'])]:text-muted-foreground`,i),t[8]=i,t[9]=c);let l;t[10]!==n||t[11]!==c?(l=(0,G.jsx)(`div`,{className:c,"data-slot":`combobox-item-content`,children:n}),t[10]=n,t[11]=c,t[12]=l):l=t[12];let u;return t[13]!==a||t[14]!==s||t[15]!==l?(u=(0,G.jsx)(Ht,{className:s,"data-slot":`combobox-item`,...a,children:l}),t[13]=a,t[14]=s,t[15]=l,t[16]=u):u=t[16],u}function br(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`[[role=group]+&]:mt-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(qt,{className:i,"data-slot":`combobox-group`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function xr(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`px-2 py-1.5 font-medium text-muted-foreground text-xs`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(Jt,{className:i,"data-slot":`combobox-group-label`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Sr(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`not-empty:p-2 text-center text-base text-muted-foreground sm:text-sm`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(zt,{className:i,"data-slot":`combobox-empty`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Cr(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`not-empty:scroll-py-1 not-empty:px-1 not-empty:py-1`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(fr,{scrollbarGutter:!0,scrollFade:!0,children:(0,G.jsx)(Rt,{className:i,"data-slot":`combobox-list`,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function wr(e){let t=(0,U.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=(0,G.jsx)(Wt,{className:n,"data-slot":`combobox-clear`,...r}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i}function Tr(e){let t=(0,U.c)(2),n;return t[0]===e?n=t[1]:(n=(0,G.jsx)(Gt,{"data-slot":`combobox-collection`,...e}),t[0]=e,t[1]=n),n}var Er={thread:`This thread`,project:`Project`,other:`Other designs`};function Dr(e){let t=(0,U.c)(10),{target:n,item:r}=e,{transport:i}=Yn(),a;t[0]!==r.missing||t[1]!==r.modifiedAt||t[2]!==r.path||t[3]!==n||t[4]!==i?(a=n&&!r.missing?i.thumbnail(n,r.path,r.modifiedAt??``):null,t[0]=r.missing,t[1]=r.modifiedAt,t[2]=r.path,t[3]=n,t[4]=i,t[5]=a):a=t[5];let o=Qn(a),s=r.missing||o.error?null:o.data?.dataUrl,c;return t[6]!==r.missing||t[7]!==r.pageCount||t[8]!==s?(c=(0,G.jsx)(_n,{pageCount:r.pageCount,muted:r.missing,thumbnail:s}),t[6]=r.missing,t[7]=r.pageCount,t[8]=s,t[9]=c):c=t[9],c}function Or(e){let t=(0,U.c)(66),{target:n,path:r,paths:i,entries:a,linkedPaths:o,onOpen:s,statuses:c,onStartDesign:l,onStartDesignInNewThread:u,onManageDesigns:d,open:f,onOpenChange:p}=e,m=(0,H.useRef)(null),[h,g]=(0,H.useState)(``),[_,v]=(0,H.useState)(Mr),y;t[0]===r?y=t[1]:(y=r?vn(r):`Choose design`,t[0]=r,t[1]=y);let b=y,x;t[2]!==a||t[3]!==o||t[4]!==i?(x=xn({paths:i,entries:a,linkedPaths:o}),t[2]=a,t[3]=o,t[4]=i,t[5]=x):x=t[5];let S=x,C;t[6]===h?C=t[7]:(C=h.trim(),t[6]=h,t[7]=C);let w=C.length>0,T;if(t[8]!==_||t[9]!==S||t[10]!==h||t[11]!==w){let e=S.filter(e=>wn(e,h));T=[`thread`,`project`,`other`].map(t=>{let n=e.filter(e=>e.group===t);return{value:t,count:n.length,items:!w&&_.has(t)?[]:n}}).filter(jr),t[8]=_,t[9]=S,t[10]=h,t[11]=w,t[12]=T}else T=t[12];let E=T,D;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>v(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),t[13]=D):D=t[13];let O=D,k;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(k=Date.now(),t[14]=k):k=t[14];let A=k,j;t[15]===p?j=t[16]:(j=()=>{p(!1),g(``)},t[15]=p,t[16]=j);let M=j;if(!S.length&&!l){let e=r||b,n;return t[17]!==e||t[18]!==b?(n=(0,G.jsx)(`h1`,{className:`design-title`,children:(0,G.jsx)(Mt,{full:e,children:b})}),t[17]=e,t[18]=b,t[19]=n):n=t[19],n}let N;t[20]!==M||t[21]!==s||t[22]!==r?(N=e=>{e&&(M(),e.path!==r&&s(e.path))},t[20]=M,t[21]=s,t[22]=r,t[23]=N):N=t[23];let P;t[24]!==M||t[25]!==p?(P=e=>e?p(!0):M(),t[24]=M,t[25]=p,t[26]=P):P=t[26];let F=r||b,ee,te;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,G.jsx)(_r,{render:(0,G.jsx)(W,{variant:`ghost`,size:`sm`}),className:`design-document-switcher`}),te=(0,G.jsx)(`span`,{className:`sr-only`,children:`Design document: `}),t[27]=ee,t[28]=te):(ee=t[27],te=t[28]);let I;t[29]===b?I=t[30]:(I=(0,G.jsx)(`span`,{ref:m,className:`design-truncate`,children:b}),t[29]=b,t[30]=I);let L;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,G.jsx)(Ce,{"aria-hidden":`true`,size:14}),t[31]=L):L=t[31];let ne;t[32]!==F||t[33]!==I?(ne=(0,G.jsxs)(At,{full:F,labelRef:m,render:ee,children:[te,I,L]}),t[32]=F,t[33]=I,t[34]=ne):ne=t[34];let re;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,G.jsxs)(`div`,{className:`design-picker-search`,children:[(0,G.jsx)(gr,{"aria-label":`Search designs`,placeholder:`Search designs`,showTrigger:!1,size:`sm`,startAddon:(0,G.jsx)(tt,{})}),(0,G.jsx)(`kbd`,{className:`design-picker-kbd`,"aria-hidden":`true`,children:`esc`})]}),t[35]=re):re=t[35];let ie;t[36]!==S.length||t[37]!==h||t[38]!==w?(ie=w?(0,G.jsxs)(`div`,{className:`design-picker-empty`,children:[(0,G.jsxs)(`strong`,{children:[`No designs match "`,h.trim(),`"`]}),(0,G.jsx)(W,{size:`sm`,variant:`outline`,onClick:()=>g(``),children:`Clear search`})]}):S.length?null:(0,G.jsx)(`div`,{className:`design-picker-empty`,children:`No designs in this project yet.`}),t[36]=S.length,t[37]=h,t[38]=w,t[39]=ie):ie=t[39];let R;t[40]===ie?R=t[41]:(R=(0,G.jsx)(Sr,{children:ie}),t[40]=ie,t[41]=R);let ae;t[42]!==_||t[43]!==r||t[44]!==h||t[45]!==w||t[46]!==c||t[47]!==n?(ae=(0,G.jsx)(Cr,{className:`design-picker-list`,children:e=>(0,G.jsxs)(br,{items:e.items,children:[(0,G.jsx)(xr,{className:`design-picker-group`,children:(0,G.jsxs)(`button`,{type:`button`,className:`design-picker-group-toggle`,"aria-expanded":w||!_.has(e.value),disabled:w,onMouseDown:kr,onClick:()=>O(e.value),children:[w||!_.has(e.value)?(0,G.jsx)(Ce,{"aria-hidden":`true`,size:14}):(0,G.jsx)(Te,{"aria-hidden":`true`,size:14}),(0,G.jsx)(`span`,{className:`flex-1`,children:Er[e.value]}),(0,G.jsx)(`span`,{children:e.count})]})}),(0,G.jsx)(Tr,{children:e=>{let t=c?.get(e.path),i=yn(e.name,h);return(0,G.jsx)(yr,{value:e,children:(0,G.jsxs)(`span`,{className:`design-picker-item`,children:[(0,G.jsx)(Dr,{target:n,item:e}),(0,G.jsxs)(`span`,{className:`design-picker-text`,children:[(0,G.jsxs)(`span`,{className:`design-picker-name`,children:[i.before,i.match?(0,G.jsx)(`mark`,{children:i.match}):null,i.after]}),(0,G.jsx)(`span`,{className:`design-picker-meta`,children:Sn(e,A)})]}),e.missing?(0,G.jsx)(dr,{variant:`warning`,size:`sm`,children:`Missing`}):e.path===r?(0,G.jsx)(dr,{variant:`info`,size:`sm`,children:`Open`}):t?(0,G.jsx)(dr,{variant:t.tone,size:`sm`,children:t.label}):null]})},e.path)}})]},e.value)}),t[42]=_,t[43]=r,t[44]=h,t[45]=w,t[46]=c,t[47]=n,t[48]=ae):ae=t[48];let oe;t[49]!==M||t[50]!==d||t[51]!==l||t[52]!==u?(oe=l||u||d?(0,G.jsxs)(`div`,{className:`design-picker-footer`,children:[l?(0,G.jsxs)(W,{size:`sm`,variant:`ghost`,onClick:()=>{M(),l()},children:[(0,G.jsx)(Ze,{"aria-hidden":`true`}),`New design in this thread`]}):null,u?(0,G.jsxs)(W,{size:`sm`,variant:`ghost`,onClick:()=>{M(),u()},children:[(0,G.jsx)(Ke,{"aria-hidden":`true`}),`New design in a new thread`]}):null,d?(0,G.jsxs)(W,{size:`sm`,variant:`ghost`,onClick:()=>{M(),d()},children:[(0,G.jsx)(Ve,{"aria-hidden":`true`}),`Manage designs`]}):null]}):null,t[49]=M,t[50]=d,t[51]=l,t[52]=u,t[53]=oe):oe=t[53];let se;t[54]!==R||t[55]!==ae||t[56]!==oe?(se=(0,G.jsxs)(vr,{className:`design-picker max-h-[min(var(--available-height),34rem)]`,align:`start`,children:[re,R,ae,oe]}),t[54]=R,t[55]=ae,t[56]=oe,t[57]=se):se=t[57];let ce;return t[58]!==E||t[59]!==f||t[60]!==h||t[61]!==ne||t[62]!==se||t[63]!==N||t[64]!==P?(ce=(0,G.jsxs)(hr,{items:E,filteredItems:E,inputValue:h,onInputValueChange:g,value:null,onValueChange:N,itemToStringLabel:Ar,open:f,onOpenChange:P,autoHighlight:!0,children:[ne,se]}),t[58]=E,t[59]=f,t[60]=h,t[61]=ne,t[62]=se,t[63]=N,t[64]=P,t[65]=ce):ce=t[65],ce}function kr(e){return e.preventDefault()}function Ar(e){return e.name}function jr(e){return e.count>0}function Mr(){return new Set([`other`])}var Nr=dt,Pr=A(de),Fr=A(D),Ir=(e,t,n,r=`error`)=>({code:e,message:t,severity:r,...n?{nodeId:n}:{}});function Lr(e){let t=e=>{if(e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e))return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(t).join(`,`)}]`;if(typeof e==`object`&&e&&Object.getPrototypeOf(e)===Object.prototype){let n=e;return`{${Object.keys(n).sort().map(e=>`${JSON.stringify(e)}:${t(n[e])}`).join(`,`)}}`}throw Error(`Design JSON must contain only finite JSON values`)};return`${t(e)}\n`}function Rr(e){return ut(Nr(typeof e==`string`?new TextEncoder().encode(e):e))}function zr(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t||!(`version`in t)||typeof t.version!=`string`||!/^\d+\.\d+$/.test(t.version))throw Error(`Missing or invalid format version`);return t.version.split(`.`)[0]===`1`?{status:`editable`,document:Pr(t,{onExcessProperty:`error`}),fileHash:Rr(e),diagnostics:[]}:{status:`read-only`,raw:t,source:e,fileHash:Rr(e),diagnostics:[Ir(`unknown-major`,`Unsupported design version ${t.version}`)]}}catch{return{status:`invalid`,source:e,diagnostics:[Ir(`invalid-schema`,`Invalid .p4design JSON or schema`)]}}}function Br(e,t){return Fr({...e,...t},{onExcessProperty:`error`})}function Vr(e){let t=new Map,n=new Map,r=[],i=(i,a,o)=>{e.nodes[i]||r.push(Ir(`missing-node`,`Referenced node is missing`,a??i)),t.has(i)?r.push(Ir(`multiple-parents`,`Node occurs in more than one ordered child list`,i)):(t.set(i,a),n.set(i,o))};e.roots.forEach((e,t)=>i(e,null,t));for(let[t,n]of Object.entries(e.nodes))`children`in n&&n.children.forEach((e,n)=>i(e,t,n));for(let[t,n]of Object.entries(e.instances))for(let e of Object.values(n.slots))e.forEach((e,n)=>i(e,t,n));let a=new Set,o=new Set,s=(t,n)=>{if(a.has(t)){r.push(Ir(`tree-cycle`,`Child lists contain a cycle`,t));return}if(n>256){r.push(Ir(`depth-limit`,`Scene exceeds 256 levels`,t));return}if(o.has(t))return;a.add(t);let i=e.nodes[t];if(i&&`children`in i)for(let e of i.children)s(e,n+1);a.delete(t),o.add(t)};for(let t of Object.keys(e.nodes))s(t,0);return{parents:t,order:n,diagnostics:r}}function Hr(e,t,n={},r=new Set){if(r.has(t))throw Error(`token-cycle`);if(r.size>=256)throw Error(`token-depth-limit`);let i=e.tokens[t];if(!i)throw Error(`missing-token`);let a=new Set(r).add(t),o=i.variants.filter(e=>Object.entries(e.theme).every(([e,t])=>n[e]===t));if(o.sort((e,t)=>Object.keys(t.theme).length-Object.keys(e.theme).length),o[0]&&o.some(e=>Object.keys(e.theme).length===Object.keys(o[0].theme).length&&Lr(e.value)!==Lr(o[0].value)))throw Error(`ambiguous-token`);let s=o[0]?.value??i.value,c=typeof s==`object`?Hr(e,s.tokenId,n,a):s;if((i.kind===`number`?typeof c!=`number`:typeof c!=`string`)||i.kind===`color`&&(typeof c!=`string`||!/^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/.test(c)))throw Error(`token-type`);return c}function Ur(e,t,n={}){return typeof t==`object`?Hr(e,t.tokenId,n):t}function Wr(e,t={}){let n=[],r=(e,i,a,o,s,c,l)=>{let u=e.nodes[i];if(!u){n.push(Ir(`missing-node`,`Expansion target is missing`,o));return}if(l>256||s.has(`${e.documentId}/node/${i}`)){n.push(Ir(`component-cycle`,`Expansion contains a cycle or exceeds 256 levels`,o));return}let d=u;try{c[i]&&(d=Br(d,c[i]))}catch{n.push(Ir(`invalid-override`,`Override does not match its source node`,o))}let f=new Set(s).add(`${e.documentId}/node/${i}`);if(d.type===`ref`){let s=d.importId?e.imports[d.importId]:void 0,u=s?t.manifest?.libraries[s.libraryId]:void 0,p=d.importId?u?.exports.includes(d.componentId)&&s?t.documents?.[s.libraryId]:void 0:e,m=p?.components[d.componentId];if(!p||!m)return n.push(Ir(`missing-import`,`Component or exported library symbol is unavailable`,o)),{key:a,sourceId:i,ownerId:o,document:e,node:d,children:[]};let h=e.instances[i],g={...c,...h?.overrides},_=p===e?p:{...p,tokens:{...p.tokens,...e.tokens},themeAxes:{...p.themeAxes,...e.themeAxes}},v=r(_,m.rootId,`${a}/${m.rootId}`,o,f,g,l+1);if(!v)return;let y=t=>{let n=Object.entries(m.slots).find(([,e])=>e.nodeId===t.sourceId),i=n?h?.slots[n[0]]:void 0;return i?{...t,children:i.flatMap(n=>{let i=r(e,n,`${t.key}/slot/${n}`,o,f,{},l+1);return i?[i]:[]})}:{...t,children:t.children.map(y)}},{type:b,componentId:x,importId:S,...C}=d;return{...y(v),key:a,ownerId:o,node:{...v.node,...C}}}let p=`children`in d?d.children.flatMap(t=>{let n=r(e,t,`${a}/${t}`,o===i?t:o,f,c,l+1);return n?[n]:[]}):[];return{key:a,sourceId:i,ownerId:o,document:e,node:d,children:p}};return{roots:e.roots.flatMap(t=>{let n=r(e,t,t,t,new Set,{},0);return n?[n]:[]}),diagnostics:n}}function Gr(e,t){let n=new Set(t),r=new Set(e.filter(e=>n.has(e.ownerId)).map(e=>e.key));return e.filter(e=>{let t=e.key;for(;t;){if(r.has(t))return!0;let e=t.lastIndexOf(`/`);if(e<0)break;t=t.slice(0,e)}return!1})}function Kr(e,t={},n={}){let r=Wr(e,n),i=[...r.diagnostics],a=[],o=(e,n)=>{try{let r=Ur(e.document,n,t);if(typeof r!=`number`||!Number.isFinite(r))throw Error(`token-type`);return r}catch{return i.push(Ir(`invalid-layout-token`,`Layout value requires a finite number`,e.ownerId)),0}},s=new Map,c=e=>{let t=s.get(e.key);if(t)return t;let n=e.node,r=e.children.map(c),a=`layout`in n?n.layout:void 0,l=a?Object.fromEntries(Object.entries(a.padding).map(([t,n])=>[t,o(e,n)])):{top:0,right:0,bottom:0,left:0},u=a?o(e,a.gap):0,d=a?.direction??`none`,f=d===`horizontal`?r.reduce((e,t)=>e+t.width,0)+Math.max(0,r.length-1)*u:Math.max(0,...r.map(e=>e.width)),p=d===`vertical`?r.reduce((e,t)=>e+t.height,0)+Math.max(0,r.length-1)*u:Math.max(0,...r.map(e=>e.height));if(d===`none`&&(f=Math.max(0,...e.children.map((e,t)=>o(e,e.node.x)+r[t].width)),p=Math.max(0,...e.children.map((e,t)=>o(e,e.node.y)+r[t].height))),n.type===`text`){let t=o(e,n.fontSize),r=n.lineHeight?o(e,n.lineHeight):1.2,i=n.text.split(`
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{r as t}from"./Icon-l19w4AjM.js";import{$o as n,BE as r,Co as i,D as a,Eg as o,Er as s,Es as c,Fw as l,Hu as u,Hw as d,Ir as f,Ix as p,Jc as m,Kc as h,Kw as g,Kx as _,Lr as v,NS as y,Qo as b,RT as x,SS as S,Ss as C,Sv as w,VS as T,W as E,Yc as D,Ys as O,_S as k,ab as A,b as j,bn as M,br as N,cb as P,ds as F,eC as I,es as ee,fr as L,fw as te,gs as ne,hr as re,hs as R,hv as ie,l as ae,lr as oe,mE as se,mr as ce,pr as le,qS as ue,qc as de,rs as fe,ts as pe,ya as me,yn as he,yr as ge}from"./utils-B0w8dSf5.js";import{t as _e}from"./arrow-down-up-B46gw0xW.js";import{t as ve}from"./arrow-down-DvRecXuy.js";import{t as ye}from"./arrow-left-BLE461db.js";import{t as be}from"./arrow-right-CoV5ameY.js";import{t as z}from"./arrow-up-right-C6IM-WPd.js";import{t as xe}from"./arrow-up-3Yp3lsoe.js";import{t as Se}from"./boxes-D4AJ0ucE.js";import{t as Ce}from"./chevron-down-DHV04o66.js";import{t as we}from"./chevron-left-DrNh6cTh.js";import{t as Te}from"./chevron-right-NbahR9_s.js";import{t as Ee}from"./chevron-up-C-w52bD6.js";import{t as B}from"./chevrons-up-down-BMPucOK_.js";import{t as De}from"./circle-alert-B83jEPoh.js";import{t as Oe}from"./circle-4zZlZno3.js";import{t as ke}from"./component-HJu09bM6.js";import{t as Ae}from"./download-BAp4p4A-.js";import{t as je}from"./ellipsis-6x3R4_IB.js";import{t as Me}from"./file-code-corner-Dt6PpZnb.js";import{t as Ne}from"./focus-o7yKOd1j.js";import{t as Pe}from"./folder-CMIvEUJv.js";import{t as Fe}from"./frame-DGUYPXa7.js";import{t as Ie}from"./group-aBPDkCFm.js";import{t as Le}from"./hand-Bz2YZhrG.js";import{t as Re}from"./history-B22_6xEN.js";import{t as ze}from"./image-xUrgiZ2i.js";import{t as Be}from"./layers-BqgDAlx3.js";import{t as Ve}from"./layout-grid-CCkPw5ih.js";import{t as He}from"./library-C8DuZzap.js";import{t as Ue}from"./link-zAXVcUwk.js";import{t as We}from"./map-pin-5mbcayYf.js";import{t as Ge}from"./maximize-2-CHT2IkVy.js";import{t as Ke}from"./message-square-plus-ChUy6onn.js";import{t as qe}from"./message-square-DLzUyuIE.js";import{t as Je}from"./minus-C7W28oE7.js";import{t as Ye}from"./monitor-Ddj8MK6z.js";import{t as Xe}from"./mouse-pointer-2-DbBU41il.js";import{t as Ze}from"./plus-Cr075-cy.js";import{t as Qe}from"./refresh-cw-PY_ECjtI.js";import{t as $e}from"./scan-search-Chb5YdZY.js";import{t as et}from"./scan-BPBcmOMp.js";import{t as tt}from"./search-Cr9eaeTj.js";import{t as nt}from"./settings-CTjEqsg3.js";import{t as rt}from"./spline-EJpY6uhz.js";import{t as it}from"./square-DVrCvZRU.js";import{t as at}from"./swatch-book-CO6HbEgI.js";import{t as ot}from"./type-ChjbxAhu.js";import{t as st}from"./upload-D9-Kv89Z.js";import{t as ct}from"./wifi-off-DtJhRDhE.js";import{t as lt}from"./x-CSwbgjBe.js";import{_ as ut,g as dt}from"./runtime-IzhBj1XN.js";import{j as ft,k as pt}from"./entities-CrdpKvvL.js";import{t as mt}from"./runtime-BWwa38SO.js";import{a as ht,c as gt,i as _t,l as vt,n as yt,o as bt,r as xt,s as St,t as Ct,u as wt}from"./SelectScrollUpArrow-CMpd0Jm1.js";import{t as Tt}from"./useNavigate-CSxB1zLo.js";import{S as Et}from"./useSettings-DPnlKDDE.js";import{u as Dt}from"./rightPanelStore-BLSD3K6s.js";import{a as Ot,i as kt,n as At,o as V,r as jt,t as Mt}from"./ClippedText-DoAq5p0h.js";import{n as Nt,t as Pt}from"./CheckboxIndicator-CtJqB7ns.js";import{a as Ft,f as It,i as Lt,l as Rt,n as zt,o as Bt,p as Vt,r as Ht,s as Ut,t as Wt,u as Gt}from"./ComboboxClear-gWUoU_9i.js";import{d as Kt}from"./combobox-CJgXDxx7.js";import{n as qt,t as Jt}from"./ComboboxGroupLabel-PqwekxYO.js";import{t as Yt}from"./Input-BcEftKLM.js";import{a as Xt,i as Zt,n as Qt,r as $t,t as en}from"./ScrollAreaCorner-CpFtD7m1.js";import{c as tn,l as nn,n as rn,o as an,r as on,s as sn,t as cn,u as ln}from"./DialogTitle-B_iSZXaO.js";import{a as un,c as dn,n as fn,o as pn,r as mn,s as hn}from"./PopoverHandle-BUkWn6lX.js";import{t as gn}from"./AlertDialogRoot-uMQTdBRo.js";import{t as _n}from"./DesignPageTile-6OCPIqLU.js";import{c as vn,d as yn,i as bn,l as xn,s as Sn,t as Cn,u as wn}from"./design-Bt_NY2zM.js";import{n as Tn}from"./useHandleNewThread-NoutVPDs.js";var H=e(t(),1),U=r(),En=u(`[&_svg]:-mx-0.5 relative inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-lg border font-medium text-base outline-none transition-colors pointer-coarse:after:absolute pointer-coarse:after:size-full pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-64 sm:text-sm [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0`,{defaultVariants:{size:`default`,variant:`default`},variants:{size:{default:`h-9 px-[calc(--spacing(3)-1px)] sm:h-8`,icon:`size-9 sm:size-8`,"icon-lg":`size-10 sm:size-9`,"icon-micro":`size-5 rounded-sm p-0 [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-8 sm:size-7`,"icon-xl":`size-11 sm:size-10 [&_svg:not([class*='size-'])]:size-5 sm:[&_svg:not([class*='size-'])]:size-4.5`,"icon-xs":`size-7 rounded-md sm:size-6 not-in-data-[slot=input-group]:[&_svg:not([class*='size-'])]:size-4 sm:not-in-data-[slot=input-group]:[&_svg:not([class*='size-'])]:size-3.5`,lg:`h-10 px-[calc(--spacing(3.5)-1px)] sm:h-9`,sm:`h-8 gap-1.5 px-[calc(--spacing(2.5)-1px)] sm:h-7`,xl:`h-11 px-[calc(--spacing(4)-1px)] text-lg sm:h-10 sm:text-base [&_svg:not([class*='size-'])]:size-5 sm:[&_svg:not([class*='size-'])]:size-4.5`,xs:`h-7 gap-1 rounded-md px-[calc(--spacing(2)-1px)] text-sm sm:h-6 sm:text-xs [&_svg:not([class*='size-'])]:size-4 sm:[&_svg:not([class*='size-'])]:size-3.5`},variant:{default:`border-primary bg-primary text-primary-foreground [:active,[data-pressed]]:bg-primary/80 [:hover,[data-pressed]]:bg-primary/90`,destructive:`border-primary bg-primary text-primary-foreground [:active,[data-pressed]]:bg-primary/80 [:hover,[data-pressed]]:bg-primary/90`,"destructive-outline":`border-input bg-popover not-dark:bg-clip-padding text-foreground dark:bg-input/32 [:active,[data-pressed]]:bg-accent/70 [:hover,[data-pressed]]:bg-accent/50 dark:[:hover,[data-pressed]]:bg-input/64 [&_svg:not([class*='text-'])]:text-muted-foreground`,ghost:`border-transparent text-foreground data-pressed:bg-accent [:hover,[data-pressed]]:bg-accent [&_svg:not([class*='text-'])]:text-muted-foreground`,link:`border-transparent underline-offset-4 [:hover,[data-pressed]]:underline`,outline:`border-input bg-popover not-dark:bg-clip-padding text-foreground dark:bg-input/32 [:active,[data-pressed]]:bg-accent/70 [:hover,[data-pressed]]:bg-accent/50 dark:[:hover,[data-pressed]]:bg-input/64 [&_svg:not([class*='text-'])]:text-muted-foreground`,secondary:`border-transparent bg-secondary text-secondary-foreground [:active,[data-pressed]]:bg-secondary/80 [:hover,[data-pressed]]:bg-secondary/90`}}});function W(e){let t=(0,U.c)(9),n,r,a,o;if(t[0]!==e){let{className:s,variant:c,size:l,render:u,...d}=e;n=u;let f=n?void 0:`button`,p={className:V(En({className:s,size:l,variant:c})),"data-slot":`button`,type:f};o=L,r=`button`,a=i(p,d),t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=o}else n=t[1],r=t[2],a=t[3],o=t[4];let s;return t[5]!==n||t[6]!==r||t[7]!==a?(s={defaultTagName:r,props:a,render:n},t[5]=n,t[6]=r,t[7]=a,t[8]=s):s=t[8],o(s)}var G=e(se(),1);function Dn(e){let t=(0,U.c)(30),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:n,size:i,unstyled:a,nativeInput:o,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=i===void 0?`default`:i,c=a!==void 0&&a,l=o!==void 0&&o,u=s===`sm`&&`h-7.5 px-[calc(--spacing(2.5)-1px)] leading-7.5 sm:h-6.5 sm:leading-6.5`,d=s===`lg`&&`h-9.5 leading-9.5 sm:h-8.5 sm:leading-8.5`,f=r.type===`search`&&`[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none [&::-webkit-search-results-button]:appearance-none [&::-webkit-search-results-decoration]:appearance-none`,p=r.type===`file`&&`text-muted-foreground file:me-3 file:bg-transparent file:font-medium file:text-foreground file:text-sm`,m;t[6]!==u||t[7]!==d||t[8]!==f||t[9]!==p?(m=V(`h-8.5 w-full min-w-0 rounded-[inherit] px-[calc(--spacing(3)-1px)] leading-8.5 outline-none placeholder:text-muted-foreground/72 sm:h-7.5 sm:leading-7.5 [transition:background-color_5000000s_ease-in-out_0s]`,u,d,f,p),t[6]=u,t[7]=d,t[8]=f,t[9]=p,t[10]=m):m=t[10];let h=m,g;if(l){let e,n;if(t[11]!==r){let{style:i,onValueChange:a,...o}=r;n=i,e=o,t[11]=r,t[12]=e,t[13]=n}else e=t[12],n=t[13];let i=typeof n==`function`?void 0:n,a=typeof s==`number`?s:void 0,o=e,c;t[14]!==h||t[15]!==i||t[16]!==o||t[17]!==a?(c=(0,G.jsx)(`input`,{className:h,"data-slot":`input`,size:a,style:i,...o}),t[14]=h,t[15]=i,t[16]=o,t[17]=a,t[18]=c):c=t[18],g=c}else{let e=typeof s==`number`?s:void 0,n;t[19]!==h||t[20]!==r||t[21]!==e?(n=(0,G.jsx)(Yt,{className:h,"data-slot":`input`,size:e,...r}),t[19]=h,t[20]=r,t[21]=e,t[22]=n):n=t[22],g=n}let _;t[23]!==n||t[24]!==c?(_=V(!c&&`relative inline-flex w-full rounded-lg border border-input bg-background not-dark:bg-clip-padding text-base text-foreground shadow-xs/5 ring-ring/24 transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-has-disabled:not-has-focus-visible:not-has-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] has-focus-visible:has-aria-invalid:border-destructive/64 has-focus-visible:has-aria-invalid:ring-destructive/16 has-aria-invalid:border-destructive/36 has-focus-visible:border-ring has-autofill:bg-foreground/4 has-disabled:opacity-64 has-[:disabled,:focus-visible,[aria-invalid]]:shadow-none has-focus-visible:ring-[3px] sm:text-sm dark:bg-input/32 dark:has-autofill:bg-foreground/8 dark:has-aria-invalid:ring-destructive/24 dark:not-has-disabled:not-has-focus-visible:not-has-aria-invalid:before:shadow-[0_-1px_--theme(--color-white/6%)]`,n)||void 0,t[23]=n,t[24]=c,t[25]=_):_=t[25];let v;return t[26]!==g||t[27]!==s||t[28]!==_?(v=(0,G.jsx)(`span`,{className:_,"data-size":s,"data-slot":`input-control`,children:g}),t[26]=g,t[27]=s,t[28]=_,t[29]=v):v=t[29],v}var On=N;function kn(e){let t=(0,U.c)(8),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;return t[4]!==n||t[5]!==r||t[6]!==i?(a=(0,G.jsx)(re,{className:r,"data-slot":`menu-trigger`,...i,children:n}),t[4]=n,t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function An(e){let t=(0,U.c)(26),n,r,i,a,o,c,l,u,d;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],c=t[6],l=t[7],u=t[8],d=t[9]):({children:i,className:a,sideOffset:l,align:u,alignOffset:n,side:d,anchor:r,disableAnchorTracking:o,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=c,t[7]=l,t[8]=u,t[9]=d);let p=l===void 0?4:l,m=u===void 0?`center`:u,h=d===void 0?`bottom`:d,g;t[10]===a?g=t[11]:(g=V(`dropdown-glass relative flex not-[class*='w-']:min-w-32 origin-(--transform-origin) rounded-lg outline-none transition-[scale,opacity] duration-[140ms] ease-[cubic-bezier(0.23,1,0.32,1)] data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0 data-instant:duration-0 focus:outline-none`,a),t[10]=a,t[11]=g);let _;t[12]===i?_=t[13]:(_=(0,G.jsx)(`div`,{className:`max-h-(--available-height) w-full overflow-y-auto p-1`,children:i}),t[12]=i,t[13]=_);let y;t[14]!==c||t[15]!==g||t[16]!==_?(y=(0,G.jsx)(v,{className:g,"data-slot":`menu-popup`,...c,children:_}),t[14]=c,t[15]=g,t[16]=_,t[17]=y):y=t[17];let b;return t[18]!==m||t[19]!==n||t[20]!==r||t[21]!==o||t[22]!==h||t[23]!==p||t[24]!==y?(b=(0,G.jsx)(f,{children:(0,G.jsx)(s,{align:m,alignOffset:n,anchor:r,disableAnchorTracking:o,className:`z-[60]`,"data-slot":`menu-positioner`,side:h,sideOffset:p,children:y})}),t[18]=m,t[19]=n,t[20]=r,t[21]=o,t[22]=h,t[23]=p,t[24]=y,t[25]=b):b=t[25],b}function jn(e){let t=(0,U.c)(12),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:n,inset:r,variant:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=a===void 0?`default`:a,s;t[5]===n?s=t[6]:(s=V(`[&>svg]:-mx-0.5 flex min-h-8 cursor-default select-none items-center gap-2 rounded-sm px-2 py-1 text-base text-foreground outline-none data-disabled:pointer-events-none data-highlighted:bg-accent data-inset:ps-8 data-[variant=destructive]:text-destructive-foreground data-highlighted:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&>svg:not([class*='opacity-'])]:opacity-80 [&>svg:not([class*='size-'])]:size-4.5 sm:[&>svg:not([class*='size-'])]:size-4 [&>svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:[&>svg:not([class*='text-'])]:text-current [&>svg]:pointer-events-none [&>svg]:shrink-0`,n),t[5]=n,t[6]=s);let c;return t[7]!==r||t[8]!==i||t[9]!==s||t[10]!==o?(c=(0,G.jsx)(me,{className:s,"data-inset":r,"data-slot":`menu-item`,"data-variant":o,...i}),t[7]=r,t[8]=i,t[9]=s,t[10]=o,t[11]=c):c=t[11],c}function Mn(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`mx-2 my-1 h-px bg-border`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(ce,{className:i,"data-slot":`menu-separator`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Nn(e){let t=(0,U.c)(2),n;return t[0]===e?n=t[1]:(n=(0,G.jsx)(ge,{"data-slot":`menu-sub`,...e}),t[0]=e,t[1]=n),n}function Pn(e){let t=(0,U.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,inset:i,children:n,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===r?o=t[6]:(o=V(`flex min-h-8 items-center gap-2 rounded-sm px-2 py-1 text-base text-foreground outline-none data-disabled:pointer-events-none data-highlighted:bg-accent data-popup-open:bg-accent data-inset:ps-8 data-highlighted:text-accent-foreground data-popup-open:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none`,r),t[5]=r,t[6]=o);let s;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,G.jsx)(Te,{className:`-me-0.5 ms-auto opacity-80`}),t[7]=s):s=t[7];let c;return t[8]!==n||t[9]!==i||t[10]!==a||t[11]!==o?(c=(0,G.jsxs)(le,{className:o,"data-inset":i,"data-slot":`menu-sub-trigger`,...a,children:[n,s]}),t[8]=n,t[9]=i,t[10]=a,t[11]=o,t[12]=c):c=t[12],c}function Fn(e){let t=(0,U.c)(12),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,sideOffset:a,alignOffset:n,align:o,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=a===void 0?0:a,c=o===void 0?`start`:o,l=n??(c===`center`?void 0:-5),u;return t[6]!==c||t[7]!==r||t[8]!==i||t[9]!==s||t[10]!==l?(u=(0,G.jsx)(An,{align:c,alignOffset:l,className:r,"data-slot":`menu-sub-content`,side:`inline-end`,sideOffset:s,...i}),t[6]=c,t[7]=r,t[8]=i,t[9]=s,t[10]=l,t[11]=u):u=t[11],u}var In=`dialog-backdrop panel-motion fixed inset-0 z-50 transition-all duration-(--panel-duration) data-ending-style:opacity-0 data-starting-style:opacity-0`,Ln=`dialog-glass panel-motion -translate-y-[calc(1.25rem*var(--nested-dialogs))] relative flex min-h-0 w-full min-w-0 scale-[calc(1-0.1*var(--nested-dialogs))] flex-col rounded-2xl border opacity-[calc(1-0.1*var(--nested-dialogs))] outline-none transition-[scale,opacity,translate] duration-(--panel-duration) ease-in-out will-change-transform data-nested:data-ending-style:translate-y-8 data-nested:data-starting-style:translate-y-8 data-nested-dialog-open:origin-top data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0`,Rn=gn,zn=an;function Bn(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(In,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(ln,{forceRender:!0,className:i,"data-slot":`alert-dialog-backdrop`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Vn(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`fixed inset-0 z-50 grid grid-rows-[1fr_auto_1fr] justify-items-center p-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(rn,{className:i,"data-slot":`alert-dialog-viewport`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Hn(e){let t=(0,U.c)(16),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,bottomStickOnMobile:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0||i,o;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,G.jsx)(Bn,{}),t[4]=o):o=t[4];let s=a&&`max-sm:grid-rows-[1fr_auto] max-sm:p-0 max-sm:pt-12`,c;t[5]===s?c=t[6]:(c=V(s),t[5]=s,t[6]=c);let l=a&&`max-sm:max-w-none max-sm:rounded-none max-sm:border-x-0 max-sm:border-t max-sm:border-b-0 max-sm:opacity-[calc(1-min(var(--nested-dialogs),1))] max-sm:data-ending-style:translate-y-4 max-sm:data-starting-style:translate-y-4`,u;t[7]!==n||t[8]!==l?(u=V(Ln,`row-start-2 max-h-full max-w-lg text-popover-foreground`,l,n),t[7]=n,t[8]=l,t[9]=u):u=t[9];let d;t[10]!==r||t[11]!==u?(d=(0,G.jsx)(sn,{className:u,"data-slot":`alert-dialog-popup`,...r}),t[10]=r,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==c||t[14]!==d?(f=(0,G.jsxs)(zn,{children:[o,(0,G.jsx)(Vn,{className:c,children:d})]}),t[13]=c,t[14]=d,t[15]=f):f=t[15],f}function Un(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`flex flex-col gap-2 p-6 text-center max-sm:pb-4 sm:text-left`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(`div`,{className:i,"data-slot":`alert-dialog-header`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Wn(e){let t=(0,U.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,variant:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`default`:i,o=a==="default"&&`border-t bg-muted/72 py-4`,s=a===`bare`&&`pb-6`,c;t[4]!==n||t[5]!==o||t[6]!==s?(c=V(`flex flex-col-reverse gap-2 px-6 sm:flex-row sm:justify-end sm:rounded-b-[calc(var(--radius-2xl)-1px)]`,o,s,n),t[4]=n,t[5]=o,t[6]=s,t[7]=c):c=t[7];let l;return t[8]!==r||t[9]!==c?(l=(0,G.jsx)(`div`,{className:c,"data-slot":`alert-dialog-footer`,...r}),t[8]=r,t[9]=c,t[10]=l):l=t[10],l}function Gn(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`font-heading font-semibold text-xl leading-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(cn,{className:i,"data-slot":`alert-dialog-title`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Kn(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`text-muted-foreground text-sm`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(tn,{className:i,"data-slot":`alert-dialog-description`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}var qn=(0,H.createContext)(null);function Jn(e){let t=(0,U.c)(3),{host:n,children:r}=e,i=n,a;return t[0]!==r||t[1]!==i?(a=(0,G.jsx)(qn,{value:i,children:r}),t[0]=r,t[1]=i,t[2]=a):a=t[2],a}function Yn(){let e=(0,H.use)(qn);if(!e)throw Error(`Design workspace rendered outside a DesignHostProvider`);return e}var Xn=fe(C(!1)).pipe(F(`design-query:empty`));function Zn(e){let t=l(e);return t instanceof Error&&t.message.trim().length>0?t.message:`The environment request failed.`}function Qn(e){let t=(0,U.c)(10),r=e??Xn,i=n(r),a=b(r),o;t[0]===i?o=t[1]:(o=x(c(i)),t[0]=i,t[1]=o);let s;t[2]!==i._tag||t[3]!==i.cause?(s=i._tag===`Failure`?Zn(i.cause):null,t[2]=i._tag,t[3]=i.cause,t[4]=s):s=t[4];let l=e!==null&&i.waiting,u;return t[5]!==a||t[6]!==o||t[7]!==s||t[8]!==l?(u={data:o,error:s,isPending:l,refresh:a},t[5]=a,t[6]=o,t[7]=s,t[8]=l,t[9]=u):u=t[9],u}function $n(){let e=Yn(),t=(0,H.useContext)(ee);return(0,H.useCallback)(async n=>{let r=e.runtime.atom(n),i=await y(T(_(function*(){return yield*ne(t,r),yield*R(t,r,{suspendOnWaiting:!0})})));if(te(i))throw l(i.cause);return i.value},[e,t])}function er(e){return e.label?e.label:e.origin===`agent`?`Agent run`:e.origin===`restore`?`Restored`:`Edits`}function tr(e){let t=new Date(e);return t.toDateString()===new Date().toDateString()?t.toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`}):t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function nr(e,t){return[new Date(e.savedAt).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}),`${e.changes} ${e.changes===1?`change`:`changes`}`,t?`Current`:null].filter(Boolean).join(` · `)}var rr=e=>e instanceof Error&&`code`in e?String(e.code):null;function ir(e){let t=(0,U.c)(96),{target:n,path:r,revision:i,fileHash:a,disabled:o,compact:s,onCompare:c}=e,l=s!==void 0&&s,{transport:u}=Yn(),d=$n(),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(null),[g,_]=(0,H.useState)(null),[v,y]=(0,H.useState)(null),[b,x]=(0,H.useState)(null),[S,C]=(0,H.useState)(``),[w,T]=(0,H.useState)(!1),[E,D]=(0,H.useState)(0),O;t[0]!==r||t[1]!==d||t[2]!==n||t[3]!==u?(O=()=>{let e=!0;return _(null),d(u.revisions(n,r)).then(t=>{e&&h(t)},()=>{e&&_(`Could not load revisions.`)}),()=>{e=!1}},t[0]=r,t[1]=d,t[2]=n,t[3]=u,t[4]=O):O=t[4];let k;t[5]!==E||t[6]!==a||t[7]!==f||t[8]!==r||t[9]!==d||t[10]!==n||t[11]!==u?(k=[f,E,n,r,a,u,d],t[5]=E,t[6]=a,t[7]=f,t[8]=r,t[9]=d,t[10]=n,t[11]=u,t[12]=k):k=t[12],(0,H.useEffect)(O,k);let A;if(t[13]!==a||t[14]!==i||t[15]!==m){let e=m?.find(e=>e.fileHash===a);A=e?`${er(e)} · ${tr(e.savedAt)}`:i?`Revision ${i.slice(0,8)}`:`Revisions`,t[13]=a,t[14]=i,t[15]=m,t[16]=A}else A=t[16];let j=A,M;t[17]===w?M=t[18]:(M=()=>{w||(x(null),y(null))},t[17]=w,t[18]=M);let N=M,P;t[19]!==b||t[20]!==w||t[21]!==S||t[22]!==r||t[23]!==d||t[24]!==n||t[25]!==u?(P=()=>{if(!b||w)return;T(!0),y(null);let e=b.kind===`restore`?u.restoreRevision(n,r,b.entry.id,b.expectedFileHash):b.kind===`rename`?u.renameRevision(n,r,b.entry.id,S):u.deleteRevision(n,r,b.entry.id);d(e).then(()=>{x(null),D(ar)},e=>{let t=rr(e);y(b.kind===`restore`&&t===`conflict`?`The design changed. Reopen revisions and try again.`:b.kind===`restore`&&t===`invalid-document`?`This revision cannot be restored with the current libraries and assets.`:b.kind===`delete`&&t===`conflict`?`The current revision can't be deleted. Restore another revision first.`:`Could not ${b.kind} this revision. Reopen revisions and try again.`)}).finally(()=>T(!1))},t[19]=b,t[20]=w,t[21]=S,t[22]=r,t[23]=d,t[24]=n,t[25]=u,t[26]=P):P=t[26];let F=P,I;t[27]===b?I=t[28]:(I=b?er(b.entry):``,t[27]=b,t[28]=I);let ee=I,L=l?`icon-sm`:`sm`,te=o||w,ne=`Revision history, current: ${j}`,re=l?void 0:`design-revision-trigger`,R;t[29]!==ne||t[30]!==re||t[31]!==L||t[32]!==te?(R=(0,G.jsx)(kn,{render:(0,G.jsx)(W,{size:L,variant:`ghost`,disabled:te,"aria-label":ne,className:re})}),t[29]=ne,t[30]=re,t[31]=L,t[32]=te,t[33]=R):R=t[33];let ie;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,G.jsx)(Re,{"aria-hidden":`true`}),t[34]=ie):ie=t[34];let ae;t[35]!==l||t[36]!==j?(ae=l?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`design-collapsible-label design-truncate`,children:j}),(0,G.jsx)(Ce,{"aria-hidden":`true`,className:`design-collapsible-label`})]}),t[35]=l,t[36]=j,t[37]=ae):ae=t[37];let oe;t[38]!==R||t[39]!==ae?(oe=(0,G.jsxs)(Ot,{render:R,children:[ie,ae]}),t[38]=R,t[39]=ae,t[40]=oe):oe=t[40];let se;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,G.jsx)(kt,{children:`Revision history`}),t[41]=se):se=t[41];let ce;t[42]===oe?ce=t[43]:(ce=(0,G.jsxs)(jt,{children:[oe,se]}),t[42]=oe,t[43]=ce);let le;t[44]!==E||t[45]!==o||t[46]!==a||t[47]!==g||t[48]!==c||t[49]!==m?(le=g?(0,G.jsxs)(jn,{onClick:()=>D(E+1),children:[g,` Retry`]}):m===null?(0,G.jsx)(jn,{disabled:!0,children:`Loading revisions...`}):m.length===0?(0,G.jsx)(jn,{disabled:!0,children:`No saved revisions yet`}):m.map(e=>{let t=e.fileHash===a;return(0,G.jsxs)(Nn,{children:[(0,G.jsx)(Pn,{children:(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,G.jsx)(`span`,{className:`truncate`,children:er(e)}),(0,G.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:nr(e,t)})]})}),(0,G.jsxs)(Fn,{children:[(0,G.jsx)(jn,{disabled:t||o,onClick:()=>{y(null),x({kind:`restore`,entry:e,expectedFileHash:a})},children:`Restore...`}),c?(0,G.jsx)(jn,{disabled:t,onClick:()=>c(e),children:`Compare with current`}):null,(0,G.jsx)(Mn,{}),(0,G.jsx)(jn,{disabled:o,onClick:()=>{y(null),C(e.label??``),x({kind:`rename`,entry:e})},children:`Rename...`}),(0,G.jsx)(jn,{disabled:t||o,onClick:()=>{y(null),x({kind:`delete`,entry:e})},children:`Delete...`})]})]},e.id)}),t[44]=E,t[45]=o,t[46]=a,t[47]=g,t[48]=c,t[49]=m,t[50]=le):le=t[50];let ue;t[51]===le?ue=t[52]:(ue=(0,G.jsx)(An,{align:`start`,className:`max-h-80 w-72 overflow-y-auto`,children:le}),t[51]=le,t[52]=ue);let de;t[53]!==f||t[54]!==ce||t[55]!==ue?(de=(0,G.jsxs)(On,{open:f,onOpenChange:p,children:[ce,ue]}),t[53]=f,t[54]=ce,t[55]=ue,t[56]=de):de=t[56];let fe=b!==null,pe;t[57]===N?pe=t[58]:(pe=e=>e?void 0:N(),t[57]=N,t[58]=pe);let me;t[59]===F?me=t[60]:(me=e=>{e.preventDefault(),F()},t[59]=F,t[60]=me);let he=b?.kind===`restore`?`Restore "${ee}"?`:b?.kind===`rename`?`Rename revision`:`Delete "${ee}"?`,ge;t[61]===he?ge=t[62]:(ge=(0,G.jsx)(Gn,{children:he}),t[61]=he,t[62]=ge);let _e=b?.kind===`restore`?`Replace this design with that revision. Your current version stays in revision history. Libraries and assets are unchanged.`:b?.kind===`rename`?`Name it so it is easy to find. Leave it empty to show what made it.`:`Its saved versions are removed from history. This cannot be undone.`,ve;t[63]===_e?ve=t[64]:(ve=(0,G.jsx)(Kn,{children:_e}),t[63]=_e,t[64]=ve);let ye;t[65]!==b||t[66]!==S?(ye=b?.kind===`rename`?(0,G.jsx)(Dn,{"aria-label":`Revision name`,value:S,maxLength:80,placeholder:er({...b.entry,label:void 0}),onChange:e=>C(e.currentTarget.value),autoFocus:!0}):null,t[65]=b,t[66]=S,t[67]=ye):ye=t[67];let be;t[68]===v?be=t[69]:(be=v?(0,G.jsx)(`p`,{role:`alert`,className:`design-revision-error`,children:v}):null,t[68]=v,t[69]=be);let z;t[70]!==ge||t[71]!==ve||t[72]!==ye||t[73]!==be?(z=(0,G.jsxs)(Un,{children:[ge,ve,ye,be]}),t[70]=ge,t[71]=ve,t[72]=ye,t[73]=be,t[74]=z):z=t[74];let xe;t[75]!==w||t[76]!==N?(xe=(0,G.jsx)(W,{type:`button`,size:`sm`,variant:`ghost`,disabled:w,onClick:N,children:`Cancel`}),t[75]=w,t[76]=N,t[77]=xe):xe=t[77];let Se=b?.kind===`delete`?`destructive`:`default`,we=w||!b,Te=b?.kind===`restore`?w?`Restoring...`:`Restore revision`:b?.kind===`rename`?w?`Saving...`:`Save name`:w?`Deleting...`:`Delete revision`,Ee;t[78]!==Se||t[79]!==we||t[80]!==Te?(Ee=(0,G.jsx)(W,{type:`submit`,size:`sm`,variant:Se,disabled:we,children:Te}),t[78]=Se,t[79]=we,t[80]=Te,t[81]=Ee):Ee=t[81];let B;t[82]!==xe||t[83]!==Ee?(B=(0,G.jsxs)(Wn,{children:[xe,Ee]}),t[82]=xe,t[83]=Ee,t[84]=B):B=t[84];let De;t[85]!==me||t[86]!==z||t[87]!==B?(De=(0,G.jsx)(Hn,{className:`max-w-md`,children:(0,G.jsxs)(`form`,{onSubmit:me,children:[z,B]})}),t[85]=me,t[86]=z,t[87]=B,t[88]=De):De=t[88];let Oe;t[89]!==fe||t[90]!==pe||t[91]!==De?(Oe=(0,G.jsx)(Rn,{open:fe,onOpenChange:pe,children:De}),t[89]=fe,t[90]=pe,t[91]=De,t[92]=Oe):Oe=t[92];let ke;return t[93]!==de||t[94]!==Oe?(ke=(0,G.jsxs)(G.Fragment,{children:[de,Oe]}),t[93]=de,t[94]=Oe,t[95]=ke):ke=t[95],ke}function ar(e){return e+1}function or(e){let t=new URL(`p4design://open`);if(t.searchParams.set(`project`,e.projectRoot),t.searchParams.set(`file`,e.documentPath),t.searchParams.set(`revision`,e.revision),e.environmentId&&t.searchParams.set(`environment`,e.environmentId),!sr(t.href))throw Error(`Invalid design reference.`);return t.href}function sr(e){if(e.length>16384)return null;try{let t=new URL(e.trim());if(t.protocol!==`p4design:`||t.host!==`open`||t.username||t.password||t.hash||t.pathname)return null;let n=t.searchParams.get(`project`)??``,r=t.searchParams.get(`file`)??``,i=t.searchParams.get(`revision`)??``,a=t.searchParams.get(`environment`);return!/^(\/|[a-z]:[\\/])/i.test(n)||/\p{Cc}/u.test(n)||!r.endsWith(`.p4design`)||/^[\\/]|^[a-z]:/i.test(r)||r.split(/[\\/]/).some(e=>!e||e===`.`||e===`..`)||/\p{Cc}/u.test(r)||!/^[0-9a-f]{64}$/.test(i)||a!==null&&(!a||a.length>200)?null:{projectRoot:n,documentPath:r,revision:i,...a?{environmentId:a}:{}}}catch{return null}}var cr=()=>null;function lr({target:e,path:t,revision:n,compact:r=!1,iconOnly:i=!1}){let{navigation:a}=Yn(),o=(a.useWorkspaceRoot??cr)(e),[s,c]=(0,H.useState)(null);if(!e||!o||!t||!n)return null;let l=or({projectRoot:o,documentPath:t,revision:n,...a.linkEnvironment?{environmentId:e.environmentId}:{}}),u=s?.link===l?s:null,d=()=>{Promise.resolve().then(()=>navigator.clipboard.writeText(l)).then(()=>c({link:l,error:!1}),()=>c({link:l,error:!0}))},f=u!==null&&!u.error;return(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[i?(0,G.jsxs)(jt,{children:[(0,G.jsx)(Ot,{render:(0,G.jsx)(W,{size:`icon-sm`,variant:`ghost`,"aria-label":f?`Link copied`:`Copy design link`,onClick:d}),children:(0,G.jsx)(Ue,{"aria-hidden":`true`})}),(0,G.jsx)(kt,{children:f?`Link copied`:`Copy design link`})]}):(0,G.jsxs)(W,{size:`sm`,variant:r?`ghost`:`outline`,onClick:d,children:[(0,G.jsx)(Ue,{"aria-hidden":`true`}),f?`Link copied`:r?`Copy link`:`Copy design link`]}),u?.error?(0,G.jsx)(`span`,{role:`alert`,className:`text-xs`,children:`Could not copy. Try again.`}):null,u&&!u.error?(0,G.jsx)(`span`,{role:`status`,className:`sr-only`,children:`Paste into a P4 Code thread in this project.`}):null]})}var ur=u(`relative inline-flex shrink-0 items-center justify-center gap-1 whitespace-nowrap rounded-sm border border-transparent font-medium outline-none transition-shadow focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-64 [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-3.5 sm:[&_svg:not([class*='size-'])]:size-3 [&_svg]:pointer-events-none [&_svg]:shrink-0 [button&,a&]:cursor-pointer [button&,a&]:pointer-coarse:after:absolute [button&,a&]:pointer-coarse:after:size-full [button&,a&]:pointer-coarse:after:min-h-11 [button&,a&]:pointer-coarse:after:min-w-11`,{defaultVariants:{size:`default`,variant:`default`},variants:{size:{default:`h-5.5 min-w-5.5 px-[calc(--spacing(1)-1px)] text-sm sm:h-4.5 sm:min-w-4.5 sm:text-xs`,lg:`h-6.5 min-w-6.5 px-[calc(--spacing(1.5)-1px)] text-base sm:h-5.5 sm:min-w-5.5 sm:text-sm`,sm:`h-5 min-w-5 rounded-[.25rem] px-[calc(--spacing(1)-1px)] text-xs sm:h-4 sm:min-w-4 sm:text-[.625rem]`},variant:{default:`bg-primary text-primary-foreground [button&,a&]:hover:bg-primary/90`,destructive:`bg-destructive text-white [button&,a&]:hover:bg-destructive/90`,error:`bg-destructive/8 text-destructive-foreground dark:bg-destructive/16`,info:`bg-info/8 text-info-foreground dark:bg-info/16`,outline:`border-input bg-background text-foreground dark:bg-input/32 [button&,a&]:hover:bg-accent/50 dark:[button&,a&]:hover:bg-input/48`,secondary:`bg-secondary text-secondary-foreground [button&,a&]:hover:bg-secondary/90`,success:`bg-success/8 text-success-foreground dark:bg-success/16`,warning:`bg-warning/8 text-warning-foreground dark:bg-warning/16`}}});function dr(e){let t=(0,U.c)(9),n,r,a,o;if(t[0]!==e){let{className:s,variant:c,size:l,render:u,...d}=e;n=u;let f={className:V(ur({className:s,size:l,variant:c})),"data-slot":`badge`};o=L,r=`span`,a=i(f,d),t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=o}else n=t[1],r=t[2],a=t[3],o=t[4];let s;return t[5]!==n||t[6]!==r||t[7]!==a?(s={defaultTagName:r,props:a,render:n},t[5]=n,t[6]=r,t[7]=a,t[8]=s):s=t[8],o(s)}function fr(e){let t=(0,U.c)(25),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({className:r,children:n,scrollFade:a,scrollbarGutter:o,hideScrollbars:s,chainVerticalScroll:c,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c);let l=a!==void 0&&a,u=o!==void 0&&o,d=s!==void 0&&s,f=c!==void 0&&c,p;t[8]===r?p=t[9]:(p=V(`relative size-full min-h-0 overflow-hidden rounded-[inherit]`,r),t[8]=r,t[9]=p);let m=f&&`overscroll-y-auto`,h=l&&`mask-t-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-y-start)))] mask-b-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-y-end)))] mask-l-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-x-start)))] mask-r-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-x-end)))] [--fade-size:1.5rem]`,g=u&&`scrollbar-gutter-stable`,_=d&&`[-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,v;t[10]!==m||t[11]!==h||t[12]!==g||t[13]!==_?(v=V(`h-full max-h-[inherit] overflow-auto overscroll-contain rounded-[inherit] outline-none transition-shadows focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background data-has-overflow-x:overscroll-x-contain`,m,h,g,_),t[10]=m,t[11]=h,t[12]=g,t[13]=_,t[14]=v):v=t[14];let y;t[15]!==n||t[16]!==v?(y=(0,G.jsx)(Zt,{className:v,"data-slot":`scroll-area-viewport`,children:n}),t[15]=n,t[16]=v,t[17]=y):y=t[17];let b;t[18]===d?b=t[19]:(b=!d&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(pr,{orientation:`vertical`}),(0,G.jsx)(pr,{orientation:`horizontal`}),(0,G.jsx)(en,{"data-slot":`scroll-area-corner`})]}),t[18]=d,t[19]=b);let x;return t[20]!==i||t[21]!==y||t[22]!==b||t[23]!==p?(x=(0,G.jsxs)(Xt,{className:p,...i,children:[y,b]}),t[20]=i,t[21]=y,t[22]=b,t[23]=p,t[24]=x):x=t[24],x}function pr(e){let t=(0,U.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,orientation:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`vertical`:i,o;t[4]===n?o=t[5]:(o=V(`flex opacity-0 transition-opacity delay-300 data-[orientation=horizontal]:mx-1 data-[orientation=horizontal]:mb-px data-[orientation=horizontal]:h-1.5 data-[orientation=vertical]:my-1 data-[orientation=vertical]:mr-px data-[orientation=vertical]:w-1.5 data-[orientation=horizontal]:flex-col data-hovering:opacity-100 data-scrolling:opacity-100 data-hovering:delay-0 data-scrolling:delay-0 data-hovering:duration-100 data-scrolling:duration-100`,n),t[4]=n,t[5]=o);let s;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,G.jsx)(Qt,{className:`relative flex-1 rounded-full bg-[var(--app-scrollbar-thumb)] transition-colors hover:bg-[var(--app-scrollbar-thumb-hover)]`,"data-slot":`scroll-area-thumb`}),t[6]=s):s=t[6];let c;return t[7]!==a||t[8]!==r||t[9]!==o?(c=(0,G.jsx)($t,{className:o,"data-slot":`scroll-area-scrollbar`,orientation:a,...r,children:s}),t[7]=a,t[8]=r,t[9]=o,t[10]=c):c=t[10],c}var mr=H.createContext({chipsRef:null,multiple:!1});function hr(e){let t=(0,U.c)(7),n=H.useRef(null),r=!!e.multiple,i;t[0]===r?i=t[1]:(i={chipsRef:n,multiple:r},t[0]=r,t[1]=i);let a=i,o;t[2]===e?o=t[3]:(o=(0,G.jsx)(Kt,{...e}),t[2]=e,t[3]=o);let s;return t[4]!==o||t[5]!==a?(s=(0,G.jsx)(mr,{value:a,children:o}),t[4]=o,t[5]=a,t[6]=s):s=t[6],s}function gr(e){let t=(0,U.c)(36),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({className:n,inputClassName:r,showTrigger:s,showClear:c,startAddon:o,size:a,unstyled:l,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=s===void 0||s,d=c!==void 0&&c,f=l!==void 0&&l,p=a??`default`,m;t[9]===o?m=t[10]:(m=o&&(0,G.jsx)(`div`,{"aria-hidden":`true`,className:`[&_svg]:-mx-0.5 pointer-events-none absolute inset-y-0 start-px z-10 flex items-center ps-[calc(--spacing(3)-1px)] opacity-80 has-[+[data-size=sm]]:ps-[calc(--spacing(2.5)-1px)] [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4`,"data-slot":`combobox-start-addon`,children:o}),t[9]=o,t[10]=m);let h=o&&`data-[size=sm]:*:data-[slot=combobox-input]:ps-[calc(--spacing(7.5)-1px)] *:data-[slot=combobox-input]:ps-[calc(--spacing(8.5)-1px)] sm:data-[size=sm]:*:data-[slot=combobox-input]:ps-[calc(--spacing(7)-1px)] sm:*:data-[slot=combobox-input]:ps-[calc(--spacing(8)-1px)]`,g=p===`sm`?`has-[+[data-slot=combobox-trigger],+[data-slot=combobox-clear]]:*:data-[slot=combobox-input]:pe-6.5`:`has-[+[data-slot=combobox-trigger],+[data-slot=combobox-clear]]:*:data-[slot=combobox-input]:pe-7`,_;t[11]!==n||t[12]!==h||t[13]!==g?(_=V(h,g,n),t[11]=n,t[12]=h,t[13]=g,t[14]=_):_=t[14];let v;t[15]===r?v=t[16]:(v=V(`has-disabled:opacity-100`,r),t[15]=r,t[16]=v);let y;t[17]!==p||t[18]!==v||t[19]!==f?(y=(0,G.jsx)(Dn,{className:v,nativeInput:!0,size:p,unstyled:f}),t[17]=p,t[18]=v,t[19]=f,t[20]=y):y=t[20];let b;t[21]!==i||t[22]!==_||t[23]!==y?(b=(0,G.jsx)(Vt,{className:_,"data-slot":`combobox-input`,render:y,...i}),t[21]=i,t[22]=_,t[23]=y,t[24]=b):b=t[24];let x;t[25]!==u||t[26]!==p?(x=u&&(0,G.jsx)(_r,{className:V(`-translate-y-1/2 absolute top-1/2 inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md border border-transparent opacity-80 outline-none transition-opacity pointer-coarse:after:absolute pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 hover:opacity-100 has-[+[data-slot=combobox-clear]]:hidden sm:size-7 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0`,p===`sm`?`end-0`:`end-0.5`),children:(0,G.jsx)(Lt,{"data-slot":`combobox-icon`,children:(0,G.jsx)(B,{})})}),t[25]=u,t[26]=p,t[27]=x):x=t[27];let S;t[28]!==d||t[29]!==p?(S=d&&(0,G.jsx)(wr,{className:V(`-translate-y-1/2 absolute top-1/2 inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md border border-transparent opacity-80 outline-none transition-opacity pointer-coarse:after:absolute pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 hover:opacity-100 has-[+[data-slot=combobox-clear]]:hidden sm:size-7 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0`,p===`sm`?`end-0`:`end-0.5`),children:(0,G.jsx)(lt,{})}),t[28]=d,t[29]=p,t[30]=S):S=t[30];let C;return t[31]!==b||t[32]!==x||t[33]!==S||t[34]!==m?(C=(0,G.jsxs)(`div`,{className:`relative not-has-[>*.w-full]:w-fit w-full text-foreground has-disabled:opacity-64`,children:[m,b,x,S]}),t[31]=b,t[32]=x,t[33]=S,t[34]=m,t[35]=C):C=t[35],C}function _r(e){let t=(0,U.c)(8),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;return t[4]!==n||t[5]!==r||t[6]!==i?(a=(0,G.jsx)(It,{className:r,"data-slot":`combobox-trigger`,...i,children:n}),t[4]=n,t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function vr(e){let t=(0,U.c)(22),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({className:a,children:i,side:s,sideOffset:c,alignOffset:n,align:l,anchor:r,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=s===void 0?`bottom`:s,d=c===void 0?4:c,f=l===void 0?`start`:l,{chipsRef:p}=H.use(mr),m=r??p,h;t[9]===a?h=t[10]:(h=V(`dropdown-glass relative flex max-h-[min(var(--available-height),23rem)] min-w-(--anchor-width) max-w-(--available-width) flex-1 flex-col origin-(--transform-origin) rounded-lg text-foreground transition-[scale,opacity] duration-[140ms] ease-[cubic-bezier(0.23,1,0.32,1)] data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0 data-instant:duration-0`,a),t[9]=a,t[10]=h);let g;t[11]!==i||t[12]!==o||t[13]!==h?(g=(0,G.jsx)(Ft,{className:h,"data-slot":`combobox-popup`,...o,children:i}),t[11]=i,t[12]=o,t[13]=h,t[14]=g):g=t[14];let _;return t[15]!==f||t[16]!==n||t[17]!==m||t[18]!==u||t[19]!==d||t[20]!==g?(_=(0,G.jsx)(Ut,{children:(0,G.jsx)(Bt,{align:f,alignOffset:n,anchor:m,className:`z-50 select-none`,"data-slot":`combobox-positioner`,side:u,sideOffset:d,children:g})}),t[15]=f,t[16]=n,t[17]=m,t[18]=u,t[19]=d,t[20]=g,t[21]=_):_=t[21],_}function yr(e){let t=(0,U.c)(17),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,contentClassName:i,children:n,hideIndicator:o,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===r?s=t[7]:(s=V(`flex min-h-8 in-data-[side=none]:min-w-[calc(var(--anchor-width)+1.25rem)] cursor-default items-center rounded-sm px-2 py-1 text-base outline-none hover:bg-accent data-disabled:pointer-events-none data-selected:bg-foreground/[0.08] data-selected:text-foreground data-highlighted:bg-accent data-highlighted:text-accent-foreground [&[data-highlighted][data-selected]]:bg-accent [&[data-highlighted][data-selected]]:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0`,r),t[6]=r,t[7]=s);let c;t[8]===i?c=t[9]:(c=V(`min-w-0 flex-1 [&_svg:not([class*='text-'])]:text-muted-foreground`,i),t[8]=i,t[9]=c);let l;t[10]!==n||t[11]!==c?(l=(0,G.jsx)(`div`,{className:c,"data-slot":`combobox-item-content`,children:n}),t[10]=n,t[11]=c,t[12]=l):l=t[12];let u;return t[13]!==a||t[14]!==s||t[15]!==l?(u=(0,G.jsx)(Ht,{className:s,"data-slot":`combobox-item`,...a,children:l}),t[13]=a,t[14]=s,t[15]=l,t[16]=u):u=t[16],u}function br(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`[[role=group]+&]:mt-1.5`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(qt,{className:i,"data-slot":`combobox-group`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function xr(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`px-2 py-1.5 font-medium text-muted-foreground text-xs`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(Jt,{className:i,"data-slot":`combobox-group-label`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Sr(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`not-empty:p-2 text-center text-base text-muted-foreground sm:text-sm`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(zt,{className:i,"data-slot":`combobox-empty`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Cr(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`not-empty:scroll-py-1 not-empty:px-1 not-empty:py-1`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(fr,{scrollbarGutter:!0,scrollFade:!0,children:(0,G.jsx)(Rt,{className:i,"data-slot":`combobox-list`,...r})}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function wr(e){let t=(0,U.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=(0,G.jsx)(Wt,{className:n,"data-slot":`combobox-clear`,...r}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i}function Tr(e){let t=(0,U.c)(2),n;return t[0]===e?n=t[1]:(n=(0,G.jsx)(Gt,{"data-slot":`combobox-collection`,...e}),t[0]=e,t[1]=n),n}var Er={thread:`This thread`,project:`Project`,other:`Other designs`};function Dr(e){let t=(0,U.c)(10),{target:n,item:r}=e,{transport:i}=Yn(),a;t[0]!==r.missing||t[1]!==r.modifiedAt||t[2]!==r.path||t[3]!==n||t[4]!==i?(a=n&&!r.missing?i.thumbnail(n,r.path,r.modifiedAt??``):null,t[0]=r.missing,t[1]=r.modifiedAt,t[2]=r.path,t[3]=n,t[4]=i,t[5]=a):a=t[5];let o=Qn(a),s=r.missing||o.error?null:o.data?.dataUrl,c;return t[6]!==r.missing||t[7]!==r.pageCount||t[8]!==s?(c=(0,G.jsx)(_n,{pageCount:r.pageCount,muted:r.missing,thumbnail:s}),t[6]=r.missing,t[7]=r.pageCount,t[8]=s,t[9]=c):c=t[9],c}function Or(e){let t=(0,U.c)(66),{target:n,path:r,paths:i,entries:a,linkedPaths:o,onOpen:s,statuses:c,onStartDesign:l,onStartDesignInNewThread:u,onManageDesigns:d,open:f,onOpenChange:p}=e,m=(0,H.useRef)(null),[h,g]=(0,H.useState)(``),[_,v]=(0,H.useState)(Mr),y;t[0]===r?y=t[1]:(y=r?vn(r):`Choose design`,t[0]=r,t[1]=y);let b=y,x;t[2]!==a||t[3]!==o||t[4]!==i?(x=xn({paths:i,entries:a,linkedPaths:o}),t[2]=a,t[3]=o,t[4]=i,t[5]=x):x=t[5];let S=x,C;t[6]===h?C=t[7]:(C=h.trim(),t[6]=h,t[7]=C);let w=C.length>0,T;if(t[8]!==_||t[9]!==S||t[10]!==h||t[11]!==w){let e=S.filter(e=>wn(e,h));T=[`thread`,`project`,`other`].map(t=>{let n=e.filter(e=>e.group===t);return{value:t,count:n.length,items:!w&&_.has(t)?[]:n}}).filter(jr),t[8]=_,t[9]=S,t[10]=h,t[11]=w,t[12]=T}else T=t[12];let E=T,D;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>v(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),t[13]=D):D=t[13];let O=D,k;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(k=Date.now(),t[14]=k):k=t[14];let A=k,j;t[15]===p?j=t[16]:(j=()=>{p(!1),g(``)},t[15]=p,t[16]=j);let M=j;if(!S.length&&!l){let e=r||b,n;return t[17]!==e||t[18]!==b?(n=(0,G.jsx)(`h1`,{className:`design-title`,children:(0,G.jsx)(Mt,{full:e,children:b})}),t[17]=e,t[18]=b,t[19]=n):n=t[19],n}let N;t[20]!==M||t[21]!==s||t[22]!==r?(N=e=>{e&&(M(),e.path!==r&&s(e.path))},t[20]=M,t[21]=s,t[22]=r,t[23]=N):N=t[23];let P;t[24]!==M||t[25]!==p?(P=e=>e?p(!0):M(),t[24]=M,t[25]=p,t[26]=P):P=t[26];let F=r||b,I,ee;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,G.jsx)(_r,{render:(0,G.jsx)(W,{variant:`ghost`,size:`sm`}),className:`design-document-switcher`}),ee=(0,G.jsx)(`span`,{className:`sr-only`,children:`Design document: `}),t[27]=I,t[28]=ee):(I=t[27],ee=t[28]);let L;t[29]===b?L=t[30]:(L=(0,G.jsx)(`span`,{ref:m,className:`design-truncate`,children:b}),t[29]=b,t[30]=L);let te;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,G.jsx)(Ce,{"aria-hidden":`true`,size:14}),t[31]=te):te=t[31];let ne;t[32]!==F||t[33]!==L?(ne=(0,G.jsxs)(At,{full:F,labelRef:m,render:I,children:[ee,L,te]}),t[32]=F,t[33]=L,t[34]=ne):ne=t[34];let re;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,G.jsxs)(`div`,{className:`design-picker-search`,children:[(0,G.jsx)(gr,{"aria-label":`Search designs`,placeholder:`Search designs`,showTrigger:!1,size:`sm`,startAddon:(0,G.jsx)(tt,{})}),(0,G.jsx)(`kbd`,{className:`design-picker-kbd`,"aria-hidden":`true`,children:`esc`})]}),t[35]=re):re=t[35];let R;t[36]!==S.length||t[37]!==h||t[38]!==w?(R=w?(0,G.jsxs)(`div`,{className:`design-picker-empty`,children:[(0,G.jsxs)(`strong`,{children:[`No designs match "`,h.trim(),`"`]}),(0,G.jsx)(W,{size:`sm`,variant:`outline`,onClick:()=>g(``),children:`Clear search`})]}):S.length?null:(0,G.jsx)(`div`,{className:`design-picker-empty`,children:`No designs in this project yet.`}),t[36]=S.length,t[37]=h,t[38]=w,t[39]=R):R=t[39];let ie;t[40]===R?ie=t[41]:(ie=(0,G.jsx)(Sr,{children:R}),t[40]=R,t[41]=ie);let ae;t[42]!==_||t[43]!==r||t[44]!==h||t[45]!==w||t[46]!==c||t[47]!==n?(ae=(0,G.jsx)(Cr,{className:`design-picker-list`,children:e=>(0,G.jsxs)(br,{items:e.items,children:[(0,G.jsx)(xr,{className:`design-picker-group`,children:(0,G.jsxs)(`button`,{type:`button`,className:`design-picker-group-toggle`,"aria-expanded":w||!_.has(e.value),disabled:w,onMouseDown:kr,onClick:()=>O(e.value),children:[w||!_.has(e.value)?(0,G.jsx)(Ce,{"aria-hidden":`true`,size:14}):(0,G.jsx)(Te,{"aria-hidden":`true`,size:14}),(0,G.jsx)(`span`,{className:`flex-1`,children:Er[e.value]}),(0,G.jsx)(`span`,{children:e.count})]})}),(0,G.jsx)(Tr,{children:e=>{let t=c?.get(e.path),i=yn(e.name,h);return(0,G.jsx)(yr,{value:e,children:(0,G.jsxs)(`span`,{className:`design-picker-item`,children:[(0,G.jsx)(Dr,{target:n,item:e}),(0,G.jsxs)(`span`,{className:`design-picker-text`,children:[(0,G.jsxs)(`span`,{className:`design-picker-name`,children:[i.before,i.match?(0,G.jsx)(`mark`,{children:i.match}):null,i.after]}),(0,G.jsx)(`span`,{className:`design-picker-meta`,children:Sn(e,A)})]}),e.missing?(0,G.jsx)(dr,{variant:`warning`,size:`sm`,children:`Missing`}):e.path===r?(0,G.jsx)(dr,{variant:`info`,size:`sm`,children:`Open`}):t?(0,G.jsx)(dr,{variant:t.tone,size:`sm`,children:t.label}):null]})},e.path)}})]},e.value)}),t[42]=_,t[43]=r,t[44]=h,t[45]=w,t[46]=c,t[47]=n,t[48]=ae):ae=t[48];let oe;t[49]!==M||t[50]!==d||t[51]!==l||t[52]!==u?(oe=l||u||d?(0,G.jsxs)(`div`,{className:`design-picker-footer`,children:[l?(0,G.jsxs)(W,{size:`sm`,variant:`ghost`,onClick:()=>{M(),l()},children:[(0,G.jsx)(Ze,{"aria-hidden":`true`}),`New design in this thread`]}):null,u?(0,G.jsxs)(W,{size:`sm`,variant:`ghost`,onClick:()=>{M(),u()},children:[(0,G.jsx)(Ke,{"aria-hidden":`true`}),`New design in a new thread`]}):null,d?(0,G.jsxs)(W,{size:`sm`,variant:`ghost`,onClick:()=>{M(),d()},children:[(0,G.jsx)(Ve,{"aria-hidden":`true`}),`Manage designs`]}):null]}):null,t[49]=M,t[50]=d,t[51]=l,t[52]=u,t[53]=oe):oe=t[53];let se;t[54]!==ie||t[55]!==ae||t[56]!==oe?(se=(0,G.jsxs)(vr,{className:`design-picker max-h-[min(var(--available-height),34rem)]`,align:`start`,children:[re,ie,ae,oe]}),t[54]=ie,t[55]=ae,t[56]=oe,t[57]=se):se=t[57];let ce;return t[58]!==E||t[59]!==f||t[60]!==h||t[61]!==ne||t[62]!==se||t[63]!==N||t[64]!==P?(ce=(0,G.jsxs)(hr,{items:E,filteredItems:E,inputValue:h,onInputValueChange:g,value:null,onValueChange:N,itemToStringLabel:Ar,open:f,onOpenChange:P,autoHighlight:!0,children:[ne,se]}),t[58]=E,t[59]=f,t[60]=h,t[61]=ne,t[62]=se,t[63]=N,t[64]=P,t[65]=ce):ce=t[65],ce}function kr(e){return e.preventDefault()}function Ar(e){return e.name}function jr(e){return e.count>0}function Mr(){return new Set([`other`])}var Nr=dt,Pr=A(de),Fr=A(D),Ir=(e,t,n,r=`error`)=>({code:e,message:t,severity:r,...n?{nodeId:n}:{}});function Lr(e){let t=e=>{if(e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e))return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(t).join(`,`)}]`;if(typeof e==`object`&&e&&Object.getPrototypeOf(e)===Object.prototype){let n=e;return`{${Object.keys(n).sort().map(e=>`${JSON.stringify(e)}:${t(n[e])}`).join(`,`)}}`}throw Error(`Design JSON must contain only finite JSON values`)};return`${t(e)}\n`}function Rr(e){return ut(Nr(typeof e==`string`?new TextEncoder().encode(e):e))}function zr(e){try{let t=JSON.parse(e);if(typeof t!=`object`||!t||!(`version`in t)||typeof t.version!=`string`||!/^\d+\.\d+$/.test(t.version))throw Error(`Missing or invalid format version`);return t.version.split(`.`)[0]===`1`?{status:`editable`,document:Pr(t,{onExcessProperty:`error`}),fileHash:Rr(e),diagnostics:[]}:{status:`read-only`,raw:t,source:e,fileHash:Rr(e),diagnostics:[Ir(`unknown-major`,`Unsupported design version ${t.version}`)]}}catch{return{status:`invalid`,source:e,diagnostics:[Ir(`invalid-schema`,`Invalid .p4design JSON or schema`)]}}}function Br(e,t){return Fr({...e,...t},{onExcessProperty:`error`})}function Vr(e){let t=new Map,n=new Map,r=[],i=(i,a,o)=>{e.nodes[i]||r.push(Ir(`missing-node`,`Referenced node is missing`,a??i)),t.has(i)?r.push(Ir(`multiple-parents`,`Node occurs in more than one ordered child list`,i)):(t.set(i,a),n.set(i,o))};e.roots.forEach((e,t)=>i(e,null,t));for(let[t,n]of Object.entries(e.nodes))`children`in n&&n.children.forEach((e,n)=>i(e,t,n));for(let[t,n]of Object.entries(e.instances))for(let e of Object.values(n.slots))e.forEach((e,n)=>i(e,t,n));let a=new Set,o=new Set,s=(t,n)=>{if(a.has(t)){r.push(Ir(`tree-cycle`,`Child lists contain a cycle`,t));return}if(n>256){r.push(Ir(`depth-limit`,`Scene exceeds 256 levels`,t));return}if(o.has(t))return;a.add(t);let i=e.nodes[t];if(i&&`children`in i)for(let e of i.children)s(e,n+1);a.delete(t),o.add(t)};for(let t of Object.keys(e.nodes))s(t,0);return{parents:t,order:n,diagnostics:r}}function Hr(e,t,n={},r=new Set){if(r.has(t))throw Error(`token-cycle`);if(r.size>=256)throw Error(`token-depth-limit`);let i=e.tokens[t];if(!i)throw Error(`missing-token`);let a=new Set(r).add(t),o=i.variants.filter(e=>Object.entries(e.theme).every(([e,t])=>n[e]===t));if(o.sort((e,t)=>Object.keys(t.theme).length-Object.keys(e.theme).length),o[0]&&o.some(e=>Object.keys(e.theme).length===Object.keys(o[0].theme).length&&Lr(e.value)!==Lr(o[0].value)))throw Error(`ambiguous-token`);let s=o[0]?.value??i.value,c=typeof s==`object`?Hr(e,s.tokenId,n,a):s;if((i.kind===`number`?typeof c!=`number`:typeof c!=`string`)||i.kind===`color`&&(typeof c!=`string`||!/^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/.test(c)))throw Error(`token-type`);return c}function Ur(e,t,n={}){return typeof t==`object`?Hr(e,t.tokenId,n):t}function Wr(e,t={}){let n=[],r=(e,i,a,o,s,c,l)=>{let u=e.nodes[i];if(!u){n.push(Ir(`missing-node`,`Expansion target is missing`,o));return}if(l>256||s.has(`${e.documentId}/node/${i}`)){n.push(Ir(`component-cycle`,`Expansion contains a cycle or exceeds 256 levels`,o));return}let d=u;try{c[i]&&(d=Br(d,c[i]))}catch{n.push(Ir(`invalid-override`,`Override does not match its source node`,o))}let f=new Set(s).add(`${e.documentId}/node/${i}`);if(d.type===`ref`){let s=d.importId?e.imports[d.importId]:void 0,u=s?t.manifest?.libraries[s.libraryId]:void 0,p=d.importId?u?.exports.includes(d.componentId)&&s?t.documents?.[s.libraryId]:void 0:e,m=p?.components[d.componentId];if(!p||!m)return n.push(Ir(`missing-import`,`Component or exported library symbol is unavailable`,o)),{key:a,sourceId:i,ownerId:o,document:e,node:d,children:[]};let h=e.instances[i],g={...c,...h?.overrides},_=p===e?p:{...p,tokens:{...p.tokens,...e.tokens},themeAxes:{...p.themeAxes,...e.themeAxes}},v=r(_,m.rootId,`${a}/${m.rootId}`,o,f,g,l+1);if(!v)return;let y=t=>{let n=Object.entries(m.slots).find(([,e])=>e.nodeId===t.sourceId),i=n?h?.slots[n[0]]:void 0;return i?{...t,children:i.flatMap(n=>{let i=r(e,n,`${t.key}/slot/${n}`,o,f,{},l+1);return i?[i]:[]})}:{...t,children:t.children.map(y)}},{type:b,componentId:x,importId:S,...C}=d;return{...y(v),key:a,ownerId:o,node:{...v.node,...C}}}let p=`children`in d?d.children.flatMap(t=>{let n=r(e,t,`${a}/${t}`,o===i?t:o,f,c,l+1);return n?[n]:[]}):[];return{key:a,sourceId:i,ownerId:o,document:e,node:d,children:p}};return{roots:e.roots.flatMap(t=>{let n=r(e,t,t,t,new Set,{},0);return n?[n]:[]}),diagnostics:n}}function Gr(e,t){let n=new Set(t),r=new Set(e.filter(e=>n.has(e.ownerId)).map(e=>e.key));return e.filter(e=>{let t=e.key;for(;t;){if(r.has(t))return!0;let e=t.lastIndexOf(`/`);if(e<0)break;t=t.slice(0,e)}return!1})}function Kr(e,t={},n={}){let r=Wr(e,n),i=[...r.diagnostics],a=[],o=(e,n)=>{try{let r=Ur(e.document,n,t);if(typeof r!=`number`||!Number.isFinite(r))throw Error(`token-type`);return r}catch{return i.push(Ir(`invalid-layout-token`,`Layout value requires a finite number`,e.ownerId)),0}},s=new Map,c=e=>{let t=s.get(e.key);if(t)return t;let n=e.node,r=e.children.map(c),a=`layout`in n?n.layout:void 0,l=a?Object.fromEntries(Object.entries(a.padding).map(([t,n])=>[t,o(e,n)])):{top:0,right:0,bottom:0,left:0},u=a?o(e,a.gap):0,d=a?.direction??`none`,f=d===`horizontal`?r.reduce((e,t)=>e+t.width,0)+Math.max(0,r.length-1)*u:Math.max(0,...r.map(e=>e.width)),p=d===`vertical`?r.reduce((e,t)=>e+t.height,0)+Math.max(0,r.length-1)*u:Math.max(0,...r.map(e=>e.height));if(d===`none`&&(f=Math.max(0,...e.children.map((e,t)=>o(e,e.node.x)+r[t].width)),p=Math.max(0,...e.children.map((e,t)=>o(e,e.node.y)+r[t].height))),n.type===`text`){let t=o(e,n.fontSize),r=n.lineHeight?o(e,n.lineHeight):1.2,i=n.text.split(`
2
2
  `);f=Math.max(0,...i.map(e=>e.length))*t*.6,p=i.length*t*r}f+=l.left+l.right,p+=l.top+l.bottom;let m={width:n.width.mode===`fixed`?o(e,n.width.value):n.width.mode===`hug`?f:0,height:n.height.mode===`fixed`?o(e,n.height.value):n.height.mode===`hug`?p:0};for(let t of[`width`,`height`])m[t]<0&&(i.push(Ir(`negative-size`,`Dimensions cannot be negative`,e.ownerId)),m[t]=0),n[t].mode===`hug`&&e.children.some(e=>e.node[t].mode===`fill`)&&i.push(Ir(`layout-cycle`,`A hug dimension cannot contain fill on the same axis`,e.ownerId));return s.set(e.key,m),m},l=(e,t,n,r,i,s,u=!0)=>{let d={x:t,y:n,width:r,height:i},f=u&&e.node.visible!==!1;a.push({...e,node:{...e.node,visible:f},bounds:d,clips:s});let p=`layout`in e.node?e.node.layout:void 0,m=p?Object.fromEntries(Object.entries(p.padding).map(([t,n])=>[t,o(e,n)])):{top:0,right:0,bottom:0,left:0},h=p?o(e,p.gap):0,g=p?.direction??`none`,_={width:Math.max(0,r-m.left-m.right),height:Math.max(0,i-m.top-m.bottom)},v=g===`horizontal`?`width`:`height`,y=e.children.filter(e=>e.node[v].mode===`fill`).length,b=e.children.reduce((e,t)=>e+(t.node[v].mode===`fill`?0:c(t)[v]),0)+Math.max(0,e.children.length-1)*h,x=y?Math.max(0,_[v]-b)/y:0,S=0,C=e.node.type===`frame`&&e.node.clip?[...s,d]:s;for(let r of e.children){let e=c(r),i={width:r.node.width.mode===`fill`?g===`horizontal`?x:_.width:e.width,height:r.node.height.mode===`fill`?g===`vertical`?x:_.height:e.height},a=t+m.left+(g===`horizontal`?S:g===`none`?o(r,r.node.x):0),s=n+m.top+(g===`vertical`?S:g===`none`?o(r,r.node.y):0);l(r,a,s,i.width,i.height,C,f),S+=i[v]+h}};for(let e of r.roots){let t=c(e);(e.node.width.mode===`fill`||e.node.height.mode===`fill`)&&i.push(Ir(`root-fill`,`Root dimensions need fixed or hug sizing`,e.ownerId)),l(e,o(e,e.node.x),o(e,e.node.y),t.width,t.height,[])}return{items:a,diagnostics:i}}function qr(e,t){let n=[],r=(e,t,i)=>{if(e===void 0){n.push({path:i,kind:`added`,after:t});return}if(t===void 0){n.push({path:i,kind:`removed`,before:e});return}if(Lr(e)!==Lr(t)){if(e&&t&&typeof e==`object`&&typeof t==`object`&&!Array.isArray(e)&&!Array.isArray(t)){let n=e,a=t;for(let e of[...new Set([...Object.keys(n),...Object.keys(a)])].sort())r(n[e],a[e],`${i}/${e.replaceAll(`~`,`~0`).replaceAll(`/`,`~1`)}`)}else n.push({path:i,kind:`changed`,before:e,after:t})}},{thumbnail:i,...a}=e,{thumbnail:o,...s}=t;return r(a,s,``),n}var Jr=u(`relative rounded-xl border px-3.5 py-3 text-card-foreground text-sm`,{defaultVariants:{variant:`default`},variants:{variant:{default:`bg-transparent dark:bg-input/32 [&_svg]:text-muted-foreground`,error:`border-destructive/32 bg-destructive/4 text-destructive-foreground [&_[data-slot=alert-description]]:text-destructive-foreground/80 [&_svg]:text-destructive`,info:`border-info/32 bg-info/4 [&_svg]:text-info`,success:`border-success/32 bg-success/4 [&_svg]:text-success`,warning:`border-warning/32 bg-warning/4 [&_svg]:text-warning`}}});function Yr(e){let t=e.props[`data-slot`];if(t)return t;let n=e.type;switch(n.displayName??n.name){case`AlertAction`:return`alert-action`;case`AlertTitle`:return`alert-title`;case`AlertDescription`:return`alert-description`;default:return}}function Xr(e){let t=(0,U.c)(26),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,variant:a,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o,s,c;t[5]===n?(o=t[6],s=t[7],c=t[8]):(c=[],s=[],o=[],H.Children.forEach(n,e=>{if(!(0,H.isValidElement)(e)){s.push(e);return}let t=Yr(e);t===`alert-action`?o.push(e):t===`alert-title`||t===`alert-description`?s.push(e):c.push(e)}),t[5]=n,t[6]=o,t[7]=s,t[8]=c);let l;t[9]!==r||t[10]!==a?(l=V(Jr({variant:a}),r),t[9]=r,t[10]=a,t[11]=l):l=t[11];let u;t[12]===c?u=t[13]:(u=c.length>0&&(0,G.jsx)(`div`,{className:`flex size-4 shrink-0 items-center justify-center [&>svg]:size-full`,children:c}),t[12]=c,t[13]=u);let d;t[14]===s?d=t[15]:(d=s.length>0&&(0,G.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:s}),t[14]=s,t[15]=d);let f;t[16]===o?f=t[17]:(f=o.length>0&&(0,G.jsx)(`div`,{className:`flex shrink-0 items-center self-center`,"data-slot":`alert-actions`,children:o}),t[16]=o,t[17]=f);let p;t[18]!==u||t[19]!==d||t[20]!==f?(p=(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,"data-slot":`alert-row`,children:[u,d,f]}),t[18]=u,t[19]=d,t[20]=f,t[21]=p):p=t[21];let m;return t[22]!==i||t[23]!==l||t[24]!==p?(m=(0,G.jsx)(`div`,{className:l,"data-slot":`alert`,role:`alert`,...i,children:p}),t[22]=i,t[23]=l,t[24]=p,t[25]=m):m=t[25],m}function Zr(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`font-medium`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(`div`,{className:i,"data-slot":`alert-title`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Qr(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`flex gap-1`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(`div`,{className:i,"data-slot":`alert-action`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}Zr.displayName=`AlertTitle`,Qr.displayName=`AlertAction`;var $r=dn;function ei(e){let t=(0,U.c)(8),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;return t[4]!==n||t[5]!==r||t[6]!==i?(a=(0,G.jsx)(hn,{className:r,"data-slot":`popover-trigger`,...i,children:n}),t[4]=n,t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function ti(e){let t=(0,U.c)(33),n,r,i,a,o,s,c,l,u,d,f;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9],d=t[10],f=t[11]):({children:r,className:i,viewportClassName:f,side:s,align:c,sideOffset:l,alignOffset:u,tooltipStyle:d,anchor:n,collisionAvoidance:a,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f);let p=s===void 0?`bottom`:s,m=c===void 0?`center`:c,h=l===void 0?4:l,g=u===void 0?0:u,_=d!==void 0&&d,v=_&&`w-fit text-balance rounded-md text-xs shadow-md/5 before:rounded-[calc(var(--radius-md)-1px)]`,y;t[12]!==i||t[13]!==v?(y=V(`dropdown-glass relative flex h-(--popup-height,auto) w-(--popup-width,auto) origin-(--transform-origin) rounded-lg text-popover-foreground outline-none transition-[width,height,scale,opacity] before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] has-data-[slot=calendar]:rounded-xl has-data-[slot=calendar]:before:rounded-[calc(var(--radius-xl)-1px)] data-starting-style:scale-98 data-starting-style:opacity-0 dark:before:shadow-[0_-1px_--theme(--color-white/6%)]`,v,i),t[12]=i,t[13]=v,t[14]=y):y=t[14];let b=_?`py-1 [--viewport-inline-padding:--spacing(2)]`:`not-data-transitioning:overflow-y-auto`,x;t[15]!==b||t[16]!==f?(x=V(`relative size-full max-h-(--available-height) overflow-clip px-(--viewport-inline-padding) py-4 [--viewport-inline-padding:--spacing(4)] has-data-[slot=calendar]:p-2 data-instant:transition-none **:data-current:data-ending-style:opacity-0 **:data-current:data-starting-style:opacity-0 **:data-previous:data-ending-style:opacity-0 **:data-previous:data-starting-style:opacity-0 **:data-current:w-[calc(var(--popup-width)-2*var(--viewport-inline-padding)-2px)] **:data-previous:w-[calc(var(--popup-width)-2*var(--viewport-inline-padding)-2px)] **:data-current:opacity-100 **:data-previous:opacity-100 **:data-current:transition-opacity **:data-previous:transition-opacity`,b,f),t[15]=b,t[16]=f,t[17]=x):x=t[17];let S;t[18]!==r||t[19]!==x?(S=(0,G.jsx)(fn,{className:x,"data-slot":`popover-viewport`,children:r}),t[18]=r,t[19]=x,t[20]=S):S=t[20];let C;t[21]!==o||t[22]!==S||t[23]!==y?(C=(0,G.jsx)(mn,{className:y,"data-slot":`popover-popup`,...o,children:S}),t[21]=o,t[22]=S,t[23]=y,t[24]=C):C=t[24];let w;return t[25]!==m||t[26]!==g||t[27]!==n||t[28]!==a||t[29]!==p||t[30]!==h||t[31]!==C?(w=(0,G.jsx)(pn,{children:(0,G.jsx)(un,{align:m,alignOffset:g,anchor:n,collisionAvoidance:a,className:`z-[60] h-(--positioner-height) w-(--positioner-width) max-w-(--available-width) transition-transform data-instant:transition-none`,"data-slot":`popover-positioner`,side:p,sideOffset:h,children:C})}),t[25]=m,t[26]=g,t[27]=n,t[28]=a,t[29]=p,t[30]=h,t[31]=C,t[32]=w):w=t[32],w}var ni=wt,ri=u(`relative inline-flex cursor-pointer select-none items-center justify-between gap-2 border rounded-lg text-left text-base outline-none transition-[color,box-shadow,background-color] data-disabled:pointer-events-none data-disabled:opacity-64 sm:text-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4`,{defaultVariants:{size:`default`,variant:`default`},variants:{variant:{default:`w-full min-w-36 border-input bg-background not-dark:bg-clip-padding text-foreground shadow-xs/5 ring-ring/24 before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] not-data-disabled:not-focus-visible:not-aria-invalid:not-data-pressed:before:shadow-[0_1px_--theme(--color-black/4%)] pointer-coarse:after:absolute pointer-coarse:after:size-full pointer-coarse:after:min-h-11 focus-visible:border-ring focus-visible:ring-[3px] aria-invalid:border-destructive/36 focus-visible:aria-invalid:border-destructive/64 focus-visible:aria-invalid:ring-destructive/16 dark:bg-input/32 dark:aria-invalid:ring-destructive/24 dark:not-data-disabled:not-focus-visible:not-aria-invalid:not-data-pressed:before:shadow-[0_-1px_--theme(--color-white/6%)] [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='text-'])]:text-muted-foreground [[data-disabled],:focus-visible,[aria-invalid],[data-pressed]]:shadow-none`,ghost:`border-transparent text-muted-foreground/70 focus-visible:ring-2 focus-visible:ring-ring data-pressed:bg-accent [:hover,[data-pressed]]:bg-accent [:hover,[data-pressed]]:text-foreground/80`},size:{default:`min-h-9 px-[calc(--spacing(3)-1px)] sm:min-h-8`,lg:`min-h-10 px-[calc(--spacing(3)-1px)] sm:min-h-9`,sm:`min-h-8 gap-1.5 px-[calc(--spacing(2.5)-1px)] sm:min-h-7`,xs:`h-7 gap-1 rounded-md px-[calc(--spacing(2)-1px)] text-sm before:rounded-[calc(var(--radius-md)-1px)] sm:h-6 sm:text-xs [&_svg:not([class*='size-'])]:size-4 sm:[&_svg:not([class*='size-'])]:size-3.5`}}});function ii(e){let t=(0,U.c)(20),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({className:r,size:o,variant:s,children:n,icon:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=o===void 0?`default`:o,l=s===void 0?`default`:s,u;t[7]!==r||t[8]!==c||t[9]!==l?(u=V(ri({size:c,variant:l}),r),t[7]=r,t[8]=c,t[9]=l,t[10]=u):u=t[10];let d;t[11]===i?d=t[12]:(d=i??(0,G.jsx)(Ce,{className:`-me-1 size-3 opacity-50`}),t[11]=i,t[12]=d);let f;t[13]===d?f=t[14]:(f=(0,G.jsx)(he,{"data-slot":`select-icon`,children:d}),t[13]=d,t[14]=f);let p;return t[15]!==n||t[16]!==a||t[17]!==u||t[18]!==f?(p=(0,G.jsxs)(M,{className:u,"data-slot":`select-trigger`,...a,children:[n,f]}),t[15]=n,t[16]=a,t[17]=u,t[18]=f,t[19]=p):p=t[19],p}function ai(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`flex-1 truncate data-placeholder:text-muted-foreground`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(vt,{className:i,"data-slot":`select-value`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function oi(e){let t=(0,U.c)(36),n,r,i,a,o,s,c,l,u,d,f;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9],d=t[10],f=t[11]):({className:i,popupClassName:a,children:r,side:s,sideOffset:c,align:l,alignOffset:u,alignItemWithTrigger:d,matchTriggerWidth:f,anchor:n,...o}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f);let p=s===void 0?`bottom`:s,m=c===void 0?4:c,h=l===void 0?`start`:l,g=u===void 0?0:u,_=d===void 0||d,v=f===void 0||f,y;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,G.jsx)(Ct,{className:`top-0 z-50 flex h-6 w-full cursor-default items-center justify-center before:pointer-events-none before:absolute before:inset-x-px before:top-px before:h-[200%] before:rounded-t-[calc(var(--radius-lg)-1px)] before:bg-linear-to-b before:from-50% before:from-popover`,"data-slot":`select-scroll-up-arrow`,children:(0,G.jsx)(Ee,{className:`relative size-4.5 sm:size-4`})}),t[12]=y):y=t[12];let b=v&&`min-w-(--anchor-width)`,x;t[13]!==a||t[14]!==b?(x=V(`dropdown-glass relative h-full rounded-lg`,b,a),t[13]=a,t[14]=b,t[15]=x):x=t[15];let S;t[16]===i?S=t[17]:(S=V(`max-h-(--available-height) overflow-y-auto p-1`,i),t[16]=i,t[17]=S);let C;t[18]!==r||t[19]!==S?(C=(0,G.jsx)(ht,{className:S,"data-slot":`select-list`,children:r}),t[18]=r,t[19]=S,t[20]=C):C=t[20];let w;t[21]!==C||t[22]!==x?(w=(0,G.jsx)(`div`,{className:x,children:C}),t[21]=C,t[22]=x,t[23]=w):w=t[23];let T;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,G.jsx)(yt,{className:`bottom-0 z-50 flex h-6 w-full cursor-default items-center justify-center before:pointer-events-none before:absolute before:inset-x-px before:bottom-px before:h-[200%] before:rounded-b-[calc(var(--radius-lg)-1px)] before:bg-linear-to-t before:from-50% before:from-popover`,"data-slot":`select-scroll-down-arrow`,children:(0,G.jsx)(Ce,{className:`relative size-4.5 sm:size-4`})}),t[24]=T):T=t[24];let E;t[25]!==o||t[26]!==w?(E=(0,G.jsxs)(bt,{className:`origin-(--transform-origin) rounded-lg text-foreground outline-none`,"data-slot":`select-popup`,...o,children:[y,w,T]}),t[25]=o,t[26]=w,t[27]=E):E=t[27];let D;return t[28]!==h||t[29]!==_||t[30]!==g||t[31]!==n||t[32]!==p||t[33]!==m||t[34]!==E?(D=(0,G.jsx)(gt,{children:(0,G.jsx)(St,{align:h,alignItemWithTrigger:_,alignOffset:g,anchor:n,className:`z-50 select-none`,"data-slot":`select-positioner`,side:p,sideOffset:m,children:E})}),t[28]=h,t[29]=_,t[30]=g,t[31]=n,t[32]=p,t[33]=m,t[34]=E,t[35]=D):D=t[35],D}function si(e){let t=(0,U.c)(13),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({className:r,children:n,hideIndicator:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o;t[5]===r?o=t[6]:(o=V(`flex min-h-8 in-data-[side=none]:min-w-[calc(var(--anchor-width)+1.25rem)] cursor-default items-center rounded-sm px-2 py-1 text-base outline-none data-selected:bg-foreground/[0.08] data-disabled:pointer-events-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:opacity-64 sm:min-h-7 sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0`,r),t[5]=r,t[6]=o);let s;t[7]===n?s=t[8]:(s=(0,G.jsx)(xt,{className:`min-w-0 flex-1 [&_svg:not([class*='text-'])]:text-muted-foreground`,"data-slot":`select-item-text`,children:n}),t[7]=n,t[8]=s);let c;return t[9]!==i||t[10]!==o||t[11]!==s?(c=(0,G.jsx)(_t,{className:o,"data-slot":`select-item`,...i,children:s}),t[9]=i,t[10]=o,t[11]=s,t[12]=c):c=t[12],c}function ci(e){let t=(0,U.c)(11),{label:n,onClick:r,children:i}=e,a;t[0]!==n||t[1]!==r?(a=(0,G.jsx)(W,{size:`icon-sm`,variant:`ghost`,"aria-label":n,onClick:r}),t[0]=n,t[1]=r,t[2]=a):a=t[2];let o;t[3]!==i||t[4]!==a?(o=(0,G.jsx)(Ot,{render:a,children:i}),t[3]=i,t[4]=a,t[5]=o):o=t[5];let s;t[6]===n?s=t[7]:(s=(0,G.jsx)(kt,{children:n}),t[6]=n,t[7]=s);let c;return t[8]!==o||t[9]!==s?(c=(0,G.jsxs)(jt,{children:[o,s]}),t[8]=o,t[9]=s,t[10]=c):c=t[10],c}function li(e){let t=(0,U.c)(27),{title:n,heading:r,card:i,thread:a,hostLabel:o,onOpenThread:s,onCollapse:c}=e,l=n===void 0?`Design agent`:n,u;t[0]!==r||t[1]!==l?(u=r??(0,G.jsxs)(`h2`,{children:[(0,G.jsx)(qe,{"aria-hidden":`true`,size:16}),l]}),t[0]=r,t[1]=l,t[2]=u):u=t[2];let d;t[3]===o?d=t[4]:(d=o?(0,G.jsx)(`span`,{className:`design-small-muted`,children:o}):null,t[3]=o,t[4]=d);let f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,G.jsx)(`span`,{className:`design-agent-header-spacer`}),t[5]=f):f=t[5];let p;t[6]===s?p=t[7]:(p=s?(0,G.jsx)(ci,{label:`Open full thread`,onClick:s,children:(0,G.jsx)(z,{"aria-hidden":`true`})}):null,t[6]=s,t[7]=p);let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,G.jsx)(we,{"aria-hidden":`true`}),t[8]=m):m=t[8];let h;t[9]===c?h=t[10]:(h=(0,G.jsx)(ci,{label:`Hide agent`,onClick:c,children:m}),t[9]=c,t[10]=h);let g;t[11]!==u||t[12]!==d||t[13]!==p||t[14]!==h?(g=(0,G.jsxs)(`header`,{className:`design-agent-header`,children:[u,d,f,p,h]}),t[11]=u,t[12]=d,t[13]=p,t[14]=h,t[15]=g):g=t[15];let _;t[16]===i?_=t[17]:(_=i?(0,G.jsx)(`div`,{className:`design-agent-card`,children:i}):null,t[16]=i,t[17]=_);let v;t[18]===a?v=t[19]:(v=a??(0,G.jsx)(`p`,{className:`design-agent-empty`,children:`Open this design from a thread to talk to the agent.`}),t[18]=a,t[19]=v);let y;t[20]===v?y=t[21]:(y=(0,G.jsx)(`div`,{className:`design-agent-thread`,children:v}),t[20]=v,t[21]=y);let b;return t[22]!==y||t[23]!==g||t[24]!==_||t[25]!==l?(b=(0,G.jsxs)(`aside`,{className:`design-agent`,"aria-label":l,children:[g,_,y]}),t[22]=y,t[23]=g,t[24]=_,t[25]=l,t[26]=b):b=t[26],b}function ui(e){let t=(0,U.c)(3),{onOpen:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,G.jsx)(qe,{"aria-hidden":`true`}),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,G.jsxs)(W,{size:`sm`,variant:`outline`,className:`design-float-pill`,onClick:n,children:[r,`Agent`]}),t[1]=n,t[2]=i),i}function di(e,t,n,r,i=0){if(!e.length)return{x:0,y:0,width:t,height:n};let a=Math.min(...e.map(e=>e.x)),o=Math.min(...e.map(e=>e.y)),s=Math.max(...e.map(e=>e.x+e.width)),c=Math.max(...e.map(e=>e.y+e.height)),l=r===`workspace`?{left:32,right:32+i,top:72,bottom:72}:{left:56,right:24,top:56,bottom:100},u=Math.max(40,t-l.left-l.right),d=Math.max(40,n-l.top-l.bottom),f=Math.max(1,s-a),p=Math.max(1,c-o),m=Math.max(.05,Math.min(2,u/f,d/p));return{x:a-(l.left+(u-f*m)/2)/m,y:o-(l.top+(d-p*m)/2)/m,width:t/m,height:n/m}}var fi=(e,t,n)=>Math.min(Math.max(e,t),n),pi=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height;function mi(e,t,n,r={top:60,right:12,bottom:12,left:12},i={below:32,above:12},a=null){if(e.x+e.width<0||e.x>n.width||e.y+e.height<0||e.y>n.height)return null;let o=e=>fi(e,r.left,Math.max(r.left,n.width-r.right-t.width)),s=o(e.x+e.width/2-t.width/2),c=n.height-r.bottom,l=Math.max(r.top,e.y+e.height+i.below),u=e.y-i.above-t.height,d=[];l+t.height<=c&&d.push({x:s,y:l,side:`below`}),u>=r.top&&d.push({x:s,y:u,side:`above`});let f={x:s,y:fi(l,r.top,Math.max(r.top,c-t.height)),side:`below`};if(!a)return d[0]??f;let p=e=>!pi({...e,width:t.width,height:t.height},a),m=[...d,f],h=m.flatMap(e=>[{...e,x:o(a.x-i.above-t.width)},{...e,x:o(a.x+a.width+i.above)}]);return[...m,...h].find(p)??d[0]??f}var hi={width:280,height:110};function gi(e,t,n,r=null,i=hi){let a=(t,r,a)=>({side:r,placement:a,reach:r===`left`?e.x-t.x:t.x+t.width-(e.x+e.width),fits:r===`right`?t.x+t.width+i.width<=n.width:t.x>=i.width,box:{x:r===`right`?t.x+t.width:t.x-i.width,y:e.y,width:i.width,height:i.height}}),o=[...t?[a(t,`right`,`margin`),a(t,`left`,`margin`)]:[],a(e,`right`,`node`),a(e,`left`,`node`)],s=o.filter(e=>e.fits),c=s.find(e=>!r||!pi(e.box,r))??s[0]??o.at(-2);return{side:c.side,placement:c.placement,reach:Math.max(0,c.reach)}}function _i(e,t,n,r){let i=e=>({x:(e.x-n.x)*r,y:(e.y-n.y)*r,width:e.width*r,height:e.height*r}),a=t.map(e=>({key:e.key,rect:i(e.bounds)})),o=[],s=new Set;for(let t of e.toSorted((e,t)=>t.bounds.width*t.bounds.height-e.bounds.width*e.bounds.height)){let e=i(t.bounds),n={x:e.x,y:e.y-20,width:Math.min(240,e.width),height:20};a.some(e=>e.key!==t.key&&pi(n,e.rect))||o.some(e=>pi(n,e))?s.add(t.key):o.push(n)}return s}var vi=Math.PI/180;function yi(){return typeof window<`u`&&({}.toString.call(window)===`[object Window]`||{}.toString.call(window)===`[object global]`)}var bi=typeof global<`u`?global:typeof window<`u`?window:typeof WorkerGlobalScope<`u`?self:{},K={_global:bi,version:`10.7.1`,isBrowser:yi(),isUnminified:/param/.test(function(e){}.toString()),dblClickWindow:400,getAngle(e){return K.angleDeg?e*vi:e},enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_renderBackend:`web`,legacyTextRendering:!1,pixelRatio:typeof window<`u`&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging(){return K.DD.isDragging},isTransforming(){return K.Transformer?.isTransforming()??!1},isDragReady(){return!!K.DD.node},releaseCanvasOnDestroy:!0,document:bi.document,_injectGlobal(e){bi.Konva!==void 0&&console.error(`Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment.`),bi.Konva=e}},xi=new Set,Si=(e,t=!1)=>{K[e.prototype.getClassName()]=e,t&&xi.add(e)};K._injectGlobal(K);var Ci=`Konva.js unsupported environment.
3
3
 
4
4
  Looks like you are trying to use Konva.js in Node.js environment (or in a Web Worker), because "document" object is undefined.
@@ -13,7 +13,7 @@ or
13
13
  bash: npm install skia-canvas
14
14
  js: import "konva/skia-backend";
15
15
  `,wi=()=>{if(typeof document>`u`)throw Error(Ci)},Ti=class e{constructor(e){this.dirty=!1,this.m=e?e.slice():[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new e(this.m)}copyInto(e){e.m[0]=this.m[0],e.m[1]=this.m[1],e.m[2]=this.m[2],e.m[3]=this.m[3],e.m[4]=this.m[4],e.m[5]=this.m[5]}point(e){let t=this.m;return{x:t[0]*e.x+t[2]*e.y+t[4],y:t[1]*e.x+t[3]*e.y+t[5]}}_getTransformedRect(e){let[t,n,r,i,a,o]=this.m,s=e.x,c=e.y,l=e.x+e.width,u=e.y+e.height,d=[t*s+r*c+a,t*l+r*c+a,t*l+r*u+a,t*s+r*u+a],f=[n*s+i*c+o,n*l+i*c+o,n*l+i*u+o,n*s+i*u+o],p=Math.min(d[0],d[1],d[2],d[3]),m=Math.min(f[0],f[1],f[2],f[3]);return{x:p,y:m,width:Math.max(d[0],d[1],d[2],d[3])-p,height:Math.max(f[0],f[1],f[2],f[3])-m}}translate(e,t){return this.m[4]+=this.m[0]*e+this.m[2]*t,this.m[5]+=this.m[1]*e+this.m[3]*t,this}scale(e,t){return this.m[0]*=e,this.m[1]*=e,this.m[2]*=t,this.m[3]*=t,this}rotate(e){let t=Math.cos(e),n=Math.sin(e),r=this.m[0]*t+this.m[2]*n,i=this.m[1]*t+this.m[3]*n,a=this.m[0]*-n+this.m[2]*t,o=this.m[1]*-n+this.m[3]*t;return this.m[0]=r,this.m[1]=i,this.m[2]=a,this.m[3]=o,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(e,t){let n=this.m[0]+this.m[2]*t,r=this.m[1]+this.m[3]*t,i=this.m[2]+this.m[0]*e,a=this.m[3]+this.m[1]*e;return this.m[0]=n,this.m[1]=r,this.m[2]=i,this.m[3]=a,this}multiply(e){let t=this.m[0]*e.m[0]+this.m[2]*e.m[1],n=this.m[1]*e.m[0]+this.m[3]*e.m[1],r=this.m[0]*e.m[2]+this.m[2]*e.m[3],i=this.m[1]*e.m[2]+this.m[3]*e.m[3],a=this.m[0]*e.m[4]+this.m[2]*e.m[5]+this.m[4],o=this.m[1]*e.m[4]+this.m[3]*e.m[5]+this.m[5];return this.m[0]=t,this.m[1]=n,this.m[2]=r,this.m[3]=i,this.m[4]=a,this.m[5]=o,this}isInvertible(){return this.m[0]*this.m[3]-this.m[1]*this.m[2]!==0}invert(){let e=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),t=this.m[3]*e,n=-this.m[1]*e,r=-this.m[2]*e,i=this.m[0]*e,a=e*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),o=e*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=t,this.m[1]=n,this.m[2]=r,this.m[3]=i,this.m[4]=a,this.m[5]=o,this}getMatrix(){return this.m}decompose(){let e=this.m[0],t=this.m[1],n=this.m[2],r=this.m[3],i=this.m[4],a=this.m[5],o=e*r-t*n,s={x:i,y:a,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(e!=0||t!=0){let i=Math.sqrt(e*e+t*t);s.rotation=t>0?Math.acos(e/i):-Math.acos(e/i),s.scaleX=i,s.scaleY=o/i,s.skewX=o&&(e*n+t*r)/o,s.skewY=0}else if(n!=0||r!=0){let i=Math.sqrt(n*n+r*r);s.rotation=Math.PI/2-(r>0?Math.acos(-n/i):-Math.acos(n/i)),s.scaleX=o/i,s.scaleY=i,s.skewX=0,s.skewY=o&&(e*n+t*r)/o}return s.rotation=q._getRotation(s.rotation),s}},Ei=`[object Array]`,Di=`[object Number]`,Oi=`[object String]`,ki=`[object Boolean]`,Ai=Math.PI/180,ji=180/Math.PI,Mi=`#`,Ni=``,Pi=`0`,Fi=`Konva warning: `,Ii=`Konva error: `,Li={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[0,0,0,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},Ri=null,zi=typeof window<`u`?window:{},Bi=new WeakMap,Vi=(e,t)=>{typeof e.requestAnimationFrame==`function`?e.requestAnimationFrame(t):typeof requestAnimationFrame<`u`?requestAnimationFrame(t):setTimeout(t,16)},Hi=new Map,Ui=Object.getPrototypeOf(Int8Array),Wi=e=>{let t=e.trim();return t.indexOf(`,`)===-1?t.split(/\s*\/\s*|\s+/):t.split(/\s*,\s*/)},Gi=`[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[+-]?\\d+)?`,Ki=RegExp(`^(${Gi})(%?)$`,`i`),qi=(e,t)=>{let n=Ki.exec(e);if(!n)return NaN;let r=n[2]?Number(n[1])/100*t:Number(n[1]);return Math.min(Math.max(r,0),t)},Ji=/^#[0-9a-f]+$/i,Yi=RegExp(`^(${Gi})(deg|grad|rad|turn)?$`,`i`),Xi={deg:1,grad:.9,rad:ji,turn:360};function Zi(e,t){return Math.min(Math.max(e||0,0),t)}var q={_isElement(e){return!!(e&&e.nodeType==1)},_isFunction(e){return!!(e&&e.constructor&&e.call&&e.apply)},_isPlainObject(e){return!!e&&e.constructor===Object},_isArray(e){return Object.prototype.toString.call(e)===Ei},_isNumber(e){return Object.prototype.toString.call(e)===Di&&!isNaN(e)&&isFinite(e)},_isString(e){return Object.prototype.toString.call(e)===Oi},_isBoolean(e){return Object.prototype.toString.call(e)===ki},isObject(e){return e instanceof Object},isValidSelector(e){if(typeof e!=`string`)return!1;let t=e[0];return t===`#`||t===`.`||t===t.toUpperCase()},_sign(e){return e===0||e>0?1:-1},requestAnimFrame(e,t){let n=t&&!t.closed&&t||zi,r=Bi.get(n);r||(r=[],Bi.set(n,r),Vi(n,function(){Bi.delete(n),r.forEach(function(e){e()})})),r.push(e)},createCanvasElement(){wi();let e=document.createElement(`canvas`);try{e.style=e.style||{}}catch{}return e},createImageElement(){return wi(),document.createElement(`img`)},_urlToImage(e,t,n){let r=q.createImageElement();r.onload=function(){t(r)},r.onerror=e=>{n?.(e instanceof Error?e:Error(`Unable to load image.`))},r.src=e},_rgbToHex(e,t,n){return((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1)},_hexToRgb(e){e=e.replace(Mi,Ni);let t=parseInt(e,16);return{r:t>>16&255,g:t>>8&255,b:t&255}},getRandomColor(){let e=(Math.random()*16777215<<0).toString(16);for(;e.length<6;)e=Pi+e;return Mi+e},isCanvasFarblingActive(){if(Ri!==null)return Ri;if(typeof document>`u`)return Ri=!1,!1;let e=this.createCanvasElement();e.width=10,e.height=10;let t=e.getContext(`2d`,{willReadFrequently:!0});t.clearRect(0,0,10,10),t.fillStyle=`#282828`,t.fillRect(0,0,10,10);let n=t.getImageData(0,0,10,10).data,r=!1;for(let e=0;e<100;e++)if(n[e*4]!==40||n[e*4+1]!==40||n[e*4+2]!==40||n[e*4+3]!==255){r=!0;break}return Ri=r,this.releaseCanvas(e),Ri},getHitColor(){let e=()=>Math.random()*256|0;return this.getHitColorKey(e(),e(),e())},getHitColorKey(e,t,n){let r=this.isCanvasFarblingActive()?5:3,i=e=>Math.round(e/r)*r;return Mi+this._rgbToHex(i(e),i(t),i(n))},getSnappedHexColor(e){let{r:t,g:n,b:r}=this._hexToRgb(e);return this.getHitColorKey(t,n,r)},getRGB(e){let{r:t=0,g:n=0,b:r=0}=q.colorToRGBA(e)??{};return{r:t,g:n,b:r}},colorToRGBA(e){e=(e||``).trim()||`black`;let t=q._namedColorToRBA(e)||q._hex3ColorToRGBA(e)||q._hex4ColorToRGBA(e)||q._hex6ColorToRGBA(e)||q._hex8ColorToRGBA(e)||q._rgbColorToRGBA(e)||q._hslColorToRGBA(e);if(t&&[t.r,t.g,t.b,t.a].every(q._isNumber))return t},_namedColorToRBA(e){let t=Li[e.toLowerCase()];return t?{r:t[0],g:t[1],b:t[2],a:t.length>3?t[3]:1}:null},_rgbColorToRGBA(e){let t=/^rgba?\(([^)]*)\)$/i.exec(e);if(!t)return;let n=Wi(t[1]);if(!(n.length<3||n.length>4))return{r:qi(n[0],255),g:qi(n[1],255),b:qi(n[2],255),a:n.length>3?qi(n[3],1):1}},_hex8ColorToRGBA(e){if(e.length===9&&Ji.test(e))return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:parseInt(e.slice(7,9),16)/255}},_hex6ColorToRGBA(e){if(e.length===7&&Ji.test(e))return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:1}},_hex4ColorToRGBA(e){if(e.length===5&&Ji.test(e))return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:parseInt(e[4]+e[4],16)/255}},_hex3ColorToRGBA(e){if(e.length===4&&Ji.test(e))return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:1}},_hslColorToRGBA(e){let t=/^hsla?\(([^)]*)\)$/i.exec(e);if(!t)return;let n=Wi(t[1]);if(n.length<3||n.length>4)return;let r=Yi.exec(n[0]);if(!r)return;let i=r[2],a=Number(r[1])*(i?Xi[i.toLowerCase()]:1);if(!isFinite(a))return;let o=(a%360+360)%360/360,s=qi(n[1],100)/100,c=qi(n[2],100)/100,l=n.length>3?qi(n[3],1):1,u=c<.5?c*(1+s):c+s-c*s,d=2*c-u,f=[0,0,0];for(let e=0;e<3;e++){let t=o+1/3*-(e-1);t<0&&t++,t>1&&t--;let n;n=6*t<1?d+(u-d)*6*t:2*t<1?u:3*t<2?d+(u-d)*(2/3-t)*6:d,f[e]=n*255}return{r:Math.round(f[0]),g:Math.round(f[1]),b:Math.round(f[2]),a:l}},_getPointsRect(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a=0;a<e.length;a+=2){let o=e[a],s=e[a+1];isNaN(o)||(t=Math.min(t,o),r=Math.max(r,o)),isNaN(s)||(n=Math.min(n,s),i=Math.max(i,s))}return isFinite(t+n)?{x:t,y:n,width:r-t,height:i-n}:{x:0,y:0,width:0,height:0}},haveIntersection(e,t){return!(t.x>e.x+e.width||t.x+t.width<e.x||t.y>e.y+e.height||t.y+t.height<e.y)},cloneObject(e){let t={};for(let n in e)t[n]=q._cloneValue(e[n]);return t},_cloneValue(e){return q._isArray(e)?e.some(e=>typeof e==`object`)?e.map(q._cloneValue):e.slice():q._isPlainObject(e)?q.cloneObject(e):e instanceof Ui?e.slice():e},cloneArray(e){return e.slice(0)},degToRad(e){return e*Ai},radToDeg(e){return e*ji},_getRotation(e){return K.angleDeg?q.radToDeg(e):e},_capitalize(e){let t=Hi.get(e);if(t!==void 0)return t;let n=e.charAt(0).toUpperCase()+e.slice(1);return Hi.set(e,n),n},throw(e){throw Error(Ii+e)},error(e){console.error(Ii+e)},warn(e){K.showWarnings&&console.warn(Fi+e)},_batchEvents(e,t){if(!e)return t();let n=!1,r=!0;try{e(()=>{if(n||!r){q.warn(`eventBatchFunc must call its argument exactly once, synchronously.`);return}n=!0,t()})}finally{r=!1,n||q.warn(`eventBatchFunc must call its argument synchronously.`)}},each(e,t){for(let n in e)t(n,e[n])},_inRange(e,t,n){return t<=e&&e<n},_getProjectionToSegment(e,t,n,r,i,a){let o,s,c,l=(e-n)*(e-n)+(t-r)*(t-r);if(l==0)o=e,s=t,c=(i-n)*(i-n)+(a-r)*(a-r);else{let u=((i-e)*(n-e)+(a-t)*(r-t))/l;u<0?(o=e,s=t,c=(e-i)*(e-i)+(t-a)*(t-a)):u>1?(o=n,s=r,c=(n-i)*(n-i)+(r-a)*(r-a)):(o=e+u*(n-e),s=t+u*(r-t),c=(o-i)*(o-i)+(s-a)*(s-a))}return[o,s,c]},_getProjectionToLine(e,t,n){let r=q.cloneObject(e),i=Number.MAX_VALUE;return t.forEach(function(a,o){if(!n&&o===t.length-1)return;let s=t[(o+1)%t.length],c=q._getProjectionToSegment(a.x,a.y,s.x,s.y,e.x,e.y),l=c[0],u=c[1],d=c[2];d<i&&(r.x=l,r.y=u,i=d)}),r},_prepareArrayForTween(e,t,n){let r=[],i=[];if(e.length>t.length){let n=t;t=e,e=n}for(let t=0;t<e.length;t+=2)r.push({x:e[t],y:e[t+1]});for(let e=0;e<t.length;e+=2)i.push({x:t[e],y:t[e+1]});let a=[];return i.forEach(function(e){let t=q._getProjectionToLine(e,r,n);a.push(t.x),a.push(t.y)}),a},_prepareToStringify(e,t=new Set){let n=q._isArray(e)?[]:{};t.add(e);for(let r of Object.keys(e)){let i=e[r];q._isElement(i)||t.has(i)||(n[r]=q._isPlainObject(i)||q._isArray(i)?q._prepareToStringify(i,t):i)}return t.delete(e),n},_assign(e,t){for(let n in t)e[n]=t[n];return e},_getEventType(e){return e.indexOf(`pointer`)>=0?`pointer`:e.indexOf(`touch`)>=0?`touch`:`mouse`},_getFirstPointerId(e){return e.touches?e.changedTouches[0].identifier:e.pointerId??999},releaseCanvas(...e){K.releaseCanvasOnDestroy&&e.forEach(e=>{e.width=0,e.height=0})},_cornerRadii(e,t,n){let r=Math.min(t,n)/2;if(typeof e==`number`){let t=Zi(e,r);return[t,t,t,t]}return[Zi(e[0],r),Zi(e[1],r),Zi(e[2],r),Zi(e[3],r)]},drawRoundedRectPath(e,t,n,r){let i=t<0?t:0,a=n<0?n:0;t=Math.abs(t),n=Math.abs(n);let[o,s,c,l]=q._cornerRadii(r,t,n);e.moveTo(i+o,a),e.lineTo(i+t-s,a),e.arc(i+t-s,a+s,s,Math.PI*3/2,0,!1),e.lineTo(i+t,a+n-c),e.arc(i+t-c,a+n-c,c,0,Math.PI/2,!1),e.lineTo(i+l,a+n),e.arc(i+l,a+n-l,l,Math.PI/2,Math.PI,!1),e.lineTo(i,a+o),e.arc(i+o,a+o,o,Math.PI,Math.PI*3/2,!1)},drawRoundedPolygonPath(e,t,n,r,i){r=Math.abs(r);for(let a=0;a<n;a++){let o=t[(a-1+n)%n],s=t[a],c=t[(a+1)%n],l={x:s.x-o.x,y:s.y-o.y},u={x:c.x-s.x,y:c.y-s.y},d=Math.hypot(l.x,l.y),f=Math.hypot(u.x,u.y),p;p=typeof i==`number`?i:a<i.length?i[a]:0,p=r*Math.cos(Math.PI/n)*Math.min(1,p/r*2);let m={x:l.x/d,y:l.y/d},h={x:u.x/f,y:u.y/f},g={x:s.x-m.x*p,y:s.y-m.y*p},_={x:s.x+h.x*p,y:s.y+h.y*p};a===0?e.moveTo(g.x,g.y):e.lineTo(g.x,g.y),e.arcTo(s.x,s.y,_.x,_.y,p)}}};function Qi(e){let t=[],n=e.length,r=q;for(let i=0;i<n;i++){let n=e[i];r._isNumber(n)?n=Math.round(n*1e3)/1e3:r._isString(n)||(n+=``),t.push(n)}return t}var $i=`,`,ea=`(`,ta=`)`,na=`;`,ra=`()`,ia=`=`,aa=`arc.arcTo.beginPath.bezierCurveTo.clearRect.clip.closePath.createLinearGradient.createPattern.createRadialGradient.drawImage.ellipse.fill.fillText.getImageData.createImageData.lineTo.moveTo.putImageData.quadraticCurveTo.rect.roundRect.restore.rotate.save.scale.setLineDash.setTransform.stroke.strokeText.transform.translate`.split(`.`),oa=[`fillStyle`,`strokeStyle`,`shadowColor`,`shadowBlur`,`shadowOffsetX`,`shadowOffsetY`,`letterSpacing`,`lineCap`,`lineDashOffset`,`lineJoin`,`lineWidth`,`miterLimit`,`direction`,`font`,`textAlign`,`textBaseline`,`globalAlpha`,`globalCompositeOperation`,`imageSmoothingEnabled`,`imageSmoothingQuality`,`filter`],sa=100,ca=null;function la(){if(ca!==null)return ca;try{let e=q.createCanvasElement(),t=e.getContext(`2d`);ca=!!t&&`filter`in t,q.releaseCanvas(e)}catch{ca=!1}return ca}var ua=class{constructor(e){this.canvas=e,K.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(e){e.fillEnabled()&&this._fill(e)}_fill(e){}strokeShape(e){e.hasStroke()&&this._stroke(e)}_stroke(e){}fillStrokeShape(e){e.attrs.fillAfterStrokeEnabled?(this.strokeShape(e),this.fillShape(e)):(this.fillShape(e),this.strokeShape(e))}getTrace(e,t){let n=this.traceArr,r=n.length,i=``,a,o,s,c;for(a=0;a<r;a++)o=n[a],s=o.method,s?(c=o.args,i+=s,e?i+=ra:(t&&(c=c.map(e=>typeof e==`number`?Math.floor(e):e)),i+=ea+c.join($i)+ta)):(i+=o.property,e||(i+=ia+o.val)),i+=na;return i}clearTrace(){this.traceArr=[]}_trace(e){let t=this.traceArr,n;t.push(e),n=t.length,n>=sa&&t.shift()}reset(){let e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){let t=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,t.getWidth()/t.pixelRatio,t.getHeight()/t.pixelRatio)}_drawDeviceBuffer(e){let{x:t,y:n,width:r,height:i}=e._isolationRect;this.setTransform(1,0,0,1,0,0),this.imageSmoothingEnabled=!1,this.drawImage(e._canvas,0,0,r,i,t,n,r,i)}_applyLineCap(e){let t=e.attrs.lineCap;t&&this.setAttr(`lineCap`,t)}_getOpacity(e){if(!this._opacityRoot)return e.getAbsoluteOpacity();let t=e.opacity(),n=e.parent;for(;n&&n!==this._opacityRoot;)t*=n.opacity(),n=n.parent;return t}_applyOpacity(e){let t=this._getOpacity(e);t!==1&&this.setAttr(`globalAlpha`,t)}_applyLineJoin(e){let t=e.attrs.lineJoin;t&&this.setAttr(`lineJoin`,t)}_applyMiterLimit(e){let t=e.attrs.miterLimit;t!=null&&this.setAttr(`miterLimit`,t)}setAttr(e,t){this._context[e]=t}arc(e,t,n,r,i,a){this._context.arc(e,t,n,r,i,a)}arcTo(e,t,n,r,i){this._context.arcTo(e,t,n,r,i)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,n,r,i,a){this._context.bezierCurveTo(e,t,n,r,i,a)}clearRect(e,t,n,r){this._context.clearRect(e,t,n,r)}clip(...e){this._context.clip.apply(this._context,e)}closePath(){this._context.closePath()}createImageData(e,t){let n=arguments;if(n.length===2)return this._context.createImageData(e,t);if(n.length===1)return this._context.createImageData(e)}createLinearGradient(e,t,n,r){return this._context.createLinearGradient(e,t,n,r)}createPattern(e,t){return this._context.createPattern(e,t)}createRadialGradient(e,t,n,r,i,a){return this._context.createRadialGradient(e,t,n,r,i,a)}drawImage(e,t,n,r,i,a,o,s,c){let l=arguments,u=this._context;l.length===3?u.drawImage(e,t,n):l.length===5?u.drawImage(e,t,n,r,i):l.length===9&&u.drawImage(e,t,n,r,i,a,o,s,c)}ellipse(e,t,n,r,i,a,o,s){this._context.ellipse(e,t,n,r,i,a,o,s)}isPointInPath(e,t,n,r){return n?this._context.isPointInPath(n,e,t,r):this._context.isPointInPath(e,t,r)}fill(...e){this._context.fill.apply(this._context,e)}fillRect(e,t,n,r){this._context.fillRect(e,t,n,r)}strokeRect(e,t,n,r){this._context.strokeRect(e,t,n,r)}fillText(e,t,n,r){r?this._context.fillText(e,t,n,r):this._context.fillText(e,t,n)}measureText(e){return this._context.measureText(e)}getImageData(e,t,n,r){return this._context.getImageData(e,t,n,r)}lineTo(e,t){this._context.lineTo(e,t)}moveTo(e,t){this._context.moveTo(e,t)}rect(e,t,n,r){this._context.rect(e,t,n,r)}roundRect(e,t,n,r,i){this._context.roundRect(e,t,n,r,i)}putImageData(e,t,n){this._context.putImageData(e,t,n)}quadraticCurveTo(e,t,n,r){this._context.quadraticCurveTo(e,t,n,r)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,t){this._context.scale(e,t)}setLineDash(e){this._context.setLineDash(e)}getLineDash(){return this._context.getLineDash()}setTransform(e,t,n,r,i,a){this._context.setTransform(e,t,n,r,i,a)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,t,n,r){this._context.strokeText(e,t,n,r)}transform(e,t,n,r,i,a){this._context.transform(e,t,n,r,i,a)}translate(e,t){this._context.translate(e,t)}_enableTrace(){let e=this,t=aa.length,n=this.setAttr,r,i,a=function(t){let n=e[t],r;e[t]=function(){return i=Qi(Array.prototype.slice.call(arguments,0)),r=n.apply(e,arguments),e._trace({method:t,args:i}),r}};for(r=0;r<t;r++)a(aa[r]);e.setAttr=function(){n.apply(e,arguments);let t=arguments[0],r=arguments[1];(t===`shadowOffsetX`||t===`shadowOffsetY`||t===`shadowBlur`)&&(r/=this.canvas.getPixelRatio()),e._trace({property:t,val:r})}}_applyGlobalCompositeOperation(e){let t=e.attrs.globalCompositeOperation;t&&t!==`source-over`&&this.setAttr(`globalCompositeOperation`,t)}};oa.forEach(function(e){Object.defineProperty(ua.prototype,e,{get(){return this._context[e]},set(t){this._context[e]=t}})});var da=class extends ua{constructor(e,{willReadFrequently:t=!1}={}){super(e),this._context=e._canvas.getContext(`2d`,{willReadFrequently:t})}_getFillPattern(e){let t=this._context;return`patternQuality`in t&&(t.patternQuality=t.imageSmoothingEnabled?`good`:`nearest`),e._getFillPattern()}_getFillStyle(e){let t=e.fill(),n=e.fillPriority();if(t&&n===`color`)return t;let r=e.fillPatternImage();if(r&&n===`pattern`)return this._getFillPattern(e);let i=e.fillLinearGradientColorStops();if(i&&n===`linear-gradient`)return e._getLinearGradient();let a=e.fillRadialGradientColorStops();if(a&&n===`radial-gradient`)return e._getRadialGradient();if(t)return t;if(r)return this._getFillPattern(e);if(i)return e._getLinearGradient();if(a)return e._getRadialGradient()}_fill(e){let t=this._getFillStyle(e);t!==void 0&&(this.setAttr(`fillStyle`,t),e._fillFunc(this))}_strokeLinearGradient(e){let t=e.getStrokeLinearGradientStartPoint(),n=e.getStrokeLinearGradientEndPoint();if(!e.getStrokeScaleEnabled()){let{a:e,b:r,c:i,d:a,e:o,f:s}=this._context.getTransform(),c=new Ti([e,r,i,a,o,s]),l=this.canvas.getPixelRatio(),u=n.x-t.x,d=n.y-t.y,f=a*u-r*d,p=e*d-i*u,m=f*f+p*p,h=m?(u*u+d*d)*(e*a-r*i)/m:0;t=c.point(t),n={x:t.x+f*h,y:t.y+p*h},t={x:t.x/l,y:t.y/l},n={x:n.x/l,y:n.y/l}}let r=e.getStrokeLinearGradientColorStops(),i=this.createLinearGradient(t.x,t.y,n.x,n.y);if(r){for(let e=0;e<r.length;e+=2)i.addColorStop(r[e],r[e+1]);this.setAttr(`strokeStyle`,i)}}_applyStrokeStyle(e){e.strokeLinearGradientColorStops()?this._strokeLinearGradient(e):this.setAttr(`strokeStyle`,e.stroke())}_stroke(e){let t=e.dash(),n=e.getStrokeScaleEnabled();n||this.save(),this._applyLineCap(e),t&&e.dashEnabled()&&(this.setLineDash(t),this.setAttr(`lineDashOffset`,e.dashOffset())),this.setAttr(`lineWidth`,e.strokeWidth());let r=this.shadowColor,i=e.getShadowForStrokeEnabled();if(i||this.setAttr(`shadowColor`,`rgba(0,0,0,0)`),this._applyStrokeStyle(e),!n){let e=this.getCanvas().getPixelRatio();this.setTransform(e,0,0,e,0,0)}try{e._strokeFunc(this)}finally{i||this.setAttr(`shadowColor`,r),n||this.restore()}}_applyShadow(e){let t=e.getShadowRGBA()??`black`,n=e.getShadowBlur(),r=e.getShadowOffset(),i=e.getAbsoluteScale(),a=this.canvas.getPixelRatio(),o=i.x*a,s=i.y*a;this.setAttr(`shadowColor`,t),this.setAttr(`shadowBlur`,n*Math.min(Math.abs(o),Math.abs(s))),this.setAttr(`shadowOffsetX`,r.x*o),this.setAttr(`shadowOffsetY`,r.y*s)}},fa=class extends ua{constructor(e){super(e),this._context=e._canvas.getContext(`2d`,{willReadFrequently:!0})}_fill(e){this.save(),this.setAttr(`fillStyle`,e.colorKey),e._fillFuncHit(this),this.restore()}strokeShape(e){e.hasHitStroke()&&this._stroke(e)}_stroke(e){let t=e.getStrokeScaleEnabled();if(!t){this.save();let e=this.getCanvas().getPixelRatio();this.setTransform(e,0,0,e,0,0)}this._applyLineCap(e);let n=e.hitStrokeWidth(),r=n===`auto`?e.strokeWidth():n;this.setAttr(`lineWidth`,r),this.setAttr(`strokeStyle`,e.colorKey),e._strokeFuncHit(this),t||this.restore()}},pa=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this._logicalWidth=0,this._logicalHeight=0,this.isCache=!1;let t=(e||{}).pixelRatio||K.pixelRatio||K._global.devicePixelRatio||1;this.pixelRatio=t,this._canvas=q.createCanvasElement(),this._canvas.style.padding=`0`,this._canvas.style.margin=`0`,this._canvas.style.border=`0`,this._canvas.style.background=`transparent`,this._canvas.style.position=`absolute`,this._canvas.style.top=`0`,this._canvas.style.left=`0`}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(e){this.pixelRatio=e,this.setSize(this._logicalWidth,this._logicalHeight)}setWidth(e){this.setSize(e,this._logicalHeight)}setHeight(e){this.setSize(this._logicalWidth,e)}getWidth(){return this.width}getHeight(){return this.height}_bitmapSize(e){return Math.floor((e||0)*this.pixelRatio)}setSize(e,t){(!isFinite(e??0)||!isFinite(t??0))&&(q.error(`Canvas size must be finite numbers, got ${e}x${t}. The canvas is left empty.`),e=t=0),e||=0,t||=0;let n=this.pixelRatio,r=this.getContext()._context,i=r.imageSmoothingEnabled;this._logicalWidth=e,this._logicalHeight=t,this.width=this._canvas.width=this._bitmapSize(e),this.height=this._canvas.height=this._bitmapSize(t),this._canvas.style.width=e+`px`,this._canvas.style.height=t+`px`,r.scale(n,n),r.imageSmoothingEnabled=i}setSizeIfChanged(e,t){(this.width!==this._bitmapSize(e)||this.height!==this._bitmapSize(t))&&this.setSize(e,t)}toDataURL(e,t){try{return this._canvas.toDataURL(e,t)}catch{try{return this._canvas.toDataURL()}catch(e){throw q.error(`Unable to get data URL. `+e.message+` For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html.`),e}}}},ma=class e extends pa{_prepareIsolationCanvas(t){let{a:n,b:r,c:i,d:a,e:o,f:s}=this.getContext()._context.getTransform(),c=this._isolationRect||this,l=0,u=0,d=c.width,f=c.height;if(t){let e=new Ti([n,r,i,a,o,s])._getTransformedRect(t);l=Math.max(0,Math.floor(e.x)-1),u=Math.max(0,Math.floor(e.y)-1),d=Math.min(d,Math.ceil(e.x+e.width)+1)-l,f=Math.min(f,Math.ceil(e.y+e.height)+1)-u}d>0&&f>0||(l=u=0,d=f=1);let p=this._isolationCanvas||=new e({width:0,height:0,pixelRatio:this.pixelRatio});if(p.width<d||p.height<f){let e=this.pixelRatio,t=(t,n,r)=>Math.min(r,Math.ceil((n<t?Math.max(t,n*1.5):n)/e));p.setSize(t(d,p.width,this._logicalWidth),t(f,p.height,this._logicalHeight))}p._isolationRect={x:l,y:u,width:d,height:f};let m=p._isolationPeak;m.width=Math.max(m.width,d),m.height=Math.max(m.height,f);let h=p.getContext();h.setTransform(1,0,0,1,0,0),h.clearRect(0,0,d,f),h.setTransform(n,r,i,a,o-l,s-u);let g=this.getContext();return h.imageSmoothingEnabled=g.imageSmoothingEnabled,h.imageSmoothingQuality=g.imageSmoothingQuality,h.direction=g.direction,p}_trimIsolationCanvas(){let e=this._isolationCanvas;if(!e)return;let t=e._isolationPeak;e._isolationLowFrames=e.width*e.height>4*t.width*t.height?e._isolationLowFrames+1:0,e._isolationLowFrames>=10?this._releaseIsolationCanvas():(t.width=t.height=0,e._trimIsolationCanvas())}_releaseIsolationCanvas(){let e=this._isolationCanvas;e&&(e._releaseIsolationCanvas(),q.releaseCanvas(e._canvas),this._isolationCanvas=void 0)}setSize(e,t){this._releaseIsolationCanvas(),super.setSize(e,t)}constructor(e={width:0,height:0,willReadFrequently:!1}){super(e),this._isolationPeak={width:0,height:0},this._isolationLowFrames=0,this.context=new da(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}},ha=class extends pa{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new fa(this),this.context.imageSmoothingEnabled=!1,this.setSize(e.width,e.height)}},J={get isDragging(){let e=!1;return J._dragElements.forEach(t=>{t.dragStatus===`dragging`&&(e=!0)}),e},get node(){let e;for(let t of J._dragElements.values()){if(t.dragStatus===`dragging`)return t.node;e=t.node}return e},_dragElements:new Map,_listenToWindow(e){let t=t=>J._endDragBefore(t,e),n=t=>J._batchEvents(()=>J._drag(t,e),e),r=e=>J._batchEvents(()=>J._endDragAfter(e));e.addEventListener(`mouseup`,t,!0),e.addEventListener(`touchend`,t,!0),e.addEventListener(`touchcancel`,t,!0),e.addEventListener(`mousemove`,n),e.addEventListener(`touchmove`,n),e.addEventListener(`mouseup`,r,!1),e.addEventListener(`touchend`,r,!1),e.addEventListener(`touchcancel`,r,!1)},_batchEvents(e,t){if(!J._dragElements.size)return;let n=new Set;for(let{node:e}of J._dragElements.values()){let r=e.getStage();if(!r||t&&r._getOwnerWindow()!==t)continue;let i=r.eventBatchFunc();i&&n.add(i)}let r=e;for(let e of n){let t=r;r=()=>q._batchEvents(e,t)}r()},_drag(e,t){let n=[],r=new Set;J._dragElements.forEach((i,a)=>{let{node:o}=i,s=o.getStage();if(t&&s._getOwnerWindow()!==t||(r.has(s)||(s.setPointersPositions(e),r.add(s)),i.pointerEventType&&i.pointerEventType!==s._pointerEventType))return;i.pointerId===void 0&&(i.pointerId=q._getFirstPointerId(e),i.pointerEventType=s._pointerEventType,i.dragStatus===`dragging`&&s._cancelClick(i.pointerId,i.pointerEventType));let c=s._changedPointerPositions.find(e=>e.id===i.pointerId);if(c){if(i.dragStatus!==`dragging`){let t=o.dragDistance();if(Math.max(Math.abs(c.x-i.startPointerPos.x),Math.abs(c.y-i.startPointerPos.y))<t||(o.startDrag({evt:e}),!o.isDragging()))return}o._setDragPosition(e,i),n.push(o)}}),n.forEach(t=>{t.getStage()&&t.fire(`dragmove`,{type:`dragmove`,target:t,evt:e},!0)})},_endDragBefore(e,t,n){let r=[],i=new Set;J._dragElements.forEach((a,o)=>{let{node:s}=a;if(n&&a!==n&&a.pointerId!==n.pointerId)return;let c=s.getStage();if(e&&!i.has(c)&&(!t||c._getOwnerWindow()===t)&&(c.setPointersPositions(e),i.add(c)),n||(!e||!a.pointerEventType||a.pointerEventType===q._getEventType(e.type))&&(a.pointerId===void 0||c._changedPointerPositions.some(e=>e.id===a.pointerId))){if(a.dragStatus===`ready`)J._dragElements.delete(o);else{c._cancelClick(a.pointerId,a.pointerEventType),a.dragStatus=`stopped`;let e=s.getLayer()||c;e&&r.indexOf(e)===-1&&r.push(e)}}}),r.forEach(e=>{e.draw()})},_endDragAfter(e,t){J._dragElements.forEach((n,r)=>{n.dragStatus!==`stopped`||t&&n!==t&&n.pointerId!==t.pointerId||(n.node.fire(`dragend`,{type:`dragend`,target:n.node,evt:e},!0),n.dragStatus!==`dragging`&&J._dragElements.delete(r))})}},ga=new Map,_a=K._global.PointerEvent!==void 0;function va(e,t){let n=ga.get(e);return n&&(!t||n.stage===t)?n.shape:void 0}function ya(e,t,n){e._fire(t,{evt:new PointerEvent(t,{pointerId:n}),pointerId:n})}function ba(e,t){return ga.get(e)?.shape===t}function xa(e,t){var n;Ca(e);let r=t.getStage();if(r&&(ga.set(e,{shape:t,stage:r}),_a)){try{(n=r.content)==null||n.setPointerCapture(e)}catch{}ya(t,`gotpointercapture`,e)}}function Sa(e){ga.forEach(({shape:t,stage:n},r)=>{(t===e||n===e)&&Ca(r)})}function Ca(e,t){var n;let r=ga.get(e);if(!r||t&&r.shape!==t)return;let{shape:i,stage:a}=r;if(ga.delete(e),_a){try{(n=a.content)==null||n.releasePointerCapture(e)}catch{}ya(i,`lostpointercapture`,e)}}function wa(e){return q._isString(e)?`"`+e+`"`:Object.prototype.toString.call(e)===`[object Number]`||q._isBoolean(e)?e:Object.prototype.toString.call(e)}function Ta(e){return e>255?255:e<0?0:Math.round(e)}function Y(){if(K.isUnminified)return function(e,t){return q._isNumber(e)||q.warn(wa(e)+` is a not valid value for "`+t+`" attribute. The value should be a number.`),e}}function Ea(e){if(K.isUnminified)return function(t,n){let r=q._isNumber(t),i=q._isArray(t)&&t.length==e;return!r&&!i&&q.warn(wa(t)+` is a not valid value for "`+n+`" attribute. The value should be a number or Array<number>(`+e+`)`),t}}function Da(){if(K.isUnminified)return function(e,t){return q._isNumber(e)||e===`auto`||q.warn(wa(e)+` is a not valid value for "`+t+`" attribute. The value should be a number or "auto".`),e}}function Oa(){if(K.isUnminified)return function(e,t){return q._isString(e)||q.warn(wa(e)+` is a not valid value for "`+t+`" attribute. The value should be a string.`),e}}function ka(){if(K.isUnminified)return function(e,t){let n=q._isString(e),r=Object.prototype.toString.call(e)===`[object CanvasGradient]`||e&&e.addColorStop;return n||r||q.warn(wa(e)+` is a not valid value for "`+t+`" attribute. The value should be a string or a native gradient.`),e}}function Aa(){if(K.isUnminified)return function(e,t){return e instanceof Ui||(q._isArray(e)?e.forEach(function(e){q._isNumber(e)||q.warn(`"`+t+`" attribute has non numeric element `+e+`. Make sure that all elements are numbers.`)}):q.warn(wa(e)+` is a not valid value for "`+t+`" attribute. The value should be a array of numbers.`)),e}}function ja(){if(K.isUnminified)return function(e,t){return e!==!0&&e!==!1&&q.warn(wa(e)+` is a not valid value for "`+t+`" attribute. The value should be a boolean.`),e}}function Ma(e){if(K.isUnminified)return function(t,n){return t==null||q.isObject(t)||q.warn(wa(t)+` is a not valid value for "`+n+`" attribute. The value should be an object with properties `+e),t}}var Na=`get`,Pa=`set`,X={addGetterSetter(e,t,n,r,i){X.addGetter(e,t,n),X.addSetter(e,t,r,i),X.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){let r=Na+q._capitalize(t),i=Array.isArray(n),a=function(){let e=this.attrs[t];return e===void 0?i?n.slice():n:e};a._def=n,e.prototype[r]=e.prototype[r]||a},addSetter(e,t,n,r){let i=Pa+q._capitalize(t);e.prototype[i]||X.overWriteSetter(e,t,n,r)},overWriteSetter(e,t,n,r){let i=Pa+q._capitalize(t);e.prototype[i]=function(e){return n&&e!=null&&(e=n.call(this,e,t)),this._setAttr(t,e),r&&r.call(this),this}},addComponentsGetterSetter(e,t,n,r,i){let a=n.length,o=q._capitalize,s=Na+o(t),c=Pa+o(t),l=n.map(e=>t+o(e)),u=l.map(e=>Na+o(e));e.prototype[s]=function(){let e={};for(let t=0;t<a;t++){let r=this[u[t]];e[n[t]]=r?r.call(this):this.attrs[l[t]]}return e};let d=Ma(n);e.prototype[c]=function(e){let a=this[s]();r&&(e=r.call(this,e,t)),d&&d.call(this,e,t);for(let n in e)e.hasOwnProperty(n)&&this._setAttr(t+o(n),e[n]);return e||n.forEach(e=>{this._setAttr(t+o(e),void 0)}),this._fireChangeEvent(t,a,e),i&&i.call(this),this},X.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){let n=q._capitalize(t),r=Pa+n,i=Na+n,a=function(){return arguments.length?(this[r](arguments[0]),this):this[i]()};e.prototype[t]=a},backCompat(e,t){q.each(t,function(t,n){let r=e.prototype[n],i=Na+q._capitalize(t),a=Pa+q._capitalize(t);function o(){return q.error(`"`+t+`" method is deprecated and will be removed soon. Use ""`+n+`" instead.`),r.apply(this,arguments)}e.prototype[t]=o,e.prototype[i]=o,e.prototype[a]=o})},afterSetFilter(){this._filterUpToDate=!1}};function Fa(e){let t=[],n=/(\w+)\(([^)]*)\)/g,r;for(;(r=n.exec(e))!==null;){let[,e,n]=r;if(![`blur`,`brightness`,`contrast`,`grayscale`,`sepia`,`invert`].includes(e)){q.warn(`CSS filter "${e}" is not supported in fallback mode. Consider using function filters for better compatibility.`);continue}let i=n.trim()===``?e===`blur`?0:1:parseFloat(n)/(n.includes(`%`)?100:1);t.push({name:e,value:i})}return function(e,n=1){for(let{name:r,value:i}of t){if([`grayscale`,`sepia`,`invert`].includes(r)){let t=Math.min(1,Math.max(0,i)),n=e.data;for(let e=0;e<n.length;e+=4){let i=n[e],a=n[e+1],o=n[e+2],s,c,l;r===`grayscale`?s=c=l=.2126*i+.7152*a+.0722*o:r===`sepia`?(s=.393*i+.769*a+.189*o,c=.349*i+.686*a+.168*o,l=.272*i+.534*a+.131*o):(s=255-i,c=255-a,l=255-o),n[e]=i+(s-i)*t,n[e+1]=a+(c-a)*t,n[e+2]=o+(l-o)*t}continue}let t=K.Filters?.[q._capitalize(r)];if(!t)continue;let a=Object.create(this);a.attrs={...this.attrs},r===`blur`&&(a.attrs.blurRadius=i*.5),r===`brightness`&&(a.attrs.brightness=i),r===`contrast`&&(a.attrs.contrast=100*(Math.sqrt(i)-1)),t.call(a,e,n)}}}var Ia=`absoluteOpacity`,La=`absoluteTransform`,Ra=`Change`,za=`children`,Ba=`konva`,Va=`listening`,Ha=[`mouseenter`,`mouseleave`,`pointerenter`,`pointerleave`,`touchenter`,`touchleave`],Ua=`set`,Wa=`Shape`,Ga=` `,Ka=`stage`,qa=`transform`,Ja=`Stage`,Ya=`visible`,Xa=[`xChange.konva`,`yChange.konva`,`scaleXChange.konva`,`scaleYChange.konva`,`skewXChange.konva`,`skewYChange.konva`,`rotationChange.konva`,`offsetXChange.konva`,`offsetYChange.konva`,`transformsEnabledChange.konva`].join(Ga),Za=1,Z=class e{constructor(e){this._id=Za++,this.eventListeners={},this.attrs={},this.index=0,this.parent=null,this._cache={},this._canvasCache=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(e),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(e){(e===qa||e===La)&&this._cache[e]?this._cache[e].dirty=!0:e?this._cache[e]=void 0:(this._cache={},this._attrsVersion!==void 0&&this._attrsVersion++)}_releaseCanvasCache(){let e=this._canvasCache;e&&(q.releaseCanvas(e.scene._canvas,e.filter._canvas,...e.hit?[e.hit._canvas]:[]),this._canvasCache=null)}_getCache(e,t){let n=this._cache[e];return(n===void 0||(e===qa||e===La)&&n.dirty===!0)&&(n=t.call(this),this._cache[e]=n),n}_getCanvasCache(){return this._canvasCache}_clearSelfAndDescendantCache(e){this._clearCache(e),(e===void 0||e===La)&&this.fire(`absoluteTransformChange`)}static _runAfterAbsTransformCascade(t){e._absTransformCascadeDepth>0?e._pendingAfterCascade.push(t):t()}clearCache(){return this._releaseCanvasCache(),this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){let t=e||{},n={};if(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0){let e=this._isUnderCache;this._isUnderCache=!0,n=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}),this._isUnderCache=e}let r=t.x===void 0?Math.floor(n.x):t.x,i=t.y===void 0?Math.floor(n.y):t.y,a=Math.ceil(t.width||n.x+n.width-r),o=Math.ceil(t.height||n.y+n.height-i),s=t.pixelRatio,c=t.offset||0,l=t.drawBorder||!1,u=t.hitCanvasPixelRatio||1;if(a<=0||o<=0||!isFinite(r+i+a+o))return q.error(`Can not cache the node. Its size is 0 or its bounds are not finite numbers (${r}, ${i}, ${a}x${o}). Caching is skipped.`),this;a+=c*2,o+=c*2,r-=c,i-=c;let d=new ma({pixelRatio:s,width:a,height:o}),f=new ma({pixelRatio:s,width:0,height:0,willReadFrequently:!0}),p=d.getContext();d.isCache=!0,this._releaseCanvasCache(),this._filterUpToDate=!1,t.imageSmoothingEnabled===!1&&(d.getContext()._context.imageSmoothingEnabled=!1,f.getContext()._context.imageSmoothingEnabled=!1),p.save(),p.translate(-r,-i),this._isUnderCache=!0,this._clearSelfAndDescendantCache(Ia);try{this.drawScene(d,this)}catch(e){throw q.releaseCanvas(d._canvas),e}finally{this._isUnderCache=!1,this._clearSelfAndDescendantCache(Ia),p.restore(),d._releaseIsolationCanvas()}return l&&(p.save(),p.beginPath(),p.rect(0,0,a,o),p.closePath(),p.setAttr(`strokeStyle`,`red`),p.setAttr(`lineWidth`,5),p.stroke(),p.restore()),this._canvasCache={scene:d,filter:f,hit:null,hitConfig:{pixelRatio:u,width:a,height:o},x:r,y:i},this._clearSelfAndDescendantCache(),this._requestDraw(),this}_getCachedHitCanvas(e){if(e===this)return null;let t=this._getCanvasCache();if(!t)return null;if(t.hit)return t.hit;let n=new ha(t.hitConfig);n.isCache=!0;let r=n.getContext();return r.save(),r.translate(-t.x,-t.y),this.drawHit(n,this),r.restore(),t.hit=n,n}isCached(){return!!this._canvasCache}getClientRect(e){throw Error(`abstract "getClientRect" method call`)}_getCachedSceneRect(e){let t=e._forDrawing&&!this._isUnderCache&&this._getCanvasCache();if(!t)return;let n={x:t.x,y:t.y,width:t.scene.width/t.scene.pixelRatio,height:t.scene.height/t.scene.pixelRatio};return e.skipTransform?n:this._transformedRect(n,e.relativeTo)}_transformedRect(e,t){return this.getAbsoluteTransform(t)._getTransformedRect(e)}_drawCachedSceneCanvas(e){e.save(),e._applyOpacity(this),e._applyGlobalCompositeOperation(this);let t=this._getCanvasCache();e.translate(t.x,t.y);let n=this._getCachedSceneCanvas(),r=n.pixelRatio;e.drawImage(n._canvas,0,0,n.width/r,n.height/r),e.restore()}_drawCachedHitCanvas(e,t){let n=this._getCanvasCache();e.save(),e.translate(n.x,n.y),e.drawImage(t._canvas,0,0,t.width/t.pixelRatio,t.height/t.pixelRatio),e.restore()}_getCachedSceneCanvas(){let e=this.filters(),t=this._getCanvasCache(),n=t.scene,r=t.filter,i=r.getContext(),a,o,s,c;if(!e||e.length===0)return n;if(this._filterUpToDate)return r;let l=!0;for(let t=0;t<e.length;t++)if(typeof e[t]!=`string`||!la()){l=!1;break}let u=n.pixelRatio;if(r.setSizeIfChanged(n._logicalWidth,n._logicalHeight),l){let t=e.join(` `).replace(/url\((?:[^()"']|"[^"]*"|'[^']*')*\)|"[^"]*"|'[^']*'|([-+]?(?:\d*\.)?\d+(?:e[-+]?\d+)?)(px|em|rem|ex|ch|cap|ic|lh|rlh|vw|vh|vmin|vmax|cm|mm|q|in|pt|pc)\b/gi,(e,t,n)=>t===void 0?e:`${Number(t)*u}${n}`);return i.clear(),i.save(),i.setAttr(`filter`,t),i.drawImage(n._canvas,0,0,n.getWidth()/u,n.getHeight()/u),i.restore(),this._filterUpToDate=!0,r}try{for(a=e.length,i.clear(),i.drawImage(n._canvas,0,0,n.getWidth()/u,n.getHeight()/u),o=i.getImageData(0,0,r.getWidth(),r.getHeight()),s=0;s<a;s++)c=e[s],typeof c==`string`&&(c=Fa(c)),c.call(this,o,u);i.putImageData(o,0,0)}catch(e){q.error(`Unable to apply filter. `+e.message+` This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.`)}return this._filterUpToDate=!0,r}on(...e){this._prepareListeners();let t=e[0],n=e[1];if(e[2],e.length===3)return this._delegate.apply(this,e);let r=t.split(Ga);for(let e=0;e<r.length;e++){let t=r[e].split(`.`),i=t[0],a=t[1]||``;this.eventListeners[i]||(this.eventListeners[i]=[]),this.eventListeners[i].push({name:a,handler:n})}return this}_prepareListeners(){this===this.constructor.prototype&&(this.hasOwnProperty(`eventListeners`)||(this.eventListeners={}),e.protoListenerMap=new WeakMap)}off(e,t){this._prepareListeners();let n=(e||``).split(Ga),r=n.length,i,a,o,s,c,l;if(!e)for(a in this.eventListeners)this._off(a);for(i=0;i<r;i++)if(o=n[i],s=o.split(`.`),c=s[0],l=s[1],c)this.eventListeners[c]&&this._off(c,l,t);else for(a in this.eventListeners)this._off(a,l,t);return this}dispatchEvent(e){let t={target:this,type:e.type,evt:e};return this.fire(e.type,t),this}addEventListener(e,t){return this.on(e,function(e){t.call(this,e.evt)}),this}removeEventListener(e){return this.off(e),this}_delegate(e,t,n){let r=this;return this.on(e,function(e){let i=e.target.findAncestors(t,!0,r);for(let t=0;t<i.length;t++)e=q.cloneObject(e),e.currentTarget=i[t],n.call(i[t],e)}),this}remove(){return this.isDragging()&&this.stopDrag(),J._dragElements.delete(this._id),J._dragElements.forEach((e,t)=>{this.isAncestorOf(e.node)&&J._dragElements.delete(t)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(La),this._clearSelfAndDescendantCache(Ia),this._clearSelfAndDescendantCache(Ka),this._clearSelfAndDescendantCache(Ya),this._clearSelfAndDescendantCache(Va)}_remove(){let e=this.getParent();e&&e.children&&(e.children.splice(this.index,1),e._setChildrenIndices(),this.parent=null),this._clearCaches()}destroy(){return this._fire(`destroy`,{target:this}),Sa(this),this.remove(),this.clearCache(),this}getAttr(e){let t=`get`+q._capitalize(e);return q._isFunction(this[t])?this[t]():this.attrs[e]}getAncestors(){let e=this.getParent(),t=[];for(;e;)t.push(e),e=e.getParent();return t}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges(()=>{let t,n;if(!e)return this;for(t in e)t!==za&&(n=Ua+q._capitalize(t),q._isFunction(this[n])?this[n](e[t]):this._setAttr(t,e[t]))}),this}isListening(){return this._getCache(Va,this._isListening)}_isListening(e){if(!this.listening())return!1;let t=this.getParent();return t&&t!==e&&this!==e?t._isListening(e):!0}isVisible(){return this._getCache(Ya,this._isVisible)}_isVisible(e){if(!this.visible())return!1;let t=this.getParent();return t&&t!==e&&this!==e?t._isVisible(e):!0}shouldDrawHit(e){return e?this._isVisible(e)&&this._isListening(e):this.isListening()&&this.isVisible()}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let e=this.getDepth(),t=this,n=0,r,i,a,o;function s(c){for(r=[],i=c.length,a=0;a<i;a++)o=c[a],n++,o.nodeType!==Wa&&(r=r.concat(o.children)),o._id===t._id&&(a=i);r.length>0&&r[0].getDepth()<=e&&s(r)}let c=this.getStage();return t.nodeType!==Ja&&c&&s(c.children),n}getDepth(){let e=0,t=this.parent;for(;t;)e++,t=t.parent;return e}_batchTransformChanges(e){if(this._batchingTransformChange){e();return}this._batchingTransformChange=!0;try{e()}finally{this._batchingTransformChange=!1,this._needClearTransformCache&&(this._needClearTransformCache=!1,this._clearCache(qa),this._clearSelfAndDescendantCache(La))}}setPosition(e){return this._batchTransformChanges(()=>{this.x(e.x),this.y(e.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){let e=this.getStage();if(!e)return null;let t=e.getPointerPosition();if(!t)return null;let n=this.getAbsoluteTransform().copy();return n.invert(),n.point(t)}getAbsolutePosition(e){let t=this.getAbsoluteTransform(e).getMatrix(),n=new Ti,r=this.offset();return n.m=t.slice(),n.translate(r.x,r.y),n.getTranslation()}setAbsolutePosition(e){let{x:t,y:n,...r}=this._clearTransform();this.attrs.x=t,this.attrs.y=n,this._clearCache(qa);let i=this._getAbsoluteTransform().copy(),a=i.isInvertible();i.invert(),i.translate(e.x,e.y);let{x:o,y:s}=i.getTranslation();return this._setTransform(r),a?this.setPosition({x:this.attrs.x+o,y:this.attrs.y+s}):q.warn(`Cannot set the absolute position: the absolute transform is not invertible (an ancestor has a zero scale).`),this._clearCache(qa),this._clearSelfAndDescendantCache(La),this}_setTransform(e){let t;for(t in e)this.attrs[t]=e[t]}_clearTransform(){let e={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,e}move(e){let t=e.x,n=e.y,r=this.x(),i=this.y();return t!==void 0&&(r+=t),n!==void 0&&(i+=n),this.setPosition({x:r,y:i}),this}rotate(e){return this.rotation(this.rotation()+e),this}moveToTop(){if(!this.parent)return q.warn(`Node has no parent. moveToTop function is ignored.`),!1;let e=this.index;return e<this.parent.children.length-1&&(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return q.warn(`Node has no parent. moveUp function is ignored.`),!1;let e=this.index;return e<this.parent.children.length-1&&(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return q.warn(`Node has no parent. moveDown function is ignored.`),!1;let e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return q.warn(`Node has no parent. moveToBottom function is ignored.`),!1;let e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(e){if(!this.parent)return q.warn(`Node has no parent. zIndex parameter is ignored.`),this;(e<0||e>=this.parent.children.length)&&q.warn(`Unexpected value `+e+` for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to `+(this.parent.children.length-1)+`.`);let t=this.index;return this.parent.children.splice(t,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(Ia,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let e=this.opacity(),t=this.getParent();return t&&!t._isUnderCache&&(e*=t.getAbsoluteOpacity()),e}moveTo(e){return this.getParent()!==e&&(this._remove(),e.add(this)),this}toObject(){let e=this.getAttrs(),t,n,r,i={attrs:{},className:this.getClassName()};for(t in e)n=e[t],n instanceof Ui&&(n=Array.from(n)),r=q.isObject(n)&&!q._isPlainObject(n)&&!q._isArray(n),!r&&(this[`get`+q._capitalize(t)]?._def!==n||t===`brightness`||t===`threshold`)&&(i.attrs[t]=t===`filters`&&q._isArray(n)?n.filter(e=>typeof e==`string`):q.isObject(n)?q._prepareToStringify(n):n);return i}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,t,n){let r=[];t&&this._isMatch(e)&&r.push(this);let i=this.parent;for(;i;){if(i===n)return r;i._isMatch(e)&&r.push(i),i=i.parent}return r}isAncestorOf(e){return!1}findAncestor(e,t,n){return this.findAncestors(e,t,n)[0]}_isMatch(e){if(!e)return!1;if(typeof e==`function`)return e(this);let t=e.replace(/ /g,``).split(`,`),n=t.length,r,i;for(r=0;r<n;r++)if(i=t[r],q.isValidSelector(i)||(q.warn(`Selector "`+i+`" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".`),q.warn(`If you have a custom shape with such className, please change it to start with upper letter like "Triangle".`),q.warn(`Konva is awesome, right?`)),i.charAt(0)===`#`){if(this.id()===i.slice(1))return!0}else if(i.charAt(0)===`.`){if(this.hasName(i.slice(1)))return!0}else if(this.className===i||this.nodeType===i)return!0;return!1}getLayer(){let e=this.getParent();return e?e.getLayer():null}getStage(){return this._getCache(Ka,this._getStage)}_getStage(){let e=this.getParent();return e?e.getStage():null}fire(e,t,n){return t||={},t.target=t.target||this,n?this._fireAndBubble(e,t):this._fire(e,t),this}getAbsoluteTransform(e){return e||this._hasCachedAncestor()?this._getAbsoluteTransform(e):this._getCache(La,this._getCachedAbsoluteTransform)}_hasCachedAncestor(){let e=this.parent;for(;e;){if(e.isCached())return!0;e=e.parent}return!1}_getAbsoluteTransform(e){let t=new Ti;return this===e?t:(this.parent&&this.parent!==e&&this.parent.getAbsoluteTransform(e).copyInto(t),this._multiplyOwnTransform(t))}_getCachedAbsoluteTransform(){let e=this._cache[La]||new Ti;return this.parent?this.parent.getAbsoluteTransform().copyInto(e):e.reset(),this._multiplyOwnTransform(e),e.dirty=!1,e}_multiplyOwnTransform(e){let t=this.transformsEnabled();if(t===`all`)e.multiply(this.getTransform());else if(t===`position`){let t=this.attrs.x||0,n=this.attrs.y||0,r=this.attrs.offsetX||0,i=this.attrs.offsetY||0;e.translate(t-r,n-i)}return e}getAbsoluteScale(e){let t=this;for(;t;)t._isUnderCache&&(e=t),t=t.getParent();let n=this.getAbsoluteTransform(e).decompose();return{x:n.scaleX,y:n.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(qa,this._getTransform)}_getTransform(){let e=this._cache[qa]||new Ti;e.reset();let t=this.x(),n=this.y(),r=K.getAngle(this.rotation()),i=this.attrs.scaleX??1,a=this.attrs.scaleY??1,o=this.attrs.skewX||0,s=this.attrs.skewY||0,c=this.attrs.offsetX||0,l=this.attrs.offsetY||0;return(t!==0||n!==0)&&e.translate(t,n),r!==0&&e.rotate(r),(o!==0||s!==0)&&e.skew(o,s),(i!==1||a!==1)&&e.scale(i,a),(c!==0||l!==0)&&e.translate(-1*c,-1*l),e.dirty=!1,e}clone(e){let t=q.cloneObject(this.attrs),n,r,i,a,o;for(n in e)t[n]=e[n];let s=new this.constructor(t);for(n in this.eventListeners)for(r=this.eventListeners[n],i=r.length,a=0;a<i;a++)o=r[a],o.name.indexOf(Ba)<0&&(s.eventListeners[n]||(s.eventListeners[n]=[]),s.eventListeners[n].push(o));return s}_toKonvaCanvas(e){e||={};let t=e.x===void 0||e.y===void 0||!e.width||!e.height?this.getClientRect():{x:0,y:0,width:0,height:0};isFinite(t.x+t.y+t.width+t.height)||q.error(`Cannot find the bounds of the node to export, its client rect is ${t.x}, ${t.y}, ${t.width}x${t.height}. Check its position, size and points.`);let n=this.getStage(),r=e.x===void 0?Math.floor(t.x):e.x,i=e.y===void 0?Math.floor(t.y):e.y,a=e.pixelRatio||1,o=new ma({width:e.width||Math.max(0,Math.ceil(t.x+t.width-r))||(n?n.width():0),height:e.height||Math.max(0,Math.ceil(t.y+t.height-i))||(n?n.height():0),pixelRatio:a}),s=o.getContext();return e.imageSmoothingEnabled===!1&&(s._context.imageSmoothingEnabled=!1),s.save(),(r||i)&&s.translate(-1*r,-1*i),this.drawScene(o),s.restore(),o._releaseIsolationCanvas(),o}toCanvas(e){return this._toKonvaCanvas(e)._canvas}toDataURL(e){e||={};let t=e.mimeType||null,n=e.quality??null,r=this._toKonvaCanvas(e).toDataURL(t,n);return e.callback&&e.callback(r),r}toImage(e){return new Promise((t,n)=>{try{let{callback:r,...i}=e||{};q._urlToImage(this.toDataURL(i),function(e){t(e),r?.(e)},n)}catch(e){n(e)}})}toBlob(e){return new Promise((t,n)=>{try{this.toCanvas(e).toBlob(r=>{var i;if(!r){n(Error(`Konva: toBlob() failed, the canvas was not encoded`));return}t(r),(i=e?.callback)==null||i.call(e,r)},e?.mimeType,e?.quality)}catch(e){n(e)}})}setSize(e){return this.width(e.width),this.height(e.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return this.attrs.dragDistance===void 0?this.parent?this.parent.getDragDistance():K.dragDistance:this.attrs.dragDistance}_off(e,t,n){let r=this.eventListeners[e],i,a,o;for(i=0;i<r.length;i++)if(a=r[i].name,o=r[i].handler,(a!==`konva`||t===`konva`)&&(!t||a===t)&&(!n||n===o)){if(r.splice(i,1),r.length===0){delete this.eventListeners[e];break}i--}}_fireChangeEvent(e,t,n){this._fire(e+Ra,{oldVal:t,newVal:n})}addName(e){if(!this.hasName(e)){let t=this.name(),n=t?t+` `+e:e;this.name(n)}return this}hasName(e){if(!e)return!1;let t=this.name();return t?(t||``).split(/\s/g).indexOf(e)!==-1:!1}removeName(e){let t=(this.name()||``).split(/\s/g),n=t.indexOf(e);return n!==-1&&(t.splice(n,1),this.name(t.join(` `))),this}setAttr(e,t){let n=this[Ua+q._capitalize(e)];return q._isFunction(n)?n.call(this,t):this._setAttr(e,t),this}_addSubtreeObserver(t){(this._subtreeObservers??=new Set).add(t),e._subtreeObserverCount++}_removeSubtreeObserver(t){this._subtreeObservers?.delete(t)&&e._subtreeObserverCount--}_notifySubtreeChange(){if(e._subtreeObserverCount)for(let e=this;e;e=e.parent){let t=e._subtreeObservers;if(t)for(let n of t)n._onSubtreeChange(e)}}_requestDraw(){var e;(e=this.parent)==null||e._notifySubtreeChange(),K.autoDrawEnabled&&(this.getLayer()||this.getStage())?.batchDraw()}_setAttr(e,t){let n=this.attrs[e];(n!==t||q.isObject(t))&&(t==null?delete this.attrs[e]:this.attrs[e]=t,this._attrsVersion!==void 0&&this._attrsVersion++,this._shouldFireChangeEvents&&this._fireChangeEvent(e,n,t),this._requestDraw())}_fireAndBubble(e,t,n){t&&this.nodeType===Wa&&(t.target=this);let r=Ha.indexOf(e)!==-1;if(!(r&&(n&&(this===n||this.isAncestorOf&&this.isAncestorOf(n))||this.nodeType===`Stage`&&!n))){this._fire(e,t);let i=r&&n&&n.isAncestorOf&&n.isAncestorOf(this)&&!n.isAncestorOf(this.parent);(t&&!t.cancelBubble||!t)&&this.parent&&this.parent.isListening()&&!i&&(n&&n.parent?this._fireAndBubble.call(this.parent,e,t,n):this._fireAndBubble.call(this.parent,e,t))}}_getProtoListeners(t){let n=Object.getPrototypeOf(this),r=e.protoListenerMap.get(n);r||(r={},e.protoListenerMap.set(n,r));let i=r[t];if(i===void 0){i=[];let e=new Set,n=Object.getPrototypeOf(this);for(;n;){let r=n.eventListeners?.[t]??[];for(let t=0;t<r.length;t++){let n=r[t];e.has(n)||(e.add(n),i.push(n))}n=Object.getPrototypeOf(n)}r[t]=i}return i}_fire(e,t){t||={},t.currentTarget=this,t.type=e;let n=this._getProtoListeners(e);if(n)for(let e=0;e<n.length;e++)n[e].handler.call(this,t);let r=this.eventListeners[e];if(r){let n=r.slice(),i=n.length;for(let e=0;e<n.length;e++)n[e].handler.call(this,t);let a=this.eventListeners[e];if(a)for(let e=i;e<a.length;e++)a[e].handler.call(this,t)}}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(e){let t=e?e.pointerId:void 0,n=this.getStage(),r=this.getAbsolutePosition();if(!n)return;let i=n._getPointerById(t)||n._changedPointerPositions[0]||r,a=e?.evt?.type?q._getEventType(e.evt.type):n._pointerEventType,o=a!==`pointer`;J._dragElements.set(this._id,{node:this,startPointerPos:i,offset:{x:i.x-r.x,y:i.y-r.y},dragStatus:`ready`,pointerId:o?t??(`id`in i?i.id:void 0):void 0,pointerEventType:o?a:void 0,startEvent:e})}startDrag(e,t=!0){var n;J._dragElements.has(this._id)||this._createDragElement(e);let r=J._dragElements.get(this._id);r&&(r.dragStatus=`dragging`,(n=this.getStage())==null||n._cancelClick(r.pointerId,r.pointerEventType),this.fire(`dragstart`,{type:`dragstart`,target:this,evt:r.startEvent&&r.startEvent.evt||e&&e.evt},t))}_setDragPosition(e,t){let n=this.getStage()._getPointerById(t.pointerId);if(!n)return;let r={x:n.x-t.offset.x,y:n.y-t.offset.y},i=this.dragBoundFunc();if(i!==void 0){let t=i.call(this,r,e);if(!t)q.warn(`dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.`);else if(!q._isNumber(t.x)||!q._isNumber(t.y)){q.warn(`dragBoundFunc returned a position with a non-finite x or y (${t.x}, ${t.y}). The node was not moved.`);return}else r=t}let a=t.lastPos;(!a||a.x!==r.x||a.y!==r.y)&&(this.setAbsolutePosition(r),this._requestDraw()),t.lastPos=r}stopDrag(e){let t=J._dragElements.get(this._id);t&&(t.dragStatus=`stopped`,J._endDragBefore(e,void 0,t),J._endDragAfter(e,t))}setDraggable(e){this._setAttr(`draggable`,e),this._dragChange()}isDragging(){let e=J._dragElements.get(this._id);return e?e.dragStatus===`dragging`:!1}_listenDrag(){this._dragCleanup(),this.on(`mousedown.konva touchstart.konva`,function(e){if(!(e.evt.button===void 0||K.dragButtons.indexOf(e.evt.button)>=0)||J._dragElements.has(this._id))return;let t=!1;J._dragElements.forEach(e=>{this.isAncestorOf(e.node)&&(t=!0)}),t||this._createDragElement(e)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;let e=J._dragElements.get(this._id),t=e&&e.dragStatus===`dragging`,n=e&&e.dragStatus===`ready`;t?this.stopDrag():n&&J._dragElements.delete(this._id)}}_dragCleanup(){this.off(`mousedown.konva`),this.off(`touchstart.konva`)}isClientRectOnScreen(e={x:0,y:0}){let t=this.getStage();if(!t)return!1;let n={x:-e.x,y:-e.y,width:t.width()+2*e.x,height:t.height()+2*e.y};return q.haveIntersection(n,this.getClientRect())}static create(e,t){return q._isString(e)&&(e=JSON.parse(e)),this._createNode(e,t)}static _createNode(t,n){let r=e.prototype.getClassName.call(t),i=t.children,a,o,s;if(n&&(t.attrs.container=n),!K[r]){let e=i?`Group`:`Shape`;q.warn(`Can not find a node with class name "`+r+`". Fallback to "${e}".`),r=e}let c=K[r];if(a=new c(t.attrs),i)for(o=i.length,s=0;s<o;s++)a.add(e._createNode(i[s]));return a}};Z._subtreeObserverCount=0,Z._absTransformCascadeDepth=0,Z._pendingAfterCascade=[],Z.protoListenerMap=new WeakMap,Z.prototype.nodeType=`Node`,Z.prototype._attrsAffectingSize=[],Z.prototype.on(Xa,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(qa),this._clearSelfAndDescendantCache(La)}),Z.prototype.on(`visibleChange.konva`,function(){this._clearSelfAndDescendantCache(Ya)}),Z.prototype.on(`listeningChange.konva`,function(){this._clearSelfAndDescendantCache(Va);for(let e=this.getParent();e;e=e.getParent()){let t=e._getCanvasCache();t?.hit&&(q.releaseCanvas(t.hit._canvas),t.hit=null)}}),Z.prototype.on(`opacityChange.konva`,function(){this._clearSelfAndDescendantCache(Ia)});var Qa=X.addGetterSetter;Qa(Z,`zIndex`),Qa(Z,`absolutePosition`),Qa(Z,`position`),Qa(Z,`x`,0,Y()),Qa(Z,`y`,0,Y()),Qa(Z,`globalCompositeOperation`,`source-over`,Oa()),Qa(Z,`opacity`,1,Y()),Qa(Z,`name`,``,Oa()),Qa(Z,`id`,``,Oa()),Qa(Z,`rotation`,0,Y()),X.addComponentsGetterSetter(Z,`scale`,[`x`,`y`]),Qa(Z,`scaleX`,1,Y()),Qa(Z,`scaleY`,1,Y()),X.addComponentsGetterSetter(Z,`skew`,[`x`,`y`]),Qa(Z,`skewX`,0,Y()),Qa(Z,`skewY`,0,Y()),X.addComponentsGetterSetter(Z,`offset`,[`x`,`y`]),Qa(Z,`offsetX`,0,Y()),Qa(Z,`offsetY`,0,Y()),Qa(Z,`dragDistance`,void 0,Y()),Qa(Z,`width`,0,Y()),Qa(Z,`height`,0,Y()),Qa(Z,`listening`,!0,ja()),Qa(Z,`preventDefault`,!0,ja()),Qa(Z,`filters`,void 0,function(e){return this._filterUpToDate=!1,e}),Qa(Z,`visible`,!0,ja()),Qa(Z,`transformsEnabled`,`all`,Oa()),Qa(Z,`size`),Qa(Z,`dragBoundFunc`),Qa(Z,`draggable`,!1,ja()),X.backCompat(Z,{rotateDeg:`rotate`,setRotationDeg:`setRotation`,getRotationDeg:`getRotation`});var $a=class extends Z{constructor(){super(...arguments),this.children=[]}getChildren(e){let t=this.children||[];return e?t.filter(e):t.slice()}hasChildren(){return this.children.length>0}removeChildren(){return this.children.forEach(e=>{e.parent=null,e.index=0,e.remove()}),this.children=[],this._notifySubtreeChange(),this._requestDraw(),this}destroyChildren(){return this.children.forEach(e=>{e.parent=null,e.index=0,e.destroy()}),this.children=[],this._notifySubtreeChange(),this._requestDraw(),this}add(...e){if(e.length===0)return this;if(e.length>1){for(let t=0;t<e.length;t++)this.add(e[t]);return this}let t=e[0];return t.getParent()?(t.moveTo(this),this):(this._validateAdd(t),t.index=this.children.length,t.parent=this,t._clearCaches(),this.children.push(t),this._fire(`add`,{child:t}),this._notifySubtreeChange(),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(e){return this._generalFind(e,!1)}findOne(e){let t=this._generalFind(e,!0);return t.length>0?t[0]:void 0}_generalFind(e,t){let n=[];return this._descendants(r=>{let i=r._isMatch(e);return i&&n.push(r),!!(i&&t)}),n}_descendants(e){let t=!1;for(let n of this.children)if(t=e(n),t||n.hasChildren()&&(t=n._descendants(e),t))return!0;return!1}toObject(){let e=Z.prototype.toObject.call(this);return e.children=[],this.children.forEach(t=>{e.children.push(t.toObject())}),e}isAncestorOf(e){let t=e.getParent();for(;t;){if(t._id===this._id)return!0;t=t.getParent()}return!1}clone(e){let t=Z.prototype.clone.call(this,e);return this.children.forEach(function(e){t.add(e.clone())}),t}getAllIntersections(e){let t=[];return this.find(`Shape`).forEach(n=>{n.isVisible()&&n.intersects(e)&&t.push(n)}),t}_clearSelfAndDescendantCache(e){var t;let n=e===void 0||e===`absoluteTransform`;n&&Z._absTransformCascadeDepth++;try{if(super._clearSelfAndDescendantCache(e),e===`absoluteTransform`&&this.isCached())return;(t=this.children)==null||t.forEach(function(t){t._clearSelfAndDescendantCache(e)})}finally{if(n&&--Z._absTransformCascadeDepth===0){let e=Z._pendingAfterCascade;if(e.length){Z._pendingAfterCascade=[];for(let t=0;t<e.length;t++)e[t]()}}}}_setChildrenIndices(){var e;(e=this.children)==null||e.forEach(function(e,t){e.index=t}),this._notifySubtreeChange(),this._requestDraw()}drawScene(e,t){let n=this.getLayer(),r=e||n&&n.getCanvas(),i=r&&r.getContext(),a=this._getCanvasCache(),o=a&&a.scene,s=t===this;if(!(t?this._isVisible(t):this.isVisible())&&!s)return this;if(o){i.save();let e=this.getAbsoluteTransform(t).getMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedSceneCanvas(i),i.restore()}else this._drawChildren(`drawScene`,r,t);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;let n=this.getLayer(),r=e||n&&n.hitCanvas,i=r&&r.getContext(),a=this._getCachedHitCanvas(t);if(a){i.save();let e=this.getAbsoluteTransform(t).getMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedHitCanvas(i,a),i.restore()}else this._drawChildren(`drawHit`,r,t);return this}_drawChildren(e,t,n){let r=t&&t.getContext(),i=this.clipWidth(),a=this.clipHeight(),o=this.clipFunc(),s=typeof i==`number`&&typeof a==`number`||o,c=n===this;if(s){r.save();let e=this.getAbsoluteTransform(n),t=e.getMatrix();r.transform(t[0],t[1],t[2],t[3],t[4],t[5]),r.beginPath();let s;if(o)s=o.call(this,r,this);else{let e=this.clipX(),t=this.clipY();r.rect(e||0,t||0,i,a)}r.clip.apply(r,s),t=e.copy().invert().getMatrix(),r.transform(t[0],t[1],t[2],t[3],t[4],t[5])}let l=!c&&this.globalCompositeOperation()!==`source-over`&&e===`drawScene`;l&&(r.save(),r._applyGlobalCompositeOperation(this));try{this._drawChildNodes(e,t,n)}finally{l&&r.restore(),s&&r.restore()}}_drawChildNodes(e,t,n){var r;(r=this.children)==null||r.forEach(function(r){r[e](t,n)})}getClientRect(e={}){var t;let n=this._getCachedSceneRect(e);if(n)return n;let r=e.skipTransform,i=e.relativeTo,[a,o,s,c]=this.getAbsoluteTransform().getMatrix(),l=!r&&(e._forDrawing||a*c-o*s===0),u,d,f,p,m={x:1/0,y:1/0,width:0,height:0},h=this;return(t=this.children)==null||t.forEach(function(t){if(!t.visible())return;let n=t.getClientRect({relativeTo:l?i:h,_forDrawing:e._forDrawing,skipShadow:e.skipShadow,skipStroke:e.skipStroke});n.width===0&&n.height===0||!isFinite(n.x+n.y+n.width+n.height)||(u===void 0?(u=n.x,d=n.y,f=n.x+n.width,p=n.y+n.height):(u=Math.min(u,n.x),d=Math.min(d,n.y),f=Math.max(f,n.x+n.width),p=Math.max(p,n.y+n.height)))}),m=u===void 0?{x:0,y:0,width:0,height:0}:{x:u,y:d,width:f-u,height:p-d},!r&&!l?this._transformedRect(m,i):m}};X.addComponentsGetterSetter($a,`clip`,[`x`,`y`,`width`,`height`]),X.addGetterSetter($a,`clipX`,void 0,Y()),X.addGetterSetter($a,`clipY`,void 0,Y()),X.addGetterSetter($a,`clipWidth`,void 0,Y()),X.addGetterSetter($a,`clipHeight`,void 0,Y()),X.addGetterSetter($a,`clipFunc`);var eo=`Stage`,to=`string`,no=`px`,ro=`mouseout`,io=`mouseleave`,ao=`mouseover`,oo=`mouseenter`,so=`mousemove`,co=`mousedown`,lo=`mouseup`,uo=`pointermove`,fo=`pointerdown`,po=`pointerup`,mo=`pointercancel`,ho=`lostpointercapture`,go=`pointerout`,_o=`pointerleave`,vo=`pointerover`,yo=`pointerenter`,bo=`contextmenu`,xo=`touchstart`,So=`touchend`,Co=`touchmove`,wo=`touchcancel`,To=`wheel`,Eo=5,Do=[[oo,`_pointerenter`],[co,`_pointerdown`],[so,`_pointermove`],[lo,`_pointerup`],[io,`_pointerleave`],[xo,`_pointerdown`],[Co,`_pointermove`],[So,`_pointerup`],[wo,`_pointercancel`],[ao,`_pointerover`],[To,`_wheel`],[bo,`_contextmenu`],[fo,`_pointerdown`],[uo,`_pointermove`],[po,`_pointerup`],[mo,`_pointercancel`],[_o,`_pointerleave`],[ho,`_lostpointercapture`]],Oo={mouse:{[go]:ro,[_o]:io,[vo]:ao,[yo]:oo,[uo]:so,[fo]:co,[po]:lo,[mo]:`mousecancel`,pointerclick:`click`,pointerdblclick:`dblclick`},touch:{[go]:`touchout`,[_o]:`touchleave`,[vo]:`touchover`,[yo]:`touchenter`,[uo]:Co,[fo]:xo,[po]:So,[mo]:wo,pointerclick:`tap`,pointerdblclick:`dbltap`},pointer:{[go]:go,[_o]:_o,[vo]:vo,[yo]:yo,[uo]:uo,[fo]:fo,[po]:po,[mo]:mo,pointerclick:`pointerclick`,pointerdblclick:`pointerdblclick`}},ko=e=>{let t=q._getEventType(e);if(t===`pointer`)return K.pointerEventsEnabled&&Oo.pointer;if(t===`touch`)return Oo.touch;if(t===`mouse`)return Oo.mouse};function Ao(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&&q.warn(`Stage does not support clipping. Please use clip for Layers or Groups.`),e}var jo=`Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);`,Mo=[],No=new WeakSet,Po=e=>{e&&!No.has(e)&&(No.add(e),J._listenToWindow(e),e.document.addEventListener(`visibilitychange`,()=>{Mo.forEach(e=>{e.batchDraw()})}))},Fo=class extends $a{constructor(e){super(Ao(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._pointerStates=new Map,this._lastClicks={},this._buildDOM(),this._bindContentEvents(),Mo.push(this),this.on(`widthChange.konva heightChange.konva`,this._resizeDOM),this.on(`visibleChange.konva`,this._checkVisibility),this.on(`clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva`,()=>{Ao(this.attrs)}),this._checkVisibility()}_validateAdd(e){let t=e.getType()===`Layer`,n=e.getType()===`FastLayer`;t||n||q.throw(`You may only add layers to the stage.`)}_checkVisibility(){if(!this.content)return;let e=this.visible()?``:`none`;this.content.style.display=e}_getOwnerWindow(){return(this.content||this.container())?.ownerDocument?.defaultView||(K.isBrowser?window:null)}setContainer(e){if(typeof e===to){let t;if(e.charAt(0)===`.`){let t=e.slice(1);e=document.getElementsByClassName(t)[0]}else t=e.charAt(0)===`#`?e.slice(1):e,e=document.getElementById(t);if(!e)throw`Can not find container in document with id `+t}return this._setAttr(`container`,e),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),e.appendChild(this.content),Po(this._getOwnerWindow())),this}shouldDrawHit(){return!0}clear(){let e=this.children,t=e.length;for(let n=0;n<t;n++)e[n].clear();return this}clone(e){return e||={},e.container=typeof document<`u`&&document.createElement(`div`),$a.prototype.clone.call(this,e)}destroy(){var e;super.destroy(),this._pointerStates.clear(),this._lastClicks={};let t=this.content;(e=t?.parentNode)==null||e.removeChild(t);let n=Mo.indexOf(this);return n>-1&&Mo.splice(n,1),q.releaseCanvas(this.bufferHitCanvas._canvas),this}getPointerPosition(){let e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(q.warn(jo),null)}_getPointerById(e){return this._pointerPositions.find(t=>t.id===e)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(e){e={...e},e.x=e.x||0,e.y=e.y||0,e.width=e.width||this.width(),e.height=e.height||this.height();let t=new ma({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),n=t.getContext()._context,r=this.children;return(e.x||e.y)&&n.translate(-1*e.x,-1*e.y),r.forEach(function(t){if(!t.isVisible())return;let r=t._toKonvaCanvas(e);n.drawImage(r._canvas,e.x,e.y,r.getWidth()/r.getPixelRatio(),r.getHeight()/r.getPixelRatio()),q.releaseCanvas(r._canvas)}),t}getIntersection(e){if(!e)return null;let t=this.children,n=t.length-1;for(let r=n;r>=0;r--){let n=t[r].getIntersection(e);if(n)return n}return null}_resizeDOM(){let e=this.width(),t=this.height();this.content&&(this.content.style.width=e+no,this.content.style.height=t+no),this.children.forEach(n=>{n._setSize({width:e,height:t}),n.draw()})}add(e,...t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}super.add(e);let n=this.children.length;return n>Eo&&q.warn(`The stage has `+n+` layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group.`),e._setSize({width:this.width(),height:this.height()}),e.draw(),K.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return ba(e,this)}setPointerCapture(e){xa(e,this)}releaseCapture(e){Ca(e,this)}getLayers(){return this.getChildren()}_bindContentEvents(){K.isBrowser&&Do.forEach(([e,t])=>{this.content.addEventListener(e,e=>{this._batchEvents(()=>this[t](e))},{passive:!1})})}_batchEvents(e){q._batchEvents(this.eventBatchFunc(),e)}_pointerenter(e){this.setPointersPositions(e);let t=ko(e.type);t&&this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);let t=ko(e.type);t&&this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_pointerEventsEnabled(){if(K.hitOnDragEnabled)return!0;for(let{node:e,dragStatus:t}of J._dragElements.values())if(t===`dragging`&&e.getStage()===this)return!1;return!this.getLayers().some(e=>K.Transformer?._isLayerTransforming(e))}_cancelClick(e,t){let n=t?[t]:[`mouse`,`touch`,`pointer`];for(let t of n){let n=this._pointerStates.get(`${t}:${e}`);n&&(n.clickStartShape=void 0,n.relatedPointer&&(n.relatedPointer.clickStartShape=void 0))}}_pointerleave(e){let t=ko(e.type),n=q._getEventType(e.type);if(!t)return;this.setPointersPositions(e);let r=this._changedPointerPositions[0]?.id,i=`${n}:${r}`,a=this._pointerStates.get(i),o=(a?.targetShape)?.getStage()===this?a.targetShape:void 0,s=this._pointerEventsEnabled()||e.pointerType===`touch`&&!a?.downPosition;s&&(a?.clickStartShape===void 0?this._pointerStates.delete(i):a.targetShape=void 0),o&&s?(o._fireAndBubble(t.pointerout,{evt:e,pointerId:r}),o._fireAndBubble(t.pointerleave,{evt:e,pointerId:r}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this})):s&&(this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(t.pointerout,{evt:e,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[],this._changedPointerPositions=[],this._pointerEventType=void 0}_pointerdown(e){let t=ko(e.type),n=q._getEventType(e.type);if(!t)return;this.setPointersPositions(e);let r=!1;this._changedPointerPositions.forEach(i=>{let a=this.getIntersection(i),o=`${n}:${i.id}`,s={targetShape:this._pointerStates.get(o)?.targetShape,clickStartShape:a&&a.isListening()?a:null,lastClick:this._lastClicks[n],downPosition:i,pointerType:e.pointerType};if(this._pointerStates.delete(o),n!==`pointer`){for(let[e,t]of[...this._pointerStates].reverse())if(!(!e.startsWith(`pointer:`)||!t.downPosition||n===`touch`&&t.relatedPointer)&&(n===`mouse`?t.pointerType!==`touch`:t.pointerType===`touch`&&t.downPosition.x===i.x&&t.downPosition.y===i.y)){s.relatedPointer=t,t.relatedPointer=s,t.clickStartShape===void 0&&(s.clickStartShape=void 0);break}}this._pointerStates.set(o,s);for(let e of J._dragElements.values())e.dragStatus===`dragging`&&(e.pointerId===void 0||e.pointerEventType===n&&e.pointerId===i.id||e.pointerEventType===`mouse`&&n===`pointer`&&s.pointerType!==`touch`)&&e.node.getStage()===this&&(e.pointerId===void 0&&n!==`pointer`&&(e.pointerId=i.id,e.pointerEventType=n),this._cancelClick(i.id,n));if(!a||!a.isListening())return;K.capturePointerEventsEnabled&&a.setPointerCapture(i.id),a._fireAndBubble(t.pointerdown,{evt:e,pointerId:i.id}),r=!0;let c=e.type.indexOf(`touch`)>=0;a.preventDefault()&&e.cancelable&&c&&e.preventDefault()}),r||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointermove(e){let t=ko(e.type),n=q._getEventType(e.type);if(!t)return;let r=e.type.indexOf(`touch`)>=0||e.pointerType===`touch`;if(e.cancelable&&r){for(let{node:t,dragStatus:n}of J._dragElements.values())if(n===`dragging`&&t.getStage()===this&&t.preventDefault()){e.preventDefault();break}}if(this.setPointersPositions(e),!this._pointerEventsEnabled())return;let i={},a=!1;this._changedPointerPositions.forEach(r=>{let o=`${n}:${r.id}`,s=this._pointerStates.get(o);s||(s={},this._pointerStates.set(o,s));let c=va(r.id)||this.getIntersection(r),l=s.targetShape===c||s.targetShape?.getStage()===this?s.targetShape:void 0,u=r.id,d={evt:e,pointerId:u},f=l!==c;s.targetShape=c&&c.isListening()?c:void 0,f&&l&&(l._fireAndBubble(t.pointerout,{...d},c),l._fireAndBubble(t.pointerleave,{...d},c)),c&&c.isListening()?(a=!0,f&&(c._fireAndBubble(t.pointerover,{...d},l),c._fireAndBubble(t.pointerenter,{...d},l)),i[c._id]||(i[c._id]=!0,c._fireAndBubble(t.pointermove,{...d}))):l&&this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:u})}),a||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){let t=ko(e.type),n=q._getEventType(e.type);if(!t)return;this.setPointersPositions(e);let r={},i=!1;this._changedPointerPositions.forEach(a=>{let o=`${n}:${a.id}`,s=this._pointerStates.get(o),c=s?.clickStartShape!==void 0,l=s?.clickStartShape;s?.targetShape&&n!==`touch`?this._pointerStates.set(o,{targetShape:s.targetShape}):this._pointerStates.delete(o);let u=va(a.id)||this.getIntersection(a),d=u&&r[u._id];u&&(u.releaseCapture(a.id),r[u._id]=!0);let f=a.id,p={evt:e,pointerId:f},m=u&&u.isListening()?u:null,h=this._lastClicks[n],g=c&&(!m||l===m),_=g&&h&&s?.lastClick===h&&h.shape===m&&Date.now()-h.time<K.dblClickWindow;g&&(this._lastClicks[n]=_?void 0:{shape:m,time:Date.now()}),u&&u.isListening()?(i=!0,d||u._fireAndBubble(t.pointerup,{...p}),c&&l===u&&(u._fireAndBubble(t.pointerclick,{...p}),_&&u._fireAndBubble(t.pointerdblclick,{...p}))):(i||=(this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),!0),c&&this._fire(t.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:f}),_&&this._fire(t.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:f})),n===`touch`&&(s?.targetShape)?.getStage()===this&&(s.targetShape._fireAndBubble(t.pointerout,{...p}),s.targetShape._fireAndBubble(t.pointerleave,{...p}))}),i||this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),e.cancelable&&n!==`touch`&&n!==`pointer`&&e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);let t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(bo,{evt:e}):this._fire(bo,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);let t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(To,{evt:e}):this._fire(To,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);let t=ko(e.type);this._changedPointerPositions.forEach(n=>{let r=q._getEventType(e.type),i=`${r}:${n.id}`;this._cancelClick(n.id,r);let a=this._pointerStates.get(i)?.targetShape;a&&r!==`touch`?this._pointerStates.set(i,{targetShape:a}):this._pointerStates.delete(i);let o=va(n.id)||this.getIntersection(n),s={evt:e,pointerId:n.id};o?(t&&o._fireAndBubble(t.pointercancel,{...s}),o._fireAndBubble(po,{...s})):t&&this._fire(t.pointercancel,{...s,target:this,currentTarget:this}),Ca(n.id),t&&r===`touch`&&a?.getStage()===this&&(a._fireAndBubble(t.pointerout,{...s}),a._fireAndBubble(t.pointerleave,{...s}))})}_lostpointercapture(e){va(e.pointerId,this)&&Ca(e.pointerId)}setPointersPositions(e){let t=this._getContentPosition(),n=null,r=null;e||=window.event,e.touches===void 0?(this._pointerEventType=e.pointerId===void 0?`mouse`:`pointer`,n=(e.clientX-t.left)/t.scaleX,r=(e.clientY-t.top)/t.scaleY,this.pointerPos={x:n,y:r},this._pointerPositions=[{x:n,y:r,id:q._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:r,id:q._getFirstPointerId(e)}]):(this._pointerEventType=`touch`,this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(e.touches,e=>{this._pointerPositions.push({id:e.identifier,x:(e.clientX-t.left)/t.scaleX,y:(e.clientY-t.top)/t.scaleY})}),Array.prototype.forEach.call(e.changedTouches||e.touches,e=>{this._changedPointerPositions.push({id:e.identifier,x:(e.clientX-t.left)/t.scaleX,y:(e.clientY-t.top)/t.scaleY})}))}_setPointerPosition(e){q.warn(`Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.`),this.setPointersPositions(e)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};let e=this.content.getBoundingClientRect();return{top:e.top,left:e.left,scaleX:e.width/this.content.clientWidth||1,scaleY:e.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferHitCanvas=new ha({pixelRatio:1,width:0,height:0}),!K.isBrowser)return;let e=this.container();if(!e)throw`Stage has no container. A container is required.`;e.innerHTML=``,this.content=e.ownerDocument.createElement(`div`),this.content.style.position=`relative`,this.content.style.userSelect=`none`,this.content.className=`konvajs-content`,this.content.setAttribute(`role`,`presentation`),e.appendChild(this.content),Po(this._getOwnerWindow()),this._resizeDOM()}cache(){return q.warn(`Cache function is not allowed for stage. You may use cache only for layers, groups and shapes.`),this}clearCache(){return this}batchDraw(){var e;return(e=this.children)==null||e.forEach(function(e){e.batchDraw()}),this}};Fo.prototype.nodeType=eo,Si(Fo),X.addGetterSetter(Fo,`container`),X.addGetterSetter(Fo,`eventBatchFunc`);var Io=`hasShadow`,Lo=`hasFill`,Ro=`hasStroke`,zo=`shadowRGBA`,Bo=`patternImage`,Vo=`linearGradient`,Ho=`radialGradient`,Uo;function Wo(){return Uo||(Uo=q.createCanvasElement().getContext(`2d`),Uo)}var Go={};function Ko(e){let t=this.attrs.fillRule;t?e.fill(t):e.fill()}function qo(e){e.stroke()}function Jo(){this._clearCache(Io)}function Yo(){this._clearCache(Lo)}function Xo(){this._clearCache(Ro)}function Zo(){this._clearCache(zo)}function Qo(){this._clearCache(Bo)}function $o(){this._clearCache(Vo)}function es(){this._clearCache(Ho)}var Q=class e extends Z{constructor(e){super(e);let t,n=0;for(;t=q.getHitColor(),!t||t in Go;)if(n++,n>=1e4){q.warn(`Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it.`),t=q.getRandomColor();break}this.colorKey=t,Go[t]=this}getContext(){return q.warn(`shape.getContext() method is deprecated. Please do not use it.`),this.getLayer().getContext()}getCanvas(){return q.warn(`shape.getCanvas() method is deprecated. Please do not use it.`),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(Io,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(Bo,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){let e=Wo().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||`repeat`);if(e&&e.setTransform){let t=new Ti;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(K.getAngle(this.fillPatternRotation())),t.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),t.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());let n=t.getMatrix(),r=typeof DOMMatrix>`u`?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);e.setTransform(r)}return e}}_getLinearGradient(){return this._getCache(Vo,this.__getLinearGradient)}__getLinearGradient(){let e=this.fillLinearGradientColorStops();if(e){let t=Wo(),n=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),i=t.createLinearGradient(n.x,n.y,r.x,r.y);for(let t=0;t<e.length;t+=2)i.addColorStop(e[t],e[t+1]);return i}}_getRadialGradient(){return this._getCache(Ho,this.__getRadialGradient)}__getRadialGradient(){let e=this.fillRadialGradientColorStops();if(e){let t=Wo(),n=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),i=t.createRadialGradient(n.x,n.y,this.fillRadialGradientStartRadius(),r.x,r.y,this.fillRadialGradientEndRadius());for(let t=0;t<e.length;t+=2)i.addColorStop(e[t],e[t+1]);return i}}getShadowRGBA(){return this._getCache(zo,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;let e=q.colorToRGBA(this.shadowColor());if(e)return`rgba(`+e.r+`,`+e.g+`,`+e.b+`,`+e.a*(this.shadowOpacity()||1)+`)`}hasFill(){return this._getCache(Lo,this._hasFill)}_hasFill(){return this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops())}hasStroke(){return this._getCache(Ro,this._hasStroke)}_hasStroke(){return this.strokeEnabled()&&!!(this.strokeWidth()&&(this.stroke()||this.strokeLinearGradientColorStops()))}hasHitStroke(){let e=this.hitStrokeWidth();return e===`auto`?this.hasStroke():this.strokeEnabled()&&!!e}intersects(e){let t=this.getStage();if(!t)return!1;let n=t.bufferHitCanvas;return n.setSizeIfChanged(t.width(),t.height()),n.getContext().clear(),this.drawHit(n),n.context.getImageData(Math.floor(e.x),Math.floor(e.y),1,1).data[3]>0}destroy(){return Z.prototype.destroy.call(this),delete Go[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){if(!(this.attrs.perfectDrawEnabled??!0))return!1;let n=e||this.hasFill(),r=this.hasStroke(),i=!this._isUnderCache&&t!==1;if(n&&r&&i)return!0;let a=this.hasShadow(),o=this.shadowForStrokeEnabled();return!!(n&&r&&a&&o)}setStrokeHitEnabled(e){q.warn(`strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead.`),e?this.hitStrokeWidth(`auto`):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){let e=this.attrs.selfRectFunc;if(e)return{...e.call(this,this)};let t=this.size();return{x:this._centroid?-t.width/2:0,y:this._centroid?-t.height/2:0,width:t.width,height:t.height}}_getSelfRectForDrawing(){return this.getSelfRect()}getClientRect(e={}){let t=this._getCachedSceneRect(e);if(t)return t;let n=e.skipTransform,r=e.relativeTo,i=e._forDrawing,a=i?this.strokeScaleEnabled()?new Ti()._getTransformedRect(this._getSelfRectForDrawing()):this._transformedRect(this._getSelfRectForDrawing(),r):this.getSelfRect(),o=!e.skipStroke&&this.hasStroke()?i?this._getStrokePadding()*2:this.strokeWidth():0,s=o,c=o,l;if(!i&&o&&!this.strokeScaleEnabled()){let e=this;for(;e&&!e.isCached()&&!e._isUnderCache;)e=e.parent;let[t,i,a,o]=this.getAbsoluteTransform(e).getMatrix(),u=Math.abs(t*o-i*a);if(u)s*=Math.hypot(a,o)/u,c*=Math.hypot(t,i)/u;else if(!n&&(s=c=0,l=e?e.getAbsoluteTransform().copy():new Ti,r)){let e=r.getAbsoluteTransform(),[t,n,i,a]=e.getMatrix();l=t*a-n*i?e.copy().invert().multiply(l):new Ti}}let u={x:a.x-s/2,y:a.y-c/2,width:a.width+s,height:a.height+c};if(i&&this.strokeScaleEnabled()&&(u=this._transformedRect(u,r)),!e.skipShadow&&this.hasShadow()){let e=i?this.getAbsoluteScale():{x:1,y:1},t=this.shadowOffsetX()*e.x,n=this.shadowOffsetY()*e.y,r=this.shadowBlur()*(i?2*Math.min(Math.abs(e.x),Math.abs(e.y)):1);u.x+=Math.min(0,t)-r,u.y+=Math.min(0,n)-r,u.width+=Math.abs(t)+r*2,u.height+=Math.abs(n)+r*2}if(i)return u;if(!n){let e=this._transformedRect(u,r);if(l){let[t,n,r,i]=l.getMatrix(),a=o*Math.hypot(t,r)/2,s=o*Math.hypot(n,i)/2;e.x-=a,e.y-=s,e.width+=a*2,e.height+=s*2}return e}return u}_getStrokePadding(e=this.miterLimit()||10){return this.attrs.sceneFunc&&(e=this.miterLimit()||10),Math.abs(this.strokeWidth())/2*Math.max(this.lineCap()===`square`?Math.SQRT2:1,(this.lineJoin()||`miter`)===`miter`?e:1)}drawScene(t,n){let r=this.getLayer(),i=t||r.getCanvas(),a=i.getContext(),o=this._getCanvasCache(),s=this.getSceneFunc(),c=this.hasShadow(),l=n===this;if(!(n?this._isVisible(n):this.isVisible())&&!l)return this;if(o){a.save();let e=this.getAbsoluteTransform(n).getMatrix();return a.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedSceneCanvas(a),a.restore(),this}if(!s)return this;a.save();try{if(i.width&&i.height&&this._useBufferCanvas(void 0,a._getOpacity(this))){let t=!!a._opacityRoot||!!this.attrs.selfRectFunc&&this.getSelfRect===e.prototype.getSelfRect||!this.attrs.sceneFunc&&!this.attrs.charRenderFunc&&xi.has(this.constructor),r=i._prepareIsolationCanvas(t?this.getClientRect({_forDrawing:!0,relativeTo:n,skipShadow:!0}):void 0),o=r.getContext();o.save(),o._applyLineJoin(this),o._applyMiterLimit(this);let u=this.getAbsoluteTransform(n).getMatrix();o.transform(u[0],u[1],u[2],u[3],u[4],u[5]),s.call(this,o,this),o.restore(),c&&a._applyShadow(this),l||(a._applyOpacity(this),a._applyGlobalCompositeOperation(this)),a._drawDeviceBuffer(r)}else{if(a._applyLineJoin(this),a._applyMiterLimit(this),!l){let e=this.getAbsoluteTransform(n).getMatrix();a.transform(e[0],e[1],e[2],e[3],e[4],e[5]),a._applyOpacity(this),a._applyGlobalCompositeOperation(this)}c&&a._applyShadow(this),s.call(this,a,this)}}catch(e){throw i._releaseIsolationCanvas(),e}finally{a.restore()}return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;let n=this.getLayer(),r=e||n.hitCanvas,i=r&&r.getContext(),a=this.hitFunc()||this.sceneFunc(),o=this._getCachedHitCanvas(t);if(this.colorKey||q.warn(`Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()`),o){i.save();let e=this.getAbsoluteTransform(t).getMatrix();return i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedHitCanvas(i,o),i.restore(),this}if(!a)return this;if(i.save(),i._applyLineJoin(this),i._applyMiterLimit(this),this!==t){let e=this.getAbsoluteTransform(t).getMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5])}try{a.call(this,i,this)}finally{i.restore()}return this}drawHitFromCache(e=0){let t=this._getCachedSceneCanvas(),n=this._getCachedHitCanvas(),r=n.getContext(),i=n.getWidth(),a=n.getHeight();r.clear(),r.drawImage(t._canvas,0,0,i/n.pixelRatio,a/n.pixelRatio);try{let t=r.getImageData(0,0,i,a),n=t.data,o=n.length,s=q._hexToRgb(this.colorKey);for(let t=0;t<o;t+=4)n[t+3]>e?(n[t]=s.r,n[t+1]=s.g,n[t+2]=s.b,n[t+3]=255):n[t+3]=0;r.putImageData(t,0,0)}catch(e){q.error(`Unable to draw hit graph from cached scene canvas. `+e.message)}return this}hasPointerCapture(e){return ba(e,this)}setPointerCapture(e){xa(e,this)}releaseCapture(e){Ca(e,this)}};Q.prototype._fillFunc=Ko,Q.prototype._strokeFunc=qo,Q.prototype._fillFuncHit=Ko,Q.prototype._strokeFuncHit=qo,Q.prototype._centroid=!1,Q.prototype.nodeType=`Shape`,Si(Q),Q.prototype.on(`shadowColorChange.konva shadowBlurChange.konva shadowOffsetXChange.konva shadowOffsetYChange.konva shadowOpacityChange.konva shadowEnabledChange.konva`,Jo),Q.prototype.on(`shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva`,Zo),Q.prototype.on(`fillEnabledChange.konva fillChange.konva fillPatternImageChange.konva fillLinearGradientColorStopsChange.konva fillRadialGradientColorStopsChange.konva`,Yo),Q.prototype.on(`strokeEnabledChange.konva strokeWidthChange.konva strokeChange.konva strokeLinearGradientColorStopsChange.konva`,Xo),Q.prototype.on(`fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva`,Qo),Q.prototype.on(`fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva`,$o),Q.prototype.on(`fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva`,es),X.addGetterSetter(Q,`stroke`,void 0,ka()),X.addGetterSetter(Q,`strokeWidth`,2,Y()),X.addGetterSetter(Q,`fillAfterStrokeEnabled`,!1),X.addGetterSetter(Q,`hitStrokeWidth`,`auto`,Da()),X.addGetterSetter(Q,`strokeHitEnabled`,!0,ja()),X.addGetterSetter(Q,`perfectDrawEnabled`,!0,ja()),X.addGetterSetter(Q,`shadowForStrokeEnabled`,!0,ja()),X.addGetterSetter(Q,`lineJoin`),X.addGetterSetter(Q,`lineCap`),X.addGetterSetter(Q,`miterLimit`),X.addGetterSetter(Q,`sceneFunc`),X.addGetterSetter(Q,`hitFunc`),X.addGetterSetter(Q,`selfRectFunc`),X.addGetterSetter(Q,`dash`),X.addGetterSetter(Q,`dashOffset`,0,Y()),X.addGetterSetter(Q,`shadowColor`,void 0,Oa()),X.addGetterSetter(Q,`shadowBlur`,0,Y()),X.addGetterSetter(Q,`shadowOpacity`,1,Y()),X.addComponentsGetterSetter(Q,`shadowOffset`,[`x`,`y`]),X.addGetterSetter(Q,`shadowOffsetX`,0,Y()),X.addGetterSetter(Q,`shadowOffsetY`,0,Y()),X.addGetterSetter(Q,`fillPatternImage`),X.addGetterSetter(Q,`fill`,void 0,ka()),X.addGetterSetter(Q,`fillPatternX`,0,Y()),X.addGetterSetter(Q,`fillPatternY`,0,Y()),X.addGetterSetter(Q,`fillLinearGradientColorStops`),X.addGetterSetter(Q,`strokeLinearGradientColorStops`),X.addGetterSetter(Q,`fillRadialGradientStartRadius`,0),X.addGetterSetter(Q,`fillRadialGradientEndRadius`,0),X.addGetterSetter(Q,`fillRadialGradientColorStops`),X.addGetterSetter(Q,`fillPatternRepeat`,`repeat`),X.addGetterSetter(Q,`fillEnabled`,!0),X.addGetterSetter(Q,`strokeEnabled`,!0),X.addGetterSetter(Q,`shadowEnabled`,!0),X.addGetterSetter(Q,`dashEnabled`,!0),X.addGetterSetter(Q,`strokeScaleEnabled`,!0),X.addGetterSetter(Q,`fillPriority`,`color`),X.addComponentsGetterSetter(Q,`fillPatternOffset`,[`x`,`y`]),X.addGetterSetter(Q,`fillPatternOffsetX`,0,Y()),X.addGetterSetter(Q,`fillPatternOffsetY`,0,Y()),X.addComponentsGetterSetter(Q,`fillPatternScale`,[`x`,`y`]),X.addGetterSetter(Q,`fillPatternScaleX`,1,Y()),X.addGetterSetter(Q,`fillPatternScaleY`,1,Y()),X.addComponentsGetterSetter(Q,`fillLinearGradientStartPoint`,[`x`,`y`]),X.addComponentsGetterSetter(Q,`strokeLinearGradientStartPoint`,[`x`,`y`]),X.addGetterSetter(Q,`fillLinearGradientStartPointX`,0),X.addGetterSetter(Q,`strokeLinearGradientStartPointX`,0),X.addGetterSetter(Q,`fillLinearGradientStartPointY`,0),X.addGetterSetter(Q,`strokeLinearGradientStartPointY`,0),X.addComponentsGetterSetter(Q,`fillLinearGradientEndPoint`,[`x`,`y`]),X.addComponentsGetterSetter(Q,`strokeLinearGradientEndPoint`,[`x`,`y`]),X.addGetterSetter(Q,`fillLinearGradientEndPointX`,0),X.addGetterSetter(Q,`strokeLinearGradientEndPointX`,0),X.addGetterSetter(Q,`fillLinearGradientEndPointY`,0),X.addGetterSetter(Q,`strokeLinearGradientEndPointY`,0),X.addComponentsGetterSetter(Q,`fillRadialGradientStartPoint`,[`x`,`y`]),X.addGetterSetter(Q,`fillRadialGradientStartPointX`,0),X.addGetterSetter(Q,`fillRadialGradientStartPointY`,0),X.addComponentsGetterSetter(Q,`fillRadialGradientEndPoint`,[`x`,`y`]),X.addGetterSetter(Q,`fillRadialGradientEndPointX`,0),X.addGetterSetter(Q,`fillRadialGradientEndPointY`,0),X.addGetterSetter(Q,`fillPatternRotation`,0),X.addGetterSetter(Q,`fillRule`,void 0,Oa()),X.backCompat(Q,{dashArray:`dash`,getDashArray:`getDash`,setDashArray:`setDash`,drawFunc:`sceneFunc`,getDrawFunc:`getSceneFunc`,setDrawFunc:`setSceneFunc`,drawHitFunc:`hitFunc`,getDrawHitFunc:`getHitFunc`,setDrawHitFunc:`setHitFunc`});var ts=`beforeDraw`,ns=`draw`,rs=10,is=256;function as(e,t){return e[t+3]>=128?Go[q.getHitColorKey(e[t],e[t+1],e[t+2])]:void 0}var os=class extends $a{constructor(e){super(e),this.canvas=new ma,this.hitCanvas=new ha({pixelRatio:1}),this._waitingForDraw=!1,this.on(`visibleChange.konva`,this._checkVisibility),this._checkVisibility(),this.on(`imageSmoothingEnabledChange.konva`,this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);let t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),e<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[e+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){Z.prototype.moveToTop.call(this);let e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!Z.prototype.moveUp.call(this))return!1;let e=this.getStage();return!e||!e.content?!1:(e.content.removeChild(this.getNativeCanvasElement()),this.index<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[this.index+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(Z.prototype.moveDown.call(this)){let e=this.getStage();if(e){let t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(Z.prototype.moveToBottom.call(this)){let e=this.getStage();if(e){let t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){var e,t;super.remove();let n=this.getNativeCanvasElement(),r=this.getHitCanvas()._canvas;return(e=n.parentNode)==null||e.removeChild(n),(t=r.parentNode)==null||t.removeChild(r),this}getStage(){return this.parent}_setSize({width:e,height:t}){return this.canvas.setSize(e,t),this._syncHitCanvasSize(),this._setSmoothEnabled(),this}_syncHitCanvasSize(){let e=this.isListening();this.hitCanvas.setSizeIfChanged((e?this.getWidth():0)||0,(e?this.getHeight():0)||0)}_validateAdd(e){let t=e.getType();t!==`Group`&&t!==`Shape`&&q.throw(`You may only add groups and shapes to a layer.`)}_toKonvaCanvas(e){return e={...e},e.width=e.width||this.getWidth(),e.height=e.height||this.getHeight(),e.x=e.x===void 0?this.x():e.x,e.y=e.y===void 0?this.y():e.y,Z.prototype._toKonvaCanvas.call(this,e)}_checkVisibility(){this.visible()?this.canvas._canvas.style.display=`block`:this.canvas._canvas.style.display=`none`}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){q.warn(`Can not change width of layer. Use "stage.width(value)" function instead.`)}getHeight(){if(this.parent)return this.parent.height()}setHeight(){q.warn(`Can not change height of layer. Use "stage.height(value)" function instead.`)}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,q.requestAnimFrame(()=>{this._waitingForDraw=!1,this.draw()},this.getStage()?._getOwnerWindow())),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;let t=this._getIntersection(e);if(t.shape)return t.shape;if(!t.antialiased)return null;let n=this.hitCanvas.pixelRatio,r=Math.floor(e.x*n),i=Math.floor(e.y*n),a=e=>this.hitCanvas.context.getImageData(r-e,i-e,e*2+1,e*2+1).data,o=rs,s=o*2+1,c=a(o),l=c[(o*s+o)*4+3];for(let e=1;e<=is;e++){e>o&&(o=Math.min(is,o*2),s=o*2+1,c=a(o));let t=0;for(let n=-e;n<=e;n++){let r=Math.abs(n)===e?1:e*2;for(let i=-e;i<=e;i+=r){let e=((n+o)*s+i+o)*4,r=as(c,e);if(r)return r;t=Math.max(t,c[e+3])}}if(t<=l&&t!==255)return null;l=t}return null}_getIntersection(e){if(!this.hitCanvas.width||!this.hitCanvas.height)return{};let t=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.floor(e.x*t),Math.floor(e.y*t),1,1).data,r=as(n,0);return r?{shape:r}:n[3]>0?{antialiased:!0}:{}}drawScene(e,t){let n=this.getLayer(),r=e||n&&n.getCanvas();return this._fire(ts,{node:this}),this.clearBeforeDraw()&&r.getContext().clear(),$a.prototype.drawScene.call(this,r,t),r._trimIsolationCanvas(),this._fire(ns,{node:this}),this}shouldDrawHit(e){if(!super.shouldDrawHit(e))return!1;if(e||K.hitOnDragEnabled)return!0;let t=!1;return J._dragElements.forEach(e=>{e.dragStatus===`dragging`&&(e.node===this.getStage()||e.node.getLayer()===this)&&(t=!0)}),!t&&!K.Transformer?._isLayerTransforming(this)}drawHit(e,t){let n=this.getLayer(),r=e||n&&n.hitCanvas;return!e&&n&&(n._syncHitCanvasSize(),n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear()),$a.prototype.drawHit.call(this,r,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){q.warn(`hitGraphEnabled method is deprecated. Please use layer.listening() instead.`),this.listening(e)}getHitGraphEnabled(e){return q.warn(`hitGraphEnabled method is deprecated. Please use layer.listening() instead.`),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;let e=this.parent;this.hitCanvas._canvas.parentNode?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}destroy(){return this.getCanvas()._releaseIsolationCanvas(),q.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};os.prototype.nodeType=`Layer`,Si(os),X.addGetterSetter(os,`imageSmoothingEnabled`,!0),X.addGetterSetter(os,`clearBeforeDraw`,!0),X.addOverloadedGetterSetter(os,`hitGraphEnabled`);var ss=class extends os{constructor(e){super(e),this.listening(!1),q.warn(`Konva.FastLayer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.`)}};ss.prototype.nodeType=`FastLayer`,Si(ss);var cs=class extends $a{_validateAdd(e){let t=e.getType();t!==`Group`&&t!==`Shape`&&q.throw(`You may only add groups and shapes to groups.`)}_drawChildNodes(e,t,n){if(e!==`drawScene`||!this.isolated()||n===this)return super._drawChildNodes(e,t,n);if(!t.width||!t.height)return;let r=t.getContext(),i=t._prepareIsolationCanvas(this.getClientRect({_forDrawing:!0,relativeTo:n})),a=i.getContext();a._opacityRoot=this,r.save();try{super._drawChildNodes(e,i,n),r._applyOpacity(this),r._drawDeviceBuffer(i)}catch(e){throw t._releaseIsolationCanvas(),e}finally{r.restore(),a._opacityRoot=void 0}}};X.addGetterSetter(cs,`isolated`,!1,ja()),cs.prototype.nodeType=`Group`,Si(cs);var ls=bi.performance?.now?()=>bi.performance.now():Date.now,us=class e{constructor(t,n){this.id=e.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:ls(),frameRate:0},this.func=t,this.setLayers(n)}setLayers(e){return this.layers=e?[].concat(e):[],this}getLayers(){return this.layers}addLayer(e){let t=this.layers,n=t.length;for(let r=0;r<n;r++)if(t[r]._id===e._id)return!1;return this.layers.push(e),!0}isRunning(){return e.animations.has(this)}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=ls(),e._addAnimation(this),this}stop(){return e._removeAnimation(this),this}_updateFrameObject(e){this.frame.timeDiff=e-this.frame.lastTime,this.frame.lastTime=e,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(e){this.animations.add(e),this._handleAnimation()}static _removeAnimation(e){this.animations.delete(e)}static _runFrames(){let e=new Set;Array.from(this.animations).forEach(t=>{this.animations.has(t)&&(t._updateFrameObject(ls()),!(t.func&&t.func.call(t,t.frame)===!1)&&t.layers.forEach(t=>t&&e.add(t)))}),e.forEach(e=>e.batchDraw())}static _animationLoop(){let t=e;t.animations.size?(t._runFrames(),q.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,q.requestAnimFrame(this._animationLoop))}};us.animations=new Set,us.animIdCounter=0,us.animRunning=!1;var ds={node:1,duration:1,easing:1,onFinish:1,onUpdate:1,onReset:1,yoyo:1},fs=1,ps=2,ms=3,hs=[`fill`,`stroke`,`shadowColor`],gs=0;function _s(e){return q.colorToRGBA(e)||q.throw(`can not tween the color "`+e+`", because it is not a valid color.`)}function vs(e,t){return{r:t.r-e.r,g:t.g-e.g,b:t.b-e.b,a:t.a-e.a}}function ys(e,t,n){return`rgba(`+Math.round(e.r+t.r*n)+`,`+Math.round(e.g+t.g*n)+`,`+Math.round(e.b+t.b*n)+`,`+(e.a+t.a*n)+`)`}var bs=class{constructor(e,t,n,r,i,a,o){this.prop=e,this.propFunc=t,this.begin=r,this._pos=r,this.duration=a,this._change=0,this.prevPos=0,this.yoyo=o,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=i-this.begin,this.pause()}fire(e){let t=this[e];t&&t()}setTime(e){e>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():e<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=e,this.update())}getTime(){return this._time}setPosition(e){this.prevPos=this._pos,this.propFunc(e),this._pos=e}getPosition(e){return e===void 0&&(e=this._time),this.func(e,this.begin,this._change,this.duration)}play(){this.state=ps,this._startTime=this.getTimer()-this._time,this.fire(`onPlay`),this.onEnterFrame()}reverse(){this.state=ms,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.fire(`onReverse`),this.onEnterFrame()}seek(e){this.pause(),this._time=e,this.update(),this.fire(`onSeek`)}reset(){this.pause(),this._time=0,this.update(),this.fire(`onReset`)}finish(){this.pause(),this._time=this.duration,this.update(),this.fire(`onFinish`)}update(){this.setPosition(this.getPosition(this._time)),this.fire(`onUpdate`)}onEnterFrame(){let e=this.getTimer()-this._startTime;this.state===ps?this.setTime(e):this.state===ms&&this.setTime(this.duration-e)}pause(){this.state=fs,this.fire(`onPause`)}getTimer(){return Date.now()}},xs=class e{constructor(t){let n=this,r=t.node,i=r._id,a=t.easing||Ss.Linear,o=!!t.yoyo,s,c;s=t.duration===void 0?.3:t.duration===0?.001:t.duration,this.node=r,this._id=gs++;let l=r.getLayer()||(r instanceof K.Stage?r.getLayers():null);for(c in l||q.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new us(function(){n.tween.onEnterFrame()},l),this.tween=new bs(c,function(e){n._tweenFunc(e)},a,0,1,s*1e3,o),this._addListeners(),e.attrs[i]||(e.attrs[i]={}),e.attrs[i][this._id]||(e.attrs[i][this._id]={}),e.tweens[i]||(e.tweens[i]={}),t)ds[c]===void 0&&this._addAttr(c,t[c]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,n){if(q._isPlainObject(n)){for(let e in n)this._addAttr(t+q._capitalize(e),n[e]);return}let r=this.node,i=r._id,a,o,s,c,l=e.tweens[i][t];l!==void 0&&delete e.attrs[i][l][t];let u=r.getAttr(t);if(q._isArray(n)||q._isArray(u)){if(a=[],c=u,s=n,u=q._isArray(u)?u.slice():Array(n.length).fill(u||0),q._isArray(n)||(n=Array(u.length).fill(n)),o=Math.max(n.length,u.length),t===`points`&&n.length!==u.length&&(n.length>u.length?u=q._prepareArrayForTween(u,n,r.closed()):n=q._prepareArrayForTween(n,u,r.closed())),t.endsWith(`ColorStops`))for(let e=0;e<o;e++)if(e%2==0)a.push((n[e]||0)-(u[e]||0));else{let t=_s(u[e]);u[e]=t,a.push(vs(t,_s(n[e])))}else for(let e=0;e<o;e++)a.push((n[e]||0)-(u[e]||0))}else hs.indexOf(t)===-1?a=n-u:(u=_s(u),a=vs(u,_s(n)));e.attrs[i][this._id][t]={start:u,diff:a,end:n,trueEnd:s,trueStart:c},e.tweens[i][t]=this._id}_tweenFunc(t){let n=this.node,r=e.attrs[n._id]?.[this._id],i,a,o,s,c,l,u,d;for(i in r){if(a=r[i],o=a.start,s=a.diff,d=a.end,q._isArray(o)){if(c=[],u=Math.max(o.length,d.length),i.endsWith(`ColorStops`))for(l=0;l<u;l++)l%2==0?c.push((o[l]||0)+s[l]*t):c.push(ys(o[l],s[l],t));else for(l=0;l<u;l++)c.push((o[l]||0)+s[l]*t)}else c=hs.indexOf(i)===-1?o+s*t:ys(o,s,t);n.setAttr(i,c)}}_addListeners(){let t=`destroy.konva-tween${this._id}`,n=()=>this.destroy(),r=()=>{this.node.off(t).on(t,n),this.anim.start()};this.tween.onPlay=r,this.tween.onReverse=r,this.tween.onPause=()=>{this.node.off(t),this.anim.stop()};let i=(t,n)=>{let r=e.attrs[this.node._id]?.[this._id];if(r){for(let e in r)r[e][t]!==void 0&&this.node.setAttr(e,r[e][t]);n?.call(this)}};this.tween.onFinish=()=>i(`trueEnd`,this.onFinish),this.tween.onReset=()=>i(`trueStart`,this.onReset),this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(e){return this.tween.seek(e*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){let t=this.node._id,n=this._id,r=e.attrs[t]?.[n],i=e.tweens[t];if(this.pause(),this.anim&&this.anim.stop(),r){if(i){for(let e in r)delete i[e];Object.keys(i).length===0&&delete e.tweens[t]}delete e.attrs[t][n],Object.keys(e.attrs[t]).length===0&&delete e.attrs[t]}}};xs.attrs={},xs.tweens={},Z.prototype.to=function(e){let t=e.onFinish,n=new xs({...e,node:this,onFinish(){n.destroy(),t&&t()}});return n.play(),n};var Ss={BackEaseIn(e,t,n,r){return n*(e/=r)*e*(2.70158*e-1.70158)+t},BackEaseOut(e,t,n,r){return n*((e=e/r-1)*e*(2.70158*e+1.70158)+1)+t},BackEaseInOut(e,t,n,r){let i=1.70158;return(e/=r/2)<1?n/2*(e*e*(((i*=1.525)+1)*e-i))+t:n/2*((e-=2)*e*(((i*=1.525)+1)*e+i)+2)+t},ElasticEaseIn(e,t,n,r,i,a){let o=0;return e===0?t:(e/=r)===1?t+n:(a||=r*.3,!i||i<Math.abs(n)?(i=n,o=a/4):o=a/(2*Math.PI)*Math.asin(n/i),-(i*2**(10*--e)*Math.sin((e*r-o)*(2*Math.PI)/a))+t)},ElasticEaseOut(e,t,n,r,i,a){let o=0;return e===0?t:(e/=r)===1?t+n:(a||=r*.3,!i||i<Math.abs(n)?(i=n,o=a/4):o=a/(2*Math.PI)*Math.asin(n/i),i*2**(-10*e)*Math.sin((e*r-o)*(2*Math.PI)/a)+n+t)},ElasticEaseInOut(e,t,n,r,i,a){let o=0;return e===0?t:(e/=r/2)==2?t+n:(a||=.3*1.5*r,!i||i<Math.abs(n)?(i=n,o=a/4):o=a/(2*Math.PI)*Math.asin(n/i),e<1?-.5*(i*2**(10*--e)*Math.sin((e*r-o)*(2*Math.PI)/a))+t:i*2**(-10*--e)*Math.sin((e*r-o)*(2*Math.PI)/a)*.5+n+t)},BounceEaseOut(e,t,n,r){return(e/=r)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t},BounceEaseIn(e,t,n,r){return n-Ss.BounceEaseOut(r-e,0,n,r)+t},BounceEaseInOut(e,t,n,r){return e<r/2?Ss.BounceEaseIn(e*2,0,n,r)*.5+t:Ss.BounceEaseOut(e*2-r,0,n,r)*.5+n*.5+t},EaseIn(e,t,n,r){return n*(e/=r)*e+t},EaseOut(e,t,n,r){return-n*(e/=r)*(e-2)+t},EaseInOut(e,t,n,r){return(e/=r/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t},StrongEaseIn(e,t,n,r){return n*(e/=r)*e*e*e*e+t},StrongEaseOut(e,t,n,r){return n*((e=e/r-1)*e*e*e*e+1)+t},StrongEaseInOut(e,t,n,r){return(e/=r/2)<1?n/2*e*e*e*e*e+t:n/2*((e-=2)*e*e*e*e+2)+t},Linear(e,t,n,r){return n*e/r+t}},Cs=q._assign(K,{Util:q,Transform:Ti,Node:Z,Container:$a,Stage:Fo,stages:Mo,Layer:os,FastLayer:ss,Group:cs,DD:J,Shape:Q,shapes:Go,Animation:us,Tween:xs,Easings:Ss,Context:ua,Canvas:pa}),ws=class extends Q{_sceneFunc(e){let t=K.getAngle(this.angle()),n=this.clockwise();e.beginPath(),e.arc(0,0,Math.abs(this.outerRadius()),0,t,n),e.arc(0,0,Math.abs(this.innerRadius()),t,0,!n),e.closePath(),e.fillStrokeShape(this)}getWidth(){return Math.abs(this.outerRadius())*2}getHeight(){return Math.abs(this.outerRadius())*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){let e=Math.abs(this.innerRadius()),t=Math.abs(this.outerRadius()),n=Math.min(e,t),r=Math.max(e,t),i=this.clockwise(),a=K.getAngle(this.angle());if(a%(Math.PI*2)==0)return a===0?{x:n,y:0,width:r-n,height:0}:{x:-r,y:-r,width:r*2,height:r*2};let o=Math.PI*2,s=i?-a:a,c=s>=o?o:(s%o+o)%o,l=Math.cos(Math.min(c,Math.PI)),u=Math.sin(Math.min(Math.max(Math.PI,c),3*Math.PI/2)),d=Math.sin(Math.min(c,Math.PI/2)),f=l*(l>0?n:r),p=1*r,m=u*(u>0?n:r),h=d*(d>0?r:n);return{x:f,y:i?-1*h:m,width:p-f,height:h-m}}};ws.prototype._centroid=!0,ws.prototype.className=`Arc`,ws.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`,`angle`,`clockwise`],Si(ws,!0),X.addGetterSetter(ws,`innerRadius`,0,Y()),X.addGetterSetter(ws,`outerRadius`,0,Y()),X.addGetterSetter(ws,`angle`,0,Y()),X.addGetterSetter(ws,`clockwise`,!1,ja());var Ts=[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],Es=[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],Ds=(e,t,n)=>{let r=n/2,i=0;for(let n=0;n<Ts.length;n++){let a=r*Ts[n]+r;i+=Es[n]*ks(e,t,a)}return r*i},Os=(e,t,n=1)=>Ds([e[0],e[0]+2/3*(e[1]-e[0]),e[2]+2/3*(e[1]-e[2]),e[2]],[t[0],t[0]+2/3*(t[1]-t[0]),t[2]+2/3*(t[1]-t[2]),t[2]],n);function ks(e,t,n){let r=1-n,i=r*r,a=2*r*n,o=n*n,s=i*(3*(e[1]-e[0]))+a*(3*(e[2]-e[1]))+o*(3*(e[3]-e[2])),c=i*(3*(t[1]-t[0]))+a*(3*(t[2]-t[1]))+o*(3*(t[3]-t[2]));return Math.sqrt(s*s+c*c)}var As=(e,t,n)=>{let r=1,i=e/t,a=(e-n(i))/t,o=0;for(;r>.001;){let s=n(i+a),c=Math.abs(e-s)/t;if(c<r)r=c,i+=a;else{let o=n(i-a),s=Math.abs(e-o)/t;s<r?(r=s,i-=a):a/=2}if(o++,o>500)break}return i},js=(e,t,n,r)=>{let i=1-r;return i*i*e+2*i*r*t+r*r*n},Ms=(e,t,n,r,i,a)=>{let o=[];for(let s of[[e,n,i],[t,r,a]]){let c=(s[0]-s[1])/(s[0]-2*s[1]+s[2]);c>0&&c<1&&o.push(js(e,n,i,c),js(t,r,a,c))}return o},Ns=(e,t,n,r,i)=>{let a=1-i;return a*a*a*e+3*a*a*i*t+3*a*i*i*n+i*i*i*r},Ps=(e,t,n,r,i,a,o,s)=>{let c=[];for(let l of[[e,n,i,o],[t,r,a,s]]){let u=-3*l[0]+9*l[1]-9*l[2]+3*l[3],d=6*l[0]-12*l[1]+6*l[2],f=-3*l[0]+3*l[1],p=d*d-4*u*f;if(p<0)continue;let m=-(d+(d<0?-1:1)*Math.sqrt(p))/2;for(let l of[m/u,f/m])l>0&&l<1&&c.push(Ns(e,n,i,o,l),Ns(t,r,a,s,l))}return c};function Fs(e,t,n,r,i,a,o){let s=Math.sqrt((n-e)**2+(r-t)**2),c=Math.sqrt((i-n)**2+(a-r)**2),l=s+c;if(l===0)return[n,r,n,r];let u=o*s/l,d=o*c/l;return[n-u*(i-e),r-u*(a-t),n+d*(i-e),r+d*(a-t)]}function Is(e,t){let n=e.length,r=[];for(let i=2;i<n-2;i+=2){let n=Fs(e[i-2],e[i-1],e[i],e[i+1],e[i+2],e[i+3],t);isNaN(n[0])||(r.push(n[0]),r.push(n[1]),r.push(e[i]),r.push(e[i+1]),r.push(n[2]),r.push(n[3]))}return r}function Ls(e){let t=[];for(let n=0;n+7<e.length;n+=6)t.push(e[n+6],e[n+7],...Ps(e[n],e[n+1],e[n+2],e[n+3],e[n+4],e[n+5],e[n+6],e[n+7]));return t}var Rs=class extends Q{constructor(e){super(e),this.on(`pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva`,function(){this._clearCache(`tensionPoints`)})}_hasTension(){return this.tension()!==0&&this.points().length>4}_eachTensionSegment(e,t){let n=this.points(),r=n.length,i=this.closed(),a=this.getTensionPoints(),o=a.length,s=n[0],c=n[1],l=i?0:4;for(i||(e(s,c,a[0],a[1],a[2],a[3]),s=a[2],c=a[3]);l<o-2;){let e=a[l++],n=a[l++],r=a[l++],i=a[l++],o=a[l++],u=a[l++];t(s,c,e,n,r,i,o,u),s=o,c=u}i||e(s,c,a[o-2],a[o-1],n[r-2],n[r-1])}_getStrokePadding(e=this.points().length===4&&!this.closed()?1:void 0){return super._getStrokePadding(e)}_sceneFunc(e){let t=this.points(),n=t.length,r=this.closed(),i=this.bezier();if(!n)return;let a=0;if(e.beginPath(),e.moveTo(t[0],t[1]),this._hasTension())this._eachTensionSegment((t,n,r,i,a,o)=>e.quadraticCurveTo(r,i,a,o),(t,n,r,i,a,o,s,c)=>e.bezierCurveTo(r,i,a,o,s,c));else if(i)for(a=2;a<n;)e.bezierCurveTo(t[a++],t[a++],t[a++],t[a++],t[a++],t[a++]);else for(a=2;a<n;a+=2)e.lineTo(t[a],t[a+1]);r?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}getTensionPoints(){return this._getCache(`tensionPoints`,this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():Is(this.points(),this.tension())}_getTensionPointsClosed(){let e=this.points(),t=e.length,n=this.tension(),r=Fs(e[t-2],e[t-1],e[0],e[1],e[2],e[3],n),i=Fs(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],n),a=Is(e,n);return[r[2],r[3]].concat(a,[i[0],i[1],e[t-2],e[t-1],i[2],i[3],r[0],r[1],e[0],e[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let e=this.points();if(e.length<4)return{x:e[0]||0,y:e[1]||0,width:0,height:0};if(this._hasTension()){let t=[e[0],e[1]];this._eachTensionSegment((e,n,r,i,a,o)=>t.push(a,o,...Ms(e,n,r,i,a,o)),(e,n,r,i,a,o,s,c)=>t.push(s,c,...Ps(e,n,r,i,a,o,s,c))),e=t}else this.bezier()&&(e=[e[0],e[1],...Ls(e)]);return q._getPointsRect(e)}};Rs.prototype.className=`Line`,Rs.prototype._attrsAffectingSize=[`points`,`bezier`,`tension`,`closed`],Si(Rs,!0),X.addGetterSetter(Rs,`closed`,!1),X.addGetterSetter(Rs,`bezier`,!1),X.addGetterSetter(Rs,`tension`,0,Y()),X.addGetterSetter(Rs,`points`,[],Aa());var zs={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7,z:0},Bs=Math.PI*2,Vs=class e extends Q{constructor(e){super(e),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on(`dataChange.konva`,function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=e.parsePathData(this.data()),this.pathLength=e.getPathLength(this.dataArray)}_sceneFunc(e){let t=this.dataArray;e.beginPath();let n=!1;for(let r=0;r<t.length;r++){let i=t[r].command,a=t[r].points;switch(i){case`L`:e.lineTo(a[0],a[1]);break;case`M`:e.moveTo(a[0],a[1]);break;case`C`:e.bezierCurveTo(a[0],a[1],a[2],a[3],a[4],a[5]);break;case`Q`:e.quadraticCurveTo(a[0],a[1],a[2],a[3]);break;case`A`:e.ellipse(a[0],a[1],a[2],a[3],a[6],a[4],a[4]+a[5],!a[7]);break;case`z`:n=!0,e.closePath()}}!n&&!this.hasFill()?e.strokeShape(this):e.fillStrokeShape(this)}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let t=[];return this.dataArray.forEach(function(n){if(n.command===`A`){let[r,i,a,o,s,c,l]=n.points,u=Math.cos(l),d=Math.sin(l),f=e.getPointOnEllipticalArc(r,i,a,o,s+c,l);t.push(n.start.x,n.start.y,f.x,f.y);let p=Math.atan2(-o*d,a*u),m=Math.atan2(o*u,a*d);[p,p+Math.PI,m,m+Math.PI].forEach(n=>{if(((n-s)*Math.sign(c)%Bs+Bs)%Bs<Math.abs(c)){let s=e.getPointOnEllipticalArc(r,i,a,o,n,l);t.push(s.x,s.y)}})}else n.command===`C`?t.push(n.start.x,n.start.y,n.points[4],n.points[5],...Ps(n.start.x,n.start.y,n.points[0],n.points[1],n.points[2],n.points[3],n.points[4],n.points[5])):n.command===`Q`?t.push(n.start.x,n.start.y,n.points[2],n.points[3],...Ms(n.start.x,n.start.y,n.points[0],n.points[1],n.points[2],n.points[3])):t.push(...n.points)}),q._getPointsRect(t)}getLength(){return this.pathLength}getPointAtLength(t){return e.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(e,t,n,r){return Math.sqrt((n-e)*(n-e)+(r-t)*(r-t))}static getPathLength(e){let t=0;for(let n=0;n<e.length;++n)t+=e[n].pathLength;return t}static getPointAtLengthOfDataArray(t,n,r){let i,a=r?.index??0,o=r?.offset??0,s=n.length;if(!s)return null;for(;a>0&&t<=o;)o-=n[--a].pathLength;for(t-=o;a<s&&t>n[a].pathLength;){let e=n[a].pathLength;t-=e,o+=e,++a}if(r&&a<s&&(r.index=a,r.offset=o),a===s&&(a--,t=n[a].pathLength),t<.01)return n[a].command===`M`?(i=n[a].points.slice(0,2),{x:i[0],y:i[1]}):{x:n[a].start.x,y:n[a].start.y};let c=n[a],l=c.points;switch(c.command){case`L`:case`z`:return e.getPointOnLine(t,c.start.x,c.start.y,l[0],l[1]);case`C`:return e.getPointOnCubicBezier(As(t,c.pathLength,e=>Ds([c.start.x,l[0],l[2],l[4]],[c.start.y,l[1],l[3],l[5]],e)),c.start.x,c.start.y,l[0],l[1],l[2],l[3],l[4],l[5]);case`Q`:return e.getPointOnQuadraticBezier(As(t,c.pathLength,e=>Os([c.start.x,l[0],l[2]],[c.start.y,l[1],l[3]],e)),c.start.x,c.start.y,l[0],l[1],l[2],l[3]);case`A`:return e.getPointOnEllipticalArc(l[0],l[1],l[2],l[3],l[2]===l[3]?l[4]+l[5]*t/c.pathLength:e._walkArc(l,t).theta,l[6])}return null}static getPointOnLine(e,t,n,r,i,a,o){a??=t,o??=n;let s=this.getLineLength(t,n,r,i);if(s<1e-10)return{x:t,y:n};if(r===t)return{x:a,y:o+(i>n?e:-e)};let c=(i-n)/(r-t),l=Math.sqrt(e*e/(1+c*c))*(r<t?-1:1),u=c*l;if(Math.abs(o-n-c*(a-t))<1e-10)return{x:a+l,y:o+u};let d=((a-t)*(r-t)+(o-n)*(i-n))/(s*s),f=t+d*(r-t),p=n+d*(i-n),m=this.getLineLength(a,o,f,p),h=Math.sqrt(e*e-m*m),g=Math.sqrt(h*h/(1+c*c))*(r<t?-1:1),_=c*g;return{x:f+g,y:p+_}}static getPointOnCubicBezier(e,t,n,r,i,a,o,s,c){function l(e){return e*e*e}function u(e){return 3*e*e*(1-e)}function d(e){return 3*e*(1-e)*(1-e)}function f(e){return(1-e)*(1-e)*(1-e)}return{x:s*l(e)+a*u(e)+r*d(e)+t*f(e),y:c*l(e)+o*u(e)+i*d(e)+n*f(e)}}static getPointOnQuadraticBezier(e,t,n,r,i,a,o){function s(e){return e*e}function c(e){return 2*e*(1-e)}function l(e){return(1-e)*(1-e)}return{x:a*s(e)+r*c(e)+t*l(e),y:o*s(e)+i*c(e)+n*l(e)}}static getPointOnEllipticalArc(e,t,n,r,i,a){let o=Math.cos(a),s=Math.sin(a),c={x:n*Math.cos(i),y:r*Math.sin(i)};return{x:e+(c.x*o-c.y*s),y:t+(c.x*s+c.y*o)}}static parsePathData(e){if(!e)return[];let t=e,n=[`m`,`M`,`l`,`L`,`v`,`V`,`h`,`H`,`z`,`Z`,`c`,`C`,`q`,`Q`,`t`,`T`,`s`,`S`,`a`,`A`];t=t.replace(RegExp(` `,`g`),`,`);for(let e=0;e<n.length;e++)t=t.replace(new RegExp(n[e],`g`),`|`+n[e]);let r=t.split(`|`),i=[],a=[],o=0,s=0,c=0,l=0,u=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi,d;for(let e=1;e<r.length;e++){let t=r[e],n=t.charAt(0);for(t=t.slice(1),a.length=0;d=u.exec(t);)a.push(d[0]);let f=[],p=n===`A`||n===`a`?0:-1;for(let e=0,t=a.length;e<t;e++){let t=a[e];for(;(p===3||p===4)&&t.length>1&&(t[0]===`0`||t[0]===`1`);)f.push(+t[0]),p++,t=t.slice(1);let n=parseFloat(t);f.push(isNaN(n)?0:n),p>=0&&(p=(p+1)%7)}let m=0;for(;m<f.length&&!(f.length-m<zs[n.toLowerCase()]||n===`z`||n===`Z`);){let e=``,t=[],r=o,a=s,u,d,p,h,g,_,v,y,b,x;switch(n){case`l`:o+=f[m++],s+=f[m++],e=`L`,t.push(o,s);break;case`L`:o=f[m++],s=f[m++],t.push(o,s);break;case`m`:o+=f[m++],s+=f[m++],e=`M`,c=o,l=s,t.push(o,s),n=`l`;break;case`M`:o=f[m++],s=f[m++],e=`M`,c=o,l=s,t.push(o,s),n=`L`;break;case`h`:o+=f[m++],e=`L`,t.push(o,s);break;case`H`:o=f[m++],e=`L`,t.push(o,s);break;case`v`:s+=f[m++],e=`L`,t.push(o,s);break;case`V`:s=f[m++],e=`L`,t.push(o,s);break;case`C`:t.push(f[m++],f[m++],f[m++],f[m++]),o=f[m++],s=f[m++],t.push(o,s);break;case`c`:t.push(o+f[m++],s+f[m++],o+f[m++],s+f[m++]),o+=f[m++],s+=f[m++],e=`C`,t.push(o,s);break;case`S`:d=o,p=s,u=i[i.length-1],u?.command===`C`&&(d=o+(o-u.points[2]),p=s+(s-u.points[3])),t.push(d,p,f[m++],f[m++]),o=f[m++],s=f[m++],e=`C`,t.push(o,s);break;case`s`:d=o,p=s,u=i[i.length-1],u?.command===`C`&&(d=o+(o-u.points[2]),p=s+(s-u.points[3])),t.push(d,p,o+f[m++],s+f[m++]),o+=f[m++],s+=f[m++],e=`C`,t.push(o,s);break;case`Q`:t.push(f[m++],f[m++]),o=f[m++],s=f[m++],t.push(o,s);break;case`q`:t.push(o+f[m++],s+f[m++]),o+=f[m++],s+=f[m++],e=`Q`,t.push(o,s);break;case`T`:d=o,p=s,u=i[i.length-1],u?.command===`Q`&&(d=o+(o-u.points[0]),p=s+(s-u.points[1])),o=f[m++],s=f[m++],e=`Q`,t.push(d,p,o,s);break;case`t`:d=o,p=s,u=i[i.length-1],u?.command===`Q`&&(d=o+(o-u.points[0]),p=s+(s-u.points[1])),o+=f[m++],s+=f[m++],e=`Q`,t.push(d,p,o,s);break;case`A`:case`a`:if(h=Math.abs(f[m++]),g=Math.abs(f[m++]),_=f[m++],v=f[m++],y=f[m++],b=o,x=s,n===`a`?(o+=f[m++],s+=f[m++]):(o=f[m++],s=f[m++]),e=`A`,o===b&&s===x)continue;!h||!g?(e=`L`,t.push(o,s)):t=this.convertEndpointToCenterParameterization(b,x,o,s,v,y,h,g,_)}i.push({command:e||n,points:t,start:{x:r,y:a},pathLength:this.calcLength(r,a,e||n,t)})}(n===`z`||n===`Z`)&&(i.push({command:`z`,points:[c,l],start:{x:o,y:s},pathLength:this.getLineLength(o,s,c,l)}),o=c,s=l)}return i}static _walkArc(t,n){let[r,i,a,o,s,c]=t,l=Math.max(1,Math.ceil(Math.abs(c)/(Math.PI/180))),u=e.getPointOnEllipticalArc(r,i,a,o,s,0),d=s,f=0;for(let t=1;t<=l;t++){let p=s+c*t/l,m=e.getPointOnEllipticalArc(r,i,a,o,p,0),h=e.getLineLength(u.x,u.y,m.x,m.y);if(f+h>=n)return{theta:d+(p-d)*((n-f)/h),length:n};f+=h,u=m,d=p}return{theta:d,length:f}}static calcLength(t,n,r,i){let a=e;switch(r){case`L`:return a.getLineLength(t,n,i[0],i[1]);case`C`:return Ds([t,i[0],i[2],i[4]],[n,i[1],i[3],i[5]],1);case`Q`:return Os([t,i[0],i[2]],[n,i[1],i[3]],1);case`A`:return a._walkArc(i,1/0).length}return 0}static convertEndpointToCenterParameterization(e,t,n,r,i,a,o,s,c){let l=Math.PI/180*c,u=Math.cos(l)*(e-n)/2+Math.sin(l)*(t-r)/2,d=-1*Math.sin(l)*(e-n)/2+Math.cos(l)*(t-r)/2,f=u*u/(o*o)+d*d/(s*s);f>1&&(o*=Math.sqrt(f),s*=Math.sqrt(f));let p=Math.sqrt((o*o*(s*s)-o*o*(d*d)-s*s*(u*u))/(o*o*(d*d)+s*s*(u*u)));i===a&&(p*=-1),isNaN(p)&&(p=0);let m=p*o*d/s,h=p*-s*u/o,g=(e+n)/2+Math.cos(l)*m-Math.sin(l)*h,_=(t+r)/2+Math.sin(l)*m+Math.cos(l)*h,v=function(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])},y=function(e,t){return(e[0]*t[0]+e[1]*t[1])/(v(e)*v(t))},b=function(e,t){return(e[0]*t[1]<e[1]*t[0]?-1:1)*Math.acos(y(e,t))},x=b([1,0],[(u-m)/o,(d-h)/s]),S=[(u-m)/o,(d-h)/s],C=[(-1*u-m)/o,(-1*d-h)/s],w=b(S,C);return y(S,C)<=-1&&(w=Math.PI),y(S,C)>=1&&(w=0),a===0&&w>0&&(w-=2*Math.PI),a===1&&w<0&&(w+=2*Math.PI),[g,_,o,s,x,w,l,a]}};Vs.prototype.className=`Path`,Vs.prototype._attrsAffectingSize=[`data`],Si(Vs,!0),X.addGetterSetter(Vs,`data`);var Hs=class extends Rs{_getStrokePadding(){return super._getStrokePadding(this.pointerAtBeginning()||this.pointerAtEnding()?this.miterLimit()||10:void 0)}_sceneFunc(e){super._sceneFunc(e);let t=this.points(),n=t.length;if(n<4)return;let r=this.pointerLength(),i=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(t[n-2],t[n-1]),e.rotate(this._getPointerAngle(!1)),e.moveTo(0,0),e.lineTo(-r,i/2),e.lineTo(-r,-i/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(t[0],t[1]),e.rotate(this._getPointerAngle(!0)),e.moveTo(0,0),e.lineTo(-r,i/2),e.lineTo(-r,-i/2),e.closePath(),e.restore(),this.__fillStroke(e))}_getPointerAngle(e){let t=this.points(),n=t.length,r=this.tension()!==0&&n>4,i=r?this.getTensionPoints():t,a=e?t[0]:t[n-2],o=e?t[1]:t[n-1],s=0,c=0;if(r&&e)s=a-(i[0]+i[2])/2,c=o-(i[1]+i[3])/2;else if(r){let e=i[i.length-4],t=i[i.length-3],n=i[i.length-2],r=i[i.length-1],l=Vs.calcLength(e,t,`Q`,[n,r,a,o]),u=Vs.getPointOnQuadraticBezier(l?Math.max(0,1-this.pointerLength()/l):0,e,t,n,r,a,o);s=a-u.x,c=o-u.y}for(let t=e?0:i.length-2;!s&&!c&&t>=0&&t<i.length;t+=e?2:-2)s=a-i[t],c=o-i[t+1];let l=Math.PI*2;return(Math.atan2(c,s)+l)%l}__fillStroke(e){let t=this.dashEnabled();t&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),t&&(this.attrs.dashEnabled=!0)}getSelfRect(){let e=super.getSelfRect(),t=this.points();if(t.length<4)return e;let n=e.x,r=e.y,i=n+e.width,a=r+e.height;for(let e of[!1,!0]){if(!(e?this.pointerAtBeginning():this.pointerAtEnding()))continue;let o=e?0:t.length-2,s=this._getPointerAngle(e),c=Math.cos(s),l=Math.sin(s),u=t[o]-this.pointerLength()*c,d=t[o+1]-this.pointerLength()*l,f=Math.abs(this.pointerWidth()*l/2),p=Math.abs(this.pointerWidth()*c/2);n=Math.min(n,u-f),r=Math.min(r,d-p),i=Math.max(i,u+f),a=Math.max(a,d+p)}return{x:n,y:r,width:i-n,height:a-r}}};Hs.prototype.className=`Arrow`,Hs.prototype._attrsAffectingSize=[...Rs.prototype._attrsAffectingSize,`pointerLength`,`pointerWidth`,`pointerAtBeginning`,`pointerAtEnding`],Si(Hs,!0),X.addGetterSetter(Hs,`pointerLength`,10,Y()),X.addGetterSetter(Hs,`pointerWidth`,10,Y()),X.addGetterSetter(Hs,`pointerAtBeginning`,!1),X.addGetterSetter(Hs,`pointerAtEnding`,!0);var Us=class extends Q{_getStrokePadding(){return super._getStrokePadding(1)}_sceneFunc(e){e.beginPath(),e.arc(0,0,Math.abs(this.attrs.radius||0),0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return Math.abs(this.radius())*2}getHeight(){return Math.abs(this.radius())*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};Us.prototype._centroid=!0,Us.prototype.className=`Circle`,Us.prototype._attrsAffectingSize=[`radius`],Si(Us,!0),X.addGetterSetter(Us,`radius`,0,Y());var Ws=class extends Q{_getStrokePadding(){return super._getStrokePadding(1)}_sceneFunc(e){let t=Math.abs(this.radiusX()),n=Math.abs(this.radiusY());e.beginPath(),e.ellipse(0,0,t,n,0,0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return Math.abs(this.radiusX())*2}getHeight(){return Math.abs(this.radiusY())*2}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}};Ws.prototype.className=`Ellipse`,Ws.prototype._centroid=!0,Ws.prototype._attrsAffectingSize=[`radiusX`,`radiusY`],Si(Ws,!0),X.addComponentsGetterSetter(Ws,`radius`,[`x`,`y`]),X.addGetterSetter(Ws,`radiusX`,0,Y()),X.addGetterSetter(Ws,`radiusY`,0,Y());var Gs=class e extends Q{constructor(e){super(e),this._loadListener=()=>{this._requestDraw()},this.on(`imageChange.konva`,e=>{this._removeImageLoad(e.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){var e;let t=this.image();t?.complete&&t.src||t?.readyState>=2||(e=t?.addEventListener)==null||e.call(t,`videoWidth`in t?`loadeddata`:`load`,this._loadListener)}_removeImageLoad(e){var t;(t=e?.removeEventListener)==null||t.call(e,`videoWidth`in e?`loadeddata`:`load`,this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){if(this.attrs.perfectDrawEnabled===!1)return!1;let n=!!this.cornerRadius(),r=this.hasShadow();return n&&r?!0:super._useBufferCanvas(!0,t)}_getStrokePadding(){return super._getStrokePadding(this.strokeScaleEnabled()?1:void 0)}_sceneFunc(e){let t=this.getWidth(),n=this.getHeight(),r=this.cornerRadius(),i=this.attrs.image;if((this.hasFill()||this.hasStroke()||r)&&(e.beginPath(),r?q.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)),i){r&&e.clip();let a=this.attrs.cropWidth,o=this.attrs.cropHeight;a&&o?e.drawImage(i,this.cropX(),this.cropY(),a,o,0,0,t,n):e.drawImage(i,0,0,t,n)}}_hitFunc(e){let t=this.width(),n=this.height(),r=this.cornerRadius();e.beginPath(),r?q.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}getWidth(){let e=this.image();return this.attrs.width??e?.videoWidth??e?.width??0}getHeight(){let e=this.image();return this.attrs.height??e?.videoHeight??e?.height??0}static fromURL(t,n,r=null){let i=q.createImageElement();i.onload=()=>{i.onload=i.onerror=null,n(new e({image:i}))},i.onerror=r,i.crossOrigin=`Anonymous`,i.src=t}};Gs.prototype.className=`Image`,Gs.prototype._attrsAffectingSize=[`image`],Si(Gs,!0),X.addGetterSetter(Gs,`cornerRadius`,0,Ea(4)),X.addGetterSetter(Gs,`image`),X.addComponentsGetterSetter(Gs,`crop`,[`x`,`y`,`width`,`height`]),X.addGetterSetter(Gs,`cropX`,0,Y()),X.addGetterSetter(Gs,`cropY`,0,Y()),X.addGetterSetter(Gs,`cropWidth`,0,Y()),X.addGetterSetter(Gs,`cropHeight`,0,Y());var Ks=typeof Intl<`u`&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:`grapheme`}):null;function qs(e){return e/15}function Js(e){return Ks?Array.from(Ks.segment(e),e=>e.segment):e.match(/\p{RI}\p{RI}|\P{M}(?:\p{M}|\p{Emoji_Modifier}|\uFE0F|\u200D\P{M})*|\p{M}+/gu)||[]}var Ys=`auto`,Xs=`center`,Zs=`inherit`,Qs=`justify`,$s=`Change.konva`,ec=`2d`,tc=`-`,nc=`left`,rc=`text`,ic=`Text`,ac=`top`,oc=`bottom`,sc=`middle`,cc=`normal`,lc=`px `,uc=` `,dc=`right`,fc=`rtl`,pc=`word`,mc=`char`,hc=`none`,gc=`…`,_c=[`direction`,`fontFamily`,`fontSize`,`fontStyle`,`fontVariant`,`padding`,`align`,`verticalAlign`,`lineHeight`,`text`,`width`,`height`,`wrap`,`ellipsis`,`letterSpacing`],vc=null;function yc(){if(vc!==null)return vc;vc=!1;let e;try{e=q.createCanvasElement(),e.width=10,e.height=10;let t=e.getContext(ec);if(t){t.globalAlpha=0,t.shadowColor=`black`,t.shadowBlur=5,t.shadowOffsetX=5,t.shadowOffsetY=5,t.fillStyle=`black`,t.font=`10px Arial`,t.fillText(`X`,0,10);let e=t.getImageData(0,0,10,10).data;for(let t=3;t<e.length;t+=4)if(e[t]>0){vc=!0;break}}}catch{}finally{e&&q.releaseCanvas(e)}return vc}function bc(e){return e.split(`,`).map(e=>{e=e.trim();let t=e.indexOf(` `)>=0,n=e.indexOf(`"`)>=0||e.indexOf(`'`)>=0;return t&&!n&&(e=`"${e}"`),e}).join(`, `)}var xc;function Sc(){return xc||(xc=q.createCanvasElement().getContext(ec),xc)}function Cc(e){this._partialFillStyle&&e.setAttr(`fillStyle`,this._partialFillStyle),e.fillText(this._partialText,this._partialTextX,this._partialTextY)}function wc(e){e.setAttr(`miterLimit`,2),this._partialStrokeStyle&&e.setAttr(`strokeStyle`,this._partialStrokeStyle),e.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function Tc(e){return e||={},e.fill||e.fillLinearGradientColorStops||e.fillRadialGradientColorStops||e.fillPatternImage?e:{...e,fill:`black`}}var Ec=class extends Q{constructor(e){super(Tc(e)),this._partialTextX=0,this._partialTextY=0,this._baselineShift=0,this._setTextData()}_sceneFunc(e){let t=this.textArr,n=t.length;if(!this.text())return;let r=this.padding(),i=this.fontSize(),a=this.lineHeight()*i,o=this.direction(),s=this.align(),c=this.getWidth(),l=this.letterSpacing(),u=this.charRenderFunc(),d=this.textDecoration(),f=d.indexOf(`underline`)!==-1,p=d.indexOf(`line-through`)!==-1,m,h=a/2,g=sc;if(!K.legacyTextRendering){let e=this.measureSize(`M`);g=`alphabetic`,h=((e.fontBoundingBoxAscent??e.actualBoundingBoxAscent)-(e.fontBoundingBoxDescent??e.actualBoundingBoxDescent))/2+a/2}if(o===Zs?o=e.direction:e.setAttr(`direction`,o),e.setAttr(`font`,this._getContextFont()),e.setAttr(`textBaseline`,g),e.setAttr(`textAlign`,nc),e.translate(r,this._getTextTop()),u){let t=e._getFillStyle(this);t!==void 0&&(e.fillStyle=t),this.hasStroke()&&e._applyStrokeStyle(this)}let _=u?e.fillStyle:void 0,v=u?e.strokeStyle:void 0,y=0;for(m=0;m<n;m++){let d=0,g=t[m],b=g.text,x=g.width,S=g.lastInParagraph;if(e.save(),s===dc?d+=c-x-r*2:s===Xs&&(d+=(c-x-r*2)/2),f){e.save(),e.beginPath();let t=this._getUnderlineOffset(),n=d,a=h+0+t;e.moveTo(n,a);let o=s===Qs&&!S?c-r*2:x;e.lineTo(n+Math.round(o),a),e.lineWidth=qs(i),e.strokeStyle=e._getFillStyle(this),e.stroke(),e.restore()}let C=d;if(o!==fc&&(l!==0||s===Qs||u)){let t=b.split(` `).length-1,n=Js(b);for(let i=0;i<n.length;i++){let a=n[i];a===` `&&!S&&s===Qs&&(d+=(c-r*2-x)/t),this._partialTextX=d,this._partialTextY=h+0,this._partialText=a;let o=e.measureText(a).width;if(u){e.save(),u({char:a,index:y,x:d,y:h+0,lineIndex:m,column:i,isLastInLine:i===n.length-1,width:o,context:e});let t=e.fillStyle;t!==_&&(this._partialFillStyle=t);let r=e.strokeStyle;r!==v&&(this._partialStrokeStyle=r)}e.fillStrokeShape(this),u&&(this._partialFillStyle=void 0,this._partialStrokeStyle=void 0,e.restore()),d+=o+l,y++}}else l!==0&&e.setAttr(`letterSpacing`,`${l}px`),this._partialTextX=d,this._partialTextY=h+0,this._partialText=b,e.fillStrokeShape(this);if(p){e.save(),e.beginPath();let t=K.legacyTextRendering?0:-Math.round(i/4),n=C;e.moveTo(n,h+0+t);let a=s===Qs&&!S?c-r*2:x;e.lineTo(n+Math.round(a),h+0+t),e.lineWidth=qs(i),e.strokeStyle=e._getFillStyle(this),e.stroke(),e.restore()}e.restore(),n>1&&(h+=a)}}_getTextTop(){let e=this.padding(),t=this.getHeight()-this.textArr.length*this.lineHeight()*this.fontSize()-e*2,n=this.verticalAlign();return n===sc?e+t/2:n===oc?e+t:e}_getUnderlineOffset(){return this.underlineOffset()??Math.round(this.fontSize()/(K.legacyTextRendering?2:4))}getSelfRect(){let e=super.getSelfRect(),t=this.textArr.length;if(!t||this.textDecoration().indexOf(`underline`)===-1)return e;let n=this.fontSize(),r=this.lineHeight()*n,i=this._getTextTop()+t*r-r/2;return K.legacyTextRendering||(i+=this._baselineShift),i+=this._getUnderlineOffset()+qs(n)/2,e.height=Math.max(e.y+e.height,i)-e.y,e}_getSelfRectForDrawing(){let e=this.getSelfRect(),t=this.fontSize(),n=this.padding(),r=this.lineHeight()*t,i=this.getWidth()-n*2,a=this.align(),o=this.textArr.length*r,s=this._getTextTop(),c=e.x,l=e.x+e.width;for(let{text:e,width:t}of this.textArr){let r=n+(a===dc?i-t:a===Xs?(i-t)/2:0),o=Math.min(0,this.letterSpacing())*e.length;c=Math.min(c,r+o),l=Math.max(l,r+t-o)}let u=this.textDecoration().includes(`underline`),d=Math.min(e.y,s+(u?Math.min(0,this._getUnderlineOffset()):0));return{x:c-t,y:d-t,width:l-c+t*2,height:Math.max(e.y+e.height,s+o)-d+t*2}}_hitFunc(e){let t=this.getWidth(),n=this.getHeight();e.beginPath(),e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}setText(e){let t=q._isString(e)?e:e==null?``:e+``;return this._setAttr(rc,t),this}getWidth(){return this.attrs.width===Ys||this.attrs.width===void 0?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){return this.attrs.height===Ys||this.attrs.height===void 0?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return q.warn(`text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height.`),this.textHeight}measureSize(e){let t=Sc(),n=this.fontSize(),r;t.save(),t.font=this._getContextFont(),r=t.measureText(e),t.restore();let i=n/100;return{actualBoundingBoxAscent:r.actualBoundingBoxAscent??71.58203125*i,actualBoundingBoxDescent:r.actualBoundingBoxDescent??0,actualBoundingBoxLeft:r.actualBoundingBoxLeft??-7.421875*i,actualBoundingBoxRight:r.actualBoundingBoxRight??75.732421875*i,alphabeticBaseline:r.alphabeticBaseline??0,emHeightAscent:r.emHeightAscent??100*i,emHeightDescent:r.emHeightDescent??-20*i,fontBoundingBoxAscent:r.fontBoundingBoxAscent??91*i,fontBoundingBoxDescent:r.fontBoundingBoxDescent??21*i,hangingBaseline:r.hangingBaseline??72.80000305175781*i,ideographicBaseline:r.ideographicBaseline??-21*i,width:r.width,height:n}}_getContextFont(){return this.fontStyle()+uc+this.fontVariant()+uc+(this.fontSize()+lc)+bc(this.fontFamily())}_addTextLine(e){this.align()===Qs&&(e=e.trim());let t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e,t){let n=this.letterSpacing(),r=n?n*(t??Js(e).length):0;return Sc().measureText(e).width+r}_setTextData(){let e=this.text().split(`
16
- `),t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.width,i=this.attrs.height,a=r!==Ys&&r!==void 0,o=i!==Ys&&i!==void 0,s=this.padding(),c=r-s*2,l=i-s*2,u=0,d=this.wrap(),f=d!==mc&&d!==hc,p=this.ellipsis(),m=this.measureSize(`M`);this._baselineShift=(m.fontBoundingBoxAscent-m.fontBoundingBoxDescent)/2,this.textArr=[];let h=Sc();h.font=this._getContextFont(),h.fontKerning=this.direction()!==fc&&(this.letterSpacing()!==0||this.align()===Qs||this.charRenderFunc())?`none`:`auto`;let g=p?this._getTextWidth(gc):0;for(let t=0,r=e.length;t<r;++t){let i=e[t],s=this._getTextWidth(i);if(a&&s>c){let e=Js(i),a=e.length,d=0,m=t=>e.slice(d,t).join(``),h=e=>e===uc||e===tc,_=Math.max(1,Math.ceil(a*c/s));for(;d<a;){let i=p&&o&&u+n>l?g:0,s=e=>!(this._getTextWidth(m(e),e-d)+i>c),v=d,y=Math.min(a,d+_);for(;s(y)&&(v=y,y!==a);)y=Math.min(a,y+(y-d));for(;y-v>1;){let e=v+y>>>1;s(e)?v=e:y=e}if(v===d)break;if(v===a){this._addTextLine(m(a)),u+=n,o&&u+n>l&&t<r-1&&this._tryToAddEllipsisToLastLine();break}if(f&&!h(e[v])){let t=v-1;for(;t>=d&&!h(e[t]);)t--;t>=d&&(v=t+1)}if(this._addTextLine(m(v).trimRight()),u+=n,this._shouldHandleEllipsis(u)){this._tryToAddEllipsisToLastLine();break}for(d=v;d<a&&!e[d].trim();)d++}}else this._addTextLine(i),u+=n,o&&u+n>l&&t<r-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),o&&u+n>l)break}this.textHeight=t,this.textWidth=this.textArr.reduce((e,t)=>Math.max(e,t.width),0)}_shouldHandleEllipsis(e){let t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,i=r!==Ys&&r!==void 0,a=r-this.padding()*2;return this.wrap()===hc||i&&e+n>a}_tryToAddEllipsisToLastLine(){let e=this.attrs.width,t=e!==Ys&&e!==void 0,n=e-this.padding()*2,r=this.ellipsis(),i=this.textArr[this.textArr.length-1];if(!i||!r)return;let a=i.text+gc;if(t){let e=Js(i.text);for(;e.length&&this._getTextWidth(a)>n;)e.pop(),a=e.join(``)+gc;this._getTextWidth(a)>n&&(a=``)}i.text=a,i.width=this._getTextWidth(a)}getStrokeScaleEnabled(){return!0}_getStrokePadding(){return super._getStrokePadding(2)}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){if(this.attrs.perfectDrawEnabled===!1)return!1;let n=this.textDecoration().indexOf(`underline`)!==-1||this.textDecoration().indexOf(`line-through`)!==-1,r=this.hasShadow();return n&&r||r&&t!==1&&yc()?!0:super._useBufferCanvas(e,t)}};Ec.prototype._fillFunc=Cc,Ec.prototype._strokeFunc=wc,Ec.prototype.className=ic,Ec.prototype._attrsAffectingSize=_c.filter(e=>e!==`width`&&e!==`height`).concat([`textDecoration`,`underlineOffset`]),Si(Ec,!0),Ec.prototype.on(_c.map(e=>e+$s).join(` `),function(){this._setTextData()}),X.overWriteSetter(Ec,`width`,Da()),X.overWriteSetter(Ec,`height`,Da()),X.addGetterSetter(Ec,`direction`,Zs),X.addGetterSetter(Ec,`fontFamily`,`Arial`),X.addGetterSetter(Ec,`fontSize`,12,Y()),X.addGetterSetter(Ec,`fontStyle`,cc),X.addGetterSetter(Ec,`fontVariant`,cc),X.addGetterSetter(Ec,`padding`,0,Y()),X.addGetterSetter(Ec,`align`,nc),X.addGetterSetter(Ec,`verticalAlign`,ac),X.addGetterSetter(Ec,`lineHeight`,1,Y()),X.addGetterSetter(Ec,`wrap`,pc),X.addGetterSetter(Ec,`ellipsis`,!1,ja()),X.addGetterSetter(Ec,`letterSpacing`,0,Y()),X.addGetterSetter(Ec,`text`,``,Oa()),X.addGetterSetter(Ec,`textDecoration`,``),X.addGetterSetter(Ec,`underlineOffset`,void 0,Y()),X.addGetterSetter(Ec,`charRenderFunc`,void 0);var Dc=[...Ec.prototype._attrsAffectingSize,`width`,`height`,`pointerDirection`,`pointerWidth`,`pointerHeight`].map(e=>e+`Change.konva`).join(` `),Oc=`none`,kc=`up`,Ac=`right`,jc=`down`,Mc=`left`,Nc=class extends cs{constructor(e){super(e),this._sync=this._sync.bind(this),this.on(`add.konva`,function(e){e.child.off(Dc,this._sync).on(Dc,this._sync),this._sync()})}getText(){return this.find(`Text`)[0]}getTag(){return this.find(`Tag`)[0]}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let e=this.getText(),t=this.getTag(),n,r,i,a,o,s,c;if(e&&t){switch(n=e.width(),r=e.height(),i=t.pointerDirection(),a=t.pointerWidth(),c=t.pointerHeight(),o=0,s=0,i){case kc:o=n/2,s=-1*c;break;case Ac:o=n+a,s=r/2;break;case jc:o=n/2,s=r+c;break;case Mc:o=-1*a,s=r/2}t.setAttrs({x:-1*o,y:-1*s,width:n,height:r}),e.setAttrs({x:-1*o,y:-1*s})}}};Nc.prototype.className=`Label`,Si(Nc);var Pc=class extends Q{_sceneFunc(e){let t=this.width(),n=this.height(),r=this.pointerDirection(),i=this.pointerWidth(),a=this.pointerHeight(),o=this.cornerRadius(),[s,c,l,u]=q._cornerRadii(o,t,n);e.beginPath(),e.moveTo(s,0),r===kc&&(e.lineTo((t-i)/2,0),e.lineTo(t/2,-1*a),e.lineTo((t+i)/2,0)),e.lineTo(t-c,0),e.arc(t-c,c,c,Math.PI*3/2,0,!1),r===Ac&&(e.lineTo(t,(n-a)/2),e.lineTo(t+i,n/2),e.lineTo(t,(n+a)/2)),e.lineTo(t,n-l),e.arc(t-l,n-l,l,0,Math.PI/2,!1),r===jc&&(e.lineTo((t+i)/2,n),e.lineTo(t/2,n+a),e.lineTo((t-i)/2,n)),e.lineTo(u,n),e.arc(u,n-u,u,Math.PI/2,Math.PI,!1),r===Mc&&(e.lineTo(0,(n+a)/2),e.lineTo(-1*i,n/2),e.lineTo(0,(n-a)/2)),e.lineTo(0,s),e.arc(s,s,s,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=this.pointerWidth(),t=this.pointerHeight(),n=this.pointerDirection(),r=this.width(),i=this.height();return n===kc||n===jc?{x:Math.min(0,(r-e)/2),y:n===kc?-t:0,width:Math.max(r,e),height:i+t}:n===Mc||n===Ac?{x:n===Mc?-e:0,y:Math.min(0,(i-t)/2),width:r+e,height:Math.max(i,t)}:{x:0,y:0,width:r,height:i}}};Pc.prototype.className=`Tag`,Si(Pc,!0),X.addGetterSetter(Pc,`pointerDirection`,Oc),X.addGetterSetter(Pc,`pointerWidth`,0,Y()),X.addGetterSetter(Pc,`pointerHeight`,0,Y()),X.addGetterSetter(Pc,`cornerRadius`,0,Ea(4));var Fc=class extends Q{_getStrokePadding(){return super._getStrokePadding(this.strokeScaleEnabled()?1:void 0)}_sceneFunc(e){let t=this.cornerRadius(),n=this.width(),r=this.height();e.beginPath(),t?q.drawRoundedRectPath(e,n,r,t):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}};Fc.prototype.className=`Rect`,Si(Fc,!0),X.addGetterSetter(Fc,`cornerRadius`,0,Ea(4));var Ic=class extends Q{_sceneFunc(e){let t=this._getPoints(),n=this.radius(),r=this.sides(),i=this.cornerRadius();if(t.length){if(e.beginPath(),i)q.drawRoundedPolygonPath(e,t,r,n,i);else{e.moveTo(t[0].x,t[0].y);for(let n=1;n<t.length;n++)e.lineTo(t[n].x,t[n].y)}e.closePath(),e.fillStrokeShape(this)}}_getPoints(){let e=this.attrs.sides,t=this.attrs.radius||0,n=[];for(let r=0;r<e;r++)n.push({x:t*Math.sin(r*2*Math.PI/e),y:-1*t*Math.cos(r*2*Math.PI/e)});return n}getSelfRect(){let e=this._getPoints();if(!e.length)return{x:0,y:0,width:0,height:0};let t=e[0].x,n=e[0].x,r=e[0].y,i=e[0].y;return e.forEach(e=>{t=Math.min(t,e.x),n=Math.max(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.y)}),{x:t,y:r,width:n-t,height:i-r}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};Ic.prototype.className=`RegularPolygon`,Ic.prototype._centroid=!0,Ic.prototype._attrsAffectingSize=[`radius`,`sides`],Si(Ic,!0),X.addGetterSetter(Ic,`radius`,0,Y()),X.addGetterSetter(Ic,`sides`,0,Y()),X.addGetterSetter(Ic,`cornerRadius`,0,Ea(4));var Lc=Math.PI*2,Rc=class extends Q{_getStrokePadding(){return super._getStrokePadding(1)}_sceneFunc(e){let t=Math.abs(this.innerRadius()),n=Math.abs(this.outerRadius());e.beginPath(),e.arc(0,0,t,0,Lc,!1),e.moveTo(n,0),e.arc(0,0,n,Lc,0,!0),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=Math.max(Math.abs(this.innerRadius()),Math.abs(this.outerRadius()));return{x:-e,y:-e,width:e*2,height:e*2}}getWidth(){return Math.abs(this.outerRadius())*2}getHeight(){return Math.abs(this.outerRadius())*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};Rc.prototype.className=`Ring`,Rc.prototype._centroid=!0,Rc.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`],Si(Rc,!0),X.addGetterSetter(Rc,`innerRadius`,0,Y()),X.addGetterSetter(Rc,`outerRadius`,0,Y());var zc=class extends Q{constructor(e){super(e),this._updated=!0,this.anim=new us(()=>{let e=this._updated;return this._updated=!1,e}),this.on(`animationChange.konva`,function(){this.frameIndex(0)}),this.on(`frameIndexChange.konva`,function(){this._updated=!0}),this.on(`frameRateChange.konva`,function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_getFrame(){let e=this.animation(),t=this.animations()?.[e],n=this.frameIndex(),r=n*4;if(!t||!Number.isInteger(n)||r<0||r+4>t.length)return;let i=this.frameOffsets()?.[e]||[];return{x:t[r],y:t[r+1],width:t[r+2],height:t[r+3],offsetX:i[n*2]||0,offsetY:i[n*2+1]||0}}_getStrokePadding(){return super._getStrokePadding(this.strokeScaleEnabled()?1:void 0)}_sceneFunc(e){let t=this._getFrame();if(!t)return;let{x:n,y:r,width:i,height:a,offsetX:o,offsetY:s}=t,c=this.image();(this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(o,s,i,a),e.closePath(),e.fillStrokeShape(this)),c&&e.drawImage(c,n,r,i,a,o,s,i,a)}_hitFunc(e){let{x:t,y:n,width:r,height:i}=this.getSelfRect();e.beginPath(),e.rect(t,n,r,i),e.closePath(),e.fillShape(this)}getSelfRect(){let e=this._getFrame();return e?{x:e.offsetX,y:e.offsetY,width:e.width,height:e.height}:{x:0,y:0,width:0,height:0}}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){return super._useBufferCanvas(!0,t)}_setInterval(){let e=this;this.interval=setInterval(function(){e._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;let e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}destroy(){return this.stop(),super.destroy()}isRunning(){return this.anim.isRunning()}_updateIndex(){let e=this.frameIndex(),t=this.animations()?.[this.animation()],n=t?t.length/4:0;this.frameIndex(e<n-1?e+1:0)}};zc.prototype.className=`Sprite`,Si(zc,!0),X.addGetterSetter(zc,`animation`),X.addGetterSetter(zc,`animations`),X.addGetterSetter(zc,`frameOffsets`),X.addGetterSetter(zc,`image`),X.addGetterSetter(zc,`frameIndex`,0,Y()),X.addGetterSetter(zc,`frameRate`,17,Y()),X.backCompat(zc,{index:`frameIndex`,getIndex:`getFrameIndex`,setIndex:`setFrameIndex`});var Bc=class extends Q{_sceneFunc(e){let t=this.innerRadius(),n=this.outerRadius(),r=this.numPoints();e.beginPath(),e.moveTo(0,0-n);for(let i=1;i<r*2;i++){let a=i%2==0?n:t,o=a*Math.sin(i*Math.PI/r),s=-1*a*Math.cos(i*Math.PI/r);e.lineTo(o,s)}e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=Math.max(Math.abs(this.innerRadius()),Math.abs(this.outerRadius()));return{x:-e,y:-e,width:e*2,height:e*2}}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};Bc.prototype.className=`Star`,Bc.prototype._centroid=!0,Bc.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`],Si(Bc,!0),X.addGetterSetter(Bc,`numPoints`,5,Y()),X.addGetterSetter(Bc,`innerRadius`,0,Y()),X.addGetterSetter(Bc,`outerRadius`,0,Y());var Vc=``,Hc=`normal`;function Uc(e){e.fillText(this.partialText,0,0)}function Wc(e){e.strokeText(this.partialText,0,0)}var Gc=class extends Q{constructor(e){super(e),this.dataArray=[],this._readDataAttribute(),this._setTextData()}_getTextPathLength(){return Vs.getPathLength(this.dataArray)}_getPointAtLength(e,t){return!this.attrs.data||e>this.pathLength?null:Vs.getPointAtLengthOfDataArray(e,this.dataArray,t)}_readDataAttribute(){this.dataArray=Vs.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(e){e.setAttr(`font`,this._getContextFont()),e.setAttr(`textBaseline`,this.textBaseline()),e.setAttr(`textAlign`,`left`),e.save();let t=this.textDecoration(),n=this.fill(),r=this.fontSize(),i=this.glyphInfo,a=t.indexOf(`underline`)!==-1,o=t.indexOf(`line-through`)!==-1;a&&e.beginPath();for(let t=0;t<i.length;t++){e.save();let n=i[t].p0;e.translate(n.x,n.y),e.rotate(i[t].rotation),this.partialText=i[t].text,e.fillStrokeShape(this),a&&(t===0&&e.moveTo(0,r/2+1),e.lineTo(i[t].width,r/2+1)),e.restore()}if(a&&(e.strokeStyle=n,e.lineWidth=qs(r),e.stroke()),o){e.beginPath();for(let t=0;t<i.length;t++){e.save();let n=i[t].p0;e.translate(n.x,n.y),e.rotate(i[t].rotation),t===0&&e.moveTo(0,0),e.lineTo(i[t].width,0),e.restore()}e.strokeStyle=n,e.lineWidth=qs(r),e.stroke()}e.restore()}_hitFunc(e){e.beginPath();let t=this.glyphInfo;if(t.length>=1){let n=t[0].p0;e.moveTo(n.x,n.y)}for(let n=0;n<t.length;n++){let r=t[n].p1;e.lineTo(r.x,r.y)}e.setAttr(`lineWidth`,this.fontSize()),e.setAttr(`strokeStyle`,this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return q.warn(`text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height.`),this.textHeight}setText(e){return Ec.prototype.setText.call(this,e)}_getContextFont(){return Ec.prototype._getContextFont.call(this)}_getTextSize(e){let t=Sc();t.save(),t.font=this._getContextFont(),t.fontKerning=`auto`;let n=t.measureText(e);return t.restore(),{width:n.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){let e=Js(this.text());this.direction()===`rtl`&&e.reverse();let t=this.kerningFunc(),n=[],r=0;for(let i=0;i<e.length;i++){let a=0;if(t&&i>0)try{a=t(e[i-1],e[i])*this.fontSize()}catch{}n.push({char:e[i],width:this._getTextSize(e[i]).width,kern:a}),r+=n[i].width+a}let{width:i,height:a}=this._getTextSize(this.attrs.text);if(this.textWidth=r,this.textHeight=a,this.glyphInfo=[],!this.attrs.data)return null;let o=this.letterSpacing(),s=this.align(),c=s===`justify`?this.text().split(` `).length-1:0,l=Math.max(0,r-i),u=Math.max(this.textWidth+(e.length-1)*o,0),d=0;s===`center`&&(d=Math.max(0,this.pathLength/2-u/2)),s===`right`&&(d=Math.max(0,this.pathLength-u));let f=d,p=this.dataArray.some((e,t)=>t>0&&e.command===`M`)?void 0:{index:0,offset:0};for(let t=0;t<n.length;t++){f+=n[t].kern;let r=this._getPointAtLength(f,p);if(!r)return;let i=n[t].char,a=n[t].width+(t<n.length-1?o:0);i===` `&&s===`justify`&&(a+=(this.pathLength-u)/c);let d=f+a,m=this._getPointAtLength(d>this.pathLength&&d-this.pathLength<=l?this.pathLength:d,p);if(!m)return;let h=Vs.getLineLength(r.x,r.y,m.x,m.y),g=Math.atan2(m.y-r.y,m.x-r.x);this.glyphInfo.push({text:e[t],rotation:g,p0:r,p1:m,width:h}),f+=a}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};let e=[];this.glyphInfo.forEach(function(t){e.push(t.p0.x),e.push(t.p0.y),e.push(t.p1.x),e.push(t.p1.y)});let t=q._getPointsRect(e),n=this.fontSize();return{x:t.x-n/2,y:t.y-n/2,width:t.width+n,height:t.height+n}}getStrokeScaleEnabled(){return!0}_getSelfRectForDrawing(){let e=this.getSelfRect(),t=this.fontSize();return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}};Gc.prototype._fillFunc=Uc,Gc.prototype._strokeFunc=Wc,Gc.prototype._fillFuncHit=Uc,Gc.prototype._strokeFuncHit=Wc,Gc.prototype.className=`TextPath`,Gc.prototype._attrsAffectingSize=[`text`,`fontSize`,`data`,`align`,`letterSpacing`,`kerningFunc`,`fontFamily`,`fontStyle`,`fontVariant`,`direction`],Si(Gc,!0),Gc.prototype.on(`dataChange.konva`,function(){this._readDataAttribute(),this._setTextData()}),Gc.prototype.on(Gc.prototype._attrsAffectingSize.filter(e=>e!==`data`).map(e=>e+`Change.konva`).join(` `),function(){this._setTextData()}),X.addGetterSetter(Gc,`data`),X.addGetterSetter(Gc,`fontFamily`,`Arial`),X.addGetterSetter(Gc,`fontSize`,12,Y()),X.addGetterSetter(Gc,`fontStyle`,Hc),X.addGetterSetter(Gc,`align`,`left`),X.addGetterSetter(Gc,`letterSpacing`,0,Y()),X.addGetterSetter(Gc,`textBaseline`,`middle`),X.addGetterSetter(Gc,`fontVariant`,Hc),X.addGetterSetter(Gc,`text`,Vc),X.addGetterSetter(Gc,`textDecoration`,``),X.addGetterSetter(Gc,`kerningFunc`,void 0),X.addGetterSetter(Gc,`direction`,`inherit`);var Kc=`tr-konva`,qc=[`resizeEnabledChange`,`rotateAnchorOffsetChange`,`rotateAnchorAngleChange`,`rotateEnabledChange`,`enabledAnchorsChange`,`anchorSizeChange`,`borderEnabledChange`,`shouldOverdrawWholeAreaChange`,`borderStrokeChange`,`borderStrokeWidthChange`,`borderDashChange`,`anchorStrokeChange`,`anchorStrokeWidthChange`,`anchorFillChange`,`anchorCornerRadiusChange`,`ignoreStrokeChange`,`anchorStyleFuncChange`,`paddingChange`].map(e=>e+`.${Kc}`).join(` `),Jc=`nodesRect`,Yc=[`widthChange`,`heightChange`,`scaleXChange`,`scaleYChange`,`skewXChange`,`skewYChange`,`rotationChange`,`offsetXChange`,`offsetYChange`,`transformsEnabledChange`,`strokeWidthChange`,`strokeChange`,`selfRectFuncChange`,`strokeLinearGradientColorStopsChange`,`strokeScaleEnabledChange`,`strokeEnabledChange`,`draggableChange`],Xc={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},Zc=`ontouchstart`in K._global;function Qc(e,t,n){if(e===`rotater`)return n;t+=q.degToRad(Xc[e]||0);let r=(q.radToDeg(t)%360+360)%360;return q._inRange(r,337.5,360)||q._inRange(r,0,22.5)?`ns-resize`:q._inRange(r,22.5,67.5)?`nesw-resize`:q._inRange(r,67.5,112.5)?`ew-resize`:q._inRange(r,112.5,157.5)?`nwse-resize`:q._inRange(r,157.5,202.5)?`ns-resize`:q._inRange(r,202.5,247.5)?`nesw-resize`:q._inRange(r,247.5,292.5)?`ew-resize`:q._inRange(r,292.5,337.5)?`nwse-resize`:(q.error(`Transformer has unknown angle for cursor detection: `+r),`pointer`)}var $c=[`top-left`,`top-center`,`top-right`,`middle-right`,`middle-left`,`bottom-left`,`bottom-center`,`bottom-right`];function el(e){return{x:e.x+e.width/2*Math.cos(e.rotation)+e.height/2*Math.sin(-e.rotation),y:e.y+e.height/2*Math.cos(e.rotation)+e.width/2*Math.sin(e.rotation)}}function tl(e,t,n){let r=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),i=n.y+(e.x-n.x)*Math.sin(t)+(e.y-n.y)*Math.cos(t);return{...e,rotation:e.rotation+t,x:r,y:i}}function nl(e,t){return tl(e,t,el(e))}function rl(e,t,n){let r=t,i=n;for(let n=0;n<e.length;n++){let a=K.getAngle(e[n]),o=Math.abs(a-t)%(Math.PI*2),s=Math.min(o,Math.PI*2-o);s<i&&(i=s,r=a)}return r}function il(e,t,n){let r=q.degToRad(e.rotateAnchorAngle()),i=Math.sin(r),a=-Math.cos(r),o=t/2,s=n/2,c=1/0;a<0?c=Math.min(c,-s/a):a>0&&(c=Math.min(c,(n-s)/a)),i<0?c=Math.min(c,-o/i):i>0&&(c=Math.min(c,(t-o)/i));let l=o+i*c,u=s+a*c,d=e.rotateAnchorOffset()+e.padding();return{edgeX:l,edgeY:u,endX:l+i*d,endY:u+a*d}}var al=new Set,$=class extends cs{static _isLayerTransforming(e){for(let t of al)if(t.getLayer()===e||t._nodes.some(t=>t.getLayer()===e))return!0;return!1}constructor(e){super(e),this._movingAnchorName=null,this._anchors={},this._transforming=!1,this._fitting=!1,this._transformWindow=null,this._elementsCreated=!1,this._updateScheduled=!1,this._subtreeChanged=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(qc,e=>{e.type===`ignoreStrokeChange`&&this._resetTransformCache(),this.update()}),this.on(`rotationChange.${Kc}`,()=>this._clearCache(Jc)),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return q.warn(`tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead.`),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return Kc+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();let t=new Set(e);for(let e of t)e.isAncestorOf(this)&&(q.error(`Konva.Transformer cannot be an a child of the node you are trying to attach`),t.delete(e));let n=Array.from(t).filter(e=>{for(let n=e.getParent();n;n=n.getParent())if(t.has(n))return!1;return!0});return this._nodes=e=n,e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(e=>{let t=()=>{var t;if(this._fitting){(t=this._nodeRectCache)==null||t.delete(e);return}this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(e),this.isDragging()||this._scheduleUpdate()};if(e._attrsAffectingSize.length){let n=e._attrsAffectingSize.map(e=>e+`Change.`+this._getEventNamespace()).join(` `);e.on(n,t)}e.on(Yc.map(e=>e+`.${this._getEventNamespace()}`).join(` `),t),e.on(`absoluteTransformChange.${this._getEventNamespace()}`,t),e instanceof $a&&e._addSubtreeObserver(this),e.on(`destroy.${this._getEventNamespace()}`,()=>{this.setNodes(this._nodes.filter(t=>t!==e))}),this._proxyDrag(e)}),this._resetTransformCache(),this._elementsCreated&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,n=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this._back&&this.startDrag(n,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,n=>{if(!t)return;let r=e.getAbsolutePosition(),i=r.x-t.x,a=r.y-t.y;this.nodes().forEach(t=>{if(t===e||t.isDragging())return;let r=t.getAbsolutePosition();t.setAbsolutePosition({x:r.x+i,y:r.y+a}),t.startDrag(n)}),t=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){var e;this._nodes&&this._nodes.forEach(e=>{e.off(`.`+this._getEventNamespace()),e._removeSubtreeObserver(this)}),this._nodes=[],this._resetTransformCache(),(e=this.getLayer())==null||e.batchDraw()}_resetTransformCache(e){var t,n;e?(t=this._nodeRectCache)==null||t.delete(e):(n=this._nodeRectCache)==null||n.clear(),this._clearCache(Jc),this._clearCache(`transform`),this._clearSelfAndDescendantCache(`absoluteTransform`)}_onSubtreeChange(e){var t;this._fitting||(!this._subtreeChanged||this._cache[Jc])&&(this._resetTransformCache(e),this._subtreeChanged||(this._subtreeChanged=!0,q.requestAnimFrame(()=>this._syncSubtreeChange(),this.getStage()?._getOwnerWindow()),(t=this.getLayer())==null||t.batchDraw()))}_syncSubtreeChange(){this._subtreeChanged&&this._nodes?.length&&!this.isDragging()&&this._update()}drawScene(e,t){return this._syncSubtreeChange(),super.drawScene(e,t)}drawHit(e,t){return this._syncSubtreeChange(),super.drawHit(e,t)}_getNodeRect(){return this._getCache(Jc,this.__getNodeRect)}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};let e=K.getAngle(this.rotation()),t=this.ignoreStroke(),n=new Ti;n.rotate(-e);let r=this._nodeRectCache||=new Map,i=1/0,a=1/0,o=-1/0,s=-1/0;for(let c of this.nodes()){let l=c instanceof Q&&c.getSelfRect===Q.prototype.getSelfRect&&!c.attrs.selfRectFunc&&!c._hasCachedAncestor(),u=l?c.width():0,d=l?c.height():0;l&&(c._attrsVersion??=0);let f=l?r.get(c):void 0;if(!f||f.rotation!==e||f.ignoreStroke!==t||f.version!==c._attrsVersion||f.width!==u||f.height!==d){let i=c.getAbsoluteTransform(),[a,o,s,p]=i.getMatrix(),m=a*p-o*s===0,h=c.getClientRect({skipTransform:!m,skipShadow:!0,skipStroke:t}),g=[{x:h.x,y:h.y},{x:h.x+h.width,y:h.y},{x:h.x+h.width,y:h.y+h.height},{x:h.x,y:h.y+h.height}];m&&(i=new Ti),f={rotation:e,ignoreStroke:t,width:u,height:d,version:c._attrsVersion||0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(let e of g){let t=n.point(i.point(e));f.minX=Math.min(f.minX,t.x),f.minY=Math.min(f.minY,t.y),f.maxX=Math.max(f.maxX,t.x),f.maxY=Math.max(f.maxY,t.y)}l&&r.set(c,f)}i=Math.min(i,f.minX),a=Math.min(a,f.minY),o=Math.max(o,f.maxX),s=Math.max(s,f.maxY)}n.invert();let c=n.point({x:i,y:a});return{x:c.x,y:c.y,width:o-i,height:s-a,rotation:K.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),$c.forEach(e=>{this._createAnchor(e)}),this._createAnchor(`rotater`),this._elementsCreated=!0}_createAnchor(e){let t=new Fc({stroke:`rgb(0, 161, 255)`,fill:`white`,strokeWidth:1,name:e+` _anchor`,dragDistance:0,draggable:!0,hitStrokeWidth:Zc?10:`auto`});this._anchors[e]=t;let n=this;t.on(`mousedown touchstart`,function(e){n._handleMouseDown(e)}),t.on(`dragstart`,e=>{t.stopDrag(),e.cancelBubble=!0}),t.on(`dragend`,e=>{e.cancelBubble=!0}),t.on(`mouseenter`,()=>{if(this.isTransforming())return;let n=Qc(e,K.getAngle(this.rotation()),this.rotateAnchorCursor());t.getStage().content&&(t.getStage().content.style.cursor=n),this._cursorChange=!0}),t.on(`mouseout`,()=>{this._cursorChange=!1,!this.isTransforming()&&t.getStage().content&&(t.getStage().content.style.cursor=``)}),this.add(t)}_createBack(){let e=new Q({name:`back`,width:0,height:0,sceneFunc(e,t){let n=t.getParent();if(!n.borderEnabled())return;let r=n.padding(),i=t.width(),a=t.height();if(e.beginPath(),e.rect(-r,-r,i+r*2,a+r*2),n.rotateEnabled()&&n.rotateLineVisible()){let t=il(n,i,a);e.moveTo(t.edgeX,t.edgeY),e.lineTo(t.endX,t.endY)}e.fillStrokeShape(t)},hitFunc:(e,t)=>{if(!this.shouldOverdrawWholeArea())return;let n=this.padding();e.beginPath(),e.rect(-n,-n,t.width()+n*2,t.height()+n*2),e.fillStrokeShape(t)}});this._back=e,this.add(e),this._proxyDrag(e),e.on(`dragstart`,e=>{e.cancelBubble=!0}),e.on(`dragmove`,e=>{e.cancelBubble=!0}),e.on(`dragend`,e=>{e.cancelBubble=!0}),this.on(`dragmove`,e=>{this.update()})}_handleMouseDown(e){if(e.evt.button!==void 0&&!K.dragButtons.includes(e.evt.button)||this._transforming)return;this._movingAnchorName=e.target.name().split(` `)[0];let t=this._getNodeRect(),n=t.width,r=t.height,i=Math.sqrt(n**2+r**2);this.sin=Math.abs(r/i),this.cos=Math.abs(n/i);let a=this.getStage()?._getOwnerWindow();this._transformWindow=a||null,a&&(a.addEventListener(`mousemove`,this._handleMouseMove),a.addEventListener(`touchmove`,this._handleMouseMove),a.addEventListener(`mouseup`,this._handleMouseUp,!0),a.addEventListener(`touchend`,this._handleMouseUp,!0),a.addEventListener(`touchcancel`,this._handleMouseUp,!0)),this._transforming=!0,this._pointerId=e.pointerId??q._getFirstPointerId(e.evt);let o=e.target.getAbsolutePosition(),s=e.target.getStage()._getPointerById(this._pointerId);this._anchorDragOffset={x:s.x-o.x,y:s.y-o.y},al.add(this),this._fire(`transformstart`,{evt:e.evt,target:this.getNode()}),this._nodes.forEach(t=>{t._fire(`transformstart`,{evt:e.evt,target:t})})}_handleMouseMove(e){var t;(t=this.getStage())==null||t._batchEvents(()=>this._moveTransform(e))}_moveTransform(e){this._syncSubtreeChange();let t,n,r,i=this._anchors[this._movingAnchorName],a=i.getStage();a.setPointersPositions(e);let o=a._getPointerById(this._pointerId);if(!o)return;let s={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y},c=i.getAbsolutePosition();this.anchorDragBoundFunc()&&(s=this.anchorDragBoundFunc()(c,s,e)),i.setAbsolutePosition(s);let l=i.getAbsolutePosition();if(c.x===l.x&&c.y===l.y)return;if(this._movingAnchorName===`rotater`){let r=this._getNodeRect();t=i.x()-r.width/2,n=-i.y()+r.height/2;let a=q.degToRad(this.rotateAnchorAngle()),o=Math.atan2(-n,t)+Math.PI/2-a,s=K.getAngle(this.rotation())+o,c=K.getAngle(this.rotationSnapTolerance()),l=nl(r,rl(this.rotationSnaps(),s,c)-r.rotation);this._fitNodesInto(l,e);return}let u=this.shiftBehavior(),d;d=u===`inverted`?this.keepRatio()&&!e.shiftKey:u===`none`?this.keepRatio():this.keepRatio()||e.shiftKey;let f=this.centeredScaling()||e.altKey,p=!1;if(this._movingAnchorName===`top-left`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`bottom-right`].x(),y:this._anchors[`bottom-right`].y()};r=Math.sqrt((e.x-i.x())**2+(e.y-i.y())**2);let a=this._anchors[`top-left`].x()>e.x?-1:1,o=this._anchors[`top-left`].y()>e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this._anchors[`top-left`].x(e.x-t),this._anchors[`top-left`].y(e.y-n)}}else if(this._movingAnchorName===`top-center`)this._anchors[`top-left`].y(i.y());else if(this._movingAnchorName===`top-right`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`bottom-left`].x(),y:this._anchors[`bottom-left`].y()};r=Math.sqrt((i.x()-e.x)**2+(e.y-i.y())**2);let a=this._anchors[`top-right`].x()<e.x?-1:1,o=this._anchors[`top-right`].y()>e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this._anchors[`top-right`].x(e.x+t),this._anchors[`top-right`].y(e.y-n)}var m=i.position();this._anchors[`top-left`].y(m.y),this._anchors[`bottom-right`].x(m.x)}else if(this._movingAnchorName===`middle-left`)this._anchors[`top-left`].x(i.x());else if(this._movingAnchorName===`middle-right`)this._anchors[`bottom-right`].x(i.x());else if(this._movingAnchorName===`bottom-left`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`top-right`].x(),y:this._anchors[`top-right`].y()};r=Math.sqrt((e.x-i.x())**2+(i.y()-e.y)**2);let a=e.x<i.x()?-1:1,o=i.y()<e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,i.x(e.x-t),i.y(e.y+n)}m=i.position(),this._anchors[`top-left`].x(m.x),this._anchors[`bottom-right`].y(m.y)}else if(this._movingAnchorName===`bottom-center`)this._anchors[`bottom-right`].y(i.y());else if(this._movingAnchorName===`bottom-right`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`top-left`].x(),y:this._anchors[`top-left`].y()};r=Math.sqrt((i.x()-e.x)**2+(i.y()-e.y)**2);let a=this._anchors[`bottom-right`].x()<e.x?-1:1,o=this._anchors[`bottom-right`].y()<e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this._anchors[`bottom-right`].x(e.x+t),this._anchors[`bottom-right`].y(e.y+n)}}else console.error(Error(`Wrong position argument of selection resizer: `+this._movingAnchorName));if(f=this.centeredScaling()||e.altKey,f){let e=this._anchors[`top-left`],t=this._anchors[`bottom-right`],n=e.x(),r=e.y(),i=this.getWidth()-t.x(),a=this.getHeight()-t.y();t.move({x:-n,y:-r}),e.move({x:i,y:a})}let h=this._anchors[`top-left`].getAbsolutePosition();t=h.x,n=h.y;let g=this._anchors[`bottom-right`].x()-this._anchors[`top-left`].x(),_=this._anchors[`bottom-right`].y()-this._anchors[`top-left`].y();this._fitNodesInto({x:t,y:n,width:g,height:_,rotation:K.getAngle(this.rotation())},e,p)}_handleMouseUp(e){let t=this.getStage();t&&(t.setPointersPositions(e),!t._changedPointerPositions.some(e=>e.id===this._pointerId))||(t?t._batchEvents(()=>this._removeEvents(e)):this._removeEvents(e))}getAbsoluteTransform(e){let t=this.getTransform();return e?e.getAbsoluteTransform().copy().invert().multiply(t):t}_removeEvents(e){var t;if(this._transforming){this._transforming=!1;let n=this.getStage()?.content;n&&!this._cursorChange&&(n.style.cursor=``);let r=this._transformWindow;this._transformWindow=null,r&&(r.removeEventListener(`mousemove`,this._handleMouseMove),r.removeEventListener(`touchmove`,this._handleMouseMove),r.removeEventListener(`mouseup`,this._handleMouseUp,!0),r.removeEventListener(`touchend`,this._handleMouseUp,!0),r.removeEventListener(`touchcancel`,this._handleMouseUp,!0));let i=this.getNode();al.delete(this),this._fire(`transformend`,{evt:e,target:i}),(t=this.getLayer())==null||t.batchDraw(),i&&this._nodes.forEach(t=>{var n;t._fire(`transformend`,{evt:e,target:t}),(n=t.getLayer())==null||n.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(e,t,n=!1){this._fitting=!0;try{return this._doFitNodesInto(e,t,n)}finally{this._fitting=!1}}_doFitNodesInto(e,t,n=!1){let r=this._getNodeRect();if(!r.width||!r.height||q._inRange(e.width,-this.padding()*2-1,1)||q._inRange(e.height,-this.padding()*2-1,1)){this.update();return}let i=new Ti;i.rotate(K.getAngle(this.rotation()));let a=n?0:this.padding()*2,o=null,s=null;if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf(`left`)>=0){let t=i.point({x:-a,y:0});e.x+=t.x,e.y+=t.y,e.width+=a,o={axis:`width`,from:`left`,to:`right`,offset:t}}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf(`right`)>=0){let t=i.point({x:a,y:0});e.width+=a,o={axis:`width`,from:`right`,to:`left`,offset:t}}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf(`top`)>=0){let t=i.point({x:0,y:-a});e.x+=t.x,e.y+=t.y,e.height+=a,s={axis:`height`,from:`top`,to:`bottom`,offset:t}}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf(`bottom`)>=0){let t=i.point({x:0,y:a});e.height+=a,s={axis:`height`,from:`bottom`,to:`top`,offset:t}}if(this.boundBoxFunc()){let t=this.boundBoxFunc()(r,e);t?e=t:q.warn(`boundBoxFunc returned falsy. You should return new bound rect from it!`)}for(let t of[o,s])t&&e[t.axis]<0&&this._movingAnchorName&&(this._movingAnchorName=this._movingAnchorName.replace(t.from,t.to),this._anchorDragOffset.x-=t.offset.x,this._anchorDragOffset.y-=t.offset.y);let c=1e7,l=new Ti;l.translate(r.x,r.y),l.rotate(r.rotation),l.scale(r.width/c,r.height/c);let u=new Ti,d=e.width/c,f=e.height/c;this.flipEnabled()===!1?(u.translate(e.x,e.y),u.rotate(e.rotation),u.translate(e.width<0?e.width:0,e.height<0?e.height:0),u.scale(Math.abs(d),Math.abs(f))):(u.translate(e.x,e.y),u.rotate(e.rotation),u.scale(d,f));let p=u.multiply(l.invert()),m=new Set;this._nodes.forEach(e=>{if(!e.getStage())return;let t=e.getParent().getAbsoluteTransform(),n=e.getTransform().copy();n.translate(e.offsetX(),e.offsetY());let r=new Ti;r.multiply(t.copy().invert()).multiply(p).multiply(t).multiply(n);let i=r.decompose();e.setAttrs(i);let a=e.getLayer();a&&m.add(a)}),this.rotation(q._getRotation(e.rotation)),this._nodes.forEach(e=>{this._fire(`transform`,{evt:t,target:e}),e._fire(`transform`,{evt:t,target:e})}),this._resetTransformCache(),this.update(),m.add(this.getLayer()),m.forEach(e=>e&&e.batchDraw())}_scheduleUpdate(){this._updateScheduled||(this._updateScheduled=!0,Z._runAfterAbsTransformCascade(()=>{this._updateScheduled=!1,!(!this._nodes?.length||this._fitting||this.isDragging())&&this._update()}))}forceUpdate(){this._resetTransformCache(),this.update()}update(){this._lastNodeRect=void 0,this._update()}_update(){var e;this._subtreeChanged=!1;let t=this._getNodeRect();this._updateElements(t);let n=this.nodes().some(e=>e.draggable());this._back.draggable()!==n&&this._back.draggable(n);let r=this.anchorStyleFunc();r&&Object.values(this._anchors).forEach(e=>r(e)),(e=this.getLayer())==null||e.batchDraw()}_updateElements(e){let t=this._lastNodeRect;if(t&&!this.anchorStyleFunc()&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height&&e.rotation===t.rotation)return;this._lastNodeRect={...e};let n=e.width,r=e.height,i=this.enabledAnchors(),a=this.resizeEnabled(),o=this.padding(),s=this.anchorSize();Object.values(this._anchors).forEach(e=>{e.setAttrs({width:s,height:s,offsetX:s/2,offsetY:s/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._anchors[`top-left`].setAttrs({x:0,y:0,offsetX:s/2+o,offsetY:s/2+o,visible:a&&i.indexOf(`top-left`)>=0}),this._anchors[`top-center`].setAttrs({x:n/2,y:0,offsetY:s/2+o,visible:a&&i.indexOf(`top-center`)>=0}),this._anchors[`top-right`].setAttrs({x:n,y:0,offsetX:s/2-o,offsetY:s/2+o,visible:a&&i.indexOf(`top-right`)>=0}),this._anchors[`middle-left`].setAttrs({x:0,y:r/2,offsetX:s/2+o,visible:a&&i.indexOf(`middle-left`)>=0}),this._anchors[`middle-right`].setAttrs({x:n,y:r/2,offsetX:s/2-o,visible:a&&i.indexOf(`middle-right`)>=0}),this._anchors[`bottom-left`].setAttrs({x:0,y:r,offsetX:s/2+o,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-left`)>=0}),this._anchors[`bottom-center`].setAttrs({x:n/2,y:r,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-center`)>=0}),this._anchors[`bottom-right`].setAttrs({x:n,y:r,offsetX:s/2-o,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-right`)>=0});let c=il(this,n,r);this._anchors.rotater.setAttrs({x:c.endX,y:c.endY,visible:this.rotateEnabled()}),this._back.setAttrs({width:n,height:r,visible:this.borderEnabled()||this.shouldOverdrawWholeArea(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0})}isTransforming(){return this._transforming}stopTransform(){this._transforming&&this._removeEvents()}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=``),cs.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(q.error(`You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead.`),this):super.add(...e)}toObject(){return Z.prototype.toObject.call(this)}clone(e){return Z.prototype.clone.call(this,e)}getClientRect(e){return this.nodes().length>0?super.getClientRect(e):{x:0,y:0,width:0,height:0}}};$.isTransforming=()=>al.size>0;function ol(e){return e instanceof Array||q.warn(`enabledAnchors value should be an array`),e instanceof Array&&e.forEach(function(e){$c.indexOf(e)===-1&&q.warn(`Unknown anchor name: `+e+`. Available names are: `+$c.join(`, `))}),e||[]}$.prototype.className=`Transformer`,Si($),X.addGetterSetter($,`enabledAnchors`,$c,ol),X.addGetterSetter($,`flipEnabled`,!0,ja()),X.addGetterSetter($,`resizeEnabled`,!0),X.addGetterSetter($,`anchorSize`,10,Y()),X.addGetterSetter($,`rotateEnabled`,!0),X.addGetterSetter($,`rotateLineVisible`,!0),X.addGetterSetter($,`rotationSnaps`,[]),X.addGetterSetter($,`rotateAnchorOffset`,50,Y()),X.addGetterSetter($,`rotateAnchorAngle`,0,Y()),X.addGetterSetter($,`rotateAnchorCursor`,`crosshair`),X.addGetterSetter($,`rotationSnapTolerance`,5,Y()),X.addGetterSetter($,`borderEnabled`,!0),X.addGetterSetter($,`anchorStroke`,`rgb(0, 161, 255)`),X.addGetterSetter($,`anchorStrokeWidth`,1,Y()),X.addGetterSetter($,`anchorFill`,`white`),X.addGetterSetter($,`anchorCornerRadius`,0,Y()),X.addGetterSetter($,`borderStroke`,`rgb(0, 161, 255)`),X.addGetterSetter($,`borderStrokeWidth`,1,Y()),X.addGetterSetter($,`borderDash`),X.addGetterSetter($,`keepRatio`,!0),X.addGetterSetter($,`shiftBehavior`,`default`),X.addGetterSetter($,`centeredScaling`,!1),X.addGetterSetter($,`ignoreStroke`,!1),X.addGetterSetter($,`padding`,0,Y()),X.addGetterSetter($,`nodes`),X.addGetterSetter($,`node`),X.addGetterSetter($,`boundBoxFunc`),X.addGetterSetter($,`anchorDragBoundFunc`),X.addGetterSetter($,`anchorStyleFunc`),X.addGetterSetter($,`shouldOverdrawWholeArea`,!1),X.addGetterSetter($,`useSingleNodeRotation`,!0),X.backCompat($,{lineEnabled:`borderEnabled`,rotateHandlerOffset:`rotateAnchorOffset`,enabledHandlers:`enabledAnchors`});var sl=class extends Q{_sceneFunc(e){e.beginPath(),e.arc(0,0,Math.abs(this.radius()),0,K.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return Math.abs(this.radius())*2}getHeight(){return Math.abs(this.radius())*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};sl.prototype.className=`Wedge`,sl.prototype._centroid=!0,sl.prototype._attrsAffectingSize=[`radius`],Si(sl,!0),X.addGetterSetter(sl,`radius`,0,Y()),X.addGetterSetter(sl,`angle`,0,Y()),X.addGetterSetter(sl,`clockwise`,!1),X.backCompat(sl,{angleDeg:`angle`,getAngleDeg:`getAngle`,setAngleDeg:`setAngle`});function cl(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var ll=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],ul=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function dl(e,t){return t===255?e:e*t/255}var fl=180;function pl(e,t){let n=e.data,r=e.width,i=e.height,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T=t+t+1,E=r-1,D=i-1,O=t+1,k=O*(O+1)/2,A=new cl,j=t<=fl?ll[t]/2**ul[t]:1/(O*O),M=null,N=A,P=null,F=null;for(let e=1;e<T;e++)N=N.next=new cl,e===O&&(M=N);N.next=A,s=o=0;for(let e=0;e<i;e++){g=_=v=y=c=l=u=d=0,C=n[o+3],b=dl(n[o],C),x=dl(n[o+1],C),S=dl(n[o+2],C),f=O*b,p=O*x,m=O*S,h=O*C,c+=k*b,l+=k*x,u+=k*S,d+=k*C,N=A;for(let e=0;e<O;e++)N.r=b,N.g=x,N.b=S,N.a=C,N=N.next;for(let e=1;e<O;e++)a=o+((E<e?E:e)<<2),C=n[a+3],c+=(N.r=b=dl(n[a],C))*(w=O-e),l+=(N.g=x=dl(n[a+1],C))*w,u+=(N.b=S=dl(n[a+2],C))*w,d+=(N.a=C)*w,g+=b,_+=x,v+=S,y+=C,N=N.next;P=A,F=M;for(let e=0;e<r;e++)n[o]=Math.floor(c*j),n[o+1]=Math.floor(l*j),n[o+2]=Math.floor(u*j),n[o+3]=Math.floor(d*j),c-=f,l-=p,u-=m,d-=h,f-=P.r,p-=P.g,m-=P.b,h-=P.a,a=s+((a=e+t+1)<E?a:E)<<2,C=n[a+3],g+=P.r=dl(n[a],C),_+=P.g=dl(n[a+1],C),v+=P.b=dl(n[a+2],C),y+=P.a=C,c+=g,l+=_,u+=v,d+=y,P=P.next,f+=b=F.r,p+=x=F.g,m+=S=F.b,h+=C=F.a,g-=b,_-=x,v-=S,y-=C,F=F.next,o+=4;s+=r}for(let e=0;e<r;e++){_=v=y=g=l=u=d=c=0,o=e<<2,f=O*(b=n[o]),p=O*(x=n[o+1]),m=O*(S=n[o+2]),h=O*(C=n[o+3]),c+=k*b,l+=k*x,u+=k*S,d+=k*C,N=A;for(let e=0;e<O;e++)N.r=b,N.g=x,N.b=S,N.a=C,N=N.next;let s=Math.min(1,D)*r;for(let i=1;i<=t;i++)o=s+e<<2,c+=(N.r=b=n[o])*(w=O-i),l+=(N.g=x=n[o+1])*w,u+=(N.b=S=n[o+2])*w,d+=(N.a=C=n[o+3])*w,g+=b,_+=x,v+=S,y+=C,N=N.next,i<D&&(s+=r);o=e,P=A,F=M;for(let t=0;t<i;t++)a=o<<2,n[a+3]=C=Math.floor(d*j),C>0?(C=255/C,n[a]=Math.floor(c*j)*C,n[a+1]=Math.floor(l*j)*C,n[a+2]=Math.floor(u*j)*C):n[a]=n[a+1]=n[a+2]=0,c-=f,l-=p,u-=m,d-=h,f-=P.r,p-=P.g,m-=P.b,h-=P.a,a=e+((a=t+O)<D?a:D)*r<<2,c+=g+=P.r=n[a],l+=_+=P.g=n[a+1],u+=v+=P.b=n[a+2],d+=y+=P.a=n[a+3],P=P.next,f+=b=F.r,p+=x=F.g,m+=S=F.b,h+=C=F.a,g-=b,_-=x,v-=S,y-=C,F=F.next,o+=r}}var ml=function(e,t=1){let n=Math.round(Math.min(this.blurRadius(),fl)*t);n>0&&pl(e,n)};X.addGetterSetter(Z,`blurRadius`,0,Y(),X.afterSetFilter);var hl=function(e){let t=this.brightness()*255,n=e.data,r=n.length;for(let e=0;e<r;e+=4)n[e]+=t,n[e+1]+=t,n[e+2]+=t};X.addGetterSetter(Z,`brightness`,0,Y(),X.afterSetFilter);var gl=function(e){let t=this.attrs.brightness===void 0?1:this.brightness(),n=e.data,r=n.length;for(let e=0;e<r;e+=4)n[e]=Math.min(255,n[e]*t),n[e+1]=Math.min(255,n[e+1]*t),n[e+2]=Math.min(255,n[e+2]*t)},_l=function(e){let t=((this.contrast()+100)/100)**2,n=e.data,r=n.length,i=150,a=150,o=150;for(let e=0;e<r;e+=4)i=n[e],a=n[e+1],o=n[e+2],i/=255,i-=.5,i*=t,i+=.5,i*=255,a/=255,a-=.5,a*=t,a+=.5,a*=255,o/=255,o-=.5,o*=t,o+=.5,o*=255,i=i<0?0:i>255?255:i,a=a<0?0:a>255?255:a,o=o<0?0:o>255?255:o,n[e]=i,n[e+1]=a,n[e+2]=o};X.addGetterSetter(Z,`contrast`,0,Y(),X.afterSetFilter);var vl=function(e){let t=e.data,n=e.width,r=e.height,i=Math.min(1,Math.max(0,this.embossStrength?.call(this)??.5)),a=Math.min(1,Math.max(0,this.embossWhiteLevel?.call(this)??.5)),o={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[this.embossDirection?.call(this)??`top-left`]??315,s=!!(this.embossBlend?.call(this)??!1),c=i*10,l=a*255,u=o*Math.PI/180,d=Math.cos(u),f=Math.sin(u),p=128/1020*c,m=new Float32Array(n*r);for(let e=0,n=0;n<t.length;n+=4,e++)m[e]=.2126*t[n]+.7152*t[n+1]+.0722*t[n+2];let h=[-1,0,1,-2,0,2,-1,0,1],g=[-1,-2,-1,0,0,0,1,2,1],_=e=>e<0?0:e>255?255:e;for(let e=0;e<r;e++)for(let i=0;i<n;i++){let a=0,o=0,c=0;for(let t=-1;t<=1;t++){let s=Math.max(0,Math.min(r-1,e+t))*n;for(let e=-1;e<=1;e++,c++){let t=m[s+Math.max(0,Math.min(n-1,i+e))];a+=t*h[c],o+=t*g[c]}}let u=e*n+i,v=_(l+(d*a+f*o)*p),y=u*4;if(s){let e=v-l;t[y]=_(t[y]+e),t[y+1]=_(t[y+1]+e),t[y+2]=_(t[y+2]+e)}else t[y]=t[y+1]=t[y+2]=v}return e};X.addGetterSetter(Z,`embossStrength`,.5,Y(),X.afterSetFilter),X.addGetterSetter(Z,`embossWhiteLevel`,.5,Y(),X.afterSetFilter),X.addGetterSetter(Z,`embossDirection`,`top-left`,void 0,X.afterSetFilter),X.addGetterSetter(Z,`embossBlend`,!1,void 0,X.afterSetFilter);function yl(e,t,n,r,i){let a=n-t,o=i-r;if(a===0)return r+o/2;if(o===0)return r;let s=(e-t)/a;return s=o*s+r,s}var bl=function(e){let t=e.data,n=t.length,r=t[0],i=r,a,o=t[1],s=o,c,l=t[2],u=l,d,f=this.enhance();if(f===0)return;for(let e=0;e<n;e+=4)a=t[e+0],a<r?r=a:a>i&&(i=a),c=t[e+1],c<o?o=c:c>s&&(s=c),d=t[e+2],d<l?l=d:d>u&&(u=d);i===r&&(i=255,r=0),s===o&&(s=255,o=0),u===l&&(u=255,l=0);let p,m,h,g,_,v;if(f>0)p=i+f*(255-i),m=r-f*(r-0),h=s+f*(255-s),g=o-f*(o-0),_=u+f*(255-u),v=l-f*(l-0);else{let e=(i+r)*.5;p=i+f*(i-e),m=r+f*(r-e);let t=(s+o)*.5;h=s+f*(s-t),g=o+f*(o-t);let n=(u+l)*.5;_=u+f*(u-n),v=l+f*(l-n)}for(let e=0;e<n;e+=4)t[e+0]=yl(t[e+0],r,i,m,p),t[e+1]=yl(t[e+1],o,s,g,h),t[e+2]=yl(t[e+2],l,u,v,_)};X.addGetterSetter(Z,`enhance`,0,Y(),X.afterSetFilter);var xl=function(e){let t=e.data,n=t.length;for(let e=0;e<n;e+=4){let n=.34*t[e]+.5*t[e+1]+.16*t[e+2];t[e]=n,t[e+1]=n,t[e+2]=n}};X.addGetterSetter(Z,`hue`,0,Y(),X.afterSetFilter),X.addGetterSetter(Z,`saturation`,0,Y(),X.afterSetFilter),X.addGetterSetter(Z,`luminance`,0,Y(),X.afterSetFilter);var Sl=function(e){let t=e.data,n=t.length,r=2**this.saturation(),i=(this.hue()%360+360)%360,a=this.luminance()*127,o=1*r*Math.cos(i*Math.PI/180),s=1*r*Math.sin(i*Math.PI/180),c=.299+.701*o+.168*s,l=.587-.587*o+.33*s,u=.114-.114*o-.497*s,d=.299-.299*o-.328*s,f=.587+.413*o+.035*s,p=.114-.114*o+.292*s,m=.299-.3*o+1.25*s,h=.587-.588*o-1.05*s,g=.114+.886*o-.203*s,_,v,y,b;for(let e=0;e<n;e+=4)_=t[e+0],v=t[e+1],y=t[e+2],b=t[e+3],t[e+0]=c*_+l*v+u*y+a,t[e+1]=d*_+f*v+p*y+a,t[e+2]=m*_+h*v+g*y+a,t[e+3]=b},Cl=function(e){let t=e.data,n=t.length,r=2**this.value(),i=2**this.saturation(),a=(this.hue()%360+360)%360,o=r*i*Math.cos(a*Math.PI/180),s=r*i*Math.sin(a*Math.PI/180),c=.299*r+.701*o+.168*s,l=.587*r-.587*o+.33*s,u=.114*r-.114*o-.497*s,d=.299*r-.299*o-.328*s,f=.587*r+.413*o+.035*s,p=.114*r-.114*o+.292*s,m=.299*r-.3*o+1.25*s,h=.587*r-.588*o-1.05*s,g=.114*r+.886*o-.203*s;for(let e=0;e<n;e+=4){let n=t[e+0],r=t[e+1],i=t[e+2],a=t[e+3];t[e+0]=c*n+l*r+u*i,t[e+1]=d*n+f*r+p*i,t[e+2]=m*n+h*r+g*i,t[e+3]=a}};X.addGetterSetter(Z,`hue`,0,Y(),X.afterSetFilter),X.addGetterSetter(Z,`saturation`,0,Y(),X.afterSetFilter),X.addGetterSetter(Z,`value`,0,Y(),X.afterSetFilter);var wl=function(e){let t=e.data,n=t.length;for(let e=0;e<n;e+=4)t[e]=255-t[e],t[e+1]=255-t[e+1],t[e+2]=255-t[e+2]},Tl=function(e,t,n){let r=e.data,i=t.data,a=e.width,o=e.height,s=n.polarCenterX||a/2,c=n.polarCenterY||o/2,l=Math.sqrt(s*s+c*c),u=a-s,d=o-c,f=Math.sqrt(u*u+d*d);l=f>l?f:l;let p=o,m=a,h=360/m*Math.PI/180;for(let e=0;e<m;e+=1){let t=Math.sin(e*h),n=Math.cos(e*h);for(let o=0;o<p;o+=1){u=Math.floor(s+l*o/p*n),d=Math.floor(c+l*o/p*t);let f=(d*a+u)*4,m=r[f+0],h=r[f+1],g=r[f+2],_=r[f+3];f=(e+o*a)*4,i[f+0]=m,i[f+1]=h,i[f+2]=g,i[f+3]=_}}},El=function(e,t,n){let r=e.data,i=t.data,a=e.width,o=e.height,s=n.polarCenterX||a/2,c=n.polarCenterY||o/2,l=Math.sqrt(s*s+c*c),u=a-s,d=o-c,f=Math.sqrt(u*u+d*d);l=f>l?f:l;let p=o,m=a,h=n.polarRotation||0,g,_;for(u=0;u<a;u+=1)for(d=0;d<o;d+=1){let e=u-s,t=d-c,n=Math.sqrt(e*e+t*t)*p/l,o=(Math.atan2(t,e)*180/Math.PI+360+h)%360;o=o*m/360,g=Math.floor(o),_=Math.floor(n);let f=(_*a+g)*4,v=r[f+0],y=r[f+1],b=r[f+2],x=r[f+3];f=(d*a+u)*4,i[f+0]=v,i[f+1]=y,i[f+2]=b,i[f+3]=x}},Dl=function(e){let t=e.width,n=e.height,r,i,a,o,s,c,l,u,d,f,p=Math.round(this.kaleidoscopePower()),m=Math.round(this.kaleidoscopeAngle()),h=Math.floor(t*((m%360+360)%360)/360);if(p<1)return;let g={width:t,height:n,data:new Uint8ClampedArray(t*n*4)};Tl(e,g,{polarCenterX:t/2,polarCenterY:n/2});let _=t/2**p;for(;_<=8;)_*=2,--p;_=Math.ceil(_);let v=_,y=0,b=v,x=1;for(h+_>t&&(y=v,b=0,x=-1),i=0;i<n;i+=1)for(r=y;r!==b;r+=x)a=Math.round(r+h)%t,d=(t*i+a)*4,s=g.data[d+0],c=g.data[d+1],l=g.data[d+2],u=g.data[d+3],f=(t*i+r)*4,g.data[f+0]=s,g.data[f+1]=c,g.data[f+2]=l,g.data[f+3]=u;for(i=0;i<n;i+=1)for(v=Math.floor(_),o=0;o<p;o+=1){for(r=0;r<v+1;r+=1)d=(t*i+r)*4,s=g.data[d+0],c=g.data[d+1],l=g.data[d+2],u=g.data[d+3],f=(t*i+v*2-r-1)*4,g.data[f+0]=s,g.data[f+1]=c,g.data[f+2]=l,g.data[f+3]=u;v*=2}El(g,e,{polarRotation:0})};X.addGetterSetter(Z,`kaleidoscopePower`,2,Y(),X.afterSetFilter),X.addGetterSetter(Z,`kaleidoscopeAngle`,0,Y(),X.afterSetFilter);function Ol(e,t,n){let r=(n*e.width+t)*4,i=[];return i.push(e.data[r++],e.data[r++],e.data[r++],e.data[r++]),i}function kl(e,t){return Math.sqrt((e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2)}function Al(e){let t=[0,0,0];for(let n=0;n<e.length;n++)t[0]+=e[n][0],t[1]+=e[n][1],t[2]+=e[n][2];return t[0]/=e.length,t[1]/=e.length,t[2]/=e.length,t}function jl(e,t){let n=Ol(e,0,0),r=Ol(e,e.width-1,0),i=Ol(e,0,e.height-1),a=Ol(e,e.width-1,e.height-1);if(kl(n,r)<t&&kl(r,a)<t&&kl(a,i)<t&&kl(i,n)<t){let o=Al([r,n,a,i]),s=[];for(let n=0;n<e.width*e.height;n++){let r=kl(o,[e.data[n*4],e.data[n*4+1],e.data[n*4+2]]);s[n]=r<t?0:255}return s}}function Ml(e,t){for(let n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}function Nl(e,t,n){let r=[1,1,1,1,0,1,1,1,1],i=Math.round(Math.sqrt(r.length)),a=Math.floor(i/2),o=[];for(let s=0;s<n;s++)for(let c=0;c<t;c++){let l=s*t+c,u=0;for(let o=0;o<i;o++)for(let l=0;l<i;l++){let d=s+o-a,f=c+l-a;if(d>=0&&d<n&&f>=0&&f<t){let n=d*t+f,a=r[o*i+l];u+=e[n]*a}}o[l]=u===2040?255:0}return o}function Pl(e,t,n){let r=[1,1,1,1,1,1,1,1,1],i=Math.round(Math.sqrt(r.length)),a=Math.floor(i/2),o=[];for(let s=0;s<n;s++)for(let c=0;c<t;c++){let l=s*t+c,u=0;for(let o=0;o<i;o++)for(let l=0;l<i;l++){let d=s+o-a,f=c+l-a;if(d>=0&&d<n&&f>=0&&f<t){let n=d*t+f,a=r[o*i+l];u+=e[n]*a}}o[l]=u>=1020?255:0}return o}function Fl(e,t,n){let r=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],i=Math.round(Math.sqrt(r.length)),a=Math.floor(i/2),o=[];for(let s=0;s<n;s++)for(let c=0;c<t;c++){let l=s*t+c,u=0;for(let o=0;o<i;o++)for(let l=0;l<i;l++){let d=s+o-a,f=c+l-a;if(d>=0&&d<n&&f>=0&&f<t){let n=d*t+f,a=r[o*i+l];u+=e[n]*a}}o[l]=u}return o}var Il=function(e){let t=jl(e,this.attrs.threshold??10);return t&&(t=Nl(t,e.width,e.height),t=Pl(t,e.width,e.height),t=Fl(t,e.width,e.height),Ml(e,t)),e};X.addGetterSetter(Z,`threshold`,.5,Y(),X.afterSetFilter);var Ll=function(e){let t=this.noise()*255,n=e.data,r=n.length,i=t/2;for(let e=0;e<r;e+=4)n[e+0]+=i-2*i*Math.random(),n[e+1]+=i-2*i*Math.random(),n[e+2]+=i-2*i*Math.random()};X.addGetterSetter(Z,`noise`,.2,Y(),X.afterSetFilter);var Rl=function(e,t=1){let n=Math.ceil(this.pixelSize()*t),r=e.width,i=e.height,a=Math.ceil(r/n),o=Math.ceil(i/n),s=e.data;if(n<=0){q.error(`pixelSize value can not be <= 0`);return}for(let e=0;e<a;e+=1)for(let t=0;t<o;t+=1){let a=0,o=0,c=0,l=0,u=e*n,d=Math.min(u+n,r),f=t*n,p=Math.min(f+n,i);for(let e=u;e<d;e+=1)for(let t=f;t<p;t+=1){let n=(r*t+e)*4,i=s[n+3];a+=s[n+0]*i,o+=s[n+1]*i,c+=s[n+2]*i,l+=i}l&&(a/=l,o/=l,c/=l),l/=(d-u)*(p-f);for(let e=u;e<d;e+=1)for(let t=f;t<p;t+=1){let n=(r*t+e)*4;s[n+0]=a,s[n+1]=o,s[n+2]=c,s[n+3]=l}}};X.addGetterSetter(Z,`pixelSize`,8,Y(),X.afterSetFilter);var zl=function(e){let t=Math.round(this.levels()*254)+1,n=e.data,r=n.length,i=255/t;for(let e=0;e<r;e+=1)n[e]=Math.floor(n[e]/i)*i};X.addGetterSetter(Z,`levels`,.5,Y(),X.afterSetFilter);var Bl=function(e){let t=e.data,n=t.length,r=this.red(),i=this.green(),a=this.blue();for(let e=0;e<n;e+=4){let n=(.34*t[e]+.5*t[e+1]+.16*t[e+2])/255;t[e]=n*r,t[e+1]=n*i,t[e+2]=n*a,t[e+3]=t[e+3]}};X.addGetterSetter(Z,`red`,0,Ta,X.afterSetFilter),X.addGetterSetter(Z,`green`,0,Ta,X.afterSetFilter),X.addGetterSetter(Z,`blue`,0,Ta,X.afterSetFilter);var Vl=function(e){let t=e.data,n=t.length,r=this.red(),i=this.green(),a=this.blue(),o=this.alpha();for(let e=0;e<n;e+=4){let n=1-o;t[e]=r*o+t[e]*n,t[e+1]=i*o+t[e+1]*n,t[e+2]=a*o+t[e+2]*n}};X.addGetterSetter(Z,`alpha`,1,e=>Math.min(1,Math.max(0,e)),X.afterSetFilter);var Hl=function(e){let t=e.data,n=t.length;for(let e=0;e<n;e+=4){let n=t[e+0],r=t[e+1],i=t[e+2];t[e+0]=Math.min(255,n*.393+r*.769+i*.189),t[e+1]=Math.min(255,n*.349+r*.686+i*.168),t[e+2]=Math.min(255,n*.272+r*.534+i*.131)}},Ul=function(e){let t=e.data;for(let e=0;e<t.length;e+=4){let n=t[e],r=t[e+1],i=t[e+2];.2126*n+.7152*r+.0722*i>=128&&(t[e]=255-n,t[e+1]=255-r,t[e+2]=255-i)}return e},Wl=function(e){let t=this.threshold()*255,n=e.data,r=n.length;for(let e=0;e<r;e+=1)n[e]=n[e]<t?0:255};X.addGetterSetter(Z,`threshold`,.5,Y(),X.afterSetFilter);var Gl=Cs.Util._assign(Cs,{Arc:ws,Arrow:Hs,Circle:Us,Ellipse:Ws,Image:Gs,Label:Nc,Tag:Pc,Line:Rs,Path:Vs,Rect:Fc,RegularPolygon:Ic,Ring:Rc,Sprite:zc,Star:Bc,Text:Ec,TextPath:Gc,Transformer:$,Wedge:sl,Filters:{Blur:ml,Brightness:gl,Brighten:hl,Contrast:_l,Emboss:vl,Enhance:bl,Grayscale:xl,HSL:Sl,HSV:Cl,Invert:wl,Kaleidoscope:Dl,Mask:Il,Noise:Ll,Pixelate:Rl,Posterize:zl,RGB:Bl,RGBA:Vl,Sepia:Hl,Solarize:Ul,Threshold:Wl}});function Kl(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function ql(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}var Jl=class{cells=new Map;large=[];items;cellSize;constructor(e,t=256){if(this.items=e,this.cellSize=t,!Number.isFinite(t)||t<=0)throw Error(`Invalid spatial cell size`);e.forEach((e,t)=>{let[n,r,i,a]=this.range(e.bounds);if((i-n+1)*(a-r+1)>256){this.large.push(t);return}for(let e=n;e<=i;e++)for(let n=r;n<=a;n++){let r=`${e},${n}`,i=this.cells.get(r)??[];i.push(t),this.cells.set(r,i)}})}range(e){return[Math.floor(e.x/this.cellSize),Math.floor(e.y/this.cellSize),Math.floor((e.x+e.width)/this.cellSize),Math.floor((e.y+e.height)/this.cellSize)]}query(e){let[t,n,r,i]=this.range(e),a=new Set(this.large);if((r-t+1)*(i-n+1)>1e4)this.items.forEach((e,t)=>a.add(t));else for(let e=t;e<=r;e++)for(let t=n;t<=i;t++)for(let n of this.cells.get(`${e},${t}`)??[])a.add(n);let o=t=>e.width===0&&e.height===0?ql(t,e.x,e.y):Kl(t,e);return[...a].sort((e,t)=>e-t).map(e=>this.items[e]).filter(e=>e.node.visible!==!1&&o(e.bounds)&&e.clips.every(o))}hitTest(e,t){return this.query({x:e,y:t,width:0,height:0}).toReversed().find(n=>ql(n.bounds,e,t)&&n.clips.every(n=>ql(n,e,t)))}};function Yl(e,t,n=new Map,r,i,a,o=!1){Gl.autoDrawEnabled=!1,Gl.pixelRatio=1;let s=new Gl.Stage({width:e,height:t,...r?{container:r}:{}}),c=new Gl.Layer({listening:!1}),l=new Gl.Layer({listening:!1}),u=new Gl.Layer({listening:!1});s.add(c,l,u);for(let e of[c,l,u])a?.(e.getCanvas()._canvas);let d={x:0,y:0,width:e,height:t},f=new Jl([]),p={},m=[],h=[],g={selection:`#2563EB`,changes:`#B45309`},_=!1,v=!1,y=0,b=[],x=new Map,S=(e,t)=>{let n=Ur(e.document,t,p);return typeof n==`number`?n:0},C=(e,t)=>String(Ur(e.document,t,p)),w=e=>{let t=e.node,r=e.bounds,i=t.fills?.[0],a={x:r.x,y:r.y,width:r.width,height:r.height,listening:!1,opacity:t.opacity??1,rotation:t.rotation??0};if(i?.kind===`solid`&&(a.fill=C(e,i.color)),i?.kind===`image`){let t=n.get(`${e.document.documentId}:${i.assetId}`);if(!t)a.fill=`#D4D4D8`;else{let e=r.width/t.width,n=r.height/t.height,o=i.mode===`cover`?Math.max(e,n):Math.min(e,n);a.fillPriority=`pattern`,a.fillPatternRepeat=`no-repeat`,a.fillPatternScale=i.mode===`stretch`?{x:e,y:n}:{x:o,y:o},a.fillPatternX=(r.width-t.width*(i.mode===`stretch`?e:o))/2,a.fillPatternY=(r.height-t.height*(i.mode===`stretch`?n:o))/2}}if(i?.kind===`gradient`){let t=i.stops.flatMap(t=>[t.offset,C(e,t.color)]);i.gradient===`linear`?(a.fillLinearGradientStartPoint={x:0,y:0},a.fillLinearGradientEndPoint={x:r.width*Math.cos(i.angle*Math.PI/180),y:r.height*Math.sin(i.angle*Math.PI/180)},a.fillLinearGradientColorStops=t):(a.fillRadialGradientStartPoint={x:r.width/2,y:r.height/2},a.fillRadialGradientEndPoint={x:r.width/2,y:r.height/2},a.fillRadialGradientStartRadius=0,a.fillRadialGradientEndRadius=Math.max(r.width,r.height)/2,a.fillRadialGradientColorStops=t)}t.stroke&&(a.stroke=C(e,t.stroke),a.strokeWidth=t.strokeWidth?S(e,t.strokeWidth):1);let o=t.effects?.find(e=>e.kind===`shadow`);o?.kind===`shadow`&&(a.shadowColor=C(e,o.color),a.shadowBlur=S(e,o.blur),a.shadowOffset={x:S(e,o.x),y:S(e,o.y)});let s;if(s=t.type===`text`?new Gl.Text({...a,text:t.text,fontFamily:C(e,t.fontFamily),fontSize:S(e,t.fontSize),fontStyle:(t.fontWeight??400)>=600?`bold`:`normal`,lineHeight:t.lineHeight?S(e,t.lineHeight):1.2}):t.type===`ellipse`?new Gl.Ellipse({...a,x:r.x+r.width/2,y:r.y+r.height/2,radiusX:r.width/2,radiusY:r.height/2}):t.type===`path`?new Gl.Path({...a,data:t.geometry,scaleX:r.width/(t.viewBox.width||1),scaleY:r.height/(t.viewBox.height||1)}):new Gl.Rect({...a,cornerRadius:`radius`in t&&t.radius?S(e,t.radius):0}),i?.kind===`image`){let t=n.get(`${e.document.documentId}:${i.assetId}`);t&&s.setAttrs({fillPatternImage:t})}let c=t.effects?.find(e=>e.kind===`blur`);if(c?.kind===`blur`&&(s.cache(),s.filters([Gl.Filters.Blur]),s.blurRadius(S(e,c.radius))),!e.clips.length)return s;let l=e.clips.reduce((e,t)=>{let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y);return{x:n,y:r,width:Math.max(0,Math.min(e.x+e.width,t.x+t.width)-n),height:Math.max(0,Math.min(e.y+e.height,t.y+t.height)-r)}}),u=new Gl.Group({clipX:l.x,clipY:l.y,clipWidth:l.width,clipHeight:l.height,listening:!1});return u.add(s),u},T=(e,t,n)=>{e.destroyChildren();for(let r of b)if(t.includes(r.ownerId)){let t=r.bounds;e.add(new Gl.Rect({...t,stroke:n,strokeWidth:1,listening:!1}))}},E={setDocument(e,t={},n={},r){let i=Kr(e,t,n);if(i.diagnostics.some(e=>e.severity===`error`))throw Error(`Invalid layout for renderer spike`);f=new Jl(r?Gr(i.items,r):i.items),p=t,_=!0,v=!0},setViewport(e){if(e.width<=0||e.height<=0)throw Error(`Viewport needs positive dimensions`);JSON.stringify(e)!==JSON.stringify(d)&&(d=e,_=!0)},setSelection(e){m=e,_=!0},setChanges(e){h=e,_=!0},setStrokes(e){(e.selection!==g.selection||e.changes!==g.changes)&&(g=e,_=!0)},render(){if(!_)return!1;b=f.query(d);let n=new Set(b.map(e=>e.key));for(let[e,t]of x)(v||!n.has(e))&&(t.destroy(),x.delete(e));for(let e of b)if(!x.has(e.key)){let t=w(e);c.add(t),x.set(e.key,t)}b.forEach((e,t)=>{let n=x.get(e.key);n.zIndex()!==t&&n.zIndex(t)});let r=e/d.width,i=t/d.height;for(let e of[c,l,u])e.scale({x:r,y:i}),e.position({x:-d.x*r,y:-d.y*i});return T(l,m,g.selection),T(u,h,g.changes),c.draw(),l.draw(),u.draw(),y++,_=!1,v=!1,!0},hitTest(e,t){return f.hitTest(e,t)?.ownerId},async exportPng(){E.render();let e=o?c.getCanvas()._canvas:s.toCanvas({pixelRatio:1});if(i)return i(e);let t=await new Promise((t,n)=>e.toBlob(e=>e?t(e):n(Error(`PNG export failed`)),`image/png`));return new Uint8Array(await t.arrayBuffer())},stats(){return{visible:b.length,sceneShapes:x.size,draws:y}},destroy(){s.destroy(),x.clear()}};return E}var Xl=0;async function Zl(e,t,n,r=new Map,i){let a=new Map;return await Promise.all([...r].map(async([e,t])=>{let n=URL.createObjectURL(new Blob([t.slice().buffer]));try{let t=new Image;t.src=n,await t.decode(),a.set(e,t)}catch{i?.(e)}finally{URL.revokeObjectURL(n)}})),e.id||=`design-canvas-${++Xl}`,Yl(t,n,a,e.id)}var Ql=`M3 3 C4.2 1.8 6.2 2.4 8.4 3.4 L26.6 11.7 C28.6 12.6 29.7 13.9 29.6 15.2 C29.5 16.7 28.5 17.8 26.7 18.2 L20.0 19.8 C18.8 20.1 18.1 20.7 17.5 21.7 L13.7 28.2 C12.5 30.3 9.5 29.9 8.8 27.5 L3.4 8.4 C2.78 6.2 1.8 4.2 3 3 Z`,$l=`0 0 32 32`,eu=`#0a0a0a`,tu=`#fff`,nu=`drop-shadow(0 0 1px rgb(0 0 0 / 0.72))`,ru=3e3,iu=1e4,au=1200,ou=`blur(5px)`,su=.45,cu=`#fff`,lu=30,uu=Array.from({length:31},(e,t)=>{let n=t/lu;return-Math.exp(-3.2*n)*Math.sin(4*Math.PI*n)}),du=Math.max(...uu.map(Math.abs)),fu=uu.map((e,t)=>({offset:t/lu,transform:`rotate(${(e/du*15).toFixed(2)}deg)`})),pu=[{offset:0,opacity:su},{offset:.35,opacity:1},{offset:1,opacity:su}],mu={flash:650,cursorGlide:450,cursorFade:240,cursorLinger:900,batchLinger:1600,wipe:400,fade:160},hu=(e,t)=>{let n=e.nodes[t];return n&&`children`in n?n.children:[]};function gu(e){let t=new Map;for(let n of Object.keys(e.nodes))for(let r of hu(e,n))t.set(r,n);return t}function _u(e,t,n=24){let r=gu(e),i=[...new Set(t)].filter(t=>e.nodes[t]),a=e=>{let t=new Set(e);return e.filter(e=>{for(let n=r.get(e);n;n=r.get(n))if(t.has(n))return!1;return!0})},o=a(i);for(;o.length>n;){let e=[...new Set(o.map(e=>r.get(e)??e))];if(e.length===o.length)return o.slice(0,n);o=a(e)}return o}var vu=e=>{if(!e.length)return null;let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y)),r=Math.max(...e.map(e=>e.x+e.width)),i=Math.max(...e.map(e=>e.y+e.height));return{x:t,y:n,width:r-t,height:i-n}},yu=e=>({x:e.x+Math.min(20,e.width/3),y:e.y+Math.min(14,e.height/3)});function bu(e,t){for(let n=e.length-1;n>=0;n--){let r=t(e[n]);if(r)return{nodeId:e[n],bounds:r}}return null}var xu=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height;function Su(e,t,n,r={top:64,right:16,bottom:72,left:16}){let i=n.width/t.width,a=(e.x+e.width/2-t.x)*i,o=(e.y+e.height/2-t.y)*i,s=a-n.width/2,c=o-n.height/2,l=Math.abs(s)/n.width>=Math.abs(c)/n.height,u=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n));if(l){let e=s<0?`left`:`right`;return{side:e,x:e===`left`?r.left:n.width-r.right,y:u(o,r.top,n.height-r.bottom)}}let d=c<0?`top`:`bottom`;return{side:d,x:u(a,r.left+90,n.width-r.right-90),y:d===`top`?r.top:n.height-r.bottom}}function Cu(e,t,n,r=72){let i=n.width/t.width,a=Math.min((n.width-r*2)/e.width,(n.height-r*2)/e.height),o=Math.max(.05,Math.min(i,a)),s=n.width/o,c=n.height/o;return{x:e.x+e.width/2-s/2,y:e.y+e.height/2-c/2,width:s,height:c}}var wu=/^(apply|design_[a-z]+)\s+[a-z-]*:\s*/i;function Tu(e,t=56){let n=(e.replace(wu,``).split(`
17
- `,1)[0]??``).trim().replace(/\.$/,``)||`see the agent's reply`;return n.length>t?`${n.slice(0,t-1).trimEnd()}…`:n}function Eu(e){let t=new Map;return{start(n){t.set(n,setTimeout(()=>{t.delete(n),e(n)},mu.wipe+100))},dispose(){for(let e of t.values())clearTimeout(e);t.clear()}}}var Du=`(prefers-reduced-motion: reduce)`,Ou=e=>{let t=matchMedia(Du);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)},ku=()=>(0,H.useSyncExternalStore)(Ou,Bu,Vu),Au=e=>(document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)),ju=`cubic-bezier(0.77, 0, 0.175, 1)`,Mu={left:ye,right:be,top:xe,bottom:ve},Nu=64;function Pu(e,t,n){let r=n.width/t.width,i=(e.x-t.x)*r,a=(e.y-t.y)*r,o=e.width*r,s=e.height*r,c=Math.max(i,-64),l=Math.max(a,-64),u=Math.min(i+o,n.width+Nu),d=Math.min(a+s,n.height+Nu);return{corner:{x:i,y:a},visible:u>c&&d>l,style:{left:c,top:l,width:Math.max(0,u-c),height:Math.max(0,d-l),"--paint-ox":`${i-c}px`,"--paint-oy":`${a-l}px`}}}function Fu({cursorSize:e=`small`,cursorLabel:t=`name`,animations:n=!0,document:r,bounds:i,viewport:a,canvas:o,batch:s,agents:c,onReveal:l}){let u=(0,H.useSyncExternalStore)(Au,()=>!globalThis.document.hidden,()=>!1),d=ku()||!n,f=o.width/a.width,p=c?.some(e=>e.active)??!1,m=(c?.find(e=>e.active)??c?.[0])?.label??`Agent`,h=c?.find(e=>e.lastError!==null)?.lastError??null,g=(0,H.useMemo)(()=>{let e=new Set;return(c??[]).flatMap(t=>{let n=t.workingNodeId,a=n?i.get(n):void 0;return!n||!a||e.has(n)?[]:(e.add(n),[{id:n,label:t.label,box:a,root:r.roots.includes(n)}])})},[c,i,r.roots]),[_,v]=(0,H.useState)(null),[y,b]=(0,H.useState)([]),[x,S]=(0,H.useState)(!1),[C,w]=(0,H.useState)(null),T=(0,H.useRef)({document:r,bounds:i,working:g,active:p,failed:h!==null});T.current={document:r,bounds:i,working:g,active:p,failed:h!==null};let E=(0,H.useRef)(p?null:s?.sequence??null),D=(0,H.useRef)({}),O=(0,H.useRef)(0),k=(0,H.useRef)(null);k.current??=Eu(e=>b(t=>t.filter(t=>t.id!==e))),(0,H.useEffect)(()=>{if(!s||s.sequence===E.current)return;E.current=s.sequence;let{document:e,bounds:t}=T.current,n=_u(e,s.nodeIds).flatMap(e=>t.get(e)??[]),r=bu(s.nodeIds,e=>t.get(e));v({id:s.sequence,rects:n}),r&&w({point:yu(r.bounds),box:r.bounds,name:e.nodes[r.nodeId]?.name??``}),S(!0),clearTimeout(D.current.flash),clearTimeout(D.current.linger),D.current.flash=window.setTimeout(()=>v(e=>e?.id===s.sequence?null:e),mu.flash+80),D.current.linger=window.setTimeout(()=>S(!1),mu.batchLinger)},[s]),(0,H.useEffect)(()=>()=>{clearTimeout(D.current.flash),clearTimeout(D.current.linger),k.current?.dispose()},[]);let A=g.map(e=>e.id).join(`|`),j=(0,H.useRef)(new Map);(0,H.useEffect)(()=>{let e=new Map(T.current.working.map(e=>[e.id,{id:0,bounds:e.box,label:e.label,failed:T.current.failed}])),t=[...j.current].filter(([t])=>!e.has(t)),n=T.current.working.find(e=>!j.current.has(e.id));if(j.current=e,n&&w({point:yu(n.box),box:n.box,name:T.current.document.nodes[n.id]?.name??``}),!t.length)return;let r=t.map(([,e])=>({...e,id:++O.current}));b(e=>[...e,...r]);for(let e of r)k.current?.start(e.id)},[A]),(0,H.useEffect)(()=>{j.current=new Map(g.map(e=>[e.id,{id:0,bounds:e.box,label:e.label,failed:h!==null}]))},[g,h]);let M=(0,H.useMemo)(()=>{if(C)return C;if(!h)return null;let e=r.roots.map(e=>i.get(e)).find(Boolean);return e?{point:yu(e),box:e,name:``}:null},[C,h,r.roots,i]),N=M!==null&&(p||x||g.length>0||h!==null),P=(0,H.useRef)(!1),F=(0,H.useRef)(null),ee=(0,H.useRef)(null),te=(0,H.useRef)(null);(0,H.useLayoutEffect)(()=>{let e=M?.point??null,t=F.current,n=P.current;F.current=e,P.current=N;let r=ee.current;if(!r||!e||!t||!n||d){te.current?.cancel();return}if(t.x===e.x&&t.y===e.y)return;let i=0,a=0;if(te.current?.playState===`running`){let e=new DOMMatrixReadOnly(getComputedStyle(r).transform);i=e.e,a=e.f}te.current?.cancel(),te.current=r.animate([{transform:`translate(${(t.x-e.x)*f+i}px, ${(t.y-e.y)*f+a}px)`},{transform:`translate(0px, 0px)`}],{duration:mu.cursorGlide,easing:ju})},[M?.point.x,M?.point.y,d]),(0,H.useEffect)(()=>{P.current=N},[N]),(0,H.useEffect)(()=>()=>te.current?.cancel(),[]);let I=g[0]?.box??(N?M?.box:void 0)??null,L=I&&(p||x||g.length>0)&&!xu(I,a)?I:null,ne=L?Su(L,a,o):null;if(!o.width)return null;let re=h?`${m}: change not applied - ${Tu(h)}`:g[0]?`${g[0].label} is generating ${r.nodes[g[0].id]?.name??`a frame`}`:``,ie=h!==null,R=M?{x:(M.point.x-a.x)*f,y:(M.point.y-a.y)*f}:null,ae=R?R.x>o.width-240:!1;return(0,G.jsxs)(`div`,{className:`design-paint`,"data-reduced":d?``:void 0,"data-paused":u?void 0:``,style:{"--paint-cycle":`${mu.batchLinger}ms`},children:[(0,G.jsx)(`span`,{className:`sr-only`,role:`status`,children:re}),g.map(e=>{let t=Pu(e.box,a,o);return t.visible?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`design-paint-field`,"data-failed":ie?``:void 0,style:t.style}),e.root&&e.box.width*f>80?(0,G.jsxs)(`span`,{className:`design-paint-label`,"data-inside":e.root?void 0:``,style:{left:t.corner.x,top:t.corner.y},children:[(0,G.jsx)(Lu,{size:14}),(0,G.jsx)(`span`,{children:(0,G.jsx)(`b`,{children:e.label})})]}):null]},e.id):null}),y.map(e=>{let t=Pu(e.bounds,a,o);return t.visible?(0,G.jsx)(`div`,{className:`design-paint-field design-paint-wipe`,"data-failed":e.failed?``:void 0,style:t.style},e.id):null}),_?.rects.map(e=>{let t=Pu(e,a,o);return t.visible?(0,G.jsx)(`div`,{className:`design-paint-flash`,style:t.style},`${_.id}:${e.x}:${e.y}:${e.width}`):null}),M&&R?(0,G.jsx)(`div`,{className:`design-paint-cursor`,"data-size":e,"data-shown":N?``:void 0,"data-failed":ie?``:void 0,"data-flip":ae?``:void 0,style:{transform:`translate3d(${R.x}px, ${R.y}px, 0)`},children:(0,G.jsxs)(`div`,{ref:ee,className:`design-paint-glide`,children:[(0,G.jsx)(Lu,{animate:N&&u&&!d&&!ie&&R.x>=0&&R.y>=0&&R.x<=o.width&&R.y<=o.height,sequence:s?.sequence}),(0,G.jsx)(`span`,{className:`design-paint-pill`,hidden:t===`none`&&!ie,children:ie?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`b`,{children:[m,`:`]}),` change not applied - `,Tu(h??``)]}):(0,G.jsx)(G.Fragment,{children:(0,G.jsx)(`b`,{children:t===`agent`?`Agent`:m})})})]})}):null,ne?(0,G.jsx)(Iu,{label:m,chip:ne,onClick:()=>L&&l(L)}):null]})}function Iu(e){let t=(0,U.c)(11),{label:n,chip:r,onClick:i}=e,a=Mu[r.side],o;t[0]!==r.x||t[1]!==r.y?(o={left:r.x,top:r.y},t[0]=r.x,t[1]=r.y,t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=(0,G.jsx)(a,{"aria-hidden":`true`}),t[3]=a,t[4]=s);let c;return t[5]!==r.side||t[6]!==n||t[7]!==i||t[8]!==o||t[9]!==s?(c=(0,G.jsxs)(`button`,{type:`button`,className:`design-paint-chip`,"data-side":r.side,style:o,onClick:i,children:[s,n,` is working here`]}),t[5]=r.side,t[6]=n,t[7]=i,t[8]=o,t[9]=s,t[10]=c):c=t[10],c}function Lu(e){let t=(0,U.c)(10),{size:n,animate:r,sequence:i}=e,a=n===void 0?22:n,o=r!==void 0&&r,s=(0,H.useRef)(null),c=(0,H.useRef)(null),l;t[0]===o?l=t[1]:(l=()=>{if(!o)return;let e=[],t=()=>{document.hidden||(e=[s.current?.animate(fu,{duration:au,easing:`linear`}),c.current?.animate(pu,{duration:au,easing:`ease-in-out`})].filter(zu))},n,r=setTimeout(()=>{t(),n=setInterval(t,iu)},ru);return()=>{clearTimeout(r),clearInterval(n),e.forEach(Ru)}},t[0]=o,t[1]=l);let u;t[2]!==o||t[3]!==i?(u=[o,i],t[2]=o,t[3]=i,t[4]=u):u=t[4],(0,H.useEffect)(l,u);let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d={overflow:`visible`,filter:nu},t[5]=d):d=t[5];let f,p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,G.jsx)(`path`,{ref:c,d:Ql,fill:cu,stroke:cu,strokeWidth:6,strokeLinejoin:`round`,strokeLinecap:`round`,style:{filter:ou,opacity:su}}),p=(0,G.jsx)(`path`,{d:Ql,fill:eu,stroke:tu,strokeWidth:2,strokeLinejoin:`round`,strokeLinecap:`round`}),t[6]=f,t[7]=p):(f=t[6],p=t[7]);let m;return t[8]===a?m=t[9]:(m=(0,G.jsxs)(`svg`,{ref:s,className:`design-cu-cursor`,width:a,height:a,viewBox:$l,shapeRendering:`geometricPrecision`,"aria-hidden":`true`,style:d,children:[f,p]}),t[8]=a,t[9]=m),m}function Ru(e){return e.cancel()}function zu(e){return!!e}function Bu(){return matchMedia(Du).matches}function Vu(){return!0}function Hu(e){return e.split(/[-_\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function Uu(e){return String(Number.isInteger(e)?e:Math.round(e*100)/100)}var Wu=e=>`${Math.round(e*100)}%`,Gu=e=>e?`Shown`:`Hidden`,Ku=e=>e?`On`:`Off`,qu=e=>e?String(e):`None`;function Ju(e){return new Map(Object.entries(e).toSorted(([e,t],[n,r])=>t.createdAt.localeCompare(r.createdAt)||e.localeCompare(n)).map(([e],t)=>[e,t+1]))}function Yu(e){let t=getComputedStyle(e);return{selection:t.getPropertyValue(`--design-selection`).trim()||`#2563EB`,changes:t.getPropertyValue(`--design-change-stroke`).trim()||`#B45309`}}var Xu=new Map,Zu=48;function Qu(e){let t=(0,U.c)(10),{name:n,x:r,y:i,width:a,hidden:o}=e,s=Math.min(240,a),c;t[0]!==s||t[1]!==r||t[2]!==i?(c={left:r,top:i,maxWidth:s},t[0]=s,t[1]=r,t[2]=i,t[3]=c):c=t[3];let l=o||a<Zu,u;t[4]===n?u=t[5]:(u=(0,G.jsx)(Mt,{children:n}),t[4]=n,t[5]=u);let d;return t[6]!==c||t[7]!==l||t[8]!==u?(d=(0,G.jsx)(`span`,{className:`design-frame-label`,style:c,hidden:l,children:u}),t[6]=c,t[7]=l,t[8]=u,t[9]=d):d=t[9],d}function $u(e){let t=(0,U.c)(19),{screen:n,frame:r,canvas:i,avoid:a,decoration:o,callout:s}=e;if(n.x+n.width<0||n.y+n.height<0||n.x>i.width||n.y>i.height||!i.width)return null;let c=s?a:null,l;t[0]!==i||t[1]!==r||t[2]!==n||t[3]!==c?(l=gi(n,r,i,c),t[0]=i,t[1]=r,t[2]=n,t[3]=c,t[4]=l):l=t[4];let{side:u,placement:d,reach:f}=l,p=`${f}px`,m;t[5]!==n.height||t[6]!==n.width||t[7]!==n.x||t[8]!==n.y||t[9]!==p?(m={left:n.x,top:n.y,width:n.width,height:n.height,"--design-agent-edit-reach":p},t[5]=n.height,t[6]=n.width,t[7]=n.x,t[8]=n.y,t[9]=p,t[10]=m):m=t[10];let h=m,g;t[11]===s?g=t[12]:(g=s?(0,G.jsx)(`div`,{className:`design-agent-edit-callout`,children:s}):null,t[11]=s,t[12]=g);let _;return t[13]!==o||t[14]!==d||t[15]!==u||t[16]!==h||t[17]!==g?(_=(0,G.jsxs)(`div`,{className:`design-agent-edit`,"data-side":u,"data-placement":d,style:h,children:[o,g]}),t[13]=o,t[14]=d,t[15]=u,t[16]=h,t[17]=g,t[18]=_):_=t[18],_}var ed=(e,t,n,r,i,a,o=0)=>di(Kr(e,t,n).items.map(e=>e.bounds),r,i,a,o);function td({preferences:e,viewKey:t,chrome:n=`panel`,document:r,theme:i,context:a,assets:o,selection:s,changedNodeIds:c,onSelect:l,annotationMode:u,onAnnotationModeChange:d,onAnchor:f,onOpenAnnotation:p,revision:m,externalViewport:h,onViewportChange:g,renderSelectionOverlay:_,agentEdit:v,frameDecoration:y,batch:b,agents:x}){let S=(0,H.useRef)(null),C=(0,H.useRef)(null),w=(0,H.useRef)({x:0,y:0,width:1,height:1}),T=(0,H.useRef)({width:1,height:1}),E=(0,H.useRef)(0);E.current=!v||n!==`workspace`?0:v.callout?hi.width:120;let D=(0,H.useRef)(null),O=(0,H.useRef)(null),k=(0,H.useRef)(new Map),A=(0,H.useRef)(null),j=(0,H.useRef)(null),M=(0,H.useRef)(null),N=(0,H.useRef)({document:r,theme:i,context:a,selection:s,changedNodeIds:c,externalViewport:h});N.current={document:r,theme:i,context:a,selection:s,changedNodeIds:c,externalViewport:h};let[P,F]=(0,H.useState)({width:0,height:0}),[ee,te]=(0,H.useState)(!1),[I,L]=(0,H.useState)(w.current),[ne,re]=(0,H.useState)(100),[ie,R]=(0,H.useState)(null),ae=(0,H.useCallback)(()=>{let e=S.current,t=[...k.current.keys()];k.current.clear(),O.current=null,A.current=null,j.current&&(j.current.hidden=!0);for(let n of t)e?.hasPointerCapture(n)&&e.releasePointerCapture(n)},[]);(0,H.useEffect)(()=>{let e=()=>{window.document.hidden&&ae()};return window.addEventListener(`blur`,ae),window.document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`blur`,ae),window.document.removeEventListener(`visibilitychange`,e)}},[ae]),(0,H.useEffect)(ae,[t,u,ee,ae]);let oe=(0,H.useMemo)(()=>{try{return Kr(r,i,a).items}catch{return null}},[r,i,a]),se=(0,H.useMemo)(()=>{try{let e=oe??Kr(r,i,a).items,t=new Set(r.roots),n=new Set(s),o=e.filter(e=>t.has(e.ownerId)&&e.node.type===`frame`),c=e.filter(e=>n.has(e.ownerId));if(!c.length)return{frames:o,selectionBounds:null};let l=Math.min(...c.map(e=>e.bounds.x)),u=Math.min(...c.map(e=>e.bounds.y)),d=Math.max(...c.map(e=>e.bounds.x+e.bounds.width)),f=Math.max(...c.map(e=>e.bounds.y+e.bounds.height));return{frames:o,selectionBounds:{x:l,y:u,width:d-l,height:f-u}}}catch{return{frames:[],selectionBounds:null}}},[oe,r,i,a,s]),ce=!!v,le=(0,H.useMemo)(()=>{if(!ce||!c.length)return null;let e=new Set(c.flatMap(e=>{let t=r.nodes[e];return t&&`children`in t?t.children:[]})),t=c.findLast(t=>r.nodes[t]&&!e.has(t));if(!t)return null;try{let e=(oe??Kr(r,i,a).items).filter(e=>e.ownerId===t);if(!e.length)return null;let n=Math.min(...e.map(e=>e.bounds.x)),o=Math.min(...e.map(e=>e.bounds.y)),s=Math.max(...e.map(e=>e.bounds.x+e.bounds.width)),c=Math.max(...e.map(e=>e.bounds.y+e.bounds.height));return{nodeId:t,name:r.nodes[t]?.name??``,bounds:{x:n,y:o,width:s-n,height:c-o}}}catch{return null}},[ce,c,oe,r,i,a]),ue=b!==void 0,de=(0,H.useMemo)(()=>{if(!ue||!oe)return null;let e=new Map;for(let t of oe){let n=e.get(t.ownerId);n?n.push(t.bounds):e.set(t.ownerId,[t.bounds])}return new Map([...e].flatMap(([e,t])=>{let n=vu(t);return n?[[e,n]]:[]}))},[ue,oe]),fe=x?.some(e=>e.active)??!1,pe=(0,H.useMemo)(()=>new Set(x?.flatMap(e=>e.workingNodeId?[e.workingNodeId]:[])),[x]),me=P.width/I.width,he=e=>({x:(e.x-I.x)*me,y:(e.y-I.y)*me,width:e.width*me,height:e.height*me}),ge=v&&le?he(le.bounds):null,_e=(()=>{if(!le||!ge)return null;let{x:e,y:t,width:n,height:r}=le.bounds,i=e+n/2,a=t+r/2,o=se.frames.find(({bounds:e})=>i>=e.x&&i<=e.x+e.width&&a>=e.y&&a<=e.y+e.height)?.bounds;return o?he(o):null})(),[ve,ye]=(0,H.useState)(null),be=(0,H.useCallback)(e=>{ye(t=>t===e||t&&e&&Math.round(t.x)===Math.round(e.x)&&Math.round(t.y)===Math.round(e.y)&&Math.round(t.width)===Math.round(e.width)&&Math.round(t.height)===Math.round(e.height)?t:e)},[]),z=se.frames.filter(({bounds:e})=>e.x+e.width>=I.x&&e.x<=I.x+I.width&&e.y+e.height>=I.y&&e.y<=I.y+I.height).slice(0,100),xe=_i(z.filter(e=>!pe.has(e.ownerId)&&e.bounds.width*me>=Zu),z,I,me),Se=se.selectionBounds,Ce=Se?{x:(Se.x+Se.width/2-I.x)*me,y:(Se.y+Se.height-I.y)*me}:null,we=(0,H.useMemo)(()=>Ju(r.annotations),[r.annotations]),Te=(0,H.useMemo)(()=>{if(!Object.keys(r.annotations).length)return[];let e;try{e=new Map(Kr(r,i,a).items.map(e=>[e.ownerId,e.bounds]))}catch{e=new Map}return Object.entries(r.annotations).flatMap(([t,n])=>{if(n.revision!==m)return[];let r=n.anchor,i=r.kind===`point`?{x:r.x,y:r.y}:r.kind===`region`?{x:r.bounds.x+r.bounds.width/2,y:r.bounds.y+r.bounds.height/2}:(()=>{let t=r.nodeIds.map(t=>e.get(t)).find(Boolean);return t?{x:t.x+t.width,y:t.y}:null})();return i?[{id:t,annotation:n,point:i}]:[]})},[r,i,a,m]),Ee=(0,H.useCallback)(e=>{let t=M.current;if(t)for(let n of t.querySelectorAll(`[data-design-pin]`)){let t=Number(n.dataset.x),r=Number(n.dataset.y),i=(t-e.x)/e.width*T.current.width,a=(r-e.y)/e.height*T.current.height;n.style.left=`${i}px`,n.style.top=`${a}px`,n.hidden=i<0||a<0||i>T.current.width||a>T.current.height}},[]);(0,H.useEffect)(()=>{let e=S.current;if(!e)return;let t=new ResizeObserver(()=>{if(!e.clientWidth||!e.clientHeight)return;let t=Math.max(1,Math.round(e.clientWidth)),n=Math.max(1,Math.round(e.clientHeight));F(e=>e.width===t&&e.height===n?e:{width:t,height:n})});t.observe(e);let n=e=>e.preventDefault();return e.addEventListener(`wheel`,n,{passive:!1}),()=>{t.disconnect(),e.removeEventListener(`wheel`,n)}},[]);let B=(0,H.useCallback)(e=>{w.current=e,L(e);let n=C.current;n&&(n.setViewport(e),n.render()),re(Math.round(T.current.width/e.width*100)),Xu.set(t,{bounds:e,width:T.current.width}),Ee(e),g?.(e)},[t,Ee,g]);(0,H.useLayoutEffect)(()=>Ee(w.current),[Te,Ee]),(0,H.useEffect)(()=>{h&&C.current&&B(h)},[h,B]),(0,H.useEffect)(()=>{if(!P.width||!P.height||!S.current)return;let e=!1,r=S.current,i=T.current;return T.current=P,R(null),Zl(r,P.width,P.height,o,()=>{e||R(`An image could not be decoded. Its placeholder remains visible.`)}).then(a=>{if(e){a.destroy();return}let o=N.current;C.current=a,a.setStrokes(Yu(r)),a.setDocument(o.document,o.theme,o.context),a.setSelection(o.selection),a.setChanges(o.changedNodeIds);let s=w.current;if(o.externalViewport)D.current=o.document.documentId,B(o.externalViewport);else if(D.current!==o.document.documentId){D.current=o.document.documentId;let e=Xu.get(t);if(e){let t=e.width/e.bounds.width;B({...e.bounds,width:P.width/t,height:P.height/t})}else B(ed(o.document,o.theme,o.context,P.width,P.height,n,E.current))}else{let e=i.width/s.width,t=P.width/e,n=P.height/e;B({x:s.x+(s.width-t)/2,y:s.y+(s.height-n)/2,width:t,height:n})}}).catch(()=>{e||(C.current?.destroy(),C.current=null,R(`Canvas could not load. Try reopening this design.`))}),()=>{e=!0,C.current?.destroy(),C.current=null,r.replaceChildren()}},[P.width,P.height,o,t]),(0,H.useEffect)(()=>{let e=C.current;if(e)try{e.setDocument(r,i,a),D.current!==r.documentId&&(D.current=r.documentId,B(ed(r,i,a,T.current.width,T.current.height,n,E.current))),e.render(),R(null)}catch{R(`This design has layout problems. Check diagnostics.`)}},[r,i,a,B,n]),(0,H.useEffect)(()=>{let e=C.current;e&&(e.setSelection(s),e.render())},[s]),(0,H.useEffect)(()=>{let e=C.current;e&&(e.setChanges(c),e.render())},[c]),(0,H.useEffect)(()=>{let e=S.current;if(!e)return;let t=new MutationObserver(()=>{let t=C.current;t&&(t.setStrokes(Yu(e)),t.render())});return t.observe(window.document.documentElement,{attributes:!0,attributeFilter:[`class`,`data-theme`,`style`]}),()=>t.disconnect()},[]);let De=(0,H.useCallback)((e,t,n)=>{let r=w.current,i=T.current.width,a=T.current.height,o=Math.max(.05,Math.min(8,i/r.width*e)),s=i/o,c=a/o,l=r.x+t/i*r.width,u=r.y+n/a*r.height;B({x:l-t/i*s,y:u-n/a*c,width:s,height:c})},[B]),Oe=t=>{let n=t.currentTarget.getBoundingClientRect();if(t.ctrlKey||t.metaKey||e?.scrollWheelZoom){let r=e?.invertZoom?1:-1;De(Math.exp(r*t.deltaY*.006),t.clientX-n.left,t.clientY-n.top)}else{let e=w.current;B({...e,x:e.x+t.deltaX*e.width/T.current.width,y:e.y+t.deltaY*e.height/T.current.height})}},ke=e=>{if(e.button===0||e.button===1){if(e.currentTarget.focus({preventScroll:!0}),k.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),u===`region`&&e.button===0){let t=e.currentTarget.getBoundingClientRect();A.current={x:e.clientX-t.left,y:e.clientY-t.top},e.currentTarget.setPointerCapture(e.pointerId);return}if(u&&e.button===0){O.current={x:e.clientX,y:e.clientY,moved:!1},e.currentTarget.setPointerCapture(e.pointerId);return}O.current=k.current.size===1?{x:e.clientX,y:e.clientY,moved:!1}:null,e.currentTarget.setPointerCapture(e.pointerId)}},Ae=e=>{if(e.pointerType!==`touch`&&e.buttons===0){ae();return}if(A.current){let t=j.current,n=e.currentTarget.getBoundingClientRect(),r={x:e.clientX-n.left,y:e.clientY-n.top};t&&(t.hidden=!1,t.style.left=`${Math.min(A.current.x,r.x)}px`,t.style.top=`${Math.min(A.current.y,r.y)}px`,t.style.width=`${Math.abs(r.x-A.current.x)}px`,t.style.height=`${Math.abs(r.y-A.current.y)}px`);return}if(u){let t=O.current;t&&Math.abs(e.clientX-t.x)+Math.abs(e.clientY-t.y)>4&&(t.moved=!0);return}let t=k.current;if(!t.has(e.pointerId))return;let n=[...t.values()];if(t.set(e.pointerId,{x:e.clientX,y:e.clientY}),t.size===2){let r=[...t.values()],i=n[0],a=n[1],o=r[0],s=r[1];if(!i||!a||!o||!s)return;let c=Math.hypot(i.x-a.x,i.y-a.y),l=Math.hypot(o.x-s.x,o.y-s.y);if(c<1||l<1)return;let u=e.currentTarget.getBoundingClientRect(),d={x:(i.x+a.x)/2,y:(i.y+a.y)/2},f={x:(o.x+s.x)/2,y:(o.y+s.y)/2},p=w.current,m=T.current.width,h=T.current.height,g=Math.max(.05,Math.min(8,m/p.width*l/c)),_=m/g,v=h/g,y=p.x+(d.x-u.left)/m*p.width,b=p.y+(d.y-u.top)/h*p.height;B({x:y-(f.x-u.left)/m*_,y:b-(f.y-u.top)/h*v,width:_,height:v});return}let r=O.current;if(!r)return;let i=e.clientX-r.x,a=e.clientY-r.y;if(Math.abs(i)+Math.abs(a)>2&&(r.moved=!0),r.moved){let e=w.current;B({...e,x:e.x-i*e.width/T.current.width,y:e.y-a*e.height/T.current.height})}r.x=e.clientX,r.y=e.clientY},je=e=>{if(A.current){let t=A.current;A.current=null,k.current.delete(e.pointerId),j.current&&(j.current.hidden=!0);let n=e.currentTarget.getBoundingClientRect(),r={x:e.clientX-n.left,y:e.clientY-n.top};if(Math.abs(r.x-t.x)<4||Math.abs(r.y-t.y)<4)return;let i=w.current,a=i.x+Math.min(t.x,r.x)/n.width*i.width,o=i.y+Math.min(t.y,r.y)/n.height*i.height;f?.({kind:`region`,bounds:{x:a,y:o,width:Math.abs(r.x-t.x)/n.width*i.width,height:Math.abs(r.y-t.y)/n.height*i.height}});return}let t=k.current.size>1;if(k.current.delete(e.pointerId),t){let e=k.current.values().next().value;O.current=e?{...e,moved:!0}:null;return}let n=O.current;if(O.current=null,!n||n.moved||ee||e.button===1)return;let r=e.currentTarget.getBoundingClientRect(),i=w.current,a=i.x+(e.clientX-r.left)/r.width*i.width,o=i.y+(e.clientY-r.top)/r.height*i.height,s=C.current?.hitTest(a,o);if(u===`pin`){f?.({kind:`point`,x:a,y:o});return}if(u===`nodes`){s&&f?.({kind:`nodes`,nodeIds:[s]});return}l(s?[s]:[])};return(0,G.jsxs)(`div`,{className:`design-canvas-wrap`,children:[(0,G.jsx)(`div`,{className:`design-canvas-tools`,role:`toolbar`,"aria-label":`Canvas controls`,children:[{label:`Select`,icon:Xe,active:!ee&&!u,run:()=>{te(!1),d?.(null)}},{label:`Pan`,icon:Le,active:ee&&!u,run:()=>{te(!0),d?.(null)}},...d?[{label:`Pin`,mode:`pin`,icon:We},{label:`Region`,mode:`region`,icon:et},{label:`Node`,mode:`nodes`,icon:Ne}].map(({label:e,mode:t,icon:n})=>({label:e,icon:n,active:u===t,run:()=>{te(!1),d(t)}})):[],{label:`Fit`,icon:$e,active:void 0,run:()=>B(ed(r,i,a,T.current.width,T.current.height,n,E.current))}].map(({label:e,icon:t,active:n,run:r})=>(0,G.jsxs)(H.Fragment,{children:[e===`Fit`?(0,G.jsx)(`span`,{className:`design-tool-separator`,"aria-hidden":`true`}):null,(0,G.jsxs)(jt,{children:[(0,G.jsx)(Ot,{render:(0,G.jsx)(W,{size:`icon-sm`,variant:`ghost`,"aria-label":e,"aria-pressed":n,className:`aria-pressed:bg-accent`,onClick:r}),children:(0,G.jsx)(t,{"aria-hidden":`true`})}),(0,G.jsx)(kt,{children:e})]})]},e))}),(0,G.jsxs)(`div`,{className:`design-canvas-zoom`,"aria-label":`Canvas zoom`,children:[(0,G.jsxs)(jt,{children:[(0,G.jsx)(Ot,{render:(0,G.jsx)(W,{size:`icon-sm`,variant:`ghost`,"aria-label":`Zoom out`,onClick:()=>De(1/1.5,T.current.width/2,T.current.height/2)}),children:(0,G.jsx)(Je,{"aria-hidden":`true`})}),(0,G.jsx)(kt,{children:`Zoom out`})]}),(0,G.jsxs)(`output`,{"aria-label":`Zoom level`,children:[ne,`%`]}),(0,G.jsxs)(jt,{children:[(0,G.jsx)(Ot,{render:(0,G.jsx)(W,{size:`icon-sm`,variant:`ghost`,"aria-label":`Zoom in`,onClick:()=>De(1.5,T.current.width/2,T.current.height/2)}),children:(0,G.jsx)(Ze,{"aria-hidden":`true`})}),(0,G.jsx)(kt,{children:`Zoom in`})]})]}),(0,G.jsxs)(`div`,{className:`design-frame-labels`,children:[y?z.map(e=>(0,G.jsx)(`div`,{className:`design-frame-mark`,style:{left:(e.bounds.x-I.x)*me,top:(e.bounds.y-I.y)*me,width:e.bounds.width*me,height:e.bounds.height*me},children:typeof y==`function`?y({name:e.node.name,width:e.bounds.width,height:e.bounds.height}):y},`mark:${e.key}`)):null,z.map(e=>(0,G.jsx)(Qu,{name:e.node.name,x:(e.bounds.x-I.x)*me,y:(e.bounds.y-I.y)*me,width:e.bounds.width*me,hidden:pe.has(e.ownerId)||xe.has(e.key)},e.key))]}),Ce&&Se&&Ce.x>=0&&Ce.x<=P.width&&Ce.y>=0&&Ce.y<=P.height?(0,G.jsxs)(`output`,{className:`design-selection-badge`,"aria-label":`Selection dimensions`,style:{left:Ce.x,top:Ce.y},children:[Math.round(Se.width),` × `,Math.round(Se.height)]}):null,v&&le&&ge?(0,G.jsx)($u,{frame:_e,screen:ge,canvas:P,avoid:_&&Se?ve:null,decoration:fe?void 0:v.decoration,callout:fe?void 0:v.callout?.({nodeId:le.nodeId,name:le.name})},le.nodeId):null,de&&P.width&&P.height?(0,G.jsx)(Fu,{document:r,bounds:de,viewport:I,canvas:P,batch:b??null,agents:x,cursorSize:e?.agentCursorSize,cursorLabel:e?.agentCursorLabel,animations:e?.animations,onReveal:e=>B(Cu(e,w.current,T.current))}):null,_&&Se&&P.width&&P.height?_({screen:{x:(Se.x-I.x)*me,y:(Se.y-I.y)*me,width:Se.width*me,height:Se.height*me},world:Se,canvas:P,avoid:ge,onPlaced:be}):null,(0,G.jsx)(`div`,{ref:S,className:`design-canvas-surface ${ee?`design-canvas-pan`:``}`,role:`application`,"aria-label":u?`Design canvas. ${u===`region`?`Drag a region`:`Click to place an annotation`}; arrow keys move the view and Enter anchors the selection or view center.`:`Design canvas. Drag to pan, ${e?.scrollWheelZoom?`scroll or pinch`:`pinch or Control and wheel`} to zoom, click to select.`,tabIndex:0,onWheel:Oe,onPointerDown:ke,onPointerMove:Ae,onPointerUp:je,onPointerCancel:ae,onLostPointerCapture:e=>{k.current.has(e.pointerId)&&ae()},onBlur:ae,onKeyDown:e=>{if(e.key===`Enter`&&u){let t=w.current,n=t.x+t.width/2,r=t.y+t.height/2;if(u===`pin`)f?.({kind:`point`,x:n,y:r});else if(u===`region`)f?.({kind:`region`,bounds:{x:n-t.width/8,y:r-t.height/8,width:t.width/4,height:t.height/4}});else{let e=s[0]??C.current?.hitTest(n,r);e&&f?.({kind:`nodes`,nodeIds:[e]})}e.preventDefault();return}(e.key===`+`||e.key===`=`)&&(De(1.5,T.current.width/2,T.current.height/2),e.preventDefault()),e.key===`-`&&(De(1/1.5,T.current.width/2,T.current.height/2),e.preventDefault()),e.key===`Escape`&&(ae(),d?.(null),te(!1),l([]),e.preventDefault()),e.key===`Home`&&(B(ed(r,i,a,T.current.width,T.current.height,n,E.current)),e.preventDefault());let t=e.key===`ArrowLeft`?[-40,0]:e.key===`ArrowRight`?[40,0]:e.key===`ArrowUp`?[0,-40]:e.key===`ArrowDown`?[0,40]:null;if(t){let n=w.current;B({...n,x:n.x+t[0]*n.width/T.current.width,y:n.y+t[1]*n.height/T.current.height}),e.preventDefault()}}}),e?.showPixelGrid&&me>=4?(0,G.jsx)(`div`,{className:`design-pixel-grid`,"aria-hidden":`true`,style:{backgroundSize:`${me}px ${me}px`,backgroundPosition:`${-I.x*me}px ${-I.y*me}px`}}):null,(0,G.jsx)(`div`,{ref:M,className:`design-annotation-pins`,children:p?Te.map(({id:e,annotation:t,point:n})=>{let r=t.blocking&&t.status===`open`,i=we.get(e)??0;return(0,G.jsxs)(jt,{children:[(0,G.jsx)(Ot,{render:(0,G.jsx)(`button`,{type:`button`,"data-design-pin":!0,"data-x":n.x,"data-y":n.y,"aria-label":`Open ${r?`blocking `:``}comment ${i} by ${t.author}`,className:`design-annotation-pin${r?` design-annotation-pin-blocking`:``}${t.status===`resolved`?` design-annotation-pin-resolved`:``}`,onClick:()=>p?.(e)}),children:(0,G.jsx)(`span`,{"aria-hidden":`true`,children:r?`!`:i})}),(0,G.jsxs)(kt,{children:[(0,G.jsx)(`strong`,{children:t.author}),` `,t.body.split(`
18
- `,1)[0]]})]},e)}):null}),(0,G.jsx)(`div`,{ref:j,className:`design-annotation-region`,hidden:!0}),ie?(0,G.jsx)(`div`,{className:`design-canvas-error`,role:`alert`,children:ie}):null]})}function nd(e){return e===void 0?`—`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?`${e.length} items`:`Object`}function rd(e){let t=(0,U.c)(43),{preferences:n,before:r,after:i,beforeRevision:a,afterRevision:o,viewKey:s,theme:c,beforeContext:l,beforeAssets:u,context:d,assets:f,selection:p,onSelect:m,onExit:h}=e,[g,_]=(0,H.useState)(`Before / after`),[v,y]=(0,H.useState)(50),[b,x]=(0,H.useState)(),S;t[0]!==i||t[1]!==r?(S=qr(r,i).filter(sd),t[0]=i,t[1]=r,t[2]=S):S=t[2];let C=S,w;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,G.jsx)(`strong`,{children:`Compare revisions`}),t[3]=w):w=t[3];let T;t[4]===a?T=t[5]:(T=a.slice(0,8),t[4]=a,t[5]=T);let E;t[6]===o?E=t[7]:(E=o.slice(0,8),t[6]=o,t[7]=E);let D;t[8]!==T||t[9]!==E?(D=(0,G.jsxs)(`div`,{className:`design-compare-revisions`,children:[w,(0,G.jsxs)(`span`,{className:`design-small-muted`,children:[`Before `,T,` · After `,E]})]}),t[8]=T,t[9]=E,t[10]=D):D=t[10];let O;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(O=[`Before / after`,`Overlay`,`Changes`],t[11]=O):O=t[11];let k;t[12]===g?k=t[13]:(k=(0,G.jsx)(`nav`,{"aria-label":`Compare display`,children:O.map(e=>(0,G.jsx)(`button`,{type:`button`,"aria-current":g===e?`page`:void 0,onClick:()=>_(e),children:e},e))}),t[12]=g,t[13]=k);let A;t[14]===h?A=t[15]:(A=(0,G.jsx)(W,{size:`sm`,variant:`outline`,onClick:h,children:`Exit compare`}),t[14]=h,t[15]=A);let j;t[16]!==k||t[17]!==A?(j=(0,G.jsxs)(`div`,{className:`design-compare-controls`,children:[k,A]}),t[16]=k,t[17]=A,t[18]=j):j=t[18];let M;t[19]!==D||t[20]!==j?(M=(0,G.jsxs)(`header`,{className:`design-compare-header`,children:[D,j]}),t[19]=D,t[20]=j,t[21]=M):M=t[21];let N;t[22]!==i||t[23]!==o||t[24]!==f||t[25]!==r||t[26]!==u||t[27]!==l||t[28]!==a||t[29]!==C||t[30]!==d||t[31]!==g||t[32]!==m||t[33]!==v||t[34]!==b||t[35]!==n||t[36]!==p||t[37]!==c||t[38]!==s?(N=g===`Changes`?(0,G.jsx)(`div`,{className:`design-compare-changes`,children:C.length?(0,G.jsx)(`ol`,{children:C.map(od)}):(0,G.jsx)(`p`,{children:`No content changes between these revisions.`})}):g===`Before / after`?(0,G.jsxs)(`div`,{className:`design-compare-pair`,children:[(0,G.jsxs)(`section`,{"aria-label":`Before revision ${a}`,children:[(0,G.jsxs)(`div`,{className:`design-compare-caption`,children:[`Before · `,a.slice(0,8)]}),(0,G.jsx)(td,{preferences:n,viewKey:`${s}:compare-before`,document:r,theme:c,context:l,assets:u,selection:[],changedNodeIds:[],onSelect:ad})]}),(0,G.jsxs)(`section`,{"aria-label":`After revision ${o}`,children:[(0,G.jsxs)(`div`,{className:`design-compare-caption`,children:[`After · `,o.slice(0,8)]}),(0,G.jsx)(td,{preferences:n,viewKey:`${s}:compare-after`,document:i,theme:c,context:d,assets:f,selection:p,changedNodeIds:[],onSelect:m})]})]}):(0,G.jsxs)(`div`,{className:`design-compare-overlay`,children:[(0,G.jsxs)(`label`,{className:`design-compare-opacity`,children:[`After opacity`,` `,(0,G.jsx)(`input`,{type:`range`,min:`0`,max:`100`,value:v,onChange:e=>y(Number(e.target.value))}),` `,v,`%`]}),(0,G.jsxs)(`div`,{className:`design-compare-overlay-stack`,children:[(0,G.jsx)(td,{preferences:n,viewKey:`${s}:compare-overlay-before`,document:r,theme:c,context:l,assets:u,selection:[],changedNodeIds:[],onSelect:id,externalViewport:b}),(0,G.jsx)(`div`,{style:{"--design-after-opacity":v/100},"aria-label":`After revision ${o}`,children:(0,G.jsx)(td,{preferences:n,viewKey:`${s}:compare-overlay-after`,document:i,theme:c,context:d,assets:f,selection:p,changedNodeIds:[],onSelect:m,onViewportChange:x})})]})]}),t[22]=i,t[23]=o,t[24]=f,t[25]=r,t[26]=u,t[27]=l,t[28]=a,t[29]=C,t[30]=d,t[31]=g,t[32]=m,t[33]=v,t[34]=b,t[35]=n,t[36]=p,t[37]=c,t[38]=s,t[39]=N):N=t[39];let P;return t[40]!==M||t[41]!==N?(P=(0,G.jsxs)(`div`,{className:`design-compare`,children:[M,N]}),t[40]=M,t[41]=N,t[42]=P):P=t[42],P}function id(){}function ad(){}function od(e){return(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`strong`,{children:e.kind}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`code`,{children:e.path}),(0,G.jsxs)(`small`,{children:[nd(e.before),` → `,nd(e.after)]})]})]},e.path)}function sd(e){return!/^\/(annotations|reviews|acceptances)(\/|$)/.test(e.path)}function cd(e){if(e.fills?.[0]?.kind===`image`)return{label:`Image`,icon:ze};switch(e.type){case`frame`:return{label:`Frame`,icon:Fe};case`group`:return{label:`Group`,icon:Ie};case`rectangle`:return{label:`Rectangle`,icon:it};case`ellipse`:return{label:`Ellipse`,icon:Oe};case`path`:return{label:`Path`,icon:rt};case`text`:return{label:`Text`,icon:ot};case`ref`:return{label:`Component`,icon:ke}}}var ld=on,ud=an;function dd(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(In,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(ln,{forceRender:!0,className:i,"data-slot":`dialog-backdrop`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function fd(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`fixed inset-0 z-50 grid grid-rows-[1fr_auto_1fr] justify-items-center p-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(rn,{className:i,"data-slot":`dialog-viewport`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function pd(e){let t=(0,U.c)(22),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,showCloseButton:a,bottomStickOnMobile:o,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=a===void 0||a,c=o===void 0||o,l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,G.jsx)(dd,{}),t[6]=l):l=t[6];let u=c&&`max-sm:grid-rows-[1fr_auto] max-sm:p-0 max-sm:pt-12`,d;t[7]===u?d=t[8]:(d=V(u),t[7]=u,t[8]=d);let f=c&&`max-sm:max-w-none max-sm:rounded-none max-sm:border-x-0 max-sm:border-t max-sm:border-b-0 max-sm:opacity-[calc(1-min(var(--nested-dialogs),1))] max-sm:data-ending-style:translate-y-4 max-sm:data-starting-style:translate-y-4`,p;t[9]!==r||t[10]!==f?(p=V(Ln,`row-start-2 max-h-full max-w-lg text-popover-foreground`,f,r),t[9]=r,t[10]=f,t[11]=p):p=t[11];let m;t[12]===s?m=t[13]:(m=s&&(0,G.jsx)(nn,{"aria-label":`Close`,className:`absolute end-2 top-2`,render:(0,G.jsx)(W,{size:`icon`,variant:`ghost`}),children:(0,G.jsx)(lt,{})}),t[12]=s,t[13]=m);let h;t[14]!==n||t[15]!==i||t[16]!==p||t[17]!==m?(h=(0,G.jsxs)(sn,{className:p,"data-slot":`dialog-popup`,...i,children:[n,m]}),t[14]=n,t[15]=i,t[16]=p,t[17]=m,t[18]=h):h=t[18];let g;return t[19]!==d||t[20]!==h?(g=(0,G.jsxs)(ud,{children:[l,(0,G.jsx)(fd,{className:d,children:h})]}),t[19]=d,t[20]=h,t[21]=g):g=t[21],g}function md(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`flex flex-col gap-2 p-6 in-[[data-slot=dialog-popup]:has([data-slot=dialog-panel])]:pb-3 max-sm:pb-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(`div`,{className:i,"data-slot":`dialog-header`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function hd(e){let t=(0,U.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,variant:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`default`:i,o=a==="default"&&`border-t bg-muted/72 py-4`,s=a===`bare`&&`py-4`,c;t[4]!==n||t[5]!==o||t[6]!==s?(c=V(`flex flex-col-reverse gap-2 px-6 sm:flex-row sm:justify-end sm:rounded-b-[calc(var(--radius-2xl)-1px)]`,o,s,n),t[4]=n,t[5]=o,t[6]=s,t[7]=c):c=t[7];let l;return t[8]!==r||t[9]!==c?(l=(0,G.jsx)(`div`,{className:c,"data-slot":`dialog-footer`,...r}),t[8]=r,t[9]=c,t[10]=l):l=t[10],l}function gd(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`font-heading font-semibold text-xl leading-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(cn,{className:i,"data-slot":`dialog-title`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function _d(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`text-muted-foreground text-sm`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(tn,{className:i,"data-slot":`dialog-description`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function vd(e){let t=(0,U.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,scrollFade:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0||i,o;t[4]===n?o=t[5]:(o=V(`p-6 in-[[data-slot=dialog-popup]:has([data-slot=dialog-header])]:pt-1 in-[[data-slot=dialog-popup]:has([data-slot=dialog-footer]:not(.border-t))]:pb-1`,n),t[4]=n,t[5]=o);let s;t[6]!==r||t[7]!==o?(s=(0,G.jsx)(`div`,{className:o,"data-slot":`dialog-panel`,...r}),t[6]=r,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==a||t[10]!==s?(c=(0,G.jsx)(fr,{scrollFade:a,children:s}),t[9]=a,t[10]=s,t[11]=c):c=t[11],c}function yd(e){let t=(0,U.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`relative inline-flex size-4.5 shrink-0 items-center justify-center rounded-[.25rem] border border-input bg-background not-dark:bg-clip-padding shadow-xs/5 outline-none ring-ring transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[3px] not-data-disabled:not-data-checked:not-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-offset-background aria-invalid:border-destructive/36 focus-visible:aria-invalid:border-destructive/64 focus-visible:aria-invalid:ring-destructive/48 data-disabled:opacity-64 sm:size-4 dark:not-data-checked:bg-input/32 dark:aria-invalid:ring-destructive/24 dark:not-data-disabled:not-data-checked:not-aria-invalid:before:shadow-[0_-1px_--theme(--color-white/6%)] [[data-disabled],[data-checked],[aria-invalid]]:shadow-none`,n),t[3]=n,t[4]=i);let a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,G.jsx)(Pt,{className:`-inset-px absolute flex items-center justify-center rounded-[.25rem] text-primary-foreground data-unchecked:hidden data-checked:bg-primary data-indeterminate:text-foreground`,"data-slot":`checkbox-indicator`,render:bd}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,G.jsx)(Nt,{className:i,"data-slot":`checkbox`,...r,children:a}),t[6]=r,t[7]=i,t[8]=o):o=t[8],o}function bd(e,t){return(0,G.jsx)(`span`,{...e,children:t.indeterminate?(0,G.jsx)(`svg`,{className:`size-3.5 sm:size-3`,fill:`none`,height:`24`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`3`,viewBox:`0 0 24 24`,width:`24`,xmlns:`http://www.w3.org/2000/svg`,children:(0,G.jsx)(`path`,{d:`M5.252 12h13.496`})}):(0,G.jsx)(`svg`,{className:`size-3.5 sm:size-3`,fill:`none`,height:`24`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`3`,viewBox:`0 0 24 24`,width:`24`,xmlns:`http://www.w3.org/2000/svg`,children:(0,G.jsx)(`path`,{d:`M5.252 12.7 10.2 18.63 18.748 5.37`})})})}function xd(e){let t=(0,U.c)(9),n,r,a,o;if(t[0]!==e){let{className:s,render:c,...l}=e;n=c;let u={className:V(`inline-flex items-center gap-2 text-base/4.5 sm:text-sm/4 font-medium text-foreground`,s),"data-slot":`label`};o=I,r=`label`,a=i(u,l),t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=o}else n=t[1],r=t[2],a=t[3],o=t[4];let s;return t[5]!==n||t[6]!==r||t[7]!==a?(s={defaultTagName:r,props:a,render:n},t[5]=n,t[6]=r,t[7]=a,t[8]=s):s=t[8],o(s)}function Sd(e){let t=(0,U.c)(16),n=Yn(),r=$n(),i=(0,H.useRef)(null),[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(null),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=[],t[0]=d):d=t[0];let[f,p]=(0,H.useState)(d),[m,h]=(0,H.useState)(null),g,_;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>()=>i.current?.abort(),_=[],t[1]=g,t[2]=_):(g=t[1],_=t[2]),(0,H.useEffect)(g,_);let v;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>i.current?.abort(),t[3]=v):v=t[3];let y=v,b;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{y(),c(null),u(null),p([]),h(null)},t[4]=b):b=t[4];let x=b,C;t[5]!==n||t[6]!==r||t[7]!==e?(C=async t=>{if(!e)return null;y();let a=new AbortController;i.current=a,o(!0),c(null),u(null),p([]),h(null);let s=[],l=null,d=k(()=>new Promise(e=>{a.signal.aborted?e():a.signal.addEventListener(`abort`,()=>e(),{once:!0})})),f=null;try{await r(S(w(n.transport.transfer(e,t),e=>ue(()=>{a.signal.aborted||(e.kind===`progress`&&c(e),e.kind===`chunk`&&s.push(Uint8Array.from(atob(e.base64),Cd)),e.kind===`complete`&&(l=e))})),d))}catch(e){f={cause:e}}if(i.current!==a)return null;let m=a.signal.aborted;return i.current===a&&(i.current=null),a.abort(),o(!1),m?null:f?(h(f.cause instanceof Error?f.cause.message:String(f.cause)),null):l?(u(l),p(s),l):(h(`Transfer ended before a result was received.`),null)},t[5]=n,t[6]=r,t[7]=e,t[8]=C):C=t[8];let T=C,E;return t[9]!==a||t[10]!==f||t[11]!==m||t[12]!==s||t[13]!==l||t[14]!==T?(E={busy:a,progress:s,result:l,bytes:f,error:m,run:T,cancel:y,reset:x},t[9]=a,t[10]=f,t[11]=m,t[12]=s,t[13]=l,t[14]=T,t[15]=E):E=t[15],E}function Cd(e){return e.charCodeAt(0)}var wd={svg:`.svg,image/svg+xml`,png:`.png,image/png`,jpeg:`.jpg,.jpeg,image/jpeg`,webp:`.webp,image/webp`,"figma-rest":``,"figma-plugin":`.json,application/json`},Td=[[`svg`,`SVG`],[`png`,`PNG`],[`jpeg`,`JPEG`],[`webp`,`WebP`],[`figma-rest`,`Figma URL`],[`figma-plugin`,`Figma plugin bundle`]];function Ed(e){let t=(0,U.c)(18),{id:n,value:r,onChange:i,options:a,disabled:o}=e,s;t[0]===a?s=t[1]:(s=a.map(Od),t[0]=a,t[1]=s);let c;t[2]===i?c=t[3]:(c=e=>{e!==null&&i(e)},t[2]=i,t[3]=c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,G.jsx)(ai,{}),t[4]=l):l=t[4];let u;t[5]===n?u=t[6]:(u=(0,G.jsx)(ii,{id:n,children:l}),t[5]=n,t[6]=u);let d;t[7]===a?d=t[8]:(d=a.map(Dd),t[7]=a,t[8]=d);let f;t[9]===d?f=t[10]:(f=(0,G.jsx)(oi,{children:d}),t[9]=d,t[10]=f);let p;return t[11]!==o||t[12]!==s||t[13]!==c||t[14]!==u||t[15]!==f||t[16]!==r?(p=(0,G.jsxs)(ni,{modal:!1,value:r,disabled:o,items:s,onValueChange:c,children:[u,f]}),t[11]=o,t[12]=s,t[13]=c,t[14]=u,t[15]=f,t[16]=r,t[17]=p):p=t[17],p}function Dd(e){let[t,n,r]=e;return(0,G.jsx)(si,{value:t,disabled:r,children:n},String(t))}function Od(e){let[t,n]=e;return{value:t,label:n}}async function kd(e){let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=8192)n+=String.fromCharCode(...t.subarray(e,e+8192));return btoa(n)}function Ad(e,t,n){let r=new Blob(e.map(e=>new Uint8Array(e)),{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,a.click(),setTimeout(()=>URL.revokeObjectURL(i),3e4)}function jd({open:e,mode:t,onModeChange:n,onOpenChange:r,target:i,documentPath:a,revision:o,document:s,selection:c,theme:l,onImportComplete:u,onOpenImported:d}){let f=Sd(i),[p,m]=(0,H.useState)(`svg`),[h,g]=(0,H.useState)(`png`),[_,v]=(0,H.useState)(null),[y,b]=(0,H.useState)(``),[x,S]=(0,H.useState)(``),[C,w]=(0,H.useState)(``),[T,E]=(0,H.useState)(!1),[D,O]=(0,H.useState)(`selection`),[k,A]=(0,H.useState)(1),[j,M]=(0,H.useState)(`transparent`),[N,P]=(0,H.useState)(null),[F,ee]=(0,H.useState)(!1),te=(0,H.useRef)(0),I=(0,H.useRef)(null),L=f.busy&&f.progress?.stage===`Saving document`,ne=s?Object.entries(s.nodes).filter(([,e])=>e.type===`frame`):[],re=i?{projectId:i.projectId,...i.threadId?{threadId:i.threadId}:{}}:null,ie=e=>{if(!e){if(L)return;te.current+=1,f.reset(),ee(!1),S(``),v(null),b(``),w(``),P(null)}r(e)},R=async()=>{if(!re)return;if(P(null),t===`import`){let e=C.trim();if(!e.toLowerCase().endsWith(`.p4design`)){P(`Choose a new .p4design destination path.`);return}if(p===`figma-rest`?!y.trim():!_){P(p===`figma-rest`?`Enter a Figma file URL.`:`Choose a file.`);return}ee(!0);let t=++te.current,n;try{_&&p!==`figma-rest`&&(n=await kd(_))}catch{P(`The selected file could not be read. Choose it again.`),ee(!1);return}if(te.current!==t)return;ee(!1),await f.run({kind:`import`,target:re,documentPath:e,format:p,sourceName:_?.name??y.trim(),...n?{payload:n}:{},...p===`figma-rest`?{url:y.trim(),...x.trim()?{token:x.trim()}:{}}:{},allowMissingAssets:T})&&u();return}let e=D===`selection`?c.length?[...c]:ne[0]?[ne[0][0]]:[]:[D];if(!s||!a||!o||!e.length){P(`Select a node or frame in a ready design to export.`);return}await f.run({kind:`export`,target:re,documentPath:a,expectedContentHash:o,nodeIds:e,format:h,scale:k,background:j,theme:l})};return(0,G.jsx)(ld,{open:e,onOpenChange:ie,children:(0,G.jsxs)(pd,{className:`design-transfer-dialog max-w-lg`,showCloseButton:!L,children:[(0,G.jsxs)(md,{children:[(0,G.jsx)(gd,{children:`Design transfer`}),(0,G.jsx)(_d,{children:`Import a design or export selected canvas content.`})]}),(0,G.jsxs)(vd,{className:`design-transfer-panel`,children:[(0,G.jsx)(`div`,{className:`design-transfer-tabs`,role:`tablist`,"aria-label":`Transfer direction`,children:[`import`,`export`].map(e=>(0,G.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e,disabled:f.busy||F,onClick:()=>{n(e),f.reset(),P(null)},children:e===`import`?`Import`:`Export`},e))}),t===`import`?(0,G.jsxs)(`div`,{className:`design-transfer-fields`,children:[(0,G.jsx)(xd,{htmlFor:`design-import-format`,children:`Source format`}),(0,G.jsx)(Ed,{id:`design-import-format`,value:p,disabled:f.busy||F,options:Td,onChange:e=>{m(e),v(null),f.reset()}}),p===`figma-rest`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(xd,{htmlFor:`design-figma-url`,children:`Figma file URL`}),(0,G.jsx)(Dn,{id:`design-figma-url`,type:`url`,value:y,onChange:e=>b(e.target.value)}),(0,G.jsx)(xd,{htmlFor:`design-figma-token`,children:`Figma token`}),(0,G.jsx)(Dn,{id:`design-figma-token`,type:`password`,value:x,onChange:e=>S(e.target.value),placeholder:`Leave blank to use stored token`,autoComplete:`off`})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(xd,{htmlFor:`design-import-file`,children:`Source file`}),(0,G.jsxs)(`div`,{className:`design-transfer-file`,children:[(0,G.jsx)(W,{id:`design-import-file`,size:`sm`,variant:`outline`,disabled:f.busy||F,onClick:()=>I.current?.click(),children:`Choose file`}),(0,G.jsx)(`span`,{className:`design-truncate design-small-muted`,"aria-live":`polite`,children:_?_.name:`No file chosen`}),(0,G.jsx)(`input`,{ref:I,type:`file`,hidden:!0,accept:wd[p],onChange:e=>{let t=e.target.files?.[0]??null;e.target.value=``,v(t),t&&!C.trim()&&w(`${t.name.replace(/\.[^.]+$/,``)}.p4design`)}})]}),p===`figma-plugin`?(0,G.jsx)(`p`,{className:`design-transfer-hint`,children:`Choose the JSON bundle exported by the Figma plugin.`}):null]}),(0,G.jsx)(xd,{htmlFor:`design-import-destination`,children:`New design path`}),(0,G.jsx)(Dn,{id:`design-import-destination`,value:C,onChange:e=>w(e.target.value),placeholder:`home.p4design`}),(0,G.jsxs)(`label`,{className:`design-transfer-checkbox`,children:[(0,G.jsx)(yd,{checked:T,onCheckedChange:e=>E(e===!0)}),`Import with placeholders if assets fail`]})]}):(0,G.jsxs)(`div`,{className:`design-transfer-fields`,children:[!s||!o?(0,G.jsx)(`p`,{className:`design-transfer-hint`,children:`Open a ready design to export.`}):null,(0,G.jsx)(xd,{htmlFor:`design-export-scope`,children:`Export content`}),(0,G.jsx)(Ed,{id:`design-export-scope`,value:!c.length&&D===`selection`?ne[0]?.[0]??D:D,onChange:O,options:[[`selection`,`Selection (${c.length})`,!c.length],...ne.map(([e,t])=>[e,`Frame: ${t.name||e.slice(0,8)}`])]}),(0,G.jsx)(xd,{htmlFor:`design-export-format`,children:`Format`}),(0,G.jsx)(Ed,{id:`design-export-format`,value:h,onChange:g,options:[[`png`,`PNG`],[`svg`,`SVG`],[`pdf`,`PDF`]]}),(0,G.jsx)(xd,{htmlFor:`design-export-scale`,children:`Scale`}),(0,G.jsx)(Ed,{id:`design-export-scale`,value:k,onChange:A,options:[[.5,`0.5x`],[1,`1x`],[2,`2x`],[4,`4x`]]}),(0,G.jsx)(xd,{htmlFor:`design-export-background`,children:`Background`}),(0,G.jsx)(Ed,{id:`design-export-background`,value:j,onChange:M,options:[[`transparent`,`Transparent`],[`#FFFFFF`,`White`]]})]}),F?(0,G.jsx)(`p`,{role:`status`,children:`Reading source file…`}):null,f.progress&&!f.result&&!f.error&&!N?(0,G.jsxs)(`div`,{className:`design-transfer-progress`,role:`status`,children:[(0,G.jsx)(`span`,{children:L?`Finishing save`:f.progress.stage}),(0,G.jsx)(`progress`,{value:f.progress.total>0?f.progress.completed:void 0,max:f.progress.total||void 0}),f.progress.total>0?(0,G.jsxs)(`small`,{children:[f.progress.completed,` / `,f.progress.total]}):null]}):null,N||f.error?(0,G.jsx)(`p`,{className:`design-transfer-error`,role:`alert`,children:N??f.error}):null,f.result?(0,G.jsxs)(`div`,{className:`design-transfer-result`,role:`status`,children:[(0,G.jsx)(`strong`,{children:t===`import`?`Import complete`:`Export ready`}),(0,G.jsxs)(`span`,{children:[`Source: `,f.result.provenance]}),f.result.unsupported.length?(0,G.jsxs)(`span`,{children:[`Unsupported: `,f.result.unsupported.join(`, `)]}):null,f.result.failedAssets.length?(0,G.jsxs)(`span`,{children:[`Failed assets: `,f.result.failedAssets.join(`, `)]}):null,f.result.diagnostics.length?(0,G.jsx)(`ul`,{children:[...new Set(f.result.diagnostics.map(e=>e.message))].map(e=>(0,G.jsx)(`li`,{children:e},e))}):null,t===`import`?(0,G.jsx)(W,{size:`sm`,variant:`outline`,onClick:()=>{d(f.result.documentPath),ie(!1)},children:`Open design`}):f.result.filename&&f.result.mimeType&&f.bytes.length?(0,G.jsxs)(W,{size:`sm`,variant:`outline`,onClick:()=>Ad(f.bytes,f.result.filename,f.result.mimeType),children:[`Download `,f.result.filename]}):null]}):null]}),(0,G.jsxs)(hd,{children:[(0,G.jsx)(W,{variant:`outline`,disabled:L,onClick:()=>ie(!1),children:L?`Finishing save`:f.busy||F?`Cancel`:`Close`}),(0,G.jsx)(W,{disabled:!i||f.busy||F||t===`export`&&(!s||!o||!c.length&&!ne.length),onClick:()=>void R(),children:f.error||N?`Retry`:t===`import`?`Import`:`Export`})]})]})})}var Md=e=>`${e}T00:00:00.000Z`;function Nd(e,t,n){let r=e.slice(0,10);return`${t===`open`&&r<n?`Overdue`:`Due`} ${r}`}var Pd=e=>{Promise.resolve().then(e).catch(()=>{})};function Fd(e){let t=(0,U.c)(49),{anchor:n,onSubmit:r,onCancel:i,busy:a}=e,o=a!==void 0&&a,[s,c]=(0,H.useState)(``),[l,u]=(0,H.useState)(``),[d,f]=(0,H.useState)(``),[p,m]=(0,H.useState)(``),[h,g]=(0,H.useState)(!1),_=n.kind===`nodes`?`${n.nodeIds.length} selected ${n.nodeIds.length===1?`node`:`nodes`}`:n.kind===`region`?`Canvas region`:`Canvas pin`,v;t[0]!==n||t[1]!==l||t[2]!==h||t[3]!==s||t[4]!==o||t[5]!==p||t[6]!==d||t[7]!==r?(v=e=>{e.preventDefault(),s.trim()&&!o&&Pd(()=>r({anchor:n,body:s.trim(),blocking:h,labels:d.split(`,`).map(Id).filter(Boolean),...l.trim()?{assignee:l.trim()}:{},...p?{dueAt:Md(p)}:{}}))},t[0]=n,t[1]=l,t[2]=h,t[3]=s,t[4]=o,t[5]=p,t[6]=d,t[7]=r,t[8]=v):v=t[8];let y;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,G.jsx)(`strong`,{children:`New comment`}),t[9]=y):y=t[9];let b;t[10]===_?b=t[11]:(b=(0,G.jsxs)(`div`,{className:`design-editor-heading`,children:[y,(0,G.jsxs)(`span`,{className:`design-small-muted`,children:[`Anchored to `,_,` in this revision`]})]}),t[10]=_,t[11]=b);let x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>c(e.target.value),t[12]=x):x=t[12];let S;t[13]===s?S=t[14]:(S=(0,G.jsxs)(`label`,{children:[`Comment`,(0,G.jsx)(`textarea`,{value:s,onChange:x,rows:3,required:!0,placeholder:`What should be reviewed?`})]}),t[13]=s,t[14]=S);let C;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>u(e.target.value),t[15]=C):C=t[15];let w;t[16]===l?w=t[17]:(w=(0,G.jsxs)(`label`,{children:[`Assignee`,(0,G.jsx)(`input`,{value:l,onChange:C})]}),t[16]=l,t[17]=w);let T;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>m(e.target.value),t[18]=T):T=t[18];let E;t[19]===p?E=t[20]:(E=(0,G.jsxs)(`label`,{children:[`Due`,(0,G.jsx)(`input`,{type:`date`,value:p,onChange:T})]}),t[19]=p,t[20]=E);let D;t[21]!==E||t[22]!==w?(D=(0,G.jsxs)(`div`,{className:`design-editor-fields`,children:[w,E]}),t[21]=E,t[22]=w,t[23]=D):D=t[23];let O;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,G.jsx)(`span`,{className:`design-small-muted`,children:`(comma separated)`}),t[24]=O):O=t[24];let k;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(k=e=>f(e.target.value),t[25]=k):k=t[25];let A;t[26]===d?A=t[27]:(A=(0,G.jsxs)(`label`,{children:[`Labels `,O,(0,G.jsx)(`input`,{value:d,onChange:k})]}),t[26]=d,t[27]=A);let j;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>g(e.target.checked),t[28]=j):j=t[28];let M;t[29]===h?M=t[30]:(M=(0,G.jsxs)(`label`,{className:`design-editor-checkbox`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:h,onChange:j}),`Mark as blocking`]}),t[29]=h,t[30]=M);let N;t[31]===i?N=t[32]:(N=(0,G.jsx)(W,{type:`button`,size:`sm`,variant:`ghost`,onClick:i,children:`Cancel`}),t[31]=i,t[32]=N);let P;t[33]!==s||t[34]!==o?(P=o||!s.trim(),t[33]=s,t[34]=o,t[35]=P):P=t[35];let F;t[36]===P?F=t[37]:(F=(0,G.jsx)(W,{type:`submit`,size:`sm`,disabled:P,children:`Post comment`}),t[36]=P,t[37]=F);let ee;t[38]!==N||t[39]!==F?(ee=(0,G.jsxs)(`div`,{className:`design-editor-actions`,children:[N,F]}),t[38]=N,t[39]=F,t[40]=ee):ee=t[40];let te;return t[41]!==D||t[42]!==A||t[43]!==M||t[44]!==v||t[45]!==ee||t[46]!==b||t[47]!==S?(te=(0,G.jsxs)(`form`,{className:`design-annotation-editor`,onSubmit:v,children:[b,S,D,A,M,ee]}),t[41]=D,t[42]=A,t[43]=M,t[44]=v,t[45]=ee,t[46]=b,t[47]=S,t[48]=te):te=t[48],te}function Id(e){return e.trim()}function Ld(e){let t=(0,U.c)(17),{document:n,currentRevision:r,actions:i,busy:a,focusedId:o}=e,s=a!==void 0&&a,[c,l]=(0,H.useState)(null),[u,d]=(0,H.useState)(``),f=Object.entries(n.annotations).sort(Bd),p;t[0]===n.annotations?p=t[1]:(p=Ju(n.annotations),t[0]=n.annotations,t[1]=p);let m=p,h;t[2]===o?h=t[3]:(h=()=>{o&&globalThis.document.getElementById(`design-comment-${o}`)?.scrollIntoView({block:`nearest`})},t[2]=o,t[3]=h);let g;if(t[4]!==n||t[5]!==o?(g=[o,n],t[4]=n,t[5]=o,t[6]=g):g=t[6],(0,H.useEffect)(h,g),!f.length){let e;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,G.jsx)(`div`,{className:`design-notice`,children:(0,G.jsx)(`strong`,{children:`No comments`})}),t[7]=e):e=t[7],e}let _;t[8]!==i||t[9]!==s||t[10]!==r||t[11]!==m||t[12]!==u||t[13]!==c?(_=e=>{let[t,n]=e;return(0,G.jsxs)(`article`,{id:`design-comment-${t}`,className:`design-comment`,children:[(0,G.jsxs)(`div`,{className:`design-comment-heading`,children:[(0,G.jsx)(`span`,{className:`design-comment-number${n.blocking&&n.status===`open`?` design-comment-number-blocking`:``}`,"aria-label":`Comment ${m.get(t)??``}`,children:m.get(t)}),(0,G.jsx)(`strong`,{children:n.author}),(0,G.jsx)(`span`,{className:`design-small-muted`,children:n.status===`open`?`Open`:`Resolved`})]}),(0,G.jsx)(`p`,{children:n.body}),(0,G.jsxs)(`div`,{className:`design-comment-meta`,children:[n.blocking&&n.status===`open`?(0,G.jsx)(dr,{variant:`warning`,children:`Blocking`}):null,(0,G.jsx)(`span`,{children:n.anchor.kind===`nodes`?`${n.anchor.nodeIds.length} ${n.anchor.nodeIds.length===1?`layer`:`layers`}`:n.anchor.kind===`region`?`Region`:`Pin`}),n.revision===r?null:(0,G.jsxs)(`span`,{children:[`Revision `,n.revision.slice(0,8)]}),n.assignee?(0,G.jsxs)(`span`,{children:[`Assigned to `,n.assignee]}):null,n.dueAt?(0,G.jsx)(`span`,{children:Nd(n.dueAt,n.status,new Date().toISOString().slice(0,10))}):null,n.labels.map(zd)]}),n.replies.map(Rd),i?(0,G.jsxs)(`div`,{className:`design-comment-actions`,children:[(0,G.jsx)(W,{size:`sm`,variant:`ghost`,disabled:s,onClick:()=>{l(t),d(``)},children:`Reply`}),(0,G.jsx)(W,{size:`sm`,variant:`ghost`,disabled:s,onClick:()=>Pd(()=>i.setResolved(t,n.status===`open`)),children:n.status===`open`?`Resolve`:`Reopen`})]}):null,c===t&&i?(0,G.jsxs)(`form`,{className:`design-reply-form`,onSubmit:e=>{e.preventDefault(),u.trim()&&!s&&Pd(async()=>{await i.reply(t,u.trim()),l(null),d(``)})},children:[(0,G.jsxs)(`label`,{children:[`Reply`,(0,G.jsx)(`textarea`,{rows:2,value:u,onChange:e=>d(e.target.value),required:!0})]}),(0,G.jsxs)(`div`,{className:`design-editor-actions`,children:[(0,G.jsx)(W,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>l(null),children:`Cancel`}),(0,G.jsx)(W,{type:`submit`,size:`sm`,disabled:s||!u.trim(),children:`Send reply`})]})]}):null]},t)},t[8]=i,t[9]=s,t[10]=r,t[11]=m,t[12]=u,t[13]=c,t[14]=_):_=t[14];let v=f.map(_),y;return t[15]===v?y=t[16]:(y=(0,G.jsx)(`div`,{className:`design-comments`,"aria-label":`Design comments`,children:v}),t[15]=v,t[16]=y),y}function Rd(e){return(0,G.jsxs)(`div`,{className:`design-reply`,children:[(0,G.jsx)(`strong`,{children:e.author}),(0,G.jsx)(`p`,{children:e.body})]},e.id)}function zd(e){return(0,G.jsx)(`span`,{className:`design-comment-label`,children:e},e)}function Bd(e,t){let[,n]=e,[,r]=t;return r.createdAt.localeCompare(n.createdAt)}function Vd(e,t){let n=structuredClone(e),r=Vr(n),i=n,a=i.nodes,o=e=>{if(e===null)return i.roots;let t=a[e];if(!t||!(`children`in t))throw Error(`Parent must be a frame or group`);return t.children},s=e=>{if(!a[e])throw Error(`Node is missing`);let t=r.parents.get(e)??null,i=t&&a[t]?.type===`ref`?Object.values(n.instances[t]?.slots??{}).find(t=>t.includes(e)):o(t);if(!i)throw Error(`Node has no tree position`);let s=i.indexOf(e);if(s<0)throw Error(`Node has no tree position`);i.splice(s,1)},c=(e,t,n)=>{let r=o(t);if(n>r.length)throw Error(`Position is outside the ordered child list`);r.splice(n,0,e)},l=(e,t,n)=>{let r=e;n===null?delete r[t]:r[t]=n};switch(t.kind){case`insert`:case`instantiate`:if(a[t.nodeId])throw Error(`Node ID already exists`);a[t.nodeId]=t.node,c(t.nodeId,t.parentId,t.index),t.kind===`instantiate`&&l(n.instances,t.nodeId,t.instance);break;case`patch`:if(!a[t.nodeId])throw Error(`Node is missing`);a[t.nodeId]=Br(a[t.nodeId],t.patch);break;case`move`:s(t.nodeId),c(t.nodeId,t.parentId,t.index);break;case`remove`:{s(t.nodeId);let e=t=>{let r=a[t];r&&`children`in r&&r.children.forEach(e);for(let r of Object.values(n.instances[t]?.slots??{}))r.forEach(e);delete a[t],l(n.instances,t,null)};e(t.nodeId);break}case`override`:{let e=n.instances[t.instanceId];if(!e)throw Error(`Instance is missing`);l(e.overrides,t.sourceNodeId,t.patch);break}case`slots`:{let e=n.instances[t.instanceId];if(!e)throw Error(`Instance is missing`);let r=e.slots[t.slotId]??[];for(let e of t.children)s(e);for(let e of r)t.children.includes(e)||i.roots.push(e);l(e.slots,t.slotId,t.children);break}case`component`:l(n.components,t.componentId,t.value);break;case`library`:l(n.imports,t.importId,t.value);break;case`token`:l(n.tokens,t.tokenId,t.value);break;case`theme`:l(n.themeAxes,t.axis,t.values);break;case`asset`:l(n.assets,t.assetId,t.value);break;case`annotation`:l(n.annotations,t.annotationId,t.value);break;case`review`:l(n.reviews,t.reviewId,t.value);break;case`acceptance`:i.acceptances??={},l(i.acceptances,t.acceptanceId,t.value)}let u=zr(Lr(n));if(u.status!==`editable`)throw Error(`Operation violates the document schema`);return u.document}var Hd=()=>({fileHash:null,contentHash:null,diagnostics:[],readOnly:!1,status:`loading`,selection:[],changedNodeIds:[],batch:null,sequence:-1}),Ud=new Set([`component`,`library`,`token`,`theme`,`asset`]);function Wd(e){let t=new Set,n=new Set(e.changedNodeIds);for(let r of e.operations){let e=`nodeId`in r?r.nodeId:`instanceId`in r?r.instanceId:null;e&&n.has(e)&&t.add(e)}if(e.operations.some(e=>Ud.has(e.kind)))for(let n of e.changedNodeIds)t.add(n);return[...t]}function Gd(e,t,n,r){if(t.kind!==`snapshot`&&t.sequence<e.sequence)return e;if(t.kind===`snapshot`){if(n===void 0)throw Error(`Snapshot payload must be decoded`);let i=zr(n);return{...e,documentPath:t.documentPath,...i.status===`editable`?{document:i.document}:{document:void 0},fileHash:t.fileHash,contentHash:t.contentHash,diagnostics:t.diagnostics,readOnly:t.readOnly,status:`ready`,sequence:t.sequence,changedNodeIds:[],batch:null,...r?{context:r}:{},selection:e.selection.filter(e=>i.status===`editable`&&!!i.document.nodes[e])}}if(t.sequence===e.sequence&&t.fileHash===e.fileHash)return e;if(e.status===`conflict`||!e.document||t.sequence!==e.sequence+1||t.previousFileHash!==e.fileHash)return{...e,status:`conflict`,readOnly:!0};try{let n=e.document;for(let e of t.operations)n=Vd(n,e);if(Rr(Lr(n))!==t.fileHash)throw Error(`Committed operation hash mismatch`);return{...e,document:n,fileHash:t.fileHash,contentHash:t.contentHash,diagnostics:t.diagnostics,sequence:t.sequence,status:`ready`,readOnly:!1,changedNodeIds:[...t.changedNodeIds],batch:t.changedNodeIds.length?{sequence:t.sequence,nodeIds:Wd(t)}:null,selection:(t.selection&&t.selection.documentPath===e.documentPath&&t.selection.revision===t.contentHash?t.selection.nodeIds:e.selection).filter(e=>!!n.nodes[e]),...r?{context:r}:{}}}catch{return{...e,status:`conflict`,readOnly:!0}}}var Kd=class extends g(`DesignSyncError`){},qd=(e,t)=>JSON.stringify([e,t]),Jd=Hd(),Yd=E(e=>({records:{},setRecord:(t,n)=>e(e=>({records:{...e.records,[t]:n}}))}));async function Xd(e){let t=Uint8Array.from(atob(e),e=>e.charCodeAt(0)),n=new Blob([t]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Response(n).text()}var Zd=A(P(h));async function Qd(e,{event:t,fetchAsset:n}){let r=t.kind===`snapshot`?await Xd(t.payload):void 0,i;if(t.dependencies){let e=Zd(await Xd(t.dependencies));i={...e.manifest?{manifest:e.manifest}:{},documents:e.documents,documentPath:e.documentPath,availableAssets:new Set(e.availableAssets)}}let a=Gd(Yd.getState().records[e]??Hd(),t,r,i);if(Yd.getState().setRecord(e,a),a.status===`conflict`)throw Error(`Design revision changed; reload the document`);let[o,s]=JSON.parse(e),c=a.context;if(!a.document||!c||!t.dependencies||!n)return;let l=new Map,u=new Map,d=[a.document,...Object.values(c.documents??{})].flatMap(e=>Object.keys(e.assets).map(t=>({document:e,assetId:t})));await Promise.all(Array.from({length:Math.min(4,d.length)},async()=>{for(;d.length;){let{document:e,assetId:t}=d.pop();try{let r=await n({projectId:o.projectId,...o.threadId?{threadId:o.threadId}:{},documentPath:s,assetId:t,sourceDocumentId:e.documentId,...a.contentHash?{expectedContentHash:a.contentHash}:{}});r?l.set(`${e.documentId}:${t}`,r):u.set(t,e.assets[t]?.path??t)}catch{u.set(t,e.assets[t]?.path??t)}}}));let f=Yd.getState().records[e];f&&f.sequence===a.sequence&&Yd.getState().setRecord(e,{...f,assets:l,diagnostics:[...f.diagnostics.filter(e=>e.code!==`asset-unavailable`),...[...u.values()].map(e=>({code:`asset-unavailable`,severity:`warning`,message:`Image ${e} could not load. Reload to retry.`}))]})}var $d=e=>pe(t=>{let[n,r]=JSON.parse(t);return e.runtime.atom(e.transport.subscribe(n,r).pipe(R(p(`DesignCache.accept`)(function*(e){return yield*ee({try:()=>Qd(t,e),catch:e=>new Kd({message:e instanceof Error?e.message:String(e)})})}))))}),ef=new WeakMap;function tf(e){let t=ef.get(e.transport);return t||(t=$d(e),ef.set(e.transport,t)),t}var nf=fe(C());function rf(e,t){let r=Yn(),i=e&&t?qd(e,t):null,a=i?tf(r)(i):nf,o=n(a),s=b(a),c=Yd(e=>i?e.records[i]??Jd:Jd),l=r.useConnected(e?.environmentId??null),u=!!(i&&!l&&c.document),d=(0,H.useMemo)(()=>u?{...c,status:`disconnected`,readOnly:!0}:c,[u,c]);return(0,H.useEffect)(()=>{if(i&&o._tag===`Failure`){let e=Yd.getState().records[i]??Hd();Yd.getState().setRecord(i,{...e,status:e.document?`conflict`:`error`,readOnly:!0})}},[i,o]),{record:d,select:(0,H.useCallback)(e=>{if(i){let t=Yd.getState().records[i]??Hd();Yd.getState().setRecord(i,{...t,selection:e})}},[i]),reload:s}}function af(e){let t=(0,U.c)(11),n=Yn(),r;t[0]!==n||t[1]!==e?(r=e?n.transport.catalog(e):null,t[0]=n,t[1]=e,t[2]=r):r=t[2];let i=Qn(r),a;t[3]===i.data?.paths?a=t[4]:(a=i.data?.paths??[],t[3]=i.data?.paths,t[4]=a);let o=i.data?.entries??null,s=i.error??void 0,c;return t[5]!==i.isPending||t[6]!==i.refresh||t[7]!==a||t[8]!==o||t[9]!==s?(c={paths:a,entries:o,loading:i.isPending,error:s,reload:i.refresh},t[5]=i.isPending,t[6]=i.refresh,t[7]=a,t[8]=o,t[9]=s,t[10]=c):c=t[10],c}var of=16,sf=6,cf=8;function lf(){let e=globalThis.crypto.getRandomValues(new Uint8Array(of));e[sf]=e[sf]&15|64,e[cf]=e[cf]&63|128;let t=d(e);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function uf(){let[e]=(0,H.useState)(()=>{try{return localStorage.getItem(`p4-design-review-author`)?.trim()||`You`}catch{return`You`}});return{author:e,hostOwned:!1}}var df=()=>null;function ff(e,t,n){let r=Yn(),i=$n(),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!1),d=uf(),f=(r.review.useReviewer??df)(),p=f===null?d.author:f.trim()||d.author;(0,H.useEffect)(()=>{o(null),u(!1)},[t]);let h=(0,H.useRef)(null);(0,H.useEffect)(()=>{if(!l){h.current=null;return}h.current===null?h.current=n.fileHash??``:n.fileHash!==h.current&&(u(!1),o(null))},[l,n.fileHash]);let g=!!((r.useCanWrite?.(e)??!0)&&e&&t&&n.document&&n.fileHash&&n.contentHash&&n.status===`ready`&&!n.readOnly),_=async a=>{if(g&&e&&t&&n.fileHash&&!s){c(!0),o(null),u(!1);try{let o=await i(r.transport.review(e,{tool:`design.apply`,documentPath:t,expectedFileHash:n.fileHash,operations:a}));if(o.status===`conflict`&&u(!0),o.status!==`committed`)throw Error(o.status===`conflict`?`The design changed. Reload before commenting.`:o.diagnostics.at(-1)?.message??`The comment could not be saved.`)}catch(e){throw o(e instanceof Error?e.message:String(e)),e}finally{c(!1)}}};return{error:a,conflict:l,busy:s,author:p,annotate:async(e,t)=>_([{operationId:m.make(lf()),kind:`annotation`,annotationId:m.make(e),value:t}]),attach:(t,n)=>{e&&r.attachment&&(r.attachment.set(e,t),n?.stay||r.navigation.returnToThread?.(e))}}}var pf=[[`Layers`,Be],[`Comments`,qe],[`Components`,Se],[`Libraries`,He],[`Tokens`,at]];function mf(e){return e?e.slice(0,8):`unavailable`}function hf(e){let t=(0,U.c)(12),{title:n,detail:r,action:i,actionLabel:a}=e,o=a===void 0?`Reload`:a,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,G.jsx)(Me,{"aria-hidden":`true`,size:24}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,G.jsx)(`strong`,{children:n}),t[1]=n,t[2]=c);let l;t[3]===r?l=t[4]:(l=r?(0,G.jsx)(`p`,{children:r}):null,t[3]=r,t[4]=l);let u;t[5]!==i||t[6]!==o?(u=i?(0,G.jsx)(W,{size:`sm`,variant:`outline`,onClick:i,children:o}):null,t[5]=i,t[6]=o,t[7]=u):u=t[7];let d;return t[8]!==c||t[9]!==l||t[10]!==u?(d=(0,G.jsxs)(`div`,{className:`design-notice`,role:`status`,children:[s,c,l,u]}),t[8]=c,t[9]=l,t[10]=u,t[11]=d):d=t[11],d}function gf(e){let t=(0,U.c)(13),{items:n,diagnostics:r}=e,i;t[0]===r?i=t[1]:(i=r.length?(0,G.jsxs)($r,{children:[(0,G.jsxs)(ei,{render:(0,G.jsx)(W,{size:`xs`,variant:`ghost`}),children:[`Details (`,r.length,`)`]}),(0,G.jsx)(ti,{className:`w-80`,children:(0,G.jsx)(`ul`,{className:`design-diagnostics-list`,children:r.map(_f)})})]}):null,t[0]=r,t[1]=i);let a=i,o;t[2]!==a||t[3]!==r.length||t[4]!==n?(o=n.length||!a?n:[{key:`diagnostics`,variant:`info`,role:`status`,icon:De,message:`${r.length} design ${r.length===1?`diagnostic`:`diagnostics`}`}],t[2]=a,t[3]=r.length,t[4]=n,t[5]=o):o=t[5];let s=o;if(!s.length)return null;let c;if(t[6]!==a||t[7]!==s){let e;t[9]===a?e=t[10]:(e=(e,t)=>(0,G.jsxs)(Xr,{variant:e.variant,role:e.role,className:`design-notice-alert`,children:[(0,G.jsx)(e.icon,{"aria-hidden":`true`}),(0,G.jsx)(Zr,{children:e.message}),e.action||t===0&&a?(0,G.jsxs)(Qr,{children:[e.action?(0,G.jsxs)(W,{size:`xs`,variant:`ghost`,onClick:e.action.run,children:[(0,G.jsx)(Qe,{"aria-hidden":`true`}),e.action.label]}):null,t===0?a:null]}):null]},e.key),t[9]=a,t[10]=e),c=s.map(e),t[6]=a,t[7]=s,t[8]=c}else c=t[8];let l;return t[11]===c?l=t[12]:(l=(0,G.jsx)(`div`,{className:`design-notices`,children:c}),t[11]=c,t[12]=l),l}function _f(e){return(0,G.jsx)(`li`,{children:e.message},`${e.code}:${e.nodeId??e.path}:${e.message}`)}var vf=`\0project`;function yf(e){let t=(0,U.c)(16),{icon:n,label:r,kind:i,className:a,onClick:o,trailing:s}=e,c=(0,H.useRef)(null),l;t[0]!==a||t[1]!==o?(l=(0,G.jsx)(`button`,{type:`button`,className:a,onClick:o}),t[0]=a,t[1]=o,t[2]=l):l=t[2];let u;t[3]===n?u=t[4]:(u=(0,G.jsx)(`span`,{className:`design-row-icon`,"aria-hidden":`true`,children:(0,G.jsx)(n,{size:14})}),t[3]=n,t[4]=u);let d;t[5]===r?d=t[6]:(d=(0,G.jsx)(`span`,{ref:c,className:`design-truncate`,children:r}),t[5]=r,t[6]=d);let f;t[7]===i?f=t[8]:(f=i?(0,G.jsxs)(`span`,{className:`sr-only`,children:[`, `,i]}):null,t[7]=i,t[8]=f);let p;return t[9]!==r||t[10]!==l||t[11]!==u||t[12]!==d||t[13]!==f||t[14]!==s?(p=(0,G.jsxs)(At,{full:r,labelRef:c,render:l,children:[u,d,f,s]}),t[9]=r,t[10]=l,t[11]=u,t[12]=d,t[13]=f,t[14]=s,t[15]=p):p=t[15],p}function bf(e){let t=(0,U.c)(35),{document:n,selection:r,select:i,query:a}=e,o=a===void 0?``:a,s;t[0]===n.roots?s=t[1]:(s=()=>new Set(n.roots),t[0]=n.roots,t[1]=s);let[c,l]=(0,H.useState)(s),[u,d]=(0,H.useState)(0),[f,p]=(0,H.useState)(400),m=(0,H.useRef)(null),h,g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>{let e=m.current;if(!e)return;let t=new ResizeObserver(()=>p(e.clientHeight));return t.observe(e),()=>t.disconnect()},g=[],t[2]=h,t[3]=g):(h=t[2],g=t[3]),(0,H.useEffect)(h,g);let _;t[4]===n.roots?_=t[5]:(_=()=>l(new Set(n.roots)),t[4]=n.roots,t[5]=_);let v;t[6]===n.documentId?v=t[7]:(v=[n.documentId],t[6]=n.documentId,t[7]=v),(0,H.useEffect)(_,v);let y;if(t[8]!==n.nodes||t[9]!==n.roots||t[10]!==c||t[11]!==o){y=[];let e=new Set,r=(t,i)=>{for(let a of t){let t=n.nodes[a];if(!t||e.has(a))continue;let s=`children`in t?t.children:[];y.push({id:a,node:t,depth:i,children:s.length>0}),(c.has(a)||o.trim())&&s.length&&i<256&&(e.add(a),r(s,i+1),e.delete(a))}};r(n.roots,0),t[8]=n.nodes,t[9]=n.roots,t[10]=c,t[11]=o,t[12]=y}else y=t[12];let b;t[13]!==o||t[14]!==y?(b=o.trim()?y.filter(e=>{let{node:t}=e;return`${t.name} ${t.type}`.toLocaleLowerCase().includes(o.trim().toLocaleLowerCase())}):y,t[13]=o,t[14]=y,t[15]=b):b=t[15];let x=b,S=Math.max(0,Math.floor(u/32)-6),C=Math.min(x.length,Math.ceil((u+f)/32)+6),w;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(w=e=>d(e.currentTarget.scrollTop),t[16]=w):w=t[16];let T;t[17]!==o||t[18]!==x.length?(T=!x.length&&o.trim()?(0,G.jsx)(`p`,{className:`design-small-muted design-search-empty`,children:`No matching layers`}):null,t[17]=o,t[18]=x.length,t[19]=T):T=t[19];let E=x.length*32,D;t[20]===E?D=t[21]:(D={height:E,position:`relative`},t[20]=E,t[21]=D);let O;t[22]!==C||t[23]!==c||t[24]!==x||t[25]!==i||t[26]!==r||t[27]!==S?(O=x.slice(S,C).map((e,t)=>{let{id:n,node:a,depth:o,children:s}=e,u=cd(a);return(0,G.jsxs)(`div`,{className:`design-layer-row`,role:`treeitem`,"aria-level":o+1,"aria-selected":r.includes(n),"aria-expanded":s?c.has(n):void 0,style:{top:(S+t)*32,paddingInlineStart:Math.min(o,12)*13+4},children:[s?(0,G.jsx)(`button`,{type:`button`,className:`design-layer-disclosure`,"aria-label":`${c.has(n)?`Collapse`:`Expand`} ${a.name}`,onClick:()=>l(e=>{let t=new Set(e);return t.has(n)?t.delete(n):t.add(n),t}),children:c.has(n)?(0,G.jsx)(Ce,{size:14}):(0,G.jsx)(Te,{size:14})}):(0,G.jsx)(`span`,{className:`design-layer-spacer`}),(0,G.jsx)(yf,{icon:u.icon,label:a.name||u.label,kind:u.label,className:`design-layer-select`,onClick:()=>i([n])})]},n)}),t[22]=C,t[23]=c,t[24]=x,t[25]=i,t[26]=r,t[27]=S,t[28]=O):O=t[28];let k;t[29]!==D||t[30]!==O?(k=(0,G.jsx)(`div`,{style:D,children:O}),t[29]=D,t[30]=O,t[31]=k):k=t[31];let A;return t[32]!==k||t[33]!==T?(A=(0,G.jsxs)(`div`,{ref:m,className:`design-layer-viewport`,role:`tree`,"aria-label":`Layers`,onScroll:w,children:[T,k]}),t[32]=k,t[33]=T,t[34]=A):A=t[34],A}function xf(e){let t=(0,U.c)(40),{tab:n,document:r,onOpen:i,selection:a,select:o,context:s,query:c}=e,l;t[0]===c?l=t[1]:(l=e=>e.toLocaleLowerCase().includes(c.trim().toLocaleLowerCase()),t[0]=c,t[1]=l);let u=l;if(n===`Layers`){let e;return t[2]!==r||t[3]!==c||t[4]!==o||t[5]!==a?(e=r?(0,G.jsx)(bf,{document:r,selection:a,select:o,query:c}):(0,G.jsx)(hf,{title:`No layers yet`,detail:`Open a design document to inspect its layers.`}),t[2]=r,t[3]=c,t[4]=o,t[5]=a,t[6]=e):e=t[6],e}if(n===`Libraries`){let e,n,r;if(t[7]!==s?.manifest?.libraries||t[8]!==u||t[9]!==i){let a=Object.entries(s?.manifest?.libraries??{});e=`design-catalog-list`,n=a.length>0&&!a.some(e=>{let[,t]=e;return u(t.path)})?(0,G.jsx)(`p`,{className:`design-small-muted design-search-empty`,children:`No matching libraries`}):null,r=a.length?a.filter(e=>{let[,t]=e;return u(t.path)}).map(e=>{let[t,n]=e;return(0,G.jsx)(yf,{icon:Me,label:n.path,className:`design-catalog-row`,onClick:()=>i(n.path),trailing:(0,G.jsx)(`small`,{children:n.exports.length})},t)}):(0,G.jsx)(hf,{title:`No libraries`,detail:`Libraries declared in p4.design.json appear here.`}),t[7]=s?.manifest?.libraries,t[8]=u,t[9]=i,t[10]=e,t[11]=n,t[12]=r}else e=t[10],n=t[11],r=t[12];let a;return t[13]!==e||t[14]!==n||t[15]!==r?(a=(0,G.jsxs)(`div`,{className:e,children:[n,r]}),t[13]=e,t[14]=n,t[15]=r,t[16]=a):a=t[16],a}if(!r){let e;t[17]===n?e=t[18]:(e=n.toLowerCase(),t[17]=n,t[18]=e);let r=`No ${e} yet`,i;return t[19]===r?i=t[20]:(i=(0,G.jsx)(hf,{title:r,detail:`Open a design document first.`}),t[19]=r,t[20]=i),i}if(n===`Components`){let e,n,i;if(t[21]!==r.components||t[22]!==u||t[23]!==o){let a=Object.entries(r.components);e=`design-catalog-list`,n=a.length>0&&!a.some(e=>{let[,t]=e;return u(t.name)})?(0,G.jsx)(`p`,{className:`design-small-muted design-search-empty`,children:`No matching components`}):null,i=a.length?a.filter(e=>{let[,t]=e;return u(t.name)}).map(e=>{let[t,n]=e;return(0,G.jsx)(yf,{icon:ke,label:n.name,className:`design-catalog-row`,onClick:()=>o([n.rootId])},t)}):(0,G.jsx)(hf,{title:`No components`,detail:`Components created by an agent appear here.`}),t[21]=r.components,t[22]=u,t[23]=o,t[24]=e,t[25]=n,t[26]=i}else e=t[24],n=t[25],i=t[26];let a;return t[27]!==e||t[28]!==n||t[29]!==i?(a=(0,G.jsxs)(`div`,{className:e,children:[n,i]}),t[27]=e,t[28]=n,t[29]=i,t[30]=a):a=t[30],a}let d,f,p;if(t[31]!==r.tokens||t[32]!==u){let e=Object.entries(r.tokens);d=`design-catalog-list`,f=e.length>0&&!e.some(e=>{let[,t]=e;return u(t.name)})?(0,G.jsx)(`p`,{className:`design-small-muted design-search-empty`,children:`No matching tokens`}):null,p=e.length?e.filter(e=>{let[,t]=e;return u(t.name)}).map(Sf):(0,G.jsx)(hf,{title:`No tokens`,detail:`Design tokens created by an agent appear here.`}),t[31]=r.tokens,t[32]=u,t[33]=d,t[34]=f,t[35]=p}else d=t[33],f=t[34],p=t[35];let m;return t[36]!==d||t[37]!==f||t[38]!==p?(m=(0,G.jsxs)(`div`,{className:d,children:[f,p]}),t[36]=d,t[37]=f,t[38]=p,t[39]=m):m=t[39],m}function Sf(e){let[t,n]=e;return(0,G.jsxs)(`div`,{className:`design-token-row`,children:[(0,G.jsx)(Mt,{children:n.name}),(0,G.jsx)(`span`,{className:`design-small-muted`,children:Hu(n.kind)})]},t)}function Cf(e){let t=(0,U.c)(21),{open:n,onOpenChange:r,tab:i,onTabChange:a,counts:o,query:s,onQueryChange:c,comments:l,children:u}=e,d=(0,H.useRef)(null),f=(0,H.useRef)(new Map),p;t[0]===i?p=t[1]:(p=pf.find(e=>{let[t]=e;return t===i})?.[1]??Be,t[0]=i,t[1]=p);let m=p,h=e=>{let t=pf.findIndex(e=>{let[t]=e;return t===i}),n=pf[e===`first`?0:e===`last`?pf.length-1:(t+e+pf.length)%pf.length][0];a(n),f.current.get(n)?.focus()},g;t[2]!==r||t[3]!==n?(g=()=>r(!n),t[2]=r,t[3]=n,t[4]=g):g=t[4];let _;t[5]===m?_=t[6]:(_=(0,G.jsx)(m,{"aria-hidden":`true`}),t[5]=m,t[6]=_);let v=o[i],y;t[7]===v?y=t[8]:(y=(0,G.jsx)(`span`,{className:`design-pill-count`,children:v}),t[7]=v,t[8]=y);let b;t[9]===n?b=t[10]:(b=n?(0,G.jsx)(Ee,{"aria-hidden":`true`}):(0,G.jsx)(Ce,{"aria-hidden":`true`}),t[9]=n,t[10]=b);let x;t[11]!==n||t[12]!==g||t[13]!==_||t[14]!==y||t[15]!==b||t[16]!==i?(x=(0,G.jsxs)(W,{ref:d,size:`sm`,variant:`outline`,className:`design-float-pill`,"aria-expanded":n,"aria-controls":`design-catalog-panel`,onClick:g,children:[_,i,y,b]}),t[11]=n,t[12]=g,t[13]=_,t[14]=y,t[15]=b,t[16]=i,t[17]=x):x=t[17];let S=n?(0,G.jsxs)(`div`,{id:`design-catalog-panel`,className:`design-catalog-panel`,role:`region`,"aria-label":`Design catalog`,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),r(!1),d.current?.focus())},children:[(0,G.jsx)(`div`,{className:`design-catalog-tabs`,role:`tablist`,"aria-label":`Catalog`,onKeyDown:e=>{let t=e.key===`ArrowRight`?1:e.key===`ArrowLeft`?-1:e.key===`Home`?`first`:e.key===`End`?`last`:null;t!==null&&(e.preventDefault(),h(t))},children:pf.map(e=>{let[t,n]=e,r=i===t,o=(0,G.jsx)(`button`,{ref:e=>{e?f.current.set(t,e):f.current.delete(t)},type:`button`,role:`tab`,id:`design-catalog-tab-${t}`,"aria-selected":r,"aria-controls":`design-catalog-tabpanel`,"aria-label":r?void 0:t,tabIndex:r?0:-1,onClick:()=>a(t)});return r?(0,G.jsxs)(`button`,{ref:e=>{e?f.current.set(t,e):f.current.delete(t)},type:`button`,role:`tab`,id:`design-catalog-tab-${t}`,"aria-selected":!0,"aria-controls":`design-catalog-tabpanel`,tabIndex:0,onClick:()=>a(t),children:[(0,G.jsx)(n,{size:14,"aria-hidden":`true`}),(0,G.jsx)(`span`,{children:t})]},t):(0,G.jsxs)(jt,{children:[(0,G.jsx)(Ot,{render:o,children:(0,G.jsx)(n,{size:14,"aria-hidden":`true`})}),(0,G.jsx)(kt,{children:t})]},t)})}),(0,G.jsx)(`div`,{id:`design-catalog-tabpanel`,className:`design-catalog-tabpanel`,role:`tabpanel`,"aria-labelledby":`design-catalog-tab-${i}`,children:i===`Comments`?l:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`design-catalog-search`,children:[(0,G.jsx)(tt,{size:14,"aria-hidden":`true`}),(0,G.jsx)(`input`,{type:`search`,"aria-label":`Search ${i.toLowerCase()}`,placeholder:`Search ${i.toLowerCase()}`,value:s,onChange:e=>c(e.target.value)})]}),u]})})]}):null,C;return t[18]!==S||t[19]!==x?(C=(0,G.jsxs)(`div`,{className:`design-catalog-float`,children:[x,S]}),t[18]=S,t[19]=x,t[20]=C):C=t[20],C}function wf(e,t){if(e==null)return`None`;if(typeof e==`object`&&`tokenId`in e)return`Token ${t?.tokens[String(e.tokenId)]?.name??String(e.tokenId)}`;if(typeof e==`object`&&`mode`in e){let n=e;return n.mode===`fixed`?`Fixed ${wf(n.value,t)}`:Hu(n.mode)}return Array.isArray(e)?`${e.length} ${e.length===1?`item`:`items`}`:typeof e==`number`?Uu(e):String(e)}function Tf({document:e,selection:t,theme:n,context:r,compact:i=!1}){let a=(0,H.useMemo)(()=>Kr(e,n,r),[e,n,r]);if(!t.length)return(0,G.jsx)(hf,{title:`Nothing selected`,detail:`Select a layer or click an item on the canvas.`});if(t.length>1)return(0,G.jsx)(hf,{title:`${t.length} items selected`,detail:`Select one item to inspect its properties.`});let o=t[0],s=o?e.nodes[o]:void 0;if(!s)return(0,G.jsx)(hf,{title:`Selection unavailable`,detail:`The selected item is no longer in this revision.`});let c=t=>{if(t&&typeof t==`object`&&`mode`in t&&`value`in t)return`${t.mode===`fixed`?`Fixed`:Hu(String(t.mode))} ${c(t.value)}`;if(!t||typeof t!=`object`||!(`tokenId`in t))return wf(t,e);try{let r=Ur(e,t,n);return typeof r==`number`?Uu(r):String(r)}catch{return`Unresolved token`}},l=o?e.instances[o]:void 0,u=a.items.find(e=>e.ownerId===o)?.bounds,d=s.type===`ref`&&s.importId?e.imports[s.importId]:void 0,f=d?r?.documents?.[d.libraryId]:e,p=s.type===`ref`?f?.components[s.componentId]:void 0,m=t=>(0,G.jsx)(`dl`,{className:`design-property-list`,children:t.map(([t,n,r])=>(0,G.jsxs)(`div`,{className:`design-property`,children:[(0,G.jsx)(`dt`,{children:t}),(0,G.jsxs)(`dd`,{children:[r??(0,G.jsx)(`span`,{children:wf(n,e)}),r===void 0&&wf(n,e)!==c(n)?(0,G.jsxs)(`small`,{children:[`Resolved: `,c(n)]}):null]})]},t))}),h=(e,t)=>(0,G.jsxs)(`section`,{className:`design-inspector-section`,"aria-label":e,children:[(0,G.jsx)(`h3`,{children:e}),m(t)]}),g=s.fills?.[0],_=g?.kind===`solid`?c(g.color):null,v=cd(s),y=v.icon;return(0,G.jsxs)(`div`,{className:`design-inspector-content`,children:[i?null:(0,G.jsxs)(`div`,{className:`design-inspector-identity`,children:[(0,G.jsxs)(`h2`,{className:`design-inspector-title`,children:[(0,G.jsx)(y,{size:14,"aria-hidden":`true`}),(0,G.jsx)(Mt,{children:s.name||v.label})]}),(0,G.jsxs)(`span`,{className:`design-inspector-meta`,children:[(0,G.jsx)(`span`,{className:`design-small-muted`,children:v.label}),(0,G.jsx)(dr,{variant:`outline`,size:`sm`,children:`Read only`})]})]}),`clip`in s?h(`Alignment`,[[`Clip contents`,null,Ku(s.clip)]]):null,h(`Position`,[[`X`,s.x],[`Y`,s.y],[`Rotation`,s.rotation??0,`${Uu(s.rotation??0)}°`]]),h(`Layout`,`layout`in s?[[`Mode`,null,Hu(s.layout.direction)],[`Gap`,s.layout.gap],[`Padding`,null,[s.layout.padding.top,s.layout.padding.right,s.layout.padding.bottom,s.layout.padding.left].map(t=>wf(t,e)).join(` `)]]:[[`Mode`,null,`Absolute`]]),h(`Dimensions`,[[`Width`,s.width],[`Height`,s.height],[`Computed`,null,u?`${Uu(u.width)} × ${Uu(u.height)}`:`Unavailable`]]),h(`Appearance`,[[`Opacity`,null,Wu(s.opacity??1)],[`Visibility`,null,Gu(s.visible??!0)],[`Stroke`,s.stroke??`None`],[`Effects`,null,qu(s.effects?.length??0)],...`radius`in s?[[`Radius`,s.radius??0]]:[],...`text`in s?[[`Text`,null,(0,G.jsx)(Mt,{children:s.text},`text`)],[`Font`,s.fontFamily],[`Font size`,s.fontSize]]:[]]),h(`Fill`,[[`Type`,null,g?Hu(g.kind):`None`],...g?.kind===`solid`?[[`Color`,null,(0,G.jsxs)(`span`,{className:`design-fill-value`,children:[(0,G.jsx)(`span`,{className:`design-swatch`,style:{background:_??`transparent`},"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`design-mono`,children:_}),typeof g.color==`object`?(0,G.jsx)(`small`,{children:wf(g.color,e)}):null]},`color`)]]:g?.kind===`image`?[[`Asset`,null,(0,G.jsx)(Mt,{className:`design-truncate design-mono`,children:g.assetId},`asset`)]]:g?.kind===`gradient`?[[`Gradient`,null,Hu(g.gradient)]]:[]]),h(`Theme`,Object.entries(e.themeAxes).length?Object.entries(e.themeAxes).map(([e,t])=>[e,null,n[e]??`Default (${t[0]??`none`})`]):[[`Preview`,null,`Default`]]),p?(0,G.jsxs)(`section`,{className:`design-inspector-section`,"aria-label":`Source component`,children:[(0,G.jsx)(`h3`,{children:`Source component`}),(0,G.jsx)(`p`,{children:p.name}),d?(0,G.jsx)(Mt,{className:`design-truncate design-small-muted`,children:`Library ${r?.manifest?.libraries[d.libraryId]?.path??d.libraryId}`}):null]}):null,l?(0,G.jsxs)(`section`,{className:`design-inspector-section`,"aria-label":`Overrides`,children:[(0,G.jsx)(`h3`,{children:`Overrides`}),(0,G.jsxs)(`p`,{children:[Object.keys(l.overrides).length,` source`,` `,Object.keys(l.overrides).length===1?`node`:`nodes`]}),Object.entries(l.overrides).map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(Mt,{className:`design-truncate design-small-muted`,children:f?.nodes[e]?.name??e}),m(Object.entries(t))]},e))]}):null,h(`Code`,[[`Mapping`,null,e.codeMappings?`Document mapping available`:`No code mapping`]]),i?null:(0,G.jsx)(`p`,{className:`design-inspector-hint`,children:`Ask the agent to change this selection.`})]})}function Ef(e){let t=(0,U.c)(67),{geometry:n,document:r,selection:i,theme:a,context:o,collapsed:s,onCollapsedChange:c,onComment:l,extraAction:u}=e,d=(0,H.useRef)(null),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f={width:300,height:148},t[0]=f):f=t[0];let[p,m]=(0,H.useState)(f),[h,g]=(0,H.useState)(!1),_,v;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>{let e=d.current;if(!e)return;let t=new ResizeObserver(()=>{let t=e.offsetWidth,n=e.offsetHeight;t&&n&&m(e=>e.width===t&&e.height===n?e:{width:t,height:n})});return t.observe(e),()=>t.disconnect()},v=[],t[1]=_,t[2]=v):(_=t[1],v=t[2]),(0,H.useLayoutEffect)(_,v);let y;t[3]!==n.avoid||t[4]!==n.canvas||t[5]!==n.screen||t[6]!==p?(y=mi(n.screen,p,n.canvas,void 0,void 0,n.avoid),t[3]=n.avoid,t[4]=n.canvas,t[5]=n.screen,t[6]=p,t[7]=y):y=t[7];let b=y,{onPlaced:x}=n,S=b?.x,C=b?.y,w,T;t[8]!==x||t[9]!==S||t[10]!==C||t[11]!==p.height||t[12]!==p.width?(w=()=>{x(S===void 0||C===void 0?null:{x:S,y:C,width:p.width,height:p.height})},T=[x,S,C,p.width,p.height],t[8]=x,t[9]=S,t[10]=C,t[11]=p.height,t[12]=p.width,t[13]=w,t[14]=T):(w=t[13],T=t[14]),(0,H.useLayoutEffect)(w,T);let E,D;t[15]===x?(E=t[16],D=t[17]):(E=()=>()=>x(null),D=[x],t[15]=x,t[16]=E,t[17]=D),(0,H.useLayoutEffect)(E,D);let O=i.length===1?r.nodes[i[0]]:void 0,k;t[18]===O?k=t[19]:(k=O?cd(O):{label:`Selection`,icon:Be},t[18]=O,t[19]=k);let A=k,j=A.icon,M=O?O.name||A.label:`${i.length} layers`,N=!b,P;t[20]===b?P=t[21]:(P=b?{transform:`translate(${b.x}px, ${b.y}px)`}:void 0,t[20]=b,t[21]=P);let F;t[22]===j?F=t[23]:(F=(0,G.jsx)(j,{size:14,"aria-hidden":`true`}),t[22]=j,t[23]=F);let ee;t[24]===M?ee=t[25]:(ee=(0,G.jsx)(`h2`,{children:(0,G.jsx)(Mt,{children:M})}),t[24]=M,t[25]=ee);let te;t[26]!==A.label||t[27]!==O?(te=O?(0,G.jsx)(`span`,{className:`sr-only`,children:A.label}):null,t[26]=A.label,t[27]=O,t[28]=te):te=t[28];let I;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,G.jsx)(dr,{variant:`outline`,size:`sm`,children:`Read only`}),t[29]=I):I=t[29];let L=s?`Expand inspector`:`Collapse inspector`,ne=!s,re;t[30]!==s||t[31]!==c?(re=()=>c(!s),t[30]=s,t[31]=c,t[32]=re):re=t[32];let ie;t[33]!==L||t[34]!==ne||t[35]!==re?(ie=(0,G.jsx)(W,{size:`icon-xs`,variant:`ghost`,"aria-label":L,"aria-expanded":ne,onClick:re}),t[33]=L,t[34]=ne,t[35]=re,t[36]=ie):ie=t[36];let R;t[37]===s?R=t[38]:(R=s?(0,G.jsx)(Ce,{"aria-hidden":`true`}):(0,G.jsx)(Ee,{"aria-hidden":`true`}),t[37]=s,t[38]=R);let ae;t[39]!==ie||t[40]!==R?(ae=(0,G.jsx)(Ot,{render:ie,children:R}),t[39]=ie,t[40]=R,t[41]=ae):ae=t[41];let oe=s?`Expand inspector`:`Collapse inspector`,se;t[42]===oe?se=t[43]:(se=(0,G.jsx)(kt,{children:oe}),t[42]=oe,t[43]=se);let ce;t[44]!==ae||t[45]!==se?(ce=(0,G.jsxs)(jt,{children:[ae,se]}),t[44]=ae,t[45]=se,t[46]=ce):ce=t[46];let le;t[47]!==F||t[48]!==ee||t[49]!==te||t[50]!==ce?(le=(0,G.jsxs)(`header`,{className:`design-selection-card-header`,children:[F,ee,te,I,ce]}),t[47]=F,t[48]=ee,t[49]=te,t[50]=ce,t[51]=le):le=t[51];let ue;t[52]!==s||t[53]!==o||t[54]!==r||t[55]!==u||t[56]!==n.world||t[57]!==h||t[58]!==l||t[59]!==i||t[60]!==a?(ue=s?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`dl`,{className:`design-geometry`,children:[[`W`,n.world.width],[`H`,n.world.height],[`X`,n.world.x],[`Y`,n.world.y]].map(Of)}),(0,G.jsxs)(`div`,{className:`design-selection-card-actions`,children:[l?(0,G.jsxs)(W,{size:`xs`,variant:`outline`,onClick:l,children:[(0,G.jsx)(Ke,{"aria-hidden":`true`}),`Comment`]}):null,(0,G.jsx)(W,{size:`xs`,variant:`ghost`,"aria-expanded":h,onClick:()=>g(Df),children:h?`Less`:`More`}),u]}),h?(0,G.jsx)(`div`,{className:`design-selection-card-more`,children:(0,G.jsx)(Tf,{document:r,selection:i,theme:a,context:o,compact:!0})}):null]}),t[52]=s,t[53]=o,t[54]=r,t[55]=u,t[56]=n.world,t[57]=h,t[58]=l,t[59]=i,t[60]=a,t[61]=ue):ue=t[61];let de;return t[62]!==N||t[63]!==P||t[64]!==le||t[65]!==ue?(de=(0,G.jsxs)(`section`,{ref:d,className:`design-selection-card`,"aria-label":`Selection inspector`,hidden:N,style:P,children:[le,ue]}),t[62]=N,t[63]=P,t[64]=le,t[65]=ue,t[66]=de):de=t[66],de}function Df(e){return!e}function Of(e){let[t,n]=e;return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:t}),(0,G.jsx)(`dd`,{children:Uu(Math.round(n*100)/100)})]},t)}var kf=new Map,Af=e=>kf,jf=[],Mf=e=>jf,Nf=(e,t)=>void 0,Pf=(e,t,n)=>null;function Ff({resourceId:e,surface:t,agentEdit:n,frameDecoration:r,canvasPreferences:i}){let a=Yn(),{navigation:o,attachment:s}=a,c=o.useTarget(),l=a.useCanWrite?.(c)??!0,u=o.useProjects(),d=o.useActivePath(c),f=e??d??``,p=af(c),{record:m,select:h,reload:g}=rf(c,f),_=ff(c,f,m),v=$n(),y=(o.useDocumentStatuses??Af)(c),b=(o.useLinkedPaths??Mf)(c),x=(a.useAgentPresence??Nf)(c,f),S=(a.useCanvasPlaceholder??Pf)(c,{paths:p.paths,loading:p.loading,failed:!!p.error},{openImport:()=>pe(!0)}),[C,w]=(0,H.useState)(`Layers`),[T,E]=(0,H.useState)(!1),[D,O]=(0,H.useState)(!1),[k,A]=(0,H.useState)(`Canvas`),[j,M]=(0,H.useState)(``),[N,P]=(0,H.useState)(()=>typeof window>`u`||window.innerWidth>=1024),[F,ee]=(0,H.useState)(!1),[te,I]=(0,H.useState)(null),[L,ne]=(0,H.useState)(null),[re,ie]=(0,H.useState)(null),[R,ae]=(0,H.useState)(null),[oe,se]=(0,H.useState)([]),[ce,le]=(0,H.useState)(null),[ue,de]=(0,H.useState)({}),[fe,pe]=(0,H.useState)(!1),[me,he]=(0,H.useState)(`import`),ge=t===`panel`,ve=JSON.stringify([c,f,t]),ye=R?.key===ve?R:null,be=!!ye;(0,H.useEffect)(()=>ae(null),[ve]);let z=m.document,xe=m.diagnostics??[],Se=xe.find(e=>e.severity===`error`),Ce=xe.find(e=>e.severity===`warning`&&e.code.includes(`asset`)),we=(0,H.useMemo)(()=>z?Object.entries(z.themeAxes):[],[z?.themeAxes]),Te=(0,H.useMemo)(()=>Object.fromEntries(we.flatMap(([e,t])=>ue[e]&&t.includes(ue[e])?[[e,ue[e]]]:[])),[ue,we]),Ee=c?.threadId,B=(0,H.useMemo)(()=>c&&s?{environmentId:c.environmentId,projectId:c.projectId,...Ee?{threadId:Ee}:{}}:null,[c?.environmentId,c?.projectId,Ee,!!s]),Oe=!ge&&!!(Ee&&a.thread),ke=Oe&&N,Me=(e,t=ge?`panel`:`workspace`)=>{c&&o.openDocument(c,e,t)},Ne=z&&(m.status===`ready`||m.status===`disconnected`||m.status===`conflict`||m.readOnly),Fe=!!(l&&m.contentHash&&m.status===`ready`&&!m.readOnly),Ie=e=>{if(!c||!f||!z||!m.contentHash)return;let t=m.contentHash,n=e=>le({key:ve,message:e});le(null),v(a.transport.readRevision(c,f,e.id)).then(({source:r})=>{let i=zr(r);if(i.status!==`editable`)return n(`This revision can't be opened for comparison.`);if(Ve.current!==t)return n(`The design changed. Compare again.`);ae({key:ve,before:i.document,after:z,beforeRevision:e.revision,afterRevision:t,beforeContext:m.context,beforeAssets:m.assets,afterContext:m.context,afterAssets:m.assets,theme:Te,priorSelection:[...m.selection]}),se([...m.selection]),I(null),A(`Canvas`)},()=>n(`Could not load this revision.`))},Le=()=>{ye&&h(ye.priorSelection),ae(null)},Re=e=>{ie(e??null),ge?A(`Comments`):(w(`Comments`),E(!0))},ze=e=>{Oe&&P(!0),_.attach(e,{stay:Oe})},Be=m.selection.join(`\0`),Ve=(0,H.useRef)(m.contentHash);Ve.current=m.contentHash;let He=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=He.current;if(He.current=Be,!ke||!B||!s||be||(e===null||e===Be)&&s.current(B))return;let t=Ve.current,n=Be?Be.split(`\0`):[];if(!n.length||!t||!f){s.set(B,null);return}let r=n.length===1?z?.nodes[n[0]]:void 0;s.set(B,{documentPath:f,revision:t,nodeIds:n},r?{name:r.name,type:{type:r.type,fills:r.fills}}:void 0)},[ke,B,be,Be,f]),(0,H.useEffect)(()=>{if(!ke||!B||!s||!m.contentHash)return;let e=s.current(B);e&&e.selection.documentPath===f&&e.selection.revision!==m.contentHash&&s.set(B,{...e.selection,revision:m.contentHash},e.label)},[ke,B,f,m.contentHash]);let Ue=async e=>{if(be||!m.contentHash||!_.author.trim()||L?.path!==f||L.revision!==m.contentHash)return;let t=lf();await _.annotate(t,{...e,revision:m.contentHash,author:_.author.trim(),createdAt:new Date().toISOString(),replies:[],status:`open`}),ne(null),I(null)},We=async(e,t)=>{if(be)return;let n=z?.annotations[e];n&&_.author.trim()&&await _.annotate(e,{...n,replies:[...n.replies,{id:lf(),body:t,author:_.author.trim(),createdAt:new Date().toISOString()}]})},Ke=async(e,t)=>{if(be)return;let n=z?.annotations[e];n&&await _.annotate(e,{...n,status:t?`resolved`:`open`})},qe=L?.anchor.kind===`region`&&L.path===f&&L.revision===m.contentHash?L.anchor.bounds:null,Je=z?(0,G.jsxs)(`div`,{className:`design-comments-panel`,children:[be?(0,G.jsx)(`p`,{className:`design-author-hint`,children:`Exit compare to comment or attach a selection.`}):null,m.selection.length&&!be&&Fe?(0,G.jsx)(`div`,{className:`design-inspector-actions`,children:(0,G.jsx)(W,{size:`sm`,variant:`outline`,onClick:()=>ne({path:f,revision:m.contentHash,anchor:{kind:`nodes`,nodeIds:m.selection}}),children:`Comment on selection`})}):null,L&&!be&&L.path===f&&L.revision===m.contentHash&&Fe?(0,G.jsx)(Fd,{anchor:L.anchor,onSubmit:Ue,onCancel:()=>{ne(null),I(null)},busy:_.busy||!_.author.trim()},JSON.stringify(L)):null,L?.path===f&&L.revision!==m.contentHash?(0,G.jsxs)(`div`,{className:`design-annotation-stale`,role:`status`,children:[(0,G.jsx)(`span`,{children:`The revision changed. Place this comment again.`}),(0,G.jsx)(W,{size:`sm`,variant:`outline`,onClick:()=>{ne(null),I(null)},children:`Clear`})]}):null,qe&&!be&&B?(0,G.jsx)(`div`,{className:`design-inspector-actions`,children:(0,G.jsx)(W,{size:`sm`,variant:`outline`,onClick:()=>ze({documentPath:f,revision:m.contentHash,nodeIds:[],region:qe}),children:`Attach region`})}):null,(0,G.jsx)(Ld,{document:z,currentRevision:m.contentHash,focusedId:re,actions:m.status!==`ready`||m.readOnly||be?void 0:{reply:We,setResolved:Ke},busy:_.busy||!_.author.trim()})]}):(0,G.jsx)(hf,{title:`No comments`}),Xe=!l||m.status!==`ready`||m.readOnly,$e=[];z&&m.status===`disconnected`&&$e.push({key:`disconnected`,variant:`warning`,role:`status`,icon:ct,message:`Disconnected. Showing cached revision ${mf(m.contentHash)}.`,action:{label:`Retry`,run:g}}),z&&m.status===`conflict`&&$e.push({key:`conflict`,variant:`warning`,role:`alert`,icon:De,message:`This view is out of date.`,action:{label:`Reload`,run:g}}),z&&(m.readOnly||Se)&&!Ce&&m.status===`ready`&&$e.push({key:`issue`,variant:Se?`error`:`info`,role:`alert`,icon:De,message:Se?.message??`This design is read-only.`,action:{label:`Reload`,run:g}}),z&&Ce&&$e.push({key:`asset`,variant:`warning`,role:`status`,icon:De,message:`An image asset is missing. Its placeholder remains visible.`,action:{label:`Reload`,run:g}}),z&&ce?.key===ve&&$e.push({key:`compare`,variant:`error`,role:`alert`,icon:De,message:ce.message,action:{label:`Dismiss`,run:()=>le(null)}});let et=z?(0,G.jsx)(gf,{items:$e,diagnostics:xe}):null,tt=we.map(([e,t])=>(0,G.jsxs)(ni,{modal:!1,value:Te[e]??``,onValueChange:t=>de(n=>{let r={...n};return typeof t==`string`&&t?r[e]=t:delete r[e],r}),children:[(0,G.jsxs)(ii,{variant:`ghost`,size:`sm`,className:`design-topbar-select`,"aria-label":`Preview ${Hu(e)}`,children:[(0,G.jsx)(Ye,{"aria-hidden":`true`,size:16}),(0,G.jsx)(`span`,{className:`design-small-muted`,children:we.length===1?`Preview`:Hu(e)}),(0,G.jsx)(ai,{children:e=>e||`Default`})]}),(0,G.jsxs)(oi,{children:[(0,G.jsx)(si,{value:``,children:`Default`}),t.map(e=>(0,G.jsx)(si,{value:e,children:e},e))]})]},e)),rt=S||(c?f?m.status===`loading`&&!z?(0,G.jsx)(hf,{title:`Loading design…`}):z?(0,G.jsxs)(G.Fragment,{children:[ge?et:null,Ne&&!z.roots.length?(0,G.jsx)(hf,{title:`No layers yet`,detail:`Ask an agent to add a frame or shape.`}):null,Ne&&z.roots.length?ye?(0,G.jsx)(rd,{preferences:i,before:ye.before,after:ye.after,beforeRevision:ye.beforeRevision,afterRevision:ye.afterRevision,viewKey:ve,theme:ye.theme,beforeContext:ye.beforeContext,beforeAssets:ye.beforeAssets,context:ye.afterContext,assets:ye.afterAssets,selection:oe,onSelect:se,onExit:Le}):(0,G.jsx)(td,{preferences:i,chrome:ge?`panel`:`workspace`,viewKey:ve,document:z,theme:Te,context:m.context,assets:m.assets,selection:m.selection,changedNodeIds:m.changedNodeIds,batch:m.batch,agents:x,agentEdit:n,frameDecoration:r,onSelect:h,annotationMode:te,onAnnotationModeChange:Fe?I:void 0,onAnchor:e=>{m.contentHash&&ne({path:f,revision:m.contentHash,anchor:e}),Re()},onOpenAnnotation:Re,revision:m.contentHash,renderSelectionOverlay:ge?void 0:e=>(0,G.jsx)(Ef,{geometry:e,document:z,selection:m.selection,theme:Te,context:m.context,collapsed:F,onCollapsedChange:ee,onComment:Fe?()=>I(`pin`):void 0,extraAction:B&&s&&!Oe&&m.contentHash?(0,G.jsx)(W,{size:`xs`,variant:`ghost`,onClick:()=>ze({documentPath:f,revision:m.contentHash,nodeIds:m.selection}),children:`Attach selection`}):null})},f):null]}):(0,G.jsx)(hf,{title:xe.some(e=>e.code===`unknown-major`)?`Newer design version`:`Design could not be opened`,detail:Se?.message??`Check the file and try again.`,action:g}):(0,G.jsx)(hf,{title:`Choose a design`,detail:`Open a .p4design document from this project.`,action:p.paths.length?()=>O(!0):void 0,actionLabel:`Choose design`}):(0,G.jsx)(hf,{title:`Open a project`,detail:`Choose a project to view its design documents.`})),it=(0,G.jsx)(jd,{open:fe,mode:me,onModeChange:he,onOpenChange:pe,target:c,documentPath:f,revision:m.contentHash,document:m.status===`ready`&&!m.readOnly?z:void 0,selection:m.selection,onImportComplete:p.reload,theme:Te,onOpenImported:e=>{Me(e)}});if(!ge){let e={Layers:z?Object.keys(z.nodes).length:0,Comments:z?Object.keys(z.annotations).length:0,Components:z?Object.keys(z.components).length:0,Libraries:Object.keys(m.context?.manifest?.libraries??{}).length,Tokens:z?Object.keys(z.tokens).length:0};return(0,G.jsxs)(`section`,{className:`design-workspace design-workspace-full${be?` design-workspace-comparing`:``}`,"aria-label":`P4 Design workspace`,children:[(0,G.jsxs)(`header`,{className:`design-topbar`,children:[(0,G.jsxs)(`div`,{className:`design-topbar-title`,children:[a.TopbarStart?(0,G.jsx)(a.TopbarStart,{target:c}):null,u.length||o.createProject?(0,G.jsxs)(ni,{modal:!1,value:c?`${c.environmentId}\u0000${c.projectId}`:null,onValueChange:e=>{if(e===vf){o.createProject?.();return}let t=u.find(t=>`${t.environmentId}\u0000${t.projectId}`===e);t&&o.openProject(t)},children:[(0,G.jsxs)(ii,{variant:`ghost`,size:`sm`,className:`design-topbar-project`,"aria-label":`Project`,children:[(0,G.jsx)(Pe,{"aria-hidden":`true`,size:16}),(0,G.jsx)(ai,{children:e=>(0,G.jsx)(Mt,{children:u.find(t=>`${t.environmentId}\u0000${t.projectId}`===e)?.name??`Select project`})})]}),(0,G.jsxs)(oi,{children:[u.map(e=>(0,G.jsx)(si,{value:`${e.environmentId}\u0000${e.projectId}`,children:e.name},`${e.environmentId}\u0000${e.projectId}`)),o.createProject?(0,G.jsx)(si,{value:vf,children:(0,G.jsxs)(`span`,{className:`design-switcher-item`,children:[(0,G.jsx)(Ze,{"aria-hidden":`true`,size:14}),`New project`]})}):null]})]}):null,u.length||o.createProject?(0,G.jsx)(`span`,{className:`design-topbar-crumb`,"aria-hidden":`true`,children:`/`}):null,(0,G.jsx)(Or,{target:c,path:f,paths:p.paths,entries:p.entries,linkedPaths:b,open:D,onOpenChange:O,onOpen:e=>Me(e),statuses:y,onStartDesign:c&&o.startDesign?()=>{P(!0),o.startDesign?.(c)}:void 0,onStartDesignInNewThread:c&&o.startDesignInNewThread?()=>o.startDesignInNewThread?.(c):void 0,onManageDesigns:c&&o.manageDesigns?()=>o.manageDesigns?.(c):void 0})]}),(0,G.jsx)(`div`,{className:`design-topbar-notices`,children:et}),(0,G.jsxs)(`div`,{className:`design-topbar-actions`,children:[f?(0,G.jsx)(ir,{target:c,path:f,revision:m.contentHash,fileHash:m.fileHash??``,disabled:Xe||!!ye||!c||!m.fileHash,onCompare:Ie},`${c?.environmentId}:${c?.projectId}:${c?.threadId}:${f}`):null,c&&o.startDesign?(0,G.jsxs)(jt,{children:[(0,G.jsxs)(Ot,{render:(0,G.jsx)(W,{size:`sm`,variant:`outline`,"aria-label":`New design`,onClick:()=>{P(!0),o.startDesign?.(c)}}),children:[(0,G.jsx)(Ze,{"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`design-collapsible-label`,children:`New design`})]}),(0,G.jsx)(kt,{children:`New design`})]}):null,tt,(0,G.jsx)(lr,{target:c,path:f,revision:m.contentHash,iconOnly:!0}),a.TopbarEnd?(0,G.jsx)(a.TopbarEnd,{target:c,path:f}):null,(0,G.jsxs)(On,{children:[(0,G.jsxs)(jt,{children:[(0,G.jsx)(Ot,{render:(0,G.jsx)(kn,{render:(0,G.jsx)(W,{size:`icon`,variant:`ghost`,"aria-label":`More actions`})}),children:(0,G.jsx)(je,{"aria-hidden":`true`})}),(0,G.jsx)(kt,{children:`More actions`})]}),(0,G.jsxs)(An,{align:`end`,className:`w-56`,children:[(0,G.jsxs)(jn,{disabled:!c||!l,onClick:()=>{he(`import`),pe(!0)},children:[(0,G.jsx)(st,{"aria-hidden":`true`}),` Import design…`]}),(0,G.jsxs)(jn,{disabled:!l||!z||m.status!==`ready`||m.readOnly,onClick:()=>{he(`export`),pe(!0)},children:[(0,G.jsx)(Ae,{"aria-hidden":`true`}),` Export design…`]}),(0,G.jsxs)(jn,{disabled:!c,onClick:()=>{g(),p.reload()},children:[(0,G.jsx)(Qe,{"aria-hidden":`true`}),` Reload design`]}),o.openSettings?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Mn,{}),(0,G.jsxs)(jn,{onClick:()=>o.openSettings?.(),children:[(0,G.jsx)(nt,{"aria-hidden":`true`}),` Settings`]})]}):null]})]})]})]}),(0,G.jsxs)(`div`,{className:`design-body`,children:[N&&a.agentColumn!==!1?(0,G.jsx)(li,{title:a.agentColumnTitle,heading:a.AgentHeader?(0,G.jsx)(a.AgentHeader,{target:c}):void 0,hostLabel:Oe&&!a.AgentHeader?a.thread?.label:void 0,onOpenThread:c?.threadId&&o.returnToThread?()=>f?Me(f,`panel`):o.returnToThread?.(c):void 0,onCollapse:()=>P(!1),card:null,thread:Oe&&c?a.thread.render(c):a.AgentPanel?(0,G.jsx)(a.AgentPanel,{target:c}):null}):null,(0,G.jsxs)(`main`,{className:`design-main`,children:[(0,G.jsxs)(`div`,{className:`design-canvas-topleft`,children:[N||a.agentColumn===!1?null:(0,G.jsx)(ui,{onOpen:()=>P(!0)}),z&&!be&&!S?(0,G.jsx)(Cf,{open:T,onOpenChange:E,tab:C,onTabChange:w,counts:e,query:j,onQueryChange:M,comments:Je,children:C===`Comments`?null:(0,G.jsx)(xf,{tab:C,document:z,onOpen:Me,selection:m.selection,select:h,context:m.context,query:j})}):null]}),rt]})]}),it]})}return(0,G.jsxs)(`section`,{className:`design-workspace design-workspace-pane${be?` design-workspace-comparing`:``}`,"aria-label":`P4 Design workspace`,children:[(0,G.jsxs)(`header`,{className:`design-header`,children:[(0,G.jsxs)(`div`,{className:`design-heading`,children:[(0,G.jsx)(Or,{target:c,path:f,paths:p.paths,entries:p.entries,linkedPaths:b,statuses:y,onStartDesign:c&&o.startDesign?()=>o.startDesign?.(c):void 0,onStartDesignInNewThread:c&&o.startDesignInNewThread?()=>o.startDesignInNewThread?.(c):void 0,onManageDesigns:c&&o.manageDesigns?()=>o.manageDesigns?.(c):void 0,onOpen:e=>Me(e),open:D,onOpenChange:O}),f&&c?(0,G.jsx)(ir,{target:c,path:f,revision:m.contentHash,fileHash:m.fileHash??``,disabled:Xe||!!ye||!m.fileHash,compact:!0,onCompare:Ie},`${c.environmentId}:${c.projectId}:${c.threadId}:${f}`):(0,G.jsx)(`span`,{className:`design-small-muted`,children:`Project designs`})]}),(0,G.jsxs)(`div`,{className:`design-header-actions`,children:[tt,(0,G.jsx)(lr,{target:c,path:f,revision:m.contentHash,iconOnly:!0}),c&&f?(0,G.jsxs)(jt,{children:[(0,G.jsx)(Ot,{render:(0,G.jsx)(W,{size:`icon-sm`,variant:`ghost`,"aria-label":`Expand design`,onClick:()=>Me(f,`workspace`)}),children:(0,G.jsx)(Ge,{"aria-hidden":`true`})}),(0,G.jsx)(kt,{children:`Expand design`})]}):null,c?(0,G.jsxs)(On,{children:[(0,G.jsxs)(jt,{children:[(0,G.jsx)(Ot,{render:(0,G.jsx)(kn,{render:(0,G.jsx)(W,{size:`icon-sm`,variant:`ghost`,"aria-label":`More actions`})}),children:(0,G.jsx)(je,{"aria-hidden":`true`})}),(0,G.jsx)(kt,{children:`More actions`})]}),(0,G.jsxs)(An,{align:`end`,className:`w-56`,children:[(0,G.jsxs)(jn,{disabled:!l,onClick:()=>{he(`import`),pe(!0)},children:[(0,G.jsx)(_e,{"aria-hidden":`true`}),` Import / export…`]}),(0,G.jsxs)(jn,{onClick:()=>{g(),p.reload()},children:[(0,G.jsx)(Qe,{"aria-hidden":`true`}),` Reload design`]})]})]}):null]})]}),(0,G.jsx)(`nav`,{className:`design-pane-tabs`,"aria-label":`Design views`,children:[`Canvas`,`Layers`,`Inspect`,`Comments`].map(e=>(0,G.jsx)(`button`,{type:`button`,"aria-current":k===e?`page`:void 0,onClick:()=>A(e),children:e},e))}),(0,G.jsx)(`main`,{className:`design-main ${k===`Canvas`?``:`design-main-hidden`}`,children:rt}),k===`Layers`?(0,G.jsx)(`div`,{className:`design-pane-content`,children:z?(0,G.jsx)(bf,{document:z,selection:m.selection,select:h}):(0,G.jsx)(hf,{title:`No layers yet`})}):null,k===`Inspect`?(0,G.jsx)(`div`,{className:`design-pane-content`,children:z?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Tf,{document:z,selection:m.selection,theme:Te,context:m.context}),be?(0,G.jsx)(`p`,{className:`design-author-hint`,children:`Exit compare to comment or attach a selection.`}):null,m.selection.length&&m.contentHash&&B&&!be?(0,G.jsx)(`div`,{className:`design-inspector-actions`,children:(0,G.jsx)(W,{size:`sm`,variant:`outline`,onClick:()=>ze({documentPath:f,revision:m.contentHash,nodeIds:m.selection}),children:`Attach selection`})}):null]}):(0,G.jsx)(hf,{title:`Nothing to inspect`})}):null,k===`Comments`?(0,G.jsx)(`div`,{className:`design-pane-content`,children:Je}):null,_.error?(0,G.jsx)(`p`,{className:`design-review-error`,role:`alert`,children:_.error}):null,it]})}var If=`Create a new design in this project. Read design_guide, inspect the project's existing components and styles, then use design_apply to create a .p4design document. Validate and render it for review. Ask me what to design if my request is incomplete.`,Lf=[],Rf={label:`Other thread`,tone:`outline`};function zf(e,t){let n=(0,U.c)(10),r;n[0]!==t||n[1]!==e.environmentId?(r=O(e.environmentId,t),n[0]=t,n[1]=e.environmentId,n[2]=r):r=n[2];let i;n[3]===r?i=n[4]:(i=[r],n[3]=r,n[4]=i);let a=ft(i),o;if(n[5]!==a||n[6]!==e.threadId){let t;n[8]===e.threadId?t=n[9]:(t=t=>t.id!==e.threadId&&t.archivedAt===null&&t.deletedAt===null,n[8]=e.threadId,n[9]=t),o=new Map(a.filter(t).flatMap(Bf)),n[5]=a,n[6]=e.threadId,n[7]=o}else o=n[7];return o}function Bf(e){return e.designs.map(Vf)}function Vf(e){return[e.path,Rf]}function Hf({threadRef:e,composerTarget:t,workspace:r=!1,projectId:i,projectName:s,workspaceRoot:c,documentPath:l}){let u=(0,H.useContext)(te),d=Et(e.environmentId),f=pt(e),p=Tn(),m=Tt(),h=f?.designs,g=(0,H.useMemo)(()=>h?.map(e=>e.path)??Lf,[h]),_=n(bn.permissionAtom(e.environmentId)),v=(0,H.useMemo)(()=>({environmentId:e.environmentId,projectId:i,...f?{threadId:e.threadId}:{}}),[e.environmentId,e.threadId,i,!!f]),y=d?.connection.phase===`connected`,b=(0,H.useMemo)(()=>Cn(u),[u]),x=(0,H.useRef)(null);(0,H.useEffect)(()=>{u.refresh(b.catalog(v))},[u,b,v,f?.latestRun?.runId,f?.runtime?.status,h]);let S=(0,H.useMemo)(()=>{let n=e=>{let n=a.getState(),r=n.draftsByThreadKey[j(t)]?.prompt??``;n.setPrompt(t,r.trim()?`${r}\n\n${e}`:e)},r=()=>n(If);return{runtime:mt,transport:b,agentColumn:!1,attachment:{current:()=>{let e=x.current,n=a.getState().draftsByThreadKey[j(t)];return e&&n?.files.some(t=>t.id===e.fileId)?e:void 0},set:(e,n,r)=>{let i=a.getState();if(x.current&&i.removeFile(t,x.current.fileId),x.current=null,!n)return;let s=new File([JSON.stringify(n,null,2)],`${r?.name??`Design selection`}.json`,{type:`application/json`}),c=o.make(ae());i.addFiles(t,[{type:`file`,id:c,name:s.name,mimeType:s.type,sizeBytes:s.size,file:s}]).includes(c)&&(x.current={selection:n,fileId:c})}},useConnected:()=>y,useCanWrite:()=>_,navigation:{linkEnvironment:!0,useTarget:()=>v,useActivePath:()=>l??null,useWorkspaceRoot:()=>c,useProjects:()=>[{environmentId:v.environmentId,projectId:i,name:s}],openProject:()=>Dt.getState().open(e,`design`),openDocument:(t,n,r)=>{Dt.getState().openFile(e,n),r===`workspace`&&Dt.getState().setMaximized(e,!0)},returnToThread:()=>Dt.getState().setMaximized(e,!1),startDesign:r,startDesignInNewThread:()=>void p(O(e.environmentId,i)).then(e=>{e&&a.getState().setPrompt(e.draftId,If)}),manageDesigns:()=>void m({to:`/settings/designs`}),useLinkedPaths:()=>g,useDocumentStatuses:()=>zf(e,i)},review:{},useCanvasPlaceholder:(e,t)=>!l&&!t.loading&&!t.failed&&t.paths.length===0?(0,G.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,G.jsx)(`h2`,{className:`text-lg font-medium`,children:`Design with your agent`}),(0,G.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:`Describe what you want in this thread. Designs appear here as your agent creates them.`}),(0,G.jsx)(oe,{onClick:r,disabled:!_,children:`Start a design`})]}):null}},[b,v,t,e,i,s,c,l,y,_,p,m,g,f?.latestRun?.runId,f?.runtime?.status===`running`]);return(0,G.jsx)(Jn,{host:S,children:(0,G.jsx)(`div`,{className:`h-full min-h-0 min-w-0 flex-1`,children:(0,G.jsx)(Ff,{surface:r?`workspace`:`panel`})})})}export{Hf as default};
19
- //# sourceMappingURL=EmbeddedDesign-C5OUFTlD.js.map
16
+ `),t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.width,i=this.attrs.height,a=r!==Ys&&r!==void 0,o=i!==Ys&&i!==void 0,s=this.padding(),c=r-s*2,l=i-s*2,u=0,d=this.wrap(),f=d!==mc&&d!==hc,p=this.ellipsis(),m=this.measureSize(`M`);this._baselineShift=(m.fontBoundingBoxAscent-m.fontBoundingBoxDescent)/2,this.textArr=[];let h=Sc();h.font=this._getContextFont(),h.fontKerning=this.direction()!==fc&&(this.letterSpacing()!==0||this.align()===Qs||this.charRenderFunc())?`none`:`auto`;let g=p?this._getTextWidth(gc):0;for(let t=0,r=e.length;t<r;++t){let i=e[t],s=this._getTextWidth(i);if(a&&s>c){let e=Js(i),a=e.length,d=0,m=t=>e.slice(d,t).join(``),h=e=>e===uc||e===tc,_=Math.max(1,Math.ceil(a*c/s));for(;d<a;){let i=p&&o&&u+n>l?g:0,s=e=>!(this._getTextWidth(m(e),e-d)+i>c),v=d,y=Math.min(a,d+_);for(;s(y)&&(v=y,y!==a);)y=Math.min(a,y+(y-d));for(;y-v>1;){let e=v+y>>>1;s(e)?v=e:y=e}if(v===d)break;if(v===a){this._addTextLine(m(a)),u+=n,o&&u+n>l&&t<r-1&&this._tryToAddEllipsisToLastLine();break}if(f&&!h(e[v])){let t=v-1;for(;t>=d&&!h(e[t]);)t--;t>=d&&(v=t+1)}if(this._addTextLine(m(v).trimRight()),u+=n,this._shouldHandleEllipsis(u)){this._tryToAddEllipsisToLastLine();break}for(d=v;d<a&&!e[d].trim();)d++}}else this._addTextLine(i),u+=n,o&&u+n>l&&t<r-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),o&&u+n>l)break}this.textHeight=t,this.textWidth=this.textArr.reduce((e,t)=>Math.max(e,t.width),0)}_shouldHandleEllipsis(e){let t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,i=r!==Ys&&r!==void 0,a=r-this.padding()*2;return this.wrap()===hc||i&&e+n>a}_tryToAddEllipsisToLastLine(){let e=this.attrs.width,t=e!==Ys&&e!==void 0,n=e-this.padding()*2,r=this.ellipsis(),i=this.textArr[this.textArr.length-1];if(!i||!r)return;let a=i.text+gc;if(t){let e=Js(i.text);for(;e.length&&this._getTextWidth(a)>n;)e.pop(),a=e.join(``)+gc;this._getTextWidth(a)>n&&(a=``)}i.text=a,i.width=this._getTextWidth(a)}getStrokeScaleEnabled(){return!0}_getStrokePadding(){return super._getStrokePadding(2)}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){if(this.attrs.perfectDrawEnabled===!1)return!1;let n=this.textDecoration().indexOf(`underline`)!==-1||this.textDecoration().indexOf(`line-through`)!==-1,r=this.hasShadow();return n&&r||r&&t!==1&&yc()?!0:super._useBufferCanvas(e,t)}};Ec.prototype._fillFunc=Cc,Ec.prototype._strokeFunc=wc,Ec.prototype.className=ic,Ec.prototype._attrsAffectingSize=_c.filter(e=>e!==`width`&&e!==`height`).concat([`textDecoration`,`underlineOffset`]),Si(Ec,!0),Ec.prototype.on(_c.map(e=>e+$s).join(` `),function(){this._setTextData()}),X.overWriteSetter(Ec,`width`,Da()),X.overWriteSetter(Ec,`height`,Da()),X.addGetterSetter(Ec,`direction`,Zs),X.addGetterSetter(Ec,`fontFamily`,`Arial`),X.addGetterSetter(Ec,`fontSize`,12,Y()),X.addGetterSetter(Ec,`fontStyle`,cc),X.addGetterSetter(Ec,`fontVariant`,cc),X.addGetterSetter(Ec,`padding`,0,Y()),X.addGetterSetter(Ec,`align`,nc),X.addGetterSetter(Ec,`verticalAlign`,ac),X.addGetterSetter(Ec,`lineHeight`,1,Y()),X.addGetterSetter(Ec,`wrap`,pc),X.addGetterSetter(Ec,`ellipsis`,!1,ja()),X.addGetterSetter(Ec,`letterSpacing`,0,Y()),X.addGetterSetter(Ec,`text`,``,Oa()),X.addGetterSetter(Ec,`textDecoration`,``),X.addGetterSetter(Ec,`underlineOffset`,void 0,Y()),X.addGetterSetter(Ec,`charRenderFunc`,void 0);var Dc=[...Ec.prototype._attrsAffectingSize,`width`,`height`,`pointerDirection`,`pointerWidth`,`pointerHeight`].map(e=>e+`Change.konva`).join(` `),Oc=`none`,kc=`up`,Ac=`right`,jc=`down`,Mc=`left`,Nc=class extends cs{constructor(e){super(e),this._sync=this._sync.bind(this),this.on(`add.konva`,function(e){e.child.off(Dc,this._sync).on(Dc,this._sync),this._sync()})}getText(){return this.find(`Text`)[0]}getTag(){return this.find(`Tag`)[0]}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let e=this.getText(),t=this.getTag(),n,r,i,a,o,s,c;if(e&&t){switch(n=e.width(),r=e.height(),i=t.pointerDirection(),a=t.pointerWidth(),c=t.pointerHeight(),o=0,s=0,i){case kc:o=n/2,s=-1*c;break;case Ac:o=n+a,s=r/2;break;case jc:o=n/2,s=r+c;break;case Mc:o=-1*a,s=r/2}t.setAttrs({x:-1*o,y:-1*s,width:n,height:r}),e.setAttrs({x:-1*o,y:-1*s})}}};Nc.prototype.className=`Label`,Si(Nc);var Pc=class extends Q{_sceneFunc(e){let t=this.width(),n=this.height(),r=this.pointerDirection(),i=this.pointerWidth(),a=this.pointerHeight(),o=this.cornerRadius(),[s,c,l,u]=q._cornerRadii(o,t,n);e.beginPath(),e.moveTo(s,0),r===kc&&(e.lineTo((t-i)/2,0),e.lineTo(t/2,-1*a),e.lineTo((t+i)/2,0)),e.lineTo(t-c,0),e.arc(t-c,c,c,Math.PI*3/2,0,!1),r===Ac&&(e.lineTo(t,(n-a)/2),e.lineTo(t+i,n/2),e.lineTo(t,(n+a)/2)),e.lineTo(t,n-l),e.arc(t-l,n-l,l,0,Math.PI/2,!1),r===jc&&(e.lineTo((t+i)/2,n),e.lineTo(t/2,n+a),e.lineTo((t-i)/2,n)),e.lineTo(u,n),e.arc(u,n-u,u,Math.PI/2,Math.PI,!1),r===Mc&&(e.lineTo(0,(n+a)/2),e.lineTo(-1*i,n/2),e.lineTo(0,(n-a)/2)),e.lineTo(0,s),e.arc(s,s,s,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=this.pointerWidth(),t=this.pointerHeight(),n=this.pointerDirection(),r=this.width(),i=this.height();return n===kc||n===jc?{x:Math.min(0,(r-e)/2),y:n===kc?-t:0,width:Math.max(r,e),height:i+t}:n===Mc||n===Ac?{x:n===Mc?-e:0,y:Math.min(0,(i-t)/2),width:r+e,height:Math.max(i,t)}:{x:0,y:0,width:r,height:i}}};Pc.prototype.className=`Tag`,Si(Pc,!0),X.addGetterSetter(Pc,`pointerDirection`,Oc),X.addGetterSetter(Pc,`pointerWidth`,0,Y()),X.addGetterSetter(Pc,`pointerHeight`,0,Y()),X.addGetterSetter(Pc,`cornerRadius`,0,Ea(4));var Fc=class extends Q{_getStrokePadding(){return super._getStrokePadding(this.strokeScaleEnabled()?1:void 0)}_sceneFunc(e){let t=this.cornerRadius(),n=this.width(),r=this.height();e.beginPath(),t?q.drawRoundedRectPath(e,n,r,t):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}};Fc.prototype.className=`Rect`,Si(Fc,!0),X.addGetterSetter(Fc,`cornerRadius`,0,Ea(4));var Ic=class extends Q{_sceneFunc(e){let t=this._getPoints(),n=this.radius(),r=this.sides(),i=this.cornerRadius();if(t.length){if(e.beginPath(),i)q.drawRoundedPolygonPath(e,t,r,n,i);else{e.moveTo(t[0].x,t[0].y);for(let n=1;n<t.length;n++)e.lineTo(t[n].x,t[n].y)}e.closePath(),e.fillStrokeShape(this)}}_getPoints(){let e=this.attrs.sides,t=this.attrs.radius||0,n=[];for(let r=0;r<e;r++)n.push({x:t*Math.sin(r*2*Math.PI/e),y:-1*t*Math.cos(r*2*Math.PI/e)});return n}getSelfRect(){let e=this._getPoints();if(!e.length)return{x:0,y:0,width:0,height:0};let t=e[0].x,n=e[0].x,r=e[0].y,i=e[0].y;return e.forEach(e=>{t=Math.min(t,e.x),n=Math.max(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.y)}),{x:t,y:r,width:n-t,height:i-r}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};Ic.prototype.className=`RegularPolygon`,Ic.prototype._centroid=!0,Ic.prototype._attrsAffectingSize=[`radius`,`sides`],Si(Ic,!0),X.addGetterSetter(Ic,`radius`,0,Y()),X.addGetterSetter(Ic,`sides`,0,Y()),X.addGetterSetter(Ic,`cornerRadius`,0,Ea(4));var Lc=Math.PI*2,Rc=class extends Q{_getStrokePadding(){return super._getStrokePadding(1)}_sceneFunc(e){let t=Math.abs(this.innerRadius()),n=Math.abs(this.outerRadius());e.beginPath(),e.arc(0,0,t,0,Lc,!1),e.moveTo(n,0),e.arc(0,0,n,Lc,0,!0),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=Math.max(Math.abs(this.innerRadius()),Math.abs(this.outerRadius()));return{x:-e,y:-e,width:e*2,height:e*2}}getWidth(){return Math.abs(this.outerRadius())*2}getHeight(){return Math.abs(this.outerRadius())*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};Rc.prototype.className=`Ring`,Rc.prototype._centroid=!0,Rc.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`],Si(Rc,!0),X.addGetterSetter(Rc,`innerRadius`,0,Y()),X.addGetterSetter(Rc,`outerRadius`,0,Y());var zc=class extends Q{constructor(e){super(e),this._updated=!0,this.anim=new us(()=>{let e=this._updated;return this._updated=!1,e}),this.on(`animationChange.konva`,function(){this.frameIndex(0)}),this.on(`frameIndexChange.konva`,function(){this._updated=!0}),this.on(`frameRateChange.konva`,function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_getFrame(){let e=this.animation(),t=this.animations()?.[e],n=this.frameIndex(),r=n*4;if(!t||!Number.isInteger(n)||r<0||r+4>t.length)return;let i=this.frameOffsets()?.[e]||[];return{x:t[r],y:t[r+1],width:t[r+2],height:t[r+3],offsetX:i[n*2]||0,offsetY:i[n*2+1]||0}}_getStrokePadding(){return super._getStrokePadding(this.strokeScaleEnabled()?1:void 0)}_sceneFunc(e){let t=this._getFrame();if(!t)return;let{x:n,y:r,width:i,height:a,offsetX:o,offsetY:s}=t,c=this.image();(this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(o,s,i,a),e.closePath(),e.fillStrokeShape(this)),c&&e.drawImage(c,n,r,i,a,o,s,i,a)}_hitFunc(e){let{x:t,y:n,width:r,height:i}=this.getSelfRect();e.beginPath(),e.rect(t,n,r,i),e.closePath(),e.fillShape(this)}getSelfRect(){let e=this._getFrame();return e?{x:e.offsetX,y:e.offsetY,width:e.width,height:e.height}:{x:0,y:0,width:0,height:0}}_useBufferCanvas(e,t=this.getAbsoluteOpacity()){return super._useBufferCanvas(!0,t)}_setInterval(){let e=this;this.interval=setInterval(function(){e._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;let e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}destroy(){return this.stop(),super.destroy()}isRunning(){return this.anim.isRunning()}_updateIndex(){let e=this.frameIndex(),t=this.animations()?.[this.animation()],n=t?t.length/4:0;this.frameIndex(e<n-1?e+1:0)}};zc.prototype.className=`Sprite`,Si(zc,!0),X.addGetterSetter(zc,`animation`),X.addGetterSetter(zc,`animations`),X.addGetterSetter(zc,`frameOffsets`),X.addGetterSetter(zc,`image`),X.addGetterSetter(zc,`frameIndex`,0,Y()),X.addGetterSetter(zc,`frameRate`,17,Y()),X.backCompat(zc,{index:`frameIndex`,getIndex:`getFrameIndex`,setIndex:`setFrameIndex`});var Bc=class extends Q{_sceneFunc(e){let t=this.innerRadius(),n=this.outerRadius(),r=this.numPoints();e.beginPath(),e.moveTo(0,0-n);for(let i=1;i<r*2;i++){let a=i%2==0?n:t,o=a*Math.sin(i*Math.PI/r),s=-1*a*Math.cos(i*Math.PI/r);e.lineTo(o,s)}e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=Math.max(Math.abs(this.innerRadius()),Math.abs(this.outerRadius()));return{x:-e,y:-e,width:e*2,height:e*2}}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};Bc.prototype.className=`Star`,Bc.prototype._centroid=!0,Bc.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`],Si(Bc,!0),X.addGetterSetter(Bc,`numPoints`,5,Y()),X.addGetterSetter(Bc,`innerRadius`,0,Y()),X.addGetterSetter(Bc,`outerRadius`,0,Y());var Vc=``,Hc=`normal`;function Uc(e){e.fillText(this.partialText,0,0)}function Wc(e){e.strokeText(this.partialText,0,0)}var Gc=class extends Q{constructor(e){super(e),this.dataArray=[],this._readDataAttribute(),this._setTextData()}_getTextPathLength(){return Vs.getPathLength(this.dataArray)}_getPointAtLength(e,t){return!this.attrs.data||e>this.pathLength?null:Vs.getPointAtLengthOfDataArray(e,this.dataArray,t)}_readDataAttribute(){this.dataArray=Vs.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(e){e.setAttr(`font`,this._getContextFont()),e.setAttr(`textBaseline`,this.textBaseline()),e.setAttr(`textAlign`,`left`),e.save();let t=this.textDecoration(),n=this.fill(),r=this.fontSize(),i=this.glyphInfo,a=t.indexOf(`underline`)!==-1,o=t.indexOf(`line-through`)!==-1;a&&e.beginPath();for(let t=0;t<i.length;t++){e.save();let n=i[t].p0;e.translate(n.x,n.y),e.rotate(i[t].rotation),this.partialText=i[t].text,e.fillStrokeShape(this),a&&(t===0&&e.moveTo(0,r/2+1),e.lineTo(i[t].width,r/2+1)),e.restore()}if(a&&(e.strokeStyle=n,e.lineWidth=qs(r),e.stroke()),o){e.beginPath();for(let t=0;t<i.length;t++){e.save();let n=i[t].p0;e.translate(n.x,n.y),e.rotate(i[t].rotation),t===0&&e.moveTo(0,0),e.lineTo(i[t].width,0),e.restore()}e.strokeStyle=n,e.lineWidth=qs(r),e.stroke()}e.restore()}_hitFunc(e){e.beginPath();let t=this.glyphInfo;if(t.length>=1){let n=t[0].p0;e.moveTo(n.x,n.y)}for(let n=0;n<t.length;n++){let r=t[n].p1;e.lineTo(r.x,r.y)}e.setAttr(`lineWidth`,this.fontSize()),e.setAttr(`strokeStyle`,this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return q.warn(`text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height.`),this.textHeight}setText(e){return Ec.prototype.setText.call(this,e)}_getContextFont(){return Ec.prototype._getContextFont.call(this)}_getTextSize(e){let t=Sc();t.save(),t.font=this._getContextFont(),t.fontKerning=`auto`;let n=t.measureText(e);return t.restore(),{width:n.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){let e=Js(this.text());this.direction()===`rtl`&&e.reverse();let t=this.kerningFunc(),n=[],r=0;for(let i=0;i<e.length;i++){let a=0;if(t&&i>0)try{a=t(e[i-1],e[i])*this.fontSize()}catch{}n.push({char:e[i],width:this._getTextSize(e[i]).width,kern:a}),r+=n[i].width+a}let{width:i,height:a}=this._getTextSize(this.attrs.text);if(this.textWidth=r,this.textHeight=a,this.glyphInfo=[],!this.attrs.data)return null;let o=this.letterSpacing(),s=this.align(),c=s===`justify`?this.text().split(` `).length-1:0,l=Math.max(0,r-i),u=Math.max(this.textWidth+(e.length-1)*o,0),d=0;s===`center`&&(d=Math.max(0,this.pathLength/2-u/2)),s===`right`&&(d=Math.max(0,this.pathLength-u));let f=d,p=this.dataArray.some((e,t)=>t>0&&e.command===`M`)?void 0:{index:0,offset:0};for(let t=0;t<n.length;t++){f+=n[t].kern;let r=this._getPointAtLength(f,p);if(!r)return;let i=n[t].char,a=n[t].width+(t<n.length-1?o:0);i===` `&&s===`justify`&&(a+=(this.pathLength-u)/c);let d=f+a,m=this._getPointAtLength(d>this.pathLength&&d-this.pathLength<=l?this.pathLength:d,p);if(!m)return;let h=Vs.getLineLength(r.x,r.y,m.x,m.y),g=Math.atan2(m.y-r.y,m.x-r.x);this.glyphInfo.push({text:e[t],rotation:g,p0:r,p1:m,width:h}),f+=a}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};let e=[];this.glyphInfo.forEach(function(t){e.push(t.p0.x),e.push(t.p0.y),e.push(t.p1.x),e.push(t.p1.y)});let t=q._getPointsRect(e),n=this.fontSize();return{x:t.x-n/2,y:t.y-n/2,width:t.width+n,height:t.height+n}}getStrokeScaleEnabled(){return!0}_getSelfRectForDrawing(){let e=this.getSelfRect(),t=this.fontSize();return{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}}};Gc.prototype._fillFunc=Uc,Gc.prototype._strokeFunc=Wc,Gc.prototype._fillFuncHit=Uc,Gc.prototype._strokeFuncHit=Wc,Gc.prototype.className=`TextPath`,Gc.prototype._attrsAffectingSize=[`text`,`fontSize`,`data`,`align`,`letterSpacing`,`kerningFunc`,`fontFamily`,`fontStyle`,`fontVariant`,`direction`],Si(Gc,!0),Gc.prototype.on(`dataChange.konva`,function(){this._readDataAttribute(),this._setTextData()}),Gc.prototype.on(Gc.prototype._attrsAffectingSize.filter(e=>e!==`data`).map(e=>e+`Change.konva`).join(` `),function(){this._setTextData()}),X.addGetterSetter(Gc,`data`),X.addGetterSetter(Gc,`fontFamily`,`Arial`),X.addGetterSetter(Gc,`fontSize`,12,Y()),X.addGetterSetter(Gc,`fontStyle`,Hc),X.addGetterSetter(Gc,`align`,`left`),X.addGetterSetter(Gc,`letterSpacing`,0,Y()),X.addGetterSetter(Gc,`textBaseline`,`middle`),X.addGetterSetter(Gc,`fontVariant`,Hc),X.addGetterSetter(Gc,`text`,Vc),X.addGetterSetter(Gc,`textDecoration`,``),X.addGetterSetter(Gc,`kerningFunc`,void 0),X.addGetterSetter(Gc,`direction`,`inherit`);var Kc=`tr-konva`,qc=[`resizeEnabledChange`,`rotateAnchorOffsetChange`,`rotateAnchorAngleChange`,`rotateEnabledChange`,`enabledAnchorsChange`,`anchorSizeChange`,`borderEnabledChange`,`shouldOverdrawWholeAreaChange`,`borderStrokeChange`,`borderStrokeWidthChange`,`borderDashChange`,`anchorStrokeChange`,`anchorStrokeWidthChange`,`anchorFillChange`,`anchorCornerRadiusChange`,`ignoreStrokeChange`,`anchorStyleFuncChange`,`paddingChange`].map(e=>e+`.${Kc}`).join(` `),Jc=`nodesRect`,Yc=[`widthChange`,`heightChange`,`scaleXChange`,`scaleYChange`,`skewXChange`,`skewYChange`,`rotationChange`,`offsetXChange`,`offsetYChange`,`transformsEnabledChange`,`strokeWidthChange`,`strokeChange`,`selfRectFuncChange`,`strokeLinearGradientColorStopsChange`,`strokeScaleEnabledChange`,`strokeEnabledChange`,`draggableChange`],Xc={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},Zc=`ontouchstart`in K._global;function Qc(e,t,n){if(e===`rotater`)return n;t+=q.degToRad(Xc[e]||0);let r=(q.radToDeg(t)%360+360)%360;return q._inRange(r,337.5,360)||q._inRange(r,0,22.5)?`ns-resize`:q._inRange(r,22.5,67.5)?`nesw-resize`:q._inRange(r,67.5,112.5)?`ew-resize`:q._inRange(r,112.5,157.5)?`nwse-resize`:q._inRange(r,157.5,202.5)?`ns-resize`:q._inRange(r,202.5,247.5)?`nesw-resize`:q._inRange(r,247.5,292.5)?`ew-resize`:q._inRange(r,292.5,337.5)?`nwse-resize`:(q.error(`Transformer has unknown angle for cursor detection: `+r),`pointer`)}var $c=[`top-left`,`top-center`,`top-right`,`middle-right`,`middle-left`,`bottom-left`,`bottom-center`,`bottom-right`];function el(e){return{x:e.x+e.width/2*Math.cos(e.rotation)+e.height/2*Math.sin(-e.rotation),y:e.y+e.height/2*Math.cos(e.rotation)+e.width/2*Math.sin(e.rotation)}}function tl(e,t,n){let r=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),i=n.y+(e.x-n.x)*Math.sin(t)+(e.y-n.y)*Math.cos(t);return{...e,rotation:e.rotation+t,x:r,y:i}}function nl(e,t){return tl(e,t,el(e))}function rl(e,t,n){let r=t,i=n;for(let n=0;n<e.length;n++){let a=K.getAngle(e[n]),o=Math.abs(a-t)%(Math.PI*2),s=Math.min(o,Math.PI*2-o);s<i&&(i=s,r=a)}return r}function il(e,t,n){let r=q.degToRad(e.rotateAnchorAngle()),i=Math.sin(r),a=-Math.cos(r),o=t/2,s=n/2,c=1/0;a<0?c=Math.min(c,-s/a):a>0&&(c=Math.min(c,(n-s)/a)),i<0?c=Math.min(c,-o/i):i>0&&(c=Math.min(c,(t-o)/i));let l=o+i*c,u=s+a*c,d=e.rotateAnchorOffset()+e.padding();return{edgeX:l,edgeY:u,endX:l+i*d,endY:u+a*d}}var al=new Set,$=class extends cs{static _isLayerTransforming(e){for(let t of al)if(t.getLayer()===e||t._nodes.some(t=>t.getLayer()===e))return!0;return!1}constructor(e){super(e),this._movingAnchorName=null,this._anchors={},this._transforming=!1,this._fitting=!1,this._transformWindow=null,this._elementsCreated=!1,this._updateScheduled=!1,this._subtreeChanged=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(qc,e=>{e.type===`ignoreStrokeChange`&&this._resetTransformCache(),this.update()}),this.on(`rotationChange.${Kc}`,()=>this._clearCache(Jc)),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return q.warn(`tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead.`),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return Kc+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();let t=new Set(e);for(let e of t)e.isAncestorOf(this)&&(q.error(`Konva.Transformer cannot be an a child of the node you are trying to attach`),t.delete(e));let n=Array.from(t).filter(e=>{for(let n=e.getParent();n;n=n.getParent())if(t.has(n))return!1;return!0});return this._nodes=e=n,e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(e=>{let t=()=>{var t;if(this._fitting){(t=this._nodeRectCache)==null||t.delete(e);return}this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(e),this.isDragging()||this._scheduleUpdate()};if(e._attrsAffectingSize.length){let n=e._attrsAffectingSize.map(e=>e+`Change.`+this._getEventNamespace()).join(` `);e.on(n,t)}e.on(Yc.map(e=>e+`.${this._getEventNamespace()}`).join(` `),t),e.on(`absoluteTransformChange.${this._getEventNamespace()}`,t),e instanceof $a&&e._addSubtreeObserver(this),e.on(`destroy.${this._getEventNamespace()}`,()=>{this.setNodes(this._nodes.filter(t=>t!==e))}),this._proxyDrag(e)}),this._resetTransformCache(),this._elementsCreated&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,n=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this._back&&this.startDrag(n,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,n=>{if(!t)return;let r=e.getAbsolutePosition(),i=r.x-t.x,a=r.y-t.y;this.nodes().forEach(t=>{if(t===e||t.isDragging())return;let r=t.getAbsolutePosition();t.setAbsolutePosition({x:r.x+i,y:r.y+a}),t.startDrag(n)}),t=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){var e;this._nodes&&this._nodes.forEach(e=>{e.off(`.`+this._getEventNamespace()),e._removeSubtreeObserver(this)}),this._nodes=[],this._resetTransformCache(),(e=this.getLayer())==null||e.batchDraw()}_resetTransformCache(e){var t,n;e?(t=this._nodeRectCache)==null||t.delete(e):(n=this._nodeRectCache)==null||n.clear(),this._clearCache(Jc),this._clearCache(`transform`),this._clearSelfAndDescendantCache(`absoluteTransform`)}_onSubtreeChange(e){var t;this._fitting||(!this._subtreeChanged||this._cache[Jc])&&(this._resetTransformCache(e),this._subtreeChanged||(this._subtreeChanged=!0,q.requestAnimFrame(()=>this._syncSubtreeChange(),this.getStage()?._getOwnerWindow()),(t=this.getLayer())==null||t.batchDraw()))}_syncSubtreeChange(){this._subtreeChanged&&this._nodes?.length&&!this.isDragging()&&this._update()}drawScene(e,t){return this._syncSubtreeChange(),super.drawScene(e,t)}drawHit(e,t){return this._syncSubtreeChange(),super.drawHit(e,t)}_getNodeRect(){return this._getCache(Jc,this.__getNodeRect)}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};let e=K.getAngle(this.rotation()),t=this.ignoreStroke(),n=new Ti;n.rotate(-e);let r=this._nodeRectCache||=new Map,i=1/0,a=1/0,o=-1/0,s=-1/0;for(let c of this.nodes()){let l=c instanceof Q&&c.getSelfRect===Q.prototype.getSelfRect&&!c.attrs.selfRectFunc&&!c._hasCachedAncestor(),u=l?c.width():0,d=l?c.height():0;l&&(c._attrsVersion??=0);let f=l?r.get(c):void 0;if(!f||f.rotation!==e||f.ignoreStroke!==t||f.version!==c._attrsVersion||f.width!==u||f.height!==d){let i=c.getAbsoluteTransform(),[a,o,s,p]=i.getMatrix(),m=a*p-o*s===0,h=c.getClientRect({skipTransform:!m,skipShadow:!0,skipStroke:t}),g=[{x:h.x,y:h.y},{x:h.x+h.width,y:h.y},{x:h.x+h.width,y:h.y+h.height},{x:h.x,y:h.y+h.height}];m&&(i=new Ti),f={rotation:e,ignoreStroke:t,width:u,height:d,version:c._attrsVersion||0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};for(let e of g){let t=n.point(i.point(e));f.minX=Math.min(f.minX,t.x),f.minY=Math.min(f.minY,t.y),f.maxX=Math.max(f.maxX,t.x),f.maxY=Math.max(f.maxY,t.y)}l&&r.set(c,f)}i=Math.min(i,f.minX),a=Math.min(a,f.minY),o=Math.max(o,f.maxX),s=Math.max(s,f.maxY)}n.invert();let c=n.point({x:i,y:a});return{x:c.x,y:c.y,width:o-i,height:s-a,rotation:K.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),$c.forEach(e=>{this._createAnchor(e)}),this._createAnchor(`rotater`),this._elementsCreated=!0}_createAnchor(e){let t=new Fc({stroke:`rgb(0, 161, 255)`,fill:`white`,strokeWidth:1,name:e+` _anchor`,dragDistance:0,draggable:!0,hitStrokeWidth:Zc?10:`auto`});this._anchors[e]=t;let n=this;t.on(`mousedown touchstart`,function(e){n._handleMouseDown(e)}),t.on(`dragstart`,e=>{t.stopDrag(),e.cancelBubble=!0}),t.on(`dragend`,e=>{e.cancelBubble=!0}),t.on(`mouseenter`,()=>{if(this.isTransforming())return;let n=Qc(e,K.getAngle(this.rotation()),this.rotateAnchorCursor());t.getStage().content&&(t.getStage().content.style.cursor=n),this._cursorChange=!0}),t.on(`mouseout`,()=>{this._cursorChange=!1,!this.isTransforming()&&t.getStage().content&&(t.getStage().content.style.cursor=``)}),this.add(t)}_createBack(){let e=new Q({name:`back`,width:0,height:0,sceneFunc(e,t){let n=t.getParent();if(!n.borderEnabled())return;let r=n.padding(),i=t.width(),a=t.height();if(e.beginPath(),e.rect(-r,-r,i+r*2,a+r*2),n.rotateEnabled()&&n.rotateLineVisible()){let t=il(n,i,a);e.moveTo(t.edgeX,t.edgeY),e.lineTo(t.endX,t.endY)}e.fillStrokeShape(t)},hitFunc:(e,t)=>{if(!this.shouldOverdrawWholeArea())return;let n=this.padding();e.beginPath(),e.rect(-n,-n,t.width()+n*2,t.height()+n*2),e.fillStrokeShape(t)}});this._back=e,this.add(e),this._proxyDrag(e),e.on(`dragstart`,e=>{e.cancelBubble=!0}),e.on(`dragmove`,e=>{e.cancelBubble=!0}),e.on(`dragend`,e=>{e.cancelBubble=!0}),this.on(`dragmove`,e=>{this.update()})}_handleMouseDown(e){if(e.evt.button!==void 0&&!K.dragButtons.includes(e.evt.button)||this._transforming)return;this._movingAnchorName=e.target.name().split(` `)[0];let t=this._getNodeRect(),n=t.width,r=t.height,i=Math.sqrt(n**2+r**2);this.sin=Math.abs(r/i),this.cos=Math.abs(n/i);let a=this.getStage()?._getOwnerWindow();this._transformWindow=a||null,a&&(a.addEventListener(`mousemove`,this._handleMouseMove),a.addEventListener(`touchmove`,this._handleMouseMove),a.addEventListener(`mouseup`,this._handleMouseUp,!0),a.addEventListener(`touchend`,this._handleMouseUp,!0),a.addEventListener(`touchcancel`,this._handleMouseUp,!0)),this._transforming=!0,this._pointerId=e.pointerId??q._getFirstPointerId(e.evt);let o=e.target.getAbsolutePosition(),s=e.target.getStage()._getPointerById(this._pointerId);this._anchorDragOffset={x:s.x-o.x,y:s.y-o.y},al.add(this),this._fire(`transformstart`,{evt:e.evt,target:this.getNode()}),this._nodes.forEach(t=>{t._fire(`transformstart`,{evt:e.evt,target:t})})}_handleMouseMove(e){var t;(t=this.getStage())==null||t._batchEvents(()=>this._moveTransform(e))}_moveTransform(e){this._syncSubtreeChange();let t,n,r,i=this._anchors[this._movingAnchorName],a=i.getStage();a.setPointersPositions(e);let o=a._getPointerById(this._pointerId);if(!o)return;let s={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y},c=i.getAbsolutePosition();this.anchorDragBoundFunc()&&(s=this.anchorDragBoundFunc()(c,s,e)),i.setAbsolutePosition(s);let l=i.getAbsolutePosition();if(c.x===l.x&&c.y===l.y)return;if(this._movingAnchorName===`rotater`){let r=this._getNodeRect();t=i.x()-r.width/2,n=-i.y()+r.height/2;let a=q.degToRad(this.rotateAnchorAngle()),o=Math.atan2(-n,t)+Math.PI/2-a,s=K.getAngle(this.rotation())+o,c=K.getAngle(this.rotationSnapTolerance()),l=nl(r,rl(this.rotationSnaps(),s,c)-r.rotation);this._fitNodesInto(l,e);return}let u=this.shiftBehavior(),d;d=u===`inverted`?this.keepRatio()&&!e.shiftKey:u===`none`?this.keepRatio():this.keepRatio()||e.shiftKey;let f=this.centeredScaling()||e.altKey,p=!1;if(this._movingAnchorName===`top-left`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`bottom-right`].x(),y:this._anchors[`bottom-right`].y()};r=Math.sqrt((e.x-i.x())**2+(e.y-i.y())**2);let a=this._anchors[`top-left`].x()>e.x?-1:1,o=this._anchors[`top-left`].y()>e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this._anchors[`top-left`].x(e.x-t),this._anchors[`top-left`].y(e.y-n)}}else if(this._movingAnchorName===`top-center`)this._anchors[`top-left`].y(i.y());else if(this._movingAnchorName===`top-right`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`bottom-left`].x(),y:this._anchors[`bottom-left`].y()};r=Math.sqrt((i.x()-e.x)**2+(e.y-i.y())**2);let a=this._anchors[`top-right`].x()<e.x?-1:1,o=this._anchors[`top-right`].y()>e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this._anchors[`top-right`].x(e.x+t),this._anchors[`top-right`].y(e.y-n)}var m=i.position();this._anchors[`top-left`].y(m.y),this._anchors[`bottom-right`].x(m.x)}else if(this._movingAnchorName===`middle-left`)this._anchors[`top-left`].x(i.x());else if(this._movingAnchorName===`middle-right`)this._anchors[`bottom-right`].x(i.x());else if(this._movingAnchorName===`bottom-left`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`top-right`].x(),y:this._anchors[`top-right`].y()};r=Math.sqrt((e.x-i.x())**2+(i.y()-e.y)**2);let a=e.x<i.x()?-1:1,o=i.y()<e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,i.x(e.x-t),i.y(e.y+n)}m=i.position(),this._anchors[`top-left`].x(m.x),this._anchors[`bottom-right`].y(m.y)}else if(this._movingAnchorName===`bottom-center`)this._anchors[`bottom-right`].y(i.y());else if(this._movingAnchorName===`bottom-right`){if(d){p=!0;let e=f?{x:this.width()/2,y:this.height()/2}:{x:this._anchors[`top-left`].x(),y:this._anchors[`top-left`].y()};r=Math.sqrt((i.x()-e.x)**2+(i.y()-e.y)**2);let a=this._anchors[`bottom-right`].x()<e.x?-1:1,o=this._anchors[`bottom-right`].y()<e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this._anchors[`bottom-right`].x(e.x+t),this._anchors[`bottom-right`].y(e.y+n)}}else console.error(Error(`Wrong position argument of selection resizer: `+this._movingAnchorName));if(f=this.centeredScaling()||e.altKey,f){let e=this._anchors[`top-left`],t=this._anchors[`bottom-right`],n=e.x(),r=e.y(),i=this.getWidth()-t.x(),a=this.getHeight()-t.y();t.move({x:-n,y:-r}),e.move({x:i,y:a})}let h=this._anchors[`top-left`].getAbsolutePosition();t=h.x,n=h.y;let g=this._anchors[`bottom-right`].x()-this._anchors[`top-left`].x(),_=this._anchors[`bottom-right`].y()-this._anchors[`top-left`].y();this._fitNodesInto({x:t,y:n,width:g,height:_,rotation:K.getAngle(this.rotation())},e,p)}_handleMouseUp(e){let t=this.getStage();t&&(t.setPointersPositions(e),!t._changedPointerPositions.some(e=>e.id===this._pointerId))||(t?t._batchEvents(()=>this._removeEvents(e)):this._removeEvents(e))}getAbsoluteTransform(e){let t=this.getTransform();return e?e.getAbsoluteTransform().copy().invert().multiply(t):t}_removeEvents(e){var t;if(this._transforming){this._transforming=!1;let n=this.getStage()?.content;n&&!this._cursorChange&&(n.style.cursor=``);let r=this._transformWindow;this._transformWindow=null,r&&(r.removeEventListener(`mousemove`,this._handleMouseMove),r.removeEventListener(`touchmove`,this._handleMouseMove),r.removeEventListener(`mouseup`,this._handleMouseUp,!0),r.removeEventListener(`touchend`,this._handleMouseUp,!0),r.removeEventListener(`touchcancel`,this._handleMouseUp,!0));let i=this.getNode();al.delete(this),this._fire(`transformend`,{evt:e,target:i}),(t=this.getLayer())==null||t.batchDraw(),i&&this._nodes.forEach(t=>{var n;t._fire(`transformend`,{evt:e,target:t}),(n=t.getLayer())==null||n.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(e,t,n=!1){this._fitting=!0;try{return this._doFitNodesInto(e,t,n)}finally{this._fitting=!1}}_doFitNodesInto(e,t,n=!1){let r=this._getNodeRect();if(!r.width||!r.height||q._inRange(e.width,-this.padding()*2-1,1)||q._inRange(e.height,-this.padding()*2-1,1)){this.update();return}let i=new Ti;i.rotate(K.getAngle(this.rotation()));let a=n?0:this.padding()*2,o=null,s=null;if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf(`left`)>=0){let t=i.point({x:-a,y:0});e.x+=t.x,e.y+=t.y,e.width+=a,o={axis:`width`,from:`left`,to:`right`,offset:t}}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf(`right`)>=0){let t=i.point({x:a,y:0});e.width+=a,o={axis:`width`,from:`right`,to:`left`,offset:t}}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf(`top`)>=0){let t=i.point({x:0,y:-a});e.x+=t.x,e.y+=t.y,e.height+=a,s={axis:`height`,from:`top`,to:`bottom`,offset:t}}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf(`bottom`)>=0){let t=i.point({x:0,y:a});e.height+=a,s={axis:`height`,from:`bottom`,to:`top`,offset:t}}if(this.boundBoxFunc()){let t=this.boundBoxFunc()(r,e);t?e=t:q.warn(`boundBoxFunc returned falsy. You should return new bound rect from it!`)}for(let t of[o,s])t&&e[t.axis]<0&&this._movingAnchorName&&(this._movingAnchorName=this._movingAnchorName.replace(t.from,t.to),this._anchorDragOffset.x-=t.offset.x,this._anchorDragOffset.y-=t.offset.y);let c=1e7,l=new Ti;l.translate(r.x,r.y),l.rotate(r.rotation),l.scale(r.width/c,r.height/c);let u=new Ti,d=e.width/c,f=e.height/c;this.flipEnabled()===!1?(u.translate(e.x,e.y),u.rotate(e.rotation),u.translate(e.width<0?e.width:0,e.height<0?e.height:0),u.scale(Math.abs(d),Math.abs(f))):(u.translate(e.x,e.y),u.rotate(e.rotation),u.scale(d,f));let p=u.multiply(l.invert()),m=new Set;this._nodes.forEach(e=>{if(!e.getStage())return;let t=e.getParent().getAbsoluteTransform(),n=e.getTransform().copy();n.translate(e.offsetX(),e.offsetY());let r=new Ti;r.multiply(t.copy().invert()).multiply(p).multiply(t).multiply(n);let i=r.decompose();e.setAttrs(i);let a=e.getLayer();a&&m.add(a)}),this.rotation(q._getRotation(e.rotation)),this._nodes.forEach(e=>{this._fire(`transform`,{evt:t,target:e}),e._fire(`transform`,{evt:t,target:e})}),this._resetTransformCache(),this.update(),m.add(this.getLayer()),m.forEach(e=>e&&e.batchDraw())}_scheduleUpdate(){this._updateScheduled||(this._updateScheduled=!0,Z._runAfterAbsTransformCascade(()=>{this._updateScheduled=!1,!(!this._nodes?.length||this._fitting||this.isDragging())&&this._update()}))}forceUpdate(){this._resetTransformCache(),this.update()}update(){this._lastNodeRect=void 0,this._update()}_update(){var e;this._subtreeChanged=!1;let t=this._getNodeRect();this._updateElements(t);let n=this.nodes().some(e=>e.draggable());this._back.draggable()!==n&&this._back.draggable(n);let r=this.anchorStyleFunc();r&&Object.values(this._anchors).forEach(e=>r(e)),(e=this.getLayer())==null||e.batchDraw()}_updateElements(e){let t=this._lastNodeRect;if(t&&!this.anchorStyleFunc()&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height&&e.rotation===t.rotation)return;this._lastNodeRect={...e};let n=e.width,r=e.height,i=this.enabledAnchors(),a=this.resizeEnabled(),o=this.padding(),s=this.anchorSize();Object.values(this._anchors).forEach(e=>{e.setAttrs({width:s,height:s,offsetX:s/2,offsetY:s/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._anchors[`top-left`].setAttrs({x:0,y:0,offsetX:s/2+o,offsetY:s/2+o,visible:a&&i.indexOf(`top-left`)>=0}),this._anchors[`top-center`].setAttrs({x:n/2,y:0,offsetY:s/2+o,visible:a&&i.indexOf(`top-center`)>=0}),this._anchors[`top-right`].setAttrs({x:n,y:0,offsetX:s/2-o,offsetY:s/2+o,visible:a&&i.indexOf(`top-right`)>=0}),this._anchors[`middle-left`].setAttrs({x:0,y:r/2,offsetX:s/2+o,visible:a&&i.indexOf(`middle-left`)>=0}),this._anchors[`middle-right`].setAttrs({x:n,y:r/2,offsetX:s/2-o,visible:a&&i.indexOf(`middle-right`)>=0}),this._anchors[`bottom-left`].setAttrs({x:0,y:r,offsetX:s/2+o,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-left`)>=0}),this._anchors[`bottom-center`].setAttrs({x:n/2,y:r,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-center`)>=0}),this._anchors[`bottom-right`].setAttrs({x:n,y:r,offsetX:s/2-o,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-right`)>=0});let c=il(this,n,r);this._anchors.rotater.setAttrs({x:c.endX,y:c.endY,visible:this.rotateEnabled()}),this._back.setAttrs({width:n,height:r,visible:this.borderEnabled()||this.shouldOverdrawWholeArea(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0})}isTransforming(){return this._transforming}stopTransform(){this._transforming&&this._removeEvents()}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=``),cs.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(q.error(`You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead.`),this):super.add(...e)}toObject(){return Z.prototype.toObject.call(this)}clone(e){return Z.prototype.clone.call(this,e)}getClientRect(e){return this.nodes().length>0?super.getClientRect(e):{x:0,y:0,width:0,height:0}}};$.isTransforming=()=>al.size>0;function ol(e){return e instanceof Array||q.warn(`enabledAnchors value should be an array`),e instanceof Array&&e.forEach(function(e){$c.indexOf(e)===-1&&q.warn(`Unknown anchor name: `+e+`. Available names are: `+$c.join(`, `))}),e||[]}$.prototype.className=`Transformer`,Si($),X.addGetterSetter($,`enabledAnchors`,$c,ol),X.addGetterSetter($,`flipEnabled`,!0,ja()),X.addGetterSetter($,`resizeEnabled`,!0),X.addGetterSetter($,`anchorSize`,10,Y()),X.addGetterSetter($,`rotateEnabled`,!0),X.addGetterSetter($,`rotateLineVisible`,!0),X.addGetterSetter($,`rotationSnaps`,[]),X.addGetterSetter($,`rotateAnchorOffset`,50,Y()),X.addGetterSetter($,`rotateAnchorAngle`,0,Y()),X.addGetterSetter($,`rotateAnchorCursor`,`crosshair`),X.addGetterSetter($,`rotationSnapTolerance`,5,Y()),X.addGetterSetter($,`borderEnabled`,!0),X.addGetterSetter($,`anchorStroke`,`rgb(0, 161, 255)`),X.addGetterSetter($,`anchorStrokeWidth`,1,Y()),X.addGetterSetter($,`anchorFill`,`white`),X.addGetterSetter($,`anchorCornerRadius`,0,Y()),X.addGetterSetter($,`borderStroke`,`rgb(0, 161, 255)`),X.addGetterSetter($,`borderStrokeWidth`,1,Y()),X.addGetterSetter($,`borderDash`),X.addGetterSetter($,`keepRatio`,!0),X.addGetterSetter($,`shiftBehavior`,`default`),X.addGetterSetter($,`centeredScaling`,!1),X.addGetterSetter($,`ignoreStroke`,!1),X.addGetterSetter($,`padding`,0,Y()),X.addGetterSetter($,`nodes`),X.addGetterSetter($,`node`),X.addGetterSetter($,`boundBoxFunc`),X.addGetterSetter($,`anchorDragBoundFunc`),X.addGetterSetter($,`anchorStyleFunc`),X.addGetterSetter($,`shouldOverdrawWholeArea`,!1),X.addGetterSetter($,`useSingleNodeRotation`,!0),X.backCompat($,{lineEnabled:`borderEnabled`,rotateHandlerOffset:`rotateAnchorOffset`,enabledHandlers:`enabledAnchors`});var sl=class extends Q{_sceneFunc(e){e.beginPath(),e.arc(0,0,Math.abs(this.radius()),0,K.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return Math.abs(this.radius())*2}getHeight(){return Math.abs(this.radius())*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};sl.prototype.className=`Wedge`,sl.prototype._centroid=!0,sl.prototype._attrsAffectingSize=[`radius`],Si(sl,!0),X.addGetterSetter(sl,`radius`,0,Y()),X.addGetterSetter(sl,`angle`,0,Y()),X.addGetterSetter(sl,`clockwise`,!1),X.backCompat(sl,{angleDeg:`angle`,getAngleDeg:`getAngle`,setAngleDeg:`setAngle`});function cl(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var ll=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],ul=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function dl(e,t){return t===255?e:e*t/255}var fl=180;function pl(e,t){let n=e.data,r=e.width,i=e.height,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T=t+t+1,E=r-1,D=i-1,O=t+1,k=O*(O+1)/2,A=new cl,j=t<=fl?ll[t]/2**ul[t]:1/(O*O),M=null,N=A,P=null,F=null;for(let e=1;e<T;e++)N=N.next=new cl,e===O&&(M=N);N.next=A,s=o=0;for(let e=0;e<i;e++){g=_=v=y=c=l=u=d=0,C=n[o+3],b=dl(n[o],C),x=dl(n[o+1],C),S=dl(n[o+2],C),f=O*b,p=O*x,m=O*S,h=O*C,c+=k*b,l+=k*x,u+=k*S,d+=k*C,N=A;for(let e=0;e<O;e++)N.r=b,N.g=x,N.b=S,N.a=C,N=N.next;for(let e=1;e<O;e++)a=o+((E<e?E:e)<<2),C=n[a+3],c+=(N.r=b=dl(n[a],C))*(w=O-e),l+=(N.g=x=dl(n[a+1],C))*w,u+=(N.b=S=dl(n[a+2],C))*w,d+=(N.a=C)*w,g+=b,_+=x,v+=S,y+=C,N=N.next;P=A,F=M;for(let e=0;e<r;e++)n[o]=Math.floor(c*j),n[o+1]=Math.floor(l*j),n[o+2]=Math.floor(u*j),n[o+3]=Math.floor(d*j),c-=f,l-=p,u-=m,d-=h,f-=P.r,p-=P.g,m-=P.b,h-=P.a,a=s+((a=e+t+1)<E?a:E)<<2,C=n[a+3],g+=P.r=dl(n[a],C),_+=P.g=dl(n[a+1],C),v+=P.b=dl(n[a+2],C),y+=P.a=C,c+=g,l+=_,u+=v,d+=y,P=P.next,f+=b=F.r,p+=x=F.g,m+=S=F.b,h+=C=F.a,g-=b,_-=x,v-=S,y-=C,F=F.next,o+=4;s+=r}for(let e=0;e<r;e++){_=v=y=g=l=u=d=c=0,o=e<<2,f=O*(b=n[o]),p=O*(x=n[o+1]),m=O*(S=n[o+2]),h=O*(C=n[o+3]),c+=k*b,l+=k*x,u+=k*S,d+=k*C,N=A;for(let e=0;e<O;e++)N.r=b,N.g=x,N.b=S,N.a=C,N=N.next;let s=Math.min(1,D)*r;for(let i=1;i<=t;i++)o=s+e<<2,c+=(N.r=b=n[o])*(w=O-i),l+=(N.g=x=n[o+1])*w,u+=(N.b=S=n[o+2])*w,d+=(N.a=C=n[o+3])*w,g+=b,_+=x,v+=S,y+=C,N=N.next,i<D&&(s+=r);o=e,P=A,F=M;for(let t=0;t<i;t++)a=o<<2,n[a+3]=C=Math.floor(d*j),C>0?(C=255/C,n[a]=Math.floor(c*j)*C,n[a+1]=Math.floor(l*j)*C,n[a+2]=Math.floor(u*j)*C):n[a]=n[a+1]=n[a+2]=0,c-=f,l-=p,u-=m,d-=h,f-=P.r,p-=P.g,m-=P.b,h-=P.a,a=e+((a=t+O)<D?a:D)*r<<2,c+=g+=P.r=n[a],l+=_+=P.g=n[a+1],u+=v+=P.b=n[a+2],d+=y+=P.a=n[a+3],P=P.next,f+=b=F.r,p+=x=F.g,m+=S=F.b,h+=C=F.a,g-=b,_-=x,v-=S,y-=C,F=F.next,o+=r}}var ml=function(e,t=1){let n=Math.round(Math.min(this.blurRadius(),fl)*t);n>0&&pl(e,n)};X.addGetterSetter(Z,`blurRadius`,0,Y(),X.afterSetFilter);var hl=function(e){let t=this.brightness()*255,n=e.data,r=n.length;for(let e=0;e<r;e+=4)n[e]+=t,n[e+1]+=t,n[e+2]+=t};X.addGetterSetter(Z,`brightness`,0,Y(),X.afterSetFilter);var gl=function(e){let t=this.attrs.brightness===void 0?1:this.brightness(),n=e.data,r=n.length;for(let e=0;e<r;e+=4)n[e]=Math.min(255,n[e]*t),n[e+1]=Math.min(255,n[e+1]*t),n[e+2]=Math.min(255,n[e+2]*t)},_l=function(e){let t=((this.contrast()+100)/100)**2,n=e.data,r=n.length,i=150,a=150,o=150;for(let e=0;e<r;e+=4)i=n[e],a=n[e+1],o=n[e+2],i/=255,i-=.5,i*=t,i+=.5,i*=255,a/=255,a-=.5,a*=t,a+=.5,a*=255,o/=255,o-=.5,o*=t,o+=.5,o*=255,i=i<0?0:i>255?255:i,a=a<0?0:a>255?255:a,o=o<0?0:o>255?255:o,n[e]=i,n[e+1]=a,n[e+2]=o};X.addGetterSetter(Z,`contrast`,0,Y(),X.afterSetFilter);var vl=function(e){let t=e.data,n=e.width,r=e.height,i=Math.min(1,Math.max(0,this.embossStrength?.call(this)??.5)),a=Math.min(1,Math.max(0,this.embossWhiteLevel?.call(this)??.5)),o={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[this.embossDirection?.call(this)??`top-left`]??315,s=!!(this.embossBlend?.call(this)??!1),c=i*10,l=a*255,u=o*Math.PI/180,d=Math.cos(u),f=Math.sin(u),p=128/1020*c,m=new Float32Array(n*r);for(let e=0,n=0;n<t.length;n+=4,e++)m[e]=.2126*t[n]+.7152*t[n+1]+.0722*t[n+2];let h=[-1,0,1,-2,0,2,-1,0,1],g=[-1,-2,-1,0,0,0,1,2,1],_=e=>e<0?0:e>255?255:e;for(let e=0;e<r;e++)for(let i=0;i<n;i++){let a=0,o=0,c=0;for(let t=-1;t<=1;t++){let s=Math.max(0,Math.min(r-1,e+t))*n;for(let e=-1;e<=1;e++,c++){let t=m[s+Math.max(0,Math.min(n-1,i+e))];a+=t*h[c],o+=t*g[c]}}let u=e*n+i,v=_(l+(d*a+f*o)*p),y=u*4;if(s){let e=v-l;t[y]=_(t[y]+e),t[y+1]=_(t[y+1]+e),t[y+2]=_(t[y+2]+e)}else t[y]=t[y+1]=t[y+2]=v}return e};X.addGetterSetter(Z,`embossStrength`,.5,Y(),X.afterSetFilter),X.addGetterSetter(Z,`embossWhiteLevel`,.5,Y(),X.afterSetFilter),X.addGetterSetter(Z,`embossDirection`,`top-left`,void 0,X.afterSetFilter),X.addGetterSetter(Z,`embossBlend`,!1,void 0,X.afterSetFilter);function yl(e,t,n,r,i){let a=n-t,o=i-r;if(a===0)return r+o/2;if(o===0)return r;let s=(e-t)/a;return s=o*s+r,s}var bl=function(e){let t=e.data,n=t.length,r=t[0],i=r,a,o=t[1],s=o,c,l=t[2],u=l,d,f=this.enhance();if(f===0)return;for(let e=0;e<n;e+=4)a=t[e+0],a<r?r=a:a>i&&(i=a),c=t[e+1],c<o?o=c:c>s&&(s=c),d=t[e+2],d<l?l=d:d>u&&(u=d);i===r&&(i=255,r=0),s===o&&(s=255,o=0),u===l&&(u=255,l=0);let p,m,h,g,_,v;if(f>0)p=i+f*(255-i),m=r-f*(r-0),h=s+f*(255-s),g=o-f*(o-0),_=u+f*(255-u),v=l-f*(l-0);else{let e=(i+r)*.5;p=i+f*(i-e),m=r+f*(r-e);let t=(s+o)*.5;h=s+f*(s-t),g=o+f*(o-t);let n=(u+l)*.5;_=u+f*(u-n),v=l+f*(l-n)}for(let e=0;e<n;e+=4)t[e+0]=yl(t[e+0],r,i,m,p),t[e+1]=yl(t[e+1],o,s,g,h),t[e+2]=yl(t[e+2],l,u,v,_)};X.addGetterSetter(Z,`enhance`,0,Y(),X.afterSetFilter);var xl=function(e){let t=e.data,n=t.length;for(let e=0;e<n;e+=4){let n=.34*t[e]+.5*t[e+1]+.16*t[e+2];t[e]=n,t[e+1]=n,t[e+2]=n}};X.addGetterSetter(Z,`hue`,0,Y(),X.afterSetFilter),X.addGetterSetter(Z,`saturation`,0,Y(),X.afterSetFilter),X.addGetterSetter(Z,`luminance`,0,Y(),X.afterSetFilter);var Sl=function(e){let t=e.data,n=t.length,r=2**this.saturation(),i=(this.hue()%360+360)%360,a=this.luminance()*127,o=1*r*Math.cos(i*Math.PI/180),s=1*r*Math.sin(i*Math.PI/180),c=.299+.701*o+.168*s,l=.587-.587*o+.33*s,u=.114-.114*o-.497*s,d=.299-.299*o-.328*s,f=.587+.413*o+.035*s,p=.114-.114*o+.292*s,m=.299-.3*o+1.25*s,h=.587-.588*o-1.05*s,g=.114+.886*o-.203*s,_,v,y,b;for(let e=0;e<n;e+=4)_=t[e+0],v=t[e+1],y=t[e+2],b=t[e+3],t[e+0]=c*_+l*v+u*y+a,t[e+1]=d*_+f*v+p*y+a,t[e+2]=m*_+h*v+g*y+a,t[e+3]=b},Cl=function(e){let t=e.data,n=t.length,r=2**this.value(),i=2**this.saturation(),a=(this.hue()%360+360)%360,o=r*i*Math.cos(a*Math.PI/180),s=r*i*Math.sin(a*Math.PI/180),c=.299*r+.701*o+.168*s,l=.587*r-.587*o+.33*s,u=.114*r-.114*o-.497*s,d=.299*r-.299*o-.328*s,f=.587*r+.413*o+.035*s,p=.114*r-.114*o+.292*s,m=.299*r-.3*o+1.25*s,h=.587*r-.588*o-1.05*s,g=.114*r+.886*o-.203*s;for(let e=0;e<n;e+=4){let n=t[e+0],r=t[e+1],i=t[e+2],a=t[e+3];t[e+0]=c*n+l*r+u*i,t[e+1]=d*n+f*r+p*i,t[e+2]=m*n+h*r+g*i,t[e+3]=a}};X.addGetterSetter(Z,`hue`,0,Y(),X.afterSetFilter),X.addGetterSetter(Z,`saturation`,0,Y(),X.afterSetFilter),X.addGetterSetter(Z,`value`,0,Y(),X.afterSetFilter);var wl=function(e){let t=e.data,n=t.length;for(let e=0;e<n;e+=4)t[e]=255-t[e],t[e+1]=255-t[e+1],t[e+2]=255-t[e+2]},Tl=function(e,t,n){let r=e.data,i=t.data,a=e.width,o=e.height,s=n.polarCenterX||a/2,c=n.polarCenterY||o/2,l=Math.sqrt(s*s+c*c),u=a-s,d=o-c,f=Math.sqrt(u*u+d*d);l=f>l?f:l;let p=o,m=a,h=360/m*Math.PI/180;for(let e=0;e<m;e+=1){let t=Math.sin(e*h),n=Math.cos(e*h);for(let o=0;o<p;o+=1){u=Math.floor(s+l*o/p*n),d=Math.floor(c+l*o/p*t);let f=(d*a+u)*4,m=r[f+0],h=r[f+1],g=r[f+2],_=r[f+3];f=(e+o*a)*4,i[f+0]=m,i[f+1]=h,i[f+2]=g,i[f+3]=_}}},El=function(e,t,n){let r=e.data,i=t.data,a=e.width,o=e.height,s=n.polarCenterX||a/2,c=n.polarCenterY||o/2,l=Math.sqrt(s*s+c*c),u=a-s,d=o-c,f=Math.sqrt(u*u+d*d);l=f>l?f:l;let p=o,m=a,h=n.polarRotation||0,g,_;for(u=0;u<a;u+=1)for(d=0;d<o;d+=1){let e=u-s,t=d-c,n=Math.sqrt(e*e+t*t)*p/l,o=(Math.atan2(t,e)*180/Math.PI+360+h)%360;o=o*m/360,g=Math.floor(o),_=Math.floor(n);let f=(_*a+g)*4,v=r[f+0],y=r[f+1],b=r[f+2],x=r[f+3];f=(d*a+u)*4,i[f+0]=v,i[f+1]=y,i[f+2]=b,i[f+3]=x}},Dl=function(e){let t=e.width,n=e.height,r,i,a,o,s,c,l,u,d,f,p=Math.round(this.kaleidoscopePower()),m=Math.round(this.kaleidoscopeAngle()),h=Math.floor(t*((m%360+360)%360)/360);if(p<1)return;let g={width:t,height:n,data:new Uint8ClampedArray(t*n*4)};Tl(e,g,{polarCenterX:t/2,polarCenterY:n/2});let _=t/2**p;for(;_<=8;)_*=2,--p;_=Math.ceil(_);let v=_,y=0,b=v,x=1;for(h+_>t&&(y=v,b=0,x=-1),i=0;i<n;i+=1)for(r=y;r!==b;r+=x)a=Math.round(r+h)%t,d=(t*i+a)*4,s=g.data[d+0],c=g.data[d+1],l=g.data[d+2],u=g.data[d+3],f=(t*i+r)*4,g.data[f+0]=s,g.data[f+1]=c,g.data[f+2]=l,g.data[f+3]=u;for(i=0;i<n;i+=1)for(v=Math.floor(_),o=0;o<p;o+=1){for(r=0;r<v+1;r+=1)d=(t*i+r)*4,s=g.data[d+0],c=g.data[d+1],l=g.data[d+2],u=g.data[d+3],f=(t*i+v*2-r-1)*4,g.data[f+0]=s,g.data[f+1]=c,g.data[f+2]=l,g.data[f+3]=u;v*=2}El(g,e,{polarRotation:0})};X.addGetterSetter(Z,`kaleidoscopePower`,2,Y(),X.afterSetFilter),X.addGetterSetter(Z,`kaleidoscopeAngle`,0,Y(),X.afterSetFilter);function Ol(e,t,n){let r=(n*e.width+t)*4,i=[];return i.push(e.data[r++],e.data[r++],e.data[r++],e.data[r++]),i}function kl(e,t){return Math.sqrt((e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2)}function Al(e){let t=[0,0,0];for(let n=0;n<e.length;n++)t[0]+=e[n][0],t[1]+=e[n][1],t[2]+=e[n][2];return t[0]/=e.length,t[1]/=e.length,t[2]/=e.length,t}function jl(e,t){let n=Ol(e,0,0),r=Ol(e,e.width-1,0),i=Ol(e,0,e.height-1),a=Ol(e,e.width-1,e.height-1);if(kl(n,r)<t&&kl(r,a)<t&&kl(a,i)<t&&kl(i,n)<t){let o=Al([r,n,a,i]),s=[];for(let n=0;n<e.width*e.height;n++){let r=kl(o,[e.data[n*4],e.data[n*4+1],e.data[n*4+2]]);s[n]=r<t?0:255}return s}}function Ml(e,t){for(let n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}function Nl(e,t,n){let r=[1,1,1,1,0,1,1,1,1],i=Math.round(Math.sqrt(r.length)),a=Math.floor(i/2),o=[];for(let s=0;s<n;s++)for(let c=0;c<t;c++){let l=s*t+c,u=0;for(let o=0;o<i;o++)for(let l=0;l<i;l++){let d=s+o-a,f=c+l-a;if(d>=0&&d<n&&f>=0&&f<t){let n=d*t+f,a=r[o*i+l];u+=e[n]*a}}o[l]=u===2040?255:0}return o}function Pl(e,t,n){let r=[1,1,1,1,1,1,1,1,1],i=Math.round(Math.sqrt(r.length)),a=Math.floor(i/2),o=[];for(let s=0;s<n;s++)for(let c=0;c<t;c++){let l=s*t+c,u=0;for(let o=0;o<i;o++)for(let l=0;l<i;l++){let d=s+o-a,f=c+l-a;if(d>=0&&d<n&&f>=0&&f<t){let n=d*t+f,a=r[o*i+l];u+=e[n]*a}}o[l]=u>=1020?255:0}return o}function Fl(e,t,n){let r=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],i=Math.round(Math.sqrt(r.length)),a=Math.floor(i/2),o=[];for(let s=0;s<n;s++)for(let c=0;c<t;c++){let l=s*t+c,u=0;for(let o=0;o<i;o++)for(let l=0;l<i;l++){let d=s+o-a,f=c+l-a;if(d>=0&&d<n&&f>=0&&f<t){let n=d*t+f,a=r[o*i+l];u+=e[n]*a}}o[l]=u}return o}var Il=function(e){let t=jl(e,this.attrs.threshold??10);return t&&(t=Nl(t,e.width,e.height),t=Pl(t,e.width,e.height),t=Fl(t,e.width,e.height),Ml(e,t)),e};X.addGetterSetter(Z,`threshold`,.5,Y(),X.afterSetFilter);var Ll=function(e){let t=this.noise()*255,n=e.data,r=n.length,i=t/2;for(let e=0;e<r;e+=4)n[e+0]+=i-2*i*Math.random(),n[e+1]+=i-2*i*Math.random(),n[e+2]+=i-2*i*Math.random()};X.addGetterSetter(Z,`noise`,.2,Y(),X.afterSetFilter);var Rl=function(e,t=1){let n=Math.ceil(this.pixelSize()*t),r=e.width,i=e.height,a=Math.ceil(r/n),o=Math.ceil(i/n),s=e.data;if(n<=0){q.error(`pixelSize value can not be <= 0`);return}for(let e=0;e<a;e+=1)for(let t=0;t<o;t+=1){let a=0,o=0,c=0,l=0,u=e*n,d=Math.min(u+n,r),f=t*n,p=Math.min(f+n,i);for(let e=u;e<d;e+=1)for(let t=f;t<p;t+=1){let n=(r*t+e)*4,i=s[n+3];a+=s[n+0]*i,o+=s[n+1]*i,c+=s[n+2]*i,l+=i}l&&(a/=l,o/=l,c/=l),l/=(d-u)*(p-f);for(let e=u;e<d;e+=1)for(let t=f;t<p;t+=1){let n=(r*t+e)*4;s[n+0]=a,s[n+1]=o,s[n+2]=c,s[n+3]=l}}};X.addGetterSetter(Z,`pixelSize`,8,Y(),X.afterSetFilter);var zl=function(e){let t=Math.round(this.levels()*254)+1,n=e.data,r=n.length,i=255/t;for(let e=0;e<r;e+=1)n[e]=Math.floor(n[e]/i)*i};X.addGetterSetter(Z,`levels`,.5,Y(),X.afterSetFilter);var Bl=function(e){let t=e.data,n=t.length,r=this.red(),i=this.green(),a=this.blue();for(let e=0;e<n;e+=4){let n=(.34*t[e]+.5*t[e+1]+.16*t[e+2])/255;t[e]=n*r,t[e+1]=n*i,t[e+2]=n*a,t[e+3]=t[e+3]}};X.addGetterSetter(Z,`red`,0,Ta,X.afterSetFilter),X.addGetterSetter(Z,`green`,0,Ta,X.afterSetFilter),X.addGetterSetter(Z,`blue`,0,Ta,X.afterSetFilter);var Vl=function(e){let t=e.data,n=t.length,r=this.red(),i=this.green(),a=this.blue(),o=this.alpha();for(let e=0;e<n;e+=4){let n=1-o;t[e]=r*o+t[e]*n,t[e+1]=i*o+t[e+1]*n,t[e+2]=a*o+t[e+2]*n}};X.addGetterSetter(Z,`alpha`,1,e=>Math.min(1,Math.max(0,e)),X.afterSetFilter);var Hl=function(e){let t=e.data,n=t.length;for(let e=0;e<n;e+=4){let n=t[e+0],r=t[e+1],i=t[e+2];t[e+0]=Math.min(255,n*.393+r*.769+i*.189),t[e+1]=Math.min(255,n*.349+r*.686+i*.168),t[e+2]=Math.min(255,n*.272+r*.534+i*.131)}},Ul=function(e){let t=e.data;for(let e=0;e<t.length;e+=4){let n=t[e],r=t[e+1],i=t[e+2];.2126*n+.7152*r+.0722*i>=128&&(t[e]=255-n,t[e+1]=255-r,t[e+2]=255-i)}return e},Wl=function(e){let t=this.threshold()*255,n=e.data,r=n.length;for(let e=0;e<r;e+=1)n[e]=n[e]<t?0:255};X.addGetterSetter(Z,`threshold`,.5,Y(),X.afterSetFilter);var Gl=Cs.Util._assign(Cs,{Arc:ws,Arrow:Hs,Circle:Us,Ellipse:Ws,Image:Gs,Label:Nc,Tag:Pc,Line:Rs,Path:Vs,Rect:Fc,RegularPolygon:Ic,Ring:Rc,Sprite:zc,Star:Bc,Text:Ec,TextPath:Gc,Transformer:$,Wedge:sl,Filters:{Blur:ml,Brightness:gl,Brighten:hl,Contrast:_l,Emboss:vl,Enhance:bl,Grayscale:xl,HSL:Sl,HSV:Cl,Invert:wl,Kaleidoscope:Dl,Mask:Il,Noise:Ll,Pixelate:Rl,Posterize:zl,RGB:Bl,RGBA:Vl,Sepia:Hl,Solarize:Ul,Threshold:Wl}});function Kl(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function ql(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}var Jl=class{cells=new Map;large=[];items;cellSize;constructor(e,t=256){if(this.items=e,this.cellSize=t,!Number.isFinite(t)||t<=0)throw Error(`Invalid spatial cell size`);e.forEach((e,t)=>{let[n,r,i,a]=this.range(e.bounds);if((i-n+1)*(a-r+1)>256){this.large.push(t);return}for(let e=n;e<=i;e++)for(let n=r;n<=a;n++){let r=`${e},${n}`,i=this.cells.get(r)??[];i.push(t),this.cells.set(r,i)}})}range(e){return[Math.floor(e.x/this.cellSize),Math.floor(e.y/this.cellSize),Math.floor((e.x+e.width)/this.cellSize),Math.floor((e.y+e.height)/this.cellSize)]}query(e){let[t,n,r,i]=this.range(e),a=new Set(this.large);if((r-t+1)*(i-n+1)>1e4)this.items.forEach((e,t)=>a.add(t));else for(let e=t;e<=r;e++)for(let t=n;t<=i;t++)for(let n of this.cells.get(`${e},${t}`)??[])a.add(n);let o=t=>e.width===0&&e.height===0?ql(t,e.x,e.y):Kl(t,e);return[...a].sort((e,t)=>e-t).map(e=>this.items[e]).filter(e=>e.node.visible!==!1&&o(e.bounds)&&e.clips.every(o))}hitTest(e,t){return this.query({x:e,y:t,width:0,height:0}).toReversed().find(n=>ql(n.bounds,e,t)&&n.clips.every(n=>ql(n,e,t)))}};function Yl(e,t,n=new Map,r,i,a,o=!1){Gl.autoDrawEnabled=!1,Gl.pixelRatio=1;let s=new Gl.Stage({width:e,height:t,...r?{container:r}:{}}),c=new Gl.Layer({listening:!1}),l=new Gl.Layer({listening:!1}),u=new Gl.Layer({listening:!1});s.add(c,l,u);for(let e of[c,l,u])a?.(e.getCanvas()._canvas);let d={x:0,y:0,width:e,height:t},f=new Jl([]),p={},m=[],h=[],g={selection:`#2563EB`,changes:`#B45309`},_=!1,v=!1,y=0,b=[],x=new Map,S=(e,t)=>{let n=Ur(e.document,t,p);return typeof n==`number`?n:0},C=(e,t)=>String(Ur(e.document,t,p)),w=e=>{let t=e.node,r=e.bounds,i=t.fills?.[0],a={x:r.x,y:r.y,width:r.width,height:r.height,listening:!1,opacity:t.opacity??1,rotation:t.rotation??0};if(i?.kind===`solid`&&(a.fill=C(e,i.color)),i?.kind===`image`){let t=n.get(`${e.document.documentId}:${i.assetId}`);if(!t)a.fill=`#D4D4D8`;else{let e=r.width/t.width,n=r.height/t.height,o=i.mode===`cover`?Math.max(e,n):Math.min(e,n);a.fillPriority=`pattern`,a.fillPatternRepeat=`no-repeat`,a.fillPatternScale=i.mode===`stretch`?{x:e,y:n}:{x:o,y:o},a.fillPatternX=(r.width-t.width*(i.mode===`stretch`?e:o))/2,a.fillPatternY=(r.height-t.height*(i.mode===`stretch`?n:o))/2}}if(i?.kind===`gradient`){let t=i.stops.flatMap(t=>[t.offset,C(e,t.color)]);i.gradient===`linear`?(a.fillLinearGradientStartPoint={x:0,y:0},a.fillLinearGradientEndPoint={x:r.width*Math.cos(i.angle*Math.PI/180),y:r.height*Math.sin(i.angle*Math.PI/180)},a.fillLinearGradientColorStops=t):(a.fillRadialGradientStartPoint={x:r.width/2,y:r.height/2},a.fillRadialGradientEndPoint={x:r.width/2,y:r.height/2},a.fillRadialGradientStartRadius=0,a.fillRadialGradientEndRadius=Math.max(r.width,r.height)/2,a.fillRadialGradientColorStops=t)}t.stroke&&(a.stroke=C(e,t.stroke),a.strokeWidth=t.strokeWidth?S(e,t.strokeWidth):1);let o=t.effects?.find(e=>e.kind===`shadow`);o?.kind===`shadow`&&(a.shadowColor=C(e,o.color),a.shadowBlur=S(e,o.blur),a.shadowOffset={x:S(e,o.x),y:S(e,o.y)});let s;if(s=t.type===`text`?new Gl.Text({...a,text:t.text,fontFamily:C(e,t.fontFamily),fontSize:S(e,t.fontSize),fontStyle:(t.fontWeight??400)>=600?`bold`:`normal`,lineHeight:t.lineHeight?S(e,t.lineHeight):1.2}):t.type===`ellipse`?new Gl.Ellipse({...a,x:r.x+r.width/2,y:r.y+r.height/2,radiusX:r.width/2,radiusY:r.height/2}):t.type===`path`?new Gl.Path({...a,data:t.geometry,scaleX:r.width/(t.viewBox.width||1),scaleY:r.height/(t.viewBox.height||1)}):new Gl.Rect({...a,cornerRadius:`radius`in t&&t.radius?S(e,t.radius):0}),i?.kind===`image`){let t=n.get(`${e.document.documentId}:${i.assetId}`);t&&s.setAttrs({fillPatternImage:t})}let c=t.effects?.find(e=>e.kind===`blur`);if(c?.kind===`blur`&&(s.cache(),s.filters([Gl.Filters.Blur]),s.blurRadius(S(e,c.radius))),!e.clips.length)return s;let l=e.clips.reduce((e,t)=>{let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y);return{x:n,y:r,width:Math.max(0,Math.min(e.x+e.width,t.x+t.width)-n),height:Math.max(0,Math.min(e.y+e.height,t.y+t.height)-r)}}),u=new Gl.Group({clipX:l.x,clipY:l.y,clipWidth:l.width,clipHeight:l.height,listening:!1});return u.add(s),u},T=(e,t,n)=>{e.destroyChildren();for(let r of b)if(t.includes(r.ownerId)){let t=r.bounds;e.add(new Gl.Rect({...t,stroke:n,strokeWidth:1,listening:!1}))}},E={setDocument(e,t={},n={},r){let i=Kr(e,t,n);if(i.diagnostics.some(e=>e.severity===`error`))throw Error(`Invalid layout for renderer spike`);f=new Jl(r?Gr(i.items,r):i.items),p=t,_=!0,v=!0},setViewport(e){if(e.width<=0||e.height<=0)throw Error(`Viewport needs positive dimensions`);JSON.stringify(e)!==JSON.stringify(d)&&(d=e,_=!0)},setSelection(e){m=e,_=!0},setChanges(e){h=e,_=!0},setStrokes(e){(e.selection!==g.selection||e.changes!==g.changes)&&(g=e,_=!0)},render(){if(!_)return!1;b=f.query(d);let n=new Set(b.map(e=>e.key));for(let[e,t]of x)(v||!n.has(e))&&(t.destroy(),x.delete(e));for(let e of b)if(!x.has(e.key)){let t=w(e);c.add(t),x.set(e.key,t)}b.forEach((e,t)=>{let n=x.get(e.key);n.zIndex()!==t&&n.zIndex(t)});let r=e/d.width,i=t/d.height;for(let e of[c,l,u])e.scale({x:r,y:i}),e.position({x:-d.x*r,y:-d.y*i});return T(l,m,g.selection),T(u,h,g.changes),c.draw(),l.draw(),u.draw(),y++,_=!1,v=!1,!0},hitTest(e,t){return f.hitTest(e,t)?.ownerId},async exportPng(){E.render();let e=o?c.getCanvas()._canvas:s.toCanvas({pixelRatio:1});if(i)return i(e);let t=await new Promise((t,n)=>e.toBlob(e=>e?t(e):n(Error(`PNG export failed`)),`image/png`));return new Uint8Array(await t.arrayBuffer())},stats(){return{visible:b.length,sceneShapes:x.size,draws:y}},destroy(){s.destroy(),x.clear()}};return E}var Xl=0;async function Zl(e,t,n,r=new Map,i){let a=new Map;return await Promise.all([...r].map(async([e,t])=>{let n=URL.createObjectURL(new Blob([t.slice().buffer]));try{let t=new Image;t.src=n,await t.decode(),a.set(e,t)}catch{i?.(e)}finally{URL.revokeObjectURL(n)}})),e.id||=`design-canvas-${++Xl}`,Yl(t,n,a,e.id)}var Ql=`M3 3 C4.2 1.8 6.2 2.4 8.4 3.4 L26.6 11.7 C28.6 12.6 29.7 13.9 29.6 15.2 C29.5 16.7 28.5 17.8 26.7 18.2 L20.0 19.8 C18.8 20.1 18.1 20.7 17.5 21.7 L13.7 28.2 C12.5 30.3 9.5 29.9 8.8 27.5 L3.4 8.4 C2.78 6.2 1.8 4.2 3 3 Z`,$l=`0 0 32 32`,eu=`#0a0a0a`,tu=`#fff`,nu=`drop-shadow(0 0 1px rgb(0 0 0 / 0.72))`,ru=3e3,iu=1e4,au=1200,ou=`blur(5px)`,su=.45,cu=`#fff`,lu=30,uu=Array.from({length:31},(e,t)=>{let n=t/lu;return-Math.exp(-3.2*n)*Math.sin(4*Math.PI*n)}),du=Math.max(...uu.map(Math.abs)),fu=uu.map((e,t)=>({offset:t/lu,transform:`rotate(${(e/du*15).toFixed(2)}deg)`})),pu=[{offset:0,opacity:su},{offset:.35,opacity:1},{offset:1,opacity:su}],mu={paint:1500,flash:650,cursorGlide:450,cursorFade:240,cursorLinger:900,batchLinger:1600,wipe:400,fade:160},hu=(e,t)=>{let n=e.nodes[t];return n&&`children`in n?n.children:[]};function gu(e){let t=new Map;for(let n of Object.keys(e.nodes))for(let r of hu(e,n))t.set(r,n);return t}function _u(e,t,n=24){let r=gu(e),i=[...new Set(t)].filter(t=>e.nodes[t]),a=e=>{let t=new Set(e);return e.filter(e=>{for(let n=r.get(e);n;n=r.get(n))if(t.has(n))return!1;return!0})},o=a(i);for(;o.length>n;){let e=[...new Set(o.map(e=>r.get(e)??e))];if(e.length===o.length)return o.slice(0,n);o=a(e)}return o}var vu=e=>{if(!e.length)return null;let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y)),r=Math.max(...e.map(e=>e.x+e.width)),i=Math.max(...e.map(e=>e.y+e.height));return{x:t,y:n,width:r-t,height:i-n}},yu=e=>({x:e.x+Math.min(20,e.width/3),y:e.y+Math.min(14,e.height/3)});function bu(e,t){for(let n=e.length-1;n>=0;n--){let r=t(e[n]);if(r)return{nodeId:e[n],bounds:r}}return null}var xu=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height;function Su(e,t,n,r={top:64,right:16,bottom:72,left:16}){let i=n.width/t.width,a=(e.x+e.width/2-t.x)*i,o=(e.y+e.height/2-t.y)*i,s=a-n.width/2,c=o-n.height/2,l=Math.abs(s)/n.width>=Math.abs(c)/n.height,u=(e,t,n)=>Math.min(Math.max(e,t),Math.max(t,n));if(l){let e=s<0?`left`:`right`;return{side:e,x:e===`left`?r.left:n.width-r.right,y:u(o,r.top,n.height-r.bottom)}}let d=c<0?`top`:`bottom`;return{side:d,x:u(a,r.left+90,n.width-r.right-90),y:d===`top`?r.top:n.height-r.bottom}}function Cu(e,t,n,r=72){let i=n.width/t.width,a=Math.min((n.width-r*2)/e.width,(n.height-r*2)/e.height),o=Math.max(.05,Math.min(i,a)),s=n.width/o,c=n.height/o;return{x:e.x+e.width/2-s/2,y:e.y+e.height/2-c/2,width:s,height:c}}var wu=/^(apply|design_[a-z]+)\s+[a-z-]*:\s*/i;function Tu(e,t=56){let n=(e.replace(wu,``).split(`
17
+ `,1)[0]??``).trim().replace(/\.$/,``)||`see the agent's reply`;return n.length>t?`${n.slice(0,t-1).trimEnd()}…`:n}function Eu(e){let t=new Map;return{start(n){t.set(n,setTimeout(()=>{t.delete(n),e(n)},mu.wipe+100))},dispose(){for(let e of t.values())clearTimeout(e);t.clear()}}}var Du=`(prefers-reduced-motion: reduce)`,Ou=e=>{let t=matchMedia(Du);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)},ku=()=>(0,H.useSyncExternalStore)(Ou,Bu,Vu),Au=e=>(document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)),ju=`cubic-bezier(0.77, 0, 0.175, 1)`,Mu={left:ye,right:be,top:xe,bottom:ve},Nu=64;function Pu(e,t,n){let r=n.width/t.width,i=(e.x-t.x)*r,a=(e.y-t.y)*r,o=e.width*r,s=e.height*r,c=Math.max(i,-64),l=Math.max(a,-64),u=Math.min(i+o,n.width+Nu),d=Math.min(a+s,n.height+Nu);return{corner:{x:i,y:a},visible:u>c&&d>l,style:{left:c,top:l,width:Math.max(0,u-c),height:Math.max(0,d-l),"--paint-ox":`${i-c}px`,"--paint-oy":`${a-l}px`}}}function Fu({cursorSize:e=`small`,cursorLabel:t=`name`,animations:n=!0,document:r,bounds:i,viewport:a,canvas:o,batch:s,agents:c,onReveal:l}){let u=(0,H.useSyncExternalStore)(Au,()=>!globalThis.document.hidden,()=>!1),d=ku()||!n,f=o.width/a.width,p=c?.some(e=>e.active)??!1,m=(c?.find(e=>e.active)??c?.[0])?.label??`Agent`,h=c?.find(e=>e.lastError!==null)?.lastError??null,g=(0,H.useMemo)(()=>{let e=new Set;return(c??[]).flatMap(t=>{let n=t.workingNodeId,a=n?i.get(n):void 0;return!n||!a||e.has(n)?[]:(e.add(n),[{id:n,label:t.label,box:a,root:r.roots.includes(n)}])})},[c,i,r.roots]),[_,v]=(0,H.useState)(null),[y,b]=(0,H.useState)([]),[x,S]=(0,H.useState)(!1),[C,w]=(0,H.useState)(null),T=(0,H.useRef)({document:r,bounds:i,working:g,active:p,reduced:d,failed:h!==null});T.current={document:r,bounds:i,working:g,active:p,reduced:d,failed:h!==null};let E=(0,H.useRef)(p?null:s?.sequence??null),D=(0,H.useRef)(null),O=(0,H.useRef)({}),k=(0,H.useRef)(0),A=(0,H.useRef)(null);A.current??=Eu(e=>b(t=>t.filter(t=>t.id!==e))),(0,H.useEffect)(()=>{if(!s||s.sequence===E.current)return;E.current=s.sequence;let{document:e,bounds:t,reduced:n}=T.current,r=_u(e,s.nodeIds).flatMap(e=>t.get(e)??[]),i=bu(s.nodeIds,e=>t.get(e)),a=i?yu(i.bounds):null,o=D.current,c=!n&&a&&o&&(o.x!==a.x||o.y!==a.y)?mu.cursorGlide:0,l=n?mu.flash:mu.paint;v({id:s.sequence,rects:r,delay:c}),i&&a&&w({point:a,box:i.bounds,name:e.nodes[i.nodeId]?.name??``}),S(!0),clearTimeout(O.current.flash),clearTimeout(O.current.linger),O.current.flash=window.setTimeout(()=>v(e=>e?.id===s.sequence?null:e),c+l+80),O.current.linger=window.setTimeout(()=>S(!1),Math.max(mu.batchLinger,c+l))},[s]),(0,H.useEffect)(()=>()=>{clearTimeout(O.current.flash),clearTimeout(O.current.linger),A.current?.dispose()},[]);let j=g.map(e=>e.id).join(`|`),M=(0,H.useRef)(new Map);(0,H.useEffect)(()=>{let e=new Map(T.current.working.map(e=>[e.id,{id:0,bounds:e.box,label:e.label,failed:T.current.failed}])),t=[...M.current].filter(([t])=>!e.has(t)),n=T.current.working.find(e=>!M.current.has(e.id));if(M.current=e,n&&w({point:yu(n.box),box:n.box,name:T.current.document.nodes[n.id]?.name??``}),!t.length)return;let r=t.map(([,e])=>({...e,id:++k.current}));b(e=>[...e,...r]);for(let e of r)A.current?.start(e.id)},[j]),(0,H.useEffect)(()=>{M.current=new Map(g.map(e=>[e.id,{id:0,bounds:e.box,label:e.label,failed:h!==null}]))},[g,h]);let N=(0,H.useMemo)(()=>{if(C)return C;if(!h)return null;let e=r.roots.map(e=>i.get(e)).find(Boolean);return e?{point:yu(e),box:e,name:``}:null},[C,h,r.roots,i]),P=N!==null&&(p||x||g.length>0||h!==null),F=(0,H.useRef)(null),I=(0,H.useRef)(null);(0,H.useLayoutEffect)(()=>{let e=N?.point??null,t=D.current;e&&(D.current=e);let n=F.current;if(!n||!e||!t||d){I.current?.cancel();return}if(t.x===e.x&&t.y===e.y)return;let r=0,i=0;if(I.current?.playState===`running`){let e=new DOMMatrixReadOnly(getComputedStyle(n).transform);r=e.e,i=e.f}I.current?.cancel(),I.current=n.animate([{transform:`translate(${(t.x-e.x)*f+r}px, ${(t.y-e.y)*f+i}px)`},{transform:`translate(0px, 0px)`}],{duration:mu.cursorGlide,easing:ju})},[N?.point.x,N?.point.y,d]),(0,H.useEffect)(()=>()=>I.current?.cancel(),[]);let ee=g[0]?.box??(P?N?.box:void 0)??null,L=ee&&(p||x||g.length>0)&&!xu(ee,a)?ee:null,te=L?Su(L,a,o):null;if(!o.width)return null;let ne=h?`${m}: change not applied - ${Tu(h)}`:g[0]?`${g[0].label} is generating ${r.nodes[g[0].id]?.name??`a frame`}`:``,re=h!==null,R=N?{x:(N.point.x-a.x)*f,y:(N.point.y-a.y)*f}:null,ie=R?R.x>o.width-240:!1;return(0,G.jsxs)(`div`,{className:`design-paint`,"data-reduced":d?``:void 0,"data-paused":u?void 0:``,style:{"--paint-cycle":`${mu.batchLinger}ms`},children:[(0,G.jsx)(`span`,{className:`sr-only`,role:`status`,children:ne}),g.map(e=>{let t=Pu(e.box,a,o);return t.visible?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`design-paint-field`,"data-failed":re?``:void 0,style:t.style}),e.root&&e.box.width*f>80?(0,G.jsxs)(`span`,{className:`design-paint-label`,"data-inside":e.root?void 0:``,style:{left:t.corner.x,top:t.corner.y},children:[(0,G.jsx)(Lu,{size:14}),(0,G.jsx)(`span`,{children:(0,G.jsx)(`b`,{children:e.label})})]}):null]},e.id):null}),y.map(e=>{let t=Pu(e.bounds,a,o);return t.visible?(0,G.jsx)(`div`,{className:`design-paint-field design-paint-wipe`,"data-failed":e.failed?``:void 0,style:t.style},e.id):null}),_?.rects.map(e=>{let t=Pu(e,a,o);return t.visible?(0,G.jsx)(`div`,{className:`design-paint-flash`,style:{...t.style,animationDelay:`${_.delay}ms`}},`${_.id}:${e.x}:${e.y}:${e.width}`):null}),N&&R?(0,G.jsx)(`div`,{className:`design-paint-cursor`,"data-size":e,"data-shown":P?``:void 0,"data-failed":re?``:void 0,"data-flip":ie?``:void 0,style:{transform:`translate3d(${R.x}px, ${R.y}px, 0)`},children:(0,G.jsxs)(`div`,{ref:F,className:`design-paint-glide`,children:[(0,G.jsx)(Lu,{animate:P&&u&&!d&&!re&&R.x>=0&&R.y>=0&&R.x<=o.width&&R.y<=o.height,sequence:s?.sequence}),(0,G.jsx)(`span`,{className:`design-paint-pill`,hidden:t===`none`&&!re,children:re?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`b`,{children:[m,`:`]}),` change not applied - `,Tu(h??``)]}):(0,G.jsx)(G.Fragment,{children:(0,G.jsx)(`b`,{children:t===`agent`?`Agent`:m})})})]})}):null,te?(0,G.jsx)(Iu,{label:m,chip:te,onClick:()=>L&&l(L)}):null]})}function Iu(e){let t=(0,U.c)(11),{label:n,chip:r,onClick:i}=e,a=Mu[r.side],o;t[0]!==r.x||t[1]!==r.y?(o={left:r.x,top:r.y},t[0]=r.x,t[1]=r.y,t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=(0,G.jsx)(a,{"aria-hidden":`true`}),t[3]=a,t[4]=s);let c;return t[5]!==r.side||t[6]!==n||t[7]!==i||t[8]!==o||t[9]!==s?(c=(0,G.jsxs)(`button`,{type:`button`,className:`design-paint-chip`,"data-side":r.side,style:o,onClick:i,children:[s,n,` is working here`]}),t[5]=r.side,t[6]=n,t[7]=i,t[8]=o,t[9]=s,t[10]=c):c=t[10],c}function Lu(e){let t=(0,U.c)(10),{size:n,animate:r,sequence:i}=e,a=n===void 0?22:n,o=r!==void 0&&r,s=(0,H.useRef)(null),c=(0,H.useRef)(null),l;t[0]===o?l=t[1]:(l=()=>{if(!o)return;let e=[],t=()=>{document.hidden||(e=[s.current?.animate(fu,{duration:au,easing:`linear`}),c.current?.animate(pu,{duration:au,easing:`ease-in-out`})].filter(zu))},n,r=setTimeout(()=>{t(),n=setInterval(t,iu)},ru);return()=>{clearTimeout(r),clearInterval(n),e.forEach(Ru)}},t[0]=o,t[1]=l);let u;t[2]!==o||t[3]!==i?(u=[o,i],t[2]=o,t[3]=i,t[4]=u):u=t[4],(0,H.useEffect)(l,u);let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d={overflow:`visible`,filter:nu},t[5]=d):d=t[5];let f,p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,G.jsx)(`path`,{ref:c,d:Ql,fill:cu,stroke:cu,strokeWidth:6,strokeLinejoin:`round`,strokeLinecap:`round`,style:{filter:ou,opacity:su}}),p=(0,G.jsx)(`path`,{d:Ql,fill:eu,stroke:tu,strokeWidth:2,strokeLinejoin:`round`,strokeLinecap:`round`}),t[6]=f,t[7]=p):(f=t[6],p=t[7]);let m;return t[8]===a?m=t[9]:(m=(0,G.jsxs)(`svg`,{ref:s,className:`design-cu-cursor`,width:a,height:a,viewBox:$l,shapeRendering:`geometricPrecision`,"aria-hidden":`true`,style:d,children:[f,p]}),t[8]=a,t[9]=m),m}function Ru(e){return e.cancel()}function zu(e){return!!e}function Bu(){return matchMedia(Du).matches}function Vu(){return!0}function Hu(e){return e.split(/[-_\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function Uu(e){return String(Number.isInteger(e)?e:Math.round(e*100)/100)}var Wu=e=>`${Math.round(e*100)}%`,Gu=e=>e?`Shown`:`Hidden`,Ku=e=>e?`On`:`Off`,qu=e=>e?String(e):`None`;function Ju(e){return new Map(Object.entries(e).toSorted(([e,t],[n,r])=>t.createdAt.localeCompare(r.createdAt)||e.localeCompare(n)).map(([e],t)=>[e,t+1]))}function Yu(e){let t=getComputedStyle(e);return{selection:t.getPropertyValue(`--design-selection`).trim()||`#2563EB`,changes:t.getPropertyValue(`--design-change-stroke`).trim()||`#B45309`}}var Xu=new Map,Zu=48;function Qu(e){let t=(0,U.c)(10),{name:n,x:r,y:i,width:a,hidden:o}=e,s=Math.min(240,a),c;t[0]!==s||t[1]!==r||t[2]!==i?(c={left:r,top:i,maxWidth:s},t[0]=s,t[1]=r,t[2]=i,t[3]=c):c=t[3];let l=o||a<Zu,u;t[4]===n?u=t[5]:(u=(0,G.jsx)(Mt,{children:n}),t[4]=n,t[5]=u);let d;return t[6]!==c||t[7]!==l||t[8]!==u?(d=(0,G.jsx)(`span`,{className:`design-frame-label`,style:c,hidden:l,children:u}),t[6]=c,t[7]=l,t[8]=u,t[9]=d):d=t[9],d}function $u(e){let t=(0,U.c)(19),{screen:n,frame:r,canvas:i,avoid:a,decoration:o,callout:s}=e;if(n.x+n.width<0||n.y+n.height<0||n.x>i.width||n.y>i.height||!i.width)return null;let c=s?a:null,l;t[0]!==i||t[1]!==r||t[2]!==n||t[3]!==c?(l=gi(n,r,i,c),t[0]=i,t[1]=r,t[2]=n,t[3]=c,t[4]=l):l=t[4];let{side:u,placement:d,reach:f}=l,p=`${f}px`,m;t[5]!==n.height||t[6]!==n.width||t[7]!==n.x||t[8]!==n.y||t[9]!==p?(m={left:n.x,top:n.y,width:n.width,height:n.height,"--design-agent-edit-reach":p},t[5]=n.height,t[6]=n.width,t[7]=n.x,t[8]=n.y,t[9]=p,t[10]=m):m=t[10];let h=m,g;t[11]===s?g=t[12]:(g=s?(0,G.jsx)(`div`,{className:`design-agent-edit-callout`,children:s}):null,t[11]=s,t[12]=g);let _;return t[13]!==o||t[14]!==d||t[15]!==u||t[16]!==h||t[17]!==g?(_=(0,G.jsxs)(`div`,{className:`design-agent-edit`,"data-side":u,"data-placement":d,style:h,children:[o,g]}),t[13]=o,t[14]=d,t[15]=u,t[16]=h,t[17]=g,t[18]=_):_=t[18],_}var ed=(e,t,n,r,i,a,o=0)=>di(Kr(e,t,n).items.map(e=>e.bounds),r,i,a,o);function td({preferences:e,viewKey:t,chrome:n=`panel`,document:r,theme:i,context:a,assets:o,selection:s,changedNodeIds:c,onSelect:l,annotationMode:u,onAnnotationModeChange:d,onAnchor:f,onOpenAnnotation:p,revision:m,externalViewport:h,onViewportChange:g,renderSelectionOverlay:_,agentEdit:v,frameDecoration:y,batch:b,agents:x}){let S=(0,H.useRef)(null),C=(0,H.useRef)(null),w=(0,H.useRef)({x:0,y:0,width:1,height:1}),T=(0,H.useRef)({width:1,height:1}),E=(0,H.useRef)(0);E.current=!v||n!==`workspace`?0:v.callout?hi.width:120;let D=(0,H.useRef)(null),O=(0,H.useRef)(null),k=(0,H.useRef)(new Map),A=(0,H.useRef)(null),j=(0,H.useRef)(null),M=(0,H.useRef)(null),N=(0,H.useRef)({document:r,theme:i,context:a,selection:s,changedNodeIds:c,externalViewport:h});N.current={document:r,theme:i,context:a,selection:s,changedNodeIds:c,externalViewport:h};let[P,F]=(0,H.useState)({width:0,height:0}),[I,ee]=(0,H.useState)(!1),[L,te]=(0,H.useState)(w.current),[ne,re]=(0,H.useState)(100),[R,ie]=(0,H.useState)(null),ae=(0,H.useCallback)(()=>{let e=S.current,t=[...k.current.keys()];k.current.clear(),O.current=null,A.current=null,j.current&&(j.current.hidden=!0);for(let n of t)e?.hasPointerCapture(n)&&e.releasePointerCapture(n)},[]);(0,H.useEffect)(()=>{let e=()=>{window.document.hidden&&ae()};return window.addEventListener(`blur`,ae),window.document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`blur`,ae),window.document.removeEventListener(`visibilitychange`,e)}},[ae]),(0,H.useEffect)(ae,[t,u,I,ae]);let oe=(0,H.useMemo)(()=>{try{return Kr(r,i,a).items}catch{return null}},[r,i,a]),se=(0,H.useMemo)(()=>{try{let e=oe??Kr(r,i,a).items,t=new Set(r.roots),n=new Set(s),o=e.filter(e=>t.has(e.ownerId)&&e.node.type===`frame`),c=e.filter(e=>n.has(e.ownerId));if(!c.length)return{frames:o,selectionBounds:null};let l=Math.min(...c.map(e=>e.bounds.x)),u=Math.min(...c.map(e=>e.bounds.y)),d=Math.max(...c.map(e=>e.bounds.x+e.bounds.width)),f=Math.max(...c.map(e=>e.bounds.y+e.bounds.height));return{frames:o,selectionBounds:{x:l,y:u,width:d-l,height:f-u}}}catch{return{frames:[],selectionBounds:null}}},[oe,r,i,a,s]),ce=!!v,le=(0,H.useMemo)(()=>{if(!ce||!c.length)return null;let e=new Set(c.flatMap(e=>{let t=r.nodes[e];return t&&`children`in t?t.children:[]})),t=c.findLast(t=>r.nodes[t]&&!e.has(t));if(!t)return null;try{let e=(oe??Kr(r,i,a).items).filter(e=>e.ownerId===t);if(!e.length)return null;let n=Math.min(...e.map(e=>e.bounds.x)),o=Math.min(...e.map(e=>e.bounds.y)),s=Math.max(...e.map(e=>e.bounds.x+e.bounds.width)),c=Math.max(...e.map(e=>e.bounds.y+e.bounds.height));return{nodeId:t,name:r.nodes[t]?.name??``,bounds:{x:n,y:o,width:s-n,height:c-o}}}catch{return null}},[ce,c,oe,r,i,a]),ue=b!==void 0,de=(0,H.useMemo)(()=>{if(!ue||!oe)return null;let e=new Map;for(let t of oe){let n=e.get(t.ownerId);n?n.push(t.bounds):e.set(t.ownerId,[t.bounds])}return new Map([...e].flatMap(([e,t])=>{let n=vu(t);return n?[[e,n]]:[]}))},[ue,oe]),fe=x?.some(e=>e.active)??!1,pe=(0,H.useMemo)(()=>new Set(x?.flatMap(e=>e.workingNodeId?[e.workingNodeId]:[])),[x]),me=P.width/L.width,he=e=>({x:(e.x-L.x)*me,y:(e.y-L.y)*me,width:e.width*me,height:e.height*me}),ge=v&&le?he(le.bounds):null,_e=(()=>{if(!le||!ge)return null;let{x:e,y:t,width:n,height:r}=le.bounds,i=e+n/2,a=t+r/2,o=se.frames.find(({bounds:e})=>i>=e.x&&i<=e.x+e.width&&a>=e.y&&a<=e.y+e.height)?.bounds;return o?he(o):null})(),[ve,ye]=(0,H.useState)(null),be=(0,H.useCallback)(e=>{ye(t=>t===e||t&&e&&Math.round(t.x)===Math.round(e.x)&&Math.round(t.y)===Math.round(e.y)&&Math.round(t.width)===Math.round(e.width)&&Math.round(t.height)===Math.round(e.height)?t:e)},[]),z=se.frames.filter(({bounds:e})=>e.x+e.width>=L.x&&e.x<=L.x+L.width&&e.y+e.height>=L.y&&e.y<=L.y+L.height).slice(0,100),xe=_i(z.filter(e=>!pe.has(e.ownerId)&&e.bounds.width*me>=Zu),z,L,me),Se=se.selectionBounds,Ce=Se?{x:(Se.x+Se.width/2-L.x)*me,y:(Se.y+Se.height-L.y)*me}:null,we=(0,H.useMemo)(()=>Ju(r.annotations),[r.annotations]),Te=(0,H.useMemo)(()=>{if(!Object.keys(r.annotations).length)return[];let e;try{e=new Map(Kr(r,i,a).items.map(e=>[e.ownerId,e.bounds]))}catch{e=new Map}return Object.entries(r.annotations).flatMap(([t,n])=>{if(n.revision!==m)return[];let r=n.anchor,i=r.kind===`point`?{x:r.x,y:r.y}:r.kind===`region`?{x:r.bounds.x+r.bounds.width/2,y:r.bounds.y+r.bounds.height/2}:(()=>{let t=r.nodeIds.map(t=>e.get(t)).find(Boolean);return t?{x:t.x+t.width,y:t.y}:null})();return i?[{id:t,annotation:n,point:i}]:[]})},[r,i,a,m]),Ee=(0,H.useCallback)(e=>{let t=M.current;if(t)for(let n of t.querySelectorAll(`[data-design-pin]`)){let t=Number(n.dataset.x),r=Number(n.dataset.y),i=(t-e.x)/e.width*T.current.width,a=(r-e.y)/e.height*T.current.height;n.style.left=`${i}px`,n.style.top=`${a}px`,n.hidden=i<0||a<0||i>T.current.width||a>T.current.height}},[]);(0,H.useEffect)(()=>{let e=S.current;if(!e)return;let t=new ResizeObserver(()=>{if(!e.clientWidth||!e.clientHeight)return;let t=Math.max(1,Math.round(e.clientWidth)),n=Math.max(1,Math.round(e.clientHeight));F(e=>e.width===t&&e.height===n?e:{width:t,height:n})});t.observe(e);let n=e=>e.preventDefault();return e.addEventListener(`wheel`,n,{passive:!1}),()=>{t.disconnect(),e.removeEventListener(`wheel`,n)}},[]);let B=(0,H.useCallback)(e=>{w.current=e,te(e);let n=C.current;n&&(n.setViewport(e),n.render()),re(Math.round(T.current.width/e.width*100)),Xu.set(t,{bounds:e,width:T.current.width}),Ee(e),g?.(e)},[t,Ee,g]);(0,H.useLayoutEffect)(()=>Ee(w.current),[Te,Ee]),(0,H.useEffect)(()=>{h&&C.current&&B(h)},[h,B]),(0,H.useEffect)(()=>{if(!P.width||!P.height||!S.current)return;let e=!1,r=S.current,i=T.current;return T.current=P,ie(null),Zl(r,P.width,P.height,o,()=>{e||ie(`An image could not be decoded. Its placeholder remains visible.`)}).then(a=>{if(e){a.destroy();return}let o=N.current;C.current=a,a.setStrokes(Yu(r)),a.setDocument(o.document,o.theme,o.context),a.setSelection(o.selection),a.setChanges(o.changedNodeIds);let s=w.current;if(o.externalViewport)D.current=o.document.documentId,B(o.externalViewport);else if(D.current!==o.document.documentId){D.current=o.document.documentId;let e=Xu.get(t);if(e){let t=e.width/e.bounds.width;B({...e.bounds,width:P.width/t,height:P.height/t})}else B(ed(o.document,o.theme,o.context,P.width,P.height,n,E.current))}else{let e=i.width/s.width,t=P.width/e,n=P.height/e;B({x:s.x+(s.width-t)/2,y:s.y+(s.height-n)/2,width:t,height:n})}}).catch(()=>{e||(C.current?.destroy(),C.current=null,ie(`Canvas could not load. Try reopening this design.`))}),()=>{e=!0,C.current?.destroy(),C.current=null,r.replaceChildren()}},[P.width,P.height,o,t]),(0,H.useEffect)(()=>{let e=C.current;if(e)try{e.setDocument(r,i,a),D.current!==r.documentId&&(D.current=r.documentId,B(ed(r,i,a,T.current.width,T.current.height,n,E.current))),e.render(),ie(null)}catch{ie(`This design has layout problems. Check diagnostics.`)}},[r,i,a,B,n]),(0,H.useEffect)(()=>{let e=C.current;e&&(e.setSelection(s),e.render())},[s]),(0,H.useEffect)(()=>{let e=C.current;e&&(e.setChanges(c),e.render())},[c]),(0,H.useEffect)(()=>{let e=S.current;if(!e)return;let t=new MutationObserver(()=>{let t=C.current;t&&(t.setStrokes(Yu(e)),t.render())});return t.observe(window.document.documentElement,{attributes:!0,attributeFilter:[`class`,`data-theme`,`style`]}),()=>t.disconnect()},[]);let De=(0,H.useCallback)((e,t,n)=>{let r=w.current,i=T.current.width,a=T.current.height,o=Math.max(.05,Math.min(8,i/r.width*e)),s=i/o,c=a/o,l=r.x+t/i*r.width,u=r.y+n/a*r.height;B({x:l-t/i*s,y:u-n/a*c,width:s,height:c})},[B]),Oe=t=>{let n=t.currentTarget.getBoundingClientRect();if(t.ctrlKey||t.metaKey||e?.scrollWheelZoom){let r=e?.invertZoom?1:-1;De(Math.exp(r*t.deltaY*.006),t.clientX-n.left,t.clientY-n.top)}else{let e=w.current;B({...e,x:e.x+t.deltaX*e.width/T.current.width,y:e.y+t.deltaY*e.height/T.current.height})}},ke=e=>{if(e.button===0||e.button===1){if(e.currentTarget.focus({preventScroll:!0}),k.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),u===`region`&&e.button===0){let t=e.currentTarget.getBoundingClientRect();A.current={x:e.clientX-t.left,y:e.clientY-t.top},e.currentTarget.setPointerCapture(e.pointerId);return}if(u&&e.button===0){O.current={x:e.clientX,y:e.clientY,moved:!1},e.currentTarget.setPointerCapture(e.pointerId);return}O.current=k.current.size===1?{x:e.clientX,y:e.clientY,moved:!1}:null,e.currentTarget.setPointerCapture(e.pointerId)}},Ae=e=>{if(e.pointerType!==`touch`&&e.buttons===0){ae();return}if(A.current){let t=j.current,n=e.currentTarget.getBoundingClientRect(),r={x:e.clientX-n.left,y:e.clientY-n.top};t&&(t.hidden=!1,t.style.left=`${Math.min(A.current.x,r.x)}px`,t.style.top=`${Math.min(A.current.y,r.y)}px`,t.style.width=`${Math.abs(r.x-A.current.x)}px`,t.style.height=`${Math.abs(r.y-A.current.y)}px`);return}if(u){let t=O.current;t&&Math.abs(e.clientX-t.x)+Math.abs(e.clientY-t.y)>4&&(t.moved=!0);return}let t=k.current;if(!t.has(e.pointerId))return;let n=[...t.values()];if(t.set(e.pointerId,{x:e.clientX,y:e.clientY}),t.size===2){let r=[...t.values()],i=n[0],a=n[1],o=r[0],s=r[1];if(!i||!a||!o||!s)return;let c=Math.hypot(i.x-a.x,i.y-a.y),l=Math.hypot(o.x-s.x,o.y-s.y);if(c<1||l<1)return;let u=e.currentTarget.getBoundingClientRect(),d={x:(i.x+a.x)/2,y:(i.y+a.y)/2},f={x:(o.x+s.x)/2,y:(o.y+s.y)/2},p=w.current,m=T.current.width,h=T.current.height,g=Math.max(.05,Math.min(8,m/p.width*l/c)),_=m/g,v=h/g,y=p.x+(d.x-u.left)/m*p.width,b=p.y+(d.y-u.top)/h*p.height;B({x:y-(f.x-u.left)/m*_,y:b-(f.y-u.top)/h*v,width:_,height:v});return}let r=O.current;if(!r)return;let i=e.clientX-r.x,a=e.clientY-r.y;if(Math.abs(i)+Math.abs(a)>2&&(r.moved=!0),r.moved){let e=w.current;B({...e,x:e.x-i*e.width/T.current.width,y:e.y-a*e.height/T.current.height})}r.x=e.clientX,r.y=e.clientY},je=e=>{if(A.current){let t=A.current;A.current=null,k.current.delete(e.pointerId),j.current&&(j.current.hidden=!0);let n=e.currentTarget.getBoundingClientRect(),r={x:e.clientX-n.left,y:e.clientY-n.top};if(Math.abs(r.x-t.x)<4||Math.abs(r.y-t.y)<4)return;let i=w.current,a=i.x+Math.min(t.x,r.x)/n.width*i.width,o=i.y+Math.min(t.y,r.y)/n.height*i.height;f?.({kind:`region`,bounds:{x:a,y:o,width:Math.abs(r.x-t.x)/n.width*i.width,height:Math.abs(r.y-t.y)/n.height*i.height}});return}let t=k.current.size>1;if(k.current.delete(e.pointerId),t){let e=k.current.values().next().value;O.current=e?{...e,moved:!0}:null;return}let n=O.current;if(O.current=null,!n||n.moved||I||e.button===1)return;let r=e.currentTarget.getBoundingClientRect(),i=w.current,a=i.x+(e.clientX-r.left)/r.width*i.width,o=i.y+(e.clientY-r.top)/r.height*i.height,s=C.current?.hitTest(a,o);if(u===`pin`){f?.({kind:`point`,x:a,y:o});return}if(u===`nodes`){s&&f?.({kind:`nodes`,nodeIds:[s]});return}l(s?[s]:[])};return(0,G.jsxs)(`div`,{className:`design-canvas-wrap`,children:[(0,G.jsx)(`div`,{className:`design-canvas-tools`,role:`toolbar`,"aria-label":`Canvas controls`,children:[{label:`Select`,icon:Xe,active:!I&&!u,run:()=>{ee(!1),d?.(null)}},{label:`Pan`,icon:Le,active:I&&!u,run:()=>{ee(!0),d?.(null)}},...d?[{label:`Pin`,mode:`pin`,icon:We},{label:`Region`,mode:`region`,icon:et},{label:`Node`,mode:`nodes`,icon:Ne}].map(({label:e,mode:t,icon:n})=>({label:e,icon:n,active:u===t,run:()=>{ee(!1),d(t)}})):[],{label:`Fit`,icon:$e,active:void 0,run:()=>B(ed(r,i,a,T.current.width,T.current.height,n,E.current))}].map(({label:e,icon:t,active:n,run:r})=>(0,G.jsxs)(H.Fragment,{children:[e===`Fit`?(0,G.jsx)(`span`,{className:`design-tool-separator`,"aria-hidden":`true`}):null,(0,G.jsxs)(jt,{children:[(0,G.jsx)(Ot,{render:(0,G.jsx)(W,{size:`icon-sm`,variant:`ghost`,"aria-label":e,"aria-pressed":n,className:`aria-pressed:bg-accent`,onClick:r}),children:(0,G.jsx)(t,{"aria-hidden":`true`})}),(0,G.jsx)(kt,{children:e})]})]},e))}),(0,G.jsxs)(`div`,{className:`design-canvas-zoom`,"aria-label":`Canvas zoom`,children:[(0,G.jsxs)(jt,{children:[(0,G.jsx)(Ot,{render:(0,G.jsx)(W,{size:`icon-sm`,variant:`ghost`,"aria-label":`Zoom out`,onClick:()=>De(1/1.5,T.current.width/2,T.current.height/2)}),children:(0,G.jsx)(Je,{"aria-hidden":`true`})}),(0,G.jsx)(kt,{children:`Zoom out`})]}),(0,G.jsxs)(`output`,{"aria-label":`Zoom level`,children:[ne,`%`]}),(0,G.jsxs)(jt,{children:[(0,G.jsx)(Ot,{render:(0,G.jsx)(W,{size:`icon-sm`,variant:`ghost`,"aria-label":`Zoom in`,onClick:()=>De(1.5,T.current.width/2,T.current.height/2)}),children:(0,G.jsx)(Ze,{"aria-hidden":`true`})}),(0,G.jsx)(kt,{children:`Zoom in`})]})]}),(0,G.jsxs)(`div`,{className:`design-frame-labels`,children:[y?z.map(e=>(0,G.jsx)(`div`,{className:`design-frame-mark`,style:{left:(e.bounds.x-L.x)*me,top:(e.bounds.y-L.y)*me,width:e.bounds.width*me,height:e.bounds.height*me},children:typeof y==`function`?y({name:e.node.name,width:e.bounds.width,height:e.bounds.height}):y},`mark:${e.key}`)):null,z.map(e=>(0,G.jsx)(Qu,{name:e.node.name,x:(e.bounds.x-L.x)*me,y:(e.bounds.y-L.y)*me,width:e.bounds.width*me,hidden:pe.has(e.ownerId)||xe.has(e.key)},e.key))]}),Ce&&Se&&Ce.x>=0&&Ce.x<=P.width&&Ce.y>=0&&Ce.y<=P.height?(0,G.jsxs)(`output`,{className:`design-selection-badge`,"aria-label":`Selection dimensions`,style:{left:Ce.x,top:Ce.y},children:[Math.round(Se.width),` × `,Math.round(Se.height)]}):null,v&&le&&ge?(0,G.jsx)($u,{frame:_e,screen:ge,canvas:P,avoid:_&&Se?ve:null,decoration:fe?void 0:v.decoration,callout:fe?void 0:v.callout?.({nodeId:le.nodeId,name:le.name})},le.nodeId):null,de&&P.width&&P.height?(0,G.jsx)(Fu,{document:r,bounds:de,viewport:L,canvas:P,batch:b??null,agents:x,cursorSize:e?.agentCursorSize,cursorLabel:e?.agentCursorLabel,animations:e?.animations,onReveal:e=>B(Cu(e,w.current,T.current))}):null,_&&Se&&P.width&&P.height?_({screen:{x:(Se.x-L.x)*me,y:(Se.y-L.y)*me,width:Se.width*me,height:Se.height*me},world:Se,canvas:P,avoid:ge,onPlaced:be}):null,(0,G.jsx)(`div`,{ref:S,className:`design-canvas-surface ${I?`design-canvas-pan`:``}`,role:`application`,"aria-label":u?`Design canvas. ${u===`region`?`Drag a region`:`Click to place an annotation`}; arrow keys move the view and Enter anchors the selection or view center.`:`Design canvas. Drag to pan, ${e?.scrollWheelZoom?`scroll or pinch`:`pinch or Control and wheel`} to zoom, click to select.`,tabIndex:0,onWheel:Oe,onPointerDown:ke,onPointerMove:Ae,onPointerUp:je,onPointerCancel:ae,onLostPointerCapture:e=>{k.current.has(e.pointerId)&&ae()},onBlur:ae,onKeyDown:e=>{if(e.key===`Enter`&&u){let t=w.current,n=t.x+t.width/2,r=t.y+t.height/2;if(u===`pin`)f?.({kind:`point`,x:n,y:r});else if(u===`region`)f?.({kind:`region`,bounds:{x:n-t.width/8,y:r-t.height/8,width:t.width/4,height:t.height/4}});else{let e=s[0]??C.current?.hitTest(n,r);e&&f?.({kind:`nodes`,nodeIds:[e]})}e.preventDefault();return}(e.key===`+`||e.key===`=`)&&(De(1.5,T.current.width/2,T.current.height/2),e.preventDefault()),e.key===`-`&&(De(1/1.5,T.current.width/2,T.current.height/2),e.preventDefault()),e.key===`Escape`&&(ae(),d?.(null),ee(!1),l([]),e.preventDefault()),e.key===`Home`&&(B(ed(r,i,a,T.current.width,T.current.height,n,E.current)),e.preventDefault());let t=e.key===`ArrowLeft`?[-40,0]:e.key===`ArrowRight`?[40,0]:e.key===`ArrowUp`?[0,-40]:e.key===`ArrowDown`?[0,40]:null;if(t){let n=w.current;B({...n,x:n.x+t[0]*n.width/T.current.width,y:n.y+t[1]*n.height/T.current.height}),e.preventDefault()}}}),e?.showPixelGrid&&me>=4?(0,G.jsx)(`div`,{className:`design-pixel-grid`,"aria-hidden":`true`,style:{backgroundSize:`${me}px ${me}px`,backgroundPosition:`${-L.x*me}px ${-L.y*me}px`}}):null,(0,G.jsx)(`div`,{ref:M,className:`design-annotation-pins`,children:p?Te.map(({id:e,annotation:t,point:n})=>{let r=t.blocking&&t.status===`open`,i=we.get(e)??0;return(0,G.jsxs)(jt,{children:[(0,G.jsx)(Ot,{render:(0,G.jsx)(`button`,{type:`button`,"data-design-pin":!0,"data-x":n.x,"data-y":n.y,"aria-label":`Open ${r?`blocking `:``}comment ${i} by ${t.author}`,className:`design-annotation-pin${r?` design-annotation-pin-blocking`:``}${t.status===`resolved`?` design-annotation-pin-resolved`:``}`,onClick:()=>p?.(e)}),children:(0,G.jsx)(`span`,{"aria-hidden":`true`,children:r?`!`:i})}),(0,G.jsxs)(kt,{children:[(0,G.jsx)(`strong`,{children:t.author}),` `,t.body.split(`
18
+ `,1)[0]]})]},e)}):null}),(0,G.jsx)(`div`,{ref:j,className:`design-annotation-region`,hidden:!0}),R?(0,G.jsx)(`div`,{className:`design-canvas-error`,role:`alert`,children:R}):null]})}function nd(e){return e===void 0?`—`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?`${e.length} items`:`Object`}function rd(e){let t=(0,U.c)(43),{preferences:n,before:r,after:i,beforeRevision:a,afterRevision:o,viewKey:s,theme:c,beforeContext:l,beforeAssets:u,context:d,assets:f,selection:p,onSelect:m,onExit:h}=e,[g,_]=(0,H.useState)(`Before / after`),[v,y]=(0,H.useState)(50),[b,x]=(0,H.useState)(),S;t[0]!==i||t[1]!==r?(S=qr(r,i).filter(sd),t[0]=i,t[1]=r,t[2]=S):S=t[2];let C=S,w;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,G.jsx)(`strong`,{children:`Compare revisions`}),t[3]=w):w=t[3];let T;t[4]===a?T=t[5]:(T=a.slice(0,8),t[4]=a,t[5]=T);let E;t[6]===o?E=t[7]:(E=o.slice(0,8),t[6]=o,t[7]=E);let D;t[8]!==T||t[9]!==E?(D=(0,G.jsxs)(`div`,{className:`design-compare-revisions`,children:[w,(0,G.jsxs)(`span`,{className:`design-small-muted`,children:[`Before `,T,` · After `,E]})]}),t[8]=T,t[9]=E,t[10]=D):D=t[10];let O;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(O=[`Before / after`,`Overlay`,`Changes`],t[11]=O):O=t[11];let k;t[12]===g?k=t[13]:(k=(0,G.jsx)(`nav`,{"aria-label":`Compare display`,children:O.map(e=>(0,G.jsx)(`button`,{type:`button`,"aria-current":g===e?`page`:void 0,onClick:()=>_(e),children:e},e))}),t[12]=g,t[13]=k);let A;t[14]===h?A=t[15]:(A=(0,G.jsx)(W,{size:`sm`,variant:`outline`,onClick:h,children:`Exit compare`}),t[14]=h,t[15]=A);let j;t[16]!==k||t[17]!==A?(j=(0,G.jsxs)(`div`,{className:`design-compare-controls`,children:[k,A]}),t[16]=k,t[17]=A,t[18]=j):j=t[18];let M;t[19]!==D||t[20]!==j?(M=(0,G.jsxs)(`header`,{className:`design-compare-header`,children:[D,j]}),t[19]=D,t[20]=j,t[21]=M):M=t[21];let N;t[22]!==i||t[23]!==o||t[24]!==f||t[25]!==r||t[26]!==u||t[27]!==l||t[28]!==a||t[29]!==C||t[30]!==d||t[31]!==g||t[32]!==m||t[33]!==v||t[34]!==b||t[35]!==n||t[36]!==p||t[37]!==c||t[38]!==s?(N=g===`Changes`?(0,G.jsx)(`div`,{className:`design-compare-changes`,children:C.length?(0,G.jsx)(`ol`,{children:C.map(od)}):(0,G.jsx)(`p`,{children:`No content changes between these revisions.`})}):g===`Before / after`?(0,G.jsxs)(`div`,{className:`design-compare-pair`,children:[(0,G.jsxs)(`section`,{"aria-label":`Before revision ${a}`,children:[(0,G.jsxs)(`div`,{className:`design-compare-caption`,children:[`Before · `,a.slice(0,8)]}),(0,G.jsx)(td,{preferences:n,viewKey:`${s}:compare-before`,document:r,theme:c,context:l,assets:u,selection:[],changedNodeIds:[],onSelect:ad})]}),(0,G.jsxs)(`section`,{"aria-label":`After revision ${o}`,children:[(0,G.jsxs)(`div`,{className:`design-compare-caption`,children:[`After · `,o.slice(0,8)]}),(0,G.jsx)(td,{preferences:n,viewKey:`${s}:compare-after`,document:i,theme:c,context:d,assets:f,selection:p,changedNodeIds:[],onSelect:m})]})]}):(0,G.jsxs)(`div`,{className:`design-compare-overlay`,children:[(0,G.jsxs)(`label`,{className:`design-compare-opacity`,children:[`After opacity`,` `,(0,G.jsx)(`input`,{type:`range`,min:`0`,max:`100`,value:v,onChange:e=>y(Number(e.target.value))}),` `,v,`%`]}),(0,G.jsxs)(`div`,{className:`design-compare-overlay-stack`,children:[(0,G.jsx)(td,{preferences:n,viewKey:`${s}:compare-overlay-before`,document:r,theme:c,context:l,assets:u,selection:[],changedNodeIds:[],onSelect:id,externalViewport:b}),(0,G.jsx)(`div`,{style:{"--design-after-opacity":v/100},"aria-label":`After revision ${o}`,children:(0,G.jsx)(td,{preferences:n,viewKey:`${s}:compare-overlay-after`,document:i,theme:c,context:d,assets:f,selection:p,changedNodeIds:[],onSelect:m,onViewportChange:x})})]})]}),t[22]=i,t[23]=o,t[24]=f,t[25]=r,t[26]=u,t[27]=l,t[28]=a,t[29]=C,t[30]=d,t[31]=g,t[32]=m,t[33]=v,t[34]=b,t[35]=n,t[36]=p,t[37]=c,t[38]=s,t[39]=N):N=t[39];let P;return t[40]!==M||t[41]!==N?(P=(0,G.jsxs)(`div`,{className:`design-compare`,children:[M,N]}),t[40]=M,t[41]=N,t[42]=P):P=t[42],P}function id(){}function ad(){}function od(e){return(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`strong`,{children:e.kind}),(0,G.jsxs)(`span`,{children:[(0,G.jsx)(`code`,{children:e.path}),(0,G.jsxs)(`small`,{children:[nd(e.before),` → `,nd(e.after)]})]})]},e.path)}function sd(e){return!/^\/(annotations|reviews|acceptances)(\/|$)/.test(e.path)}function cd(e){if(e.fills?.[0]?.kind===`image`)return{label:`Image`,icon:ze};switch(e.type){case`frame`:return{label:`Frame`,icon:Fe};case`group`:return{label:`Group`,icon:Ie};case`rectangle`:return{label:`Rectangle`,icon:it};case`ellipse`:return{label:`Ellipse`,icon:Oe};case`path`:return{label:`Path`,icon:rt};case`text`:return{label:`Text`,icon:ot};case`ref`:return{label:`Component`,icon:ke}}}var ld=on,ud=an;function dd(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(In,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(ln,{forceRender:!0,className:i,"data-slot":`dialog-backdrop`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function fd(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`fixed inset-0 z-50 grid grid-rows-[1fr_auto_1fr] justify-items-center p-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(rn,{className:i,"data-slot":`dialog-viewport`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function pd(e){let t=(0,U.c)(22),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,showCloseButton:a,bottomStickOnMobile:o,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s=a===void 0||a,c=o===void 0||o,l;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,G.jsx)(dd,{}),t[6]=l):l=t[6];let u=c&&`max-sm:grid-rows-[1fr_auto] max-sm:p-0 max-sm:pt-12`,d;t[7]===u?d=t[8]:(d=V(u),t[7]=u,t[8]=d);let f=c&&`max-sm:max-w-none max-sm:rounded-none max-sm:border-x-0 max-sm:border-t max-sm:border-b-0 max-sm:opacity-[calc(1-min(var(--nested-dialogs),1))] max-sm:data-ending-style:translate-y-4 max-sm:data-starting-style:translate-y-4`,p;t[9]!==r||t[10]!==f?(p=V(Ln,`row-start-2 max-h-full max-w-lg text-popover-foreground`,f,r),t[9]=r,t[10]=f,t[11]=p):p=t[11];let m;t[12]===s?m=t[13]:(m=s&&(0,G.jsx)(nn,{"aria-label":`Close`,className:`absolute end-2 top-2`,render:(0,G.jsx)(W,{size:`icon`,variant:`ghost`}),children:(0,G.jsx)(lt,{})}),t[12]=s,t[13]=m);let h;t[14]!==n||t[15]!==i||t[16]!==p||t[17]!==m?(h=(0,G.jsxs)(sn,{className:p,"data-slot":`dialog-popup`,...i,children:[n,m]}),t[14]=n,t[15]=i,t[16]=p,t[17]=m,t[18]=h):h=t[18];let g;return t[19]!==d||t[20]!==h?(g=(0,G.jsxs)(ud,{children:[l,(0,G.jsx)(fd,{className:d,children:h})]}),t[19]=d,t[20]=h,t[21]=g):g=t[21],g}function md(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`flex flex-col gap-2 p-6 in-[[data-slot=dialog-popup]:has([data-slot=dialog-panel])]:pb-3 max-sm:pb-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(`div`,{className:i,"data-slot":`dialog-header`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function hd(e){let t=(0,U.c)(11),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,variant:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0?`default`:i,o=a==="default"&&`border-t bg-muted/72 py-4`,s=a===`bare`&&`py-4`,c;t[4]!==n||t[5]!==o||t[6]!==s?(c=V(`flex flex-col-reverse gap-2 px-6 sm:flex-row sm:justify-end sm:rounded-b-[calc(var(--radius-2xl)-1px)]`,o,s,n),t[4]=n,t[5]=o,t[6]=s,t[7]=c):c=t[7];let l;return t[8]!==r||t[9]!==c?(l=(0,G.jsx)(`div`,{className:c,"data-slot":`dialog-footer`,...r}),t[8]=r,t[9]=c,t[10]=l):l=t[10],l}function gd(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`font-heading font-semibold text-xl leading-none`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(cn,{className:i,"data-slot":`dialog-title`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function _d(e){let t=(0,U.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`text-muted-foreground text-sm`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,G.jsx)(tn,{className:i,"data-slot":`dialog-description`,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function vd(e){let t=(0,U.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,scrollFade:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i===void 0||i,o;t[4]===n?o=t[5]:(o=V(`p-6 in-[[data-slot=dialog-popup]:has([data-slot=dialog-header])]:pt-1 in-[[data-slot=dialog-popup]:has([data-slot=dialog-footer]:not(.border-t))]:pb-1`,n),t[4]=n,t[5]=o);let s;t[6]!==r||t[7]!==o?(s=(0,G.jsx)(`div`,{className:o,"data-slot":`dialog-panel`,...r}),t[6]=r,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==a||t[10]!==s?(c=(0,G.jsx)(fr,{scrollFade:a,children:s}),t[9]=a,t[10]=s,t[11]=c):c=t[11],c}function yd(e){let t=(0,U.c)(9),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=V(`relative inline-flex size-4.5 shrink-0 items-center justify-center rounded-[.25rem] border border-input bg-background not-dark:bg-clip-padding shadow-xs/5 outline-none ring-ring transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[3px] not-data-disabled:not-data-checked:not-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-offset-background aria-invalid:border-destructive/36 focus-visible:aria-invalid:border-destructive/64 focus-visible:aria-invalid:ring-destructive/48 data-disabled:opacity-64 sm:size-4 dark:not-data-checked:bg-input/32 dark:aria-invalid:ring-destructive/24 dark:not-data-disabled:not-data-checked:not-aria-invalid:before:shadow-[0_-1px_--theme(--color-white/6%)] [[data-disabled],[data-checked],[aria-invalid]]:shadow-none`,n),t[3]=n,t[4]=i);let a;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,G.jsx)(Pt,{className:`-inset-px absolute flex items-center justify-center rounded-[.25rem] text-primary-foreground data-unchecked:hidden data-checked:bg-primary data-indeterminate:text-foreground`,"data-slot":`checkbox-indicator`,render:bd}),t[5]=a):a=t[5];let o;return t[6]!==r||t[7]!==i?(o=(0,G.jsx)(Nt,{className:i,"data-slot":`checkbox`,...r,children:a}),t[6]=r,t[7]=i,t[8]=o):o=t[8],o}function bd(e,t){return(0,G.jsx)(`span`,{...e,children:t.indeterminate?(0,G.jsx)(`svg`,{className:`size-3.5 sm:size-3`,fill:`none`,height:`24`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`3`,viewBox:`0 0 24 24`,width:`24`,xmlns:`http://www.w3.org/2000/svg`,children:(0,G.jsx)(`path`,{d:`M5.252 12h13.496`})}):(0,G.jsx)(`svg`,{className:`size-3.5 sm:size-3`,fill:`none`,height:`24`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`3`,viewBox:`0 0 24 24`,width:`24`,xmlns:`http://www.w3.org/2000/svg`,children:(0,G.jsx)(`path`,{d:`M5.252 12.7 10.2 18.63 18.748 5.37`})})})}function xd(e){let t=(0,U.c)(9),n,r,a,o;if(t[0]!==e){let{className:s,render:c,...l}=e;n=c;let u={className:V(`inline-flex items-center gap-2 text-base/4.5 sm:text-sm/4 font-medium text-foreground`,s),"data-slot":`label`};o=L,r=`label`,a=i(u,l),t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=o}else n=t[1],r=t[2],a=t[3],o=t[4];let s;return t[5]!==n||t[6]!==r||t[7]!==a?(s={defaultTagName:r,props:a,render:n},t[5]=n,t[6]=r,t[7]=a,t[8]=s):s=t[8],o(s)}function Sd(e){let t=(0,U.c)(16),n=Yn(),r=$n(),i=(0,H.useRef)(null),[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)(null),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=[],t[0]=d):d=t[0];let[f,p]=(0,H.useState)(d),[m,h]=(0,H.useState)(null),g,_;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>()=>i.current?.abort(),_=[],t[1]=g,t[2]=_):(g=t[1],_=t[2]),(0,H.useEffect)(g,_);let v;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(v=()=>i.current?.abort(),t[3]=v):v=t[3];let y=v,b;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>{y(),c(null),u(null),p([]),h(null)},t[4]=b):b=t[4];let x=b,C;t[5]!==n||t[6]!==r||t[7]!==e?(C=async t=>{if(!e)return null;y();let a=new AbortController;i.current=a,o(!0),c(null),u(null),p([]),h(null);let s=[],l=null,d=k(()=>new Promise(e=>{a.signal.aborted?e():a.signal.addEventListener(`abort`,()=>e(),{once:!0})})),f=null;try{await r(S(w(n.transport.transfer(e,t),e=>ue(()=>{a.signal.aborted||(e.kind===`progress`&&c(e),e.kind===`chunk`&&s.push(Uint8Array.from(atob(e.base64),Cd)),e.kind===`complete`&&(l=e))})),d))}catch(e){f={cause:e}}if(i.current!==a)return null;let m=a.signal.aborted;return i.current===a&&(i.current=null),a.abort(),o(!1),m?null:f?(h(f.cause instanceof Error?f.cause.message:String(f.cause)),null):l?(u(l),p(s),l):(h(`Transfer ended before a result was received.`),null)},t[5]=n,t[6]=r,t[7]=e,t[8]=C):C=t[8];let T=C,E;return t[9]!==a||t[10]!==f||t[11]!==m||t[12]!==s||t[13]!==l||t[14]!==T?(E={busy:a,progress:s,result:l,bytes:f,error:m,run:T,cancel:y,reset:x},t[9]=a,t[10]=f,t[11]=m,t[12]=s,t[13]=l,t[14]=T,t[15]=E):E=t[15],E}function Cd(e){return e.charCodeAt(0)}var wd={svg:`.svg,image/svg+xml`,png:`.png,image/png`,jpeg:`.jpg,.jpeg,image/jpeg`,webp:`.webp,image/webp`,"figma-rest":``,"figma-plugin":`.json,application/json`},Td=[[`svg`,`SVG`],[`png`,`PNG`],[`jpeg`,`JPEG`],[`webp`,`WebP`],[`figma-rest`,`Figma URL`],[`figma-plugin`,`Figma plugin bundle`]];function Ed(e){let t=(0,U.c)(18),{id:n,value:r,onChange:i,options:a,disabled:o}=e,s;t[0]===a?s=t[1]:(s=a.map(Od),t[0]=a,t[1]=s);let c;t[2]===i?c=t[3]:(c=e=>{e!==null&&i(e)},t[2]=i,t[3]=c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,G.jsx)(ai,{}),t[4]=l):l=t[4];let u;t[5]===n?u=t[6]:(u=(0,G.jsx)(ii,{id:n,children:l}),t[5]=n,t[6]=u);let d;t[7]===a?d=t[8]:(d=a.map(Dd),t[7]=a,t[8]=d);let f;t[9]===d?f=t[10]:(f=(0,G.jsx)(oi,{children:d}),t[9]=d,t[10]=f);let p;return t[11]!==o||t[12]!==s||t[13]!==c||t[14]!==u||t[15]!==f||t[16]!==r?(p=(0,G.jsxs)(ni,{modal:!1,value:r,disabled:o,items:s,onValueChange:c,children:[u,f]}),t[11]=o,t[12]=s,t[13]=c,t[14]=u,t[15]=f,t[16]=r,t[17]=p):p=t[17],p}function Dd(e){let[t,n,r]=e;return(0,G.jsx)(si,{value:t,disabled:r,children:n},String(t))}function Od(e){let[t,n]=e;return{value:t,label:n}}async function kd(e){let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=8192)n+=String.fromCharCode(...t.subarray(e,e+8192));return btoa(n)}function Ad(e,t,n){let r=new Blob(e.map(e=>new Uint8Array(e)),{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,a.click(),setTimeout(()=>URL.revokeObjectURL(i),3e4)}function jd({open:e,mode:t,onModeChange:n,onOpenChange:r,target:i,documentPath:a,revision:o,document:s,selection:c,theme:l,onImportComplete:u,onOpenImported:d}){let f=Sd(i),[p,m]=(0,H.useState)(`svg`),[h,g]=(0,H.useState)(`png`),[_,v]=(0,H.useState)(null),[y,b]=(0,H.useState)(``),[x,S]=(0,H.useState)(``),[C,w]=(0,H.useState)(``),[T,E]=(0,H.useState)(!1),[D,O]=(0,H.useState)(`selection`),[k,A]=(0,H.useState)(1),[j,M]=(0,H.useState)(`transparent`),[N,P]=(0,H.useState)(null),[F,I]=(0,H.useState)(!1),ee=(0,H.useRef)(0),L=(0,H.useRef)(null),te=f.busy&&f.progress?.stage===`Saving document`,ne=s?Object.entries(s.nodes).filter(([,e])=>e.type===`frame`):[],re=i?{projectId:i.projectId,...i.threadId?{threadId:i.threadId}:{}}:null,R=e=>{if(!e){if(te)return;ee.current+=1,f.reset(),I(!1),S(``),v(null),b(``),w(``),P(null)}r(e)},ie=async()=>{if(!re)return;if(P(null),t===`import`){let e=C.trim();if(!e.toLowerCase().endsWith(`.p4design`)){P(`Choose a new .p4design destination path.`);return}if(p===`figma-rest`?!y.trim():!_){P(p===`figma-rest`?`Enter a Figma file URL.`:`Choose a file.`);return}I(!0);let t=++ee.current,n;try{_&&p!==`figma-rest`&&(n=await kd(_))}catch{P(`The selected file could not be read. Choose it again.`),I(!1);return}if(ee.current!==t)return;I(!1),await f.run({kind:`import`,target:re,documentPath:e,format:p,sourceName:_?.name??y.trim(),...n?{payload:n}:{},...p===`figma-rest`?{url:y.trim(),...x.trim()?{token:x.trim()}:{}}:{},allowMissingAssets:T})&&u();return}let e=D===`selection`?c.length?[...c]:ne[0]?[ne[0][0]]:[]:[D];if(!s||!a||!o||!e.length){P(`Select a node or frame in a ready design to export.`);return}await f.run({kind:`export`,target:re,documentPath:a,expectedContentHash:o,nodeIds:e,format:h,scale:k,background:j,theme:l})};return(0,G.jsx)(ld,{open:e,onOpenChange:R,children:(0,G.jsxs)(pd,{className:`design-transfer-dialog max-w-lg`,showCloseButton:!te,children:[(0,G.jsxs)(md,{children:[(0,G.jsx)(gd,{children:`Design transfer`}),(0,G.jsx)(_d,{children:`Import a design or export selected canvas content.`})]}),(0,G.jsxs)(vd,{className:`design-transfer-panel`,children:[(0,G.jsx)(`div`,{className:`design-transfer-tabs`,role:`tablist`,"aria-label":`Transfer direction`,children:[`import`,`export`].map(e=>(0,G.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":t===e,disabled:f.busy||F,onClick:()=>{n(e),f.reset(),P(null)},children:e===`import`?`Import`:`Export`},e))}),t===`import`?(0,G.jsxs)(`div`,{className:`design-transfer-fields`,children:[(0,G.jsx)(xd,{htmlFor:`design-import-format`,children:`Source format`}),(0,G.jsx)(Ed,{id:`design-import-format`,value:p,disabled:f.busy||F,options:Td,onChange:e=>{m(e),v(null),f.reset()}}),p===`figma-rest`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(xd,{htmlFor:`design-figma-url`,children:`Figma file URL`}),(0,G.jsx)(Dn,{id:`design-figma-url`,type:`url`,value:y,onChange:e=>b(e.target.value)}),(0,G.jsx)(xd,{htmlFor:`design-figma-token`,children:`Figma token`}),(0,G.jsx)(Dn,{id:`design-figma-token`,type:`password`,value:x,onChange:e=>S(e.target.value),placeholder:`Leave blank to use stored token`,autoComplete:`off`})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(xd,{htmlFor:`design-import-file`,children:`Source file`}),(0,G.jsxs)(`div`,{className:`design-transfer-file`,children:[(0,G.jsx)(W,{id:`design-import-file`,size:`sm`,variant:`outline`,disabled:f.busy||F,onClick:()=>L.current?.click(),children:`Choose file`}),(0,G.jsx)(`span`,{className:`design-truncate design-small-muted`,"aria-live":`polite`,children:_?_.name:`No file chosen`}),(0,G.jsx)(`input`,{ref:L,type:`file`,hidden:!0,accept:wd[p],onChange:e=>{let t=e.target.files?.[0]??null;e.target.value=``,v(t),t&&!C.trim()&&w(`${t.name.replace(/\.[^.]+$/,``)}.p4design`)}})]}),p===`figma-plugin`?(0,G.jsx)(`p`,{className:`design-transfer-hint`,children:`Choose the JSON bundle exported by the Figma plugin.`}):null]}),(0,G.jsx)(xd,{htmlFor:`design-import-destination`,children:`New design path`}),(0,G.jsx)(Dn,{id:`design-import-destination`,value:C,onChange:e=>w(e.target.value),placeholder:`home.p4design`}),(0,G.jsxs)(`label`,{className:`design-transfer-checkbox`,children:[(0,G.jsx)(yd,{checked:T,onCheckedChange:e=>E(e===!0)}),`Import with placeholders if assets fail`]})]}):(0,G.jsxs)(`div`,{className:`design-transfer-fields`,children:[!s||!o?(0,G.jsx)(`p`,{className:`design-transfer-hint`,children:`Open a ready design to export.`}):null,(0,G.jsx)(xd,{htmlFor:`design-export-scope`,children:`Export content`}),(0,G.jsx)(Ed,{id:`design-export-scope`,value:!c.length&&D===`selection`?ne[0]?.[0]??D:D,onChange:O,options:[[`selection`,`Selection (${c.length})`,!c.length],...ne.map(([e,t])=>[e,`Frame: ${t.name||e.slice(0,8)}`])]}),(0,G.jsx)(xd,{htmlFor:`design-export-format`,children:`Format`}),(0,G.jsx)(Ed,{id:`design-export-format`,value:h,onChange:g,options:[[`png`,`PNG`],[`svg`,`SVG`],[`pdf`,`PDF`]]}),(0,G.jsx)(xd,{htmlFor:`design-export-scale`,children:`Scale`}),(0,G.jsx)(Ed,{id:`design-export-scale`,value:k,onChange:A,options:[[.5,`0.5x`],[1,`1x`],[2,`2x`],[4,`4x`]]}),(0,G.jsx)(xd,{htmlFor:`design-export-background`,children:`Background`}),(0,G.jsx)(Ed,{id:`design-export-background`,value:j,onChange:M,options:[[`transparent`,`Transparent`],[`#FFFFFF`,`White`]]})]}),F?(0,G.jsx)(`p`,{role:`status`,children:`Reading source file…`}):null,f.progress&&!f.result&&!f.error&&!N?(0,G.jsxs)(`div`,{className:`design-transfer-progress`,role:`status`,children:[(0,G.jsx)(`span`,{children:te?`Finishing save`:f.progress.stage}),(0,G.jsx)(`progress`,{value:f.progress.total>0?f.progress.completed:void 0,max:f.progress.total||void 0}),f.progress.total>0?(0,G.jsxs)(`small`,{children:[f.progress.completed,` / `,f.progress.total]}):null]}):null,N||f.error?(0,G.jsx)(`p`,{className:`design-transfer-error`,role:`alert`,children:N??f.error}):null,f.result?(0,G.jsxs)(`div`,{className:`design-transfer-result`,role:`status`,children:[(0,G.jsx)(`strong`,{children:t===`import`?`Import complete`:`Export ready`}),(0,G.jsxs)(`span`,{children:[`Source: `,f.result.provenance]}),f.result.unsupported.length?(0,G.jsxs)(`span`,{children:[`Unsupported: `,f.result.unsupported.join(`, `)]}):null,f.result.failedAssets.length?(0,G.jsxs)(`span`,{children:[`Failed assets: `,f.result.failedAssets.join(`, `)]}):null,f.result.diagnostics.length?(0,G.jsx)(`ul`,{children:[...new Set(f.result.diagnostics.map(e=>e.message))].map(e=>(0,G.jsx)(`li`,{children:e},e))}):null,t===`import`?(0,G.jsx)(W,{size:`sm`,variant:`outline`,onClick:()=>{d(f.result.documentPath),R(!1)},children:`Open design`}):f.result.filename&&f.result.mimeType&&f.bytes.length?(0,G.jsxs)(W,{size:`sm`,variant:`outline`,onClick:()=>Ad(f.bytes,f.result.filename,f.result.mimeType),children:[`Download `,f.result.filename]}):null]}):null]}),(0,G.jsxs)(hd,{children:[(0,G.jsx)(W,{variant:`outline`,disabled:te,onClick:()=>R(!1),children:te?`Finishing save`:f.busy||F?`Cancel`:`Close`}),(0,G.jsx)(W,{disabled:!i||f.busy||F||t===`export`&&(!s||!o||!c.length&&!ne.length),onClick:()=>void ie(),children:f.error||N?`Retry`:t===`import`?`Import`:`Export`})]})]})})}var Md=e=>`${e}T00:00:00.000Z`;function Nd(e,t,n){let r=e.slice(0,10);return`${t===`open`&&r<n?`Overdue`:`Due`} ${r}`}var Pd=e=>{Promise.resolve().then(e).catch(()=>{})};function Fd(e){let t=(0,U.c)(49),{anchor:n,onSubmit:r,onCancel:i,busy:a}=e,o=a!==void 0&&a,[s,c]=(0,H.useState)(``),[l,u]=(0,H.useState)(``),[d,f]=(0,H.useState)(``),[p,m]=(0,H.useState)(``),[h,g]=(0,H.useState)(!1),_=n.kind===`nodes`?`${n.nodeIds.length} selected ${n.nodeIds.length===1?`node`:`nodes`}`:n.kind===`region`?`Canvas region`:`Canvas pin`,v;t[0]!==n||t[1]!==l||t[2]!==h||t[3]!==s||t[4]!==o||t[5]!==p||t[6]!==d||t[7]!==r?(v=e=>{e.preventDefault(),s.trim()&&!o&&Pd(()=>r({anchor:n,body:s.trim(),blocking:h,labels:d.split(`,`).map(Id).filter(Boolean),...l.trim()?{assignee:l.trim()}:{},...p?{dueAt:Md(p)}:{}}))},t[0]=n,t[1]=l,t[2]=h,t[3]=s,t[4]=o,t[5]=p,t[6]=d,t[7]=r,t[8]=v):v=t[8];let y;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,G.jsx)(`strong`,{children:`New comment`}),t[9]=y):y=t[9];let b;t[10]===_?b=t[11]:(b=(0,G.jsxs)(`div`,{className:`design-editor-heading`,children:[y,(0,G.jsxs)(`span`,{className:`design-small-muted`,children:[`Anchored to `,_,` in this revision`]})]}),t[10]=_,t[11]=b);let x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>c(e.target.value),t[12]=x):x=t[12];let S;t[13]===s?S=t[14]:(S=(0,G.jsxs)(`label`,{children:[`Comment`,(0,G.jsx)(`textarea`,{value:s,onChange:x,rows:3,required:!0,placeholder:`What should be reviewed?`})]}),t[13]=s,t[14]=S);let C;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>u(e.target.value),t[15]=C):C=t[15];let w;t[16]===l?w=t[17]:(w=(0,G.jsxs)(`label`,{children:[`Assignee`,(0,G.jsx)(`input`,{value:l,onChange:C})]}),t[16]=l,t[17]=w);let T;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>m(e.target.value),t[18]=T):T=t[18];let E;t[19]===p?E=t[20]:(E=(0,G.jsxs)(`label`,{children:[`Due`,(0,G.jsx)(`input`,{type:`date`,value:p,onChange:T})]}),t[19]=p,t[20]=E);let D;t[21]!==E||t[22]!==w?(D=(0,G.jsxs)(`div`,{className:`design-editor-fields`,children:[w,E]}),t[21]=E,t[22]=w,t[23]=D):D=t[23];let O;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,G.jsx)(`span`,{className:`design-small-muted`,children:`(comma separated)`}),t[24]=O):O=t[24];let k;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(k=e=>f(e.target.value),t[25]=k):k=t[25];let A;t[26]===d?A=t[27]:(A=(0,G.jsxs)(`label`,{children:[`Labels `,O,(0,G.jsx)(`input`,{value:d,onChange:k})]}),t[26]=d,t[27]=A);let j;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>g(e.target.checked),t[28]=j):j=t[28];let M;t[29]===h?M=t[30]:(M=(0,G.jsxs)(`label`,{className:`design-editor-checkbox`,children:[(0,G.jsx)(`input`,{type:`checkbox`,checked:h,onChange:j}),`Mark as blocking`]}),t[29]=h,t[30]=M);let N;t[31]===i?N=t[32]:(N=(0,G.jsx)(W,{type:`button`,size:`sm`,variant:`ghost`,onClick:i,children:`Cancel`}),t[31]=i,t[32]=N);let P;t[33]!==s||t[34]!==o?(P=o||!s.trim(),t[33]=s,t[34]=o,t[35]=P):P=t[35];let F;t[36]===P?F=t[37]:(F=(0,G.jsx)(W,{type:`submit`,size:`sm`,disabled:P,children:`Post comment`}),t[36]=P,t[37]=F);let I;t[38]!==N||t[39]!==F?(I=(0,G.jsxs)(`div`,{className:`design-editor-actions`,children:[N,F]}),t[38]=N,t[39]=F,t[40]=I):I=t[40];let ee;return t[41]!==D||t[42]!==A||t[43]!==M||t[44]!==v||t[45]!==I||t[46]!==b||t[47]!==S?(ee=(0,G.jsxs)(`form`,{className:`design-annotation-editor`,onSubmit:v,children:[b,S,D,A,M,I]}),t[41]=D,t[42]=A,t[43]=M,t[44]=v,t[45]=I,t[46]=b,t[47]=S,t[48]=ee):ee=t[48],ee}function Id(e){return e.trim()}function Ld(e){let t=(0,U.c)(17),{document:n,currentRevision:r,actions:i,busy:a,focusedId:o}=e,s=a!==void 0&&a,[c,l]=(0,H.useState)(null),[u,d]=(0,H.useState)(``),f=Object.entries(n.annotations).sort(Bd),p;t[0]===n.annotations?p=t[1]:(p=Ju(n.annotations),t[0]=n.annotations,t[1]=p);let m=p,h;t[2]===o?h=t[3]:(h=()=>{o&&globalThis.document.getElementById(`design-comment-${o}`)?.scrollIntoView({block:`nearest`})},t[2]=o,t[3]=h);let g;if(t[4]!==n||t[5]!==o?(g=[o,n],t[4]=n,t[5]=o,t[6]=g):g=t[6],(0,H.useEffect)(h,g),!f.length){let e;return t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,G.jsx)(`div`,{className:`design-notice`,children:(0,G.jsx)(`strong`,{children:`No comments`})}),t[7]=e):e=t[7],e}let _;t[8]!==i||t[9]!==s||t[10]!==r||t[11]!==m||t[12]!==u||t[13]!==c?(_=e=>{let[t,n]=e;return(0,G.jsxs)(`article`,{id:`design-comment-${t}`,className:`design-comment`,children:[(0,G.jsxs)(`div`,{className:`design-comment-heading`,children:[(0,G.jsx)(`span`,{className:`design-comment-number${n.blocking&&n.status===`open`?` design-comment-number-blocking`:``}`,"aria-label":`Comment ${m.get(t)??``}`,children:m.get(t)}),(0,G.jsx)(`strong`,{children:n.author}),(0,G.jsx)(`span`,{className:`design-small-muted`,children:n.status===`open`?`Open`:`Resolved`})]}),(0,G.jsx)(`p`,{children:n.body}),(0,G.jsxs)(`div`,{className:`design-comment-meta`,children:[n.blocking&&n.status===`open`?(0,G.jsx)(dr,{variant:`warning`,children:`Blocking`}):null,(0,G.jsx)(`span`,{children:n.anchor.kind===`nodes`?`${n.anchor.nodeIds.length} ${n.anchor.nodeIds.length===1?`layer`:`layers`}`:n.anchor.kind===`region`?`Region`:`Pin`}),n.revision===r?null:(0,G.jsxs)(`span`,{children:[`Revision `,n.revision.slice(0,8)]}),n.assignee?(0,G.jsxs)(`span`,{children:[`Assigned to `,n.assignee]}):null,n.dueAt?(0,G.jsx)(`span`,{children:Nd(n.dueAt,n.status,new Date().toISOString().slice(0,10))}):null,n.labels.map(zd)]}),n.replies.map(Rd),i?(0,G.jsxs)(`div`,{className:`design-comment-actions`,children:[(0,G.jsx)(W,{size:`sm`,variant:`ghost`,disabled:s,onClick:()=>{l(t),d(``)},children:`Reply`}),(0,G.jsx)(W,{size:`sm`,variant:`ghost`,disabled:s,onClick:()=>Pd(()=>i.setResolved(t,n.status===`open`)),children:n.status===`open`?`Resolve`:`Reopen`})]}):null,c===t&&i?(0,G.jsxs)(`form`,{className:`design-reply-form`,onSubmit:e=>{e.preventDefault(),u.trim()&&!s&&Pd(async()=>{await i.reply(t,u.trim()),l(null),d(``)})},children:[(0,G.jsxs)(`label`,{children:[`Reply`,(0,G.jsx)(`textarea`,{rows:2,value:u,onChange:e=>d(e.target.value),required:!0})]}),(0,G.jsxs)(`div`,{className:`design-editor-actions`,children:[(0,G.jsx)(W,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>l(null),children:`Cancel`}),(0,G.jsx)(W,{type:`submit`,size:`sm`,disabled:s||!u.trim(),children:`Send reply`})]})]}):null]},t)},t[8]=i,t[9]=s,t[10]=r,t[11]=m,t[12]=u,t[13]=c,t[14]=_):_=t[14];let v=f.map(_),y;return t[15]===v?y=t[16]:(y=(0,G.jsx)(`div`,{className:`design-comments`,"aria-label":`Design comments`,children:v}),t[15]=v,t[16]=y),y}function Rd(e){return(0,G.jsxs)(`div`,{className:`design-reply`,children:[(0,G.jsx)(`strong`,{children:e.author}),(0,G.jsx)(`p`,{children:e.body})]},e.id)}function zd(e){return(0,G.jsx)(`span`,{className:`design-comment-label`,children:e},e)}function Bd(e,t){let[,n]=e,[,r]=t;return r.createdAt.localeCompare(n.createdAt)}function Vd(e,t){let n=structuredClone(e),r=Vr(n),i=n,a=i.nodes,o=e=>{if(e===null)return i.roots;let t=a[e];if(!t||!(`children`in t))throw Error(`Parent must be a frame or group`);return t.children},s=e=>{if(!a[e])throw Error(`Node is missing`);let t=r.parents.get(e)??null,i=t&&a[t]?.type===`ref`?Object.values(n.instances[t]?.slots??{}).find(t=>t.includes(e)):o(t);if(!i)throw Error(`Node has no tree position`);let s=i.indexOf(e);if(s<0)throw Error(`Node has no tree position`);i.splice(s,1)},c=(e,t,n)=>{let r=o(t);if(n>r.length)throw Error(`Position is outside the ordered child list`);r.splice(n,0,e)},l=(e,t,n)=>{let r=e;n===null?delete r[t]:r[t]=n};switch(t.kind){case`insert`:case`instantiate`:if(a[t.nodeId])throw Error(`Node ID already exists`);a[t.nodeId]=t.node,c(t.nodeId,t.parentId,t.index),t.kind===`instantiate`&&l(n.instances,t.nodeId,t.instance);break;case`patch`:if(!a[t.nodeId])throw Error(`Node is missing`);a[t.nodeId]=Br(a[t.nodeId],t.patch);break;case`move`:s(t.nodeId),c(t.nodeId,t.parentId,t.index);break;case`remove`:{s(t.nodeId);let e=t=>{let r=a[t];r&&`children`in r&&r.children.forEach(e);for(let r of Object.values(n.instances[t]?.slots??{}))r.forEach(e);delete a[t],l(n.instances,t,null)};e(t.nodeId);break}case`override`:{let e=n.instances[t.instanceId];if(!e)throw Error(`Instance is missing`);l(e.overrides,t.sourceNodeId,t.patch);break}case`slots`:{let e=n.instances[t.instanceId];if(!e)throw Error(`Instance is missing`);let r=e.slots[t.slotId]??[];for(let e of t.children)s(e);for(let e of r)t.children.includes(e)||i.roots.push(e);l(e.slots,t.slotId,t.children);break}case`component`:l(n.components,t.componentId,t.value);break;case`library`:l(n.imports,t.importId,t.value);break;case`token`:l(n.tokens,t.tokenId,t.value);break;case`theme`:l(n.themeAxes,t.axis,t.values);break;case`asset`:l(n.assets,t.assetId,t.value);break;case`annotation`:l(n.annotations,t.annotationId,t.value);break;case`review`:l(n.reviews,t.reviewId,t.value);break;case`acceptance`:i.acceptances??={},l(i.acceptances,t.acceptanceId,t.value)}let u=zr(Lr(n));if(u.status!==`editable`)throw Error(`Operation violates the document schema`);return u.document}var Hd=()=>({fileHash:null,contentHash:null,diagnostics:[],readOnly:!1,status:`loading`,selection:[],changedNodeIds:[],batch:null,sequence:-1}),Ud=new Set([`component`,`library`,`token`,`theme`,`asset`]);function Wd(e){let t=new Set,n=new Set(e.changedNodeIds);for(let r of e.operations){let e=`nodeId`in r?r.nodeId:`instanceId`in r?r.instanceId:null;e&&n.has(e)&&t.add(e)}if(e.operations.some(e=>Ud.has(e.kind)))for(let n of e.changedNodeIds)t.add(n);return[...t]}function Gd(e,t,n,r){if(t.kind!==`snapshot`&&t.sequence<e.sequence)return e;if(t.kind===`snapshot`){if(n===void 0)throw Error(`Snapshot payload must be decoded`);let i=zr(n);return{...e,documentPath:t.documentPath,...i.status===`editable`?{document:i.document}:{document:void 0},fileHash:t.fileHash,contentHash:t.contentHash,diagnostics:t.diagnostics,readOnly:t.readOnly,status:`ready`,sequence:t.sequence,changedNodeIds:[],batch:null,...r?{context:r}:{},selection:e.selection.filter(e=>i.status===`editable`&&!!i.document.nodes[e])}}if(t.sequence===e.sequence&&t.fileHash===e.fileHash)return e;if(e.status===`conflict`||!e.document||t.sequence!==e.sequence+1||t.previousFileHash!==e.fileHash)return{...e,status:`conflict`,readOnly:!0};try{let n=e.document;for(let e of t.operations)n=Vd(n,e);if(Rr(Lr(n))!==t.fileHash)throw Error(`Committed operation hash mismatch`);return{...e,document:n,fileHash:t.fileHash,contentHash:t.contentHash,diagnostics:t.diagnostics,sequence:t.sequence,status:`ready`,readOnly:!1,changedNodeIds:[...t.changedNodeIds],batch:t.changedNodeIds.length?{sequence:t.sequence,nodeIds:Wd(t)}:null,selection:(t.selection&&t.selection.documentPath===e.documentPath&&t.selection.revision===t.contentHash?t.selection.nodeIds:e.selection).filter(e=>!!n.nodes[e]),...r?{context:r}:{}}}catch{return{...e,status:`conflict`,readOnly:!0}}}var Kd=class extends g(`DesignSyncError`){},qd=(e,t)=>JSON.stringify([e,t]),Jd=Hd(),Yd=E(e=>({records:{},setRecord:(t,n)=>e(e=>({records:{...e.records,[t]:n}}))}));async function Xd(e){let t=Uint8Array.from(atob(e),e=>e.charCodeAt(0)),n=new Blob([t]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Response(n).text()}var Zd=A(P(h));async function Qd(e,{event:t,fetchAsset:n}){let r=t.kind===`snapshot`?await Xd(t.payload):void 0,i;if(t.dependencies){let e=Zd(await Xd(t.dependencies));i={...e.manifest?{manifest:e.manifest}:{},documents:e.documents,documentPath:e.documentPath,availableAssets:new Set(e.availableAssets)}}let a=Gd(Yd.getState().records[e]??Hd(),t,r,i);if(Yd.getState().setRecord(e,a),a.status===`conflict`)throw Error(`Design revision changed; reload the document`);let[o,s]=JSON.parse(e),c=a.context;if(!a.document||!c||!t.dependencies||!n)return;let l=new Map,u=new Map,d=[a.document,...Object.values(c.documents??{})].flatMap(e=>Object.keys(e.assets).map(t=>({document:e,assetId:t})));await Promise.all(Array.from({length:Math.min(4,d.length)},async()=>{for(;d.length;){let{document:e,assetId:t}=d.pop();try{let r=await n({projectId:o.projectId,...o.threadId?{threadId:o.threadId}:{},documentPath:s,assetId:t,sourceDocumentId:e.documentId,...a.contentHash?{expectedContentHash:a.contentHash}:{}});r?l.set(`${e.documentId}:${t}`,r):u.set(t,e.assets[t]?.path??t)}catch{u.set(t,e.assets[t]?.path??t)}}}));let f=Yd.getState().records[e];f&&f.sequence===a.sequence&&Yd.getState().setRecord(e,{...f,assets:l,diagnostics:[...f.diagnostics.filter(e=>e.code!==`asset-unavailable`),...[...u.values()].map(e=>({code:`asset-unavailable`,severity:`warning`,message:`Image ${e} could not load. Reload to retry.`}))]})}var $d=e=>pe(t=>{let[n,r]=JSON.parse(t);return e.runtime.atom(e.transport.subscribe(n,r).pipe(ie(p(`DesignCache.accept`)(function*(e){return yield*I({try:()=>Qd(t,e),catch:e=>new Kd({message:e instanceof Error?e.message:String(e)})})}))))}),ef=new WeakMap;function tf(e){let t=ef.get(e.transport);return t||(t=$d(e),ef.set(e.transport,t)),t}var nf=fe(C());function rf(e,t){let r=Yn(),i=e&&t?qd(e,t):null,a=i?tf(r)(i):nf,o=n(a),s=b(a),c=Yd(e=>i?e.records[i]??Jd:Jd),l=r.useConnected(e?.environmentId??null),u=!!(i&&!l&&c.document),d=(0,H.useMemo)(()=>u?{...c,status:`disconnected`,readOnly:!0}:c,[u,c]);return(0,H.useEffect)(()=>{if(i&&o._tag===`Failure`){let e=Yd.getState().records[i]??Hd();Yd.getState().setRecord(i,{...e,status:e.document?`conflict`:`error`,readOnly:!0})}},[i,o]),{record:d,select:(0,H.useCallback)(e=>{if(i){let t=Yd.getState().records[i]??Hd();Yd.getState().setRecord(i,{...t,selection:e})}},[i]),reload:s}}function af(e){let t=(0,U.c)(11),n=Yn(),r;t[0]!==n||t[1]!==e?(r=e?n.transport.catalog(e):null,t[0]=n,t[1]=e,t[2]=r):r=t[2];let i=Qn(r),a;t[3]===i.data?.paths?a=t[4]:(a=i.data?.paths??[],t[3]=i.data?.paths,t[4]=a);let o=i.data?.entries??null,s=i.error??void 0,c;return t[5]!==i.isPending||t[6]!==i.refresh||t[7]!==a||t[8]!==o||t[9]!==s?(c={paths:a,entries:o,loading:i.isPending,error:s,reload:i.refresh},t[5]=i.isPending,t[6]=i.refresh,t[7]=a,t[8]=o,t[9]=s,t[10]=c):c=t[10],c}var of=16,sf=6,cf=8;function lf(){let e=globalThis.crypto.getRandomValues(new Uint8Array(of));e[sf]=e[sf]&15|64,e[cf]=e[cf]&63|128;let t=d(e);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function uf(){let[e]=(0,H.useState)(()=>{try{return localStorage.getItem(`p4-design-review-author`)?.trim()||`You`}catch{return`You`}});return{author:e,hostOwned:!1}}var df=()=>null;function ff(e,t,n){let r=Yn(),i=$n(),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!1),d=uf(),f=(r.review.useReviewer??df)(),p=f===null?d.author:f.trim()||d.author;(0,H.useEffect)(()=>{o(null),u(!1)},[t]);let h=(0,H.useRef)(null);(0,H.useEffect)(()=>{if(!l){h.current=null;return}h.current===null?h.current=n.fileHash??``:n.fileHash!==h.current&&(u(!1),o(null))},[l,n.fileHash]);let g=!!((r.useCanWrite?.(e)??!0)&&e&&t&&n.document&&n.fileHash&&n.contentHash&&n.status===`ready`&&!n.readOnly),_=async a=>{if(g&&e&&t&&n.fileHash&&!s){c(!0),o(null),u(!1);try{let o=await i(r.transport.review(e,{tool:`design.apply`,documentPath:t,expectedFileHash:n.fileHash,operations:a}));if(o.status===`conflict`&&u(!0),o.status!==`committed`)throw Error(o.status===`conflict`?`The design changed. Reload before commenting.`:o.diagnostics.at(-1)?.message??`The comment could not be saved.`)}catch(e){throw o(e instanceof Error?e.message:String(e)),e}finally{c(!1)}}};return{error:a,conflict:l,busy:s,author:p,annotate:async(e,t)=>_([{operationId:m.make(lf()),kind:`annotation`,annotationId:m.make(e),value:t}]),attach:(t,n)=>{e&&r.attachment&&(r.attachment.set(e,t),n?.stay||r.navigation.returnToThread?.(e))}}}var pf=[[`Layers`,Be],[`Comments`,qe],[`Components`,Se],[`Libraries`,He],[`Tokens`,at]];function mf(e){return e?e.slice(0,8):`unavailable`}function hf(e){let t=(0,U.c)(12),{title:n,detail:r,action:i,actionLabel:a}=e,o=a===void 0?`Reload`:a,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,G.jsx)(Me,{"aria-hidden":`true`,size:24}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,G.jsx)(`strong`,{children:n}),t[1]=n,t[2]=c);let l;t[3]===r?l=t[4]:(l=r?(0,G.jsx)(`p`,{children:r}):null,t[3]=r,t[4]=l);let u;t[5]!==i||t[6]!==o?(u=i?(0,G.jsx)(W,{size:`sm`,variant:`outline`,onClick:i,children:o}):null,t[5]=i,t[6]=o,t[7]=u):u=t[7];let d;return t[8]!==c||t[9]!==l||t[10]!==u?(d=(0,G.jsxs)(`div`,{className:`design-notice`,role:`status`,children:[s,c,l,u]}),t[8]=c,t[9]=l,t[10]=u,t[11]=d):d=t[11],d}function gf(e){let t=(0,U.c)(13),{items:n,diagnostics:r}=e,i;t[0]===r?i=t[1]:(i=r.length?(0,G.jsxs)($r,{children:[(0,G.jsxs)(ei,{render:(0,G.jsx)(W,{size:`xs`,variant:`ghost`}),children:[`Details (`,r.length,`)`]}),(0,G.jsx)(ti,{className:`w-80`,children:(0,G.jsx)(`ul`,{className:`design-diagnostics-list`,children:r.map(_f)})})]}):null,t[0]=r,t[1]=i);let a=i,o;t[2]!==a||t[3]!==r.length||t[4]!==n?(o=n.length||!a?n:[{key:`diagnostics`,variant:`info`,role:`status`,icon:De,message:`${r.length} design ${r.length===1?`diagnostic`:`diagnostics`}`}],t[2]=a,t[3]=r.length,t[4]=n,t[5]=o):o=t[5];let s=o;if(!s.length)return null;let c;if(t[6]!==a||t[7]!==s){let e;t[9]===a?e=t[10]:(e=(e,t)=>(0,G.jsxs)(Xr,{variant:e.variant,role:e.role,className:`design-notice-alert`,children:[(0,G.jsx)(e.icon,{"aria-hidden":`true`}),(0,G.jsx)(Zr,{children:e.message}),e.action||t===0&&a?(0,G.jsxs)(Qr,{children:[e.action?(0,G.jsxs)(W,{size:`xs`,variant:`ghost`,onClick:e.action.run,children:[(0,G.jsx)(Qe,{"aria-hidden":`true`}),e.action.label]}):null,t===0?a:null]}):null]},e.key),t[9]=a,t[10]=e),c=s.map(e),t[6]=a,t[7]=s,t[8]=c}else c=t[8];let l;return t[11]===c?l=t[12]:(l=(0,G.jsx)(`div`,{className:`design-notices`,children:c}),t[11]=c,t[12]=l),l}function _f(e){return(0,G.jsx)(`li`,{children:e.message},`${e.code}:${e.nodeId??e.path}:${e.message}`)}var vf=`\0project`;function yf(e){let t=(0,U.c)(16),{icon:n,label:r,kind:i,className:a,onClick:o,trailing:s}=e,c=(0,H.useRef)(null),l;t[0]!==a||t[1]!==o?(l=(0,G.jsx)(`button`,{type:`button`,className:a,onClick:o}),t[0]=a,t[1]=o,t[2]=l):l=t[2];let u;t[3]===n?u=t[4]:(u=(0,G.jsx)(`span`,{className:`design-row-icon`,"aria-hidden":`true`,children:(0,G.jsx)(n,{size:14})}),t[3]=n,t[4]=u);let d;t[5]===r?d=t[6]:(d=(0,G.jsx)(`span`,{ref:c,className:`design-truncate`,children:r}),t[5]=r,t[6]=d);let f;t[7]===i?f=t[8]:(f=i?(0,G.jsxs)(`span`,{className:`sr-only`,children:[`, `,i]}):null,t[7]=i,t[8]=f);let p;return t[9]!==r||t[10]!==l||t[11]!==u||t[12]!==d||t[13]!==f||t[14]!==s?(p=(0,G.jsxs)(At,{full:r,labelRef:c,render:l,children:[u,d,f,s]}),t[9]=r,t[10]=l,t[11]=u,t[12]=d,t[13]=f,t[14]=s,t[15]=p):p=t[15],p}function bf(e){let t=(0,U.c)(35),{document:n,selection:r,select:i,query:a}=e,o=a===void 0?``:a,s;t[0]===n.roots?s=t[1]:(s=()=>new Set(n.roots),t[0]=n.roots,t[1]=s);let[c,l]=(0,H.useState)(s),[u,d]=(0,H.useState)(0),[f,p]=(0,H.useState)(400),m=(0,H.useRef)(null),h,g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>{let e=m.current;if(!e)return;let t=new ResizeObserver(()=>p(e.clientHeight));return t.observe(e),()=>t.disconnect()},g=[],t[2]=h,t[3]=g):(h=t[2],g=t[3]),(0,H.useEffect)(h,g);let _;t[4]===n.roots?_=t[5]:(_=()=>l(new Set(n.roots)),t[4]=n.roots,t[5]=_);let v;t[6]===n.documentId?v=t[7]:(v=[n.documentId],t[6]=n.documentId,t[7]=v),(0,H.useEffect)(_,v);let y;if(t[8]!==n.nodes||t[9]!==n.roots||t[10]!==c||t[11]!==o){y=[];let e=new Set,r=(t,i)=>{for(let a of t){let t=n.nodes[a];if(!t||e.has(a))continue;let s=`children`in t?t.children:[];y.push({id:a,node:t,depth:i,children:s.length>0}),(c.has(a)||o.trim())&&s.length&&i<256&&(e.add(a),r(s,i+1),e.delete(a))}};r(n.roots,0),t[8]=n.nodes,t[9]=n.roots,t[10]=c,t[11]=o,t[12]=y}else y=t[12];let b;t[13]!==o||t[14]!==y?(b=o.trim()?y.filter(e=>{let{node:t}=e;return`${t.name} ${t.type}`.toLocaleLowerCase().includes(o.trim().toLocaleLowerCase())}):y,t[13]=o,t[14]=y,t[15]=b):b=t[15];let x=b,S=Math.max(0,Math.floor(u/32)-6),C=Math.min(x.length,Math.ceil((u+f)/32)+6),w;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(w=e=>d(e.currentTarget.scrollTop),t[16]=w):w=t[16];let T;t[17]!==o||t[18]!==x.length?(T=!x.length&&o.trim()?(0,G.jsx)(`p`,{className:`design-small-muted design-search-empty`,children:`No matching layers`}):null,t[17]=o,t[18]=x.length,t[19]=T):T=t[19];let E=x.length*32,D;t[20]===E?D=t[21]:(D={height:E,position:`relative`},t[20]=E,t[21]=D);let O;t[22]!==C||t[23]!==c||t[24]!==x||t[25]!==i||t[26]!==r||t[27]!==S?(O=x.slice(S,C).map((e,t)=>{let{id:n,node:a,depth:o,children:s}=e,u=cd(a);return(0,G.jsxs)(`div`,{className:`design-layer-row`,role:`treeitem`,"aria-level":o+1,"aria-selected":r.includes(n),"aria-expanded":s?c.has(n):void 0,style:{top:(S+t)*32,paddingInlineStart:Math.min(o,12)*13+4},children:[s?(0,G.jsx)(`button`,{type:`button`,className:`design-layer-disclosure`,"aria-label":`${c.has(n)?`Collapse`:`Expand`} ${a.name}`,onClick:()=>l(e=>{let t=new Set(e);return t.has(n)?t.delete(n):t.add(n),t}),children:c.has(n)?(0,G.jsx)(Ce,{size:14}):(0,G.jsx)(Te,{size:14})}):(0,G.jsx)(`span`,{className:`design-layer-spacer`}),(0,G.jsx)(yf,{icon:u.icon,label:a.name||u.label,kind:u.label,className:`design-layer-select`,onClick:()=>i([n])})]},n)}),t[22]=C,t[23]=c,t[24]=x,t[25]=i,t[26]=r,t[27]=S,t[28]=O):O=t[28];let k;t[29]!==D||t[30]!==O?(k=(0,G.jsx)(`div`,{style:D,children:O}),t[29]=D,t[30]=O,t[31]=k):k=t[31];let A;return t[32]!==k||t[33]!==T?(A=(0,G.jsxs)(`div`,{ref:m,className:`design-layer-viewport`,role:`tree`,"aria-label":`Layers`,onScroll:w,children:[T,k]}),t[32]=k,t[33]=T,t[34]=A):A=t[34],A}function xf(e){let t=(0,U.c)(40),{tab:n,document:r,onOpen:i,selection:a,select:o,context:s,query:c}=e,l;t[0]===c?l=t[1]:(l=e=>e.toLocaleLowerCase().includes(c.trim().toLocaleLowerCase()),t[0]=c,t[1]=l);let u=l;if(n===`Layers`){let e;return t[2]!==r||t[3]!==c||t[4]!==o||t[5]!==a?(e=r?(0,G.jsx)(bf,{document:r,selection:a,select:o,query:c}):(0,G.jsx)(hf,{title:`No layers yet`,detail:`Open a design document to inspect its layers.`}),t[2]=r,t[3]=c,t[4]=o,t[5]=a,t[6]=e):e=t[6],e}if(n===`Libraries`){let e,n,r;if(t[7]!==s?.manifest?.libraries||t[8]!==u||t[9]!==i){let a=Object.entries(s?.manifest?.libraries??{});e=`design-catalog-list`,n=a.length>0&&!a.some(e=>{let[,t]=e;return u(t.path)})?(0,G.jsx)(`p`,{className:`design-small-muted design-search-empty`,children:`No matching libraries`}):null,r=a.length?a.filter(e=>{let[,t]=e;return u(t.path)}).map(e=>{let[t,n]=e;return(0,G.jsx)(yf,{icon:Me,label:n.path,className:`design-catalog-row`,onClick:()=>i(n.path),trailing:(0,G.jsx)(`small`,{children:n.exports.length})},t)}):(0,G.jsx)(hf,{title:`No libraries`,detail:`Libraries declared in p4.design.json appear here.`}),t[7]=s?.manifest?.libraries,t[8]=u,t[9]=i,t[10]=e,t[11]=n,t[12]=r}else e=t[10],n=t[11],r=t[12];let a;return t[13]!==e||t[14]!==n||t[15]!==r?(a=(0,G.jsxs)(`div`,{className:e,children:[n,r]}),t[13]=e,t[14]=n,t[15]=r,t[16]=a):a=t[16],a}if(!r){let e;t[17]===n?e=t[18]:(e=n.toLowerCase(),t[17]=n,t[18]=e);let r=`No ${e} yet`,i;return t[19]===r?i=t[20]:(i=(0,G.jsx)(hf,{title:r,detail:`Open a design document first.`}),t[19]=r,t[20]=i),i}if(n===`Components`){let e,n,i;if(t[21]!==r.components||t[22]!==u||t[23]!==o){let a=Object.entries(r.components);e=`design-catalog-list`,n=a.length>0&&!a.some(e=>{let[,t]=e;return u(t.name)})?(0,G.jsx)(`p`,{className:`design-small-muted design-search-empty`,children:`No matching components`}):null,i=a.length?a.filter(e=>{let[,t]=e;return u(t.name)}).map(e=>{let[t,n]=e;return(0,G.jsx)(yf,{icon:ke,label:n.name,className:`design-catalog-row`,onClick:()=>o([n.rootId])},t)}):(0,G.jsx)(hf,{title:`No components`,detail:`Components created by an agent appear here.`}),t[21]=r.components,t[22]=u,t[23]=o,t[24]=e,t[25]=n,t[26]=i}else e=t[24],n=t[25],i=t[26];let a;return t[27]!==e||t[28]!==n||t[29]!==i?(a=(0,G.jsxs)(`div`,{className:e,children:[n,i]}),t[27]=e,t[28]=n,t[29]=i,t[30]=a):a=t[30],a}let d,f,p;if(t[31]!==r.tokens||t[32]!==u){let e=Object.entries(r.tokens);d=`design-catalog-list`,f=e.length>0&&!e.some(e=>{let[,t]=e;return u(t.name)})?(0,G.jsx)(`p`,{className:`design-small-muted design-search-empty`,children:`No matching tokens`}):null,p=e.length?e.filter(e=>{let[,t]=e;return u(t.name)}).map(Sf):(0,G.jsx)(hf,{title:`No tokens`,detail:`Design tokens created by an agent appear here.`}),t[31]=r.tokens,t[32]=u,t[33]=d,t[34]=f,t[35]=p}else d=t[33],f=t[34],p=t[35];let m;return t[36]!==d||t[37]!==f||t[38]!==p?(m=(0,G.jsxs)(`div`,{className:d,children:[f,p]}),t[36]=d,t[37]=f,t[38]=p,t[39]=m):m=t[39],m}function Sf(e){let[t,n]=e;return(0,G.jsxs)(`div`,{className:`design-token-row`,children:[(0,G.jsx)(Mt,{children:n.name}),(0,G.jsx)(`span`,{className:`design-small-muted`,children:Hu(n.kind)})]},t)}function Cf(e){let t=(0,U.c)(21),{open:n,onOpenChange:r,tab:i,onTabChange:a,counts:o,query:s,onQueryChange:c,comments:l,children:u}=e,d=(0,H.useRef)(null),f=(0,H.useRef)(new Map),p;t[0]===i?p=t[1]:(p=pf.find(e=>{let[t]=e;return t===i})?.[1]??Be,t[0]=i,t[1]=p);let m=p,h=e=>{let t=pf.findIndex(e=>{let[t]=e;return t===i}),n=pf[e===`first`?0:e===`last`?pf.length-1:(t+e+pf.length)%pf.length][0];a(n),f.current.get(n)?.focus()},g;t[2]!==r||t[3]!==n?(g=()=>r(!n),t[2]=r,t[3]=n,t[4]=g):g=t[4];let _;t[5]===m?_=t[6]:(_=(0,G.jsx)(m,{"aria-hidden":`true`}),t[5]=m,t[6]=_);let v=o[i],y;t[7]===v?y=t[8]:(y=(0,G.jsx)(`span`,{className:`design-pill-count`,children:v}),t[7]=v,t[8]=y);let b;t[9]===n?b=t[10]:(b=n?(0,G.jsx)(Ee,{"aria-hidden":`true`}):(0,G.jsx)(Ce,{"aria-hidden":`true`}),t[9]=n,t[10]=b);let x;t[11]!==n||t[12]!==g||t[13]!==_||t[14]!==y||t[15]!==b||t[16]!==i?(x=(0,G.jsxs)(W,{ref:d,size:`sm`,variant:`outline`,className:`design-float-pill`,"aria-expanded":n,"aria-controls":`design-catalog-panel`,onClick:g,children:[_,i,y,b]}),t[11]=n,t[12]=g,t[13]=_,t[14]=y,t[15]=b,t[16]=i,t[17]=x):x=t[17];let S=n?(0,G.jsxs)(`div`,{id:`design-catalog-panel`,className:`design-catalog-panel`,role:`region`,"aria-label":`Design catalog`,onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),r(!1),d.current?.focus())},children:[(0,G.jsx)(`div`,{className:`design-catalog-tabs`,role:`tablist`,"aria-label":`Catalog`,onKeyDown:e=>{let t=e.key===`ArrowRight`?1:e.key===`ArrowLeft`?-1:e.key===`Home`?`first`:e.key===`End`?`last`:null;t!==null&&(e.preventDefault(),h(t))},children:pf.map(e=>{let[t,n]=e,r=i===t,o=(0,G.jsx)(`button`,{ref:e=>{e?f.current.set(t,e):f.current.delete(t)},type:`button`,role:`tab`,id:`design-catalog-tab-${t}`,"aria-selected":r,"aria-controls":`design-catalog-tabpanel`,"aria-label":r?void 0:t,tabIndex:r?0:-1,onClick:()=>a(t)});return r?(0,G.jsxs)(`button`,{ref:e=>{e?f.current.set(t,e):f.current.delete(t)},type:`button`,role:`tab`,id:`design-catalog-tab-${t}`,"aria-selected":!0,"aria-controls":`design-catalog-tabpanel`,tabIndex:0,onClick:()=>a(t),children:[(0,G.jsx)(n,{size:14,"aria-hidden":`true`}),(0,G.jsx)(`span`,{children:t})]},t):(0,G.jsxs)(jt,{children:[(0,G.jsx)(Ot,{render:o,children:(0,G.jsx)(n,{size:14,"aria-hidden":`true`})}),(0,G.jsx)(kt,{children:t})]},t)})}),(0,G.jsx)(`div`,{id:`design-catalog-tabpanel`,className:`design-catalog-tabpanel`,role:`tabpanel`,"aria-labelledby":`design-catalog-tab-${i}`,children:i===`Comments`?l:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`design-catalog-search`,children:[(0,G.jsx)(tt,{size:14,"aria-hidden":`true`}),(0,G.jsx)(`input`,{type:`search`,"aria-label":`Search ${i.toLowerCase()}`,placeholder:`Search ${i.toLowerCase()}`,value:s,onChange:e=>c(e.target.value)})]}),u]})})]}):null,C;return t[18]!==S||t[19]!==x?(C=(0,G.jsxs)(`div`,{className:`design-catalog-float`,children:[x,S]}),t[18]=S,t[19]=x,t[20]=C):C=t[20],C}function wf(e,t){if(e==null)return`None`;if(typeof e==`object`&&`tokenId`in e)return`Token ${t?.tokens[String(e.tokenId)]?.name??String(e.tokenId)}`;if(typeof e==`object`&&`mode`in e){let n=e;return n.mode===`fixed`?`Fixed ${wf(n.value,t)}`:Hu(n.mode)}return Array.isArray(e)?`${e.length} ${e.length===1?`item`:`items`}`:typeof e==`number`?Uu(e):String(e)}function Tf({document:e,selection:t,theme:n,context:r,compact:i=!1}){let a=(0,H.useMemo)(()=>Kr(e,n,r),[e,n,r]);if(!t.length)return(0,G.jsx)(hf,{title:`Nothing selected`,detail:`Select a layer or click an item on the canvas.`});if(t.length>1)return(0,G.jsx)(hf,{title:`${t.length} items selected`,detail:`Select one item to inspect its properties.`});let o=t[0],s=o?e.nodes[o]:void 0;if(!s)return(0,G.jsx)(hf,{title:`Selection unavailable`,detail:`The selected item is no longer in this revision.`});let c=t=>{if(t&&typeof t==`object`&&`mode`in t&&`value`in t)return`${t.mode===`fixed`?`Fixed`:Hu(String(t.mode))} ${c(t.value)}`;if(!t||typeof t!=`object`||!(`tokenId`in t))return wf(t,e);try{let r=Ur(e,t,n);return typeof r==`number`?Uu(r):String(r)}catch{return`Unresolved token`}},l=o?e.instances[o]:void 0,u=a.items.find(e=>e.ownerId===o)?.bounds,d=s.type===`ref`&&s.importId?e.imports[s.importId]:void 0,f=d?r?.documents?.[d.libraryId]:e,p=s.type===`ref`?f?.components[s.componentId]:void 0,m=t=>(0,G.jsx)(`dl`,{className:`design-property-list`,children:t.map(([t,n,r])=>(0,G.jsxs)(`div`,{className:`design-property`,children:[(0,G.jsx)(`dt`,{children:t}),(0,G.jsxs)(`dd`,{children:[r??(0,G.jsx)(`span`,{children:wf(n,e)}),r===void 0&&wf(n,e)!==c(n)?(0,G.jsxs)(`small`,{children:[`Resolved: `,c(n)]}):null]})]},t))}),h=(e,t)=>(0,G.jsxs)(`section`,{className:`design-inspector-section`,"aria-label":e,children:[(0,G.jsx)(`h3`,{children:e}),m(t)]}),g=s.fills?.[0],_=g?.kind===`solid`?c(g.color):null,v=cd(s),y=v.icon;return(0,G.jsxs)(`div`,{className:`design-inspector-content`,children:[i?null:(0,G.jsxs)(`div`,{className:`design-inspector-identity`,children:[(0,G.jsxs)(`h2`,{className:`design-inspector-title`,children:[(0,G.jsx)(y,{size:14,"aria-hidden":`true`}),(0,G.jsx)(Mt,{children:s.name||v.label})]}),(0,G.jsxs)(`span`,{className:`design-inspector-meta`,children:[(0,G.jsx)(`span`,{className:`design-small-muted`,children:v.label}),(0,G.jsx)(dr,{variant:`outline`,size:`sm`,children:`Read only`})]})]}),`clip`in s?h(`Alignment`,[[`Clip contents`,null,Ku(s.clip)]]):null,h(`Position`,[[`X`,s.x],[`Y`,s.y],[`Rotation`,s.rotation??0,`${Uu(s.rotation??0)}°`]]),h(`Layout`,`layout`in s?[[`Mode`,null,Hu(s.layout.direction)],[`Gap`,s.layout.gap],[`Padding`,null,[s.layout.padding.top,s.layout.padding.right,s.layout.padding.bottom,s.layout.padding.left].map(t=>wf(t,e)).join(` `)]]:[[`Mode`,null,`Absolute`]]),h(`Dimensions`,[[`Width`,s.width],[`Height`,s.height],[`Computed`,null,u?`${Uu(u.width)} × ${Uu(u.height)}`:`Unavailable`]]),h(`Appearance`,[[`Opacity`,null,Wu(s.opacity??1)],[`Visibility`,null,Gu(s.visible??!0)],[`Stroke`,s.stroke??`None`],[`Effects`,null,qu(s.effects?.length??0)],...`radius`in s?[[`Radius`,s.radius??0]]:[],...`text`in s?[[`Text`,null,(0,G.jsx)(Mt,{children:s.text},`text`)],[`Font`,s.fontFamily],[`Font size`,s.fontSize]]:[]]),h(`Fill`,[[`Type`,null,g?Hu(g.kind):`None`],...g?.kind===`solid`?[[`Color`,null,(0,G.jsxs)(`span`,{className:`design-fill-value`,children:[(0,G.jsx)(`span`,{className:`design-swatch`,style:{background:_??`transparent`},"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`design-mono`,children:_}),typeof g.color==`object`?(0,G.jsx)(`small`,{children:wf(g.color,e)}):null]},`color`)]]:g?.kind===`image`?[[`Asset`,null,(0,G.jsx)(Mt,{className:`design-truncate design-mono`,children:g.assetId},`asset`)]]:g?.kind===`gradient`?[[`Gradient`,null,Hu(g.gradient)]]:[]]),h(`Theme`,Object.entries(e.themeAxes).length?Object.entries(e.themeAxes).map(([e,t])=>[e,null,n[e]??`Default (${t[0]??`none`})`]):[[`Preview`,null,`Default`]]),p?(0,G.jsxs)(`section`,{className:`design-inspector-section`,"aria-label":`Source component`,children:[(0,G.jsx)(`h3`,{children:`Source component`}),(0,G.jsx)(`p`,{children:p.name}),d?(0,G.jsx)(Mt,{className:`design-truncate design-small-muted`,children:`Library ${r?.manifest?.libraries[d.libraryId]?.path??d.libraryId}`}):null]}):null,l?(0,G.jsxs)(`section`,{className:`design-inspector-section`,"aria-label":`Overrides`,children:[(0,G.jsx)(`h3`,{children:`Overrides`}),(0,G.jsxs)(`p`,{children:[Object.keys(l.overrides).length,` source`,` `,Object.keys(l.overrides).length===1?`node`:`nodes`]}),Object.entries(l.overrides).map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(Mt,{className:`design-truncate design-small-muted`,children:f?.nodes[e]?.name??e}),m(Object.entries(t))]},e))]}):null,h(`Code`,[[`Mapping`,null,e.codeMappings?`Document mapping available`:`No code mapping`]]),i?null:(0,G.jsx)(`p`,{className:`design-inspector-hint`,children:`Ask the agent to change this selection.`})]})}function Ef(e){let t=(0,U.c)(67),{geometry:n,document:r,selection:i,theme:a,context:o,collapsed:s,onCollapsedChange:c,onComment:l,extraAction:u}=e,d=(0,H.useRef)(null),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f={width:300,height:148},t[0]=f):f=t[0];let[p,m]=(0,H.useState)(f),[h,g]=(0,H.useState)(!1),_,v;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>{let e=d.current;if(!e)return;let t=new ResizeObserver(()=>{let t=e.offsetWidth,n=e.offsetHeight;t&&n&&m(e=>e.width===t&&e.height===n?e:{width:t,height:n})});return t.observe(e),()=>t.disconnect()},v=[],t[1]=_,t[2]=v):(_=t[1],v=t[2]),(0,H.useLayoutEffect)(_,v);let y;t[3]!==n.avoid||t[4]!==n.canvas||t[5]!==n.screen||t[6]!==p?(y=mi(n.screen,p,n.canvas,void 0,void 0,n.avoid),t[3]=n.avoid,t[4]=n.canvas,t[5]=n.screen,t[6]=p,t[7]=y):y=t[7];let b=y,{onPlaced:x}=n,S=b?.x,C=b?.y,w,T;t[8]!==x||t[9]!==S||t[10]!==C||t[11]!==p.height||t[12]!==p.width?(w=()=>{x(S===void 0||C===void 0?null:{x:S,y:C,width:p.width,height:p.height})},T=[x,S,C,p.width,p.height],t[8]=x,t[9]=S,t[10]=C,t[11]=p.height,t[12]=p.width,t[13]=w,t[14]=T):(w=t[13],T=t[14]),(0,H.useLayoutEffect)(w,T);let E,D;t[15]===x?(E=t[16],D=t[17]):(E=()=>()=>x(null),D=[x],t[15]=x,t[16]=E,t[17]=D),(0,H.useLayoutEffect)(E,D);let O=i.length===1?r.nodes[i[0]]:void 0,k;t[18]===O?k=t[19]:(k=O?cd(O):{label:`Selection`,icon:Be},t[18]=O,t[19]=k);let A=k,j=A.icon,M=O?O.name||A.label:`${i.length} layers`,N=!b,P;t[20]===b?P=t[21]:(P=b?{transform:`translate(${b.x}px, ${b.y}px)`}:void 0,t[20]=b,t[21]=P);let F;t[22]===j?F=t[23]:(F=(0,G.jsx)(j,{size:14,"aria-hidden":`true`}),t[22]=j,t[23]=F);let I;t[24]===M?I=t[25]:(I=(0,G.jsx)(`h2`,{children:(0,G.jsx)(Mt,{children:M})}),t[24]=M,t[25]=I);let ee;t[26]!==A.label||t[27]!==O?(ee=O?(0,G.jsx)(`span`,{className:`sr-only`,children:A.label}):null,t[26]=A.label,t[27]=O,t[28]=ee):ee=t[28];let L;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,G.jsx)(dr,{variant:`outline`,size:`sm`,children:`Read only`}),t[29]=L):L=t[29];let te=s?`Expand inspector`:`Collapse inspector`,ne=!s,re;t[30]!==s||t[31]!==c?(re=()=>c(!s),t[30]=s,t[31]=c,t[32]=re):re=t[32];let R;t[33]!==te||t[34]!==ne||t[35]!==re?(R=(0,G.jsx)(W,{size:`icon-xs`,variant:`ghost`,"aria-label":te,"aria-expanded":ne,onClick:re}),t[33]=te,t[34]=ne,t[35]=re,t[36]=R):R=t[36];let ie;t[37]===s?ie=t[38]:(ie=s?(0,G.jsx)(Ce,{"aria-hidden":`true`}):(0,G.jsx)(Ee,{"aria-hidden":`true`}),t[37]=s,t[38]=ie);let ae;t[39]!==R||t[40]!==ie?(ae=(0,G.jsx)(Ot,{render:R,children:ie}),t[39]=R,t[40]=ie,t[41]=ae):ae=t[41];let oe=s?`Expand inspector`:`Collapse inspector`,se;t[42]===oe?se=t[43]:(se=(0,G.jsx)(kt,{children:oe}),t[42]=oe,t[43]=se);let ce;t[44]!==ae||t[45]!==se?(ce=(0,G.jsxs)(jt,{children:[ae,se]}),t[44]=ae,t[45]=se,t[46]=ce):ce=t[46];let le;t[47]!==F||t[48]!==I||t[49]!==ee||t[50]!==ce?(le=(0,G.jsxs)(`header`,{className:`design-selection-card-header`,children:[F,I,ee,L,ce]}),t[47]=F,t[48]=I,t[49]=ee,t[50]=ce,t[51]=le):le=t[51];let ue;t[52]!==s||t[53]!==o||t[54]!==r||t[55]!==u||t[56]!==n.world||t[57]!==h||t[58]!==l||t[59]!==i||t[60]!==a?(ue=s?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`dl`,{className:`design-geometry`,children:[[`W`,n.world.width],[`H`,n.world.height],[`X`,n.world.x],[`Y`,n.world.y]].map(Of)}),(0,G.jsxs)(`div`,{className:`design-selection-card-actions`,children:[l?(0,G.jsxs)(W,{size:`xs`,variant:`outline`,onClick:l,children:[(0,G.jsx)(Ke,{"aria-hidden":`true`}),`Comment`]}):null,(0,G.jsx)(W,{size:`xs`,variant:`ghost`,"aria-expanded":h,onClick:()=>g(Df),children:h?`Less`:`More`}),u]}),h?(0,G.jsx)(`div`,{className:`design-selection-card-more`,children:(0,G.jsx)(Tf,{document:r,selection:i,theme:a,context:o,compact:!0})}):null]}),t[52]=s,t[53]=o,t[54]=r,t[55]=u,t[56]=n.world,t[57]=h,t[58]=l,t[59]=i,t[60]=a,t[61]=ue):ue=t[61];let de;return t[62]!==N||t[63]!==P||t[64]!==le||t[65]!==ue?(de=(0,G.jsxs)(`section`,{ref:d,className:`design-selection-card`,"aria-label":`Selection inspector`,hidden:N,style:P,children:[le,ue]}),t[62]=N,t[63]=P,t[64]=le,t[65]=ue,t[66]=de):de=t[66],de}function Df(e){return!e}function Of(e){let[t,n]=e;return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:t}),(0,G.jsx)(`dd`,{children:Uu(Math.round(n*100)/100)})]},t)}var kf=new Map,Af=e=>kf,jf=[],Mf=e=>jf,Nf=(e,t)=>void 0,Pf=(e,t,n)=>null;function Ff({resourceId:e,surface:t,agentEdit:n,frameDecoration:r,canvasPreferences:i}){let a=Yn(),{navigation:o,attachment:s}=a,c=o.useTarget(),l=a.useCanWrite?.(c)??!0,u=o.useProjects(),d=o.useActivePath(c),f=e??d??``,p=af(c),{record:m,select:h,reload:g}=rf(c,f),_=ff(c,f,m),v=$n(),y=(o.useDocumentStatuses??Af)(c),b=(o.useLinkedPaths??Mf)(c),x=(a.useAgentPresence??Nf)(c,f),S=(a.useCanvasPlaceholder??Pf)(c,{paths:p.paths,loading:p.loading,failed:!!p.error},{openImport:()=>pe(!0)}),[C,w]=(0,H.useState)(`Layers`),[T,E]=(0,H.useState)(!1),[D,O]=(0,H.useState)(!1),[k,A]=(0,H.useState)(`Canvas`),[j,M]=(0,H.useState)(``),[N,P]=(0,H.useState)(()=>typeof window>`u`||window.innerWidth>=1024),[F,I]=(0,H.useState)(!1),[ee,L]=(0,H.useState)(null),[te,ne]=(0,H.useState)(null),[re,R]=(0,H.useState)(null),[ie,ae]=(0,H.useState)(null),[oe,se]=(0,H.useState)([]),[ce,le]=(0,H.useState)(null),[ue,de]=(0,H.useState)({}),[fe,pe]=(0,H.useState)(!1),[me,he]=(0,H.useState)(`import`),ge=t===`panel`,ve=JSON.stringify([c,f,t]),ye=ie?.key===ve?ie:null,be=!!ye;(0,H.useEffect)(()=>ae(null),[ve]);let z=m.document,xe=m.diagnostics??[],Se=xe.find(e=>e.severity===`error`),Ce=xe.find(e=>e.severity===`warning`&&e.code.includes(`asset`)),we=(0,H.useMemo)(()=>z?Object.entries(z.themeAxes):[],[z?.themeAxes]),Te=(0,H.useMemo)(()=>Object.fromEntries(we.flatMap(([e,t])=>ue[e]&&t.includes(ue[e])?[[e,ue[e]]]:[])),[ue,we]),Ee=c?.threadId,B=(0,H.useMemo)(()=>c&&s?{environmentId:c.environmentId,projectId:c.projectId,...Ee?{threadId:Ee}:{}}:null,[c?.environmentId,c?.projectId,Ee,!!s]),Oe=!ge&&!!(Ee&&a.thread),ke=Oe&&N,Me=(e,t=ge?`panel`:`workspace`)=>{c&&o.openDocument(c,e,t)},Ne=z&&(m.status===`ready`||m.status===`disconnected`||m.status===`conflict`||m.readOnly),Fe=!!(l&&m.contentHash&&m.status===`ready`&&!m.readOnly),Ie=e=>{if(!c||!f||!z||!m.contentHash)return;let t=m.contentHash,n=e=>le({key:ve,message:e});le(null),v(a.transport.readRevision(c,f,e.id)).then(({source:r})=>{let i=zr(r);if(i.status!==`editable`)return n(`This revision can't be opened for comparison.`);if(Ve.current!==t)return n(`The design changed. Compare again.`);ae({key:ve,before:i.document,after:z,beforeRevision:e.revision,afterRevision:t,beforeContext:m.context,beforeAssets:m.assets,afterContext:m.context,afterAssets:m.assets,theme:Te,priorSelection:[...m.selection]}),se([...m.selection]),L(null),A(`Canvas`)},()=>n(`Could not load this revision.`))},Le=()=>{ye&&h(ye.priorSelection),ae(null)},Re=e=>{R(e??null),ge?A(`Comments`):(w(`Comments`),E(!0))},ze=e=>{Oe&&P(!0),_.attach(e,{stay:Oe})},Be=m.selection.join(`\0`),Ve=(0,H.useRef)(m.contentHash);Ve.current=m.contentHash;let He=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=He.current;if(He.current=Be,!ke||!B||!s||be||(e===null||e===Be)&&s.current(B))return;let t=Ve.current,n=Be?Be.split(`\0`):[];if(!n.length||!t||!f){s.set(B,null);return}let r=n.length===1?z?.nodes[n[0]]:void 0;s.set(B,{documentPath:f,revision:t,nodeIds:n},r?{name:r.name,type:{type:r.type,fills:r.fills}}:void 0)},[ke,B,be,Be,f]),(0,H.useEffect)(()=>{if(!ke||!B||!s||!m.contentHash)return;let e=s.current(B);e&&e.selection.documentPath===f&&e.selection.revision!==m.contentHash&&s.set(B,{...e.selection,revision:m.contentHash},e.label)},[ke,B,f,m.contentHash]);let Ue=async e=>{if(be||!m.contentHash||!_.author.trim()||te?.path!==f||te.revision!==m.contentHash)return;let t=lf();await _.annotate(t,{...e,revision:m.contentHash,author:_.author.trim(),createdAt:new Date().toISOString(),replies:[],status:`open`}),ne(null),L(null)},We=async(e,t)=>{if(be)return;let n=z?.annotations[e];n&&_.author.trim()&&await _.annotate(e,{...n,replies:[...n.replies,{id:lf(),body:t,author:_.author.trim(),createdAt:new Date().toISOString()}]})},Ke=async(e,t)=>{if(be)return;let n=z?.annotations[e];n&&await _.annotate(e,{...n,status:t?`resolved`:`open`})},qe=te?.anchor.kind===`region`&&te.path===f&&te.revision===m.contentHash?te.anchor.bounds:null,Je=z?(0,G.jsxs)(`div`,{className:`design-comments-panel`,children:[be?(0,G.jsx)(`p`,{className:`design-author-hint`,children:`Exit compare to comment or attach a selection.`}):null,m.selection.length&&!be&&Fe?(0,G.jsx)(`div`,{className:`design-inspector-actions`,children:(0,G.jsx)(W,{size:`sm`,variant:`outline`,onClick:()=>ne({path:f,revision:m.contentHash,anchor:{kind:`nodes`,nodeIds:m.selection}}),children:`Comment on selection`})}):null,te&&!be&&te.path===f&&te.revision===m.contentHash&&Fe?(0,G.jsx)(Fd,{anchor:te.anchor,onSubmit:Ue,onCancel:()=>{ne(null),L(null)},busy:_.busy||!_.author.trim()},JSON.stringify(te)):null,te?.path===f&&te.revision!==m.contentHash?(0,G.jsxs)(`div`,{className:`design-annotation-stale`,role:`status`,children:[(0,G.jsx)(`span`,{children:`The revision changed. Place this comment again.`}),(0,G.jsx)(W,{size:`sm`,variant:`outline`,onClick:()=>{ne(null),L(null)},children:`Clear`})]}):null,qe&&!be&&B?(0,G.jsx)(`div`,{className:`design-inspector-actions`,children:(0,G.jsx)(W,{size:`sm`,variant:`outline`,onClick:()=>ze({documentPath:f,revision:m.contentHash,nodeIds:[],region:qe}),children:`Attach region`})}):null,(0,G.jsx)(Ld,{document:z,currentRevision:m.contentHash,focusedId:re,actions:m.status!==`ready`||m.readOnly||be?void 0:{reply:We,setResolved:Ke},busy:_.busy||!_.author.trim()})]}):(0,G.jsx)(hf,{title:`No comments`}),Xe=!l||m.status!==`ready`||m.readOnly,$e=[];z&&m.status===`disconnected`&&$e.push({key:`disconnected`,variant:`warning`,role:`status`,icon:ct,message:`Disconnected. Showing cached revision ${mf(m.contentHash)}.`,action:{label:`Retry`,run:g}}),z&&m.status===`conflict`&&$e.push({key:`conflict`,variant:`warning`,role:`alert`,icon:De,message:`This view is out of date.`,action:{label:`Reload`,run:g}}),z&&(m.readOnly||Se)&&!Ce&&m.status===`ready`&&$e.push({key:`issue`,variant:Se?`error`:`info`,role:`alert`,icon:De,message:Se?.message??`This design is read-only.`,action:{label:`Reload`,run:g}}),z&&Ce&&$e.push({key:`asset`,variant:`warning`,role:`status`,icon:De,message:`An image asset is missing. Its placeholder remains visible.`,action:{label:`Reload`,run:g}}),z&&ce?.key===ve&&$e.push({key:`compare`,variant:`error`,role:`alert`,icon:De,message:ce.message,action:{label:`Dismiss`,run:()=>le(null)}});let et=z?(0,G.jsx)(gf,{items:$e,diagnostics:xe}):null,tt=we.map(([e,t])=>(0,G.jsxs)(ni,{modal:!1,value:Te[e]??``,onValueChange:t=>de(n=>{let r={...n};return typeof t==`string`&&t?r[e]=t:delete r[e],r}),children:[(0,G.jsxs)(ii,{variant:`ghost`,size:`sm`,className:`design-topbar-select`,"aria-label":`Preview ${Hu(e)}`,children:[(0,G.jsx)(Ye,{"aria-hidden":`true`,size:16}),(0,G.jsx)(`span`,{className:`design-small-muted`,children:we.length===1?`Preview`:Hu(e)}),(0,G.jsx)(ai,{children:e=>e||`Default`})]}),(0,G.jsxs)(oi,{children:[(0,G.jsx)(si,{value:``,children:`Default`}),t.map(e=>(0,G.jsx)(si,{value:e,children:e},e))]})]},e)),rt=S||(c?f?m.status===`loading`&&!z?(0,G.jsx)(hf,{title:`Loading design…`}):z?(0,G.jsxs)(G.Fragment,{children:[ge?et:null,Ne&&!z.roots.length?(0,G.jsx)(hf,{title:`No layers yet`,detail:`Ask an agent to add a frame or shape.`}):null,Ne&&z.roots.length?ye?(0,G.jsx)(rd,{preferences:i,before:ye.before,after:ye.after,beforeRevision:ye.beforeRevision,afterRevision:ye.afterRevision,viewKey:ve,theme:ye.theme,beforeContext:ye.beforeContext,beforeAssets:ye.beforeAssets,context:ye.afterContext,assets:ye.afterAssets,selection:oe,onSelect:se,onExit:Le}):(0,G.jsx)(td,{preferences:i,chrome:ge?`panel`:`workspace`,viewKey:ve,document:z,theme:Te,context:m.context,assets:m.assets,selection:m.selection,changedNodeIds:m.changedNodeIds,batch:m.batch,agents:x,agentEdit:n,frameDecoration:r,onSelect:h,annotationMode:ee,onAnnotationModeChange:Fe?L:void 0,onAnchor:e=>{m.contentHash&&ne({path:f,revision:m.contentHash,anchor:e}),Re()},onOpenAnnotation:Re,revision:m.contentHash,renderSelectionOverlay:ge?void 0:e=>(0,G.jsx)(Ef,{geometry:e,document:z,selection:m.selection,theme:Te,context:m.context,collapsed:F,onCollapsedChange:I,onComment:Fe?()=>L(`pin`):void 0,extraAction:B&&s&&!Oe&&m.contentHash?(0,G.jsx)(W,{size:`xs`,variant:`ghost`,onClick:()=>ze({documentPath:f,revision:m.contentHash,nodeIds:m.selection}),children:`Attach selection`}):null})},f):null]}):(0,G.jsx)(hf,{title:xe.some(e=>e.code===`unknown-major`)?`Newer design version`:`Design could not be opened`,detail:Se?.message??`Check the file and try again.`,action:g}):(0,G.jsx)(hf,{title:`Choose a design`,detail:`Open a .p4design document from this project.`,action:p.paths.length?()=>O(!0):void 0,actionLabel:`Choose design`}):(0,G.jsx)(hf,{title:`Open a project`,detail:`Choose a project to view its design documents.`})),it=(0,G.jsx)(jd,{open:fe,mode:me,onModeChange:he,onOpenChange:pe,target:c,documentPath:f,revision:m.contentHash,document:m.status===`ready`&&!m.readOnly?z:void 0,selection:m.selection,onImportComplete:p.reload,theme:Te,onOpenImported:e=>{Me(e)}});if(!ge){let e={Layers:z?Object.keys(z.nodes).length:0,Comments:z?Object.keys(z.annotations).length:0,Components:z?Object.keys(z.components).length:0,Libraries:Object.keys(m.context?.manifest?.libraries??{}).length,Tokens:z?Object.keys(z.tokens).length:0};return(0,G.jsxs)(`section`,{className:`design-workspace design-workspace-full${be?` design-workspace-comparing`:``}`,"aria-label":`P4 Design workspace`,children:[(0,G.jsxs)(`header`,{className:`design-topbar`,children:[(0,G.jsxs)(`div`,{className:`design-topbar-title`,children:[a.TopbarStart?(0,G.jsx)(a.TopbarStart,{target:c}):null,u.length||o.createProject?(0,G.jsxs)(ni,{modal:!1,value:c?`${c.environmentId}\u0000${c.projectId}`:null,onValueChange:e=>{if(e===vf){o.createProject?.();return}let t=u.find(t=>`${t.environmentId}\u0000${t.projectId}`===e);t&&o.openProject(t)},children:[(0,G.jsxs)(ii,{variant:`ghost`,size:`sm`,className:`design-topbar-project`,"aria-label":`Project`,children:[(0,G.jsx)(Pe,{"aria-hidden":`true`,size:16}),(0,G.jsx)(ai,{children:e=>(0,G.jsx)(Mt,{children:u.find(t=>`${t.environmentId}\u0000${t.projectId}`===e)?.name??`Select project`})})]}),(0,G.jsxs)(oi,{children:[u.map(e=>(0,G.jsx)(si,{value:`${e.environmentId}\u0000${e.projectId}`,children:e.name},`${e.environmentId}\u0000${e.projectId}`)),o.createProject?(0,G.jsx)(si,{value:vf,children:(0,G.jsxs)(`span`,{className:`design-switcher-item`,children:[(0,G.jsx)(Ze,{"aria-hidden":`true`,size:14}),`New project`]})}):null]})]}):null,u.length||o.createProject?(0,G.jsx)(`span`,{className:`design-topbar-crumb`,"aria-hidden":`true`,children:`/`}):null,(0,G.jsx)(Or,{target:c,path:f,paths:p.paths,entries:p.entries,linkedPaths:b,open:D,onOpenChange:O,onOpen:e=>Me(e),statuses:y,onStartDesign:c&&o.startDesign?()=>{P(!0),o.startDesign?.(c)}:void 0,onStartDesignInNewThread:c&&o.startDesignInNewThread?()=>o.startDesignInNewThread?.(c):void 0,onManageDesigns:c&&o.manageDesigns?()=>o.manageDesigns?.(c):void 0})]}),(0,G.jsx)(`div`,{className:`design-topbar-notices`,children:et}),(0,G.jsxs)(`div`,{className:`design-topbar-actions`,children:[f?(0,G.jsx)(ir,{target:c,path:f,revision:m.contentHash,fileHash:m.fileHash??``,disabled:Xe||!!ye||!c||!m.fileHash,onCompare:Ie},`${c?.environmentId}:${c?.projectId}:${c?.threadId}:${f}`):null,c&&o.startDesign?(0,G.jsxs)(jt,{children:[(0,G.jsxs)(Ot,{render:(0,G.jsx)(W,{size:`sm`,variant:`outline`,"aria-label":`New design`,onClick:()=>{P(!0),o.startDesign?.(c)}}),children:[(0,G.jsx)(Ze,{"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`design-collapsible-label`,children:`New design`})]}),(0,G.jsx)(kt,{children:`New design`})]}):null,tt,(0,G.jsx)(lr,{target:c,path:f,revision:m.contentHash,iconOnly:!0}),a.TopbarEnd?(0,G.jsx)(a.TopbarEnd,{target:c,path:f}):null,(0,G.jsxs)(On,{children:[(0,G.jsxs)(jt,{children:[(0,G.jsx)(Ot,{render:(0,G.jsx)(kn,{render:(0,G.jsx)(W,{size:`icon`,variant:`ghost`,"aria-label":`More actions`})}),children:(0,G.jsx)(je,{"aria-hidden":`true`})}),(0,G.jsx)(kt,{children:`More actions`})]}),(0,G.jsxs)(An,{align:`end`,className:`w-56`,children:[(0,G.jsxs)(jn,{disabled:!c||!l,onClick:()=>{he(`import`),pe(!0)},children:[(0,G.jsx)(st,{"aria-hidden":`true`}),` Import design…`]}),(0,G.jsxs)(jn,{disabled:!l||!z||m.status!==`ready`||m.readOnly,onClick:()=>{he(`export`),pe(!0)},children:[(0,G.jsx)(Ae,{"aria-hidden":`true`}),` Export design…`]}),(0,G.jsxs)(jn,{disabled:!c,onClick:()=>{g(),p.reload()},children:[(0,G.jsx)(Qe,{"aria-hidden":`true`}),` Reload design`]}),o.openSettings?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Mn,{}),(0,G.jsxs)(jn,{onClick:()=>o.openSettings?.(),children:[(0,G.jsx)(nt,{"aria-hidden":`true`}),` Settings`]})]}):null]})]})]})]}),(0,G.jsxs)(`div`,{className:`design-body`,children:[N&&a.agentColumn!==!1?(0,G.jsx)(li,{title:a.agentColumnTitle,heading:a.AgentHeader?(0,G.jsx)(a.AgentHeader,{target:c}):void 0,hostLabel:Oe&&!a.AgentHeader?a.thread?.label:void 0,onOpenThread:c?.threadId&&o.returnToThread?()=>f?Me(f,`panel`):o.returnToThread?.(c):void 0,onCollapse:()=>P(!1),card:null,thread:Oe&&c?a.thread.render(c):a.AgentPanel?(0,G.jsx)(a.AgentPanel,{target:c}):null}):null,(0,G.jsxs)(`main`,{className:`design-main`,children:[(0,G.jsxs)(`div`,{className:`design-canvas-topleft`,children:[N||a.agentColumn===!1?null:(0,G.jsx)(ui,{onOpen:()=>P(!0)}),z&&!be&&!S?(0,G.jsx)(Cf,{open:T,onOpenChange:E,tab:C,onTabChange:w,counts:e,query:j,onQueryChange:M,comments:Je,children:C===`Comments`?null:(0,G.jsx)(xf,{tab:C,document:z,onOpen:Me,selection:m.selection,select:h,context:m.context,query:j})}):null]}),rt]})]}),it]})}return(0,G.jsxs)(`section`,{className:`design-workspace design-workspace-pane${be?` design-workspace-comparing`:``}`,"aria-label":`P4 Design workspace`,children:[(0,G.jsxs)(`header`,{className:`design-header`,children:[(0,G.jsxs)(`div`,{className:`design-heading`,children:[(0,G.jsx)(Or,{target:c,path:f,paths:p.paths,entries:p.entries,linkedPaths:b,statuses:y,onStartDesign:c&&o.startDesign?()=>o.startDesign?.(c):void 0,onStartDesignInNewThread:c&&o.startDesignInNewThread?()=>o.startDesignInNewThread?.(c):void 0,onManageDesigns:c&&o.manageDesigns?()=>o.manageDesigns?.(c):void 0,onOpen:e=>Me(e),open:D,onOpenChange:O}),f&&c?(0,G.jsx)(ir,{target:c,path:f,revision:m.contentHash,fileHash:m.fileHash??``,disabled:Xe||!!ye||!m.fileHash,compact:!0,onCompare:Ie},`${c.environmentId}:${c.projectId}:${c.threadId}:${f}`):(0,G.jsx)(`span`,{className:`design-small-muted`,children:`Project designs`})]}),(0,G.jsxs)(`div`,{className:`design-header-actions`,children:[tt,(0,G.jsx)(lr,{target:c,path:f,revision:m.contentHash,iconOnly:!0}),c&&f?(0,G.jsxs)(jt,{children:[(0,G.jsx)(Ot,{render:(0,G.jsx)(W,{size:`icon-sm`,variant:`ghost`,"aria-label":`Expand design`,onClick:()=>Me(f,`workspace`)}),children:(0,G.jsx)(Ge,{"aria-hidden":`true`})}),(0,G.jsx)(kt,{children:`Expand design`})]}):null,c?(0,G.jsxs)(On,{children:[(0,G.jsxs)(jt,{children:[(0,G.jsx)(Ot,{render:(0,G.jsx)(kn,{render:(0,G.jsx)(W,{size:`icon-sm`,variant:`ghost`,"aria-label":`More actions`})}),children:(0,G.jsx)(je,{"aria-hidden":`true`})}),(0,G.jsx)(kt,{children:`More actions`})]}),(0,G.jsxs)(An,{align:`end`,className:`w-56`,children:[(0,G.jsxs)(jn,{disabled:!l,onClick:()=>{he(`import`),pe(!0)},children:[(0,G.jsx)(_e,{"aria-hidden":`true`}),` Import / export…`]}),(0,G.jsxs)(jn,{onClick:()=>{g(),p.reload()},children:[(0,G.jsx)(Qe,{"aria-hidden":`true`}),` Reload design`]})]})]}):null]})]}),(0,G.jsx)(`nav`,{className:`design-pane-tabs`,"aria-label":`Design views`,children:[`Canvas`,`Layers`,`Inspect`,`Comments`].map(e=>(0,G.jsx)(`button`,{type:`button`,"aria-current":k===e?`page`:void 0,onClick:()=>A(e),children:e},e))}),(0,G.jsx)(`main`,{className:`design-main ${k===`Canvas`?``:`design-main-hidden`}`,children:rt}),k===`Layers`?(0,G.jsx)(`div`,{className:`design-pane-content`,children:z?(0,G.jsx)(bf,{document:z,selection:m.selection,select:h}):(0,G.jsx)(hf,{title:`No layers yet`})}):null,k===`Inspect`?(0,G.jsx)(`div`,{className:`design-pane-content`,children:z?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Tf,{document:z,selection:m.selection,theme:Te,context:m.context}),be?(0,G.jsx)(`p`,{className:`design-author-hint`,children:`Exit compare to comment or attach a selection.`}):null,m.selection.length&&m.contentHash&&B&&!be?(0,G.jsx)(`div`,{className:`design-inspector-actions`,children:(0,G.jsx)(W,{size:`sm`,variant:`outline`,onClick:()=>ze({documentPath:f,revision:m.contentHash,nodeIds:m.selection}),children:`Attach selection`})}):null]}):(0,G.jsx)(hf,{title:`Nothing to inspect`})}):null,k===`Comments`?(0,G.jsx)(`div`,{className:`design-pane-content`,children:Je}):null,_.error?(0,G.jsx)(`p`,{className:`design-review-error`,role:`alert`,children:_.error}):null,it]})}var If=`Create a new design in this project. Read design_guide, inspect the project's existing components and styles, then use design_apply to create a .p4design document. Validate and render it for review. Ask me what to design if my request is incomplete.`,Lf=[],Rf={label:`Other thread`,tone:`outline`};function zf(e,t){let n=(0,U.c)(10),r;n[0]!==t||n[1]!==e.environmentId?(r=O(e.environmentId,t),n[0]=t,n[1]=e.environmentId,n[2]=r):r=n[2];let i;n[3]===r?i=n[4]:(i=[r],n[3]=r,n[4]=i);let a=ft(i),o;if(n[5]!==a||n[6]!==e.threadId){let t;n[8]===e.threadId?t=n[9]:(t=t=>t.id!==e.threadId&&t.archivedAt===null&&t.deletedAt===null,n[8]=e.threadId,n[9]=t),o=new Map(a.filter(t).flatMap(Bf)),n[5]=a,n[6]=e.threadId,n[7]=o}else o=n[7];return o}function Bf(e){return e.designs.map(Vf)}function Vf(e){return[e.path,Rf]}function Hf({threadRef:e,composerTarget:t,workspace:r=!1,projectId:i,projectName:s,workspaceRoot:c,documentPath:l}){let u=(0,H.useContext)(ee),d=Et(e.environmentId),f=pt(e),p=Tn(),m=Tt(),h=f?.designs,g=(0,H.useMemo)(()=>h?.map(e=>e.path)??Lf,[h]),_=n(bn.permissionAtom(e.environmentId)),v=(0,H.useMemo)(()=>({environmentId:e.environmentId,projectId:i,...f?{threadId:e.threadId}:{}}),[e.environmentId,e.threadId,i,!!f]),y=d?.connection.phase===`connected`,b=(0,H.useMemo)(()=>Cn(u),[u]),x=(0,H.useRef)(null);(0,H.useEffect)(()=>{u.refresh(b.catalog(v))},[u,b,v,f?.latestRun?.runId,f?.runtime?.status,h]);let S=(0,H.useMemo)(()=>{let n=e=>{let n=a.getState(),r=n.draftsByThreadKey[j(t)]?.prompt??``;n.setPrompt(t,r.trim()?`${r}\n\n${e}`:e)},r=()=>n(If);return{runtime:mt,transport:b,agentColumn:!1,attachment:{current:()=>{let e=x.current,n=a.getState().draftsByThreadKey[j(t)];return e&&n?.files.some(t=>t.id===e.fileId)?e:void 0},set:(e,n,r)=>{let i=a.getState();if(x.current&&i.removeFile(t,x.current.fileId),x.current=null,!n)return;let s=new File([JSON.stringify(n,null,2)],`${r?.name??`Design selection`}.json`,{type:`application/json`}),c=o.make(ae());i.addFiles(t,[{type:`file`,id:c,name:s.name,mimeType:s.type,sizeBytes:s.size,file:s}]).includes(c)&&(x.current={selection:n,fileId:c})}},useConnected:()=>y,useCanWrite:()=>_,navigation:{linkEnvironment:!0,useTarget:()=>v,useActivePath:()=>l??null,useWorkspaceRoot:()=>c,useProjects:()=>[{environmentId:v.environmentId,projectId:i,name:s}],openProject:()=>Dt.getState().open(e,`design`),openDocument:(t,n,r)=>{Dt.getState().openFile(e,n),r===`workspace`&&Dt.getState().setMaximized(e,!0)},returnToThread:()=>Dt.getState().setMaximized(e,!1),startDesign:r,startDesignInNewThread:()=>void p(O(e.environmentId,i)).then(e=>{e&&a.getState().setPrompt(e.draftId,If)}),manageDesigns:()=>void m({to:`/settings/designs`}),useLinkedPaths:()=>g,useDocumentStatuses:()=>zf(e,i)},review:{},useCanvasPlaceholder:(e,t)=>!l&&!t.loading&&!t.failed&&t.paths.length===0?(0,G.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,G.jsx)(`h2`,{className:`text-lg font-medium`,children:`Design with your agent`}),(0,G.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:`Describe what you want in this thread. Designs appear here as your agent creates them.`}),(0,G.jsx)(oe,{onClick:r,disabled:!_,children:`Start a design`})]}):null}},[b,v,t,e,i,s,c,l,y,_,p,m,g,f?.latestRun?.runId,f?.runtime?.status===`running`]);return(0,G.jsx)(Jn,{host:S,children:(0,G.jsx)(`div`,{className:`h-full min-h-0 min-w-0 flex-1`,children:(0,G.jsx)(Ff,{surface:r?`workspace`:`panel`})})})}export{Hf as default};
19
+ //# sourceMappingURL=EmbeddedDesign-etv-YYdL.js.map