import{n as e,r as t,s as n}from"./DrKWWDpL.js";import{t as r}from"./fl61BeEu2.js";import{n as i,t as a}from"./C3fwTF7T2.js";var o=t({crdt_apply_to_local_doc:()=>_,crdt_apply_update:()=>u,crdt_diff_update:()=>p,crdt_encode_state_as_update:()=>l,crdt_get_text:()=>m,crdt_make_incremental_update:()=>g,crdt_make_state:()=>h,crdt_merge_updates:()=>d,crdt_new_doc:()=>c,crdt_state_vector:()=>f});function s(e){let t=0;for(let n of e)t+=4+n.length;let n=new Uint8Array(t),r=0;for(let t of e)new DataView(n.buffer,r,4).setUint32(0,t.length,!0),r+=4,n.set(t,r),r+=t.length;return n}function c(){return Buffer.from(v.crdt_new_doc())}function l(e){return Buffer.from(v.crdt_encode_state_as_update(new Uint8Array(e)))}function u(e,t){return Buffer.from(v.crdt_apply_update(new Uint8Array(e),new Uint8Array(t)))}function d(e){if(e.length===0)return c();let t=s(e);return Buffer.from(v.crdt_merge_updates_wasm(t))}function f(e){return Buffer.from(v.crdt_state_vector(new Uint8Array(e)))}function p(e,t){return Buffer.from(v.crdt_diff_update(new Uint8Array(e),new Uint8Array(t)))}function m(e){if(e.length===0)return``;let t=new a;return t.import(new Uint8Array(e)),t.getText(`content`).toString()}function h(e){let t=new a;t.getText(`content`).insert(0,e),t.commit();let n=t.export({mode:`snapshot`});return Buffer.from(n)}function g(e,t){let n=new a;e.length>0&&n.import(new Uint8Array(e));let r=n.version(),i=n.getText(`content`),o=i.length;i.insert(o,t),n.commit();let s=n.export({mode:`update`,from:r});return Buffer.from(s)}function _(e,t){return u(e,t)}var v,y=e((async()=>{await i(),v=n(r(),1)}));export{m as a,d as c,f as d,y as f,l as i,c as l,u as n,g as o,p as r,h as s,_ as t,o as u};