vzcode 0.84.0 → 0.85.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.
|
@@ -65,7 +65,7 @@ Source:
|
|
|
65
65
|
`))):tt=Y.stylize("[Circular]","special")),C(qe)){if(De&&Re.match(/^\d+$/))return tt;qe=JSON.stringify(""+Re),qe.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(qe=qe.slice(1,-1),qe=Y.stylize(qe,"name")):(qe=qe.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),qe=Y.stylize(qe,"string"))}return qe+": "+tt}function S(Y,G,ee){var ve=Y.reduce(function(Re,De){return De.indexOf(`
|
|
66
66
|
`)>=0,Re+De.replace(/\u001b\[\d\d?m/g,"").length+1},0);return ve>60?ee[0]+(G===""?"":G+`
|
|
67
67
|
`)+" "+Y.join(`,
|
|
68
|
-
`)+" "+ee[1]:ee[0]+G+" "+Y.join(", ")+" "+ee[1]}i.types=r("./support/types");function P(Y){return Array.isArray(Y)}i.isArray=P;function _(Y){return typeof Y=="boolean"}i.isBoolean=_;function Q(Y){return Y===null}i.isNull=Q;function b(Y){return Y==null}i.isNullOrUndefined=b;function k(Y){return typeof Y=="number"}i.isNumber=k;function x(Y){return typeof Y=="string"}i.isString=x;function $(Y){return typeof Y=="symbol"}i.isSymbol=$;function C(Y){return Y===void 0}i.isUndefined=C;function Z(Y){return B(Y)&&X(Y)==="[object RegExp]"}i.isRegExp=Z,i.types.isRegExp=Z;function B(Y){return typeof Y=="object"&&Y!==null}i.isObject=B;function F(Y){return B(Y)&&X(Y)==="[object Date]"}i.isDate=F,i.types.isDate=F;function M(Y){return B(Y)&&(X(Y)==="[object Error]"||Y instanceof Error)}i.isError=M,i.types.isNativeError=M;function I(Y){return typeof Y=="function"}i.isFunction=I;function D(Y){return Y===null||typeof Y=="boolean"||typeof Y=="number"||typeof Y=="string"||typeof Y=="symbol"||typeof Y>"u"}i.isPrimitive=D,i.isBuffer=r("./support/isBuffer");function X(Y){return Object.prototype.toString.call(Y)}function z(Y){return Y<10?"0"+Y.toString(10):Y.toString(10)}var le=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function he(){var Y=new Date,G=[z(Y.getHours()),z(Y.getMinutes()),z(Y.getSeconds())].join(":");return[Y.getDate(),le[Y.getMonth()],G].join(" ")}i.log=function(){console.log("%s - %s",he(),i.format.apply(i,arguments))},i.inherits=r("inherits"),i._extend=function(Y,G){if(!G||!B(G))return Y;for(var ee=Object.keys(G),ve=ee.length;ve--;)Y[ee[ve]]=G[ee[ve]];return Y};function U(Y,G){return Object.prototype.hasOwnProperty.call(Y,G)}var K=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;i.promisify=function(G){if(typeof G!="function")throw new TypeError('The "original" argument must be of type Function');if(K&&G[K]){var ee=G[K];if(typeof ee!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(ee,K,{value:ee,enumerable:!1,writable:!1,configurable:!0}),ee}function ee(){for(var ve,Re,De=new Promise(function(st,Et){ve=st,Re=Et}),qe=[],tt=0;tt<arguments.length;tt++)qe.push(arguments[tt]);qe.push(function(st,Et){st?Re(st):ve(Et)});try{G.apply(this,qe)}catch(st){Re(st)}return De}return Object.setPrototypeOf(ee,Object.getPrototypeOf(G)),K&&Object.defineProperty(ee,K,{value:ee,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(ee,s(G))},i.promisify.custom=K;function se(Y,G){if(!Y){var ee=new Error("Promise was rejected with a falsy value");ee.reason=Y,Y=ee}return G(Y)}function Me(Y){if(typeof Y!="function")throw new TypeError('The "original" argument must be of type Function');function G(){for(var ee=[],ve=0;ve<arguments.length;ve++)ee.push(arguments[ve]);var Re=ee.pop();if(typeof Re!="function")throw new TypeError("The last argument must be of type Function");var De=this,qe=function(){return Re.apply(De,arguments)};Y.apply(this,ee).then(function(tt){o.nextTick(qe.bind(null,null,tt))},function(tt){o.nextTick(se.bind(null,tt,qe))})}return Object.setPrototypeOf(G,Object.getPrototypeOf(Y)),Object.defineProperties(G,s(Y)),G}i.callbackify=Me}).call(this)}).call(this,r("_process"))},{"./support/isBuffer":35,"./support/types":36,_process:33,inherits:17}],38:[function(r,n,i){(function(o){(function(){var s=r("for-each"),a=r("available-typed-arrays"),l=r("call-bind/callBound"),c=r("gopd"),u=l("Object.prototype.toString"),f=r("has-tostringtag/shams")(),h=typeof globalThis>"u"?o:globalThis,d=a(),p=l("String.prototype.slice"),O={},m=Object.getPrototypeOf;f&&c&&m&&s(d,function(v){if(typeof h[v]=="function"){var S=new h[v];if(Symbol.toStringTag in S){var P=m(S),_=c(P,Symbol.toStringTag);if(!_){var Q=m(P);_=c(Q,Symbol.toStringTag)}O[v]=_.get}}});var y=function(S){var P=!1;return s(O,function(_,Q){if(!P)try{var b=_.call(S);b===Q&&(P=b)}catch{}}),P},g=r("is-typed-array");n.exports=function(S){return g(S)?!f||!(Symbol.toStringTag in S)?p(u(S),8,-1):y(S):!1}}).call(this)}).call(this,typeof zn<"u"?zn:typeof self<"u"?self:typeof window<"u"?window:{})},{"available-typed-arrays":5,"call-bind/callBound":6,"for-each":8,gopd:12,"has-tostringtag/shams":15,"is-typed-array":21}],39:[function(r,n,i){const o=r("ot-json1-presence"),s=r("ot-text-unicode");n.exports={json1Presence:o,textUnicode:s}},{"ot-json1-presence":26,"ot-text-unicode":31}]},{},[39])(39)})})(YQ);var Oj=YQ.exports;const gj=bi(Oj),{json1Presence:P0,textUnicode:UQ}=gj;function mj(t){return new Worker("/assets/worker-DHoGVnSk.js",{name:t==null?void 0:t.name})}function yj(t){return new Worker("/assets/index-CI1sbUJw.js",{name:t==null?void 0:t.name})}const vj=!0,rS=800,FQ="vzCodeSidebarWidth",zQ="vzCodeCodeEditorWidth",GQ=220;let vO=GQ;const HQ=800;let wO=HQ,iy=!1;if(typeof window<"u"&&vj){const t=window.localStorage.getItem(FQ),e=window.localStorage.getItem(zQ);t!==null&&(vO=+t,iy=!0),e!==null&&(wO=+e,iy=!0)}const wj={codeEditorWidth:wO,sidebarWidth:vO,moveSplitPane:()=>{},isDraggingRight:!1,isDraggingLeft:!1,setIsDragging:()=>{}},SO=q.createContext(wj),Sj={sidebarWidth:GQ,codeEditorWidth:HQ,isDraggingLeft:!1,isDraggingRight:!1,isInitialized:!1},bj=(t,e)=>{switch(e.type){case"initialize":return{...t,sidebarWidth:vO,codeEditorWidth:wO,isInitialized:!0};case"move":return e.side==="left"?{...t,sidebarWidth:t.sidebarWidth+e.movementX}:{...t,codeEditorWidth:t.codeEditorWidth+e.movementX};case"setIsDragging":return e.side==="left"?{...t,isDraggingLeft:e.isDragging}:{...t,isDraggingRight:e.isDragging};default:return t}},Pj=({children:t})=>{const[e,r]=q.useReducer(bj,Sj),n=q.useCallback((f,h)=>{r({type:"setIsDragging",isDragging:f,side:h})},[r]),i=q.useCallback((f,h)=>{r({type:"move",movementX:f,side:h})},[r]),{sidebarWidth:o,codeEditorWidth:s,isDraggingLeft:a,isDraggingRight:l,isInitialized:c}=e;typeof window<"u"&&q.useLayoutEffect(()=>{iy&&!c&&r({type:"initialize"})},[c]),q.useEffect(()=>{o!==vO&&setTimeout(()=>{window.localStorage.setItem(FQ,""+o)},rS),s!==wO&&setTimeout(()=>{window.localStorage.setItem(zQ,""+s)},rS)},[s,o]);const u={codeEditorWidth:s,sidebarWidth:o,moveSplitPane:i,isDraggingLeft:a,isDraggingRight:l,setIsDragging:n};return W.jsx(SO.Provider,{value:u,children:t})},kj=1200,xj=t=>{const e=t.match(/\.([^.]+)$/);return e?e[1]:""},_j=({shareDBDoc:t,submitOperation:e,prettierWorker:r})=>{const n=q.useRef(new Set),[i,o]=q.useState(null),s=q.useRef(!1),a=q.useRef(null);return q.useEffect(()=>{if(!t)return;const l=f=>{const{fileId:h,error:d,fileTextPrettified:p}=f.data;if(d){o(d);return}else o(null);s.current=!0,e(O=>({...O,files:{...O.files,[h]:{...O.files[h],text:p}}})),s.current=!1};r.addEventListener("message",l);const c=async()=>{const h=t.data.files,d=n.current,p=Array.from(d);d.clear();for(const O of p){const m=h[O],y={fileText:m.text,fileExtension:xj(m.name),fileId:O};r.postMessage(y)}};a.current=c;const u=f=>{if(!s.current&&f&&f.length===4&&f[0]==="files"&&typeof f[1]=="string"&&f[2]==="text"){const h=f[1];n.current.add(h)}};return t.on("op batch",u),()=>{r.removeEventListener("message",l),t.removeListener("op batch",u)}},[t]),{prettierError:i,runPrettierRef:a}},$j=500,Qj=kj+$j,Ej=({content:t,typeScriptWorker:e})=>{const r=q.useRef(null),n=q.useCallback(i=>{i!==null&&(clearTimeout(r.current),r.current=window.setTimeout(()=>{e.postMessage({event:"update-content",details:i})},Qj))},[e]);q.useEffect(()=>{n(t)},[t])},Cj=(t,e)=>{if(e.type!=="close_tabs")return t;const r=t.tabList.filter(o=>!e.fileIdsToClose.includes(o.fileId));if(!e.fileIdsToClose.includes(t.activeFileId))return{...t,tabList:r};const n=t.tabList.findIndex(o=>o.fileId===t.activeFileId);let i=null;for(let o=n-1;o>=0;o--)if(!e.fileIdsToClose.includes(t.tabList[o].fileId)){i=t.tabList[o].fileId;break}if(!i){for(let o=n+1;o<t.tabList.length;o++)if(!e.fileIdsToClose.includes(t.tabList[o].fileId)){i=t.tabList[o].fileId;break}}return{...t,tabList:r,activeFileId:i}},Tj=(t,e)=>{if(e.type!=="open_tab")return t;const r=t.tabList.findIndex(l=>l.fileId===e.fileId),n=r!==-1,i=n&&t.tabList[r].isTransient,o=t.tabList.findIndex(l=>l.isTransient&&l.fileId!==e.fileId),s={fileId:e.fileId,isTransient:e.isTransient};let a;return n?i?a=t.tabList.map(l=>l.fileId===e.fileId?s:l):a=[...t.tabList]:o!==-1?(a=[...t.tabList],a[o]=s):a=[...t.tabList,s],{...t,activeFileId:e.fileId,tabList:a,editorWantsFocus:!e.isTransient}},Rj=(t,e)=>e.type==="set_active_file_id"?{...t,activeFileId:e.activeFileId}:t,Aj=(t,e)=>{if(e.type!=="set_active_file_left")return t;let r=t.tabList.findIndex(n=>n.fileId===t.activeFileId);return r-=1,r<0&&(r=t.tabList.length-1),{...t,activeFileId:t.tabList[r].fileId}},Mj=(t,e)=>{if(e.type!=="set_active_file_right")return t;let r=t.tabList.findIndex(n=>n.fileId===t.activeFileId);return r+=1,r>t.tabList.length-1&&(r=0),{...t,activeFileId:t.tabList[r].fileId}},jj=(t,e)=>e.type==="set_is_settings_open"?{...t,isSettingsOpen:e.value}:t,Dj=(t,e)=>e.type==="set_theme"?{...t,theme:e.themeLabel}:t,qj=(t,e)=>e.type==="editor_no_longer_wants_focus"?{...t,editorWantsFocus:!1}:t,Zj=(t,e)=>e.type==="set_username"?{...t,username:e.username}:t,Nj=({defaultTheme:t,initialUsername:e="Anonymous"})=>({tabList:[],activeFileId:null,theme:t,isSettingsOpen:!1,editorWantsFocus:!1,username:e}),Wj=[Rj,Aj,Mj,Tj,Cj,Dj,jj,qj,Zj],Ij=(t,e)=>Wj.reduce((r,n)=>n(r,e),t);class It{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,r,n){[e,r]=Bl(this,e,r);let i=[];return this.decompose(0,e,i,2),n.length&&n.decompose(0,n.length,i,3),this.decompose(r,this.length,i,1),so.from(i,this.length-(r-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,r=this.length){[e,r]=Bl(this,e,r);let n=[];return this.decompose(e,r,n,0),so.from(n,r-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let r=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),i=new pc(this),o=new pc(e);for(let s=r,a=r;;){if(i.next(s),o.next(s),s=0,i.lineBreak!=o.lineBreak||i.done!=o.done||i.value!=o.value)return!1;if(a+=i.value.length,i.done||a>=n)return!0}}iter(e=1){return new pc(this,e)}iterRange(e,r=this.length){return new KQ(this,e,r)}iterLines(e,r){let n;if(e==null)n=this.iter();else{r==null&&(r=this.lines+1);let i=this.line(e).from;n=this.iterRange(i,Math.max(i,r==this.lines+1?this.length:r<=1?0:this.line(r-1).to))}return new JQ(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?It.empty:e.length<=32?new Er(e):so.from(Er.split(e,[]))}}class Er extends It{constructor(e,r=Bj(e)){super(),this.text=e,this.length=r}get lines(){return this.text.length}get children(){return null}lineInner(e,r,n,i){for(let o=0;;o++){let s=this.text[o],a=i+s.length;if((r?n:a)>=e)return new Lj(i,a,n,s);i=a+1,n++}}decompose(e,r,n,i){let o=e<=0&&r>=this.length?this:new Er(nS(this.text,e,r),Math.min(r,this.length)-Math.max(0,e));if(i&1){let s=n.pop(),a=Td(o.text,s.text.slice(),0,o.length);if(a.length<=32)n.push(new Er(a,s.length+o.length));else{let l=a.length>>1;n.push(new Er(a.slice(0,l)),new Er(a.slice(l)))}}else n.push(o)}replace(e,r,n){if(!(n instanceof Er))return super.replace(e,r,n);[e,r]=Bl(this,e,r);let i=Td(this.text,Td(n.text,nS(this.text,0,e)),r),o=this.length+n.length-(r-e);return i.length<=32?new Er(i,o):so.from(Er.split(i,[]),o)}sliceString(e,r=this.length,n=`
|
|
68
|
+
`)+" "+ee[1]:ee[0]+G+" "+Y.join(", ")+" "+ee[1]}i.types=r("./support/types");function P(Y){return Array.isArray(Y)}i.isArray=P;function _(Y){return typeof Y=="boolean"}i.isBoolean=_;function Q(Y){return Y===null}i.isNull=Q;function b(Y){return Y==null}i.isNullOrUndefined=b;function k(Y){return typeof Y=="number"}i.isNumber=k;function x(Y){return typeof Y=="string"}i.isString=x;function $(Y){return typeof Y=="symbol"}i.isSymbol=$;function C(Y){return Y===void 0}i.isUndefined=C;function Z(Y){return B(Y)&&X(Y)==="[object RegExp]"}i.isRegExp=Z,i.types.isRegExp=Z;function B(Y){return typeof Y=="object"&&Y!==null}i.isObject=B;function F(Y){return B(Y)&&X(Y)==="[object Date]"}i.isDate=F,i.types.isDate=F;function M(Y){return B(Y)&&(X(Y)==="[object Error]"||Y instanceof Error)}i.isError=M,i.types.isNativeError=M;function I(Y){return typeof Y=="function"}i.isFunction=I;function D(Y){return Y===null||typeof Y=="boolean"||typeof Y=="number"||typeof Y=="string"||typeof Y=="symbol"||typeof Y>"u"}i.isPrimitive=D,i.isBuffer=r("./support/isBuffer");function X(Y){return Object.prototype.toString.call(Y)}function z(Y){return Y<10?"0"+Y.toString(10):Y.toString(10)}var le=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function he(){var Y=new Date,G=[z(Y.getHours()),z(Y.getMinutes()),z(Y.getSeconds())].join(":");return[Y.getDate(),le[Y.getMonth()],G].join(" ")}i.log=function(){console.log("%s - %s",he(),i.format.apply(i,arguments))},i.inherits=r("inherits"),i._extend=function(Y,G){if(!G||!B(G))return Y;for(var ee=Object.keys(G),ve=ee.length;ve--;)Y[ee[ve]]=G[ee[ve]];return Y};function U(Y,G){return Object.prototype.hasOwnProperty.call(Y,G)}var K=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;i.promisify=function(G){if(typeof G!="function")throw new TypeError('The "original" argument must be of type Function');if(K&&G[K]){var ee=G[K];if(typeof ee!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(ee,K,{value:ee,enumerable:!1,writable:!1,configurable:!0}),ee}function ee(){for(var ve,Re,De=new Promise(function(st,Et){ve=st,Re=Et}),qe=[],tt=0;tt<arguments.length;tt++)qe.push(arguments[tt]);qe.push(function(st,Et){st?Re(st):ve(Et)});try{G.apply(this,qe)}catch(st){Re(st)}return De}return Object.setPrototypeOf(ee,Object.getPrototypeOf(G)),K&&Object.defineProperty(ee,K,{value:ee,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(ee,s(G))},i.promisify.custom=K;function se(Y,G){if(!Y){var ee=new Error("Promise was rejected with a falsy value");ee.reason=Y,Y=ee}return G(Y)}function Me(Y){if(typeof Y!="function")throw new TypeError('The "original" argument must be of type Function');function G(){for(var ee=[],ve=0;ve<arguments.length;ve++)ee.push(arguments[ve]);var Re=ee.pop();if(typeof Re!="function")throw new TypeError("The last argument must be of type Function");var De=this,qe=function(){return Re.apply(De,arguments)};Y.apply(this,ee).then(function(tt){o.nextTick(qe.bind(null,null,tt))},function(tt){o.nextTick(se.bind(null,tt,qe))})}return Object.setPrototypeOf(G,Object.getPrototypeOf(Y)),Object.defineProperties(G,s(Y)),G}i.callbackify=Me}).call(this)}).call(this,r("_process"))},{"./support/isBuffer":35,"./support/types":36,_process:33,inherits:17}],38:[function(r,n,i){(function(o){(function(){var s=r("for-each"),a=r("available-typed-arrays"),l=r("call-bind/callBound"),c=r("gopd"),u=l("Object.prototype.toString"),f=r("has-tostringtag/shams")(),h=typeof globalThis>"u"?o:globalThis,d=a(),p=l("String.prototype.slice"),O={},m=Object.getPrototypeOf;f&&c&&m&&s(d,function(v){if(typeof h[v]=="function"){var S=new h[v];if(Symbol.toStringTag in S){var P=m(S),_=c(P,Symbol.toStringTag);if(!_){var Q=m(P);_=c(Q,Symbol.toStringTag)}O[v]=_.get}}});var y=function(S){var P=!1;return s(O,function(_,Q){if(!P)try{var b=_.call(S);b===Q&&(P=b)}catch{}}),P},g=r("is-typed-array");n.exports=function(S){return g(S)?!f||!(Symbol.toStringTag in S)?p(u(S),8,-1):y(S):!1}}).call(this)}).call(this,typeof zn<"u"?zn:typeof self<"u"?self:typeof window<"u"?window:{})},{"available-typed-arrays":5,"call-bind/callBound":6,"for-each":8,gopd:12,"has-tostringtag/shams":15,"is-typed-array":21}],39:[function(r,n,i){const o=r("ot-json1-presence"),s=r("ot-text-unicode");n.exports={json1Presence:o,textUnicode:s}},{"ot-json1-presence":26,"ot-text-unicode":31}]},{},[39])(39)})})(YQ);var Oj=YQ.exports;const gj=bi(Oj),{json1Presence:P0,textUnicode:UQ}=gj;function mj(t){return new Worker("/assets/worker-1Ck54dGO.js",{name:t==null?void 0:t.name})}function yj(t){return new Worker("/assets/index-CI1sbUJw.js",{name:t==null?void 0:t.name})}const vj=!0,rS=800,FQ="vzCodeSidebarWidth",zQ="vzCodeCodeEditorWidth",GQ=220;let vO=GQ;const HQ=800;let wO=HQ,iy=!1;if(typeof window<"u"&&vj){const t=window.localStorage.getItem(FQ),e=window.localStorage.getItem(zQ);t!==null&&(vO=+t,iy=!0),e!==null&&(wO=+e,iy=!0)}const wj={codeEditorWidth:wO,sidebarWidth:vO,moveSplitPane:()=>{},isDraggingRight:!1,isDraggingLeft:!1,setIsDragging:()=>{}},SO=q.createContext(wj),Sj={sidebarWidth:GQ,codeEditorWidth:HQ,isDraggingLeft:!1,isDraggingRight:!1,isInitialized:!1},bj=(t,e)=>{switch(e.type){case"initialize":return{...t,sidebarWidth:vO,codeEditorWidth:wO,isInitialized:!0};case"move":return e.side==="left"?{...t,sidebarWidth:t.sidebarWidth+e.movementX}:{...t,codeEditorWidth:t.codeEditorWidth+e.movementX};case"setIsDragging":return e.side==="left"?{...t,isDraggingLeft:e.isDragging}:{...t,isDraggingRight:e.isDragging};default:return t}},Pj=({children:t})=>{const[e,r]=q.useReducer(bj,Sj),n=q.useCallback((f,h)=>{r({type:"setIsDragging",isDragging:f,side:h})},[r]),i=q.useCallback((f,h)=>{r({type:"move",movementX:f,side:h})},[r]),{sidebarWidth:o,codeEditorWidth:s,isDraggingLeft:a,isDraggingRight:l,isInitialized:c}=e;typeof window<"u"&&q.useLayoutEffect(()=>{iy&&!c&&r({type:"initialize"})},[c]),q.useEffect(()=>{o!==vO&&setTimeout(()=>{window.localStorage.setItem(FQ,""+o)},rS),s!==wO&&setTimeout(()=>{window.localStorage.setItem(zQ,""+s)},rS)},[s,o]);const u={codeEditorWidth:s,sidebarWidth:o,moveSplitPane:i,isDraggingLeft:a,isDraggingRight:l,setIsDragging:n};return W.jsx(SO.Provider,{value:u,children:t})},kj=1200,xj=t=>{const e=t.match(/\.([^.]+)$/);return e?e[1]:""},_j=({shareDBDoc:t,submitOperation:e,prettierWorker:r})=>{const n=q.useRef(new Set),[i,o]=q.useState(null),s=q.useRef(!1),a=q.useRef(null);return q.useEffect(()=>{if(!t)return;const l=f=>{const{fileId:h,error:d,fileTextPrettified:p}=f.data;if(d){o(d);return}else o(null);s.current=!0,e(O=>({...O,files:{...O.files,[h]:{...O.files[h],text:p}}})),s.current=!1};r.addEventListener("message",l);const c=async()=>{const h=t.data.files,d=n.current,p=Array.from(d);d.clear();for(const O of p){const m=h[O],y={fileText:m.text,fileExtension:xj(m.name),fileId:O};r.postMessage(y)}};a.current=c;const u=f=>{if(!s.current&&f&&f.length===4&&f[0]==="files"&&typeof f[1]=="string"&&f[2]==="text"){const h=f[1];n.current.add(h)}};return t.on("op batch",u),()=>{r.removeEventListener("message",l),t.removeListener("op batch",u)}},[t]),{prettierError:i,runPrettierRef:a}},$j=500,Qj=kj+$j,Ej=({content:t,typeScriptWorker:e})=>{const r=q.useRef(null),n=q.useCallback(i=>{i!==null&&(clearTimeout(r.current),r.current=window.setTimeout(()=>{e.postMessage({event:"update-content",details:i})},Qj))},[e]);q.useEffect(()=>{n(t)},[t])},Cj=(t,e)=>{if(e.type!=="close_tabs")return t;const r=t.tabList.filter(o=>!e.fileIdsToClose.includes(o.fileId));if(!e.fileIdsToClose.includes(t.activeFileId))return{...t,tabList:r};const n=t.tabList.findIndex(o=>o.fileId===t.activeFileId);let i=null;for(let o=n-1;o>=0;o--)if(!e.fileIdsToClose.includes(t.tabList[o].fileId)){i=t.tabList[o].fileId;break}if(!i){for(let o=n+1;o<t.tabList.length;o++)if(!e.fileIdsToClose.includes(t.tabList[o].fileId)){i=t.tabList[o].fileId;break}}return{...t,tabList:r,activeFileId:i}},Tj=(t,e)=>{if(e.type!=="open_tab")return t;const r=t.tabList.findIndex(l=>l.fileId===e.fileId),n=r!==-1,i=n&&t.tabList[r].isTransient,o=t.tabList.findIndex(l=>l.isTransient&&l.fileId!==e.fileId),s={fileId:e.fileId,isTransient:e.isTransient};let a;return n?i?a=t.tabList.map(l=>l.fileId===e.fileId?s:l):a=[...t.tabList]:o!==-1?(a=[...t.tabList],a[o]=s):a=[...t.tabList,s],{...t,activeFileId:e.fileId,tabList:a,editorWantsFocus:!e.isTransient}},Rj=(t,e)=>e.type==="set_active_file_id"?{...t,activeFileId:e.activeFileId}:t,Aj=(t,e)=>{if(e.type!=="set_active_file_left")return t;let r=t.tabList.findIndex(n=>n.fileId===t.activeFileId);return r-=1,r<0&&(r=t.tabList.length-1),{...t,activeFileId:t.tabList[r].fileId}},Mj=(t,e)=>{if(e.type!=="set_active_file_right")return t;let r=t.tabList.findIndex(n=>n.fileId===t.activeFileId);return r+=1,r>t.tabList.length-1&&(r=0),{...t,activeFileId:t.tabList[r].fileId}},jj=(t,e)=>e.type==="set_is_settings_open"?{...t,isSettingsOpen:e.value}:t,Dj=(t,e)=>e.type==="set_theme"?{...t,theme:e.themeLabel}:t,qj=(t,e)=>e.type==="editor_no_longer_wants_focus"?{...t,editorWantsFocus:!1}:t,Zj=(t,e)=>e.type==="set_username"?{...t,username:e.username}:t,Nj=({defaultTheme:t,initialUsername:e="Anonymous"})=>({tabList:[],activeFileId:null,theme:t,isSettingsOpen:!1,editorWantsFocus:!1,username:e}),Wj=[Rj,Aj,Mj,Tj,Cj,Dj,jj,qj,Zj],Ij=(t,e)=>Wj.reduce((r,n)=>n(r,e),t);class It{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,r,n){[e,r]=Bl(this,e,r);let i=[];return this.decompose(0,e,i,2),n.length&&n.decompose(0,n.length,i,3),this.decompose(r,this.length,i,1),so.from(i,this.length-(r-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,r=this.length){[e,r]=Bl(this,e,r);let n=[];return this.decompose(e,r,n,0),so.from(n,r-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let r=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),i=new pc(this),o=new pc(e);for(let s=r,a=r;;){if(i.next(s),o.next(s),s=0,i.lineBreak!=o.lineBreak||i.done!=o.done||i.value!=o.value)return!1;if(a+=i.value.length,i.done||a>=n)return!0}}iter(e=1){return new pc(this,e)}iterRange(e,r=this.length){return new KQ(this,e,r)}iterLines(e,r){let n;if(e==null)n=this.iter();else{r==null&&(r=this.lines+1);let i=this.line(e).from;n=this.iterRange(i,Math.max(i,r==this.lines+1?this.length:r<=1?0:this.line(r-1).to))}return new JQ(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?It.empty:e.length<=32?new Er(e):so.from(Er.split(e,[]))}}class Er extends It{constructor(e,r=Bj(e)){super(),this.text=e,this.length=r}get lines(){return this.text.length}get children(){return null}lineInner(e,r,n,i){for(let o=0;;o++){let s=this.text[o],a=i+s.length;if((r?n:a)>=e)return new Lj(i,a,n,s);i=a+1,n++}}decompose(e,r,n,i){let o=e<=0&&r>=this.length?this:new Er(nS(this.text,e,r),Math.min(r,this.length)-Math.max(0,e));if(i&1){let s=n.pop(),a=Td(o.text,s.text.slice(),0,o.length);if(a.length<=32)n.push(new Er(a,s.length+o.length));else{let l=a.length>>1;n.push(new Er(a.slice(0,l)),new Er(a.slice(l)))}}else n.push(o)}replace(e,r,n){if(!(n instanceof Er))return super.replace(e,r,n);[e,r]=Bl(this,e,r);let i=Td(this.text,Td(n.text,nS(this.text,0,e)),r),o=this.length+n.length-(r-e);return i.length<=32?new Er(i,o):so.from(Er.split(i,[]),o)}sliceString(e,r=this.length,n=`
|
|
69
69
|
`){[e,r]=Bl(this,e,r);let i="";for(let o=0,s=0;o<=r&&s<this.text.length;s++){let a=this.text[s],l=o+a.length;o>e&&s&&(i+=n),e<l&&r>o&&(i+=a.slice(Math.max(0,e-o),r-o)),o=l+1}return i}flatten(e){for(let r of this.text)e.push(r)}scanIdentical(){return 0}static split(e,r){let n=[],i=-1;for(let o of e)n.push(o),i+=o.length+1,n.length==32&&(r.push(new Er(n,i)),n=[],i=-1);return i>-1&&r.push(new Er(n,i)),r}}class so extends It{constructor(e,r){super(),this.children=e,this.length=r,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,r,n,i){for(let o=0;;o++){let s=this.children[o],a=i+s.length,l=n+s.lines-1;if((r?l:a)>=e)return s.lineInner(e,r,n,i);i=a+1,n=l+1}}decompose(e,r,n,i){for(let o=0,s=0;s<=r&&o<this.children.length;o++){let a=this.children[o],l=s+a.length;if(e<=l&&r>=s){let c=i&((s<=e?1:0)|(l>=r?2:0));s>=e&&l<=r&&!c?n.push(a):a.decompose(e-s,r-s,n,c)}s=l+1}}replace(e,r,n){if([e,r]=Bl(this,e,r),n.lines<this.lines)for(let i=0,o=0;i<this.children.length;i++){let s=this.children[i],a=o+s.length;if(e>=o&&r<=a){let l=s.replace(e-o,r-o,n),c=this.lines-s.lines+l.lines;if(l.lines<c>>4&&l.lines>c>>6){let u=this.children.slice();return u[i]=l,new so(u,this.length-(r-e)+n.length)}return super.replace(o,a,l)}o=a+1}return super.replace(e,r,n)}sliceString(e,r=this.length,n=`
|
|
70
70
|
`){[e,r]=Bl(this,e,r);let i="";for(let o=0,s=0;o<this.children.length&&s<=r;o++){let a=this.children[o],l=s+a.length;s>e&&o&&(i+=n),e<l&&r>s&&(i+=a.sliceString(e-s,r-s,n)),s=l+1}return i}flatten(e){for(let r of this.children)r.flatten(e)}scanIdentical(e,r){if(!(e instanceof so))return 0;let n=0,[i,o,s,a]=r>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=r,o+=r){if(i==s||o==a)return n;let l=this.children[i],c=e.children[o];if(l!=c)return n+l.scanIdentical(c,r);n+=l.length+1}}static from(e,r=e.reduce((n,i)=>n+i.length+1,-1)){let n=0;for(let d of e)n+=d.lines;if(n<32){let d=[];for(let p of e)p.flatten(d);return new Er(d,r)}let i=Math.max(32,n>>5),o=i<<1,s=i>>1,a=[],l=0,c=-1,u=[];function f(d){let p;if(d.lines>o&&d instanceof so)for(let O of d.children)f(O);else d.lines>s&&(l>s||!l)?(h(),a.push(d)):d instanceof Er&&l&&(p=u[u.length-1])instanceof Er&&d.lines+p.lines<=32?(l+=d.lines,c+=d.length+1,u[u.length-1]=new Er(p.text.concat(d.text),p.length+1+d.length)):(l+d.lines>i&&h(),l+=d.lines,c+=d.length+1,u.push(d))}function h(){l!=0&&(a.push(u.length==1?u[0]:so.from(u,c)),c=-1,l=u.length=0)}for(let d of e)f(d);return h(),a.length==1?a[0]:new so(a,r)}}It.empty=new Er([""],0);function Bj(t){let e=-1;for(let r of t)e+=r.length+1;return e}function Td(t,e,r=0,n=1e9){for(let i=0,o=0,s=!0;o<t.length&&i<=n;o++){let a=t[o],l=i+a.length;l>=r&&(l>n&&(a=a.slice(0,n-i)),i<r&&(a=a.slice(r-i)),s?(e[e.length-1]+=a,s=!1):e.push(a)),i=l+1}return e}function nS(t,e,r){return Td(t,[""],e,r)}class pc{constructor(e,r=1){this.dir=r,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[r>0?1:(e instanceof Er?e.text.length:e.children.length)<<1]}nextInner(e,r){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,i=this.nodes[n],o=this.offsets[n],s=o>>1,a=i instanceof Er?i.text.length:i.children.length;if(s==(r>0?a:0)){if(n==0)return this.done=!0,this.value="",this;r>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((o&1)==(r>0?0:1)){if(this.offsets[n]+=r,e==0)return this.lineBreak=!0,this.value=`
|
|
71
71
|
`,this;e--}else if(i instanceof Er){let l=i.text[s+(r<0?-1:0)];if(this.offsets[n]+=r,l.length>Math.max(0,e))return this.value=e==0?l:r>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=i.children[s+(r<0?-1:0)];e>l.length?(e-=l.length,this.offsets[n]+=r):(r<0&&this.offsets[n]--,this.nodes.push(l),this.offsets.push(r>0?1:(l instanceof Er?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class KQ{constructor(e,r,n){this.value="",this.done=!1,this.cursor=new pc(e,r>n?-1:1),this.pos=r>n?e.length:0,this.from=Math.min(r,n),this.to=Math.max(r,n)}nextInner(e,r){if(r<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,r<0?this.pos-this.to:this.from-this.pos);let n=r<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*r,this.value=i.length<=n?i:r<0?i.slice(i.length-n):i.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class JQ{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:r,lineBreak:n,value:i}=this.inner.next(e);return r&&this.afterBreak?(this.value="",this.afterBreak=!1):r?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(It.prototype[Symbol.iterator]=function(){return this.iter()},pc.prototype[Symbol.iterator]=KQ.prototype[Symbol.iterator]=JQ.prototype[Symbol.iterator]=function(){return this});let Lj=class{constructor(e,r,n,i){this.from=e,this.to=r,this.number=n,this.text=i}get length(){return this.to-this.from}};function Bl(t,e,r){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,r))]}let xl="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=1;t<xl.length;t++)xl[t]+=xl[t-1];function Vj(t){for(let e=1;e<xl.length;e+=2)if(xl[e]>t)return xl[e-1]<=t;return!1}function iS(t){return t>=127462&&t<=127487}const oS=8205;function ln(t,e,r=!0,n=!0){return(r?eE:Xj)(t,e,n)}function eE(t,e,r){if(e==t.length)return e;e&&tE(t.charCodeAt(e))&&rE(t.charCodeAt(e-1))&&e--;let n=on(t,e);for(e+=hi(n);e<t.length;){let i=on(t,e);if(n==oS||i==oS||r&&Vj(i))e+=hi(i),n=i;else if(iS(i)){let o=0,s=e-2;for(;s>=0&&iS(on(t,s));)o++,s-=2;if(o%2==0)break;e+=2}else break}return e}function Xj(t,e,r){for(;e>0;){let n=eE(t,e-2,r);if(n<e)return n;e--}return 0}function tE(t){return t>=56320&&t<57344}function rE(t){return t>=55296&&t<56320}function on(t,e){let r=t.charCodeAt(e);if(!rE(r)||e+1==t.length)return r;let n=t.charCodeAt(e+1);return tE(n)?(r-55296<<10)+(n-56320)+65536:r}function k0(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function hi(t){return t<65536?1:2}const oy=/\r\n?|\n/;var Xr=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(Xr||(Xr={}));class ho{constructor(e){this.sections=e}get length(){let e=0;for(let r=0;r<this.sections.length;r+=2)e+=this.sections[r];return e}get newLength(){let e=0;for(let r=0;r<this.sections.length;r+=2){let n=this.sections[r+1];e+=n<0?this.sections[r]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let r=0,n=0,i=0;r<this.sections.length;){let o=this.sections[r++],s=this.sections[r++];s<0?(e(n,i,o),i+=o):i+=s,n+=o}}iterChangedRanges(e,r=!1){sy(this,e,r)}get invertedDesc(){let e=[];for(let r=0;r<this.sections.length;){let n=this.sections[r++],i=this.sections[r++];i<0?e.push(n,i):e.push(i,n)}return new ho(e)}composeDesc(e){return this.empty?e:e.empty?this:nE(this,e)}mapDesc(e,r=!1){return e.empty?this:ay(this,e,r)}mapPos(e,r=-1,n=Xr.Simple){let i=0,o=0;for(let s=0;s<this.sections.length;){let a=this.sections[s++],l=this.sections[s++],c=i+a;if(l<0){if(c>e)return o+(e-i);o+=a}else{if(n!=Xr.Simple&&c>=e&&(n==Xr.TrackDel&&i<e&&c>e||n==Xr.TrackBefore&&i<e||n==Xr.TrackAfter&&c>e))return null;if(c>e||c==e&&r<0&&!a)return e==i||r<0?o:o+l;o+=l}i=c}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return o}touchesRange(e,r=e){for(let n=0,i=0;n<this.sections.length&&i<=r;){let o=this.sections[n++],s=this.sections[n++],a=i+o;if(s>=0&&i<=r&&a>=e)return i<e&&a>r?"cover":!0;i=a}return!1}toString(){let e="";for(let r=0;r<this.sections.length;){let n=this.sections[r++],i=this.sections[r++];e+=(e?" ":"")+n+(i>=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(r=>typeof r!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new ho(e)}static create(e){return new ho(e)}}class Vr extends ho{constructor(e,r){super(e),this.inserted=r}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return sy(this,(r,n,i,o,s)=>e=e.replace(i,i+(n-r),s),!1),e}mapDesc(e,r=!1){return ay(this,e,r,!0)}invert(e){let r=this.sections.slice(),n=[];for(let i=0,o=0;i<r.length;i+=2){let s=r[i],a=r[i+1];if(a>=0){r[i]=a,r[i+1]=s;let l=i>>1;for(;n.length<l;)n.push(It.empty);n.push(s?e.slice(o,o+s):It.empty)}o+=s}return new Vr(r,n)}compose(e){return this.empty?e:e.empty?this:nE(this,e,!0)}map(e,r=!1){return e.empty?this:ay(this,e,r,!0)}iterChanges(e,r=!1){sy(this,e,r)}get desc(){return ho.create(this.sections)}filter(e){let r=[],n=[],i=[],o=new Zc(this);e:for(let s=0,a=0;;){let l=s==e.length?1e9:e[s++];for(;a<l||a==l&&o.len==0;){if(o.done)break e;let u=Math.min(o.len,l-a);gn(i,u,-1);let f=o.ins==-1?-1:o.off==0?o.ins:0;gn(r,u,f),f>0&&rs(n,r,o.text),o.forward(u),a+=u}let c=e[s++];for(;a<c;){if(o.done)break e;let u=Math.min(o.len,c-a);gn(r,u,-1),gn(i,u,o.ins==-1?-1:o.off==0?o.ins:0),o.forward(u),a+=u}}return{changes:new Vr(r,n),filtered:ho.create(i)}}toJSON(){let e=[];for(let r=0;r<this.sections.length;r+=2){let n=this.sections[r],i=this.sections[r+1];i<0?e.push(n):i==0?e.push([n]):e.push([n].concat(this.inserted[r>>1].toJSON()))}return e}static of(e,r,n){let i=[],o=[],s=0,a=null;function l(u=!1){if(!u&&!i.length)return;s<r&&gn(i,r-s,-1);let f=new Vr(i,o);a=a?a.compose(f.map(a)):f,i=[],o=[],s=0}function c(u){if(Array.isArray(u))for(let f of u)c(f);else if(u instanceof Vr){if(u.length!=r)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${r})`);l(),a=a?a.compose(u.map(a)):u}else{let{from:f,to:h=f,insert:d}=u;if(f>h||f<0||h>r)throw new RangeError(`Invalid change range ${f} to ${h} (in doc of length ${r})`);let p=d?typeof d=="string"?It.of(d.split(n||oy)):d:It.empty,O=p.length;if(f==h&&O==0)return;f<s&&l(),f>s&&gn(i,f-s,-1),gn(i,h-f,O),rs(o,i,p),s=h}}return c(e),l(!a),a}static empty(e){return new Vr(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let r=[],n=[];for(let i=0;i<e.length;i++){let o=e[i];if(typeof o=="number")r.push(o,-1);else{if(!Array.isArray(o)||typeof o[0]!="number"||o.some((s,a)=>a&&typeof s!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)r.push(o[0],0);else{for(;n.length<i;)n.push(It.empty);n[i]=It.of(o.slice(1)),r.push(o[0],n[i].length)}}}return new Vr(r,n)}static createSet(e,r){return new Vr(e,r)}}function gn(t,e,r,n=!1){if(e==0&&r<=0)return;let i=t.length-2;i>=0&&r<=0&&r==t[i+1]?t[i]+=e:e==0&&t[i]==0?t[i+1]+=r:n?(t[i]+=e,t[i+1]+=r):t.push(e,r)}function rs(t,e,r){if(r.length==0)return;let n=e.length-2>>1;if(n<t.length)t[t.length-1]=t[t.length-1].append(r);else{for(;t.length<n;)t.push(It.empty);t.push(r)}}function sy(t,e,r){let n=t.inserted;for(let i=0,o=0,s=0;s<t.sections.length;){let a=t.sections[s++],l=t.sections[s++];if(l<0)i+=a,o+=a;else{let c=i,u=o,f=It.empty;for(;c+=a,u+=l,l&&n&&(f=f.append(n[s-2>>1])),!(r||s==t.sections.length||t.sections[s+1]<0);)a=t.sections[s++],l=t.sections[s++];e(i,c,o,u,f),i=c,o=u}}}function ay(t,e,r,n=!1){let i=[],o=n?[]:null,s=new Zc(t),a=new Zc(e);for(let l=-1;;)if(s.ins==-1&&a.ins==-1){let c=Math.min(s.len,a.len);gn(i,c,-1),s.forward(c),a.forward(c)}else if(a.ins>=0&&(s.ins<0||l==s.i||s.off==0&&(a.len<s.len||a.len==s.len&&!r))){let c=a.len;for(gn(i,a.ins,-1);c;){let u=Math.min(s.len,c);s.ins>=0&&l<s.i&&s.len<=u&&(gn(i,0,s.ins),o&&rs(o,i,s.text),l=s.i),s.forward(u),c-=u}a.next()}else if(s.ins>=0){let c=0,u=s.len;for(;u;)if(a.ins==-1){let f=Math.min(u,a.len);c+=f,u-=f,a.forward(f)}else if(a.ins==0&&a.len<u)u-=a.len,a.next();else break;gn(i,c,l<s.i?s.ins:0),o&&l<s.i&&rs(o,i,s.text),l=s.i,s.forward(s.len-u)}else{if(s.done&&a.done)return o?Vr.createSet(i,o):ho.create(i);throw new Error("Mismatched change set lengths")}}function nE(t,e,r=!1){let n=[],i=r?[]:null,o=new Zc(t),s=new Zc(e);for(let a=!1;;){if(o.done&&s.done)return i?Vr.createSet(n,i):ho.create(n);if(o.ins==0)gn(n,o.len,0,a),o.next();else if(s.len==0&&!s.done)gn(n,0,s.ins,a),i&&rs(i,n,s.text),s.next();else{if(o.done||s.done)throw new Error("Mismatched change set lengths");{let l=Math.min(o.len2,s.len),c=n.length;if(o.ins==-1){let u=s.ins==-1?-1:s.off?0:s.ins;gn(n,l,u,a),i&&u&&rs(i,n,s.text)}else s.ins==-1?(gn(n,o.off?0:o.len,l,a),i&&rs(i,n,o.textBit(l))):(gn(n,o.off?0:o.len,s.off?0:s.ins,a),i&&!s.off&&rs(i,n,s.text));a=(o.ins>l||s.ins>=0&&s.len>l)&&(a||n.length>c),o.forward2(l),s.forward(l)}}}}class Zc{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,r=this.i-2>>1;return r>=e.length?It.empty:e[r]}textBit(e){let{inserted:r}=this.set,n=this.i-2>>1;return n>=r.length&&!e?It.empty:r[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class sa{constructor(e,r,n){this.from=e,this.to=r,this.flags=n}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,r=-1){let n,i;return this.empty?n=i=e.mapPos(this.from,r):(n=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),n==this.from&&i==this.to?this:new sa(n,i,this.flags)}extend(e,r=e){if(e<=this.anchor&&r>=this.anchor)return oe.range(e,r);let n=Math.abs(e-this.anchor)>Math.abs(r-this.anchor)?e:r;return oe.range(this.anchor,n)}eq(e,r=!1){return this.anchor==e.anchor&&this.head==e.head&&(!r||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return oe.range(e.anchor,e.head)}static create(e,r,n){return new sa(e,r,n)}}class oe{constructor(e,r){this.ranges=e,this.mainIndex=r}map(e,r=-1){return e.empty?this:oe.create(this.ranges.map(n=>n.map(e,r)),this.mainIndex)}eq(e,r=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],r))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new oe([this.main],0)}addRange(e,r=!0){return oe.create([e].concat(this.ranges),r?0:this.mainIndex+1)}replaceRange(e,r=this.mainIndex){let n=this.ranges.slice();return n[r]=e,oe.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new oe(e.ranges.map(r=>sa.fromJSON(r)),e.main)}static single(e,r=e){return new oe([oe.range(e,r)],0)}static create(e,r=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,i=0;i<e.length;i++){let o=e[i];if(o.empty?o.from<=n:o.from<n)return oe.normalized(e.slice(),r);n=o.to}return new oe(e,r)}static cursor(e,r=0,n,i){return sa.create(e,e,(r==0?0:r<0?8:16)|(n==null?7:Math.min(6,n))|(i??16777215)<<6)}static range(e,r,n,i){let o=(n??16777215)<<6|(i==null?7:Math.min(6,i));return r<e?sa.create(r,e,48|o):sa.create(e,r,(r>e?8:0)|o)}static normalized(e,r=0){let n=e[r];e.sort((i,o)=>i.from-o.from),r=e.indexOf(n);for(let i=1;i<e.length;i++){let o=e[i],s=e[i-1];if(o.empty?o.from<=s.to:o.from<s.to){let a=s.from,l=Math.max(o.to,s.to);i<=r&&r--,e.splice(--i,2,o.anchor>o.head?oe.range(l,a):oe.range(a,l))}}return new oe(e,r)}}function iE(t,e){for(let r of t.ranges)if(r.to>e)throw new RangeError("Selection points outside of document")}let x0=0;class Ze{constructor(e,r,n,i,o){this.combine=e,this.compareInput=r,this.compare=n,this.isStatic=i,this.id=x0++,this.default=e([]),this.extensions=typeof o=="function"?o(this):o}get reader(){return this}static define(e={}){return new Ze(e.combine||(r=>r),e.compareInput||((r,n)=>r===n),e.compare||(e.combine?(r,n)=>r===n:_0),!!e.static,e.enables)}of(e){return new Rd([],this,0,e)}compute(e,r){if(this.isStatic)throw new Error("Can't compute a static facet");return new Rd(e,this,1,r)}computeN(e,r){if(this.isStatic)throw new Error("Can't compute a static facet");return new Rd(e,this,2,r)}from(e,r){return r||(r=n=>n),this.compute([e],n=>r(n.field(e)))}}function _0(t,e){return t==e||t.length==e.length&&t.every((r,n)=>r===e[n])}class Rd{constructor(e,r,n,i){this.dependencies=e,this.facet=r,this.type=n,this.value=i,this.id=x0++}dynamicSlot(e){var r;let n=this.value,i=this.facet.compareInput,o=this.id,s=e[o]>>1,a=this.type==2,l=!1,c=!1,u=[];for(let f of this.dependencies)f=="doc"?l=!0:f=="selection"?c=!0:((r=e[f.id])!==null&&r!==void 0?r:1)&1||u.push(e[f.id]);return{create(f){return f.values[s]=n(f),1},update(f,h){if(l&&h.docChanged||c&&(h.docChanged||h.selection)||ly(f,u)){let d=n(f);if(a?!sS(d,f.values[s],i):!i(d,f.values[s]))return f.values[s]=d,1}return 0},reconfigure:(f,h)=>{let d,p=h.config.address[o];if(p!=null){let O=Sp(h,p);if(this.dependencies.every(m=>m instanceof Ze?h.facet(m)===f.facet(m):m instanceof Fr?h.field(m,!1)==f.field(m,!1):!0)||(a?sS(d=n(f),O,i):i(d=n(f),O)))return f.values[s]=O,0}else d=n(f);return f.values[s]=d,1}}}}function sS(t,e,r){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!r(t[n],e[n]))return!1;return!0}function ly(t,e){let r=!1;for(let n of e)Oc(t,n)&1&&(r=!0);return r}function Yj(t,e,r){let n=r.map(l=>t[l.id]),i=r.map(l=>l.type),o=n.filter(l=>!(l&1)),s=t[e.id]>>1;function a(l){let c=[];for(let u=0;u<n.length;u++){let f=Sp(l,n[u]);if(i[u]==2)for(let h of f)c.push(h);else c.push(f)}return e.combine(c)}return{create(l){for(let c of n)Oc(l,c);return l.values[s]=a(l),1},update(l,c){if(!ly(l,o))return 0;let u=a(l);return e.compare(u,l.values[s])?0:(l.values[s]=u,1)},reconfigure(l,c){let u=ly(l,n),f=c.config.facets[e.id],h=c.facet(e);if(f&&!u&&_0(r,f))return l.values[s]=h,0;let d=a(l);return e.compare(d,h)?(l.values[s]=h,0):(l.values[s]=d,1)}}}const aS=Ze.define({static:!0});class Fr{constructor(e,r,n,i,o){this.id=e,this.createF=r,this.updateF=n,this.compareF=i,this.spec=o,this.provides=void 0}static define(e){let r=new Fr(x0++,e.create,e.update,e.compare||((n,i)=>n===i),e);return e.provide&&(r.provides=e.provide(r)),r}create(e){let r=e.facet(aS).find(n=>n.field==this);return((r==null?void 0:r.create)||this.createF)(e)}slot(e){let r=e[this.id]>>1;return{create:n=>(n.values[r]=this.create(n),1),update:(n,i)=>{let o=n.values[r],s=this.updateF(o,i);return this.compareF(o,s)?0:(n.values[r]=s,1)},reconfigure:(n,i)=>i.config.address[this.id]!=null?(n.values[r]=i.field(this),0):(n.values[r]=this.create(n),1)}}init(e){return[this,aS.of({field:this,create:e})]}get extension(){return this}}const Js={lowest:4,low:3,default:2,high:1,highest:0};function _u(t){return e=>new oE(e,t)}const Do={highest:_u(Js.highest),high:_u(Js.high),default:_u(Js.default),low:_u(Js.low),lowest:_u(Js.lowest)};class oE{constructor(e,r){this.inner=e,this.prec=r}}class Ll{of(e){return new uy(this,e)}reconfigure(e){return Ll.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class uy{constructor(e,r){this.compartment=e,this.inner=r}}class wp{constructor(e,r,n,i,o,s){for(this.base=e,this.compartments=r,this.dynamicSlots=n,this.address=i,this.staticValues=o,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let r=this.address[e.id];return r==null?e.default:this.staticValues[r>>1]}static resolve(e,r,n){let i=[],o=Object.create(null),s=new Map;for(let h of Uj(e,r,s))h instanceof Fr?i.push(h):(o[h.facet.id]||(o[h.facet.id]=[])).push(h);let a=Object.create(null),l=[],c=[];for(let h of i)a[h.id]=c.length<<1,c.push(d=>h.slot(d));let u=n==null?void 0:n.config.facets;for(let h in o){let d=o[h],p=d[0].facet,O=u&&u[h]||[];if(d.every(m=>m.type==0))if(a[p.id]=l.length<<1|1,_0(O,d))l.push(n.facet(p));else{let m=p.combine(d.map(y=>y.value));l.push(n&&p.compare(m,n.facet(p))?n.facet(p):m)}else{for(let m of d)m.type==0?(a[m.id]=l.length<<1|1,l.push(m.value)):(a[m.id]=c.length<<1,c.push(y=>m.dynamicSlot(y)));a[p.id]=c.length<<1,c.push(m=>Yj(m,p,d))}}let f=c.map(h=>h(a));return new wp(e,s,f,a,l,o)}}function Uj(t,e,r){let n=[[],[],[],[],[]],i=new Map;function o(s,a){let l=i.get(s);if(l!=null){if(l<=a)return;let c=n[l].indexOf(s);c>-1&&n[l].splice(c,1),s instanceof uy&&r.delete(s.compartment)}if(i.set(s,a),Array.isArray(s))for(let c of s)o(c,a);else if(s instanceof uy){if(r.has(s.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(s.compartment)||s.inner;r.set(s.compartment,c),o(c,a)}else if(s instanceof oE)o(s.inner,s.prec);else if(s instanceof Fr)n[a].push(s),s.provides&&o(s.provides,a);else if(s instanceof Rd)n[a].push(s),s.facet.extensions&&o(s.facet.extensions,Js.default);else{let c=s.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${s}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(c,a)}}return o(t,Js.default),n.reduce((s,a)=>s.concat(a))}function Oc(t,e){if(e&1)return 2;let r=e>>1,n=t.status[r];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;t.status[r]=4;let i=t.computeSlot(t,t.config.dynamicSlots[r]);return t.status[r]=2|i}function Sp(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const sE=Ze.define(),cy=Ze.define({combine:t=>t.some(e=>e),static:!0}),aE=Ze.define({combine:t=>t.length?t[0]:void 0,static:!0}),lE=Ze.define(),uE=Ze.define(),cE=Ze.define(),fE=Ze.define({combine:t=>t.length?t[0]:!1});class Oo{constructor(e,r){this.type=e,this.value=r}static define(){return new Fj}}class Fj{of(e){return new Oo(this,e)}}class zj{constructor(e){this.map=e}of(e){return new mt(this,e)}}class mt{constructor(e,r){this.type=e,this.value=r}map(e){let r=this.type.map(this.value,e);return r===void 0?void 0:r==this.value?this:new mt(this.type,r)}is(e){return this.type==e}static define(e={}){return new zj(e.map||(r=>r))}static mapEffects(e,r){if(!e.length)return e;let n=[];for(let i of e){let o=i.map(r);o&&n.push(o)}return n}}mt.reconfigure=mt.define();mt.appendConfig=mt.define();class Dr{constructor(e,r,n,i,o,s){this.startState=e,this.changes=r,this.selection=n,this.effects=i,this.annotations=o,this.scrollIntoView=s,this._doc=null,this._state=null,n&&iE(n,r.newLength),o.some(a=>a.type==Dr.time)||(this.annotations=o.concat(Dr.time.of(Date.now())))}static create(e,r,n,i,o,s){return new Dr(e,r,n,i,o,s)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let r of this.annotations)if(r.type==e)return r.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let r=this.annotation(Dr.userEvent);return!!(r&&(r==e||r.length>e.length&&r.slice(0,e.length)==e&&r[e.length]=="."))}}Dr.time=Oo.define();Dr.userEvent=Oo.define();Dr.addToHistory=Oo.define();Dr.remote=Oo.define();function Gj(t,e){let r=[];for(let n=0,i=0;;){let o,s;if(n<t.length&&(i==e.length||e[i]>=t[n]))o=t[n++],s=t[n++];else if(i<e.length)o=e[i++],s=e[i++];else return r;!r.length||r[r.length-1]<o?r.push(o,s):r[r.length-1]<s&&(r[r.length-1]=s)}}function hE(t,e,r){var n;let i,o,s;return r?(i=e.changes,o=Vr.empty(e.changes.length),s=t.changes.compose(e.changes)):(i=e.changes.map(t.changes),o=t.changes.mapDesc(e.changes,!0),s=t.changes.compose(i)),{changes:s,selection:e.selection?e.selection.map(o):(n=t.selection)===null||n===void 0?void 0:n.map(i),effects:mt.mapEffects(t.effects,i).concat(mt.mapEffects(e.effects,o)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function fy(t,e,r){let n=e.selection,i=_l(e.annotations);return e.userEvent&&(i=i.concat(Dr.userEvent.of(e.userEvent))),{changes:e.changes instanceof Vr?e.changes:Vr.of(e.changes||[],r,t.facet(aE)),selection:n&&(n instanceof oe?n:oe.single(n.anchor,n.head)),effects:_l(e.effects),annotations:i,scrollIntoView:!!e.scrollIntoView}}function dE(t,e,r){let n=fy(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(r=!1);for(let o=1;o<e.length;o++){e[o].filter===!1&&(r=!1);let s=!!e[o].sequential;n=hE(n,fy(t,e[o],s?n.changes.newLength:t.doc.length),s)}let i=Dr.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return Kj(r?Hj(i):i)}function Hj(t){let e=t.startState,r=!0;for(let i of e.facet(lE)){let o=i(t);if(o===!1){r=!1;break}Array.isArray(o)&&(r=r===!0?o:Gj(r,o))}if(r!==!0){let i,o;if(r===!1)o=t.changes.invertedDesc,i=Vr.empty(e.doc.length);else{let s=t.changes.filter(r);i=s.changes,o=s.filtered.mapDesc(s.changes).invertedDesc}t=Dr.create(e,i,t.selection&&t.selection.map(o),mt.mapEffects(t.effects,o),t.annotations,t.scrollIntoView)}let n=e.facet(uE);for(let i=n.length-1;i>=0;i--){let o=n[i](t);o instanceof Dr?t=o:Array.isArray(o)&&o.length==1&&o[0]instanceof Dr?t=o[0]:t=dE(e,_l(o),!1)}return t}function Kj(t){let e=t.startState,r=e.facet(cE),n=t;for(let i=r.length-1;i>=0;i--){let o=r[i](t);o&&Object.keys(o).length&&(n=hE(n,fy(e,o,t.changes.newLength),!0))}return n==t?t:Dr.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}const Jj=[];function _l(t){return t==null?Jj:Array.isArray(t)?t:[t]}var gr=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(gr||(gr={}));const eD=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let hy;try{hy=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function tD(t){if(hy)return hy.test(t);for(let e=0;e<t.length;e++){let r=t[e];if(/\w/.test(r)||r>""&&(r.toUpperCase()!=r.toLowerCase()||eD.test(r)))return!0}return!1}function rD(t){return e=>{if(!/\S/.test(e))return gr.Space;if(tD(e))return gr.Word;for(let r=0;r<t.length;r++)if(e.indexOf(t[r])>-1)return gr.Word;return gr.Other}}class jt{constructor(e,r,n,i,o,s){this.config=e,this.doc=r,this.selection=n,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=o,s&&(s._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)Oc(this,a<<1);this.computeSlot=null}field(e,r=!0){let n=this.config.address[e.id];if(n==null){if(r)throw new RangeError("Field is not present in this state");return}return Oc(this,n),Sp(this,n)}update(...e){return dE(this,e,!0)}applyTransaction(e){let r=this.config,{base:n,compartments:i}=r;for(let a of e.effects)a.is(Ll.reconfigure)?(r&&(i=new Map,r.compartments.forEach((l,c)=>i.set(c,l)),r=null),i.set(a.value.compartment,a.value.extension)):a.is(mt.reconfigure)?(r=null,n=a.value):a.is(mt.appendConfig)&&(r=null,n=_l(n).concat(a.value));let o;r?o=e.startState.values.slice():(r=wp.resolve(n,i,this),o=new jt(r,this.doc,this.selection,r.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let s=e.startState.facet(cy)?e.newSelection:e.newSelection.asSingle();new jt(r,e.newDoc,s,o,(a,l)=>l.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:e},range:oe.cursor(r.from+e.length)}))}changeByRange(e){let r=this.selection,n=e(r.ranges[0]),i=this.changes(n.changes),o=[n.range],s=_l(n.effects);for(let a=1;a<r.ranges.length;a++){let l=e(r.ranges[a]),c=this.changes(l.changes),u=c.map(i);for(let h=0;h<a;h++)o[h]=o[h].map(u);let f=i.mapDesc(c,!0);o.push(l.range.map(f)),i=i.compose(u),s=mt.mapEffects(s,u).concat(mt.mapEffects(_l(l.effects),f))}return{changes:i,selection:oe.create(o,r.mainIndex),effects:s}}changes(e=[]){return e instanceof Vr?e:Vr.of(e,this.doc.length,this.facet(jt.lineSeparator))}toText(e){return It.of(e.split(this.facet(jt.lineSeparator)||oy))}sliceDoc(e=0,r=this.doc.length){return this.doc.sliceString(e,r,this.lineBreak)}facet(e){let r=this.config.address[e.id];return r==null?e.default:(Oc(this,r),Sp(this,r))}toJSON(e){let r={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let i=e[n];i instanceof Fr&&this.config.address[i.id]!=null&&(r[n]=i.spec.toJSON(this.field(e[n]),this))}return r}static fromJSON(e,r={},n){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(n){for(let o in n)if(Object.prototype.hasOwnProperty.call(e,o)){let s=n[o],a=e[o];i.push(s.init(l=>s.spec.fromJSON(a,l)))}}return jt.create({doc:e.doc,selection:oe.fromJSON(e.selection),extensions:r.extensions?i.concat([r.extensions]):i})}static create(e={}){let r=wp.resolve(e.extensions||[],new Map),n=e.doc instanceof It?e.doc:It.of((e.doc||"").split(r.staticFacet(jt.lineSeparator)||oy)),i=e.selection?e.selection instanceof oe?e.selection:oe.single(e.selection.anchor,e.selection.head):oe.single(0);return iE(i,n.length),r.staticFacet(cy)||(i=i.asSingle()),new jt(r,n,i,r.dynamicSlots.map(()=>null),(o,s)=>s.create(o),null)}get tabSize(){return this.facet(jt.tabSize)}get lineBreak(){return this.facet(jt.lineSeparator)||`
|