@desplega.ai/agent-swarm 1.167.0 → 1.169.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 (184) hide show
  1. package/dist/{acp-adapter-zpvy6321.js → acp-adapter-m47zfx4a.js} +2 -2
  2. package/dist/{actions-fq2zrwtf.js → actions-ws7k3tvq.js} +25 -19
  3. package/dist/{amp-adapter-5gbk7501.js → amp-adapter-nvv8k8j5.js} +1 -1
  4. package/dist/{app-nctetn1e.js → app-80w6qspx.js} +5 -5
  5. package/dist/{assistant-0aq8gjvj.js → assistant-jtq439kw.js} +29 -20
  6. package/dist/{boot-reembed-1ze5853n.js → boot-reembed-3nc0aaed.js} +4 -4
  7. package/dist/{boot-reembed-fmp5ww69.js → boot-reembed-feda8wn8.js} +4 -4
  8. package/dist/{boot-scrub-sweep-cbp8xd4e.js → boot-scrub-sweep-grsa2er0.js} +5 -5
  9. package/dist/{boot-seeds-22tx8a53.js → boot-seeds-gcfgq44f.js} +7 -7
  10. package/dist/{claude-adapter-0jhgeh1d.js → claude-adapter-pjv2q7t8.js} +7 -7
  11. package/dist/{claude-managed-adapter-tzwxy803.js → claude-managed-adapter-0wa8se82.js} +2 -2
  12. package/dist/{claude-managed-setup-nrhfx5b0.js → claude-managed-setup-zxa9p9tx.js} +1 -1
  13. package/dist/{claude-sdk-session-wh77rh83.js → claude-sdk-session-c9j6k9kx.js} +8772 -8663
  14. package/dist/{cli-c2tpw9ck.js → cli-3ry5gx4f.js} +1 -1
  15. package/dist/{cli-wydz3feg.js → cli-61tbnjpf.js} +214 -2472
  16. package/dist/{cli-cexctgn5.js → cli-7vz49g7h.js} +101 -34
  17. package/dist/{cli-6qxmjpem.js → cli-8xjst8q2.js} +34 -22
  18. package/dist/{cli-tx2zvn23.js → cli-91r17hb1.js} +3 -3
  19. package/dist/{cli-577bxkf6.js → cli-a8vps458.js} +182 -2208
  20. package/dist/{cli-tc5zec7v.js → cli-b7y8113e.js} +1 -1
  21. package/dist/{cli-69egj654.js → cli-bqrs5ycj.js} +1 -1
  22. package/dist/{cli-cf2vgn9d.js → cli-dv76vq5d.js} +30 -28
  23. package/dist/{cli-g5erf0zt.js → cli-e2prcx5m.js} +31 -0
  24. package/dist/{cli-c8r99akr.js → cli-e5qk3m2a.js} +209 -31
  25. package/dist/{cli-z1dqhc9y.js → cli-eqfbsxsn.js} +3 -3
  26. package/dist/{cli-kw0jcfje.js → cli-fyeft04q.js} +1 -1
  27. package/dist/{cli-5qkcdv8c.js → cli-gmdajfw5.js} +3 -3
  28. package/dist/{cli-ypgba1a8.js → cli-jkfxpg1b.js} +1 -1
  29. package/dist/{cli-mxvnnv5q.js → cli-jv36y8wz.js} +1 -1
  30. package/dist/{cli-m7vmeepg.js → cli-km8559dm.js} +6 -6
  31. package/dist/{cli-ykt8f7va.js → cli-kp3vfknv.js} +1 -1
  32. package/dist/{cli-ymmc1zxg.js → cli-m23r88re.js} +8 -5
  33. package/dist/{cli-v1pwxreq.js → cli-n4z21pt8.js} +1 -1
  34. package/dist/{cli-mxry91sa.js → cli-qg2zhjfc.js} +73 -4
  35. package/dist/{cli-1yrcfa5s.js → cli-rbr91whd.js} +4 -4
  36. package/dist/{cli-mkdsy1nq.js → cli-rg1c8ccw.js} +93 -7
  37. package/dist/cli-rh44xx46.js +2659 -0
  38. package/dist/cli-s0k2j7q9.js +2084 -0
  39. package/dist/{cli-ty4bzkqr.js → cli-sajr098b.js} +1 -1
  40. package/dist/{cli-6vfz44sr.js → cli-swrz3mj8.js} +1 -1
  41. package/dist/{cli-p8rt8spp.js → cli-vejds37t.js} +2 -2
  42. package/dist/{cli-jbzbr36n.js → cli-w6xa5nf5.js} +1 -1
  43. package/dist/{cli-9q3wt23f.js → cli-x6z90nq9.js} +1 -1
  44. package/dist/{cli-qzmzwegq.js → cli-ysnkvdx6.js} +102 -9
  45. package/dist/{cli-y0kjpfm9.js → cli-yvxfaem2.js} +2 -2
  46. package/dist/{cli-pkj1w46r.js → cli-z48ggfyq.js} +1 -1
  47. package/dist/{cli-6bpvv8h4.js → cli-zzev32jw.js} +1 -1
  48. package/dist/cli.js +20 -17
  49. package/dist/{codex-adapter-cgesnjkr.js → codex-adapter-0kpg09ca.js} +3 -3
  50. package/dist/{codex-hook-15dgc4cb.js → codex-hook-295jpbfa.js} +2 -2
  51. package/dist/{codex-session-runner-8kd7ddhr.js → codex-session-runner-8n672hxh.js} +3 -3
  52. package/dist/{commands-h6zaaxym.js → commands-mhmg5n0x.js} +4 -4
  53. package/dist/{cursor-adapter-v8mm6bp5.js → cursor-adapter-wn8n5zzk.js} +2 -2
  54. package/dist/{db-qg3myn53.js → db-wa6s1mwv.js} +4 -4
  55. package/dist/{dispatcher-7vnwj9qw.js → dispatcher-nhs2pkr8.js} +16 -14
  56. package/dist/{dsh-adapter-tz6hfp5r.js → dsh-adapter-5423p70m.js} +1 -1
  57. package/dist/{grok-adapter-jdt2dz2s.js → grok-adapter-28pkdt80.js} +3 -3
  58. package/dist/{handlers-2qtkpncr.js → handlers-5rtf9nng.js} +19 -17
  59. package/dist/{hook-51yfcgsv.js → hook-krjfkpzy.js} +4 -4
  60. package/dist/{hook-qnbdgwvd.js → hook-qkm73zk6.js} +5 -5
  61. package/dist/{http-jsmtag08.js → http-a397xcn4.js} +4845 -3484
  62. package/dist/{index-2t9kesn1.js → index-ac0v8v9d.js} +4 -4
  63. package/dist/{index-ekywyv2v.js → index-kqre45fr.js} +16 -14
  64. package/dist/{index-bt8wkv1w.js → index-rtxg15ah.js} +17 -15
  65. package/dist/{index-t4g06w93.js → index-vvsq7v45.js} +26 -23
  66. package/dist/{index-cx1sb9bq.js → index-ytdhtdry.js} +50 -11
  67. package/dist/{keepalive-4aezx4bj.js → keepalive-psfh8ysx.js} +6 -6
  68. package/dist/{lead-r44bkpm5.js → lead-m6rppjn7.js} +29 -27
  69. package/dist/{maintenance-grz5jrzh.js → maintenance-41f837ke.js} +4 -4
  70. package/dist/{node-qm9eb6z0.js → node-fkajaq96.js} +1 -1
  71. package/dist/{oauth-refresh-sweep-wm4ctjfj.js → oauth-refresh-sweep-6hr55hm8.js} +5 -5
  72. package/dist/{onboard-v60zgqf0.js → onboard-ktrtd7cz.js} +2 -2
  73. package/dist/{otel-impl-ghh4dyf8.js → otel-impl-dq4f2k3m.js} +1 -1
  74. package/dist/{pi-mono-adapter-0eg8kw2c.js → pi-mono-adapter-e5v9w0hv.js} +3 -2
  75. package/dist/{pricing-refresh-mjrqvnvw.js → pricing-refresh-kmk7j1ra.js} +6 -6
  76. package/dist/{rbac-roles-fd5tskj9.js → rbac-roles-9w1dkkxd.js} +4 -4
  77. package/dist/{rbac-roles-axv4d74x.js → rbac-roles-9ykx9tc5.js} +5 -5
  78. package/dist/{render-v2-k50j33qd.js → render-v2-ycqm53np.js} +5 -5
  79. package/dist/resume-cq2pkp8q.js +70 -0
  80. package/dist/{setup-4syh0pd2.js → setup-0dcmdvbn.js} +2 -2
  81. package/dist/{virtual-modules-ftr9kwe8.js → virtual-modules-1x9k4jcs.js} +1 -1
  82. package/dist/{work-objects-jcdbg8rr.js → work-objects-x01x2fh8.js} +19 -17
  83. package/dist/{worker-x8j8c9sx.js → worker-py1ssb1h.js} +29 -27
  84. package/openapi.json +15622 -15042
  85. package/package.json +8 -5
  86. package/src/apps/store.ts +1 -0
  87. package/src/artifact-sdk/feedback-overlay.ts +528 -0
  88. package/src/be/db/workflow-runs.ts +95 -0
  89. package/src/be/db-queries/slack-inbound.ts +489 -0
  90. package/src/be/db.ts +9 -2
  91. package/src/be/extensions/assets.ts +1 -1
  92. package/src/be/migrations/203_workflow_run_parent_step.sql +10 -0
  93. package/src/be/migrations/204_slack_inbound_receipts.sql +51 -0
  94. package/src/be/script-connections.ts +41 -7
  95. package/src/be/scripts/run-saved.ts +40 -20
  96. package/src/be/swarm-config-guard.ts +4 -0
  97. package/src/extensions/catalog.generated.json +17 -0
  98. package/src/extensions/catalog.ts +1 -1
  99. package/src/extensions/dispatcher.ts +3 -3
  100. package/src/heartbeat/heartbeat.ts +152 -2
  101. package/src/heartbeat/templates.ts +16 -0
  102. package/src/http/all-routes.ts +1 -0
  103. package/src/http/index.ts +2 -0
  104. package/src/http/integrations.ts +3 -1
  105. package/src/http/mcp-bridge.ts +1 -0
  106. package/src/http/pages-public.ts +7 -2
  107. package/src/http/pages.ts +178 -0
  108. package/src/http/script-connections.ts +35 -0
  109. package/src/http/slack-inbound.ts +107 -0
  110. package/src/http/tasks.ts +45 -27
  111. package/src/http/users.ts +1 -1
  112. package/src/http/webhooks.ts +20 -20
  113. package/src/prompts/session-templates.ts +32 -0
  114. package/src/providers/acp-targets.ts +1 -1
  115. package/src/providers/amp-adapter.ts +2 -2
  116. package/src/providers/claude-adapter.ts +6 -0
  117. package/src/providers/claude-background-keepalive.ts +100 -0
  118. package/src/providers/claude-managed-adapter.ts +2 -11
  119. package/src/providers/claude-sdk-session.ts +7 -1
  120. package/src/providers/dsh-adapter.ts +1 -1
  121. package/src/providers/opencode-adapter.ts +1 -2
  122. package/src/providers/pi-mono-adapter.ts +3 -3
  123. package/src/realtime/browser.generated.txt +8 -8
  124. package/src/realtime/browser.ts +3 -3
  125. package/src/scheduler/scheduler.ts +82 -13
  126. package/src/scripts-runtime/executors/quickjs-pool-config.ts +26 -0
  127. package/src/scripts-runtime/executors/quickjs.ts +9 -2
  128. package/src/scripts-runtime/executors/registry.ts +1 -1
  129. package/src/server.ts +1 -0
  130. package/src/slack/actions.ts +6 -2
  131. package/src/slack/app.ts +5 -0
  132. package/src/slack/assistant.ts +15 -5
  133. package/src/slack/egress-scrub.ts +3 -2
  134. package/src/slack/handlers.ts +36 -18
  135. package/src/slack/inbound-dispatch.ts +549 -0
  136. package/src/slack/inbound-files.ts +2 -0
  137. package/src/telemetry-context.ts +1 -0
  138. package/src/tests/claude-background-keepalive-wiring.test.ts +220 -0
  139. package/src/tests/claude-background-keepalive.fixture.ts +162 -0
  140. package/src/tests/claude-background-keepalive.test.ts +139 -0
  141. package/src/tests/codex-oauth-device.test.ts +1 -1
  142. package/src/tests/connection-embedded-auth.test.ts +51 -0
  143. package/src/tests/docs-index-footprint.test.js +3 -3
  144. package/src/tests/dsh-adapter.test.ts +1 -1
  145. package/src/tests/extensions-catalog.test.ts +1 -0
  146. package/src/tests/extensions-example-slack-reply-gate.test.ts +756 -0
  147. package/src/tests/heartbeat-checklist.test.ts +243 -0
  148. package/src/tests/pages-feedback.test.ts +218 -0
  149. package/src/tests/schedule-target-type.test.ts +136 -0
  150. package/src/tests/script-connections-http.test.ts +45 -0
  151. package/src/tests/script-connections-mcp.test.ts +41 -0
  152. package/src/tests/script-connections.test.ts +2 -0
  153. package/src/tests/script-executor-quickjs-pool.test.ts +106 -0
  154. package/src/tests/script-executor-registry.test.ts +56 -0
  155. package/src/tests/send-task-self-send.test.ts +107 -0
  156. package/src/tests/slack-inbound-diagnostics-auth.test.ts +93 -0
  157. package/src/tests/slack-inbound-receipts.test.ts +684 -0
  158. package/src/tests/slack-session-status.test.ts +4 -2
  159. package/src/tests/ui-e2e-ingest-payload.test.ts +5 -1
  160. package/src/tests/user-token-routes.test.ts +1 -1
  161. package/src/tests/workflow-executors.test.ts +3 -2
  162. package/src/tests/workflow-sub-workflow.test.ts +363 -0
  163. package/src/tools/script-connections/tool.ts +35 -3
  164. package/src/tools/send-task.ts +9 -1
  165. package/src/utils/internal-ai/complete-structured.ts +6 -3
  166. package/src/utils/runtime-model-catalog.ts +1 -1
  167. package/src/workflows/engine.ts +17 -1
  168. package/src/workflows/executors/agent-task.ts +2 -2
  169. package/src/workflows/executors/human-in-the-loop.ts +3 -3
  170. package/src/workflows/executors/registry.ts +2 -0
  171. package/src/workflows/executors/script.ts +1 -1
  172. package/src/workflows/executors/sub-workflow.ts +135 -0
  173. package/src/workflows/executors/wait.ts +3 -3
  174. package/src/workflows/recovery.ts +11 -1
  175. package/src/workflows/resume.ts +77 -0
  176. package/src/workflows/wait-filter.ts +5 -7
  177. package/templates/extensions/README.md +1 -0
  178. package/templates/extensions/slack-reply-gate/README.md +98 -0
  179. package/templates/extensions/slack-reply-gate/hooks.ts +582 -0
  180. package/templates/extensions/slack-reply-gate/manifest.json +8 -0
  181. package/templates/skills/heartbeat-runbook/content.md +3 -1
  182. package/templates/skills/pages/content.md +25 -0
  183. package/templates/skills/swarm-scripts/SKILL.md +10 -0
  184. package/templates/skills/swarm-scripts/content.md +10 -0
@@ -1,10 +1,10 @@
1
- var Tp=Object.defineProperty;var Ap=(e)=>e;function Op(e,t){this[e]=Ap.bind(null,t)}var Zp=(e,t)=>{for(var r in t)Tp(e,r,{get:t[r],enumerable:!0,configurable:!0,set:Op.bind(t,r)})};var J=()=>new Map,yr=(e)=>{let t=J();return e.forEach((r,n)=>{t.set(n,r)}),t},ue=(e,t,r)=>{let n=e.get(t);if(n===void 0)e.set(t,n=r());return n},As=(e,t)=>{let r=[];for(let[n,o]of e)r.push(t(o,n));return r},Os=(e,t)=>{for(let[r,n]of e)if(t(n,r))return!0;return!1};var _e=()=>new Set;var _r=(e)=>e[e.length-1];var Zs=(e,t)=>{for(let r=0;r<t.length;r++)e.push(t[r])},le=Array.from,wr=(e,t)=>{for(let r=0;r<e.length;r++)if(!t(e[r],r,e))return!1;return!0},br=(e,t)=>{for(let r=0;r<e.length;r++)if(t(e[r],r,e))return!0;return!1};var Ps=(e,t)=>{let r=Array(e);for(let n=0;n<e;n++)r[n]=t(n,r);return r};var Ce=Array.isArray;class Ln{constructor(){this._observers=J()}on(e,t){return ue(this._observers,e,_e).add(t),t}once(e,t){let r=(...n)=>{this.off(e,r),t(...n)};this.on(e,r)}off(e,t){let r=this._observers.get(e);if(r!==void 0){if(r.delete(t),r.size===0)this._observers.delete(e)}}emit(e,t){return le((this._observers.get(e)||J()).values()).forEach((r)=>r(...t))}destroy(){this._observers=J()}}var q=Math.floor;var Ne=Math.abs;var kr=(e,t)=>e<t?e:t,we=(e,t)=>e>t?e:t;var vr=(e)=>e!==0?e<0:1/e<0;var Bn=1,Mn=2,zr=4,$r=8;var He=32,oe=64,M=128;var Tt=31,At=63,be=127;var Cs=2147483647;var{MAX_SAFE_INTEGER:Ye,MIN_SAFE_INTEGER:Fn}=Number;var Ns=Number.isInteger||((e)=>typeof e==="number"&&isFinite(e)&&q(e)===e);var{fromCharCode:qn,fromCodePoint:Pp}=String,cg=qn(65535),Cp=(e)=>e.toLowerCase(),Np=/^\s*/g,Up=(e)=>e.replace(Np,""),Dp=/([A-Z])/g,Gn=(e,t)=>Up(e.replace(Dp,(r)=>`${t}${Cp(r)}`));var Rp=(e)=>{let t=unescape(encodeURIComponent(e)),r=t.length,n=new Uint8Array(r);for(let o=0;o<r;o++)n[o]=t.codePointAt(o);return n},Qe=typeof TextEncoder<"u"?new TextEncoder:null,jp=(e)=>Qe.encode(e),Us=Qe?jp:Rp;var Xe=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});if(Xe&&Xe.decode(new Uint8Array).length===1)Xe=null;var Ds=(e,t)=>Ps(t,()=>e).join("");class tt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var Ot=()=>new tt;var Lp=(e)=>{let t=e.cpos;for(let r=0;r<e.bufs.length;r++)t+=e.bufs[r].length;return t};var se=(e)=>{let t=new Uint8Array(Lp(e)),r=0;for(let n=0;n<e.bufs.length;n++){let o=e.bufs[n];t.set(o,r),r+=o.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),r),t},Bp=(e,t)=>{let r=e.cbuf.length;if(r-e.cpos<t)e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(we(r,t)*2),e.cpos=0},N=(e,t)=>{let r=e.cbuf.length;if(e.cpos===r)e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(r*2),e.cpos=0;e.cbuf[e.cpos++]=t};var Er=N;var y=(e,t)=>{while(t>be)N(e,M|be&t),t=q(t/128);N(e,be&t)},Ir=(e,t)=>{let r=vr(t);if(r)t=-t;N(e,(t>At?M:0)|(r?oe:0)|At&t),t=q(t/64);while(t>0)N(e,(t>be?M:0)|be&t),t=q(t/128)},Wn=new Uint8Array(30000),Mp=Wn.length/3,Vp=(e,t)=>{if(t.length<Mp){let r=Qe.encodeInto(t,Wn).written||0;y(e,r);for(let n=0;n<r;n++)N(e,Wn[n])}else K(e,Us(t))},Fp=(e,t)=>{let r=unescape(encodeURIComponent(t)),n=r.length;y(e,n);for(let o=0;o<n;o++)N(e,r.codePointAt(o))},Ue=Qe&&Qe.encodeInto?Vp:Fp;var Zt=(e,t)=>{let r=e.cbuf.length,n=e.cpos,o=kr(r-n,t.length),s=t.length-o;if(e.cbuf.set(t.subarray(0,o),n),e.cpos+=o,s>0)e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(we(r*2,s)),e.cbuf.set(t.subarray(o)),e.cpos=s},K=(e,t)=>{y(e,t.byteLength),Zt(e,t)},Kn=(e,t)=>{Bp(e,t);let r=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,r},Jp=(e,t)=>Kn(e,4).setFloat32(0,t,!1),qp=(e,t)=>Kn(e,8).setFloat64(0,t,!1),Gp=(e,t)=>Kn(e,8).setBigInt64(0,t,!1);var Rs=new DataView(new ArrayBuffer(4)),Wp=(e)=>(Rs.setFloat32(0,e),Rs.getFloat32(0)===e),et=(e,t)=>{switch(typeof t){case"string":N(e,119),Ue(e,t);break;case"number":if(Ns(t)&&Ne(t)<=Cs)N(e,125),Ir(e,t);else if(Wp(t))N(e,124),Jp(e,t);else N(e,123),qp(e,t);break;case"bigint":N(e,122),Gp(e,t);break;case"object":if(t===null)N(e,126);else if(Ce(t)){N(e,117),y(e,t.length);for(let r=0;r<t.length;r++)et(e,t[r])}else if(t instanceof Uint8Array)N(e,116),K(e,t);else{N(e,118);let r=Object.keys(t);y(e,r.length);for(let n=0;n<r.length;n++){let o=r[n];Ue(e,o),et(e,t[o])}}break;case"boolean":N(e,t?120:121);break;default:N(e,127)}};class Tr extends tt{constructor(e){super();this.w=e,this.s=null,this.count=0}write(e){if(this.s===e)this.count++;else{if(this.count>0)y(this,this.count-1);this.count=1,this.w(this,e),this.s=e}}}var js=(e)=>{if(e.count>0){if(Ir(e.encoder,e.count===1?e.s:-e.s),e.count>1)y(e.encoder,e.count-2)}};class rt{constructor(){this.encoder=new tt,this.s=0,this.count=0}write(e){if(this.s===e)this.count++;else js(this),this.count=1,this.s=e}toUint8Array(){return js(this),se(this.encoder)}}var Ls=(e)=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);if(Ir(e.encoder,t),e.count>1)y(e.encoder,e.count-2)}};class Pt{constructor(){this.encoder=new tt,this.s=0,this.count=0,this.diff=0}write(e){if(this.diff===e-this.s)this.s=e,this.count++;else Ls(this),this.count=1,this.diff=e-this.s,this.s=e}toUint8Array(){return Ls(this),se(this.encoder)}}class Hn{constructor(){this.sarr=[],this.s="",this.lensE=new rt}write(e){if(this.s+=e,this.s.length>19)this.sarr.push(this.s),this.s="";this.lensE.write(e.length)}toUint8Array(){let e=new tt;return this.sarr.push(this.s),this.s="",Ue(e,this.sarr.join("")),Zt(e,this.lensE.toUint8Array()),se(e)}}var X=(e)=>Error(e),Q=()=>{throw X("Method unimplemented")},H=()=>{throw X("Unexpected case")};var Bs=X("Unexpected end of array"),Ms=X("Integer out of Range");class Ct{constructor(e){this.arr=e,this.pos=0}}var je=(e)=>new Ct(e),Vs=(e)=>e.pos!==e.arr.length;var Hp=(e,t)=>{let r=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,r},Y=(e)=>Hp(e,x(e));var De=(e)=>e.arr[e.pos++];var x=(e)=>{let t=0,r=1,n=e.arr.length;while(e.pos<n){let o=e.arr[e.pos++];if(t=t+(o&be)*r,r*=128,o<M)return t;if(t>Ye)throw Ms}throw Bs},Ar=(e)=>{let t=e.arr[e.pos++],r=t&At,n=64,o=(t&oe)>0?-1:1;if((t&M)===0)return o*r;let s=e.arr.length;while(e.pos<s){if(t=e.arr[e.pos++],r=r+(t&be)*n,n*=128,t<M)return o*r;if(r>Ye)throw Ms}throw Bs};var Yp=(e)=>{let t=x(e);if(t===0)return"";else{let r=String.fromCodePoint(De(e));if(--t<100)while(t--)r+=String.fromCodePoint(De(e));else while(t>0){let n=t<1e4?t:1e4,o=e.arr.subarray(e.pos,e.pos+n);e.pos+=n,r+=String.fromCodePoint.apply(null,o),t-=n}return decodeURIComponent(escape(r))}},Xp=(e)=>Xe.decode(Y(e)),Re=Xe?Xp:Yp;var Xn=(e,t)=>{let r=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,r},Qp=(e)=>Xn(e,4).getFloat32(0,!1),eh=(e)=>Xn(e,8).getFloat64(0,!1),th=(e)=>Xn(e,8).getBigInt64(0,!1);var rh=[(e)=>{return},(e)=>null,Ar,Qp,eh,th,(e)=>!1,(e)=>!0,Re,(e)=>{let t=x(e),r={};for(let n=0;n<t;n++){let o=Re(e);r[o]=nt(e)}return r},(e)=>{let t=x(e),r=[];for(let n=0;n<t;n++)r.push(nt(e));return r},Y],nt=(e)=>rh[127-De(e)](e);class Or extends Ct{constructor(e,t){super(e);this.reader=t,this.s=null,this.count=0}read(){if(this.count===0)if(this.s=this.reader(this),Vs(this))this.count=x(this)+1;else this.count=-1;return this.count--,this.s}}class ot extends Ct{constructor(e){super(e);this.s=0,this.count=0}read(){if(this.count===0){this.s=Ar(this);let e=vr(this.s);if(this.count=1,e)this.s=-this.s,this.count=x(this)+2}return this.count--,this.s}}class Nt extends Ct{constructor(e){super(e);this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Ar(this),t=e&1;if(this.diff=q(e/2),this.count=1,t)this.count=x(this)+2}return this.s+=this.diff,this.count--,this.s}}class Qn{constructor(e){this.decoder=new ot(e),this.str=Re(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}}var lg=crypto.subtle,Fs=crypto.getRandomValues.bind(crypto);var eo=()=>Fs(new Uint32Array(1))[0];var oh=[1e7]+-1000+-4000+-8000+-100000000000,Js=()=>oh.replace(/[018]/g,(e)=>(e^eo()&15>>e/4).toString(16));var qs=Date.now;var to=(e)=>new Promise(e);var dg=Promise.all.bind(Promise);var ro=(e)=>e===void 0?null:e;class Gs{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}}var Ws=new Gs,uh=!0;try{if(typeof localStorage<"u"&&localStorage)Ws=localStorage,uh=!1}catch(e){}var Ks=Ws;var Le=Symbol("Equality"),Zr=(e,t)=>e===t||!!e?.[Le]?.(t)||!1;var Hs=(e)=>typeof e==="object",Ys=Object.assign,ph=Object.keys;var Xs=(e,t)=>{for(let r in e)t(e[r],r)};var Ut=(e)=>ph(e).length;var Qs=(e)=>{for(let t in e)return!1;return!0},st=(e,t)=>{for(let r in e)if(!t(e[r],r))return!1;return!0},Dt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),oo=(e,t)=>e===t||Ut(e)===Ut(t)&&st(e,(r,n)=>(r!==void 0||Dt(t,n))&&Zr(t[n],r)),hh=Object.freeze,so=(e)=>{for(let t in e){let r=e[t];if(typeof r==="object"||typeof r==="function")so(e[t])}return hh(e)};var jt=(e,t,r=0)=>{try{for(;r<e.length;r++)e[r](...t)}finally{if(r<e.length)jt(e,t,r+1)}};var ei=(e)=>e;var Rt=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Le]!=null)return e[Le](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:{if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;break}case Set:{if(e.size!==t.size)return!1;for(let r of e)if(!t.has(r))return!1;break}case Map:{if(e.size!==t.size)return!1;for(let r of e.keys())if(!t.has(r)||!Rt(e.get(r),t.get(r)))return!1;break}case void 0:case Object:if(Ut(e)!==Ut(t))return!1;for(let r in e)if(!Dt(e,r)||!Rt(e[r],t[r]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Rt(e[r],t[r]))return!1;break;default:return!1}return!0},ti=(e,t)=>t.includes(e);var Lt=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";var fg=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,pe,dh=[],fh=()=>{if(pe===void 0)if(Lt){pe=J();let e=process.argv,t=null;for(let r=0;r<e.length;r++){let n=e[r];if(n[0]==="-"){if(t!==null)pe.set(t,"");t=n}else if(t!==null)pe.set(t,n),t=null;else dh.push(n)}if(t!==null)pe.set(t,"")}else if(typeof location==="object")pe=J(),(location.search||"?").slice(1).split("&").forEach((e)=>{if(e.length!==0){let[t,r]=e.split("=");pe.set(`--${Gn(t,"-")}`,r),pe.set(`-${Gn(t,"-")}`,r)}});else pe=J();return pe},ao=(e)=>fh().has(e);var Bt=(e)=>Lt?ro(process.env[e.toUpperCase().replaceAll("-","_")]):ro(Ks.getItem(e));var ri=(e)=>ao("--"+e)||Bt(e)!==null,ni=ri("production"),mh=Lt&&ti(process.env.FORCE_COLOR,["true","1","2"]),oi=mh||!ao("--no-colors")&&!ri("no-color")&&(!Lt||process.stdout.isTTY)&&(!Lt||ao("--color")||Bt("COLORTERM")!==null||(Bt("TERM")||"").includes("color"));var gh=(e)=>new Uint8Array(e);var si=(e)=>{let t=gh(e.byteLength);return t.set(e),t};class ii{constructor(e,t){this.left=e,this.right=t}}var he=(e,t)=>new ii(e,t);var lo=(e)=>e.next()>=0.5,Pr=(e,t,r)=>q(e.next()*(r+1-t)+t);var po=(e,t,r)=>q(e.next()*(r+1-t)+t);var ho=(e,t,r)=>po(e,t,r);var _h=(e)=>qn(ho(e,97,122)),ci=(e,t=0,r=20)=>{let n=ho(e,t,r),o="";for(let s=0;s<n;s++)o+=_h(e);return o};var Cr=(e,t)=>t[ho(e,0,t.length-1)];var bh=Symbol("0schema");class ui{constructor(){this._rerrs=[]}extend(e,t,r,n=null){this._rerrs.push({path:e,expected:t,has:r,message:n})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let r=this._rerrs[t];e.push(Ds(" ",(this._rerrs.length-t)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(`
2
- `)}}var fo=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor)return!1;if(e[Le])return Zr(e,t);if(Ce(e))return wr(e,(r)=>br(t,(n)=>fo(r,n)));else if(Hs(e))return st(e,(r,n)=>fo(r,t[n]));return!1};class V{static _dilutes=!1;extends(e){let[t,r]=[this.shape,e.shape];if(this.constructor._dilutes)[r,t]=[t,r];return fo(t,r)}equals(e){return this.constructor===e.constructor&&Rt(this.shape,e.shape)}[bh](){return!0}[Le](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Q()}get nullable(){return ut(this,Vr)}get optional(){return new mo(this)}cast(e){return ai(e,this),e}expect(e){return ai(e,this),e}}class Dr extends V{constructor(e,t){super();this.shape=e,this._c=t}check(e,t=void 0){let r=e?.constructor===this.shape&&(this._c==null||this._c(e));return!r&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor!==this.shape?"Constructor match failed":"Check failed"),r}}var O=(e,t=null)=>new Dr(e,t),gg=O(Dr);class Rr extends V{constructor(e){super();this.shape=e}check(e,t){let r=this.shape(e);return!r&&t?.extend(null,"custom prop",e?.constructor.name,"failed to check custom prop"),r}}var Z=(e)=>new Rr(e),xg=O(Rr);class Vt extends V{constructor(e){super();this.shape=e}check(e,t){let r=this.shape.some((n)=>n===e);return!r&&t?.extend(null,this.shape.join(" | "),e.toString()),r}}var jr=(...e)=>new Vt(e),li=O(Vt),kh=RegExp.escape||((e)=>e.replace(/[().|&,$^[\]]/g,(t)=>"\\"+t)),pi=(e)=>{if(at.check(e))return[kh(e)];if(li.check(e))return e.shape.map((t)=>t+"");if(_i.check(e))return["[+-]?\\d+.?\\d*"];if(wi.check(e))return[".*"];if(Nr.check(e))return e.shape.map(pi).flat(1);H()};class hi extends V{constructor(e){super();this.shape=e,this._r=new RegExp("^"+e.map(pi).map((t)=>`(${t.join("|")})`).join("")+"$")}check(e,t){let r=this._r.exec(e)!=null;return!r&&t?.extend(null,this._r.toString(),e.toString(),"String doesn't match string template."),r}}var yg=O(hi),vh=Symbol("optional");class mo extends V{constructor(e){super();this.shape=e}check(e,t){let r=e===void 0||this.shape.check(e);return!r&&t?.extend(null,"undefined (optional)","()"),r}get[vh](){return!0}}var zh=O(mo);class go extends V{check(e,t){return t?.extend(null,"never",typeof e),!1}}var _g=new go,wg=O(go);class Lr extends V{constructor(e,t=!1){super();this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new Lr(this.shape,!0)}check(e,t){if(e==null)return t?.extend(null,"object","null"),!1;return st(this.shape,(r,n)=>{let o=this._isPartial&&!Dt(e,n)||r.check(e[n],t);return!o&&t?.extend(n.toString(),r.toString(),typeof e[n],"Object property does not match"),o})}}var $h=(e)=>new Lr(e),Sh=O(Lr),Eh=Z((e)=>e!=null&&(e.constructor===Object||e.constructor==null));class xo extends V{constructor(e,t){super();this.shape={keys:e,values:t}}check(e,t){return e!=null&&st(e,(r,n)=>{let o=this.shape.keys.check(n,t);return!o&&t?.extend(n+"","Record",typeof e,o?"Key doesn't match schema":"Value doesn't match value"),o&&this.shape.values.check(r,t)})}}var di=(e,t)=>new xo(e,t),Ih=O(xo);class yo extends V{constructor(e){super();this.shape=e}check(e,t){return e!=null&&st(this.shape,(r,n)=>{let o=r.check(e[n],t);return!o&&t?.extend(n.toString(),"Tuple",typeof r),o})}}var Th=(...e)=>new yo(e),bg=O(yo);class _o extends V{constructor(e){super();this.shape=e.length===1?e[0]:new Br(e)}check(e,t){let r=Ce(e)&&wr(e,(n)=>this.shape.check(n));return!r&&t?.extend(null,"Array",""),r}}var fi=(...e)=>new _o(e),Ah=O(_o),Oh=Z((e)=>Ce(e));class wo extends V{constructor(e,t){super();this.shape=e,this._c=t}check(e,t){let r=e instanceof this.shape&&(this._c==null||this._c(e));return!r&&t?.extend(null,this.shape.name,e?.constructor.name),r}}var Zh=(e,t=null)=>new wo(e,t),kg=O(wo),Ph=Zh(V);class mi extends V{constructor(e){super();this.len=e.length-1,this.args=Th(...e.slice(-1)),this.res=e[this.len]}check(e,t){let r=e.constructor===Function&&e.length<=this.len;return!r&&t?.extend(null,"function",typeof e),r}}var Ch=O(mi),Nh=Z((e)=>typeof e==="function");class gi extends V{constructor(e){super();this.shape=e}check(e,t){let r=wr(this.shape,(n)=>n.check(e,t));return!r&&t?.extend(null,"Intersectinon",typeof e),r}}var vg=O(gi,(e)=>e.shape.length>0);class Br extends V{static _dilutes=!0;constructor(e){super();this.shape=e}check(e,t){let r=br(this.shape,(n)=>n.check(e,t));return t?.extend(null,"Union",typeof e),r}}var ut=(...e)=>e.findIndex((t)=>Nr.check(t))>=0?ut(...e.map((t)=>Mt(t)).map((t)=>Nr.check(t)?t.shape:[t]).flat(1)):e.length===1?e[0]:new Br(e),Nr=O(Br),xi=()=>!0,Ur=Z(xi),Uh=O(Rr,(e)=>e.shape===xi),bo=Z((e)=>typeof e==="bigint"),Dh=Z((e)=>e===bo),yi=Z((e)=>typeof e==="symbol"),zg=Z((e)=>e===yi),ct=Z((e)=>typeof e==="number"),_i=Z((e)=>e===ct),at=Z((e)=>typeof e==="string"),wi=Z((e)=>e===at),Mr=Z((e)=>typeof e==="boolean"),Rh=Z((e)=>e===Mr),bi=jr(void 0),$g=O(Vt,(e)=>e.shape.length===1&&e.shape[0]===void 0),Sg=jr(void 0);var Vr=jr(null),jh=O(Vt,(e)=>e.shape.length===1&&e.shape[0]===null),Eg=O(Uint8Array),Ig=O(Dr,(e)=>e.shape===Uint8Array),Lh=ut(ct,at,Vr,bi,bo,Mr,yi),Tg=(()=>{let e=fi(Ur),t=di(at,Ur),r=ut(ct,at,Vr,Mr,e,t);return e.shape=r,t.shape.values=r,r})(),Mt=(e)=>{if(Ph.check(e))return e;else if(Eh.check(e)){let t={};for(let r in e)t[r]=Mt(e[r]);return $h(t)}else if(Oh.check(e))return ut(...e.map(Mt));else if(Lh.check(e))return jr(e);else if(Nh.check(e))return O(e);H()},ai=ni?()=>{}:(e,t)=>{let r=new ui;if(!t.check(e,r))throw X(`Expected value to be of type ${t.constructor.name}.
3
- ${r.toString()}`)};class ki{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:Mt(e),h:t}),this}else(e){return this.if(Ur,e)}done(){return(e,t)=>{for(let r=0;r<this.patterns.length;r++){let n=this.patterns[r];if(n.if.check(e))return n.h(e,t)}throw X("Unhandled pattern")}}}var Bh=(e)=>new ki(e),vi=Bh(Ur).if(_i,(e,t)=>Pr(t,Fn,Ye)).if(wi,(e,t)=>ci(t)).if(Rh,(e,t)=>lo(t)).if(Dh,(e,t)=>BigInt(Pr(t,Fn,Ye))).if(Nr,(e,t)=>it(t,Cr(t,e.shape))).if(Sh,(e,t)=>{let r={};for(let n in e.shape){let o=e.shape[n];if(zh.check(o)){if(lo(t))continue;o=o.shape}r[n]=vi(o,t)}return r}).if(Ah,(e,t)=>{let r=[],n=po(t,0,42);for(let o=0;o<n;o++)r.push(it(t,e.shape));return r}).if(li,(e,t)=>Cr(t,e.shape)).if(jh,(e,t)=>null).if(Ch,(e,t)=>{let r=it(t,e.res);return()=>r}).if(Uh,(e,t)=>it(t,Cr(t,[ct,at,Vr,bi,bo,Mr,fi(ct),di(ut("a","b","c"),ct)]))).if(Ih,(e,t)=>{let r={},n=Pr(t,0,3);for(let o=0;o<n;o++){let s=it(t,e.shape.keys),i=it(t,e.shape.values);r[s]=i}return r}).done(),it=(e,t)=>vi(Mt(t),e);var Be=typeof document<"u"?document:{};var Ag=Z((e)=>e.nodeType===qh);var Og=typeof DOMParser<"u"?new DOMParser:null;var Zg=Z((e)=>e.nodeType===Vh);var Pg=Z((e)=>e.nodeType===Fh);var zi=(e)=>As(e,(t,r)=>`${r}:${t};`).join("");var{ELEMENT_NODE:Vh,TEXT_NODE:Fh,CDATA_SECTION_NODE:Cg,COMMENT_NODE:Ng,DOCUMENT_NODE:Jh,DOCUMENT_TYPE_NODE:Ug,DOCUMENT_FRAGMENT_NODE:qh}=Be,Dg=Z((e)=>e.nodeType===Jh);var de=Symbol;var Ft=de(),Jt=de(),ko=de(),vo=de(),zo=de(),qt=de(),$o=de(),lt=de(),So=de(),$i=(e)=>{if(e.length===1&&e[0]?.constructor===Function)e=e[0]();let t=[],r=[],n=0;for(;n<e.length;n++){let o=e[n];if(o===void 0)break;else if(o.constructor===String||o.constructor===Number)t.push(o);else if(o.constructor===Object)break}if(n>0)r.push(t.join(""));for(;n<e.length;n++){let o=e[n];if(!(o instanceof Symbol))r.push(o)}return r};var Rg=qs();var Hh={[Ft]:he("font-weight","bold"),[Jt]:he("font-weight","normal"),[ko]:he("color","blue"),[zo]:he("color","green"),[vo]:he("color","grey"),[qt]:he("color","red"),[$o]:he("color","purple"),[lt]:he("color","orange"),[So]:he("color","black")},Yh=(e)=>{if(e.length===1&&e[0]?.constructor===Function)e=e[0]();let t=[],r=[],n=J(),o=[],s=0;for(;s<e.length;s++){let i=e[s],c=Hh[i];if(c!==void 0)n.set(c.left,c.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let a=zi(n);if(s>0||a.length>0)t.push("%c"+i),r.push(a);else t.push(i)}else break}}if(s>0)o=r,o.unshift(t.join(""));for(;s<e.length;s++){let i=e[s];if(!(i instanceof Symbol))o.push(i)}return o},Si=oi?Yh:$i,Ei=(...e)=>{console.log(...Si(e)),Ti.forEach((t)=>t.print(e))},Ii=(...e)=>{console.warn(...Si(e)),e.unshift(lt),Ti.forEach((t)=>t.print(e))};var Ti=_e();var Ai=(e)=>({[Symbol.iterator](){return this},next:e}),Oi=(e,t)=>Ai(()=>{let r;do r=e.next();while(!r.done&&!t(r.value));return r}),Fr=(e,t)=>Ai(()=>{let{done:r,value:n}=e.next();return{done:r,value:r?void 0:t(n)}});class Ht{constructor(e,t){this.clock=e,this.len=t}}class dt{constructor(){this.clients=new Map}}var Vi=(e,t,r)=>t.clients.forEach((n,o)=>{let s=e.doc.store.clients.get(o);if(s!=null){let i=s[s.length-1],c=i.id.clock+i.length;for(let a=0,l=n[a];a<n.length&&l.clock<c;l=n[++a])rc(e,s,l.clock,l.len,r)}}),ed=(e,t)=>{let r=0,n=e.length-1;while(r<=n){let o=q((r+n)/2),s=e[o],i=s.clock;if(i<=t){if(t<i+s.len)return o;r=o+1}else n=o-1}return null},Fi=(e,t)=>{let r=e.clients.get(t.client);return r!==void 0&&ed(r,t.clock)!==null},Oo=(e)=>{e.clients.forEach((t)=>{t.sort((o,s)=>o.clock-s.clock);let r,n;for(r=1,n=1;r<t.length;r++){let o=t[n-1],s=t[r];if(o.clock+o.len>=s.clock)t[n-1]=new Ht(o.clock,we(o.len,s.clock+s.len-o.clock));else{if(n<r)t[n]=s;n++}}t.length=n})},td=(e)=>{let t=new dt;for(let r=0;r<e.length;r++)e[r].clients.forEach((n,o)=>{if(!t.clients.has(o)){let s=n.slice();for(let i=r+1;i<e.length;i++)Zs(s,e[i].clients.get(o)||[]);t.clients.set(o,s)}});return Oo(t),t},Hr=(e,t,r,n)=>{ue(e.clients,t,()=>[]).push(new Ht(r,n))},Ji=()=>new dt,rd=(e)=>{let t=Ji();return e.clients.forEach((r,n)=>{let o=[];for(let s=0;s<r.length;s++){let i=r[s];if(i.deleted){let c=i.id.clock,a=i.length;if(s+1<r.length)for(let l=r[s+1];s+1<r.length&&l.deleted;l=r[++s+1])a+=l.length;o.push(new Ht(c,a))}}if(o.length>0)t.clients.set(n,o)}),t},ft=(e,t)=>{y(e.restEncoder,t.clients.size),le(t.clients.entries()).sort((r,n)=>n[0]-r[0]).forEach(([r,n])=>{e.resetDsCurVal(),y(e.restEncoder,r);let o=n.length;y(e.restEncoder,o);for(let s=0;s<o;s++){let i=n[s];e.writeDsClock(i.clock),e.writeDsLen(i.len)}})},Zo=(e)=>{let t=new dt,r=x(e.restDecoder);for(let n=0;n<r;n++){e.resetDsCurVal();let o=x(e.restDecoder),s=x(e.restDecoder);if(s>0){let i=ue(t.clients,o,()=>[]);for(let c=0;c<s;c++)i.push(new Ht(e.readDsClock(),e.readDsLen()))}}return t},Zi=(e,t,r)=>{let n=new dt,o=x(e.restDecoder);for(let s=0;s<o;s++){e.resetDsCurVal();let i=x(e.restDecoder),c=x(e.restDecoder),a=r.clients.get(i)||[],l=U(r,i);for(let u=0;u<c;u++){let h=e.readDsClock(),p=h+e.readDsLen();if(h<l){if(l<p)Hr(n,i,l,p-l);let f=fe(a,h),m=a[f];if(!m.deleted&&m.id.clock<h)a.splice(f+1,0,on(t,m,h-m.id.clock)),f++;while(f<a.length)if(m=a[f++],m.id.clock<p){if(!m.deleted){if(p<m.id.clock+m.length)a.splice(f,0,on(t,m,p-m.id.clock));m.delete(t)}}else break}else Hr(n,i,h,p-h)}}if(n.clients.size>0){let s=new Te;return y(s.restEncoder,0),ft(s,n),s.toUint8Array()}return null};var qi=eo;class ge extends Ln{constructor({guid:e=Js(),collectionid:t=null,gc:r=!0,gcFilter:n=()=>!0,meta:o=null,autoLoad:s=!1,shouldLoad:i=!0}={}){super();this.gc=r,this.gcFilter=n,this.clientID=qi(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new Ro,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=i,this.autoLoad=s,this.meta=o,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=to((a)=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});let c=()=>to((a)=>{let l=(u)=>{if(u===void 0||u===!0)this.off("sync",l),a()};this.on("sync",l)});this.on("sync",(a)=>{if(a===!1&&this.isSynced)this.whenSynced=c();if(this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded)this.emit("load",[this])}),this.whenSynced=c()}load(){let e=this._item;if(e!==null&&!this.shouldLoad)v(e.parent.doc,(t)=>{t.subdocsLoaded.add(this)},null,!0);this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(le(this.subdocs).map((e)=>e.guid))}transact(e,t=null){return v(this,e,t)}get(e,t=D){let r=ue(this.share,e,()=>{let o=new t;return o._integrate(this,null),o}),n=r.constructor;if(t!==D&&n!==t)if(n===D){let o=new t;o._map=r._map,r._map.forEach((s)=>{for(;s!==null;s=s.left)s.parent=o}),o._start=r._start;for(let s=o._start;s!==null;s=s.right)s.parent=o;return o._length=r._length,this.share.set(e,o),o._integrate(this,null),o}else throw Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,re)}getText(e=""){return this.get(e,ie)}getMap(e=""){return this.get(e,G)}getXmlElement(e=""){return this.get(e,ht)}getXmlFragment(e=""){return this.get(e,Fe)}toJSON(){let e={};return this.share.forEach((t,r)=>{e[r]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,le(this.subdocs).forEach((t)=>t.destroy());let e=this._item;if(e!==null){this._item=null;let t=e.content;t.doc=new ge({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,v(e.parent.doc,(r)=>{let n=t.doc;if(!e.deleted)r.subdocsAdded.add(n);r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class Po{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return x(this.restDecoder)}readDsLen(){return x(this.restDecoder)}}class Co extends Po{readLeftID(){return _(x(this.restDecoder),x(this.restDecoder))}readRightID(){return _(x(this.restDecoder),x(this.restDecoder))}readClient(){return x(this.restDecoder)}readInfo(){return De(this.restDecoder)}readString(){return Re(this.restDecoder)}readParentInfo(){return x(this.restDecoder)===1}readTypeRef(){return x(this.restDecoder)}readLen(){return x(this.restDecoder)}readAny(){return nt(this.restDecoder)}readBuf(){return si(Y(this.restDecoder))}readJSON(){return JSON.parse(Re(this.restDecoder))}readKey(){return Re(this.restDecoder)}}class Gi{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=x(this.restDecoder),this.dsCurrVal}readDsLen(){let e=x(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Ve extends Gi{constructor(e){super(e);this.keys=[],x(e),this.keyClockDecoder=new Nt(Y(e)),this.clientDecoder=new ot(Y(e)),this.leftClockDecoder=new Nt(Y(e)),this.rightClockDecoder=new Nt(Y(e)),this.infoDecoder=new Or(Y(e),De),this.stringDecoder=new Qn(Y(e)),this.parentInfoDecoder=new Or(Y(e),De),this.typeRefDecoder=new ot(Y(e)),this.lenDecoder=new ot(Y(e))}readLeftID(){return new Me(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Me(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 nt(this.restDecoder)}readBuf(){return Y(this.restDecoder)}readJSON(){return nt(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];else{let t=this.stringDecoder.read();return this.keys.push(t),t}}}class No{constructor(){this.restEncoder=Ot()}toUint8Array(){return se(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){y(this.restEncoder,e)}writeDsLen(e){y(this.restEncoder,e)}}class mt extends No{writeLeftID(e){y(this.restEncoder,e.client),y(this.restEncoder,e.clock)}writeRightID(e){y(this.restEncoder,e.client),y(this.restEncoder,e.clock)}writeClient(e){y(this.restEncoder,e)}writeInfo(e){Er(this.restEncoder,e)}writeString(e){Ue(this.restEncoder,e)}writeParentInfo(e){y(this.restEncoder,e?1:0)}writeTypeRef(e){y(this.restEncoder,e)}writeLen(e){y(this.restEncoder,e)}writeAny(e){et(this.restEncoder,e)}writeBuf(e){K(this.restEncoder,e)}writeJSON(e){Ue(this.restEncoder,JSON.stringify(e))}writeKey(e){Ue(this.restEncoder,e)}}class Uo{constructor(){this.restEncoder=Ot(),this.dsCurrVal=0}toUint8Array(){return se(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,y(this.restEncoder,t)}writeDsLen(e){if(e===0)H();y(this.restEncoder,e-1),this.dsCurrVal+=e}}class Te extends Uo{constructor(){super();this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Pt,this.clientEncoder=new rt,this.leftClockEncoder=new Pt,this.rightClockEncoder=new Pt,this.infoEncoder=new Tr(Er),this.stringEncoder=new Hn,this.parentInfoEncoder=new Tr(Er),this.typeRefEncoder=new rt,this.lenEncoder=new rt}toUint8Array(){let e=Ot();return y(e,0),K(e,this.keyClockEncoder.toUint8Array()),K(e,this.clientEncoder.toUint8Array()),K(e,this.leftClockEncoder.toUint8Array()),K(e,this.rightClockEncoder.toUint8Array()),K(e,se(this.infoEncoder)),K(e,this.stringEncoder.toUint8Array()),K(e,se(this.parentInfoEncoder)),K(e,this.typeRefEncoder.toUint8Array()),K(e,this.lenEncoder.toUint8Array()),Zt(e,se(this.restEncoder)),se(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){et(this.restEncoder,e)}writeBuf(e){K(this.restEncoder,e)}writeJSON(e){et(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);if(t===void 0)this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e);else this.keyClockEncoder.write(t)}}var nd=(e,t,r,n)=>{n=we(n,t[0].id.clock);let o=fe(t,n);y(e.restEncoder,t.length-o),e.writeClient(r),y(e.restEncoder,n);let s=t[o];s.write(e,n-s.id.clock);for(let i=o+1;i<t.length;i++)t[i].write(e,0)},Do=(e,t,r)=>{let n=new Map;r.forEach((o,s)=>{if(U(t,s)>o)n.set(s,o)}),cn(t).forEach((o,s)=>{if(!r.has(s))n.set(s,0)}),y(e.restEncoder,n.size),le(n.entries()).sort((o,s)=>s[0]-o[0]).forEach(([o,s])=>{nd(e,t.clients.get(o),o,s)})},od=(e,t)=>{let r=J(),n=x(e.restDecoder);for(let o=0;o<n;o++){let s=x(e.restDecoder),i=Array(s),c=e.readClient(),a=x(e.restDecoder);r.set(c,{i:0,refs:i});for(let l=0;l<s;l++){let u=e.readInfo();switch(Tt&u){case 0:{let h=e.readLen();i[l]=new ee(_(c,a),h),a+=h;break}case 10:{let h=x(e.restDecoder);i[l]=new te(_(c,a),h),a+=h;break}default:{let h=(u&(oe|M))===0,p=new P(_(c,a),null,(u&M)===M?e.readLeftID():null,null,(u&oe)===oe?e.readRightID():null,h?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,h&&(u&He)===He?e.readString():null,Ec(e,u));i[l]=p,a+=p.length}}}}return r},sd=(e,t,r)=>{let n=[],o=le(r.keys()).sort((f,m)=>f-m);if(o.length===0)return null;let s=()=>{if(o.length===0)return null;let f=r.get(o[o.length-1]);while(f.refs.length===f.i)if(o.pop(),o.length>0)f=r.get(o[o.length-1]);else return null;return f},i=s();if(i===null)return null;let c=new Ro,a=new Map,l=(f,m)=>{let k=a.get(f);if(k==null||k>m)a.set(f,m)},u=i.refs[i.i++],h=new Map,p=()=>{for(let f of n){let m=f.id.client,k=r.get(m);if(k)k.i--,c.clients.set(m,k.refs.slice(k.i)),r.delete(m),k.i=0,k.refs=[];else c.clients.set(m,[f]);o=o.filter((z)=>z!==m)}n.length=0};while(!0){if(u.constructor!==te){let m=ue(h,u.id.client,()=>U(t,u.id.client))-u.id.clock;if(m<0)n.push(u),l(u.id.client,u.id.clock-1),p();else{let k=u.getMissing(e,t);if(k!==null){n.push(u);let z=r.get(k)||{refs:[],i:0};if(z.refs.length===z.i)l(k,U(t,k)),p();else{u=z.refs[z.i++];continue}}else if(m===0||m<u.length)u.integrate(e,m),h.set(u.id.client,u.id.clock+u.length)}}if(n.length>0)u=n.pop();else if(i!==null&&i.i<i.refs.length)u=i.refs[i.i++];else if(i=s(),i===null)break;else u=i.refs[i.i++]}if(c.clients.size>0){let f=new Te;return Do(f,c,new Map),y(f.restEncoder,0),{missing:a,update:f.toUint8Array()}}return null},id=(e,t)=>Do(e,t.doc.store,t.beforeState),cd=(e,t,r,n=new Ve(e))=>v(t,(o)=>{o.local=!1;let s=!1,i=o.doc,c=i.store,a=od(n,i),l=sd(o,c,a),u=c.pendingStructs;if(u){for(let[p,f]of u.missing)if(f<U(c,p)){s=!0;break}if(l){for(let[p,f]of l.missing){let m=u.missing.get(p);if(m==null||m>f)u.missing.set(p,f)}u.update=Yr([u.update,l.update])}}else c.pendingStructs=l;let h=Zi(n,o,c);if(c.pendingDs){let p=new Ve(je(c.pendingDs));x(p.restDecoder);let f=Zi(p,o,c);if(h&&f)c.pendingDs=Yr([h,f]);else c.pendingDs=h||f}else c.pendingDs=h;if(s){let p=c.pendingStructs.update;c.pendingStructs=null,Wi(o.doc,p)}},r,!1);var Wi=(e,t,r,n=Ve)=>{let o=je(t);cd(o,e,r,new n(o))},sn=(e,t,r)=>Wi(e,t,r,Co),ad=(e,t,r=new Map)=>{Do(e,t.store,r),ft(e,rd(t.store))},ud=(e,t=new Uint8Array([0]),r=new Te)=>{let n=Ki(t);ad(r,e,n);let o=[r.toUint8Array()];if(e.store.pendingDs)o.push(e.store.pendingDs);if(e.store.pendingStructs)o.push(kd(e.store.pendingStructs.update,t));if(o.length>1){if(r.constructor===mt)return wd(o.map((s,i)=>i===0?s:zd(s)));else if(r.constructor===Te)return Yr(o)}return o[0]},gt=(e,t)=>ud(e,t,new mt),ld=(e)=>{let t=new Map,r=x(e.restDecoder);for(let n=0;n<r;n++){let o=x(e.restDecoder),s=x(e.restDecoder);t.set(o,s)}return t},Ki=(e)=>ld(new Po(je(e))),Hi=(e,t)=>(y(e.restEncoder,t.size),le(t.entries()).sort((r,n)=>n[0]-r[0]).forEach(([r,n])=>{y(e.restEncoder,r),y(e.restEncoder,n)}),e),pd=(e,t)=>Hi(e,cn(t.store)),hd=(e,t=new Uo)=>{if(e instanceof Map)Hi(t,e);else pd(t,e);return t.toUint8Array()},Yi=(e)=>hd(e,new No);class Xi{constructor(){this.l=[]}}var Pi=()=>new Xi,Ci=(e,t)=>e.l.push(t),Ni=(e,t)=>{let r=e.l,n=r.length;if(e.l=r.filter((o)=>t!==o),n===e.l.length)console.error("[yjs] Tried to remove event handler that doesn't exist.")},Qi=(e,t,r)=>jt(e.l,[t,r]);class Me{constructor(e,t){this.client=e,this.clock=t}}var Jr=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,_=(e,t)=>new Me(e,t);var dd=(e)=>{for(let[t,r]of e.doc.share.entries())if(r===e)return t;throw H()};class ec{constructor(e,t){this.ds=e,this.sv=t}}var fd=(e,t)=>new ec(e,t),Kg=fd(Ji(),new Map);var pt=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!Fi(t.ds,e.id),To=(e,t)=>{let r=ue(e.meta,To,_e),n=e.doc.store;if(!r.has(t))t.sv.forEach((o,s)=>{if(o<U(n,s))Ae(e,_(s,o))}),Vi(e,t.ds,(o)=>{}),r.add(t)};class Ro{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}var cn=(e)=>{let t=new Map;return e.clients.forEach((r,n)=>{let o=r[r.length-1];t.set(n,o.id.clock+o.length)}),t},U=(e,t)=>{let r=e.clients.get(t);if(r===void 0)return 0;let n=r[r.length-1];return n.id.clock+n.length},tc=(e,t)=>{let r=e.clients.get(t.id.client);if(r===void 0)r=[],e.clients.set(t.id.client,r);else{let n=r[r.length-1];if(n.id.clock+n.length!==t.id.clock)throw H()}r.push(t)},fe=(e,t)=>{let r=0,n=e.length-1,o=e[n],s=o.id.clock;if(s===t)return n;let i=q(t/(s+o.length-1)*n);while(r<=n){if(o=e[i],s=o.id.clock,s<=t){if(t<s+o.length)return i;r=i+1}else n=i-1;i=q((r+n)/2)}throw H()},md=(e,t)=>{let r=e.clients.get(t.client);return r[fe(r,t.clock)]},Eo=md,Ao=(e,t,r)=>{let n=fe(t,r),o=t[n];if(o.id.clock<r&&o instanceof P)return t.splice(n+1,0,on(e,o,r-o.id.clock)),n+1;return n},Ae=(e,t)=>{let r=e.doc.store.clients.get(t.client);return r[Ao(e,r,t.clock)]},Ui=(e,t,r)=>{let n=t.clients.get(r.client),o=fe(n,r.clock),s=n[o];if(r.clock!==s.id.clock+s.length-1&&s.constructor!==ee)n.splice(o+1,0,on(e,s,r.clock-s.id.clock+1));return s},gd=(e,t,r)=>{let n=e.clients.get(t.id.client);n[fe(n,t.id.clock)]=r},rc=(e,t,r,n,o)=>{if(n===0)return;let s=r+n,i=Ao(e,t,r),c;do{if(c=t[i++],s<c.id.clock+c.length)Ao(e,t,s);o(c)}while(i<t.length&&t[i].id.clock<s)};class nc{constructor(e,t,r){this.doc=e,this.deleteSet=new dt,this.beforeState=cn(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}var Di=(e,t)=>{if(t.deleteSet.clients.size===0&&!Os(t.afterState,(r,n)=>t.beforeState.get(n)!==r))return!1;return Oo(t.deleteSet),id(e,t),ft(e,t.deleteSet),!0},Ri=(e,t,r)=>{let n=t._item;if(n===null||n.id.clock<(e.beforeState.get(n.id.client)||0)&&!n.deleted)ue(e.changed,t,_e).add(r)},Wr=(e,t)=>{let r=e[t],n=e[t-1],o=t;for(;o>0;r=n,n=e[--o-1]){if(n.deleted===r.deleted&&n.constructor===r.constructor){if(n.mergeWith(r)){if(r instanceof P&&r.parentSub!==null&&r.parent._map.get(r.parentSub)===r)r.parent._map.set(r.parentSub,n);continue}}break}let s=t-o;if(s)e.splice(t+1-s,s);return s},xd=(e,t,r)=>{for(let[n,o]of e.clients.entries()){let s=t.clients.get(n);for(let i=o.length-1;i>=0;i--){let c=o[i],a=c.clock+c.len;for(let l=fe(s,c.clock),u=s[l];l<s.length&&u.id.clock<a;u=s[++l]){let h=s[l];if(c.clock+c.len<=h.id.clock)break;if(h instanceof P&&h.deleted&&!h.keep&&r(h))h.gc(t,!1)}}}},yd=(e,t)=>{e.clients.forEach((r,n)=>{let o=t.clients.get(n);for(let s=r.length-1;s>=0;s--){let i=r[s],c=kr(o.length-1,1+fe(o,i.clock+i.len-1));for(let a=c,l=o[a];a>0&&l.id.clock>=i.clock;l=o[a])a-=1+Wr(o,a)}})};var oc=(e,t)=>{if(t<e.length){let r=e[t],n=r.doc,o=n.store,s=r.deleteSet,i=r._mergeStructs;try{Oo(s),r.afterState=cn(r.doc.store),n.emit("beforeObserverCalls",[r,n]);let c=[];r.changed.forEach((a,l)=>c.push(()=>{if(l._item===null||!l._item.deleted)l._callObserver(r,a)})),c.push(()=>{r.changedParentTypes.forEach((a,l)=>{if(l._dEH.l.length>0&&(l._item===null||!l._item.deleted))a=a.filter((u)=>u.target._item===null||!u.target._item.deleted),a.forEach((u)=>{u.currentTarget=l,u._path=null}),a.sort((u,h)=>u.path.length-h.path.length),c.push(()=>{Qi(l._dEH,a,r)})}),c.push(()=>n.emit("afterTransaction",[r,n])),c.push(()=>{if(r._needFormattingCleanup)Nd(r)})}),jt(c,[])}finally{if(n.gc)xd(s,o,n.gcFilter);yd(s,o),r.afterState.forEach((u,h)=>{let p=r.beforeState.get(h)||0;if(p!==u){let f=o.clients.get(h),m=we(fe(f,p),1);for(let k=f.length-1;k>=m;)k-=1+Wr(f,k)}});for(let u=i.length-1;u>=0;u--){let{client:h,clock:p}=i[u].id,f=o.clients.get(h),m=fe(f,p);if(m+1<f.length){if(Wr(f,m+1)>1)continue}if(m>0)Wr(f,m)}if(!r.local&&r.afterState.get(n.clientID)!==r.beforeState.get(n.clientID))Ei(lt,Ft,"[yjs] ",Jt,qt,"Changed the client-id because another client seems to be using it."),n.clientID=qi();if(n.emit("afterTransactionCleanup",[r,n]),n._observers.has("update")){let u=new mt;if(Di(u,r))n.emit("update",[u.toUint8Array(),r.origin,n,r])}if(n._observers.has("updateV2")){let u=new Te;if(Di(u,r))n.emit("updateV2",[u.toUint8Array(),r.origin,n,r])}let{subdocsAdded:c,subdocsLoaded:a,subdocsRemoved:l}=r;if(c.size>0||l.size>0||a.size>0)c.forEach((u)=>{if(u.clientID=n.clientID,u.collectionid==null)u.collectionid=n.collectionid;n.subdocs.add(u)}),l.forEach((u)=>n.subdocs.delete(u)),n.emit("subdocs",[{loaded:a,added:c,removed:l},n,r]),l.forEach((u)=>u.destroy());if(e.length<=t+1)n._transactionCleanups=[],n.emit("afterAllTransactions",[n,e]);else oc(e,t+1)}}},v=(e,t,r=null,n=!0)=>{let o=e._transactionCleanups,s=!1,i=null;if(e._transaction===null){if(s=!0,e._transaction=new nc(e,r,n),o.push(e._transaction),o.length===1)e.emit("beforeAllTransactions",[e]);e.emit("beforeTransaction",[e._transaction,e])}try{i=t(e._transaction)}finally{if(s){let c=e._transaction===o[0];if(e._transaction=null,c)oc(o,0)}}return i};function*_d(e){let t=x(e.restDecoder);for(let r=0;r<t;r++){let n=x(e.restDecoder),o=e.readClient(),s=x(e.restDecoder);for(let i=0;i<n;i++){let c=e.readInfo();if(c===10){let a=x(e.restDecoder);yield new te(_(o,s),a),s+=a}else if((Tt&c)!==0){let a=(c&(oe|M))===0,l=new P(_(o,s),null,(c&M)===M?e.readLeftID():null,null,(c&oe)===oe?e.readRightID():null,a?e.readParentInfo()?e.readString():e.readLeftID():null,a&&(c&He)===He?e.readString():null,Ec(e,c));yield l,s+=l.length}else{let a=e.readLen();yield new ee(_(o,s),a),s+=a}}}}class an{constructor(e,t){this.gen=_d(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===te);return this.curr}}class un{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}var wd=(e)=>Yr(e,Co,mt);var bd=(e,t)=>{if(e.constructor===ee){let{client:r,clock:n}=e.id;return new ee(_(r,n+t),e.length-t)}else if(e.constructor===te){let{client:r,clock:n}=e.id;return new te(_(r,n+t),e.length-t)}else{let r=e,{client:n,clock:o}=r.id;return new P(_(n,o+t),null,_(n,o+t-1),null,r.rightOrigin,r.parent,r.parentSub,r.content.splice(t))}},Yr=(e,t=Ve,r=Te)=>{if(e.length===1)return e[0];let n=e.map((u)=>new t(je(u))),o=n.map((u)=>new an(u,!0)),s=null,i=new r,c=new un(i);while(!0){if(o=o.filter((p)=>p.curr!==null),o.sort((p,f)=>{if(p.curr.id.client===f.curr.id.client){let m=p.curr.id.clock-f.curr.id.clock;if(m===0)return p.curr.constructor===f.curr.constructor?0:p.curr.constructor===te?1:-1;else return m}else return f.curr.id.client-p.curr.id.client}),o.length===0)break;let u=o[0],h=u.curr.id.client;if(s!==null){let p=u.curr,f=!1;while(p!==null&&p.id.clock+p.length<=s.struct.id.clock+s.struct.length&&p.id.client>=s.struct.id.client)p=u.next(),f=!0;if(p===null||p.id.client!==h||f&&p.id.clock>s.struct.id.clock+s.struct.length)continue;if(h!==s.struct.id.client)Ee(c,s.struct,s.offset),s={struct:p,offset:0},u.next();else if(s.struct.id.clock+s.struct.length<p.id.clock)if(s.struct.constructor===te)s.struct.length=p.id.clock+p.length-s.struct.id.clock;else{Ee(c,s.struct,s.offset);let m=p.id.clock-s.struct.id.clock-s.struct.length;s={struct:new te(_(h,s.struct.id.clock+s.struct.length),m),offset:0}}else{let m=s.struct.id.clock+s.struct.length-p.id.clock;if(m>0)if(s.struct.constructor===te)s.struct.length-=m;else p=bd(p,m);if(!s.struct.mergeWith(p))Ee(c,s.struct,s.offset),s={struct:p,offset:0},u.next()}}else s={struct:u.curr,offset:0},u.next();for(let p=u.curr;p!==null&&p.id.client===h&&p.id.clock===s.struct.id.clock+s.struct.length&&p.constructor!==te;p=u.next())Ee(c,s.struct,s.offset),s={struct:p,offset:0}}if(s!==null)Ee(c,s.struct,s.offset),s=null;jo(c);let a=n.map((u)=>Zo(u)),l=td(a);return ft(i,l),i.toUint8Array()},kd=(e,t,r=Ve,n=Te)=>{let o=Ki(t),s=new n,i=new un(s),c=new r(je(e)),a=new an(c,!1);while(a.curr){let u=a.curr,h=u.id.client,p=o.get(h)||0;if(a.curr.constructor===te){a.next();continue}if(u.id.clock+u.length>p){Ee(i,u,we(p-u.id.clock,0)),a.next();while(a.curr&&a.curr.id.client===h)Ee(i,a.curr,0),a.next()}else while(a.curr&&a.curr.id.client===h&&a.curr.id.clock+a.curr.length<=p)a.next()}jo(i);let l=Zo(c);return ft(s,l),s.toUint8Array()};var sc=(e)=>{if(e.written>0)e.clientStructs.push({written:e.written,restEncoder:se(e.encoder.restEncoder)}),e.encoder.restEncoder=Ot(),e.written=0},Ee=(e,t,r)=>{if(e.written>0&&e.currClient!==t.id.client)sc(e);if(e.written===0)e.currClient=t.id.client,e.encoder.writeClient(t.id.client),y(e.encoder.restEncoder,t.id.clock+r);t.write(e.encoder,r),e.written++},jo=(e)=>{sc(e);let t=e.encoder.restEncoder;y(t,e.clientStructs.length);for(let r=0;r<e.clientStructs.length;r++){let n=e.clientStructs[r];y(t,n.written),Zt(t,n.restEncoder)}},vd=(e,t,r,n)=>{let o=new r(je(e)),s=new an(o,!1),i=new n,c=new un(i);for(let l=s.curr;l!==null;l=s.next())Ee(c,t(l),0);jo(c);let a=Zo(o);return ft(i,a),i.toUint8Array()};var zd=(e)=>vd(e,ei,Ve,mt),ji="You must not compute changes after the event-handler fired.";class Yt{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=$d(this.currentTarget,this.target))}deletes(e){return Fi(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw X(ji);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach((n)=>{if(n!==null){let o=t._map.get(n),s,i;if(this.adds(o)){let c=o.left;while(c!==null&&this.adds(c))c=c.left;if(this.deletes(o))if(c!==null&&this.deletes(c))s="delete",i=_r(c.content.getContent());else return;else if(c!==null&&this.deletes(c))s="update",i=_r(c.content.getContent());else s="add",i=void 0}else if(this.deletes(o))s="delete",i=_r(o.content.getContent());else return;e.set(n,{action:s,oldValue:i})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw X(ji);let t=this.target,r=_e(),n=_e(),o=[];if(e={added:r,deleted:n,delta:o,keys:this.keys},this.transaction.changed.get(t).has(null)){let i=null,c=()=>{if(i)o.push(i)};for(let a=t._start;a!==null;a=a.right)if(a.deleted){if(this.deletes(a)&&!this.adds(a)){if(i===null||i.delete===void 0)c(),i={delete:0};i.delete+=a.length,n.add(a)}}else if(this.adds(a)){if(i===null||i.insert===void 0)c(),i={insert:[]};i.insert=i.insert.concat(a.content.getContent()),r.add(a)}else{if(i===null||i.retain===void 0)c(),i={retain:0};i.retain+=a.length}if(i!==null&&i.retain===void 0)c()}this._changes=e}return e}}var $d=(e,t)=>{let r=[];while(t._item!==null&&t!==e){if(t._item.parentSub!==null)r.unshift(t._item.parentSub);else{let n=0,o=t._item.parent._start;while(o!==t._item&&o!==null){if(!o.deleted&&o.countable)n+=o.length;o=o.right}r.unshift(n)}t=t._item.parent}return r},F=()=>{Ii("Invalid access: Add Yjs type to a document before reading data.")},ic=80,Lo=0;class cc{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Lo++}}var Sd=(e)=>{e.timestamp=Lo++},ac=(e,t,r)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=r,e.timestamp=Lo++},Ed=(e,t,r)=>{if(e.length>=ic){let n=e.reduce((o,s)=>o.timestamp<s.timestamp?o:s);return ac(n,t,r),n}else{let n=new cc(t,r);return e.push(n),n}},ln=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let r=e._searchMarker.length===0?null:e._searchMarker.reduce((s,i)=>Ne(t-s.index)<Ne(t-i.index)?s:i),n=e._start,o=0;if(r!==null)n=r.p,o=r.index,Sd(r);while(n.right!==null&&o<t){if(!n.deleted&&n.countable){if(t<o+n.length)break;o+=n.length}n=n.right}while(n.left!==null&&o>t)if(n=n.left,!n.deleted&&n.countable)o-=n.length;while(n.left!==null&&n.left.id.client===n.id.client&&n.left.id.clock+n.left.length===n.id.clock)if(n=n.left,!n.deleted&&n.countable)o-=n.length;if(r!==null&&Ne(r.index-o)<n.parent.length/ic)return ac(r,n,o),r;else return Ed(e._searchMarker,n,o)},Gt=(e,t,r)=>{for(let n=e.length-1;n>=0;n--){let o=e[n];if(r>0){let s=o.p;s.marker=!1;while(s&&(s.deleted||!s.countable))if(s=s.left,s&&!s.deleted&&s.countable)o.index-=s.length;if(s===null||s.marker===!0){e.splice(n,1);continue}o.p=s,s.marker=!0}if(t<o.index||r>0&&t===o.index)o.index=we(t,o.index+r)}};var pn=(e,t,r)=>{let n=e,o=t.changedParentTypes;while(!0){if(ue(o,e,()=>[]).push(r),e._item===null)break;e=e._item.parent}Qi(n._eH,r,t)};class D{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Pi(),this._dEH=Pi(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Q()}clone(){throw Q()}_write(e){}get _first(){let e=this._start;while(e!==null&&e.deleted)e=e.right;return e}_callObserver(e,t){if(!e.local&&this._searchMarker)this._searchMarker.length=0}observe(e){Ci(this._eH,e)}observeDeep(e){Ci(this._dEH,e)}unobserve(e){Ni(this._eH,e)}unobserveDeep(e){Ni(this._dEH,e)}toJSON(){}}var uc=(e,t,r)=>{if(e.doc??F(),t<0)t=e._length+t;if(r<0)r=e._length+r;let n=r-t,o=[],s=e._start;while(s!==null&&n>0){if(s.countable&&!s.deleted){let i=s.content.getContent();if(i.length<=t)t-=i.length;else{for(let c=t;c<i.length&&n>0;c++)o.push(i[c]),n--;t=0}}s=s.right}return o},lc=(e)=>{e.doc??F();let t=[],r=e._start;while(r!==null){if(r.countable&&!r.deleted){let n=r.content.getContent();for(let o=0;o<n.length;o++)t.push(n[o])}r=r.right}return t};var Wt=(e,t)=>{let r=0,n=e._start;e.doc??F();while(n!==null){if(n.countable&&!n.deleted){let o=n.content.getContent();for(let s=0;s<o.length;s++)t(o[s],r++,e)}n=n.right}},pc=(e,t)=>{let r=[];return Wt(e,(n,o)=>{r.push(t(n,o,e))}),r},Id=(e)=>{let t=e._start,r=null,n=0;return{[Symbol.iterator](){return this},next:()=>{if(r===null){while(t!==null&&t.deleted)t=t.right;if(t===null)return{done:!0,value:void 0};r=t.content.getContent(),n=0,t=t.right}let o=r[n++];if(r.length<=n)r=null;return{done:!1,value:o}}}},hc=(e,t)=>{e.doc??F();let r=ln(e,t),n=e._start;if(r!==null)n=r.p,t-=r.index;for(;n!==null;n=n.right)if(!n.deleted&&n.countable){if(t<n.length)return n.content.getContent()[t];t-=n.length}},Xr=(e,t,r,n)=>{let o=r,s=e.doc,i=s.clientID,c=s.store,a=r===null?t._start:r.right,l=[],u=()=>{if(l.length>0)o=new P(_(i,U(c,i)),o,o&&o.lastId,a,a&&a.id,t,null,new Je(l)),o.integrate(e,0),l=[]};n.forEach((h)=>{if(h===null)l.push(h);else switch(h.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(h);break;default:switch(u(),h.constructor){case Uint8Array:case ArrayBuffer:o=new P(_(i,U(c,i)),o,o&&o.lastId,a,a&&a.id,t,null,new Xt(new Uint8Array(h))),o.integrate(e,0);break;case ge:o=new P(_(i,U(c,i)),o,o&&o.lastId,a,a&&a.id,t,null,new Qt(h)),o.integrate(e,0);break;default:if(h instanceof D)o=new P(_(i,U(c,i)),o,o&&o.lastId,a,a&&a.id,t,null,new ke(h)),o.integrate(e,0);else throw Error("Unexpected content type in insert operation")}}}),u()},dc=()=>X("Length exceeded!"),fc=(e,t,r,n)=>{if(r>t._length)throw dc();if(r===0){if(t._searchMarker)Gt(t._searchMarker,r,n.length);return Xr(e,t,null,n)}let o=r,s=ln(t,r),i=t._start;if(s!==null){if(i=s.p,r-=s.index,r===0)i=i.prev,r+=i&&i.countable&&!i.deleted?i.length:0}for(;i!==null;i=i.right)if(!i.deleted&&i.countable){if(r<=i.length){if(r<i.length)Ae(e,_(i.id.client,i.id.clock+r));break}r-=i.length}if(t._searchMarker)Gt(t._searchMarker,o,n.length);return Xr(e,t,i,n)},Td=(e,t,r)=>{let o=(t._searchMarker||[]).reduce((s,i)=>i.index>s.index?i:s,{index:0,p:t._start}).p;if(o)while(o.right)o=o.right;return Xr(e,t,o,r)},mc=(e,t,r,n)=>{if(n===0)return;let o=r,s=n,i=ln(t,r),c=t._start;if(i!==null)c=i.p,r-=i.index;for(;c!==null&&r>0;c=c.right)if(!c.deleted&&c.countable){if(r<c.length)Ae(e,_(c.id.client,c.id.clock+r));r-=c.length}while(n>0&&c!==null){if(!c.deleted){if(n<c.length)Ae(e,_(c.id.client,c.id.clock+n));c.delete(e),n-=c.length}c=c.right}if(n>0)throw dc();if(t._searchMarker)Gt(t._searchMarker,o,-s+n)},Qr=(e,t,r)=>{let n=t._map.get(r);if(n!==void 0)n.delete(e)},Bo=(e,t,r,n)=>{let o=t._map.get(r)||null,s=e.doc,i=s.clientID,c;if(n==null)c=new Je([n]);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new Je([n]);break;case Uint8Array:c=new Xt(n);break;case ge:c=new Qt(n);break;default:if(n instanceof D)c=new ke(n);else throw Error("Unexpected content type")}new P(_(i,U(s.store,i)),o,o&&o.lastId,null,null,t,r,c).integrate(e,0)},Mo=(e,t)=>{e.doc??F();let r=e._map.get(t);return r!==void 0&&!r.deleted?r.content.getContent()[r.length-1]:void 0},gc=(e)=>{let t={};return e.doc??F(),e._map.forEach((r,n)=>{if(!r.deleted)t[n]=r.content.getContent()[r.length-1]}),t},xc=(e,t)=>{e.doc??F();let r=e._map.get(t);return r!==void 0&&!r.deleted};var Ad=(e,t)=>{let r={};return e._map.forEach((n,o)=>{let s=n;while(s!==null&&(!t.sv.has(s.id.client)||s.id.clock>=(t.sv.get(s.id.client)||0)))s=s.left;if(s!==null&&pt(s,t))r[o]=s.content.getContent()[s.length-1]}),r},qr=(e)=>(e.doc??F(),Oi(e._map.entries(),(t)=>!t[1].deleted));class yc extends Yt{}class re extends D{constructor(){super();this._prelimContent=[],this._searchMarker=[]}static from(e){let t=new re;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new re}clone(){let e=new re;return e.insert(0,this.toArray().map((t)=>t instanceof D?t.clone():t)),e}get length(){return this.doc??F(),this._length}_callObserver(e,t){super._callObserver(e,t),pn(this,e,new yc(this,e))}insert(e,t){if(this.doc!==null)v(this.doc,(r)=>{fc(r,this,e,t)});else this._prelimContent.splice(e,0,...t)}push(e){if(this.doc!==null)v(this.doc,(t)=>{Td(t,this,e)});else this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){if(this.doc!==null)v(this.doc,(r)=>{mc(r,this,e,t)});else this._prelimContent.splice(e,t)}get(e){return hc(this,e)}toArray(){return lc(this)}slice(e=0,t=this.length){return uc(this,e,t)}toJSON(){return this.map((e)=>e instanceof D?e.toJSON():e)}map(e){return pc(this,e)}forEach(e){Wt(this,e)}[Symbol.iterator](){return Id(this)}_write(e){e.writeTypeRef(Xd)}}var Od=(e)=>new re;class _c extends Yt{constructor(e,t,r){super(e,t);this.keysChanged=r}}class G extends D{constructor(e){super();if(this._prelimContent=null,e===void 0)this._prelimContent=new Map;else this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((r,n)=>{this.set(n,r)}),this._prelimContent=null}_copy(){return new G}clone(){let e=new G;return this.forEach((t,r)=>{e.set(r,t instanceof D?t.clone():t)}),e}_callObserver(e,t){pn(this,e,new _c(this,e,t))}toJSON(){this.doc??F();let e={};return this._map.forEach((t,r)=>{if(!t.deleted){let n=t.content.getContent()[t.length-1];e[r]=n instanceof D?n.toJSON():n}}),e}get size(){return[...qr(this)].length}keys(){return Fr(qr(this),(e)=>e[0])}values(){return Fr(qr(this),(e)=>e[1].content.getContent()[e[1].length-1])}entries(){return Fr(qr(this),(e)=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??F(),this._map.forEach((t,r)=>{if(!t.deleted)e(t.content.getContent()[t.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){if(this.doc!==null)v(this.doc,(t)=>{Qr(t,this,e)});else this._prelimContent.delete(e)}set(e,t){if(this.doc!==null)v(this.doc,(r)=>{Bo(r,this,e,t)});else this._prelimContent.set(e,t);return t}get(e){return Mo(this,e)}has(e){return xc(this,e)}clear(){if(this.doc!==null)v(this.doc,(e)=>{this.forEach(function(t,r,n){Qr(e,n,r)})});else this._prelimContent.clear()}_write(e){e.writeTypeRef(Qd)}}var Zd=(e)=>new G,Ie=(e,t)=>e===t||typeof e==="object"&&typeof t==="object"&&e&&t&&oo(e,t);class en{constructor(e,t,r,n){this.left=e,this.right=t,this.index=r,this.currentAttributes=n}forward(){if(this.right===null)H();switch(this.right.content.constructor){case C:if(!this.right.deleted)xt(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 Li=(e,t,r)=>{while(t.right!==null&&r>0){switch(t.right.content.constructor){case C:if(!t.right.deleted)xt(t.currentAttributes,t.right.content);break;default:if(!t.right.deleted){if(r<t.right.length)Ae(e,_(t.right.id.client,t.right.id.clock+r));t.index+=t.right.length,r-=t.right.length}break}t.left=t.right,t.right=t.right.right}return t},Gr=(e,t,r,n)=>{let o=new Map,s=n?ln(t,r):null;if(s){let i=new en(s.p.left,s.p,s.index,o);return Li(e,i,r-s.index)}else{let i=new en(null,t._start,0,o);return Li(e,i,r)}},wc=(e,t,r,n)=>{while(r.right!==null&&(r.right.deleted===!0||r.right.content.constructor===C&&Ie(n.get(r.right.content.key),r.right.content.value))){if(!r.right.deleted)n.delete(r.right.content.key);r.forward()}let o=e.doc,s=o.clientID;n.forEach((i,c)=>{let{left:a,right:l}=r,u=new P(_(s,U(o.store,s)),a,a&&a.lastId,l,l&&l.id,t,null,new C(c,i));u.integrate(e,0),r.right=u,r.forward()})},xt=(e,t)=>{let{key:r,value:n}=t;if(n===null)e.delete(r);else e.set(r,n)},bc=(e,t)=>{while(!0){if(e.right===null)break;else if(e.right.deleted||e.right.content.constructor===C&&Ie(t[e.right.content.key]??null,e.right.content.value));else break;e.forward()}},kc=(e,t,r,n)=>{let o=e.doc,s=o.clientID,i=new Map;for(let c in n){let a=n[c],l=r.currentAttributes.get(c)??null;if(!Ie(l,a)){i.set(c,l);let{left:u,right:h}=r;r.right=new P(_(s,U(o.store,s)),u,u&&u.lastId,h,h&&h.id,t,null,new C(c,a)),r.right.integrate(e,0),r.forward()}}return i},Io=(e,t,r,n,o)=>{r.currentAttributes.forEach((p,f)=>{if(o[f]===void 0)o[f]=null});let s=e.doc,i=s.clientID;bc(r,o);let c=kc(e,t,r,o),a=n.constructor===String?new me(n):n instanceof D?new ke(n):new qe(n),{left:l,right:u,index:h}=r;if(t._searchMarker)Gt(t._searchMarker,r.index,a.getLength());u=new P(_(i,U(s.store,i)),l,l&&l.lastId,u,u&&u.id,t,null,a),u.integrate(e,0),r.right=u,r.index=h,r.forward(),wc(e,t,r,c)},Bi=(e,t,r,n,o)=>{let s=e.doc,i=s.clientID;bc(r,o);let c=kc(e,t,r,o);e:while(r.right!==null&&(n>0||c.size>0&&(r.right.deleted||r.right.content.constructor===C))){if(!r.right.deleted)switch(r.right.content.constructor){case C:{let{key:a,value:l}=r.right.content,u=o[a];if(u!==void 0){if(Ie(u,l))c.delete(a);else{if(n===0)break e;c.set(a,l)}r.right.delete(e)}else r.currentAttributes.set(a,l);break}default:if(n<r.right.length)Ae(e,_(r.right.id.client,r.right.id.clock+n));n-=r.right.length;break}r.forward()}if(n>0){let a="";for(;n>0;n--)a+=`
4
- `;r.right=new P(_(i,U(s.store,i)),r.left,r.left&&r.left.lastId,r.right,r.right&&r.right.id,t,null,new me(a)),r.right.integrate(e,0),r.forward()}wc(e,t,r,c)},vc=(e,t,r,n,o)=>{let s=t,i=J();while(s&&(!s.countable||s.deleted)){if(!s.deleted&&s.content.constructor===C){let l=s.content;i.set(l.key,l)}s=s.right}let c=0,a=!1;while(t!==s){if(r===t)a=!0;if(!t.deleted){let l=t.content;switch(l.constructor){case C:{let{key:u,value:h}=l,p=n.get(u)??null;if(i.get(u)!==l||p===h){if(t.delete(e),c++,!a&&(o.get(u)??null)===h&&p!==h)if(p===null)o.delete(u);else o.set(u,p)}if(!a&&!t.deleted)xt(o,l);break}}}t=t.right}return c},Pd=(e,t)=>{while(t&&t.right&&(t.right.deleted||!t.right.countable))t=t.right;let r=new Set;while(t&&(t.deleted||!t.countable)){if(!t.deleted&&t.content.constructor===C){let n=t.content.key;if(r.has(n))t.delete(e);else r.add(n)}t=t.left}},Cd=(e)=>{let t=0;return v(e.doc,(r)=>{let{_start:n,_start:o}=e,s=J(),i=yr(s);while(o){if(o.deleted===!1)switch(o.content.constructor){case C:xt(i,o.content);break;default:t+=vc(r,n,o,s,i),s=yr(i),n=o;break}o=o.right}}),t},Nd=(e)=>{let t=new Set,r=e.doc;for(let[n,o]of e.afterState.entries()){let s=e.beforeState.get(n)||0;if(o===s)continue;rc(e,r.store.clients.get(n),s,o,(i)=>{if(!i.deleted&&i.content.constructor===C&&i.constructor!==ee)t.add(i.parent)})}v(r,(n)=>{Vi(e,e.deleteSet,(o)=>{if(o instanceof ee||!o.parent._hasFormatting||t.has(o.parent))return;let s=o.parent;if(o.content.constructor===C)t.add(s);else Pd(n,o)});for(let o of t)Cd(o)})},Mi=(e,t,r)=>{let n=r,o=yr(t.currentAttributes),s=t.right;while(r>0&&t.right!==null){if(t.right.deleted===!1)switch(t.right.content.constructor){case ke:case qe:case me:if(r<t.right.length)Ae(e,_(t.right.id.client,t.right.id.clock+r));r-=t.right.length,t.right.delete(e);break}t.forward()}if(s)vc(e,s,t.right,o,t.currentAttributes);let i=(t.left||t.right).parent;if(i._searchMarker)Gt(i._searchMarker,t.index,-n+r);return t};class zc extends Yt{constructor(e,t,r){super(e,t);this.childListChanged=!1,this.keysChanged=new Set,r.forEach((n)=>{if(n===null)this.childListChanged=!0;else this.keysChanged.add(n)})}get changes(){if(this._changes===null){let e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];v(e,(r)=>{let n=new Map,o=new Map,s=this.target._start,i=null,c={},a="",l=0,u=0,h=()=>{if(i!==null){let p=null;switch(i){case"delete":if(u>0)p={delete:u};u=0;break;case"insert":if(typeof a==="object"||a.length>0){if(p={insert:a},n.size>0)p.attributes={},n.forEach((f,m)=>{if(f!==null)p.attributes[m]=f})}a="";break;case"retain":if(l>0){if(p={retain:l},!Qs(c))p.attributes=Ys({},c)}l=0;break}if(p)t.push(p);i=null}};while(s!==null){switch(s.content.constructor){case ke:case qe:if(this.adds(s)){if(!this.deletes(s))h(),i="insert",a=s.content.getContent()[0],h()}else if(this.deletes(s)){if(i!=="delete")h(),i="delete";u+=1}else if(!s.deleted){if(i!=="retain")h(),i="retain";l+=1}break;case me:if(this.adds(s)){if(!this.deletes(s)){if(i!=="insert")h(),i="insert";a+=s.content.str}}else if(this.deletes(s)){if(i!=="delete")h(),i="delete";u+=s.length}else if(!s.deleted){if(i!=="retain")h(),i="retain";l+=s.length}break;case C:{let{key:p,value:f}=s.content;if(this.adds(s)){if(!this.deletes(s)){let m=n.get(p)??null;if(!Ie(m,f)){if(i==="retain")h();if(Ie(f,o.get(p)??null))delete c[p];else c[p]=f}else if(f!==null)s.delete(r)}}else if(this.deletes(s)){o.set(p,f);let m=n.get(p)??null;if(!Ie(m,f)){if(i==="retain")h();c[p]=m}}else if(!s.deleted){o.set(p,f);let m=c[p];if(m!==void 0){if(!Ie(m,f)){if(i==="retain")h();if(f===null)delete c[p];else c[p]=f}else if(m!==null)s.delete(r)}}if(!s.deleted){if(i==="insert")h();xt(n,s.content)}break}}s=s.right}h();while(t.length>0){let p=t[t.length-1];if(p.retain!==void 0&&p.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}}class ie extends D{constructor(e){super();this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??F(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach((r)=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new ie}clone(){let e=new ie;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);let r=new zc(this,e,t);if(pn(this,e,r),!e.local&&this._hasFormatting)e._needFormattingCleanup=!0}toString(){this.doc??F();let e="",t=this._start;while(t!==null){if(!t.deleted&&t.countable&&t.content.constructor===me)e+=t.content.str;t=t.right}return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){if(this.doc!==null)v(this.doc,(r)=>{let n=new en(null,this._start,0,new Map);for(let o=0;o<e.length;o++){let s=e[o];if(s.insert!==void 0){let i=!t&&typeof s.insert==="string"&&o===e.length-1&&n.right===null&&s.insert.slice(-1)===`
5
- `?s.insert.slice(0,-1):s.insert;if(typeof i!=="string"||i.length>0)Io(r,this,n,i,s.attributes||{})}else if(s.retain!==void 0)Bi(r,this,n,s.retain,s.attributes||{});else if(s.delete!==void 0)Mi(r,n,s.delete)}});else this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,r){this.doc??F();let n=[],o=new Map,s=this.doc,i="",c=this._start;function a(){if(i.length>0){let u={},h=!1;o.forEach((f,m)=>{h=!0,u[m]=f});let p={insert:i};if(h)p.attributes=u;n.push(p),i=""}}let l=()=>{while(c!==null){if(pt(c,e)||t!==void 0&&pt(c,t))switch(c.content.constructor){case me:{let u=o.get("ychange");if(e!==void 0&&!pt(c,e)){if(u===void 0||u.user!==c.id.client||u.type!=="removed")a(),o.set("ychange",r?r("removed",c.id):{type:"removed"})}else if(t!==void 0&&!pt(c,t)){if(u===void 0||u.user!==c.id.client||u.type!=="added")a(),o.set("ychange",r?r("added",c.id):{type:"added"})}else if(u!==void 0)a(),o.delete("ychange");i+=c.content.str;break}case ke:case qe:{a();let u={insert:c.content.getContent()[0]};if(o.size>0){let h={};u.attributes=h,o.forEach((p,f)=>{h[f]=p})}n.push(u);break}case C:if(pt(c,e))a(),xt(o,c.content);break}c=c.right}a()};if(e||t)v(s,(u)=>{if(e)To(u,e);if(t)To(u,t);l()},"cleanup");else l();return n}insert(e,t,r){if(t.length<=0)return;let n=this.doc;if(n!==null)v(n,(o)=>{let s=Gr(o,this,e,!r);if(!r)r={},s.currentAttributes.forEach((i,c)=>{r[c]=i});Io(o,this,s,t,r)});else this._pending.push(()=>this.insert(e,t,r))}insertEmbed(e,t,r){let n=this.doc;if(n!==null)v(n,(o)=>{let s=Gr(o,this,e,!r);Io(o,this,s,t,r||{})});else this._pending.push(()=>this.insertEmbed(e,t,r||{}))}delete(e,t){if(t===0)return;let r=this.doc;if(r!==null)v(r,(n)=>{Mi(n,Gr(n,this,e,!0),t)});else this._pending.push(()=>this.delete(e,t))}format(e,t,r){if(t===0)return;let n=this.doc;if(n!==null)v(n,(o)=>{let s=Gr(o,this,e,!1);if(s.right===null)return;Bi(o,this,s,t,r)});else this._pending.push(()=>this.format(e,t,r))}removeAttribute(e){if(this.doc!==null)v(this.doc,(t)=>{Qr(t,this,e)});else this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){if(this.doc!==null)v(this.doc,(r)=>{Bo(r,this,e,t)});else this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return Mo(this,e)}getAttributes(){return gc(this)}_write(e){e.writeTypeRef(ef)}}var Ud=(e)=>new ie;class Kr{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??F()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===ht||t.constructor===Fe)&&t._start!==null)e=t._start;else while(e!==null){let r=e.next;if(r!==null){e=r;break}else if(e.parent===this._root)e=null;else e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));if(this._firstCall=!1,e===null)return{value:void 0,done:!0};return this._currentNode=e,{value:e.content.type,done:!1}}}class Fe extends D{constructor(){super();this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Fe}clone(){let e=new Fe;return e.insert(0,this.toArray().map((t)=>t instanceof D?t.clone():t)),e}get length(){return this.doc??F(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Kr(this,e)}querySelector(e){e=e.toUpperCase();let r=new Kr(this,(n)=>n.nodeName&&n.nodeName.toUpperCase()===e).next();if(r.done)return null;else return r.value}querySelectorAll(e){return e=e.toUpperCase(),le(new Kr(this,(t)=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){pn(this,e,new $c(this,t,e))}toString(){return pc(this,(e)=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},r){let n=e.createDocumentFragment();if(r!==void 0)r._createAssociation(n,this);return Wt(this,(o)=>{n.insertBefore(o.toDOM(e,t,r),null)}),n}insert(e,t){if(this.doc!==null)v(this.doc,(r)=>{fc(r,this,e,t)});else this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)v(this.doc,(r)=>{let n=e&&e instanceof D?e._item:e;Xr(r,this,n,t)});else{let r=this._prelimContent,n=e===null?0:r.findIndex((o)=>o===e)+1;if(n===0&&e!==null)throw X("Reference item not found");r.splice(n,0,...t)}}delete(e,t=1){if(this.doc!==null)v(this.doc,(r)=>{mc(r,this,e,t)});else this._prelimContent.splice(e,t)}toArray(){return lc(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return hc(this,e)}slice(e=0,t=this.length){return uc(this,e,t)}forEach(e){Wt(this,e)}_write(e){e.writeTypeRef(rf)}}var Dd=(e)=>new Fe;class ht extends Fe{constructor(e="UNDEFINED"){super();this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((r,n)=>{this.setAttribute(n,r)}),this._prelimAttrs=null}_copy(){return new ht(this.nodeName)}clone(){let e=new ht(this.nodeName),t=this.getAttributes();return Xs(t,(r,n)=>{e.setAttribute(n,r)}),e.insert(0,this.toArray().map((r)=>r instanceof D?r.clone():r)),e}toString(){let e=this.getAttributes(),t=[],r=[];for(let i in e)r.push(i);r.sort();let n=r.length;for(let i=0;i<n;i++){let c=r[i];t.push(c+'="'+e[c]+'"')}let o=this.nodeName.toLocaleLowerCase(),s=t.length>0?" "+t.join(" "):"";return`<${o}${s}>${super.toString()}</${o}>`}removeAttribute(e){if(this.doc!==null)v(this.doc,(t)=>{Qr(t,this,e)});else this._prelimAttrs.delete(e)}setAttribute(e,t){if(this.doc!==null)v(this.doc,(r)=>{Bo(r,this,e,t)});else this._prelimAttrs.set(e,t)}getAttribute(e){return Mo(this,e)}hasAttribute(e){return xc(this,e)}getAttributes(e){return e?Ad(this,e):gc(this)}toDOM(e=document,t={},r){let n=e.createElement(this.nodeName),o=this.getAttributes();for(let s in o){let i=o[s];if(typeof i==="string")n.setAttribute(s,i)}if(Wt(this,(s)=>{n.appendChild(s.toDOM(e,t,r))}),r!==void 0)r._createAssociation(n,this);return n}_write(e){e.writeTypeRef(tf),e.writeKey(this.nodeName)}}var Rd=(e)=>new ht(e.readKey());class $c extends Yt{constructor(e,t,r){super(e,r);this.childListChanged=!1,this.attributesChanged=new Set,t.forEach((n)=>{if(n===null)this.childListChanged=!0;else this.attributesChanged.add(n)})}}class tn extends G{constructor(e){super();this.hookName=e}_copy(){return new tn(this.hookName)}clone(){let e=new tn(this.hookName);return this.forEach((t,r)=>{e.set(r,t)}),e}toDOM(e=document,t={},r){let n=t[this.hookName],o;if(n!==void 0)o=n.createDom(this);else o=document.createElement(this.hookName);if(o.setAttribute("data-yjs-hook",this.hookName),r!==void 0)r._createAssociation(o,this);return o}_write(e){e.writeTypeRef(nf),e.writeKey(this.hookName)}}var jd=(e)=>new tn(e.readKey());class rn extends ie{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new rn}clone(){let e=new rn;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,r){let n=e.createTextNode(this.toString());if(r!==void 0)r._createAssociation(n,this);return n}toString(){return this.toDelta().map((e)=>{let t=[];for(let n in e.attributes){let o=[];for(let s in e.attributes[n])o.push({key:s,value:e.attributes[n][s]});o.sort((s,i)=>s.key<i.key?-1:1),t.push({nodeName:n,attrs:o})}t.sort((n,o)=>n.nodeName<o.nodeName?-1:1);let r="";for(let n=0;n<t.length;n++){let o=t[n];r+=`<${o.nodeName}`;for(let s=0;s<o.attrs.length;s++){let i=o.attrs[s];r+=` ${i.key}="${i.value}"`}r+=">"}r+=e.insert;for(let n=t.length-1;n>=0;n--)r+=`</${t[n].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(of)}}var Ld=(e)=>new rn;class hn{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Q()}mergeWith(e){return!1}write(e,t,r){throw Q()}integrate(e,t){throw Q()}}var Bd=0;class ee extends hn{get deleted(){return!0}delete(){}mergeWith(e){if(this.constructor!==e.constructor)return!1;return this.length+=e.length,!0}integrate(e,t){if(t>0)this.id.clock+=t,this.length-=t;tc(e.doc.store,this)}write(e,t){e.writeInfo(Bd),e.writeLen(this.length-t)}getMissing(e,t){return null}}class Xt{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Xt(this.content)}splice(e){throw Q()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}var Md=(e)=>new Xt(e.readBuf());class Kt{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Kt(this.len)}splice(e){let t=new Kt(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){Hr(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}}var Vd=(e)=>new Kt(e.readLen()),Sc=(e,t)=>new ge({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});class Qt{constructor(e){if(e._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=e;let t={};if(this.opts=t,!e.gc)t.gc=!1;if(e.autoLoad)t.autoLoad=!0;if(e.meta!==null)t.meta=e.meta}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Qt(Sc(this.doc.guid,this.opts))}splice(e){throw Q()}mergeWith(e){return!1}integrate(e,t){if(this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad)e.subdocsLoaded.add(this.doc)}delete(e){if(e.subdocsAdded.has(this.doc))e.subdocsAdded.delete(this.doc);else e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}var Fd=(e)=>new Qt(Sc(e.readString(),e.readAny()));class qe{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new qe(this.embed)}splice(e){throw Q()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}var Jd=(e)=>new qe(e.readJSON());class C{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new C(this.key,this.value)}splice(e){throw Q()}mergeWith(e){return!1}integrate(e,t){let r=t.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}var qd=(e)=>new C(e.readKey(),e.readJSON());class nn{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new nn(this.arr)}splice(e){let t=new nn(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let r=this.arr.length;e.writeLen(r-t);for(let n=t;n<r;n++){let o=this.arr[n];e.writeString(o===void 0?"undefined":JSON.stringify(o))}}getRef(){return 2}}var Gd=(e)=>{let t=e.readLen(),r=[];for(let n=0;n<t;n++){let o=e.readString();if(o==="undefined")r.push(void 0);else r.push(JSON.parse(o))}return new nn(r)},Wd=Bt("node_env")==="development";class Je{constructor(e){this.arr=e,Wd&&so(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Je(this.arr)}splice(e){let t=new Je(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let r=this.arr.length;e.writeLen(r-t);for(let n=t;n<r;n++){let o=this.arr[n];e.writeAny(o)}}getRef(){return 8}}var Kd=(e)=>{let t=e.readLen(),r=[];for(let n=0;n<t;n++)r.push(e.readAny());return new Je(r)};class me{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new me(this.str)}splice(e){let t=new me(this.str.slice(e));this.str=this.str.slice(0,e);let r=this.str.charCodeAt(e-1);if(r>=55296&&r<=56319)this.str=this.str.slice(0,e-1)+"�",t.str="�"+t.str.slice(1);return t}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}}var Hd=(e)=>new me(e.readString()),Yd=[Od,Zd,Ud,Rd,Dd,jd,Ld],Xd=0,Qd=1,ef=2,tf=3,rf=4,nf=5,of=6;class ke{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new ke(this.type._copy())}splice(e){throw Q()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;while(t!==null){if(!t.deleted)t.delete(e);else if(t.id.clock<(e.beforeState.get(t.id.client)||0))e._mergeStructs.push(t);t=t.right}this.type._map.forEach((r)=>{if(!r.deleted)r.delete(e);else if(r.id.clock<(e.beforeState.get(r.id.client)||0))e._mergeStructs.push(r)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;while(t!==null)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach((r)=>{while(r!==null)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}}var sf=(e)=>new ke(Yd[e.readTypeRef()](e));var on=(e,t,r)=>{let{client:n,clock:o}=t.id,s=new P(_(n,o+r),t,_(n,o+r-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(r));if(t.deleted)s.markDeleted();if(t.keep)s.keep=!0;if(t.redone!==null)s.redone=_(t.redone.client,t.redone.clock+r);if(t.right=s,s.right!==null)s.right.left=s;if(e._mergeStructs.push(s),s.parentSub!==null&&s.right===null)s.parent._map.set(s.parentSub,s);return t.length=r,s};class P extends hn{constructor(e,t,r,n,o,s,i,c){super(e,c.getLength());this.origin=r,this.left=t,this.right=n,this.rightOrigin=o,this.parent=s,this.parentSub=i,this.redone=null,this.content=c,this.info=this.content.isCountable()?Mn:0}set marker(e){if((this.info&$r)>0!==e)this.info^=$r}get marker(){return(this.info&$r)>0}get keep(){return(this.info&Bn)>0}set keep(e){if(this.keep!==e)this.info^=Bn}get countable(){return(this.info&Mn)>0}get deleted(){return(this.info&zr)>0}set deleted(e){if(this.deleted!==e)this.info^=zr}markDeleted(){this.info|=zr}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=U(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=U(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Me&&this.id.client!==this.parent.client&&this.parent.clock>=U(t,this.parent.client))return this.parent.client;if(this.origin)this.left=Ui(e,t,this.origin),this.origin=this.left.lastId;if(this.rightOrigin)this.right=Ae(e,this.rightOrigin),this.rightOrigin=this.right.id;if(this.left&&this.left.constructor===ee||this.right&&this.right.constructor===ee)this.parent=null;else if(!this.parent){if(this.left&&this.left.constructor===P)this.parent=this.left.parent,this.parentSub=this.left.parentSub;else if(this.right&&this.right.constructor===P)this.parent=this.right.parent,this.parentSub=this.right.parentSub}else if(this.parent.constructor===Me){let r=Eo(t,this.parent);if(r.constructor===ee)this.parent=null;else this.parent=r.content.type}return null}integrate(e,t){if(t>0)this.id.clock+=t,this.left=Ui(e,e.doc.store,_(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t;if(this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,n;if(r!==null)n=r.right;else if(this.parentSub!==null){n=this.parent._map.get(this.parentSub)||null;while(n!==null&&n.left!==null)n=n.left}else n=this.parent._start;let o=new Set,s=new Set;while(n!==null&&n!==this.right){if(s.add(n),o.add(n),Jr(this.origin,n.origin)){if(n.id.client<this.id.client)r=n,o.clear();else if(Jr(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&s.has(Eo(e.doc.store,n.origin))){if(!o.has(Eo(e.doc.store,n.origin)))r=n,o.clear()}else break;n=n.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(e)}if(this.parentSub===null&&this.countable&&!this.deleted)this.parent._length+=this.length;if(tc(e.doc.store,this),this.content.integrate(e,this),Ri(e,this.parent,this.parentSub),this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)this.delete(e)}else new ee(this.id,this.length).integrate(e,0)}get next(){let e=this.right;while(e!==null&&e.deleted)e=e.right;return e}get prev(){let e=this.left;while(e!==null&&e.deleted)e=e.left;return e}get lastId(){return this.length===1?this.id:_(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Jr(e.origin,this.lastId)&&this.right===e&&Jr(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;if(t)t.forEach((r)=>{if(r.p===e){if(r.p=this,!this.deleted&&this.countable)r.index-=this.length}});if(e.keep)this.keep=!0;if(this.right=e.right,this.right!==null)this.right.left=this;return this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;if(this.countable&&this.parentSub===null)t._length-=this.length;this.markDeleted(),Hr(e.deleteSet,this.id.client,this.id.clock,this.length),Ri(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw H();if(this.content.gc(e),t)gd(e,this,new ee(this.id,this.length));else this.content=new Kt(this.length)}write(e,t){let r=t>0?_(this.id.client,this.id.clock+t-1):this.origin,n=this.rightOrigin,o=this.parentSub,s=this.content.getRef()&Tt|(r===null?0:M)|(n===null?0:oe)|(o===null?0:He);if(e.writeInfo(s),r!==null)e.writeLeftID(r);if(n!==null)e.writeRightID(n);if(r===null&&n===null){let i=this.parent;if(i._item!==void 0){let c=i._item;if(c===null){let a=dd(i);e.writeParentInfo(!0),e.writeString(a)}else e.writeParentInfo(!1),e.writeLeftID(c.id)}else if(i.constructor===String)e.writeParentInfo(!0),e.writeString(i);else if(i.constructor===Me)e.writeParentInfo(!1),e.writeLeftID(i);else H();if(o!==null)e.writeString(o)}this.content.write(e,t)}}var Ec=(e,t)=>cf[t&Tt](e),cf=[()=>{H()},Vd,Gd,Md,Hd,Jd,qd,sf,Kd,Fd,()=>{H()}],af=10;class te extends hn{get deleted(){return!0}delete(){}mergeWith(e){if(this.constructor!==e.constructor)return!1;return this.length+=e.length,!0}integrate(e,t){H()}write(e,t){e.writeInfo(af),y(e.restEncoder,this.length-t)}getMissing(e,t){return null}}var Ic=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Tc="__ $YJS$ __";if(Ic[Tc]===!0)console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Ic[Tc]=!0;var Oc;function d(e,t,r){function n(c,a){if(!c._zod)Object.defineProperty(c,"_zod",{value:{def:a,constr:i,traits:new Set},enumerable:!1});if(c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,a);let l=i.prototype,u=Object.keys(l);for(let h=0;h<u.length;h++){let p=u[h];if(!(p in c))c[p]=l[p].bind(c)}}let o=r?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(c){var a;let l=r?.Parent?new s:this;n(l,c),(a=l._zod).deferred??(a.deferred=[]);for(let u of l._zod.deferred)u();return l}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:(c)=>{if(r?.Parent&&c instanceof r.Parent)return!0;return c?._zod?.traits?.has(e)}}),Object.defineProperty(i,"name",{value:e}),i}var Hg=Symbol("zod_brand");class ve extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class er extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Oc=globalThis).__zod_globalConfig??(Oc.__zod_globalConfig={});var yt=globalThis.__zod_globalConfig;function ze(e){if(e)Object.assign(yt,e);return yt}var b={};Zp(b,{BIGINT_FORMAT_RANGES:()=>Uc,Class:()=>Lc,NUMBER_FORMAT_RANGES:()=>Ko,aborted:()=>Ze,allowsEval:()=>qo,assert:()=>df,assertEqual:()=>uf,assertIs:()=>pf,assertNever:()=>hf,assertNotEqual:()=>lf,assignProp:()=>Oe,base64ToUint8Array:()=>Rc,base64urlToUint8Array:()=>Zf,cached:()=>wt,captureStackTrace:()=>fn,cleanEnum:()=>Of,cleanRegex:()=>or,clone:()=>ce,cloneDef:()=>gf,createTransparentProxy:()=>kf,defineLazy:()=>w,esc:()=>dn,escapeRegex:()=>Se,explicitlyAborted:()=>Ho,extend:()=>$f,finalizeIssue:()=>xe,floatSafeRemainder:()=>Fo,getElementAtPath:()=>xf,getEnumValues:()=>rr,getLengthableOrigin:()=>ir,getParsedType:()=>bf,getSizableOrigin:()=>Dc,hexToUint8Array:()=>Cf,isObject:()=>Ge,isPlainObject:()=>We,issue:()=>bt,joinValues:()=>ff,jsonStringifyReplacer:()=>_t,merge:()=>Ef,mergeDefs:()=>$e,normalizeParams:()=>g,nullish:()=>nr,numKeys:()=>wf,objectClone:()=>mf,omit:()=>zf,optionalKeys:()=>Wo,parsedType:()=>Af,partial:()=>If,pick:()=>vf,prefixIssues:()=>sr,primitiveTypes:()=>Cc,promiseAllObject:()=>yf,propertyKeyTypes:()=>Go,randomString:()=>_f,required:()=>Tf,safeExtend:()=>Sf,shallowClone:()=>Pc,slugify:()=>Jo,stringifyPrimitive:()=>Nc,uint8ArrayToBase64:()=>jc,uint8ArrayToBase64url:()=>Pf,uint8ArrayToHex:()=>Nf,unwrapMessage:()=>tr});function uf(e){return e}function lf(e){return e}function pf(e){}function hf(e){throw Error("Unexpected value in exhaustive check")}function df(e){}function rr(e){let t=Object.values(e).filter((n)=>typeof n==="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function ff(e,t="|"){return e.map((r)=>Nc(r)).join(t)}function _t(e,t){if(typeof t==="bigint")return t.toString();return t}function wt(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw Error("cached value already set")}}}function nr(e){return e===null||e===void 0}function or(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Fo(e,t){let r=e/t,n=Math.round(r),o=Number.EPSILON*Math.max(Math.abs(r),1);if(Math.abs(r-n)<o)return 0;return r-n}var Zc=Symbol("evaluating");function w(e,t,r){let n=void 0;Object.defineProperty(e,t,{get(){if(n===Zc)return;if(n===void 0)n=Zc,n=r();return n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function mf(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Oe(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function $e(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function gf(e){return $e(e._zod.def)}function xf(e,t){if(!t)return e;return t.reduce((r,n)=>r?.[n],e)}function yf(e){let t=Object.keys(e),r=t.map((n)=>e[n]);return Promise.all(r).then((n)=>{let o={};for(let s=0;s<t.length;s++)o[t[s]]=n[s];return o})}function _f(e=10){let r="";for(let n=0;n<e;n++)r+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return r}function dn(e){return JSON.stringify(e)}function Jo(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var fn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ge(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var qo=wt(()=>{if(yt.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function We(e){if(Ge(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let r=t.prototype;if(Ge(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function Pc(e){if(We(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}function wf(e){let t=0;for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r))t++;return t}var bf=(e)=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(e))return"array";if(e===null)return"null";if(e.then&&typeof e.then==="function"&&e.catch&&typeof e.catch==="function")return"promise";if(typeof Map<"u"&&e instanceof Map)return"map";if(typeof Set<"u"&&e instanceof Set)return"set";if(typeof Date<"u"&&e instanceof Date)return"date";if(typeof File<"u"&&e instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${t}`)}},Go=new Set(["string","number","symbol"]),Cc=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Se(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ce(e,t,r){let n=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)n._zod.parent=e;return n}function g(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function kf(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,s){return t??(t=e()),Reflect.set(t,n,o,s)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function Nc(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Wo(e){return Object.keys(e).filter((t)=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Ko={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Uc={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function vf(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s=$e(e._zod.def,{get shape(){let i={};for(let c in t){if(!(c in r.shape))throw Error(`Unrecognized key: "${c}"`);if(!t[c])continue;i[c]=r.shape[c]}return Oe(this,"shape",i),i},checks:[]});return ce(e,s)}function zf(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=$e(e._zod.def,{get shape(){let i={...e._zod.def.shape};for(let c in t){if(!(c in r.shape))throw Error(`Unrecognized key: "${c}"`);if(!t[c])continue;delete i[c]}return Oe(this,"shape",i),i},checks:[]});return ce(e,s)}function $f(e,t){if(!We(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let s=e._zod.def.shape;for(let i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=$e(e._zod.def,{get shape(){let s={...e._zod.def.shape,...t};return Oe(this,"shape",s),s}});return ce(e,o)}function Sf(e,t){if(!We(t))throw Error("Invalid input to safeExtend: expected a plain object");let r=$e(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Oe(this,"shape",n),n}});return ce(e,r)}function Ef(e,t){if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=$e(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Oe(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ce(e,r)}function If(e,t,r){let o=t._zod.def.checks;if(o&&o.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let i=$e(t._zod.def,{get shape(){let c=t._zod.def.shape,a={...c};if(r)for(let l in r){if(!(l in c))throw Error(`Unrecognized key: "${l}"`);if(!r[l])continue;a[l]=e?new e({type:"optional",innerType:c[l]}):c[l]}else for(let l in c)a[l]=e?new e({type:"optional",innerType:c[l]}):c[l];return Oe(this,"shape",a),a},checks:[]});return ce(t,i)}function Tf(e,t,r){let n=$e(t._zod.def,{get shape(){let o=t._zod.def.shape,s={...o};if(r)for(let i in r){if(!(i in s))throw Error(`Unrecognized key: "${i}"`);if(!r[i])continue;s[i]=new e({type:"nonoptional",innerType:o[i]})}else for(let i in o)s[i]=new e({type:"nonoptional",innerType:o[i]});return Oe(this,"shape",s),s}});return ce(t,n)}function Ze(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Ho(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function sr(e,t){return t.map((r)=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function tr(e){return typeof e==="string"?e:e?.message}function xe(e,t,r){let n=e.message?e.message:tr(e.inst?._zod.def?.error?.(e))??tr(t?.error?.(e))??tr(r.customError?.(e))??tr(r.localeError?.(e))??"Invalid input",{inst:o,continue:s,input:i,...c}=e;if(c.path??(c.path=[]),c.message=n,t?.reportInput)c.input=i;return c}function Dc(e){if(e instanceof Set)return"set";if(e instanceof Map)return"map";if(e instanceof File)return"file";return"unknown"}function ir(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Af(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function bt(...e){let[t,r,n]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:n};return{...t}}function Of(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map((t)=>t[1])}function Rc(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function jc(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function Zf(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return Rc(t+r)}function Pf(e){return jc(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Cf(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function Nf(e){return Array.from(e).map((t)=>t.toString(16).padStart(2,"0")).join("")}class Lc{constructor(...e){}}var Bc=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,_t,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},mn=d("$ZodError",Bc),Yo=d("$ZodError",Bc,{Parent:Error});function Mc(e,t=(r)=>r.message){let r={},n=[];for(let o of e.issues)if(o.path.length>0)r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o));else n.push(t(o));return{formErrors:n,fieldErrors:r}}function Vc(e,t=(r)=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map((c)=>n({issues:c},[...s,...i.path]));else if(i.code==="invalid_key")n({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")n({issues:i.issues},[...s,...i.path]);else{let c=[...s,...i.path];if(c.length===0)r._errors.push(t(i));else{let a=r,l=0;while(l<c.length){let u=c[l];if(l!==c.length-1)a[u]=a[u]||{_errors:[]};else a[u]=a[u]||{_errors:[]},a[u]._errors.push(t(i));a=a[u],l++}}}};return n(e),r}var gn=(e)=>(t,r,n,o)=>{let s=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new ve;if(i.issues.length){let c=new(o?.Err??e)(i.issues.map((a)=>xe(a,s,ze())));throw fn(c,o?.callee),c}return i.value};var xn=(e)=>async(t,r,n,o)=>{let s=n?{...n,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise)i=await i;if(i.issues.length){let c=new(o?.Err??e)(i.issues.map((a)=>xe(a,s,ze())));throw fn(c,o?.callee),c}return i.value};var cr=(e)=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new ve;return s.issues.length?{success:!1,error:new(e??mn)(s.issues.map((i)=>xe(i,o,ze())))}:{success:!0,data:s.value}},Fc=cr(Yo),ar=(e)=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)s=await s;return s.issues.length?{success:!1,error:new e(s.issues.map((i)=>xe(i,o,ze())))}:{success:!0,data:s.value}},Jc=ar(Yo),qc=(e)=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return gn(e)(t,r,o)};var Gc=(e)=>(t,r,n)=>gn(e)(t,r,n);var Wc=(e)=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return xn(e)(t,r,o)};var Kc=(e)=>async(t,r,n)=>xn(e)(t,r,n);var Hc=(e)=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return cr(e)(t,r,o)};var Yc=(e)=>(t,r,n)=>cr(e)(t,r,n);var Xc=(e)=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return ar(e)(t,r,o)};var Qc=(e)=>async(t,r,n)=>ar(e)(t,r,n);var ea=/^[cC][0-9a-z]{6,}$/,ta=/^[0-9a-z]+$/,ra=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,na=/^[0-9a-vA-V]{20}$/,oa=/^[A-Za-z0-9]{27}$/,sa=/^[a-zA-Z0-9_-]{21}$/,ia=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var ca=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Xo=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var aa=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Df="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function ua(){return new RegExp(Df,"u")}var la=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,pa=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var ha=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,da=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,fa=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Qo=/^[A-Za-z0-9_-]*$/;var ma=/^https?$/,ga=/^\+[1-9]\d{6,14}$/,xa="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",ya=new RegExp(`^${xa}$`);function _a(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function wa(e){return new RegExp(`^${_a(e)}$`)}function ba(e){let t=_a({precision:e.precision}),r=["Z"];if(e.local)r.push("");if(e.offset)r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${xa}T(?:${n})$`)}var ka=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var va=/^-?\d+$/,za=/^-?\d+(?:\.\d+)?$/;var $a=/^[^A-Z]*$/,Sa=/^[^a-z]*$/;var L=d("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Ea={number:"number",bigint:"bigint",object:"date"},es=d("$ZodCheckLessThan",(e,t)=>{L.init(e,t);let r=Ea[typeof t.value];e._zod.onattach.push((n)=>{let o=n._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(t.value<s)if(t.inclusive)o.maximum=t.value;else o.exclusiveMaximum=t.value}),e._zod.check=(n)=>{if(t.inclusive?n.value<=t.value:n.value<t.value)return;n.issues.push({origin:r,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ts=d("$ZodCheckGreaterThan",(e,t)=>{L.init(e,t);let r=Ea[typeof t.value];e._zod.onattach.push((n)=>{let o=n._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(t.value>s)if(t.inclusive)o.minimum=t.value;else o.exclusiveMinimum=t.value}),e._zod.check=(n)=>{if(t.inclusive?n.value>=t.value:n.value>t.value)return;n.issues.push({origin:r,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ia=d("$ZodCheckMultipleOf",(e,t)=>{L.init(e,t),e._zod.onattach.push((r)=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=(r)=>{if(typeof r.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof r.value==="bigint"?r.value%t.value===BigInt(0):Fo(r.value,t.value)===0)return;r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Ta=d("$ZodCheckNumberFormat",(e,t)=>{L.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=Ko[t.format];e._zod.onattach.push((i)=>{let c=i._zod.bag;if(c.format=t.format,c.minimum=o,c.maximum=s,r)c.pattern=va}),e._zod.check=(i)=>{let c=i.value;if(r){if(!Number.isInteger(c)){i.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){if(c>0)i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});else i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}if(c<o)i.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort});if(c>s)i.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Aa=d("$ZodCheckMaxLength",(e,t)=>{var r;L.init(e,t),(r=e._zod.def).when??(r.when=(n)=>{let o=n.value;return!nr(o)&&o.length!==void 0}),e._zod.onattach.push((n)=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<o)n._zod.bag.maximum=t.maximum}),e._zod.check=(n)=>{let o=n.value;if(o.length<=t.maximum)return;let i=ir(o);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Oa=d("$ZodCheckMinLength",(e,t)=>{var r;L.init(e,t),(r=e._zod.def).when??(r.when=(n)=>{let o=n.value;return!nr(o)&&o.length!==void 0}),e._zod.onattach.push((n)=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>o)n._zod.bag.minimum=t.minimum}),e._zod.check=(n)=>{let o=n.value;if(o.length>=t.minimum)return;let i=ir(o);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Za=d("$ZodCheckLengthEquals",(e,t)=>{var r;L.init(e,t),(r=e._zod.def).when??(r.when=(n)=>{let o=n.value;return!nr(o)&&o.length!==void 0}),e._zod.onattach.push((n)=>{let o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=(n)=>{let o=n.value,s=o.length;if(s===t.length)return;let i=ir(o),c=s>t.length;n.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),ur=d("$ZodCheckStringFormat",(e,t)=>{var r,n;if(L.init(e,t),e._zod.onattach.push((o)=>{let s=o._zod.bag;if(s.format=t.format,t.pattern)s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern)}),t.pattern)(r=e._zod).check??(r.check=(o)=>{if(t.pattern.lastIndex=0,t.pattern.test(o.value))return;o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(n=e._zod).check??(n.check=()=>{})}),Pa=d("$ZodCheckRegex",(e,t)=>{ur.init(e,t),e._zod.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ca=d("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=$a),ur.init(e,t)}),Na=d("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Sa),ur.init(e,t)}),Ua=d("$ZodCheckIncludes",(e,t)=>{L.init(e,t);let r=Se(t.includes),n=new RegExp(typeof t.position==="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push((o)=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=(o)=>{if(o.value.includes(t.includes,t.position))return;o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Da=d("$ZodCheckStartsWith",(e,t)=>{L.init(e,t);let r=new RegExp(`^${Se(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push((n)=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=(n)=>{if(n.value.startsWith(t.prefix))return;n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Ra=d("$ZodCheckEndsWith",(e,t)=>{L.init(e,t);let r=new RegExp(`.*${Se(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push((n)=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=(n)=>{if(n.value.endsWith(t.suffix))return;n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var ja=d("$ZodCheckOverwrite",(e,t)=>{L.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class rs{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let r=e.split(`
1
+ var Tp=Object.defineProperty;var Ap=(e)=>e;function Op(e,t){this[e]=Ap.bind(null,t)}var Zp=(e,t)=>{for(var r in t)Tp(e,r,{get:t[r],enumerable:!0,configurable:!0,set:Op.bind(t,r)})};var J=()=>new Map,xr=(e)=>{let t=J();return e.forEach((r,n)=>{t.set(n,r)}),t},ue=(e,t,r)=>{let n=e.get(t);if(n===void 0)e.set(t,n=r());return n},As=(e,t)=>{let r=[];for(let[n,o]of e)r.push(t(o,n));return r},Os=(e,t)=>{for(let[r,n]of e)if(t(n,r))return!0;return!1};var _e=()=>new Set;var _r=(e)=>e[e.length-1];var Zs=(e,t)=>{for(let r=0;r<t.length;r++)e.push(t[r])},le=Array.from,wr=(e,t)=>{for(let r=0;r<e.length;r++)if(!t(e[r],r,e))return!1;return!0},br=(e,t)=>{for(let r=0;r<e.length;r++)if(t(e[r],r,e))return!0;return!1};var Ps=(e,t)=>{let r=Array(e);for(let n=0;n<e;n++)r[n]=t(n,r);return r};var Ce=Array.isArray;class Ln{constructor(){this._observers=J()}on(e,t){return ue(this._observers,e,_e).add(t),t}once(e,t){let r=(...n)=>{this.off(e,r),t(...n)};this.on(e,r)}off(e,t){let r=this._observers.get(e);if(r!==void 0){if(r.delete(t),r.size===0)this._observers.delete(e)}}emit(e,t){return le((this._observers.get(e)||J()).values()).forEach((r)=>r(...t))}destroy(){this._observers=J()}}var q=Math.floor;var Ne=Math.abs;var kr=(e,t)=>e<t?e:t,we=(e,t)=>e>t?e:t;var vr=(e)=>e!==0?e<0:1/e<0;var Bn=1,Mn=2,zr=4,$r=8;var He=32,oe=64,M=128;var Tt=31,At=63,be=127;var Cs=2147483647;var{MAX_SAFE_INTEGER:Ye,MIN_SAFE_INTEGER:Fn}=Number;var Ns=Number.isInteger||((e)=>typeof e==="number"&&isFinite(e)&&q(e)===e);var{fromCharCode:qn,fromCodePoint:Pp}=String,cg=qn(65535),Cp=(e)=>e.toLowerCase(),Np=/^\s*/g,Up=(e)=>e.replace(Np,""),Dp=/([A-Z])/g,Gn=(e,t)=>Up(e.replace(Dp,(r)=>`${t}${Cp(r)}`));var Rp=(e)=>{let t=unescape(encodeURIComponent(e)),r=t.length,n=new Uint8Array(r);for(let o=0;o<r;o++)n[o]=t.codePointAt(o);return n},Qe=typeof TextEncoder<"u"?new TextEncoder:null,jp=(e)=>Qe.encode(e),Us=Qe?jp:Rp;var Xe=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});if(Xe&&Xe.decode(new Uint8Array).length===1)Xe=null;var Ds=(e,t)=>Ps(t,()=>e).join("");class tt{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}var Ot=()=>new tt;var Lp=(e)=>{let t=e.cpos;for(let r=0;r<e.bufs.length;r++)t+=e.bufs[r].length;return t};var se=(e)=>{let t=new Uint8Array(Lp(e)),r=0;for(let n=0;n<e.bufs.length;n++){let o=e.bufs[n];t.set(o,r),r+=o.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),r),t},Bp=(e,t)=>{let r=e.cbuf.length;if(r-e.cpos<t)e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(we(r,t)*2),e.cpos=0},N=(e,t)=>{let r=e.cbuf.length;if(e.cpos===r)e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(r*2),e.cpos=0;e.cbuf[e.cpos++]=t};var Er=N;var x=(e,t)=>{while(t>be)N(e,M|be&t),t=q(t/128);N(e,be&t)},Ir=(e,t)=>{let r=vr(t);if(r)t=-t;N(e,(t>At?M:0)|(r?oe:0)|At&t),t=q(t/64);while(t>0)N(e,(t>be?M:0)|be&t),t=q(t/128)},Wn=new Uint8Array(30000),Mp=Wn.length/3,Vp=(e,t)=>{if(t.length<Mp){let r=Qe.encodeInto(t,Wn).written||0;x(e,r);for(let n=0;n<r;n++)N(e,Wn[n])}else K(e,Us(t))},Fp=(e,t)=>{let r=unescape(encodeURIComponent(t)),n=r.length;x(e,n);for(let o=0;o<n;o++)N(e,r.codePointAt(o))},Ue=Qe&&Qe.encodeInto?Vp:Fp;var Zt=(e,t)=>{let r=e.cbuf.length,n=e.cpos,o=kr(r-n,t.length),s=t.length-o;if(e.cbuf.set(t.subarray(0,o),n),e.cpos+=o,s>0)e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(we(r*2,s)),e.cbuf.set(t.subarray(o)),e.cpos=s},K=(e,t)=>{x(e,t.byteLength),Zt(e,t)},Kn=(e,t)=>{Bp(e,t);let r=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,r},Jp=(e,t)=>Kn(e,4).setFloat32(0,t,!1),qp=(e,t)=>Kn(e,8).setFloat64(0,t,!1),Gp=(e,t)=>Kn(e,8).setBigInt64(0,t,!1);var Rs=new DataView(new ArrayBuffer(4)),Wp=(e)=>(Rs.setFloat32(0,e),Rs.getFloat32(0)===e),et=(e,t)=>{switch(typeof t){case"string":N(e,119),Ue(e,t);break;case"number":if(Ns(t)&&Ne(t)<=Cs)N(e,125),Ir(e,t);else if(Wp(t))N(e,124),Jp(e,t);else N(e,123),qp(e,t);break;case"bigint":N(e,122),Gp(e,t);break;case"object":if(t===null)N(e,126);else if(Ce(t)){N(e,117),x(e,t.length);for(let r=0;r<t.length;r++)et(e,t[r])}else if(t instanceof Uint8Array)N(e,116),K(e,t);else{N(e,118);let r=Object.keys(t);x(e,r.length);for(let n=0;n<r.length;n++){let o=r[n];Ue(e,o),et(e,t[o])}}break;case"boolean":N(e,t?120:121);break;default:N(e,127)}};class Tr extends tt{constructor(e){super();this.w=e,this.s=null,this.count=0}write(e){if(this.s===e)this.count++;else{if(this.count>0)x(this,this.count-1);this.count=1,this.w(this,e),this.s=e}}}var js=(e)=>{if(e.count>0){if(Ir(e.encoder,e.count===1?e.s:-e.s),e.count>1)x(e.encoder,e.count-2)}};class rt{constructor(){this.encoder=new tt,this.s=0,this.count=0}write(e){if(this.s===e)this.count++;else js(this),this.count=1,this.s=e}toUint8Array(){return js(this),se(this.encoder)}}var Ls=(e)=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);if(Ir(e.encoder,t),e.count>1)x(e.encoder,e.count-2)}};class Pt{constructor(){this.encoder=new tt,this.s=0,this.count=0,this.diff=0}write(e){if(this.diff===e-this.s)this.s=e,this.count++;else Ls(this),this.count=1,this.diff=e-this.s,this.s=e}toUint8Array(){return Ls(this),se(this.encoder)}}class Hn{constructor(){this.sarr=[],this.s="",this.lensE=new rt}write(e){if(this.s+=e,this.s.length>19)this.sarr.push(this.s),this.s="";this.lensE.write(e.length)}toUint8Array(){let e=new tt;return this.sarr.push(this.s),this.s="",Ue(e,this.sarr.join("")),Zt(e,this.lensE.toUint8Array()),se(e)}}var X=(e)=>Error(e),Q=()=>{throw X("Method unimplemented")},H=()=>{throw X("Unexpected case")};var Bs=X("Unexpected end of array"),Ms=X("Integer out of Range");class Ct{constructor(e){this.arr=e,this.pos=0}}var je=(e)=>new Ct(e),Vs=(e)=>e.pos!==e.arr.length;var Hp=(e,t)=>{let r=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,r},Y=(e)=>Hp(e,y(e));var De=(e)=>e.arr[e.pos++];var y=(e)=>{let t=0,r=1,n=e.arr.length;while(e.pos<n){let o=e.arr[e.pos++];if(t=t+(o&be)*r,r*=128,o<M)return t;if(t>Ye)throw Ms}throw Bs},Ar=(e)=>{let t=e.arr[e.pos++],r=t&At,n=64,o=(t&oe)>0?-1:1;if((t&M)===0)return o*r;let s=e.arr.length;while(e.pos<s){if(t=e.arr[e.pos++],r=r+(t&be)*n,n*=128,t<M)return o*r;if(r>Ye)throw Ms}throw Bs};var Yp=(e)=>{let t=y(e);if(t===0)return"";else{let r=String.fromCodePoint(De(e));if(--t<100)while(t--)r+=String.fromCodePoint(De(e));else while(t>0){let n=t<1e4?t:1e4,o=e.arr.subarray(e.pos,e.pos+n);e.pos+=n,r+=String.fromCodePoint.apply(null,o),t-=n}return decodeURIComponent(escape(r))}},Xp=(e)=>Xe.decode(Y(e)),Re=Xe?Xp:Yp;var Xn=(e,t)=>{let r=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,r},Qp=(e)=>Xn(e,4).getFloat32(0,!1),eh=(e)=>Xn(e,8).getFloat64(0,!1),th=(e)=>Xn(e,8).getBigInt64(0,!1);var rh=[(e)=>{return},(e)=>null,Ar,Qp,eh,th,(e)=>!1,(e)=>!0,Re,(e)=>{let t=y(e),r={};for(let n=0;n<t;n++){let o=Re(e);r[o]=nt(e)}return r},(e)=>{let t=y(e),r=[];for(let n=0;n<t;n++)r.push(nt(e));return r},Y],nt=(e)=>rh[127-De(e)](e);class Or extends Ct{constructor(e,t){super(e);this.reader=t,this.s=null,this.count=0}read(){if(this.count===0)if(this.s=this.reader(this),Vs(this))this.count=y(this)+1;else this.count=-1;return this.count--,this.s}}class ot extends Ct{constructor(e){super(e);this.s=0,this.count=0}read(){if(this.count===0){this.s=Ar(this);let e=vr(this.s);if(this.count=1,e)this.s=-this.s,this.count=y(this)+2}return this.count--,this.s}}class Nt extends Ct{constructor(e){super(e);this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Ar(this),t=e&1;if(this.diff=q(e/2),this.count=1,t)this.count=y(this)+2}return this.s+=this.diff,this.count--,this.s}}class Qn{constructor(e){this.decoder=new ot(e),this.str=Re(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}}var lg=crypto.subtle,Fs=crypto.getRandomValues.bind(crypto);var eo=()=>Fs(new Uint32Array(1))[0];var oh=[1e7]+-1000+-4000+-8000+-100000000000,Js=()=>oh.replace(/[018]/g,(e)=>(e^eo()&15>>e/4).toString(16));var qs=Date.now;var to=(e)=>new Promise(e);var dg=Promise.all.bind(Promise);var ro=(e)=>e===void 0?null:e;class Gs{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}}var Ws=new Gs,uh=!0;try{if(typeof localStorage<"u"&&localStorage)Ws=localStorage,uh=!1}catch(e){}var Ks=Ws;var Le=Symbol("Equality"),Zr=(e,t)=>e===t||!!e?.[Le]?.(t)||!1;var Hs=(e)=>typeof e==="object",Ys=Object.assign,ph=Object.keys;var Xs=(e,t)=>{for(let r in e)t(e[r],r)};var Ut=(e)=>ph(e).length;var Qs=(e)=>{for(let t in e)return!1;return!0},st=(e,t)=>{for(let r in e)if(!t(e[r],r))return!1;return!0},Dt=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),oo=(e,t)=>e===t||Ut(e)===Ut(t)&&st(e,(r,n)=>(r!==void 0||Dt(t,n))&&Zr(t[n],r)),hh=Object.freeze,so=(e)=>{for(let t in e){let r=e[t];if(typeof r==="object"||typeof r==="function")so(e[t])}return hh(e)};var jt=(e,t,r=0)=>{try{for(;r<e.length;r++)e[r](...t)}finally{if(r<e.length)jt(e,t,r+1)}};var ei=(e)=>e;var Rt=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Le]!=null)return e[Le](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:{if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;break}case Set:{if(e.size!==t.size)return!1;for(let r of e)if(!t.has(r))return!1;break}case Map:{if(e.size!==t.size)return!1;for(let r of e.keys())if(!t.has(r)||!Rt(e.get(r),t.get(r)))return!1;break}case void 0:case Object:if(Ut(e)!==Ut(t))return!1;for(let r in e)if(!Dt(e,r)||!Rt(e[r],t[r]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Rt(e[r],t[r]))return!1;break;default:return!1}return!0},ti=(e,t)=>t.includes(e);var Lt=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";var fg=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,pe,dh=[],fh=()=>{if(pe===void 0)if(Lt){pe=J();let e=process.argv,t=null;for(let r=0;r<e.length;r++){let n=e[r];if(n[0]==="-"){if(t!==null)pe.set(t,"");t=n}else if(t!==null)pe.set(t,n),t=null;else dh.push(n)}if(t!==null)pe.set(t,"")}else if(typeof location==="object")pe=J(),(location.search||"?").slice(1).split("&").forEach((e)=>{if(e.length!==0){let[t,r]=e.split("=");pe.set(`--${Gn(t,"-")}`,r),pe.set(`-${Gn(t,"-")}`,r)}});else pe=J();return pe},ao=(e)=>fh().has(e);var Bt=(e)=>Lt?ro(process.env[e.toUpperCase().replaceAll("-","_")]):ro(Ks.getItem(e));var ri=(e)=>ao("--"+e)||Bt(e)!==null,ni=ri("production"),mh=Lt&&ti(process.env.FORCE_COLOR,["true","1","2"]),oi=mh||!ao("--no-colors")&&!ri("no-color")&&(!Lt||process.stdout.isTTY)&&(!Lt||ao("--color")||Bt("COLORTERM")!==null||(Bt("TERM")||"").includes("color"));var gh=(e)=>new Uint8Array(e);var si=(e)=>{let t=gh(e.byteLength);return t.set(e),t};class ii{constructor(e,t){this.left=e,this.right=t}}var he=(e,t)=>new ii(e,t);var lo=(e)=>e.next()>=0.5,Pr=(e,t,r)=>q(e.next()*(r+1-t)+t);var po=(e,t,r)=>q(e.next()*(r+1-t)+t);var ho=(e,t,r)=>po(e,t,r);var _h=(e)=>qn(ho(e,97,122)),ci=(e,t=0,r=20)=>{let n=ho(e,t,r),o="";for(let s=0;s<n;s++)o+=_h(e);return o};var Cr=(e,t)=>t[ho(e,0,t.length-1)];var bh=Symbol("0schema");class ui{constructor(){this._rerrs=[]}extend(e,t,r,n=null){this._rerrs.push({path:e,expected:t,has:r,message:n})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let r=this._rerrs[t];e.push(Ds(" ",(this._rerrs.length-t)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(`
2
+ `)}}var fo=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor)return!1;if(e[Le])return Zr(e,t);if(Ce(e))return wr(e,(r)=>br(t,(n)=>fo(r,n)));else if(Hs(e))return st(e,(r,n)=>fo(r,t[n]));return!1};class V{static _dilutes=!1;extends(e){let[t,r]=[this.shape,e.shape];if(this.constructor._dilutes)[r,t]=[t,r];return fo(t,r)}equals(e){return this.constructor===e.constructor&&Rt(this.shape,e.shape)}[bh](){return!0}[Le](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Q()}get nullable(){return ut(this,Vr)}get optional(){return new mo(this)}cast(e){return ai(e,this),e}expect(e){return ai(e,this),e}}class Dr extends V{constructor(e,t){super();this.shape=e,this._c=t}check(e,t=void 0){let r=e?.constructor===this.shape&&(this._c==null||this._c(e));return!r&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor!==this.shape?"Constructor match failed":"Check failed"),r}}var O=(e,t=null)=>new Dr(e,t),gg=O(Dr);class Rr extends V{constructor(e){super();this.shape=e}check(e,t){let r=this.shape(e);return!r&&t?.extend(null,"custom prop",e?.constructor.name,"failed to check custom prop"),r}}var Z=(e)=>new Rr(e),yg=O(Rr);class Vt extends V{constructor(e){super();this.shape=e}check(e,t){let r=this.shape.some((n)=>n===e);return!r&&t?.extend(null,this.shape.join(" | "),e.toString()),r}}var jr=(...e)=>new Vt(e),li=O(Vt),kh=RegExp.escape||((e)=>e.replace(/[().|&,$^[\]]/g,(t)=>"\\"+t)),pi=(e)=>{if(at.check(e))return[kh(e)];if(li.check(e))return e.shape.map((t)=>t+"");if(_i.check(e))return["[+-]?\\d+.?\\d*"];if(wi.check(e))return[".*"];if(Nr.check(e))return e.shape.map(pi).flat(1);H()};class hi extends V{constructor(e){super();this.shape=e,this._r=new RegExp("^"+e.map(pi).map((t)=>`(${t.join("|")})`).join("")+"$")}check(e,t){let r=this._r.exec(e)!=null;return!r&&t?.extend(null,this._r.toString(),e.toString(),"String doesn't match string template."),r}}var xg=O(hi),vh=Symbol("optional");class mo extends V{constructor(e){super();this.shape=e}check(e,t){let r=e===void 0||this.shape.check(e);return!r&&t?.extend(null,"undefined (optional)","()"),r}get[vh](){return!0}}var zh=O(mo);class go extends V{check(e,t){return t?.extend(null,"never",typeof e),!1}}var _g=new go,wg=O(go);class Lr extends V{constructor(e,t=!1){super();this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new Lr(this.shape,!0)}check(e,t){if(e==null)return t?.extend(null,"object","null"),!1;return st(this.shape,(r,n)=>{let o=this._isPartial&&!Dt(e,n)||r.check(e[n],t);return!o&&t?.extend(n.toString(),r.toString(),typeof e[n],"Object property does not match"),o})}}var $h=(e)=>new Lr(e),Sh=O(Lr),Eh=Z((e)=>e!=null&&(e.constructor===Object||e.constructor==null));class yo extends V{constructor(e,t){super();this.shape={keys:e,values:t}}check(e,t){return e!=null&&st(e,(r,n)=>{let o=this.shape.keys.check(n,t);return!o&&t?.extend(n+"","Record",typeof e,o?"Key doesn't match schema":"Value doesn't match value"),o&&this.shape.values.check(r,t)})}}var di=(e,t)=>new yo(e,t),Ih=O(yo);class xo extends V{constructor(e){super();this.shape=e}check(e,t){return e!=null&&st(this.shape,(r,n)=>{let o=r.check(e[n],t);return!o&&t?.extend(n.toString(),"Tuple",typeof r),o})}}var Th=(...e)=>new xo(e),bg=O(xo);class _o extends V{constructor(e){super();this.shape=e.length===1?e[0]:new Br(e)}check(e,t){let r=Ce(e)&&wr(e,(n)=>this.shape.check(n));return!r&&t?.extend(null,"Array",""),r}}var fi=(...e)=>new _o(e),Ah=O(_o),Oh=Z((e)=>Ce(e));class wo extends V{constructor(e,t){super();this.shape=e,this._c=t}check(e,t){let r=e instanceof this.shape&&(this._c==null||this._c(e));return!r&&t?.extend(null,this.shape.name,e?.constructor.name),r}}var Zh=(e,t=null)=>new wo(e,t),kg=O(wo),Ph=Zh(V);class mi extends V{constructor(e){super();this.len=e.length-1,this.args=Th(...e.slice(-1)),this.res=e[this.len]}check(e,t){let r=e.constructor===Function&&e.length<=this.len;return!r&&t?.extend(null,"function",typeof e),r}}var Ch=O(mi),Nh=Z((e)=>typeof e==="function");class gi extends V{constructor(e){super();this.shape=e}check(e,t){let r=wr(this.shape,(n)=>n.check(e,t));return!r&&t?.extend(null,"Intersectinon",typeof e),r}}var vg=O(gi,(e)=>e.shape.length>0);class Br extends V{static _dilutes=!0;constructor(e){super();this.shape=e}check(e,t){let r=br(this.shape,(n)=>n.check(e,t));return t?.extend(null,"Union",typeof e),r}}var ut=(...e)=>e.findIndex((t)=>Nr.check(t))>=0?ut(...e.map((t)=>Mt(t)).map((t)=>Nr.check(t)?t.shape:[t]).flat(1)):e.length===1?e[0]:new Br(e),Nr=O(Br),yi=()=>!0,Ur=Z(yi),Uh=O(Rr,(e)=>e.shape===yi),bo=Z((e)=>typeof e==="bigint"),Dh=Z((e)=>e===bo),xi=Z((e)=>typeof e==="symbol"),zg=Z((e)=>e===xi),ct=Z((e)=>typeof e==="number"),_i=Z((e)=>e===ct),at=Z((e)=>typeof e==="string"),wi=Z((e)=>e===at),Mr=Z((e)=>typeof e==="boolean"),Rh=Z((e)=>e===Mr),bi=jr(void 0),$g=O(Vt,(e)=>e.shape.length===1&&e.shape[0]===void 0),Sg=jr(void 0);var Vr=jr(null),jh=O(Vt,(e)=>e.shape.length===1&&e.shape[0]===null),Eg=O(Uint8Array),Ig=O(Dr,(e)=>e.shape===Uint8Array),Lh=ut(ct,at,Vr,bi,bo,Mr,xi),Tg=(()=>{let e=fi(Ur),t=di(at,Ur),r=ut(ct,at,Vr,Mr,e,t);return e.shape=r,t.shape.values=r,r})(),Mt=(e)=>{if(Ph.check(e))return e;else if(Eh.check(e)){let t={};for(let r in e)t[r]=Mt(e[r]);return $h(t)}else if(Oh.check(e))return ut(...e.map(Mt));else if(Lh.check(e))return jr(e);else if(Nh.check(e))return O(e);H()},ai=ni?()=>{}:(e,t)=>{let r=new ui;if(!t.check(e,r))throw X(`Expected value to be of type ${t.constructor.name}.
3
+ ${r.toString()}`)};class ki{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:Mt(e),h:t}),this}else(e){return this.if(Ur,e)}done(){return(e,t)=>{for(let r=0;r<this.patterns.length;r++){let n=this.patterns[r];if(n.if.check(e))return n.h(e,t)}throw X("Unhandled pattern")}}}var Bh=(e)=>new ki(e),vi=Bh(Ur).if(_i,(e,t)=>Pr(t,Fn,Ye)).if(wi,(e,t)=>ci(t)).if(Rh,(e,t)=>lo(t)).if(Dh,(e,t)=>BigInt(Pr(t,Fn,Ye))).if(Nr,(e,t)=>it(t,Cr(t,e.shape))).if(Sh,(e,t)=>{let r={};for(let n in e.shape){let o=e.shape[n];if(zh.check(o)){if(lo(t))continue;o=o.shape}r[n]=vi(o,t)}return r}).if(Ah,(e,t)=>{let r=[],n=po(t,0,42);for(let o=0;o<n;o++)r.push(it(t,e.shape));return r}).if(li,(e,t)=>Cr(t,e.shape)).if(jh,(e,t)=>null).if(Ch,(e,t)=>{let r=it(t,e.res);return()=>r}).if(Uh,(e,t)=>it(t,Cr(t,[ct,at,Vr,bi,bo,Mr,fi(ct),di(ut("a","b","c"),ct)]))).if(Ih,(e,t)=>{let r={},n=Pr(t,0,3);for(let o=0;o<n;o++){let s=it(t,e.shape.keys),i=it(t,e.shape.values);r[s]=i}return r}).done(),it=(e,t)=>vi(Mt(t),e);var Be=typeof document<"u"?document:{};var Ag=Z((e)=>e.nodeType===qh);var Og=typeof DOMParser<"u"?new DOMParser:null;var Zg=Z((e)=>e.nodeType===Vh);var Pg=Z((e)=>e.nodeType===Fh);var zi=(e)=>As(e,(t,r)=>`${r}:${t};`).join("");var{ELEMENT_NODE:Vh,TEXT_NODE:Fh,CDATA_SECTION_NODE:Cg,COMMENT_NODE:Ng,DOCUMENT_NODE:Jh,DOCUMENT_TYPE_NODE:Ug,DOCUMENT_FRAGMENT_NODE:qh}=Be,Dg=Z((e)=>e.nodeType===Jh);var de=Symbol;var Ft=de(),Jt=de(),ko=de(),vo=de(),zo=de(),qt=de(),$o=de(),lt=de(),So=de(),$i=(e)=>{if(e.length===1&&e[0]?.constructor===Function)e=e[0]();let t=[],r=[],n=0;for(;n<e.length;n++){let o=e[n];if(o===void 0)break;else if(o.constructor===String||o.constructor===Number)t.push(o);else if(o.constructor===Object)break}if(n>0)r.push(t.join(""));for(;n<e.length;n++){let o=e[n];if(!(o instanceof Symbol))r.push(o)}return r};var Rg=qs();var Hh={[Ft]:he("font-weight","bold"),[Jt]:he("font-weight","normal"),[ko]:he("color","blue"),[zo]:he("color","green"),[vo]:he("color","grey"),[qt]:he("color","red"),[$o]:he("color","purple"),[lt]:he("color","orange"),[So]:he("color","black")},Yh=(e)=>{if(e.length===1&&e[0]?.constructor===Function)e=e[0]();let t=[],r=[],n=J(),o=[],s=0;for(;s<e.length;s++){let i=e[s],c=Hh[i];if(c!==void 0)n.set(c.left,c.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){let a=zi(n);if(s>0||a.length>0)t.push("%c"+i),r.push(a);else t.push(i)}else break}}if(s>0)o=r,o.unshift(t.join(""));for(;s<e.length;s++){let i=e[s];if(!(i instanceof Symbol))o.push(i)}return o},Si=oi?Yh:$i,Ei=(...e)=>{console.log(...Si(e)),Ti.forEach((t)=>t.print(e))},Ii=(...e)=>{console.warn(...Si(e)),e.unshift(lt),Ti.forEach((t)=>t.print(e))};var Ti=_e();var Ai=(e)=>({[Symbol.iterator](){return this},next:e}),Oi=(e,t)=>Ai(()=>{let r;do r=e.next();while(!r.done&&!t(r.value));return r}),Fr=(e,t)=>Ai(()=>{let{done:r,value:n}=e.next();return{done:r,value:r?void 0:t(n)}});class Ht{constructor(e,t){this.clock=e,this.len=t}}class dt{constructor(){this.clients=new Map}}var Vi=(e,t,r)=>t.clients.forEach((n,o)=>{let s=e.doc.store.clients.get(o);if(s!=null){let i=s[s.length-1],c=i.id.clock+i.length;for(let a=0,l=n[a];a<n.length&&l.clock<c;l=n[++a])rc(e,s,l.clock,l.len,r)}}),ed=(e,t)=>{let r=0,n=e.length-1;while(r<=n){let o=q((r+n)/2),s=e[o],i=s.clock;if(i<=t){if(t<i+s.len)return o;r=o+1}else n=o-1}return null},Fi=(e,t)=>{let r=e.clients.get(t.client);return r!==void 0&&ed(r,t.clock)!==null},Oo=(e)=>{e.clients.forEach((t)=>{t.sort((o,s)=>o.clock-s.clock);let r,n;for(r=1,n=1;r<t.length;r++){let o=t[n-1],s=t[r];if(o.clock+o.len>=s.clock)t[n-1]=new Ht(o.clock,we(o.len,s.clock+s.len-o.clock));else{if(n<r)t[n]=s;n++}}t.length=n})},td=(e)=>{let t=new dt;for(let r=0;r<e.length;r++)e[r].clients.forEach((n,o)=>{if(!t.clients.has(o)){let s=n.slice();for(let i=r+1;i<e.length;i++)Zs(s,e[i].clients.get(o)||[]);t.clients.set(o,s)}});return Oo(t),t},Hr=(e,t,r,n)=>{ue(e.clients,t,()=>[]).push(new Ht(r,n))},Ji=()=>new dt,rd=(e)=>{let t=Ji();return e.clients.forEach((r,n)=>{let o=[];for(let s=0;s<r.length;s++){let i=r[s];if(i.deleted){let c=i.id.clock,a=i.length;if(s+1<r.length)for(let l=r[s+1];s+1<r.length&&l.deleted;l=r[++s+1])a+=l.length;o.push(new Ht(c,a))}}if(o.length>0)t.clients.set(n,o)}),t},ft=(e,t)=>{x(e.restEncoder,t.clients.size),le(t.clients.entries()).sort((r,n)=>n[0]-r[0]).forEach(([r,n])=>{e.resetDsCurVal(),x(e.restEncoder,r);let o=n.length;x(e.restEncoder,o);for(let s=0;s<o;s++){let i=n[s];e.writeDsClock(i.clock),e.writeDsLen(i.len)}})},Zo=(e)=>{let t=new dt,r=y(e.restDecoder);for(let n=0;n<r;n++){e.resetDsCurVal();let o=y(e.restDecoder),s=y(e.restDecoder);if(s>0){let i=ue(t.clients,o,()=>[]);for(let c=0;c<s;c++)i.push(new Ht(e.readDsClock(),e.readDsLen()))}}return t},Zi=(e,t,r)=>{let n=new dt,o=y(e.restDecoder);for(let s=0;s<o;s++){e.resetDsCurVal();let i=y(e.restDecoder),c=y(e.restDecoder),a=r.clients.get(i)||[],l=U(r,i);for(let u=0;u<c;u++){let h=e.readDsClock(),p=h+e.readDsLen();if(h<l){if(l<p)Hr(n,i,l,p-l);let f=fe(a,h),m=a[f];if(!m.deleted&&m.id.clock<h)a.splice(f+1,0,on(t,m,h-m.id.clock)),f++;while(f<a.length)if(m=a[f++],m.id.clock<p){if(!m.deleted){if(p<m.id.clock+m.length)a.splice(f,0,on(t,m,p-m.id.clock));m.delete(t)}}else break}else Hr(n,i,h,p-h)}}if(n.clients.size>0){let s=new Te;return x(s.restEncoder,0),ft(s,n),s.toUint8Array()}return null};var qi=eo;class ge extends Ln{constructor({guid:e=Js(),collectionid:t=null,gc:r=!0,gcFilter:n=()=>!0,meta:o=null,autoLoad:s=!1,shouldLoad:i=!0}={}){super();this.gc=r,this.gcFilter=n,this.clientID=qi(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new Ro,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=i,this.autoLoad=s,this.meta=o,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=to((a)=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});let c=()=>to((a)=>{let l=(u)=>{if(u===void 0||u===!0)this.off("sync",l),a()};this.on("sync",l)});this.on("sync",(a)=>{if(a===!1&&this.isSynced)this.whenSynced=c();if(this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded)this.emit("load",[this])}),this.whenSynced=c()}load(){let e=this._item;if(e!==null&&!this.shouldLoad)v(e.parent.doc,(t)=>{t.subdocsLoaded.add(this)},null,!0);this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(le(this.subdocs).map((e)=>e.guid))}transact(e,t=null){return v(this,e,t)}get(e,t=D){let r=ue(this.share,e,()=>{let o=new t;return o._integrate(this,null),o}),n=r.constructor;if(t!==D&&n!==t)if(n===D){let o=new t;o._map=r._map,r._map.forEach((s)=>{for(;s!==null;s=s.left)s.parent=o}),o._start=r._start;for(let s=o._start;s!==null;s=s.right)s.parent=o;return o._length=r._length,this.share.set(e,o),o._integrate(this,null),o}else throw Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,re)}getText(e=""){return this.get(e,ie)}getMap(e=""){return this.get(e,G)}getXmlElement(e=""){return this.get(e,ht)}getXmlFragment(e=""){return this.get(e,Fe)}toJSON(){let e={};return this.share.forEach((t,r)=>{e[r]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,le(this.subdocs).forEach((t)=>t.destroy());let e=this._item;if(e!==null){this._item=null;let t=e.content;t.doc=new ge({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,v(e.parent.doc,(r)=>{let n=t.doc;if(!e.deleted)r.subdocsAdded.add(n);r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class Po{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return y(this.restDecoder)}readDsLen(){return y(this.restDecoder)}}class Co extends Po{readLeftID(){return _(y(this.restDecoder),y(this.restDecoder))}readRightID(){return _(y(this.restDecoder),y(this.restDecoder))}readClient(){return y(this.restDecoder)}readInfo(){return De(this.restDecoder)}readString(){return Re(this.restDecoder)}readParentInfo(){return y(this.restDecoder)===1}readTypeRef(){return y(this.restDecoder)}readLen(){return y(this.restDecoder)}readAny(){return nt(this.restDecoder)}readBuf(){return si(Y(this.restDecoder))}readJSON(){return JSON.parse(Re(this.restDecoder))}readKey(){return Re(this.restDecoder)}}class Gi{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=y(this.restDecoder),this.dsCurrVal}readDsLen(){let e=y(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Ve extends Gi{constructor(e){super(e);this.keys=[],y(e),this.keyClockDecoder=new Nt(Y(e)),this.clientDecoder=new ot(Y(e)),this.leftClockDecoder=new Nt(Y(e)),this.rightClockDecoder=new Nt(Y(e)),this.infoDecoder=new Or(Y(e),De),this.stringDecoder=new Qn(Y(e)),this.parentInfoDecoder=new Or(Y(e),De),this.typeRefDecoder=new ot(Y(e)),this.lenDecoder=new ot(Y(e))}readLeftID(){return new Me(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Me(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 nt(this.restDecoder)}readBuf(){return Y(this.restDecoder)}readJSON(){return nt(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];else{let t=this.stringDecoder.read();return this.keys.push(t),t}}}class No{constructor(){this.restEncoder=Ot()}toUint8Array(){return se(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){x(this.restEncoder,e)}writeDsLen(e){x(this.restEncoder,e)}}class mt extends No{writeLeftID(e){x(this.restEncoder,e.client),x(this.restEncoder,e.clock)}writeRightID(e){x(this.restEncoder,e.client),x(this.restEncoder,e.clock)}writeClient(e){x(this.restEncoder,e)}writeInfo(e){Er(this.restEncoder,e)}writeString(e){Ue(this.restEncoder,e)}writeParentInfo(e){x(this.restEncoder,e?1:0)}writeTypeRef(e){x(this.restEncoder,e)}writeLen(e){x(this.restEncoder,e)}writeAny(e){et(this.restEncoder,e)}writeBuf(e){K(this.restEncoder,e)}writeJSON(e){Ue(this.restEncoder,JSON.stringify(e))}writeKey(e){Ue(this.restEncoder,e)}}class Uo{constructor(){this.restEncoder=Ot(),this.dsCurrVal=0}toUint8Array(){return se(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,x(this.restEncoder,t)}writeDsLen(e){if(e===0)H();x(this.restEncoder,e-1),this.dsCurrVal+=e}}class Te extends Uo{constructor(){super();this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Pt,this.clientEncoder=new rt,this.leftClockEncoder=new Pt,this.rightClockEncoder=new Pt,this.infoEncoder=new Tr(Er),this.stringEncoder=new Hn,this.parentInfoEncoder=new Tr(Er),this.typeRefEncoder=new rt,this.lenEncoder=new rt}toUint8Array(){let e=Ot();return x(e,0),K(e,this.keyClockEncoder.toUint8Array()),K(e,this.clientEncoder.toUint8Array()),K(e,this.leftClockEncoder.toUint8Array()),K(e,this.rightClockEncoder.toUint8Array()),K(e,se(this.infoEncoder)),K(e,this.stringEncoder.toUint8Array()),K(e,se(this.parentInfoEncoder)),K(e,this.typeRefEncoder.toUint8Array()),K(e,this.lenEncoder.toUint8Array()),Zt(e,se(this.restEncoder)),se(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){et(this.restEncoder,e)}writeBuf(e){K(this.restEncoder,e)}writeJSON(e){et(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);if(t===void 0)this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e);else this.keyClockEncoder.write(t)}}var nd=(e,t,r,n)=>{n=we(n,t[0].id.clock);let o=fe(t,n);x(e.restEncoder,t.length-o),e.writeClient(r),x(e.restEncoder,n);let s=t[o];s.write(e,n-s.id.clock);for(let i=o+1;i<t.length;i++)t[i].write(e,0)},Do=(e,t,r)=>{let n=new Map;r.forEach((o,s)=>{if(U(t,s)>o)n.set(s,o)}),cn(t).forEach((o,s)=>{if(!r.has(s))n.set(s,0)}),x(e.restEncoder,n.size),le(n.entries()).sort((o,s)=>s[0]-o[0]).forEach(([o,s])=>{nd(e,t.clients.get(o),o,s)})},od=(e,t)=>{let r=J(),n=y(e.restDecoder);for(let o=0;o<n;o++){let s=y(e.restDecoder),i=Array(s),c=e.readClient(),a=y(e.restDecoder);r.set(c,{i:0,refs:i});for(let l=0;l<s;l++){let u=e.readInfo();switch(Tt&u){case 0:{let h=e.readLen();i[l]=new ee(_(c,a),h),a+=h;break}case 10:{let h=y(e.restDecoder);i[l]=new te(_(c,a),h),a+=h;break}default:{let h=(u&(oe|M))===0,p=new P(_(c,a),null,(u&M)===M?e.readLeftID():null,null,(u&oe)===oe?e.readRightID():null,h?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,h&&(u&He)===He?e.readString():null,Ec(e,u));i[l]=p,a+=p.length}}}}return r},sd=(e,t,r)=>{let n=[],o=le(r.keys()).sort((f,m)=>f-m);if(o.length===0)return null;let s=()=>{if(o.length===0)return null;let f=r.get(o[o.length-1]);while(f.refs.length===f.i)if(o.pop(),o.length>0)f=r.get(o[o.length-1]);else return null;return f},i=s();if(i===null)return null;let c=new Ro,a=new Map,l=(f,m)=>{let k=a.get(f);if(k==null||k>m)a.set(f,m)},u=i.refs[i.i++],h=new Map,p=()=>{for(let f of n){let m=f.id.client,k=r.get(m);if(k)k.i--,c.clients.set(m,k.refs.slice(k.i)),r.delete(m),k.i=0,k.refs=[];else c.clients.set(m,[f]);o=o.filter((z)=>z!==m)}n.length=0};while(!0){if(u.constructor!==te){let m=ue(h,u.id.client,()=>U(t,u.id.client))-u.id.clock;if(m<0)n.push(u),l(u.id.client,u.id.clock-1),p();else{let k=u.getMissing(e,t);if(k!==null){n.push(u);let z=r.get(k)||{refs:[],i:0};if(z.refs.length===z.i)l(k,U(t,k)),p();else{u=z.refs[z.i++];continue}}else if(m===0||m<u.length)u.integrate(e,m),h.set(u.id.client,u.id.clock+u.length)}}if(n.length>0)u=n.pop();else if(i!==null&&i.i<i.refs.length)u=i.refs[i.i++];else if(i=s(),i===null)break;else u=i.refs[i.i++]}if(c.clients.size>0){let f=new Te;return Do(f,c,new Map),x(f.restEncoder,0),{missing:a,update:f.toUint8Array()}}return null},id=(e,t)=>Do(e,t.doc.store,t.beforeState),cd=(e,t,r,n=new Ve(e))=>v(t,(o)=>{o.local=!1;let s=!1,i=o.doc,c=i.store,a=od(n,i),l=sd(o,c,a),u=c.pendingStructs;if(u){for(let[p,f]of u.missing)if(f<U(c,p)){s=!0;break}if(l){for(let[p,f]of l.missing){let m=u.missing.get(p);if(m==null||m>f)u.missing.set(p,f)}u.update=Yr([u.update,l.update])}}else c.pendingStructs=l;let h=Zi(n,o,c);if(c.pendingDs){let p=new Ve(je(c.pendingDs));y(p.restDecoder);let f=Zi(p,o,c);if(h&&f)c.pendingDs=Yr([h,f]);else c.pendingDs=h||f}else c.pendingDs=h;if(s){let p=c.pendingStructs.update;c.pendingStructs=null,Wi(o.doc,p)}},r,!1);var Wi=(e,t,r,n=Ve)=>{let o=je(t);cd(o,e,r,new n(o))},sn=(e,t,r)=>Wi(e,t,r,Co),ad=(e,t,r=new Map)=>{Do(e,t.store,r),ft(e,rd(t.store))},ud=(e,t=new Uint8Array([0]),r=new Te)=>{let n=Ki(t);ad(r,e,n);let o=[r.toUint8Array()];if(e.store.pendingDs)o.push(e.store.pendingDs);if(e.store.pendingStructs)o.push(kd(e.store.pendingStructs.update,t));if(o.length>1){if(r.constructor===mt)return wd(o.map((s,i)=>i===0?s:zd(s)));else if(r.constructor===Te)return Yr(o)}return o[0]},gt=(e,t)=>ud(e,t,new mt),ld=(e)=>{let t=new Map,r=y(e.restDecoder);for(let n=0;n<r;n++){let o=y(e.restDecoder),s=y(e.restDecoder);t.set(o,s)}return t},Ki=(e)=>ld(new Po(je(e))),Hi=(e,t)=>(x(e.restEncoder,t.size),le(t.entries()).sort((r,n)=>n[0]-r[0]).forEach(([r,n])=>{x(e.restEncoder,r),x(e.restEncoder,n)}),e),pd=(e,t)=>Hi(e,cn(t.store)),hd=(e,t=new Uo)=>{if(e instanceof Map)Hi(t,e);else pd(t,e);return t.toUint8Array()},Yi=(e)=>hd(e,new No);class Xi{constructor(){this.l=[]}}var Pi=()=>new Xi,Ci=(e,t)=>e.l.push(t),Ni=(e,t)=>{let r=e.l,n=r.length;if(e.l=r.filter((o)=>t!==o),n===e.l.length)console.error("[yjs] Tried to remove event handler that doesn't exist.")},Qi=(e,t,r)=>jt(e.l,[t,r]);class Me{constructor(e,t){this.client=e,this.clock=t}}var Jr=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,_=(e,t)=>new Me(e,t);var dd=(e)=>{for(let[t,r]of e.doc.share.entries())if(r===e)return t;throw H()};class ec{constructor(e,t){this.ds=e,this.sv=t}}var fd=(e,t)=>new ec(e,t),Kg=fd(Ji(),new Map);var pt=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!Fi(t.ds,e.id),To=(e,t)=>{let r=ue(e.meta,To,_e),n=e.doc.store;if(!r.has(t))t.sv.forEach((o,s)=>{if(o<U(n,s))Ae(e,_(s,o))}),Vi(e,t.ds,(o)=>{}),r.add(t)};class Ro{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}var cn=(e)=>{let t=new Map;return e.clients.forEach((r,n)=>{let o=r[r.length-1];t.set(n,o.id.clock+o.length)}),t},U=(e,t)=>{let r=e.clients.get(t);if(r===void 0)return 0;let n=r[r.length-1];return n.id.clock+n.length},tc=(e,t)=>{let r=e.clients.get(t.id.client);if(r===void 0)r=[],e.clients.set(t.id.client,r);else{let n=r[r.length-1];if(n.id.clock+n.length!==t.id.clock)throw H()}r.push(t)},fe=(e,t)=>{let r=0,n=e.length-1,o=e[n],s=o.id.clock;if(s===t)return n;let i=q(t/(s+o.length-1)*n);while(r<=n){if(o=e[i],s=o.id.clock,s<=t){if(t<s+o.length)return i;r=i+1}else n=i-1;i=q((r+n)/2)}throw H()},md=(e,t)=>{let r=e.clients.get(t.client);return r[fe(r,t.clock)]},Eo=md,Ao=(e,t,r)=>{let n=fe(t,r),o=t[n];if(o.id.clock<r&&o instanceof P)return t.splice(n+1,0,on(e,o,r-o.id.clock)),n+1;return n},Ae=(e,t)=>{let r=e.doc.store.clients.get(t.client);return r[Ao(e,r,t.clock)]},Ui=(e,t,r)=>{let n=t.clients.get(r.client),o=fe(n,r.clock),s=n[o];if(r.clock!==s.id.clock+s.length-1&&s.constructor!==ee)n.splice(o+1,0,on(e,s,r.clock-s.id.clock+1));return s},gd=(e,t,r)=>{let n=e.clients.get(t.id.client);n[fe(n,t.id.clock)]=r},rc=(e,t,r,n,o)=>{if(n===0)return;let s=r+n,i=Ao(e,t,r),c;do{if(c=t[i++],s<c.id.clock+c.length)Ao(e,t,s);o(c)}while(i<t.length&&t[i].id.clock<s)};class nc{constructor(e,t,r){this.doc=e,this.deleteSet=new dt,this.beforeState=cn(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}var Di=(e,t)=>{if(t.deleteSet.clients.size===0&&!Os(t.afterState,(r,n)=>t.beforeState.get(n)!==r))return!1;return Oo(t.deleteSet),id(e,t),ft(e,t.deleteSet),!0},Ri=(e,t,r)=>{let n=t._item;if(n===null||n.id.clock<(e.beforeState.get(n.id.client)||0)&&!n.deleted)ue(e.changed,t,_e).add(r)},Wr=(e,t)=>{let r=e[t],n=e[t-1],o=t;for(;o>0;r=n,n=e[--o-1]){if(n.deleted===r.deleted&&n.constructor===r.constructor){if(n.mergeWith(r)){if(r instanceof P&&r.parentSub!==null&&r.parent._map.get(r.parentSub)===r)r.parent._map.set(r.parentSub,n);continue}}break}let s=t-o;if(s)e.splice(t+1-s,s);return s},yd=(e,t,r)=>{for(let[n,o]of e.clients.entries()){let s=t.clients.get(n);for(let i=o.length-1;i>=0;i--){let c=o[i],a=c.clock+c.len;for(let l=fe(s,c.clock),u=s[l];l<s.length&&u.id.clock<a;u=s[++l]){let h=s[l];if(c.clock+c.len<=h.id.clock)break;if(h instanceof P&&h.deleted&&!h.keep&&r(h))h.gc(t,!1)}}}},xd=(e,t)=>{e.clients.forEach((r,n)=>{let o=t.clients.get(n);for(let s=r.length-1;s>=0;s--){let i=r[s],c=kr(o.length-1,1+fe(o,i.clock+i.len-1));for(let a=c,l=o[a];a>0&&l.id.clock>=i.clock;l=o[a])a-=1+Wr(o,a)}})};var oc=(e,t)=>{if(t<e.length){let r=e[t],n=r.doc,o=n.store,s=r.deleteSet,i=r._mergeStructs;try{Oo(s),r.afterState=cn(r.doc.store),n.emit("beforeObserverCalls",[r,n]);let c=[];r.changed.forEach((a,l)=>c.push(()=>{if(l._item===null||!l._item.deleted)l._callObserver(r,a)})),c.push(()=>{r.changedParentTypes.forEach((a,l)=>{if(l._dEH.l.length>0&&(l._item===null||!l._item.deleted))a=a.filter((u)=>u.target._item===null||!u.target._item.deleted),a.forEach((u)=>{u.currentTarget=l,u._path=null}),a.sort((u,h)=>u.path.length-h.path.length),c.push(()=>{Qi(l._dEH,a,r)})}),c.push(()=>n.emit("afterTransaction",[r,n])),c.push(()=>{if(r._needFormattingCleanup)Nd(r)})}),jt(c,[])}finally{if(n.gc)yd(s,o,n.gcFilter);xd(s,o),r.afterState.forEach((u,h)=>{let p=r.beforeState.get(h)||0;if(p!==u){let f=o.clients.get(h),m=we(fe(f,p),1);for(let k=f.length-1;k>=m;)k-=1+Wr(f,k)}});for(let u=i.length-1;u>=0;u--){let{client:h,clock:p}=i[u].id,f=o.clients.get(h),m=fe(f,p);if(m+1<f.length){if(Wr(f,m+1)>1)continue}if(m>0)Wr(f,m)}if(!r.local&&r.afterState.get(n.clientID)!==r.beforeState.get(n.clientID))Ei(lt,Ft,"[yjs] ",Jt,qt,"Changed the client-id because another client seems to be using it."),n.clientID=qi();if(n.emit("afterTransactionCleanup",[r,n]),n._observers.has("update")){let u=new mt;if(Di(u,r))n.emit("update",[u.toUint8Array(),r.origin,n,r])}if(n._observers.has("updateV2")){let u=new Te;if(Di(u,r))n.emit("updateV2",[u.toUint8Array(),r.origin,n,r])}let{subdocsAdded:c,subdocsLoaded:a,subdocsRemoved:l}=r;if(c.size>0||l.size>0||a.size>0)c.forEach((u)=>{if(u.clientID=n.clientID,u.collectionid==null)u.collectionid=n.collectionid;n.subdocs.add(u)}),l.forEach((u)=>n.subdocs.delete(u)),n.emit("subdocs",[{loaded:a,added:c,removed:l},n,r]),l.forEach((u)=>u.destroy());if(e.length<=t+1)n._transactionCleanups=[],n.emit("afterAllTransactions",[n,e]);else oc(e,t+1)}}},v=(e,t,r=null,n=!0)=>{let o=e._transactionCleanups,s=!1,i=null;if(e._transaction===null){if(s=!0,e._transaction=new nc(e,r,n),o.push(e._transaction),o.length===1)e.emit("beforeAllTransactions",[e]);e.emit("beforeTransaction",[e._transaction,e])}try{i=t(e._transaction)}finally{if(s){let c=e._transaction===o[0];if(e._transaction=null,c)oc(o,0)}}return i};function*_d(e){let t=y(e.restDecoder);for(let r=0;r<t;r++){let n=y(e.restDecoder),o=e.readClient(),s=y(e.restDecoder);for(let i=0;i<n;i++){let c=e.readInfo();if(c===10){let a=y(e.restDecoder);yield new te(_(o,s),a),s+=a}else if((Tt&c)!==0){let a=(c&(oe|M))===0,l=new P(_(o,s),null,(c&M)===M?e.readLeftID():null,null,(c&oe)===oe?e.readRightID():null,a?e.readParentInfo()?e.readString():e.readLeftID():null,a&&(c&He)===He?e.readString():null,Ec(e,c));yield l,s+=l.length}else{let a=e.readLen();yield new ee(_(o,s),a),s+=a}}}}class an{constructor(e,t){this.gen=_d(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===te);return this.curr}}class un{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}var wd=(e)=>Yr(e,Co,mt);var bd=(e,t)=>{if(e.constructor===ee){let{client:r,clock:n}=e.id;return new ee(_(r,n+t),e.length-t)}else if(e.constructor===te){let{client:r,clock:n}=e.id;return new te(_(r,n+t),e.length-t)}else{let r=e,{client:n,clock:o}=r.id;return new P(_(n,o+t),null,_(n,o+t-1),null,r.rightOrigin,r.parent,r.parentSub,r.content.splice(t))}},Yr=(e,t=Ve,r=Te)=>{if(e.length===1)return e[0];let n=e.map((u)=>new t(je(u))),o=n.map((u)=>new an(u,!0)),s=null,i=new r,c=new un(i);while(!0){if(o=o.filter((p)=>p.curr!==null),o.sort((p,f)=>{if(p.curr.id.client===f.curr.id.client){let m=p.curr.id.clock-f.curr.id.clock;if(m===0)return p.curr.constructor===f.curr.constructor?0:p.curr.constructor===te?1:-1;else return m}else return f.curr.id.client-p.curr.id.client}),o.length===0)break;let u=o[0],h=u.curr.id.client;if(s!==null){let p=u.curr,f=!1;while(p!==null&&p.id.clock+p.length<=s.struct.id.clock+s.struct.length&&p.id.client>=s.struct.id.client)p=u.next(),f=!0;if(p===null||p.id.client!==h||f&&p.id.clock>s.struct.id.clock+s.struct.length)continue;if(h!==s.struct.id.client)Ee(c,s.struct,s.offset),s={struct:p,offset:0},u.next();else if(s.struct.id.clock+s.struct.length<p.id.clock)if(s.struct.constructor===te)s.struct.length=p.id.clock+p.length-s.struct.id.clock;else{Ee(c,s.struct,s.offset);let m=p.id.clock-s.struct.id.clock-s.struct.length;s={struct:new te(_(h,s.struct.id.clock+s.struct.length),m),offset:0}}else{let m=s.struct.id.clock+s.struct.length-p.id.clock;if(m>0)if(s.struct.constructor===te)s.struct.length-=m;else p=bd(p,m);if(!s.struct.mergeWith(p))Ee(c,s.struct,s.offset),s={struct:p,offset:0},u.next()}}else s={struct:u.curr,offset:0},u.next();for(let p=u.curr;p!==null&&p.id.client===h&&p.id.clock===s.struct.id.clock+s.struct.length&&p.constructor!==te;p=u.next())Ee(c,s.struct,s.offset),s={struct:p,offset:0}}if(s!==null)Ee(c,s.struct,s.offset),s=null;jo(c);let a=n.map((u)=>Zo(u)),l=td(a);return ft(i,l),i.toUint8Array()},kd=(e,t,r=Ve,n=Te)=>{let o=Ki(t),s=new n,i=new un(s),c=new r(je(e)),a=new an(c,!1);while(a.curr){let u=a.curr,h=u.id.client,p=o.get(h)||0;if(a.curr.constructor===te){a.next();continue}if(u.id.clock+u.length>p){Ee(i,u,we(p-u.id.clock,0)),a.next();while(a.curr&&a.curr.id.client===h)Ee(i,a.curr,0),a.next()}else while(a.curr&&a.curr.id.client===h&&a.curr.id.clock+a.curr.length<=p)a.next()}jo(i);let l=Zo(c);return ft(s,l),s.toUint8Array()};var sc=(e)=>{if(e.written>0)e.clientStructs.push({written:e.written,restEncoder:se(e.encoder.restEncoder)}),e.encoder.restEncoder=Ot(),e.written=0},Ee=(e,t,r)=>{if(e.written>0&&e.currClient!==t.id.client)sc(e);if(e.written===0)e.currClient=t.id.client,e.encoder.writeClient(t.id.client),x(e.encoder.restEncoder,t.id.clock+r);t.write(e.encoder,r),e.written++},jo=(e)=>{sc(e);let t=e.encoder.restEncoder;x(t,e.clientStructs.length);for(let r=0;r<e.clientStructs.length;r++){let n=e.clientStructs[r];x(t,n.written),Zt(t,n.restEncoder)}},vd=(e,t,r,n)=>{let o=new r(je(e)),s=new an(o,!1),i=new n,c=new un(i);for(let l=s.curr;l!==null;l=s.next())Ee(c,t(l),0);jo(c);let a=Zo(o);return ft(i,a),i.toUint8Array()};var zd=(e)=>vd(e,ei,Ve,mt),ji="You must not compute changes after the event-handler fired.";class Yt{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=$d(this.currentTarget,this.target))}deletes(e){return Fi(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw X(ji);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach((n)=>{if(n!==null){let o=t._map.get(n),s,i;if(this.adds(o)){let c=o.left;while(c!==null&&this.adds(c))c=c.left;if(this.deletes(o))if(c!==null&&this.deletes(c))s="delete",i=_r(c.content.getContent());else return;else if(c!==null&&this.deletes(c))s="update",i=_r(c.content.getContent());else s="add",i=void 0}else if(this.deletes(o))s="delete",i=_r(o.content.getContent());else return;e.set(n,{action:s,oldValue:i})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw X(ji);let t=this.target,r=_e(),n=_e(),o=[];if(e={added:r,deleted:n,delta:o,keys:this.keys},this.transaction.changed.get(t).has(null)){let i=null,c=()=>{if(i)o.push(i)};for(let a=t._start;a!==null;a=a.right)if(a.deleted){if(this.deletes(a)&&!this.adds(a)){if(i===null||i.delete===void 0)c(),i={delete:0};i.delete+=a.length,n.add(a)}}else if(this.adds(a)){if(i===null||i.insert===void 0)c(),i={insert:[]};i.insert=i.insert.concat(a.content.getContent()),r.add(a)}else{if(i===null||i.retain===void 0)c(),i={retain:0};i.retain+=a.length}if(i!==null&&i.retain===void 0)c()}this._changes=e}return e}}var $d=(e,t)=>{let r=[];while(t._item!==null&&t!==e){if(t._item.parentSub!==null)r.unshift(t._item.parentSub);else{let n=0,o=t._item.parent._start;while(o!==t._item&&o!==null){if(!o.deleted&&o.countable)n+=o.length;o=o.right}r.unshift(n)}t=t._item.parent}return r},F=()=>{Ii("Invalid access: Add Yjs type to a document before reading data.")},ic=80,Lo=0;class cc{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Lo++}}var Sd=(e)=>{e.timestamp=Lo++},ac=(e,t,r)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=r,e.timestamp=Lo++},Ed=(e,t,r)=>{if(e.length>=ic){let n=e.reduce((o,s)=>o.timestamp<s.timestamp?o:s);return ac(n,t,r),n}else{let n=new cc(t,r);return e.push(n),n}},ln=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let r=e._searchMarker.length===0?null:e._searchMarker.reduce((s,i)=>Ne(t-s.index)<Ne(t-i.index)?s:i),n=e._start,o=0;if(r!==null)n=r.p,o=r.index,Sd(r);while(n.right!==null&&o<t){if(!n.deleted&&n.countable){if(t<o+n.length)break;o+=n.length}n=n.right}while(n.left!==null&&o>t)if(n=n.left,!n.deleted&&n.countable)o-=n.length;while(n.left!==null&&n.left.id.client===n.id.client&&n.left.id.clock+n.left.length===n.id.clock)if(n=n.left,!n.deleted&&n.countable)o-=n.length;if(r!==null&&Ne(r.index-o)<n.parent.length/ic)return ac(r,n,o),r;else return Ed(e._searchMarker,n,o)},Gt=(e,t,r)=>{for(let n=e.length-1;n>=0;n--){let o=e[n];if(r>0){let s=o.p;s.marker=!1;while(s&&(s.deleted||!s.countable))if(s=s.left,s&&!s.deleted&&s.countable)o.index-=s.length;if(s===null||s.marker===!0){e.splice(n,1);continue}o.p=s,s.marker=!0}if(t<o.index||r>0&&t===o.index)o.index=we(t,o.index+r)}};var pn=(e,t,r)=>{let n=e,o=t.changedParentTypes;while(!0){if(ue(o,e,()=>[]).push(r),e._item===null)break;e=e._item.parent}Qi(n._eH,r,t)};class D{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Pi(),this._dEH=Pi(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Q()}clone(){throw Q()}_write(e){}get _first(){let e=this._start;while(e!==null&&e.deleted)e=e.right;return e}_callObserver(e,t){if(!e.local&&this._searchMarker)this._searchMarker.length=0}observe(e){Ci(this._eH,e)}observeDeep(e){Ci(this._dEH,e)}unobserve(e){Ni(this._eH,e)}unobserveDeep(e){Ni(this._dEH,e)}toJSON(){}}var uc=(e,t,r)=>{if(e.doc??F(),t<0)t=e._length+t;if(r<0)r=e._length+r;let n=r-t,o=[],s=e._start;while(s!==null&&n>0){if(s.countable&&!s.deleted){let i=s.content.getContent();if(i.length<=t)t-=i.length;else{for(let c=t;c<i.length&&n>0;c++)o.push(i[c]),n--;t=0}}s=s.right}return o},lc=(e)=>{e.doc??F();let t=[],r=e._start;while(r!==null){if(r.countable&&!r.deleted){let n=r.content.getContent();for(let o=0;o<n.length;o++)t.push(n[o])}r=r.right}return t};var Wt=(e,t)=>{let r=0,n=e._start;e.doc??F();while(n!==null){if(n.countable&&!n.deleted){let o=n.content.getContent();for(let s=0;s<o.length;s++)t(o[s],r++,e)}n=n.right}},pc=(e,t)=>{let r=[];return Wt(e,(n,o)=>{r.push(t(n,o,e))}),r},Id=(e)=>{let t=e._start,r=null,n=0;return{[Symbol.iterator](){return this},next:()=>{if(r===null){while(t!==null&&t.deleted)t=t.right;if(t===null)return{done:!0,value:void 0};r=t.content.getContent(),n=0,t=t.right}let o=r[n++];if(r.length<=n)r=null;return{done:!1,value:o}}}},hc=(e,t)=>{e.doc??F();let r=ln(e,t),n=e._start;if(r!==null)n=r.p,t-=r.index;for(;n!==null;n=n.right)if(!n.deleted&&n.countable){if(t<n.length)return n.content.getContent()[t];t-=n.length}},Xr=(e,t,r,n)=>{let o=r,s=e.doc,i=s.clientID,c=s.store,a=r===null?t._start:r.right,l=[],u=()=>{if(l.length>0)o=new P(_(i,U(c,i)),o,o&&o.lastId,a,a&&a.id,t,null,new Je(l)),o.integrate(e,0),l=[]};n.forEach((h)=>{if(h===null)l.push(h);else switch(h.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(h);break;default:switch(u(),h.constructor){case Uint8Array:case ArrayBuffer:o=new P(_(i,U(c,i)),o,o&&o.lastId,a,a&&a.id,t,null,new Xt(new Uint8Array(h))),o.integrate(e,0);break;case ge:o=new P(_(i,U(c,i)),o,o&&o.lastId,a,a&&a.id,t,null,new Qt(h)),o.integrate(e,0);break;default:if(h instanceof D)o=new P(_(i,U(c,i)),o,o&&o.lastId,a,a&&a.id,t,null,new ke(h)),o.integrate(e,0);else throw Error("Unexpected content type in insert operation")}}}),u()},dc=()=>X("Length exceeded!"),fc=(e,t,r,n)=>{if(r>t._length)throw dc();if(r===0){if(t._searchMarker)Gt(t._searchMarker,r,n.length);return Xr(e,t,null,n)}let o=r,s=ln(t,r),i=t._start;if(s!==null){if(i=s.p,r-=s.index,r===0)i=i.prev,r+=i&&i.countable&&!i.deleted?i.length:0}for(;i!==null;i=i.right)if(!i.deleted&&i.countable){if(r<=i.length){if(r<i.length)Ae(e,_(i.id.client,i.id.clock+r));break}r-=i.length}if(t._searchMarker)Gt(t._searchMarker,o,n.length);return Xr(e,t,i,n)},Td=(e,t,r)=>{let o=(t._searchMarker||[]).reduce((s,i)=>i.index>s.index?i:s,{index:0,p:t._start}).p;if(o)while(o.right)o=o.right;return Xr(e,t,o,r)},mc=(e,t,r,n)=>{if(n===0)return;let o=r,s=n,i=ln(t,r),c=t._start;if(i!==null)c=i.p,r-=i.index;for(;c!==null&&r>0;c=c.right)if(!c.deleted&&c.countable){if(r<c.length)Ae(e,_(c.id.client,c.id.clock+r));r-=c.length}while(n>0&&c!==null){if(!c.deleted){if(n<c.length)Ae(e,_(c.id.client,c.id.clock+n));c.delete(e),n-=c.length}c=c.right}if(n>0)throw dc();if(t._searchMarker)Gt(t._searchMarker,o,-s+n)},Qr=(e,t,r)=>{let n=t._map.get(r);if(n!==void 0)n.delete(e)},Bo=(e,t,r,n)=>{let o=t._map.get(r)||null,s=e.doc,i=s.clientID,c;if(n==null)c=new Je([n]);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new Je([n]);break;case Uint8Array:c=new Xt(n);break;case ge:c=new Qt(n);break;default:if(n instanceof D)c=new ke(n);else throw Error("Unexpected content type")}new P(_(i,U(s.store,i)),o,o&&o.lastId,null,null,t,r,c).integrate(e,0)},Mo=(e,t)=>{e.doc??F();let r=e._map.get(t);return r!==void 0&&!r.deleted?r.content.getContent()[r.length-1]:void 0},gc=(e)=>{let t={};return e.doc??F(),e._map.forEach((r,n)=>{if(!r.deleted)t[n]=r.content.getContent()[r.length-1]}),t},yc=(e,t)=>{e.doc??F();let r=e._map.get(t);return r!==void 0&&!r.deleted};var Ad=(e,t)=>{let r={};return e._map.forEach((n,o)=>{let s=n;while(s!==null&&(!t.sv.has(s.id.client)||s.id.clock>=(t.sv.get(s.id.client)||0)))s=s.left;if(s!==null&&pt(s,t))r[o]=s.content.getContent()[s.length-1]}),r},qr=(e)=>(e.doc??F(),Oi(e._map.entries(),(t)=>!t[1].deleted));class xc extends Yt{}class re extends D{constructor(){super();this._prelimContent=[],this._searchMarker=[]}static from(e){let t=new re;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new re}clone(){let e=new re;return e.insert(0,this.toArray().map((t)=>t instanceof D?t.clone():t)),e}get length(){return this.doc??F(),this._length}_callObserver(e,t){super._callObserver(e,t),pn(this,e,new xc(this,e))}insert(e,t){if(this.doc!==null)v(this.doc,(r)=>{fc(r,this,e,t)});else this._prelimContent.splice(e,0,...t)}push(e){if(this.doc!==null)v(this.doc,(t)=>{Td(t,this,e)});else this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){if(this.doc!==null)v(this.doc,(r)=>{mc(r,this,e,t)});else this._prelimContent.splice(e,t)}get(e){return hc(this,e)}toArray(){return lc(this)}slice(e=0,t=this.length){return uc(this,e,t)}toJSON(){return this.map((e)=>e instanceof D?e.toJSON():e)}map(e){return pc(this,e)}forEach(e){Wt(this,e)}[Symbol.iterator](){return Id(this)}_write(e){e.writeTypeRef(Xd)}}var Od=(e)=>new re;class _c extends Yt{constructor(e,t,r){super(e,t);this.keysChanged=r}}class G extends D{constructor(e){super();if(this._prelimContent=null,e===void 0)this._prelimContent=new Map;else this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((r,n)=>{this.set(n,r)}),this._prelimContent=null}_copy(){return new G}clone(){let e=new G;return this.forEach((t,r)=>{e.set(r,t instanceof D?t.clone():t)}),e}_callObserver(e,t){pn(this,e,new _c(this,e,t))}toJSON(){this.doc??F();let e={};return this._map.forEach((t,r)=>{if(!t.deleted){let n=t.content.getContent()[t.length-1];e[r]=n instanceof D?n.toJSON():n}}),e}get size(){return[...qr(this)].length}keys(){return Fr(qr(this),(e)=>e[0])}values(){return Fr(qr(this),(e)=>e[1].content.getContent()[e[1].length-1])}entries(){return Fr(qr(this),(e)=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??F(),this._map.forEach((t,r)=>{if(!t.deleted)e(t.content.getContent()[t.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){if(this.doc!==null)v(this.doc,(t)=>{Qr(t,this,e)});else this._prelimContent.delete(e)}set(e,t){if(this.doc!==null)v(this.doc,(r)=>{Bo(r,this,e,t)});else this._prelimContent.set(e,t);return t}get(e){return Mo(this,e)}has(e){return yc(this,e)}clear(){if(this.doc!==null)v(this.doc,(e)=>{this.forEach(function(t,r,n){Qr(e,n,r)})});else this._prelimContent.clear()}_write(e){e.writeTypeRef(Qd)}}var Zd=(e)=>new G,Ie=(e,t)=>e===t||typeof e==="object"&&typeof t==="object"&&e&&t&&oo(e,t);class en{constructor(e,t,r,n){this.left=e,this.right=t,this.index=r,this.currentAttributes=n}forward(){if(this.right===null)H();switch(this.right.content.constructor){case C:if(!this.right.deleted)yt(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 Li=(e,t,r)=>{while(t.right!==null&&r>0){switch(t.right.content.constructor){case C:if(!t.right.deleted)yt(t.currentAttributes,t.right.content);break;default:if(!t.right.deleted){if(r<t.right.length)Ae(e,_(t.right.id.client,t.right.id.clock+r));t.index+=t.right.length,r-=t.right.length}break}t.left=t.right,t.right=t.right.right}return t},Gr=(e,t,r,n)=>{let o=new Map,s=n?ln(t,r):null;if(s){let i=new en(s.p.left,s.p,s.index,o);return Li(e,i,r-s.index)}else{let i=new en(null,t._start,0,o);return Li(e,i,r)}},wc=(e,t,r,n)=>{while(r.right!==null&&(r.right.deleted===!0||r.right.content.constructor===C&&Ie(n.get(r.right.content.key),r.right.content.value))){if(!r.right.deleted)n.delete(r.right.content.key);r.forward()}let o=e.doc,s=o.clientID;n.forEach((i,c)=>{let{left:a,right:l}=r,u=new P(_(s,U(o.store,s)),a,a&&a.lastId,l,l&&l.id,t,null,new C(c,i));u.integrate(e,0),r.right=u,r.forward()})},yt=(e,t)=>{let{key:r,value:n}=t;if(n===null)e.delete(r);else e.set(r,n)},bc=(e,t)=>{while(!0){if(e.right===null)break;else if(e.right.deleted||e.right.content.constructor===C&&Ie(t[e.right.content.key]??null,e.right.content.value));else break;e.forward()}},kc=(e,t,r,n)=>{let o=e.doc,s=o.clientID,i=new Map;for(let c in n){let a=n[c],l=r.currentAttributes.get(c)??null;if(!Ie(l,a)){i.set(c,l);let{left:u,right:h}=r;r.right=new P(_(s,U(o.store,s)),u,u&&u.lastId,h,h&&h.id,t,null,new C(c,a)),r.right.integrate(e,0),r.forward()}}return i},Io=(e,t,r,n,o)=>{r.currentAttributes.forEach((p,f)=>{if(o[f]===void 0)o[f]=null});let s=e.doc,i=s.clientID;bc(r,o);let c=kc(e,t,r,o),a=n.constructor===String?new me(n):n instanceof D?new ke(n):new qe(n),{left:l,right:u,index:h}=r;if(t._searchMarker)Gt(t._searchMarker,r.index,a.getLength());u=new P(_(i,U(s.store,i)),l,l&&l.lastId,u,u&&u.id,t,null,a),u.integrate(e,0),r.right=u,r.index=h,r.forward(),wc(e,t,r,c)},Bi=(e,t,r,n,o)=>{let s=e.doc,i=s.clientID;bc(r,o);let c=kc(e,t,r,o);e:while(r.right!==null&&(n>0||c.size>0&&(r.right.deleted||r.right.content.constructor===C))){if(!r.right.deleted)switch(r.right.content.constructor){case C:{let{key:a,value:l}=r.right.content,u=o[a];if(u!==void 0){if(Ie(u,l))c.delete(a);else{if(n===0)break e;c.set(a,l)}r.right.delete(e)}else r.currentAttributes.set(a,l);break}default:if(n<r.right.length)Ae(e,_(r.right.id.client,r.right.id.clock+n));n-=r.right.length;break}r.forward()}if(n>0){let a="";for(;n>0;n--)a+=`
4
+ `;r.right=new P(_(i,U(s.store,i)),r.left,r.left&&r.left.lastId,r.right,r.right&&r.right.id,t,null,new me(a)),r.right.integrate(e,0),r.forward()}wc(e,t,r,c)},vc=(e,t,r,n,o)=>{let s=t,i=J();while(s&&(!s.countable||s.deleted)){if(!s.deleted&&s.content.constructor===C){let l=s.content;i.set(l.key,l)}s=s.right}let c=0,a=!1;while(t!==s){if(r===t)a=!0;if(!t.deleted){let l=t.content;switch(l.constructor){case C:{let{key:u,value:h}=l,p=n.get(u)??null;if(i.get(u)!==l||p===h){if(t.delete(e),c++,!a&&(o.get(u)??null)===h&&p!==h)if(p===null)o.delete(u);else o.set(u,p)}if(!a&&!t.deleted)yt(o,l);break}}}t=t.right}return c},Pd=(e,t)=>{while(t&&t.right&&(t.right.deleted||!t.right.countable))t=t.right;let r=new Set;while(t&&(t.deleted||!t.countable)){if(!t.deleted&&t.content.constructor===C){let n=t.content.key;if(r.has(n))t.delete(e);else r.add(n)}t=t.left}},Cd=(e)=>{let t=0;return v(e.doc,(r)=>{let{_start:n,_start:o}=e,s=J(),i=xr(s);while(o){if(o.deleted===!1)switch(o.content.constructor){case C:yt(i,o.content);break;default:t+=vc(r,n,o,s,i),s=xr(i),n=o;break}o=o.right}}),t},Nd=(e)=>{let t=new Set,r=e.doc;for(let[n,o]of e.afterState.entries()){let s=e.beforeState.get(n)||0;if(o===s)continue;rc(e,r.store.clients.get(n),s,o,(i)=>{if(!i.deleted&&i.content.constructor===C&&i.constructor!==ee)t.add(i.parent)})}v(r,(n)=>{Vi(e,e.deleteSet,(o)=>{if(o instanceof ee||!o.parent._hasFormatting||t.has(o.parent))return;let s=o.parent;if(o.content.constructor===C)t.add(s);else Pd(n,o)});for(let o of t)Cd(o)})},Mi=(e,t,r)=>{let n=r,o=xr(t.currentAttributes),s=t.right;while(r>0&&t.right!==null){if(t.right.deleted===!1)switch(t.right.content.constructor){case ke:case qe:case me:if(r<t.right.length)Ae(e,_(t.right.id.client,t.right.id.clock+r));r-=t.right.length,t.right.delete(e);break}t.forward()}if(s)vc(e,s,t.right,o,t.currentAttributes);let i=(t.left||t.right).parent;if(i._searchMarker)Gt(i._searchMarker,t.index,-n+r);return t};class zc extends Yt{constructor(e,t,r){super(e,t);this.childListChanged=!1,this.keysChanged=new Set,r.forEach((n)=>{if(n===null)this.childListChanged=!0;else this.keysChanged.add(n)})}get changes(){if(this._changes===null){let e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];v(e,(r)=>{let n=new Map,o=new Map,s=this.target._start,i=null,c={},a="",l=0,u=0,h=()=>{if(i!==null){let p=null;switch(i){case"delete":if(u>0)p={delete:u};u=0;break;case"insert":if(typeof a==="object"||a.length>0){if(p={insert:a},n.size>0)p.attributes={},n.forEach((f,m)=>{if(f!==null)p.attributes[m]=f})}a="";break;case"retain":if(l>0){if(p={retain:l},!Qs(c))p.attributes=Ys({},c)}l=0;break}if(p)t.push(p);i=null}};while(s!==null){switch(s.content.constructor){case ke:case qe:if(this.adds(s)){if(!this.deletes(s))h(),i="insert",a=s.content.getContent()[0],h()}else if(this.deletes(s)){if(i!=="delete")h(),i="delete";u+=1}else if(!s.deleted){if(i!=="retain")h(),i="retain";l+=1}break;case me:if(this.adds(s)){if(!this.deletes(s)){if(i!=="insert")h(),i="insert";a+=s.content.str}}else if(this.deletes(s)){if(i!=="delete")h(),i="delete";u+=s.length}else if(!s.deleted){if(i!=="retain")h(),i="retain";l+=s.length}break;case C:{let{key:p,value:f}=s.content;if(this.adds(s)){if(!this.deletes(s)){let m=n.get(p)??null;if(!Ie(m,f)){if(i==="retain")h();if(Ie(f,o.get(p)??null))delete c[p];else c[p]=f}else if(f!==null)s.delete(r)}}else if(this.deletes(s)){o.set(p,f);let m=n.get(p)??null;if(!Ie(m,f)){if(i==="retain")h();c[p]=m}}else if(!s.deleted){o.set(p,f);let m=c[p];if(m!==void 0){if(!Ie(m,f)){if(i==="retain")h();if(f===null)delete c[p];else c[p]=f}else if(m!==null)s.delete(r)}}if(!s.deleted){if(i==="insert")h();yt(n,s.content)}break}}s=s.right}h();while(t.length>0){let p=t[t.length-1];if(p.retain!==void 0&&p.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}}class ie extends D{constructor(e){super();this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??F(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach((r)=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new ie}clone(){let e=new ie;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);let r=new zc(this,e,t);if(pn(this,e,r),!e.local&&this._hasFormatting)e._needFormattingCleanup=!0}toString(){this.doc??F();let e="",t=this._start;while(t!==null){if(!t.deleted&&t.countable&&t.content.constructor===me)e+=t.content.str;t=t.right}return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){if(this.doc!==null)v(this.doc,(r)=>{let n=new en(null,this._start,0,new Map);for(let o=0;o<e.length;o++){let s=e[o];if(s.insert!==void 0){let i=!t&&typeof s.insert==="string"&&o===e.length-1&&n.right===null&&s.insert.slice(-1)===`
5
+ `?s.insert.slice(0,-1):s.insert;if(typeof i!=="string"||i.length>0)Io(r,this,n,i,s.attributes||{})}else if(s.retain!==void 0)Bi(r,this,n,s.retain,s.attributes||{});else if(s.delete!==void 0)Mi(r,n,s.delete)}});else this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,r){this.doc??F();let n=[],o=new Map,s=this.doc,i="",c=this._start;function a(){if(i.length>0){let u={},h=!1;o.forEach((f,m)=>{h=!0,u[m]=f});let p={insert:i};if(h)p.attributes=u;n.push(p),i=""}}let l=()=>{while(c!==null){if(pt(c,e)||t!==void 0&&pt(c,t))switch(c.content.constructor){case me:{let u=o.get("ychange");if(e!==void 0&&!pt(c,e)){if(u===void 0||u.user!==c.id.client||u.type!=="removed")a(),o.set("ychange",r?r("removed",c.id):{type:"removed"})}else if(t!==void 0&&!pt(c,t)){if(u===void 0||u.user!==c.id.client||u.type!=="added")a(),o.set("ychange",r?r("added",c.id):{type:"added"})}else if(u!==void 0)a(),o.delete("ychange");i+=c.content.str;break}case ke:case qe:{a();let u={insert:c.content.getContent()[0]};if(o.size>0){let h={};u.attributes=h,o.forEach((p,f)=>{h[f]=p})}n.push(u);break}case C:if(pt(c,e))a(),yt(o,c.content);break}c=c.right}a()};if(e||t)v(s,(u)=>{if(e)To(u,e);if(t)To(u,t);l()},"cleanup");else l();return n}insert(e,t,r){if(t.length<=0)return;let n=this.doc;if(n!==null)v(n,(o)=>{let s=Gr(o,this,e,!r);if(!r)r={},s.currentAttributes.forEach((i,c)=>{r[c]=i});Io(o,this,s,t,r)});else this._pending.push(()=>this.insert(e,t,r))}insertEmbed(e,t,r){let n=this.doc;if(n!==null)v(n,(o)=>{let s=Gr(o,this,e,!r);Io(o,this,s,t,r||{})});else this._pending.push(()=>this.insertEmbed(e,t,r||{}))}delete(e,t){if(t===0)return;let r=this.doc;if(r!==null)v(r,(n)=>{Mi(n,Gr(n,this,e,!0),t)});else this._pending.push(()=>this.delete(e,t))}format(e,t,r){if(t===0)return;let n=this.doc;if(n!==null)v(n,(o)=>{let s=Gr(o,this,e,!1);if(s.right===null)return;Bi(o,this,s,t,r)});else this._pending.push(()=>this.format(e,t,r))}removeAttribute(e){if(this.doc!==null)v(this.doc,(t)=>{Qr(t,this,e)});else this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){if(this.doc!==null)v(this.doc,(r)=>{Bo(r,this,e,t)});else this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return Mo(this,e)}getAttributes(){return gc(this)}_write(e){e.writeTypeRef(ef)}}var Ud=(e)=>new ie;class Kr{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??F()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===ht||t.constructor===Fe)&&t._start!==null)e=t._start;else while(e!==null){let r=e.next;if(r!==null){e=r;break}else if(e.parent===this._root)e=null;else e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));if(this._firstCall=!1,e===null)return{value:void 0,done:!0};return this._currentNode=e,{value:e.content.type,done:!1}}}class Fe extends D{constructor(){super();this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Fe}clone(){let e=new Fe;return e.insert(0,this.toArray().map((t)=>t instanceof D?t.clone():t)),e}get length(){return this.doc??F(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Kr(this,e)}querySelector(e){e=e.toUpperCase();let r=new Kr(this,(n)=>n.nodeName&&n.nodeName.toUpperCase()===e).next();if(r.done)return null;else return r.value}querySelectorAll(e){return e=e.toUpperCase(),le(new Kr(this,(t)=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){pn(this,e,new $c(this,t,e))}toString(){return pc(this,(e)=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},r){let n=e.createDocumentFragment();if(r!==void 0)r._createAssociation(n,this);return Wt(this,(o)=>{n.insertBefore(o.toDOM(e,t,r),null)}),n}insert(e,t){if(this.doc!==null)v(this.doc,(r)=>{fc(r,this,e,t)});else this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)v(this.doc,(r)=>{let n=e&&e instanceof D?e._item:e;Xr(r,this,n,t)});else{let r=this._prelimContent,n=e===null?0:r.findIndex((o)=>o===e)+1;if(n===0&&e!==null)throw X("Reference item not found");r.splice(n,0,...t)}}delete(e,t=1){if(this.doc!==null)v(this.doc,(r)=>{mc(r,this,e,t)});else this._prelimContent.splice(e,t)}toArray(){return lc(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return hc(this,e)}slice(e=0,t=this.length){return uc(this,e,t)}forEach(e){Wt(this,e)}_write(e){e.writeTypeRef(rf)}}var Dd=(e)=>new Fe;class ht extends Fe{constructor(e="UNDEFINED"){super();this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((r,n)=>{this.setAttribute(n,r)}),this._prelimAttrs=null}_copy(){return new ht(this.nodeName)}clone(){let e=new ht(this.nodeName),t=this.getAttributes();return Xs(t,(r,n)=>{e.setAttribute(n,r)}),e.insert(0,this.toArray().map((r)=>r instanceof D?r.clone():r)),e}toString(){let e=this.getAttributes(),t=[],r=[];for(let i in e)r.push(i);r.sort();let n=r.length;for(let i=0;i<n;i++){let c=r[i];t.push(c+'="'+e[c]+'"')}let o=this.nodeName.toLocaleLowerCase(),s=t.length>0?" "+t.join(" "):"";return`<${o}${s}>${super.toString()}</${o}>`}removeAttribute(e){if(this.doc!==null)v(this.doc,(t)=>{Qr(t,this,e)});else this._prelimAttrs.delete(e)}setAttribute(e,t){if(this.doc!==null)v(this.doc,(r)=>{Bo(r,this,e,t)});else this._prelimAttrs.set(e,t)}getAttribute(e){return Mo(this,e)}hasAttribute(e){return yc(this,e)}getAttributes(e){return e?Ad(this,e):gc(this)}toDOM(e=document,t={},r){let n=e.createElement(this.nodeName),o=this.getAttributes();for(let s in o){let i=o[s];if(typeof i==="string")n.setAttribute(s,i)}if(Wt(this,(s)=>{n.appendChild(s.toDOM(e,t,r))}),r!==void 0)r._createAssociation(n,this);return n}_write(e){e.writeTypeRef(tf),e.writeKey(this.nodeName)}}var Rd=(e)=>new ht(e.readKey());class $c extends Yt{constructor(e,t,r){super(e,r);this.childListChanged=!1,this.attributesChanged=new Set,t.forEach((n)=>{if(n===null)this.childListChanged=!0;else this.attributesChanged.add(n)})}}class tn extends G{constructor(e){super();this.hookName=e}_copy(){return new tn(this.hookName)}clone(){let e=new tn(this.hookName);return this.forEach((t,r)=>{e.set(r,t)}),e}toDOM(e=document,t={},r){let n=t[this.hookName],o;if(n!==void 0)o=n.createDom(this);else o=document.createElement(this.hookName);if(o.setAttribute("data-yjs-hook",this.hookName),r!==void 0)r._createAssociation(o,this);return o}_write(e){e.writeTypeRef(nf),e.writeKey(this.hookName)}}var jd=(e)=>new tn(e.readKey());class rn extends ie{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new rn}clone(){let e=new rn;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,r){let n=e.createTextNode(this.toString());if(r!==void 0)r._createAssociation(n,this);return n}toString(){return this.toDelta().map((e)=>{let t=[];for(let n in e.attributes){let o=[];for(let s in e.attributes[n])o.push({key:s,value:e.attributes[n][s]});o.sort((s,i)=>s.key<i.key?-1:1),t.push({nodeName:n,attrs:o})}t.sort((n,o)=>n.nodeName<o.nodeName?-1:1);let r="";for(let n=0;n<t.length;n++){let o=t[n];r+=`<${o.nodeName}`;for(let s=0;s<o.attrs.length;s++){let i=o.attrs[s];r+=` ${i.key}="${i.value}"`}r+=">"}r+=e.insert;for(let n=t.length-1;n>=0;n--)r+=`</${t[n].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(of)}}var Ld=(e)=>new rn;class hn{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Q()}mergeWith(e){return!1}write(e,t,r){throw Q()}integrate(e,t){throw Q()}}var Bd=0;class ee extends hn{get deleted(){return!0}delete(){}mergeWith(e){if(this.constructor!==e.constructor)return!1;return this.length+=e.length,!0}integrate(e,t){if(t>0)this.id.clock+=t,this.length-=t;tc(e.doc.store,this)}write(e,t){e.writeInfo(Bd),e.writeLen(this.length-t)}getMissing(e,t){return null}}class Xt{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Xt(this.content)}splice(e){throw Q()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}var Md=(e)=>new Xt(e.readBuf());class Kt{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Kt(this.len)}splice(e){let t=new Kt(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){Hr(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}}var Vd=(e)=>new Kt(e.readLen()),Sc=(e,t)=>new ge({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});class Qt{constructor(e){if(e._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=e;let t={};if(this.opts=t,!e.gc)t.gc=!1;if(e.autoLoad)t.autoLoad=!0;if(e.meta!==null)t.meta=e.meta}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Qt(Sc(this.doc.guid,this.opts))}splice(e){throw Q()}mergeWith(e){return!1}integrate(e,t){if(this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad)e.subdocsLoaded.add(this.doc)}delete(e){if(e.subdocsAdded.has(this.doc))e.subdocsAdded.delete(this.doc);else e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}var Fd=(e)=>new Qt(Sc(e.readString(),e.readAny()));class qe{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new qe(this.embed)}splice(e){throw Q()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}var Jd=(e)=>new qe(e.readJSON());class C{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new C(this.key,this.value)}splice(e){throw Q()}mergeWith(e){return!1}integrate(e,t){let r=t.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}var qd=(e)=>new C(e.readKey(),e.readJSON());class nn{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new nn(this.arr)}splice(e){let t=new nn(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let r=this.arr.length;e.writeLen(r-t);for(let n=t;n<r;n++){let o=this.arr[n];e.writeString(o===void 0?"undefined":JSON.stringify(o))}}getRef(){return 2}}var Gd=(e)=>{let t=e.readLen(),r=[];for(let n=0;n<t;n++){let o=e.readString();if(o==="undefined")r.push(void 0);else r.push(JSON.parse(o))}return new nn(r)},Wd=Bt("node_env")==="development";class Je{constructor(e){this.arr=e,Wd&&so(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Je(this.arr)}splice(e){let t=new Je(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let r=this.arr.length;e.writeLen(r-t);for(let n=t;n<r;n++){let o=this.arr[n];e.writeAny(o)}}getRef(){return 8}}var Kd=(e)=>{let t=e.readLen(),r=[];for(let n=0;n<t;n++)r.push(e.readAny());return new Je(r)};class me{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new me(this.str)}splice(e){let t=new me(this.str.slice(e));this.str=this.str.slice(0,e);let r=this.str.charCodeAt(e-1);if(r>=55296&&r<=56319)this.str=this.str.slice(0,e-1)+"�",t.str="�"+t.str.slice(1);return t}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}}var Hd=(e)=>new me(e.readString()),Yd=[Od,Zd,Ud,Rd,Dd,jd,Ld],Xd=0,Qd=1,ef=2,tf=3,rf=4,nf=5,of=6;class ke{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new ke(this.type._copy())}splice(e){throw Q()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;while(t!==null){if(!t.deleted)t.delete(e);else if(t.id.clock<(e.beforeState.get(t.id.client)||0))e._mergeStructs.push(t);t=t.right}this.type._map.forEach((r)=>{if(!r.deleted)r.delete(e);else if(r.id.clock<(e.beforeState.get(r.id.client)||0))e._mergeStructs.push(r)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;while(t!==null)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach((r)=>{while(r!==null)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}}var sf=(e)=>new ke(Yd[e.readTypeRef()](e));var on=(e,t,r)=>{let{client:n,clock:o}=t.id,s=new P(_(n,o+r),t,_(n,o+r-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(r));if(t.deleted)s.markDeleted();if(t.keep)s.keep=!0;if(t.redone!==null)s.redone=_(t.redone.client,t.redone.clock+r);if(t.right=s,s.right!==null)s.right.left=s;if(e._mergeStructs.push(s),s.parentSub!==null&&s.right===null)s.parent._map.set(s.parentSub,s);return t.length=r,s};class P extends hn{constructor(e,t,r,n,o,s,i,c){super(e,c.getLength());this.origin=r,this.left=t,this.right=n,this.rightOrigin=o,this.parent=s,this.parentSub=i,this.redone=null,this.content=c,this.info=this.content.isCountable()?Mn:0}set marker(e){if((this.info&$r)>0!==e)this.info^=$r}get marker(){return(this.info&$r)>0}get keep(){return(this.info&Bn)>0}set keep(e){if(this.keep!==e)this.info^=Bn}get countable(){return(this.info&Mn)>0}get deleted(){return(this.info&zr)>0}set deleted(e){if(this.deleted!==e)this.info^=zr}markDeleted(){this.info|=zr}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=U(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=U(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Me&&this.id.client!==this.parent.client&&this.parent.clock>=U(t,this.parent.client))return this.parent.client;if(this.origin)this.left=Ui(e,t,this.origin),this.origin=this.left.lastId;if(this.rightOrigin)this.right=Ae(e,this.rightOrigin),this.rightOrigin=this.right.id;if(this.left&&this.left.constructor===ee||this.right&&this.right.constructor===ee)this.parent=null;else if(!this.parent){if(this.left&&this.left.constructor===P)this.parent=this.left.parent,this.parentSub=this.left.parentSub;else if(this.right&&this.right.constructor===P)this.parent=this.right.parent,this.parentSub=this.right.parentSub}else if(this.parent.constructor===Me){let r=Eo(t,this.parent);if(r.constructor===ee)this.parent=null;else this.parent=r.content.type}return null}integrate(e,t){if(t>0)this.id.clock+=t,this.left=Ui(e,e.doc.store,_(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t;if(this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,n;if(r!==null)n=r.right;else if(this.parentSub!==null){n=this.parent._map.get(this.parentSub)||null;while(n!==null&&n.left!==null)n=n.left}else n=this.parent._start;let o=new Set,s=new Set;while(n!==null&&n!==this.right){if(s.add(n),o.add(n),Jr(this.origin,n.origin)){if(n.id.client<this.id.client)r=n,o.clear();else if(Jr(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&s.has(Eo(e.doc.store,n.origin))){if(!o.has(Eo(e.doc.store,n.origin)))r=n,o.clear()}else break;n=n.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(e)}if(this.parentSub===null&&this.countable&&!this.deleted)this.parent._length+=this.length;if(tc(e.doc.store,this),this.content.integrate(e,this),Ri(e,this.parent,this.parentSub),this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)this.delete(e)}else new ee(this.id,this.length).integrate(e,0)}get next(){let e=this.right;while(e!==null&&e.deleted)e=e.right;return e}get prev(){let e=this.left;while(e!==null&&e.deleted)e=e.left;return e}get lastId(){return this.length===1?this.id:_(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Jr(e.origin,this.lastId)&&this.right===e&&Jr(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){let t=this.parent._searchMarker;if(t)t.forEach((r)=>{if(r.p===e){if(r.p=this,!this.deleted&&this.countable)r.index-=this.length}});if(e.keep)this.keep=!0;if(this.right=e.right,this.right!==null)this.right.left=this;return this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){let t=this.parent;if(this.countable&&this.parentSub===null)t._length-=this.length;this.markDeleted(),Hr(e.deleteSet,this.id.client,this.id.clock,this.length),Ri(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw H();if(this.content.gc(e),t)gd(e,this,new ee(this.id,this.length));else this.content=new Kt(this.length)}write(e,t){let r=t>0?_(this.id.client,this.id.clock+t-1):this.origin,n=this.rightOrigin,o=this.parentSub,s=this.content.getRef()&Tt|(r===null?0:M)|(n===null?0:oe)|(o===null?0:He);if(e.writeInfo(s),r!==null)e.writeLeftID(r);if(n!==null)e.writeRightID(n);if(r===null&&n===null){let i=this.parent;if(i._item!==void 0){let c=i._item;if(c===null){let a=dd(i);e.writeParentInfo(!0),e.writeString(a)}else e.writeParentInfo(!1),e.writeLeftID(c.id)}else if(i.constructor===String)e.writeParentInfo(!0),e.writeString(i);else if(i.constructor===Me)e.writeParentInfo(!1),e.writeLeftID(i);else H();if(o!==null)e.writeString(o)}this.content.write(e,t)}}var Ec=(e,t)=>cf[t&Tt](e),cf=[()=>{H()},Vd,Gd,Md,Hd,Jd,qd,sf,Kd,Fd,()=>{H()}],af=10;class te extends hn{get deleted(){return!0}delete(){}mergeWith(e){if(this.constructor!==e.constructor)return!1;return this.length+=e.length,!0}integrate(e,t){H()}write(e,t){e.writeInfo(af),x(e.restEncoder,this.length-t)}getMissing(e,t){return null}}var Ic=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Tc="__ $YJS$ __";if(Ic[Tc]===!0)console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Ic[Tc]=!0;var Oc;function d(e,t,r){function n(c,a){if(!c._zod)Object.defineProperty(c,"_zod",{value:{def:a,constr:i,traits:new Set},enumerable:!1});if(c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,a);let l=i.prototype,u=Object.keys(l);for(let h=0;h<u.length;h++){let p=u[h];if(!(p in c))c[p]=l[p].bind(c)}}let o=r?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(c){var a;let l=r?.Parent?new s:this;n(l,c),(a=l._zod).deferred??(a.deferred=[]);for(let u of l._zod.deferred)u();return l}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:(c)=>{if(r?.Parent&&c instanceof r.Parent)return!0;return c?._zod?.traits?.has(e)}}),Object.defineProperty(i,"name",{value:e}),i}var Hg=Symbol("zod_brand");class ve extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class er extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name="ZodEncodeError"}}(Oc=globalThis).__zod_globalConfig??(Oc.__zod_globalConfig={});var xt=globalThis.__zod_globalConfig;function ze(e){if(e)Object.assign(xt,e);return xt}var b={};Zp(b,{BIGINT_FORMAT_RANGES:()=>Uc,Class:()=>Lc,NUMBER_FORMAT_RANGES:()=>Ko,aborted:()=>Ze,allowsEval:()=>qo,assert:()=>df,assertEqual:()=>uf,assertIs:()=>pf,assertNever:()=>hf,assertNotEqual:()=>lf,assignProp:()=>Oe,base64ToUint8Array:()=>Rc,base64urlToUint8Array:()=>Zf,cached:()=>wt,captureStackTrace:()=>fn,cleanEnum:()=>Of,cleanRegex:()=>or,clone:()=>ce,cloneDef:()=>gf,createTransparentProxy:()=>kf,defineLazy:()=>w,esc:()=>dn,escapeRegex:()=>Se,explicitlyAborted:()=>Ho,extend:()=>$f,finalizeIssue:()=>ye,floatSafeRemainder:()=>Fo,getElementAtPath:()=>yf,getEnumValues:()=>rr,getLengthableOrigin:()=>ir,getParsedType:()=>bf,getSizableOrigin:()=>Dc,hexToUint8Array:()=>Cf,isObject:()=>Ge,isPlainObject:()=>We,issue:()=>bt,joinValues:()=>ff,jsonStringifyReplacer:()=>_t,merge:()=>Ef,mergeDefs:()=>$e,normalizeParams:()=>g,nullish:()=>nr,numKeys:()=>wf,objectClone:()=>mf,omit:()=>zf,optionalKeys:()=>Wo,parsedType:()=>Af,partial:()=>If,pick:()=>vf,prefixIssues:()=>sr,primitiveTypes:()=>Cc,promiseAllObject:()=>xf,propertyKeyTypes:()=>Go,randomString:()=>_f,required:()=>Tf,safeExtend:()=>Sf,shallowClone:()=>Pc,slugify:()=>Jo,stringifyPrimitive:()=>Nc,uint8ArrayToBase64:()=>jc,uint8ArrayToBase64url:()=>Pf,uint8ArrayToHex:()=>Nf,unwrapMessage:()=>tr});function uf(e){return e}function lf(e){return e}function pf(e){}function hf(e){throw Error("Unexpected value in exhaustive check")}function df(e){}function rr(e){let t=Object.values(e).filter((n)=>typeof n==="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function ff(e,t="|"){return e.map((r)=>Nc(r)).join(t)}function _t(e,t){if(typeof t==="bigint")return t.toString();return t}function wt(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw Error("cached value already set")}}}function nr(e){return e===null||e===void 0}function or(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Fo(e,t){let r=e/t,n=Math.round(r),o=Number.EPSILON*Math.max(Math.abs(r),1);if(Math.abs(r-n)<o)return 0;return r-n}var Zc=Symbol("evaluating");function w(e,t,r){let n=void 0;Object.defineProperty(e,t,{get(){if(n===Zc)return;if(n===void 0)n=Zc,n=r();return n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function mf(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Oe(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function $e(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function gf(e){return $e(e._zod.def)}function yf(e,t){if(!t)return e;return t.reduce((r,n)=>r?.[n],e)}function xf(e){let t=Object.keys(e),r=t.map((n)=>e[n]);return Promise.all(r).then((n)=>{let o={};for(let s=0;s<t.length;s++)o[t[s]]=n[s];return o})}function _f(e=10){let r="";for(let n=0;n<e;n++)r+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return r}function dn(e){return JSON.stringify(e)}function Jo(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var fn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Ge(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var qo=wt(()=>{if(xt.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function We(e){if(Ge(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!=="function")return!0;let r=t.prototype;if(Ge(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)return!1;return!0}function Pc(e){if(We(e))return{...e};if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);return e}function wf(e){let t=0;for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r))t++;return t}var bf=(e)=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(e))return"array";if(e===null)return"null";if(e.then&&typeof e.then==="function"&&e.catch&&typeof e.catch==="function")return"promise";if(typeof Map<"u"&&e instanceof Map)return"map";if(typeof Set<"u"&&e instanceof Set)return"set";if(typeof Date<"u"&&e instanceof Date)return"date";if(typeof File<"u"&&e instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${t}`)}},Go=new Set(["string","number","symbol"]),Cc=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Se(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ce(e,t,r){let n=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)n._zod.parent=e;return n}function g(e){let t=e;if(!t)return{};if(typeof t==="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}if(delete t.message,typeof t.error==="string")return{...t,error:()=>t.error};return t}function kf(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,s){return t??(t=e()),Reflect.set(t,n,o,s)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function Nc(e){if(typeof e==="bigint")return e.toString()+"n";if(typeof e==="string")return`"${e}"`;return`${e}`}function Wo(e){return Object.keys(e).filter((t)=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Ko={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Uc={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function vf(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s=$e(e._zod.def,{get shape(){let i={};for(let c in t){if(!(c in r.shape))throw Error(`Unrecognized key: "${c}"`);if(!t[c])continue;i[c]=r.shape[c]}return Oe(this,"shape",i),i},checks:[]});return ce(e,s)}function zf(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=$e(e._zod.def,{get shape(){let i={...e._zod.def.shape};for(let c in t){if(!(c in r.shape))throw Error(`Unrecognized key: "${c}"`);if(!t[c])continue;delete i[c]}return Oe(this,"shape",i),i},checks:[]});return ce(e,s)}function $f(e,t){if(!We(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let s=e._zod.def.shape;for(let i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=$e(e._zod.def,{get shape(){let s={...e._zod.def.shape,...t};return Oe(this,"shape",s),s}});return ce(e,o)}function Sf(e,t){if(!We(t))throw Error("Invalid input to safeExtend: expected a plain object");let r=$e(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Oe(this,"shape",n),n}});return ce(e,r)}function Ef(e,t){if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=$e(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return Oe(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ce(e,r)}function If(e,t,r){let o=t._zod.def.checks;if(o&&o.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let i=$e(t._zod.def,{get shape(){let c=t._zod.def.shape,a={...c};if(r)for(let l in r){if(!(l in c))throw Error(`Unrecognized key: "${l}"`);if(!r[l])continue;a[l]=e?new e({type:"optional",innerType:c[l]}):c[l]}else for(let l in c)a[l]=e?new e({type:"optional",innerType:c[l]}):c[l];return Oe(this,"shape",a),a},checks:[]});return ce(t,i)}function Tf(e,t,r){let n=$e(t._zod.def,{get shape(){let o=t._zod.def.shape,s={...o};if(r)for(let i in r){if(!(i in s))throw Error(`Unrecognized key: "${i}"`);if(!r[i])continue;s[i]=new e({type:"nonoptional",innerType:o[i]})}else for(let i in o)s[i]=new e({type:"nonoptional",innerType:o[i]});return Oe(this,"shape",s),s}});return ce(t,n)}function Ze(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Ho(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function sr(e,t){return t.map((r)=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function tr(e){return typeof e==="string"?e:e?.message}function ye(e,t,r){let n=e.message?e.message:tr(e.inst?._zod.def?.error?.(e))??tr(t?.error?.(e))??tr(r.customError?.(e))??tr(r.localeError?.(e))??"Invalid input",{inst:o,continue:s,input:i,...c}=e;if(c.path??(c.path=[]),c.message=n,t?.reportInput)c.input=i;return c}function Dc(e){if(e instanceof Set)return"set";if(e instanceof Map)return"map";if(e instanceof File)return"file";return"unknown"}function ir(e){if(Array.isArray(e))return"array";if(typeof e==="string")return"string";return"unknown"}function Af(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function bt(...e){let[t,r,n]=e;if(typeof t==="string")return{message:t,code:"custom",input:r,inst:n};return{...t}}function Of(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map((t)=>t[1])}function Rc(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function jc(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function Zf(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return Rc(t+r)}function Pf(e){return jc(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Cf(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function Nf(e){return Array.from(e).map((t)=>t.toString(16).padStart(2,"0")).join("")}class Lc{constructor(...e){}}var Bc=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,_t,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},mn=d("$ZodError",Bc),Yo=d("$ZodError",Bc,{Parent:Error});function Mc(e,t=(r)=>r.message){let r={},n=[];for(let o of e.issues)if(o.path.length>0)r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o));else n.push(t(o));return{formErrors:n,fieldErrors:r}}function Vc(e,t=(r)=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map((c)=>n({issues:c},[...s,...i.path]));else if(i.code==="invalid_key")n({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")n({issues:i.issues},[...s,...i.path]);else{let c=[...s,...i.path];if(c.length===0)r._errors.push(t(i));else{let a=r,l=0;while(l<c.length){let u=c[l];if(l!==c.length-1)a[u]=a[u]||{_errors:[]};else a[u]=a[u]||{_errors:[]},a[u]._errors.push(t(i));a=a[u],l++}}}};return n(e),r}var gn=(e)=>(t,r,n,o)=>{let s=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new ve;if(i.issues.length){let c=new(o?.Err??e)(i.issues.map((a)=>ye(a,s,ze())));throw fn(c,o?.callee),c}return i.value};var yn=(e)=>async(t,r,n,o)=>{let s=n?{...n,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise)i=await i;if(i.issues.length){let c=new(o?.Err??e)(i.issues.map((a)=>ye(a,s,ze())));throw fn(c,o?.callee),c}return i.value};var cr=(e)=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new ve;return s.issues.length?{success:!1,error:new(e??mn)(s.issues.map((i)=>ye(i,o,ze())))}:{success:!0,data:s.value}},Fc=cr(Yo),ar=(e)=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)s=await s;return s.issues.length?{success:!1,error:new e(s.issues.map((i)=>ye(i,o,ze())))}:{success:!0,data:s.value}},Jc=ar(Yo),qc=(e)=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return gn(e)(t,r,o)};var Gc=(e)=>(t,r,n)=>gn(e)(t,r,n);var Wc=(e)=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return yn(e)(t,r,o)};var Kc=(e)=>async(t,r,n)=>yn(e)(t,r,n);var Hc=(e)=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return cr(e)(t,r,o)};var Yc=(e)=>(t,r,n)=>cr(e)(t,r,n);var Xc=(e)=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return ar(e)(t,r,o)};var Qc=(e)=>async(t,r,n)=>ar(e)(t,r,n);var ea=/^[cC][0-9a-z]{6,}$/,ta=/^[0-9a-z]+$/,ra=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,na=/^[0-9a-vA-V]{20}$/,oa=/^[A-Za-z0-9]{27}$/,sa=/^[a-zA-Z0-9_-]{21}$/,ia=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var ca=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Xo=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var aa=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Df="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function ua(){return new RegExp(Df,"u")}var la=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,pa=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var ha=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,da=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,fa=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Qo=/^[A-Za-z0-9_-]*$/;var ma=/^https?$/,ga=/^\+[1-9]\d{6,14}$/,ya="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",xa=new RegExp(`^${ya}$`);function _a(e){return typeof e.precision==="number"?e.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":e.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function wa(e){return new RegExp(`^${_a(e)}$`)}function ba(e){let t=_a({precision:e.precision}),r=["Z"];if(e.local)r.push("");if(e.offset)r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${ya}T(?:${n})$`)}var ka=(e)=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var va=/^-?\d+$/,za=/^-?\d+(?:\.\d+)?$/;var $a=/^[^A-Z]*$/,Sa=/^[^a-z]*$/;var L=d("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Ea={number:"number",bigint:"bigint",object:"date"},es=d("$ZodCheckLessThan",(e,t)=>{L.init(e,t);let r=Ea[typeof t.value];e._zod.onattach.push((n)=>{let o=n._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(t.value<s)if(t.inclusive)o.maximum=t.value;else o.exclusiveMaximum=t.value}),e._zod.check=(n)=>{if(t.inclusive?n.value<=t.value:n.value<t.value)return;n.issues.push({origin:r,code:"too_big",maximum:typeof t.value==="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ts=d("$ZodCheckGreaterThan",(e,t)=>{L.init(e,t);let r=Ea[typeof t.value];e._zod.onattach.push((n)=>{let o=n._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(t.value>s)if(t.inclusive)o.minimum=t.value;else o.exclusiveMinimum=t.value}),e._zod.check=(n)=>{if(t.inclusive?n.value>=t.value:n.value>t.value)return;n.issues.push({origin:r,code:"too_small",minimum:typeof t.value==="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ia=d("$ZodCheckMultipleOf",(e,t)=>{L.init(e,t),e._zod.onattach.push((r)=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=(r)=>{if(typeof r.value!==typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof r.value==="bigint"?r.value%t.value===BigInt(0):Fo(r.value,t.value)===0)return;r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Ta=d("$ZodCheckNumberFormat",(e,t)=>{L.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=Ko[t.format];e._zod.onattach.push((i)=>{let c=i._zod.bag;if(c.format=t.format,c.minimum=o,c.maximum=s,r)c.pattern=va}),e._zod.check=(i)=>{let c=i.value;if(r){if(!Number.isInteger(c)){i.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){if(c>0)i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});else i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}if(c<o)i.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort});if(c>s)i.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Aa=d("$ZodCheckMaxLength",(e,t)=>{var r;L.init(e,t),(r=e._zod.def).when??(r.when=(n)=>{let o=n.value;return!nr(o)&&o.length!==void 0}),e._zod.onattach.push((n)=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<o)n._zod.bag.maximum=t.maximum}),e._zod.check=(n)=>{let o=n.value;if(o.length<=t.maximum)return;let i=ir(o);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Oa=d("$ZodCheckMinLength",(e,t)=>{var r;L.init(e,t),(r=e._zod.def).when??(r.when=(n)=>{let o=n.value;return!nr(o)&&o.length!==void 0}),e._zod.onattach.push((n)=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>o)n._zod.bag.minimum=t.minimum}),e._zod.check=(n)=>{let o=n.value;if(o.length>=t.minimum)return;let i=ir(o);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Za=d("$ZodCheckLengthEquals",(e,t)=>{var r;L.init(e,t),(r=e._zod.def).when??(r.when=(n)=>{let o=n.value;return!nr(o)&&o.length!==void 0}),e._zod.onattach.push((n)=>{let o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=(n)=>{let o=n.value,s=o.length;if(s===t.length)return;let i=ir(o),c=s>t.length;n.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),ur=d("$ZodCheckStringFormat",(e,t)=>{var r,n;if(L.init(e,t),e._zod.onattach.push((o)=>{let s=o._zod.bag;if(s.format=t.format,t.pattern)s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern)}),t.pattern)(r=e._zod).check??(r.check=(o)=>{if(t.pattern.lastIndex=0,t.pattern.test(o.value))return;o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(n=e._zod).check??(n.check=()=>{})}),Pa=d("$ZodCheckRegex",(e,t)=>{ur.init(e,t),e._zod.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ca=d("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=$a),ur.init(e,t)}),Na=d("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Sa),ur.init(e,t)}),Ua=d("$ZodCheckIncludes",(e,t)=>{L.init(e,t);let r=Se(t.includes),n=new RegExp(typeof t.position==="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push((o)=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=(o)=>{if(o.value.includes(t.includes,t.position))return;o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Da=d("$ZodCheckStartsWith",(e,t)=>{L.init(e,t);let r=new RegExp(`^${Se(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push((n)=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=(n)=>{if(n.value.startsWith(t.prefix))return;n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Ra=d("$ZodCheckEndsWith",(e,t)=>{L.init(e,t);let r=new RegExp(`.*${Se(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push((n)=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=(n)=>{if(n.value.endsWith(t.suffix))return;n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var ja=d("$ZodCheckOverwrite",(e,t)=>{L.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class rs{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e==="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let r=e.split(`
6
6
  `).filter((s)=>s),n=Math.min(...r.map((s)=>s.length-s.trimStart().length)),o=r.map((s)=>s.slice(n)).map((s)=>" ".repeat(this.indent*2)+s);for(let s of o)this.content.push(s)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[""]).map((o)=>` ${o}`)];return new e(...t,n.join(`
7
- `))}}var Ba={major:4,minor:4,patch:3};var T=d("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ba;let n=[...e._zod.def.checks??[]];if(e._zod.traits.has("$ZodCheck"))n.unshift(e);for(let o of n)for(let s of o._zod.onattach)s(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(i,c,a)=>{let l=Ze(i),u;for(let h of c){if(h._zod.def.when){if(Ho(i))continue;if(!h._zod.def.when(i))continue}else if(l)continue;let p=i.issues.length,f=h._zod.check(i);if(f instanceof Promise&&a?.async===!1)throw new ve;if(u||f instanceof Promise)u=(u??Promise.resolve()).then(async()=>{if(await f,i.issues.length===p)return;if(!l)l=Ze(i,p)});else{if(i.issues.length===p)continue;if(!l)l=Ze(i,p)}}if(u)return u.then(()=>i);return i},s=(i,c,a)=>{if(Ze(i))return i.aborted=!0,i;let l=o(c,n,a);if(l instanceof Promise){if(a.async===!1)throw new ve;return l.then((u)=>e._zod.parse(u,a))}return e._zod.parse(l,a)};e._zod.run=(i,c)=>{if(c.skipChecks)return e._zod.parse(i,c);if(c.direction==="backward"){let l=e._zod.parse({value:i.value,issues:[]},{...c,skipChecks:!0});if(l instanceof Promise)return l.then((u)=>s(u,i,c));return s(l,i,c)}let a=e._zod.parse(i,c);if(a instanceof Promise){if(c.async===!1)throw new ve;return a.then((l)=>o(l,n,c))}return o(a,n,c)}}w(e,"~standard",()=>({validate:(o)=>{try{let s=Fc(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch(s){return Jc(e,o).then((i)=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),bn=d("$ZodString",(e,t)=>{T.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ka(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(o){}if(typeof r.value==="string")return r;return r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),S=d("$ZodStringFormat",(e,t)=>{ur.init(e,t),bn.init(e,t)}),Ha=d("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ca),S.init(e,t)}),Ya=d("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Xo(n))}else t.pattern??(t.pattern=Xo());S.init(e,t)}),Xa=d("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=aa),S.init(e,t)}),Qa=d("$ZodURL",(e,t)=>{S.init(e,t),e._zod.check=(r)=>{try{let n=r.value.trim();if(!t.normalize&&t.protocol?.source===ma.source){if(!/^https?:\/\//i.test(n)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}}let o=new URL(n);if(t.hostname){if(t.hostname.lastIndex=0,!t.hostname.test(o.hostname))r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})}if(t.protocol){if(t.protocol.lastIndex=0,!t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})}if(t.normalize)r.value=o.href;else r.value=n;return}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),eu=d("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=ua()),S.init(e,t)}),tu=d("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=sa),S.init(e,t)}),ru=d("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ea),S.init(e,t)}),nu=d("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ta),S.init(e,t)}),ou=d("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ra),S.init(e,t)}),su=d("$ZodXID",(e,t)=>{t.pattern??(t.pattern=na),S.init(e,t)}),iu=d("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=oa),S.init(e,t)}),cu=d("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=ba(t)),S.init(e,t)}),au=d("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ya),S.init(e,t)}),uu=d("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=wa(t)),S.init(e,t)}),lu=d("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ia),S.init(e,t)}),pu=d("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=la),S.init(e,t),e._zod.bag.format="ipv4"}),hu=d("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=pa),S.init(e,t),e._zod.bag.format="ipv6",e._zod.check=(r)=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}});var du=d("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ha),S.init(e,t)}),fu=d("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=da),S.init(e,t),e._zod.check=(r)=>{let n=r.value.split("/");try{if(n.length!==2)throw Error();let[o,s]=n;if(!s)throw Error();let i=Number(s);if(`${i}`!==s)throw Error();if(i<0||i>128)throw Error();new URL(`http://[${o}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function mu(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var gu=d("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=fa),S.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=(r)=>{if(mu(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Rf(e){if(!Qo.test(e))return!1;let t=e.replace(/[-_]/g,(n)=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return mu(r)}var xu=d("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Qo),S.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=(r)=>{if(Rf(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),yu=d("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ga),S.init(e,t)});function jf(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));if("typ"in o&&o?.typ!=="JWT")return!1;if(!o.alg)return!1;if(t&&(!("alg"in o)||o.alg!==t))return!1;return!0}catch{return!1}}var _u=d("$ZodJWT",(e,t)=>{S.init(e,t),e._zod.check=(r)=>{if(jf(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var os=d("$ZodNumber",(e,t)=>{T.init(e,t),e._zod.pattern=e._zod.bag.pattern??za,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(i){}let o=r.value;if(typeof o==="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o==="number"?Number.isNaN(o)?"NaN":!Number.isFinite(o)?"Infinity":void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),wu=d("$ZodNumberFormat",(e,t)=>{Ta.init(e,t),os.init(e,t)});var bu=d("$ZodUnknown",(e,t)=>{T.init(e,t),e._zod.parse=(r)=>r}),ku=d("$ZodNever",(e,t)=>{T.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Ma(e,t,r){if(e.issues.length)t.issues.push(...sr(r,e.issues));t.value[r]=e.value}var vu=d("$ZodArray",(e,t)=>{T.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);let s=[];for(let i=0;i<o.length;i++){let c=o[i],a=t.element._zod.run({value:c,issues:[]},n);if(a instanceof Promise)s.push(a.then((l)=>Ma(l,r,i)));else Ma(a,r,i)}if(s.length)return Promise.all(s).then(()=>r);return r}});function wn(e,t,r,n,o,s){let i=r in n;if(e.issues.length){if(o&&s&&!i)return;t.issues.push(...sr(r,e.issues))}if(!i&&!o){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}if(e.value===void 0){if(i)t.value[r]=void 0}else t.value[r]=e.value}function zu(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let r=Wo(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function $u(e,t,r,n,o,s){let i=[],c=o.keySet,a=o.catchall._zod,l=a.def.type,u=a.optin==="optional",h=a.optout==="optional";for(let p in t){if(p==="__proto__")continue;if(c.has(p))continue;if(l==="never"){i.push(p);continue}let f=a.run({value:t[p],issues:[]},n);if(f instanceof Promise)e.push(f.then((m)=>wn(m,r,p,t,u,h)));else wn(f,r,p,t,u,h)}if(i.length)r.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s});if(!e.length)return r;return Promise.all(e).then(()=>r)}var Lf=d("$ZodObject",(e,t)=>{if(T.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let c=t.shape;Object.defineProperty(t,"shape",{get:()=>{let a={...c};return Object.defineProperty(t,"shape",{value:a}),a}})}let n=wt(()=>zu(t));w(e._zod,"propValues",()=>{let c=t.shape,a={};for(let l in c){let u=c[l]._zod;if(u.values){a[l]??(a[l]=new Set);for(let h of u.values)a[l].add(h)}}return a});let o=Ge,s=t.catchall,i;e._zod.parse=(c,a)=>{i??(i=n.value);let l=c.value;if(!o(l))return c.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),c;c.value={};let u=[],h=i.shape;for(let p of i.keys){let f=h[p],m=f._zod.optin==="optional",k=f._zod.optout==="optional",z=f._zod.run({value:l[p],issues:[]},a);if(z instanceof Promise)u.push(z.then((Rn)=>wn(Rn,c,p,l,m,k)));else wn(z,c,p,l,m,k)}if(!s)return u.length?Promise.all(u).then(()=>c):c;return $u(u,l,c,a,n.value,e)}}),Su=d("$ZodObjectJIT",(e,t)=>{Lf.init(e,t);let r=e._zod.parse,n=wt(()=>zu(t)),o=(p)=>{let f=new rs(["shape","payload","ctx"]),m=n.value,k=(ae)=>{let I=dn(ae);return`shape[${I}]._zod.run({ value: input[${I}], issues: [] }, ctx)`};f.write("const input = payload.value;");let z=Object.create(null),Rn=0;for(let ae of m.keys)z[ae]=`key_${Rn++}`;f.write("const newResult = {};");for(let ae of m.keys){let I=z[ae],j=dn(ae),Is=p[ae],Ts=Is?._zod?.optin==="optional",Ip=Is?._zod?.optout==="optional";if(f.write(`const ${I} = ${k(ae)};`),Ts&&Ip)f.write(`
7
+ `))}}var Ba={major:4,minor:4,patch:3};var T=d("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ba;let n=[...e._zod.def.checks??[]];if(e._zod.traits.has("$ZodCheck"))n.unshift(e);for(let o of n)for(let s of o._zod.onattach)s(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(i,c,a)=>{let l=Ze(i),u;for(let h of c){if(h._zod.def.when){if(Ho(i))continue;if(!h._zod.def.when(i))continue}else if(l)continue;let p=i.issues.length,f=h._zod.check(i);if(f instanceof Promise&&a?.async===!1)throw new ve;if(u||f instanceof Promise)u=(u??Promise.resolve()).then(async()=>{if(await f,i.issues.length===p)return;if(!l)l=Ze(i,p)});else{if(i.issues.length===p)continue;if(!l)l=Ze(i,p)}}if(u)return u.then(()=>i);return i},s=(i,c,a)=>{if(Ze(i))return i.aborted=!0,i;let l=o(c,n,a);if(l instanceof Promise){if(a.async===!1)throw new ve;return l.then((u)=>e._zod.parse(u,a))}return e._zod.parse(l,a)};e._zod.run=(i,c)=>{if(c.skipChecks)return e._zod.parse(i,c);if(c.direction==="backward"){let l=e._zod.parse({value:i.value,issues:[]},{...c,skipChecks:!0});if(l instanceof Promise)return l.then((u)=>s(u,i,c));return s(l,i,c)}let a=e._zod.parse(i,c);if(a instanceof Promise){if(c.async===!1)throw new ve;return a.then((l)=>o(l,n,c))}return o(a,n,c)}}w(e,"~standard",()=>({validate:(o)=>{try{let s=Fc(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch(s){return Jc(e,o).then((i)=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),bn=d("$ZodString",(e,t)=>{T.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ka(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(o){}if(typeof r.value==="string")return r;return r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),S=d("$ZodStringFormat",(e,t)=>{ur.init(e,t),bn.init(e,t)}),Ha=d("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ca),S.init(e,t)}),Ya=d("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Xo(n))}else t.pattern??(t.pattern=Xo());S.init(e,t)}),Xa=d("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=aa),S.init(e,t)}),Qa=d("$ZodURL",(e,t)=>{S.init(e,t),e._zod.check=(r)=>{try{let n=r.value.trim();if(!t.normalize&&t.protocol?.source===ma.source){if(!/^https?:\/\//i.test(n)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}}let o=new URL(n);if(t.hostname){if(t.hostname.lastIndex=0,!t.hostname.test(o.hostname))r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})}if(t.protocol){if(t.protocol.lastIndex=0,!t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol))r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})}if(t.normalize)r.value=o.href;else r.value=n;return}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),eu=d("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=ua()),S.init(e,t)}),tu=d("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=sa),S.init(e,t)}),ru=d("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ea),S.init(e,t)}),nu=d("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ta),S.init(e,t)}),ou=d("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ra),S.init(e,t)}),su=d("$ZodXID",(e,t)=>{t.pattern??(t.pattern=na),S.init(e,t)}),iu=d("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=oa),S.init(e,t)}),cu=d("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=ba(t)),S.init(e,t)}),au=d("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=xa),S.init(e,t)}),uu=d("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=wa(t)),S.init(e,t)}),lu=d("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ia),S.init(e,t)}),pu=d("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=la),S.init(e,t),e._zod.bag.format="ipv4"}),hu=d("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=pa),S.init(e,t),e._zod.bag.format="ipv6",e._zod.check=(r)=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}});var du=d("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ha),S.init(e,t)}),fu=d("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=da),S.init(e,t),e._zod.check=(r)=>{let n=r.value.split("/");try{if(n.length!==2)throw Error();let[o,s]=n;if(!s)throw Error();let i=Number(s);if(`${i}`!==s)throw Error();if(i<0||i>128)throw Error();new URL(`http://[${o}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function mu(e){if(e==="")return!0;if(/\s/.test(e))return!1;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var gu=d("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=fa),S.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=(r)=>{if(mu(r.value))return;r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Rf(e){if(!Qo.test(e))return!1;let t=e.replace(/[-_]/g,(n)=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return mu(r)}var yu=d("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Qo),S.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=(r)=>{if(Rf(r.value))return;r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),xu=d("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ga),S.init(e,t)});function jf(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));if("typ"in o&&o?.typ!=="JWT")return!1;if(!o.alg)return!1;if(t&&(!("alg"in o)||o.alg!==t))return!1;return!0}catch{return!1}}var _u=d("$ZodJWT",(e,t)=>{S.init(e,t),e._zod.check=(r)=>{if(jf(r.value,t.alg))return;r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var os=d("$ZodNumber",(e,t)=>{T.init(e,t),e._zod.pattern=e._zod.bag.pattern??za,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(i){}let o=r.value;if(typeof o==="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o==="number"?Number.isNaN(o)?"NaN":!Number.isFinite(o)?"Infinity":void 0:void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),wu=d("$ZodNumberFormat",(e,t)=>{Ta.init(e,t),os.init(e,t)});var bu=d("$ZodUnknown",(e,t)=>{T.init(e,t),e._zod.parse=(r)=>r}),ku=d("$ZodNever",(e,t)=>{T.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Ma(e,t,r){if(e.issues.length)t.issues.push(...sr(r,e.issues));t.value[r]=e.value}var vu=d("$ZodArray",(e,t)=>{T.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);let s=[];for(let i=0;i<o.length;i++){let c=o[i],a=t.element._zod.run({value:c,issues:[]},n);if(a instanceof Promise)s.push(a.then((l)=>Ma(l,r,i)));else Ma(a,r,i)}if(s.length)return Promise.all(s).then(()=>r);return r}});function wn(e,t,r,n,o,s){let i=r in n;if(e.issues.length){if(o&&s&&!i)return;t.issues.push(...sr(r,e.issues))}if(!i&&!o){if(!e.issues.length)t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}if(e.value===void 0){if(i)t.value[r]=void 0}else t.value[r]=e.value}function zu(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let r=Wo(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function $u(e,t,r,n,o,s){let i=[],c=o.keySet,a=o.catchall._zod,l=a.def.type,u=a.optin==="optional",h=a.optout==="optional";for(let p in t){if(p==="__proto__")continue;if(c.has(p))continue;if(l==="never"){i.push(p);continue}let f=a.run({value:t[p],issues:[]},n);if(f instanceof Promise)e.push(f.then((m)=>wn(m,r,p,t,u,h)));else wn(f,r,p,t,u,h)}if(i.length)r.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s});if(!e.length)return r;return Promise.all(e).then(()=>r)}var Lf=d("$ZodObject",(e,t)=>{if(T.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let c=t.shape;Object.defineProperty(t,"shape",{get:()=>{let a={...c};return Object.defineProperty(t,"shape",{value:a}),a}})}let n=wt(()=>zu(t));w(e._zod,"propValues",()=>{let c=t.shape,a={};for(let l in c){let u=c[l]._zod;if(u.values){a[l]??(a[l]=new Set);for(let h of u.values)a[l].add(h)}}return a});let o=Ge,s=t.catchall,i;e._zod.parse=(c,a)=>{i??(i=n.value);let l=c.value;if(!o(l))return c.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),c;c.value={};let u=[],h=i.shape;for(let p of i.keys){let f=h[p],m=f._zod.optin==="optional",k=f._zod.optout==="optional",z=f._zod.run({value:l[p],issues:[]},a);if(z instanceof Promise)u.push(z.then((Rn)=>wn(Rn,c,p,l,m,k)));else wn(z,c,p,l,m,k)}if(!s)return u.length?Promise.all(u).then(()=>c):c;return $u(u,l,c,a,n.value,e)}}),Su=d("$ZodObjectJIT",(e,t)=>{Lf.init(e,t);let r=e._zod.parse,n=wt(()=>zu(t)),o=(p)=>{let f=new rs(["shape","payload","ctx"]),m=n.value,k=(ae)=>{let I=dn(ae);return`shape[${I}]._zod.run({ value: input[${I}], issues: [] }, ctx)`};f.write("const input = payload.value;");let z=Object.create(null),Rn=0;for(let ae of m.keys)z[ae]=`key_${Rn++}`;f.write("const newResult = {};");for(let ae of m.keys){let I=z[ae],j=dn(ae),Is=p[ae],Ts=Is?._zod?.optin==="optional",Ip=Is?._zod?.optout==="optional";if(f.write(`const ${I} = ${k(ae)};`),Ts&&Ip)f.write(`
8
8
  if (${I}.issues.length) {
9
9
  if (${j} in input) {
10
10
  payload.issues = payload.issues.concat(${I}.issues.map(iss => ({
@@ -63,7 +63,7 @@ ${r.toString()}`)};class ki{constructor(e){this.patterns=[],this.$state=e}if(e,t
63
63
  newResult[${j}] = ${I}.value;
64
64
  }
65
65
 
66
- `)}f.write("payload.value = newResult;"),f.write("return payload;");let Ep=f.compile();return(ae,I)=>Ep(p,ae,I)},s,i=Ge,c=!yt.jitless,l=c&&qo.value,u=t.catchall,h;e._zod.parse=(p,f)=>{h??(h=n.value);let m=p.value;if(!i(m))return p.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),p;if(c&&l&&f?.async===!1&&f.jitless!==!0){if(!s)s=o(t.shape);if(p=s(p,f),!u)return p;return $u([],m,p,f,h,e)}return r(p,f)}});function Va(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter((s)=>!Ze(s));if(o.length===1)return t.value=o[0].value,o[0];return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((s)=>s.issues.map((i)=>xe(i,n,ze())))}),t}var ss=d("$ZodUnion",(e,t)=>{T.init(e,t),w(e._zod,"optin",()=>t.options.some((n)=>n._zod.optin==="optional")?"optional":void 0),w(e._zod,"optout",()=>t.options.some((n)=>n._zod.optout==="optional")?"optional":void 0),w(e._zod,"values",()=>{if(t.options.every((n)=>n._zod.values))return new Set(t.options.flatMap((n)=>Array.from(n._zod.values)));return}),w(e._zod,"pattern",()=>{if(t.options.every((n)=>n._zod.pattern)){let n=t.options.map((o)=>o._zod.pattern);return new RegExp(`^(${n.map((o)=>or(o.source)).join("|")})$`)}return});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let c of t.options){let a=c._zod.run({value:n.value,issues:[]},o);if(a instanceof Promise)i.push(a),s=!0;else{if(a.issues.length===0)return a;i.push(a)}}if(!s)return Va(i,n,e,o);return Promise.all(i).then((c)=>Va(c,n,e,o))}});var Eu=d("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,ss.init(e,t);let r=e._zod.parse;w(e._zod,"propValues",()=>{let o={};for(let s of t.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let[c,a]of Object.entries(i)){if(!o[c])o[c]=new Set;for(let l of a)o[c].add(l)}}return o});let n=wt(()=>{let o=t.options,s=new Map;for(let i of o){let c=i._zod.propValues?.[t.discriminator];if(!c||c.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let a of c){if(s.has(a))throw Error(`Duplicate discriminator value "${String(a)}"`);s.set(a,i)}}return s});e._zod.parse=(o,s)=>{let i=o.value;if(!Ge(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;let c=n.value.get(i?.[t.discriminator]);if(c)return c._zod.run(o,s);if(t.unionFallback||s.direction==="backward")return r(o,s);return o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()),input:i,path:[t.discriminator],inst:e}),o}}),Iu=d("$ZodIntersection",(e,t)=>{T.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);if(s instanceof Promise||i instanceof Promise)return Promise.all([s,i]).then(([a,l])=>Fa(r,a,l));return Fa(r,s,i)}});function ns(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(We(e)&&We(t)){let r=Object.keys(t),n=Object.keys(e).filter((s)=>r.indexOf(s)!==-1),o={...e,...t};for(let s of n){let i=ns(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],i=ns(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Fa(e,t,r){let n=new Map,o;for(let c of t.issues)if(c.code==="unrecognized_keys"){o??(o=c);for(let a of c.keys){if(!n.has(a))n.set(a,{});n.get(a).l=!0}}else e.issues.push(c);for(let c of r.issues)if(c.code==="unrecognized_keys")for(let a of c.keys){if(!n.has(a))n.set(a,{});n.get(a).r=!0}else e.issues.push(c);let s=[...n].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(s.length&&o)e.issues.push({...o,keys:s});if(Ze(e))return e;let i=ns(t.value,r.value);if(!i.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}var Tu=d("$ZodEnum",(e,t)=>{T.init(e,t);let r=rr(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter((o)=>Go.has(typeof o)).map((o)=>typeof o==="string"?Se(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{let i=o.value;if(n.has(i))return o;return o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}}),Au=d("$ZodLiteral",(e,t)=>{if(T.init(e,t),t.values.length===0)throw Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map((n)=>typeof n==="string"?Se(n):n?Se(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,o)=>{let s=n.value;if(r.has(s))return n;return n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}});var Ou=d("$ZodTransform",(e,t)=>{T.init(e,t),e._zod.optin="optional",e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new er(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then((i)=>(r.value=i,r.fallback=!0,r));if(o instanceof Promise)throw new ve;return r.value=o,r.fallback=!0,r}});function Ja(e,t){if(t===void 0&&(e.issues.length||e.fallback))return{issues:[],value:void 0};return e}var is=d("$ZodOptional",(e,t)=>{T.init(e,t),e._zod.optin="optional",e._zod.optout="optional",w(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),w(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${or(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let o=r.value,s=t.innerType._zod.run(r,n);if(s instanceof Promise)return s.then((i)=>Ja(i,o));return Ja(s,o)}if(r.value===void 0)return r;return t.innerType._zod.run(r,n)}}),Zu=d("$ZodExactOptional",(e,t)=>{is.init(e,t),w(e._zod,"values",()=>t.innerType._zod.values),w(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Pu=d("$ZodNullable",(e,t)=>{T.init(e,t),w(e._zod,"optin",()=>t.innerType._zod.optin),w(e._zod,"optout",()=>t.innerType._zod.optout),w(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${or(r.source)}|null)$`):void 0}),w(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>{if(r.value===null)return r;return t.innerType._zod.run(r,n)}}),Cu=d("$ZodDefault",(e,t)=>{T.init(e,t),e._zod.optin="optional",w(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>qa(s,t));return qa(o,t)}});function qa(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Nu=d("$ZodPrefault",(e,t)=>{T.init(e,t),e._zod.optin="optional",w(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,n)}}),Uu=d("$ZodNonOptional",(e,t)=>{T.init(e,t),w(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter((n)=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>Ga(s,e));return Ga(o,e)}});function Ga(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}var Du=d("$ZodCatch",(e,t)=>{T.init(e,t),e._zod.optin="optional",w(e._zod,"optout",()=>t.innerType._zod.optout),w(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>{if(r.value=s.value,s.issues.length)r.value=t.catchValue({...r,error:{issues:s.issues.map((i)=>xe(i,n,ze()))},input:r.value}),r.issues=[],r.fallback=!0;return r});if(r.value=o.value,o.issues.length)r.value=t.catchValue({...r,error:{issues:o.issues.map((s)=>xe(s,n,ze()))},input:r.value}),r.issues=[],r.fallback=!0;return r}});var Ru=d("$ZodPipe",(e,t)=>{T.init(e,t),w(e._zod,"values",()=>t.in._zod.values),w(e._zod,"optin",()=>t.in._zod.optin),w(e._zod,"optout",()=>t.out._zod.optout),w(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=t.out._zod.run(r,n);if(s instanceof Promise)return s.then((i)=>_n(i,t.in,n));return _n(s,t.in,n)}let o=t.in._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>_n(s,t.out,n));return _n(o,t.out,n)}});function _n(e,t,r){if(e.issues.length)return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}var ju=d("$ZodReadonly",(e,t)=>{T.init(e,t),w(e._zod,"propValues",()=>t.innerType._zod.propValues),w(e._zod,"values",()=>t.innerType._zod.values),w(e._zod,"optin",()=>t.innerType?._zod?.optin),w(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then(Wa);return Wa(o)}});function Wa(e){return e.value=Object.freeze(e.value),e}var Lu=d("$ZodCustom",(e,t)=>{L.init(e,t),T.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=(r)=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then((s)=>Ka(s,r,n,e));Ka(o,r,n,e);return}});function Ka(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};if(n._zod.def.params)o.params=n._zod.def.params;t.issues.push(bt(o))}}var Bu,mx=Symbol("ZodOutput"),gx=Symbol("ZodInput");class Mu{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];if(this._map.set(e,r),r&&typeof r==="object"&&"id"in r)this._idmap.set(r.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Bf(){return new Mu}(Bu=globalThis).__zod_globalRegistry??(Bu.__zod_globalRegistry=Bf());var Ke=globalThis.__zod_globalRegistry;function Vu(e,t){return new e({type:"string",...g(t)})}function Fu(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...g(t)})}function cs(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...g(t)})}function Ju(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...g(t)})}function qu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...g(t)})}function Gu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...g(t)})}function Wu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...g(t)})}function Ku(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...g(t)})}function Hu(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...g(t)})}function Yu(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...g(t)})}function Xu(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...g(t)})}function Qu(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...g(t)})}function el(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...g(t)})}function tl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...g(t)})}function rl(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...g(t)})}function nl(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...g(t)})}function ol(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...g(t)})}function sl(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...g(t)})}function il(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...g(t)})}function cl(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...g(t)})}function al(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...g(t)})}function ul(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...g(t)})}function ll(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...g(t)})}function pl(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...g(t)})}function hl(e,t){return new e({type:"string",format:"date",check:"string_format",...g(t)})}function dl(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...g(t)})}function fl(e,t){return new e({type:"string",format:"duration",check:"string_format",...g(t)})}function ml(e,t){return new e({type:"number",checks:[],...g(t)})}function gl(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...g(t)})}function xl(e){return new e({type:"unknown"})}function yl(e,t){return new e({type:"never",...g(t)})}function kn(e,t){return new es({check:"less_than",...g(t),value:e,inclusive:!1})}function lr(e,t){return new es({check:"less_than",...g(t),value:e,inclusive:!0})}function vn(e,t){return new ts({check:"greater_than",...g(t),value:e,inclusive:!1})}function pr(e,t){return new ts({check:"greater_than",...g(t),value:e,inclusive:!0})}function zn(e,t){return new Ia({check:"multiple_of",...g(t),value:e})}function $n(e,t){return new Aa({check:"max_length",...g(t),maximum:e})}function kt(e,t){return new Oa({check:"min_length",...g(t),minimum:e})}function Sn(e,t){return new Za({check:"length_equals",...g(t),length:e})}function as(e,t){return new Pa({check:"string_format",format:"regex",...g(t),pattern:e})}function us(e){return new Ca({check:"string_format",format:"lowercase",...g(e)})}function ls(e){return new Na({check:"string_format",format:"uppercase",...g(e)})}function ps(e,t){return new Ua({check:"string_format",format:"includes",...g(t),includes:e})}function hs(e,t){return new Da({check:"string_format",format:"starts_with",...g(t),prefix:e})}function ds(e,t){return new Ra({check:"string_format",format:"ends_with",...g(t),suffix:e})}function Pe(e){return new ja({check:"overwrite",tx:e})}function fs(e){return Pe((t)=>t.normalize(e))}function ms(){return Pe((e)=>e.trim())}function gs(){return Pe((e)=>e.toLowerCase())}function xs(){return Pe((e)=>e.toUpperCase())}function ys(){return Pe((e)=>Jo(e))}function _l(e,t,r){return new e({type:"array",element:t,...g(r)})}function wl(e,t,r){return new e({type:"custom",check:"custom",fn:t,...g(r)})}function bl(e,t){let r=Mf((n)=>(n.addIssue=(o)=>{if(typeof o==="string")n.issues.push(bt(o,n.value,r._zod.def));else{let s=o;if(s.fatal)s.continue=!1;s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(bt(s))}},e(n.value,n)),t);return r}function Mf(e,t){let r=new L({check:"custom",...g(t)});return r._zod.check=e,r}function _s(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Ke,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function R(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,r.schemaPath.includes(e))s.cycle=r.path;return s.schema}let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i);let c=e._zod.toJSONSchema?.();if(c)i.schema=c;else{let u={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,u);else{let p=i.schema,f=t.processors[o.type];if(!f)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(e,t,p,u)}let h=e._zod.parent;if(h){if(!i.ref)i.ref=h;R(h,t,u),t.seen.get(h).isParent=!0}}let a=t.metadataRegistry.get(e);if(a)Object.assign(i.schema,a);if(t.io==="input"&&W(e))delete i.schema.examples,delete i.schema.default;if(t.io==="input"&&"_prefault"in i.schema)(n=i.schema).default??(n.default=i.schema._prefault);return delete i.schema._prefault,t.seen.get(e).schema}function ws(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let n=new Map;for(let i of e.seen.entries()){let c=e.metadataRegistry.get(i[0])?.id;if(c){let a=n.get(c);if(a&&a!==i[0])throw Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(c,i[0])}}let o=(i)=>{let c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let h=e.external.registry.get(i[0])?.id,p=e.external.uri??((m)=>m);if(h)return{ref:p(h)};let f=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=f,{defId:f,ref:`${p("__shared")}#/${c}/${f}`}}if(i[1]===r)return{ref:"#"};let l=`${"#"}/${c}/`,u=i[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+u}},s=(i)=>{if(i[1].schema.$ref)return;let c=i[1],{ref:a,defId:l}=o(i);if(c.def={...c.schema},l)c.defId=l;let u=c.schema;for(let h in u)delete u[h];u.$ref=a};if(e.cycles==="throw")for(let i of e.seen.entries()){let c=i[1];if(c.cycle)throw Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
66
+ `)}f.write("payload.value = newResult;"),f.write("return payload;");let Ep=f.compile();return(ae,I)=>Ep(p,ae,I)},s,i=Ge,c=!xt.jitless,l=c&&qo.value,u=t.catchall,h;e._zod.parse=(p,f)=>{h??(h=n.value);let m=p.value;if(!i(m))return p.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),p;if(c&&l&&f?.async===!1&&f.jitless!==!0){if(!s)s=o(t.shape);if(p=s(p,f),!u)return p;return $u([],m,p,f,h,e)}return r(p,f)}});function Va(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter((s)=>!Ze(s));if(o.length===1)return t.value=o[0].value,o[0];return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map((s)=>s.issues.map((i)=>ye(i,n,ze())))}),t}var ss=d("$ZodUnion",(e,t)=>{T.init(e,t),w(e._zod,"optin",()=>t.options.some((n)=>n._zod.optin==="optional")?"optional":void 0),w(e._zod,"optout",()=>t.options.some((n)=>n._zod.optout==="optional")?"optional":void 0),w(e._zod,"values",()=>{if(t.options.every((n)=>n._zod.values))return new Set(t.options.flatMap((n)=>Array.from(n._zod.values)));return}),w(e._zod,"pattern",()=>{if(t.options.every((n)=>n._zod.pattern)){let n=t.options.map((o)=>o._zod.pattern);return new RegExp(`^(${n.map((o)=>or(o.source)).join("|")})$`)}return});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let c of t.options){let a=c._zod.run({value:n.value,issues:[]},o);if(a instanceof Promise)i.push(a),s=!0;else{if(a.issues.length===0)return a;i.push(a)}}if(!s)return Va(i,n,e,o);return Promise.all(i).then((c)=>Va(c,n,e,o))}});var Eu=d("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,ss.init(e,t);let r=e._zod.parse;w(e._zod,"propValues",()=>{let o={};for(let s of t.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let[c,a]of Object.entries(i)){if(!o[c])o[c]=new Set;for(let l of a)o[c].add(l)}}return o});let n=wt(()=>{let o=t.options,s=new Map;for(let i of o){let c=i._zod.propValues?.[t.discriminator];if(!c||c.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let a of c){if(s.has(a))throw Error(`Duplicate discriminator value "${String(a)}"`);s.set(a,i)}}return s});e._zod.parse=(o,s)=>{let i=o.value;if(!Ge(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;let c=n.value.get(i?.[t.discriminator]);if(c)return c._zod.run(o,s);if(t.unionFallback||s.direction==="backward")return r(o,s);return o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()),input:i,path:[t.discriminator],inst:e}),o}}),Iu=d("$ZodIntersection",(e,t)=>{T.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);if(s instanceof Promise||i instanceof Promise)return Promise.all([s,i]).then(([a,l])=>Fa(r,a,l));return Fa(r,s,i)}});function ns(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(We(e)&&We(t)){let r=Object.keys(t),n=Object.keys(e).filter((s)=>r.indexOf(s)!==-1),o={...e,...t};for(let s of n){let i=ns(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],i=ns(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Fa(e,t,r){let n=new Map,o;for(let c of t.issues)if(c.code==="unrecognized_keys"){o??(o=c);for(let a of c.keys){if(!n.has(a))n.set(a,{});n.get(a).l=!0}}else e.issues.push(c);for(let c of r.issues)if(c.code==="unrecognized_keys")for(let a of c.keys){if(!n.has(a))n.set(a,{});n.get(a).r=!0}else e.issues.push(c);let s=[...n].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(s.length&&o)e.issues.push({...o,keys:s});if(Ze(e))return e;let i=ns(t.value,r.value);if(!i.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}var Tu=d("$ZodEnum",(e,t)=>{T.init(e,t);let r=rr(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter((o)=>Go.has(typeof o)).map((o)=>typeof o==="string"?Se(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{let i=o.value;if(n.has(i))return o;return o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}}),Au=d("$ZodLiteral",(e,t)=>{if(T.init(e,t),t.values.length===0)throw Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map((n)=>typeof n==="string"?Se(n):n?Se(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,o)=>{let s=n.value;if(r.has(s))return n;return n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}});var Ou=d("$ZodTransform",(e,t)=>{T.init(e,t),e._zod.optin="optional",e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new er(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then((i)=>(r.value=i,r.fallback=!0,r));if(o instanceof Promise)throw new ve;return r.value=o,r.fallback=!0,r}});function Ja(e,t){if(t===void 0&&(e.issues.length||e.fallback))return{issues:[],value:void 0};return e}var is=d("$ZodOptional",(e,t)=>{T.init(e,t),e._zod.optin="optional",e._zod.optout="optional",w(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),w(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${or(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let o=r.value,s=t.innerType._zod.run(r,n);if(s instanceof Promise)return s.then((i)=>Ja(i,o));return Ja(s,o)}if(r.value===void 0)return r;return t.innerType._zod.run(r,n)}}),Zu=d("$ZodExactOptional",(e,t)=>{is.init(e,t),w(e._zod,"values",()=>t.innerType._zod.values),w(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Pu=d("$ZodNullable",(e,t)=>{T.init(e,t),w(e._zod,"optin",()=>t.innerType._zod.optin),w(e._zod,"optout",()=>t.innerType._zod.optout),w(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${or(r.source)}|null)$`):void 0}),w(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>{if(r.value===null)return r;return t.innerType._zod.run(r,n)}}),Cu=d("$ZodDefault",(e,t)=>{T.init(e,t),e._zod.optin="optional",w(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>qa(s,t));return qa(o,t)}});function qa(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Nu=d("$ZodPrefault",(e,t)=>{T.init(e,t),e._zod.optin="optional",w(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,n)}}),Uu=d("$ZodNonOptional",(e,t)=>{T.init(e,t),w(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter((n)=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>Ga(s,e));return Ga(o,e)}});function Ga(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t});return e}var Du=d("$ZodCatch",(e,t)=>{T.init(e,t),e._zod.optin="optional",w(e._zod,"optout",()=>t.innerType._zod.optout),w(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>{if(r.value=s.value,s.issues.length)r.value=t.catchValue({...r,error:{issues:s.issues.map((i)=>ye(i,n,ze()))},input:r.value}),r.issues=[],r.fallback=!0;return r});if(r.value=o.value,o.issues.length)r.value=t.catchValue({...r,error:{issues:o.issues.map((s)=>ye(s,n,ze()))},input:r.value}),r.issues=[],r.fallback=!0;return r}});var Ru=d("$ZodPipe",(e,t)=>{T.init(e,t),w(e._zod,"values",()=>t.in._zod.values),w(e._zod,"optin",()=>t.in._zod.optin),w(e._zod,"optout",()=>t.out._zod.optout),w(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=t.out._zod.run(r,n);if(s instanceof Promise)return s.then((i)=>_n(i,t.in,n));return _n(s,t.in,n)}let o=t.in._zod.run(r,n);if(o instanceof Promise)return o.then((s)=>_n(s,t.out,n));return _n(o,t.out,n)}});function _n(e,t,r){if(e.issues.length)return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}var ju=d("$ZodReadonly",(e,t)=>{T.init(e,t),w(e._zod,"propValues",()=>t.innerType._zod.propValues),w(e._zod,"values",()=>t.innerType._zod.values),w(e._zod,"optin",()=>t.innerType?._zod?.optin),w(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then(Wa);return Wa(o)}});function Wa(e){return e.value=Object.freeze(e.value),e}var Lu=d("$ZodCustom",(e,t)=>{L.init(e,t),T.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=(r)=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then((s)=>Ka(s,r,n,e));Ka(o,r,n,e);return}});function Ka(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};if(n._zod.def.params)o.params=n._zod.def.params;t.issues.push(bt(o))}}var Bu,my=Symbol("ZodOutput"),gy=Symbol("ZodInput");class Mu{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];if(this._map.set(e,r),r&&typeof r==="object"&&"id"in r)this._idmap.set(r.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t==="object"&&"id"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Bf(){return new Mu}(Bu=globalThis).__zod_globalRegistry??(Bu.__zod_globalRegistry=Bf());var Ke=globalThis.__zod_globalRegistry;function Vu(e,t){return new e({type:"string",...g(t)})}function Fu(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...g(t)})}function cs(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...g(t)})}function Ju(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...g(t)})}function qu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...g(t)})}function Gu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...g(t)})}function Wu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...g(t)})}function Ku(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...g(t)})}function Hu(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...g(t)})}function Yu(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...g(t)})}function Xu(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...g(t)})}function Qu(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...g(t)})}function el(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...g(t)})}function tl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...g(t)})}function rl(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...g(t)})}function nl(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...g(t)})}function ol(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...g(t)})}function sl(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...g(t)})}function il(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...g(t)})}function cl(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...g(t)})}function al(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...g(t)})}function ul(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...g(t)})}function ll(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...g(t)})}function pl(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...g(t)})}function hl(e,t){return new e({type:"string",format:"date",check:"string_format",...g(t)})}function dl(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...g(t)})}function fl(e,t){return new e({type:"string",format:"duration",check:"string_format",...g(t)})}function ml(e,t){return new e({type:"number",checks:[],...g(t)})}function gl(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...g(t)})}function yl(e){return new e({type:"unknown"})}function xl(e,t){return new e({type:"never",...g(t)})}function kn(e,t){return new es({check:"less_than",...g(t),value:e,inclusive:!1})}function lr(e,t){return new es({check:"less_than",...g(t),value:e,inclusive:!0})}function vn(e,t){return new ts({check:"greater_than",...g(t),value:e,inclusive:!1})}function pr(e,t){return new ts({check:"greater_than",...g(t),value:e,inclusive:!0})}function zn(e,t){return new Ia({check:"multiple_of",...g(t),value:e})}function $n(e,t){return new Aa({check:"max_length",...g(t),maximum:e})}function kt(e,t){return new Oa({check:"min_length",...g(t),minimum:e})}function Sn(e,t){return new Za({check:"length_equals",...g(t),length:e})}function as(e,t){return new Pa({check:"string_format",format:"regex",...g(t),pattern:e})}function us(e){return new Ca({check:"string_format",format:"lowercase",...g(e)})}function ls(e){return new Na({check:"string_format",format:"uppercase",...g(e)})}function ps(e,t){return new Ua({check:"string_format",format:"includes",...g(t),includes:e})}function hs(e,t){return new Da({check:"string_format",format:"starts_with",...g(t),prefix:e})}function ds(e,t){return new Ra({check:"string_format",format:"ends_with",...g(t),suffix:e})}function Pe(e){return new ja({check:"overwrite",tx:e})}function fs(e){return Pe((t)=>t.normalize(e))}function ms(){return Pe((e)=>e.trim())}function gs(){return Pe((e)=>e.toLowerCase())}function ys(){return Pe((e)=>e.toUpperCase())}function xs(){return Pe((e)=>Jo(e))}function _l(e,t,r){return new e({type:"array",element:t,...g(r)})}function wl(e,t,r){return new e({type:"custom",check:"custom",fn:t,...g(r)})}function bl(e,t){let r=Mf((n)=>(n.addIssue=(o)=>{if(typeof o==="string")n.issues.push(bt(o,n.value,r._zod.def));else{let s=o;if(s.fatal)s.continue=!1;s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(bt(s))}},e(n.value,n)),t);return r}function Mf(e,t){let r=new L({check:"custom",...g(t)});return r._zod.check=e,r}function _s(e){let t=e?.target??"draft-2020-12";if(t==="draft-4")t="draft-04";if(t==="draft-7")t="draft-07";return{processors:e.processors??{},metadataRegistry:e?.metadata??Ke,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function R(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s=t.seen.get(e);if(s){if(s.count++,r.schemaPath.includes(e))s.cycle=r.path;return s.schema}let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i);let c=e._zod.toJSONSchema?.();if(c)i.schema=c;else{let u={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,u);else{let p=i.schema,f=t.processors[o.type];if(!f)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(e,t,p,u)}let h=e._zod.parent;if(h){if(!i.ref)i.ref=h;R(h,t,u),t.seen.get(h).isParent=!0}}let a=t.metadataRegistry.get(e);if(a)Object.assign(i.schema,a);if(t.io==="input"&&W(e))delete i.schema.examples,delete i.schema.default;if(t.io==="input"&&"_prefault"in i.schema)(n=i.schema).default??(n.default=i.schema._prefault);return delete i.schema._prefault,t.seen.get(e).schema}function ws(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let n=new Map;for(let i of e.seen.entries()){let c=e.metadataRegistry.get(i[0])?.id;if(c){let a=n.get(c);if(a&&a!==i[0])throw Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(c,i[0])}}let o=(i)=>{let c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let h=e.external.registry.get(i[0])?.id,p=e.external.uri??((m)=>m);if(h)return{ref:p(h)};let f=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=f,{defId:f,ref:`${p("__shared")}#/${c}/${f}`}}if(i[1]===r)return{ref:"#"};let l=`${"#"}/${c}/`,u=i[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+u}},s=(i)=>{if(i[1].schema.$ref)return;let c=i[1],{ref:a,defId:l}=o(i);if(c.def={...c.schema},l)c.defId=l;let u=c.schema;for(let h in u)delete u[h];u.$ref=a};if(e.cycles==="throw")for(let i of e.seen.entries()){let c=i[1];if(c.cycle)throw Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
67
67
 
68
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let c=i[1];if(t===i[0]){s(i);continue}if(e.external){let l=e.external.registry.get(i[0])?.id;if(t!==i[0]&&l){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(c.cycle){s(i);continue}if(c.count>1){if(e.reused==="ref"){s(i);continue}}}}function bs(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let n=(c)=>{let a=e.seen.get(c);if(a.ref===null)return;let l=a.def??a.schema,u={...l},h=a.ref;if(a.ref=null,h){n(h);let f=e.seen.get(h),m=f.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(m);else Object.assign(l,m);if(Object.assign(l,u),c._zod.parent===h)for(let z in l){if(z==="$ref"||z==="allOf")continue;if(!(z in u))delete l[z]}if(m.$ref&&f.def)for(let z in l){if(z==="$ref"||z==="allOf")continue;if(z in f.def&&JSON.stringify(l[z])===JSON.stringify(f.def[z]))delete l[z]}}let p=c._zod.parent;if(p&&p!==h){n(p);let f=e.seen.get(p);if(f?.schema.$ref){if(l.$ref=f.schema.$ref,f.def)for(let m in l){if(m==="$ref"||m==="allOf")continue;if(m in f.def&&JSON.stringify(l[m])===JSON.stringify(f.def[m]))delete l[m]}}}e.override({zodSchema:c,jsonSchema:l,path:a.path??[]})};for(let c of[...e.seen.entries()].reverse())n(c[0]);let o={};if(e.target==="draft-2020-12")o.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")o.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")o.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let c=e.external.registry.get(t)?.id;if(!c)throw Error("Schema is missing an `id` property");o.$id=e.external.uri(c)}Object.assign(o,r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&o.id===s)delete o.id;let i=e.external?.defs??{};for(let c of e.seen.entries()){let a=c[1];if(a.def&&a.defId){if(a.def.id===a.defId)delete a.def.id;i[a.defId]=a.def}}if(e.external);else if(Object.keys(i).length>0)if(e.target==="draft-2020-12")o.$defs=i;else o.definitions=i;try{let c=JSON.parse(JSON.stringify(o));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:hr(t,"input",e.processors),output:hr(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch(c){throw Error("Error converting schema to JSON.")}}function W(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return W(n.element,r);if(n.type==="set")return W(n.valueType,r);if(n.type==="lazy")return W(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return W(n.innerType,r);if(n.type==="intersection")return W(n.left,r)||W(n.right,r);if(n.type==="record"||n.type==="map")return W(n.keyType,r)||W(n.valueType,r);if(n.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return W(n.in,r)||W(n.out,r)}if(n.type==="object"){for(let o in n.shape)if(W(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(W(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(W(o,r))return!0;if(n.rest&&W(n.rest,r))return!0;return!1}return!1}var kl=(e,t={})=>(r)=>{let n=_s({...r,processors:t});return R(e,n),ws(n,e),bs(n,e)},hr=(e,t,r={})=>(n)=>{let{libraryOptions:o,target:s}=n??{},i=_s({...o??{},target:s,io:t,processors:r});return R(e,i),ws(i,e),bs(i,e)};var Vf={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},vl=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:c,patterns:a,contentEncoding:l}=e._zod.bag;if(typeof s==="number")o.minLength=s;if(typeof i==="number")o.maxLength=i;if(c){if(o.format=Vf[c]??c,o.format==="")delete o.format;if(c==="time")delete o.format}if(l)o.contentEncoding=l;if(a&&a.size>0){let u=[...a];if(u.length===1)o.pattern=u[0].source;else if(u.length>1)o.allOf=[...u.map((h)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))]}},zl=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,format:c,multipleOf:a,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;if(typeof c==="string"&&c.includes("int"))o.type="integer";else o.type="number";let h=typeof u==="number"&&u>=(s??Number.NEGATIVE_INFINITY),p=typeof l==="number"&&l<=(i??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(h)if(f)o.minimum=u,o.exclusiveMinimum=!0;else o.exclusiveMinimum=u;else if(typeof s==="number")o.minimum=s;if(p)if(f)o.maximum=l,o.exclusiveMaximum=!0;else o.exclusiveMaximum=l;else if(typeof i==="number")o.maximum=i;if(typeof a==="number")o.multipleOf=a};var $l=(e,t,r,n)=>{r.not={}};var Sl=(e,t,r,n)=>{};var El=(e,t,r,n)=>{let o=e._zod.def,s=rr(o.entries);if(s.every((i)=>typeof i==="number"))r.type="number";if(s.every((i)=>typeof i==="string"))r.type="string";r.enum=s},Il=(e,t,r,n)=>{let o=e._zod.def,s=[];for(let i of o.values)if(i===void 0){if(t.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i==="bigint")if(t.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else s.push(Number(i));else s.push(i);if(s.length===0);else if(s.length===1){let i=s[0];if(r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0")r.enum=[i];else r.const=i}else{if(s.every((i)=>typeof i==="number"))r.type="number";if(s.every((i)=>typeof i==="string"))r.type="string";if(s.every((i)=>typeof i==="boolean"))r.type="boolean";if(s.every((i)=>i===null))r.type="null";r.enum=s}};var Tl=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")};var Al=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")};var Ol=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:c}=e._zod.bag;if(typeof i==="number")o.minItems=i;if(typeof c==="number")o.maxItems=c;o.type="array",o.items=R(s.element,t,{...n,path:[...n.path,"items"]})},Zl=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object",o.properties={};let i=s.shape;for(let l in i)o.properties[l]=R(i[l],t,{...n,path:[...n.path,"properties",l]});let c=new Set(Object.keys(i)),a=new Set([...c].filter((l)=>{let u=s.shape[l]._zod;if(t.io==="input")return u.optin===void 0;else return u.optout===void 0}));if(a.size>0)o.required=Array.from(a);if(s.catchall?._zod.def.type==="never")o.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")o.additionalProperties=!1}else if(s.catchall)o.additionalProperties=R(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})},Pl=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((c,a)=>R(c,t,{...n,path:[...n.path,s?"oneOf":"anyOf",a]}));if(s)r.oneOf=i;else r.anyOf=i},Cl=(e,t,r,n)=>{let o=e._zod.def,s=R(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=R(o.right,t,{...n,path:[...n.path,"allOf",1]}),c=(l)=>("allOf"in l)&&Object.keys(l).length===1,a=[...c(s)?s.allOf:[s],...c(i)?i.allOf:[i]];r.allOf=a};var Nl=(e,t,r,n)=>{let o=e._zod.def,s=R(o.innerType,t,n),i=t.seen.get(e);if(t.target==="openapi-3.0")i.ref=o.innerType,r.nullable=!0;else r.anyOf=[s,{type:"null"}]},Ul=(e,t,r,n)=>{let o=e._zod.def;R(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},Dl=(e,t,r,n)=>{let o=e._zod.def;R(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},Rl=(e,t,r,n)=>{let o=e._zod.def;R(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io==="input")r._prefault=JSON.parse(JSON.stringify(o.defaultValue))},jl=(e,t,r,n)=>{let o=e._zod.def;R(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}r.default=i},Ll=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;R(i,t,n);let c=t.seen.get(e);c.ref=i},Bl=(e,t,r,n)=>{let o=e._zod.def;R(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var ks=(e,t,r,n)=>{let o=e._zod.def;R(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType};var Hf=d("ZodISODateTime",(e,t)=>{cu.init(e,t),E.init(e,t)});function Ml(e){return pl(Hf,e)}var Yf=d("ZodISODate",(e,t)=>{au.init(e,t),E.init(e,t)});function Vl(e){return hl(Yf,e)}var Xf=d("ZodISOTime",(e,t)=>{uu.init(e,t),E.init(e,t)});function Fl(e){return dl(Xf,e)}var Qf=d("ZodISODuration",(e,t)=>{lu.init(e,t),E.init(e,t)});function Jl(e){return fl(Qf,e)}var rm=(e,t)=>{mn.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:(r)=>Vc(e,r)},flatten:{value:(r)=>Mc(e,r)},addIssue:{value:(r)=>{e.issues.push(r),e.message=JSON.stringify(e.issues,_t,2)}},addIssues:{value:(r)=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,_t,2)}},isEmpty:{get(){return e.issues.length===0}}})};var ne=d("ZodError",rm,{Parent:Error});var ql=gn(ne),Gl=xn(ne),Wl=cr(ne),Kl=ar(ne),Hl=qc(ne),Yl=Gc(ne),Xl=Wc(ne),Ql=Kc(ne),ep=Hc(ne),tp=Yc(ne),rp=Xc(ne),np=Qc(ne);var op=new WeakMap;function dr(e,t,r){let n=Object.getPrototypeOf(e),o=op.get(n);if(!o)o=new Set,op.set(n,o);if(o.has(t))return;o.add(t);for(let s in r){let i=r[s];Object.defineProperty(n,s,{configurable:!0,enumerable:!1,get(){let c=i.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:c}),c},set(c){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:c})}})}}var A=d("ZodType",(e,t)=>(T.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:hr(e,"input"),output:hr(e,"output")}}),e.toJSONSchema=kl(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,n)=>ql(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Wl(e,r,n),e.parseAsync=async(r,n)=>Gl(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Kl(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>Hl(e,r,n),e.decode=(r,n)=>Yl(e,r,n),e.encodeAsync=async(r,n)=>Xl(e,r,n),e.decodeAsync=async(r,n)=>Ql(e,r,n),e.safeEncode=(r,n)=>ep(e,r,n),e.safeDecode=(r,n)=>tp(e,r,n),e.safeEncodeAsync=async(r,n)=>rp(e,r,n),e.safeDecodeAsync=async(r,n)=>np(e,r,n),dr(e,"ZodType",{check(...r){let n=this.def;return this.clone(b.mergeDefs(n,{checks:[...n.checks??[],...r.map((o)=>typeof o==="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return ce(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(Km(r,n))},superRefine(r,n){return this.check(Hm(r,n))},overwrite(r){return this.check(Pe(r))},optional(){return cp(this)},exactOptional(){return Um(this)},nullable(){return ap(this)},nullish(){return cp(ap(this))},nonoptional(r){return Mm(this,r)},array(){return fr(this)},or(r){return $s([this,r])},and(r){return Am(this,r)},transform(r){return up(this,Cm(r))},default(r){return jm(this,r)},prefault(r){return Bm(this,r)},catch(r){return Fm(this,r)},pipe(r){return up(this,r)},readonly(){return Gm(this)},describe(r){let n=this.clone();return Ke.add(n,{description:r}),n},meta(...r){if(r.length===0)return Ke.get(this);let n=this.clone();return Ke.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return Ke.get(e)?.description},configurable:!0}),e)),lp=d("_ZodString",(e,t)=>{bn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,o,s)=>vl(e,n,o,s);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,dr(e,"_ZodString",{regex(...n){return this.check(as(...n))},includes(...n){return this.check(ps(...n))},startsWith(...n){return this.check(hs(...n))},endsWith(...n){return this.check(ds(...n))},min(...n){return this.check(kt(...n))},max(...n){return this.check($n(...n))},length(...n){return this.check(Sn(...n))},nonempty(...n){return this.check(kt(1,...n))},lowercase(n){return this.check(us(n))},uppercase(n){return this.check(ls(n))},trim(){return this.check(ms())},normalize(...n){return this.check(fs(...n))},toLowerCase(){return this.check(gs())},toUpperCase(){return this.check(xs())},slugify(){return this.check(ys())}})}),om=d("ZodString",(e,t)=>{bn.init(e,t),lp.init(e,t),e.email=(r)=>e.check(Fu(sm,r)),e.url=(r)=>e.check(Ku(im,r)),e.jwt=(r)=>e.check(ll(bm,r)),e.emoji=(r)=>e.check(Hu(cm,r)),e.guid=(r)=>e.check(cs(sp,r)),e.uuid=(r)=>e.check(Ju(In,r)),e.uuidv4=(r)=>e.check(qu(In,r)),e.uuidv6=(r)=>e.check(Gu(In,r)),e.uuidv7=(r)=>e.check(Wu(In,r)),e.nanoid=(r)=>e.check(Yu(am,r)),e.guid=(r)=>e.check(cs(sp,r)),e.cuid=(r)=>e.check(Xu(um,r)),e.cuid2=(r)=>e.check(Qu(lm,r)),e.ulid=(r)=>e.check(el(pm,r)),e.base64=(r)=>e.check(cl(ym,r)),e.base64url=(r)=>e.check(al(_m,r)),e.xid=(r)=>e.check(tl(hm,r)),e.ksuid=(r)=>e.check(rl(dm,r)),e.ipv4=(r)=>e.check(nl(fm,r)),e.ipv6=(r)=>e.check(ol(mm,r)),e.cidrv4=(r)=>e.check(sl(gm,r)),e.cidrv6=(r)=>e.check(il(xm,r)),e.e164=(r)=>e.check(ul(wm,r)),e.datetime=(r)=>e.check(Ml(r)),e.date=(r)=>e.check(Vl(r)),e.time=(r)=>e.check(Fl(r)),e.duration=(r)=>e.check(Jl(r))});function zs(e){return Vu(om,e)}var E=d("ZodStringFormat",(e,t)=>{S.init(e,t),lp.init(e,t)}),sm=d("ZodEmail",(e,t)=>{Xa.init(e,t),E.init(e,t)});var sp=d("ZodGUID",(e,t)=>{Ha.init(e,t),E.init(e,t)});var In=d("ZodUUID",(e,t)=>{Ya.init(e,t),E.init(e,t)});var im=d("ZodURL",(e,t)=>{Qa.init(e,t),E.init(e,t)});var cm=d("ZodEmoji",(e,t)=>{eu.init(e,t),E.init(e,t)});var am=d("ZodNanoID",(e,t)=>{tu.init(e,t),E.init(e,t)});var um=d("ZodCUID",(e,t)=>{ru.init(e,t),E.init(e,t)});var lm=d("ZodCUID2",(e,t)=>{nu.init(e,t),E.init(e,t)});var pm=d("ZodULID",(e,t)=>{ou.init(e,t),E.init(e,t)});var hm=d("ZodXID",(e,t)=>{su.init(e,t),E.init(e,t)});var dm=d("ZodKSUID",(e,t)=>{iu.init(e,t),E.init(e,t)});var fm=d("ZodIPv4",(e,t)=>{pu.init(e,t),E.init(e,t)});var mm=d("ZodIPv6",(e,t)=>{hu.init(e,t),E.init(e,t)});var gm=d("ZodCIDRv4",(e,t)=>{du.init(e,t),E.init(e,t)});var xm=d("ZodCIDRv6",(e,t)=>{fu.init(e,t),E.init(e,t)});var ym=d("ZodBase64",(e,t)=>{gu.init(e,t),E.init(e,t)});var _m=d("ZodBase64URL",(e,t)=>{xu.init(e,t),E.init(e,t)});var wm=d("ZodE164",(e,t)=>{yu.init(e,t),E.init(e,t)});var bm=d("ZodJWT",(e,t)=>{_u.init(e,t),E.init(e,t)});var pp=d("ZodNumber",(e,t)=>{os.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,o,s)=>zl(e,n,o,s),dr(e,"ZodNumber",{gt(n,o){return this.check(vn(n,o))},gte(n,o){return this.check(pr(n,o))},min(n,o){return this.check(pr(n,o))},lt(n,o){return this.check(kn(n,o))},lte(n,o){return this.check(lr(n,o))},max(n,o){return this.check(lr(n,o))},int(n){return this.check(ip(n))},safe(n){return this.check(ip(n))},positive(n){return this.check(vn(0,n))},nonnegative(n){return this.check(pr(0,n))},negative(n){return this.check(kn(0,n))},nonpositive(n){return this.check(lr(0,n))},multipleOf(n,o){return this.check(zn(n,o))},step(n,o){return this.check(zn(n,o))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??0.5),e.isFinite=!0,e.format=r.format??null});function vt(e){return ml(pp,e)}var km=d("ZodNumberFormat",(e,t)=>{wu.init(e,t),pp.init(e,t)});function ip(e){return gl(km,e)}var vm=d("ZodUnknown",(e,t)=>{bu.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Sl(e,r,n,o)});function Tn(){return xl(vm)}var zm=d("ZodNever",(e,t)=>{ku.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>$l(e,r,n,o)});function $m(e){return yl(zm,e)}var Sm=d("ZodArray",(e,t)=>{vu.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ol(e,r,n,o),e.element=t.element,dr(e,"ZodArray",{min(r,n){return this.check(kt(r,n))},nonempty(r){return this.check(kt(1,r))},max(r,n){return this.check($n(r,n))},length(r,n){return this.check(Sn(r,n))},unwrap(){return this.element}})});function fr(e,t){return _l(Sm,e,t)}var Em=d("ZodObject",(e,t)=>{Su.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Zl(e,r,n,o),b.defineLazy(e,"shape",()=>t.shape),dr(e,"ZodObject",{keyof(){return Om(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:Tn()})},loose(){return this.clone({...this._zod.def,catchall:Tn()})},strict(){return this.clone({...this._zod.def,catchall:$m()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return b.extend(this,r)},safeExtend(r){return b.safeExtend(this,r)},merge(r){return b.merge(this,r)},pick(r){return b.pick(this,r)},omit(r){return b.omit(this,r)},partial(...r){return b.partial(fp,this,r[0])},required(...r){return b.required(mp,this,r[0])}})});function zt(e,t){let r={type:"object",shape:e??{},...b.normalizeParams(t)};return new Em(r)}var hp=d("ZodUnion",(e,t)=>{ss.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Pl(e,r,n,o),e.options=t.options});function $s(e,t){return new hp({type:"union",options:e,...b.normalizeParams(t)})}var Im=d("ZodDiscriminatedUnion",(e,t)=>{hp.init(e,t),Eu.init(e,t)});function dp(e,t,r){return new Im({type:"union",options:t,discriminator:e,...b.normalizeParams(r)})}var Tm=d("ZodIntersection",(e,t)=>{Iu.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Cl(e,r,n,o)});function Am(e,t){return new Tm({type:"intersection",left:e,right:t})}var vs=d("ZodEnum",(e,t)=>{Tu.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,o,s)=>El(e,n,o,s),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw Error(`Key ${i} not found in enum`);return new vs({...t,checks:[],...b.normalizeParams(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let i of n)if(r.has(i))delete s[i];else throw Error(`Key ${i} not found in enum`);return new vs({...t,checks:[],...b.normalizeParams(o),entries:s})}});function Om(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new vs({type:"enum",entries:r,...b.normalizeParams(t)})}var Zm=d("ZodLiteral",(e,t)=>{Au.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Il(e,r,n,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function $t(e,t){return new Zm({type:"literal",values:Array.isArray(e)?e:[e],...b.normalizeParams(t)})}var Pm=d("ZodTransform",(e,t)=>{Ou.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Al(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new er(e.constructor.name);r.addIssue=(s)=>{if(typeof s==="string")r.issues.push(b.issue(s,r.value,t));else{let i=s;if(i.fatal)i.continue=!1;i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=e),r.issues.push(b.issue(i))}};let o=t.transform(r.value,r);if(o instanceof Promise)return o.then((s)=>(r.value=s,r.fallback=!0,r));return r.value=o,r.fallback=!0,r}});function Cm(e){return new Pm({type:"transform",transform:e})}var fp=d("ZodOptional",(e,t)=>{is.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ks(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function cp(e){return new fp({type:"optional",innerType:e})}var Nm=d("ZodExactOptional",(e,t)=>{Zu.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ks(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Um(e){return new Nm({type:"optional",innerType:e})}var Dm=d("ZodNullable",(e,t)=>{Pu.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Nl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ap(e){return new Dm({type:"nullable",innerType:e})}var Rm=d("ZodDefault",(e,t)=>{Cu.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Dl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function jm(e,t){return new Rm({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():b.shallowClone(t)}})}var Lm=d("ZodPrefault",(e,t)=>{Nu.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Rl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Bm(e,t){return new Lm({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():b.shallowClone(t)}})}var mp=d("ZodNonOptional",(e,t)=>{Uu.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ul(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Mm(e,t){return new mp({type:"nonoptional",innerType:e,...b.normalizeParams(t)})}var Vm=d("ZodCatch",(e,t)=>{Du.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>jl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Fm(e,t){return new Vm({type:"catch",innerType:e,catchValue:typeof t==="function"?t:()=>t})}var Jm=d("ZodPipe",(e,t)=>{Ru.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ll(e,r,n,o),e.in=t.in,e.out=t.out});function up(e,t){return new Jm({type:"pipe",in:e,out:t})}var qm=d("ZodReadonly",(e,t)=>{ju.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Gm(e){return new qm({type:"readonly",innerType:e})}var Wm=d("ZodCustom",(e,t)=>{Lu.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Tl(e,r,n,o)});function Km(e,t={}){return wl(Wm,e,t)}function Hm(e,t){return bl(e,t)}var gr=32,Cn=new Set(["__proto__","constructor","prototype"]),Ym=$s([zs().min(1).max(512).refine((e)=>!Cn.has(e),"unsafe path key"),vt().int().nonnegative()]),mr=fr(Ym).min(1).max(gr);function xr(e,t=0){if(t>gr)return!1;if(e===null||typeof e==="boolean"||typeof e==="string")return!0;if(typeof e==="number")return Number.isFinite(e);if(Array.isArray(e))return e.every((n)=>xr(n,t+1));if(typeof e!=="object")return!1;let r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null)return!1;return Object.entries(e).every(([n,o])=>!Cn.has(n)&&xr(o,t+1))}var gp=Tn().refine(xr,"value must be safe JSON"),Xm=dp("type",[zt({type:$t("set"),path:mr,value:gp}),zt({type:$t("delete"),path:mr}),zt({type:$t("insert"),path:mr,index:vt().int().nonnegative(),values:fr(gp).min(1)}),zt({type:$t("increment"),path:mr,by:vt().finite()}),zt({type:$t("text"),path:mr,index:vt().int().nonnegative(),deleteCount:vt().int().nonnegative().optional(),insert:zs().optional()})]).superRefine((e,t)=>{if(e.type==="text"&&(e.deleteCount??0)===0&&(e.insert??"").length===0)t.addIssue({code:"custom",message:"text operation must insert or delete content"})});function Zn(e){if(Array.isArray(e)){let t=new re;return t.insert(0,e.map(Zn)),t}if(e!==null&&typeof e==="object"){let t=new G;for(let[r,n]of Object.entries(e))t.set(r,Zn(n));return t}return e}function Ss(e,t=0){if(t>gr)throw Error("room document exceeds the maximum nesting depth");if(e instanceof G){let r=Object.create(null);for(let[n,o]of e.entries()){if(Cn.has(n))throw Error(`room document contains unsafe key "${n}"`);r[n]=Ss(o,t+1)}return r}if(e instanceof re)return e.toArray().map((r)=>Ss(r,t+1));if(e instanceof ie)return e.toString();if(!xr(e))throw Error("room document contains a non-JSON value");return e}function Nn(e){return Ss(e.getMap("root"))}function B(e){return e.map(String).join(".")}function wp(e){if(e.length===0||e.length>gr)throw Error(`room path must contain 1 to ${gr} segments`);for(let t of e)if(typeof t==="string"){if(t.length===0||t.length>512||Cn.has(t))throw Error(`invalid room path segment "${t}"`)}else if(!Number.isInteger(t)||t<0)throw Error(`invalid room array index ${String(t)}`)}function bp(e,t,r){if(e instanceof G){if(typeof t!=="string")throw Error(`expected an object key at "${B(r)}"`);if(!e.has(t))throw Error(`room path does not exist: "${B(r)}"`);return e.get(t)}if(typeof t!=="number"||t>=e.length)throw Error(`invalid array index at "${B(r)}"`);return e.get(t)}function Un(e,t){wp(t);let r=e.getMap("root");for(let n=0;n<t.length-1;n+=1){if(!(r instanceof G)&&!(r instanceof re))throw Error(`room path crosses a scalar at "${B(t.slice(0,n+1))}"`);r=bp(r,t[n],t.slice(0,n+1))}if(!(r instanceof G)&&!(r instanceof re))throw Error(`room path parent is not a container: "${B(t)}"`);return{parent:r,key:t[t.length-1]}}function An(e,t){let{parent:r,key:n}=Un(e,t);return bp(r,n,t)}function xp(e,t,r){let{parent:n,key:o}=Un(e,t),s=Zn(r);if(n instanceof G){if(typeof o!=="string")throw Error(`expected an object key at "${B(t)}"`);n.set(o,s);return}if(typeof o!=="number"||o>=n.length)throw Error(`invalid array index at "${B(t)}"`);n.delete(o,1),n.insert(o,[s])}function Qm(e,t){let{parent:r,key:n}=Un(e,t);if(r instanceof G){if(typeof n!=="string")throw Error(`expected an object key at "${B(t)}"`);if(!r.has(n))throw Error(`room path does not exist: "${B(t)}"`);r.delete(n);return}if(typeof n!=="number"||n>=r.length)throw Error(`invalid array index at "${B(t)}"`);r.delete(n,1)}function yp(e,t){e.transact(()=>{for(let r of t)switch(r.type){case"set":xp(e,r.path,r.value);break;case"delete":Qm(e,r.path);break;case"insert":{wp(r.path);let n=An(e,r.path);if(!(n instanceof re))throw Error(`insert target is not an array: "${B(r.path)}"`);if(r.index>n.length)throw Error(`insert index is outside the array: "${B(r.path)}"`);n.insert(r.index,r.values.map(Zn));break}case"increment":{let n=An(e,r.path);if(typeof n!=="number"||!Number.isFinite(n))throw Error(`increment target is not a finite number: "${B(r.path)}"`);let o=n+r.by;if(!Number.isFinite(o))throw Error(`increment result is not finite: "${B(r.path)}"`);xp(e,r.path,o);break}case"text":{let n=An(e,r.path),o;if(n instanceof ie)o=n;else if(typeof n==="string"){o=new ie(n);let{parent:i,key:c}=Un(e,r.path);if(i instanceof G&&typeof c==="string")i.set(c,o);else if(i instanceof re&&typeof c==="number"&&c<i.length)i.delete(c,1),i.insert(c,[o]);else throw Error(`invalid text path: "${B(r.path)}"`)}else throw Error(`text target is not a string: "${B(r.path)}"`);let s=r.deleteCount??0;if(r.index>o.length||r.index+s>o.length)throw Error(`text range is outside the string: "${B(r.path)}"`);if(s>0)o.delete(r.index,s);if(r.insert)o.insert(r.index,r.insert);break}}})}function eg(e,t){let r=fr(Xm).min(1).parse(t),n=new ge({gc:!0});try{sn(n,gt(e)),yp(n,r),Nn(n)}finally{n.destroy()}let o=Yi(e);return yp(e,r),gt(e,o)}function Pn(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((o,s)=>Pn(o,t[s]));if(e===null||t===null||typeof e!=="object"||typeof t!=="object")return!1;let r=Object.keys(e),n=Object.keys(t);return r.length===n.length&&r.every((o)=>Object.hasOwn(t,o)&&Pn(e[o],t[o]))}function tg(e,t){if(Pn(e,t))return!0;if(e!==null&&t!==null&&!Array.isArray(e)&&!Array.isArray(t)&&typeof e==="object"&&typeof t==="object"&&Object.hasOwn(e,"id")&&Object.hasOwn(t,"id")){let r=e.id;return(typeof r==="string"||typeof r==="number")&&Object.is(r,t.id)}return!1}function Es(e){if(e!==null&&!Array.isArray(e)&&typeof e==="object"&&(typeof e.id==="string"||typeof e.id==="number"))return`id:${typeof e.id}:${String(e.id)}`;return`value:${JSON.stringify(e)}`}function _p(e){let t=[],r=new Set;for(let n of e){if(n===null||Array.isArray(n)||typeof n!=="object"||typeof n.id!=="string"&&typeof n.id!=="number")return null;let o=Es(n);if(r.has(o))return null;r.add(o),t.push(o)}return t}function rg(e,t){let r=new Map;for(let s=0;s<t.length;s+=1){let i=Es(t[s]),c=r.get(i);if(c)c.push(s);else r.set(i,[s])}let n=[],o=-1;for(let s=0;s<e.length;s+=1){let i=r.get(Es(e[s]));while(i?.length&&i[0]<=o)i.shift();let c=i?.shift();if(c===void 0)continue;if(!tg(e[s],t[c]))continue;n.push([s,c]),o=c}return n}function ng(e,t){try{return An(e,t)}catch{return}}function On(e,t,r,n,o){if(Pn(t,r))return;if(t!==null&&r!==null&&!Array.isArray(t)&&!Array.isArray(r)&&typeof t==="object"&&typeof r==="object"){for(let s of Object.keys(t))if(!Object.hasOwn(r,s))o.push({type:"delete",path:[...n,s]});for(let[s,i]of Object.entries(r))if(!Object.hasOwn(t,s))o.push({type:"set",path:[...n,s],value:i});else On(e,t[s],i,[...n,s],o);return}if(Array.isArray(t)&&Array.isArray(r)){let s=_p(t),i=_p(r),c=s!==null&&i!==null&&(s.length!==i.length||s.some((h,p)=>h!==i[p]));if(t.length===r.length&&!c){for(let h=0;h<r.length;h+=1)On(e,t[h],r[h],[...n,h],o);return}let a=0,l=0,u=0;for(let[h,p]of[...rg(t,r),[t.length,r.length]]){let f=h-a;for(let k=0;k<f;k+=1)o.push({type:"delete",path:[...n,u]});let m=r.slice(l,p);if(m.length>0)o.push({type:"insert",path:n,index:u,values:m}),u+=m.length;if(h<t.length&&p<r.length)On(e,t[h],r[p],[...n,u],o),u+=1;a=h+1,l=p+1}return}if(typeof t==="string"&&typeof r==="string"&&ng(e,n)instanceof ie){let s=0;while(s<t.length&&s<r.length&&t[s]===r[s])s+=1;let i=0;while(i<t.length-s&&i<r.length-s&&t[t.length-1-i]===r[r.length-1-i])i+=1;o.push({type:"text",path:n,index:s,deleteCount:t.length-s-i,insert:r.slice(s,r.length-i)});return}o.push({type:"set",path:n,value:r})}function kp(e,t){let r=Nn(e),n=structuredClone(r),o=t(n);if(o!==null&&(typeof o==="object"||typeof o==="function")&&typeof o.then==="function")throw Error("room change callback must be synchronous");if(!xr(n)||Array.isArray(n))throw Error("room state must be a safe JSON object");let s=[];if(On(e,r,n,[],s),s.length>0)eg(e,s);return s}function vp(e){let t="";for(let r=0;r<e.length;r+=8192)t+=String.fromCharCode(...e.subarray(r,r+8192));return btoa(t)}function og(e){return Uint8Array.from(atob(e),(t)=>t.charCodeAt(0))}class Dn{handlers=new Map;on(e,t){let r=this.handlers.get(e)??new Set;return r.add(t),this.handlers.set(e,r),()=>r.delete(t)}emit(e,t){for(let r of this.handlers.get(e)??[])r(t)}}class zp extends Dn{socket;rooms=new Map;channels=new Map;pending=new Map;nextId=0;opening;retry;stopped=!1;me;async open(){if(this.socket?.readyState===WebSocket.OPEN)return;if(this.opening)return this.opening;let e=location.pathname.match(/^\/p\/([^/.]+)/);if(!e)throw Error("Realtime rooms require a Swarm page");let t=new URL("/@swarm/realtime",location.href);return t.protocol=location.protocol==="https:"?"wss:":"ws:",t.searchParams.set("pageId",decodeURIComponent(e[1])),this.opening=new Promise((r,n)=>{let o=new WebSocket(t);this.socket=o,o.onopen=()=>{this.opening=void 0,r()},o.onerror=()=>n(Error("Realtime connection failed")),o.onmessage=(s)=>{let i=JSON.parse(s.data);if(i.seq)o.send(JSON.stringify({ack:i.seq}));if(i.type==="hello")this.me=i.me;if(i.type==="room")this.rooms.get(i.name??"")?.receive(i);if(i.type==="presence")this.rooms.get(i.name??"")?.receivePresence(i.peers);if(i.type==="channel")this.channels.get(i.name??"")?.emit("message",i.data);if(i.type==="deleted")this.rooms.get(i.name??"")?.deleted();if(i.id!==void 0){let c=this.pending.get(i.id);if(c)if(clearTimeout(c.timer),this.pending.delete(i.id),i.type==="error")c.reject(Error(i.error));else c.resolve(i)}},o.onclose=()=>{this.opening=void 0,n(Error("Realtime connection closed"));for(let s of this.pending.values())clearTimeout(s.timer),s.reject(Error("Realtime connection closed"));if(this.pending.clear(),!this.stopped)this.retry=setTimeout(()=>{this.reconnect()},1000)}}),this.opening}async reconnect(){try{await this.open();for(let e of this.rooms.values())await e.join(!0);for(let e of this.channels.keys())await this.request({op:"subscribe",name:e})}catch(e){for(let t of this.rooms.values())t.emit("error",e)}}async request(e){await this.open();let t=++this.nextId;return new Promise((r,n)=>{let o=setTimeout(()=>{this.pending.delete(t),n(Error("Realtime request timed out"))},15000);this.pending.set(t,{resolve:r,reject:n,timer:o}),this.socket.send(JSON.stringify({...e,id:t}))})}close(){this.stopped=!0,clearTimeout(this.retry),this.socket?.close()}}class $p extends Dn{connection;name;ydoc=new ge({gc:!0});generation="";stale=!1;bytes=0;me;ready;writes=Promise.resolve();lastWrite=Promise.resolve();peers=[];presenceData={};presenceTimer;closed=!1;schemaVersion;presence;constructor(e,t,r){super();this.connection=e;this.name=t;this.schemaVersion=r.schemaVersion??1;let n=this;this.presence={set(o){if(n.presenceData=structuredClone(o),!n.presenceTimer)n.presenceTimer=setTimeout(()=>{n.presenceTimer=void 0,e.request({op:"presence",name:t,data:n.presenceData}).catch((s)=>n.emit("error",s))},50)},get peers(){return n.peers}},this.observe()}get state(){return Nn(this.ydoc)}observe(){this.ydoc.on("update",(e,t)=>{if(this.emit("change",this.state),t==="remote"||!this.generation||this.closed)return;if(this.connection.socket?.readyState!==WebSocket.OPEN)return;let r=vp(gt(this.ydoc)),n=this.generation,o=this.writes.then(async()=>{try{let s=await this.connection.request({op:"update",name:this.name,generation:n,schemaVersion:this.schemaVersion,snapshot:r});if(s.room)this.receive(s.room)}catch(s){if(this.connection.socket?.readyState===WebSocket.OPEN){let i=await this.connection.request({op:"join",name:this.name,schemaVersion:this.schemaVersion});this.receive(i.room,!0)}throw this.emit("error",s),s}});this.lastWrite=o,this.writes=o.catch(()=>{})})}async join(e=!1){if(this.ready&&!e)return this.ready;return this.ready=(async()=>{let t=this.generation,r=await this.connection.request({op:"join",name:this.name,schemaVersion:this.schemaVersion});if(this.me=r.me,this.receive(r.room),this.receivePresence(r.peers),e&&t===this.generation&&!this.stale){let n=await this.connection.request({op:"update",name:this.name,schemaVersion:this.schemaVersion,generation:t,snapshot:vp(gt(this.ydoc))});this.receive(n.room)}if(e)this.presence.set(this.presenceData)})(),this.ready}receive(e,t=!1){if(this.closed||!e)return;let r=t||this.generation!==""&&e.generation!==this.generation;if(this.generation=e.generation,this.stale=e.schemaVersion!==this.schemaVersion,this.bytes=e.bytes,r)this.ydoc.destroy(),this.ydoc=new ge({gc:!0}),this.observe();if(sn(this.ydoc,og(e.snapshot),"remote"),r)this.emit("reset",this.state)}receivePresence(e=[]){this.peers=e,this.emit("presence",e)}deleted(){this.closed=!0,this.emit("error",Error("Room owner was deleted")),this.ydoc.destroy()}async change(e){if(this.closed)throw Error("Room is closed");if(this.stale)throw Error("Room schema is stale. Read the state and reset explicitly.");if(kp(this.ydoc,e).length>0)await this.lastWrite}async apply(e){if(this.closed||this.stale)throw Error("Room is closed or stale");await this.writes;let t=await this.connection.request({op:"change",name:this.name,generation:this.generation,schemaVersion:this.schemaVersion,operations:e});this.receive(t.room)}async reset(e={}){if(this.closed)throw Error("Room is closed");await this.writes;let t=await this.connection.request({op:"reset",name:this.name,schemaVersion:this.schemaVersion,state:e});this.receive(t.room)}async close(){this.closed=!0,clearTimeout(this.presenceTimer),this.connection.rooms.delete(this.name);try{await this.connection.request({op:"leave",name:this.name})}finally{this.ydoc.destroy()}}}class Sp extends Dn{connection;name;constructor(e,t){super();this.connection=e;this.name=t}async publish(e){await this.connection.request({op:"publish",name:this.name,data:e})}async close(){this.connection.channels.delete(this.name),await this.connection.request({op:"unsubscribe",name:this.name})}}var ye=new zp;window.addEventListener("pagehide",()=>ye.close());async function h_(e="default",t={}){if(!/^[a-zA-Z0-9_-]{1,64}$/.test(e))throw Error("Invalid room name");let r=ye.rooms.get(e);if(r&&r.schemaVersion!==(t.schemaVersion??1))throw Error("Room already opened with a different schema version");if(!r)r=new $p(ye,e,t),ye.rooms.set(e,r);try{await r.join()}catch(n){throw ye.rooms.delete(e),n}return r}async function d_(e){if(!/^[a-zA-Z0-9_-]{1,64}$/.test(e))throw Error("Invalid channel name");let t=ye.channels.get(e);if(t)return t;let r=new Sp(ye,e);ye.channels.set(e,r);try{await ye.request({op:"subscribe",name:e})}catch(n){throw ye.channels.delete(e),n}return r}export{d_ as channel,h_ as room};
68
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let c=i[1];if(t===i[0]){s(i);continue}if(e.external){let l=e.external.registry.get(i[0])?.id;if(t!==i[0]&&l){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(c.cycle){s(i);continue}if(c.count>1){if(e.reused==="ref"){s(i);continue}}}}function bs(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let n=(c)=>{let a=e.seen.get(c);if(a.ref===null)return;let l=a.def??a.schema,u={...l},h=a.ref;if(a.ref=null,h){n(h);let f=e.seen.get(h),m=f.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"))l.allOf=l.allOf??[],l.allOf.push(m);else Object.assign(l,m);if(Object.assign(l,u),c._zod.parent===h)for(let z in l){if(z==="$ref"||z==="allOf")continue;if(!(z in u))delete l[z]}if(m.$ref&&f.def)for(let z in l){if(z==="$ref"||z==="allOf")continue;if(z in f.def&&JSON.stringify(l[z])===JSON.stringify(f.def[z]))delete l[z]}}let p=c._zod.parent;if(p&&p!==h){n(p);let f=e.seen.get(p);if(f?.schema.$ref){if(l.$ref=f.schema.$ref,f.def)for(let m in l){if(m==="$ref"||m==="allOf")continue;if(m in f.def&&JSON.stringify(l[m])===JSON.stringify(f.def[m]))delete l[m]}}}e.override({zodSchema:c,jsonSchema:l,path:a.path??[]})};for(let c of[...e.seen.entries()].reverse())n(c[0]);let o={};if(e.target==="draft-2020-12")o.$schema="https://json-schema.org/draft/2020-12/schema";else if(e.target==="draft-07")o.$schema="http://json-schema.org/draft-07/schema#";else if(e.target==="draft-04")o.$schema="http://json-schema.org/draft-04/schema#";else if(e.target==="openapi-3.0");if(e.external?.uri){let c=e.external.registry.get(t)?.id;if(!c)throw Error("Schema is missing an `id` property");o.$id=e.external.uri(c)}Object.assign(o,r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;if(s!==void 0&&o.id===s)delete o.id;let i=e.external?.defs??{};for(let c of e.seen.entries()){let a=c[1];if(a.def&&a.defId){if(a.def.id===a.defId)delete a.def.id;i[a.defId]=a.def}}if(e.external);else if(Object.keys(i).length>0)if(e.target==="draft-2020-12")o.$defs=i;else o.definitions=i;try{let c=JSON.parse(JSON.stringify(o));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:hr(t,"input",e.processors),output:hr(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch(c){throw Error("Error converting schema to JSON.")}}function W(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return W(n.element,r);if(n.type==="set")return W(n.valueType,r);if(n.type==="lazy")return W(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return W(n.innerType,r);if(n.type==="intersection")return W(n.left,r)||W(n.right,r);if(n.type==="record"||n.type==="map")return W(n.keyType,r)||W(n.valueType,r);if(n.type==="pipe"){if(e._zod.traits.has("$ZodCodec"))return!0;return W(n.in,r)||W(n.out,r)}if(n.type==="object"){for(let o in n.shape)if(W(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(W(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(W(o,r))return!0;if(n.rest&&W(n.rest,r))return!0;return!1}return!1}var kl=(e,t={})=>(r)=>{let n=_s({...r,processors:t});return R(e,n),ws(n,e),bs(n,e)},hr=(e,t,r={})=>(n)=>{let{libraryOptions:o,target:s}=n??{},i=_s({...o??{},target:s,io:t,processors:r});return R(e,i),ws(i,e),bs(i,e)};var Vf={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},vl=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:c,patterns:a,contentEncoding:l}=e._zod.bag;if(typeof s==="number")o.minLength=s;if(typeof i==="number")o.maxLength=i;if(c){if(o.format=Vf[c]??c,o.format==="")delete o.format;if(c==="time")delete o.format}if(l)o.contentEncoding=l;if(a&&a.size>0){let u=[...a];if(u.length===1)o.pattern=u[0].source;else if(u.length>1)o.allOf=[...u.map((h)=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))]}},zl=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,format:c,multipleOf:a,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;if(typeof c==="string"&&c.includes("int"))o.type="integer";else o.type="number";let h=typeof u==="number"&&u>=(s??Number.NEGATIVE_INFINITY),p=typeof l==="number"&&l<=(i??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(h)if(f)o.minimum=u,o.exclusiveMinimum=!0;else o.exclusiveMinimum=u;else if(typeof s==="number")o.minimum=s;if(p)if(f)o.maximum=l,o.exclusiveMaximum=!0;else o.exclusiveMaximum=l;else if(typeof i==="number")o.maximum=i;if(typeof a==="number")o.multipleOf=a};var $l=(e,t,r,n)=>{r.not={}};var Sl=(e,t,r,n)=>{};var El=(e,t,r,n)=>{let o=e._zod.def,s=rr(o.entries);if(s.every((i)=>typeof i==="number"))r.type="number";if(s.every((i)=>typeof i==="string"))r.type="string";r.enum=s},Il=(e,t,r,n)=>{let o=e._zod.def,s=[];for(let i of o.values)if(i===void 0){if(t.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i==="bigint")if(t.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else s.push(Number(i));else s.push(i);if(s.length===0);else if(s.length===1){let i=s[0];if(r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0")r.enum=[i];else r.const=i}else{if(s.every((i)=>typeof i==="number"))r.type="number";if(s.every((i)=>typeof i==="string"))r.type="string";if(s.every((i)=>typeof i==="boolean"))r.type="boolean";if(s.every((i)=>i===null))r.type="null";r.enum=s}};var Tl=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")};var Al=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")};var Ol=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:c}=e._zod.bag;if(typeof i==="number")o.minItems=i;if(typeof c==="number")o.maxItems=c;o.type="array",o.items=R(s.element,t,{...n,path:[...n.path,"items"]})},Zl=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object",o.properties={};let i=s.shape;for(let l in i)o.properties[l]=R(i[l],t,{...n,path:[...n.path,"properties",l]});let c=new Set(Object.keys(i)),a=new Set([...c].filter((l)=>{let u=s.shape[l]._zod;if(t.io==="input")return u.optin===void 0;else return u.optout===void 0}));if(a.size>0)o.required=Array.from(a);if(s.catchall?._zod.def.type==="never")o.additionalProperties=!1;else if(!s.catchall){if(t.io==="output")o.additionalProperties=!1}else if(s.catchall)o.additionalProperties=R(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})},Pl=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((c,a)=>R(c,t,{...n,path:[...n.path,s?"oneOf":"anyOf",a]}));if(s)r.oneOf=i;else r.anyOf=i},Cl=(e,t,r,n)=>{let o=e._zod.def,s=R(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=R(o.right,t,{...n,path:[...n.path,"allOf",1]}),c=(l)=>("allOf"in l)&&Object.keys(l).length===1,a=[...c(s)?s.allOf:[s],...c(i)?i.allOf:[i]];r.allOf=a};var Nl=(e,t,r,n)=>{let o=e._zod.def,s=R(o.innerType,t,n),i=t.seen.get(e);if(t.target==="openapi-3.0")i.ref=o.innerType,r.nullable=!0;else r.anyOf=[s,{type:"null"}]},Ul=(e,t,r,n)=>{let o=e._zod.def;R(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},Dl=(e,t,r,n)=>{let o=e._zod.def;R(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},Rl=(e,t,r,n)=>{let o=e._zod.def;R(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io==="input")r._prefault=JSON.parse(JSON.stringify(o.defaultValue))},jl=(e,t,r,n)=>{let o=e._zod.def;R(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}r.default=i},Ll=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;R(i,t,n);let c=t.seen.get(e);c.ref=i},Bl=(e,t,r,n)=>{let o=e._zod.def;R(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var ks=(e,t,r,n)=>{let o=e._zod.def;R(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType};var Hf=d("ZodISODateTime",(e,t)=>{cu.init(e,t),E.init(e,t)});function Ml(e){return pl(Hf,e)}var Yf=d("ZodISODate",(e,t)=>{au.init(e,t),E.init(e,t)});function Vl(e){return hl(Yf,e)}var Xf=d("ZodISOTime",(e,t)=>{uu.init(e,t),E.init(e,t)});function Fl(e){return dl(Xf,e)}var Qf=d("ZodISODuration",(e,t)=>{lu.init(e,t),E.init(e,t)});function Jl(e){return fl(Qf,e)}var rm=(e,t)=>{mn.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:(r)=>Vc(e,r)},flatten:{value:(r)=>Mc(e,r)},addIssue:{value:(r)=>{e.issues.push(r),e.message=JSON.stringify(e.issues,_t,2)}},addIssues:{value:(r)=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,_t,2)}},isEmpty:{get(){return e.issues.length===0}}})};var ne=d("ZodError",rm,{Parent:Error});var ql=gn(ne),Gl=yn(ne),Wl=cr(ne),Kl=ar(ne),Hl=qc(ne),Yl=Gc(ne),Xl=Wc(ne),Ql=Kc(ne),ep=Hc(ne),tp=Yc(ne),rp=Xc(ne),np=Qc(ne);var op=new WeakMap;function dr(e,t,r){let n=Object.getPrototypeOf(e),o=op.get(n);if(!o)o=new Set,op.set(n,o);if(o.has(t))return;o.add(t);for(let s in r){let i=r[s];Object.defineProperty(n,s,{configurable:!0,enumerable:!1,get(){let c=i.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:c}),c},set(c){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:c})}})}}var A=d("ZodType",(e,t)=>(T.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:hr(e,"input"),output:hr(e,"output")}}),e.toJSONSchema=kl(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,n)=>ql(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Wl(e,r,n),e.parseAsync=async(r,n)=>Gl(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Kl(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>Hl(e,r,n),e.decode=(r,n)=>Yl(e,r,n),e.encodeAsync=async(r,n)=>Xl(e,r,n),e.decodeAsync=async(r,n)=>Ql(e,r,n),e.safeEncode=(r,n)=>ep(e,r,n),e.safeDecode=(r,n)=>tp(e,r,n),e.safeEncodeAsync=async(r,n)=>rp(e,r,n),e.safeDecodeAsync=async(r,n)=>np(e,r,n),dr(e,"ZodType",{check(...r){let n=this.def;return this.clone(b.mergeDefs(n,{checks:[...n.checks??[],...r.map((o)=>typeof o==="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return ce(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(Km(r,n))},superRefine(r,n){return this.check(Hm(r,n))},overwrite(r){return this.check(Pe(r))},optional(){return cp(this)},exactOptional(){return Um(this)},nullable(){return ap(this)},nullish(){return cp(ap(this))},nonoptional(r){return Mm(this,r)},array(){return fr(this)},or(r){return $s([this,r])},and(r){return Am(this,r)},transform(r){return up(this,Cm(r))},default(r){return jm(this,r)},prefault(r){return Bm(this,r)},catch(r){return Fm(this,r)},pipe(r){return up(this,r)},readonly(){return Gm(this)},describe(r){let n=this.clone();return Ke.add(n,{description:r}),n},meta(...r){if(r.length===0)return Ke.get(this);let n=this.clone();return Ke.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return Ke.get(e)?.description},configurable:!0}),e)),lp=d("_ZodString",(e,t)=>{bn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,o,s)=>vl(e,n,o,s);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,dr(e,"_ZodString",{regex(...n){return this.check(as(...n))},includes(...n){return this.check(ps(...n))},startsWith(...n){return this.check(hs(...n))},endsWith(...n){return this.check(ds(...n))},min(...n){return this.check(kt(...n))},max(...n){return this.check($n(...n))},length(...n){return this.check(Sn(...n))},nonempty(...n){return this.check(kt(1,...n))},lowercase(n){return this.check(us(n))},uppercase(n){return this.check(ls(n))},trim(){return this.check(ms())},normalize(...n){return this.check(fs(...n))},toLowerCase(){return this.check(gs())},toUpperCase(){return this.check(ys())},slugify(){return this.check(xs())}})}),om=d("ZodString",(e,t)=>{bn.init(e,t),lp.init(e,t),e.email=(r)=>e.check(Fu(sm,r)),e.url=(r)=>e.check(Ku(im,r)),e.jwt=(r)=>e.check(ll(bm,r)),e.emoji=(r)=>e.check(Hu(cm,r)),e.guid=(r)=>e.check(cs(sp,r)),e.uuid=(r)=>e.check(Ju(In,r)),e.uuidv4=(r)=>e.check(qu(In,r)),e.uuidv6=(r)=>e.check(Gu(In,r)),e.uuidv7=(r)=>e.check(Wu(In,r)),e.nanoid=(r)=>e.check(Yu(am,r)),e.guid=(r)=>e.check(cs(sp,r)),e.cuid=(r)=>e.check(Xu(um,r)),e.cuid2=(r)=>e.check(Qu(lm,r)),e.ulid=(r)=>e.check(el(pm,r)),e.base64=(r)=>e.check(cl(xm,r)),e.base64url=(r)=>e.check(al(_m,r)),e.xid=(r)=>e.check(tl(hm,r)),e.ksuid=(r)=>e.check(rl(dm,r)),e.ipv4=(r)=>e.check(nl(fm,r)),e.ipv6=(r)=>e.check(ol(mm,r)),e.cidrv4=(r)=>e.check(sl(gm,r)),e.cidrv6=(r)=>e.check(il(ym,r)),e.e164=(r)=>e.check(ul(wm,r)),e.datetime=(r)=>e.check(Ml(r)),e.date=(r)=>e.check(Vl(r)),e.time=(r)=>e.check(Fl(r)),e.duration=(r)=>e.check(Jl(r))});function zs(e){return Vu(om,e)}var E=d("ZodStringFormat",(e,t)=>{S.init(e,t),lp.init(e,t)}),sm=d("ZodEmail",(e,t)=>{Xa.init(e,t),E.init(e,t)});var sp=d("ZodGUID",(e,t)=>{Ha.init(e,t),E.init(e,t)});var In=d("ZodUUID",(e,t)=>{Ya.init(e,t),E.init(e,t)});var im=d("ZodURL",(e,t)=>{Qa.init(e,t),E.init(e,t)});var cm=d("ZodEmoji",(e,t)=>{eu.init(e,t),E.init(e,t)});var am=d("ZodNanoID",(e,t)=>{tu.init(e,t),E.init(e,t)});var um=d("ZodCUID",(e,t)=>{ru.init(e,t),E.init(e,t)});var lm=d("ZodCUID2",(e,t)=>{nu.init(e,t),E.init(e,t)});var pm=d("ZodULID",(e,t)=>{ou.init(e,t),E.init(e,t)});var hm=d("ZodXID",(e,t)=>{su.init(e,t),E.init(e,t)});var dm=d("ZodKSUID",(e,t)=>{iu.init(e,t),E.init(e,t)});var fm=d("ZodIPv4",(e,t)=>{pu.init(e,t),E.init(e,t)});var mm=d("ZodIPv6",(e,t)=>{hu.init(e,t),E.init(e,t)});var gm=d("ZodCIDRv4",(e,t)=>{du.init(e,t),E.init(e,t)});var ym=d("ZodCIDRv6",(e,t)=>{fu.init(e,t),E.init(e,t)});var xm=d("ZodBase64",(e,t)=>{gu.init(e,t),E.init(e,t)});var _m=d("ZodBase64URL",(e,t)=>{yu.init(e,t),E.init(e,t)});var wm=d("ZodE164",(e,t)=>{xu.init(e,t),E.init(e,t)});var bm=d("ZodJWT",(e,t)=>{_u.init(e,t),E.init(e,t)});var pp=d("ZodNumber",(e,t)=>{os.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,o,s)=>zl(e,n,o,s),dr(e,"ZodNumber",{gt(n,o){return this.check(vn(n,o))},gte(n,o){return this.check(pr(n,o))},min(n,o){return this.check(pr(n,o))},lt(n,o){return this.check(kn(n,o))},lte(n,o){return this.check(lr(n,o))},max(n,o){return this.check(lr(n,o))},int(n){return this.check(ip(n))},safe(n){return this.check(ip(n))},positive(n){return this.check(vn(0,n))},nonnegative(n){return this.check(pr(0,n))},negative(n){return this.check(kn(0,n))},nonpositive(n){return this.check(lr(0,n))},multipleOf(n,o){return this.check(zn(n,o))},step(n,o){return this.check(zn(n,o))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??0.5),e.isFinite=!0,e.format=r.format??null});function vt(e){return ml(pp,e)}var km=d("ZodNumberFormat",(e,t)=>{wu.init(e,t),pp.init(e,t)});function ip(e){return gl(km,e)}var vm=d("ZodUnknown",(e,t)=>{bu.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Sl(e,r,n,o)});function Tn(){return yl(vm)}var zm=d("ZodNever",(e,t)=>{ku.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>$l(e,r,n,o)});function $m(e){return xl(zm,e)}var Sm=d("ZodArray",(e,t)=>{vu.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ol(e,r,n,o),e.element=t.element,dr(e,"ZodArray",{min(r,n){return this.check(kt(r,n))},nonempty(r){return this.check(kt(1,r))},max(r,n){return this.check($n(r,n))},length(r,n){return this.check(Sn(r,n))},unwrap(){return this.element}})});function fr(e,t){return _l(Sm,e,t)}var Em=d("ZodObject",(e,t)=>{Su.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Zl(e,r,n,o),b.defineLazy(e,"shape",()=>t.shape),dr(e,"ZodObject",{keyof(){return Om(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:Tn()})},loose(){return this.clone({...this._zod.def,catchall:Tn()})},strict(){return this.clone({...this._zod.def,catchall:$m()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return b.extend(this,r)},safeExtend(r){return b.safeExtend(this,r)},merge(r){return b.merge(this,r)},pick(r){return b.pick(this,r)},omit(r){return b.omit(this,r)},partial(...r){return b.partial(fp,this,r[0])},required(...r){return b.required(mp,this,r[0])}})});function zt(e,t){let r={type:"object",shape:e??{},...b.normalizeParams(t)};return new Em(r)}var hp=d("ZodUnion",(e,t)=>{ss.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Pl(e,r,n,o),e.options=t.options});function $s(e,t){return new hp({type:"union",options:e,...b.normalizeParams(t)})}var Im=d("ZodDiscriminatedUnion",(e,t)=>{hp.init(e,t),Eu.init(e,t)});function dp(e,t,r){return new Im({type:"union",options:t,discriminator:e,...b.normalizeParams(r)})}var Tm=d("ZodIntersection",(e,t)=>{Iu.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Cl(e,r,n,o)});function Am(e,t){return new Tm({type:"intersection",left:e,right:t})}var vs=d("ZodEnum",(e,t)=>{Tu.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,o,s)=>El(e,n,o,s),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw Error(`Key ${i} not found in enum`);return new vs({...t,checks:[],...b.normalizeParams(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let i of n)if(r.has(i))delete s[i];else throw Error(`Key ${i} not found in enum`);return new vs({...t,checks:[],...b.normalizeParams(o),entries:s})}});function Om(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new vs({type:"enum",entries:r,...b.normalizeParams(t)})}var Zm=d("ZodLiteral",(e,t)=>{Au.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Il(e,r,n,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function $t(e,t){return new Zm({type:"literal",values:Array.isArray(e)?e:[e],...b.normalizeParams(t)})}var Pm=d("ZodTransform",(e,t)=>{Ou.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Al(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new er(e.constructor.name);r.addIssue=(s)=>{if(typeof s==="string")r.issues.push(b.issue(s,r.value,t));else{let i=s;if(i.fatal)i.continue=!1;i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=e),r.issues.push(b.issue(i))}};let o=t.transform(r.value,r);if(o instanceof Promise)return o.then((s)=>(r.value=s,r.fallback=!0,r));return r.value=o,r.fallback=!0,r}});function Cm(e){return new Pm({type:"transform",transform:e})}var fp=d("ZodOptional",(e,t)=>{is.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ks(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function cp(e){return new fp({type:"optional",innerType:e})}var Nm=d("ZodExactOptional",(e,t)=>{Zu.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ks(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Um(e){return new Nm({type:"optional",innerType:e})}var Dm=d("ZodNullable",(e,t)=>{Pu.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Nl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ap(e){return new Dm({type:"nullable",innerType:e})}var Rm=d("ZodDefault",(e,t)=>{Cu.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Dl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function jm(e,t){return new Rm({type:"default",innerType:e,get defaultValue(){return typeof t==="function"?t():b.shallowClone(t)}})}var Lm=d("ZodPrefault",(e,t)=>{Nu.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Rl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Bm(e,t){return new Lm({type:"prefault",innerType:e,get defaultValue(){return typeof t==="function"?t():b.shallowClone(t)}})}var mp=d("ZodNonOptional",(e,t)=>{Uu.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ul(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Mm(e,t){return new mp({type:"nonoptional",innerType:e,...b.normalizeParams(t)})}var Vm=d("ZodCatch",(e,t)=>{Du.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>jl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Fm(e,t){return new Vm({type:"catch",innerType:e,catchValue:typeof t==="function"?t:()=>t})}var Jm=d("ZodPipe",(e,t)=>{Ru.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ll(e,r,n,o),e.in=t.in,e.out=t.out});function up(e,t){return new Jm({type:"pipe",in:e,out:t})}var qm=d("ZodReadonly",(e,t)=>{ju.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bl(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Gm(e){return new qm({type:"readonly",innerType:e})}var Wm=d("ZodCustom",(e,t)=>{Lu.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Tl(e,r,n,o)});function Km(e,t={}){return wl(Wm,e,t)}function Hm(e,t){return bl(e,t)}var gr=32,Cn=new Set(["__proto__","constructor","prototype"]),Ym=$s([zs().min(1).max(512).refine((e)=>!Cn.has(e),"unsafe path key"),vt().int().nonnegative()]),mr=fr(Ym).min(1).max(gr);function yr(e,t=0){if(t>gr)return!1;if(e===null||typeof e==="boolean"||typeof e==="string")return!0;if(typeof e==="number")return Number.isFinite(e);if(Array.isArray(e))return e.every((n)=>yr(n,t+1));if(typeof e!=="object")return!1;let r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null)return!1;return Object.entries(e).every(([n,o])=>!Cn.has(n)&&yr(o,t+1))}var gp=Tn().refine(yr,"value must be safe JSON"),Xm=dp("type",[zt({type:$t("set"),path:mr,value:gp}),zt({type:$t("delete"),path:mr}),zt({type:$t("insert"),path:mr,index:vt().int().nonnegative(),values:fr(gp).min(1)}),zt({type:$t("increment"),path:mr,by:vt().finite()}),zt({type:$t("text"),path:mr,index:vt().int().nonnegative(),deleteCount:vt().int().nonnegative().optional(),insert:zs().optional()})]).superRefine((e,t)=>{if(e.type==="text"&&(e.deleteCount??0)===0&&(e.insert??"").length===0)t.addIssue({code:"custom",message:"text operation must insert or delete content"})});function Zn(e){if(Array.isArray(e)){let t=new re;return t.insert(0,e.map(Zn)),t}if(e!==null&&typeof e==="object"){let t=new G;for(let[r,n]of Object.entries(e))t.set(r,Zn(n));return t}return e}function Ss(e,t=0){if(t>gr)throw Error("room document exceeds the maximum nesting depth");if(e instanceof G){let r=Object.create(null);for(let[n,o]of e.entries()){if(Cn.has(n))throw Error(`room document contains unsafe key "${n}"`);r[n]=Ss(o,t+1)}return r}if(e instanceof re)return e.toArray().map((r)=>Ss(r,t+1));if(e instanceof ie)return e.toString();if(!yr(e))throw Error("room document contains a non-JSON value");return e}function Nn(e){return Ss(e.getMap("root"))}function B(e){return e.map(String).join(".")}function wp(e){if(e.length===0||e.length>gr)throw Error(`room path must contain 1 to ${gr} segments`);for(let t of e)if(typeof t==="string"){if(t.length===0||t.length>512||Cn.has(t))throw Error(`invalid room path segment "${t}"`)}else if(!Number.isInteger(t)||t<0)throw Error(`invalid room array index ${String(t)}`)}function bp(e,t,r){if(e instanceof G){if(typeof t!=="string")throw Error(`expected an object key at "${B(r)}"`);if(!e.has(t))throw Error(`room path does not exist: "${B(r)}"`);return e.get(t)}if(typeof t!=="number"||t>=e.length)throw Error(`invalid array index at "${B(r)}"`);return e.get(t)}function Un(e,t){wp(t);let r=e.getMap("root");for(let n=0;n<t.length-1;n+=1){if(!(r instanceof G)&&!(r instanceof re))throw Error(`room path crosses a scalar at "${B(t.slice(0,n+1))}"`);r=bp(r,t[n],t.slice(0,n+1))}if(!(r instanceof G)&&!(r instanceof re))throw Error(`room path parent is not a container: "${B(t)}"`);return{parent:r,key:t[t.length-1]}}function An(e,t){let{parent:r,key:n}=Un(e,t);return bp(r,n,t)}function yp(e,t,r){let{parent:n,key:o}=Un(e,t),s=Zn(r);if(n instanceof G){if(typeof o!=="string")throw Error(`expected an object key at "${B(t)}"`);n.set(o,s);return}if(typeof o!=="number"||o>=n.length)throw Error(`invalid array index at "${B(t)}"`);n.delete(o,1),n.insert(o,[s])}function Qm(e,t){let{parent:r,key:n}=Un(e,t);if(r instanceof G){if(typeof n!=="string")throw Error(`expected an object key at "${B(t)}"`);if(!r.has(n))throw Error(`room path does not exist: "${B(t)}"`);r.delete(n);return}if(typeof n!=="number"||n>=r.length)throw Error(`invalid array index at "${B(t)}"`);r.delete(n,1)}function xp(e,t){e.transact(()=>{for(let r of t)switch(r.type){case"set":yp(e,r.path,r.value);break;case"delete":Qm(e,r.path);break;case"insert":{wp(r.path);let n=An(e,r.path);if(!(n instanceof re))throw Error(`insert target is not an array: "${B(r.path)}"`);if(r.index>n.length)throw Error(`insert index is outside the array: "${B(r.path)}"`);n.insert(r.index,r.values.map(Zn));break}case"increment":{let n=An(e,r.path);if(typeof n!=="number"||!Number.isFinite(n))throw Error(`increment target is not a finite number: "${B(r.path)}"`);let o=n+r.by;if(!Number.isFinite(o))throw Error(`increment result is not finite: "${B(r.path)}"`);yp(e,r.path,o);break}case"text":{let n=An(e,r.path),o;if(n instanceof ie)o=n;else if(typeof n==="string"){o=new ie(n);let{parent:i,key:c}=Un(e,r.path);if(i instanceof G&&typeof c==="string")i.set(c,o);else if(i instanceof re&&typeof c==="number"&&c<i.length)i.delete(c,1),i.insert(c,[o]);else throw Error(`invalid text path: "${B(r.path)}"`)}else throw Error(`text target is not a string: "${B(r.path)}"`);let s=r.deleteCount??0;if(r.index>o.length||r.index+s>o.length)throw Error(`text range is outside the string: "${B(r.path)}"`);if(s>0)o.delete(r.index,s);if(r.insert)o.insert(r.index,r.insert);break}}})}function eg(e,t){let r=fr(Xm).min(1).parse(t),n=new ge({gc:!0});try{sn(n,gt(e)),xp(n,r),Nn(n)}finally{n.destroy()}let o=Yi(e);return xp(e,r),gt(e,o)}function Pn(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((o,s)=>Pn(o,t[s]));if(e===null||t===null||typeof e!=="object"||typeof t!=="object")return!1;let r=Object.keys(e),n=Object.keys(t);return r.length===n.length&&r.every((o)=>Object.hasOwn(t,o)&&Pn(e[o],t[o]))}function tg(e,t){if(Pn(e,t))return!0;if(e!==null&&t!==null&&!Array.isArray(e)&&!Array.isArray(t)&&typeof e==="object"&&typeof t==="object"&&Object.hasOwn(e,"id")&&Object.hasOwn(t,"id")){let r=e.id;return(typeof r==="string"||typeof r==="number")&&Object.is(r,t.id)}return!1}function Es(e){if(e!==null&&!Array.isArray(e)&&typeof e==="object"&&(typeof e.id==="string"||typeof e.id==="number"))return`id:${typeof e.id}:${String(e.id)}`;return`value:${JSON.stringify(e)}`}function _p(e){let t=[],r=new Set;for(let n of e){if(n===null||Array.isArray(n)||typeof n!=="object"||typeof n.id!=="string"&&typeof n.id!=="number")return null;let o=Es(n);if(r.has(o))return null;r.add(o),t.push(o)}return t}function rg(e,t){let r=new Map;for(let s=0;s<t.length;s+=1){let i=Es(t[s]),c=r.get(i);if(c)c.push(s);else r.set(i,[s])}let n=[],o=-1;for(let s=0;s<e.length;s+=1){let i=r.get(Es(e[s]));while(i?.length&&i[0]<=o)i.shift();let c=i?.shift();if(c===void 0)continue;if(!tg(e[s],t[c]))continue;n.push([s,c]),o=c}return n}function ng(e,t){try{return An(e,t)}catch{return}}function On(e,t,r,n,o){if(Pn(t,r))return;if(t!==null&&r!==null&&!Array.isArray(t)&&!Array.isArray(r)&&typeof t==="object"&&typeof r==="object"){for(let s of Object.keys(t))if(!Object.hasOwn(r,s))o.push({type:"delete",path:[...n,s]});for(let[s,i]of Object.entries(r))if(!Object.hasOwn(t,s))o.push({type:"set",path:[...n,s],value:i});else On(e,t[s],i,[...n,s],o);return}if(Array.isArray(t)&&Array.isArray(r)){let s=_p(t),i=_p(r),c=s!==null&&i!==null&&(s.length!==i.length||s.some((h,p)=>h!==i[p]));if(t.length===r.length&&!c){for(let h=0;h<r.length;h+=1)On(e,t[h],r[h],[...n,h],o);return}let a=0,l=0,u=0;for(let[h,p]of[...rg(t,r),[t.length,r.length]]){let f=h-a;for(let k=0;k<f;k+=1)o.push({type:"delete",path:[...n,u]});let m=r.slice(l,p);if(m.length>0)o.push({type:"insert",path:n,index:u,values:m}),u+=m.length;if(h<t.length&&p<r.length)On(e,t[h],r[p],[...n,u],o),u+=1;a=h+1,l=p+1}return}if(typeof t==="string"&&typeof r==="string"&&ng(e,n)instanceof ie){let s=0;while(s<t.length&&s<r.length&&t[s]===r[s])s+=1;let i=0;while(i<t.length-s&&i<r.length-s&&t[t.length-1-i]===r[r.length-1-i])i+=1;o.push({type:"text",path:n,index:s,deleteCount:t.length-s-i,insert:r.slice(s,r.length-i)});return}o.push({type:"set",path:n,value:r})}function kp(e,t){let r=Nn(e),n=structuredClone(r),o=t(n);if(o!==null&&(typeof o==="object"||typeof o==="function")&&typeof o.then==="function")throw Error("room change callback must be synchronous");if(!yr(n)||Array.isArray(n))throw Error("room state must be a safe JSON object");let s=[];if(On(e,r,n,[],s),s.length>0)eg(e,s);return s}function vp(e){let t="";for(let r=0;r<e.length;r+=8192)t+=String.fromCharCode(...e.subarray(r,r+8192));return btoa(t)}function og(e){return Uint8Array.from(atob(e),(t)=>t.charCodeAt(0))}class Dn{handlers=new Map;on(e,t){let r=this.handlers.get(e)??new Set;return r.add(t),this.handlers.set(e,r),()=>r.delete(t)}emit(e,t){for(let r of this.handlers.get(e)??[])r(t)}}class zp extends Dn{socket;rooms=new Map;channels=new Map;pending=new Map;nextId=0;opening;retry;stopped=!1;me;async open(){if(this.socket?.readyState===WebSocket.OPEN)return;if(this.opening)return this.opening;let e=location.pathname.match(/^\/p\/([^/.]+)/);if(!e)throw Error("Realtime rooms require a Swarm page");let t=new URL("/@swarm/realtime",location.href);return t.protocol=location.protocol==="https:"?"wss:":"ws:",t.searchParams.set("pageId",decodeURIComponent(e[1])),this.opening=new Promise((r,n)=>{let o=new WebSocket(t);this.socket=o,o.onopen=()=>{this.opening=void 0,r()},o.onerror=()=>n(Error("Realtime connection failed")),o.onmessage=(s)=>{let i=JSON.parse(s.data),c=i;if(c.seq)o.send(JSON.stringify({ack:c.seq}));if(c.type==="hello")this.me=c.me;if(c.type==="room")this.rooms.get(c.name??"")?.receive(i);if(c.type==="presence")this.rooms.get(c.name??"")?.receivePresence(c.peers);if(c.type==="channel")this.channels.get(c.name??"")?.emit("message",c.data);if(c.type==="deleted")this.rooms.get(c.name??"")?.deleted();if(c.id!==void 0){let a=this.pending.get(c.id);if(a)if(clearTimeout(a.timer),this.pending.delete(c.id),c.type==="error")a.reject(Error(c.error));else a.resolve(c)}},o.onclose=()=>{this.opening=void 0,n(Error("Realtime connection closed"));for(let s of this.pending.values())clearTimeout(s.timer),s.reject(Error("Realtime connection closed"));if(this.pending.clear(),!this.stopped)this.retry=setTimeout(()=>{this.reconnect()},1000)}}),this.opening}async reconnect(){try{await this.open();for(let e of this.rooms.values())await e.join(!0);for(let e of this.channels.keys())await this.request({op:"subscribe",name:e})}catch(e){for(let t of this.rooms.values())t.emit("error",e)}}async request(e){await this.open();let t=++this.nextId;return new Promise((r,n)=>{let o=setTimeout(()=>{this.pending.delete(t),n(Error("Realtime request timed out"))},15000);this.pending.set(t,{resolve:r,reject:n,timer:o}),this.socket.send(JSON.stringify({...e,id:t}))})}close(){this.stopped=!0,clearTimeout(this.retry),this.socket?.close()}}class $p extends Dn{connection;name;ydoc=new ge({gc:!0});generation="";stale=!1;bytes=0;me;ready;writes=Promise.resolve();lastWrite=Promise.resolve();peers=[];presenceData={};presenceTimer;closed=!1;schemaVersion;presence;constructor(e,t,r){super();this.connection=e;this.name=t;this.schemaVersion=r.schemaVersion??1;let n=this;this.presence={set(o){if(n.presenceData=structuredClone(o),!n.presenceTimer)n.presenceTimer=setTimeout(()=>{n.presenceTimer=void 0,e.request({op:"presence",name:t,data:n.presenceData}).catch((s)=>n.emit("error",s))},50)},get peers(){return n.peers}},this.observe()}get state(){return Nn(this.ydoc)}observe(){this.ydoc.on("update",(e,t)=>{if(this.emit("change",this.state),t==="remote"||!this.generation||this.closed)return;if(this.connection.socket?.readyState!==WebSocket.OPEN)return;let r=vp(gt(this.ydoc)),n=this.generation,o=this.writes.then(async()=>{try{let s=await this.connection.request({op:"update",name:this.name,generation:n,schemaVersion:this.schemaVersion,snapshot:r});if(s.room)this.receive(s.room)}catch(s){if(this.connection.socket?.readyState===WebSocket.OPEN){let i=await this.connection.request({op:"join",name:this.name,schemaVersion:this.schemaVersion});this.receive(i.room,!0)}throw this.emit("error",s),s}});this.lastWrite=o,this.writes=o.catch(()=>{})})}async join(e=!1){if(this.ready&&!e)return this.ready;return this.ready=(async()=>{let t=this.generation,r=await this.connection.request({op:"join",name:this.name,schemaVersion:this.schemaVersion});if(this.me=r.me,this.receive(r.room),this.receivePresence(r.peers),e&&t===this.generation&&!this.stale){let n=await this.connection.request({op:"update",name:this.name,schemaVersion:this.schemaVersion,generation:t,snapshot:vp(gt(this.ydoc))});this.receive(n.room)}if(e)this.presence.set(this.presenceData)})(),this.ready}receive(e,t=!1){if(this.closed||!e)return;let r=t||this.generation!==""&&e.generation!==this.generation;if(this.generation=e.generation,this.stale=e.schemaVersion!==this.schemaVersion,this.bytes=e.bytes,r)this.ydoc.destroy(),this.ydoc=new ge({gc:!0}),this.observe();if(sn(this.ydoc,og(e.snapshot),"remote"),r)this.emit("reset",this.state)}receivePresence(e=[]){this.peers=e,this.emit("presence",e)}deleted(){this.closed=!0,this.emit("error",Error("Room owner was deleted")),this.ydoc.destroy()}async change(e){if(this.closed)throw Error("Room is closed");if(this.stale)throw Error("Room schema is stale. Read the state and reset explicitly.");if(kp(this.ydoc,e).length>0)await this.lastWrite}async apply(e){if(this.closed||this.stale)throw Error("Room is closed or stale");await this.writes;let t=await this.connection.request({op:"change",name:this.name,generation:this.generation,schemaVersion:this.schemaVersion,operations:e});this.receive(t.room)}async reset(e={}){if(this.closed)throw Error("Room is closed");await this.writes;let t=await this.connection.request({op:"reset",name:this.name,schemaVersion:this.schemaVersion,state:e});this.receive(t.room)}async close(){this.closed=!0,clearTimeout(this.presenceTimer),this.connection.rooms.delete(this.name);try{await this.connection.request({op:"leave",name:this.name})}finally{this.ydoc.destroy()}}}class Sp extends Dn{connection;name;constructor(e,t){super();this.connection=e;this.name=t}async publish(e){await this.connection.request({op:"publish",name:this.name,data:e})}async close(){this.connection.channels.delete(this.name),await this.connection.request({op:"unsubscribe",name:this.name})}}var xe=new zp;window.addEventListener("pagehide",()=>xe.close());async function h_(e="default",t={}){if(!/^[a-zA-Z0-9_-]{1,64}$/.test(e))throw Error("Invalid room name");let r=xe.rooms.get(e);if(r&&r.schemaVersion!==(t.schemaVersion??1))throw Error("Room already opened with a different schema version");if(!r)r=new $p(xe,e,t),xe.rooms.set(e,r);try{await r.join()}catch(n){throw xe.rooms.delete(e),n}return r}async function d_(e){if(!/^[a-zA-Z0-9_-]{1,64}$/.test(e))throw Error("Invalid channel name");let t=xe.channels.get(e);if(t)return t;let r=new Sp(xe,e);xe.channels.set(e,r);try{await xe.request({op:"subscribe",name:e})}catch(n){throw xe.channels.delete(e),n}return r}export{d_ as channel,h_ as room};
69
69