code-playpad 0.10.0 → 0.11.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.
- package/README.md +218 -17
- package/dist/THIRD-PARTY-NOTICES.txt +223 -0
- package/dist/cdn.js +2 -2
- package/dist/compiler-B408qd3N.js +151 -0
- package/dist/{config-CT3H6Oum.js → config-DB58UVsk.js} +1 -1
- package/dist/{cpp-CO2abWii.js → cpp-C77X5wRk.js} +1 -1
- package/dist/{cpp-Cs32J8JC.js → cpp-DuOQ_23Z.js} +1 -1
- package/dist/{dist-DXjodKfp.js → dist-B4dyQ4mN.js} +1 -1
- package/dist/{dist-BkpKCrXQ.js → dist-BFlbXnjn.js} +1 -1
- package/dist/dist-BoJapv5W.js +28 -0
- package/dist/dist-BqLa1O1y.js +6 -0
- package/dist/dist-CJRlQ049.js +6 -0
- package/dist/{dist-CJxiVI4a.js → dist-DBpvb9b1.js} +1 -1
- package/dist/{dist-BIgiGgKu.js → dist-DRocX-cv.js} +1 -1
- package/dist/dist-DfjaG4Ra.js +6 -0
- package/dist/{dist-D2igTc4m.js → dist-DviSDQoT.js} +1 -1
- package/dist/dist-F28mE6nM.js +8 -0
- package/dist/{dist-CNOK8CHE.js → dist-TxeNlzAy.js} +1 -1
- package/dist/dist-y6lcdYKh.js +14 -0
- package/dist/element-COcjM0hI.js +521 -0
- package/dist/element.d.ts +26 -0
- package/dist/element.js +1 -1
- package/dist/hints-DpBIeoeG.js +6 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/{java-DeBiVPXO.js → java-Df5HdXMz.js} +1 -1
- package/dist/{java-8qjVCjsN.js → java-DyH3mSiH.js} +1 -1
- package/dist/{javascript-DLPaJJzf.js → javascript-BtHVyxzg.js} +2 -2
- package/dist/{javascript-B1tVx7AD.js → javascript-CWolHiSP.js} +1 -1
- package/dist/languages.d.ts +1 -1
- package/dist/{pyodide-BOoYEfX1.js → pyodide-3MPS4ySA.js} +2 -2
- package/dist/{pyodide-C8ImkXdD.js → pyodide-EUDn__Gx.js} +1 -1
- package/dist/react-CL1KABFm.js +9 -0
- package/dist/react-Db_rGDYu.js +4 -0
- package/dist/react-runtime-19.2.8.js +240 -0
- package/dist/react-vendor.generated-DMxIoCMn.js +6 -0
- package/dist/react-version.generated-BNNJmf7J.js +6 -0
- package/dist/react.d.ts +5 -1
- package/dist/react.js +1 -1
- package/dist/runtime/config.d.ts +15 -1
- package/dist/runtime/react/boot.d.ts +9 -0
- package/dist/runtime/react/compiler.d.ts +30 -0
- package/dist/runtime/react-vendor.generated.d.ts +5 -0
- package/dist/runtime/react-version.generated.d.ts +3 -0
- package/dist/runtime/react.d.ts +2 -0
- package/dist/standalone.js +214 -17
- package/dist/{hints-CCMgezw9.js → types-CfcYqU2K.js} +1 -1
- package/dist/types.d.ts +23 -0
- package/dist/worker-runtime-DvpugeXD.js +9 -0
- package/dist/{worker-runtime-sUPz1J56.js → worker-runtime-PykJQLB7.js} +1 -1
- package/package.json +21 -6
- package/dist/dist--J_vhCIU.js +0 -14
- package/dist/dist-BNvM_BAY.js +0 -6
- package/dist/dist-D7jBL3Ib.js +0 -28
- package/dist/dist-DfFrsBkU.js +0 -8
- package/dist/element-CQGYVEF7.js +0 -324
- package/dist/worker-runtime-DfYet3xy.js +0 -9
package/dist/dist-DfFrsBkU.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* code-playpad — MIT © 2026 Seung Hun Lee
|
|
3
|
-
* Bundles CodeMirror 6 and Lezer (MIT) © Marijn Haverbeke and others.
|
|
4
|
-
* Full third-party licences: THIRD-PARTY-NOTICES.txt in this package.
|
|
5
|
-
*/
|
|
6
|
-
import{b as e,d as t,l as n,m as r,o as i,p as a,s as o,u as s,y as c}from"./dist-D25hs99E.js";import{a as l,d as u,i as d,l as f,n as p,o as m,p as h,r as g,t as _}from"./dist-Vr-fb58P.js";var ee=1024,v=0,y=class{constructor(e,t){this.from=e,this.to=t}},b=class{constructor(e={}){this.id=v++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=C.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};b.closedBy=new b({deserialize:e=>e.split(` `)}),b.openedBy=new b({deserialize:e=>e.split(` `)}),b.group=new b({deserialize:e=>e.split(` `)}),b.isolate=new b({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),b.contextHash=new b({perNode:!0}),b.lookAhead=new b({perNode:!0}),b.mounted=new b({perNode:!0});var x=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[b.mounted.id]}},S=Object.create(null),C=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):S,r=+!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e==`string`){if(this.name==e)return!0;let t=this.prop(b.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(b.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};C.none=new C(``,Object.create(null),0,8);var w=class e{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError(`Node type ids should correspond to array positions when creating a node set`)}extend(...t){let n=[];for(let e of this.types){let r=null;for(let n of t){let t=n(e);if(t){r||=Object.assign({},e.props);let n=t[1],i=t[0];i.combine&&i.id in r&&(n=i.combine(r[i.id],n)),r[i.id]=n}}n.push(r?new C(e.name,r,e.id,e.flags):e)}return new e(n)}},T=/* @__PURE__ */ new WeakMap,E=/* @__PURE__ */ new WeakMap,D;(function(e){e[e.ExcludeBuffers=1]=`ExcludeBuffers`,e[e.IncludeAnonymous=2]=`IncludeAnonymous`,e[e.IgnoreMounts=4]=`IgnoreMounts`,e[e.IgnoreOverlays=8]=`IgnoreOverlays`,e[e.EnterBracketed=16]=`EnterBracketed`})(D||={});var O=class e{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e==`number`?e:e.id]=t}}toString(){let e=x.get(this);if(e&&!e.overlay)return e.tree.toString();let t=``;for(let e of this.children){let n=e.toString();n&&(t&&(t+=`,`),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?`(`+t+`)`:``):t}cursor(e=0){return new ue(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new ue(T.get(this)||this.topNode);return r.moveTo(e,t),T.set(this,r._tree),r}get topNode(){return new j(this,0,0,null)}resolve(e,t=0){let n=A(T.get(this)||this.topNode,e,t,!1);return T.set(this,n),n}resolveInner(e,t=0){let n=A(E.get(this)||this.topNode,e,t,!0);return E.set(this,n),n}resolveStack(e,t=0){return le(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&D.IncludeAnonymous)>0;for(let e=this.cursor(a|D.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(t={}){return this.children.length<=8?this:he(C.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(C.none,t,n,r)))}static build(e){return fe(e)}};O.empty=new O(C.none,[],[],0);var te=class e{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new e(this.buffer,this.index)}},k=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return C.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(`,`)}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let a=[];for(;e<n;)a.push(this.childString(e)),e=this.buffer[e+3];return i+`(`+a.join(`,`)+`)`}findChild(e,t,n,r,i){let{buffer:a}=this,o=-1;for(let s=e;s!=t&&!(ne(i,r,a[s+1],a[s+2])&&(o=s,n>0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e<n;){a[s++]=i[e++],a[s++]=i[e++]-r;let n=a[s++]=i[e++]-r;a[s++]=i[e++]-t,o=Math.max(o,n)}return new e(a,o,this.set)}};function ne(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function A(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof j&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:D.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof j&&r.index<0&&a.enter(t,n,i)?.from!=r.from&&(e=a);for(;;){let r=e.enter(t,n,i);if(!r)return e;e=r}}var re=class{cursor(e=0){return new ue(this,e)}getChild(e,t=null,n=null){let r=ie(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return ie(this,e,t,n)}resolve(e,t=0){return A(this,e,t,!1)}resolveInner(e,t=0){return A(this,e,t,!0)}matchContext(e){return ae(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}},j=class e extends re{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,a=0){for(let o=this;;){for(let{children:s,positions:c}=o._tree,l=n>0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(a&D.EnterBracketed&&l instanceof O&&(d=x.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length||ne(i,r,u,u+l.length)){if(l instanceof k){if(a&D.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new M(new oe(o,l,t,u),null,e)}else if(a&D.IncludeAnonymous||!l.type.isAnonymous||de(l)){let s;if(!(a&D.IgnoreMounts)&&(s=x.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&D.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&D.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&D.IgnoreOverlays)&&(i=x.get(this._tree))&&i.overlay){let a=t-this.from,o=r&D.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t<a)&&(n<0||o?r>=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function ie(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function ae(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var oe=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},M=class e extends re{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(t,n,r=0){if(r&D.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new O(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function se(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof j&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new ce(i,n)}var ce=class{constructor(e,t){this.heads=e,this.node=t}get next(){return se(this.heads)}};function le(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof j?r:r.context.parent;e;e=e.parent)if(e.index<0){let a=e.parent;(i||=[r]).push(a.resolve(t,n)),e=a}else{let a=x.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new j(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(A(o,t,n,!1))}}return i?se(i):r}var ue=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~D.EnterBracketed,e instanceof j)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof j?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&D.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&D.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&D.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&D.IncludeAnonymous||e instanceof k||!e.type.isAnonymous||de(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)scan:for(let r=this.index,i=this.stack.length;i>=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new M(this.buffer,t,this.stack[e]);return this.bufferNode=new M(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return ae(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return ae(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function de(e){return e.children.some(e=>e instanceof k||!e.type.isAnonymous||de(e))}function fe(e){let{buffer:t,nodeSet:n,maxBufferLength:r=ee,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new te(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,ee,v,y){let{id:b,start:x,end:S,size:C}=o,w=l,T=c;if(C<0){if(o.next(),C==-1){let t=i[b];_.push(t),ee.push(x-e);return}if(C==-3){c=b;return}if(C==-4){l=b;return}throw RangeError(`Unrecognized record size: ${C}`)}let E=s[b],D,O,te=x-e;if(S-x<=r&&(O=h(o.pos-t,v))){let t=new Uint16Array(O.size-O.skip),r=o.pos-O.size,i=t.length;for(;o.pos>r;)i=g(O.start,t,i);D=new k(t,S-O.start,n),te=O.start-e}else{let e=o.pos-C;o.next();let t=[],n=[],i=b>=a?b:-1,s=0,c=S;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,x,s,o.end,c,i,w,T),s=t.length,c=o.end),o.next()):y>2500?d(x,e,t,n):u(x,e,t,n,i,y+1);if(i>=0&&s>0&&s<t.length&&p(t,n,x,s,x,c,i,w,T),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(E,T);D=he(E,t,n,0,t.length,0,S-x,e,e)}else D=m(E,t,n,S-x,w-S,T)}_.push(D),ee.push(te)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t<l)break;else l<0&&(l=n-r),s.push(e,t,n),c++,o.next()}if(c){let t=new Uint16Array(c*4),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new k(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof O){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(b.lookAhead))&&(a=r[o]+s.length+c)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[b.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[b.lookAhead,i];o=o?[e].concat(o):[e]}return new O(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o<r||n.start<l)break;let d=n.id>=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0){if(n.size==-3||n.size==-4)d+=4;else break scan}else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r<a){let a=n;if(u>4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new O(s[e.topID],_.reverse(),v.reverse(),y)}var pe=/* @__PURE__ */ new WeakMap;function me(e,t){if(!e.isAnonymous||t instanceof k||t.type!=e)return 1;let n=pe.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof O)){n=1;break}n+=me(e,r)}pe.set(t,n)}return n}function he(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=me(e,t[n]);let u=Math.ceil(l*1.5/8),d=[],f=[];function p(t,n,r,i,o){for(let s=r;s<i;){let r=s,l=n[s],m=me(e,t[s]);for(s++;s<i;s++){let n=me(e,t[s]);if(m+n>=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(he(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var ge=class{constructor(){this.map=/* @__PURE__ */ new WeakMap}setBuffer(e,t,n){let r=this.map.get(e);r||this.map.set(e,r=/* @__PURE__ */ new Map),r.set(t,n)}getBuffer(e,t){let n=this.map.get(e);return n&&n.get(t)}set(e,t){e instanceof M?this.setBuffer(e.context.buffer,e.index,t):e instanceof j&&this.map.set(e.tree,t)}get(e){return e instanceof M?this.getBuffer(e.context.buffer,e.index):e instanceof j?this.map.get(e.tree):void 0}cursorSet(e,t){e.buffer?this.setBuffer(e.buffer.buffer,e.index,t):this.map.set(e.tree,t)}cursorGet(e){return e.buffer?this.getBuffer(e.buffer.buffer,e.index):this.map.get(e.tree)}},_e=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s<n.length?n[s]:null,d=u?u.fromA:1e9;if(d-c>=r)for(;o&&o.from<d;){let n=o;if(c>=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=a<t.length?t[a++]:null}if(!u)break;c=u.toA,l=u.toA-u.toB}return i}},ve=class{startParse(e,t,n){return typeof e==`string`&&(e=new ye(e)),n=n?n.length?n.map(e=>new y(e.from,e.to)):[new y(0,0)]:[new y(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},ye=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};new b({perNode:!0});var be=0,N=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=be++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new Se(e);return e=>e.modified.indexOf(t)>-1?e:Se.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},xe=0,Se=class e{constructor(e){this.name=e,this.instances=[],this.id=xe++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&Ce(n,e.modified));if(r)return r;let i=[],a=new N(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=we(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function Ce(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function we(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}function Te(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new P(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return Ee.add(t)}var Ee=new b({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new P(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),P=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};P.empty=new P([],2,null);function De(e,t){let n=Object.create(null);for(let t of e)if(!Array.isArray(t.tag))n[t.tag.id]=t.class;else for(let e of t.tag)n[e.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function Oe(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function ke(e,t,n,r=0,i=e.length){let a=new Ae(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var Ae=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=je(e)||P.empty,u=Oe(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(b.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f<d.overlay.length?d.overlay[f]:null,h=m?m.from+o:s,g=Math.max(t,p),_=Math.min(n,h);if(g<_&&u)for(;e.from<_&&(this.highlightRange(e,g,_,r,i),this.startSpan(Math.min(_,e.to),c),!(e.to>=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function je(e){let t=e.type.prop(Ee);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var F=N.define,Me=F(),I=F(),Ne=F(I),Pe=F(I),L=F(),Fe=F(L),Ie=F(L),R=F(),z=F(R),B=F(),V=F(),Le=F(),H=F(Le),Re=F(),U={comment:Me,lineComment:F(Me),blockComment:F(Me),docComment:F(Me),name:I,variableName:F(I),typeName:Ne,tagName:F(Ne),propertyName:Pe,attributeName:F(Pe),className:F(I),labelName:F(I),namespace:F(I),macroName:F(I),literal:L,string:Fe,docString:F(Fe),character:F(Fe),attributeValue:F(Fe),number:Ie,integer:F(Ie),float:F(Ie),bool:F(L),regexp:F(L),escape:F(L),color:F(L),url:F(L),keyword:B,self:F(B),null:F(B),atom:F(B),unit:F(B),modifier:F(B),operatorKeyword:F(B),controlKeyword:F(B),definitionKeyword:F(B),moduleKeyword:F(B),operator:V,derefOperator:F(V),arithmeticOperator:F(V),logicOperator:F(V),bitwiseOperator:F(V),compareOperator:F(V),updateOperator:F(V),definitionOperator:F(V),typeOperator:F(V),controlOperator:F(V),punctuation:Le,separator:F(Le),bracket:H,angleBracket:F(H),squareBracket:F(H),paren:F(H),brace:F(H),content:R,heading:z,heading1:F(z),heading2:F(z),heading3:F(z),heading4:F(z),heading5:F(z),heading6:F(z),contentSeparator:F(R),list:F(R),quote:F(R),emphasis:F(R),strong:F(R),link:F(R),monospace:F(R),strikethrough:F(R),inserted:F(),deleted:F(),changed:F(),invalid:F(),meta:Re,documentMeta:F(Re),annotation:F(Re),processingInstruction:F(Re),definition:N.defineModifier(`definition`),constant:N.defineModifier(`constant`),function:N.defineModifier(`function`),standard:N.defineModifier(`standard`),local:N.defineModifier(`local`),special:N.defineModifier(`special`)};for(let e in U){let t=U[e];t instanceof N&&(t.name=e)}De([{tag:U.link,class:`tok-link`},{tag:U.heading,class:`tok-heading`},{tag:U.emphasis,class:`tok-emphasis`},{tag:U.strong,class:`tok-strong`},{tag:U.keyword,class:`tok-keyword`},{tag:U.atom,class:`tok-atom`},{tag:U.bool,class:`tok-bool`},{tag:U.url,class:`tok-url`},{tag:U.labelName,class:`tok-labelName`},{tag:U.inserted,class:`tok-inserted`},{tag:U.deleted,class:`tok-deleted`},{tag:U.literal,class:`tok-literal`},{tag:U.string,class:`tok-string`},{tag:U.number,class:`tok-number`},{tag:[U.regexp,U.escape,U.special(U.string)],class:`tok-string2`},{tag:U.variableName,class:`tok-variableName`},{tag:U.local(U.variableName),class:`tok-variableName tok-local`},{tag:U.definition(U.variableName),class:`tok-variableName tok-definition`},{tag:U.special(U.variableName),class:`tok-variableName2`},{tag:U.definition(U.propertyName),class:`tok-propertyName tok-definition`},{tag:U.typeName,class:`tok-typeName`},{tag:U.namespace,class:`tok-namespace`},{tag:U.className,class:`tok-className`},{tag:U.macroName,class:`tok-macroName`},{tag:U.propertyName,class:`tok-propertyName`},{tag:U.operator,class:`tok-operator`},{tag:U.comment,class:`tok-comment`},{tag:U.meta,class:`tok-meta`},{tag:U.invalid,class:`tok-invalid`},{tag:U.punctuation,class:`tok-punctuation`}]);var W=/*@__PURE__*/ new b;function ze(e){return o.define({combine:e?t=>t.concat(e):void 0})}var Be=/*@__PURE__*/ new b,G=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,i.prototype.hasOwnProperty(`tree`)||Object.defineProperty(i.prototype,"tree",{get(){return K(this)}}),this.parser=t,this.extension=[q.of(this),i.languageData.of((e,t,n)=>{let r=Ve(e,t,n),i=r.type.prop(W);if(!i)return[];let a=e.facet(i),o=r.type.prop(Be);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return Ve(e,t,n).type.prop(W)==this.data}findRegions(e){let t=e.facet(q);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(W)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(b.mounted);if(i){if(i.tree.prop(W)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof O&&r(i,e.positions[n]+t)}};return r(K(e),0),n}get allowsNesting(){return!0}};G.setState=/*@__PURE__*/ a.define();function Ve(e,t,n){let r=e.facet(q),i=K(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,D.ExcludeBuffers|D.EnterBracketed))e.type.isTop&&(i=e);return i}var He=class e extends G{constructor(e,t,n){super(e,t,[],n),this.parser=t}static define(t){let n=ze(t.languageData);return new e(n,t.parser.configure({props:[W.add(e=>e.isTop?n:void 0)]}),t.name)}configure(t,n){return new e(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function K(e){let t=e.field(G.state,!1);return t?t.tree:O.empty}function Ue(e,t,n=50){let r=e.field(G.state,!1)?.context;if(!r)return null;let i=r.viewport;r.updateViewport({from:0,to:t});let a=r.isDone(t)||r.work(n,t)?r.tree:null;return r.updateViewport(i),a}function We(e,t=e.doc.length){return e.field(G.state,!1)?.context.isDone(t)||!1}function Ge(e,t=e.viewport.to,n=100){let r=Ue(e.state,t,n);return r!=K(e.state)&&e.dispatch({}),!!r}function Ke(e){return e.plugin(et)?.isWorking()||!1}var qe=class{constructor(e){this.doc=e,this.cursorPos=0,this.string=``,this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},Je=null,Ye=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],O.empty,0,r,[],null)}startParse(){return this.parser.startParse(new qe(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=O.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(_e.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=this.parse.stoppedAt??this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0}if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(_e.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Je;Je=this;try{return e()}finally{Je=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Xe(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=_e.applyChanges(r,e),i=O.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);n<r&&s.push({from:n,to:r})}}}return new e(this.parser,n,r,i,a,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=Xe(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends ve{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=Je;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new O(C.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Je}};function Xe(e,t,n){return _e.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var Ze=class e{constructor(e){this.context=e,this.tree=e.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=Ye.create(t.facet(q).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};G.state=/*@__PURE__*/ r.define({create:Ze.init,update(e,t){for(let e of t.effects)if(e.is(G.setState))return e.value;return t.startState.facet(q)==t.state.facet(q)?e.apply(t):Ze.init(t.state)}});var Qe=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(Qe=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var $e=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,et=/*@__PURE__*/ l.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(G.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(G.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=Qe(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(G.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!$e?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>$e&&$e()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:G.setState.of(new Ze(i.context))})),this.chunkBudget>0&&(!s||o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>u(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),q=/*@__PURE__*/ o.define({combine(e){return e.length?e[0]:null},enables:e=>[G.state,et,g.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),tt=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},nt=class e{constructor(e,t,n,r,i,a=void 0){this.name=e,this.alias=t,this.extensions=n,this.filename=r,this.loadFunc=i,this.support=a,this.loading=null}load(){return this.loading||=this.loadFunc().then(e=>this.support=e,e=>{throw this.loading=null,e})}static of(t){let{load:n,support:r}=t;if(!n){if(!r)throw RangeError(`Must pass either 'load' or 'support' to LanguageDescription.of`);n=()=>Promise.resolve(r)}return new e(t.name,(t.alias||[]).concat(t.name).map(e=>e.toLowerCase()),t.extensions||[],t.filename,n,r)}static matchFilename(e,t){for(let n of e)if(n.filename&&n.filename.test(t))return n;let n=/\.([^.]+)$/.exec(t);if(n){for(let t of e)if(t.extensions.indexOf(n[1])>-1)return t}return null}static matchLanguageName(e,t,n=!0){t=t.toLowerCase();for(let n of e)if(n.alias.some(e=>e==t))return n;if(n)for(let n of e)for(let e of n.alias){let r=t.indexOf(e);if(r>-1&&(e.length>2||!/\w/.test(t[r-1])&&!/\w/.test(t[r+e.length])))return n}return null}},rt=/*@__PURE__*/ o.define(),it=/*@__PURE__*/ o.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function at(e){let t=e.facet(it);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function ot(e,t){let n=``,r=e.tabSize,i=e.facet(it)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function st(e,t){e instanceof i&&(e=new lt(e));for(let n of e.state.facet(rt)){let r=n(e,t);if(r!==void 0)return r}let n=K(e.state);return n.length>=t?dt(e,n,t):null}function ct(e,t,n){let r=Object.create(null),i=new lt(e,{overrideIndentation:e=>r[e]??-1}),a=[];for(let o=t;o<=n;){let t=e.doc.lineAt(o);o=t.to+1;let n=st(i,t.from);if(n==null)continue;/\S/.test(t.text)||(n=0);let s=/^\s*/.exec(t.text)[0],c=ot(e,n);s!=c&&(r[t.from]=n,a.push({from:t.from,to:t.from+s.length,insert:c}))}return e.changes(a)}var lt=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=at(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return``;let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),a=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return a>-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(t,n=t.length){return e(t,this.state.tabSize,n)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},ut=/*@__PURE__*/ new b;function dt(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return ft(r,e,n)}function ft(e,t,n){for(let r=e;r;r=r.next){let e=mt(r.node);if(e)return e(gt.create(t,n,r))}return 0}function pt(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function mt(e){let t=e.type.prop(ut);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(b.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>bt(e,!0,1,void 0,n&&!pt(e)?t.from:void 0)}return e.parent==null?ht:null}function ht(){return 0}var gt=class e extends lt{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(_t(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return ft(this.context.next,this.base,this.pos)}};function _t(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function vt(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function yt({closing:e,align:t=!0,units:n=1}){return r=>bt(r,t,n,e)}function bt(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?vt(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}var xt=e=>e.baseIndent;function St({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var Ct=200;function wt(){return i.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent(`input.type`)&&!e.isUserEvent(`input.complete`))return e;let t=e.startState.languageDataAt(`indentOnInput`,e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+Ct)return e;let a=n.sliceString(i.from,r);if(!t.some(e=>e.test(a)))return e;let{state:o}=e,s=-1,c=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==s)continue;s=t.from;let n=st(o,t.from);if(n==null)continue;let r=/^\s*/.exec(t.text)[0],i=ot(o,n);r!=i&&c.push({from:t.from,to:t.from+r.length,insert:i})}return c.length?[e,{changes:c,sequential:!0}]:e})}var Tt=/*@__PURE__*/ o.define(),Et=/*@__PURE__*/ new b;function Dt(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}function Ot(e,t,n){let r=K(e);if(r.length<n)return null;let i=r.resolveStack(n,1),a=null;for(let o=i;o;o=o.next){let i=o.node;if(i.to<=n||i.from>n)continue;if(a&&i.from<t)break;let s=i.type.prop(Et);if(s&&(i.to<r.length-50||r.length==e.doc.length||!kt(i))){let r=s(i,e);r&&r.from<=n&&r.from>=t&&r.to>n&&(a=r)}}return a}function kt(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function J(e,t,n){for(let r of e.facet(Tt)){let i=r(e,t,n);if(i)return i}return Ot(e,t,n)}function At(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}var Y=/*@__PURE__*/ a.define({map:At}),X=/*@__PURE__*/ a.define({map:At});function jt(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}var Z=/*@__PURE__*/ r.define({create(){return _.none},update(e,t){t.isUserEvent(`delete`)&&t.changes.iterChangedRanges((t,n)=>e=Mt(e,t,n)),e=e.map(t.changes);let n=[];for(let r of t.effects)r.is(Y)&&!Ft(e,r.value.from,r.value.to)?n.push(r.value):r.is(X)&&(e=e.update({filter:(e,t)=>r.value.from!=e||r.value.to!=t,filterFrom:r.value.from,filterTo:r.value.to}));if(n.length){let{preparePlaceholder:r}=t.state.facet(Kt),i=n.map(e=>(r?_.replace({widget:new Xt(r(t.state,e))}):Yt).range(e.from,e.to));e=e.update({add:i})}return t.selection&&(e=Mt(e,t.selection.main.head)),e},provide:e=>g.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw RangeError(`Invalid JSON for fold state`);let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid JSON for fold state`);t.push(Yt.range(r,i))}return _.set(t,!0)}});function Mt(e,t,n=t){let r=!1;return e.between(t,n,(e,i)=>{e<n&&i>t&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:(e,r)=>e>=n||r<=t}):e}function Nt(e){return e.field(Z,!1)||s.empty}function Pt(e,t,n){var r;let i=null;return(r=e.field(Z,!1))==null||r.between(t,n,(e,t)=>{(!i||i.from>e)&&(i={from:e,to:t})}),i}function Ft(e,t,n){let r=!1;return e.between(t,t,(e,i)=>{e==t&&i==n&&(r=!0)}),r}function It(e,t){return e.field(Z,!1)?t:t.concat(a.appendConfig.of(qt()))}var Lt=e=>{for(let t of jt(e)){let n=J(e.state,t.from,t.to);if(n)return e.dispatch({effects:It(e.state,[Y.of(n),zt(e,n)])}),!0}return!1},Rt=e=>{if(!e.state.field(Z,!1))return!1;let t=[];for(let n of jt(e)){let r=Pt(e.state,n.from,n.to);r&&t.push(X.of(r),zt(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function zt(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return g.announce.of(`${e.state.phrase(n?`Folded lines`:`Unfolded lines`)} ${r} ${e.state.phrase(`to`)} ${i}.`)}var Bt=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=J(t,i.from,i.to);a&&n.push(Y.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:It(e.state,n)}),!!n.length},Vt=e=>{let t=e.state.field(Z,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(X.of({from:e,to:t}))}),e.dispatch({effects:n}),!0};function Ht(e,t){for(let n=t;;){let r=J(e.state,n.from,n.to);if(r&&r.to>t.from)return r;if(!n.from)return null;n=e.lineBlockAt(n.from-1)}}var Ut=e=>{let t=[];for(let n of jt(e)){let r=Pt(e.state,n.from,n.to);if(r)t.push(X.of(r),zt(e,r,!1));else{let r=Ht(e,n);r&&t.push(Y.of(r),zt(e,r))}}return t.length>0&&e.dispatch({effects:It(e.state,t)}),!!t.length},Wt=[{key:`Ctrl-Shift-[`,mac:`Cmd-Alt-[`,run:Lt},{key:`Ctrl-Shift-]`,mac:`Cmd-Alt-]`,run:Rt},{key:`Ctrl-Alt-[`,run:Bt},{key:`Ctrl-Alt-]`,run:Vt}],Gt={placeholderDOM:null,preparePlaceholder:null,placeholderText:`…`},Kt=/*@__PURE__*/ o.define({combine(e){return c(e,Gt)}});function qt(e){let t=[Z,en];return e&&t.push(Kt.of(e)),t}function Jt(e,t){let{state:n}=e,r=n.facet(Kt),i=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),r=Pt(e.state,n.from,n.to);r&&e.dispatch({effects:X.of(r)}),t.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let a=document.createElement(`span`);return a.textContent=r.placeholderText,a.setAttribute(`aria-label`,n.phrase(`folded code`)),a.title=n.phrase(`unfold`),a.className=`cm-foldPlaceholder`,a.onclick=i,a}var Yt=/*@__PURE__*/ _.replace({widget:/*@__PURE__*/ new class extends m{toDOM(e){return Jt(e,null)}}}),Xt=class extends m{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return Jt(e,this.value)}},Zt={openText:`⌄`,closedText:`›`,markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},Qt=class extends d{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement(`span`);return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?`Fold line`:`Unfold line`),t}};function $t(e={}){let n={...Zt,...e},r=new Qt(n,!0),i=new Qt(n,!1),a=l.fromClass(class{constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}update(e){(e.docChanged||e.viewportChanged||e.startState.facet(q)!=e.state.facet(q)||e.startState.field(Z,!1)!=e.state.field(Z,!1)||K(e.startState)!=K(e.state)||n.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let n=new t;for(let t of e.viewportLineBlocks){let a=Pt(e.state,t.from,t.to)?i:J(e.state,t.from,t.to)?r:null;a&&n.add(t.from,t.from,a)}return n.finish()}}),{domEventHandlers:o}=n;return[a,f({class:`cm-foldGutter`,markers(e){return e.plugin(a)?.markers||s.empty},initialSpacer(){return new Qt(n,!1)},domEventHandlers:{...o,click:(e,t,n)=>{if(o.click&&o.click(e,t,n))return!0;let r=Pt(e.state,t.from,t.to);if(r)return e.dispatch({effects:X.of(r)}),!0;let i=J(e.state,t.from,t.to);return i?(e.dispatch({effects:Y.of(i)}),!0):!1}}}),qt()]}var en=/*@__PURE__*/ g.baseTheme({".cm-foldPlaceholder":{backgroundColor:`#eee`,border:`1px solid #ddd`,color:`#888`,borderRadius:`.2em`,margin:`0 1px`,padding:`0 1px`,cursor:`pointer`},".cm-foldGutter span":{padding:`0 1px`,cursor:`pointer`}}),tn=class e{constructor(e,t){this.specs=e;let n;function r(e){let t=h.newName();return(n||=Object.create(null))[`.`+t]=e,t}let i=typeof t.all==`string`?t.all:t.all?r(t.all):void 0,a=t.scope;this.scope=a instanceof G?e=>e.prop(W)==a.data:a?e=>e==a:void 0,this.style=De(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new h(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},nn=/*@__PURE__*/ o.define(),rn=/*@__PURE__*/ o.define({combine(e){return e.length?[e[0]]:null}});function an(e){let t=e.facet(nn);return t.length?t:e.facet(rn)}function on(e,t){let n=[ln],r;return e instanceof tn&&(e.module&&n.push(g.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(rn.of(e)):r?n.push(nn.computeN([g.darkTheme],t=>t.facet(g.darkTheme)==(r==`dark`)?[e]:[])):n.push(nn.of(e)),n}function sn(e,t,n){let r=an(e),i=null;if(r){for(let e of r)if(!e.scope||n&&e.scope(n)){let n=e.style(t);n&&(i=i?i+` `+n:n)}}return i}var cn=class{constructor(e){this.markCache=Object.create(null),this.tree=K(e.state),this.decorations=this.buildDeco(e,an(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=K(e.state),n=an(e.state),r=n!=an(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&a>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,n){if(!n||!this.tree.length)return _.none;let r=new t;for(let{from:t,to:i}of e.visibleRanges)ke(this.tree,n,(e,t,n)=>{r.add(e,t,this.markCache[n]||(this.markCache[n]=_.mark({class:n})))},t,i);return r.finish()}},ln=/*@__PURE__*/ n.high(/*@__PURE__*/ l.fromClass(cn,{decorations:e=>e.decorations})),un=/*@__PURE__*/ tn.define([{tag:U.meta,color:`#404740`},{tag:U.link,textDecoration:`underline`},{tag:U.heading,textDecoration:`underline`,fontWeight:`bold`},{tag:U.emphasis,fontStyle:`italic`},{tag:U.strong,fontWeight:`bold`},{tag:U.strikethrough,textDecoration:`line-through`},{tag:U.keyword,color:`#708`},{tag:[U.atom,U.bool,U.url,U.contentSeparator,U.labelName],color:`#219`},{tag:[U.literal,U.inserted],color:`#164`},{tag:[U.string,U.deleted],color:`#a11`},{tag:[U.regexp,U.escape,/*@__PURE__*/ U.special(U.string)],color:`#e40`},{tag:/*@__PURE__*/ U.definition(U.variableName),color:`#00f`},{tag:/*@__PURE__*/ U.local(U.variableName),color:`#30a`},{tag:[U.typeName,U.namespace],color:`#085`},{tag:U.className,color:`#167`},{tag:[/*@__PURE__*/ U.special(U.variableName),U.macroName],color:`#256`},{tag:/*@__PURE__*/ U.definition(U.propertyName),color:`#00c`},{tag:U.comment,color:`#940`},{tag:U.invalid,color:`#f00`}]),dn=/*@__PURE__*/ g.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:`#328c8252`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bb555544`}}),fn=1e4,pn=`()[]{}`,mn=/*@__PURE__*/ o.define({combine(e){return c(e,{afterCursor:!0,brackets:pn,maxScanDistance:fn,renderMatch:_n})}}),hn=/*@__PURE__*/ _.mark({class:`cm-matchingBracket`}),gn=/*@__PURE__*/ _.mark({class:`cm-nonmatchingBracket`});function _n(e){let t=[],n=e.matched?hn:gn;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function vn(e){let t=[],n=e.facet(mn);for(let r of e.selection.ranges){if(!r.empty)continue;let i=Q(e,r.head,-1,n)||r.head>0&&Q(e,r.head-1,1,n)||n.afterCursor&&(Q(e,r.head,1,n)||r.head<e.doc.length&&Q(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return _.set(t,!0)}var yn=[/* @__PURE__ */ l.fromClass(class{constructor(e){this.paused=!1,this.decorations=vn(e.state)}update(e){(e.docChanged||e.selectionSet||this.paused)&&(e.view.composing?(this.decorations=this.decorations.map(e.changes),this.paused=!0):(this.decorations=vn(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),dn];function bn(e={}){return[mn.of(e),yn]}var xn=/*@__PURE__*/ new b;function Sn(e,t,n){let r=e.prop(t<0?b.openedBy:b.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function Cn(e){let t=e.type.prop(xn);return t?t(e.node):e}function Q(e,t,n,r={}){let i=r.maxScanDistance||fn,a=r.brackets||pn,o=K(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=Sn(r.type,n,a);if(i&&r.from<r.to){let o=Cn(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return wn(e,t,n,r,o,i,a)}}return Tn(e,t,n,o,s.type,i,a)}function wn(e,t,n,r,i,a,o){let s=r.parent,c={from:i.from,to:i.to},l=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(l==0&&a.indexOf(u.type.name)>-1&&u.from<u.to){let e=Cn(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(Sn(u.type,n,o))l++;else if(Sn(u.type,-n,o)){if(l==0){let e=Cn(u);return{start:c,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}l--}}while(n<0?u.prevSibling():u.nextSibling());return{start:c,matched:!1}}function Tn(e,t,n,r,i,a,o){if(n<0?!t:t==e.doc.length)return null;let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),c=o.indexOf(s);if(c<0||c%2==0!=n>0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i)){if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}function En(e,t,n,r=0,i=0){t??(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));let a=i;for(let i=r;i<t;i++)e.charCodeAt(i)==9?a+=n-a%n:a++;return a}var Dn=class{constructor(e,t,n,r){this.string=e,this.tabSize=t,this.indentUnit=n,this.overrideIndent=r,this.pos=0,this.start=0,this.lastColumnPos=0,this.lastColumnValue=0}eol(){return this.pos>=this.string.length}sol(){return this.pos==0}peek(){return this.string.charAt(this.pos)||void 0}next(){if(this.pos<this.string.length)return this.string.charAt(this.pos++)}eat(e){let t=this.string.charAt(this.pos),n;if(n=typeof e==`string`?t==e:t&&(e instanceof RegExp?e.test(t):e(t)),n)return++this.pos,t}eatWhile(e){let t=this.pos;for(;this.eat(e););return this.pos>t}eatSpace(){let e=this.pos;for(;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e}skipToEnd(){this.pos=this.string.length}skipTo(e){let t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0}backUp(e){this.pos-=e}column(){return this.lastColumnPos<this.start&&(this.lastColumnValue=En(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue}indentation(){return this.overrideIndent??En(this.string,null,this.tabSize)}match(e,t,n){if(typeof e==`string`){let r=e=>n?e.toLowerCase():e;return r(this.string.substr(this.pos,e.length))==r(e)?(t!==!1&&(this.pos+=e.length),!0):null}{let n=this.string.slice(this.pos).match(e);return n&&n.index>0?null:(n&&t!==!1&&(this.pos+=n[0].length),n)}}current(){return this.string.slice(this.start,this.pos)}};function On(e){return{name:e.name||``,token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||kn,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||Ln,mergeTokens:e.mergeTokens!==!1}}function kn(e){if(typeof e!=`object`)return e;let t={};for(let n in e){let r=e[n];t[n]=r instanceof Array?r.slice():r}return t}var An=/*@__PURE__*/ new WeakMap,jn=class e extends G{constructor(e){let t=ze(e.languageData),n=On(e),r,i=new class extends ve{createParse(e,t,n){return new Fn(r,e,t,n)}};super(t,i,[],e.name),this.topNode=Kn(t,this),r=this,this.streamParser=n,this.stateAfter=new b({perNode:!0}),this.tokenTable=e.tokenTable?new Hn(n.tokenTable):Un}static define(t){return new e(t)}getIndent(e){let t,{overrideIndentation:n}=e.options;n&&(t=An.get(e.state),t!=null&&t<e.pos-1e4&&(t=void 0));let r=Mn(this,e.node.tree,e.node.from,e.node.from,t??e.pos),i,a;if(r?(a=r.state,i=r.pos+1):(a=this.streamParser.startState(e.unit),i=e.node.from),e.pos-i>1e4)return null;for(;i<e.pos;){let t=e.state.doc.lineAt(i),r=Math.min(e.pos,t.to);if(t.length){let i=n?n(t.from):-1,o=new Dn(t.text,e.state.tabSize,e.unit,i<0?void 0:i);for(;o.pos<r-t.from;)In(this.streamParser.token,o,a)}else this.streamParser.blankLine(a,e.unit);if(r==e.pos)break;i=t.to+1}let o=e.lineAt(e.pos);return n&&t==null&&An.set(e.state,o.from),this.streamParser.indent(a,/^\s*(.*)/.exec(o.text)[1],e)}get allowsNesting(){return!1}};function Mn(e,t,n,r,i){let a=n>=r&&n+t.length<=i&&t.prop(e.stateAfter);if(a)return{state:e.streamParser.copyState(a),pos:n+t.length};for(let a=t.children.length-1;a>=0;a--){let o=t.children[a],s=n+t.positions[a],c=o instanceof O&&s<i&&Mn(e,o,s,r,i);if(c)return c}return null}function Nn(e,t,n,r,i){if(i&&n<=0&&r>=t.length)return t;!i&&n==0&&t.type==e.topNode&&(i=!0);for(let a=t.children.length-1;a>=0;a--){let o=t.positions[a],s=t.children[a],c;if(o<r&&s instanceof O){if(!(c=Nn(e,s,n-o,r-o,i)))break;return i?new O(t.type,t.children.slice(0,a).concat(c),t.positions.slice(0,a+1),o+c.length):c}}return null}function Pn(e,t,n,r,i){for(let i of t){let t=i.from+(i.openStart?25:0),a=i.to-(i.openEnd?25:0),o=t<=n&&a>n&&Mn(e,i.tree,0-i.offset,n,a),s;if(o&&o.pos<=r&&(s=Nn(e,i.tree,n+i.offset,o.pos+i.offset,!1)))return{state:o.state,tree:s}}return{state:e.streamParser.startState(i?at(i):4),tree:O.empty}}var Fn=class{constructor(e,t,n,r){this.lang=e,this.input=t,this.fragments=n,this.ranges=r,this.stoppedAt=null,this.chunks=[],this.chunkPos=[],this.chunk=[],this.chunkReused=void 0,this.rangeIndex=0,this.to=r[r.length-1].to;let i=Ye.get(),a=r[0].from,{state:o,tree:s}=Pn(e,n,a,this.to,i?.state);this.state=o,this.parsedPos=this.chunkStart=a+s.length;for(let e=0;e<s.children.length;e++)this.chunks.push(s.children[e]),this.chunkPos.push(s.positions[e]);i&&this.parsedPos<i.viewport.from-1e5&&r.some(e=>e.from<=i.viewport.from&&e.to>=i.viewport.from)&&(this.state=this.lang.streamParser.startState(at(i.state)),i.skipUntilInView(this.parsedPos,i.viewport.from),this.parsedPos=i.viewport.from),this.moveRangeIndex()}advance(){let e=Ye.get(),t=this.stoppedAt==null?this.to:Math.min(this.to,this.stoppedAt),n=Math.min(t,this.chunkStart+512);for(e&&(n=Math.min(n,e.viewport.to));this.parsedPos<n;)this.parseLine(e);return this.chunkStart<this.parsedPos&&this.finishChunk(),this.parsedPos>=t?this.finish():e&&this.parsedPos>=e.viewport.to?(e.skipUntilInView(this.parsedPos,t),this.finish()):null}stopAt(e){this.stoppedAt=e}lineAfter(e){let t=this.input.chunk(e);if(this.input.lineChunks)t==`
|
|
7
|
-
`&&(t=``);else{let e=t.indexOf(`
|
|
8
|
-
`);e>-1&&(t=t.slice(0,e))}return e+t.length<=this.to?t:t.slice(0,this.to-e)}nextLine(){let e=this.parsedPos,t=this.lineAfter(e),n=e+t.length;for(let e=this.rangeIndex;;){let r=this.ranges[e].to;if(r>=n||(t=t.slice(0,r-(n-t.length)),e++,e==this.ranges.length))break;let i=this.ranges[e].from,a=this.lineAfter(i);t+=a,n=i+a.length}return{line:t,end:n}}skipGapsTo(e,t,n){for(;;){let r=this.ranges[this.rangeIndex].to,i=e+t;if(n>0?r>i:r>=i)break;let a=this.ranges[++this.rangeIndex].from;t+=a-r}return t}moveRangeIndex(){for(;this.ranges[this.rangeIndex].to<this.parsedPos;)this.rangeIndex++}emitToken(e,t,n,r){let i=4;if(this.ranges.length>1){r=this.skipGapsTo(t,r,1),t+=r;let e=this.chunk.length;r=this.skipGapsTo(n,r,-1),n+=r,i+=this.chunk.length-e}let a=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&i==4&&a>=0&&this.chunk[a]==e&&this.chunk[a+2]==t?this.chunk[a+2]=n:this.chunk.push(e,t,n,i),r}parseLine(e){let{line:t,end:n}=this.nextLine(),r=0,{streamParser:i}=this.lang,a=new Dn(t,e?e.state.tabSize:4,e?at(e.state):2);if(a.eol())i.blankLine(this.state,a.indentUnit);else for(;!a.eol();){let e=In(i.token,a,this.state);if(e&&(r=this.emitToken(this.lang.tokenTable.resolve(e),this.parsedPos+a.start,this.parsedPos+a.pos,r)),a.start>1e4)break}this.parsedPos=n,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let e=O.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:Rn,topID:0,maxBufferLength:512,reused:this.chunkReused});e=new O(e.type,e.children,e.positions,e.length,[[this.lang.stateAfter,this.lang.streamParser.copyState(this.state)]]),this.chunks.push(e),this.chunkPos.push(this.chunkStart-this.ranges[0].from),this.chunk=[],this.chunkReused=void 0,this.chunkStart=this.parsedPos}finish(){return new O(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function In(e,t,n){t.start=t.pos;for(let r=0;r<10;r++){let r=e(t,n);if(t.pos>t.start)return r}throw Error(`Stream parser failed to advance stream.`)}var Ln=/*@__PURE__*/ Object.create(null),$=[C.none],Rn=/*@__PURE__*/ new w($),zn=[],Bn=/*@__PURE__*/ Object.create(null),Vn=/*@__PURE__*/ Object.create(null);for(let[e,t]of[[`variable`,`variableName`],[`variable-2`,`variableName.special`],[`string-2`,`string.special`],[`def`,`variableName.definition`],[`tag`,`tagName`],[`attribute`,`attributeName`],[`type`,`typeName`],[`builtin`,`variableName.standard`],[`qualifier`,`modifier`],[`error`,`invalid`],[`header`,`heading`],[`property`,`propertyName`]])Vn[e]=/*@__PURE__*/ Gn(Ln,t);var Hn=class{constructor(e){this.extra=e,this.table=Object.assign(Object.create(null),Vn)}resolve(e){return e?this.table[e]||(this.table[e]=Gn(this.extra,e)):0}},Un=/*@__PURE__*/ new Hn(Ln);function Wn(e,t){zn.indexOf(e)>-1||(zn.push(e),console.warn(t))}function Gn(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||U[n];r?typeof r==`function`?t.length?t=t.map(r):Wn(n,`Modifier ${n} used at start of tag`):t.length?Wn(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:Wn(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=Bn[i];if(a)return a.id;let o=Bn[i]=C.define({id:$.length,name:r,props:[Te({[r]:n})]});return $.push(o),o.id}function Kn(e,t){let n=C.define({id:$.length,name:`Document`,props:[W.add(()=>e),ut.add(()=>e=>t.getIndent(e))],top:!0});return $.push(n),n}function qn(e){return e.length<=4096&&/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/.test(e)}function Jn(e){for(let t=e.iter();!t.next().done;)if(qn(t.value))return!0;return!1}function Yn(e){let t=!1;return e.iterChanges((e,n,r,i,a)=>{!t&&Jn(a)&&(t=!0)}),t}var Xn=/*@__PURE__*/ o.define({combine:e=>e.some(e=>e)});function Zn(e={}){let t=[Qn];return e.alwaysIsolate&&t.push(Xn.of(!0)),t}var Qn=/*@__PURE__*/ l.fromClass(class{constructor(e){this.always=e.state.facet(Xn)||e.textDirection!=p.LTR||e.state.facet(g.perLineTextDirection),this.hasRTL=!this.always&&Jn(e.state.doc),this.tree=K(e.state),this.decorations=this.always||this.hasRTL?$n(e,this.tree,this.always):_.none}update(e){let t=e.state.facet(Xn)||e.view.textDirection!=p.LTR||e.state.facet(g.perLineTextDirection);if(!t&&!this.hasRTL&&Yn(e.changes)&&(this.hasRTL=!0),!t&&!this.hasRTL)return;let n=K(e.state);(t!=this.always||n!=this.tree||e.docChanged||e.viewportChanged)&&(this.tree=n,this.always=t,this.decorations=$n(e.view,n,t))}},{provide:e=>{function t(t){return t.plugin(e)?.decorations??_.none}return[g.outerDecorations.of(t),n.lowest(g.bidiIsolatedRanges.of(t))]}});function $n(e,n,r){let i=new t,a=e.visibleRanges;r||(a=er(a,e.state.doc));for(let{from:e,to:t}of a)n.iterate({enter:e=>{let t=e.type.prop(b.isolate);t&&i.add(e.from,e.to,tr[t])},from:e,to:t});return i.finish()}function er(e,t){let n=t.iter(),r=0,i=[],a=null;for(let{from:t,to:o}of e)if(!(a&&a.to>t&&(t=a.to,t>=o)))for(r+n.value.length<t&&(n.next(t-(r+n.value.length)),r=t);;){let e=r,t=r+n.value.length;if(!n.lineBreak&&qn(n.value)&&(a&&a.to>e-10?a.to=Math.min(o,t):i.push(a={from:e,to:Math.min(o,t)})),t>=o)break;r=t,n.next()}return i}var tr={rtl:/*@__PURE__*/ _.mark({class:`cm-iso`,inclusive:!0,attributes:{dir:`rtl`},bidiIsolate:p.RTL}),ltr:/*@__PURE__*/ _.mark({class:`cm-iso`,inclusive:!0,attributes:{dir:`ltr`},bidiIsolate:p.LTR}),auto:/*@__PURE__*/ _.mark({class:`cm-iso`,inclusive:!0,attributes:{dir:`auto`},bidiIsolate:null})};export{qe as DocInput,tn as HighlightStyle,lt as IndentContext,He as LRLanguage,G as Language,nt as LanguageDescription,tt as LanguageSupport,Ye as ParseContext,jn as StreamLanguage,Dn as StringStream,gt as TreeIndentContext,b as a,Zn as bidiIsolates,bn as bracketMatching,xn as bracketMatchingHandle,ge as c,qt as codeFolding,St as continuedIndent,un as defaultHighlightStyle,ze as defineLanguageFacet,yt as delimitedIndent,Ue as ensureSyntaxTree,xt as flatIndent,Bt as foldAll,Lt as foldCode,Y as foldEffect,$t as foldGutter,Dt as foldInside,Wt as foldKeymap,Et as foldNodeProp,Tt as foldService,Z as foldState,J as foldable,Nt as foldedRanges,Ge as forceParsing,at as getIndentUnit,st as getIndentation,sn as highlightingFor,D as i,ut as indentNodeProp,wt as indentOnInput,ct as indentRange,rt as indentService,ot as indentString,it as indentUnit,ve as l,q as language,W as languageDataProp,Q as matchBrackets,U as n,w as o,ee as r,C as s,Be as sublanguageProp,on as syntaxHighlighting,Ke as syntaxParserRunning,K as syntaxTree,We as syntaxTreeAvailable,Te as t,Ut as toggleFold,O as u,Vt as unfoldAll,Rt as unfoldCode,X as unfoldEffect};
|
package/dist/element-CQGYVEF7.js
DELETED
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
async function e(e){try{return await t(e)}catch(t){return console.warn(`[code-playpad] CodeMirror unavailable, using plain textarea:`,t),n(e)}}async function t(e){let[t,n,r,i,a,o]=await Promise.all([import(`@codemirror/view`),import(`@codemirror/state`),import(`@codemirror/commands`),import(`@codemirror/language`),import(`@codemirror/autocomplete`),import(`@codemirror/theme-one-dark`)]),{EditorView:s,keymap:c,lineNumbers:l,highlightActiveLine:u,highlightActiveLineGutter:d,highlightSpecialChars:f,drawSelection:p,rectangularSelection:m,crosshairCursor:h}=t,{EditorState:g,Compartment:_}=n,{defaultKeymap:v,history:y,historyKeymap:b,indentWithTab:x}=r,{syntaxHighlighting:S,defaultHighlightStyle:C,indentOnInput:w,bracketMatching:T,foldGutter:E,foldKeymap:D}=i,{autocompletion:O,closeBrackets:k,closeBracketsKeymap:A,completionKeymap:j}=a,M=new _,N=new _,P=new _,F=[s.theme({"&":{color:`#1f2328`,backgroundColor:`#ffffff`},".cm-gutters":{backgroundColor:`#f6f8fa`,color:`#8b949e`,border:`none`},".cm-activeLine":{backgroundColor:`#f6f8fa88`},".cm-activeLineGutter":{backgroundColor:`#eaeef2`},".cm-cursor":{borderLeftColor:`#1f2328`},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:`#cfe3ff`}}),S(C,{fallback:!0})],I=e=>e?o.oneDark:F,L=c.of([{key:`Mod-Enter`,preventDefault:!0,run:()=>(e.onRun?.(),!0)},{key:`Shift-Enter`,preventDefault:!0,run:()=>(e.onRun?.(),!0)}]),R=e.dark,z=e.readOnly,B=e.language??[],V=t=>g.create({doc:t,extensions:[l(),d(),f(),y(),E(),p(),g.allowMultipleSelections.of(!0),w(),T(),k(),O(),m(),h(),u(),L,c.of([...A,...v,...b,...D,...j,x]),s.lineWrapping,P.of(B),M.of(I(R)),N.of(g.readOnly.of(z)),s.updateListener.of(t=>{t.docChanged&&e.onChange?.(t.state.doc.toString())})]}),H=new s({parent:e.parent,state:V(e.doc)}),U=/* @__PURE__ */ new Map,W=e.name??``;return{fallback:!1,getCode:()=>H.state.doc.toString(),setCode(e){H.dispatch({changes:{from:0,to:H.state.doc.length,insert:e}})},openFile(e,t){if(e===W)return;U.set(W,H.state);let n=U.get(e);H.setState(n??V(t)),W=e,n&&H.dispatch({effects:[M.reconfigure(I(R)),N.reconfigure(g.readOnly.of(z)),P.reconfigure(B)]})},fileCode(e,t){if(e===W)return H.state.doc.toString();let n=U.get(e);return n?n.doc.toString():t},forgetFiles(e){for(let t of[...U.keys()])e.includes(t)||U.delete(t)},setTheme(e){R=e,H.dispatch({effects:M.reconfigure(I(R))})},setReadOnly(e){z=e,H.dispatch({effects:N.reconfigure(g.readOnly.of(z))})},setLanguage(e){B=e,H.dispatch({effects:P.reconfigure(B)})},focus:()=>H.focus(),destroy:()=>H.destroy()}}function n(e){let t=document.createElement(`textarea`);t.className=`cp-fallback-editor`,t.spellcheck=!1,t.value=e.doc,t.readOnly=e.readOnly,t.addEventListener(`input`,()=>e.onChange?.(t.value)),t.addEventListener(`keydown`,t=>{(t.metaKey||t.ctrlKey)&&t.key===`Enter`&&(t.preventDefault(),e.onRun?.())}),e.parent.appendChild(t);let n=/* @__PURE__ */ new Map,r=e.name??``;return{fallback:!0,getCode:()=>t.value,setCode:e=>{t.value=e},openFile(e,i){e!==r&&(n.set(r,t.value),t.value=n.get(e)??i,r=e)},fileCode(e,i){return e===r?t.value:n.get(e)??i},forgetFiles(e){for(let t of[...n.keys()])e.includes(t)||n.delete(t)},setTheme:()=>{},setReadOnly:e=>{t.readOnly=e},setLanguage:()=>{},focus:()=>t.focus(),destroy:()=>t.remove()}}var r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map;function a(e,t){r.set(e,t)}function o(){return[...r.keys()]}function s(e){let t=i.get(e);if(t)return t;let n=r.get(e);if(!n)return Promise.reject(/* @__PURE__ */ Error(`Unknown runtime "${e}". Registered: ${o().join(`, `)||`none`}`));let a=n().catch(t=>{throw i.delete(e),t});return i.set(e,a),a}a(`python`,()=>import(`./pyodide-C8ImkXdD.js`).then(e=>e.pythonRuntime)),a(`javascript`,()=>import(`./javascript-B1tVx7AD.js`).then(e=>e.javascriptRuntime)),a(`typescript`,()=>import(`./javascript-B1tVx7AD.js`).then(e=>e.typescriptRuntime)),a(`java`,()=>import(`./java-8qjVCjsN.js`).then(e=>e.javaRuntime)),a(`c`,()=>import(`./cpp-CO2abWii.js`).then(e=>e.cRuntime)),a(`cpp`,()=>import(`./cpp-CO2abWii.js`).then(e=>e.cppRuntime));var c=class extends Error{constructor(e=`Execution stopped`){super(e),this.name=`RunStopped`}},l=class extends Error{constructor(e=`Web Workers are unavailable in this page`){super(e),this.name=`WorkerUnavailable`}},u=/* @__PURE__ */ new WeakSet,d=String.raw`
|
|
2
|
-
:host {
|
|
3
|
-
--cp-bg: #ffffff;
|
|
4
|
-
--cp-fg: #1f2328;
|
|
5
|
-
--cp-muted: #656d76;
|
|
6
|
-
--cp-border: #d0d7de;
|
|
7
|
-
--cp-surface: #f6f8fa;
|
|
8
|
-
--cp-accent: #1f6feb;
|
|
9
|
-
--cp-accent-fg: #ffffff;
|
|
10
|
-
--cp-danger: #cf222e;
|
|
11
|
-
--cp-ok: #1a7f37;
|
|
12
|
-
--cp-radius: 8px;
|
|
13
|
-
--cp-font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
|
|
14
|
-
--cp-font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
|
15
|
-
|
|
16
|
-
display: block;
|
|
17
|
-
margin: 1rem 0;
|
|
18
|
-
color-scheme: light;
|
|
19
|
-
contain: content;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
:host([hidden]) { display: none; }
|
|
23
|
-
|
|
24
|
-
:host([data-resolved-theme="dark"]) {
|
|
25
|
-
--cp-bg: #0d1117;
|
|
26
|
-
--cp-fg: #e6edf3;
|
|
27
|
-
--cp-muted: #8b949e;
|
|
28
|
-
--cp-border: #30363d;
|
|
29
|
-
--cp-surface: #161b22;
|
|
30
|
-
--cp-accent: #388bfd;
|
|
31
|
-
--cp-danger: #ff7b72;
|
|
32
|
-
--cp-ok: #3fb950;
|
|
33
|
-
color-scheme: dark;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
* { box-sizing: border-box; }
|
|
37
|
-
|
|
38
|
-
.cp-root {
|
|
39
|
-
border: 1px solid var(--cp-border);
|
|
40
|
-
border-radius: var(--cp-radius);
|
|
41
|
-
background: var(--cp-bg);
|
|
42
|
-
color: var(--cp-fg);
|
|
43
|
-
font-family: var(--cp-font-ui);
|
|
44
|
-
font-size: 14px;
|
|
45
|
-
overflow: hidden;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.cp-toolbar {
|
|
49
|
-
display: flex;
|
|
50
|
-
align-items: center;
|
|
51
|
-
gap: 8px;
|
|
52
|
-
padding: 6px 8px;
|
|
53
|
-
background: var(--cp-surface);
|
|
54
|
-
border-bottom: 1px solid var(--cp-border);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.cp-spacer { flex: 1 1 auto; }
|
|
58
|
-
|
|
59
|
-
.cp-status {
|
|
60
|
-
font-size: 12px;
|
|
61
|
-
color: var(--cp-muted);
|
|
62
|
-
white-space: nowrap;
|
|
63
|
-
overflow: hidden;
|
|
64
|
-
text-overflow: ellipsis;
|
|
65
|
-
max-width: 55%;
|
|
66
|
-
}
|
|
67
|
-
.cp-status[data-state="error"] { color: var(--cp-danger); }
|
|
68
|
-
.cp-status[data-state="ok"] { color: var(--cp-ok); }
|
|
69
|
-
|
|
70
|
-
button {
|
|
71
|
-
font: inherit;
|
|
72
|
-
font-size: 13px;
|
|
73
|
-
line-height: 1;
|
|
74
|
-
padding: 6px 12px;
|
|
75
|
-
border-radius: 6px;
|
|
76
|
-
border: 1px solid var(--cp-border);
|
|
77
|
-
background: var(--cp-bg);
|
|
78
|
-
color: var(--cp-fg);
|
|
79
|
-
cursor: pointer;
|
|
80
|
-
}
|
|
81
|
-
button:hover:not(:disabled) { border-color: var(--cp-accent); }
|
|
82
|
-
button:disabled { opacity: 0.5; cursor: default; }
|
|
83
|
-
button:focus-visible { outline: 2px solid var(--cp-accent); outline-offset: 1px; }
|
|
84
|
-
|
|
85
|
-
button.cp-primary {
|
|
86
|
-
background: var(--cp-accent);
|
|
87
|
-
border-color: var(--cp-accent);
|
|
88
|
-
color: var(--cp-accent-fg);
|
|
89
|
-
font-weight: 600;
|
|
90
|
-
}
|
|
91
|
-
button.cp-danger { color: var(--cp-danger); border-color: var(--cp-danger); }
|
|
92
|
-
|
|
93
|
-
.cp-tabs {
|
|
94
|
-
display: flex;
|
|
95
|
-
gap: 2px;
|
|
96
|
-
overflow-x: auto;
|
|
97
|
-
padding: 0 6px;
|
|
98
|
-
background: var(--cp-surface);
|
|
99
|
-
border-bottom: 1px solid var(--cp-border);
|
|
100
|
-
scrollbar-width: thin;
|
|
101
|
-
}
|
|
102
|
-
.cp-tabs[hidden] { display: none; }
|
|
103
|
-
.cp-tabs button {
|
|
104
|
-
border: 0;
|
|
105
|
-
border-bottom: 2px solid transparent;
|
|
106
|
-
border-radius: 0;
|
|
107
|
-
background: transparent;
|
|
108
|
-
color: var(--cp-muted);
|
|
109
|
-
font-family: var(--cp-font-mono);
|
|
110
|
-
font-size: 12px;
|
|
111
|
-
padding: 7px 10px;
|
|
112
|
-
white-space: nowrap;
|
|
113
|
-
}
|
|
114
|
-
.cp-tabs button:hover:not(:disabled) { color: var(--cp-fg); }
|
|
115
|
-
.cp-tabs button[aria-pressed='true'] {
|
|
116
|
-
color: var(--cp-fg);
|
|
117
|
-
border-bottom-color: var(--cp-accent);
|
|
118
|
-
background: var(--cp-bg);
|
|
119
|
-
}
|
|
120
|
-
.cp-tabs button.cp-entry::before {
|
|
121
|
-
content: '▸';
|
|
122
|
-
margin-right: 4px;
|
|
123
|
-
color: var(--cp-accent);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.cp-editor {
|
|
127
|
-
height: var(--cp-height, 220px);
|
|
128
|
-
overflow: hidden;
|
|
129
|
-
}
|
|
130
|
-
.cp-editor .cm-editor { height: 100%; }
|
|
131
|
-
|
|
132
|
-
/* Content-fitting mode. Until 0.2.0 height="auto" happened to work, because a
|
|
133
|
-
percentage height against an indefinite parent computes to auto — true, but
|
|
134
|
-
accidental, and one future rule away from silently reverting to 220px. These
|
|
135
|
-
rules make it a supported mode instead. */
|
|
136
|
-
:host([height='auto']) .cp-editor,
|
|
137
|
-
:host([height='auto']) .cp-editor .cm-editor,
|
|
138
|
-
:host([height='auto']) .cp-fallback-editor {
|
|
139
|
-
height: auto;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/* Bounds for that mode, following CodeMirror's own recipes.
|
|
143
|
-
|
|
144
|
-
max-height goes on .cm-editor: its theme already gives .cm-scroller
|
|
145
|
-
overflow-y: auto, so a capped editor scrolls rather than clips. Putting the
|
|
146
|
-
cap on .cp-editor instead would clip, since the scroller has already sized
|
|
147
|
-
itself to the content.
|
|
148
|
-
|
|
149
|
-
min-height goes on .cm-content and .cm-gutter, not on .cm-editor. Both give
|
|
150
|
-
the right outer height, but on .cm-editor the scroller stays at content
|
|
151
|
-
height — so the empty space below a one-line snippet is not part of the
|
|
152
|
-
editor and clicking it does nothing. That empty space is exactly what a
|
|
153
|
-
"write your answer here" box is for. */
|
|
154
|
-
.cp-editor .cm-editor { max-height: var(--cp-max-height, none); }
|
|
155
|
-
|
|
156
|
-
/* Three classes deep on purpose: CodeMirror's base theme sets
|
|
157
|
-
.cm-content { min-height: 100% } through a generated wrapper class, which
|
|
158
|
-
ties on specificity with a two-class selector and wins on order, since its
|
|
159
|
-
stylesheet is injected into the shadow root after this one. */
|
|
160
|
-
.cp-editor .cm-editor .cm-content,
|
|
161
|
-
.cp-editor .cm-editor .cm-gutter { min-height: var(--cp-min-height, 0); }
|
|
162
|
-
.cp-editor .cp-fallback-editor {
|
|
163
|
-
min-height: var(--cp-min-height, 0);
|
|
164
|
-
max-height: var(--cp-max-height, none);
|
|
165
|
-
}
|
|
166
|
-
.cp-editor .cm-scroller {
|
|
167
|
-
font-family: var(--cp-font-mono);
|
|
168
|
-
font-size: 13px;
|
|
169
|
-
line-height: 1.5;
|
|
170
|
-
}
|
|
171
|
-
.cp-editor .cm-editor.cm-focused { outline: none; }
|
|
172
|
-
|
|
173
|
-
.cp-fallback-editor {
|
|
174
|
-
width: 100%;
|
|
175
|
-
height: 100%;
|
|
176
|
-
border: 0;
|
|
177
|
-
padding: 8px;
|
|
178
|
-
resize: none;
|
|
179
|
-
background: var(--cp-bg);
|
|
180
|
-
color: var(--cp-fg);
|
|
181
|
-
font-family: var(--cp-font-mono);
|
|
182
|
-
font-size: 13px;
|
|
183
|
-
line-height: 1.5;
|
|
184
|
-
}
|
|
185
|
-
.cp-fallback-editor:focus { outline: none; }
|
|
186
|
-
|
|
187
|
-
.cp-stdin { border-top: 1px solid var(--cp-border); background: var(--cp-surface); }
|
|
188
|
-
.cp-stdin[hidden] { display: none; }
|
|
189
|
-
.cp-stdin.cp-attention {
|
|
190
|
-
box-shadow: inset 0 0 0 2px var(--cp-accent);
|
|
191
|
-
}
|
|
192
|
-
.cp-stdin label {
|
|
193
|
-
display: block;
|
|
194
|
-
padding: 6px 8px 0;
|
|
195
|
-
font-size: 11px;
|
|
196
|
-
text-transform: uppercase;
|
|
197
|
-
letter-spacing: 0.04em;
|
|
198
|
-
color: var(--cp-muted);
|
|
199
|
-
}
|
|
200
|
-
.cp-stdin textarea {
|
|
201
|
-
display: block;
|
|
202
|
-
width: 100%;
|
|
203
|
-
min-height: 52px;
|
|
204
|
-
border: 0;
|
|
205
|
-
padding: 4px 8px 8px;
|
|
206
|
-
background: transparent;
|
|
207
|
-
color: var(--cp-fg);
|
|
208
|
-
font-family: var(--cp-font-mono);
|
|
209
|
-
font-size: 13px;
|
|
210
|
-
resize: vertical;
|
|
211
|
-
}
|
|
212
|
-
.cp-stdin textarea:focus { outline: none; }
|
|
213
|
-
|
|
214
|
-
.cp-output {
|
|
215
|
-
border-top: 1px solid var(--cp-border);
|
|
216
|
-
padding: 8px 10px;
|
|
217
|
-
margin: 0;
|
|
218
|
-
max-height: 260px;
|
|
219
|
-
overflow: auto;
|
|
220
|
-
background: var(--cp-surface);
|
|
221
|
-
font-family: var(--cp-font-mono);
|
|
222
|
-
font-size: 13px;
|
|
223
|
-
line-height: 1.5;
|
|
224
|
-
white-space: pre-wrap;
|
|
225
|
-
word-break: break-word;
|
|
226
|
-
}
|
|
227
|
-
.cp-output[hidden] { display: none; }
|
|
228
|
-
.cp-output .cp-err { color: var(--cp-danger); }
|
|
229
|
-
.cp-output .cp-hint {
|
|
230
|
-
margin-top: 6px;
|
|
231
|
-
padding: 6px 8px;
|
|
232
|
-
border-left: 3px solid var(--cp-accent);
|
|
233
|
-
background: var(--cp-bg);
|
|
234
|
-
color: var(--cp-fg);
|
|
235
|
-
font-family: var(--cp-font-ui);
|
|
236
|
-
font-size: 12.5px;
|
|
237
|
-
white-space: normal;
|
|
238
|
-
}
|
|
239
|
-
.cp-output .cp-value { color: var(--cp-muted); }
|
|
240
|
-
.cp-output .cp-in { color: var(--cp-accent); }
|
|
241
|
-
|
|
242
|
-
.cp-prompt {
|
|
243
|
-
display: inline-flex;
|
|
244
|
-
align-items: center;
|
|
245
|
-
gap: 4px;
|
|
246
|
-
}
|
|
247
|
-
.cp-prompt input {
|
|
248
|
-
font: inherit;
|
|
249
|
-
color: var(--cp-accent);
|
|
250
|
-
background: transparent;
|
|
251
|
-
border: 0;
|
|
252
|
-
border-bottom: 1px solid var(--cp-accent);
|
|
253
|
-
padding: 0 2px;
|
|
254
|
-
min-width: 12ch;
|
|
255
|
-
caret-color: var(--cp-accent);
|
|
256
|
-
}
|
|
257
|
-
.cp-prompt input:focus { outline: none; }
|
|
258
|
-
.cp-prompt button {
|
|
259
|
-
padding: 1px 6px;
|
|
260
|
-
font-size: 11px;
|
|
261
|
-
line-height: 1.4;
|
|
262
|
-
border-radius: 4px;
|
|
263
|
-
color: var(--cp-muted);
|
|
264
|
-
font-family: var(--cp-font-mono);
|
|
265
|
-
}
|
|
266
|
-
.cp-prompt button.cp-send { color: var(--cp-accent); border-color: var(--cp-accent); }
|
|
267
|
-
|
|
268
|
-
table.cp-table {
|
|
269
|
-
border-collapse: collapse;
|
|
270
|
-
margin: 6px 0;
|
|
271
|
-
font-size: 12px;
|
|
272
|
-
}
|
|
273
|
-
table.cp-table th, table.cp-table td {
|
|
274
|
-
border: 1px solid var(--cp-border);
|
|
275
|
-
padding: 3px 8px;
|
|
276
|
-
text-align: left;
|
|
277
|
-
}
|
|
278
|
-
table.cp-table th { background: var(--cp-bg); }
|
|
279
|
-
|
|
280
|
-
.cp-progress {
|
|
281
|
-
height: 2px;
|
|
282
|
-
background: linear-gradient(90deg, transparent, var(--cp-accent), transparent);
|
|
283
|
-
background-size: 40% 100%;
|
|
284
|
-
background-repeat: no-repeat;
|
|
285
|
-
animation: cp-slide 1.1s ease-in-out infinite;
|
|
286
|
-
}
|
|
287
|
-
.cp-progress[hidden] { display: none; }
|
|
288
|
-
|
|
289
|
-
@keyframes cp-slide {
|
|
290
|
-
0% { background-position: -40% 0; }
|
|
291
|
-
100% { background-position: 140% 0; }
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
@media (prefers-reduced-motion: reduce) {
|
|
295
|
-
.cp-progress { animation: none; background-position: 0 0; background-size: 100% 100%; opacity: 0.4; }
|
|
296
|
-
}
|
|
297
|
-
`,f=e=>()=>import(`@codemirror/lang-javascript`).then(t=>t.javascript(e)),p={py:()=>import(`@codemirror/lang-python`).then(e=>e.python()),pyi:()=>import(`@codemirror/lang-python`).then(e=>e.python()),js:f({}),mjs:f({}),cjs:f({}),jsx:f({jsx:!0}),ts:f({typescript:!0}),mts:f({typescript:!0}),cts:f({typescript:!0}),tsx:f({typescript:!0,jsx:!0}),json:()=>import(`@codemirror/lang-json`).then(e=>e.json()),c:()=>import(`@codemirror/lang-cpp`).then(e=>e.cpp()),h:()=>import(`@codemirror/lang-cpp`).then(e=>e.cpp()),cpp:()=>import(`@codemirror/lang-cpp`).then(e=>e.cpp()),cc:()=>import(`@codemirror/lang-cpp`).then(e=>e.cpp()),cxx:()=>import(`@codemirror/lang-cpp`).then(e=>e.cpp()),hpp:()=>import(`@codemirror/lang-cpp`).then(e=>e.cpp()),hxx:()=>import(`@codemirror/lang-cpp`).then(e=>e.cpp()),java:()=>import(`@codemirror/lang-java`).then(e=>e.java())};async function m(e){let t=p[e.includes(`.`)?e.slice(e.lastIndexOf(`.`)+1).toLowerCase():``];return t?t().catch(()=>null):null}var h=`code-playpad`,g=1,_=`snippets`,v=`progress`,y=null;function b(){return typeof indexedDB>`u`?Promise.reject(/* @__PURE__ */ Error(`IndexedDB unavailable`)):(y||=new Promise((e,t)=>{let n=indexedDB.open(h,g);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(_)||e.createObjectStore(_),e.objectStoreNames.contains(v)||e.createObjectStore(v,{keyPath:`id`})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)}).catch(e=>{throw y=null,e}),y)}function x(e,t,n){return b().then(r=>new Promise((i,a)=>{let o=n(r.transaction(e,t).objectStore(e));o.onsuccess=()=>i(o.result),o.onerror=()=>a(o.error)}))}function S(e,t){return x(_,`readwrite`,n=>n.put(t,e)).then(()=>void 0)}function C(e){return x(_,`readonly`,t=>t.get(e)).then(e=>e??null)}function w(e){return x(_,`readwrite`,t=>t.delete(e)).then(()=>void 0)}function T(e,t={}){let n={completed:!0,...t,id:e,updatedAt:Date.now()};return x(v,`readwrite`,e=>e.put(n)).then(()=>n)}function E(e){return x(v,`readonly`,t=>t.get(e)).then(e=>e??null)}function D(){return x(v,`readonly`,e=>e.getAll())}var O=`code-playpad`;function k(e){let t=e.replace(/\t/g,` `).split(`
|
|
298
|
-
`);for(;t.length&&t[0].trim()===``;)t.shift();for(;t.length&&t[t.length-1].trim()===``;)t.pop();let n=t.filter(e=>e.trim()!==``).reduce((e,t)=>Math.min(e,t.match(/^ */)[0].length),1/0);return(n===1/0?t:t.map(e=>e.slice(n))).join(`
|
|
299
|
-
`)}var A=2e5,j=`playpad-file`,M={python:`main.py`,javascript:`main.js`,typescript:`main.ts`,java:`Main.java`,c:`main.c`,cpp:`main.cpp`};function N(e){return M[e]??`main.txt`}function P(e,t){let n={};for(let t of e.children){if(t.tagName.toLowerCase()!==j)continue;let e=t.getAttribute(`name`);e&&(n[e]=k(t.textContent??``))}if(Object.keys(n).length)return n;let r=[...e.childNodes].filter(e=>e.nodeType!==Node.ELEMENT_NODE||e.tagName.toLowerCase()!==j),i=r.some(e=>e.nodeType===Node.ELEMENT_NODE),a=k(r.filter(e=>!(i&&e.nodeType===Node.TEXT_NODE&&!(e.textContent??``).trim())).map(e=>e.textContent??``).join(``));return{[t]:a}}function F(e,t){try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t;return Object.keys(e).length?e:null}}catch{}return e?{[t]:e}:null}var I=typeof HTMLElement>`u`?class{}:HTMLElement,L=class extends I{static get observedAttributes(){return[`language`,`height`,`min-height`,`max-height`,`theme`,`readonly`,`autorun`,`stdin`,`persist`,`entry`,`practice`]}#e;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u=null;#d=null;#f=null;#p=null;#m={};#h={};#g=`main.py`;#_=null;#v;#y=!1;#b=null;#x=!1;#S=!1;#C=null;#w=null;#T=null;#E=()=>this.#X();#D=null;#O=!0;#k=[];#A=null;#j=null;#M=null;#N=0;#P=!1;#F=null;constructor(){super(),this.#e=this.attachShadow({mode:`open`})}get code(){return this.#u?this.#u.getCode():this.#m[this.#g]??``}set code(e){this.#m[this.#g]=e,this.#V()}get practice(){if(this.#F)return this.#F;let e=this.getAttribute(`practice`);if(!e)return null;try{return JSON.parse(e)}catch{return null}}set practice(e){this.#F=e}get files(){return this.#K()}set files(e){let t=Object.keys(e);if(!t.length)return;let n=Object.keys(this.#h);n.length===1&&!this.#h[n[0]]&&(this.#h={...e}),this.#m={...e},t.includes(this.#g)||(this.#g=this.#G()),this.#u?.forgetFiles([]),this.#V(),this.#q(),this.#B()}get entry(){return this.#G()}set entry(e){this.setAttribute(`entry`,e)}openFile(e){e in this.#m&&(this.#u&&(this.#m[this.#g]=this.#u.getCode(),this.#u.openFile(e,this.#m[e]??``)),this.#g=e,this.#q(),this.#B())}get stdin(){return this.#l?this.#l.value:``}set stdin(e){this.#l&&(this.#l.value=e,this.#c.hidden=!1)}get language(){return this.getAttribute(`language`)||`python`}set language(e){this.setAttribute(`language`,e)}getCode(){return this.code}getFiles(){return this.#K()}reset(){this.#m={...this.#h},this.#g=this.#G(),this.#u?.forgetFiles([]),this.#V(),this.#q(),this.#$(),this.#s.hidden=!0,this.#Q(this.#f?.ready?`${this.#f.label} ready`:``,`idle`)}async run(){if(this.#y)return;await this.#d;let e=this.#K(),t=this.getAttribute(`entry`);if(t&&!(t in e))return this.#U(t,e);this.#H=!1;let n=this.#G(),r=e[n]??``;this.#y=!0,this.#x=!1,this.#n.disabled=!0,this.#r.hidden=!1,this.#$(),this.#s.hidden=!1;let i=this.practice;this.hasAttribute(`practice`)&&!i&&this.#ee(`The practice attribute is not valid JSON.
|
|
300
|
-
`,`cp-err`),this.#oe(`py-run`,{code:r,entry:n,files:e,language:this.language,...i?{practice:i}:{}});try{let t=await this.#z();if(this.#x)throw new c;if(i&&!t.supportsPractice)throw Error(`Practice mode is not available for ${t.label}.`);this.#Q(`Queued…`,`busy`),this.#o.hidden=!1;let a=t.run(r,{stdin:this.#l.value,files:e,entry:n,onStart:()=>this.#Q(`Running…`,`busy`),onProgress:e=>this.#Q(e.message,`busy`),onStdout:e=>this.#ee(e),onStderr:e=>this.#ee(e,`cp-err`),onEcho:e=>this.#ee(e,`cp-in`),onStdinRequest:()=>this.#ne(),...i?{practice:i}:{}});this.#b={runtime:t,run:a};let o=await a;if(o.table&&this.#ae(o.table),o.value!==void 0&&this.#ee(`${o.value}\n`,`cp-value`),o.hint&&this.#ie(o.hint,u.has(o)),o.failed=t.statusDecidesFailure?o.failed===!0:!!o.stderr,o.failed)this.#Q(`Error · ${o.durationMs} ms`,`error`),this.#oe(`py-error`,{message:o.stderr??``,hint:o.hint,language:this.language});else if(o.cases){let e=o.cases.filter(e=>e.expected!==void 0).length,t=o.passed===e;this.#Q(e?`${o.passed} of ${e} passed · ${o.durationMs} ms`:`Done in ${o.durationMs} ms`,t?`ok`:`error`)}else this.#Q(`Done in ${o.durationMs} ms`,`ok`);return this.#oe(`py-output`,{...o,language:this.language}),o}catch(e){if(e instanceof c)this.#ee(`
|
|
301
|
-
[stopped]
|
|
302
|
-
`,`cp-err`),this.#Q(`Stopped`,`error`);else{let t=e instanceof Error?e.message:String(e);this.#ee(t+`
|
|
303
|
-
`,`cp-err`),this.#Q(`Failed to start`,`error`),this.#oe(`py-error`,{message:t,language:this.language})}return}finally{this.#b=null,this.#re(null),this.#te(),this.#y=!1,this.#n.disabled=!1,this.#r.hidden=!0,this.#o.hidden=!0}}stop(){this.#b?this.#b.runtime.stop?.(this.#b.run):this.#y&&(this.#x=!0)}prewarm(){return this.#z()}connectedCallback(){this.#P?this.#R():!this.textContent?.trim()&&document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>this.isConnected&&this.#I(),{once:!0}):this.#I()}disconnectedCallback(){this.#C?.disconnect(),this.#C=null,this.#w?.removeEventListener(`change`,this.#E),this.#w=null,this.#T?.disconnect(),this.#T=null,this.#D&&clearTimeout(this.#D),this.#re(null),setTimeout(()=>{!this.isConnected&&this.#u&&(this.#_=this.#K(),this.#u.destroy(),this.#u=null,this.#d=null,this.#P=!1)},0)}attributeChangedCallback(e,t,n){if(this.#P)switch(e){case`theme`:this.#X();break;case`height`:case`min-height`:case`max-height`:this.#Z();break;case`readonly`:this.#u?.setReadOnly(n!==null);break;case`stdin`:this.#c.hidden=n===null&&!this.#l.value;break;case`entry`:this.#q();break;case`language`:this.#f=null,this.#p=null,this.#S=!1,this.#z().catch(()=>{})}}#I(){this.#P=!0,this.#h=P(this,this.#W()),this.#m=this.#_??{...this.#h},this.#g=this.#G(),this.#L(),this.#X(),this.#Z();let t=this.getAttribute(`persist`);this.#d=(async()=>{if(t&&this.#_==null){let e=await C(t).catch(()=>null),n=e==null?null:F(e,this.#W());if(n){let e={},t=Object.keys(this.#h),r=Object.keys(n);for(let r of t)e[r]=n[r]??this.#h[r];t.length===1&&r.length===1&&!(t[0]in n)&&(e[t[0]]=n[r[0]]),this.#m=e,this.#g=this.#G()}}this.#q();let n=await s(this.language).catch(()=>null),r=n?await n.editorLanguage().catch(()=>null):null;this.#u=await e({parent:this.#t,doc:this.#m[this.#g]??``,name:this.#g,dark:this.#Y(),readOnly:this.hasAttribute(`readonly`),language:r,onRun:()=>void this.run(),onChange:e=>this.#J(e)}),this.#_=null,this.#B()})(),this.#R()}#L(){let e=document.createElement(`style`);e.textContent=d;let t=document.createElement(`div`);t.className=`cp-root`,t.innerHTML=`
|
|
304
|
-
<div class="cp-toolbar">
|
|
305
|
-
<button class="cp-primary" part="run-button" data-action="run">Run</button>
|
|
306
|
-
<button class="cp-danger" part="stop-button" data-action="stop" hidden>Stop</button>
|
|
307
|
-
<button data-action="reset">Reset</button>
|
|
308
|
-
<span class="cp-spacer"></span>
|
|
309
|
-
<span class="cp-status" data-state="idle"></span>
|
|
310
|
-
</div>
|
|
311
|
-
<div class="cp-progress" hidden></div>
|
|
312
|
-
<div class="cp-tabs" part="tabs" hidden></div>
|
|
313
|
-
<div class="cp-editor"></div>
|
|
314
|
-
<div class="cp-stdin" hidden>
|
|
315
|
-
<label>Standard input — one value per line</label>
|
|
316
|
-
<textarea rows="2" spellcheck="false"></textarea>
|
|
317
|
-
</div>
|
|
318
|
-
<pre class="cp-output" part="output" hidden></pre>`,this.#e.replaceChildren(e,t),this.#n=t.querySelector(`[data-action="run"]`),this.#r=t.querySelector(`[data-action="stop"]`),this.#i=t.querySelector(`[data-action="reset"]`),this.#a=t.querySelector(`.cp-status`),this.#o=t.querySelector(`.cp-progress`),this.#v=t.querySelector(`.cp-tabs`),this.#t=t.querySelector(`.cp-editor`),this.#c=t.querySelector(`.cp-stdin`),this.#l=t.querySelector(`.cp-stdin textarea`),this.#s=t.querySelector(`.cp-output`),this.#c.hidden=!this.hasAttribute(`stdin`),this.#l.addEventListener(`input`,()=>this.#c.classList.remove(`cp-attention`)),this.#v.addEventListener(`click`,e=>{let t=e.target.closest(`button[data-file]`);t&&this.openFile(t.getAttribute(`data-file`))}),this.#n.addEventListener(`click`,()=>void this.run()),this.#r.addEventListener(`click`,()=>this.stop()),this.#i.addEventListener(`click`,()=>this.reset());let n=()=>void this.#z().catch(()=>{});this.#t.addEventListener(`pointerdown`,n,{once:!0}),this.#t.addEventListener(`focusin`,n,{once:!0})}#R(){this.#C||typeof IntersectionObserver>`u`||(this.#C=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(this.#C?.disconnect(),this.#C=null,this.#z().then(()=>{this.hasAttribute(`autorun`)&&this.run()}).catch(()=>{}))},{rootMargin:`300px`}),this.#C.observe(this))}#z(){return this.#p||=(async()=>{let e=await s(this.language);this.#f=e,!e.ready&&!this.#H&&(this.#o.hidden=!1,this.#Q(`Loading ${e.label}…`,`busy`));try{await e.load(e=>{!this.#y&&!this.#H&&this.#Q(e.message,e.phase===`ready`?`ok`:`busy`)})}catch(e){this.#p=null,this.#Q(`Runtime unavailable`,`error`);let t=e instanceof Error?e.message:String(e);throw this.#ee(t+`
|
|
319
|
-
`,`cp-err`),this.#s.hidden=!1,e}finally{this.#o.hidden=!0}return this.#B(),this.#S||(this.#S=!0,this.#H||this.#Q(`${e.label} ready`,`ok`),this.#oe(`py-ready`,{language:e.id,label:e.label})),e})(),this.#p}async#B(){if(!this.#u)return;let e=this.#g,t=await m(e);if(t){this.#g===e&&this.#u?.setLanguage(t);return}let n=e.includes(`.`)?null:await(this.#f??await s(this.language).catch(()=>null))?.editorLanguage().catch(()=>null);this.#g===e&&this.#u?.setLanguage(n??[])}#V(){this.#u?this.#u.setCode(this.#m[this.#g]??``):this.#d?.then(()=>{this.#u?.setCode(this.#m[this.#g]??``),this.#q()})}#H=!1;#U(e,t){let n=Object.keys(t),r=`This widget's entry is "${e}", but it has no file of that name${n.length?` (its files: ${n.join(`, `)})`:``}. Set entry to one of its files.\n`;this.#$(),this.#s.hidden=!1,this.#ee(r,`cp-err`),this.#H=!0,this.#Q(`Error · entry not found`,`error`);let i={stdout:``,stderr:r,durationMs:0,failed:!0};return this.#oe(`py-error`,{message:r,language:this.language}),this.#oe(`py-output`,{...i,language:this.language}),i}#W(){return this.getAttribute(`entry`)||N(this.language)}#G(){let e=Object.keys(this.#m),t=this.getAttribute(`entry`);if(t&&e.includes(t))return t;let n=N(this.language);return e.includes(n)?n:e[0]??n}#K(){let e={...this.#m};if(this.#u)for(let t of Object.keys(e))e[t]=this.#u.fileCode(t,e[t]);return e}#q(){let e=Object.keys(this.#m);if(this.#v.hidden=e.length<2,this.#v.hidden){this.#v.replaceChildren();return}let t=this.#G();this.#v.replaceChildren(...e.map(e=>{let n=document.createElement(`button`);return n.dataset.file=e,n.textContent=e,n.setAttribute(`aria-pressed`,String(e===this.#g)),e===t&&(n.classList.add(`cp-entry`),n.title=`entry point — this is the file Run executes`),n}))}#J(e){this.#m[this.#g]=e;let t=this.getAttribute(`persist`);if(!t)return;this.#D&&clearTimeout(this.#D);let n=JSON.stringify(this.#K());this.#D=setTimeout(()=>void S(t,n).catch(()=>{}),400)}#Y(){let e=this.getAttribute(`theme`)??`auto`;if(e===`dark`)return!0;if(e===`light`)return!1;let t=typeof document>`u`?``:getComputedStyle(document.documentElement).colorScheme,n=t.includes(`dark`);return n===t.includes(`light`)?!!this.#w?.matches:n}#X(){!this.#w&&typeof matchMedia==`function`&&(this.#w=matchMedia(`(prefers-color-scheme: dark)`),this.#w.addEventListener(`change`,this.#E)),!this.#T&&typeof MutationObserver==`function`&&typeof document<`u`&&(this.#T=new MutationObserver(this.#E),this.#T.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`,`data-theme`,`data-color-scheme`,`color-scheme`]}));let e=this.#Y();this.setAttribute(`data-resolved-theme`,e?`dark`:`light`),this.#u?.setTheme(e)}#Z(){for(let[e,t]of[[`height`,`--cp-height`],[`min-height`,`--cp-min-height`],[`max-height`,`--cp-max-height`]]){let n=this.getAttribute(e);n===null||n===``?this.style.removeProperty(t):this.style.setProperty(t,/^\d+$/.test(n)?`${n}px`:n)}}#Q(e,t){this.#a.textContent=e,this.#a.dataset.state=t}#$(){this.#M&&clearTimeout(this.#M),this.#M=null,this.#k=[],this.#N=0,this.#s.replaceChildren(),this.#O=!0}#ee(e,t){if(!e)return;let n=t===`cp-err`&&!this.#O?`\n${e}`:e;this.#O=n.endsWith(`
|
|
320
|
-
`),this.#k.push({text:n,className:t}),this.#M??=setTimeout(()=>this.#te(),16)}#te(){if(this.#M&&clearTimeout(this.#M),this.#M=null,!this.#k.length)return;let e=this.#k;this.#k=[];let t=document.createDocumentFragment(),n=``,r,i=()=>{if(!n)return;let e=document.createElement(`span`);r&&(e.className=r),e.textContent=n,t.appendChild(e),n=``};for(let t of e){if(this.#N>=A)break;let e=t.text;this.#N+e.length>A&&(e=e.slice(0,A-this.#N)+`
|
|
321
|
-
… output truncated for display — the full text is in the playpad-output event
|
|
322
|
-
`),this.#N+=t.text.length,r!==t.className&&(i(),r=t.className),n+=e}i(),this.#s.hidden=!1;let a=this.#s.querySelector(`.cp-prompt`);a?this.#s.insertBefore(t,a):this.#s.appendChild(t),this.#s.scrollTop=this.#s.scrollHeight}#ne(){return this.#te(),this.#re(null),new Promise(e=>{let t=document.createElement(`form`);t.className=`cp-prompt`;let n=document.createElement(`input`);n.type=`text`,n.setAttribute(`aria-label`,`Program input — press Enter to send`),n.autocapitalize=`off`,n.autocomplete=`off`,n.spellcheck=!1;let r=document.createElement(`button`);r.type=`submit`,r.className=`cp-send`,r.textContent=`⏎`,r.title=`Send this line (Enter)`;let i=document.createElement(`button`);i.type=`button`,i.className=`cp-eof`,i.textContent=`EOF`,i.title=`End of input (Ctrl-D) — makes input() raise EOFError`;let a=n=>{this.#A===e&&(this.#A=null,this.#j=null,t.remove(),n===null?this.#ee(`
|
|
323
|
-
`,`cp-in`):this.#ee(n+`
|
|
324
|
-
`,`cp-in`),this.#te(),e(n))};t.addEventListener(`submit`,e=>{e.preventDefault(),a(n.value)}),i.addEventListener(`click`,()=>a(null)),n.addEventListener(`keydown`,e=>{(e.key===`Escape`||e.key===`d`&&e.ctrlKey)&&(e.preventDefault(),a(null))}),t.append(n,r,i),this.#s.hidden=!1,this.#s.appendChild(t),this.#s.scrollTop=this.#s.scrollHeight,this.#A=e,this.#j=a,n.focus({preventScroll:!0})})}#re(e){this.#j?.(e),this.#j=null,this.#A=null}#ie(e,t){this.#te();let n=document.createElement(`div`);n.className=`cp-hint`,n.textContent=e,this.#s.hidden=!1,this.#s.appendChild(n),this.#s.scrollTop=this.#s.scrollHeight,t&&(this.#c.hidden=!1,this.#c.classList.add(`cp-attention`))}#ae(e){this.#te();let t=document.createElement(`table`);t.className=`cp-table`;let n=t.createTHead().insertRow();for(let t of e.columns){let e=document.createElement(`th`);e.textContent=t,n.appendChild(e)}let r=t.createTBody();for(let t of e.rows){let e=r.insertRow();for(let n of t)e.insertCell().textContent=n==null?``:String(n)}this.#s.hidden=!1,this.#s.appendChild(t)}#oe(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`playpad-${e.slice(3)}`,{detail:t,bubbles:!0,composed:!0}))}};function R(e=O){typeof window<`u`&&typeof customElements<`u`&&(customElements.get(e)||customElements.define(e,L))}R();export{E as a,T as c,l as d,s as f,e as h,w as i,u as l,a as m,R as n,C as o,o as p,D as r,S as s,L as t,c as u};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* code-playpad — MIT © 2026 Seung Hun Lee
|
|
3
|
-
* Bundles CodeMirror 6 and Lezer (MIT) © Marijn Haverbeke and others.
|
|
4
|
-
* Full third-party licences: THIRD-PARTY-NOTICES.txt in this package.
|
|
5
|
-
*/
|
|
6
|
-
import{n as e,r as t,t as n}from"./hints-CCMgezw9.js";var r=1,i=class{#e=null;#t=null;#n=`module`;#r=null;#i=null;#a=!1;#o=!1;#s=``;#c=/* @__PURE__ */ new Set;#l=[];#u=null;#d=!1;initPayload(){return{}}loadModule(e){return Promise.reject(/* @__PURE__ */ Error(`no module named ${e}`))}get ready(){return this.#a}get interactiveStdin(){return this.#o}get version(){return this.#s}load(e){e&&this.#c.add(e);let n=()=>{e&&this.#c.delete(e)};if(!this.#r){let e=new Promise((e,n)=>{this.#i={resolve:e,reject:n};let r;try{if(typeof Worker>`u`)throw Error(`Worker constructor missing`);let e=new Blob([this.source],{type:`text/javascript`});this.#t=URL.createObjectURL(e),r=new Worker(this.#t,{type:this.#n})}catch(e){this.#i=null,n(new t(`Could not start a Web Worker: ${e.message}`));return}this.#e=r,r.onmessage=t=>{let r=t.data;r.type===`ready`?(this.#s=r.version,this.#o=r.interactiveStdin===!0,this.#a=!0,this.#i=null,this.#h({phase:`ready`,message:`${this.label} ready`}),e()):r.type===`fatal`&&!this.#a?this.#p(r.message,e,n):this.#g(r)},r.onerror=t=>{let r=t.message||`Worker failed to start`;this.#a?this.#u&&this.#y(this.#u,Error(r)):this.#p(r,e,n)},r.postMessage({type:`init`,...this.initPayload()})});this.#r=e,e.catch(()=>{this.#r===e&&(this.#r=null)})}return this.#r.then(n,e=>{throw n(),e})}run(e,t={}){let n,i,a=new Promise((e,t)=>{n=e,i=t}),o,s=new Promise(e=>{o=e}),c={id:r++,code:e,options:t,stdout:``,stderr:``,resolve:n,reject:i,promise:a,started:!1,settled:!1,done:s,markDone:()=>{clearTimeout(c.timer),c.settled=!0,o()}};return this.#l.push(c),this.#b(),a}stop(t){if(t){let n=this.#l.findIndex(e=>e.promise===t);if(n!==-1){this.#y(this.#l.splice(n,1)[0],new e);return}let r=this.#u;if(!r||r.promise!==t||r.settled)return;if(!r.started){this.#y(r,new e);return}}this.#f()}#f(){let t=this.#e!==null,n=this.#i;if(this.#m(),this.#u&&this.#y(this.#u,new e),t){let e=this.load();n&&e.then(n.resolve,n.reject),e.catch(()=>{})}}#p(e,t,n){this.#m(),this.#n===`module`?(this.#n=`classic`,this.load().then(t,n)):n(Error(e))}#m(){this.#e?.terminate(),this.#e=null,this.#t&&=(URL.revokeObjectURL(this.#t),null),this.#r=null,this.#i=null,this.#a=!1}#h(e){for(let t of this.#c)t(e)}#g(e){if(e.type===`progress`){this.#h({phase:e.phase,message:e.message}),this.#u&&e.id===this.#u.id&&!this.#u.settled&&this.#u.options.onProgress?.({phase:e.phase,message:e.message});return}let t=this.#u;if(t&&`id`in e&&e.id===t.id)switch(e.type){case`stdout`:t.stdout+=e.text,t.options.onStdout?.(e.text);break;case`echo`:t.options.onEcho?.(e.text);break;case`stdin-request`:this.#v(t,e.request);break;case`module-request`:this.#_(t,e.name);break;case`stderr`:t.stderr+=e.text,t.options.onStderr?.(e.text);break;case`result`:t.resolve({stdout:t.stdout,stderr:t.stderr||void 0,value:e.value,durationMs:Math.round(e.durationMs),failed:!1,...e.memory?{memory:e.memory}:{},...e.cases?{cases:e.cases,passed:e.passed,total:e.total}:{}}),t.markDone();break;case`error`:case`fatal`:{let r=(t.stderr&&!t.stderr.endsWith(`
|
|
7
|
-
`)?`
|
|
8
|
-
`:``)+e.message+`
|
|
9
|
-
`;t.stderr+=r,t.options.onStderr?.(r);let i={stdout:t.stdout,stderr:t.stderr,hint:`hint`in e?e.hint:void 0,durationMs:Math.round(`durationMs`in e?e.durationMs:0),failed:!0,...`cases`in e&&e.cases?{cases:e.cases,passed:0,total:e.cases.length}:{}};`hintAbout`in e&&e.hintAbout===`stdin`&&n.add(i),t.resolve(i),t.markDone();break}}}#_(e,t){let n=this.#e,r=r=>{this.#e===n&&this.#u===e&&n?.postMessage({type:`module`,name:t,...r})};this.loadModule(t).then(e=>r({code:e}),e=>r({error:e instanceof Error?e.message:String(e)}))}#v(e,t){let n=this.#e,r=r=>{this.#e===n&&this.#u===e&&n?.postMessage({type:`stdin-response`,request:t,text:r})},i=e.options.onStdinRequest;i?i().then(r,()=>r(null)):r(null)}#y(e,t){e.reject(t),e.markDone()}async#b(){if(!this.#d){this.#d=!0;try{for(;this.#l.length;){let e=this.#l.shift();this.#u=e;try{if(await this.load(),e.settled)continue;e.started=!0,e.options.onStart?.(),e.options.timeoutMs&&Number.isFinite(e.options.timeoutMs)&&e.options.timeoutMs>0&&(e.timer=setTimeout(()=>{this.#u!==e||e.settled||(this.#g({type:`error`,id:e.id,message:`Run exceeded its wall-clock time limit.`,durationMs:e.options.timeoutMs}),this.#m())},e.options.timeoutMs)),this.#e.postMessage({type:`run`,id:e.id,code:e.code,stdin:e.options.stdin,files:e.options.files,entry:e.options.entry,...e.options.compilerLanguage?{compilerLanguage:e.options.compilerLanguage}:{},...e.options.practice?{practice:e.options.practice}:{}}),await e.done}catch(t){this.#y(e,t)}finally{this.#u=null}}}finally{this.#d=!1}}}};export{i as t};
|