dorkos 0.119.0 → 0.121.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (319) hide show
  1. package/dist/bin/cli.js +3332 -2835
  2. package/dist/browser/native/package-manifest.json +1 -1
  3. package/dist/browser/source-manifest.json +1 -1
  4. package/dist/client/assets/{AboutPage-DPEGtCwv.js → AboutPage-CtI8gbER.js} +1 -1
  5. package/dist/client/assets/{ActivityErrorState-ENqFKw2l.js → ActivityErrorState-CHTXfBS7.js} +1 -1
  6. package/dist/client/assets/{ActivityPage-Bh3Fhkkr.js → ActivityPage-B8p4yYJL.js} +1 -1
  7. package/dist/client/assets/{ActivityRow-Mj9YGZo2.js → ActivityRow-CSuSz-92.js} +1 -1
  8. package/dist/client/assets/{AdapterIcon-BcejWkC-.js → AdapterIcon-Qnxn0cE5.js} +1 -1
  9. package/dist/client/assets/{AdapterSetupWizard-CEnUjD84.js → AdapterSetupWizard-BG8H-Lld.js} +1 -1
  10. package/dist/client/assets/{AgentOptionRow-DcKMOkUs.js → AgentOptionRow-BWFQFynn.js} +1 -1
  11. package/dist/client/assets/{AgentPicker-W6XeKjz9.js → AgentPicker-CL93SET3.js} +1 -1
  12. package/dist/client/assets/{AgentRequestCard-C8xPf4Ij.js → AgentRequestCard-CamX7Tvr.js} +3 -3
  13. package/dist/client/assets/{AppearancePage-uoWRNL1C.js → AppearancePage-rN70_7ih.js} +1 -1
  14. package/dist/client/assets/{ApplyToOverridesDialog-C5Nf8pjH.js → ApplyToOverridesDialog-DeWaXbgm.js} +1 -1
  15. package/dist/client/assets/{AttentionSignalRow-BI-uQ-ay.js → AttentionSignalRow-CKcSWExi.js} +1 -1
  16. package/dist/client/assets/{BaseTanStackRouterDevtoolsPanel-B-iktbLX-Cpi-0c7y.js → BaseTanStackRouterDevtoolsPanel-B-iktbLX-BwYaLf2P.js} +1 -1
  17. package/dist/client/assets/{BindingDialog-B3vCYvfL.js → BindingDialog-DqPDLYbF.js} +1 -1
  18. package/dist/client/assets/BlintzCanvas-DoAZs5bz.js +1231 -0
  19. package/dist/client/assets/{BlintzCanvas-GgiCXV7C.css → BlintzCanvas-xZ3u3nk7.css} +1 -1
  20. package/dist/client/assets/{CanvasCsvContent-DtZuAo03.js → CanvasCsvContent-ViqRJuhW.js} +1 -1
  21. package/dist/client/assets/CanvasFileContent-ClcHZ_l-.js +2 -0
  22. package/dist/client/assets/{CanvasModel3dContent-BlYcTOLd.js → CanvasModel3dContent-Cm3msNdQ.js} +2 -2
  23. package/dist/client/assets/{ChatAppsOff-B996C06C.js → ChatAppsOff-D0PbHYqF.js} +1 -1
  24. package/dist/client/assets/{CodeMirrorDiff-UfNeO6Wa.js → CodeMirrorDiff-DFNSXeuV.js} +1 -1
  25. package/dist/client/assets/{CodeMirrorEditor-BMSnTJnS.js → CodeMirrorEditor-AgkgsSqN.js} +1 -1
  26. package/dist/client/assets/{CommitmentList-LBnn140g.js → CommitmentList-0V6QivXH.js} +1 -1
  27. package/dist/client/assets/{CommitmentsPage-BNEP939u.js → CommitmentsPage-i3XoHwBj.js} +1 -1
  28. package/dist/client/assets/{ComputerResourceView-C97PoLhs.js → ComputerResourceView-RPoBc-km.js} +1 -1
  29. package/dist/client/assets/{ComputerViewer-DVaP4S-x.js → ComputerViewer-2ugaCd0H.js} +1 -1
  30. package/dist/client/assets/{ConnectionAccessLists-COotkMKW.js → ConnectionAccessLists-DaPP4U96.js} +1 -1
  31. package/dist/client/assets/{ConnectionsPage-DMqldmCl.js → ConnectionsPage-BVqYvfk5.js} +2 -2
  32. package/dist/client/assets/{ConventionPage-DXcAUNjb.js → ConventionPage-BoqncrFd.js} +1 -1
  33. package/dist/client/assets/{ExtensionPageRoute-Cx-zCEnS.js → ExtensionPageRoute-BrOEeNX3.js} +2 -2
  34. package/dist/client/assets/{FloatingTanStackRouterDevtools-CqogiFob-U9QmMzNM.js → FloatingTanStackRouterDevtools-CqogiFob-DLwix3K7.js} +1 -1
  35. package/dist/client/assets/HandlePage-B_5GLHsp.js +1 -0
  36. package/dist/client/assets/{HeartbeatPage-lS53N7qR.js → HeartbeatPage-DgXhbaBJ.js} +1 -1
  37. package/dist/client/assets/KeyEntry-CRr32Ae5.js +1 -0
  38. package/dist/client/assets/{LexicalField-NpV0yrX5.js → LexicalField-DeAoA6yr.js} +1 -1
  39. package/dist/client/assets/{ManagesPage-Dvjt_Ql0.js → ManagesPage-ZBWYLTZx.js} +1 -1
  40. package/dist/client/assets/{Marketplace-BXrL6XrG.js → Marketplace-iL5p8Omt.js} +4 -4
  41. package/dist/client/assets/{MarketplaceSourcesView-Xm9UboIG.js → MarketplaceSourcesView-CsNLVOdP.js} +1 -1
  42. package/dist/client/assets/{McpAppFrame-BOhSmDHb.js → McpAppFrame-B1WPswgk.js} +1 -1
  43. package/dist/client/assets/McpSigninBody-CJ28yu0o.js +1 -0
  44. package/dist/client/assets/{Model3dViewer-B0efG9VW.js → Model3dViewer-BIZWdK8g.js} +1 -1
  45. package/dist/client/assets/NamePage-0nr288eM.js +1 -0
  46. package/dist/client/assets/{NewDirectMessageMenu-BOwmahin.js → NewDirectMessageMenu-DRx9e9kM.js} +1 -1
  47. package/dist/client/assets/{NotificationsPage-pQg9DtG3.js → NotificationsPage-cfqgSuVy.js} +1 -1
  48. package/dist/client/assets/{OpenMeshSwitch-C5dCRdqs.js → OpenMeshSwitch-BIIuKDku.js} +1 -1
  49. package/dist/client/assets/{OperatorIdentityForm-CgSvpX-s.js → OperatorIdentityForm-BKUSGrs6.js} +1 -1
  50. package/dist/client/assets/{PermissionHistory-ChEe8iYR.js → PermissionHistory-Ctdqhib6.js} +1 -1
  51. package/dist/client/assets/{PermissionsPage-C8gICIw9.js → PermissionsPage-CYA_zdrV.js} +1 -1
  52. package/dist/client/assets/{PersonalityPopover-DcuHjnIT.js → PersonalityPopover-BR4Cpr2C.js} +1 -1
  53. package/dist/client/assets/PhotoPage-C3Ir3wlA.js +1 -0
  54. package/dist/client/assets/{PresetPicker-C-HcfktA.js → PresetPicker-zGvDOqTf.js} +2 -2
  55. package/dist/client/assets/{PreviewRefusedNotice-CgJeWKad.js → PreviewRefusedNotice-D1Tl265t.js} +1 -1
  56. package/dist/client/assets/{ProfileFields-Bpe71duM.js → ProfileFields-T3vVbHRC.js} +1 -1
  57. package/dist/client/assets/{ProfilePanelContainer-r2T2nLuy.js → ProfilePanelContainer-CParzTPA.js} +1 -1
  58. package/dist/client/assets/{ProfileRolePicker-B9as28eL.js → ProfileRolePicker-BU4eiMKn.js} +1 -1
  59. package/dist/client/assets/{PromptSuggestionChips-BjyRYcZH.js → PromptSuggestionChips-CGNQc2Tf.js} +1 -1
  60. package/dist/client/assets/{ReportsToPopover-Bs59IbmP.js → ReportsToPopover-Dj5U_Ppi.js} +1 -1
  61. package/dist/client/assets/{RoomSurface-CcxCucEt.js → RoomSurface-BIyjtxKD.js} +7 -7
  62. package/dist/client/assets/{RoomsPage-gAEppmDN.js → RoomsPage-Cvs3h6f0.js} +1 -1
  63. package/dist/client/assets/{RunsOnPopover-BYqbPh-k.js → RunsOnPopover-BUlYwRW4.js} +1 -1
  64. package/dist/client/assets/{RuntimeConnectFlow-BmMBE_ki.js → RuntimeConnectFlow-ChrvjC84.js} +1 -1
  65. package/dist/client/assets/{RuntimeSetupDialog-DsDi5RBn.js → RuntimeSetupDialog-BK9yo7YF.js} +1 -1
  66. package/dist/client/assets/{SessionsPage-Cid8fhdk.js → SessionsPage-CWUwU3US.js} +1 -1
  67. package/dist/client/assets/SettingsDialog-BApzy0J8.js +12 -0
  68. package/dist/client/assets/{SkillsPage-YiAaBf5n.js → SkillsPage-z3XnApNX.js} +1 -1
  69. package/dist/client/assets/{TaskDialogWrapper-BZ19n03x.js → TaskDialogWrapper-BEWUpAlk.js} +1 -1
  70. package/dist/client/assets/{TasksEmptyState-RqhzTXZs.js → TasksEmptyState-CLwpLnIO.js} +2 -2
  71. package/dist/client/assets/{TasksPage-CkaqOq26.js → TasksPage-CyHjr9OZ.js} +1 -1
  72. package/dist/client/assets/{TeamComputerEntry-BFwHEcxT.js → TeamComputerEntry-BHHIofx3.js} +1 -1
  73. package/dist/client/assets/{ToolsPage-BnCLKQr8.js → ToolsPage-CckCco8x.js} +2 -2
  74. package/dist/client/assets/TopologyGraph-Dox7aWP3.js +30 -0
  75. package/dist/client/assets/{TourHost-D6Lclw6P.js → TourHost-CTBewD-a.js} +1 -1
  76. package/dist/client/assets/{UnlinkDialog-DqKrNRIZ.js → UnlinkDialog-CFRgExId.js} +1 -1
  77. package/dist/client/assets/{WidgetErrorCard-YpoGnbGt.js → WidgetErrorCard-Dx5oPMlF.js} +3 -3
  78. package/dist/client/assets/_commonjs-dynamic-modules-TDtrdbi3.js +1 -0
  79. package/dist/client/assets/_shell-BHUZq_8C.js +80 -0
  80. package/dist/client/assets/{_shell._home-BcVOIprN.js → _shell._home-DnBkgWs4.js} +1 -1
  81. package/dist/client/assets/{_shell._home.activity-B-5keh6v.js → _shell._home.activity-CVCC-EEI.js} +1 -1
  82. package/dist/client/assets/{_shell._home.index-CeUO_fiS.js → _shell._home.index-Ck6jxwIx.js} +1 -1
  83. package/dist/client/assets/{_shell._home.tasks-DrghkSwu.js → _shell._home.tasks-B7QQAZnA.js} +1 -1
  84. package/dist/client/assets/{_shell._home.workspaces-ClpXSXb7.js → _shell._home.workspaces-DlrRd9tv.js} +1 -1
  85. package/dist/client/assets/_shell.channels-CiWehoyl.js +10 -0
  86. package/dist/client/assets/{_shell.connections-BAyaKCu0.js → _shell.connections-CGP5hZHq.js} +1 -1
  87. package/dist/client/assets/{_shell.feedback-requests-C_0Cb9ew.js → _shell.feedback-requests-BxxNvw6j.js} +1 -1
  88. package/dist/client/assets/_shell.marketplace-BoAmyvPt.js +1 -0
  89. package/dist/client/assets/_shell.marketplace_.sources-BpqWjkGL.js +1 -0
  90. package/dist/client/assets/{_shell.session-DAOicD3_.js → _shell.session-KyPj3OxK.js} +17 -17
  91. package/dist/client/assets/{_shell.team-C9JBEYch.js → _shell.team-CsXH3NkS.js} +6 -6
  92. package/dist/client/assets/_shell.x._extensionId-CfiAgtoq.js +1 -0
  93. package/dist/client/assets/_shell.x._extensionId_._-CfiAgtoq.js +1 -0
  94. package/dist/client/assets/abnfDiagram-WEYOIA3C-CMdkyiQ3.js +1 -0
  95. package/dist/client/assets/{access-copy-DBchOVu9.js → access-copy-CW-z1oMH.js} +1 -1
  96. package/dist/client/assets/arc-Bw7tftQk.js +1 -0
  97. package/dist/client/assets/architectureDiagram-ZHVYKT53-BhpXALtX.js +36 -0
  98. package/dist/client/assets/{banner-DyAc42ob.js → banner-EomQNDOH.js} +1 -1
  99. package/dist/client/assets/blockDiagram-RJAE7QA3-Bxk_BuZv.js +140 -0
  100. package/dist/client/assets/c4Diagram-XDPPPE54-CYN0FwR8.js +38 -0
  101. package/dist/client/assets/{card-B1UFbnvJ.js → card-ww4ebz8h.js} +1 -1
  102. package/dist/client/assets/channel-DZpRF3QJ.js +1 -0
  103. package/dist/client/assets/chunk-2E7WHVMD-IPDvYcPa.js +88 -0
  104. package/dist/client/assets/chunk-2Q5K7J3B-DZ5bU5Ax.js +1 -0
  105. package/dist/client/assets/chunk-4EMNKR2T-DrsWxa6Y.js +1 -0
  106. package/dist/client/assets/chunk-55XCU76K-CiBbKG0b.js +1 -0
  107. package/dist/client/assets/chunk-5VM5RSS4-B3K3MUav.js +15 -0
  108. package/dist/client/assets/chunk-JWPE2WC7-CjV5RcIh.js +1 -0
  109. package/dist/client/assets/chunk-VQ5W62QI-CWoRr0H2.js +1 -0
  110. package/dist/client/assets/chunk-XXDRQBXY-E0nvzXiG.js +1 -0
  111. package/dist/client/assets/chunk-ZCHMQSOR-DFop6Lvt.js +2 -0
  112. package/dist/client/assets/classDiagram-v2-4MYWR3UA-B7JJfc9z.js +217 -0
  113. package/dist/client/assets/{command-EveETx4P.js → command-D4fLpJxA.js} +1 -1
  114. package/dist/client/assets/cose-bilkent-JH36ORCC-BjNppl29.js +1 -0
  115. package/dist/client/assets/{cpu-6HIzSTBv.js → cpu-DCe0Yyml.js} +1 -1
  116. package/dist/client/assets/cynefin-EF2NZ3EQ-PmRntJwW.js +141 -0
  117. package/dist/client/assets/cynefinDiagram-WF24UDRP-Ctdbp_Vg.js +62 -0
  118. package/dist/client/assets/cytoscape.esm-BLAcgzS2.js +331 -0
  119. package/dist/client/assets/dagre-NK4GIZVX-5tvLY2ZW.js +4 -0
  120. package/dist/client/assets/defaultLocale-DX6XiGOO.js +1 -0
  121. package/dist/client/assets/diagram-CBK3MWTC-DZO-XBOO.js +24 -0
  122. package/dist/client/assets/diagram-I5XIIV2D-CWBbA1Pv.js +24 -0
  123. package/dist/client/assets/diagram-ODIL2UCW-hP5A1tGl.js +30 -0
  124. package/dist/client/assets/diagram-PFBEJUXE-EI_-RoN7.js +3 -0
  125. package/dist/client/assets/diagram-RJA3I4VV-TrYq9A4Z.js +41 -0
  126. package/dist/client/assets/diagram-TYUNFSNR-BAQq2OM5.js +200 -0
  127. package/dist/client/assets/ebnfDiagram-V4P3TTPT-cKbeW9dQ.js +1 -0
  128. package/dist/client/assets/elk-QONTBCTQ-wpfNPp0q.js +27 -0
  129. package/dist/client/assets/{empty-state-DK2Wg9m3.js → empty-state-DXWQsHMf.js} +1 -1
  130. package/dist/client/assets/erDiagram-KYQIGQAA-Dk0OrvjE.js +99 -0
  131. package/dist/client/assets/{execution-config-e5c_6oSg.js → execution-config-CAyT2Qoo.js} +1 -1
  132. package/dist/client/assets/{file-CxdN5JO4.js → file-Bf7D_47y.js} +1 -1
  133. package/dist/client/assets/{file-exclamation-point-ID9vXo0l.js → file-exclamation-point-DZXE9_8o.js} +1 -1
  134. package/dist/client/assets/{file-text-DtcloCeg.js → file-text-C1ougnBY.js} +1 -1
  135. package/dist/client/assets/{find-latest-widget-fence-BGZDFnjV.js → find-latest-widget-fence-B1_-pC-Z.js} +1 -1
  136. package/dist/client/assets/flowDiagram-IUGLLWBU-CdlOoRZV.js +213 -0
  137. package/dist/client/assets/{form-Bs1x_gSI.js → form-D7kF-U0d.js} +1 -1
  138. package/dist/client/assets/{format-cron-i_Bh2HP3.js → format-cron-ZtliseYi.js} +1 -1
  139. package/dist/client/assets/ganttDiagram-R7GPNTJY-x0MJLv5d.js +292 -0
  140. package/dist/client/assets/{git-branch-B3IXXOlG.js → git-branch-B2k77X3Q.js} +1 -1
  141. package/dist/client/assets/gitGraphDiagram-PDYL7XHY-CruCvk7w.js +106 -0
  142. package/dist/client/assets/graph-5PBe05F8.js +1 -0
  143. package/dist/client/assets/{heart-BKVGdKg5.js → heart-CmqGJPDc.js} +1 -1
  144. package/dist/client/assets/{highlighted-body-KPVGNVTW-2S9TnGZL.js → highlighted-body-KPVGNVTW-Bqu2cQDj.js} +1 -1
  145. package/dist/client/assets/{image-lightbox-D28E719A.js → image-lightbox-BBbz-ThL.js} +1 -1
  146. package/dist/client/assets/{image-off-BuNZtQ_w.js → image-off-BCtWIY4q.js} +1 -1
  147. package/dist/client/assets/{index-LPr-pCZr.js → index-1ShgR_xt.js} +1 -1
  148. package/dist/client/assets/{index-V5Rn9SxH.js → index-8IAr9b71.js} +1 -1
  149. package/dist/client/assets/{index-rROsmUvj.js → index-8TfzCkKR.js} +1 -1
  150. package/dist/client/assets/{index-CsUyZMaJ.js → index-B5rRtvWx.js} +1 -1
  151. package/dist/client/assets/index-B6dEbNhI.js +1 -0
  152. package/dist/client/assets/{index-7cQQSs20.js → index-BCk4wW-T.js} +1 -1
  153. package/dist/client/assets/{index-CfpVrvtk.js → index-BIIH5CXj.js} +1 -1
  154. package/dist/client/assets/{index-DP_WiQNC.js → index-BXMxoWrk.js} +1 -1
  155. package/dist/client/assets/index-BXZlDqvy.js +74 -0
  156. package/dist/client/assets/{index-5081rTdO.js → index-BfRW2WTx.js} +1 -1
  157. package/dist/client/assets/{index-DVpRV8UX.js → index-BpmmNapD.js} +1 -1
  158. package/dist/client/assets/{index-CQ_s1Luo.js → index-BrQGZ6iF.js} +1 -1
  159. package/dist/client/assets/{index-KONo3kU0.js → index-BuGQxHrf.js} +1 -1
  160. package/dist/client/assets/{index-BM9n-UZ_.js → index-BzPgsdPn.js} +1 -1
  161. package/dist/client/assets/{index-ByUBGmdN.js → index-C11Ssk2u.js} +3 -3
  162. package/dist/client/assets/{index-Ce9sdGIU.js → index-CJ5v2_Cz.js} +1 -1
  163. package/dist/client/assets/{index-CIxwv14l.js → index-CMNc_OrC.js} +1 -1
  164. package/dist/client/assets/{index-ClxqCDE6.js → index-CQ0VLZf-.js} +1 -1
  165. package/dist/client/assets/{index-CHZfO-eM.js → index-ChwNEkM8.js} +1 -1
  166. package/dist/client/assets/index-Cl8trmnL.js +1 -0
  167. package/dist/client/assets/{index-CDBp2azY.js → index-ClBIPuLA.js} +1 -1
  168. package/dist/client/assets/{index-CtRknSis.js → index-Cml5572f.js} +1 -1
  169. package/dist/client/assets/{index-DIpkbx_g.js → index-Cp3yShS8.js} +7 -7
  170. package/dist/client/assets/index-CrflCTqO.css +1 -0
  171. package/dist/client/assets/{index-CJllc1_e.js → index-CtycM8wY.js} +1 -1
  172. package/dist/client/assets/{index-DVUGIueq.js → index-Cv0GsC4n.js} +1 -1
  173. package/dist/client/assets/{index-CqcPXANi.js → index-DAdo_yIq.js} +1 -1
  174. package/dist/client/assets/{index-DwKOsAwH.js → index-DIxzqCwG.js} +1 -1
  175. package/dist/client/assets/index-DKDK-3KH.js +17 -0
  176. package/dist/client/assets/index-DPNBHwcQ.js +1 -0
  177. package/dist/client/assets/{index-B-wVtE7g.js → index-DbDI5BAA.js} +1 -1
  178. package/dist/client/assets/index-DcZPWi_I.js +1023 -0
  179. package/dist/client/assets/{index-Pcm0P4su.js → index-Dmn03xST.js} +1 -1
  180. package/dist/client/assets/{index-BUAYrK-t.js → index-Do6eeFps.js} +2 -2
  181. package/dist/client/assets/{index-CAB4SfyK.js → index-DrA03bMq.js} +1 -1
  182. package/dist/client/assets/{index-5BVp-usS.js → index-DsJWzmWw.js} +1 -1
  183. package/dist/client/assets/{index-Cc5UdmnD.js → index-EdJm7ZN-.js} +1 -1
  184. package/dist/client/assets/{index-CxYD3BRB.js → index-JxeBJIuE.js} +1 -1
  185. package/dist/client/assets/{index-Dr3MaxIU.js → index-mFOJXyAE.js} +3 -3
  186. package/dist/client/assets/{index-uukEE2As.js → index-rWZWP3Wh.js} +1 -1
  187. package/dist/client/assets/{index-CFo8WKHw.js → index-t4Ud6YTX.js} +1 -1
  188. package/dist/client/assets/{index-DaFf8fyv.js → index-xaMF1mrN.js} +1 -1
  189. package/dist/client/assets/{index-DrBU917j.js → index-xmk9Ohv9.js} +1 -1
  190. package/dist/client/assets/{index-OTmqX-Xu.js → index-yI1r4pSP.js} +1 -1
  191. package/dist/client/assets/{index.esm-C1I5Nd91.js → index.esm-CZZtbPRj.js} +1 -1
  192. package/dist/client/assets/infoDiagram-MVDRKAX5-Bj9DD77n.js +2 -0
  193. package/dist/client/assets/init-Gi6I4Gst.js +1 -0
  194. package/dist/client/assets/{inline-code-BxjIkZsu.js → inline-code-g9PVHZI2.js} +1 -1
  195. package/dist/client/assets/ishikawaDiagram-HPEHV2GE-DckI6dhS.js +70 -0
  196. package/dist/client/assets/journeyDiagram-BOSHW7O7-Ce1GAVa0.js +139 -0
  197. package/dist/client/assets/kanban-definition-FNSA4HC5-Kq5O9rZa.js +89 -0
  198. package/dist/client/assets/katex-DLorvT8M.js +257 -0
  199. package/dist/client/assets/{layers-CIuBDynf.js → layers-D3lEdRF0.js} +1 -1
  200. package/dist/client/assets/{lightbulb-C75cqB7d.js → lightbulb-BFE-KkFU.js} +1 -1
  201. package/dist/client/assets/linear-BT-xgETh.js +1 -0
  202. package/dist/client/assets/{link-2-g7crG37S.js → link-2-Dvb6g-2Q.js} +1 -1
  203. package/dist/client/assets/{list-runtime-types-GVPyyQUh.js → list-runtime-types-8YGEK3Al.js} +1 -1
  204. package/dist/client/assets/{markdown-content-siVxwwSU.js → markdown-content-Cqq_QMXA.js} +1 -1
  205. package/dist/client/assets/{mention-pill-CjxBxD6M.js → mention-pill-Bnzt4u2l.js} +1 -1
  206. package/dist/client/assets/mermaid.core-dpp59v7L.js +312 -0
  207. package/dist/client/assets/{message-square-off-BxuvD1QP.js → message-square-off-BX2XnEDx.js} +1 -1
  208. package/dist/client/assets/mindmap-definition-6OY57UG3-CFdfJO6g.js +98 -0
  209. package/dist/client/assets/{more-details-DN_gIeya.js → more-details-B4lBMpKi.js} +1 -1
  210. package/dist/client/assets/ordinal-Cboi1Yqb.js +1 -0
  211. package/dist/client/assets/{owner-notice-DnYrX3mh.js → owner-notice-ByjrIRmX.js} +1 -1
  212. package/dist/client/assets/{package-b8MxCYZr.js → package-6Rbxg35g.js} +1 -1
  213. package/dist/client/assets/{page-container-bbfE5uTV.js → page-container-DoZzad36.js} +1 -1
  214. package/dist/client/assets/{paperclip-BNBU7WUb.js → paperclip-B-jDXtxw.js} +1 -1
  215. package/dist/client/assets/{path-input-BhzVuKWq.js → path-input-DpqUD8hN.js} +1 -1
  216. package/dist/client/assets/pegDiagram-ECIUJNBX-eVnSw2Ma.js +1 -0
  217. package/dist/client/assets/pieDiagram-GNMPY74T-BYG7LY5Q.js +39 -0
  218. package/dist/client/assets/plug-DnaAhcy4.js +11 -0
  219. package/dist/client/assets/{primer-trigger-DHPWwwZl.js → primer-trigger-Da5ECjY8.js} +2 -2
  220. package/dist/client/assets/{profile-errors-DDvyjpcQ.js → profile-errors-GbTNc2-M.js} +1 -1
  221. package/dist/client/assets/{progress-DUKHwOZJ.js → progress-DlIRjXIA.js} +1 -1
  222. package/dist/client/assets/quadrantDiagram-D57K4MC3-CRgNKuHR.js +7 -0
  223. package/dist/client/assets/{query-error-state-DOJRiizQ.js → query-error-state-DB-Jby7_.js} +1 -1
  224. package/dist/client/assets/{radio-kbMW2w1m.js → radio-CaaE60ws.js} +1 -1
  225. package/dist/client/assets/railroadDiagram-Y72NRBL7-DGL-Hqz9.js +1 -0
  226. package/dist/client/assets/registry-DS1Ghdft.js +1 -0
  227. package/dist/client/assets/{relay-trace-schemas-3XV1_WMC.js → relay-trace-schemas-CcCqyOrA.js} +2 -2
  228. package/dist/client/assets/requirementDiagram-EQYSW5RA-DKsFpU3l.js +84 -0
  229. package/dist/client/assets/{room-files-source-CDA5V_Mw.js → room-files-source-CbbVpvSW.js} +1 -1
  230. package/dist/client/assets/{rotate-ccw-clock-BGYqHuYK.js → rotate-ccw-clock-CeY00nlZ.js} +1 -1
  231. package/dist/client/assets/{rotate-cw-BdJrGLyp.js → rotate-cw-Djl5J_x9.js} +1 -1
  232. package/dist/client/assets/sankeyDiagram-SY24JHO5-BFRkDxic.js +40 -0
  233. package/dist/client/assets/{scroll-area-D-CWiQov.js → scroll-area-BOqrziJf.js} +1 -1
  234. package/dist/client/assets/{search-x-DNIPyXe6.js → search-x-B_mHjnlo.js} +1 -1
  235. package/dist/client/assets/sequenceDiagram-BLEHNHQU-fHea3KOI.js +169 -0
  236. package/dist/client/assets/{shield-check-zWzf9nt2.js → shield-check-Csnr5rFy.js} +1 -1
  237. package/dist/client/assets/{shield-x-Bu5-LOse.js → shield-x-Dhl4YvvW.js} +1 -1
  238. package/dist/client/assets/signed-in-BMqAss8c.js +1 -0
  239. package/dist/client/assets/sizeCapture-INFHLROL-CztsD3qF.js +1 -0
  240. package/dist/client/assets/{soul-file-CoSSajv6.js → soul-file-DOfamgB5.js} +1 -1
  241. package/dist/client/assets/stateDiagram-v2-A6IESKWZ-CWyOqZ9S.js +291 -0
  242. package/dist/client/assets/swimlanes-B3ENRKFQ-0EfOxSAX.js +1 -0
  243. package/dist/client/assets/swimlanesDiagram-AYQRV4AK-C7fkUKrq.js +8 -0
  244. package/dist/client/assets/{table-Bt_aJtoi.js → table-L7FvN6Or.js} +1 -1
  245. package/dist/client/assets/{terminal-ub-ExeTA.js → terminal-C9M5a_PS.js} +1 -1
  246. package/dist/client/assets/timeline-definition-JXYKGLGB-sFyYvZ20.js +120 -0
  247. package/dist/client/assets/transform-BqqRT-Iy.js +1 -0
  248. package/dist/client/assets/{trust-posture-CWt3tUjL.js → trust-posture-dl6qwDtI.js} +1 -1
  249. package/dist/client/assets/{unplug-BCqRQfhH.js → unplug-CFUEVRbc.js} +1 -1
  250. package/dist/client/assets/{unverified-catalog-notice-CgvUEO5t.js → unverified-catalog-notice-CdYU3WEJ.js} +1 -1
  251. package/dist/client/assets/{use-adapter-catalog-ClW3m3Yz.js → use-adapter-catalog-YTofdqDJ.js} +1 -1
  252. package/dist/client/assets/{use-bindings-CFiTPDOx.js → use-bindings-CpyT6kNu.js} +1 -1
  253. package/dist/client/assets/{use-composer-prefs-B70wbKdU.js → use-composer-prefs-CK_EK_QJ.js} +1 -1
  254. package/dist/client/assets/{use-connector-management-B_mb2h8I.js → use-connector-management-DwoK8kon.js} +1 -1
  255. package/dist/client/assets/{use-deep-link-scroll-DuJW3UA9.js → use-deep-link-scroll-CgRjt48R.js} +1 -1
  256. package/dist/client/assets/{use-delete-binding-DWXownno.js → use-delete-binding-CfsnMXrL.js} +1 -1
  257. package/dist/client/assets/{use-dev-links-UPIkbIjA.js → use-dev-links-B3I-ZK34.js} +1 -1
  258. package/dist/client/assets/{use-external-adapter-catalog-x7pDUqmo.js → use-external-adapter-catalog-aGlZNRrp.js} +1 -1
  259. package/dist/client/assets/{use-full-activity-feed-l9UhDUNU.js → use-full-activity-feed-B61Olhdw.js} +1 -1
  260. package/dist/client/assets/use-is-below-desktop-Qwyg-mFb.js +1 -0
  261. package/dist/client/assets/use-is-hub-CSz6NDaP.js +1 -0
  262. package/dist/client/assets/{use-jump-back-in-CKA3z2by.js → use-jump-back-in-C39GOTHa.js} +3 -3
  263. package/dist/client/assets/{use-local-browser-DL5b5JIK.js → use-local-browser-DCwzB4D8.js} +1 -1
  264. package/dist/client/assets/{use-mesh-topology-BYGYArKq.js → use-mesh-topology-LRYxFuZp.js} +1 -1
  265. package/dist/client/assets/{use-mounted-ref-D_xUn22L.js → use-mounted-ref-CZaegwTr.js} +1 -1
  266. package/dist/client/assets/{use-notification-prefs-42ajom2z.js → use-notification-prefs-FtOiUS5H.js} +1 -1
  267. package/dist/client/assets/{use-panel-tab-placements-CLIDc7_z.js → use-panel-tab-placements-Dv2OPvKh.js} +1 -1
  268. package/dist/client/assets/use-pending-read-DBOl1ee_.js +1 -0
  269. package/dist/client/assets/{use-personality-commit-D7jyGUrF.js → use-personality-commit-BB5aeh6p.js} +1 -1
  270. package/dist/client/assets/use-promo-activation-BW0u7n7m.js +11 -0
  271. package/dist/client/assets/{use-promo-dismissals-CsJELZ1_.js → use-promo-dismissals-BOXzW4kD.js} +1 -1
  272. package/dist/client/assets/{use-pulse-freshness-TqSBTrFT.js → use-pulse-freshness-ClW-MLMo.js} +1 -1
  273. package/dist/client/assets/{use-relay-config-CLeVWrpV.js → use-relay-config-hItHtkSr.js} +1 -1
  274. package/dist/client/assets/{use-room-follow-claim-C-zlw4nh.js → use-room-follow-claim-wotzxUWc.js} +1 -1
  275. package/dist/client/assets/{use-roving-tab-list-H2EzOl9b.js → use-roving-tab-list-DkbO6xSs.js} +1 -1
  276. package/dist/client/assets/use-session-canvas-C_fuAgW_.js +24 -0
  277. package/dist/client/assets/{use-session-diagnostics-CDmiMYHx.js → use-session-diagnostics-DmxvD-wy.js} +3 -3
  278. package/dist/client/assets/{use-unclaimed-chats-Bd93jy-J.js → use-unclaimed-chats-DKpexDm3.js} +1 -1
  279. package/dist/client/assets/use-update-config-CSYwg557.js +1 -0
  280. package/dist/client/assets/{useMutationState-BZZ5TO4d.js → useMutationState-Btf2Hp1a.js} +1 -1
  281. package/dist/client/assets/usecaseDiagram-WPOLBNNX-DRngjDUq.js +370 -0
  282. package/dist/client/assets/value-wA6veExk.js +1 -0
  283. package/dist/client/assets/vennDiagram-Q3Y3IDCW-iK-dlS1-.js +34 -0
  284. package/dist/client/assets/wardleyDiagram-IVAIDKWA-sOS67Cks.js +78 -0
  285. package/dist/client/assets/xychartDiagram-4URNHDU4-EgnLiIao.js +7 -0
  286. package/dist/client/index.html +2 -2
  287. package/dist/drizzle/20261017113300_session_public_computer.sql +1 -0
  288. package/dist/drizzle/meta/20261017113300_snapshot.json +14020 -0
  289. package/dist/drizzle/meta/_journal.json +7 -0
  290. package/dist/server/index.js +24307 -20763
  291. package/dist/server/index.js.map +2 -2
  292. package/package.json +7 -7
  293. package/dist/client/assets/BlintzCanvas-D_HlpfZu.js +0 -1141
  294. package/dist/client/assets/CanvasFileContent-g5wQR7yt.js +0 -2
  295. package/dist/client/assets/HandlePage-DUFrvuVy.js +0 -1
  296. package/dist/client/assets/KeyEntry-tKXV9D24.js +0 -6
  297. package/dist/client/assets/McpSigninBody-CRj8tXsh.js +0 -1
  298. package/dist/client/assets/NamePage-fiIXQig_.js +0 -1
  299. package/dist/client/assets/PhotoPage-BnxmY5mq.js +0 -1
  300. package/dist/client/assets/SettingsDialog-BZkPlifY.js +0 -12
  301. package/dist/client/assets/TopologyGraph-CAkARLa1.js +0 -30
  302. package/dist/client/assets/_shell-BQ7hvFsP.js +0 -90
  303. package/dist/client/assets/_shell.channels-DYNK-rbr.js +0 -10
  304. package/dist/client/assets/_shell.marketplace-B1CT9Y3y.js +0 -1
  305. package/dist/client/assets/_shell.marketplace_.sources-DVHJ2s7a.js +0 -1
  306. package/dist/client/assets/_shell.x._extensionId-B6Ccjrvp.js +0 -1
  307. package/dist/client/assets/_shell.x._extensionId_._-B6Ccjrvp.js +0 -1
  308. package/dist/client/assets/index-BONR--d7.css +0 -1
  309. package/dist/client/assets/index-BULRe04c.js +0 -1018
  310. package/dist/client/assets/index-C8NfFfij.js +0 -17
  311. package/dist/client/assets/index-CRMbYKMh.js +0 -1
  312. package/dist/client/assets/index-CidWt_HE.js +0 -1
  313. package/dist/client/assets/index-CoMMwnLj.js +0 -74
  314. package/dist/client/assets/registry-BisJE2TH.js +0 -1
  315. package/dist/client/assets/use-is-below-desktop-ByiGZk3p.js +0 -1
  316. package/dist/client/assets/use-pending-read-Cy9OB3jX.js +0 -1
  317. package/dist/client/assets/use-promo-activation-Dw1KvykA.js +0 -11
  318. package/dist/client/assets/use-session-canvas-Bm_AzSm7.js +0 -24
  319. package/dist/client/assets/use-update-config-DjF61lwf.js +0 -1
@@ -1,24 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BlintzCanvas-D_HlpfZu.js","assets/index-BULRe04c.js","assets/index-BONR--d7.css","assets/index-Dr3MaxIU.js","assets/BlintzCanvas-GgiCXV7C.css","assets/CanvasFileContent-g5wQR7yt.js","assets/rotate-cw-BdJrGLyp.js","assets/index.esm-C1I5Nd91.js","assets/WidgetErrorCard-YpoGnbGt.js","assets/index-LPr-pCZr.js","assets/card-B1UFbnvJ.js","assets/progress-DUKHwOZJ.js","assets/markdown-content-siVxwwSU.js","assets/table-Bt_aJtoi.js","assets/terminal-ub-ExeTA.js","assets/package-b8MxCYZr.js","assets/heart-BKVGdKg5.js","assets/git-branch-B3IXXOlG.js","assets/file-text-DtcloCeg.js","assets/file-CxdN5JO4.js","assets/McpAppFrame-BOhSmDHb.js","assets/more-details-DN_gIeya.js","assets/CanvasModel3dContent-BlYcTOLd.js","assets/CanvasCsvContent-DtZuAo03.js","assets/index-OTmqX-Xu.js"])))=>i.map(i=>d[i]);
2
- var Lr=Object.defineProperty;var Gt=e=>{throw TypeError(e)};var Pr=(e,t,r)=>t in e?Lr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ee=(e,t,r)=>Pr(e,typeof t!="symbol"?t+"":t,r),dt=(e,t,r)=>t.has(e)||Gt("Cannot "+r);var Me=(e,t,r)=>(dt(e,t,"read from private field"),r?r.call(e):t.get(e)),Te=(e,t,r)=>t.has(e)?Gt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),ge=(e,t,r,n)=>(dt(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),ve=(e,t,r)=>(dt(e,t,"access private method"),r);import{W as at,lA as ct,fD as se,fO as Y,fH as $t,fK as qe,fE as $e,lB as Br,lC as Ur,lD as Wr,aX as Ce,a1 as ue,r as p,c6 as St,lE as Gr,aW as J,im as $r,j as d,hk as Hr,hl as Vr,e2 as Jr,G as Dt,I as Xr,fo as Zr,lF as Yr,lG as cr,lH as bt,lI as rt,lJ as ur,fC as Ht,lK as Qr,fF as Vt,lL as Kr,lM as en,gz as V,lN as tn,lO as rn,B as et,J as lr,go as dr,C as nn,lP as sn,lQ as on,lR as Jt}from"./index-BULRe04c.js";import{R as an}from"./rotate-cw-BdJrGLyp.js";import{T as cn,a as un,u as ln}from"./index.esm-C1I5Nd91.js";import{v as dn,a as fn,W as hn}from"./WidgetErrorCard-YpoGnbGt.js";import{M as pn}from"./McpAppFrame-BOhSmDHb.js";/**
3
- * @license lucide-react v1.48.0 - ISC
4
- *
5
- * This source code is licensed under the ISC license.
6
- * See the LICENSE file in the root directory of this source tree.
7
- */const fr={name:"file-code",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]};fr.node;const Pi=at(fr);/**
8
- * @license lucide-react v1.48.0 - ISC
9
- *
10
- * This source code is licensed under the ISC license.
11
- * See the LICENSE file in the root directory of this source tree.
12
- */const hr={name:"maximize",size:24,node:[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]};hr.node;const mn=at(hr);/**
13
- * @license lucide-react v1.48.0 - ISC
14
- *
15
- * This source code is licensed under the ISC license.
16
- * See the LICENSE file in the root directory of this source tree.
17
- */const pr={name:"zoom-in",size:24,node:[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]};pr.node;const gn=at(pr);/**
18
- * @license lucide-react v1.48.0 - ISC
19
- *
20
- * This source code is licensed under the ISC license.
21
- * See the LICENSE file in the root directory of this source tree.
22
- */const mr={name:"zoom-out",size:24,node:[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]};mr.node;const vn=at(mr),Oe={pending:64,queueBytes:1048576,batchMs:300,frames:62,imageChars:9e5,imageEdge:1568,resourceErrors:1e4},nt=$e().min(1).max(128),Ie={bridgeGeneration:nt},bn=se({...Ie,__dorkosDevtools:Y("capture-result"),requestId:nt,dataUrl:$e().max(9e5).optional(),error:$e().max(2048).optional()}),wn=Br.omit({hostOutcome:!0}).extend({...Ie,__dorkosDevtools:Y("act-result"),dataUrl:$e().max(9e5).optional()}),yn=Ur.extend({status:qe().int().min(0).max(599),durationMs:qe().min(0),responseSize:qe().int().min(0).max(Number.MAX_SAFE_INTEGER).optional(),timestamp:qe().min(0)}),xn=Wr.refine(e=>e.timestamp>=0),kn=ct("__dorkosDevtools",[se({__dorkosDevtools:Y("hello"),pageInstanceId:nt,bridgeVersion:Y(2)}),se({...Ie,__dorkosDevtools:Y("ready"),pageInstanceId:nt}),se({...Ie,__dorkosDevtools:Y("navigated")}),se({...Ie,__dorkosDevtools:Y("resource-error")}),se({...Ie,__dorkosDevtools:Y("batch"),seq:qe().int().min(0).max(Number.MAX_SAFE_INTEGER),console:$t(xn).max(500),network:$t(yn).max(200)}),bn,wn]);function jn(e){const t=new Set;let r=0,n=0;const s=c=>(n+=c)<=16384;function i(c){if(!s(2))return!1;for(let o=0;o<c.length;o++){const f=c.charCodeAt(o);if(f>=55296&&f<=56319&&o+1<c.length&&c.charCodeAt(o+1)>=56320&&c.charCodeAt(o+1)<=57343){if(!s(2))return!1;o++;continue}const l=f===34||f===92||[8,9,10,12,13].includes(f)?2:f<32||f>=55296&&f<=57343?6:1;if(!s(l))return!1}return!0}function a(c,o){if(++r>2048||o>8)return!1;if(c===null)return s(4);if(typeof c=="boolean")return s(c?4:5);if(typeof c=="string")return i(c);if(typeof c=="number")return Number.isFinite(c)&&s(String(c).length);if(typeof c!="object"||t.has(c))return!1;const f=Object.getPrototypeOf(c);if(f!==Object.prototype&&f!==null&&f!==Array.prototype)return!1;const l=Array.isArray(c);if(l&&c.length>2048||Object.getOwnPropertySymbols(c).length||!s(2))return!1;t.add(c);let h=0;for(const u in c){if(!Object.prototype.hasOwnProperty.call(c,u))continue;if(++h>2048||l&&(!/^\d+$/.test(u)||Number(u)>=c.length))return!1;const g=Object.getOwnPropertyDescriptor(c,u);if(["__proto__","constructor","prototype"].includes(u)||!("value"in g)||!g.enumerable||h>1&&!s(1)||!l&&(!i(u)||!s(1))||!a(g.value,o+1))return!1}return t.delete(c),!l||h===c.length}try{return a(e,0)}catch{return!1}}function Cn(e){try{if(!e||typeof e!="object")return null;const t=e;if(t.__dorkosDevtools==="capture-result"&&t.dataUrl===void 0&&t.error===void 0)return null;if(t.__dorkosDevtools==="batch"){if(!Array.isArray(t.console)||t.console.length>500||!Array.isArray(t.network)||t.network.length>200)return null;for(const s of t.console){if(!s||typeof s!="object")return null;const i=s.args;if(i!==void 0&&(!Array.isArray(i)||i.length>50||!jn(i)))return null}}const r=kn.safeParse(e);if(!r.success)return null;const n=r.data;return"dataUrl"in n&&n.dataUrl!==void 0&&!gr(n.dataUrl)?null:n}catch{return null}}function gr(e){if(e.length>9e5||!/^data:image\/png;base64,[A-Za-z0-9+/]+={0,2}$/.test(e))return null;try{const t=atob(e.slice(e.indexOf(",")+1));if(t.length<24||t.slice(0,8)!==`‰PNG\r
23
- 
24
- `||t.slice(12,16)!=="IHDR")return null;const r=i=>t.charCodeAt(i)*2**24+(t.charCodeAt(i+1)<<16)+(t.charCodeAt(i+2)<<8)+t.charCodeAt(i+3),n=r(16),s=r(20);return n>0&&s>0&&n<=1568&&s<=1568?{width:n,height:s}:null}catch{return null}}let ft=null;async function Xt(){return ft===null&&(ft=(await Ce(()=>import("./html-to-image-cl8bZGTj.js"),[])).default),ft}let ht=null;async function Rn(){if(ht===null){const e=await Ce(()=>import("./gifenc.esm-sOOlYEo8.js"),[]);ht={GIFEncoder:e.GIFEncoder,quantize:e.quantize,applyPalette:e.applyPalette}}return ht}async function Zt(e,t,r=()=>{}){if(e.length===0)return{ok:!1,error:"The recording has no frames in it."};r();const{GIFEncoder:n,quantize:s,applyPalette:i}=await Rn();r();const a=e[0],c=e[e.length-1],o=new Uint8ClampedArray(a.data.length+c.data.length);o.set(a.data,0),o.set(c.data,a.data.length);const f=s(o,256),l=n();for(let u=0;u<e.length;u++){r();const g=e[u];if(l.writeFrame(i(g.data,f),g.width,g.height,{...u===0?{palette:f,repeat:0}:{},delay:t.frameMs}),l.bytesView().byteLength>t.maxBytes)return{ok:!1,error:`The recording came out bigger than ${Math.round(t.maxBytes/1024/1024)} MB, so it was not saved.`}}l.finish();const h=l.bytes();return h.byteLength>t.maxBytes?{ok:!1,error:`The recording came out bigger than ${Math.round(t.maxBytes/1024/1024)} MB, so it was not saved.`}:{ok:!0,bytes:h}}async function On(e,t,r=()=>{}){const n=[],s=document.createElement("canvas");let i=0,a=0;try{for(let c=0;c<Math.min(e.length,62);c++){r();const o=e[c];if(!gr(o)){e[c]="";continue}const f=await _n(o);e[c]="";try{if(r(),!f)continue;if(!i){const u=Math.min(1,Math.min(800,t)/Math.max(f.width,f.height,1));i=Math.max(1,Math.round(f.width*u)),a=Math.max(1,Math.round(f.height*u)),s.width=i,s.height=a}const l=s.getContext("2d",{willReadFrequently:!0});if(!l)return[];l.fillStyle="#ffffff",l.fillRect(0,0,i,a);const h=Math.min(i/f.width,a/f.height);l.drawImage(f,0,0,Math.round(f.width*h),Math.round(f.height*h)),r(),n.push({data:l.getImageData(0,0,i,a).data,width:i,height:a})}finally{f&&(f.src="")}}return n}catch(c){throw n.length=0,c}finally{e.length=0,s.width=0,s.height=0}}function En(e,t=()=>{}){const r=document.createElement("canvas"),n=document.createElement("canvas");try{for(let s=0;s<e.length;s++){t();const i=e[s];n.width=i.width,n.height=i.height,r.width=Math.max(1,Math.round(i.width/2)),r.height=Math.max(1,Math.round(i.height/2));const a=n.getContext("2d"),c=r.getContext("2d",{willReadFrequently:!0});if(!a||!c)throw new Error("Canvas pixels are unavailable");a.putImageData(new ImageData(new Uint8ClampedArray(i.data),i.width,i.height),0,0),c.drawImage(n,0,0,r.width,r.height),e[s]={data:c.getImageData(0,0,r.width,r.height).data,width:r.width,height:r.height}}}finally{n.width=n.height=r.width=r.height=0}}function _n(e){return new Promise(t=>{const r=new Image;r.onload=()=>{r.onload=r.onerror=null,t(r)},r.onerror=()=>{r.onload=r.onerror=null,r.src="",t(null)},r.src=e})}function Yt(e,t,r){const n=r.slice().buffer;return{name:e,type:t,size:r.byteLength,arrayBuffer:async()=>n}}function Sn(e){const t=atob(e.slice(e.indexOf(",")+1));return Uint8Array.from(t,r=>r.charCodeAt(0))}const Dn=8e3;function In(e){const t=ue(),r=p.useRef(t);p.useLayoutEffect(()=>{r.current=t});const[n]=St(),[s,i]=p.useState(0),a=p.useRef(null),c=p.useRef(new Map),o=p.useRef(null),f=p.useRef({console:[],network:[],entryBytes:0,overheadBytes:0}),l=p.useRef(null),h=p.useRef(-1),u=p.useRef(null),g=p.useRef(null),w=p.useRef(!1),m=p.useRef(-1/0),y=p.useRef(!1),N=p.useRef(null),D=p.useRef(0),I=p.useRef(null),T=p.useRef(null),M=p.useRef(!1),U=p.useRef(null),P=p.useRef({...e,sessionId:n}),q=p.useRef(Promise.resolve()),$=p.useRef(()=>{}),te=p.useRef({initialize:S,retire:b,consume:ae,register:L,eligiblePending:K,refuseRequest:k,live:R,captureFrame:lt,valid:Ye,reportRecordingStart:Ae,cancelReservation:Mt,finish:Tt});p.useLayoutEffect(()=>{te.current={initialize:S,retire:b,consume:ae,register:L,eligiblePending:K,refuseRequest:k,live:R,captureFrame:lt,valid:Ye,reportRecordingStart:Ae,cancelReservation:Mt,finish:Tt}});const me=C=>U.current===C||J.getState().openDocuments.some(v=>v.id===C&&v.openedHere);function x(C,{active:v,activation:O=!1,keepalive:j=!1,reset:A=!1}){if(!C.sessionId)return;const Z={documentId:C.documentId,logicalUrl:C.logicalUrl,bridgeGeneration:C.generation,seq:Math.max(0,h.current),console:[],network:[],active:v,activation:O,instrumented:C.ready&&!C.retired,...A?{reset:!0}:{}};q.current=q.current.then(()=>r.current.ingestDevtoolsCapture(C.sessionId,Z,j?{keepalive:!0}:void 0)).catch(()=>{})}function b(){var O;const C=a.current;C&&(C.retired=!0),a.current=null,l.current!==null&&clearTimeout(l.current),l.current=null,o.current=null,f.current={console:[],network:[],entryBytes:0,overheadBytes:0},h.current=-1,m.current=-1/0,y.current=!1;for(const[j,A]of c.current)A.life.sessionId&&A.deadline>Date.now()&&A.kind!=="frame"&&k(j,A.kind,A.life,"The frame changed while this request was pending."),clearTimeout(A.timer),(O=A.resolve)==null||O.call(A,null);c.current.clear(),C&&x(C,{active:!1});const v=N.current;v&&(clearTimeout(v.reservationTimer),v.cancelled=!0,v.abort.abort(),v.frames.length=0,v.finishing||(v.drawn.length=0,N.current=null)),I.current!==null&&cancelAnimationFrame(I.current),I.current=null,D.current=0,i(0)}function S({loadActivation:C,reset:v=!1}={}){var G,ne;const O=P.current,j=(G=O.iframeRef.current)==null?void 0:G.contentWindow;if(w.current||!j||!O.bridgeEligibility||!O.resolvedSource)return;const A={generation:crypto.randomUUID(),frame:j,sessionId:O.sessionId,documentId:O.documentId,logicalUrl:O.logicalUrl,source:O.resolvedSource,origin:O.bridgeEligibility==="served-document"?"null":O.previewOrigin,ready:!1,activation:!1,retired:!1};a.current=A;const Z=C??(M.current||T.current!==A.documentId&&me(A.documentId));A.activation=Z,M.current=!1,T.current=A.documentId,x(A,{active:!0,activation:Z,reset:v}),((ne=u.current)==null?void 0:ne.frame)===j&&u.current.source===O.resolvedSource&&u.current.reload===O.reloadNonce&&u.current.documentId===O.documentId&&u.current.logicalUrl===O.logicalUrl&&j.postMessage({__dorkosDevtools:"init",bridgeGeneration:A.generation},"*")}p.useLayoutEffect(()=>{var j;P.current={...e,sessionId:n};const C={frame:(j=e.iframeRef.current)==null?void 0:j.contentWindow,sessionId:n,documentId:e.documentId,logicalUrl:e.logicalUrl,source:e.resolvedSource,eligibility:e.bridgeEligibility,origin:e.previewOrigin,reload:e.reloadNonce},v=g.current;if(!v||Object.keys(C).some(A=>C[A]!==v[A])){const A=!v||v.frame!==C.frame||v.documentId!==C.documentId||v.logicalUrl!==C.logicalUrl||v.source!==C.source||v.reload!==C.reload;g.current=C,w.current=!1,b(),S({reset:A})}});const _=p.useCallback(()=>{var Z,G,ne;const{initialize:C,retire:v}=te.current,O=P.current,j=(Z=O.iframeRef.current)==null?void 0:Z.contentWindow,A=(G=a.current)!=null&&G.ready?!1:(ne=a.current)==null?void 0:ne.activation;j&&O.resolvedSource&&(u.current={frame:j,source:O.resolvedSource,reload:O.reloadNonce,documentId:O.documentId,logicalUrl:O.logicalUrl}),w.current=!1,v(),C({loadActivation:A,reset:!0})},[]),z=p.useCallback(()=>{const C=a.current;M.current=!0,U.current=P.current.documentId,C&&$.current({active:!0,activation:!0})},[]);p.useLayoutEffect(()=>{$.current=C=>{a.current&&x(a.current,C)}});function R(C){return a.current===C&&!C.retired}function k(C,v,O,j){if(!O.sessionId)return;const A={requestId:C,bridgeGeneration:O.generation,documentId:O.documentId,hostOutcome:"host",error:j};v==="action"?r.current.postDevtoolsAction(O.sessionId,{...A,ok:!1}).catch(()=>{}):r.current.ingestDevtoolsCapture(O.sessionId,{...A,logicalUrl:O.logicalUrl,seq:Math.max(0,h.current),console:[],network:[],screenshot:{requestId:C,error:j}}).catch(()=>{})}function L(C,v,O,{capture:j=!1,resolve:A,timeoutMs:Z=8e3}={}){if(c.current.size>=Oe.pending||c.current.has(C))return null;const G=setTimeout(()=>W(C,ne),Z),ne={kind:v,life:O,capture:j,deadline:Date.now()+Z,timer:G,resolve:A};return c.current.set(C,ne),ne}function W(C,v){var O;c.current.get(C)===v&&(c.current.delete(C),clearTimeout(v.timer),(O=v.resolve)==null||O.call(v,null))}function K(C,v,O){return c.current.get(C)!==v||v.life!==O||!R(O)?!1:Date.now()>=v.deadline?(W(C,v),!1):!0}function ae(C,v,O){const j=c.current.get(C);return!j||j.life!==O||j.kind!==v&&!(v==="capture"&&j.kind==="frame")||!K(C,j,O)?null:(c.current.delete(C),clearTimeout(j.timer),j)}p.useEffect(()=>{const{initialize:C,retire:v,consume:O}=te.current;function j(){l.current=null;const le=o.current;o.current=null,f.current={console:[],network:[],entryBytes:0,overheadBytes:0};const E=a.current;le&&E&&!E.retired&&E.sessionId&&le.bridgeGeneration===E.generation&&r.current.ingestDevtoolsCapture(E.sessionId,le)}function A(le){var qt,Lt,Pt,Bt;const E=a.current;if(!E||E.retired||le.source!==E.frame||le.origin!==E.origin||((qt=u.current)==null?void 0:qt.frame)!==E.frame||u.current.source!==E.source||u.current.reload!==P.current.reloadNonce||u.current.documentId!==E.documentId||u.current.logicalUrl!==E.logicalUrl)return;const F=le.data;if(!F||typeof F!="object"||typeof F.__dorkosDevtools!="string"||!["hello","ready","navigated","resource-error","batch","capture-result","act-result"].includes(F.__dorkosDevtools)||F.__dorkosDevtools!=="hello"&&F.bridgeGeneration!==E.generation)return;const ie=F.__dorkosDevtools==="batch";if(ie){if(!E.ready||!E.sessionId||F.bridgeGeneration!==E.generation||!Number.isSafeInteger(F.seq)||F.seq<0||F.seq<=h.current)return;const H=Date.now();if(H-m.current<Oe.batchMs){o.current?o.current.dropped=!0:y.current=!0;return}m.current=H}const B=Cn(F);if(!B){ie&&(y.current=!0);return}if(B.__dorkosDevtools==="hello"){E.frame.postMessage({__dorkosDevtools:"init",bridgeGeneration:E.generation},"*");return}if(B.bridgeGeneration!==E.generation)return;if(B.__dorkosDevtools==="ready"){E.ready||(E.ready=!0,E.activation=!1,x(E,{active:!0}));return}if(!E.ready)return;if(B.__dorkosDevtools==="navigated"){w.current=!0,v();return}if(B.__dorkosDevtools==="resource-error"){D.current=Math.min(Oe.resourceErrors,D.current+1),I.current===null&&(I.current=requestAnimationFrame(()=>{I.current=null,R(E)&&i(D.current)}));return}if(!E.sessionId)return;if(B.__dorkosDevtools==="batch"){if(B.seq<=h.current)return;h.current=B.seq;const H=o.current??{documentId:E.documentId,logicalUrl:E.logicalUrl,bridgeGeneration:E.generation,seq:B.seq,console:[],network:[]};H.seq=B.seq,y.current&&(H.dropped=!0),y.current=!1;const xe=f.current,Ut=new TextEncoder;if(o.current||(xe.overheadBytes=Ut.encode(JSON.stringify({...H,seq:Number.MAX_SAFE_INTEGER,dropped:!0,console:[],network:[]})).length),xe.overheadBytes>Oe.queueBytes){o.current=null,f.current={console:[],network:[],entryBytes:0,overheadBytes:0},y.current=!0;return}for(const[ze,Fr]of[["console",B.console],["network",B.network]])for(const qr of Fr){const Wt=Ut.encode(JSON.stringify(qr)).length;xe[ze].push(Wt),xe.entryBytes+=Wt}H.console.push(...B.console),H.network.push(...B.network);const Tr=()=>xe.overheadBytes+xe.entryBytes+Math.max(0,H.console.length-1)+Math.max(0,H.network.length-1);for(;H.console.length>500||H.network.length>200||Tr()>Oe.queueBytes;){H.dropped=!0;const ze=(((Lt=H.console[0])==null?void 0:Lt.timestamp)??1/0)<=(((Pt=H.network[0])==null?void 0:Pt.timestamp)??1/0)?"console":"network";if(!H[ze].length)break;H[ze].shift(),xe.entryBytes-=xe[ze].shift()}o.current=H,l.current===null&&(l.current=setTimeout(j,Oe.batchMs));return}if(B.__dorkosDevtools==="capture-result"){const H=O(B.requestId,"capture",E);if(!H)return;if(H.kind==="frame"){(Bt=H.resolve)==null||Bt.call(H,B.dataUrl??null);return}r.current.ingestDevtoolsCapture(E.sessionId,{bridgeGeneration:E.generation,documentId:E.documentId,logicalUrl:E.logicalUrl,seq:Math.max(0,h.current),console:[],network:[],hostOutcome:"page-reported",screenshot:{requestId:B.requestId,dataUrl:B.dataUrl,error:B.error}});return}const Ne=O(B.requestId,"action",E);if(!Ne)return;const Re=N.current,Ft=Ne.capture&&B.dataUrl!==void 0&&Re!==null&&Re.life===E&&Re.activated&&!Re.finishing&&!Re.cancelled&&Re.frames.length<61;Ft&&Re.frames.push(B.dataUrl);const{__dorkosDevtools:Ai,dataUrl:Ni,...Mr}=B;r.current.postDevtoolsAction(E.sessionId,{...Mr,hostOutcome:"page-reported",documentId:E.documentId,captured:Ft||void 0})}window.addEventListener("message",A);const Z=setInterval(()=>$.current({active:!0}),15e3),G=()=>{a.current||C(),$.current({active:!0,activation:!0})},ne=()=>{$.current({active:!1,keepalive:!0}),v()},oe=()=>{document.visibilityState==="visible"&&G()};return window.addEventListener("focus",G),window.addEventListener("pagehide",ne),window.addEventListener("pageshow",G),document.addEventListener("visibilitychange",oe),()=>{window.removeEventListener("message",A),clearInterval(Z),window.removeEventListener("focus",G),window.removeEventListener("pagehide",ne),window.removeEventListener("pageshow",G),document.removeEventListener("visibilitychange",oe),v()}},[]),p.useEffect(()=>Gr.subscribeSessionEvent((C,v)=>{if(v.type!=="devtools_capture_request"&&v.type!=="devtools_action_request"&&v.type!=="devtools_recording_request")return;const{register:O,eligiblePending:j,refuseRequest:A,captureFrame:Z,valid:G,finish:ne,reportRecordingStart:oe,cancelReservation:le}=te.current,E=a.current;if(!(!(E!=null&&E.ready)||!E.sessionId||E.retired||v.targetClientId!==r.current.clientId||v.documentId!==E.documentId||v.bridgeGeneration!==E.generation)){if(v.type==="devtools_capture_request"||v.type==="devtools_action_request"){const F=v.type==="devtools_action_request",ie=O(v.requestId,F?"action":"capture",E,{capture:F&&!!v.capture,timeoutMs:F&&v.command.action==="wait_for"?Math.min(1e4,v.command.timeoutMs)+2e3:8e3});if(!ie){c.current.has(v.requestId)||A(v.requestId,F?"action":"capture",E,"Too many browser requests are waiting. Try again when one finishes.");return}const B=Ne=>{j(v.requestId,ie,E)&&E.frame.postMessage(F?{__dorkosDevtools:"act-request",bridgeGeneration:E.generation,requestId:v.requestId,documentId:E.documentId,command:v.command,...v.capture?{capture:!0,lib:Ne}:{}}:{__dorkosDevtools:"capture-request",bridgeGeneration:E.generation,requestId:v.requestId,lib:Ne},"*")};!F||v.capture?Xt().then(B,()=>B()):B()}if(v.type==="devtools_recording_request"){if(v.action==="cancel-start"){le(v.recordingId,v.requestId,E);return}if(v.action==="confirm-start"){const F=N.current;if(!F||F.id!==v.recordingId||F.startRequestId!==v.requestId||F.life!==E||F.finishing||!G(F))return;if(!F.activated){if(performance.now()>=F.reservationDeadline){le(F.id,F.startRequestId,E),oe(v,E,{phase:"started",ok:!1,error:"This recording reservation expired before capture could start."});return}clearTimeout(F.reservationTimer),F.activated=!0,F.startedAt=Date.now(),Z(E).then(ie=>{ie&&G(F)&&F.frames.push(ie)})}oe(v,E,{phase:"started",ok:!0});return}if(v.action==="start"){const F=v.reservationTimeoutMs;if(!Number.isSafeInteger(F)||!F||F<1||F>Dn){oe(v,E,{phase:"reserved",ok:!1,error:"This recording request has no valid reservation timeout."});return}if(N.current){oe(v,E,{phase:"reserved",ok:!1,error:"Another recording in this window is still running or being saved. Wait for it to finish, then start again."});return}const ie={id:v.recordingId,startRequestId:v.requestId,activated:!1,reservationDeadline:performance.now()+F,life:E,startedAt:Date.now(),frames:[],drawn:[],finishing:!1,cancelled:!1,abort:new AbortController};N.current=ie,ie.reservationTimer=setTimeout(()=>{N.current===ie&&!ie.activated&&le(ie.id,ie.startRequestId,E)},F),oe(v,E,{phase:"reserved",ok:!0})}else ne(v.requestId,v.recordingId,E)}}}),[]);function Ae(C,v,O){!R(v)||!v.sessionId||r.current.ingestDevtoolsCapture(v.sessionId,{hostOutcome:"host",documentId:v.documentId,bridgeGeneration:v.generation,seq:0,console:[],network:[],recordingStart:{...O,requestId:C.requestId,recordingId:C.recordingId}}).catch(()=>{})}function Mt(C,v,O){var A;const j=N.current;if(!(!j||j.id!==C||j.startRequestId!==v||j.life!==O||j.finishing)){clearTimeout(j.reservationTimer),j.cancelled=!0,j.abort.abort(),j.frames.length=0,j.drawn.length=0;for(const[Z,G]of c.current)G.life===O&&G.kind==="frame"&&(clearTimeout(G.timer),(A=G.resolve)==null||A.call(G,null),c.current.delete(Z));N.current=null}}function Ye(C){return N.current===C&&!C.cancelled&&R(C.life)}function lt(C){const v=`frame-${crypto.randomUUID()}`;return new Promise(O=>{const j=L(v,"frame",C,{resolve:O});if(!j){O(null);return}Xt().then(A=>{K(v,j,C)&&C.frame.postMessage({__dorkosDevtools:"capture-request",bridgeGeneration:C.generation,requestId:v,lib:A},"*")},()=>{W(v,j)})})}async function Tt(C,v,O){const j=N.current;if(!j||!j.activated||j.id!==v||j.life!==O){R(O)&&await r.current.uploadDevtoolsRecording(O.sessionId,{requestId:C,bridgeGeneration:O.generation,documentId:O.documentId,hostOutcome:"host",error:"The window showing that page stopped recording before it could be saved."}).catch(()=>{});return}if(j.finishing)return;j.finishing=!0;const A=()=>{if(!Ye(j))throw new Error("retired")},Z={requestId:C,bridgeGeneration:O.generation,documentId:O.documentId};try{const G=await lt(O);A(),G&&j.frames.length<Oe.frames&&j.frames.push(G);const ne=j.frames.length?Sn(j.frames[j.frames.length-1]):new Uint8Array;j.drawn=await On(j.frames,800,A),A();let oe=await Zt(j.drawn,{frameMs:500,maxBytes:8*1024*1024},A);if(A(),!oe.ok&&j.drawn.length&&(En(j.drawn,A),oe=await Zt(j.drawn,{frameMs:500,maxBytes:8*1024*1024},A),A()),!oe.ok){await r.current.uploadDevtoolsRecording(O.sessionId,{...Z,hostOutcome:"host",error:oe.error},{signal:j.abort.signal}),A();return}A(),await r.current.uploadDevtoolsRecording(O.sessionId,{...Z,frames:j.drawn.length,durationMs:Date.now()-j.startedAt,recording:Yt(`${v}.gif`,"image/gif",oe.bytes),keyframe:Yt(`${v}.png`,"image/png",ne)},{signal:j.abort.signal}),A()}catch{Ye(j)&&await r.current.uploadDevtoolsRecording(O.sessionId,{...Z,hostOutcome:"host",error:"This window could not turn that recording into a file."},{signal:j.abort.signal}).catch(()=>{})}finally{j.frames.length=0,j.drawn.length=0,N.current===j&&(N.current=null)}}return{resourceErrorCount:s,notePersonNavigated:z,noteFrameLoaded:_}}const An=15e3;function Nn(e){const t=e instanceof Error?e.message.trim():"";return t.length>0?t:"Couldn’t reach DorkOS. Check your network and try again."}function zn(e){const t=ue();return{open:p.useCallback(async r=>{await t.openRoomCanvasDocument(e,r)},[t,e]),update:p.useCallback(async(r,n)=>{await t.updateRoomCanvasDocument(e,r,{content:n})},[t,e]),pin:p.useCallback(async(r,n)=>{await t.updateRoomCanvasDocument(e,r,{pinned:n})},[t,e]),close:p.useCallback(async r=>{await t.closeRoomCanvasDocument(e,r)},[t,e])}}function Mn(e,t){const r=ue(),n=J(s=>s.setRoomCanvasEditing);p.useEffect(()=>{if(n(e,t),t===null)return;const s=a=>{r.setRoomCanvasEditing(e,t,a).catch(c=>{console.warn("[room-canvas] edit lock failed",{roomId:e,documentId:t,err:c})})};s(!0);const i=setInterval(()=>s(!0),An);return()=>{clearInterval(i),s(!1),n(e,null)}},[r,e,t,n])}const Tn=400;function Bi(e,t){const r=ue(),n=J(s=>s.roomCanvasPresenceEpoch[e]??0);p.useEffect(()=>{const s=c=>{r.setRoomCanvasViewing(e,c).catch(o=>{console.warn("[room-canvas] could not say where we are looking",{roomId:e,err:o})})};let i=!1;const a=setTimeout(()=>{i=!0,s(t)},Tn);return()=>{clearTimeout(a),i&&s(null)}},[r,e,t,n])}const Fn="allow-scripts allow-forms allow-popups allow-modals",pt="allow-scripts allow-same-origin allow-popups allow-forms allow-modals allow-downloads",qn=new Set(["javascript:","data:","blob:"]),Ln=new Set(["localhost","127.0.0.1","0.0.0.0","[::1]","::1"]);function It(e){return Ln.has(e)||e.endsWith(".localhost")}function Pn(e){return It(e)?"direct":"server"}function Bn(e,t){let r;try{r=new URL(e)}catch{return null}const n=r.searchParams.get(Qt),s=new URL(r.origin),i=t.indexOf("?");return s.pathname=(i===-1?t:t.slice(0,i))||"/",s.search=i===-1?"":t.slice(i),n!==null&&s.searchParams.set(Qt,n),s.toString()}const Qt="__dorkos_preview",Un="/__dorkos_preview/health";function Wn(e){return e==="https:"?443:80}function vr(e){let t;try{t=new URL(e)}catch{return{mode:"serve",path:e}}if(qn.has(t.protocol))return{mode:"blocked"};if(t.protocol==="file:")return{mode:"serve",path:decodeURIComponent(t.pathname)};if(t.protocol==="http:"||t.protocol==="https:"){if(It(t.hostname)){const r=t.port?Number(t.port):Wn(t.protocol);return{mode:"proxy",hostname:t.hostname,port:r,path:`${t.pathname}${t.search}`}}return{mode:"external",url:e}}return{mode:"blocked"}}function Gn(e){const t=e.trim();if(t===""||/^[a-z][a-z0-9+.-]*:\/\//i.test(t)||t.startsWith("/")||t.startsWith("./")||t.startsWith("../"))return t;const r=t.split("/")[0];if(t.includes("/")&&!r.includes(".")&&!r.includes(":"))return t;const s=r.split(":")[0];return`${It(s)?"http":"https"}://${t}`}function $n(e){const t=vr(e);if(t.mode==="serve")return{kind:"local",path:t.path};if(t.mode==="blocked")return{kind:"raw",text:e};try{const r=new URL(e),n=r.host.replace(/^www\./,""),s=r.pathname==="/"&&r.search===""&&r.hash===""?"":`${r.pathname}${r.search}${r.hash}`;return{kind:"url",host:n,rest:s}}catch{return{kind:"raw",text:e}}}const Hn=2e3;async function Kt(e,t=globalThis.fetch,r=Hn){const n=new AbortController,s=setTimeout(()=>n.abort(),r);try{return await t(e,{mode:"no-cors",cache:"no-store",signal:n.signal}),!0}catch{return n.signal.aborted}finally{clearTimeout(s)}}function Vn({target:e,currentUrl:t,strategy:r,cwd:n,reloadNonce:s}){const i=JSON.stringify([t,r,n,s]),[a,c]=p.useState(null),[o,f]=p.useState(null),[l,h]=p.useState(null),u=ue(),g=p.useRef(u);return p.useEffect(()=>{g.current=u}),p.useEffect(()=>{const w=g.current;let m=!1;const y=T=>{c(i),f(T)};async function N(T){if(n===null){h({kind:"no-session"});return}try{const M=await w.createServeUrl(n,T);if(m)return;M===null?h({kind:"unsupported"}):y({src:M,sandbox:Fn,previewOrigin:null,bridgeEligibility:"served-document"})}catch{m||h({kind:"failed"})}}async function D(T,M){let U;try{const q=await w.probeLoopbackPort(T);U=q===null?"unknown":q.listening}catch{U="unknown"}if(m)return;let P=null;if(U!==!1){let q=null;try{q=await w.createProxyUrl(T)}catch{if(m)return;P={kind:"failed"}}if(m)return;if((q==null?void 0:q.unavailable)==="tunnel"){h({kind:"tunnel"});return}if((q==null?void 0:q.unavailable)==="no-port"&&(P={kind:"no-port"}),q!=null&&q.url){const $=new URL(q.url);if(await Kt(`${$.origin}${Un}`)){if(m)return;const te=Bn(q.url,M);if(te!==null){y({src:te,sandbox:pt,previewOrigin:$.origin,bridgeEligibility:"preview-listener"});return}}if(m)return;P={kind:"origin-unreachable",host:$.hostname,listenPort:$.port}}}if(r==="direct"&&await Kt(t)){if(m)return;y({src:t,sandbox:pt,previewOrigin:null,bridgeEligibility:null});return}m||h(P??{kind:"no-upstream"})}async function I(){if(h(null),f(null),e.mode!=="blocked"){if(e.mode==="external"){y({src:e.url,sandbox:pt,previewOrigin:null,bridgeEligibility:null});return}return e.mode==="serve"?N(e.path):D(e.port,e.path)}}return I(),()=>{m=!0}},[e,t,r,n,s,i]),{resolved:a===i?o:null,resolveError:l}}const Jn=1e4;function Xn(e,t){if(e&&e.contentUrl===t&&e.stack.length>0){const r=Math.min(Math.max(e.cursor,0),e.stack.length-1);return{stack:e.stack,cursor:r}}return{stack:[t],cursor:0}}function Zn({documentId:e,content:t}){const r=J(_=>_.selectedCwd),n=J(_=>_.writeBrowserHistory),[s]=p.useState(()=>Xn(J.getState().browserHistories[e],t.url)),[i,a]=p.useState(s.stack),[c,o]=p.useState(s.cursor),[f,l]=p.useState(0);p.useEffect(()=>{n(e,{contentUrl:t.url,stack:i,cursor:c})},[e,t.url,i,c,n]);const h=i[c],u=p.useMemo(()=>vr(h),[h]),g=p.useMemo(()=>u.mode==="proxy"?Pn(window.location.hostname):null,[u]),w=p.useRef(null),{resolved:m,resolveError:y}=Vn({target:u,currentUrl:h,strategy:g,cwd:r,reloadNonce:f}),{resourceErrorCount:N,notePersonNavigated:D,noteFrameLoaded:I}=In({iframeRef:w,documentId:e,logicalUrl:h,reloadNonce:f,previewOrigin:(m==null?void 0:m.previewOrigin)??null,bridgeEligibility:(m==null?void 0:m.bridgeEligibility)??null,resolvedSource:(m==null?void 0:m.src)??null}),T=J(_=>_.roomCanvasLiveRoomId),{open:M}=zn(T??""),[U,P]=p.useState(null),q=p.useCallback(_=>{a(z=>[...z.slice(0,c+1),_]),o(z=>z+1)},[c]),$=$r(T),te=J(_=>T?_.roomCanvasEditing[T]??null:null);p.useEffect(()=>{if($===null||te!==null||$.documentId!==e)return;const _=$.url;_===void 0||_===h||q(_)},[$,te,e,h,q]);const me=c>0,x=c<i.length-1,b=p.useCallback(_=>{const z=Gn(_);if(!z||z===h){D(),l(R=>R+1);return}if(T){P(null),M({type:"browser",url:z}).catch(R=>{P({url:z,message:Nn(R)})});return}D(),q(z)},[h,q,T,M,D]),S=()=>Zr(h);return d.jsxs("div",{className:"flex h-full flex-col",children:[d.jsxs("div",{className:"border-border/60 flex shrink-0 flex-wrap items-center gap-1 border-b px-2 py-1 lg:h-9 lg:flex-nowrap lg:py-0",children:[d.jsx(Qe,{label:"Back",disabled:!me,onClick:()=>o(_=>_-1),children:d.jsx(Hr,{className:"size-4"})}),d.jsx(Qe,{label:"Forward",disabled:!x,onClick:()=>o(_=>_+1),children:d.jsx(Vr,{className:"size-4"})}),d.jsx(Qe,{label:"Reload",onClick:()=>l(_=>_+1),children:d.jsx(an,{className:"size-4"})}),d.jsx("div",{className:"order-first flex w-full min-w-0 lg:order-none lg:w-auto lg:flex-1",children:d.jsx(Yn,{url:(U==null?void 0:U.url)??h,startEditing:U!==null,onSubmit:b},U===null?"address":`retry:${U.url}`)}),d.jsx(Qe,{label:"Open in system browser",onClick:S,children:d.jsx(Jr,{className:"size-4"})})]}),U!==null&&d.jsx("p",{role:"status",className:"text-destructive border-border/60 border-b px-2 py-1 text-xs",children:U.message}),d.jsx(ts,{target:u,resolved:m,resolveError:y,reloadNonce:f,resourceErrorCount:N,title:t.title??"Embedded browser",onOpenExternally:S,onReload:()=>{D(),l(_=>_+1)},iframeRef:w,onFrameLoad:I})]})}function Yn({url:e,startEditing:t=!1,onSubmit:r}){const[n,s]=p.useState(t),[i,a]=p.useState(e);if(!n)return d.jsx(Kn,{url:e,onActivate:()=>{a(e),s(!0)}});const c=o=>{o.preventDefault(),s(!1),r(i)};return d.jsx("form",{onSubmit:c,className:"min-w-0 flex-1",children:d.jsx(Xr,{"aria-label":"Address",autoFocus:!0,value:i,onChange:o=>a(o.target.value),onFocus:o=>o.currentTarget.select(),onBlur:()=>s(!1),onKeyDown:o=>{o.key==="Escape"&&(o.preventDefault(),s(!1))},spellCheck:!1,autoCapitalize:"off",autoCorrect:"off",className:"h-11 w-full text-base lg:h-7 lg:text-sm"})})}function Qn(e){return e.kind==="local"?e.path:e.kind==="url"?`${e.host}${e.rest}`:e.text}function Kn({url:e,onActivate:t}){const r=p.useMemo(()=>$n(e),[e]);return d.jsxs("button",{type:"button","aria-label":`Address: ${Qn(r)}`,onClick:t,className:"text-muted-foreground hover:bg-muted focus-ring flex h-11 min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 text-left text-sm transition-colors lg:h-7",children:[r.kind==="local"&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"bg-muted-foreground/15 text-3xs rounded px-1 py-0.5 font-medium tracking-wide uppercase",children:"local"}),d.jsx("span",{className:"text-foreground truncate",children:r.path})]}),r.kind==="url"&&d.jsxs("span",{className:"truncate",children:[d.jsx("span",{className:"text-foreground",children:r.host}),d.jsx("span",{className:"text-muted-foreground",children:r.rest})]}),r.kind==="raw"&&d.jsx("span",{className:"truncate",children:r.text})]})}function es(e,t){switch(e.kind){case"no-session":return"Open a chat to preview local files.";case"unsupported":return"Local previews aren’t available in this environment.";case"failed":return"Couldn’t load this preview. Reload, or open the app in your browser.";case"tunnel":return"Dev server previews don’t work remotely. Open DorkOS on the computer running it.";case"no-port":return"All preview ports are in use. Close a preview, then reload.";case"origin-unreachable":return`This view can’t reach port ${e.listenPort} on ${e.host}. Open DorkOS on the computer running it.`;case"no-upstream":return`Nothing is listening on ${t.mode==="proxy"?`${t.hostname}:${t.port}`:"that address"}. Start the dev server, then reload.`}}function ts({target:e,resolved:t,resolveError:r,reloadNonce:n,resourceErrorCount:s,title:i,onOpenExternally:a,onReload:c,iframeRef:o,onFrameLoad:f}){if(e.mode==="blocked")return d.jsx(mt,{children:"This address is blocked for safety."});if(r!==null)return d.jsxs(mt,{children:[d.jsx("p",{children:es(r,e)}),r.kind!=="no-session"&&r.kind!=="unsupported"&&d.jsx("button",{type:"button",onClick:c,className:"text-foreground mt-3 hover:underline",children:"Reload"})]});if(t===null)return d.jsx(mt,{children:"Loading…"});const l=e.mode==="external";return d.jsx(rs,{src:t.src,sandbox:t.sandbox,title:i,iframeRef:o,onFrameLoad:f,watchLoadDeadline:!l,resourceErrorCount:s,showEmbedFallback:l,onOpenExternally:a,onReload:c},`${t.src}:${n}`)}function rs({src:e,sandbox:t,title:r,iframeRef:n,onFrameLoad:s,watchLoadDeadline:i,resourceErrorCount:a,showEmbedFallback:c,onOpenExternally:o,onReload:f}){const[l,h]=p.useState(!1),[u,g]=p.useState(!1);return p.useEffect(()=>{if(!i)return;const w=setTimeout(()=>g(!0),Jn);return()=>clearTimeout(w)},[i]),d.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[u&&!l&&d.jsx(er,{onOpenExternally:o,onReload:f,children:"This preview is slow to load."}),a>0&&d.jsxs(er,{onOpenExternally:o,children:["This page hit ",a===1e4?"at least 10,000":a," ",a===1?"error":"errors"," while loading."]}),d.jsx("iframe",{ref:n,src:e,sandbox:t,onLoad:()=>{h(!0),s()},className:"min-h-0 w-full flex-1 border-0",title:r}),c&&d.jsxs("div",{className:"text-muted-foreground border-border/60 flex items-center justify-between gap-2 border-t px-3 py-1.5 text-xs",children:[d.jsx("span",{children:"This site can’t always be embedded here."}),d.jsx("button",{type:"button",onClick:o,className:"text-foreground hover:underline",children:"Open in system browser"})]})]})}function er({children:e,onOpenExternally:t,onReload:r}){return d.jsxs("div",{className:"text-muted-foreground border-border/60 flex items-center justify-between gap-2 border-b px-3 py-1.5 text-xs",children:[d.jsx("span",{children:e}),d.jsxs("span",{className:"flex shrink-0 items-center gap-3",children:[r&&d.jsx("button",{type:"button",onClick:r,className:"text-foreground hover:underline",children:"Reload"}),d.jsx("button",{type:"button",onClick:t,className:"text-foreground hover:underline",children:"Open in system browser"})]})]})}function Qe({label:e,disabled:t,onClick:r,children:n}){return d.jsx("button",{type:"button","aria-label":e,disabled:t,onClick:r,className:Dt("text-muted-foreground hover:text-foreground hover:bg-muted focus-ring flex size-11 shrink-0 items-center justify-center rounded-md transition-colors lg:size-7",t&&"pointer-events-none opacity-40"),children:n})}function mt({children:e}){return d.jsx("div",{className:"text-muted-foreground flex min-h-0 flex-1 flex-col items-center justify-center p-8 text-center",children:e})}const He=$e().min(1).max(128),fe={protocol:Y("dorkos-doc"),v:Y(1),nonce:He,requestToken:He,loadToken:bt,generation:cr.shape.generation};ct("kind",[se({...fe,kind:Y("challenge")}).strict(),se({...fe,kind:Y("ack")}).strict(),se({...fe,kind:Y("connect")}).strict()]);ct("kind",[se({...fe,kind:Y("emit"),requestId:He,event:rt}).strict(),se({...fe,kind:Y("retire")}).strict()]);ct("kind",[se({...fe,kind:Y("receipt"),requestId:He,receipt:ur}).strict(),se({...fe,kind:Y("refused"),requestId:He,outcome:Ht(["cancelled","unconfirmed","refused"])}).strict(),se({...fe,kind:Y("state"),state:Qr,stateRev:bt,docSeq:bt,reset:Vt()}).strict(),se({...fe,kind:Y("event"),frame:Kr}).strict(),se({...fe,kind:Y("status"),status:Ht(["connecting","ready","offline","revoked"]),unconfirmed:Vt()}).strict()]);function ns(e,t){try{if(Yr(t,1048576)!==void 0)return null;const r=e.safeParse(t);return r.success?r.data:null}catch{return null}}function ss({owner:e,getOwner:t,readTail:r,writeTail:n,transport:s,cwd:i,sourcePath:a,documentId:c,pending:o}){const f=()=>{var m,y;return((m=t())==null?void 0:m.recoveryGate)==="unsupported"||((y=t())==null?void 0:y.recoveryGate)==="observed_clear"},l=m=>{var D;const y=en.parse(m),N=(D=t())==null?void 0:D.recoveryBinding;if(!N||y.documentId!==c||!V(y.incarnation,N.incarnation))throw new Error("Original save scope changed");return y},h=s.originalFileSaveRecovery,u=()=>{var m;try{const y=t();return(y==null?void 0:y.identity)===e&&y.active&&!!((m=y.recoveryBinding)!=null&&m.current())}catch{return!1}},g=(m,y,N=!1)=>{if(!h||!u())return Promise.resolve({status:"idle"});const D=t(),I={},T=()=>t()===D&&u()&&(!y||D.recoveryBinding===y)&&(!N||D.recoveryWork===I),M=D.discovery;let U=!1;D.recoveryWork=I,D.recoveryGate="pending",D.recoveryBusy=!0;const P=r().catch(()=>{}).then(async()=>{try{if(!T())return{status:"idle"};const q=await m();return T()?(N&&(D.recoveryGate="observed_clear"),U=!0,{status:"observed",value:q}):{status:"idle"}}catch{return T()?(D.recoveryGate="unavailable",{status:"unavailable"}):{status:"idle"}}finally{!U&&D.discovery===M&&(D.discovery=void 0),D.recoveryWork===I&&(D.recoveryBusy=!1,D.recoveryWork=void 0)}});return N||n(P.then(()=>{})),P};return{identity:e,supported:!!h,current:u,discover:(m=!1)=>{if(!h||!u())return Promise.resolve({status:"idle"});const y=t(),N=y.recoveryBinding;if(y.discoveryBinding===N&&y.discovery&&(y.pendingDiscovery===y.discovery||!m&&y.recoveryGate==="observed_clear"))return y.discovery;const D=g(async()=>{const I=l(await h.discover(c));return t()===y&&y.recoveryBinding===N&&u()&&(y.recoveryGate=I.admission==="blocked"?"blocked":"observed_clear"),I},N);return y.discoveryBinding=N,y.discovery=D,y.pendingDiscovery=D,D.then(I=>{y.pendingDiscovery===D&&(y.pendingDiscovery=void 0),I.status==="idle"&&y.discovery===D&&(y.discovery=void 0)}),D},recover(m){if(o())return Promise.resolve({status:"local_uncertain"});const y=t();return g(async()=>{if(!y||o())throw new Error("Mounted original still uncertain");const N=y.recoveryBinding,D=tn.parse(await h.recover(c,m,N.incarnation));if(t()!==y||!u()||D.documentId!==c||D.entry.eventId!==m||!V(D.incarnation,N.incarnation))throw new Error("Original recovery scope changed");const I=l(await h.discover(c));return t()===y&&u()&&(y.recoveryGate=I.admission==="blocked"?"blocked":"observed_clear"),{result:D,discovery:I}})},inspectCurrent(){const m=t();return!m||!u()||o()||!f()?Promise.resolve({status:"local_uncertain"}):g(async()=>{const y=await s.readFileContent(i,a);if(!y||typeof y.content!="string"||typeof y.hash!="string"||!/^[a-f0-9]{64}$/u.test(y.hash))throw new Error("Current file evidence missing");return{content:y.content,hash:y.hash}},m.recoveryBinding,!0)}}}class Ee extends Error{constructor(){super("The original save is not confirmed. Retry it before saving another draft.")}}class Ue extends Error{}function is(){const e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;const t=[...e].map(r=>r.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function os(e){const t=e;return(t==null?void 0:t.status)===412&&t.code==="DOC_SAVE_FAILED"}var de,Se,Xe,wt;class as{constructor(){Te(this,Xe);Te(this,de);Te(this,Se)}get pending(){return Me(this,de)!==void 0}get receipt(){return Me(this,Se)}async write(t,r,n,s,i,a,c=!1){if(Me(this,de))throw new Ee;if(ge(this,Se,void 0),!a)return t.writeFile(r,n,s,i);if(!c&&!a.current())throw new Ue;const o=Object.freeze({cwd:r,path:n,content:s,options:Object.freeze({...i,documentSave:Object.freeze({documentId:a.incarnation.documentId,eventId:is(),incarnation:Object.freeze({...a.incarnation})})})});return ge(this,de,o),ve(this,Xe,wt).call(this,t,o)}async retry(t,r){const n=Me(this,de);if(!(n!=null&&n.options.documentSave)||!r.current()||!V(n.options.documentSave.incarnation,r.incarnation))throw new Ue;return{result:await ve(this,Xe,wt).call(this,t,n),content:n.content}}}de=new WeakMap,Se=new WeakMap,Xe=new WeakSet,wt=async function(t,r){try{const n=await t.writeFile(r.cwd,r.path,r.content,r.options);if(!n||typeof n!="object"||typeof n.ok!="boolean")throw new Ee;if(!n.ok){if(!n.conflict||typeof n.conflict.currentHash!="string"||!n.conflict.currentHash||typeof n.conflict.currentContent!="string")throw new Ee;return ge(this,de,void 0),n}if(typeof n.hash!="string"||!n.hash||n.effect!=="changed"&&n.effect!=="no_op")throw new Ee;const s="documentReceipt"in n?rn.parse(n.documentReceipt):void 0,i=r.options.documentSave;if(!s&&n.effect!=="no_op")throw new Ee;if(s&&(s.documentId!==i.documentId||s.eventId!==i.eventId||!V(s.incarnation,i.incarnation)||s.fileHash!==n.hash||(s.status==="accepted"?n.effect!=="changed":n.effect!=="no_op")))throw new Ee;if((s==null?void 0:s.status)==="duplicate"){const a=await t.readFileContent(r.cwd,r.path);if(!a||typeof a!="object"||Array.isArray(a)||typeof a.hash!="string"||!a.hash||typeof a.content!="string")throw new Ee;if(a.hash!==s.fileHash||a.content!==r.content)return ge(this,Se,s),ge(this,de,void 0),{ok:!1,conflict:{currentHash:a.hash,currentContent:a.content}}}return ge(this,Se,s),ge(this,de,void 0),n}catch(n){throw os(n)&&ge(this,de,void 0),n}};function cs({sourcePath:e,cwd:t,loadedContent:r,documentId:n,documentSaveBinding:s,documentRecoveryBinding:i}){const a=ue(),c=(s==null?void 0:s.incarnation)??(i==null?void 0:i.incarnation),o=c?JSON.stringify([c.documentId,c.physicalOpenedAt,c.channelCreatedAt,c.generation]):void 0,f=p.useRef(new as),l=p.useMemo(()=>({sourcePath:e,cwd:t,documentId:n,transport:a,birthKey:o}),[e,t,n,a,o]),h=p.useRef(null),u=p.useRef(null),g=p.useRef(Promise.resolve()),w=p.useCallback(()=>{var R;return((R=u.current)==null?void 0:R.identity)===l&&u.current.active},[l]);p.useLayoutEffect(()=>{var R;return((R=u.current)==null?void 0:R.identity)!==l?u.current={identity:l,baseHash:null,baseContent:r,active:!0,recoveryBinding:i,recoveryGate:i&&a.originalFileSaveRecovery?"pending":"unsupported"}:(u.current.active=!0,u.current.recoveryBinding=i),()=>{var k;((k=u.current)==null?void 0:k.identity)===l&&(u.current.active=!1)}},[l,r,i,a]);const[m,y]=p.useState({owner:l,status:"idle",conflict:null}),N=m.owner===l?m.status:"idle",D=m.owner===l?m.conflict:null,I=p.useCallback((R,k,L)=>{w()&&y(W=>({owner:l,status:R,documentReceipt:k,confirmedContent:L,conflict:W.owner===l?W.conflict:null}))},[l,w]),T=p.useCallback(R=>{w()&&y(k=>({owner:l,conflict:R,status:k.owner===l?k.status:"idle"}))},[l,w]),M=p.useCallback(()=>{var R,k;return((R=u.current)==null?void 0:R.recoveryGate)==="unsupported"||((k=u.current)==null?void 0:k.recoveryGate)==="observed_clear"},[]),U=p.useMemo(()=>{const R=()=>ss({owner:l,getOwner:()=>u.current,readTail:()=>g.current,writeTail:k=>{g.current=k},transport:a,cwd:t,sourcePath:e,documentId:n,pending:()=>f.current.pending});return{identity:l,supported:!!a.originalFileSaveRecovery,current:()=>R().current(),discover:k=>R().discover(k),recover:k=>R().recover(k),inspectCurrent:()=>R().inspectCurrent()}},[l,a,t,e,n]),P=!!(e&&t),q=p.useCallback((R,k,L,W=!1)=>{const K=()=>w()&&u.current===R&&(!s||s.current());if(k.ok){if(typeof k.hash!="string"||!k.hash||k.effect!=="changed"&&k.effect!=="no_op")throw new Error("Invalid file save acknowledgement");return R.baseHash=k.hash,R.baseContent=L,!W&&!K()?{status:"idle"}:(W||(T(null),I("saved",f.current.receipt,L)),{status:k.effect,confirmed:{hash:k.hash,content:L}})}return!W&&!K()?{status:"idle"}:(W||(T(k.conflict),I("conflict")),{status:"conflict"})},[w,s,T,I]),$=p.useCallback(async(R,k)=>{if(!w())return{status:"idle"};const L=u.current;s&&!f.current.pending&&(h.current=l);const W=await f.current.write(a,t,e,R,k,s);return q(L,W,R)},[w,a,t,e,s,q,l]),te=p.useCallback(R=>{var W;if(!P||!w())return Promise.resolve({status:"idle"});const k=((W=u.current.finalToken)==null?void 0:W.content)===R?u.current.finalToken:void 0,L=g.current.catch(()=>{}).then(async()=>{if(!w()||s&&!s.current())return{status:"idle"};if(f.current.pending)return I("uncertain"),{status:"uncertain"};if(!M())return I("error"),{status:"error"};u.current.finalToken===k&&(u.current.finalToken=void 0),I("saving");try{const K=u.current.baseHash!==null?{expectedHash:u.current.baseHash}:{expectedContent:u.current.baseContent};return await $(R,K)}catch(K){if(K instanceof Ue)return{status:"idle"};if(!w()||s&&!s.current())return{status:"idle"};const ae=f.current.pending?"uncertain":"error";return I(ae),{status:ae}}});return g.current=L.then(()=>{}),L},[P,$,w,I,s,M]),me=p.useCallback(R=>{if(!P||!w()||s&&!s.current())return null;const k=u.current,L={content:R,id:Symbol("buffered canvas draft")};return k.finalToken=L,{cancel(){k.finalToken===L&&(k.finalToken=void 0)},flush(){if(k.finalToken!==L||u.current!==k||k.active)return Promise.resolve({status:"idle"});k.finalToken=void 0;const W=g.current.catch(()=>{}).then(async()=>{if(u.current!==k||k.active)return{status:"idle"};try{if(k.recoveryGate!=="unsupported"&&k.recoveryGate!=="observed_clear")return{status:"error"};const K=k.baseHash!==null?{expectedHash:k.baseHash}:{expectedContent:k.baseContent};s&&!f.current.pending&&(h.current=l);const ae=await f.current.write(a,t,e,R,K,s,!0);return q(k,ae,R,!0)}catch{return{status:"error"}}});return g.current=W.then(()=>{}),W}}},[P,w,a,t,e,s,q,l]),x=p.useCallback(async R=>{const k=u.current;return!k||k.identity!==l?!1:(await g.current.catch(()=>{}),u.current===k&&!f.current.pending&&k.baseContent===R)},[l]),b=p.useCallback(()=>{if(!w()||!s||h.current!==l)return Promise.resolve({status:"idle"});const R=u.current,k=g.current.catch(()=>{}).then(async()=>{if(!w()||u.current!==R||h.current!==l)return{status:"idle"};try{I("saving");const L=await f.current.retry(a,s);return q(R,L.result,L.content)}catch(L){if(L instanceof Ue||!w()||u.current!==R)return{status:"idle"};const W=f.current.pending?"uncertain":"error";return I(W),{status:W}}});return g.current=k.then(()=>{}),k},[w,s,a,q,I,l]),S=p.useCallback(R=>{var K;if(!P||!D||!w())return Promise.resolve({status:"idle"});const k=D.currentHash,L=((K=u.current.finalToken)==null?void 0:K.content)===R?u.current.finalToken:void 0,W=g.current.catch(()=>{}).then(async()=>{if(!w()||s&&!s.current())return{status:"idle"};if(f.current.pending)return I("uncertain"),{status:"uncertain"};if(!M())return I("error"),{status:"error"};u.current.finalToken===L&&(u.current.finalToken=void 0),I("saving");try{return await $(R,{expectedHash:k})}catch(ae){if(ae instanceof Ue)return{status:"idle"};if(!w()||s&&!s.current())return{status:"idle"};const Ae=f.current.pending?"uncertain":"error";return I(Ae),{status:Ae}}});return g.current=W.then(()=>{}),W},[P,D,$,w,I,s,M]),_=p.useCallback(()=>{var R;return((R=u.current)==null?void 0:R.identity)===l?{hash:u.current.baseHash,content:u.current.baseContent}:{hash:null,content:r}},[l,r]),z=p.useCallback(()=>{if(!D||!w()||s&&!s.current())return null;u.current.finalToken=void 0;const R=D.currentContent;return u.current.baseHash=D.currentHash,u.current.baseContent=R,T(null),I("idle"),R},[D,w,T,I,s]);return{recovery:U,status:N,conflict:D,canSave:P,save:te,overwrite:S,adoptDisk:z,getConfirmedBase:_,prepareFinalSave:me,retryUnconfirmed:b,waitForCloseDrain:x,documentReceipt:m.owner===l?m.documentReceipt:void 0,confirmedContent:m.owner===l?m.confirmedContent:void 0}}const us=p.lazy(()=>Ce(()=>import("./BlintzCanvas-D_HlpfZu.js"),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.BlintzCanvas}))),ls=500;function ds(e){switch(e){case"saving":return"Saving…";case"saved":return"Saved";case"error":return"Couldn’t save";default:return null}}function fs({content:e,documentId:t,onContentChange:r}){const[n,s]=p.useState(!1),[i,a]=p.useState(e.content),c=J(b=>b.canvasSessionId),o=J(b=>b.setDocumentEditing),f=J(b=>{var S;return((S=b.openDocuments.find(_=>_.id===t))==null?void 0:S.editing)??!1}),l=J(b=>b.selectedCwd),h=n&&f,u=cs({documentId:t,sourcePath:e.sourcePath,cwd:l,loadedContent:e.content}),g=u.canSave,w=p.useRef(null),m=p.useRef(null),y=p.useRef(i),N=p.useRef(e),D=p.useRef(r),I=p.useRef(u.save),T=p.useRef(u.prepareFinalSave),M=p.useRef(null);p.useEffect(()=>{y.current=i,N.current=e,D.current=r,I.current=u.save,T.current=u.prepareFinalSave});const U=p.useCallback(b=>{J.getState().canvasSessionId===w.current&&(D.current({...N.current,content:b}),I.current(b))},[]),P=p.useCallback(b=>{var S;a(b),y.current=b,(S=M.current)==null||S.cancel(),M.current=T.current(b),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{m.current=null,U(b)},ls)},[U]),q=()=>{w.current=J.getState().canvasSessionId,a(e.content),s(!0),o(t,!0)},$=()=>{m.current&&(clearTimeout(m.current),m.current=null,U(y.current)),s(!1),o(t,!1)};p.useEffect(()=>{var b;h&&c!==w.current&&(m.current&&(clearTimeout(m.current),m.current=null),(b=M.current)==null||b.cancel(),M.current=null,s(!1),o(t,!1))},[c,h,t,o]),p.useEffect(()=>{var b;!n||h||(m.current&&clearTimeout(m.current),m.current=null,(b=M.current)==null||b.cancel(),M.current=null)},[h,n]),p.useEffect(()=>()=>{var b,S;m.current&&(clearTimeout(m.current),m.current=null,J.getState().canvasSessionId===w.current&&D.current({...N.current,content:y.current})),J.getState().canvasSessionId===w.current?(b=M.current)==null||b.flush():(S=M.current)==null||S.cancel(),M.current=null,o(t,!1)},[U,t,o]);const te=()=>{const b=u.adoptDisk();b!=null&&(r({...e,content:b}),a(b))},me=()=>{u.overwrite(y.current)},x=ds(u.status);return d.jsxs("div",{className:"relative flex h-full flex-col",children:[d.jsxs("div",{className:"sticky top-0 z-10 flex h-0 items-start justify-end gap-2 pr-2",children:[g&&x&&d.jsx("span",{className:"text-muted-foreground mt-3 text-xs","aria-live":"polite",children:x}),g&&d.jsx(et,{type:"button",variant:"ghost",size:"icon-md",className:"text-muted-foreground hover:text-foreground mt-2",onClick:h?$:q,"aria-label":h?"Finish editing":"Edit document",children:h?d.jsx(lr,{className:"size-4"}):d.jsx(dr,{className:"size-4"})})]}),u.status==="conflict"&&d.jsxs("div",{className:"bg-destructive/10 text-destructive mx-2 mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 rounded-md px-3 py-2 text-sm",children:[d.jsx("span",{className:"flex-1",children:"This file changed on disk since you opened it."}),d.jsx(et,{type:"button",variant:"ghost",size:"sm",className:"h-7",onClick:te,children:"Reload"}),d.jsx(et,{type:"button",variant:"destructive",size:"sm",className:"h-7",onClick:me,children:"Overwrite"})]}),d.jsx("div",{className:"flex-1 px-2 pb-6",children:d.jsx(p.Suspense,{fallback:d.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading editor…"}),children:d.jsx(us,{value:h?i:e.content,editable:h,onChange:h?P:void 0})})})]})}function hs({content:e}){return d.jsx("div",{className:"p-4 font-mono text-sm",children:d.jsx(br,{value:e.data,depth:0})})}const ps=20;function br({value:e,depth:t,keyName:r}){const[n,s]=p.useState(t>2),i=p.useCallback(()=>s(l=>!l),[]);if(t>=ps)return d.jsx(Fe,{keyName:r,value:"[max depth]",className:"text-muted-foreground"});if(e===null)return d.jsx(Fe,{keyName:r,value:"null",className:"text-muted-foreground"});if(typeof e=="boolean")return d.jsx(Fe,{keyName:r,value:String(e),className:"text-blue-500"});if(typeof e=="number")return d.jsx(Fe,{keyName:r,value:String(e),className:"text-green-500"});if(typeof e=="string")return d.jsx(Fe,{keyName:r,value:`"${e}"`,className:"text-amber-500"});const a=Array.isArray(e),c=a?e.map((l,h)=>[String(h),l]):Object.entries(e),o=a?"[":"{",f=a?"]":"}";return d.jsxs("div",{style:{paddingLeft:t>0?16:0},children:[d.jsxs("button",{type:"button",className:"hover:bg-muted -ml-0.5 inline-flex items-center gap-0.5 rounded px-0.5 transition-colors duration-150",onClick:i,children:[d.jsx(nn,{className:Dt("size-3 transition-transform",!n&&"rotate-90")}),r!=null&&d.jsxs("span",{className:"text-foreground",children:[r,": "]}),d.jsxs("span",{className:"text-muted-foreground",children:[o,n&&` … ${c.length} items `,n&&f]})]}),!n&&d.jsxs(d.Fragment,{children:[c.map(([l,h])=>d.jsx(br,{keyName:a?void 0:l,value:h,depth:t+1},l)),d.jsx("div",{className:"text-muted-foreground",children:f})]})]})}function Fe({keyName:e,value:t,className:r}){return d.jsxs("div",{style:{paddingLeft:16},children:[e!=null&&d.jsxs("span",{className:"text-foreground",children:[e,": "]}),d.jsx("span",{className:r,children:t})]})}const ms=new Set(["http:","https:"]);function gs(e){const t=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);return!t||t[1].length===1?null:`${t[1].toLowerCase()}:`}const vs={image:"data:image/",pdf:"data:application/pdf"};function wr(e,t,r){const n=e.trim();if(n.startsWith("data:"))return n.toLowerCase().startsWith(vs[t])?{url:n,error:null}:{url:null,error:"unsupported-data"};const s=gs(n);if(s!==null)return ms.has(s)?{url:n,error:null}:{url:null,error:"blocked"};const i=r(n);return i?{url:i,error:null}:{url:null,error:"local-unavailable"}}function yr(e,t){switch(e){case"blocked":return`This ${t} source is blocked for safety.`;case"unsupported-data":return`This data URI isn’t a valid ${t} source.`;case"local-unavailable":return`Local ${t} files can’t be displayed here.`}}function bs({content:e}){const t=ue(),r=J(l=>l.selectedCwd),n=p.useMemo(()=>wr(e.src,"image",l=>t.mediaUrl(r??"",l)),[e.src,t,r]),[s,i]=p.useState("loading"),[a,c]=p.useState(e.src);a!==e.src&&(c(e.src),i("loading"));const o=e.alt??e.title??"Canvas image";if(n.url===null){const l=n.error?yr(n.error,"image"):"";return d.jsx(tr,{children:l})}const f=n.url;return d.jsxs("div",{className:"bg-muted/40 relative flex h-full items-center justify-center",children:[s==="loading"&&d.jsx("p",{className:"text-muted-foreground absolute text-sm","aria-live":"polite",children:"Loading image…"}),s==="error"?d.jsx(tr,{children:"This image couldn’t be loaded."}):d.jsxs(cn,{centerOnInit:!0,doubleClick:{mode:"toggle"},wheel:{step:.15},children:[d.jsx(ws,{}),d.jsx(un,{wrapperClass:"!h-full !w-full",contentClass:"!h-full !w-full flex items-center justify-center",children:d.jsx("img",{src:f,alt:o,onLoad:()=>i("loaded"),onError:()=>i("error"),className:Dt("max-h-full max-w-full object-contain transition-opacity",s==="loaded"?"opacity-100":"opacity-0")})})]})]})}function ws(){const{zoomIn:e,zoomOut:t,resetTransform:r}=ln();return d.jsxs("div",{className:"absolute top-2 right-2 z-10 flex gap-1",children:[d.jsx(gt,{label:"Zoom in",onClick:()=>e(),children:d.jsx(gn,{className:"size-4"})}),d.jsx(gt,{label:"Zoom out",onClick:()=>t(),children:d.jsx(vn,{className:"size-4"})}),d.jsx(gt,{label:"Reset zoom",onClick:()=>r(),children:d.jsx(mn,{className:"size-4"})})]})}function gt({label:e,onClick:t,children:r}){return d.jsx("button",{type:"button",onClick:t,"aria-label":e,className:"bg-background/80 text-muted-foreground hover:text-foreground focus-ring rounded-md border p-1.5 backdrop-blur transition-colors",children:r})}function tr({children:e}){return d.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:d.jsx("p",{children:e})})}function ys({content:e}){const t=ue(),r=J(a=>a.selectedCwd),n=p.useMemo(()=>wr(e.src,"pdf",a=>t.mediaUrl(r??"",a)),[e.src,t,r]);if(n.url===null){const a=n.error?yr(n.error,"pdf"):"";return d.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:d.jsx("p",{children:a})})}const s=n.url,i=e.title??"PDF document";return d.jsx("object",{data:s,type:"application/pdf",title:i,className:"h-full w-full",children:d.jsxs("div",{className:"text-muted-foreground flex h-full flex-col items-center justify-center gap-3 p-8 text-center",children:[d.jsx("p",{children:"This PDF can’t be shown here."}),d.jsxs("a",{href:s,target:"_blank",rel:"noreferrer",className:"text-foreground focus-ring rounded-md underline underline-offset-4",children:["Open ",i," in a new tab"]})]})})}function xs(e){const t=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);return!t||t[1].length===1?null:`${t[1].toLowerCase()}:`}const ks=new Set(["http:","https:","data:"]);function xr(e,t,r){const n=e.trim(),s=xs(n);return s!==null?ks.has(s)?s==="data:"&&r!==void 0?n.toLowerCase().startsWith(r)?{url:n}:{url:null}:{url:n}:{url:null}:{url:t(n)}}function js({content:e}){const t=ue(),r=J(i=>i.selectedCwd),n=p.useMemo(()=>xr(e.src,i=>t.mediaUrl(r??"",i),"data:audio/"),[e.src,t,r]),s=e.title??"Canvas audio";return n.url===null?d.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:d.jsx("p",{children:"This audio can’t be played here."})}):d.jsx("div",{className:"bg-muted/40 flex h-full w-full items-center justify-center p-8",children:d.jsx("audio",{controls:!0,src:n.url,"aria-label":s,className:"w-full max-w-2xl",children:d.jsxs("p",{className:"text-muted-foreground text-sm",children:["Your browser can’t play this audio."," ",d.jsxs("a",{href:n.url,className:"text-foreground underline underline-offset-4",children:["Download ",s]}),"."]})})})}function Cs({content:e}){const t=ue(),r=J(i=>i.selectedCwd),n=p.useMemo(()=>xr(e.src,i=>t.mediaUrl(r??"",i),"data:video/"),[e.src,t,r]),s=e.title??"Canvas video";return n.url===null?d.jsx("div",{className:"text-muted-foreground flex h-full items-center justify-center p-8 text-center",children:d.jsx("p",{children:"This video can’t be played here."})}):d.jsx("div",{className:"bg-muted/40 flex h-full w-full items-center justify-center",children:d.jsx("video",{controls:!0,src:n.url,"aria-label":s,className:"max-h-full w-full max-w-full object-contain",children:d.jsxs("p",{className:"text-muted-foreground p-8 text-sm",children:["Your browser can’t play this video."," ",d.jsxs("a",{href:n.url,className:"text-foreground underline underline-offset-4",children:["Download ",s]}),"."]})})})}function kr({content:e,documentId:t,channel:r}){const[n]=St(),s=dn(e.definition),i=p.useMemo(()=>JSON.stringify(e.definition),[e.definition]);return d.jsx("div",{className:"p-4",children:s.ok?d.jsx(fn,{channel:r,document:s.document,sessionId:n??void 0},r?t??r.documentId:i):d.jsx(hn,{error:s.error,raw:s.raw})})}class Rs{constructor(){ee(this,"contiguous",0);ee(this,"through",0);ee(this,"pending",new Map)}get highest(){return this.contiguous}get catchUpThrough(){return this.through}get pendingCount(){return this.pending.size}reset(){this.contiguous=0,this.through=0,this.pending.clear()}resetHighest(){this.contiguous=0}advance(t){this.contiguous=Math.max(this.contiguous,t)}markThrough(t){this.through=Math.max(this.through,t)}recordGap(t){return this.markThrough(t.docSeq),this.pending.set(t.docSeq,t),this.pending.size<=200?!1:(this.pending.clear(),!0)}takeNextContiguous(){for(const n of this.pending.keys())n<=this.contiguous&&this.pending.delete(n);const t=this.contiguous+1,r=this.pending.get(t);return r&&this.pending.delete(t),r}clearReachedTarget(){return this.contiguous<this.through?!1:(this.through=0,!0)}}const yt=new WeakMap,Ze=new WeakMap,we=new WeakMap,We=new WeakMap;function je(e){De(e);const t=yt.get(e);if(!t)throw new Error("Replay owner lifetime is absent.");return t}function Os(e,t){const r=Ze.get(t);if(!r||r.owner!==e)throw new Error("Replay run is foreign.");return r}function jr(e){if(e&&typeof e=="object"&&!Object.isFrozen(e)){for(const t of Object.values(e))jr(t);Object.freeze(e)}return e}function Es(e){if(De(e),yt.has(e))throw new Error("Replay owner lifetime is already initialized.");yt.set(e,new Rs)}function At(e){const t=je(e);return Object.freeze({highest:t.highest,through:t.catchUpThrough,pending:t.pendingCount})}function rr(e){je(e).reset()}function nr(e,t){const r=Ze.get(t);if(!(!r||r.owner!==e))return Object.freeze({subject:r.subject,epoch:r.epoch,revision:r.revision,observation:r.observation,ended:r.ended})}function _s(e,t,r){const n=we.get(r),s=Ze.get(t);if(!(!s||s.owner!==e||!n||n.owner!==e||n.run!==t||n.phase!=="consuming"||n.admissionRead||!re(e,t)))return n.admissionRead=!0,Object.freeze({response:n.response,since:n.since,revision:n.revision,observation:n.observation,targetBirth:s.targetBirth})}function Ss(e,t,r){const n=Os(e,t),s=we.get(r),i=_r(e,t,r);if(!i||!s||s.owner!==e||s.run!==t||s.phase!=="consuming"||!s.admissionRead||n.ended||n.epoch!==i.epoch||n.subject!==i.previous)throw new Error("Replay own issuance is foreign or stale.");n.subject=i.subject}function Cr(e,t,r,n){if(!re(e,t))return;if(n){const i=We.get(r);return i&&i.owner===e&&i.run===t&&i.phase==="dispatching"&&!i.advanced?i.frame:void 0}const s=we.get(r);return s&&s.owner===e&&s.run===t&&s.phase==="frames"&&s.dispatching!==void 0&&!s.advanced?s.frames[s.dispatching]:void 0}function Ds(e,t,r,n){const s=ni(e,t,r,n);if(!s||!re(e,t))throw new Error("Replay cursor advance has no genuine core witness.");const i=n?We.get(r):we.get(r);if(!i||i.advanced)throw new Error("Replay frame advance was consumed.");i.advanced=!0,je(e).advance(s.docSeq)}function Is(e,t){const r=Ze.get(t),n=(r==null?void 0:r.lastPage)&&we.get(r.lastPage);if(!r||r.owner!==e||!re(e,t)||r.target===void 0||!n||n.phase!=="finished"||n.next!==n.frames.length||n.response.events.length>=200&&je(e).highest<r.target)return;const s=je(e);return Object.freeze({highest:s.highest,through:s.catchUpThrough,target:r.target})}function As(e,t){const r=Je(e,t);if(!r)throw new Error("Replay notice is foreign or stale.");const n=je(e),s=r.notification;if(r.mode==="quarantine")n.markThrough(s.type==="canvas_channel_snapshot"?s.snapshot.highWatermark:s.docSeq),s.type!=="canvas_channel_snapshot"&&n.recordGap(s);else{if(r.mode==="gap"&&s.type!=="canvas_channel_snapshot")return n.recordGap(s);r.mode==="event"&&gi(e,t)}return!1}function Ns(e,t){const r=Je(e,t);if(!r||r.mode!=="event"||r.notification.type==="canvas_channel_snapshot")throw new Error("Notice cursor advance is foreign.");je(e).advance(r.notification.docSeq)}function zs(e){const t=ce(e),r=je(e),n=Object.freeze({}),s={owner:e,subject:t.subject,epoch:t.epoch,revision:t.revision,observation:t.observation,ended:!1,starting:r.highest,succeeded:!1};Ze.set(n,s),ai(e,n);const i=()=>re(e,n),a=()=>ce(e).live?i()?void 0:"restart":"stop";return Object.freeze({async readPage(){if(!i())return null;const c=ce(e),o=r.highest,f=ut(e),l=f.getCanvasChannel;if(!i())return null;const h=await l.call(f,t.documentId,{since:o,limit:200});if(!i())return null;const u=jr(sn.parse(h));if(!i())return null;const g=Object.freeze({});return we.set(g,{owner:e,run:n,response:u,since:o,revision:c.revision,observation:c.observation,phase:"read",admissionRead:!1,frames:[],next:0,advanced:!1}),g},consumePage(c){const o=we.get(c);return!i()||!o||o.owner!==e||o.run!==n||o.phase!=="read"?{kind:"done"}:(o.phase="consuming",ci(e,n,c)!=="accepted"||!i()?(o.phase="finished",{kind:"done"}):(s.target??(s.target=o.response.highWatermark),s.targetBirth=o.response.incarnation,o.frames=Object.freeze(o.response.events.filter(l=>l.docSeq<=s.target)),o.phase="frames",s.lastPage=c,o.response.resetRequired&&r.advance(o.response.retentionFloor-1),{kind:"frames",count:o.frames.length}))},advancePageFrame(c,o){const f=we.get(c);if(!i()||!f||f.owner!==e||f.run!==n||f.phase!=="frames"||o!==f.next||!f.frames[o])return!1;f.next=o+1,f.dispatching=o,f.advanced=!1;try{return ir(e,n,c,!1)&&i()}finally{f.dispatching=void 0}},finishPage(c){const o=we.get(c);if(!i()||!o||o.owner!==e||o.run!==n||o.phase!=="frames"||o.next!==o.frames.length||s.target===void 0)return"done";if(o.phase="finished",o.response.events.length<200||r.highest>=s.target)return r.advance(s.target),!i()||(or(e,n),!i())||(s.succeeded=!0),"done";if(r.highest<=o.since)throw new Error("Document replay made no progress.");return"again"},failed(){i()&&ui(e,n)},beginFinalization(){return a()??(s.succeeded?"drain":"stop")},takePending(){if(!i())return null;const c=r.takeNextContiguous();if(!c||!i())return null;const o=Object.freeze({});return We.set(o,{owner:e,run:n,frame:c,phase:"taken",advanced:!1}),o},advancePending(c){const o=We.get(c);if(!i()||!o||o.owner!==e||o.run!==n||o.phase!=="taken")return!1;o.phase="dispatching";try{return ir(e,n,c,!0)&&i()}finally{o.phase="finished",We.delete(c)}},finishFinalization(){const c=a();if(c)return c;if(r.clearReachedTarget()){const o=a();if(o)return o;or(e,n);const f=a();if(f)return f}if(r.pendingCount||r.catchUpThrough>r.highest){const o=ce(e);if(r.highest>s.starting||o.revision>s.revision||o.observation>s.observation)return"restart";li(e,n)}return a()??"stop"},current:i,end:()=>{s.ended=!0}})}var pe,kt,Le;class xt{constructor(){Te(this,pe);ee(this,"current",null);ee(this,"token",0);ee(this,"retiring",!1);ee(this,"subscribers",new Set);ee(this,"resources",new Map);ee(this,"doc",null);ee(this,"docClaims",new WeakMap);ee(this,"retiringDoc",!1);ee(this,"docResources",new Map);ee(this,"bindings",new WeakSet)}getCurrent(){return this.current}observeHostContext(t){if(this.retiring)return null;if(!t.transportOwner||typeof t.transportOwner!="object"||!Number.isSafeInteger(t.publisherEpoch)||t.publisherEpoch<0)throw new Error("Explicit transport owner and epoch required.");const r=["frame","documentId","resolvedSource","logicalUrl","reloadKey","sessionId","eligibility","exactOrigin","transportOwner","publisherEpoch"];if(r.some(s=>!Object.hasOwn(t,s))||typeof t.documentId!="string"||!t.documentId||typeof t.logicalUrl!="string"||typeof t.reloadKey!="string")throw new Error("Complete host context required.");const n=this.current;return n&&r.every(s=>Object.is(n[s],t[s]))?n:(this.retire(),this.current=Object.freeze({...t,token:this.token,loaded:!1}),this.current)}observeLoaded(t){return this.retiring||this.current!==t||!t.frame?null:(this.retire(),this.current=Object.freeze({...t,token:this.token,loaded:!0}),this.current)}retire(){if(this.retiring)return;const t=this.current;this.current=null;const r=this.doc;this.doc=null,this.token++,this.retiring=!0;const n=[...t?this.resources.get(t)??[]:[],...r?this.docResources.get(r)??[]:[],...this.subscribers];r&&this.docResources.delete(r),t&&this.resources.delete(t);try{for(const s of n)try{const i=s();i&&typeof i.then=="function"&&Promise.resolve(i).catch(()=>{})}catch{}}finally{this.retiring=!1}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}own(t,r){if(this.retiring||this.current!==t)throw new Error("Frame observation retired.");const n=this.resources.get(t)??new Set;return n.add(r),this.resources.set(t,n),()=>{n.delete(r)}}bindDoc(t,r,n){return ve(this,pe,kt).call(this,t,r,n)}acquireDoc(t,r,n){const s=ve(this,pe,kt).call(this,t,r,n),i=Object.freeze({});this.docClaims.set(s,i);let a=!1;return Object.freeze({binding:s,release:()=>{a||(a=!0,this.docClaims.get(s)===i&&(this.docClaims.delete(s),this.doc===s&&this.bindings.has(s)&&ve(this,pe,Le).call(this)))}})}disableDoc(){ve(this,pe,Le).call(this)}retireDoc(t){this.doc===t&&this.bindings.has(t)&&ve(this,pe,Le).call(this)}ownDoc(t,r){if(!this.isCurrent(t))throw new Error("Doc binding retired.");const n=this.docResources.get(t)??new Set;return n.add(r),this.docResources.set(t,n),()=>{n.delete(r)}}isCurrent(t){return!this.retiring&&!this.retiringDoc&&this.doc===t&&this.bindings.has(t)&&this.current===t.observation}}pe=new WeakSet,kt=function(t,r,n){const s=this.doc,i=this.token,a=ns(cr,r);if(!a)throw this.disableDoc(),new Error("Established server Doc birth required.");const c=a,o=t.exactOrigin,f=t.eligibility==="served-document"?o==="null":t.eligibility==="preview-listener"&&o!==null&&new URL(o).origin===o;if(!t.loaded||!t.frame||typeof t.frame.postMessage!="function"||!t.resolvedSource||!f||t.documentId!==c.documentId||!n||n.length>200)throw new Error("Loaded eligible frame and established Doc birth required.");if(this.retiring||this.retiringDoc||this.current!==t||this.doc!==s||this.token!==i)throw new Error("Frame observation retired during Doc admission.");if(this.doc){if(this.doc.observation!==t)throw new Error("Doc binding belongs to another host load.");if(V(this.doc.incarnation,c)&&this.doc.scope===n)return this.doc;throw this.retire(),new Error("Doc birth changed; a fresh host load is required.")}const l=Object.freeze({observation:t,incarnation:Object.freeze(c),scope:n});try{return this.doc=l,this.bindings.add(l),l}catch(h){throw this.doc===l&&ve(this,pe,Le).call(this),h}},Le=function(){if(this.retiringDoc)return;const t=this.doc;this.doc=null,this.retiringDoc=!0;const r=[...t?this.docResources.get(t)??[]:[]];t&&this.docResources.delete(t);try{for(const n of r)try{const s=n();s&&typeof s.then=="function"&&Promise.resolve(s).catch(()=>{})}catch{}}finally{this.retiringDoc=!1}};function Ms(e,t,r){if(!r||typeof r.captureOriginal!="function"||typeof r.submit!="function"||typeof r.inspect!="function"||typeof r.isCurrentOwner!="function"||r.owner!==t.observation.transportOwner||r.publisherEpoch!==t.observation.publisherEpoch)throw new Error("Explicit current transport submit and inspect ports required.");const{owner:n,publisherEpoch:s,isCurrentOwner:i,submit:a,inspect:c,captureOriginal:o}=r,f=Object.freeze({expectedGeneration:t.incarnation.generation}),l=()=>{try{return e.isCurrent(t)?i(n,s)===!0&&e.isCurrent(t):!1}catch{return!1}};if(!l())throw new Error("Doc binding unavailable.");const h=()=>{if(!l())throw new Error("Doc binding retired.")};return Object.freeze({binding:t,current:l,captureOriginal:u=>{h();const g=u.id;h();const w=u.bytes;h();const m=Reflect.apply(o,r,[Object.freeze({id:g,bytes:w})]);if(h(),!m)return null;const y=m.id;h();const N=m.bytes;h();const D=m.submit;h();const I=m.inspect;return h(),y!==g||N!==w||typeof D!="function"||typeof I!="function"?null:Object.freeze({id:g,bytes:w,submit:async T=>{h(),T.throwIfAborted();const M=await Reflect.apply(D,m,[T]);return h(),T.throwIfAborted(),M},inspect:async T=>{h(),T.throwIfAborted();const M=await Reflect.apply(I,m,[T]);return h(),T.throwIfAborted(),M}})},retireObservation:()=>{l()&&e.retire()},onRetire:u=>e.ownDoc(t,u),submit:(u,g)=>(h(),g.throwIfAborted(),a(u,f,g)),inspect:(u,g)=>(h(),g.throwIfAborted(),c(u,f,g))})}class Ts{constructor(){ee(this,"revision",0);ee(this,"draining",!1);ee(this,"cleanup");ee(this,"subscribers",new Set);ee(this,"retirements",new WeakMap)}captureRetirement(){const t=Object.freeze({}),r=++this.revision,n=this.cleanup;return this.cleanup=void 0,this.retirements.set(t,{revision:r,cleanup:n,callbacks:this.draining?[]:[...this.subscribers]}),t}drainRetirement(t){const r=this.retirements.get(t);if(!r)throw new Error("Frame resource retirement is foreign or consumed.");this.retirements.delete(t);const n=this.draining;this.draining=!0;try{this.drain(r.cleanup);for(const s of r.callbacks)this.drain(s)}finally{this.draining=n}}begin(){const t=this.captureRetirement(),r=this.revision;return this.drainRetirement(t),r}once(t,r,n){let s=!1;return()=>{if(s||(s=!0,!this.current(t)||!r()||!this.current(t)))return null;const i=n();return!this.current(t)||!r()||!this.current(t)?null:i}}drain(t){try{Promise.resolve(t==null?void 0:t()).catch(()=>{})}catch{}}current(t){return this.revision===t}install(t,r){return this.current(t)?(this.cleanup=r,!0):!1}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}}function Fs(e,t,r){const n=()=>e.current(t)&&r.current()===!0&&e.current(t),s=e.once(t,n,r.complete);return Object.freeze({completeLoad:()=>{const i=s();return!i||!n()||r.accept(i)!==!0||!n()?null:i}})}function qs(e,t,r){const n=()=>e.current(t)&&r.current()===!0&&e.current(t);if(!n())return null;const s=r.acquire();if(!s)return null;let i=!1,a=null,c;try{const o=s.binding;if(n()&&r.bindingCurrent(o)===!0&&n()){const f=r.createPort(o);n()&&r.portCurrent(f)===!0&&n()&&e.install(t,s.release)&&(i=!0,a=f)}}catch(o){c={cause:o}}if(!i)try{s.release()}catch(o){c??(c={cause:o})}if(c)throw c.cause;return a}function Ls(e){const t=()=>Object.assign(new Error("Document actions are unavailable."),{status:409}),r=(s,i)=>{if(i.aborted||!e.current(s)||i.aborted)throw t()},n=(s,i)=>{const a=ur.parse(i);if(a.receipt.id!==s)throw new Error("Document receipt does not match this action.");return a};return Object.freeze({current:e.current,submit:async(s,i)=>{const a=rt.parse(JSON.parse(JSON.stringify(s))),c=a.id;r("submit",i);const o=await e.submit(a,i);r("read",i);const f=n(c,o);return r("read",i),f},inspect:async(s,i)=>{r("read",i);const a=await e.inspect(s,i);r("read",i);const c=n(s,a);return r("read",i),c},captureOriginal:s=>{const i=rt.parse(JSON.parse(JSON.stringify(s))),a=i.id,c=JSON.stringify(i);if(!e.current("submit"))return null;const o=e.capture(i,c);if(!o||!e.current("submit")||!o.current("submit"))return null;let f=!1;const l=h=>o.current(h)===!0;return Object.freeze({id:a,bytes:c,current:l,submit:async h=>{if(f||h.aborted||!l("submit"))throw t();f=!0;const u=await o.submit(JSON.parse(c),h);if(h.aborted||!l("read"))throw t();const g=n(a,u);if(h.aborted||!l("read"))throw t();return g},inspect:async h=>{if(h.aborted||!l("read"))throw t();const u=await o.inspect(a,h);if(h.aborted||!l("read"))throw t();const g=n(a,u);if(h.aborted||!l("read"))throw t();return g}})}})}function Ps(e){return Object.freeze({id:e.id,bytes:e.bytes,submit:async t=>{try{return{kind:"accepted",receipt:await e.submit(t)}}catch{return{kind:"uncertain"}}},inspect:async t=>{try{return{kind:"accepted",receipt:await e.inspect(t)}}catch{return{kind:"unknown"}}}})}function Bs(e,t,r){const n=rt.parse(JSON.parse(e.bytes));if(n.id!==e.id||JSON.stringify(n)!==e.bytes||!r())return null;const s=t(n);return!r()||!s?null:Ps(s)}const Us=xt.prototype.acquireDoc,st=new WeakMap,jt=new WeakMap;function Ws(e,t){const r=ut(e),n=new WeakMap,s=(a,c)=>t.current(c)&&ke(e,a,!0);return Object.freeze({prepareFrameLoad:(a,c)=>{var u;if(!(a instanceof xt)||c.loaded)return null;const o=sr(e),f=o?(u=_e(e,o))==null?void 0:u.httpBaseline:void 0,l=t.begin();if(!o||!f||!t.current(l)||!ke(e,o,!0)||a.getCurrent()!==c||c.transportOwner!==r||!s(o,l))return null;let h=null;return Fs(t,l,{current:()=>{var g;return ke(e,o,!0)&&((g=_e(e,o))==null?void 0:g.httpBaseline)===f&&a.getCurrent()===(h??c)&&t.current(l)&&ke(e,o,!0)},complete:()=>(h=a.observeLoaded(c),h),accept:g=>{var w,m;return!t.current(l)||!ke(e,o,!0)||((w=_e(e,o))==null?void 0:w.httpBaseline)!==f||a.getCurrent()!==g||!t.current(l)||!ke(e,o,!0)||((m=_e(e,o))==null?void 0:m.httpBaseline)!==f?!1:(n.set(g,{record:o,birth:f.birth}),!0)}})},subscribeInvalidation:a=>t.subscribe(a),attachFrame:(a,c)=>{if(!(a instanceof xt))return null;const o=sr(e),f=t.begin();if(!o||!t.current(f)||!ke(e,o,!0)||a.getCurrent()!==c||c.transportOwner!==r||!s(o,f))return null;const l=n.get(c);return!l||l.record!==o||!V(l.birth,_e(e,o).birth)?null:qs(t,f,{current:()=>s(o,f),acquire:()=>{const h=Us.call(a,c,_e(e,o).birth,_e(e,o).birth.documentId);let u=!1,g=null,w;try{s(o,f)&&a.getCurrent()===c&&s(o,f)&&(g=Object.freeze({binding:h.binding,release:h.release}),u=!0)}catch(m){w={cause:m}}if(!u)try{h.release()}catch(m){w??(w={cause:m})}if(w)throw w.cause;return g},bindingCurrent:h=>a.isCurrent(h)&&s(o,f),createPort:h=>Ms(a,h,{owner:r,publisherEpoch:c.publisherEpoch,isCurrentOwner:(u,g)=>u===r&&g===c.publisherEpoch&&t.current(f)&&ke(e,o),captureOriginal:u=>Bs(u,g=>{var w;return((w=oi(e,o))==null?void 0:w.captureOriginal(g))??null},()=>s(o,f)),submit:async()=>({kind:"terminal"}),inspect:async()=>({kind:"unknown"})}),portCurrent:h=>h.current()&&s(o,f)})}})}function Gs(e){if(De(e),st.has(e))throw new Error("Frame owner is already initialized.");const t=new Ts,r=Ws(e,t);return st.set(e,{frames:t,facade:r}),r}function $s(e){var t;return De(e),(t=st.get(e))==null?void 0:t.facade}function Pe(e){De(e);const t=st.get(e);if(!t)return;const r=Object.freeze({});return jt.set(r,{owner:e,frames:t.frames,ticket:t.frames.captureRetirement()}),r}function Be(e,t){if(!t)return;const r=jt.get(t);if(!r||r.owner!==e)throw new Error("Frame retirement is foreign or consumed.");jt.delete(t),r.frames.drainRetirement(r.ticket)}function Rr(e,t){const r=be(e,t),n=ri(e,t);if(!(!r||!n))return{owner:t,verified:r.verified,...Ls(n)}}function he(e,t){return{documentId:e,transport:t,events:[],available:!1}}function Hs(e,t,r,n,s,i){var o,f;const a=e.documentId===r&&e.transport===n?e:he(r,n);if(a.snapshot&&(t.highWatermark<a.snapshot.highWatermark||t.stateRev<a.snapshot.stateRev))return a;const c=new Map((((o=a.snapshot)==null?void 0:o.receipts)??[]).filter(l=>l.receipt.docSeq>=t.receiptRetentionFloor).map(l=>[l.receipt.id,l]));for(const l of t.receipts)c.set(l.receipt.id,l);return{...a,available:i,snapshot:{...t,...s?{}:{routing:(f=a.snapshot)==null?void 0:f.routing},receipts:[...c.values()].sort((l,h)=>h.receipt.docSeq-l.receipt.docSeq).slice(0,400)},events:t.resetRequired?a.events.filter(l=>l.docSeq>=t.retentionFloor):a.events}}function Vs(e){var r,n,s,i,a,c,o,f,l,h,u,g;const t=async()=>{throw Object.assign(new Error("Document actions are unavailable."),{status:409})};return{documentId:e.documentId,enabled:e.available&&((r=e.binding)==null?void 0:r.verified)===!0&&((s=(n=e.snapshot)==null?void 0:n.routing)==null?void 0:s.enabled)===!0,submissionOwner:(i=e.binding)==null?void 0:i.owner,current:((a=e.binding)==null?void 0:a.current)??(()=>!1),approvedEventTypes:e.available?((o=(c=e.snapshot)==null?void 0:c.routing)==null?void 0:o.approvedEventTypes)??[]:[],destinationLabel:e.available?((l=(f=e.snapshot)==null?void 0:f.routing)==null?void 0:l.destinationLabel)??"Actions unavailable":"Actions unavailable",...e.snapshot?{snapshot:e.snapshot}:{},submit:((h=e.binding)==null?void 0:h.submit)??t,inspect:((u=e.binding)==null?void 0:u.inspect)??t,captureOriginal:(g=e.binding)==null?void 0:g.captureOriginal}}function Js(e,t,r){return!!(e&&t&&r.incarnation&&V(t,r.incarnation)&&(r.highWatermark<e.highWatermark||r.stateRev<e.stateRev))}function Or(e,t,r,n){const s=e.documentId===r&&e.transport===n?e:he(r,n);return{...s,events:[...s.events,t].slice(-200)}}function Xs(e,t){if(e.incarnation&&(e.incarnation.documentId!==t||e.events.some(r=>r.documentId!==t||!r.incarnation||!V(e.incarnation,r.incarnation))))throw new Error("Document replay identity changed.")}const Ct=new WeakMap;function Zs(e,t,r){const n=_s(e,t,r);if(n)return Ct.set(r,{owner:e,run:t,witness:n}),n}const Er=new WeakMap,Ve=new WeakMap,Rt=new WeakMap,Ot=new WeakMap;function ye(e,t){De(e);const r=t??Ve.get(e),n=r&&Er.get(r);return n&&n.owner===e&&Ve.get(e)===r&&n.active?n:void 0}function X(e){return De(e),Ve.get(e)}function be(e,t){const r=ye(e,t);return r?Object.freeze({birth:r.birth,httpBaseline:r.httpBaseline,snapshot:r.snapshot,verified:r.verified}):void 0}function Ge(e,t,r=!1){var i,a;const n=ye(e,t),s=ce(e);return!!n&&s.live&&n.verified&&n.transport===ut(e)&&(!r||((a=(i=n.snapshot)==null?void 0:i.routing)==null?void 0:a.enabled)===!0)}function Ys(e){const t=ye(e);Ve.delete(e),t&&(t.active=!1,t.verified=!1)}function vt(e,t){const r=ye(e,t);r&&(r.verified=!1)}function Qs(e,t,r){const n=ye(e,r);return!n||!re(e,t)?!1:(n.verified=!0,re(e,t))}function Ks(e,t,r){const n=Ct.get(r);Ct.delete(r);const s=(n==null?void 0:n.owner)===e&&n.run===t?n.witness:void 0;if(!s||!re(e,t))return!1;const i=s.response.incarnation;let a=ye(e);if(!a&&!i)return re(e,t);if(!a&&i){const c=ce(e),o=()=>{const w=ce(e);return re(e,t)&&w.epoch===c.epoch&&w.observation===c.observation&&X(e)===c.subject},f=ut(e),l=f.ingestCanvasEvent;if(!o())return!1;const h=Function.prototype.bind.call(l,f),u=f.getCanvasEventReceipt;if(!o())return!1;const g=Function.prototype.bind.call(u,f);if(!o())return!1;a={owner:e,token:Object.freeze({}),birth:Object.freeze({...i}),active:!0,verified:!1,submit:h,inspect:g,transport:f},Er.set(a.token,a),Ve.set(e,a.token),a.httpBaseline=Object.freeze({birth:a.birth,floor:s.response.receiptRetentionFloor}),Rt.set(r,Object.freeze({owner:e,run:t,epoch:c.epoch,previous:c.subject,subject:a.token}));try{Ss(e,t,r)}catch(w){throw ye(e)===a&&hi(e,t,r),w}finally{Rt.delete(r)}if(!re(e,t))return!1}else if(a){if(!i||!V(a.birth,i))return!1;a.httpBaseline=Object.freeze({birth:a.birth,floor:s.response.receiptRetentionFloor})}return re(e,t)?(a&&(a.verified=pi(e)||a.verified),!0):!1}function Nt(e,t,r){const n=zt(e),s=n.subject,i=()=>Ir(e,n,r);if(!s||!Ge(e,s)){const o=Pe(e);Be(e,o)}if(!i())return;const a=s&&Rr(e,s),c=$s(e);n.dispatch(o=>{var h;if(!i())return o;const f=((h=o.binding)==null?void 0:h.owner)===s?o:he(n.documentId,n.transport),l=typeof t=="function"?t(f):t;return i()?{...l,...l.snapshot?{snapshot:Object.freeze({...l.snapshot})}:{},binding:a,frameAdmission:c}:o})}function ei(e,t,r,n,s){const i=zt(e),a=ye(e);Ir(e,i,s)&&(a&&(a.snapshot=t),Nt(e,c=>Hs(c,t,i.documentId,i.transport,r,n),s))}function ti(e,t,r,n){const s=Cr(e,t,r,n);if(!re(e,t)||!s)return!1;if(s.docSeq<=At(e).highest)return re(e,t);Ot.set(r,{owner:e,run:t,pending:n,frame:s});try{Ds(e,t,r,n)}finally{Ot.delete(r)}if(!re(e,t))return!1;const i=zt(e);return Nt(e,a=>Or(a,s,i.documentId,i.transport),t),re(e,t)}function ri(e,t){const r=ye(e,t);if(!r)return;const n=ce(e).documentId;return{current:s=>Ge(e,t,s==="submit"),submit:(s,i)=>r.submit(n,s,{expectedGeneration:r.birth.generation},i),inspect:(s,i)=>r.inspect(n,s,{expectedGeneration:r.birth.generation},i),capture:()=>{const s=r.httpBaseline;return!s||!Ge(e,t,!0)||!V(s.birth,r.birth)?null:Object.freeze({current:i=>Ge(e,t,i==="submit")&&(i==="read"||r.httpBaseline===s),submit:(i,a)=>r.submit(n,i,{expectedGeneration:s.birth.generation},a),inspect:(i,a)=>r.inspect(n,i,{expectedGeneration:s.birth.generation},a)})}}}function _r(e,t,r){const n=Rt.get(r),s=ce(e);return n&&n.owner===e&&n.run===t&&s.epoch===n.epoch&&s.subject===n.subject&&s.live?n:void 0}function ni(e,t,r,n){const s=Ot.get(r);return s&&s.owner===e&&s.run===t&&s.pending===n&&re(e,t)?s.frame:void 0}const Sr=new WeakMap,it=new WeakMap;function si(e){const t=it.get(e);if(!t)throw new Error("Document construction ticket is foreign or consumed.");return it.delete(e),t}function ii(e,t,r){const n=Object.freeze({});it.set(n,Object.freeze({documentId:e,transport:t,dispatch:r}));try{const s=mi(n);return Sr.set(n,s),n}finally{it.delete(n)}}function Q(e){const t=Sr.get(e);if(!t)throw new Error("Document owner is foreign.");return t}function De(e){Q(e)}function ce(e){return Q(e).facts()}function ut(e){return Q(e).transport()}function sr(e){return Q(e).subject()}function _e(e,t){return Q(e).subjectFacts(t)}function ke(e,t,r=!1){return Q(e).subjectCurrent(t,r)}function oi(e,t){return Q(e).binding(t)}function ai(e,t){Q(e).reserve(t)}function re(e,t){return Q(e).current(t)}function ci(e,t,r){return Q(e).admit(t,r)}function ir(e,t,r,n){return Q(e).frame(t,r,n)}function or(e,t){return Q(e).qualify(t)}function ui(e,t){Q(e).failed(t)}function li(e,t){Q(e).unavailable(t)}function di(e,t){Q(e).start(t)}function fi(e){Q(e).dispose()}const Dr=new WeakMap;function zt(e){const t=Object.freeze(Q(e).projection());return Dr.set(t,Object.freeze({custodyKey:e,capture:t})),t}function Ir(e,t,r){const n=Dr.get(t);return(n==null?void 0:n.custodyKey)===e&&n.capture===t&&Q(e).projectionCurrent(t.epoch,t.subject,r)}function hi(e,t,r){Q(e).abortAdmission(t,r)}function pi(e){return Q(e).qualified()}const Et=new WeakMap;function mi(e){const{documentId:t,transport:r,dispatch:n}=si(e);let s,i=!1,a;const c={live:!0};let o=0,f,l,h=!1,u,g,w=0;const m=()=>c.live,y=()=>Ys(e);let N=0;const D=()=>At(e),I=x=>{const b=nr(e,x);return!!b&&!b.ended&&m()&&s===x&&b.epoch===o&&b.subject===X(e)},T=(x=!1)=>{const b=Pe(e);y(),o++,s=void 0,x&&rr(e),Be(e,b)},M=(x,b)=>Nt(e,x,b),U=x=>{const b=Is(e,x),S=X(e),_=S&&be(e,S);return!I(x)||!b||b.through>b.highest||!u||!_||!V(u,_.birth)||!Qs(e,x,S)?!1:(u=void 0,M(z=>({...z,available:!0}),x),I(x))},P=(x,b,S)=>{const _=X(e),z=_&&be(e,_),R=o,k=()=>m()&&R===o&&X(e)===_&&(!S||I(S));if(!k()||Js(z==null?void 0:z.snapshot,z==null?void 0:z.birth,x))return;const L=b?x.routing:l;x={...x,routing:L&&Object.freeze({enabled:L.enabled,destinationLabel:L.destinationLabel,approvedEventTypes:Object.freeze([...L.approvedEventTypes])})},b&&(l=x.routing),!_&&!x.incarnation&&(h=!0),k()&&ei(e,x,b,u===void 0,S)},q=(x,b)=>{var ae;const S=Zs(e,x,b);if(!I(x)||!S)return"discard";const _=S.response;Xs(_,t);const z=_.incarnation;if((X(e)||u||g)&&!z)throw new Error("Document replay identity is unavailable.");if(g&&z&&!V(g,z))return T(!0),M(he(t,r)),"restart";const R=X(e),k=(R&&((ae=be(e,R))==null?void 0:ae.birth))??u;if(z&&(k&&!V(k,z)||!k&&h||S.targetBirth&&!V(S.targetBirth,z)))return u=z,h=!1,l=void 0,f=void 0,T(!0),M(he(t,r)),"restart";const{events:L,...W}=_,K=X(e);return!K&&z&&(u=g??z),!Ks(e,x,b)||!I(x)?"discard":(!K&&z&&(g=void 0),P(W,S.revision===N,x),I(x)?"accepted":"discard")},$=(x,b,S)=>{var k;const _=Cr(e,x,b,S),z=X(e),R=(z&&((k=be(e,z))==null?void 0:k.birth))??u;return!I(x)||!_||_.documentId!==t||R&&(!_.incarnation||!V(R,_.incarnation))?!1:ti(e,x,b,S)},te=(x,b)=>{const S=Object.freeze({});Et.set(S,Object.freeze({owner:e,revision:N,observation:w,epoch:o,notification:x,mode:b}));try{return As(e,S)}finally{Et.delete(S)}},me=x=>{if(i||!m()||(i=!0,M(he(t,r)),!m()))return;const b=on(void 0,S=>{if(!m()||S.documentId!==t)return;const _=S.type==="canvas_channel_snapshot"?S.snapshot.incarnation:S.incarnation,z=X(e);if(!z){if(u&&!g&&(!_||!V(u,_))||!_||_.documentId!==t)return;if(!g||!V(g,_)){const R=!!g||!!u;if(g=Object.freeze({..._}),w++,l=void 0,f=void 0,h=!1,R&&(T(!0),M(he(t,r))),!m()||!g||!V(g,_))return}te(S,"quarantine"),m()&&x();return}if(u&&(!_||!V(u,_))){_&&x();return}if(_&&!V(be(e,z).birth,_)){u=_,h=!1,l=void 0,f=void 0,T(!0),M(he(t,r)),m()&&x();return}if(_){if(f!==void 0&&f!==S.scope){const R=Pe(e);if(f=S.scope,vt(e,z),o++,s=void 0,N++,Be(e,R),X(e)!==z||!m())return;M(k=>({...k,available:!1})),X(e)===z&&m()&&x();return}f=S.scope,N++,S.type==="canvas_channel_snapshot"?P(S.snapshot,!0):S.docSeq>D().highest+1?(te(S,"gap")&&m()&&M(k=>({...k,available:!1})),m()&&x()):te(S,"event")}},r,()=>{if(!m())return;const S=Pe(e),_=X(e);_&&vt(e,_),o++,s=void 0,N++,Be(e,S),M(z=>({...z,available:!1})),m()&&x()});m()?a=b:b(),m()&&x()};return Ar.set(e,x=>{const b=Je(e,x);if(!b||b.notification.type==="canvas_channel_snapshot")return;const S=X(e),_=o;!S||!b.notification.incarnation||!V(be(e,S).birth,b.notification.incarnation)||(M(z=>Or(z,b.notification,t,r)),!m()||_!==o||X(e))}),{facts:()=>Object.freeze({documentId:t,live:m(),epoch:o,revision:N,observation:w,subject:X(e)}),transport:()=>r,subject:()=>X(e),subjectFacts:x=>be(e,x),subjectCurrent:(x,b)=>Ge(e,x,b),binding:x=>Rr(e,x),qualified:()=>u===void 0,projection:()=>({documentId:t,transport:r,dispatch:n,epoch:o,run:s,subject:X(e)}),projectionCurrent:(x,b,S)=>m()&&x===o&&b===X(e)&&(!S||s===S),abortAdmission:(x,b)=>{_r(e,x,b)&&T(!0)},reserve:x=>{const b=nr(e,x);if(!b||b.ended||!m()||b.epoch!==o||b.subject!==X(e))throw new Error("Replay run is foreign or stale.");s=x},current:I,admit:q,frame:$,qualify:U,failed:x=>{if(!I(x))return;const b=X(e);b&&vt(e,b),M(S=>({...S,available:!1}),x)},unavailable:x=>{I(x)&&M(b=>({...b,available:!1}),x)},start:me,dispose:()=>{if(!m())return;const x=Pe(e);c.live=!1,s=void 0;const b=a;a=void 0,y(),o++,rr(e);try{Be(e,x)}finally{b==null||b()}}}}function Je(e,t){const r=Et.get(t),n=ce(e);if(!(!r||r.owner!==e||!n.live||n.epoch!==r.epoch||n.revision!==r.revision||n.observation!==r.observation))return r}function gi(e,t){var c;const r=Je(e,t);if(!r||r.notification.type==="canvas_channel_snapshot")return;const n=r.notification,i=ce(e).subject,a=i&&be(e,i);!a||!n.incarnation||!V(a.birth,n.incarnation)||n.docSeq<=At(e).highest||(Ns(e,t),!(!Je(e,t)||ce(e).subject!==i)&&((c=Ar.get(e))==null||c(t)))}const Ar=new WeakMap;function vi(e,t,r){const n=ii(e,t,r);Es(n);const s=Gs(n);return Object.freeze({beginRun:()=>zs(n),frameAdmission:s,start:i=>di(n,i),dispose:()=>fi(n)})}function bi(e,t){let r,n=0;const s=h=>{try{t==null||t(h)}catch{}},i=h=>{r===h&&(r=void 0)},a=(h,u)=>{h.settled||(h.settled=!0,r||s(!1),u?h.reject(u.cause):h.resolve())},c=()=>{l().catch(()=>{})},o=(h,u)=>{const g=()=>n===h.revision;if(!g())return;const w=u.beginFinalization();if(g()){if(w==="restart"){c();return}if(w==="drain")for(;g();){const m=u.drainOne();if(!g())return;if(m!=="again"){if(m==="restart")c();else if(m==="tail"){const y=u.finishFinalization();g()&&y==="restart"&&c()}return}}}},f=async h=>{let u,g;try{u=e();try{for(;await u.page()==="again";);}catch(w){u.failed(w)}}catch(w){g={cause:w}}finally{i(h);try{u&&o(h,u)}catch(w){g={cause:w}}finally{a(h,g)}}},l=()=>{if(r)return r.promise;let h,u;const g=new Promise((m,y)=>{h=m,u=y}),w={revision:++n,promise:g,resolve:h,reject:u,settled:!1};return r=w,s(!0),f(w),g};return Object.freeze({request:l})}function wi(e,t,r,n){const s=vi(e,t,r);let i=!1;const a=bi(()=>{const c=s.beginRun();return{async page(){const o=await c.readPage();if(!o)return"done";const f=c.consumePage(o);if(f.kind!=="frames")return f.kind;for(let l=0;l<f.count;l++)if(!c.advancePageFrame(o,l))return"done";return c.finishPage(o)},failed:()=>c.failed(),beginFinalization:()=>{const o=c.beginFinalization();return o!=="drain"&&c.end(),o},drainOne(){if(!c.current())return c.end(),"stop";const o=c.takePending();return o?c.advancePending(o)?"again":(c.end(),"stop"):"tail"},finishFinalization:()=>{try{return c.finishFinalization()}finally{c.end()}}}},c=>{i||n==null||n(c)});return s.start(()=>{a.request().catch(()=>{})}),Object.freeze({dispose(){i=!0,s.dispose()}})}function yi(e){var f,l,h;const t=ue(),[r,n]=p.useState(()=>he(e,t)),[s,i]=p.useState({documentId:e,transport:t,pending:!0});p.useLayoutEffect(()=>{const u=wi(e,t,n,g=>{i({documentId:e,transport:t,pending:g})});return()=>u.dispose()},[e,t]);const a=r.documentId===e&&r.transport===t?r:he(e,t),c=p.useMemo(()=>Vs(a),[a]),o=p.useMemo(()=>{var w;const u=(w=a.snapshot)==null?void 0:w.incarnation,g=a.binding;return u&&g?Object.freeze({incarnation:Object.freeze({...u}),current:()=>g.current("read")}):void 0},[(f=a.snapshot)==null?void 0:f.incarnation,a.binding]);return{channel:c,events:a.events,frameAdmission:a.frameAdmission,fileSaveBinding:o,fileSaveObservation:s.documentId!==e||s.transport!==t||s.pending?"pending":a.available&&((l=a.binding)!=null&&l.verified)&&((h=a.snapshot)!=null&&h.incarnation)?"ready":"unavailable"}}function xi({content:e}){const[t]=St();return t?d.jsx("div",{className:"h-full w-full",children:d.jsx(pn,{sessionId:t,serverName:e.serverName,uri:e.uri,title:e.title})}):null}const ki=p.lazy(()=>Ce(()=>import("./CanvasFileContent-g5wQR7yt.js"),__vite__mapDeps([5,1,2,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21])).then(e=>({default:e.CanvasFileContent}))),ji=p.lazy(()=>Ce(()=>import("./CanvasModel3dContent-BlYcTOLd.js"),__vite__mapDeps([22,1,2,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21])).then(e=>({default:e.CanvasModel3dContent}))),Ci=p.lazy(()=>Ce(()=>import("./CanvasCsvContent-DtZuAo03.js"),__vite__mapDeps([23,1,2,24,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21])).then(e=>({default:e.CanvasCsvContent}))),Ri=p.lazy(()=>Ce(()=>import("./index-BULRe04c.js").then(e=>e.uc),__vite__mapDeps([1,2])).then(e=>({default:e.CanvasDiffContent})));function Ui({documentId:e,widgetChannel:t,content:r,onContentChange:n}){switch(r.type){case"url":case"browser":return d.jsx(Zn,{documentId:e,content:r},`${e}:${r.url}`);case"markdown":return d.jsx(fs,{documentId:e,content:r,onContentChange:n},r.sourcePath??"generated");case"json":return d.jsx(hs,{content:r});case"image":return d.jsx(bs,{content:r});case"pdf":return d.jsx(ys,{content:r});case"audio":return d.jsx(js,{content:r});case"video":return d.jsx(Cs,{content:r});case"widget":return t?d.jsx(kr,{content:r,documentId:e,channel:t}):d.jsx(Oi,{documentId:e,content:r});case"mcp_app":return d.jsx(xi,{content:r});case"file":return d.jsx(p.Suspense,{fallback:d.jsx(Ke,{}),children:d.jsx(ki,{documentId:e,content:r})});case"model3d":return d.jsx(p.Suspense,{fallback:d.jsx(Ke,{}),children:d.jsx(ji,{content:r})});case"csv":return d.jsx(p.Suspense,{fallback:d.jsx(Ke,{}),children:d.jsx(Ci,{content:r})});case"diff":return d.jsx(p.Suspense,{fallback:d.jsx(Ke,{}),children:d.jsx(Ri,{documentId:e,content:r},r.sourcePath)})}}function Ke(){return d.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading…"})}function Oi({documentId:e,content:t}){const{channel:r}=yi(e);return d.jsx(kr,{documentId:e,content:t,channel:r})}const Ei=p.lazy(()=>Ce(()=>import("./BlintzCanvas-D_HlpfZu.js"),__vite__mapDeps([0,1,2,3,4])).then(e=>({default:e.BlintzCanvas})));function Wi({roomId:e,document:t,content:r,onSave:n}){const[s,i]=p.useState(null),[a,c]=p.useState(!1),[o,f]=p.useState(null),l=s!==null,h=r.sourcePath===void 0;Mn(e,l?t.id:null);const u=async()=>{if(s===null)return;if(s===r.content){i(null),f(null);return}c(!0),f(null);const g=await n(t.id,{...r,content:s});c(!1),g?i(null):f("Couldn’t save. Your words are still here. Try again.")};return d.jsxs("div",{className:"flex h-full flex-col",children:[h&&d.jsxs("div",{className:"flex items-center justify-end gap-2 border-b px-2 py-1",children:[l&&d.jsx("span",{className:"text-muted-foreground text-xs",children:a?"Saving…":"Everyone sees your save."}),d.jsx(et,{type:"button",size:"xs",variant:"ghost",disabled:a,"aria-label":l?"Save for the room":"Edit this document",onClick:()=>l?void u():i(r.content),children:l?d.jsx(lr,{className:"size-3.5"}):d.jsx(dr,{className:"size-3.5"})})]}),o!==null&&d.jsx("p",{role:"status",className:"text-destructive border-b px-2 py-1 text-xs",children:o}),d.jsx("div",{className:"flex-1 px-2 pb-6",children:d.jsx(p.Suspense,{fallback:d.jsx("div",{className:"text-muted-foreground p-4 text-sm",children:"Loading…"}),children:d.jsx(Ei,{value:s??r.content,editable:l,onChange:i},l?"editing":`rev-${t.rev}`)})})]})}const _t="dorkos-canvas-sessions",_i=1440*60*60*1e3;function Nr(){try{const e=localStorage.getItem(_t);if(!e)return null;const t=JSON.parse(e);return t===null||typeof t!="object"?null:t}catch{return null}}function zr(e){try{Object.keys(e).length===0?localStorage.removeItem(_t):localStorage.setItem(_t,JSON.stringify(e))}catch{}}function Si(e){return Array.isArray(e.documents)?[...e.documents].sort((t,r)=>(t.openedAt??0)-(r.openedAt??0)).map(t=>t.content).filter(t=>!!t):e.content?[e.content]:[]}function ot(e){return e===null||typeof e!="object"?JSON.stringify(e)??"null":Array.isArray(e)?`[${e.map(ot).join(",")}]`:`{${Object.entries(e).filter(([,r])=>r!==void 0).sort(([r],[n])=>r<n?-1:r>n?1:0).map(([r,n])=>`${JSON.stringify(r)}:${ot(n)}`).join(",")}}`}function Di(e,t){const r=new Set,n=new Map;for(const i of e){const a=Jt(i.content);if(a!==null){r.add(a);continue}const c=ot(i.content);n.set(c,(n.get(c)??0)+1)}const s=[];for(const i of t){const a=Jt(i);if(a!==null){r.has(a)||s.push(i);continue}const c=ot(i),o=n.get(c)??0;o>0?n.set(c,o-1):s.push(i)}return s}const tt=new Set;function Gi(){tt.clear()}function $i(e,t={}){const r=ue(),n=t.canonical??!0;p.useEffect(()=>{e&&J.getState().loadCanvasForSession(e)},[e]),p.useEffect(()=>{if(!e||!n||tt.has(e))return;const s=Nr();if(!s)return;const i=s[e];if(!i){Ii(s);return}tt.add(e),(async()=>{try{const a=Si(i),c=Di(await r.listSessionCanvas(e),a);if(c.length===0){ar(e);return}for(const o of c)await r.openSessionCanvasDocument(e,o);ar(e),J.getState().hydrateCanvasFromSnapshot(e,await r.listSessionCanvas(e))}catch{tt.delete(e)}})()},[e,n,r])}function ar(e){const t=Nr();if(!t)return;const{[e]:r,...n}=t;zr(n)}function Ii(e){const t=Date.now()-_i,r=Object.entries(e).filter(([,n])=>n.accessedAt===void 0||n.accessedAt>=t);r.length!==Object.keys(e).length&&zr(Object.fromEntries(r))}export{Ui as C,Pi as F,Wi as R,yi as a,zn as b,Nn as c,Bi as d,kr as e,Gi as f,In as g,$i as h,xr as r,cs as u};
@@ -1 +0,0 @@
1
- import{a1 as n,a3 as s,a4 as u,at as o,au as r}from"./index-BULRe04c.js";function c(){const t=n(),e=s();return u({mutationKey:o,mutationFn:a=>t.updateConfig(a),onSuccess:()=>{e.invalidateQueries({queryKey:r.current()})}})}export{c as u};