diff --git a/CHANGELOG.md b/CHANGELOG.md index 10c1016..fd20874 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ - updated code editor to cm6 - still not working: dice button +# [1.5.3] - 2023 - 02 - 19 +- fixed error reporting +- removed devtools + +# [1.5.2] - 2023 - 02 - 10 +- updated upload text, removed default + # [1.5.1] - 2023 - 07 - 19 ## Added - extension loader diff --git a/dist/assets/index-3e7f6eb3.js b/dist/assets/index-e814b025.js similarity index 73% rename from dist/assets/index-3e7f6eb3.js rename to dist/assets/index-e814b025.js index 6081408..5554b8a 100644 --- a/dist/assets/index-3e7f6eb3.js +++ b/dist/assets/index-e814b025.js @@ -1,8 +1,8 @@ -var ev=Object.defineProperty;var tv=(i,e,t)=>e in i?ev(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var fd=(i,e,t)=>(tv(i,typeof e!="symbol"?e+"":e,t),t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function t(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(r){if(r.ep)return;r.ep=!0;const s=t(r);fetch(r.href,s)}})();var lt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function zt(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function Py(i){if(i.__esModule)return i;var e=i.default;if(typeof e=="function"){var t=function n(){if(this instanceof n){var r=[null];r.push.apply(r,arguments);var s=Function.bind.apply(e,r);return new s}return e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(i).forEach(function(n){var r=Object.getOwnPropertyDescriptor(i,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return i[n]}})}),t}var ec={exports:{}},dr=typeof Reflect=="object"?Reflect:null,cd=dr&&typeof dr.apply=="function"?dr.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},ua;dr&&typeof dr.ownKeys=="function"?ua=dr.ownKeys:Object.getOwnPropertySymbols?ua=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:ua=function(e){return Object.getOwnPropertyNames(e)};function iv(i){console&&console.warn&&console.warn(i)}var Jy=Number.isNaN||function(e){return e!==e};function $e(){$e.init.call(this)}ec.exports=$e;ec.exports.once=ov;$e.EventEmitter=$e;$e.prototype._events=void 0;$e.prototype._eventsCount=0;$e.prototype._maxListeners=void 0;var dd=10;function yl(i){if(typeof i!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof i)}Object.defineProperty($e,"defaultMaxListeners",{enumerable:!0,get:function(){return dd},set:function(i){if(typeof i!="number"||i<0||Jy(i))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+i+".");dd=i}});$e.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};$e.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Jy(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Iy(i){return i._maxListeners===void 0?$e.defaultMaxListeners:i._maxListeners}$e.prototype.getMaxListeners=function(){return Iy(this)};$e.prototype.emit=function(e){for(var t=[],n=1;n0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var l=s[e];if(l===void 0)return!1;if(typeof l=="function")cd(l,this,t);else for(var u=l.length,h=Ny(l,u),n=0;n0&&o.length>r&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=i,a.type=e,a.count=o.length,iv(a)}return i}$e.prototype.addListener=function(e,t){return By(this,e,t,!1)};$e.prototype.on=$e.prototype.addListener;$e.prototype.prependListener=function(e,t){return By(this,e,t,!0)};function nv(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Ly(i,e,t){var n={fired:!1,wrapFn:void 0,target:i,type:e,listener:t},r=nv.bind(n);return r.listener=t,n.wrapFn=r,r}$e.prototype.once=function(e,t){return yl(t),this.on(e,Ly(this,e,t)),this};$e.prototype.prependOnceListener=function(e,t){return yl(t),this.prependListener(e,Ly(this,e,t)),this};$e.prototype.removeListener=function(e,t){var n,r,s,o,a;if(yl(t),r=this._events,r===void 0)return this;if(n=r[e],n===void 0)return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():rv(n,s),n.length===1&&(r[e]=n[0]),r.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this};$e.prototype.off=$e.prototype.removeListener;$e.prototype.removeAllListeners=function(e){var t,n,r;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),o;for(r=0;r=0;r--)this.removeListener(e,t[r]);return this};function jy(i,e,t){var n=i._events;if(n===void 0)return[];var r=n[e];return r===void 0?[]:typeof r=="function"?t?[r.listener||r]:[r]:t?sv(r):Ny(r,r.length)}$e.prototype.listeners=function(e){return jy(this,e,!0)};$e.prototype.rawListeners=function(e){return jy(this,e,!1)};$e.listenerCount=function(i,e){return typeof i.listenerCount=="function"?i.listenerCount(e):Dy.call(i,e)};$e.prototype.listenerCount=Dy;function Dy(i){var e=this._events;if(e!==void 0){var t=e[i];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}$e.prototype.eventNames=function(){return this._eventsCount>0?ua(this._events):[]};function Ny(i,e){for(var t=new Array(e),n=0;n=10||i%1===0?(e?"-":"")+i.toFixed(0)+" "+r:(e?"-":"")+i.toFixed(1)+" "+r}var hv=lv,fv=cv;function cv(){Object.defineProperty(window.choo,"storage",{get:i,set:dv});function i(){if(navigator.storage)return navigator.storage.estimate().then(function(t){var n=(t.usage/t.quota).toFixed();Vl("Max storage:",pd(t.quota)),Vl("Storage used:",pd(t.usage)+" ("+n+"%)"),navigator.storage.persisted().then(function(r){var s=r?"enabled":"disabled";Vl("Persistent storage:",s)})}),"Calculating storage quota…";var e=window.location.protocol;return/https/.test(e)?"The Storage API is unavailable in this browser. We're sorry!":"The Storage API is unavailable. Serving this site over HTTPS might help enable it!"}}function Vl(i,e){var t="#cc99cc";console.log("%c"+i,"color: "+t,e)}function pd(i){return hv(i).replace(" ","")}function dv(){}Li.notEqual=gv;Li.notOk=mv;Li.equal=pv;Li.ok=Li;var Pt=Li;function pv(i,e,t){Li(i==e,t)}function gv(i,e,t){Li(i!=e,t)}function mv(i,e){Li(!i,e)}function Li(i,e){if(!i)throw new Error(e||"AssertionError")}var yv=Pt,Ov=typeof window<"u";function _v(){var i;return Ov?(window._nanoScheduler||(window._nanoScheduler=new Es(!0)),i=window._nanoScheduler):i=new Es,i}function Es(i){this.hasWindow=i,this.hasIdle=this.hasWindow&&window.requestIdleCallback,this.method=this.hasIdle?window.requestIdleCallback.bind(window):this.setTimeout,this.scheduled=!1,this.queue=[]}Es.prototype.push=function(i){yv.equal(typeof i,"function","nanoscheduler.push: cb should be type function"),this.queue.push(i),this.schedule()};Es.prototype.schedule=function(){if(!this.scheduled){this.scheduled=!0;var i=this;this.method(function(e){for(var t;i.queue.length&&e.timeRemaining()>0;)t=i.queue.shift(),t(e);i.scheduled=!1,i.queue.length&&i.schedule()})}};Es.prototype.setTimeout=function(i){setTimeout(i,0,{timeRemaining:function(){return 1}})};var ro=_v,Fy={exports:{}};/* +var Jb=Object.defineProperty;var Ib=(i,e,t)=>e in i?Jb(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var id=(i,e,t)=>(Ib(i,typeof e!="symbol"?e+"":e,t),t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function t(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function n(r){if(r.ep)return;r.ep=!0;const s=t(r);fetch(r.href,s)}})();var lt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ui(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}function Bb(i){if(i.__esModule)return i;var e=i.default;if(typeof e=="function"){var t=function n(){if(this instanceof n){var r=[null];r.push.apply(r,arguments);var s=Function.bind.apply(e,r);return new s}return e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(i).forEach(function(n){var r=Object.getOwnPropertyDescriptor(i,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return i[n]}})}),t}var Gf={exports:{}},cr=typeof Reflect=="object"?Reflect:null,nd=cr&&typeof cr.apply=="function"?cr.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},oa;cr&&typeof cr.ownKeys=="function"?oa=cr.ownKeys:Object.getOwnPropertySymbols?oa=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:oa=function(e){return Object.getOwnPropertyNames(e)};function Lb(i){console&&console.warn&&console.warn(i)}var wy=Number.isNaN||function(e){return e!==e};function $e(){$e.init.call(this)}Gf.exports=$e;Gf.exports.once=Zb;$e.EventEmitter=$e;$e.prototype._events=void 0;$e.prototype._eventsCount=0;$e.prototype._maxListeners=void 0;var rd=10;function dl(i){if(typeof i!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof i)}Object.defineProperty($e,"defaultMaxListeners",{enumerable:!0,get:function(){return rd},set:function(i){if(typeof i!="number"||i<0||wy(i))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+i+".");rd=i}});$e.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};$e.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||wy(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function by(i){return i._maxListeners===void 0?$e.defaultMaxListeners:i._maxListeners}$e.prototype.getMaxListeners=function(){return by(this)};$e.prototype.emit=function(e){for(var t=[],n=1;n0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var l=s[e];if(l===void 0)return!1;if(typeof l=="function")nd(l,this,t);else for(var u=l.length,h=My(l,u),n=0;n0&&o.length>r&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=i,a.type=e,a.count=o.length,Lb(a)}return i}$e.prototype.addListener=function(e,t){return vy(this,e,t,!1)};$e.prototype.on=$e.prototype.addListener;$e.prototype.prependListener=function(e,t){return vy(this,e,t,!0)};function jb(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Sy(i,e,t){var n={fired:!1,wrapFn:void 0,target:i,type:e,listener:t},r=jb.bind(n);return r.listener=t,n.wrapFn=r,r}$e.prototype.once=function(e,t){return dl(t),this.on(e,Sy(this,e,t)),this};$e.prototype.prependOnceListener=function(e,t){return dl(t),this.prependListener(e,Sy(this,e,t)),this};$e.prototype.removeListener=function(e,t){var n,r,s,o,a;if(dl(t),r=this._events,r===void 0)return this;if(n=r[e],n===void 0)return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===t||n[o].listener===t){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():Db(n,s),n.length===1&&(r[e]=n[0]),r.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this};$e.prototype.off=$e.prototype.removeListener;$e.prototype.removeAllListeners=function(e){var t,n,r;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),o;for(r=0;r=0;r--)this.removeListener(e,t[r]);return this};function xy(i,e,t){var n=i._events;if(n===void 0)return[];var r=n[e];return r===void 0?[]:typeof r=="function"?t?[r.listener||r]:[r]:t?Nb(r):My(r,r.length)}$e.prototype.listeners=function(e){return xy(this,e,!0)};$e.prototype.rawListeners=function(e){return xy(this,e,!1)};$e.listenerCount=function(i,e){return typeof i.listenerCount=="function"?i.listenerCount(e):ky.call(i,e)};$e.prototype.listenerCount=ky;function ky(i){var e=this._events;if(e!==void 0){var t=e[i];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}$e.prototype.eventNames=function(){return this._eventsCount>0?oa(this._events):[]};function My(i,e){for(var t=new Array(e),n=0;n0;)t=i.queue.shift(),t(e);i.scheduled=!1,i.queue.length&&i.schedule()})}};Ms.prototype.setTimeout=function(i){setTimeout(i,0,{timeRemaining:function(){return 1}})};var io=Vb,Cy={exports:{}};/* object-assign (c) Sindre Sorhus @license MIT -*/var gd=Object.getOwnPropertySymbols,wv=Object.prototype.hasOwnProperty,bv=Object.prototype.propertyIsEnumerable;function vv(i){if(i==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(i)}function Sv(){try{if(!Object.assign)return!1;var i=new String("abc");if(i[5]="de",Object.getOwnPropertyNames(i)[0]==="5")return!1;for(var e={},t=0;t<10;t++)e["_"+String.fromCharCode(t)]=t;var n=Object.getOwnPropertyNames(e).map(function(s){return e[s]});if(n.join("")!=="0123456789")return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(s){r[s]=s}),Object.keys(Object.assign({},r)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}var xv=Sv()?Object.assign:function(i,e){for(var t,n=vv(i),r,s=1;s=se)return de;switch(de){case"%s":return String(te[Y++]);case"%d":return Number(te[Y++]);case"%j":try{return JSON.stringify(te[Y++])}catch{return"[Circular]"}default:return de}}),ue=te[Y];Y=3&&(Y.depth=arguments[2]),arguments.length>=4&&(Y.colors=arguments[3]),x(N)?Y.showHidden=N:N&&i._extend(Y,N),T(Y.showHidden)&&(Y.showHidden=!1),T(Y.depth)&&(Y.depth=2),T(Y.colors)&&(Y.colors=!1),T(Y.customInspect)&&(Y.customInspect=!0),Y.colors&&(Y.stylize=s),l(Y,R,Y.depth)}i.inspect=r,r.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},r.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function s(R,N){var Y=r.styles[N];return Y?"\x1B["+r.colors[Y][0]+"m"+R+"\x1B["+r.colors[Y][1]+"m":R}function o(R,N){return R}function a(R){var N={};return R.forEach(function(Y,te){N[Y]=!0}),N}function l(R,N,Y){if(R.customInspect&&N&&_(N.inspect)&&N.inspect!==i.inspect&&!(N.constructor&&N.constructor.prototype===N)){var te=N.inspect(Y,R);return A(te)||(te=l(R,te,Y)),te}var se=u(R,N);if(se)return se;var le=Object.keys(N),ue=a(le);if(R.showHidden&&(le=Object.getOwnPropertyNames(N)),I(N)&&(le.indexOf("message")>=0||le.indexOf("description")>=0))return h(N);if(le.length===0){if(_(N)){var de=N.name?": "+N.name:"";return R.stylize("[Function"+de+"]","special")}if(k(N))return R.stylize(RegExp.prototype.toString.call(N),"regexp");if(C(N))return R.stylize(Date.prototype.toString.call(N),"date");if(I(N))return h(N)}var Qe="",W=!1,G=["{","}"];if(v(N)&&(W=!0,G=["[","]"]),_(N)){var ne=N.name?": "+N.name:"";Qe=" [Function"+ne+"]"}if(k(N)&&(Qe=" "+RegExp.prototype.toString.call(N)),C(N)&&(Qe=" "+Date.prototype.toUTCString.call(N)),I(N)&&(Qe=" "+h(N)),le.length===0&&(!W||N.length==0))return G[0]+Qe+G[1];if(Y<0)return k(N)?R.stylize(RegExp.prototype.toString.call(N),"regexp"):R.stylize("[Object]","special");R.seen.push(N);var ce;return W?ce=f(R,N,Y,ue,le):ce=le.map(function(ye){return c(R,N,Y,ue,ye,W)}),R.seen.pop(),p(ce,Qe,G)}function u(R,N){if(T(N))return R.stylize("undefined","undefined");if(A(N)){var Y="'"+JSON.stringify(N).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return R.stylize(Y,"string")}if(b(N))return R.stylize(""+N,"number");if(x(N))return R.stylize(""+N,"boolean");if(m(N))return R.stylize("null","null")}function h(R){return"["+Error.prototype.toString.call(R)+"]"}function f(R,N,Y,te,se){for(var le=[],ue=0,de=N.length;ue=se)return de;switch(de){case"%s":return String(te[Y++]);case"%d":return Number(te[Y++]);case"%j":try{return JSON.stringify(te[Y++])}catch{return"[Circular]"}default:return de}}),ue=te[Y];Y=3&&(Y.depth=arguments[2]),arguments.length>=4&&(Y.colors=arguments[3]),x(N)?Y.showHidden=N:N&&i._extend(Y,N),T(Y.showHidden)&&(Y.showHidden=!1),T(Y.depth)&&(Y.depth=2),T(Y.colors)&&(Y.colors=!1),T(Y.customInspect)&&(Y.customInspect=!0),Y.colors&&(Y.stylize=s),l(Y,R,Y.depth)}i.inspect=r,r.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},r.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function s(R,N){var Y=r.styles[N];return Y?"\x1B["+r.colors[Y][0]+"m"+R+"\x1B["+r.colors[Y][1]+"m":R}function o(R,N){return R}function a(R){var N={};return R.forEach(function(Y,te){N[Y]=!0}),N}function l(R,N,Y){if(R.customInspect&&N&&_(N.inspect)&&N.inspect!==i.inspect&&!(N.constructor&&N.constructor.prototype===N)){var te=N.inspect(Y,R);return A(te)||(te=l(R,te,Y)),te}var se=u(R,N);if(se)return se;var le=Object.keys(N),ue=a(le);if(R.showHidden&&(le=Object.getOwnPropertyNames(N)),I(N)&&(le.indexOf("message")>=0||le.indexOf("description")>=0))return h(N);if(le.length===0){if(_(N)){var de=N.name?": "+N.name:"";return R.stylize("[Function"+de+"]","special")}if(k(N))return R.stylize(RegExp.prototype.toString.call(N),"regexp");if(C(N))return R.stylize(Date.prototype.toString.call(N),"date");if(I(N))return h(N)}var Qe="",W=!1,G=["{","}"];if(v(N)&&(W=!0,G=["[","]"]),_(N)){var ne=N.name?": "+N.name:"";Qe=" [Function"+ne+"]"}if(k(N)&&(Qe=" "+RegExp.prototype.toString.call(N)),C(N)&&(Qe=" "+Date.prototype.toUTCString.call(N)),I(N)&&(Qe=" "+h(N)),le.length===0&&(!W||N.length==0))return G[0]+Qe+G[1];if(Y<0)return k(N)?R.stylize(RegExp.prototype.toString.call(N),"regexp"):R.stylize("[Object]","special");R.seen.push(N);var ce;return W?ce=f(R,N,Y,ue,le):ce=le.map(function(ye){return c(R,N,Y,ue,ye,W)}),R.seen.pop(),p(ce,Qe,G)}function u(R,N){if(T(N))return R.stylize("undefined","undefined");if(A(N)){var Y="'"+JSON.stringify(N).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return R.stylize(Y,"string")}if(b(N))return R.stylize(""+N,"number");if(x(N))return R.stylize(""+N,"boolean");if(m(N))return R.stylize("null","null")}function h(R){return"["+Error.prototype.toString.call(R)+"]"}function f(R,N,Y,te,se){for(var le=[],ue=0,de=N.length;ue-1&&(le?de=de.split(` `).map(function(W){return" "+W}).join(` `).substr(2):de=` @@ -11,51 +11,48 @@ object-assign `))):de=R.stylize("[Circular]","special")),T(ue)){if(le&&se.match(/^\d+$/))return de;ue=JSON.stringify(""+se),ue.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(ue=ue.substr(1,ue.length-2),ue=R.stylize(ue,"name")):(ue=ue.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),ue=R.stylize(ue,"string"))}return ue+": "+de}function p(R,N,Y){var te=R.reduce(function(se,le){return le.indexOf(` `)>=0,se+le.replace(/\u001b\[\d\d?m/g,"").length+1},0);return te>60?Y[0]+(N===""?"":N+` `)+" "+R.join(`, - `)+" "+Y[1]:Y[0]+N+" "+R.join(", ")+" "+Y[1]}function v(R){return Array.isArray(R)}i.isArray=v;function x(R){return typeof R=="boolean"}i.isBoolean=x;function m(R){return R===null}i.isNull=m;function d(R){return R==null}i.isNullOrUndefined=d;function b(R){return typeof R=="number"}i.isNumber=b;function A(R){return typeof R=="string"}i.isString=A;function S(R){return typeof R=="symbol"}i.isSymbol=S;function T(R){return R===void 0}i.isUndefined=T;function k(R){return Q(R)&&D(R)==="[object RegExp]"}i.isRegExp=k;function Q(R){return typeof R=="object"&&R!==null}i.isObject=Q;function C(R){return Q(R)&&D(R)==="[object Date]"}i.isDate=C;function I(R){return Q(R)&&(D(R)==="[object Error]"||R instanceof Error)}i.isError=I;function _(R){return typeof R=="function"}i.isFunction=_;function j(R){return R===null||typeof R=="boolean"||typeof R=="number"||typeof R=="string"||typeof R=="symbol"||typeof R>"u"}i.isPrimitive=j,i.isBuffer=kv;function D(R){return Object.prototype.toString.call(R)}function V(R){return R<10?"0"+R.toString(10):R.toString(10)}var ee=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function B(){var R=new Date,N=[V(R.getHours()),V(R.getMinutes()),V(R.getSeconds())].join(":");return[R.getDate(),ee[R.getMonth()],N].join(" ")}i.log=function(){console.log("%s - %s",B(),i.format.apply(i,arguments))},i.inherits=Mv,i._extend=function(R,N){if(!N||!Q(N))return R;for(var Y=Object.keys(N),te=Y.length;te--;)R[Y[te]]=N[Y[te]];return R};function Z(R,N){return Object.prototype.hasOwnProperty.call(R,N)}})(Xy);var Tv=xv;/*! + `)+" "+Y[1]:Y[0]+N+" "+R.join(", ")+" "+Y[1]}function v(R){return Array.isArray(R)}i.isArray=v;function x(R){return typeof R=="boolean"}i.isBoolean=x;function m(R){return R===null}i.isNull=m;function d(R){return R==null}i.isNullOrUndefined=d;function b(R){return typeof R=="number"}i.isNumber=b;function A(R){return typeof R=="string"}i.isString=A;function S(R){return typeof R=="symbol"}i.isSymbol=S;function T(R){return R===void 0}i.isUndefined=T;function k(R){return Q(R)&&D(R)==="[object RegExp]"}i.isRegExp=k;function Q(R){return typeof R=="object"&&R!==null}i.isObject=Q;function C(R){return Q(R)&&D(R)==="[object Date]"}i.isDate=C;function I(R){return Q(R)&&(D(R)==="[object Error]"||R instanceof Error)}i.isError=I;function _(R){return typeof R=="function"}i.isFunction=_;function j(R){return R===null||typeof R=="boolean"||typeof R=="number"||typeof R=="string"||typeof R=="symbol"||typeof R>"u"}i.isPrimitive=j,i.isBuffer=iv;function D(R){return Object.prototype.toString.call(R)}function V(R){return R<10?"0"+R.toString(10):R.toString(10)}var ee=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function B(){var R=new Date,N=[V(R.getHours()),V(R.getMinutes()),V(R.getSeconds())].join(":");return[R.getDate(),ee[R.getMonth()],N].join(" ")}i.log=function(){console.log("%s - %s",B(),i.format.apply(i,arguments))},i.inherits=nv,i._extend=function(R,N){if(!N||!Q(N))return R;for(var Y=Object.keys(N),te=Y.length;te--;)R[Y[te]]=N[Y[te]];return R};function Z(R,N){return Object.prototype.hasOwnProperty.call(R,N)}})(Ey);var rv=tv;/*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT - */function md(i,e){if(i===e)return 0;for(var t=i.length,n=e.length,r=0,s=Math.min(t,n);r=0){var a=r.indexOf(` -`,o+1);r=r.substring(a+1)}this.stack=r}}};ri.inherits(Me.AssertionError,Error);function wd(i,e){return typeof i=="string"?i.length=0;u--)if(o[u]!==a[u])return!1;for(u=o.length-1;u>=0;u--)if(l=o[u],!xr(i[l],e[l],t,n))return!1;return!0}Me.notDeepEqual=function(e,t,n){xr(e,t,!1)&&Rt(e,t,n,"notDeepEqual",Me.notDeepEqual)};Me.notDeepStrictEqual=zy;function zy(i,e,t){xr(i,e,!0)&&Rt(i,e,t,"notDeepStrictEqual",zy)}Me.strictEqual=function(e,t,n){e!==t&&Rt(e,t,n,"===",Me.strictEqual)};Me.notStrictEqual=function(e,t,n){e===t&&Rt(e,t,n,"!==",Me.notStrictEqual)};function Sd(i,e){if(!i||!e)return!1;if(Object.prototype.toString.call(e)=="[object RegExp]")return e.test(i);try{if(i instanceof e)return!0}catch{}return Error.isPrototypeOf(e)?!1:e.call({},i)===!0}function Rv(i){var e;try{i()}catch(t){e=t}return e}function Vy(i,e,t,n){var r;if(typeof e!="function")throw new TypeError('"block" argument must be a function');typeof t=="string"&&(n=t,t=null),r=Rv(e),n=(t&&t.name?" ("+t.name+").":".")+(n?" "+n:"."),i&&!r&&Rt(r,t,"Missing expected exception"+n);var s=typeof n=="string",o=!i&&ri.isError(r),a=!i&&r&&!t;if((o&&s&&Sd(r,t)||a)&&Rt(r,t,"Got unwanted exception"+n),i&&r&&t&&!Sd(r,t)||!i&&r)throw r}Me.throws=function(i,e,t){Vy(!0,i,e,t)};Me.doesNotThrow=function(i,e,t){Vy(!1,i,e,t)};Me.ifError=function(i){if(i)throw i};function Ky(i,e){i||Rt(i,!0,e,"==",Ky)}Me.strict=Tv(Ky,Me,{equal:Me.strictEqual,deepEqual:Me.deepStrictEqual,notEqual:Me.notStrictEqual,notDeepEqual:Me.notDeepStrictEqual});Me.strict.strict=Me.strict;var xd=Object.keys||function(i){var e=[];for(var t in i)Cv.call(i,t)&&e.push(t);return e},_l=Fy.exports,Uv=_l,$v={trace:"🔍",debug:"🐛",info:"✨",warn:"⚠️",error:"🚨",fatal:"💀"},qy={trace:10,debug:20,info:30,warn:40,error:50,fatal:60},Pv={foreground:"#d3c0c8",background:"#2d2d2d",black:"#2d2d2d",red:"#f2777a",green:"#99cc99",yellow:"#ffcc66",blue:"#6699cc",magenta:"#cc99cc",cyan:"#66cccc",white:"#d3d0c8",brightBlack:"#747369"},tc=Ui;function Ui(i,e){if(e=e||{},!(this instanceof Ui))return new Ui(i,e);Uv.equal(typeof e,"object","nanologger: opts should be type object"),this._name=i||"",this._colors=Object.assign({},Pv,e.colors||{});try{this.logLevel=window.localStorage.getItem("logLevel")||"info"}catch{this.logLevel="info"}this._logLevel=qy[this.logLevel]}Ui.prototype.trace=function(){for(var i=["trace"],e=0,t=arguments.length;e2?e.slice(2):e,e[0]=e[0].replace(/^ {4}at /,""),` -`+e.join(` -`)}var qv=Vv,Hv=tc,eS=_l,ql="Debugging enabled. To disable run: `choo.debug = false`",tS="Debugging disabled. We hope it was helpful! 🙌",iS=nS;function nS(i,e,t,n){var r=Hv("choo-devtools"),s=window.localStorage.logLevel==="debug";s&&r.info(ql),i=qv(i,function(o,a,l){s&&(l=l.split(` -`)[1].replace(/^ +/,""),r.info("state."+o,a,` -`+l))}),t.state=i,Object.defineProperty(window.choo,"debug",{get:function(){return window.localStorage.logLevel="debug",n.emit("debug",!0),s=!0,ql},set:function(o){eS.equal(typeof o,"boolean","choo-devtools.debug: bool should be type boolean"),window.localStorage.logLevel=o?"debug":"info",s=o,n.emit("debug",s),s?r.info(ql):r.info(tS)}})}var eO=Qs;Qs.default=Qs;Qs.stable=nO;Qs.stableStringify=nO;var Ta="[...]",tO="[Circular]",Jn=[],Tn=[];function iO(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function Qs(i,e,t,n){typeof n>"u"&&(n=iO()),kh(i,"",0,[],void 0,0,n);var r;try{Tn.length===0?r=JSON.stringify(i,e,t):r=JSON.stringify(i,rO(e),t)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;Jn.length!==0;){var s=Jn.pop();s.length===4?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return r}function pr(i,e,t,n){var r=Object.getOwnPropertyDescriptor(n,t);r.get!==void 0?r.configurable?(Object.defineProperty(n,t,{value:i}),Jn.push([n,t,e,r])):Tn.push([e,t,i]):(n[t]=i,Jn.push([n,t,e]))}function kh(i,e,t,n,r,s,o){s+=1;var a;if(typeof i=="object"&&i!==null){for(a=0;ao.depthLimit){pr(Ta,i,e,r);return}if(typeof o.edgesLimit<"u"&&t+1>o.edgesLimit){pr(Ta,i,e,r);return}if(n.push(i),Array.isArray(i))for(a=0;ae?1:0}function nO(i,e,t,n){typeof n>"u"&&(n=iO());var r=Mh(i,"",0,[],void 0,0,n)||i,s;try{Tn.length===0?s=JSON.stringify(r,e,t):s=JSON.stringify(r,rO(e),t)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;Jn.length!==0;){var o=Jn.pop();o.length===4?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return s}function Mh(i,e,t,n,r,s,o){s+=1;var a;if(typeof i=="object"&&i!==null){for(a=0;ao.depthLimit){pr(Ta,i,e,r);return}if(typeof o.edgesLimit<"u"&&t+1>o.edgesLimit){pr(Ta,i,e,r);return}if(n.push(i),Array.isArray(i))for(a=0;a0)for(var n=0;n */var sS=oS;function oS(i){if(navigator.clipboard)return navigator.clipboard.writeText(i).catch(function(s){throw s!==void 0?s:new DOMException("The request is not allowed","NotAllowedError")});var e=document.createElement("span");e.textContent=i,e.style.whiteSpace="pre",e.style.webkitUserSelect="auto",e.style.userSelect="all",document.body.appendChild(e);var t=window.getSelection(),n=window.document.createRange();t.removeAllRanges(),n.selectNode(e),t.addRange(n);var r=!1;try{r=window.document.execCommand("copy")}catch(s){console.log("error",s)}return t.removeAllRanges(),window.document.body.removeChild(e),r?Promise.resolve():Promise.reject(new DOMException("The request is not allowed","NotAllowedError"))}var aS=eO,lS=sS;function uS(i){try{return JSON.stringify(i)}catch{}}function hS(i){var e=uS(i)||aS(i);lS(e)}var fS=hS,cS=dS;function dS(i,e){return arguments.length>=2?Td(i)(e):Td(i)}function Td(i){if(i=typeof i=="string"?String(i).trim().split("."):i,i.length<2)return i=i[0],t;var e=i.length;return n;function t(r){return r[i]}function n(r){for(var s=0;s"u");s++)r=r[i[s]];return r}}var pS=fS,gS=cS,mS=yS;function yS(i){var e=i&&typeof i=="string",t=e&&arguments.length===1&&i.indexOf("state.")===0;(!i||typeof i=="function")&&(i=window.choo.state),t&&[].push.call(arguments,{state:window.choo.state}),pS(e?gS.apply(this,arguments):i)}var OS=_S;function _S(){Object.defineProperty(window.choo,"help",{get:i,set:wS});function i(){return setTimeout(function(){di("copy","Serialize the current state to the clipboard."),di("debug","Enable Choo debug mode."),di("emit","Emit an event in the Choo emitter."),di("help","Print usage information."),di("log","Print the last 150 events emitted."),di("on","Listen for an event in the Choo emitter."),di("once","Listen for an event once in the Choo emitter."),di("perf","Print out performance metrics"),di("state","Print the Choo state object."),di("storage","Print browser storage information.")},0),"Choo command overview"}}function di(i,e){var t="#cc99cc";console.log(" %cchoo."+i,"color: "+t,"— "+e)}function wS(){}var bS=Hy,vS="█",SS=xS;function xS(i,e,t,n){var r={};window.choo.perf={};var s=new fs(r,"all");Object.defineProperty(window.choo.perf,"all",{get:s.get.bind(s),set:Oo});var o=new fs(r,"core",function(u){return/^choo/.test(u)});Object.defineProperty(window.choo.perf,"core",{get:o.get.bind(o),set:Oo});var a=new fs(r,"components",function(u){return!/^choo/.test(u)&&!/^bankai/.test(u)});Object.defineProperty(window.choo.perf,"components",{get:a.get.bind(a),set:Oo});var l=new fs(r,"events",function(u){return/^choo\.emit/.test(u)},function(u){return u.replace(/^choo\.emit\('/,"").replace(/'\)$/,"")});Object.defineProperty(window.choo.perf,"events",{get:l.get.bind(l),set:Oo}),bS(function(u){if(u.entryType==="measure"){var h=u.name.replace(/ .*$/,"");r[h]||(r[h]={name:h,count:0,entries:[]});var f=r[h];f.count+=1,f.entries.push(u.duration)}})}function fs(i,e,t,n){this.stats=i,this.name=e,this.filter=t||function(){return!0},this.rename=n||function(r){return r}}fs.prototype.get=function(){var i=Object.keys(this.stats).filter(this.filter),e=this,t=0,n=0,r=i.map(function(l){var u=e.stats[l],h=Number(u.entries.reduce(function(p,v){return p+v},0).toFixed(2));h>t&&(t=h);var f=MS(u.entries);f>n&&(n=f);var c=e.rename(u.name);return new kS(c,h,f,u.count)}),s=10;r.forEach(function(l){var u=l["Total Time (ms)"],h=l["Median (ms)"];l[" "]=o(u/t*100/s),l[" "]=o(h/n*100/s)});function o(l){for(var u="",h=0,f=Math.round(l);h=r||t<=0||e<0)){t=e+t>r?r-e:t;var s=r-t;for(n=e;n"u"&&(p=!0),typeof v>"u"&&(v=1/0);function S(T,k){if(T===null)return null;if(k===0)return T;var Q,C;if(typeof T!="object")return T;if(t(T,n))Q=new n;else if(t(T,r))Q=new r;else if(t(T,s))Q=new s(function(R,N){T.then(function(Y){R(S(Y,k-1))},function(Y){N(S(Y,k-1))})});else if(o.__isArray(T))Q=[];else if(o.__isRegExp(T))Q=new RegExp(T.source,f(T)),T.lastIndex&&(Q.lastIndex=T.lastIndex);else if(o.__isDate(T))Q=new Date(T.getTime());else{if(A&&Buffer.isBuffer(T))return Buffer.allocUnsafe?Q=Buffer.allocUnsafe(T.length):Q=new Buffer(T.length),T.copy(Q),Q;t(T,Error)?Q=Object.create(T):typeof x>"u"?(C=Object.getPrototypeOf(T),Q=Object.create(C)):(Q=Object.create(x),C=x)}if(p){var I=d.indexOf(T);if(I!=-1)return b[I];d.push(T),b.push(Q)}t(T,n)&&T.forEach(function(R,N){var Y=S(N,k-1),te=S(R,k-1);Q.set(Y,te)}),t(T,r)&&T.forEach(function(R){var N=S(R,k-1);Q.add(N)});for(var _ in T){var j;C&&(j=Object.getOwnPropertyDescriptor(C,_)),!(j&&j.set==null)&&(Q[_]=S(T[_],k-1))}if(Object.getOwnPropertySymbols)for(var D=Object.getOwnPropertySymbols(T),_=0;_eu&&AS(s,0,v-eu)})});function l(){setTimeout(function(){console.table(s)},0);var f=o===1?"event":"events",c=o+" "+f+" recorded, showing the last "+eu+".";return r===!1?c+=" Enable state capture by calling `choo.debug`.":c+=" Disable state capture by calling `choo.debug = false`.",c}function u(f,c,p){this.name=f,this.data=c===void 0?"":c,this.state=r?h(p):""}function h(f){try{var c=PS(f);return a||(a=!0),c}catch{return a&&($S.warn("Could not clone your app state. Make sure to have a serializable state so it can be cloned"),a=!1),""}}}function Ed(){}var Qd=Pt,BS=LS,sO=function(i,e){var t=e||"/",n={},r=i.nodes;return Object.keys(r).forEach(function(s){var o=(t==="/"?t:t+"/")+(s==="$$"?":"+i.name:s),a=r[s].cb;if(a!==void 0&&(n[o]=a),Object.keys(r[s].nodes).length!==0){var l=sO(r[s],o);Object.keys(l).forEach(function(u){n[u]=l[u]})}}),n};function LS(i){Qd.equal(typeof i,"function","wayfarer.getAllRoutes: router should be an function");var e=i._trie;Qd.equal(typeof e,"object","wayfarer.getAllRoutes: trie should be an object");var t=e.trie;return sO(t)}var jS=Ol.EventEmitter,DS=fv,NS=Yv,ZS=iS,FS=mS,XS=OS,GS=SS,WS=JS,YS=BS,zS=VS;function VS(i){return i=i||{},e.storeName="choo-devtools",e;function e(t,n,r){var s=new jS;typeof window<"u"&&NS(t,n,i),n.on("DOMContentLoaded",function(){typeof window>"u"||(window.choo={},window.choo.state=t,window.choo.emit=function(){n.emit.apply(n,arguments)},window.choo.on=function(o,a){n.on(o,a)},ZS(t,n,r,s),WS(t,n,r,s),GS(),window.choo.copy=FS,r.router&&r.router.router&&(window.choo.routes=Object.keys(YS(r.router.router))),DS(),XS())})}}const KS=zt(zS);var qS=HS;function HS(i,e){if(i)try{var t=document.querySelector(i);t&&t.scrollIntoView(e)}catch{}}var e1=t1;function t1(i){if(typeof document>"u")throw new Error("document-ready only runs in the browser");var e=document.readyState;if(e==="complete"||e==="interactive")return setTimeout(i,0);document.addEventListener("DOMContentLoaded",function(){i()})}var oO=ro(),i1=Pt,Vi;wl.disabled=!0;try{Vi=window.performance,wl.disabled=window.localStorage.DISABLE_NANOTIMING==="true"||!Vi.mark}catch{}var ic=wl;function wl(i){if(i1.equal(typeof i,"string","nanotiming: name should be type string"),wl.disabled)return n1;var e=(Vi.now()*1e4).toFixed()%Number.MAX_SAFE_INTEGER,t="start-"+e+"-"+i;Vi.mark(t);function n(r){var s="end-"+e+"-"+i;Vi.mark(s),oO.push(function(){var o=null;try{var a=i+" ["+e+"]";Vi.measure(a,t,s),Vi.clearMarks(t),Vi.clearMarks(s)}catch(l){o=l}r&&r(o,i)})}return n.uuid=e,n}function n1(i){i&&oO.push(function(){i(new Error("nanotiming: performance API unavailable"))})}var Ca=Pt,r1=Mr;function Mr(){if(!(this instanceof Mr))return new Mr;this.trie={nodes:{}}}Mr.prototype.create=function(i){Ca.equal(typeof i,"string","route should be a string");var e=i.replace(/^\//,"").split("/");function t(n,r){var s=ha(e,n)&&e[n];if(s===!1)return r;var o=null;return/^:|^\*/.test(s)?(ha(r.nodes,"$$")?o=r.nodes.$$:(o={nodes:{}},r.nodes.$$=o),s[0]==="*"&&(r.wildcard=!0),r.name=s.replace(/^:|^\*/,"")):ha(r.nodes,s)?o=r.nodes[s]:(o={nodes:{}},r.nodes[s]=o),t(n+1,o)}return t(0,this.trie)};Mr.prototype.match=function(i){Ca.equal(typeof i,"string","route should be a string");var e=i.replace(/^\//,"").split("/"),t={};function n(s,o){if(o!==void 0){var a=e[s];if(a===void 0)return o;if(ha(o.nodes,a))return n(s+1,o.nodes[a]);if(o.name){try{t[o.name]=decodeURIComponent(a)}catch{return n(s,void 0)}return n(s+1,o.nodes.$$)}else if(o.wildcard){try{t.wildcard=decodeURIComponent(e.slice(s).join("/"))}catch{return n(s,void 0)}return o.nodes.$$}else return n(s+1)}}var r=n(0,this.trie);if(r)return r=Object.assign({},r),r.params=t,r};Mr.prototype.mount=function(i,e){Ca.equal(typeof i,"string","route should be a string"),Ca.equal(typeof e,"object","trie should be a object");var t=i.replace(/^\//,"").split("/"),n=null,r=null;if(t.length===1)r=t[0],n=this.create(r);else{var s=t.join("/");r=t[0],n=this.create(s)}Object.assign(n.nodes,e.nodes),e.name&&(n.name=e.name),n.nodes[""]&&(Object.keys(n.nodes[""]).forEach(function(o){o!=="nodes"&&(n[o]=n.nodes[""][o])}),Object.assign(n.nodes,n.nodes[""].nodes),delete n.nodes[""].nodes)};function ha(i,e){return Object.prototype.hasOwnProperty.call(i,e)}var tu=Pt,s1=r1,o1=Th;function Th(i){if(!(this instanceof Th))return new Th(i);var e=(i||"").replace(/^\//,""),t=s1();return r._trie=t,r.on=n,r.emit=r,r.match=s,r._wayfarer=!0,r;function n(a,l){if(tu.equal(typeof a,"string"),tu.equal(typeof l,"function"),a=a||"/",l._wayfarer&&l._trie)t.mount(a,l._trie.trie);else{var u=t.create(a);u.cb=l,u.route=a}return r}function r(a){var l=s(a),u=new Array(arguments.length);u[0]=l.params;for(var h=1;h=0;--u)l=n[u],a=l.name,r=l.namespaceURI,s=l.value,r?(a=l.localName||a,o=e.getAttributeNS(r,a),o!==s&&e.setAttributeNS(r,a,s)):e.hasAttribute(a)?(o=e.getAttribute(a),o!==s&&(s==="null"||s==="undefined"?e.removeAttribute(a):e.setAttribute(a,s))):e.setAttribute(a,s);for(var h=t.length-1;h>=0;--h)l=t[h],l.specified!==!1&&(a=l.name,r=l.namespaceURI,r?(a=l.localName||a,i.hasAttributeNS(r,a)||e.removeAttributeNS(r,a)):i.hasAttributeNS(null,a)||e.removeAttribute(a))}function k1(i,e){for(var t=0;t"u","nanoraf: raf should be a function or undefined"),e||(e=window.requestAnimationFrame);var t=!1,n=null;return function(){n===null&&!t&&(t=!0,e(function(){t=!1;for(var o=n.length,a=new Array(o),l=0;l=s||n===0)){n=t+n>s?s-t:n;var o=s-n;for(r=t;r0&&this._emit(this._listeners[i],e),this._starListeners.length>0&&this._emit(this._starListeners,i,e,r.uuid),r(),this};Dt.prototype.on=Dt.prototype.addListener=function(i,e){return li.ok(typeof i=="string"||typeof i=="symbol","nanobus.on: eventName should be type string or symbol"),li.equal(typeof e,"function","nanobus.on: listener should be type function"),i==="*"?this._starListeners.push(e):(this._listeners[i]||(this._listeners[i]=[]),this._listeners[i].push(e)),this};Dt.prototype.prependListener=function(i,e){return li.ok(typeof i=="string"||typeof i=="symbol","nanobus.prependListener: eventName should be type string or symbol"),li.equal(typeof e,"function","nanobus.prependListener: listener should be type function"),i==="*"?this._starListeners.unshift(e):(this._listeners[i]||(this._listeners[i]=[]),this._listeners[i].unshift(e)),this};Dt.prototype.once=function(i,e){li.ok(typeof i=="string"||typeof i=="symbol","nanobus.once: eventName should be type string or symbol"),li.equal(typeof e,"function","nanobus.once: listener should be type function");var t=this;this.on(i,n);function n(){e.apply(t,arguments),t.removeListener(i,n)}return this};Dt.prototype.prependOnceListener=function(i,e){li.ok(typeof i=="string"||typeof i=="symbol","nanobus.prependOnceListener: eventName should be type string or symbol"),li.equal(typeof e,"function","nanobus.prependOnceListener: listener should be type function");var t=this;this.prependListener(i,n);function n(){e.apply(t,arguments),t.removeListener(i,n)}return this};Dt.prototype.removeListener=function(i,e){if(li.ok(typeof i=="string"||typeof i=="symbol","nanobus.removeListener: eventName should be type string or symbol"),li.equal(typeof e,"function","nanobus.removeListener: listener should be type function"),i==="*")return this._starListeners=this._starListeners.slice(),t(this._starListeners,e);return typeof this._listeners[i]<"u"&&(this._listeners[i]=this._listeners[i].slice()),t(this._listeners[i],e);function t(n,r){if(n){var s=n.indexOf(r);if(s!==-1)return Z1(n,s,1),!0}}};Dt.prototype.removeAllListeners=function(i){return i?i==="*"?this._starListeners=[]:this._listeners[i]=[]:(this._starListeners=[],this._listeners={}),this};Dt.prototype.listeners=function(i){var e=i!=="*"?this._listeners[i]:this._starListeners,t=[];if(e)for(var n=e.length,r=0;r"u")&&i.length!==0){t===void 0&&(t=e,e=null),e&&(n!==void 0?t=[e].concat(t,n):t=[e].concat(t));for(var r=i.length,s=0;sthis.maxAge?(this.remove(i),!1):!0};Wt.prototype.get=function(i){if(typeof i!="string"&&(i=""+i),!!this.cache.hasOwnProperty(i)){var e=this.cache[i];if(this._checkAge(i,e))return this.head!==i&&(i===this.tail?(this.tail=e.next,this.cache[this.tail].prev=null):this.cache[e.prev].next=e.next,this.cache[e.next].prev=e.prev,this.cache[this.head].next=i,e.prev=this.head,e.next=null,this.head=i),e.value}};Wt.prototype.evict=function(){this.tail&&this.remove(this.tail)};var vs=Pt,$d=G1,W1=rc;function rc(i,e,t){vs.ok(this instanceof rc,"ChooComponentCache should be created with `new`"),vs.equal(typeof i,"object","ChooComponentCache: state should be type object"),vs.equal(typeof e,"function","ChooComponentCache: emit should be type function"),typeof t=="number"?this.cache=new $d(t):this.cache=t||new $d(100),this.state=i,this.emit=e}rc.prototype.render=function(i,e){vs.equal(typeof i,"function","ChooComponentCache.render: Component should be type function"),vs.ok(typeof e=="string"||typeof e=="number","ChooComponentCache.render: id should be type string or type number");var t=this.cache.get(e);if(!t){for(var n=[],r=2,s=arguments.length;r is not the same type as the new node <"+n.nodeName.toLowerCase()+">.");var r=Qi("choo.morph");pO(e._tree,n),r(),t()})),dO(function(){e.emitter.emit(e._events.DOMCONTENTLOADED),e._loaded=!0}),i(),this._tree};ui.prototype.mount=function(e){var t=Qi("choo.mount('"+e+"')");if(typeof window!="object")return ze.ok(typeof e=="string","choo.mount: selector should be type String"),this.selector=e,t(),this;ze.ok(typeof e=="string"||typeof e=="object","choo.mount: selector should be type String or HTMLElement");var n=this;dO(function(){var r=Qi("choo.render"),s=n.start();typeof e=="string"?n._tree=document.querySelector(e):n._tree=e,ze.ok(n._tree,"choo.mount: could not query selector: "+e),ze.equal(n._tree.nodeName,s.nodeName,"choo.mount: The target node <"+n._tree.nodeName.toLowerCase()+"> is not the same type as the new node <"+s.nodeName.toLowerCase()+">.");var o=Qi("choo.morph");pO(n._tree,s),o(),r()}),t()};ui.prototype.toString=function(i,e){e=e||{},e.components=e.components||{},e.events=Object.assign({},e.events,this._events),ze.notEqual(typeof window,"object","choo.mount: window was found. .toString() must be called in Node, use .start() or .mount() if running in the browser"),ze.equal(typeof i,"string","choo.toString: location should be type string"),ze.equal(typeof e,"object","choo.toString: state should be type object"),this._setCache(e),this._matchRoute(e,i),this.emitter.removeAllListeners(),this._stores.forEach(function(n){n(e)});var t=this._prerender(e);return ze.ok(t,"choo.toString: no valid value returned for the route "+i),ze(!Array.isArray(t),"choo.toString: return value was an array for the route "+i),typeof t.outerHTML=="string"?t.outerHTML:t.toString()};ui.prototype._matchRoute=function(i,e){var t,n;e?(t=e.replace(/\?.+$/,"").replace(/\/$/,""),this._hashEnabled||(t=t.replace(/#.+$/,"")),n=e):(t=window.location.pathname.replace(/\/$/,""),this._hashEnabled&&(t+=window.location.hash.replace(/^#/,"/")),n=window.location.search);var r=this.router.match(t);this._handler=r.cb,i.href=t,i.query=z1(n),i.route=r.route,i.params=r.params};ui.prototype._prerender=function(i){var e=Qi("choo.prerender('"+i.route+"')"),t=this._handler(i,this.emit);return e(),t};ui.prototype._setCache=function(i){var e=new H1(i,this.emitter.emit.bind(this.emitter),this._cache);i.cache=t;function t(n,r){ze.equal(typeof n,"function","choo.state.cache: Component should be type function");for(var s=[],o=0,a=arguments.length;o{Ai=i},ca=(i,e="")=>{console.log("logging",i,e),Ai&&(Ai.innerHTML=` >> ${i} `)},nx=()=>{Ai&&(Ai.style.display="none")},rx=()=>{Ai&&(Ai.style.display="block")},sx=()=>{Ai.style.display=="none"?Ai.style.display="block":Ai.style.display="none"},ox={init:ix,log:ca,hide:nx,show:rx,toggle:sx},ax={eval:(i,e)=>{var t=`(async() => { +`,o+1);r=r.substring(a+1)}this.stack=r}}};ni.inherits(Me.AssertionError,Error);function hd(i,e){return typeof i=="string"?i.length=0;u--)if(o[u]!==a[u])return!1;for(u=o.length-1;u>=0;u--)if(l=o[u],!Sr(i[l],e[l],t,n))return!1;return!0}Me.notDeepEqual=function(e,t,n){Sr(e,t,!1)&&Rt(e,t,n,"notDeepEqual",Me.notDeepEqual)};Me.notDeepStrictEqual=Uy;function Uy(i,e,t){Sr(i,e,!0)&&Rt(i,e,t,"notDeepStrictEqual",Uy)}Me.strictEqual=function(e,t,n){e!==t&&Rt(e,t,n,"===",Me.strictEqual)};Me.notStrictEqual=function(e,t,n){e===t&&Rt(e,t,n,"!==",Me.notStrictEqual)};function dd(i,e){if(!i||!e)return!1;if(Object.prototype.toString.call(e)=="[object RegExp]")return e.test(i);try{if(i instanceof e)return!0}catch{}return Error.isPrototypeOf(e)?!1:e.call({},i)===!0}function uv(i){var e;try{i()}catch(t){e=t}return e}function $y(i,e,t,n){var r;if(typeof e!="function")throw new TypeError('"block" argument must be a function');typeof t=="string"&&(n=t,t=null),r=uv(e),n=(t&&t.name?" ("+t.name+").":".")+(n?" "+n:"."),i&&!r&&Rt(r,t,"Missing expected exception"+n);var s=typeof n=="string",o=!i&&ni.isError(r),a=!i&&r&&!t;if((o&&s&&dd(r,t)||a)&&Rt(r,t,"Got unwanted exception"+n),i&&r&&t&&!dd(r,t)||!i&&r)throw r}Me.throws=function(i,e,t){$y(!0,i,e,t)};Me.doesNotThrow=function(i,e,t){$y(!1,i,e,t)};Me.ifError=function(i){if(i)throw i};function Py(i,e){i||Rt(i,!0,e,"==",Py)}Me.strict=rv(Py,Me,{equal:Me.strictEqual,deepEqual:Me.deepStrictEqual,notEqual:Me.notStrictEqual,notDeepEqual:Me.notDeepStrictEqual});Me.strict.strict=Me.strict;var pd=Object.keys||function(i){var e=[];for(var t in i)sv.call(i,t)&&e.push(t);return e},Jy=Cy.exports,hv=Jy,fv={trace:"🔍",debug:"🐛",info:"✨",warn:"⚠️",error:"🚨",fatal:"💀"},Iy={trace:10,debug:20,info:30,warn:40,error:50,fatal:60},cv={foreground:"#d3c0c8",background:"#2d2d2d",black:"#2d2d2d",red:"#f2777a",green:"#99cc99",yellow:"#ffcc66",blue:"#6699cc",magenta:"#cc99cc",cyan:"#66cccc",white:"#d3d0c8",brightBlack:"#747369"},dv=Ri;function Ri(i,e){if(e=e||{},!(this instanceof Ri))return new Ri(i,e);hv.equal(typeof e,"object","nanologger: opts should be type object"),this._name=i||"",this._colors=Object.assign({},cv,e.colors||{});try{this.logLevel=window.localStorage.getItem("logLevel")||"info"}catch{this.logLevel="info"}this._logLevel=Iy[this.logLevel]}Ri.prototype.trace=function(){for(var i=["trace"],e=0,t=arguments.length;e"u"&&(n=Ly()),yh(i,"",0,[],void 0,0,n);var r;try{Mn.length===0?r=JSON.stringify(i,e,t):r=JSON.stringify(i,Dy(e),t)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;Pn.length!==0;){var s=Pn.pop();s.length===4?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return r}function dr(i,e,t,n){var r=Object.getOwnPropertyDescriptor(n,t);r.get!==void 0?r.configurable?(Object.defineProperty(n,t,{value:i}),Pn.push([n,t,e,r])):Mn.push([e,t,i]):(n[t]=i,Pn.push([n,t,e]))}function yh(i,e,t,n,r,s,o){s+=1;var a;if(typeof i=="object"&&i!==null){for(a=0;ao.depthLimit){dr(Sa,i,e,r);return}if(typeof o.edgesLimit<"u"&&t+1>o.edgesLimit){dr(Sa,i,e,r);return}if(n.push(i),Array.isArray(i))for(a=0;ae?1:0}function jy(i,e,t,n){typeof n>"u"&&(n=Ly());var r=Oh(i,"",0,[],void 0,0,n)||i,s;try{Mn.length===0?s=JSON.stringify(r,e,t):s=JSON.stringify(r,Dy(e),t)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;Pn.length!==0;){var o=Pn.pop();o.length===4?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return s}function Oh(i,e,t,n,r,s,o){s+=1;var a;if(typeof i=="object"&&i!==null){for(a=0;ao.depthLimit){dr(Sa,i,e,r);return}if(typeof o.edgesLimit<"u"&&t+1>o.edgesLimit){dr(Sa,i,e,r);return}if(n.push(i),Array.isArray(i))for(a=0;a0)for(var n=0;n"u"&&(p=!0),typeof v>"u"&&(v=1/0);function S(T,k){if(T===null)return null;if(k===0)return T;var Q,C;if(typeof T!="object")return T;if(t(T,n))Q=new n;else if(t(T,r))Q=new r;else if(t(T,s))Q=new s(function(R,N){T.then(function(Y){R(S(Y,k-1))},function(Y){N(S(Y,k-1))})});else if(o.__isArray(T))Q=[];else if(o.__isRegExp(T))Q=new RegExp(T.source,f(T)),T.lastIndex&&(Q.lastIndex=T.lastIndex);else if(o.__isDate(T))Q=new Date(T.getTime());else{if(A&&Buffer.isBuffer(T))return Buffer.allocUnsafe?Q=Buffer.allocUnsafe(T.length):Q=new Buffer(T.length),T.copy(Q),Q;t(T,Error)?Q=Object.create(T):typeof x>"u"?(C=Object.getPrototypeOf(T),Q=Object.create(C)):(Q=Object.create(x),C=x)}if(p){var I=d.indexOf(T);if(I!=-1)return b[I];d.push(T),b.push(Q)}t(T,n)&&T.forEach(function(R,N){var Y=S(N,k-1),te=S(R,k-1);Q.set(Y,te)}),t(T,r)&&T.forEach(function(R){var N=S(R,k-1);Q.add(N)});for(var _ in T){var j;C&&(j=Object.getOwnPropertyDescriptor(C,_)),!(j&&j.set==null)&&(Q[_]=S(T[_],k-1))}if(Object.getOwnPropertySymbols)for(var D=Object.getOwnPropertySymbols(T),_=0;_"u")throw new Error("document-ready only runs in the browser");var e=document.readyState;if(e==="complete"||e==="interactive")return setTimeout(i,0);document.addEventListener("DOMContentLoaded",function(){i()})}var Ny=io(),Av=Dt,Yi;gl.disabled=!0;try{Yi=window.performance,gl.disabled=window.localStorage.DISABLE_NANOTIMING==="true"||!Yi.mark}catch{}var Wf=gl;function gl(i){if(Av.equal(typeof i,"string","nanotiming: name should be type string"),gl.disabled)return Rv;var e=(Yi.now()*1e4).toFixed()%Number.MAX_SAFE_INTEGER,t="start-"+e+"-"+i;Yi.mark(t);function n(r){var s="end-"+e+"-"+i;Yi.mark(s),Ny.push(function(){var o=null;try{var a=i+" ["+e+"]";Yi.measure(a,t,s),Yi.clearMarks(t),Yi.clearMarks(s)}catch(l){o=l}r&&r(o,i)})}return n.uuid=e,n}function Rv(i){i&&Ny.push(function(){i(new Error("nanotiming: performance API unavailable"))})}var xa=Dt,Uv=xr;function xr(){if(!(this instanceof xr))return new xr;this.trie={nodes:{}}}xr.prototype.create=function(i){xa.equal(typeof i,"string","route should be a string");var e=i.replace(/^\//,"").split("/");function t(n,r){var s=aa(e,n)&&e[n];if(s===!1)return r;var o=null;return/^:|^\*/.test(s)?(aa(r.nodes,"$$")?o=r.nodes.$$:(o={nodes:{}},r.nodes.$$=o),s[0]==="*"&&(r.wildcard=!0),r.name=s.replace(/^:|^\*/,"")):aa(r.nodes,s)?o=r.nodes[s]:(o={nodes:{}},r.nodes[s]=o),t(n+1,o)}return t(0,this.trie)};xr.prototype.match=function(i){xa.equal(typeof i,"string","route should be a string");var e=i.replace(/^\//,"").split("/"),t={};function n(s,o){if(o!==void 0){var a=e[s];if(a===void 0)return o;if(aa(o.nodes,a))return n(s+1,o.nodes[a]);if(o.name){try{t[o.name]=decodeURIComponent(a)}catch{return n(s,void 0)}return n(s+1,o.nodes.$$)}else if(o.wildcard){try{t.wildcard=decodeURIComponent(e.slice(s).join("/"))}catch{return n(s,void 0)}return o.nodes.$$}else return n(s+1)}}var r=n(0,this.trie);if(r)return r=Object.assign({},r),r.params=t,r};xr.prototype.mount=function(i,e){xa.equal(typeof i,"string","route should be a string"),xa.equal(typeof e,"object","trie should be a object");var t=i.replace(/^\//,"").split("/"),n=null,r=null;if(t.length===1)r=t[0],n=this.create(r);else{var s=t.join("/");r=t[0],n=this.create(s)}Object.assign(n.nodes,e.nodes),e.name&&(n.name=e.name),n.nodes[""]&&(Object.keys(n.nodes[""]).forEach(function(o){o!=="nodes"&&(n[o]=n.nodes[""][o])}),Object.assign(n.nodes,n.nodes[""].nodes),delete n.nodes[""].nodes)};function aa(i,e){return Object.prototype.hasOwnProperty.call(i,e)}var Wl=Dt,$v=Uv,Pv=_h;function _h(i){if(!(this instanceof _h))return new _h(i);var e=(i||"").replace(/^\//,""),t=$v();return r._trie=t,r.on=n,r.emit=r,r.match=s,r._wayfarer=!0,r;function n(a,l){if(Wl.equal(typeof a,"string"),Wl.equal(typeof l,"function"),a=a||"/",l._wayfarer&&l._trie)t.mount(a,l._trie.trie);else{var u=t.create(a);u.cb=l,u.route=a}return r}function r(a){var l=s(a),u=new Array(arguments.length);u[0]=l.params;for(var h=1;h=0;--u)l=n[u],a=l.name,r=l.namespaceURI,s=l.value,r?(a=l.localName||a,o=e.getAttributeNS(r,a),o!==s&&e.setAttributeNS(r,a,s)):e.hasAttribute(a)?(o=e.getAttribute(a),o!==s&&(s==="null"||s==="undefined"?e.removeAttribute(a):e.setAttribute(a,s))):e.setAttribute(a,s);for(var h=t.length-1;h>=0;--h)l=t[h],l.specified!==!1&&(a=l.name,r=l.namespaceURI,r?(a=l.localName||a,i.hasAttributeNS(r,a)||e.removeAttributeNS(r,a)):i.hasAttributeNS(null,a)||e.removeAttribute(a))}function eS(i,e){for(var t=0;t"u","nanoraf: raf should be a function or undefined"),e||(e=window.requestAnimationFrame);var t=!1,n=null;return function(){n===null&&!t&&(t=!0,e(function(){t=!1;for(var o=n.length,a=new Array(o),l=0;l=s||n===0)){n=t+n>s?s-t:n;var o=s-n;for(r=t;r0&&this._emit(this._listeners[i],e),this._starListeners.length>0&&this._emit(this._starListeners,i,e,r.uuid),r(),this};jt.prototype.on=jt.prototype.addListener=function(i,e){return ai.ok(typeof i=="string"||typeof i=="symbol","nanobus.on: eventName should be type string or symbol"),ai.equal(typeof e,"function","nanobus.on: listener should be type function"),i==="*"?this._starListeners.push(e):(this._listeners[i]||(this._listeners[i]=[]),this._listeners[i].push(e)),this};jt.prototype.prependListener=function(i,e){return ai.ok(typeof i=="string"||typeof i=="symbol","nanobus.prependListener: eventName should be type string or symbol"),ai.equal(typeof e,"function","nanobus.prependListener: listener should be type function"),i==="*"?this._starListeners.unshift(e):(this._listeners[i]||(this._listeners[i]=[]),this._listeners[i].unshift(e)),this};jt.prototype.once=function(i,e){ai.ok(typeof i=="string"||typeof i=="symbol","nanobus.once: eventName should be type string or symbol"),ai.equal(typeof e,"function","nanobus.once: listener should be type function");var t=this;this.on(i,n);function n(){e.apply(t,arguments),t.removeListener(i,n)}return this};jt.prototype.prependOnceListener=function(i,e){ai.ok(typeof i=="string"||typeof i=="symbol","nanobus.prependOnceListener: eventName should be type string or symbol"),ai.equal(typeof e,"function","nanobus.prependOnceListener: listener should be type function");var t=this;this.prependListener(i,n);function n(){e.apply(t,arguments),t.removeListener(i,n)}return this};jt.prototype.removeListener=function(i,e){if(ai.ok(typeof i=="string"||typeof i=="symbol","nanobus.removeListener: eventName should be type string or symbol"),ai.equal(typeof e,"function","nanobus.removeListener: listener should be type function"),i==="*")return this._starListeners=this._starListeners.slice(),t(this._starListeners,e);return typeof this._listeners[i]<"u"&&(this._listeners[i]=this._listeners[i].slice()),t(this._listeners[i],e);function t(n,r){if(n){var s=n.indexOf(r);if(s!==-1)return OS(n,s,1),!0}}};jt.prototype.removeAllListeners=function(i){return i?i==="*"?this._starListeners=[]:this._listeners[i]=[]:(this._starListeners=[],this._listeners={}),this};jt.prototype.listeners=function(i){var e=i!=="*"?this._listeners[i]:this._starListeners,t=[];if(e)for(var n=e.length,r=0;r"u")&&i.length!==0){t===void 0&&(t=e,e=null),e&&(n!==void 0?t=[e].concat(t,n):t=[e].concat(t));for(var r=i.length,s=0;sthis.maxAge?(this.remove(i),!1):!0};Wt.prototype.get=function(i){if(typeof i!="string"&&(i=""+i),!!this.cache.hasOwnProperty(i)){var e=this.cache[i];if(this._checkAge(i,e))return this.head!==i&&(i===this.tail?(this.tail=e.next,this.cache[this.tail].prev=null):this.cache[e.prev].next=e.next,this.cache[e.next].prev=e.prev,this.cache[this.head].next=i,e.prev=this.head,e.next=null,this.head=i),e.value}};Wt.prototype.evict=function(){this.tail&&this.remove(this.tail)};var _s=Dt,_d=bS,vS=zf;function zf(i,e,t){_s.ok(this instanceof zf,"ChooComponentCache should be created with `new`"),_s.equal(typeof i,"object","ChooComponentCache: state should be type object"),_s.equal(typeof e,"function","ChooComponentCache: emit should be type function"),typeof t=="number"?this.cache=new _d(t):this.cache=t||new _d(100),this.state=i,this.emit=e}zf.prototype.render=function(i,e){_s.equal(typeof i,"function","ChooComponentCache.render: Component should be type function"),_s.ok(typeof e=="string"||typeof e=="number","ChooComponentCache.render: id should be type string or type number");var t=this.cache.get(e);if(!t){for(var n=[],r=2,s=arguments.length;r is not the same type as the new node <"+n.nodeName.toLowerCase()+">.");var r=Ei("choo.morph");Vy(e._tree,n),r(),t()})),zy(function(){e.emitter.emit(e._events.DOMCONTENTLOADED),e._loaded=!0}),i(),this._tree};li.prototype.mount=function(e){var t=Ei("choo.mount('"+e+"')");if(typeof window!="object")return ze.ok(typeof e=="string","choo.mount: selector should be type String"),this.selector=e,t(),this;ze.ok(typeof e=="string"||typeof e=="object","choo.mount: selector should be type String or HTMLElement");var n=this;zy(function(){var r=Ei("choo.render"),s=n.start();typeof e=="string"?n._tree=document.querySelector(e):n._tree=e,ze.ok(n._tree,"choo.mount: could not query selector: "+e),ze.equal(n._tree.nodeName,s.nodeName,"choo.mount: The target node <"+n._tree.nodeName.toLowerCase()+"> is not the same type as the new node <"+s.nodeName.toLowerCase()+">.");var o=Ei("choo.morph");Vy(n._tree,s),o(),r()}),t()};li.prototype.toString=function(i,e){e=e||{},e.components=e.components||{},e.events=Object.assign({},e.events,this._events),ze.notEqual(typeof window,"object","choo.mount: window was found. .toString() must be called in Node, use .start() or .mount() if running in the browser"),ze.equal(typeof i,"string","choo.toString: location should be type string"),ze.equal(typeof e,"object","choo.toString: state should be type object"),this._setCache(e),this._matchRoute(e,i),this.emitter.removeAllListeners(),this._stores.forEach(function(n){n(e)});var t=this._prerender(e);return ze.ok(t,"choo.toString: no valid value returned for the route "+i),ze(!Array.isArray(t),"choo.toString: return value was an array for the route "+i),typeof t.outerHTML=="string"?t.outerHTML:t.toString()};li.prototype._matchRoute=function(i,e){var t,n;e?(t=e.replace(/\?.+$/,"").replace(/\/$/,""),this._hashEnabled||(t=t.replace(/#.+$/,"")),n=e):(t=window.location.pathname.replace(/\/$/,""),this._hashEnabled&&(t+=window.location.hash.replace(/^#/,"/")),n=window.location.search);var r=this.router.match(t);this._handler=r.cb,i.href=t,i.query=xS(n),i.route=r.route,i.params=r.params};li.prototype._prerender=function(i){var e=Ei("choo.prerender('"+i.route+"')"),t=this._handler(i,this.emit);return e(),t};li.prototype._setCache=function(i){var e=new CS(i,this.emitter.emit.bind(this.emitter),this._cache);i.cache=t;function t(n,r){ze.equal(typeof n,"function","choo.state.cache: Component should be type function");for(var s=[],o=0,a=arguments.length;o{})=>{const t={isError:!1,codeString:"",errorMessage:""};var n=`(async() => { ${i} -})().catch(${r=>ca(r.message,"log-error")})`,n=!1;try{window.eval(t),ca("")}catch(r){n=!0,console.log("logging",r),ca(r.message,"log-error")}e&&e(t,n)}};function lx(i,e){i.showInfo=!1,i.showUI=!0,i.showExtensions=!1;const t="https://api.hydrasynth.xyz";i.serverURL=t,e.on("load and eval code",(r,s=!0)=>{e.emit("editor: load code",r),e.emit("repl: eval",r),s&&e.emit("gallery: save to URL",r)}),e.on("repl: eval",(r="",s)=>{ax.eval(r,s)}),e.on("screencap",()=>{screencap();const s=i.editor.editor.getValue(),o=new Blob([s],{type:"text/plain"}),a=document.createElement("a");a.style.display="none";let l=new Date;a.download=`hydra-${l.getFullYear()}-${l.getMonth()+1}-${l.getDate()}-${l.getHours()}.${l.getMinutes()}.${l.getSeconds()}.js`,a.href=URL.createObjectURL(o),a.click(),setTimeout(()=>{window.URL.revokeObjectURL(a.href)},300)});function n(){const r=i.editor.editor;hush(),speed=1,e.emit("gallery: clear"),r.clear()}e.on("clear all",()=>{n()}),e.on("ui: hide all",function(){i.showUI=!i.showUI,e.emit("render")}),e.on("ui: toggle info",function(r){i.showInfo?e.emit("ui: hide info"):e.emit("ui: show info")}),e.on("ui: show info",()=>{i.showInfo=!0,e.emit("render")}),e.on("ui: hide info",()=>{i.showInfo=!1,i.showExtensions=!1,e.emit("render")}),e.on("ui: show extensions",()=>{i.showExtensions=!0,i.showInfo=!0,e.emit("extensions: select category"),e.emit("render")}),e.on("ui: hide extensions",()=>{i.showExtensions=!1,e.emit("render")})}function oi(i){"@babel/helpers - typeof";return oi=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},oi(i)}function hi(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function ux(i,e){if(oi(i)!=="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(oi(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function gO(i){var e=ux(i,"string");return oi(e)==="symbol"?e:String(e)}function Bd(i,e){for(var t=0;ti.length)&&(e=i.length);for(var t=0,n=new Array(e);t1&&arguments[1]!==void 0?arguments[1]:{};hi(this,i),this.init(e,t)}return fi(i,[{key:"init",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=n.prefix||"i18next:",this.logger=t||gx,this.options=n,this.debug=n.debug}},{key:"setDebug",value:function(t){this.debug=t}},{key:"log",value:function(){for(var t=arguments.length,n=new Array(t),r=0;r1?n-1:0),s=1;s-1?a.replace(/###/g,"."):a}function r(){return!i||typeof i=="string"}for(var s=typeof e!="string"?[].concat(e):e.split(".");s.length>1;){if(r())return{};var o=n(s.shift());!i[o]&&t&&(i[o]=new t),Object.prototype.hasOwnProperty.call(i,o)?i=i[o]:i={}}return r()?{}:{obj:i,k:n(s.shift())}}function Zd(i,e,t){var n=sc(i,e,Object),r=n.obj,s=n.k;r[s]=t}function Ox(i,e,t,n){var r=sc(i,e,Object),s=r.obj,o=r.k;s[o]=s[o]||[],n&&(s[o]=s[o].concat(t)),n||s[o].push(t)}function Ea(i,e){var t=sc(i,e),n=t.obj,r=t.k;if(n)return n[r]}function Fd(i,e,t){var n=Ea(i,t);return n!==void 0?n:Ea(e,t)}function mO(i,e,t){for(var n in e)n!=="__proto__"&&n!=="constructor"&&(n in i?typeof i[n]=="string"||i[n]instanceof String||typeof e[n]=="string"||e[n]instanceof String?t&&(i[n]=e[n]):mO(i[n],e[n],t):i[n]=e[n]);return i}function zn(i){return i.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var _x={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function wx(i){return typeof i=="string"?i.replace(/[&<>"'\/]/g,function(e){return _x[e]}):i}var vl=typeof window<"u"&&window.navigator&&typeof window.navigator.userAgentData>"u"&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,bx=[" ",",","?","!",";"];function vx(i,e,t){e=e||"",t=t||"";var n=bx.filter(function(a){return e.indexOf(a)<0&&t.indexOf(a)<0});if(n.length===0)return!0;var r=new RegExp("(".concat(n.map(function(a){return a==="?"?"\\?":a}).join("|"),")")),s=!r.test(i);if(!s){var o=i.indexOf(t);o>0&&!r.test(i.substring(0,o))&&(s=!0)}return s}function Xd(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function _o(i){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function yO(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(i){if(i[e])return i[e];for(var n=e.split(t),r=i,s=0;ss+o;)o++,a=n.slice(s,s+o).join(t),l=r[a];if(l===void 0)return;if(l===null)return null;if(e.endsWith(a)){if(typeof l=="string")return l;if(a&&typeof l[a]=="string")return l[a]}var u=n.slice(s+o).join(t);return u?yO(l,u,t):void 0}r=r[n[s]]}return r}}var kx=function(i){bl(t,i);var e=Sx(t);function t(n){var r,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};return hi(this,t),r=e.call(this),vl&&cn.call(un(r)),r.data=n||{},r.options=s,r.options.keySeparator===void 0&&(r.options.keySeparator="."),r.options.ignoreJSONStructure===void 0&&(r.options.ignoreJSONStructure=!0),r}return fi(t,[{key:"addNamespaces",value:function(r){this.options.ns.indexOf(r)<0&&this.options.ns.push(r)}},{key:"removeNamespaces",value:function(r){var s=this.options.ns.indexOf(r);s>-1&&this.options.ns.splice(s,1)}},{key:"getResource",value:function(r,s,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},l=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,u=a.ignoreJSONStructure!==void 0?a.ignoreJSONStructure:this.options.ignoreJSONStructure,h=[r,s];o&&typeof o!="string"&&(h=h.concat(o)),o&&typeof o=="string"&&(h=h.concat(l?o.split(l):o)),r.indexOf(".")>-1&&(h=r.split("."));var f=Ea(this.data,h);return f||!u||typeof o!="string"?f:yO(this.data&&this.data[r]&&this.data[r][s],o,l)}},{key:"addResource",value:function(r,s,o,a){var l=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1},u=this.options.keySeparator;u===void 0&&(u=".");var h=[r,s];o&&(h=h.concat(u?o.split(u):o)),r.indexOf(".")>-1&&(h=r.split("."),a=s,s=h[1]),this.addNamespaces(s),Zd(this.data,h,a),l.silent||this.emit("added",r,s,o,a)}},{key:"addResources",value:function(r,s,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(var l in o)(typeof o[l]=="string"||Object.prototype.toString.apply(o[l])==="[object Array]")&&this.addResource(r,s,l,o[l],{silent:!0});a.silent||this.emit("added",r,s,o)}},{key:"addResourceBundle",value:function(r,s,o,a,l){var u=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1},h=[r,s];r.indexOf(".")>-1&&(h=r.split("."),a=o,o=s,s=h[1]),this.addNamespaces(s);var f=Ea(this.data,h)||{};a?mO(f,o,l):f=_o(_o({},f),o),Zd(this.data,h,f),u.silent||this.emit("added",r,s,o)}},{key:"removeResourceBundle",value:function(r,s){this.hasResourceBundle(r,s)&&delete this.data[r][s],this.removeNamespaces(s),this.emit("removed",r,s)}},{key:"hasResourceBundle",value:function(r,s){return this.getResource(r,s)!==void 0}},{key:"getResourceBundle",value:function(r,s){return s||(s=this.options.defaultNS),this.options.compatibilityAPI==="v1"?_o(_o({},{}),this.getResource(r,s)):this.getResource(r,s)}},{key:"getDataByLanguage",value:function(r){return this.data[r]}},{key:"hasLanguageSomeTranslations",value:function(r){var s=this.getDataByLanguage(r),o=s&&Object.keys(s)||[];return!!o.find(function(a){return s[a]&&Object.keys(s[a]).length>0})}},{key:"toJSON",value:function(){return this.data}}]),t}(cn),OO={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,n,r,s){var o=this;return e.forEach(function(a){o.processors[a]&&(t=o.processors[a].process(t,n,r,s))}),t}};function Gd(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function St(i){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Wd={},Yd=function(i){bl(t,i);var e=Mx(t);function t(n){var r,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return hi(this,t),r=e.call(this),vl&&cn.call(un(r)),yx(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],n,un(r)),r.options=s,r.options.keySeparator===void 0&&(r.options.keySeparator="."),r.logger=Mi.create("translator"),r}return fi(t,[{key:"changeLanguage",value:function(r){r&&(this.language=r)}},{key:"exists",value:function(r){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(r==null)return!1;var o=this.resolve(r,s);return o&&o.res!==void 0}},{key:"extractFromKey",value:function(r,s){var o=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;o===void 0&&(o=":");var a=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,l=s.ns||this.options.defaultNS||[],u=o&&r.indexOf(o)>-1,h=!this.options.userDefinedKeySeparator&&!s.keySeparator&&!this.options.userDefinedNsSeparator&&!s.nsSeparator&&!vx(r,o,a);if(u&&!h){var f=r.match(this.interpolator.nestingRegexp);if(f&&f.length>0)return{key:r,namespaces:l};var c=r.split(o);(o!==a||o===a&&this.options.ns.indexOf(c[0])>-1)&&(l=c.shift()),r=c.join(a)}return typeof l=="string"&&(l=[l]),{key:r,namespaces:l}}},{key:"translate",value:function(r,s,o){var a=this;if(oi(s)!=="object"&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),s||(s={}),r==null)return"";Array.isArray(r)||(r=[String(r)]);var l=s.returnDetails!==void 0?s.returnDetails:this.options.returnDetails,u=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,h=this.extractFromKey(r[r.length-1],s),f=h.key,c=h.namespaces,p=c[c.length-1],v=s.lng||this.language,x=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(v&&v.toLowerCase()==="cimode"){if(x){var m=s.nsSeparator||this.options.nsSeparator;return l?(d.res="".concat(p).concat(m).concat(f),d):"".concat(p).concat(m).concat(f)}return l?(d.res=f,d):f}var d=this.resolve(r,s),b=d&&d.res,A=d&&d.usedKey||f,S=d&&d.exactUsedKey||f,T=Object.prototype.toString.apply(b),k=["[object Number]","[object Function]","[object RegExp]"],Q=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,C=!this.i18nFormat||this.i18nFormat.handleAsObject,I=typeof b!="string"&&typeof b!="boolean"&&typeof b!="number";if(C&&b&&I&&k.indexOf(T)<0&&!(typeof Q=="string"&&T==="[object Array]")){if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var _=this.options.returnedObjectHandler?this.options.returnedObjectHandler(A,b,St(St({},s),{},{ns:c})):"key '".concat(f," (").concat(this.language,")' returned an object instead of string.");return l?(d.res=_,d):_}if(u){var j=T==="[object Array]",D=j?[]:{},V=j?S:A;for(var ee in b)if(Object.prototype.hasOwnProperty.call(b,ee)){var B="".concat(V).concat(u).concat(ee);D[ee]=this.translate(B,St(St({},s),{joinArrays:!1,ns:c})),D[ee]===B&&(D[ee]=b[ee])}b=D}}else if(C&&typeof Q=="string"&&T==="[object Array]")b=b.join(Q),b&&(b=this.extendTranslation(b,r,s,o));else{var Z=!1,R=!1,N=s.count!==void 0&&typeof s.count!="string",Y=t.hasDefaultValue(s),te=N?this.pluralResolver.getSuffix(v,s.count,s):"",se=s["defaultValue".concat(te)]||s.defaultValue;!this.isValidLookup(b)&&Y&&(Z=!0,b=se),this.isValidLookup(b)||(R=!0,b=f);var le=s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey,ue=le&&R?void 0:b,de=Y&&se!==b&&this.options.updateMissing;if(R||Z||de){if(this.logger.log(de?"updateKey":"missingKey",v,p,f,de?se:b),u){var Qe=this.resolve(f,St(St({},s),{},{keySeparator:!1}));Qe&&Qe.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var W=[],G=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&G&&G[0])for(var ne=0;ne1&&arguments[1]!==void 0?arguments[1]:{},a,l,u,h,f;return typeof r=="string"&&(r=[r]),r.forEach(function(c){if(!s.isValidLookup(a)){var p=s.extractFromKey(c,o),v=p.key;l=v;var x=p.namespaces;s.options.fallbackNS&&(x=x.concat(s.options.fallbackNS));var m=o.count!==void 0&&typeof o.count!="string",d=m&&!o.ordinal&&o.count===0&&s.pluralResolver.shouldUseIntlApi(),b=o.context!==void 0&&(typeof o.context=="string"||typeof o.context=="number")&&o.context!=="",A=o.lngs?o.lngs:s.languageUtils.toResolveHierarchy(o.lng||s.language,o.fallbackLng);x.forEach(function(S){s.isValidLookup(a)||(f=S,!Wd["".concat(A[0],"-").concat(S)]&&s.utils&&s.utils.hasLoadedNamespace&&!s.utils.hasLoadedNamespace(f)&&(Wd["".concat(A[0],"-").concat(S)]=!0,s.logger.warn('key "'.concat(l,'" for languages "').concat(A.join(", "),`" won't get resolved as namespace "`).concat(f,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),A.forEach(function(T){if(!s.isValidLookup(a)){h=T;var k=[v];if(s.i18nFormat&&s.i18nFormat.addLookupKeys)s.i18nFormat.addLookupKeys(k,v,T,S,o);else{var Q;m&&(Q=s.pluralResolver.getSuffix(T,o.count,o));var C="".concat(s.options.pluralSeparator,"zero");if(m&&(k.push(v+Q),d&&k.push(v+C)),b){var I="".concat(v).concat(s.options.contextSeparator).concat(o.context);k.push(I),m&&(k.push(I+Q),d&&k.push(I+C))}}for(var _;_=k.pop();)s.isValidLookup(a)||(u=_,a=s.getResource(T,S,_,o))}}))})}}),{res:a,usedKey:l,exactUsedKey:u,usedLng:h,usedNS:f}}},{key:"isValidLookup",value:function(r){return r!==void 0&&!(!this.options.returnNull&&r===null)&&!(!this.options.returnEmptyString&&r==="")}},{key:"getResource",value:function(r,s,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(r,s,o,a):this.resourceStore.getResource(r,s,o,a)}}],[{key:"hasDefaultValue",value:function(r){var s="defaultValue";for(var o in r)if(Object.prototype.hasOwnProperty.call(r,o)&&s===o.substring(0,s.length)&&r[o]!==void 0)return!0;return!1}}]),t}(cn);function ru(i){return i.charAt(0).toUpperCase()+i.slice(1)}var Cx=function(){function i(e){hi(this,i),this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Mi.create("languageUtils")}return fi(i,[{key:"getScriptPartFromCode",value:function(t){if(!t||t.indexOf("-")<0)return null;var n=t.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}},{key:"getLanguagePartFromCode",value:function(t){if(!t||t.indexOf("-")<0)return t;var n=t.split("-");return this.formatLanguageCode(n[0])}},{key:"formatLanguageCode",value:function(t){if(typeof t=="string"&&t.indexOf("-")>-1){var n=["hans","hant","latn","cyrl","cans","mong","arab"],r=t.split("-");return this.options.lowerCaseLng?r=r.map(function(s){return s.toLowerCase()}):r.length===2?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=ru(r[1].toLowerCase()))):r.length===3&&(r[0]=r[0].toLowerCase(),r[1].length===2&&(r[1]=r[1].toUpperCase()),r[0]!=="sgn"&&r[2].length===2&&(r[2]=r[2].toUpperCase()),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=ru(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=ru(r[2].toLowerCase()))),r.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}},{key:"isSupportedCode",value:function(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}},{key:"getBestMatchFromCodes",value:function(t){var n=this;if(!t)return null;var r;return t.forEach(function(s){if(!r){var o=n.formatLanguageCode(s);(!n.options.supportedLngs||n.isSupportedCode(o))&&(r=o)}}),!r&&this.options.supportedLngs&&t.forEach(function(s){if(!r){var o=n.getLanguagePartFromCode(s);if(n.isSupportedCode(o))return r=o;r=n.options.supportedLngs.find(function(a){if(a.indexOf(o)===0)return a})}}),r||(r=this.getFallbackCodes(this.options.fallbackLng)[0]),r}},{key:"getFallbackCodes",value:function(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),typeof t=="string"&&(t=[t]),Object.prototype.toString.apply(t)==="[object Array]")return t;if(!n)return t.default||[];var r=t[n];return r||(r=t[this.getScriptPartFromCode(n)]),r||(r=t[this.formatLanguageCode(n)]),r||(r=t[this.getLanguagePartFromCode(n)]),r||(r=t.default),r||[]}},{key:"toResolveHierarchy",value:function(t,n){var r=this,s=this.getFallbackCodes(n||this.options.fallbackLng||[],t),o=[],a=function(u){u&&(r.isSupportedCode(u)?o.push(u):r.logger.warn("rejecting language code not found in supportedLngs: ".concat(u)))};return typeof t=="string"&&t.indexOf("-")>-1?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(t))):typeof t=="string"&&a(this.formatLanguageCode(t)),s.forEach(function(l){o.indexOf(l)<0&&a(r.formatLanguageCode(l))}),o}}]),i}(),Ex=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],Qx={1:function(e){return+(e>1)},2:function(e){return+(e!=1)},3:function(e){return 0},4:function(e){return e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2},5:function(e){return e==0?0:e==1?1:e==2?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5},6:function(e){return e==1?0:e>=2&&e<=4?1:2},7:function(e){return e==1?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2},8:function(e){return e==1?0:e==2?1:e!=8&&e!=11?2:3},9:function(e){return+(e>=2)},10:function(e){return e==1?0:e==2?1:e<7?2:e<11?3:4},11:function(e){return e==1||e==11?0:e==2||e==12?1:e>2&&e<20?2:3},12:function(e){return+(e%10!=1||e%100==11)},13:function(e){return+(e!==0)},14:function(e){return e==1?0:e==2?1:e==3?2:3},15:function(e){return e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2},16:function(e){return e%10==1&&e%100!=11?0:e!==0?1:2},17:function(e){return e==1||e%10==1&&e%100!=11?0:1},18:function(e){return e==0?0:e==1?1:2},19:function(e){return e==1?0:e==0||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3},20:function(e){return e==1?0:e==0||e%100>0&&e%100<20?1:2},21:function(e){return e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0},22:function(e){return e==1?0:e==2?1:(e<0||e>10)&&e%10==0?2:3}},Ax=["v1","v2","v3"],zd={zero:0,one:1,two:2,few:3,many:4,other:5};function Rx(){var i={};return Ex.forEach(function(e){e.lngs.forEach(function(t){i[t]={numbers:e.nr,plurals:Qx[e.fc]}})}),i}var Ux=function(){function i(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};hi(this,i),this.languageUtils=e,this.options=t,this.logger=Mi.create("pluralResolver"),(!this.options.compatibilityJSON||this.options.compatibilityJSON==="v4")&&(typeof Intl>"u"||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=Rx()}return fi(i,[{key:"addRule",value:function(t,n){this.rules[t]=n}},{key:"getRule",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(t,{type:n.ordinal?"ordinal":"cardinal"})}catch{return}return this.rules[t]||this.rules[this.languageUtils.getLanguagePartFromCode(t)]}},{key:"needsPlural",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.getRule(t,n);return this.shouldUseIntlApi()?r&&r.resolvedOptions().pluralCategories.length>1:r&&r.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(t,r).map(function(s){return"".concat(n).concat(s)})}},{key:"getSuffixes",value:function(t){var n=this,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=this.getRule(t,r);return s?this.shouldUseIntlApi()?s.resolvedOptions().pluralCategories.sort(function(o,a){return zd[o]-zd[a]}).map(function(o){return"".concat(n.options.prepend).concat(o)}):s.numbers.map(function(o){return n.getSuffix(t,o,r)}):[]}},{key:"getSuffix",value:function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=this.getRule(t,r);return s?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(s.select(n)):this.getSuffixRetroCompatible(s,n):(this.logger.warn("no plural rule found for: ".concat(t)),"")}},{key:"getSuffixRetroCompatible",value:function(t,n){var r=this,s=t.noAbs?t.plurals(n):t.plurals(Math.abs(n)),o=t.numbers[s];this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1&&(o===2?o="plural":o===1&&(o=""));var a=function(){return r.options.prepend&&o.toString()?r.options.prepend+o.toString():o.toString()};return this.options.compatibilityJSON==="v1"?o===1?"":typeof o=="number"?"_plural_".concat(o.toString()):a():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1?a():this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString()}},{key:"shouldUseIntlApi",value:function(){return!Ax.includes(this.options.compatibilityJSON)}}]),i}();function Vd(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function qt(i){for(var e=1;e0&&arguments[0]!==void 0?arguments[0]:{};hi(this,i),this.logger=Mi.create("interpolator"),this.options=e,this.format=e.interpolation&&e.interpolation.format||function(t){return t},this.init(e)}return fi(i,[{key:"init",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};t.interpolation||(t.interpolation={escapeValue:!0});var n=t.interpolation;this.escape=n.escape!==void 0?n.escape:wx,this.escapeValue=n.escapeValue!==void 0?n.escapeValue:!0,this.useRawValueToEscape=n.useRawValueToEscape!==void 0?n.useRawValueToEscape:!1,this.prefix=n.prefix?zn(n.prefix):n.prefixEscaped||"{{",this.suffix=n.suffix?zn(n.suffix):n.suffixEscaped||"}}",this.formatSeparator=n.formatSeparator?n.formatSeparator:n.formatSeparator||",",this.unescapePrefix=n.unescapeSuffix?"":n.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":n.unescapeSuffix||"",this.nestingPrefix=n.nestingPrefix?zn(n.nestingPrefix):n.nestingPrefixEscaped||zn("$t("),this.nestingSuffix=n.nestingSuffix?zn(n.nestingSuffix):n.nestingSuffixEscaped||zn(")"),this.nestingOptionsSeparator=n.nestingOptionsSeparator?n.nestingOptionsSeparator:n.nestingOptionsSeparator||",",this.maxReplaces=n.maxReplaces?n.maxReplaces:1e3,this.alwaysFormat=n.alwaysFormat!==void 0?n.alwaysFormat:!1,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var t="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(t,"g");var n="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(n,"g");var r="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(r,"g")}},{key:"interpolate",value:function(t,n,r,s){var o=this,a,l,u,h=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function f(m){return m.replace(/\$/g,"$$$$")}var c=function(d){if(d.indexOf(o.formatSeparator)<0){var b=Fd(n,h,d);return o.alwaysFormat?o.format(b,void 0,r,qt(qt(qt({},s),n),{},{interpolationkey:d})):b}var A=d.split(o.formatSeparator),S=A.shift().trim(),T=A.join(o.formatSeparator).trim();return o.format(Fd(n,h,S),T,r,qt(qt(qt({},s),n),{},{interpolationkey:S}))};this.resetRegExp();var p=s&&s.missingInterpolationHandler||this.options.missingInterpolationHandler,v=s&&s.interpolation&&s.interpolation.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables,x=[{regex:this.regexpUnescape,safeValue:function(d){return f(d)}},{regex:this.regexp,safeValue:function(d){return o.escapeValue?f(o.escape(d)):f(d)}}];return x.forEach(function(m){for(u=0;a=m.regex.exec(t);){var d=a[1].trim();if(l=c(d),l===void 0)if(typeof p=="function"){var b=p(t,a,s);l=typeof b=="string"?b:""}else if(s&&s.hasOwnProperty(d))l="";else if(v){l=a[0];continue}else o.logger.warn("missed to pass in variable ".concat(d," for interpolating ").concat(t)),l="";else typeof l!="string"&&!o.useRawValueToEscape&&(l=Nd(l));var A=m.safeValue(l);if(t=t.replace(a[0],A),v?(m.regex.lastIndex+=l.length,m.regex.lastIndex-=a[0].length):m.regex.lastIndex=0,u++,u>=o.maxReplaces)break}}),t}},{key:"nest",value:function(t,n){var r=this,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o,a,l=qt({},s);l.applyPostProcessor=!1,delete l.defaultValue;function u(p,v){var x=this.nestingOptionsSeparator;if(p.indexOf(x)<0)return p;var m=p.split(new RegExp("".concat(x,"[ ]*{"))),d="{".concat(m[1]);p=m[0],d=this.interpolate(d,l);var b=d.match(/'/g),A=d.match(/"/g);(b&&b.length%2===0&&!A||A.length%2!==0)&&(d=d.replace(/'/g,'"'));try{l=JSON.parse(d),v&&(l=qt(qt({},v),l))}catch(S){return this.logger.warn("failed parsing options string in nesting for key ".concat(p),S),"".concat(p).concat(x).concat(d)}return delete l.defaultValue,p}for(;o=this.nestingRegexp.exec(t);){var h=[],f=!1;if(o[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(o[1])){var c=o[1].split(this.formatSeparator).map(function(p){return p.trim()});o[1]=c.shift(),h=c,f=!0}if(a=n(u.call(this,o[1].trim(),l),l),a&&o[0]===t&&typeof a!="string")return a;typeof a!="string"&&(a=Nd(a)),a||(this.logger.warn("missed to resolve ".concat(o[1]," for nesting ").concat(t)),a=""),f&&(a=h.reduce(function(p,v){return r.format(p,v,s.lng,qt(qt({},s),{},{interpolationkey:o[1].trim()}))},a.trim())),t=t.replace(o[0],a),this.regexp.lastIndex=0}return t}}]),i}();function Kd(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function Yi(i){for(var e=1;e-1){var n=i.split("(");e=n[0].toLowerCase().trim();var r=n[1].substring(0,n[1].length-1);if(e==="currency"&&r.indexOf(":")<0)t.currency||(t.currency=r.trim());else if(e==="relativetime"&&r.indexOf(":")<0)t.range||(t.range=r.trim());else{var s=r.split(";");s.forEach(function(o){if(o){var a=o.split(":"),l=px(a),u=l[0],h=l.slice(1),f=h.join(":").trim().replace(/^'+|'+$/g,"");t[u.trim()]||(t[u.trim()]=f),f==="false"&&(t[u.trim()]=!1),f==="true"&&(t[u.trim()]=!0),isNaN(f)||(t[u.trim()]=parseInt(f,10))}})}}return{formatName:e,formatOptions:t}}function Vn(i){var e={};return function(n,r,s){var o=r+JSON.stringify(s),a=e[o];return a||(a=i(r,s),e[o]=a),a(n)}}var Jx=function(){function i(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};hi(this,i),this.logger=Mi.create("formatter"),this.options=e,this.formats={number:Vn(function(t,n){var r=new Intl.NumberFormat(t,n);return function(s){return r.format(s)}}),currency:Vn(function(t,n){var r=new Intl.NumberFormat(t,Yi(Yi({},n),{},{style:"currency"}));return function(s){return r.format(s)}}),datetime:Vn(function(t,n){var r=new Intl.DateTimeFormat(t,Yi({},n));return function(s){return r.format(s)}}),relativetime:Vn(function(t,n){var r=new Intl.RelativeTimeFormat(t,Yi({},n));return function(s){return r.format(s,n.range||"day")}}),list:Vn(function(t,n){var r=new Intl.ListFormat(t,Yi({},n));return function(s){return r.format(s)}})},this.init(e)}return fi(i,[{key:"init",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}},r=n.interpolation;this.formatSeparator=r.formatSeparator?r.formatSeparator:r.formatSeparator||","}},{key:"add",value:function(t,n){this.formats[t.toLowerCase().trim()]=n}},{key:"addCached",value:function(t,n){this.formats[t.toLowerCase().trim()]=Vn(n)}},{key:"format",value:function(t,n,r,s){var o=this,a=n.split(this.formatSeparator),l=a.reduce(function(u,h){var f=Px(h),c=f.formatName,p=f.formatOptions;if(o.formats[c]){var v=u;try{var x=s&&s.formatParams&&s.formatParams[s.interpolationkey]||{},m=x.locale||x.lng||s.locale||s.lng||r;v=o.formats[c](u,m,Yi(Yi(Yi({},p),s),x))}catch(d){o.logger.warn(d)}return v}else o.logger.warn("there was no format function for ".concat(c));return u},t);return l}}]),i}();function qd(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function Hd(i){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Lx(i,e){i.pending[e]!==void 0&&(delete i.pending[e],i.pendingCount--)}var jx=function(i){bl(t,i);var e=Ix(t);function t(n,r,s){var o,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return hi(this,t),o=e.call(this),vl&&cn.call(un(o)),o.backend=n,o.store=r,o.services=s,o.languageUtils=s.languageUtils,o.options=a,o.logger=Mi.create("backendConnector"),o.waitingReads=[],o.maxParallelReads=a.maxParallelReads||10,o.readingCalls=0,o.maxRetries=a.maxRetries>=0?a.maxRetries:5,o.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,o.state={},o.queue=[],o.backend&&o.backend.init&&o.backend.init(s,a.backend,a),o}return fi(t,[{key:"queueLoad",value:function(r,s,o,a){var l=this,u={},h={},f={},c={};return r.forEach(function(p){var v=!0;s.forEach(function(x){var m="".concat(p,"|").concat(x);!o.reload&&l.store.hasResourceBundle(p,x)?l.state[m]=2:l.state[m]<0||(l.state[m]===1?h[m]===void 0&&(h[m]=!0):(l.state[m]=1,v=!1,h[m]===void 0&&(h[m]=!0),u[m]===void 0&&(u[m]=!0),c[x]===void 0&&(c[x]=!0)))}),v||(f[p]=!0)}),(Object.keys(u).length||Object.keys(h).length)&&this.queue.push({pending:h,pendingCount:Object.keys(h).length,loaded:{},errors:[],callback:a}),{toLoad:Object.keys(u),pending:Object.keys(h),toLoadLanguages:Object.keys(f),toLoadNamespaces:Object.keys(c)}}},{key:"loaded",value:function(r,s,o){var a=r.split("|"),l=a[0],u=a[1];s&&this.emit("failedLoading",l,u,s),o&&this.store.addResourceBundle(l,u,o),this.state[r]=s?-1:2;var h={};this.queue.forEach(function(f){Ox(f.loaded,[l],u),Lx(f,r),s&&f.errors.push(s),f.pendingCount===0&&!f.done&&(Object.keys(f.loaded).forEach(function(c){h[c]||(h[c]={});var p=f.loaded[c];p.length&&p.forEach(function(v){h[c][v]===void 0&&(h[c][v]=!0)})}),f.done=!0,f.errors.length?f.callback(f.errors):f.callback())}),this.emit("loaded",h),this.queue=this.queue.filter(function(f){return!f.done})}},{key:"read",value:function(r,s,o){var a=this,l=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,u=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,h=arguments.length>5?arguments[5]:void 0;if(!r.length)return h(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:r,ns:s,fcName:o,tried:l,wait:u,callback:h});return}return this.readingCalls++,this.backend[o](r,s,function(f,c){if(a.readingCalls--,a.waitingReads.length>0){var p=a.waitingReads.shift();a.read(p.lng,p.ns,p.fcName,p.tried,p.wait,p.callback)}if(f&&c&&l2&&arguments[2]!==void 0?arguments[2]:{},l=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),l&&l();typeof r=="string"&&(r=this.languageUtils.toResolveHierarchy(r)),typeof s=="string"&&(s=[s]);var u=this.queueLoad(r,s,a,l);if(!u.toLoad.length)return u.pending.length||l(),null;u.toLoad.forEach(function(h){o.loadOne(h)})}},{key:"load",value:function(r,s,o){this.prepareLoading(r,s,{},o)}},{key:"reload",value:function(r,s,o){this.prepareLoading(r,s,{reload:!0},o)}},{key:"loadOne",value:function(r){var s=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",a=r.split("|"),l=a[0],u=a[1];this.read(l,u,"read",void 0,void 0,function(h,f){h&&s.logger.warn("".concat(o,"loading namespace ").concat(u," for language ").concat(l," failed"),h),!h&&f&&s.logger.log("".concat(o,"loaded namespace ").concat(u," for language ").concat(l),f),s.loaded(r,h,f)})}},{key:"saveMissing",value:function(r,s,o,a,l){var u=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(s)){this.logger.warn('did not save key "'.concat(o,'" as the namespace "').concat(s,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}o==null||o===""||(this.backend&&this.backend.create&&this.backend.create(r,s,o,a,null,Hd(Hd({},u),{},{isUpdate:l})),!(!r||!r[0])&&this.store.addResource(r[0],s,o,a))}}]),t}(cn);function Dx(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if(oi(e[1])==="object"&&(t=e[1]),typeof e[1]=="string"&&(t.defaultValue=e[1]),typeof e[2]=="string"&&(t.tDescription=e[2]),oi(e[2])==="object"||oi(e[3])==="object"){var n=e[3]||e[2];Object.keys(n).forEach(function(r){t[r]=n[r]})}return t},interpolation:{escapeValue:!0,format:function(e,t,n,r){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function ep(i){return typeof i.ns=="string"&&(i.ns=[i.ns]),typeof i.fallbackLng=="string"&&(i.fallbackLng=[i.fallbackLng]),typeof i.fallbackNS=="string"&&(i.fallbackNS=[i.fallbackNS]),i.supportedLngs&&i.supportedLngs.indexOf("cimode")<0&&(i.supportedLngs=i.supportedLngs.concat(["cimode"])),i}function tp(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function pi(i){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function wo(){}function Fx(i){var e=Object.getOwnPropertyNames(Object.getPrototypeOf(i));e.forEach(function(t){typeof i[t]=="function"&&(i[t]=i[t].bind(i))})}var Qa=function(i){bl(t,i);var e=Nx(t);function t(){var n,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;if(hi(this,t),n=e.call(this),vl&&cn.call(un(n)),n.options=ep(r),n.services={},n.logger=Mi,n.modules={external:[]},Fx(un(n)),s&&!n.isInitialized&&!r.isClone){if(!n.options.initImmediate)return n.init(r,s),so(n,un(n));setTimeout(function(){n.init(r,s)},0)}return n}return fi(t,[{key:"init",value:function(){var r=this,s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=arguments.length>1?arguments[1]:void 0;typeof s=="function"&&(o=s,s={}),!s.defaultNS&&s.defaultNS!==!1&&s.ns&&(typeof s.ns=="string"?s.defaultNS=s.ns:s.ns.indexOf("translation")<0&&(s.defaultNS=s.ns[0]));var a=Dx();this.options=pi(pi(pi({},a),this.options),ep(s)),this.options.compatibilityAPI!=="v1"&&(this.options.interpolation=pi(pi({},a.interpolation),this.options.interpolation)),s.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=s.keySeparator),s.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=s.nsSeparator);function l(d){return d?typeof d=="function"?new d:d:null}if(!this.options.isClone){this.modules.logger?Mi.init(l(this.modules.logger),this.options):Mi.init(null,this.options);var u;this.modules.formatter?u=this.modules.formatter:typeof Intl<"u"&&(u=Jx);var h=new Cx(this.options);this.store=new kx(this.options.resources,this.options);var f=this.services;f.logger=Mi,f.resourceStore=this.store,f.languageUtils=h,f.pluralResolver=new Ux(h,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),u&&(!this.options.interpolation.format||this.options.interpolation.format===a.interpolation.format)&&(f.formatter=l(u),f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new $x(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new jx(l(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",function(d){for(var b=arguments.length,A=new Array(b>1?b-1:0),S=1;S1?b-1:0),S=1;S0&&c[0]!=="dev"&&(this.options.lng=c[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined");var p=["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"];p.forEach(function(d){r[d]=function(){var b;return(b=r.store)[d].apply(b,arguments)}});var v=["addResource","addResources","addResourceBundle","removeResourceBundle"];v.forEach(function(d){r[d]=function(){var b;return(b=r.store)[d].apply(b,arguments),r}});var x=Kr(),m=function(){var b=function(S,T){r.isInitialized&&!r.initializedStoreOnce&&r.logger.warn("init: i18next is already initialized. You should call init just once!"),r.isInitialized=!0,r.options.isClone||r.logger.log("initialized",r.options),r.emit("initialized",r.options),x.resolve(T),o(S,T)};if(r.languages&&r.options.compatibilityAPI!=="v1"&&!r.isInitialized)return b(null,r.t.bind(r));r.changeLanguage(r.options.lng,b)};return this.options.resources||!this.options.initImmediate?m():setTimeout(m,0),x}},{key:"loadResources",value:function(r){var s=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:wo,a=o,l=typeof r=="string"?r:this.language;if(typeof r=="function"&&(a=r),!this.options.resources||this.options.partialBundledLanguages){if(l&&l.toLowerCase()==="cimode")return a();var u=[],h=function(p){if(p){var v=s.services.languageUtils.toResolveHierarchy(p);v.forEach(function(x){u.indexOf(x)<0&&u.push(x)})}};if(l)h(l);else{var f=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);f.forEach(function(c){return h(c)})}this.options.preload&&this.options.preload.forEach(function(c){return h(c)}),this.services.backendConnector.load(u,this.options.ns,function(c){!c&&!s.resolvedLanguage&&s.language&&s.setResolvedLanguage(s.language),a(c)})}else a(null)}},{key:"reloadResources",value:function(r,s,o){var a=Kr();return r||(r=this.languages),s||(s=this.options.ns),o||(o=wo),this.services.backendConnector.reload(r,s,function(l){a.resolve(),o(l)}),a}},{key:"use",value:function(r){if(!r)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!r.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return r.type==="backend"&&(this.modules.backend=r),(r.type==="logger"||r.log&&r.warn&&r.error)&&(this.modules.logger=r),r.type==="languageDetector"&&(this.modules.languageDetector=r),r.type==="i18nFormat"&&(this.modules.i18nFormat=r),r.type==="postProcessor"&&OO.addPostProcessor(r),r.type==="formatter"&&(this.modules.formatter=r),r.type==="3rdParty"&&this.modules.external.push(r),this}},{key:"setResolvedLanguage",value:function(r){if(!(!r||!this.languages)&&!(["cimode","dev"].indexOf(r)>-1))for(var s=0;s-1)&&this.store.hasLanguageSomeTranslations(o)){this.resolvedLanguage=o;break}}}},{key:"changeLanguage",value:function(r,s){var o=this;this.isLanguageChangingTo=r;var a=Kr();this.emit("languageChanging",r);var l=function(c){o.language=c,o.languages=o.services.languageUtils.toResolveHierarchy(c),o.resolvedLanguage=void 0,o.setResolvedLanguage(c)},u=function(c,p){p?(l(p),o.translator.changeLanguage(p),o.isLanguageChangingTo=void 0,o.emit("languageChanged",p),o.logger.log("languageChanged",p)):o.isLanguageChangingTo=void 0,a.resolve(function(){return o.t.apply(o,arguments)}),s&&s(c,function(){return o.t.apply(o,arguments)})},h=function(c){!r&&!c&&o.services.languageDetector&&(c=[]);var p=typeof c=="string"?c:o.services.languageUtils.getBestMatchFromCodes(c);p&&(o.language||l(p),o.translator.language||o.translator.changeLanguage(p),o.services.languageDetector&&o.services.languageDetector.cacheUserLanguage(p)),o.loadResources(p,function(v){u(v,p)})};return!r&&this.services.languageDetector&&!this.services.languageDetector.async?h(this.services.languageDetector.detect()):!r&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect(h):h(r),a}},{key:"getFixedT",value:function(r,s,o){var a=this,l=function u(h,f){var c;if(oi(f)!=="object"){for(var p=arguments.length,v=new Array(p>2?p-2:0),x=2;x1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var a=this.resolvedLanguage||this.languages[0],l=this.options?this.options.fallbackLng:!1,u=this.languages[this.languages.length-1];if(a.toLowerCase()==="cimode")return!0;var h=function(p,v){var x=s.services.backendConnector.state["".concat(p,"|").concat(v)];return x===-1||x===2};if(o.precheck){var f=o.precheck(this,h);if(f!==void 0)return f}return!!(this.hasResourceBundle(a,r)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||h(a,r)&&(!l||h(u,r)))}},{key:"loadNamespaces",value:function(r,s){var o=this,a=Kr();return this.options.ns?(typeof r=="string"&&(r=[r]),r.forEach(function(l){o.options.ns.indexOf(l)<0&&o.options.ns.push(l)}),this.loadResources(function(l){a.resolve(),s&&s(l)}),a):(s&&s(),Promise.resolve())}},{key:"loadLanguages",value:function(r,s){var o=Kr();typeof r=="string"&&(r=[r]);var a=this.options.preload||[],l=r.filter(function(u){return a.indexOf(u)<0});return l.length?(this.options.preload=a.concat(l),this.loadResources(function(u){o.resolve(),s&&s(u)}),o):(s&&s(),Promise.resolve())}},{key:"dir",value:function(r){if(r||(r=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!r)return"rtl";var s=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"];return s.indexOf(this.services.languageUtils.getLanguagePartFromCode(r))>-1||r.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}},{key:"cloneInstance",value:function(){var r=this,s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:wo,a=pi(pi(pi({},this.options),s),{isClone:!0}),l=new t(a);(s.debug!==void 0||s.prefix!==void 0)&&(l.logger=l.logger.clone(s));var u=["store","services","language"];return u.forEach(function(h){l[h]=r[h]}),l.services=pi({},this.services),l.services.utils={hasLoadedNamespace:l.hasLoadedNamespace.bind(l)},l.translator=new Yd(l.services,l.options),l.translator.on("*",function(h){for(var f=arguments.length,c=new Array(f>1?f-1:0),p=1;p0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;return new Qa(i,e)});var Ge=Qa.createInstance();Ge.createInstance=Qa.createInstance;Ge.createInstance;Ge.init;Ge.loadResources;Ge.reloadResources;Ge.use;Ge.changeLanguage;Ge.getFixedT;Ge.t;Ge.exists;Ge.setDefaultNamespace;Ge.hasLoadedNamespace;Ge.loadNamespaces;Ge.loadLanguages;var _O=[],Xx=_O.forEach,Gx=_O.slice;function Wx(i){return Xx.call(Gx.call(arguments,1),function(e){if(e)for(var t in e)i[t]===void 0&&(i[t]=e[t])}),i}var ip=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Yx=function(e,t,n){var r=n||{};r.path=r.path||"/";var s=encodeURIComponent(t),o="".concat(e,"=").concat(s);if(r.maxAge>0){var a=r.maxAge-0;if(Number.isNaN(a))throw new Error("maxAge should be a Number");o+="; Max-Age=".concat(Math.floor(a))}if(r.domain){if(!ip.test(r.domain))throw new TypeError("option domain is invalid");o+="; Domain=".concat(r.domain)}if(r.path){if(!ip.test(r.path))throw new TypeError("option path is invalid");o+="; Path=".concat(r.path)}if(r.expires){if(typeof r.expires.toUTCString!="function")throw new TypeError("option expires is invalid");o+="; Expires=".concat(r.expires.toUTCString())}if(r.httpOnly&&(o+="; HttpOnly"),r.secure&&(o+="; Secure"),r.sameSite){var l=typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.sameSite;switch(l){case!0:o+="; SameSite=Strict";break;case"lax":o+="; SameSite=Lax";break;case"strict":o+="; SameSite=Strict";break;case"none":o+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return o},np={create:function(e,t,n,r){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};n&&(s.expires=new Date,s.expires.setTime(s.expires.getTime()+n*60*1e3)),r&&(s.domain=r),document.cookie=Yx(e,encodeURIComponent(t),s)},read:function(e){for(var t="".concat(e,"="),n=document.cookie.split(";"),r=0;r-1&&(n=window.location.hash.substring(window.location.hash.indexOf("?")));for(var r=n.substring(1),s=r.split("&"),o=0;o0){var l=s[o].substring(0,a);l===e.lookupQuerystring&&(t=s[o].substring(a+1))}}}return t}},qr=null,rp=function(){if(qr!==null)return qr;try{qr=window!=="undefined"&&window.localStorage!==null;var e="i18next.translate.boo";window.localStorage.setItem(e,"foo"),window.localStorage.removeItem(e)}catch{qr=!1}return qr},Kx={name:"localStorage",lookup:function(e){var t;if(e.lookupLocalStorage&&rp()){var n=window.localStorage.getItem(e.lookupLocalStorage);n&&(t=n)}return t},cacheUserLanguage:function(e,t){t.lookupLocalStorage&&rp()&&window.localStorage.setItem(t.lookupLocalStorage,e)}},Hr=null,sp=function(){if(Hr!==null)return Hr;try{Hr=window!=="undefined"&&window.sessionStorage!==null;var e="i18next.translate.boo";window.sessionStorage.setItem(e,"foo"),window.sessionStorage.removeItem(e)}catch{Hr=!1}return Hr},qx={name:"sessionStorage",lookup:function(e){var t;if(e.lookupSessionStorage&&sp()){var n=window.sessionStorage.getItem(e.lookupSessionStorage);n&&(t=n)}return t},cacheUserLanguage:function(e,t){t.lookupSessionStorage&&sp()&&window.sessionStorage.setItem(t.lookupSessionStorage,e)}},Hx={name:"navigator",lookup:function(e){var t=[];if(typeof navigator<"u"){if(navigator.languages)for(var n=0;n0?t:void 0}},ek={name:"htmlTag",lookup:function(e){var t,n=e.htmlTag||(typeof document<"u"?document.documentElement:null);return n&&typeof n.getAttribute=="function"&&(t=n.getAttribute("lang")),t}},tk={name:"path",lookup:function(e){var t;if(typeof window<"u"){var n=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(n instanceof Array)if(typeof e.lookupFromPathIndex=="number"){if(typeof n[e.lookupFromPathIndex]!="string")return;t=n[e.lookupFromPathIndex].replace("/","")}else t=n[0].replace("/","")}return t}},ik={name:"subdomain",lookup:function(e){var t=typeof e.lookupFromSubdomainIndex=="number"?e.lookupFromSubdomainIndex+1:1,n=typeof window<"u"&&window.location&&window.location.hostname&&window.location.hostname.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(n)return n[t]}};function nk(){return{order:["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"],lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"]}}var wO=function(){function i(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};hi(this,i),this.type="languageDetector",this.detectors={},this.init(e,t)}return fi(i,[{key:"init",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=t,this.options=Wx(n,this.options||{},nk()),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=r,this.addDetector(zx),this.addDetector(Vx),this.addDetector(Kx),this.addDetector(qx),this.addDetector(Hx),this.addDetector(ek),this.addDetector(tk),this.addDetector(ik)}},{key:"addDetector",value:function(t){this.detectors[t.name]=t}},{key:"detect",value:function(t){var n=this;t||(t=this.options.order);var r=[];return t.forEach(function(s){if(n.detectors[s]){var o=n.detectors[s].lookup(n.options);o&&typeof o=="string"&&(o=[o]),o&&(r=r.concat(o))}}),this.services.languageUtils.getBestMatchFromCodes?r:r.length>0?r[0]:null}},{key:"cacheUserLanguage",value:function(t,n){var r=this;n||(n=this.options.caches),n&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(t)>-1||n.forEach(function(s){r.detectors[s]&&r.detectors[s].cacheUserLanguage(t,r.options)}))}}]),i}();wO.type="languageDetector";const bO={en:{translation:{"language-name":"english",toolbar:{run:"Run all code (ctrl+shift+enter)",upload:"upload to gallery",clear:"clear all",shuffle:"show random sketch",random:"make random change","load-extension":"load library or extension","show-info":"show info window","hide-info":"hide info window"},info:{title:"hydra",subtitle:"live coding video synth",description:"Hydra is live code-able video synth and coding environment that runs directly in the browser. It is free and open-source and made for beginners and experts alike.","get-started-title":"To get started:","get-started-list":["Close this window","Change some numbers","Type Ctrl + Shift + Enter"],"description-detailed":"Hydra is written in JavaScript and compiles to WebGL under the hood. The syntax is inspired by analog modular synthesis, in which chaining or patching a set of transformations together generates a visual result.",uses:"Hydra can be used:","uses-list":["to mix and add effects to camera feeds, screenshares, live streams, and videos","to create generative and audio-reactive visuals, and share them online with others","in combination with other javascript libraries such as P5.js, Tone.js, THREE.js, or gibber","to add interactive video effects to a website","to experiment with and learn about video feedback, fractals, and pixel operations","to stream video between browsers and live-jam with others online"],author:"Created by olivia.","more-info":"For more information and instructions, see: the interactive documentation, a list of hydra functions, the community database of projects and tutorials, a gallery of user-generated sketches, and the source code on github,","more-info-forums":"There is also an active Discord server and facebook group for hydra users+contributors.",support:"If you enjoy using Hydra, please consider supporting continued development <3 ."},extensions:{"about-extensions":"Show community extensions for hydra-synth.","show-example":"Load and run {{extension-name}} example.","show-library":"Add code for loading {{extension-name}} to the top of the current sketch.","show-docs":"Documentation of usage for {{extension-name}}"}}}},rk=["ja","es","ar","id","pt-br","ch","ko","fr","de"],sk=i=>`https://raw.githubusercontent.com/hydra-synth/l10n/main/${i}/editor.json`;Ge.use(wO).init({debug:!0,fallbackLng:"en",partialBundledLanguages:!0,resources:bO});function ok(i,e){const t={};let n=new URLSearchParams(window.location.search),r=n.get("l10n-lang"),s=n.get("l10n-url");rk.forEach(l=>{a(l,sk(l))}),r!==null&&s!==null&&a(r,s),o(),e.on("set language",l=>{Ge.changeLanguage(l,(u,h)=>{i.translation.selectedLanguage=l,e.emit("render")})});function o(){Object.keys(bO).forEach(l=>{const u=l.split("-")[0];t[u]=Ge.getFixedT(u)("language-name")}),i.translation={t:Ge.t,languages:t,selectedLanguage:Ge.language,textDirection:Ge.language==="ar"?"rtl":"ltr"}}function a(l="es",u){const h="color: purple; background: orange; font-size: 14px;padding:10px";console.log(`%cloading translation for ${l} from ${u}`,h),fetch(u).then(f=>f.ok?f.json():f.text().then(c=>{throw new Error(c)})).then(f=>{window.i18n=Ge,console.log("adding language",l,f);const c=l.split("-")[0];Ge.addResourceBundle(c,"translation",f),o(),e.emit("render")})}}const ak="https://raw.githubusercontent.com/hydra-synth/hydra-extensions/main/";async function lk(i,e){i.extensions={baseURL:ak,selectedCategoryIndex:0,categories:[{name:"extensions",slug:"extensions",entries:[],hasLoaded:!1},{name:"external libraries",slug:"external-libraries",entries:[],hasLoaded:!1},{name:"examples",slug:"examples",entries:[],hasLoaded:!1}]},e.on("extensions: select category",(t=i.extensions.selectedCategoryIndex)=>{i.extensions.selectedCategoryIndex=t,e.emit("render");const n=i.extensions.categories[t];if(!n.hasLoaded){const r=i.extensions.baseURL+n.slug+".json?laskd";fetch(r).then(s=>s.json()).then(s=>{console.log("loaded d",s),s.forEach(o=>{o.thumbnail=i.extensions.baseURL+"thumbnails/"+o.thumbnail}),n.entries=s,e.emit("render")})}}),e.on("extensions: add to editor",t=>{const{categories:n,selectedCategoryIndex:r}=i.extensions,s=n[r].entries[t].load;e.emit("editor: add code to top",s)}),e.on("extensions: load example",(t,n)=>{const{categories:r,selectedCategoryIndex:s}=i.extensions,o=r[s].entries[t].examples[n],a=new URL(o);console.log(a,i.gallery),i.gallery.setSketchFromURL(a.search,l=>{e.emit("load and eval code",l)})})}const vO=1024;let uk=0,su=class{constructor(e,t){this.from=e,this.to=t}};class we{constructor(e={}){this.id=uk++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Ut.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}}we.closedBy=new we({deserialize:i=>i.split(" ")});we.openedBy=new we({deserialize:i=>i.split(" ")});we.group=new we({deserialize:i=>i.split(" ")});we.contextHash=new we({perNode:!0});we.lookAhead=new we({perNode:!0});we.mounted=new we({perNode:!0});const hk=Object.create(null);class Ut{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):hk,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new Ut(e.name||"",t,e.id,n);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}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(we.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 n=>{for(let r=n.prop(we.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?n.name:r[s]];if(o)return o}}}}Ut.none=new Ut("",Object.create(null),0,8);class oc{constructor(e){this.types=e;for(let t=0;t0;for(let l=this.cursor(o|nt.IncludeAnonymous);;){let u=!1;if(l.from<=s&&l.to>=r&&(!a&&l.type.isAnonymous||t(l)!==!1)){if(l.firstChild())continue;u=!0}for(;u&&n&&(a||!l.type.isAnonymous)&&n(l),!l.nextSibling();){if(!l.parent())return;u=!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(e={}){return this.children.length<=8?this:uc(Ut.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new He(this.type,t,n,r,this.propValues),e.makeTree||((t,n,r)=>new He(Ut.none,t,n,r)))}static build(e){return ck(e)}}He.empty=new He(Ut.none,[],[],0);class ac{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 ac(this.buffer,this.index)}}class Nn{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Ut.none}toString(){let e=[];for(let t=0;t0));l=o[l+3]);return a}slice(e,t,n){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let a=e,l=0;a=e&&te;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function xO(i,e){let t=i.childBefore(e);for(;t;){let n=t.lastChild;if(!n||n.to!=t.to)break;n.type.isError&&n.from==n.to?(i=t,t=n.prevSibling):t=n}return i}function Cr(i,e,t,n){for(var r;i.from==i.to||(t<1?i.from>=e:i.from>e)||(t>-1?i.to<=e:i.to0?a.length:-1;e!=u;e+=t){let h=a[e],f=l[e]+o.from;if(SO(r,n,f,f+h.length)){if(h instanceof Nn){if(s&nt.ExcludeBuffers)continue;let c=h.findChild(0,h.buffer.length,t,n-f,r);if(c>-1)return new Ti(new fk(o,h,e,f),null,c)}else if(s&nt.IncludeAnonymous||!h.type.isAnonymous||lc(h)){let c;if(!(s&nt.IgnoreMounts)&&h.props&&(c=h.prop(we.mounted))&&!c.overlay)return new ai(c.tree,f,e,o);let p=new ai(h,f,e,o);return s&nt.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?h.children.length-1:0,t,n,r)}}}if(s&nt.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<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)}enter(e,t,n=0){let r;if(!(n&nt.IgnoreOverlays)&&(r=this._tree.prop(we.mounted))&&r.overlay){let s=e-this.from;for(let{from:o,to:a}of r.overlay)if((t>0?o<=s:o=s:a>s))return new ai(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}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}cursor(e=0){return new Ua(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return Cr(this,e,t,!1)}resolveInner(e,t=0){return Cr(this,e,t,!0)}enterUnfinishedNodesBefore(e){return xO(this,e)}getChild(e,t=null,n=null){let r=Aa(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return Aa(this,e,t,n)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return Ra(this,e)}}function Aa(i,e,t,n){let r=i.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(;!r.type.is(t);)if(!r.nextSibling())return s}for(;;){if(n!=null&&r.type.is(n))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return n==null?s:[]}}function Ra(i,e,t=e.length-1){for(let n=i.parent;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}class fk{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}}class Ti{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){this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,n);return s<0?null:new Ti(this.context,this,s)}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)}enter(e,t,n=0){if(n&nt.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new Ti(this.context,this,s)}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:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Ti(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Ti(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new Ua(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,s=n.buffer[this.index+3];if(s>r){let o=n.buffer[this.index+1];e.push(n.slice(r,s,o)),t.push(0)}return new He(this.type,e,t,this.to-this.from)}resolve(e,t=0){return Cr(this,e,t,!1)}resolveInner(e,t=0){return Cr(this,e,t,!0)}enterUnfinishedNodesBefore(e){return xO(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,n=null){let r=Aa(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return Aa(this,e,t,n)}get node(){return this}matchContext(e){return Ra(this,e)}}class Ua{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof ai)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.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 ai?(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,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}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&nt.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&nt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&nt.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 r=n<0?0:this.stack[n]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(r)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}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-1)for(let s=t+e,o=e<0?-1:n._tree.children.length;s!=o;s+=e){let a=n._tree.children[s];if(this.mode&nt.IncludeAnonymous||a instanceof Nn||!a.type.isAnonymous||lc(a))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=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,n=s+1;break e}r=this.stack[--s]}for(let r=n;r=0;s--){if(s<0)return Ra(this.node,e,r);let o=n[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function lc(i){return i.children.some(e=>e instanceof Nn||!e.type.isAnonymous||lc(e))}function ck(i){var e;let{buffer:t,nodeSet:n,maxBufferLength:r=vO,reused:s=[],minRepeatType:o=n.types.length}=i,a=Array.isArray(t)?new ac(t,t.length):t,l=n.types,u=0,h=0;function f(S,T,k,Q,C){let{id:I,start:_,end:j,size:D}=a,V=h;for(;D<0;)if(a.next(),D==-1){let N=s[I];k.push(N),Q.push(_-S);return}else if(D==-3){u=I;return}else if(D==-4){h=I;return}else throw new RangeError(`Unrecognized record size: ${D}`);let ee=l[I],B,Z,R=_-S;if(j-_<=r&&(Z=x(a.pos-T,C))){let N=new Uint16Array(Z.size-Z.skip),Y=a.pos-Z.size,te=N.length;for(;a.pos>Y;)te=m(Z.start,N,te);B=new Nn(N,j-Z.start,n),R=Z.start-S}else{let N=a.pos-D;a.next();let Y=[],te=[],se=I>=o?I:-1,le=0,ue=j;for(;a.pos>N;)se>=0&&a.id==se&&a.size>=0?(a.end<=ue-r&&(p(Y,te,_,le,a.end,ue,se,V),le=Y.length,ue=a.end),a.next()):f(_,N,Y,te,se);if(se>=0&&le>0&&le-1&&le>0){let de=c(ee);B=uc(ee,Y,te,0,Y.length,0,j-_,de,de)}else B=v(ee,Y,te,j-_,V-j)}k.push(B),Q.push(R)}function c(S){return(T,k,Q)=>{let C=0,I=T.length-1,_,j;if(I>=0&&(_=T[I])instanceof He){if(!I&&_.type==S&&_.length==Q)return _;(j=_.prop(we.lookAhead))&&(C=k[I]+_.length+j)}return v(S,T,k,Q,C)}}function p(S,T,k,Q,C,I,_,j){let D=[],V=[];for(;S.length>Q;)D.push(S.pop()),V.push(T.pop()+k-C);S.push(v(n.types[_],D,V,I-C,j-I)),T.push(C-k)}function v(S,T,k,Q,C=0,I){if(u){let _=[we.contextHash,u];I=I?[_].concat(I):[_]}if(C>25){let _=[we.lookAhead,C];I=I?[_].concat(I):[_]}return new He(S,T,k,Q,I)}function x(S,T){let k=a.fork(),Q=0,C=0,I=0,_=k.end-r,j={size:0,start:0,skip:0};e:for(let D=k.pos-S;k.pos>D;){let V=k.size;if(k.id==T&&V>=0){j.size=Q,j.start=C,j.skip=I,I+=4,Q+=4,k.next();continue}let ee=k.pos-V;if(V<0||ee=o?4:0,Z=k.start;for(k.next();k.pos>ee;){if(k.size<0)if(k.size==-3)B+=4;else break e;else k.id>=o&&(B+=4);k.next()}C=Z,Q+=V,I+=B}return(T<0||Q==S)&&(j.size=Q,j.start=C,j.skip=I),j.size>4?j:void 0}function m(S,T,k){let{id:Q,start:C,end:I,size:_}=a;if(a.next(),_>=0&&Q4){let D=a.pos-(_-4);for(;a.pos>D;)k=m(S,T,k)}T[--k]=j,T[--k]=I-S,T[--k]=C-S,T[--k]=Q}else _==-3?u=Q:_==-4&&(h=Q);return k}let d=[],b=[];for(;a.pos>0;)f(i.start||0,i.bufferStart||0,d,b,-1);let A=(e=i.length)!==null&&e!==void 0?e:d.length?b[0]+d[0].length:0;return new He(l[i.topID],d.reverse(),b.reverse(),A)}const ap=new WeakMap;function da(i,e){if(!i.isAnonymous||e instanceof Nn||e.type!=i)return 1;let t=ap.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=i||!(n instanceof He)){t=1;break}t+=da(i,n)}ap.set(e,t)}return t}function uc(i,e,t,n,r,s,o,a,l){let u=0;for(let v=n;v=h)break;k+=Q}if(A==S+1){if(k>h){let Q=v[S];p(Q.children,Q.positions,0,Q.children.length,x[S]+b);continue}f.push(v[S])}else{let Q=x[A-1]+v[A-1].length-T;f.push(uc(i,v,x,S,A,T,Q,null,l))}c.push(T+b-s)}}return p(e,t,n,r,0),(a||l)(f,c,o)}class dk{constructor(){this.map=new WeakMap}setBuffer(e,t,n){let r=this.map.get(e);r||this.map.set(e,r=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 Ti?this.setBuffer(e.context.buffer,e.index,t):e instanceof ai&&this.map.set(e.tree,t)}get(e){return e instanceof Ti?this.getBuffer(e.context.buffer,e.index):e instanceof ai?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)}}class An{constructor(e,t,n,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let r=[new An(0,e.length,e,0,!1,n)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,n=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let a=0,l=0,u=0;;a++){let h=a=n)for(;o&&o.from=c.from||f<=c.to||u){let p=Math.max(c.from,l)-u,v=Math.min(c.to,f)-u;c=p>=v?null:new An(p,v,c.tree,c.offset+u,a>0,!!h)}if(c&&r.push(c),o.to>f)break;o=snew su(r.from,r.to)):[new su(0,0)]:[new su(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let s=r.advance();if(s)return s}}}class pk{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 we({perNode:!0});class Te{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),Si.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){let n=[];return this.decompose(e,t,n,0),Si.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new Ss(this),s=new Ss(e);for(let o=t,a=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new Ss(this,e)}iterRange(e,t=this.length){return new MO(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new TO(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Te.empty:e.length<=32?new Ye(e):Si.from(Ye.split(e,[]))}}class Ye extends Te{constructor(e,t=gk(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.text[s],a=r+o.length;if((t?n:a)>=e)return new mk(r,a,n,o);r=a+1,n++}}decompose(e,t,n,r){let s=e<=0&&t>=this.length?this:new Ye(lp(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=n.pop(),a=pa(s.text,o.text.slice(),0,s.length);if(a.length<=32)n.push(new Ye(a,o.length+s.length));else{let l=a.length>>1;n.push(new Ye(a.slice(0,l)),new Ye(a.slice(l)))}}else n.push(s)}replace(e,t,n){if(!(n instanceof Ye))return super.replace(e,t,n);let r=pa(this.text,pa(n.text,lp(this.text,0,e)),t),s=this.length+n.length-(t-e);return r.length<=32?new Ye(r,s):Si.from(Ye.split(r,[]),s)}sliceString(e,t=this.length,n=` -`){let r="";for(let s=0,o=0;s<=t&&oe&&o&&(r+=n),es&&(r+=a.slice(Math.max(0,e-s),t-s)),s=l+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],r=-1;for(let s of e)n.push(s),r+=s.length+1,n.length==32&&(t.push(new Ye(n,r)),n=[],r=-1);return r>-1&&t.push(new Ye(n,r)),t}}class Si extends Te{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.children[s],a=r+o.length,l=n+o.lines-1;if((t?l:a)>=e)return o.lineInner(e,t,n,r);r=a+1,n=l+1}}decompose(e,t,n,r){for(let s=0,o=0;o<=t&&s=o){let u=r&((o<=e?1:0)|(l>=t?2:0));o>=e&&l<=t&&!u?n.push(a):a.decompose(e-o,t-o,n,u)}o=l+1}}replace(e,t,n){if(n.lines=s&&t<=a){let l=o.replace(e-s,t-s,n),u=this.lines-o.lines+l.lines;if(l.lines>5-1&&l.lines>u>>5+1){let h=this.children.slice();return h[r]=l,new Si(h,this.length-(t-e)+n.length)}return super.replace(s,a,l)}s=a+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=` -`){let r="";for(let s=0,o=0;se&&s&&(r+=n),eo&&(r+=a.sliceString(e-o,t-o,n)),o=l+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof Si))return 0;let n=0,[r,s,o,a]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==a)return n;let l=this.children[r],u=e.children[s];if(l!=u)return n+l.scanIdentical(u,t);n+=l.length+1}}static from(e,t=e.reduce((n,r)=>n+r.length+1,-1)){let n=0;for(let p of e)n+=p.lines;if(n<32){let p=[];for(let v of e)v.flatten(p);return new Ye(p,t)}let r=Math.max(32,n>>5),s=r<<1,o=r>>1,a=[],l=0,u=-1,h=[];function f(p){let v;if(p.lines>s&&p instanceof Si)for(let x of p.children)f(x);else p.lines>o&&(l>o||!l)?(c(),a.push(p)):p instanceof Ye&&l&&(v=h[h.length-1])instanceof Ye&&p.lines+v.lines<=32?(l+=p.lines,u+=p.length+1,h[h.length-1]=new Ye(v.text.concat(p.text),v.length+1+p.length)):(l+p.lines>r&&c(),l+=p.lines,u+=p.length+1,h.push(p))}function c(){l!=0&&(a.push(h.length==1?h[0]:Si.from(h,u)),u=-1,l=h.length=0)}for(let p of e)f(p);return c(),a.length==1?a[0]:new Si(a,t)}}Te.empty=new Ye([""],0);function gk(i){let e=-1;for(let t of i)e+=t.length+1;return e}function pa(i,e,t=0,n=1e9){for(let r=0,s=0,o=!0;s=t&&(l>n&&(a=a.slice(0,n-r)),r0?1:(e instanceof Ye?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],s=this.offsets[n],o=s>>1,a=r instanceof Ye?r.text.length:r.children.length;if(o==(t>0?a:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(r instanceof Ye){let l=r.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,l.length>Math.max(0,e))return this.value=e==0?l:t>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=r.children[o+(t<0?-1:0)];e>l.length?(e-=l.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(l),this.offsets.push(t>0?1:(l instanceof Ye?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class MO{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new Ss(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class TO{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Te.prototype[Symbol.iterator]=function(){return this.iter()},Ss.prototype[Symbol.iterator]=MO.prototype[Symbol.iterator]=TO.prototype[Symbol.iterator]=function(){return this});class mk{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}}let gr="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(i=>i?parseInt(i,36):1);for(let i=1;ii)return gr[e-1]<=i;return!1}function up(i){return i>=127462&&i<=127487}const hp=8205;function xt(i,e,t=!0,n=!0){return(t?CO:Ok)(i,e,n)}function CO(i,e,t){if(e==i.length)return e;e&&EO(i.charCodeAt(e))&&QO(i.charCodeAt(e-1))&&e--;let n=dt(i,e);for(e+=Zt(n);e=0&&up(dt(i,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function Ok(i,e,t){for(;e>0;){let n=CO(i,e-2,t);if(n=56320&&i<57344}function QO(i){return i>=55296&&i<56320}function dt(i,e){let t=i.charCodeAt(e);if(!QO(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return EO(n)?(t-55296<<10)+(n-56320)+65536:t}function hc(i){return i<=65535?String.fromCharCode(i):(i-=65536,String.fromCharCode((i>>10)+55296,(i&1023)+56320))}function Zt(i){return i<65536?1:2}const Qh=/\r\n?|\n/;var gt=function(i){return i[i.Simple=0]="Simple",i[i.TrackDel=1]="TrackDel",i[i.TrackBefore=2]="TrackBefore",i[i.TrackAfter=3]="TrackAfter",i}(gt||(gt={}));class Ri{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return s+(e-r);s+=a}else{if(n!=gt.Simple&&u>=e&&(n==gt.TrackDel&&re||n==gt.TrackBefore&&re))return null;if(u>e||u==e&&t<0&&!a)return e==r||t<0?s:s+l;s+=l}r=u}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let n=0,r=0;n=0&&r<=t&&a>=e)return rt?"cover":!0;r=a}return!1}toString(){let e="";for(let t=0;t=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Ri(e)}static create(e){return new Ri(e)}}class it extends Ri{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Ah(this,(t,n,r,s,o)=>e=e.replace(r,r+(n-t),o),!1),e}mapDesc(e,t=!1){return Rh(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let r=0,s=0;r=0){t[r]=a,t[r+1]=o;let l=r>>1;for(;n.length0&&rn(n,t,s.text),s.forward(h),a+=h}let u=e[o++];for(;a>1].toJSON()))}return e}static of(e,t,n){let r=[],s=[],o=0,a=null;function l(h=!1){if(!h&&!r.length)return;oc||f<0||c>t)throw new RangeError(`Invalid change range ${f} to ${c} (in doc of length ${t})`);let v=p?typeof p=="string"?Te.of(p.split(n||Qh)):p:Te.empty,x=v.length;if(f==c&&x==0)return;fo&&_t(r,f-o,-1),_t(r,c-f,x),rn(s,r,v),o=c}}return u(e),l(!a),a}static empty(e){return new it(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let r=0;ra&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;n.length=0&&t<=0&&t==i[r+1]?i[r]+=e:e==0&&i[r]==0?i[r+1]+=t:n?(i[r]+=e,i[r+1]+=t):i.push(e,t)}function rn(i,e,t){if(t.length==0)return;let n=e.length-2>>1;if(n>1])),!(t||o==i.sections.length||i.sections[o+1]<0);)a=i.sections[o++],l=i.sections[o++];e(r,u,s,h,f),r=u,s=h}}}function Rh(i,e,t,n=!1){let r=[],s=n?[]:null,o=new As(i),a=new As(e);for(let l=-1;;)if(o.ins==-1&&a.ins==-1){let u=Math.min(o.len,a.len);_t(r,u,-1),o.forward(u),a.forward(u)}else if(a.ins>=0&&(o.ins<0||l==o.i||o.off==0&&(a.len=0&&l=0){let u=0,h=o.len;for(;h;)if(a.ins==-1){let f=Math.min(h,a.len);u+=f,h-=f,a.forward(f)}else if(a.ins==0&&a.lenl||o.ins>=0&&o.len>l)&&(a||n.length>u),s.forward2(l),o.forward(l)}}}}class As{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?Te.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?Te.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Cn{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&16?this.to:this.from}get head(){return this.flags&16?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&4?-1:this.flags&8?1:0}get bidiLevel(){let e=this.flags&3;return e==3?null:e}get goalColumn(){let e=this.flags>>5;return e==33554431?void 0:e}map(e,t=-1){let n,r;return this.empty?n=r=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new Cn(n,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return K.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return K.range(this.anchor,n)}eq(e){return this.anchor==e.anchor&&this.head==e.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return K.range(e.anchor,e.head)}static create(e,t,n){return new Cn(e,t,n)}}class K{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:K.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;te.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new K(e.ranges.map(t=>Cn.fromJSON(t)),e.main)}static single(e,t=e){return new K([K.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,r=0;re?4:0)|s)}static normalized(e,t=0){let n=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(n);for(let r=1;rs.head?K.range(l,a):K.range(a,l))}}return new K(e,t)}}function RO(i,e){for(let t of i.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let fc=0;class pe{constructor(e,t,n,r,s){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=fc++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}static define(e={}){return new pe(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:cc),!!e.static,e.enables)}of(e){return new ga([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new ga(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new ga(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}}function cc(i,e){return i==e||i.length==e.length&&i.every((t,n)=>t===e[n])}class ga{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=fc++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,a=this.type==2,l=!1,u=!1,h=[];for(let f of this.dependencies)f=="doc"?l=!0:f=="selection"?u=!0:((t=e[f.id])!==null&&t!==void 0?t:1)&1||h.push(e[f.id]);return{create(f){return f.values[o]=n(f),1},update(f,c){if(l&&c.docChanged||u&&(c.docChanged||c.selection)||Uh(f,h)){let p=n(f);if(a?!fp(p,f.values[o],r):!r(p,f.values[o]))return f.values[o]=p,1}return 0},reconfigure:(f,c)=>{let p,v=c.config.address[s];if(v!=null){let x=Pa(c,v);if(this.dependencies.every(m=>m instanceof pe?c.facet(m)===f.facet(m):m instanceof ft?c.field(m,!1)==f.field(m,!1):!0)||(a?fp(p=n(f),x,r):r(p=n(f),x)))return f.values[o]=x,0}else p=n(f);return f.values[o]=p,1}}}}function fp(i,e,t){if(i.length!=e.length)return!1;for(let n=0;ni[l.id]),r=t.map(l=>l.type),s=n.filter(l=>!(l&1)),o=i[e.id]>>1;function a(l){let u=[];for(let h=0;hn===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(cp).find(n=>n.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:n=>(n.values[t]=this.create(n),1),update:(n,r)=>{let s=n.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(n.values[t]=o,1)},reconfigure:(n,r)=>r.config.address[this.id]!=null?(n.values[t]=r.field(this),0):(n.values[t]=this.create(n),1)}}init(e){return[this,cp.of({field:this,create:e})]}get extension(){return this}}const Sn={lowest:4,low:3,default:2,high:1,highest:0};function es(i){return e=>new UO(e,i)}const Zn={highest:es(Sn.highest),high:es(Sn.high),default:es(Sn.default),low:es(Sn.low),lowest:es(Sn.lowest)};class UO{constructor(e,t){this.inner=e,this.prec=t}}class Sl{of(e){return new $h(this,e)}reconfigure(e){return Sl.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class $h{constructor(e,t){this.compartment=e,this.inner=t}}class $a{constructor(e,t,n,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,n){let r=[],s=Object.create(null),o=new Map;for(let c of wk(e,t,o))c instanceof ft?r.push(c):(s[c.facet.id]||(s[c.facet.id]=[])).push(c);let a=Object.create(null),l=[],u=[];for(let c of r)a[c.id]=u.length<<1,u.push(p=>c.slot(p));let h=n==null?void 0:n.config.facets;for(let c in s){let p=s[c],v=p[0].facet,x=h&&h[c]||[];if(p.every(m=>m.type==0))if(a[v.id]=l.length<<1|1,cc(x,p))l.push(n.facet(v));else{let m=v.combine(p.map(d=>d.value));l.push(n&&v.compare(m,n.facet(v))?n.facet(v):m)}else{for(let m of p)m.type==0?(a[m.id]=l.length<<1|1,l.push(m.value)):(a[m.id]=u.length<<1,u.push(d=>m.dynamicSlot(d)));a[v.id]=u.length<<1,u.push(m=>_k(m,v,p))}}let f=u.map(c=>c(a));return new $a(e,o,f,a,l,s)}}function wk(i,e,t){let n=[[],[],[],[],[]],r=new Map;function s(o,a){let l=r.get(o);if(l!=null){if(l<=a)return;let u=n[l].indexOf(o);u>-1&&n[l].splice(u,1),o instanceof $h&&t.delete(o.compartment)}if(r.set(o,a),Array.isArray(o))for(let u of o)s(u,a);else if(o instanceof $h){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(o.compartment)||o.inner;t.set(o.compartment,u),s(u,a)}else if(o instanceof UO)s(o.inner,o.prec);else if(o instanceof ft)n[a].push(o),o.provides&&s(o.provides,a);else if(o instanceof ga)n[a].push(o),o.facet.extensions&&s(o.facet.extensions,Sn.default);else{let u=o.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(u,a)}}return s(i,Sn.default),n.reduce((o,a)=>o.concat(a))}function xs(i,e){if(e&1)return 2;let t=e>>1,n=i.status[t];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;i.status[t]=4;let r=i.computeSlot(i,i.config.dynamicSlots[t]);return i.status[t]=2|r}function Pa(i,e){return e&1?i.config.staticValues[e>>1]:i.values[e>>1]}const $O=pe.define(),PO=pe.define({combine:i=>i.some(e=>e),static:!0}),JO=pe.define({combine:i=>i.length?i[0]:void 0,static:!0}),IO=pe.define(),BO=pe.define(),LO=pe.define(),jO=pe.define({combine:i=>i.length?i[0]:!1});class Zi{constructor(e,t){this.type=e,this.value=t}static define(){return new bk}}class bk{of(e){return new Zi(this,e)}}class vk{constructor(e){this.map=e}of(e){return new Oe(this,e)}}class Oe{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new Oe(this.type,t)}is(e){return this.type==e}static define(e={}){return new vk(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let s=r.map(t);s&&n.push(s)}return n}}Oe.reconfigure=Oe.define();Oe.appendConfig=Oe.define();class et{constructor(e,t,n,r,s,o){this.startState=e,this.changes=t,this.selection=n,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,n&&RO(n,t.newLength),s.some(a=>a.type==et.time)||(this.annotations=s.concat(et.time.of(Date.now())))}static create(e,t,n,r,s,o){return new et(e,t,n,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(et.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}et.time=Zi.define();et.userEvent=Zi.define();et.addToHistory=Zi.define();et.remote=Zi.define();function Sk(i,e){let t=[];for(let n=0,r=0;;){let s,o;if(n=i[n]))s=i[n++],o=i[n++];else if(r=0;r--){let s=n[r](i);s instanceof et?i=s:Array.isArray(s)&&s.length==1&&s[0]instanceof et?i=s[0]:i=NO(e,mr(s),!1)}return i}function kk(i){let e=i.startState,t=e.facet(LO),n=i;for(let r=t.length-1;r>=0;r--){let s=t[r](i);s&&Object.keys(s).length&&(n=DO(n,Ph(e,s,i.changes.newLength),!0))}return n==i?i:et.create(e,i.changes,i.selection,n.effects,n.annotations,n.scrollIntoView)}const Mk=[];function mr(i){return i==null?Mk:Array.isArray(i)?i:[i]}var je=function(i){return i[i.Word=0]="Word",i[i.Space=1]="Space",i[i.Other=2]="Other",i}(je||(je={}));const Tk=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Jh;try{Jh=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Ck(i){if(Jh)return Jh.test(i);for(let e=0;e"€"&&(t.toUpperCase()!=t.toLowerCase()||Tk.test(t)))return!0}return!1}function Ek(i){return e=>{if(!/\S/.test(e))return je.Space;if(Ck(e))return je.Word;for(let t=0;t-1)return je.Word;return je.Other}}class ke{constructor(e,t,n,r,s,o){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let a=0;ar.set(l,a)),t=null),r.set(o.value.compartment,o.value.extension)):o.is(Oe.reconfigure)?(t=null,n=o.value):o.is(Oe.appendConfig)&&(t=null,n=mr(n).concat(o.value));let s;t?s=e.startState.values.slice():(t=$a.resolve(n,r,this),s=new ke(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,l)=>l.reconfigure(a,this),null).values),new ke(t,e.newDoc,e.newSelection,s,(o,a)=>a.update(o,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:K.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),s=[n.range],o=mr(n.effects);for(let a=1;ao.spec.fromJSON(a,l)))}}return ke.create({doc:e.doc,selection:K.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=$a.resolve(e.extensions||[],new Map),n=e.doc instanceof Te?e.doc:Te.of((e.doc||"").split(t.staticFacet(ke.lineSeparator)||Qh)),r=e.selection?e.selection instanceof K?e.selection:K.single(e.selection.anchor,e.selection.head):K.single(0);return RO(r,n.length),t.staticFacet(PO)||(r=r.asSingle()),new ke(t,n,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(ke.tabSize)}get lineBreak(){return this.facet(ke.lineSeparator)||` -`}get readOnly(){return this.facet(jO)}phrase(e,...t){for(let n of this.facet(ke.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(n,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?n:t[s-1]})),e}languageDataAt(e,t,n=-1){let r=[];for(let s of this.facet($O))for(let o of s(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){return Ek(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-n,a=e-n;for(;o>0;){let l=xt(t,o,!1);if(s(t.slice(l,o))!=je.Word)break;o=l}for(;ai.length?i[0]:4});ke.lineSeparator=JO;ke.readOnly=jO;ke.phrases=pe.define({compare(i,e){let t=Object.keys(i),n=Object.keys(e);return t.length==n.length&&t.every(r=>i[r]==e[r])}});ke.languageData=$O;ke.changeFilter=IO;ke.transactionFilter=BO;ke.transactionExtender=LO;Sl.reconfigure=Oe.define();function Fi(i,e,t={}){let n={};for(let r of i)for(let s of Object.keys(r)){let o=r[s],a=n[s];if(a===void 0)n[s]=o;else if(!(a===o||o===void 0))if(Object.hasOwnProperty.call(t,s))n[s]=t[s](a,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)n[r]===void 0&&(n[r]=e[r]);return n}class In{eq(e){return this==e}range(e,t=e){return Rs.create(e,t,this)}}In.prototype.startSide=In.prototype.endSide=0;In.prototype.point=!1;In.prototype.mapMode=gt.TrackDel;class Rs{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new Rs(e,t,n)}}function Ih(i,e){return i.from-e.from||i.value.startSide-e.value.startSide}class dc{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let s=n?this.to:this.from;for(let o=r,a=s.length;;){if(o==a)return o;let l=o+a>>1,u=s[l]-e||(n?this.value[l].endSide:this.value[l].startSide)-t;if(l==o)return u>=0?o:a;u>=0?a=l:o=l+1}}between(e,t,n,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,s);sp||c==p&&u.startSide>0&&u.endSide<=0)continue;(p-c||u.endSide-u.startSide)<0||(o<0&&(o=c),u.point&&(a=Math.max(a,p-c)),n.push(u),r.push(c-o),s.push(p-o))}return{mapped:n.length?new dc(r,s,n,a):null,pos:o}}}class Ne{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(e,t,n,r){return new Ne(e,t,n,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(n&&(t=t.slice().sort(Ih)),this.isEmpty)return t.length?Ne.of(t):this;let a=new ZO(this,null,-1).goto(0),l=0,u=[],h=new Bn;for(;a.value||l=0){let f=t[l++];h.addInner(f.from,f.to,f.value)||u.push(f)}else a.rangeIndex==1&&a.chunkIndexthis.chunkEnd(a.chunkIndex)||sa.to||s=s&&e<=s+o.length&&o.between(s,e-s,t-s,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return Us.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Us.from(e).goto(t)}static compare(e,t,n,r,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=dp(o,a,n),u=new ts(o,l,s),h=new ts(a,l,s);n.iterGaps((f,c,p)=>pp(u,f,h,c,p,r)),n.empty&&n.length==0&&pp(u,0,h,0,0,r)}static eq(e,t,n=0,r){r==null&&(r=1e9-1);let s=e.filter(h=>!h.isEmpty&&t.indexOf(h)<0),o=t.filter(h=>!h.isEmpty&&e.indexOf(h)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let a=dp(s,o),l=new ts(s,a,0).goto(n),u=new ts(o,a,0).goto(n);for(;;){if(l.to!=u.to||!Bh(l.active,u.active)||l.point&&(!u.point||!l.point.eq(u.point)))return!1;if(l.to>r)return!0;l.next(),u.next()}}static spans(e,t,n,r,s=-1){let o=new ts(e,null,s).goto(t),a=t,l=o.openStart;for(;;){let u=Math.min(o.to,n);if(o.point){let h=o.activeForPoint(o.to),f=o.pointFroma&&(r.span(a,u,o.active,l),l=o.openEnd(u));if(o.to>n)return l+(o.point&&o.to>n?1:0);a=o.to,o.next()}}static of(e,t=!1){let n=new Bn;for(let r of e instanceof Rs?[e]:t?Qk(e):e)n.add(r.from,r.to,r.value);return n.finish()}}Ne.empty=new Ne([],[],null,-1);function Qk(i){if(i.length>1)for(let e=i[0],t=1;t0)return i.slice().sort(Ih);e=n}return i}Ne.empty.nextLayer=Ne.empty;class Bn{finishChunk(e){this.chunks.push(new dc(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new Bn)).add(e,t,n)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(Ne.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=Ne.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function dp(i,e,t){let n=new Map;for(let s of i)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=n&&r.push(new ZO(o,t,n,s));return r.length==1?r[0]:new Us(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let n=this.heap.length>>1;n>=0;n--)ou(this.heap,n);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let n=this.heap.length>>1;n>=0;n--)ou(this.heap,n);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),ou(this.heap,0)}}}function ou(i,e){for(let t=i[e];;){let n=(e<<1)+1;if(n>=i.length)break;let r=i[n];if(n+1=0&&(r=i[n+1],n++),t.compare(r)<0)break;i[n]=t,i[e]=r,e=n}}class ts{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Us.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){vo(this.active,e),vo(this.activeTo,e),vo(this.activeRank,e),this.minActive=gp(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:s}=this.cursor;for(;t-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&vo(n,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&n[r]=0&&!(this.activeRank[n]e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function pp(i,e,t,n,r,s){i.goto(e),t.goto(n);let o=n+r,a=n,l=n-e;for(;;){let u=i.to+l-t.to||i.endSide-t.endSide,h=u<0?i.to+l:t.to,f=Math.min(h,o);if(i.point||t.point?i.point&&t.point&&(i.point==t.point||i.point.eq(t.point))&&Bh(i.activeForPoint(i.to),t.activeForPoint(t.to))||s.comparePoint(a,f,i.point,t.point):f>a&&!Bh(i.active,t.active)&&s.compareRange(a,f,i.active,t.active),h>o)break;a=h,u<=0&&i.next(),u>=0&&t.next()}}function Bh(i,e){if(i.length!=e.length)return!1;for(let t=0;t=e;n--)i[n+1]=i[n];i[e]=t}function gp(i,e){let t=-1,n=1e9;for(let r=0;r=e)return r;if(r==i.length)break;s+=i.charCodeAt(r)==9?t-s%t:1,r=xt(i,r)}return n===!0?-1:i.length}const jh="ͼ",mp=typeof Symbol>"u"?"__"+jh:Symbol.for(jh),Dh=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),yp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class dn{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,a,l,u){let h=[],f=/^@(\w+)\b/.exec(o[0]),c=f&&f[1]=="keyframes";if(f&&a==null)return l.push(o[0]+";");for(let p in a){let v=a[p];if(/&/.test(p))s(p.split(/,\s*/).map(x=>o.map(m=>x.replace(/&/,m))).reduce((x,m)=>x.concat(m)),v,l);else if(v&&typeof v=="object"){if(!f)throw new RangeError("The value of a property ("+p+") should be a primitive value.");s(r(p),v,h,c)}else v!=null&&h.push(p.replace(/_.*/,"").replace(/[A-Z]/g,x=>"-"+x.toLowerCase())+": "+v+";")}(h.length||c)&&l.push((n&&!f&&!u?o.map(n):o).join(", ")+" {"+h.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=yp[mp]||1;return yp[mp]=e+1,jh+e.toString(36)}static mount(e,t){(e[Dh]||new Ak(e)).mount(Array.isArray(t)?t:[t])}}let Op=new Map;class Ak{constructor(e){let t=e.ownerDocument||e,n=t.defaultView;if(!e.head&&e.adoptedStyleSheets&&n.CSSStyleSheet){let r=Op.get(t);if(r)return e.adoptedStyleSheets=[r.sheet,...e.adoptedStyleSheets],e[Dh]=r;this.sheet=new n.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],Op.set(t,this)}else{this.styleTag=t.createElement("style");let r=e.head||e;r.insertBefore(this.styleTag,r.firstChild)}this.modules=[],e[Dh]=this}mount(e){let t=this.sheet,n=0,r=0;for(let s=0;s-1&&(this.modules.splice(a,1),r--,a=-1),a==-1){if(this.modules.splice(r++,0,o),t)for(let l=0;l",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Rk=typeof navigator<"u"&&/Mac/.test(navigator.platform),Uk=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var pt=0;pt<10;pt++)pn[48+pt]=pn[96+pt]=String(pt);for(var pt=1;pt<=24;pt++)pn[pt+111]="F"+pt;for(var pt=65;pt<=90;pt++)pn[pt]=String.fromCharCode(pt+32),$s[pt]=String.fromCharCode(pt);for(var au in pn)$s.hasOwnProperty(au)||($s[au]=pn[au]);function $k(i){var e=Rk&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||Uk&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",t=!e&&i.key||(i.shiftKey?$s:pn)[i.keyCode]||i.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function Ja(i){let e;return i.nodeType==11?e=i.getSelection?i:i.ownerDocument:e=i,e.getSelection()}function Nh(i,e){return e?i==e||i.contains(e.nodeType!=1?e.parentNode:e):!1}function Pk(i){let e=i.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function ma(i,e){if(!e.anchorNode)return!1;try{return Nh(i,e.anchorNode)}catch{return!1}}function Er(i){return i.nodeType==3?Qr(i,0,i.nodeValue.length).getClientRects():i.nodeType==1?i.getClientRects():[]}function Ia(i,e,t,n){return t?_p(i,e,t,n,-1)||_p(i,e,t,n,1):!1}function Ba(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e}function _p(i,e,t,n,r){for(;;){if(i==t&&e==n)return!0;if(e==(r<0?0:gn(i))){if(i.nodeName=="DIV")return!1;let s=i.parentNode;if(!s||s.nodeType!=1)return!1;e=Ba(i)+(r<0?0:1),i=s}else if(i.nodeType==1){if(i=i.childNodes[e+(r<0?-1:0)],i.nodeType==1&&i.contentEditable=="false")return!1;e=r<0?gn(i):0}else return!1}}function gn(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function xl(i,e){let t=e?i.left:i.right;return{left:t,right:t,top:i.top,bottom:i.bottom}}function Jk(i){return{left:0,right:i.innerWidth,top:0,bottom:i.innerHeight}}function Ik(i,e,t,n,r,s,o,a){let l=i.ownerDocument,u=l.defaultView||window;for(let h=i,f=!1;h&&!f;)if(h.nodeType==1){let c,p=h==l.body;if(p)c=Jk(u);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(f=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let m=h.getBoundingClientRect();c={left:m.left,right:m.left+h.clientWidth,top:m.top,bottom:m.top+h.clientHeight}}let v=0,x=0;if(r=="nearest")e.top0&&e.bottom>c.bottom+x&&(x=e.bottom-c.bottom+x+o)):e.bottom>c.bottom&&(x=e.bottom-c.bottom+o,t<0&&e.top-x0&&e.right>c.right+v&&(v=e.right-c.right+v+s)):e.right>c.right&&(v=e.right-c.right+s,t<0&&e.leftt.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.assignedSlot||t.parentNode}else if(t.nodeType==11)t=t.host;else break;return null}class Lk{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?gn(t):0),n,Math.min(e.focusOffset,n?gn(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}}let Kn=null;function FO(i){if(i.setActive)return i.setActive();if(Kn)return i.focus(Kn);let e=[];for(let t=i;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(i.focus(Kn==null?{get preventScroll(){return Kn={preventScroll:!0},!0}}:void 0),!Kn){Kn=!1;for(let t=0;tMath.max(1,i.scrollHeight-i.clientHeight-4)}class kt{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new kt(e.parentNode,Ba(e),t)}static after(e,t){return new kt(e.parentNode,Ba(e)+1,t)}}const pc=[];class Ie{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let n of this.children){if(n==e)return t;t+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(this.flags&2){let n=this.dom,r=null,s;for(let o of this.children){if(o.flags&7){if(!o.dom&&(s=r?r.nextSibling:n.firstChild)){let a=Ie.get(s);(!a||!a.parent&&a.canReuseDOM(o))&&o.reuseDOM(s)}o.sync(e,t),o.flags&=-8}if(s=r?r.nextSibling:n.firstChild,t&&!t.written&&t.node==n&&s!=o.dom&&(t.written=!0),o.dom.parentNode==n)for(;s&&s!=o.dom;)s=bp(s);else n.insertBefore(o.dom,s);r=o.dom}for(s=r?r.nextSibling:n.firstChild,s&&t&&t.node==n&&(t.written=!0);s;)s=bp(s)}else if(this.flags&1)for(let n of this.children)n.flags&7&&(n.sync(e,t),n.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let n;if(e==this.dom)n=this.dom.childNodes[t];else{let r=gn(e)==0?0:t==0?-1:1;for(;;){let s=e.parentNode;if(s==this.dom)break;r==0&&s.firstChild!=s.lastChild&&(e==s.firstChild?r=-1:r=1),e=s}r<0?n=e:n=e.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!Ie.get(n);)n=n.nextSibling;if(!n)return this.length;for(let r=0,s=0;;r++){let o=this.children[r];if(o.dom==n)return s;s+=o.length+o.breakAfter}}domBoundsAround(e,t,n=0){let r=-1,s=-1,o=-1,a=-1;for(let l=0,u=n,h=n;lt)return f.domBoundsAround(e,t,u);if(c>=e&&r==-1&&(r=l,s=u),u>t&&f.dom.parentNode==this.dom){o=l,a=h;break}h=c,u=c+f.breakAfter}return{from:s,to:a<0?n+this.length:a,startDOM:(r?this.children[r-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o=0?this.children[o].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,n=pc){this.markDirty();for(let r=e;rthis.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}}function YO(i,e,t,n,r,s,o,a,l){let{children:u}=i,h=u.length?u[e]:null,f=s.length?s[s.length-1]:null,c=f?f.breakAfter:o;if(!(e==n&&h&&!o&&!c&&s.length<2&&h.merge(t,r,s.length?f:null,t==0,a,l))){if(n0&&(!o&&s.length&&h.merge(t,h.length,s[0],!1,a,0)?h.breakAfter=s.shift().breakAfter:(ts)&&this.lineBreak(),r=o}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,a;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,n),o=this.lineSeparator.length):(a=r.exec(t))&&(s=a.index,o=a[0].length),this.append(t.slice(n,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let l of this.points)l.node==e&&l.pos>this.text.length&&(l.pos-=o-1);n=s+o}}readNode(e){if(e.cmIgnore)return;let t=Ie.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let r=n.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+Math.min(t,n.offset))}}function vp(i){return i.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(i.nodeName)}class Sp{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}let Lt=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Zh=typeof document<"u"?document:{documentElement:{style:{}}};const Fh=/Edge\/(\d+)/.exec(Lt.userAgent),KO=/MSIE \d/.test(Lt.userAgent),Xh=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Lt.userAgent),kl=!!(KO||Xh||Fh),xp=!kl&&/gecko\/(\d+)/i.test(Lt.userAgent),lu=!kl&&/Chrome\/(\d+)/.exec(Lt.userAgent),kp="webkitFontSmoothing"in Zh.documentElement.style,qO=!kl&&/Apple Computer/.test(Lt.vendor),Mp=qO&&(/Mobile\/\w+/.test(Lt.userAgent)||Lt.maxTouchPoints>2);var fe={mac:Mp||/Mac/.test(Lt.platform),windows:/Win/.test(Lt.platform),linux:/Linux|X11/.test(Lt.platform),ie:kl,ie_version:KO?Zh.documentMode||6:Xh?+Xh[1]:Fh?+Fh[1]:0,gecko:xp,gecko_version:xp?+(/Firefox\/(\d+)/.exec(Lt.userAgent)||[0,0])[1]:0,chrome:!!lu,chrome_version:lu?+lu[1]:0,ios:Mp,android:/Android\b/.test(Lt.userAgent),webkit:kp,safari:qO,webkit_version:kp?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:Zh.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const Nk=256;class ji extends Ie{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,n){return this.flags&8||n&&(!(n instanceof ji)||this.length-(t-e)+n.length>Nk||n.flags&8)?!1:(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new ji(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new kt(this.dom,e)}domBoundsAround(e,t,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return Zk(this.dom,e,t)}}class Di extends Ie{constructor(e,t=[],n=0){super(),this.mark=e,this.children=t,this.length=n;for(let r of t)r.setParent(this)}setAttrs(e){if(XO(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,n,r,s,o){return n&&(!(n instanceof Di&&n.mark.eq(this.mark))||e&&s<=0||te&&t.push(n=e&&(r=s),n=l,s++}let o=this.length-e;return this.length=e,r>-1&&(this.children.length=r,this.markDirty()),new Di(this.mark,t,o)}domAtPos(e){return HO(this,e)}coordsAt(e,t){return t0(this,e,t)}}function Zk(i,e,t){let n=i.nodeValue.length;e>n&&(e=n);let r=e,s=e,o=0;e==0&&t<0||e==n&&t>=0?fe.chrome||fe.gecko||(e?(r--,o=1):s=0)?0:a.length-1];return fe.safari&&!o&&l.width==0&&(l=Array.prototype.find.call(a,u=>u.width)||l),o?xl(l,o<0):l||null}class En extends Ie{constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}static create(e,t,n){return new En(e,t,n)}split(e){let t=En.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.dom.contentEditable="false")}getSide(){return this.side}merge(e,t,n,r,s,o){return n&&(!(n instanceof En)||!this.widget.compare(n.widget)||e>0&&s<=0||t0)?kt.before(this.dom):kt.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;let r=this.dom.getClientRects(),s=null;if(!r.length)return null;let o=this.side?this.side<0:e>0;for(let a=o?r.length-1:0;s=r[a],!(e>0?a==0:a==r.length-1||s.top0?kt.before(this.dom):kt.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Te.empty}get isHidden(){return!0}}ji.prototype.children=En.prototype.children=Ar.prototype.children=pc;function HO(i,e){let t=i.dom,{children:n}=i,r=0;for(let s=0;rs&&e0;s--){let o=n[s-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let s=r;s0&&e instanceof Di&&r.length&&(n=r[r.length-1])instanceof Di&&n.mark.eq(e.mark)?e0(n,e.children[0],t-1):(r.push(e),e.setParent(i)),i.length+=e.length}function t0(i,e,t){let n=null,r=-1,s=null,o=-1;function a(u,h){for(let f=0,c=0;f=h&&(p.children.length?a(p,h-c):(!s||s.isHidden&&t>0)&&(v>h||c==v&&p.getSide()>0)?(s=p,o=h-c):(c-1?1:0)!=r.length-(t&&r.indexOf(t)>-1?1:0))return!1;for(let s of n)if(s!=t&&(r.indexOf(s)==-1||i[s]!==e[s]))return!1;return!0}function Wh(i,e,t){let n=null;if(e)for(let r in e)t&&r in t||i.removeAttribute(n=r);if(t)for(let r in t)e&&e[r]==t[r]||i.setAttribute(n=r,t[r]);return!!n}function Xk(i){let e=Object.create(null);for(let t=0;t0?3e8:-4e8:t>0?1e8:-1e8,new mn(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:s,end:o}=i0(e,t);n=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new mn(e,n,r,t,e.widget||null,!0)}static line(e){return new lo(e)}static set(e,t=!1){return Ne.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ge.none=Ne.empty;class ao extends ge{constructor(e){let{start:t,end:n}=i0(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,n;return this==e||e instanceof ao&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((n=e.attrs)===null||n===void 0?void 0:n.class))&&gc(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}ao.prototype.point=!1;class lo extends ge{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof lo&&this.spec.class==e.spec.class&&gc(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}lo.prototype.mapMode=gt.TrackBefore;lo.prototype.point=!0;class mn extends ge{constructor(e,t,n,r,s,o){super(t,n,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?gt.TrackBefore:gt.TrackAfter:gt.TrackDel}get type(){return this.startSide=5||this.widget.lineBreaks>0)}eq(e){return e instanceof mn&&Gk(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}mn.prototype.point=!0;function i0(i,e=!1){let{inclusiveStart:t,inclusiveEnd:n}=i;return t==null&&(t=i.inclusive),n==null&&(n=i.inclusive),{start:t??e,end:n??e}}function Gk(i,e){return i==e||!!(i&&e&&i.compare(e))}function Yh(i,e,t,n=0){let r=t.length-1;r>=0&&t[r]+n>=i?t[r]=Math.max(t[r],e):t.push(i,e)}class Et extends Ie{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,n,r,s,o){if(n){if(!(n instanceof Et))return!1;this.dom||n.transferDOM(this)}return r&&this.setDeco(n?n.attrs:null),zO(this,e,t,n?n.children:[],s,o),!0}split(e){let t=new Et;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i:n,off:r}=this.childPos(e);r&&(t.append(this.children[n].split(r),0),this.children[n].merge(r,this.children[n].length,null,!1,0,0),n++);for(let s=n;s0&&this.children[n-1].length==0;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){gc(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){e0(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=Gh(t,this.attrs||{})),n&&(this.attrs=Gh({class:n},this.attrs||{}))}domAtPos(e){return HO(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?this.flags&4&&(XO(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(Wh(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let r=this.dom.lastChild;for(;r&&Ie.get(r)instanceof Di;)r=r.lastChild;if(!r||!this.length||r.nodeName!="BR"&&((n=Ie.get(r))===null||n===void 0?void 0:n.isEditable)==!1&&(!fe.ios||!this.children.some(s=>s instanceof ji))){let s=document.createElement("BR");s.cmIgnore=!0,this.dom.appendChild(s)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let n of this.children){if(!(n instanceof ji)||/[^ -~]/.test(n.text))return null;let r=Er(n.dom);if(r.length!=1)return null;e+=r[0].width,t=r[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let n=t0(this,e,t);if(!this.children.length&&n&&this.parent){let{heightOracle:r}=this.parent.view.viewState,s=n.bottom-n.top;if(Math.abs(s-r.lineHeight)<2&&r.textHeight=t){if(s instanceof Et)return s;if(o>t)break}r=o+s.breakAfter}return null}}class Rn extends Ie{constructor(e,t,n){super(),this.widget=e,this.length=t,this.type=n,this.breakAfter=0,this.prevWidget=null}merge(e,t,n,r,s,o){return n&&(!(n instanceof Rn)||!this.widget.compare(n.widget)||e>0&&s<=0||t0;){if(this.textOff==this.text.length){let{value:s,lineBreak:o,done:a}=this.cursor.next(this.skip);if(this.skip=0,a)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=s,this.textOff=0}let r=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append(xo(new ji(this.text.slice(this.textOff,this.textOff+r)),t),n),this.atCursorPos=!0,this.textOff+=r,e-=r,n=0}}span(e,t,n,r){this.buildText(t-e,n,r),this.pos=t,this.openStart<0&&(this.openStart=r)}point(e,t,n,r,s,o){if(this.disallowBlockEffectsFor[o]&&n instanceof mn){if(n.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let a=t-e;if(n instanceof mn)if(n.block){let{type:l}=n;l==Ke.WidgetAfter&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Rn(n.widget||new Cp("div"),a,l))}else{let l=En.create(n.widget||new Cp("span"),a,a?0:n.startSide),u=this.atCursorPos&&!l.isEditable&&s<=r.length&&(e0),h=!l.isEditable&&(er.length||n.startSide<=0),f=this.getLine();this.pendingBuffer==2&&!u&&!l.isEditable&&(this.pendingBuffer=0),this.flushBuffer(r),u&&(f.append(xo(new Ar(1),r),s),s=r.length+Math.max(0,s-r.length)),f.append(xo(l,r),s),this.atCursorPos=h,this.pendingBuffer=h?er.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=r.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);a&&(this.textOff+a<=this.text.length?this.textOff+=a:(this.skip+=a-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=s)}static build(e,t,n,r,s){let o=new ks(e,t,n,s);return o.openEnd=Ne.spans(r,t,n,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function xo(i,e){for(let t of e)i=new Di(t,[i],i.length);return i}class Cp extends Xi{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}const n0=pe.define(),r0=pe.define(),s0=pe.define(),a0=pe.define(),zh=pe.define(),l0=pe.define(),u0=pe.define(),h0=pe.define({combine:i=>i.some(e=>e)}),f0=pe.define({combine:i=>i.some(e=>e)});class La{constructor(e,t="nearest",n="nearest",r=5,s=5){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=s}map(e){return e.empty?this:new La(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin)}}const Ep=Oe.define({map:(i,e)=>i.map(e)});function Xt(i,e,t){let n=i.facet(a0);n.length?n[0](e):window.onerror?window.onerror(String(e),t,void 0,void 0,e):t?console.error(t+":",e):console.error(e)}const Ml=pe.define({combine:i=>i.length?i[0]:!0});let Wk=0;const cs=pe.define();class ut{constructor(e,t,n,r){this.id=e,this.create=t,this.domEventHandlers=n,this.extension=r(this)}static define(e,t){const{eventHandlers:n,provide:r,decorations:s}=t||{};return new ut(Wk++,e,n,o=>{let a=[cs.of(o)];return s&&a.push(Ps.of(l=>{let u=l.plugin(o);return u?s(u):ge.none})),r&&a.push(r(o)),a})}static fromClass(e,t){return ut.define(n=>new e(n),t)}}class uu{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(n){if(Xt(t.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){Xt(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(n){Xt(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const c0=pe.define(),mc=pe.define(),Ps=pe.define(),yc=pe.define(),d0=pe.define();function p0(i){let e=0,t=0,n=0,r=0;for(let s of i.state.facet(d0)){let o=s(i);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(n=Math.max(n,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:t,top:n,bottom:r}}const ds=pe.define();class Gt{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(e){return new Gt(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toAh)break;s+=2}if(!l)return n;new Gt(l.fromA,l.toA,l.fromB,l.toB).addToSet(n),o=l.toA,a=l.toB}}}class ja{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=it.empty(this.startState.doc.length);for(let s of n)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,a,l)=>r.push(new Gt(s,o,a,l))),this.changedRanges=r}static create(e,t,n){return new ja(e,t,n)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}var We=function(i){return i[i.LTR=0]="LTR",i[i.RTL=1]="RTL",i}(We||(We={}));const Vh=We.LTR,Yk=We.RTL;function g0(i){let e=[];for(let t=0;t=t){if(a.level==n)return o;(s<0||(r!=0?r<0?a.fromt:e[s].level>a.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}const De=[];function Hk(i,e){let t=i.length,n=e==Vh?1:2,r=e==Vh?2:1;if(!i||n==1&&!qk.test(i))return m0(t);for(let o=0,a=n,l=n;o=0;c-=3)if(gi[c+1]==-h){let p=gi[c+2],v=p&2?n:p&4?p&1?r:n:0;v&&(De[o]=De[gi[c]]=v),a=c;break}}else{if(gi.length==189)break;gi[a++]=o,gi[a++]=u,gi[a++]=l}else if((f=De[o])==2||f==1){let c=f==n;l=c?0:1;for(let p=a-3;p>=0;p-=3){let v=gi[p+2];if(v&2)break;if(c)gi[p+2]|=2;else{if(v&4)break;gi[p+2]|=4}}}for(let o=0;oa;){let h=u,f=De[--u]!=2;for(;u>a&&f==(De[u-1]!=2);)u--;s.push(new Or(u,h,f?2:1))}else s.push(new Or(a,o,0))}else for(let o=0;o0&&t.length&&(t.every(({fromA:a,toA:l})=>lthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0);let n=this.view.inputState.composing<0?null:iM(this.view,e.changes);if(this.hasComposition){this.markedForComposition.clear();let{from:a,to:l}=this.hasComposition;t=new Gt(a,l,e.changes.mapPos(a,-1),e.changes.mapPos(l,1)).addToSet(t.slice())}this.hasComposition=n?{from:n.range.fromB,to:n.range.toB}:null,(fe.ie||fe.chrome)&&!n&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let r=this.decorations,s=this.updateDeco(),o=sM(r,s,e.changes);return t=Gt.extendWithRanges(t,o),!(this.flags&7)&&t.length==0?!1:(this.updateInner(t,e.startState.doc.length,n),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,n){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,n);let{observer:r}=this.view;r.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=fe.chrome||fe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||r.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=-9);let s=[];if(this.view.viewport.from||this.view.viewport.to=0?r[o]:null;if(!a)break;let{fromA:l,toA:u,fromB:h,toB:f}=a,c,p,v,x;if(n&&n.range.fromBh){let S=ks.build(this.view.state.doc,h,n.range.fromB,this.decorations,this.dynamicDecorationMap),T=ks.build(this.view.state.doc,n.range.toB,f,this.decorations,this.dynamicDecorationMap);p=S.breakAtStart,v=S.openStart,x=T.openEnd;let k=this.compositionView(n);T.breakAtStart?k.breakAfter=1:T.content.length&&k.merge(k.length,k.length,T.content[0],!1,T.openStart,0)&&(k.breakAfter=T.content[0].breakAfter,T.content.shift()),S.content.length&&k.merge(0,0,S.content[S.content.length-1],!0,0,S.openEnd)&&S.content.pop(),c=S.content.concat(k).concat(T.content)}else({content:c,breakAtStart:p,openStart:v,openEnd:x}=ks.build(this.view.state.doc,h,f,this.decorations,this.dynamicDecorationMap));let{i:m,off:d}=s.findPos(u,1),{i:b,off:A}=s.findPos(l,-1);YO(this,b,A,m,d,c,p,v,x)}n&&this.fixCompositionDOM(n)}compositionView(e){let t=new ji(e.text.nodeValue);t.flags|=8;for(let{deco:r}of e.marks)t=new Di(r,[t],t.length);let n=new Et;return n.append(t,0),n}fixCompositionDOM(e){let t=(s,o)=>{o.flags|=8,this.markedForComposition.add(o);let a=Ie.get(s);a!=o&&(a&&(a.dom=null),o.setDOM(s))},n=this.childPos(e.range.fromB,1),r=this.children[n.i];t(e.line,r);for(let s=e.marks.length-1;s>=-1;s--)n=r.childPos(n.off,1),r=r.children[n.i],t(s>=0?e.marks[s].node:e.text,r)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let n=this.view.root.activeElement,r=n==this.dom,s=!r&&ma(this.dom,this.view.observer.selectionRange)&&!(n&&this.dom.contains(n));if(!(r||t||s))return;let o=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,l=this.domAtPos(a.anchor),u=a.empty?l:this.domAtPos(a.head);if(fe.gecko&&a.empty&&!this.hasComposition&&tM(l)){let f=document.createTextNode("");this.view.observer.ignore(()=>l.node.insertBefore(f,l.node.childNodes[l.offset]||null)),l=u=new kt(f,0),o=!0}let h=this.view.observer.selectionRange;(o||!h.focusNode||!Ia(l.node,l.offset,h.anchorNode,h.anchorOffset)||!Ia(u.node,u.offset,h.focusNode,h.focusOffset))&&(this.view.observer.ignore(()=>{fe.android&&fe.chrome&&this.dom.contains(h.focusNode)&&oM(h.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let f=Ja(this.view.root);if(f)if(a.empty){if(fe.gecko){let c=nM(l.node,l.offset);if(c&&c!=3){let p=_0(l.node,l.offset,c==1?1:-1);p&&(l=new kt(p,c==1?0:p.nodeValue.length))}}f.collapse(l.node,l.offset),a.bidiLevel!=null&&h.cursorBidiLevel!=null&&(h.cursorBidiLevel=a.bidiLevel)}else if(f.extend){f.collapse(l.node,l.offset);try{f.extend(u.node,u.offset)}catch{}}else{let c=document.createRange();a.anchor>a.head&&([l,u]=[u,l]),c.setEnd(u.node,u.offset),c.setStart(l.node,l.offset),f.removeAllRanges(),f.addRange(c)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(l,u)),this.impreciseAnchor=l.precise?null:new kt(h.anchorNode,h.anchorOffset),this.impreciseHead=u.precise?null:new kt(h.focusNode,h.focusOffset)}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=Ja(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let o=Et.find(this,t.head);if(!o)return;let a=o.posAtStart;if(t.head==a||t.head==a+o.length)return;let l=this.coordsAt(t.head,-1),u=this.coordsAt(t.head,1);if(!l||!u||l.bottom>u.top)return;let h=this.domAtPos(t.head+t.assoc);n.collapse(h.node,h.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=t.from&&n.collapse(r,s)}nearest(e){for(let t=e;t;){let n=Ie.get(t);if(n&&n.rootView==this)return n;t=t.parentNode}return null}posFromDOM(e,t){let n=this.nearest(e);if(!n)throw new RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(e,t)+n.posAtStart}domAtPos(e){let{i:t,off:n}=this.childCursor().findPos(e,-1);for(;to||e==o&&s.type!=Ke.WidgetBefore&&s.type!=Ke.WidgetAfter&&(!r||t==2||this.children[r-1].breakAfter||this.children[r-1].type==Ke.WidgetBefore&&t>-2))return s.coordsAt(e-o,t);n=o}}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,a=-1,l=this.view.textDirection==We.LTR;for(let u=0,h=0;hr)break;if(u>=n){let p=f.dom.getBoundingClientRect();if(t.push(p.height),o){let v=f.dom.lastChild,x=v?Er(v):[];if(x.length){let m=x[x.length-1],d=l?m.right-p.left:p.right-m.left;d>a&&(a=d,this.minWidth=s,this.minWidthFrom=u,this.minWidthTo=c)}}}u=c+f.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?We.RTL:We.LTR}measureTextSize(){for(let s of this.children)if(s instanceof Et){let o=s.measureTextSize();if(o)return o}let e=document.createElement("div"),t,n,r;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let s=Er(e.firstChild)[0];t=e.getBoundingClientRect().height,n=s?s.width/27:7,r=s?s.height:t,e.remove()}),{lineHeight:t,charWidth:n,textHeight:r}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new WO(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],o=s?s.from-1:this.length;if(o>n){let a=t.lineBlockAt(o).bottom-t.lineBlockAt(n).top;e.push(ge.replace({widget:new Ap(a),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!s)break;n=s.to+1}return ge.set(e)}updateDeco(){let e=this.view.state.facet(Ps).map((t,n)=>(this.dynamicDecorationMap[n]=typeof t=="function")?t(this.view):t);for(let t=e.length;tt.anchor?-1:1),r;if(!n)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let s=p0(this.view),o={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom};Ik(this.view.scrollDOM,o,t.head-1)return null;o+=f.text.length}if(a=a.parentNode,!a)return null;let l=Ie.get(a);if(l){r=s=l.posAtStart+o;break}}return{from:r,to:s,node:t}}function iM(i,e){let t=O0(i);if(!t)return null;let{from:n,to:r,node:s}=t,o=e.mapPos(n,-1),a=e.mapPos(r,1),l=s.nodeValue;if(/[\n\r]/.test(l))return null;if(a-o!=l.length){let c=e.mapPos(n,1),p=e.mapPos(r,-1);if(p-c==l.length)o=c,a=p;else if(i.state.doc.sliceString(a-l.length,a)==l)o=a-l.length;else if(i.state.doc.sliceString(o,o+l.length)==l)a=o+l.length;else return null}let{main:u}=i.state.selection;if(i.state.doc.sliceString(o,a)!=l||o>u.head||a0)n=n.childNodes[r-1],r=gn(n);else break}if(t>=0)for(let n=i,r=e;;){if(n.nodeType==3)return n;if(n.nodeType==1&&r=0)n=n.childNodes[r],r=0;else break}return null}function nM(i,e){return i.nodeType!=1?0:(e&&i.childNodes[e-1].contentEditable=="false"?1:0)|(e0;){let u=xt(r.text,o,!1);if(n(r.text.slice(u,o))!=l)break;o=u}for(;ai?e.left-i:Math.max(0,i-e.right)}function uM(i,e){return e.top>i?e.top-i:Math.max(0,i-e.bottom)}function hu(i,e){return i.tope.top+1}function Rp(i,e){return ei.bottom?{top:i.top,left:i.left,right:i.right,bottom:e}:i}function qh(i,e,t){let n,r,s,o,a=!1,l,u,h,f;for(let v=i.firstChild;v;v=v.nextSibling){let x=Er(v);for(let m=0;mA||o==A&&s>b){n=v,r=d,s=b,o=A;let S=A?t0?m0)}b==0?t>d.bottom&&(!h||h.bottomd.top)&&(u=v,f=d):h&&hu(h,d)?h=Up(h,d.bottom):f&&hu(f,d)&&(f=Rp(f,d.top))}}if(h&&h.bottom>=t?(n=l,r=h):f&&f.top<=t&&(n=u,r=f),!n)return{node:i,offset:0};let c=Math.max(r.left,Math.min(r.right,e));if(n.nodeType==3)return $p(n,c,t);if(a&&n.contentEditable!="false")return qh(n,c,t);let p=Array.prototype.indexOf.call(i.childNodes,n)+(e>=(r.left+r.right)/2?1:0);return{node:i,offset:p}}function $p(i,e,t){let n=i.nodeValue.length,r=-1,s=1e9,o=0;for(let a=0;at?h.top-t:t-h.bottom)-1;if(h.left-1<=e&&h.right+1>=e&&f=(h.left+h.right)/2,p=c;if((fe.chrome||fe.gecko)&&Qr(i,a).getBoundingClientRect().left==h.right&&(p=!c),f<=0)return{node:i,offset:a+(p?1:0)};r=a+(p?1:0),s=f}}}return{node:i,offset:r>-1?r:o>0?i.nodeValue.length:0}}function w0(i,e,t,n=-1){var r,s;let o=i.contentDOM.getBoundingClientRect(),a=o.top+i.viewState.paddingTop,l,{docHeight:u}=i.viewState,{x:h,y:f}=e,c=f-a;if(c<0)return 0;if(c>u)return i.state.doc.length;for(let S=i.viewState.heightOracle.textHeight/2,T=!1;l=i.elementAtHeight(c),l.type!=Ke.Text;)for(;c=n>0?l.bottom+S:l.top-S,!(c>=0&&c<=u);){if(T)return t?null:0;T=!0,n=-n}f=a+c;let p=l.from;if(pi.viewport.to)return i.viewport.to==i.state.doc.length?i.state.doc.length:t?null:Pp(i,o,l,h,f);let v=i.dom.ownerDocument,x=i.root.elementFromPoint?i.root:v,m=x.elementFromPoint(h,f);m&&!i.contentDOM.contains(m)&&(m=null),m||(h=Math.max(o.left+1,Math.min(o.right-1,h)),m=x.elementFromPoint(h,f),m&&!i.contentDOM.contains(m)&&(m=null));let d,b=-1;if(m&&((r=i.docView.nearest(m))===null||r===void 0?void 0:r.isEditable)!=!1){if(v.caretPositionFromPoint){let S=v.caretPositionFromPoint(h,f);S&&({offsetNode:d,offset:b}=S)}else if(v.caretRangeFromPoint){let S=v.caretRangeFromPoint(h,f);S&&({startContainer:d,startOffset:b}=S,(!i.contentDOM.contains(d)||fe.safari&&hM(d,b,h)||fe.chrome&&fM(d,b,h))&&(d=void 0))}}if(!d||!i.docView.dom.contains(d)){let S=Et.find(i.docView,p);if(!S)return c>l.top+l.height/2?l.to:l.from;({node:d,offset:b}=qh(S.dom,h,f))}let A=i.docView.nearest(d);if(!A)return null;if(A.isWidget&&((s=A.dom)===null||s===void 0?void 0:s.nodeType)==1){let S=A.dom.getBoundingClientRect();return e.yi.defaultLineHeight*1.5){let a=i.viewState.heightOracle.textHeight,l=Math.floor((r-t.top-(i.defaultLineHeight-a)*.5)/a);s+=l*i.viewState.heightOracle.lineLength}let o=i.state.sliceDoc(t.from,t.to);return t.from+Lh(o,s,i.state.tabSize)}function hM(i,e,t){let n;if(i.nodeType!=3||e!=(n=i.nodeValue.length))return!1;for(let r=i.nextSibling;r;r=r.nextSibling)if(r.nodeType!=1||r.nodeName!="BR")return!1;return Qr(i,n-1,n).getBoundingClientRect().left>t}function fM(i,e,t){if(e!=0)return!1;for(let r=i;;){let s=r.parentNode;if(!s||s.nodeType!=1||s.firstChild!=r)return!1;if(s.classList.contains("cm-line"))break;r=s}let n=i.nodeType==1?i.getBoundingClientRect():Qr(i,0,Math.max(i.nodeValue.length,1)).getBoundingClientRect();return t-n.left>5}function Hh(i,e){let t=i.lineBlockAt(e);if(Array.isArray(t.type)){for(let n of t.type)if(n.to>e||n.to==e&&(n.to==t.to||n.type==Ke.Text))return n}return t}function cM(i,e,t,n){let r=Hh(i,e.head),s=!n||r.type!=Ke.Text||!(i.lineWrapping||r.widgetLineBreaks)?null:i.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=i.dom.getBoundingClientRect(),a=i.textDirectionAt(r.from),l=i.posAtCoords({x:t==(a==We.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(l!=null)return K.cursor(l,t?-1:1)}return K.cursor(t?r.to:r.from,t?-1:1)}function Jp(i,e,t,n){let r=i.state.doc.lineAt(e.head),s=i.bidiSpans(r),o=i.textDirectionAt(r.from);for(let a=e,l=null;;){let u=eM(r,s,o,a,t),h=y0;if(!u){if(r.number==(t?i.state.doc.lines:1))return a;h=` -`,r=i.state.doc.line(r.number+(t?1:-1)),s=i.bidiSpans(r),u=K.cursor(t?r.from:r.to)}if(l){if(!l(h))return a}else{if(!n)return u;l=n(h)}a=u}}function dM(i,e,t){let n=i.state.charCategorizer(e),r=n(t);return s=>{let o=n(s);return r==je.Space&&(r=o),r==o}}function pM(i,e,t,n){let r=e.head,s=t?1:-1;if(r==(t?i.state.doc.length:0))return K.cursor(r,e.assoc);let o=e.goalColumn,a,l=i.contentDOM.getBoundingClientRect(),u=i.coordsAtPos(r),h=i.documentTop;if(u)o==null&&(o=u.left-l.left),a=s<0?u.top:u.bottom;else{let p=i.viewState.lineBlockAt(r);o==null&&(o=Math.min(l.right-l.left,i.defaultCharacterWidth*(r-p.from))),a=(s<0?p.top:p.bottom)+h}let f=l.left+o,c=n??i.viewState.heightOracle.textHeight>>1;for(let p=0;;p+=10){let v=a+(c+p)*s,x=w0(i,{x:f,y:v},!1,s);if(vl.bottom||(s<0?xr))return K.cursor(x,e.assoc,void 0,o)}}function ya(i,e,t){for(;;){let n=0;for(let r of i)r.between(e-1,e+1,(s,o,a)=>{if(e>s&&er(i)),t.from,e.head>t.from?-1:1);return n==t.from?t:K.cursor(n,n{this.ignoreDuringComposition(r)||r.type=="keydown"&&this.keydown(e,r)||(this.mustFlushObserver(r)&&e.observer.forceFlush(),this.runCustomHandlers(r.type,e,r)?r.preventDefault():n(e,r))};for(let n in tt){let r=tt[n];e.contentDOM.addEventListener(n,s=>{Ip(e,s)&&t(r,s)},ef[n]),this.registeredEvents.push(n)}e.scrollDOM.addEventListener("mousedown",n=>{if(n.target==e.scrollDOM&&n.clientY>e.contentDOM.getBoundingClientRect().bottom&&(t(tt.mousedown,n),!n.defaultPrevented&&n.button==2)){let r=e.contentDOM.style.minHeight;e.contentDOM.style.minHeight="100%",setTimeout(()=>e.contentDOM.style.minHeight=r,200)}}),e.scrollDOM.addEventListener("drop",n=>{n.target==e.scrollDOM&&n.clientY>e.contentDOM.getBoundingClientRect().bottom&&t(tt.drop,n)}),fe.chrome&&fe.chrome_version==102&&e.scrollDOM.addEventListener("wheel",()=>{this.chromeScrollHack<0?e.contentDOM.style.pointerEvents="none":window.clearTimeout(this.chromeScrollHack),this.chromeScrollHack=setTimeout(()=>{this.chromeScrollHack=-1,e.contentDOM.style.pointerEvents=""},100)},{passive:!0}),this.notifiedFocused=e.hasFocus,fe.safari&&e.contentDOM.addEventListener("input",()=>null)}setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}ensureHandlers(e,t){var n;let r;this.customHandlers=[];for(let s of t)if(r=(n=s.update(e).spec)===null||n===void 0?void 0:n.domEventHandlers){this.customHandlers.push({plugin:s.value,handlers:r});for(let o in r)this.registeredEvents.indexOf(o)<0&&o!="scroll"&&(this.registeredEvents.push(o),e.contentDOM.addEventListener(o,a=>{Ip(e,a)&&this.runCustomHandlers(o,e,a)&&a.preventDefault()}))}}runCustomHandlers(e,t,n){for(let r of this.customHandlers){let s=r.handlers[e];if(s)try{if(s.call(r.plugin,n,t)||n.defaultPrevented)return!0}catch(o){Xt(t.state,o)}}return!1}runScrollHandlers(e,t){this.lastScrollTop=e.scrollDOM.scrollTop,this.lastScrollLeft=e.scrollDOM.scrollLeft;for(let n of this.customHandlers){let r=n.handlers.scroll;if(r)try{r.call(n.plugin,t,e)}catch(s){Xt(e.state,s)}}}keydown(e,t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&Date.now()r.keyCode==t.keyCode))&&!t.ctrlKey||mM.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(this.pendingIOSKey=n||t,setTimeout(()=>this.flushIOSKey(e),250),!0):!1}flushIOSKey(e){let t=this.pendingIOSKey;return t?(this.pendingIOSKey=void 0,yr(e.contentDOM,t.key,t.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:fe.safari&&!fe.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}mustFlushObserver(e){return e.type=="keydown"&&e.keyCode!=229}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.mouseSelection&&this.mouseSelection.update(e),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}const b0=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],mM="dthko",v0=[16,17,18,20,91,92,224,225],ko=6;function Mo(i){return Math.max(0,i)*.7+8}function yM(i,e){return Math.max(Math.abs(i.clientX-e.clientX),Math.abs(i.clientY-e.clientY))}class OM{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParent=Bk(e.contentDOM),this.atoms=e.state.facet(yc).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(ke.allowMultipleSelections)&&_M(e,t),this.dragging=bM(e,t)&&M0(t)==1?null:!1}start(e){this.dragging===!1&&(e.preventDefault(),this.select(e))}move(e){var t;if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&yM(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=((t=this.scrollParent)===null||t===void 0?void 0:t.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},o=p0(this.view);e.clientX-o.left<=s.left+ko?n=-Mo(s.left-e.clientX):e.clientX+o.right>=s.right-ko&&(n=Mo(e.clientX-s.right)),e.clientY-o.top<=s.top+ko?r=-Mo(s.top-e.clientY):e.clientY+o.bottom>=s.bottom-ko&&(r=Mo(e.clientY-s.bottom)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let n=0;nthis.select(this.lastEvent),20)}}function _M(i,e){let t=i.state.facet(n0);return t.length?t[0](e):fe.mac?e.metaKey:e.ctrlKey}function wM(i,e){let t=i.state.facet(r0);return t.length?t[0](e):fe.mac?!e.altKey:!e.ctrlKey}function bM(i,e){let{main:t}=i.state.selection;if(t.empty)return!1;let n=Ja(i.root);if(!n||n.rangeCount==0)return!0;let r=n.getRangeAt(0).getClientRects();for(let s=0;s=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function Ip(i,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,n;t!=i.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(n=Ie.get(t))&&n.ignoreEvent(e))return!1;return!0}const tt=Object.create(null),ef=Object.create(null),S0=fe.ie&&fe.ie_version<15||fe.ios&&fe.webkit_version<604;function vM(i){let e=i.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{i.focus(),t.remove(),x0(i,t.value)},50)}function x0(i,e){let{state:t}=i,n,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(tf!=null&&t.selection.ranges.every(l=>l.empty)&&tf==s.toString()){let l=-1;n=t.changeByRange(u=>{let h=t.doc.lineAt(u.from);if(h.from==l)return{range:u};l=h.from;let f=t.toText((o?s.line(r++).text:e)+t.lineBreak);return{changes:{from:h.from,insert:f},range:K.cursor(u.from+f.length)}})}else o?n=t.changeByRange(l=>{let u=s.line(r++);return{changes:{from:l.from,to:l.to,insert:u.text},range:K.cursor(l.from+u.length)}}):n=t.replaceSelection(s);i.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}tt.keydown=(i,e)=>{i.inputState.setSelectionOrigin("select"),e.keyCode==27&&(i.inputState.lastEscPress=Date.now())};tt.touchstart=(i,e)=>{i.inputState.lastTouchTime=Date.now(),i.inputState.setSelectionOrigin("select.pointer")};tt.touchmove=i=>{i.inputState.setSelectionOrigin("select.pointer")};ef.touchstart=ef.touchmove={passive:!0};tt.mousedown=(i,e)=>{if(i.observer.flush(),i.inputState.lastTouchTime>Date.now()-2e3)return;let t=null;for(let n of i.state.facet(s0))if(t=n(i,e),t)break;if(!t&&e.button==0&&(t=kM(i,e)),t){let n=!i.hasFocus;i.inputState.startMouseSelection(new OM(i,e,t,n)),n&&i.observer.ignore(()=>FO(i.contentDOM)),i.inputState.mouseSelection&&i.inputState.mouseSelection.start(e)}};function Bp(i,e,t,n){if(n==1)return K.cursor(e,t);if(n==2)return aM(i.state,e,t);{let r=Et.find(i.docView,e),s=i.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,a=r?r.posAtEnd:s.to;return ai>=e.top&&i<=e.bottom,Lp=(i,e,t)=>k0(e,t)&&i>=t.left&&i<=t.right;function SM(i,e,t,n){let r=Et.find(i.docView,e);if(!r)return 1;let s=e-r.posAtStart;if(s==0)return 1;if(s==r.length)return-1;let o=r.coordsAt(s,-1);if(o&&Lp(t,n,o))return-1;let a=r.coordsAt(s,1);return a&&Lp(t,n,a)?1:o&&k0(n,o)?-1:1}function jp(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:SM(i,t,e.clientX,e.clientY)}}const xM=fe.ie&&fe.ie_version<=11;let Dp=null,Np=0,Zp=0;function M0(i){if(!xM)return i.detail;let e=Dp,t=Zp;return Dp=i,Zp=Date.now(),Np=!e||t>Date.now()-400&&Math.abs(e.clientX-i.clientX)<2&&Math.abs(e.clientY-i.clientY)<2?(Np+1)%3:1}function kM(i,e){let t=jp(i,e),n=M0(e),r=i.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,a){let l=jp(i,s),u,h=Bp(i,l.pos,l.bias,n);if(t.pos!=l.pos&&!o){let f=Bp(i,t.pos,t.bias,n),c=Math.min(f.from,h.from),p=Math.max(f.to,h.to);h=c1&&(u=MM(r,l.pos))?u:a?r.addRange(h):K.create([h])}}}function MM(i,e){for(let t=0;t=e)return K.create(i.ranges.slice(0,t).concat(i.ranges.slice(t+1)),i.mainIndex==t?0:i.mainIndex-(i.mainIndex>t?1:0))}return null}tt.dragstart=(i,e)=>{let{selection:{main:t}}=i.state,{mouseSelection:n}=i.inputState;n&&(n.dragging=t),e.dataTransfer&&(e.dataTransfer.setData("Text",i.state.sliceDoc(t.from,t.to)),e.dataTransfer.effectAllowed="copyMove")};function Fp(i,e,t,n){if(!t)return;let r=i.posAtCoords({x:e.clientX,y:e.clientY},!1);e.preventDefault();let{mouseSelection:s}=i.inputState,o=n&&s&&s.dragging&&wM(i,e)?{from:s.dragging.from,to:s.dragging.to}:null,a={from:r,insert:t},l=i.state.changes(o?[o,a]:a);i.focus(),i.dispatch({changes:l,selection:{anchor:l.mapPos(r,-1),head:l.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"})}tt.drop=(i,e)=>{if(!e.dataTransfer)return;if(i.state.readOnly)return e.preventDefault();let t=e.dataTransfer.files;if(t&&t.length){e.preventDefault();let n=Array(t.length),r=0,s=()=>{++r==t.length&&Fp(i,e,n.filter(o=>o!=null).join(i.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(n[o]=a.result),s()},a.readAsText(t[o])}}else Fp(i,e,e.dataTransfer.getData("Text"),!0)};tt.paste=(i,e)=>{if(i.state.readOnly)return e.preventDefault();i.observer.flush();let t=S0?null:e.clipboardData;t?(x0(i,t.getData("text/plain")||t.getData("text/uri-text")),e.preventDefault()):vM(i)};function TM(i,e){let t=i.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),i.focus()},50)}function CM(i){let e=[],t=[],n=!1;for(let r of i.selection.ranges)r.empty||(e.push(i.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of i.selection.ranges){let o=i.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(i.doc.length,o.to+1)})),r=o.number}n=!0}return{text:e.join(i.lineBreak),ranges:t,linewise:n}}let tf=null;tt.copy=tt.cut=(i,e)=>{let{text:t,ranges:n,linewise:r}=CM(i.state);if(!t&&!r)return;tf=r?t:null;let s=S0?null:e.clipboardData;s?(e.preventDefault(),s.clearData(),s.setData("text/plain",t)):TM(i,t),e.type=="cut"&&!i.state.readOnly&&i.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"})};const T0=Zi.define();function C0(i,e){let t=[];for(let n of i.facet(u0)){let r=n(i,e);r&&t.push(r)}return t?i.update({effects:t,annotations:T0.of(!0)}):null}function E0(i){setTimeout(()=>{let e=i.hasFocus;if(e!=i.inputState.notifiedFocused){let t=C0(i.state,e);t?i.dispatch(t):i.update([])}},10)}tt.focus=i=>{i.inputState.lastFocusTime=Date.now(),!i.scrollDOM.scrollTop&&(i.inputState.lastScrollTop||i.inputState.lastScrollLeft)&&(i.scrollDOM.scrollTop=i.inputState.lastScrollTop,i.scrollDOM.scrollLeft=i.inputState.lastScrollLeft),E0(i)};tt.blur=i=>{i.observer.clearSelectionRange(),E0(i)};tt.compositionstart=tt.compositionupdate=i=>{i.inputState.compositionFirstChange==null&&(i.inputState.compositionFirstChange=!0),i.inputState.composing<0&&(i.inputState.composing=0)};tt.compositionend=i=>{i.inputState.composing=-1,i.inputState.compositionEndedAt=Date.now(),i.inputState.compositionPendingKey=!0,i.inputState.compositionPendingChange=i.observer.pendingRecords().length>0,i.inputState.compositionFirstChange=null,fe.chrome&&fe.android?i.observer.flushSoon():i.inputState.compositionPendingChange?Promise.resolve().then(()=>i.observer.flush()):setTimeout(()=>{i.inputState.composing<0&&i.docView.hasComposition&&i.update([])},50)};tt.contextmenu=i=>{i.inputState.lastContextMenu=Date.now()};tt.beforeinput=(i,e)=>{var t;let n;if(fe.chrome&&fe.android&&(n=b0.find(r=>r.inputType==e.inputType))&&(i.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let r=((t=window.visualViewport)===null||t===void 0?void 0:t.height)||0;setTimeout(()=>{var s;(((s=window.visualViewport)===null||s===void 0?void 0:s.height)||0)>r+10&&i.hasFocus&&(i.contentDOM.blur(),i.focus())},100)}};const Xp=["pre-wrap","normal","pre-line","break-spaces"];class EM{constructor(e){this.lineWrapping=e,this.doc=Te.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Xp.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n-1,l=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=a;if(this.lineWrapping=a,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=s,l){this.heightSamples={};for(let u=0;u0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>Oa&&(e.heightChanged=!0),this.height=t)}replace(e,t,n){return Mt.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let s=this,o=n.doc;for(let a=r.length-1;a>=0;a--){let{fromA:l,toA:u,fromB:h,toB:f}=r[a],c=s.lineAt(l,Be.ByPosNoHeight,n.setDoc(t),0,0),p=c.to>=u?c:s.lineAt(u,Be.ByPosNoHeight,n,0,0);for(f+=p.to-u,u=p.to;a>0&&c.from<=r[a-1].toA;)l=r[a-1].fromA,h=r[a-1].fromB,a--,ls*2){let a=e[t-1];a.break?e.splice(--t,1,a.left,null,a.right):e.splice(--t,1,a.left,a.right),n+=1+a.break,r-=a.size}else if(s>r*2){let a=e[n];a.break?e.splice(n,1,a.left,null,a.right):e.splice(n,1,a.left,a.right),n+=2+a.break,s-=a.size}else break;else if(r=s&&o(this.blockAt(0,n,r,s))}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setHeight(e,r.heights[r.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class It extends Q0{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,r){return new xi(r,this.length,n,this.height,this.breaks)}replace(e,t,n){let r=n[0];return n.length==1&&(r instanceof It||r instanceof ct&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof ct?r=new It(r.length,this.height):r.height=this.height,this.outdated||(r.outdated=!1),r):Mt.of(n)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setHeight(e,r.heights[r.index++]):(n||this.outdated)&&this.setHeight(e,Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class ct extends Mt{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-n+1,o,a=0;if(e.lineWrapping){let l=Math.min(this.height,e.lineHeight*s);o=l/s,this.length>s+1&&(a=(this.height-l)/(this.length-s-1))}else o=this.height/s;return{firstLine:n,lastLine:r,perLine:o,perChar:a}}blockAt(e,t,n,r){let{firstLine:s,lastLine:o,perLine:a,perChar:l}=this.heightMetrics(t,r);if(t.lineWrapping){let u=r+Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length),h=t.doc.lineAt(u),f=a+h.length*l,c=Math.max(n,e-f/2);return new xi(h.from,h.length,c,f,0)}else{let u=Math.max(0,Math.min(o-s,Math.floor((e-n)/a))),{from:h,length:f}=t.doc.line(s+u);return new xi(h,f,n+a*u,a,0)}}lineAt(e,t,n,r,s){if(t==Be.ByHeight)return this.blockAt(e,n,r,s);if(t==Be.ByPosNoHeight){let{from:p,to:v}=n.doc.lineAt(e);return new xi(p,v-p,0,0,0)}let{firstLine:o,perLine:a,perChar:l}=this.heightMetrics(n,s),u=n.doc.lineAt(e),h=a+u.length*l,f=u.number-o,c=r+a*f+l*(u.from-s-f);return new xi(u.from,u.length,Math.max(r,Math.min(c,r+this.height-h)),h,0)}forEachLine(e,t,n,r,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:a,perLine:l,perChar:u}=this.heightMetrics(n,s);for(let h=e,f=r;h<=t;){let c=n.doc.lineAt(h);if(h==e){let v=c.number-a;f+=l*v+u*(e-s-v)}let p=l+u*c.length;o(new xi(c.from,c.length,f,p,0)),f+=p,h=c.to+1}}replace(e,t,n){let r=this.length-t;if(r>0){let s=n[n.length-1];s instanceof ct?n[n.length-1]=new ct(s.length+r):n.push(null,new ct(r-1))}if(e>0){let s=n[0];s instanceof ct?n[0]=new ct(e+s.length):n.unshift(new ct(e-1),null)}return Mt.of(n)}decomposeLeft(e,t){t.push(new ct(e-1),null)}decomposeRight(e,t){t.push(null,new ct(this.length-e-1))}updateHeight(e,t=0,n=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],a=Math.max(t,r.from),l=-1;for(r.from>t&&o.push(new ct(r.from-t-1).updateHeight(e,t));a<=s&&r.more;){let h=e.doc.lineAt(a).length;o.length&&o.push(null);let f=r.heights[r.index++];l==-1?l=f:Math.abs(f-l)>=Oa&&(l=-2);let c=new It(h,f);c.outdated=!1,o.push(c),a+=h+1}a<=s&&o.push(null,new ct(s-a).updateHeight(e,a));let u=Mt.of(o);return(l<0||Math.abs(u.height-this.height)>=Oa||Math.abs(l-this.heightMetrics(e,t).perLine)>=Oa)&&(e.heightChanged=!0),u}else(n||this.outdated)&&(this.setHeight(e,e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class AM extends Mt{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let s=n+this.left.height;return ea))return u;let h=t==Be.ByPosNoHeight?Be.ByPosNoHeight:Be.ByPos;return l?u.join(this.right.lineAt(a,h,n,o,a)):this.left.lineAt(a,h,n,r,s).join(u)}forEachLine(e,t,n,r,s,o){let a=r+this.left.height,l=s+this.left.length+this.break;if(this.break)e=l&&this.right.forEachLine(e,t,n,a,l,o);else{let u=this.lineAt(l,Be.ByPos,n,r,s);e=e&&u.from<=t&&o(u),t>u.to&&this.right.forEachLine(u.to+1,t,n,a,l,o)}}replace(e,t,n){let r=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let a of n)s.push(a);if(e>0&&Gp(s,o-1),t=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e2*t.size||t.size>2*e.size?Mt.of(this.break?[e,null,t]:[e,t]):(this.left=e,this.right=t,this.height=e.height+t.height,this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:s,right:o}=this,a=t+s.length+this.break,l=null;return r&&r.from<=t+s.length&&r.more?l=s=s.updateHeight(e,t,n,r):s.updateHeight(e,t,n),r&&r.from<=a+o.length&&r.more?l=o=o.updateHeight(e,a,n,r):o.updateHeight(e,a,n),l?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Gp(i,e){let t,n;i[e]==null&&(t=i[e-1])instanceof ct&&(n=i[e+1])instanceof ct&&i.splice(e-1,3,new ct(t.length+1+n.length))}const RM=5;class Oc{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let n=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof It?r.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new It(n-this.pos,-1)),this.writtenTo=n,t>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e=RM)&&this.addLineDeco(r,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new It(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new ct(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof It)return e;let t=new It(0,-1);return this.nodes.push(t),t}addBlock(e){var t;this.enterLine();let n=(t=e.deco)===null||t===void 0?void 0:t.type;n==Ke.WidgetAfter&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n!=Ke.WidgetBefore&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof It)&&!this.isCovered?this.nodes.push(new It(0,-1)):(this.writtenToh.clientHeight||h.scrollWidth>h.clientWidth)&&f.overflow!="visible"){let c=h.getBoundingClientRect();s=Math.max(s,c.left),o=Math.min(o,c.right),a=Math.max(a,c.top),l=u==i.parentNode?c.bottom:Math.min(l,c.bottom)}u=f.position=="absolute"||f.position=="fixed"?h.offsetParent:h.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:a-(t.top+e),bottom:Math.max(a,l)-(t.top+e)}}function JM(i,e){let t=i.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class cu{constructor(e,t,n){this.from=e,this.to=t,this.size=n}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;ntypeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new EM(t),this.stateDeco=e.facet(Ps).filter(n=>typeof n!="function"),this.heightMap=Mt.empty().applyChanges(this.stateDeco,Te.empty,this.heightOracle.setDoc(e.doc),[new Gt(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ge.set(this.lineGaps.map(n=>n.draw(!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new To(s,o))}}this.viewports=e.sort((n,r)=>n.from-r.from),this.scaler=this.heightMap.height<=7e6?Yp:new jM(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(this.scaler.scale==1?e:ps(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(Ps).filter(h=>typeof h!="function");let r=e.changedRanges,s=Gt.extendWithRanges(r,UM(n,this.stateDeco,e?e.changes:it.empty(this.state.doc.length))),o=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=o&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let l=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.headl.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,t));let u=!e.changes.empty||e.flags&2||l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,this.updateForViewport(),u&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(f0)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,s=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?We.RTL:We.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),a=t.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let u=0,h=0,f=parseInt(n.paddingTop)||0,c=parseInt(n.paddingBottom)||0;(this.paddingTop!=f||this.paddingBottom!=c)&&(this.paddingTop=f,this.paddingBottom=c,u|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,u|=8),this.scrollTop!=e.scrollDOM.scrollTop&&(this.scrollAnchorHeight=-1,this.scrollTop=e.scrollDOM.scrollTop),this.scrolledToBottom=GO(e.scrollDOM);let p=(this.printing?JM:PM)(t,this.paddingTop),v=p.top-this.pixelViewport.top,x=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let m=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(m!=this.inView&&(this.inView=m,m&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let d=a.width;if((this.contentDOMWidth!=d||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,u|=8),l){let A=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(A)&&(o=!0),o||r.lineWrapping&&Math.abs(d-this.contentDOMWidth)>r.charWidth){let{lineHeight:S,charWidth:T,textHeight:k}=e.docView.measureTextSize();o=S>0&&r.refresh(s,S,T,k,d/T,A),o&&(e.docView.minWidth=0,u|=8)}v>0&&x>0?h=Math.max(v,x):v<0&&x<0&&(h=Math.min(v,x)),r.heightChanged=!1;for(let S of this.viewports){let T=S.from==this.viewport.from?A:e.docView.measureVisibleLineHeights(S);this.heightMap=(o?Mt.empty().applyChanges(this.stateDeco,Te.empty,this.heightOracle,[new Gt(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new QM(S.from,T))}r.heightChanged&&(u|=2)}let b=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return b&&(this.viewport=this.getViewport(h,this.scrollTarget)),this.updateForViewport(),(u&2||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:a}=this,l=new To(r.lineAt(o-n*1e3,Be.ByHeight,s,0,0).from,r.lineAt(a+(1-n)*1e3,Be.ByHeight,s,0,0).to);if(t){let{head:u}=t.range;if(ul.to){let h=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=r.lineAt(u,Be.ByPos,s,0,0),c;t.y=="center"?c=(f.top+f.bottom)/2-h/2:t.y=="start"||t.y=="nearest"&&u=a+Math.max(10,Math.min(n,250)))&&r>o-2*1e3&&s>1,o=r<<1;if(this.defaultTextDirection!=We.LTR&&!n)return[];let a=[],l=(u,h,f,c)=>{if(h-uu&&mm.from>=f.from&&m.to<=f.to&&Math.abs(m.from-u)m.fromd));if(!x){if(hm.from<=h&&m.to>=h)){let m=t.moveToLineBoundary(K.cursor(h),!1,!0).head;m>u&&(h=m)}x=new cu(u,h,this.gapSize(f,u,h,c))}a.push(x)};for(let u of this.viewportLines){if(u.lengthu.from&&l(u.from,c,u,h),pt.draw(this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];Ne.spans(e,this.viewport.from,this.viewport.to,{span(r,s){t.push({from:r,to:s})},point(){}},20);let n=t.length!=this.visibleRanges.length||this.visibleRanges.some((r,s)=>r.from!=t[s].from||r.to!=t[s].to);return this.visibleRanges=t,n?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||ps(this.heightMap.lineAt(e,Be.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return ps(this.heightMap.lineAt(this.scaler.fromDOM(e),Be.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return ps(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class To{constructor(e,t){this.from=e,this.to=t}}function BM(i,e,t){let n=[],r=i,s=0;return Ne.spans(t,i,e,{span(){},point(o,a){o>r&&(n.push({from:r,to:o}),s+=o-r),r=a}},20),r=1)return e[e.length-1].to;let n=Math.floor(i*t);for(let r=0;;r++){let{from:s,to:o}=e[r],a=o-s;if(n<=a)return s+n;n-=a}}function Eo(i,e){let t=0;for(let{from:n,to:r}of i.ranges){if(e<=r){t+=e-n;break}t+=r-n}return t/i.total}function LM(i,e){for(let t of i)if(e(t))return t}const Yp={toDOM(i){return i},fromDOM(i){return i},scale:1};class jM{constructor(e,t,n){let r=0,s=0,o=0;this.viewports=n.map(({from:a,to:l})=>{let u=t.lineAt(a,Be.ByPos,e,0,0).top,h=t.lineAt(l,Be.ByPos,e,0,0).bottom;return r+=h-u,{from:a,to:l,top:u,bottom:h,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let a of this.viewports)a.domTop=o+(a.top-s)*this.scale,o=a.domBottom=a.domTop+(a.bottom-a.top),s=a.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let s=tps(r,e)):i._content)}const Qo=pe.define({combine:i=>i.join(" ")}),nf=pe.define({combine:i=>i.indexOf(!0)>-1}),rf=dn.newName(),A0=dn.newName(),R0=dn.newName(),U0={"&light":"."+A0,"&dark":"."+R0};function sf(i,e,t){return new dn(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,r=>{if(r=="&")return i;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):i+" "+n}})}const DM=sf("."+rf,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",left:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},U0);class NM{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,n,0))){let a=s||o?[]:FM(e),l=new VO(a,e.state);l.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=l.text,this.newSel=XM(a,this.bounds.from)}else{let a=e.observer.selectionRange,l=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!Nh(e.contentDOM,a.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),u=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!Nh(e.contentDOM,a.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset);this.newSel=K.single(u,l)}}}function $0(i,e){let t,{newSel:n}=e,r=i.state.selection.main,s=i.inputState.lastKeyTime>Date.now()-100?i.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:a}=e.bounds,l=r.from,u=null;(s===8||fe.android&&e.text.length=r.from&&t.to<=r.to&&(t.from!=r.from||t.to!=r.to)&&r.to-r.from-(t.to-t.from)<=4?t={from:r.from,to:r.to,insert:i.state.doc.slice(r.from,t.from).append(t.insert).append(i.state.doc.slice(t.to,r.to))}:(fe.mac||fe.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&i.contentDOM.getAttribute("autocorrect")=="off"?(n&&t.insert.length==2&&(n=K.single(n.main.anchor-1,n.main.head-1)),t={from:r.from,to:r.to,insert:Te.of([" "])}):fe.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==` - `&&i.lineWrapping&&(n&&(n=K.single(n.main.anchor-1,n.main.head-1)),t={from:r.from,to:r.to,insert:Te.of([" "])}),t){let o=i.state;if(fe.ios&&i.inputState.flushIOSKey(i)||fe.android&&(t.from==r.from&&t.to==r.to&&t.insert.length==1&&t.insert.lines==2&&yr(i.contentDOM,"Enter",13)||(t.from==r.from-1&&t.to==r.to&&t.insert.length==0||s==8&&t.insert.lengthh(i,t.from,t.to,a)))return!0;i.inputState.composing>=0&&i.inputState.composing++;let l;if(t.from>=r.from&&t.to<=r.to&&t.to-t.from>=(r.to-r.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&i.inputState.composing<0){let h=r.fromt.to?o.sliceDoc(t.to,r.to):"";l=o.replaceSelection(i.state.toText(h+t.insert.sliceString(0,void 0,i.state.lineBreak)+f))}else{let h=o.changes(t),f=n&&n.main.to<=h.newLength?n.main:void 0;if(o.selection.ranges.length>1&&i.inputState.composing>=0&&t.to<=r.to&&t.to>=r.to-10){let c=i.state.sliceDoc(t.from,t.to),p=O0(i)||i.state.doc.lineAt(r.head),v=r.to-t.to,x=r.to-r.from;l=o.changeByRange(m=>{if(m.from==r.from&&m.to==r.to)return{changes:h,range:f||m.map(h)};let d=m.to-v,b=d-c.length;if(m.to-m.from!=x||i.state.sliceDoc(b,d)!=c||p&&m.to>=p.from&&m.from<=p.to)return{range:m};let A=o.changes({from:b,to:d,insert:t.insert}),S=m.to-r.to;return{changes:A,range:f?K.range(Math.max(0,f.anchor+S),Math.max(0,f.head+S)):m.map(A)}})}else l={changes:h,selection:f&&o.selection.replaceRange(f)}}let u="input.type";return(i.composing||i.inputState.compositionPendingChange&&i.inputState.compositionEndedAt>Date.now()-50)&&(i.inputState.compositionPendingChange=!1,u+=".compose",i.inputState.compositionFirstChange&&(u+=".start",i.inputState.compositionFirstChange=!1)),i.dispatch(l,{scrollIntoView:!0,userEvent:u}),!0}else if(n&&!n.main.eq(r)){let o=!1,a="select";return i.inputState.lastSelectionTime>Date.now()-50&&(i.inputState.lastSelectionOrigin=="select"&&(o=!0),a=i.inputState.lastSelectionOrigin),i.dispatch({selection:n,scrollIntoView:o,userEvent:a}),!0}else return!1}function ZM(i,e,t,n){let r=Math.min(i.length,e.length),s=0;for(;s0&&a>0&&i.charCodeAt(o-1)==e.charCodeAt(a-1);)o--,a--;if(n=="end"){let l=Math.max(0,s-Math.min(o,a));t-=o+l-s}if(o=o?s-t:0;s-=l,a=s+(a-o),o=s}else if(a=a?s-t:0;s-=l,o=s+(o-a),a=s}return{from:s,toA:o,toB:a}}function FM(i){let e=[];if(i.root.activeElement!=i.contentDOM)return e;let{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:s}=i.observer.selectionRange;return t&&(e.push(new Sp(t,n)),(r!=t||s!=n)&&e.push(new Sp(r,s))),e}function XM(i,e){if(i.length==0)return null;let t=i[0].pos,n=i.length==2?i[1].pos:t;return t>-1&&n>-1?K.single(t+e,n+e):null}const GM={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},du=fe.ie&&fe.ie_version<=11;class WM{constructor(e){this.view=e,this.active=!1,this.selectionRange=new Lk,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.resizeContent=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let n of t)this.queue.push(n);(fe.ie&&fe.ie_version<=11||fe.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),du&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)this.view.requestMeasure()),this.resizeContent.observe(e.contentDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runScrollHandlers(this.view,e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500)}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(Ml)?n.root.activeElement!=this.dom:!ma(n.dom,r))return;let s=r.anchorNode&&n.docView.nearest(r.anchorNode);if(s&&s.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(fe.ie&&fe.ie_version<=11||fe.android&&fe.chrome)&&!n.state.selection.main.empty&&r.focusNode&&Ia(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=fe.safari&&e.root.nodeType==11&&Pk(this.dom.ownerDocument)==this.dom&&YM(this.view)||Ja(e.root);if(!t||this.selectionRange.eq(t))return!1;let n=ma(this.dom,t);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&yr(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),t==-1?{from:t,to:n}=o:(t=Math.min(o.from,t),n=Math.max(o.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&ma(this.dom,this.selectionRange);return e<0&&!r?null:(e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1,new NM(this.view,e,t,n))}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return!1;let n=this.view.state,r=$0(this.view,t);return this.view.state==n&&this.view.update([]),r}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let n=zp(t,e.previousSibling||e.target.previousSibling,-1),r=zp(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var e,t,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect(),(r=this.resizeContent)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function zp(i,e,t){for(;e;){let n=Ie.get(e);if(n&&n.parent==i)return n;let r=e.parentNode;e=r!=i.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function YM(i){let e=null;function t(l){l.preventDefault(),l.stopImmediatePropagation(),e=l.getTargetRanges()[0]}if(i.contentDOM.addEventListener("beforeinput",t,!0),i.dom.ownerDocument.execCommand("indent"),i.contentDOM.removeEventListener("beforeinput",t,!0),!e)return null;let n=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,a=i.docView.domAtPos(i.state.selection.main.anchor);return Ia(a.node,a.offset,s,o)&&([n,r,s,o]=[s,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}}class he{constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.style.cssText="position: fixed; top: -10000px",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),this._dispatch=e.dispatch||(t=>this.update([t])),this.dispatch=this.dispatch.bind(this),this._root=e.root||jk(e.parent)||document,this.viewState=new Wp(e.state||ke.create(e)),this.plugins=this.state.facet(cs).map(t=>new uu(t));for(let t of this.plugins)t.update(this);this.observer=new WM(this),this.inputState=new gM(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new Qp(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),e.parent&&e.parent.appendChild(this.dom)}get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}dispatch(...e){let t=e.length==1&&e[0]instanceof et?e[0]:this.state.update(...e);this._dispatch(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,n=!1,r,s=this.state;for(let c of e){if(c.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=c.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,a=0,l=null;e.some(c=>c.annotation(T0))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=C0(s,o),l||(a=1));let u=this.observer.delayedAndroidKey,h=null;if(u?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(h=null)):this.observer.clear(),s.facet(ke.phrases)!=this.state.facet(ke.phrases))return this.setState(s);r=ja.create(this,s,e),r.flags|=a;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let c of e){if(f&&(f=f.map(c.changes)),c.scrollIntoView){let{main:p}=c.state.selection;f=new La(p.empty?p:K.cursor(p.head,p.head>p.anchor?-1:1))}for(let p of c.effects)p.is(Ep)&&(f=p.value)}this.viewState.update(r,f),this.bidiCache=Da.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(ds)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(c=>c.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(Qo)!=r.state.facet(Qo)&&(this.viewState.mustMeasureContent=!0),(t||n||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!r.empty)for(let c of this.state.facet(zh))c(r);(l||h)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),h&&!$0(this,h)&&u.force&&yr(this.contentDOM,u.key,u.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new Wp(e),this.plugins=e.facet(cs).map(n=>new uu(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView=new Qp(this),this.inputState.ensureHandlers(this,this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(cs),n=e.state.facet(cs);if(t!=n){let r=[];for(let s of n){let o=t.indexOf(s);if(o<0)r.push(new uu(s));else{let a=this.plugins[o];a.mustUpdate=e,r.push(a)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear(),this.inputState.ensureHandlers(this,this.plugins)}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,{scrollTop:r}=n,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;r!=this.viewState.scrollTop&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0)if(GO(n))s=-1,o=this.viewState.heightMap.height;else{let p=this.viewState.scrollAnchorAt(r);s=p.from,o=p.top}this.updateState=1;let l=this.viewState.measure(this);if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let u=[];l&4||([this.measureRequests,u]=[u,this.measureRequests]);let h=u.map(p=>{try{return p.read(this)}catch(v){return Xt(this.state,v),Vp}}),f=ja.create(this,this.state,[]),c=!1;f.flags|=l,t?t.flags|=l:t=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),c=this.docView.update(f));for(let p=0;p1||v<-1){r=n.scrollTop=r+v,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(zh))a(t)}get themeClasses(){return rf+" "+(this.state.facet(nf)?R0:A0)+" "+this.state.facet(Qo)}updateAttrs(){let e=Kp(this,c0,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(Ml)?"true":"false",class:"cm-content",style:`${fe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Kp(this,mc,t);let n=this.observer.ignore(()=>{let r=Wh(this.contentDOM,this.contentAttrs,t),s=Wh(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let r of n.effects)if(r.is(he.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(ds),dn.mount(this.root,this.styleModules.concat(DM).reverse())}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;tn.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return fu(this,e,Jp(this,e,t,n))}moveByGroup(e,t){return fu(this,e,Jp(this,e,t,n=>dM(this,e.head,n)))}moveToLineBoundary(e,t,n=!0){return cM(this,e,t,n)}moveVertically(e,t,n){return fu(this,e,pM(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),w0(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[Or.find(s,e-r.from,-1,t)];return xl(n,o.dir==We.LTR==t>0)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(h0)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>zM)return m0(e.length);let t=this.textDirectionAt(e.from);for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t)return r.order;let n=Hk(e.text,t);return this.bidiCache.push(new Da(e.from,e.to,t,n)),n}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||fe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{FO(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Ep.of(new La(typeof e=="number"?K.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}static domEventHandlers(e){return ut.define(()=>({}),{eventHandlers:e})}static theme(e,t){let n=dn.newName(),r=[Qo.of(n),ds.of(sf(`.${n}`,e))];return t&&t.dark&&r.push(nf.of(!0)),r}static baseTheme(e){return Zn.lowest(ds.of(sf("."+rf,e,U0)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),r=n&&Ie.get(n)||Ie.get(e);return((t=r==null?void 0:r.rootView)===null||t===void 0?void 0:t.view)||null}}he.styleModule=ds;he.inputHandler=l0;he.focusChangeEffect=u0;he.perLineTextDirection=h0;he.exceptionSink=a0;he.updateListener=zh;he.editable=Ml;he.mouseSelectionStyle=s0;he.dragMovesSelection=r0;he.clickAddsSelectionRange=n0;he.decorations=Ps;he.atomicRanges=yc;he.scrollMargins=d0;he.darkTheme=nf;he.contentAttributes=mc;he.editorAttributes=c0;he.lineWrapping=he.contentAttributes.of({class:"cm-lineWrapping"});he.announce=Oe.define();const zM=4096,Vp={};class Da{constructor(e,t,n,r){this.from=e,this.to=t,this.dir=n,this.order=r}static update(e,t){if(t.empty)return e;let n=[],r=e.length?e[e.length-1].dir:We.LTR;for(let s=Math.max(0,e.length-10);s=0;r--){let s=n[r],o=typeof s=="function"?s(i):s;o&&Gh(o,t)}return t}const VM=fe.mac?"mac":fe.windows?"win":fe.linux?"linux":"key";function KM(i,e){const t=i.split(/-(?!$)/);let n=t[t.length-1];n=="Space"&&(n=" ");let r,s,o,a;for(let l=0;ln.concat(r),[]))),t}function HM(i,e,t){return J0(P0(i.state),e,i,t)}let tn=null;const eT=4e3;function tT(i,e=VM){let t=Object.create(null),n=Object.create(null),r=(o,a)=>{let l=n[o];if(l==null)n[o]=a;else if(l!=a)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,a,l,u,h)=>{var f,c;let p=t[o]||(t[o]=Object.create(null)),v=a.split(/ (?!$)/).map(d=>KM(d,e));for(let d=1;d{let S=tn={view:A,prefix:b,scope:o};return setTimeout(()=>{tn==S&&(tn=null)},eT),!0}]})}let x=v.join(" ");r(x,!1);let m=p[x]||(p[x]={preventDefault:!1,stopPropagation:!1,run:((c=(f=p._any)===null||f===void 0?void 0:f.run)===null||c===void 0?void 0:c.slice())||[]});l&&m.run.push(l),u&&(m.preventDefault=!0),h&&(m.stopPropagation=!0)};for(let o of i){let a=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let u of a){let h=t[u]||(t[u]=Object.create(null));h._any||(h._any={preventDefault:!1,stopPropagation:!1,run:[]});for(let f in h)h[f].run.push(o.any)}let l=o[e]||o.key;if(l)for(let u of a)s(u,l,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(u,"Shift-"+l,o.shift,o.preventDefault,o.stopPropagation)}return t}function J0(i,e,t,n){let r=$k(e),s=dt(r,0),o=Zt(s)==r.length&&r!=" ",a="",l=!1,u=!1,h=!1;tn&&tn.view==t&&tn.scope==n&&(a=tn.prefix+" ",v0.indexOf(e.keyCode)<0&&(u=!0,tn=null));let f=new Set,c=m=>{if(m){for(let d of m.run)if(!f.has(d)&&(f.add(d),d(t,e)))return m.stopPropagation&&(h=!0),!0;m.preventDefault&&(m.stopPropagation&&(h=!0),u=!0)}return!1},p=i[n],v,x;return p&&(c(p[a+Ao(r,e,!o)])?l=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(fe.windows&&e.ctrlKey&&e.altKey)&&(v=pn[e.keyCode])&&v!=r?(c(p[a+Ao(v,e,!0)])||e.shiftKey&&(x=$s[e.keyCode])!=r&&x!=v&&c(p[a+Ao(x,e,!1)]))&&(l=!0):o&&e.shiftKey&&c(p[a+Ao(r,e,!0)])&&(l=!0),!l&&c(p._any)&&(l=!0)),u&&(l=!0),l&&h&&e.stopPropagation(),l}class uo{constructor(e,t,n,r,s){this.className=e,this.left=t,this.top=n,this.width=r,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let r=e.coordsAtPos(n.head,n.assoc||1);if(!r)return[];let s=I0(e);return[new uo(t,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return iT(e,t,n)}}function I0(i){let e=i.scrollDOM.getBoundingClientRect();return{left:(i.textDirection==We.LTR?e.left:e.right-i.scrollDOM.clientWidth)-i.scrollDOM.scrollLeft,top:e.top-i.scrollDOM.scrollTop}}function Hp(i,e,t){let n=K.cursor(e);return{from:Math.max(t.from,i.moveToLineBoundary(n,!1,!0).from),to:Math.min(t.to,i.moveToLineBoundary(n,!0,!0).from),type:Ke.Text}}function iT(i,e,t){if(t.to<=i.viewport.from||t.from>=i.viewport.to)return[];let n=Math.max(t.from,i.viewport.from),r=Math.min(t.to,i.viewport.to),s=i.textDirection==We.LTR,o=i.contentDOM,a=o.getBoundingClientRect(),l=I0(i),u=o.querySelector(".cm-line"),h=u&&window.getComputedStyle(u),f=a.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),c=a.right-(h?parseInt(h.paddingRight):0),p=Hh(i,n),v=Hh(i,r),x=p.type==Ke.Text?p:null,m=v.type==Ke.Text?v:null;if(x&&(i.lineWrapping||p.widgetLineBreaks)&&(x=Hp(i,n,x)),m&&(i.lineWrapping||v.widgetLineBreaks)&&(m=Hp(i,r,m)),x&&m&&x.from==m.from)return b(A(t.from,t.to,x));{let T=x?A(t.from,null,x):S(p,!1),k=m?A(null,t.to,m):S(v,!0),Q=[];return(x||p).to<(m||v).from-(x&&m?1:0)||p.widgetLineBreaks>1&&T.bottom+i.defaultLineHeight/2D&&ee.from=Z)break;te>B&&j(Math.max(Y,B),T==null&&Y<=D,Math.min(te,Z),k==null&&te>=V,N.dir)}if(B=R.to+1,B>=Z)break}return _.length==0&&j(D,T==null,V,k==null,i.textDirection),{top:C,bottom:I,horizontal:_}}function S(T,k){let Q=a.top+(k?T.top:T.bottom);return{top:Q,bottom:Q,horizontal:[]}}}function nT(i,e){return i.constructor==e.constructor&&i.eq(e)}class rT{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(_a)!=e.state.facet(_a)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&e.view.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(_a);for(;t!nT(t,this.drawn[n]))){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let r=t.nextSibling;t.remove(),t=r}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const _a=pe.define();function B0(i){return[ut.define(e=>new rT(e,i)),_a.of(i)]}const L0=!fe.ios,Js=pe.define({combine(i){return Fi(i,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function j0(i={}){return[Js.of(i),sT,oT,aT,f0.of(!0)]}function D0(i){return i.startState.facet(Js)!=i.state.facet(Js)}const sT=B0({above:!0,markers(i){let{state:e}=i,t=e.facet(Js),n=[];for(let r of e.selection.ranges){let s=r==e.selection.main;if(r.empty?!s||L0:t.drawRangeCursor){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",a=r.empty?r:K.cursor(r.head,r.head>r.anchor?-1:1);for(let l of uo.forRange(i,o,a))n.push(l)}}return n},update(i,e){i.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=D0(i);return t&&eg(i.state,e),i.docChanged||i.selectionSet||t},mount(i,e){eg(e.state,i)},class:"cm-cursorLayer"});function eg(i,e){e.style.animationDuration=i.facet(Js).cursorBlinkRate+"ms"}const oT=B0({above:!1,markers(i){return i.state.selection.ranges.map(e=>e.empty?[]:uo.forRange(i,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(i,e){return i.docChanged||i.selectionSet||i.viewportChanged||D0(i)},class:"cm-selectionLayer"}),N0={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};L0&&(N0[".cm-line"].caretColor="transparent !important");const aT=Zn.highest(he.theme(N0)),Z0=Oe.define({map(i,e){return i==null?null:e.mapPos(i)}}),gs=ft.define({create(){return null},update(i,e){return i!=null&&(i=e.changes.mapPos(i)),e.effects.reduce((t,n)=>n.is(Z0)?n.value:t,i)}}),lT=ut.fromClass(class{constructor(i){this.view=i,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(i){var e;let t=i.state.field(gs);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(i.startState.field(gs)!=t||i.docChanged||i.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let i=this.view.state.field(gs),e=i!=null&&this.view.coordsAtPos(i);if(!e)return null;let t=this.view.scrollDOM.getBoundingClientRect();return{left:e.left-t.left+this.view.scrollDOM.scrollLeft,top:e.top-t.top+this.view.scrollDOM.scrollTop,height:e.bottom-e.top}}drawCursor(i){this.cursor&&(i?(this.cursor.style.left=i.left+"px",this.cursor.style.top=i.top+"px",this.cursor.style.height=i.height+"px"):this.cursor.style.left="-100000px")}destroy(){this.cursor&&this.cursor.remove()}setDropPos(i){this.view.state.field(gs)!=i&&this.view.dispatch({effects:Z0.of(i)})}},{eventHandlers:{dragover(i){this.setDropPos(this.view.posAtCoords({x:i.clientX,y:i.clientY}))},dragleave(i){(i.target==this.view.contentDOM||!this.view.contentDOM.contains(i.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function uT(){return[gs,lT]}function tg(i,e,t,n,r){e.lastIndex=0;for(let s=i.iterRange(t,n),o=t,a;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;a=e.exec(s.value);)r(o+a.index,a)}function hT(i,e){let t=i.visibleRanges;if(t.length==1&&t[0].from==i.viewport.from&&t[0].to==i.viewport.to)return t;let n=[];for(let{from:r,to:s}of t)r=Math.max(i.state.doc.lineAt(r).from,r-e),s=Math.min(i.state.doc.lineAt(s).to,s+e),n.length&&n[n.length-1].to>=r?n[n.length-1].to=s:n.push({from:r,to:s});return n}class fT{constructor(e){const{regexp:t,decoration:n,decorate:r,boundary:s,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,r)this.addMatch=(a,l,u,h)=>r(h,u,u+a[0].length,a,l);else if(typeof n=="function")this.addMatch=(a,l,u,h)=>{let f=n(a,l,u);f&&h(u,u+a[0].length,f)};else if(n)this.addMatch=(a,l,u,h)=>h(u,u+a[0].length,n);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=o}createDeco(e){let t=new Bn,n=t.add.bind(t);for(let{from:r,to:s}of hT(e,this.maxLength))tg(e.state.doc,this.regexp,r,s,(o,a)=>this.addMatch(a,e,o,n));return t.finish()}updateDeco(e,t){let n=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((s,o,a,l)=>{l>e.view.viewport.from&&a1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),n,r):t}updateRange(e,t,n,r){for(let s of e.visibleRanges){let o=Math.max(s.from,n),a=Math.min(s.to,r);if(a>o){let l=e.state.doc.lineAt(o),u=l.tol.from;o--)if(this.boundary.test(l.text[o-1-l.from])){h=o;break}for(;ac.push(d.range(x,m));if(l==u)for(this.regexp.lastIndex=h-l.from;(p=this.regexp.exec(l.text))&&p.indexthis.addMatch(m,e,x,v));t=t.update({filterFrom:h,filterTo:f,filter:(x,m)=>xf,add:c})}}return t}}const of=/x/.unicode!=null?"gu":"g",cT=new RegExp(`[\0-\b ---Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,of),dT={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let pu=null;function pT(){var i;if(pu==null&&typeof document<"u"&&document.body){let e=document.body.style;pu=((i=e.tabSize)!==null&&i!==void 0?i:e.MozTabSize)!=null}return pu||!1}const wa=pe.define({combine(i){let e=Fi(i,{render:null,specialChars:cT,addSpecialChars:null});return(e.replaceTabs=!pT())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,of)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,of)),e}});function F0(i={}){return[wa.of(i),gT()]}let ig=null;function gT(){return ig||(ig=ut.fromClass(class{constructor(i){this.view=i,this.decorations=ge.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(i.state.facet(wa)),this.decorations=this.decorator.createDeco(i)}makeDecorator(i){return new fT({regexp:i.specialChars,decoration:(e,t,n)=>{let{doc:r}=t.state,s=dt(e[0],0);if(s==9){let o=r.lineAt(n),a=t.state.tabSize,l=oo(o.text,a,n-o.from);return ge.replace({widget:new _T((a-l%a)*this.view.defaultCharacterWidth)})}return this.decorationCache[s]||(this.decorationCache[s]=ge.replace({widget:new OT(i,s)}))},boundary:i.replaceTabs?void 0:/[^]/})}update(i){let e=i.state.facet(wa);i.startState.facet(wa)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(i.view)):this.decorations=this.decorator.updateDeco(i,this.decorations)}},{decorations:i=>i.decorations}))}const mT="•";function yT(i){return i>=32?mT:i==10?"␤":String.fromCharCode(9216+i)}class OT extends Xi{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=yT(this.code),n=e.state.phrase("Control character")+" "+(dT[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,n,t);if(r)return r;let s=document.createElement("span");return s.textContent=t,s.title=n,s.setAttribute("aria-label",n),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class _T extends Xi{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}class wT extends Xi{constructor(e){super(),this.content=e}toDOM(){let e=document.createElement("span");return e.className="cm-placeholder",e.style.pointerEvents="none",e.appendChild(typeof this.content=="string"?document.createTextNode(this.content):this.content),typeof this.content=="string"?e.setAttribute("aria-label","placeholder "+this.content):e.setAttribute("aria-hidden","true"),e}coordsAt(e){let t=e.firstChild?Er(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),r=xl(t[0],n.direction!="rtl"),s=parseInt(n.lineHeight);return r.bottom-r.top>s*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+s}:r}ignoreEvent(){return!1}}function bT(i){return ut.fromClass(class{constructor(e){this.view=e,this.placeholder=i?ge.set([ge.widget({widget:new wT(i),side:1}).range(0)]):ge.none}get decorations(){return this.view.state.doc.length?ge.none:this.placeholder}},{decorations:e=>e.decorations})}const af=2e3;function vT(i,e,t){let n=Math.min(e.line,t.line),r=Math.max(e.line,t.line),s=[];if(e.off>af||t.off>af||e.col<0||t.col<0){let o=Math.min(e.off,t.off),a=Math.max(e.off,t.off);for(let l=n;l<=r;l++){let u=i.doc.line(l);u.length<=a&&s.push(K.range(u.from+o,u.to+a))}}else{let o=Math.min(e.col,t.col),a=Math.max(e.col,t.col);for(let l=n;l<=r;l++){let u=i.doc.line(l),h=Lh(u.text,o,i.tabSize,!0);if(h<0)s.push(K.cursor(u.to));else{let f=Lh(u.text,a,i.tabSize);s.push(K.range(u.from+h,u.from+f))}}}return s}function ST(i,e){let t=i.coordsAtPos(i.viewport.from);return t?Math.round(Math.abs((t.left-e)/i.defaultCharacterWidth)):-1}function ng(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1),n=i.state.doc.lineAt(t),r=t-n.from,s=r>af?-1:r==n.length?ST(i,e.clientX):oo(n.text,i.state.tabSize,t-n.from);return{line:n.number,col:s,off:r}}function xT(i,e){let t=ng(i,e),n=i.state.selection;return t?{update(r){if(r.docChanged){let s=r.changes.mapPos(r.startState.doc.line(t.line).from),o=r.state.doc.lineAt(s);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},n=n.map(r.changes)}},get(r,s,o){let a=ng(i,r);if(!a)return n;let l=vT(i.state,t,a);return l.length?o?K.create(l.concat(n.ranges)):K.create(l):n}}:null}function kT(i){let e=(i==null?void 0:i.eventFilter)||(t=>t.altKey&&t.button==0);return he.mouseSelectionStyle.of((t,n)=>e(n)?xT(t,n):null)}const MT={Alt:[18,i=>!!i.altKey],Control:[17,i=>!!i.ctrlKey],Shift:[16,i=>!!i.shiftKey],Meta:[91,i=>!!i.metaKey]},TT={style:"cursor: crosshair"};function CT(i={}){let[e,t]=MT[i.key||"Alt"],n=ut.fromClass(class{constructor(r){this.view=r,this.isDown=!1}set(r){this.isDown!=r&&(this.isDown=r,this.view.update([]))}},{eventHandlers:{keydown(r){this.set(r.keyCode==e||t(r))},keyup(r){(r.keyCode==e||!t(r))&&this.set(!1)},mousemove(r){this.set(t(r))}}});return[n,he.contentAttributes.of(r=>{var s;return!((s=r.plugin(n))===null||s===void 0)&&s.isDown?TT:null})]}const Ro="-10000px";class X0{constructor(e,t,n){this.facet=t,this.createTooltipView=n,this.input=e.state.facet(t),this.tooltips=this.input.filter(r=>r),this.tooltipViews=this.tooltips.map(n)}update(e){var t;let n=e.state.facet(this.facet),r=n.filter(o=>o);if(n===this.input){for(let o of this.tooltipViews)o.update&&o.update(e);return!1}let s=[];for(let o=0;o{var e,t,n;return{position:fe.ios?"absolute":((e=i.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=i.find(r=>r.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((n=i.find(r=>r.tooltipSpace))===null||n===void 0?void 0:n.tooltipSpace)||ET}}}),rg=new WeakMap,G0=ut.fromClass(class{constructor(i){this.view=i,this.inView=!0,this.lastTransaction=0,this.measureTimeout=-1;let e=i.state.facet(gu);this.position=e.position,this.parent=e.parent,this.classes=i.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.manager=new X0(i,_c,t=>this.createTooltip(t)),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),i.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let i of this.manager.tooltipViews)this.intersectionObserver.observe(i.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(i){i.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(i);e&&this.observeIntersection();let t=e||i.geometryChanged,n=i.state.facet(gu);if(n.position!=this.position){this.position=n.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;t=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(i){let e=i.create(this.view);if(e.dom.classList.add("cm-tooltip"),i.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",e.dom.appendChild(t)}return e.dom.style.position=this.position,e.dom.style.top=Ro,this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var i,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(i=t.destroy)===null||i===void 0||i.call(t);(e=this.intersectionObserver)===null||e===void 0||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let i=this.view.dom.getBoundingClientRect();return{editor:i,parent:this.parent?this.container.getBoundingClientRect():i,pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(gu).tooltipSpace(this.view)}}writeMeasure(i){var e;let{editor:t,space:n}=i,r=[];for(let s=0;s=Math.min(t.bottom,n.bottom)||u.rightMath.min(t.right,n.right)+.1){l.style.top=Ro;continue}let f=o.arrow?a.dom.querySelector(".cm-tooltip-arrow"):null,c=f?7:0,p=h.right-h.left,v=(e=rg.get(a))!==null&&e!==void 0?e:h.bottom-h.top,x=a.offset||AT,m=this.view.textDirection==We.LTR,d=h.width>n.right-n.left?m?n.left:n.right-h.width:m?Math.min(u.left-(f?14:0)+x.x,n.right-p):Math.max(n.left,u.left-p+(f?14:0)-x.x),b=!!o.above;!o.strictSide&&(b?u.top-(h.bottom-h.top)-x.yn.bottom)&&b==n.bottom-u.bottom>u.top-n.top&&(b=!b);let A=(b?u.top-n.top:n.bottom-u.bottom)-c;if(Ad&&k.topS&&(S=b?k.top-v-2-c:k.bottom+c+2);this.position=="absolute"?(l.style.top=S-i.parent.top+"px",l.style.left=d-i.parent.left+"px"):(l.style.top=S+"px",l.style.left=d+"px"),f&&(f.style.left=`${u.left+(m?x.x:-x.x)-(d+14-7)}px`),a.overlap!==!0&&r.push({left:d,top:S,right:T,bottom:S+v}),l.classList.toggle("cm-tooltip-above",b),l.classList.toggle("cm-tooltip-below",!b),a.positioned&&a.positioned(i.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let i of this.manager.tooltipViews)i.dom.style.top=Ro}},{eventHandlers:{scroll(){this.maybeMeasure()}}}),QT=he.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),AT={x:0,y:0},_c=pe.define({enables:[G0,QT]}),Na=pe.define();class wc{constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new X0(e,Na,t=>this.createHostedView(t))}static create(e){return new wc(e)}createHostedView(e){let t=e.create(this.view);return t.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(t.dom),this.mounted&&t.mount&&t.mount(this.view),t}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}}const RT=_c.compute([Na],i=>{let e=i.facet(Na).filter(t=>t);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.filter(t=>t.end!=null).map(t=>t.end)),create:wc.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class UT{constructor(e,t,n,r,s){this.view=e,this.source=t,this.field=n,this.setHover=r,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active)return;let e=Date.now()-this.lastMove.time;en.bottom||e.xn.right+this.view.defaultCharacterWidth)return;let r=this.view.bidiSpans(this.view.state.doc.lineAt(t)).find(a=>a.from<=t&&a.to>=t),s=r&&r.dir==We.RTL?-1:1,o=this.source(this.view,t,e.x{this.pending==a&&(this.pending=null,l&&this.view.dispatch({effects:this.setHover.of(l)}))},l=>Xt(this.view.state,l,"hover tooltip"))}else o&&this.view.dispatch({effects:this.setHover.of(o)})}mousemove(e){var t;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let n=this.active;if(n&&!sg(this.lastMove.target)||this.pending){let{pos:r}=n||this.pending,s=(t=n==null?void 0:n.end)!==null&&t!==void 0?t:r;(r==s?this.view.posAtCoords(this.lastMove)!=r:!$T(this.view,r,s,e.clientX,e.clientY,6))&&(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1,this.active&&!sg(e.relatedTarget)&&this.view.dispatch({effects:this.setHover.of(null)})}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}function sg(i){for(let e=i;e;e=e.parentNode)if(e.nodeType==1&&e.classList.contains("cm-tooltip"))return!0;return!1}function $T(i,e,t,n,r,s){let o=document.createRange(),a=i.domAtPos(e),l=i.domAtPos(t);o.setEnd(l.node,l.offset),o.setStart(a.node,a.offset);let u=o.getClientRects();o.detach();for(let h=0;hNa.from(r)});return[n,ut.define(r=>new UT(r,i,n,t,e.hoverTime||300)),RT]}function W0(i,e){let t=i.plugin(G0);if(!t)return null;let n=t.manager.tooltips.indexOf(e);return n<0?null:t.manager.tooltipViews[n]}const JT=Oe.define(),og=pe.define({combine(i){let e,t;for(let n of i)e=e||n.topContainer,t=t||n.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Is(i,e){let t=i.plugin(Y0),n=t?t.specs.indexOf(e):-1;return n>-1?t.panels[n]:null}const Y0=ut.fromClass(class{constructor(i){this.input=i.state.facet(Bs),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(i));let e=i.state.facet(og);this.top=new Uo(i,!0,e.topContainer),this.bottom=new Uo(i,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(i){let e=i.state.facet(og);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Uo(i.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Uo(i.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=i.state.facet(Bs);if(t!=this.input){let n=t.filter(l=>l),r=[],s=[],o=[],a=[];for(let l of n){let u=this.specs.indexOf(l),h;u<0?(h=l(i.view),a.push(h)):(h=this.panels[u],h.update&&h.update(i)),r.push(h),(h.top?s:o).push(h)}this.specs=n,this.panels=r,this.top.sync(s),this.bottom.sync(o);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let n of this.panels)n.update&&n.update(i)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:i=>he.scrollMargins.of(e=>{let t=e.plugin(i);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class Uo{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=ag(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=ag(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function ag(i){let e=i.nextSibling;return i.remove(),e}const Bs=pe.define({enables:Y0});class Ln extends In{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Ln.prototype.elementClass="";Ln.prototype.toDOM=void 0;Ln.prototype.mapMode=gt.TrackBefore;Ln.prototype.startSide=Ln.prototype.endSide=-1;Ln.prototype.point=!0;const IT=pe.define(),BT=new class extends Ln{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},LT=IT.compute(["selection"],i=>{let e=[],t=-1;for(let n of i.selection.ranges){let r=i.doc.lineAt(n.head).from;r>t&&(t=r,e.push(BT.range(r)))}return Ne.of(e)});function jT(){return LT}let DT=0;class bi{constructor(e,t,n){this.set=e,this.base=t,this.modified=n,this.id=DT++}static define(e){if(e!=null&&e.base)throw new Error("Can not derive from a modified tag");let t=new bi([],null,[]);if(t.set.push(t),e)for(let n of e.set)t.set.push(n);return t}static defineModifier(){let e=new Za;return t=>t.modified.indexOf(e)>-1?t:Za.get(t.base||t,t.modified.concat(e).sort((n,r)=>n.id-r.id))}}let NT=0;class Za{constructor(){this.instances=[],this.id=NT++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(a=>a.base==e&&ZT(t,a.modified));if(n)return n;let r=[],s=new bi(r,e,t);for(let a of t)a.instances.push(s);let o=FT(t);for(let a of e.set)if(!a.modified.length)for(let l of o)r.push(Za.get(a,l));return s}}function ZT(i,e){return i.length==e.length&&i.every((t,n)=>t==e[n])}function FT(i){let e=[[]];for(let t=0;tn.length-t.length)}function z0(i){let e=Object.create(null);for(let t in i){let n=i[t];Array.isArray(n)||(n=[n]);for(let r of t.split(" "))if(r){let s=[],o=2,a=r;for(let f=0;;){if(a=="..."&&f>0&&f+3==r.length){o=1;break}let c=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!c)throw new RangeError("Invalid path: "+r);if(s.push(c[0]=="*"?"":c[0][0]=='"'?JSON.parse(c[0]):c[0]),f+=c[0].length,f==r.length)break;let p=r[f++];if(f==r.length&&p=="!"){o=0;break}if(p!="/")throw new RangeError("Invalid path: "+r);a=r.slice(f)}let l=s.length-1,u=s[l];if(!u)throw new RangeError("Invalid path: "+r);let h=new Fa(n,o,l>0?s.slice(0,l):null);e[u]=h.sort(e[u])}}return V0.add(e)}const V0=new we;class Fa{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{let o=r;for(let a of s)for(let l of a.set){let u=t[l.id];if(u){o=o?o+" "+u:u;break}}return o},scope:n}}function XT(i,e){let t=null;for(let n of i){let r=n.style(e);r&&(t=t?t+" "+r:r)}return t}function GT(i,e,t,n=0,r=i.length){let s=new WT(n,Array.isArray(e)?e:[e],t);s.highlightRange(i.cursor(),n,r,"",s.highlighters),s.flush(r)}class WT{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,s){let{type:o,from:a,to:l}=e;if(a>=n||l<=t)return;o.isTop&&(s=this.highlighters.filter(p=>!p.scope||p.scope(o)));let u=r,h=YT(e)||Fa.empty,f=XT(s,h.tags);if(f&&(u&&(u+=" "),u+=f,h.mode==1&&(r+=(r?" ":"")+f)),this.startSpan(Math.max(t,a),u),h.opaque)return;let c=e.tree&&e.tree.prop(we.mounted);if(c&&c.overlay){let p=e.node.enter(c.overlay[0].from+a,1),v=this.highlighters.filter(m=>!m.scope||m.scope(c.tree.type)),x=e.firstChild();for(let m=0,d=a;;m++){let b=m=A||!e.nextSibling())););if(!b||A>n)break;d=b.to+a,d>t&&(this.highlightRange(p.cursor(),Math.max(t,b.from+a),Math.min(n,d),"",v),this.startSpan(Math.min(n,d),u))}x&&e.parent()}else if(e.firstChild()){c&&(r="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,s),this.startSpan(Math.min(n,e.to),u)}while(e.nextSibling());e.parent()}}}function YT(i){let e=i.type.prop(V0);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}const oe=bi.define,$o=oe(),Ki=oe(),lg=oe(Ki),ug=oe(Ki),qi=oe(),Po=oe(qi),mu=oe(qi),wi=oe(),wn=oe(wi),mi=oe(),yi=oe(),lf=oe(),is=oe(lf),Jo=oe(),L={comment:$o,lineComment:oe($o),blockComment:oe($o),docComment:oe($o),name:Ki,variableName:oe(Ki),typeName:lg,tagName:oe(lg),propertyName:ug,attributeName:oe(ug),className:oe(Ki),labelName:oe(Ki),namespace:oe(Ki),macroName:oe(Ki),literal:qi,string:Po,docString:oe(Po),character:oe(Po),attributeValue:oe(Po),number:mu,integer:oe(mu),float:oe(mu),bool:oe(qi),regexp:oe(qi),escape:oe(qi),color:oe(qi),url:oe(qi),keyword:mi,self:oe(mi),null:oe(mi),atom:oe(mi),unit:oe(mi),modifier:oe(mi),operatorKeyword:oe(mi),controlKeyword:oe(mi),definitionKeyword:oe(mi),moduleKeyword:oe(mi),operator:yi,derefOperator:oe(yi),arithmeticOperator:oe(yi),logicOperator:oe(yi),bitwiseOperator:oe(yi),compareOperator:oe(yi),updateOperator:oe(yi),definitionOperator:oe(yi),typeOperator:oe(yi),controlOperator:oe(yi),punctuation:lf,separator:oe(lf),bracket:is,angleBracket:oe(is),squareBracket:oe(is),paren:oe(is),brace:oe(is),content:wi,heading:wn,heading1:oe(wn),heading2:oe(wn),heading3:oe(wn),heading4:oe(wn),heading5:oe(wn),heading6:oe(wn),contentSeparator:oe(wi),list:oe(wi),quote:oe(wi),emphasis:oe(wi),strong:oe(wi),link:oe(wi),monospace:oe(wi),strikethrough:oe(wi),inserted:oe(),deleted:oe(),changed:oe(),invalid:oe(),meta:Jo,documentMeta:oe(Jo),annotation:oe(Jo),processingInstruction:oe(Jo),definition:bi.defineModifier(),constant:bi.defineModifier(),function:bi.defineModifier(),standard:bi.defineModifier(),local:bi.defineModifier(),special:bi.defineModifier()};K0([{tag:L.link,class:"tok-link"},{tag:L.heading,class:"tok-heading"},{tag:L.emphasis,class:"tok-emphasis"},{tag:L.strong,class:"tok-strong"},{tag:L.keyword,class:"tok-keyword"},{tag:L.atom,class:"tok-atom"},{tag:L.bool,class:"tok-bool"},{tag:L.url,class:"tok-url"},{tag:L.labelName,class:"tok-labelName"},{tag:L.inserted,class:"tok-inserted"},{tag:L.deleted,class:"tok-deleted"},{tag:L.literal,class:"tok-literal"},{tag:L.string,class:"tok-string"},{tag:L.number,class:"tok-number"},{tag:[L.regexp,L.escape,L.special(L.string)],class:"tok-string2"},{tag:L.variableName,class:"tok-variableName"},{tag:L.local(L.variableName),class:"tok-variableName tok-local"},{tag:L.definition(L.variableName),class:"tok-variableName tok-definition"},{tag:L.special(L.variableName),class:"tok-variableName2"},{tag:L.definition(L.propertyName),class:"tok-propertyName tok-definition"},{tag:L.typeName,class:"tok-typeName"},{tag:L.namespace,class:"tok-namespace"},{tag:L.className,class:"tok-className"},{tag:L.macroName,class:"tok-macroName"},{tag:L.propertyName,class:"tok-propertyName"},{tag:L.operator,class:"tok-operator"},{tag:L.comment,class:"tok-comment"},{tag:L.meta,class:"tok-meta"},{tag:L.invalid,class:"tok-invalid"},{tag:L.punctuation,class:"tok-punctuation"}]);var yu;const fr=new we;function q0(i){return pe.define({combine:i?e=>e.concat(i):void 0})}const bc=new we;class si{constructor(e,t,n=[],r=""){this.data=e,this.name=r,ke.prototype.hasOwnProperty("tree")||Object.defineProperty(ke.prototype,"tree",{get(){return ht(this)}}),this.parser=t,this.extension=[Ur.of(this),ke.languageData.of((s,o,a)=>{let l=hg(s,o,a),u=l.type.prop(fr);if(!u)return[];let h=s.facet(u),f=l.type.prop(bc);if(f){let c=l.resolve(o-l.from,a);for(let p of f)if(p.test(c,s)){let v=s.facet(p.facet);return p.type=="replace"?v:v.concat(h)}}return h})].concat(n)}isActiveAt(e,t,n=-1){return hg(e,t,n).type.prop(fr)==this.data}findRegions(e){let t=e.facet(Ur);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(s,o)=>{if(s.prop(fr)==this.data){n.push({from:o,to:o+s.length});return}let a=s.prop(we.mounted);if(a){if(a.tree.prop(fr)==this.data){if(a.overlay)for(let l of a.overlay)n.push({from:l.from+o,to:l.to+o});else n.push({from:o,to:o+s.length});return}else if(a.overlay){let l=n.length;if(r(a.tree,a.overlay[0].from+o),n.length>l)return}}for(let l=0;ln.isTop?t:void 0)]}),e.name)}configure(e,t){return new Xa(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function ht(i){let e=i.field(si.state,!1);return e?e.tree:He.empty}class zT{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=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let ns=null;class Ga{constructor(e,t,n=[],r,s,o,a,l){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new Ga(e,t,[],He.empty,0,n,[],null)}startParse(){return this.parser.startParse(new zT(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=He.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=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(An.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=ns;ns=this;try{return e()}finally{ns=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=fg(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:r,treeLen:s,viewport:o,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((u,h,f,c)=>l.push({fromA:u,toA:h,fromB:f,toB:c})),n=An.applyChanges(n,l),r=He.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){a=[];for(let u of this.skipped){let h=e.mapPos(u.from,1),f=e.mapPos(u.to,-1);he.from&&(this.fragments=fg(this.fragments,r,s),this.skipped.splice(n--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends kO{createParse(t,n,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let l=ns;if(l){for(let u of r)l.tempSkipped.push(u);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=o,new He(Ut.none,[],[],o-s)},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 ns}}function fg(i,e,t){return An.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}class Rr{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new Rr(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Ga.create(e.facet(Ur).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new Rr(n)}}si.state=ft.define({create:Rr.init,update(i,e){for(let t of e.effects)if(t.is(si.setState))return t.value;return e.startState.facet(Ur)!=e.state.facet(Ur)?Rr.init(e.state):i.apply(e)}});let H0=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(H0=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:500-100})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const Ou=typeof navigator<"u"&&(!((yu=navigator.scheduling)===null||yu===void 0)&&yu.isInputPending)?()=>navigator.scheduling.isInputPending():null,VT=ut.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(si.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),e.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(si.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=H0(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndr+1e3,l=s.context.work(()=>Ou&&Ou()||Date.now()>o,r+(a?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:si.setState.of(new Rr(s.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Xt(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ur=pe.define({combine(i){return i.length?i[0]:null},enables:i=>[si.state,VT,he.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]});class KT{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const qT=pe.define(),Tl=pe.define({combine:i=>{if(!i.length)return" ";let e=i[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(i[0]));return e}});function Wa(i){let e=i.facet(Tl);return e.charCodeAt(0)==9?i.tabSize*e.length:e.length}function Ls(i,e){let t="",n=i.tabSize,r=i.facet(Tl)[0];if(r==" "){for(;e>=n;)t+=" ",e-=n;r=" "}for(let s=0;s=n.from&&r<=n.to?s&&r==e?{text:"",from:e}:(t<0?r-1&&(s+=o-this.countColumn(n,n.search(/\S|$/))),s}countColumn(e,t=e.length){return oo(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const e_=new we;function HT(i,e,t){return t_(e.resolveInner(t).enterUnfinishedNodesBefore(t),t,i)}function eC(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function tC(i){let e=i.type.prop(e_);if(e)return e;let t=i.firstChild,n;if(t&&(n=t.type.prop(we.closedBy))){let r=i.lastChild,s=r&&n.indexOf(r.name)>-1;return o=>i_(o,!0,1,void 0,s&&!eC(o)?r.from:void 0)}return i.parent==null?iC:null}function t_(i,e,t){for(;i;i=i.parent){let n=tC(i);if(n)return n(Sc.create(t,e,i))}return null}function iC(){return 0}class Sc extends Cl{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.node=n}static create(e,t,n){return new Sc(e,t,n)}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(nC(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){let e=this.node.parent;return e?t_(e,this.pos,this.base):0}}function nC(i,e){for(let t=e;t;t=t.parent)if(i==t)return!0;return!1}function rC(i){let e=i.node,t=e.childAfter(e.from),n=e.lastChild;if(!t)return null;let r=i.options.simulateBreak,s=i.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let a=t.to;;){let l=e.childAfter(a);if(!l||l==n)return null;if(!l.type.isSkipped)return l.fromi_(n,e,t,i)}function i_(i,e,t,n,r){let s=i.textAfter,o=s.match(/^\s*/)[0].length,a=n&&s.slice(o,o+n.length)==n||r==i.pos+o,l=e?rC(i):null;return l?a?i.column(l.from):i.column(l.to):i.baseIndent+(a?0:i.unit*t)}const oC=i=>i.baseIndent;function _u({except:i,units:e=1}={}){return t=>{let n=i&&i.test(t.textAfter);return t.baseIndent+(n?0:e*t.unit)}}const aC=200;function lC(){return ke.transactionFilter.of(i=>{if(!i.docChanged||!i.isUserEvent("input.type")&&!i.isUserEvent("input.complete"))return i;let e=i.startState.languageDataAt("indentOnInput",i.startState.selection.main.head);if(!e.length)return i;let t=i.newDoc,{head:n}=i.newSelection.main,r=t.lineAt(n);if(n>r.from+aC)return i;let s=t.sliceString(r.from,n);if(!e.some(u=>u.test(s)))return i;let{state:o}=i,a=-1,l=[];for(let{head:u}of o.selection.ranges){let h=o.doc.lineAt(u);if(h.from==a)continue;a=h.from;let f=vc(o,h.from);if(f==null)continue;let c=/^\s*/.exec(h.text)[0],p=Ls(o,f);c!=p&&l.push({from:h.from,to:h.from+c.length,insert:p})}return l.length?[i,{changes:l,sequential:!0}]:i})}const uC=pe.define(),n_=new we;function hC(i){let e=i.firstChild,t=i.lastChild;return e&&e.tot)continue;if(s&&o.from=e&&l.to>t&&(s=l)}}return s}function cC(i){let e=i.lastChild;return e&&e.to==i.to&&e.type.isError}function r_(i,e,t){for(let n of i.facet(uC)){let r=n(i,e,t);if(r)return r}return fC(i,e,t)}function s_(i,e){let t=e.mapPos(i.from,1),n=e.mapPos(i.to,-1);return t>=n?void 0:{from:t,to:n}}const xc=Oe.define({map:s_}),El=Oe.define({map:s_});function o_(i){let e=[];for(let{head:t}of i.state.selection.ranges)e.some(n=>n.from<=t&&n.to>=t)||e.push(i.lineBlockAt(t));return e}const ho=ft.define({create(){return ge.none},update(i,e){i=i.map(e.changes);for(let t of e.effects)t.is(xc)&&!dC(i,t.value.from,t.value.to)?i=i.update({add:[cg.range(t.value.from,t.value.to)]}):t.is(El)&&(i=i.update({filter:(n,r)=>t.value.from!=n||t.value.to!=r,filterFrom:t.value.from,filterTo:t.value.to}));if(e.selection){let t=!1,{head:n}=e.selection.main;i.between(n,n,(r,s)=>{rn&&(t=!0)}),t&&(i=i.update({filterFrom:n,filterTo:n,filter:(r,s)=>s<=n||r>=n}))}return i},provide:i=>he.decorations.from(i),toJSON(i,e){let t=[];return i.between(0,e.doc.length,(n,r)=>{t.push(n,r)}),t},fromJSON(i){if(!Array.isArray(i)||i.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t{(!r||r.from>s)&&(r={from:s,to:o})}),r}function dC(i,e,t){let n=!1;return i.between(e,e,(r,s)=>{r==e&&s==t&&(n=!0)}),n}function l_(i,e){return i.field(ho,!1)?e:e.concat(Oe.appendConfig.of(wC()))}const pC=i=>{for(let e of o_(i)){let t=r_(i.state,e.from,e.to);if(t)return i.dispatch({effects:l_(i.state,[xc.of(t),u_(i,t)])}),!0}return!1},gC=i=>{if(!i.state.field(ho,!1))return!1;let e=[];for(let t of o_(i)){let n=a_(i.state,t.from,t.to);n&&e.push(El.of(n),u_(i,n,!1))}return e.length&&i.dispatch({effects:e}),e.length>0};function u_(i,e,t=!0){let n=i.state.doc.lineAt(e.from).number,r=i.state.doc.lineAt(e.to).number;return he.announce.of(`${i.state.phrase(t?"Folded lines":"Unfolded lines")} ${n} ${i.state.phrase("to")} ${r}.`)}const mC=i=>{let{state:e}=i,t=[];for(let n=0;n{let e=i.state.field(ho,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,i.state.doc.length,(n,r)=>{t.push(El.of({from:n,to:r}))}),i.dispatch({effects:t}),!0},OC=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:pC},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:gC},{key:"Ctrl-Alt-[",run:mC},{key:"Ctrl-Alt-]",run:yC}],_C={placeholderDOM:null,placeholderText:"…"},h_=pe.define({combine(i){return Fi(i,_C)}});function wC(i){let e=[ho,bC];return i&&e.push(h_.of(i)),e}const cg=ge.replace({widget:new class extends Xi{toDOM(i){let{state:e}=i,t=e.facet(h_),n=s=>{let o=i.lineBlockAt(i.posAtDOM(s.target)),a=a_(i.state,o.from,o.to);a&&i.dispatch({effects:El.of(a)}),s.preventDefault()};if(t.placeholderDOM)return t.placeholderDOM(i,n);let r=document.createElement("span");return r.textContent=t.placeholderText,r.setAttribute("aria-label",e.phrase("folded code")),r.title=e.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=n,r}}}),bC=he.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"}});class jr{constructor(e,t){this.specs=e;let n;function r(a){let l=dn.newName();return(n||(n=Object.create(null)))["."+l]=a,l}const s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof si?a=>a.prop(fr)==o.data:o?a=>a==o:void 0,this.style=K0(e.map(a=>({tag:a.tag,class:a.class||r(Object.assign({},a,{tag:null}))})),{all:s}).style,this.module=n?new dn(n):null,this.themeType=t.themeType}static define(e,t){return new jr(e,t||{})}}const uf=pe.define(),f_=pe.define({combine(i){return i.length?[i[0]]:null}});function wu(i){let e=i.facet(uf);return e.length?e:i.facet(f_)}function Ya(i,e){let t=[SC],n;return i instanceof jr&&(i.module&&t.push(he.styleModule.of(i.module)),n=i.themeType),e!=null&&e.fallback?t.push(f_.of(i)):n?t.push(uf.computeN([he.darkTheme],r=>r.facet(he.darkTheme)==(n=="dark")?[i]:[])):t.push(uf.of(i)),t}class vC{constructor(e){this.markCache=Object.create(null),this.tree=ht(e.state),this.decorations=this.buildDeco(e,wu(e.state))}update(e){let t=ht(e.state),n=wu(e.state),r=n!=wu(e.startState);t.length{n.add(o,a,this.markCache[l]||(this.markCache[l]=ge.mark({class:l})))},r,s);return n.finish()}}const SC=Zn.high(ut.fromClass(vC,{decorations:i=>i.decorations})),xC=jr.define([{tag:L.meta,color:"#404740"},{tag:L.link,textDecoration:"underline"},{tag:L.heading,textDecoration:"underline",fontWeight:"bold"},{tag:L.emphasis,fontStyle:"italic"},{tag:L.strong,fontWeight:"bold"},{tag:L.strikethrough,textDecoration:"line-through"},{tag:L.keyword,color:"#708"},{tag:[L.atom,L.bool,L.url,L.contentSeparator,L.labelName],color:"#219"},{tag:[L.literal,L.inserted],color:"#164"},{tag:[L.string,L.deleted],color:"#a11"},{tag:[L.regexp,L.escape,L.special(L.string)],color:"#e40"},{tag:L.definition(L.variableName),color:"#00f"},{tag:L.local(L.variableName),color:"#30a"},{tag:[L.typeName,L.namespace],color:"#085"},{tag:L.className,color:"#167"},{tag:[L.special(L.variableName),L.macroName],color:"#256"},{tag:L.definition(L.propertyName),color:"#00c"},{tag:L.comment,color:"#940"},{tag:L.invalid,color:"#f00"}]),kC=he.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),c_=1e4,d_="()[]{}",p_=pe.define({combine(i){return Fi(i,{afterCursor:!0,brackets:d_,maxScanDistance:c_,renderMatch:CC})}}),MC=ge.mark({class:"cm-matchingBracket"}),TC=ge.mark({class:"cm-nonmatchingBracket"});function CC(i){let e=[],t=i.matched?MC:TC;return e.push(t.range(i.start.from,i.start.to)),i.end&&e.push(t.range(i.end.from,i.end.to)),e}const EC=ft.define({create(){return ge.none},update(i,e){if(!e.docChanged&&!e.selection)return i;let t=[],n=e.state.facet(p_);for(let r of e.state.selection.ranges){if(!r.empty)continue;let s=Ci(e.state,r.head,-1,n)||r.head>0&&Ci(e.state,r.head-1,1,n)||n.afterCursor&&(Ci(e.state,r.head,1,n)||r.headhe.decorations.from(i)}),QC=[EC,kC];function AC(i={}){return[p_.of(i),QC]}const RC=new we;function hf(i,e,t){let n=i.prop(e<0?we.openedBy:we.closedBy);if(n)return n;if(i.name.length==1){let r=t.indexOf(i.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function ff(i){let e=i.type.prop(RC);return e?e(i.node):i}function Ci(i,e,t,n={}){let r=n.maxScanDistance||c_,s=n.brackets||d_,o=ht(i),a=o.resolveInner(e,t);for(let l=a;l;l=l.parent){let u=hf(l.type,t,s);if(u&&l.from0?e>=h.from&&eh.from&&e<=h.to))return UC(i,e,t,l,h,u,s)}}return $C(i,e,t,o,a.type,r,s)}function UC(i,e,t,n,r,s,o){let a=n.parent,l={from:r.from,to:r.to},u=0,h=a==null?void 0:a.cursor();if(h&&(t<0?h.childBefore(n.from):h.childAfter(n.to)))do if(t<0?h.to<=n.from:h.from>=n.to){if(u==0&&s.indexOf(h.type.name)>-1&&h.from0)return null;let u={from:t<0?e-1:e,to:t>0?e+1:e},h=i.doc.iterRange(e,t>0?i.doc.length:0),f=0;for(let c=0;!h.next().done&&c<=s;){let p=h.value;t<0&&(c+=p.length);let v=e+c*t;for(let x=t>0?0:p.length-1,m=t>0?p.length:-1;x!=m;x+=t){let d=o.indexOf(p[x]);if(!(d<0||n.resolveInner(v+x,1).type!=r))if(d%2==0==t>0)f++;else{if(f==1)return{start:u,end:{from:v+x,to:v+x+1},matched:d>>1==l>>1};f--}}t>0&&(c+=p.length)}return h.done?{start:u,matched:!1}:null}const PC=Object.create(null),dg=[Ut.none],pg=[],JC=Object.create(null);for(let[i,e]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"]])JC[i]=IC(PC,e);function bu(i,e){pg.indexOf(i)>-1||(pg.push(i),console.warn(e))}function IC(i,e){let t=null;for(let s of e.split(".")){let o=i[s]||L[s];o?typeof o=="function"?t?t=o(t):bu(s,`Modifier ${s} used at start of tag`):t?bu(s,`Tag ${s} used as modifier`):t=o:bu(s,`Unknown highlighting tag ${s}`)}if(!t)return 0;let n=e.replace(/ /g,"_"),r=Ut.define({id:dg.length,name:n,props:[z0({[n]:t})]});return dg.push(r),r.id}function BC(i,e){e.on("editor: randomize",function(t){const n=i.editor.editor,r=n.cm;let s=r.state.doc.toString(),o=ht(r.state);console.log("RANDIMIZING",n,s,o)}),e.on("editor: add code to top",t=>{i.editor.editor.addCodeToTop(t)}),e.on("editor: format code",()=>{i.editor.editor.formatCode()}),e.on("editor: load code",t=>{i.editor.editor.setValue(t)}),e.on("editor: eval all",function(){const t=i.editor.editor,n=t.getValue();e.emit("repl: eval",n,(r,s)=>{t.flashCode(),s||e.emit("gallery: save to URL",n)})})}var cf={exports:{}},g_={exports:{}};(function(i){i.exports=e;function e(n){if(n)return t(n)}function t(n){for(var r in e.prototype)n[r]=e.prototype[r];return n}e.prototype.on=e.prototype.addEventListener=function(n,r){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(r),this},e.prototype.once=function(n,r){function s(){this.off(n,s),r.apply(this,arguments)}return s.fn=r,this.on(n,s),this},e.prototype.off=e.prototype.removeListener=e.prototype.removeAllListeners=e.prototype.removeEventListener=function(n,r){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var s=this._callbacks["$"+n];if(!s)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var o,a=0;a"u"||!at?be:at(Uint8Array),$n={"%AggregateError%":typeof AggregateError>"u"?be:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?be:ArrayBuffer,"%ArrayIteratorPrototype%":qn&&at?at([][Symbol.iterator]()):be,"%AsyncFromSyncIteratorPrototype%":be,"%AsyncFunction%":sr,"%AsyncGenerator%":sr,"%AsyncGeneratorFunction%":sr,"%AsyncIteratorPrototype%":sr,"%Atomics%":typeof Atomics>"u"?be:Atomics,"%BigInt%":typeof BigInt>"u"?be:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?be:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?be:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?be:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?be:Float32Array,"%Float64Array%":typeof Float64Array>"u"?be:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?be:FinalizationRegistry,"%Function%":m_,"%GeneratorFunction%":sr,"%Int8Array%":typeof Int8Array>"u"?be:Int8Array,"%Int16Array%":typeof Int16Array>"u"?be:Int16Array,"%Int32Array%":typeof Int32Array>"u"?be:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":qn&&at?at(at([][Symbol.iterator]())):be,"%JSON%":typeof JSON=="object"?JSON:be,"%Map%":typeof Map>"u"?be:Map,"%MapIteratorPrototype%":typeof Map>"u"||!qn||!at?be:at(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?be:Promise,"%Proxy%":typeof Proxy>"u"?be:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?be:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?be:Set,"%SetIteratorPrototype%":typeof Set>"u"||!qn||!at?be:at(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?be:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":qn&&at?at(""[Symbol.iterator]()):be,"%Symbol%":qn?Symbol:be,"%SyntaxError%":$r,"%ThrowTypeError%":KC,"%TypedArray%":HC,"%TypeError%":_r,"%Uint8Array%":typeof Uint8Array>"u"?be:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?be:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?be:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?be:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?be:WeakMap,"%WeakRef%":typeof WeakRef>"u"?be:WeakRef,"%WeakSet%":typeof WeakSet>"u"?be:WeakSet};if(at)try{null.error}catch(i){var eE=at(at(i));$n["%Error.prototype%"]=eE}var tE=function i(e){var t;if(e==="%AsyncFunction%")t=Su("async function () {}");else if(e==="%GeneratorFunction%")t=Su("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=Su("async function* () {}");else if(e==="%AsyncGenerator%"){var n=i("%AsyncGeneratorFunction%");n&&(t=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var r=i("%AsyncGenerator%");r&&at&&(t=at(r.prototype))}return $n[e]=t,t},yg={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},fo=kc,za=VC,iE=fo.call(Function.call,Array.prototype.concat),nE=fo.call(Function.apply,Array.prototype.splice),Og=fo.call(Function.call,String.prototype.replace),Va=fo.call(Function.call,String.prototype.slice),rE=fo.call(Function.call,RegExp.prototype.exec),sE=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,oE=/\\(\\)?/g,aE=function(e){var t=Va(e,0,1),n=Va(e,-1);if(t==="%"&&n!=="%")throw new $r("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&t!=="%")throw new $r("invalid intrinsic syntax, expected opening `%`");var r=[];return Og(e,sE,function(s,o,a,l){r[r.length]=a?Og(l,oE,"$1"):o||s}),r},lE=function(e,t){var n=e,r;if(za(yg,n)&&(r=yg[n],n="%"+r[0]+"%"),za($n,n)){var s=$n[n];if(s===sr&&(s=tE(n)),typeof s>"u"&&!t)throw new _r("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:s}}throw new $r("intrinsic "+e+" does not exist!")},Mc=function(e,t){if(typeof e!="string"||e.length===0)throw new _r("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof t!="boolean")throw new _r('"allowMissing" argument must be a boolean');if(rE(/^%?[^%]*%?$/,e)===null)throw new $r("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=aE(e),r=n.length>0?n[0]:"",s=lE("%"+r+"%",t),o=s.name,a=s.value,l=!1,u=s.alias;u&&(r=u[0],nE(n,iE([0,1],u)));for(var h=1,f=!0;h=n.length){var x=Un(a,c);f=!!x,f&&"get"in x&&!("originalValue"in x.get)?a=x.get:a=a[c]}else f=za(a,c),a=a[c];f&&!l&&($n[o]=a)}}return a},y_={exports:{}};(function(i){var e=kc,t=Mc,n=t("%Function.prototype.apply%"),r=t("%Function.prototype.call%"),s=t("%Reflect.apply%",!0)||e.call(r,n),o=t("%Object.getOwnPropertyDescriptor%",!0),a=t("%Object.defineProperty%",!0),l=t("%Math.max%");if(a)try{a({},"a",{value:1})}catch{a=null}i.exports=function(f){var c=s(e,r,arguments);if(o&&a){var p=o(c,"length");p.configurable&&a(c,"length",{value:1+l(0,f.length-(arguments.length-1))})}return c};var u=function(){return s(e,n,arguments)};a?a(i.exports,"apply",{value:u}):i.exports.apply=u})(y_);var uE=y_.exports,O_=Mc,__=uE,hE=__(O_("String.prototype.indexOf")),fE=function(e,t){var n=O_(e,!!t);return typeof n=="function"&&hE(e,".prototype.")>-1?__(n):n};const cE={},dE=Object.freeze(Object.defineProperty({__proto__:null,default:cE},Symbol.toStringTag,{value:"Module"})),Dr=Py(dE);var Tc=typeof Map=="function"&&Map.prototype,ku=Object.getOwnPropertyDescriptor&&Tc?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Ka=Tc&&ku&&typeof ku.get=="function"?ku.get:null,_g=Tc&&Map.prototype.forEach,Cc=typeof Set=="function"&&Set.prototype,Mu=Object.getOwnPropertyDescriptor&&Cc?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,qa=Cc&&Mu&&typeof Mu.get=="function"?Mu.get:null,wg=Cc&&Set.prototype.forEach,pE=typeof WeakMap=="function"&&WeakMap.prototype,Ms=pE?WeakMap.prototype.has:null,gE=typeof WeakSet=="function"&&WeakSet.prototype,Ts=gE?WeakSet.prototype.has:null,mE=typeof WeakRef=="function"&&WeakRef.prototype,bg=mE?WeakRef.prototype.deref:null,yE=Boolean.prototype.valueOf,OE=Object.prototype.toString,_E=Function.prototype.toString,wE=String.prototype.match,Ec=String.prototype.slice,sn=String.prototype.replace,bE=String.prototype.toUpperCase,vg=String.prototype.toLowerCase,w_=RegExp.prototype.test,Sg=Array.prototype.concat,vi=Array.prototype.join,vE=Array.prototype.slice,xg=Math.floor,df=typeof BigInt=="function"?BigInt.prototype.valueOf:null,Tu=Object.getOwnPropertySymbols,pf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Pr=typeof Symbol=="function"&&typeof Symbol.iterator=="object",bt=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Pr||"symbol")?Symbol.toStringTag:null,b_=Object.prototype.propertyIsEnumerable,kg=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(i){return i.__proto__}:null);function Mg(i,e){if(i===1/0||i===-1/0||i!==i||i&&i>-1e3&&i<1e3||w_.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof i=="number"){var n=i<0?-xg(-i):xg(i);if(n!==i){var r=String(n),s=Ec.call(e,r.length+1);return sn.call(r,t,"$&_")+"."+sn.call(sn.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return sn.call(e,t,"$&_")}var gf=Dr,Tg=gf.custom,Cg=S_(Tg)?Tg:null,SE=function i(e,t,n,r){var s=t||{};if(Hi(s,"quoteStyle")&&s.quoteStyle!=="single"&&s.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Hi(s,"maxStringLength")&&(typeof s.maxStringLength=="number"?s.maxStringLength<0&&s.maxStringLength!==1/0:s.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=Hi(s,"customInspect")?s.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Hi(s,"indent")&&s.indent!==null&&s.indent!==" "&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Hi(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=s.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return k_(e,s);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var l=String(e);return a?Mg(e,l):l}if(typeof e=="bigint"){var u=String(e)+"n";return a?Mg(e,u):u}var h=typeof s.depth>"u"?5:s.depth;if(typeof n>"u"&&(n=0),n>=h&&h>0&&typeof e=="object")return mf(e)?"[Array]":"[Object]";var f=DE(s,n);if(typeof r>"u")r=[];else if(x_(r,e)>=0)return"[Circular]";function c(V,ee,B){if(ee&&(r=vE.call(r),r.push(ee)),B){var Z={depth:s.depth};return Hi(s,"quoteStyle")&&(Z.quoteStyle=s.quoteStyle),i(V,Z,n+1,r)}return i(V,s,n+1,r)}if(typeof e=="function"&&!Eg(e)){var p=RE(e),v=Io(e,c);return"[Function"+(p?": "+p:" (anonymous)")+"]"+(v.length>0?" { "+vi.call(v,", ")+" }":"")}if(S_(e)){var x=Pr?sn.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):pf.call(e);return typeof e=="object"&&!Pr?rs(x):x}if(BE(e)){for(var m="<"+vg.call(String(e.nodeName)),d=e.attributes||[],b=0;b",m}if(mf(e)){if(e.length===0)return"[]";var A=Io(e,c);return f&&!jE(A)?"["+yf(A,f)+"]":"[ "+vi.call(A,", ")+" ]"}if(ME(e)){var S=Io(e,c);return!("cause"in Error.prototype)&&"cause"in e&&!b_.call(e,"cause")?"{ ["+String(e)+"] "+vi.call(Sg.call("[cause]: "+c(e.cause),S),", ")+" }":S.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+vi.call(S,", ")+" }"}if(typeof e=="object"&&o){if(Cg&&typeof e[Cg]=="function"&&gf)return gf(e,{depth:h-n});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(UE(e)){var T=[];return _g&&_g.call(e,function(V,ee){T.push(c(ee,e,!0)+" => "+c(V,e))}),Qg("Map",Ka.call(e),T,f)}if(JE(e)){var k=[];return wg&&wg.call(e,function(V){k.push(c(V,e))}),Qg("Set",qa.call(e),k,f)}if($E(e))return Cu("WeakMap");if(IE(e))return Cu("WeakSet");if(PE(e))return Cu("WeakRef");if(CE(e))return rs(c(Number(e)));if(QE(e))return rs(c(df.call(e)));if(EE(e))return rs(yE.call(e));if(TE(e))return rs(c(String(e)));if(!kE(e)&&!Eg(e)){var Q=Io(e,c),C=kg?kg(e)===Object.prototype:e instanceof Object||e.constructor===Object,I=e instanceof Object?"":"null prototype",_=!C&&bt&&Object(e)===e&&bt in e?Ec.call(On(e),8,-1):I?"Object":"",j=C||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",D=j+(_||I?"["+vi.call(Sg.call([],_||[],I||[]),": ")+"] ":"");return Q.length===0?D+"{}":f?D+"{"+yf(Q,f)+"}":D+"{ "+vi.call(Q,", ")+" }"}return String(e)};function v_(i,e,t){var n=(t.quoteStyle||e)==="double"?'"':"'";return n+i+n}function xE(i){return sn.call(String(i),/"/g,""")}function mf(i){return On(i)==="[object Array]"&&(!bt||!(typeof i=="object"&&bt in i))}function kE(i){return On(i)==="[object Date]"&&(!bt||!(typeof i=="object"&&bt in i))}function Eg(i){return On(i)==="[object RegExp]"&&(!bt||!(typeof i=="object"&&bt in i))}function ME(i){return On(i)==="[object Error]"&&(!bt||!(typeof i=="object"&&bt in i))}function TE(i){return On(i)==="[object String]"&&(!bt||!(typeof i=="object"&&bt in i))}function CE(i){return On(i)==="[object Number]"&&(!bt||!(typeof i=="object"&&bt in i))}function EE(i){return On(i)==="[object Boolean]"&&(!bt||!(typeof i=="object"&&bt in i))}function S_(i){if(Pr)return i&&typeof i=="object"&&i instanceof Symbol;if(typeof i=="symbol")return!0;if(!i||typeof i!="object"||!pf)return!1;try{return pf.call(i),!0}catch{}return!1}function QE(i){if(!i||typeof i!="object"||!df)return!1;try{return df.call(i),!0}catch{}return!1}var AE=Object.prototype.hasOwnProperty||function(i){return i in this};function Hi(i,e){return AE.call(i,e)}function On(i){return OE.call(i)}function RE(i){if(i.name)return i.name;var e=wE.call(_E.call(i),/^function\s*([\w$]+)/);return e?e[1]:null}function x_(i,e){if(i.indexOf)return i.indexOf(e);for(var t=0,n=i.length;te.maxStringLength){var t=i.length-e.maxStringLength,n="... "+t+" more character"+(t>1?"s":"");return k_(Ec.call(i,0,e.maxStringLength),e)+n}var r=sn.call(sn.call(i,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,LE);return v_(r,"single",e)}function LE(i){var e=i.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+bE.call(e.toString(16))}function rs(i){return"Object("+i+")"}function Cu(i){return i+" { ? }"}function Qg(i,e,t,n){var r=n?yf(t,n):vi.call(t,", ");return i+" ("+e+") {"+r+"}"}function jE(i){for(var e=0;e=0)return!1;return!0}function DE(i,e){var t;if(i.indent===" ")t=" ";else if(typeof i.indent=="number"&&i.indent>0)t=vi.call(Array(i.indent+1)," ");else return null;return{base:t,prev:vi.call(Array(e+1),t)}}function yf(i,e){if(i.length===0)return"";var t=` -`+e.prev+e.base;return t+vi.call(i,","+t)+` -`+e.prev}function Io(i,e){var t=mf(i),n=[];if(t){n.length=i.length;for(var r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(xn(n)){for(var r=[],s=0;s=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||s===iQ.RFC1738&&(u===40||u===41)){a+=o.charAt(l);continue}if(u<128){a=a+Oi[u];continue}if(u<2048){a=a+(Oi[192|u>>6]+Oi[128|u&63]);continue}if(u<55296||u>=57344){a=a+(Oi[224|u>>12]+Oi[128|u>>6&63]+Oi[128|u&63]);continue}l+=1,u=65536+((u&1023)<<10|o.charCodeAt(l)&1023),a+=Oi[240|u>>18]+Oi[128|u>>12&63]+Oi[128|u>>6&63]+Oi[128|u&63]}return a},lQ=function(e){for(var t=[{obj:{o:e},prop:"o"}],n=[],r=0;r"u"&&(A=0)}if(typeof l=="function"?d=l(t,d):d instanceof Date?d=f(d):n==="comma"&&Ii(d)&&(d=ba.maybeMap(d,function(Z){return Z instanceof Date?f(Z):Z})),d===null){if(s)return a&&!v?a(t,Ot.encoder,x,"key",c):t;d=""}if(mQ(d)||ba.isBuffer(d)){if(a){var k=v?t:a(t,Ot.encoder,x,"key",c);return[p(k)+"="+p(a(d,Ot.encoder,x,"value",c))]}return[p(t)+"="+p(String(d))]}var Q=[];if(typeof d>"u")return Q;var C;if(n==="comma"&&Ii(d))v&&a&&(d=ba.maybeMap(d,a)),C=[{value:d.length>0?d.join(",")||null:void 0}];else if(Ii(l))C=l;else{var I=Object.keys(d);C=u?I.sort(u):I}for(var _=r&&Ii(d)&&d.length===1?t+"[]":t,j=0;j"u"?Ot.allowDots:!!e.allowDots,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:Ot.charsetSentinel,delimiter:typeof e.delimiter>"u"?Ot.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:Ot.encode,encoder:typeof e.encoder=="function"?e.encoder:Ot.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:Ot.encodeValuesOnly,filter:s,format:n,formatter:r,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:Ot.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:Ot.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:Ot.strictNullHandling}},_Q=function(i,e){var t=i,n=OQ(e),r,s;typeof n.filter=="function"?(s=n.filter,t=s("",t)):Ii(n.filter)&&(s=n.filter,r=s);var o=[];if(typeof t!="object"||t===null)return"";var a;e&&e.arrayFormat in Ag?a=e.arrayFormat:e&&"indices"in e?a=e.indices?"indices":"repeat":a="indices";var l=Ag[a];if(e&&"commaRoundTrip"in e&&typeof e.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var u=l==="comma"&&e&&e.commaRoundTrip;r||(r=Object.keys(t)),n.sort&&r.sort(n.sort);for(var h=C_(),f=0;f0?v+p:""},Jr=T_,Of=Object.prototype.hasOwnProperty,wQ=Array.isArray,ot={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:Jr.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},bQ=function(i){return i.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},Q_=function(i,e){return i&&typeof i=="string"&&e.comma&&i.indexOf(",")>-1?i.split(","):i},vQ="utf8=%26%2310003%3B",SQ="utf8=%E2%9C%93",xQ=function(e,t){var n={__proto__:null},r=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,s=t.parameterLimit===1/0?void 0:t.parameterLimit,o=r.split(t.delimiter,s),a=-1,l,u=t.charset;if(t.charsetSentinel)for(l=0;l-1&&(v=wQ(v)?[v]:v),Of.call(n,p)?n[p]=Jr.combine(n[p],v):n[p]=v}return n},kQ=function(i,e,t,n){for(var r=n?e:Q_(e,t),s=i.length-1;s>=0;--s){var o,a=i[s];if(a==="[]"&&t.parseArrays)o=[].concat(r);else{o=t.plainObjects?Object.create(null):{};var l=a.charAt(0)==="["&&a.charAt(a.length-1)==="]"?a.slice(1,-1):a,u=parseInt(l,10);!t.parseArrays&&l===""?o={0:r}:!isNaN(u)&&a!==l&&String(u)===l&&u>=0&&t.parseArrays&&u<=t.arrayLimit?(o=[],o[u]=r):l!=="__proto__"&&(o[l]=r)}r=o}return r},MQ=function(e,t,n,r){if(e){var s=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,l=n.depth>0&&o.exec(s),u=l?s.slice(0,l.index):s,h=[];if(u){if(!n.plainObjects&&Of.call(Object.prototype,u)&&!n.allowPrototypes)return;h.push(u)}for(var f=0;n.depth>0&&(l=a.exec(s))!==null&&f"u"?ot.charset:e.charset;return{allowDots:typeof e.allowDots>"u"?ot.allowDots:!!e.allowDots,allowPrototypes:typeof e.allowPrototypes=="boolean"?e.allowPrototypes:ot.allowPrototypes,allowSparse:typeof e.allowSparse=="boolean"?e.allowSparse:ot.allowSparse,arrayLimit:typeof e.arrayLimit=="number"?e.arrayLimit:ot.arrayLimit,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:ot.charsetSentinel,comma:typeof e.comma=="boolean"?e.comma:ot.comma,decoder:typeof e.decoder=="function"?e.decoder:ot.decoder,delimiter:typeof e.delimiter=="string"||Jr.isRegExp(e.delimiter)?e.delimiter:ot.delimiter,depth:typeof e.depth=="number"||e.depth===!1?+e.depth:ot.depth,ignoreQueryPrefix:e.ignoreQueryPrefix===!0,interpretNumericEntities:typeof e.interpretNumericEntities=="boolean"?e.interpretNumericEntities:ot.interpretNumericEntities,parameterLimit:typeof e.parameterLimit=="number"?e.parameterLimit:ot.parameterLimit,parseArrays:e.parseArrays!==!1,plainObjects:typeof e.plainObjects=="boolean"?e.plainObjects:ot.plainObjects,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:ot.strictNullHandling}},CQ=function(i,e){var t=TQ(e);if(i===""||i===null||typeof i>"u")return t.plainObjects?Object.create(null):{};for(var n=typeof i=="string"?xQ(i,t):i,r=t.plainObjects?Object.create(null):{},s=Object.keys(n),o=0;o=s.length?{done:!0}:{done:!1,value:s[l++]}},e:function(v){throw v},f:u}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var h=!0,f=!1,c;return{s:function(){a=a.call(s)},n:function(){var v=a.next();return h=v.done,v},e:function(v){f=!0,c=v},f:function(){try{!h&&a.return!=null&&a.return()}finally{if(f)throw c}}}}function n(s,o){if(s){if(typeof s=="string")return r(s,o);var a=Object.prototype.toString.call(s).slice(8,-1);if(a==="Object"&&s.constructor&&(a=s.constructor.name),a==="Map"||a==="Set")return Array.from(s);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return r(s,o)}}function r(s,o){(o==null||o>s.length)&&(o=s.length);for(var a=0,l=new Array(o);a=this._maxRetries)return!1;if(this._retryCallback)try{var t=this._retryCallback(i,e);if(t===!0)return!0;if(t===!1)return!1}catch(n){console.error(n)}return!!(e&&e.status&&PQ.has(e.status)||i&&(i.code&&$Q.has(i.code)||i.timeout&&i.code==="ECONNABORTED"||i.crossDomain))};Ce.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()};Ce.prototype.then=function(i,e){var t=this;if(!this._fullfilledPromise){var n=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(r,s){n.on("abort",function(){if(!(t._maxRetries&&t._maxRetries>t._retries)){if(t.timedout&&t.timedoutError){s(t.timedoutError);return}var o=new Error("Aborted");o.code="ABORTED",o.status=t.status,o.method=t.method,o.url=t.url,s(o)}}),n.end(function(o,a){o?s(o):r(a)})})}return this._fullfilledPromise.then(i,e)};Ce.prototype.catch=function(i){return this.then(void 0,i)};Ce.prototype.use=function(i){return i(this),this};Ce.prototype.ok=function(i){if(typeof i!="function")throw new Error("Callback required");return this._okCallback=i,this};Ce.prototype._isResponseOK=function(i){return i?this._okCallback?this._okCallback(i):i.status>=200&&i.status<300:!1};Ce.prototype.get=function(i){return this._header[i.toLowerCase()]};Ce.prototype.getHeader=Ce.prototype.get;Ce.prototype.set=function(i,e){if(Ha(i)){for(var t in i)js(i,t)&&this.set(t,i[t]);return this}return this._header[i.toLowerCase()]=e,this.header[i]=e,this};Ce.prototype.unset=function(i){return delete this._header[i.toLowerCase()],delete this.header[i],this};Ce.prototype.field=function(i,e,t){if(i==null)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(Ha(i)){for(var n in i)js(i,n)&&this.field(n,i[n]);return this}if(Array.isArray(e)){for(var r in e)js(e,r)&&this.field(i,e[r]);return this}if(e==null)throw new Error(".field(name, val) val can not be empty");return typeof e=="boolean"&&(e=String(e)),t?this._getFormData().append(i,e,t):this._getFormData().append(i,e),this};Ce.prototype.abort=function(){if(this._aborted)return this;if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(Ru.gte(process.version,"v13.0.0")&&Ru.lt(process.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");Ru.gte(process.version,"v14.0.0")&&(this.req.destroyed=!0),this.req.abort()}return this.clearTimeout(),this.emit("abort"),this};Ce.prototype._auth=function(i,e,t,n){switch(t.type){case"basic":this.set("Authorization","Basic ".concat(n("".concat(i,":").concat(e))));break;case"auto":this.username=i,this.password=e;break;case"bearer":this.set("Authorization","Bearer ".concat(i));break}return this};Ce.prototype.withCredentials=function(i){return i===void 0&&(i=!0),this._withCredentials=i,this};Ce.prototype.redirects=function(i){return this._maxRedirects=i,this};Ce.prototype.maxResponseSize=function(i){if(typeof i!="number")throw new TypeError("Invalid argument");return this._maxResponseSize=i,this};Ce.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}};Ce.prototype.send=function(i){var e=Ha(i),t=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(e&&!this._data)Array.isArray(i)?this._data=[]:this._isHost(i)||(this._data={});else if(i&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(e&&Ha(this._data))for(var n in i)js(i,n)&&(this._data[n]=i[n]);else typeof i=="string"?(t||this.type("form"),t=this._header["content-type"],t&&(t=t.toLowerCase().trim()),t==="application/x-www-form-urlencoded"?this._data=this._data?"".concat(this._data,"&").concat(i):i:this._data=(this._data||"")+i):this._data=i;return!e||this._isHost(i)?this:(t||this.type("json"),this)};Ce.prototype.sortQuery=function(i){return this._sort=typeof i>"u"?!0:i,this};Ce.prototype._finalizeQueryString=function(){var i=this._query.join("&");if(i&&(this.url+=(this.url.includes("?")?"&":"?")+i),this._query.length=0,this._sort){var e=this.url.indexOf("?");if(e>=0){var t=this.url.slice(e+1).split("&");typeof this._sort=="function"?t.sort(this._sort):t.sort(),this.url=this.url.slice(0,e)+"?"+t.join("&")}}};Ce.prototype._appendQueryString=function(){console.warn("Unsupported")};Ce.prototype._timeoutError=function(i,e,t){if(!this._aborted){var n=new Error("".concat(i+e,"ms exceeded"));n.timeout=e,n.code="ECONNABORTED",n.errno=t,this.timedout=!0,this.timedoutError=n,this.abort(),this.callback(n)}};Ce.prototype._setTimeouts=function(){var i=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){i._timeoutError("Timeout of ",i._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){i._timeoutError("Response timeout of ",i._responseTimeout,"ETIMEDOUT")},this._responseTimeout))};var Uu=Ql,JQ=Al;function Al(){}Al.prototype.get=function(i){return this.header[i.toLowerCase()]};Al.prototype._setHeaderProperties=function(i){var e=i["content-type"]||"";this.type=Uu.type(e);var t=Uu.params(e);for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(this[n]=t[n]);this.links={};try{i.link&&(this.links=Uu.parseLinks(i.link))}catch{}};Al.prototype._setStatusProperties=function(i){var e=Math.trunc(i/100);this.statusCode=i,this.status=this.statusCode,this.statusType=e,this.info=e===1,this.ok=e===2,this.redirect=e===3,this.clientError=e===4,this.serverError=e===5,this.error=e===4||e===5?this.toError():!1,this.created=i===201,this.accepted=i===202,this.noContent=i===204,this.badRequest=i===400,this.unauthorized=i===401,this.notAcceptable=i===406,this.forbidden=i===403,this.notFound=i===404,this.unprocessableEntity=i===422};function IQ(i){return jQ(i)||LQ(i)||R_(i)||BQ()}function BQ(){throw new TypeError(`Invalid attempt to spread non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function LQ(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function jQ(i){if(Array.isArray(i))return wf(i)}function DQ(i,e){var t=typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(!t){if(Array.isArray(i)||(t=R_(i))||e&&i&&typeof i.length=="number"){t&&(i=t);var n=0,r=function(){};return{s:r,n:function(){return n>=i.length?{done:!0}:{done:!1,value:i[n++]}},e:function(u){throw u},f:r}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s=!0,o=!1,a;return{s:function(){t=t.call(i)},n:function(){var u=t.next();return s=u.done,u},e:function(u){o=!0,a=u},f:function(){try{!s&&t.return!=null&&t.return()}finally{if(o)throw a}}}}function R_(i,e){if(i){if(typeof i=="string")return wf(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(i);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return wf(i,e)}}function wf(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=new Array(e);t=B.length?{done:!0}:{done:!1,value:B[N++]}},e:function(de){throw de},f:Y}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var te=!0,se=!1,le;return{s:function(){R=R.call(B)},n:function(){var de=R.next();return te=de.done,de},e:function(de){se=!0,le=de},f:function(){try{!te&&R.return!=null&&R.return()}finally{if(se)throw le}}}}function r(B,Z){if(B){if(typeof B=="string")return s(B,Z);var R=Object.prototype.toString.call(B).slice(8,-1);if(R==="Object"&&B.constructor&&(R=B.constructor.name),R==="Map"||R==="Set")return Array.from(B);if(R==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(R))return s(B,Z)}}function s(B,Z){(Z==null||Z>B.length)&&(Z=B.length);for(var R=0,N=new Array(Z);R"u"?(console.warn("Using browser-only version of superagent in non-browser environment"),o=void 0):o=self;var a=Xn,l=eO,u=RQ,h=UQ,f=Ql,c=f.isObject,p=f.mixin,v=f.hasOwn,x=JQ,m=ZQ;function d(){}i.exports=function(B,Z){return typeof Z=="function"?new e.Request("GET",B).end(Z):arguments.length===1?new e.Request("GET",B):new e.Request(B,Z)},e=i.exports;var b=e;e.Request=_,b.getXHR=function(){if(o.XMLHttpRequest&&(!o.location||o.location.protocol!=="file:"||!o.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch{}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch{}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch{}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch{}throw new Error("Browser-only version of superagent could not find XHR")};var A="".trim?function(B){return B.trim()}:function(B){return B.replace(/(^\s*|\s*$)/g,"")};function S(B){if(!c(B))return B;var Z=[];for(var R in B)v(B,R)&&T(Z,R,B[R]);return Z.join("&")}function T(B,Z,R){if(R!==void 0){if(R===null){B.push(encodeURI(Z));return}if(Array.isArray(R)){var N=n(R),Y;try{for(N.s();!(Y=N.n()).done;){var te=Y.value;T(B,Z,te)}}catch(le){N.e(le)}finally{N.f()}}else if(c(R))for(var se in R)v(R,se)&&T(B,"".concat(Z,"[").concat(se,"]"),R[se]);else B.push(encodeURI(Z)+"="+encodeURIComponent(R))}}b.serializeObject=S;function k(B){for(var Z={},R=B.split("&"),N,Y,te=0,se=R.length;te"u"?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText;var Z=this.xhr.status;Z===1223&&(Z=204),this._setStatusProperties(Z),this.headers=Q(this.xhr.getAllResponseHeaders()),this.header=this.headers,this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this._setHeaderProperties(this.header),this.text===null&&B._responseType?this.body=this.xhr.response:this.body=this.req.method==="HEAD"?null:this._parseBody(this.text?this.text:this.xhr.response)}p(I.prototype,x.prototype),I.prototype._parseBody=function(B){var Z=b.parse[this.type];return this.req._parser?this.req._parser(this,B):(!Z&&C(this.type)&&(Z=b.parse["application/json"]),Z&&B&&(B.length>0||B instanceof Object)?Z(B):null)},I.prototype.toError=function(){var B=this.req,Z=B.method,R=B.url,N="cannot ".concat(Z," ").concat(R," (").concat(this.status,")"),Y=new Error(N);return Y.status=this.status,Y.method=Z,Y.url=R,Y},b.Response=I;function _(B,Z){var R=this;this._query=this._query||[],this.method=B,this.url=Z,this.header={},this._header={},this.on("end",function(){var N=null,Y=null;try{Y=new I(R)}catch(se){return N=new Error("Parser is unable to parse the response"),N.parse=!0,N.original=se,R.xhr?(N.rawResponse=typeof R.xhr.responseType>"u"?R.xhr.responseText:R.xhr.response,N.status=R.xhr.status?R.xhr.status:null,N.statusCode=N.status):(N.rawResponse=null,N.status=null),R.callback(N)}R.emit("response",Y);var te;try{R._isResponseOK(Y)||(te=new Error(Y.statusText||Y.text||"Unsuccessful HTTP response"))}catch(se){te=se}te?(te.original=N,te.response=Y,te.status=Y.status,R.callback(te,Y)):R.callback(null,Y)})}a(_.prototype),p(_.prototype,h.prototype),_.prototype.type=function(B){return this.set("Content-Type",b.types[B]||B),this},_.prototype.accept=function(B){return this.set("Accept",b.types[B]||B),this},_.prototype.auth=function(B,Z,R){arguments.length===1&&(Z=""),t(Z)==="object"&&Z!==null&&(R=Z,Z=""),R||(R={type:typeof btoa=="function"?"basic":"auto"});var N=R.encoder?R.encoder:function(Y){if(typeof btoa=="function")return btoa(Y);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(B,Z,R,N)},_.prototype.query=function(B){return typeof B!="string"&&(B=S(B)),B&&this._query.push(B),this},_.prototype.attach=function(B,Z,R){if(Z){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(B,Z,R||Z.name)}return this},_.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},_.prototype.callback=function(B,Z){if(this._shouldRetry(B,Z))return this._retry();var R=this._callback;this.clearTimeout(),B&&(this._maxRetries&&(B.retries=this._retries-1),this.emit("error",B)),R(B,Z)},_.prototype.crossDomainError=function(){var B=new Error(`Request has been terminated -Possible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.`);B.crossDomain=!0,B.status=this.status,B.method=this.method,B.url=this.url,this.callback(B)},_.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},_.prototype.ca=_.prototype.agent,_.prototype.buffer=_.prototype.ca,_.prototype.write=function(){throw new Error("Streaming is not supported in browser version of superagent")},_.prototype.pipe=_.prototype.write,_.prototype._isHost=function(B){return B&&t(B)==="object"&&!Array.isArray(B)&&Object.prototype.toString.call(B)!=="[object Object]"},_.prototype.end=function(B){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=B||d,this._finalizeQueryString(),this._end()},_.prototype._setUploadTimeout=function(){var B=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout(function(){B._timeoutError("Upload timeout of ",B._uploadTimeout,"ETIMEDOUT")},this._uploadTimeout))},_.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));var B=this;this.xhr=b.getXHR();var Z=this.xhr,R=this._formData||this._data;this._setTimeouts(),Z.addEventListener("readystatechange",function(){var le=Z.readyState;if(le>=2&&B._responseTimeoutTimer&&clearTimeout(B._responseTimeoutTimer),le===4){var ue;try{ue=Z.status}catch{ue=0}if(!ue)return B.timedout||B._aborted?void 0:B.crossDomainError();B.emit("end")}});var N=function(ue,de){de.total>0&&(de.percent=de.loaded/de.total*100,de.percent===100&&clearTimeout(B._uploadTimeoutTimer)),de.direction=ue,B.emit("progress",de)};if(this.hasListeners("progress"))try{Z.addEventListener("progress",N.bind(null,"download")),Z.upload&&Z.upload.addEventListener("progress",N.bind(null,"upload"))}catch{}Z.upload&&this._setUploadTimeout();try{this.username&&this.password?Z.open(this.method,this.url,!0,this.username,this.password):Z.open(this.method,this.url,!0)}catch(le){return this.callback(le)}if(this._withCredentials&&(Z.withCredentials=!0),!this._formData&&this.method!=="GET"&&this.method!=="HEAD"&&typeof R!="string"&&!this._isHost(R)){var Y=this._header["content-type"],te=this._serializer||b.serialize[Y?Y.split(";")[0]:""];!te&&C(Y)&&(te=b.serialize["application/json"]),te&&(R=te(R))}for(var se in this.header)this.header[se]!==null&&v(this.header,se)&&Z.setRequestHeader(se,this.header[se]);this._responseType&&(Z.responseType=this._responseType),this.emit("request",this),Z.send(typeof R>"u"?null:R)},b.agent=function(){return new m};for(var j=function(){var Z=V[D];m.prototype[Z.toLowerCase()]=function(R,N){var Y=new b.Request(Z,R);return this._setDefaults(Y),N&&Y.end(N),Y}},D=0,V=["GET","POST","OPTIONS","PATCH","PUT","DELETE"];D{this.setSketchFromURL(window.location.search,e)}),this.setRandomSketch=this.setRandomSketch.bind(this)}clear(){this.current=null,this.code=null;let e=window.location.protocol+"//"+window.location.host+window.location.pathname;window.history.pushState({path:e},"",e),this.url=e}setSketchFromURL(e=window.location.search,t){hush(),render(o0);let n=new URLSearchParams(e);this.searchParams=n;let r=n.get("code"),s=n.get("sketch_id"),o=n.get("showCode");if(console.log("code is",r),this.foundSketch=!1,s){var a=this.getExampleById(s);a?(this.setSketch(a),t(this.code,!1)):$u.get(`${this.state.serverURL}/sketchById`).query({sketch_id:s}).end((l,u)=>{l?(console.log("err getting sketches",l),this.setSketchFromCode(r,t)):(this.sketches=JSON.parse(u.text),this.sketches.length>0?(this.setSketch(this.sketches[0]),this.foundSketch=!0,t(this.code,this.foundSketch)):this.setSketchFromCode(r,t))})}else this.setSketchFromCode(r,t);o==="false"&&(this.emitter.emit("ui: hide all"),this.emitter.emit("hide info"))}setSketchFromCode(e,t){e?(this.code=this.decodeBase64(e),this.foundSketch=!0):this.setRandomSketch(),t(this.code,this.foundSketch)}saveImage(){}setToURL(e){this.searchParams.delete("sketch_id"),this.searchParams.delete("code"),e.sketch_id?(`${e.sketch_id}`,this.searchParams.append("sketch_id",e.sketch_id)):(`${e.sketch_id}${e.code}`,this.searchParams.append("sketch_id",e.sketch_id),this.searchParams.append("code",e.code));let t=window.location.protocol+"//"+window.location.host+window.location.pathname+"?"+this.searchParams.toString();window.history.replaceState({path:t},"",t),this.url=t}encodeBase64(e){return btoa(encodeURIComponent(e))}decodeBase64(e){return decodeURIComponent(atob(e))}setSketch(e){let t=this.decodeBase64(e.code);t.indexOf(Ug)<0&&(t=`${Ug} +})().catch(${r=>{window._reportError(r)}})`;try{window.eval(n)}catch(r){t.errorMessage=r.message}t.codeString=n,t.errorMessage.length>0&&(t.isError=!0),e(t)}};function RS(i,e){i.showInfo=!1,i.showUI=!0,i.showExtensions=!1,i.errorMessage="",i.isError=!1;const t="https://api.hydrasynth.xyz";i.serverURL=t,window._reportError=r=>{i.errorMessage=r.message,i.isError=!0,e.emit("render")},e.on("load and eval code",(r,s=!0)=>{e.emit("editor: load code",r),e.emit("repl: eval",r),s&&e.emit("gallery: save to URL",r)}),e.on("repl: eval",(r="",s)=>{AS.eval(r,o=>{i.errorMessage=o.errorMessage,i.isError=o.isError,s&&s(o.codeString,o.isError),e.emit("render")})}),e.on("screencap",()=>{screencap();const s=i.editor.editor.getValue(),o=new Blob([s],{type:"text/plain"}),a=document.createElement("a");a.style.display="none";let l=new Date;a.download=`hydra-${l.getFullYear()}-${l.getMonth()+1}-${l.getDate()}-${l.getHours()}.${l.getMinutes()}.${l.getSeconds()}.js`,a.href=URL.createObjectURL(o),a.click(),setTimeout(()=>{window.URL.revokeObjectURL(a.href)},300)});function n(){const r=i.editor.editor;hush(),speed=1,e.emit("gallery: clear"),r.clear()}e.on("clear all",()=>{n()}),e.on("ui: hide all",function(){i.showUI=!i.showUI,e.emit("render")}),e.on("ui: toggle info",function(r){i.showInfo?e.emit("ui: hide info"):e.emit("ui: show info")}),e.on("ui: show info",()=>{i.showInfo=!0,e.emit("render")}),e.on("ui: hide info",()=>{i.showInfo=!1,i.showExtensions=!1,e.emit("render")}),e.on("ui: show extensions",()=>{i.showExtensions=!0,i.showInfo=!0,e.emit("extensions: select category"),e.emit("render")}),e.on("ui: hide extensions",()=>{i.showExtensions=!1,e.emit("render")})}function si(i){"@babel/helpers - typeof";return si=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},si(i)}function hi(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function US(i,e){if(si(i)!=="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(si(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function Ky(i){var e=US(i,"string");return si(e)==="symbol"?e:String(e)}function Sd(i,e){for(var t=0;ti.length)&&(e=i.length);for(var t=0,n=new Array(e);t1&&arguments[1]!==void 0?arguments[1]:{};hi(this,i),this.init(e,t)}return fi(i,[{key:"init",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=n.prefix||"i18next:",this.logger=t||LS,this.options=n,this.debug=n.debug}},{key:"setDebug",value:function(t){this.debug=t}},{key:"log",value:function(){for(var t=arguments.length,n=new Array(t),r=0;r1?n-1:0),s=1;s-1?a.replace(/###/g,"."):a}function r(){return!i||typeof i=="string"}for(var s=typeof e!="string"?[].concat(e):e.split(".");s.length>1;){if(r())return{};var o=n(s.shift());!i[o]&&t&&(i[o]=new t),Object.prototype.hasOwnProperty.call(i,o)?i=i[o]:i={}}return r()?{}:{obj:i,k:n(s.shift())}}function Cd(i,e,t){var n=Vf(i,e,Object),r=n.obj,s=n.k;r[s]=t}function NS(i,e,t,n){var r=Vf(i,e,Object),s=r.obj,o=r.k;s[o]=s[o]||[],n&&(s[o]=s[o].concat(t)),n||s[o].push(t)}function ka(i,e){var t=Vf(i,e),n=t.obj,r=t.k;if(n)return n[r]}function Ed(i,e,t){var n=ka(i,t);return n!==void 0?n:ka(e,t)}function qy(i,e,t){for(var n in e)n!=="__proto__"&&n!=="constructor"&&(n in i?typeof i[n]=="string"||i[n]instanceof String||typeof e[n]=="string"||e[n]instanceof String?t&&(i[n]=e[n]):qy(i[n],e[n],t):i[n]=e[n]);return i}function Yn(i){return i.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var ZS={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function FS(i){return typeof i=="string"?i.replace(/[&<>"'\/]/g,function(e){return ZS[e]}):i}var yl=typeof window<"u"&&window.navigator&&typeof window.navigator.userAgentData>"u"&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,XS=[" ",",","?","!",";"];function GS(i,e,t){e=e||"",t=t||"";var n=XS.filter(function(a){return e.indexOf(a)<0&&t.indexOf(a)<0});if(n.length===0)return!0;var r=new RegExp("(".concat(n.map(function(a){return a==="?"?"\\?":a}).join("|"),")")),s=!r.test(i);if(!s){var o=i.indexOf(t);o>0&&!r.test(i.substring(0,o))&&(s=!0)}return s}function Qd(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function mo(i){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Hy(i,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(i){if(i[e])return i[e];for(var n=e.split(t),r=i,s=0;ss+o;)o++,a=n.slice(s,s+o).join(t),l=r[a];if(l===void 0)return;if(l===null)return null;if(e.endsWith(a)){if(typeof l=="string")return l;if(a&&typeof l[a]=="string")return l[a]}var u=n.slice(s+o).join(t);return u?Hy(l,u,t):void 0}r=r[n[s]]}return r}}var zS=function(i){ml(t,i);var e=WS(t);function t(n){var r,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};return hi(this,t),r=e.call(this),yl&&hn.call(an(r)),r.data=n||{},r.options=s,r.options.keySeparator===void 0&&(r.options.keySeparator="."),r.options.ignoreJSONStructure===void 0&&(r.options.ignoreJSONStructure=!0),r}return fi(t,[{key:"addNamespaces",value:function(r){this.options.ns.indexOf(r)<0&&this.options.ns.push(r)}},{key:"removeNamespaces",value:function(r){var s=this.options.ns.indexOf(r);s>-1&&this.options.ns.splice(s,1)}},{key:"getResource",value:function(r,s,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},l=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,u=a.ignoreJSONStructure!==void 0?a.ignoreJSONStructure:this.options.ignoreJSONStructure,h=[r,s];o&&typeof o!="string"&&(h=h.concat(o)),o&&typeof o=="string"&&(h=h.concat(l?o.split(l):o)),r.indexOf(".")>-1&&(h=r.split("."));var f=ka(this.data,h);return f||!u||typeof o!="string"?f:Hy(this.data&&this.data[r]&&this.data[r][s],o,l)}},{key:"addResource",value:function(r,s,o,a){var l=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1},u=this.options.keySeparator;u===void 0&&(u=".");var h=[r,s];o&&(h=h.concat(u?o.split(u):o)),r.indexOf(".")>-1&&(h=r.split("."),a=s,s=h[1]),this.addNamespaces(s),Cd(this.data,h,a),l.silent||this.emit("added",r,s,o,a)}},{key:"addResources",value:function(r,s,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(var l in o)(typeof o[l]=="string"||Object.prototype.toString.apply(o[l])==="[object Array]")&&this.addResource(r,s,l,o[l],{silent:!0});a.silent||this.emit("added",r,s,o)}},{key:"addResourceBundle",value:function(r,s,o,a,l){var u=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1},h=[r,s];r.indexOf(".")>-1&&(h=r.split("."),a=o,o=s,s=h[1]),this.addNamespaces(s);var f=ka(this.data,h)||{};a?qy(f,o,l):f=mo(mo({},f),o),Cd(this.data,h,f),u.silent||this.emit("added",r,s,o)}},{key:"removeResourceBundle",value:function(r,s){this.hasResourceBundle(r,s)&&delete this.data[r][s],this.removeNamespaces(s),this.emit("removed",r,s)}},{key:"hasResourceBundle",value:function(r,s){return this.getResource(r,s)!==void 0}},{key:"getResourceBundle",value:function(r,s){return s||(s=this.options.defaultNS),this.options.compatibilityAPI==="v1"?mo(mo({},{}),this.getResource(r,s)):this.getResource(r,s)}},{key:"getDataByLanguage",value:function(r){return this.data[r]}},{key:"hasLanguageSomeTranslations",value:function(r){var s=this.getDataByLanguage(r),o=s&&Object.keys(s)||[];return!!o.find(function(a){return s[a]&&Object.keys(s[a]).length>0})}},{key:"toJSON",value:function(){return this.data}}]),t}(hn),eO={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,n,r,s){var o=this;return e.forEach(function(a){o.processors[a]&&(t=o.processors[a].process(t,n,r,s))}),t}};function Ad(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function St(i){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Rd={},Ud=function(i){ml(t,i);var e=VS(t);function t(n){var r,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return hi(this,t),r=e.call(this),yl&&hn.call(an(r)),DS(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],n,an(r)),r.options=s,r.options.keySeparator===void 0&&(r.options.keySeparator="."),r.logger=ki.create("translator"),r}return fi(t,[{key:"changeLanguage",value:function(r){r&&(this.language=r)}},{key:"exists",value:function(r){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(r==null)return!1;var o=this.resolve(r,s);return o&&o.res!==void 0}},{key:"extractFromKey",value:function(r,s){var o=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;o===void 0&&(o=":");var a=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,l=s.ns||this.options.defaultNS||[],u=o&&r.indexOf(o)>-1,h=!this.options.userDefinedKeySeparator&&!s.keySeparator&&!this.options.userDefinedNsSeparator&&!s.nsSeparator&&!GS(r,o,a);if(u&&!h){var f=r.match(this.interpolator.nestingRegexp);if(f&&f.length>0)return{key:r,namespaces:l};var c=r.split(o);(o!==a||o===a&&this.options.ns.indexOf(c[0])>-1)&&(l=c.shift()),r=c.join(a)}return typeof l=="string"&&(l=[l]),{key:r,namespaces:l}}},{key:"translate",value:function(r,s,o){var a=this;if(si(s)!=="object"&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),s||(s={}),r==null)return"";Array.isArray(r)||(r=[String(r)]);var l=s.returnDetails!==void 0?s.returnDetails:this.options.returnDetails,u=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,h=this.extractFromKey(r[r.length-1],s),f=h.key,c=h.namespaces,p=c[c.length-1],v=s.lng||this.language,x=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(v&&v.toLowerCase()==="cimode"){if(x){var m=s.nsSeparator||this.options.nsSeparator;return l?(d.res="".concat(p).concat(m).concat(f),d):"".concat(p).concat(m).concat(f)}return l?(d.res=f,d):f}var d=this.resolve(r,s),b=d&&d.res,A=d&&d.usedKey||f,S=d&&d.exactUsedKey||f,T=Object.prototype.toString.apply(b),k=["[object Number]","[object Function]","[object RegExp]"],Q=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,C=!this.i18nFormat||this.i18nFormat.handleAsObject,I=typeof b!="string"&&typeof b!="boolean"&&typeof b!="number";if(C&&b&&I&&k.indexOf(T)<0&&!(typeof Q=="string"&&T==="[object Array]")){if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var _=this.options.returnedObjectHandler?this.options.returnedObjectHandler(A,b,St(St({},s),{},{ns:c})):"key '".concat(f," (").concat(this.language,")' returned an object instead of string.");return l?(d.res=_,d):_}if(u){var j=T==="[object Array]",D=j?[]:{},V=j?S:A;for(var ee in b)if(Object.prototype.hasOwnProperty.call(b,ee)){var B="".concat(V).concat(u).concat(ee);D[ee]=this.translate(B,St(St({},s),{joinArrays:!1,ns:c})),D[ee]===B&&(D[ee]=b[ee])}b=D}}else if(C&&typeof Q=="string"&&T==="[object Array]")b=b.join(Q),b&&(b=this.extendTranslation(b,r,s,o));else{var Z=!1,R=!1,N=s.count!==void 0&&typeof s.count!="string",Y=t.hasDefaultValue(s),te=N?this.pluralResolver.getSuffix(v,s.count,s):"",se=s["defaultValue".concat(te)]||s.defaultValue;!this.isValidLookup(b)&&Y&&(Z=!0,b=se),this.isValidLookup(b)||(R=!0,b=f);var le=s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey,ue=le&&R?void 0:b,de=Y&&se!==b&&this.options.updateMissing;if(R||Z||de){if(this.logger.log(de?"updateKey":"missingKey",v,p,f,de?se:b),u){var Qe=this.resolve(f,St(St({},s),{},{keySeparator:!1}));Qe&&Qe.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var W=[],G=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&G&&G[0])for(var ne=0;ne1&&arguments[1]!==void 0?arguments[1]:{},a,l,u,h,f;return typeof r=="string"&&(r=[r]),r.forEach(function(c){if(!s.isValidLookup(a)){var p=s.extractFromKey(c,o),v=p.key;l=v;var x=p.namespaces;s.options.fallbackNS&&(x=x.concat(s.options.fallbackNS));var m=o.count!==void 0&&typeof o.count!="string",d=m&&!o.ordinal&&o.count===0&&s.pluralResolver.shouldUseIntlApi(),b=o.context!==void 0&&(typeof o.context=="string"||typeof o.context=="number")&&o.context!=="",A=o.lngs?o.lngs:s.languageUtils.toResolveHierarchy(o.lng||s.language,o.fallbackLng);x.forEach(function(S){s.isValidLookup(a)||(f=S,!Rd["".concat(A[0],"-").concat(S)]&&s.utils&&s.utils.hasLoadedNamespace&&!s.utils.hasLoadedNamespace(f)&&(Rd["".concat(A[0],"-").concat(S)]=!0,s.logger.warn('key "'.concat(l,'" for languages "').concat(A.join(", "),`" won't get resolved as namespace "`).concat(f,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),A.forEach(function(T){if(!s.isValidLookup(a)){h=T;var k=[v];if(s.i18nFormat&&s.i18nFormat.addLookupKeys)s.i18nFormat.addLookupKeys(k,v,T,S,o);else{var Q;m&&(Q=s.pluralResolver.getSuffix(T,o.count,o));var C="".concat(s.options.pluralSeparator,"zero");if(m&&(k.push(v+Q),d&&k.push(v+C)),b){var I="".concat(v).concat(s.options.contextSeparator).concat(o.context);k.push(I),m&&(k.push(I+Q),d&&k.push(I+C))}}for(var _;_=k.pop();)s.isValidLookup(a)||(u=_,a=s.getResource(T,S,_,o))}}))})}}),{res:a,usedKey:l,exactUsedKey:u,usedLng:h,usedNS:f}}},{key:"isValidLookup",value:function(r){return r!==void 0&&!(!this.options.returnNull&&r===null)&&!(!this.options.returnEmptyString&&r==="")}},{key:"getResource",value:function(r,s,o){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(r,s,o,a):this.resourceStore.getResource(r,s,o,a)}}],[{key:"hasDefaultValue",value:function(r){var s="defaultValue";for(var o in r)if(Object.prototype.hasOwnProperty.call(r,o)&&s===o.substring(0,s.length)&&r[o]!==void 0)return!0;return!1}}]),t}(hn);function Vl(i){return i.charAt(0).toUpperCase()+i.slice(1)}var qS=function(){function i(e){hi(this,i),this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=ki.create("languageUtils")}return fi(i,[{key:"getScriptPartFromCode",value:function(t){if(!t||t.indexOf("-")<0)return null;var n=t.split("-");return n.length===2||(n.pop(),n[n.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(n.join("-"))}},{key:"getLanguagePartFromCode",value:function(t){if(!t||t.indexOf("-")<0)return t;var n=t.split("-");return this.formatLanguageCode(n[0])}},{key:"formatLanguageCode",value:function(t){if(typeof t=="string"&&t.indexOf("-")>-1){var n=["hans","hant","latn","cyrl","cans","mong","arab"],r=t.split("-");return this.options.lowerCaseLng?r=r.map(function(s){return s.toLowerCase()}):r.length===2?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=Vl(r[1].toLowerCase()))):r.length===3&&(r[0]=r[0].toLowerCase(),r[1].length===2&&(r[1]=r[1].toUpperCase()),r[0]!=="sgn"&&r[2].length===2&&(r[2]=r[2].toUpperCase()),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=Vl(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=Vl(r[2].toLowerCase()))),r.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}},{key:"isSupportedCode",value:function(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}},{key:"getBestMatchFromCodes",value:function(t){var n=this;if(!t)return null;var r;return t.forEach(function(s){if(!r){var o=n.formatLanguageCode(s);(!n.options.supportedLngs||n.isSupportedCode(o))&&(r=o)}}),!r&&this.options.supportedLngs&&t.forEach(function(s){if(!r){var o=n.getLanguagePartFromCode(s);if(n.isSupportedCode(o))return r=o;r=n.options.supportedLngs.find(function(a){if(a.indexOf(o)===0)return a})}}),r||(r=this.getFallbackCodes(this.options.fallbackLng)[0]),r}},{key:"getFallbackCodes",value:function(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),typeof t=="string"&&(t=[t]),Object.prototype.toString.apply(t)==="[object Array]")return t;if(!n)return t.default||[];var r=t[n];return r||(r=t[this.getScriptPartFromCode(n)]),r||(r=t[this.formatLanguageCode(n)]),r||(r=t[this.getLanguagePartFromCode(n)]),r||(r=t.default),r||[]}},{key:"toResolveHierarchy",value:function(t,n){var r=this,s=this.getFallbackCodes(n||this.options.fallbackLng||[],t),o=[],a=function(u){u&&(r.isSupportedCode(u)?o.push(u):r.logger.warn("rejecting language code not found in supportedLngs: ".concat(u)))};return typeof t=="string"&&t.indexOf("-")>-1?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(t))):typeof t=="string"&&a(this.formatLanguageCode(t)),s.forEach(function(l){o.indexOf(l)<0&&a(r.formatLanguageCode(l))}),o}}]),i}(),HS=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],e1={1:function(e){return+(e>1)},2:function(e){return+(e!=1)},3:function(e){return 0},4:function(e){return e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2},5:function(e){return e==0?0:e==1?1:e==2?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5},6:function(e){return e==1?0:e>=2&&e<=4?1:2},7:function(e){return e==1?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2},8:function(e){return e==1?0:e==2?1:e!=8&&e!=11?2:3},9:function(e){return+(e>=2)},10:function(e){return e==1?0:e==2?1:e<7?2:e<11?3:4},11:function(e){return e==1||e==11?0:e==2||e==12?1:e>2&&e<20?2:3},12:function(e){return+(e%10!=1||e%100==11)},13:function(e){return+(e!==0)},14:function(e){return e==1?0:e==2?1:e==3?2:3},15:function(e){return e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2},16:function(e){return e%10==1&&e%100!=11?0:e!==0?1:2},17:function(e){return e==1||e%10==1&&e%100!=11?0:1},18:function(e){return e==0?0:e==1?1:2},19:function(e){return e==1?0:e==0||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3},20:function(e){return e==1?0:e==0||e%100>0&&e%100<20?1:2},21:function(e){return e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0},22:function(e){return e==1?0:e==2?1:(e<0||e>10)&&e%10==0?2:3}},t1=["v1","v2","v3"],$d={zero:0,one:1,two:2,few:3,many:4,other:5};function i1(){var i={};return HS.forEach(function(e){e.lngs.forEach(function(t){i[t]={numbers:e.nr,plurals:e1[e.fc]}})}),i}var n1=function(){function i(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};hi(this,i),this.languageUtils=e,this.options=t,this.logger=ki.create("pluralResolver"),(!this.options.compatibilityJSON||this.options.compatibilityJSON==="v4")&&(typeof Intl>"u"||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=i1()}return fi(i,[{key:"addRule",value:function(t,n){this.rules[t]=n}},{key:"getRule",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(t,{type:n.ordinal?"ordinal":"cardinal"})}catch{return}return this.rules[t]||this.rules[this.languageUtils.getLanguagePartFromCode(t)]}},{key:"needsPlural",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=this.getRule(t,n);return this.shouldUseIntlApi()?r&&r.resolvedOptions().pluralCategories.length>1:r&&r.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(t,r).map(function(s){return"".concat(n).concat(s)})}},{key:"getSuffixes",value:function(t){var n=this,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=this.getRule(t,r);return s?this.shouldUseIntlApi()?s.resolvedOptions().pluralCategories.sort(function(o,a){return $d[o]-$d[a]}).map(function(o){return"".concat(n.options.prepend).concat(o)}):s.numbers.map(function(o){return n.getSuffix(t,o,r)}):[]}},{key:"getSuffix",value:function(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=this.getRule(t,r);return s?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(s.select(n)):this.getSuffixRetroCompatible(s,n):(this.logger.warn("no plural rule found for: ".concat(t)),"")}},{key:"getSuffixRetroCompatible",value:function(t,n){var r=this,s=t.noAbs?t.plurals(n):t.plurals(Math.abs(n)),o=t.numbers[s];this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1&&(o===2?o="plural":o===1&&(o=""));var a=function(){return r.options.prepend&&o.toString()?r.options.prepend+o.toString():o.toString()};return this.options.compatibilityJSON==="v1"?o===1?"":typeof o=="number"?"_plural_".concat(o.toString()):a():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1?a():this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString()}},{key:"shouldUseIntlApi",value:function(){return!t1.includes(this.options.compatibilityJSON)}}]),i}();function Pd(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function Kt(i){for(var e=1;e0&&arguments[0]!==void 0?arguments[0]:{};hi(this,i),this.logger=ki.create("interpolator"),this.options=e,this.format=e.interpolation&&e.interpolation.format||function(t){return t},this.init(e)}return fi(i,[{key:"init",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};t.interpolation||(t.interpolation={escapeValue:!0});var n=t.interpolation;this.escape=n.escape!==void 0?n.escape:FS,this.escapeValue=n.escapeValue!==void 0?n.escapeValue:!0,this.useRawValueToEscape=n.useRawValueToEscape!==void 0?n.useRawValueToEscape:!1,this.prefix=n.prefix?Yn(n.prefix):n.prefixEscaped||"{{",this.suffix=n.suffix?Yn(n.suffix):n.suffixEscaped||"}}",this.formatSeparator=n.formatSeparator?n.formatSeparator:n.formatSeparator||",",this.unescapePrefix=n.unescapeSuffix?"":n.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":n.unescapeSuffix||"",this.nestingPrefix=n.nestingPrefix?Yn(n.nestingPrefix):n.nestingPrefixEscaped||Yn("$t("),this.nestingSuffix=n.nestingSuffix?Yn(n.nestingSuffix):n.nestingSuffixEscaped||Yn(")"),this.nestingOptionsSeparator=n.nestingOptionsSeparator?n.nestingOptionsSeparator:n.nestingOptionsSeparator||",",this.maxReplaces=n.maxReplaces?n.maxReplaces:1e3,this.alwaysFormat=n.alwaysFormat!==void 0?n.alwaysFormat:!1,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var t="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(t,"g");var n="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(n,"g");var r="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(r,"g")}},{key:"interpolate",value:function(t,n,r,s){var o=this,a,l,u,h=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function f(m){return m.replace(/\$/g,"$$$$")}var c=function(d){if(d.indexOf(o.formatSeparator)<0){var b=Ed(n,h,d);return o.alwaysFormat?o.format(b,void 0,r,Kt(Kt(Kt({},s),n),{},{interpolationkey:d})):b}var A=d.split(o.formatSeparator),S=A.shift().trim(),T=A.join(o.formatSeparator).trim();return o.format(Ed(n,h,S),T,r,Kt(Kt(Kt({},s),n),{},{interpolationkey:S}))};this.resetRegExp();var p=s&&s.missingInterpolationHandler||this.options.missingInterpolationHandler,v=s&&s.interpolation&&s.interpolation.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables,x=[{regex:this.regexpUnescape,safeValue:function(d){return f(d)}},{regex:this.regexp,safeValue:function(d){return o.escapeValue?f(o.escape(d)):f(d)}}];return x.forEach(function(m){for(u=0;a=m.regex.exec(t);){var d=a[1].trim();if(l=c(d),l===void 0)if(typeof p=="function"){var b=p(t,a,s);l=typeof b=="string"?b:""}else if(s&&s.hasOwnProperty(d))l="";else if(v){l=a[0];continue}else o.logger.warn("missed to pass in variable ".concat(d," for interpolating ").concat(t)),l="";else typeof l!="string"&&!o.useRawValueToEscape&&(l=Td(l));var A=m.safeValue(l);if(t=t.replace(a[0],A),v?(m.regex.lastIndex+=l.length,m.regex.lastIndex-=a[0].length):m.regex.lastIndex=0,u++,u>=o.maxReplaces)break}}),t}},{key:"nest",value:function(t,n){var r=this,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o,a,l=Kt({},s);l.applyPostProcessor=!1,delete l.defaultValue;function u(p,v){var x=this.nestingOptionsSeparator;if(p.indexOf(x)<0)return p;var m=p.split(new RegExp("".concat(x,"[ ]*{"))),d="{".concat(m[1]);p=m[0],d=this.interpolate(d,l);var b=d.match(/'/g),A=d.match(/"/g);(b&&b.length%2===0&&!A||A.length%2!==0)&&(d=d.replace(/'/g,'"'));try{l=JSON.parse(d),v&&(l=Kt(Kt({},v),l))}catch(S){return this.logger.warn("failed parsing options string in nesting for key ".concat(p),S),"".concat(p).concat(x).concat(d)}return delete l.defaultValue,p}for(;o=this.nestingRegexp.exec(t);){var h=[],f=!1;if(o[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(o[1])){var c=o[1].split(this.formatSeparator).map(function(p){return p.trim()});o[1]=c.shift(),h=c,f=!0}if(a=n(u.call(this,o[1].trim(),l),l),a&&o[0]===t&&typeof a!="string")return a;typeof a!="string"&&(a=Td(a)),a||(this.logger.warn("missed to resolve ".concat(o[1]," for nesting ").concat(t)),a=""),f&&(a=h.reduce(function(p,v){return r.format(p,v,s.lng,Kt(Kt({},s),{},{interpolationkey:o[1].trim()}))},a.trim())),t=t.replace(o[0],a),this.regexp.lastIndex=0}return t}}]),i}();function Jd(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function Gi(i){for(var e=1;e-1){var n=i.split("(");e=n[0].toLowerCase().trim();var r=n[1].substring(0,n[1].length-1);if(e==="currency"&&r.indexOf(":")<0)t.currency||(t.currency=r.trim());else if(e==="relativetime"&&r.indexOf(":")<0)t.range||(t.range=r.trim());else{var s=r.split(";");s.forEach(function(o){if(o){var a=o.split(":"),l=BS(a),u=l[0],h=l.slice(1),f=h.join(":").trim().replace(/^'+|'+$/g,"");t[u.trim()]||(t[u.trim()]=f),f==="false"&&(t[u.trim()]=!1),f==="true"&&(t[u.trim()]=!0),isNaN(f)||(t[u.trim()]=parseInt(f,10))}})}}return{formatName:e,formatOptions:t}}function zn(i){var e={};return function(n,r,s){var o=r+JSON.stringify(s),a=e[o];return a||(a=i(r,s),e[o]=a),a(n)}}var o1=function(){function i(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};hi(this,i),this.logger=ki.create("formatter"),this.options=e,this.formats={number:zn(function(t,n){var r=new Intl.NumberFormat(t,n);return function(s){return r.format(s)}}),currency:zn(function(t,n){var r=new Intl.NumberFormat(t,Gi(Gi({},n),{},{style:"currency"}));return function(s){return r.format(s)}}),datetime:zn(function(t,n){var r=new Intl.DateTimeFormat(t,Gi({},n));return function(s){return r.format(s)}}),relativetime:zn(function(t,n){var r=new Intl.RelativeTimeFormat(t,Gi({},n));return function(s){return r.format(s,n.range||"day")}}),list:zn(function(t,n){var r=new Intl.ListFormat(t,Gi({},n));return function(s){return r.format(s)}})},this.init(e)}return fi(i,[{key:"init",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}},r=n.interpolation;this.formatSeparator=r.formatSeparator?r.formatSeparator:r.formatSeparator||","}},{key:"add",value:function(t,n){this.formats[t.toLowerCase().trim()]=n}},{key:"addCached",value:function(t,n){this.formats[t.toLowerCase().trim()]=zn(n)}},{key:"format",value:function(t,n,r,s){var o=this,a=n.split(this.formatSeparator),l=a.reduce(function(u,h){var f=s1(h),c=f.formatName,p=f.formatOptions;if(o.formats[c]){var v=u;try{var x=s&&s.formatParams&&s.formatParams[s.interpolationkey]||{},m=x.locale||x.lng||s.locale||s.lng||r;v=o.formats[c](u,m,Gi(Gi(Gi({},p),s),x))}catch(d){o.logger.warn(d)}return v}else o.logger.warn("there was no format function for ".concat(c));return u},t);return l}}]),i}();function Id(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function Bd(i){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function u1(i,e){i.pending[e]!==void 0&&(delete i.pending[e],i.pendingCount--)}var h1=function(i){ml(t,i);var e=a1(t);function t(n,r,s){var o,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return hi(this,t),o=e.call(this),yl&&hn.call(an(o)),o.backend=n,o.store=r,o.services=s,o.languageUtils=s.languageUtils,o.options=a,o.logger=ki.create("backendConnector"),o.waitingReads=[],o.maxParallelReads=a.maxParallelReads||10,o.readingCalls=0,o.maxRetries=a.maxRetries>=0?a.maxRetries:5,o.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,o.state={},o.queue=[],o.backend&&o.backend.init&&o.backend.init(s,a.backend,a),o}return fi(t,[{key:"queueLoad",value:function(r,s,o,a){var l=this,u={},h={},f={},c={};return r.forEach(function(p){var v=!0;s.forEach(function(x){var m="".concat(p,"|").concat(x);!o.reload&&l.store.hasResourceBundle(p,x)?l.state[m]=2:l.state[m]<0||(l.state[m]===1?h[m]===void 0&&(h[m]=!0):(l.state[m]=1,v=!1,h[m]===void 0&&(h[m]=!0),u[m]===void 0&&(u[m]=!0),c[x]===void 0&&(c[x]=!0)))}),v||(f[p]=!0)}),(Object.keys(u).length||Object.keys(h).length)&&this.queue.push({pending:h,pendingCount:Object.keys(h).length,loaded:{},errors:[],callback:a}),{toLoad:Object.keys(u),pending:Object.keys(h),toLoadLanguages:Object.keys(f),toLoadNamespaces:Object.keys(c)}}},{key:"loaded",value:function(r,s,o){var a=r.split("|"),l=a[0],u=a[1];s&&this.emit("failedLoading",l,u,s),o&&this.store.addResourceBundle(l,u,o),this.state[r]=s?-1:2;var h={};this.queue.forEach(function(f){NS(f.loaded,[l],u),u1(f,r),s&&f.errors.push(s),f.pendingCount===0&&!f.done&&(Object.keys(f.loaded).forEach(function(c){h[c]||(h[c]={});var p=f.loaded[c];p.length&&p.forEach(function(v){h[c][v]===void 0&&(h[c][v]=!0)})}),f.done=!0,f.errors.length?f.callback(f.errors):f.callback())}),this.emit("loaded",h),this.queue=this.queue.filter(function(f){return!f.done})}},{key:"read",value:function(r,s,o){var a=this,l=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,u=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,h=arguments.length>5?arguments[5]:void 0;if(!r.length)return h(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:r,ns:s,fcName:o,tried:l,wait:u,callback:h});return}return this.readingCalls++,this.backend[o](r,s,function(f,c){if(a.readingCalls--,a.waitingReads.length>0){var p=a.waitingReads.shift();a.read(p.lng,p.ns,p.fcName,p.tried,p.wait,p.callback)}if(f&&c&&l2&&arguments[2]!==void 0?arguments[2]:{},l=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),l&&l();typeof r=="string"&&(r=this.languageUtils.toResolveHierarchy(r)),typeof s=="string"&&(s=[s]);var u=this.queueLoad(r,s,a,l);if(!u.toLoad.length)return u.pending.length||l(),null;u.toLoad.forEach(function(h){o.loadOne(h)})}},{key:"load",value:function(r,s,o){this.prepareLoading(r,s,{},o)}},{key:"reload",value:function(r,s,o){this.prepareLoading(r,s,{reload:!0},o)}},{key:"loadOne",value:function(r){var s=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",a=r.split("|"),l=a[0],u=a[1];this.read(l,u,"read",void 0,void 0,function(h,f){h&&s.logger.warn("".concat(o,"loading namespace ").concat(u," for language ").concat(l," failed"),h),!h&&f&&s.logger.log("".concat(o,"loaded namespace ").concat(u," for language ").concat(l),f),s.loaded(r,h,f)})}},{key:"saveMissing",value:function(r,s,o,a,l){var u=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(s)){this.logger.warn('did not save key "'.concat(o,'" as the namespace "').concat(s,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}o==null||o===""||(this.backend&&this.backend.create&&this.backend.create(r,s,o,a,null,Bd(Bd({},u),{},{isUpdate:l})),!(!r||!r[0])&&this.store.addResource(r[0],s,o,a))}}]),t}(hn);function f1(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(e){var t={};if(si(e[1])==="object"&&(t=e[1]),typeof e[1]=="string"&&(t.defaultValue=e[1]),typeof e[2]=="string"&&(t.tDescription=e[2]),si(e[2])==="object"||si(e[3])==="object"){var n=e[3]||e[2];Object.keys(n).forEach(function(r){t[r]=n[r]})}return t},interpolation:{escapeValue:!0,format:function(e,t,n,r){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function Ld(i){return typeof i.ns=="string"&&(i.ns=[i.ns]),typeof i.fallbackLng=="string"&&(i.fallbackLng=[i.fallbackLng]),typeof i.fallbackNS=="string"&&(i.fallbackNS=[i.fallbackNS]),i.supportedLngs&&i.supportedLngs.indexOf("cimode")<0&&(i.supportedLngs=i.supportedLngs.concat(["cimode"])),i}function jd(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function di(i){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function yo(){}function p1(i){var e=Object.getOwnPropertyNames(Object.getPrototypeOf(i));e.forEach(function(t){typeof i[t]=="function"&&(i[t]=i[t].bind(i))})}var Ma=function(i){ml(t,i);var e=c1(t);function t(){var n,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;if(hi(this,t),n=e.call(this),yl&&hn.call(an(n)),n.options=Ld(r),n.services={},n.logger=ki,n.modules={external:[]},p1(an(n)),s&&!n.isInitialized&&!r.isClone){if(!n.options.initImmediate)return n.init(r,s),no(n,an(n));setTimeout(function(){n.init(r,s)},0)}return n}return fi(t,[{key:"init",value:function(){var r=this,s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=arguments.length>1?arguments[1]:void 0;typeof s=="function"&&(o=s,s={}),!s.defaultNS&&s.defaultNS!==!1&&s.ns&&(typeof s.ns=="string"?s.defaultNS=s.ns:s.ns.indexOf("translation")<0&&(s.defaultNS=s.ns[0]));var a=f1();this.options=di(di(di({},a),this.options),Ld(s)),this.options.compatibilityAPI!=="v1"&&(this.options.interpolation=di(di({},a.interpolation),this.options.interpolation)),s.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=s.keySeparator),s.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=s.nsSeparator);function l(d){return d?typeof d=="function"?new d:d:null}if(!this.options.isClone){this.modules.logger?ki.init(l(this.modules.logger),this.options):ki.init(null,this.options);var u;this.modules.formatter?u=this.modules.formatter:typeof Intl<"u"&&(u=o1);var h=new qS(this.options);this.store=new zS(this.options.resources,this.options);var f=this.services;f.logger=ki,f.resourceStore=this.store,f.languageUtils=h,f.pluralResolver=new n1(h,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),u&&(!this.options.interpolation.format||this.options.interpolation.format===a.interpolation.format)&&(f.formatter=l(u),f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new r1(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new h1(l(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",function(d){for(var b=arguments.length,A=new Array(b>1?b-1:0),S=1;S1?b-1:0),S=1;S0&&c[0]!=="dev"&&(this.options.lng=c[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined");var p=["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"];p.forEach(function(d){r[d]=function(){var b;return(b=r.store)[d].apply(b,arguments)}});var v=["addResource","addResources","addResourceBundle","removeResourceBundle"];v.forEach(function(d){r[d]=function(){var b;return(b=r.store)[d].apply(b,arguments),r}});var x=zr(),m=function(){var b=function(S,T){r.isInitialized&&!r.initializedStoreOnce&&r.logger.warn("init: i18next is already initialized. You should call init just once!"),r.isInitialized=!0,r.options.isClone||r.logger.log("initialized",r.options),r.emit("initialized",r.options),x.resolve(T),o(S,T)};if(r.languages&&r.options.compatibilityAPI!=="v1"&&!r.isInitialized)return b(null,r.t.bind(r));r.changeLanguage(r.options.lng,b)};return this.options.resources||!this.options.initImmediate?m():setTimeout(m,0),x}},{key:"loadResources",value:function(r){var s=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:yo,a=o,l=typeof r=="string"?r:this.language;if(typeof r=="function"&&(a=r),!this.options.resources||this.options.partialBundledLanguages){if(l&&l.toLowerCase()==="cimode")return a();var u=[],h=function(p){if(p){var v=s.services.languageUtils.toResolveHierarchy(p);v.forEach(function(x){u.indexOf(x)<0&&u.push(x)})}};if(l)h(l);else{var f=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);f.forEach(function(c){return h(c)})}this.options.preload&&this.options.preload.forEach(function(c){return h(c)}),this.services.backendConnector.load(u,this.options.ns,function(c){!c&&!s.resolvedLanguage&&s.language&&s.setResolvedLanguage(s.language),a(c)})}else a(null)}},{key:"reloadResources",value:function(r,s,o){var a=zr();return r||(r=this.languages),s||(s=this.options.ns),o||(o=yo),this.services.backendConnector.reload(r,s,function(l){a.resolve(),o(l)}),a}},{key:"use",value:function(r){if(!r)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!r.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return r.type==="backend"&&(this.modules.backend=r),(r.type==="logger"||r.log&&r.warn&&r.error)&&(this.modules.logger=r),r.type==="languageDetector"&&(this.modules.languageDetector=r),r.type==="i18nFormat"&&(this.modules.i18nFormat=r),r.type==="postProcessor"&&eO.addPostProcessor(r),r.type==="formatter"&&(this.modules.formatter=r),r.type==="3rdParty"&&this.modules.external.push(r),this}},{key:"setResolvedLanguage",value:function(r){if(!(!r||!this.languages)&&!(["cimode","dev"].indexOf(r)>-1))for(var s=0;s-1)&&this.store.hasLanguageSomeTranslations(o)){this.resolvedLanguage=o;break}}}},{key:"changeLanguage",value:function(r,s){var o=this;this.isLanguageChangingTo=r;var a=zr();this.emit("languageChanging",r);var l=function(c){o.language=c,o.languages=o.services.languageUtils.toResolveHierarchy(c),o.resolvedLanguage=void 0,o.setResolvedLanguage(c)},u=function(c,p){p?(l(p),o.translator.changeLanguage(p),o.isLanguageChangingTo=void 0,o.emit("languageChanged",p),o.logger.log("languageChanged",p)):o.isLanguageChangingTo=void 0,a.resolve(function(){return o.t.apply(o,arguments)}),s&&s(c,function(){return o.t.apply(o,arguments)})},h=function(c){!r&&!c&&o.services.languageDetector&&(c=[]);var p=typeof c=="string"?c:o.services.languageUtils.getBestMatchFromCodes(c);p&&(o.language||l(p),o.translator.language||o.translator.changeLanguage(p),o.services.languageDetector&&o.services.languageDetector.cacheUserLanguage(p)),o.loadResources(p,function(v){u(v,p)})};return!r&&this.services.languageDetector&&!this.services.languageDetector.async?h(this.services.languageDetector.detect()):!r&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect(h):h(r),a}},{key:"getFixedT",value:function(r,s,o){var a=this,l=function u(h,f){var c;if(si(f)!=="object"){for(var p=arguments.length,v=new Array(p>2?p-2:0),x=2;x1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var a=this.resolvedLanguage||this.languages[0],l=this.options?this.options.fallbackLng:!1,u=this.languages[this.languages.length-1];if(a.toLowerCase()==="cimode")return!0;var h=function(p,v){var x=s.services.backendConnector.state["".concat(p,"|").concat(v)];return x===-1||x===2};if(o.precheck){var f=o.precheck(this,h);if(f!==void 0)return f}return!!(this.hasResourceBundle(a,r)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||h(a,r)&&(!l||h(u,r)))}},{key:"loadNamespaces",value:function(r,s){var o=this,a=zr();return this.options.ns?(typeof r=="string"&&(r=[r]),r.forEach(function(l){o.options.ns.indexOf(l)<0&&o.options.ns.push(l)}),this.loadResources(function(l){a.resolve(),s&&s(l)}),a):(s&&s(),Promise.resolve())}},{key:"loadLanguages",value:function(r,s){var o=zr();typeof r=="string"&&(r=[r]);var a=this.options.preload||[],l=r.filter(function(u){return a.indexOf(u)<0});return l.length?(this.options.preload=a.concat(l),this.loadResources(function(u){o.resolve(),s&&s(u)}),o):(s&&s(),Promise.resolve())}},{key:"dir",value:function(r){if(r||(r=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!r)return"rtl";var s=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"];return s.indexOf(this.services.languageUtils.getLanguagePartFromCode(r))>-1||r.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}},{key:"cloneInstance",value:function(){var r=this,s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:yo,a=di(di(di({},this.options),s),{isClone:!0}),l=new t(a);(s.debug!==void 0||s.prefix!==void 0)&&(l.logger=l.logger.clone(s));var u=["store","services","language"];return u.forEach(function(h){l[h]=r[h]}),l.services=di({},this.services),l.services.utils={hasLoadedNamespace:l.hasLoadedNamespace.bind(l)},l.translator=new Ud(l.services,l.options),l.translator.on("*",function(h){for(var f=arguments.length,c=new Array(f>1?f-1:0),p=1;p0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1?arguments[1]:void 0;return new Ma(i,e)});var Ge=Ma.createInstance();Ge.createInstance=Ma.createInstance;Ge.createInstance;Ge.init;Ge.loadResources;Ge.reloadResources;Ge.use;Ge.changeLanguage;Ge.getFixedT;Ge.t;Ge.exists;Ge.setDefaultNamespace;Ge.hasLoadedNamespace;Ge.loadNamespaces;Ge.loadLanguages;var tO=[],g1=tO.forEach,m1=tO.slice;function y1(i){return g1.call(m1.call(arguments,1),function(e){if(e)for(var t in e)i[t]===void 0&&(i[t]=e[t])}),i}var Dd=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,O1=function(e,t,n){var r=n||{};r.path=r.path||"/";var s=encodeURIComponent(t),o="".concat(e,"=").concat(s);if(r.maxAge>0){var a=r.maxAge-0;if(Number.isNaN(a))throw new Error("maxAge should be a Number");o+="; Max-Age=".concat(Math.floor(a))}if(r.domain){if(!Dd.test(r.domain))throw new TypeError("option domain is invalid");o+="; Domain=".concat(r.domain)}if(r.path){if(!Dd.test(r.path))throw new TypeError("option path is invalid");o+="; Path=".concat(r.path)}if(r.expires){if(typeof r.expires.toUTCString!="function")throw new TypeError("option expires is invalid");o+="; Expires=".concat(r.expires.toUTCString())}if(r.httpOnly&&(o+="; HttpOnly"),r.secure&&(o+="; Secure"),r.sameSite){var l=typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.sameSite;switch(l){case!0:o+="; SameSite=Strict";break;case"lax":o+="; SameSite=Lax";break;case"strict":o+="; SameSite=Strict";break;case"none":o+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return o},Nd={create:function(e,t,n,r){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};n&&(s.expires=new Date,s.expires.setTime(s.expires.getTime()+n*60*1e3)),r&&(s.domain=r),document.cookie=O1(e,encodeURIComponent(t),s)},read:function(e){for(var t="".concat(e,"="),n=document.cookie.split(";"),r=0;r-1&&(n=window.location.hash.substring(window.location.hash.indexOf("?")));for(var r=n.substring(1),s=r.split("&"),o=0;o0){var l=s[o].substring(0,a);l===e.lookupQuerystring&&(t=s[o].substring(a+1))}}}return t}},Vr=null,Zd=function(){if(Vr!==null)return Vr;try{Vr=window!=="undefined"&&window.localStorage!==null;var e="i18next.translate.boo";window.localStorage.setItem(e,"foo"),window.localStorage.removeItem(e)}catch{Vr=!1}return Vr},b1={name:"localStorage",lookup:function(e){var t;if(e.lookupLocalStorage&&Zd()){var n=window.localStorage.getItem(e.lookupLocalStorage);n&&(t=n)}return t},cacheUserLanguage:function(e,t){t.lookupLocalStorage&&Zd()&&window.localStorage.setItem(t.lookupLocalStorage,e)}},Kr=null,Fd=function(){if(Kr!==null)return Kr;try{Kr=window!=="undefined"&&window.sessionStorage!==null;var e="i18next.translate.boo";window.sessionStorage.setItem(e,"foo"),window.sessionStorage.removeItem(e)}catch{Kr=!1}return Kr},v1={name:"sessionStorage",lookup:function(e){var t;if(e.lookupSessionStorage&&Fd()){var n=window.sessionStorage.getItem(e.lookupSessionStorage);n&&(t=n)}return t},cacheUserLanguage:function(e,t){t.lookupSessionStorage&&Fd()&&window.sessionStorage.setItem(t.lookupSessionStorage,e)}},S1={name:"navigator",lookup:function(e){var t=[];if(typeof navigator<"u"){if(navigator.languages)for(var n=0;n0?t:void 0}},x1={name:"htmlTag",lookup:function(e){var t,n=e.htmlTag||(typeof document<"u"?document.documentElement:null);return n&&typeof n.getAttribute=="function"&&(t=n.getAttribute("lang")),t}},k1={name:"path",lookup:function(e){var t;if(typeof window<"u"){var n=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(n instanceof Array)if(typeof e.lookupFromPathIndex=="number"){if(typeof n[e.lookupFromPathIndex]!="string")return;t=n[e.lookupFromPathIndex].replace("/","")}else t=n[0].replace("/","")}return t}},M1={name:"subdomain",lookup:function(e){var t=typeof e.lookupFromSubdomainIndex=="number"?e.lookupFromSubdomainIndex+1:1,n=typeof window<"u"&&window.location&&window.location.hostname&&window.location.hostname.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(n)return n[t]}};function T1(){return{order:["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"],lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"]}}var iO=function(){function i(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};hi(this,i),this.type="languageDetector",this.detectors={},this.init(e,t)}return fi(i,[{key:"init",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=t,this.options=y1(n,this.options||{},T1()),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=r,this.addDetector(_1),this.addDetector(w1),this.addDetector(b1),this.addDetector(v1),this.addDetector(S1),this.addDetector(x1),this.addDetector(k1),this.addDetector(M1)}},{key:"addDetector",value:function(t){this.detectors[t.name]=t}},{key:"detect",value:function(t){var n=this;t||(t=this.options.order);var r=[];return t.forEach(function(s){if(n.detectors[s]){var o=n.detectors[s].lookup(n.options);o&&typeof o=="string"&&(o=[o]),o&&(r=r.concat(o))}}),this.services.languageUtils.getBestMatchFromCodes?r:r.length>0?r[0]:null}},{key:"cacheUserLanguage",value:function(t,n){var r=this;n||(n=this.options.caches),n&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(t)>-1||n.forEach(function(s){r.detectors[s]&&r.detectors[s].cacheUserLanguage(t,r.options)}))}}]),i}();iO.type="languageDetector";const nO={en:{translation:{"language-name":"english",toolbar:{run:"Run all code (ctrl+shift+enter)",upload:"upload to gallery",clear:"clear all",shuffle:"show random sketch",random:"make random change","load-extension":"load library or extension","show-info":"show info window","hide-info":"hide info window"},info:{title:"hydra",subtitle:"live coding video synth",description:"Hydra is live code-able video synth and coding environment that runs directly in the browser. It is free and open-source and made for beginners and experts alike.","get-started-title":"To get started:","get-started-list":["Close this window","Change some numbers","Type Ctrl + Shift + Enter"],"description-detailed":"Hydra is written in JavaScript and compiles to WebGL under the hood. The syntax is inspired by analog modular synthesis, in which chaining or patching a set of transformations together generates a visual result.",uses:"Hydra can be used:","uses-list":["to mix and add effects to camera feeds, screenshares, live streams, and videos","to create generative and audio-reactive visuals, and share them online with others","in combination with other javascript libraries such as P5.js, Tone.js, THREE.js, or gibber","to add interactive video effects to a website","to experiment with and learn about video feedback, fractals, and pixel operations","to stream video between browsers and live-jam with others online"],author:"Created by olivia.","more-info":"For more information and instructions, see: the interactive documentation, a list of hydra functions, the community database of projects and tutorials, a gallery of user-generated sketches, and the source code on github,","more-info-forums":"There is also an active Discord server and facebook group for hydra users+contributors.",support:"If you enjoy using Hydra, please consider supporting continued development <3 ."},extensions:{"about-extensions":"Show community extensions for hydra-synth.","show-example":"Load and run {{extension-name}} example.","show-library":"Add code for loading {{extension-name}} to the top of the current sketch.","show-docs":"Documentation of usage for {{extension-name}}"}}}},C1=["ja","es","ar","id","pt-br","ch","ko","fr","de"],E1=i=>`https://raw.githubusercontent.com/hydra-synth/l10n/main/${i}/editor.json`;Ge.use(iO).init({debug:!0,fallbackLng:"en",partialBundledLanguages:!0,resources:nO});function Q1(i,e){const t={};let n=new URLSearchParams(window.location.search),r=n.get("l10n-lang"),s=n.get("l10n-url");C1.forEach(l=>{a(l,E1(l))}),r!==null&&s!==null&&a(r,s),o(),e.on("set language",l=>{Ge.changeLanguage(l,(u,h)=>{i.translation.selectedLanguage=l,e.emit("render")})});function o(){Object.keys(nO).forEach(l=>{const u=l.split("-")[0];t[u]=Ge.getFixedT(u)("language-name")}),i.translation={t:Ge.t,languages:t,selectedLanguage:Ge.language,textDirection:Ge.language==="ar"?"rtl":"ltr"}}function a(l="es",u){const h="color: purple; background: orange; font-size: 14px;padding:10px";console.log(`%cloading translation for ${l} from ${u}`,h),fetch(u).then(f=>f.ok?f.json():f.text().then(c=>{throw new Error(c)})).then(f=>{window.i18n=Ge,console.log("adding language",l,f);const c=l.split("-")[0];Ge.addResourceBundle(c,"translation",f),o(),e.emit("render")})}}const A1="https://raw.githubusercontent.com/hydra-synth/hydra-extensions/main/";async function R1(i,e){i.extensions={baseURL:A1,selectedCategoryIndex:0,categories:[{name:"extensions",slug:"extensions",entries:[],hasLoaded:!1},{name:"external libraries",slug:"external-libraries",entries:[],hasLoaded:!1},{name:"examples",slug:"examples",entries:[],hasLoaded:!1}]},e.on("extensions: select category",(t=i.extensions.selectedCategoryIndex)=>{i.extensions.selectedCategoryIndex=t,e.emit("render");const n=i.extensions.categories[t];if(!n.hasLoaded){const r=i.extensions.baseURL+n.slug+".json?laskd";fetch(r).then(s=>s.json()).then(s=>{console.log("loaded d",s),s.forEach(o=>{o.thumbnail=i.extensions.baseURL+"thumbnails/"+o.thumbnail}),n.entries=s,e.emit("render")})}}),e.on("extensions: add to editor",t=>{const{categories:n,selectedCategoryIndex:r}=i.extensions,s=n[r].entries[t].load;e.emit("editor: add code to top",s)}),e.on("extensions: load example",(t,n)=>{const{categories:r,selectedCategoryIndex:s}=i.extensions,o=r[s].entries[t].examples[n],a=new URL(o);console.log(a,i.gallery),i.gallery.setSketchFromURL(a.search,l=>{e.emit("load and eval code",l)})})}const rO=1024;let U1=0,Kl=class{constructor(e,t){this.from=e,this.to=t}};class we{constructor(e={}){this.id=U1++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Ut.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}}we.closedBy=new we({deserialize:i=>i.split(" ")});we.openedBy=new we({deserialize:i=>i.split(" ")});we.group=new we({deserialize:i=>i.split(" ")});we.contextHash=new we({perNode:!0});we.lookAhead=new we({perNode:!0});we.mounted=new we({perNode:!0});const $1=Object.create(null);class Ut{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):$1,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new Ut(e.name||"",t,e.id,n);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(r)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[s[0].id]=s[1]}}return r}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(we.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 n=>{for(let r=n.prop(we.group),s=-1;s<(r?r.length:0);s++){let o=t[s<0?n.name:r[s]];if(o)return o}}}}Ut.none=new Ut("",Object.create(null),0,8);class Kf{constructor(e){this.types=e;for(let t=0;t0;for(let l=this.cursor(o|nt.IncludeAnonymous);;){let u=!1;if(l.from<=s&&l.to>=r&&(!a&&l.type.isAnonymous||t(l)!==!1)){if(l.firstChild())continue;u=!0}for(;u&&n&&(a||!l.type.isAnonymous)&&n(l),!l.nextSibling();){if(!l.parent())return;u=!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(e={}){return this.children.length<=8?this:ec(Ut.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new He(this.type,t,n,r,this.propValues),e.makeTree||((t,n,r)=>new He(Ut.none,t,n,r)))}static build(e){return J1(e)}}He.empty=new He(Ut.none,[],[],0);class qf{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 qf(this.buffer,this.index)}}class Dn{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Ut.none}toString(){let e=[];for(let t=0;t0));l=o[l+3]);return a}slice(e,t,n){let r=this.buffer,s=new Uint16Array(t-e),o=0;for(let a=e,l=0;a=e&&te;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function oO(i,e){let t=i.childBefore(e);for(;t;){let n=t.lastChild;if(!n||n.to!=t.to)break;n.type.isError&&n.from==n.to?(i=t,t=n.prevSibling):t=n}return i}function Mr(i,e,t,n){for(var r;i.from==i.to||(t<1?i.from>=e:i.from>e)||(t>-1?i.to<=e:i.to0?a.length:-1;e!=u;e+=t){let h=a[e],f=l[e]+o.from;if(sO(r,n,f,f+h.length)){if(h instanceof Dn){if(s&nt.ExcludeBuffers)continue;let c=h.findChild(0,h.buffer.length,t,n-f,r);if(c>-1)return new Mi(new P1(o,h,e,f),null,c)}else if(s&nt.IncludeAnonymous||!h.type.isAnonymous||Hf(h)){let c;if(!(s&nt.IgnoreMounts)&&h.props&&(c=h.prop(we.mounted))&&!c.overlay)return new oi(c.tree,f,e,o);let p=new oi(h,f,e,o);return s&nt.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?h.children.length-1:0,t,n,r)}}}if(s&nt.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<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)}enter(e,t,n=0){let r;if(!(n&nt.IgnoreOverlays)&&(r=this._tree.prop(we.mounted))&&r.overlay){let s=e-this.from;for(let{from:o,to:a}of r.overlay)if((t>0?o<=s:o=s:a>s))return new oi(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}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}cursor(e=0){return new Ea(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return Mr(this,e,t,!1)}resolveInner(e,t=0){return Mr(this,e,t,!0)}enterUnfinishedNodesBefore(e){return oO(this,e)}getChild(e,t=null,n=null){let r=Ta(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return Ta(this,e,t,n)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return Ca(this,e)}}function Ta(i,e,t,n){let r=i.cursor(),s=[];if(!r.firstChild())return s;if(t!=null){for(;!r.type.is(t);)if(!r.nextSibling())return s}for(;;){if(n!=null&&r.type.is(n))return s;if(r.type.is(e)&&s.push(r.node),!r.nextSibling())return n==null?s:[]}}function Ca(i,e,t=e.length-1){for(let n=i.parent;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}class P1{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}}class Mi{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){this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,n);return s<0?null:new Mi(this.context,this,s)}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)}enter(e,t,n=0){if(n&nt.ExcludeBuffers)return null;let{buffer:r}=this.context,s=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return s<0?null:new Mi(this.context,this,s)}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:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Mi(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new Mi(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new Ea(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,s=n.buffer[this.index+3];if(s>r){let o=n.buffer[this.index+1];e.push(n.slice(r,s,o)),t.push(0)}return new He(this.type,e,t,this.to-this.from)}resolve(e,t=0){return Mr(this,e,t,!1)}resolveInner(e,t=0){return Mr(this,e,t,!0)}enterUnfinishedNodesBefore(e){return oO(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,n=null){let r=Ta(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return Ta(this,e,t,n)}get node(){return this}matchContext(e){return Ca(this,e)}}class Ea{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof oi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.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 oi?(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,s=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}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&nt.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&nt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&nt.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 r=n<0?0:this.stack[n]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(r)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}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-1)for(let s=t+e,o=e<0?-1:n._tree.children.length;s!=o;s+=e){let a=n._tree.children[s];if(this.mode&nt.IncludeAnonymous||a instanceof Dn||!a.type.isAnonymous||Hf(a))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=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,n=s+1;break e}r=this.stack[--s]}for(let r=n;r=0;s--){if(s<0)return Ca(this.node,e,r);let o=n[t.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}}function Hf(i){return i.children.some(e=>e instanceof Dn||!e.type.isAnonymous||Hf(e))}function J1(i){var e;let{buffer:t,nodeSet:n,maxBufferLength:r=rO,reused:s=[],minRepeatType:o=n.types.length}=i,a=Array.isArray(t)?new qf(t,t.length):t,l=n.types,u=0,h=0;function f(S,T,k,Q,C){let{id:I,start:_,end:j,size:D}=a,V=h;for(;D<0;)if(a.next(),D==-1){let N=s[I];k.push(N),Q.push(_-S);return}else if(D==-3){u=I;return}else if(D==-4){h=I;return}else throw new RangeError(`Unrecognized record size: ${D}`);let ee=l[I],B,Z,R=_-S;if(j-_<=r&&(Z=x(a.pos-T,C))){let N=new Uint16Array(Z.size-Z.skip),Y=a.pos-Z.size,te=N.length;for(;a.pos>Y;)te=m(Z.start,N,te);B=new Dn(N,j-Z.start,n),R=Z.start-S}else{let N=a.pos-D;a.next();let Y=[],te=[],se=I>=o?I:-1,le=0,ue=j;for(;a.pos>N;)se>=0&&a.id==se&&a.size>=0?(a.end<=ue-r&&(p(Y,te,_,le,a.end,ue,se,V),le=Y.length,ue=a.end),a.next()):f(_,N,Y,te,se);if(se>=0&&le>0&&le-1&&le>0){let de=c(ee);B=ec(ee,Y,te,0,Y.length,0,j-_,de,de)}else B=v(ee,Y,te,j-_,V-j)}k.push(B),Q.push(R)}function c(S){return(T,k,Q)=>{let C=0,I=T.length-1,_,j;if(I>=0&&(_=T[I])instanceof He){if(!I&&_.type==S&&_.length==Q)return _;(j=_.prop(we.lookAhead))&&(C=k[I]+_.length+j)}return v(S,T,k,Q,C)}}function p(S,T,k,Q,C,I,_,j){let D=[],V=[];for(;S.length>Q;)D.push(S.pop()),V.push(T.pop()+k-C);S.push(v(n.types[_],D,V,I-C,j-I)),T.push(C-k)}function v(S,T,k,Q,C=0,I){if(u){let _=[we.contextHash,u];I=I?[_].concat(I):[_]}if(C>25){let _=[we.lookAhead,C];I=I?[_].concat(I):[_]}return new He(S,T,k,Q,I)}function x(S,T){let k=a.fork(),Q=0,C=0,I=0,_=k.end-r,j={size:0,start:0,skip:0};e:for(let D=k.pos-S;k.pos>D;){let V=k.size;if(k.id==T&&V>=0){j.size=Q,j.start=C,j.skip=I,I+=4,Q+=4,k.next();continue}let ee=k.pos-V;if(V<0||ee=o?4:0,Z=k.start;for(k.next();k.pos>ee;){if(k.size<0)if(k.size==-3)B+=4;else break e;else k.id>=o&&(B+=4);k.next()}C=Z,Q+=V,I+=B}return(T<0||Q==S)&&(j.size=Q,j.start=C,j.skip=I),j.size>4?j:void 0}function m(S,T,k){let{id:Q,start:C,end:I,size:_}=a;if(a.next(),_>=0&&Q4){let D=a.pos-(_-4);for(;a.pos>D;)k=m(S,T,k)}T[--k]=j,T[--k]=I-S,T[--k]=C-S,T[--k]=Q}else _==-3?u=Q:_==-4&&(h=Q);return k}let d=[],b=[];for(;a.pos>0;)f(i.start||0,i.bufferStart||0,d,b,-1);let A=(e=i.length)!==null&&e!==void 0?e:d.length?b[0]+d[0].length:0;return new He(l[i.topID],d.reverse(),b.reverse(),A)}const Gd=new WeakMap;function ua(i,e){if(!i.isAnonymous||e instanceof Dn||e.type!=i)return 1;let t=Gd.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=i||!(n instanceof He)){t=1;break}t+=ua(i,n)}Gd.set(e,t)}return t}function ec(i,e,t,n,r,s,o,a,l){let u=0;for(let v=n;v=h)break;k+=Q}if(A==S+1){if(k>h){let Q=v[S];p(Q.children,Q.positions,0,Q.children.length,x[S]+b);continue}f.push(v[S])}else{let Q=x[A-1]+v[A-1].length-T;f.push(ec(i,v,x,S,A,T,Q,null,l))}c.push(T+b-s)}}return p(e,t,n,r,0),(a||l)(f,c,o)}class I1{constructor(){this.map=new WeakMap}setBuffer(e,t,n){let r=this.map.get(e);r||this.map.set(e,r=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 Mi?this.setBuffer(e.context.buffer,e.index,t):e instanceof oi&&this.map.set(e.tree,t)}get(e){return e instanceof Mi?this.getBuffer(e.context.buffer,e.index):e instanceof oi?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)}}class Qn{constructor(e,t,n,r,s=!1,o=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let r=[new Qn(0,e.length,e,0,!1,n)];for(let s of t)s.to>e.length&&r.push(s);return r}static applyChanges(e,t,n=128){if(!t.length)return e;let r=[],s=1,o=e.length?e[0]:null;for(let a=0,l=0,u=0;;a++){let h=a=n)for(;o&&o.from=c.from||f<=c.to||u){let p=Math.max(c.from,l)-u,v=Math.min(c.to,f)-u;c=p>=v?null:new Qn(p,v,c.tree,c.offset+u,a>0,!!h)}if(c&&r.push(c),o.to>f)break;o=snew Kl(r.from,r.to)):[new Kl(0,0)]:[new Kl(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let s=r.advance();if(s)return s}}}class B1{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 we({perNode:!0});class Te{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),vi.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){let n=[];return this.decompose(e,t,n,0),vi.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new ws(this),s=new ws(e);for(let o=t,a=t;;){if(r.next(o),s.next(o),o=0,r.lineBreak!=s.lineBreak||r.done!=s.done||r.value!=s.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new ws(this,e)}iterRange(e,t=this.length){return new lO(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new uO(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Te.empty:e.length<=32?new Ye(e):vi.from(Ye.split(e,[]))}}class Ye extends Te{constructor(e,t=L1(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.text[s],a=r+o.length;if((t?n:a)>=e)return new j1(r,a,n,o);r=a+1,n++}}decompose(e,t,n,r){let s=e<=0&&t>=this.length?this:new Ye(Wd(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let o=n.pop(),a=ha(s.text,o.text.slice(),0,s.length);if(a.length<=32)n.push(new Ye(a,o.length+s.length));else{let l=a.length>>1;n.push(new Ye(a.slice(0,l)),new Ye(a.slice(l)))}}else n.push(s)}replace(e,t,n){if(!(n instanceof Ye))return super.replace(e,t,n);let r=ha(this.text,ha(n.text,Wd(this.text,0,e)),t),s=this.length+n.length-(t-e);return r.length<=32?new Ye(r,s):vi.from(Ye.split(r,[]),s)}sliceString(e,t=this.length,n=` +`){let r="";for(let s=0,o=0;s<=t&&oe&&o&&(r+=n),es&&(r+=a.slice(Math.max(0,e-s),t-s)),s=l+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],r=-1;for(let s of e)n.push(s),r+=s.length+1,n.length==32&&(t.push(new Ye(n,r)),n=[],r=-1);return r>-1&&t.push(new Ye(n,r)),t}}class vi extends Te{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let n of e)this.lines+=n.lines}lineInner(e,t,n,r){for(let s=0;;s++){let o=this.children[s],a=r+o.length,l=n+o.lines-1;if((t?l:a)>=e)return o.lineInner(e,t,n,r);r=a+1,n=l+1}}decompose(e,t,n,r){for(let s=0,o=0;o<=t&&s=o){let u=r&((o<=e?1:0)|(l>=t?2:0));o>=e&&l<=t&&!u?n.push(a):a.decompose(e-o,t-o,n,u)}o=l+1}}replace(e,t,n){if(n.lines=s&&t<=a){let l=o.replace(e-s,t-s,n),u=this.lines-o.lines+l.lines;if(l.lines>5-1&&l.lines>u>>5+1){let h=this.children.slice();return h[r]=l,new vi(h,this.length-(t-e)+n.length)}return super.replace(s,a,l)}s=a+1}return super.replace(e,t,n)}sliceString(e,t=this.length,n=` +`){let r="";for(let s=0,o=0;se&&s&&(r+=n),eo&&(r+=a.sliceString(e-o,t-o,n)),o=l+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof vi))return 0;let n=0,[r,s,o,a]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;r+=t,s+=t){if(r==o||s==a)return n;let l=this.children[r],u=e.children[s];if(l!=u)return n+l.scanIdentical(u,t);n+=l.length+1}}static from(e,t=e.reduce((n,r)=>n+r.length+1,-1)){let n=0;for(let p of e)n+=p.lines;if(n<32){let p=[];for(let v of e)v.flatten(p);return new Ye(p,t)}let r=Math.max(32,n>>5),s=r<<1,o=r>>1,a=[],l=0,u=-1,h=[];function f(p){let v;if(p.lines>s&&p instanceof vi)for(let x of p.children)f(x);else p.lines>o&&(l>o||!l)?(c(),a.push(p)):p instanceof Ye&&l&&(v=h[h.length-1])instanceof Ye&&p.lines+v.lines<=32?(l+=p.lines,u+=p.length+1,h[h.length-1]=new Ye(v.text.concat(p.text),v.length+1+p.length)):(l+p.lines>r&&c(),l+=p.lines,u+=p.length+1,h.push(p))}function c(){l!=0&&(a.push(h.length==1?h[0]:vi.from(h,u)),u=-1,l=h.length=0)}for(let p of e)f(p);return c(),a.length==1?a[0]:new vi(a,t)}}Te.empty=new Ye([""],0);function L1(i){let e=-1;for(let t of i)e+=t.length+1;return e}function ha(i,e,t=0,n=1e9){for(let r=0,s=0,o=!0;s=t&&(l>n&&(a=a.slice(0,n-r)),r0?1:(e instanceof Ye?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],s=this.offsets[n],o=s>>1,a=r instanceof Ye?r.text.length:r.children.length;if(o==(t>0?a:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(r instanceof Ye){let l=r.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,l.length>Math.max(0,e))return this.value=e==0?l:t>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=r.children[o+(t<0?-1:0)];e>l.length?(e-=l.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(l),this.offsets.push(t>0?1:(l instanceof Ye?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class lO{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new ws(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class uO{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Te.prototype[Symbol.iterator]=function(){return this.iter()},ws.prototype[Symbol.iterator]=lO.prototype[Symbol.iterator]=uO.prototype[Symbol.iterator]=function(){return this});class j1{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}}let pr="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(i=>i?parseInt(i,36):1);for(let i=1;ii)return pr[e-1]<=i;return!1}function Yd(i){return i>=127462&&i<=127487}const zd=8205;function xt(i,e,t=!0,n=!0){return(t?hO:N1)(i,e,n)}function hO(i,e,t){if(e==i.length)return e;e&&fO(i.charCodeAt(e))&&cO(i.charCodeAt(e-1))&&e--;let n=dt(i,e);for(e+=Zt(n);e=0&&Yd(dt(i,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function N1(i,e,t){for(;e>0;){let n=hO(i,e-2,t);if(n=56320&&i<57344}function cO(i){return i>=55296&&i<56320}function dt(i,e){let t=i.charCodeAt(e);if(!cO(t)||e+1==i.length)return t;let n=i.charCodeAt(e+1);return fO(n)?(t-55296<<10)+(n-56320)+65536:t}function tc(i){return i<=65535?String.fromCharCode(i):(i-=65536,String.fromCharCode((i>>10)+55296,(i&1023)+56320))}function Zt(i){return i<65536?1:2}const vh=/\r\n?|\n/;var gt=function(i){return i[i.Simple=0]="Simple",i[i.TrackDel=1]="TrackDel",i[i.TrackBefore=2]="TrackBefore",i[i.TrackAfter=3]="TrackAfter",i}(gt||(gt={}));class Qi{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return s+(e-r);s+=a}else{if(n!=gt.Simple&&u>=e&&(n==gt.TrackDel&&re||n==gt.TrackBefore&&re))return null;if(u>e||u==e&&t<0&&!a)return e==r||t<0?s:s+l;s+=l}r=u}if(e>r)throw new RangeError(`Position ${e} is out of range for changeset of length ${r}`);return s}touchesRange(e,t=e){for(let n=0,r=0;n=0&&r<=t&&a>=e)return rt?"cover":!0;r=a}return!1}toString(){let e="";for(let t=0;t=0?":"+r:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Qi(e)}static create(e){return new Qi(e)}}class it extends Qi{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Sh(this,(t,n,r,s,o)=>e=e.replace(r,r+(n-t),o),!1),e}mapDesc(e,t=!1){return xh(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let r=0,s=0;r=0){t[r]=a,t[r+1]=o;let l=r>>1;for(;n.length0&&tn(n,t,s.text),s.forward(h),a+=h}let u=e[o++];for(;a>1].toJSON()))}return e}static of(e,t,n){let r=[],s=[],o=0,a=null;function l(h=!1){if(!h&&!r.length)return;oc||f<0||c>t)throw new RangeError(`Invalid change range ${f} to ${c} (in doc of length ${t})`);let v=p?typeof p=="string"?Te.of(p.split(n||vh)):p:Te.empty,x=v.length;if(f==c&&x==0)return;fo&&_t(r,f-o,-1),_t(r,c-f,x),tn(s,r,v),o=c}}return u(e),l(!a),a}static empty(e){return new it(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let r=0;ra&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)t.push(s[0],0);else{for(;n.length=0&&t<=0&&t==i[r+1]?i[r]+=e:e==0&&i[r]==0?i[r+1]+=t:n?(i[r]+=e,i[r+1]+=t):i.push(e,t)}function tn(i,e,t){if(t.length==0)return;let n=e.length-2>>1;if(n>1])),!(t||o==i.sections.length||i.sections[o+1]<0);)a=i.sections[o++],l=i.sections[o++];e(r,u,s,h,f),r=u,s=h}}}function xh(i,e,t,n=!1){let r=[],s=n?[]:null,o=new Es(i),a=new Es(e);for(let l=-1;;)if(o.ins==-1&&a.ins==-1){let u=Math.min(o.len,a.len);_t(r,u,-1),o.forward(u),a.forward(u)}else if(a.ins>=0&&(o.ins<0||l==o.i||o.off==0&&(a.len=0&&l=0){let u=0,h=o.len;for(;h;)if(a.ins==-1){let f=Math.min(h,a.len);u+=f,h-=f,a.forward(f)}else if(a.ins==0&&a.lenl||o.ins>=0&&o.len>l)&&(a||n.length>u),s.forward2(l),o.forward(l)}}}}class Es{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?Te.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?Te.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Tn{constructor(e,t,n){this.from=e,this.to=t,this.flags=n}get anchor(){return this.flags&16?this.to:this.from}get head(){return this.flags&16?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&4?-1:this.flags&8?1:0}get bidiLevel(){let e=this.flags&3;return e==3?null:e}get goalColumn(){let e=this.flags>>5;return e==33554431?void 0:e}map(e,t=-1){let n,r;return this.empty?n=r=e.mapPos(this.from,t):(n=e.mapPos(this.from,1),r=e.mapPos(this.to,-1)),n==this.from&&r==this.to?this:new Tn(n,r,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return K.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return K.range(this.anchor,n)}eq(e){return this.anchor==e.anchor&&this.head==e.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return K.range(e.anchor,e.head)}static create(e,t,n){return new Tn(e,t,n)}}class K{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:K.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;te.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new K(e.ranges.map(t=>Tn.fromJSON(t)),e.main)}static single(e,t=e){return new K([K.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let n=0,r=0;re?4:0)|s)}static normalized(e,t=0){let n=e[t];e.sort((r,s)=>r.from-s.from),t=e.indexOf(n);for(let r=1;rs.head?K.range(l,a):K.range(a,l))}}return new K(e,t)}}function pO(i,e){for(let t of i.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let ic=0;class pe{constructor(e,t,n,r,s){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=ic++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}static define(e={}){return new pe(e.combine||(t=>t),e.compareInput||((t,n)=>t===n),e.compare||(e.combine?(t,n)=>t===n:nc),!!e.static,e.enables)}of(e){return new fa([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new fa(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new fa(e,this,2,t)}from(e,t){return t||(t=n=>n),this.compute([e],n=>t(n.field(e)))}}function nc(i,e){return i==e||i.length==e.length&&i.every((t,n)=>t===e[n])}class fa{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=ic++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,s=this.id,o=e[s]>>1,a=this.type==2,l=!1,u=!1,h=[];for(let f of this.dependencies)f=="doc"?l=!0:f=="selection"?u=!0:((t=e[f.id])!==null&&t!==void 0?t:1)&1||h.push(e[f.id]);return{create(f){return f.values[o]=n(f),1},update(f,c){if(l&&c.docChanged||u&&(c.docChanged||c.selection)||kh(f,h)){let p=n(f);if(a?!Vd(p,f.values[o],r):!r(p,f.values[o]))return f.values[o]=p,1}return 0},reconfigure:(f,c)=>{let p,v=c.config.address[s];if(v!=null){let x=Aa(c,v);if(this.dependencies.every(m=>m instanceof pe?c.facet(m)===f.facet(m):m instanceof ft?c.field(m,!1)==f.field(m,!1):!0)||(a?Vd(p=n(f),x,r):r(p=n(f),x)))return f.values[o]=x,0}else p=n(f);return f.values[o]=p,1}}}}function Vd(i,e,t){if(i.length!=e.length)return!1;for(let n=0;ni[l.id]),r=t.map(l=>l.type),s=n.filter(l=>!(l&1)),o=i[e.id]>>1;function a(l){let u=[];for(let h=0;hn===r),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(Kd).find(n=>n.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:n=>(n.values[t]=this.create(n),1),update:(n,r)=>{let s=n.values[t],o=this.updateF(s,r);return this.compareF(s,o)?0:(n.values[t]=o,1)},reconfigure:(n,r)=>r.config.address[this.id]!=null?(n.values[t]=r.field(this),0):(n.values[t]=this.create(n),1)}}init(e){return[this,Kd.of({field:this,create:e})]}get extension(){return this}}const vn={lowest:4,low:3,default:2,high:1,highest:0};function qr(i){return e=>new gO(e,i)}const Nn={highest:qr(vn.highest),high:qr(vn.high),default:qr(vn.default),low:qr(vn.low),lowest:qr(vn.lowest)};class gO{constructor(e,t){this.inner=e,this.prec=t}}class Ol{of(e){return new Mh(this,e)}reconfigure(e){return Ol.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Mh{constructor(e,t){this.compartment=e,this.inner=t}}class Qa{constructor(e,t,n,r,s,o){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,n){let r=[],s=Object.create(null),o=new Map;for(let c of F1(e,t,o))c instanceof ft?r.push(c):(s[c.facet.id]||(s[c.facet.id]=[])).push(c);let a=Object.create(null),l=[],u=[];for(let c of r)a[c.id]=u.length<<1,u.push(p=>c.slot(p));let h=n==null?void 0:n.config.facets;for(let c in s){let p=s[c],v=p[0].facet,x=h&&h[c]||[];if(p.every(m=>m.type==0))if(a[v.id]=l.length<<1|1,nc(x,p))l.push(n.facet(v));else{let m=v.combine(p.map(d=>d.value));l.push(n&&v.compare(m,n.facet(v))?n.facet(v):m)}else{for(let m of p)m.type==0?(a[m.id]=l.length<<1|1,l.push(m.value)):(a[m.id]=u.length<<1,u.push(d=>m.dynamicSlot(d)));a[v.id]=u.length<<1,u.push(m=>Z1(m,v,p))}}let f=u.map(c=>c(a));return new Qa(e,o,f,a,l,s)}}function F1(i,e,t){let n=[[],[],[],[],[]],r=new Map;function s(o,a){let l=r.get(o);if(l!=null){if(l<=a)return;let u=n[l].indexOf(o);u>-1&&n[l].splice(u,1),o instanceof Mh&&t.delete(o.compartment)}if(r.set(o,a),Array.isArray(o))for(let u of o)s(u,a);else if(o instanceof Mh){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(o.compartment)||o.inner;t.set(o.compartment,u),s(u,a)}else if(o instanceof gO)s(o.inner,o.prec);else if(o instanceof ft)n[a].push(o),o.provides&&s(o.provides,a);else if(o instanceof fa)n[a].push(o),o.facet.extensions&&s(o.facet.extensions,vn.default);else{let u=o.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(u,a)}}return s(i,vn.default),n.reduce((o,a)=>o.concat(a))}function bs(i,e){if(e&1)return 2;let t=e>>1,n=i.status[t];if(n==4)throw new Error("Cyclic dependency between fields and/or facets");if(n&2)return n;i.status[t]=4;let r=i.computeSlot(i,i.config.dynamicSlots[t]);return i.status[t]=2|r}function Aa(i,e){return e&1?i.config.staticValues[e>>1]:i.values[e>>1]}const mO=pe.define(),yO=pe.define({combine:i=>i.some(e=>e),static:!0}),OO=pe.define({combine:i=>i.length?i[0]:void 0,static:!0}),_O=pe.define(),wO=pe.define(),bO=pe.define(),vO=pe.define({combine:i=>i.length?i[0]:!1});class Ni{constructor(e,t){this.type=e,this.value=t}static define(){return new X1}}class X1{of(e){return new Ni(this,e)}}class G1{constructor(e){this.map=e}of(e){return new Oe(this,e)}}class Oe{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new Oe(this.type,t)}is(e){return this.type==e}static define(e={}){return new G1(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let s=r.map(t);s&&n.push(s)}return n}}Oe.reconfigure=Oe.define();Oe.appendConfig=Oe.define();class et{constructor(e,t,n,r,s,o){this.startState=e,this.changes=t,this.selection=n,this.effects=r,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,n&&pO(n,t.newLength),s.some(a=>a.type==et.time)||(this.annotations=s.concat(et.time.of(Date.now())))}static create(e,t,n,r,s,o){return new et(e,t,n,r,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(et.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}et.time=Ni.define();et.userEvent=Ni.define();et.addToHistory=Ni.define();et.remote=Ni.define();function W1(i,e){let t=[];for(let n=0,r=0;;){let s,o;if(n=i[n]))s=i[n++],o=i[n++];else if(r=0;r--){let s=n[r](i);s instanceof et?i=s:Array.isArray(s)&&s.length==1&&s[0]instanceof et?i=s[0]:i=xO(e,gr(s),!1)}return i}function z1(i){let e=i.startState,t=e.facet(bO),n=i;for(let r=t.length-1;r>=0;r--){let s=t[r](i);s&&Object.keys(s).length&&(n=SO(n,Th(e,s,i.changes.newLength),!0))}return n==i?i:et.create(e,i.changes,i.selection,n.effects,n.annotations,n.scrollIntoView)}const V1=[];function gr(i){return i==null?V1:Array.isArray(i)?i:[i]}var je=function(i){return i[i.Word=0]="Word",i[i.Space=1]="Space",i[i.Other=2]="Other",i}(je||(je={}));const K1=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Ch;try{Ch=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function q1(i){if(Ch)return Ch.test(i);for(let e=0;e"€"&&(t.toUpperCase()!=t.toLowerCase()||K1.test(t)))return!0}return!1}function H1(i){return e=>{if(!/\S/.test(e))return je.Space;if(q1(e))return je.Word;for(let t=0;t-1)return je.Word;return je.Other}}class ke{constructor(e,t,n,r,s,o){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let a=0;ar.set(l,a)),t=null),r.set(o.value.compartment,o.value.extension)):o.is(Oe.reconfigure)?(t=null,n=o.value):o.is(Oe.appendConfig)&&(t=null,n=gr(n).concat(o.value));let s;t?s=e.startState.values.slice():(t=Qa.resolve(n,r,this),s=new ke(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(a,l)=>l.reconfigure(a,this),null).values),new ke(t,e.newDoc,e.newSelection,s,(o,a)=>a.update(o,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:K.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),s=[n.range],o=gr(n.effects);for(let a=1;ao.spec.fromJSON(a,l)))}}return ke.create({doc:e.doc,selection:K.fromJSON(e.selection),extensions:t.extensions?r.concat([t.extensions]):r})}static create(e={}){let t=Qa.resolve(e.extensions||[],new Map),n=e.doc instanceof Te?e.doc:Te.of((e.doc||"").split(t.staticFacet(ke.lineSeparator)||vh)),r=e.selection?e.selection instanceof K?e.selection:K.single(e.selection.anchor,e.selection.head):K.single(0);return pO(r,n.length),t.staticFacet(yO)||(r=r.asSingle()),new ke(t,n,r,t.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(ke.tabSize)}get lineBreak(){return this.facet(ke.lineSeparator)||` +`}get readOnly(){return this.facet(vO)}phrase(e,...t){for(let n of this.facet(ke.phrases))if(Object.prototype.hasOwnProperty.call(n,e)){e=n[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(n,r)=>{if(r=="$")return"$";let s=+(r||1);return!s||s>t.length?n:t[s-1]})),e}languageDataAt(e,t,n=-1){let r=[];for(let s of this.facet(mO))for(let o of s(this,t,n))Object.prototype.hasOwnProperty.call(o,e)&&r.push(o[e]);return r}charCategorizer(e){return H1(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-n,a=e-n;for(;o>0;){let l=xt(t,o,!1);if(s(t.slice(l,o))!=je.Word)break;o=l}for(;ai.length?i[0]:4});ke.lineSeparator=OO;ke.readOnly=vO;ke.phrases=pe.define({compare(i,e){let t=Object.keys(i),n=Object.keys(e);return t.length==n.length&&t.every(r=>i[r]==e[r])}});ke.languageData=mO;ke.changeFilter=_O;ke.transactionFilter=wO;ke.transactionExtender=bO;Ol.reconfigure=Oe.define();function Zi(i,e,t={}){let n={};for(let r of i)for(let s of Object.keys(r)){let o=r[s],a=n[s];if(a===void 0)n[s]=o;else if(!(a===o||o===void 0))if(Object.hasOwnProperty.call(t,s))n[s]=t[s](a,o);else throw new Error("Config merge conflict for field "+s)}for(let r in e)n[r]===void 0&&(n[r]=e[r]);return n}class Jn{eq(e){return this==e}range(e,t=e){return Qs.create(e,t,this)}}Jn.prototype.startSide=Jn.prototype.endSide=0;Jn.prototype.point=!1;Jn.prototype.mapMode=gt.TrackDel;class Qs{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(e,t,n){return new Qs(e,t,n)}}function Eh(i,e){return i.from-e.from||i.value.startSide-e.value.startSide}class rc{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return this.to[this.to.length-1]}findIndex(e,t,n,r=0){let s=n?this.to:this.from;for(let o=r,a=s.length;;){if(o==a)return o;let l=o+a>>1,u=s[l]-e||(n?this.value[l].endSide:this.value[l].startSide)-t;if(l==o)return u>=0?o:a;u>=0?a=l:o=l+1}}between(e,t,n,r){for(let s=this.findIndex(t,-1e9,!0),o=this.findIndex(n,1e9,!1,s);sp||c==p&&u.startSide>0&&u.endSide<=0)continue;(p-c||u.endSide-u.startSide)<0||(o<0&&(o=c),u.point&&(a=Math.max(a,p-c)),n.push(u),r.push(c-o),s.push(p-o))}return{mapped:n.length?new rc(r,s,n,a):null,pos:o}}}class Ne{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(e,t,n,r){return new Ne(e,t,n,r)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:n=!1,filterFrom:r=0,filterTo:s=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(n&&(t=t.slice().sort(Eh)),this.isEmpty)return t.length?Ne.of(t):this;let a=new kO(this,null,-1).goto(0),l=0,u=[],h=new In;for(;a.value||l=0){let f=t[l++];h.addInner(f.from,f.to,f.value)||u.push(f)}else a.rangeIndex==1&&a.chunkIndexthis.chunkEnd(a.chunkIndex)||sa.to||s=s&&e<=s+o.length&&o.between(s,e-s,t-s,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return As.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return As.from(e).goto(t)}static compare(e,t,n,r,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=qd(o,a,n),u=new Hr(o,l,s),h=new Hr(a,l,s);n.iterGaps((f,c,p)=>Hd(u,f,h,c,p,r)),n.empty&&n.length==0&&Hd(u,0,h,0,0,r)}static eq(e,t,n=0,r){r==null&&(r=1e9-1);let s=e.filter(h=>!h.isEmpty&&t.indexOf(h)<0),o=t.filter(h=>!h.isEmpty&&e.indexOf(h)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let a=qd(s,o),l=new Hr(s,a,0).goto(n),u=new Hr(o,a,0).goto(n);for(;;){if(l.to!=u.to||!Qh(l.active,u.active)||l.point&&(!u.point||!l.point.eq(u.point)))return!1;if(l.to>r)return!0;l.next(),u.next()}}static spans(e,t,n,r,s=-1){let o=new Hr(e,null,s).goto(t),a=t,l=o.openStart;for(;;){let u=Math.min(o.to,n);if(o.point){let h=o.activeForPoint(o.to),f=o.pointFroma&&(r.span(a,u,o.active,l),l=o.openEnd(u));if(o.to>n)return l+(o.point&&o.to>n?1:0);a=o.to,o.next()}}static of(e,t=!1){let n=new In;for(let r of e instanceof Qs?[e]:t?ex(e):e)n.add(r.from,r.to,r.value);return n.finish()}}Ne.empty=new Ne([],[],null,-1);function ex(i){if(i.length>1)for(let e=i[0],t=1;t0)return i.slice().sort(Eh);e=n}return i}Ne.empty.nextLayer=Ne.empty;class In{finishChunk(e){this.chunks.push(new rc(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new In)).add(e,t,n)}addInner(e,t,n){let r=e-this.lastTo||n.startSide-this.last.endSide;if(r<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return r<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(Ne.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=Ne.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function qd(i,e,t){let n=new Map;for(let s of i)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=n&&r.push(new kO(o,t,n,s));return r.length==1?r[0]:new As(r)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let n=this.heap.length>>1;n>=0;n--)ql(this.heap,n);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let n=this.heap.length>>1;n>=0;n--)ql(this.heap,n);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),ql(this.heap,0)}}}function ql(i,e){for(let t=i[e];;){let n=(e<<1)+1;if(n>=i.length)break;let r=i[n];if(n+1=0&&(r=i[n+1],n++),t.compare(r)<0)break;i[n]=t,i[e]=r,e=n}}class Hr{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=As.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){_o(this.active,e),_o(this.activeTo,e),_o(this.activeRank,e),this.minActive=ep(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:s}=this.cursor;for(;t-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&_o(n,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&n[r]=0&&!(this.activeRank[n]e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}}function Hd(i,e,t,n,r,s){i.goto(e),t.goto(n);let o=n+r,a=n,l=n-e;for(;;){let u=i.to+l-t.to||i.endSide-t.endSide,h=u<0?i.to+l:t.to,f=Math.min(h,o);if(i.point||t.point?i.point&&t.point&&(i.point==t.point||i.point.eq(t.point))&&Qh(i.activeForPoint(i.to),t.activeForPoint(t.to))||s.comparePoint(a,f,i.point,t.point):f>a&&!Qh(i.active,t.active)&&s.compareRange(a,f,i.active,t.active),h>o)break;a=h,u<=0&&i.next(),u>=0&&t.next()}}function Qh(i,e){if(i.length!=e.length)return!1;for(let t=0;t=e;n--)i[n+1]=i[n];i[e]=t}function ep(i,e){let t=-1,n=1e9;for(let r=0;r=e)return r;if(r==i.length)break;s+=i.charCodeAt(r)==9?t-s%t:1,r=xt(i,r)}return n===!0?-1:i.length}const Rh="ͼ",tp=typeof Symbol>"u"?"__"+Rh:Symbol.for(Rh),Uh=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),ip=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class fn{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,a,l,u){let h=[],f=/^@(\w+)\b/.exec(o[0]),c=f&&f[1]=="keyframes";if(f&&a==null)return l.push(o[0]+";");for(let p in a){let v=a[p];if(/&/.test(p))s(p.split(/,\s*/).map(x=>o.map(m=>x.replace(/&/,m))).reduce((x,m)=>x.concat(m)),v,l);else if(v&&typeof v=="object"){if(!f)throw new RangeError("The value of a property ("+p+") should be a primitive value.");s(r(p),v,h,c)}else v!=null&&h.push(p.replace(/_.*/,"").replace(/[A-Z]/g,x=>"-"+x.toLowerCase())+": "+v+";")}(h.length||c)&&l.push((n&&!f&&!u?o.map(n):o).join(", ")+" {"+h.join(" ")+"}")}for(let o in e)s(r(o),e[o],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let e=ip[tp]||1;return ip[tp]=e+1,Rh+e.toString(36)}static mount(e,t){(e[Uh]||new tx(e)).mount(Array.isArray(t)?t:[t])}}let np=new Map;class tx{constructor(e){let t=e.ownerDocument||e,n=t.defaultView;if(!e.head&&e.adoptedStyleSheets&&n.CSSStyleSheet){let r=np.get(t);if(r)return e.adoptedStyleSheets=[r.sheet,...e.adoptedStyleSheets],e[Uh]=r;this.sheet=new n.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],np.set(t,this)}else{this.styleTag=t.createElement("style");let r=e.head||e;r.insertBefore(this.styleTag,r.firstChild)}this.modules=[],e[Uh]=this}mount(e){let t=this.sheet,n=0,r=0;for(let s=0;s-1&&(this.modules.splice(a,1),r--,a=-1),a==-1){if(this.modules.splice(r++,0,o),t)for(let l=0;l",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ix=typeof navigator<"u"&&/Mac/.test(navigator.platform),nx=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var pt=0;pt<10;pt++)cn[48+pt]=cn[96+pt]=String(pt);for(var pt=1;pt<=24;pt++)cn[pt+111]="F"+pt;for(var pt=65;pt<=90;pt++)cn[pt]=String.fromCharCode(pt+32),Rs[pt]=String.fromCharCode(pt);for(var Hl in cn)Rs.hasOwnProperty(Hl)||(Rs[Hl]=cn[Hl]);function rx(i){var e=ix&&i.metaKey&&i.shiftKey&&!i.ctrlKey&&!i.altKey||nx&&i.shiftKey&&i.key&&i.key.length==1||i.key=="Unidentified",t=!e&&i.key||(i.shiftKey?Rs:cn)[i.keyCode]||i.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function Ra(i){let e;return i.nodeType==11?e=i.getSelection?i:i.ownerDocument:e=i,e.getSelection()}function $h(i,e){return e?i==e||i.contains(e.nodeType!=1?e.parentNode:e):!1}function sx(i){let e=i.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function ca(i,e){if(!e.anchorNode)return!1;try{return $h(i,e.anchorNode)}catch{return!1}}function Tr(i){return i.nodeType==3?Cr(i,0,i.nodeValue.length).getClientRects():i.nodeType==1?i.getClientRects():[]}function Ua(i,e,t,n){return t?rp(i,e,t,n,-1)||rp(i,e,t,n,1):!1}function $a(i){for(var e=0;;e++)if(i=i.previousSibling,!i)return e}function rp(i,e,t,n,r){for(;;){if(i==t&&e==n)return!0;if(e==(r<0?0:dn(i))){if(i.nodeName=="DIV")return!1;let s=i.parentNode;if(!s||s.nodeType!=1)return!1;e=$a(i)+(r<0?0:1),i=s}else if(i.nodeType==1){if(i=i.childNodes[e+(r<0?-1:0)],i.nodeType==1&&i.contentEditable=="false")return!1;e=r<0?dn(i):0}else return!1}}function dn(i){return i.nodeType==3?i.nodeValue.length:i.childNodes.length}function _l(i,e){let t=e?i.left:i.right;return{left:t,right:t,top:i.top,bottom:i.bottom}}function ox(i){return{left:0,right:i.innerWidth,top:0,bottom:i.innerHeight}}function ax(i,e,t,n,r,s,o,a){let l=i.ownerDocument,u=l.defaultView||window;for(let h=i,f=!1;h&&!f;)if(h.nodeType==1){let c,p=h==l.body;if(p)c=ox(u);else{if(/^(fixed|sticky)$/.test(getComputedStyle(h).position)&&(f=!0),h.scrollHeight<=h.clientHeight&&h.scrollWidth<=h.clientWidth){h=h.assignedSlot||h.parentNode;continue}let m=h.getBoundingClientRect();c={left:m.left,right:m.left+h.clientWidth,top:m.top,bottom:m.top+h.clientHeight}}let v=0,x=0;if(r=="nearest")e.top0&&e.bottom>c.bottom+x&&(x=e.bottom-c.bottom+x+o)):e.bottom>c.bottom&&(x=e.bottom-c.bottom+o,t<0&&e.top-x0&&e.right>c.right+v&&(v=e.right-c.right+v+s)):e.right>c.right&&(v=e.right-c.right+s,t<0&&e.leftt.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.assignedSlot||t.parentNode}else if(t.nodeType==11)t=t.host;else break;return null}class ux{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?dn(t):0),n,Math.min(e.focusOffset,n?dn(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}}let Vn=null;function MO(i){if(i.setActive)return i.setActive();if(Vn)return i.focus(Vn);let e=[];for(let t=i;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(i.focus(Vn==null?{get preventScroll(){return Vn={preventScroll:!0},!0}}:void 0),!Vn){Vn=!1;for(let t=0;tMath.max(1,i.scrollHeight-i.clientHeight-4)}class kt{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(e,t){return new kt(e.parentNode,$a(e),t)}static after(e,t){return new kt(e.parentNode,$a(e)+1,t)}}const sc=[];class Ie{constructor(){this.parent=null,this.dom=null,this.flags=2}get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let n of this.children){if(n==e)return t;t+=n.length+n.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(this.flags&2){let n=this.dom,r=null,s;for(let o of this.children){if(o.flags&7){if(!o.dom&&(s=r?r.nextSibling:n.firstChild)){let a=Ie.get(s);(!a||!a.parent&&a.canReuseDOM(o))&&o.reuseDOM(s)}o.sync(e,t),o.flags&=-8}if(s=r?r.nextSibling:n.firstChild,t&&!t.written&&t.node==n&&s!=o.dom&&(t.written=!0),o.dom.parentNode==n)for(;s&&s!=o.dom;)s=op(s);else n.insertBefore(o.dom,s);r=o.dom}for(s=r?r.nextSibling:n.firstChild,s&&t&&t.node==n&&(t.written=!0);s;)s=op(s)}else if(this.flags&1)for(let n of this.children)n.flags&7&&(n.sync(e,t),n.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let n;if(e==this.dom)n=this.dom.childNodes[t];else{let r=dn(e)==0?0:t==0?-1:1;for(;;){let s=e.parentNode;if(s==this.dom)break;r==0&&s.firstChild!=s.lastChild&&(e==s.firstChild?r=-1:r=1),e=s}r<0?n=e:n=e.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!Ie.get(n);)n=n.nextSibling;if(!n)return this.length;for(let r=0,s=0;;r++){let o=this.children[r];if(o.dom==n)return s;s+=o.length+o.breakAfter}}domBoundsAround(e,t,n=0){let r=-1,s=-1,o=-1,a=-1;for(let l=0,u=n,h=n;lt)return f.domBoundsAround(e,t,u);if(c>=e&&r==-1&&(r=l,s=u),u>t&&f.dom.parentNode==this.dom){o=l,a=h;break}h=c,u=c+f.breakAfter}return{from:s,to:a<0?n+this.length:a,startDOM:(r?this.children[r-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o=0?this.children[o].dom:null}}markDirty(e=!1){this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),t.flags&1)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.flags&7&&this.markParentsDirty(!0))}setDOM(e){this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,n=sc){this.markDirty();for(let r=e;rthis.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}}function QO(i,e,t,n,r,s,o,a,l){let{children:u}=i,h=u.length?u[e]:null,f=s.length?s[s.length-1]:null,c=f?f.breakAfter:o;if(!(e==n&&h&&!o&&!c&&s.length<2&&h.merge(t,r,s.length?f:null,t==0,a,l))){if(n0&&(!o&&s.length&&h.merge(t,h.length,s[0],!1,a,0)?h.breakAfter=s.shift().breakAfter:(ts)&&this.lineBreak(),r=o}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,a;if(this.lineSeparator?(s=t.indexOf(this.lineSeparator,n),o=this.lineSeparator.length):(a=r.exec(t))&&(s=a.index,o=a[0].length),this.append(t.slice(n,s<0?t.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let l of this.points)l.node==e&&l.pos>this.text.length&&(l.pos-=o-1);n=s+o}}readNode(e){if(e.cmIgnore)return;let t=Ie.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let r=n.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+Math.min(t,n.offset))}}function ap(i){return i.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(i.nodeName)}class lp{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}let Bt=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},Ph=typeof document<"u"?document:{documentElement:{style:{}}};const Jh=/Edge\/(\d+)/.exec(Bt.userAgent),UO=/MSIE \d/.test(Bt.userAgent),Ih=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Bt.userAgent),wl=!!(UO||Ih||Jh),up=!wl&&/gecko\/(\d+)/i.test(Bt.userAgent),eu=!wl&&/Chrome\/(\d+)/.exec(Bt.userAgent),hp="webkitFontSmoothing"in Ph.documentElement.style,$O=!wl&&/Apple Computer/.test(Bt.vendor),fp=$O&&(/Mobile\/\w+/.test(Bt.userAgent)||Bt.maxTouchPoints>2);var fe={mac:fp||/Mac/.test(Bt.platform),windows:/Win/.test(Bt.platform),linux:/Linux|X11/.test(Bt.platform),ie:wl,ie_version:UO?Ph.documentMode||6:Ih?+Ih[1]:Jh?+Jh[1]:0,gecko:up,gecko_version:up?+(/Firefox\/(\d+)/.exec(Bt.userAgent)||[0,0])[1]:0,chrome:!!eu,chrome_version:eu?+eu[1]:0,ios:fp,android:/Android\b/.test(Bt.userAgent),webkit:hp,safari:$O,webkit_version:hp?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:Ph.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const cx=256;class Li extends Ie{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,n){return this.flags&8||n&&(!(n instanceof Li)||this.length-(t-e)+n.length>cx||n.flags&8)?!1:(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new Li(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=this.flags&8,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new kt(this.dom,e)}domBoundsAround(e,t,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return dx(this.dom,e,t)}}class ji extends Ie{constructor(e,t=[],n=0){super(),this.mark=e,this.children=t,this.length=n;for(let r of t)r.setParent(this)}setAttrs(e){if(TO(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?this.flags&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,n,r,s,o){return n&&(!(n instanceof ji&&n.mark.eq(this.mark))||e&&s<=0||te&&t.push(n=e&&(r=s),n=l,s++}let o=this.length-e;return this.length=e,r>-1&&(this.children.length=r,this.markDirty()),new ji(this.mark,t,o)}domAtPos(e){return PO(this,e)}coordsAt(e,t){return IO(this,e,t)}}function dx(i,e,t){let n=i.nodeValue.length;e>n&&(e=n);let r=e,s=e,o=0;e==0&&t<0||e==n&&t>=0?fe.chrome||fe.gecko||(e?(r--,o=1):s=0)?0:a.length-1];return fe.safari&&!o&&l.width==0&&(l=Array.prototype.find.call(a,u=>u.width)||l),o?_l(l,o<0):l||null}class Cn extends Ie{constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}static create(e,t,n){return new Cn(e,t,n)}split(e){let t=Cn.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.dom.contentEditable="false")}getSide(){return this.side}merge(e,t,n,r,s,o){return n&&(!(n instanceof Cn)||!this.widget.compare(n.widget)||e>0&&s<=0||t0)?kt.before(this.dom):kt.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;let r=this.dom.getClientRects(),s=null;if(!r.length)return null;let o=this.side?this.side<0:e>0;for(let a=o?r.length-1:0;s=r[a],!(e>0?a==0:a==r.length-1||s.top0?kt.before(this.dom):kt.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return Te.empty}get isHidden(){return!0}}Li.prototype.children=Cn.prototype.children=Er.prototype.children=sc;function PO(i,e){let t=i.dom,{children:n}=i,r=0;for(let s=0;rs&&e0;s--){let o=n[s-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let s=r;s0&&e instanceof ji&&r.length&&(n=r[r.length-1])instanceof ji&&n.mark.eq(e.mark)?JO(n,e.children[0],t-1):(r.push(e),e.setParent(i)),i.length+=e.length}function IO(i,e,t){let n=null,r=-1,s=null,o=-1;function a(u,h){for(let f=0,c=0;f=h&&(p.children.length?a(p,h-c):(!s||s.isHidden&&t>0)&&(v>h||c==v&&p.getSide()>0)?(s=p,o=h-c):(c-1?1:0)!=r.length-(t&&r.indexOf(t)>-1?1:0))return!1;for(let s of n)if(s!=t&&(r.indexOf(s)==-1||i[s]!==e[s]))return!1;return!0}function Lh(i,e,t){let n=null;if(e)for(let r in e)t&&r in t||i.removeAttribute(n=r);if(t)for(let r in t)e&&e[r]==t[r]||i.setAttribute(n=r,t[r]);return!!n}function gx(i){let e=Object.create(null);for(let t=0;t0?3e8:-4e8:t>0?1e8:-1e8,new pn(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:s,end:o}=BO(e,t);n=(s?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new pn(e,n,r,t,e.widget||null,!0)}static line(e){return new oo(e)}static set(e,t=!1){return Ne.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ge.none=Ne.empty;class so extends ge{constructor(e){let{start:t,end:n}=BO(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){var t,n;return this==e||e instanceof so&&this.tagName==e.tagName&&(this.class||((t=this.attrs)===null||t===void 0?void 0:t.class))==(e.class||((n=e.attrs)===null||n===void 0?void 0:n.class))&&oc(this.attrs,e.attrs,"class")}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}so.prototype.point=!1;class oo extends ge{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof oo&&this.spec.class==e.spec.class&&oc(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}oo.prototype.mapMode=gt.TrackBefore;oo.prototype.point=!0;class pn extends ge{constructor(e,t,n,r,s,o){super(t,n,s,e),this.block=r,this.isReplace=o,this.mapMode=r?t<=0?gt.TrackBefore:gt.TrackAfter:gt.TrackDel}get type(){return this.startSide=5||this.widget.lineBreaks>0)}eq(e){return e instanceof pn&&mx(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}pn.prototype.point=!0;function BO(i,e=!1){let{inclusiveStart:t,inclusiveEnd:n}=i;return t==null&&(t=i.inclusive),n==null&&(n=i.inclusive),{start:t??e,end:n??e}}function mx(i,e){return i==e||!!(i&&e&&i.compare(e))}function jh(i,e,t,n=0){let r=t.length-1;r>=0&&t[r]+n>=i?t[r]=Math.max(t[r],e):t.push(i,e)}class Et extends Ie{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,n,r,s,o){if(n){if(!(n instanceof Et))return!1;this.dom||n.transferDOM(this)}return r&&this.setDeco(n?n.attrs:null),AO(this,e,t,n?n.children:[],s,o),!0}split(e){let t=new Et;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i:n,off:r}=this.childPos(e);r&&(t.append(this.children[n].split(r),0),this.children[n].merge(r,this.children[n].length,null,!1,0,0),n++);for(let s=n;s0&&this.children[n-1].length==0;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){oc(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){JO(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=Bh(t,this.attrs||{})),n&&(this.attrs=Bh({class:n},this.attrs||{}))}domAtPos(e){return PO(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?this.flags&4&&(TO(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(Lh(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let r=this.dom.lastChild;for(;r&&Ie.get(r)instanceof ji;)r=r.lastChild;if(!r||!this.length||r.nodeName!="BR"&&((n=Ie.get(r))===null||n===void 0?void 0:n.isEditable)==!1&&(!fe.ios||!this.children.some(s=>s instanceof Li))){let s=document.createElement("BR");s.cmIgnore=!0,this.dom.appendChild(s)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let n of this.children){if(!(n instanceof Li)||/[^ -~]/.test(n.text))return null;let r=Tr(n.dom);if(r.length!=1)return null;e+=r[0].width,t=r[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let n=IO(this,e,t);if(!this.children.length&&n&&this.parent){let{heightOracle:r}=this.parent.view.viewState,s=n.bottom-n.top;if(Math.abs(s-r.lineHeight)<2&&r.textHeight=t){if(s instanceof Et)return s;if(o>t)break}r=o+s.breakAfter}return null}}class An extends Ie{constructor(e,t,n){super(),this.widget=e,this.length=t,this.type=n,this.breakAfter=0,this.prevWidget=null}merge(e,t,n,r,s,o){return n&&(!(n instanceof An)||!this.widget.compare(n.widget)||e>0&&s<=0||t0;){if(this.textOff==this.text.length){let{value:s,lineBreak:o,done:a}=this.cursor.next(this.skip);if(this.skip=0,a)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=s,this.textOff=0}let r=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append(bo(new Li(this.text.slice(this.textOff,this.textOff+r)),t),n),this.atCursorPos=!0,this.textOff+=r,e-=r,n=0}}span(e,t,n,r){this.buildText(t-e,n,r),this.pos=t,this.openStart<0&&(this.openStart=r)}point(e,t,n,r,s,o){if(this.disallowBlockEffectsFor[o]&&n instanceof pn){if(n.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let a=t-e;if(n instanceof pn)if(n.block){let{type:l}=n;l==Ke.WidgetAfter&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new An(n.widget||new dp("div"),a,l))}else{let l=Cn.create(n.widget||new dp("span"),a,a?0:n.startSide),u=this.atCursorPos&&!l.isEditable&&s<=r.length&&(e0),h=!l.isEditable&&(er.length||n.startSide<=0),f=this.getLine();this.pendingBuffer==2&&!u&&!l.isEditable&&(this.pendingBuffer=0),this.flushBuffer(r),u&&(f.append(bo(new Er(1),r),s),s=r.length+Math.max(0,s-r.length)),f.append(bo(l,r),s),this.atCursorPos=h,this.pendingBuffer=h?er.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=r.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);a&&(this.textOff+a<=this.text.length?this.textOff+=a:(this.skip+=a-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=s)}static build(e,t,n,r,s){let o=new vs(e,t,n,s);return o.openEnd=Ne.spans(r,t,n,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function bo(i,e){for(let t of e)i=new ji(t,[i],i.length);return i}class dp extends Fi{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}const LO=pe.define(),jO=pe.define(),DO=pe.define(),NO=pe.define(),Dh=pe.define(),ZO=pe.define(),FO=pe.define(),XO=pe.define({combine:i=>i.some(e=>e)}),GO=pe.define({combine:i=>i.some(e=>e)});class Pa{constructor(e,t="nearest",n="nearest",r=5,s=5){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=s}map(e){return e.empty?this:new Pa(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin)}}const pp=Oe.define({map:(i,e)=>i.map(e)});function Xt(i,e,t){let n=i.facet(NO);n.length?n[0](e):window.onerror?window.onerror(String(e),t,void 0,void 0,e):t?console.error(t+":",e):console.error(e)}const bl=pe.define({combine:i=>i.length?i[0]:!0});let yx=0;const us=pe.define();class ut{constructor(e,t,n,r){this.id=e,this.create=t,this.domEventHandlers=n,this.extension=r(this)}static define(e,t){const{eventHandlers:n,provide:r,decorations:s}=t||{};return new ut(yx++,e,n,o=>{let a=[us.of(o)];return s&&a.push(Us.of(l=>{let u=l.plugin(o);return u?s(u):ge.none})),r&&a.push(r(o)),a})}static fromClass(e,t){return ut.define(n=>new e(n),t)}}class tu{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(n){if(Xt(t.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){Xt(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(n){Xt(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const WO=pe.define(),ac=pe.define(),Us=pe.define(),lc=pe.define(),YO=pe.define();function zO(i){let e=0,t=0,n=0,r=0;for(let s of i.state.facet(YO)){let o=s(i);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(n=Math.max(n,o.top)),o.bottom!=null&&(r=Math.max(r,o.bottom)))}return{left:e,right:t,top:n,bottom:r}}const hs=pe.define();class Gt{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(e){return new Gt(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toAh)break;s+=2}if(!l)return n;new Gt(l.fromA,l.toA,l.fromB,l.toB).addToSet(n),o=l.toA,a=l.toB}}}class Ja{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=it.empty(this.startState.doc.length);for(let s of n)this.changes=this.changes.compose(s.changes);let r=[];this.changes.iterChangedRanges((s,o,a,l)=>r.push(new Gt(s,o,a,l))),this.changedRanges=r}static create(e,t,n){return new Ja(e,t,n)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}var We=function(i){return i[i.LTR=0]="LTR",i[i.RTL=1]="RTL",i}(We||(We={}));const Nh=We.LTR,Ox=We.RTL;function VO(i){let e=[];for(let t=0;t=t){if(a.level==n)return o;(s<0||(r!=0?r<0?a.fromt:e[s].level>a.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}const De=[];function Sx(i,e){let t=i.length,n=e==Nh?1:2,r=e==Nh?2:1;if(!i||n==1&&!vx.test(i))return KO(t);for(let o=0,a=n,l=n;o=0;c-=3)if(pi[c+1]==-h){let p=pi[c+2],v=p&2?n:p&4?p&1?r:n:0;v&&(De[o]=De[pi[c]]=v),a=c;break}}else{if(pi.length==189)break;pi[a++]=o,pi[a++]=u,pi[a++]=l}else if((f=De[o])==2||f==1){let c=f==n;l=c?0:1;for(let p=a-3;p>=0;p-=3){let v=pi[p+2];if(v&2)break;if(c)pi[p+2]|=2;else{if(v&4)break;pi[p+2]|=4}}}for(let o=0;oa;){let h=u,f=De[--u]!=2;for(;u>a&&f==(De[u-1]!=2);)u--;s.push(new yr(u,h,f?2:1))}else s.push(new yr(a,o,0))}else for(let o=0;o0&&t.length&&(t.every(({fromA:a,toA:l})=>lthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0);let n=this.view.inputState.composing<0?null:Mx(this.view,e.changes);if(this.hasComposition){this.markedForComposition.clear();let{from:a,to:l}=this.hasComposition;t=new Gt(a,l,e.changes.mapPos(a,-1),e.changes.mapPos(l,1)).addToSet(t.slice())}this.hasComposition=n?{from:n.range.fromB,to:n.range.toB}:null,(fe.ie||fe.chrome)&&!n&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let r=this.decorations,s=this.updateDeco(),o=Ex(r,s,e.changes);return t=Gt.extendWithRanges(t,o),!(this.flags&7)&&t.length==0?!1:(this.updateInner(t,e.startState.doc.length,n),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,n){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,n);let{observer:r}=this.view;r.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let o=fe.chrome||fe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,o),this.flags&=-8,o&&(o.written||r.selectionRange.focusNode!=o.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(o=>o.flags&=-9);let s=[];if(this.view.viewport.from||this.view.viewport.to=0?r[o]:null;if(!a)break;let{fromA:l,toA:u,fromB:h,toB:f}=a,c,p,v,x;if(n&&n.range.fromBh){let S=vs.build(this.view.state.doc,h,n.range.fromB,this.decorations,this.dynamicDecorationMap),T=vs.build(this.view.state.doc,n.range.toB,f,this.decorations,this.dynamicDecorationMap);p=S.breakAtStart,v=S.openStart,x=T.openEnd;let k=this.compositionView(n);T.breakAtStart?k.breakAfter=1:T.content.length&&k.merge(k.length,k.length,T.content[0],!1,T.openStart,0)&&(k.breakAfter=T.content[0].breakAfter,T.content.shift()),S.content.length&&k.merge(0,0,S.content[S.content.length-1],!0,0,S.openEnd)&&S.content.pop(),c=S.content.concat(k).concat(T.content)}else({content:c,breakAtStart:p,openStart:v,openEnd:x}=vs.build(this.view.state.doc,h,f,this.decorations,this.dynamicDecorationMap));let{i:m,off:d}=s.findPos(u,1),{i:b,off:A}=s.findPos(l,-1);QO(this,b,A,m,d,c,p,v,x)}n&&this.fixCompositionDOM(n)}compositionView(e){let t=new Li(e.text.nodeValue);t.flags|=8;for(let{deco:r}of e.marks)t=new ji(r,[t],t.length);let n=new Et;return n.append(t,0),n}fixCompositionDOM(e){let t=(s,o)=>{o.flags|=8,this.markedForComposition.add(o);let a=Ie.get(s);a!=o&&(a&&(a.dom=null),o.setDOM(s))},n=this.childPos(e.range.fromB,1),r=this.children[n.i];t(e.line,r);for(let s=e.marks.length-1;s>=-1;s--)n=r.childPos(n.off,1),r=r.children[n.i],t(s>=0?e.marks[s].node:e.text,r)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let n=this.view.root.activeElement,r=n==this.dom,s=!r&&ca(this.dom,this.view.observer.selectionRange)&&!(n&&this.dom.contains(n));if(!(r||t||s))return;let o=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,l=this.domAtPos(a.anchor),u=a.empty?l:this.domAtPos(a.head);if(fe.gecko&&a.empty&&!this.hasComposition&&kx(l)){let f=document.createTextNode("");this.view.observer.ignore(()=>l.node.insertBefore(f,l.node.childNodes[l.offset]||null)),l=u=new kt(f,0),o=!0}let h=this.view.observer.selectionRange;(o||!h.focusNode||!Ua(l.node,l.offset,h.anchorNode,h.anchorOffset)||!Ua(u.node,u.offset,h.focusNode,h.focusOffset))&&(this.view.observer.ignore(()=>{fe.android&&fe.chrome&&this.dom.contains(h.focusNode)&&Qx(h.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let f=Ra(this.view.root);if(f)if(a.empty){if(fe.gecko){let c=Tx(l.node,l.offset);if(c&&c!=3){let p=e0(l.node,l.offset,c==1?1:-1);p&&(l=new kt(p,c==1?0:p.nodeValue.length))}}f.collapse(l.node,l.offset),a.bidiLevel!=null&&h.cursorBidiLevel!=null&&(h.cursorBidiLevel=a.bidiLevel)}else if(f.extend){f.collapse(l.node,l.offset);try{f.extend(u.node,u.offset)}catch{}}else{let c=document.createRange();a.anchor>a.head&&([l,u]=[u,l]),c.setEnd(u.node,u.offset),c.setStart(l.node,l.offset),f.removeAllRanges(),f.addRange(c)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),n&&n.focus())}),this.view.observer.setSelectionRange(l,u)),this.impreciseAnchor=l.precise?null:new kt(h.anchorNode,h.anchorOffset),this.impreciseHead=u.precise?null:new kt(h.focusNode,h.focusOffset)}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=Ra(e.root),{anchorNode:r,anchorOffset:s}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let o=Et.find(this,t.head);if(!o)return;let a=o.posAtStart;if(t.head==a||t.head==a+o.length)return;let l=this.coordsAt(t.head,-1),u=this.coordsAt(t.head,1);if(!l||!u||l.bottom>u.top)return;let h=this.domAtPos(t.head+t.assoc);n.collapse(h.node,h.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=t.from&&n.collapse(r,s)}nearest(e){for(let t=e;t;){let n=Ie.get(t);if(n&&n.rootView==this)return n;t=t.parentNode}return null}posFromDOM(e,t){let n=this.nearest(e);if(!n)throw new RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(e,t)+n.posAtStart}domAtPos(e){let{i:t,off:n}=this.childCursor().findPos(e,-1);for(;to||e==o&&s.type!=Ke.WidgetBefore&&s.type!=Ke.WidgetAfter&&(!r||t==2||this.children[r-1].breakAfter||this.children[r-1].type==Ke.WidgetBefore&&t>-2))return s.coordsAt(e-o,t);n=o}}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,s=this.view.contentDOM.clientWidth,o=s>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,a=-1,l=this.view.textDirection==We.LTR;for(let u=0,h=0;hr)break;if(u>=n){let p=f.dom.getBoundingClientRect();if(t.push(p.height),o){let v=f.dom.lastChild,x=v?Tr(v):[];if(x.length){let m=x[x.length-1],d=l?m.right-p.left:p.right-m.left;d>a&&(a=d,this.minWidth=s,this.minWidthFrom=u,this.minWidthTo=c)}}}u=c+f.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?We.RTL:We.LTR}measureTextSize(){for(let s of this.children)if(s instanceof Et){let o=s.measureTextSize();if(o)return o}let e=document.createElement("div"),t,n,r;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let s=Tr(e.firstChild)[0];t=e.getBoundingClientRect().height,n=s?s.width/27:7,r=s?s.height:t,e.remove()}),{lineHeight:t,charWidth:n,textHeight:r}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new EO(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let s=r==t.viewports.length?null:t.viewports[r],o=s?s.from-1:this.length;if(o>n){let a=t.lineBlockAt(o).bottom-t.lineBlockAt(n).top;e.push(ge.replace({widget:new mp(a),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!s)break;n=s.to+1}return ge.set(e)}updateDeco(){let e=this.view.state.facet(Us).map((t,n)=>(this.dynamicDecorationMap[n]=typeof t=="function")?t(this.view):t);for(let t=e.length;tt.anchor?-1:1),r;if(!n)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let s=zO(this.view),o={left:n.left-s.left,top:n.top-s.top,right:n.right+s.right,bottom:n.bottom+s.bottom};ax(this.view.scrollDOM,o,t.head-1)return null;o+=f.text.length}if(a=a.parentNode,!a)return null;let l=Ie.get(a);if(l){r=s=l.posAtStart+o;break}}return{from:r,to:s,node:t}}function Mx(i,e){let t=HO(i);if(!t)return null;let{from:n,to:r,node:s}=t,o=e.mapPos(n,-1),a=e.mapPos(r,1),l=s.nodeValue;if(/[\n\r]/.test(l))return null;if(a-o!=l.length){let c=e.mapPos(n,1),p=e.mapPos(r,-1);if(p-c==l.length)o=c,a=p;else if(i.state.doc.sliceString(a-l.length,a)==l)o=a-l.length;else if(i.state.doc.sliceString(o,o+l.length)==l)a=o+l.length;else return null}let{main:u}=i.state.selection;if(i.state.doc.sliceString(o,a)!=l||o>u.head||a0)n=n.childNodes[r-1],r=dn(n);else break}if(t>=0)for(let n=i,r=e;;){if(n.nodeType==3)return n;if(n.nodeType==1&&r=0)n=n.childNodes[r],r=0;else break}return null}function Tx(i,e){return i.nodeType!=1?0:(e&&i.childNodes[e-1].contentEditable=="false"?1:0)|(e0;){let u=xt(r.text,o,!1);if(n(r.text.slice(u,o))!=l)break;o=u}for(;ai?e.left-i:Math.max(0,i-e.right)}function Ux(i,e){return e.top>i?e.top-i:Math.max(0,i-e.bottom)}function iu(i,e){return i.tope.top+1}function yp(i,e){return ei.bottom?{top:i.top,left:i.left,right:i.right,bottom:e}:i}function Fh(i,e,t){let n,r,s,o,a=!1,l,u,h,f;for(let v=i.firstChild;v;v=v.nextSibling){let x=Tr(v);for(let m=0;mA||o==A&&s>b){n=v,r=d,s=b,o=A;let S=A?t0?m0)}b==0?t>d.bottom&&(!h||h.bottomd.top)&&(u=v,f=d):h&&iu(h,d)?h=Op(h,d.bottom):f&&iu(f,d)&&(f=yp(f,d.top))}}if(h&&h.bottom>=t?(n=l,r=h):f&&f.top<=t&&(n=u,r=f),!n)return{node:i,offset:0};let c=Math.max(r.left,Math.min(r.right,e));if(n.nodeType==3)return _p(n,c,t);if(a&&n.contentEditable!="false")return Fh(n,c,t);let p=Array.prototype.indexOf.call(i.childNodes,n)+(e>=(r.left+r.right)/2?1:0);return{node:i,offset:p}}function _p(i,e,t){let n=i.nodeValue.length,r=-1,s=1e9,o=0;for(let a=0;at?h.top-t:t-h.bottom)-1;if(h.left-1<=e&&h.right+1>=e&&f=(h.left+h.right)/2,p=c;if((fe.chrome||fe.gecko)&&Cr(i,a).getBoundingClientRect().left==h.right&&(p=!c),f<=0)return{node:i,offset:a+(p?1:0)};r=a+(p?1:0),s=f}}}return{node:i,offset:r>-1?r:o>0?i.nodeValue.length:0}}function t0(i,e,t,n=-1){var r,s;let o=i.contentDOM.getBoundingClientRect(),a=o.top+i.viewState.paddingTop,l,{docHeight:u}=i.viewState,{x:h,y:f}=e,c=f-a;if(c<0)return 0;if(c>u)return i.state.doc.length;for(let S=i.viewState.heightOracle.textHeight/2,T=!1;l=i.elementAtHeight(c),l.type!=Ke.Text;)for(;c=n>0?l.bottom+S:l.top-S,!(c>=0&&c<=u);){if(T)return t?null:0;T=!0,n=-n}f=a+c;let p=l.from;if(pi.viewport.to)return i.viewport.to==i.state.doc.length?i.state.doc.length:t?null:wp(i,o,l,h,f);let v=i.dom.ownerDocument,x=i.root.elementFromPoint?i.root:v,m=x.elementFromPoint(h,f);m&&!i.contentDOM.contains(m)&&(m=null),m||(h=Math.max(o.left+1,Math.min(o.right-1,h)),m=x.elementFromPoint(h,f),m&&!i.contentDOM.contains(m)&&(m=null));let d,b=-1;if(m&&((r=i.docView.nearest(m))===null||r===void 0?void 0:r.isEditable)!=!1){if(v.caretPositionFromPoint){let S=v.caretPositionFromPoint(h,f);S&&({offsetNode:d,offset:b}=S)}else if(v.caretRangeFromPoint){let S=v.caretRangeFromPoint(h,f);S&&({startContainer:d,startOffset:b}=S,(!i.contentDOM.contains(d)||fe.safari&&$x(d,b,h)||fe.chrome&&Px(d,b,h))&&(d=void 0))}}if(!d||!i.docView.dom.contains(d)){let S=Et.find(i.docView,p);if(!S)return c>l.top+l.height/2?l.to:l.from;({node:d,offset:b}=Fh(S.dom,h,f))}let A=i.docView.nearest(d);if(!A)return null;if(A.isWidget&&((s=A.dom)===null||s===void 0?void 0:s.nodeType)==1){let S=A.dom.getBoundingClientRect();return e.yi.defaultLineHeight*1.5){let a=i.viewState.heightOracle.textHeight,l=Math.floor((r-t.top-(i.defaultLineHeight-a)*.5)/a);s+=l*i.viewState.heightOracle.lineLength}let o=i.state.sliceDoc(t.from,t.to);return t.from+Ah(o,s,i.state.tabSize)}function $x(i,e,t){let n;if(i.nodeType!=3||e!=(n=i.nodeValue.length))return!1;for(let r=i.nextSibling;r;r=r.nextSibling)if(r.nodeType!=1||r.nodeName!="BR")return!1;return Cr(i,n-1,n).getBoundingClientRect().left>t}function Px(i,e,t){if(e!=0)return!1;for(let r=i;;){let s=r.parentNode;if(!s||s.nodeType!=1||s.firstChild!=r)return!1;if(s.classList.contains("cm-line"))break;r=s}let n=i.nodeType==1?i.getBoundingClientRect():Cr(i,0,Math.max(i.nodeValue.length,1)).getBoundingClientRect();return t-n.left>5}function Xh(i,e){let t=i.lineBlockAt(e);if(Array.isArray(t.type)){for(let n of t.type)if(n.to>e||n.to==e&&(n.to==t.to||n.type==Ke.Text))return n}return t}function Jx(i,e,t,n){let r=Xh(i,e.head),s=!n||r.type!=Ke.Text||!(i.lineWrapping||r.widgetLineBreaks)?null:i.coordsAtPos(e.assoc<0&&e.head>r.from?e.head-1:e.head);if(s){let o=i.dom.getBoundingClientRect(),a=i.textDirectionAt(r.from),l=i.posAtCoords({x:t==(a==We.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(l!=null)return K.cursor(l,t?-1:1)}return K.cursor(t?r.to:r.from,t?-1:1)}function bp(i,e,t,n){let r=i.state.doc.lineAt(e.head),s=i.bidiSpans(r),o=i.textDirectionAt(r.from);for(let a=e,l=null;;){let u=xx(r,s,o,a,t),h=qO;if(!u){if(r.number==(t?i.state.doc.lines:1))return a;h=` +`,r=i.state.doc.line(r.number+(t?1:-1)),s=i.bidiSpans(r),u=K.cursor(t?r.from:r.to)}if(l){if(!l(h))return a}else{if(!n)return u;l=n(h)}a=u}}function Ix(i,e,t){let n=i.state.charCategorizer(e),r=n(t);return s=>{let o=n(s);return r==je.Space&&(r=o),r==o}}function Bx(i,e,t,n){let r=e.head,s=t?1:-1;if(r==(t?i.state.doc.length:0))return K.cursor(r,e.assoc);let o=e.goalColumn,a,l=i.contentDOM.getBoundingClientRect(),u=i.coordsAtPos(r),h=i.documentTop;if(u)o==null&&(o=u.left-l.left),a=s<0?u.top:u.bottom;else{let p=i.viewState.lineBlockAt(r);o==null&&(o=Math.min(l.right-l.left,i.defaultCharacterWidth*(r-p.from))),a=(s<0?p.top:p.bottom)+h}let f=l.left+o,c=n??i.viewState.heightOracle.textHeight>>1;for(let p=0;;p+=10){let v=a+(c+p)*s,x=t0(i,{x:f,y:v},!1,s);if(vl.bottom||(s<0?xr))return K.cursor(x,e.assoc,void 0,o)}}function da(i,e,t){for(;;){let n=0;for(let r of i)r.between(e-1,e+1,(s,o,a)=>{if(e>s&&er(i)),t.from,e.head>t.from?-1:1);return n==t.from?t:K.cursor(n,n{this.ignoreDuringComposition(r)||r.type=="keydown"&&this.keydown(e,r)||(this.mustFlushObserver(r)&&e.observer.forceFlush(),this.runCustomHandlers(r.type,e,r)?r.preventDefault():n(e,r))};for(let n in tt){let r=tt[n];e.contentDOM.addEventListener(n,s=>{vp(e,s)&&t(r,s)},Gh[n]),this.registeredEvents.push(n)}e.scrollDOM.addEventListener("mousedown",n=>{if(n.target==e.scrollDOM&&n.clientY>e.contentDOM.getBoundingClientRect().bottom&&(t(tt.mousedown,n),!n.defaultPrevented&&n.button==2)){let r=e.contentDOM.style.minHeight;e.contentDOM.style.minHeight="100%",setTimeout(()=>e.contentDOM.style.minHeight=r,200)}}),e.scrollDOM.addEventListener("drop",n=>{n.target==e.scrollDOM&&n.clientY>e.contentDOM.getBoundingClientRect().bottom&&t(tt.drop,n)}),fe.chrome&&fe.chrome_version==102&&e.scrollDOM.addEventListener("wheel",()=>{this.chromeScrollHack<0?e.contentDOM.style.pointerEvents="none":window.clearTimeout(this.chromeScrollHack),this.chromeScrollHack=setTimeout(()=>{this.chromeScrollHack=-1,e.contentDOM.style.pointerEvents=""},100)},{passive:!0}),this.notifiedFocused=e.hasFocus,fe.safari&&e.contentDOM.addEventListener("input",()=>null)}setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}ensureHandlers(e,t){var n;let r;this.customHandlers=[];for(let s of t)if(r=(n=s.update(e).spec)===null||n===void 0?void 0:n.domEventHandlers){this.customHandlers.push({plugin:s.value,handlers:r});for(let o in r)this.registeredEvents.indexOf(o)<0&&o!="scroll"&&(this.registeredEvents.push(o),e.contentDOM.addEventListener(o,a=>{vp(e,a)&&this.runCustomHandlers(o,e,a)&&a.preventDefault()}))}}runCustomHandlers(e,t,n){for(let r of this.customHandlers){let s=r.handlers[e];if(s)try{if(s.call(r.plugin,n,t)||n.defaultPrevented)return!0}catch(o){Xt(t.state,o)}}return!1}runScrollHandlers(e,t){this.lastScrollTop=e.scrollDOM.scrollTop,this.lastScrollLeft=e.scrollDOM.scrollLeft;for(let n of this.customHandlers){let r=n.handlers.scroll;if(r)try{r.call(n.plugin,t,e)}catch(s){Xt(e.state,s)}}}keydown(e,t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&Date.now()r.keyCode==t.keyCode))&&!t.ctrlKey||jx.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(this.pendingIOSKey=n||t,setTimeout(()=>this.flushIOSKey(e),250),!0):!1}flushIOSKey(e){let t=this.pendingIOSKey;return t?(this.pendingIOSKey=void 0,mr(e.contentDOM,t.key,t.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:fe.safari&&!fe.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}mustFlushObserver(e){return e.type=="keydown"&&e.keyCode!=229}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.mouseSelection&&this.mouseSelection.update(e),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}const i0=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],jx="dthko",n0=[16,17,18,20,91,92,224,225],vo=6;function So(i){return Math.max(0,i)*.7+8}function Dx(i,e){return Math.max(Math.abs(i.clientX-e.clientX),Math.abs(i.clientY-e.clientY))}class Nx{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParent=lx(e.contentDOM),this.atoms=e.state.facet(lc).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(ke.allowMultipleSelections)&&Zx(e,t),this.dragging=Xx(e,t)&&l0(t)==1?null:!1}start(e){this.dragging===!1&&(e.preventDefault(),this.select(e))}move(e){var t;if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&Dx(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=((t=this.scrollParent)===null||t===void 0?void 0:t.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},o=zO(this.view);e.clientX-o.left<=s.left+vo?n=-So(s.left-e.clientX):e.clientX+o.right>=s.right-vo&&(n=So(e.clientX-s.right)),e.clientY-o.top<=s.top+vo?r=-So(s.top-e.clientY):e.clientY+o.bottom>=s.bottom-vo&&(r=So(e.clientY-s.bottom)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let n=0;nthis.select(this.lastEvent),20)}}function Zx(i,e){let t=i.state.facet(LO);return t.length?t[0](e):fe.mac?e.metaKey:e.ctrlKey}function Fx(i,e){let t=i.state.facet(jO);return t.length?t[0](e):fe.mac?!e.altKey:!e.ctrlKey}function Xx(i,e){let{main:t}=i.state.selection;if(t.empty)return!1;let n=Ra(i.root);if(!n||n.rangeCount==0)return!0;let r=n.getRangeAt(0).getClientRects();for(let s=0;s=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function vp(i,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,n;t!=i.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(n=Ie.get(t))&&n.ignoreEvent(e))return!1;return!0}const tt=Object.create(null),Gh=Object.create(null),r0=fe.ie&&fe.ie_version<15||fe.ios&&fe.webkit_version<604;function Gx(i){let e=i.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{i.focus(),t.remove(),s0(i,t.value)},50)}function s0(i,e){let{state:t}=i,n,r=1,s=t.toText(e),o=s.lines==t.selection.ranges.length;if(Wh!=null&&t.selection.ranges.every(l=>l.empty)&&Wh==s.toString()){let l=-1;n=t.changeByRange(u=>{let h=t.doc.lineAt(u.from);if(h.from==l)return{range:u};l=h.from;let f=t.toText((o?s.line(r++).text:e)+t.lineBreak);return{changes:{from:h.from,insert:f},range:K.cursor(u.from+f.length)}})}else o?n=t.changeByRange(l=>{let u=s.line(r++);return{changes:{from:l.from,to:l.to,insert:u.text},range:K.cursor(l.from+u.length)}}):n=t.replaceSelection(s);i.dispatch(n,{userEvent:"input.paste",scrollIntoView:!0})}tt.keydown=(i,e)=>{i.inputState.setSelectionOrigin("select"),e.keyCode==27&&(i.inputState.lastEscPress=Date.now())};tt.touchstart=(i,e)=>{i.inputState.lastTouchTime=Date.now(),i.inputState.setSelectionOrigin("select.pointer")};tt.touchmove=i=>{i.inputState.setSelectionOrigin("select.pointer")};Gh.touchstart=Gh.touchmove={passive:!0};tt.mousedown=(i,e)=>{if(i.observer.flush(),i.inputState.lastTouchTime>Date.now()-2e3)return;let t=null;for(let n of i.state.facet(DO))if(t=n(i,e),t)break;if(!t&&e.button==0&&(t=zx(i,e)),t){let n=!i.hasFocus;i.inputState.startMouseSelection(new Nx(i,e,t,n)),n&&i.observer.ignore(()=>MO(i.contentDOM)),i.inputState.mouseSelection&&i.inputState.mouseSelection.start(e)}};function Sp(i,e,t,n){if(n==1)return K.cursor(e,t);if(n==2)return Ax(i.state,e,t);{let r=Et.find(i.docView,e),s=i.state.doc.lineAt(r?r.posAtEnd:e),o=r?r.posAtStart:s.from,a=r?r.posAtEnd:s.to;return ai>=e.top&&i<=e.bottom,xp=(i,e,t)=>a0(e,t)&&i>=t.left&&i<=t.right;function Wx(i,e,t,n){let r=Et.find(i.docView,e);if(!r)return 1;let s=e-r.posAtStart;if(s==0)return 1;if(s==r.length)return-1;let o=r.coordsAt(s,-1);if(o&&xp(t,n,o))return-1;let a=r.coordsAt(s,1);return a&&xp(t,n,a)?1:o&&a0(n,o)?-1:1}function kp(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:Wx(i,t,e.clientX,e.clientY)}}const Yx=fe.ie&&fe.ie_version<=11;let Mp=null,Tp=0,Cp=0;function l0(i){if(!Yx)return i.detail;let e=Mp,t=Cp;return Mp=i,Cp=Date.now(),Tp=!e||t>Date.now()-400&&Math.abs(e.clientX-i.clientX)<2&&Math.abs(e.clientY-i.clientY)<2?(Tp+1)%3:1}function zx(i,e){let t=kp(i,e),n=l0(e),r=i.state.selection;return{update(s){s.docChanged&&(t.pos=s.changes.mapPos(t.pos),r=r.map(s.changes))},get(s,o,a){let l=kp(i,s),u,h=Sp(i,l.pos,l.bias,n);if(t.pos!=l.pos&&!o){let f=Sp(i,t.pos,t.bias,n),c=Math.min(f.from,h.from),p=Math.max(f.to,h.to);h=c1&&(u=Vx(r,l.pos))?u:a?r.addRange(h):K.create([h])}}}function Vx(i,e){for(let t=0;t=e)return K.create(i.ranges.slice(0,t).concat(i.ranges.slice(t+1)),i.mainIndex==t?0:i.mainIndex-(i.mainIndex>t?1:0))}return null}tt.dragstart=(i,e)=>{let{selection:{main:t}}=i.state,{mouseSelection:n}=i.inputState;n&&(n.dragging=t),e.dataTransfer&&(e.dataTransfer.setData("Text",i.state.sliceDoc(t.from,t.to)),e.dataTransfer.effectAllowed="copyMove")};function Ep(i,e,t,n){if(!t)return;let r=i.posAtCoords({x:e.clientX,y:e.clientY},!1);e.preventDefault();let{mouseSelection:s}=i.inputState,o=n&&s&&s.dragging&&Fx(i,e)?{from:s.dragging.from,to:s.dragging.to}:null,a={from:r,insert:t},l=i.state.changes(o?[o,a]:a);i.focus(),i.dispatch({changes:l,selection:{anchor:l.mapPos(r,-1),head:l.mapPos(r,1)},userEvent:o?"move.drop":"input.drop"})}tt.drop=(i,e)=>{if(!e.dataTransfer)return;if(i.state.readOnly)return e.preventDefault();let t=e.dataTransfer.files;if(t&&t.length){e.preventDefault();let n=Array(t.length),r=0,s=()=>{++r==t.length&&Ep(i,e,n.filter(o=>o!=null).join(i.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(n[o]=a.result),s()},a.readAsText(t[o])}}else Ep(i,e,e.dataTransfer.getData("Text"),!0)};tt.paste=(i,e)=>{if(i.state.readOnly)return e.preventDefault();i.observer.flush();let t=r0?null:e.clipboardData;t?(s0(i,t.getData("text/plain")||t.getData("text/uri-text")),e.preventDefault()):Gx(i)};function Kx(i,e){let t=i.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.value=e,n.focus(),n.selectionEnd=e.length,n.selectionStart=0,setTimeout(()=>{n.remove(),i.focus()},50)}function qx(i){let e=[],t=[],n=!1;for(let r of i.selection.ranges)r.empty||(e.push(i.sliceDoc(r.from,r.to)),t.push(r));if(!e.length){let r=-1;for(let{from:s}of i.selection.ranges){let o=i.doc.lineAt(s);o.number>r&&(e.push(o.text),t.push({from:o.from,to:Math.min(i.doc.length,o.to+1)})),r=o.number}n=!0}return{text:e.join(i.lineBreak),ranges:t,linewise:n}}let Wh=null;tt.copy=tt.cut=(i,e)=>{let{text:t,ranges:n,linewise:r}=qx(i.state);if(!t&&!r)return;Wh=r?t:null;let s=r0?null:e.clipboardData;s?(e.preventDefault(),s.clearData(),s.setData("text/plain",t)):Kx(i,t),e.type=="cut"&&!i.state.readOnly&&i.dispatch({changes:n,scrollIntoView:!0,userEvent:"delete.cut"})};const u0=Ni.define();function h0(i,e){let t=[];for(let n of i.facet(FO)){let r=n(i,e);r&&t.push(r)}return t?i.update({effects:t,annotations:u0.of(!0)}):null}function f0(i){setTimeout(()=>{let e=i.hasFocus;if(e!=i.inputState.notifiedFocused){let t=h0(i.state,e);t?i.dispatch(t):i.update([])}},10)}tt.focus=i=>{i.inputState.lastFocusTime=Date.now(),!i.scrollDOM.scrollTop&&(i.inputState.lastScrollTop||i.inputState.lastScrollLeft)&&(i.scrollDOM.scrollTop=i.inputState.lastScrollTop,i.scrollDOM.scrollLeft=i.inputState.lastScrollLeft),f0(i)};tt.blur=i=>{i.observer.clearSelectionRange(),f0(i)};tt.compositionstart=tt.compositionupdate=i=>{i.inputState.compositionFirstChange==null&&(i.inputState.compositionFirstChange=!0),i.inputState.composing<0&&(i.inputState.composing=0)};tt.compositionend=i=>{i.inputState.composing=-1,i.inputState.compositionEndedAt=Date.now(),i.inputState.compositionPendingKey=!0,i.inputState.compositionPendingChange=i.observer.pendingRecords().length>0,i.inputState.compositionFirstChange=null,fe.chrome&&fe.android?i.observer.flushSoon():i.inputState.compositionPendingChange?Promise.resolve().then(()=>i.observer.flush()):setTimeout(()=>{i.inputState.composing<0&&i.docView.hasComposition&&i.update([])},50)};tt.contextmenu=i=>{i.inputState.lastContextMenu=Date.now()};tt.beforeinput=(i,e)=>{var t;let n;if(fe.chrome&&fe.android&&(n=i0.find(r=>r.inputType==e.inputType))&&(i.observer.delayAndroidKey(n.key,n.keyCode),n.key=="Backspace"||n.key=="Delete")){let r=((t=window.visualViewport)===null||t===void 0?void 0:t.height)||0;setTimeout(()=>{var s;(((s=window.visualViewport)===null||s===void 0?void 0:s.height)||0)>r+10&&i.hasFocus&&(i.contentDOM.blur(),i.focus())},100)}};const Qp=["pre-wrap","normal","pre-line","break-spaces"];class Hx{constructor(e){this.lineWrapping=e,this.doc=Te.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Qp.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n-1,l=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=a;if(this.lineWrapping=a,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=s,l){this.heightSamples={};for(let u=0;u0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>pa&&(e.heightChanged=!0),this.height=t)}replace(e,t,n){return Mt.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let s=this,o=n.doc;for(let a=r.length-1;a>=0;a--){let{fromA:l,toA:u,fromB:h,toB:f}=r[a],c=s.lineAt(l,Be.ByPosNoHeight,n.setDoc(t),0,0),p=c.to>=u?c:s.lineAt(u,Be.ByPosNoHeight,n,0,0);for(f+=p.to-u,u=p.to;a>0&&c.from<=r[a-1].toA;)l=r[a-1].fromA,h=r[a-1].fromB,a--,ls*2){let a=e[t-1];a.break?e.splice(--t,1,a.left,null,a.right):e.splice(--t,1,a.left,a.right),n+=1+a.break,r-=a.size}else if(s>r*2){let a=e[n];a.break?e.splice(n,1,a.left,null,a.right):e.splice(n,1,a.left,a.right),n+=2+a.break,s-=a.size}else break;else if(r=s&&o(this.blockAt(0,n,r,s))}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setHeight(e,r.heights[r.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Jt extends c0{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,n,r){return new Si(r,this.length,n,this.height,this.breaks)}replace(e,t,n){let r=n[0];return n.length==1&&(r instanceof Jt||r instanceof ct&&r.flags&4)&&Math.abs(this.length-r.length)<10?(r instanceof ct?r=new Jt(r.length,this.height):r.height=this.height,this.outdated||(r.outdated=!1),r):Mt.of(n)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setHeight(e,r.heights[r.index++]):(n||this.outdated)&&this.setHeight(e,Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class ct extends Mt{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,s=r-n+1,o,a=0;if(e.lineWrapping){let l=Math.min(this.height,e.lineHeight*s);o=l/s,this.length>s+1&&(a=(this.height-l)/(this.length-s-1))}else o=this.height/s;return{firstLine:n,lastLine:r,perLine:o,perChar:a}}blockAt(e,t,n,r){let{firstLine:s,lastLine:o,perLine:a,perChar:l}=this.heightMetrics(t,r);if(t.lineWrapping){let u=r+Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length),h=t.doc.lineAt(u),f=a+h.length*l,c=Math.max(n,e-f/2);return new Si(h.from,h.length,c,f,0)}else{let u=Math.max(0,Math.min(o-s,Math.floor((e-n)/a))),{from:h,length:f}=t.doc.line(s+u);return new Si(h,f,n+a*u,a,0)}}lineAt(e,t,n,r,s){if(t==Be.ByHeight)return this.blockAt(e,n,r,s);if(t==Be.ByPosNoHeight){let{from:p,to:v}=n.doc.lineAt(e);return new Si(p,v-p,0,0,0)}let{firstLine:o,perLine:a,perChar:l}=this.heightMetrics(n,s),u=n.doc.lineAt(e),h=a+u.length*l,f=u.number-o,c=r+a*f+l*(u.from-s-f);return new Si(u.from,u.length,Math.max(r,Math.min(c,r+this.height-h)),h,0)}forEachLine(e,t,n,r,s,o){e=Math.max(e,s),t=Math.min(t,s+this.length);let{firstLine:a,perLine:l,perChar:u}=this.heightMetrics(n,s);for(let h=e,f=r;h<=t;){let c=n.doc.lineAt(h);if(h==e){let v=c.number-a;f+=l*v+u*(e-s-v)}let p=l+u*c.length;o(new Si(c.from,c.length,f,p,0)),f+=p,h=c.to+1}}replace(e,t,n){let r=this.length-t;if(r>0){let s=n[n.length-1];s instanceof ct?n[n.length-1]=new ct(s.length+r):n.push(null,new ct(r-1))}if(e>0){let s=n[0];s instanceof ct?n[0]=new ct(e+s.length):n.unshift(new ct(e-1),null)}return Mt.of(n)}decomposeLeft(e,t){t.push(new ct(e-1),null)}decomposeRight(e,t){t.push(null,new ct(this.length-e-1))}updateHeight(e,t=0,n=!1,r){let s=t+this.length;if(r&&r.from<=t+this.length&&r.more){let o=[],a=Math.max(t,r.from),l=-1;for(r.from>t&&o.push(new ct(r.from-t-1).updateHeight(e,t));a<=s&&r.more;){let h=e.doc.lineAt(a).length;o.length&&o.push(null);let f=r.heights[r.index++];l==-1?l=f:Math.abs(f-l)>=pa&&(l=-2);let c=new Jt(h,f);c.outdated=!1,o.push(c),a+=h+1}a<=s&&o.push(null,new ct(s-a).updateHeight(e,a));let u=Mt.of(o);return(l<0||Math.abs(u.height-this.height)>=pa||Math.abs(l-this.heightMetrics(e,t).perLine)>=pa)&&(e.heightChanged=!0),u}else(n||this.outdated)&&(this.setHeight(e,e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class tk extends Mt{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let s=n+this.left.height;return ea))return u;let h=t==Be.ByPosNoHeight?Be.ByPosNoHeight:Be.ByPos;return l?u.join(this.right.lineAt(a,h,n,o,a)):this.left.lineAt(a,h,n,r,s).join(u)}forEachLine(e,t,n,r,s,o){let a=r+this.left.height,l=s+this.left.length+this.break;if(this.break)e=l&&this.right.forEachLine(e,t,n,a,l,o);else{let u=this.lineAt(l,Be.ByPos,n,r,s);e=e&&u.from<=t&&o(u),t>u.to&&this.right.forEachLine(u.to+1,t,n,a,l,o)}}replace(e,t,n){let r=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let a of n)s.push(a);if(e>0&&Ap(s,o-1),t=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e2*t.size||t.size>2*e.size?Mt.of(this.break?[e,null,t]:[e,t]):(this.left=e,this.right=t,this.height=e.height+t.height,this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:s,right:o}=this,a=t+s.length+this.break,l=null;return r&&r.from<=t+s.length&&r.more?l=s=s.updateHeight(e,t,n,r):s.updateHeight(e,t,n),r&&r.from<=a+o.length&&r.more?l=o=o.updateHeight(e,a,n,r):o.updateHeight(e,a,n),l?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Ap(i,e){let t,n;i[e]==null&&(t=i[e-1])instanceof ct&&(n=i[e+1])instanceof ct&&i.splice(e-1,3,new ct(t.length+1+n.length))}const ik=5;class uc{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let n=Math.min(t,this.lineEnd),r=this.nodes[this.nodes.length-1];r instanceof Jt?r.length+=n-this.pos:(n>this.pos||!this.isCovered)&&this.nodes.push(new Jt(n-this.pos,-1)),this.writtenTo=n,t>n&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e=ik)&&this.addLineDeco(r,s,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new Jt(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new ct(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Jt)return e;let t=new Jt(0,-1);return this.nodes.push(t),t}addBlock(e){var t;this.enterLine();let n=(t=e.deco)===null||t===void 0?void 0:t.type;n==Ke.WidgetAfter&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n!=Ke.WidgetBefore&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof Jt)&&!this.isCovered?this.nodes.push(new Jt(0,-1)):(this.writtenToh.clientHeight||h.scrollWidth>h.clientWidth)&&f.overflow!="visible"){let c=h.getBoundingClientRect();s=Math.max(s,c.left),o=Math.min(o,c.right),a=Math.max(a,c.top),l=u==i.parentNode?c.bottom:Math.min(l,c.bottom)}u=f.position=="absolute"||f.position=="fixed"?h.offsetParent:h.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:s-t.left,right:Math.max(s,o)-t.left,top:a-(t.top+e),bottom:Math.max(a,l)-(t.top+e)}}function ok(i,e){let t=i.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class ru{constructor(e,t,n){this.from=e,this.to=t,this.size=n}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;ntypeof n!="function"&&n.class=="cm-lineWrapping");this.heightOracle=new Hx(t),this.stateDeco=e.facet(Us).filter(n=>typeof n!="function"),this.heightMap=Mt.empty().applyChanges(this.stateDeco,Te.empty,this.heightOracle.setDoc(e.doc),[new Gt(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ge.set(this.lineGaps.map(n=>n.draw(!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:s,to:o})=>r>=s&&r<=o)){let{from:s,to:o}=this.lineBlockAt(r);e.push(new xo(s,o))}}this.viewports=e.sort((n,r)=>n.from-r.from),this.scaler=this.heightMap.height<=7e6?Up:new hk(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(this.scaler.scale==1?e:fs(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=this.state.facet(Us).filter(h=>typeof h!="function");let r=e.changedRanges,s=Gt.extendWithRanges(r,nk(n,this.stateDeco,e?e.changes:it.empty(this.state.doc.length))),o=this.heightMap.height,a=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),this.heightMap.height!=o&&(e.flags|=2),a?(this.scrollAnchorPos=e.changes.mapPos(a.from,-1),this.scrollAnchorHeight=a.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let l=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.headl.to)||!this.viewportIsAppropriate(l))&&(l=this.getViewport(0,t));let u=!e.changes.empty||e.flags&2||l.from!=this.viewport.from||l.to!=this.viewport.to;this.viewport=l,this.updateForViewport(),u&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(GO)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,s=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?We.RTL:We.LTR;let o=this.heightOracle.mustRefreshForWrapping(s),a=t.getBoundingClientRect(),l=o||this.mustMeasureContent||this.contentDOMHeight!=a.height;this.contentDOMHeight=a.height,this.mustMeasureContent=!1;let u=0,h=0,f=parseInt(n.paddingTop)||0,c=parseInt(n.paddingBottom)||0;(this.paddingTop!=f||this.paddingBottom!=c)&&(this.paddingTop=f,this.paddingBottom=c,u|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(l=!0),this.editorWidth=e.scrollDOM.clientWidth,u|=8),this.scrollTop!=e.scrollDOM.scrollTop&&(this.scrollAnchorHeight=-1,this.scrollTop=e.scrollDOM.scrollTop),this.scrolledToBottom=CO(e.scrollDOM);let p=(this.printing?ok:sk)(t,this.paddingTop),v=p.top-this.pixelViewport.top,x=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let m=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(m!=this.inView&&(this.inView=m,m&&(l=!0)),!this.inView&&!this.scrollTarget)return 0;let d=a.width;if((this.contentDOMWidth!=d||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=a.width,this.editorHeight=e.scrollDOM.clientHeight,u|=8),l){let A=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(A)&&(o=!0),o||r.lineWrapping&&Math.abs(d-this.contentDOMWidth)>r.charWidth){let{lineHeight:S,charWidth:T,textHeight:k}=e.docView.measureTextSize();o=S>0&&r.refresh(s,S,T,k,d/T,A),o&&(e.docView.minWidth=0,u|=8)}v>0&&x>0?h=Math.max(v,x):v<0&&x<0&&(h=Math.min(v,x)),r.heightChanged=!1;for(let S of this.viewports){let T=S.from==this.viewport.from?A:e.docView.measureVisibleLineHeights(S);this.heightMap=(o?Mt.empty().applyChanges(this.stateDeco,Te.empty,this.heightOracle,[new Gt(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new ek(S.from,T))}r.heightChanged&&(u|=2)}let b=!this.viewportIsAppropriate(this.viewport,h)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return b&&(this.viewport=this.getViewport(h,this.scrollTarget)),this.updateForViewport(),(u&2||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:a}=this,l=new xo(r.lineAt(o-n*1e3,Be.ByHeight,s,0,0).from,r.lineAt(a+(1-n)*1e3,Be.ByHeight,s,0,0).to);if(t){let{head:u}=t.range;if(ul.to){let h=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=r.lineAt(u,Be.ByPos,s,0,0),c;t.y=="center"?c=(f.top+f.bottom)/2-h/2:t.y=="start"||t.y=="nearest"&&u=a+Math.max(10,Math.min(n,250)))&&r>o-2*1e3&&s>1,o=r<<1;if(this.defaultTextDirection!=We.LTR&&!n)return[];let a=[],l=(u,h,f,c)=>{if(h-uu&&mm.from>=f.from&&m.to<=f.to&&Math.abs(m.from-u)m.fromd));if(!x){if(hm.from<=h&&m.to>=h)){let m=t.moveToLineBoundary(K.cursor(h),!1,!0).head;m>u&&(h=m)}x=new ru(u,h,this.gapSize(f,u,h,c))}a.push(x)};for(let u of this.viewportLines){if(u.lengthu.from&&l(u.from,c,u,h),pt.draw(this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];Ne.spans(e,this.viewport.from,this.viewport.to,{span(r,s){t.push({from:r,to:s})},point(){}},20);let n=t.length!=this.visibleRanges.length||this.visibleRanges.some((r,s)=>r.from!=t[s].from||r.to!=t[s].to);return this.visibleRanges=t,n?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||fs(this.heightMap.lineAt(e,Be.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return fs(this.heightMap.lineAt(this.scaler.fromDOM(e),Be.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return fs(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class xo{constructor(e,t){this.from=e,this.to=t}}function lk(i,e,t){let n=[],r=i,s=0;return Ne.spans(t,i,e,{span(){},point(o,a){o>r&&(n.push({from:r,to:o}),s+=o-r),r=a}},20),r=1)return e[e.length-1].to;let n=Math.floor(i*t);for(let r=0;;r++){let{from:s,to:o}=e[r],a=o-s;if(n<=a)return s+n;n-=a}}function Mo(i,e){let t=0;for(let{from:n,to:r}of i.ranges){if(e<=r){t+=e-n;break}t+=r-n}return t/i.total}function uk(i,e){for(let t of i)if(e(t))return t}const Up={toDOM(i){return i},fromDOM(i){return i},scale:1};class hk{constructor(e,t,n){let r=0,s=0,o=0;this.viewports=n.map(({from:a,to:l})=>{let u=t.lineAt(a,Be.ByPos,e,0,0).top,h=t.lineAt(l,Be.ByPos,e,0,0).bottom;return r+=h-u,{from:a,to:l,top:u,bottom:h,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let a of this.viewports)a.domTop=o+(a.top-s)*this.scale,o=a.domBottom=a.domTop+(a.bottom-a.top),s=a.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let s=tfs(r,e)):i._content)}const To=pe.define({combine:i=>i.join(" ")}),Yh=pe.define({combine:i=>i.indexOf(!0)>-1}),zh=fn.newName(),d0=fn.newName(),p0=fn.newName(),g0={"&light":"."+d0,"&dark":"."+p0};function Vh(i,e,t){return new fn(e,{finish(n){return/&/.test(n)?n.replace(/&\w*/,r=>{if(r=="&")return i;if(!t||!t[r])throw new RangeError(`Unsupported selector: ${r}`);return t[r]}):i+" "+n}})}const fk=Vh("."+zh,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",left:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},g0);class ck{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text="";let{impreciseHead:s,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,n,0))){let a=s||o?[]:pk(e),l=new RO(a,e.state);l.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=l.text,this.newSel=gk(a,this.bounds.from)}else{let a=e.observer.selectionRange,l=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!$h(e.contentDOM,a.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),u=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!$h(e.contentDOM,a.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset);this.newSel=K.single(u,l)}}}function m0(i,e){let t,{newSel:n}=e,r=i.state.selection.main,s=i.inputState.lastKeyTime>Date.now()-100?i.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:a}=e.bounds,l=r.from,u=null;(s===8||fe.android&&e.text.length=r.from&&t.to<=r.to&&(t.from!=r.from||t.to!=r.to)&&r.to-r.from-(t.to-t.from)<=4?t={from:r.from,to:r.to,insert:i.state.doc.slice(r.from,t.from).append(t.insert).append(i.state.doc.slice(t.to,r.to))}:(fe.mac||fe.android)&&t&&t.from==t.to&&t.from==r.head-1&&/^\. ?$/.test(t.insert.toString())&&i.contentDOM.getAttribute("autocorrect")=="off"?(n&&t.insert.length==2&&(n=K.single(n.main.anchor-1,n.main.head-1)),t={from:r.from,to:r.to,insert:Te.of([" "])}):fe.chrome&&t&&t.from==t.to&&t.from==r.head&&t.insert.toString()==` + `&&i.lineWrapping&&(n&&(n=K.single(n.main.anchor-1,n.main.head-1)),t={from:r.from,to:r.to,insert:Te.of([" "])}),t){let o=i.state;if(fe.ios&&i.inputState.flushIOSKey(i)||fe.android&&(t.from==r.from&&t.to==r.to&&t.insert.length==1&&t.insert.lines==2&&mr(i.contentDOM,"Enter",13)||(t.from==r.from-1&&t.to==r.to&&t.insert.length==0||s==8&&t.insert.lengthh(i,t.from,t.to,a)))return!0;i.inputState.composing>=0&&i.inputState.composing++;let l;if(t.from>=r.from&&t.to<=r.to&&t.to-t.from>=(r.to-r.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&i.inputState.composing<0){let h=r.fromt.to?o.sliceDoc(t.to,r.to):"";l=o.replaceSelection(i.state.toText(h+t.insert.sliceString(0,void 0,i.state.lineBreak)+f))}else{let h=o.changes(t),f=n&&n.main.to<=h.newLength?n.main:void 0;if(o.selection.ranges.length>1&&i.inputState.composing>=0&&t.to<=r.to&&t.to>=r.to-10){let c=i.state.sliceDoc(t.from,t.to),p=HO(i)||i.state.doc.lineAt(r.head),v=r.to-t.to,x=r.to-r.from;l=o.changeByRange(m=>{if(m.from==r.from&&m.to==r.to)return{changes:h,range:f||m.map(h)};let d=m.to-v,b=d-c.length;if(m.to-m.from!=x||i.state.sliceDoc(b,d)!=c||p&&m.to>=p.from&&m.from<=p.to)return{range:m};let A=o.changes({from:b,to:d,insert:t.insert}),S=m.to-r.to;return{changes:A,range:f?K.range(Math.max(0,f.anchor+S),Math.max(0,f.head+S)):m.map(A)}})}else l={changes:h,selection:f&&o.selection.replaceRange(f)}}let u="input.type";return(i.composing||i.inputState.compositionPendingChange&&i.inputState.compositionEndedAt>Date.now()-50)&&(i.inputState.compositionPendingChange=!1,u+=".compose",i.inputState.compositionFirstChange&&(u+=".start",i.inputState.compositionFirstChange=!1)),i.dispatch(l,{scrollIntoView:!0,userEvent:u}),!0}else if(n&&!n.main.eq(r)){let o=!1,a="select";return i.inputState.lastSelectionTime>Date.now()-50&&(i.inputState.lastSelectionOrigin=="select"&&(o=!0),a=i.inputState.lastSelectionOrigin),i.dispatch({selection:n,scrollIntoView:o,userEvent:a}),!0}else return!1}function dk(i,e,t,n){let r=Math.min(i.length,e.length),s=0;for(;s0&&a>0&&i.charCodeAt(o-1)==e.charCodeAt(a-1);)o--,a--;if(n=="end"){let l=Math.max(0,s-Math.min(o,a));t-=o+l-s}if(o=o?s-t:0;s-=l,a=s+(a-o),o=s}else if(a=a?s-t:0;s-=l,o=s+(o-a),a=s}return{from:s,toA:o,toB:a}}function pk(i){let e=[];if(i.root.activeElement!=i.contentDOM)return e;let{anchorNode:t,anchorOffset:n,focusNode:r,focusOffset:s}=i.observer.selectionRange;return t&&(e.push(new lp(t,n)),(r!=t||s!=n)&&e.push(new lp(r,s))),e}function gk(i,e){if(i.length==0)return null;let t=i[0].pos,n=i.length==2?i[1].pos:t;return t>-1&&n>-1?K.single(t+e,n+e):null}const mk={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},su=fe.ie&&fe.ie_version<=11;class yk{constructor(e){this.view=e,this.active=!1,this.selectionRange=new ux,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.resizeContent=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let n of t)this.queue.push(n);(fe.ie&&fe.ie_version<=11||fe.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),su&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)this.view.requestMeasure()),this.resizeContent.observe(e.contentDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runScrollHandlers(this.view,e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500)}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(bl)?n.root.activeElement!=this.dom:!ca(n.dom,r))return;let s=r.anchorNode&&n.docView.nearest(r.anchorNode);if(s&&s.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(fe.ie&&fe.ie_version<=11||fe.android&&fe.chrome)&&!n.state.selection.main.empty&&r.focusNode&&Ua(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=fe.safari&&e.root.nodeType==11&&sx(this.dom.ownerDocument)==this.dom&&Ok(this.view)||Ra(e.root);if(!t||this.selectionRange.eq(t))return!1;let n=ca(this.dom,t);return n&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&mr(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(r=!0),t==-1?{from:t,to:n}=o:(t=Math.min(o.from,t),n=Math.max(o.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&ca(this.dom,this.selectionRange);return e<0&&!r?null:(e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1,new ck(this.view,e,t,n))}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return!1;let n=this.view.state,r=m0(this.view,t);return this.view.state==n&&this.view.update([]),r}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.flags|=4),e.type=="childList"){let n=$p(t,e.previousSibling||e.target.previousSibling,-1),r=$p(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var e,t,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect(),(r=this.resizeContent)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function $p(i,e,t){for(;e;){let n=Ie.get(e);if(n&&n.parent==i)return n;let r=e.parentNode;e=r!=i.dom?r:t>0?e.nextSibling:e.previousSibling}return null}function Ok(i){let e=null;function t(l){l.preventDefault(),l.stopImmediatePropagation(),e=l.getTargetRanges()[0]}if(i.contentDOM.addEventListener("beforeinput",t,!0),i.dom.ownerDocument.execCommand("indent"),i.contentDOM.removeEventListener("beforeinput",t,!0),!e)return null;let n=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,a=i.docView.domAtPos(i.state.selection.main.anchor);return Ua(a.node,a.offset,s,o)&&([n,r,s,o]=[s,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}}class he{constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.style.cssText="position: fixed; top: -10000px",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),this._dispatch=e.dispatch||(t=>this.update([t])),this.dispatch=this.dispatch.bind(this),this._root=e.root||hx(e.parent)||document,this.viewState=new Rp(e.state||ke.create(e)),this.plugins=this.state.facet(us).map(t=>new tu(t));for(let t of this.plugins)t.update(this);this.observer=new yk(this),this.inputState=new Lx(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new gp(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),e.parent&&e.parent.appendChild(this.dom)}get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}dispatch(...e){let t=e.length==1&&e[0]instanceof et?e[0]:this.state.update(...e);this._dispatch(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,n=!1,r,s=this.state;for(let c of e){if(c.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=c.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,a=0,l=null;e.some(c=>c.annotation(u0))?(this.inputState.notifiedFocused=o,a=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=h0(s,o),l||(a=1));let u=this.observer.delayedAndroidKey,h=null;if(u?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(h=null)):this.observer.clear(),s.facet(ke.phrases)!=this.state.facet(ke.phrases))return this.setState(s);r=Ja.create(this,s,e),r.flags|=a;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let c of e){if(f&&(f=f.map(c.changes)),c.scrollIntoView){let{main:p}=c.state.selection;f=new Pa(p.empty?p:K.cursor(p.head,p.head>p.anchor?-1:1))}for(let p of c.effects)p.is(pp)&&(f=p.value)}this.viewState.update(r,f),this.bidiCache=Ia.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(hs)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(c=>c.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(To)!=r.state.facet(To)&&(this.viewState.mustMeasureContent=!0),(t||n||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!r.empty)for(let c of this.state.facet(Dh))c(r);(l||h)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),h&&!m0(this,h)&&u.force&&mr(this.contentDOM,u.key,u.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new Rp(e),this.plugins=e.facet(us).map(n=>new tu(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView=new gp(this),this.inputState.ensureHandlers(this,this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(us),n=e.state.facet(us);if(t!=n){let r=[];for(let s of n){let o=t.indexOf(s);if(o<0)r.push(new tu(s));else{let a=this.plugins[o];a.mustUpdate=e,r.push(a)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=r,this.pluginMap.clear(),this.inputState.ensureHandlers(this,this.plugins)}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,{scrollTop:r}=n,{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;r!=this.viewState.scrollTop&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(o<0)if(CO(n))s=-1,o=this.viewState.heightMap.height;else{let p=this.viewState.scrollAnchorAt(r);s=p.from,o=p.top}this.updateState=1;let l=this.viewState.measure(this);if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let u=[];l&4||([this.measureRequests,u]=[u,this.measureRequests]);let h=u.map(p=>{try{return p.read(this)}catch(v){return Xt(this.state,v),Pp}}),f=Ja.create(this,this.state,[]),c=!1;f.flags|=l,t?t.flags|=l:t=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),c=this.docView.update(f));for(let p=0;p1||v<-1){r=n.scrollTop=r+v,o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(Dh))a(t)}get themeClasses(){return zh+" "+(this.state.facet(Yh)?p0:d0)+" "+this.state.facet(To)}updateAttrs(){let e=Jp(this,WO,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(bl)?"true":"false",class:"cm-content",style:`${fe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),Jp(this,ac,t);let n=this.observer.ignore(()=>{let r=Lh(this.contentDOM,this.contentAttrs,t),s=Lh(this.dom,this.editorAttrs,e);return r||s});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let r of n.effects)if(r.is(he.announce)){t&&(this.announceDOM.textContent=""),t=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(hs),fn.mount(this.root,this.styleModules.concat(fk).reverse())}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;tn.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return nu(this,e,bp(this,e,t,n))}moveByGroup(e,t){return nu(this,e,bp(this,e,t,n=>Ix(this,e.head,n)))}moveToLineBoundary(e,t,n=!0){return Jx(this,e,t,n)}moveVertically(e,t,n){return nu(this,e,Bx(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),t0(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),o=s[yr.find(s,e-r.from,-1,t)];return _l(n,o.dir==We.LTR==t>0)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(XO)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>_k)return KO(e.length);let t=this.textDirectionAt(e.from);for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t)return r.order;let n=Sx(e.text,t);return this.bidiCache.push(new Ia(e.from,e.to,t,n)),n}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||fe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{MO(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return pp.of(new Pa(typeof e=="number"?K.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}static domEventHandlers(e){return ut.define(()=>({}),{eventHandlers:e})}static theme(e,t){let n=fn.newName(),r=[To.of(n),hs.of(Vh(`.${n}`,e))];return t&&t.dark&&r.push(Yh.of(!0)),r}static baseTheme(e){return Nn.lowest(hs.of(Vh("."+zh,e,g0)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),r=n&&Ie.get(n)||Ie.get(e);return((t=r==null?void 0:r.rootView)===null||t===void 0?void 0:t.view)||null}}he.styleModule=hs;he.inputHandler=ZO;he.focusChangeEffect=FO;he.perLineTextDirection=XO;he.exceptionSink=NO;he.updateListener=Dh;he.editable=bl;he.mouseSelectionStyle=DO;he.dragMovesSelection=jO;he.clickAddsSelectionRange=LO;he.decorations=Us;he.atomicRanges=lc;he.scrollMargins=YO;he.darkTheme=Yh;he.contentAttributes=ac;he.editorAttributes=WO;he.lineWrapping=he.contentAttributes.of({class:"cm-lineWrapping"});he.announce=Oe.define();const _k=4096,Pp={};class Ia{constructor(e,t,n,r){this.from=e,this.to=t,this.dir=n,this.order=r}static update(e,t){if(t.empty)return e;let n=[],r=e.length?e[e.length-1].dir:We.LTR;for(let s=Math.max(0,e.length-10);s=0;r--){let s=n[r],o=typeof s=="function"?s(i):s;o&&Bh(o,t)}return t}const wk=fe.mac?"mac":fe.windows?"win":fe.linux?"linux":"key";function bk(i,e){const t=i.split(/-(?!$)/);let n=t[t.length-1];n=="Space"&&(n=" ");let r,s,o,a;for(let l=0;ln.concat(r),[]))),t}function Sk(i,e,t){return O0(y0(i.state),e,i,t)}let Hi=null;const xk=4e3;function kk(i,e=wk){let t=Object.create(null),n=Object.create(null),r=(o,a)=>{let l=n[o];if(l==null)n[o]=a;else if(l!=a)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,a,l,u,h)=>{var f,c;let p=t[o]||(t[o]=Object.create(null)),v=a.split(/ (?!$)/).map(d=>bk(d,e));for(let d=1;d{let S=Hi={view:A,prefix:b,scope:o};return setTimeout(()=>{Hi==S&&(Hi=null)},xk),!0}]})}let x=v.join(" ");r(x,!1);let m=p[x]||(p[x]={preventDefault:!1,stopPropagation:!1,run:((c=(f=p._any)===null||f===void 0?void 0:f.run)===null||c===void 0?void 0:c.slice())||[]});l&&m.run.push(l),u&&(m.preventDefault=!0),h&&(m.stopPropagation=!0)};for(let o of i){let a=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let u of a){let h=t[u]||(t[u]=Object.create(null));h._any||(h._any={preventDefault:!1,stopPropagation:!1,run:[]});for(let f in h)h[f].run.push(o.any)}let l=o[e]||o.key;if(l)for(let u of a)s(u,l,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(u,"Shift-"+l,o.shift,o.preventDefault,o.stopPropagation)}return t}function O0(i,e,t,n){let r=rx(e),s=dt(r,0),o=Zt(s)==r.length&&r!=" ",a="",l=!1,u=!1,h=!1;Hi&&Hi.view==t&&Hi.scope==n&&(a=Hi.prefix+" ",n0.indexOf(e.keyCode)<0&&(u=!0,Hi=null));let f=new Set,c=m=>{if(m){for(let d of m.run)if(!f.has(d)&&(f.add(d),d(t,e)))return m.stopPropagation&&(h=!0),!0;m.preventDefault&&(m.stopPropagation&&(h=!0),u=!0)}return!1},p=i[n],v,x;return p&&(c(p[a+Co(r,e,!o)])?l=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(fe.windows&&e.ctrlKey&&e.altKey)&&(v=cn[e.keyCode])&&v!=r?(c(p[a+Co(v,e,!0)])||e.shiftKey&&(x=Rs[e.keyCode])!=r&&x!=v&&c(p[a+Co(x,e,!1)]))&&(l=!0):o&&e.shiftKey&&c(p[a+Co(r,e,!0)])&&(l=!0),!l&&c(p._any)&&(l=!0)),u&&(l=!0),l&&h&&e.stopPropagation(),l}class ao{constructor(e,t,n,r,s){this.className=e,this.left=t,this.top=n,this.width=r,this.height=s}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let r=e.coordsAtPos(n.head,n.assoc||1);if(!r)return[];let s=_0(e);return[new ao(t,r.left-s.left,r.top-s.top,null,r.bottom-r.top)]}else return Mk(e,t,n)}}function _0(i){let e=i.scrollDOM.getBoundingClientRect();return{left:(i.textDirection==We.LTR?e.left:e.right-i.scrollDOM.clientWidth)-i.scrollDOM.scrollLeft,top:e.top-i.scrollDOM.scrollTop}}function Bp(i,e,t){let n=K.cursor(e);return{from:Math.max(t.from,i.moveToLineBoundary(n,!1,!0).from),to:Math.min(t.to,i.moveToLineBoundary(n,!0,!0).from),type:Ke.Text}}function Mk(i,e,t){if(t.to<=i.viewport.from||t.from>=i.viewport.to)return[];let n=Math.max(t.from,i.viewport.from),r=Math.min(t.to,i.viewport.to),s=i.textDirection==We.LTR,o=i.contentDOM,a=o.getBoundingClientRect(),l=_0(i),u=o.querySelector(".cm-line"),h=u&&window.getComputedStyle(u),f=a.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),c=a.right-(h?parseInt(h.paddingRight):0),p=Xh(i,n),v=Xh(i,r),x=p.type==Ke.Text?p:null,m=v.type==Ke.Text?v:null;if(x&&(i.lineWrapping||p.widgetLineBreaks)&&(x=Bp(i,n,x)),m&&(i.lineWrapping||v.widgetLineBreaks)&&(m=Bp(i,r,m)),x&&m&&x.from==m.from)return b(A(t.from,t.to,x));{let T=x?A(t.from,null,x):S(p,!1),k=m?A(null,t.to,m):S(v,!0),Q=[];return(x||p).to<(m||v).from-(x&&m?1:0)||p.widgetLineBreaks>1&&T.bottom+i.defaultLineHeight/2D&&ee.from=Z)break;te>B&&j(Math.max(Y,B),T==null&&Y<=D,Math.min(te,Z),k==null&&te>=V,N.dir)}if(B=R.to+1,B>=Z)break}return _.length==0&&j(D,T==null,V,k==null,i.textDirection),{top:C,bottom:I,horizontal:_}}function S(T,k){let Q=a.top+(k?T.top:T.bottom);return{top:Q,bottom:Q,horizontal:[]}}}function Tk(i,e){return i.constructor==e.constructor&&i.eq(e)}class Ck{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(ga)!=e.state.facet(ga)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&e.view.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(ga);for(;t!Tk(t,this.drawn[n]))){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let r=t.nextSibling;t.remove(),t=r}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const ga=pe.define();function w0(i){return[ut.define(e=>new Ck(e,i)),ga.of(i)]}const b0=!fe.ios,$s=pe.define({combine(i){return Zi(i,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function v0(i={}){return[$s.of(i),Ek,Qk,Ak,GO.of(!0)]}function S0(i){return i.startState.facet($s)!=i.state.facet($s)}const Ek=w0({above:!0,markers(i){let{state:e}=i,t=e.facet($s),n=[];for(let r of e.selection.ranges){let s=r==e.selection.main;if(r.empty?!s||b0:t.drawRangeCursor){let o=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",a=r.empty?r:K.cursor(r.head,r.head>r.anchor?-1:1);for(let l of ao.forRange(i,o,a))n.push(l)}}return n},update(i,e){i.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=S0(i);return t&&Lp(i.state,e),i.docChanged||i.selectionSet||t},mount(i,e){Lp(e.state,i)},class:"cm-cursorLayer"});function Lp(i,e){e.style.animationDuration=i.facet($s).cursorBlinkRate+"ms"}const Qk=w0({above:!1,markers(i){return i.state.selection.ranges.map(e=>e.empty?[]:ao.forRange(i,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(i,e){return i.docChanged||i.selectionSet||i.viewportChanged||S0(i)},class:"cm-selectionLayer"}),x0={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};b0&&(x0[".cm-line"].caretColor="transparent !important");const Ak=Nn.highest(he.theme(x0)),k0=Oe.define({map(i,e){return i==null?null:e.mapPos(i)}}),cs=ft.define({create(){return null},update(i,e){return i!=null&&(i=e.changes.mapPos(i)),e.effects.reduce((t,n)=>n.is(k0)?n.value:t,i)}}),Rk=ut.fromClass(class{constructor(i){this.view=i,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(i){var e;let t=i.state.field(cs);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(i.startState.field(cs)!=t||i.docChanged||i.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let i=this.view.state.field(cs),e=i!=null&&this.view.coordsAtPos(i);if(!e)return null;let t=this.view.scrollDOM.getBoundingClientRect();return{left:e.left-t.left+this.view.scrollDOM.scrollLeft,top:e.top-t.top+this.view.scrollDOM.scrollTop,height:e.bottom-e.top}}drawCursor(i){this.cursor&&(i?(this.cursor.style.left=i.left+"px",this.cursor.style.top=i.top+"px",this.cursor.style.height=i.height+"px"):this.cursor.style.left="-100000px")}destroy(){this.cursor&&this.cursor.remove()}setDropPos(i){this.view.state.field(cs)!=i&&this.view.dispatch({effects:k0.of(i)})}},{eventHandlers:{dragover(i){this.setDropPos(this.view.posAtCoords({x:i.clientX,y:i.clientY}))},dragleave(i){(i.target==this.view.contentDOM||!this.view.contentDOM.contains(i.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function Uk(){return[cs,Rk]}function jp(i,e,t,n,r){e.lastIndex=0;for(let s=i.iterRange(t,n),o=t,a;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;a=e.exec(s.value);)r(o+a.index,a)}function $k(i,e){let t=i.visibleRanges;if(t.length==1&&t[0].from==i.viewport.from&&t[0].to==i.viewport.to)return t;let n=[];for(let{from:r,to:s}of t)r=Math.max(i.state.doc.lineAt(r).from,r-e),s=Math.min(i.state.doc.lineAt(s).to,s+e),n.length&&n[n.length-1].to>=r?n[n.length-1].to=s:n.push({from:r,to:s});return n}class Pk{constructor(e){const{regexp:t,decoration:n,decorate:r,boundary:s,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,r)this.addMatch=(a,l,u,h)=>r(h,u,u+a[0].length,a,l);else if(typeof n=="function")this.addMatch=(a,l,u,h)=>{let f=n(a,l,u);f&&h(u,u+a[0].length,f)};else if(n)this.addMatch=(a,l,u,h)=>h(u,u+a[0].length,n);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=s,this.maxLength=o}createDeco(e){let t=new In,n=t.add.bind(t);for(let{from:r,to:s}of $k(e,this.maxLength))jp(e.state.doc,this.regexp,r,s,(o,a)=>this.addMatch(a,e,o,n));return t.finish()}updateDeco(e,t){let n=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((s,o,a,l)=>{l>e.view.viewport.from&&a1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),n,r):t}updateRange(e,t,n,r){for(let s of e.visibleRanges){let o=Math.max(s.from,n),a=Math.min(s.to,r);if(a>o){let l=e.state.doc.lineAt(o),u=l.tol.from;o--)if(this.boundary.test(l.text[o-1-l.from])){h=o;break}for(;ac.push(d.range(x,m));if(l==u)for(this.regexp.lastIndex=h-l.from;(p=this.regexp.exec(l.text))&&p.indexthis.addMatch(m,e,x,v));t=t.update({filterFrom:h,filterTo:f,filter:(x,m)=>xf,add:c})}}return t}}const Kh=/x/.unicode!=null?"gu":"g",Jk=new RegExp(`[\0-\b +--Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,Kh),Ik={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let ou=null;function Bk(){var i;if(ou==null&&typeof document<"u"&&document.body){let e=document.body.style;ou=((i=e.tabSize)!==null&&i!==void 0?i:e.MozTabSize)!=null}return ou||!1}const ma=pe.define({combine(i){let e=Zi(i,{render:null,specialChars:Jk,addSpecialChars:null});return(e.replaceTabs=!Bk())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Kh)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Kh)),e}});function M0(i={}){return[ma.of(i),Lk()]}let Dp=null;function Lk(){return Dp||(Dp=ut.fromClass(class{constructor(i){this.view=i,this.decorations=ge.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(i.state.facet(ma)),this.decorations=this.decorator.createDeco(i)}makeDecorator(i){return new Pk({regexp:i.specialChars,decoration:(e,t,n)=>{let{doc:r}=t.state,s=dt(e[0],0);if(s==9){let o=r.lineAt(n),a=t.state.tabSize,l=ro(o.text,a,n-o.from);return ge.replace({widget:new Zk((a-l%a)*this.view.defaultCharacterWidth)})}return this.decorationCache[s]||(this.decorationCache[s]=ge.replace({widget:new Nk(i,s)}))},boundary:i.replaceTabs?void 0:/[^]/})}update(i){let e=i.state.facet(ma);i.startState.facet(ma)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(i.view)):this.decorations=this.decorator.updateDeco(i,this.decorations)}},{decorations:i=>i.decorations}))}const jk="•";function Dk(i){return i>=32?jk:i==10?"␤":String.fromCharCode(9216+i)}class Nk extends Fi{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=Dk(this.code),n=e.state.phrase("Control character")+" "+(Ik[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,n,t);if(r)return r;let s=document.createElement("span");return s.textContent=t,s.title=n,s.setAttribute("aria-label",n),s.className="cm-specialChar",s}ignoreEvent(){return!1}}class Zk extends Fi{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}class Fk extends Fi{constructor(e){super(),this.content=e}toDOM(){let e=document.createElement("span");return e.className="cm-placeholder",e.style.pointerEvents="none",e.appendChild(typeof this.content=="string"?document.createTextNode(this.content):this.content),typeof this.content=="string"?e.setAttribute("aria-label","placeholder "+this.content):e.setAttribute("aria-hidden","true"),e}coordsAt(e){let t=e.firstChild?Tr(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),r=_l(t[0],n.direction!="rtl"),s=parseInt(n.lineHeight);return r.bottom-r.top>s*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+s}:r}ignoreEvent(){return!1}}function Xk(i){return ut.fromClass(class{constructor(e){this.view=e,this.placeholder=i?ge.set([ge.widget({widget:new Fk(i),side:1}).range(0)]):ge.none}get decorations(){return this.view.state.doc.length?ge.none:this.placeholder}},{decorations:e=>e.decorations})}const qh=2e3;function Gk(i,e,t){let n=Math.min(e.line,t.line),r=Math.max(e.line,t.line),s=[];if(e.off>qh||t.off>qh||e.col<0||t.col<0){let o=Math.min(e.off,t.off),a=Math.max(e.off,t.off);for(let l=n;l<=r;l++){let u=i.doc.line(l);u.length<=a&&s.push(K.range(u.from+o,u.to+a))}}else{let o=Math.min(e.col,t.col),a=Math.max(e.col,t.col);for(let l=n;l<=r;l++){let u=i.doc.line(l),h=Ah(u.text,o,i.tabSize,!0);if(h<0)s.push(K.cursor(u.to));else{let f=Ah(u.text,a,i.tabSize);s.push(K.range(u.from+h,u.from+f))}}}return s}function Wk(i,e){let t=i.coordsAtPos(i.viewport.from);return t?Math.round(Math.abs((t.left-e)/i.defaultCharacterWidth)):-1}function Np(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1),n=i.state.doc.lineAt(t),r=t-n.from,s=r>qh?-1:r==n.length?Wk(i,e.clientX):ro(n.text,i.state.tabSize,t-n.from);return{line:n.number,col:s,off:r}}function Yk(i,e){let t=Np(i,e),n=i.state.selection;return t?{update(r){if(r.docChanged){let s=r.changes.mapPos(r.startState.doc.line(t.line).from),o=r.state.doc.lineAt(s);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},n=n.map(r.changes)}},get(r,s,o){let a=Np(i,r);if(!a)return n;let l=Gk(i.state,t,a);return l.length?o?K.create(l.concat(n.ranges)):K.create(l):n}}:null}function zk(i){let e=(i==null?void 0:i.eventFilter)||(t=>t.altKey&&t.button==0);return he.mouseSelectionStyle.of((t,n)=>e(n)?Yk(t,n):null)}const Vk={Alt:[18,i=>!!i.altKey],Control:[17,i=>!!i.ctrlKey],Shift:[16,i=>!!i.shiftKey],Meta:[91,i=>!!i.metaKey]},Kk={style:"cursor: crosshair"};function qk(i={}){let[e,t]=Vk[i.key||"Alt"],n=ut.fromClass(class{constructor(r){this.view=r,this.isDown=!1}set(r){this.isDown!=r&&(this.isDown=r,this.view.update([]))}},{eventHandlers:{keydown(r){this.set(r.keyCode==e||t(r))},keyup(r){(r.keyCode==e||!t(r))&&this.set(!1)},mousemove(r){this.set(t(r))}}});return[n,he.contentAttributes.of(r=>{var s;return!((s=r.plugin(n))===null||s===void 0)&&s.isDown?Kk:null})]}const Eo="-10000px";class T0{constructor(e,t,n){this.facet=t,this.createTooltipView=n,this.input=e.state.facet(t),this.tooltips=this.input.filter(r=>r),this.tooltipViews=this.tooltips.map(n)}update(e){var t;let n=e.state.facet(this.facet),r=n.filter(o=>o);if(n===this.input){for(let o of this.tooltipViews)o.update&&o.update(e);return!1}let s=[];for(let o=0;o{var e,t,n;return{position:fe.ios?"absolute":((e=i.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=i.find(r=>r.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((n=i.find(r=>r.tooltipSpace))===null||n===void 0?void 0:n.tooltipSpace)||Hk}}}),Zp=new WeakMap,C0=ut.fromClass(class{constructor(i){this.view=i,this.inView=!0,this.lastTransaction=0,this.measureTimeout=-1;let e=i.state.facet(au);this.position=e.position,this.parent=e.parent,this.classes=i.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.manager=new T0(i,hc,t=>this.createTooltip(t)),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),i.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let i of this.manager.tooltipViews)this.intersectionObserver.observe(i.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(i){i.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(i);e&&this.observeIntersection();let t=e||i.geometryChanged,n=i.state.facet(au);if(n.position!=this.position){this.position=n.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;t=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(i){let e=i.create(this.view);if(e.dom.classList.add("cm-tooltip"),i.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",e.dom.appendChild(t)}return e.dom.style.position=this.position,e.dom.style.top=Eo,this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var i,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(i=t.destroy)===null||i===void 0||i.call(t);(e=this.intersectionObserver)===null||e===void 0||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let i=this.view.dom.getBoundingClientRect();return{editor:i,parent:this.parent?this.container.getBoundingClientRect():i,pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(au).tooltipSpace(this.view)}}writeMeasure(i){var e;let{editor:t,space:n}=i,r=[];for(let s=0;s=Math.min(t.bottom,n.bottom)||u.rightMath.min(t.right,n.right)+.1){l.style.top=Eo;continue}let f=o.arrow?a.dom.querySelector(".cm-tooltip-arrow"):null,c=f?7:0,p=h.right-h.left,v=(e=Zp.get(a))!==null&&e!==void 0?e:h.bottom-h.top,x=a.offset||tM,m=this.view.textDirection==We.LTR,d=h.width>n.right-n.left?m?n.left:n.right-h.width:m?Math.min(u.left-(f?14:0)+x.x,n.right-p):Math.max(n.left,u.left-p+(f?14:0)-x.x),b=!!o.above;!o.strictSide&&(b?u.top-(h.bottom-h.top)-x.yn.bottom)&&b==n.bottom-u.bottom>u.top-n.top&&(b=!b);let A=(b?u.top-n.top:n.bottom-u.bottom)-c;if(Ad&&k.topS&&(S=b?k.top-v-2-c:k.bottom+c+2);this.position=="absolute"?(l.style.top=S-i.parent.top+"px",l.style.left=d-i.parent.left+"px"):(l.style.top=S+"px",l.style.left=d+"px"),f&&(f.style.left=`${u.left+(m?x.x:-x.x)-(d+14-7)}px`),a.overlap!==!0&&r.push({left:d,top:S,right:T,bottom:S+v}),l.classList.toggle("cm-tooltip-above",b),l.classList.toggle("cm-tooltip-below",!b),a.positioned&&a.positioned(i.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let i of this.manager.tooltipViews)i.dom.style.top=Eo}},{eventHandlers:{scroll(){this.maybeMeasure()}}}),eM=he.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),tM={x:0,y:0},hc=pe.define({enables:[C0,eM]}),Ba=pe.define();class fc{constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new T0(e,Ba,t=>this.createHostedView(t))}static create(e){return new fc(e)}createHostedView(e){let t=e.create(this.view);return t.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(t.dom),this.mounted&&t.mount&&t.mount(this.view),t}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}}const iM=hc.compute([Ba],i=>{let e=i.facet(Ba).filter(t=>t);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.filter(t=>t.end!=null).map(t=>t.end)),create:fc.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class nM{constructor(e,t,n,r,s){this.view=e,this.source=t,this.field=n,this.setHover=r,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active)return;let e=Date.now()-this.lastMove.time;en.bottom||e.xn.right+this.view.defaultCharacterWidth)return;let r=this.view.bidiSpans(this.view.state.doc.lineAt(t)).find(a=>a.from<=t&&a.to>=t),s=r&&r.dir==We.RTL?-1:1,o=this.source(this.view,t,e.x{this.pending==a&&(this.pending=null,l&&this.view.dispatch({effects:this.setHover.of(l)}))},l=>Xt(this.view.state,l,"hover tooltip"))}else o&&this.view.dispatch({effects:this.setHover.of(o)})}mousemove(e){var t;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let n=this.active;if(n&&!Fp(this.lastMove.target)||this.pending){let{pos:r}=n||this.pending,s=(t=n==null?void 0:n.end)!==null&&t!==void 0?t:r;(r==s?this.view.posAtCoords(this.lastMove)!=r:!rM(this.view,r,s,e.clientX,e.clientY,6))&&(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1,this.active&&!Fp(e.relatedTarget)&&this.view.dispatch({effects:this.setHover.of(null)})}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}function Fp(i){for(let e=i;e;e=e.parentNode)if(e.nodeType==1&&e.classList.contains("cm-tooltip"))return!0;return!1}function rM(i,e,t,n,r,s){let o=document.createRange(),a=i.domAtPos(e),l=i.domAtPos(t);o.setEnd(l.node,l.offset),o.setStart(a.node,a.offset);let u=o.getClientRects();o.detach();for(let h=0;hBa.from(r)});return[n,ut.define(r=>new nM(r,i,n,t,e.hoverTime||300)),iM]}function E0(i,e){let t=i.plugin(C0);if(!t)return null;let n=t.manager.tooltips.indexOf(e);return n<0?null:t.manager.tooltipViews[n]}const oM=Oe.define(),Xp=pe.define({combine(i){let e,t;for(let n of i)e=e||n.topContainer,t=t||n.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Ps(i,e){let t=i.plugin(Q0),n=t?t.specs.indexOf(e):-1;return n>-1?t.panels[n]:null}const Q0=ut.fromClass(class{constructor(i){this.input=i.state.facet(Js),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(i));let e=i.state.facet(Xp);this.top=new Qo(i,!0,e.topContainer),this.bottom=new Qo(i,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(i){let e=i.state.facet(Xp);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Qo(i.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Qo(i.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=i.state.facet(Js);if(t!=this.input){let n=t.filter(l=>l),r=[],s=[],o=[],a=[];for(let l of n){let u=this.specs.indexOf(l),h;u<0?(h=l(i.view),a.push(h)):(h=this.panels[u],h.update&&h.update(i)),r.push(h),(h.top?s:o).push(h)}this.specs=n,this.panels=r,this.top.sync(s),this.bottom.sync(o);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let n of this.panels)n.update&&n.update(i)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:i=>he.scrollMargins.of(e=>{let t=e.plugin(i);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class Qo{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=Gp(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Gp(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function Gp(i){let e=i.nextSibling;return i.remove(),e}const Js=pe.define({enables:Q0});class Bn extends Jn{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Bn.prototype.elementClass="";Bn.prototype.toDOM=void 0;Bn.prototype.mapMode=gt.TrackBefore;Bn.prototype.startSide=Bn.prototype.endSide=-1;Bn.prototype.point=!0;const aM=pe.define(),lM=new class extends Bn{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},uM=aM.compute(["selection"],i=>{let e=[],t=-1;for(let n of i.selection.ranges){let r=i.doc.lineAt(n.head).from;r>t&&(t=r,e.push(lM.range(r)))}return Ne.of(e)});function hM(){return uM}let fM=0;class wi{constructor(e,t,n){this.set=e,this.base=t,this.modified=n,this.id=fM++}static define(e){if(e!=null&&e.base)throw new Error("Can not derive from a modified tag");let t=new wi([],null,[]);if(t.set.push(t),e)for(let n of e.set)t.set.push(n);return t}static defineModifier(){let e=new La;return t=>t.modified.indexOf(e)>-1?t:La.get(t.base||t,t.modified.concat(e).sort((n,r)=>n.id-r.id))}}let cM=0;class La{constructor(){this.instances=[],this.id=cM++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(a=>a.base==e&&dM(t,a.modified));if(n)return n;let r=[],s=new wi(r,e,t);for(let a of t)a.instances.push(s);let o=pM(t);for(let a of e.set)if(!a.modified.length)for(let l of o)r.push(La.get(a,l));return s}}function dM(i,e){return i.length==e.length&&i.every((t,n)=>t==e[n])}function pM(i){let e=[[]];for(let t=0;tn.length-t.length)}function A0(i){let e=Object.create(null);for(let t in i){let n=i[t];Array.isArray(n)||(n=[n]);for(let r of t.split(" "))if(r){let s=[],o=2,a=r;for(let f=0;;){if(a=="..."&&f>0&&f+3==r.length){o=1;break}let c=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!c)throw new RangeError("Invalid path: "+r);if(s.push(c[0]=="*"?"":c[0][0]=='"'?JSON.parse(c[0]):c[0]),f+=c[0].length,f==r.length)break;let p=r[f++];if(f==r.length&&p=="!"){o=0;break}if(p!="/")throw new RangeError("Invalid path: "+r);a=r.slice(f)}let l=s.length-1,u=s[l];if(!u)throw new RangeError("Invalid path: "+r);let h=new ja(n,o,l>0?s.slice(0,l):null);e[u]=h.sort(e[u])}}return R0.add(e)}const R0=new we;class ja{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{let o=r;for(let a of s)for(let l of a.set){let u=t[l.id];if(u){o=o?o+" "+u:u;break}}return o},scope:n}}function gM(i,e){let t=null;for(let n of i){let r=n.style(e);r&&(t=t?t+" "+r:r)}return t}function mM(i,e,t,n=0,r=i.length){let s=new yM(n,Array.isArray(e)?e:[e],t);s.highlightRange(i.cursor(),n,r,"",s.highlighters),s.flush(r)}class yM{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,s){let{type:o,from:a,to:l}=e;if(a>=n||l<=t)return;o.isTop&&(s=this.highlighters.filter(p=>!p.scope||p.scope(o)));let u=r,h=OM(e)||ja.empty,f=gM(s,h.tags);if(f&&(u&&(u+=" "),u+=f,h.mode==1&&(r+=(r?" ":"")+f)),this.startSpan(Math.max(t,a),u),h.opaque)return;let c=e.tree&&e.tree.prop(we.mounted);if(c&&c.overlay){let p=e.node.enter(c.overlay[0].from+a,1),v=this.highlighters.filter(m=>!m.scope||m.scope(c.tree.type)),x=e.firstChild();for(let m=0,d=a;;m++){let b=m=A||!e.nextSibling())););if(!b||A>n)break;d=b.to+a,d>t&&(this.highlightRange(p.cursor(),Math.max(t,b.from+a),Math.min(n,d),"",v),this.startSpan(Math.min(n,d),u))}x&&e.parent()}else if(e.firstChild()){c&&(r="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,s),this.startSpan(Math.min(n,e.to),u)}while(e.nextSibling());e.parent()}}}function OM(i){let e=i.type.prop(R0);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}const oe=wi.define,Ao=oe(),zi=oe(),Wp=oe(zi),Yp=oe(zi),Vi=oe(),Ro=oe(Vi),lu=oe(Vi),_i=oe(),_n=oe(_i),gi=oe(),mi=oe(),Hh=oe(),es=oe(Hh),Uo=oe(),L={comment:Ao,lineComment:oe(Ao),blockComment:oe(Ao),docComment:oe(Ao),name:zi,variableName:oe(zi),typeName:Wp,tagName:oe(Wp),propertyName:Yp,attributeName:oe(Yp),className:oe(zi),labelName:oe(zi),namespace:oe(zi),macroName:oe(zi),literal:Vi,string:Ro,docString:oe(Ro),character:oe(Ro),attributeValue:oe(Ro),number:lu,integer:oe(lu),float:oe(lu),bool:oe(Vi),regexp:oe(Vi),escape:oe(Vi),color:oe(Vi),url:oe(Vi),keyword:gi,self:oe(gi),null:oe(gi),atom:oe(gi),unit:oe(gi),modifier:oe(gi),operatorKeyword:oe(gi),controlKeyword:oe(gi),definitionKeyword:oe(gi),moduleKeyword:oe(gi),operator:mi,derefOperator:oe(mi),arithmeticOperator:oe(mi),logicOperator:oe(mi),bitwiseOperator:oe(mi),compareOperator:oe(mi),updateOperator:oe(mi),definitionOperator:oe(mi),typeOperator:oe(mi),controlOperator:oe(mi),punctuation:Hh,separator:oe(Hh),bracket:es,angleBracket:oe(es),squareBracket:oe(es),paren:oe(es),brace:oe(es),content:_i,heading:_n,heading1:oe(_n),heading2:oe(_n),heading3:oe(_n),heading4:oe(_n),heading5:oe(_n),heading6:oe(_n),contentSeparator:oe(_i),list:oe(_i),quote:oe(_i),emphasis:oe(_i),strong:oe(_i),link:oe(_i),monospace:oe(_i),strikethrough:oe(_i),inserted:oe(),deleted:oe(),changed:oe(),invalid:oe(),meta:Uo,documentMeta:oe(Uo),annotation:oe(Uo),processingInstruction:oe(Uo),definition:wi.defineModifier(),constant:wi.defineModifier(),function:wi.defineModifier(),standard:wi.defineModifier(),local:wi.defineModifier(),special:wi.defineModifier()};U0([{tag:L.link,class:"tok-link"},{tag:L.heading,class:"tok-heading"},{tag:L.emphasis,class:"tok-emphasis"},{tag:L.strong,class:"tok-strong"},{tag:L.keyword,class:"tok-keyword"},{tag:L.atom,class:"tok-atom"},{tag:L.bool,class:"tok-bool"},{tag:L.url,class:"tok-url"},{tag:L.labelName,class:"tok-labelName"},{tag:L.inserted,class:"tok-inserted"},{tag:L.deleted,class:"tok-deleted"},{tag:L.literal,class:"tok-literal"},{tag:L.string,class:"tok-string"},{tag:L.number,class:"tok-number"},{tag:[L.regexp,L.escape,L.special(L.string)],class:"tok-string2"},{tag:L.variableName,class:"tok-variableName"},{tag:L.local(L.variableName),class:"tok-variableName tok-local"},{tag:L.definition(L.variableName),class:"tok-variableName tok-definition"},{tag:L.special(L.variableName),class:"tok-variableName2"},{tag:L.definition(L.propertyName),class:"tok-propertyName tok-definition"},{tag:L.typeName,class:"tok-typeName"},{tag:L.namespace,class:"tok-namespace"},{tag:L.className,class:"tok-className"},{tag:L.macroName,class:"tok-macroName"},{tag:L.propertyName,class:"tok-propertyName"},{tag:L.operator,class:"tok-operator"},{tag:L.comment,class:"tok-comment"},{tag:L.meta,class:"tok-meta"},{tag:L.invalid,class:"tok-invalid"},{tag:L.punctuation,class:"tok-punctuation"}]);var uu;const hr=new we;function $0(i){return pe.define({combine:i?e=>e.concat(i):void 0})}const cc=new we;class ri{constructor(e,t,n=[],r=""){this.data=e,this.name=r,ke.prototype.hasOwnProperty("tree")||Object.defineProperty(ke.prototype,"tree",{get(){return ht(this)}}),this.parser=t,this.extension=[Ar.of(this),ke.languageData.of((s,o,a)=>{let l=zp(s,o,a),u=l.type.prop(hr);if(!u)return[];let h=s.facet(u),f=l.type.prop(cc);if(f){let c=l.resolve(o-l.from,a);for(let p of f)if(p.test(c,s)){let v=s.facet(p.facet);return p.type=="replace"?v:v.concat(h)}}return h})].concat(n)}isActiveAt(e,t,n=-1){return zp(e,t,n).type.prop(hr)==this.data}findRegions(e){let t=e.facet(Ar);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(s,o)=>{if(s.prop(hr)==this.data){n.push({from:o,to:o+s.length});return}let a=s.prop(we.mounted);if(a){if(a.tree.prop(hr)==this.data){if(a.overlay)for(let l of a.overlay)n.push({from:l.from+o,to:l.to+o});else n.push({from:o,to:o+s.length});return}else if(a.overlay){let l=n.length;if(r(a.tree,a.overlay[0].from+o),n.length>l)return}}for(let l=0;ln.isTop?t:void 0)]}),e.name)}configure(e,t){return new Da(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function ht(i){let e=i.field(ri.state,!1);return e?e.tree:He.empty}class _M{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=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let ts=null;class Na{constructor(e,t,n=[],r,s,o,a,l){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=s,this.viewport=o,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new Na(e,t,[],He.empty,0,n,[],null)}startParse(){return this.parser.startParse(new _M(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=He.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=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(Qn.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=ts;ts=this;try{return e()}finally{ts=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=Vp(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:r,treeLen:s,viewport:o,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((u,h,f,c)=>l.push({fromA:u,toA:h,fromB:f,toB:c})),n=Qn.applyChanges(n,l),r=He.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){a=[];for(let u of this.skipped){let h=e.mapPos(u.from,1),f=e.mapPos(u.to,-1);he.from&&(this.fragments=Vp(this.fragments,r,s),this.skipped.splice(n--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends aO{createParse(t,n,r){let s=r[0].from,o=r[r.length-1].to;return{parsedPos:s,advance(){let l=ts;if(l){for(let u of r)l.tempSkipped.push(u);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=o,new He(Ut.none,[],[],o-s)},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 ts}}function Vp(i,e,t){return Qn.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}class Qr{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new Qr(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Na.create(e.facet(Ar).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new Qr(n)}}ri.state=ft.define({create:Qr.init,update(i,e){for(let t of e.effects)if(t.is(ri.setState))return t.value;return e.startState.facet(Ar)!=e.state.facet(Ar)?Qr.init(e.state):i.apply(e)}});let P0=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(P0=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:500-100})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const hu=typeof navigator<"u"&&(!((uu=navigator.scheduling)===null||uu===void 0)&&uu.isInputPending)?()=>navigator.scheduling.isInputPending():null,wM=ut.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(ri.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),e.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(ri.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=P0(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndr+1e3,l=s.context.work(()=>hu&&hu()||Date.now()>o,r+(a?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:ri.setState.of(new Qr(s.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Xt(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ar=pe.define({combine(i){return i.length?i[0]:null},enables:i=>[ri.state,wM,he.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]});class bM{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const vM=pe.define(),vl=pe.define({combine:i=>{if(!i.length)return" ";let e=i[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(i[0]));return e}});function Za(i){let e=i.facet(vl);return e.charCodeAt(0)==9?i.tabSize*e.length:e.length}function Is(i,e){let t="",n=i.tabSize,r=i.facet(vl)[0];if(r==" "){for(;e>=n;)t+=" ",e-=n;r=" "}for(let s=0;s=n.from&&r<=n.to?s&&r==e?{text:"",from:e}:(t<0?r-1&&(s+=o-this.countColumn(n,n.search(/\S|$/))),s}countColumn(e,t=e.length){return ro(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),s=this.options.overrideIndentation;if(s){let o=s(r);if(o>-1)return o}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const J0=new we;function SM(i,e,t){return I0(e.resolveInner(t).enterUnfinishedNodesBefore(t),t,i)}function xM(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function kM(i){let e=i.type.prop(J0);if(e)return e;let t=i.firstChild,n;if(t&&(n=t.type.prop(we.closedBy))){let r=i.lastChild,s=r&&n.indexOf(r.name)>-1;return o=>B0(o,!0,1,void 0,s&&!xM(o)?r.from:void 0)}return i.parent==null?MM:null}function I0(i,e,t){for(;i;i=i.parent){let n=kM(i);if(n)return n(pc.create(t,e,i))}return null}function MM(){return 0}class pc extends Sl{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.node=n}static create(e,t,n){return new pc(e,t,n)}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(TM(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){let e=this.node.parent;return e?I0(e,this.pos,this.base):0}}function TM(i,e){for(let t=e;t;t=t.parent)if(i==t)return!0;return!1}function CM(i){let e=i.node,t=e.childAfter(e.from),n=e.lastChild;if(!t)return null;let r=i.options.simulateBreak,s=i.state.doc.lineAt(t.from),o=r==null||r<=s.from?s.to:Math.min(s.to,r);for(let a=t.to;;){let l=e.childAfter(a);if(!l||l==n)return null;if(!l.type.isSkipped)return l.fromB0(n,e,t,i)}function B0(i,e,t,n,r){let s=i.textAfter,o=s.match(/^\s*/)[0].length,a=n&&s.slice(o,o+n.length)==n||r==i.pos+o,l=e?CM(i):null;return l?a?i.column(l.from):i.column(l.to):i.baseIndent+(a?0:i.unit*t)}const QM=i=>i.baseIndent;function fu({except:i,units:e=1}={}){return t=>{let n=i&&i.test(t.textAfter);return t.baseIndent+(n?0:e*t.unit)}}const AM=200;function RM(){return ke.transactionFilter.of(i=>{if(!i.docChanged||!i.isUserEvent("input.type")&&!i.isUserEvent("input.complete"))return i;let e=i.startState.languageDataAt("indentOnInput",i.startState.selection.main.head);if(!e.length)return i;let t=i.newDoc,{head:n}=i.newSelection.main,r=t.lineAt(n);if(n>r.from+AM)return i;let s=t.sliceString(r.from,n);if(!e.some(u=>u.test(s)))return i;let{state:o}=i,a=-1,l=[];for(let{head:u}of o.selection.ranges){let h=o.doc.lineAt(u);if(h.from==a)continue;a=h.from;let f=dc(o,h.from);if(f==null)continue;let c=/^\s*/.exec(h.text)[0],p=Is(o,f);c!=p&&l.push({from:h.from,to:h.from+c.length,insert:p})}return l.length?[i,{changes:l,sequential:!0}]:i})}const UM=pe.define(),L0=new we;function $M(i){let e=i.firstChild,t=i.lastChild;return e&&e.tot)continue;if(s&&o.from=e&&l.to>t&&(s=l)}}return s}function JM(i){let e=i.lastChild;return e&&e.to==i.to&&e.type.isError}function j0(i,e,t){for(let n of i.facet(UM)){let r=n(i,e,t);if(r)return r}return PM(i,e,t)}function D0(i,e){let t=e.mapPos(i.from,1),n=e.mapPos(i.to,-1);return t>=n?void 0:{from:t,to:n}}const gc=Oe.define({map:D0}),xl=Oe.define({map:D0});function N0(i){let e=[];for(let{head:t}of i.state.selection.ranges)e.some(n=>n.from<=t&&n.to>=t)||e.push(i.lineBlockAt(t));return e}const lo=ft.define({create(){return ge.none},update(i,e){i=i.map(e.changes);for(let t of e.effects)t.is(gc)&&!IM(i,t.value.from,t.value.to)?i=i.update({add:[Kp.range(t.value.from,t.value.to)]}):t.is(xl)&&(i=i.update({filter:(n,r)=>t.value.from!=n||t.value.to!=r,filterFrom:t.value.from,filterTo:t.value.to}));if(e.selection){let t=!1,{head:n}=e.selection.main;i.between(n,n,(r,s)=>{rn&&(t=!0)}),t&&(i=i.update({filterFrom:n,filterTo:n,filter:(r,s)=>s<=n||r>=n}))}return i},provide:i=>he.decorations.from(i),toJSON(i,e){let t=[];return i.between(0,e.doc.length,(n,r)=>{t.push(n,r)}),t},fromJSON(i){if(!Array.isArray(i)||i.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t{(!r||r.from>s)&&(r={from:s,to:o})}),r}function IM(i,e,t){let n=!1;return i.between(e,e,(r,s)=>{r==e&&s==t&&(n=!0)}),n}function F0(i,e){return i.field(lo,!1)?e:e.concat(Oe.appendConfig.of(FM()))}const BM=i=>{for(let e of N0(i)){let t=j0(i.state,e.from,e.to);if(t)return i.dispatch({effects:F0(i.state,[gc.of(t),X0(i,t)])}),!0}return!1},LM=i=>{if(!i.state.field(lo,!1))return!1;let e=[];for(let t of N0(i)){let n=Z0(i.state,t.from,t.to);n&&e.push(xl.of(n),X0(i,n,!1))}return e.length&&i.dispatch({effects:e}),e.length>0};function X0(i,e,t=!0){let n=i.state.doc.lineAt(e.from).number,r=i.state.doc.lineAt(e.to).number;return he.announce.of(`${i.state.phrase(t?"Folded lines":"Unfolded lines")} ${n} ${i.state.phrase("to")} ${r}.`)}const jM=i=>{let{state:e}=i,t=[];for(let n=0;n{let e=i.state.field(lo,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,i.state.doc.length,(n,r)=>{t.push(xl.of({from:n,to:r}))}),i.dispatch({effects:t}),!0},NM=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:BM},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:LM},{key:"Ctrl-Alt-[",run:jM},{key:"Ctrl-Alt-]",run:DM}],ZM={placeholderDOM:null,placeholderText:"…"},G0=pe.define({combine(i){return Zi(i,ZM)}});function FM(i){let e=[lo,XM];return i&&e.push(G0.of(i)),e}const Kp=ge.replace({widget:new class extends Fi{toDOM(i){let{state:e}=i,t=e.facet(G0),n=s=>{let o=i.lineBlockAt(i.posAtDOM(s.target)),a=Z0(i.state,o.from,o.to);a&&i.dispatch({effects:xl.of(a)}),s.preventDefault()};if(t.placeholderDOM)return t.placeholderDOM(i,n);let r=document.createElement("span");return r.textContent=t.placeholderText,r.setAttribute("aria-label",e.phrase("folded code")),r.title=e.phrase("unfold"),r.className="cm-foldPlaceholder",r.onclick=n,r}}}),XM=he.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"}});class Br{constructor(e,t){this.specs=e;let n;function r(a){let l=fn.newName();return(n||(n=Object.create(null)))["."+l]=a,l}const s=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,o=t.scope;this.scope=o instanceof ri?a=>a.prop(hr)==o.data:o?a=>a==o:void 0,this.style=U0(e.map(a=>({tag:a.tag,class:a.class||r(Object.assign({},a,{tag:null}))})),{all:s}).style,this.module=n?new fn(n):null,this.themeType=t.themeType}static define(e,t){return new Br(e,t||{})}}const ef=pe.define(),W0=pe.define({combine(i){return i.length?[i[0]]:null}});function cu(i){let e=i.facet(ef);return e.length?e:i.facet(W0)}function Fa(i,e){let t=[WM],n;return i instanceof Br&&(i.module&&t.push(he.styleModule.of(i.module)),n=i.themeType),e!=null&&e.fallback?t.push(W0.of(i)):n?t.push(ef.computeN([he.darkTheme],r=>r.facet(he.darkTheme)==(n=="dark")?[i]:[])):t.push(ef.of(i)),t}class GM{constructor(e){this.markCache=Object.create(null),this.tree=ht(e.state),this.decorations=this.buildDeco(e,cu(e.state))}update(e){let t=ht(e.state),n=cu(e.state),r=n!=cu(e.startState);t.length{n.add(o,a,this.markCache[l]||(this.markCache[l]=ge.mark({class:l})))},r,s);return n.finish()}}const WM=Nn.high(ut.fromClass(GM,{decorations:i=>i.decorations})),YM=Br.define([{tag:L.meta,color:"#404740"},{tag:L.link,textDecoration:"underline"},{tag:L.heading,textDecoration:"underline",fontWeight:"bold"},{tag:L.emphasis,fontStyle:"italic"},{tag:L.strong,fontWeight:"bold"},{tag:L.strikethrough,textDecoration:"line-through"},{tag:L.keyword,color:"#708"},{tag:[L.atom,L.bool,L.url,L.contentSeparator,L.labelName],color:"#219"},{tag:[L.literal,L.inserted],color:"#164"},{tag:[L.string,L.deleted],color:"#a11"},{tag:[L.regexp,L.escape,L.special(L.string)],color:"#e40"},{tag:L.definition(L.variableName),color:"#00f"},{tag:L.local(L.variableName),color:"#30a"},{tag:[L.typeName,L.namespace],color:"#085"},{tag:L.className,color:"#167"},{tag:[L.special(L.variableName),L.macroName],color:"#256"},{tag:L.definition(L.propertyName),color:"#00c"},{tag:L.comment,color:"#940"},{tag:L.invalid,color:"#f00"}]),zM=he.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Y0=1e4,z0="()[]{}",V0=pe.define({combine(i){return Zi(i,{afterCursor:!0,brackets:z0,maxScanDistance:Y0,renderMatch:qM})}}),VM=ge.mark({class:"cm-matchingBracket"}),KM=ge.mark({class:"cm-nonmatchingBracket"});function qM(i){let e=[],t=i.matched?VM:KM;return e.push(t.range(i.start.from,i.start.to)),i.end&&e.push(t.range(i.end.from,i.end.to)),e}const HM=ft.define({create(){return ge.none},update(i,e){if(!e.docChanged&&!e.selection)return i;let t=[],n=e.state.facet(V0);for(let r of e.state.selection.ranges){if(!r.empty)continue;let s=Ti(e.state,r.head,-1,n)||r.head>0&&Ti(e.state,r.head-1,1,n)||n.afterCursor&&(Ti(e.state,r.head,1,n)||r.headhe.decorations.from(i)}),eT=[HM,zM];function tT(i={}){return[V0.of(i),eT]}const iT=new we;function tf(i,e,t){let n=i.prop(e<0?we.openedBy:we.closedBy);if(n)return n;if(i.name.length==1){let r=t.indexOf(i.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function nf(i){let e=i.type.prop(iT);return e?e(i.node):i}function Ti(i,e,t,n={}){let r=n.maxScanDistance||Y0,s=n.brackets||z0,o=ht(i),a=o.resolveInner(e,t);for(let l=a;l;l=l.parent){let u=tf(l.type,t,s);if(u&&l.from0?e>=h.from&&eh.from&&e<=h.to))return nT(i,e,t,l,h,u,s)}}return rT(i,e,t,o,a.type,r,s)}function nT(i,e,t,n,r,s,o){let a=n.parent,l={from:r.from,to:r.to},u=0,h=a==null?void 0:a.cursor();if(h&&(t<0?h.childBefore(n.from):h.childAfter(n.to)))do if(t<0?h.to<=n.from:h.from>=n.to){if(u==0&&s.indexOf(h.type.name)>-1&&h.from0)return null;let u={from:t<0?e-1:e,to:t>0?e+1:e},h=i.doc.iterRange(e,t>0?i.doc.length:0),f=0;for(let c=0;!h.next().done&&c<=s;){let p=h.value;t<0&&(c+=p.length);let v=e+c*t;for(let x=t>0?0:p.length-1,m=t>0?p.length:-1;x!=m;x+=t){let d=o.indexOf(p[x]);if(!(d<0||n.resolveInner(v+x,1).type!=r))if(d%2==0==t>0)f++;else{if(f==1)return{start:u,end:{from:v+x,to:v+x+1},matched:d>>1==l>>1};f--}}t>0&&(c+=p.length)}return h.done?{start:u,matched:!1}:null}const sT=Object.create(null),qp=[Ut.none],Hp=[],oT=Object.create(null);for(let[i,e]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"]])oT[i]=aT(sT,e);function du(i,e){Hp.indexOf(i)>-1||(Hp.push(i),console.warn(e))}function aT(i,e){let t=null;for(let s of e.split(".")){let o=i[s]||L[s];o?typeof o=="function"?t?t=o(t):du(s,`Modifier ${s} used at start of tag`):t?du(s,`Tag ${s} used as modifier`):t=o:du(s,`Unknown highlighting tag ${s}`)}if(!t)return 0;let n=e.replace(/ /g,"_"),r=Ut.define({id:qp.length,name:n,props:[A0({[n]:t})]});return qp.push(r),r.id}function lT(i,e){e.on("editor: randomize",function(t){const n=i.editor.editor,r=n.cm;let s=r.state.doc.toString(),o=ht(r.state);console.log("RANDIMIZING",n,s,o)}),e.on("editor: add code to top",t=>{i.editor.editor.addCodeToTop(t)}),e.on("editor: format code",()=>{i.editor.editor.formatCode()}),e.on("editor: load code",t=>{i.editor.editor.setValue(t)}),e.on("editor: eval all",function(){const t=i.editor.editor,n=t.getValue();e.emit("repl: eval",n,(r,s)=>{t.flashCode(),s||e.emit("gallery: save to URL",n)})})}var rf={exports:{}},K0={exports:{}};(function(i){i.exports=e;function e(n){if(n)return t(n)}function t(n){for(var r in e.prototype)n[r]=e.prototype[r];return n}e.prototype.on=e.prototype.addEventListener=function(n,r){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(r),this},e.prototype.once=function(n,r){function s(){this.off(n,s),r.apply(this,arguments)}return s.fn=r,this.on(n,s),this},e.prototype.off=e.prototype.removeListener=e.prototype.removeAllListeners=e.prototype.removeEventListener=function(n,r){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var s=this._callbacks["$"+n];if(!s)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var o,a=0;a"u"||!at?be:at(Uint8Array),Un={"%AggregateError%":typeof AggregateError>"u"?be:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?be:ArrayBuffer,"%ArrayIteratorPrototype%":Kn&&at?at([][Symbol.iterator]()):be,"%AsyncFromSyncIteratorPrototype%":be,"%AsyncFunction%":rr,"%AsyncGenerator%":rr,"%AsyncGeneratorFunction%":rr,"%AsyncIteratorPrototype%":rr,"%Atomics%":typeof Atomics>"u"?be:Atomics,"%BigInt%":typeof BigInt>"u"?be:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?be:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?be:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?be:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?be:Float32Array,"%Float64Array%":typeof Float64Array>"u"?be:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?be:FinalizationRegistry,"%Function%":q0,"%GeneratorFunction%":rr,"%Int8Array%":typeof Int8Array>"u"?be:Int8Array,"%Int16Array%":typeof Int16Array>"u"?be:Int16Array,"%Int32Array%":typeof Int32Array>"u"?be:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Kn&&at?at(at([][Symbol.iterator]())):be,"%JSON%":typeof JSON=="object"?JSON:be,"%Map%":typeof Map>"u"?be:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Kn||!at?be:at(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?be:Promise,"%Proxy%":typeof Proxy>"u"?be:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?be:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?be:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Kn||!at?be:at(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?be:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Kn&&at?at(""[Symbol.iterator]()):be,"%Symbol%":Kn?Symbol:be,"%SyntaxError%":Rr,"%ThrowTypeError%":bT,"%TypedArray%":ST,"%TypeError%":Or,"%Uint8Array%":typeof Uint8Array>"u"?be:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?be:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?be:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?be:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?be:WeakMap,"%WeakRef%":typeof WeakRef>"u"?be:WeakRef,"%WeakSet%":typeof WeakSet>"u"?be:WeakSet};if(at)try{null.error}catch(i){var xT=at(at(i));Un["%Error.prototype%"]=xT}var kT=function i(e){var t;if(e==="%AsyncFunction%")t=gu("async function () {}");else if(e==="%GeneratorFunction%")t=gu("function* () {}");else if(e==="%AsyncGeneratorFunction%")t=gu("async function* () {}");else if(e==="%AsyncGenerator%"){var n=i("%AsyncGeneratorFunction%");n&&(t=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var r=i("%AsyncGenerator%");r&&at&&(t=at(r.prototype))}return Un[e]=t,t},ig={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},uo=mc,Xa=wT,MT=uo.call(Function.call,Array.prototype.concat),TT=uo.call(Function.apply,Array.prototype.splice),ng=uo.call(Function.call,String.prototype.replace),Ga=uo.call(Function.call,String.prototype.slice),CT=uo.call(Function.call,RegExp.prototype.exec),ET=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,QT=/\\(\\)?/g,AT=function(e){var t=Ga(e,0,1),n=Ga(e,-1);if(t==="%"&&n!=="%")throw new Rr("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&t!=="%")throw new Rr("invalid intrinsic syntax, expected opening `%`");var r=[];return ng(e,ET,function(s,o,a,l){r[r.length]=a?ng(l,QT,"$1"):o||s}),r},RT=function(e,t){var n=e,r;if(Xa(ig,n)&&(r=ig[n],n="%"+r[0]+"%"),Xa(Un,n)){var s=Un[n];if(s===rr&&(s=kT(n)),typeof s>"u"&&!t)throw new Or("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:s}}throw new Rr("intrinsic "+e+" does not exist!")},yc=function(e,t){if(typeof e!="string"||e.length===0)throw new Or("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof t!="boolean")throw new Or('"allowMissing" argument must be a boolean');if(CT(/^%?[^%]*%?$/,e)===null)throw new Rr("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=AT(e),r=n.length>0?n[0]:"",s=RT("%"+r+"%",t),o=s.name,a=s.value,l=!1,u=s.alias;u&&(r=u[0],TT(n,MT([0,1],u)));for(var h=1,f=!0;h=n.length){var x=Rn(a,c);f=!!x,f&&"get"in x&&!("originalValue"in x.get)?a=x.get:a=a[c]}else f=Xa(a,c),a=a[c];f&&!l&&(Un[o]=a)}}return a},H0={exports:{}};(function(i){var e=mc,t=yc,n=t("%Function.prototype.apply%"),r=t("%Function.prototype.call%"),s=t("%Reflect.apply%",!0)||e.call(r,n),o=t("%Object.getOwnPropertyDescriptor%",!0),a=t("%Object.defineProperty%",!0),l=t("%Math.max%");if(a)try{a({},"a",{value:1})}catch{a=null}i.exports=function(f){var c=s(e,r,arguments);if(o&&a){var p=o(c,"length");p.configurable&&a(c,"length",{value:1+l(0,f.length-(arguments.length-1))})}return c};var u=function(){return s(e,n,arguments)};a?a(i.exports,"apply",{value:u}):i.exports.apply=u})(H0);var UT=H0.exports,e_=yc,t_=UT,$T=t_(e_("String.prototype.indexOf")),PT=function(e,t){var n=e_(e,!!t);return typeof n=="function"&&$T(e,".prototype.")>-1?t_(n):n};const JT={},IT=Object.freeze(Object.defineProperty({__proto__:null,default:JT},Symbol.toStringTag,{value:"Module"})),Lr=Bb(IT);var Oc=typeof Map=="function"&&Map.prototype,yu=Object.getOwnPropertyDescriptor&&Oc?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,Wa=Oc&&yu&&typeof yu.get=="function"?yu.get:null,rg=Oc&&Map.prototype.forEach,_c=typeof Set=="function"&&Set.prototype,Ou=Object.getOwnPropertyDescriptor&&_c?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,Ya=_c&&Ou&&typeof Ou.get=="function"?Ou.get:null,sg=_c&&Set.prototype.forEach,BT=typeof WeakMap=="function"&&WeakMap.prototype,Ss=BT?WeakMap.prototype.has:null,LT=typeof WeakSet=="function"&&WeakSet.prototype,xs=LT?WeakSet.prototype.has:null,jT=typeof WeakRef=="function"&&WeakRef.prototype,og=jT?WeakRef.prototype.deref:null,DT=Boolean.prototype.valueOf,NT=Object.prototype.toString,ZT=Function.prototype.toString,FT=String.prototype.match,wc=String.prototype.slice,nn=String.prototype.replace,XT=String.prototype.toUpperCase,ag=String.prototype.toLowerCase,i_=RegExp.prototype.test,lg=Array.prototype.concat,bi=Array.prototype.join,GT=Array.prototype.slice,ug=Math.floor,sf=typeof BigInt=="function"?BigInt.prototype.valueOf:null,_u=Object.getOwnPropertySymbols,of=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Ur=typeof Symbol=="function"&&typeof Symbol.iterator=="object",bt=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Ur||"symbol")?Symbol.toStringTag:null,n_=Object.prototype.propertyIsEnumerable,hg=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(i){return i.__proto__}:null);function fg(i,e){if(i===1/0||i===-1/0||i!==i||i&&i>-1e3&&i<1e3||i_.call(/e/,e))return e;var t=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof i=="number"){var n=i<0?-ug(-i):ug(i);if(n!==i){var r=String(n),s=wc.call(e,r.length+1);return nn.call(r,t,"$&_")+"."+nn.call(nn.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return nn.call(e,t,"$&_")}var af=Lr,cg=af.custom,dg=s_(cg)?cg:null,WT=function i(e,t,n,r){var s=t||{};if(Ki(s,"quoteStyle")&&s.quoteStyle!=="single"&&s.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(Ki(s,"maxStringLength")&&(typeof s.maxStringLength=="number"?s.maxStringLength<0&&s.maxStringLength!==1/0:s.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var o=Ki(s,"customInspect")?s.customInspect:!0;if(typeof o!="boolean"&&o!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(Ki(s,"indent")&&s.indent!==null&&s.indent!==" "&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(Ki(s,"numericSeparator")&&typeof s.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=s.numericSeparator;if(typeof e>"u")return"undefined";if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return a_(e,s);if(typeof e=="number"){if(e===0)return 1/0/e>0?"0":"-0";var l=String(e);return a?fg(e,l):l}if(typeof e=="bigint"){var u=String(e)+"n";return a?fg(e,u):u}var h=typeof s.depth>"u"?5:s.depth;if(typeof n>"u"&&(n=0),n>=h&&h>0&&typeof e=="object")return lf(e)?"[Array]":"[Object]";var f=fC(s,n);if(typeof r>"u")r=[];else if(o_(r,e)>=0)return"[Circular]";function c(V,ee,B){if(ee&&(r=GT.call(r),r.push(ee)),B){var Z={depth:s.depth};return Ki(s,"quoteStyle")&&(Z.quoteStyle=s.quoteStyle),i(V,Z,n+1,r)}return i(V,s,n+1,r)}if(typeof e=="function"&&!pg(e)){var p=iC(e),v=$o(e,c);return"[Function"+(p?": "+p:" (anonymous)")+"]"+(v.length>0?" { "+bi.call(v,", ")+" }":"")}if(s_(e)){var x=Ur?nn.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):of.call(e);return typeof e=="object"&&!Ur?is(x):x}if(lC(e)){for(var m="<"+ag.call(String(e.nodeName)),d=e.attributes||[],b=0;b",m}if(lf(e)){if(e.length===0)return"[]";var A=$o(e,c);return f&&!hC(A)?"["+uf(A,f)+"]":"[ "+bi.call(A,", ")+" ]"}if(VT(e)){var S=$o(e,c);return!("cause"in Error.prototype)&&"cause"in e&&!n_.call(e,"cause")?"{ ["+String(e)+"] "+bi.call(lg.call("[cause]: "+c(e.cause),S),", ")+" }":S.length===0?"["+String(e)+"]":"{ ["+String(e)+"] "+bi.call(S,", ")+" }"}if(typeof e=="object"&&o){if(dg&&typeof e[dg]=="function"&&af)return af(e,{depth:h-n});if(o!=="symbol"&&typeof e.inspect=="function")return e.inspect()}if(nC(e)){var T=[];return rg&&rg.call(e,function(V,ee){T.push(c(ee,e,!0)+" => "+c(V,e))}),gg("Map",Wa.call(e),T,f)}if(oC(e)){var k=[];return sg&&sg.call(e,function(V){k.push(c(V,e))}),gg("Set",Ya.call(e),k,f)}if(rC(e))return wu("WeakMap");if(aC(e))return wu("WeakSet");if(sC(e))return wu("WeakRef");if(qT(e))return is(c(Number(e)));if(eC(e))return is(c(sf.call(e)));if(HT(e))return is(DT.call(e));if(KT(e))return is(c(String(e)));if(!zT(e)&&!pg(e)){var Q=$o(e,c),C=hg?hg(e)===Object.prototype:e instanceof Object||e.constructor===Object,I=e instanceof Object?"":"null prototype",_=!C&&bt&&Object(e)===e&&bt in e?wc.call(mn(e),8,-1):I?"Object":"",j=C||typeof e.constructor!="function"?"":e.constructor.name?e.constructor.name+" ":"",D=j+(_||I?"["+bi.call(lg.call([],_||[],I||[]),": ")+"] ":"");return Q.length===0?D+"{}":f?D+"{"+uf(Q,f)+"}":D+"{ "+bi.call(Q,", ")+" }"}return String(e)};function r_(i,e,t){var n=(t.quoteStyle||e)==="double"?'"':"'";return n+i+n}function YT(i){return nn.call(String(i),/"/g,""")}function lf(i){return mn(i)==="[object Array]"&&(!bt||!(typeof i=="object"&&bt in i))}function zT(i){return mn(i)==="[object Date]"&&(!bt||!(typeof i=="object"&&bt in i))}function pg(i){return mn(i)==="[object RegExp]"&&(!bt||!(typeof i=="object"&&bt in i))}function VT(i){return mn(i)==="[object Error]"&&(!bt||!(typeof i=="object"&&bt in i))}function KT(i){return mn(i)==="[object String]"&&(!bt||!(typeof i=="object"&&bt in i))}function qT(i){return mn(i)==="[object Number]"&&(!bt||!(typeof i=="object"&&bt in i))}function HT(i){return mn(i)==="[object Boolean]"&&(!bt||!(typeof i=="object"&&bt in i))}function s_(i){if(Ur)return i&&typeof i=="object"&&i instanceof Symbol;if(typeof i=="symbol")return!0;if(!i||typeof i!="object"||!of)return!1;try{return of.call(i),!0}catch{}return!1}function eC(i){if(!i||typeof i!="object"||!sf)return!1;try{return sf.call(i),!0}catch{}return!1}var tC=Object.prototype.hasOwnProperty||function(i){return i in this};function Ki(i,e){return tC.call(i,e)}function mn(i){return NT.call(i)}function iC(i){if(i.name)return i.name;var e=FT.call(ZT.call(i),/^function\s*([\w$]+)/);return e?e[1]:null}function o_(i,e){if(i.indexOf)return i.indexOf(e);for(var t=0,n=i.length;te.maxStringLength){var t=i.length-e.maxStringLength,n="... "+t+" more character"+(t>1?"s":"");return a_(wc.call(i,0,e.maxStringLength),e)+n}var r=nn.call(nn.call(i,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,uC);return r_(r,"single",e)}function uC(i){var e=i.charCodeAt(0),t={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return t?"\\"+t:"\\x"+(e<16?"0":"")+XT.call(e.toString(16))}function is(i){return"Object("+i+")"}function wu(i){return i+" { ? }"}function gg(i,e,t,n){var r=n?uf(t,n):bi.call(t,", ");return i+" ("+e+") {"+r+"}"}function hC(i){for(var e=0;e=0)return!1;return!0}function fC(i,e){var t;if(i.indent===" ")t=" ";else if(typeof i.indent=="number"&&i.indent>0)t=bi.call(Array(i.indent+1)," ");else return null;return{base:t,prev:bi.call(Array(e+1),t)}}function uf(i,e){if(i.length===0)return"";var t=` +`+e.prev+e.base;return t+bi.call(i,","+t)+` +`+e.prev}function $o(i,e){var t=lf(i),n=[];if(t){n.length=i.length;for(var r=0;r1;){var t=e.pop(),n=t.obj[t.prop];if(Sn(n)){for(var r=[],s=0;s=48&&u<=57||u>=65&&u<=90||u>=97&&u<=122||s===MC.RFC1738&&(u===40||u===41)){a+=o.charAt(l);continue}if(u<128){a=a+yi[u];continue}if(u<2048){a=a+(yi[192|u>>6]+yi[128|u&63]);continue}if(u<55296||u>=57344){a=a+(yi[224|u>>12]+yi[128|u>>6&63]+yi[128|u&63]);continue}l+=1,u=65536+((u&1023)<<10|o.charCodeAt(l)&1023),a+=yi[240|u>>18]+yi[128|u>>12&63]+yi[128|u>>6&63]+yi[128|u&63]}return a},RC=function(e){for(var t=[{obj:{o:e},prop:"o"}],n=[],r=0;r"u"&&(A=0)}if(typeof l=="function"?d=l(t,d):d instanceof Date?d=f(d):n==="comma"&&Ji(d)&&(d=ya.maybeMap(d,function(Z){return Z instanceof Date?f(Z):Z})),d===null){if(s)return a&&!v?a(t,Ot.encoder,x,"key",c):t;d=""}if(jC(d)||ya.isBuffer(d)){if(a){var k=v?t:a(t,Ot.encoder,x,"key",c);return[p(k)+"="+p(a(d,Ot.encoder,x,"value",c))]}return[p(t)+"="+p(String(d))]}var Q=[];if(typeof d>"u")return Q;var C;if(n==="comma"&&Ji(d))v&&a&&(d=ya.maybeMap(d,a)),C=[{value:d.length>0?d.join(",")||null:void 0}];else if(Ji(l))C=l;else{var I=Object.keys(d);C=u?I.sort(u):I}for(var _=r&&Ji(d)&&d.length===1?t+"[]":t,j=0;j"u"?Ot.allowDots:!!e.allowDots,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:Ot.charsetSentinel,delimiter:typeof e.delimiter>"u"?Ot.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:Ot.encode,encoder:typeof e.encoder=="function"?e.encoder:Ot.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:Ot.encodeValuesOnly,filter:s,format:n,formatter:r,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:Ot.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:Ot.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:Ot.strictNullHandling}},ZC=function(i,e){var t=i,n=NC(e),r,s;typeof n.filter=="function"?(s=n.filter,t=s("",t)):Ji(n.filter)&&(s=n.filter,r=s);var o=[];if(typeof t!="object"||t===null)return"";var a;e&&e.arrayFormat in mg?a=e.arrayFormat:e&&"indices"in e?a=e.indices?"indices":"repeat":a="indices";var l=mg[a];if(e&&"commaRoundTrip"in e&&typeof e.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var u=l==="comma"&&e&&e.commaRoundTrip;r||(r=Object.keys(t)),n.sort&&r.sort(n.sort);for(var h=h_(),f=0;f0?v+p:""},$r=u_,hf=Object.prototype.hasOwnProperty,FC=Array.isArray,ot={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:$r.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},XC=function(i){return i.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},c_=function(i,e){return i&&typeof i=="string"&&e.comma&&i.indexOf(",")>-1?i.split(","):i},GC="utf8=%26%2310003%3B",WC="utf8=%E2%9C%93",YC=function(e,t){var n={__proto__:null},r=t.ignoreQueryPrefix?e.replace(/^\?/,""):e,s=t.parameterLimit===1/0?void 0:t.parameterLimit,o=r.split(t.delimiter,s),a=-1,l,u=t.charset;if(t.charsetSentinel)for(l=0;l-1&&(v=FC(v)?[v]:v),hf.call(n,p)?n[p]=$r.combine(n[p],v):n[p]=v}return n},zC=function(i,e,t,n){for(var r=n?e:c_(e,t),s=i.length-1;s>=0;--s){var o,a=i[s];if(a==="[]"&&t.parseArrays)o=[].concat(r);else{o=t.plainObjects?Object.create(null):{};var l=a.charAt(0)==="["&&a.charAt(a.length-1)==="]"?a.slice(1,-1):a,u=parseInt(l,10);!t.parseArrays&&l===""?o={0:r}:!isNaN(u)&&a!==l&&String(u)===l&&u>=0&&t.parseArrays&&u<=t.arrayLimit?(o=[],o[u]=r):l!=="__proto__"&&(o[l]=r)}r=o}return r},VC=function(e,t,n,r){if(e){var s=n.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e,o=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,l=n.depth>0&&o.exec(s),u=l?s.slice(0,l.index):s,h=[];if(u){if(!n.plainObjects&&hf.call(Object.prototype,u)&&!n.allowPrototypes)return;h.push(u)}for(var f=0;n.depth>0&&(l=a.exec(s))!==null&&f"u"?ot.charset:e.charset;return{allowDots:typeof e.allowDots>"u"?ot.allowDots:!!e.allowDots,allowPrototypes:typeof e.allowPrototypes=="boolean"?e.allowPrototypes:ot.allowPrototypes,allowSparse:typeof e.allowSparse=="boolean"?e.allowSparse:ot.allowSparse,arrayLimit:typeof e.arrayLimit=="number"?e.arrayLimit:ot.arrayLimit,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:ot.charsetSentinel,comma:typeof e.comma=="boolean"?e.comma:ot.comma,decoder:typeof e.decoder=="function"?e.decoder:ot.decoder,delimiter:typeof e.delimiter=="string"||$r.isRegExp(e.delimiter)?e.delimiter:ot.delimiter,depth:typeof e.depth=="number"||e.depth===!1?+e.depth:ot.depth,ignoreQueryPrefix:e.ignoreQueryPrefix===!0,interpretNumericEntities:typeof e.interpretNumericEntities=="boolean"?e.interpretNumericEntities:ot.interpretNumericEntities,parameterLimit:typeof e.parameterLimit=="number"?e.parameterLimit:ot.parameterLimit,parseArrays:e.parseArrays!==!1,plainObjects:typeof e.plainObjects=="boolean"?e.plainObjects:ot.plainObjects,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:ot.strictNullHandling}},qC=function(i,e){var t=KC(e);if(i===""||i===null||typeof i>"u")return t.plainObjects?Object.create(null):{};for(var n=typeof i=="string"?YC(i,t):i,r=t.plainObjects?Object.create(null):{},s=Object.keys(n),o=0;o=s.length?{done:!0}:{done:!1,value:s[l++]}},e:function(v){throw v},f:u}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var h=!0,f=!1,c;return{s:function(){a=a.call(s)},n:function(){var v=a.next();return h=v.done,v},e:function(v){f=!0,c=v},f:function(){try{!h&&a.return!=null&&a.return()}finally{if(f)throw c}}}}function n(s,o){if(s){if(typeof s=="string")return r(s,o);var a=Object.prototype.toString.call(s).slice(8,-1);if(a==="Object"&&s.constructor&&(a=s.constructor.name),a==="Map"||a==="Set")return Array.from(s);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return r(s,o)}}function r(s,o){(o==null||o>s.length)&&(o=s.length);for(var a=0,l=new Array(o);a=this._maxRetries)return!1;if(this._retryCallback)try{var t=this._retryCallback(i,e);if(t===!0)return!0;if(t===!1)return!1}catch(n){console.error(n)}return!!(e&&e.status&&sE.has(e.status)||i&&(i.code&&rE.has(i.code)||i.timeout&&i.code==="ECONNABORTED"||i.crossDomain))};Ce.prototype._retry=function(){return this.clearTimeout(),this.req&&(this.req=null,this.req=this.request()),this._aborted=!1,this.timedout=!1,this.timedoutError=null,this._end()};Ce.prototype.then=function(i,e){var t=this;if(!this._fullfilledPromise){var n=this;this._endCalled&&console.warn("Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises"),this._fullfilledPromise=new Promise(function(r,s){n.on("abort",function(){if(!(t._maxRetries&&t._maxRetries>t._retries)){if(t.timedout&&t.timedoutError){s(t.timedoutError);return}var o=new Error("Aborted");o.code="ABORTED",o.status=t.status,o.method=t.method,o.url=t.url,s(o)}}),n.end(function(o,a){o?s(o):r(a)})})}return this._fullfilledPromise.then(i,e)};Ce.prototype.catch=function(i){return this.then(void 0,i)};Ce.prototype.use=function(i){return i(this),this};Ce.prototype.ok=function(i){if(typeof i!="function")throw new Error("Callback required");return this._okCallback=i,this};Ce.prototype._isResponseOK=function(i){return i?this._okCallback?this._okCallback(i):i.status>=200&&i.status<300:!1};Ce.prototype.get=function(i){return this._header[i.toLowerCase()]};Ce.prototype.getHeader=Ce.prototype.get;Ce.prototype.set=function(i,e){if(za(i)){for(var t in i)Bs(i,t)&&this.set(t,i[t]);return this}return this._header[i.toLowerCase()]=e,this.header[i]=e,this};Ce.prototype.unset=function(i){return delete this._header[i.toLowerCase()],delete this.header[i],this};Ce.prototype.field=function(i,e,t){if(i==null)throw new Error(".field(name, val) name can not be empty");if(this._data)throw new Error(".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()");if(za(i)){for(var n in i)Bs(i,n)&&this.field(n,i[n]);return this}if(Array.isArray(e)){for(var r in e)Bs(e,r)&&this.field(i,e[r]);return this}if(e==null)throw new Error(".field(name, val) val can not be empty");return typeof e=="boolean"&&(e=String(e)),t?this._getFormData().append(i,e,t):this._getFormData().append(i,e),this};Ce.prototype.abort=function(){if(this._aborted)return this;if(this._aborted=!0,this.xhr&&this.xhr.abort(),this.req){if(xu.gte(process.version,"v13.0.0")&&xu.lt(process.version,"v14.0.0"))throw new Error("Superagent does not work in v13 properly with abort() due to Node.js core changes");xu.gte(process.version,"v14.0.0")&&(this.req.destroyed=!0),this.req.abort()}return this.clearTimeout(),this.emit("abort"),this};Ce.prototype._auth=function(i,e,t,n){switch(t.type){case"basic":this.set("Authorization","Basic ".concat(n("".concat(i,":").concat(e))));break;case"auto":this.username=i,this.password=e;break;case"bearer":this.set("Authorization","Bearer ".concat(i));break}return this};Ce.prototype.withCredentials=function(i){return i===void 0&&(i=!0),this._withCredentials=i,this};Ce.prototype.redirects=function(i){return this._maxRedirects=i,this};Ce.prototype.maxResponseSize=function(i){if(typeof i!="number")throw new TypeError("Invalid argument");return this._maxResponseSize=i,this};Ce.prototype.toJSON=function(){return{method:this.method,url:this.url,data:this._data,headers:this._header}};Ce.prototype.send=function(i){var e=za(i),t=this._header["content-type"];if(this._formData)throw new Error(".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()");if(e&&!this._data)Array.isArray(i)?this._data=[]:this._isHost(i)||(this._data={});else if(i&&this._data&&this._isHost(this._data))throw new Error("Can't merge these send calls");if(e&&za(this._data))for(var n in i)Bs(i,n)&&(this._data[n]=i[n]);else typeof i=="string"?(t||this.type("form"),t=this._header["content-type"],t&&(t=t.toLowerCase().trim()),t==="application/x-www-form-urlencoded"?this._data=this._data?"".concat(this._data,"&").concat(i):i:this._data=(this._data||"")+i):this._data=i;return!e||this._isHost(i)?this:(t||this.type("json"),this)};Ce.prototype.sortQuery=function(i){return this._sort=typeof i>"u"?!0:i,this};Ce.prototype._finalizeQueryString=function(){var i=this._query.join("&");if(i&&(this.url+=(this.url.includes("?")?"&":"?")+i),this._query.length=0,this._sort){var e=this.url.indexOf("?");if(e>=0){var t=this.url.slice(e+1).split("&");typeof this._sort=="function"?t.sort(this._sort):t.sort(),this.url=this.url.slice(0,e)+"?"+t.join("&")}}};Ce.prototype._appendQueryString=function(){console.warn("Unsupported")};Ce.prototype._timeoutError=function(i,e,t){if(!this._aborted){var n=new Error("".concat(i+e,"ms exceeded"));n.timeout=e,n.code="ECONNABORTED",n.errno=t,this.timedout=!0,this.timedoutError=n,this.abort(),this.callback(n)}};Ce.prototype._setTimeouts=function(){var i=this;this._timeout&&!this._timer&&(this._timer=setTimeout(function(){i._timeoutError("Timeout of ",i._timeout,"ETIME")},this._timeout)),this._responseTimeout&&!this._responseTimeoutTimer&&(this._responseTimeoutTimer=setTimeout(function(){i._timeoutError("Response timeout of ",i._responseTimeout,"ETIMEDOUT")},this._responseTimeout))};var ku=kl,oE=Ml;function Ml(){}Ml.prototype.get=function(i){return this.header[i.toLowerCase()]};Ml.prototype._setHeaderProperties=function(i){var e=i["content-type"]||"";this.type=ku.type(e);var t=ku.params(e);for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(this[n]=t[n]);this.links={};try{i.link&&(this.links=ku.parseLinks(i.link))}catch{}};Ml.prototype._setStatusProperties=function(i){var e=Math.trunc(i/100);this.statusCode=i,this.status=this.statusCode,this.statusType=e,this.info=e===1,this.ok=e===2,this.redirect=e===3,this.clientError=e===4,this.serverError=e===5,this.error=e===4||e===5?this.toError():!1,this.created=i===201,this.accepted=i===202,this.noContent=i===204,this.badRequest=i===400,this.unauthorized=i===401,this.notAcceptable=i===406,this.forbidden=i===403,this.notFound=i===404,this.unprocessableEntity=i===422};function aE(i){return hE(i)||uE(i)||p_(i)||lE()}function lE(){throw new TypeError(`Invalid attempt to spread non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function uE(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function hE(i){if(Array.isArray(i))return cf(i)}function fE(i,e){var t=typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(!t){if(Array.isArray(i)||(t=p_(i))||e&&i&&typeof i.length=="number"){t&&(i=t);var n=0,r=function(){};return{s:r,n:function(){return n>=i.length?{done:!0}:{done:!1,value:i[n++]}},e:function(u){throw u},f:r}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s=!0,o=!1,a;return{s:function(){t=t.call(i)},n:function(){var u=t.next();return s=u.done,u},e:function(u){o=!0,a=u},f:function(){try{!s&&t.return!=null&&t.return()}finally{if(o)throw a}}}}function p_(i,e){if(i){if(typeof i=="string")return cf(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(i);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return cf(i,e)}}function cf(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=new Array(e);t=B.length?{done:!0}:{done:!1,value:B[N++]}},e:function(de){throw de},f:Y}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var te=!0,se=!1,le;return{s:function(){R=R.call(B)},n:function(){var de=R.next();return te=de.done,de},e:function(de){se=!0,le=de},f:function(){try{!te&&R.return!=null&&R.return()}finally{if(se)throw le}}}}function r(B,Z){if(B){if(typeof B=="string")return s(B,Z);var R=Object.prototype.toString.call(B).slice(8,-1);if(R==="Object"&&B.constructor&&(R=B.constructor.name),R==="Map"||R==="Set")return Array.from(B);if(R==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(R))return s(B,Z)}}function s(B,Z){(Z==null||Z>B.length)&&(Z=B.length);for(var R=0,N=new Array(Z);R"u"?(console.warn("Using browser-only version of superagent in non-browser environment"),o=void 0):o=self;var a=Fn,l=Sv,u=iE,h=nE,f=kl,c=f.isObject,p=f.mixin,v=f.hasOwn,x=oE,m=dE;function d(){}i.exports=function(B,Z){return typeof Z=="function"?new e.Request("GET",B).end(Z):arguments.length===1?new e.Request("GET",B):new e.Request(B,Z)},e=i.exports;var b=e;e.Request=_,b.getXHR=function(){if(o.XMLHttpRequest&&(!o.location||o.location.protocol!=="file:"||!o.ActiveXObject))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch{}try{return new ActiveXObject("Msxml2.XMLHTTP.6.0")}catch{}try{return new ActiveXObject("Msxml2.XMLHTTP.3.0")}catch{}try{return new ActiveXObject("Msxml2.XMLHTTP")}catch{}throw new Error("Browser-only version of superagent could not find XHR")};var A="".trim?function(B){return B.trim()}:function(B){return B.replace(/(^\s*|\s*$)/g,"")};function S(B){if(!c(B))return B;var Z=[];for(var R in B)v(B,R)&&T(Z,R,B[R]);return Z.join("&")}function T(B,Z,R){if(R!==void 0){if(R===null){B.push(encodeURI(Z));return}if(Array.isArray(R)){var N=n(R),Y;try{for(N.s();!(Y=N.n()).done;){var te=Y.value;T(B,Z,te)}}catch(le){N.e(le)}finally{N.f()}}else if(c(R))for(var se in R)v(R,se)&&T(B,"".concat(Z,"[").concat(se,"]"),R[se]);else B.push(encodeURI(Z)+"="+encodeURIComponent(R))}}b.serializeObject=S;function k(B){for(var Z={},R=B.split("&"),N,Y,te=0,se=R.length;te"u"?this.xhr.responseText:null,this.statusText=this.req.xhr.statusText;var Z=this.xhr.status;Z===1223&&(Z=204),this._setStatusProperties(Z),this.headers=Q(this.xhr.getAllResponseHeaders()),this.header=this.headers,this.header["content-type"]=this.xhr.getResponseHeader("content-type"),this._setHeaderProperties(this.header),this.text===null&&B._responseType?this.body=this.xhr.response:this.body=this.req.method==="HEAD"?null:this._parseBody(this.text?this.text:this.xhr.response)}p(I.prototype,x.prototype),I.prototype._parseBody=function(B){var Z=b.parse[this.type];return this.req._parser?this.req._parser(this,B):(!Z&&C(this.type)&&(Z=b.parse["application/json"]),Z&&B&&(B.length>0||B instanceof Object)?Z(B):null)},I.prototype.toError=function(){var B=this.req,Z=B.method,R=B.url,N="cannot ".concat(Z," ").concat(R," (").concat(this.status,")"),Y=new Error(N);return Y.status=this.status,Y.method=Z,Y.url=R,Y},b.Response=I;function _(B,Z){var R=this;this._query=this._query||[],this.method=B,this.url=Z,this.header={},this._header={},this.on("end",function(){var N=null,Y=null;try{Y=new I(R)}catch(se){return N=new Error("Parser is unable to parse the response"),N.parse=!0,N.original=se,R.xhr?(N.rawResponse=typeof R.xhr.responseType>"u"?R.xhr.responseText:R.xhr.response,N.status=R.xhr.status?R.xhr.status:null,N.statusCode=N.status):(N.rawResponse=null,N.status=null),R.callback(N)}R.emit("response",Y);var te;try{R._isResponseOK(Y)||(te=new Error(Y.statusText||Y.text||"Unsuccessful HTTP response"))}catch(se){te=se}te?(te.original=N,te.response=Y,te.status=Y.status,R.callback(te,Y)):R.callback(null,Y)})}a(_.prototype),p(_.prototype,h.prototype),_.prototype.type=function(B){return this.set("Content-Type",b.types[B]||B),this},_.prototype.accept=function(B){return this.set("Accept",b.types[B]||B),this},_.prototype.auth=function(B,Z,R){arguments.length===1&&(Z=""),t(Z)==="object"&&Z!==null&&(R=Z,Z=""),R||(R={type:typeof btoa=="function"?"basic":"auto"});var N=R.encoder?R.encoder:function(Y){if(typeof btoa=="function")return btoa(Y);throw new Error("Cannot use basic auth, btoa is not a function")};return this._auth(B,Z,R,N)},_.prototype.query=function(B){return typeof B!="string"&&(B=S(B)),B&&this._query.push(B),this},_.prototype.attach=function(B,Z,R){if(Z){if(this._data)throw new Error("superagent can't mix .send() and .attach()");this._getFormData().append(B,Z,R||Z.name)}return this},_.prototype._getFormData=function(){return this._formData||(this._formData=new o.FormData),this._formData},_.prototype.callback=function(B,Z){if(this._shouldRetry(B,Z))return this._retry();var R=this._callback;this.clearTimeout(),B&&(this._maxRetries&&(B.retries=this._retries-1),this.emit("error",B)),R(B,Z)},_.prototype.crossDomainError=function(){var B=new Error(`Request has been terminated +Possible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.`);B.crossDomain=!0,B.status=this.status,B.method=this.method,B.url=this.url,this.callback(B)},_.prototype.agent=function(){return console.warn("This is not supported in browser version of superagent"),this},_.prototype.ca=_.prototype.agent,_.prototype.buffer=_.prototype.ca,_.prototype.write=function(){throw new Error("Streaming is not supported in browser version of superagent")},_.prototype.pipe=_.prototype.write,_.prototype._isHost=function(B){return B&&t(B)==="object"&&!Array.isArray(B)&&Object.prototype.toString.call(B)!=="[object Object]"},_.prototype.end=function(B){this._endCalled&&console.warn("Warning: .end() was called twice. This is not supported in superagent"),this._endCalled=!0,this._callback=B||d,this._finalizeQueryString(),this._end()},_.prototype._setUploadTimeout=function(){var B=this;this._uploadTimeout&&!this._uploadTimeoutTimer&&(this._uploadTimeoutTimer=setTimeout(function(){B._timeoutError("Upload timeout of ",B._uploadTimeout,"ETIMEDOUT")},this._uploadTimeout))},_.prototype._end=function(){if(this._aborted)return this.callback(new Error("The request has been aborted even before .end() was called"));var B=this;this.xhr=b.getXHR();var Z=this.xhr,R=this._formData||this._data;this._setTimeouts(),Z.addEventListener("readystatechange",function(){var le=Z.readyState;if(le>=2&&B._responseTimeoutTimer&&clearTimeout(B._responseTimeoutTimer),le===4){var ue;try{ue=Z.status}catch{ue=0}if(!ue)return B.timedout||B._aborted?void 0:B.crossDomainError();B.emit("end")}});var N=function(ue,de){de.total>0&&(de.percent=de.loaded/de.total*100,de.percent===100&&clearTimeout(B._uploadTimeoutTimer)),de.direction=ue,B.emit("progress",de)};if(this.hasListeners("progress"))try{Z.addEventListener("progress",N.bind(null,"download")),Z.upload&&Z.upload.addEventListener("progress",N.bind(null,"upload"))}catch{}Z.upload&&this._setUploadTimeout();try{this.username&&this.password?Z.open(this.method,this.url,!0,this.username,this.password):Z.open(this.method,this.url,!0)}catch(le){return this.callback(le)}if(this._withCredentials&&(Z.withCredentials=!0),!this._formData&&this.method!=="GET"&&this.method!=="HEAD"&&typeof R!="string"&&!this._isHost(R)){var Y=this._header["content-type"],te=this._serializer||b.serialize[Y?Y.split(";")[0]:""];!te&&C(Y)&&(te=b.serialize["application/json"]),te&&(R=te(R))}for(var se in this.header)this.header[se]!==null&&v(this.header,se)&&Z.setRequestHeader(se,this.header[se]);this._responseType&&(Z.responseType=this._responseType),this.emit("request",this),Z.send(typeof R>"u"?null:R)},b.agent=function(){return new m};for(var j=function(){var Z=V[D];m.prototype[Z.toLowerCase()]=function(R,N){var Y=new b.Request(Z,R);return this._setDefaults(Y),N&&Y.end(N),Y}},D=0,V=["GET","POST","OPTIONS","PATCH","PUT","DELETE"];D{this.setSketchFromURL(window.location.search,e)}),this.setRandomSketch=this.setRandomSketch.bind(this)}clear(){this.current=null,this.code=null;let e=window.location.protocol+"//"+window.location.host+window.location.pathname;window.history.pushState({path:e},"",e),this.url=e}setSketchFromURL(e=window.location.search,t){hush(),render(o0);let n=new URLSearchParams(e);this.searchParams=n;let r=n.get("code"),s=n.get("sketch_id"),o=n.get("showCode");if(console.log("code is",r),this.foundSketch=!1,s){var a=this.getExampleById(s);a?(this.setSketch(a),t(this.code,!1)):Mu.get(`${this.state.serverURL}/sketchById`).query({sketch_id:s}).end((l,u)=>{l?(console.log("err getting sketches",l),this.setSketchFromCode(r,t)):(this.sketches=JSON.parse(u.text),this.sketches.length>0?(this.setSketch(this.sketches[0]),this.foundSketch=!0,t(this.code,this.foundSketch)):this.setSketchFromCode(r,t))})}else this.setSketchFromCode(r,t);o==="false"&&(this.emitter.emit("ui: hide all"),this.emitter.emit("hide info"))}setSketchFromCode(e,t){e?(this.code=this.decodeBase64(e),this.foundSketch=!0):this.setRandomSketch(),t(this.code,this.foundSketch)}saveImage(){}setToURL(e){this.searchParams.delete("sketch_id"),this.searchParams.delete("code"),e.sketch_id?(`${e.sketch_id}`,this.searchParams.append("sketch_id",e.sketch_id)):(`${e.sketch_id}${e.code}`,this.searchParams.append("sketch_id",e.sketch_id),this.searchParams.append("code",e.code));let t=window.location.protocol+"//"+window.location.host+window.location.pathname+"?"+this.searchParams.toString();window.history.replaceState({path:t},"",t),this.url=t}encodeBase64(e){return btoa(encodeURIComponent(e))}decodeBase64(e){return decodeURIComponent(atob(e))}setSketch(e){let t=this.decodeBase64(e.code);t.indexOf(Og)<0&&(t=`${Og} ${t} -`),this.code=t,this.current=e,this.setToURL(e)}setRandomSketch(){if(this.examples.length>0){let t;for(t=Math.floor(Math.random()*this.examples.length);t===this.exampleIndex;)t=Math.floor(Math.random()*this.examples.length);this.exampleIndex=t,this.setSketch(this.examples[t])}else{var e="osc(2"+Math.floor(Math.pow(10,Math.random()*2))+")";e+=".color("+Math.random().toFixed(2)+","+Math.random().toFixed(2)+","+Math.random().toFixed(2)+")",e+=".rotate("+Math.random().toFixed(2)+")",e+=".out(o0)",this.code=e}}shareSketch(e,t,n){this.saveSketch(e,()=>{console.log("URL is",this.url,"sketch is",this.current),t.getScreenImage(r=>{$u.post(`${this.state.serverURL}/image`).attach("previewImage",r).query({url:this.url,sketch_id:this.current.sketch_id,name:n}).end((s,o)=>{s?console.log("error postingimage",s):console.log("image response",o.text)})})})}saveSketch(e,t){let n=this,r=this.encodeBase64(e),s={code:r,parent:this.current?this.current.sketch_id:null};console.log("saving in gallery",s),$u.post(`${this.state.serverURL}/sketch`).query(s).end((o,a)=>{o?(console.log("error posting sketch",o),t&&t(o)):(console.log("response",a.text),n.setSketch({sketch_id:a.text,code:r}),t&&t(null))})}saveLocally(e){let t=this.encodeBase64(e);this.searchParams.delete("sketch_id"),this.searchParams.delete("code"),this.searchParams.append("code",t);var n=this.searchParams.toString();let r=window.location.protocol+"//"+window.location.host+window.location.pathname+"?"+n;window.history.pushState({path:r},"",r),this.url=r}getExampleById(e){var t=this.examples.filter(n=>n.sketch_id===e);return t.length<=0&&(t=this.sketches.filter(n=>n.sketch_id===e)),t[0]}}let zi;function WQ(i,e){e.on("DOMContentLoaded",function(){zi=new GQ((t,n)=>{e.emit("load and eval code",t,!1),n?e.emit("ui: hide info"):e.emit("ui: show info"),e.emit("render")},i,e),i.gallery=zi}),e.on("gallery: save to URL",function(t){zi.saveLocally(t)}),e.on("gallery: clear",()=>{zi.clear()}),e.on("gallery:shareSketch",function(){const n=i.editor.editor.getValue();e.emit("repl: eval",n,(r,s)=>{s?console.warn(s):YQ(o=>{zi.shareSketch(n,i.hydra.hydra,o)},()=>{})})}),e.on("gallery:showExample",()=>{const t=i.editor.editor;e.emit("clear all"),zi.setRandomSketch(),e.emit("repl: eval",zi.code),t.setValue(zi.code)})}function YQ(i,e){var t=prompt(` +`),this.code=t,this.current=e,this.setToURL(e)}setRandomSketch(){if(this.examples.length>0){let t;for(t=Math.floor(Math.random()*this.examples.length);t===this.exampleIndex;)t=Math.floor(Math.random()*this.examples.length);this.exampleIndex=t,this.setSketch(this.examples[t])}else{var e="osc(2"+Math.floor(Math.pow(10,Math.random()*2))+")";e+=".color("+Math.random().toFixed(2)+","+Math.random().toFixed(2)+","+Math.random().toFixed(2)+")",e+=".rotate("+Math.random().toFixed(2)+")",e+=".out(o0)",this.code=e}}shareSketch(e,t,n){this.saveSketch(e,()=>{console.log("URL is",this.url,"sketch is",this.current),t.getScreenImage(r=>{Mu.post(`${this.state.serverURL}/image`).attach("previewImage",r).query({url:this.url,sketch_id:this.current.sketch_id,name:n}).end((s,o)=>{s?console.log("error postingimage",s):console.log("image response",o.text)})})})}saveSketch(e,t){let n=this,r=this.encodeBase64(e),s={code:r,parent:this.current?this.current.sketch_id:null};console.log("saving in gallery",s),Mu.post(`${this.state.serverURL}/sketch`).query(s).end((o,a)=>{o?(console.log("error posting sketch",o),t&&t(o)):(console.log("response",a.text),n.setSketch({sketch_id:a.text,code:r}),t&&t(null))})}saveLocally(e){let t=this.encodeBase64(e);this.searchParams.delete("sketch_id"),this.searchParams.delete("code"),this.searchParams.append("code",t);var n=this.searchParams.toString();let r=window.location.protocol+"//"+window.location.host+window.location.pathname+"?"+n;window.history.pushState({path:r},"",r),this.url=r}getExampleById(e){var t=this.examples.filter(n=>n.sketch_id===e);return t.length<=0&&(t=this.sketches.filter(n=>n.sketch_id===e)),t[0]}}let Wi;function yE(i,e){e.on("DOMContentLoaded",function(){Wi=new mE((t,n)=>{e.emit("load and eval code",t,!1),n?e.emit("ui: hide info"):e.emit("ui: show info"),e.emit("render")},i,e),i.gallery=Wi}),e.on("gallery: save to URL",function(t){Wi.saveLocally(t)}),e.on("gallery: clear",()=>{Wi.clear()}),e.on("gallery:shareSketch",function(){const n=i.editor.editor.getValue();e.emit("repl: eval",n,(r,s)=>{s?console.warn(s):OE(o=>{Wi.shareSketch(n,i.hydra.hydra,o)},()=>{})})}),e.on("gallery:showExample",()=>{const t=i.editor.editor;e.emit("clear all"),Wi.setRandomSketch(),e.emit("repl: eval",Wi.code),t.setValue(Wi.code)})}function OE(i,e){var t=prompt(` HYDRA SKETCH GALLERY /////////////////////////////////////// -🎨 Click 'OK' to add your sketch and screenshot to the gallery of hydra sketches at https://botsin.space/@hydra. +🎨 Add your sketch to the gallery of hydra sketches at https://botsin.space/@hydra. + +✍️ Type your name, mastodon handle, or a short description below, and then press 'OK' to share. ‼️ Make sure you are ready to share - there is no undo button! 💖 Thank you for sharing! You are also warmly invited to join the the live coding server on the fediverse at https://social.toplap.org/. -`,"your name, mastodon handle, and/or a short description");t!==null?i(t):e()}var zQ=VQ,$g={class:"className",for:"htmlFor","http-equiv":"httpEquiv"};function VQ(i){return function(e,t,n){for(var r in t)r in $g&&(t[$g[r]]=t[r],delete t[r]);return i(e,t,n)}}var KQ=zQ,Hn=0,_i=1,Tt=2,jo=3,Ht=4,Xe=5,Pu=6,bn=7,st=8,or=9,ar=10,ss=11,vn=12,er=13,qQ=function(i,e){e||(e={});var t=e.concat||function(r,s){return String(r)+String(s)};return e.attrToProp!==!1&&(i=KQ(i)),function(r){for(var s=_i,o="",a=arguments.length,l=[],u=0;u1&&(v.pop(),v[v.length-1][0][2][d]=i(x[0],x[1],x[2].length?x[2]:void 0))}else if(m===Tt){var b=[f[1],{},[]];x[2].push(b),v.push([b,x[2].length-1])}else if(m===Xe||m===Hn&&f[1]===Xe){for(var A="",S;u1&&/^\s*$/.test(p[2][0])&&p[2].shift(),p[2].length>2||p[2].length===2&&/\S/.test(p[2][1])){if(e.createFragment)return e.createFragment(p[2]);throw new Error("multiple root elements must be wrapped in an enclosing tag")}return Array.isArray(p[2][0])&&typeof p[2][0][0]=="string"&&Array.isArray(p[2][0][2])&&(p[2][0]=i(p[2][0][0],p[2][0][1],p[2][0][2])),p[2][0];function k(Q){var C=[];s===bn&&(s=Ht);for(var I=0;I"&&!HQ(s)&&s!==er?(s===Tt&&o.length?C.push([Tt,o]):s===Xe?C.push([Xe,o]):s===st&&o.length&&C.push([st,o]),C.push([jo]),o="",s=_i):s===er&&/-$/.test(o)&&_==="-"?(e.comments&&C.push([st,o.substr(0,o.length-1)]),o="",s=_i):s===Tt&&/^!--$/.test(o)?(e.comments&&C.push([Tt,o],[Xe,"comment"],[ss]),o=_,s=er):s===_i||s===er?o+=_:s===Tt&&_==="/"&&o.length||(s===Tt&&/\s/.test(_)?(o.length&&C.push([Tt,o]),o="",s=Ht):s===Tt?o+=_:s===Ht&&/[^\s"'=/]/.test(_)?(s=Xe,o=_):s===Ht&&/\s/.test(_)?(o.length&&C.push([Xe,o]),C.push([vn])):s===Xe&&/\s/.test(_)?(C.push([Xe,o]),o="",s=Pu):s===Xe&&_==="="?(C.push([Xe,o],[ss]),o="",s=bn):s===Xe?o+=_:(s===Pu||s===Ht)&&_==="="?(C.push([ss]),s=bn):(s===Pu||s===Ht)&&!/\s/.test(_)?(C.push([vn]),/[\w-]/.test(_)?(o+=_,s=Xe):s=Ht):s===bn&&_==='"'?s=ar:s===bn&&_==="'"?s=or:s===ar&&_==='"'?(C.push([st,o],[vn]),o="",s=Ht):s===or&&_==="'"?(C.push([st,o],[vn]),o="",s=Ht):s===bn&&!/\s/.test(_)?(s=st,I--):s===st&&/\s/.test(_)?(C.push([st,o],[vn]),o="",s=Ht):(s===st||s===or||s===ar)&&(o+=_))}return s===_i&&o.length?(C.push([_i,o]),o=""):s===st&&o.length?(C.push([st,o]),o=""):s===ar&&o.length?(C.push([st,o]),o=""):s===or&&o.length?(C.push([st,o]),o=""):s===Xe&&(C.push([Xe,o]),o=""),C}};function n(r){return typeof r=="function"||typeof r=="string"||r&&typeof r=="object"||r==null?r:t("",r)}};function HQ(i){return i===or||i===ar}var eA=RegExp("^("+["area","base","basefont","bgsound","br","col","command","embed","frame","hr","img","input","isindex","keygen","link","meta","param","source","track","wbr","!--","animate","animateTransform","circle","cursor","desc","ellipse","feBlend","feColorMatrix","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","font-face-format","font-face-name","font-face-uri","glyph","glyphRef","hkern","image","line","missing-glyph","mpath","path","polygon","polyline","rect","set","stop","tref","use","view","vkern"].join("|")+")(?:[.#][a-zA-Z0-9-￿_:-]+)*$");function tA(i){return eA.test(i)}var Do=/\n[\s]+$/,No=/^\n[\s]+/,Pg=/[\s]+$/,Jg=/^[\s]+/,Zo=/[\n\s]+/g,Ig=["a","abbr","b","bdi","bdo","br","cite","data","dfn","em","i","kbd","mark","q","rp","rt","rtc","ruby","s","amp","small","span","strong","sub","sup","time","u","var","wbr"],Fo=["code","pre","textarea"],iA=function i(e,t){if(Array.isArray(t))for(var n=e.nodeName.toLowerCase(),r=!1,s,o,a=0,l=t.length;au=>e(l,u),s=(l,u,h,f)=>Ve` +`,"");t!==null?i(t):e()}var _E=wE,_g={class:"className",for:"htmlFor","http-equiv":"httpEquiv"};function wE(i){return function(e,t,n){for(var r in t)r in _g&&(t[_g[r]]=t[r],delete t[r]);return i(e,t,n)}}var bE=_E,qn=0,Oi=1,Tt=2,Io=3,qt=4,Xe=5,Tu=6,wn=7,st=8,sr=9,or=10,ns=11,bn=12,Hn=13,vE=function(i,e){e||(e={});var t=e.concat||function(r,s){return String(r)+String(s)};return e.attrToProp!==!1&&(i=bE(i)),function(r){for(var s=Oi,o="",a=arguments.length,l=[],u=0;u1&&(v.pop(),v[v.length-1][0][2][d]=i(x[0],x[1],x[2].length?x[2]:void 0))}else if(m===Tt){var b=[f[1],{},[]];x[2].push(b),v.push([b,x[2].length-1])}else if(m===Xe||m===qn&&f[1]===Xe){for(var A="",S;u1&&/^\s*$/.test(p[2][0])&&p[2].shift(),p[2].length>2||p[2].length===2&&/\S/.test(p[2][1])){if(e.createFragment)return e.createFragment(p[2]);throw new Error("multiple root elements must be wrapped in an enclosing tag")}return Array.isArray(p[2][0])&&typeof p[2][0][0]=="string"&&Array.isArray(p[2][0][2])&&(p[2][0]=i(p[2][0][0],p[2][0][1],p[2][0][2])),p[2][0];function k(Q){var C=[];s===wn&&(s=qt);for(var I=0;I"&&!SE(s)&&s!==Hn?(s===Tt&&o.length?C.push([Tt,o]):s===Xe?C.push([Xe,o]):s===st&&o.length&&C.push([st,o]),C.push([Io]),o="",s=Oi):s===Hn&&/-$/.test(o)&&_==="-"?(e.comments&&C.push([st,o.substr(0,o.length-1)]),o="",s=Oi):s===Tt&&/^!--$/.test(o)?(e.comments&&C.push([Tt,o],[Xe,"comment"],[ns]),o=_,s=Hn):s===Oi||s===Hn?o+=_:s===Tt&&_==="/"&&o.length||(s===Tt&&/\s/.test(_)?(o.length&&C.push([Tt,o]),o="",s=qt):s===Tt?o+=_:s===qt&&/[^\s"'=/]/.test(_)?(s=Xe,o=_):s===qt&&/\s/.test(_)?(o.length&&C.push([Xe,o]),C.push([bn])):s===Xe&&/\s/.test(_)?(C.push([Xe,o]),o="",s=Tu):s===Xe&&_==="="?(C.push([Xe,o],[ns]),o="",s=wn):s===Xe?o+=_:(s===Tu||s===qt)&&_==="="?(C.push([ns]),s=wn):(s===Tu||s===qt)&&!/\s/.test(_)?(C.push([bn]),/[\w-]/.test(_)?(o+=_,s=Xe):s=qt):s===wn&&_==='"'?s=or:s===wn&&_==="'"?s=sr:s===or&&_==='"'?(C.push([st,o],[bn]),o="",s=qt):s===sr&&_==="'"?(C.push([st,o],[bn]),o="",s=qt):s===wn&&!/\s/.test(_)?(s=st,I--):s===st&&/\s/.test(_)?(C.push([st,o],[bn]),o="",s=qt):(s===st||s===sr||s===or)&&(o+=_))}return s===Oi&&o.length?(C.push([Oi,o]),o=""):s===st&&o.length?(C.push([st,o]),o=""):s===or&&o.length?(C.push([st,o]),o=""):s===sr&&o.length?(C.push([st,o]),o=""):s===Xe&&(C.push([Xe,o]),o=""),C}};function n(r){return typeof r=="function"||typeof r=="string"||r&&typeof r=="object"||r==null?r:t("",r)}};function SE(i){return i===sr||i===or}var xE=RegExp("^("+["area","base","basefont","bgsound","br","col","command","embed","frame","hr","img","input","isindex","keygen","link","meta","param","source","track","wbr","!--","animate","animateTransform","circle","cursor","desc","ellipse","feBlend","feColorMatrix","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","font-face-format","font-face-name","font-face-uri","glyph","glyphRef","hkern","image","line","missing-glyph","mpath","path","polygon","polyline","rect","set","stop","tref","use","view","vkern"].join("|")+")(?:[.#][a-zA-Z0-9-￿_:-]+)*$");function kE(i){return xE.test(i)}var Bo=/\n[\s]+$/,Lo=/^\n[\s]+/,wg=/[\s]+$/,bg=/^[\s]+/,jo=/[\n\s]+/g,vg=["a","abbr","b","bdi","bdo","br","cite","data","dfn","em","i","kbd","mark","q","rp","rt","rtc","ruby","s","amp","small","span","strong","sub","sup","time","u","var","wbr"],Do=["code","pre","textarea"],ME=function i(e,t){if(Array.isArray(t))for(var n=e.nodeName.toLowerCase(),r=!1,s,o,a=0,l=t.length;au=>e(l,u),s=(l,u,h,f)=>Ve` `,o=i.showInfo?s("close","fa-times",n("toolbar.hide-info"),"ui: toggle info"):s("close","fa-question-circle",n("toolbar.show-info"),"ui: toggle info"),a=i.showExtensions?s("close","fa-question-circle",n("toolbar.show-info"),"ui: hide extensions"):s("add","fa-solid fa-puzzle-piece",n("toolbar.load-extension"),"ui: show extensions");return Ve`
${s("run",`fa-play-circle ${t}`,n("toolbar.run"),"editor: eval all")} ${s("clear",`fa fa-trash ${t}`,n("toolbar.clear"),"clear all")} @@ -64,20 +61,20 @@ HYDRA SKETCH GALLERY ${s("mutator",`fa-dice ${t}`,n("toolbar.random"),"editor: randomize")} ${i.serverURL===null?"":s("share",`fa-upload ${t}`,n("toolbar.upload"),"gallery:shareSketch")} ${o} -
`}const vA=({content:i,header:e},t,n)=>{t.translation;const r=t.translation.selectedLanguage==="ar"&&t.showInfo===!0?"rtl":"ltr";return Ve` + `}const GE=({content:i,header:e},t,n)=>{t.translation;const r=t.translation.selectedLanguage==="ar"&&t.showInfo===!0?"rtl":"ltr";return Ve`
-`},SA=(i,e,t)=>()=>t(i,e),Bg=(i,e,t,n)=>Ve` -`,xA=(i,e,t,n)=>Ve`
()=>t(i,e),Sg=(i,e,t,n)=>Ve` +`,YE=(i,e,t,n)=>Ve`
@@ -87,16 +84,16 @@ HYDRA SKETCH GALLERY
- ${Bg("add-extension","fa-solid fa-plus",n("extensions.show-library",{"extension-name":i.name}),SA("extensions: add to editor",e,t))} - ${Bg("show-documentation","fa-book-open",n("extensions.show-docs",{"extension-name":i.name}),()=>{window.open(i.documentation,"_blank")})} + ${Sg("add-extension","fa-solid fa-plus",n("extensions.show-library",{"extension-name":i.name}),WE("extensions: add to editor",e,t))} + ${Sg("show-documentation","fa-book-open",n("extensions.show-docs",{"extension-name":i.name}),()=>{window.open(i.documentation,"_blank")})}
${i.examples.map((r,s)=>Ve`
{t("extensions: load example",e,s)}}>${s+1}
`)}
-
`,kA=(i,e)=>{const{categories:t,selectedCategoryIndex:n}=i.extensions,r=t[n].entries,{t:s}=i.translation,o=Ve``,zE=(i,e)=>{const{categories:t,selectedCategoryIndex:n}=i.extensions,r=t[n].entries,{t:s}=i.translation,o=Ve` `,a=Ve`
@@ -104,7 +101,7 @@ ${r.map((l,u)=>xA(l,u,e,s))} class="language-select ${u===n?"selected":""}" onclick=${()=>e("extensions: select category",u)} >${l.name}
`)} -
`;return{content:o,header:a}},ei=i=>`href=${i} target=_blank`,MA=i=>Ve` + `;return{content:o,header:a}},Ht=i=>`href=${i} target=_blank`,VE=i=>Ve` `;function TA(i,e){const{t,languages:n}=i.translation,r=Object.entries(n),s=Ve`
`,o=Ve` +

${ds(i("info.support",{"open-collective":Ht("https://opencollective.com/hydra-synth")}))}

+`;function KE(i,e){const{t,languages:n}=i.translation,r=Object.entries(n),s=Ve`
`,o=Ve` ${i.showInfo&&r.length>1?Ve`
${r.map(([l,u])=>Ve`
e("set language",l)}>${u}
`)}
`:Ve`
`} - ${MA(t)} - `,a=i.showExtensions?kA(i,e):{content:o,header:s};return vA(a,i,e)}var Lg=typeof lt<"u"?lt:typeof window<"u"?window:{},CA=Dr,ys;typeof document<"u"?ys=document:(ys=Lg["__GLOBAL_DOCUMENT_CACHE@4"],ys||(ys=Lg["__GLOBAL_DOCUMENT_CACHE@4"]=CA));var $_=ys,Rl={exports:{}},Os;typeof window<"u"?Os=window:typeof lt<"u"?Os=lt:typeof self<"u"?Os=self:Os={};var EA=Os,Ju=$_,jg=EA,mt=Object.create(null),P_="onloadid"+Math.random().toString(36).slice(2),jn="data-"+P_,Iu=0;if(jg&&jg.MutationObserver){var QA=new MutationObserver(function(i){if(!(Object.keys(mt).length<1))for(var e=0;e0&&vf(i[n].childNodes,e)}}var UA=Rl.exports,$A=I_;class J_ extends Error{}J_.prototype.name="AssertionError";function I_(i,e){if(!i){var t=new J_(e);throw Error.captureStackTrace&&Error.captureStackTrace(t,I_),t}}const B_=$_,_s=ic,PA=hO,$c=UA,Sf=$A,JA=$c.KEY_ID,IA=$c.KEY_ATTR;var BA=$t;function LA(){return"ncid-"+Math.floor((1+Math.random())*65536).toString(16).substring(1)}$t.makeID=LA;function $t(i){this._hasWindow=typeof window<"u",this._id=null,this._ncID=null,this._olID=null,this._proxy=null,this._loaded=!1,this._rootNodeName=null,this._name=i||"nanocomponent",this._rerender=!1,this._handleLoad=this._handleLoad.bind(this),this._handleUnload=this._handleUnload.bind(this),this._arguments=[];const e=this;Object.defineProperty(this,"element",{get:function(){const t=B_.getElementById(e._id);if(t)return t.dataset.nanocomponent===e._ncID?t:void 0}})}$t.prototype.render=function(){const i=_s(this._name+".render"),e=this,t=new Array(arguments.length);let n;for(let r=0;r{r.setup=()=>{r.createCanvas(e,t,r[n])},r.draw=()=>{}},"hydra-ui"),this.width=e,this.height=t,this.mode=n,this.canvas.style.position="absolute",this.canvas.style.top="0px",this.canvas.style.left="0px",this.canvas.style.zIndex=-1}show(){this.canvas.style.visibility="visible"}hide(){this.canvas.style.visibility="hidden"}clear(){this.drawingContext.clearRect(0,0,this.canvas.width,this.canvas.height)}}var xf={exports:{}},NA=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,ZA=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],j_=function(e){var t=e,n=e.indexOf("["),r=e.indexOf("]");n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));for(var s=NA.exec(e||""),o={},a=14;a--;)o[ZA[a]]=s[a]||"";return n!=-1&&r!=-1&&(o.source=t,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=FA(o,o.path),o.queryKey=XA(o,o.query),o};function FA(i,e){var t=/\/{2,9}/g,n=e.replace(t,"/").split("/");return(e.substr(0,1)=="/"||e.length===0)&&n.splice(0,1),e.substr(e.length-1,1)=="/"&&n.splice(n.length-1,1),n}function XA(i,e){var t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(n,r,s){r&&(t[r]=s)}),t}var kf={exports:{}},Mf={exports:{}},Ds=1e3,Ns=Ds*60,Zs=Ns*60,Fs=Zs*24,GA=Fs*365.25,WA=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return YA(i);if(t==="number"&&isNaN(i)===!1)return e.long?VA(i):zA(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function YA(i){if(i=String(i),!(i.length>100)){var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(i);if(e){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*GA;case"days":case"day":case"d":return t*Fs;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Zs;case"minutes":case"minute":case"mins":case"min":case"m":return t*Ns;case"seconds":case"second":case"secs":case"sec":case"s":return t*Ds;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function zA(i){return i>=Fs?Math.round(i/Fs)+"d":i>=Zs?Math.round(i/Zs)+"h":i>=Ns?Math.round(i/Ns)+"m":i>=Ds?Math.round(i/Ds)+"s":i+"ms"}function VA(i){return Xo(i,Fs,"day")||Xo(i,Zs,"hour")||Xo(i,Ns,"minute")||Xo(i,Ds,"second")||i+" ms"}function Xo(i,e,t){if(!(i=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}e.formatters.j=function(l){try{return JSON.stringify(l)}catch(u){return"[UnexpectedJSONParseError]: "+u.message}};function n(l){var u=this.useColors;if(l[0]=(u?"%c":"")+this.namespace+(u?" %c":" ")+l[0]+(u?"%c ":" ")+"+"+e.humanize(this.diff),!!u){var h="color: "+this.color;l.splice(1,0,h,"color: inherit");var f=0,c=0;l[0].replace(/%[a-zA-Z%]/g,function(p){p!=="%%"&&(f++,p==="%c"&&(c=f))}),l.splice(c,0,h)}}function r(){return typeof console=="object"&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function s(l){try{l==null?e.storage.removeItem("debug"):e.storage.debug=l}catch{}}function o(){var l;try{l=e.storage.debug}catch{}return!l&&typeof process<"u"&&"env"in process&&(l={}.DEBUG),l}e.enable(o());function a(){try{return window.localStorage}catch{}}})(kf,kf.exports);var Ul=kf.exports,qA=j_,Zg=Ul("socket.io-client:url"),HA=eR;function eR(i,e){var t=i;e=e||typeof location<"u"&&location,i==null&&(i=e.protocol+"//"+e.host),typeof i=="string"&&(i.charAt(0)==="/"&&(i.charAt(1)==="/"?i=e.protocol+i:i=e.host+i),/^(https?|wss?):\/\//.test(i)||(Zg("protocol-less url %s",i),typeof e<"u"?i=e.protocol+"//"+i:i="https://"+i),Zg("parse %s",i),t=qA(i)),t.port||(/^(http|ws)$/.test(t.protocol)?t.port="80":/^(http|ws)s$/.test(t.protocol)&&(t.port="443")),t.path=t.path||"/";var n=t.host.indexOf(":")!==-1,r=n?"["+t.host+"]":t.host;return t.id=t.protocol+"://"+r+":"+t.port,t.href=t.protocol+"://"+r+(e&&e.port===t.port?"":":"+t.port),t}var $l={},Tf={exports:{}},Cf={exports:{}},Xs=1e3,Gs=Xs*60,Ws=Gs*60,Ys=Ws*24,tR=Ys*365.25,iR=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return nR(i);if(t==="number"&&isNaN(i)===!1)return e.long?sR(i):rR(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function nR(i){if(i=String(i),!(i.length>100)){var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(i);if(e){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*tR;case"days":case"day":case"d":return t*Ys;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Ws;case"minutes":case"minute":case"mins":case"min":case"m":return t*Gs;case"seconds":case"second":case"secs":case"sec":case"s":return t*Xs;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function rR(i){return i>=Ys?Math.round(i/Ys)+"d":i>=Ws?Math.round(i/Ws)+"h":i>=Gs?Math.round(i/Gs)+"m":i>=Xs?Math.round(i/Xs)+"s":i+"ms"}function sR(i){return Go(i,Ys,"day")||Go(i,Ws,"hour")||Go(i,Gs,"minute")||Go(i,Xs,"second")||i+" ms"}function Go(i,e,t){if(!(i=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}e.formatters.j=function(l){try{return JSON.stringify(l)}catch(u){return"[UnexpectedJSONParseError]: "+u.message}};function n(l){var u=this.useColors;if(l[0]=(u?"%c":"")+this.namespace+(u?" %c":" ")+l[0]+(u?"%c ":" ")+"+"+e.humanize(this.diff),!!u){var h="color: "+this.color;l.splice(1,0,h,"color: inherit");var f=0,c=0;l[0].replace(/%[a-zA-Z%]/g,function(p){p!=="%%"&&(f++,p==="%c"&&(c=f))}),l.splice(c,0,h)}}function r(){return typeof console=="object"&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function s(l){try{l==null?e.storage.removeItem("debug"):e.storage.debug=l}catch{}}function o(){var l;try{l=e.storage.debug}catch{}return!l&&typeof process<"u"&&"env"in process&&(l={}.DEBUG),l}e.enable(o());function a(){try{return window.localStorage}catch{}}})(Tf,Tf.exports);var aR=Tf.exports,Pl={},lR={}.toString,D_=Array.isArray||function(i){return lR.call(i)=="[object Array]"},N_=cR,uR=typeof Buffer=="function"&&typeof Buffer.isBuffer=="function",hR=typeof ArrayBuffer=="function",fR=function(i){return typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer};function cR(i){return uR&&Buffer.isBuffer(i)||hR&&(i instanceof ArrayBuffer||fR(i))}var Pc=D_,Z_=N_,F_=Object.prototype.toString,dR=typeof Blob=="function"||typeof Blob<"u"&&F_.call(Blob)==="[object BlobConstructor]",pR=typeof File=="function"||typeof File<"u"&&F_.call(File)==="[object FileConstructor]";Pl.deconstructPacket=function(i){var e=[],t=i.data,n=i;return n.data=Ef(t,e),n.attachments=e.length,{packet:n,buffers:e}};function Ef(i,e){if(!i)return i;if(Z_(i)){var t={_placeholder:!0,num:e.length};return e.push(i),t}else if(Pc(i)){for(var n=new Array(i.length),r=0;r=0&&i.numn&&(t=n),e>=n||e>=t||n===0)return new ArrayBuffer(0);for(var r=new Uint8Array(i),s=new Uint8Array(t-e),o=e,a=0;o=55296&&r<=56319&&t65535&&(n-=65536,r+=nn(n>>>10&1023|55296),n=56320|n&1023),r+=nn(n);return r}function Y_(i,e){if(i>=55296&&i<=57343){if(e)throw Error("Lone surrogate U+"+i.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function Bu(i,e){return nn(i>>e&63|128)}function ER(i,e){if(!(i&4294967168))return nn(i);var t="";return i&4294965248?i&4294901760?i&4292870144||(t=nn(i>>18&7|240),t+=Bu(i,12),t+=Bu(i,6)):(Y_(i,e)||(i=65533),t=nn(i>>12&15|224),t+=Bu(i,6)):t=nn(i>>6&31|192),t+=nn(i&63|128),t}function QR(i,e){e=e||{};for(var t=e.strict!==!1,n=W_(i),r=n.length,s=-1,o,a="";++s=tl)throw Error("Invalid byte index");var i=el[on]&255;if(on++,(i&192)==128)return i&63;throw Error("Invalid continuation byte")}function AR(i){var e,t,n,r,s;if(on>tl)throw Error("Invalid byte index");if(on==tl)return!1;if(e=el[on]&255,on++,!(e&128))return e;if((e&224)==192){if(t=tr(),s=(e&31)<<6|t,s>=128)return s;throw Error("Invalid continuation byte")}if((e&240)==224){if(t=tr(),n=tr(),s=(e&15)<<12|t<<6|n,s>=2048)return Y_(s,i)?s:65533;throw Error("Invalid continuation byte")}if((e&248)==240&&(t=tr(),n=tr(),r=tr(),s=(e&7)<<18|t<<12|n<<6|r,s>=65536&&s<=1114111))return s;throw Error("Invalid UTF-8 detected")}var el,tl,on;function RR(i,e){e=e||{};var t=e.strict!==!1;el=W_(i),tl=el.length,on=0;for(var n=[],r;(r=AR(t))!==!1;)n.push(r);return CR(n)}var UR={version:"2.1.2",encode:QR,decode:RR},Wo={},Fg;function $R(){return Fg||(Fg=1,function(i){Wo.encode=function(e){var t=new Uint8Array(e),n,r=t.length,s="";for(n=0;n>2],s+=i[(t[n]&3)<<4|t[n+1]>>4],s+=i[(t[n+1]&15)<<2|t[n+2]>>6],s+=i[t[n+2]&63];return r%3===2?s=s.substring(0,s.length-1)+"=":r%3===1&&(s=s.substring(0,s.length-2)+"=="),s},Wo.decode=function(e){var t=e.length*.75,n=e.length,r,s=0,o,a,l,u;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);var h=new ArrayBuffer(t),f=new Uint8Array(h);for(r=0;r>4,f[s++]=(a&15)<<4|l>>2,f[s++]=(l&3)<<6|u&63;return h}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")),Wo}var Lu,Xg;function PR(){if(Xg)return Lu;Xg=1;var i=typeof i<"u"?i:typeof WebKitBlobBuilder<"u"?WebKitBlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:!1,e=function(){try{var a=new Blob(["hi"]);return a.size===2}catch{return!1}}(),t=e&&function(){try{var a=new Blob([new Uint8Array([1,2])]);return a.size===2}catch{return!1}}(),n=i&&i.prototype.append&&i.prototype.getBlob;function r(a){return a.map(function(l){if(l.buffer instanceof ArrayBuffer){var u=l.buffer;if(l.byteLength!==u.byteLength){var h=new Uint8Array(l.byteLength);h.set(new Uint8Array(u,l.byteOffset,l.byteLength)),u=h.buffer}return u}return l})}function s(a,l){l=l||{};var u=new i;return r(a).forEach(function(h){u.append(h)}),l.type?u.getBlob(l.type):u.getBlob()}function o(a,l){return new Blob(r(a),l||{})}return typeof Blob<"u"&&(s.prototype=Blob.prototype,o.prototype=Blob.prototype),Lu=function(){return e?t?Blob:o:n?s:void 0}(),Lu}(function(i){var e=OR,t=G_,n=xR,r=kR,s=UR,o;typeof ArrayBuffer<"u"&&(o=$R());var a=typeof navigator<"u"&&/Android/i.test(navigator.userAgent),l=typeof navigator<"u"&&/PhantomJS/i.test(navigator.userAgent),u=a||l;i.protocol=3;var h=i.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},f=e(h),c={type:"error",data:"parser error"},p=PR();i.encodePacket=function(S,T,k,Q){typeof T=="function"&&(Q=T,T=!1),typeof k=="function"&&(Q=k,k=null);var C=S.data===void 0?void 0:S.data.buffer||S.data;if(typeof ArrayBuffer<"u"&&C instanceof ArrayBuffer)return x(S,T,Q);if(typeof p<"u"&&C instanceof p)return d(S,T,Q);if(C&&C.base64)return v(S,Q);var I=h[S.type];return S.data!==void 0&&(I+=k?s.encode(String(S.data),{strict:!1}):String(S.data)),Q(""+I)};function v(S,T){var k="b"+i.packets[S.type]+S.data.data;return T(k)}function x(S,T,k){if(!T)return i.encodeBase64Packet(S,k);var Q=S.data,C=new Uint8Array(Q),I=new Uint8Array(1+Q.byteLength);I[0]=h[S.type];for(var _=0;_1?{type:f[C],data:S.substring(1)}:{type:f[C]}}var Q=new Uint8Array(S),C=Q[0],I=n(S,1);return p&&T==="blob"&&(I=new p([I])),{type:f[C],data:I}};function b(S){try{S=s.decode(S,{strict:!1})}catch{return!1}return S}i.decodeBase64Packet=function(S,T){var k=f[S.charAt(0)];if(!o)return{type:k,data:{base64:!0,data:S.substr(1)}};var Q=o.decode(S.substr(1));return T==="blob"&&p&&(Q=new p([Q])),{type:k,data:Q}},i.encodePayload=function(S,T,k){typeof T=="function"&&(k=T,T=null);var Q=t(S);if(T&&Q)return p&&!u?i.encodePayloadAsBlob(S,k):i.encodePayloadAsArrayBuffer(S,k);if(!S.length)return k("0:");function C(_){return _.length+":"+_}function I(_,j){i.encodePacket(_,Q?T:!1,!1,function(D){j(null,C(D))})}A(S,I,function(_,j){return k(j.join(""))})};function A(S,T,k){for(var Q=new Array(S.length),C=r(S.length,k),I=function(j,D,V){T(D,function(ee,B){Q[j]=B,V(ee,Q)})},_=0;_0;){for(var I=new Uint8Array(Q),_=I[0]===0,j="",D=1;I[D]!==255;D++){if(j.length>310)return k(c,0,1);j+=I[D]}Q=n(Q,2+j.length),j=parseInt(j);var V=n(Q,0,j);if(_)try{V=String.fromCharCode.apply(null,new Uint8Array(V))}catch{var ee=new Uint8Array(V);V="";for(var D=0;D0);return e}function JR(i){var e=0;for(an=0;an0)return LR(i);if(t==="number"&&isNaN(i)===!1)return e.long?DR(i):jR(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function LR(i){if(i=String(i),!(i.length>100)){var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(i);if(e){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*IR;case"days":case"day":case"d":return t*qs;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Ks;case"minutes":case"minute":case"mins":case"min":case"m":return t*Vs;case"seconds":case"second":case"secs":case"sec":case"s":return t*zs;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function jR(i){return i>=qs?Math.round(i/qs)+"d":i>=Ks?Math.round(i/Ks)+"h":i>=Vs?Math.round(i/Vs)+"m":i>=zs?Math.round(i/zs)+"s":i+"ms"}function DR(i){return Yo(i,qs,"day")||Yo(i,Ks,"hour")||Yo(i,Vs,"minute")||Yo(i,zs,"second")||i+" ms"}function Yo(i,e,t){if(!(i=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}e.formatters.j=function(l){try{return JSON.stringify(l)}catch(u){return"[UnexpectedJSONParseError]: "+u.message}};function n(l){var u=this.useColors;if(l[0]=(u?"%c":"")+this.namespace+(u?" %c":" ")+l[0]+(u?"%c ":" ")+"+"+e.humanize(this.diff),!!u){var h="color: "+this.color;l.splice(1,0,h,"color: inherit");var f=0,c=0;l[0].replace(/%[a-zA-Z%]/g,function(p){p!=="%%"&&(f++,p==="%c"&&(c=f))}),l.splice(c,0,h)}}function r(){return typeof console=="object"&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function s(l){try{l==null?e.storage.removeItem("debug"):e.storage.debug=l}catch{}}function o(){var l;try{l=e.storage.debug}catch{}return!l&&typeof process<"u"&&"env"in process&&(l={}.DEBUG),l}e.enable(o());function a(){try{return window.localStorage}catch{}}})(Uf,Uf.exports);var Bl=Uf.exports,q_=jc(),ZR=Zr,H_=Gn,FR=Il,XR=K_,ni=Bl("engine.io-client:polling"),ew=Pi,GR=function(){var i=Bc,e=new i({xdomain:!1});return e.responseType!=null}();function Pi(i){var e=i&&i.forceBase64;(!GR||e)&&(this.supportsBinary=!1),q_.call(this,i)}FR(Pi,q_);Pi.prototype.name="polling";Pi.prototype.doOpen=function(){this.poll()};Pi.prototype.pause=function(i){var e=this;this.readyState="pausing";function t(){ni("paused"),e.readyState="paused",i()}if(this.polling||!this.writable){var n=0;this.polling&&(ni("we are currently polling - waiting to pause"),n++,this.once("pollComplete",function(){ni("pre-pause polling complete"),--n||t()})),this.writable||(ni("we are currently writing - waiting to pause"),n++,this.once("drain",function(){ni("pre-pause writing complete"),--n||t()}))}else t()};Pi.prototype.poll=function(){ni("polling"),this.polling=!0,this.doPoll(),this.emit("poll")};Pi.prototype.onData=function(i){var e=this;ni("polling got data %s",i);var t=function(n,r,s){if(e.readyState==="opening"&&n.type==="open"&&e.onOpen(),n.type==="close")return e.onClose(),!1;e.onPacket(n)};H_.decodePayload(i,this.socket.binaryType,t),this.readyState!=="closed"&&(this.polling=!1,this.emit("pollComplete"),this.readyState==="open"?this.poll():ni('ignoring poll - transport state "%s"',this.readyState))};Pi.prototype.doClose=function(){var i=this;function e(){ni("writing close packet"),i.write([{type:"close"}])}this.readyState==="open"?(ni("transport open - closing"),e()):(ni("transport not open - deferring close"),this.once("open",e))};Pi.prototype.write=function(i){var e=this;this.writable=!1;var t=function(){e.writable=!0,e.emit("drain")};H_.encodePayload(i,this.supportsBinary,function(n){e.doWrite(n,t)})};Pi.prototype.uri=function(){var i=this.query||{},e=this.secure?"https":"http",t="";this.timestampRequests!==!1&&(i[this.timestampParam]=XR()),!this.supportsBinary&&!i.sid&&(i.b64=1),i=ZR.encode(i),this.port&&(e==="https"&&Number(this.port)!==443||e==="http"&&Number(this.port)!==80)&&(t=":"+this.port),i.length&&(i="?"+i);var n=this.hostname.indexOf(":")!==-1;return e+"://"+(n?"["+this.hostname+"]":this.hostname)+t+this.path+i};var WR=Bc,tw=ew,YR=Xn,zR=Il,Pf=Bl("engine.io-client:polling-xhr"),VR=Ic;Lc.exports=Fr;Lc.exports.Request=rt;function zg(){}function Fr(i){if(tw.call(this,i),this.requestTimeout=i.requestTimeout,this.extraHeaders=i.extraHeaders,typeof location<"u"){var e=location.protocol==="https:",t=location.port;t||(t=e?443:80),this.xd=typeof location<"u"&&i.hostname!==location.hostname||t!==i.port,this.xs=i.secure!==e}}zR(Fr,tw);Fr.prototype.supportsBinary=!0;Fr.prototype.request=function(i){return i=i||{},i.uri=this.uri(),i.xd=this.xd,i.xs=this.xs,i.agent=this.agent||!1,i.supportsBinary=this.supportsBinary,i.enablesXDR=this.enablesXDR,i.withCredentials=this.withCredentials,i.pfx=this.pfx,i.key=this.key,i.passphrase=this.passphrase,i.cert=this.cert,i.ca=this.ca,i.ciphers=this.ciphers,i.rejectUnauthorized=this.rejectUnauthorized,i.requestTimeout=this.requestTimeout,i.extraHeaders=this.extraHeaders,new rt(i)};Fr.prototype.doWrite=function(i,e){var t=typeof i!="string"&&i!==void 0,n=this.request({method:"POST",data:i,isBinary:t}),r=this;n.on("success",e),n.on("error",function(s){r.onError("xhr post error",s)}),this.sendXhr=n};Fr.prototype.doPoll=function(){Pf("xhr poll");var i=this.request(),e=this;i.on("data",function(t){e.onData(t)}),i.on("error",function(t){e.onError("xhr poll error",t)}),this.pollXhr=i};function rt(i){this.method=i.method||"GET",this.uri=i.uri,this.xd=!!i.xd,this.xs=!!i.xs,this.async=i.async!==!1,this.data=i.data!==void 0?i.data:null,this.agent=i.agent,this.isBinary=i.isBinary,this.supportsBinary=i.supportsBinary,this.enablesXDR=i.enablesXDR,this.withCredentials=i.withCredentials,this.requestTimeout=i.requestTimeout,this.pfx=i.pfx,this.key=i.key,this.passphrase=i.passphrase,this.cert=i.cert,this.ca=i.ca,this.ciphers=i.ciphers,this.rejectUnauthorized=i.rejectUnauthorized,this.extraHeaders=i.extraHeaders,this.create()}YR(rt.prototype);rt.prototype.create=function(){var i={agent:this.agent,xdomain:this.xd,xscheme:this.xs,enablesXDR:this.enablesXDR};i.pfx=this.pfx,i.key=this.key,i.passphrase=this.passphrase,i.cert=this.cert,i.ca=this.ca,i.ciphers=this.ciphers,i.rejectUnauthorized=this.rejectUnauthorized;var e=this.xhr=new WR(i),t=this;try{Pf("xhr open %s: %s",this.method,this.uri),e.open(this.method,this.uri,this.async);try{if(this.extraHeaders){e.setDisableHeaderCheck&&e.setDisableHeaderCheck(!0);for(var n in this.extraHeaders)this.extraHeaders.hasOwnProperty(n)&&e.setRequestHeader(n,this.extraHeaders[n])}}catch{}if(this.method==="POST")try{this.isBinary?e.setRequestHeader("Content-type","application/octet-stream"):e.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{e.setRequestHeader("Accept","*/*")}catch{}"withCredentials"in e&&(e.withCredentials=this.withCredentials),this.requestTimeout&&(e.timeout=this.requestTimeout),this.hasXDR()?(e.onload=function(){t.onLoad()},e.onerror=function(){t.onError(e.responseText)}):e.onreadystatechange=function(){if(e.readyState===2)try{var r=e.getResponseHeader("Content-Type");(t.supportsBinary&&r==="application/octet-stream"||r==="application/octet-stream; charset=UTF-8")&&(e.responseType="arraybuffer")}catch{}e.readyState===4&&(e.status===200||e.status===1223?t.onLoad():setTimeout(function(){t.onError(typeof e.status=="number"?e.status:0)},0))},Pf("xhr data %s",this.data),e.send(this.data)}catch(r){setTimeout(function(){t.onError(r)},0);return}typeof document<"u"&&(this.index=rt.requestsCount++,rt.requests[this.index]=this)};rt.prototype.onSuccess=function(){this.emit("success"),this.cleanup()};rt.prototype.onData=function(i){this.emit("data",i),this.onSuccess()};rt.prototype.onError=function(i){this.emit("error",i),this.cleanup(!0)};rt.prototype.cleanup=function(i){if(!(typeof this.xhr>"u"||this.xhr===null)){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=zg:this.xhr.onreadystatechange=zg,i)try{this.xhr.abort()}catch{}typeof document<"u"&&delete rt.requests[this.index],this.xhr=null}};rt.prototype.onLoad=function(){var i;try{var e;try{e=this.xhr.getResponseHeader("Content-Type")}catch{}e==="application/octet-stream"||e==="application/octet-stream; charset=UTF-8"?i=this.xhr.response||this.xhr.responseText:i=this.xhr.responseText}catch(t){this.onError(t)}i!=null&&this.onData(i)};rt.prototype.hasXDR=function(){return typeof XDomainRequest<"u"&&!this.xs&&this.enablesXDR};rt.prototype.abort=function(){this.cleanup()};rt.requestsCount=0;rt.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Vg);else if(typeof addEventListener=="function"){var KR="onpagehide"in VR?"pagehide":"unload";addEventListener(KR,Vg,!1)}}function Vg(){for(var i in rt.requests)rt.requests.hasOwnProperty(i)&&rt.requests[i].abort()}var qR=Lc.exports,Nc=ew,HR=Il,Kg=Ic,eU=Xr,tU=/\n/g,iU=/\\n/g,zo;function nU(){}function Xr(i){Nc.call(this,i),this.query=this.query||{},zo||(zo=Kg.___eio=Kg.___eio||[]),this.index=zo.length;var e=this;zo.push(function(t){e.onData(t)}),this.query.j=this.index,typeof addEventListener=="function"&&addEventListener("beforeunload",function(){e.script&&(e.script.onerror=nU)},!1)}HR(Xr,Nc);Xr.prototype.supportsBinary=!1;Xr.prototype.doClose=function(){this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),Nc.prototype.doClose.call(this)};Xr.prototype.doPoll=function(){var i=this,e=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),e.async=!0,e.src=this.uri(),e.onerror=function(r){i.onError("jsonp poll error",r)};var t=document.getElementsByTagName("script")[0];t?t.parentNode.insertBefore(e,t):(document.head||document.body).appendChild(e),this.script=e;var n=typeof navigator<"u"&&/gecko/i.test(navigator.userAgent);n&&setTimeout(function(){var r=document.createElement("iframe");document.body.appendChild(r),document.body.removeChild(r)},100)};Xr.prototype.doWrite=function(i,e){var t=this;if(!this.form){var n=document.createElement("form"),r=document.createElement("textarea"),s=this.iframeId="eio_iframe_"+this.index,o;n.className="socketio",n.style.position="absolute",n.style.top="-1000px",n.style.left="-1000px",n.target=s,n.method="POST",n.setAttribute("accept-charset","utf-8"),r.name="d",n.appendChild(r),document.body.appendChild(n),this.form=n,this.area=r}this.form.action=this.uri();function a(){l(),e()}function l(){if(t.iframe)try{t.form.removeChild(t.iframe)}catch(h){t.onError("jsonp polling iframe removal error",h)}try{var u='