collabmd 0.1.18 → 0.1.20
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.
- package/README.md +107 -25
- package/docker-compose.yml +1 -1
- package/package.json +1 -1
- package/public/assets/css/style.css +1 -1
- package/public/assets/js/chunks/{preview-render-compiler-WD3A76I6.js → chunk-5QRWYPYT.js} +18 -18
- package/public/assets/js/chunks/chunk-HEWVH67U.js +9 -0
- package/public/assets/js/chunks/chunk-R3DDMJHH.js +1 -0
- package/public/assets/js/chunks/editor-session-TAV2VXTA.js +22 -0
- package/public/assets/js/chunks/preview-render-compiler-UZ4SZDQQ.js +1 -0
- package/public/assets/js/chunks/quick-switcher-controller-J7I3CUET.js +5 -0
- package/public/assets/js/{excalidraw-editor-LKW2AZBU.js → excalidraw-editor-ZDYKMZOL.js} +33 -33
- package/public/assets/js/excalidraw-editor.js +1 -1
- package/public/assets/js/main.js +100 -73
- package/public/assets/js/preview-render-worker.js +19 -19
- package/public/index.html +14 -4
- package/src/client/application/app-shell/git-feature.js +29 -1
- package/src/client/application/app-shell/presence-feature.js +2 -1
- package/src/client/application/app-shell/ui-feature.js +113 -1
- package/src/client/application/app-shell/workspace-feature.js +9 -0
- package/src/client/application/app-shell-elements.js +1 -0
- package/src/client/application/preview-render-compiler.js +55 -5
- package/src/client/application/preview-render-executor.js +8 -0
- package/src/client/application/preview-render-worker.js +13 -2
- package/src/client/application/preview-renderer.js +5 -0
- package/src/client/application/workspace-chrome-controller.js +12 -1
- package/src/client/application/workspace-coordinator.js +16 -7
- package/src/client/application/workspace-preview-controller.js +45 -5
- package/src/client/application/workspace-route-controller.js +4 -0
- package/src/client/bootstrap/collabmd-app-shell.js +19 -3
- package/src/client/domain/room.js +37 -0
- package/src/client/domain/vault-utils.js +46 -0
- package/src/client/infrastructure/comment-thread-store.js +98 -0
- package/src/client/infrastructure/editor-paste-utils.js +45 -0
- package/src/client/infrastructure/editor-session.js +10 -0
- package/src/client/infrastructure/editor-view-adapter.js +98 -7
- package/src/client/infrastructure/vault-api-client.js +17 -0
- package/src/client/presentation/backlinks-panel.js +157 -101
- package/src/client/presentation/comment-markdown-renderer.js +68 -0
- package/src/client/presentation/comment-ui-controller.js +352 -20
- package/src/client/presentation/file-explorer-controller.js +5 -0
- package/src/client/presentation/file-explorer-view.js +10 -2
- package/src/client/presentation/file-tree-state.js +7 -1
- package/src/client/presentation/git-panel-controller.js +73 -0
- package/src/client/presentation/image-lightbox-controller.js +394 -0
- package/src/client/presentation/outline-controller.js +25 -0
- package/src/client/styles/style.css +677 -21
- package/src/domain/comment-threads.js +95 -13
- package/src/domain/file-kind.js +16 -1
- package/src/server/infrastructure/git/errors.js +4 -1
- package/src/server/infrastructure/git/git-service.js +215 -1
- package/src/server/infrastructure/http/create-git-api-command-handler.js +6 -1
- package/src/server/infrastructure/http/create-git-api-query-handler.js +16 -1
- package/src/server/infrastructure/http/create-vault-api-command-handler.js +48 -2
- package/src/server/infrastructure/http/create-vault-api-query-handler.js +67 -1
- package/src/server/infrastructure/http/request-body.js +11 -2
- package/src/server/infrastructure/persistence/path-utils.js +1 -1
- package/src/server/infrastructure/persistence/pull-backup-store.js +283 -0
- package/src/server/infrastructure/persistence/vault-file-store.js +203 -2
- package/public/assets/js/chunks/chunk-BBHPYU2R.js +0 -1
- package/public/assets/js/chunks/chunk-OG2TNZEU.js +0 -9
- package/public/assets/js/chunks/chunk-QSTBGTWJ.js +0 -1
- package/public/assets/js/chunks/chunk-SR3U53EQ.js +0 -1
- package/public/assets/js/chunks/editor-session-IHFTYG5D.js +0 -22
- package/public/assets/js/chunks/quick-switcher-controller-JYDIJVAJ.js +0 -5
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
var N=()=>new Map,qe=e=>{let t=N();return e.forEach((n,r)=>{t.set(r,n)}),t},z=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},ws=(e,t)=>{let n=[];for(let[r,s]of e)n.push(t(s,r));return n},ys=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1};var Y=()=>new Set;var Ye=e=>e[e.length-1];var xs=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},W=Array.from,Je=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},he=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1};var bs=(e,t)=>{let n=new Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n};var st=Array.isArray;var bt=class{constructor(){this._observers=N()}on(t,n){return z(this._observers,t,Y).add(n),n}once(t,n){let r=(...s)=>{this.off(t,r),n(...s)};this.on(t,r)}off(t,n){let r=this._observers.get(t);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(t))}emit(t,n){return W((this._observers.get(t)||N()).values()).forEach(r=>r(...n))}destroy(){this._observers=N()}},We=class{constructor(){this._observers=N()}on(t,n){z(this._observers,t,Y).add(n)}once(t,n){let r=(...s)=>{this.off(t,r),n(...s)};this.on(t,r)}off(t,n){let r=this._observers.get(t);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(t))}emit(t,n){return W((this._observers.get(t)||N()).values()).forEach(r=>r(...n))}destroy(){this._observers=N()}};var B=Math.floor;var St=Math.abs;var Lt=(e,t)=>e<t?e:t,it=(e,t)=>e>t?e:t,nh=Number.isNaN,Ss=Math.pow;var Xe=e=>e!==0?e<0:1/e<0;var Ot=Number.MAX_SAFE_INTEGER,Kn=Number.MIN_SAFE_INTEGER,rh=1<<31;var ks=Number.isInteger||(e=>typeof e=="number"&&isFinite(e)&&B(e)===e),sh=Number.isNaN,ih=Number.parseInt;var ue=String.fromCharCode,Po=String.fromCodePoint,oh=ue(65535),zo=e=>e.toLowerCase(),Ho=/^\s*/g,qo=e=>e.replace(Ho,""),Go=/([A-Z])/g,Zn=(e,t)=>qo(e.replace(Go,n=>`${t}${zo(n)}`));var Yo=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=t.codePointAt(s);return r},Mt=typeof TextEncoder<"u"?new TextEncoder:null,Jo=e=>Mt.encode(e),_s=Mt?Jo:Yo;var Bt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Bt&&Bt.decode(new Uint8Array).length===1&&(Bt=null);var Us=(e,t)=>bs(t,()=>e).join("");var _t=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},I=()=>new _t;var Qe=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t};var k=e=>{let t=new Uint8Array(Qe(e)),n=0;for(let r=0;r<e.bufs.length;r++){let s=e.bufs[r];t.set(s,n),n+=s.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},Wo=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(it(n,t)*2),e.cpos=0)},L=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t};var Ze=L;var g=(e,t)=>{for(;t>127;)L(e,128|127&t),t=B(t/128);L(e,127&t)},tn=(e,t)=>{let n=Xe(t);for(n&&(t=-t),L(e,(t>63?128:0)|(n?64:0)|63&t),t=B(t/64);t>0;)L(e,(t>127?128:0)|127&t),t=B(t/128)},tr=new Uint8Array(3e4),Xo=tr.length/3,Ko=(e,t)=>{if(t.length<Xo){let n=Mt.encodeInto(t,tr).written||0;g(e,n);for(let r=0;r<n;r++)L(e,tr[r])}else U(e,_s(t))},Qo=(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;g(e,r);for(let s=0;s<r;s++)L(e,n.codePointAt(s))},ot=Mt&&Mt.encodeInto?Ko:Qo;var ge=(e,t)=>{let n=e.cbuf.length,r=e.cpos,s=Lt(n-r,t.length),i=t.length-s;e.cbuf.set(t.subarray(0,s),r),e.cpos+=s,i>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(it(n*2,i)),e.cbuf.set(t.subarray(s)),e.cpos=i)},U=(e,t)=>{g(e,t.byteLength),ge(e,t)},er=(e,t)=>{Wo(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},Zo=(e,t)=>er(e,4).setFloat32(0,t,!1),tc=(e,t)=>er(e,8).setFloat64(0,t,!1),ec=(e,t)=>er(e,8).setBigInt64(0,t,!1);var As=new DataView(new ArrayBuffer(4)),nc=e=>(As.setFloat32(0,e),As.getFloat32(0)===e),Rt=(e,t)=>{switch(typeof t){case"string":L(e,119),ot(e,t);break;case"number":ks(t)&&St(t)<=2147483647?(L(e,125),tn(e,t)):nc(t)?(L(e,124),Zo(e,t)):(L(e,123),tc(e,t));break;case"bigint":L(e,122),ec(e,t);break;case"object":if(t===null)L(e,126);else if(st(t)){L(e,117),g(e,t.length);for(let n=0;n<t.length;n++)Rt(e,t[n])}else if(t instanceof Uint8Array)L(e,116),U(e,t);else{L(e,118);let n=Object.keys(t);g(e,n.length);for(let r=0;r<n.length;r++){let s=n[r];ot(e,s),Rt(e,t[s])}}break;case"boolean":L(e,t?120:121);break;default:L(e,127)}},pe=class extends _t{constructor(t){super(),this.w=t,this.s=null,this.count=0}write(t){this.s===t?this.count++:(this.count>0&&g(this,this.count-1),this.count=1,this.w(this,t),this.s=t)}};var Cs=e=>{e.count>0&&(tn(e.encoder,e.count===1?e.s:-e.s),e.count>1&&g(e.encoder,e.count-2))},Ut=class{constructor(){this.encoder=new _t,this.s=0,this.count=0}write(t){this.s===t?this.count++:(Cs(this),this.count=1,this.s=t)}toUint8Array(){return Cs(this),k(this.encoder)}};var Is=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);tn(e.encoder,t),e.count>1&&g(e.encoder,e.count-2)}},$t=class{constructor(){this.encoder=new _t,this.s=0,this.count=0,this.diff=0}write(t){this.diff===t-this.s?(this.s=t,this.count++):(Is(this),this.count=1,this.diff=t-this.s,this.s=t)}toUint8Array(){return Is(this),k(this.encoder)}},Ke=class{constructor(){this.sarr=[],this.s="",this.lensE=new Ut}write(t){this.s+=t,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(t.length)}toUint8Array(){let t=new _t;return this.sarr.push(this.s),this.s="",ot(t,this.sarr.join("")),ge(t,this.lensE.toUint8Array()),k(t)}};var H=e=>new Error(e),q=()=>{throw H("Method unimplemented")},$=()=>{throw H("Unexpected case")};var Ts=H("Unexpected end of array"),Ds=H("Integer out of Range"),Ft=class{constructor(t){this.arr=t,this.pos=0}},K=e=>new Ft(e),Vs=e=>e.pos!==e.arr.length;var rc=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},T=e=>rc(e,m(e));var Et=e=>e.arr[e.pos++];var m=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let s=e.arr[e.pos++];if(t=t+(s&127)*n,n*=128,s<128)return t;if(t>Ot)throw Ds}throw Ts},rn=e=>{let t=e.arr[e.pos++],n=t&63,r=64,s=(t&64)>0?-1:1;if((t&128)===0)return s*n;let i=e.arr.length;for(;e.pos<i;){if(t=e.arr[e.pos++],n=n+(t&127)*r,r*=128,t<128)return s*n;if(n>Ot)throw Ds}throw Ts};var sc=e=>{let t=m(e);if(t===0)return"";{let n=String.fromCodePoint(Et(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Et(e));else for(;t>0;){let r=t<1e4?t:1e4,s=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,s),t-=r}return decodeURIComponent(escape(n))}},ic=e=>Bt.decode(T(e)),X=Bt?ic:sc;var rr=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},oc=e=>rr(e,4).getFloat32(0,!1),cc=e=>rr(e,8).getFloat64(0,!1),lc=e=>rr(e,8).getBigInt64(0,!1);var ac=[e=>{},e=>null,rn,oc,cc,lc,e=>!1,e=>!0,X,e=>{let t=m(e),n={};for(let r=0;r<t;r++){let s=X(e);n[s]=jt(e)}return n},e=>{let t=m(e),n=[];for(let r=0;r<t;r++)n.push(jt(e));return n},T],jt=e=>ac[127-Et(e)](e),me=class extends Ft{constructor(t,n){super(t),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Vs(this)?this.count=m(this)+1:this.count=-1),this.count--,this.s}};var At=class extends Ft{constructor(t){super(t),this.s=0,this.count=0}read(){if(this.count===0){this.s=rn(this);let t=Xe(this.s);this.count=1,t&&(this.s=-this.s,this.count=m(this)+2)}return this.count--,this.s}};var Pt=class extends Ft{constructor(t){super(t),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let t=rn(this),n=t&1;this.diff=B(t/2),this.count=1,n&&(this.count=m(this)+2)}return this.s+=this.diff,this.count--,this.s}},nn=class{constructor(t){this.decoder=new At(t),this.str=X(this.decoder),this.spos=0}read(){let t=this.spos+this.decoder.read(),n=this.str.slice(this.spos,t);return this.spos=t,n}};var ah=crypto.subtle,Ns=crypto.getRandomValues.bind(crypto);var sr=()=>Ns(new Uint32Array(1))[0];var hc="10000000-1000-4000-8000"+-1e11,Ls=()=>hc.replace(/[018]/g,e=>(e^sr()&15>>e/4).toString(16));var G=Date.now;var ir=e=>new Promise(e);var uh=Promise.all.bind(Promise);var or=e=>e===void 0?null:e;var cr=class{constructor(){this.map=new Map}setItem(t,n){this.map.set(t,n)}getItem(t){return this.map.get(t)}},Os=new cr,lr=!0;try{typeof localStorage<"u"&&localStorage&&(Os=localStorage,lr=!1)}catch{}var on=Os,Bs=e=>lr||addEventListener("storage",e),Ms=e=>lr||removeEventListener("storage",e);var Ct=Symbol("Equality"),cn=(e,t)=>e===t||!!e?.[Ct]?.(t)||!1;var Rs=e=>typeof e=="object",$s=Object.assign,pc=Object.keys;var Fs=(e,t)=>{for(let n in e)t(e[n],n)},js=(e,t)=>{let n=[];for(let r in e)n.push(t(e[r],r));return n};var ye=e=>pc(e).length;var Ps=e=>{for(let t in e)return!1;return!0},zt=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},xe=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),hr=(e,t)=>e===t||ye(e)===ye(t)&&zt(e,(n,r)=>(n!==void 0||xe(t,r))&&cn(t[r],n)),gc=Object.freeze,dr=e=>{for(let t in e){let n=e[t];(typeof n=="object"||typeof n=="function")&&dr(e[t])}return gc(e)};var be=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&be(e,t,n+1)}};var zs=e=>e;var ft=(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[Ct]!=null)return e[Ct](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 n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break}case Set:{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break}case Map:{if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!ft(e.get(n),t.get(n)))return!1;break}case void 0:case Object:if(ye(e)!==ye(t))return!1;for(let n in e)if(!xe(e,n)||!ft(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!ft(e[n],t[n]))return!1;break;default:return!1}return!0},Hs=(e,t)=>t.includes(e);var ct=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",hn=typeof window<"u"&&typeof document<"u"&&!ct,fh=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,Q,mc=[],wc=()=>{if(Q===void 0)if(ct){Q=N();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]==="-"?(t!==null&&Q.set(t,""),t=r):t!==null?(Q.set(t,r),t=null):mc.push(r)}t!==null&&Q.set(t,"")}else typeof location=="object"?(Q=N(),(location.search||"?").slice(1).split("&").forEach(e=>{if(e.length!==0){let[t,n]=e.split("=");Q.set(`--${Zn(t,"-")}`,n),Q.set(`-${Zn(t,"-")}`,n)}})):Q=N();return Q},ur=e=>wc().has(e);var Se=e=>ct?or(process.env[e.toUpperCase().replaceAll("-","_")]):or(on.getItem(e));var qs=e=>ur("--"+e)||Se(e)!==null,Gs=qs("production"),yc=ct&&Hs(process.env.FORCE_COLOR,["true","1","2"]),Ys=yc||!ur("--no-colors")&&!qs("no-color")&&(!ct||process.stdout.isTTY)&&(!ct||ur("--color")||Se("COLORTERM")!==null||(Se("TERM")||"").includes("color"));var Js=e=>new Uint8Array(e),xc=(e,t,n)=>new Uint8Array(e,t,n),Ws=e=>new Uint8Array(e),bc=e=>{let t="";for(let n=0;n<e.byteLength;n++)t+=ue(e[n]);return btoa(t)},Sc=e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("base64"),kc=e=>{let t=atob(e),n=Js(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n},_c=e=>{let t=Buffer.from(e,"base64");return xc(t.buffer,t.byteOffset,t.byteLength)},Xs=hn?bc:Sc,Ks=hn?kc:_c;var Qs=e=>{let t=Js(e.byteLength);return t.set(e),t};var fr=class{constructor(t,n){this.left=t,this.right=n}},Z=(e,t)=>new fr(e,t);var ti=(e,t)=>e.forEach(n=>t(n.left,n.right));var pr=e=>e.next()>=.5,dn=(e,t,n)=>B(e.next()*(n+1-t)+t);var gr=(e,t,n)=>B(e.next()*(n+1-t)+t);var mr=(e,t,n)=>gr(e,t,n);var Uc=e=>ue(mr(e,97,122)),ni=(e,t=0,n=20)=>{let r=mr(e,t,n),s="";for(let i=0;i<r;i++)s+=Uc(e);return s};var un=(e,t)=>t[mr(e,0,t.length-1)];var Ac=Symbol("0schema"),wr=class{constructor(){this._rerrs=[]}extend(t,n,r,s=null){this._rerrs.push({path:t,expected:n,has:r,message:s})}toString(){let t=[];for(let n=this._rerrs.length-1;n>0;n--){let r=this._rerrs[n];t.push(Us(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return t.join(`
|
|
2
|
-
`)}},yr=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Ct]?cn(e,t):st(e)?Je(e,n=>he(t,r=>yr(n,r))):Rs(e)?zt(e,(n,r)=>yr(n,t[r])):!1,M=class{static _dilutes=!1;extends(t){let[n,r]=[this.shape,t.shape];return this.constructor._dilutes&&([r,n]=[n,r]),yr(n,r)}equals(t){return this.constructor===t.constructor&&ft(this.shape,t.shape)}[Ac](){return!0}[Ct](t){return this.equals(t)}validate(t){return this.check(t)}check(t,n){q()}get nullable(){return Jt(this,Un)}get optional(){return new fn(this)}cast(t){return ri(t,this),t}expect(t){return ri(t,this),t}},_e=class extends M{constructor(t,n){super(),this.shape=t,this._c=n}check(t,n=void 0){let r=t?.constructor===this.shape&&(this._c==null||this._c(t));return!r&&n?.extend(null,this.shape.name,t?.constructor.name,t?.constructor!==this.shape?"Constructor match failed":"Check failed"),r}},A=(e,t=null)=>new _e(e,t),gh=A(_e),Ue=class extends M{constructor(t){super(),this.shape=t}check(t,n){let r=this.shape(t);return!r&&n?.extend(null,"custom prop",t?.constructor.name,"failed to check custom prop"),r}},D=e=>new Ue(e),mh=A(Ue),Gt=class extends M{constructor(t){super(),this.shape=t}check(t,n){let r=this.shape.some(s=>s===t);return!r&&n?.extend(null,this.shape.join(" | "),t.toString()),r}},kn=(...e)=>new Gt(e),si=A(Gt),Cc=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,t=>"\\"+t)),ii=e=>{if(Yt.check(e))return[Cc(e)];if(si.check(e))return e.shape.map(t=>t+"");if(hi.check(e))return["[+-]?\\d+.?\\d*"];if(di.check(e))return[".*"];if(bn.check(e))return e.shape.map(ii).flat(1);$()},xr=class extends M{constructor(t){super(),this.shape=t,this._r=new RegExp("^"+t.map(ii).map(n=>`(${n.join("|")})`).join("")+"$")}check(t,n){let r=this._r.exec(t)!=null;return!r&&n?.extend(null,this._r.toString(),t.toString(),"String doesn't match string template."),r}};var wh=A(xr),Ic=Symbol("optional"),fn=class extends M{constructor(t){super(),this.shape=t}check(t,n){let r=t===void 0||this.shape.check(t);return!r&&n?.extend(null,"undefined (optional)","()"),r}get[Ic](){return!0}},Tc=A(fn),pn=class extends M{check(t,n){return n?.extend(null,"never",typeof t),!1}},yh=new pn,xh=A(pn),gn=class e extends M{constructor(t,n=!1){super(),this.shape=t,this._isPartial=n}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(t,n){return t==null?(n?.extend(null,"object","null"),!1):zt(this.shape,(r,s)=>{let i=this._isPartial&&!xe(t,s)||r.check(t[s],n);return!i&&n?.extend(s.toString(),r.toString(),typeof t[s],"Object property does not match"),i})}},Dc=e=>new gn(e),Vc=A(gn),Nc=D(e=>e!=null&&(e.constructor===Object||e.constructor==null)),mn=class extends M{constructor(t,n){super(),this.shape={keys:t,values:n}}check(t,n){return t!=null&&zt(t,(r,s)=>{let i=this.shape.keys.check(s,n);return!i&&n?.extend(s+"","Record",typeof t,i?"Key doesn't match schema":"Value doesn't match value"),i&&this.shape.values.check(r,n)})}},oi=(e,t)=>new mn(e,t),Lc=A(mn),wn=class extends M{constructor(t){super(),this.shape=t}check(t,n){return t!=null&&zt(this.shape,(r,s)=>{let i=r.check(t[s],n);return!i&&n?.extend(s.toString(),"Tuple",typeof r),i})}},Oc=(...e)=>new wn(e),bh=A(wn),yn=class extends M{constructor(t){super(),this.shape=t.length===1?t[0]:new Ee(t)}check(t,n){let r=st(t)&&Je(t,s=>this.shape.check(s));return!r&&n?.extend(null,"Array",""),r}},ci=(...e)=>new yn(e),Bc=A(yn),Mc=D(e=>st(e)),xn=class extends M{constructor(t,n){super(),this.shape=t,this._c=n}check(t,n){let r=t instanceof this.shape&&(this._c==null||this._c(t));return!r&&n?.extend(null,this.shape.name,t?.constructor.name),r}},vc=(e,t=null)=>new xn(e,t),Sh=A(xn),Rc=vc(M),br=class extends M{constructor(t){super(),this.len=t.length-1,this.args=Oc(...t.slice(-1)),this.res=t[this.len]}check(t,n){let r=t.constructor===Function&&t.length<=this.len;return!r&&n?.extend(null,"function",typeof t),r}};var $c=A(br),Fc=D(e=>typeof e=="function"),Sr=class extends M{constructor(t){super(),this.shape=t}check(t,n){let r=Je(this.shape,s=>s.check(t,n));return!r&&n?.extend(null,"Intersectinon",typeof t),r}};var kh=A(Sr,e=>e.shape.length>0),Ee=class extends M{static _dilutes=!0;constructor(t){super(),this.shape=t}check(t,n){let r=he(this.shape,s=>s.check(t,n));return n?.extend(null,"Union",typeof t),r}},Jt=(...e)=>e.findIndex(t=>bn.check(t))>=0?Jt(...e.map(t=>Ae(t)).map(t=>bn.check(t)?t.shape:[t]).flat(1)):e.length===1?e[0]:new Ee(e),bn=A(Ee),li=()=>!0,Sn=D(li),jc=A(Ue,e=>e.shape===li),_r=D(e=>typeof e=="bigint"),Pc=D(e=>e===_r),ai=D(e=>typeof e=="symbol"),_h=D(e=>e===ai),qt=D(e=>typeof e=="number"),hi=D(e=>e===qt),Yt=D(e=>typeof e=="string"),di=D(e=>e===Yt),_n=D(e=>typeof e=="boolean"),zc=D(e=>e===_n),ui=kn(void 0),Uh=A(Gt,e=>e.shape.length===1&&e.shape[0]===void 0),Eh=kn(void 0);var Un=kn(null),Hc=A(Gt,e=>e.shape.length===1&&e.shape[0]===null),Ah=A(Uint8Array),Ch=A(_e,e=>e.shape===Uint8Array),qc=Jt(qt,Yt,Un,ui,_r,_n,ai),Ih=(()=>{let e=ci(Sn),t=oi(Yt,Sn),n=Jt(qt,Yt,Un,_n,e,t);return e.shape=n,t.shape.values=n,n})(),Ae=e=>{if(Rc.check(e))return e;if(Nc.check(e)){let t={};for(let n in e)t[n]=Ae(e[n]);return Dc(t)}else{if(Mc.check(e))return Jt(...e.map(Ae));if(qc.check(e))return kn(e);if(Fc.check(e))return A(e)}$()},ri=Gs?()=>{}:(e,t)=>{let n=new wr;if(!t.check(e,n))throw H(`Expected value to be of type ${t.constructor.name}.
|
|
3
|
-
${n.toString()}`)},kr=class{constructor(t){this.patterns=[],this.$state=t}if(t,n){return this.patterns.push({if:Ae(t),h:n}),this}else(t){return this.if(Sn,t)}done(){return(t,n)=>{for(let r=0;r<this.patterns.length;r++){let s=this.patterns[r];if(s.if.check(t))return s.h(t,n)}throw H("Unhandled pattern")}}},Gc=e=>new kr(e),fi=Gc(Sn).if(hi,(e,t)=>dn(t,Kn,Ot)).if(di,(e,t)=>ni(t)).if(zc,(e,t)=>pr(t)).if(Pc,(e,t)=>BigInt(dn(t,Kn,Ot))).if(bn,(e,t)=>Ht(t,un(t,e.shape))).if(Vc,(e,t)=>{let n={};for(let r in e.shape){let s=e.shape[r];if(Tc.check(s)){if(pr(t))continue;s=s.shape}n[r]=fi(s,t)}return n}).if(Bc,(e,t)=>{let n=[],r=gr(t,0,42);for(let s=0;s<r;s++)n.push(Ht(t,e.shape));return n}).if(si,(e,t)=>un(t,e.shape)).if(Hc,(e,t)=>null).if($c,(e,t)=>{let n=Ht(t,e.res);return()=>n}).if(jc,(e,t)=>Ht(t,un(t,[qt,Yt,Un,ui,_r,_n,ci(qt),oi(Jt("a","b","c"),qt)]))).if(Lc,(e,t)=>{let n={},r=dn(t,0,3);for(let s=0;s<r;s++){let i=Ht(t,e.shape.keys),o=Ht(t,e.shape.values);n[i]=o}return n}).done(),Ht=(e,t)=>fi(Ae(t),e);var tt=typeof document<"u"?document:{},Jc=e=>tt.createElement(e),Wc=()=>tt.createDocumentFragment(),Th=D(e=>e.nodeType===sl),Xc=e=>tt.createTextNode(e),Dh=typeof DOMParser<"u"?new DOMParser:null;var Kc=(e,t)=>(ti(t,(n,r)=>{r===!1?e.removeAttribute(n):r===!0?e.setAttribute(n,""):e.setAttribute(n,r)}),e);var Qc=e=>{let t=Wc();for(let n=0;n<e.length;n++)mi(t,e[n]);return t},pi=(e,t)=>(mi(e,Qc(t)),e);var Zc=(e,t=[],n=[])=>pi(Kc(Jc(e),t),n),Vh=D(e=>e.nodeType===el);var tl=Xc,Nh=D(e=>e.nodeType===nl);var gi=e=>ws(e,(t,n)=>`${n}:${t};`).join("");var mi=(e,t)=>e.appendChild(t),el=tt.ELEMENT_NODE,nl=tt.TEXT_NODE,Lh=tt.CDATA_SECTION_NODE,Oh=tt.COMMENT_NODE,rl=tt.DOCUMENT_NODE,Bh=tt.DOCUMENT_TYPE_NODE,sl=tt.DOCUMENT_FRAGMENT_NODE,Mh=D(e=>e.nodeType===rl);var et=Symbol;var Ce=et(),Ie=et(),Ur=et(),Er=et(),Ar=et(),Te=et(),Cr=et(),Wt=et(),Ir=et(),wi=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let s=e[r];if(s===void 0)break;if(s.constructor===String||s.constructor===Number)t.push(s);else if(s.constructor===Object)break}for(r>0&&n.push(t.join(""));r<e.length;r++){let s=e[r];s instanceof Symbol||n.push(s)}return n};var vh=G();var ll={[Ce]:Z("font-weight","bold"),[Ie]:Z("font-weight","normal"),[Ur]:Z("color","blue"),[Ar]:Z("color","green"),[Er]:Z("color","grey"),[Te]:Z("color","red"),[Cr]:Z("color","purple"),[Wt]:Z("color","orange"),[Ir]:Z("color","black")},al=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());let t=[],n=[],r=N(),s=[],i=0;for(;i<e.length;i++){let o=e[i],c=ll[o];if(c!==void 0)r.set(c.left,c.right);else{if(o===void 0)break;if(o.constructor===String||o.constructor===Number){let l=gi(r);i>0||l.length>0?(t.push("%c"+o),n.push(l)):t.push(o)}else break}}for(i>0&&(s=n,s.unshift(t.join("")));i<e.length;i++){let o=e[i];o instanceof Symbol||s.push(o)}return s},yi=Ys?al:wi,xi=(...e)=>{console.log(...yi(e)),bi.forEach(t=>t.print(e))},Tr=(...e)=>{console.warn(...yi(e)),e.unshift(Wt),bi.forEach(t=>t.print(e))};var bi=Y();var Si=e=>({[Symbol.iterator](){return this},next:e}),ki=(e,t)=>Si(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),En=(e,t)=>Si(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}});var Ve=class{constructor(t,n){this.clock=t,this.len=n}},wt=class{constructor(){this.clients=new Map}},Zt=(e,t,n)=>t.clients.forEach((r,s)=>{let i=e.doc.store.clients.get(s);if(i!=null){let o=i[i.length-1],c=o.id.clock+o.length;for(let l=0,h=r[l];l<r.length&&h.clock<c;h=r[++l])Ki(e,i,h.clock,h.len,n)}}),pl=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let s=B((n+r)/2),i=e[s],o=i.clock;if(o<=t){if(t<o+i.len)return s;n=s+1}else r=s-1}return null},ze=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&pl(n,t.clock)!==null},Xr=e=>{e.clients.forEach(t=>{t.sort((s,i)=>s.clock-i.clock);let n,r;for(n=1,r=1;n<t.length;n++){let s=t[r-1],i=t[n];s.clock+s.len>=i.clock?s.len=it(s.len,i.clock+i.len-s.clock):(r<n&&(t[r]=i),r++)}t.length=r})},Vr=e=>{let t=new wt;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,s)=>{if(!t.clients.has(s)){let i=r.slice();for(let o=n+1;o<e.length;o++)xs(i,e[o].clients.get(s)||[]);t.clients.set(s,i)}});return Xr(t),t},Ne=(e,t,n,r)=>{z(e.clients,t,()=>[]).push(new Ve(n,r))},Fi=()=>new wt,gl=e=>{let t=Fi();return e.clients.forEach((n,r)=>{let s=[];for(let i=0;i<n.length;i++){let o=n[i];if(o.deleted){let c=o.id.clock,l=o.length;if(i+1<n.length)for(let h=n[i+1];i+1<n.length&&h.deleted;h=n[++i+1])l+=h.length;s.push(new Ve(c,l))}}s.length>0&&t.clients.set(r,s)}),t},se=(e,t)=>{g(e.restEncoder,t.clients.size),W(t.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{e.resetDsCurVal(),g(e.restEncoder,n);let s=r.length;g(e.restEncoder,s);for(let i=0;i<s;i++){let o=r[i];e.writeDsClock(o.clock),e.writeDsLen(o.len)}})},Kr=e=>{let t=new wt,n=m(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let s=m(e.restDecoder),i=m(e.restDecoder);if(i>0){let o=z(t.clients,s,()=>[]);for(let c=0;c<i;c++)o.push(new Ve(e.readDsClock(),e.readDsLen()))}}return t},Ei=(e,t,n)=>{let r=new wt,s=m(e.restDecoder);for(let i=0;i<s;i++){e.resetDsCurVal();let o=m(e.restDecoder),c=m(e.restDecoder),l=n.clients.get(o)||[],h=E(n,o);for(let a=0;a<c;a++){let d=e.readDsClock(),u=d+e.readDsLen();if(d<h){h<u&&Ne(r,o,h,u-h);let f=nt(l,d),p=l[f];for(!p.deleted&&p.id.clock<d&&(l.splice(f+1,0,Pn(t,p,d-p.id.clock)),f++);f<l.length&&(p=l[f++],p.id.clock<u);)p.deleted||(u<p.id.clock+p.length&&l.splice(f,0,Pn(t,p,u-p.id.clock)),p.delete(t))}else Ne(r,o,d,u-d)}}if(r.clients.size>0){let i=new lt;return g(i.restEncoder,0),se(i,r),i.toUint8Array()}return null};var ji=sr,te=class e extends bt{constructor({guid:t=Ls(),collectionid:n=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:c=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=ji(),this.guid=t,this.collectionid=n,this.share=new Map,this.store=new vn,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=ir(h=>{this.on("load",()=>{this.isLoaded=!0,h(this)})});let l=()=>ir(h=>{let a=d=>{(d===void 0||d===!0)&&(this.off("sync",a),h())};this.on("sync",a)});this.on("sync",h=>{h===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=h===void 0||h===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){let t=this._item;t!==null&&!this.shouldLoad&&S(t.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(W(this.subdocs).map(t=>t.guid))}transact(t,n=null){return S(this,t,n)}get(t,n=C){let r=z(this.share,t,()=>{let i=new n;return i._integrate(this,null),i}),s=r.constructor;if(n!==C&&s!==n)if(s===C){let i=new n;i._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(t,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${t} has already been defined with a different constructor`);return r}getArray(t=""){return this.get(t,xt)}getText(t=""){return this.get(t,Re)}getMap(t=""){return this.get(t,at)}getXmlElement(t=""){return this.get(t,$e)}getXmlFragment(t=""){return this.get(t,ne)}toJSON(){let t={};return this.share.forEach((n,r)=>{t[r]=n.toJSON()}),t}destroy(){this.isDestroyed=!0,W(this.subdocs).forEach(n=>n.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,S(t.parent.doc,r=>{let s=n.doc;t.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}},Vn=class{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return m(this.restDecoder)}readDsLen(){return m(this.restDecoder)}},Nn=class extends Vn{readLeftID(){return y(m(this.restDecoder),m(this.restDecoder))}readRightID(){return y(m(this.restDecoder),m(this.restDecoder))}readClient(){return m(this.restDecoder)}readInfo(){return Et(this.restDecoder)}readString(){return X(this.restDecoder)}readParentInfo(){return m(this.restDecoder)===1}readTypeRef(){return m(this.restDecoder)}readLen(){return m(this.restDecoder)}readAny(){return jt(this.restDecoder)}readBuf(){return Qs(T(this.restDecoder))}readJSON(){return JSON.parse(X(this.restDecoder))}readKey(){return X(this.restDecoder)}},Nr=class{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=m(this.restDecoder),this.dsCurrVal}readDsLen(){let t=m(this.restDecoder)+1;return this.dsCurrVal+=t,t}},yt=class extends Nr{constructor(t){super(t),this.keys=[],m(t),this.keyClockDecoder=new Pt(T(t)),this.clientDecoder=new At(T(t)),this.leftClockDecoder=new Pt(T(t)),this.rightClockDecoder=new Pt(T(t)),this.infoDecoder=new me(T(t),Et),this.stringDecoder=new nn(T(t)),this.parentInfoDecoder=new me(T(t),Et),this.typeRefDecoder=new At(T(t)),this.lenDecoder=new At(T(t))}readLeftID(){return new mt(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new mt(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 jt(this.restDecoder)}readBuf(){return T(this.restDecoder)}readJSON(){return jt(this.restDecoder)}readKey(){let t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];{let n=this.stringDecoder.read();return this.keys.push(n),n}}},Ln=class{constructor(){this.restEncoder=I()}toUint8Array(){return k(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){g(this.restEncoder,t)}writeDsLen(t){g(this.restEncoder,t)}},It=class extends Ln{writeLeftID(t){g(this.restEncoder,t.client),g(this.restEncoder,t.clock)}writeRightID(t){g(this.restEncoder,t.client),g(this.restEncoder,t.clock)}writeClient(t){g(this.restEncoder,t)}writeInfo(t){Ze(this.restEncoder,t)}writeString(t){ot(this.restEncoder,t)}writeParentInfo(t){g(this.restEncoder,t?1:0)}writeTypeRef(t){g(this.restEncoder,t)}writeLen(t){g(this.restEncoder,t)}writeAny(t){Rt(this.restEncoder,t)}writeBuf(t){U(this.restEncoder,t)}writeJSON(t){ot(this.restEncoder,JSON.stringify(t))}writeKey(t){ot(this.restEncoder,t)}},On=class{constructor(){this.restEncoder=I(),this.dsCurrVal=0}toUint8Array(){return k(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let n=t-this.dsCurrVal;this.dsCurrVal=t,g(this.restEncoder,n)}writeDsLen(t){t===0&&$(),g(this.restEncoder,t-1),this.dsCurrVal+=t}},lt=class extends On{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new $t,this.clientEncoder=new Ut,this.leftClockEncoder=new $t,this.rightClockEncoder=new $t,this.infoEncoder=new pe(Ze),this.stringEncoder=new Ke,this.parentInfoEncoder=new pe(Ze),this.typeRefEncoder=new Ut,this.lenEncoder=new Ut}toUint8Array(){let t=I();return g(t,0),U(t,this.keyClockEncoder.toUint8Array()),U(t,this.clientEncoder.toUint8Array()),U(t,this.leftClockEncoder.toUint8Array()),U(t,this.rightClockEncoder.toUint8Array()),U(t,k(this.infoEncoder)),U(t,this.stringEncoder.toUint8Array()),U(t,k(this.parentInfoEncoder)),U(t,this.typeRefEncoder.toUint8Array()),U(t,this.lenEncoder.toUint8Array()),ge(t,k(this.restEncoder)),k(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){Rt(this.restEncoder,t)}writeBuf(t){U(this.restEncoder,t)}writeJSON(t){Rt(this.restEncoder,t)}writeKey(t){let n=this.keyMap.get(t);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(n)}},ml=(e,t,n,r)=>{r=it(r,t[0].id.clock);let s=nt(t,r);g(e.restEncoder,t.length-s),e.writeClient(n),g(e.restEncoder,r);let i=t[s];i.write(e,r-i.id.clock);for(let o=s+1;o<t.length;o++)t[o].write(e,0)},Qr=(e,t,n)=>{let r=new Map;n.forEach((s,i)=>{E(t,i)>s&&r.set(i,s)}),zn(t).forEach((s,i)=>{n.has(i)||r.set(i,0)}),g(e.restEncoder,r.size),W(r.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{ml(e,t.clients.get(s),s,i)})},wl=(e,t)=>{let n=N(),r=m(e.restDecoder);for(let s=0;s<r;s++){let i=m(e.restDecoder),o=new Array(i),c=e.readClient(),l=m(e.restDecoder);n.set(c,{i:0,refs:o});for(let h=0;h<i;h++){let a=e.readInfo();switch(31&a){case 0:{let d=e.readLen();o[h]=new j(y(c,l),d),l+=d;break}case 10:{let d=m(e.restDecoder);o[h]=new P(y(c,l),d),l+=d;break}default:{let d=(a&192)===0,u=new _(y(c,l),null,(a&128)===128?e.readLeftID():null,null,(a&64)===64?e.readRightID():null,d?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,d&&(a&32)===32?e.readString():null,yo(e,a));o[h]=u,l+=u.length}}}}return n},yl=(e,t,n)=>{let r=[],s=W(n.keys()).sort((f,p)=>f-p);if(s.length===0)return null;let i=()=>{if(s.length===0)return null;let f=n.get(s[s.length-1]);for(;f.refs.length===f.i;)if(s.pop(),s.length>0)f=n.get(s[s.length-1]);else return null;return f},o=i();if(o===null)return null;let c=new vn,l=new Map,h=(f,p)=>{let w=l.get(f);(w==null||w>p)&&l.set(f,p)},a=o.refs[o.i++],d=new Map,u=()=>{for(let f of r){let p=f.id.client,w=n.get(p);w?(w.i--,c.clients.set(p,w.refs.slice(w.i)),n.delete(p),w.i=0,w.refs=[]):c.clients.set(p,[f]),s=s.filter(x=>x!==p)}r.length=0};for(;;){if(a.constructor!==P){let p=z(d,a.id.client,()=>E(t,a.id.client))-a.id.clock;if(p<0)r.push(a),h(a.id.client,a.id.clock-1),u();else{let w=a.getMissing(e,t);if(w!==null){r.push(a);let x=n.get(w)||{refs:[],i:0};if(x.refs.length===x.i)h(w,E(t,w)),u();else{a=x.refs[x.i++];continue}}else(p===0||p<a.length)&&(a.integrate(e,p),d.set(a.id.client,a.id.clock+a.length))}}if(r.length>0)a=r.pop();else if(o!==null&&o.i<o.refs.length)a=o.refs[o.i++];else{if(o=i(),o===null)break;a=o.refs[o.i++]}}if(c.clients.size>0){let f=new lt;return Qr(f,c,new Map),g(f.restEncoder,0),{missing:l,update:f.toUint8Array()}}return null},xl=(e,t)=>Qr(e,t.doc.store,t.beforeState),bl=(e,t,n,r=new yt(e))=>S(t,s=>{s.local=!1;let i=!1,o=s.doc,c=o.store,l=wl(r,o),h=yl(s,c,l),a=c.pendingStructs;if(a){for(let[u,f]of a.missing)if(f<E(c,u)){i=!0;break}if(h){for(let[u,f]of h.missing){let p=a.missing.get(u);(p==null||p>f)&&a.missing.set(u,f)}a.update=Rn([a.update,h.update])}}else c.pendingStructs=h;let d=Ei(r,s,c);if(c.pendingDs){let u=new yt(K(c.pendingDs));m(u.restDecoder);let f=Ei(u,s,c);d&&f?c.pendingDs=Rn([d,f]):c.pendingDs=d||f}else c.pendingDs=d;if(i){let u=c.pendingStructs.update;c.pendingStructs=null,Pi(s.doc,u)}},n,!1);var Pi=(e,t,n,r=yt)=>{let s=K(t);bl(s,e,n,new r(s))},zi=(e,t,n)=>Pi(e,t,n,Nn),Sl=(e,t,n=new Map)=>{Qr(e,t.store,n),se(e,gl(t.store))},kl=(e,t=new Uint8Array([0]),n=new lt)=>{let r=qi(t);Sl(n,e,r);let s=[n.toUint8Array()];if(e.store.pendingDs&&s.push(e.store.pendingDs),e.store.pendingStructs&&s.push(Ml(e.store.pendingStructs.update,t)),s.length>1){if(n.constructor===It)return Ol(s.map((i,o)=>o===0?i:Rl(i)));if(n.constructor===lt)return Rn(s)}return s[0]},Hi=(e,t)=>kl(e,t,new It),_l=e=>{let t=new Map,n=m(e.restDecoder);for(let r=0;r<n;r++){let s=m(e.restDecoder),i=m(e.restDecoder);t.set(s,i)}return t},qi=e=>_l(new Vn(K(e))),Gi=(e,t)=>(g(e.restEncoder,t.size),W(t.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{g(e.restEncoder,n),g(e.restEncoder,r)}),e),Ul=(e,t)=>Gi(e,zn(t.store)),El=(e,t=new On)=>(e instanceof Map?Gi(t,e):Ul(t,e),t.toUint8Array()),Yi=e=>El(e,new Ln),Lr=class{constructor(){this.l=[]}},Ai=()=>new Lr,Ci=(e,t)=>e.l.push(t),Ii=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(s=>t!==s),r===e.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},Ji=(e,t,n)=>be(e.l,[t,n]),mt=class{constructor(t,n){this.client=t,this.clock=n}},Kt=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,y=(e,t)=>new mt(e,t);var Wi=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw $()},Bn=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1};var Mn=class{constructor(t,n,r,s=0){this.type=t,this.tname=n,this.item=r,this.assoc=s}},Hh=e=>{let t={};return e.type&&(t.type=e.type),e.tname&&(t.tname=e.tname),e.item&&(t.item=e.item),e.assoc!=null&&(t.assoc=e.assoc),t},qh=e=>new Mn(e.type==null?null:y(e.type.client,e.type.clock),e.tname??null,e.item==null?null:y(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),Or=class{constructor(t,n,r=0){this.type=t,this.index=n,this.assoc=r}},Al=(e,t,n=0)=>new Or(e,t,n),An=(e,t,n)=>{let r=null,s=null;return e._item===null?s=Wi(e):r=y(e._item.id.client,e._item.id.clock),new Mn(r,s,t,n)},Gh=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return An(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return An(e,y(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return An(e,r.lastId,n);r=r.right}return An(e,null,n)};var Cl=(e,t)=>{let n=Qt(e,t),r=t.clock-n.id.clock;return{item:n,diff:r}},Yh=(e,t,n=!0)=>{let r=t.store,s=e.item,i=e.type,o=e.tname,c=e.assoc,l=null,h=0;if(s!==null){if(E(r,s.client)<=s.clock)return null;let a=n?Jr(r,s):Cl(r,s),d=a.item;if(!(d instanceof _))return null;if(l=d.parent,l._item===null||!l._item.deleted){h=d.deleted||!d.countable?0:a.diff+(c>=0?0:1);let u=d.left;for(;u!==null;)!u.deleted&&u.countable&&(h+=u.length),u=u.left}}else{if(o!==null)l=t.get(o);else if(i!==null){if(E(r,i.client)<=i.clock)return null;let{item:a}=n?Jr(r,i):{item:Qt(r,i)};if(a instanceof _&&a.content instanceof rt)l=a.content.type;else return null}else throw $();c>=0?h=l._length:h=0}return Al(l,h,e.assoc)},Jh=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&Kt(e.item,t.item)&&Kt(e.type,t.type)&&e.assoc===t.assoc,Br=class{constructor(t,n){this.ds=t,this.sv=n}};var Il=(e,t)=>new Br(e,t),Wh=Il(Fi(),new Map);var Xt=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!ze(t.ds,e.id),Mr=(e,t)=>{let n=z(e.meta,Mr,Y),r=e.doc.store;n.has(t)||(t.sv.forEach((s,i)=>{s<E(r,i)&&F(e,y(i,s))}),Zt(e,t.ds,s=>{}),n.add(t))};var vn=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},zn=e=>{let t=new Map;return e.clients.forEach((n,r)=>{let s=n[n.length-1];t.set(r,s.id.clock+s.length)}),t},E=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},Xi=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let r=n[n.length-1];if(r.id.clock+r.length!==t.id.clock)throw $()}n.push(t)},nt=(e,t)=>{let n=0,r=e.length-1,s=e[r],i=s.id.clock;if(i===t)return r;let o=B(t/(i+s.length-1)*r);for(;n<=r;){if(s=e[o],i=s.id.clock,i<=t){if(t<i+s.length)return o;n=o+1}else r=o-1;o=B((n+r)/2)}throw $()},Tl=(e,t)=>{let n=e.clients.get(t.client);return n[nt(n,t.clock)]},Qt=Tl,vr=(e,t,n)=>{let r=nt(t,n),s=t[r];return s.id.clock<n&&s instanceof _?(t.splice(r+1,0,Pn(e,s,n-s.id.clock)),r+1):r},F=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[vr(e,n,t.clock)]},Ti=(e,t,n)=>{let r=t.clients.get(n.client),s=nt(r,n.clock),i=r[s];return n.clock!==i.id.clock+i.length-1&&i.constructor!==j&&r.splice(s+1,0,Pn(e,i,n.clock-i.id.clock+1)),i},Dl=(e,t,n)=>{let r=e.clients.get(t.id.client);r[nt(r,t.id.clock)]=n},Ki=(e,t,n,r,s)=>{if(r===0)return;let i=n+r,o=vr(e,t,n),c;do c=t[o++],i<c.id.clock+c.length&&vr(e,t,i),s(c);while(o<t.length&&t[o].id.clock<i)},Rr=class{constructor(t,n,r){this.doc=t,this.deleteSet=new wt,this.beforeState=zn(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},Di=(e,t)=>t.deleteSet.clients.size===0&&!ys(t.afterState,(n,r)=>t.beforeState.get(r)!==n)?!1:(Xr(t.deleteSet),xl(e,t),se(e,t.deleteSet),!0),Vi=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&z(e.changed,t,Y).add(n)},Tn=(e,t)=>{let n=e[t],r=e[t-1],s=t;for(;s>0;n=r,r=e[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof _&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let i=t-s;return i&&e.splice(t+1-i,i),i},Vl=(e,t,n)=>{for(let[r,s]of e.clients.entries()){let i=t.clients.get(r);for(let o=s.length-1;o>=0;o--){let c=s[o],l=c.clock+c.len;for(let h=nt(i,c.clock),a=i[h];h<i.length&&a.id.clock<l;a=i[++h]){let d=i[h];if(c.clock+c.len<=d.id.clock)break;d instanceof _&&d.deleted&&!d.keep&&n(d)&&d.gc(t,!1)}}}},Nl=(e,t)=>{e.clients.forEach((n,r)=>{let s=t.clients.get(r);for(let i=n.length-1;i>=0;i--){let o=n[i],c=Lt(s.length-1,1+nt(s,o.clock+o.len-1));for(let l=c,h=s[l];l>0&&h.id.clock>=o.clock;h=s[l])l-=1+Tn(s,l)}})};var Qi=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,s=r.store,i=n.deleteSet,o=n._mergeStructs;try{Xr(i),n.afterState=zn(n.doc.store),r.emit("beforeObserverCalls",[n,r]);let c=[];n.changed.forEach((l,h)=>c.push(()=>{(h._item===null||!h._item.deleted)&&h._callObserver(n,l)})),c.push(()=>{n.changedParentTypes.forEach((l,h)=>{h._dEH.l.length>0&&(h._item===null||!h._item.deleted)&&(l=l.filter(a=>a.target._item===null||!a.target._item.deleted),l.forEach(a=>{a.currentTarget=h,a._path=null}),l.sort((a,d)=>a.path.length-d.path.length),c.push(()=>{Ji(h._dEH,l,n)}))}),c.push(()=>r.emit("afterTransaction",[n,r])),c.push(()=>{n._needFormattingCleanup&&Wl(n)})}),be(c,[])}finally{r.gc&&Vl(i,s,r.gcFilter),Nl(i,s),n.afterState.forEach((a,d)=>{let u=n.beforeState.get(d)||0;if(u!==a){let f=s.clients.get(d),p=it(nt(f,u),1);for(let w=f.length-1;w>=p;)w-=1+Tn(f,w)}});for(let a=o.length-1;a>=0;a--){let{client:d,clock:u}=o[a].id,f=s.clients.get(d),p=nt(f,u);p+1<f.length&&Tn(f,p+1)>1||p>0&&Tn(f,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(xi(Wt,Ce,"[yjs] ",Ie,Te,"Changed the client-id because another client seems to be using it."),r.clientID=ji()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){let a=new It;Di(a,n)&&r.emit("update",[a.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){let a=new lt;Di(a,n)&&r.emit("updateV2",[a.toUint8Array(),n.origin,r,n])}let{subdocsAdded:c,subdocsLoaded:l,subdocsRemoved:h}=n;(c.size>0||h.size>0||l.size>0)&&(c.forEach(a=>{a.clientID=r.clientID,a.collectionid==null&&(a.collectionid=r.collectionid),r.subdocs.add(a)}),h.forEach(a=>r.subdocs.delete(a)),r.emit("subdocs",[{loaded:l,added:c,removed:h},r,n]),h.forEach(a=>a.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,e])):Qi(e,t+1)}}},S=(e,t,n=null,r=!0)=>{let s=e._transactionCleanups,i=!1,o=null;e._transaction===null&&(i=!0,e._transaction=new Rr(e,n,r),s.push(e._transaction),s.length===1&&e.emit("beforeAllTransactions",[e]),e.emit("beforeTransaction",[e._transaction,e]));try{o=t(e._transaction)}finally{if(i){let c=e._transaction===s[0];e._transaction=null,c&&Qi(s,0)}}return o},$r=class{constructor(t,n){this.insertions=n,this.deletions=t,this.meta=new Map}},Ni=(e,t,n)=>{Zt(e,n.deletions,r=>{r instanceof _&&t.scope.some(s=>s===e.doc||Bn(s,r))&&rs(r,!1)})},Li=(e,t,n)=>{let r=null,s=e.doc,i=e.scope;S(s,c=>{for(;t.length>0&&e.currStackItem===null;){let l=s.store,h=t.pop(),a=new Set,d=[],u=!1;Zt(c,h.insertions,f=>{if(f instanceof _){if(f.redone!==null){let{item:p,diff:w}=Jr(l,f.id);w>0&&(p=F(c,y(p.id.client,p.id.clock+w))),f=p}!f.deleted&&i.some(p=>p===c.doc||Bn(p,f))&&d.push(f)}}),Zt(c,h.deletions,f=>{f instanceof _&&i.some(p=>p===c.doc||Bn(p,f))&&!ze(h.insertions,f.id)&&a.add(f)}),a.forEach(f=>{u=wo(c,f,a,h.insertions,e.ignoreRemoteMapChanges,e)!==null||u});for(let f=d.length-1;f>=0;f--){let p=d[f];e.deleteFilter(p)&&(p.delete(c),u=!0)}e.currStackItem=u?h:null}c.changed.forEach((l,h)=>{l.has(null)&&h._searchMarker&&(h._searchMarker.length=0)}),r=c},e);let o=e.currStackItem;if(o!=null){let c=r.changedParentTypes;e.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:c,origin:e},e]),e.currStackItem=null}return o},Oi=class extends bt{constructor(t,{captureTimeout:n=500,captureTransaction:r=l=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:c=st(t)?t[0].doc:t instanceof te?t:t.doc}={}){super(),this.scope=[],this.doc=c,this.addToScope(t),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=n,this.afterTransactionHandler=l=>{if(!this.captureTransaction(l)||!this.scope.some(x=>l.changedParentTypes.has(x)||x===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;let h=this.undoing,a=this.redoing,d=h?this.redoStack:this.undoStack;h?this.stopCapturing():a||this.clear(!1,!0);let u=new wt;l.afterState.forEach((x,b)=>{let gs=l.beforeState.get(b)||0,ms=x-gs;ms>0&&Ne(u,b,gs,ms)});let f=G(),p=!1;if(this.lastChange>0&&f-this.lastChange<this.captureTimeout&&d.length>0&&!h&&!a){let x=d[d.length-1];x.deletions=Vr([x.deletions,l.deleteSet]),x.insertions=Vr([x.insertions,u])}else d.push(new $r(l.deleteSet,u)),p=!0;!h&&!a&&(this.lastChange=f),Zt(l,l.deleteSet,x=>{x instanceof _&&this.scope.some(b=>b===l.doc||Bn(b,x))&&rs(x,!0)});let w=[{stackItem:d[d.length-1],origin:l.origin,type:h?"redo":"undo",changedParentTypes:l.changedParentTypes},this];p?this.emit("stack-item-added",w):this.emit("stack-item-updated",w)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(t){let n=new Set(this.scope);t=st(t)?t:[t],t.forEach(r=>{n.has(r)||(n.add(r),(r instanceof C?r.doc!==this.doc:r!==this.doc)&&Tr("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,n=!0){(t&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{t&&(this.undoStack.forEach(s=>Ni(r,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>Ni(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=Li(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=Li(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}};function*Ll(e){let t=m(e.restDecoder);for(let n=0;n<t;n++){let r=m(e.restDecoder),s=e.readClient(),i=m(e.restDecoder);for(let o=0;o<r;o++){let c=e.readInfo();if(c===10){let l=m(e.restDecoder);yield new P(y(s,i),l),i+=l}else if((31&c)!==0){let l=(c&192)===0,h=new _(y(s,i),null,(c&128)===128?e.readLeftID():null,null,(c&64)===64?e.readRightID():null,l?e.readParentInfo()?e.readString():e.readLeftID():null,l&&(c&32)===32?e.readString():null,yo(e,c));yield h,i+=h.length}else{let l=e.readLen();yield new j(y(s,i),l),i+=l}}}}var Le=class{constructor(t,n){this.gen=Ll(t),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===P);return this.curr}};var Oe=class{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}},Ol=e=>Rn(e,Nn,It);var Bl=(e,t)=>{if(e.constructor===j){let{client:n,clock:r}=e.id;return new j(y(n,r+t),e.length-t)}else if(e.constructor===P){let{client:n,clock:r}=e.id;return new P(y(n,r+t),e.length-t)}else{let n=e,{client:r,clock:s}=n.id;return new _(y(r,s+t),null,y(r,s+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Rn=(e,t=yt,n=lt)=>{if(e.length===1)return e[0];let r=e.map(a=>new t(K(a))),s=r.map(a=>new Le(a,!0)),i=null,o=new n,c=new Oe(o);for(;s=s.filter(u=>u.curr!==null),s.sort((u,f)=>{if(u.curr.id.client===f.curr.id.client){let p=u.curr.id.clock-f.curr.id.clock;return p===0?u.curr.constructor===f.curr.constructor?0:u.curr.constructor===P?1:-1:p}else return f.curr.id.client-u.curr.id.client}),s.length!==0;){let a=s[0],d=a.curr.id.client;if(i!==null){let u=a.curr,f=!1;for(;u!==null&&u.id.clock+u.length<=i.struct.id.clock+i.struct.length&&u.id.client>=i.struct.id.client;)u=a.next(),f=!0;if(u===null||u.id.client!==d||f&&u.id.clock>i.struct.id.clock+i.struct.length)continue;if(d!==i.struct.id.client)pt(c,i.struct,i.offset),i={struct:u,offset:0},a.next();else if(i.struct.id.clock+i.struct.length<u.id.clock)if(i.struct.constructor===P)i.struct.length=u.id.clock+u.length-i.struct.id.clock;else{pt(c,i.struct,i.offset);let p=u.id.clock-i.struct.id.clock-i.struct.length;i={struct:new P(y(d,i.struct.id.clock+i.struct.length),p),offset:0}}else{let p=i.struct.id.clock+i.struct.length-u.id.clock;p>0&&(i.struct.constructor===P?i.struct.length-=p:u=Bl(u,p)),i.struct.mergeWith(u)||(pt(c,i.struct,i.offset),i={struct:u,offset:0},a.next())}}else i={struct:a.curr,offset:0},a.next();for(let u=a.curr;u!==null&&u.id.client===d&&u.id.clock===i.struct.id.clock+i.struct.length&&u.constructor!==P;u=a.next())pt(c,i.struct,i.offset),i={struct:u,offset:0}}i!==null&&(pt(c,i.struct,i.offset),i=null),Zr(c);let l=r.map(a=>Kr(a)),h=Vr(l);return se(o,h),o.toUint8Array()},Ml=(e,t,n=yt,r=lt)=>{let s=qi(t),i=new r,o=new Oe(i),c=new n(K(e)),l=new Le(c,!1);for(;l.curr;){let a=l.curr,d=a.id.client,u=s.get(d)||0;if(l.curr.constructor===P){l.next();continue}if(a.id.clock+a.length>u)for(pt(o,a,it(u-a.id.clock,0)),l.next();l.curr&&l.curr.id.client===d;)pt(o,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===d&&l.curr.id.clock+l.curr.length<=u;)l.next()}Zr(o);let h=Kr(c);return se(i,h),i.toUint8Array()};var Zi=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:k(e.encoder.restEncoder)}),e.encoder.restEncoder=I(),e.written=0)},pt=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Zi(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),g(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},Zr=e=>{Zi(e);let t=e.encoder.restEncoder;g(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];g(t,r.written),ge(t,r.restEncoder)}},vl=(e,t,n,r)=>{let s=new n(K(e)),i=new Le(s,!1),o=new r,c=new Oe(o);for(let h=i.curr;h!==null;h=i.next())pt(c,t(h),0);Zr(c);let l=Kr(s);return se(o,l),o.toUint8Array()};var Rl=e=>vl(e,zs,yt,It),Bi="You must not compute changes after the event-handler fired.",ee=class{constructor(t,n){this.target=t,this.currentTarget=t,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=$l(this.currentTarget,this.target))}deletes(t){return ze(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw H(Bi);let t=new Map,n=this.target;this.transaction.changed.get(n).forEach(s=>{if(s!==null){let i=n._map.get(s),o,c;if(this.adds(i)){let l=i.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(i))if(l!==null&&this.deletes(l))o="delete",c=Ye(l.content.getContent());else return;else l!==null&&this.deletes(l)?(o="update",c=Ye(l.content.getContent())):(o="add",c=void 0)}else if(this.deletes(i))o="delete",c=Ye(i.content.getContent());else return;t.set(s,{action:o,oldValue:c})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw H(Bi);let n=this.target,r=Y(),s=Y(),i=[];if(t={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(n).has(null)){let c=null,l=()=>{c&&i.push(c)};for(let h=n._start;h!==null;h=h.right)h.deleted?this.deletes(h)&&!this.adds(h)&&((c===null||c.delete===void 0)&&(l(),c={delete:0}),c.delete+=h.length,s.add(h)):this.adds(h)?((c===null||c.insert===void 0)&&(l(),c={insert:[]}),c.insert=c.insert.concat(h.content.getContent()),r.add(h)):((c===null||c.retain===void 0)&&(l(),c={retain:0}),c.retain+=h.length);c!==null&&c.retain===void 0&&l()}this._changes=t}return t}},$l=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let r=0,s=t._item.parent._start;for(;s!==t._item&&s!==null;)!s.deleted&&s.countable&&(r+=s.length),s=s.right;n.unshift(r)}t=t._item.parent}return n},R=()=>{Tr("Invalid access: Add Yjs type to a document before reading data.")},to=80,ts=0,Fr=class{constructor(t,n){t.marker=!0,this.p=t,this.index=n,this.timestamp=ts++}},Fl=e=>{e.timestamp=ts++},eo=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=ts++},jl=(e,t,n)=>{if(e.length>=to){let r=e.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return eo(r,t,n),r}else{let r=new Fr(t,n);return e.push(r),r}},Hn=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((i,o)=>St(t-i.index)<St(t-o.index)?i:o),r=e._start,s=0;for(n!==null&&(r=n.p,s=n.index,Fl(n));r.right!==null&&s<t;){if(!r.deleted&&r.countable){if(t<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>t;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);return n!==null&&St(n.index-s)<r.parent.length/to?(eo(n,r,s),n):jl(e._searchMarker,r,s)},Be=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let s=e[r];if(n>0){let i=s.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(s.index-=i.length);if(i===null||i.marker===!0){e.splice(r,1);continue}s.p=i,i.marker=!0}(t<s.index||n>0&&t===s.index)&&(s.index=it(t,s.index+n))}};var qn=(e,t,n)=>{let r=e,s=t.changedParentTypes;for(;z(s,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;Ji(r._eH,n,t)},C=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Ai(),this._dEH=Ai(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,n){this.doc=t,this._item=n}_copy(){throw q()}clone(){throw q()}_write(t){}get _first(){let t=this._start;for(;t!==null&&t.deleted;)t=t.right;return t}_callObserver(t,n){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){Ci(this._eH,t)}observeDeep(t){Ci(this._dEH,t)}unobserve(t){Ii(this._eH,t)}unobserveDeep(t){Ii(this._dEH,t)}toJSON(){}},no=(e,t,n)=>{e.doc??R(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,s=[],i=e._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){let o=i.content.getContent();if(o.length<=t)t-=o.length;else{for(let c=t;c<o.length&&r>0;c++)s.push(o[c]),r--;t=0}}i=i.right}return s},ro=e=>{e.doc??R();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let r=n.content.getContent();for(let s=0;s<r.length;s++)t.push(r[s])}n=n.right}return t};var Me=(e,t)=>{let n=0,r=e._start;for(e.doc??R();r!==null;){if(r.countable&&!r.deleted){let s=r.content.getContent();for(let i=0;i<s.length;i++)t(s[i],n++,e)}r=r.right}},so=(e,t)=>{let n=[];return Me(e,(r,s)=>{n.push(t(r,s,e))}),n},Pl=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let s=n[r++];return n.length<=r&&(n=null),{done:!1,value:s}}}},io=(e,t)=>{e.doc??R();let n=Hn(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},$n=(e,t,n,r)=>{let s=n,i=e.doc,o=i.clientID,c=i.store,l=n===null?t._start:n.right,h=[],a=()=>{h.length>0&&(s=new _(y(o,E(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new re(h)),s.integrate(e,0),h=[])};r.forEach(d=>{if(d===null)h.push(d);else switch(d.constructor){case Number:case Object:case Boolean:case Array:case String:h.push(d);break;default:switch(a(),d.constructor){case Uint8Array:case ArrayBuffer:s=new _(y(o,E(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new je(new Uint8Array(d))),s.integrate(e,0);break;case te:s=new _(y(o,E(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new Pe(d)),s.integrate(e,0);break;default:if(d instanceof C)s=new _(y(o,E(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new rt(d)),s.integrate(e,0);else throw new Error("Unexpected content type in insert operation")}}}),a()},oo=()=>H("Length exceeded!"),co=(e,t,n,r)=>{if(n>t._length)throw oo();if(n===0)return t._searchMarker&&Be(t._searchMarker,n,r.length),$n(e,t,null,r);let s=n,i=Hn(t,n),o=t._start;for(i!==null&&(o=i.p,n-=i.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&F(e,y(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&Be(t._searchMarker,s,r.length),$n(e,t,o,r)},zl=(e,t,n)=>{let s=(t._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:t._start}).p;if(s)for(;s.right;)s=s.right;return $n(e,t,s,n)},lo=(e,t,n,r)=>{if(r===0)return;let s=n,i=r,o=Hn(t,n),c=t._start;for(o!==null&&(c=o.p,n-=o.index);c!==null&&n>0;c=c.right)!c.deleted&&c.countable&&(n<c.length&&F(e,y(c.id.client,c.id.clock+n)),n-=c.length);for(;r>0&&c!==null;)c.deleted||(r<c.length&&F(e,y(c.id.client,c.id.clock+r)),c.delete(e),r-=c.length),c=c.right;if(r>0)throw oo();t._searchMarker&&Be(t._searchMarker,s,-i+r)},Fn=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},es=(e,t,n,r)=>{let s=t._map.get(n)||null,i=e.doc,o=i.clientID,c;if(r==null)c=new re([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new re([r]);break;case Uint8Array:c=new je(r);break;case te:c=new Pe(r);break;default:if(r instanceof C)c=new rt(r);else throw new Error("Unexpected content type")}new _(y(o,E(i.store,o)),s,s&&s.lastId,null,null,t,n,c).integrate(e,0)},ns=(e,t)=>{e.doc??R();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},ao=e=>{let t={};return e.doc??R(),e._map.forEach((n,r)=>{n.deleted||(t[r]=n.content.getContent()[n.length-1])}),t},ho=(e,t)=>{e.doc??R();let n=e._map.get(t);return n!==void 0&&!n.deleted};var Hl=(e,t)=>{let n={};return e._map.forEach((r,s)=>{let i=r;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&Xt(i,t)&&(n[s]=i.content.getContent()[i.length-1])}),n},Cn=e=>(e.doc??R(),ki(e._map.entries(),t=>!t[1].deleted)),jr=class extends ee{},xt=class e extends C{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(n=>n instanceof C?n.clone():n)),t}get length(){return this.doc??R(),this._length}_callObserver(t,n){super._callObserver(t,n),qn(this,t,new jr(this,t))}insert(t,n){this.doc!==null?S(this.doc,r=>{co(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}push(t){this.doc!==null?S(this.doc,n=>{zl(n,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,n=1){this.doc!==null?S(this.doc,r=>{lo(r,this,t,n)}):this._prelimContent.splice(t,n)}get(t){return io(this,t)}toArray(){return ro(this)}slice(t=0,n=this.length){return no(this,t,n)}toJSON(){return this.map(t=>t instanceof C?t.toJSON():t)}map(t){return so(this,t)}forEach(t){Me(this,t)}[Symbol.iterator](){return Pl(this)}_write(t){t.writeTypeRef(ua)}},ql=e=>new xt,Pr=class extends ee{constructor(t,n,r){super(t,n),this.keysChanged=r}},at=class e extends C{constructor(t){super(),this._prelimContent=null,t===void 0?this._prelimContent=new Map:this._prelimContent=new Map(t)}_integrate(t,n){super._integrate(t,n),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((n,r)=>{t.set(r,n instanceof C?n.clone():n)}),t}_callObserver(t,n){qn(this,t,new Pr(this,t,n))}toJSON(){this.doc??R();let t={};return this._map.forEach((n,r)=>{if(!n.deleted){let s=n.content.getContent()[n.length-1];t[r]=s instanceof C?s.toJSON():s}}),t}get size(){return[...Cn(this)].length}keys(){return En(Cn(this),t=>t[0])}values(){return En(Cn(this),t=>t[1].content.getContent()[t[1].length-1])}entries(){return En(Cn(this),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??R(),this._map.forEach((n,r)=>{n.deleted||t(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(t){this.doc!==null?S(this.doc,n=>{Fn(n,this,t)}):this._prelimContent.delete(t)}set(t,n){return this.doc!==null?S(this.doc,r=>{es(r,this,t,n)}):this._prelimContent.set(t,n),n}get(t){return ns(this,t)}has(t){return ho(this,t)}clear(){this.doc!==null?S(this.doc,t=>{this.forEach(function(n,r,s){Fn(t,s,r)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(fa)}},Gl=e=>new at,gt=(e,t)=>e===t||typeof e=="object"&&typeof t=="object"&&e&&t&&hr(e,t),ve=class{constructor(t,n,r,s){this.left=t,this.right=n,this.index=r,this.currentAttributes=s}forward(){this.right===null&&$(),this.right.content.constructor===V?this.right.deleted||ie(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}},Mi=(e,t,n)=>{for(;t.right!==null&&n>0;)t.right.content.constructor===V?t.right.deleted||ie(t.currentAttributes,t.right.content):t.right.deleted||(n<t.right.length&&F(e,y(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length),t.left=t.right,t.right=t.right.right;return t},In=(e,t,n,r)=>{let s=new Map,i=r?Hn(t,n):null;if(i){let o=new ve(i.p.left,i.p,i.index,s);return Mi(e,o,n-i.index)}else{let o=new ve(null,t._start,0,s);return Mi(e,o,n)}},uo=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===V&>(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let s=e.doc,i=s.clientID;r.forEach((o,c)=>{let l=n.left,h=n.right,a=new _(y(i,E(s.store,i)),l,l&&l.lastId,h,h&&h.id,t,null,new V(c,o));a.integrate(e,0),n.right=a,n.forward()})},ie=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},fo=(e,t)=>{for(;e.right!==null;){if(!(e.right.deleted||e.right.content.constructor===V&>(t[e.right.content.key]??null,e.right.content.value)))break;e.forward()}},po=(e,t,n,r)=>{let s=e.doc,i=s.clientID,o=new Map;for(let c in r){let l=r[c],h=n.currentAttributes.get(c)??null;if(!gt(h,l)){o.set(c,h);let{left:a,right:d}=n;n.right=new _(y(i,E(s.store,i)),a,a&&a.lastId,d,d&&d.id,t,null,new V(c,l)),n.right.integrate(e,0),n.forward()}}return o},Dr=(e,t,n,r,s)=>{n.currentAttributes.forEach((u,f)=>{s[f]===void 0&&(s[f]=null)});let i=e.doc,o=i.clientID;fo(n,s);let c=po(e,t,n,s),l=r.constructor===String?new ht(r):r instanceof C?new rt(r):new Tt(r),{left:h,right:a,index:d}=n;t._searchMarker&&Be(t._searchMarker,n.index,l.getLength()),a=new _(y(o,E(i.store,o)),h,h&&h.lastId,a,a&&a.id,t,null,l),a.integrate(e,0),n.right=a,n.index=d,n.forward(),uo(e,t,n,c)},vi=(e,t,n,r,s)=>{let i=e.doc,o=i.clientID;fo(n,s);let c=po(e,t,n,s);t:for(;n.right!==null&&(r>0||c.size>0&&(n.right.deleted||n.right.content.constructor===V));){if(!n.right.deleted)switch(n.right.content.constructor){case V:{let{key:l,value:h}=n.right.content,a=s[l];if(a!==void 0){if(gt(a,h))c.delete(l);else{if(r===0)break t;c.set(l,h)}n.right.delete(e)}else n.currentAttributes.set(l,h);break}default:r<n.right.length&&F(e,y(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
|
|
4
|
-
`;n.right=new _(y(o,E(i.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new ht(l)),n.right.integrate(e,0),n.forward()}uo(e,t,n,c)},go=(e,t,n,r,s)=>{let i=t,o=N();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===V){let h=i.content;o.set(h.key,h)}i=i.right}let c=0,l=!1;for(;t!==i;){if(n===t&&(l=!0),!t.deleted){let h=t.content;if(h.constructor===V){let{key:a,value:d}=h,u=r.get(a)??null;(o.get(a)!==h||u===d)&&(t.delete(e),c++,!l&&(s.get(a)??null)===d&&u!==d&&(u===null?s.delete(a):s.set(a,u))),!l&&!t.deleted&&ie(s,h)}}t=t.right}return c},Yl=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===V){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},Jl=e=>{let t=0;return S(e.doc,n=>{let r=e._start,s=e._start,i=N(),o=qe(i);for(;s;)s.deleted===!1&&(s.content.constructor===V?ie(o,s.content):(t+=go(n,r,s,i,o),i=qe(o),r=s)),s=s.right}),t},Wl=e=>{let t=new Set,n=e.doc;for(let[r,s]of e.afterState.entries()){let i=e.beforeState.get(r)||0;s!==i&&Ki(e,n.store.clients.get(r),i,s,o=>{!o.deleted&&o.content.constructor===V&&o.constructor!==j&&t.add(o.parent)})}S(n,r=>{Zt(e,e.deleteSet,s=>{if(s instanceof j||!s.parent._hasFormatting||t.has(s.parent))return;let i=s.parent;s.content.constructor===V?t.add(i):Yl(r,s)});for(let s of t)Jl(s)})},Ri=(e,t,n)=>{let r=n,s=qe(t.currentAttributes),i=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case rt:case Tt:case ht:n<t.right.length&&F(e,y(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}i&&go(e,i,t.right,s,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&Be(o._searchMarker,t.index,-r+n),t},zr=class extends ee{constructor(t,n,r){super(t,n),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(s=>{s===null?this.childListChanged=!0:this.keysChanged.add(s)})}get changes(){if(this._changes===null){let t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(this._delta===null){let t=this.target.doc,n=[];S(t,r=>{let s=new Map,i=new Map,o=this.target._start,c=null,l={},h="",a=0,d=0,u=()=>{if(c!==null){let f=null;switch(c){case"delete":d>0&&(f={delete:d}),d=0;break;case"insert":(typeof h=="object"||h.length>0)&&(f={insert:h},s.size>0&&(f.attributes={},s.forEach((p,w)=>{p!==null&&(f.attributes[w]=p)}))),h="";break;case"retain":a>0&&(f={retain:a},Ps(l)||(f.attributes=$s({},l))),a=0;break}f&&n.push(f),c=null}};for(;o!==null;){switch(o.content.constructor){case rt:case Tt:this.adds(o)?this.deletes(o)||(u(),c="insert",h=o.content.getContent()[0],u()):this.deletes(o)?(c!=="delete"&&(u(),c="delete"),d+=1):o.deleted||(c!=="retain"&&(u(),c="retain"),a+=1);break;case ht:this.adds(o)?this.deletes(o)||(c!=="insert"&&(u(),c="insert"),h+=o.content.str):this.deletes(o)?(c!=="delete"&&(u(),c="delete"),d+=o.length):o.deleted||(c!=="retain"&&(u(),c="retain"),a+=o.length);break;case V:{let{key:f,value:p}=o.content;if(this.adds(o)){if(!this.deletes(o)){let w=s.get(f)??null;gt(w,p)?p!==null&&o.delete(r):(c==="retain"&&u(),gt(p,i.get(f)??null)?delete l[f]:l[f]=p)}}else if(this.deletes(o)){i.set(f,p);let w=s.get(f)??null;gt(w,p)||(c==="retain"&&u(),l[f]=w)}else if(!o.deleted){i.set(f,p);let w=l[f];w!==void 0&&(gt(w,p)?w!==null&&o.delete(r):(c==="retain"&&u(),p===null?delete l[f]:l[f]=p))}o.deleted||(c==="insert"&&u(),ie(s,o.content));break}}o=o.right}for(u();n.length>0;){let f=n[n.length-1];if(f.retain!==void 0&&f.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}},Re=class e extends C{constructor(t){super(),this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??R(),this._length}_integrate(t,n){super._integrate(t,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(t,n){super._callObserver(t,n);let r=new zr(this,t,n);qn(this,t,r),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){this.doc??R();let t="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===ht&&(t+=n.content.str),n=n.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:n=!0}={}){this.doc!==null?S(this.doc,r=>{let s=new ve(null,this._start,0,new Map);for(let i=0;i<t.length;i++){let o=t[i];if(o.insert!==void 0){let c=!n&&typeof o.insert=="string"&&i===t.length-1&&s.right===null&&o.insert.slice(-1)===`
|
|
5
|
-
`?o.insert.slice(0,-1):o.insert;(typeof c!="string"||c.length>0)&&Dr(r,this,s,c,o.attributes||{})}else o.retain!==void 0?vi(r,this,s,o.retain,o.attributes||{}):o.delete!==void 0&&Ri(r,s,o.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,n,r){this.doc??R();let s=[],i=new Map,o=this.doc,c="",l=this._start;function h(){if(c.length>0){let d={},u=!1;i.forEach((p,w)=>{u=!0,d[w]=p});let f={insert:c};u&&(f.attributes=d),s.push(f),c=""}}let a=()=>{for(;l!==null;){if(Xt(l,t)||n!==void 0&&Xt(l,n))switch(l.content.constructor){case ht:{let d=i.get("ychange");t!==void 0&&!Xt(l,t)?(d===void 0||d.user!==l.id.client||d.type!=="removed")&&(h(),i.set("ychange",r?r("removed",l.id):{type:"removed"})):n!==void 0&&!Xt(l,n)?(d===void 0||d.user!==l.id.client||d.type!=="added")&&(h(),i.set("ychange",r?r("added",l.id):{type:"added"})):d!==void 0&&(h(),i.delete("ychange")),c+=l.content.str;break}case rt:case Tt:{h();let d={insert:l.content.getContent()[0]};if(i.size>0){let u={};d.attributes=u,i.forEach((f,p)=>{u[p]=f})}s.push(d);break}case V:Xt(l,t)&&(h(),ie(i,l.content));break}l=l.right}h()};return t||n?S(o,d=>{t&&Mr(d,t),n&&Mr(d,n),a()},"cleanup"):a(),s}insert(t,n,r){if(n.length<=0)return;let s=this.doc;s!==null?S(s,i=>{let o=In(i,this,t,!r);r||(r={},o.currentAttributes.forEach((c,l)=>{r[l]=c})),Dr(i,this,o,n,r)}):this._pending.push(()=>this.insert(t,n,r))}insertEmbed(t,n,r){let s=this.doc;s!==null?S(s,i=>{let o=In(i,this,t,!r);Dr(i,this,o,n,r||{})}):this._pending.push(()=>this.insertEmbed(t,n,r||{}))}delete(t,n){if(n===0)return;let r=this.doc;r!==null?S(r,s=>{Ri(s,In(s,this,t,!0),n)}):this._pending.push(()=>this.delete(t,n))}format(t,n,r){if(n===0)return;let s=this.doc;s!==null?S(s,i=>{let o=In(i,this,t,!1);o.right!==null&&vi(i,this,o,n,r)}):this._pending.push(()=>this.format(t,n,r))}removeAttribute(t){this.doc!==null?S(this.doc,n=>{Fn(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?S(this.doc,r=>{es(r,this,t,n)}):this._pending.push(()=>this.setAttribute(t,n))}getAttribute(t){return ns(this,t)}getAttributes(){return ao(this)}_write(t){t.writeTypeRef(pa)}},Xl=e=>new Re,De=class{constructor(t,n=()=>!0){this._filter=n,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??R()}[Symbol.iterator](){return this}next(){let t=this._currentNode,n=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(n)))do if(n=t.content.type,!t.deleted&&(n.constructor===$e||n.constructor===ne)&&n._start!==null)t=n._start;else for(;t!==null;){let r=t.next;if(r!==null){t=r;break}else t.parent===this._root?t=null:t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,t===null?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}},ne=class e extends C{constructor(){super(),this._prelimContent=[]}get firstChild(){let t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(n=>n instanceof C?n.clone():n)),t}get length(){return this.doc??R(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new De(this,t)}querySelector(t){t=t.toUpperCase();let r=new De(this,s=>s.nodeName&&s.nodeName.toUpperCase()===t).next();return r.done?null:r.value}querySelectorAll(t){return t=t.toUpperCase(),W(new De(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){qn(this,t,new Hr(this,n,t))}toString(){return so(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,n={},r){let s=t.createDocumentFragment();return r!==void 0&&r._createAssociation(s,this),Me(this,i=>{s.insertBefore(i.toDOM(t,n,r),null)}),s}insert(t,n){this.doc!==null?S(this.doc,r=>{co(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}insertAfter(t,n){if(this.doc!==null)S(this.doc,r=>{let s=t&&t instanceof C?t._item:t;$n(r,this,s,n)});else{let r=this._prelimContent,s=t===null?0:r.findIndex(i=>i===t)+1;if(s===0&&t!==null)throw H("Reference item not found");r.splice(s,0,...n)}}delete(t,n=1){this.doc!==null?S(this.doc,r=>{lo(r,this,t,n)}):this._prelimContent.splice(t,n)}toArray(){return ro(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return io(this,t)}slice(t=0,n=this.length){return no(this,t,n)}forEach(t){Me(this,t)}_write(t){t.writeTypeRef(ma)}},Kl=e=>new ne,$e=class e extends ne{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,n){super._integrate(t,n),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName),n=this.getAttributes();return Fs(n,(r,s)=>{t.setAttribute(s,r)}),t.insert(0,this.toArray().map(r=>r instanceof C?r.clone():r)),t}toString(){let t=this.getAttributes(),n=[],r=[];for(let c in t)r.push(c);r.sort();let s=r.length;for(let c=0;c<s;c++){let l=r[c];n.push(l+'="'+t[l]+'"')}let i=this.nodeName.toLocaleLowerCase(),o=n.length>0?" "+n.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(t){this.doc!==null?S(this.doc,n=>{Fn(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){this.doc!==null?S(this.doc,r=>{es(r,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return ns(this,t)}hasAttribute(t){return ho(this,t)}getAttributes(t){return t?Hl(this,t):ao(this)}toDOM(t=document,n={},r){let s=t.createElement(this.nodeName),i=this.getAttributes();for(let o in i){let c=i[o];typeof c=="string"&&s.setAttribute(o,c)}return Me(this,o=>{s.appendChild(o.toDOM(t,n,r))}),r!==void 0&&r._createAssociation(s,this),s}_write(t){t.writeTypeRef(ga),t.writeKey(this.nodeName)}},Ql=e=>new $e(e.readKey()),Hr=class extends ee{constructor(t,n,r){super(t,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}},qr=class e extends at{constructor(t){super(),this.hookName=t}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((n,r)=>{t.set(r,n)}),t}toDOM(t=document,n={},r){let s=n[this.hookName],i;return s!==void 0?i=s.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(i,this),i}_write(t){t.writeTypeRef(wa),t.writeKey(this.hookName)}},Zl=e=>new qr(e.readKey()),Gr=class e extends Re{get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(t=document,n,r){let s=t.createTextNode(this.toString());return r!==void 0&&r._createAssociation(s,this),s}toString(){return this.toDelta().map(t=>{let n=[];for(let s in t.attributes){let i=[];for(let o in t.attributes[s])i.push({key:o,value:t.attributes[s][o]});i.sort((o,c)=>o.key<c.key?-1:1),n.push({nodeName:s,attrs:i})}n.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let r="";for(let s=0;s<n.length;s++){let i=n[s];r+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){let c=i.attrs[o];r+=` ${c.key}="${c.value}"`}r+=">"}r+=t.insert;for(let s=n.length-1;s>=0;s--)r+=`</${n[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(ya)}},ta=e=>new Gr,Fe=class{constructor(t,n){this.id=t,this.length=n}get deleted(){throw q()}mergeWith(t){return!1}write(t,n,r){throw q()}integrate(t,n){throw q()}},ea=0,j=class extends Fe{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){n>0&&(this.id.clock+=n,this.length-=n),Xi(t.doc.store,this)}write(t,n){t.writeInfo(ea),t.writeLen(this.length-n)}getMissing(t,n){return null}},je=class e{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(t){throw q()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeBuf(this.content)}getRef(){return 3}},na=e=>new je(e.readBuf()),jn=class e{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,n){Ne(t.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(t){}gc(t){}write(t,n){t.writeLen(this.len-n)}getRef(){return 1}},ra=e=>new jn(e.readLen()),mo=(e,t)=>new te({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),Pe=class e{constructor(t){t._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=t;let n={};this.opts=n,t.gc||(n.gc=!1),t.autoLoad&&(n.autoLoad=!0),t.meta!==null&&(n.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(mo(this.doc.guid,this.opts))}splice(t){throw q()}mergeWith(t){return!1}integrate(t,n){this.doc._item=n,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,n){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}},sa=e=>new Pe(mo(e.readString(),e.readAny())),Tt=class e{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(t){throw q()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}},ia=e=>new Tt(e.readJSON()),V=class e{constructor(t,n){this.key=t,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(t){throw q()}mergeWith(t){return!1}integrate(t,n){let r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(t){}gc(t){}write(t,n){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}},oa=e=>new V(e.readKey(),e.readJSON()),Yr=class e{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){let r=this.arr.length;t.writeLen(r-n);for(let s=n;s<r;s++){let i=this.arr[s];t.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}},ca=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let s=e.readString();s==="undefined"?n.push(void 0):n.push(JSON.parse(s))}return new Yr(n)},la=Se("node_env")==="development",re=class e{constructor(t){this.arr=t,la&&dr(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){let r=this.arr.length;t.writeLen(r-n);for(let s=n;s<r;s++){let i=this.arr[s];t.writeAny(i)}}getRef(){return 8}},aa=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new re(n)},ht=class e{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+"\uFFFD",n.str="\uFFFD"+n.str.slice(1)),n}mergeWith(t){return this.str+=t.str,!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}},ha=e=>new ht(e.readString()),da=[ql,Gl,Xl,Ql,Kl,Zl,ta],ua=0,fa=1,pa=2,ga=3,ma=4,wa=5,ya=6,rt=class e{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(t){throw q()}mergeWith(t){return!1}integrate(t,n){this.type._integrate(t.doc,n)}delete(t){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(t.beforeState.get(n.id.client)||0)&&t._mergeStructs.push(n):n.delete(t),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(t.beforeState.get(r.id.client)||0)&&t._mergeStructs.push(r):r.delete(t)}),t.changed.delete(this.type)}gc(t){let n=this.type._start;for(;n!==null;)n.gc(t,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(t,!0),r=r.left}),this.type._map=new Map}write(t,n){this.type._write(t)}getRef(){return 7}},xa=e=>new rt(da[e.readTypeRef()](e)),Jr=(e,t)=>{let n=t,r=0,s;do r>0&&(n=y(n.client,n.clock+r)),s=Qt(e,n),r=n.clock-s.id.clock,n=s.redone;while(n!==null&&s instanceof _);return{item:s,diff:r}},rs=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Pn=(e,t,n)=>{let{client:r,clock:s}=t.id,i=new _(y(r,s+n),t,y(r,s+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&i.markDeleted(),t.keep&&(i.keep=!0),t.redone!==null&&(i.redone=y(t.redone.client,t.redone.clock+n)),t.right=i,i.right!==null&&(i.right.left=i),e._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),t.length=n,i},$i=(e,t)=>he(e,n=>ze(n.deletions,t)),wo=(e,t,n,r,s,i)=>{let o=e.doc,c=o.store,l=o.clientID,h=t.redone;if(h!==null)return F(e,h);let a=t.parent._item,d=null,u;if(a!==null&&a.deleted===!0){if(a.redone===null&&(!n.has(a)||wo(e,a,n,r,s,i)===null))return null;for(;a.redone!==null;)a=F(e,a.redone)}let f=a===null?t.parent:a.content.type;if(t.parentSub===null){for(d=t.left,u=t;d!==null;){let b=d;for(;b!==null&&b.parent._item!==a;)b=b.redone===null?null:F(e,b.redone);if(b!==null&&b.parent._item===a){d=b;break}d=d.left}for(;u!==null;){let b=u;for(;b!==null&&b.parent._item!==a;)b=b.redone===null?null:F(e,b.redone);if(b!==null&&b.parent._item===a){u=b;break}u=u.right}}else if(u=null,t.right&&!s){for(d=t;d!==null&&d.right!==null&&(d.right.redone||ze(r,d.right.id)||$i(i.undoStack,d.right.id)||$i(i.redoStack,d.right.id));)for(d=d.right;d.redone;)d=F(e,d.redone);if(d&&d.right!==null)return null}else d=f._map.get(t.parentSub)||null;let p=E(c,l),w=y(l,p),x=new _(w,d,d&&d.lastId,u,u&&u.id,f,t.parentSub,t.content.copy());return t.redone=w,rs(x,!0),x.integrate(e,0),x},_=class e extends Fe{constructor(t,n,r,s,i,o,c,l){super(t,l.getLength()),this.origin=r,this.left=n,this.right=s,this.rightOrigin=i,this.parent=o,this.parentSub=c,this.redone=null,this.content=l,this.info=this.content.isCountable()?2:0}set marker(t){(this.info&8)>0!==t&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(t){this.keep!==t&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(t){this.deleted!==t&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=E(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=E(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===mt&&this.id.client!==this.parent.client&&this.parent.clock>=E(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Ti(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=F(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===j||this.right&&this.right.constructor===j)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===mt){let r=Qt(n,this.parent);r.constructor===j?this.parent=null:this.parent=r.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=Ti(t,t.doc.store,y(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;let i=new Set,o=new Set;for(;s!==null&&s!==this.right;){if(o.add(s),i.add(s),Kt(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if(Kt(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(Qt(t.doc.store,s.origin)))i.has(Qt(t.doc.store,s.origin))||(r=s,i.clear());else break;s=s.right}this.left=r}if(this.left!==null){let r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(t)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Xi(t.doc.store,this),this.content.integrate(t,this),Vi(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new j(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;t!==null&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;t!==null&&t.deleted;)t=t.left;return t}get lastId(){return this.length===1?this.id:y(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&Kt(t.origin,this.lastId)&&this.right===t&&Kt(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){let n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===t&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),t.keep&&(this.keep=!0),this.right=t.right,this.right!==null&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){let n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),Ne(t.deleteSet,this.id.client,this.id.clock,this.length),Vi(t,n,this.parentSub),this.content.delete(t)}}gc(t,n){if(!this.deleted)throw $();this.content.gc(t),n?Dl(t,this,new j(this.id,this.length)):this.content=new jn(this.length)}write(t,n){let r=n>0?y(this.id.client,this.id.clock+n-1):this.origin,s=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&31|(r===null?0:128)|(s===null?0:64)|(i===null?0:32);if(t.writeInfo(o),r!==null&&t.writeLeftID(r),s!==null&&t.writeRightID(s),r===null&&s===null){let c=this.parent;if(c._item!==void 0){let l=c._item;if(l===null){let h=Wi(c);t.writeParentInfo(!0),t.writeString(h)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else c.constructor===String?(t.writeParentInfo(!0),t.writeString(c)):c.constructor===mt?(t.writeParentInfo(!1),t.writeLeftID(c)):$();i!==null&&t.writeString(i)}this.content.write(t,n)}},yo=(e,t)=>ba[t&31](e),ba=[()=>{$()},ra,ca,na,ha,ia,oa,xa,aa,sa,()=>{$()}],Sa=10,P=class extends Fe{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){$()}write(t,n){t.writeInfo(Sa),g(t.restEncoder,this.length-n)}getMissing(t,n){return null}},xo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},bo="__ $YJS$ __";xo[bo]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");xo[bo]=!0;function Gn(e){return e.endsWith("/")?e.slice(0,-1):e}function is(e){let t=Gn(String(e??"").trim());if(!t||t==="/")return"";if(/^[a-zA-Z][a-zA-Z\d+.-]*:/u.test(t))try{return is(new URL(t).pathname)}catch{return""}return t.startsWith("/")?t:`/${t}`}function ka(e,t){let n=Gn(String(e??"").trim());return!n||n==="/"?t:n.startsWith("/")?n:`/${n}`}function ss(e,t){let n=is(e),r=String(t??"").trim();return r?/^[a-zA-Z][a-zA-Z\d+.-]*:/u.test(r)||n&&(r===n||r.startsWith(`${n}/`))?r:r==="/"?n||"/":r.startsWith("/")?n?`${n}${r}`:r:n?`${n}/${r}`:`/${r}`:n||"/"}function ce(){let e={auth:{enabled:!1,implemented:!0,requiresLogin:!1,sessionEndpoint:"/api/auth/session",statusEndpoint:"/api/auth/status",strategy:"none"},basePath:"",environment:"development",gitEnabled:!0,publicWsBaseUrl:"",wsBasePath:"/ws",...window.__COLLABMD_CONFIG__??{}},t=is(e.basePath),n={enabled:!1,implemented:!0,requiresLogin:!1,sessionEndpoint:"/api/auth/session",statusEndpoint:"/api/auth/status",strategy:"none",...e.auth??{}};return{...e,auth:{...n,sessionEndpoint:ss(t,n.sessionEndpoint),statusEndpoint:ss(t,n.statusEndpoint)},basePath:t,wsBasePath:ka(e.wsBasePath,"/ws")}}function oe(e="/",t=ce()){return ss(t.basePath,e)}function _a(e="/",t=ce()){return new URL(oe(e,t),window.location.origin).toString()}function Ua(e="/",t=ce()){let n=String(e??"").trim();return!n||n==="/"?oe("/api",t):n.startsWith("/api")?oe(n,t):oe(`/api${n.startsWith("/")?n:`/${n}`}`,t)}function Ea(e=ce()){let n=new URLSearchParams(window.location.search).get("server");return n?Gn(n):e.publicWsBaseUrl?Gn(e.publicWsBaseUrl):`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${oe(e.wsBasePath,e)}`}var Aa=["Alice","Bob","Charlie","Dana","Eve","Frank","Grace","Hank","Iris","Jack","Kim","Leo","Maya","Nate","Olivia","Pete","Quinn","Ruby","Sam","Tara"],Ca=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#14b8a6","#f59e0b","#6366f1","#10b981","#f43f5e","#0ea5e9","#a855f7"];function ko(e){return e[Math.floor(Math.random()*e.length)]}function Ia(){let e=new Uint8Array(8);return(globalThis.crypto??{}).getRandomValues?.(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}var os=null;function Ta(){return os||(os=Ia()),os}function Da(e){return String(e??"").trim().replace(/\s+/g," ").slice(0,24)||null}function Kh(e=null){let t=ko(Ca);return{color:t,colorLight:`${t}33`,name:Da(e)??ko(Aa),peerId:Ta()}}var _o=new Map,cs=class{constructor(t){this.room=t,this.onmessage=null,this._onChange=n=>n.key===t&&this.onmessage!==null&&this.onmessage({data:Ks(n.newValue||"")}),Bs(this._onChange)}postMessage(t){on.setItem(this.room,Xs(Ws(t)))}close(){Ms(this._onChange)}},Va=typeof BroadcastChannel>"u"?cs:BroadcastChannel,ls=e=>z(_o,e,()=>{let t=Y(),n=new Va(e);return n.onmessage=r=>t.forEach(s=>s(r.data,"broadcastchannel")),{bc:n,subs:t}}),Uo=(e,t)=>(ls(e).subs.add(t),t),Eo=(e,t)=>{let n=ls(e),r=n.subs.delete(t);return r&&n.subs.size===0&&(n.bc.close(),_o.delete(e)),r},Dt=(e,t,n=null)=>{let r=ls(e);r.bc.postMessage(t),r.subs.forEach(s=>s(t,n))};var Ao=0,Yn=1,Co=2,Jn=(e,t)=>{g(e,Ao);let n=Yi(t);U(e,n)},as=(e,t,n)=>{g(e,Yn),U(e,Hi(t,n))},La=(e,t,n)=>as(t,n,T(e)),Io=(e,t,n,r)=>{try{zi(t,T(e),n)}catch(s){r?.(s),console.error("Caught error while handling a Yjs update",s)}},To=(e,t)=>{g(e,Co),U(e,t)},Oa=Io,Do=(e,t,n,r,s)=>{let i=m(e);switch(i){case Ao:La(e,t,n);break;case Yn:Io(e,n,r,s);break;case Co:Oa(e,n,r,s);break;default:throw new Error("Unknown message type")}return i};var Ma=0;var Vo=(e,t,n)=>{m(e)===Ma&&n(t,X(e))};var hs=3e4,Wn=class extends We{constructor(t){super(),this.doc=t,this.clientID=t.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let n=G();this.getLocalState()!==null&&hs/2<=n-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let r=[];this.meta.forEach((s,i)=>{i!==this.clientID&&hs<=n-s.lastUpdated&&this.states.has(i)&&r.push(i)}),r.length>0&&Xn(this,r,"timeout")},B(hs/10)),t.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(t){let n=this.clientID,r=this.meta.get(n),s=r===void 0?0:r.clock+1,i=this.states.get(n);t===null?this.states.delete(n):this.states.set(n,t),this.meta.set(n,{clock:s,lastUpdated:G()});let o=[],c=[],l=[],h=[];t===null?h.push(n):i==null?t!=null&&o.push(n):(c.push(n),ft(i,t)||l.push(n)),(o.length>0||l.length>0||h.length>0)&&this.emit("change",[{added:o,updated:l,removed:h},"local"]),this.emit("update",[{added:o,updated:c,removed:h},"local"])}setLocalStateField(t,n){let r=this.getLocalState();r!==null&&this.setLocalState({...r,[t]:n})}getStates(){return this.states}},Xn=(e,t,n)=>{let r=[];for(let s=0;s<t.length;s++){let i=t[s];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){let o=e.meta.get(i);e.meta.set(i,{clock:o.clock+1,lastUpdated:G()})}r.push(i)}}r.length>0&&(e.emit("change",[{added:[],updated:[],removed:r},n]),e.emit("update",[{added:[],updated:[],removed:r},n]))},le=(e,t,n=e.states)=>{let r=t.length,s=I();g(s,r);for(let i=0;i<r;i++){let o=t[i],c=n.get(o)||null,l=e.meta.get(o).clock;g(s,o),g(s,l),ot(s,JSON.stringify(c))}return k(s)};var No=(e,t,n)=>{let r=K(t),s=G(),i=[],o=[],c=[],l=[],h=m(r);for(let a=0;a<h;a++){let d=m(r),u=m(r),f=JSON.parse(X(r)),p=e.meta.get(d),w=e.states.get(d),x=p===void 0?0:p.clock;(x<u||x===u&&f===null&&e.states.has(d))&&(f===null?d===e.clientID&&e.getLocalState()!=null?u++:e.states.delete(d):e.states.set(d,f),e.meta.set(d,{clock:u,lastUpdated:s}),p===void 0&&f!==null?i.push(d):p!==void 0&&f===null?l.push(d):f!==null&&(ft(f,w)||c.push(d),o.push(d)))}(i.length>0||c.length>0||l.length>0)&&e.emit("change",[{added:i,updated:c,removed:l},n]),(i.length>0||o.length>0||l.length>0)&&e.emit("update",[{added:i,updated:o,removed:l},n])};var Lo=e=>js(e,(t,n)=>`${encodeURIComponent(n)}=${encodeURIComponent(t)}`).join("&");var Vt=0,Mo=3,ae=1,Fa=2,He=[];He[Vt]=(e,t,n,r,s)=>{g(e,Vt);let i=Do(t,e,n.doc,n);r&&i===Yn&&!n.synced&&(n.synced=!0)};He[Mo]=(e,t,n,r,s)=>{g(e,ae),U(e,le(n.awareness,Array.from(n.awareness.getStates().keys())))};He[ae]=(e,t,n,r,s)=>{No(n.awareness,T(t),n)};He[Fa]=(e,t,n,r,s)=>{Vo(t,n.doc,(i,o)=>ja(n,o))};var Oo=3e4,ja=(e,t)=>console.warn(`Permission denied to access ${e.url}.
|
|
6
|
-
${t}`),vo=(e,t,n)=>{let r=K(t),s=I(),i=m(r),o=e.messageHandlers[i];return o?o(s,r,e,n,i):console.error("Unable to compute message"),s},us=(e,t,n)=>{t===e.ws&&(e.emit("connection-close",[n,e]),e.ws=null,t.close(),e.wsconnecting=!1,e.wsconnected?(e.wsconnected=!1,e.synced=!1,Xn(e.awareness,Array.from(e.awareness.getStates().keys()).filter(r=>r!==e.doc.clientID),e),e.emit("status",[{status:"disconnected"}])):e.wsUnsuccessfulReconnects++,setTimeout(Ro,Lt(Ss(2,e.wsUnsuccessfulReconnects)*100,e.maxBackoffTime),e))},Ro=e=>{if(e.shouldConnect&&e.ws===null){let t=new e._WS(e.url,e.protocols);t.binaryType="arraybuffer",e.ws=t,e.wsconnecting=!0,e.wsconnected=!1,e.synced=!1,t.onmessage=n=>{e.wsLastMessageReceived=G();let r=vo(e,new Uint8Array(n.data),!0);Qe(r)>1&&t.send(k(r))},t.onerror=n=>{e.emit("connection-error",[n,e])},t.onclose=n=>{us(e,t,n)},t.onopen=()=>{e.wsLastMessageReceived=G(),e.wsconnecting=!1,e.wsconnected=!0,e.wsUnsuccessfulReconnects=0,e.emit("status",[{status:"connected"}]);let n=I();if(g(n,Vt),Jn(n,e.doc),t.send(k(n)),e.awareness.getLocalState()!==null){let r=I();g(r,ae),U(r,le(e.awareness,[e.doc.clientID])),t.send(k(r))}},e.emit("status",[{status:"connecting"}])}},ds=(e,t)=>{let n=e.ws;e.wsconnected&&n&&n.readyState===n.OPEN&&n.send(t),e.bcconnected&&Dt(e.bcChannel,t,e)},Bo=class extends bt{constructor(t,n,r,{connect:s=!0,awareness:i=new Wn(r),params:o={},protocols:c=[],WebSocketPolyfill:l=WebSocket,resyncInterval:h=-1,maxBackoffTime:a=2500,disableBc:d=!1}={}){for(super();t[t.length-1]==="/";)t=t.slice(0,t.length-1);this.serverUrl=t,this.bcChannel=t+"/"+n,this.maxBackoffTime=a,this.params=o,this.protocols=c,this.roomname=n,this.doc=r,this._WS=l,this.awareness=i,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=d,this.wsUnsuccessfulReconnects=0,this.messageHandlers=He.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=s,this._resyncInterval=0,h>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){let u=I();g(u,Vt),Jn(u,r),this.ws.send(k(u))}},h)),this._bcSubscriber=(u,f)=>{if(f!==this){let p=vo(this,new Uint8Array(u),!1);Qe(p)>1&&Dt(this.bcChannel,k(p),this)}},this._updateHandler=(u,f)=>{if(f!==this){let p=I();g(p,Vt),To(p,u),ds(this,k(p))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:u,updated:f,removed:p},w)=>{let x=u.concat(f).concat(p),b=I();g(b,ae),U(b,le(i,x)),ds(this,k(b))},this._exitHandler=()=>{Xn(this.awareness,[r.clientID],"app closed")},ct&&typeof process<"u"&&process.on("exit",this._exitHandler),i.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{this.wsconnected&&Oo<G()-this.wsLastMessageReceived&&us(this,this.ws,null)},Oo/10),s&&this.connect()}get url(){let t=Lo(this.params);return this.serverUrl+"/"+this.roomname+(t.length===0?"":"?"+t)}get synced(){return this._synced}set synced(t){this._synced!==t&&(this._synced=t,this.emit("synced",[t]),this.emit("sync",[t]))}destroy(){this._resyncInterval!==0&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),ct&&typeof process<"u"&&process.off("exit",this._exitHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.doc.off("update",this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;this.bcconnected||(Uo(this.bcChannel,this._bcSubscriber),this.bcconnected=!0);let t=I();g(t,Vt),Jn(t,this.doc),Dt(this.bcChannel,k(t),this);let n=I();g(n,Vt),as(n,this.doc),Dt(this.bcChannel,k(n),this);let r=I();g(r,Mo),Dt(this.bcChannel,k(r),this);let s=I();g(s,ae),U(s,le(this.awareness,[this.doc.clientID])),Dt(this.bcChannel,k(s),this)}disconnectBc(){let t=I();g(t,ae),U(t,le(this.awareness,[this.doc.clientID],new Map)),ds(this,k(t)),this.bcconnected&&(Eo(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),this.ws!==null&&us(this,this.ws,null)}connect(){this.shouldConnect=!0,!this.wsconnected&&this.ws===null&&(Ro(this),this.connectBc())}};function rd(){return ce()}function Pa(){let e=window.location.hash.startsWith("#")?window.location.hash.slice(1):window.location.hash;return new URLSearchParams(e)}function $o(e){return e==="staged"||e==="all"||e==="working-tree"?e:"all"}function sd(){let e=Pa();if(e.has("git-diff")){let t=e.get("git-diff")||null;return{filePath:t,scope:$o(e.get("scope")||(t?"working-tree":"all")),type:"git-diff"}}return e.has("file")?{filePath:e.get("file"),type:"file"}:{type:"empty"}}function id(e){let t=new URLSearchParams;e&&t.set("file",e),window.location.hash=t.toString()}function od({filePath:e=null,scope:t="all"}={}){let n=new URLSearchParams;n.set("git-diff",e??""),n.set("scope",$o(t)),window.location.hash=n.toString()}var za=new Set(["Room reset","Server shutting down"]);function ld(e){!e||typeof e.on!="function"||typeof e.disconnect!="function"||e.on("connection-close",t=>{let n=String(t?.reason||"");za.has(n)&&e.disconnect()})}var Ha=2e3,qa=160,Ga=280,Ya=new Set(["line","text"]);function dt(e){return Number.isFinite(e)?e:null}function Fo(e){return e instanceof at?e.toJSON():e&&typeof e=="object"&&!Array.isArray(e)?e:null}function O(e){return typeof e=="string"?e:""}function v(e,t){return e instanceof at?e.get(t):e?.[t]}function Ja(e){return dt(v(e,"resolvedAt"))!==null}function Wa(e){return Ya.has(e)?e:null}function Xa(e){return String(e??"").replace(/\r\n?/g,`
|
|
7
|
-
`).trim().slice(0,Ha)||null}function Ka(e){return String(e??"").replace(/\r\n?/g,`
|
|
8
|
-
`).trim().slice(0,Ga)||""}function Qa(e){return String(e??"").replace(/\r\n?/g,`
|
|
9
|
-
`).replace(/\s+/g," ").trim()}function hd(e,t=qa){let n=Qa(e);return n?n.length<=t?n:`${n.slice(0,Math.max(t-1,1)).trimEnd()}\u2026`:""}function fs(e){let t=Xa(e?.body);return t?{body:t,createdAt:dt(e?.createdAt)??Date.now(),id:O(e?.id)||ps("comment"),peerId:O(e?.peerId),userColor:O(e?.userColor),userName:O(e?.userName)||"Anonymous"}:null}function Za(e){return(e instanceof xt?e.toArray():Array.isArray(e)?e:[]).map(n=>fs(n)).filter(Boolean)}function ps(e="comment"){return globalThis.crypto?.randomUUID?`${e}-${globalThis.crypto.randomUUID()}`:`${e}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function jo(e={}){let t=Wa(e.anchorKind),n=Fo(e.anchorStart),r=Fo(e.anchorEnd),s=dt(e.anchorStartLine),i=dt(e.anchorEndLine),o=Ka(e.anchorQuote);return!t||!n||!r||s===null||i===null?null:{anchorEnd:r,anchorEndLine:Math.max(i,s),anchorKind:t,anchorQuote:o,anchorStart:n,anchorStartLine:Math.max(s,1)}}function dd(e={}){if(dt(e.resolvedAt)!==null)return null;let t=jo(e),n=fs(e.messages?.[0]);if(!t||!n)return null;let r=new xt,s=e.messages?.map(o=>fs(o)).filter(Boolean)??[];r.push(s.length>0?s:[n]);let i=new at;return i.set("anchorEnd",t.anchorEnd),i.set("anchorEndLine",t.anchorEndLine),i.set("anchorKind",t.anchorKind),i.set("anchorQuote",t.anchorQuote),i.set("anchorStart",t.anchorStart),i.set("anchorStartLine",t.anchorStartLine),i.set("createdAt",dt(e.createdAt)??Date.now()),i.set("createdByColor",O(e.createdByColor)),i.set("createdByName",O(e.createdByName)||n.userName),i.set("createdByPeerId",O(e.createdByPeerId)||n.peerId),i.set("id",O(e.id)||ps("thread")),i.set("messages",r),i.set("resolvedAt",dt(e.resolvedAt)),i.set("resolvedByColor",O(e.resolvedByColor)),i.set("resolvedByName",O(e.resolvedByName)),i.set("resolvedByPeerId",O(e.resolvedByPeerId)),i}function th(e){if(Ja(e))return null;let t=jo({anchorEnd:v(e,"anchorEnd"),anchorEndLine:v(e,"anchorEndLine"),anchorKind:v(e,"anchorKind"),anchorQuote:v(e,"anchorQuote"),anchorStart:v(e,"anchorStart"),anchorStartLine:v(e,"anchorStartLine")}),n=Za(v(e,"messages"));return!t||n.length===0?null:{...t,createdAt:dt(v(e,"createdAt"))??n[0].createdAt,createdByColor:O(v(e,"createdByColor"))||n[0].userColor,createdByName:O(v(e,"createdByName"))||n[0].userName,createdByPeerId:O(v(e,"createdByPeerId"))||n[0].peerId,id:O(v(e,"id"))||ps("thread"),messages:n,resolvedAt:dt(v(e,"resolvedAt")),resolvedByColor:O(v(e,"resolvedByColor")),resolvedByName:O(v(e,"resolvedByName")),resolvedByPeerId:O(v(e,"resolvedByPeerId"))}}function ud(e){return(e instanceof xt?e.toArray():Array.isArray(e)?e:[]).map(n=>th(n)).filter(Boolean)}export{_a as a,Ua as b,Ea as c,Da as d,Kh as e,Lt as f,it as g,Z as h,Zc as i,tl as j,te as k,Hh as l,qh as m,Gh as n,Yh as o,Jh as p,Oi as q,xt as r,at as s,Bo as t,rd as u,sd as v,id as w,od as x,ld as y,Ha as z,Xa as A,Ka as B,Qa as C,hd as D,ps as E,jo as F,dd as G,ud as H};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var o=Object.freeze([".md",".markdown",".mdx"]),a=".excalidraw",u=Object.freeze([".mmd",".mermaid"]),l=Object.freeze([".puml",".plantuml"]),d=Object.freeze([a,...u,...l]),s=Object.freeze([...o,...d]),p=/\.(?:md|markdown|mdx|excalidraw|mmd|mermaid|puml|plantuml)$/i;function m(t){return String(t??"").trim().toLowerCase()}function r(t,e){let i=m(t);return e.some(c=>i.endsWith(c))}function n(t){return r(t,o)?"markdown":r(t,[a])?"excalidraw":r(t,u)?"mermaid":r(t,l)?"plantuml":null}function x(t){let e=n(t);return e?e==="markdown"?"file":e:null}function f(t){let e=m(t);return s.find(i=>e.endsWith(i))??""}function E(t){return n(t)==="markdown"}function F(t){return n(t)==="excalidraw"}function N(t){return n(t)==="mermaid"}function I(t){return n(t)==="plantuml"}function S(t){let e=n(t);return e==="excalidraw"||e==="mermaid"||e==="plantuml"}function T(t){let e=n(t);return e==="markdown"||e==="mermaid"||e==="plantuml"}function _(t){return E(t)}function w(t){return String(t??"").replace(p,"")}export{n as a,x as b,f as c,E as d,F as e,N as f,I as g,S as h,T as i,_ as j,w as k};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function t(n,e){return n.match(e)?.length??0}function o(n=""){let e=String(n),r=t(e,/!\[\[[^\]]+\.(?:mmd|mermaid)(?:\|[^\]]+)?\]\]/gi),l=t(e,/(^|\n)```(?:plantuml|puml)\b/gi),a=t(e,/!\[\[[^\]]+\.(?:puml|plantuml)(?:\|[^\]]+)?\]\]/gi);return{chars:e.length,excalidrawEmbeds:t(e,/!\[\[[^\]]+\.excalidraw(?:\|[^\]]+)?\]\]/gi),mermaidBlocks:t(e,/(^|\n)```mermaid\b/gi)+r,plantumlBlocks:l+a}}function i(n){return!!(n&&(n.chars>=15e4||n.mermaidBlocks>=20||n.excalidrawEmbeds>=8||n.plantumlBlocks>=12))}function c(n=""){let e=String(n),r=/(^|\n)```mermaid\b/i.test(e)||/!\[\[[^\]]+\.(?:mmd|mermaid)(?:\|[^\]]+)?\]\]/i.test(e),l=/!\[\[[^\]]+\.excalidraw(?:\|[^\]]+)?\]\]/i.test(e),a=/(^|\n)```(?:plantuml|puml)\b/i.test(e)||/!\[\[[^\]]+\.(?:puml|plantuml)(?:\|[^\]]+)?\]\]/i.test(e);return e.length>=15e4?{debounceMs:500,deferUntilIdle:!0}:r||l||a?{debounceMs:0,deferUntilIdle:!1}:{debounceMs:100,deferUntilIdle:!1}}export{o as a,i as b,c};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import{b as Pn,g as Vn}from"./chunk-X6EEYWV4.js";import"./chunk-OOT2HALX.js";import"./chunk-NO7UPWTU.js";import"./chunk-CGVY4PKT.js";import{e as En,f as In,g as Rn}from"./chunk-OQLLZFFN.js";import{A as mn,Aa as ke,Ba as Dn,C as F,Ca as Bn,D as x,E as dn,Ea as q,F as fn,Fa as Le,G as pn,H as gn,I as xn,J as yn,K as Cn,N as ct,O as Sn,P as bn,Q as kn,R as Ln,S as ye,a as lt,aa as f,b as V,c as nn,d as on,e as rn,g as sn,ga as Ce,h as an,i as p,ia as Se,j as P,ja as c,k as fe,ka as vn,l as ln,la as be,m as pe,ma as se,n as O,na as ht,o as j,oa as ut,p as ge,q as v,r as re,s as ie,ta as wn,u as cn,v as hn,w as xe,x as w,xa as Mn,y as un,ya as An,z as S,za as Tn}from"./chunk-G7NUGGE7.js";import{A as st,B as oe,D as Xt,E as at,F as Zt,G as en,H as tn,c as _t,d as jt,e as qt,f as Ht,g as Yt,h as te,i as de,j as ne,k as Gt,l as G,m as I,n as U,o as R,p as rt,q as J,r as Jt,s as it,t as Kt,y as Qt}from"./chunk-OG2TNZEU.js";import"./chunk-775E65SU.js";function On({body:e,user:t}){return{body:e,createdAt:Date.now(),id:at("comment"),peerId:t?.peerId??"",userColor:t?.color??"",userName:t?.name??"Anonymous"}}function mr(e,t){let n=t?.doc;if(!n)return null;let o=e?.anchor??e,r=o?.anchorKind==="text"?"text":"line",i=n.lines,s=Math.min(Math.max(Math.round(o?.startLine??1),1),i),a=Math.min(Math.max(Math.round(o?.endLine??s),s),i),l=n.line(s).from,u=n.line(a).to,m=Math.min(Math.max(Math.round(o?.startIndex??l),0),n.length),d=Math.min(Math.max(Math.round(o?.endIndex??u),m),n.length);return{anchorEndLine:a,anchorKind:r,anchorQuote:oe(o?.anchorQuote||n.sliceString(m,d)),anchorStartLine:s,endIndex:d,startIndex:m}}var ve=class{constructor({getDoc:t,getEditorState:n,getLocalUser:o,onCommentsChange:r=null}){this.getDoc=t,this.getEditorState=n,this.getLocalUser=o,this.onCommentsChange=r,this.commentThreads=null,this.ydoc=null,this.ytext=null,this.handleCommentThreadsChange=null,this.handleTextChange=null}bind({commentThreads:t,ydoc:n,ytext:o}){this.unbind(),this.commentThreads=t,this.ydoc=n,this.ytext=o,this.handleCommentThreadsChange=()=>{this.emitCommentsChange()},this.handleTextChange=()=>{this.emitCommentsChange()},this.commentThreads.observeDeep(this.handleCommentThreadsChange),this.ytext?.observe?.(this.handleTextChange),this.emitCommentsChange()}unbind(){this.commentThreads&&this.handleCommentThreadsChange&&this.commentThreads.unobserveDeep(this.handleCommentThreadsChange),this.ytext&&this.handleTextChange&&this.ytext.unobserve(this.handleTextChange),this.commentThreads=null,this.ydoc=null,this.ytext=null,this.handleCommentThreadsChange=null,this.handleTextChange=null}emitCommentsChange(){this.onCommentsChange?.(this.getCommentThreads())}getCommentThreads(){return this.commentThreads?tn(this.commentThreads).map(t=>this.resolveCommentThread(t)).filter(Boolean):[]}createCommentThread({anchor:t,body:n}){let o=this.getEditorState();if(!o||!this.commentThreads||!this.ytext||!this.ydoc)return null;let r=st(n),i=mr(t,o);if(!r||!i)return null;let s=en({anchorEnd:G(U(this.ytext,i.endIndex)),anchorEndLine:i.anchorEndLine,anchorKind:i.anchorKind,anchorQuote:i.anchorQuote,anchorStart:G(U(this.ytext,i.startIndex)),anchorStartLine:i.anchorStartLine,createdAt:Date.now(),createdByColor:this.getLocalUser()?.color??"",createdByName:this.getLocalUser()?.name??"Anonymous",createdByPeerId:this.getLocalUser()?.peerId??"",id:at("thread"),messages:[On({body:r,user:this.getLocalUser()})]});return s?(this.ydoc.transact(()=>{this.commentThreads.push([s])},"comment-thread-create"),s.get("id")):null}replyToCommentThread(t,n){let o=st(n);if(!o||!this.ydoc)return null;let i=this.findSharedCommentThread(t)?.get("messages");if(!(i instanceof Jt))return null;let s=On({body:o,user:this.getLocalUser()});return this.ydoc.transact(()=>{i.push([s])},"comment-thread-reply"),s.id}deleteCommentThread(t){if(!this.commentThreads||!this.ydoc)return!1;let n=this.findSharedCommentThreadIndex(t);return n<0?!1:(this.ydoc.transact(()=>{this.commentThreads.delete(n,1)},"comment-thread-resolve"),!0)}findSharedCommentThread(t){return this.commentThreads?this.commentThreads.toArray().find(n=>n instanceof it&&n.get("id")===t)??null:null}findSharedCommentThreadIndex(t){return this.commentThreads?this.commentThreads.toArray().findIndex(n=>n instanceof it&&n.get("id")===t):-1}resolveCommentThread(t){let n=this.getEditorState();if(!t||!n||!this.ydoc)return null;let o=Zt(t);if(!o)return null;let r=this.resolveCommentPosition(o.anchorStart),i=this.resolveCommentPosition(o.anchorEnd),s=r?.index??n.doc.line(o.anchorStartLine).from,a=Math.min(Math.max(o.anchorEndLine??o.anchorStartLine,o.anchorStartLine),n.doc.lines),l=i?.index??n.doc.line(a).to,u=n.doc.lineAt(s).number,m=Math.min(Math.max(l,s),n.doc.length),d=n.doc.lineAt(m).number,g=n.doc.sliceString(s,o.anchorKind==="text"?Math.max(l,s):n.doc.line(d).to),y=Xt(g)||o.anchorQuote;return{...t,anchor:{endIndex:l,endLine:d,excerpt:y,quote:o.anchorQuote,startIndex:s,startLine:u,kind:o.anchorKind},anchorEnd:o.anchorEnd,anchorEndLine:o.anchorEndLine,anchorKind:o.anchorKind,anchorQuote:o.anchorQuote,anchorStart:o.anchorStart,anchorStartLine:o.anchorStartLine}}resolveCommentPosition(t){if(!t||!this.ydoc||!this.ytext)return null;try{let n=I(t),o=R(n,this.ydoc);return!o||o.type!==this.ytext?null:o}catch{return null}}};var we=class{constructor({localUser:t=null,onAwarenessChange:n=null,onConnectionChange:o=null,onInitialSync:r=null,preferredUserName:i,resolveAwarenessCursor:s=null}){this.onAwarenessChange=n,this.onConnectionChange=o,this.onInitialSync=r,this.preferredUserName=i,this.providedLocalUser=t,this.resolveAwarenessCursor=s??(()=>null),this.provider=null,this.awareness=null,this.localUser=null,this.ydoc=null,this.ytext=null,this.commentThreads=null,this.wsBaseUrl="",this.initialSyncComplete=!1,this.initialSyncPromise=Promise.resolve(),this.resolveInitialSync=null}normalizeViewport(t){if(!t||typeof t!="object")return null;let n=Number(t.topLine),o=Number(t.viewportRatio);return!Number.isFinite(n)||n<1?null:{topLine:Math.max(1,Math.round(n)),viewportRatio:Number.isFinite(o)?Math.min(Math.max(o,0),1):.35}}async initialize(t){this.wsBaseUrl=_t(),this.ydoc=new Gt,this.ytext=this.ydoc.getText("codemirror"),this.commentThreads=this.ydoc.getArray("comments");let n=new J(this.ytext),o=new Kt(this.wsBaseUrl,t,this.ydoc,{disableBc:!0,maxBackoffTime:5e3});Qt(o);let r=o.awareness,i=this.providedLocalUser??qt(this.preferredUserName);this.provider=o,this.awareness=r,this.localUser=i,this.initialSyncComplete=!1,this.initialSyncPromise=new Promise(a=>{this.resolveInitialSync=a}),r.setLocalStateField("user",i),r.on("change",()=>{this.onAwarenessChange?.(this.collectUsers(this.resolveAwarenessCursor))}),this.trackConnectionStatus();let s=!1;return o.on("sync",a=>{!a||s||(s=!0,this.initialSyncComplete=!0,this.resolveInitialSync?.(),this.resolveInitialSync=null,this.onInitialSync?.())}),{awareness:r,commentThreads:this.commentThreads,localUser:this.localUser,undoManager:n,ydoc:this.ydoc,ytext:this.ytext}}destroy(){this.resolveInitialSync?.(),this.resolveInitialSync=null,this.initialSyncComplete=!1,this.initialSyncPromise=Promise.resolve(),this.provider?.disconnect(),this.provider?.destroy(),this.provider=null,this.awareness=null,this.localUser=null,this.ydoc?.destroy(),this.ydoc=null,this.ytext=null,this.commentThreads=null}waitForInitialSync(t=1500){return this.initialSyncComplete?Promise.resolve():Promise.race([this.initialSyncPromise,new Promise(n=>{window.setTimeout(n,t)})])}getText(){return this.ytext?.toString()??""}getLocalUser(){return this.localUser}setUserName(t){let n=jt(t);return!n||!this.awareness||!this.localUser?null:(this.localUser={...this.localUser,name:n},this.awareness.setLocalStateField("user",this.localUser),n)}getUserCursor(t,n){if(!this.awareness)return null;let o=this.awareness.getStates().get(t);return n(o?.cursor)}getUserViewport(t){if(!this.awareness)return null;let n=this.awareness.getStates().get(t);return this.normalizeViewport(n?.viewport)}setLocalViewport(t){if(!this.awareness)return null;let n=this.normalizeViewport(t);return this.awareness.setLocalStateField("viewport",n),n}collectUsers(t=()=>null){if(!this.awareness)return[];let n=[];return this.awareness.getStates().forEach((o,r)=>{if(!o.user)return;let i=t(o.cursor);n.push({...i??{},...o.user,clientId:r,hasCursor:!!i,isLocal:r===this.awareness.clientID,viewport:this.normalizeViewport(o.viewport)})}),n}trackConnectionStatus(){if(!this.provider)return;let t=0,n=!1;this.provider.on("status",({status:o})=>{o==="connecting"&&(t+=1);let r=o==="connected"&&!n;o==="connected"&&(t=0,n=!0),this.onConnectionChange?.({attempts:t,firstConnection:r,hasEverConnected:n,status:o,unreachable:!n&&t>=3,wsBaseUrl:this.wsBaseUrl})})}};var dr=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),o=yt(e.state,n.from);return o.line?fr(e):o.block?gr(e):!1};function xt(e,t){return({state:n,dispatch:o})=>{if(n.readOnly)return!1;let r=e(t,n);return r?(o(n.update(r)),!0):!1}}var fr=xt(Cr,0);var pr=xt(qn,0);var gr=xt((e,t)=>qn(e,t,yr(t)),0);function yt(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}var ae=50;function xr(e,{open:t,close:n},o,r){let i=e.sliceDoc(o-ae,o),s=e.sliceDoc(r,r+ae),a=/\s*$/.exec(i)[0].length,l=/^\s*/.exec(s)[0].length,u=i.length-a;if(i.slice(u-t.length,u)==t&&s.slice(l,l+n.length)==n)return{open:{pos:o-a,margin:a&&1},close:{pos:r+l,margin:l&&1}};let m,d;r-o<=2*ae?m=d=e.sliceDoc(o,r):(m=e.sliceDoc(o,o+ae),d=e.sliceDoc(r-ae,r));let g=/^\s*/.exec(m)[0].length,y=/\s*$/.exec(d)[0].length,b=d.length-y-n.length;return m.slice(g,g+t.length)==t&&d.slice(b,b+n.length)==n?{open:{pos:o+g+t.length,margin:/\s/.test(m.charAt(g+t.length))?1:0},close:{pos:r-y-n.length,margin:/\s/.test(d.charAt(b-1))?1:0}}:null}function yr(e){let t=[];for(let n of e.selection.ranges){let o=e.doc.lineAt(n.from),r=n.to<=o.to?o:e.doc.lineAt(n.to);r.from>o.from&&r.from==n.to&&(r=n.to==o.to+1?o:e.doc.lineAt(n.to-1));let i=t.length-1;i>=0&&t[i].to>o.from?t[i].to=r.to:t.push({from:o.from+/^\s*/.exec(o.text)[0].length,to:r.to})}return t}function qn(e,t,n=t.selection.ranges){let o=n.map(i=>yt(t,i.from).block);if(!o.every(i=>i))return null;let r=n.map((i,s)=>xr(t,o[s],i.from,i.to));if(e!=2&&!r.every(i=>i))return{changes:t.changes(n.map((i,s)=>r[s]?[]:[{from:i.from,insert:o[s].open+" "},{from:i.to,insert:" "+o[s].close}]))};if(e!=1&&r.some(i=>i)){let i=[];for(let s=0,a;s<r.length;s++)if(a=r[s]){let l=o[s],{open:u,close:m}=a;i.push({from:u.pos-l.open.length,to:u.pos+u.margin},{from:m.pos-m.margin,to:m.pos+l.close.length})}return{changes:i}}return null}function Cr(e,t,n=t.selection.ranges){let o=[],r=-1;e:for(let{from:i,to:s}of n){let a=o.length,l=1e9,u;for(let m=i;m<=s;){let d=t.doc.lineAt(m);if(u==null&&(u=yt(t,d.from).line,!u))continue e;if(d.from>r&&(i==s||s>d.from)){r=d.from;let g=/^\s*/.exec(d.text)[0].length,y=g==d.length,b=d.text.slice(g,g+u.length)==u?g:-1;g<d.text.length&&g<l&&(l=g),o.push({line:d,comment:b,token:u,indent:g,empty:y,single:!1})}m=d.to+1}if(l<1e9)for(let m=a;m<o.length;m++)o[m].indent<o[m].line.text.length&&(o[m].indent=l);o.length==a+1&&(o[a].single=!0)}if(e!=2&&o.some(i=>i.comment<0&&(!i.empty||i.single))){let i=[];for(let{line:a,token:l,indent:u,empty:m,single:d}of o)(d||!m)&&i.push({from:a.from+u,insert:l+" "});let s=t.changes(i);return{changes:s,selection:t.selection.map(s,1)}}else if(e!=1&&o.some(i=>i.comment>=0)){let i=[];for(let{line:s,comment:a,token:l}of o)if(a>=0){let u=s.from+a,m=u+l.length;s.text[m-s.from]==" "&&m++,i.push({from:u,to:m})}return{changes:i}}return null}var dt=O.define(),Sr=O.define(),br=P.define(),Hn=P.define({combine(e){return ie(e,{minDepth:100,newGroupDelay:500,joinToEvent:(t,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,n)=>(o,r)=>t(o,r)||n(o,r)})}}),Yn=fe.define({create(){return H.empty},update(e,t){let n=t.state.facet(Hn),o=t.annotation(dt);if(o){let l=D.fromTransaction(t,o.selection),u=o.side,m=u==0?e.undone:e.done;return l?m=Ae(m,m.length,n.minDepth,l):m=Qn(m,t.startState.selection),new H(u==0?o.rest:m,u==0?m:o.rest)}let r=t.annotation(Sr);if((r=="full"||r=="before")&&(e=e.isolate()),t.annotation(ge.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let i=D.fromTransaction(t),s=t.annotation(ge.time),a=t.annotation(ge.userEvent);return i?e=e.addChanges(i,s,a,n,t):t.selection&&(e=e.addSelection(t.startState.selection,s,a,n.newGroupDelay)),(r=="full"||r=="after")&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(t=>t.toJSON()),undone:e.undone.map(t=>t.toJSON())}},fromJSON(e){return new H(e.done.map(D.fromJSON),e.undone.map(D.fromJSON))}});function Gn(e={}){return[Yn,Hn.of(e),x.domEventHandlers({beforeinput(t,n){let o=t.inputType=="historyUndo"?Jn:t.inputType=="historyRedo"?ft:null;return o?(t.preventDefault(),o(n)):!1}})]}function Te(e,t){return function({state:n,dispatch:o}){if(!t&&n.readOnly)return!1;let r=n.field(Yn,!1);if(!r)return!1;let i=r.pop(e,n,t);return i?(o(i),!0):!1}}var Jn=Te(0,!1),ft=Te(1,!1),kr=Te(0,!0),Lr=Te(1,!0);var D=class e{constructor(t,n,o,r,i){this.changes=t,this.effects=n,this.mapped=o,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,n,o;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(o=this.startSelection)===null||o===void 0?void 0:o.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(t){return new e(t.changes&&an.fromJSON(t.changes),[],t.mapped&&sn.fromJSON(t.mapped),t.startSelection&&p.fromJSON(t.startSelection),t.selectionsAfter.map(p.fromJSON))}static fromTransaction(t,n){let o=A;for(let r of t.startState.facet(br)){let i=r(t);i.length&&(o=o.concat(i))}return!o.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),o,void 0,n||t.startState.selection,A)}static selection(t){return new e(void 0,A,void 0,void 0,t)}};function Ae(e,t,n,o){let r=t+1>n+20?t-n-1:0,i=e.slice(r,t);return i.push(o),i}function vr(e,t){let n=[],o=!1;return e.iterChangedRanges((r,i)=>n.push(r,i)),t.iterChangedRanges((r,i,s,a)=>{for(let l=0;l<n.length;){let u=n[l++],m=n[l++];a>=u&&s<=m&&(o=!0)}}),o}function wr(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,o)=>n.empty!=t.ranges[o].empty).length===0}function Kn(e,t){return e.length?t.length?e.concat(t):e:t}var A=[],Mr=200;function Qn(e,t){if(e.length){let n=e[e.length-1],o=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Mr));return o.length&&o[o.length-1].eq(t)?e:(o.push(t),Ae(e,e.length-1,1e9,n.setSelAfter(o)))}else return[D.selection([t])]}function Ar(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function mt(e,t){if(!e.length)return e;let n=e.length,o=A;for(;n;){let r=Tr(e[n-1],t,o);if(r.changes&&!r.changes.empty||r.effects.length){let i=e.slice(0,n);return i[n-1]=r,i}else t=r.mapped,n--,o=r.selectionsAfter}return o.length?[D.selection(o)]:A}function Tr(e,t,n){let o=Kn(e.selectionsAfter.length?e.selectionsAfter.map(a=>a.map(t)):A,n);if(!e.changes)return D.selection(o);let r=e.changes.map(t),i=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(i):i;return new D(r,j.mapEffects(e.effects,t),s,e.startSelection.map(i),o)}var Dr=/^(input\.type|delete)($|\.)/,H=class e{constructor(t,n,o=0,r=void 0){this.done=t,this.undone=n,this.prevTime=o,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,o,r,i){let s=this.done,a=s[s.length-1];return a&&a.changes&&!a.changes.empty&&t.changes&&(!o||Dr.test(o))&&(!a.selectionsAfter.length&&n-this.prevTime<r.newGroupDelay&&r.joinToEvent(i,vr(a.changes,t.changes))||o=="input.type.compose")?s=Ae(s,s.length-1,r.minDepth,new D(t.changes.compose(a.changes),Kn(j.mapEffects(t.effects,a.changes),a.effects),a.mapped,a.startSelection,A)):s=Ae(s,s.length,r.minDepth,t),new e(s,A,n,o)}addSelection(t,n,o,r){let i=this.done.length?this.done[this.done.length-1].selectionsAfter:A;return i.length>0&&n-this.prevTime<r&&o==this.prevUserEvent&&o&&/^select($|\.)/.test(o)&&wr(i[i.length-1],t)?this:new e(Qn(this.done,t),this.undone,n,o)}addMapping(t){return new e(mt(this.done,t),mt(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,n,o){let r=t==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],s=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):n.selection);if(o&&i.selectionsAfter.length)return n.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:dt.of({side:t,rest:Ar(r),selection:s}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(i.changes){let a=r.length==1?A:r.slice(0,r.length-1);return i.mapped&&(a=mt(a,i.mapped)),n.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:dt.of({side:t,rest:a,selection:s}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}};H.empty=new H(A,A);var Xn=[{key:"Mod-z",run:Jn,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:ft,preventDefault:!0},{linux:"Ctrl-Shift-z",run:ft,preventDefault:!0},{key:"Mod-u",run:kr,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:Lr,preventDefault:!0}];function Q(e,t){return p.create(e.ranges.map(t),e.mainIndex)}function B(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function E({state:e,dispatch:t},n){let o=Q(e.selection,n);return o.eq(e.selection,!0)?!1:(t(B(e,o)),!0)}function De(e,t){return p.cursor(t?e.to:e.from)}function Zn(e,t){return E(e,n=>n.empty?e.moveByChar(n,t):De(n,t))}function L(e){return e.textDirectionAt(e.state.selection.main.head)==mn.LTR}var eo=e=>Zn(e,!L(e)),to=e=>Zn(e,L(e));function no(e,t){return E(e,n=>n.empty?e.moveByGroup(n,t):De(n,t))}var Br=e=>no(e,!L(e)),Er=e=>no(e,L(e));var Fs=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function Ir(e,t,n){if(t.type.prop(n))return!0;let o=t.to-t.from;return o&&(o>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function Be(e,t,n){let o=Ce(e).resolveInner(t.head),r=n?ye.closedBy:ye.openedBy;for(let l=t.head;;){let u=n?o.childAfter(l):o.childBefore(l);if(!u)break;Ir(e,u,r)?o=u:l=n?u.to:u.from}let i=o.type.prop(r),s,a;return i&&(s=n?q(e,o.from,1):q(e,o.to,-1))&&s.matched?a=n?s.end.to:s.end.from:a=n?o.to:o.from,p.cursor(a,n?-1:1)}var Rr=e=>E(e,t=>Be(e.state,t,!L(e))),Pr=e=>E(e,t=>Be(e.state,t,L(e)));function oo(e,t){return E(e,n=>{if(!n.empty)return De(n,t);let o=e.moveVertically(n,t);return o.head!=n.head?o:e.moveToLineBoundary(n,t)})}var ro=e=>oo(e,!1),io=e=>oo(e,!0);function so(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,o=0,r;if(t){for(let i of e.state.facet(x.scrollMargins)){let s=i(e);s?.top&&(n=Math.max(s?.top,n)),s?.bottom&&(o=Math.max(s?.bottom,o))}r=e.scrollDOM.clientHeight-n-o}else r=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:o,selfScroll:t,height:Math.max(e.defaultLineHeight,r-5)}}function ao(e,t){let n=so(e),{state:o}=e,r=Q(o.selection,s=>s.empty?e.moveVertically(s,t,n.height):De(s,t));if(r.eq(o.selection))return!1;let i;if(n.selfScroll){let s=e.coordsAtPos(o.selection.main.head),a=e.scrollDOM.getBoundingClientRect(),l=a.top+n.marginTop,u=a.bottom-n.marginBottom;s&&s.top>l&&s.bottom<u&&(i=x.scrollIntoView(r.main.head,{y:"start",yMargin:s.top-l}))}return e.dispatch(B(o,r),{effects:i}),!0}var Fn=e=>ao(e,!1),pt=e=>ao(e,!0);function N(e,t,n){let o=e.lineBlockAt(t.head),r=e.moveToLineBoundary(t,n);if(r.head==t.head&&r.head!=(n?o.to:o.from)&&(r=e.moveToLineBoundary(t,n,!1)),!n&&r.head==o.from&&o.length){let i=/^\s*/.exec(e.state.sliceDoc(o.from,Math.min(o.from+100,o.to)))[0].length;i&&t.head!=o.from+i&&(r=p.cursor(o.from+i))}return r}var Vr=e=>E(e,t=>N(e,t,!0)),Or=e=>E(e,t=>N(e,t,!1)),Fr=e=>E(e,t=>N(e,t,!L(e))),Ur=e=>E(e,t=>N(e,t,L(e))),Nr=e=>E(e,t=>p.cursor(e.lineBlockAt(t.head).from,1)),Wr=e=>E(e,t=>p.cursor(e.lineBlockAt(t.head).to,-1));function $r(e,t,n){let o=!1,r=Q(e.selection,i=>{let s=q(e,i.head,-1)||q(e,i.head,1)||i.head>0&&q(e,i.head-1,1)||i.head<e.doc.length&&q(e,i.head+1,-1);if(!s||!s.end)return i;o=!0;let a=s.start.from==i.head?s.end.to:s.end.from;return n?p.range(i.anchor,a):p.cursor(a)});return o?(t(B(e,r)),!0):!1}var zr=({state:e,dispatch:t})=>$r(e,t,!1);function T(e,t){let n=Q(e.state.selection,o=>{let r=t(o);return p.range(o.anchor,r.head,r.goalColumn,r.bidiLevel||void 0)});return n.eq(e.state.selection)?!1:(e.dispatch(B(e.state,n)),!0)}function lo(e,t){return T(e,n=>e.moveByChar(n,t))}var co=e=>lo(e,!L(e)),ho=e=>lo(e,L(e));function uo(e,t){return T(e,n=>e.moveByGroup(n,t))}var _r=e=>uo(e,!L(e)),jr=e=>uo(e,L(e));var qr=e=>T(e,t=>Be(e.state,t,!L(e))),Hr=e=>T(e,t=>Be(e.state,t,L(e)));function mo(e,t){return T(e,n=>e.moveVertically(n,t))}var fo=e=>mo(e,!1),po=e=>mo(e,!0);function go(e,t){return T(e,n=>e.moveVertically(n,t,so(e).height))}var Un=e=>go(e,!1),Nn=e=>go(e,!0),Yr=e=>T(e,t=>N(e,t,!0)),Gr=e=>T(e,t=>N(e,t,!1)),Jr=e=>T(e,t=>N(e,t,!L(e))),Kr=e=>T(e,t=>N(e,t,L(e))),Qr=e=>T(e,t=>p.cursor(e.lineBlockAt(t.head).from)),Xr=e=>T(e,t=>p.cursor(e.lineBlockAt(t.head).to)),Wn=({state:e,dispatch:t})=>(t(B(e,{anchor:0})),!0),$n=({state:e,dispatch:t})=>(t(B(e,{anchor:e.doc.length})),!0),zn=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:0})),!0),_n=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),Zr=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),ei=({state:e,dispatch:t})=>{let n=Ee(e).map(({from:o,to:r})=>p.range(o,Math.min(r+1,e.doc.length)));return t(e.update({selection:p.create(n),userEvent:"select"})),!0},ti=({state:e,dispatch:t})=>{let n=Q(e.selection,o=>{let r=Ce(e),i=r.resolveStack(o.from,1);if(o.empty){let s=r.resolveStack(o.from,-1);s.node.from>=i.node.from&&s.node.to<=i.node.to&&(i=s)}for(let s=i;s;s=s.next){let{node:a}=s;if((a.from<o.from&&a.to>=o.to||a.to>o.to&&a.from<=o.from)&&s.next)return p.range(a.to,a.from)}return o});return n.eq(e.selection)?!1:(t(B(e,n)),!0)};function xo(e,t){let{state:n}=e,o=n.selection,r=n.selection.ranges.slice();for(let i of n.selection.ranges){let s=n.doc.lineAt(i.head);if(t?s.to<e.state.doc.length:s.from>0)for(let a=i;;){let l=e.moveVertically(a,t);if(l.head<s.from||l.head>s.to){r.some(u=>u.head==l.head)||r.push(l);break}else{if(l.head==a.head)break;a=l}}}return r.length==o.ranges.length?!1:(e.dispatch(B(n,p.create(r,r.length-1))),!0)}var ni=e=>xo(e,!1),oi=e=>xo(e,!0),ri=({state:e,dispatch:t})=>{let n=e.selection,o=null;return n.ranges.length>1?o=p.create([n.main]):n.main.empty||(o=p.create([p.cursor(n.main.head)])),o?(t(B(e,o)),!0):!1};function le(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:o}=e,r=o.changeByRange(i=>{let{from:s,to:a}=i;if(s==a){let l=t(i);l<s?(n="delete.backward",l=Me(e,l,!1)):l>s&&(n="delete.forward",l=Me(e,l,!0)),s=Math.min(s,l),a=Math.max(a,l)}else s=Me(e,s,!1),a=Me(e,a,!0);return s==a?{range:i}:{changes:{from:s,to:a},range:p.cursor(s,s<i.head?-1:1)}});return r.changes.empty?!1:(e.dispatch(o.update(r,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?x.announce.of(o.phrase("Selection deleted")):void 0})),!0)}function Me(e,t,n){if(e instanceof x)for(let o of e.state.facet(x.atomicRanges).map(r=>r(e)))o.between(t,t,(r,i)=>{r<t&&i>t&&(t=n?i:r)});return t}var yo=(e,t,n)=>le(e,o=>{let r=o.from,{state:i}=e,s=i.doc.lineAt(r),a,l;if(n&&!t&&r>s.from&&r<s.from+200&&!/[^ \t]/.test(a=s.text.slice(0,r-s.from))){if(a[a.length-1]==" ")return r-1;let u=xe(a,i.tabSize),m=u%be(i)||be(i);for(let d=0;d<m&&a[a.length-1-d]==" ";d++)r--;l=r}else l=V(s.text,r-s.from,t,t)+s.from,l==r&&s.number!=(t?i.doc.lines:1)?l+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(s.text.slice(l-s.from,r-s.from))&&(l=V(s.text,l-s.from,!1,!1)+s.from);return l}),gt=e=>yo(e,!1,!0);var Co=e=>yo(e,!0,!1),So=(e,t)=>le(e,n=>{let o=n.head,{state:r}=e,i=r.doc.lineAt(o),s=r.charCategorizer(o);for(let a=null;;){if(o==(t?i.to:i.from)){o==n.head&&i.number!=(t?r.doc.lines:1)&&(o+=t?1:-1);break}let l=V(i.text,o-i.from,t)+i.from,u=i.text.slice(Math.min(o,l)-i.from,Math.max(o,l)-i.from),m=s(u);if(a!=null&&m!=a)break;(u!=" "||o!=n.head)&&(a=m),o=l}return o}),bo=e=>So(e,!1),ii=e=>So(e,!0);var si=e=>le(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)});var ai=e=>le(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),li=e=>le(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)});var ci=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(o=>({changes:{from:o.from,to:o.to,insert:lt.of(["",""])},range:p.cursor(o.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},hi=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(o=>{if(!o.empty||o.from==0||o.from==e.doc.length)return{range:o};let r=o.from,i=e.doc.lineAt(r),s=r==i.from?r-1:V(i.text,r-i.from,!1)+i.from,a=r==i.to?r+1:V(i.text,r-i.from,!0)+i.from;return{changes:{from:s,to:a,insert:e.doc.slice(r,a).append(e.doc.slice(s,r))},range:p.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Ee(e){let t=[],n=-1;for(let o of e.selection.ranges){let r=e.doc.lineAt(o.from),i=e.doc.lineAt(o.to);if(!o.empty&&o.to==i.from&&(i=e.doc.lineAt(o.to-1)),n>=r.number){let s=t[t.length-1];s.to=i.to,s.ranges.push(o)}else t.push({from:r.from,to:i.to,ranges:[o]});n=i.number+1}return t}function ko(e,t,n){if(e.readOnly)return!1;let o=[],r=[];for(let i of Ee(e)){if(n?i.to==e.doc.length:i.from==0)continue;let s=e.doc.lineAt(n?i.to+1:i.from-1),a=s.length+1;if(n){o.push({from:i.to,to:s.to},{from:i.from,insert:s.text+e.lineBreak});for(let l of i.ranges)r.push(p.range(Math.min(e.doc.length,l.anchor+a),Math.min(e.doc.length,l.head+a)))}else{o.push({from:s.from,to:i.from},{from:i.to,insert:e.lineBreak+s.text});for(let l of i.ranges)r.push(p.range(l.anchor-a,l.head-a))}}return o.length?(t(e.update({changes:o,scrollIntoView:!0,selection:p.create(r,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}var ui=({state:e,dispatch:t})=>ko(e,t,!1),mi=({state:e,dispatch:t})=>ko(e,t,!0);function Lo(e,t,n){if(e.readOnly)return!1;let o=[];for(let i of Ee(e))n?o.push({from:i.from,insert:e.doc.slice(i.from,i.to)+e.lineBreak}):o.push({from:i.to,insert:e.lineBreak+e.doc.slice(i.from,i.to)});let r=e.changes(o);return t(e.update({changes:r,selection:e.selection.map(r,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var di=({state:e,dispatch:t})=>Lo(e,t,!1),fi=({state:e,dispatch:t})=>Lo(e,t,!0),pi=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(Ee(t).map(({from:r,to:i})=>(r>0?r--:i<t.doc.length&&i++,{from:r,to:i}))),o=Q(t.selection,r=>{let i;if(e.lineWrapping){let s=e.lineBlockAt(r.head),a=e.coordsAtPos(r.head,r.assoc||1);a&&(i=s.bottom+e.documentTop-a.bottom+e.defaultLineHeight/2)}return e.moveVertically(r,!0,i)}).map(n);return e.dispatch({changes:n,selection:o,scrollIntoView:!0,userEvent:"delete.line"}),!0};function gi(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=Ce(e).resolveInner(t),o=n.childBefore(t),r=n.childAfter(t),i;return o&&r&&o.to<=t&&r.from>=t&&(i=o.type.prop(ye.closedBy))&&i.indexOf(r.name)>-1&&e.doc.lineAt(o.to).from==e.doc.lineAt(r.from).from&&!/\S/.test(e.sliceDoc(o.to,r.from))?{from:o.to,to:r.from}:null}var jn=vo(!1),xi=vo(!0);function vo(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let o=t.changeByRange(r=>{let{from:i,to:s}=r,a=t.doc.lineAt(i),l=!e&&i==s&&gi(t,i);e&&(i=s=(s<=a.to?a:t.doc.lineAt(s)).to);let u=new ut(t,{simulateBreak:i,simulateDoubleBreak:!!l}),m=ht(u,i);for(m==null&&(m=xe(/^\s*/.exec(t.doc.lineAt(i).text)[0],t.tabSize));s<a.to&&/\s/.test(a.text[s-a.from]);)s++;l?{from:i,to:s}=l:i>a.from&&i<a.from+100&&!/\S/.test(a.text.slice(0,i))&&(i=a.from);let d=["",se(t,m)];return l&&d.push(se(t,u.lineIndent(a.from,-1))),{changes:{from:i,to:s,insert:lt.of(d)},range:p.cursor(i+1+d[1].length)}});return n(t.update(o,{scrollIntoView:!0,userEvent:"input"})),!0}}function Ct(e,t){let n=-1;return e.changeByRange(o=>{let r=[];for(let s=o.from;s<=o.to;){let a=e.doc.lineAt(s);a.number>n&&(o.empty||o.to>a.from)&&(t(a,r,o),n=a.number),s=a.to+1}let i=e.changes(r);return{changes:r,range:p.range(i.mapPos(o.anchor,1),i.mapPos(o.head,1))}})}var yi=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),o=new ut(e,{overrideIndentation:i=>{let s=n[i];return s??-1}}),r=Ct(e,(i,s,a)=>{let l=ht(o,i.from);if(l==null)return;/\S/.test(i.text)||(l=0);let u=/^\s*/.exec(i.text)[0],m=se(e,l);(u!=m||a.from<i.from+u.length)&&(n[i.from]=l,s.push({from:i.from,to:i.from+u.length,insert:m}))});return r.changes.empty||t(e.update(r,{userEvent:"indent"})),!0},wo=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Ct(e,(n,o)=>{o.push({from:n.from,insert:e.facet(vn)})}),{userEvent:"input.indent"})),!0),Mo=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Ct(e,(n,o)=>{let r=/^\s*/.exec(n.text)[0];if(!r)return;let i=xe(r,e.tabSize),s=0,a=se(e,Math.max(0,i-be(e)));for(;s<r.length&&s<a.length&&r.charCodeAt(s)==a.charCodeAt(s);)s++;o.push({from:n.from+s,to:n.from+r.length,insert:a.slice(s)})}),{userEvent:"delete.dedent"})),!0),Ci=e=>(e.setTabFocusMode(),!0);var Si=[{key:"Ctrl-b",run:eo,shift:co,preventDefault:!0},{key:"Ctrl-f",run:to,shift:ho},{key:"Ctrl-p",run:ro,shift:fo},{key:"Ctrl-n",run:io,shift:po},{key:"Ctrl-a",run:Nr,shift:Qr},{key:"Ctrl-e",run:Wr,shift:Xr},{key:"Ctrl-d",run:Co},{key:"Ctrl-h",run:gt},{key:"Ctrl-k",run:si},{key:"Ctrl-Alt-h",run:bo},{key:"Ctrl-o",run:ci},{key:"Ctrl-t",run:hi},{key:"Ctrl-v",run:pt}],bi=[{key:"ArrowLeft",run:eo,shift:co,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:Br,shift:_r,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Fr,shift:Jr,preventDefault:!0},{key:"ArrowRight",run:to,shift:ho,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Er,shift:jr,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Ur,shift:Kr,preventDefault:!0},{key:"ArrowUp",run:ro,shift:fo,preventDefault:!0},{mac:"Cmd-ArrowUp",run:Wn,shift:zn},{mac:"Ctrl-ArrowUp",run:Fn,shift:Un},{key:"ArrowDown",run:io,shift:po,preventDefault:!0},{mac:"Cmd-ArrowDown",run:$n,shift:_n},{mac:"Ctrl-ArrowDown",run:pt,shift:Nn},{key:"PageUp",run:Fn,shift:Un},{key:"PageDown",run:pt,shift:Nn},{key:"Home",run:Or,shift:Gr,preventDefault:!0},{key:"Mod-Home",run:Wn,shift:zn},{key:"End",run:Vr,shift:Yr,preventDefault:!0},{key:"Mod-End",run:$n,shift:_n},{key:"Enter",run:jn,shift:jn},{key:"Mod-a",run:Zr},{key:"Backspace",run:gt,shift:gt,preventDefault:!0},{key:"Delete",run:Co,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:bo,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:ii,preventDefault:!0},{mac:"Mod-Backspace",run:ai,preventDefault:!0},{mac:"Mod-Delete",run:li,preventDefault:!0}].concat(Si.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),Ao=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Rr,shift:qr},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Pr,shift:Hr},{key:"Alt-ArrowUp",run:ui},{key:"Shift-Alt-ArrowUp",run:di},{key:"Alt-ArrowDown",run:mi},{key:"Shift-Alt-ArrowDown",run:fi},{key:"Mod-Alt-ArrowUp",run:ni},{key:"Mod-Alt-ArrowDown",run:oi},{key:"Escape",run:ri},{key:"Mod-Enter",run:xi},{key:"Alt-l",mac:"Ctrl-l",run:ei},{key:"Mod-i",run:ti,preventDefault:!0},{key:"Mod-[",run:Mo},{key:"Mod-]",run:wo},{key:"Mod-Alt-\\",run:yi},{key:"Shift-Mod-k",run:pi},{key:"Shift-Mod-\\",run:zr},{key:"Mod-/",run:dr},{key:"Alt-A",run:pr},{key:"Ctrl-m",mac:"Shift-Alt-m",run:Ci}].concat(bi),To={key:"Tab",run:wo,shift:Mo};function h(e){return new Se(Le.define(e))}function W(e){return import("./dist-DPBSGC3Y.js").then(t=>t.sql({dialect:t[e]}))}var Do=[c.of({name:"C",extensions:["c","h","ino"],load(){return import("./dist-IQA4KVJK.js").then(e=>e.cpp())}}),c.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return import("./dist-IQA4KVJK.js").then(e=>e.cpp())}}),c.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return W("Cassandra")}}),c.of({name:"CSS",extensions:["css"],load(){return import("./dist-HAB5NIXI.js").then(e=>e.css())}}),c.of({name:"Go",extensions:["go"],load(){return import("./dist-7RQKSOUX.js").then(e=>e.go())}}),c.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return import("./dist-XOODBV4L.js").then(e=>e.html())}}),c.of({name:"Java",extensions:["java"],load(){return import("./dist-RCQFQRLD.js").then(e=>e.java())}}),c.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return import("./dist-ERADYPEK.js").then(e=>e.javascript())}}),c.of({name:"Jinja",extensions:["j2","jinja","jinja2"],load(){return import("./dist-E5NM7OBW.js").then(e=>e.jinja())}}),c.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return import("./dist-F43RIHBZ.js").then(e=>e.json())}}),c.of({name:"JSX",extensions:["jsx"],load(){return import("./dist-ERADYPEK.js").then(e=>e.javascript({jsx:!0}))}}),c.of({name:"LESS",extensions:["less"],load(){return import("./dist-ZFZNCRZY.js").then(e=>e.less())}}),c.of({name:"Liquid",extensions:["liquid"],load(){return import("./dist-RSJGLSKC.js").then(e=>e.liquid())}}),c.of({name:"MariaDB SQL",load(){return W("MariaSQL")}}),c.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return import("./dist-RQLC4GVI.js").then(e=>e.markdown())}}),c.of({name:"MS SQL",load(){return W("MSSQL")}}),c.of({name:"MySQL",load(){return W("MySQL")}}),c.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return import("./dist-HG23OLRA.js").then(e=>e.php())}}),c.of({name:"PLSQL",extensions:["pls"],load(){return W("PLSQL")}}),c.of({name:"PostgreSQL",load(){return W("PostgreSQL")}}),c.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return import("./dist-OIQTNVT2.js").then(e=>e.python())}}),c.of({name:"Rust",extensions:["rs"],load(){return import("./dist-VCFTF7Z6.js").then(e=>e.rust())}}),c.of({name:"Sass",extensions:["sass"],load(){return import("./dist-ARWGZ6MN.js").then(e=>e.sass({indented:!0}))}}),c.of({name:"SCSS",extensions:["scss"],load(){return import("./dist-ARWGZ6MN.js").then(e=>e.sass())}}),c.of({name:"SQL",extensions:["sql"],load(){return W("StandardSQL")}}),c.of({name:"SQLite",load(){return W("SQLite")}}),c.of({name:"TSX",extensions:["tsx"],load(){return import("./dist-ERADYPEK.js").then(e=>e.javascript({jsx:!0,typescript:!0}))}}),c.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return import("./dist-ERADYPEK.js").then(e=>e.javascript({typescript:!0}))}}),c.of({name:"WebAssembly",extensions:["wat","wast"],load(){return import("./dist-PMZJ734S.js").then(e=>e.wast())}}),c.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return import("./dist-IEJXBSDJ.js").then(e=>e.xml())}}),c.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return import("./dist-VTO23SHH.js").then(e=>e.yaml())}}),c.of({name:"APL",extensions:["dyalog","apl"],load(){return import("./apl-C5P5JBDI.js").then(e=>h(e.apl))}}),c.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return import("./asciiarmor-3NCLLELT.js").then(e=>h(e.asciiArmor))}}),c.of({name:"ASN.1",extensions:["asn","asn1"],load(){return import("./asn1-KF4WXU3M.js").then(e=>h(e.asn1({})))}}),c.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return import("./asterisk-EA3VIN65.js").then(e=>h(e.asterisk))}}),c.of({name:"Brainfuck",extensions:["b","bf"],load(){return import("./brainfuck-A3CTQVFD.js").then(e=>h(e.brainfuck))}}),c.of({name:"Cobol",extensions:["cob","cpy"],load(){return import("./cobol-V6EIK6DN.js").then(e=>h(e.cobol))}}),c.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return import("./clike-RTBH33GE.js").then(e=>h(e.csharp))}}),c.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return import("./clojure-BR2VJ2JI.js").then(e=>h(e.clojure))}}),c.of({name:"ClojureScript",extensions:["cljs"],load(){return import("./clojure-BR2VJ2JI.js").then(e=>h(e.clojure))}}),c.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return import("./css-C5DVWGB4.js").then(e=>h(e.gss))}}),c.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return import("./cmake-2HEWVFEE.js").then(e=>h(e.cmake))}}),c.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return import("./coffeescript-JW3ZOGMD.js").then(e=>h(e.coffeeScript))}}),c.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return import("./commonlisp-UCWSIHYK.js").then(e=>h(e.commonLisp))}}),c.of({name:"Cypher",extensions:["cyp","cypher"],load(){return import("./cypher-K7FZM5GC.js").then(e=>h(e.cypher))}}),c.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return import("./python-6YGH4S47.js").then(e=>h(e.cython))}}),c.of({name:"Crystal",extensions:["cr"],load(){return import("./crystal-GR4VLC3M.js").then(e=>h(e.crystal))}}),c.of({name:"D",extensions:["d"],load(){return import("./d-CF3QNNH5.js").then(e=>h(e.d))}}),c.of({name:"Dart",extensions:["dart"],load(){return import("./clike-RTBH33GE.js").then(e=>h(e.dart))}}),c.of({name:"diff",extensions:["diff","patch"],load(){return import("./diff-KOMSZU7O.js").then(e=>h(e.diff))}}),c.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return import("./dockerfile-XCIKYOSI.js").then(e=>h(e.dockerFile))}}),c.of({name:"DTD",extensions:["dtd"],load(){return import("./dtd-3XFH7W6Z.js").then(e=>h(e.dtd))}}),c.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return import("./dylan-3UWPKVOR.js").then(e=>h(e.dylan))}}),c.of({name:"EBNF",load(){return import("./ebnf-OLHTL3VN.js").then(e=>h(e.ebnf))}}),c.of({name:"ECL",extensions:["ecl"],load(){return import("./ecl-43LZ3ZRM.js").then(e=>h(e.ecl))}}),c.of({name:"edn",extensions:["edn"],load(){return import("./clojure-BR2VJ2JI.js").then(e=>h(e.clojure))}}),c.of({name:"Eiffel",extensions:["e"],load(){return import("./eiffel-ISPO2UJF.js").then(e=>h(e.eiffel))}}),c.of({name:"Elm",extensions:["elm"],load(){return import("./elm-CLK576PK.js").then(e=>h(e.elm))}}),c.of({name:"Erlang",extensions:["erl"],load(){return import("./erlang-AVQXQFOT.js").then(e=>h(e.erlang))}}),c.of({name:"Esper",load(){return import("./sql-BPLIIUYC.js").then(e=>h(e.esper))}}),c.of({name:"Factor",extensions:["factor"],load(){return import("./factor-CRTVBD6Q.js").then(e=>h(e.factor))}}),c.of({name:"FCL",load(){return import("./fcl-FX24LKTH.js").then(e=>h(e.fcl))}}),c.of({name:"Forth",extensions:["forth","fth","4th"],load(){return import("./forth-YKDKCTVS.js").then(e=>h(e.forth))}}),c.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return import("./fortran-UJWC6SLU.js").then(e=>h(e.fortran))}}),c.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return import("./mllike-VV3KS46B.js").then(e=>h(e.fSharp))}}),c.of({name:"Gas",extensions:["s"],load(){return import("./gas-MYEMWGRE.js").then(e=>h(e.gas))}}),c.of({name:"Gherkin",extensions:["feature"],load(){return import("./gherkin-JWHAU2YG.js").then(e=>h(e.gherkin))}}),c.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return import("./groovy-QZIZQIAK.js").then(e=>h(e.groovy))}}),c.of({name:"Haskell",extensions:["hs"],load(){return import("./haskell-JR3G7YNW.js").then(e=>h(e.haskell))}}),c.of({name:"Haxe",extensions:["hx"],load(){return import("./haxe-TVLAIYEN.js").then(e=>h(e.haxe))}}),c.of({name:"HXML",extensions:["hxml"],load(){return import("./haxe-TVLAIYEN.js").then(e=>h(e.hxml))}}),c.of({name:"HTTP",load(){return import("./http-YXQRE77G.js").then(e=>h(e.http))}}),c.of({name:"IDL",extensions:["pro"],load(){return import("./idl-RAQGJ6LJ.js").then(e=>h(e.idl))}}),c.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return import("./javascript-NM7KDJUE.js").then(e=>h(e.jsonld))}}),c.of({name:"Julia",extensions:["jl"],load(){return import("./julia-LG3BH25B.js").then(e=>h(e.julia))}}),c.of({name:"Kotlin",extensions:["kt","kts"],load(){return import("./clike-RTBH33GE.js").then(e=>h(e.kotlin))}}),c.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return import("./livescript-4CVWVI4M.js").then(e=>h(e.liveScript))}}),c.of({name:"Lua",extensions:["lua"],load(){return import("./lua-VWGE7DQ7.js").then(e=>h(e.lua))}}),c.of({name:"mIRC",extensions:["mrc"],load(){return import("./mirc-565WBI76.js").then(e=>h(e.mirc))}}),c.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return import("./mathematica-D7APQSEU.js").then(e=>h(e.mathematica))}}),c.of({name:"Modelica",extensions:["mo"],load(){return import("./modelica-EGX44FZV.js").then(e=>h(e.modelica))}}),c.of({name:"MUMPS",extensions:["mps"],load(){return import("./mumps-POZYWSMI.js").then(e=>h(e.mumps))}}),c.of({name:"Mbox",extensions:["mbox"],load(){return import("./mbox-BN3XQBYX.js").then(e=>h(e.mbox))}}),c.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return import("./nginx-JUBX55EU.js").then(e=>h(e.nginx))}}),c.of({name:"NSIS",extensions:["nsh","nsi"],load(){return import("./nsis-RC4CREGM.js").then(e=>h(e.nsis))}}),c.of({name:"NTriples",extensions:["nt","nq"],load(){return import("./ntriples-4WK6CNVE.js").then(e=>h(e.ntriples))}}),c.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return import("./clike-RTBH33GE.js").then(e=>h(e.objectiveC))}}),c.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return import("./clike-RTBH33GE.js").then(e=>h(e.objectiveCpp))}}),c.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return import("./mllike-VV3KS46B.js").then(e=>h(e.oCaml))}}),c.of({name:"Octave",extensions:["m"],load(){return import("./octave-GOKFN2V7.js").then(e=>h(e.octave))}}),c.of({name:"Oz",extensions:["oz"],load(){return import("./oz-OQUMNC63.js").then(e=>h(e.oz))}}),c.of({name:"Pascal",extensions:["p","pas"],load(){return import("./pascal-BBWQWWWD.js").then(e=>h(e.pascal))}}),c.of({name:"Perl",extensions:["pl","pm"],load(){return import("./perl-KTPJTTAM.js").then(e=>h(e.perl))}}),c.of({name:"Pig",extensions:["pig"],load(){return import("./pig-IJMBS4FZ.js").then(e=>h(e.pig))}}),c.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return import("./powershell-6YGCBHDP.js").then(e=>h(e.powerShell))}}),c.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return import("./properties-5QTD3364.js").then(e=>h(e.properties))}}),c.of({name:"ProtoBuf",extensions:["proto"],load(){return import("./protobuf-LTRWBIK3.js").then(e=>h(e.protobuf))}}),c.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return import("./pug-U4PV3WLG.js").then(e=>h(e.pug))}}),c.of({name:"Puppet",extensions:["pp"],load(){return import("./puppet-WGYJPR3Y.js").then(e=>h(e.puppet))}}),c.of({name:"Q",extensions:["q"],load(){return import("./q-VIG4IJLI.js").then(e=>h(e.q))}}),c.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return import("./r-NVPCXGTR.js").then(e=>h(e.r))}}),c.of({name:"RPM Changes",load(){return import("./rpm-UEA257HD.js").then(e=>h(e.rpmChanges))}}),c.of({name:"RPM Spec",extensions:["spec"],load(){return import("./rpm-UEA257HD.js").then(e=>h(e.rpmSpec))}}),c.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return import("./ruby-KPQRAJGE.js").then(e=>h(e.ruby))}}),c.of({name:"SAS",extensions:["sas"],load(){return import("./sas-L7VATVH5.js").then(e=>h(e.sas))}}),c.of({name:"Scala",extensions:["scala"],load(){return import("./clike-RTBH33GE.js").then(e=>h(e.scala))}}),c.of({name:"Scheme",extensions:["scm","ss"],load(){return import("./scheme-T2NOWR3P.js").then(e=>h(e.scheme))}}),c.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return import("./shell-DLVDUNFA.js").then(e=>h(e.shell))}}),c.of({name:"Sieve",extensions:["siv","sieve"],load(){return import("./sieve-BKBZYDBU.js").then(e=>h(e.sieve))}}),c.of({name:"Smalltalk",extensions:["st"],load(){return import("./smalltalk-WRJQKJSD.js").then(e=>h(e.smalltalk))}}),c.of({name:"Solr",load(){return import("./solr-66B3BIDL.js").then(e=>h(e.solr))}}),c.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return import("./mllike-VV3KS46B.js").then(e=>h(e.sml))}}),c.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return import("./sparql-S25Z47JG.js").then(e=>h(e.sparql))}}),c.of({name:"Spreadsheet",alias:["excel","formula"],load(){return import("./spreadsheet-B272EF7Y.js").then(e=>h(e.spreadsheet))}}),c.of({name:"Squirrel",extensions:["nut"],load(){return import("./clike-RTBH33GE.js").then(e=>h(e.squirrel))}}),c.of({name:"Stylus",extensions:["styl"],load(){return import("./stylus-PJUHLGPT.js").then(e=>h(e.stylus))}}),c.of({name:"Swift",extensions:["swift"],load(){return import("./swift-UYHTO4SX.js").then(e=>h(e.swift))}}),c.of({name:"sTeX",load(){return import("./stex-4IJY64QX.js").then(e=>h(e.stex))}}),c.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return import("./stex-4IJY64QX.js").then(e=>h(e.stex))}}),c.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return import("./verilog-EWWQPMNN.js").then(e=>h(e.verilog))}}),c.of({name:"Tcl",extensions:["tcl"],load(){return import("./tcl-OQ5J3VO2.js").then(e=>h(e.tcl))}}),c.of({name:"Textile",extensions:["textile"],load(){return import("./textile-NOGVBEYF.js").then(e=>h(e.textile))}}),c.of({name:"TiddlyWiki",load(){return import("./tiddlywiki-SYTK4QUE.js").then(e=>h(e.tiddlyWiki))}}),c.of({name:"Tiki wiki",load(){return import("./tiki-P7K4ZLOM.js").then(e=>h(e.tiki))}}),c.of({name:"TOML",extensions:["toml"],load(){return import("./toml-AUZYRP36.js").then(e=>h(e.toml))}}),c.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return import("./troff-XFYJNQOJ.js").then(e=>h(e.troff))}}),c.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return import("./ttcn-AK2IXWU6.js").then(e=>h(e.ttcn))}}),c.of({name:"TTCN_CFG",extensions:["cfg"],load(){return import("./ttcn-cfg-3IDPIYPU.js").then(e=>h(e.ttcnCfg))}}),c.of({name:"Turtle",extensions:["ttl"],load(){return import("./turtle-OIDMF46P.js").then(e=>h(e.turtle))}}),c.of({name:"Web IDL",extensions:["webidl"],load(){return import("./webidl-XVBHXCRV.js").then(e=>h(e.webIDL))}}),c.of({name:"VB.NET",extensions:["vb"],load(){return import("./vb-J6K4XVA2.js").then(e=>h(e.vb))}}),c.of({name:"VBScript",extensions:["vbs"],load(){return import("./vbscript-FM7DDZZE.js").then(e=>h(e.vbScript))}}),c.of({name:"Velocity",extensions:["vtl"],load(){return import("./velocity-6KZFEOFD.js").then(e=>h(e.velocity))}}),c.of({name:"Verilog",extensions:["v"],load(){return import("./verilog-EWWQPMNN.js").then(e=>h(e.verilog))}}),c.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return import("./vhdl-CJ3M4IHI.js").then(e=>h(e.vhdl))}}),c.of({name:"XQuery",extensions:["xy","xquery","xq","xqm","xqy"],load(){return import("./xquery-7WZOZ4UK.js").then(e=>h(e.xQuery))}}),c.of({name:"Yacas",extensions:["ys"],load(){return import("./yacas-MZ2ZZPF3.js").then(e=>h(e.yacas))}}),c.of({name:"Z80",extensions:["z80"],load(){return import("./z80-I447CBF7.js").then(e=>h(e.z80))}}),c.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return import("./mscgen-GFGTHENT.js").then(e=>h(e.mscgen))}}),c.of({name:"X\xF9",extensions:["xu"],load(){return import("./mscgen-GFGTHENT.js").then(e=>h(e.xu))}}),c.of({name:"MsGenny",extensions:["msgenny"],load(){return import("./mscgen-GFGTHENT.js").then(e=>h(e.msgenny))}}),c.of({name:"Vue",extensions:["vue"],load(){return import("./dist-E36PJE5M.js").then(e=>e.vue())}}),c.of({name:"Angular Template",load(){return import("./dist-SGNQZVVX.js").then(e=>e.angular())}})];var Bo=typeof String.prototype.normalize=="function"?e=>e.normalize("NFKD"):e=>e,z=class{constructor(t,n,o=0,r=t.length,i,s){this.test=s,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(o,r),this.bufferStart=o,this.normalize=i?a=>i(Bo(a)):Bo,this.query=this.normalize(n)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return nn(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let n=on(t),o=this.bufferStart+this.bufferPos;this.bufferPos+=rn(t);let r=this.normalize(n);if(r.length)for(let i=0,s=o;;i++){let a=r.charCodeAt(i),l=this.match(a,s,this.bufferPos+this.bufferStart);if(i==r.length-1){if(l)return this.value=l,this;break}s==o&&i<n.length&&n.charCodeAt(i)==a&&s++}}}match(t,n,o){let r=null;for(let i=0;i<this.matches.length;i+=2){let s=this.matches[i],a=!1;this.query.charCodeAt(s)==t&&(s==this.query.length-1?r={from:this.matches[i+1],to:o}:(this.matches[i]++,a=!0)),a||(this.matches.splice(i,2),i-=2)}return this.query.charCodeAt(0)==t&&(this.query.length==1?r={from:n,to:o}:this.matches.push(1,n)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<"u"&&(z.prototype[Symbol.iterator]=function(){return this});var Ro={from:-1,to:-1,match:/.*/.exec("")},wt="gm"+(/x/.unicode==null?"":"u"),Pe=class{constructor(t,n,o,r=0,i=t.length){if(this.text=t,this.to=i,this.curLine="",this.done=!1,this.value=Ro,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new Oe(t,n,o,r,i);this.re=new RegExp(n,wt+(o?.ignoreCase?"i":"")),this.test=o?.test,this.iter=t.iter();let s=t.lineAt(r);this.curLineStart=s.from,this.matchPos=Fe(t,r),this.getLine(this.curLineStart)}getLine(t){this.iter.next(t),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let o=this.curLineStart+n.index,r=o+n[0].length;if(this.matchPos=Fe(this.text,r+(o==r?1:0)),o==this.curLineStart+this.curLine.length&&this.nextLine(),(o<r||o>this.value.to)&&(!this.test||this.test(o,r,n)))return this.value={from:o,to:r,match:n},this;t=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),t=0;else return this.done=!0,this}}},St=new WeakMap,Ve=class e{constructor(t,n){this.from=t,this.text=n}get to(){return this.from+this.text.length}static get(t,n,o){let r=St.get(t);if(!r||r.from>=o||r.to<=n){let a=new e(n,t.sliceString(n,o));return St.set(t,a),a}if(r.from==n&&r.to==o)return r;let{text:i,from:s}=r;return s>n&&(i=t.sliceString(n,s)+i,s=n),r.to<o&&(i+=t.sliceString(r.to,o)),St.set(t,new e(s,i)),new e(n,i.slice(n-s,o-s))}},Oe=class{constructor(t,n,o,r,i){this.text=t,this.to=i,this.done=!1,this.value=Ro,this.matchPos=Fe(t,r),this.re=new RegExp(n,wt+(o?.ignoreCase?"i":"")),this.test=o?.test,this.flat=Ve.get(t,r,this.chunkEnd(r+5e3))}chunkEnd(t){return t>=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==t&&(this.re.lastIndex=t+1,n=this.re.exec(this.flat.text)),n){let o=this.flat.from+n.index,r=o+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(o,r,n)))return this.value={from:o,to:r,match:n},this.matchPos=Fe(this.text,r+(o==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Ve.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<"u"&&(Pe.prototype[Symbol.iterator]=Oe.prototype[Symbol.iterator]=function(){return this});function ki(e){try{return new RegExp(e,wt),!0}catch{return!1}}function Fe(e,t){if(t>=e.length)return t;let n=e.lineAt(t),o;for(;t<n.to&&(o=n.text.charCodeAt(t-n.from))>=56320&&o<57344;)t++;return t}var Li=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:o,result:r}=bn(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:t.phrase("go")});return r.then(i=>{let s=i&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(i.elements.line.value);if(!s){e.dispatch({effects:o});return}let a=t.doc.lineAt(t.selection.main.head),[,l,u,m,d]=s,g=m?+m.slice(1):0,y=u?+u:a.number;if(u&&d){let k=y/100;l&&(k=k*(l=="-"?-1:1)+a.number/t.doc.lines),y=Math.round(t.doc.lines*k)}else u&&l&&(y=y*(l=="-"?-1:1)+a.number);let b=t.doc.line(Math.max(1,Math.min(t.doc.lines,y))),C=p.cursor(b.from+Math.max(0,Math.min(g,b.length)));e.dispatch({effects:[o,x.scrollIntoView(C.from,{y:"center"})],selection:C})}),!0},vi={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Po=P.define({combine(e){return ie(e,vi,{highlightWordAroundCursor:(t,n)=>t||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function Vo(e){let t=[Di,Ti];return e&&t.push(Po.of(e)),t}var wi=S.mark({class:"cm-selectionMatch"}),Mi=S.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function Eo(e,t,n,o){return(n==0||e(t.sliceDoc(n-1,n))!=v.Word)&&(o==t.doc.length||e(t.sliceDoc(o,o+1))!=v.Word)}function Ai(e,t,n,o){return e(t.sliceDoc(n,n+1))==v.Word&&e(t.sliceDoc(o-1,o))==v.Word}var Ti=F.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(Po),{state:n}=e,o=n.selection;if(o.ranges.length>1)return S.none;let r=o.main,i,s=null;if(r.empty){if(!t.highlightWordAroundCursor)return S.none;let l=n.wordAt(r.head);if(!l)return S.none;s=n.charCategorizer(r.head),i=n.sliceDoc(l.from,l.to)}else{let l=r.to-r.from;if(l<t.minSelectionLength||l>200)return S.none;if(t.wholeWords){if(i=n.sliceDoc(r.from,r.to),s=n.charCategorizer(r.head),!(Eo(s,n,r.from,r.to)&&Ai(s,n,r.from,r.to)))return S.none}else if(i=n.sliceDoc(r.from,r.to),!i)return S.none}let a=[];for(let l of e.visibleRanges){let u=new z(n.doc,i,l.from,l.to);for(;!u.next().done;){let{from:m,to:d}=u.value;if((!s||Eo(s,n,m,d))&&(r.empty&&m<=r.from&&d>=r.to?a.push(Mi.range(m,d)):(m>=r.to||d<=r.from)&&a.push(wi.range(m,d)),a.length>t.maxMatches))return S.none}}return S.set(a)}},{decorations:e=>e.decorations}),Di=x.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Bi=({state:e,dispatch:t})=>{let{selection:n}=e,o=p.create(n.ranges.map(r=>e.wordAt(r.head)||p.cursor(r.head)),n.mainIndex);return o.eq(n)?!1:(t(e.update({selection:o})),!0)};function Ei(e,t){let{main:n,ranges:o}=e.selection,r=e.wordAt(n.head),i=r&&r.from==n.from&&r.to==n.to;for(let s=!1,a=new z(e.doc,t,o[o.length-1].to);;)if(a.next(),a.done){if(s)return null;a=new z(e.doc,t,0,Math.max(0,o[o.length-1].from-1)),s=!0}else{if(s&&o.some(l=>l.from==a.value.from))continue;if(i){let l=e.wordAt(a.value.from);if(!l||l.from!=a.value.from||l.to!=a.value.to)continue}return a.value}}var Ii=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(i=>i.from===i.to))return Bi({state:e,dispatch:t});let o=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(i=>e.sliceDoc(i.from,i.to)!=o))return!1;let r=Ei(e,o);return r?(t(e.update({selection:e.selection.addRange(p.range(r.from,r.to),!1),effects:x.scrollIntoView(r.to)})),!0):!1},ee=P.define({combine(e){return ie(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new vt(t),scrollToMatch:t=>x.scrollIntoView(t)})}});var Ue=class{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||ki(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord,this.test=t.test}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,(n,o)=>o=="n"?`
|
|
2
|
-
`:o=="r"?"\r":o=="t"?" ":"\\")}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord&&this.test==t.test}create(){return this.regexp?new kt(this):new bt(this)}getCursor(t,n=0,o){let r=t.doc?t:re.create({doc:t});return o==null&&(o=r.doc.length),this.regexp?Z(this,r,n,o):X(this,r,n,o)}},Ne=class{constructor(t){this.spec=t}};function Ri(e,t,n){return(o,r,i,s)=>{if(n&&!n(o,r,i,s))return!1;let a=o>=s&&r<=s+i.length?i.slice(o-s,r-s):t.doc.sliceString(o,r);return e(a,t,o,r)}}function X(e,t,n,o){let r;return e.wholeWord&&(r=Pi(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(r=Ri(e.test,t,r)),new z(t.doc,e.unquoted,n,o,e.caseSensitive?void 0:i=>i.toLowerCase(),r)}function Pi(e,t){return(n,o,r,i)=>((i>n||i+r.length<o)&&(i=Math.max(0,n-2),r=e.sliceString(i,Math.min(e.length,o+2))),(t(We(r,n-i))!=v.Word||t($e(r,n-i))!=v.Word)&&(t($e(r,o-i))!=v.Word||t(We(r,o-i))!=v.Word))}var bt=class extends Ne{constructor(t){super(t)}nextMatch(t,n,o){let r=X(this.spec,t,o,t.doc.length).nextOverlapping();if(r.done){let i=Math.min(t.doc.length,n+this.spec.unquoted.length);r=X(this.spec,t,0,i).nextOverlapping()}return r.done||r.value.from==n&&r.value.to==o?null:r.value}prevMatchInRange(t,n,o){for(let r=o;;){let i=Math.max(n,r-1e4-this.spec.unquoted.length),s=X(this.spec,t,i,r),a=null;for(;!s.nextOverlapping().done;)a=s.value;if(a)return a;if(i==n)return null;r-=1e4}}prevMatch(t,n,o){let r=this.prevMatchInRange(t,0,n);return r||(r=this.prevMatchInRange(t,Math.max(0,o-this.spec.unquoted.length),t.doc.length)),r&&(r.from!=n||r.to!=o)?r:null}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,n){let o=X(this.spec,t,0,t.doc.length),r=[];for(;!o.next().done;){if(r.length>=n)return null;r.push(o.value)}return r}highlight(t,n,o,r){let i=X(this.spec,t,Math.max(0,n-this.spec.unquoted.length),Math.min(o+this.spec.unquoted.length,t.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function Vi(e,t,n){return(o,r,i)=>(!n||n(o,r,i))&&e(i[0],t,o,r)}function Z(e,t,n,o){let r;return e.wholeWord&&(r=Oi(t.charCategorizer(t.selection.main.head))),e.test&&(r=Vi(e.test,t,r)),new Pe(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:r},n,o)}function We(e,t){return e.slice(V(e,t,!1),t)}function $e(e,t){return e.slice(t,V(e,t))}function Oi(e){return(t,n,o)=>!o[0].length||(e(We(o.input,o.index))!=v.Word||e($e(o.input,o.index))!=v.Word)&&(e($e(o.input,o.index+o[0].length))!=v.Word||e(We(o.input,o.index+o[0].length))!=v.Word)}var kt=class extends Ne{nextMatch(t,n,o){let r=Z(this.spec,t,o,t.doc.length).next();return r.done&&(r=Z(this.spec,t,0,n).next()),r.done?null:r.value}prevMatchInRange(t,n,o){for(let r=1;;r++){let i=Math.max(n,o-r*1e4),s=Z(this.spec,t,i,o),a=null;for(;!s.next().done;)a=s.value;if(a&&(i==n||a.from>i+10))return a;if(i==n)return null}}prevMatch(t,n,o){return this.prevMatchInRange(t,0,n)||this.prevMatchInRange(t,o,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,o)=>{if(o=="&")return t.match[0];if(o=="$")return"$";for(let r=o.length;r>0;r--){let i=+o.slice(0,r);if(i>0&&i<t.match.length)return t.match[i]+o.slice(r)}return n})}matchAll(t,n){let o=Z(this.spec,t,0,t.doc.length),r=[];for(;!o.next().done;){if(r.length>=n)return null;r.push(o.value)}return r}highlight(t,n,o,r){let i=Z(this.spec,t,Math.max(0,n-250),Math.min(o+250,t.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},he=j.define(),Mt=j.define(),$=fe.define({create(e){return new ce(Lt(e).create(),null)},update(e,t){for(let n of t.effects)n.is(he)?e=new ce(n.value.create(),e.panel):n.is(Mt)&&(e=new ce(e.query,n.value?At:null));return e},provide:e=>Sn.from(e,t=>t.panel)});var ce=class{constructor(t,n){this.query=t,this.panel=n}},Fi=S.mark({class:"cm-searchMatch"}),Ui=S.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Ni=F.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field($))}update(e){let t=e.state.field($);(t!=e.startState.field($)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return S.none;let{view:n}=this,o=new hn;for(let r=0,i=n.visibleRanges,s=i.length;r<s;r++){let{from:a,to:l}=i[r];for(;r<s-1&&l>i[r+1].from-500;)l=i[++r].to;e.highlight(n.state,a,l,(u,m)=>{let d=n.state.selection.ranges.some(g=>g.from==u&&g.to==m);o.add(u,m,d?Ui:Fi)})}return o.finish()}},{decorations:e=>e.decorations});function ue(e){return t=>{let n=t.state.field($,!1);return n&&n.query.spec.valid?e(t,n):Uo(t)}}var ze=ue((e,{query:t})=>{let{to:n}=e.state.selection.main,o=t.nextMatch(e.state,n,n);if(!o)return!1;let r=p.single(o.from,o.to),i=e.state.facet(ee);return e.dispatch({selection:r,effects:[Tt(e,o),i.scrollToMatch(r.main,e)],userEvent:"select.search"}),Fo(e),!0}),_e=ue((e,{query:t})=>{let{state:n}=e,{from:o}=n.selection.main,r=t.prevMatch(n,o,o);if(!r)return!1;let i=p.single(r.from,r.to),s=e.state.facet(ee);return e.dispatch({selection:i,effects:[Tt(e,r),s.scrollToMatch(i.main,e)],userEvent:"select.search"}),Fo(e),!0}),Wi=ue((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:p.create(n.map(o=>p.range(o.from,o.to))),userEvent:"select.search.matches"}),!0)}),$i=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:o,to:r}=n.main,i=[],s=0;for(let a=new z(e.doc,e.sliceDoc(o,r));!a.next().done;){if(i.length>1e3)return!1;a.value.from==o&&(s=i.length),i.push(p.range(a.value.from,a.value.to))}return t(e.update({selection:p.create(i,s),userEvent:"select.search.matches"})),!0},Io=ue((e,{query:t})=>{let{state:n}=e,{from:o,to:r}=n.selection.main;if(n.readOnly)return!1;let i=t.nextMatch(n,o,o);if(!i)return!1;let s=i,a=[],l,u,m=[];s.from==o&&s.to==r&&(u=n.toText(t.getReplacement(s)),a.push({from:s.from,to:s.to,insert:u}),s=t.nextMatch(n,s.from,s.to),m.push(x.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(o).number)+".")));let d=e.state.changes(a);return s&&(l=p.single(s.from,s.to).map(d),m.push(Tt(e,s)),m.push(n.facet(ee).scrollToMatch(l.main,e))),e.dispatch({changes:d,selection:l,effects:m,userEvent:"input.replace"}),!0}),zi=ue((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(r=>{let{from:i,to:s}=r;return{from:i,to:s,insert:t.getReplacement(r)}});if(!n.length)return!1;let o=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:x.announce.of(o),userEvent:"input.replace.all"}),!0});function At(e){return e.state.facet(ee).createPanel(e)}function Lt(e,t){var n,o,r,i,s;let a=e.selection.main,l=a.empty||a.to>a.from+100?"":e.sliceDoc(a.from,a.to);if(t&&!l)return t;let u=e.facet(ee);return new Ue({search:((n=t?.literal)!==null&&n!==void 0?n:u.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(o=t?.caseSensitive)!==null&&o!==void 0?o:u.caseSensitive,literal:(r=t?.literal)!==null&&r!==void 0?r:u.literal,regexp:(i=t?.regexp)!==null&&i!==void 0?i:u.regexp,wholeWord:(s=t?.wholeWord)!==null&&s!==void 0?s:u.wholeWord})}function Oo(e){let t=ct(e,At);return t&&t.dom.querySelector("[main-field]")}function Fo(e){let t=Oo(e);t&&t==e.root.activeElement&&t.select()}var Uo=e=>{let t=e.state.field($,!1);if(t&&t.panel){let n=Oo(e);if(n&&n!=e.root.activeElement){let o=Lt(e.state,t.query.spec);o.valid&&e.dispatch({effects:he.of(o)}),n.focus(),n.select()}}else e.dispatch({effects:[Mt.of(!0),t?he.of(Lt(e.state,t.query.spec)):j.appendConfig.of(ji)]});return!0},No=e=>{let t=e.state.field($,!1);if(!t||!t.panel)return!1;let n=ct(e,At);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:Mt.of(!1)}),!0},Wo=[{key:"Mod-f",run:Uo,scope:"editor search-panel"},{key:"F3",run:ze,shift:_e,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:ze,shift:_e,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:No,scope:"editor search-panel"},{key:"Mod-Shift-l",run:$i},{key:"Mod-Alt-g",run:Li},{key:"Mod-d",run:Ii,preventDefault:!0}],vt=class{constructor(t){this.view=t;let n=this.query=t.state.field($).query.spec;this.commit=this.commit.bind(this),this.searchField=w("input",{value:n.search,placeholder:M(t,"Find"),"aria-label":M(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=w("input",{value:n.replace,placeholder:M(t,"Replace"),"aria-label":M(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=w("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=w("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=w("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function o(r,i,s){return w("button",{class:"cm-button",name:r,onclick:i,type:"button"},s)}this.dom=w("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,o("next",()=>ze(t),[M(t,"next")]),o("prev",()=>_e(t),[M(t,"previous")]),o("select",()=>Wi(t),[M(t,"all")]),w("label",null,[this.caseField,M(t,"match case")]),w("label",null,[this.reField,M(t,"regexp")]),w("label",null,[this.wordField,M(t,"by word")]),...t.state.readOnly?[]:[w("br"),this.replaceField,o("replace",()=>Io(t),[M(t,"replace")]),o("replaceAll",()=>zi(t),[M(t,"replace all")])],w("button",{name:"close",onclick:()=>No(t),"aria-label":M(t,"close"),type:"button"},["\xD7"])])}commit(){let t=new Ue({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:he.of(t)}))}keydown(t){fn(this.view,t,"search-panel")?t.preventDefault():t.keyCode==13&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?_e:ze)(this.view)):t.keyCode==13&&t.target==this.replaceField&&(t.preventDefault(),Io(this.view))}update(t){for(let n of t.transactions)for(let o of n.effects)o.is(he)&&!o.value.eq(this.query)&&this.setQuery(o.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(ee).top}};function M(e,t){return e.state.phrase(t)}var Ie=30,Re=/[\s\.,:;?!]/;function Tt(e,{from:t,to:n}){let o=e.state.doc.lineAt(t),r=e.state.doc.lineAt(n).to,i=Math.max(o.from,t-Ie),s=Math.min(r,n+Ie),a=e.state.sliceDoc(i,s);if(i!=o.from){for(let l=0;l<Ie;l++)if(!Re.test(a[l+1])&&Re.test(a[l])){a=a.slice(l);break}}if(s!=r){for(let l=a.length-1;l>a.length-Ie;l--)if(!Re.test(a[l-1])&&Re.test(a[l])){a=a.slice(0,l);break}}return x.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${o.number}.`)}var _i=x.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),ji=[$,ln.low(Ni),_i];var qi="#e5c07b",$o="#e06c75",Hi="#56b6c2",Yi="#ffffff",je="#abb2bf",Bt="#7d8799",Gi="#61afef",Ji="#98c379",zo="#d19a66",Ki="#c678dd",Qi="#21252b",_o="#2c313a",jo="#282c34",Dt="#353a42",Xi="#3E4451",qo="#528bff";var Zi=x.theme({"&":{color:je,backgroundColor:jo},".cm-content":{caretColor:qo},".cm-cursor, .cm-dropCursor":{borderLeftColor:qo},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Xi},".cm-panels":{backgroundColor:Qi,color:je},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:jo,color:Bt,border:"none"},".cm-activeLineGutter":{backgroundColor:_o},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Dt},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Dt,borderBottomColor:Dt},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:_o,color:je}}},{dark:!0}),es=Tn.define([{tag:f.keyword,color:Ki},{tag:[f.name,f.deleted,f.character,f.propertyName,f.macroName],color:$o},{tag:[f.function(f.variableName),f.labelName],color:Gi},{tag:[f.color,f.constant(f.name),f.standard(f.name)],color:zo},{tag:[f.definition(f.name),f.separator],color:je},{tag:[f.typeName,f.className,f.number,f.changed,f.annotation,f.modifier,f.self,f.namespace],color:qi},{tag:[f.operator,f.operatorKeyword,f.url,f.escape,f.regexp,f.link,f.special(f.string)],color:Hi},{tag:[f.meta,f.comment],color:Bt},{tag:f.strong,fontWeight:"bold"},{tag:f.emphasis,fontStyle:"italic"},{tag:f.strikethrough,textDecoration:"line-through"},{tag:f.link,color:Bt,textDecoration:"underline"},{tag:f.heading,fontWeight:"bold",color:$o},{tag:[f.atom,f.bool,f.special(f.variableName)],color:zo},{tag:[f.processingInstruction,f.string,f.inserted],color:Ji},{tag:f.invalid,color:Yi}]),Et=[Zi,ke(es)];var qe=class e{constructor(t,n){this.yanchor=t,this.yhead=n}toJSON(){return{yanchor:G(this.yanchor),yhead:G(this.yhead)}}static fromJSON(t){return new e(I(t.yanchor),I(t.yhead))}};var He=class{constructor(t,n){this.ytext=t,this.awareness=n,this.undoManager=new J(t)}toYPos(t,n=0){return U(this.ytext,t,n)}fromYPos(t){let n=R(I(t),this.ytext.doc);if(n==null||n.type!==this.ytext)throw new Error("[y-codemirror] The position you want to retrieve was created by a different document");return{pos:n.index,assoc:n.assoc}}toYRange(t){let n=t.assoc,o=this.toYPos(t.anchor,n),r=this.toYPos(t.head,n);return new qe(o,r)}fromYRange(t){let n=this.fromYPos(t.yanchor),o=this.fromYPos(t.yhead);return n.pos===o.pos?p.cursor(o.pos,o.assoc):p.range(n.pos,o.pos)}},Y=P.define({combine(e){return e[e.length-1]}}),Ye=O.define(),It=class{constructor(t){this.view=t,this.conf=t.state.facet(Y),this._observer=(n,o)=>{if(o.origin!==this.conf){let r=n.delta,i=[],s=0;for(let a=0;a<r.length;a++){let l=r[a];l.insert!=null?i.push({from:s,to:s,insert:l.insert}):l.delete!=null?(i.push({from:s,to:s+l.delete,insert:""}),s+=l.delete):s+=l.retain}t.dispatch({changes:i,annotations:[Ye.of(this.conf)]})}},this._ytext=this.conf.ytext,this._ytext.observe(this._observer)}update(t){if(!t.docChanged||t.transactions.length>0&&t.transactions[0].annotation(Ye)===this.conf)return;let n=this.conf.ytext;n.doc.transact(()=>{let o=0;t.changes.iterChanges((r,i,s,a,l)=>{let u=l.sliceString(0,l.length,`
|
|
3
|
-
`);r!==i&&n.delete(r+o,i-r),u.length>0&&n.insert(r+o,u),o+=u.length-(i-r)})},this.conf)}destroy(){this._ytext.unobserve(this._observer)}},Yo=F.fromClass(It);var Go=x.baseTheme({".cm-ySelection":{},".cm-yLineSelection":{padding:0,margin:"0px 2px 0px 4px"},".cm-ySelectionCaret":{position:"relative",borderLeft:"1px solid black",borderRight:"1px solid black",marginLeft:"-1px",marginRight:"-1px",boxSizing:"border-box",display:"inline"},".cm-ySelectionCaretDot":{borderRadius:"50%",position:"absolute",width:".4em",height:".4em",top:"-.2em",left:"-.2em",backgroundColor:"inherit",transition:"transform .3s ease-in-out",boxSizing:"border-box"},".cm-ySelectionCaret:hover > .cm-ySelectionCaretDot":{transformOrigin:"bottom center",transform:"scale(0)"},".cm-ySelectionInfo":{position:"absolute",top:"-1.05em",left:"-1px",fontSize:".75em",fontFamily:"serif",fontStyle:"normal",fontWeight:"normal",lineHeight:"normal",userSelect:"none",color:"white",paddingLeft:"2px",paddingRight:"2px",zIndex:101,transition:"opacity .3s ease-in-out",backgroundColor:"inherit",opacity:0,transitionDelay:"0s",whiteSpace:"nowrap"},".cm-ySelectionCaret:hover > .cm-ySelectionInfo":{opacity:1,transitionDelay:"0s"}}),ts=O.define(),Pt=class extends un{constructor(t,n){super(),this.color=t,this.name=n}toDOM(){return de("span",[te("class","cm-ySelectionCaret"),te("style",`background-color: ${this.color}; border-color: ${this.color}`)],[ne("\u2060"),de("div",[te("class","cm-ySelectionCaretDot")]),ne("\u2060"),de("div",[te("class","cm-ySelectionInfo")],[ne(this.name)]),ne("\u2060")])}eq(t){return t.color===this.color}compare(t){return t.color===this.color}updateDOM(){return!1}get estimatedHeight(){return-1}ignoreEvent(){return!0}},Vt=class{constructor(t){this.conf=t.state.facet(Y),this._listener=({added:n,updated:o,removed:r},i,s)=>{n.concat(o).concat(r).findIndex(l=>l!==this.conf.awareness.doc.clientID)>=0&&t.dispatch({annotations:[ts.of([])]})},this._awareness=this.conf.awareness,this._awareness.on("change",this._listener),this.decorations=cn.of([])}destroy(){this._awareness.off("change",this._listener)}update(t){let n=this.conf.ytext,o=n.doc,r=this.conf.awareness,i=[],s=this.conf.awareness.getLocalState();if(s!=null){let a=t.view.hasFocus&&t.view.dom.ownerDocument.hasFocus(),l=a?t.state.selection.main:null,u=s.cursor==null?null:I(s.cursor.anchor),m=s.cursor==null?null:I(s.cursor.head);if(l!=null){let d=U(n,l.anchor),g=U(n,l.head);(s.cursor==null||!rt(u,d)||!rt(m,g))&&r.setLocalStateField("cursor",{anchor:d,head:g})}else s.cursor!=null&&a&&r.setLocalStateField("cursor",null)}r.getStates().forEach((a,l)=>{if(l===r.doc.clientID)return;let u=a.cursor;if(u==null||u.anchor==null||u.head==null)return;let m=R(u.anchor,o),d=R(u.head,o);if(m==null||d==null||m.type!==n||d.type!==n)return;let{color:g="#30bced",name:y="Anonymous"}=a.user||{},b=a.user&&a.user.colorLight||g+"33",C=Ht(m.index,d.index),k=Yt(m.index,d.index),_=t.view.state.doc.lineAt(C),nt=t.view.state.doc.lineAt(k);if(_.number===nt.number)i.push({from:C,to:k,value:S.mark({attributes:{style:`background-color: ${b}`},class:"cm-ySelection"})});else{i.push({from:C,to:_.from+_.length,value:S.mark({attributes:{style:`background-color: ${b}`},class:"cm-ySelection"})}),i.push({from:nt.from,to:k,value:S.mark({attributes:{style:`background-color: ${b}`},class:"cm-ySelection"})});for(let ot=_.number+1;ot<nt.number;ot++){let zt=t.view.state.doc.line(ot).from;i.push({from:zt,to:zt,value:S.line({attributes:{style:`background-color: ${b}`,class:"cm-yLineSelection"}})})}}i.push({from:d.index,to:d.index,value:S.widget({side:d.index-m.index>0?-1:1,block:!1,widget:new Pt(g,y)})})}),this.decorations=S.set(i,!0)}},Jo=F.fromClass(Vt,{decorations:e=>e.decorations});var Ko=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}};var Ge=class{constructor(t){this.undoManager=t}addTrackedOrigin(t){this.undoManager.addTrackedOrigin(t)}removeTrackedOrigin(t){this.undoManager.removeTrackedOrigin(t)}undo(){return this.undoManager.undo()!=null}redo(){return this.undoManager.redo()!=null}},me=P.define({combine(e){return e[e.length-1]}}),la=O.define(),Ot=class{constructor(t){this.view=t,this.conf=t.state.facet(me),this._undoManager=this.conf.undoManager,this.syncConf=t.state.facet(Y),this._beforeChangeSelection=null,this._mux=Ko(),this._onStackItemAdded=({stackItem:n,changedParentTypes:o})=>{o.has(this.syncConf.ytext)&&this._beforeChangeSelection&&!n.meta.has(this)&&n.meta.set(this,this._beforeChangeSelection)},this._onStackItemPopped=({stackItem:n})=>{let o=n.meta.get(this);if(o){let r=this.syncConf.fromYRange(o);t.dispatch(t.state.update({selection:r,effects:[x.scrollIntoView(r)]})),this._storeSelection()}},this._storeSelection=()=>{this._beforeChangeSelection=this.syncConf.toYRange(this.view.state.selection.main)},this._undoManager.on("stack-item-added",this._onStackItemAdded),this._undoManager.on("stack-item-popped",this._onStackItemPopped),this._undoManager.addTrackedOrigin(this.syncConf)}update(t){t.selectionSet&&(t.transactions.length===0||t.transactions[0].annotation(Ye)!==this.syncConf)&&this._storeSelection()}destroy(){this._undoManager.off("stack-item-added",this._onStackItemAdded),this._undoManager.off("stack-item-popped",this._onStackItemPopped),this._undoManager.removeTrackedOrigin(this.syncConf)}},Qo=F.fromClass(Ot),Xo=({state:e,dispatch:t})=>e.facet(me).undo()||!0,Zo=({state:e,dispatch:t})=>e.facet(me).redo()||!0;var er=(e,t,{undoManager:n=new J(e)}={})=>{let o=new He(e,t),r=[Y.of(o),Yo];return t&&r.push(Go,Jo),n!==!1&&r.push(me.of(new Ge(n)),Qo,x.domEventHandlers({beforeinput(i,s){return i.inputType==="historyUndo"?Xo(s):i.inputType==="historyRedo"?Zo(s):!1}})),r};var Je=Object.freeze({bold:"bold text",code:"code",italic:"emphasis",strikethrough:"struck text"}),Ke="link text",Ft="https://",Qe="alt text",Ut="https://",Xe="Video",Nt="https://",tr="code",or=Object.freeze(["Column 1","Column 2"]),nr="Value";function ns(e,t){let n=Math.max(0,Math.min(e.from,e.to,t)),o=Math.max(0,Math.min(Math.max(e.from,e.to),t));return{from:n,to:o}}function os(e,t){return t===0||e[t-1]===`
|
|
4
|
-
`}function rs(e,t){if(t<=0)return 0;let n=e.lastIndexOf(`
|
|
5
|
-
`,t-1);return n<0?0:n+1}function is(e,t){let n=e.indexOf(`
|
|
6
|
-
`,t);return n<0?e.length:n}function rr(e,t){let{from:n}=t,{to:o}=t;return o>n&&os(e,o)&&(o-=1),{from:rs(e,n),to:is(e,Math.max(n,o))}}function Ze(e,t,n,o){let r=e.slice(t.from,t.to);return r.length>0?{anchor:t.from+n.length,from:t.from,head:t.from+n.length+r.length,insert:`${n}${r}${n}`,to:t.to}:{anchor:t.from+n.length,from:t.from,head:t.from+n.length+o.length,insert:`${n}${o}${n}`,to:t.to}}function Wt(e){return/^https?:\/\//i.test(e.trim())}function ss(e,t){let n=e.slice(t.from,t.to);if(n.length>0&&Wt(n))return{anchor:t.from+1,from:t.from,head:t.from+1+Ke.length,insert:`[${Ke}](${n})`,to:t.to};if(n.length>0){let o=`[${n}](`;return{anchor:t.from+o.length,from:t.from,head:t.from+o.length+Ft.length,insert:`${o}${Ft})`,to:t.to}}return{anchor:t.from+1,from:t.from,head:t.from+1+Ke.length,insert:`[${Ke}](${Ft})`,to:t.to}}function as(e,t){let n=e.slice(t.from,t.to);if(n.length>0&&Wt(n))return{anchor:t.from+2,from:t.from,head:t.from+2+Qe.length,insert:``,to:t.to};if(n.length>0){let o=``,to:t.to}}return{anchor:t.from+2,from:t.from,head:t.from+2+Qe.length,insert:``,to:t.to}}function ls(e,t){let n=e.slice(t.from,t.to);if(n.length>0&&Wt(n))return{anchor:t.from+2,from:t.from,head:t.from+2+Xe.length,insert:``,to:t.to};if(n.length>0){let o=``,to:t.to}}return{anchor:t.from+2,from:t.from,head:t.from+2+Xe.length,insert:``,to:t.to}}function et(e,t,n,o){let r=rr(e,t),s=e.slice(r.from,r.to).split(`
|
|
7
|
-
`),a=d=>o.test(d),l=s.every(d=>d.trim().length===0||a(d)),u=0,m=s.map(d=>{if(d.trim().length===0)return d;if(l)return a(d)?d.replace(o,""):d;let g=n(u);return u+=1,`${g}${d}`});return{anchor:r.from,from:r.from,head:r.from+m.join(`
|
|
8
|
-
`).length,insert:m.join(`
|
|
9
|
-
`),to:r.to}}function cs(e,t){return et(e,t,()=>"## ",/^#{1,6}\s+/)}function hs(e,t){return et(e,t,()=>"- ",/^[-*+]\s+/)}function us(e,t){return et(e,t,()=>"> ",/^>\s+/)}function ms(e,t){return et(e,t,()=>"- [ ] ",/^-\s\[(?: |x|X)\]\s+/)}function ds(e,t){let n=rr(e,t),r=e.slice(n.from,n.to).split(`
|
|
10
|
-
`),i=r.every(l=>l.trim().length===0||/^\d+\.\s+/.test(l)),s=1,a=r.map(l=>{if(l.trim().length===0)return l;if(i)return l.replace(/^\d+\.\s+/,"");let u=`${s}. ${l}`;return s+=1,u});return{anchor:n.from,from:n.from,head:n.from+a.join(`
|
|
11
|
-
`).length,insert:a.join(`
|
|
12
|
-
`),to:n.to}}function fs(e){let n=e.replace(/\r\n/g,`
|
|
13
|
-
`).match(/^```[^\n]*\n([\s\S]*?)\n```$/);return n?n[1]:null}function ps(e,t){let n=e.slice(t.from,t.to);if(n.length>0){let o=fs(n);return o!==null?{anchor:t.from,from:t.from,head:t.from+o.length,insert:o,to:t.to}:{anchor:t.from+4,from:t.from,head:t.from+4+n.length,insert:`\`\`\`
|
|
14
|
-
${n}
|
|
15
|
-
\`\`\``,to:t.to}}return{anchor:t.from+4,from:t.from,head:t.from+4+tr.length,insert:`\`\`\`
|
|
16
|
-
${tr}
|
|
17
|
-
\`\`\``,to:t.to}}function ir(e,t,n,o,r=0){let i=t.from>0&&e[t.from-1]!==`
|
|
18
|
-
`,s=t.to<e.length&&e[t.to]!==`
|
|
19
|
-
`,a=i?`
|
|
20
|
-
`:"",u=`${a}${n}${s?`
|
|
21
|
-
`:""}`,m=t.from+a.length+o;return{anchor:m,from:t.from,head:m+r,insert:u,to:t.to}}function gs(e=""){let t=e.trim()||nr;return[`| ${or.join(" | ")} |`,"| --- | --- |",`| ${t} | ${nr} |`].join(`
|
|
22
|
-
`)}function xs(e,t){let n=e.slice(t.from,t.to),o=gs(n);return ir(e,t,o,2,or[0].length)}function ys(e,t){return ir(e,t,"---",4,0)}function sr(e,t,n){let o=String(e??""),r=ns(t,o.length);switch(n){case"bold":return Ze(o,r,"**",Je.bold);case"italic":return Ze(o,r,"_",Je.italic);case"strikethrough":return Ze(o,r,"~~",Je.strikethrough);case"code":return Ze(o,r,"`",Je.code);case"link":return ss(o,r);case"image":return as(o,r);case"video":return ls(o,r);case"heading":return cs(o,r);case"quote":return us(o,r);case"bullet-list":return hs(o,r);case"numbered-list":return ds(o,r);case"task-list":return ms(o,r);case"code-block":return ps(o,r);case"table":return xs(o,r);case"horizontal-rule":return ys(o,r);default:return null}}function ar(e){return t=>{let n=t.state.doc.lineAt(t.pos),o=n.text.slice(0,t.pos-n.from),r=o.lastIndexOf("[[");if(r===-1)return null;let i=o.slice(r+2);if(i.includes("]]"))return null;let s=i.toLowerCase(),a=n.from+r+2,u=e().map(m=>{let d=m.replace(/\.md$/i,""),g=d.split("/").pop();return{filePath:m,label:d,fileName:g}}).filter(({label:m,fileName:d})=>m.toLowerCase().includes(s)||d.toLowerCase().includes(s)).map(({label:m,fileName:d})=>({label:m,detail:m.includes("/")?` ${d}`:void 0,apply:(g,y,b,C)=>{let k=g.state.doc.toString(),_=C;k.slice(C,C+2)==="]]"&&(_=C+2),g.dispatch({changes:{from:b,to:_,insert:`${y.label}]]`},selection:{anchor:b+y.label.length+2}})},type:"text",boost:m.toLowerCase().startsWith(s)?1:0}));return u.length===0?null:{from:a,options:u,filter:!1}}}var Cs=new Set(["@startuml","@enduml","@startmindmap","@endmindmap","@startwbs","@endwbs","@startgantt","@endgantt","@startjson","@endjson","@startyaml","@endyaml","@startsalt","@endsalt"]),Ss=new Set(["activate","actor","agent","allowmixing","alt","annotation","artifact","as","autonumber","boundary","box","break","caption","card","case","circle","class","cloud","collections","component","control","create","critical","database","deactivate","destroy","detach","else","elseif","end","endlegend","endif","endwhile","entity","enum","exception","file","folder","footer","fork","frame","group","header","hide","hnote","if","interface","json","kill","label","legend","loop","map","namespace","newpage","node","note","object","of","opt","order","over","package","page","par","participant","partition","person","port","protocol","queue","rectangle","ref","repeat","return","rnote","show","skinparam","split","stack","start","state","stop","storage","struct","switch","then","title","usecase","while"]),bs=new Set(["false","no","off","on","true","yes"]);function ks(e){let t=e.match(/[@!A-Za-z_][\w.-]*/u,!1);return t?(e.match(/[@!A-Za-z_][\w.-]*/u),t[0]):""}var Ls=Le.define({languageData:{commentTokens:{block:{close:"'/",open:"/'"},line:"'"}},startState(){return{inBlockComment:!1}},token(e,t){if(t.inBlockComment)return e.skipTo("'/")?(e.match("'/"),t.inBlockComment=!1):e.skipToEnd(),"comment";if(e.eatSpace())return null;if(e.match("/'"))return t.inBlockComment=!0,"comment";let n=e.pos===0?" ":e.string.charAt(e.pos-1);if(e.peek()==="'"&&(e.sol()||/\s/u.test(n)))return e.skipToEnd(),"comment";if(e.match(/"(?:[^"\\]|\\.)*"?/u))return"string";if(e.match(/#[0-9a-f]{3,8}\b/iu)||e.match(/#[A-Za-z][\w-]*/u))return"atom";if(e.match(/\b\d+(?:\.\d+)?\b/u))return"number";if(e.match(/[<>{}[\]():,]/u))return"punctuation";if(e.match(/[ox*+<#]?[-=.\\/]+(?:left|right|up|down)?[-=.\\/]*[ox*+>#]?/iu))return"operator";let o=ks(e);if(o){let r=o.toLowerCase();return r.startsWith("!")||Cs.has(r)?"meta":Ss.has(r)?"keyword":bs.has(r)?"bool":/^[A-Z][A-Z0-9_]*$/u.test(o)?"typeName":"variableName"}return e.next(),null}}),$t=new Se(Ls),lr=c.of({alias:["plantuml","puml"],extensions:["plantuml","puml"],name:"PlantUML",support:$t});var vs=[...Do,lr];function cr(e){let t=e==="dark"?"oklch(from var(--color-surface-offset) l c h / 0.55)":"oklch(from var(--color-surface-offset) l c h / 0.75)",n=e==="dark"?"oklch(from var(--color-primary) l c h / 0.28)":"oklch(from var(--color-primary) l c h / 0.18)",o=e==="dark"?"oklch(from var(--color-primary) l c h / 0.4)":"oklch(from var(--color-primary) l c h / 0.26)",r=e==="dark"?"oklch(from var(--color-primary) l c h / 0.65)":"oklch(from var(--color-primary) l c h / 0.5)";return x.theme({"&":{backgroundColor:"var(--color-bg)",color:"var(--color-text)"},".cm-content":{caretColor:"var(--color-primary)",fontFamily:"var(--font-mono)",padding:"16px 0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--color-primary)",borderLeftWidth:"2px"},".cm-foldPlaceholder":{backgroundColor:"var(--color-surface-dynamic)",border:"none",color:"var(--color-text-muted)"},".cm-gutters":{backgroundColor:"var(--color-surface)",borderRight:"1px solid var(--color-divider)",color:"var(--color-text-muted)",minWidth:"44px"},".cm-line":{padding:"0 16px"},".cm-activeLine":{backgroundColor:t,boxShadow:`inset 3px 0 0 ${n}`},".cm-activeLineGutter":{backgroundColor:t,boxShadow:`inset 3px 0 0 ${n}`,color:"var(--color-text-muted)"},".cm-matchingBracket":{backgroundColor:"var(--color-primary-highlight)",outline:"1px solid var(--color-primary)"},".cm-selectionMatch":{backgroundColor:"var(--color-primary-highlight)"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:o},"&.cm-focused .cm-selectionLayer .cm-selectionBackground":{border:`1px solid ${r}`,borderRadius:"2px"}},{dark:e==="dark"})}function ws(e){return typeof e=="string"&&(e.toLowerCase().endsWith(".puml")||e.toLowerCase().endsWith(".plantuml"))?$t:Vn({base:Pn,codeLanguages:vs})}function hr(e){return{from:Math.min(...e.ranges.map(t=>Math.min(t.from,t.to))),to:Math.max(...e.ranges.map(t=>Math.max(t.from,t.to)))}}var tt=class{constructor({editorContainer:t,getFileList:n,initialTheme:o,lineInfoElement:r,lineWrappingEnabled:i=!0,onDocChanged:s=null,onSelectionChanged:a=null,onViewportChanged:l=null}){this.editorContainer=t,this.getFileList=n??(()=>[]),this.initialTheme=o,this.lineInfoElement=r,this.lineWrappingEnabled=i,this.onDocChanged=s,this.onSelectionChanged=a,this.onViewportChanged=l,this.editorView=null,this.themeCompartment=new pe,this.syntaxThemeCompartment=new pe,this.lineWrappingCompartment=new pe,this.viewportFrame=0,this.handleScroll=()=>{this.viewportFrame||(this.viewportFrame=requestAnimationFrame(()=>{this.viewportFrame=0,this.emitViewportChange()}))}}initialize({awareness:t,filePath:n,undoManager:o,ytext:r}){let i=x.updateListener.of(a=>{a.docChanged&&this.onDocChanged?.(),(a.selectionSet||a.docChanged)&&(this.updateCursorInfo(a.state),this.onSelectionChanged?.(a.state))}),s=this.editorContainer.querySelector("#editorLoading");Array.from(this.editorContainer.children).forEach(a=>{a!==s&&a.remove()}),this.editorView=new x({parent:this.editorContainer,state:re.create({doc:r.toString(),extensions:[kn(),Ln(),gn(),Gn(),An(),pn(),re.allowMultipleSelections.of(!0),wn(),ke(Dn,{fallback:!0}),Bn(),En(),Rn({override:[ar(this.getFileList)]}),yn(),Cn(),xn(),Vo(),dn.of([...In,...Ao,...Xn,...Wo,...Mn,To]),x.contentAttributes.of({"aria-label":"Markdown editor"}),ws(n),this.themeCompartment.of(cr(this.initialTheme)),this.syntaxThemeCompartment.of(this.initialTheme==="dark"?Et:[]),this.lineWrappingCompartment.of(this.lineWrappingEnabled?x.lineWrapping:[]),er(r,t,{undoManager:o}),i]})}),this.editorView.scrollDOM.addEventListener("scroll",this.handleScroll,{passive:!0}),this.updateCursorInfo(this.editorView.state),this.onSelectionChanged?.(this.editorView.state),this.emitViewportChange()}destroy(){this.viewportFrame&&(cancelAnimationFrame(this.viewportFrame),this.viewportFrame=0),this.editorView?.scrollDOM?.removeEventListener("scroll",this.handleScroll),this.editorView?.destroy(),this.editorView=null,this.editorContainer&&(this.editorContainer.innerHTML="")}getText(){return this.editorView?.state.doc.toString()??""}getDoc(){return this.editorView?.state.doc??null}getState(){return this.editorView?.state??null}getScrollContainer(){return this.editorView?.scrollDOM??null}applyTheme(t){this.editorView&&this.editorView.dispatch({effects:[this.themeCompartment.reconfigure(cr(t)),this.syntaxThemeCompartment.reconfigure(t==="dark"?Et:[])]})}isLineWrappingEnabled(){return this.lineWrappingEnabled}setLineWrapping(t){return this.lineWrappingEnabled=!!t,this.editorView?(this.editorView.dispatch({effects:this.lineWrappingCompartment.reconfigure(this.lineWrappingEnabled?x.lineWrapping:[])}),this.lineWrappingEnabled):this.lineWrappingEnabled}requestMeasure(){this.editorView?.requestMeasure()}getViewportState(t=.35){return{topLine:this.getTopVisibleLineNumber(t),viewportRatio:t}}getTopVisibleLineNumber(t=0){if(!this.editorView)return 1;let n=this.editorView.scrollDOM.getBoundingClientRect(),o=Math.max(n.height*t,8),r=this.editorView.lineBlockAtHeight(n.top+o-this.editorView.documentTop);return r?this.editorView.state.doc.lineAt(r.from).number:1}getCurrentSelectionLineRange(){let t=this.editorView?.state;if(!t)return null;let{doc:n,selection:o}=t,{from:r,to:i}=hr(o),s=n.lineAt(r).number,a=Math.min(Math.max(i,r),n.length);return a>r&&n.lineAt(a).from===a&&(a-=1),{endLine:n.lineAt(a).number,startLine:s}}getCurrentSelectionCommentAnchor(){let t=this.editorView?.state;if(!t)return null;let{doc:n,selection:o}=t,{from:r,to:i}=hr(o);if(r===i){let l=n.lineAt(r);return{anchorKind:"line",anchorQuote:oe(l.text),endIndex:l.to,endLine:l.number,startIndex:l.from,startLine:l.number}}let a=Math.min(Math.max(i,r),n.length);return a>r&&n.lineAt(a).from===a&&(a-=1),{anchorKind:"text",anchorQuote:oe(n.sliceString(r,i)),endIndex:i,endLine:n.lineAt(a).number,startIndex:r,startLine:n.lineAt(r).number}}normalizeLineRange({endLine:t,startLine:n}){let o=this.editorView?.state;if(!o)return{endLine:1,startLine:1};let r=o.doc.lines,i=Math.min(Math.max(Math.round(n??1),1),r);return{endLine:Math.min(Math.max(Math.round(t??i),i),r),startLine:i}}getLineInfoAt(t){let n=this.editorView?.state;if(!n)return null;let o=Math.min(Math.max(t,0),n.doc.length),r=n.doc.lineAt(o);return{line:r,lineNumber:r.number}}getAnchorClientRect(t){let n=this.editorView?.state,o=this.editorView;if(!n||!o||!t)return null;let r=t.anchorKind||t.kind||"line",i=Math.min(Math.max(Math.round(t.startIndex??0),0),n.doc.length),s=Math.min(Math.max(Math.round(t.endIndex??i),i),n.doc.length);if(r==="text"&&s>i){let C=o.coordsAtPos(i),k=o.coordsAtPos(Math.max(s-1,i));if(C&&k)return{bottom:Math.max(C.bottom,k.bottom),height:Math.max(C.bottom,k.bottom)-Math.min(C.top,k.top),left:Math.min(C.left,k.left),right:Math.max(C.right,k.right),top:Math.min(C.top,k.top),width:Math.max(C.right,k.right)-Math.min(C.left,k.left)}}let a=n.doc.line(Math.min(Math.max(Math.round(t.startLine??1),1),n.doc.lines)),l=o.lineBlockAt(a.from),u=o.scrollDOM.getBoundingClientRect(),m=o.scrollDOM.scrollTop,d=o.contentDOM.getBoundingClientRect(),g=d.left,y=Math.max(d.right,u.right-8),b=u.top+l.top-m;return{bottom:b+l.height,height:l.height,left:g,right:y,top:b,width:Math.max(y-g,0)}}getSelectionChipClientRect(t){let n=this.editorView?.state,o=this.editorView;if(!n||!o||!t)return null;let r=Math.min(Math.max(Math.round(t.startIndex??0),0),n.doc.length),i=n.doc.lineAt(r),s=o.lineBlockAt(i.from),a=o.scrollDOM.getBoundingClientRect(),l=o.scrollDOM.scrollTop,u=o.contentDOM.getBoundingClientRect(),m=Math.max(u.right,a.right-8),d=a.top+s.top-l;return{bottom:d+s.height,height:s.height,left:u.left,right:m,top:d,width:Math.max(m-u.left,0)}}scrollToLine(t,n=0){let o=this.editorView?.state,r=this.editorView?.scrollDOM;if(!o||!r||!this.editorView)return!1;let i=Math.min(Math.max(Math.round(t),1),o.doc.lines),s=o.doc.line(i),a=this.editorView.lineBlockAt(s.from),l=Math.max(r.scrollHeight-r.clientHeight,0),u=n>0?r.clientHeight*n:8,m=Math.min(Math.max(a.top-u,0),l);return r.scrollTo({top:m}),!0}scrollToPosition(t,n="center"){let o=this.editorView?.state,r=this.editorView?.scrollDOM;if(!o||!r||!this.editorView)return!1;let i=Math.min(Math.max(Math.round(t),0),o.doc.length),s=this.editorView.lineBlockAt(i),a=Math.max(r.scrollHeight-r.clientHeight,0),l=s.top;return n==="center"&&(l=s.top-(r.clientHeight-s.height)/2),r.scrollTo({top:Math.min(Math.max(l,0),a)}),!0}applyMarkdownToolbarAction(t){if(!this.editorView)return!1;let{state:n}=this.editorView,o=n.doc.toString(),r=!1,i=n.changeByRange(s=>{let a=sr(o,s,t);return a?(r=!0,{changes:{from:a.from,insert:a.insert,to:a.to},range:p.range(a.anchor,a.head)}):{range:s}});return r?(this.editorView.dispatch(n.update(i,{scrollIntoView:!0,userEvent:"input"})),this.editorView.focus(),!0):!1}updateCursorInfo(t){if(!this.lineInfoElement)return;let n=t.selection.main.head,o=t.doc.lineAt(n),r=n-o.from+1;this.lineInfoElement.textContent=`Ln ${o.number}, Col ${r}`}emitViewportChange(){this.onViewportChanged?.(this.getViewportState())}};var ur=class{constructor({editorContainer:t,lineWrappingEnabled:n=!0,initialTheme:o,lineInfoElement:r,onAwarenessChange:i,onConnectionChange:s,onCommentsChange:a,onContentChange:l,onSelectionChange:u,preferredUserName:m,localUser:d,getFileList:g}){this.onAwarenessChange=i,this.onCommentsChange=a,this.onContentChange=l,this.onSelectionChange=u,this.hasDeliveredContent=!1,this.lastDeliveredContent=null,this.collaborationClient=new we({localUser:d,onAwarenessChange:y=>this.onAwarenessChange?.(y),onConnectionChange:s,onInitialSync:()=>this.emitContentChange(),preferredUserName:m,resolveAwarenessCursor:y=>this.resolveAwarenessCursor(y)}),this.viewAdapter=new tt({editorContainer:t,getFileList:g||(()=>[]),initialTheme:o,lineInfoElement:r,lineWrappingEnabled:n,onDocChanged:()=>{this.emitContentChange()},onViewportChanged:y=>{this.collaborationClient.setLocalViewport(y)},onSelectionChanged:()=>{this.onSelectionChange?.(this.getCurrentSelectionCommentAnchor())}}),this.commentThreadStore=new ve({getDoc:()=>this.collaborationClient.ydoc,getEditorState:()=>this.viewAdapter.getState(),getLocalUser:()=>this.collaborationClient.getLocalUser(),onCommentsChange:y=>this.onCommentsChange?.(y)})}async initialize(t){this.hasDeliveredContent=!1,this.lastDeliveredContent=null;let n=await this.collaborationClient.initialize(t);this.viewAdapter.initialize({awareness:n.awareness,filePath:t,undoManager:n.undoManager,ytext:n.ytext}),this.commentThreadStore.bind({commentThreads:n.commentThreads,ydoc:n.ydoc,ytext:n.ytext}),this.onAwarenessChange?.(this.collaborationClient.collectUsers(o=>this.resolveAwarenessCursor(o)))}emitContentChange({force:t=!1}={}){let n=this.getText();return!t&&this.hasDeliveredContent&&n===this.lastDeliveredContent?!1:(this.hasDeliveredContent=!0,this.lastDeliveredContent=n,this.onContentChange?.(),!0)}ensureInitialContent(){return this.emitContentChange()}applyTheme(t){this.viewAdapter.applyTheme(t)}getText(){return this.collaborationClient.getText()||this.viewAdapter.getText()}getScrollContainer(){return this.viewAdapter.getScrollContainer()}getTopVisibleLineNumber(t=0){return this.viewAdapter.getTopVisibleLineNumber(t)}getLocalUser(){return this.collaborationClient.getLocalUser()}get awareness(){return this.collaborationClient.awareness}get provider(){return this.collaborationClient.provider}get ydoc(){return this.collaborationClient.ydoc}get ytext(){return this.collaborationClient.ytext}getCurrentSelectionLineRange(){return this.viewAdapter.getCurrentSelectionLineRange()}getCurrentSelectionCommentAnchor(){return this.viewAdapter.getCurrentSelectionCommentAnchor()}getCommentAnchorClientRect(t){return this.viewAdapter.getAnchorClientRect(t)}getSelectionChipClientRect(t){return this.viewAdapter.getSelectionChipClientRect(t)}getCommentThreads(){return this.commentThreadStore.getCommentThreads()}createCommentThread(t){return this.commentThreadStore.createCommentThread(t)}replyToCommentThread(t,n){return this.commentThreadStore.replyToCommentThread(t,n)}deleteCommentThread(t){return this.commentThreadStore.deleteCommentThread(t)}isLineWrappingEnabled(){return this.viewAdapter.isLineWrappingEnabled()}setLineWrapping(t){return this.viewAdapter.setLineWrapping(t)}scrollToLine(t,n=0){return this.viewAdapter.scrollToLine(t,n)}getUserCursor(t){return this.collaborationClient.getUserCursor(t,n=>this.resolveAwarenessCursor(n))}getUserViewport(t){return this.collaborationClient.getUserViewport(t)}scrollToPosition(t,n="center"){return this.viewAdapter.scrollToPosition(t,n)}scrollToUserViewport(t){let n=this.getUserViewport(t);return n?this.scrollToLine(n.topLine,n.viewportRatio):!1}scrollToUserCursor(t,n="center"){let o=this.getUserCursor(t);return o?this.scrollToPosition(o.cursorHead,n)||this.scrollToLine(o.cursorLine):!1}setUserName(t){return this.collaborationClient.setUserName(t)}requestMeasure(){this.viewAdapter.requestMeasure()}applyMarkdownToolbarAction(t){return this.viewAdapter.applyMarkdownToolbarAction(t)}waitForInitialSync(t=1500){return this.collaborationClient.waitForInitialSync(t)}destroy(){this.commentThreadStore.unbind(),this.hasDeliveredContent=!1,this.lastDeliveredContent=null,this.collaborationClient.destroy(),this.viewAdapter.destroy()}resolveAwarenessCursor(t){let n=this.collaborationClient.ydoc,o=this.collaborationClient.ytext,r=this.viewAdapter.getState();if(!t?.anchor||!t?.head||!n||!r||!o)return null;let i=R(t.anchor,n),s=R(t.head,n);if(!i||!s||i.type!==o||s.type!==o)return null;let a=r.doc.lineAt(s.index);return{cursorAnchor:i.index,cursorHead:s.index,cursorLine:a.number}}};export{ur as EditorSession};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{k as a}from"./chunk-QSTBGTWJ.js";import{a as c}from"./chunk-BBHPYU2R.js";import"./chunk-775E65SU.js";var d=12;function u(h){return a(h)}var f=class{constructor({getFileList:e,onFileSelect:t}){this.getFileList=e,this.onFileSelect=t,this.overlay=document.getElementById("quickSwitcher"),this.input=document.getElementById("quickSwitcherInput"),this.resultsList=document.getElementById("quickSwitcherResults"),this.hint=document.getElementById("quickSwitcherHint"),this.filteredFiles=[],this.selectedIndex=0,this.isOpen=!1,this.bindEvents()}bindEvents(){this.overlay?.addEventListener("mousedown",e=>{e.target===this.overlay&&this.close()}),this.input?.addEventListener("input",()=>{this.filterFiles()}),this.input?.addEventListener("keydown",e=>{switch(e.key){case"ArrowDown":e.preventDefault(),this.moveSelection(1);break;case"ArrowUp":e.preventDefault(),this.moveSelection(-1);break;case"Enter":e.preventDefault(),this.confirmSelection();break;case"Escape":e.preventDefault(),this.close();break;case"Tab":e.preventDefault(),this.moveSelection(e.shiftKey?-1:1);break}})}open(){this.overlay&&(this.isOpen=!0,this.input.value="",this.selectedIndex=0,this.overlay.classList.add("visible"),this.filterFiles(),this._focusAfterTransition())}_focusAfterTransition(){this._cancelPendingFocus();let e=()=>{this._focusCleanup=null,this.input?.focus(),this.isOpen&&this.input&&document.activeElement!==this.input&&setTimeout(()=>this.input?.focus(),50)},t=i=>{(i.propertyName==="visibility"||i.propertyName==="opacity")&&(this.overlay.removeEventListener("transitionend",t),clearTimeout(s),e())};this.overlay.addEventListener("transitionend",t);let s=setTimeout(()=>{this.overlay.removeEventListener("transitionend",t),e()},160);this._focusCleanup=()=>{this.overlay.removeEventListener("transitionend",t),clearTimeout(s)}}_cancelPendingFocus(){this._focusCleanup&&(this._focusCleanup(),this._focusCleanup=null)}close(){this.overlay&&(this._cancelPendingFocus(),this.isOpen=!1,this.overlay.classList.remove("visible"),this.input.value="",this.resultsList.innerHTML="")}toggle(){this.isOpen?this.close():this.open()}filterFiles(){let e=this.input?.value.trim().toLowerCase()??"",t=this.getFileList?.()??[];e?this.filteredFiles=t.map(s=>{let i=this.fuzzyScore(s.toLowerCase(),e);return{filePath:s,score:i}}).filter(s=>s.score>0).sort((s,i)=>i.score-s.score).slice(0,d).map(s=>s.filePath):this.filteredFiles=t.slice(0,d),this.selectedIndex=0,this.renderResults(e)}fuzzyScore(e,t){let s=u(e),i=s.split("/").pop();if(i.includes(t))return 100+1/i.length;if(s.includes(t))return 50+1/s.length;let n=0,o=0,l=0;for(let r=0;r<s.length&&n<t.length;r++)s[r]===t[n]?(n++,l+=1,o+=l,(r===0||s[r-1]==="/"||s[r-1]==="-"||s[r-1]==="_"||s[r-1]===" ")&&(o+=5)):l=0;return n===t.length?o:0}renderResults(e){if(!this.resultsList)return;if(this.resultsList.innerHTML="",this.filteredFiles.length===0){this.hint&&(this.hint.textContent=e?"No files found":"No files in vault",this.hint.classList.remove("hidden"));return}this.hint&&this.hint.classList.add("hidden");let t=document.createDocumentFragment();this.filteredFiles.forEach((s,i)=>{let n=document.createElement("button");n.type="button",n.className="qs-result-item",i===this.selectedIndex&&n.classList.add("selected"),n.dataset.index=String(i);let o=u(s),l=o.split("/").pop(),r=o.includes("/")?o.substring(0,o.lastIndexOf("/")):"";n.innerHTML=`
|
|
2
|
-
<svg class="qs-result-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>
|
|
3
|
-
<span class="qs-result-name">${this.highlightMatch(l,e)}</span>
|
|
4
|
-
${r?`<span class="qs-result-path">${c(r)}</span>`:""}
|
|
5
|
-
`,n.addEventListener("click",()=>{this.selectedIndex=i,this.confirmSelection()}),n.addEventListener("mouseenter",()=>{this.selectedIndex=i,this.updateSelection()}),t.appendChild(n)}),this.resultsList.appendChild(t)}highlightMatch(e,t){if(!t)return c(e);let i=e.toLowerCase().indexOf(t);if(i>=0){let l=e.slice(0,i),r=e.slice(i,i+t.length),p=e.slice(i+t.length);return`${c(l)}<mark>${c(r)}</mark>${c(p)}`}let n="",o=0;for(let l=0;l<e.length;l++)o<t.length&&e[l].toLowerCase()===t[o]?(n+=`<mark>${c(e[l])}</mark>`,o++):n+=c(e[l]);return n}moveSelection(e){this.filteredFiles.length!==0&&(this.selectedIndex=(this.selectedIndex+e+this.filteredFiles.length)%this.filteredFiles.length,this.updateSelection())}updateSelection(){if(!this.resultsList)return;let e=this.resultsList.querySelectorAll(".qs-result-item");e.forEach((s,i)=>{s.classList.toggle("selected",i===this.selectedIndex)}),e[this.selectedIndex]?.scrollIntoView({block:"nearest"})}confirmSelection(){let e=this.filteredFiles[this.selectedIndex];e&&(this.close(),this.onFileSelect?.(e))}};export{f as QuickSwitcherController};
|