var U={},R=Symbol(),ne=Symbol(),Y=e=>typeof e=="string"?V[e]:e,V={plain:U,plaintext:U,text:U,txt:U},Z=(e,i)=>(i[ne]||te)(e,i),te=(e,i)=>{for(var r=[e],a,c=[],d=0;a=Y(i[R]);)delete i[R],Object.assign(i,a);for(ee(e,i,r,0);c[d++]=r[0],r=r[1];);return c},ie=(e,i,r)=>e.replace(/&/g,"&amp;").replace(i,r),X="</span>",q="",G="",j=e=>{for(var i="",r,a=0;r=e[a++];)i+=N(r);return i},N=e=>{if(e instanceof P){var{type:i,alias:r,content:a}=e,c=q,d=G,o=`<span class="token ${i+(r?" "+r:"")+(i=="keyword"&&typeof a=="string"?" keyword-"+a:"")}">`;G+=X,q+=o;var f=N(a);return q=c,G=d,o+f+X}return typeof e!="string"?j(e):(e=ie(e,/</g,"&lt;"),G&&e.includes(`
`)?e.replace(/\n/g,G+`
`+q):e)},ee=(e,i,r,a,c)=>{for(var d in i)if(i[d])for(var o=0,f=i[d],g,z=Array.isArray(f)?f:[f];g=z[o];o++){if(c&&c[0]==d&&c[1]==o)return;for(var E=g.pattern||g,_=Y(g.inside),x=g.lookbehind,w=E.global,O=g.alias,s=r,v=a;s&&(!c||v<c[2]);v+=s[0].length,s=s[1]){var l=s[0],u=0,h;if(!(l instanceof P)){if(E.lastIndex=w?v:0,h=E.exec(w?e:l),!h&&w)break;if(h&&h[0]){var A=x&&h[1]?h[1].length:0,b=h.index+A,C=h[0].slice(A),H=b+C.length,L,f;if(w){for(;f=v+s[0].length,b>=f;s=s[1],v=f);if(s[0]instanceof P)continue;for(L=s,f=v;(f+=L[0].length)<H;L=L[1],u++);l=e.slice(v,f),b-=v,H-=v}for(var T=l.slice(H),S=v+l.length,I=new P(d,_?Z(C,_):C,C,O),p=s,k=0,$;p=p[1],k++<u;);T&&(!p||p[0]instanceof P?p=[T,p]:p[0]=T+p[0]),v+=b,s[0]=b?l.slice(0,b):I,b?s=s[1]=[I,p]:s[1]=p,u&&(ee(e,i,s,v,$=[d,o,S]),S=$[2]),c&&S>c[2]&&(c[2]=S)}}}}};function P(e,i,r,a){this.type=e,this.content=i,this.alias=a,this.length=r.length}const ue=(e,i,...r)=>{let a,c=[],d,o="",f,g=!1,z=!0,E=[],_,x=0;const w=re(),O=w.firstChild,s=O.children,v=s[0],l=v.firstChild,u={language:"text",value:o},h=new Set(r),A={},b=n=>{Object.assign(u,n);let t=o!=(o=n.value??o),y=a!=(a=u.language);_=!!u.readOnly,w.style.tabSize=u.tabSize||2,l.inputMode=_?"none":"",l.setAttribute("aria-readonly",_),L(),H(),t&&(g||l.remove(),l.value=o,l.selectionEnd=0,g||v.prepend(l)),(t||y)&&C()},C=()=>{E=Z(o=l.value,V[a]||{}),p("tokenize",E,a,o);let n=j(E).split(`
`),t=0,y=x,M=x=n.length;for(;n[t]==c[t]&&t<M;)++t;for(;M&&n[--M]==c[--y];);if(t==M&&t==y)s[t+1].innerHTML=n[t]+`
`;else{let Q=y<t?y:t-1,D=Q,B="";for(;D<M;)B+=`<div class=pce-line aria-hidden=true>${n[++D]}
</div>`;for(D=M<t?M:t-1;D<y;D++)s[t+1].remove();B&&s[Q+1].insertAdjacentHTML("afterend",B),w.style.setProperty("--number-width",(0|Math.log10(x))+1+".001ch")}p("update",o),k(!0),z&&setTimeout(setTimeout,0,()=>z=!0),c=n,z=!1},H=n=>{(n||h).forEach(t=>{typeof t=="object"?(t.update($,u),n&&h.add(t)):(t($,u),n||h.delete(t))})},L=([n,t]=T())=>{w.className=`prism-code-editor language-${a}${u.lineNumbers==!1?"":" show-line-numbers"} pce-${u.wordWrap?"":"no"}wrap${u.rtl?" pce-rtl":""} pce-${n<t?"has":"no"}-selection${g?" pce-focus":""}${_?" pce-readonly":""}${u.class?" "+u.class:""}`},T=()=>[l.selectionStart,l.selectionEnd,l.selectionDirection],S={Escape(){l.blur()}},I={},p=(n,...t)=>{A[n]?.forEach(y=>y.apply($,t)),u["on"+n[0].toUpperCase()+n.slice(1)]?.(...t,$)},k=n=>{if(n||z){const t=T(),y=s[f=se(o,0,t[t[2]<"f"?0:1])];y!=d&&(d?.classList.remove("active-line"),y.classList.add("active-line"),d=y),L(t),p("selectionChange",t,o)}},$={container:w,wrapper:O,lines:s,textarea:l,get activeLine(){return f},get value(){return o},options:u,get focused(){return g},get tokens(){return E},inputCommandMap:I,keyCommandMap:S,extensions:{},setOptions:b,update:C,getSelection:T,addExtensions(...n){H(n)},on:(n,t)=>((A[n]||=new Set).add(t),()=>A[n].delete(t)),remove(){w.remove()}};return m(l,"keydown",n=>{S[n.key]?.(n,T(),o)&&J(n)}),m(l,"beforeinput",n=>{(_||n.inputType=="insertText"&&I[n.data]?.(n,T(),o))&&J(n)}),m(l,"input",C),m(l,"blur",()=>{K=null,g=!1,L()}),m(l,"focus",()=>{K=k,g=!0,L()}),m(l,"selectionchange",n=>{k(),J(n)}),ae(e)?.append(w),i&&b(i),$},W="u">typeof window?document:null,F=W?.createElement("div"),le=(e,i)=>(F&&(F.innerHTML=e,i=F.firstChild),()=>i.cloneNode(!0)),m=(e,i,r,a)=>e.addEventListener(i,r,a),ae=e=>typeof e=="string"?W.querySelector(e):e,se=(e,i=0,r=1/0)=>{let a=1;for(;(i=e.indexOf(`
`,i)+1)&&i<=r;a++);return a},re=le("<div><div class=pce-wrapper><div class=pce-overlays><textarea class=pce-textarea spellcheck=false autocapitalize=off autocomplete=off>"),J=e=>{e.preventDefault(),e.stopImmediatePropagation()};let K;W&&m(W,"selectionchange",()=>K?.());var oe=/\/\/.*|\/\*[^]*?(?:\*\/|$)/g,ce=/\b(?:false|true)\b/;V.webmanifest=V.json={property:/"(?:\\.|[^\\\n"])*"(?=\s*:)/g,string:/"(?:\\.|[^\\\n"])*"/g,comment:oe,number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,operator:/:/,punctuation:/[[\]{},]/,boolean:ce,null:{pattern:/\bnull\b/,alias:"keyword"}};export{ue as c};
