@jxsuite/studio 10.4.0 → 10.5.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 (274) hide show
  1. package/dist/chunks/2020-7sx2vexa.js +4 -0
  2. package/dist/chunks/adapter-12dxr3z7.js +4 -0
  3. package/dist/chunks/{add-new-flow-v0pm96mr.js → add-new-flow-any4pw2q.js} +3 -3
  4. package/dist/chunks/{cf-account-picker-xb8vvt2h.js → cf-account-picker-ajh60k54.js} +3 -3
  5. package/dist/chunks/cf-settings-hbj16kh3.js +4 -0
  6. package/dist/chunks/{color-area-h8dbasp1.js → color-area-gbcftzh3.js} +2 -2
  7. package/dist/chunks/{color-field-qv5r2b16.js → color-field-85136598.js} +3 -3
  8. package/dist/chunks/{color-slider-nz2mrzky.js → color-slider-w1s3ndd8.js} +2 -2
  9. package/dist/chunks/color-thzpppyc.js +4 -0
  10. package/dist/chunks/{combobox-6hs00996.js → combobox-dk98wc5x.js} +3 -3
  11. package/dist/chunks/components-a98hzqw9.js +4 -0
  12. package/dist/chunks/content-source-jq3fjs3w.js +4 -0
  13. package/dist/chunks/{convert-to-repeater-r8sfxjjm.js → convert-to-repeater-g66r6qp1.js} +3 -3
  14. package/dist/chunks/editor-rth1rzj8.js +4 -0
  15. package/dist/chunks/entry-commands-02j0s19w.js +4 -0
  16. package/dist/chunks/{extension-sections-vjzw46xb.js → extension-sections-rqrs7dr0.js} +3 -3
  17. package/dist/chunks/file-ops-6a49er4c.js +4 -0
  18. package/dist/chunks/files-b2p9y0yz.js +4 -0
  19. package/dist/chunks/format-host-7xe57k1s.js +4 -0
  20. package/dist/chunks/fs-events-0xsy168g.js +4 -0
  21. package/dist/chunks/grid-open-h3q4fjy5.js +4 -0
  22. package/dist/chunks/{grid-view-2f03wcgw.js → grid-view-0v4hjspb.js} +17 -17
  23. package/dist/chunks/{icons-gb967qc8.js → icons-j9eksgew.js} +2 -2
  24. package/dist/chunks/{iframe-entry-btck0e9s.js → iframe-entry-4zqtn3ry.js} +4 -4
  25. package/dist/chunks/{iframe-entry-b5qgggyp.js → iframe-entry-54kwwhmg.js} +4 -4
  26. package/dist/chunks/{iframe-entry-42hpmwz5.js → iframe-entry-m24fza30.js} +4 -4
  27. package/dist/chunks/iframe-host-8jcmaktg.js +4 -0
  28. package/dist/chunks/{image-bake-4afr4y6a.js → image-bake-m8gzaan9.js} +3 -3
  29. package/dist/chunks/{image-editor-x7t8jbjn.js → image-editor-0afyws7c.js} +3 -3
  30. package/dist/chunks/{index-yjrfeks8.js → index-2q88g57p.js} +3 -3
  31. package/dist/chunks/index-7nj2375a.js +4 -0
  32. package/dist/chunks/{javascript-hy2mws8v.js → javascript-5sxtr1g7.js} +3 -3
  33. package/dist/chunks/jsonMode-m6sf47hq.js +13 -0
  34. package/dist/chunks/jx-validate-808zgbgy.js +4 -0
  35. package/dist/chunks/layers-0ffdtqjn.js +4 -0
  36. package/dist/chunks/layers-panel-rw62wtvf.js +4 -0
  37. package/dist/chunks/{listbox-7gka1h86.js → listbox-k5p41049.js} +2 -2
  38. package/dist/chunks/lit-html-9bz9rcfv.js +4 -0
  39. package/dist/chunks/media-library-2a5hdbek.js +4 -0
  40. package/dist/chunks/media-open-069kzhj4.js +4 -0
  41. package/dist/chunks/media-picker-4p4pd28y.js +4 -0
  42. package/dist/chunks/menu-26nez152.js +4 -0
  43. package/dist/chunks/{monaco-binding-a51py33c.js → monaco-binding-1s2b8snq.js} +3 -3
  44. package/dist/chunks/monaco-buffer-m9fd2dka.js +4 -0
  45. package/dist/chunks/monaco-setup-e0crh3v6.js +4 -0
  46. package/dist/chunks/notify-re3js157.js +4 -0
  47. package/dist/chunks/platform-rywy3tkg.js +4 -0
  48. package/dist/chunks/popover-fhdnt4be.js +4 -0
  49. package/dist/chunks/publish-panel-czkpg8m4.js +4 -0
  50. package/dist/chunks/{publish-quick-4fwngwrw.js → publish-quick-b9wbhqj6.js} +3 -3
  51. package/dist/chunks/publish-workspace-yy6d23b7.js +4 -0
  52. package/dist/chunks/quick-search-tp7pjnmv.js +4 -0
  53. package/dist/chunks/references-wd2yj8s1.js +4 -0
  54. package/dist/chunks/right-panel-x971k0zc.js +4 -0
  55. package/dist/chunks/source-control-k4p00hpe.js +4 -0
  56. package/dist/chunks/{split-m5rwn31z.js → split-qh21j2b0.js} +2 -2
  57. package/dist/chunks/{studio-v5wktj6f.js → studio-151kgn69.js} +4 -4
  58. package/dist/chunks/studio-15mfah02.js +10 -0
  59. package/dist/chunks/studio-1a7zshnv.js +5 -0
  60. package/dist/chunks/studio-1d8m5s38.js +16 -0
  61. package/dist/chunks/studio-35pmfjtx.js +5 -0
  62. package/dist/chunks/{studio-3na1r48j.js → studio-3yr1zdp9.js} +8 -8
  63. package/dist/chunks/studio-43pynnhz.js +5 -0
  64. package/dist/chunks/studio-44xqe0b7.js +4 -0
  65. package/dist/chunks/{studio-hh394phe.js → studio-48yzqzqr.js} +4 -4
  66. package/dist/chunks/{studio-9gr7xs9r.js → studio-4jy967rj.js} +5 -5
  67. package/dist/chunks/{studio-4bgvvzhv.js → studio-4ncxzw5m.js} +4 -4
  68. package/dist/chunks/{studio-pm17wdc4.js → studio-4s5bka8t.js} +4 -4
  69. package/dist/chunks/{studio-5tet77de.js → studio-4z0cdh16.js} +3 -3
  70. package/dist/chunks/studio-5rq3e4q5.js +5 -0
  71. package/dist/chunks/{studio-wmjmsw0p.js → studio-69g6a0jn.js} +4 -4
  72. package/dist/chunks/studio-6hcfm9q3.js +5 -0
  73. package/dist/chunks/studio-6mf31e16.js +5 -0
  74. package/dist/chunks/studio-6sxnqqw8.js +5 -0
  75. package/dist/chunks/{studio-0939t1q1.js → studio-7qqb7hb8.js} +4 -4
  76. package/dist/chunks/{studio-bg8pzprg.js → studio-7qr8k0v2.js} +4 -4
  77. package/dist/chunks/{studio-0x6f3nk9.js → studio-8ncm9zwx.js} +4 -4
  78. package/dist/chunks/studio-8w5pa88p.js +7 -0
  79. package/dist/chunks/{studio-3qr08sxq.js → studio-9f5vcb4w.js} +3 -3
  80. package/dist/chunks/studio-aaw7wxv8.js +5 -0
  81. package/dist/chunks/studio-afx9brsc.js +5 -0
  82. package/dist/chunks/studio-ajfq4fmr.js +5 -0
  83. package/dist/chunks/{studio-evq47j2z.js → studio-ber1dgte.js} +4 -4
  84. package/dist/chunks/{studio-sce30r7b.js → studio-bk0anq3b.js} +3 -3
  85. package/dist/chunks/{studio-0gvvqj3h.js → studio-bmwgj8ez.js} +4 -4
  86. package/dist/chunks/{studio-s24mhq0z.js → studio-bpzwhn88.js} +4 -4
  87. package/dist/chunks/{studio-g9brbewz.js → studio-c72v1kwc.js} +4 -4
  88. package/dist/chunks/{studio-tpxcryf2.js → studio-cv6gnjqd.js} +4 -4
  89. package/dist/chunks/{studio-90zkgne5.js → studio-czpmzs9r.js} +7 -7
  90. package/dist/chunks/{studio-2pk7kc7z.js → studio-d5f7sskn.js} +4 -4
  91. package/dist/chunks/studio-dmgh2rrj.js +5 -0
  92. package/dist/chunks/{studio-nwf0c32p.js → studio-dst8y8vh.js} +4 -4
  93. package/dist/chunks/studio-ehj3csbm.js +6 -0
  94. package/dist/chunks/{studio-hfqpfmpk.js → studio-ek4fb4eb.js} +4 -4
  95. package/dist/chunks/studio-ep1384t9.js +5 -0
  96. package/dist/chunks/{studio-abh9kfdh.js → studio-eq5vqn1q.js} +4 -4
  97. package/dist/chunks/studio-erjccagy.js +5 -0
  98. package/dist/chunks/studio-ex1644g2.js +5 -0
  99. package/dist/chunks/studio-f3awr5nc.js +12 -0
  100. package/dist/chunks/studio-f69wcajk.js +9 -0
  101. package/dist/chunks/{studio-jma2q8r9.js → studio-g65t6svn.js} +4 -4
  102. package/dist/chunks/{studio-r6mx7vm5.js → studio-gw83z798.js} +5 -5
  103. package/dist/chunks/{studio-2x972v58.js → studio-hy936516.js} +4 -4
  104. package/dist/chunks/studio-j3bq30yz.js +5 -0
  105. package/dist/chunks/studio-j52ks8q7.js +5 -0
  106. package/dist/chunks/{studio-g0hxtcga.js → studio-jqvke4ac.js} +4 -4
  107. package/dist/chunks/{studio-bnc50f9h.js → studio-k05g7efh.js} +4 -4
  108. package/dist/chunks/studio-kefs4sz4.js +5 -0
  109. package/dist/chunks/{studio-2e4hry72.js → studio-ketrgtph.js} +5 -5
  110. package/dist/chunks/studio-m3jrjfhy.js +14 -0
  111. package/dist/chunks/{studio-45mj4jqe.js → studio-m8hesdrw.js} +4 -4
  112. package/dist/chunks/{studio-k0xzrse2.js → studio-n271vdsg.js} +36 -36
  113. package/dist/chunks/studio-n4pnf0sw.js +5 -0
  114. package/dist/chunks/{studio-gnazwtv3.js → studio-ncwx602y.js} +4 -4
  115. package/dist/chunks/{studio-amaz545p.js → studio-nngc45ct.js} +4 -4
  116. package/dist/chunks/{studio-eqcddvc2.js → studio-nv5eq0f7.js} +173 -173
  117. package/dist/chunks/{studio-az3wvyh2.js → studio-nzp0sqjg.js} +4 -4
  118. package/dist/chunks/{studio-k2evngrj.js → studio-pgze9p34.js} +5 -5
  119. package/dist/chunks/studio-ph17an19.js +5 -0
  120. package/dist/chunks/studio-pte5w7rf.js +9 -0
  121. package/dist/chunks/studio-pv1ts08p.js +6 -0
  122. package/dist/chunks/studio-q509sqt8.js +5 -0
  123. package/dist/chunks/{studio-rr00ex23.js → studio-qarg1xf9.js} +6 -6
  124. package/dist/chunks/studio-r5g7fx7q.js +9 -0
  125. package/dist/chunks/studio-s49y6m5b.js +5 -0
  126. package/dist/chunks/studio-s4k1v7dt.js +7 -0
  127. package/dist/chunks/studio-t46rt6gx.js +5 -0
  128. package/dist/chunks/{studio-61rg2cz5.js → studio-td3h1644.js} +4 -4
  129. package/dist/chunks/{studio-v7a7yb5w.js → studio-thgexj3w.js} +7 -7
  130. package/dist/chunks/{studio-vpevkfxw.js → studio-veh91hjv.js} +4 -4
  131. package/dist/chunks/studio-vswmz40d.js +6 -0
  132. package/dist/chunks/{studio-daksw8kh.js → studio-w3aafbpk.js} +4 -4
  133. package/dist/chunks/studio-w4mfaaam.js +5 -0
  134. package/dist/chunks/{studio-4zd6an2b.js → studio-wn2cmf9q.js} +4 -4
  135. package/dist/chunks/studio-x5ffyssw.js +5 -0
  136. package/dist/chunks/{studio-swedpd82.js → studio-x5py815g.js} +4 -4
  137. package/dist/chunks/{studio-4fnb5648.js → studio-xh6rf05g.js} +4 -4
  138. package/dist/chunks/studio-z6s56dzz.js +5 -0
  139. package/dist/chunks/{studio-nvcn2ykc.js → studio-zav9hgb3.js} +4 -4
  140. package/dist/chunks/{studio-a88ej93p.js → studio-ze1sm147.js} +6 -6
  141. package/dist/chunks/{studio-pj216fmn.js → studio-zkkt13qd.js} +4 -4
  142. package/dist/chunks/studio-zn7ysyzb.js +5 -0
  143. package/dist/chunks/{studio-xx3r3sb0.js → studio-ztzf8mce.js} +4 -4
  144. package/dist/chunks/{studio-1410q5dw.js → studio-zzgp5yka.js} +4 -4
  145. package/dist/chunks/{tooltip-dj1pvgz7.js → tooltip-gtx40bjg.js} +3 -3
  146. package/dist/chunks/{tree-j0ebwr5s.js → tree-a19s1c05.js} +2 -2
  147. package/dist/chunks/tsMode-3f116hth.js +14 -0
  148. package/dist/chunks/workspace-home-61n1jz3q.js +4 -0
  149. package/dist/chunks/workspace-sheek6zw.js +4 -0
  150. package/dist/chunks/{ws-client-arz2qsy9.js → ws-client-cb49m87s.js} +3 -3
  151. package/dist/iframe-entry.js +14 -14
  152. package/dist/manifest.json +82 -82
  153. package/dist/studio.js +97 -96
  154. package/dist/workers/ts.worker.js +3 -3
  155. package/package.json +11 -11
  156. package/src/browse/library-layouts.ts +9 -12
  157. package/src/browse/library-pane.ts +22 -16
  158. package/src/browse/library-source.ts +3 -4
  159. package/src/canvas/canvas-live-render.ts +2 -5
  160. package/src/canvas/canvas-page-context.ts +5 -0
  161. package/src/content/entry-commands.ts +32 -27
  162. package/src/content/entry-editor.ts +46 -44
  163. package/src/content/entry-inspector.ts +15 -12
  164. package/src/content/entry-model.ts +3 -3
  165. package/src/content/entry-summaries.ts +5 -5
  166. package/src/content/hold-state.ts +172 -0
  167. package/src/content/page-summaries.ts +10 -14
  168. package/src/editor/inline-edit.ts +6 -1
  169. package/src/editor/repeater-scope.ts +333 -74
  170. package/src/grid/sources/content-source.ts +42 -66
  171. package/src/panels/block-action-bar.ts +3 -4
  172. package/src/panels/events-panel.ts +6 -2
  173. package/src/panels/formula-workspace.ts +9 -0
  174. package/src/panels/properties-panel.ts +127 -35
  175. package/src/panels/statement-editor.ts +4 -0
  176. package/src/panels/tab-strip.ts +29 -26
  177. package/src/services/ai-project-tools.ts +3 -3
  178. package/src/services/ai-tools.ts +5 -5
  179. package/src/services/ai-write-report.ts +22 -4
  180. package/src/services/context-manager.ts +110 -2
  181. package/src/services/document-assistant.ts +2 -2
  182. package/src/services/harness/chat-reducer.ts +9 -4
  183. package/src/services/render-critic.ts +234 -12
  184. package/src/services/tool-executor.ts +16 -8
  185. package/src/surfaces/collections-panel.json +1 -1
  186. package/src/surfaces/collections-panel.ts +1 -1
  187. package/src/surfaces/entry-editor.json +10 -10
  188. package/src/surfaces/entry-editor.ts +22 -19
  189. package/src/surfaces/entry-inspector.json +11 -11
  190. package/src/surfaces/entry-inspector.ts +17 -10
  191. package/src/surfaces/tab-strip.json +5 -5
  192. package/src/surfaces/tab-strip.ts +2 -2
  193. package/src/types.ts +2 -0
  194. package/src/ui/expression-editor.ts +10 -5
  195. package/src/ui/schema-form.ts +18 -1
  196. package/src/utils/edit-display.ts +27 -1
  197. package/dist/chunks/2020-906vx2dq.js +0 -4
  198. package/dist/chunks/adapter-hnvad61x.js +0 -4
  199. package/dist/chunks/cf-settings-mkbcz4z2.js +0 -4
  200. package/dist/chunks/color-04361ttk.js +0 -4
  201. package/dist/chunks/components-w5zqwva1.js +0 -4
  202. package/dist/chunks/content-source-g38w0d3f.js +0 -4
  203. package/dist/chunks/editor-wvf5e6j9.js +0 -4
  204. package/dist/chunks/entry-commands-t13dyw3c.js +0 -4
  205. package/dist/chunks/file-ops-1sghzgcr.js +0 -4
  206. package/dist/chunks/files-zrqtgt41.js +0 -4
  207. package/dist/chunks/format-host-9gy76erh.js +0 -4
  208. package/dist/chunks/fs-events-45rhg3me.js +0 -4
  209. package/dist/chunks/grid-open-t4fq6bbm.js +0 -4
  210. package/dist/chunks/iframe-host-9aq8ze3q.js +0 -4
  211. package/dist/chunks/index-f9qr7kzh.js +0 -4
  212. package/dist/chunks/jsonMode-vj30te2h.js +0 -13
  213. package/dist/chunks/jx-validate-r4ax11e3.js +0 -4
  214. package/dist/chunks/layers-m49nmwvx.js +0 -4
  215. package/dist/chunks/layers-panel-zr92pwdp.js +0 -4
  216. package/dist/chunks/lit-html-k2mb9k0r.js +0 -4
  217. package/dist/chunks/media-library-j74rt0w4.js +0 -4
  218. package/dist/chunks/media-open-mypr0k6b.js +0 -4
  219. package/dist/chunks/media-picker-pemtbsjv.js +0 -4
  220. package/dist/chunks/menu-d2jxpgma.js +0 -4
  221. package/dist/chunks/monaco-buffer-pa0g6ax7.js +0 -4
  222. package/dist/chunks/monaco-setup-0hw9f835.js +0 -4
  223. package/dist/chunks/notify-bwehrp7q.js +0 -4
  224. package/dist/chunks/platform-kv0k65cy.js +0 -4
  225. package/dist/chunks/popover-9tf4cjrk.js +0 -4
  226. package/dist/chunks/publish-panel-vg1n880b.js +0 -4
  227. package/dist/chunks/publish-workspace-jv4w2bx2.js +0 -4
  228. package/dist/chunks/quick-search-nh29rt8a.js +0 -4
  229. package/dist/chunks/references-vqyr5s9x.js +0 -4
  230. package/dist/chunks/right-panel-3ws9f2w0.js +0 -4
  231. package/dist/chunks/source-control-h3hcs5gy.js +0 -4
  232. package/dist/chunks/studio-0khd8xtx.js +0 -4
  233. package/dist/chunks/studio-1ctnw3xv.js +0 -5
  234. package/dist/chunks/studio-1ks5d9y4.js +0 -5
  235. package/dist/chunks/studio-1y9mab9m.js +0 -5
  236. package/dist/chunks/studio-2kpxm0eh.js +0 -7
  237. package/dist/chunks/studio-2zz4qbv9.js +0 -5
  238. package/dist/chunks/studio-3pz4t5a2.js +0 -5
  239. package/dist/chunks/studio-4f7thq0p.js +0 -5
  240. package/dist/chunks/studio-7rrdbvex.js +0 -5
  241. package/dist/chunks/studio-9dq7rwc7.js +0 -5
  242. package/dist/chunks/studio-acer0g8w.js +0 -5
  243. package/dist/chunks/studio-brh8d2pr.js +0 -5
  244. package/dist/chunks/studio-c2fa783p.js +0 -9
  245. package/dist/chunks/studio-cfnn70h1.js +0 -5
  246. package/dist/chunks/studio-cqxj4fcy.js +0 -5
  247. package/dist/chunks/studio-cw11h078.js +0 -5
  248. package/dist/chunks/studio-dn56z7sn.js +0 -5
  249. package/dist/chunks/studio-egnjpyde.js +0 -9
  250. package/dist/chunks/studio-ejrypvmq.js +0 -5
  251. package/dist/chunks/studio-frc16j8v.js +0 -10
  252. package/dist/chunks/studio-j0zf5x2x.js +0 -5
  253. package/dist/chunks/studio-j5fcp6gj.js +0 -5
  254. package/dist/chunks/studio-jd1qb1st.js +0 -7
  255. package/dist/chunks/studio-k1xqrgm5.js +0 -5
  256. package/dist/chunks/studio-k3we3kqb.js +0 -5
  257. package/dist/chunks/studio-knsjyx7n.js +0 -5
  258. package/dist/chunks/studio-mrjtnm62.js +0 -5
  259. package/dist/chunks/studio-n9qba0gx.js +0 -5
  260. package/dist/chunks/studio-nzemfbkk.js +0 -14
  261. package/dist/chunks/studio-pwctzka3.js +0 -16
  262. package/dist/chunks/studio-q80fg1d6.js +0 -12
  263. package/dist/chunks/studio-q9hx2qp0.js +0 -5
  264. package/dist/chunks/studio-qrzmfaf6.js +0 -5
  265. package/dist/chunks/studio-tmfcn347.js +0 -6
  266. package/dist/chunks/studio-wqfaqw4m.js +0 -5
  267. package/dist/chunks/studio-xpx91fby.js +0 -6
  268. package/dist/chunks/studio-xva3hzkv.js +0 -5
  269. package/dist/chunks/studio-z3fztxrp.js +0 -9
  270. package/dist/chunks/studio-z9453ypn.js +0 -6
  271. package/dist/chunks/tsMode-jg1dtphj.js +0 -14
  272. package/dist/chunks/workspace-6ztqcrsh.js +0 -4
  273. package/dist/chunks/workspace-home-rse9h8a0.js +0 -4
  274. package/src/content/draft-state.ts +0 -108
@@ -0,0 +1,16 @@
1
+ import{ot,Er,_o}from"./studio-c72v1kwc.js";import{p}from"./studio-xh6rf05g.js";import{XP,w}from"./studio-bk0anq3b.js";import{jn,Ux,ln,gr,s1,Up,Kx,bR,an,Cy,Zm,Hi,qn,Se,pi,Tr,Z,fi,tg,g,Co,ac,Ft}from"./studio-s49y6m5b.js";import{af}from"./studio-ex1644g2.js";import{X}from"./studio-9c6cbq2c.js";import{x,id,_n}from"./studio-zn7ysyzb.js";import{me,te,$o,Lo,b,le}from"./studio-9f5vcb4w.js";import{n,J,qe,Xy,Q,S,m}from"./studio-erjccagy.js";import{ce}from"./studio-7qqb7hb8.js";var Ve={default:{description:"Resume whatever was persisted — layout, recents, settings, chat history.",id:"default",reset:"none"},fresh:{description:"A first-run app: no layout, no recents, no settings, no history.",id:"fresh",reset:"app-state"}},be=new Map(Object.entries(Ve)),He="default",Ge=/^jx[-._:]/;function Ke(e){return Ge.test(e)}function Ze(){let e=typeof localStorage>"u"?void 0:localStorage;if(!e)return[];let t=[];try{for(let o=0;o<e.length;o++){let r=e.key(o);if(r&&Ke(r))t.push(r)}for(let o of t)e.removeItem(o)}catch{}return t}function Ye(e){let t=be.get(e);if(!t)throw RangeError(`unknown startup profile "${e}"; declared: ${[...be.keys()].join(", ")}`);if(t.reset==="app-state")Ze();return t}var W=null;function he(e){if(W)return W;let t=new URLSearchParams(e??(typeof location>"u"?"":location.search)),o=Ye(t.get("profile")??He),r=t.get("clock");return W={clock:r===null?null:XP(r),profile:o},W}var ye=new Set([fi,tg]),Xe=new Set(["auto","light","dark"]);function Qe(e){return n(e)&&Xe.has(e)}function et(e){let{ui:t}=e.session;return{activeMedia:t.activeMedia,canvasMode:t.canvasMode,editZoom:t.editZoom,preview:t.preview,previewColorScheme:t.previewColorScheme,previewLocale:t.previewLocale,showLayout:t.showLayout,zoom:t.zoom}}function we(){let e={},t=[];for(let o of g.panes){if(o.derived)continue;let r=[];for(let i of o.tabOrder){let a=g.tabs.get(i);if(!a?.documentPath)continue;r.push(a.documentPath),e[a.documentPath]=et(a)}if(r.length===0)continue;let s=o.activeTabId?g.tabs.get(o.activeTabId):null;t.push({activeFile:s?.documentPath??null,files:r,id:o.id})}return{focusedPane:g.activePaneId,panes:t,ui:e}}function tt(e){if(!m(e))return{};let t={};if(n(e.canvasMode))t.canvasMode=e.canvasMode;if(qe(e.preview))t.preview=e.preview;if(J(e.zoom)&&Number.isFinite(e.zoom))t.zoom=e.zoom;if(J(e.editZoom)&&Number.isFinite(e.editZoom))t.editZoom=e.editZoom;if(e.activeMedia===null||n(e.activeMedia))t.activeMedia=e.activeMedia;if(Qe(e.previewColorScheme))t.previewColorScheme=e.previewColorScheme;if(e.previewLocale===null||n(e.previewLocale)&&Ux(e.previewLocale))t.previewLocale=e.previewLocale;if(qe(e.showLayout))t.showLayout=e.showLayout;return t}function ve(e){if(!m(e)||!Array.isArray(e.panes))return null;let t=[];for(let r of e.panes){if(!m(r)||!n(r.id)||!ye.has(r.id))continue;let s=Array.isArray(r.files)?r.files.filter((i)=>n(i)&&i!==""):[];if(s.length===0)continue;t.push({activeFile:n(r.activeFile)&&s.includes(r.activeFile)?r.activeFile:null,files:s,id:r.id})}if(t.length===0)return null;let o={};if(S(e.ui))for(let[r,s]of Object.entries(e.ui))o[r]=tt(s);return{focusedPane:n(e.focusedPane)&&ye.has(e.focusedPane)?e.focusedPane:fi,panes:t,ui:o}}async function kA(e,t){let o=0;if(e.panes.some((i)=>i.id===tg))t.ensureSecondPane();for(let i of e.panes)for(let a of i.files){try{await t.openFile(a,i.id)}catch{}if([...g.tabs.values()].some((l)=>l.documentPath===a))o+=1}if(o===0)return 0;for(let i of g.tabs.values()){let a=i.documentPath?e.ui[i.documentPath]:void 0;if(!a)continue;let{ui:l}=i.session;if(a.canvasMode&&i.capabilities.modes.includes(a.canvasMode))l.canvasMode=a.canvasMode;if(a.preview!==void 0)l.preview=a.preview;if(a.zoom!==void 0)l.zoom=a.zoom;if(a.editZoom!==void 0)l.editZoom=a.editZoom;if(a.activeMedia!==void 0)l.activeMedia=a.activeMedia;if(a.previewColorScheme!==void 0)l.previewColorScheme=a.previewColorScheme;if(a.previewLocale!==void 0)l.previewLocale=a.previewLocale;if(a.showLayout!==void 0)l.showLayout=a.showLayout}let r=g.panes.some((i)=>i.id===e.focusedPane)?e.focusedPane:null,s=null;for(let i of e.panes){let a=g.panes.find((f)=>f.id===i.id);if(!a||!i.activeFile)continue;let l=a.tabOrder.find((f)=>g.tabs.get(f)?.documentPath===i.activeFile);if(!l)continue;if(a.id===r)s=l;else Ft(l,{focus:!1})}if(s)Ft(s);else if(r)Co(r);return o}var zm=["review","deploys","branches","hosting"],YC={branches:"Branches",deploys:"Deploys",hosting:"Hosting",review:"Review changes"},nt=["live","review"],xe="review",Pe="live",rt=new Set(zm),it=new Set(nt);function EA(e){return typeof e==="string"&&rt.has(e)}function Ix(e){return typeof e==="string"&&it.has(e)}var B=["site","collections","styles","files","search","i18n","layers","data","packages","insert"],st=new Set(["collections","styles"]);function ke(e){return e&&!st.has(e)?e:lt}var at=new Map([["blocks","insert"],["head","site"],["page","site"],["imports","packages"],["git","site"],["state","data"]]),lt="site";function ZC(e,t){let o=B.find((r)=>r===e);if(o===void 0)throw Error(`${t}: "${e}" is not a declared Navigator panel id.`);return o}function q(e){if(!n(e))return null;let t=at.get(e);if(t)return t;return B.find((o)=>o===e)??null}var H=["page","properties","style","events","assistant"],Nx="page",ct=["properties","style","events"],XC="properties";function Dx(e){return typeof e==="string"&&ct.some((t)=>t===e)}function KL(e){return typeof e==="string"&&H.some((t)=>t===e)}var Ox=["problems","logic","activity"],GL="problems";function JL(e){return typeof e==="string"&&Ox.some((t)=>t===e)}var Ax=["light","dark"],Kc={content:{id:"content",inspector:{open:!1,whileWriting:!0},navigator:{open:!0,panel:"collections"},rail:!1,tabStrip:!0},design:{id:"design",inspector:{open:!0},navigator:{initial:"site",open:!0},rail:!0,tabStrip:!0},media:{id:"media",inspector:{open:!1},navigator:{open:!1},rail:!1,tabStrip:!1},publish:{id:"publish",inspector:{open:!1},navigator:{open:!1},rail:!1,tabStrip:!1},settings:{id:"settings",inspector:{open:!1},navigator:{open:!1},rail:!1,tabStrip:!1},styles:{id:"styles",inspector:{open:!1,tab:"style",whileWriting:!0},navigator:{open:!0,panel:"styles"},rail:!1,tabStrip:!1}},Ie="jx-studio-panel-widths",_e="jx-studio-project::",ut="dark";function YL(e){return typeof e==="string"&&Ax.some((t)=>t===e)}function pt(){let e=Er(ot.theme);return YL(e)?e:ut}var Px=["left","right","bottom"],D={bottom:{collapsed:!0,size:220},left:{collapsed:!1,size:240},right:{collapsed:!1,size:280}},TA={bottom:D.bottom.size,left:D.left.size,right:D.right.size},ft={bottom:"--dock-h-bottom",left:"--panel-w-left",right:"--panel-w-right"},dt={bottom:"bottom-collapsed",left:"left-collapsed",right:"right-collapsed"},ZL=0.5,QC=0.2,e1=0.8;function mt(e){return J(e)&&e>=QC&&e<=e1?e:ZL}function $A(e){u.paneSplit=Math.min(e1,Math.max(QC,e))}function gt(){try{let e=JSON.parse(localStorage.getItem(Ie)||"{}");return m(e)?e:{}}catch{return{}}}function bt(e){return{left:e("left"),right:e("right"),bottom:e("bottom")}}function Ee(){return{branches:null,commitMessage:"",diffState:null,error:null,lastUpdated:null,loading:!1,logEntries:null,rev:0,status:null}}function Ce(){return{build:{for:"",state:"idle",text:""},deploys:{error:"",project:"",rows:[],state:"idle"},destination:Pe,review:{number:0,url:""},tab:xe}}var ht="tokens";function Ae(){return{customizedOnly:!1,filter:"",selection:null,variable:null,view:ht}}function St(){let e=gt(),t=bt((o)=>{let r=e[o],s=e[`${o}Collapsed`];return{collapsed:qe(s)?s:D[o].collapsed,size:J(r)&&r>0?r:D[o].size}});return{bottomTab:JL(e.bottomTab)?e.bottomTab:GL,docks:t,focusRegion:"pane",paneSplit:mt(e.paneSplit),git:Ee(),publish:Ce(),layoutSelection:null,leftTab:ke(q(e.leftTab)),stylebook:Ae(),theme:pt(),workspace:Up}}he();var yt=["jx-studio-doc-header-expanded"];function wt(){try{for(let e of yt)localStorage.removeItem(e)}catch{}}wt();var u=b(St());function Bd(){try{localStorage.setItem(Ie,JSON.stringify({bottom:u.docks.bottom.size,bottomCollapsed:u.docks.bottom.collapsed,bottomTab:u.bottomTab,left:u.docks.left.size,leftCollapsed:u.docks.left.collapsed,leftTab:u.leftTab,paneSplit:u.paneSplit,right:u.docks.right.size,rightCollapsed:u.docks.right.collapsed}))}catch{}}var G,Y={},ee=null;function LA(){return ee}function oe(e){if(!e)return{};try{let t=JSON.parse(localStorage.getItem(`${_e}${e}`)||"{}");return m(t)?t:{}}catch{return{}}}function XL(e){let t=oe(e).workspace;return bR(t)?t:Up}function RA(e){return ve(oe(e).session)}var ne=null;function Mx(e){ne=e}function IA(){re()}function re(){let e=g.projectRoot;if(!e)return;try{localStorage.setItem(`${_e}${e}`,JSON.stringify({session:e===ne?we():oe(e).session,workspace:u.workspace}))}catch{}}function vt(e){if(e===G)return;if(G=e,Y={},ee=null,u.workspace=XL(e),e===null){u.leftTab=ke(q(u.leftTab));return}$o();try{je(u.workspace),Bd()}finally{Lo()}}function QL(e,t){let{inspector:o}=Kc[e];return o.open||o.whileWriting===!0&&t}function je(e,t){let o=Kc[e],r=q(o.navigator.panel??Y[e]??o.navigator.initial??u.leftTab);if(r)u.leftTab=r;if(u.docks.left.collapsed=!o.navigator.open,u.docks.right.collapsed=!QL(e,t?.writingOnCanvas?.()===!0),o.inspector.tab&&t)t.setInspectorTab(o.inspector.tab)}function t1(e,t){if(u.workspace===e)return!1;if(!Kc[u.workspace].navigator.panel)Y[u.workspace]=u.leftTab;return ee=u.workspace,u.workspace=e,je(e,t),Bd(),re(),!0}function Um(e=u.theme){return e==="light"?"vs":"vs-dark"}function xt(){document.documentElement.dataset.theme=u.theme,af()?.editor.setTheme(Um())}var Pt="rail-hidden",Tt="tabs-hidden";function sy(e=u.workspace){return Kc[e].tabStrip}function kt(){let e=document.documentElement;for(let o of Px)e.style.setProperty(ft[o],`${u.docks[o].size}px`);let t=document.querySelector("#app");if(!t)return;for(let o of Px)t.classList.toggle(dt[o],u.docks[o].collapsed);t.classList.toggle(Pt,!Kc[u.workspace].rail),t.classList.toggle(Tt,!Kc[u.workspace].tabStrip)}var U=null,K=[];function ay(e){if(!K.includes(e))K.push(e)}function NA(){if(U)return;for(let e of K)e.mount();U=me(),U.run(()=>{te(()=>{kt()}),te(()=>{xt()}),te(()=>{vt(g.projectRoot)}),te(()=>{let e=g.projectRoot;g.activePaneId;for(let t of g.panes)t.id,t.activeTabId,t.tabOrder.join("\x00");if(e)re()})})}function kr(e,t){if(u.docks[e].collapsed===t){Bd();return}u.docks[e].collapsed=t,Bd()}function It(e){kr(e,!u.docks[e].collapsed)}function DA(e,t){u.docks[e].size=t}function Gc(e){u.leftTab=e,kr("left",!1),Bd()}function dh(e){u.bottomTab=e,kr("bottom",!1),Bd()}function eR(e){if(u.theme===e)return;u.theme=e,_o(ot.theme,e)}function OA(e){if(e===u.leftTab&&!u.docks.left.collapsed){kr("left",!0);return}Gc(e)}function tR(e){u.layoutSelection=e}function Fx(){Object.assign(u.git,Ee()),Object.assign(u.publish,Ce()),Object.assign(u.stylebook,Ae()),u.layoutSelection=null,ne=null,G=void 0}function Te(e,t){if(t.showWorkspace){t.showWorkspace(e);return}t1(e,t)}var V=(e)=>e.project.open;function _t(e){return[{args:Se({tab:pi(B,"Which Navigator panel to show.")}),category:"View",id:"view.setActivity",level:"application",menus:["commandbar/overflow","palette"],group:"4_docks",requires:"an open project",when:V,run:(t,o)=>{let r=qn("view.setActivity",o,"tab",B);if(e.panelAvailable&&!e.panelAvailable(r))throw RangeError(`command "view.setActivity" argument "tab": "${r}" names a panel that is registered but not available right now, so showing it would persist a Navigator tab nothing can draw`);Gc(r)},title:"Show Navigator Panel"},{args:Se({tab:pi(H,"Which Inspector tab to show.")}),category:"View",id:"view.setRightTab",level:"document",menus:["palette"],group:"4_docks",requires:"an open document",when:(t)=>t.document.open,run:(t,o)=>{e.setInspectorTab(qn("view.setRightTab",o,"tab",H))},title:"Show Inspector Tab"},{args:Se({open:Tr("True to show the Navigator dock, false to collapse it.")}),category:"View",id:"view.setNavigator",level:"application",menus:["palette"],group:"4_docks",run:(t,o)=>{kr("left",!Hi("view.setNavigator",o,"open"))},title:"Show Navigator Dock"},{args:Se({open:Tr("True to show the Inspector dock, false to collapse it.")}),category:"View",id:"view.setRightPanel",level:"application",menus:["palette"],group:"4_docks",run:(t,o)=>{kr("right",!Hi("view.setRightPanel",o,"open"))},title:"Show Inspector Dock"},{args:Se({open:Tr("True to show the Bottom dock, false to collapse it.")}),category:"View",id:"view.setBottomDock",level:"application",menus:["palette"],group:"4_docks",run:(t,o)=>{kr("bottom",!Hi("view.setBottomDock",o,"open"))},title:"Show Bottom Dock"},{category:"View",id:"view.toggleBottomDock",keybinding:"mod+j",level:"application",menus:["commandbar/overflow","palette"],group:"4_docks",run:()=>{It("bottom")},title:"Toggle Bottom Dock"},{args:Se({tab:pi(Ox,"Which Bottom dock tab to show.")}),category:"View",id:"view.setBottomTab",level:"application",menus:["palette"],group:"4_docks",run:(t,o)=>{let r=qn("view.setBottomTab",o,"tab",Ox);if(e.panelAvailable&&!e.panelAvailable(r))throw RangeError(`command "view.setBottomTab" argument "tab": "${r}" names a panel that is registered but not available right now, so showing it would persist a Bottom dock tab nothing can draw`);dh(r)},title:"Show Bottom Dock Tab"},{args:Se({open:Tr("True to show the Assistant tab, false to step off it.")}),category:"View",id:"view.setAssistant",level:"application",menus:["never"],group:"4_docks",run:(t,o)=>{if(Hi("view.setAssistant",o,"open")){kr("right",!1),e.setInspectorTab("assistant");return}if(e.inspectorTab()==="assistant")e.setInspectorTab(e.restingInspectorTab?.()??Nx)},title:"Show Assistant"},{args:Se({workspace:pi(s1,"Which workspace to show.")}),category:"View",id:"view.setWorkspace",level:"application",menus:["never"],group:"4_workspaces",requires:"an open project",when:V,run:(t,o)=>{Te(qn("view.setWorkspace",o,"workspace",s1),e)},title:"Switch Workspace"},...Kx.map((t,o)=>({category:"View",id:`workspace.focus.${t.id}`,keybinding:`mod+${o+1}`,level:"application",menus:["palette"],group:"4_workspaces",requires:"an open project",when:V,run:()=>{Te(t.id,e)},title:`Go to ${t.title}`})),{args:Se({color:pi(Ax,"The Studio chrome's theme.")}),category:"View",id:"view.setTheme",level:"application",menus:["palette"],group:"6_appearance",run:(t,o)=>{eR(qn("view.setTheme",o,"color",Ax))},title:"Set Theme"}]}function AA(e,t){e.registerAll(_t(t))}function ie(e){return e.replaceAll("~","~0").replaceAll("/","~1")}var Et=100;function ue(e){let t={blankAfter:new Set,escaped:new Map,inline:new Map},o=0,r=()=>{let l=0;while(o<e.length&&(e[o]===" "||e[o]==="\t"||e[o]==="\r"||e[o]===`
2
+ `)){if(e[o]===`
3
+ `)l+=1;o+=1}return l},s=()=>{let l=o,f=new Set;o+=1;while(o<e.length&&e[o]!=='"')if(e[o]==="\\")if(e[o+1]==="u"){let h=Number.parseInt(e.slice(o+2,o+6),16);if(h>=128)f.add(h);o+=6}else o+=2;else o+=1;return o+=1,{escaped:f,raw:e.slice(l,o)}},i=(l,f)=>{let h=r();if(e[o]===f)return o+=1,!0;if(o+=1,h+=r(),h>=2)t.blankAfter.add(l);return!1},a=(l)=>{r();let f=e[o];if(f==="{"){o+=1;let h=r()>0;if(e[o]==="}"){o+=1;return}t.inline.set(l,!h);while(o<e.length){let c=JSON.parse(s().raw);r(),o+=1;let d=`${l}/${ie(c)}`;if(a(d),i(d,"}"))return}}else if(f==="["){if(o+=1,r(),e[o]==="]"){o+=1;return}for(let h=0;o<e.length;h+=1){let c=`${l}/${h}`;if(a(c),i(c,"]"))return}}else if(f==='"'){let{escaped:h}=s();if(h.size>0)t.escaped.set(l,h)}else while(o<e.length&&!`,]} \r
4
+ `.includes(e[o]))o+=1};return a(""),t}function Ts(e){return{document:JSON.parse(e),layout:ue(e)}}var Ct=/[^\u0020-\u007E]/,At=/^[\p{Mn}\p{Me}\p{Cf}]$/u,jt=/^\p{Emoji_Presentation}$/u;function Nt(e){return e>=4352&&(e<=4447||e===9001||e===9002||e>=11904&&e<=12871&&e!==12351||e>=12880&&e<=19903||e>=19968&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65131||e>=65281&&e<=65376||e>=65504&&e<=65510||e>=110592&&e<=110593||e>=127488&&e<=127569||e>=131072&&e<=262141)}function Ne(e){if(!Ct.test(e))return e.length;let t=0;for(let o of e){if(At.test(o))continue;t+=Nt(o.codePointAt(0))||jt.test(o)?2:1}return t}function Oe(e){return e===void 0||Q(e)||Xy(e)}function se(e){return Object.entries(e).filter(([,t])=>!Oe(t))}function z(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Ot(e){if(e.length<2)return!1;let t=Array.isArray(e[0])?"array":z(e[0])?"object":null;if(t===null)return!1;return e.every((o)=>t==="array"?Array.isArray(o)&&o.length>1:z(o)&&se(o).length>1)}function Dt(e){return e.length>1&&e.every((t)=>J(t))}function ae(e,t){let o=Oe(e)?"null":JSON.stringify(e);return t===void 0?o:o.replaceAll(/[\u0080-\uFFFF]/g,(r)=>{let s=r.codePointAt(0);return t.has(s)?`\\u${s.toString(16).padStart(4,"0")}`:r})}function Cr(e,t,o=Et){let r=t?.inline??new Map,s=t?.blankAfter??new Set,i=t?.escaped??new Map,a=(c,d)=>r.get(c)??d,l=(c,d,y)=>{if(Array.isArray(c)){if(c.length===0)return"[]";if(Ot(c))return null;let v=[];for(let[T,k]of c.entries()){let I=`${d}/${T}`,P=s.has(I)?null:l(k,I,y);if(P===null)return null;v.push(P)}return`[${v.join(", ")}]`}if(z(c)){let v=se(c);if(v.length===0)return"{}";if(!a(d,y))return null;let T=[];for(let[k,I]of v){let P=`${d}/${ie(k)}`,C=s.has(P)?null:l(I,P,!0);if(C===null)return null;T.push(`${JSON.stringify(k)}: ${C}`)}return`{ ${T.join(", ")} }`}return ae(c,i.get(d))},f=(c)=>c.map(({path:d,text:y},v)=>v===c.length-1?y:`${y},
5
+ ${s.has(d)?`
6
+ `:""}`).join(""),h=(c,d,y,v,T,k)=>{if(!Array.isArray(c)&&!z(c))return ae(c,i.get(d));let I=l(c,d,T);if(I!==null&&v+Ne(I)+k<=o)return I;let P=" ".repeat(y+2),C=`
7
+ ${" ".repeat(y)}`;if(Array.isArray(c)){if(Dt(c))return`[
8
+ ${Lt(c,P,o,(A)=>s.has(`${d}/${A}`))}${C}]`;let L=c.map((R,A)=>{let O=`${d}/${A}`,M=A===c.length-1,F=h(R,O,y+2,P.length,T,M?0:1);return{path:O,text:`${P}${F}`}});return`[
9
+ ${f(L)}${C}]`}let ge=se(c),Be=a(d,T),ze=ge.map(([L,R],A)=>{let O=`${d}/${ie(L)}`,M=`${JSON.stringify(L)}: `,F=A===ge.length-1,Fe=P.length+Ne(M),Ue=h(R,O,y+2,Fe,Be,F?0:1);return{path:O,text:`${P}${M}${Ue}`}});return`{
10
+ ${f(ze)}${C}}`};return`${h(e,"",0,0,!1,0)}
11
+ `}function Lt(e,t,o,r){let s=[],i="";for(let[a,l]of e.entries()){let f=`${ae(l)}${a===e.length-1?"":","}`;if(i==="")i=`${t}${f}`;else if(i.length+1+f.length<=o)i=`${i} ${f}`;else s.push(i),i=`${t}${f}`;if(r(a)&&a<e.length-1)s.push(i,""),i=""}return s.push(i),s.join(`
12
+ `)}function Wm(e){return Cr(e,Re())}var _=null,j=null,N=null,E=null;function Re(){return $e()?.doc.layout??E}var pe=null;function $e(){let e=g.tabs.get(an);return e?le(e):null}function Rt(){if(j)Zm(j),j=null;_=null,N=null,E=null,pe=null}function Je(){return pe??=(async()=>{try{let e=await p().readFile(an),{document:t,layout:o}=Ts(e);E=o,N=Cr(t,Re())}catch{N=null}})(),pe}async function zL(e){if(await Je(),e.doc.layout===null&&E!==null)e.doc.layout=E}function $t(e){let t=_n();if(t.projectConfig===e)return;id({...t,projectConfig:e}),ac(g.projectRoot,e)}function Jt(){let e=x?.projectConfig;return e?le(e):null}function fe(e){return le(e)}function Me(e,t){for(let o of Object.keys(e))delete e[o];Object.assign(e,t)}function De(e){return _=e,e.scope.run(()=>{te(()=>{let t=e.doc.document;if(_!==e||!x)return;$t(fe(t))})}),e}function JC(){let e=_n(),t=$e();if(_&&(_!==(t??j)||le(_.doc.document)!==e.projectConfig))Rt();if(_)return _;if(t)return De(t);return j=Cy({document:e.projectConfig??{},documentPath:an,id:an}),De(j)}function Le(e){return JSON.stringify(e.extensions??null)}async function Mt(){let{loadFormats:e,refreshExtensionUi:t,refreshFormats:o}=await (ce("7xe57k1s"),import("./format-host-7xe57k1s.js"));o(),e(),t(p())}async function rc(e){let t=Jt(),o=JC();await zL(o);let r=fe(o.doc.document),s=Wm(r),i=t&&t!==r&&Wm(t)!==s?t:null;if(i&&o.doc.dirty){let y=Error(`${an} has unsaved changes in its editor tab`);return w.error(`Could not save ${an} — the file is open with unsaved changes. Save or `+"revert that tab, then make the settings change again.",{key:`save:${an}`,path:an,source:"Settings"}),{error:y,ok:!1}}let a=i??r,l=e?{...a,...e}:a,f=Wm(l);if(!i&&!o.doc.dirty&&f===N)return{ok:!0};let h=Le(r);Z(o,(y)=>{let v=y.doc.document;if(i)Me(v,i);for(let[T,k]of Object.entries(e??{}))v[T]=k});let c=fe(o.doc.document),d=Wm(c);try{await p().writeFile(an,d)}catch(y){return w.error(`Could not save ${an} — ${X(y)}`,{key:`save:${an}`,path:an,source:"Settings"}),{error:y,ok:!1}}if(N=d,o.doc.dirty=!1,Le(c)!==h)await Mt();return{ok:!0}}async function _A(e,t){if(!x){ac(g.projectRoot,e);return}let o=JC();Z(o,(r)=>Me(r.doc.document,e),{skipHistory:!0}),o.doc.dirty=!1,await Je(),E=ue(t),o.doc.layout=E,N=Wm(e)}function tr(e){let t=x?.projectConfig?.$media;if(!t)return e||{};if(!e)return{...t};return{...t,...e}}function xo(e){let t=x?.projectConfig?.style;if(!t)return e||{};if(!e)return{...t};let o={...t};for(let[r,s]of Object.entries(e)){let i=o[r];o[r]=S(s)&&S(i)?{...i,...s}:s}return o}function SA(e,t=[]){return{...UL(t),...x?.projectConfig?.imports,...e}}function UL(e){let t=e.flatMap((o)=>(o.classes??[]).filter((r)=>r.path.endsWith(".class.json")).map((r)=>[r.name,r.path]));return Object.fromEntries(t.toReversed())}function $x(e){let t=x?.projectConfig?.$elements;if(!t?.length)return e||[];if(!e?.length)return[...t];let o=new Set,r=[];for(let s of[...t,...e]){let i=n(s)?s:S(s)?s.$ref:void 0;if(i&&!o.has(i))o.add(i),r.push(s)}return r}function Lx(e){let t=x?.projectConfig?.$head;if(!t?.length)return e||[];if(!e?.length)return[...t];let o=new Set,r=[];for(let s of[...t,...e]){let i=S(s)?s.attributes:void 0,a=String(i?.href||i?.src||"")||JSON.stringify(s);if(!o.has(a))o.add(a),r.push(s)}return r}function $s(){let e=x?.projectConfig;return e?ln(e).i18n:null}function Hp(e,t){let o=$s();if(o===null)return null;let r=jn(e);if(r!==null&&o.locales.includes(r))return r;return gr(t??"",o)??o.defaultLocale}var de=new Map;function CA(){de.clear()}function fl(e){if(e===!1)return null;let t=x?.projectConfig?.defaults?.layout;return e||t||null}async function Rx(e){let t=e.replace(/^\.\//,""),o=de.get(t);if(o!==void 0)return structuredClone(o);try{let s=await p().readFile(t),i=JSON.parse(s);return de.set(t,i),structuredClone(i)}catch{return null}}function qL(e,t){let o=t.children??[],r=Array.isArray(o)?o:[],s=new Map,i=[];for(let a of r){let l=n(a)?void 0:a.attributes?.slot;if(!n(a)&&n(l)&&l){if(!s.has(l))s.set(l,[]);s.get(l).push(a)}else i.push(a)}if(We(e,s,i),t.state)e.state={...e.state,...t.state};if(t.$media)e.$media={...e.$media,...t.$media};if(t.style)e.style={...e.style,...t.style};if(t.attributes)e.attributes={...e.attributes,...t.attributes};return e}function We(e,t,o){if(!Array.isArray(e.children))return;let r=[];for(let s of e.children)if(S(s)&&s.tagName==="slot"){let i=s.attributes?.name;if(n(i)&&i&&t.has(i))r.push(...t.get(i)),t.delete(i);else if(!i&&o.length>0)r.push(...o);else if(Array.isArray(s.children))r.push(...s.children)}else{if(S(s))We(s,t,o);r.push(s)}e.children=r}async function nr(e){let t=await rc(e);if(!t.ok)throw t.error}
13
+ export{Ts,Cr,Wm,zL,JC,rc,_A,tr,xo,SA,UL,$x,Lx,$s,Hp,CA,fl,Rx,qL,nr,kA,zm,YC,EA,Ix,ZC,Nx,XC,Dx,KL,Ox,GL,JL,Ax,Kc,YL,Px,TA,ZL,QC,e1,$A,u,Bd,LA,XL,RA,Mx,IA,QL,t1,Um,sy,ay,NA,kr,DA,Gc,dh,eR,OA,tR,Fx,AA};
14
+
15
+ //# debugId=80CC3C2FB271FD9164756E2164756E21
16
+ //# sourceMappingURL=studio-1d8m5s38.js.map
@@ -0,0 +1,5 @@
1
+ import{ot,Er,_o,Vp}from"./studio-c72v1kwc.js";function mb(){return Er(ot.cfToken)}function UE(t){_o(ot.cfToken,t||"")}function qE(){return Er(ot.cfAccountId)}function CF(t){_o(ot.cfAccountId,t||"")}function KE(){Vp([ot.cfToken,ot.cfAccountId])}
2
+ export{mb,UE,qE,CF,KE};
3
+
4
+ //# debugId=C4229E8CF390BC4D64756E2164756E21
5
+ //# sourceMappingURL=studio-35pmfjtx.js.map
@@ -1,9 +1,9 @@
1
- import{n,_}from"./studio-k3we3kqb.js";var is=Math.floor;var nt=Math.abs;var ue=(t,e)=>t<e?t:e,Z=(t,e)=>t>e?t:e;var de=(t)=>t!==0?t<0:1/t<0;var cn=1,ln=2,fe=4,pe=8;var dt=32,F=64,D=128;var Vt=31,Mt=63,X=127;var fr=2147483647;var{MAX_SAFE_INTEGER:ft,MIN_SAFE_INTEGER:hn}=Number;var pr=Number.isInteger||((t)=>typeof t==="number"&&isFinite(t)&&is(t)===t);var G=()=>new Set;var ge=(t)=>t[t.length-1];var gr=(t,e)=>{for(let r=0;r<e.length;r++)t.push(e[r])},j=Array.from,me=(t,e)=>{for(let r=0;r<t.length;r++)if(!e(t[r],r,t))return!1;return!0},$t=(t,e)=>{for(let r=0;r<t.length;r++)if(e(t[r],r,t))return!0;return!1};var mr=(t,e)=>{let r=Array(t);for(let s=0;s<t;s++)r[s]=e(s,r);return r};var Q=Array.isArray;var{fromCharCode:fn,fromCodePoint:yi}=String,Zc=fn(65535),bi=(t)=>t.toLowerCase(),ki=/^\s*/g,_i=(t)=>t.replace(ki,""),Si=/([A-Z])/g,pn=(t,e)=>_i(t.replace(Si,(r)=>`${e}${bi(r)}`));var Ei=(t)=>{let e=unescape(encodeURIComponent(t)),r=e.length,s=new Uint8Array(r);for(let i=0;i<r;i++)s[i]=e.codePointAt(i);return s},gt=typeof TextEncoder<"u"?new TextEncoder:null,Ii=(t)=>gt.encode(t),wr=gt?Ii:Ei;var pt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});if(pt&&pt.decode(new Uint8Array).length===1)pt=null;var xr=(t,e)=>mr(e,()=>t).join("");class wt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var Qa=()=>new wt;var Zk=(t)=>{let e=t.cpos;for(let r=0;r<t.bufs.length;r++)e+=t.bufs[r].length;return e};var br=(t)=>{let e=new Uint8Array(Zk(t)),r=0;for(let s=0;s<t.bufs.length;s++){let i=t.bufs[s];e.set(i,r),r+=i.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),r),e},Ui=(t,e)=>{let r=t.cbuf.length;if(r-t.cpos<e)t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(Z(r,e)*2),t.cpos=0},T=(t,e)=>{let r=t.cbuf.length;if(t.cpos===r)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(r*2),t.cpos=0;t.cbuf[t.cpos++]=e};var xe=T;var _t=(t,e)=>{while(e>X)T(t,D|X&e),e=is(e/128);T(t,X&e)},ye=(t,e)=>{let r=de(e);if(r)e=-e;T(t,(e>Mt?D:0)|(r?F:0)|Mt&e),e=is(e/64);while(e>0)T(t,(e>X?D:0)|X&e),e=is(e/128)},gn=new Uint8Array(30000),Ti=gn.length/3,Ai=(t,e)=>{if(e.length<Ti){let r=gt.encodeInto(e,gn).written||0;_t(t,r);for(let s=0;s<r;s++)T(t,gn[s])}else zo(t,wr(e))},Ci=(t,e)=>{let r=unescape(encodeURIComponent(e)),s=r.length;_t(t,s);for(let i=0;i<s;i++)T(t,r.codePointAt(i))},el=gt&&gt.encodeInto?Ai:Ci;var jt=(t,e)=>{let r=t.cbuf.length,s=t.cpos,i=ue(r-s,e.length),o=e.length-i;if(t.cbuf.set(e.subarray(0,i),s),t.cpos+=i,o>0)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(Z(r*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o},zo=(t,e)=>{_t(t,e.byteLength),jt(t,e)},mn=(t,e)=>{Ui(t,e);let r=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,r},Di=(t,e)=>mn(t,4).setFloat32(0,e,!1),Bi=(t,e)=>mn(t,8).setFloat64(0,e,!1),Oi=(t,e)=>mn(t,8).setBigInt64(0,e,!1);var yr=new DataView(new ArrayBuffer(4)),vi=(t)=>(yr.setFloat32(0,t),yr.getFloat32(0)===t),mt=(t,e)=>{switch(typeof e){case"string":T(t,119),el(t,e);break;case"number":if(pr(e)&&nt(e)<=fr)T(t,125),ye(t,e);else if(vi(e))T(t,124),Di(t,e);else T(t,123),Bi(t,e);break;case"bigint":T(t,122),Oi(t,e);break;case"object":if(e===null)T(t,126);else if(Q(e)){T(t,117),_t(t,e.length);for(let r=0;r<e.length;r++)mt(t,e[r])}else if(e instanceof Uint8Array)T(t,116),zo(t,e);else{T(t,118);let r=Object.keys(e);_t(t,r.length);for(let s=0;s<r.length;s++){let i=r[s];el(t,i),mt(t,e[i])}}break;case"boolean":T(t,e?120:121);break;default:T(t,127)}};class be extends wt{constructor(t){super();this.w=t,this.s=null,this.count=0}write(t){if(this.s===t)this.count++;else{if(this.count>0)_t(this,this.count-1);this.count=1,this.w(this,t),this.s=t}}}var kr=(t)=>{if(t.count>0){if(ye(t.encoder,t.count===1?t.s:-t.s),t.count>1)_t(t.encoder,t.count-2)}};class xt{constructor(){this.encoder=new wt,this.s=0,this.count=0}write(t){if(this.s===t)this.count++;else kr(this),this.count=1,this.s=t}toUint8Array(){return kr(this),br(this.encoder)}}var _r=(t)=>{if(t.count>0){let e=t.diff*2+(t.count===1?0:1);if(ye(t.encoder,e),t.count>1)_t(t.encoder,t.count-2)}};class qt{constructor(){this.encoder=new wt,this.s=0,this.count=0,this.diff=0}write(t){if(this.diff===t-this.s)this.s=t,this.count++;else _r(this),this.count=1,this.diff=t-this.s,this.s=t}toUint8Array(){return _r(this),br(this.encoder)}}class wn{constructor(){this.sarr=[],this.s="",this.lensE=new xt}write(t){if(this.s+=t,this.s.length>19)this.sarr.push(this.s),this.s="";this.lensE.write(t.length)}toUint8Array(){let t=new wt;return this.sarr.push(this.s),this.s="",el(t,this.sarr.join("")),jt(t,this.lensE.toUint8Array()),br(t)}}var R=(t)=>Error(t),L=()=>{throw R("Method unimplemented")},v=()=>{throw R("Unexpected case")};var ke=R("Unexpected end of array"),Er=R("Integer out of Range"),Ni=(t,e,r)=>{if(e<0||r<0||e+r>t.length)throw ke;return new Uint8Array(t.buffer,t.byteOffset+e,r)},Ri=(t,e,r)=>{if(e<0||r<0||e+r>t.length)throw ke;return new DataView(t.buffer,t.byteOffset+e,r)};class Gt{constructor(t){this.arr=t,this.pos=0}}var tl=(t)=>new Gt(t),Ir=(t)=>t.pos!==t.arr.length;var Li=(t,e)=>{let r=Ni(t.arr,t.pos,e);return t.pos+=e,r},Xo=(t)=>Li(t,Dt(t));var rt=(t)=>t.arr[t.pos++];var Dt=(t)=>{let e=0,r=1,s=t.arr.length;while(t.pos<s){let i=t.arr[t.pos++];if(e=e+(i&X)*r,r*=128,i<D)return e;if(e>ft)throw Er}throw ke},_e=(t)=>{let e=t.arr[t.pos++],r=e&Mt,s=64,i=(e&F)>0?-1:1;if((e&D)===0)return i*r;let o=t.arr.length;while(t.pos<o){if(e=t.arr[t.pos++],r=r+(e&X)*s,s*=128,e<D)return i*r;if(r>ft)throw Er}throw ke};var Vi=(t)=>{let e=Dt(t);if(e===0)return"";else{let r=String.fromCodePoint(rt(t));if(--e<100)while(e--)r+=String.fromCodePoint(rt(t));else while(e>0){let s=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+s);t.pos+=s,r+=String.fromCodePoint.apply(null,i),e-=s}return decodeURIComponent(escape(r))}},Mi=(t)=>pt.decode(Xo(t)),nl=pt?Mi:Vi;var yn=(t,e)=>{let r=Ri(t.arr,t.pos,e);return t.pos+=e,r},$i=(t)=>yn(t,4).getFloat32(0,!1),Fi=(t)=>yn(t,8).getFloat64(0,!1),ji=(t)=>yn(t,8).getBigInt64(0,!1);var qi=[(t)=>{return},(t)=>null,_e,$i,Fi,ji,(t)=>!1,(t)=>!0,nl,(t)=>{let e=Dt(t),r={};for(let s=0;s<e;s++){let i=nl(t);r[i]=yt(t)}return r},(t)=>{let e=Dt(t),r=[];for(let s=0;s<e;s++)r.push(yt(t));return r},Xo],yt=(t)=>qi[127-rt(t)](t);class Se extends Gt{constructor(t,e){super(t);this.reader=e,this.s=null,this.count=0}read(){if(this.count===0)if(this.s=this.reader(this),Ir(this))this.count=Dt(this)+1;else this.count=-1;return this.count--,this.s}}class bt extends Gt{constructor(t){super(t);this.s=0,this.count=0}read(){if(this.count===0){this.s=_e(this);let t=de(this.s);if(this.count=1,t)this.s=-this.s,this.count=Dt(this)+2}return this.count--,this.s}}class zt extends Gt{constructor(t){super(t);this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let t=_e(this),e=t&1;if(this.diff=is(t/2),this.count=1,e)this.count=Dt(this)+2}return this.s+=this.diff,this.count--,this.s}}class bn{constructor(t){this.decoder=new bt(t),this.str=nl(this.decoder),this.spos=0}read(){let t=this.spos+this.decoder.read(),e=this.str.slice(this.spos,t);return this.spos=t,e}}var A=()=>new Map,Ee=(t)=>{let e=A();return t.forEach((r,s)=>{e.set(s,r)}),e},q=(t,e,r)=>{let s=t.get(e);if(s===void 0)t.set(e,s=r());return s},Tr=(t,e)=>{let r=[];for(let[s,i]of t)r.push(e(i,s));return r},Ar=(t,e)=>{for(let[r,s]of t)if(e(s,r))return!0;return!1};class Ie{constructor(){this._observers=A()}on(t,e){return q(this._observers,t,G).add(e),e}once(t,e){let r=(...s)=>{this.off(t,r),e(...s)};this.on(t,r)}off(t,e){let r=this._observers.get(t);if(r!==void 0){if(r.delete(e),r.size===0)this._observers.delete(t)}}emit(t,e){return j((this._observers.get(t)||A()).values()).forEach((r)=>r(...e))}destroy(){this._observers=A()}}class Yk{constructor(){this._observers=A()}on(t,e){q(this._observers,t,G).add(e)}once(t,e){let r=(...s)=>{this.off(t,r),e(...s)};this.on(t,r)}off(t,e){let r=this._observers.get(t);if(r!==void 0){if(r.delete(e),r.size===0)this._observers.delete(t)}}emit(t,e){return j((this._observers.get(t)||A()).values()).forEach((r)=>r(...e))}destroy(){this._observers=A()}}var rl=crypto.subtle,Cr=crypto.getRandomValues.bind(crypto);var kn=()=>Cr(new Uint32Array(1))[0];var Gi=[1e7]+-1000+-4000+-8000+-100000000000,Dr=()=>Gi.replace(/[018]/g,(t)=>(t^kn()&15>>t/4).toString(16));var $u=Date.now;var _n=(t)=>new Promise(t);var ol=Promise.all.bind(Promise);var Sn=(t)=>t===void 0?null:t;class Or{constructor(){this.map=new Map}setItem(t,e){this.map.set(t,e)}getItem(t){return this.map.get(t)}}var vr=new Or,Pi=!0;try{if(typeof localStorage<"u"&&localStorage)vr=localStorage,Pi=!1}catch(t){}var Nr=vr;var st=Symbol("Equality"),Ue=(t,e)=>t===e||!!t?.[st]?.(e)||!1;var Rr=(t)=>typeof t==="object",{assign:Lr,keys:Wi}=Object;var Vr=(t,e)=>{for(let r in t)e(t[r],r)};var Jt=(t)=>Wi(t).length;var Mr=(t)=>{for(let e in t)return!1;return!0},kt=(t,e)=>{for(let r in t)if(!e(t[r],r))return!1;return!0},Pt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),In=(t,e)=>t===e||Jt(t)===Jt(e)&&kt(t,(r,s)=>(r!==void 0||Pt(e,s))&&Ue(e[s],r)),Zi=Object.freeze,Un=(t)=>{for(let e in t){let r=t[e];if(typeof r==="object"||typeof r==="function")Un(t[e])}return Zi(t)};var Kt=(t,e,r=0)=>{try{for(;r<t.length;r++)t[r](...e)}finally{if(r<t.length)Kt(t,e,r+1)}};var $r=(t)=>t;var fp=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[st]!=null)return t[st](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;break}case Set:{if(t.size!==e.size)return!1;for(let r of t)if(!e.has(r))return!1;break}case Map:{if(t.size!==e.size)return!1;for(let r of t.keys())if(!e.has(r)||!fp(t.get(r),e.get(r)))return!1;break}case void 0:case Object:if(Jt(t)!==Jt(e))return!1;for(let r in t)if(!Pt(t,r)||!fp(t[r],e[r]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!fp(t[r],e[r]))return!1;break;default:return!1}return!0},Fr=(t,e)=>e.includes(t);var Wt=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";var cl=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,z,Xi=[],Qi=()=>{if(z===void 0)if(Wt){z=A();let t=process.argv,e=null;for(let r=0;r<t.length;r++){let s=t[r];if(s[0]==="-"){if(e!==null)z.set(e,"");e=s}else if(e!==null)z.set(e,s),e=null;else Xi.push(s)}if(e!==null)z.set(e,"")}else if(typeof location==="object")z=A(),(location.search||"?").slice(1).split("&").forEach((t)=>{if(t.length!==0){let[e,r]=t.split("=");z.set(`--${pn(e,"-")}`,r),z.set(`-${pn(e,"-")}`,r)}});else z=A();return z},Cn=(t)=>Qi().has(t);var Zt=(t)=>Wt?Sn(process.env[t.toUpperCase().replaceAll("-","_")]):Sn(Nr.getItem(t));var jr=(t)=>Cn("--"+t)||Zt(t)!==null,qr=jr("production"),Yi=Wt&&Fr(process.env.FORCE_COLOR,["true","1","2"]),Gr=Yi||!Cn("--no-colors")&&!jr("no-color")&&(!Wt||process.stdout.isTTY)&&(!Wt||Cn("--color")||Zt("COLORTERM")!==null||(Zt("TERM")||"").includes("color"));var to=(t)=>new Uint8Array(t);var zr=(t)=>{let e=to(t.byteLength);return e.set(t),e};class Hr{constructor(t,e){this.left=t,this.right=e}}var H=(t,e)=>new Hr(t,e);var Bn=(t)=>t.next()>=0.5,Te=(t,e,r)=>is(t.next()*(r+1-e)+e);var On=(t,e,r)=>is(t.next()*(r+1-e)+e);var vn=(t,e,r)=>On(t,e,r);var ro=(t)=>fn(vn(t,97,122)),Jr=(t,e=0,r=20)=>{let s=vn(t,e,r),i="";for(let o=0;o<s;o++)i+=ro(t);return i};var Ae=(t,e)=>e[vn(t,0,e.length-1)];var io=Symbol("0schema");class Kr{constructor(){this._rerrs=[]}extend(t,e,r,s=null){this._rerrs.push({path:t,expected:e,has:r,message:s})}toString(){let t=[];for(let e=this._rerrs.length-1;e>0;e--){let r=this._rerrs[e];t.push(xr(" ",(this._rerrs.length-e)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return t.join(`
2
- `)}}var Nn=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor)return!1;if(t[st])return Ue(t,e);if(Q(t))return me(t,(r)=>$t(e,(s)=>Nn(r,s)));else if(Rr(t))return kt(t,(r,s)=>Nn(r,e[s]));return!1};class B{static _dilutes=!1;extends(t){let[e,r]=[this.shape,t.shape];if(this.constructor._dilutes)[r,e]=[e,r];return Nn(e,r)}equals(t){return this.constructor===t.constructor&&fp(this.shape,t.shape)}[io](){return!0}[st](t){return this.equals(t)}validate(t){return this.check(t)}check(t,e){L()}get nullable(){return Ut(this,Ve)}get optional(){return new Rn(this)}cast(t){return Pr(t,this),t}expect(t){return Pr(t,this),t}}class Be extends B{constructor(t,e){super();this.shape=t,this._c=e}check(t,e=void 0){let r=t?.constructor===this.shape&&(this._c==null||this._c(t));return!r&&e?.extend(null,this.shape.name,t?.constructor.name,t?.constructor!==this.shape?"Constructor match failed":"Check failed"),r}}var S=(t,e=null)=>new Be(t,e),al=S(Be);class Oe extends B{constructor(t){super();this.shape=t}check(t,e){let r=this.shape(t);return!r&&e?.extend(null,"custom prop",t?.constructor.name,"failed to check custom prop"),r}}var E=(t)=>new Oe(t),hl=S(Oe);class Qt extends B{constructor(t){super();this.shape=t}check(t,e){let r=this.shape.some((s)=>s===t);return!r&&e?.extend(null,this.shape.join(" | "),t.toString()),r}}var ve=(...t)=>new Qt(t),Wr=S(Qt),oo=RegExp.escape||((t)=>t.replace(/[().|&,$^[\]]/g,(e)=>"\\"+e)),Zr=(t)=>{if(It.check(t))return[oo(t)];if(Wr.check(t))return t.shape.map((e)=>e+"");if(cs.check(t))return["[+-]?\\d+.?\\d*"];if(ls.check(t))return[".*"];if(Ce.check(t))return t.shape.map(Zr).flat(1);v()};class Xr extends B{constructor(t){super();this.shape=t,this._r=new RegExp("^"+t.map(Zr).map((e)=>`(${e.join("|")})`).join("")+"$")}check(t,e){let r=this._r.exec(t)!=null;return!r&&e?.extend(null,this._r.toString(),t.toString(),"String doesn't match string template."),r}}var ul=S(Xr),co=Symbol("optional");class Rn extends B{constructor(t){super();this.shape=t}check(t,e){let r=t===void 0||this.shape.check(t);return!r&&e?.extend(null,"undefined (optional)","()"),r}get[co](){return!0}}var lo=S(Rn);class Ln extends B{check(t,e){return e?.extend(null,"never",typeof t),!1}}var dl=new Ln,fl=S(Ln);class Ne extends B{constructor(t,e=!1){super();this.shape=t,this._isPartial=e}static _dilutes=!0;get partial(){return new Ne(this.shape,!0)}check(t,e){if(t==null)return e?.extend(null,"object","null"),!1;return kt(this.shape,(r,s)=>{let i=this._isPartial&&!Pt(t,s)||r.check(t[s],e);return!i&&e?.extend(s.toString(),r.toString(),typeof t[s],"Object property does not match"),i})}}var ao=(t)=>new Ne(t),ho=S(Ne),uo=E((t)=>t!=null&&(t.constructor===Object||t.constructor==null));class Vn extends B{constructor(t,e){super();this.shape={keys:t,values:e}}check(t,e){return t!=null&&kt(t,(r,s)=>{let i=this.shape.keys.check(s,e);return!i&&e?.extend(s+"","Record",typeof t,i?"Key doesn't match schema":"Value doesn't match value"),i&&this.shape.values.check(r,e)})}}var Qr=(t,e)=>new Vn(t,e),fo=S(Vn);class Mn extends B{constructor(t){super();this.shape=t}check(t,e){return t!=null&&kt(this.shape,(r,s)=>{let i=r.check(t[s],e);return!i&&e?.extend(s.toString(),"Tuple",typeof r),i})}}var po=(...t)=>new Mn(t),pl=S(Mn);class $n extends B{constructor(t){super();this.shape=t.length===1?t[0]:new Re(t)}check(t,e){let r=Q(t)&&me(t,(s)=>this.shape.check(s));return!r&&e?.extend(null,"Array",""),r}}var Yr=(...t)=>new $n(t),go=S($n),mo=E((t)=>Q(t));class Fn extends B{constructor(t,e){super();this.shape=t,this._c=e}check(t,e){let r=t instanceof this.shape&&(this._c==null||this._c(t));return!r&&e?.extend(null,this.shape.name,t?.constructor.name),r}}var wo=(t,e=null)=>new Fn(t,e),gl=S(Fn),xo=wo(B);class ts extends B{constructor(t){super();this.len=t.length-1,this.args=po(...t.slice(-1)),this.res=t[this.len]}check(t,e){let r=t.constructor===Function&&t.length<=this.len;return!r&&e?.extend(null,"function",typeof t),r}}var yo=S(ts),bo=E((t)=>typeof t==="function");class es extends B{constructor(t){super();this.shape=t}check(t,e){let r=me(this.shape,(s)=>s.check(t,e));return!r&&e?.extend(null,"Intersectinon",typeof t),r}}var ml=S(es,(t)=>t.shape.length>0);class Re extends B{static _dilutes=!0;constructor(t){super();this.shape=t}check(t,e){let r=$t(this.shape,(s)=>s.check(t,e));return e?.extend(null,"Union",typeof t),r}}var Ut=(...t)=>t.findIndex((e)=>Ce.check(e))>=0?Ut(...t.map((e)=>Xt(e)).map((e)=>Ce.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new Re(t),Ce=S(Re),ns=()=>!0,De=E(ns),ko=S(Oe,(t)=>t.shape===ns),jn=E((t)=>typeof t==="bigint"),_o=E((t)=>t===jn),ss=E((t)=>typeof t==="symbol"),wl=E((t)=>t===ss),Et=E((t)=>typeof t==="number"),cs=E((t)=>t===Et),It=E((t)=>typeof t==="string"),ls=E((t)=>t===It),Le=E((t)=>typeof t==="boolean"),So=E((t)=>t===Le),as=ve(void 0),xl=S(Qt,(t)=>t.shape.length===1&&t.shape[0]===void 0),yl=ve(void 0);var Ve=ve(null),Eo=S(Qt,(t)=>t.shape.length===1&&t.shape[0]===null),bl=S(Uint8Array),kl=S(Be,(t)=>t.shape===Uint8Array),Io=Ut(Et,It,Ve,as,jn,Le,ss),_l=(()=>{let t=Yr(De),e=Qr(It,De),r=Ut(Et,It,Ve,Le,t,e);return t.shape=r,e.shape.values=r,r})(),Xt=(t)=>{if(xo.check(t))return t;else if(uo.check(t)){let e={};for(let r in t)e[r]=Xt(t[r]);return ao(e)}else if(mo.check(t))return Ut(...t.map(Xt));else if(Io.check(t))return ve(t);else if(bo.check(t))return S(t);v()},Pr=qr?()=>{}:(t,e)=>{let r=new Kr;if(!e.check(t,r))throw R(`Expected value to be of type ${e.constructor.name}.
3
- ${r.toString()}`)};class hs{constructor(t){this.patterns=[],this.$state=t}if(t,e){return this.patterns.push({if:Xt(t),h:e}),this}else(t){return this.if(De,t)}done(){return(t,e)=>{for(let r=0;r<this.patterns.length;r++){let s=this.patterns[r];if(s.if.check(t))return s.h(t,e)}throw R("Unhandled pattern")}}}var Uo=(t)=>new hs(t),us=Uo(De).if(cs,(t,e)=>Te(e,hn,ft)).if(ls,(t,e)=>Jr(e)).if(So,(t,e)=>Bn(e)).if(_o,(t,e)=>BigInt(Te(e,hn,ft))).if(Ce,(t,e)=>St(e,Ae(e,t.shape))).if(ho,(t,e)=>{let r={};for(let s in t.shape){let i=t.shape[s];if(lo.check(i)){if(Bn(e))continue;i=i.shape}r[s]=us(i,e)}return r}).if(go,(t,e)=>{let r=[],s=On(e,0,42);for(let i=0;i<s;i++)r.push(St(e,t.shape));return r}).if(Wr,(t,e)=>Ae(e,t.shape)).if(Eo,(t,e)=>null).if(yo,(t,e)=>{let r=St(e,t.res);return()=>r}).if(ko,(t,e)=>St(e,Ae(e,[Et,It,Ve,as,jn,Le,Yr(Et),Qr(Ut("a","b","c"),Et)]))).if(fo,(t,e)=>{let r={},s=Te(e,0,3);for(let i=0;i<s;i++){let o=St(e,t.shape.keys),c=St(e,t.shape.values);r[o]=c}return r}).done(),St=(t,e)=>us(Xt(e),t);var it=typeof document<"u"?document:{};var Sl=E((t)=>t.nodeType===Bo);var El=typeof DOMParser<"u"?new DOMParser:null;var Il=E((t)=>t.nodeType===Ao);var Ul=E((t)=>t.nodeType===Co);var ds=(t)=>Tr(t,(e,r)=>`${r}:${e};`).join("");var{ELEMENT_NODE:Ao,TEXT_NODE:Co,CDATA_SECTION_NODE:Tl,COMMENT_NODE:Al,DOCUMENT_NODE:Do,DOCUMENT_TYPE_NODE:Cl,DOCUMENT_FRAGMENT_NODE:Bo}=it,Dl=E((t)=>t.nodeType===Do);var J=Symbol;var Yt=J(),te=J(),qn=J(),Gn=J(),zn=J(),ee=J(),Hn=J(),Tt=J(),Jn=J(),fs=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],r=[],s=0;for(;s<t.length;s++){let i=t[s];if(i===void 0)break;else if(i.constructor===String||i.constructor===Number)e.push(i);else if(i.constructor===Object)break}if(s>0)r.push(e.join(""));for(;s<t.length;s++){let i=t[s];if(!(i instanceof Symbol))r.push(i)}return r};var Bl=$u();var Ro={[Yt]:H("font-weight","bold"),[te]:H("font-weight","normal"),[qn]:H("color","blue"),[zn]:H("color","green"),[Gn]:H("color","grey"),[ee]:H("color","red"),[Hn]:H("color","purple"),[Tt]:H("color","orange"),[Jn]:H("color","black")},Lo=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],r=[],s=A(),i=[],o=0;for(;o<t.length;o++){let c=t[o],l=Ro[c];if(l!==void 0)s.set(l.left,l.right);else{if(c===void 0)break;if(c.constructor===String||c.constructor===Number){let h=ds(s);if(o>0||h.length>0)e.push("%c"+c),r.push(h);else e.push(c)}else break}}if(o>0)i=r,i.unshift(e.join(""));for(;o<t.length;o++){let c=t[o];if(!(c instanceof Symbol))i.push(c)}return i},ps=Gr?Lo:fs,gs=(...t)=>{console.log(...ps(t)),ms.forEach((e)=>e.print(t))},Pn=(...t)=>{console.warn(...ps(t)),t.unshift(Tt),ms.forEach((e)=>e.print(t))};var ms=G();var ws=(t)=>({[Symbol.iterator](){return this},next:t}),xs=(t,e)=>ws(()=>{let r;do r=t.next();while(!r.done&&!e(r.value));return r}),Me=(t,e)=>ws(()=>{let{done:r,value:s}=t.next();return{done:r,value:r?void 0:e(s)}});class oe{constructor(t,e){this.clock=t,this.len=e}}class ht{constructor(){this.clients=new Map}}var Bt=(t,e,r)=>e.clients.forEach((s,i)=>{let o=t.doc.store.clients.get(i);if(o!=null){let c=o[o.length-1],l=c.id.clock+c.length;for(let h=0,f=s[h];h<s.length&&f.clock<l;f=s[++h])Js(t,o,f.clock,f.len,r)}}),$o=(t,e)=>{let r=0,s=t.length-1;while(r<=s){let i=is((r+s)/2),o=t[i],c=o.clock;if(c<=e){if(e<c+o.len)return i;r=i+1}else s=i-1}return null},ce=(t,e)=>{let r=t.clients.get(e.client);return r!==void 0&&$o(r,e.clock)!==null},Yn=(t)=>{t.clients.forEach((e)=>{e.sort((i,o)=>i.clock-o.clock);let r,s;for(r=1,s=1;r<e.length;r++){let i=e[s-1],o=e[r];if(i.clock+i.len>=o.clock)e[s-1]=new oe(i.clock,Z(i.len,o.clock+o.len-i.clock));else{if(s<r)e[s]=o;s++}}e.length=s})},Wn=(t)=>{let e=new ht;for(let r=0;r<t.length;r++)t[r].clients.forEach((s,i)=>{if(!e.clients.has(i)){let o=s.slice();for(let c=r+1;c<t.length;c++)gr(o,t[c].clients.get(i)||[]);e.clients.set(i,o)}});return Yn(e),e},ne=(t,e,r,s)=>{q(t.clients,e,()=>[]).push(new oe(r,s))},vs=()=>new ht,Fo=(t)=>{let e=vs();return t.clients.forEach((r,s)=>{let i=[];for(let o=0;o<r.length;o++){let c=r[o];if(c.deleted){let l=c.id.clock,h=c.length;if(o+1<r.length)for(let f=r[o+1];o+1<r.length&&f.deleted;f=r[++o+1])h+=f.length;i.push(new oe(l,h))}}if(i.length>0)e.clients.set(s,i)}),e},vt=(t,e)=>{_t(t.restEncoder,e.clients.size),j(e.clients.entries()).sort((r,s)=>s[0]-r[0]).forEach(([r,s])=>{t.resetDsCurVal(),_t(t.restEncoder,r);let i=s.length;_t(t.restEncoder,i);for(let o=0;o<i;o++){let c=s[o];t.writeDsClock(c.clock),t.writeDsLen(c.len)}})},tr=(t)=>{let e=new ht,r=Dt(t.restDecoder);for(let s=0;s<r;s++){t.resetDsCurVal();let i=Dt(t.restDecoder),o=Dt(t.restDecoder);if(o>0){let c=q(e.clients,i,()=>[]);for(let l=0;l<o;l++)c.push(new oe(t.readDsClock(),t.readDsLen()))}}return e},ys=(t,e,r)=>{let s=new ht,i=Dt(t.restDecoder);for(let o=0;o<i;o++){t.resetDsCurVal();let c=Dt(t.restDecoder),l=Dt(t.restDecoder),h=r.clients.get(c)||[],f=b(r,c);for(let a=0;a<l;a++){let u=t.readDsClock(),d=u+t.readDsLen();if(u<f){if(f<d)ne(s,c,f,d-f);let p=P(h,u),g=h[p];if(!g.deleted&&g.id.clock<u)h.splice(p+1,0,Ye(e,g,u-g.id.clock)),p++;while(p<h.length)if(g=h[p++],g.id.clock<d){if(!g.deleted){if(d<g.id.clock+g.length)h.splice(p,0,Ye(e,g,d-g.id.clock));g.delete(e)}}else break}else ne(s,c,u,d-u)}}if(s.clients.size>0){let o=new et;return _t(o.restEncoder,0),vt(o,s),o.toUint8Array()}return null};var Ns=kn;class Td extends Ie{constructor({guid:t=Dr(),collectionid:e=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:c=!0}={}){super();this.gc=r,this.gcFilter=s,this.clientID=Ns(),this.guid=t,this.collectionid=e,this.share=new Map,this.store=new or,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=_n((h)=>{this.on("load",()=>{this.isLoaded=!0,h(this)})});let l=()=>_n((h)=>{let f=(a)=>{if(a===void 0||a===!0)this.off("sync",f),h()};this.on("sync",f)});this.on("sync",(h)=>{if(h===!1&&this.isSynced)this.whenSynced=l();if(this.isSynced=h===void 0||h===!0,this.isSynced&&!this.isLoaded)this.emit("load",[this])}),this.whenSynced=l()}load(){let t=this._item;if(t!==null&&!this.shouldLoad)x(t.parent.doc,(e)=>{e.subdocsLoaded.add(this)},null,!0);this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(j(this.subdocs).map((t)=>t.guid))}transact(t,e=null){return x(this,t,e)}get(t,e=I){let r=q(this.share,t,()=>{let i=new e;return i._integrate(this,null),i}),s=r.constructor;if(e!==I&&s!==e)if(s===I){let i=new e;i._map=r._map,r._map.forEach((o)=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(t,i),i._integrate(this,null),i}else throw Error(`Type with the name ${t} has already been defined with a different constructor`);return r}getArray(t=""){return this.get(t,xa)}getText(t=""){return this.get(t,rs)}getMap(t=""){return this.get(t,os)}getXmlElement(t=""){return this.get(t,Ot)}getXmlFragment(t=""){return this.get(t,lt)}toJSON(){let t={};return this.share.forEach((e,r)=>{t[r]=e.toJSON()}),t}destroy(){this.isDestroyed=!0,j(this.subdocs).forEach((e)=>e.destroy());let t=this._item;if(t!==null){this._item=null;let e=t.content;e.doc=new Td({guid:this.guid,...e.opts,shouldLoad:!1}),e.doc._item=t,x(t.parent.doc,(r)=>{let s=e.doc;if(!t.deleted)r.subdocsAdded.add(s);r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class er{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return Dt(this.restDecoder)}readDsLen(){return Dt(this.restDecoder)}}class nr extends er{readLeftID(){return m(Dt(this.restDecoder),Dt(this.restDecoder))}readRightID(){return m(Dt(this.restDecoder),Dt(this.restDecoder))}readClient(){return Dt(this.restDecoder)}readInfo(){return rt(this.restDecoder)}readString(){return nl(this.restDecoder)}readParentInfo(){return Dt(this.restDecoder)===1}readTypeRef(){return Dt(this.restDecoder)}readLen(){return Dt(this.restDecoder)}readAny(){return yt(this.restDecoder)}readBuf(){return zr(Xo(this.restDecoder))}readJSON(){return JSON.parse(nl(this.restDecoder))}readKey(){return nl(this.restDecoder)}}class Rs{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Dt(this.restDecoder),this.dsCurrVal}readDsLen(){let t=Dt(this.restDecoder)+1;return this.dsCurrVal+=t,t}}class ct extends Rs{constructor(t){super(t);this.keys=[],Dt(t),this.keyClockDecoder=new zt(Xo(t)),this.clientDecoder=new bt(Xo(t)),this.leftClockDecoder=new zt(Xo(t)),this.rightClockDecoder=new zt(Xo(t)),this.infoDecoder=new Se(Xo(t),rt),this.stringDecoder=new bn(Xo(t)),this.parentInfoDecoder=new Se(Xo(t),rt),this.typeRefDecoder=new bt(Xo(t)),this.lenDecoder=new bt(Xo(t))}readLeftID(){return new ot(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ot(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return yt(this.restDecoder)}readBuf(){return Xo(this.restDecoder)}readJSON(){return yt(this.restDecoder)}readKey(){let t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];else{let e=this.stringDecoder.read();return this.keys.push(e),e}}}class rr{constructor(){this.restEncoder=Qa()}toUint8Array(){return br(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){_t(this.restEncoder,t)}writeDsLen(t){_t(this.restEncoder,t)}}class Nt extends rr{writeLeftID(t){_t(this.restEncoder,t.client),_t(this.restEncoder,t.clock)}writeRightID(t){_t(this.restEncoder,t.client),_t(this.restEncoder,t.clock)}writeClient(t){_t(this.restEncoder,t)}writeInfo(t){xe(this.restEncoder,t)}writeString(t){el(this.restEncoder,t)}writeParentInfo(t){_t(this.restEncoder,t?1:0)}writeTypeRef(t){_t(this.restEncoder,t)}writeLen(t){_t(this.restEncoder,t)}writeAny(t){mt(this.restEncoder,t)}writeBuf(t){zo(this.restEncoder,t)}writeJSON(t){el(this.restEncoder,JSON.stringify(t))}writeKey(t){el(this.restEncoder,t)}}class sr{constructor(){this.restEncoder=Qa(),this.dsCurrVal=0}toUint8Array(){return br(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let e=t-this.dsCurrVal;this.dsCurrVal=t,_t(this.restEncoder,e)}writeDsLen(t){if(t===0)v();_t(this.restEncoder,t-1),this.dsCurrVal+=t}}class et extends sr{constructor(){super();this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new qt,this.clientEncoder=new xt,this.leftClockEncoder=new qt,this.rightClockEncoder=new qt,this.infoEncoder=new be(xe),this.stringEncoder=new wn,this.parentInfoEncoder=new be(xe),this.typeRefEncoder=new xt,this.lenEncoder=new xt}toUint8Array(){let t=Qa();return _t(t,0),zo(t,this.keyClockEncoder.toUint8Array()),zo(t,this.clientEncoder.toUint8Array()),zo(t,this.leftClockEncoder.toUint8Array()),zo(t,this.rightClockEncoder.toUint8Array()),zo(t,br(this.infoEncoder)),zo(t,this.stringEncoder.toUint8Array()),zo(t,br(this.parentInfoEncoder)),zo(t,this.typeRefEncoder.toUint8Array()),zo(t,this.lenEncoder.toUint8Array()),jt(t,br(this.restEncoder)),br(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){mt(this.restEncoder,t)}writeBuf(t){zo(this.restEncoder,t)}writeJSON(t){mt(this.restEncoder,t)}writeKey(t){let e=this.keyMap.get(t);if(e===void 0)this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t);else this.keyClockEncoder.write(e)}}var jo=(t,e,r,s)=>{s=Z(s,e[0].id.clock);let i=P(e,s);_t(t.restEncoder,e.length-i),t.writeClient(r),_t(t.restEncoder,s);let o=e[i];o.write(t,s-o.id.clock);for(let c=i+1;c<e.length;c++)e[c].write(t,0)},ir=(t,e,r)=>{let s=new Map;r.forEach((i,o)=>{if(b(e,o)>i)s.set(o,i)}),tn(e).forEach((i,o)=>{if(!r.has(o))s.set(o,0)}),_t(t.restEncoder,s.size),j(s.entries()).sort((i,o)=>o[0]-i[0]).forEach(([i,o])=>{jo(t,e.clients.get(i),i,o)})},qo=(t,e)=>{let r=A(),s=Dt(t.restDecoder);for(let i=0;i<s;i++){let o=Dt(t.restDecoder),c=Array(o),l=t.readClient(),h=Dt(t.restDecoder);r.set(l,{i:0,refs:c});for(let f=0;f<o;f++){let a=t.readInfo();switch(Vt&a){case 0:{let u=t.readLen();c[f]=new V(m(l,h),u),h+=u;break}case 10:{let u=Dt(t.restDecoder);c[f]=new M(m(l,h),u),h+=u;break}default:{let u=(a&(F|D))===0,d=new y(m(l,h),null,(a&D)===D?t.readLeftID():null,null,(a&F)===F?t.readRightID():null,u?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,u&&(a&dt)===dt?t.readString():null,mi(t,a));c[f]=d,h+=d.length}}}}return r},Go=(t,e,r)=>{let s=[],i=j(r.keys()).sort((p,g)=>p-g);if(i.length===0)return null;let o=()=>{if(i.length===0)return null;let p=r.get(i[i.length-1]);while(p.refs.length===p.i)if(i.pop(),i.length>0)p=r.get(i[i.length-1]);else return null;return p},c=o();if(c===null)return null;let l=new or,h=new Map,f=(p,g)=>{let w=h.get(p);if(w==null||w>g)h.set(p,g)},a=c.refs[c.i++],u=new Map,d=()=>{for(let p of s){let g=p.id.client,w=r.get(g);if(w)w.i--,l.clients.set(g,w.refs.slice(w.i)),r.delete(g),w.i=0,w.refs=[];else l.clients.set(g,[p]);i=i.filter((C)=>C!==g)}s.length=0};while(!0){if(a.constructor!==M){let g=q(u,a.id.client,()=>b(e,a.id.client))-a.id.clock;if(g<0)s.push(a),f(a.id.client,a.id.clock-1),d();else{let w=a.getMissing(t,e);if(w!==null){s.push(a);let C=r.get(w)||{refs:[],i:0};if(C.refs.length===C.i)f(w,b(e,w)),d();else{a=C.refs[C.i++];continue}}else if(g===0||g<a.length)a.integrate(t,g),u.set(a.id.client,a.id.clock+a.length)}}if(s.length>0)a=s.pop();else if(c!==null&&c.i<c.refs.length)a=c.refs[c.i++];else if(c=o(),c===null)break;else a=c.refs[c.i++]}if(l.clients.size>0){let p=new et;return ir(p,l,new Map),_t(p.restEncoder,0),{missing:h,update:p.toUint8Array()}}return null},Ho=(t,e)=>ir(t,e.doc.store,e.beforeState),Jo=(t,e,r,s=new ct(t))=>x(e,(i)=>{i.local=!1;let o=!1,c=i.doc,l=c.store,h=qo(s,c),f=Go(i,l,h),a=l.pendingStructs;if(a){for(let[d,p]of a.missing)if(p<b(l,d)){o=!0;break}if(f){for(let[d,p]of f.missing){let g=a.missing.get(d);if(g==null||g>p)a.missing.set(d,p)}a.update=Je([a.update,f.update])}}else l.pendingStructs=f;let u=ys(s,i,l);if(l.pendingDs){let d=new ct(tl(l.pendingDs));Dt(d.restDecoder);let p=ys(d,i,l);if(u&&p)l.pendingDs=Je([u,p]);else l.pendingDs=u||p}else l.pendingDs=u;if(o){let d=l.pendingStructs.update;l.pendingStructs=null,Ls(i.doc,d)}},r,!1);var Ls=(t,e,r,s=ct)=>{let i=tl(e);Jo(i,t,r,new s(i))},WR=(t,e,r)=>Ls(t,e,r,nr),Po=(t,e,r=new Map)=>{ir(t,e.store,r),vt(t,Fo(e.store))},Ko=(t,e=new Uint8Array([0]),r=new et)=>{let s=Vs(e);Po(r,t,s);let i=[r.toUint8Array()];if(t.store.pendingDs)i.push(t.store.pendingDs);if(t.store.pendingStructs)i.push(ac(t.store.pendingStructs.update,e));if(i.length>1){if(r.constructor===Nt)return cc(i.map((o,c)=>c===0?o:uc(o)));else if(r.constructor===et)return Je(i)}return i[0]},VR=(t,e)=>Ko(t,e,new Nt),Wo=(t)=>{let e=new Map,r=Dt(t.restDecoder);for(let s=0;s<r;s++){let i=Dt(t.restDecoder),o=Dt(t.restDecoder);e.set(i,o)}return e},Vs=(t)=>Wo(new er(tl(t))),Ms=(t,e)=>(_t(t.restEncoder,e.size),j(e.entries()).sort((r,s)=>s[0]-r[0]).forEach(([r,s])=>{_t(t.restEncoder,r),_t(t.restEncoder,s)}),t),Zo=(t,e)=>Ms(t,tn(e.store)),Qo=(t,e=new sr)=>{if(t instanceof Map)Ms(e,t);else Zo(e,t);return e.toUint8Array()},UR=(t)=>Qo(t,new rr);class $s{constructor(){this.l=[]}}var bs=()=>new $s,ks=(t,e)=>t.l.push(e),_s=(t,e)=>{let r=t.l,s=r.length;if(t.l=r.filter((i)=>e!==i),s===t.l.length)console.error("[yjs] Tried to remove event handler that doesn't exist.")},Fs=(t,e,r)=>Kt(t.l,[e,r]);class ot{constructor(t,e){this.client=t,this.clock=e}}var $e=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,m=(t,e)=>new ot(t,e);var js=(t)=>{for(let[e,r]of t.doc.share.entries())if(r===t)return e;throw v()},He=(t,e)=>{while(e!==null){if(e.parent===t)return!0;e=e.parent._item}return!1};class qs{constructor(t,e,r,s=0){this.type=t,this.tname=e,this.item=r,this.assoc=s}}class Gs{constructor(t,e,r=0){this.type=t,this.index=e,this.assoc=r}}var Yo=(t,e,r=0)=>new Gs(t,e,r),Fe=(t,e,r)=>{let s=null,i=null;if(t._item===null)i=js(t);else s=m(t._item.id.client,t._item.id.clock);return new qs(s,i,e,r)},T_=(t,e,r=0)=>{let s=t._start;if(r<0){if(e===0)return Fe(t,null,r);e--}while(s!==null){if(!s.deleted&&s.countable){if(s.length>e)return Fe(t,m(s.id.client,s.id.clock+e),r);e-=s.length}if(s.right===null&&r<0)return Fe(t,s.lastId,r);s=s.right}return Fe(t,null,r)};var tc=(t,e)=>{let r=Ct(t,e),s=e.clock-r.id.clock;return{item:r,diff:s}},Qg=(t,e,r=!0)=>{let s=e.store,{item:i,type:o,tname:c,assoc:l}=t,h=null,f=0;if(i!==null){if(b(s,i.client)<=i.clock)return null;let a=r?Qn(s,i):tc(s,i),u=a.item;if(!(u instanceof y))return null;if(h=u.parent,h._item===null||!h._item.deleted){f=u.deleted||!u.countable?0:a.diff+(l>=0?0:1);let d=u.left;while(d!==null){if(!d.deleted&&d.countable)f+=d.length;d=d.left}}}else{if(c!==null)h=e.get(c);else if(o!==null){if(b(s,o.client)<=o.clock)return null;let{item:a}=r?Qn(s,o):{item:Ct(s,o)};if(a instanceof y&&a.content instanceof W)h=a.content.type;else return null}else throw v();if(l>=0)f=h._length;else f=0}return Yo(h,f,t.assoc)};class zs{constructor(t,e){this.ds=t,this.sv=e}}var ec=(t,e)=>new zs(t,e),ql=ec(vs(),new Map);var At=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!ce(e.ds,t.id),Zn=(t,e)=>{let r=q(t.meta,Zn,G),s=t.doc.store;if(!r.has(e))e.sv.forEach((i,o)=>{if(i<b(s,o))N(t,m(o,i))}),Bt(t,e.ds,(i)=>{}),r.add(e)};class or{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}var tn=(t)=>{let e=new Map;return t.clients.forEach((r,s)=>{let i=r[r.length-1];e.set(s,i.id.clock+i.length)}),e},b=(t,e)=>{let r=t.clients.get(e);if(r===void 0)return 0;let s=r[r.length-1];return s.id.clock+s.length},Hs=(t,e)=>{let r=t.clients.get(e.id.client);if(r===void 0)r=[],t.clients.set(e.id.client,r);else{let s=r[r.length-1];if(s.id.clock+s.length!==e.id.clock)throw v()}r.push(e)},P=(t,e)=>{let r=0,s=t.length-1,i=t[s],o=i.id.clock;if(o===e)return s;let c=is(e/(o+i.length-1)*s);while(r<=s){if(i=t[c],o=i.id.clock,o<=e){if(e<o+i.length)return c;r=c+1}else s=c-1;c=is((r+s)/2)}throw v()},nc=(t,e)=>{let r=t.clients.get(e.client);return r[P(r,e.clock)]},Ct=nc,Xn=(t,e,r)=>{let s=P(e,r),i=e[s];if(i.id.clock<r&&i instanceof y)return e.splice(s+1,0,Ye(t,i,r-i.id.clock)),s+1;return s},N=(t,e)=>{let r=t.doc.store.clients.get(e.client);return r[Xn(t,r,e.clock)]},Ss=(t,e,r)=>{let s=e.clients.get(r.client),i=P(s,r.clock),o=s[i];if(r.clock!==o.id.clock+o.length-1&&o.constructor!==V)s.splice(i+1,0,Ye(t,o,r.clock-o.id.clock+1));return o},rc=(t,e,r)=>{let s=t.clients.get(e.id.client);s[P(s,e.id.clock)]=r},Js=(t,e,r,s,i)=>{if(s===0)return;let o=r+s,c=Xn(t,e,r),l;do{if(l=e[c++],o<l.id.clock+l.length)Xn(t,e,o);i(l)}while(c<e.length&&e[c].id.clock<o)};class Ps{constructor(t,e,r){this.doc=t,this.deleteSet=new ht,this.beforeState=tn(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=e,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}var Es=(t,e)=>{if(e.deleteSet.clients.size===0&&!Ar(e.afterState,(r,s)=>e.beforeState.get(s)!==r))return!1;return Yn(e.deleteSet),Ho(t,e),vt(t,e.deleteSet),!0},Is=(t,e,r)=>{let s=e._item;if(s===null||s.id.clock<(t.beforeState.get(s.id.client)||0)&&!s.deleted)q(t.changed,e,G).add(r)},Ge=(t,e)=>{let r=t[e],s=t[e-1],i=e;for(;i>0;r=s,s=t[--i-1]){if(s.deleted===r.deleted&&s.constructor===r.constructor){if(s.mergeWith(r)){if(r instanceof y&&r.parentSub!==null&&r.parent._map.get(r.parentSub)===r)r.parent._map.set(r.parentSub,s);continue}}break}let o=e-i;if(o)t.splice(e+1-o,o);return o},sc=(t,e,r)=>{for(let[s,i]of t.clients.entries()){let o=e.clients.get(s);for(let c=i.length-1;c>=0;c--){let l=i[c],h=l.clock+l.len;for(let f=P(o,l.clock),a=o[f];f<o.length&&a.id.clock<h;a=o[++f]){let u=o[f];if(l.clock+l.len<=u.id.clock)break;if(u instanceof y&&u.deleted&&!u.keep&&r(u))u.gc(e,!1)}}}},ic=(t,e)=>{t.clients.forEach((r,s)=>{let i=e.clients.get(s);for(let o=r.length-1;o>=0;o--){let c=r[o],l=ue(i.length-1,1+P(i,c.clock+c.len-1));for(let h=l,f=i[h];h>0&&f.id.clock>=c.clock;f=i[h])h-=1+Ge(i,h)}})};var Ks=(t,e)=>{if(e<t.length){let r=t[e],s=r.doc,i=s.store,{deleteSet:o,_mergeStructs:c}=r;try{Yn(o),r.afterState=tn(r.doc.store),s.emit("beforeObserverCalls",[r,s]);let l=[];r.changed.forEach((h,f)=>l.push(()=>{if(f._item===null||!f._item.deleted)f._callObserver(r,h)})),l.push(()=>{r.changedParentTypes.forEach((h,f)=>{if(f._dEH.l.length>0&&(f._item===null||!f._item.deleted))l.push(()=>{h=h.filter((a)=>a.target._item===null||!a.target._item.deleted),h.forEach((a)=>{a.currentTarget=f,a._path=null}),h.sort((a,u)=>a.path.length-u.path.length),Fs(f._dEH,h,r)})}),l.push(()=>s.emit("afterTransaction",[r,s])),l.push(()=>{if(r._needFormattingCleanup)_c(r)})}),Kt(l,[])}finally{if(s.gc)sc(o,i,s.gcFilter);ic(o,i),r.afterState.forEach((a,u)=>{let d=r.beforeState.get(u)||0;if(d!==a){let p=i.clients.get(u),g=Z(P(p,d),1);for(let w=p.length-1;w>=g;)w-=1+Ge(p,w)}});for(let a=c.length-1;a>=0;a--){let{client:u,clock:d}=c[a].id,p=i.clients.get(u),g=P(p,d);if(g+1<p.length){if(Ge(p,g+1)>1)continue}if(g>0)Ge(p,g)}if(!r.local&&r.afterState.get(s.clientID)!==r.beforeState.get(s.clientID))gs(Tt,Yt,"[yjs] ",te,ee,"Changed the client-id because another client seems to be using it."),s.clientID=Ns();if(s.emit("afterTransactionCleanup",[r,s]),s._observers.has("update")){let a=new Nt;if(Es(a,r))s.emit("update",[a.toUint8Array(),r.origin,s,r])}if(s._observers.has("updateV2")){let a=new et;if(Es(a,r))s.emit("updateV2",[a.toUint8Array(),r.origin,s,r])}let{subdocsAdded:l,subdocsLoaded:h,subdocsRemoved:f}=r;if(l.size>0||f.size>0||h.size>0)l.forEach((a)=>{if(a.clientID=s.clientID,a.collectionid==null)a.collectionid=s.collectionid;s.subdocs.add(a)}),f.forEach((a)=>s.subdocs.delete(a)),s.emit("subdocs",[{loaded:h,added:l,removed:f},s,r]),f.forEach((a)=>a.destroy());if(t.length<=e+1)s._transactionCleanups=[],s.emit("afterAllTransactions",[s,t]);else Ks(t,e+1)}}},x=(t,e,r=null,s=!0)=>{let i=t._transactionCleanups,o=!1,c=null;if(t._transaction===null){if(o=!0,t._transaction=new Ps(t,r,s),i.push(t._transaction),i.length===1)t.emit("beforeAllTransactions",[t]);t.emit("beforeTransaction",[t._transaction,t])}try{c=e(t._transaction)}finally{if(o){let l=t._transaction===i[0];if(t._transaction=null,l)Ks(i,0)}}return c};class Ws{constructor(t,e){this.insertions=e,this.deletions=t,this.meta=new Map}}var Us=(t,e,r)=>{Bt(t,r.deletions,(s)=>{if(s instanceof y&&e.scope.some((i)=>i===t.doc||He(i,s)))ur(s,!1)})},Ts=(t,e,r)=>{let s=null,{doc:i,scope:o}=t;x(i,(l)=>{while(e.length>0&&t.currStackItem===null){let h=i.store,f=e.pop(),a=new Set,u=[],d=!1;Bt(l,f.insertions,(p)=>{if(p instanceof y){if(p.redone!==null){let{item:g,diff:w}=Qn(h,p.id);if(w>0)g=N(l,m(g.id.client,g.id.clock+w));p=g}if(!p.deleted&&o.some((g)=>g===l.doc||He(g,p)))u.push(p)}}),Bt(l,f.deletions,(p)=>{if(p instanceof y&&o.some((g)=>g===l.doc||He(g,p))&&!ce(f.insertions,p.id))a.add(p)}),a.forEach((p)=>{d=gi(l,p,a,f.insertions,t.ignoreRemoteMapChanges,t)!==null||d});for(let p=u.length-1;p>=0;p--){let g=u[p];if(t.deleteFilter(g))g.delete(l),d=!0}t.currStackItem=d?f:null}l.changed.forEach((h,f)=>{if(h.has(null)&&f._searchMarker)f._searchMarker.length=0}),s=l},t);let c=t.currStackItem;if(c!=null){let l=s.changedParentTypes;t.emit("stack-item-popped",[{stackItem:c,type:r,changedParentTypes:l,origin:t},t]),t.currStackItem=null}return c};class PP extends Ie{constructor(t,{captureTimeout:e=500,captureTransaction:r=(l)=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:c=Q(t)?t[0].doc:t instanceof Td?t:t.doc}={}){super();this.scope=[],this.doc=c,this.addToScope(t),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=e,this.afterTransactionHandler=(l)=>{if(!this.captureTransaction(l)||!this.scope.some((w)=>l.changedParentTypes.has(w)||w===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;let h=this.undoing,f=this.redoing,a=h?this.redoStack:this.undoStack;if(h)this.stopCapturing();else if(!f)this.clear(!1,!0);let u=new ht;l.afterState.forEach((w,C)=>{let k=l.beforeState.get(C)||0,dr=w-k;if(dr>0)ne(u,C,k,dr)});let d=$u(),p=!1;if(this.lastChange>0&&d-this.lastChange<this.captureTimeout&&a.length>0&&!h&&!f){let w=a[a.length-1];w.deletions=Wn([w.deletions,l.deleteSet]),w.insertions=Wn([w.insertions,u])}else a.push(new Ws(l.deleteSet,u)),p=!0;if(!h&&!f)this.lastChange=d;Bt(l,l.deleteSet,(w)=>{if(w instanceof y&&this.scope.some((C)=>C===l.doc||He(C,w)))ur(w,!0)});let g=[{stackItem:a[a.length-1],origin:l.origin,type:h?"redo":"undo",changedParentTypes:l.changedParentTypes},this];if(p)this.emit("stack-item-added",g);else this.emit("stack-item-updated",g)},this.destroy=this.destroy.bind(this),this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",this.destroy)}addToScope(t){let e=new Set(this.scope);t=Q(t)?t:[t],t.forEach((r)=>{if(!e.has(r)){if(e.add(r),r instanceof I?r.doc!==this.doc:r!==this.doc)Pn("[yjs#509] Not same Y.Doc");this.scope.push(r)}})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,e=!0){if(t&&this.canUndo()||e&&this.canRedo())this.doc.transact((r)=>{if(t)this.undoStack.forEach((s)=>Us(r,this,s)),this.undoStack=[];if(e)this.redoStack.forEach((s)=>Us(r,this,s)),this.redoStack=[];this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:e}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=Ts(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=Ts(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),this.doc.off("destroy",this.destroy),super.destroy()}}function*oc(t){let e=Dt(t.restDecoder);for(let r=0;r<e;r++){let s=Dt(t.restDecoder),i=t.readClient(),o=Dt(t.restDecoder);for(let c=0;c<s;c++){let l=t.readInfo();if(l===10){let h=Dt(t.restDecoder);yield new M(m(i,o),h),o+=h}else if((Vt&l)!==0){let h=(l&(F|D))===0,f=new y(m(i,o),null,(l&D)===D?t.readLeftID():null,null,(l&F)===F?t.readRightID():null,h?t.readParentInfo()?t.readString():t.readLeftID():null,h&&(l&dt)===dt?t.readString():null,mi(t,l));yield f,o+=f.length}else{let h=t.readLen();yield new V(m(i,o),h),o+=h}}}}class en{constructor(t,e){this.gen=oc(t),this.curr=null,this.done=!1,this.filterSkips=e,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===M);return this.curr}}class nn{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}var cc=(t)=>Je(t,nr,Nt);var lc=(t,e)=>{if(t.constructor===V){let{client:r,clock:s}=t.id;return new V(m(r,s+e),t.length-e)}else if(t.constructor===M){let{client:r,clock:s}=t.id;return new M(m(r,s+e),t.length-e)}else{let r=t,{client:s,clock:i}=r.id;return new y(m(s,i+e),null,m(s,i+e-1),null,r.rightOrigin,r.parent,r.parentSub,r.content.splice(e))}},Je=(t,e=ct,r=et)=>{if(t.length===1)return t[0];let s=t.map((a)=>new e(tl(a))),i=s.map((a)=>new en(a,!0)),o=null,c=new r,l=new nn(c);while(!0){if(i=i.filter((d)=>d.curr!==null),i.sort((d,p)=>{if(d.curr.id.client===p.curr.id.client){let g=d.curr.id.clock-p.curr.id.clock;if(g===0)return d.curr.constructor===p.curr.constructor?0:d.curr.constructor===M?1:-1;else return g}else return p.curr.id.client-d.curr.id.client}),i.length===0)break;let a=i[0],u=a.curr.id.client;if(o!==null){let d=a.curr,p=!1;while(d!==null&&d.id.clock+d.length<=o.struct.id.clock+o.struct.length&&d.id.client>=o.struct.id.client)d=a.next(),p=!0;if(d===null||d.id.client!==u||p&&d.id.clock>o.struct.id.clock+o.struct.length)continue;if(u!==o.struct.id.client)Y(l,o.struct,o.offset),o={struct:d,offset:0},a.next();else if(o.struct.id.clock+o.struct.length<d.id.clock)if(o.struct.constructor===M)o.struct.length=d.id.clock+d.length-o.struct.id.clock;else{Y(l,o.struct,o.offset);let g=d.id.clock-o.struct.id.clock-o.struct.length;o={struct:new M(m(u,o.struct.id.clock+o.struct.length),g),offset:0}}else{let g=o.struct.id.clock+o.struct.length-d.id.clock;if(g>0)if(o.struct.constructor===M)o.struct.length-=g;else d=lc(d,g);if(!o.struct.mergeWith(d))Y(l,o.struct,o.offset),o={struct:d,offset:0},a.next()}}else o={struct:a.curr,offset:0},a.next();for(let d=a.curr;d!==null&&d.id.client===u&&d.id.clock===o.struct.id.clock+o.struct.length&&d.constructor!==M;d=a.next())Y(l,o.struct,o.offset),o={struct:d,offset:0}}if(o!==null)Y(l,o.struct,o.offset),o=null;cr(l);let h=s.map((a)=>tr(a)),f=Wn(h);return vt(c,f),c.toUint8Array()},ac=(t,e,r=ct,s=et)=>{let i=Vs(e),o=new s,c=new nn(o),l=new r(tl(t)),h=new en(l,!1);while(h.curr){let a=h.curr,u=a.id.client,d=i.get(u)||0;if(h.curr.constructor===M){h.next();continue}if(a.id.clock+a.length>d){Y(c,a,Z(d-a.id.clock,0)),h.next();while(h.curr&&h.curr.id.client===u)Y(c,h.curr,0),h.next()}else while(h.curr&&h.curr.id.client===u&&h.curr.id.clock+h.curr.length<=d)h.next()}cr(c);let f=tr(l);return vt(o,f),o.toUint8Array()};var Zs=(t)=>{if(t.written>0)t.clientStructs.push({written:t.written,restEncoder:br(t.encoder.restEncoder)}),t.encoder.restEncoder=Qa(),t.written=0},Y=(t,e,r)=>{if(t.written>0&&t.currClient!==e.id.client)Zs(t);if(t.written===0)t.currClient=e.id.client,t.encoder.writeClient(e.id.client),_t(t.encoder.restEncoder,e.id.clock+r);e.write(t.encoder,r),t.written++},cr=(t)=>{Zs(t);let e=t.encoder.restEncoder;_t(e,t.clientStructs.length);for(let r=0;r<t.clientStructs.length;r++){let s=t.clientStructs[r];_t(e,s.written),jt(e,s.restEncoder)}},hc=(t,e,r,s)=>{let i=new r(tl(t)),o=new en(i,!1),c=new s,l=new nn(c);for(let f=o.curr;f!==null;f=o.next())Y(l,e(f),0);cr(l);let h=tr(i);return vt(c,h),c.toUint8Array()};var uc=(t)=>hc(t,$r,ct,Nt),As="You must not compute changes after the event-handler fired.";class le{constructor(t,e){this.target=t,this.currentTarget=t,this.transaction=e,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=dc(this.currentTarget,this.target))}deletes(t){return ce(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw R(As);let t=new Map,e=this.target;this.transaction.changed.get(e).forEach((s)=>{if(s!==null){let i=e._map.get(s),o,c;if(this.adds(i)){let l=i.left;while(l!==null&&this.adds(l))l=l.left;if(this.deletes(i))if(l!==null&&this.deletes(l))o="delete",c=ge(l.content.getContent());else return;else if(l!==null&&this.deletes(l))o="update",c=ge(l.content.getContent());else o="add",c=void 0}else if(this.deletes(i))o="delete",c=ge(i.content.getContent());else return;t.set(s,{action:o,oldValue:c})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw R(As);let e=this.target,r=G(),s=G(),i=[];if(t={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(e).has(null)){let c=null,l=()=>{if(c)i.push(c)};for(let h=e._start;h!==null;h=h.right)if(h.deleted){if(this.deletes(h)&&!this.adds(h)){if(c===null||c.delete===void 0)l(),c={delete:0};c.delete+=h.length,s.add(h)}}else if(this.adds(h)){if(c===null||c.insert===void 0)l(),c={insert:[]};c.insert=c.insert.concat(h.content.getContent()),r.add(h)}else{if(c===null||c.retain===void 0)l(),c={retain:0};c.retain+=h.length}if(c!==null&&c.retain===void 0)l()}this._changes=t}return t}}var dc=(t,e)=>{let r=[];while(e._item!==null&&e!==t){if(e._item.parentSub!==null)r.unshift(e._item.parentSub);else{let s=0,i=e._item.parent._start;while(i!==e._item&&i!==null){if(!i.deleted&&i.countable)s+=i.length;i=i.right}r.unshift(s)}e=e._item.parent}return r},O=()=>{Pn("Invalid access: Add Yjs type to a document before reading data.")},Xs=80,lr=0;class Qs{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=lr++}}var fc=(t)=>{t.timestamp=lr++},Ys=(t,e,r)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=r,t.timestamp=lr++},pc=(t,e,r)=>{if(t.length>=Xs){let s=t.reduce((i,o)=>i.timestamp<o.timestamp?i:o);return Ys(s,e,r),s}else{let s=new Qs(e,r);return t.push(s),s}},rn=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;let r=t._searchMarker.length===0?null:t._searchMarker.reduce((o,c)=>nt(e-o.index)<nt(e-c.index)?o:c),s=t._start,i=0;if(r!==null)s=r.p,i=r.index,fc(r);while(s.right!==null&&i<e){if(!s.deleted&&s.countable){if(e<i+s.length)break;i+=s.length}s=s.right}while(s.left!==null&&i>e)if(s=s.left,!s.deleted&&s.countable)i-=s.length;while(s.left!==null&&s.left.id.client===s.id.client&&s.left.id.clock+s.left.length===s.id.clock)if(s=s.left,!s.deleted&&s.countable)i-=s.length;if(r!==null&&nt(r.index-i)<s.parent.length/Xs)return Ys(r,s,i),r;else return pc(t._searchMarker,s,i)},re=(t,e,r)=>{for(let s=t.length-1;s>=0;s--){let i=t[s];if(r>0){let o=i.p;o.marker=!1;while(o&&(o.deleted||!o.countable))if(o=o.left,o&&!o.deleted&&o.countable)i.index-=o.length;if(o===null||o.marker===!0){t.splice(s,1);continue}i.p=o,o.marker=!0}if(e<i.index||r>0&&e===i.index)i.index=Z(e,i.index+r)}};var sn=(t,e,r)=>{let s=t,i=e.changedParentTypes;while(!0){if(q(i,t,()=>[]).push(r),t._item===null)break;t=t._item.parent}Fs(s._eH,r,e)};class I{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=bs(),this._dEH=bs(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw L()}clone(){throw L()}_write(t){}get _first(){let t=this._start;while(t!==null&&t.deleted)t=t.right;return t}_callObserver(t,e){if(!t.local&&this._searchMarker)this._searchMarker.length=0}observe(t){ks(this._eH,t)}observeDeep(t){ks(this._dEH,t)}unobserve(t){_s(this._eH,t)}unobserveDeep(t){_s(this._dEH,t)}toJSON(){}}var ti=(t,e,r)=>{if(t.doc??O(),e<0)e=t._length+e;if(r<0)r=t._length+r;let s=r-e,i=[],o=t._start;while(o!==null&&s>0){if(o.countable&&!o.deleted){let c=o.content.getContent();if(c.length<=e)e-=c.length;else{for(let l=e;l<c.length&&s>0;l++)i.push(c[l]),s--;e=0}}o=o.right}return i},ei=(t)=>{t.doc??O();let e=[],r=t._start;while(r!==null){if(r.countable&&!r.deleted){let s=r.content.getContent();for(let i=0;i<s.length;i++)e.push(s[i])}r=r.right}return e};var se=(t,e)=>{let r=0,s=t._start;t.doc??O();while(s!==null){if(s.countable&&!s.deleted){let i=s.content.getContent();for(let o=0;o<i.length;o++)e(i[o],r++,t)}s=s.right}},ni=(t,e)=>{let r=[];return se(t,(s,i)=>{r.push(e(s,i,t))}),r},gc=(t)=>{let e=t._start,r=null,s=0;return{[Symbol.iterator](){return this},next:()=>{if(r===null){while(e!==null&&e.deleted)e=e.right;if(e===null)return{done:!0,value:void 0};r=e.content.getContent(),s=0,e=e.right}let i=r[s++];if(r.length<=s)r=null;return{done:!1,value:i}}}},ri=(t,e)=>{t.doc??O();let r=rn(t,e),s=t._start;if(r!==null)s=r.p,e-=r.index;for(;s!==null;s=s.right)if(!s.deleted&&s.countable){if(e<s.length)return s.content.getContent()[e];e-=s.length}},Pe=(t,e,r,s)=>{let i=r,o=t.doc,{clientID:c,store:l}=o,h=r===null?e._start:r.right,f=[],a=()=>{if(f.length>0)i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new at(f)),i.integrate(t,0),f=[]};s.forEach((u)=>{if(u===null)f.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:f.push(u);break;default:switch(a(),u.constructor){case Uint8Array:case ArrayBuffer:i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new ae(new Uint8Array(u))),i.integrate(t,0);break;case Td:i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new he(u)),i.integrate(t,0);break;default:if(u instanceof I)i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new W(u)),i.integrate(t,0);else throw Error("Unexpected content type in insert operation")}}}),a()},si=()=>R("Length exceeded!"),ii=(t,e,r,s)=>{if(r>e._length)throw si();if(r===0){if(e._searchMarker)re(e._searchMarker,r,s.length);return Pe(t,e,null,s)}let i=r,o=rn(e,r),c=e._start;if(o!==null){if(c=o.p,r-=o.index,r===0)c=c.prev,r+=c&&c.countable&&!c.deleted?c.length:0}for(;c!==null;c=c.right)if(!c.deleted&&c.countable){if(r<=c.length){if(r<c.length)N(t,m(c.id.client,c.id.clock+r));break}r-=c.length}if(e._searchMarker)re(e._searchMarker,i,s.length);return Pe(t,e,c,s)},mc=(t,e,r)=>{let i=(e._searchMarker||[]).reduce((o,c)=>c.index>o.index?c:o,{index:0,p:e._start}).p;if(i)while(i.right)i=i.right;return Pe(t,e,i,r)},oi=(t,e,r,s)=>{if(s===0)return;let i=r,o=s,c=rn(e,r),l=e._start;if(c!==null)l=c.p,r-=c.index;for(;l!==null&&r>0;l=l.right)if(!l.deleted&&l.countable){if(r<l.length)N(t,m(l.id.client,l.id.clock+r));r-=l.length}while(s>0&&l!==null){if(!l.deleted){if(s<l.length)N(t,m(l.id.client,l.id.clock+s));l.delete(t),s-=l.length}l=l.right}if(s>0)throw si();if(e._searchMarker)re(e._searchMarker,i,-o+s)},Ke=(t,e,r)=>{let s=e._map.get(r);if(s!==void 0)s.delete(t)},ar=(t,e,r,s)=>{let i=e._map.get(r)||null,o=t.doc,c=o.clientID,l;if(s==null)l=new at([s]);else switch(s.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new at([s]);break;case Uint8Array:l=new ae(s);break;case Td:l=new he(s);break;default:if(s instanceof I)l=new W(s);else throw Error("Unexpected content type")}new y(m(c,b(o.store,c)),i,i&&i.lastId,null,null,e,r,l).integrate(t,0)},hr=(t,e)=>{t.doc??O();let r=t._map.get(e);return r!==void 0&&!r.deleted?r.content.getContent()[r.length-1]:void 0},ci=(t)=>{let e={};return t.doc??O(),t._map.forEach((r,s)=>{if(!r.deleted)e[s]=r.content.getContent()[r.length-1]}),e},li=(t,e)=>{t.doc??O();let r=t._map.get(e);return r!==void 0&&!r.deleted};var wc=(t,e)=>{let r={};return t._map.forEach((s,i)=>{let o=s;while(o!==null&&(!e.sv.has(o.id.client)||o.id.clock>=(e.sv.get(o.id.client)||0)))o=o.left;if(o!==null&&At(o,e))r[i]=o.content.getContent()[o.length-1]}),r},je=(t)=>(t.doc??O(),xs(t._map.entries(),(e)=>!e[1].deleted));class zy extends le{}class xa extends I{constructor(){super();this._prelimContent=[],this._searchMarker=[]}static from(t){let e=new xa;return e.push(t),e}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new xa}clone(){let t=new xa;return t.insert(0,this.toArray().map((e)=>e instanceof I?e.clone():e)),t}get length(){return this.doc??O(),this._length}_callObserver(t,e){super._callObserver(t,e),sn(this,t,new zy(this,t))}insert(t,e){if(this.doc!==null)x(this.doc,(r)=>{ii(r,this,t,e)});else this._prelimContent.splice(t,0,...e)}push(t){if(this.doc!==null)x(this.doc,(e)=>{mc(e,this,t)});else this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,e=1){if(this.doc!==null)x(this.doc,(r)=>{oi(r,this,t,e)});else this._prelimContent.splice(t,e)}get(t){return ri(this,t)}toArray(){return ei(this)}slice(t=0,e=this.length){return ti(this,t,e)}toJSON(){return this.map((t)=>t instanceof I?t.toJSON():t)}map(t){return ni(this,t)}forEach(t){se(this,t)}[Symbol.iterator](){return gc(this)}_write(t){t.writeTypeRef($c)}}var xc=(t)=>new xa;class L_ extends le{constructor(t,e,r){super(t,e);this.keysChanged=r}}class os extends I{constructor(t){super();if(this._prelimContent=null,t===void 0)this._prelimContent=new Map;else this._prelimContent=new Map(t)}_integrate(t,e){super._integrate(t,e),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new os}clone(){let t=new os;return this.forEach((e,r)=>{t.set(r,e instanceof I?e.clone():e)}),t}_callObserver(t,e){sn(this,t,new L_(this,t,e))}toJSON(){this.doc??O();let t={};return this._map.forEach((e,r)=>{if(!e.deleted){let s=e.content.getContent()[e.length-1];t[r]=s instanceof I?s.toJSON():s}}),t}get size(){return[...je(this)].length}keys(){return Me(je(this),(t)=>t[0])}values(){return Me(je(this),(t)=>t[1].content.getContent()[t[1].length-1])}entries(){return Me(je(this),(t)=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??O(),this._map.forEach((e,r)=>{if(!e.deleted)t(e.content.getContent()[e.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(t){if(this.doc!==null)x(this.doc,(e)=>{Ke(e,this,t)});else this._prelimContent.delete(t)}set(t,e){if(this.doc!==null)x(this.doc,(r)=>{ar(r,this,t,e)});else this._prelimContent.set(t,e);return e}get(t){return hr(this,t)}has(t){return li(this,t)}clear(){if(this.doc!==null)x(this.doc,(t)=>{this.forEach(function(e,r,s){Ke(t,s,r)})});else this._prelimContent.clear()}_write(t){t.writeTypeRef(Fc)}}var yc=(t)=>new os,tt=(t,e)=>t===e||typeof t==="object"&&typeof e==="object"&&t&&e&&In(t,e);class We{constructor(t,e,r,s){this.left=t,this.right=e,this.index=r,this.currentAttributes=s}forward(){if(this.right===null)v();switch(this.right.content.constructor){case U:if(!this.right.deleted)Rt(this.currentAttributes,this.right.content);break;default:if(!this.right.deleted)this.index+=this.right.length;break}this.left=this.right,this.right=this.right.right}}var Cs=(t,e,r)=>{while(e.right!==null&&r>0){switch(e.right.content.constructor){case U:if(!e.right.deleted)Rt(e.currentAttributes,e.right.content);break;default:if(!e.right.deleted){if(r<e.right.length)N(t,m(e.right.id.client,e.right.id.clock+r));e.index+=e.right.length,r-=e.right.length}break}e.left=e.right,e.right=e.right.right}return e},qe=(t,e,r,s)=>{let i=new Map,o=s?rn(e,r):null;if(o){let c=new We(o.p.left,o.p,o.index,i);return Cs(t,c,r-o.index)}else{let c=new We(null,e._start,0,i);return Cs(t,c,r)}},ai=(t,e,r,s)=>{while(r.right!==null&&(r.right.deleted===!0||r.right.content.constructor===U&&tt(s.get(r.right.content.key),r.right.content.value))){if(!r.right.deleted)s.delete(r.right.content.key);r.forward()}let i=t.doc,o=i.clientID;s.forEach((c,l)=>{let{left:h,right:f}=r,a=new y(m(o,b(i.store,o)),h,h&&h.lastId,f,f&&f.id,e,null,new U(l,c));a.integrate(t,0),r.right=a,r.forward()})},Rt=(t,e)=>{let{key:r,value:s}=e;if(s===null)t.delete(r);else t.set(r,s)},hi=(t,e)=>{while(!0){if(t.right===null)break;else if(t.right.deleted||t.right.content.constructor===U&&tt(e[t.right.content.key]??null,t.right.content.value));else break;t.forward()}},ui=(t,e,r,s)=>{let i=t.doc,o=i.clientID,c=new Map;for(let l in s){let h=s[l],f=r.currentAttributes.get(l)??null;if(!tt(f,h)){c.set(l,f);let{left:a,right:u}=r;r.right=new y(m(o,b(i.store,o)),a,a&&a.lastId,u,u&&u.id,e,null,new U(l,h)),r.right.integrate(t,0),r.forward()}}return c},Kn=(t,e,r,s,i)=>{r.currentAttributes.forEach((d,p)=>{if(i[p]===void 0)i[p]=null});let o=t.doc,c=o.clientID;hi(r,i);let l=ui(t,e,r,i),h=s.constructor===String?new K(s):s instanceof I?new W(s):new ut(s),{left:f,right:a,index:u}=r;if(e._searchMarker)re(e._searchMarker,r.index,h.getLength());a=new y(m(c,b(o.store,c)),f,f&&f.lastId,a,a&&a.id,e,null,h),a.integrate(t,0),r.right=a,r.index=u,r.forward(),ai(t,e,r,l)},Ds=(t,e,r,s,i)=>{let o=t.doc,c=o.clientID;hi(r,i);let l=ui(t,e,r,i);t:while(r.right!==null&&(s>0||l.size>0&&(r.right.deleted||r.right.content.constructor===U))){if(!r.right.deleted)switch(r.right.content.constructor){case U:{let{key:h,value:f}=r.right.content,a=i[h];if(a!==void 0){if(tt(a,f))l.delete(h);else{if(s===0)break t;l.set(h,f)}r.right.delete(t)}else r.currentAttributes.set(h,f);break}default:if(s<r.right.length)N(t,m(r.right.id.client,r.right.id.clock+s));s-=r.right.length;break}r.forward()}if(s>0){let h="";for(;s>0;s--)h+=`
4
- `;r.right=new y(m(c,b(o.store,c)),r.left,r.left&&r.left.lastId,r.right,r.right&&r.right.id,e,null,new K(h)),r.right.integrate(t,0),r.forward()}ai(t,e,r,l)},di=(t,e,r,s,i)=>{let o=e,c=A();while(o&&(!o.countable||o.deleted)){if(!o.deleted&&o.content.constructor===U){let f=o.content;c.set(f.key,f)}o=o.right}let l=0,h=!1;while(e!==o){if(r===e)h=!0;if(!e.deleted){let f=e.content;switch(f.constructor){case U:{let{key:a,value:u}=f,d=s.get(a)??null;if(c.get(a)!==f||d===u){if(e.delete(t),l++,!h&&(i.get(a)??null)===u&&d!==u)if(d===null)i.delete(a);else i.set(a,d)}if(!h&&!e.deleted)Rt(i,f);break}}}e=e.right}return l},bc=(t,e)=>{while(e&&e.right&&(e.right.deleted||!e.right.countable))e=e.right;let r=new Set;while(e&&(e.deleted||!e.countable)){if(!e.deleted&&e.content.constructor===U){let s=e.content.key;if(r.has(s))e.delete(t);else r.add(s)}e=e.left}},kc=(t)=>{let e=0;return x(t.doc,(r)=>{let{_start:s,_start:i}=t,o=A(),c=Ee(o);while(i){if(i.deleted===!1)switch(i.content.constructor){case U:Rt(c,i.content);break;default:e+=di(r,s,i,o,c),o=Ee(c),s=i;break}i=i.right}}),e},_c=(t)=>{let e=new Set,r=t.doc;for(let[s,i]of t.afterState.entries()){let o=t.beforeState.get(s)||0;if(i===o)continue;Js(t,r.store.clients.get(s),o,i,(c)=>{if(!c.deleted&&c.content.constructor===U&&c.constructor!==V)e.add(c.parent)})}x(r,(s)=>{Bt(t,t.deleteSet,(i)=>{if(i instanceof V||!i.parent._hasFormatting||e.has(i.parent))return;let o=i.parent;if(i.content.constructor===U)e.add(o);else bc(s,i)});for(let i of e)kc(i)})},Bs=(t,e,r)=>{let s=r,i=Ee(e.currentAttributes),o=e.right;while(r>0&&e.right!==null){if(e.right.deleted===!1)switch(e.right.content.constructor){case W:case ut:case K:if(r<e.right.length)N(t,m(e.right.id.client,e.right.id.clock+r));r-=e.right.length,e.right.delete(t);break}e.forward()}if(o)di(t,o,e.right,i,e.currentAttributes);let c=(e.left||e.right).parent;if(c._searchMarker)re(c._searchMarker,e.index,-s+r);return e};class $_ extends le{constructor(t,e,r){super(t,e);this.childListChanged=!1,this.keysChanged=new Set,r.forEach((s)=>{if(s===null)this.childListChanged=!0;else this.keysChanged.add(s)})}get changes(){if(this._changes===null){let t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(this._delta===null){let t=this.target.doc,e=[];x(t,(r)=>{let s=new Map,i=new Map,o=this.target._start,c=null,l={},h="",f=0,a=0,u=()=>{if(c!==null){let d=null;switch(c){case"delete":if(a>0)d={delete:a};a=0;break;case"insert":if(typeof h==="object"||h.length>0){if(d={insert:h},s.size>0)d.attributes={},s.forEach((p,g)=>{if(p!==null)d.attributes[g]=p})}h="";break;case"retain":if(f>0){if(d={retain:f},!Mr(l))d.attributes=Lr({},l)}f=0;break}if(d)e.push(d);c=null}};while(o!==null){switch(o.content.constructor){case W:case ut:if(this.adds(o)){if(!this.deletes(o))u(),c="insert",h=o.content.getContent()[0],u()}else if(this.deletes(o)){if(c!=="delete")u(),c="delete";a+=1}else if(!o.deleted){if(c!=="retain")u(),c="retain";f+=1}break;case K:if(this.adds(o)){if(!this.deletes(o)){if(c!=="insert")u(),c="insert";h+=o.content.str}}else if(this.deletes(o)){if(c!=="delete")u(),c="delete";a+=o.length}else if(!o.deleted){if(c!=="retain")u(),c="retain";f+=o.length}break;case U:{let{key:d,value:p}=o.content;if(this.adds(o)){if(!this.deletes(o)){let g=s.get(d)??null;if(!tt(g,p)){if(c==="retain")u();if(tt(p,i.get(d)??null))delete l[d];else l[d]=p}else if(p!==null)o.delete(r)}}else if(this.deletes(o)){i.set(d,p);let g=s.get(d)??null;if(!tt(g,p)){if(c==="retain")u();l[d]=g}}else if(!o.deleted){i.set(d,p);let g=l[d];if(g!==void 0){if(!tt(g,p)){if(c==="retain")u();if(p===null)delete l[d];else l[d]=p}else if(g!==null)o.delete(r)}}if(!o.deleted){if(c==="insert")u();Rt(s,o.content)}break}}o=o.right}u();while(e.length>0){let d=e[e.length-1];if(d.retain!==void 0&&d.attributes===void 0)e.pop();else break}}),this._delta=e}return this._delta}}class rs extends I{constructor(t){super();this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??O(),this._length}_integrate(t,e){super._integrate(t,e);try{this._pending.forEach((r)=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new rs}clone(){let t=new rs;return t.applyDelta(this.toDelta()),t}_callObserver(t,e){super._callObserver(t,e);let r=new $_(this,t,e);if(sn(this,t,r),!t.local&&this._hasFormatting)t._needFormattingCleanup=!0}toString(){this.doc??O();let t="",e=this._start;while(e!==null){if(!e.deleted&&e.countable&&e.content.constructor===K)t+=e.content.str;e=e.right}return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:e=!0}={}){if(this.doc!==null)x(this.doc,(r)=>{let s=new We(null,this._start,0,new Map);for(let i=0;i<t.length;i++){let o=t[i];if(o.insert!==void 0){let c=!e&&typeof o.insert==="string"&&i===t.length-1&&s.right===null&&o.insert.slice(-1)===`
5
- `?o.insert.slice(0,-1):o.insert;if(typeof c!=="string"||c.length>0)Kn(r,this,s,c,o.attributes||{})}else if(o.retain!==void 0)Ds(r,this,s,o.retain,o.attributes||{});else if(o.delete!==void 0)Bs(r,s,o.delete)}});else this._pending.push(()=>this.applyDelta(t))}toDelta(t,e,r){this.doc??O();let s=[],i=new Map,o=this.doc,c="",l=this._start;function h(){if(c.length>0){let a={},u=!1;i.forEach((p,g)=>{u=!0,a[g]=p});let d={insert:c};if(u)d.attributes=a;s.push(d),c=""}}let f=()=>{while(l!==null){if(At(l,t)||e!==void 0&&At(l,e))switch(l.content.constructor){case K:{let a=i.get("ychange");if(t!==void 0&&!At(l,t)){if(a===void 0||a.user!==l.id.client||a.type!=="removed")h(),i.set("ychange",r?r("removed",l.id):{type:"removed"})}else if(e!==void 0&&!At(l,e)){if(a===void 0||a.user!==l.id.client||a.type!=="added")h(),i.set("ychange",r?r("added",l.id):{type:"added"})}else if(a!==void 0)h(),i.delete("ychange");c+=l.content.str;break}case W:case ut:{h();let a={insert:l.content.getContent()[0]};if(i.size>0){let u={};a.attributes=u,i.forEach((d,p)=>{u[p]=d})}s.push(a);break}case U:if(At(l,t))h(),Rt(i,l.content);break}l=l.right}h()};if(t||e)x(o,(a)=>{if(t)Zn(a,t);if(e)Zn(a,e);f()},"cleanup");else f();return s}insert(t,e,r){if(e.length<=0)return;let s=this.doc;if(s!==null)x(s,(i)=>{let o=qe(i,this,t,!r);if(!r)r={},o.currentAttributes.forEach((c,l)=>{r[l]=c});Kn(i,this,o,e,r)});else this._pending.push(()=>this.insert(t,e,r))}insertEmbed(t,e,r){let s=this.doc;if(s!==null)x(s,(i)=>{let o=qe(i,this,t,!r);Kn(i,this,o,e,r||{})});else this._pending.push(()=>this.insertEmbed(t,e,r||{}))}delete(t,e){if(e===0)return;let r=this.doc;if(r!==null)x(r,(s)=>{Bs(s,qe(s,this,t,!0),e)});else this._pending.push(()=>this.delete(t,e))}format(t,e,r){if(e===0)return;let s=this.doc;if(s!==null)x(s,(i)=>{let o=qe(i,this,t,!1);if(o.right===null)return;Ds(i,this,o,e,r)});else this._pending.push(()=>this.format(t,e,r))}removeAttribute(t){if(this.doc!==null)x(this.doc,(e)=>{Ke(e,this,t)});else this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,e){if(this.doc!==null)x(this.doc,(r)=>{ar(r,this,t,e)});else this._pending.push(()=>this.setAttribute(t,e))}getAttribute(t){return hr(this,t)}getAttributes(){return ci(this)}_write(t){t.writeTypeRef(jc)}}var Sc=(t)=>new rs;class ze{constructor(t,e=()=>!0){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??O()}[Symbol.iterator](){return this}next(){let t=this._currentNode,e=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(e)))do if(e=t.content.type,!t.deleted&&(e.constructor===Ot||e.constructor===lt)&&e._start!==null)t=e._start;else while(t!==null){let r=t.next;if(r!==null){t=r;break}else if(t.parent===this._root)t=null;else t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));if(this._firstCall=!1,t===null)return{value:void 0,done:!0};return this._currentNode=t,{value:t.content.type,done:!1}}}class lt extends I{constructor(){super();this._prelimContent=[]}get firstChild(){let t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new lt}clone(){let t=new lt;return t.insert(0,this.toArray().map((e)=>e instanceof I?e.clone():e)),t}get length(){return this.doc??O(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new ze(this,t)}querySelector(t){t=t.toUpperCase();let r=new ze(this,(s)=>s.nodeName&&s.nodeName.toUpperCase()===t).next();if(r.done)return null;else return r.value}querySelectorAll(t){return t=t.toUpperCase(),j(new ze(this,(e)=>e.nodeName&&e.nodeName.toUpperCase()===t))}_callObserver(t,e){sn(this,t,new fi(this,e,t))}toString(){return ni(this,(t)=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},r){let s=t.createDocumentFragment();if(r!==void 0)r._createAssociation(s,this);return se(this,(i)=>{s.insertBefore(i.toDOM(t,e,r),null)}),s}insert(t,e){if(this.doc!==null)x(this.doc,(r)=>{ii(r,this,t,e)});else this._prelimContent.splice(t,0,...e)}insertAfter(t,e){if(this.doc!==null)x(this.doc,(r)=>{let s=t&&t instanceof I?t._item:t;Pe(r,this,s,e)});else{let r=this._prelimContent,s=t===null?0:r.findIndex((i)=>i===t)+1;if(s===0&&t!==null)throw R("Reference item not found");r.splice(s,0,...e)}}delete(t,e=1){if(this.doc!==null)x(this.doc,(r)=>{oi(r,this,t,e)});else this._prelimContent.splice(t,e)}toArray(){return ei(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return ri(this,t)}slice(t=0,e=this.length){return ti(this,t,e)}forEach(t){se(this,t)}_write(t){t.writeTypeRef(Gc)}}var Ec=(t)=>new lt;class Ot extends lt{constructor(t="UNDEFINED"){super();this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,e){super._integrate(t,e),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new Ot(this.nodeName)}clone(){let t=new Ot(this.nodeName),e=this.getAttributes();return Vr(e,(r,s)=>{t.setAttribute(s,r)}),t.insert(0,this.toArray().map((r)=>r instanceof I?r.clone():r)),t}toString(){let t=this.getAttributes(),e=[],r=[];for(let c in t)r.push(c);r.sort();let s=r.length;for(let c=0;c<s;c++){let l=r[c];e.push(l+'="'+t[l]+'"')}let i=this.nodeName.toLocaleLowerCase(),o=e.length>0?" "+e.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(t){if(this.doc!==null)x(this.doc,(e)=>{Ke(e,this,t)});else this._prelimAttrs.delete(t)}setAttribute(t,e){if(this.doc!==null)x(this.doc,(r)=>{ar(r,this,t,e)});else this._prelimAttrs.set(t,e)}getAttribute(t){return hr(this,t)}hasAttribute(t){return li(this,t)}getAttributes(t){return t?wc(this,t):ci(this)}toDOM(t=document,e={},r){let s=t.createElement(this.nodeName),i=this.getAttributes();for(let o in i){let c=i[o];if(typeof c==="string")s.setAttribute(o,c)}if(se(this,(o)=>{s.appendChild(o.toDOM(t,e,r))}),r!==void 0)r._createAssociation(s,this);return s}_write(t){t.writeTypeRef(qc),t.writeKey(this.nodeName)}}var Ic=(t)=>new Ot(t.readKey());class fi extends le{constructor(t,e,r){super(t,r);this.childListChanged=!1,this.attributesChanged=new Set,e.forEach((s)=>{if(s===null)this.childListChanged=!0;else this.attributesChanged.add(s)})}}class Ze extends os{constructor(t){super();this.hookName=t}_copy(){return new Ze(this.hookName)}clone(){let t=new Ze(this.hookName);return this.forEach((e,r)=>{t.set(r,e)}),t}toDOM(t=document,e={},r){let s=e[this.hookName],i;if(s!==void 0)i=s.createDom(this);else i=document.createElement(this.hookName);if(i.setAttribute("data-yjs-hook",this.hookName),r!==void 0)r._createAssociation(i,this);return i}_write(t){t.writeTypeRef(zc),t.writeKey(this.hookName)}}var Uc=(t)=>new Ze(t.readKey());class Xe extends rs{get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new Xe}clone(){let t=new Xe;return t.applyDelta(this.toDelta()),t}toDOM(t=document,e,r){let s=t.createTextNode(this.toString());if(r!==void 0)r._createAssociation(s,this);return s}toString(){return this.toDelta().map((t)=>{let e=[];for(let s in t.attributes){let i=[];for(let o in t.attributes[s])i.push({key:o,value:t.attributes[s][o]});i.sort((o,c)=>o.key<c.key?-1:1),e.push({nodeName:s,attrs:i})}e.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let r="";for(let s=0;s<e.length;s++){let i=e[s];r+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){let c=i.attrs[o];r+=` ${c.key}="${c.value}"`}r+=">"}r+=t.insert;for(let s=e.length-1;s>=0;s--)r+=`</${e[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Hc)}}var Tc=(t)=>new Xe;class on{constructor(t,e){this.id=t,this.length=e}get deleted(){throw L()}mergeWith(t){return!1}write(t,e,r){throw L()}integrate(t,e){throw L()}}var Ac=0;class V extends on{get deleted(){return!0}delete(){}mergeWith(t){if(this.constructor!==t.constructor)return!1;return this.length+=t.length,!0}integrate(t,e){if(e>0)this.id.clock+=e,this.length-=e;Hs(t.doc.store,this)}write(t,e){t.writeInfo(Ac),t.writeLen(this.length-e)}getMissing(t,e){return null}}class ae{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new ae(this.content)}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}}var Cc=(t)=>new ae(t.readBuf());class ie{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new ie(this.len)}splice(t){let e=new ie(this.len-t);return this.len=t,e}mergeWith(t){return this.len+=t.len,!0}integrate(t,e){ne(t.deleteSet,e.id.client,e.id.clock,this.len),e.markDeleted()}delete(t){}gc(t){}write(t,e){t.writeLen(this.len-e)}getRef(){return 1}}var Dc=(t)=>new ie(t.readLen()),pi=(t,e)=>new Td({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class he{constructor(t){if(t._item)console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid.");this.doc=t;let e={};if(this.opts=e,!t.gc)e.gc=!1;if(t.autoLoad)e.autoLoad=!0;if(t.meta!==null)e.meta=t.meta}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new he(pi(this.doc.guid,this.opts))}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){if(this.doc._item=e,t.subdocsAdded.add(this.doc),this.doc.shouldLoad)t.subdocsLoaded.add(this.doc)}delete(t){if(t.subdocsAdded.has(this.doc))t.subdocsAdded.delete(this.doc);else t.subdocsRemoved.add(this.doc)}gc(t){}write(t,e){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}var Bc=(t)=>new he(pi(t.readString(),t.readAny()));class ut{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ut(this.embed)}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}}var Oc=(t)=>new ut(t.readJSON());class U{constructor(t,e){this.key=t,this.value=e}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new U(this.key,this.value)}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){let r=e.parent;r._searchMarker=null,r._hasFormatting=!0}delete(t){}gc(t){}write(t,e){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}var vc=(t)=>new U(t.readKey(),t.readJSON());class Qe{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Qe(this.arr)}splice(t){let e=new Qe(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let r=this.arr.length;t.writeLen(r-e);for(let s=e;s<r;s++){let i=this.arr[s];t.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}var Nc=(t)=>{let e=t.readLen(),r=[];for(let s=0;s<e;s++){let i=t.readString();if(i==="undefined")r.push(void 0);else r.push(JSON.parse(i))}return new Qe(r)},Rc=Zt("node_env")==="development";class at{constructor(t){this.arr=t,Rc&&Un(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new at(this.arr)}splice(t){let e=new at(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let r=this.arr.length;t.writeLen(r-e);for(let s=e;s<r;s++){let i=this.arr[s];t.writeAny(i)}}getRef(){return 8}}var Lc=(t)=>{let e=t.readLen(),r=[];for(let s=0;s<e;s++)r.push(t.readAny());return new at(r)};class K{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new K(this.str)}splice(t){let e=new K(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);if(r>=55296&&r<=56319)this.str=this.str.slice(0,t-1)+"�",e.str="�"+e.str.slice(1);return e}mergeWith(t){return this.str+=t.str,!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeString(e===0?this.str:this.str.slice(e))}getRef(){return 4}}var Vc=(t)=>new K(t.readString()),Mc=[xc,yc,Sc,Ic,Ec,Uc,Tc],$c=0,Fc=1,jc=2,qc=3,Gc=4,zc=5,Hc=6;class W{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new W(this.type._copy())}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){this.type._integrate(t.doc,e)}delete(t){let e=this.type._start;while(e!==null){if(!e.deleted)e.delete(t);else if(e.id.clock<(t.beforeState.get(e.id.client)||0))t._mergeStructs.push(e);e=e.right}this.type._map.forEach((r)=>{if(!r.deleted)r.delete(t);else if(r.id.clock<(t.beforeState.get(r.id.client)||0))t._mergeStructs.push(r)}),t.changed.delete(this.type)}gc(t){let e=this.type._start;while(e!==null)e.gc(t,!0),e=e.right;this.type._start=null,this.type._map.forEach((r)=>{while(r!==null)r.gc(t,!0),r=r.left}),this.type._map=new Map}write(t,e){this.type._write(t)}getRef(){return 7}}var Jc=(t)=>new W(Mc[t.readTypeRef()](t)),Qn=(t,e)=>{let r=e,s=0,i;do{if(s>0)r=m(r.client,r.clock+s);i=Ct(t,r),s=r.clock-i.id.clock,r=i.redone}while(r!==null&&i instanceof y);return{item:i,diff:s}},ur=(t,e)=>{while(t!==null&&t.keep!==e)t.keep=e,t=t.parent._item},Ye=(t,e,r)=>{let{client:s,clock:i}=e.id,o=new y(m(s,i+r),e,m(s,i+r-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(r));if(e.deleted)o.markDeleted();if(e.keep)o.keep=!0;if(e.redone!==null)o.redone=m(e.redone.client,e.redone.clock+r);if(e.right=o,o.right!==null)o.right.left=o;if(t._mergeStructs.push(o),o.parentSub!==null&&o.right===null)o.parent._map.set(o.parentSub,o);return e.length=r,o},Os=(t,e)=>$t(t,(r)=>ce(r.deletions,e)),gi=(t,e,r,s,i,o)=>{let c=t.doc,{store:l,clientID:h}=c,f=e.redone;if(f!==null)return N(t,f);let a=e.parent._item,u=null,d;if(a!==null&&a.deleted===!0){if(a.redone===null&&(!r.has(a)||gi(t,a,r,s,i,o)===null))return null;while(a.redone!==null)a=N(t,a.redone)}let p=a===null?e.parent:a.content.type;if(e.parentSub===null){u=e.left,d=e;while(u!==null){let k=u;while(k!==null&&k.parent._item!==a)k=k.redone===null?null:N(t,k.redone);if(k!==null&&k.parent._item===a){u=k;break}u=u.left}while(d!==null){let k=d;while(k!==null&&k.parent._item!==a)k=k.redone===null?null:N(t,k.redone);if(k!==null&&k.parent._item===a){d=k;break}d=d.right}}else{if(d=null,e.right&&!i){u=e;while(u!==null&&u.right!==null&&(u.right.redone||ce(s,u.right.id)||Os(o.undoStack,u.right.id)||Os(o.redoStack,u.right.id))){u=u.right;while(u.redone)u=N(t,u.redone)}if(u&&u.right!==null)return null}else u=p._map.get(e.parentSub)||null;if(u!==null&&u.parent._item!==a)u=p._map.get(e.parentSub)||null}let g=b(l,h),w=m(h,g),C=new y(w,u,u&&u.lastId,d,d&&d.id,p,e.parentSub,e.content.copy());return e.redone=w,ur(C,!0),C.integrate(t,0),C};class y extends on{constructor(t,e,r,s,i,o,c,l){super(t,l.getLength());this.origin=r,this.left=e,this.right=s,this.rightOrigin=i,this.parent=o,this.parentSub=c,this.redone=null,this.content=l,this.info=this.content.isCountable()?ln:0}set marker(t){if((this.info&pe)>0!==t)this.info^=pe}get marker(){return(this.info&pe)>0}get keep(){return(this.info&cn)>0}set keep(t){if(this.keep!==t)this.info^=cn}get countable(){return(this.info&ln)>0}get deleted(){return(this.info&fe)>0}set deleted(t){if(this.deleted!==t)this.info^=fe}markDeleted(){this.info|=fe}getMissing(t,e){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=b(e,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=b(e,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ot&&this.id.client!==this.parent.client&&this.parent.clock>=b(e,this.parent.client))return this.parent.client;if(this.origin)this.left=Ss(t,e,this.origin),this.origin=this.left.lastId;if(this.rightOrigin)this.right=N(t,this.rightOrigin),this.rightOrigin=this.right.id;if(this.left&&this.left.constructor===V||this.right&&this.right.constructor===V)this.parent=null;else if(!this.parent){if(this.left&&this.left.constructor===y)this.parent=this.left.parent,this.parentSub=this.left.parentSub;else if(this.right&&this.right.constructor===y)this.parent=this.right.parent,this.parentSub=this.right.parentSub}else if(this.parent.constructor===ot){let r=Ct(e,this.parent);if(r.constructor===V)this.parent=null;else this.parent=r.content.type}return null}integrate(t,e){if(e>0)this.id.clock+=e,this.left=Ss(t,t.doc.store,m(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(e),this.length-=e;if(this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null){s=this.parent._map.get(this.parentSub)||null;while(s!==null&&s.left!==null)s=s.left}else s=this.parent._start;let i=new Set,o=new Set;while(s!==null&&s!==this.right){if(o.add(s),i.add(s),$e(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if($e(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(Ct(t.doc.store,s.origin))){if(!i.has(Ct(t.doc.store,s.origin)))r=s,i.clear()}else break;s=s.right}this.left=r}if(this.left!==null){let r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null){r=this.parent._map.get(this.parentSub)||null;while(r!==null&&r.left!==null)r=r.left}else r=this.parent._start,this.parent._start=this;this.right=r}if(this.right!==null)this.right.left=this;else if(this.parentSub!==null){if(this.parent._map.set(this.parentSub,this),this.left!==null)this.left.delete(t)}if(this.parentSub===null&&this.countable&&!this.deleted)this.parent._length+=this.length;if(Hs(t.doc.store,this),this.content.integrate(t,this),Is(t,this.parent,this.parentSub),this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)this.delete(t)}else new V(this.id,this.length).integrate(t,0)}get next(){let t=this.right;while(t!==null&&t.deleted)t=t.right;return t}get prev(){let t=this.left;while(t!==null&&t.deleted)t=t.left;return t}get lastId(){return this.length===1?this.id:m(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&$e(t.origin,this.lastId)&&this.right===t&&$e(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){let e=this.parent._searchMarker;if(e)e.forEach((r)=>{if(r.p===t){if(r.p=this,!this.deleted&&this.countable)r.index-=this.length}});if(t.keep)this.keep=!0;if(this.right=t.right,this.right!==null)this.right.left=this;return this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){let e=this.parent;if(this.countable&&this.parentSub===null)e._length-=this.length;this.markDeleted(),ne(t.deleteSet,this.id.client,this.id.clock,this.length),Is(t,e,this.parentSub),this.content.delete(t)}}gc(t,e){if(!this.deleted)throw v();if(this.content.gc(t),e)rc(t,this,new V(this.id,this.length));else this.content=new ie(this.length)}write(t,e){let r=e>0?m(this.id.client,this.id.clock+e-1):this.origin,s=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&Vt|(r===null?0:D)|(s===null?0:F)|(i===null?0:dt);if(t.writeInfo(o),r!==null)t.writeLeftID(r);if(s!==null)t.writeRightID(s);if(r===null&&s===null){let c=this.parent;if(c._item!==void 0){let l=c._item;if(l===null){let h=js(c);t.writeParentInfo(!0),t.writeString(h)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else if(c.constructor===String)t.writeParentInfo(!0),t.writeString(c);else if(c.constructor===ot)t.writeParentInfo(!1),t.writeLeftID(c);else v();if(i!==null)t.writeString(i)}this.content.write(t,e)}}var mi=(t,e)=>Pc[e&Vt](t),Pc=[()=>{v()},Dc,Nc,Cc,Vc,Oc,vc,Jc,Lc,Bc,()=>{v()}],Kc=10;class M extends on{get deleted(){return!0}delete(){}mergeWith(t){if(this.constructor!==t.constructor)return!1;return this.length+=t.length,!0}integrate(t,e){v()}write(t,e){t.writeInfo(Kc),_t(t.restEncoder,this.length-e)}getMissing(t,e){return null}}var wi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},xi="__ $YJS$ __";if(wi[xi]===!0)console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");wi[xi]=!0;var qR=0,GR=1,KR=2,JR=3;class eb extends Error{constructor(t){super(t);this.name="EnvelopeError"}}function Wc(t){return _(t)&&"type"in t&&n(t.type)}function Xk(t){let e=Qa(),{type:r}=t;switch(t.type){case"doc-sync":{_t(e,qR),el(e,t.path),_t(e,t.epoch),zo(e,t.body);break}case"awareness":{_t(e,GR),zo(e,t.body);break}case"doc-close":{_t(e,KR),el(e,t.path);break}case"control":{_t(e,JR),el(e,JSON.stringify(t.message));break}default:throw new eb(`unknown-frame:${r}`)}return br(e)}function Qk(t){try{let e=tl(t),r=Dt(e);switch(r){case qR:{let s=nl(e),i=Dt(e);return{body:Xo(e),epoch:i,path:s,type:"doc-sync"}}case GR:return{body:Xo(e),type:"awareness"};case KR:return{path:nl(e),type:"doc-close"};case JR:{let s=JSON.parse(nl(e));if(!Wc(s))throw new eb("malformed-control");return{message:s,type:"control"}}default:throw new eb(`unknown-frame-type:${r}`)}}catch(e){if(e instanceof eb)throw e;throw new eb(`malformed-frame: ${e instanceof Error?e.message:String(e)}`)}}
6
- export{Yk,is,Qa,Zk,br,_t,el,zo,tl,Xo,Dt,nl,$u,fp,Td,WR,VR,UR,T_,Qg,PP,zy,xa,L_,os,$_,rs,qR,GR,KR,JR,eb,Xk,Qk};
1
+ import{n,S}from"./studio-erjccagy.js";var T=()=>new Map,ue=(t)=>{let e=T();return t.forEach((r,s)=>{e.set(s,r)}),e},j=(t,e,r)=>{let s=t.get(e);if(s===void 0)t.set(e,s=r());return s},fr=(t,e)=>{let r=[];for(let[s,i]of t)r.push(e(i,s));return r},pr=(t,e)=>{for(let[r,s]of t)if(e(s,r))return!0;return!1};var G=()=>new Set;var de=(t)=>t[t.length-1];var gr=(t,e)=>{for(let r=0;r<e.length;r++)t.push(e[r])},q=Array.from,fe=(t,e)=>{for(let r=0;r<t.length;r++)if(!e(t[r],r,t))return!1;return!0},Vt=(t,e)=>{for(let r=0;r<t.length;r++)if(e(t[r],r,t))return!0;return!1};var mr=(t,e)=>{let r=Array(t);for(let s=0;s<t;s++)r[s]=e(s,r);return r};var Z=Array.isArray;class pe{constructor(){this._observers=T()}on(t,e){return j(this._observers,t,G).add(e),e}once(t,e){let r=(...s)=>{this.off(t,r),e(...s)};this.on(t,r)}off(t,e){let r=this._observers.get(t);if(r!==void 0){if(r.delete(e),r.size===0)this._observers.delete(t)}}emit(t,e){return q((this._observers.get(t)||T()).values()).forEach((r)=>r(...e))}destroy(){this._observers=T()}}class aE{constructor(){this._observers=T()}on(t,e){j(this._observers,t,G).add(e)}once(t,e){let r=(...s)=>{this.off(t,r),e(...s)};this.on(t,r)}off(t,e){let r=this._observers.get(t);if(r!==void 0){if(r.delete(e),r.size===0)this._observers.delete(t)}}emit(t,e){return q((this._observers.get(t)||T()).values()).forEach((r)=>r(...e))}destroy(){this._observers=T()}}var rs=Math.floor;var nt=Math.abs;var ge=(t,e)=>t<e?t:e,X=(t,e)=>t>e?t:e;var me=(t)=>t!==0?t<0:1/t<0;var ln=1,an=2,we=4,xe=8;var dt=32,F=64,D=128;var Ft=31,jt=63,Q=127;var wr=2147483647;var{MAX_SAFE_INTEGER:ft,MIN_SAFE_INTEGER:un}=Number;var xr=Number.isInteger||((t)=>typeof t==="number"&&isFinite(t)&&rs(t)===t);var{fromCharCode:fn,fromCodePoint:bi}=String,Xc=fn(65535),ki=(t)=>t.toLowerCase(),_i=/^\s*/g,Si=(t)=>t.replace(_i,""),Ei=/([A-Z])/g,pn=(t,e)=>Si(t.replace(Ei,(r)=>`${e}${ki(r)}`));var Ii=(t)=>{let e=unescape(encodeURIComponent(t)),r=e.length,s=new Uint8Array(r);for(let i=0;i<r;i++)s[i]=e.codePointAt(i);return s},gt=typeof TextEncoder<"u"?new TextEncoder:null,Ui=(t)=>gt.encode(t),yr=gt?Ui:Ii;var pt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});if(pt&&pt.decode(new Uint8Array).length===1)pt=null;var br=(t,e)=>mr(e,()=>t).join("");class wt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var Qa=()=>new wt;var lE=(t)=>{let e=t.cpos;for(let r=0;r<t.bufs.length;r++)e+=t.bufs[r].length;return e};var yo=(t)=>{let e=new Uint8Array(lE(t)),r=0;for(let s=0;s<t.bufs.length;s++){let i=t.bufs[s];e.set(i,r),r+=i.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),r),e},Ti=(t,e)=>{let r=t.cbuf.length;if(r-t.cpos<e)t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(X(r,e)*2),t.cpos=0},A=(t,e)=>{let r=t.cbuf.length;if(t.cpos===r)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(r*2),t.cpos=0;t.cbuf[t.cpos++]=e};var be=A;var _t=(t,e)=>{while(e>Q)A(t,D|Q&e),e=rs(e/128);A(t,Q&e)},ke=(t,e)=>{let r=me(e);if(r)e=-e;A(t,(e>jt?D:0)|(r?F:0)|jt&e),e=rs(e/64);while(e>0)A(t,(e>Q?D:0)|Q&e),e=rs(e/128)},gn=new Uint8Array(30000),Ai=gn.length/3,Ci=(t,e)=>{if(e.length<Ai){let r=gt.encodeInto(e,gn).written||0;_t(t,r);for(let s=0;s<r;s++)A(t,gn[s])}else Wr(t,yr(e))},Di=(t,e)=>{let r=unescape(encodeURIComponent(e)),s=r.length;_t(t,s);for(let i=0;i<s;i++)A(t,r.codePointAt(i))},el=gt&&gt.encodeInto?Ci:Di;var qt=(t,e)=>{let r=t.cbuf.length,s=t.cpos,i=ge(r-s,e.length),o=e.length-i;if(t.cbuf.set(e.subarray(0,i),s),t.cpos+=i,o>0)t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(X(r*2,o)),t.cbuf.set(e.subarray(i)),t.cpos=o},Wr=(t,e)=>{_t(t,e.byteLength),qt(t,e)},mn=(t,e)=>{Ti(t,e);let r=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,r},Bi=(t,e)=>mn(t,4).setFloat32(0,e,!1),Oi=(t,e)=>mn(t,8).setFloat64(0,e,!1),vi=(t,e)=>mn(t,8).setBigInt64(0,e,!1);var kr=new DataView(new ArrayBuffer(4)),Ni=(t)=>(kr.setFloat32(0,t),kr.getFloat32(0)===t),mt=(t,e)=>{switch(typeof e){case"string":A(t,119),el(t,e);break;case"number":if(xr(e)&&nt(e)<=wr)A(t,125),ke(t,e);else if(Ni(e))A(t,124),Bi(t,e);else A(t,123),Oi(t,e);break;case"bigint":A(t,122),vi(t,e);break;case"object":if(e===null)A(t,126);else if(Z(e)){A(t,117),_t(t,e.length);for(let r=0;r<e.length;r++)mt(t,e[r])}else if(e instanceof Uint8Array)A(t,116),Wr(t,e);else{A(t,118);let r=Object.keys(e);_t(t,r.length);for(let s=0;s<r.length;s++){let i=r[s];el(t,i),mt(t,e[i])}}break;case"boolean":A(t,e?120:121);break;default:A(t,127)}};class _e extends wt{constructor(t){super();this.w=t,this.s=null,this.count=0}write(t){if(this.s===t)this.count++;else{if(this.count>0)_t(this,this.count-1);this.count=1,this.w(this,t),this.s=t}}}var _r=(t)=>{if(t.count>0){if(ke(t.encoder,t.count===1?t.s:-t.s),t.count>1)_t(t.encoder,t.count-2)}};class xt{constructor(){this.encoder=new wt,this.s=0,this.count=0}write(t){if(this.s===t)this.count++;else _r(this),this.count=1,this.s=t}toUint8Array(){return _r(this),yo(this.encoder)}}var Sr=(t)=>{if(t.count>0){let e=t.diff*2+(t.count===1?0:1);if(ke(t.encoder,e),t.count>1)_t(t.encoder,t.count-2)}};class Gt{constructor(){this.encoder=new wt,this.s=0,this.count=0,this.diff=0}write(t){if(this.diff===t-this.s)this.s=t,this.count++;else Sr(this),this.count=1,this.diff=t-this.s,this.s=t}toUint8Array(){return Sr(this),yo(this.encoder)}}class wn{constructor(){this.sarr=[],this.s="",this.lensE=new xt}write(t){if(this.s+=t,this.s.length>19)this.sarr.push(this.s),this.s="";this.lensE.write(t.length)}toUint8Array(){let t=new wt;return this.sarr.push(this.s),this.s="",el(t,this.sarr.join("")),qt(t,this.lensE.toUint8Array()),yo(t)}}var R=(t)=>Error(t),L=()=>{throw R("Method unimplemented")},v=()=>{throw R("Unexpected case")};var Se=R("Unexpected end of array"),Ir=R("Integer out of Range"),Ri=(t,e,r)=>{if(e<0||r<0||e+r>t.length)throw Se;return new Uint8Array(t.buffer,t.byteOffset+e,r)},Li=(t,e,r)=>{if(e<0||r<0||e+r>t.length)throw Se;return new DataView(t.buffer,t.byteOffset+e,r)};class zt{constructor(t){this.arr=t,this.pos=0}}var tl=(t)=>new zt(t),Ur=(t)=>t.pos!==t.arr.length;var Vi=(t,e)=>{let r=Ri(t.arr,t.pos,e);return t.pos+=e,r},Xr=(t)=>Vi(t,Nt(t));var rt=(t)=>t.arr[t.pos++];var Nt=(t)=>{let e=0,r=1,s=t.arr.length;while(t.pos<s){let i=t.arr[t.pos++];if(e=e+(i&Q)*r,r*=128,i<D)return e;if(e>ft)throw Ir}throw Se},Ee=(t)=>{let e=t.arr[t.pos++],r=e&jt,s=64,i=(e&F)>0?-1:1;if((e&D)===0)return i*r;let o=t.arr.length;while(t.pos<o){if(e=t.arr[t.pos++],r=r+(e&Q)*s,s*=128,e<D)return i*r;if(r>ft)throw Ir}throw Se};var Mi=(t)=>{let e=Nt(t);if(e===0)return"";else{let r=String.fromCodePoint(rt(t));if(--e<100)while(e--)r+=String.fromCodePoint(rt(t));else while(e>0){let s=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+s);t.pos+=s,r+=String.fromCodePoint.apply(null,i),e-=s}return decodeURIComponent(escape(r))}},$i=(t)=>pt.decode(Xr(t)),nl=pt?$i:Mi;var yn=(t,e)=>{let r=Li(t.arr,t.pos,e);return t.pos+=e,r},Fi=(t)=>yn(t,4).getFloat32(0,!1),ji=(t)=>yn(t,8).getFloat64(0,!1),qi=(t)=>yn(t,8).getBigInt64(0,!1);var Gi=[(t)=>{return},(t)=>null,Ee,Fi,ji,qi,(t)=>!1,(t)=>!0,nl,(t)=>{let e=Nt(t),r={};for(let s=0;s<e;s++){let i=nl(t);r[i]=yt(t)}return r},(t)=>{let e=Nt(t),r=[];for(let s=0;s<e;s++)r.push(yt(t));return r},Xr],yt=(t)=>Gi[127-rt(t)](t);class Ie extends zt{constructor(t,e){super(t);this.reader=e,this.s=null,this.count=0}read(){if(this.count===0)if(this.s=this.reader(this),Ur(this))this.count=Nt(this)+1;else this.count=-1;return this.count--,this.s}}class bt extends zt{constructor(t){super(t);this.s=0,this.count=0}read(){if(this.count===0){this.s=Ee(this);let t=me(this.s);if(this.count=1,t)this.s=-this.s,this.count=Nt(this)+2}return this.count--,this.s}}class Ht extends zt{constructor(t){super(t);this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let t=Ee(this),e=t&1;if(this.diff=rs(t/2),this.count=1,e)this.count=Nt(this)+2}return this.s+=this.diff,this.count--,this.s}}class bn{constructor(t){this.decoder=new bt(t),this.str=nl(this.decoder),this.spos=0}read(){let t=this.spos+this.decoder.read(),e=this.str.slice(this.spos,t);return this.spos=t,e}}var rl=crypto.subtle,Ar=crypto.getRandomValues.bind(crypto);var kn=()=>Ar(new Uint32Array(1))[0];var zi=[1e7]+-1000+-4000+-8000+-100000000000,Cr=()=>zi.replace(/[018]/g,(t)=>(t^kn()&15>>t/4).toString(16));var Lu=Date.now;var _n=(t)=>new Promise(t);var ol=Promise.all.bind(Promise);var Sn=(t)=>t===void 0?null:t;class Br{constructor(){this.map=new Map}setItem(t,e){this.map.set(t,e)}getItem(t){return this.map.get(t)}}var Or=new Br,Ki=!0;try{if(typeof localStorage<"u"&&localStorage)Or=localStorage,Ki=!1}catch(t){}var vr=Or;var st=Symbol("Equality"),Ue=(t,e)=>t===e||!!t?.[st]?.(e)||!1;var Nr=(t)=>typeof t==="object",{assign:Rr,keys:Zi}=Object;var Lr=(t,e)=>{for(let r in t)e(t[r],r)};var Jt=(t)=>Zi(t).length;var Vr=(t)=>{for(let e in t)return!1;return!0},kt=(t,e)=>{for(let r in t)if(!e(t[r],r))return!1;return!0},Pt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),In=(t,e)=>t===e||Jt(t)===Jt(e)&&kt(t,(r,s)=>(r!==void 0||Pt(e,s))&&Ue(e[s],r)),Xi=Object.freeze,Un=(t)=>{for(let e in t){let r=t[e];if(typeof r==="object"||typeof r==="function")Un(t[e])}return Xi(t)};var Kt=(t,e,r=0)=>{try{for(;r<t.length;r++)t[r](...e)}finally{if(r<t.length)Kt(t,e,r+1)}};var Mr=(t)=>t;var hp=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[st]!=null)return t[st](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;break}case Set:{if(t.size!==e.size)return!1;for(let r of t)if(!e.has(r))return!1;break}case Map:{if(t.size!==e.size)return!1;for(let r of t.keys())if(!e.has(r)||!hp(t.get(r),e.get(r)))return!1;break}case void 0:case Object:if(Jt(t)!==Jt(e))return!1;for(let r in t)if(!Pt(t,r)||!hp(t[r],e[r]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!hp(t[r],e[r]))return!1;break;default:return!1}return!0},$r=(t,e)=>e.includes(t);var Wt=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";var cl=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,z,Qi=[],Yi=()=>{if(z===void 0)if(Wt){z=T();let t=process.argv,e=null;for(let r=0;r<t.length;r++){let s=t[r];if(s[0]==="-"){if(e!==null)z.set(e,"");e=s}else if(e!==null)z.set(e,s),e=null;else Qi.push(s)}if(e!==null)z.set(e,"")}else if(typeof location==="object")z=T(),(location.search||"?").slice(1).split("&").forEach((t)=>{if(t.length!==0){let[e,r]=t.split("=");z.set(`--${pn(e,"-")}`,r),z.set(`-${pn(e,"-")}`,r)}});else z=T();return z},Cn=(t)=>Yi().has(t);var Zt=(t)=>Wt?Sn(process.env[t.toUpperCase().replaceAll("-","_")]):Sn(vr.getItem(t));var Fr=(t)=>Cn("--"+t)||Zt(t)!==null,jr=Fr("production"),to=Wt&&$r(process.env.FORCE_COLOR,["true","1","2"]),qr=to||!Cn("--no-colors")&&!Fr("no-color")&&(!Wt||process.stdout.isTTY)&&(!Wt||Cn("--color")||Zt("COLORTERM")!==null||(Zt("TERM")||"").includes("color"));var eo=(t)=>new Uint8Array(t);var Gr=(t)=>{let e=eo(t.byteLength);return e.set(t),e};class zr{constructor(t,e){this.left=t,this.right=e}}var H=(t,e)=>new zr(t,e);var Bn=(t)=>t.next()>=0.5,Te=(t,e,r)=>rs(t.next()*(r+1-e)+e);var On=(t,e,r)=>rs(t.next()*(r+1-e)+e);var vn=(t,e,r)=>On(t,e,r);var so=(t)=>fn(vn(t,97,122)),Hr=(t,e=0,r=20)=>{let s=vn(t,e,r),i="";for(let o=0;o<s;o++)i+=so(t);return i};var Ae=(t,e)=>e[vn(t,0,e.length-1)];var oo=Symbol("0schema");class Pr{constructor(){this._rerrs=[]}extend(t,e,r,s=null){this._rerrs.push({path:t,expected:e,has:r,message:s})}toString(){let t=[];for(let e=this._rerrs.length-1;e>0;e--){let r=this._rerrs[e];t.push(br(" ",(this._rerrs.length-e)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return t.join(`
2
+ `)}}var Nn=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor)return!1;if(t[st])return Ue(t,e);if(Z(t))return fe(t,(r)=>Vt(e,(s)=>Nn(r,s)));else if(Nr(t))return kt(t,(r,s)=>Nn(r,e[s]));return!1};class B{static _dilutes=!1;extends(t){let[e,r]=[this.shape,t.shape];if(this.constructor._dilutes)[r,e]=[e,r];return Nn(e,r)}equals(t){return this.constructor===t.constructor&&hp(this.shape,t.shape)}[oo](){return!0}[st](t){return this.equals(t)}validate(t){return this.check(t)}check(t,e){L()}get nullable(){return Ut(this,Ve)}get optional(){return new Rn(this)}cast(t){return Jr(t,this),t}expect(t){return Jr(t,this),t}}class Be extends B{constructor(t,e){super();this.shape=t,this._c=e}check(t,e=void 0){let r=t?.constructor===this.shape&&(this._c==null||this._c(t));return!r&&e?.extend(null,this.shape.name,t?.constructor.name,t?.constructor!==this.shape?"Constructor match failed":"Check failed"),r}}var _=(t,e=null)=>new Be(t,e),al=_(Be);class Oe extends B{constructor(t){super();this.shape=t}check(t,e){let r=this.shape(t);return!r&&e?.extend(null,"custom prop",t?.constructor.name,"failed to check custom prop"),r}}var E=(t)=>new Oe(t),hl=_(Oe);class Qt extends B{constructor(t){super();this.shape=t}check(t,e){let r=this.shape.some((s)=>s===t);return!r&&e?.extend(null,this.shape.join(" | "),t.toString()),r}}var ve=(...t)=>new Qt(t),Kr=_(Qt),co=RegExp.escape||((t)=>t.replace(/[().|&,$^[\]]/g,(e)=>"\\"+e)),Zr=(t)=>{if(It.check(t))return[co(t)];if(Kr.check(t))return t.shape.map((e)=>e+"");if(ls.check(t))return["[+-]?\\d+.?\\d*"];if(as.check(t))return[".*"];if(Ce.check(t))return t.shape.map(Zr).flat(1);v()};class Qr extends B{constructor(t){super();this.shape=t,this._r=new RegExp("^"+t.map(Zr).map((e)=>`(${e.join("|")})`).join("")+"$")}check(t,e){let r=this._r.exec(t)!=null;return!r&&e?.extend(null,this._r.toString(),t.toString(),"String doesn't match string template."),r}}var ul=_(Qr),lo=Symbol("optional");class Rn extends B{constructor(t){super();this.shape=t}check(t,e){let r=t===void 0||this.shape.check(t);return!r&&e?.extend(null,"undefined (optional)","()"),r}get[lo](){return!0}}var ao=_(Rn);class Ln extends B{check(t,e){return e?.extend(null,"never",typeof t),!1}}var dl=new Ln,fl=_(Ln);class Ne extends B{constructor(t,e=!1){super();this.shape=t,this._isPartial=e}static _dilutes=!0;get partial(){return new Ne(this.shape,!0)}check(t,e){if(t==null)return e?.extend(null,"object","null"),!1;return kt(this.shape,(r,s)=>{let i=this._isPartial&&!Pt(t,s)||r.check(t[s],e);return!i&&e?.extend(s.toString(),r.toString(),typeof t[s],"Object property does not match"),i})}}var ho=(t)=>new Ne(t),uo=_(Ne),fo=E((t)=>t!=null&&(t.constructor===Object||t.constructor==null));class Vn extends B{constructor(t,e){super();this.shape={keys:t,values:e}}check(t,e){return t!=null&&kt(t,(r,s)=>{let i=this.shape.keys.check(s,e);return!i&&e?.extend(s+"","Record",typeof t,i?"Key doesn't match schema":"Value doesn't match value"),i&&this.shape.values.check(r,e)})}}var Yr=(t,e)=>new Vn(t,e),po=_(Vn);class Mn extends B{constructor(t){super();this.shape=t}check(t,e){return t!=null&&kt(this.shape,(r,s)=>{let i=r.check(t[s],e);return!i&&e?.extend(s.toString(),"Tuple",typeof r),i})}}var go=(...t)=>new Mn(t),pl=_(Mn);class $n extends B{constructor(t){super();this.shape=t.length===1?t[0]:new Re(t)}check(t,e){let r=Z(t)&&fe(t,(s)=>this.shape.check(s));return!r&&e?.extend(null,"Array",""),r}}var ts=(...t)=>new $n(t),mo=_($n),wo=E((t)=>Z(t));class Fn extends B{constructor(t,e){super();this.shape=t,this._c=e}check(t,e){let r=t instanceof this.shape&&(this._c==null||this._c(t));return!r&&e?.extend(null,this.shape.name,t?.constructor.name),r}}var xo=(t,e=null)=>new Fn(t,e),gl=_(Fn),bo=xo(B);class es extends B{constructor(t){super();this.len=t.length-1,this.args=go(...t.slice(-1)),this.res=t[this.len]}check(t,e){let r=t.constructor===Function&&t.length<=this.len;return!r&&e?.extend(null,"function",typeof t),r}}var ko=_(es),_o=E((t)=>typeof t==="function");class ns extends B{constructor(t){super();this.shape=t}check(t,e){let r=fe(this.shape,(s)=>s.check(t,e));return!r&&e?.extend(null,"Intersectinon",typeof t),r}}var ml=_(ns,(t)=>t.shape.length>0);class Re extends B{static _dilutes=!0;constructor(t){super();this.shape=t}check(t,e){let r=Vt(this.shape,(s)=>s.check(t,e));return e?.extend(null,"Union",typeof t),r}}var Ut=(...t)=>t.findIndex((e)=>Ce.check(e))>=0?Ut(...t.map((e)=>Xt(e)).map((e)=>Ce.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new Re(t),Ce=_(Re),is=()=>!0,De=E(is),So=_(Oe,(t)=>t.shape===is),jn=E((t)=>typeof t==="bigint"),Eo=E((t)=>t===jn),cs=E((t)=>typeof t==="symbol"),wl=E((t)=>t===cs),Et=E((t)=>typeof t==="number"),ls=E((t)=>t===Et),It=E((t)=>typeof t==="string"),as=E((t)=>t===It),Le=E((t)=>typeof t==="boolean"),Io=E((t)=>t===Le),hs=ve(void 0),xl=_(Qt,(t)=>t.shape.length===1&&t.shape[0]===void 0),yl=ve(void 0);var Ve=ve(null),Uo=_(Qt,(t)=>t.shape.length===1&&t.shape[0]===null),bl=_(Uint8Array),kl=_(Be,(t)=>t.shape===Uint8Array),To=Ut(Et,It,Ve,hs,jn,Le,cs),_l=(()=>{let t=ts(De),e=Yr(It,De),r=Ut(Et,It,Ve,Le,t,e);return t.shape=r,e.shape.values=r,r})(),Xt=(t)=>{if(bo.check(t))return t;else if(fo.check(t)){let e={};for(let r in t)e[r]=Xt(t[r]);return ho(e)}else if(wo.check(t))return Ut(...t.map(Xt));else if(To.check(t))return ve(t);else if(_o.check(t))return _(t);v()},Jr=jr?()=>{}:(t,e)=>{let r=new Pr;if(!e.check(t,r))throw R(`Expected value to be of type ${e.constructor.name}.
3
+ ${r.toString()}`)};class us{constructor(t){this.patterns=[],this.$state=t}if(t,e){return this.patterns.push({if:Xt(t),h:e}),this}else(t){return this.if(De,t)}done(){return(t,e)=>{for(let r=0;r<this.patterns.length;r++){let s=this.patterns[r];if(s.if.check(t))return s.h(t,e)}throw R("Unhandled pattern")}}}var Ao=(t)=>new us(t),ds=Ao(De).if(ls,(t,e)=>Te(e,un,ft)).if(as,(t,e)=>Hr(e)).if(Io,(t,e)=>Bn(e)).if(Eo,(t,e)=>BigInt(Te(e,un,ft))).if(Ce,(t,e)=>St(e,Ae(e,t.shape))).if(uo,(t,e)=>{let r={};for(let s in t.shape){let i=t.shape[s];if(ao.check(i)){if(Bn(e))continue;i=i.shape}r[s]=ds(i,e)}return r}).if(mo,(t,e)=>{let r=[],s=On(e,0,42);for(let i=0;i<s;i++)r.push(St(e,t.shape));return r}).if(Kr,(t,e)=>Ae(e,t.shape)).if(Uo,(t,e)=>null).if(ko,(t,e)=>{let r=St(e,t.res);return()=>r}).if(So,(t,e)=>St(e,Ae(e,[Et,It,Ve,hs,jn,Le,ts(Et),Yr(Ut("a","b","c"),Et)]))).if(po,(t,e)=>{let r={},s=Te(e,0,3);for(let i=0;i<s;i++){let o=St(e,t.shape.keys),c=St(e,t.shape.values);r[o]=c}return r}).done(),St=(t,e)=>ds(Xt(e),t);var it=typeof document<"u"?document:{};var Sl=E((t)=>t.nodeType===vo);var El=typeof DOMParser<"u"?new DOMParser:null;var Il=E((t)=>t.nodeType===Do);var Ul=E((t)=>t.nodeType===Bo);var fs=(t)=>fr(t,(e,r)=>`${r}:${e};`).join("");var{ELEMENT_NODE:Do,TEXT_NODE:Bo,CDATA_SECTION_NODE:Tl,COMMENT_NODE:Al,DOCUMENT_NODE:Oo,DOCUMENT_TYPE_NODE:Cl,DOCUMENT_FRAGMENT_NODE:vo}=it,Dl=E((t)=>t.nodeType===Oo);var J=Symbol;var Yt=J(),te=J(),qn=J(),Gn=J(),zn=J(),ee=J(),Hn=J(),Tt=J(),Jn=J(),ps=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],r=[],s=0;for(;s<t.length;s++){let i=t[s];if(i===void 0)break;else if(i.constructor===String||i.constructor===Number)e.push(i);else if(i.constructor===Object)break}if(s>0)r.push(e.join(""));for(;s<t.length;s++){let i=t[s];if(!(i instanceof Symbol))r.push(i)}return r};var Bl=Lu();var Vo={[Yt]:H("font-weight","bold"),[te]:H("font-weight","normal"),[qn]:H("color","blue"),[zn]:H("color","green"),[Gn]:H("color","grey"),[ee]:H("color","red"),[Hn]:H("color","purple"),[Tt]:H("color","orange"),[Jn]:H("color","black")},Mo=(t)=>{if(t.length===1&&t[0]?.constructor===Function)t=t[0]();let e=[],r=[],s=T(),i=[],o=0;for(;o<t.length;o++){let c=t[o],l=Vo[c];if(l!==void 0)s.set(l.left,l.right);else{if(c===void 0)break;if(c.constructor===String||c.constructor===Number){let h=fs(s);if(o>0||h.length>0)e.push("%c"+c),r.push(h);else e.push(c)}else break}}if(o>0)i=r,i.unshift(e.join(""));for(;o<t.length;o++){let c=t[o];if(!(c instanceof Symbol))i.push(c)}return i},gs=qr?Mo:ps,ms=(...t)=>{console.log(...gs(t)),ws.forEach((e)=>e.print(t))},Pn=(...t)=>{console.warn(...gs(t)),t.unshift(Tt),ws.forEach((e)=>e.print(t))};var ws=G();var xs=(t)=>({[Symbol.iterator](){return this},next:t}),ys=(t,e)=>xs(()=>{let r;do r=t.next();while(!r.done&&!e(r.value));return r}),Me=(t,e)=>xs(()=>{let{done:r,value:s}=t.next();return{done:r,value:r?void 0:e(s)}});class oe{constructor(t,e){this.clock=t,this.len=e}}class ht{constructor(){this.clients=new Map}}var Dt=(t,e,r)=>e.clients.forEach((s,i)=>{let o=t.doc.store.clients.get(i);if(o!=null){let c=o[o.length-1],l=c.id.clock+c.length;for(let h=0,f=s[h];h<s.length&&f.clock<l;f=s[++h])Ps(t,o,f.clock,f.len,r)}}),jo=(t,e)=>{let r=0,s=t.length-1;while(r<=s){let i=rs((r+s)/2),o=t[i],c=o.clock;if(c<=e){if(e<c+o.len)return i;r=i+1}else s=i-1}return null},ce=(t,e)=>{let r=t.clients.get(e.client);return r!==void 0&&jo(r,e.clock)!==null},Yn=(t)=>{t.clients.forEach((e)=>{e.sort((i,o)=>i.clock-o.clock);let r,s;for(r=1,s=1;r<e.length;r++){let i=e[s-1],o=e[r];if(i.clock+i.len>=o.clock)e[s-1]=new oe(i.clock,X(i.len,o.clock+o.len-i.clock));else{if(s<r)e[s]=o;s++}}e.length=s})},Wn=(t)=>{let e=new ht;for(let r=0;r<t.length;r++)t[r].clients.forEach((s,i)=>{if(!e.clients.has(i)){let o=s.slice();for(let c=r+1;c<t.length;c++)gr(o,t[c].clients.get(i)||[]);e.clients.set(i,o)}});return Yn(e),e},ne=(t,e,r,s)=>{j(t.clients,e,()=>[]).push(new oe(r,s))},Ns=()=>new ht,qo=(t)=>{let e=Ns();return t.clients.forEach((r,s)=>{let i=[];for(let o=0;o<r.length;o++){let c=r[o];if(c.deleted){let l=c.id.clock,h=c.length;if(o+1<r.length)for(let f=r[o+1];o+1<r.length&&f.deleted;f=r[++o+1])h+=f.length;i.push(new oe(l,h))}}if(i.length>0)e.clients.set(s,i)}),e},Ot=(t,e)=>{_t(t.restEncoder,e.clients.size),q(e.clients.entries()).sort((r,s)=>s[0]-r[0]).forEach(([r,s])=>{t.resetDsCurVal(),_t(t.restEncoder,r);let i=s.length;_t(t.restEncoder,i);for(let o=0;o<i;o++){let c=s[o];t.writeDsClock(c.clock),t.writeDsLen(c.len)}})},tr=(t)=>{let e=new ht,r=Nt(t.restDecoder);for(let s=0;s<r;s++){t.resetDsCurVal();let i=Nt(t.restDecoder),o=Nt(t.restDecoder);if(o>0){let c=j(e.clients,i,()=>[]);for(let l=0;l<o;l++)c.push(new oe(t.readDsClock(),t.readDsLen()))}}return e},bs=(t,e,r)=>{let s=new ht,i=Nt(t.restDecoder);for(let o=0;o<i;o++){t.resetDsCurVal();let c=Nt(t.restDecoder),l=Nt(t.restDecoder),h=r.clients.get(c)||[],f=b(r,c);for(let a=0;a<l;a++){let u=t.readDsClock(),d=u+t.readDsLen();if(u<f){if(f<d)ne(s,c,f,d-f);let p=P(h,u),g=h[p];if(!g.deleted&&g.id.clock<u)h.splice(p+1,0,Ye(e,g,u-g.id.clock)),p++;while(p<h.length)if(g=h[p++],g.id.clock<d){if(!g.deleted){if(d<g.id.clock+g.length)h.splice(p,0,Ye(e,g,d-g.id.clock));g.delete(e)}}else break}else ne(s,c,u,d-u)}}if(s.clients.size>0){let o=new et;return _t(o.restEncoder,0),Ot(o,s),o.toUint8Array()}return null};var Rs=kn;class Td extends pe{constructor({guid:t=Cr(),collectionid:e=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:c=!0}={}){super();this.gc=r,this.gcFilter=s,this.clientID=Rs(),this.guid=t,this.collectionid=e,this.share=new Map,this.store=new or,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=_n((h)=>{this.on("load",()=>{this.isLoaded=!0,h(this)})});let l=()=>_n((h)=>{let f=(a)=>{if(a===void 0||a===!0)this.off("sync",f),h()};this.on("sync",f)});this.on("sync",(h)=>{if(h===!1&&this.isSynced)this.whenSynced=l();if(this.isSynced=h===void 0||h===!0,this.isSynced&&!this.isLoaded)this.emit("load",[this])}),this.whenSynced=l()}load(){let t=this._item;if(t!==null&&!this.shouldLoad)x(t.parent.doc,(e)=>{e.subdocsLoaded.add(this)},null,!0);this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(q(this.subdocs).map((t)=>t.guid))}transact(t,e=null){return x(this,t,e)}get(t,e=I){let r=j(this.share,t,()=>{let i=new e;return i._integrate(this,null),i}),s=r.constructor;if(e!==I&&s!==e)if(s===I){let i=new e;i._map=r._map,r._map.forEach((o)=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(t,i),i._integrate(this,null),i}else throw Error(`Type with the name ${t} has already been defined with a different constructor`);return r}getArray(t=""){return this.get(t,Ca)}getText(t=""){return this.get(t,ss)}getMap(t=""){return this.get(t,os)}getXmlElement(t=""){return this.get(t,Bt)}getXmlFragment(t=""){return this.get(t,lt)}toJSON(){let t={};return this.share.forEach((e,r)=>{t[r]=e.toJSON()}),t}destroy(){this.isDestroyed=!0,q(this.subdocs).forEach((e)=>e.destroy());let t=this._item;if(t!==null){this._item=null;let e=t.content;e.doc=new Td({guid:this.guid,...e.opts,shouldLoad:!1}),e.doc._item=t,x(t.parent.doc,(r)=>{let s=e.doc;if(!t.deleted)r.subdocsAdded.add(s);r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class er{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return Nt(this.restDecoder)}readDsLen(){return Nt(this.restDecoder)}}class nr extends er{readLeftID(){return m(Nt(this.restDecoder),Nt(this.restDecoder))}readRightID(){return m(Nt(this.restDecoder),Nt(this.restDecoder))}readClient(){return Nt(this.restDecoder)}readInfo(){return rt(this.restDecoder)}readString(){return nl(this.restDecoder)}readParentInfo(){return Nt(this.restDecoder)===1}readTypeRef(){return Nt(this.restDecoder)}readLen(){return Nt(this.restDecoder)}readAny(){return yt(this.restDecoder)}readBuf(){return Gr(Xr(this.restDecoder))}readJSON(){return JSON.parse(nl(this.restDecoder))}readKey(){return nl(this.restDecoder)}}class Ls{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Nt(this.restDecoder),this.dsCurrVal}readDsLen(){let t=Nt(this.restDecoder)+1;return this.dsCurrVal+=t,t}}class ct extends Ls{constructor(t){super(t);this.keys=[],Nt(t),this.keyClockDecoder=new Ht(Xr(t)),this.clientDecoder=new bt(Xr(t)),this.leftClockDecoder=new Ht(Xr(t)),this.rightClockDecoder=new Ht(Xr(t)),this.infoDecoder=new Ie(Xr(t),rt),this.stringDecoder=new bn(Xr(t)),this.parentInfoDecoder=new Ie(Xr(t),rt),this.typeRefDecoder=new bt(Xr(t)),this.lenDecoder=new bt(Xr(t))}readLeftID(){return new ot(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ot(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return yt(this.restDecoder)}readBuf(){return Xr(this.restDecoder)}readJSON(){return yt(this.restDecoder)}readKey(){let t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];else{let e=this.stringDecoder.read();return this.keys.push(e),e}}}class rr{constructor(){this.restEncoder=Qa()}toUint8Array(){return yo(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){_t(this.restEncoder,t)}writeDsLen(t){_t(this.restEncoder,t)}}class vt extends rr{writeLeftID(t){_t(this.restEncoder,t.client),_t(this.restEncoder,t.clock)}writeRightID(t){_t(this.restEncoder,t.client),_t(this.restEncoder,t.clock)}writeClient(t){_t(this.restEncoder,t)}writeInfo(t){be(this.restEncoder,t)}writeString(t){el(this.restEncoder,t)}writeParentInfo(t){_t(this.restEncoder,t?1:0)}writeTypeRef(t){_t(this.restEncoder,t)}writeLen(t){_t(this.restEncoder,t)}writeAny(t){mt(this.restEncoder,t)}writeBuf(t){Wr(this.restEncoder,t)}writeJSON(t){el(this.restEncoder,JSON.stringify(t))}writeKey(t){el(this.restEncoder,t)}}class sr{constructor(){this.restEncoder=Qa(),this.dsCurrVal=0}toUint8Array(){return yo(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let e=t-this.dsCurrVal;this.dsCurrVal=t,_t(this.restEncoder,e)}writeDsLen(t){if(t===0)v();_t(this.restEncoder,t-1),this.dsCurrVal+=t}}class et extends sr{constructor(){super();this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Gt,this.clientEncoder=new xt,this.leftClockEncoder=new Gt,this.rightClockEncoder=new Gt,this.infoEncoder=new _e(be),this.stringEncoder=new wn,this.parentInfoEncoder=new _e(be),this.typeRefEncoder=new xt,this.lenEncoder=new xt}toUint8Array(){let t=Qa();return _t(t,0),Wr(t,this.keyClockEncoder.toUint8Array()),Wr(t,this.clientEncoder.toUint8Array()),Wr(t,this.leftClockEncoder.toUint8Array()),Wr(t,this.rightClockEncoder.toUint8Array()),Wr(t,yo(this.infoEncoder)),Wr(t,this.stringEncoder.toUint8Array()),Wr(t,yo(this.parentInfoEncoder)),Wr(t,this.typeRefEncoder.toUint8Array()),Wr(t,this.lenEncoder.toUint8Array()),qt(t,yo(this.restEncoder)),yo(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){mt(this.restEncoder,t)}writeBuf(t){Wr(this.restEncoder,t)}writeJSON(t){mt(this.restEncoder,t)}writeKey(t){let e=this.keyMap.get(t);if(e===void 0)this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t);else this.keyClockEncoder.write(e)}}var Go=(t,e,r,s)=>{s=X(s,e[0].id.clock);let i=P(e,s);_t(t.restEncoder,e.length-i),t.writeClient(r),_t(t.restEncoder,s);let o=e[i];o.write(t,s-o.id.clock);for(let c=i+1;c<e.length;c++)e[c].write(t,0)},ir=(t,e,r)=>{let s=new Map;r.forEach((i,o)=>{if(b(e,o)>i)s.set(o,i)}),tn(e).forEach((i,o)=>{if(!r.has(o))s.set(o,0)}),_t(t.restEncoder,s.size),q(s.entries()).sort((i,o)=>o[0]-i[0]).forEach(([i,o])=>{Go(t,e.clients.get(i),i,o)})},zo=(t,e)=>{let r=T(),s=Nt(t.restDecoder);for(let i=0;i<s;i++){let o=Nt(t.restDecoder),c=Array(o),l=t.readClient(),h=Nt(t.restDecoder);r.set(l,{i:0,refs:c});for(let f=0;f<o;f++){let a=t.readInfo();switch(Ft&a){case 0:{let u=t.readLen();c[f]=new V(m(l,h),u),h+=u;break}case 10:{let u=Nt(t.restDecoder);c[f]=new M(m(l,h),u),h+=u;break}default:{let u=(a&(F|D))===0,d=new y(m(l,h),null,(a&D)===D?t.readLeftID():null,null,(a&F)===F?t.readRightID():null,u?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,u&&(a&dt)===dt?t.readString():null,wi(t,a));c[f]=d,h+=d.length}}}}return r},Ho=(t,e,r)=>{let s=[],i=q(r.keys()).sort((p,g)=>p-g);if(i.length===0)return null;let o=()=>{if(i.length===0)return null;let p=r.get(i[i.length-1]);while(p.refs.length===p.i)if(i.pop(),i.length>0)p=r.get(i[i.length-1]);else return null;return p},c=o();if(c===null)return null;let l=new or,h=new Map,f=(p,g)=>{let w=h.get(p);if(w==null||w>g)h.set(p,g)},a=c.refs[c.i++],u=new Map,d=()=>{for(let p of s){let g=p.id.client,w=r.get(g);if(w)w.i--,l.clients.set(g,w.refs.slice(w.i)),r.delete(g),w.i=0,w.refs=[];else l.clients.set(g,[p]);i=i.filter((C)=>C!==g)}s.length=0};while(!0){if(a.constructor!==M){let g=j(u,a.id.client,()=>b(e,a.id.client))-a.id.clock;if(g<0)s.push(a),f(a.id.client,a.id.clock-1),d();else{let w=a.getMissing(t,e);if(w!==null){s.push(a);let C=r.get(w)||{refs:[],i:0};if(C.refs.length===C.i)f(w,b(e,w)),d();else{a=C.refs[C.i++];continue}}else if(g===0||g<a.length)a.integrate(t,g),u.set(a.id.client,a.id.clock+a.length)}}if(s.length>0)a=s.pop();else if(c!==null&&c.i<c.refs.length)a=c.refs[c.i++];else if(c=o(),c===null)break;else a=c.refs[c.i++]}if(l.clients.size>0){let p=new et;return ir(p,l,new Map),_t(p.restEncoder,0),{missing:h,update:p.toUint8Array()}}return null},Jo=(t,e)=>ir(t,e.doc.store,e.beforeState),Po=(t,e,r,s=new ct(t))=>x(e,(i)=>{i.local=!1;let o=!1,c=i.doc,l=c.store,h=zo(s,c),f=Ho(i,l,h),a=l.pendingStructs;if(a){for(let[d,p]of a.missing)if(p<b(l,d)){o=!0;break}if(f){for(let[d,p]of f.missing){let g=a.missing.get(d);if(g==null||g>p)a.missing.set(d,p)}a.update=Je([a.update,f.update])}}else l.pendingStructs=f;let u=bs(s,i,l);if(l.pendingDs){let d=new ct(tl(l.pendingDs));Nt(d.restDecoder);let p=bs(d,i,l);if(u&&p)l.pendingDs=Je([u,p]);else l.pendingDs=u||p}else l.pendingDs=u;if(o){let d=l.pendingStructs.update;l.pendingStructs=null,Vs(i.doc,d)}},r,!1);var Vs=(t,e,r,s=ct)=>{let i=tl(e);Po(i,t,r,new s(i))},XI=(t,e,r)=>Vs(t,e,r,nr),Ko=(t,e,r=new Map)=>{ir(t,e.store,r),Ot(t,qo(e.store))},Wo=(t,e=new Uint8Array([0]),r=new et)=>{let s=Ms(e);Ko(r,t,s);let i=[r.toUint8Array()];if(t.store.pendingDs)i.push(t.store.pendingDs);if(t.store.pendingStructs)i.push(ac(t.store.pendingStructs.update,e));if(i.length>1){if(r.constructor===vt)return cc(i.map((o,c)=>c===0?o:uc(o)));else if(r.constructor===et)return Je(i)}return i[0]},QI=(t,e)=>Wo(t,e,new vt),Zo=(t)=>{let e=new Map,r=Nt(t.restDecoder);for(let s=0;s<r;s++){let i=Nt(t.restDecoder),o=Nt(t.restDecoder);e.set(i,o)}return e},Ms=(t)=>Zo(new er(tl(t))),$s=(t,e)=>(_t(t.restEncoder,e.size),q(e.entries()).sort((r,s)=>s[0]-r[0]).forEach(([r,s])=>{_t(t.restEncoder,r),_t(t.restEncoder,s)}),t),Xo=(t,e)=>$s(t,tn(e.store)),Qo=(t,e=new sr)=>{if(t instanceof Map)$s(e,t);else Xo(e,t);return e.toUint8Array()},eN=(t)=>Qo(t,new rr);class Fs{constructor(){this.l=[]}}var ks=()=>new Fs,_s=(t,e)=>t.l.push(e),Ss=(t,e)=>{let r=t.l,s=r.length;if(t.l=r.filter((i)=>e!==i),s===t.l.length)console.error("[yjs] Tried to remove event handler that doesn't exist.")},js=(t,e,r)=>Kt(t.l,[e,r]);class ot{constructor(t,e){this.client=t,this.clock=e}}var $e=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,m=(t,e)=>new ot(t,e);var qs=(t)=>{for(let[e,r]of t.doc.share.entries())if(r===t)return e;throw v()},He=(t,e)=>{while(e!==null){if(e.parent===t)return!0;e=e.parent._item}return!1};class Gs{constructor(t,e,r,s=0){this.type=t,this.tname=e,this.item=r,this.assoc=s}}class zs{constructor(t,e,r=0){this.type=t,this.index=e,this.assoc=r}}var Yo=(t,e,r=0)=>new zs(t,e,r),Fe=(t,e,r)=>{let s=null,i=null;if(t._item===null)i=qs(t);else s=m(t._item.id.client,t._item.id.clock);return new Gs(s,i,e,r)},OS=(t,e,r=0)=>{let s=t._start;if(r<0){if(e===0)return Fe(t,null,r);e--}while(s!==null){if(!s.deleted&&s.countable){if(s.length>e)return Fe(t,m(s.id.client,s.id.clock+e),r);e-=s.length}if(s.right===null&&r<0)return Fe(t,s.lastId,r);s=s.right}return Fe(t,null,r)};var tc=(t,e)=>{let r=Ct(t,e),s=e.clock-r.id.clock;return{item:r,diff:s}},nb=(t,e,r=!0)=>{let s=e.store,{item:i,type:o,tname:c,assoc:l}=t,h=null,f=0;if(i!==null){if(b(s,i.client)<=i.clock)return null;let a=r?Qn(s,i):tc(s,i),u=a.item;if(!(u instanceof y))return null;if(h=u.parent,h._item===null||!h._item.deleted){f=u.deleted||!u.countable?0:a.diff+(l>=0?0:1);let d=u.left;while(d!==null){if(!d.deleted&&d.countable)f+=d.length;d=d.left}}}else{if(c!==null)h=e.get(c);else if(o!==null){if(b(s,o.client)<=o.clock)return null;let{item:a}=r?Qn(s,o):{item:Ct(s,o)};if(a instanceof y&&a.content instanceof W)h=a.content.type;else return null}else throw v();if(l>=0)f=h._length;else f=0}return Yo(h,f,t.assoc)};class Hs{constructor(t,e){this.ds=t,this.sv=e}}var ec=(t,e)=>new Hs(t,e),ql=ec(Ns(),new Map);var At=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!ce(e.ds,t.id),Zn=(t,e)=>{let r=j(t.meta,Zn,G),s=t.doc.store;if(!r.has(e))e.sv.forEach((i,o)=>{if(i<b(s,o))N(t,m(o,i))}),Dt(t,e.ds,(i)=>{}),r.add(e)};class or{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}var tn=(t)=>{let e=new Map;return t.clients.forEach((r,s)=>{let i=r[r.length-1];e.set(s,i.id.clock+i.length)}),e},b=(t,e)=>{let r=t.clients.get(e);if(r===void 0)return 0;let s=r[r.length-1];return s.id.clock+s.length},Js=(t,e)=>{let r=t.clients.get(e.id.client);if(r===void 0)r=[],t.clients.set(e.id.client,r);else{let s=r[r.length-1];if(s.id.clock+s.length!==e.id.clock)throw v()}r.push(e)},P=(t,e)=>{let r=0,s=t.length-1,i=t[s],o=i.id.clock;if(o===e)return s;let c=rs(e/(o+i.length-1)*s);while(r<=s){if(i=t[c],o=i.id.clock,o<=e){if(e<o+i.length)return c;r=c+1}else s=c-1;c=rs((r+s)/2)}throw v()},nc=(t,e)=>{let r=t.clients.get(e.client);return r[P(r,e.clock)]},Ct=nc,Xn=(t,e,r)=>{let s=P(e,r),i=e[s];if(i.id.clock<r&&i instanceof y)return e.splice(s+1,0,Ye(t,i,r-i.id.clock)),s+1;return s},N=(t,e)=>{let r=t.doc.store.clients.get(e.client);return r[Xn(t,r,e.clock)]},Es=(t,e,r)=>{let s=e.clients.get(r.client),i=P(s,r.clock),o=s[i];if(r.clock!==o.id.clock+o.length-1&&o.constructor!==V)s.splice(i+1,0,Ye(t,o,r.clock-o.id.clock+1));return o},rc=(t,e,r)=>{let s=t.clients.get(e.id.client);s[P(s,e.id.clock)]=r},Ps=(t,e,r,s,i)=>{if(s===0)return;let o=r+s,c=Xn(t,e,r),l;do{if(l=e[c++],o<l.id.clock+l.length)Xn(t,e,o);i(l)}while(c<e.length&&e[c].id.clock<o)};class Ks{constructor(t,e,r){this.doc=t,this.deleteSet=new ht,this.beforeState=tn(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=e,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}var Is=(t,e)=>{if(e.deleteSet.clients.size===0&&!pr(e.afterState,(r,s)=>e.beforeState.get(s)!==r))return!1;return Yn(e.deleteSet),Jo(t,e),Ot(t,e.deleteSet),!0},Us=(t,e,r)=>{let s=e._item;if(s===null||s.id.clock<(t.beforeState.get(s.id.client)||0)&&!s.deleted)j(t.changed,e,G).add(r)},Ge=(t,e)=>{let r=t[e],s=t[e-1],i=e;for(;i>0;r=s,s=t[--i-1]){if(s.deleted===r.deleted&&s.constructor===r.constructor){if(s.mergeWith(r)){if(r instanceof y&&r.parentSub!==null&&r.parent._map.get(r.parentSub)===r)r.parent._map.set(r.parentSub,s);continue}}break}let o=e-i;if(o)t.splice(e+1-o,o);return o},sc=(t,e,r)=>{for(let[s,i]of t.clients.entries()){let o=e.clients.get(s);for(let c=i.length-1;c>=0;c--){let l=i[c],h=l.clock+l.len;for(let f=P(o,l.clock),a=o[f];f<o.length&&a.id.clock<h;a=o[++f]){let u=o[f];if(l.clock+l.len<=u.id.clock)break;if(u instanceof y&&u.deleted&&!u.keep&&r(u))u.gc(e,!1)}}}},ic=(t,e)=>{t.clients.forEach((r,s)=>{let i=e.clients.get(s);for(let o=r.length-1;o>=0;o--){let c=r[o],l=ge(i.length-1,1+P(i,c.clock+c.len-1));for(let h=l,f=i[h];h>0&&f.id.clock>=c.clock;f=i[h])h-=1+Ge(i,h)}})};var Ws=(t,e)=>{if(e<t.length){let r=t[e],s=r.doc,i=s.store,{deleteSet:o,_mergeStructs:c}=r;try{Yn(o),r.afterState=tn(r.doc.store),s.emit("beforeObserverCalls",[r,s]);let l=[];r.changed.forEach((h,f)=>l.push(()=>{if(f._item===null||!f._item.deleted)f._callObserver(r,h)})),l.push(()=>{r.changedParentTypes.forEach((h,f)=>{if(f._dEH.l.length>0&&(f._item===null||!f._item.deleted))l.push(()=>{h=h.filter((a)=>a.target._item===null||!a.target._item.deleted),h.forEach((a)=>{a.currentTarget=f,a._path=null}),h.sort((a,u)=>a.path.length-u.path.length),js(f._dEH,h,r)})}),l.push(()=>s.emit("afterTransaction",[r,s])),l.push(()=>{if(r._needFormattingCleanup)_c(r)})}),Kt(l,[])}finally{if(s.gc)sc(o,i,s.gcFilter);ic(o,i),r.afterState.forEach((a,u)=>{let d=r.beforeState.get(u)||0;if(d!==a){let p=i.clients.get(u),g=X(P(p,d),1);for(let w=p.length-1;w>=g;)w-=1+Ge(p,w)}});for(let a=c.length-1;a>=0;a--){let{client:u,clock:d}=c[a].id,p=i.clients.get(u),g=P(p,d);if(g+1<p.length){if(Ge(p,g+1)>1)continue}if(g>0)Ge(p,g)}if(!r.local&&r.afterState.get(s.clientID)!==r.beforeState.get(s.clientID))ms(Tt,Yt,"[yjs] ",te,ee,"Changed the client-id because another client seems to be using it."),s.clientID=Rs();if(s.emit("afterTransactionCleanup",[r,s]),s._observers.has("update")){let a=new vt;if(Is(a,r))s.emit("update",[a.toUint8Array(),r.origin,s,r])}if(s._observers.has("updateV2")){let a=new et;if(Is(a,r))s.emit("updateV2",[a.toUint8Array(),r.origin,s,r])}let{subdocsAdded:l,subdocsLoaded:h,subdocsRemoved:f}=r;if(l.size>0||f.size>0||h.size>0)l.forEach((a)=>{if(a.clientID=s.clientID,a.collectionid==null)a.collectionid=s.collectionid;s.subdocs.add(a)}),f.forEach((a)=>s.subdocs.delete(a)),s.emit("subdocs",[{loaded:h,added:l,removed:f},s,r]),f.forEach((a)=>a.destroy());if(t.length<=e+1)s._transactionCleanups=[],s.emit("afterAllTransactions",[s,t]);else Ws(t,e+1)}}},x=(t,e,r=null,s=!0)=>{let i=t._transactionCleanups,o=!1,c=null;if(t._transaction===null){if(o=!0,t._transaction=new Ks(t,r,s),i.push(t._transaction),i.length===1)t.emit("beforeAllTransactions",[t]);t.emit("beforeTransaction",[t._transaction,t])}try{c=e(t._transaction)}finally{if(o){let l=t._transaction===i[0];if(t._transaction=null,l)Ws(i,0)}}return c};class Zs{constructor(t,e){this.insertions=e,this.deletions=t,this.meta=new Map}}var Ts=(t,e,r)=>{Dt(t,r.deletions,(s)=>{if(s instanceof y&&e.scope.some((i)=>i===t.doc||He(i,s)))ur(s,!1)})},As=(t,e,r)=>{let s=null,{doc:i,scope:o}=t;x(i,(l)=>{while(e.length>0&&t.currStackItem===null){let h=i.store,f=e.pop(),a=new Set,u=[],d=!1;Dt(l,f.insertions,(p)=>{if(p instanceof y){if(p.redone!==null){let{item:g,diff:w}=Qn(h,p.id);if(w>0)g=N(l,m(g.id.client,g.id.clock+w));p=g}if(!p.deleted&&o.some((g)=>g===l.doc||He(g,p)))u.push(p)}}),Dt(l,f.deletions,(p)=>{if(p instanceof y&&o.some((g)=>g===l.doc||He(g,p))&&!ce(f.insertions,p.id))a.add(p)}),a.forEach((p)=>{d=mi(l,p,a,f.insertions,t.ignoreRemoteMapChanges,t)!==null||d});for(let p=u.length-1;p>=0;p--){let g=u[p];if(t.deleteFilter(g))g.delete(l),d=!0}t.currStackItem=d?f:null}l.changed.forEach((h,f)=>{if(h.has(null)&&f._searchMarker)f._searchMarker.length=0}),s=l},t);let c=t.currStackItem;if(c!=null){let l=s.changedParentTypes;t.emit("stack-item-popped",[{stackItem:c,type:r,changedParentTypes:l,origin:t},t]),t.currStackItem=null}return c};class Z2 extends pe{constructor(t,{captureTimeout:e=500,captureTransaction:r=(l)=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:c=Z(t)?t[0].doc:t instanceof Td?t:t.doc}={}){super();this.scope=[],this.doc=c,this.addToScope(t),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=e,this.afterTransactionHandler=(l)=>{if(!this.captureTransaction(l)||!this.scope.some((w)=>l.changedParentTypes.has(w)||w===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;let h=this.undoing,f=this.redoing,a=h?this.redoStack:this.undoStack;if(h)this.stopCapturing();else if(!f)this.clear(!1,!0);let u=new ht;l.afterState.forEach((w,C)=>{let k=l.beforeState.get(C)||0,dr=w-k;if(dr>0)ne(u,C,k,dr)});let d=Lu(),p=!1;if(this.lastChange>0&&d-this.lastChange<this.captureTimeout&&a.length>0&&!h&&!f){let w=a[a.length-1];w.deletions=Wn([w.deletions,l.deleteSet]),w.insertions=Wn([w.insertions,u])}else a.push(new Zs(l.deleteSet,u)),p=!0;if(!h&&!f)this.lastChange=d;Dt(l,l.deleteSet,(w)=>{if(w instanceof y&&this.scope.some((C)=>C===l.doc||He(C,w)))ur(w,!0)});let g=[{stackItem:a[a.length-1],origin:l.origin,type:h?"redo":"undo",changedParentTypes:l.changedParentTypes},this];if(p)this.emit("stack-item-added",g);else this.emit("stack-item-updated",g)},this.destroy=this.destroy.bind(this),this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",this.destroy)}addToScope(t){let e=new Set(this.scope);t=Z(t)?t:[t],t.forEach((r)=>{if(!e.has(r)){if(e.add(r),r instanceof I?r.doc!==this.doc:r!==this.doc)Pn("[yjs#509] Not same Y.Doc");this.scope.push(r)}})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,e=!0){if(t&&this.canUndo()||e&&this.canRedo())this.doc.transact((r)=>{if(t)this.undoStack.forEach((s)=>Ts(r,this,s)),this.undoStack=[];if(e)this.redoStack.forEach((s)=>Ts(r,this,s)),this.redoStack=[];this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:e}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=As(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=As(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),this.doc.off("destroy",this.destroy),super.destroy()}}function*oc(t){let e=Nt(t.restDecoder);for(let r=0;r<e;r++){let s=Nt(t.restDecoder),i=t.readClient(),o=Nt(t.restDecoder);for(let c=0;c<s;c++){let l=t.readInfo();if(l===10){let h=Nt(t.restDecoder);yield new M(m(i,o),h),o+=h}else if((Ft&l)!==0){let h=(l&(F|D))===0,f=new y(m(i,o),null,(l&D)===D?t.readLeftID():null,null,(l&F)===F?t.readRightID():null,h?t.readParentInfo()?t.readString():t.readLeftID():null,h&&(l&dt)===dt?t.readString():null,wi(t,l));yield f,o+=f.length}else{let h=t.readLen();yield new V(m(i,o),h),o+=h}}}}class en{constructor(t,e){this.gen=oc(t),this.curr=null,this.done=!1,this.filterSkips=e,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===M);return this.curr}}class nn{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}var cc=(t)=>Je(t,nr,vt);var lc=(t,e)=>{if(t.constructor===V){let{client:r,clock:s}=t.id;return new V(m(r,s+e),t.length-e)}else if(t.constructor===M){let{client:r,clock:s}=t.id;return new M(m(r,s+e),t.length-e)}else{let r=t,{client:s,clock:i}=r.id;return new y(m(s,i+e),null,m(s,i+e-1),null,r.rightOrigin,r.parent,r.parentSub,r.content.splice(e))}},Je=(t,e=ct,r=et)=>{if(t.length===1)return t[0];let s=t.map((a)=>new e(tl(a))),i=s.map((a)=>new en(a,!0)),o=null,c=new r,l=new nn(c);while(!0){if(i=i.filter((d)=>d.curr!==null),i.sort((d,p)=>{if(d.curr.id.client===p.curr.id.client){let g=d.curr.id.clock-p.curr.id.clock;if(g===0)return d.curr.constructor===p.curr.constructor?0:d.curr.constructor===M?1:-1;else return g}else return p.curr.id.client-d.curr.id.client}),i.length===0)break;let a=i[0],u=a.curr.id.client;if(o!==null){let d=a.curr,p=!1;while(d!==null&&d.id.clock+d.length<=o.struct.id.clock+o.struct.length&&d.id.client>=o.struct.id.client)d=a.next(),p=!0;if(d===null||d.id.client!==u||p&&d.id.clock>o.struct.id.clock+o.struct.length)continue;if(u!==o.struct.id.client)Y(l,o.struct,o.offset),o={struct:d,offset:0},a.next();else if(o.struct.id.clock+o.struct.length<d.id.clock)if(o.struct.constructor===M)o.struct.length=d.id.clock+d.length-o.struct.id.clock;else{Y(l,o.struct,o.offset);let g=d.id.clock-o.struct.id.clock-o.struct.length;o={struct:new M(m(u,o.struct.id.clock+o.struct.length),g),offset:0}}else{let g=o.struct.id.clock+o.struct.length-d.id.clock;if(g>0)if(o.struct.constructor===M)o.struct.length-=g;else d=lc(d,g);if(!o.struct.mergeWith(d))Y(l,o.struct,o.offset),o={struct:d,offset:0},a.next()}}else o={struct:a.curr,offset:0},a.next();for(let d=a.curr;d!==null&&d.id.client===u&&d.id.clock===o.struct.id.clock+o.struct.length&&d.constructor!==M;d=a.next())Y(l,o.struct,o.offset),o={struct:d,offset:0}}if(o!==null)Y(l,o.struct,o.offset),o=null;cr(l);let h=s.map((a)=>tr(a)),f=Wn(h);return Ot(c,f),c.toUint8Array()},ac=(t,e,r=ct,s=et)=>{let i=Ms(e),o=new s,c=new nn(o),l=new r(tl(t)),h=new en(l,!1);while(h.curr){let a=h.curr,u=a.id.client,d=i.get(u)||0;if(h.curr.constructor===M){h.next();continue}if(a.id.clock+a.length>d){Y(c,a,X(d-a.id.clock,0)),h.next();while(h.curr&&h.curr.id.client===u)Y(c,h.curr,0),h.next()}else while(h.curr&&h.curr.id.client===u&&h.curr.id.clock+h.curr.length<=d)h.next()}cr(c);let f=tr(l);return Ot(o,f),o.toUint8Array()};var Xs=(t)=>{if(t.written>0)t.clientStructs.push({written:t.written,restEncoder:yo(t.encoder.restEncoder)}),t.encoder.restEncoder=Qa(),t.written=0},Y=(t,e,r)=>{if(t.written>0&&t.currClient!==e.id.client)Xs(t);if(t.written===0)t.currClient=e.id.client,t.encoder.writeClient(e.id.client),_t(t.encoder.restEncoder,e.id.clock+r);e.write(t.encoder,r),t.written++},cr=(t)=>{Xs(t);let e=t.encoder.restEncoder;_t(e,t.clientStructs.length);for(let r=0;r<t.clientStructs.length;r++){let s=t.clientStructs[r];_t(e,s.written),qt(e,s.restEncoder)}},hc=(t,e,r,s)=>{let i=new r(tl(t)),o=new en(i,!1),c=new s,l=new nn(c);for(let f=o.curr;f!==null;f=o.next())Y(l,e(f),0);cr(l);let h=tr(i);return Ot(c,h),c.toUint8Array()};var uc=(t)=>hc(t,Mr,ct,vt),Cs="You must not compute changes after the event-handler fired.";class le{constructor(t,e){this.target=t,this.currentTarget=t,this.transaction=e,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=dc(this.currentTarget,this.target))}deletes(t){return ce(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw R(Cs);let t=new Map,e=this.target;this.transaction.changed.get(e).forEach((s)=>{if(s!==null){let i=e._map.get(s),o,c;if(this.adds(i)){let l=i.left;while(l!==null&&this.adds(l))l=l.left;if(this.deletes(i))if(l!==null&&this.deletes(l))o="delete",c=de(l.content.getContent());else return;else if(l!==null&&this.deletes(l))o="update",c=de(l.content.getContent());else o="add",c=void 0}else if(this.deletes(i))o="delete",c=de(i.content.getContent());else return;t.set(s,{action:o,oldValue:c})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw R(Cs);let e=this.target,r=G(),s=G(),i=[];if(t={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(e).has(null)){let c=null,l=()=>{if(c)i.push(c)};for(let h=e._start;h!==null;h=h.right)if(h.deleted){if(this.deletes(h)&&!this.adds(h)){if(c===null||c.delete===void 0)l(),c={delete:0};c.delete+=h.length,s.add(h)}}else if(this.adds(h)){if(c===null||c.insert===void 0)l(),c={insert:[]};c.insert=c.insert.concat(h.content.getContent()),r.add(h)}else{if(c===null||c.retain===void 0)l(),c={retain:0};c.retain+=h.length}if(c!==null&&c.retain===void 0)l()}this._changes=t}return t}}var dc=(t,e)=>{let r=[];while(e._item!==null&&e!==t){if(e._item.parentSub!==null)r.unshift(e._item.parentSub);else{let s=0,i=e._item.parent._start;while(i!==e._item&&i!==null){if(!i.deleted&&i.countable)s+=i.length;i=i.right}r.unshift(s)}e=e._item.parent}return r},O=()=>{Pn("Invalid access: Add Yjs type to a document before reading data.")},Qs=80,lr=0;class Ys{constructor(t,e){t.marker=!0,this.p=t,this.index=e,this.timestamp=lr++}}var fc=(t)=>{t.timestamp=lr++},ti=(t,e,r)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=r,t.timestamp=lr++},pc=(t,e,r)=>{if(t.length>=Qs){let s=t.reduce((i,o)=>i.timestamp<o.timestamp?i:o);return ti(s,e,r),s}else{let s=new Ys(e,r);return t.push(s),s}},rn=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;let r=t._searchMarker.length===0?null:t._searchMarker.reduce((o,c)=>nt(e-o.index)<nt(e-c.index)?o:c),s=t._start,i=0;if(r!==null)s=r.p,i=r.index,fc(r);while(s.right!==null&&i<e){if(!s.deleted&&s.countable){if(e<i+s.length)break;i+=s.length}s=s.right}while(s.left!==null&&i>e)if(s=s.left,!s.deleted&&s.countable)i-=s.length;while(s.left!==null&&s.left.id.client===s.id.client&&s.left.id.clock+s.left.length===s.id.clock)if(s=s.left,!s.deleted&&s.countable)i-=s.length;if(r!==null&&nt(r.index-i)<s.parent.length/Qs)return ti(r,s,i),r;else return pc(t._searchMarker,s,i)},re=(t,e,r)=>{for(let s=t.length-1;s>=0;s--){let i=t[s];if(r>0){let o=i.p;o.marker=!1;while(o&&(o.deleted||!o.countable))if(o=o.left,o&&!o.deleted&&o.countable)i.index-=o.length;if(o===null||o.marker===!0){t.splice(s,1);continue}i.p=o,o.marker=!0}if(e<i.index||r>0&&e===i.index)i.index=X(e,i.index+r)}};var sn=(t,e,r)=>{let s=t,i=e.changedParentTypes;while(!0){if(j(i,t,()=>[]).push(r),t._item===null)break;t=t._item.parent}js(s._eH,r,e)};class I{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=ks(),this._dEH=ks(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,e){this.doc=t,this._item=e}_copy(){throw L()}clone(){throw L()}_write(t){}get _first(){let t=this._start;while(t!==null&&t.deleted)t=t.right;return t}_callObserver(t,e){if(!t.local&&this._searchMarker)this._searchMarker.length=0}observe(t){_s(this._eH,t)}observeDeep(t){_s(this._dEH,t)}unobserve(t){Ss(this._eH,t)}unobserveDeep(t){Ss(this._dEH,t)}toJSON(){}}var ei=(t,e,r)=>{if(t.doc??O(),e<0)e=t._length+e;if(r<0)r=t._length+r;let s=r-e,i=[],o=t._start;while(o!==null&&s>0){if(o.countable&&!o.deleted){let c=o.content.getContent();if(c.length<=e)e-=c.length;else{for(let l=e;l<c.length&&s>0;l++)i.push(c[l]),s--;e=0}}o=o.right}return i},ni=(t)=>{t.doc??O();let e=[],r=t._start;while(r!==null){if(r.countable&&!r.deleted){let s=r.content.getContent();for(let i=0;i<s.length;i++)e.push(s[i])}r=r.right}return e};var se=(t,e)=>{let r=0,s=t._start;t.doc??O();while(s!==null){if(s.countable&&!s.deleted){let i=s.content.getContent();for(let o=0;o<i.length;o++)e(i[o],r++,t)}s=s.right}},ri=(t,e)=>{let r=[];return se(t,(s,i)=>{r.push(e(s,i,t))}),r},gc=(t)=>{let e=t._start,r=null,s=0;return{[Symbol.iterator](){return this},next:()=>{if(r===null){while(e!==null&&e.deleted)e=e.right;if(e===null)return{done:!0,value:void 0};r=e.content.getContent(),s=0,e=e.right}let i=r[s++];if(r.length<=s)r=null;return{done:!1,value:i}}}},si=(t,e)=>{t.doc??O();let r=rn(t,e),s=t._start;if(r!==null)s=r.p,e-=r.index;for(;s!==null;s=s.right)if(!s.deleted&&s.countable){if(e<s.length)return s.content.getContent()[e];e-=s.length}},Pe=(t,e,r,s)=>{let i=r,o=t.doc,{clientID:c,store:l}=o,h=r===null?e._start:r.right,f=[],a=()=>{if(f.length>0)i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new at(f)),i.integrate(t,0),f=[]};s.forEach((u)=>{if(u===null)f.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:f.push(u);break;default:switch(a(),u.constructor){case Uint8Array:case ArrayBuffer:i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new ae(new Uint8Array(u))),i.integrate(t,0);break;case Td:i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new he(u)),i.integrate(t,0);break;default:if(u instanceof I)i=new y(m(c,b(l,c)),i,i&&i.lastId,h,h&&h.id,e,null,new W(u)),i.integrate(t,0);else throw Error("Unexpected content type in insert operation")}}}),a()},ii=()=>R("Length exceeded!"),oi=(t,e,r,s)=>{if(r>e._length)throw ii();if(r===0){if(e._searchMarker)re(e._searchMarker,r,s.length);return Pe(t,e,null,s)}let i=r,o=rn(e,r),c=e._start;if(o!==null){if(c=o.p,r-=o.index,r===0)c=c.prev,r+=c&&c.countable&&!c.deleted?c.length:0}for(;c!==null;c=c.right)if(!c.deleted&&c.countable){if(r<=c.length){if(r<c.length)N(t,m(c.id.client,c.id.clock+r));break}r-=c.length}if(e._searchMarker)re(e._searchMarker,i,s.length);return Pe(t,e,c,s)},mc=(t,e,r)=>{let i=(e._searchMarker||[]).reduce((o,c)=>c.index>o.index?c:o,{index:0,p:e._start}).p;if(i)while(i.right)i=i.right;return Pe(t,e,i,r)},ci=(t,e,r,s)=>{if(s===0)return;let i=r,o=s,c=rn(e,r),l=e._start;if(c!==null)l=c.p,r-=c.index;for(;l!==null&&r>0;l=l.right)if(!l.deleted&&l.countable){if(r<l.length)N(t,m(l.id.client,l.id.clock+r));r-=l.length}while(s>0&&l!==null){if(!l.deleted){if(s<l.length)N(t,m(l.id.client,l.id.clock+s));l.delete(t),s-=l.length}l=l.right}if(s>0)throw ii();if(e._searchMarker)re(e._searchMarker,i,-o+s)},Ke=(t,e,r)=>{let s=e._map.get(r);if(s!==void 0)s.delete(t)},ar=(t,e,r,s)=>{let i=e._map.get(r)||null,o=t.doc,c=o.clientID,l;if(s==null)l=new at([s]);else switch(s.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new at([s]);break;case Uint8Array:l=new ae(s);break;case Td:l=new he(s);break;default:if(s instanceof I)l=new W(s);else throw Error("Unexpected content type")}new y(m(c,b(o.store,c)),i,i&&i.lastId,null,null,e,r,l).integrate(t,0)},hr=(t,e)=>{t.doc??O();let r=t._map.get(e);return r!==void 0&&!r.deleted?r.content.getContent()[r.length-1]:void 0},li=(t)=>{let e={};return t.doc??O(),t._map.forEach((r,s)=>{if(!r.deleted)e[s]=r.content.getContent()[r.length-1]}),e},ai=(t,e)=>{t.doc??O();let r=t._map.get(e);return r!==void 0&&!r.deleted};var wc=(t,e)=>{let r={};return t._map.forEach((s,i)=>{let o=s;while(o!==null&&(!e.sv.has(o.id.client)||o.id.clock>=(e.sv.get(o.id.client)||0)))o=o.left;if(o!==null&&At(o,e))r[i]=o.content.getContent()[o.length-1]}),r},je=(t)=>(t.doc??O(),ys(t._map.entries(),(e)=>!e[1].deleted));class Gv extends le{}class Ca extends I{constructor(){super();this._prelimContent=[],this._searchMarker=[]}static from(t){let e=new Ca;return e.push(t),e}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Ca}clone(){let t=new Ca;return t.insert(0,this.toArray().map((e)=>e instanceof I?e.clone():e)),t}get length(){return this.doc??O(),this._length}_callObserver(t,e){super._callObserver(t,e),sn(this,t,new Gv(this,t))}insert(t,e){if(this.doc!==null)x(this.doc,(r)=>{oi(r,this,t,e)});else this._prelimContent.splice(t,0,...e)}push(t){if(this.doc!==null)x(this.doc,(e)=>{mc(e,this,t)});else this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,e=1){if(this.doc!==null)x(this.doc,(r)=>{ci(r,this,t,e)});else this._prelimContent.splice(t,e)}get(t){return si(this,t)}toArray(){return ni(this)}slice(t=0,e=this.length){return ei(this,t,e)}toJSON(){return this.map((t)=>t instanceof I?t.toJSON():t)}map(t){return ri(this,t)}forEach(t){se(this,t)}[Symbol.iterator](){return gc(this)}_write(t){t.writeTypeRef($c)}}var xc=(t)=>new Ca;class AS extends le{constructor(t,e,r){super(t,e);this.keysChanged=r}}class os extends I{constructor(t){super();if(this._prelimContent=null,t===void 0)this._prelimContent=new Map;else this._prelimContent=new Map(t)}_integrate(t,e){super._integrate(t,e),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new os}clone(){let t=new os;return this.forEach((e,r)=>{t.set(r,e instanceof I?e.clone():e)}),t}_callObserver(t,e){sn(this,t,new AS(this,t,e))}toJSON(){this.doc??O();let t={};return this._map.forEach((e,r)=>{if(!e.deleted){let s=e.content.getContent()[e.length-1];t[r]=s instanceof I?s.toJSON():s}}),t}get size(){return[...je(this)].length}keys(){return Me(je(this),(t)=>t[0])}values(){return Me(je(this),(t)=>t[1].content.getContent()[t[1].length-1])}entries(){return Me(je(this),(t)=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??O(),this._map.forEach((e,r)=>{if(!e.deleted)t(e.content.getContent()[e.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(t){if(this.doc!==null)x(this.doc,(e)=>{Ke(e,this,t)});else this._prelimContent.delete(t)}set(t,e){if(this.doc!==null)x(this.doc,(r)=>{ar(r,this,t,e)});else this._prelimContent.set(t,e);return e}get(t){return hr(this,t)}has(t){return ai(this,t)}clear(){if(this.doc!==null)x(this.doc,(t)=>{this.forEach(function(e,r,s){Ke(t,s,r)})});else this._prelimContent.clear()}_write(t){t.writeTypeRef(Fc)}}var yc=(t)=>new os,tt=(t,e)=>t===e||typeof t==="object"&&typeof e==="object"&&t&&e&&In(t,e);class We{constructor(t,e,r,s){this.left=t,this.right=e,this.index=r,this.currentAttributes=s}forward(){if(this.right===null)v();switch(this.right.content.constructor){case U:if(!this.right.deleted)Rt(this.currentAttributes,this.right.content);break;default:if(!this.right.deleted)this.index+=this.right.length;break}this.left=this.right,this.right=this.right.right}}var Ds=(t,e,r)=>{while(e.right!==null&&r>0){switch(e.right.content.constructor){case U:if(!e.right.deleted)Rt(e.currentAttributes,e.right.content);break;default:if(!e.right.deleted){if(r<e.right.length)N(t,m(e.right.id.client,e.right.id.clock+r));e.index+=e.right.length,r-=e.right.length}break}e.left=e.right,e.right=e.right.right}return e},qe=(t,e,r,s)=>{let i=new Map,o=s?rn(e,r):null;if(o){let c=new We(o.p.left,o.p,o.index,i);return Ds(t,c,r-o.index)}else{let c=new We(null,e._start,0,i);return Ds(t,c,r)}},hi=(t,e,r,s)=>{while(r.right!==null&&(r.right.deleted===!0||r.right.content.constructor===U&&tt(s.get(r.right.content.key),r.right.content.value))){if(!r.right.deleted)s.delete(r.right.content.key);r.forward()}let i=t.doc,o=i.clientID;s.forEach((c,l)=>{let{left:h,right:f}=r,a=new y(m(o,b(i.store,o)),h,h&&h.lastId,f,f&&f.id,e,null,new U(l,c));a.integrate(t,0),r.right=a,r.forward()})},Rt=(t,e)=>{let{key:r,value:s}=e;if(s===null)t.delete(r);else t.set(r,s)},ui=(t,e)=>{while(!0){if(t.right===null)break;else if(t.right.deleted||t.right.content.constructor===U&&tt(e[t.right.content.key]??null,t.right.content.value));else break;t.forward()}},di=(t,e,r,s)=>{let i=t.doc,o=i.clientID,c=new Map;for(let l in s){let h=s[l],f=r.currentAttributes.get(l)??null;if(!tt(f,h)){c.set(l,f);let{left:a,right:u}=r;r.right=new y(m(o,b(i.store,o)),a,a&&a.lastId,u,u&&u.id,e,null,new U(l,h)),r.right.integrate(t,0),r.forward()}}return c},Kn=(t,e,r,s,i)=>{r.currentAttributes.forEach((d,p)=>{if(i[p]===void 0)i[p]=null});let o=t.doc,c=o.clientID;ui(r,i);let l=di(t,e,r,i),h=s.constructor===String?new K(s):s instanceof I?new W(s):new ut(s),{left:f,right:a,index:u}=r;if(e._searchMarker)re(e._searchMarker,r.index,h.getLength());a=new y(m(c,b(o.store,c)),f,f&&f.lastId,a,a&&a.id,e,null,h),a.integrate(t,0),r.right=a,r.index=u,r.forward(),hi(t,e,r,l)},Bs=(t,e,r,s,i)=>{let o=t.doc,c=o.clientID;ui(r,i);let l=di(t,e,r,i);t:while(r.right!==null&&(s>0||l.size>0&&(r.right.deleted||r.right.content.constructor===U))){if(!r.right.deleted)switch(r.right.content.constructor){case U:{let{key:h,value:f}=r.right.content,a=i[h];if(a!==void 0){if(tt(a,f))l.delete(h);else{if(s===0)break t;l.set(h,f)}r.right.delete(t)}else r.currentAttributes.set(h,f);break}default:if(s<r.right.length)N(t,m(r.right.id.client,r.right.id.clock+s));s-=r.right.length;break}r.forward()}if(s>0){let h="";for(;s>0;s--)h+=`
4
+ `;r.right=new y(m(c,b(o.store,c)),r.left,r.left&&r.left.lastId,r.right,r.right&&r.right.id,e,null,new K(h)),r.right.integrate(t,0),r.forward()}hi(t,e,r,l)},fi=(t,e,r,s,i)=>{let o=e,c=T();while(o&&(!o.countable||o.deleted)){if(!o.deleted&&o.content.constructor===U){let f=o.content;c.set(f.key,f)}o=o.right}let l=0,h=!1;while(e!==o){if(r===e)h=!0;if(!e.deleted){let f=e.content;switch(f.constructor){case U:{let{key:a,value:u}=f,d=s.get(a)??null;if(c.get(a)!==f||d===u){if(e.delete(t),l++,!h&&(i.get(a)??null)===u&&d!==u)if(d===null)i.delete(a);else i.set(a,d)}if(!h&&!e.deleted)Rt(i,f);break}}}e=e.right}return l},bc=(t,e)=>{while(e&&e.right&&(e.right.deleted||!e.right.countable))e=e.right;let r=new Set;while(e&&(e.deleted||!e.countable)){if(!e.deleted&&e.content.constructor===U){let s=e.content.key;if(r.has(s))e.delete(t);else r.add(s)}e=e.left}},kc=(t)=>{let e=0;return x(t.doc,(r)=>{let{_start:s,_start:i}=t,o=T(),c=ue(o);while(i){if(i.deleted===!1)switch(i.content.constructor){case U:Rt(c,i.content);break;default:e+=fi(r,s,i,o,c),o=ue(c),s=i;break}i=i.right}}),e},_c=(t)=>{let e=new Set,r=t.doc;for(let[s,i]of t.afterState.entries()){let o=t.beforeState.get(s)||0;if(i===o)continue;Ps(t,r.store.clients.get(s),o,i,(c)=>{if(!c.deleted&&c.content.constructor===U&&c.constructor!==V)e.add(c.parent)})}x(r,(s)=>{Dt(t,t.deleteSet,(i)=>{if(i instanceof V||!i.parent._hasFormatting||e.has(i.parent))return;let o=i.parent;if(i.content.constructor===U)e.add(o);else bc(s,i)});for(let i of e)kc(i)})},Os=(t,e,r)=>{let s=r,i=ue(e.currentAttributes),o=e.right;while(r>0&&e.right!==null){if(e.right.deleted===!1)switch(e.right.content.constructor){case W:case ut:case K:if(r<e.right.length)N(t,m(e.right.id.client,e.right.id.clock+r));r-=e.right.length,e.right.delete(t);break}e.forward()}if(o)fi(t,o,e.right,i,e.currentAttributes);let c=(e.left||e.right).parent;if(c._searchMarker)re(c._searchMarker,e.index,-s+r);return e};class PS extends le{constructor(t,e,r){super(t,e);this.childListChanged=!1,this.keysChanged=new Set,r.forEach((s)=>{if(s===null)this.childListChanged=!0;else this.keysChanged.add(s)})}get changes(){if(this._changes===null){let t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(this._delta===null){let t=this.target.doc,e=[];x(t,(r)=>{let s=new Map,i=new Map,o=this.target._start,c=null,l={},h="",f=0,a=0,u=()=>{if(c!==null){let d=null;switch(c){case"delete":if(a>0)d={delete:a};a=0;break;case"insert":if(typeof h==="object"||h.length>0){if(d={insert:h},s.size>0)d.attributes={},s.forEach((p,g)=>{if(p!==null)d.attributes[g]=p})}h="";break;case"retain":if(f>0){if(d={retain:f},!Vr(l))d.attributes=Rr({},l)}f=0;break}if(d)e.push(d);c=null}};while(o!==null){switch(o.content.constructor){case W:case ut:if(this.adds(o)){if(!this.deletes(o))u(),c="insert",h=o.content.getContent()[0],u()}else if(this.deletes(o)){if(c!=="delete")u(),c="delete";a+=1}else if(!o.deleted){if(c!=="retain")u(),c="retain";f+=1}break;case K:if(this.adds(o)){if(!this.deletes(o)){if(c!=="insert")u(),c="insert";h+=o.content.str}}else if(this.deletes(o)){if(c!=="delete")u(),c="delete";a+=o.length}else if(!o.deleted){if(c!=="retain")u(),c="retain";f+=o.length}break;case U:{let{key:d,value:p}=o.content;if(this.adds(o)){if(!this.deletes(o)){let g=s.get(d)??null;if(!tt(g,p)){if(c==="retain")u();if(tt(p,i.get(d)??null))delete l[d];else l[d]=p}else if(p!==null)o.delete(r)}}else if(this.deletes(o)){i.set(d,p);let g=s.get(d)??null;if(!tt(g,p)){if(c==="retain")u();l[d]=g}}else if(!o.deleted){i.set(d,p);let g=l[d];if(g!==void 0){if(!tt(g,p)){if(c==="retain")u();if(p===null)delete l[d];else l[d]=p}else if(g!==null)o.delete(r)}}if(!o.deleted){if(c==="insert")u();Rt(s,o.content)}break}}o=o.right}u();while(e.length>0){let d=e[e.length-1];if(d.retain!==void 0&&d.attributes===void 0)e.pop();else break}}),this._delta=e}return this._delta}}class ss extends I{constructor(t){super();this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??O(),this._length}_integrate(t,e){super._integrate(t,e);try{this._pending.forEach((r)=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new ss}clone(){let t=new ss;return t.applyDelta(this.toDelta()),t}_callObserver(t,e){super._callObserver(t,e);let r=new PS(this,t,e);if(sn(this,t,r),!t.local&&this._hasFormatting)t._needFormattingCleanup=!0}toString(){this.doc??O();let t="",e=this._start;while(e!==null){if(!e.deleted&&e.countable&&e.content.constructor===K)t+=e.content.str;e=e.right}return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:e=!0}={}){if(this.doc!==null)x(this.doc,(r)=>{let s=new We(null,this._start,0,new Map);for(let i=0;i<t.length;i++){let o=t[i];if(o.insert!==void 0){let c=!e&&typeof o.insert==="string"&&i===t.length-1&&s.right===null&&o.insert.slice(-1)===`
5
+ `?o.insert.slice(0,-1):o.insert;if(typeof c!=="string"||c.length>0)Kn(r,this,s,c,o.attributes||{})}else if(o.retain!==void 0)Bs(r,this,s,o.retain,o.attributes||{});else if(o.delete!==void 0)Os(r,s,o.delete)}});else this._pending.push(()=>this.applyDelta(t))}toDelta(t,e,r){this.doc??O();let s=[],i=new Map,o=this.doc,c="",l=this._start;function h(){if(c.length>0){let a={},u=!1;i.forEach((p,g)=>{u=!0,a[g]=p});let d={insert:c};if(u)d.attributes=a;s.push(d),c=""}}let f=()=>{while(l!==null){if(At(l,t)||e!==void 0&&At(l,e))switch(l.content.constructor){case K:{let a=i.get("ychange");if(t!==void 0&&!At(l,t)){if(a===void 0||a.user!==l.id.client||a.type!=="removed")h(),i.set("ychange",r?r("removed",l.id):{type:"removed"})}else if(e!==void 0&&!At(l,e)){if(a===void 0||a.user!==l.id.client||a.type!=="added")h(),i.set("ychange",r?r("added",l.id):{type:"added"})}else if(a!==void 0)h(),i.delete("ychange");c+=l.content.str;break}case W:case ut:{h();let a={insert:l.content.getContent()[0]};if(i.size>0){let u={};a.attributes=u,i.forEach((d,p)=>{u[p]=d})}s.push(a);break}case U:if(At(l,t))h(),Rt(i,l.content);break}l=l.right}h()};if(t||e)x(o,(a)=>{if(t)Zn(a,t);if(e)Zn(a,e);f()},"cleanup");else f();return s}insert(t,e,r){if(e.length<=0)return;let s=this.doc;if(s!==null)x(s,(i)=>{let o=qe(i,this,t,!r);if(!r)r={},o.currentAttributes.forEach((c,l)=>{r[l]=c});Kn(i,this,o,e,r)});else this._pending.push(()=>this.insert(t,e,r))}insertEmbed(t,e,r){let s=this.doc;if(s!==null)x(s,(i)=>{let o=qe(i,this,t,!r);Kn(i,this,o,e,r||{})});else this._pending.push(()=>this.insertEmbed(t,e,r||{}))}delete(t,e){if(e===0)return;let r=this.doc;if(r!==null)x(r,(s)=>{Os(s,qe(s,this,t,!0),e)});else this._pending.push(()=>this.delete(t,e))}format(t,e,r){if(e===0)return;let s=this.doc;if(s!==null)x(s,(i)=>{let o=qe(i,this,t,!1);if(o.right===null)return;Bs(i,this,o,e,r)});else this._pending.push(()=>this.format(t,e,r))}removeAttribute(t){if(this.doc!==null)x(this.doc,(e)=>{Ke(e,this,t)});else this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,e){if(this.doc!==null)x(this.doc,(r)=>{ar(r,this,t,e)});else this._pending.push(()=>this.setAttribute(t,e))}getAttribute(t){return hr(this,t)}getAttributes(){return li(this)}_write(t){t.writeTypeRef(jc)}}var Sc=(t)=>new ss;class ze{constructor(t,e=()=>!0){this._filter=e,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??O()}[Symbol.iterator](){return this}next(){let t=this._currentNode,e=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(e)))do if(e=t.content.type,!t.deleted&&(e.constructor===Bt||e.constructor===lt)&&e._start!==null)t=e._start;else while(t!==null){let r=t.next;if(r!==null){t=r;break}else if(t.parent===this._root)t=null;else t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));if(this._firstCall=!1,t===null)return{value:void 0,done:!0};return this._currentNode=t,{value:t.content.type,done:!1}}}class lt extends I{constructor(){super();this._prelimContent=[]}get firstChild(){let t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,e){super._integrate(t,e),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new lt}clone(){let t=new lt;return t.insert(0,this.toArray().map((e)=>e instanceof I?e.clone():e)),t}get length(){return this.doc??O(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new ze(this,t)}querySelector(t){t=t.toUpperCase();let r=new ze(this,(s)=>s.nodeName&&s.nodeName.toUpperCase()===t).next();if(r.done)return null;else return r.value}querySelectorAll(t){return t=t.toUpperCase(),q(new ze(this,(e)=>e.nodeName&&e.nodeName.toUpperCase()===t))}_callObserver(t,e){sn(this,t,new pi(this,e,t))}toString(){return ri(this,(t)=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,e={},r){let s=t.createDocumentFragment();if(r!==void 0)r._createAssociation(s,this);return se(this,(i)=>{s.insertBefore(i.toDOM(t,e,r),null)}),s}insert(t,e){if(this.doc!==null)x(this.doc,(r)=>{oi(r,this,t,e)});else this._prelimContent.splice(t,0,...e)}insertAfter(t,e){if(this.doc!==null)x(this.doc,(r)=>{let s=t&&t instanceof I?t._item:t;Pe(r,this,s,e)});else{let r=this._prelimContent,s=t===null?0:r.findIndex((i)=>i===t)+1;if(s===0&&t!==null)throw R("Reference item not found");r.splice(s,0,...e)}}delete(t,e=1){if(this.doc!==null)x(this.doc,(r)=>{ci(r,this,t,e)});else this._prelimContent.splice(t,e)}toArray(){return ni(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return si(this,t)}slice(t=0,e=this.length){return ei(this,t,e)}forEach(t){se(this,t)}_write(t){t.writeTypeRef(Gc)}}var Ec=(t)=>new lt;class Bt extends lt{constructor(t="UNDEFINED"){super();this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,e){super._integrate(t,e),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new Bt(this.nodeName)}clone(){let t=new Bt(this.nodeName),e=this.getAttributes();return Lr(e,(r,s)=>{t.setAttribute(s,r)}),t.insert(0,this.toArray().map((r)=>r instanceof I?r.clone():r)),t}toString(){let t=this.getAttributes(),e=[],r=[];for(let c in t)r.push(c);r.sort();let s=r.length;for(let c=0;c<s;c++){let l=r[c];e.push(l+'="'+t[l]+'"')}let i=this.nodeName.toLocaleLowerCase(),o=e.length>0?" "+e.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(t){if(this.doc!==null)x(this.doc,(e)=>{Ke(e,this,t)});else this._prelimAttrs.delete(t)}setAttribute(t,e){if(this.doc!==null)x(this.doc,(r)=>{ar(r,this,t,e)});else this._prelimAttrs.set(t,e)}getAttribute(t){return hr(this,t)}hasAttribute(t){return ai(this,t)}getAttributes(t){return t?wc(this,t):li(this)}toDOM(t=document,e={},r){let s=t.createElement(this.nodeName),i=this.getAttributes();for(let o in i){let c=i[o];if(typeof c==="string")s.setAttribute(o,c)}if(se(this,(o)=>{s.appendChild(o.toDOM(t,e,r))}),r!==void 0)r._createAssociation(s,this);return s}_write(t){t.writeTypeRef(qc),t.writeKey(this.nodeName)}}var Ic=(t)=>new Bt(t.readKey());class pi extends le{constructor(t,e,r){super(t,r);this.childListChanged=!1,this.attributesChanged=new Set,e.forEach((s)=>{if(s===null)this.childListChanged=!0;else this.attributesChanged.add(s)})}}class Ze extends os{constructor(t){super();this.hookName=t}_copy(){return new Ze(this.hookName)}clone(){let t=new Ze(this.hookName);return this.forEach((e,r)=>{t.set(r,e)}),t}toDOM(t=document,e={},r){let s=e[this.hookName],i;if(s!==void 0)i=s.createDom(this);else i=document.createElement(this.hookName);if(i.setAttribute("data-yjs-hook",this.hookName),r!==void 0)r._createAssociation(i,this);return i}_write(t){t.writeTypeRef(zc),t.writeKey(this.hookName)}}var Uc=(t)=>new Ze(t.readKey());class Xe extends ss{get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new Xe}clone(){let t=new Xe;return t.applyDelta(this.toDelta()),t}toDOM(t=document,e,r){let s=t.createTextNode(this.toString());if(r!==void 0)r._createAssociation(s,this);return s}toString(){return this.toDelta().map((t)=>{let e=[];for(let s in t.attributes){let i=[];for(let o in t.attributes[s])i.push({key:o,value:t.attributes[s][o]});i.sort((o,c)=>o.key<c.key?-1:1),e.push({nodeName:s,attrs:i})}e.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let r="";for(let s=0;s<e.length;s++){let i=e[s];r+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){let c=i.attrs[o];r+=` ${c.key}="${c.value}"`}r+=">"}r+=t.insert;for(let s=e.length-1;s>=0;s--)r+=`</${e[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Hc)}}var Tc=(t)=>new Xe;class on{constructor(t,e){this.id=t,this.length=e}get deleted(){throw L()}mergeWith(t){return!1}write(t,e,r){throw L()}integrate(t,e){throw L()}}var Ac=0;class V extends on{get deleted(){return!0}delete(){}mergeWith(t){if(this.constructor!==t.constructor)return!1;return this.length+=t.length,!0}integrate(t,e){if(e>0)this.id.clock+=e,this.length-=e;Js(t.doc.store,this)}write(t,e){t.writeInfo(Ac),t.writeLen(this.length-e)}getMissing(t,e){return null}}class ae{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new ae(this.content)}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeBuf(this.content)}getRef(){return 3}}var Cc=(t)=>new ae(t.readBuf());class ie{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new ie(this.len)}splice(t){let e=new ie(this.len-t);return this.len=t,e}mergeWith(t){return this.len+=t.len,!0}integrate(t,e){ne(t.deleteSet,e.id.client,e.id.clock,this.len),e.markDeleted()}delete(t){}gc(t){}write(t,e){t.writeLen(this.len-e)}getRef(){return 1}}var Dc=(t)=>new ie(t.readLen()),gi=(t,e)=>new Td({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class he{constructor(t){if(t._item)console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid.");this.doc=t;let e={};if(this.opts=e,!t.gc)e.gc=!1;if(t.autoLoad)e.autoLoad=!0;if(t.meta!==null)e.meta=t.meta}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new he(gi(this.doc.guid,this.opts))}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){if(this.doc._item=e,t.subdocsAdded.add(this.doc),this.doc.shouldLoad)t.subdocsLoaded.add(this.doc)}delete(t){if(t.subdocsAdded.has(this.doc))t.subdocsAdded.delete(this.doc);else t.subdocsRemoved.add(this.doc)}gc(t){}write(t,e){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}var Bc=(t)=>new he(gi(t.readString(),t.readAny()));class ut{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ut(this.embed)}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeJSON(this.embed)}getRef(){return 5}}var Oc=(t)=>new ut(t.readJSON());class U{constructor(t,e){this.key=t,this.value=e}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new U(this.key,this.value)}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){let r=e.parent;r._searchMarker=null,r._hasFormatting=!0}delete(t){}gc(t){}write(t,e){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}var vc=(t)=>new U(t.readKey(),t.readJSON());class Qe{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Qe(this.arr)}splice(t){let e=new Qe(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let r=this.arr.length;t.writeLen(r-e);for(let s=e;s<r;s++){let i=this.arr[s];t.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}var Nc=(t)=>{let e=t.readLen(),r=[];for(let s=0;s<e;s++){let i=t.readString();if(i==="undefined")r.push(void 0);else r.push(JSON.parse(i))}return new Qe(r)},Rc=Zt("node_env")==="development";class at{constructor(t){this.arr=t,Rc&&Un(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new at(this.arr)}splice(t){let e=new at(this.arr.slice(t));return this.arr=this.arr.slice(0,t),e}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){let r=this.arr.length;t.writeLen(r-e);for(let s=e;s<r;s++){let i=this.arr[s];t.writeAny(i)}}getRef(){return 8}}var Lc=(t)=>{let e=t.readLen(),r=[];for(let s=0;s<e;s++)r.push(t.readAny());return new at(r)};class K{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new K(this.str)}splice(t){let e=new K(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);if(r>=55296&&r<=56319)this.str=this.str.slice(0,t-1)+"�",e.str="�"+e.str.slice(1);return e}mergeWith(t){return this.str+=t.str,!0}integrate(t,e){}delete(t){}gc(t){}write(t,e){t.writeString(e===0?this.str:this.str.slice(e))}getRef(){return 4}}var Vc=(t)=>new K(t.readString()),Mc=[xc,yc,Sc,Ic,Ec,Uc,Tc],$c=0,Fc=1,jc=2,qc=3,Gc=4,zc=5,Hc=6;class W{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new W(this.type._copy())}splice(t){throw L()}mergeWith(t){return!1}integrate(t,e){this.type._integrate(t.doc,e)}delete(t){let e=this.type._start;while(e!==null){if(!e.deleted)e.delete(t);else if(e.id.clock<(t.beforeState.get(e.id.client)||0))t._mergeStructs.push(e);e=e.right}this.type._map.forEach((r)=>{if(!r.deleted)r.delete(t);else if(r.id.clock<(t.beforeState.get(r.id.client)||0))t._mergeStructs.push(r)}),t.changed.delete(this.type)}gc(t){let e=this.type._start;while(e!==null)e.gc(t,!0),e=e.right;this.type._start=null,this.type._map.forEach((r)=>{while(r!==null)r.gc(t,!0),r=r.left}),this.type._map=new Map}write(t,e){this.type._write(t)}getRef(){return 7}}var Jc=(t)=>new W(Mc[t.readTypeRef()](t)),Qn=(t,e)=>{let r=e,s=0,i;do{if(s>0)r=m(r.client,r.clock+s);i=Ct(t,r),s=r.clock-i.id.clock,r=i.redone}while(r!==null&&i instanceof y);return{item:i,diff:s}},ur=(t,e)=>{while(t!==null&&t.keep!==e)t.keep=e,t=t.parent._item},Ye=(t,e,r)=>{let{client:s,clock:i}=e.id,o=new y(m(s,i+r),e,m(s,i+r-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(r));if(e.deleted)o.markDeleted();if(e.keep)o.keep=!0;if(e.redone!==null)o.redone=m(e.redone.client,e.redone.clock+r);if(e.right=o,o.right!==null)o.right.left=o;if(t._mergeStructs.push(o),o.parentSub!==null&&o.right===null)o.parent._map.set(o.parentSub,o);return e.length=r,o},vs=(t,e)=>Vt(t,(r)=>ce(r.deletions,e)),mi=(t,e,r,s,i,o)=>{let c=t.doc,{store:l,clientID:h}=c,f=e.redone;if(f!==null)return N(t,f);let a=e.parent._item,u=null,d;if(a!==null&&a.deleted===!0){if(a.redone===null&&(!r.has(a)||mi(t,a,r,s,i,o)===null))return null;while(a.redone!==null)a=N(t,a.redone)}let p=a===null?e.parent:a.content.type;if(e.parentSub===null){u=e.left,d=e;while(u!==null){let k=u;while(k!==null&&k.parent._item!==a)k=k.redone===null?null:N(t,k.redone);if(k!==null&&k.parent._item===a){u=k;break}u=u.left}while(d!==null){let k=d;while(k!==null&&k.parent._item!==a)k=k.redone===null?null:N(t,k.redone);if(k!==null&&k.parent._item===a){d=k;break}d=d.right}}else{if(d=null,e.right&&!i){u=e;while(u!==null&&u.right!==null&&(u.right.redone||ce(s,u.right.id)||vs(o.undoStack,u.right.id)||vs(o.redoStack,u.right.id))){u=u.right;while(u.redone)u=N(t,u.redone)}if(u&&u.right!==null)return null}else u=p._map.get(e.parentSub)||null;if(u!==null&&u.parent._item!==a)u=p._map.get(e.parentSub)||null}let g=b(l,h),w=m(h,g),C=new y(w,u,u&&u.lastId,d,d&&d.id,p,e.parentSub,e.content.copy());return e.redone=w,ur(C,!0),C.integrate(t,0),C};class y extends on{constructor(t,e,r,s,i,o,c,l){super(t,l.getLength());this.origin=r,this.left=e,this.right=s,this.rightOrigin=i,this.parent=o,this.parentSub=c,this.redone=null,this.content=l,this.info=this.content.isCountable()?an:0}set marker(t){if((this.info&xe)>0!==t)this.info^=xe}get marker(){return(this.info&xe)>0}get keep(){return(this.info&ln)>0}set keep(t){if(this.keep!==t)this.info^=ln}get countable(){return(this.info&an)>0}get deleted(){return(this.info&we)>0}set deleted(t){if(this.deleted!==t)this.info^=we}markDeleted(){this.info|=we}getMissing(t,e){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=b(e,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=b(e,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ot&&this.id.client!==this.parent.client&&this.parent.clock>=b(e,this.parent.client))return this.parent.client;if(this.origin)this.left=Es(t,e,this.origin),this.origin=this.left.lastId;if(this.rightOrigin)this.right=N(t,this.rightOrigin),this.rightOrigin=this.right.id;if(this.left&&this.left.constructor===V||this.right&&this.right.constructor===V)this.parent=null;else if(!this.parent){if(this.left&&this.left.constructor===y)this.parent=this.left.parent,this.parentSub=this.left.parentSub;else if(this.right&&this.right.constructor===y)this.parent=this.right.parent,this.parentSub=this.right.parentSub}else if(this.parent.constructor===ot){let r=Ct(e,this.parent);if(r.constructor===V)this.parent=null;else this.parent=r.content.type}return null}integrate(t,e){if(e>0)this.id.clock+=e,this.left=Es(t,t.doc.store,m(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(e),this.length-=e;if(this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null){s=this.parent._map.get(this.parentSub)||null;while(s!==null&&s.left!==null)s=s.left}else s=this.parent._start;let i=new Set,o=new Set;while(s!==null&&s!==this.right){if(o.add(s),i.add(s),$e(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if($e(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(Ct(t.doc.store,s.origin))){if(!i.has(Ct(t.doc.store,s.origin)))r=s,i.clear()}else break;s=s.right}this.left=r}if(this.left!==null){let r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null){r=this.parent._map.get(this.parentSub)||null;while(r!==null&&r.left!==null)r=r.left}else r=this.parent._start,this.parent._start=this;this.right=r}if(this.right!==null)this.right.left=this;else if(this.parentSub!==null){if(this.parent._map.set(this.parentSub,this),this.left!==null)this.left.delete(t)}if(this.parentSub===null&&this.countable&&!this.deleted)this.parent._length+=this.length;if(Js(t.doc.store,this),this.content.integrate(t,this),Us(t,this.parent,this.parentSub),this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)this.delete(t)}else new V(this.id,this.length).integrate(t,0)}get next(){let t=this.right;while(t!==null&&t.deleted)t=t.right;return t}get prev(){let t=this.left;while(t!==null&&t.deleted)t=t.left;return t}get lastId(){return this.length===1?this.id:m(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&$e(t.origin,this.lastId)&&this.right===t&&$e(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){let e=this.parent._searchMarker;if(e)e.forEach((r)=>{if(r.p===t){if(r.p=this,!this.deleted&&this.countable)r.index-=this.length}});if(t.keep)this.keep=!0;if(this.right=t.right,this.right!==null)this.right.left=this;return this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){let e=this.parent;if(this.countable&&this.parentSub===null)e._length-=this.length;this.markDeleted(),ne(t.deleteSet,this.id.client,this.id.clock,this.length),Us(t,e,this.parentSub),this.content.delete(t)}}gc(t,e){if(!this.deleted)throw v();if(this.content.gc(t),e)rc(t,this,new V(this.id,this.length));else this.content=new ie(this.length)}write(t,e){let r=e>0?m(this.id.client,this.id.clock+e-1):this.origin,s=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&Ft|(r===null?0:D)|(s===null?0:F)|(i===null?0:dt);if(t.writeInfo(o),r!==null)t.writeLeftID(r);if(s!==null)t.writeRightID(s);if(r===null&&s===null){let c=this.parent;if(c._item!==void 0){let l=c._item;if(l===null){let h=qs(c);t.writeParentInfo(!0),t.writeString(h)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else if(c.constructor===String)t.writeParentInfo(!0),t.writeString(c);else if(c.constructor===ot)t.writeParentInfo(!1),t.writeLeftID(c);else v();if(i!==null)t.writeString(i)}this.content.write(t,e)}}var wi=(t,e)=>Pc[e&Ft](t),Pc=[()=>{v()},Dc,Nc,Cc,Vc,Oc,vc,Jc,Lc,Bc,()=>{v()}],Kc=10;class M extends on{get deleted(){return!0}delete(){}mergeWith(t){if(this.constructor!==t.constructor)return!1;return this.length+=t.length,!0}integrate(t,e){v()}write(t,e){t.writeInfo(Kc),_t(t.restEncoder,this.length-e)}getMissing(t,e){return null}}var xi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},yi="__ $YJS$ __";if(xi[yi]===!0)console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");xi[yi]=!0;var tN=0,nN=1,iN=2,rN=3;class ib extends Error{constructor(t){super(t);this.name="EnvelopeError"}}function Wc(t){return S(t)&&"type"in t&&n(t.type)}function cE(t){let e=Qa(),{type:r}=t;switch(t.type){case"doc-sync":{_t(e,tN),el(e,t.path),_t(e,t.epoch),Wr(e,t.body);break}case"awareness":{_t(e,nN),Wr(e,t.body);break}case"doc-close":{_t(e,iN),el(e,t.path);break}case"control":{_t(e,rN),el(e,JSON.stringify(t.message));break}default:throw new ib(`unknown-frame:${r}`)}return yo(e)}function dE(t){try{let e=tl(t),r=Nt(e);switch(r){case tN:{let s=nl(e),i=Nt(e);return{body:Xr(e),epoch:i,path:s,type:"doc-sync"}}case nN:return{body:Xr(e),type:"awareness"};case iN:return{path:nl(e),type:"doc-close"};case rN:{let s=JSON.parse(nl(e));if(!Wc(s))throw new ib("malformed-control");return{message:s,type:"control"}}default:throw new ib(`unknown-frame-type:${r}`)}}catch(e){if(e instanceof ib)throw e;throw new ib(`malformed-frame: ${e instanceof Error?e.message:String(e)}`)}}
6
+ export{aE,rs,Qa,lE,yo,_t,el,Wr,tl,Xr,Nt,nl,Lu,hp,Td,XI,QI,eN,OS,nb,Z2,Gv,Ca,AS,os,PS,ss,tN,nN,iN,rN,ib,cE,dE};
7
7
 
8
- //# debugId=198C109F54CBB45964756E2164756E21
9
- //# sourceMappingURL=studio-3na1r48j.js.map
8
+ //# debugId=2B97840B2DCBA36C64756E2164756E21
9
+ //# sourceMappingURL=studio-3yr1zdp9.js.map
@@ -0,0 +1,5 @@
1
+ import{p}from"./studio-xh6rf05g.js";import{x}from"./studio-zn7ysyzb.js";import{n,J,S,m}from"./studio-erjccagy.js";function b(e,o=[]){if(!m(e))return o;let{children:t}=e;if(e.tagName==="slot"){let s=e.attributes,r=m(s)?s.name:void 0,l={name:n(r)?r.trim():""};if(Array.isArray(t)&&t.length>0)l.fallback=t;o.push(l)}if(Array.isArray(t))for(let s of t)b(s,o);return o}function KC(e,o=new Set){if(!m(e))return o;let t=(i)=>{if(m(i)){if(n(i.tagName)&&i.tagName.includes("-"))o.add(i.tagName);KC(i,o)}},{cases:s,children:r,map:l}=e,a=[...Array.isArray(r)?r:[r],l];if(m(s))a.push(...Object.values(s));for(let i of a)t(i);return o}function N(e){if(n(e))return"string";return J(e)?"number":"boolean"}function C(e,o){if(o==null)return null;if(!S(o))return{default:o,name:e,type:N(o)};let t=m(o)?o:{};if(t.$prototype||t.$handler||t.$compute)return null;return{default:t.default,format:t.format,name:e,type:t.type}}function GC(e,o){if(!m(e))return null;let{tagName:t}=e;if(!n(t)||!t.includes("-"))return null;let s=b(e),r=e.state,l=m(r)||Array.isArray(r)||n(r)?Object.entries(r):[],a={$id:n(e.$id)&&e.$id?e.$id:null,hasElements:Array.isArray(e.$elements)&&e.$elements.length>0,path:o,props:l.flatMap(([u,f])=>{let c=C(u,f);return c===null?[]:[c]})};if(s.length>0)a.slots=s;let i=[...KC(e)].filter((u)=>u!==t).toSorted();if(i.length>0)a.uses=i;return{...a,tagName:t}}var De=[],Tx=!1,d=0,h=Promise.resolve();function $a(){d+=1;let e=d,o=(async()=>{let t=null;try{t=await p().discoverComponents(x?.projectRoot||void 0)}catch{t=null}if(e!==d){await h;return}if(t)De=t;Tx=!0})();return h=o,o}function oy(e,o){if(!e)return!1;let t=De.findIndex((l)=>l.path===e),s=GC(o,e);if(!s){if(t===-1)return!1;return De.splice(t,1),!0}let r=s;if(t===-1)De.push(r);else De[t]=r;return!0}function Uc(e){let o=Object.fromEntries((e.props??[]).map((r)=>[r.name,r.default!==void 0?r.default:""])),t=[];for(let r of e.slots??[])for(let l of structuredClone(r.fallback??[]))if(!r.name)t.push(l);else if(S(l)&&n(l.tagName))l.attributes={slot:r.name,...l.attributes},t.push(l);else t.push({attributes:{slot:r.name},children:[l],tagName:"span"});let s={$props:o,tagName:e.tagName};if(t.length>0)s.children=t;return s}function g(e){let o=[];for(let t of e){if(t===".")continue;if(t===".."&&o.length>0&&o.at(-1)!=="..")o.pop();else o.push(t)}return o}function qc(e,o,t=x?.projectRoot??null){if(!e)return`./${o}`;let s=e.replaceAll("\\","/"),r=o.replaceAll("\\","/"),l=s.includes("/")?s.slice(0,s.lastIndexOf("/")):"",a=g(l.split("/").filter(Boolean)),i=g(r.split("/").filter(Boolean));if(a[0]===".."&&t){let y=t.replaceAll("\\","/").split("/").filter(Boolean);a=g([...y,...a]),i=g([...y,...i])}let u=0;while(u<a.length&&u<i.length&&a[u]===i[u])u+=1;let f=a.length-u,c=i.slice(u);return(f>0?"../".repeat(f):"./")+c.join("/")}
2
+ export{KC,GC,De,Tx,$a,oy,Uc,qc};
3
+
4
+ //# debugId=C84DCF4B35AD39D964756E2164756E21
5
+ //# sourceMappingURL=studio-43pynnhz.js.map
@@ -0,0 +1,4 @@
1
+ import{Gv,Ca,AS,os,PS,ss}from"./studio-3yr1zdp9.js";import{Ce}from"./studio-151kgn69.js";import{n,J,m}from"./studio-erjccagy.js";var zI="meta",UI="frontmatter",qI="structure",KI="source",GI=2;function Y(e){return m(e)}function Tu(e){return e.getMap(zI)}function JI(e){return e.getMap(UI)}function tb(e){return e.getMap(qI)}function YI(e){return e.getText(KI)}var h=new Set(["textContent"]),y=new Set(["style","attributes","$props"]);function g(e,t){let o=e.toString();if(o===t)return!1;let r=0,s=Math.min(o.length,t.length);while(r<s&&o[r]===t[r])r+=1;let a=o.length,i=t.length;while(a>r&&i>r&&o[a-1]===t[i-1])a-=1,i-=1;if(a>r)e.delete(r,a-r);if(i>r)e.insert(r,t.slice(r,i));return!0}function f(e){let t=new os;for(let[o,r]of Object.entries(e)){if(r===void 0)continue;t.set(o,Y(r)?f(r):Ce(r))}return t}function S(e,t){for(let o of[...e.keys()])if(!(o in t)||t[o]===void 0)e.delete(o);for(let[o,r]of Object.entries(t)){if(r===void 0)continue;let s=e.get(o);if(Y(r))if(s instanceof os)S(s,r);else e.set(o,f(r));else if(!V(s,r))e.set(o,Ce(r))}}function V(e,t){if(e===t)return!0;if(e instanceof os||e instanceof Ca||e instanceof ss)return!1;return JSON.stringify(e??null)===JSON.stringify(t??null)}function d(e){return n(e)?new ss(e):ZI(e)}function im(e){let t=new Ca;return t.insert(0,e.map((o)=>d(o))),t}function ZI(e){if(!Y(e))throw TypeError("collab-schema: a document node must be a plain object");let t=new os;for(let[o,r]of Object.entries(e)){if(r===void 0)continue;if(o==="children"&&Array.isArray(r))t.set(o,im(r));else if(h.has(o)&&n(r))t.set(o,new ss(r));else if(y.has(o)&&Y(r))t.set(o,f(r));else t.set(o,Ce(r))}return t}function D(e){return Object.fromEntries(Array.from(e.entries(),([t,o])=>[t,rm(o)]))}function O(e){if(n(e))return e;return e instanceof ss?e.toString():D(e)}function rm(e){if(e instanceof os)return D(e);if(e instanceof Ca)return e.toArray().map((t)=>rm(t));if(e instanceof ss)return e.toString();return e}function F2(e){return D(tb(e))}function DS(e,t){let o=tb(e);for(let r of t)if(o instanceof os)o=o.get(String(r));else if(o instanceof Ca){let s=Number(r);if(!Number.isInteger(s)||s<0||s>=o.length)return;o=o.get(s)}else return;return o}function iE(e,t,o){let r=YI(e);if(r.toString()===t)return!1;return e.transact(()=>{g(r,t)},o),!0}function j2(e,t,o={}){let r=Tu(e);if(r.get("structureSeeded")===!0)return!1;return e.transact(()=>{let s=tb(e);for(let[i,c]of Object.entries(t)){if(c===void 0)continue;if(i==="children"&&Array.isArray(c))s.set(i,im(c));else s.set(i,Ce(c))}let a=JI(e);for(let[i,c]of Object.entries(o.frontmatter??{}))if(c!==void 0)a.set(i,Ce(c));r.set("schemaVersion",GI),r.set("canonical","structure"),r.set("canonicalRev",0),r.set("sourceFormat",o.sourceFormat??null),r.set("structureSeeded",!0)},o.origin),!0}var H2="jx-local",B2="jx-mirror",V2="jx-seed";class $u extends Error{constructor(e){super(`collab-path-unresolved:${e.join("/")}`);this.name="CollabPathError"}}function T(e,t){let o=DS(e,t);if(!(o instanceof os))throw new $u(t);return o}function p(e,t,o){let r=T(e,t),s=r.get("children");if(s instanceof Ca)return s;if(o&&s===void 0){let a=new Ca;return r.set("children",a),a}throw new $u([...t,"children"])}function w(e,t,o){let r=e.get(t);if(t==="children"&&Array.isArray(o)){e.set(t,im(o));return}if(h.has(t)&&n(o)){if(r instanceof ss)g(r,o);else e.set(t,new ss(o));return}if(y.has(t)&&m(o)){if(r instanceof os)S(r,o);else e.set(t,f(o));return}e.set(t,Ce(o))}function P(e,t){let{op:o}=t;switch(t.op){case"set-key":{let r=T(e,t.path);if(t.value===void 0)r.delete(t.key);else w(r,t.key,t.value);return}case"insert-child":{let r=p(e,t.parentPath,!0);if(t.index<0||t.index>r.length)throw new $u([...t.parentPath,"children",t.index]);r.insert(t.index,[d(t.node)]);return}case"remove-child":{let r=p(e,t.parentPath,!1);if(t.index<0||t.index>=r.length)throw new $u([...t.parentPath,"children",t.index]);r.delete(t.index,1);return}case"set-child":{let r=p(e,t.parentPath,!1);if(t.index<0||t.index>=r.length)throw new $u([...t.parentPath,"children",t.index]);let s=r.get(t.index);if(s instanceof ss&&n(t.node)){g(s,t.node);return}r.delete(t.index,1),r.insert(t.index,[d(t.node)]);return}case"move-child":{let r=p(e,t.fromParentPath,!1),s=p(e,t.toParentPath,!0);if(t.fromIndex<0||t.fromIndex>=r.length)throw new $u([...t.fromParentPath,"children",t.fromIndex]);let a=rm(r.get(t.fromIndex));if(r.delete(t.fromIndex,1),t.toIndex<0||t.toIndex>s.length)throw new $u([...t.toParentPath,"children",t.toIndex]);s.insert(t.toIndex,[d(a)]);return}default:throw Error(`unknown-doc-op:${o}`)}}function W2(e,t,o){e.transact(()=>{for(let r of t)P(e,r)},o)}function C(e){for(let t=0;t<e.length;t++){let o=e[t];if(!n(o))continue;if(y.has(o))return{key:o,nodePath:e.slice(0,t)};if(h.has(o))return{key:o,nodePath:e.slice(0,t)}}return null}function N(e){return e instanceof ss||e instanceof os||n(e)}function v(e){return e.every((t)=>n(t)||J(t))}function z2(e){if(e.length===0)return[];let t=e.map((s)=>s.path);if(!t.every((s)=>v(s)))return null;for(let s=0;s<t.length;s++)for(let a=0;a<t.length;a++){if(s===a)continue;let i=t[s],c=t[a];if(i.length<=c.length&&i.every((u,l)=>u===c[l]))return null}if(e.filter((s)=>s instanceof Gv).length>1)return null;let r=[];for(let s of e){let{path:a}=s,i=C(a);if(i){let{doc:c}=s.target;if(!c)return null;let u=DS(c,[...i.nodePath,i.key]);if(u===void 0)return null;r.push({key:i.key,op:"set-key",path:i.nodePath,value:rm(u)});continue}if(s instanceof PS){let c=a.at(-1);if(a.at(-2)==="children"&&J(c)){r.push({index:c,node:s.target.toString(),op:"set-child",parentPath:a.slice(0,-2)});continue}return null}if(s instanceof AS){let c=s.target;for(let[u,l]of s.changes.keys)if(l.action==="delete")r.push({key:u,op:"set-key",path:a});else r.push({key:u,op:"set-key",path:a,value:rm(c.get(u))})}else if(s instanceof Gv){if(a.at(-1)!=="children")return null;let c=a.slice(0,-1),u=0;for(let l of s.changes.delta)if(l.retain!==void 0)u+=l.retain;else if(l.delete!==void 0)for(let x=0;x<l.delete;x++)r.push({index:u,op:"remove-child",parentPath:c});else if(l.insert!==void 0){let x=Array.isArray(l.insert)?l.insert:[l.insert];for(let E of x){if(!N(E))return null;r.push({index:u,node:O(E),op:"insert-child",parentPath:c}),u+=1}}}else return null}return r}function U2(e,t,o){e.transact(()=>{let r=tb(e),s=[...r.keys()];for(let i of s)if(!(i in t)||t[i]===void 0)r.delete(i);for(let[i,c]of Object.entries(t)){if(c===void 0)continue;if(i==="children"&&Array.isArray(c))r.set(i,im(c));else r.set(i,Ce(c))}let a=Tu(e);a.set("canonicalRev",Number(a.get("canonicalRev")??0)+1)},o)}function rE(e){return Tu(e).get("canonical")==="source"?"source":"structure"}function oE(e){return Number(Tu(e).get("canonicalRev")??0)}function q2(e,t,o){if(rE(e)==="source")return!1;return e.transact(()=>{iE(e,t,o);let r=Tu(e);r.set("canonical","source"),r.set("canonicalRev",oE(e)+1)},o),!0}function K2(e,t){if(rE(e)!=="source")return!1;return e.transact(()=>{let o=Tu(e);o.set("canonical","structure"),o.set("canonicalRev",oE(e)+1)},t),!0}function G2(e,t,o){let r=[];for(let[s,a]of e.getStates()){let i=a;if(s!==o&&i.mode==="source"&&i.focusedPath===t)r.push(s)}return r}function J2(e,t){let o=e.clientID,r=e.getStates().get(o);if(r?.mode!=="source"||r.focusedPath!==t)return!1;let s=o;for(let[a,i]of e.getStates()){let c=i;if(c.mode==="source"&&c.focusedPath===t&&c.canWrite!==!1&&a<s)s=a}return s===o}var sE=["#4f9cf9","#e5484d","#30a46c","#f5a524","#8e4ec6","#00a2c7","#e93d82","#a8845c"];function Y2(e){let t=5381;for(let r=0;r<e.length;r++)t=Math.imul(t,33)+(e.codePointAt(r)??0);let o=Math.abs(t)%sE.length;return sE[o]}export{zI,UI,qI,KI,GI,Tu,JI,tb,YI,im,ZI,rm,F2,DS,iE,j2,H2,B2,V2,$u,W2,z2,U2,rE,oE,q2,K2,G2,J2,sE,Y2};
2
+
3
+ //# debugId=C08DCFE705B801A964756E2164756E21
4
+ //# sourceMappingURL=studio-44xqe0b7.js.map