UNPKG

py_sandpack

Version:

PySandpack is a React library designed to provide a sandbox environment for executing Python code directly in the browser. It is ideal for educational purposes, quick experiments, or running Python scripts without requiring a local Python installation.

34 lines (32 loc) 492 kB
(function(Ue,B){typeof exports=="object"&&typeof module<"u"?B(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],B):(Ue=typeof globalThis<"u"?globalThis:Ue||self,B(Ue.index={},Ue.React))})(this,function(Ue,B){"use strict";function Ld(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const Wd=Ld(B);function zd(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function Id(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(i){var s=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return n[i]}})}),t}var Bn={exports:{}},Ii={};const $l=Id(Wd);/** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Ll;function _d(){if(Ll)return Ii;Ll=1;var n=$l,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,s=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,r={key:!0,ref:!0,__self:!0,__source:!0};function o(l,a,h){var c,f={},u=null,d=null;h!==void 0&&(u=""+h),a.key!==void 0&&(u=""+a.key),a.ref!==void 0&&(d=a.ref);for(c in a)i.call(a,c)&&!r.hasOwnProperty(c)&&(f[c]=a[c]);if(l&&l.defaultProps)for(c in a=l.defaultProps,a)f[c]===void 0&&(f[c]=a[c]);return{$$typeof:e,type:l,key:u,ref:d,props:f,_owner:s.current}}return Ii.Fragment=t,Ii.jsx=o,Ii.jsxs=o,Ii}var _i={};/** * @license React * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Wl;function Nd(){return Wl||(Wl=1,process.env.NODE_ENV!=="production"&&function(){var n=$l,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),u=Symbol.for("react.lazy"),d=Symbol.for("react.offscreen"),p=Symbol.iterator,O="@@iterator";function m(g){if(g===null||typeof g!="object")return null;var A=p&&g[p]||g[O];return typeof A=="function"?A:null}var y=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function S(g){{for(var A=arguments.length,E=new Array(A>1?A-1:0),I=1;I<A;I++)E[I-1]=arguments[I];C("error",g,E)}}function C(g,A,E){{var I=y.ReactDebugCurrentFrame,K=I.getStackAddendum();K!==""&&(A+="%s",E=E.concat([K]));var ie=E.map(function(G){return String(G)});ie.unshift("Warning: "+A),Function.prototype.apply.call(console[g],console,ie)}}var k=!1,w=!1,b=!1,v=!1,Q=!1,W;W=Symbol.for("react.module.reference");function j(g){return!!(typeof g=="string"||typeof g=="function"||g===i||g===r||Q||g===s||g===h||g===c||v||g===d||k||w||b||typeof g=="object"&&g!==null&&(g.$$typeof===u||g.$$typeof===f||g.$$typeof===o||g.$$typeof===l||g.$$typeof===a||g.$$typeof===W||g.getModuleId!==void 0))}function z(g,A,E){var I=g.displayName;if(I)return I;var K=A.displayName||A.name||"";return K!==""?E+"("+K+")":E}function $(g){return g.displayName||"Context"}function N(g){if(g==null)return null;if(typeof g.tag=="number"&&S("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof g=="function")return g.displayName||g.name||null;if(typeof g=="string")return g;switch(g){case i:return"Fragment";case t:return"Portal";case r:return"Profiler";case s:return"StrictMode";case h:return"Suspense";case c:return"SuspenseList"}if(typeof g=="object")switch(g.$$typeof){case l:var A=g;return $(A)+".Consumer";case o:var E=g;return $(E._context)+".Provider";case a:return z(g,g.render,"ForwardRef");case f:var I=g.displayName||null;return I!==null?I:N(g.type)||"Memo";case u:{var K=g,ie=K._payload,G=K._init;try{return N(G(ie))}catch{return null}}}return null}var V=Object.assign,H=0,ae,J,ye,oe,Pe,tt,De;function Xe(){}Xe.__reactDisabledLog=!0;function Dt(){{if(H===0){ae=console.log,J=console.info,ye=console.warn,oe=console.error,Pe=console.group,tt=console.groupCollapsed,De=console.groupEnd;var g={configurable:!0,enumerable:!0,value:Xe,writable:!0};Object.defineProperties(console,{info:g,log:g,warn:g,error:g,group:g,groupCollapsed:g,groupEnd:g})}H++}}function Gt(){{if(H--,H===0){var g={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:V({},g,{value:ae}),info:V({},g,{value:J}),warn:V({},g,{value:ye}),error:V({},g,{value:oe}),group:V({},g,{value:Pe}),groupCollapsed:V({},g,{value:tt}),groupEnd:V({},g,{value:De})})}H<0&&S("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Yt=y.ReactCurrentDispatcher,Li;function ar(g,A,E){{if(Li===void 0)try{throw Error()}catch(K){var I=K.stack.trim().match(/\n( *(at )?)/);Li=I&&I[1]||""}return` `+Li+g}}var Al=!1,hr;{var Jx=typeof WeakMap=="function"?WeakMap:Map;hr=new Jx}function vd(g,A){if(!g||Al)return"";{var E=hr.get(g);if(E!==void 0)return E}var I;Al=!0;var K=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var ie;ie=Yt.current,Yt.current=null,Dt();try{if(A){var G=function(){throw Error()};if(Object.defineProperty(G.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(G,[])}catch(_e){I=_e}Reflect.construct(g,[],G)}else{try{G.call()}catch(_e){I=_e}g.call(G.prototype)}}else{try{throw Error()}catch(_e){I=_e}g()}}catch(_e){if(_e&&I&&typeof _e.stack=="string"){for(var X=_e.stack.split(` `),qe=I.stack.split(` `),fe=X.length-1,ge=qe.length-1;fe>=1&&ge>=0&&X[fe]!==qe[ge];)ge--;for(;fe>=1&&ge>=0;fe--,ge--)if(X[fe]!==qe[ge]){if(fe!==1||ge!==1)do if(fe--,ge--,ge<0||X[fe]!==qe[ge]){var it=` `+X[fe].replace(" at new "," at ");return g.displayName&&it.includes("<anonymous>")&&(it=it.replace("<anonymous>",g.displayName)),typeof g=="function"&&hr.set(g,it),it}while(fe>=1&&ge>=0);break}}}finally{Al=!1,Yt.current=ie,Gt(),Error.prepareStackTrace=K}var zi=g?g.displayName||g.name:"",ci=zi?ar(zi):"";return typeof g=="function"&&hr.set(g,ci),ci}function eS(g,A,E){return vd(g,!1)}function tS(g){var A=g.prototype;return!!(A&&A.isReactComponent)}function cr(g,A,E){if(g==null)return"";if(typeof g=="function")return vd(g,tS(g));if(typeof g=="string")return ar(g);switch(g){case h:return ar("Suspense");case c:return ar("SuspenseList")}if(typeof g=="object")switch(g.$$typeof){case a:return eS(g.render);case f:return cr(g.type,A,E);case u:{var I=g,K=I._payload,ie=I._init;try{return cr(ie(K),A,E)}catch{}}}return""}var Dn=Object.prototype.hasOwnProperty,wd={},kd=y.ReactDebugCurrentFrame;function fr(g){if(g){var A=g._owner,E=cr(g.type,g._source,A?A.type:null);kd.setExtraStackFrame(E)}else kd.setExtraStackFrame(null)}function iS(g,A,E,I,K){{var ie=Function.call.bind(Dn);for(var G in g)if(ie(g,G)){var X=void 0;try{if(typeof g[G]!="function"){var qe=Error((I||"React class")+": "+E+" type `"+G+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof g[G]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw qe.name="Invariant Violation",qe}X=g[G](A,G,I,E,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(fe){X=fe}X&&!(X instanceof Error)&&(fr(K),S("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",I||"React class",E,G,typeof X),fr(null)),X instanceof Error&&!(X.message in wd)&&(wd[X.message]=!0,fr(K),S("Failed %s type: %s",E,X.message),fr(null))}}}var nS=Array.isArray;function Rl(g){return nS(g)}function sS(g){{var A=typeof Symbol=="function"&&Symbol.toStringTag,E=A&&g[Symbol.toStringTag]||g.constructor.name||"Object";return E}}function rS(g){try{return Td(g),!1}catch{return!0}}function Td(g){return""+g}function Cd(g){if(rS(g))return S("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",sS(g)),Td(g)}var qn=y.ReactCurrentOwner,oS={key:!0,ref:!0,__self:!0,__source:!0},Pd,Qd,Ml;Ml={};function lS(g){if(Dn.call(g,"ref")){var A=Object.getOwnPropertyDescriptor(g,"ref").get;if(A&&A.isReactWarning)return!1}return g.ref!==void 0}function aS(g){if(Dn.call(g,"key")){var A=Object.getOwnPropertyDescriptor(g,"key").get;if(A&&A.isReactWarning)return!1}return g.key!==void 0}function hS(g,A){if(typeof g.ref=="string"&&qn.current&&A&&qn.current.stateNode!==A){var E=N(qn.current.type);Ml[E]||(S('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',N(qn.current.type),g.ref),Ml[E]=!0)}}function cS(g,A){{var E=function(){Pd||(Pd=!0,S("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",A))};E.isReactWarning=!0,Object.defineProperty(g,"key",{get:E,configurable:!0})}}function fS(g,A){{var E=function(){Qd||(Qd=!0,S("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",A))};E.isReactWarning=!0,Object.defineProperty(g,"ref",{get:E,configurable:!0})}}var uS=function(g,A,E,I,K,ie,G){var X={$$typeof:e,type:g,key:A,ref:E,props:G,_owner:ie};return X._store={},Object.defineProperty(X._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(X,"_self",{configurable:!1,enumerable:!1,writable:!1,value:I}),Object.defineProperty(X,"_source",{configurable:!1,enumerable:!1,writable:!1,value:K}),Object.freeze&&(Object.freeze(X.props),Object.freeze(X)),X};function dS(g,A,E,I,K){{var ie,G={},X=null,qe=null;E!==void 0&&(Cd(E),X=""+E),aS(A)&&(Cd(A.key),X=""+A.key),lS(A)&&(qe=A.ref,hS(A,K));for(ie in A)Dn.call(A,ie)&&!oS.hasOwnProperty(ie)&&(G[ie]=A[ie]);if(g&&g.defaultProps){var fe=g.defaultProps;for(ie in fe)G[ie]===void 0&&(G[ie]=fe[ie])}if(X||qe){var ge=typeof g=="function"?g.displayName||g.name||"Unknown":g;X&&cS(G,ge),qe&&fS(G,ge)}return uS(g,X,qe,K,I,qn.current,G)}}var El=y.ReactCurrentOwner,Ad=y.ReactDebugCurrentFrame;function Wi(g){if(g){var A=g._owner,E=cr(g.type,g._source,A?A.type:null);Ad.setExtraStackFrame(E)}else Ad.setExtraStackFrame(null)}var Dl;Dl=!1;function ql(g){return typeof g=="object"&&g!==null&&g.$$typeof===e}function Rd(){{if(El.current){var g=N(El.current.type);if(g)return` Check the render method of \``+g+"`."}return""}}function pS(g){return""}var Md={};function gS(g){{var A=Rd();if(!A){var E=typeof g=="string"?g:g.displayName||g.name;E&&(A=` Check the top-level render call using <`+E+">.")}return A}}function Ed(g,A){{if(!g._store||g._store.validated||g.key!=null)return;g._store.validated=!0;var E=gS(A);if(Md[E])return;Md[E]=!0;var I="";g&&g._owner&&g._owner!==El.current&&(I=" It was passed a child from "+N(g._owner.type)+"."),Wi(g),S('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',E,I),Wi(null)}}function Dd(g,A){{if(typeof g!="object")return;if(Rl(g))for(var E=0;E<g.length;E++){var I=g[E];ql(I)&&Ed(I,A)}else if(ql(g))g._store&&(g._store.validated=!0);else if(g){var K=m(g);if(typeof K=="function"&&K!==g.entries)for(var ie=K.call(g),G;!(G=ie.next()).done;)ql(G.value)&&Ed(G.value,A)}}}function mS(g){{var A=g.type;if(A==null||typeof A=="string")return;var E;if(typeof A=="function")E=A.propTypes;else if(typeof A=="object"&&(A.$$typeof===a||A.$$typeof===f))E=A.propTypes;else return;if(E){var I=N(A);iS(E,g.props,"prop",I,g)}else if(A.PropTypes!==void 0&&!Dl){Dl=!0;var K=N(A);S("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",K||"Unknown")}typeof A.getDefaultProps=="function"&&!A.getDefaultProps.isReactClassApproved&&S("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function OS(g){{for(var A=Object.keys(g.props),E=0;E<A.length;E++){var I=A[E];if(I!=="children"&&I!=="key"){Wi(g),S("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",I),Wi(null);break}}g.ref!==null&&(Wi(g),S("Invalid attribute `ref` supplied to `React.Fragment`."),Wi(null))}}var qd={};function Bd(g,A,E,I,K,ie){{var G=j(g);if(!G){var X="";(g===void 0||typeof g=="object"&&g!==null&&Object.keys(g).length===0)&&(X+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var qe=pS();qe?X+=qe:X+=Rd();var fe;g===null?fe="null":Rl(g)?fe="array":g!==void 0&&g.$$typeof===e?(fe="<"+(N(g.type)||"Unknown")+" />",X=" Did you accidentally export a JSX literal instead of a component?"):fe=typeof g,S("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",fe,X)}var ge=dS(g,A,E,K,ie);if(ge==null)return ge;if(G){var it=A.children;if(it!==void 0)if(I)if(Rl(it)){for(var zi=0;zi<it.length;zi++)Dd(it[zi],g);Object.freeze&&Object.freeze(it)}else S("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Dd(it,g)}if(Dn.call(A,"key")){var ci=N(g),_e=Object.keys(A).filter(function(wS){return wS!=="key"}),Bl=_e.length>0?"{key: someKey, "+_e.join(": ..., ")+": ...}":"{key: someKey}";if(!qd[ci+Bl]){var vS=_e.length>0?"{"+_e.join(": ..., ")+": ...}":"{}";S(`A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; <%s key={someKey} {...props} />`,Bl,ci,vS,ci),qd[ci+Bl]=!0}}return g===i?OS(ge):mS(ge),ge}}function yS(g,A,E){return Bd(g,A,E,!0)}function bS(g,A,E){return Bd(g,A,E,!1)}var xS=bS,SS=yS;_i.Fragment=i,_i.jsx=xS,_i.jsxs=SS}()),_i}var zl;function Vd(){return zl||(zl=1,process.env.NODE_ENV==="production"?Bn.exports=_d():Bn.exports=Nd()),Bn.exports}var P=Vd();function ur(){return ur=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},ur.apply(null,arguments)}function jd(n,e){if(n==null)return{};var t={};for(var i in n)if({}.hasOwnProperty.call(n,i)){if(e.includes(i))continue;t[i]=n[i]}return t}class Y{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,t,i){[e,t]=fi(this,e,t);let s=[];return this.decompose(0,e,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(t,this.length,s,1),at.from(s,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=fi(this,e,t);let i=[];return this.decompose(e,t,i,0),at.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),s=new Ni(this),r=new Ni(e);for(let o=t,l=t;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(l+=s.value.length,s.done||l>=i)return!0}}iter(e=1){return new Ni(this,e)}iterRange(e,t=this.length){return new _l(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;i=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Nl(i)}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]?Y.empty:e.length<=32?new he(e):at.from(he.split(e,[]))}}class he extends Y{constructor(e,t=Fd(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.text[r],l=s+o.length;if((t?i:l)>=e)return new Xd(s,l,i,o);s=l+1,i++}}decompose(e,t,i,s){let r=e<=0&&t>=this.length?this:new he(Il(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=i.pop(),l=$n(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new he(l,o.length+r.length));else{let a=l.length>>1;i.push(new he(l.slice(0,a)),new he(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof he))return super.replace(e,t,i);[e,t]=fi(this,e,t);let s=$n(this.text,$n(i.text,Il(this.text,0,e)),t),r=this.length+i.length-(t-e);return s.length<=32?new he(s,r):at.from(he.split(s,[]),r)}sliceString(e,t=this.length,i=` `){[e,t]=fi(this,e,t);let s="";for(let r=0,o=0;r<=t&&o<this.text.length;o++){let l=this.text[o],a=r+l.length;r>e&&o&&(s+=i),e<a&&t>r&&(s+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return s}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],s=-1;for(let r of e)i.push(r),s+=r.length+1,i.length==32&&(t.push(new he(i,s)),i=[],s=-1);return s>-1&&t.push(new he(i,s)),t}}class at extends Y{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.children[r],l=s+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,s);s=l+1,i=a+1}}decompose(e,t,i,s){for(let r=0,o=0;o<=t&&r<this.children.length;r++){let l=this.children[r],a=o+l.length;if(e<=a&&t>=o){let h=s&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!h?i.push(l):l.decompose(e-o,t-o,i,h)}o=a+1}}replace(e,t,i){if([e,t]=fi(this,e,t),i.lines<this.lines)for(let s=0,r=0;s<this.children.length;s++){let o=this.children[s],l=r+o.length;if(e>=r&&t<=l){let a=o.replace(e-r,t-r,i),h=this.lines-o.lines+a.lines;if(a.lines<h>>4&&a.lines>h>>6){let c=this.children.slice();return c[s]=a,new at(c,this.length-(t-e)+i.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=` `){[e,t]=fi(this,e,t);let s="";for(let r=0,o=0;r<this.children.length&&o<=t;r++){let l=this.children[r],a=o+l.length;o>e&&r&&(s+=i),e<a&&t>o&&(s+=l.sliceString(e-o,t-o,i)),o=a+1}return s}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof at))return 0;let i=0,[s,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=t,r+=t){if(s==o||r==l)return i;let a=this.children[s],h=e.children[r];if(a!=h)return i+a.scanIdentical(h,t);i+=a.length+1}}static from(e,t=e.reduce((i,s)=>i+s.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let p of e)p.flatten(d);return new he(d,t)}let s=Math.max(32,i>>5),r=s<<1,o=s>>1,l=[],a=0,h=-1,c=[];function f(d){let p;if(d.lines>r&&d instanceof at)for(let O of d.children)f(O);else d.lines>o&&(a>o||!a)?(u(),l.push(d)):d instanceof he&&a&&(p=c[c.length-1])instanceof he&&d.lines+p.lines<=32?(a+=d.lines,h+=d.length+1,c[c.length-1]=new he(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>s&&u(),a+=d.lines,h+=d.length+1,c.push(d))}function u(){a!=0&&(l.push(c.length==1?c[0]:at.from(c,h)),h=-1,a=c.length=0)}for(let d of e)f(d);return u(),l.length==1?l[0]:new at(l,t)}}Y.empty=new he([""],0);function Fd(n){let e=-1;for(let t of n)e+=t.length+1;return e}function $n(n,e,t=0,i=1e9){for(let s=0,r=0,o=!0;r<n.length&&s<=i;r++){let l=n[r],a=s+l.length;a>=t&&(a>i&&(l=l.slice(0,i-s)),s<t&&(l=l.slice(t-s)),o?(e[e.length-1]+=l,o=!1):e.push(l)),s=a+1}return e}function Il(n,e,t){return $n(n,[""],e,t)}class Ni{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof he?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,s=this.nodes[i],r=this.offsets[i],o=r>>1,l=s instanceof he?s.text.length:s.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=` `,this;e--}else if(s instanceof he){let a=s.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=s.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof he?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class _l{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Ni(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*t,this.value=s.length<=i?s:t<0?s.slice(s.length-i):s.slice(0,i),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 Nl{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:s}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Y.prototype[Symbol.iterator]=function(){return this.iter()},Ni.prototype[Symbol.iterator]=_l.prototype[Symbol.iterator]=Nl.prototype[Symbol.iterator]=function(){return this});class Xd{constructor(e,t,i,s){this.from=e,this.to=t,this.number=i,this.text=s}get length(){return this.to-this.from}}function fi(n,e,t){return e=Math.max(0,Math.min(n.length,e)),[e,Math.max(e,Math.min(n.length,t))]}let ui="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(n=>n?parseInt(n,36):1);for(let n=1;n<ui.length;n++)ui[n]+=ui[n-1];function Ud(n){for(let e=1;e<ui.length;e+=2)if(ui[e]>n)return ui[e-1]<=n;return!1}function Vl(n){return n>=127462&&n<=127487}const jl=8205;function ve(n,e,t=!0,i=!0){return(t?Fl:Hd)(n,e,i)}function Fl(n,e,t){if(e==n.length)return e;e&&Xl(n.charCodeAt(e))&&Ul(n.charCodeAt(e-1))&&e--;let i=we(n,e);for(e+=He(i);e<n.length;){let s=we(n,e);if(i==jl||s==jl||t&&Ud(s))e+=He(s),i=s;else if(Vl(s)){let r=0,o=e-2;for(;o>=0&&Vl(we(n,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function Hd(n,e,t){for(;e>0;){let i=Fl(n,e-2,t);if(i<e)return i;e--}return 0}function Xl(n){return n>=56320&&n<57344}function Ul(n){return n>=55296&&n<56320}function we(n,e){let t=n.charCodeAt(e);if(!Ul(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return Xl(i)?(t-55296<<10)+(i-56320)+65536:t}function dr(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function He(n){return n<65536?1:2}const pr=/\r\n?|\n/;var ke=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(ke||(ke={}));class ht{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t+1];e+=i<0?this.sections[t]:i}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,i=0,s=0;t<this.sections.length;){let r=this.sections[t++],o=this.sections[t++];o<0?(e(i,s,r),s+=r):s+=o,i+=r}}iterChangedRanges(e,t=!1){gr(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];s<0?e.push(i,s):e.push(s,i)}return new ht(e)}composeDesc(e){return this.empty?e:e.empty?this:Hl(this,e)}mapDesc(e,t=!1){return e.empty?this:mr(this,e,t)}mapPos(e,t=-1,i=ke.Simple){let s=0,r=0;for(let o=0;o<this.sections.length;){let l=this.sections[o++],a=this.sections[o++],h=s+l;if(a<0){if(h>e)return r+(e-s);r+=l}else{if(i!=ke.Simple&&h>=e&&(i==ke.TrackDel&&s<e&&h>e||i==ke.TrackBefore&&s<e||i==ke.TrackAfter&&h>e))return null;if(h>e||h==e&&t<0&&!l)return e==s||t<0?r:r+a;r+=a}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return r}touchesRange(e,t=e){for(let i=0,s=0;i<this.sections.length&&s<=t;){let r=this.sections[i++],o=this.sections[i++],l=s+r;if(o>=0&&s<=t&&l>=e)return s<e&&l>t?"cover":!0;s=l}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let i=this.sections[t++],s=this.sections[t++];e+=(e?" ":"")+i+(s>=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new ht(e)}static create(e){return new ht(e)}}class me extends ht{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return gr(this,(t,i,s,r,o)=>e=e.replace(s,s+(i-t),o),!1),e}mapDesc(e,t=!1){return mr(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let s=0,r=0;s<t.length;s+=2){let o=t[s],l=t[s+1];if(l>=0){t[s]=l,t[s+1]=o;let a=s>>1;for(;i.length<a;)i.push(Y.empty);i.push(o?e.slice(r,r+o):Y.empty)}r+=o}return new me(t,i)}compose(e){return this.empty?e:e.empty?this:Hl(this,e,!0)}map(e,t=!1){return e.empty?this:mr(this,e,t,!0)}iterChanges(e,t=!1){gr(this,e,t)}get desc(){return ht.create(this.sections)}filter(e){let t=[],i=[],s=[],r=new Vi(this);e:for(let o=0,l=0;;){let a=o==e.length?1e9:e[o++];for(;l<a||l==a&&r.len==0;){if(r.done)break e;let c=Math.min(r.len,a-l);Qe(s,c,-1);let f=r.ins==-1?-1:r.off==0?r.ins:0;Qe(t,c,f),f>0&&qt(i,t,r.text),r.forward(c),l+=c}let h=e[o++];for(;l<h;){if(r.done)break e;let c=Math.min(r.len,h-l);Qe(t,c,-1),Qe(s,c,r.ins==-1?-1:r.off==0?r.ins:0),r.forward(c),l+=c}}return{changes:new me(t,i),filtered:ht.create(s)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let i=this.sections[t],s=this.sections[t+1];s<0?e.push(i):s==0?e.push([i]):e.push([i].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,i){let s=[],r=[],o=0,l=null;function a(c=!1){if(!c&&!s.length)return;o<t&&Qe(s,t-o,-1);let f=new me(s,r);l=l?l.compose(f.map(l)):f,s=[],r=[],o=0}function h(c){if(Array.isArray(c))for(let f of c)h(f);else if(c instanceof me){if(c.length!=t)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${t})`);a(),l=l?l.compose(c.map(l)):c}else{let{from:f,to:u=f,insert:d}=c;if(f>u||f<0||u>t)throw new RangeError(`Invalid change range ${f} to ${u} (in doc of length ${t})`);let p=d?typeof d=="string"?Y.of(d.split(i||pr)):d:Y.empty,O=p.length;if(f==u&&O==0)return;f<o&&a(),f>o&&Qe(s,f-o,-1),Qe(s,u-f,O),qt(r,s,p),o=u}}return h(e),a(!l),l}static empty(e){return new me(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let s=0;s<e.length;s++){let r=e[s];if(typeof r=="number")t.push(r,-1);else{if(!Array.isArray(r)||typeof r[0]!="number"||r.some((o,l)=>l&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length<s;)i.push(Y.empty);i[s]=Y.of(r.slice(1)),t.push(r[0],i[s].length)}}}return new me(t,i)}static createSet(e,t){return new me(e,t)}}function Qe(n,e,t,i=!1){if(e==0&&t<=0)return;let s=n.length-2;s>=0&&t<=0&&t==n[s+1]?n[s]+=e:e==0&&n[s]==0?n[s+1]+=t:i?(n[s]+=e,n[s+1]+=t):n.push(e,t)}function qt(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i<n.length)n[n.length-1]=n[n.length-1].append(t);else{for(;n.length<i;)n.push(Y.empty);n.push(t)}}function gr(n,e,t){let i=n.inserted;for(let s=0,r=0,o=0;o<n.sections.length;){let l=n.sections[o++],a=n.sections[o++];if(a<0)s+=l,r+=l;else{let h=s,c=r,f=Y.empty;for(;h+=l,c+=a,a&&i&&(f=f.append(i[o-2>>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(s,h,r,c,f),s=h,r=c}}}function mr(n,e,t,i=!1){let s=[],r=i?[]:null,o=new Vi(n),l=new Vi(e);for(let a=-1;;)if(o.ins==-1&&l.ins==-1){let h=Math.min(o.len,l.len);Qe(s,h,-1),o.forward(h),l.forward(h)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len<o.len||l.len==o.len&&!t))){let h=l.len;for(Qe(s,l.ins,-1);h;){let c=Math.min(o.len,h);o.ins>=0&&a<o.i&&o.len<=c&&(Qe(s,0,o.ins),r&&qt(r,s,o.text),a=o.i),o.forward(c),h-=c}l.next()}else if(o.ins>=0){let h=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);h+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.len<c)c-=l.len,l.next();else break;Qe(s,h,a<o.i?o.ins:0),r&&a<o.i&&qt(r,s,o.text),a=o.i,o.forward(o.len-c)}else{if(o.done&&l.done)return r?me.createSet(s,r):ht.create(s);throw new Error("Mismatched change set lengths")}}function Hl(n,e,t=!1){let i=[],s=t?[]:null,r=new Vi(n),o=new Vi(e);for(let l=!1;;){if(r.done&&o.done)return s?me.createSet(i,s):ht.create(i);if(r.ins==0)Qe(i,r.len,0,l),r.next();else if(o.len==0&&!o.done)Qe(i,0,o.ins,l),s&&qt(s,i,o.text),o.next();else{if(r.done||o.done)throw new Error("Mismatched change set lengths");{let a=Math.min(r.len2,o.len),h=i.length;if(r.ins==-1){let c=o.ins==-1?-1:o.off?0:o.ins;Qe(i,a,c,l),s&&c&&qt(s,i,o.text)}else o.ins==-1?(Qe(i,r.off?0:r.len,a,l),s&&qt(s,i,r.textBit(a))):(Qe(i,r.off?0:r.len,o.off?0:o.ins,l),s&&!o.off&&qt(s,i,o.text));l=(r.ins>a||o.ins>=0&&o.len>a)&&(l||i.length>h),r.forward2(a),o.forward(a)}}}}class Vi{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,t=this.i-2>>1;return t>=e.length?Y.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?Y.empty:t[i].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 Zt{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}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,t=-1){let i,s;return this.empty?i=s=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),i==this.from&&s==this.to?this:new Zt(i,s,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return T.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return T.range(this.anchor,i)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&(!t||!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 T.range(e.anchor,e.head)}static create(e,t,i){return new Zt(e,t,i)}}class T{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:T.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let i=0;i<this.ranges.length;i++)if(!this.ranges[i].eq(e.ranges[i],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new T([this.main],0)}addRange(e,t=!0){return T.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e,t=this.mainIndex){let i=this.ranges.slice();return i[t]=e,T.create(i,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 T(e.ranges.map(t=>Zt.fromJSON(t)),e.main)}static single(e,t=e){return new T([T.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,s=0;s<e.length;s++){let r=e[s];if(r.empty?r.from<=i:r.from<i)return T.normalized(e.slice(),t);i=r.to}return new T(e,t)}static cursor(e,t=0,i,s){return Zt.create(e,e,(t==0?0:t<0?8:16)|(i==null?7:Math.min(6,i))|(s??16777215)<<6)}static range(e,t,i,s){let r=(i??16777215)<<6|(s==null?7:Math.min(6,s));return t<e?Zt.create(t,e,48|r):Zt.create(e,t,(t>e?8:0)|r)}static normalized(e,t=0){let i=e[t];e.sort((s,r)=>s.from-r.from),t=e.indexOf(i);for(let s=1;s<e.length;s++){let r=e[s],o=e[s-1];if(r.empty?r.from<=o.to:r.from<o.to){let l=o.from,a=Math.max(r.to,o.to);s<=t&&t--,e.splice(--s,2,r.anchor>r.head?T.range(a,l):T.range(l,a))}}return new T(e,t)}}function Gl(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let Or=0;class D{constructor(e,t,i,s,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=s,this.id=Or++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}get reader(){return this}static define(e={}){return new D(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:yr),!!e.static,e.enables)}of(e){return new Ln([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ln(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new Ln(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function yr(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class Ln{constructor(e,t,i,s){this.dependencies=e,this.facet=t,this.type=i,this.value=s,this.id=Or++}dynamicSlot(e){var t;let i=this.value,s=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,h=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?h=!0:((t=e[f.id])!==null&&t!==void 0?t:1)&1||c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,u){if(a&&u.docChanged||h&&(u.docChanged||u.selection)||br(f,c)){let d=i(f);if(l?!Yl(d,f.values[o],s):!s(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,u)=>{let d,p=u.config.address[r];if(p!=null){let O=In(u,p);if(this.dependencies.every(m=>m instanceof D?u.facet(m)===f.facet(m):m instanceof be?u.field(m,!1)==f.field(m,!1):!0)||(l?Yl(d=i(f),O,s):s(d=i(f),O)))return f.values[o]=O,0}else d=i(f);return f.values[o]=d,1}}}}function Yl(n,e,t){if(n.length!=e.length)return!1;for(let i=0;i<n.length;i++)if(!t(n[i],e[i]))return!1;return!0}function br(n,e){let t=!1;for(let i of e)Fi(n,i)&1&&(t=!0);return t}function Gd(n,e,t){let i=t.map(a=>n[a.id]),s=t.map(a=>a.type),r=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let h=[];for(let c=0;c<i.length;c++){let f=In(a,i[c]);if(s[c]==2)for(let u of f)h.push(u);else h.push(f)}return e.combine(h)}return{create(a){for(let h of i)Fi(a,h);return a.values[o]=l(a),1},update(a,h){if(!br(a,r))return 0;let c=l(a);return e.compare(c,a.values[o])?0:(a.values[o]=c,1)},reconfigure(a,h){let c=br(a,i),f=h.config.facets[e.id],u=h.facet(e);if(f&&!c&&yr(t,f))return a.values[o]=u,0;let d=l(a);return e.compare(d,u)?(a.values[o]=u,0):(a.values[o]=d,1)}}}const Zl=D.define({static:!0});class be{constructor(e,t,i,s,r){this.id=e,this.createF=t,this.updateF=i,this.compareF=s,this.spec=r,this.provides=void 0}static define(e){let t=new be(Or++,e.create,e.update,e.compare||((i,s)=>i===s),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Zl).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,s)=>{let r=i.values[t],o=this.updateF(r,s);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,s)=>s.config.address[this.id]!=null?(i.values[t]=s.field(this),0):(i.values[t]=this.create(i),1)}}init(e){return[this,Zl.of({field:this,create:e})]}get extension(){return this}}const Kt={lowest:4,low:3,default:2,high:1,highest:0};function ji(n){return e=>new Kl(e,n)}const Bt={highest:ji(Kt.highest),high:ji(Kt.high),default:ji(Kt.default),low:ji(Kt.low),lowest:ji(Kt.lowest)};class Kl{constructor(e,t){this.inner=e,this.prec=t}}class Wn{of(e){return new xr(this,e)}reconfigure(e){return Wn.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class xr{constructor(e,t){this.compartment=e,this.inner=t}}class zn{constructor(e,t,i,s,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=s,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<i.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(e,t,i){let s=[],r=Object.create(null),o=new Map;for(let u of Yd(e,t,o))u instanceof be?s.push(u):(r[u.facet.id]||(r[u.facet.id]=[])).push(u);let l=Object.create(null),a=[],h=[];for(let u of s)l[u.id]=h.length<<1,h.push(d=>u.slot(d));let c=i==null?void 0:i.config.facets;for(let u in r){let d=r[u],p=d[0].facet,O=c&&c[u]||[];if(d.every(m=>m.type==0))if(l[p.id]=a.length<<1|1,yr(O,d))a.push(i.facet(p));else{let m=p.combine(d.map(y=>y.value));a.push(i&&p.compare(m,i.facet(p))?i.facet(p):m)}else{for(let m of d)m.type==0?(l[m.id]=a.length<<1|1,a.push(m.value)):(l[m.id]=h.length<<1,h.push(y=>m.dynamicSlot(y)));l[p.id]=h.length<<1,h.push(m=>Gd(m,p,d))}}let f=h.map(u=>u(l));return new zn(e,o,f,l,a,r)}}function Yd(n,e,t){let i=[[],[],[],[],[]],s=new Map;function r(o,l){let a=s.get(o);if(a!=null){if(a<=l)return;let h=i[a].indexOf(o);h>-1&&i[a].splice(h,1),o instanceof xr&&t.delete(o.compartment)}if(s.set(o,l),Array.isArray(o))for(let h of o)r(h,l);else if(o instanceof xr){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(o.compartment)||o.inner;t.set(o.compartment,h),r(h,l)}else if(o instanceof Kl)r(o.inner,o.prec);else if(o instanceof be)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof Ln)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,Kt.default);else{let h=o.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(h,l)}}return r(n,Kt.default),i.reduce((o,l)=>o.concat(l))}function Fi(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let s=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|s}function In(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const Jl=D.define(),Sr=D.define({combine:n=>n.some(e=>e),static:!0}),ea=D.define({combine:n=>n.length?n[0]:void 0,static:!0}),ta=D.define(),ia=D.define(),na=D.define(),sa=D.define({combine:n=>n.length?n[0]:!1});class ct{constructor(e,t){this.type=e,this.value=t}static define(){return new Zd}}class Zd{of(e){return new ct(this,e)}}class Kd{constructor(e){this.map=e}of(e){return new _(this,e)}}class _{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new _(this.type,t)}is(e){return this.type==e}static define(e={}){return new Kd(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let s of e){let r=s.map(t);r&&i.push(r)}return i}}_.reconfigure=_.define(),_.appendConfig=_.define();class ue{constructor(e,t,i,s,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=s,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Gl(i,t.newLength),r.some(l=>l.type==ue.time)||(this.annotations=r.concat(ue.time.of(Date.now())))}static create(e,t,i,s,r,o){return new ue(e,t,i,s,r,o)}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 t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(ue.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}ue.time=ct.define(),ue.userEvent=ct.define(),ue.addToHistory=ct.define(),ue.remote=ct.define();function Jd(n,e){let t=[];for(let i=0,s=0;;){let r,o;if(i<n.length&&(s==e.length||e[s]>=n[i]))r=n[i++],o=n[i++];else if(s<e.length)r=e[s++],o=e[s++];else return t;!t.length||t[t.length-1]<r?t.push(r,o):t[t.length-1]<o&&(t[t.length-1]=o)}}function ra(n,e,t){var i;let s,r,o;return t?(s=e.changes,r=me.empty(e.changes.length),o=n.changes.compose(e.changes)):(s=e.changes.map(n.changes),r=n.changes.mapDesc(e.changes,!0),o=n.changes.compose(s)),{changes:o,selection:e.selection?e.selection.map(r):(i=n.selection)===null||i===void 0?void 0:i.map(s),effects:_.mapEffects(n.effects,s).concat(_.mapEffects(e.effects,r)),annotations:n.annotations.length?n.annotations.concat(e.annotations):e.annotations,scrollIntoView:n.scrollIntoView||e.scrollIntoView}}function vr(n,e,t){let i=e.selection,s=di(e.annotations);return e.userEvent&&(s=s.concat(ue.userEvent.of(e.userEvent))),{changes:e.changes instanceof me?e.changes:me.of(e.changes||[],t,n.facet(ea)),selection:i&&(i instanceof T?i:T.single(i.anchor,i.head)),effects:di(e.effects),annotations:s,scrollIntoView:!!e.scrollIntoView}}function oa(n,e,t){let i=vr(n,e.length?e[0]:{},n.doc.length);e.length&&e[0].filter===!1&&(t=!1);for(let r=1;r<e.length;r++){e[r].filter===!1&&(t=!1);let o=!!e[r].sequential;i=ra(i,vr(n,e[r],o?i.changes.newLength:n.doc.length),o)}let s=ue.create(n,i.changes,i.selection,i.effects,i.annotations,i.scrollIntoView);return tp(t?ep(s):s)}function ep(n){let e=n.startState,t=!0;for(let s of e.facet(ta)){let r=s(n);if(r===!1){t=!1;break}Array.isArray(r)&&(t=t===!0?r:Jd(t,r))}if(t!==!0){let s,r;if(t===!1)r=n.changes.invertedDesc,s=me.empty(e.doc.length);else{let o=n.changes.filter(t);s=o.changes,r=o.filtered.mapDesc(o.changes).invertedDesc}n=ue.create(e,s,n.selection&&n.selection.map(r),_.mapEffects(n.effects,r),n.annotations,n.scrollIntoView)}let i=e.facet(ia);for(let s=i.length-1;s>=0;s--){let r=i[s](n);r instanceof ue?n=r:Array.isArray(r)&&r.length==1&&r[0]instanceof ue?n=r[0]:n=oa(e,di(r),!1)}return n}function tp(n){let e=n.startState,t=e.facet(na),i=n;for(let s=t.length-1;s>=0;s--){let r=t[s](n);r&&Object.keys(r).length&&(i=ra(i,vr(e,r,n.changes.newLength),!0))}return i==n?n:ue.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const ip=[];function di(n){return n==null?ip:Array.isArray(n)?n:[n]}var le=function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n}(le||(le={}));const np=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let wr;try{wr=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function sp(n){if(wr)return wr.test(n);for(let e=0;e<n.length;e++){let t=n[e];if(/\w/.test(t)||t>"€"&&(t.toUpperCase()!=t.toLowerCase()||np.test(t)))return!0}return!1}function rp(n){return e=>{if(!/\S/.test(e))return le.Space;if(sp(e))return le.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return le.Word;return le.Other}}class U{constructor(e,t,i,s,r,o){this.config=e,this.doc=t,this.selection=i,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;l<this.config.dynamicSlots.length;l++)Fi(this,l<<1);this.computeSlot=null}field(e,t=!0){let i=this.config.address[e.id];if(i==null){if(t)throw new RangeError("Field is not present in this state");return}return Fi(this,i),In(this,i)}update(...e){return oa(this,e,!0)}applyTransaction(e){let t=this.config,{base:i,compartments:s}=t;for(let l of e.effects)l.is(Wn.reconfigure)?(t&&(s=new Map,t.compartments.forEach((a,h)=>s.set(h,a)),t=null),s.set(l.value.compartment,l.value.extension)):l.is(_.reconfigure)?(t=null,i=l.value):l.is(_.appendConfig)&&(t=null,i=di(i).concat(l.value));let r;t?r=e.startState.values.slice():(t=zn.resolve(i,s,this),r=new U(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,h)=>h.reconfigure(a,this),null).values);let o=e.startState.facet(Sr)?e.newSelection:e.newSelection.asSingle();new U(t,e.newDoc,o,r,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:T.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),s=this.changes(i.changes),r=[i.range],o=di(i.effects);for(let l=1;l<t.ranges.length;l++){let a=e(t.ranges[l]),h=this.changes(a.changes),c=h.map(s);for(let u=0;u<l;u++)r[u]=r[u].map(c);let f=s.mapDesc(h,!0);r.push(a.range.map(f)),s=s.compose(c),o=_.mapEffects(o,c).concat(_.mapEffects(di(a.effects),f))}return{changes:s,selection:T.create(r,t.mainIndex),effects:o}}changes(e=[]){return e instanceof me?e:me.of(e,this.doc.length,this.facet(U.lineSeparator))}toText(e){return Y.of(e.split(this.facet(U.lineSeparator)||pr))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:(Fi(this,t),In(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let i in e){let s=e[i];s instanceof be&&this.config.address[s.id]!=null&&(t[i]=s.spec.toJSON(this.field(e[i]),this))}return t}static fromJSON(e,t={},i){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let s=[];if(i){for(let r in i)if(Object.prototype.hasOwnProperty.call(e,r)){let o=i[r],l=e[r];s.push(o.init(a=>o.spec.fromJSON(l,a)))}}return U.create({doc:e.doc,selection:T.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=zn.resolve(e.extensions||[],new Map),i=e.doc instanceof Y?e.doc:Y.of((e.doc||"").split(t.staticFacet(U.lineSeparator)||pr)),s=e.selection?e.selection instanceof T?e.selection:T.single(e.selection.anchor,e.selection.head):T.single(0);return Gl(s,i.length),t.staticFacet(Sr)||(s=s.asSingle()),new U(t,i,s,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(U.tabSize)}get lineBreak(){return this.facet(U.lineSeparator)||` `}get readOnly(){return this.facet(sa)}phrase(e,...t){for(let i of this.facet(U.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,s)=>{if(s=="$")return"$";let r=+(s||1);return!r||r>t.length?i:t[r-1]})),e}languageDataAt(e,t,i=-1){let s=[];for(let r of this.facet(Jl))for(let o of r(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&s.push(o[e]);return s}charCategorizer(e){return rp(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:i,length:s}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=ve(t,o,!1);if(r(t.slice(a,o))!=le.Word)break;o=a}for(;l<s;){let a=ve(t,l);if(r(t.slice(l,a))!=le.Word)break;l=a}return o==l?null:T.range(o+i,l+i)}}U.allowMultipleSelections=Sr,U.tabSize=D.define({combine:n=>n.length?n[0]:4}),U.lineS