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