vzcode 0.55.0 → 0.56.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
  `))):rt=Y.stylize("[Circular]","special")),T(qe)){if(Me&&Ae.match(/^\d+$/))return rt;qe=JSON.stringify(""+Ae),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+": "+rt}function S(Y,F,J){var be=Y.reduce(function(Ae,Me){return Me.indexOf(`
66
66
  `)>=0,Ae+Me.replace(/\u001b\[\d\d?m/g,"").length+1},0);return be>60?J[0]+(F===""?"":F+`
67
67
  `)+" "+Y.join(`,
68
- `)+" "+J[1]:J[0]+F+" "+Y.join(", ")+" "+J[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 $(Y){return Y===null}i.isNull=$;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 Q(Y){return typeof Y=="symbol"}i.isSymbol=Q;function T(Y){return Y===void 0}i.isUndefined=T;function D(Y){return I(Y)&&X(Y)==="[object RegExp]"}i.isRegExp=D,i.types.isRegExp=D;function I(Y){return typeof Y=="object"&&Y!==null}i.isObject=I;function G(Y){return I(Y)&&X(Y)==="[object Date]"}i.isDate=G,i.types.isDate=G;function M(Y){return I(Y)&&(X(Y)==="[object Error]"||Y instanceof Error)}i.isError=M,i.types.isNativeError=M;function N(Y){return typeof Y=="function"}i.isFunction=N;function j(Y){return Y===null||typeof Y=="boolean"||typeof Y=="number"||typeof Y=="string"||typeof Y=="symbol"||typeof Y>"u"}i.isPrimitive=j,i.isBuffer=r("./support/isBuffer");function X(Y){return Object.prototype.toString.call(Y)}function U(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 pe(){var Y=new Date,F=[U(Y.getHours()),U(Y.getMinutes()),U(Y.getSeconds())].join(":");return[Y.getDate(),le[Y.getMonth()],F].join(" ")}i.log=function(){console.log("%s - %s",pe(),i.format.apply(i,arguments))},i.inherits=r("inherits"),i._extend=function(Y,F){if(!F||!I(F))return Y;for(var J=Object.keys(F),be=J.length;be--;)Y[J[be]]=F[J[be]];return Y};function V(Y,F){return Object.prototype.hasOwnProperty.call(Y,F)}var H=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;i.promisify=function(F){if(typeof F!="function")throw new TypeError('The "original" argument must be of type Function');if(H&&F[H]){var J=F[H];if(typeof J!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(J,H,{value:J,enumerable:!1,writable:!1,configurable:!0}),J}function J(){for(var be,Ae,Me=new Promise(function(st,Et){be=st,Ae=Et}),qe=[],rt=0;rt<arguments.length;rt++)qe.push(arguments[rt]);qe.push(function(st,Et){st?Ae(st):be(Et)});try{F.apply(this,qe)}catch(st){Ae(st)}return Me}return Object.setPrototypeOf(J,Object.getPrototypeOf(F)),H&&Object.defineProperty(J,H,{value:J,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(J,s(F))},i.promisify.custom=H;function se(Y,F){if(!Y){var J=new Error("Promise was rejected with a falsy value");J.reason=Y,Y=J}return F(Y)}function Ne(Y){if(typeof Y!="function")throw new TypeError('The "original" argument must be of type Function');function F(){for(var J=[],be=0;be<arguments.length;be++)J.push(arguments[be]);var Ae=J.pop();if(typeof Ae!="function")throw new TypeError("The last argument must be of type Function");var Me=this,qe=function(){return Ae.apply(Me,arguments)};Y.apply(this,J).then(function(rt){o.nextTick(qe.bind(null,null,rt))},function(rt){o.nextTick(se.bind(null,rt,qe))})}return Object.setPrototypeOf(F,Object.getPrototypeOf(Y)),Object.defineProperties(F,s(Y)),F}i.callbackify=Ne}).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"),u=r("gopd"),c=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&&u&&m&&s(d,function(v){if(typeof h[v]=="function"){var S=new h[v];if(Symbol.toStringTag in S){var P=m(S),_=u(P,Symbol.toStringTag);if(!_){var $=m(P);_=u($,Symbol.toStringTag)}O[v]=_.get}}});var y=function(S){var P=!1;return s(O,function(_,$){if(!P)try{var b=_.call(S);b===$&&(P=b)}catch{}}),P},g=r("is-typed-array");n.exports=function(S){return g(S)?!f||!(Symbol.toStringTag in S)?p(c(S),8,-1):y(S):!1}}).call(this)}).call(this,typeof Vn<"u"?Vn: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)})})(ZQ);var nj=ZQ.exports;const ij=vi(nj),{json1Presence:m0,textUnicode:NQ}=ij;function oj(t){return new Worker("/assets/worker-Cl_j3b6K.js",{name:t==null?void 0:t.name})}function sj(t){return new Worker("/assets/worker--Fv7mJZP.js",{name:t==null?void 0:t.name})}const aj=!0,Fw=800,WQ="vzCodeSidebarWidth",IQ="vzCodeCodeEditorWidth",BQ=220;let hO=BQ;const LQ=800;let dO=LQ,Hm=!1;if(typeof window<"u"&&aj){const t=window.localStorage.getItem(WQ),e=window.localStorage.getItem(IQ);t!==null&&(hO=+t,Hm=!0),e!==null&&(dO=+e,Hm=!0)}const lj={codeEditorWidth:dO,sidebarWidth:hO,moveSplitPane:()=>{},isDraggingRight:!1,isDraggingLeft:!1,setIsDragging:()=>{}},pO=W.createContext(lj),uj={sidebarWidth:BQ,codeEditorWidth:LQ,isDraggingLeft:!1,isDraggingRight:!1,isInitialized:!1},cj=(t,e)=>{switch(e.type){case"initialize":return{...t,sidebarWidth:hO,codeEditorWidth:dO,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}},fj=({children:t})=>{const[e,r]=W.useReducer(cj,uj),n=W.useCallback((f,h)=>{r({type:"setIsDragging",isDragging:f,side:h})},[r]),i=W.useCallback((f,h)=>{r({type:"move",movementX:f,side:h})},[r]),{sidebarWidth:o,codeEditorWidth:s,isDraggingLeft:a,isDraggingRight:l,isInitialized:u}=e;typeof window<"u"&&W.useLayoutEffect(()=>{Hm&&!u&&r({type:"initialize"})},[u]),W.useEffect(()=>{o!==hO&&setTimeout(()=>{window.localStorage.setItem(WQ,""+o)},Fw),s!==dO&&setTimeout(()=>{window.localStorage.setItem(IQ,""+s)},Fw)},[s,o]);const c={codeEditorWidth:s,sidebarWidth:o,moveSplitPane:i,isDraggingLeft:a,isDraggingRight:l,setIsDragging:n};return ee.jsx(pO.Provider,{value:c,children:t})},hj=t=>{const r=/Mac|iMac|MacBook/i.test(navigator.userAgent)?t.metaKey:t.ctrlKey;return r&&t.key==="s"?!0:!!(t.key==="F5"||r&&t.key==="Enter"||t.shiftKey&&t.key==="Enter"||t.altKey&&t.key==="Enter"||r&&t.shiftKey&&(t.key==="B"||t.key==="b")||r&&t.shiftKey&&t.key==="F10"||t.key==="F8"||t.key==="F9")},XQ=1200,dj=t=>{const e=t.match(/\.([^.]+)$/);return e?e[1]:""},pj=({shareDBDoc:t,submitOperation:e,prettierWorker:r,enableManualPretter:n})=>{const i=W.useRef(new Set),[o,s]=W.useState(null),a=W.useRef(!1);return W.useEffect(()=>{if(!t)return;const l=d=>{const{fileId:p,error:O,fileTextPrettified:m}=d.data;if(O){s(O);return}else s(null);a.current=!0,e(y=>({...y,files:{...y.files,[p]:{...y.files[p],text:m}}})),a.current=!1};r.addEventListener("message",l);const u=async()=>{const p=t.data.files,O=i.current,m=Array.from(O);O.clear();for(const y of m){const g=p[y],v={fileText:g.text,fileExtension:dj(g.name),fileId:y};r.postMessage(v)}};let c,f,h;return n?(h=d=>{hj(d)&&(d.preventDefault(),u())},document.addEventListener("keydown",h)):(c=()=>{clearTimeout(f),f=setTimeout(u,XQ)},window.addEventListener("mousemove",c),window.addEventListener("keydown",c)),t.on("op batch",(d,p)=>{if(p){if(a.current)return;if(d&&d.length===4&&d[0]==="files"&&typeof d[1]=="string"&&d[2]==="text"){const O=d[1];i.current.add(O),n||c()}}}),()=>{r.removeEventListener("message",l),n?document.removeEventListener("keydown",h):(window.removeEventListener("keydown",c),window.removeEventListener("mousemove",c),clearTimeout(f))}},[t]),{prettierError:o}},Oj=500,gj=XQ+Oj,mj=({content:t,typeScriptWorker:e})=>{const r=W.useRef(null),n=W.useCallback(i=>{i!==null&&(clearTimeout(r.current),r.current=window.setTimeout(()=>{e.postMessage({event:"update-content",details:i})},gj))},[e]);W.useEffect(()=>{n(t)},[t])},yj=(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}},vj=(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}},wj=(t,e)=>e.type==="set_active_file_id"?{...t,activeFileId:e.activeFileId}:t,Sj=(t,e)=>e.type==="set_is_settings_open"?{...t,isSettingsOpen:e.value}:t,bj=(t,e)=>e.type==="set_theme"?{...t,theme:e.themeLabel}:t,Pj=(t,e)=>e.type==="editor_no_longer_wants_focus"?{...t,editorWantsFocus:!1}:t,kj=(t,e)=>e.type==="set_username"?{...t,username:e.username}:t,xj=({defaultTheme:t,initialUsername:e="Anonymous"})=>({tabList:[],activeFileId:null,theme:t,isSettingsOpen:!1,editorWantsFocus:!1,username:e}),_j=[wj,vj,yj,bj,Sj,Pj,kj],$j=(t,e)=>_j.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]=Nl(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),io.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]=Nl(this,e,r);let n=[];return this.decompose(e,r,n,0),io.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 lc(this),o=new lc(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 lc(this,e)}iterRange(e,r=this.length){return new VQ(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 YQ(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):io.from(Er.split(e,[]))}}class Er extends It{constructor(e,r=Qj(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 Ej(i,a,n,s);i=a+1,n++}}decompose(e,r,n,i){let o=e<=0&&r>=this.length?this:new Er(zw(this.text,e,r),Math.min(r,this.length)-Math.max(0,e));if(i&1){let s=n.pop(),a=$d(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]=Nl(this,e,r);let i=$d(this.text,$d(n.text,zw(this.text,0,e)),r),o=this.length+n.length-(r-e);return i.length<=32?new Er(i,o):io.from(Er.split(i,[]),o)}sliceString(e,r=this.length,n=`
68
+ `)+" "+J[1]:J[0]+F+" "+Y.join(", ")+" "+J[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 $(Y){return Y===null}i.isNull=$;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 Q(Y){return typeof Y=="symbol"}i.isSymbol=Q;function T(Y){return Y===void 0}i.isUndefined=T;function D(Y){return I(Y)&&X(Y)==="[object RegExp]"}i.isRegExp=D,i.types.isRegExp=D;function I(Y){return typeof Y=="object"&&Y!==null}i.isObject=I;function G(Y){return I(Y)&&X(Y)==="[object Date]"}i.isDate=G,i.types.isDate=G;function M(Y){return I(Y)&&(X(Y)==="[object Error]"||Y instanceof Error)}i.isError=M,i.types.isNativeError=M;function N(Y){return typeof Y=="function"}i.isFunction=N;function j(Y){return Y===null||typeof Y=="boolean"||typeof Y=="number"||typeof Y=="string"||typeof Y=="symbol"||typeof Y>"u"}i.isPrimitive=j,i.isBuffer=r("./support/isBuffer");function X(Y){return Object.prototype.toString.call(Y)}function U(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 pe(){var Y=new Date,F=[U(Y.getHours()),U(Y.getMinutes()),U(Y.getSeconds())].join(":");return[Y.getDate(),le[Y.getMonth()],F].join(" ")}i.log=function(){console.log("%s - %s",pe(),i.format.apply(i,arguments))},i.inherits=r("inherits"),i._extend=function(Y,F){if(!F||!I(F))return Y;for(var J=Object.keys(F),be=J.length;be--;)Y[J[be]]=F[J[be]];return Y};function V(Y,F){return Object.prototype.hasOwnProperty.call(Y,F)}var H=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;i.promisify=function(F){if(typeof F!="function")throw new TypeError('The "original" argument must be of type Function');if(H&&F[H]){var J=F[H];if(typeof J!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(J,H,{value:J,enumerable:!1,writable:!1,configurable:!0}),J}function J(){for(var be,Ae,Me=new Promise(function(st,Et){be=st,Ae=Et}),qe=[],rt=0;rt<arguments.length;rt++)qe.push(arguments[rt]);qe.push(function(st,Et){st?Ae(st):be(Et)});try{F.apply(this,qe)}catch(st){Ae(st)}return Me}return Object.setPrototypeOf(J,Object.getPrototypeOf(F)),H&&Object.defineProperty(J,H,{value:J,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(J,s(F))},i.promisify.custom=H;function se(Y,F){if(!Y){var J=new Error("Promise was rejected with a falsy value");J.reason=Y,Y=J}return F(Y)}function Ne(Y){if(typeof Y!="function")throw new TypeError('The "original" argument must be of type Function');function F(){for(var J=[],be=0;be<arguments.length;be++)J.push(arguments[be]);var Ae=J.pop();if(typeof Ae!="function")throw new TypeError("The last argument must be of type Function");var Me=this,qe=function(){return Ae.apply(Me,arguments)};Y.apply(this,J).then(function(rt){o.nextTick(qe.bind(null,null,rt))},function(rt){o.nextTick(se.bind(null,rt,qe))})}return Object.setPrototypeOf(F,Object.getPrototypeOf(Y)),Object.defineProperties(F,s(Y)),F}i.callbackify=Ne}).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"),u=r("gopd"),c=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&&u&&m&&s(d,function(v){if(typeof h[v]=="function"){var S=new h[v];if(Symbol.toStringTag in S){var P=m(S),_=u(P,Symbol.toStringTag);if(!_){var $=m(P);_=u($,Symbol.toStringTag)}O[v]=_.get}}});var y=function(S){var P=!1;return s(O,function(_,$){if(!P)try{var b=_.call(S);b===$&&(P=b)}catch{}}),P},g=r("is-typed-array");n.exports=function(S){return g(S)?!f||!(Symbol.toStringTag in S)?p(c(S),8,-1):y(S):!1}}).call(this)}).call(this,typeof Vn<"u"?Vn: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)})})(ZQ);var nj=ZQ.exports;const ij=vi(nj),{json1Presence:m0,textUnicode:NQ}=ij;function oj(t){return new Worker("/assets/worker-Cl_j3b6K.js",{name:t==null?void 0:t.name})}function sj(t){return new Worker("/assets/worker-pDIx6AF9.js",{name:t==null?void 0:t.name})}const aj=!0,Fw=800,WQ="vzCodeSidebarWidth",IQ="vzCodeCodeEditorWidth",BQ=220;let hO=BQ;const LQ=800;let dO=LQ,Hm=!1;if(typeof window<"u"&&aj){const t=window.localStorage.getItem(WQ),e=window.localStorage.getItem(IQ);t!==null&&(hO=+t,Hm=!0),e!==null&&(dO=+e,Hm=!0)}const lj={codeEditorWidth:dO,sidebarWidth:hO,moveSplitPane:()=>{},isDraggingRight:!1,isDraggingLeft:!1,setIsDragging:()=>{}},pO=W.createContext(lj),uj={sidebarWidth:BQ,codeEditorWidth:LQ,isDraggingLeft:!1,isDraggingRight:!1,isInitialized:!1},cj=(t,e)=>{switch(e.type){case"initialize":return{...t,sidebarWidth:hO,codeEditorWidth:dO,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}},fj=({children:t})=>{const[e,r]=W.useReducer(cj,uj),n=W.useCallback((f,h)=>{r({type:"setIsDragging",isDragging:f,side:h})},[r]),i=W.useCallback((f,h)=>{r({type:"move",movementX:f,side:h})},[r]),{sidebarWidth:o,codeEditorWidth:s,isDraggingLeft:a,isDraggingRight:l,isInitialized:u}=e;typeof window<"u"&&W.useLayoutEffect(()=>{Hm&&!u&&r({type:"initialize"})},[u]),W.useEffect(()=>{o!==hO&&setTimeout(()=>{window.localStorage.setItem(WQ,""+o)},Fw),s!==dO&&setTimeout(()=>{window.localStorage.setItem(IQ,""+s)},Fw)},[s,o]);const c={codeEditorWidth:s,sidebarWidth:o,moveSplitPane:i,isDraggingLeft:a,isDraggingRight:l,setIsDragging:n};return ee.jsx(pO.Provider,{value:c,children:t})},hj=t=>{const r=/Mac|iMac|MacBook/i.test(navigator.userAgent)?t.metaKey:t.ctrlKey;return r&&t.key==="s"?!0:!!(t.key==="F5"||r&&t.key==="Enter"||t.shiftKey&&t.key==="Enter"||t.altKey&&t.key==="Enter"||r&&t.shiftKey&&(t.key==="B"||t.key==="b")||r&&t.shiftKey&&t.key==="F10"||t.key==="F8"||t.key==="F9")},XQ=1200,dj=t=>{const e=t.match(/\.([^.]+)$/);return e?e[1]:""},pj=({shareDBDoc:t,submitOperation:e,prettierWorker:r,enableManualPretter:n})=>{const i=W.useRef(new Set),[o,s]=W.useState(null),a=W.useRef(!1);return W.useEffect(()=>{if(!t)return;const l=d=>{const{fileId:p,error:O,fileTextPrettified:m}=d.data;if(O){s(O);return}else s(null);a.current=!0,e(y=>({...y,files:{...y.files,[p]:{...y.files[p],text:m}}})),a.current=!1};r.addEventListener("message",l);const u=async()=>{const p=t.data.files,O=i.current,m=Array.from(O);O.clear();for(const y of m){const g=p[y],v={fileText:g.text,fileExtension:dj(g.name),fileId:y};r.postMessage(v)}};let c,f,h;return n?(h=d=>{hj(d)&&(d.preventDefault(),u())},document.addEventListener("keydown",h)):(c=()=>{clearTimeout(f),f=setTimeout(u,XQ)},window.addEventListener("mousemove",c),window.addEventListener("keydown",c)),t.on("op batch",(d,p)=>{if(p){if(a.current)return;if(d&&d.length===4&&d[0]==="files"&&typeof d[1]=="string"&&d[2]==="text"){const O=d[1];i.current.add(O),n||c()}}}),()=>{r.removeEventListener("message",l),n?document.removeEventListener("keydown",h):(window.removeEventListener("keydown",c),window.removeEventListener("mousemove",c),clearTimeout(f))}},[t]),{prettierError:o}},Oj=500,gj=XQ+Oj,mj=({content:t,typeScriptWorker:e})=>{const r=W.useRef(null),n=W.useCallback(i=>{i!==null&&(clearTimeout(r.current),r.current=window.setTimeout(()=>{e.postMessage({event:"update-content",details:i})},gj))},[e]);W.useEffect(()=>{n(t)},[t])},yj=(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}},vj=(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}},wj=(t,e)=>e.type==="set_active_file_id"?{...t,activeFileId:e.activeFileId}:t,Sj=(t,e)=>e.type==="set_is_settings_open"?{...t,isSettingsOpen:e.value}:t,bj=(t,e)=>e.type==="set_theme"?{...t,theme:e.themeLabel}:t,Pj=(t,e)=>e.type==="editor_no_longer_wants_focus"?{...t,editorWantsFocus:!1}:t,kj=(t,e)=>e.type==="set_username"?{...t,username:e.username}:t,xj=({defaultTheme:t,initialUsername:e="Anonymous"})=>({tabList:[],activeFileId:null,theme:t,isSettingsOpen:!1,editorWantsFocus:!1,username:e}),_j=[wj,vj,yj,bj,Sj,Pj,kj],$j=(t,e)=>_j.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]=Nl(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),io.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]=Nl(this,e,r);let n=[];return this.decompose(e,r,n,0),io.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 lc(this),o=new lc(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 lc(this,e)}iterRange(e,r=this.length){return new VQ(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 YQ(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):io.from(Er.split(e,[]))}}class Er extends It{constructor(e,r=Qj(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 Ej(i,a,n,s);i=a+1,n++}}decompose(e,r,n,i){let o=e<=0&&r>=this.length?this:new Er(zw(this.text,e,r),Math.min(r,this.length)-Math.max(0,e));if(i&1){let s=n.pop(),a=$d(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]=Nl(this,e,r);let i=$d(this.text,$d(n.text,zw(this.text,0,e)),r),o=this.length+n.length-(r-e);return i.length<=32?new Er(i,o):io.from(Er.split(i,[]),o)}sliceString(e,r=this.length,n=`
69
69
  `){[e,r]=Nl(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 io 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 u=i&((s<=e?1:0)|(l>=r?2:0));s>=e&&l<=r&&!u?n.push(a):a.decompose(e-s,r-s,n,u)}s=l+1}}replace(e,r,n){if([e,r]=Nl(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),u=this.lines-s.lines+l.lines;if(l.lines<u>>4&&l.lines>u>>6){let c=this.children.slice();return c[i]=l,new io(c,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]=Nl(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 io))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],u=e.children[o];if(l!=u)return n+l.scanIdentical(u,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,u=-1,c=[];function f(d){let p;if(d.lines>o&&d instanceof io)for(let O of d.children)f(O);else d.lines>s&&(l>s||!l)?(h(),a.push(d)):d instanceof Er&&l&&(p=c[c.length-1])instanceof Er&&d.lines+p.lines<=32?(l+=d.lines,u+=d.length+1,c[c.length-1]=new Er(p.text.concat(d.text),p.length+1+d.length)):(l+d.lines>i&&h(),l+=d.lines,u+=d.length+1,c.push(d))}function h(){l!=0&&(a.push(c.length==1?c[0]:io.from(c,u)),u=-1,l=c.length=0)}for(let d of e)f(d);return h(),a.length==1?a[0]:new io(a,r)}}It.empty=new Er([""],0);function Qj(t){let e=-1;for(let r of t)e+=r.length+1;return e}function $d(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 zw(t,e,r){return $d(t,[""],e,r)}class lc{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 VQ{constructor(e,r,n){this.value="",this.done=!1,this.cursor=new lc(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 YQ{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()},lc.prototype[Symbol.iterator]=VQ.prototype[Symbol.iterator]=YQ.prototype[Symbol.iterator]=function(){return this});let Ej=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 Nl(t,e,r){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,r))]}let bl="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<bl.length;t++)bl[t]+=bl[t-1];function Tj(t){for(let e=1;e<bl.length;e+=2)if(bl[e]>t)return bl[e-1]<=t;return!1}function Gw(t){return t>=127462&&t<=127487}const Hw=8205;function an(t,e,r=!0,n=!0){return(r?UQ:Cj)(t,e,n)}function UQ(t,e,r){if(e==t.length)return e;e&&FQ(t.charCodeAt(e))&&zQ(t.charCodeAt(e-1))&&e--;let n=nn(t,e);for(e+=ci(n);e<t.length;){let i=nn(t,e);if(n==Hw||i==Hw||r&&Tj(i))e+=ci(i),n=i;else if(Gw(i)){let o=0,s=e-2;for(;s>=0&&Gw(nn(t,s));)o++,s-=2;if(o%2==0)break;e+=2}else break}return e}function Cj(t,e,r){for(;e>0;){let n=UQ(t,e-2,r);if(n<e)return n;e--}return 0}function FQ(t){return t>=56320&&t<57344}function zQ(t){return t>=55296&&t<56320}function nn(t,e){let r=t.charCodeAt(e);if(!zQ(r)||e+1==t.length)return r;let n=t.charCodeAt(e+1);return FQ(n)?(r-55296<<10)+(n-56320)+65536:r}function y0(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function ci(t){return t<65536?1:2}const Km=/\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 co{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){Jm(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 co(e)}composeDesc(e){return this.empty?e:e.empty?this:GQ(this,e)}mapDesc(e,r=!1){return e.empty?this:ey(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++],u=i+a;if(l<0){if(u>e)return o+(e-i);o+=a}else{if(n!=Xr.Simple&&u>=e&&(n==Xr.TrackDel&&i<e&&u>e||n==Xr.TrackBefore&&i<e||n==Xr.TrackAfter&&u>e))return null;if(u>e||u==e&&r<0&&!a)return e==i||r<0?o:o+l;o+=l}i=u}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 co(e)}static create(e){return new co(e)}}class Lr extends co{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 Jm(this,(r,n,i,o,s)=>e=e.replace(i,i+(n-r),s),!1),e}mapDesc(e,r=!1){return ey(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 Lr(r,n)}compose(e){return this.empty?e:e.empty?this:GQ(this,e,!0)}map(e,r=!1){return e.empty?this:ey(this,e,r,!0)}iterChanges(e,r=!1){Jm(this,e,r)}get desc(){return co.create(this.sections)}filter(e){let r=[],n=[],i=[],o=new Ac(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 c=Math.min(o.len,l-a);pn(i,c,-1);let f=o.ins==-1?-1:o.off==0?o.ins:0;pn(r,c,f),f>0&&es(n,r,o.text),o.forward(c),a+=c}let u=e[s++];for(;a<u;){if(o.done)break e;let c=Math.min(o.len,u-a);pn(r,c,-1),pn(i,c,o.ins==-1?-1:o.off==0?o.ins:0),o.forward(c),a+=c}}return{changes:new Lr(r,n),filtered:co.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(c=!1){if(!c&&!i.length)return;s<r&&pn(i,r-s,-1);let f=new Lr(i,o);a=a?a.compose(f.map(a)):f,i=[],o=[],s=0}function u(c){if(Array.isArray(c))for(let f of c)u(f);else if(c instanceof Lr){if(c.length!=r)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${r})`);l(),a=a?a.compose(c.map(a)):c}else{let{from:f,to:h=f,insert:d}=c;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||Km)):d:It.empty,O=p.length;if(f==h&&O==0)return;f<s&&l(),f>s&&pn(i,f-s,-1),pn(i,h-f,O),es(o,i,p),s=h}}return u(e),l(!a),a}static empty(e){return new Lr(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 Lr(r,n)}static createSet(e,r){return new Lr(e,r)}}function pn(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 es(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 Jm(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 u=i,c=o,f=It.empty;for(;u+=a,c+=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,u,o,c,f),i=u,o=c}}}function ey(t,e,r,n=!1){let i=[],o=n?[]:null,s=new Ac(t),a=new Ac(e);for(let l=-1;;)if(s.ins==-1&&a.ins==-1){let u=Math.min(s.len,a.len);pn(i,u,-1),s.forward(u),a.forward(u)}else if(a.ins>=0&&(s.ins<0||l==s.i||s.off==0&&(a.len<s.len||a.len==s.len&&!r))){let u=a.len;for(pn(i,a.ins,-1);u;){let c=Math.min(s.len,u);s.ins>=0&&l<s.i&&s.len<=c&&(pn(i,0,s.ins),o&&es(o,i,s.text),l=s.i),s.forward(c),u-=c}a.next()}else if(s.ins>=0){let u=0,c=s.len;for(;c;)if(a.ins==-1){let f=Math.min(c,a.len);u+=f,c-=f,a.forward(f)}else if(a.ins==0&&a.len<c)c-=a.len,a.next();else break;pn(i,u,l<s.i?s.ins:0),o&&l<s.i&&es(o,i,s.text),l=s.i,s.forward(s.len-c)}else{if(s.done&&a.done)return o?Lr.createSet(i,o):co.create(i);throw new Error("Mismatched change set lengths")}}function GQ(t,e,r=!1){let n=[],i=r?[]:null,o=new Ac(t),s=new Ac(e);for(let a=!1;;){if(o.done&&s.done)return i?Lr.createSet(n,i):co.create(n);if(o.ins==0)pn(n,o.len,0,a),o.next();else if(s.len==0&&!s.done)pn(n,0,s.ins,a),i&&es(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),u=n.length;if(o.ins==-1){let c=s.ins==-1?-1:s.off?0:s.ins;pn(n,l,c,a),i&&c&&es(i,n,s.text)}else s.ins==-1?(pn(n,o.off?0:o.len,l,a),i&&es(i,n,o.textBit(l))):(pn(n,o.off?0:o.len,s.off?0:s.ins,a),i&&!s.off&&es(i,n,s.text));a=(o.ins>l||s.ins>=0&&s.len>l)&&(a||n.length>u),o.forward2(l),s.forward(l)}}}}class Ac{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 ia{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 ia(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 ia(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=>ia.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 ia.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?ia.create(r,e,48|o):ia.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 HQ(t,e){for(let r of t.ranges)if(r.to>e)throw new RangeError("Selection points outside of document")}let v0=0;class De{constructor(e,r,n,i,o){this.combine=e,this.compareInput=r,this.compare=n,this.isStatic=i,this.id=v0++,this.default=e([]),this.extensions=typeof o=="function"?o(this):o}get reader(){return this}static define(e={}){return new De(e.combine||(r=>r),e.compareInput||((r,n)=>r===n),e.compare||(e.combine?(r,n)=>r===n:w0),!!e.static,e.enables)}of(e){return new Qd([],this,0,e)}compute(e,r){if(this.isStatic)throw new Error("Can't compute a static facet");return new Qd(e,this,1,r)}computeN(e,r){if(this.isStatic)throw new Error("Can't compute a static facet");return new Qd(e,this,2,r)}from(e,r){return r||(r=n=>n),this.compute([e],n=>r(n.field(e)))}}function w0(t,e){return t==e||t.length==e.length&&t.every((r,n)=>r===e[n])}class Qd{constructor(e,r,n,i){this.dependencies=e,this.facet=r,this.type=n,this.value=i,this.id=v0++}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,u=!1,c=[];for(let f of this.dependencies)f=="doc"?l=!0:f=="selection"?u=!0:((r=e[f.id])!==null&&r!==void 0?r:1)&1||c.push(e[f.id]);return{create(f){return f.values[s]=n(f),1},update(f,h){if(l&&h.docChanged||u&&(h.docChanged||h.selection)||ty(f,c)){let d=n(f);if(a?!Kw(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=gp(h,p);if(this.dependencies.every(m=>m instanceof De?h.facet(m)===f.facet(m):m instanceof Ur?h.field(m,!1)==f.field(m,!1):!0)||(a?Kw(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 Kw(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 ty(t,e){let r=!1;for(let n of e)uc(t,n)&1&&(r=!0);return r}function Rj(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 u=[];for(let c=0;c<n.length;c++){let f=gp(l,n[c]);if(i[c]==2)for(let h of f)u.push(h);else u.push(f)}return e.combine(u)}return{create(l){for(let u of n)uc(l,u);return l.values[s]=a(l),1},update(l,u){if(!ty(l,o))return 0;let c=a(l);return e.compare(c,l.values[s])?0:(l.values[s]=c,1)},reconfigure(l,u){let c=ty(l,n),f=u.config.facets[e.id],h=u.facet(e);if(f&&!c&&w0(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 Jw=De.define({static:!0});class Ur{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 Ur(v0++,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(Jw).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,Jw.of({field:this,create:e})]}get extension(){return this}}const Hs={lowest:4,low:3,default:2,high:1,highest:0};function Su(t){return e=>new KQ(e,t)}const Es={highest:Su(Hs.highest),high:Su(Hs.high),default:Su(Hs.default),low:Su(Hs.low),lowest:Su(Hs.lowest)};class KQ{constructor(e,r){this.inner=e,this.prec=r}}class Wl{of(e){return new ry(this,e)}reconfigure(e){return Wl.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class ry{constructor(e,r){this.compartment=e,this.inner=r}}class Op{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 Aj(e,r,s))h instanceof Ur?i.push(h):(o[h.facet.id]||(o[h.facet.id]=[])).push(h);let a=Object.create(null),l=[],u=[];for(let h of i)a[h.id]=u.length<<1,u.push(d=>h.slot(d));let c=n==null?void 0:n.config.facets;for(let h in o){let d=o[h],p=d[0].facet,O=c&&c[h]||[];if(d.every(m=>m.type==0))if(a[p.id]=l.length<<1|1,w0(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]=u.length<<1,u.push(y=>m.dynamicSlot(y)));a[p.id]=u.length<<1,u.push(m=>Rj(m,p,d))}}let f=u.map(h=>h(a));return new Op(e,s,f,a,l,o)}}function Aj(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 u=n[l].indexOf(s);u>-1&&n[l].splice(u,1),s instanceof ry&&r.delete(s.compartment)}if(i.set(s,a),Array.isArray(s))for(let u of s)o(u,a);else if(s instanceof ry){if(r.has(s.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(s.compartment)||s.inner;r.set(s.compartment,u),o(u,a)}else if(s instanceof KQ)o(s.inner,s.prec);else if(s instanceof Ur)n[a].push(s),s.provides&&o(s.provides,a);else if(s instanceof Qd)n[a].push(s),s.facet.extensions&&o(s.facet.extensions,Hs.default);else{let u=s.extension;if(!u)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(u,a)}}return o(t,Hs.default),n.reduce((s,a)=>s.concat(a))}function uc(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 gp(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const JQ=De.define(),ny=De.define({combine:t=>t.some(e=>e),static:!0}),eE=De.define({combine:t=>t.length?t[0]:void 0,static:!0}),tE=De.define(),rE=De.define(),nE=De.define(),iE=De.define({combine:t=>t.length?t[0]:!1});class ho{constructor(e,r){this.type=e,this.value=r}static define(){return new Mj}}class Mj{of(e){return new ho(this,e)}}class qj{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 qj(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 qr{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&&HQ(n,r.newLength),o.some(a=>a.type==qr.time)||(this.annotations=o.concat(qr.time.of(Date.now())))}static create(e,r,n,i,o,s){return new qr(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(qr.userEvent);return!!(r&&(r==e||r.length>e.length&&r.slice(0,e.length)==e&&r[e.length]=="."))}}qr.time=ho.define();qr.userEvent=ho.define();qr.addToHistory=ho.define();qr.remote=ho.define();function jj(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 oE(t,e,r){var n;let i,o,s;return r?(i=e.changes,o=Lr.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 iy(t,e,r){let n=e.selection,i=Pl(e.annotations);return e.userEvent&&(i=i.concat(qr.userEvent.of(e.userEvent))),{changes:e.changes instanceof Lr?e.changes:Lr.of(e.changes||[],r,t.facet(eE)),selection:n&&(n instanceof oe?n:oe.single(n.anchor,n.head)),effects:Pl(e.effects),annotations:i,scrollIntoView:!!e.scrollIntoView}}function sE(t,e,r){let n=iy(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=oE(n,iy(t,e[o],s?n.changes.newLength:t.doc.length),s)}let i=qr.create(t,n.changes,n.selection,n.effects,n.annotations,n.scrollIntoView);return Zj(r?Dj(i):i)}function Dj(t){let e=t.startState,r=!0;for(let i of e.facet(tE)){let o=i(t);if(o===!1){r=!1;break}Array.isArray(o)&&(r=r===!0?o:jj(r,o))}if(r!==!0){let i,o;if(r===!1)o=t.changes.invertedDesc,i=Lr.empty(e.doc.length);else{let s=t.changes.filter(r);i=s.changes,o=s.filtered.mapDesc(s.changes).invertedDesc}t=qr.create(e,i,t.selection&&t.selection.map(o),mt.mapEffects(t.effects,o),t.annotations,t.scrollIntoView)}let n=e.facet(rE);for(let i=n.length-1;i>=0;i--){let o=n[i](t);o instanceof qr?t=o:Array.isArray(o)&&o.length==1&&o[0]instanceof qr?t=o[0]:t=sE(e,Pl(o),!1)}return t}function Zj(t){let e=t.startState,r=e.facet(nE),n=t;for(let i=r.length-1;i>=0;i--){let o=r[i](t);o&&Object.keys(o).length&&(n=oE(n,iy(e,o,t.changes.newLength),!0))}return n==t?t:qr.create(e,t.changes,t.selection,n.effects,n.annotations,n.scrollIntoView)}const Nj=[];function Pl(t){return t==null?Nj: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 Wj=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let oy;try{oy=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Ij(t){if(oy)return oy.test(t);for(let e=0;e<t.length;e++){let r=t[e];if(/\w/.test(r)||r>"€"&&(r.toUpperCase()!=r.toLowerCase()||Wj.test(r)))return!0}return!1}function Bj(t){return e=>{if(!/\S/.test(e))return gr.Space;if(Ij(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 qt{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++)uc(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 uc(this,n),gp(this,n)}update(...e){return sE(this,e,!0)}applyTransaction(e){let r=this.config,{base:n,compartments:i}=r;for(let a of e.effects)a.is(Wl.reconfigure)?(r&&(i=new Map,r.compartments.forEach((l,u)=>i.set(u,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=Pl(n).concat(a.value));let o;r?o=e.startState.values.slice():(r=Op.resolve(n,i,this),o=new qt(r,this.doc,this.selection,r.dynamicSlots.map(()=>null),(l,u)=>u.reconfigure(l,this),null).values);let s=e.startState.facet(ny)?e.newSelection:e.newSelection.asSingle();new qt(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=Pl(n.effects);for(let a=1;a<r.ranges.length;a++){let l=e(r.ranges[a]),u=this.changes(l.changes),c=u.map(i);for(let h=0;h<a;h++)o[h]=o[h].map(c);let f=i.mapDesc(u,!0);o.push(l.range.map(f)),i=i.compose(c),s=mt.mapEffects(s,c).concat(mt.mapEffects(Pl(l.effects),f))}return{changes:i,selection:oe.create(o,r.mainIndex),effects:s}}changes(e=[]){return e instanceof Lr?e:Lr.of(e,this.doc.length,this.facet(qt.lineSeparator))}toText(e){return It.of(e.split(this.facet(qt.lineSeparator)||Km))}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:(uc(this,r),gp(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 Ur&&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 qt.create({doc:e.doc,selection:oe.fromJSON(e.selection),extensions:r.extensions?i.concat([r.extensions]):i})}static create(e={}){let r=Op.resolve(e.extensions||[],new Map),n=e.doc instanceof It?e.doc:It.of((e.doc||"").split(r.staticFacet(qt.lineSeparator)||Km)),i=e.selection?e.selection instanceof oe?e.selection:oe.single(e.selection.anchor,e.selection.head):oe.single(0);return HQ(i,n.length),r.staticFacet(ny)||(i=i.asSingle()),new qt(r,n,i,r.dynamicSlots.map(()=>null),(o,s)=>s.create(o),null)}get tabSize(){return this.facet(qt.tabSize)}get lineBreak(){return this.facet(qt.lineSeparator)||`