mbeditor 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +131 -0
- data/README.md +153 -3
- data/app/assets/javascripts/mbeditor/application.js +5 -0
- data/app/assets/javascripts/mbeditor/application_iife_tail.js +6 -0
- data/app/assets/javascripts/mbeditor/collaboration_identity.js +234 -0
- data/app/assets/javascripts/mbeditor/collaboration_service.js +690 -0
- data/app/assets/javascripts/mbeditor/components/EditorPanel.js +120 -19
- data/app/assets/javascripts/mbeditor/components/FileTree.js +127 -8
- data/app/assets/javascripts/mbeditor/components/GitPanel.js +12 -3
- data/app/assets/javascripts/mbeditor/components/ImportConflictModal.js +127 -0
- data/app/assets/javascripts/mbeditor/components/MbeditorApp.js +911 -72
- data/app/assets/javascripts/mbeditor/components/ModelGraph.js +565 -0
- data/app/assets/javascripts/mbeditor/components/ProblemsPanel.js +130 -10
- data/app/assets/javascripts/mbeditor/components/ShortcutHelp.js +1 -0
- data/app/assets/javascripts/mbeditor/components/TabBar.js +4 -2
- data/app/assets/javascripts/mbeditor/editor_plugins.js +517 -111
- data/app/assets/javascripts/mbeditor/file_import.js +146 -0
- data/app/assets/javascripts/mbeditor/file_service.js +52 -3
- data/app/assets/javascripts/mbeditor/tab_manager.js +50 -1
- data/app/assets/javascripts/mbeditor/websocket_service.js +89 -0
- data/app/assets/stylesheets/mbeditor/editor.css +273 -10
- data/app/channels/mbeditor/channel_authentication.rb +94 -0
- data/app/channels/mbeditor/collaboration_channel.rb +84 -0
- data/app/channels/mbeditor/editor_channel.rb +40 -1
- data/app/controllers/mbeditor/application_controller.rb +5 -1
- data/app/controllers/mbeditor/editors_controller.rb +465 -19
- data/app/controllers/mbeditor/git_controller.rb +9 -2
- data/app/services/mbeditor/availability_probe.rb +76 -17
- data/app/services/mbeditor/code_search_service.rb +23 -3
- data/app/services/mbeditor/collaboration_doc_store.rb +116 -0
- data/app/services/mbeditor/file_import_service.rb +103 -0
- data/app/services/mbeditor/git_combined_diff_service.rb +36 -5
- data/app/services/mbeditor/git_info_service.rb +6 -0
- data/app/services/mbeditor/git_service.rb +22 -6
- data/app/services/mbeditor/lsp_diagnostics_translator.rb +99 -5
- data/app/services/mbeditor/model_graph_service.rb +232 -0
- data/app/services/mbeditor/presence_registry.rb +83 -0
- data/app/services/mbeditor/ri_definition_service.rb +39 -5
- data/app/services/mbeditor/search_replace_service.rb +24 -4
- data/app/views/layouts/mbeditor/application.html.erb +2 -0
- data/lib/mbeditor/configuration.rb +33 -3
- data/lib/mbeditor/engine.rb +34 -0
- data/lib/mbeditor/exception_log.rb +84 -0
- data/lib/mbeditor/route_map.rb +5 -0
- data/lib/mbeditor/ruby_lsp_client.rb +28 -1
- data/lib/mbeditor/version.rb +1 -1
- data/lib/mbeditor.rb +1 -0
- data/vendor/assets/javascripts/yjs-collab.js +12 -0
- metadata +15 -2
|
@@ -76,6 +76,7 @@ module Mbeditor
|
|
|
76
76
|
@next_id = 0
|
|
77
77
|
@state = :stopped # :stopped | :ready | :crashed | :failed
|
|
78
78
|
@crash_times = []
|
|
79
|
+
@last_error = nil # last start failure, surfaced to the editor's status chip
|
|
79
80
|
end
|
|
80
81
|
|
|
81
82
|
attr_reader :state
|
|
@@ -85,6 +86,28 @@ module Mbeditor
|
|
|
85
86
|
@state == :ready
|
|
86
87
|
end
|
|
87
88
|
|
|
89
|
+
# A snapshot for the editor's status indicator. Deliberately does not start
|
|
90
|
+
# the process — asking "how are you?" must not be what boots the server.
|
|
91
|
+
def health
|
|
92
|
+
@state_mutex.synchronize do
|
|
93
|
+
{ state: @state, restarts: @crash_times.length, error: @last_error }
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Clears the crash budget so a client latched at :failed can be revived
|
|
98
|
+
# without restarting the whole Rails process. Clearing @crash_times is the
|
|
99
|
+
# load-bearing part: restart_allowed? re-latches :failed immediately if the
|
|
100
|
+
# window still holds MAX_RESTARTS entries.
|
|
101
|
+
def reset!
|
|
102
|
+
stop
|
|
103
|
+
@state_mutex.synchronize do
|
|
104
|
+
@crash_times.clear
|
|
105
|
+
@last_error = nil
|
|
106
|
+
@state = :stopped
|
|
107
|
+
end
|
|
108
|
+
ready?
|
|
109
|
+
end
|
|
110
|
+
|
|
88
111
|
# Syncs the document (didOpen / full-text didChange) and issues a request
|
|
89
112
|
# against it under one mutex, so concurrent Puma threads can't interleave
|
|
90
113
|
# a positional request with a stale document.
|
|
@@ -215,6 +238,7 @@ module Mbeditor
|
|
|
215
238
|
@state = :ready
|
|
216
239
|
rescue StandardError => e
|
|
217
240
|
Rails.logger.warn("[mbeditor] ruby-lsp start failed: #{e.class}: #{e.message}") if defined?(Rails)
|
|
241
|
+
@last_error = "#{e.class}: #{e.message}"
|
|
218
242
|
record_crash
|
|
219
243
|
cleanup_process
|
|
220
244
|
@state = @crash_times.length >= MAX_RESTARTS ? :failed : :crashed
|
|
@@ -310,10 +334,13 @@ module Mbeditor
|
|
|
310
334
|
def start_monitor_thread
|
|
311
335
|
wait_thr = @wait_thr
|
|
312
336
|
@monitor_thread = Thread.new do
|
|
313
|
-
wait_thr.value # blocks until process exit
|
|
337
|
+
status = wait_thr.value # blocks until process exit
|
|
314
338
|
@state_mutex.synchronize do
|
|
315
339
|
next if @stopping || @wait_thr != wait_thr
|
|
316
340
|
|
|
341
|
+
# A crash mid-session leaves no exception to quote, so the exit
|
|
342
|
+
# status is the only reason the status chip can show.
|
|
343
|
+
@last_error = "ruby-lsp exited (#{status.exitstatus || status})"
|
|
317
344
|
record_crash
|
|
318
345
|
cleanup_process
|
|
319
346
|
@state = @crash_times.length >= MAX_RESTARTS ? :failed : :crashed
|
data/lib/mbeditor/version.rb
CHANGED
data/lib/mbeditor.rb
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* mbeditor collaborative-editing bundle — GENERATED, DO NOT EDIT BY HAND.
|
|
3
|
+
* Rebuild: npm install && npm run build:yjs (maintainer-only; consumers run zero JS tooling — ADR-0001).
|
|
4
|
+
* Bundled: yjs@13.6.31, y-monaco@0.1.6, y-protocols@1.0.7.
|
|
5
|
+
* Exposes globals: window.Y, window.MonacoBinding, window.awarenessProtocol.
|
|
6
|
+
* Monaco is NOT bundled; y-monaco binds to the page's runtime window.monaco.
|
|
7
|
+
*/
|
|
8
|
+
(()=>{var gs=Object.defineProperty;var ko=(e,t,n)=>t in e?gs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ms=(e,t)=>{for(var n in t)gs(e,n,{get:t[n],enumerable:!0})};var We=(e,t,n)=>ko(e,typeof t!="symbol"?t+"":t,n);var Kn={};ms(Kn,{AbsolutePosition:()=>Nn,AbstractConnector:()=>Fr,AbstractStruct:()=>ge,AbstractType:()=>U,Array:()=>Bt,ContentAny:()=>_t,ContentBinary:()=>jt,ContentDeleted:()=>me,ContentDoc:()=>Pt,ContentEmbed:()=>pt,ContentFormat:()=>C,ContentJSON:()=>Xe,ContentString:()=>tt,ContentType:()=>K,Doc:()=>kt,GC:()=>$,ID:()=>ut,Item:()=>S,Map:()=>Mt,PermanentUserData:()=>Pr,RelativePosition:()=>fe,Skip:()=>N,Snapshot:()=>Pe,Text:()=>pe,Transaction:()=>Rn,UndoManager:()=>Jr,UpdateDecoderV1:()=>q,UpdateDecoderV2:()=>F,UpdateEncoderV1:()=>ct,UpdateEncoderV2:()=>J,XmlElement:()=>Ft,XmlFragment:()=>$t,XmlHook:()=>Ye,XmlText:()=>qn,YArrayEvent:()=>$n,YEvent:()=>Rt,YMapEvent:()=>Fn,YTextEvent:()=>jn,YXmlEvent:()=>Pn,applyUpdate:()=>Yc,applyUpdateV2:()=>zn,cleanupYTextFormatting:()=>lo,compareIDs:()=>vt,compareRelativePositions:()=>al,convertUpdateFormatV1ToV2:()=>Tl,convertUpdateFormatV2ToV1:()=>Hi,createAbsolutePositionFromRelativePosition:()=>ye,createDeleteSet:()=>Hn,createDeleteSetFromStructStore:()=>Zr,createDocFromSnapshot:()=>gl,createID:()=>y,createRelativePositionFromJSON:()=>nl,createRelativePositionFromTypeIndex:()=>we,createSnapshot:()=>ss,decodeRelativePosition:()=>cl,decodeSnapshot:()=>ul,decodeSnapshotV2:()=>Vi,decodeStateVector:()=>es,decodeUpdate:()=>_l,decodeUpdateV2:()=>$i,diffUpdate:()=>Al,diffUpdateV2:()=>is,emptySnapshot:()=>fl,encodeRelativePosition:()=>il,encodeSnapshot:()=>dl,encodeSnapshotV2:()=>vi,encodeStateAsUpdate:()=>Kc,encodeStateAsUpdateV2:()=>Di,encodeStateVector:()=>Qc,encodeStateVectorFromUpdate:()=>El,encodeStateVectorFromUpdateV2:()=>ji,equalDeleteSets:()=>Ci,equalSnapshots:()=>hl,findIndexSS:()=>X,findRootTypeKey:()=>rs,getItem:()=>Vt,getItemCleanEnd:()=>Hr,getItemCleanStart:()=>M,getState:()=>_,getTypeChildren:()=>Nl,isDeleted:()=>qt,isParentOf:()=>je,iterateDeletedStructs:()=>Ot,logType:()=>tl,logUpdate:()=>Sl,logUpdateV2:()=>Mi,mergeDeleteSets:()=>Nt,mergeUpdates:()=>Fi,mergeUpdatesV2:()=>Ge,obfuscateUpdate:()=>Dl,obfuscateUpdateV2:()=>Il,parseUpdateMeta:()=>Ul,parseUpdateMetaV2:()=>Pi,readUpdate:()=>Jc,readUpdateV2:()=>ts,relativePositionToJSON:()=>el,snapshot:()=>pl,snapshotContainsUpdate:()=>wl,transact:()=>k,tryGc:()=>bl,typeListToArraySnapshot:()=>Ll,typeMapGetAllSnapshot:()=>ro,typeMapGetSnapshot:()=>Ml});var E=()=>new Map,Ze=e=>{let t=E();return e.forEach((n,r)=>{t.set(r,n)}),t},R=(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 et=()=>new Set;var Qe=e=>e[e.length-1];var xs=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},W=Array.from,tn=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},ke=(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 at=Array.isArray;var Gt=class{constructor(){this._observers=E()}on(t,n){return R(this._observers,t,et).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)||E()).values()).forEach(r=>r(...n))}destroy(){this._observers=E()}},en=class{constructor(){this._observers=E()}on(t,n){R(this._observers,t,et).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)||E()).values()).forEach(r=>r(...n))}destroy(){this._observers=E()}};var O=Math.floor;var Et=Math.abs;var nn=(e,t)=>e<t?e:t,ht=(e,t)=>e>t?e:t,_a=Number.isNaN;var rn=e=>e!==0?e<0:1/e<0;var zt=Number.MAX_SAFE_INTEGER,nr=Number.MIN_SAFE_INTEGER,Ea=1<<31;var ks=Number.isInteger||(e=>typeof e=="number"&&isFinite(e)&&O(e)===e),Ua=Number.isNaN,Ca=Number.parseInt;var sr=String.fromCharCode,So=String.fromCodePoint,Aa=sr(65535),_o=e=>e.toLowerCase(),Eo=/^\s*/g,Uo=e=>e.replace(Eo,""),Co=/([A-Z])/g,ir=(e,t)=>Uo(e.replace(Co,n=>`${t}${_o(n)}`));var Ao=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},Yt=typeof TextEncoder!="undefined"?new TextEncoder:null,Do=e=>Yt.encode(e),Ss=Yt?Do:Ao;var Jt=typeof TextDecoder=="undefined"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Jt&&Jt.decode(new Uint8Array).length===1&&(Jt=null);var sn=(e,t)=>bs(t,()=>e).join("");var Ut=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},nt=()=>new Ut;var Io=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t};var B=e=>{let t=new Uint8Array(Io(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},To=(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(ht(n,t)*2),e.cpos=0)},v=(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 Zt=v;var g=(e,t)=>{for(;t>127;)v(e,128|127&t),t=O(t/128);v(e,127&t)},Ue=(e,t)=>{let n=rn(t);for(n&&(t=-t),v(e,(t>63?128:0)|(n?64:0)|63&t),t=O(t/64);t>0;)v(e,(t>127?128:0)|127&t),t=O(t/128)},or=new Uint8Array(3e4),vo=or.length/3,Vo=(e,t)=>{if(t.length<vo){let n=Yt.encodeInto(t,or).written||0;g(e,n);for(let r=0;r<n;r++)v(e,or[r])}else j(e,Ss(t))},Oo=(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;g(e,r);for(let s=0;s<r;s++)v(e,n.codePointAt(s))},Z=Yt&&Yt.encodeInto?Vo:Oo;var As=(e,t)=>Qt(e,B(t)),Qt=(e,t)=>{let n=e.cbuf.length,r=e.cpos,s=nn(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(ht(n*2,i)),e.cbuf.set(t.subarray(s)),e.cpos=i)},j=(e,t)=>{g(e,t.byteLength),Qt(e,t)},cr=(e,t)=>{To(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},No=(e,t)=>cr(e,4).setFloat32(0,t,!1),Lo=(e,t)=>cr(e,8).setFloat64(0,t,!1),Ro=(e,t)=>cr(e,8).setBigInt64(0,t,!1);var Es=new DataView(new ArrayBuffer(4)),Bo=e=>(Es.setFloat32(0,e),Es.getFloat32(0)===e),Kt=(e,t)=>{switch(typeof t){case"string":v(e,119),Z(e,t);break;case"number":ks(t)&&Et(t)<=2147483647?(v(e,125),Ue(e,t)):Bo(t)?(v(e,124),No(e,t)):(v(e,123),Lo(e,t));break;case"bigint":v(e,122),Ro(e,t);break;case"object":if(t===null)v(e,126);else if(at(t)){v(e,117),g(e,t.length);for(let n=0;n<t.length;n++)Kt(e,t[n])}else if(t instanceof Uint8Array)v(e,116),j(e,t);else{v(e,118);let n=Object.keys(t);g(e,n.length);for(let r=0;r<n.length;r++){let s=n[r];Z(e,s),Kt(e,t[s])}}break;case"boolean":v(e,t?120:121);break;default:v(e,127)}},Ee=class extends Ut{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 Us=e=>{e.count>0&&(Ue(e.encoder,e.count===1?e.s:-e.s),e.count>1&&g(e.encoder,e.count-2))},Ct=class{constructor(){this.encoder=new Ut,this.s=0,this.count=0}write(t){this.s===t?this.count++:(Us(this),this.count=1,this.s=t)}toUint8Array(){return Us(this),B(this.encoder)}};var Cs=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);Ue(e.encoder,t),e.count>1&&g(e.encoder,e.count-2)}},Wt=class{constructor(){this.encoder=new Ut,this.s=0,this.count=0,this.diff=0}write(t){this.diff===t-this.s?(this.s=t,this.count++):(Cs(this),this.count=1,this.diff=t-this.s,this.s=t)}toUint8Array(){return Cs(this),B(this.encoder)}},on=class{constructor(){this.sarr=[],this.s="",this.lensE=new Ct}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 Ut;return this.sarr.push(this.s),this.s="",Z(t,this.sarr.join("")),Qt(t,this.lensE.toUint8Array()),B(t)}};var H=e=>new Error(e),z=()=>{throw H("Method unimplemented")},A=()=>{throw H("Unexpected case")};var Is=H("Unexpected end of array"),Ts=H("Integer out of Range"),te=class{constructor(t){this.arr=t,this.pos=0}},D=e=>new te(e),lr=e=>e.pos!==e.arr.length;var Mo=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},P=e=>Mo(e,w(e));var At=e=>e.arr[e.pos++];var w=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>zt)throw Ts}throw Is},Ae=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>zt)throw Ts}throw Is};var $o=e=>{let t=w(e);if(t===0)return"";{let n=String.fromCodePoint(At(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(At(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))}},Fo=e=>Jt.decode(P(e)),Q=Jt?Fo:$o;var ar=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},jo=e=>ar(e,4).getFloat32(0,!1),Po=e=>ar(e,8).getFloat64(0,!1),qo=e=>ar(e,8).getBigInt64(0,!1);var Go=[e=>{},e=>null,Ae,jo,Po,qo,e=>!1,e=>!0,Q,e=>{let t=w(e),n={};for(let r=0;r<t;r++){let s=Q(e);n[s]=ee(e)}return n},e=>{let t=w(e),n=[];for(let r=0;r<t;r++)n.push(ee(e));return n},P],ee=e=>Go[127-At(e)](e),Ce=class extends te{constructor(t,n){super(t),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),lr(this)?this.count=w(this)+1:this.count=-1),this.count--,this.s}};var Dt=class extends te{constructor(t){super(t),this.s=0,this.count=0}read(){if(this.count===0){this.s=Ae(this);let t=rn(this.s);this.count=1,t&&(this.s=-this.s,this.count=w(this)+2)}return this.count--,this.s}};var ne=class extends te{constructor(t){super(t),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let t=Ae(this),n=t&1;this.diff=O(t/2),this.count=1,n&&(this.count=w(this)+2)}return this.s+=this.diff,this.count--,this.s}},ln=class{constructor(t){this.decoder=new Dt(t),this.str=Q(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 Ta=crypto.subtle,Vs=crypto.getRandomValues.bind(crypto);var hr=()=>Vs(new Uint32Array(1))[0];var Ho="10000000-1000-4000-8000"+-1e11,Os=()=>Ho.replace(/[018]/g,e=>(e^hr()&15>>e/4).toString(16));var dt=Date.now;var ur=e=>new Promise(e);var Oa=Promise.all.bind(Promise);var fr=e=>e===void 0?null:e;var pr=class{constructor(){this.map=new Map}setItem(t,n){this.map.set(t,n)}getItem(t){return this.map.get(t)}},Ns=new pr,Xo=!0;try{typeof localStorage!="undefined"&&localStorage&&(Ns=localStorage,Xo=!1)}catch{}var Ls=Ns;var It=Symbol("Equality"),an=(e,t)=>{var n;return e===t||!!((n=e==null?void 0:e[It])!=null&&n.call(e,t))||!1};var Rs=e=>typeof e=="object",Bs=Object.assign,Wo=Object.keys;var Ms=(e,t)=>{for(let n in e)t(e[n],n)};var De=e=>Wo(e).length;var $s=e=>{for(let t in e)return!1;return!0},re=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},Ie=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),mr=(e,t)=>e===t||De(e)===De(t)&&re(e,(n,r)=>(n!==void 0||Ie(t,r))&&an(t[r],n)),Zo=Object.freeze,wr=e=>{for(let t in e){let n=e[t];(typeof n=="object"||typeof n=="function")&&wr(e[t])}return Zo(e)};var Te=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&Te(e,t,n+1)}};var xr=e=>e;var mt=(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[It]!=null)return e[It](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)||!mt(e.get(n),t.get(n)))return!1;break}case void 0:case Object:if(De(e)!==De(t))return!1;for(let n in e)if(!Ie(e,n)||!mt(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(!mt(e[n],t[n]))return!1;break;default:return!1}return!0},Fs=(e,t)=>t.includes(e);var ve=typeof process!="undefined"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process!="undefined"?process:0)==="[object process]";var Na=typeof navigator!="undefined"?/Mac/.test(navigator.platform):!1,rt,Qo=[],tc=()=>{if(rt===void 0)if(ve){rt=E();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]==="-"?(t!==null&&rt.set(t,""),t=r):t!==null?(rt.set(t,r),t=null):Qo.push(r)}t!==null&&rt.set(t,"")}else typeof location=="object"?(rt=E(),(location.search||"?").slice(1).split("&").forEach(e=>{if(e.length!==0){let[t,n]=e.split("=");rt.set(`--${ir(t,"-")}`,n),rt.set(`-${ir(t,"-")}`,n)}})):rt=E();return rt},br=e=>tc().has(e);var Ve=e=>ve?fr(process.env[e.toUpperCase().replaceAll("-","_")]):fr(Ls.getItem(e));var js=e=>br("--"+e)||Ve(e)!==null,Ps=js("production"),ec=ve&&Fs(process.env.FORCE_COLOR,["true","1","2"]),qs=ec||!br("--no-colors")&&!js("no-color")&&(!ve||process.stdout.isTTY)&&(!ve||br("--color")||Ve("COLORTERM")!==null||(Ve("TERM")||"").includes("color"));var nc=e=>new Uint8Array(e);var Gs=e=>{let t=nc(e.byteLength);return t.set(e),t};var Sr=class{constructor(t,n){this.left=t,this.right=n}},st=(e,t)=>new Sr(e,t);var _r=e=>e.next()>=.5,dn=(e,t,n)=>O(e.next()*(n+1-t)+t);var Er=(e,t,n)=>O(e.next()*(n+1-t)+t);var Ur=(e,t,n)=>Er(e,t,n);var ic=e=>sr(Ur(e,97,122)),Hs=(e,t=0,n=20)=>{let r=Ur(e,t,n),s="";for(let i=0;i<r;i++)s+=ic(e);return s};var un=(e,t)=>t[Ur(e,0,t.length-1)];var cc=Symbol("0schema"),Cr=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(sn(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return t.join(`
|
|
9
|
+
`)}},Ar=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[It]?an(e,t):at(e)?tn(e,n=>ke(t,r=>Ar(n,r))):Rs(e)?re(e,(n,r)=>Ar(n,t[r])):!1,V=class{extends(t){let[n,r]=[this.shape,t.shape];return this.constructor._dilutes&&([r,n]=[n,r]),Ar(n,r)}equals(t){return this.constructor===t.constructor&&mt(this.shape,t.shape)}[cc](){return!0}[It](t){return this.equals(t)}validate(t){return this.check(t)}check(t,n){z()}get nullable(){return ae(this,Un)}get optional(){return new fn(this)}cast(t){return zs(t,this),t}expect(t){return zs(t,this),t}};We(V,"_dilutes",!1);var Oe=class extends V{constructor(t,n){super(),this.shape=t,this._c=n}check(t,n=void 0){let r=(t==null?void 0:t.constructor)===this.shape&&(this._c==null||this._c(t));return!r&&(n==null||n.extend(null,this.shape.name,t==null?void 0:t.constructor.name,(t==null?void 0:t.constructor)!==this.shape?"Constructor match failed":"Check failed")),r}},I=(e,t=null)=>new Oe(e,t),Ra=I(Oe),Ne=class extends V{constructor(t){super(),this.shape=t}check(t,n){let r=this.shape(t);return!r&&(n==null||n.extend(null,"custom prop",t==null?void 0:t.constructor.name,"failed to check custom prop")),r}},T=e=>new Ne(e),Ba=I(Ne),ce=class extends V{constructor(t){super(),this.shape=t}check(t,n){let r=this.shape.some(s=>s===t);return!r&&(n==null||n.extend(null,this.shape.join(" | "),t.toString())),r}},_n=(...e)=>new ce(e),Js=I(ce),lc=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,t=>"\\"+t)),Ys=e=>{if(le.check(e))return[lc(e)];if(Js.check(e))return e.shape.map(t=>t+"");if(Qs.check(e))return["[+-]?\\d+.?\\d*"];if(ti.check(e))return[".*"];if(bn.check(e))return e.shape.map(Ys).flat(1);A()},Dr=class extends V{constructor(t){super(),this.shape=t,this._r=new RegExp("^"+t.map(Ys).map(n=>`(${n.join("|")})`).join("")+"$")}check(t,n){let r=this._r.exec(t)!=null;return!r&&(n==null||n.extend(null,this._r.toString(),t.toString(),"String doesn't match string template.")),r}};var Ma=I(Dr),ac=Symbol("optional"),fn=class extends V{constructor(t){super(),this.shape=t}check(t,n){let r=t===void 0||this.shape.check(t);return!r&&(n==null||n.extend(null,"undefined (optional)","()")),r}get[ac](){return!0}},hc=I(fn),pn=class extends V{check(t,n){return n==null||n.extend(null,"never",typeof t),!1}},$a=new pn,Fa=I(pn),Sn=class Sn extends V{constructor(t,n=!1){super(),this.shape=t,this._isPartial=n}get partial(){return new Sn(this.shape,!0)}check(t,n){return t==null?(n==null||n.extend(null,"object","null"),!1):re(this.shape,(r,s)=>{let i=this._isPartial&&!Ie(t,s)||r.check(t[s],n);return!i&&(n==null||n.extend(s.toString(),r.toString(),typeof t[s],"Object property does not match")),i})}};We(Sn,"_dilutes",!0);var gn=Sn,dc=e=>new gn(e),uc=I(gn),fc=T(e=>e!=null&&(e.constructor===Object||e.constructor==null)),mn=class extends V{constructor(t,n){super(),this.shape={keys:t,values:n}}check(t,n){return t!=null&&re(t,(r,s)=>{let i=this.shape.keys.check(s,n);return!i&&(n==null||n.extend(s+"","Record",typeof t,i?"Key doesn't match schema":"Value doesn't match value")),i&&this.shape.values.check(r,n)})}},Xs=(e,t)=>new mn(e,t),pc=I(mn),wn=class extends V{constructor(t){super(),this.shape=t}check(t,n){return t!=null&&re(this.shape,(r,s)=>{let i=r.check(t[s],n);return!i&&(n==null||n.extend(s.toString(),"Tuple",typeof r)),i})}},gc=(...e)=>new wn(e),ja=I(wn),yn=class extends V{constructor(t){super(),this.shape=t.length===1?t[0]:new ie(t)}check(t,n){let r=at(t)&&tn(t,s=>this.shape.check(s));return!r&&(n==null||n.extend(null,"Array","")),r}},Ks=(...e)=>new yn(e),mc=I(yn),wc=T(e=>at(e)),xn=class extends V{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==null||n.extend(null,this.shape.name,t==null?void 0:t.constructor.name)),r}},yc=(e,t=null)=>new xn(e,t),Pa=I(xn),xc=yc(V),Ir=class extends V{constructor(t){super(),this.len=t.length-1,this.args=gc(...t.slice(-1)),this.res=t[this.len]}check(t,n){let r=t.constructor===Function&&t.length<=this.len;return!r&&(n==null||n.extend(null,"function",typeof t)),r}};var bc=I(Ir),kc=T(e=>typeof e=="function"),Tr=class extends V{constructor(t){super(),this.shape=t}check(t,n){let r=tn(this.shape,s=>s.check(t,n));return!r&&(n==null||n.extend(null,"Intersectinon",typeof t)),r}};var qa=I(Tr,e=>e.shape.length>0),ie=class extends V{constructor(t){super(),this.shape=t}check(t,n){let r=ke(this.shape,s=>s.check(t,n));return n==null||n.extend(null,"Union",typeof t),r}};We(ie,"_dilutes",!0);var ae=(...e)=>e.findIndex(t=>bn.check(t))>=0?ae(...e.map(t=>Le(t)).map(t=>bn.check(t)?t.shape:[t]).flat(1)):e.length===1?e[0]:new ie(e),bn=I(ie),Ws=()=>!0,kn=T(Ws),Sc=I(Ne,e=>e.shape===Ws),Vr=T(e=>typeof e=="bigint"),_c=T(e=>e===Vr),Zs=T(e=>typeof e=="symbol"),Ga=T(e=>e===Zs),oe=T(e=>typeof e=="number"),Qs=T(e=>e===oe),le=T(e=>typeof e=="string"),ti=T(e=>e===le),En=T(e=>typeof e=="boolean"),Ec=T(e=>e===En),ei=_n(void 0),Ha=I(ce,e=>e.shape.length===1&&e.shape[0]===void 0),za=_n(void 0);var Un=_n(null),Uc=I(ce,e=>e.shape.length===1&&e.shape[0]===null),Ja=I(Uint8Array),Ya=I(Oe,e=>e.shape===Uint8Array),Cc=ae(oe,le,Un,ei,Vr,En,Zs),Xa=(()=>{let e=Ks(kn),t=Xs(le,kn),n=ae(oe,le,Un,En,e,t);return e.shape=n,t.shape.values=n,n})(),Le=e=>{if(xc.check(e))return e;if(fc.check(e)){let t={};for(let n in e)t[n]=Le(e[n]);return dc(t)}else{if(wc.check(e))return ae(...e.map(Le));if(Cc.check(e))return _n(e);if(kc.check(e))return I(e)}A()},zs=Ps?()=>{}:(e,t)=>{let n=new Cr;if(!t.check(e,n))throw H(`Expected value to be of type ${t.constructor.name}.
|
|
10
|
+
${n.toString()}`)},vr=class{constructor(t){this.patterns=[],this.$state=t}if(t,n){return this.patterns.push({if:Le(t),h:n}),this}else(t){return this.if(kn,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")}}},Ac=e=>new vr(e),ni=Ac(kn).if(Qs,(e,t)=>dn(t,nr,zt)).if(ti,(e,t)=>Hs(t)).if(Ec,(e,t)=>_r(t)).if(_c,(e,t)=>BigInt(dn(t,nr,zt))).if(bn,(e,t)=>se(t,un(t,e.shape))).if(uc,(e,t)=>{let n={};for(let r in e.shape){let s=e.shape[r];if(hc.check(s)){if(_r(t))continue;s=s.shape}n[r]=ni(s,t)}return n}).if(mc,(e,t)=>{let n=[],r=Er(t,0,42);for(let s=0;s<r;s++)n.push(se(t,e.shape));return n}).if(Js,(e,t)=>un(t,e.shape)).if(Uc,(e,t)=>null).if(bc,(e,t)=>{let n=se(t,e.res);return()=>n}).if(Sc,(e,t)=>se(t,un(t,[oe,le,Un,ei,Vr,En,Ks(oe),Xs(ae("a","b","c"),oe)]))).if(pc,(e,t)=>{let n={},r=dn(t,0,3);for(let s=0;s<r;s++){let i=se(t,e.shape.keys),o=se(t,e.shape.values);n[i]=o}return n}).done(),se=(e,t)=>ni(Le(t),e);var Tt=typeof document!="undefined"?document:{};var Wa=T(e=>e.nodeType===Vc);var Za=typeof DOMParser!="undefined"?new DOMParser:null;var Qa=T(e=>e.nodeType===Ic);var th=T(e=>e.nodeType===Tc);var ri=e=>ws(e,(t,n)=>`${n}:${t};`).join("");var Ic=Tt.ELEMENT_NODE,Tc=Tt.TEXT_NODE,eh=Tt.CDATA_SECTION_NODE,nh=Tt.COMMENT_NODE,vc=Tt.DOCUMENT_NODE,rh=Tt.DOCUMENT_TYPE_NODE,Vc=Tt.DOCUMENT_FRAGMENT_NODE,sh=T(e=>e.nodeType===vc);var it=Symbol;var Re=it(),Be=it(),Or=it(),Nr=it(),Lr=it(),Me=it(),Rr=it(),he=it(),Br=it(),si=e=>{var s;e.length===1&&((s=e[0])==null?void 0:s.constructor)===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let i=e[r];if(i===void 0)break;if(i.constructor===String||i.constructor===Number)t.push(i);else if(i.constructor===Object)break}for(r>0&&n.push(t.join(""));r<e.length;r++){let i=e[r];i instanceof Symbol||n.push(i)}return n};var ih=dt();var Rc={[Re]:st("font-weight","bold"),[Be]:st("font-weight","normal"),[Or]:st("color","blue"),[Lr]:st("color","green"),[Nr]:st("color","grey"),[Me]:st("color","red"),[Rr]:st("color","purple"),[he]:st("color","orange"),[Br]:st("color","black")},Bc=e=>{var o;e.length===1&&((o=e[0])==null?void 0:o.constructor)===Function&&(e=e[0]());let t=[],n=[],r=E(),s=[],i=0;for(;i<e.length;i++){let c=e[i],l=Rc[c];if(l!==void 0)r.set(l.left,l.right);else{if(c===void 0)break;if(c.constructor===String||c.constructor===Number){let a=ri(r);i>0||a.length>0?(t.push("%c"+c),n.push(a)):t.push(c)}else break}}for(i>0&&(s=n,s.unshift(t.join("")));i<e.length;i++){let c=e[i];c instanceof Symbol||s.push(c)}return s},ii=qs?Bc:si,Cn=(...e)=>{console.log(...ii(e)),oi.forEach(t=>t.print(e))},Mr=(...e)=>{console.warn(...ii(e)),e.unshift(he),oi.forEach(t=>t.print(e))};var oi=et();var ci=e=>({[Symbol.iterator](){return this},next:e}),li=(e,t)=>ci(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),An=(e,t)=>ci(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}});var Fr=class extends Gt{constructor(t,n){super(),this.doc=t,this.awareness=n}},de=class{constructor(t,n){this.clock=t,this.len=n}},bt=class{constructor(){this.clients=new Map}},Ot=(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,a=r[l];l<r.length&&a.clock<c;a=r[++l])Ni(e,i,a.clock,a.len,n)}}),Pc=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let s=O((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},qt=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&Pc(n,t.clock)!==null},Wr=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?t[r-1]=new de(s.clock,ht(s.len,i.clock+i.len-s.clock)):(r<n&&(t[r]=i),r++)}t.length=r})},Nt=e=>{let t=new bt;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 Wr(t),t},Fe=(e,t,n,r)=>{R(e.clients,t,()=>[]).push(new de(n,r))},Hn=()=>new bt,Zr=e=>{let t=Hn();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 a=n[i+1];i+1<n.length&&a.deleted;a=n[++i+1])l+=a.length;s.push(new de(c,l))}}s.length>0&&t.clients.set(r,s)}),t},ot=(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)}})},ft=e=>{let t=new bt,n=w(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let s=w(e.restDecoder),i=w(e.restDecoder);if(i>0){let o=R(t.clients,s,()=>[]);for(let c=0;c<i;c++)o.push(new de(e.readDsClock(),e.readDsLen()))}}return t},di=(e,t,n)=>{let r=new bt,s=w(e.restDecoder);for(let i=0;i<s;i++){e.resetDsCurVal();let o=w(e.restDecoder),c=w(e.restDecoder),l=n.clients.get(o)||[],a=_(n,o);for(let h=0;h<c;h++){let d=e.readDsClock(),u=d+e.readDsLen();if(d<a){a<u&&Fe(r,o,a,u-a);let f=X(l,d),p=l[f];for(!p.deleted&&p.id.clock<d&&(l.splice(f+1,0,Gn(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,Gn(t,p,u-p.id.clock)),p.delete(t))}else Fe(r,o,d,u-d)}}if(r.clients.size>0){let i=new J;return g(i.restEncoder,0),ot(i,r),i.toUint8Array()}return null},Ci=(e,t)=>{if(e.clients.size!==t.clients.size)return!1;for(let[n,r]of e.clients.entries()){let s=t.clients.get(n);if(s===void 0||r.length!==s.length)return!1;for(let i=0;i<r.length;i++){let o=r[i],c=s[i];if(o.clock!==c.clock||o.len!==c.len)return!1}}return!0},Ai=hr,kt=class e extends Gt{constructor({guid:t=Os(),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=Ai(),this.guid=t,this.collectionid=n,this.share=new Map,this.store=new Ln,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=ur(a=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});let l=()=>ur(a=>{let h=d=>{(d===void 0||d===!0)&&(this.off("sync",h),a())};this.on("sync",h)});this.on("sync",a=>{a===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){let t=this._item;t!==null&&!this.shouldLoad&&k(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 k(this,t,n)}get(t,n=U){let r=R(this.share,t,()=>{let i=new n;return i._integrate(this,null),i}),s=r.constructor;if(n!==U&&s!==n)if(s===U){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,Bt)}getText(t=""){return this.get(t,pe)}getMap(t=""){return this.get(t,Mt)}getXmlElement(t=""){return this.get(t,Ft)}getXmlFragment(t=""){return this.get(t,$t)}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,k(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()}},Lt=class{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return w(this.restDecoder)}readDsLen(){return w(this.restDecoder)}},q=class extends Lt{readLeftID(){return y(w(this.restDecoder),w(this.restDecoder))}readRightID(){return y(w(this.restDecoder),w(this.restDecoder))}readClient(){return w(this.restDecoder)}readInfo(){return At(this.restDecoder)}readString(){return Q(this.restDecoder)}readParentInfo(){return w(this.restDecoder)===1}readTypeRef(){return w(this.restDecoder)}readLen(){return w(this.restDecoder)}readAny(){return ee(this.restDecoder)}readBuf(){return Gs(P(this.restDecoder))}readJSON(){return JSON.parse(Q(this.restDecoder))}readKey(){return Q(this.restDecoder)}},On=class{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=w(this.restDecoder),this.dsCurrVal}readDsLen(){let t=w(this.restDecoder)+1;return this.dsCurrVal+=t,t}},F=class extends On{constructor(t){super(t),this.keys=[],w(t),this.keyClockDecoder=new ne(P(t)),this.clientDecoder=new Dt(P(t)),this.leftClockDecoder=new ne(P(t)),this.rightClockDecoder=new ne(P(t)),this.infoDecoder=new Ce(P(t),At),this.stringDecoder=new ln(P(t)),this.parentInfoDecoder=new Ce(P(t),At),this.typeRefDecoder=new Dt(P(t)),this.lenDecoder=new Dt(P(t))}readLeftID(){return new ut(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ut(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 ee(this.restDecoder)}readBuf(){return P(this.restDecoder)}readJSON(){return ee(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}}},St=class{constructor(){this.restEncoder=nt()}toUint8Array(){return B(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){g(this.restEncoder,t)}writeDsLen(t){g(this.restEncoder,t)}},ct=class extends St{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){Zt(this.restEncoder,t)}writeString(t){Z(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){Kt(this.restEncoder,t)}writeBuf(t){j(this.restEncoder,t)}writeJSON(t){Z(this.restEncoder,JSON.stringify(t))}writeKey(t){Z(this.restEncoder,t)}},ue=class{constructor(){this.restEncoder=nt(),this.dsCurrVal=0}toUint8Array(){return B(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let n=t-this.dsCurrVal;this.dsCurrVal=t,g(this.restEncoder,n)}writeDsLen(t){t===0&&A(),g(this.restEncoder,t-1),this.dsCurrVal+=t}},J=class extends ue{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Wt,this.clientEncoder=new Ct,this.leftClockEncoder=new Wt,this.rightClockEncoder=new Wt,this.infoEncoder=new Ee(Zt),this.stringEncoder=new on,this.parentInfoEncoder=new Ee(Zt),this.typeRefEncoder=new Ct,this.lenEncoder=new Ct}toUint8Array(){let t=nt();return g(t,0),j(t,this.keyClockEncoder.toUint8Array()),j(t,this.clientEncoder.toUint8Array()),j(t,this.leftClockEncoder.toUint8Array()),j(t,this.rightClockEncoder.toUint8Array()),j(t,B(this.infoEncoder)),j(t,this.stringEncoder.toUint8Array()),j(t,B(this.parentInfoEncoder)),j(t,this.typeRefEncoder.toUint8Array()),j(t,this.lenEncoder.toUint8Array()),Qt(t,B(this.restEncoder)),B(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){Kt(this.restEncoder,t)}writeBuf(t){j(this.restEncoder,t)}writeJSON(t){Kt(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)}},qc=(e,t,n,r)=>{r=ht(r,t[0].id.clock);let s=X(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)=>{_(t,i)>s&&r.set(i,s)}),Ke(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])=>{qc(e,t.clients.get(s),s,i)})},Gc=(e,t)=>{let n=E(),r=w(e.restDecoder);for(let s=0;s<r;s++){let i=w(e.restDecoder),o=new Array(i),c=e.readClient(),l=w(e.restDecoder);n.set(c,{i:0,refs:o});for(let a=0;a<i;a++){let h=e.readInfo();switch(31&h){case 0:{let d=e.readLen();o[a]=new $(y(c,l),d),l+=d;break}case 10:{let d=w(e.restDecoder);o[a]=new N(y(c,l),d),l+=d;break}default:{let d=(h&192)===0,u=new S(y(c,l),null,(h&128)===128?e.readLeftID():null,null,(h&64)===64?e.readRightID():null,d?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,d&&(h&32)===32?e.readString():null,uo(e,h));o[a]=u,l+=u.length}}}}return n},Hc=(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 Ln,l=new Map,a=(f,p)=>{let x=l.get(f);(x==null||x>p)&&l.set(f,p)},h=o.refs[o.i++],d=new Map,u=()=>{for(let f of r){let p=f.id.client,x=n.get(p);x?(x.i--,c.clients.set(p,x.refs.slice(x.i)),n.delete(p),x.i=0,x.refs=[]):c.clients.set(p,[f]),s=s.filter(m=>m!==p)}r.length=0};for(;;){if(h.constructor!==N){let p=R(d,h.id.client,()=>_(t,h.id.client))-h.id.clock;if(p<0)r.push(h),a(h.id.client,h.id.clock-1),u();else{let x=h.getMissing(e,t);if(x!==null){r.push(h);let m=n.get(x)||{refs:[],i:0};if(m.refs.length===m.i)a(x,_(t,x)),u();else{h=m.refs[m.i++];continue}}else(p===0||p<h.length)&&(h.integrate(e,p),d.set(h.id.client,h.id.clock+h.length))}}if(r.length>0)h=r.pop();else if(o!==null&&o.i<o.refs.length)h=o.refs[o.i++];else{if(o=i(),o===null)break;h=o.refs[o.i++]}}if(c.clients.size>0){let f=new J;return Qr(f,c,new Map),g(f.restEncoder,0),{missing:l,update:f.toUint8Array()}}return null},zc=(e,t)=>Qr(e,t.doc.store,t.beforeState),ts=(e,t,n,r=new F(e))=>k(t,s=>{s.local=!1;let i=!1,o=s.doc,c=o.store,l=Gc(r,o),a=Hc(s,c,l),h=c.pendingStructs;if(h){for(let[u,f]of h.missing)if(f<_(c,u)){i=!0;break}if(a){for(let[u,f]of a.missing){let p=h.missing.get(u);(p==null||p>f)&&h.missing.set(u,f)}h.update=Ge([h.update,a.update])}}else c.pendingStructs=a;let d=di(r,s,c);if(c.pendingDs){let u=new F(D(c.pendingDs));w(u.restDecoder);let f=di(u,s,c);d&&f?c.pendingDs=Ge([d,f]):c.pendingDs=d||f}else c.pendingDs=d;if(i){let u=c.pendingStructs.update;c.pendingStructs=null,zn(s.doc,u)}},n,!1),Jc=(e,t,n)=>ts(e,t,n,new q(e)),zn=(e,t,n,r=F)=>{let s=D(t);ts(s,e,n,new r(s))},Yc=(e,t,n)=>zn(e,t,n,q),Xc=(e,t,n=new Map)=>{Qr(e,t.store,n),ot(e,Zr(t.store))},Di=(e,t=new Uint8Array([0]),n=new J)=>{let r=es(t);Xc(n,e,r);let s=[n.toUint8Array()];if(e.store.pendingDs&&s.push(e.store.pendingDs),e.store.pendingStructs&&s.push(is(e.store.pendingStructs.update,t)),s.length>1){if(n.constructor===ct)return Fi(s.map((i,o)=>o===0?i:Hi(i)));if(n.constructor===J)return Ge(s)}return s[0]},Kc=(e,t)=>Di(e,t,new ct),Ii=e=>{let t=new Map,n=w(e.restDecoder);for(let r=0;r<n;r++){let s=w(e.restDecoder),i=w(e.restDecoder);t.set(s,i)}return t},es=e=>Ii(new Lt(D(e))),ns=(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),Wc=(e,t)=>ns(e,Ke(t.store)),Zc=(e,t=new ue)=>(e instanceof Map?ns(t,e):Wc(t,e),t.toUint8Array()),Qc=e=>Zc(e,new St),jr=class{constructor(){this.l=[]}},ui=()=>new jr,fi=(e,t)=>e.l.push(t),pi=(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.")},Ti=(e,t,n)=>Te(e.l,[t,n]),ut=class{constructor(t,n){this.client=t,this.clock=n}},vt=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,y=(e,t)=>new ut(e,t),gi=(e,t)=>{g(e,t.client),g(e,t.clock)},mi=e=>y(w(e),w(e)),rs=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw A()},je=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},tl=e=>{let t=[],n=e._start;for(;n;)t.push(n),n=n.right;console.log("Children: ",t),console.log("Children content: ",t.filter(r=>!r.deleted).map(r=>r.content))},Pr=class{constructor(t,n=t.getMap("users")){let r=new Map;this.yusers=n,this.doc=t,this.clients=new Map,this.dss=r;let s=(i,o)=>{let c=i.get("ds"),l=i.get("ids"),a=h=>this.clients.set(h,o);c.observe(h=>{h.changes.added.forEach(d=>{d.content.getContent().forEach(u=>{u instanceof Uint8Array&&this.dss.set(o,Nt([this.dss.get(o)||Hn(),ft(new Lt(D(u)))]))})})}),this.dss.set(o,Nt(c.map(h=>ft(new Lt(D(h)))))),l.observe(h=>h.changes.added.forEach(d=>d.content.getContent().forEach(a))),l.forEach(a)};n.observe(i=>{i.keysChanged.forEach(o=>s(n.get(o),o))}),n.forEach(s)}setUserMapping(t,n,r,{filter:s=()=>!0}={}){let i=this.yusers,o=i.get(r);o||(o=new Mt,o.set("ids",new Bt),o.set("ds",new Bt),i.set(r,o)),o.get("ids").push([n]),i.observe(c=>{setTimeout(()=>{let l=i.get(r);if(l!==o){o=l,this.clients.forEach((d,u)=>{r===d&&o.get("ids").push([u])});let a=new St,h=this.dss.get(r);h&&(ot(a,h),o.get("ds").push([a.toUint8Array()]))}},0)}),t.on("afterTransaction",c=>{setTimeout(()=>{let l=o.get("ds"),a=c.deleteSet;if(c.local&&a.clients.size>0&&s(c,a)){let h=new St;ot(h,a),l.push([h.toUint8Array()])}})})}getUserByClientId(t){return this.clients.get(t)||null}getUserByDeletedId(t){for(let[n,r]of this.dss.entries())if(qt(r,t))return n;return null}},fe=class{constructor(t,n,r,s=0){this.type=t,this.tname=n,this.item=r,this.assoc=s}},el=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},nl=e=>{var t;return new fe(e.type==null?null:y(e.type.client,e.type.clock),(t=e.tname)!=null?t:null,e.item==null?null:y(e.item.client,e.item.clock),e.assoc==null?0:e.assoc)},Nn=class{constructor(t,n,r=0){this.type=t,this.index=n,this.assoc=r}},rl=(e,t,n=0)=>new Nn(e,t,n),Dn=(e,t,n)=>{let r=null,s=null;return e._item===null?s=rs(e):r=y(e._item.id.client,e._item.id.clock),new fe(r,s,t,n)},we=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return Dn(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return Dn(e,y(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return Dn(e,r.lastId,n);r=r.right}return Dn(e,null,n)},sl=(e,t)=>{let{type:n,tname:r,item:s,assoc:i}=t;if(s!==null)g(e,0),gi(e,s);else if(r!==null)Zt(e,1),Z(e,r);else if(n!==null)Zt(e,2),gi(e,n);else throw A();return Ue(e,i),e},il=e=>{let t=nt();return sl(t,e),B(t)},ol=e=>{let t=null,n=null,r=null;switch(w(e)){case 0:r=mi(e);break;case 1:n=Q(e);break;case 2:t=mi(e)}let s=lr(e)?Ae(e):0;return new fe(t,n,r,s)},cl=e=>ol(D(e)),ll=(e,t)=>{let n=Vt(e,t),r=t.clock-n.id.clock;return{item:n,diff:r}},ye=(e,t,n=!0)=>{let r=t.store,s=e.item,i=e.type,o=e.tname,c=e.assoc,l=null,a=0;if(s!==null){if(_(r,s.client)<=s.clock)return null;let h=n?Xr(r,s):ll(r,s),d=h.item;if(!(d instanceof S))return null;if(l=d.parent,l._item===null||!l._item.deleted){a=d.deleted||!d.countable?0:h.diff+(c>=0?0:1);let u=d.left;for(;u!==null;)!u.deleted&&u.countable&&(a+=u.length),u=u.left}}else{if(o!==null)l=t.get(o);else if(i!==null){if(_(r,i.client)<=i.clock)return null;let{item:h}=n?Xr(r,i):{item:Vt(r,i)};if(h instanceof S&&h.content instanceof K)l=h.content.type;else return null}else throw A();c>=0?a=l._length:a=0}return rl(l,a,e.assoc)},al=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&vt(e.item,t.item)&&vt(e.type,t.type)&&e.assoc===t.assoc,Pe=class{constructor(t,n){this.ds=t,this.sv=n}},hl=(e,t)=>{let n=e.ds.clients,r=t.ds.clients,s=e.sv,i=t.sv;if(s.size!==i.size||n.size!==r.size)return!1;for(let[o,c]of s.entries())if(i.get(o)!==c)return!1;for(let[o,c]of n.entries()){let l=r.get(o)||[];if(c.length!==l.length)return!1;for(let a=0;a<c.length;a++){let h=c[a],d=l[a];if(h.clock!==d.clock||h.len!==d.len)return!1}}return!0},vi=(e,t=new ue)=>(ot(t,e.ds),ns(t,e.sv),t.toUint8Array()),dl=e=>vi(e,new St),Vi=(e,t=new On(D(e)))=>new Pe(ft(t),Ii(t)),ul=e=>Vi(e,new Lt(D(e))),ss=(e,t)=>new Pe(e,t),fl=ss(Hn(),new Map),pl=e=>ss(Zr(e.store),Ke(e.store)),wt=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!qt(t.ds,e.id),qr=(e,t)=>{let n=R(e.meta,qr,et),r=e.doc.store;n.has(t)||(t.sv.forEach((s,i)=>{s<_(r,i)&&M(e,y(i,s))}),Ot(e,t.ds,s=>{}),n.add(t))},gl=(e,t,n=new kt)=>{if(e.gc)throw new Error("Garbage-collection must be disabled in `originDoc`!");let{sv:r,ds:s}=t,i=new J;return e.transact(o=>{let c=0;r.forEach(l=>{l>0&&c++}),g(i.restEncoder,c);for(let[l,a]of r){if(a===0)continue;a<_(e.store,l)&&M(o,y(l,a));let h=e.store.clients.get(l)||[],d=X(h,a-1);g(i.restEncoder,d+1),i.writeClient(l),g(i.restEncoder,0);for(let u=0;u<=d;u++)h[u].write(i,0)}ot(i,s)}),zn(n,i.toUint8Array(),"snapshot"),n},ml=(e,t,n=F)=>{let r=new n(D(t)),s=new lt(r,!1);for(let o=s.curr;o!==null;o=s.next())if((e.sv.get(o.id.client)||0)<o.id.clock+o.length)return!1;let i=Nt([e.ds,ft(r)]);return Ci(e.ds,i)},wl=(e,t)=>ml(e,t,q),Ln=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},Ke=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,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},Oi=(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 A()}n.push(t)},X=(e,t)=>{let n=0,r=e.length-1,s=e[r],i=s.id.clock;if(i===t)return r;let o=O(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=O((n+r)/2)}throw A()},yl=(e,t)=>{let n=e.clients.get(t.client);return n[X(n,t.clock)]},Vt=yl,Gr=(e,t,n)=>{let r=X(t,n),s=t[r];return s.id.clock<n&&s instanceof S?(t.splice(r+1,0,Gn(e,s,n-s.id.clock)),r+1):r},M=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[Gr(e,n,t.clock)]},Hr=(e,t,n)=>{let r=t.clients.get(n.client),s=X(r,n.clock),i=r[s];return n.clock!==i.id.clock+i.length-1&&i.constructor!==$&&r.splice(s+1,0,Gn(e,i,n.clock-i.id.clock+1)),i},xl=(e,t,n)=>{let r=e.clients.get(t.id.client);r[X(r,t.id.clock)]=n},Ni=(e,t,n,r,s)=>{if(r===0)return;let i=n+r,o=Gr(e,t,n),c;do c=t[o++],i<c.id.clock+c.length&&Gr(e,t,i),s(c);while(o<t.length&&t[o].id.clock<i)},Rn=class{constructor(t,n,r){this.doc=t,this.deleteSet=new bt,this.beforeState=Ke(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}},wi=(e,t)=>t.deleteSet.clients.size===0&&!ys(t.afterState,(n,r)=>t.beforeState.get(r)!==n)?!1:(Wr(t.deleteSet),zc(e,t),ot(e,t.deleteSet),!0),yi=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&R(e.changed,t,et).add(n)},vn=(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 S&&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},Li=(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 a=X(i,c.clock),h=i[a];a<i.length&&h.id.clock<l;h=i[++a]){let d=i[a];if(c.clock+c.len<=d.id.clock)break;d instanceof S&&d.deleted&&!d.keep&&n(d)&&d.gc(t,!1)}}}},Ri=(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=nn(s.length-1,1+X(s,o.clock+o.len-1));for(let l=c,a=s[l];l>0&&a.id.clock>=o.clock;a=s[l])l-=1+vn(s,l)}})},bl=(e,t,n)=>{Li(e,t,n),Ri(e,t)},Bi=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,s=r.store,i=n.deleteSet,o=n._mergeStructs;try{Wr(i),n.afterState=Ke(n.doc.store),r.emit("beforeObserverCalls",[n,r]);let c=[];n.changed.forEach((l,a)=>c.push(()=>{(a._item===null||!a._item.deleted)&&a._callObserver(n,l)})),c.push(()=>{n.changedParentTypes.forEach((l,a)=>{a._dEH.l.length>0&&(a._item===null||!a._item.deleted)&&(l=l.filter(h=>h.target._item===null||!h.target._item.deleted),l.forEach(h=>{h.currentTarget=a,h._path=null}),l.sort((h,d)=>h.path.length-d.path.length),c.push(()=>{Ti(a._dEH,l,n)}))}),c.push(()=>r.emit("afterTransaction",[n,r])),c.push(()=>{n._needFormattingCleanup&&Pl(n)})}),Te(c,[])}finally{r.gc&&Li(i,s,r.gcFilter),Ri(i,s),n.afterState.forEach((h,d)=>{let u=n.beforeState.get(d)||0;if(u!==h){let f=s.clients.get(d),p=ht(X(f,u),1);for(let x=f.length-1;x>=p;)x-=1+vn(f,x)}});for(let h=o.length-1;h>=0;h--){let{client:d,clock:u}=o[h].id,f=s.clients.get(d),p=X(f,u);p+1<f.length&&vn(f,p+1)>1||p>0&&vn(f,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(Cn(he,Re,"[yjs] ",Be,Me,"Changed the client-id because another client seems to be using it."),r.clientID=Ai()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){let h=new ct;wi(h,n)&&r.emit("update",[h.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){let h=new J;wi(h,n)&&r.emit("updateV2",[h.toUint8Array(),n.origin,r,n])}let{subdocsAdded:c,subdocsLoaded:l,subdocsRemoved:a}=n;(c.size>0||a.size>0||l.size>0)&&(c.forEach(h=>{h.clientID=r.clientID,h.collectionid==null&&(h.collectionid=r.collectionid),r.subdocs.add(h)}),a.forEach(h=>r.subdocs.delete(h)),r.emit("subdocs",[{loaded:l,added:c,removed:a},r,n]),a.forEach(h=>h.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,e])):Bi(e,t+1)}}},k=(e,t,n=null,r=!0)=>{let s=e._transactionCleanups,i=!1,o=null;e._transaction===null&&(i=!0,e._transaction=new Rn(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&&Bi(s,0)}}return o},zr=class{constructor(t,n){this.insertions=n,this.deletions=t,this.meta=new Map}},xi=(e,t,n)=>{Ot(e,n.deletions,r=>{r instanceof S&&t.scope.some(s=>s===e.doc||je(s,r))&&hs(r,!1)})},bi=(e,t,n)=>{let r=null,s=e.doc,i=e.scope;k(s,c=>{for(;t.length>0&&e.currStackItem===null;){let l=s.store,a=t.pop(),h=new Set,d=[],u=!1;Ot(c,a.insertions,f=>{if(f instanceof S){if(f.redone!==null){let{item:p,diff:x}=Xr(l,f.id);x>0&&(p=M(c,y(p.id.client,p.id.clock+x))),f=p}!f.deleted&&i.some(p=>p===c.doc||je(p,f))&&d.push(f)}}),Ot(c,a.deletions,f=>{f instanceof S&&i.some(p=>p===c.doc||je(p,f))&&!qt(a.insertions,f.id)&&h.add(f)}),h.forEach(f=>{u=ho(c,f,h,a.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?a:null}c.changed.forEach((l,a)=>{l.has(null)&&a._searchMarker&&(a._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},Jr=class extends Gt{constructor(t,{captureTimeout:n=500,captureTransaction:r=l=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:c=at(t)?t[0].doc:t instanceof kt?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(m=>l.changedParentTypes.has(m)||m===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;let a=this.undoing,h=this.redoing,d=a?this.redoStack:this.undoStack;a?this.stopCapturing():h||this.clear(!1,!0);let u=new bt;l.afterState.forEach((m,b)=>{let G=l.beforeState.get(b)||0,ps=m-G;ps>0&&Fe(u,b,G,ps)});let f=dt(),p=!1;if(this.lastChange>0&&f-this.lastChange<this.captureTimeout&&d.length>0&&!a&&!h){let m=d[d.length-1];m.deletions=Nt([m.deletions,l.deleteSet]),m.insertions=Nt([m.insertions,u])}else d.push(new zr(l.deleteSet,u)),p=!0;!a&&!h&&(this.lastChange=f),Ot(l,l.deleteSet,m=>{m instanceof S&&this.scope.some(b=>b===l.doc||je(b,m))&&hs(m,!0)});let x=[{stackItem:d[d.length-1],origin:l.origin,type:a?"redo":"undo",changedParentTypes:l.changedParentTypes},this];p?this.emit("stack-item-added",x):this.emit("stack-item-updated",x)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(t){let n=new Set(this.scope);t=at(t)?t:[t],t.forEach(r=>{n.has(r)||(n.add(r),(r instanceof U?r.doc!==this.doc:r!==this.doc)&&Mr("[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=>xi(r,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>xi(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=bi(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=bi(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*kl(e){let t=w(e.restDecoder);for(let n=0;n<t;n++){let r=w(e.restDecoder),s=e.readClient(),i=w(e.restDecoder);for(let o=0;o<r;o++){let c=e.readInfo();if(c===10){let l=w(e.restDecoder);yield new N(y(s,i),l),i+=l}else if((31&c)!==0){let l=(c&192)===0,a=new S(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,uo(e,c));yield a,i+=a.length}else{let l=e.readLen();yield new $(y(s,i),l),i+=l}}}}var lt=class{constructor(t,n){this.gen=kl(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===N);return this.curr}},Sl=e=>Mi(e,q),Mi=(e,t=F)=>{let n=[],r=new t(D(e)),s=new lt(r,!1);for(let o=s.curr;o!==null;o=s.next())n.push(o);Cn("Structs: ",n);let i=ft(r);Cn("DeleteSet: ",i)},_l=e=>$i(e,q),$i=(e,t=F)=>{let n=[],r=new t(D(e)),s=new lt(r,!1);for(let i=s.curr;i!==null;i=s.next())n.push(i);return{structs:n,ds:ft(r)}},qe=class{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}},Fi=e=>Ge(e,q,ct),ji=(e,t=ue,n=F)=>{let r=new t,s=new lt(new n(D(e)),!1),i=s.curr;if(i!==null){let o=0,c=i.id.client,l=i.id.clock!==0,a=l?0:i.id.clock+i.length;for(;i!==null;i=s.next())c!==i.id.client&&(a!==0&&(o++,g(r.restEncoder,c),g(r.restEncoder,a)),c=i.id.client,a=0,l=i.id.clock!==0),i.constructor===N&&(l=!0),l||(a=i.id.clock+i.length);a!==0&&(o++,g(r.restEncoder,c),g(r.restEncoder,a));let h=nt();return g(h,o),As(h,r.restEncoder),r.restEncoder=h,r.toUint8Array()}else return g(r.restEncoder,0),r.toUint8Array()},El=e=>ji(e,St,q),Pi=(e,t=F)=>{let n=new Map,r=new Map,s=new lt(new t(D(e)),!1),i=s.curr;if(i!==null){let o=i.id.client,c=i.id.clock;for(n.set(o,c);i!==null;i=s.next())o!==i.id.client&&(r.set(o,c),n.set(i.id.client,i.id.clock),o=i.id.client),c=i.id.clock+i.length;r.set(o,c)}return{from:n,to:r}},Ul=e=>Pi(e,q),Cl=(e,t)=>{if(e.constructor===$){let{client:n,clock:r}=e.id;return new $(y(n,r+t),e.length-t)}else if(e.constructor===N){let{client:n,clock:r}=e.id;return new N(y(n,r+t),e.length-t)}else{let n=e,{client:r,clock:s}=n.id;return new S(y(r,s+t),null,y(r,s+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},Ge=(e,t=F,n=J)=>{if(e.length===1)return e[0];let r=e.map(h=>new t(D(h))),s=r.map(h=>new lt(h,!0)),i=null,o=new n,c=new qe(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===N?1:-1:p}else return f.curr.id.client-u.curr.id.client}),s.length!==0;){let h=s[0],d=h.curr.id.client;if(i!==null){let u=h.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=h.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)yt(c,i.struct,i.offset),i={struct:u,offset:0},h.next();else if(i.struct.id.clock+i.struct.length<u.id.clock)if(i.struct.constructor===N)i.struct.length=u.id.clock+u.length-i.struct.id.clock;else{yt(c,i.struct,i.offset);let p=u.id.clock-i.struct.id.clock-i.struct.length;i={struct:new N(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===N?i.struct.length-=p:u=Cl(u,p)),i.struct.mergeWith(u)||(yt(c,i.struct,i.offset),i={struct:u,offset:0},h.next())}}else i={struct:h.curr,offset:0},h.next();for(let u=h.curr;u!==null&&u.id.client===d&&u.id.clock===i.struct.id.clock+i.struct.length&&u.constructor!==N;u=h.next())yt(c,i.struct,i.offset),i={struct:u,offset:0}}i!==null&&(yt(c,i.struct,i.offset),i=null),os(c);let l=r.map(h=>ft(h)),a=Nt(l);return ot(o,a),o.toUint8Array()},is=(e,t,n=F,r=J)=>{let s=es(t),i=new r,o=new qe(i),c=new n(D(e)),l=new lt(c,!1);for(;l.curr;){let h=l.curr,d=h.id.client,u=s.get(d)||0;if(l.curr.constructor===N){l.next();continue}if(h.id.clock+h.length>u)for(yt(o,h,ht(u-h.id.clock,0)),l.next();l.curr&&l.curr.id.client===d;)yt(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()}os(o);let a=ft(c);return ot(i,a),i.toUint8Array()},Al=(e,t)=>is(e,t,q,ct),qi=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:B(e.encoder.restEncoder)}),e.encoder.restEncoder=nt(),e.written=0)},yt=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&qi(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++},os=e=>{qi(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),Qt(t,r.restEncoder)}},Jn=(e,t,n,r)=>{let s=new n(D(e)),i=new lt(s,!1),o=new r,c=new qe(o);for(let a=i.curr;a!==null;a=i.next())yt(c,t(a),0);os(c);let l=ft(s);return ot(o,l),o.toUint8Array()},Gi=({formatting:e=!0,subdocs:t=!0,yxml:n=!0}={})=>{let r=0,s=E(),i=E(),o=E(),c=E();return c.set(null,null),l=>{switch(l.constructor){case $:case N:return l;case S:{let a=l,h=a.content;switch(h.constructor){case me:break;case K:{if(n){let d=h.type;d instanceof Ft&&(d.nodeName=R(i,d.nodeName,()=>"node-"+r)),d instanceof Ye&&(d.hookName=R(i,d.hookName,()=>"hook-"+r))}break}case _t:{let d=h;d.arr=d.arr.map(()=>r);break}case jt:{let d=h;d.content=new Uint8Array([r]);break}case Pt:{let d=h;t&&(d.opts={},d.doc.guid=r+"");break}case pt:{let d=h;d.embed={};break}case C:{let d=h;e&&(d.key=R(o,d.key,()=>r+""),d.value=R(c,d.value,()=>({i:r})));break}case Xe:{let d=h;d.arr=d.arr.map(()=>r);break}case tt:{let d=h;d.str=sn(r%10+"",d.str.length);break}default:A()}return a.parentSub&&(a.parentSub=R(s,a.parentSub,()=>r+"")),r++,l}default:A()}}},Dl=(e,t)=>Jn(e,Gi(t),q,ct),Il=(e,t)=>Jn(e,Gi(t),F,J),Tl=e=>Jn(e,xr,q,J),Hi=e=>Jn(e,xr,F,ct),ki="You must not compute changes after the event-handler fired.",Rt=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=vl(this.currentTarget,this.target))}deletes(t){return qt(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw H(ki);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=Qe(l.content.getContent());else return;else l!==null&&this.deletes(l)?(o="update",c=Qe(l.content.getContent())):(o="add",c=void 0)}else if(this.deletes(i))o="delete",c=Qe(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(ki);let n=this.target,r=et(),s=et(),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 a=n._start;a!==null;a=a.right)a.deleted?this.deletes(a)&&!this.adds(a)&&((c===null||c.delete===void 0)&&(l(),c={delete:0}),c.delete+=a.length,s.add(a)):this.adds(a)?((c===null||c.insert===void 0)&&(l(),c={insert:[]}),c.insert=c.insert.concat(a.content.getContent()),r.add(a)):((c===null||c.retain===void 0)&&(l(),c={retain:0}),c.retain+=a.length);c!==null&&c.retain===void 0&&l()}this._changes=t}return t}},vl=(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},L=()=>{Mr("Invalid access: Add Yjs type to a document before reading data.")},zi=80,cs=0,Yr=class{constructor(t,n){t.marker=!0,this.p=t,this.index=n,this.timestamp=cs++}},Vl=e=>{e.timestamp=cs++},Ji=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=cs++},Ol=(e,t,n)=>{if(e.length>=zi){let r=e.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return Ji(r,t,n),r}else{let r=new Yr(t,n);return e.push(r),r}},Yn=(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)=>Et(t-i.index)<Et(t-o.index)?i:o),r=e._start,s=0;for(n!==null&&(r=n.p,s=n.index,Vl(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&&Et(n.index-s)<r.parent.length/zi?(Ji(n,r,s),n):Ol(e._searchMarker,r,s)},He=(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=ht(t,s.index+n))}},Nl=e=>{var r;(r=e.doc)!=null||L();let t=e._start,n=[];for(;t;)n.push(t),t=t.right;return n},Xn=(e,t,n)=>{let r=e,s=t.changedParentTypes;for(;R(s,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;Ti(r._eH,n,t)},U=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=ui(),this._dEH=ui(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,n){this.doc=t,this._item=n}_copy(){throw z()}clone(){throw z()}_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){fi(this._eH,t)}observeDeep(t){fi(this._dEH,t)}unobserve(t){pi(this._eH,t)}unobserveDeep(t){pi(this._dEH,t)}toJSON(){}},Yi=(e,t,n)=>{var o;(o=e.doc)!=null||L(),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 c=i.content.getContent();if(c.length<=t)t-=c.length;else{for(let l=t;l<c.length&&r>0;l++)s.push(c[l]),r--;t=0}}i=i.right}return s},Xi=e=>{var r;(r=e.doc)!=null||L();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let s=n.content.getContent();for(let i=0;i<s.length;i++)t.push(s[i])}n=n.right}return t},Ll=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&wt(r,t)){let s=r.content.getContent();for(let i=0;i<s.length;i++)n.push(s[i])}r=r.right}return n},ze=(e,t)=>{var s;let n=0,r=e._start;for((s=e.doc)!=null||L();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let o=0;o<i.length;o++)t(i[o],n++,e)}r=r.right}},Ki=(e,t)=>{let n=[];return ze(e,(r,s)=>{n.push(t(r,s,e))}),n},Rl=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}}}},Wi=(e,t)=>{var s;(s=e.doc)!=null||L();let n=Yn(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}},Bn=(e,t,n,r)=>{let s=n,i=e.doc,o=i.clientID,c=i.store,l=n===null?t._start:n.right,a=[],h=()=>{a.length>0&&(s=new S(y(o,_(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new _t(a)),s.integrate(e,0),a=[])};r.forEach(d=>{if(d===null)a.push(d);else switch(d.constructor){case Number:case Object:case Boolean:case Array:case String:a.push(d);break;default:switch(h(),d.constructor){case Uint8Array:case ArrayBuffer:s=new S(y(o,_(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new jt(new Uint8Array(d))),s.integrate(e,0);break;case kt:s=new S(y(o,_(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new Pt(d)),s.integrate(e,0);break;default:if(d instanceof U)s=new S(y(o,_(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new K(d)),s.integrate(e,0);else throw new Error("Unexpected content type in insert operation")}}}),h()},Zi=()=>H("Length exceeded!"),Qi=(e,t,n,r)=>{if(n>t._length)throw Zi();if(n===0)return t._searchMarker&&He(t._searchMarker,n,r.length),Bn(e,t,null,r);let s=n,i=Yn(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&&M(e,y(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&He(t._searchMarker,s,r.length),Bn(e,t,o,r)},Bl=(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 Bn(e,t,s,n)},to=(e,t,n,r)=>{if(r===0)return;let s=n,i=r,o=Yn(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&&M(e,y(c.id.client,c.id.clock+n)),n-=c.length);for(;r>0&&c!==null;)c.deleted||(r<c.length&&M(e,y(c.id.client,c.id.clock+r)),c.delete(e),r-=c.length),c=c.right;if(r>0)throw Zi();t._searchMarker&&He(t._searchMarker,s,-i+r)},Mn=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},ls=(e,t,n,r)=>{let s=t._map.get(n)||null,i=e.doc,o=i.clientID,c;if(r==null)c=new _t([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new _t([r]);break;case Uint8Array:c=new jt(r);break;case kt:c=new Pt(r);break;default:if(r instanceof U)c=new K(r);else throw new Error("Unexpected content type")}new S(y(o,_(i.store,o)),s,s&&s.lastId,null,null,t,n,c).integrate(e,0)},as=(e,t)=>{var r;(r=e.doc)!=null||L();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},eo=e=>{var n;let t={};return(n=e.doc)!=null||L(),e._map.forEach((r,s)=>{r.deleted||(t[s]=r.content.getContent()[r.length-1])}),t},no=(e,t)=>{var r;(r=e.doc)!=null||L();let n=e._map.get(t);return n!==void 0&&!n.deleted},Ml=(e,t,n)=>{let r=e._map.get(t)||null;for(;r!==null&&(!n.sv.has(r.id.client)||r.id.clock>=(n.sv.get(r.id.client)||0));)r=r.left;return r!==null&&wt(r,n)?r.content.getContent()[r.length-1]:void 0},ro=(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&&wt(i,t)&&(n[s]=i.content.getContent()[i.length-1])}),n},In=e=>{var t;return(t=e.doc)!=null||L(),li(e._map.entries(),n=>!n[1].deleted)},$n=class extends Rt{},Bt=class e extends U{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 U?n.clone():n)),t}get length(){var t;return(t=this.doc)!=null||L(),this._length}_callObserver(t,n){super._callObserver(t,n),Xn(this,t,new $n(this,t))}insert(t,n){this.doc!==null?k(this.doc,r=>{Qi(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}push(t){this.doc!==null?k(this.doc,n=>{Bl(n,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,n=1){this.doc!==null?k(this.doc,r=>{to(r,this,t,n)}):this._prelimContent.splice(t,n)}get(t){return Wi(this,t)}toArray(){return Xi(this)}slice(t=0,n=this.length){return Yi(this,t,n)}toJSON(){return this.map(t=>t instanceof U?t.toJSON():t)}map(t){return Ki(this,t)}forEach(t){ze(this,t)}[Symbol.iterator](){return Rl(this)}_write(t){t.writeTypeRef(ia)}},$l=e=>new Bt,Fn=class extends Rt{constructor(t,n,r){super(t,n),this.keysChanged=r}},Mt=class e extends U{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 U?n.clone():n)}),t}_callObserver(t,n){Xn(this,t,new Fn(this,t,n))}toJSON(){var n;(n=this.doc)!=null||L();let t={};return this._map.forEach((r,s)=>{if(!r.deleted){let i=r.content.getContent()[r.length-1];t[s]=i instanceof U?i.toJSON():i}}),t}get size(){return[...In(this)].length}keys(){return An(In(this),t=>t[0])}values(){return An(In(this),t=>t[1].content.getContent()[t[1].length-1])}entries(){return An(In(this),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){var n;(n=this.doc)!=null||L(),this._map.forEach((r,s)=>{r.deleted||t(r.content.getContent()[r.length-1],s,this)})}[Symbol.iterator](){return this.entries()}delete(t){this.doc!==null?k(this.doc,n=>{Mn(n,this,t)}):this._prelimContent.delete(t)}set(t,n){return this.doc!==null?k(this.doc,r=>{ls(r,this,t,n)}):this._prelimContent.set(t,n),n}get(t){return as(this,t)}has(t){return no(this,t)}clear(){this.doc!==null?k(this.doc,t=>{this.forEach(function(n,r,s){Mn(t,s,r)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(oa)}},Fl=e=>new Mt,xt=(e,t)=>e===t||typeof e=="object"&&typeof t=="object"&&e&&t&&mr(e,t),Je=class{constructor(t,n,r,s){this.left=t,this.right=n,this.index=r,this.currentAttributes=s}forward(){this.right===null&&A(),this.right.content.constructor===C?this.right.deleted||xe(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}},Si=(e,t,n)=>{for(;t.right!==null&&n>0;)t.right.content.constructor===C?t.right.deleted||xe(t.currentAttributes,t.right.content):t.right.deleted||(n<t.right.length&&M(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},Tn=(e,t,n,r)=>{let s=new Map,i=r?Yn(t,n):null;if(i){let o=new Je(i.p.left,i.p,i.index,s);return Si(e,o,n-i.index)}else{let o=new Je(null,t._start,0,s);return Si(e,o,n)}},so=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===C&&xt(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,a=n.right,h=new S(y(i,_(s.store,i)),l,l&&l.lastId,a,a&&a.id,t,null,new C(c,o));h.integrate(e,0),n.right=h,n.forward()})},xe=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},io=(e,t)=>{var n;for(;e.right!==null;){if(!(e.right.deleted||e.right.content.constructor===C&&xt((n=t[e.right.content.key])!=null?n:null,e.right.content.value)))break;e.forward()}},oo=(e,t,n,r)=>{var c;let s=e.doc,i=s.clientID,o=new Map;for(let l in r){let a=r[l],h=(c=n.currentAttributes.get(l))!=null?c:null;if(!xt(h,a)){o.set(l,h);let{left:d,right:u}=n;n.right=new S(y(i,_(s.store,i)),d,d&&d.lastId,u,u&&u.id,t,null,new C(l,a)),n.right.integrate(e,0),n.forward()}}return o},$r=(e,t,n,r,s)=>{n.currentAttributes.forEach((u,f)=>{s[f]===void 0&&(s[f]=null)});let i=e.doc,o=i.clientID;io(n,s);let c=oo(e,t,n,s),l=r.constructor===String?new tt(r):r instanceof U?new K(r):new pt(r),{left:a,right:h,index:d}=n;t._searchMarker&&He(t._searchMarker,n.index,l.getLength()),h=new S(y(o,_(i.store,o)),a,a&&a.lastId,h,h&&h.id,t,null,l),h.integrate(e,0),n.right=h,n.index=d,n.forward(),so(e,t,n,c)},_i=(e,t,n,r,s)=>{let i=e.doc,o=i.clientID;io(n,s);let c=oo(e,t,n,s);t:for(;n.right!==null&&(r>0||c.size>0&&(n.right.deleted||n.right.content.constructor===C));){if(!n.right.deleted)switch(n.right.content.constructor){case C:{let{key:l,value:a}=n.right.content,h=s[l];if(h!==void 0){if(xt(h,a))c.delete(l);else{if(r===0)break t;c.set(l,a)}n.right.delete(e)}else n.currentAttributes.set(l,a);break}default:r<n.right.length&&M(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+=`
|
|
11
|
+
`;n.right=new S(y(o,_(i.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new tt(l)),n.right.integrate(e,0),n.forward()}so(e,t,n,c)},co=(e,t,n,r,s)=>{var a,h;let i=t,o=E();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===C){let d=i.content;o.set(d.key,d)}i=i.right}let c=0,l=!1;for(;t!==i;){if(n===t&&(l=!0),!t.deleted){let d=t.content;if(d.constructor===C){let{key:u,value:f}=d,p=(a=r.get(u))!=null?a:null;(o.get(u)!==d||p===f)&&(t.delete(e),c++,!l&&((h=s.get(u))!=null?h:null)===f&&p!==f&&(p===null?s.delete(u):s.set(u,p))),!l&&!t.deleted&&xe(s,d)}}t=t.right}return c},jl=(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===C){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},lo=e=>{let t=0;return k(e.doc,n=>{let r=e._start,s=e._start,i=E(),o=Ze(i);for(;s;)s.deleted===!1&&(s.content.constructor===C?xe(o,s.content):(t+=co(n,r,s,i,o),i=Ze(o),r=s)),s=s.right}),t},Pl=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&&Ni(e,n.store.clients.get(r),i,s,o=>{!o.deleted&&o.content.constructor===C&&o.constructor!==$&&t.add(o.parent)})}k(n,r=>{Ot(e,e.deleteSet,s=>{if(s instanceof $||!s.parent._hasFormatting||t.has(s.parent))return;let i=s.parent;s.content.constructor===C?t.add(i):jl(r,s)});for(let s of t)lo(s)})},Ei=(e,t,n)=>{let r=n,s=Ze(t.currentAttributes),i=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case K:case pt:case tt:n<t.right.length&&M(e,y(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}i&&co(e,i,t.right,s,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&He(o._searchMarker,t.index,-r+n),t},jn=class extends Rt{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=[];k(t,r=>{var f,p,x;let s=new Map,i=new Map,o=this.target._start,c=null,l={},a="",h=0,d=0,u=()=>{if(c!==null){let m=null;switch(c){case"delete":d>0&&(m={delete:d}),d=0;break;case"insert":(typeof a=="object"||a.length>0)&&(m={insert:a},s.size>0&&(m.attributes={},s.forEach((b,G)=>{b!==null&&(m.attributes[G]=b)}))),a="";break;case"retain":h>0&&(m={retain:h},$s(l)||(m.attributes=Bs({},l))),h=0;break}m&&n.push(m),c=null}};for(;o!==null;){switch(o.content.constructor){case K:case pt:this.adds(o)?this.deletes(o)||(u(),c="insert",a=o.content.getContent()[0],u()):this.deletes(o)?(c!=="delete"&&(u(),c="delete"),d+=1):o.deleted||(c!=="retain"&&(u(),c="retain"),h+=1);break;case tt:this.adds(o)?this.deletes(o)||(c!=="insert"&&(u(),c="insert"),a+=o.content.str):this.deletes(o)?(c!=="delete"&&(u(),c="delete"),d+=o.length):o.deleted||(c!=="retain"&&(u(),c="retain"),h+=o.length);break;case C:{let{key:m,value:b}=o.content;if(this.adds(o)){if(!this.deletes(o)){let G=(f=s.get(m))!=null?f:null;xt(G,b)?b!==null&&o.delete(r):(c==="retain"&&u(),xt(b,(p=i.get(m))!=null?p:null)?delete l[m]:l[m]=b)}}else if(this.deletes(o)){i.set(m,b);let G=(x=s.get(m))!=null?x:null;xt(G,b)||(c==="retain"&&u(),l[m]=G)}else if(!o.deleted){i.set(m,b);let G=l[m];G!==void 0&&(xt(G,b)?G!==null&&o.delete(r):(c==="retain"&&u(),b===null?delete l[m]:l[m]=b))}o.deleted||(c==="insert"&&u(),xe(s,o.content));break}}o=o.right}for(u();n.length>0;){let m=n[n.length-1];if(m.retain!==void 0&&m.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}},pe=class e extends U{constructor(t){super(),this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){var t;return(t=this.doc)!=null||L(),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 jn(this,t,n);Xn(this,t,r),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){var r;(r=this.doc)!=null||L();let t="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===tt&&(t+=n.content.str),n=n.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:n=!0}={}){this.doc!==null?k(this.doc,r=>{let s=new Je(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)===`
|
|
12
|
+
`?o.insert.slice(0,-1):o.insert;(typeof c!="string"||c.length>0)&&$r(r,this,s,c,o.attributes||{})}else o.retain!==void 0?_i(r,this,s,o.retain,o.attributes||{}):o.delete!==void 0&&Ei(r,s,o.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,n,r){var d;(d=this.doc)!=null||L();let s=[],i=new Map,o=this.doc,c="",l=this._start;function a(){if(c.length>0){let u={},f=!1;i.forEach((x,m)=>{f=!0,u[m]=x});let p={insert:c};f&&(p.attributes=u),s.push(p),c=""}}let h=()=>{for(;l!==null;){if(wt(l,t)||n!==void 0&&wt(l,n))switch(l.content.constructor){case tt:{let u=i.get("ychange");t!==void 0&&!wt(l,t)?(u===void 0||u.user!==l.id.client||u.type!=="removed")&&(a(),i.set("ychange",r?r("removed",l.id):{type:"removed"})):n!==void 0&&!wt(l,n)?(u===void 0||u.user!==l.id.client||u.type!=="added")&&(a(),i.set("ychange",r?r("added",l.id):{type:"added"})):u!==void 0&&(a(),i.delete("ychange")),c+=l.content.str;break}case K:case pt:{a();let u={insert:l.content.getContent()[0]};if(i.size>0){let f={};u.attributes=f,i.forEach((p,x)=>{f[x]=p})}s.push(u);break}case C:wt(l,t)&&(a(),xe(i,l.content));break}l=l.right}a()};return t||n?k(o,u=>{t&&qr(u,t),n&&qr(u,n),h()},"cleanup"):h(),s}insert(t,n,r){if(n.length<=0)return;let s=this.doc;s!==null?k(s,i=>{let o=Tn(i,this,t,!r);r||(r={},o.currentAttributes.forEach((c,l)=>{r[l]=c})),$r(i,this,o,n,r)}):this._pending.push(()=>this.insert(t,n,r))}insertEmbed(t,n,r){let s=this.doc;s!==null?k(s,i=>{let o=Tn(i,this,t,!r);$r(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?k(r,s=>{Ei(s,Tn(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?k(s,i=>{let o=Tn(i,this,t,!1);o.right!==null&&_i(i,this,o,n,r)}):this._pending.push(()=>this.format(t,n,r))}removeAttribute(t){this.doc!==null?k(this.doc,n=>{Mn(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?k(this.doc,r=>{ls(r,this,t,n)}):this._pending.push(()=>this.setAttribute(t,n))}getAttribute(t){return as(this,t)}getAttributes(){return eo(this)}_write(t){t.writeTypeRef(ca)}},ql=e=>new pe,$e=class{constructor(t,n=()=>!0){var r;this._filter=n,this._root=t,this._currentNode=t._start,this._firstCall=!0,(r=t.doc)!=null||L()}[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===Ft||n.constructor===$t)&&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})}},$t=class e extends U{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 U?n.clone():n)),t}get length(){var t;return(t=this.doc)!=null||L(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new $e(this,t)}querySelector(t){t=t.toUpperCase();let r=new $e(this,s=>s.nodeName&&s.nodeName.toUpperCase()===t).next();return r.done?null:r.value}querySelectorAll(t){return t=t.toUpperCase(),W(new $e(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){Xn(this,t,new Pn(this,n,t))}toString(){return Ki(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),ze(this,i=>{s.insertBefore(i.toDOM(t,n,r),null)}),s}insert(t,n){this.doc!==null?k(this.doc,r=>{Qi(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}insertAfter(t,n){if(this.doc!==null)k(this.doc,r=>{let s=t&&t instanceof U?t._item:t;Bn(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?k(this.doc,r=>{to(r,this,t,n)}):this._prelimContent.splice(t,n)}toArray(){return Xi(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return Wi(this,t)}slice(t=0,n=this.length){return Yi(this,t,n)}forEach(t){ze(this,t)}_write(t){t.writeTypeRef(aa)}},Gl=e=>new $t,Ft=class e extends $t{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 Ms(n,(r,s)=>{t.setAttribute(s,r)}),t.insert(0,this.toArray().map(r=>r instanceof U?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?k(this.doc,n=>{Mn(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){this.doc!==null?k(this.doc,r=>{ls(r,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return as(this,t)}hasAttribute(t){return no(this,t)}getAttributes(t){return t?ro(this,t):eo(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 ze(this,o=>{s.appendChild(o.toDOM(t,n,r))}),r!==void 0&&r._createAssociation(s,this),s}_write(t){t.writeTypeRef(la),t.writeKey(this.nodeName)}},Hl=e=>new Ft(e.readKey()),Pn=class extends Rt{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)})}},Ye=class e extends Mt{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(ha),t.writeKey(this.hookName)}},zl=e=>new Ye(e.readKey()),qn=class e extends pe{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(da)}},Jl=e=>new qn,ge=class{constructor(t,n){this.id=t,this.length=n}get deleted(){throw z()}mergeWith(t){return!1}write(t,n,r){throw z()}integrate(t,n){throw z()}},Yl=0,$=class extends ge{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),Oi(t.doc.store,this)}write(t,n){t.writeInfo(Yl),t.writeLen(this.length-n)}getMissing(t,n){return null}},jt=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 z()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeBuf(this.content)}getRef(){return 3}},Xl=e=>new jt(e.readBuf()),me=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){Fe(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}},Kl=e=>new me(e.readLen()),ao=(e,t)=>new kt({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),Pt=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(ao(this.doc.guid,this.opts))}splice(t){throw z()}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}},Wl=e=>new Pt(ao(e.readString(),e.readAny())),pt=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 z()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}},Zl=e=>new pt(e.readJSON()),C=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 z()}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}},Ql=e=>new C(e.readKey(),e.readJSON()),Xe=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}},ta=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 Xe(n)},ea=Ve("node_env")==="development",_t=class e{constructor(t){this.arr=t,ea&&wr(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}},na=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new _t(n)},tt=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}},ra=e=>new tt(e.readString()),sa=[$l,Fl,ql,Hl,Gl,zl,Jl],ia=0,oa=1,ca=2,la=3,aa=4,ha=5,da=6,K=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 z()}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}},ua=e=>new K(sa[e.readTypeRef()](e)),Xr=(e,t)=>{let n=t,r=0,s;do r>0&&(n=y(n.client,n.clock+r)),s=Vt(e,n),r=n.clock-s.id.clock,n=s.redone;while(n!==null&&s instanceof S);return{item:s,diff:r}},hs=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Gn=(e,t,n)=>{let{client:r,clock:s}=t.id,i=new S(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},Ui=(e,t)=>ke(e,n=>qt(n.deletions,t)),ho=(e,t,n,r,s,i)=>{let o=e.doc,c=o.store,l=o.clientID,a=t.redone;if(a!==null)return M(e,a);let h=t.parent._item,d=null,u;if(h!==null&&h.deleted===!0){if(h.redone===null&&(!n.has(h)||ho(e,h,n,r,s,i)===null))return null;for(;h.redone!==null;)h=M(e,h.redone)}let f=h===null?t.parent:h.content.type;if(t.parentSub===null){for(d=t.left,u=t;d!==null;){let b=d;for(;b!==null&&b.parent._item!==h;)b=b.redone===null?null:M(e,b.redone);if(b!==null&&b.parent._item===h){d=b;break}d=d.left}for(;u!==null;){let b=u;for(;b!==null&&b.parent._item!==h;)b=b.redone===null?null:M(e,b.redone);if(b!==null&&b.parent._item===h){u=b;break}u=u.right}}else{if(u=null,t.right&&!s){for(d=t;d!==null&&d.right!==null&&(d.right.redone||qt(r,d.right.id)||Ui(i.undoStack,d.right.id)||Ui(i.redoStack,d.right.id));)for(d=d.right;d.redone;)d=M(e,d.redone);if(d&&d.right!==null)return null}else d=f._map.get(t.parentSub)||null;d!==null&&d.parent._item!==h&&(d=f._map.get(t.parentSub)||null)}let p=_(c,l),x=y(l,p),m=new S(x,d,d&&d.lastId,u,u&&u.id,f,t.parentSub,t.content.copy());return t.redone=x,hs(m,!0),m.integrate(e,0),m},S=class e extends ge{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>=_(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=_(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ut&&this.id.client!==this.parent.client&&this.parent.clock>=_(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Hr(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=M(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===$||this.right&&this.right.constructor===$)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===ut){let r=Vt(n,this.parent);r.constructor===$?this.parent=null:this.parent=r.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=Hr(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),vt(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if(vt(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(Vt(t.doc.store,s.origin)))i.has(Vt(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),Oi(t.doc.store,this),this.content.integrate(t,this),yi(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new $(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&&vt(t.origin,this.lastId)&&this.right===t&&vt(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(),Fe(t.deleteSet,this.id.client,this.id.clock,this.length),yi(t,n,this.parentSub),this.content.delete(t)}}gc(t,n){if(!this.deleted)throw A();this.content.gc(t),n?xl(t,this,new $(this.id,this.length)):this.content=new me(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 a=rs(c);t.writeParentInfo(!0),t.writeString(a)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else c.constructor===String?(t.writeParentInfo(!0),t.writeString(c)):c.constructor===ut?(t.writeParentInfo(!1),t.writeLeftID(c)):A();i!==null&&t.writeString(i)}this.content.write(t,n)}},uo=(e,t)=>fa[t&31](e),fa=[()=>{A()},Kl,ta,Xl,ra,Zl,Ql,ua,na,Wl,()=>{A()}],pa=10,N=class extends ge{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){A()}write(t,n){t.writeInfo(pa),g(t.restEncoder,this.length-n)}getMissing(t,n){return null}},fo=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:{},po="__ $YJS$ __";fo[po]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");fo[po]=!0;var Wn=e=>{let t=globalThis.monaco;if(!t)throw new Error("[mbeditor] window.monaco is not loaded yet \u2014 the Yjs/Monaco binding requires Monaco to be available on the page first.");return t[e]},go=e=>new Proxy(function(){},{construct:(t,n)=>Reflect.construct(Wn(e),n),apply:(t,n,r)=>Wn(e)(...r),get:(t,n)=>Wn(e)[n]}),mo=e=>new Proxy({},{get:(t,n)=>Wn(e)[n]}),wo=go("Range"),Zn=go("Selection"),yo=mo("SelectionDirection"),gh=mo("editor");var xo=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}};var us={};ms(us,{Awareness:()=>ds,applyAwarenessUpdate:()=>ya,encodeAwarenessUpdate:()=>ma,modifyAwarenessUpdate:()=>wa,outdatedTimeout:()=>Qn,removeAwarenessStates:()=>bo});var Qn=3e4,ds=class extends en{constructor(t){super(),this.doc=t,this.clientID=t.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let n=dt();this.getLocalState()!==null&&Qn/2<=n-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let r=[];this.meta.forEach((s,i)=>{i!==this.clientID&&Qn<=n-s.lastUpdated&&this.states.has(i)&&r.push(i)}),r.length>0&&bo(this,r,"timeout")},O(Qn/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:dt()});let o=[],c=[],l=[],a=[];t===null?a.push(n):i==null?t!=null&&o.push(n):(c.push(n),mt(i,t)||l.push(n)),(o.length>0||l.length>0||a.length>0)&&this.emit("change",[{added:o,updated:l,removed:a},"local"]),this.emit("update",[{added:o,updated:c,removed:a},"local"])}setLocalStateField(t,n){let r=this.getLocalState();r!==null&&this.setLocalState({...r,[t]:n})}getStates(){return this.states}},bo=(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:dt()})}r.push(i)}}r.length>0&&(e.emit("change",[{added:[],updated:[],removed:r},n]),e.emit("update",[{added:[],updated:[],removed:r},n]))},ma=(e,t,n=e.states)=>{let r=t.length,s=nt();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),Z(s,JSON.stringify(c))}return B(s)},wa=(e,t)=>{let n=D(e),r=nt(),s=w(n);g(r,s);for(let i=0;i<s;i++){let o=w(n),c=w(n),l=JSON.parse(Q(n)),a=t(l);g(r,o),g(r,c),Z(r,JSON.stringify(a))}return B(r)},ya=(e,t,n)=>{let r=D(t),s=dt(),i=[],o=[],c=[],l=[],a=w(r);for(let h=0;h<a;h++){let d=w(r),u=w(r),f=JSON.parse(Q(r)),p=e.meta.get(d),x=e.states.get(d),m=p===void 0?0:p.clock;(m<u||m===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&&(mt(f,x)||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 fs=class{constructor(t,n,r){this.start=t,this.end=n,this.direction=r}},xa=(e,t,n)=>{let r=e.getSelection();if(r!==null){let s=r.getStartPosition(),i=r.getEndPosition(),o=we(n,t.getOffsetAt(s)),c=we(n,t.getOffsetAt(i));return new fs(o,c,r.getDirection())}return null},ba=(e,t,n,r)=>{let s=ye(n.start,r),i=ye(n.end,r);if(s!==null&&i!==null&&s.type===t&&i.type===t){let o=e.getModel(),c=o.getPositionAt(s.index),l=o.getPositionAt(i.index);return Zn.createWithDirection(c.lineNumber,c.column,l.lineNumber,l.column,n.direction)}return null},tr=class{constructor(t,n,r=new Set,s=null){this.doc=t.doc,this.ytext=t,this.monacoModel=n,this.editors=r,this.mux=xo(),this._savedSelections=new Map,this._beforeTransaction=()=>{this.mux(()=>{this._savedSelections=new Map,r.forEach(i=>{if(i.getModel()===n){let o=xa(i,n,t);o!==null&&this._savedSelections.set(i,o)}})})},this.doc.on("beforeAllTransactions",this._beforeTransaction),this._decorations=new Map,this._rerenderDecorations=()=>{r.forEach(i=>{if(s&&i.getModel()===n){let o=this._decorations.get(i)||[],c=[];s.getStates().forEach((l,a)=>{if(a!==this.doc.clientID&&l.selection!=null&&l.selection.anchor!=null&&l.selection.head!=null){let h=ye(l.selection.anchor,this.doc),d=ye(l.selection.head,this.doc);if(h!==null&&d!==null&&h.type===t&&d.type===t){let u,f,p,x;h.index<d.index?(u=n.getPositionAt(h.index),f=n.getPositionAt(d.index),p="yRemoteSelectionHead yRemoteSelectionHead-"+a,x=null):(u=n.getPositionAt(d.index),f=n.getPositionAt(h.index),p=null,x="yRemoteSelectionHead yRemoteSelectionHead-"+a),c.push({range:new wo(u.lineNumber,u.column,f.lineNumber,f.column),options:{className:"yRemoteSelection yRemoteSelection-"+a,afterContentClassName:p,beforeContentClassName:x}})}}}),this._decorations.set(i,i.deltaDecorations(o,c))}else this._decorations.delete(i)})},this._ytextObserver=i=>{this.mux(()=>{let o=0;i.delta.forEach(c=>{if(c.retain!==void 0)o+=c.retain;else if(c.insert!==void 0){let l=n.getPositionAt(o),a=new Zn(l.lineNumber,l.column,l.lineNumber,l.column),h=c.insert;n.applyEdits([{range:a,text:h}]),o+=h.length}else if(c.delete!==void 0){let l=n.getPositionAt(o),a=n.getPositionAt(o+c.delete),h=new Zn(l.lineNumber,l.column,a.lineNumber,a.column);n.applyEdits([{range:h,text:""}])}else throw A()}),this._savedSelections.forEach((c,l)=>{let a=ba(l,t,c,this.doc);a!==null&&l.setSelection(a)})}),this._rerenderDecorations()},t.observe(this._ytextObserver);{let i=t.toString();n.getValue()!==i&&n.setValue(i)}this._monacoChangeHandler=n.onDidChangeContent(i=>{this.mux(()=>{this.doc.transact(()=>{i.changes.sort((o,c)=>c.rangeOffset-o.rangeOffset).forEach(o=>{t.delete(o.rangeOffset,o.rangeLength),t.insert(o.rangeOffset,o.text)})},this)})}),this._monacoDisposeHandler=n.onWillDispose(()=>{this.destroy()}),s&&(r.forEach(i=>{i.onDidChangeCursorSelection(()=>{if(i.getModel()===n){let o=i.getSelection();if(o===null)return;let c=n.getOffsetAt(o.getStartPosition()),l=n.getOffsetAt(o.getEndPosition());if(o.getDirection()===yo.RTL){let a=c;c=l,l=a}s.setLocalStateField("selection",{anchor:we(t,c),head:we(t,l)})}}),s.on("change",this._rerenderDecorations)}),this.awareness=s)}destroy(){this._monacoChangeHandler.dispose(),this._monacoDisposeHandler.dispose(),this.ytext.unobserve(this._ytextObserver),this.doc.off("beforeAllTransactions",this._beforeTransaction),this.awareness&&this.awareness.off("change",this._rerenderDecorations)}};globalThis.Y=Kn;globalThis.MonacoBinding=tr;globalThis.awarenessProtocol=us;})();
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mbeditor
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.12.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Oliver Noonan
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-07-
|
|
11
|
+
date: 2026-07-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -57,6 +57,8 @@ files:
|
|
|
57
57
|
- app/assets/javascripts/mbeditor/application.js
|
|
58
58
|
- app/assets/javascripts/mbeditor/application_iife_head.js
|
|
59
59
|
- app/assets/javascripts/mbeditor/application_iife_tail.js
|
|
60
|
+
- app/assets/javascripts/mbeditor/collaboration_identity.js
|
|
61
|
+
- app/assets/javascripts/mbeditor/collaboration_service.js
|
|
60
62
|
- app/assets/javascripts/mbeditor/color_provider.js
|
|
61
63
|
- app/assets/javascripts/mbeditor/components/ChangelogView.js
|
|
62
64
|
- app/assets/javascripts/mbeditor/components/CodeReviewPanel.js
|
|
@@ -68,8 +70,10 @@ files:
|
|
|
68
70
|
- app/assets/javascripts/mbeditor/components/FileHistoryPanel.js
|
|
69
71
|
- app/assets/javascripts/mbeditor/components/FileTree.js
|
|
70
72
|
- app/assets/javascripts/mbeditor/components/GitPanel.js
|
|
73
|
+
- app/assets/javascripts/mbeditor/components/ImportConflictModal.js
|
|
71
74
|
- app/assets/javascripts/mbeditor/components/LogPanel.js
|
|
72
75
|
- app/assets/javascripts/mbeditor/components/MbeditorApp.js
|
|
76
|
+
- app/assets/javascripts/mbeditor/components/ModelGraph.js
|
|
73
77
|
- app/assets/javascripts/mbeditor/components/ProblemsPanel.js
|
|
74
78
|
- app/assets/javascripts/mbeditor/components/QuickOpenDialog.js
|
|
75
79
|
- app/assets/javascripts/mbeditor/components/ShortcutHelp.js
|
|
@@ -79,6 +83,7 @@ files:
|
|
|
79
83
|
- app/assets/javascripts/mbeditor/editor_plugins.js
|
|
80
84
|
- app/assets/javascripts/mbeditor/editor_store.js
|
|
81
85
|
- app/assets/javascripts/mbeditor/file_icon.js
|
|
86
|
+
- app/assets/javascripts/mbeditor/file_import.js
|
|
82
87
|
- app/assets/javascripts/mbeditor/file_service.js
|
|
83
88
|
- app/assets/javascripts/mbeditor/git_service.js
|
|
84
89
|
- app/assets/javascripts/mbeditor/history_service.js
|
|
@@ -91,6 +96,8 @@ files:
|
|
|
91
96
|
- app/assets/stylesheets/mbeditor/application.css
|
|
92
97
|
- app/assets/stylesheets/mbeditor/editor.css
|
|
93
98
|
- app/assets/stylesheets/mbeditor/themes.css
|
|
99
|
+
- app/channels/mbeditor/channel_authentication.rb
|
|
100
|
+
- app/channels/mbeditor/collaboration_channel.rb
|
|
94
101
|
- app/channels/mbeditor/editor_channel.rb
|
|
95
102
|
- app/controllers/mbeditor/application_controller.rb
|
|
96
103
|
- app/controllers/mbeditor/editors_controller.rb
|
|
@@ -98,8 +105,10 @@ files:
|
|
|
98
105
|
- app/controllers/mbeditor/logs_controller.rb
|
|
99
106
|
- app/services/mbeditor/availability_probe.rb
|
|
100
107
|
- app/services/mbeditor/code_search_service.rb
|
|
108
|
+
- app/services/mbeditor/collaboration_doc_store.rb
|
|
101
109
|
- app/services/mbeditor/editor_state_service.rb
|
|
102
110
|
- app/services/mbeditor/exclusion_matcher.rb
|
|
111
|
+
- app/services/mbeditor/file_import_service.rb
|
|
103
112
|
- app/services/mbeditor/file_operation_service.rb
|
|
104
113
|
- app/services/mbeditor/file_tree_service.rb
|
|
105
114
|
- app/services/mbeditor/git_blame_service.rb
|
|
@@ -118,6 +127,8 @@ files:
|
|
|
118
127
|
- app/services/mbeditor/js_syntax_check_service.rb
|
|
119
128
|
- app/services/mbeditor/log_tail_service.rb
|
|
120
129
|
- app/services/mbeditor/lsp_diagnostics_translator.rb
|
|
130
|
+
- app/services/mbeditor/model_graph_service.rb
|
|
131
|
+
- app/services/mbeditor/presence_registry.rb
|
|
121
132
|
- app/services/mbeditor/process_runner.rb
|
|
122
133
|
- app/services/mbeditor/rails_related_files_service.rb
|
|
123
134
|
- app/services/mbeditor/redmine_service.rb
|
|
@@ -137,6 +148,7 @@ files:
|
|
|
137
148
|
- lib/mbeditor/configuration.rb
|
|
138
149
|
- lib/mbeditor/editor_bootstrap.rb
|
|
139
150
|
- lib/mbeditor/engine.rb
|
|
151
|
+
- lib/mbeditor/exception_log.rb
|
|
140
152
|
- lib/mbeditor/mount_path.rb
|
|
141
153
|
- lib/mbeditor/private_routes.rb
|
|
142
154
|
- lib/mbeditor/rack/handle_pending_migrations.rb
|
|
@@ -172,6 +184,7 @@ files:
|
|
|
172
184
|
- vendor/assets/javascripts/prettier-standalone.js
|
|
173
185
|
- vendor/assets/javascripts/react-dom.min.js
|
|
174
186
|
- vendor/assets/javascripts/react.min.js
|
|
187
|
+
- vendor/assets/javascripts/yjs-collab.js
|
|
175
188
|
- vendor/assets/stylesheets/fontawesome.min.css.erb
|
|
176
189
|
- vendor/assets/stylesheets/pico.classless.css
|
|
177
190
|
- vendor/assets/webfonts/fa-brands-400.woff2
|